Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
feat: add Apache License and new agent-3d files for 3D rendering support
nirholas15e261d5fb75
diff --git a/publish/LICENSE b/publish/LICENSEnew file mode 100644index 000000000..8e2251ab4--- /dev/null+++ b/publish/LICENSE@@ -0,0 +1,180 @@+ Apache License+ Version 2.0, January 2004+ http://www.apache.org/licenses/++ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION++ 1. Definitions.++ "License" shall mean the terms and conditions for use, reproduction,+ and distribution as defined by Sections 1 through 9 of this document.++ "Licensor" shall mean the copyright owner or entity authorized by+ the copyright owner that is granting the License.++ "Legal Entity" shall mean the union of the acting entity and all+ other entities that control, are controlled by, or are under common+ control with that entity. For the purposes of this definition,+ "control" means (i) the power, direct or indirect, to cause the+ direction or management of such entity, whether by contract or+ otherwise, or (ii) ownership of fifty percent (50%) or more of the+ outstanding shares, or (iii) beneficial ownership of such entity.++ "You" (or "Your") shall mean an individual or Legal Entity+ exercising permissions granted by this License.++ "Source" form shall mean the preferred form for making modifications,+ including but not limited to software source code, documentation+ source, and configuration files.++ "Object" form shall mean any form resulting from mechanical+ transformation or translation of a Source form, including but+ not limited to compiled object code, generated documentation,+ and conversions to other media types.++ "Work" shall mean the work of authorship made available under+ the License, as indicated by a copyright notice that is included in+ or attached to the work (an example is provided in the Appendix below).++ "Derivative Works" shall mean any work, whether in Source or Object+ form, that is based on (or derived from) the Work and for which the+ editorial revisions, annotations, elaborations, or other transformations+ represent, as a whole, an original work of authorship. For the purposes+ of this License, Derivative Works shall not include works that remain+ separable from, or merely link (or bind by name) to the interfaces of,+ the Work and Derivative Works thereof.++ "Contribution" shall mean, as submitted to the Licensor for inclusion+ in the Work by the copyright owner or by an individual or Legal Entity+ authorized to submit on behalf of the copyright owner. For the purposes+ of this definition, "submitted" means any form of electronic, verbal,+ or written communication sent to the Licensor or its representatives,+ including but not limited to communication on electronic mailing lists,+ source code control systems, and issue tracking systems that are managed+ by, or on behalf of, the Licensor for the purpose of discussing and+ improving the Work, but excluding communication that is conspicuously+ marked or designated in writing by the copyright owner as "Not a+ Contribution."++ "Contributor" shall mean Licensor and any Legal Entity on behalf of+ whom a Contribution has been received by the Licensor and included+ within the Work.++ 2. Grant of Copyright License. Subject to the terms and conditions of+ this License, each Contributor hereby grants to You a perpetual,+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable+ copyright license to reproduce, prepare Derivative Works of,+ publicly display, publicly perform, sublicense, and distribute the+ Work and such Derivative Works in Source or Object form.++ 3. Grant of Patent License. Subject to the terms and conditions of+ this License, each Contributor hereby grants to You a perpetual,+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable+ (except as stated in this section) patent license to make, have made,+ use, offer to sell, sell, import, and otherwise transfer the Work,+ where such license applies only to those patent claims licensable+ by such Contributor that are necessarily infringed by their+ Contribution(s) alone or by the combination of their Contribution(s)+ with the Work to which such Contribution(s) was submitted. If You+ institute patent litigation against any entity (including a cross-claim+ or counterclaim in a lawsuit) alleging that the Work or any+ Contribution embodied within the Work constitutes direct or contributory+ patent infringement, then any patent licenses granted to You under+ this License for that Work shall terminate as of the date such+ litigation is filed.++ 4. Redistribution. You may reproduce and distribute copies of the+ Work or Derivative Works thereof in any medium, with or without+ modifications, and in Source or Object form, provided that You+ meet the following conditions:++ (a) You must give any other recipients of the Work or Derivative+ Works a copy of this License; and++ (b) You must cause any modified files to carry prominent notices+ stating that You changed the files; and++ (c) You must retain, in the Source form of any Derivative Works+ that You distribute, all copyright, patent, trademark, and+ attribution notices from the Source form of the Work,+ excluding those notices that do not pertain to any part of+ the Derivative Works; and++ (d) If the Work includes a "NOTICE" text file as part of its+ distribution, You must include a readable copy of the+ attribution notices contained within such NOTICE file, in+ at least one of the following places: within a NOTICE text+ file distributed as part of the Derivative Works; within+ the Source form or documentation, if provided along with the+ Derivative Works; or, within a display generated by the+ Derivative Works, if and wherever such third-party notices+ normally appear. The contents of the NOTICE file are for+ informational purposes only and do not modify the License.+ You may add Your own attribution notices within Derivative+ Works that You distribute, alongside or in addition to the+ NOTICE text from the Work, provided that such additional+ attribution notices cannot be construed as modifying the License.++ You may add Your own license statement for Your modifications and+ may provide additional grant of rights to use, copy, modify, merge,+ publish, distribute, sublicense, and/or sell copies of the+ Derivative Works, and to permit persons to whom the Derivative Works+ are furnished to do so.++ 5. Submission of Contributions. Unless You explicitly state otherwise,+ any Contribution intentionally submitted for inclusion in the Work+ by You to the Licensor shall be under the terms and conditions of+ this License, without any additional terms or conditions.+ Notwithstanding the above, nothing herein shall supersede or modify+ the terms of any separate license agreement you may have executed+ with Licensor regarding such Contributions.++ 6. Trademarks. This License does not grant permission to use the trade+ names, trademarks, service marks, or product names of the Licensor,+ except as required for reasonable and customary use in describing the+ origin of the Work and reproducing the content of the NOTICE file.++ 7. Disclaimer of Warranty. Unless required by applicable law or+ agreed to in writing, Licensor provides the Work (and each+ Contributor provides its Contributions) on an "AS IS" BASIS,+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or+ implied, including, without limitation, any warranties or conditions+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A+ PARTICULAR PURPOSE. You are solely responsible for determining the+ appropriateness of using or reproducing the Work and assume any+ risks associated with Your exercise of permissions under this License.++ 8. Limitation of Liability. In no event and under no legal theory,+ whether in tort (including negligence), contract, or otherwise,+ unless required by applicable law (such as deliberate and grossly+ negligent acts) or agreed to in writing, shall any Contributor be+ liable to You for damages, including any direct, indirect, special,+ incidental, or exemplary damages of any character arising as a+ result of this License or out of the use or inability to use the+ Work (including but not limited to damages for loss of goodwill,+ work stoppage, computer failure or malfunction, or all other+ commercial damages or losses), even if such Contributor has been+ advised of the possibility of such damages.++ 9. Accepting Warranty or Additional Liability. While redistributing+ the Work or Derivative Works thereof, You may choose to offer,+ and charge a fee for, acceptance of support, warranty, indemnity,+ or other liability obligations and/or rights consistent with this+ License. However, in accepting such obligations, You may offer only+ conditions consistent with this License.++ END OF TERMS AND CONDITIONS++ Copyright 2026 nirholas++ Licensed under the Apache License, Version 2.0 (the "License");+ you may not use this file except in compliance with the License.+ You may obtain a copy of the License at++ http://www.apache.org/licenses/LICENSE-2.0++ Unless required by applicable law or agreed to in writing, software+ distributed under the License is distributed on an "AS IS" BASIS,+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ See the License for the specific language governing permissions and+ limitations under the License.diff --git a/publish/agent-3d.js b/publish/agent-3d.jsnew file mode 100644index 000000000..1fda16536--- /dev/null+++ b/publish/agent-3d.js@@ -0,0 +1,49848 @@+const da = { ROTATE: 0, DOLLY: 1, PAN: 2 }, sa = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 }, v_ = 0, up = 1, C_ = 2, Hm = 1, S_ = 2, ji = 3, us = 0, Pn = 1, Ni = 2, Ds = 0, fa = 1, dp = 2, fp = 3, pp = 4, I_ = 5, ar = 100, M_ = 101, B_ = 102, T_ = 103, R_ = 104, N_ = 200, F_ = 201, D_ = 202, L_ = 203, Hu = 204, zu = 205, P_ = 206, k_ = 207, U_ = 208, O_ = 209, Q_ = 210, G_ = 211, H_ = 212, z_ = 213, V_ = 214, Vu = 0, Wu = 1, qu = 2, wa = 3, Ku = 4, ju = 5, Xu = 6, Yu = 7, zm = 0, W_ = 1, q_ = 2, Ls = 0, Ju = 1, K_ = 2, j_ = 3, Vm = 4, X_ = 5, Y_ = 6, J_ = 7, Ap = "attached", Z_ = "detached", Wm = 300, Er = 301, va = 302, Zu = 303, $u = 304, jl = 306, Ca = 1e3, _i = 1001, El = 1002, kn = 1003, qm = 1004, fo = 1005, qt = 1006, ul = 1007, si = 1008, rn = 1009, Km = 1010, jm = 1011, To = 1012, ff = 1013, yr = 1014, an = 1015, Nn = 1016, pf = 1017, Af = 1018, Ro = 1020, Xm = 35902, Ym = 1021, Jm = 1022, on = 1023, No = 1026, Fo = 1027, ns = 1028, gf = 1029, dr = 1030, mf = 1031, bf = 1033, dl = 33776, xo = 33777, fl = 33778, _o = 33779, yl = 35840, ed = 35841, wl = 35842, td = 35843, vl = 36196, Cl = 37492, Sl = 37496, Do = 37808, nd = 37809, id = 37810, sd = 37811, Lo = 37812, rd = 37813, ad = 37814, od = 37815, cd = 37816, ld = 37817, hd = 37818, ud = 37819, dd = 37820, fd = 37821, Eo = 36492, pd = 36494, Il = 36495, Zm = 36283, Ad = 36284, gd = 36285, md = 36286, $m = 2200, e0 = 2201, $_ = 2202, Po = 2300, ko = 2301, _h = 2302, ra = 2400, aa = 2401, Ml = 2402, xf = 2500, eE = 2501, tE = 0, t0 = 1, bd = 2, nE = 3200, iE = 3201, n0 = 0, sE = 1, gi = "", Kt = "srgb", ln = "srgb-linear", Bl = "linear", Mt = "srgb", Lr = 7680, gp = 519, rE = 512, aE = 513, oE = 514, i0 = 515, cE = 516, lE = 517, hE = 518, uE = 519, xd = 35044, mp = "300 es", is = 2e3, Tl = 2001;+class zs {+ /**+ * Adds the given event listener to the given event type.+ *+ * @param {string} type - The type of event to listen to.+ * @param {Function} listener - The function that gets called when the event is fired.+ */+ addEventListener(e, t) {+ this._listeners === void 0 && (this._listeners = {});+ const n = this._listeners;+ n[e] === void 0 && (n[e] = []), n[e].indexOf(t) === -1 && n[e].push(t);+ }+ /**+ * Returns `true` if the given event listener has been added to the given event type.+ *+ * @param {string} type - The type of event.+ * @param {Function} listener - The listener to check.+ * @return {boolean} Whether the given event listener has been added to the given event type.+ */+ hasEventListener(e, t) {+ const n = this._listeners;+ return n === void 0 ? !1 : n[e] !== void 0 && n[e].indexOf(t) !== -1;+ }+ /**+ * Removes the given event listener from the given event type.+ *+ * @param {string} type - The type of event.+ * @param {Function} listener - The listener to remove.+ */+ removeEventListener(e, t) {+ const n = this._listeners;+ if (n === void 0) return;+ const s = n[e];+ if (s !== void 0) {+ const r = s.indexOf(t);+ r !== -1 && s.splice(r, 1);+ }+ }+ /**+ * Dispatches an event object.+ *+ * @param {Object} event - The event that gets fired.+ */+ dispatchEvent(e) {+ const t = this._listeners;+ if (t === void 0) return;+ const n = t[e.type];+ if (n !== void 0) {+ e.target = this;+ const s = n.slice(0);+ for (let r = 0, a = s.length; r < a; r++)+ s[r].call(this, e);+ e.target = null;+ }+ }+}+const yn = ["00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "0a", "0b", "0c", "0d", "0e", "0f", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "1a", "1b", "1c", "1d", "1e", "1f", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "2a", "2b", "2c", "2d", "2e", "2f", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "3a", "3b", "3c", "3d", "3e", "3f", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "4a", "4b", "4c", "4d", "4e", "4f", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "5a", "5b", "5c", "5d", "5e", "5f", "60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "6a", "6b", "6c", "6d", "6e", "6f", "70", "71", "72", "73", "74", "75", "76", "77", "78", "79", "7a", "7b", "7c", "7d", "7e", "7f", "80", "81", "82", "83", "84", "85", "86", "87", "88", "89", "8a", "8b", "8c", "8d", "8e", "8f", "90", "91", "92", "93", "94", "95", "96", "97", "98", "99", "9a", "9b", "9c", "9d", "9e", "9f", "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "aa", "ab", "ac", "ad", "ae", "af", "b0", "b1", "b2", "b3", "b4", "b5", "b6", "b7", "b8", "b9", "ba", "bb", "bc", "bd", "be", "bf", "c0", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "ca", "cb", "cc", "cd", "ce", "cf", "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "d8", "d9", "da", "db", "dc", "dd", "de", "df", "e0", "e1", "e2", "e3", "e4", "e5", "e6", "e7", "e8", "e9", "ea", "eb", "ec", "ed", "ee", "ef", "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9", "fa", "fb", "fc", "fd", "fe", "ff"];+let bp = 1234567;+const yo = Math.PI / 180, Sa = 180 / Math.PI;+function Ei() {+ const i = Math.random() * 4294967295 | 0, e = Math.random() * 4294967295 | 0, t = Math.random() * 4294967295 | 0, n = Math.random() * 4294967295 | 0;+ return (yn[i & 255] + yn[i >> 8 & 255] + yn[i >> 16 & 255] + yn[i >> 24 & 255] + "-" + yn[e & 255] + yn[e >> 8 & 255] + "-" + yn[e >> 16 & 15 | 64] + yn[e >> 24 & 255] + "-" + yn[t & 63 | 128] + yn[t >> 8 & 255] + "-" + yn[t >> 16 & 255] + yn[t >> 24 & 255] + yn[n & 255] + yn[n >> 8 & 255] + yn[n >> 16 & 255] + yn[n >> 24 & 255]).toLowerCase();+}+function ct(i, e, t) {+ return Math.max(e, Math.min(t, i));+}+function _f(i, e) {+ return (i % e + e) % e;+}+function dE(i, e, t, n, s) {+ return n + (i - e) * (s - n) / (t - e);+}+function fE(i, e, t) {+ return i !== e ? (t - i) / (e - i) : 0;+}+function wo(i, e, t) {+ return (1 - t) * i + t * e;+}+function pE(i, e, t, n) {+ return wo(i, e, 1 - Math.exp(-t * n));+}+function AE(i, e = 1) {+ return e - Math.abs(_f(i, e * 2) - e);+}+function gE(i, e, t) {+ return i <= e ? 0 : i >= t ? 1 : (i = (i - e) / (t - e), i * i * (3 - 2 * i));+}+function mE(i, e, t) {+ return i <= e ? 0 : i >= t ? 1 : (i = (i - e) / (t - e), i * i * i * (i * (i * 6 - 15) + 10));+}+function bE(i, e) {+ return i + Math.floor(Math.random() * (e - i + 1));+}+function xE(i, e) {+ return i + Math.random() * (e - i);+}+function _E(i) {+ return i * (0.5 - Math.random());+}+function EE(i) {+ i !== void 0 && (bp = i);+ let e = bp += 1831565813;+ return e = Math.imul(e ^ e >>> 15, e | 1), e ^= e + Math.imul(e ^ e >>> 7, e | 61), ((e ^ e >>> 14) >>> 0) / 4294967296;+}+function yE(i) {+ return i * yo;+}+function wE(i) {+ return i * Sa;+}+function vE(i) {+ return (i & i - 1) === 0 && i !== 0;+}+function CE(i) {+ return Math.pow(2, Math.ceil(Math.log(i) / Math.LN2));+}+function SE(i) {+ return Math.pow(2, Math.floor(Math.log(i) / Math.LN2));+}+function IE(i, e, t, n, s) {+ const r = Math.cos, a = Math.sin, o = r(t / 2), c = a(t / 2), l = r((e + n) / 2), h = a((e + n) / 2), u = r((e - n) / 2), d = a((e - n) / 2), f = r((n - e) / 2), m = a((n - e) / 2);+ switch (s) {+ case "XYX":+ i.set(o * h, c * u, c * d, o * l);+ break;+ case "YZY":+ i.set(c * d, o * h, c * u, o * l);+ break;+ case "ZXZ":+ i.set(c * u, c * d, o * h, o * l);+ break;+ case "XZX":+ i.set(o * h, c * m, c * f, o * l);+ break;+ case "YXY":+ i.set(c * f, o * h, c * m, o * l);+ break;+ case "ZYZ":+ i.set(c * m, c * f, o * h, o * l);+ break;+ default:+ console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: " + s);+ }+}+function mi(i, e) {+ switch (e.constructor) {+ case Float32Array:+ return i;+ case Uint32Array:+ return i / 4294967295;+ case Uint16Array:+ return i / 65535;+ case Uint8Array:+ return i / 255;+ case Int32Array:+ return Math.max(i / 2147483647, -1);+ case Int16Array:+ return Math.max(i / 32767, -1);+ case Int8Array:+ return Math.max(i / 127, -1);+ default:+ throw new Error("Invalid component type.");+ }+}+function It(i, e) {+ switch (e.constructor) {+ case Float32Array:+ return i;+ case Uint32Array:+ return Math.round(i * 4294967295);+ case Uint16Array:+ return Math.round(i * 65535);+ case Uint8Array:+ return Math.round(i * 255);+ case Int32Array:+ return Math.round(i * 2147483647);+ case Int16Array:+ return Math.round(i * 32767);+ case Int8Array:+ return Math.round(i * 127);+ default:+ throw new Error("Invalid component type.");+ }+}+const s0 = {+ DEG2RAD: yo,+ RAD2DEG: Sa,+ /**+ * Generate a [UUID]{@link https://en.wikipedia.org/wiki/Universally_unique_identifier}+ * (universally unique identifier).+ *+ * @static+ * @method+ * @return {string} The UUID.+ */+ generateUUID: Ei,+ /**+ * Clamps the given value between min and max.+ *+ * @static+ * @method+ * @param {number} value - The value to clamp.+ * @param {number} min - The min value.+ * @param {number} max - The max value.+ * @return {number} The clamped value.+ */+ clamp: ct,+ /**+ * Computes the Euclidean modulo of the given parameters that+ * is `( ( n % m ) + m ) % m`.+ *+ * @static+ * @method+ * @param {number} n - The first parameter.+ * @param {number} m - The second parameter.+ * @return {number} The Euclidean modulo.+ */+ euclideanModulo: _f,+ /**+ * Performs a linear mapping from range `<a1, a2>` to range `<b1, b2>`+ * for the given value.+ *+ * @static+ * @method+ * @param {number} x - The value to be mapped.+ * @param {number} a1 - Minimum value for range A.+ * @param {number} a2 - Maximum value for range A.+ * @param {number} b1 - Minimum value for range B.+ * @param {number} b2 - Maximum value for range B.+ * @return {number} The mapped value.+ */+ mapLinear: dE,+ /**+ * Returns the percentage in the closed interval `[0, 1]` of the given value+ * between the start and end point.+ *+ * @static+ * @method+ * @param {number} x - The start point+ * @param {number} y - The end point.+ * @param {number} value - A value between start and end.+ * @return {number} The interpolation factor.+ */+ inverseLerp: fE,+ /**+ * Returns a value linearly interpolated from two known points based on the given interval -+ * `t = 0` will return `x` and `t = 1` will return `y`.+ *+ * @static+ * @method+ * @param {number} x - The start point+ * @param {number} y - The end point.+ * @param {number} t - The interpolation factor in the closed interval `[0, 1]`.+ * @return {number} The interpolated value.+ */+ lerp: wo,+ /**+ * Smoothly interpolate a number from `x` to `y` in a spring-like manner using a delta+ * time to maintain frame rate independent movement. For details, see+ * [Frame rate independent damping using lerp]{@link http://www.rorydriscoll.com/2016/03/07/frame-rate-independent-damping-using-lerp/}.+ *+ * @static+ * @method+ * @param {number} x - The current point.+ * @param {number} y - The target point.+ * @param {number} lambda - A higher lambda value will make the movement more sudden,+ * and a lower value will make the movement more gradual.+ * @param {number} dt - Delta time in seconds.+ * @return {number} The interpolated value.+ */+ damp: pE,+ /**+ * Returns a value that alternates between `0` and the given `length` parameter.+ *+ * @static+ * @method+ * @param {number} x - The value to pingpong.+ * @param {number} [length=1] - The positive value the function will pingpong to.+ * @return {number} The alternated value.+ */+ pingpong: AE,+ /**+ * Returns a value in the range `[0,1]` that represents the percentage that `x` has+ * moved between `min` and `max`, but smoothed or slowed down the closer `x` is to+ * the `min` and `max`.+ *+ * See [Smoothstep]{@link http://en.wikipedia.org/wiki/Smoothstep} for more details.+ *+ * @static+ * @method+ * @param {number} x - The value to evaluate based on its position between min and max.+ * @param {number} min - The min value. Any x value below min will be `0`.+ * @param {number} max - The max value. Any x value above max will be `1`.+ * @return {number} The alternated value.+ */+ smoothstep: gE,+ /**+ * A [variation on smoothstep]{@link https://en.wikipedia.org/wiki/Smoothstep#Variations}+ * that has zero 1st and 2nd order derivatives at x=0 and x=1.+ *+ * @static+ * @method+ * @param {number} x - The value to evaluate based on its position between min and max.+ * @param {number} min - The min value. Any x value below min will be `0`.+ * @param {number} max - The max value. Any x value above max will be `1`.+ * @return {number} The alternated value.+ */+ smootherstep: mE,+ /**+ * Returns a random integer from `<low, high>` interval.+ *+ * @static+ * @method+ * @param {number} low - The lower value boundary.+ * @param {number} high - The upper value boundary+ * @return {number} A random integer.+ */+ randInt: bE,+ /**+ * Returns a random float from `<low, high>` interval.+ *+ * @static+ * @method+ * @param {number} low - The lower value boundary.+ * @param {number} high - The upper value boundary+ * @return {number} A random float.+ */+ randFloat: xE,+ /**+ * Returns a random integer from `<-range/2, range/2>` interval.+ *+ * @static+ * @method+ * @param {number} range - Defines the value range.+ * @return {number} A random float.+ */+ randFloatSpread: _E,+ /**+ * Returns a deterministic pseudo-random float in the interval `[0, 1]`.+ *+ * @static+ * @method+ * @param {number} [s] - The integer seed.+ * @return {number} A random float.+ */+ seededRandom: EE,+ /**+ * Converts degrees to radians.+ *+ * @static+ * @method+ * @param {number} degrees - A value in degrees.+ * @return {number} The converted value in radians.+ */+ degToRad: yE,+ /**+ * Converts radians to degrees.+ *+ * @static+ * @method+ * @param {number} radians - A value in radians.+ * @return {number} The converted value in degrees.+ */+ radToDeg: wE,+ /**+ * Returns `true` if the given number is a power of two.+ *+ * @static+ * @method+ * @param {number} value - The value to check.+ * @return {boolean} Whether the given number is a power of two or not.+ */+ isPowerOfTwo: vE,+ /**+ * Returns the smallest power of two that is greater than or equal to the given number.+ *+ * @static+ * @method+ * @param {number} value - The value to find a POT for.+ * @return {number} The smallest power of two that is greater than or equal to the given number.+ */+ ceilPowerOfTwo: CE,+ /**+ * Returns the largest power of two that is less than or equal to the given number.+ *+ * @static+ * @method+ * @param {number} value - The value to find a POT for.+ * @return {number} The largest power of two that is less than or equal to the given number.+ */+ floorPowerOfTwo: SE,+ /**+ * Sets the given quaternion from the [Intrinsic Proper Euler Angles]{@link https://en.wikipedia.org/wiki/Euler_angles}+ * defined by the given angles and order.+ *+ * Rotations are applied to the axes in the order specified by order:+ * rotation by angle `a` is applied first, then by angle `b`, then by angle `c`.+ *+ * @static+ * @method+ * @param {Quaternion} q - The quaternion to set.+ * @param {number} a - The rotation applied to the first axis, in radians.+ * @param {number} b - The rotation applied to the second axis, in radians.+ * @param {number} c - The rotation applied to the third axis, in radians.+ * @param {('XYX'|'XZX'|'YXY'|'YZY'|'ZXZ'|'ZYZ')} order - A string specifying the axes order.+ */+ setQuaternionFromProperEuler: IE,+ /**+ * Normalizes the given value according to the given typed array.+ *+ * @static+ * @method+ * @param {number} value - The float value in the range `[0,1]` to normalize.+ * @param {TypedArray} array - The typed array that defines the data type of the value.+ * @return {number} The normalize value.+ */+ normalize: It,+ /**+ * Denormalizes the given value according to the given typed array.+ *+ * @static+ * @method+ * @param {number} value - The value to denormalize.+ * @param {TypedArray} array - The typed array that defines the data type of the value.+ * @return {number} The denormalize (float) value in the range `[0,1]`.+ */+ denormalize: mi+};+class Ze {+ /**+ * Constructs a new 2D vector.+ *+ * @param {number} [x=0] - The x value of this vector.+ * @param {number} [y=0] - The y value of this vector.+ */+ constructor(e = 0, t = 0) {+ Ze.prototype.isVector2 = !0, this.x = e, this.y = t;+ }+ /**+ * Alias for {@link Vector2#x}.+ *+ * @type {number}+ */+ get width() {+ return this.x;+ }+ set width(e) {+ this.x = e;+ }+ /**+ * Alias for {@link Vector2#y}.+ *+ * @type {number}+ */+ get height() {+ return this.y;+ }+ set height(e) {+ this.y = e;+ }+ /**+ * Sets the vector components.+ *+ * @param {number} x - The value of the x component.+ * @param {number} y - The value of the y component.+ * @return {Vector2} A reference to this vector.+ */+ set(e, t) {+ return this.x = e, this.y = t, this;+ }+ /**+ * Sets the vector components to the same value.+ *+ * @param {number} scalar - The value to set for all vector components.+ * @return {Vector2} A reference to this vector.+ */+ setScalar(e) {+ return this.x = e, this.y = e, this;+ }+ /**+ * Sets the vector's x component to the given value+ *+ * @param {number} x - The value to set.+ * @return {Vector2} A reference to this vector.+ */+ setX(e) {+ return this.x = e, this;+ }+ /**+ * Sets the vector's y component to the given value+ *+ * @param {number} y - The value to set.+ * @return {Vector2} A reference to this vector.+ */+ setY(e) {+ return this.y = e, this;+ }+ /**+ * Allows to set a vector component with an index.+ *+ * @param {number} index - The component index. `0` equals to x, `1` equals to y.+ * @param {number} value - The value to set.+ * @return {Vector2} A reference to this vector.+ */+ setComponent(e, t) {+ switch (e) {+ case 0:+ this.x = t;+ break;+ case 1:+ this.y = t;+ break;+ default:+ throw new Error("index is out of range: " + e);+ }+ return this;+ }+ /**+ * Returns the value of the vector component which matches the given index.+ *+ * @param {number} index - The component index. `0` equals to x, `1` equals to y.+ * @return {number} A vector component value.+ */+ getComponent(e) {+ switch (e) {+ case 0:+ return this.x;+ case 1:+ return this.y;+ default:+ throw new Error("index is out of range: " + e);+ }+ }+ /**+ * Returns a new vector with copied values from this instance.+ *+ * @return {Vector2} A clone of this instance.+ */+ clone() {+ return new this.constructor(this.x, this.y);+ }+ /**+ * Copies the values of the given vector to this instance.+ *+ * @param {Vector2} v - The vector to copy.+ * @return {Vector2} A reference to this vector.+ */+ copy(e) {+ return this.x = e.x, this.y = e.y, this;+ }+ /**+ * Adds the given vector to this instance.+ *+ * @param {Vector2} v - The vector to add.+ * @return {Vector2} A reference to this vector.+ */+ add(e) {+ return this.x += e.x, this.y += e.y, this;+ }+ /**+ * Adds the given scalar value to all components of this instance.+ *+ * @param {number} s - The scalar to add.+ * @return {Vector2} A reference to this vector.+ */+ addScalar(e) {+ return this.x += e, this.y += e, this;+ }+ /**+ * Adds the given vectors and stores the result in this instance.+ *+ * @param {Vector2} a - The first vector.+ * @param {Vector2} b - The second vector.+ * @return {Vector2} A reference to this vector.+ */+ addVectors(e, t) {+ return this.x = e.x + t.x, this.y = e.y + t.y, this;+ }+ /**+ * Adds the given vector scaled by the given factor to this instance.+ *+ * @param {Vector2} v - The vector.+ * @param {number} s - The factor that scales `v`.+ * @return {Vector2} A reference to this vector.+ */+ addScaledVector(e, t) {+ return this.x += e.x * t, this.y += e.y * t, this;+ }+ /**+ * Subtracts the given vector from this instance.+ *+ * @param {Vector2} v - The vector to subtract.+ * @return {Vector2} A reference to this vector.+ */+ sub(e) {+ return this.x -= e.x, this.y -= e.y, this;+ }+ /**+ * Subtracts the given scalar value from all components of this instance.+ *+ * @param {number} s - The scalar to subtract.+ * @return {Vector2} A reference to this vector.+ */+ subScalar(e) {+ return this.x -= e, this.y -= e, this;+ }+ /**+ * Subtracts the given vectors and stores the result in this instance.+ *+ * @param {Vector2} a - The first vector.+ * @param {Vector2} b - The second vector.+ * @return {Vector2} A reference to this vector.+ */+ subVectors(e, t) {+ return this.x = e.x - t.x, this.y = e.y - t.y, this;+ }+ /**+ * Multiplies the given vector with this instance.+ *+ * @param {Vector2} v - The vector to multiply.+ * @return {Vector2} A reference to this vector.+ */+ multiply(e) {+ return this.x *= e.x, this.y *= e.y, this;+ }+ /**+ * Multiplies the given scalar value with all components of this instance.+ *+ * @param {number} scalar - The scalar to multiply.+ * @return {Vector2} A reference to this vector.+ */+ multiplyScalar(e) {+ return this.x *= e, this.y *= e, this;+ }+ /**+ * Divides this instance by the given vector.+ *+ * @param {Vector2} v - The vector to divide.+ * @return {Vector2} A reference to this vector.+ */+ divide(e) {+ return this.x /= e.x, this.y /= e.y, this;+ }+ /**+ * Divides this vector by the given scalar.+ *+ * @param {number} scalar - The scalar to divide.+ * @return {Vector2} A reference to this vector.+ */+ divideScalar(e) {+ return this.multiplyScalar(1 / e);+ }+ /**+ * Multiplies this vector (with an implicit 1 as the 3rd component) by+ * the given 3x3 matrix.+ *+ * @param {Matrix3} m - The matrix to apply.+ * @return {Vector2} A reference to this vector.+ */+ applyMatrix3(e) {+ const t = this.x, n = this.y, s = e.elements;+ return this.x = s[0] * t + s[3] * n + s[6], this.y = s[1] * t + s[4] * n + s[7], this;+ }+ /**+ * If this vector's x or y value is greater than the given vector's x or y+ * value, replace that value with the corresponding min value.+ *+ * @param {Vector2} v - The vector.+ * @return {Vector2} A reference to this vector.+ */+ min(e) {+ return this.x = Math.min(this.x, e.x), this.y = Math.min(this.y, e.y), this;+ }+ /**+ * If this vector's x or y value is less than the given vector's x or y+ * value, replace that value with the corresponding max value.+ *+ * @param {Vector2} v - The vector.+ * @return {Vector2} A reference to this vector.+ */+ max(e) {+ return this.x = Math.max(this.x, e.x), this.y = Math.max(this.y, e.y), this;+ }+ /**+ * If this vector's x or y value is greater than the max vector's x or y+ * value, it is replaced by the corresponding value.+ * If this vector's x or y value is less than the min vector's x or y value,+ * it is replaced by the corresponding value.+ *+ * @param {Vector2} min - The minimum x and y values.+ * @param {Vector2} max - The maximum x and y values in the desired range.+ * @return {Vector2} A reference to this vector.+ */+ clamp(e, t) {+ return this.x = ct(this.x, e.x, t.x), this.y = ct(this.y, e.y, t.y), this;+ }+ /**+ * If this vector's x or y values are greater than the max value, they are+ * replaced by the max value.+ * If this vector's x or y values are less than the min value, they are+ * replaced by the min value.+ *+ * @param {number} minVal - The minimum value the components will be clamped to.+ * @param {number} maxVal - The maximum value the components will be clamped to.+ * @return {Vector2} A reference to this vector.+ */+ clampScalar(e, t) {+ return this.x = ct(this.x, e, t), this.y = ct(this.y, e, t), this;+ }+ /**+ * If this vector's length is greater than the max value, it is replaced by+ * the max value.+ * If this vector's length is less than the min value, it is replaced by the+ * min value.+ *+ * @param {number} min - The minimum value the vector length will be clamped to.+ * @param {number} max - The maximum value the vector length will be clamped to.+ * @return {Vector2} A reference to this vector.+ */+ clampLength(e, t) {+ const n = this.length();+ return this.divideScalar(n || 1).multiplyScalar(ct(n, e, t));+ }+ /**+ * The components of this vector are rounded down to the nearest integer value.+ *+ * @return {Vector2} A reference to this vector.+ */+ floor() {+ return this.x = Math.floor(this.x), this.y = Math.floor(this.y), this;+ }+ /**+ * The components of this vector are rounded up to the nearest integer value.+ *+ * @return {Vector2} A reference to this vector.+ */+ ceil() {+ return this.x = Math.ceil(this.x), this.y = Math.ceil(this.y), this;+ }+ /**+ * The components of this vector are rounded to the nearest integer value+ *+ * @return {Vector2} A reference to this vector.+ */+ round() {+ return this.x = Math.round(this.x), this.y = Math.round(this.y), this;+ }+ /**+ * The components of this vector are rounded towards zero (up if negative,+ * down if positive) to an integer value.+ *+ * @return {Vector2} A reference to this vector.+ */+ roundToZero() {+ return this.x = Math.trunc(this.x), this.y = Math.trunc(this.y), this;+ }+ /**+ * Inverts this vector - i.e. sets x = -x and y = -y.+ *+ * @return {Vector2} A reference to this vector.+ */+ negate() {+ return this.x = -this.x, this.y = -this.y, this;+ }+ /**+ * Calculates the dot product of the given vector with this instance.+ *+ * @param {Vector2} v - The vector to compute the dot product with.+ * @return {number} The result of the dot product.+ */+ dot(e) {+ return this.x * e.x + this.y * e.y;+ }+ /**+ * Calculates the cross product of the given vector with this instance.+ *+ * @param {Vector2} v - The vector to compute the cross product with.+ * @return {number} The result of the cross product.+ */+ cross(e) {+ return this.x * e.y - this.y * e.x;+ }+ /**+ * Computes the square of the Euclidean length (straight-line length) from+ * (0, 0) to (x, y). If you are comparing the lengths of vectors, you should+ * compare the length squared instead as it is slightly more efficient to calculate.+ *+ * @return {number} The square length of this vector.+ */+ lengthSq() {+ return this.x * this.x + this.y * this.y;+ }+ /**+ * Computes the Euclidean length (straight-line length) from (0, 0) to (x, y).+ *+ * @return {number} The length of this vector.+ */+ length() {+ return Math.sqrt(this.x * this.x + this.y * this.y);+ }+ /**+ * Computes the Manhattan length of this vector.+ *+ * @return {number} The length of this vector.+ */+ manhattanLength() {+ return Math.abs(this.x) + Math.abs(this.y);+ }+ /**+ * Converts this vector to a unit vector - that is, sets it equal to a vector+ * with the same direction as this one, but with a vector length of `1`.+ *+ * @return {Vector2} A reference to this vector.+ */+ normalize() {+ return this.divideScalar(this.length() || 1);+ }+ /**+ * Computes the angle in radians of this vector with respect to the positive x-axis.+ *+ * @return {number} The angle in radians.+ */+ angle() {+ return Math.atan2(-this.y, -this.x) + Math.PI;+ }+ /**+ * Returns the angle between the given vector and this instance in radians.+ *+ * @param {Vector2} v - The vector to compute the angle with.+ * @return {number} The angle in radians.+ */+ angleTo(e) {+ const t = Math.sqrt(this.lengthSq() * e.lengthSq());+ if (t === 0) return Math.PI / 2;+ const n = this.dot(e) / t;+ return Math.acos(ct(n, -1, 1));+ }+ /**+ * Computes the distance from the given vector to this instance.+ *+ * @param {Vector2} v - The vector to compute the distance to.+ * @return {number} The distance.+ */+ distanceTo(e) {+ return Math.sqrt(this.distanceToSquared(e));+ }+ /**+ * Computes the squared distance from the given vector to this instance.+ * If you are just comparing the distance with another distance, you should compare+ * the distance squared instead as it is slightly more efficient to calculate.+ *+ * @param {Vector2} v - The vector to compute the squared distance to.+ * @return {number} The squared distance.+ */+ distanceToSquared(e) {+ const t = this.x - e.x, n = this.y - e.y;+ return t * t + n * n;+ }+ /**+ * Computes the Manhattan distance from the given vector to this instance.+ *+ * @param {Vector2} v - The vector to compute the Manhattan distance to.+ * @return {number} The Manhattan distance.+ */+ manhattanDistanceTo(e) {+ return Math.abs(this.x - e.x) + Math.abs(this.y - e.y);+ }+ /**+ * Sets this vector to a vector with the same direction as this one, but+ * with the specified length.+ *+ * @param {number} length - The new length of this vector.+ * @return {Vector2} A reference to this vector.+ */+ setLength(e) {+ return this.normalize().multiplyScalar(e);+ }+ /**+ * Linearly interpolates between the given vector and this instance, where+ * alpha is the percent distance along the line - alpha = 0 will be this+ * vector, and alpha = 1 will be the given one.+ *+ * @param {Vector2} v - The vector to interpolate towards.+ * @param {number} alpha - The interpolation factor, typically in the closed interval `[0, 1]`.+ * @return {Vector2} A reference to this vector.+ */+ lerp(e, t) {+ return this.x += (e.x - this.x) * t, this.y += (e.y - this.y) * t, this;+ }+ /**+ * Linearly interpolates between the given vectors, where alpha is the percent+ * distance along the line - alpha = 0 will be first vector, and alpha = 1 will+ * be the second one. The result is stored in this instance.+ *+ * @param {Vector2} v1 - The first vector.+ * @param {Vector2} v2 - The second vector.+ * @param {number} alpha - The interpolation factor, typically in the closed interval `[0, 1]`.+ * @return {Vector2} A reference to this vector.+ */+ lerpVectors(e, t, n) {+ return this.x = e.x + (t.x - e.x) * n, this.y = e.y + (t.y - e.y) * n, this;+ }+ /**+ * Returns `true` if this vector is equal with the given one.+ *+ * @param {Vector2} v - The vector to test for equality.+ * @return {boolean} Whether this vector is equal with the given one.+ */+ equals(e) {+ return e.x === this.x && e.y === this.y;+ }+ /**+ * Sets this vector's x value to be `array[ offset ]` and y+ * value to be `array[ offset + 1 ]`.+ *+ * @param {Array<number>} array - An array holding the vector component values.+ * @param {number} [offset=0] - The offset into the array.+ * @return {Vector2} A reference to this vector.+ */+ fromArray(e, t = 0) {+ return this.x = e[t], this.y = e[t + 1], this;+ }+ /**+ * Writes the components of this vector to the given array. If no array is provided,+ * the method returns a new instance.+ *+ * @param {Array<number>} [array=[]] - The target array holding the vector components.+ * @param {number} [offset=0] - Index of the first element in the array.+ * @return {Array<number>} The vector components.+ */+ toArray(e = [], t = 0) {+ return e[t] = this.x, e[t + 1] = this.y, e;+ }+ /**+ * Sets the components of this vector from the given buffer attribute.+ *+ * @param {BufferAttribute} attribute - The buffer attribute holding vector data.+ * @param {number} index - The index into the attribute.+ * @return {Vector2} A reference to this vector.+ */+ fromBufferAttribute(e, t) {+ return this.x = e.getX(t), this.y = e.getY(t), this;+ }+ /**+ * Rotates this vector around the given center by the given angle.+ *+ * @param {Vector2} center - The point around which to rotate.+ * @param {number} angle - The angle to rotate, in radians.+ * @return {Vector2} A reference to this vector.+ */+ rotateAround(e, t) {+ const n = Math.cos(t), s = Math.sin(t), r = this.x - e.x, a = this.y - e.y;+ return this.x = r * n - a * s + e.x, this.y = r * s + a * n + e.y, this;+ }+ /**+ * Sets each component of this vector to a pseudo-random value between `0` and+ * `1`, excluding `1`.+ *+ * @return {Vector2} A reference to this vector.+ */+ random() {+ return this.x = Math.random(), this.y = Math.random(), this;+ }+ *[Symbol.iterator]() {+ yield this.x, yield this.y;+ }+}+class rt {+ /**+ * Constructs a new 3x3 matrix. The arguments are supposed to be+ * in row-major order. If no arguments are provided, the constructor+ * initializes the matrix as an identity matrix.+ *+ * @param {number} [n11] - 1-1 matrix element.+ * @param {number} [n12] - 1-2 matrix element.+ * @param {number} [n13] - 1-3 matrix element.+ * @param {number} [n21] - 2-1 matrix element.+ * @param {number} [n22] - 2-2 matrix element.+ * @param {number} [n23] - 2-3 matrix element.+ * @param {number} [n31] - 3-1 matrix element.+ * @param {number} [n32] - 3-2 matrix element.+ * @param {number} [n33] - 3-3 matrix element.+ */+ constructor(e, t, n, s, r, a, o, c, l) {+ rt.prototype.isMatrix3 = !0, this.elements = [+ 1,+ 0,+ 0,+ 0,+ 1,+ 0,+ 0,+ 0,+ 1+ ], e !== void 0 && this.set(e, t, n, s, r, a, o, c, l);+ }+ /**+ * Sets the elements of the matrix.The arguments are supposed to be+ * in row-major order.+ *+ * @param {number} [n11] - 1-1 matrix element.+ * @param {number} [n12] - 1-2 matrix element.+ * @param {number} [n13] - 1-3 matrix element.+ * @param {number} [n21] - 2-1 matrix element.+ * @param {number} [n22] - 2-2 matrix element.+ * @param {number} [n23] - 2-3 matrix element.+ * @param {number} [n31] - 3-1 matrix element.+ * @param {number} [n32] - 3-2 matrix element.+ * @param {number} [n33] - 3-3 matrix element.+ * @return {Matrix3} A reference to this matrix.+ */+ set(e, t, n, s, r, a, o, c, l) {+ const h = this.elements;+ return h[0] = e, h[1] = s, h[2] = o, h[3] = t, h[4] = r, h[5] = c, h[6] = n, h[7] = a, h[8] = l, this;+ }+ /**+ * Sets this matrix to the 3x3 identity matrix.+ *+ * @return {Matrix3} A reference to this matrix.+ */+ identity() {+ return this.set(+ 1,+ 0,+ 0,+ 0,+ 1,+ 0,+ 0,+ 0,+ 1+ ), this;+ }+ /**+ * Copies the values of the given matrix to this instance.+ *+ * @param {Matrix3} m - The matrix to copy.+ * @return {Matrix3} A reference to this matrix.+ */+ copy(e) {+ const 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;+ }+ /**+ * Extracts the basis of this matrix into the three axis vectors provided.+ *+ * @param {Vector3} xAxis - The basis's x axis.+ * @param {Vector3} yAxis - The basis's y axis.+ * @param {Vector3} zAxis - The basis's z axis.+ * @return {Matrix3} A reference to this matrix.+ */+ extractBasis(e, t, n) {+ return e.setFromMatrix3Column(this, 0), t.setFromMatrix3Column(this, 1), n.setFromMatrix3Column(this, 2), this;+ }+ /**+ * Set this matrix to the upper 3x3 matrix of the given 4x4 matrix.+ *+ * @param {Matrix4} m - The 4x4 matrix.+ * @return {Matrix3} A reference to this matrix.+ */+ setFromMatrix4(e) {+ const 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;+ }+ /**+ * Post-multiplies this matrix by the given 3x3 matrix.+ *+ * @param {Matrix3} m - The matrix to multiply with.+ * @return {Matrix3} A reference to this matrix.+ */+ multiply(e) {+ return this.multiplyMatrices(this, e);+ }+ /**+ * Pre-multiplies this matrix by the given 3x3 matrix.+ *+ * @param {Matrix3} m - The matrix to multiply with.+ * @return {Matrix3} A reference to this matrix.+ */+ premultiply(e) {+ return this.multiplyMatrices(e, this);+ }+ /**+ * Multiples the given 3x3 matrices and stores the result+ * in this matrix.+ *+ * @param {Matrix3} a - The first matrix.+ * @param {Matrix3} b - The second matrix.+ * @return {Matrix3} A reference to this matrix.+ */+ multiplyMatrices(e, t) {+ const n = e.elements, s = t.elements, r = this.elements, a = n[0], o = n[3], c = n[6], l = n[1], h = n[4], u = n[7], d = n[2], f = n[5], m = n[8], A = s[0], g = s[3], p = s[6], y = s[1], b = s[4], E = s[7], M = s[2], w = s[5], S = s[8];+ return r[0] = a * A + o * y + c * M, r[3] = a * g + o * b + c * w, r[6] = a * p + o * E + c * S, r[1] = l * A + h * y + u * M, r[4] = l * g + h * b + u * w, r[7] = l * p + h * E + u * S, r[2] = d * A + f * y + m * M, r[5] = d * g + f * b + m * w, r[8] = d * p + f * E + m * S, this;+ }+ /**+ * Multiplies every component of the matrix by the given scalar.+ *+ * @param {number} s - The scalar.+ * @return {Matrix3} A reference to this matrix.+ */+ multiplyScalar(e) {+ const 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;+ }+ /**+ * Computes and returns the determinant of this matrix.+ *+ * @return {number} The determinant.+ */+ determinant() {+ const e = this.elements, t = e[0], n = e[1], s = e[2], r = e[3], a = e[4], o = e[5], c = e[6], l = e[7], h = e[8];+ return t * a * h - t * o * l - n * r * h + n * o * c + s * r * l - s * a * c;+ }+ /**+ * Inverts this matrix, using the [analytic method]{@link https://en.wikipedia.org/wiki/Invertible_matrix#Analytic_solution}.+ * You can not invert with a determinant of zero. If you attempt this, the method produces+ * a zero matrix instead.+ *+ * @return {Matrix3} A reference to this matrix.+ */+ invert() {+ const e = this.elements, t = e[0], n = e[1], s = e[2], r = e[3], a = e[4], o = e[5], c = e[6], l = e[7], h = e[8], u = h * a - o * l, d = o * c - h * r, f = l * r - a * c, m = t * u + n * d + s * f;+ if (m === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0);+ const A = 1 / m;+ return e[0] = u * A, e[1] = (s * l - h * n) * A, e[2] = (o * n - s * a) * A, e[3] = d * A, e[4] = (h * t - s * c) * A, e[5] = (s * r - o * t) * A, e[6] = f * A, e[7] = (n * c - l * t) * A, e[8] = (a * t - n * r) * A, this;+ }+ /**+ * Transposes this matrix in place.+ *+ * @return {Matrix3} A reference to this matrix.+ */+ transpose() {+ let e;+ const 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;+ }+ /**+ * Computes the normal matrix which is the inverse transpose of the upper+ * left 3x3 portion of the given 4x4 matrix.+ *+ * @param {Matrix4} matrix4 - The 4x4 matrix.+ * @return {Matrix3} A reference to this matrix.+ */+ getNormalMatrix(e) {+ return this.setFromMatrix4(e).invert().transpose();+ }+ /**+ * Transposes this matrix into the supplied array, and returns itself unchanged.+ *+ * @param {Array<number>} r - An array to store the transposed matrix elements.+ * @return {Matrix3} A reference to this matrix.+ */+ transposeIntoArray(e) {+ const 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;+ }+ /**+ * Sets the UV transform matrix from offset, repeat, rotation, and center.+ *+ * @param {number} tx - Offset x.+ * @param {number} ty - Offset y.+ * @param {number} sx - Repeat x.+ * @param {number} sy - Repeat y.+ * @param {number} rotation - Rotation, in radians. Positive values rotate counterclockwise.+ * @param {number} cx - Center x of rotation.+ * @param {number} cy - Center y of rotation+ * @return {Matrix3} A reference to this matrix.+ */+ setUvTransform(e, t, n, s, r, a, o) {+ const c = Math.cos(r), l = Math.sin(r);+ return this.set(+ n * c,+ n * l,+ -n * (c * a + l * o) + a + e,+ -s * l,+ s * c,+ -s * (-l * a + c * o) + o + t,+ 0,+ 0,+ 1+ ), this;+ }+ /**+ * Scales this matrix with the given scalar values.+ *+ * @param {number} sx - The amount to scale in the X axis.+ * @param {number} sy - The amount to scale in the Y axis.+ * @return {Matrix3} A reference to this matrix.+ */+ scale(e, t) {+ return this.premultiply(Eh.makeScale(e, t)), this;+ }+ /**+ * Rotates this matrix by the given angle.+ *+ * @param {number} theta - The rotation in radians.+ * @return {Matrix3} A reference to this matrix.+ */+ rotate(e) {+ return this.premultiply(Eh.makeRotation(-e)), this;+ }+ /**+ * Translates this matrix by the given scalar values.+ *+ * @param {number} tx - The amount to translate in the X axis.+ * @param {number} ty - The amount to translate in the Y axis.+ * @return {Matrix3} A reference to this matrix.+ */+ translate(e, t) {+ return this.premultiply(Eh.makeTranslation(e, t)), this;+ }+ // for 2D Transforms+ /**+ * Sets this matrix as a 2D translation transform.+ *+ * @param {number|Vector2} x - The amount to translate in the X axis or alternatively a translation vector.+ * @param {number} y - The amount to translate in the Y axis.+ * @return {Matrix3} A reference to this matrix.+ */+ 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;+ }+ /**+ * Sets this matrix as a 2D rotational transformation.+ *+ * @param {number} theta - The rotation in radians.+ * @return {Matrix3} A reference to this matrix.+ */+ makeRotation(e) {+ const t = Math.cos(e), n = Math.sin(e);+ return this.set(+ t,+ -n,+ 0,+ n,+ t,+ 0,+ 0,+ 0,+ 1+ ), this;+ }+ /**+ * Sets this matrix as a 2D scale transform.+ *+ * @param {number} x - The amount to scale in the X axis.+ * @param {number} y - The amount to scale in the Y axis.+ * @return {Matrix3} A reference to this matrix.+ */+ makeScale(e, t) {+ return this.set(+ e,+ 0,+ 0,+ 0,+ t,+ 0,+ 0,+ 0,+ 1+ ), this;+ }+ /**+ * Returns `true` if this matrix is equal with the given one.+ *+ * @param {Matrix3} matrix - The matrix to test for equality.+ * @return {boolean} Whether this matrix is equal with the given one.+ */+ equals(e) {+ const t = this.elements, n = e.elements;+ for (let s = 0; s < 9; s++)+ if (t[s] !== n[s]) return !1;+ return !0;+ }+ /**+ * Sets the elements of the matrix from the given array.+ *+ * @param {Array<number>} array - The matrix elements in column-major order.+ * @param {number} [offset=0] - Index of the first element in the array.+ * @return {Matrix3} A reference to this matrix.+ */+ fromArray(e, t = 0) {+ for (let n = 0; n < 9; n++)+ this.elements[n] = e[n + t];+ return this;+ }+ /**+ * Writes the elements of this matrix to the given array. If no array is provided,+ * the method returns a new instance.+ *+ * @param {Array<number>} [array=[]] - The target array holding the matrix elements in column-major order.+ * @param {number} [offset=0] - Index of the first element in the array.+ * @return {Array<number>} The matrix elements in column-major order.+ */+ toArray(e = [], t = 0) {+ const 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;+ }+ /**+ * Returns a matrix with copied values from this instance.+ *+ * @return {Matrix3} A clone of this instance.+ */+ clone() {+ return new this.constructor().fromArray(this.elements);+ }+}+const Eh = /* @__PURE__ */ new rt();+function r0(i) {+ for (let e = i.length - 1; e >= 0; --e)+ if (i[e] >= 65535) return !0;+ return !1;+}+function Uo(i) {+ return document.createElementNS("http://www.w3.org/1999/xhtml", i);+}+function ME() {+ const i = Uo("canvas");+ return i.style.display = "block", i;+}+const xp = {};+function pl(i) {+ i in xp || (xp[i] = !0, console.warn(i));+}+function BE(i, e, t) {+ return new Promise(function(n, s) {+ function r() {+ switch (i.clientWaitSync(e, i.SYNC_FLUSH_COMMANDS_BIT, 0)) {+ case i.WAIT_FAILED:+ s();+ break;+ case i.TIMEOUT_EXPIRED:+ setTimeout(r, t);+ break;+ default:+ n();+ }+ }+ setTimeout(r, t);+ });+}+function TE(i) {+ const e = i.elements;+ e[2] = 0.5 * e[2] + 0.5 * e[3], e[6] = 0.5 * e[6] + 0.5 * e[7], e[10] = 0.5 * e[10] + 0.5 * e[11], e[14] = 0.5 * e[14] + 0.5 * e[15];+}+function RE(i) {+ const e = i.elements;+ e[11] === -1 ? (e[10] = -e[10] - 1, e[14] = -e[14]) : (e[10] = -e[10], e[14] = -e[14] + 1);+}+const _p = /* @__PURE__ */ new rt().set(+ 0.4123908,+ 0.3575843,+ 0.1804808,+ 0.212639,+ 0.7151687,+ 0.0721923,+ 0.0193308,+ 0.1191948,+ 0.9505322+), Ep = /* @__PURE__ */ new rt().set(+ 3.2409699,+ -1.5373832,+ -0.4986108,+ -0.9692436,+ 1.8759675,+ 0.0415551,+ 0.0556301,+ -0.203977,+ 1.0569715+);+function NE() {+ const i = {+ enabled: !0,+ workingColorSpace: ln,+ /**+ * Implementations of supported color spaces.+ *+ * Required:+ * - primaries: chromaticity coordinates [ rx ry gx gy bx by ]+ * - whitePoint: reference white [ x y ]+ * - transfer: transfer function (pre-defined)+ * - toXYZ: Matrix3 RGB to XYZ transform+ * - fromXYZ: Matrix3 XYZ to RGB transform+ * - luminanceCoefficients: RGB luminance coefficients+ *+ * Optional:+ * - outputColorSpaceConfig: { drawingBufferColorSpace: ColorSpace }+ * - workingColorSpaceConfig: { unpackColorSpace: ColorSpace }+ *+ * Reference:+ * - https://www.russellcottrell.com/photo/matrixCalculator.htm+ */+ spaces: {},+ convert: function(s, r, a) {+ return this.enabled === !1 || r === a || !r || !a || (this.spaces[r].transfer === Mt && (s.r = os(s.r), s.g = os(s.g), s.b = os(s.b)), this.spaces[r].primaries !== this.spaces[a].primaries && (s.applyMatrix3(this.spaces[r].toXYZ), s.applyMatrix3(this.spaces[a].fromXYZ)), this.spaces[a].transfer === Mt && (s.r = pa(s.r), s.g = pa(s.g), s.b = pa(s.b))), s;+ },+ fromWorkingColorSpace: function(s, r) {+ return this.convert(s, this.workingColorSpace, r);+ },+ toWorkingColorSpace: function(s, r) {+ return this.convert(s, r, this.workingColorSpace);+ },+ getPrimaries: function(s) {+ return this.spaces[s].primaries;+ },+ getTransfer: function(s) {+ return s === gi ? Bl : this.spaces[s].transfer;+ },+ getLuminanceCoefficients: function(s, r = this.workingColorSpace) {+ return s.fromArray(this.spaces[r].luminanceCoefficients);+ },+ define: function(s) {+ Object.assign(this.spaces, s);+ },+ // Internal APIs+ _getMatrix: function(s, r, a) {+ return s.copy(this.spaces[r].toXYZ).multiply(this.spaces[a].fromXYZ);+ },+ _getDrawingBufferColorSpace: function(s) {+ return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace;+ },+ _getUnpackColorSpace: function(s = this.workingColorSpace) {+ return this.spaces[s].workingColorSpaceConfig.unpackColorSpace;+ }+ }, e = [0.64, 0.33, 0.3, 0.6, 0.15, 0.06], t = [0.2126, 0.7152, 0.0722], n = [0.3127, 0.329];+ return i.define({+ [ln]: {+ primaries: e,+ whitePoint: n,+ transfer: Bl,+ toXYZ: _p,+ fromXYZ: Ep,+ luminanceCoefficients: t,+ workingColorSpaceConfig: { unpackColorSpace: Kt },+ outputColorSpaceConfig: { drawingBufferColorSpace: Kt }+ },+ [Kt]: {+ primaries: e,+ whitePoint: n,+ transfer: Mt,+ toXYZ: _p,+ fromXYZ: Ep,+ luminanceCoefficients: t,+ outputColorSpaceConfig: { drawingBufferColorSpace: Kt }+ }+ }), i;+}+const mt = /* @__PURE__ */ NE();+function os(i) {+ return i < 0.04045 ? i * 0.0773993808 : Math.pow(i * 0.9478672986 + 0.0521327014, 2.4);+}+function pa(i) {+ return i < 31308e-7 ? i * 12.92 : 1.055 * Math.pow(i, 0.41666) - 0.055;+}+let Pr;+class FE {+ /**+ * Returns a data URI containing a representation of the given image.+ *+ * @param {(HTMLImageElement|HTMLCanvasElement)} image - The image object.+ * @param {string} [type='image/png'] - Indicates the image format.+ * @return {string} The data URI.+ */+ 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 {+ Pr === void 0 && (Pr = Uo("canvas")), Pr.width = e.width, Pr.height = e.height;+ const s = Pr.getContext("2d");+ e instanceof ImageData ? s.putImageData(e, 0, 0) : s.drawImage(e, 0, 0, e.width, e.height), n = Pr;+ }+ return n.toDataURL(t);+ }+ /**+ * Converts the given sRGB image data to linear color space.+ *+ * @param {(HTMLImageElement|HTMLCanvasElement|ImageBitmap|Object)} image - The image object.+ * @return {HTMLCanvasElement|Object} The converted image.+ */+ static sRGBToLinear(e) {+ if (typeof HTMLImageElement < "u" && e instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && e instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && e instanceof ImageBitmap) {+ const t = Uo("canvas");+ t.width = e.width, t.height = e.height;+ const n = t.getContext("2d");+ n.drawImage(e, 0, 0, e.width, e.height);+ const s = n.getImageData(0, 0, e.width, e.height), r = s.data;+ for (let a = 0; a < r.length; a++)+ r[a] = os(r[a] / 255) * 255;+ return n.putImageData(s, 0, 0), t;+ } else if (e.data) {+ const t = e.data.slice(0);+ for (let n = 0; n < t.length; n++)+ t instanceof Uint8Array || t instanceof Uint8ClampedArray ? t[n] = Math.floor(os(t[n] / 255) * 255) : t[n] = os(t[n]);+ return {+ data: t,+ width: e.width,+ height: e.height+ };+ } else+ return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."), e;+ }+}+let DE = 0;+class Ef {+ /**+ * Constructs a new video texture.+ *+ * @param {any} [data=null] - The data definition of a texture.+ */+ constructor(e = null) {+ this.isSource = !0, Object.defineProperty(this, "id", { value: DE++ }), this.uuid = Ei(), this.data = e, this.dataReady = !0, this.version = 0;+ }+ /**+ * When the property is set to `true`, the engine allocates the memory+ * for the texture (if necessary) and triggers the actual texture upload+ * to the GPU next time the source is used.+ *+ * @type {boolean}+ * @default false+ * @param {boolean} value+ */+ set needsUpdate(e) {+ e === !0 && this.version++;+ }+ /**+ * Serializes the source into JSON.+ *+ * @param {?(Object|string)} meta - An optional value holding meta information about the serialization.+ * @return {Object} A JSON object representing the serialized source.+ * @see {@link ObjectLoader#parse}+ */+ toJSON(e) {+ const t = e === void 0 || typeof e == "string";+ if (!t && e.images[this.uuid] !== void 0)+ return e.images[this.uuid];+ const n = {+ uuid: this.uuid,+ url: ""+ }, s = this.data;+ if (s !== null) {+ let r;+ if (Array.isArray(s)) {+ r = [];+ for (let a = 0, o = s.length; a < o; a++)+ s[a].isDataTexture ? r.push(yh(s[a].image)) : r.push(yh(s[a]));+ } else+ r = yh(s);+ n.url = r;+ }+ return t || (e.images[this.uuid] = n), n;+ }+}+function yh(i) {+ return typeof HTMLImageElement < "u" && i instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && i instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && i instanceof ImageBitmap ? FE.getDataURL(i) : i.data ? {+ data: Array.from(i.data),+ width: i.width,+ height: i.height,+ type: i.data.constructor.name+ } : (console.warn("THREE.Texture: Unable to serialize Texture."), {});+}+let LE = 0;+class cn extends zs {+ /**+ * Constructs a new texture.+ *+ * @param {?Object} [image=Texture.DEFAULT_IMAGE] - The image holding the texture data.+ * @param {number} [mapping=Texture.DEFAULT_MAPPING] - The texture mapping.+ * @param {number} [wrapS=ClampToEdgeWrapping] - The wrapS value.+ * @param {number} [wrapT=ClampToEdgeWrapping] - The wrapT value.+ * @param {number} [magFilter=LinearFilter] - The mag filter value.+ * @param {number} [minFilter=LinearMipmapLinearFilter] - The min filter value.+ * @param {number} [format=RGBAFormat] - The texture format.+ * @param {number} [type=UnsignedByteType] - The texture type.+ * @param {number} [anisotropy=Texture.DEFAULT_ANISOTROPY] - The anisotropy value.+ * @param {string} [colorSpace=NoColorSpace] - The color space.+ */+ constructor(e = cn.DEFAULT_IMAGE, t = cn.DEFAULT_MAPPING, n = _i, s = _i, r = qt, a = si, o = on, c = rn, l = cn.DEFAULT_ANISOTROPY, h = gi) {+ super(), this.isTexture = !0, Object.defineProperty(this, "id", { value: LE++ }), this.uuid = Ei(), this.name = "", this.source = new Ef(e), this.mipmaps = [], this.mapping = t, this.channel = 0, this.wrapS = n, this.wrapT = s, this.magFilter = r, this.minFilter = a, this.anisotropy = l, this.format = o, this.internalFormat = null, this.type = c, this.offset = new Ze(0, 0), this.repeat = new Ze(1, 1), this.center = new Ze(0, 0), this.rotation = 0, this.matrixAutoUpdate = !0, this.matrix = new rt(), this.generateMipmaps = !0, this.premultiplyAlpha = !1, this.flipY = !0, this.unpackAlignment = 4, this.colorSpace = h, this.userData = {}, this.version = 0, this.onUpdate = null, this.renderTarget = null, this.isRenderTargetTexture = !1, this.isTextureArray = !1, this.pmremVersion = 0;+ }+ /**+ * The image object holding the texture data.+ *+ * @type {?Object}+ */+ get image() {+ return this.source.data;+ }+ set image(e = null) {+ this.source.data = e;+ }+ /**+ * Updates the texture transformation matrix from the from the properties {@link Texture#offset},+ * {@link Texture#repeat}, {@link Texture#rotation}, and {@link Texture#center}.+ */+ updateMatrix() {+ this.matrix.setUvTransform(this.offset.x, this.offset.y, this.repeat.x, this.repeat.y, this.rotation, this.center.x, this.center.y);+ }+ /**+ * Returns a new texture with copied values from this instance.+ *+ * @return {Texture} A clone of this instance.+ */+ clone() {+ return new this.constructor().copy(this);+ }+ /**+ * Copies the values of the given texture to this instance.+ *+ * @param {Texture} source - The texture to copy.+ * @return {Texture} A reference to this instance.+ */+ copy(e) {+ return this.name = e.name, this.source = e.source, this.mipmaps = e.mipmaps.slice(0), this.mapping = e.mapping, this.channel = e.channel, this.wrapS = e.wrapS, this.wrapT = e.wrapT, this.magFilter = e.magFilter, this.minFilter = e.minFilter, this.anisotropy = e.anisotropy, this.format = e.format, this.internalFormat = e.internalFormat, this.type = e.type, this.offset.copy(e.offset), this.repeat.copy(e.repeat), this.center.copy(e.center), this.rotation = e.rotation, this.matrixAutoUpdate = e.matrixAutoUpdate, this.matrix.copy(e.matrix), this.generateMipmaps = e.generateMipmaps, this.premultiplyAlpha = e.premultiplyAlpha, this.flipY = e.flipY, this.unpackAlignment = e.unpackAlignment, this.colorSpace = e.colorSpace, this.renderTarget = e.renderTarget, this.isRenderTargetTexture = e.isRenderTargetTexture, this.isTextureArray = e.isTextureArray, this.userData = JSON.parse(JSON.stringify(e.userData)), this.needsUpdate = !0, this;+ }+ /**+ * Serializes the texture into JSON.+ *+ * @param {?(Object|string)} meta - An optional value holding meta information about the serialization.+ * @return {Object} A JSON object representing the serialized texture.+ * @see {@link ObjectLoader#parse}+ */+ toJSON(e) {+ const t = e === void 0 || typeof e == "string";+ if (!t && e.textures[this.uuid] !== void 0)+ return e.textures[this.uuid];+ const n = {+ metadata: {+ version: 4.6,+ type: "Texture",+ generator: "Texture.toJSON"+ },+ uuid: this.uuid,+ name: this.name,+ image: this.source.toJSON(e).uuid,+ mapping: this.mapping,+ channel: this.channel,+ repeat: [this.repeat.x, this.repeat.y],+ offset: [this.offset.x, this.offset.y],+ center: [this.center.x, this.center.y],+ rotation: this.rotation,+ wrap: [this.wrapS, this.wrapT],+ format: this.format,+ internalFormat: this.internalFormat,+ type: this.type,+ colorSpace: this.colorSpace,+ minFilter: this.minFilter,+ magFilter: this.magFilter,+ anisotropy: this.anisotropy,+ flipY: this.flipY,+ generateMipmaps: this.generateMipmaps,+ premultiplyAlpha: this.premultiplyAlpha,+ unpackAlignment: this.unpackAlignment+ };+ return Object.keys(this.userData).length > 0 && (n.userData = this.userData), t || (e.textures[this.uuid] = n), n;+ }+ /**+ * Frees the GPU-related resources allocated by this instance. Call this+ * method whenever this instance is no longer used in your app.+ *+ * @fires Texture#dispose+ */+ dispose() {+ this.dispatchEvent({ type: "dispose" });+ }+ /**+ * Transforms the given uv vector with the textures uv transformation matrix.+ *+ * @param {Vector2} uv - The uv vector.+ * @return {Vector2} The transformed uv vector.+ */+ transformUv(e) {+ if (this.mapping !== Wm) return e;+ if (e.applyMatrix3(this.matrix), e.x < 0 || e.x > 1)+ switch (this.wrapS) {+ case Ca:+ e.x = e.x - Math.floor(e.x);+ break;+ case _i:+ e.x = e.x < 0 ? 0 : 1;+ break;+ case El:+ Math.abs(Math.floor(e.x) % 2) === 1 ? e.x = Math.ceil(e.x) - e.x : e.x = e.x - Math.floor(e.x);+ break;+ }+ if (e.y < 0 || e.y > 1)+ switch (this.wrapT) {+ case Ca:+ e.y = e.y - Math.floor(e.y);+ break;+ case _i:+ e.y = e.y < 0 ? 0 : 1;+ break;+ case El:+ Math.abs(Math.floor(e.y) % 2) === 1 ? e.y = Math.ceil(e.y) - e.y : e.y = e.y - Math.floor(e.y);+ break;+ }+ return this.flipY && (e.y = 1 - e.y), e;+ }+ /**+ * Setting this property to `true` indicates the engine the texture+ * must be updated in the next render. This triggers a texture upload+ * to the GPU and ensures correct texture parameter configuration.+ *+ * @type {boolean}+ * @default false+ * @param {boolean} value+ */+ set needsUpdate(e) {+ e === !0 && (this.version++, this.source.needsUpdate = !0);+ }+ /**+ * Setting this property to `true` indicates the engine the PMREM+ * must be regenerated.+ *+ * @type {boolean}+ * @default false+ * @param {boolean} value+ */+ set needsPMREMUpdate(e) {+ e === !0 && this.pmremVersion++;+ }+}+cn.DEFAULT_IMAGE = null;+cn.DEFAULT_MAPPING = Wm;+cn.DEFAULT_ANISOTROPY = 1;+class wt {+ /**+ * Constructs a new 4D vector.+ *+ * @param {number} [x=0] - The x value of this vector.+ * @param {number} [y=0] - The y value of this vector.+ * @param {number} [z=0] - The z value of this vector.+ * @param {number} [w=1] - The w value of this vector.+ */+ constructor(e = 0, t = 0, n = 0, s = 1) {+ wt.prototype.isVector4 = !0, this.x = e, this.y = t, this.z = n, this.w = s;+ }+ /**+ * Alias for {@link Vector4#z}.+ *+ * @type {number}+ */+ get width() {+ return this.z;+ }+ set width(e) {+ this.z = e;+ }+ /**+ * Alias for {@link Vector4#w}.+ *+ * @type {number}+ */+ get height() {+ return this.w;+ }+ set height(e) {+ this.w = e;+ }+ /**+ * Sets the vector components.+ *+ * @param {number} x - The value of the x component.+ * @param {number} y - The value of the y component.+ * @param {number} z - The value of the z component.+ * @param {number} w - The value of the w component.+ * @return {Vector4} A reference to this vector.+ */+ set(e, t, n, s) {+ return this.x = e, this.y = t, this.z = n, this.w = s, this;+ }+ /**+ * Sets the vector components to the same value.+ *+ * @param {number} scalar - The value to set for all vector components.+ * @return {Vector4} A reference to this vector.+ */+ setScalar(e) {+ return this.x = e, this.y = e, this.z = e, this.w = e, this;+ }+ /**+ * Sets the vector's x component to the given value+ *+ * @param {number} x - The value to set.+ * @return {Vector4} A reference to this vector.+ */+ setX(e) {+ return this.x = e, this;+ }+ /**+ * Sets the vector's y component to the given value+ *+ * @param {number} y - The value to set.+ * @return {Vector4} A reference to this vector.+ */+ setY(e) {+ return this.y = e, this;+ }+ /**+ * Sets the vector's z component to the given value+ *+ * @param {number} z - The value to set.+ * @return {Vector4} A reference to this vector.+ */+ setZ(e) {+ return this.z = e, this;+ }+ /**+ * Sets the vector's w component to the given value+ *+ * @param {number} w - The value to set.+ * @return {Vector4} A reference to this vector.+ */+ setW(e) {+ return this.w = e, this;+ }+ /**+ * Allows to set a vector component with an index.+ *+ * @param {number} index - The component index. `0` equals to x, `1` equals to y,+ * `2` equals to z, `3` equals to w.+ * @param {number} value - The value to set.+ * @return {Vector4} A reference to this vector.+ */+ 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 new Error("index is out of range: " + e);+ }+ return this;+ }+ /**+ * Returns the value of the vector component which matches the given index.+ *+ * @param {number} index - The component index. `0` equals to x, `1` equals to y,+ * `2` equals to z, `3` equals to w.+ * @return {number} A vector component value.+ */+ getComponent(e) {+ switch (e) {+ case 0:+ return this.x;+ case 1:+ return this.y;+ case 2:+ return this.z;+ case 3:+ return this.w;+ default:+ throw new Error("index is out of range: " + e);+ }+ }+ /**+ * Returns a new vector with copied values from this instance.+ *+ * @return {Vector4} A clone of this instance.+ */+ clone() {+ return new this.constructor(this.x, this.y, this.z, this.w);+ }+ /**+ * Copies the values of the given vector to this instance.+ *+ * @param {Vector3|Vector4} v - The vector to copy.+ * @return {Vector4} A reference to this vector.+ */+ copy(e) {+ return this.x = e.x, this.y = e.y, this.z = e.z, this.w = e.w !== void 0 ? e.w : 1, this;+ }+ /**+ * Adds the given vector to this instance.+ *+ * @param {Vector4} v - The vector to add.+ * @return {Vector4} A reference to this vector.+ */+ add(e) {+ return this.x += e.x, this.y += e.y, this.z += e.z, this.w += e.w, this;+ }+ /**+ * Adds the given scalar value to all components of this instance.+ *+ * @param {number} s - The scalar to add.+ * @return {Vector4} A reference to this vector.+ */+ addScalar(e) {+ return this.x += e, this.y += e, this.z += e, this.w += e, this;+ }+ /**+ * Adds the given vectors and stores the result in this instance.+ *+ * @param {Vector4} a - The first vector.+ * @param {Vector4} b - The second vector.+ * @return {Vector4} A reference to this vector.+ */+ 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;+ }+ /**+ * Adds the given vector scaled by the given factor to this instance.+ *+ * @param {Vector4} v - The vector.+ * @param {number} s - The factor that scales `v`.+ * @return {Vector4} A reference to this vector.+ */+ 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;+ }+ /**+ * Subtracts the given vector from this instance.+ *+ * @param {Vector4} v - The vector to subtract.+ * @return {Vector4} A reference to this vector.+ */+ sub(e) {+ return this.x -= e.x, this.y -= e.y, this.z -= e.z, this.w -= e.w, this;+ }+ /**+ * Subtracts the given scalar value from all components of this instance.+ *+ * @param {number} s - The scalar to subtract.+ * @return {Vector4} A reference to this vector.+ */+ subScalar(e) {+ return this.x -= e, this.y -= e, this.z -= e, this.w -= e, this;+ }+ /**+ * Subtracts the given vectors and stores the result in this instance.+ *+ * @param {Vector4} a - The first vector.+ * @param {Vector4} b - The second vector.+ * @return {Vector4} A reference to this vector.+ */+ 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;+ }+ /**+ * Multiplies the given vector with this instance.+ *+ * @param {Vector4} v - The vector to multiply.+ * @return {Vector4} A reference to this vector.+ */+ multiply(e) {+ return this.x *= e.x, this.y *= e.y, this.z *= e.z, this.w *= e.w, this;+ }+ /**+ * Multiplies the given scalar value with all components of this instance.+ *+ * @param {number} scalar - The scalar to multiply.+ * @return {Vector4} A reference to this vector.+ */+ multiplyScalar(e) {+ return this.x *= e, this.y *= e, this.z *= e, this.w *= e, this;+ }+ /**+ * Multiplies this vector with the given 4x4 matrix.+ *+ * @param {Matrix4} m - The 4x4 matrix.+ * @return {Vector4} A reference to this vector.+ */+ applyMatrix4(e) {+ const t = this.x, n = this.y, s = this.z, r = this.w, a = e.elements;+ return this.x = a[0] * t + a[4] * n + a[8] * s + a[12] * r, this.y = a[1] * t + a[5] * n + a[9] * s + a[13] * r, this.z = a[2] * t + a[6] * n + a[10] * s + a[14] * r, this.w = a[3] * t + a[7] * n + a[11] * s + a[15] * r, this;+ }+ /**+ * Divides this instance by the given vector.+ *+ * @param {Vector4} v - The vector to divide.+ * @return {Vector4} A reference to this vector.+ */+ divide(e) {+ return this.x /= e.x, this.y /= e.y, this.z /= e.z, this.w /= e.w, this;+ }+ /**+ * Divides this vector by the given scalar.+ *+ * @param {number} scalar - The scalar to divide.+ * @return {Vector4} A reference to this vector.+ */+ divideScalar(e) {+ return this.multiplyScalar(1 / e);+ }+ /**+ * Sets the x, y and z components of this+ * vector to the quaternion's axis and w to the angle.+ *+ * @param {Quaternion} q - The Quaternion to set.+ * @return {Vector4} A reference to this vector.+ */+ setAxisAngleFromQuaternion(e) {+ this.w = 2 * Math.acos(e.w);+ const 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;+ }+ /**+ * Sets the x, y and z components of this+ * vector to the axis of rotation and w to the angle.+ *+ * @param {Matrix4} m - A 4x4 matrix of which the upper left 3x3 matrix is a pure rotation matrix.+ * @return {Vector4} A reference to this vector.+ */+ setAxisAngleFromRotationMatrix(e) {+ let t, n, s, r;+ const c = e.elements, l = c[0], h = c[4], u = c[8], d = c[1], f = c[5], m = c[9], A = c[2], g = c[6], p = c[10];+ if (Math.abs(h - d) < 0.01 && Math.abs(u - A) < 0.01 && Math.abs(m - g) < 0.01) {+ if (Math.abs(h + d) < 0.1 && Math.abs(u + A) < 0.1 && Math.abs(m + g) < 0.1 && Math.abs(l + f + p - 3) < 0.1)+ return this.set(1, 0, 0, 0), this;+ t = Math.PI;+ const b = (l + 1) / 2, E = (f + 1) / 2, M = (p + 1) / 2, w = (h + d) / 4, S = (u + A) / 4, T = (m + g) / 4;+ return b > E && b > M ? b < 0.01 ? (n = 0, s = 0.707106781, r = 0.707106781) : (n = Math.sqrt(b), s = w / n, r = S / n) : E > M ? E < 0.01 ? (n = 0.707106781, s = 0, r = 0.707106781) : (s = Math.sqrt(E), n = w / s, r = T / s) : M < 0.01 ? (n = 0.707106781, s = 0.707106781, r = 0) : (r = Math.sqrt(M), n = S / r, s = T / r), this.set(n, s, r, t), this;+ }+ let y = Math.sqrt((g - m) * (g - m) + (u - A) * (u - A) + (d - h) * (d - h));+ return Math.abs(y) < 1e-3 && (y = 1), this.x = (g - m) / y, this.y = (u - A) / y, this.z = (d - h) / y, this.w = Math.acos((l + f + p - 1) / 2), this;+ }+ /**+ * Sets the vector components to the position elements of the+ * given transformation matrix.+ *+ * @param {Matrix4} m - The 4x4 matrix.+ * @return {Vector4} A reference to this vector.+ */+ setFromMatrixPosition(e) {+ const t = e.elements;+ return this.x = t[12], this.y = t[13], this.z = t[14], this.w = t[15], this;+ }+ /**+ * If this vector's x, y, z or w value is greater than the given vector's x, y, z or w+ * value, replace that value with the corresponding min value.+ *+ * @param {Vector4} v - The vector.+ * @return {Vector4} A reference to this vector.+ */+ 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;+ }+ /**+ * If this vector's x, y, z or w value is less than the given vector's x, y, z or w+ * value, replace that value with the corresponding max value.+ *+ * @param {Vector4} v - The vector.+ * @return {Vector4} A reference to this vector.+ */+ 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;+ }+ /**+ * If this vector's x, y, z or w value is greater than the max vector's x, y, z or w+ * value, it is replaced by the corresponding value.+ * If this vector's x, y, z or w value is less than the min vector's x, y, z or w value,+ * it is replaced by the corresponding value.+ *+ * @param {Vector4} min - The minimum x, y and z values.+ * @param {Vector4} max - The maximum x, y and z values in the desired range.+ * @return {Vector4} A reference to this vector.+ */+ clamp(e, t) {+ return this.x = ct(this.x, e.x, t.x), this.y = ct(this.y, e.y, t.y), this.z = ct(this.z, e.z, t.z), this.w = ct(this.w, e.w, t.w), this;+ }+ /**+ * If this vector's x, y, z or w values are greater than the max value, they are+ * replaced by the max value.+ * If this vector's x, y, z or w values are less than the min value, they are+ * replaced by the min value.+ *+ * @param {number} minVal - The minimum value the components will be clamped to.+ * @param {number} maxVal - The maximum value the components will be clamped to.+ * @return {Vector4} A reference to this vector.+ */+ clampScalar(e, t) {+ return this.x = ct(this.x, e, t), this.y = ct(this.y, e, t), this.z = ct(this.z, e, t), this.w = ct(this.w, e, t), this;+ }+ /**+ * If this vector's length is greater than the max value, it is replaced by+ * the max value.+ * If this vector's length is less than the min value, it is replaced by the+ * min value.+ *+ * @param {number} min - The minimum value the vector length will be clamped to.+ * @param {number} max - The maximum value the vector length will be clamped to.+ * @return {Vector4} A reference to this vector.+ */+ clampLength(e, t) {+ const n = this.length();+ return this.divideScalar(n || 1).multiplyScalar(ct(n, e, t));+ }+ /**+ * The components of this vector are rounded down to the nearest integer value.+ *+ * @return {Vector4} A reference to this vector.+ */+ 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;+ }+ /**+ * The components of this vector are rounded up to the nearest integer value.+ *+ * @return {Vector4} A reference to this vector.+ */+ 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;+ }+ /**+ * The components of this vector are rounded to the nearest integer value+ *+ * @return {Vector4} A reference to this vector.+ */+ 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;+ }+ /**+ * The components of this vector are rounded towards zero (up if negative,+ * down if positive) to an integer value.+ *+ * @return {Vector4} A reference to this vector.+ */+ 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;+ }+ /**+ * Inverts this vector - i.e. sets x = -x, y = -y, z = -z, w = -w.+ *+ * @return {Vector4} A reference to this vector.+ */+ negate() {+ return this.x = -this.x, this.y = -this.y, this.z = -this.z, this.w = -this.w, this;+ }+ /**+ * Calculates the dot product of the given vector with this instance.+ *+ * @param {Vector4} v - The vector to compute the dot product with.+ * @return {number} The result of the dot product.+ */+ dot(e) {+ return this.x * e.x + this.y * e.y + this.z * e.z + this.w * e.w;+ }+ /**+ * Computes the square of the Euclidean length (straight-line length) from+ * (0, 0, 0, 0) to (x, y, z, w). If you are comparing the lengths of vectors, you should+ * compare the length squared instead as it is slightly more efficient to calculate.+ *+ * @return {number} The square length of this vector.+ */+ lengthSq() {+ return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w;+ }+ /**+ * Computes the Euclidean length (straight-line length) from (0, 0, 0, 0) to (x, y, z, w).+ *+ * @return {number} The length of this vector.+ */+ length() {+ return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);+ }+ /**+ * Computes the Manhattan length of this vector.+ *+ * @return {number} The length of this vector.+ */+ manhattanLength() {+ return Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z) + Math.abs(this.w);+ }+ /**+ * Converts this vector to a unit vector - that is, sets it equal to a vector+ * with the same direction as this one, but with a vector length of `1`.+ *+ * @return {Vector4} A reference to this vector.+ */+ normalize() {+ return this.divideScalar(this.length() || 1);+ }+ /**+ * Sets this vector to a vector with the same direction as this one, but+ * with the specified length.+ *+ * @param {number} length - The new length of this vector.+ * @return {Vector4} A reference to this vector.+ */+ setLength(e) {+ return this.normalize().multiplyScalar(e);+ }+ /**+ * Linearly interpolates between the given vector and this instance, where+ * alpha is the percent distance along the line - alpha = 0 will be this+ * vector, and alpha = 1 will be the given one.+ *+ * @param {Vector4} v - The vector to interpolate towards.+ * @param {number} alpha - The interpolation factor, typically in the closed interval `[0, 1]`.+ * @return {Vector4} A reference to this vector.+ */+ 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;+ }+ /**+ * Linearly interpolates between the given vectors, where alpha is the percent+ * distance along the line - alpha = 0 will be first vector, and alpha = 1 will+ * be the second one. The result is stored in this instance.+ *+ * @param {Vector4} v1 - The first vector.+ * @param {Vector4} v2 - The second vector.+ * @param {number} alpha - The interpolation factor, typically in the closed interval `[0, 1]`.+ * @return {Vector4} A reference to this vector.+ */+ 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;+ }+ /**+ * Returns `true` if this vector is equal with the given one.+ *+ * @param {Vector4} v - The vector to test for equality.+ * @return {boolean} Whether this vector is equal with the given one.+ */+ equals(e) {+ return e.x === this.x && e.y === this.y && e.z === this.z && e.w === this.w;+ }+ /**+ * Sets this vector's x value to be `array[ offset ]`, y value to be `array[ offset + 1 ]`,+ * z value to be `array[ offset + 2 ]`, w value to be `array[ offset + 3 ]`.+ *+ * @param {Array<number>} array - An array holding the vector component values.+ * @param {number} [offset=0] - The offset into the array.+ * @return {Vector4} A reference to this vector.+ */+ 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;+ }+ /**+ * Writes the components of this vector to the given array. If no array is provided,+ * the method returns a new instance.+ *+ * @param {Array<number>} [array=[]] - The target array holding the vector components.+ * @param {number} [offset=0] - Index of the first element in the array.+ * @return {Array<number>} The vector components.+ */+ 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;+ }+ /**+ * Sets the components of this vector from the given buffer attribute.+ *+ * @param {BufferAttribute} attribute - The buffer attribute holding vector data.+ * @param {number} index - The index into the attribute.+ * @return {Vector4} A reference to this vector.+ */+ 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;+ }+ /**+ * Sets each component of this vector to a pseudo-random value between `0` and+ * `1`, excluding `1`.+ *+ * @return {Vector4} A reference to this vector.+ */+ random() {+ return this.x = Math.random(), this.y = Math.random(), this.z = Math.random(), this.w = Math.random(), this;+ }+ *[Symbol.iterator]() {+ yield this.x, yield this.y, yield this.z, yield this.w;+ }+}+class PE extends zs {+ /**+ * Render target options.+ *+ * @typedef {Object} RenderTarget~Options+ * @property {boolean} [generateMipmaps=false] - Whether to generate mipmaps or not.+ * @property {number} [magFilter=LinearFilter] - The mag filter.+ * @property {number} [minFilter=LinearFilter] - The min filter.+ * @property {number} [format=RGBAFormat] - The texture format.+ * @property {number} [type=UnsignedByteType] - The texture type.+ * @property {?string} [internalFormat=null] - The texture's internal format.+ * @property {number} [wrapS=ClampToEdgeWrapping] - The texture's uv wrapping mode.+ * @property {number} [wrapT=ClampToEdgeWrapping] - The texture's uv wrapping mode.+ * @property {number} [anisotropy=1] - The texture's anisotropy value.+ * @property {string} [colorSpace=NoColorSpace] - The texture's color space.+ * @property {boolean} [depthBuffer=true] - Whether to allocate a depth buffer or not.+ * @property {boolean} [stencilBuffer=false] - Whether to allocate a stencil buffer or not.+ * @property {boolean} [resolveDepthBuffer=true] - Whether to resolve the depth buffer or not.+ * @property {boolean} [resolveStencilBuffer=true] - Whether to resolve the stencil buffer or not.+ * @property {?Texture} [depthTexture=null] - Reference to a depth texture.+ * @property {number} [samples=0] - The MSAA samples count.+ * @property {number} [count=1] - Defines the number of color attachments . Must be at least `1`.+ * @property {boolean} [multiview=false] - Whether this target is used for multiview rendering.+ */+ /**+ * Constructs a new render target.+ *+ * @param {number} [width=1] - The width of the render target.+ * @param {number} [height=1] - The height of the render target.+ * @param {RenderTarget~Options} [options] - The configuration object.+ */+ constructor(e = 1, t = 1, n = {}) {+ super(), this.isRenderTarget = !0, this.width = e, this.height = t, this.depth = n.depth ? n.depth : 1, this.scissor = new wt(0, 0, e, t), this.scissorTest = !1, this.viewport = new wt(0, 0, e, t);+ const s = { width: e, height: t, depth: this.depth };+ n = Object.assign({+ generateMipmaps: !1,+ internalFormat: null,+ minFilter: qt,+ depthBuffer: !0,+ stencilBuffer: !1,+ resolveDepthBuffer: !0,+ resolveStencilBuffer: !0,+ depthTexture: null,+ samples: 0,+ count: 1,+ multiview: !1+ }, n);+ const r = new cn(s, n.mapping, n.wrapS, n.wrapT, n.magFilter, n.minFilter, n.format, n.type, n.anisotropy, n.colorSpace);+ r.flipY = !1, r.generateMipmaps = n.generateMipmaps, r.internalFormat = n.internalFormat, this.textures = [];+ const a = n.count;+ for (let o = 0; o < a; o++)+ this.textures[o] = r.clone(), this.textures[o].isRenderTargetTexture = !0, this.textures[o].renderTarget = this;+ this.depthBuffer = n.depthBuffer, this.stencilBuffer = n.stencilBuffer, this.resolveDepthBuffer = n.resolveDepthBuffer, this.resolveStencilBuffer = n.resolveStencilBuffer, this._depthTexture = null, this.depthTexture = n.depthTexture, this.samples = n.samples, this.multiview = n.multiview;+ }+ /**+ * The texture representing the default color attachment.+ *+ * @type {Texture}+ */+ get texture() {+ return this.textures[0];+ }+ set texture(e) {+ this.textures[0] = e;+ }+ set depthTexture(e) {+ this._depthTexture !== null && (this._depthTexture.renderTarget = null), e !== null && (e.renderTarget = this), this._depthTexture = e;+ }+ /**+ * Instead of saving the depth in a renderbuffer, a texture+ * can be used instead which is useful for further processing+ * e.g. in context of post-processing.+ *+ * @type {?DepthTexture}+ * @default null+ */+ get depthTexture() {+ return this._depthTexture;+ }+ /**+ * Sets the size of this render target.+ *+ * @param {number} width - The width.+ * @param {number} height - The height.+ * @param {number} [depth=1] - The depth.+ */+ 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 s = 0, r = this.textures.length; s < r; s++)+ this.textures[s].image.width = e, this.textures[s].image.height = t, this.textures[s].image.depth = n;+ this.dispose();+ }+ this.viewport.set(0, 0, e, t), this.scissor.set(0, 0, e, t);+ }+ /**+ * Returns a new render target with copied values from this instance.+ *+ * @return {RenderTarget} A clone of this instance.+ */+ clone() {+ return new this.constructor().copy(this);+ }+ /**+ * Copies the settings of the given render target. This is a structural copy so+ * no resources are shared between render targets after the copy. That includes+ * all MRT textures and the depth texture.+ *+ * @param {RenderTarget} source - The render target to copy.+ * @return {RenderTarget} A reference to this instance.+ */+ 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;+ const s = Object.assign({}, e.textures[t].image);+ this.textures[t].source = new Ef(s);+ }+ return this.depthBuffer = e.depthBuffer, this.stencilBuffer = e.stencilBuffer, this.resolveDepthBuffer = e.resolveDepthBuffer, this.resolveStencilBuffer = e.resolveStencilBuffer, e.depthTexture !== null && (this.depthTexture = e.depthTexture.clone()), this.samples = e.samples, this;+ }+ /**+ * Frees the GPU-related resources allocated by this instance. Call this+ * method whenever this instance is no longer used in your app.+ *+ * @fires RenderTarget#dispose+ */+ dispose() {+ this.dispatchEvent({ type: "dispose" });+ }+}+class wr extends PE {+ /**+ * Constructs a new 3D render target.+ *+ * @param {number} [width=1] - The width of the render target.+ * @param {number} [height=1] - The height of the render target.+ * @param {RenderTarget~Options} [options] - The configuration object.+ */+ constructor(e = 1, t = 1, n = {}) {+ super(e, t, n), this.isWebGLRenderTarget = !0;+ }+}+class a0 extends cn {+ /**+ * Constructs a new data array texture.+ *+ * @param {?TypedArray} [data=null] - The buffer data.+ * @param {number} [width=1] - The width of the texture.+ * @param {number} [height=1] - The height of the texture.+ * @param {number} [depth=1] - The depth of the texture.+ */+ constructor(e = null, t = 1, n = 1, s = 1) {+ super(null), this.isDataArrayTexture = !0, this.image = { data: e, width: t, height: n, depth: s }, this.magFilter = kn, this.minFilter = kn, this.wrapR = _i, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1, this.layerUpdates = /* @__PURE__ */ new Set();+ }+ /**+ * Describes that a specific layer of the texture needs to be updated.+ * Normally when {@link Texture#needsUpdate} is set to `true`, the+ * entire data texture array is sent to the GPU. Marking specific+ * layers will only transmit subsets of all mipmaps associated with a+ * specific depth in the array which is often much more performant.+ *+ * @param {number} layerIndex - The layer index that should be updated.+ */+ addLayerUpdate(e) {+ this.layerUpdates.add(e);+ }+ /**+ * Resets the layer updates registry.+ */+ clearLayerUpdates() {+ this.layerUpdates.clear();+ }+}+class o0 extends cn {+ /**+ * Constructs a new data array texture.+ *+ * @param {?TypedArray} [data=null] - The buffer data.+ * @param {number} [width=1] - The width of the texture.+ * @param {number} [height=1] - The height of the texture.+ * @param {number} [depth=1] - The depth of the texture.+ */+ constructor(e = null, t = 1, n = 1, s = 1) {+ super(null), this.isData3DTexture = !0, this.image = { data: e, width: t, height: n, depth: s }, this.magFilter = kn, this.minFilter = kn, this.wrapR = _i, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1;+ }+}+class Yn {+ /**+ * Constructs a new quaternion.+ *+ * @param {number} [x=0] - The x value of this quaternion.+ * @param {number} [y=0] - The y value of this quaternion.+ * @param {number} [z=0] - The z value of this quaternion.+ * @param {number} [w=1] - The w value of this quaternion.+ */+ constructor(e = 0, t = 0, n = 0, s = 1) {+ this.isQuaternion = !0, this._x = e, this._y = t, this._z = n, this._w = s;+ }+ /**+ * Interpolates between two quaternions via SLERP. This implementation assumes the+ * quaternion data are managed in flat arrays.+ *+ * @param {Array<number>} dst - The destination array.+ * @param {number} dstOffset - An offset into the destination array.+ * @param {Array<number>} src0 - The source array of the first quaternion.+ * @param {number} srcOffset0 - An offset into the first source array.+ * @param {Array<number>} src1 - The source array of the second quaternion.+ * @param {number} srcOffset1 - An offset into the second source array.+ * @param {number} t - The interpolation factor in the range `[0,1]`.+ * @see {@link Quaternion#slerp}+ */+ static slerpFlat(e, t, n, s, r, a, o) {+ let c = n[s + 0], l = n[s + 1], h = n[s + 2], u = n[s + 3];+ const d = r[a + 0], f = r[a + 1], m = r[a + 2], A = r[a + 3];+ if (o === 0) {+ e[t + 0] = c, e[t + 1] = l, e[t + 2] = h, e[t + 3] = u;+ return;+ }+ if (o === 1) {+ e[t + 0] = d, e[t + 1] = f, e[t + 2] = m, e[t + 3] = A;+ return;+ }+ if (u !== A || c !== d || l !== f || h !== m) {+ let g = 1 - o;+ const p = c * d + l * f + h * m + u * A, y = p >= 0 ? 1 : -1, b = 1 - p * p;+ if (b > Number.EPSILON) {+ const M = Math.sqrt(b), w = Math.atan2(M, p * y);+ g = Math.sin(g * w) / M, o = Math.sin(o * w) / M;+ }+ const E = o * y;+ if (c = c * g + d * E, l = l * g + f * E, h = h * g + m * E, u = u * g + A * E, g === 1 - o) {+ const M = 1 / Math.sqrt(c * c + l * l + h * h + u * u);+ c *= M, l *= M, h *= M, u *= M;+ }+ }+ e[t] = c, e[t + 1] = l, e[t + 2] = h, e[t + 3] = u;+ }+ /**+ * Multiplies two quaternions. This implementation assumes the quaternion data are managed+ * in flat arrays.+ *+ * @param {Array<number>} dst - The destination array.+ * @param {number} dstOffset - An offset into the destination array.+ * @param {Array<number>} src0 - The source array of the first quaternion.+ * @param {number} srcOffset0 - An offset into the first source array.+ * @param {Array<number>} src1 - The source array of the second quaternion.+ * @param {number} srcOffset1 - An offset into the second source array.+ * @return {Array<number>} The destination array.+ * @see {@link Quaternion#multiplyQuaternions}.+ */+ static multiplyQuaternionsFlat(e, t, n, s, r, a) {+ const o = n[s], c = n[s + 1], l = n[s + 2], h = n[s + 3], u = r[a], d = r[a + 1], f = r[a + 2], m = r[a + 3];+ return e[t] = o * m + h * u + c * f - l * d, e[t + 1] = c * m + h * d + l * u - o * f, e[t + 2] = l * m + h * f + o * d - c * u, e[t + 3] = h * m - o * u - c * d - l * f, e;+ }+ /**+ * The x value of this quaternion.+ *+ * @type {number}+ * @default 0+ */+ get x() {+ return this._x;+ }+ set x(e) {+ this._x = e, this._onChangeCallback();+ }+ /**+ * The y value of this quaternion.+ *+ * @type {number}+ * @default 0+ */+ get y() {+ return this._y;+ }+ set y(e) {+ this._y = e, this._onChangeCallback();+ }+ /**+ * The z value of this quaternion.+ *+ * @type {number}+ * @default 0+ */+ get z() {+ return this._z;+ }+ set z(e) {+ this._z = e, this._onChangeCallback();+ }+ /**+ * The w value of this quaternion.+ *+ * @type {number}+ * @default 1+ */+ get w() {+ return this._w;+ }+ set w(e) {+ this._w = e, this._onChangeCallback();+ }+ /**+ * Sets the quaternion components.+ *+ * @param {number} x - The x value of this quaternion.+ * @param {number} y - The y value of this quaternion.+ * @param {number} z - The z value of this quaternion.+ * @param {number} w - The w value of this quaternion.+ * @return {Quaternion} A reference to this quaternion.+ */+ set(e, t, n, s) {+ return this._x = e, this._y = t, this._z = n, this._w = s, this._onChangeCallback(), this;+ }+ /**+ * Returns a new quaternion with copied values from this instance.+ *+ * @return {Quaternion} A clone of this instance.+ */+ clone() {+ return new this.constructor(this._x, this._y, this._z, this._w);+ }+ /**+ * Copies the values of the given quaternion to this instance.+ *+ * @param {Quaternion} quaternion - The quaternion to copy.+ * @return {Quaternion} A reference to this quaternion.+ */+ copy(e) {+ return this._x = e.x, this._y = e.y, this._z = e.z, this._w = e.w, this._onChangeCallback(), this;+ }+ /**+ * Sets this quaternion from the rotation specified by the given+ * Euler angles.+ *+ * @param {Euler} euler - The Euler angles.+ * @param {boolean} [update=true] - Whether the internal `onChange` callback should be executed or not.+ * @return {Quaternion} A reference to this quaternion.+ */+ setFromEuler(e, t = !0) {+ const n = e._x, s = e._y, r = e._z, a = e._order, o = Math.cos, c = Math.sin, l = o(n / 2), h = o(s / 2), u = o(r / 2), d = c(n / 2), f = c(s / 2), m = c(r / 2);+ switch (a) {+ case "XYZ":+ this._x = d * h * u + l * f * m, this._y = l * f * u - d * h * m, this._z = l * h * m + d * f * u, this._w = l * h * u - d * f * m;+ break;+ case "YXZ":+ this._x = d * h * u + l * f * m, this._y = l * f * u - d * h * m, this._z = l * h * m - d * f * u, this._w = l * h * u + d * f * m;+ break;+ case "ZXY":+ this._x = d * h * u - l * f * m, this._y = l * f * u + d * h * m, this._z = l * h * m + d * f * u, this._w = l * h * u - d * f * m;+ break;+ case "ZYX":+ this._x = d * h * u - l * f * m, this._y = l * f * u + d * h * m, this._z = l * h * m - d * f * u, this._w = l * h * u + d * f * m;+ break;+ case "YZX":+ this._x = d * h * u + l * f * m, this._y = l * f * u + d * h * m, this._z = l * h * m - d * f * u, this._w = l * h * u - d * f * m;+ break;+ case "XZY":+ this._x = d * h * u - l * f * m, this._y = l * f * u - d * h * m, this._z = l * h * m + d * f * u, this._w = l * h * u + d * f * m;+ break;+ default:+ console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: " + a);+ }+ return t === !0 && this._onChangeCallback(), this;+ }+ /**+ * Sets this quaternion from the given axis and angle.+ *+ * @param {Vector3} axis - The normalized axis.+ * @param {number} angle - The angle in radians.+ * @return {Quaternion} A reference to this quaternion.+ */+ setFromAxisAngle(e, t) {+ const n = t / 2, s = Math.sin(n);+ return this._x = e.x * s, this._y = e.y * s, this._z = e.z * s, this._w = Math.cos(n), this._onChangeCallback(), this;+ }+ /**+ * Sets this quaternion from the given rotation matrix.+ *+ * @param {Matrix4} m - A 4x4 matrix of which the upper 3x3 of matrix is a pure rotation matrix (i.e. unscaled).+ * @return {Quaternion} A reference to this quaternion.+ */+ setFromRotationMatrix(e) {+ const t = e.elements, n = t[0], s = t[4], r = t[8], a = t[1], o = t[5], c = t[9], l = t[2], h = t[6], u = t[10], d = n + o + u;+ if (d > 0) {+ const f = 0.5 / Math.sqrt(d + 1);+ this._w = 0.25 / f, this._x = (h - c) * f, this._y = (r - l) * f, this._z = (a - s) * f;+ } else if (n > o && n > u) {+ const f = 2 * Math.sqrt(1 + n - o - u);+ this._w = (h - c) / f, this._x = 0.25 * f, this._y = (s + a) / f, this._z = (r + l) / f;+ } else if (o > u) {+ const f = 2 * Math.sqrt(1 + o - n - u);+ this._w = (r - l) / f, this._x = (s + a) / f, this._y = 0.25 * f, this._z = (c + h) / f;+ } else {+ const f = 2 * Math.sqrt(1 + u - n - o);+ this._w = (a - s) / f, this._x = (r + l) / f, this._y = (c + h) / f, this._z = 0.25 * f;+ }+ return this._onChangeCallback(), this;+ }+ /**+ * Sets this quaternion to the rotation required to rotate the direction vector+ * `vFrom` to the direction vector `vTo`.+ *+ * @param {Vector3} vFrom - The first (normalized) direction vector.+ * @param {Vector3} vTo - The second (normalized) direction vector.+ * @return {Quaternion} A reference to this quaternion.+ */+ setFromUnitVectors(e, t) {+ let n = e.dot(t) + 1;+ return n < Number.EPSILON ? (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();+ }+ /**+ * Returns the angle between this quaternion and the given one in radians.+ *+ * @param {Quaternion} q - The quaternion to compute the angle with.+ * @return {number} The angle in radians.+ */+ angleTo(e) {+ return 2 * Math.acos(Math.abs(ct(this.dot(e), -1, 1)));+ }+ /**+ * Rotates this quaternion by a given angular step to the given quaternion.+ * The method ensures that the final quaternion will not overshoot `q`.+ *+ * @param {Quaternion} q - The target quaternion.+ * @param {number} step - The angular step in radians.+ * @return {Quaternion} A reference to this quaternion.+ */+ rotateTowards(e, t) {+ const n = this.angleTo(e);+ if (n === 0) return this;+ const s = Math.min(1, t / n);+ return this.slerp(e, s), this;+ }+ /**+ * Sets this quaternion to the identity quaternion; that is, to the+ * quaternion that represents "no rotation".+ *+ * @return {Quaternion} A reference to this quaternion.+ */+ identity() {+ return this.set(0, 0, 0, 1);+ }+ /**+ * Inverts this quaternion via {@link Quaternion#conjugate}. The+ * quaternion is assumed to have unit length.+ *+ * @return {Quaternion} A reference to this quaternion.+ */+ invert() {+ return this.conjugate();+ }+ /**+ * Returns the rotational conjugate of this quaternion. The conjugate of a+ * quaternion represents the same rotation in the opposite direction about+ * the rotational axis.+ *+ * @return {Quaternion} A reference to this quaternion.+ */+ conjugate() {+ return this._x *= -1, this._y *= -1, this._z *= -1, this._onChangeCallback(), this;+ }+ /**+ * Calculates the dot product of this quaternion and the given one.+ *+ * @param {Quaternion} v - The quaternion to compute the dot product with.+ * @return {number} The result of the dot product.+ */+ dot(e) {+ return this._x * e._x + this._y * e._y + this._z * e._z + this._w * e._w;+ }+ /**+ * Computes the squared Euclidean length (straight-line length) of this quaternion,+ * considered as a 4 dimensional vector. This can be useful if you are comparing the+ * lengths of two quaternions, as this is a slightly more efficient calculation than+ * {@link Quaternion#length}.+ *+ * @return {number} The squared Euclidean length.+ */+ lengthSq() {+ return this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w;+ }+ /**+ * Computes the Euclidean length (straight-line length) of this quaternion,+ * considered as a 4 dimensional vector.+ *+ * @return {number} The Euclidean length.+ */+ length() {+ return Math.sqrt(this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w);+ }+ /**+ * Normalizes this quaternion - that is, calculated the quaternion that performs+ * the same rotation as this one, but has a length equal to `1`.+ *+ * @return {Quaternion} A reference to this quaternion.+ */+ normalize() {+ let e = this.length();+ return e === 0 ? (this._x = 0, this._y = 0, this._z = 0, this._w = 1) : (e = 1 / e, this._x = this._x * e, this._y = this._y * e, this._z = this._z * e, this._w = this._w * e), this._onChangeCallback(), this;+ }+ /**+ * Multiplies this quaternion by the given one.+ *+ * @param {Quaternion} q - The quaternion.+ * @return {Quaternion} A reference to this quaternion.+ */+ multiply(e) {+ return this.multiplyQuaternions(this, e);+ }+ /**+ * Pre-multiplies this quaternion by the given one.+ *+ * @param {Quaternion} q - The quaternion.+ * @return {Quaternion} A reference to this quaternion.+ */+ premultiply(e) {+ return this.multiplyQuaternions(e, this);+ }+ /**+ * Multiplies the given quaternions and stores the result in this instance.+ *+ * @param {Quaternion} a - The first quaternion.+ * @param {Quaternion} b - The second quaternion.+ * @return {Quaternion} A reference to this quaternion.+ */+ multiplyQuaternions(e, t) {+ const n = e._x, s = e._y, r = e._z, a = e._w, o = t._x, c = t._y, l = t._z, h = t._w;+ return this._x = n * h + a * o + s * l - r * c, this._y = s * h + a * c + r * o - n * l, this._z = r * h + a * l + n * c - s * o, this._w = a * h - n * o - s * c - r * l, this._onChangeCallback(), this;+ }+ /**+ * Performs a spherical linear interpolation between quaternions.+ *+ * @param {Quaternion} qb - The target quaternion.+ * @param {number} t - The interpolation factor in the closed interval `[0, 1]`.+ * @return {Quaternion} A reference to this quaternion.+ */+ slerp(e, t) {+ if (t === 0) return this;+ if (t === 1) return this.copy(e);+ const n = this._x, s = this._y, r = this._z, a = this._w;+ let o = a * e._w + n * e._x + s * e._y + r * e._z;+ if (o < 0 ? (this._w = -e._w, this._x = -e._x, this._y = -e._y, this._z = -e._z, o = -o) : this.copy(e), o >= 1)+ return this._w = a, this._x = n, this._y = s, this._z = r, this;+ const c = 1 - o * o;+ if (c <= Number.EPSILON) {+ const f = 1 - t;+ return this._w = f * a + t * this._w, this._x = f * n + t * this._x, this._y = f * s + t * this._y, this._z = f * r + t * this._z, this.normalize(), this;+ }+ const l = Math.sqrt(c), h = Math.atan2(l, o), u = Math.sin((1 - t) * h) / l, d = Math.sin(t * h) / l;+ return this._w = a * u + this._w * d, this._x = n * u + this._x * d, this._y = s * u + this._y * d, this._z = r * u + this._z * d, this._onChangeCallback(), this;+ }+ /**+ * Performs a spherical linear interpolation between the given quaternions+ * and stores the result in this quaternion.+ *+ * @param {Quaternion} qa - The source quaternion.+ * @param {Quaternion} qb - The target quaternion.+ * @param {number} t - The interpolation factor in the closed interval `[0, 1]`.+ * @return {Quaternion} A reference to this quaternion.+ */+ slerpQuaternions(e, t, n) {+ return this.copy(e).slerp(t, n);+ }+ /**+ * Sets this quaternion to a uniformly random, normalized quaternion.+ *+ * @return {Quaternion} A reference to this quaternion.+ */+ random() {+ const e = 2 * Math.PI * Math.random(), t = 2 * Math.PI * Math.random(), n = Math.random(), s = Math.sqrt(1 - n), r = Math.sqrt(n);+ return this.set(+ s * Math.sin(e),+ s * Math.cos(e),+ r * Math.sin(t),+ r * Math.cos(t)+ );+ }+ /**+ * Returns `true` if this quaternion is equal with the given one.+ *+ * @param {Quaternion} quaternion - The quaternion to test for equality.+ * @return {boolean} Whether this quaternion is equal with the given one.+ */+ equals(e) {+ return e._x === this._x && e._y === this._y && e._z === this._z && e._w === this._w;+ }+ /**+ * Sets this quaternion's components from the given array.+ *+ * @param {Array<number>} array - An array holding the quaternion component values.+ * @param {number} [offset=0] - The offset into the array.+ * @return {Quaternion} A reference to this quaternion.+ */+ 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;+ }+ /**+ * Writes the components of this quaternion to the given array. If no array is provided,+ * the method returns a new instance.+ *+ * @param {Array<number>} [array=[]] - The target array holding the quaternion components.+ * @param {number} [offset=0] - Index of the first element in the array.+ * @return {Array<number>} The quaternion components.+ */+ 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;+ }+ /**+ * Sets the components of this quaternion from the given buffer attribute.+ *+ * @param {BufferAttribute} attribute - The buffer attribute holding quaternion data.+ * @param {number} index - The index into the attribute.+ * @return {Quaternion} A reference to this quaternion.+ */+ 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;+ }+ /**+ * This methods defines the serialization result of this class. Returns the+ * numerical elements of this quaternion in an array of format `[x, y, z, w]`.+ *+ * @return {Array<number>} The serialized quaternion.+ */+ toJSON() {+ return this.toArray();+ }+ _onChange(e) {+ return this._onChangeCallback = e, this;+ }+ _onChangeCallback() {+ }+ *[Symbol.iterator]() {+ yield this._x, yield this._y, yield this._z, yield this._w;+ }+}+class H {+ /**+ * Constructs a new 3D vector.+ *+ * @param {number} [x=0] - The x value of this vector.+ * @param {number} [y=0] - The y value of this vector.+ * @param {number} [z=0] - The z value of this vector.+ */+ constructor(e = 0, t = 0, n = 0) {+ H.prototype.isVector3 = !0, this.x = e, this.y = t, this.z = n;+ }+ /**+ * Sets the vector components.+ *+ * @param {number} x - The value of the x component.+ * @param {number} y - The value of the y component.+ * @param {number} z - The value of the z component.+ * @return {Vector3} A reference to this vector.+ */+ set(e, t, n) {+ return n === void 0 && (n = this.z), this.x = e, this.y = t, this.z = n, this;+ }+ /**+ * Sets the vector components to the same value.+ *+ * @param {number} scalar - The value to set for all vector components.+ * @return {Vector3} A reference to this vector.+ */+ setScalar(e) {+ return this.x = e, this.y = e, this.z = e, this;+ }+ /**+ * Sets the vector's x component to the given value+ *+ * @param {number} x - The value to set.+ * @return {Vector3} A reference to this vector.+ */+ setX(e) {+ return this.x = e, this;+ }+ /**+ * Sets the vector's y component to the given value+ *+ * @param {number} y - The value to set.+ * @return {Vector3} A reference to this vector.+ */+ setY(e) {+ return this.y = e, this;+ }+ /**+ * Sets the vector's z component to the given value+ *+ * @param {number} z - The value to set.+ * @return {Vector3} A reference to this vector.+ */+ setZ(e) {+ return this.z = e, this;+ }+ /**+ * Allows to set a vector component with an index.+ *+ * @param {number} index - The component index. `0` equals to x, `1` equals to y, `2` equals to z.+ * @param {number} value - The value to set.+ * @return {Vector3} A reference to this vector.+ */+ 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 new Error("index is out of range: " + e);+ }+ return this;+ }+ /**+ * Returns the value of the vector component which matches the given index.+ *+ * @param {number} index - The component index. `0` equals to x, `1` equals to y, `2` equals to z.+ * @return {number} A vector component value.+ */+ getComponent(e) {+ switch (e) {+ case 0:+ return this.x;+ case 1:+ return this.y;+ case 2:+ return this.z;+ default:+ throw new Error("index is out of range: " + e);+ }+ }+ /**+ * Returns a new vector with copied values from this instance.+ *+ * @return {Vector3} A clone of this instance.+ */+ clone() {+ return new this.constructor(this.x, this.y, this.z);+ }+ /**+ * Copies the values of the given vector to this instance.+ *+ * @param {Vector3} v - The vector to copy.+ * @return {Vector3} A reference to this vector.+ */+ copy(e) {+ return this.x = e.x, this.y = e.y, this.z = e.z, this;+ }+ /**+ * Adds the given vector to this instance.+ *+ * @param {Vector3} v - The vector to add.+ * @return {Vector3} A reference to this vector.+ */+ add(e) {+ return this.x += e.x, this.y += e.y, this.z += e.z, this;+ }+ /**+ * Adds the given scalar value to all components of this instance.+ *+ * @param {number} s - The scalar to add.+ * @return {Vector3} A reference to this vector.+ */+ addScalar(e) {+ return this.x += e, this.y += e, this.z += e, this;+ }+ /**+ * Adds the given vectors and stores the result in this instance.+ *+ * @param {Vector3} a - The first vector.+ * @param {Vector3} b - The second vector.+ * @return {Vector3} A reference to this vector.+ */+ addVectors(e, t) {+ return this.x = e.x + t.x, this.y = e.y + t.y, this.z = e.z + t.z, this;+ }+ /**+ * Adds the given vector scaled by the given factor to this instance.+ *+ * @param {Vector3|Vector4} v - The vector.+ * @param {number} s - The factor that scales `v`.+ * @return {Vector3} A reference to this vector.+ */+ addScaledVector(e, t) {+ return this.x += e.x * t, this.y += e.y * t, this.z += e.z * t, this;+ }+ /**+ * Subtracts the given vector from this instance.+ *+ * @param {Vector3} v - The vector to subtract.+ * @return {Vector3} A reference to this vector.+ */+ sub(e) {+ return this.x -= e.x, this.y -= e.y, this.z -= e.z, this;+ }+ /**+ * Subtracts the given scalar value from all components of this instance.+ *+ * @param {number} s - The scalar to subtract.+ * @return {Vector3} A reference to this vector.+ */+ subScalar(e) {+ return this.x -= e, this.y -= e, this.z -= e, this;+ }+ /**+ * Subtracts the given vectors and stores the result in this instance.+ *+ * @param {Vector3} a - The first vector.+ * @param {Vector3} b - The second vector.+ * @return {Vector3} A reference to this vector.+ */+ subVectors(e, t) {+ return this.x = e.x - t.x, this.y = e.y - t.y, this.z = e.z - t.z, this;+ }+ /**+ * Multiplies the given vector with this instance.+ *+ * @param {Vector3} v - The vector to multiply.+ * @return {Vector3} A reference to this vector.+ */+ multiply(e) {+ return this.x *= e.x, this.y *= e.y, this.z *= e.z, this;+ }+ /**+ * Multiplies the given scalar value with all components of this instance.+ *+ * @param {number} scalar - The scalar to multiply.+ * @return {Vector3} A reference to this vector.+ */+ multiplyScalar(e) {+ return this.x *= e, this.y *= e, this.z *= e, this;+ }+ /**+ * Multiplies the given vectors and stores the result in this instance.+ *+ * @param {Vector3} a - The first vector.+ * @param {Vector3} b - The second vector.+ * @return {Vector3} A reference to this vector.+ */+ multiplyVectors(e, t) {+ return this.x = e.x * t.x, this.y = e.y * t.y, this.z = e.z * t.z, this;+ }+ /**+ * Applies the given Euler rotation to this vector.+ *+ * @param {Euler} euler - The Euler angles.+ * @return {Vector3} A reference to this vector.+ */+ applyEuler(e) {+ return this.applyQuaternion(yp.setFromEuler(e));+ }+ /**+ * Applies a rotation specified by an axis and an angle to this vector.+ *+ * @param {Vector3} axis - A normalized vector representing the rotation axis.+ * @param {number} angle - The angle in radians.+ * @return {Vector3} A reference to this vector.+ */+ applyAxisAngle(e, t) {+ return this.applyQuaternion(yp.setFromAxisAngle(e, t));+ }+ /**+ * Multiplies this vector with the given 3x3 matrix.+ *+ * @param {Matrix3} m - The 3x3 matrix.+ * @return {Vector3} A reference to this vector.+ */+ applyMatrix3(e) {+ const t = this.x, n = this.y, s = this.z, r = e.elements;+ return this.x = r[0] * t + r[3] * n + r[6] * s, this.y = r[1] * t + r[4] * n + r[7] * s, this.z = r[2] * t + r[5] * n + r[8] * s, this;+ }+ /**+ * Multiplies this vector by the given normal matrix and normalizes+ * the result.+ *+ * @param {Matrix3} m - The normal matrix.+ * @return {Vector3} A reference to this vector.+ */+ applyNormalMatrix(e) {+ return this.applyMatrix3(e).normalize();+ }+ /**+ * Multiplies this vector (with an implicit 1 in the 4th dimension) by m, and+ * divides by perspective.+ *+ * @param {Matrix4} m - The matrix to apply.+ * @return {Vector3} A reference to this vector.+ */+ applyMatrix4(e) {+ const t = this.x, n = this.y, s = this.z, r = e.elements, a = 1 / (r[3] * t + r[7] * n + r[11] * s + r[15]);+ return this.x = (r[0] * t + r[4] * n + r[8] * s + r[12]) * a, this.y = (r[1] * t + r[5] * n + r[9] * s + r[13]) * a, this.z = (r[2] * t + r[6] * n + r[10] * s + r[14]) * a, this;+ }+ /**+ * Applies the given Quaternion to this vector.+ *+ * @param {Quaternion} q - The Quaternion.+ * @return {Vector3} A reference to this vector.+ */+ applyQuaternion(e) {+ const t = this.x, n = this.y, s = this.z, r = e.x, a = e.y, o = e.z, c = e.w, l = 2 * (a * s - o * n), h = 2 * (o * t - r * s), u = 2 * (r * n - a * t);+ return this.x = t + c * l + a * u - o * h, this.y = n + c * h + o * l - r * u, this.z = s + c * u + r * h - a * l, this;+ }+ /**+ * Projects this vector from world space into the camera's normalized+ * device coordinate (NDC) space.+ *+ * @param {Camera} camera - The camera.+ * @return {Vector3} A reference to this vector.+ */+ project(e) {+ return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix);+ }+ /**+ * Unprojects this vector from the camera's normalized device coordinate (NDC)+ * space into world space.+ *+ * @param {Camera} camera - The camera.+ * @return {Vector3} A reference to this vector.+ */+ unproject(e) {+ return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld);+ }+ /**+ * Transforms the direction of this vector by a matrix (the upper left 3 x 3+ * subset of the given 4x4 matrix and then normalizes the result.+ *+ * @param {Matrix4} m - The matrix.+ * @return {Vector3} A reference to this vector.+ */+ transformDirection(e) {+ const t = this.x, n = this.y, s = this.z, r = e.elements;+ return this.x = r[0] * t + r[4] * n + r[8] * s, this.y = r[1] * t + r[5] * n + r[9] * s, this.z = r[2] * t + r[6] * n + r[10] * s, this.normalize();+ }+ /**+ * Divides this instance by the given vector.+ *+ * @param {Vector3} v - The vector to divide.+ * @return {Vector3} A reference to this vector.+ */+ divide(e) {+ return this.x /= e.x, this.y /= e.y, this.z /= e.z, this;+ }+ /**+ * Divides this vector by the given scalar.+ *+ * @param {number} scalar - The scalar to divide.+ * @return {Vector3} A reference to this vector.+ */+ divideScalar(e) {+ return this.multiplyScalar(1 / e);+ }+ /**+ * If this vector's x, y or z value is greater than the given vector's x, y or z+ * value, replace that value with the corresponding min value.+ *+ * @param {Vector3} v - The vector.+ * @return {Vector3} A reference to this vector.+ */+ 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;+ }+ /**+ * If this vector's x, y or z value is less than the given vector's x, y or z+ * value, replace that value with the corresponding max value.+ *+ * @param {Vector3} v - The vector.+ * @return {Vector3} A reference to this vector.+ */+ 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;+ }+ /**+ * If this vector's x, y or z value is greater than the max vector's x, y or z+ * value, it is replaced by the corresponding value.+ * If this vector's x, y or z value is less than the min vector's x, y or z value,+ * it is replaced by the corresponding value.+ *+ * @param {Vector3} min - The minimum x, y and z values.+ * @param {Vector3} max - The maximum x, y and z values in the desired range.+ * @return {Vector3} A reference to this vector.+ */+ clamp(e, t) {+ return this.x = ct(this.x, e.x, t.x), this.y = ct(this.y, e.y, t.y), this.z = ct(this.z, e.z, t.z), this;+ }+ /**+ * If this vector's x, y or z values are greater than the max value, they are+ * replaced by the max value.+ * If this vector's x, y or z values are less than the min value, they are+ * replaced by the min value.+ *+ * @param {number} minVal - The minimum value the components will be clamped to.+ * @param {number} maxVal - The maximum value the components will be clamped to.+ * @return {Vector3} A reference to this vector.+ */+ clampScalar(e, t) {+ return this.x = ct(this.x, e, t), this.y = ct(this.y, e, t), this.z = ct(this.z, e, t), this;+ }+ /**+ * If this vector's length is greater than the max value, it is replaced by+ * the max value.+ * If this vector's length is less than the min value, it is replaced by the+ * min value.+ *+ * @param {number} min - The minimum value the vector length will be clamped to.+ * @param {number} max - The maximum value the vector length will be clamped to.+ * @return {Vector3} A reference to this vector.+ */+ clampLength(e, t) {+ const n = this.length();+ return this.divideScalar(n || 1).multiplyScalar(ct(n, e, t));+ }+ /**+ * The components of this vector are rounded down to the nearest integer value.+ *+ * @return {Vector3} A reference to this vector.+ */+ floor() {+ return this.x = Math.floor(this.x), this.y = Math.floor(this.y), this.z = Math.floor(this.z), this;+ }+ /**+ * The components of this vector are rounded up to the nearest integer value.+ *+ * @return {Vector3} A reference to this vector.+ */+ ceil() {+ return this.x = Math.ceil(this.x), this.y = Math.ceil(this.y), this.z = Math.ceil(this.z), this;+ }+ /**+ * The components of this vector are rounded to the nearest integer value+ *+ * @return {Vector3} A reference to this vector.+ */+ round() {+ return this.x = Math.round(this.x), this.y = Math.round(this.y), this.z = Math.round(this.z), this;+ }+ /**+ * The components of this vector are rounded towards zero (up if negative,+ * down if positive) to an integer value.+ *+ * @return {Vector3} A reference to this vector.+ */+ roundToZero() {+ return this.x = Math.trunc(this.x), this.y = Math.trunc(this.y), this.z = Math.trunc(this.z), this;+ }+ /**+ * Inverts this vector - i.e. sets x = -x, y = -y and z = -z.+ *+ * @return {Vector3} A reference to this vector.+ */+ negate() {+ return this.x = -this.x, this.y = -this.y, this.z = -this.z, this;+ }+ /**+ * Calculates the dot product of the given vector with this instance.+ *+ * @param {Vector3} v - The vector to compute the dot product with.+ * @return {number} The result of the dot product.+ */+ dot(e) {+ return this.x * e.x + this.y * e.y + this.z * e.z;+ }+ // TODO lengthSquared?+ /**+ * Computes the square of the Euclidean length (straight-line length) from+ * (0, 0, 0) to (x, y, z). If you are comparing the lengths of vectors, you should+ * compare the length squared instead as it is slightly more efficient to calculate.+ *+ * @return {number} The square length of this vector.+ */+ lengthSq() {+ return this.x * this.x + this.y * this.y + this.z * this.z;+ }+ /**+ * Computes the Euclidean length (straight-line length) from (0, 0, 0) to (x, y, z).+ *+ * @return {number} The length of this vector.+ */+ length() {+ return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);+ }+ /**+ * Computes the Manhattan length of this vector.+ *+ * @return {number} The length of this vector.+ */+ manhattanLength() {+ return Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z);+ }+ /**+ * Converts this vector to a unit vector - that is, sets it equal to a vector+ * with the same direction as this one, but with a vector length of `1`.+ *+ * @return {Vector3} A reference to this vector.+ */+ normalize() {+ return this.divideScalar(this.length() || 1);+ }+ /**+ * Sets this vector to a vector with the same direction as this one, but+ * with the specified length.+ *+ * @param {number} length - The new length of this vector.+ * @return {Vector3} A reference to this vector.+ */+ setLength(e) {+ return this.normalize().multiplyScalar(e);+ }+ /**+ * Linearly interpolates between the given vector and this instance, where+ * alpha is the percent distance along the line - alpha = 0 will be this+ * vector, and alpha = 1 will be the given one.+ *+ * @param {Vector3} v - The vector to interpolate towards.+ * @param {number} alpha - The interpolation factor, typically in the closed interval `[0, 1]`.+ * @return {Vector3} A reference to this vector.+ */+ 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;+ }+ /**+ * Linearly interpolates between the given vectors, where alpha is the percent+ * distance along the line - alpha = 0 will be first vector, and alpha = 1 will+ * be the second one. The result is stored in this instance.+ *+ * @param {Vector3} v1 - The first vector.+ * @param {Vector3} v2 - The second vector.+ * @param {number} alpha - The interpolation factor, typically in the closed interval `[0, 1]`.+ * @return {Vector3} A reference to this vector.+ */+ 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;+ }+ /**+ * Calculates the cross product of the given vector with this instance.+ *+ * @param {Vector3} v - The vector to compute the cross product with.+ * @return {Vector3} The result of the cross product.+ */+ cross(e) {+ return this.crossVectors(this, e);+ }+ /**+ * Calculates the cross product of the given vectors and stores the result+ * in this instance.+ *+ * @param {Vector3} a - The first vector.+ * @param {Vector3} b - The second vector.+ * @return {Vector3} A reference to this vector.+ */+ crossVectors(e, t) {+ const n = e.x, s = e.y, r = e.z, a = t.x, o = t.y, c = t.z;+ return this.x = s * c - r * o, this.y = r * a - n * c, this.z = n * o - s * a, this;+ }+ /**+ * Projects this vector onto the given one.+ *+ * @param {Vector3} v - The vector to project to.+ * @return {Vector3} A reference to this vector.+ */+ projectOnVector(e) {+ const t = e.lengthSq();+ if (t === 0) return this.set(0, 0, 0);+ const n = e.dot(this) / t;+ return this.copy(e).multiplyScalar(n);+ }+ /**+ * Projects this vector onto a plane by subtracting this+ * vector projected onto the plane's normal from this vector.+ *+ * @param {Vector3} planeNormal - The plane normal.+ * @return {Vector3} A reference to this vector.+ */+ projectOnPlane(e) {+ return wh.copy(this).projectOnVector(e), this.sub(wh);+ }+ /**+ * Reflects this vector off a plane orthogonal to the given normal vector.+ *+ * @param {Vector3} normal - The (normalized) normal vector.+ * @return {Vector3} A reference to this vector.+ */+ reflect(e) {+ return this.sub(wh.copy(e).multiplyScalar(2 * this.dot(e)));+ }+ /**+ * Returns the angle between the given vector and this instance in radians.+ *+ * @param {Vector3} v - The vector to compute the angle with.+ * @return {number} The angle in radians.+ */+ angleTo(e) {+ const t = Math.sqrt(this.lengthSq() * e.lengthSq());+ if (t === 0) return Math.PI / 2;+ const n = this.dot(e) / t;+ return Math.acos(ct(n, -1, 1));+ }+ /**+ * Computes the distance from the given vector to this instance.+ *+ * @param {Vector3} v - The vector to compute the distance to.+ * @return {number} The distance.+ */+ distanceTo(e) {+ return Math.sqrt(this.distanceToSquared(e));+ }+ /**+ * Computes the squared distance from the given vector to this instance.+ * If you are just comparing the distance with another distance, you should compare+ * the distance squared instead as it is slightly more efficient to calculate.+ *+ * @param {Vector3} v - The vector to compute the squared distance to.+ * @return {number} The squared distance.+ */+ distanceToSquared(e) {+ const t = this.x - e.x, n = this.y - e.y, s = this.z - e.z;+ return t * t + n * n + s * s;+ }+ /**+ * Computes the Manhattan distance from the given vector to this instance.+ *+ * @param {Vector3} v - The vector to compute the Manhattan distance to.+ * @return {number} The Manhattan distance.+ */+ manhattanDistanceTo(e) {+ return Math.abs(this.x - e.x) + Math.abs(this.y - e.y) + Math.abs(this.z - e.z);+ }+ /**+ * Sets the vector components from the given spherical coordinates.+ *+ * @param {Spherical} s - The spherical coordinates.+ * @return {Vector3} A reference to this vector.+ */+ setFromSpherical(e) {+ return this.setFromSphericalCoords(e.radius, e.phi, e.theta);+ }+ /**+ * Sets the vector components from the given spherical coordinates.+ *+ * @param {number} radius - The radius.+ * @param {number} phi - The phi angle in radians.+ * @param {number} theta - The theta angle in radians.+ * @return {Vector3} A reference to this vector.+ */+ setFromSphericalCoords(e, t, n) {+ const s = Math.sin(t) * e;+ return this.x = s * Math.sin(n), this.y = Math.cos(t) * e, this.z = s * Math.cos(n), this;+ }+ /**+ * Sets the vector components from the given cylindrical coordinates.+ *+ * @param {Cylindrical} c - The cylindrical coordinates.+ * @return {Vector3} A reference to this vector.+ */+ setFromCylindrical(e) {+ return this.setFromCylindricalCoords(e.radius, e.theta, e.y);+ }+ /**+ * Sets the vector components from the given cylindrical coordinates.+ *+ * @param {number} radius - The radius.+ * @param {number} theta - The theta angle in radians.+ * @param {number} y - The y value.+ * @return {Vector3} A reference to this vector.+ */+ setFromCylindricalCoords(e, t, n) {+ return this.x = e * Math.sin(t), this.y = n, this.z = e * Math.cos(t), this;+ }+ /**+ * Sets the vector components to the position elements of the+ * given transformation matrix.+ *+ * @param {Matrix4} m - The 4x4 matrix.+ * @return {Vector3} A reference to this vector.+ */+ setFromMatrixPosition(e) {+ const t = e.elements;+ return this.x = t[12], this.y = t[13], this.z = t[14], this;+ }+ /**+ * Sets the vector components to the scale elements of the+ * given transformation matrix.+ *+ * @param {Matrix4} m - The 4x4 matrix.+ * @return {Vector3} A reference to this vector.+ */+ setFromMatrixScale(e) {+ const t = this.setFromMatrixColumn(e, 0).length(), n = this.setFromMatrixColumn(e, 1).length(), s = this.setFromMatrixColumn(e, 2).length();+ return this.x = t, this.y = n, this.z = s, this;+ }+ /**+ * Sets the vector components from the specified matrix column.+ *+ * @param {Matrix4} m - The 4x4 matrix.+ * @param {number} index - The column index.+ * @return {Vector3} A reference to this vector.+ */+ setFromMatrixColumn(e, t) {+ return this.fromArray(e.elements, t * 4);+ }+ /**+ * Sets the vector components from the specified matrix column.+ *+ * @param {Matrix3} m - The 3x3 matrix.+ * @param {number} index - The column index.+ * @return {Vector3} A reference to this vector.+ */+ setFromMatrix3Column(e, t) {+ return this.fromArray(e.elements, t * 3);+ }+ /**+ * Sets the vector components from the given Euler angles.+ *+ * @param {Euler} e - The Euler angles to set.+ * @return {Vector3} A reference to this vector.+ */+ setFromEuler(e) {+ return this.x = e._x, this.y = e._y, this.z = e._z, this;+ }+ /**+ * Sets the vector components from the RGB components of the+ * given color.+ *+ * @param {Color} c - The color to set.+ * @return {Vector3} A reference to this vector.+ */+ setFromColor(e) {+ return this.x = e.r, this.y = e.g, this.z = e.b, this;+ }+ /**+ * Returns `true` if this vector is equal with the given one.+ *+ * @param {Vector3} v - The vector to test for equality.+ * @return {boolean} Whether this vector is equal with the given one.+ */+ equals(e) {+ return e.x === this.x && e.y === this.y && e.z === this.z;+ }+ /**+ * Sets this vector's x value to be `array[ offset ]`, y value to be `array[ offset + 1 ]`+ * and z value to be `array[ offset + 2 ]`.+ *+ * @param {Array<number>} array - An array holding the vector component values.+ * @param {number} [offset=0] - The offset into the array.+ * @return {Vector3} A reference to this vector.+ */+ fromArray(e, t = 0) {+ return this.x = e[t], this.y = e[t + 1], this.z = e[t + 2], this;+ }+ /**+ * Writes the components of this vector to the given array. If no array is provided,+ * the method returns a new instance.+ *+ * @param {Array<number>} [array=[]] - The target array holding the vector components.+ * @param {number} [offset=0] - Index of the first element in the array.+ * @return {Array<number>} The vector components.+ */+ toArray(e = [], t = 0) {+ return e[t] = this.x, e[t + 1] = this.y, e[t + 2] = this.z, e;+ }+ /**+ * Sets the components of this vector from the given buffer attribute.+ *+ * @param {BufferAttribute} attribute - The buffer attribute holding vector data.+ * @param {number} index - The index into the attribute.+ * @return {Vector3} A reference to this vector.+ */+ fromBufferAttribute(e, t) {+ return this.x = e.getX(t), this.y = e.getY(t), this.z = e.getZ(t), this;+ }+ /**+ * Sets each component of this vector to a pseudo-random value between `0` and+ * `1`, excluding `1`.+ *+ * @return {Vector3} A reference to this vector.+ */+ random() {+ return this.x = Math.random(), this.y = Math.random(), this.z = Math.random(), this;+ }+ /**+ * Sets this vector to a uniformly random point on a unit sphere.+ *+ * @return {Vector3} A reference to this vector.+ */+ randomDirection() {+ const 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;+ }+}+const wh = /* @__PURE__ */ new H(), yp = /* @__PURE__ */ new Yn();+class yi {+ /**+ * Constructs a new bounding box.+ *+ * @param {Vector3} [min=(Infinity,Infinity,Infinity)] - A vector representing the lower boundary of the box.+ * @param {Vector3} [max=(-Infinity,-Infinity,-Infinity)] - A vector representing the upper boundary of the box.+ */+ constructor(e = new H(1 / 0, 1 / 0, 1 / 0), t = new H(-1 / 0, -1 / 0, -1 / 0)) {+ this.isBox3 = !0, this.min = e, this.max = t;+ }+ /**+ * Sets the lower and upper boundaries of this box.+ * Please note that this method only copies the values from the given objects.+ *+ * @param {Vector3} min - The lower boundary of the box.+ * @param {Vector3} max - The upper boundary of the box.+ * @return {Box3} A reference to this bounding box.+ */+ set(e, t) {+ return this.min.copy(e), this.max.copy(t), this;+ }+ /**+ * Sets the upper and lower bounds of this box so it encloses the position data+ * in the given array.+ *+ * @param {Array<number>} array - An array holding 3D position data.+ * @return {Box3} A reference to this bounding box.+ */+ setFromArray(e) {+ this.makeEmpty();+ for (let t = 0, n = e.length; t < n; t += 3)+ this.expandByPoint(ci.fromArray(e, t));+ return this;+ }+ /**+ * Sets the upper and lower bounds of this box so it encloses the position data+ * in the given buffer attribute.+ *+ * @param {BufferAttribute} attribute - A buffer attribute holding 3D position data.+ * @return {Box3} A reference to this bounding box.+ */+ setFromBufferAttribute(e) {+ this.makeEmpty();+ for (let t = 0, n = e.count; t < n; t++)+ this.expandByPoint(ci.fromBufferAttribute(e, t));+ return this;+ }+ /**+ * Sets the upper and lower bounds of this box so it encloses the position data+ * in the given array.+ *+ * @param {Array<Vector3>} points - An array holding 3D position data as instances of {@link Vector3}.+ * @return {Box3} A reference to this bounding box.+ */+ setFromPoints(e) {+ this.makeEmpty();+ for (let t = 0, n = e.length; t < n; t++)+ this.expandByPoint(e[t]);+ return this;+ }+ /**+ * Centers this box on the given center vector and sets this box's width, height and+ * depth to the given size values.+ *+ * @param {Vector3} center - The center of the box.+ * @param {Vector3} size - The x, y and z dimensions of the box.+ * @return {Box3} A reference to this bounding box.+ */+ setFromCenterAndSize(e, t) {+ const n = ci.copy(t).multiplyScalar(0.5);+ return this.min.copy(e).sub(n), this.max.copy(e).add(n), this;+ }+ /**+ * Computes the world-axis-aligned bounding box for the given 3D object+ * (including its children), accounting for the object's, and children's,+ * world transforms. The function may result in a larger box than strictly necessary.+ *+ * @param {Object3D} object - The 3D object to compute the bounding box for.+ * @param {boolean} [precise=false] - If set to `true`, the method computes the smallest+ * world-axis-aligned bounding box at the expense of more computation.+ * @return {Box3} A reference to this bounding box.+ */+ setFromObject(e, t = !1) {+ return this.makeEmpty(), this.expandByObject(e, t);+ }+ /**+ * Returns a new box with copied values from this instance.+ *+ * @return {Box3} A clone of this instance.+ */+ clone() {+ return new this.constructor().copy(this);+ }+ /**+ * Copies the values of the given box to this instance.+ *+ * @param {Box3} box - The box to copy.+ * @return {Box3} A reference to this bounding box.+ */+ copy(e) {+ return this.min.copy(e.min), this.max.copy(e.max), this;+ }+ /**+ * Makes this box empty which means in encloses a zero space in 3D.+ *+ * @return {Box3} A reference to this bounding box.+ */+ 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;+ }+ /**+ * Returns true if this box includes zero points within its bounds.+ * Note that a box with equal lower and upper bounds still includes one+ * point, the one both bounds share.+ *+ * @return {boolean} Whether this box is empty or not.+ */+ isEmpty() {+ return this.max.x < this.min.x || this.max.y < this.min.y || this.max.z < this.min.z;+ }+ /**+ * Returns the center point of this box.+ *+ * @param {Vector3} target - The target vector that is used to store the method's result.+ * @return {Vector3} The center point.+ */+ getCenter(e) {+ return this.isEmpty() ? e.set(0, 0, 0) : e.addVectors(this.min, this.max).multiplyScalar(0.5);+ }+ /**+ * Returns the dimensions of this box.+ *+ * @param {Vector3} target - The target vector that is used to store the method's result.+ * @return {Vector3} The size.+ */+ getSize(e) {+ return this.isEmpty() ? e.set(0, 0, 0) : e.subVectors(this.max, this.min);+ }+ /**+ * Expands the boundaries of this box to include the given point.+ *+ * @param {Vector3} point - The point that should be included by the bounding box.+ * @return {Box3} A reference to this bounding box.+ */+ expandByPoint(e) {+ return this.min.min(e), this.max.max(e), this;+ }+ /**+ * Expands this box equilaterally by the given vector. The width of this+ * box will be expanded by the x component of the vector in both+ * directions. The height of this box will be expanded by the y component of+ * the vector in both directions. The depth of this box will be+ * expanded by the z component of the vector in both directions.+ *+ * @param {Vector3} vector - The vector that should expand the bounding box.+ * @return {Box3} A reference to this bounding box.+ */+ expandByVector(e) {+ return this.min.sub(e), this.max.add(e), this;+ }+ /**+ * Expands each dimension of the box by the given scalar. If negative, the+ * dimensions of the box will be contracted.+ *+ * @param {number} scalar - The scalar value that should expand the bounding box.+ * @return {Box3} A reference to this bounding box.+ */+ expandByScalar(e) {+ return this.min.addScalar(-e), this.max.addScalar(e), this;+ }+ /**+ * Expands the boundaries of this box to include the given 3D object and+ * its children, accounting for the object's, and children's, world+ * transforms. The function may result in a larger box than strictly+ * necessary (unless the precise parameter is set to true).+ *+ * @param {Object3D} object - The 3D object that should expand the bounding box.+ * @param {boolean} precise - If set to `true`, the method expands the bounding box+ * as little as necessary at the expense of more computation.+ * @return {Box3} A reference to this bounding box.+ */+ expandByObject(e, t = !1) {+ e.updateWorldMatrix(!1, !1);+ const n = e.geometry;+ if (n !== void 0) {+ const r = n.getAttribute("position");+ if (t === !0 && r !== void 0 && e.isInstancedMesh !== !0)+ for (let a = 0, o = r.count; a < o; a++)+ e.isMesh === !0 ? e.getVertexPosition(a, ci) : ci.fromBufferAttribute(r, a), ci.applyMatrix4(e.matrixWorld), this.expandByPoint(ci);+ else+ e.boundingBox !== void 0 ? (e.boundingBox === null && e.computeBoundingBox(), fc.copy(e.boundingBox)) : (n.boundingBox === null && n.computeBoundingBox(), fc.copy(n.boundingBox)), fc.applyMatrix4(e.matrixWorld), this.union(fc);+ }+ const s = e.children;+ for (let r = 0, a = s.length; r < a; r++)+ this.expandByObject(s[r], t);+ return this;+ }+ /**+ * Returns `true` if the given point lies within or on the boundaries of this box.+ *+ * @param {Vector3} point - The point to test.+ * @return {boolean} Whether the bounding box contains the given point or not.+ */+ 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;+ }+ /**+ * Returns `true` if this bounding box includes the entirety of the given bounding box.+ * If this box and the given one are identical, this function also returns `true`.+ *+ * @param {Box3} box - The bounding box to test.+ * @return {boolean} Whether the bounding box contains the given bounding box or not.+ */+ 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;+ }+ /**+ * Returns a point as a proportion of this box's width, height and depth.+ *+ * @param {Vector3} point - A point in 3D space.+ * @param {Vector3} target - The target vector that is used to store the method's result.+ * @return {Vector3} A point as a proportion of this box's width, height and depth.+ */+ 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)+ );+ }+ /**+ * Returns `true` if the given bounding box intersects with this bounding box.+ *+ * @param {Box3} box - The bounding box to test.+ * @return {boolean} Whether the given bounding box intersects with this bounding box.+ */+ 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;+ }+ /**+ * Returns `true` if the given bounding sphere intersects with this bounding box.+ *+ * @param {Sphere} sphere - The bounding sphere to test.+ * @return {boolean} Whether the given bounding sphere intersects with this bounding box.+ */+ intersectsSphere(e) {+ return this.clampPoint(e.center, ci), ci.distanceToSquared(e.center) <= e.radius * e.radius;+ }+ /**+ * Returns `true` if the given plane intersects with this bounding box.+ *+ * @param {Plane} plane - The plane to test.+ * @return {boolean} Whether the given plane intersects with this bounding box.+ */+ 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;+ }+ /**+ * Returns `true` if the given triangle intersects with this bounding box.+ *+ * @param {Triangle} triangle - The triangle to test.+ * @return {boolean} Whether the given triangle intersects with this bounding box.+ */+ intersectsTriangle(e) {+ if (this.isEmpty())+ return !1;+ this.getCenter(Xa), pc.subVectors(this.max, Xa), kr.subVectors(e.a, Xa), Ur.subVectors(e.b, Xa), Or.subVectors(e.c, Xa), ms.subVectors(Ur, kr), bs.subVectors(Or, Ur), js.subVectors(kr, Or);+ let t = [+ 0,+ -ms.z,+ ms.y,+ 0,+ -bs.z,+ bs.y,+ 0,+ -js.z,+ js.y,+ ms.z,+ 0,+ -ms.x,+ bs.z,+ 0,+ -bs.x,+ js.z,+ 0,+ -js.x,+ -ms.y,+ ms.x,+ 0,+ -bs.y,+ bs.x,+ 0,+ -js.y,+ js.x,+ 0+ ];+ return !vh(t, kr, Ur, Or, pc) || (t = [1, 0, 0, 0, 1, 0, 0, 0, 1], !vh(t, kr, Ur, Or, pc)) ? !1 : (Ac.crossVectors(ms, bs), t = [Ac.x, Ac.y, Ac.z], vh(t, kr, Ur, Or, pc));+ }+ /**+ * Clamps the given point within the bounds of this box.+ *+ * @param {Vector3} point - The point to clamp.+ * @param {Vector3} target - The target vector that is used to store the method's result.+ * @return {Vector3} The clamped point.+ */+ clampPoint(e, t) {+ return t.copy(e).clamp(this.min, this.max);+ }+ /**+ * Returns the euclidean distance from any edge of this box to the specified point. If+ * the given point lies inside of this box, the distance will be `0`.+ *+ * @param {Vector3} point - The point to compute the distance to.+ * @return {number} The euclidean distance.+ */+ distanceToPoint(e) {+ return this.clampPoint(e, ci).distanceTo(e);+ }+ /**+ * Returns a bounding sphere that encloses this bounding box.+ *+ * @param {Sphere} target - The target sphere that is used to store the method's result.+ * @return {Sphere} The bounding sphere that encloses this bounding box.+ */+ getBoundingSphere(e) {+ return this.isEmpty() ? e.makeEmpty() : (this.getCenter(e.center), e.radius = this.getSize(ci).length() * 0.5), e;+ }+ /**+ * Computes the intersection of this bounding box and the given one, setting the upper+ * bound of this box to the lesser of the two boxes' upper bounds and the+ * lower bound of this box to the greater of the two boxes' lower bounds. If+ * there's no overlap, makes this box empty.+ *+ * @param {Box3} box - The bounding box to intersect with.+ * @return {Box3} A reference to this bounding box.+ */+ intersect(e) {+ return this.min.max(e.min), this.max.min(e.max), this.isEmpty() && this.makeEmpty(), this;+ }+ /**+ * Computes the union of this box and another and the given one, setting the upper+ * bound of this box to the greater of the two boxes' upper bounds and the+ * lower bound of this box to the lesser of the two boxes' lower bounds.+ *+ * @param {Box3} box - The bounding box that will be unioned with this instance.+ * @return {Box3} A reference to this bounding box.+ */+ union(e) {+ return this.min.min(e.min), this.max.max(e.max), this;+ }+ /**+ * Transforms this bounding box by the given 4x4 transformation matrix.+ *+ * @param {Matrix4} matrix - The transformation matrix.+ * @return {Box3} A reference to this bounding box.+ */+ applyMatrix4(e) {+ return this.isEmpty() ? this : (Hi[0].set(this.min.x, this.min.y, this.min.z).applyMatrix4(e), Hi[1].set(this.min.x, this.min.y, this.max.z).applyMatrix4(e), Hi[2].set(this.min.x, this.max.y, this.min.z).applyMatrix4(e), Hi[3].set(this.min.x, this.max.y, this.max.z).applyMatrix4(e), Hi[4].set(this.max.x, this.min.y, this.min.z).applyMatrix4(e), Hi[5].set(this.max.x, this.min.y, this.max.z).applyMatrix4(e), Hi[6].set(this.max.x, this.max.y, this.min.z).applyMatrix4(e), Hi[7].set(this.max.x, this.max.y, this.max.z).applyMatrix4(e), this.setFromPoints(Hi), this);+ }+ /**+ * Adds the given offset to both the upper and lower bounds of this bounding box,+ * effectively moving it in 3D space.+ *+ * @param {Vector3} offset - The offset that should be used to translate the bounding box.+ * @return {Box3} A reference to this bounding box.+ */+ translate(e) {+ return this.min.add(e), this.max.add(e), this;+ }+ /**+ * Returns `true` if this bounding box is equal with the given one.+ *+ * @param {Box3} box - The box to test for equality.+ * @return {boolean} Whether this bounding box is equal with the given one.+ */+ equals(e) {+ return e.min.equals(this.min) && e.max.equals(this.max);+ }+}+const Hi = [+ /* @__PURE__ */ new H(),+ /* @__PURE__ */ new H(),+ /* @__PURE__ */ new H(),+ /* @__PURE__ */ new H(),+ /* @__PURE__ */ new H(),+ /* @__PURE__ */ new H(),+ /* @__PURE__ */ new H(),+ /* @__PURE__ */ new H()+], ci = /* @__PURE__ */ new H(), fc = /* @__PURE__ */ new yi(), kr = /* @__PURE__ */ new H(), Ur = /* @__PURE__ */ new H(), Or = /* @__PURE__ */ new H(), ms = /* @__PURE__ */ new H(), bs = /* @__PURE__ */ new H(), js = /* @__PURE__ */ new H(), Xa = /* @__PURE__ */ new H(), pc = /* @__PURE__ */ new H(), Ac = /* @__PURE__ */ new H(), Xs = /* @__PURE__ */ new H();+function vh(i, e, t, n, s) {+ for (let r = 0, a = i.length - 3; r <= a; r += 3) {+ Xs.fromArray(i, r);+ const o = s.x * Math.abs(Xs.x) + s.y * Math.abs(Xs.y) + s.z * Math.abs(Xs.z), c = e.dot(Xs), l = t.dot(Xs), h = n.dot(Xs);+ if (Math.max(-Math.max(c, l, h), Math.min(c, l, h)) > o)+ return !1;+ }+ return !0;+}+const kE = /* @__PURE__ */ new yi(), Ya = /* @__PURE__ */ new H(), Ch = /* @__PURE__ */ new H();+class Ui {+ /**+ * Constructs a new sphere.+ *+ * @param {Vector3} [center=(0,0,0)] - The center of the sphere+ * @param {number} [radius=-1] - The radius of the sphere.+ */+ constructor(e = new H(), t = -1) {+ this.isSphere = !0, this.center = e, this.radius = t;+ }+ /**+ * Sets the sphere's components by copying the given values.+ *+ * @param {Vector3} center - The center.+ * @param {number} radius - The radius.+ * @return {Sphere} A reference to this sphere.+ */+ set(e, t) {+ return this.center.copy(e), this.radius = t, this;+ }+ /**+ * Computes the minimum bounding sphere for list of points.+ * If the optional center point is given, it is used as the sphere's+ * center. Otherwise, the center of the axis-aligned bounding box+ * encompassing the points is calculated.+ *+ * @param {Array<Vector3>} points - A list of points in 3D space.+ * @param {Vector3} [optionalCenter] - The center of the sphere.+ * @return {Sphere} A reference to this sphere.+ */+ setFromPoints(e, t) {+ const n = this.center;+ t !== void 0 ? n.copy(t) : kE.setFromPoints(e).getCenter(n);+ let s = 0;+ for (let r = 0, a = e.length; r < a; r++)+ s = Math.max(s, n.distanceToSquared(e[r]));+ return this.radius = Math.sqrt(s), this;+ }+ /**+ * Copies the values of the given sphere to this instance.+ *+ * @param {Sphere} sphere - The sphere to copy.+ * @return {Sphere} A reference to this sphere.+ */+ copy(e) {+ return this.center.copy(e.center), this.radius = e.radius, this;+ }+ /**+ * Returns `true` if the sphere is empty (the radius set to a negative number).+ *+ * Spheres with a radius of `0` contain only their center point and are not+ * considered to be empty.+ *+ * @return {boolean} Whether this sphere is empty or not.+ */+ isEmpty() {+ return this.radius < 0;+ }+ /**+ * Makes this sphere empty which means in encloses a zero space in 3D.+ *+ * @return {Sphere} A reference to this sphere.+ */+ makeEmpty() {+ return this.center.set(0, 0, 0), this.radius = -1, this;+ }+ /**+ * Returns `true` if this sphere contains the given point inclusive of+ * the surface of the sphere.+ *+ * @param {Vector3} point - The point to check.+ * @return {boolean} Whether this sphere contains the given point or not.+ */+ containsPoint(e) {+ return e.distanceToSquared(this.center) <= this.radius * this.radius;+ }+ /**+ * Returns the closest distance from the boundary of the sphere to the+ * given point. If the sphere contains the point, the distance will+ * be negative.+ *+ * @param {Vector3} point - The point to compute the distance to.+ * @return {number} The distance to the point.+ */+ distanceToPoint(e) {+ return e.distanceTo(this.center) - this.radius;+ }+ /**+ * Returns `true` if this sphere intersects with the given one.+ *+ * @param {Sphere} sphere - The sphere to test.+ * @return {boolean} Whether this sphere intersects with the given one or not.+ */+ intersectsSphere(e) {+ const t = this.radius + e.radius;+ return e.center.distanceToSquared(this.center) <= t * t;+ }+ /**+ * Returns `true` if this sphere intersects with the given box.+ *+ * @param {Box3} box - The box to test.+ * @return {boolean} Whether this sphere intersects with the given box or not.+ */+ intersectsBox(e) {+ return e.intersectsSphere(this);+ }+ /**+ * Returns `true` if this sphere intersects with the given plane.+ *+ * @param {Plane} plane - The plane to test.+ * @return {boolean} Whether this sphere intersects with the given plane or not.+ */+ intersectsPlane(e) {+ return Math.abs(e.distanceToPoint(this.center)) <= this.radius;+ }+ /**+ * Clamps a point within the sphere. If the point is outside the sphere, it+ * will clamp it to the closest point on the edge of the sphere. Points+ * already inside the sphere will not be affected.+ *+ * @param {Vector3} point - The plane to clamp.+ * @param {Vector3} target - The target vector that is used to store the method's result.+ * @return {Vector3} The clamped point.+ */+ clampPoint(e, t) {+ const 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;+ }+ /**+ * Returns a bounding box that encloses this sphere.+ *+ * @param {Box3} target - The target box that is used to store the method's result.+ * @return {Box3} The bounding box that encloses this sphere.+ */+ getBoundingBox(e) {+ return this.isEmpty() ? (e.makeEmpty(), e) : (e.set(this.center, this.center), e.expandByScalar(this.radius), e);+ }+ /**+ * Transforms this sphere with the given 4x4 transformation matrix.+ *+ * @param {Matrix4} matrix - The transformation matrix.+ * @return {Sphere} A reference to this sphere.+ */+ applyMatrix4(e) {+ return this.center.applyMatrix4(e), this.radius = this.radius * e.getMaxScaleOnAxis(), this;+ }+ /**+ * Translates the sphere's center by the given offset.+ *+ * @param {Vector3} offset - The offset.+ * @return {Sphere} A reference to this sphere.+ */+ translate(e) {+ return this.center.add(e), this;+ }+ /**+ * Expands the boundaries of this sphere to include the given point.+ *+ * @param {Vector3} point - The point to include.+ * @return {Sphere} A reference to this sphere.+ */+ expandByPoint(e) {+ if (this.isEmpty())+ return this.center.copy(e), this.radius = 0, this;+ Ya.subVectors(e, this.center);+ const t = Ya.lengthSq();+ if (t > this.radius * this.radius) {+ const n = Math.sqrt(t), s = (n - this.radius) * 0.5;+ this.center.addScaledVector(Ya, s / n), this.radius += s;+ }+ return this;+ }+ /**+ * Expands this sphere to enclose both the original sphere and the given sphere.+ *+ * @param {Sphere} sphere - The sphere to include.+ * @return {Sphere} A reference to this sphere.+ */+ 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) : (Ch.subVectors(e.center, this.center).setLength(e.radius), this.expandByPoint(Ya.copy(e.center).add(Ch)), this.expandByPoint(Ya.copy(e.center).sub(Ch))), this);+ }+ /**+ * Returns `true` if this sphere is equal with the given one.+ *+ * @param {Sphere} sphere - The sphere to test for equality.+ * @return {boolean} Whether this bounding sphere is equal with the given one.+ */+ equals(e) {+ return e.center.equals(this.center) && e.radius === this.radius;+ }+ /**+ * Returns a new sphere with copied values from this instance.+ *+ * @return {Sphere} A clone of this instance.+ */+ clone() {+ return new this.constructor().copy(this);+ }+}+const zi = /* @__PURE__ */ new H(), Sh = /* @__PURE__ */ new H(), gc = /* @__PURE__ */ new H(), xs = /* @__PURE__ */ new H(), Ih = /* @__PURE__ */ new H(), mc = /* @__PURE__ */ new H(), Mh = /* @__PURE__ */ new H();+class Jo {+ /**+ * Constructs a new ray.+ *+ * @param {Vector3} [origin=(0,0,0)] - The origin of the ray.+ * @param {Vector3} [direction=(0,0,-1)] - The (normalized) direction of the ray.+ */+ constructor(e = new H(), t = new H(0, 0, -1)) {+ this.origin = e, this.direction = t;+ }+ /**+ * Sets the ray's components by copying the given values.+ *+ * @param {Vector3} origin - The origin.+ * @param {Vector3} direction - The direction.+ * @return {Ray} A reference to this ray.+ */+ set(e, t) {+ return this.origin.copy(e), this.direction.copy(t), this;+ }+ /**+ * Copies the values of the given ray to this instance.+ *+ * @param {Ray} ray - The ray to copy.+ * @return {Ray} A reference to this ray.+ */+ copy(e) {+ return this.origin.copy(e.origin), this.direction.copy(e.direction), this;+ }+ /**+ * Returns a vector that is located at a given distance along this ray.+ *+ * @param {number} t - The distance along the ray to retrieve a position for.+ * @param {Vector3} target - The target vector that is used to store the method's result.+ * @return {Vector3} A position on the ray.+ */+ at(e, t) {+ return t.copy(this.origin).addScaledVector(this.direction, e);+ }+ /**+ * Adjusts the direction of the ray to point at the given vector in world space.+ *+ * @param {Vector3} v - The target position.+ * @return {Ray} A reference to this ray.+ */+ lookAt(e) {+ return this.direction.copy(e).sub(this.origin).normalize(), this;+ }+ /**+ * Shift the origin of this ray along its direction by the given distance.+ *+ * @param {number} t - The distance along the ray to interpolate.+ * @return {Ray} A reference to this ray.+ */+ recast(e) {+ return this.origin.copy(this.at(e, zi)), this;+ }+ /**+ * Returns the point along this ray that is closest to the given point.+ *+ * @param {Vector3} point - A point in 3D space to get the closet location on the ray for.+ * @param {Vector3} target - The target vector that is used to store the method's result.+ * @return {Vector3} The closest point on this ray.+ */+ closestPointToPoint(e, t) {+ t.subVectors(e, this.origin);+ const n = t.dot(this.direction);+ return n < 0 ? t.copy(this.origin) : t.copy(this.origin).addScaledVector(this.direction, n);+ }+ /**+ * Returns the distance of the closest approach between this ray and the given point.+ *+ * @param {Vector3} point - A point in 3D space to compute the distance to.+ * @return {number} The distance.+ */+ distanceToPoint(e) {+ return Math.sqrt(this.distanceSqToPoint(e));+ }+ /**+ * Returns the squared distance of the closest approach between this ray and the given point.+ *+ * @param {Vector3} point - A point in 3D space to compute the distance to.+ * @return {number} The squared distance.+ */+ distanceSqToPoint(e) {+ const t = zi.subVectors(e, this.origin).dot(this.direction);+ return t < 0 ? this.origin.distanceToSquared(e) : (zi.copy(this.origin).addScaledVector(this.direction, t), zi.distanceToSquared(e));+ }+ /**+ * Returns the squared distance between this ray and the given line segment.+ *+ * @param {Vector3} v0 - The start point of the line segment.+ * @param {Vector3} v1 - The end point of the line segment.+ * @param {Vector3} [optionalPointOnRay] - When provided, it receives the point on this ray that is closest to the segment.+ * @param {Vector3} [optionalPointOnSegment] - When provided, it receives the point on the line segment that is closest to this ray.+ * @return {number} The squared distance.+ */+ distanceSqToSegment(e, t, n, s) {+ Sh.copy(e).add(t).multiplyScalar(0.5), gc.copy(t).sub(e).normalize(), xs.copy(this.origin).sub(Sh);+ const r = e.distanceTo(t) * 0.5, a = -this.direction.dot(gc), o = xs.dot(this.direction), c = -xs.dot(gc), l = xs.lengthSq(), h = Math.abs(1 - a * a);+ let u, d, f, m;+ if (h > 0)+ if (u = a * c - o, d = a * o - c, m = r * h, u >= 0)+ if (d >= -m)+ if (d <= m) {+ const A = 1 / h;+ u *= A, d *= A, f = u * (u + a * d + 2 * o) + d * (a * u + d + 2 * c) + l;+ } else+ d = r, u = Math.max(0, -(a * d + o)), f = -u * u + d * (d + 2 * c) + l;+ else+ d = -r, u = Math.max(0, -(a * d + o)), f = -u * u + d * (d + 2 * c) + l;+ else+ d <= -m ? (u = Math.max(0, -(-a * r + o)), d = u > 0 ? -r : Math.min(Math.max(-r, -c), r), f = -u * u + d * (d + 2 * c) + l) : d <= m ? (u = 0, d = Math.min(Math.max(-r, -c), r), f = d * (d + 2 * c) + l) : (u = Math.max(0, -(a * r + o)), d = u > 0 ? r : Math.min(Math.max(-r, -c), r), f = -u * u + d * (d + 2 * c) + l);+ else+ d = a > 0 ? -r : r, u = Math.max(0, -(a * d + o)), f = -u * u + d * (d + 2 * c) + l;+ return n && n.copy(this.origin).addScaledVector(this.direction, u), s && s.copy(Sh).addScaledVector(gc, d), f;+ }+ /**+ * Intersects this ray with the given sphere, returning the intersection+ * point or `null` if there is no intersection.+ *+ * @param {Sphere} sphere - The sphere to intersect.+ * @param {Vector3} target - The target vector that is used to store the method's result.+ * @return {?Vector3} The intersection point.+ */+ intersectSphere(e, t) {+ zi.subVectors(e.center, this.origin);+ const n = zi.dot(this.direction), s = zi.dot(zi) - n * n, r = e.radius * e.radius;+ if (s > r) return null;+ const a = Math.sqrt(r - s), o = n - a, c = n + a;+ return c < 0 ? null : o < 0 ? this.at(c, t) : this.at(o, t);+ }+ /**+ * Returns `true` if this ray intersects with the given sphere.+ *+ * @param {Sphere} sphere - The sphere to intersect.+ * @return {boolean} Whether this ray intersects with the given sphere or not.+ */+ intersectsSphere(e) {+ return this.distanceSqToPoint(e.center) <= e.radius * e.radius;+ }+ /**+ * Computes the distance from the ray's origin to the given plane. Returns `null` if the ray+ * does not intersect with the plane.+ *+ * @param {Plane} plane - The plane to compute the distance to.+ * @return {?number} Whether this ray intersects with the given sphere or not.+ */+ distanceToPlane(e) {+ const t = e.normal.dot(this.direction);+ if (t === 0)+ return e.distanceToPoint(this.origin) === 0 ? 0 : null;+ const n = -(this.origin.dot(e.normal) + e.constant) / t;+ return n >= 0 ? n : null;+ }+ /**+ * Intersects this ray with the given plane, returning the intersection+ * point or `null` if there is no intersection.+ *+ * @param {Plane} plane - The plane to intersect.+ * @param {Vector3} target - The target vector that is used to store the method's result.+ * @return {?Vector3} The intersection point.+ */+ intersectPlane(e, t) {+ const n = this.distanceToPlane(e);+ return n === null ? null : this.at(n, t);+ }+ /**+ * Returns `true` if this ray intersects with the given plane.+ *+ * @param {Plane} plane - The plane to intersect.+ * @return {boolean} Whether this ray intersects with the given plane or not.+ */+ intersectsPlane(e) {+ const t = e.distanceToPoint(this.origin);+ return t === 0 || e.normal.dot(this.direction) * t < 0;+ }+ /**+ * Intersects this ray with the given bounding box, returning the intersection+ * point or `null` if there is no intersection.+ *+ * @param {Box3} box - The box to intersect.+ * @param {Vector3} target - The target vector that is used to store the method's result.+ * @return {?Vector3} The intersection point.+ */+ intersectBox(e, t) {+ let n, s, r, a, o, c;+ const l = 1 / this.direction.x, h = 1 / this.direction.y, u = 1 / this.direction.z, d = this.origin;+ return l >= 0 ? (n = (e.min.x - d.x) * l, s = (e.max.x - d.x) * l) : (n = (e.max.x - d.x) * l, s = (e.min.x - d.x) * l), h >= 0 ? (r = (e.min.y - d.y) * h, a = (e.max.y - d.y) * h) : (r = (e.max.y - d.y) * h, a = (e.min.y - d.y) * h), n > a || r > s || ((r > n || isNaN(n)) && (n = r), (a < s || isNaN(s)) && (s = a), u >= 0 ? (o = (e.min.z - d.z) * u, c = (e.max.z - d.z) * u) : (o = (e.max.z - d.z) * u, c = (e.min.z - d.z) * u), n > c || o > s) || ((o > n || n !== n) && (n = o), (c < s || s !== s) && (s = c), s < 0) ? null : this.at(n >= 0 ? n : s, t);+ }+ /**+ * Returns `true` if this ray intersects with the given box.+ *+ * @param {Box3} box - The box to intersect.+ * @return {boolean} Whether this ray intersects with the given box or not.+ */+ intersectsBox(e) {+ return this.intersectBox(e, zi) !== null;+ }+ /**+ * Intersects this ray with the given triangle, returning the intersection+ * point or `null` if there is no intersection.+ *+ * @param {Vector3} a - The first vertex of the triangle.+ * @param {Vector3} b - The second vertex of the triangle.+ * @param {Vector3} c - The third vertex of the triangle.+ * @param {boolean} backfaceCulling - Whether to use backface culling or not.+ * @param {Vector3} target - The target vector that is used to store the method's result.+ * @return {?Vector3} The intersection point.+ */+ intersectTriangle(e, t, n, s, r) {+ Ih.subVectors(t, e), mc.subVectors(n, e), Mh.crossVectors(Ih, mc);+ let a = this.direction.dot(Mh), o;+ if (a > 0) {+ if (s) return null;+ o = 1;+ } else if (a < 0)+ o = -1, a = -a;+ else+ return null;+ xs.subVectors(this.origin, e);+ const c = o * this.direction.dot(mc.crossVectors(xs, mc));+ if (c < 0)+ return null;+ const l = o * this.direction.dot(Ih.cross(xs));+ if (l < 0 || c + l > a)+ return null;+ const h = -o * xs.dot(Mh);+ return h < 0 ? null : this.at(h / a, r);+ }+ /**+ * Transforms this ray with the given 4x4 transformation matrix.+ *+ * @param {Matrix4} matrix4 - The transformation matrix.+ * @return {Ray} A reference to this ray.+ */+ applyMatrix4(e) {+ return this.origin.applyMatrix4(e), this.direction.transformDirection(e), this;+ }+ /**+ * Returns `true` if this ray is equal with the given one.+ *+ * @param {Ray} ray - The ray to test for equality.+ * @return {boolean} Whether this ray is equal with the given one.+ */+ equals(e) {+ return e.origin.equals(this.origin) && e.direction.equals(this.direction);+ }+ /**+ * Returns a new ray with copied values from this instance.+ *+ * @return {Ray} A clone of this instance.+ */+ clone() {+ return new this.constructor().copy(this);+ }+}+class et {+ /**+ * Constructs a new 4x4 matrix. The arguments are supposed to be+ * in row-major order. If no arguments are provided, the constructor+ * initializes the matrix as an identity matrix.+ *+ * @param {number} [n11] - 1-1 matrix element.+ * @param {number} [n12] - 1-2 matrix element.+ * @param {number} [n13] - 1-3 matrix element.+ * @param {number} [n14] - 1-4 matrix element.+ * @param {number} [n21] - 2-1 matrix element.+ * @param {number} [n22] - 2-2 matrix element.+ * @param {number} [n23] - 2-3 matrix element.+ * @param {number} [n24] - 2-4 matrix element.+ * @param {number} [n31] - 3-1 matrix element.+ * @param {number} [n32] - 3-2 matrix element.+ * @param {number} [n33] - 3-3 matrix element.+ * @param {number} [n34] - 3-4 matrix element.+ * @param {number} [n41] - 4-1 matrix element.+ * @param {number} [n42] - 4-2 matrix element.+ * @param {number} [n43] - 4-3 matrix element.+ * @param {number} [n44] - 4-4 matrix element.+ */+ constructor(e, t, n, s, r, a, o, c, l, h, u, d, f, m, A, g) {+ et.prototype.isMatrix4 = !0, this.elements = [+ 1,+ 0,+ 0,+ 0,+ 0,+ 1,+ 0,+ 0,+ 0,+ 0,+ 1,+ 0,+ 0,+ 0,+ 0,+ 1+ ], e !== void 0 && this.set(e, t, n, s, r, a, o, c, l, h, u, d, f, m, A, g);+ }+ /**+ * Sets the elements of the matrix.The arguments are supposed to be+ * in row-major order.+ *+ * @param {number} [n11] - 1-1 matrix element.+ * @param {number} [n12] - 1-2 matrix element.+ * @param {number} [n13] - 1-3 matrix element.+ * @param {number} [n14] - 1-4 matrix element.+ * @param {number} [n21] - 2-1 matrix element.+ * @param {number} [n22] - 2-2 matrix element.+ * @param {number} [n23] - 2-3 matrix element.+ * @param {number} [n24] - 2-4 matrix element.+ * @param {number} [n31] - 3-1 matrix element.+ * @param {number} [n32] - 3-2 matrix element.+ * @param {number} [n33] - 3-3 matrix element.+ * @param {number} [n34] - 3-4 matrix element.+ * @param {number} [n41] - 4-1 matrix element.+ * @param {number} [n42] - 4-2 matrix element.+ * @param {number} [n43] - 4-3 matrix element.+ * @param {number} [n44] - 4-4 matrix element.+ * @return {Matrix4} A reference to this matrix.+ */+ set(e, t, n, s, r, a, o, c, l, h, u, d, f, m, A, g) {+ const p = this.elements;+ return p[0] = e, p[4] = t, p[8] = n, p[12] = s, p[1] = r, p[5] = a, p[9] = o, p[13] = c, p[2] = l, p[6] = h, p[10] = u, p[14] = d, p[3] = f, p[7] = m, p[11] = A, p[15] = g, this;+ }+ /**+ * Sets this matrix to the 4x4 identity matrix.+ *+ * @return {Matrix4} A reference to this matrix.+ */+ identity() {+ return this.set(+ 1,+ 0,+ 0,+ 0,+ 0,+ 1,+ 0,+ 0,+ 0,+ 0,+ 1,+ 0,+ 0,+ 0,+ 0,+ 1+ ), this;+ }+ /**+ * Returns a matrix with copied values from this instance.+ *+ * @return {Matrix4} A clone of this instance.+ */+ clone() {+ return new et().fromArray(this.elements);+ }+ /**+ * Copies the values of the given matrix to this instance.+ *+ * @param {Matrix4} m - The matrix to copy.+ * @return {Matrix4} A reference to this matrix.+ */+ copy(e) {+ const 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;+ }+ /**+ * Copies the translation component of the given matrix+ * into this matrix's translation component.+ *+ * @param {Matrix4} m - The matrix to copy the translation component.+ * @return {Matrix4} A reference to this matrix.+ */+ copyPosition(e) {+ const t = this.elements, n = e.elements;+ return t[12] = n[12], t[13] = n[13], t[14] = n[14], this;+ }+ /**+ * Set the upper 3x3 elements of this matrix to the values of given 3x3 matrix.+ *+ * @param {Matrix3} m - The 3x3 matrix.+ * @return {Matrix4} A reference to this matrix.+ */+ setFromMatrix3(e) {+ const 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;+ }+ /**+ * Extracts the basis of this matrix into the three axis vectors provided.+ *+ * @param {Vector3} xAxis - The basis's x axis.+ * @param {Vector3} yAxis - The basis's y axis.+ * @param {Vector3} zAxis - The basis's z axis.+ * @return {Matrix4} A reference to this matrix.+ */+ extractBasis(e, t, n) {+ return e.setFromMatrixColumn(this, 0), t.setFromMatrixColumn(this, 1), n.setFromMatrixColumn(this, 2), this;+ }+ /**+ * Sets the given basis vectors to this matrix.+ *+ * @param {Vector3} xAxis - The basis's x axis.+ * @param {Vector3} yAxis - The basis's y axis.+ * @param {Vector3} zAxis - The basis's z axis.+ * @return {Matrix4} A reference to this matrix.+ */+ 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;+ }+ /**+ * Extracts the rotation component of the given matrix+ * into this matrix's rotation component.+ *+ * Note: This method does not support reflection matrices.+ *+ * @param {Matrix4} m - The matrix.+ * @return {Matrix4} A reference to this matrix.+ */+ extractRotation(e) {+ const t = this.elements, n = e.elements, s = 1 / Qr.setFromMatrixColumn(e, 0).length(), r = 1 / Qr.setFromMatrixColumn(e, 1).length(), a = 1 / Qr.setFromMatrixColumn(e, 2).length();+ return t[0] = n[0] * s, t[1] = n[1] * s, t[2] = n[2] * s, t[3] = 0, t[4] = n[4] * r, t[5] = n[5] * r, t[6] = n[6] * r, 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;+ }+ /**+ * Sets the rotation component (the upper left 3x3 matrix) of this matrix to+ * the rotation specified by the given Euler angles. The rest of+ * the matrix is set to the identity. Depending on the {@link Euler#order},+ * there are six possible outcomes. See [this page]{@link https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix}+ * for a complete list.+ *+ * @param {Euler} euler - The Euler angles.+ * @return {Matrix4} A reference to this matrix.+ */+ makeRotationFromEuler(e) {+ const t = this.elements, n = e.x, s = e.y, r = e.z, a = Math.cos(n), o = Math.sin(n), c = Math.cos(s), l = Math.sin(s), h = Math.cos(r), u = Math.sin(r);+ if (e.order === "XYZ") {+ const d = a * h, f = a * u, m = o * h, A = o * u;+ t[0] = c * h, t[4] = -c * u, t[8] = l, t[1] = f + m * l, t[5] = d - A * l, t[9] = -o * c, t[2] = A - d * l, t[6] = m + f * l, t[10] = a * c;+ } else if (e.order === "YXZ") {+ const d = c * h, f = c * u, m = l * h, A = l * u;+ t[0] = d + A * o, t[4] = m * o - f, t[8] = a * l, t[1] = a * u, t[5] = a * h, t[9] = -o, t[2] = f * o - m, t[6] = A + d * o, t[10] = a * c;+ } else if (e.order === "ZXY") {+ const d = c * h, f = c * u, m = l * h, A = l * u;+ t[0] = d - A * o, t[4] = -a * u, t[8] = m + f * o, t[1] = f + m * o, t[5] = a * h, t[9] = A - d * o, t[2] = -a * l, t[6] = o, t[10] = a * c;+ } else if (e.order === "ZYX") {+ const d = a * h, f = a * u, m = o * h, A = o * u;+ t[0] = c * h, t[4] = m * l - f, t[8] = d * l + A, t[1] = c * u, t[5] = A * l + d, t[9] = f * l - m, t[2] = -l, t[6] = o * c, t[10] = a * c;+ } else if (e.order === "YZX") {+ const d = a * c, f = a * l, m = o * c, A = o * l;+ t[0] = c * h, t[4] = A - d * u, t[8] = m * u + f, t[1] = u, t[5] = a * h, t[9] = -o * h, t[2] = -l * h, t[6] = f * u + m, t[10] = d - A * u;+ } else if (e.order === "XZY") {+ const d = a * c, f = a * l, m = o * c, A = o * l;+ t[0] = c * h, t[4] = -u, t[8] = l * h, t[1] = d * u + A, t[5] = a * h, t[9] = f * u - m, t[2] = m * u - f, t[6] = o * h, t[10] = A * u + d;+ }+ return t[3] = 0, t[7] = 0, t[11] = 0, t[12] = 0, t[13] = 0, t[14] = 0, t[15] = 1, this;+ }+ /**+ * Sets the rotation component of this matrix to the rotation specified by+ * the given Quaternion as outlined [here]{@link https://en.wikipedia.org/wiki/Rotation_matrix#Quaternion}+ * The rest of the matrix is set to the identity.+ *+ * @param {Quaternion} q - The Quaternion.+ * @return {Matrix4} A reference to this matrix.+ */+ makeRotationFromQuaternion(e) {+ return this.compose(UE, e, OE);+ }+ /**+ * Sets the rotation component of the transformation matrix, looking from `eye` towards+ * `target`, and oriented by the up-direction.+ *+ * @param {Vector3} eye - The eye vector.+ * @param {Vector3} target - The target vector.+ * @param {Vector3} up - The up vector.+ * @return {Matrix4} A reference to this matrix.+ */+ lookAt(e, t, n) {+ const s = this.elements;+ return Wn.subVectors(e, t), Wn.lengthSq() === 0 && (Wn.z = 1), Wn.normalize(), _s.crossVectors(n, Wn), _s.lengthSq() === 0 && (Math.abs(n.z) === 1 ? Wn.x += 1e-4 : Wn.z += 1e-4, Wn.normalize(), _s.crossVectors(n, Wn)), _s.normalize(), bc.crossVectors(Wn, _s), s[0] = _s.x, s[4] = bc.x, s[8] = Wn.x, s[1] = _s.y, s[5] = bc.y, s[9] = Wn.y, s[2] = _s.z, s[6] = bc.z, s[10] = Wn.z, this;+ }+ /**+ * Post-multiplies this matrix by the given 4x4 matrix.+ *+ * @param {Matrix4} m - The matrix to multiply with.+ * @return {Matrix4} A reference to this matrix.+ */+ multiply(e) {+ return this.multiplyMatrices(this, e);+ }+ /**+ * Pre-multiplies this matrix by the given 4x4 matrix.+ *+ * @param {Matrix4} m - The matrix to multiply with.+ * @return {Matrix4} A reference to this matrix.+ */+ premultiply(e) {+ return this.multiplyMatrices(e, this);+ }+ /**+ * Multiples the given 4x4 matrices and stores the result+ * in this matrix.+ *+ * @param {Matrix4} a - The first matrix.+ * @param {Matrix4} b - The second matrix.+ * @return {Matrix4} A reference to this matrix.+ */+ multiplyMatrices(e, t) {+ const n = e.elements, s = t.elements, r = this.elements, a = n[0], o = n[4], c = n[8], l = n[12], h = n[1], u = n[5], d = n[9], f = n[13], m = n[2], A = n[6], g = n[10], p = n[14], y = n[3], b = n[7], E = n[11], M = n[15], w = s[0], S = s[4], T = s[8], C = s[12], v = s[1], F = s[5], K = s[9], q = s[13], $ = s[2], D = s[6], O = s[10], Y = s[14], Q = s[3], J = s[7], ee = s[11], ae = s[15];+ return r[0] = a * w + o * v + c * $ + l * Q, r[4] = a * S + o * F + c * D + l * J, r[8] = a * T + o * K + c * O + l * ee, r[12] = a * C + o * q + c * Y + l * ae, r[1] = h * w + u * v + d * $ + f * Q, r[5] = h * S + u * F + d * D + f * J, r[9] = h * T + u * K + d * O + f * ee, r[13] = h * C + u * q + d * Y + f * ae, r[2] = m * w + A * v + g * $ + p * Q, r[6] = m * S + A * F + g * D + p * J, r[10] = m * T + A * K + g * O + p * ee, r[14] = m * C + A * q + g * Y + p * ae, r[3] = y * w + b * v + E * $ + M * Q, r[7] = y * S + b * F + E * D + M * J, r[11] = y * T + b * K + E * O + M * ee, r[15] = y * C + b * q + E * Y + M * ae, this;+ }+ /**+ * Multiplies every component of the matrix by the given scalar.+ *+ * @param {number} s - The scalar.+ * @return {Matrix4} A reference to this matrix.+ */+ multiplyScalar(e) {+ const 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;+ }+ /**+ * Computes and returns the determinant of this matrix.+ *+ * Based on the method outlined [here]{@link http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.html}.+ *+ * @return {number} The determinant.+ */+ determinant() {+ const e = this.elements, t = e[0], n = e[4], s = e[8], r = e[12], a = e[1], o = e[5], c = e[9], l = e[13], h = e[2], u = e[6], d = e[10], f = e[14], m = e[3], A = e[7], g = e[11], p = e[15];+ return m * (+r * c * u - s * l * u - r * o * d + n * l * d + s * o * f - n * c * f) + A * (+t * c * f - t * l * d + r * a * d - s * a * f + s * l * h - r * c * h) + g * (+t * l * u - t * o * f - r * a * u + n * a * f + r * o * h - n * l * h) + p * (-s * o * h - t * c * u + t * o * d + s * a * u - n * a * d + n * c * h);+ }+ /**+ * Transposes this matrix in place.+ *+ * @return {Matrix4} A reference to this matrix.+ */+ transpose() {+ const e = this.elements;+ let 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;+ }+ /**+ * Sets the position component for this matrix from the given vector,+ * without affecting the rest of the matrix.+ *+ * @param {number|Vector3} x - The x component of the vector or alternatively the vector object.+ * @param {number} y - The y component of the vector.+ * @param {number} z - The z component of the vector.+ * @return {Matrix4} A reference to this matrix.+ */+ setPosition(e, t, n) {+ const s = this.elements;+ return e.isVector3 ? (s[12] = e.x, s[13] = e.y, s[14] = e.z) : (s[12] = e, s[13] = t, s[14] = n), this;+ }+ /**+ * Inverts this matrix, using the [analytic method]{@link https://en.wikipedia.org/wiki/Invertible_matrix#Analytic_solution}.+ * You can not invert with a determinant of zero. If you attempt this, the method produces+ * a zero matrix instead.+ *+ * @return {Matrix4} A reference to this matrix.+ */+ invert() {+ const e = this.elements, t = e[0], n = e[1], s = e[2], r = e[3], a = e[4], o = e[5], c = e[6], l = e[7], h = e[8], u = e[9], d = e[10], f = e[11], m = e[12], A = e[13], g = e[14], p = e[15], y = u * g * l - A * d * l + A * c * f - o * g * f - u * c * p + o * d * p, b = m * d * l - h * g * l - m * c * f + a * g * f + h * c * p - a * d * p, E = h * A * l - m * u * l + m * o * f - a * A * f - h * o * p + a * u * p, M = m * u * c - h * A * c - m * o * d + a * A * d + h * o * g - a * u * g, w = t * y + n * b + s * E + r * M;+ if (w === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);+ const S = 1 / w;+ return e[0] = y * S, e[1] = (A * d * r - u * g * r - A * s * f + n * g * f + u * s * p - n * d * p) * S, e[2] = (o * g * r - A * c * r + A * s * l - n * g * l - o * s * p + n * c * p) * S, e[3] = (u * c * r - o * d * r - u * s * l + n * d * l + o * s * f - n * c * f) * S, e[4] = b * S, e[5] = (h * g * r - m * d * r + m * s * f - t * g * f - h * s * p + t * d * p) * S, e[6] = (m * c * r - a * g * r - m * s * l + t * g * l + a * s * p - t * c * p) * S, e[7] = (a * d * r - h * c * r + h * s * l - t * d * l - a * s * f + t * c * f) * S, e[8] = E * S, e[9] = (m * u * r - h * A * r - m * n * f + t * A * f + h * n * p - t * u * p) * S, e[10] = (a * A * r - m * o * r + m * n * l - t * A * l - a * n * p + t * o * p) * S, e[11] = (h * o * r - a * u * r - h * n * l + t * u * l + a * n * f - t * o * f) * S, e[12] = M * S, e[13] = (h * A * s - m * u * s + m * n * d - t * A * d - h * n * g + t * u * g) * S, e[14] = (m * o * s - a * A * s - m * n * c + t * A * c + a * n * g - t * o * g) * S, e[15] = (a * u * s - h * o * s + h * n * c - t * u * c - a * n * d + t * o * d) * S, this;+ }+ /**+ * Multiplies the columns of this matrix by the given vector.+ *+ * @param {Vector3} v - The scale vector.+ * @return {Matrix4} A reference to this matrix.+ */+ scale(e) {+ const t = this.elements, n = e.x, s = e.y, r = e.z;+ return t[0] *= n, t[4] *= s, t[8] *= r, t[1] *= n, t[5] *= s, t[9] *= r, t[2] *= n, t[6] *= s, t[10] *= r, t[3] *= n, t[7] *= s, t[11] *= r, this;+ }+ /**+ * Gets the maximum scale value of the three axes.+ *+ * @return {number} The maximum scale.+ */+ getMaxScaleOnAxis() {+ const 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], s = e[8] * e[8] + e[9] * e[9] + e[10] * e[10];+ return Math.sqrt(Math.max(t, n, s));+ }+ /**+ * Sets this matrix as a translation transform from the given vector.+ *+ * @param {number|Vector3} x - The amount to translate in the X axis or alternatively a translation vector.+ * @param {number} y - The amount to translate in the Y axis.+ * @param {number} z - The amount to translate in the z axis.+ * @return {Matrix4} A reference to this matrix.+ */+ 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;+ }+ /**+ * Sets this matrix as a rotational transformation around the X axis by+ * the given angle.+ *+ * @param {number} theta - The rotation in radians.+ * @return {Matrix4} A reference to this matrix.+ */+ makeRotationX(e) {+ const 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;+ }+ /**+ * Sets this matrix as a rotational transformation around the Y axis by+ * the given angle.+ *+ * @param {number} theta - The rotation in radians.+ * @return {Matrix4} A reference to this matrix.+ */+ makeRotationY(e) {+ const 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;+ }+ /**+ * Sets this matrix as a rotational transformation around the Z axis by+ * the given angle.+ *+ * @param {number} theta - The rotation in radians.+ * @return {Matrix4} A reference to this matrix.+ */+ makeRotationZ(e) {+ const 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;+ }+ /**+ * Sets this matrix as a rotational transformation around the given axis by+ * the given angle.+ *+ * This is a somewhat controversial but mathematically sound alternative to+ * rotating via Quaternions. See the discussion [here]{@link https://www.gamedev.net/articles/programming/math-and-physics/do-we-really-need-quaternions-r1199}.+ *+ * @param {Vector3} axis - The normalized rotation axis.+ * @param {number} angle - The rotation in radians.+ * @return {Matrix4} A reference to this matrix.+ */+ makeRotationAxis(e, t) {+ const n = Math.cos(t), s = Math.sin(t), r = 1 - n, a = e.x, o = e.y, c = e.z, l = r * a, h = r * o;+ return this.set(+ l * a + n,+ l * o - s * c,+ l * c + s * o,+ 0,+ l * o + s * c,+ h * o + n,+ h * c - s * a,+ 0,+ l * c - s * o,+ h * c + s * a,+ r * c * c + n,+ 0,+ 0,+ 0,+ 0,+ 1+ ), this;+ }+ /**+ * Sets this matrix as a scale transformation.+ *+ * @param {number} x - The amount to scale in the X axis.+ * @param {number} y - The amount to scale in the Y axis.+ * @param {number} z - The amount to scale in the Z axis.+ * @return {Matrix4} A reference to this matrix.+ */+ makeScale(e, t, n) {+ return this.set(+ e,+ 0,+ 0,+ 0,+ 0,+ t,+ 0,+ 0,+ 0,+ 0,+ n,+ 0,+ 0,+ 0,+ 0,+ 1+ ), this;+ }+ /**+ * Sets this matrix as a shear transformation.+ *+ * @param {number} xy - The amount to shear X by Y.+ * @param {number} xz - The amount to shear X by Z.+ * @param {number} yx - The amount to shear Y by X.+ * @param {number} yz - The amount to shear Y by Z.+ * @param {number} zx - The amount to shear Z by X.+ * @param {number} zy - The amount to shear Z by Y.+ * @return {Matrix4} A reference to this matrix.+ */+ makeShear(e, t, n, s, r, a) {+ return this.set(+ 1,+ n,+ r,+ 0,+ e,+ 1,+ a,+ 0,+ t,+ s,+ 1,+ 0,+ 0,+ 0,+ 0,+ 1+ ), this;+ }+ /**+ * Sets this matrix to the transformation composed of the given position,+ * rotation (Quaternion) and scale.+ *+ * @param {Vector3} position - The position vector.+ * @param {Quaternion} quaternion - The rotation as a Quaternion.+ * @param {Vector3} scale - The scale vector.+ * @return {Matrix4} A reference to this matrix.+ */+ compose(e, t, n) {+ const s = this.elements, r = t._x, a = t._y, o = t._z, c = t._w, l = r + r, h = a + a, u = o + o, d = r * l, f = r * h, m = r * u, A = a * h, g = a * u, p = o * u, y = c * l, b = c * h, E = c * u, M = n.x, w = n.y, S = n.z;+ return s[0] = (1 - (A + p)) * M, s[1] = (f + E) * M, s[2] = (m - b) * M, s[3] = 0, s[4] = (f - E) * w, s[5] = (1 - (d + p)) * w, s[6] = (g + y) * w, s[7] = 0, s[8] = (m + b) * S, s[9] = (g - y) * S, s[10] = (1 - (d + A)) * S, s[11] = 0, s[12] = e.x, s[13] = e.y, s[14] = e.z, s[15] = 1, this;+ }+ /**+ * Decomposes this matrix into its position, rotation and scale components+ * and provides the result in the given objects.+ *+ * Note: Not all matrices are decomposable in this way. For example, if an+ * object has a non-uniformly scaled parent, then the object's world matrix+ * may not be decomposable, and this method may not be appropriate.+ *+ * @param {Vector3} position - The position vector.+ * @param {Quaternion} quaternion - The rotation as a Quaternion.+ * @param {Vector3} scale - The scale vector.+ * @return {Matrix4} A reference to this matrix.+ */+ decompose(e, t, n) {+ const s = this.elements;+ let r = Qr.set(s[0], s[1], s[2]).length();+ const a = Qr.set(s[4], s[5], s[6]).length(), o = Qr.set(s[8], s[9], s[10]).length();+ this.determinant() < 0 && (r = -r), e.x = s[12], e.y = s[13], e.z = s[14], li.copy(this);+ const l = 1 / r, h = 1 / a, u = 1 / o;+ return li.elements[0] *= l, li.elements[1] *= l, li.elements[2] *= l, li.elements[4] *= h, li.elements[5] *= h, li.elements[6] *= h, li.elements[8] *= u, li.elements[9] *= u, li.elements[10] *= u, t.setFromRotationMatrix(li), n.x = r, n.y = a, n.z = o, this;+ }+ /**+ * Creates a perspective projection matrix. This is used internally by+ * {@link PerspectiveCamera#updateProjectionMatrix}.++ * @param {number} left - Left boundary of the viewing frustum at the near plane.+ * @param {number} right - Right boundary of the viewing frustum at the near plane.+ * @param {number} top - Top boundary of the viewing frustum at the near plane.+ * @param {number} bottom - Bottom boundary of the viewing frustum at the near plane.+ * @param {number} near - The distance from the camera to the near plane.+ * @param {number} far - The distance from the camera to the far plane.+ * @param {(WebGLCoordinateSystem|WebGPUCoordinateSystem)} [coordinateSystem=WebGLCoordinateSystem] - The coordinate system.+ * @return {Matrix4} A reference to this matrix.+ */+ makePerspective(e, t, n, s, r, a, o = is) {+ const c = this.elements, l = 2 * r / (t - e), h = 2 * r / (n - s), u = (t + e) / (t - e), d = (n + s) / (n - s);+ let f, m;+ if (o === is)+ f = -(a + r) / (a - r), m = -2 * a * r / (a - r);+ else if (o === Tl)+ f = -a / (a - r), m = -a * r / (a - r);+ else+ throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: " + o);+ return c[0] = l, c[4] = 0, c[8] = u, c[12] = 0, c[1] = 0, c[5] = h, c[9] = d, c[13] = 0, c[2] = 0, c[6] = 0, c[10] = f, c[14] = m, c[3] = 0, c[7] = 0, c[11] = -1, c[15] = 0, this;+ }+ /**+ * Creates a orthographic projection matrix. This is used internally by+ * {@link OrthographicCamera#updateProjectionMatrix}.++ * @param {number} left - Left boundary of the viewing frustum at the near plane.+ * @param {number} right - Right boundary of the viewing frustum at the near plane.+ * @param {number} top - Top boundary of the viewing frustum at the near plane.+ * @param {number} bottom - Bottom boundary of the viewing frustum at the near plane.+ * @param {number} near - The distance from the camera to the near plane.+ * @param {number} far - The distance from the camera to the far plane.+ * @param {(WebGLCoordinateSystem|WebGPUCoordinateSystem)} [coordinateSystem=WebGLCoordinateSystem] - The coordinate system.+ * @return {Matrix4} A reference to this matrix.+ */+ makeOrthographic(e, t, n, s, r, a, o = is) {+ const c = this.elements, l = 1 / (t - e), h = 1 / (n - s), u = 1 / (a - r), d = (t + e) * l, f = (n + s) * h;+ let m, A;+ if (o === is)+ m = (a + r) * u, A = -2 * u;+ else if (o === Tl)+ m = r * u, A = -1 * u;+ else+ throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: " + o);+ return c[0] = 2 * l, c[4] = 0, c[8] = 0, c[12] = -d, c[1] = 0, c[5] = 2 * h, c[9] = 0, c[13] = -f, c[2] = 0, c[6] = 0, c[10] = A, c[14] = -m, c[3] = 0, c[7] = 0, c[11] = 0, c[15] = 1, this;+ }+ /**+ * Returns `true` if this matrix is equal with the given one.+ *+ * @param {Matrix4} matrix - The matrix to test for equality.+ * @return {boolean} Whether this matrix is equal with the given one.+ */+ equals(e) {+ const t = this.elements, n = e.elements;+ for (let s = 0; s < 16; s++)+ if (t[s] !== n[s]) return !1;+ return !0;+ }+ /**+ * Sets the elements of the matrix from the given array.+ *+ * @param {Array<number>} array - The matrix elements in column-major order.+ * @param {number} [offset=0] - Index of the first element in the array.+ * @return {Matrix4} A reference to this matrix.+ */+ fromArray(e, t = 0) {+ for (let n = 0; n < 16; n++)+ this.elements[n] = e[n + t];+ return this;+ }+ /**+ * Writes the elements of this matrix to the given array. If no array is provided,+ * the method returns a new instance.+ *+ * @param {Array<number>} [array=[]] - The target array holding the matrix elements in column-major order.+ * @param {number} [offset=0] - Index of the first element in the array.+ * @return {Array<number>} The matrix elements in column-major order.+ */+ toArray(e = [], t = 0) {+ const 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;+ }+}+const Qr = /* @__PURE__ */ new H(), li = /* @__PURE__ */ new et(), UE = /* @__PURE__ */ new H(0, 0, 0), OE = /* @__PURE__ */ new H(1, 1, 1), _s = /* @__PURE__ */ new H(), bc = /* @__PURE__ */ new H(), Wn = /* @__PURE__ */ new H(), wp = /* @__PURE__ */ new et(), vp = /* @__PURE__ */ new Yn();+class Pi {+ /**+ * Constructs a new euler instance.+ *+ * @param {number} [x=0] - The angle of the x axis in radians.+ * @param {number} [y=0] - The angle of the y axis in radians.+ * @param {number} [z=0] - The angle of the z axis in radians.+ * @param {string} [order=Euler.DEFAULT_ORDER] - A string representing the order that the rotations are applied.+ */+ constructor(e = 0, t = 0, n = 0, s = Pi.DEFAULT_ORDER) {+ this.isEuler = !0, this._x = e, this._y = t, this._z = n, this._order = s;+ }+ /**+ * The angle of the x axis in radians.+ *+ * @type {number}+ * @default 0+ */+ get x() {+ return this._x;+ }+ set x(e) {+ this._x = e, this._onChangeCallback();+ }+ /**+ * The angle of the y axis in radians.+ *+ * @type {number}+ * @default 0+ */+ get y() {+ return this._y;+ }+ set y(e) {+ this._y = e, this._onChangeCallback();+ }+ /**+ * The angle of the z axis in radians.+ *+ * @type {number}+ * @default 0+ */+ get z() {+ return this._z;+ }+ set z(e) {+ this._z = e, this._onChangeCallback();+ }+ /**+ * A string representing the order that the rotations are applied.+ *+ * @type {string}+ * @default 'XYZ'+ */+ get order() {+ return this._order;+ }+ set order(e) {+ this._order = e, this._onChangeCallback();+ }+ /**+ * Sets the Euler components.+ *+ * @param {number} x - The angle of the x axis in radians.+ * @param {number} y - The angle of the y axis in radians.+ * @param {number} z - The angle of the z axis in radians.+ * @param {string} [order] - A string representing the order that the rotations are applied.+ * @return {Euler} A reference to this Euler instance.+ */+ set(e, t, n, s = this._order) {+ return this._x = e, this._y = t, this._z = n, this._order = s, this._onChangeCallback(), this;+ }+ /**+ * Returns a new Euler instance with copied values from this instance.+ *+ * @return {Euler} A clone of this instance.+ */+ clone() {+ return new this.constructor(this._x, this._y, this._z, this._order);+ }+ /**+ * Copies the values of the given Euler instance to this instance.+ *+ * @param {Euler} euler - The Euler instance to copy.+ * @return {Euler} A reference to this Euler instance.+ */+ copy(e) {+ return this._x = e._x, this._y = e._y, this._z = e._z, this._order = e._order, this._onChangeCallback(), this;+ }+ /**+ * Sets the angles of this Euler instance from a pure rotation matrix.+ *+ * @param {Matrix4} m - A 4x4 matrix of which the upper 3x3 of matrix is a pure rotation matrix (i.e. unscaled).+ * @param {string} [order] - A string representing the order that the rotations are applied.+ * @param {boolean} [update=true] - Whether the internal `onChange` callback should be executed or not.+ * @return {Euler} A reference to this Euler instance.+ */+ setFromRotationMatrix(e, t = this._order, n = !0) {+ const s = e.elements, r = s[0], a = s[4], o = s[8], c = s[1], l = s[5], h = s[9], u = s[2], d = s[6], f = s[10];+ switch (t) {+ case "XYZ":+ this._y = Math.asin(ct(o, -1, 1)), Math.abs(o) < 0.9999999 ? (this._x = Math.atan2(-h, f), this._z = Math.atan2(-a, r)) : (this._x = Math.atan2(d, l), this._z = 0);+ break;+ case "YXZ":+ this._x = Math.asin(-ct(h, -1, 1)), Math.abs(h) < 0.9999999 ? (this._y = Math.atan2(o, f), this._z = Math.atan2(c, l)) : (this._y = Math.atan2(-u, r), this._z = 0);+ break;+ case "ZXY":+ this._x = Math.asin(ct(d, -1, 1)), Math.abs(d) < 0.9999999 ? (this._y = Math.atan2(-u, f), this._z = Math.atan2(-a, l)) : (this._y = 0, this._z = Math.atan2(c, r));+ break;+ case "ZYX":+ this._y = Math.asin(-ct(u, -1, 1)), Math.abs(u) < 0.9999999 ? (this._x = Math.atan2(d, f), this._z = Math.atan2(c, r)) : (this._x = 0, this._z = Math.atan2(-a, l));+ break;+ case "YZX":+ this._z = Math.asin(ct(c, -1, 1)), Math.abs(c) < 0.9999999 ? (this._x = Math.atan2(-h, l), this._y = Math.atan2(-u, r)) : (this._x = 0, this._y = Math.atan2(o, f));+ break;+ case "XZY":+ this._z = Math.asin(-ct(a, -1, 1)), Math.abs(a) < 0.9999999 ? (this._x = Math.atan2(d, l), this._y = Math.atan2(o, r)) : (this._x = Math.atan2(-h, f), this._y = 0);+ break;+ default:+ console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: " + t);+ }+ return this._order = t, n === !0 && this._onChangeCallback(), this;+ }+ /**+ * Sets the angles of this Euler instance from a normalized quaternion.+ *+ * @param {Quaternion} q - A normalized Quaternion.+ * @param {string} [order] - A string representing the order that the rotations are applied.+ * @param {boolean} [update=true] - Whether the internal `onChange` callback should be executed or not.+ * @return {Euler} A reference to this Euler instance.+ */+ setFromQuaternion(e, t, n) {+ return wp.makeRotationFromQuaternion(e), this.setFromRotationMatrix(wp, t, n);+ }+ /**+ * Sets the angles of this Euler instance from the given vector.+ *+ * @param {Vector3} v - The vector.+ * @param {string} [order] - A string representing the order that the rotations are applied.+ * @return {Euler} A reference to this Euler instance.+ */+ setFromVector3(e, t = this._order) {+ return this.set(e.x, e.y, e.z, t);+ }+ /**+ * Resets the euler angle with a new order by creating a quaternion from this+ * euler angle and then setting this euler angle with the quaternion and the+ * new order.+ *+ * Warning: This discards revolution information.+ *+ * @param {string} [newOrder] - A string representing the new order that the rotations are applied.+ * @return {Euler} A reference to this Euler instance.+ */+ reorder(e) {+ return vp.setFromEuler(this), this.setFromQuaternion(vp, e);+ }+ /**+ * Returns `true` if this Euler instance is equal with the given one.+ *+ * @param {Euler} euler - The Euler instance to test for equality.+ * @return {boolean} Whether this Euler instance is equal with the given one.+ */+ equals(e) {+ return e._x === this._x && e._y === this._y && e._z === this._z && e._order === this._order;+ }+ /**+ * Sets this Euler instance's components to values from the given array. The first three+ * entries of the array are assign to the x,y and z components. An optional fourth entry+ * defines the Euler order.+ *+ * @param {Array<number,number,number,?string>} array - An array holding the Euler component values.+ * @return {Euler} A reference to this Euler instance.+ */+ 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;+ }+ /**+ * Writes the components of this Euler instance to the given array. If no array is provided,+ * the method returns a new instance.+ *+ * @param {Array<number,number,number,string>} [array=[]] - The target array holding the Euler components.+ * @param {number} [offset=0] - Index of the first element in the array.+ * @return {Array<number,number,number,string>} The Euler components.+ */+ 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;+ }+}+Pi.DEFAULT_ORDER = "XYZ";+class c0 {+ /**+ * Constructs a new layers instance, with membership+ * initially set to layer `0`.+ */+ constructor() {+ this.mask = 1;+ }+ /**+ * Sets membership to the given layer, and remove membership all other layers.+ *+ * @param {number} layer - The layer to set.+ */+ set(e) {+ this.mask = (1 << e | 0) >>> 0;+ }+ /**+ * Adds membership of the given layer.+ *+ * @param {number} layer - The layer to enable.+ */+ enable(e) {+ this.mask |= 1 << e | 0;+ }+ /**+ * Adds membership to all layers.+ */+ enableAll() {+ this.mask = -1;+ }+ /**+ * Toggles the membership of the given layer.+ *+ * @param {number} layer - The layer to toggle.+ */+ toggle(e) {+ this.mask ^= 1 << e | 0;+ }+ /**+ * Removes membership of the given layer.+ *+ * @param {number} layer - The layer to enable.+ */+ disable(e) {+ this.mask &= ~(1 << e | 0);+ }+ /**+ * Removes the membership from all layers.+ */+ disableAll() {+ this.mask = 0;+ }+ /**+ * Returns `true` if this and the given layers object have at least one+ * layer in common.+ *+ * @param {Layers} layers - The layers to test.+ * @return {boolean } Whether this and the given layers object have at least one layer in common or not.+ */+ test(e) {+ return (this.mask & e.mask) !== 0;+ }+ /**+ * Returns `true` if the given layer is enabled.+ *+ * @param {number} layer - The layer to test.+ * @return {boolean } Whether the given layer is enabled or not.+ */+ isEnabled(e) {+ return (this.mask & (1 << e | 0)) !== 0;+ }+}+let QE = 0;+const Cp = /* @__PURE__ */ new H(), Gr = /* @__PURE__ */ new Yn(), Vi = /* @__PURE__ */ new et(), xc = /* @__PURE__ */ new H(), Ja = /* @__PURE__ */ new H(), GE = /* @__PURE__ */ new H(), HE = /* @__PURE__ */ new Yn(), Sp = /* @__PURE__ */ new H(1, 0, 0), Ip = /* @__PURE__ */ new H(0, 1, 0), Mp = /* @__PURE__ */ new H(0, 0, 1), Bp = { type: "added" }, zE = { type: "removed" }, Hr = { type: "childadded", child: null }, Bh = { type: "childremoved", child: null };+class kt extends zs {+ /**+ * Constructs a new 3D object.+ */+ constructor() {+ super(), this.isObject3D = !0, Object.defineProperty(this, "id", { value: QE++ }), this.uuid = Ei(), this.name = "", this.type = "Object3D", this.parent = null, this.children = [], this.up = kt.DEFAULT_UP.clone();+ const e = new H(), t = new Pi(), n = new Yn(), s = new H(1, 1, 1);+ function r() {+ n.setFromEuler(t, !1);+ }+ function a() {+ t.setFromQuaternion(n, void 0, !1);+ }+ t._onChange(r), n._onChange(a), Object.defineProperties(this, {+ /**+ * Represents the object's local position.+ *+ * @name Object3D#position+ * @type {Vector3}+ * @default (0,0,0)+ */+ position: {+ configurable: !0,+ enumerable: !0,+ value: e+ },+ /**+ * Represents the object's local rotation as Euler angles, in radians.+ *+ * @name Object3D#rotation+ * @type {Euler}+ * @default (0,0,0)+ */+ rotation: {+ configurable: !0,+ enumerable: !0,+ value: t+ },+ /**+ * Represents the object's local rotation as Quaternions.+ *+ * @name Object3D#quaternion+ * @type {Quaternion}+ */+ quaternion: {+ configurable: !0,+ enumerable: !0,+ value: n+ },+ /**+ * Represents the object's local scale.+ *+ * @name Object3D#scale+ * @type {Vector3}+ * @default (1,1,1)+ */+ scale: {+ configurable: !0,+ enumerable: !0,+ value: s+ },+ /**+ * Represents the object's model-view matrix.+ *+ * @name Object3D#modelViewMatrix+ * @type {Matrix4}+ */+ modelViewMatrix: {+ value: new et()+ },+ /**+ * Represents the object's normal matrix.+ *+ * @name Object3D#normalMatrix+ * @type {Matrix3}+ */+ normalMatrix: {+ value: new rt()+ }+ }), this.matrix = new et(), this.matrixWorld = new et(), this.matrixAutoUpdate = kt.DEFAULT_MATRIX_AUTO_UPDATE, this.matrixWorldAutoUpdate = kt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE, this.matrixWorldNeedsUpdate = !1, this.layers = new c0(), 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.userData = {};+ }+ /**+ * A callback that is executed immediately before a 3D object is rendered to a shadow map.+ *+ * @param {Renderer|WebGLRenderer} renderer - The renderer.+ * @param {Object3D} object - The 3D object.+ * @param {Camera} camera - The camera that is used to render the scene.+ * @param {Camera} shadowCamera - The shadow camera.+ * @param {BufferGeometry} geometry - The 3D object's geometry.+ * @param {Material} depthMaterial - The depth material.+ * @param {Object} group - The geometry group data.+ */+ onBeforeShadow() {+ }+ /**+ * A callback that is executed immediately after a 3D object is rendered to a shadow map.+ *+ * @param {Renderer|WebGLRenderer} renderer - The renderer.+ * @param {Object3D} object - The 3D object.+ * @param {Camera} camera - The camera that is used to render the scene.+ * @param {Camera} shadowCamera - The shadow camera.+ * @param {BufferGeometry} geometry - The 3D object's geometry.+ * @param {Material} depthMaterial - The depth material.+ * @param {Object} group - The geometry group data.+ */+ onAfterShadow() {+ }+ /**+ * A callback that is executed immediately before a 3D object is rendered.+ *+ * @param {Renderer|WebGLRenderer} renderer - The renderer.+ * @param {Object3D} object - The 3D object.+ * @param {Camera} camera - The camera that is used to render the scene.+ * @param {BufferGeometry} geometry - The 3D object's geometry.+ * @param {Material} material - The 3D object's material.+ * @param {Object} group - The geometry group data.+ */+ onBeforeRender() {+ }+ /**+ * A callback that is executed immediately after a 3D object is rendered.+ *+ * @param {Renderer|WebGLRenderer} renderer - The renderer.+ * @param {Object3D} object - The 3D object.+ * @param {Camera} camera - The camera that is used to render the scene.+ * @param {BufferGeometry} geometry - The 3D object's geometry.+ * @param {Material} material - The 3D object's material.+ * @param {Object} group - The geometry group data.+ */+ onAfterRender() {+ }+ /**+ * Applies the given transformation matrix to the object and updates the object's position,+ * rotation and scale.+ *+ * @param {Matrix4} matrix - The transformation matrix.+ */+ applyMatrix4(e) {+ this.matrixAutoUpdate && this.updateMatrix(), this.matrix.premultiply(e), this.matrix.decompose(this.position, this.quaternion, this.scale);+ }+ /**+ * Applies a rotation represented by given the quaternion to the 3D object.+ *+ * @param {Quaternion} q - The quaternion.+ * @return {Object3D} A reference to this instance.+ */+ applyQuaternion(e) {+ return this.quaternion.premultiply(e), this;+ }+ /**+ * Sets the given rotation represented as an axis/angle couple to the 3D object.+ *+ * @param {Vector3} axis - The (normalized) axis vector.+ * @param {number} angle - The angle in radians.+ */+ setRotationFromAxisAngle(e, t) {+ this.quaternion.setFromAxisAngle(e, t);+ }+ /**+ * Sets the given rotation represented as Euler angles to the 3D object.+ *+ * @param {Euler} euler - The Euler angles.+ */+ setRotationFromEuler(e) {+ this.quaternion.setFromEuler(e, !0);+ }+ /**+ * Sets the given rotation represented as rotation matrix to the 3D object.+ *+ * @param {Matrix4} m - Although a 4x4 matrix is expected, the upper 3x3 portion must be+ * a pure rotation matrix (i.e, unscaled).+ */+ setRotationFromMatrix(e) {+ this.quaternion.setFromRotationMatrix(e);+ }+ /**+ * Sets the given rotation represented as a Quaternion to the 3D object.+ *+ * @param {Quaternion} q - The Quaternion+ */+ setRotationFromQuaternion(e) {+ this.quaternion.copy(e);+ }+ /**+ * Rotates the 3D object along an axis in local space.+ *+ * @param {Vector3} axis - The (normalized) axis vector.+ * @param {number} angle - The angle in radians.+ * @return {Object3D} A reference to this instance.+ */+ rotateOnAxis(e, t) {+ return Gr.setFromAxisAngle(e, t), this.quaternion.multiply(Gr), this;+ }+ /**+ * Rotates the 3D object along an axis in world space.+ *+ * @param {Vector3} axis - The (normalized) axis vector.+ * @param {number} angle - The angle in radians.+ * @return {Object3D} A reference to this instance.+ */+ rotateOnWorldAxis(e, t) {+ return Gr.setFromAxisAngle(e, t), this.quaternion.premultiply(Gr), this;+ }+ /**+ * Rotates the 3D object around its X axis in local space.+ *+ * @param {number} angle - The angle in radians.+ * @return {Object3D} A reference to this instance.+ */+ rotateX(e) {+ return this.rotateOnAxis(Sp, e);+ }+ /**+ * Rotates the 3D object around its Y axis in local space.+ *+ * @param {number} angle - The angle in radians.+ * @return {Object3D} A reference to this instance.+ */+ rotateY(e) {+ return this.rotateOnAxis(Ip, e);+ }+ /**+ * Rotates the 3D object around its Z axis in local space.+ *+ * @param {number} angle - The angle in radians.+ * @return {Object3D} A reference to this instance.+ */+ rotateZ(e) {+ return this.rotateOnAxis(Mp, e);+ }+ /**+ * Translate the 3D object by a distance along the given axis in local space.+ *+ * @param {Vector3} axis - The (normalized) axis vector.+ * @param {number} distance - The distance in world units.+ * @return {Object3D} A reference to this instance.+ */+ translateOnAxis(e, t) {+ return Cp.copy(e).applyQuaternion(this.quaternion), this.position.add(Cp.multiplyScalar(t)), this;+ }+ /**+ * Translate the 3D object by a distance along its X-axis in local space.+ *+ * @param {number} distance - The distance in world units.+ * @return {Object3D} A reference to this instance.+ */+ translateX(e) {+ return this.translateOnAxis(Sp, e);+ }+ /**+ * Translate the 3D object by a distance along its Y-axis in local space.+ *+ * @param {number} distance - The distance in world units.+ * @return {Object3D} A reference to this instance.+ */+ translateY(e) {+ return this.translateOnAxis(Ip, e);+ }+ /**+ * Translate the 3D object by a distance along its Z-axis in local space.+ *+ * @param {number} distance - The distance in world units.+ * @return {Object3D} A reference to this instance.+ */+ translateZ(e) {+ return this.translateOnAxis(Mp, e);+ }+ /**+ * Converts the given vector from this 3D object's local space to world space.+ *+ * @param {Vector3} vector - The vector to convert.+ * @return {Vector3} The converted vector.+ */+ localToWorld(e) {+ return this.updateWorldMatrix(!0, !1), e.applyMatrix4(this.matrixWorld);+ }+ /**+ * Converts the given vector from this 3D object's word space to local space.+ *+ * @param {Vector3} vector - The vector to convert.+ * @return {Vector3} The converted vector.+ */+ worldToLocal(e) {+ return this.updateWorldMatrix(!0, !1), e.applyMatrix4(Vi.copy(this.matrixWorld).invert());+ }+ /**+ * Rotates the object to face a point in world space.+ *+ * This method does not support objects having non-uniformly-scaled parent(s).+ *+ * @param {number|Vector3} x - The x coordinate in world space. Alternatively, a vector representing a position in world space+ * @param {number} [y] - The y coordinate in world space.+ * @param {number} [z] - The z coordinate in world space.+ */+ lookAt(e, t, n) {+ e.isVector3 ? xc.copy(e) : xc.set(e, t, n);+ const s = this.parent;+ this.updateWorldMatrix(!0, !1), Ja.setFromMatrixPosition(this.matrixWorld), this.isCamera || this.isLight ? Vi.lookAt(Ja, xc, this.up) : Vi.lookAt(xc, Ja, this.up), this.quaternion.setFromRotationMatrix(Vi), s && (Vi.extractRotation(s.matrixWorld), Gr.setFromRotationMatrix(Vi), this.quaternion.premultiply(Gr.invert()));+ }+ /**+ * Adds the given 3D object as a child to this 3D object. An arbitrary number of+ * objects may be added. Any current parent on an object passed in here will be+ * removed, since an object can have at most one parent.+ *+ * @fires Object3D#added+ * @fires Object3D#childadded+ * @param {Object3D} object - The 3D object to add.+ * @return {Object3D} A reference to this instance.+ */+ add(e) {+ if (arguments.length > 1) {+ for (let t = 0; t < arguments.length; t++)+ this.add(arguments[t]);+ return this;+ }+ return e === this ? (console.error("THREE.Object3D.add: object can't be added as a child of itself.", e), this) : (e && e.isObject3D ? (e.removeFromParent(), e.parent = this, this.children.push(e), e.dispatchEvent(Bp), Hr.child = e, this.dispatchEvent(Hr), Hr.child = null) : console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.", e), this);+ }+ /**+ * Removes the given 3D object as child from this 3D object.+ * An arbitrary number of objects may be removed.+ *+ * @fires Object3D#removed+ * @fires Object3D#childremoved+ * @param {Object3D} object - The 3D object to remove.+ * @return {Object3D} A reference to this instance.+ */+ remove(e) {+ if (arguments.length > 1) {+ for (let n = 0; n < arguments.length; n++)+ this.remove(arguments[n]);+ return this;+ }+ const t = this.children.indexOf(e);+ return t !== -1 && (e.parent = null, this.children.splice(t, 1), e.dispatchEvent(zE), Bh.child = e, this.dispatchEvent(Bh), Bh.child = null), this;+ }+ /**+ * Removes this 3D object from its current parent.+ *+ * @fires Object3D#removed+ * @fires Object3D#childremoved+ * @return {Object3D} A reference to this instance.+ */+ removeFromParent() {+ const e = this.parent;+ return e !== null && e.remove(this), this;+ }+ /**+ * Removes all child objects.+ *+ * @fires Object3D#removed+ * @fires Object3D#childremoved+ * @return {Object3D} A reference to this instance.+ */+ clear() {+ return this.remove(...this.children);+ }+ /**+ * Adds the given 3D object as a child of this 3D object, while maintaining the object's world+ * transform. This method does not support scene graphs having non-uniformly-scaled nodes(s).+ *+ * @fires Object3D#added+ * @fires Object3D#childadded+ * @param {Object3D} object - The 3D object to attach.+ * @return {Object3D} A reference to this instance.+ */+ attach(e) {+ return this.updateWorldMatrix(!0, !1), Vi.copy(this.matrixWorld).invert(), e.parent !== null && (e.parent.updateWorldMatrix(!0, !1), Vi.multiply(e.parent.matrixWorld)), e.applyMatrix4(Vi), e.removeFromParent(), e.parent = this, this.children.push(e), e.updateWorldMatrix(!1, !0), e.dispatchEvent(Bp), Hr.child = e, this.dispatchEvent(Hr), Hr.child = null, this;+ }+ /**+ * Searches through the 3D object and its children, starting with the 3D object+ * itself, and returns the first with a matching ID.+ *+ * @param {number} id - The id.+ * @return {Object3D|undefined} The found 3D object. Returns `undefined` if no 3D object has been found.+ */+ getObjectById(e) {+ return this.getObjectByProperty("id", e);+ }+ /**+ * Searches through the 3D object and its children, starting with the 3D object+ * itself, and returns the first with a matching name.+ *+ * @param {string} name - The name.+ * @return {Object3D|undefined} The found 3D object. Returns `undefined` if no 3D object has been found.+ */+ getObjectByName(e) {+ return this.getObjectByProperty("name", e);+ }+ /**+ * Searches through the 3D object and its children, starting with the 3D object+ * itself, and returns the first with a matching property value.+ *+ * @param {string} name - The name of the property.+ * @param {any} value - The value.+ * @return {Object3D|undefined} The found 3D object. Returns `undefined` if no 3D object has been found.+ */+ getObjectByProperty(e, t) {+ if (this[e] === t) return this;+ for (let n = 0, s = this.children.length; n < s; n++) {+ const a = this.children[n].getObjectByProperty(e, t);+ if (a !== void 0)+ return a;+ }+ }+ /**+ * Searches through the 3D object and its children, starting with the 3D object+ * itself, and returns all 3D objects with a matching property value.+ *+ * @param {string} name - The name of the property.+ * @param {any} value - The value.+ * @param {Array<Object3D>} result - The method stores the result in this array.+ * @return {Array<Object3D>} The found 3D objects.+ */+ getObjectsByProperty(e, t, n = []) {+ this[e] === t && n.push(this);+ const s = this.children;+ for (let r = 0, a = s.length; r < a; r++)+ s[r].getObjectsByProperty(e, t, n);+ return n;+ }+ /**+ * Returns a vector representing the position of the 3D object in world space.+ *+ * @param {Vector3} target - The target vector the result is stored to.+ * @return {Vector3} The 3D object's position in world space.+ */+ getWorldPosition(e) {+ return this.updateWorldMatrix(!0, !1), e.setFromMatrixPosition(this.matrixWorld);+ }+ /**+ * Returns a Quaternion representing the position of the 3D object in world space.+ *+ * @param {Quaternion} target - The target Quaternion the result is stored to.+ * @return {Quaternion} The 3D object's rotation in world space.+ */+ getWorldQuaternion(e) {+ return this.updateWorldMatrix(!0, !1), this.matrixWorld.decompose(Ja, e, GE), e;+ }+ /**+ * Returns a vector representing the scale of the 3D object in world space.+ *+ * @param {Vector3} target - The target vector the result is stored to.+ * @return {Vector3} The 3D object's scale in world space.+ */+ getWorldScale(e) {+ return this.updateWorldMatrix(!0, !1), this.matrixWorld.decompose(Ja, HE, e), e;+ }+ /**+ * Returns a vector representing the ("look") direction of the 3D object in world space.+ *+ * @param {Vector3} target - The target vector the result is stored to.+ * @return {Vector3} The 3D object's direction in world space.+ */+ getWorldDirection(e) {+ this.updateWorldMatrix(!0, !1);+ const t = this.matrixWorld.elements;+ return e.set(t[8], t[9], t[10]).normalize();+ }+ /**+ * Abstract method to get intersections between a casted ray and this+ * 3D object. Renderable 3D objects such as {@link Mesh}, {@link Line} or {@link Points}+ * implement this method in order to use raycasting.+ *+ * @abstract+ * @param {Raycaster} raycaster - The raycaster.+ * @param {Array<Object>} intersects - An array holding the result of the method.+ */+ raycast() {+ }+ /**+ * Executes the callback on this 3D object and all descendants.+ *+ * Note: Modifying the scene graph inside the callback is discouraged.+ *+ * @param {Function} callback - A callback function that allows to process the current 3D object.+ */+ traverse(e) {+ e(this);+ const t = this.children;+ for (let n = 0, s = t.length; n < s; n++)+ t[n].traverse(e);+ }+ /**+ * Like {@link Object3D#traverse}, but the callback will only be executed for visible 3D objects.+ * Descendants of invisible 3D objects are not traversed.+ *+ * Note: Modifying the scene graph inside the callback is discouraged.+ *+ * @param {Function} callback - A callback function that allows to process the current 3D object.+ */+ traverseVisible(e) {+ if (this.visible === !1) return;+ e(this);+ const t = this.children;+ for (let n = 0, s = t.length; n < s; n++)+ t[n].traverseVisible(e);+ }+ /**+ * Like {@link Object3D#traverse}, but the callback will only be executed for all ancestors.+ *+ * Note: Modifying the scene graph inside the callback is discouraged.+ *+ * @param {Function} callback - A callback function that allows to process the current 3D object.+ */+ traverseAncestors(e) {+ const t = this.parent;+ t !== null && (e(t), t.traverseAncestors(e));+ }+ /**+ * Updates the transformation matrix in local space by computing it from the current+ * position, rotation and scale values.+ */+ updateMatrix() {+ this.matrix.compose(this.position, this.quaternion, this.scale), this.matrixWorldNeedsUpdate = !0;+ }+ /**+ * Updates the transformation matrix in world space of this 3D objects and its descendants.+ *+ * To ensure correct results, this method also recomputes the 3D object's transformation matrix in+ * local space. The computation of the local and world matrix can be controlled with the+ * {@link Object3D#matrixAutoUpdate} and {@link Object3D#matrixWorldAutoUpdate} flags which are both+ * `true` by default. Set these flags to `false` if you need more control over the update matrix process.+ *+ * @param {boolean} [force=false] - When set to `true`, a recomputation of world matrices is forced even+ * when {@link Object3D#matrixWorldAutoUpdate} is set to `false`.+ */+ updateMatrixWorld(e) {+ this.matrixAutoUpdate && this.updateMatrix(), (this.matrixWorldNeedsUpdate || e) && (this.matrixWorldAutoUpdate === !0 && (this.parent === null ? this.matrixWorld.copy(this.matrix) : this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix)), this.matrixWorldNeedsUpdate = !1, e = !0);+ const t = this.children;+ for (let n = 0, s = t.length; n < s; n++)+ t[n].updateMatrixWorld(e);+ }+ /**+ * An alternative version of {@link Object3D#updateMatrixWorld} with more control over the+ * update of ancestor and descendant nodes.+ *+ * @param {boolean} [updateParents=false] Whether ancestor nodes should be updated or not.+ * @param {boolean} [updateChildren=false] Whether descendant nodes should be updated or not.+ */+ updateWorldMatrix(e, t) {+ const n = this.parent;+ if (e === !0 && n !== null && n.updateWorldMatrix(!0, !1), this.matrixAutoUpdate && this.updateMatrix(), this.matrixWorldAutoUpdate === !0 && (this.parent === null ? this.matrixWorld.copy(this.matrix) : this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix)), t === !0) {+ const s = this.children;+ for (let r = 0, a = s.length; r < a; r++)+ s[r].updateWorldMatrix(!1, !0);+ }+ }+ /**+ * Serializes the 3D object into JSON.+ *+ * @param {?(Object|string)} meta - An optional value holding meta information about the serialization.+ * @return {Object} A JSON object representing the serialized 3D object.+ * @see {@link ObjectLoader#parse}+ */+ toJSON(e) {+ const t = e === void 0 || typeof e == "string", n = {};+ t && (e = {+ geometries: {},+ materials: {},+ textures: {},+ images: {},+ shapes: {},+ skeletons: {},+ animations: {},+ nodes: {}+ }, n.metadata = {+ version: 4.6,+ type: "Object",+ generator: "Object3D.toJSON"+ });+ const s = {};+ s.uuid = this.uuid, s.type = this.type, this.name !== "" && (s.name = this.name), this.castShadow === !0 && (s.castShadow = !0), this.receiveShadow === !0 && (s.receiveShadow = !0), this.visible === !1 && (s.visible = !1), this.frustumCulled === !1 && (s.frustumCulled = !1), this.renderOrder !== 0 && (s.renderOrder = this.renderOrder), Object.keys(this.userData).length > 0 && (s.userData = this.userData), s.layers = this.layers.mask, s.matrix = this.matrix.toArray(), s.up = this.up.toArray(), this.matrixAutoUpdate === !1 && (s.matrixAutoUpdate = !1), this.isInstancedMesh && (s.type = "InstancedMesh", s.count = this.count, s.instanceMatrix = this.instanceMatrix.toJSON(), this.instanceColor !== null && (s.instanceColor = this.instanceColor.toJSON())), this.isBatchedMesh && (s.type = "BatchedMesh", s.perObjectFrustumCulled = this.perObjectFrustumCulled, s.sortObjects = this.sortObjects, s.drawRanges = this._drawRanges, s.reservedRanges = this._reservedRanges, s.geometryInfo = this._geometryInfo.map((o) => ({+ ...o,+ boundingBox: o.boundingBox ? {+ min: o.boundingBox.min.toArray(),+ max: o.boundingBox.max.toArray()+ } : void 0,+ boundingSphere: o.boundingSphere ? {+ radius: o.boundingSphere.radius,+ center: o.boundingSphere.center.toArray()+ } : void 0+ })), s.instanceInfo = this._instanceInfo.map((o) => ({ ...o })), s.availableInstanceIds = this._availableInstanceIds.slice(), s.availableGeometryIds = this._availableGeometryIds.slice(), s.nextIndexStart = this._nextIndexStart, s.nextVertexStart = this._nextVertexStart, s.geometryCount = this._geometryCount, s.maxInstanceCount = this._maxInstanceCount, s.maxVertexCount = this._maxVertexCount, s.maxIndexCount = this._maxIndexCount, s.geometryInitialized = this._geometryInitialized, s.matricesTexture = this._matricesTexture.toJSON(e), s.indirectTexture = this._indirectTexture.toJSON(e), this._colorsTexture !== null && (s.colorsTexture = this._colorsTexture.toJSON(e)), this.boundingSphere !== null && (s.boundingSphere = {+ center: this.boundingSphere.center.toArray(),+ radius: this.boundingSphere.radius+ }), this.boundingBox !== null && (s.boundingBox = {+ min: this.boundingBox.min.toArray(),+ max: this.boundingBox.max.toArray()+ }));+ function r(o, c) {+ return o[c.uuid] === void 0 && (o[c.uuid] = c.toJSON(e)), c.uuid;+ }+ if (this.isScene)+ this.background && (this.background.isColor ? s.background = this.background.toJSON() : this.background.isTexture && (s.background = this.background.toJSON(e).uuid)), this.environment && this.environment.isTexture && this.environment.isRenderTargetTexture !== !0 && (s.environment = this.environment.toJSON(e).uuid);+ else if (this.isMesh || this.isLine || this.isPoints) {+ s.geometry = r(e.geometries, this.geometry);+ const o = this.geometry.parameters;+ if (o !== void 0 && o.shapes !== void 0) {+ const c = o.shapes;+ if (Array.isArray(c))+ for (let l = 0, h = c.length; l < h; l++) {+ const u = c[l];+ r(e.shapes, u);+ }+ else+ r(e.shapes, c);+ }+ }+ if (this.isSkinnedMesh && (s.bindMode = this.bindMode, s.bindMatrix = this.bindMatrix.toArray(), this.skeleton !== void 0 && (r(e.skeletons, this.skeleton), s.skeleton = this.skeleton.uuid)), this.material !== void 0)+ if (Array.isArray(this.material)) {+ const o = [];+ for (let c = 0, l = this.material.length; c < l; c++)+ o.push(r(e.materials, this.material[c]));+ s.material = o;+ } else+ s.material = r(e.materials, this.material);+ if (this.children.length > 0) {+ s.children = [];+ for (let o = 0; o < this.children.length; o++)+ s.children.push(this.children[o].toJSON(e).object);+ }+ if (this.animations.length > 0) {+ s.animations = [];+ for (let o = 0; o < this.animations.length; o++) {+ const c = this.animations[o];+ s.animations.push(r(e.animations, c));+ }+ }+ if (t) {+ const o = a(e.geometries), c = a(e.materials), l = a(e.textures), h = a(e.images), u = a(e.shapes), d = a(e.skeletons), f = a(e.animations), m = a(e.nodes);+ o.length > 0 && (n.geometries = o), c.length > 0 && (n.materials = c), l.length > 0 && (n.textures = l), h.length > 0 && (n.images = h), u.length > 0 && (n.shapes = u), d.length > 0 && (n.skeletons = d), f.length > 0 && (n.animations = f), m.length > 0 && (n.nodes = m);+ }+ return n.object = s, n;+ function a(o) {+ const c = [];+ for (const l in o) {+ const h = o[l];+ delete h.metadata, c.push(h);+ }+ return c;+ }+ }+ /**+ * Returns a new 3D object with copied values from this instance.+ *+ * @param {boolean} [recursive=true] - When set to `true`, descendants of the 3D object are also cloned.+ * @return {Object3D} A clone of this instance.+ */+ clone(e) {+ return new this.constructor().copy(this, e);+ }+ /**+ * Copies the values of the given 3D object to this instance.+ *+ * @param {Object3D} source - The 3D object to copy.+ * @param {boolean} [recursive=true] - When set to `true`, descendants of the 3D object are cloned.+ * @return {Object3D} A reference to this instance.+ */+ 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.matrix.copy(e.matrix), this.matrixWorld.copy(e.matrixWorld), this.matrixAutoUpdate = e.matrixAutoUpdate, this.matrixWorldAutoUpdate = e.matrixWorldAutoUpdate, this.matrixWorldNeedsUpdate = e.matrixWorldNeedsUpdate, this.layers.mask = e.layers.mask, this.visible = e.visible, this.castShadow = e.castShadow, this.receiveShadow = e.receiveShadow, this.frustumCulled = e.frustumCulled, this.renderOrder = e.renderOrder, this.animations = e.animations.slice(), this.userData = JSON.parse(JSON.stringify(e.userData)), t === !0)+ for (let n = 0; n < e.children.length; n++) {+ const s = e.children[n];+ this.add(s.clone());+ }+ return this;+ }+}+kt.DEFAULT_UP = /* @__PURE__ */ new H(0, 1, 0);+kt.DEFAULT_MATRIX_AUTO_UPDATE = !0;+kt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE = !0;+const hi = /* @__PURE__ */ new H(), Wi = /* @__PURE__ */ new H(), Th = /* @__PURE__ */ new H(), qi = /* @__PURE__ */ new H(), zr = /* @__PURE__ */ new H(), Vr = /* @__PURE__ */ new H(), Tp = /* @__PURE__ */ new H(), Rh = /* @__PURE__ */ new H(), Nh = /* @__PURE__ */ new H(), Fh = /* @__PURE__ */ new H(), Dh = /* @__PURE__ */ new wt(), Lh = /* @__PURE__ */ new wt(), Ph = /* @__PURE__ */ new wt();+class bi {+ /**+ * Constructs a new triangle.+ *+ * @param {Vector3} [a=(0,0,0)] - The first corner of the triangle.+ * @param {Vector3} [b=(0,0,0)] - The second corner of the triangle.+ * @param {Vector3} [c=(0,0,0)] - The third corner of the triangle.+ */+ constructor(e = new H(), t = new H(), n = new H()) {+ this.a = e, this.b = t, this.c = n;+ }+ /**+ * Computes the normal vector of a triangle.+ *+ * @param {Vector3} a - The first corner of the triangle.+ * @param {Vector3} b - The second corner of the triangle.+ * @param {Vector3} c - The third corner of the triangle.+ * @param {Vector3} target - The target vector that is used to store the method's result.+ * @return {Vector3} The triangle's normal.+ */+ static getNormal(e, t, n, s) {+ s.subVectors(n, t), hi.subVectors(e, t), s.cross(hi);+ const r = s.lengthSq();+ return r > 0 ? s.multiplyScalar(1 / Math.sqrt(r)) : s.set(0, 0, 0);+ }+ /**+ * Computes a barycentric coordinates from the given vector.+ * Returns `null` if the triangle is degenerate.+ *+ * @param {Vector3} point - A point in 3D space.+ * @param {Vector3} a - The first corner of the triangle.+ * @param {Vector3} b - The second corner of the triangle.+ * @param {Vector3} c - The third corner of the triangle.+ * @param {Vector3} target - The target vector that is used to store the method's result.+ * @return {?Vector3} The barycentric coordinates for the given point+ */+ static getBarycoord(e, t, n, s, r) {+ hi.subVectors(s, t), Wi.subVectors(n, t), Th.subVectors(e, t);+ const a = hi.dot(hi), o = hi.dot(Wi), c = hi.dot(Th), l = Wi.dot(Wi), h = Wi.dot(Th), u = a * l - o * o;+ if (u === 0)+ return r.set(0, 0, 0), null;+ const d = 1 / u, f = (l * c - o * h) * d, m = (a * h - o * c) * d;+ return r.set(1 - f - m, m, f);+ }+ /**+ * Returns `true` if the given point, when projected onto the plane of the+ * triangle, lies within the triangle.+ *+ * @param {Vector3} point - The point in 3D space to test.+ * @param {Vector3} a - The first corner of the triangle.+ * @param {Vector3} b - The second corner of the triangle.+ * @param {Vector3} c - The third corner of the triangle.+ * @return {boolean} Whether the given point, when projected onto the plane of the+ * triangle, lies within the triangle or not.+ */+ static containsPoint(e, t, n, s) {+ return this.getBarycoord(e, t, n, s, qi) === null ? !1 : qi.x >= 0 && qi.y >= 0 && qi.x + qi.y <= 1;+ }+ /**+ * Computes the value barycentrically interpolated for the given point on the+ * triangle. Returns `null` if the triangle is degenerate.+ *+ * @param {Vector3} point - Position of interpolated point.+ * @param {Vector3} p1 - The first corner of the triangle.+ * @param {Vector3} p2 - The second corner of the triangle.+ * @param {Vector3} p3 - The third corner of the triangle.+ * @param {Vector3} v1 - Value to interpolate of first vertex.+ * @param {Vector3} v2 - Value to interpolate of second vertex.+ * @param {Vector3} v3 - Value to interpolate of third vertex.+ * @param {Vector3} target - The target vector that is used to store the method's result.+ * @return {?Vector3} The interpolated value.+ */+ static getInterpolation(e, t, n, s, r, a, o, c) {+ return this.getBarycoord(e, t, n, s, qi) === null ? (c.x = 0, c.y = 0, "z" in c && (c.z = 0), "w" in c && (c.w = 0), null) : (c.setScalar(0), c.addScaledVector(r, qi.x), c.addScaledVector(a, qi.y), c.addScaledVector(o, qi.z), c);+ }+ /**+ * Computes the value barycentrically interpolated for the given attribute and indices.+ *+ * @param {BufferAttribute} attr - The attribute to interpolate.+ * @param {number} i1 - Index of first vertex.+ * @param {number} i2 - Index of second vertex.+ * @param {number} i3 - Index of third vertex.+ * @param {Vector3} barycoord - The barycoordinate value to use to interpolate.+ * @param {Vector3} target - The target vector that is used to store the method's result.+ * @return {Vector3} The interpolated attribute value.+ */+ static getInterpolatedAttribute(e, t, n, s, r, a) {+ return Dh.setScalar(0), Lh.setScalar(0), Ph.setScalar(0), Dh.fromBufferAttribute(e, t), Lh.fromBufferAttribute(e, n), Ph.fromBufferAttribute(e, s), a.setScalar(0), a.addScaledVector(Dh, r.x), a.addScaledVector(Lh, r.y), a.addScaledVector(Ph, r.z), a;+ }+ /**+ * Returns `true` if the triangle is oriented towards the given direction.+ *+ * @param {Vector3} a - The first corner of the triangle.+ * @param {Vector3} b - The second corner of the triangle.+ * @param {Vector3} c - The third corner of the triangle.+ * @param {Vector3} direction - The (normalized) direction vector.+ * @return {boolean} Whether the triangle is oriented towards the given direction or not.+ */+ static isFrontFacing(e, t, n, s) {+ return hi.subVectors(n, t), Wi.subVectors(e, t), hi.cross(Wi).dot(s) < 0;+ }+ /**+ * Sets the triangle's vertices by copying the given values.+ *+ * @param {Vector3} a - The first corner of the triangle.+ * @param {Vector3} b - The second corner of the triangle.+ * @param {Vector3} c - The third corner of the triangle.+ * @return {Triangle} A reference to this triangle.+ */+ set(e, t, n) {+ return this.a.copy(e), this.b.copy(t), this.c.copy(n), this;+ }+ /**+ * Sets the triangle's vertices by copying the given array values.+ *+ * @param {Array<Vector3>} points - An array with 3D points.+ * @param {number} i0 - The array index representing the first corner of the triangle.+ * @param {number} i1 - The array index representing the second corner of the triangle.+ * @param {number} i2 - The array index representing the third corner of the triangle.+ * @return {Triangle} A reference to this triangle.+ */+ setFromPointsAndIndices(e, t, n, s) {+ return this.a.copy(e[t]), this.b.copy(e[n]), this.c.copy(e[s]), this;+ }+ /**+ * Sets the triangle's vertices by copying the given attribute values.+ *+ * @param {BufferAttribute} attribute - A buffer attribute with 3D points data.+ * @param {number} i0 - The attribute index representing the first corner of the triangle.+ * @param {number} i1 - The attribute index representing the second corner of the triangle.+ * @param {number} i2 - The attribute index representing the third corner of the triangle.+ * @return {Triangle} A reference to this triangle.+ */+ setFromAttributeAndIndices(e, t, n, s) {+ return this.a.fromBufferAttribute(e, t), this.b.fromBufferAttribute(e, n), this.c.fromBufferAttribute(e, s), this;+ }+ /**+ * Returns a new triangle with copied values from this instance.+ *+ * @return {Triangle} A clone of this instance.+ */+ clone() {+ return new this.constructor().copy(this);+ }+ /**+ * Copies the values of the given triangle to this instance.+ *+ * @param {Triangle} triangle - The triangle to copy.+ * @return {Triangle} A reference to this triangle.+ */+ copy(e) {+ return this.a.copy(e.a), this.b.copy(e.b), this.c.copy(e.c), this;+ }+ /**+ * Computes the area of the triangle.+ *+ * @return {number} The triangle's area.+ */+ getArea() {+ return hi.subVectors(this.c, this.b), Wi.subVectors(this.a, this.b), hi.cross(Wi).length() * 0.5;+ }+ /**+ * Computes the midpoint of the triangle.+ *+ * @param {Vector3} target - The target vector that is used to store the method's result.+ * @return {Vector3} The triangle's midpoint.+ */+ getMidpoint(e) {+ return e.addVectors(this.a, this.b).add(this.c).multiplyScalar(1 / 3);+ }+ /**+ * Computes the normal of the triangle.+ *+ * @param {Vector3} target - The target vector that is used to store the method's result.+ * @return {Vector3} The triangle's normal.+ */+ getNormal(e) {+ return bi.getNormal(this.a, this.b, this.c, e);+ }+ /**+ * Computes a plane the triangle lies within.+ *+ * @param {Plane} target - The target vector that is used to store the method's result.+ * @return {Plane} The plane the triangle lies within.+ */+ getPlane(e) {+ return e.setFromCoplanarPoints(this.a, this.b, this.c);+ }+ /**+ * Computes a barycentric coordinates from the given vector.+ * Returns `null` if the triangle is degenerate.+ *+ * @param {Vector3} point - A point in 3D space.+ * @param {Vector3} target - The target vector that is used to store the method's result.+ * @return {?Vector3} The barycentric coordinates for the given point+ */+ getBarycoord(e, t) {+ return bi.getBarycoord(e, this.a, this.b, this.c, t);+ }+ /**+ * Computes the value barycentrically interpolated for the given point on the+ * triangle. Returns `null` if the triangle is degenerate.+ *+ * @param {Vector3} point - Position of interpolated point.+ * @param {Vector3} v1 - Value to interpolate of first vertex.+ * @param {Vector3} v2 - Value to interpolate of second vertex.+ * @param {Vector3} v3 - Value to interpolate of third vertex.+ * @param {Vector3} target - The target vector that is used to store the method's result.+ * @return {?Vector3} The interpolated value.+ */+ getInterpolation(e, t, n, s, r) {+ return bi.getInterpolation(e, this.a, this.b, this.c, t, n, s, r);+ }+ /**+ * Returns `true` if the given point, when projected onto the plane of the+ * triangle, lies within the triangle.+ *+ * @param {Vector3} point - The point in 3D space to test.+ * @return {boolean} Whether the given point, when projected onto the plane of the+ * triangle, lies within the triangle or not.+ */+ containsPoint(e) {+ return bi.containsPoint(e, this.a, this.b, this.c);+ }+ /**+ * Returns `true` if the triangle is oriented towards the given direction.+ *+ * @param {Vector3} direction - The (normalized) direction vector.+ * @return {boolean} Whether the triangle is oriented towards the given direction or not.+ */+ isFrontFacing(e) {+ return bi.isFrontFacing(this.a, this.b, this.c, e);+ }+ /**+ * Returns `true` if this triangle intersects with the given box.+ *+ * @param {Box3} box - The box to intersect.+ * @return {boolean} Whether this triangle intersects with the given box or not.+ */+ intersectsBox(e) {+ return e.intersectsTriangle(this);+ }+ /**+ * Returns the closest point on the triangle to the given point.+ *+ * @param {Vector3} p - The point to compute the closest point for.+ * @param {Vector3} target - The target vector that is used to store the method's result.+ * @return {Vector3} The closest point on the triangle.+ */+ closestPointToPoint(e, t) {+ const n = this.a, s = this.b, r = this.c;+ let a, o;+ zr.subVectors(s, n), Vr.subVectors(r, n), Rh.subVectors(e, n);+ const c = zr.dot(Rh), l = Vr.dot(Rh);+ if (c <= 0 && l <= 0)+ return t.copy(n);+ Nh.subVectors(e, s);+ const h = zr.dot(Nh), u = Vr.dot(Nh);+ if (h >= 0 && u <= h)+ return t.copy(s);+ const d = c * u - h * l;+ if (d <= 0 && c >= 0 && h <= 0)+ return a = c / (c - h), t.copy(n).addScaledVector(zr, a);+ Fh.subVectors(e, r);+ const f = zr.dot(Fh), m = Vr.dot(Fh);+ if (m >= 0 && f <= m)+ return t.copy(r);+ const A = f * l - c * m;+ if (A <= 0 && l >= 0 && m <= 0)+ return o = l / (l - m), t.copy(n).addScaledVector(Vr, o);+ const g = h * m - f * u;+ if (g <= 0 && u - h >= 0 && f - m >= 0)+ return Tp.subVectors(r, s), o = (u - h) / (u - h + (f - m)), t.copy(s).addScaledVector(Tp, o);+ const p = 1 / (g + A + d);+ return a = A * p, o = d * p, t.copy(n).addScaledVector(zr, a).addScaledVector(Vr, o);+ }+ /**+ * Returns `true` if this triangle is equal with the given one.+ *+ * @param {Triangle} triangle - The triangle to test for equality.+ * @return {boolean} Whether this triangle is equal with the given one.+ */+ equals(e) {+ return e.a.equals(this.a) && e.b.equals(this.b) && e.c.equals(this.c);+ }+}+const l0 = {+ 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+}, Es = { h: 0, s: 0, l: 0 }, _c = { h: 0, s: 0, l: 0 };+function kh(i, e, t) {+ return t < 0 && (t += 1), t > 1 && (t -= 1), t < 1 / 6 ? i + (e - i) * 6 * t : t < 1 / 2 ? e : t < 2 / 3 ? i + (e - i) * 6 * (2 / 3 - t) : i;+}+let je = class {+ /**+ * Constructs a new color.+ *+ * Note that standard method of specifying color in three.js is with a hexadecimal triplet,+ * and that method is used throughout the rest of the documentation.+ *+ * @param {(number|string|Color)} [r] - The red component of the color. If `g` and `b` are+ * not provided, it can be hexadecimal triplet, a CSS-style string or another `Color` instance.+ * @param {number} [g] - The green component.+ * @param {number} [b] - The blue component.+ */+ constructor(e, t, n) {+ return this.isColor = !0, this.r = 1, this.g = 1, this.b = 1, this.set(e, t, n);+ }+ /**+ * Sets the colors's components from the given values.+ *+ * @param {(number|string|Color)} [r] - The red component of the color. If `g` and `b` are+ * not provided, it can be hexadecimal triplet, a CSS-style string or another `Color` instance.+ * @param {number} [g] - The green component.+ * @param {number} [b] - The blue component.+ * @return {Color} A reference to this color.+ */+ set(e, t, n) {+ if (t === void 0 && n === void 0) {+ const s = e;+ s && s.isColor ? this.copy(s) : typeof s == "number" ? this.setHex(s) : typeof s == "string" && this.setStyle(s);+ } else+ this.setRGB(e, t, n);+ return this;+ }+ /**+ * Sets the colors's components to the given scalar value.+ *+ * @param {number} scalar - The scalar value.+ * @return {Color} A reference to this color.+ */+ setScalar(e) {+ return this.r = e, this.g = e, this.b = e, this;+ }+ /**+ * Sets this color from a hexadecimal value.+ *+ * @param {number} hex - The hexadecimal value.+ * @param {string} [colorSpace=SRGBColorSpace] - The color space.+ * @return {Color} A reference to this color.+ */+ setHex(e, t = Kt) {+ return e = Math.floor(e), this.r = (e >> 16 & 255) / 255, this.g = (e >> 8 & 255) / 255, this.b = (e & 255) / 255, mt.toWorkingColorSpace(this, t), this;+ }+ /**+ * Sets this color from RGB values.+ *+ * @param {number} r - Red channel value between `0.0` and `1.0`.+ * @param {number} g - Green channel value between `0.0` and `1.0`.+ * @param {number} b - Blue channel value between `0.0` and `1.0`.+ * @param {string} [colorSpace=ColorManagement.workingColorSpace] - The color space.+ * @return {Color} A reference to this color.+ */+ setRGB(e, t, n, s = mt.workingColorSpace) {+ return this.r = e, this.g = t, this.b = n, mt.toWorkingColorSpace(this, s), this;+ }+ /**+ * Sets this color from RGB values.+ *+ * @param {number} h - Hue value between `0.0` and `1.0`.+ * @param {number} s - Saturation value between `0.0` and `1.0`.+ * @param {number} l - Lightness value between `0.0` and `1.0`.+ * @param {string} [colorSpace=ColorManagement.workingColorSpace] - The color space.+ * @return {Color} A reference to this color.+ */+ setHSL(e, t, n, s = mt.workingColorSpace) {+ if (e = _f(e, 1), t = ct(t, 0, 1), n = ct(n, 0, 1), t === 0)+ this.r = this.g = this.b = n;+ else {+ const r = n <= 0.5 ? n * (1 + t) : n + t - n * t, a = 2 * n - r;+ this.r = kh(a, r, e + 1 / 3), this.g = kh(a, r, e), this.b = kh(a, r, e - 1 / 3);+ }+ return mt.toWorkingColorSpace(this, s), this;+ }+ /**+ * Sets this color from a CSS-style string. For example, `rgb(250, 0,0)`,+ * `rgb(100%, 0%, 0%)`, `hsl(0, 100%, 50%)`, `#ff0000`, `#f00`, or `red` ( or+ * any [X11 color name]{@link https://en.wikipedia.org/wiki/X11_color_names#Color_name_chart} -+ * all 140 color names are supported).+ *+ * @param {string} style - Color as a CSS-style string.+ * @param {string} [colorSpace=SRGBColorSpace] - The color space.+ * @return {Color} A reference to this color.+ */+ setStyle(e, t = Kt) {+ function n(r) {+ r !== void 0 && parseFloat(r) < 1 && console.warn("THREE.Color: Alpha component of " + e + " will be ignored.");+ }+ let s;+ if (s = /^(\w+)\(([^\)]*)\)/.exec(e)) {+ let r;+ const a = s[1], o = s[2];+ switch (a) {+ case "rgb":+ case "rgba":+ if (r = /^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))+ return n(r[4]), this.setRGB(+ Math.min(255, parseInt(r[1], 10)) / 255,+ Math.min(255, parseInt(r[2], 10)) / 255,+ Math.min(255, parseInt(r[3], 10)) / 255,+ t+ );+ if (r = /^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))+ return n(r[4]), this.setRGB(+ Math.min(100, parseInt(r[1], 10)) / 100,+ Math.min(100, parseInt(r[2], 10)) / 100,+ Math.min(100, parseInt(r[3], 10)) / 100,+ t+ );+ break;+ case "hsl":+ case "hsla":+ if (r = /^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))+ return n(r[4]), this.setHSL(+ parseFloat(r[1]) / 360,+ parseFloat(r[2]) / 100,+ parseFloat(r[3]) / 100,+ t+ );+ break;+ default:+ console.warn("THREE.Color: Unknown color model " + e);+ }+ } else if (s = /^\#([A-Fa-f\d]+)$/.exec(e)) {+ const r = s[1], a = r.length;+ if (a === 3)+ return this.setRGB(+ parseInt(r.charAt(0), 16) / 15,+ parseInt(r.charAt(1), 16) / 15,+ parseInt(r.charAt(2), 16) / 15,+ t+ );+ if (a === 6)+ return this.setHex(parseInt(r, 16), t);+ console.warn("THREE.Color: Invalid hex color " + e);+ } else if (e && e.length > 0)+ return this.setColorName(e, t);+ return this;+ }+ /**+ * Sets this color from a color name. Faster than {@link Color#setStyle} if+ * you don't need the other CSS-style formats.+ *+ * For convenience, the list of names is exposed in `Color.NAMES` as a hash.+ * ```js+ * Color.NAMES.aliceblue // returns 0xF0F8FF+ * ```+ *+ * @param {string} style - The color name.+ * @param {string} [colorSpace=SRGBColorSpace] - The color space.+ * @return {Color} A reference to this color.+ */+ setColorName(e, t = Kt) {+ const n = l0[e.toLowerCase()];+ return n !== void 0 ? this.setHex(n, t) : console.warn("THREE.Color: Unknown color " + e), this;+ }+ /**+ * Returns a new color with copied values from this instance.+ *+ * @return {Color} A clone of this instance.+ */+ clone() {+ return new this.constructor(this.r, this.g, this.b);+ }+ /**+ * Copies the values of the given color to this instance.+ *+ * @param {Color} color - The color to copy.+ * @return {Color} A reference to this color.+ */+ copy(e) {+ return this.r = e.r, this.g = e.g, this.b = e.b, this;+ }+ /**+ * Copies the given color into this color, and then converts this color from+ * `SRGBColorSpace` to `LinearSRGBColorSpace`.+ *+ * @param {Color} color - The color to copy/convert.+ * @return {Color} A reference to this color.+ */+ copySRGBToLinear(e) {+ return this.r = os(e.r), this.g = os(e.g), this.b = os(e.b), this;+ }+ /**+ * Copies the given color into this color, and then converts this color from+ * `LinearSRGBColorSpace` to `SRGBColorSpace`.+ *+ * @param {Color} color - The color to copy/convert.+ * @return {Color} A reference to this color.+ */+ copyLinearToSRGB(e) {+ return this.r = pa(e.r), this.g = pa(e.g), this.b = pa(e.b), this;+ }+ /**+ * Converts this color from `SRGBColorSpace` to `LinearSRGBColorSpace`.+ *+ * @return {Color} A reference to this color.+ */+ convertSRGBToLinear() {+ return this.copySRGBToLinear(this), this;+ }+ /**+ * Converts this color from `LinearSRGBColorSpace` to `SRGBColorSpace`.+ *+ * @return {Color} A reference to this color.+ */+ convertLinearToSRGB() {+ return this.copyLinearToSRGB(this), this;+ }+ /**+ * Returns the hexadecimal value of this color.+ *+ * @param {string} [colorSpace=SRGBColorSpace] - The color space.+ * @return {number} The hexadecimal value.+ */+ getHex(e = Kt) {+ return mt.fromWorkingColorSpace(wn.copy(this), e), Math.round(ct(wn.r * 255, 0, 255)) * 65536 + Math.round(ct(wn.g * 255, 0, 255)) * 256 + Math.round(ct(wn.b * 255, 0, 255));+ }+ /**+ * Returns the hexadecimal value of this color as a string (for example, 'FFFFFF').+ *+ * @param {string} [colorSpace=SRGBColorSpace] - The color space.+ * @return {string} The hexadecimal value as a string.+ */+ getHexString(e = Kt) {+ return ("000000" + this.getHex(e).toString(16)).slice(-6);+ }+ /**+ * Converts the colors RGB values into the HSL format and stores them into the+ * given target object.+ *+ * @param {{h:number,s:number,l:number}} target - The target object that is used to store the method's result.+ * @param {string} [colorSpace=ColorManagement.workingColorSpace] - The color space.+ * @return {{h:number,s:number,l:number}} The HSL representation of this color.+ */+ getHSL(e, t = mt.workingColorSpace) {+ mt.fromWorkingColorSpace(wn.copy(this), t);+ const n = wn.r, s = wn.g, r = wn.b, a = Math.max(n, s, r), o = Math.min(n, s, r);+ let c, l;+ const h = (o + a) / 2;+ if (o === a)+ c = 0, l = 0;+ else {+ const u = a - o;+ switch (l = h <= 0.5 ? u / (a + o) : u / (2 - a - o), a) {+ case n:+ c = (s - r) / u + (s < r ? 6 : 0);+ break;+ case s:+ c = (r - n) / u + 2;+ break;+ case r:+ c = (n - s) / u + 4;+ break;+ }+ c /= 6;+ }+ return e.h = c, e.s = l, e.l = h, e;+ }+ /**+ * Returns the RGB values of this color and stores them into the given target object.+ *+ * @param {Color} target - The target color that is used to store the method's result.+ * @param {string} [colorSpace=ColorManagement.workingColorSpace] - The color space.+ * @return {Color} The RGB representation of this color.+ */+ getRGB(e, t = mt.workingColorSpace) {+ return mt.fromWorkingColorSpace(wn.copy(this), t), e.r = wn.r, e.g = wn.g, e.b = wn.b, e;+ }+ /**+ * Returns the value of this color as a CSS style string. Example: `rgb(255,0,0)`.+ *+ * @param {string} [colorSpace=SRGBColorSpace] - The color space.+ * @return {string} The CSS representation of this color.+ */+ getStyle(e = Kt) {+ mt.fromWorkingColorSpace(wn.copy(this), e);+ const t = wn.r, n = wn.g, s = wn.b;+ return e !== Kt ? `color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${s.toFixed(3)})` : `rgb(${Math.round(t * 255)},${Math.round(n * 255)},${Math.round(s * 255)})`;+ }+ /**+ * Adds the given HSL values to this color's values.+ * Internally, this converts the color's RGB values to HSL, adds HSL+ * and then converts the color back to RGB.+ *+ * @param {number} h - Hue value between `0.0` and `1.0`.+ * @param {number} s - Saturation value between `0.0` and `1.0`.+ * @param {number} l - Lightness value between `0.0` and `1.0`.+ * @return {Color} A reference to this color.+ */+ offsetHSL(e, t, n) {+ return this.getHSL(Es), this.setHSL(Es.h + e, Es.s + t, Es.l + n);+ }+ /**+ * Adds the RGB values of the given color to the RGB values of this color.+ *+ * @param {Color} color - The color to add.+ * @return {Color} A reference to this color.+ */+ add(e) {+ return this.r += e.r, this.g += e.g, this.b += e.b, this;+ }+ /**+ * Adds the RGB values of the given colors and stores the result in this instance.+ *+ * @param {Color} color1 - The first color.+ * @param {Color} color2 - The second color.+ * @return {Color} A reference to this color.+ */+ addColors(e, t) {+ return this.r = e.r + t.r, this.g = e.g + t.g, this.b = e.b + t.b, this;+ }+ /**+ * Adds the given scalar value to the RGB values of this color.+ *+ * @param {number} s - The scalar to add.+ * @return {Color} A reference to this color.+ */+ addScalar(e) {+ return this.r += e, this.g += e, this.b += e, this;+ }+ /**+ * Subtracts the RGB values of the given color from the RGB values of this color.+ *+ * @param {Color} color - The color to subtract.+ * @return {Color} A reference to this color.+ */+ 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;+ }+ /**+ * Multiplies the RGB values of the given color with the RGB values of this color.+ *+ * @param {Color} color - The color to multiply.+ * @return {Color} A reference to this color.+ */+ multiply(e) {+ return this.r *= e.r, this.g *= e.g, this.b *= e.b, this;+ }+ /**+ * Multiplies the given scalar value with the RGB values of this color.+ *+ * @param {number} s - The scalar to multiply.+ * @return {Color} A reference to this color.+ */+ multiplyScalar(e) {+ return this.r *= e, this.g *= e, this.b *= e, this;+ }+ /**+ * Linearly interpolates this color's RGB values toward the RGB values of the+ * given color. The alpha argument can be thought of as the ratio between+ * the two colors, where `0.0` is this color and `1.0` is the first argument.+ *+ * @param {Color} color - The color to converge on.+ * @param {number} alpha - The interpolation factor in the closed interval `[0,1]`.+ * @return {Color} A reference to this color.+ */+ 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;+ }+ /**+ * Linearly interpolates between the given colors and stores the result in this instance.+ * The alpha argument can be thought of as the ratio between the two colors, where `0.0`+ * is the first and `1.0` is the second color.+ *+ * @param {Color} color1 - The first color.+ * @param {Color} color2 - The second color.+ * @param {number} alpha - The interpolation factor in the closed interval `[0,1]`.+ * @return {Color} A reference to this color.+ */+ 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;+ }+ /**+ * Linearly interpolates this color's HSL values toward the HSL values of the+ * given color. It differs from {@link Color#lerp} by not interpolating straight+ * from one color to the other, but instead going through all the hues in between+ * those two colors. The alpha argument can be thought of as the ratio between+ * the two colors, where 0.0 is this color and 1.0 is the first argument.+ *+ * @param {Color} color - The color to converge on.+ * @param {number} alpha - The interpolation factor in the closed interval `[0,1]`.+ * @return {Color} A reference to this color.+ */+ lerpHSL(e, t) {+ this.getHSL(Es), e.getHSL(_c);+ const n = wo(Es.h, _c.h, t), s = wo(Es.s, _c.s, t), r = wo(Es.l, _c.l, t);+ return this.setHSL(n, s, r), this;+ }+ /**+ * Sets the color's RGB components from the given 3D vector.+ *+ * @param {Vector3} v - The vector to set.+ * @return {Color} A reference to this color.+ */+ setFromVector3(e) {+ return this.r = e.x, this.g = e.y, this.b = e.z, this;+ }+ /**+ * Transforms this color with the given 3x3 matrix.+ *+ * @param {Matrix3} m - The matrix.+ * @return {Color} A reference to this color.+ */+ applyMatrix3(e) {+ const t = this.r, n = this.g, s = this.b, r = e.elements;+ return this.r = r[0] * t + r[3] * n + r[6] * s, this.g = r[1] * t + r[4] * n + r[7] * s, this.b = r[2] * t + r[5] * n + r[8] * s, this;+ }+ /**+ * Returns `true` if this color is equal with the given one.+ *+ * @param {Color} c - The color to test for equality.+ * @return {boolean} Whether this bounding color is equal with the given one.+ */+ equals(e) {+ return e.r === this.r && e.g === this.g && e.b === this.b;+ }+ /**+ * Sets this color's RGB components from the given array.+ *+ * @param {Array<number>} array - An array holding the RGB values.+ * @param {number} [offset=0] - The offset into the array.+ * @return {Color} A reference to this color.+ */+ fromArray(e, t = 0) {+ return this.r = e[t], this.g = e[t + 1], this.b = e[t + 2], this;+ }+ /**+ * Writes the RGB components of this color to the given array. If no array is provided,+ * the method returns a new instance.+ *+ * @param {Array<number>} [array=[]] - The target array holding the color components.+ * @param {number} [offset=0] - Index of the first element in the array.+ * @return {Array<number>} The color components.+ */+ toArray(e = [], t = 0) {+ return e[t] = this.r, e[t + 1] = this.g, e[t + 2] = this.b, e;+ }+ /**+ * Sets the components of this color from the given buffer attribute.+ *+ * @param {BufferAttribute} attribute - The buffer attribute holding color data.+ * @param {number} index - The index into the attribute.+ * @return {Color} A reference to this color.+ */+ fromBufferAttribute(e, t) {+ return this.r = e.getX(t), this.g = e.getY(t), this.b = e.getZ(t), this;+ }+ /**+ * This methods defines the serialization result of this class. Returns the color+ * as a hexadecimal value.+ *+ * @return {number} The hexadecimal value.+ */+ toJSON() {+ return this.getHex();+ }+ *[Symbol.iterator]() {+ yield this.r, yield this.g, yield this.b;+ }+};+const wn = /* @__PURE__ */ new je();+je.NAMES = l0;+let VE = 0;+class Li extends zs {+ /**+ * Constructs a new material.+ */+ constructor() {+ super(), this.isMaterial = !0, Object.defineProperty(this, "id", { value: VE++ }), this.uuid = Ei(), this.name = "", this.type = "Material", this.blending = fa, this.side = us, this.vertexColors = !1, this.opacity = 1, this.transparent = !1, this.alphaHash = !1, this.blendSrc = Hu, this.blendDst = zu, this.blendEquation = ar, this.blendSrcAlpha = null, this.blendDstAlpha = null, this.blendEquationAlpha = null, this.blendColor = new je(0, 0, 0), this.blendAlpha = 0, this.depthFunc = wa, this.depthTest = !0, this.depthWrite = !0, this.stencilWriteMask = 255, this.stencilFunc = gp, this.stencilRef = 0, this.stencilFuncMask = 255, this.stencilFail = Lr, this.stencilZFail = Lr, this.stencilZPass = Lr, 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;+ }+ /**+ * Sets the alpha value to be used when running an alpha test. The material+ * will not be rendered if the opacity is lower than this value.+ *+ * @type {number}+ * @readonly+ * @default 0+ */+ get alphaTest() {+ return this._alphaTest;+ }+ set alphaTest(e) {+ this._alphaTest > 0 != e > 0 && this.version++, this._alphaTest = e;+ }+ /**+ * An optional callback that is executed immediately before the material is used to render a 3D object.+ *+ * This method can only be used when rendering with {@link WebGLRenderer}.+ *+ * @param {WebGLRenderer} renderer - The renderer.+ * @param {Scene} scene - The scene.+ * @param {Camera} camera - The camera that is used to render the scene.+ * @param {BufferGeometry} geometry - The 3D object's geometry.+ * @param {Object3D} object - The 3D object.+ * @param {Object} group - The geometry group data.+ */+ onBeforeRender() {+ }+ /**+ * An optional callback that is executed immediately before the shader+ * program is compiled. This function is called with the shader source code+ * as a parameter. Useful for the modification of built-in materials.+ *+ * This method can only be used when rendering with {@link WebGLRenderer}. The+ * recommended approach when customizing materials is to use `WebGPURenderer` with the new+ * Node Material system and [TSL]{@link https://github.com/mrdoob/three.js/wiki/Three.js-Shading-Language}.+ *+ * @param {{vertexShader:string,fragmentShader:string,uniforms:Object}} shaderobject - The object holds the uniforms and the vertex and fragment shader source.+ * @param {WebGLRenderer} renderer - A reference to the renderer.+ */+ onBeforeCompile() {+ }+ /**+ * In case {@link Material#onBeforeCompile} is used, this callback can be used to identify+ * values of settings used in `onBeforeCompile()`, so three.js can reuse a cached+ * shader or recompile the shader for this material as needed.+ *+ * This method can only be used when rendering with {@link WebGLRenderer}.+ *+ * @return {string} The custom program cache key.+ */+ customProgramCacheKey() {+ return this.onBeforeCompile.toString();+ }+ /**+ * This method can be used to set default values from parameter objects.+ * It is a generic implementation so it can be used with different types+ * of materials.+ *+ * @param {Object} [values] - The material values to set.+ */+ setValues(e) {+ if (e !== void 0)+ for (const t in e) {+ const n = e[t];+ if (n === void 0) {+ console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);+ continue;+ }+ const s = this[t];+ if (s === void 0) {+ console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);+ continue;+ }+ s && s.isColor ? s.set(n) : s && s.isVector3 && n && n.isVector3 ? s.copy(n) : this[t] = n;+ }+ }+ /**+ * Serializes the material into JSON.+ *+ * @param {?(Object|string)} meta - An optional value holding meta information about the serialization.+ * @return {Object} A JSON object representing the serialized material.+ * @see {@link ObjectLoader#parse}+ */+ toJSON(e) {+ const t = e === void 0 || typeof e == "string";+ t && (e = {+ textures: {},+ images: {}+ });+ const n = {+ metadata: {+ version: 4.6,+ type: "Material",+ generator: "Material.toJSON"+ }+ };+ n.uuid = this.uuid, n.type = this.type, this.name !== "" && (n.name = this.name), this.color && this.color.isColor && (n.color = this.color.getHex()), this.roughness !== void 0 && (n.roughness = this.roughness), this.metalness !== void 0 && (n.metalness = this.metalness), this.sheen !== void 0 && (n.sheen = this.sheen), this.sheenColor && this.sheenColor.isColor && (n.sheenColor = this.sheenColor.getHex()), this.sheenRoughness !== void 0 && (n.sheenRoughness = this.sheenRoughness), this.emissive && this.emissive.isColor && (n.emissive = this.emissive.getHex()), this.emissiveIntensity !== void 0 && this.emissiveIntensity !== 1 && (n.emissiveIntensity = this.emissiveIntensity), this.specular && this.specular.isColor && (n.specular = this.specular.getHex()), this.specularIntensity !== void 0 && (n.specularIntensity = this.specularIntensity), this.specularColor && this.specularColor.isColor && (n.specularColor = this.specularColor.getHex()), this.shininess !== void 0 && (n.shininess = this.shininess), this.clearcoat !== void 0 && (n.clearcoat = this.clearcoat), this.clearcoatRoughness !== void 0 && (n.clearcoatRoughness = this.clearcoatRoughness), this.clearcoatMap && this.clearcoatMap.isTexture && (n.clearcoatMap = this.clearcoatMap.toJSON(e).uuid), this.clearcoatRoughnessMap && this.clearcoatRoughnessMap.isTexture && (n.clearcoatRoughnessMap = this.clearcoatRoughnessMap.toJSON(e).uuid), this.clearcoatNormalMap && this.clearcoatNormalMap.isTexture && (n.clearcoatNormalMap = this.clearcoatNormalMap.toJSON(e).uuid, n.clearcoatNormalScale = this.clearcoatNormalScale.toArray()), this.dispersion !== void 0 && (n.dispersion = this.dispersion), this.iridescence !== void 0 && (n.iridescence = this.iridescence), this.iridescenceIOR !== void 0 && (n.iridescenceIOR = this.iridescenceIOR), this.iridescenceThicknessRange !== void 0 && (n.iridescenceThicknessRange = this.iridescenceThicknessRange), this.iridescenceMap && this.iridescenceMap.isTexture && (n.iridescenceMap = this.iridescenceMap.toJSON(e).uuid), this.iridescenceThicknessMap && this.iridescenceThicknessMap.isTexture && (n.iridescenceThicknessMap = this.iridescenceThicknessMap.toJSON(e).uuid), this.anisotropy !== void 0 && (n.anisotropy = this.anisotropy), this.anisotropyRotation !== void 0 && (n.anisotropyRotation = this.anisotropyRotation), this.anisotropyMap && this.anisotropyMap.isTexture && (n.anisotropyMap = this.anisotropyMap.toJSON(e).uuid), this.map && this.map.isTexture && (n.map = this.map.toJSON(e).uuid), this.matcap && this.matcap.isTexture && (n.matcap = this.matcap.toJSON(e).uuid), this.alphaMap && this.alphaMap.isTexture && (n.alphaMap = this.alphaMap.toJSON(e).uuid), this.lightMap && this.lightMap.isTexture && (n.lightMap = this.lightMap.toJSON(e).uuid, n.lightMapIntensity = this.lightMapIntensity), this.aoMap && this.aoMap.isTexture && (n.aoMap = this.aoMap.toJSON(e).uuid, n.aoMapIntensity = this.aoMapIntensity), this.bumpMap && this.bumpMap.isTexture && (n.bumpMap = this.bumpMap.toJSON(e).uuid, n.bumpScale = this.bumpScale), this.normalMap && this.normalMap.isTexture && (n.normalMap = this.normalMap.toJSON(e).uuid, n.normalMapType = this.normalMapType, n.normalScale = this.normalScale.toArray()), this.displacementMap && this.displacementMap.isTexture && (n.displacementMap = this.displacementMap.toJSON(e).uuid, n.displacementScale = this.displacementScale, n.displacementBias = this.displacementBias), this.roughnessMap && this.roughnessMap.isTexture && (n.roughnessMap = this.roughnessMap.toJSON(e).uuid), this.metalnessMap && this.metalnessMap.isTexture && (n.metalnessMap = this.metalnessMap.toJSON(e).uuid), this.emissiveMap && this.emissiveMap.isTexture && (n.emissiveMap = this.emissiveMap.toJSON(e).uuid), this.specularMap && this.specularMap.isTexture && (n.specularMap = this.specularMap.toJSON(e).uuid), this.specularIntensityMap && this.specularIntensityMap.isTexture && (n.specularIntensityMap = this.specularIntensityMap.toJSON(e).uuid), this.specularColorMap && this.specularColorMap.isTexture && (n.specularColorMap = this.specularColorMap.toJSON(e).uuid), this.envMap && this.envMap.isTexture && (n.envMap = this.envMap.toJSON(e).uuid, this.combine !== void 0 && (n.combine = this.combine)), this.envMapRotation !== void 0 && (n.envMapRotation = this.envMapRotation.toArray()), this.envMapIntensity !== void 0 && (n.envMapIntensity = this.envMapIntensity), this.reflectivity !== void 0 && (n.reflectivity = this.reflectivity), this.refractionRatio !== void 0 && (n.refractionRatio = this.refractionRatio), this.gradientMap && this.gradientMap.isTexture && (n.gradientMap = this.gradientMap.toJSON(e).uuid), this.transmission !== void 0 && (n.transmission = this.transmission), this.transmissionMap && this.transmissionMap.isTexture && (n.transmissionMap = this.transmissionMap.toJSON(e).uuid), this.thickness !== void 0 && (n.thickness = this.thickness), this.thicknessMap && this.thicknessMap.isTexture && (n.thicknessMap = this.thicknessMap.toJSON(e).uuid), this.attenuationDistance !== void 0 && this.attenuationDistance !== 1 / 0 && (n.attenuationDistance = this.attenuationDistance), this.attenuationColor !== void 0 && (n.attenuationColor = this.attenuationColor.getHex()), this.size !== void 0 && (n.size = this.size), this.shadowSide !== null && (n.shadowSide = this.shadowSide), this.sizeAttenuation !== void 0 && (n.sizeAttenuation = this.sizeAttenuation), this.blending !== fa && (n.blending = this.blending), this.side !== us && (n.side = this.side), this.vertexColors === !0 && (n.vertexColors = !0), this.opacity < 1 && (n.opacity = this.opacity), this.transparent === !0 && (n.transparent = !0), this.blendSrc !== Hu && (n.blendSrc = this.blendSrc), this.blendDst !== zu && (n.blendDst = this.blendDst), this.blendEquation !== ar && (n.blendEquation = this.blendEquation), this.blendSrcAlpha !== null && (n.blendSrcAlpha = this.blendSrcAlpha), this.blendDstAlpha !== null && (n.blendDstAlpha = this.blendDstAlpha), this.blendEquationAlpha !== null && (n.blendEquationAlpha = this.blendEquationAlpha), this.blendColor && this.blendColor.isColor && (n.blendColor = this.blendColor.getHex()), this.blendAlpha !== 0 && (n.blendAlpha = this.blendAlpha), this.depthFunc !== wa && (n.depthFunc = this.depthFunc), this.depthTest === !1 && (n.depthTest = this.depthTest), this.depthWrite === !1 && (n.depthWrite = this.depthWrite), this.colorWrite === !1 && (n.colorWrite = this.colorWrite), this.stencilWriteMask !== 255 && (n.stencilWriteMask = this.stencilWriteMask), this.stencilFunc !== gp && (n.stencilFunc = this.stencilFunc), this.stencilRef !== 0 && (n.stencilRef = this.stencilRef), this.stencilFuncMask !== 255 && (n.stencilFuncMask = this.stencilFuncMask), this.stencilFail !== Lr && (n.stencilFail = this.stencilFail), this.stencilZFail !== Lr && (n.stencilZFail = this.stencilZFail), this.stencilZPass !== Lr && (n.stencilZPass = this.stencilZPass), this.stencilWrite === !0 && (n.stencilWrite = this.stencilWrite), this.rotation !== void 0 && this.rotation !== 0 && (n.rotation = this.rotation), this.polygonOffset === !0 && (n.polygonOffset = !0), this.polygonOffsetFactor !== 0 && (n.polygonOffsetFactor = this.polygonOffsetFactor), this.polygonOffsetUnits !== 0 && (n.polygonOffsetUnits = this.polygonOffsetUnits), this.linewidth !== void 0 && this.linewidth !== 1 && (n.linewidth = this.linewidth), this.dashSize !== void 0 && (n.dashSize = this.dashSize), this.gapSize !== void 0 && (n.gapSize = this.gapSize), this.scale !== void 0 && (n.scale = this.scale), this.dithering === !0 && (n.dithering = !0), this.alphaTest > 0 && (n.alphaTest = this.alphaTest), this.alphaHash === !0 && (n.alphaHash = !0), this.alphaToCoverage === !0 && (n.alphaToCoverage = !0), this.premultipliedAlpha === !0 && (n.premultipliedAlpha = !0), this.forceSinglePass === !0 && (n.forceSinglePass = !0), this.wireframe === !0 && (n.wireframe = !0), this.wireframeLinewidth > 1 && (n.wireframeLinewidth = this.wireframeLinewidth), this.wireframeLinecap !== "round" && (n.wireframeLinecap = this.wireframeLinecap), this.wireframeLinejoin !== "round" && (n.wireframeLinejoin = this.wireframeLinejoin), this.flatShading === !0 && (n.flatShading = !0), this.visible === !1 && (n.visible = !1), this.toneMapped === !1 && (n.toneMapped = !1), this.fog === !1 && (n.fog = !1), Object.keys(this.userData).length > 0 && (n.userData = this.userData);+ function s(r) {+ const a = [];+ for (const o in r) {+ const c = r[o];+ delete c.metadata, a.push(c);+ }+ return a;+ }+ if (t) {+ const r = s(e.textures), a = s(e.images);+ r.length > 0 && (n.textures = r), a.length > 0 && (n.images = a);+ }+ return n;+ }+ /**+ * Returns a new material with copied values from this instance.+ *+ * @return {Material} A clone of this instance.+ */+ clone() {+ return new this.constructor().copy(this);+ }+ /**+ * Copies the values of the given material to this instance.+ *+ * @param {Material} source - The material to copy.+ * @return {Material} A reference to this instance.+ */+ copy(e) {+ this.name = e.name, this.blending = e.blending, this.side = e.side, this.vertexColors = e.vertexColors, this.opacity = e.opacity, this.transparent = e.transparent, this.blendSrc = e.blendSrc, this.blendDst = e.blendDst, this.blendEquation = e.blendEquation, this.blendSrcAlpha = e.blendSrcAlpha, this.blendDstAlpha = e.blendDstAlpha, this.blendEquationAlpha = e.blendEquationAlpha, this.blendColor.copy(e.blendColor), this.blendAlpha = e.blendAlpha, this.depthFunc = e.depthFunc, this.depthTest = e.depthTest, this.depthWrite = e.depthWrite, this.stencilWriteMask = e.stencilWriteMask, this.stencilFunc = e.stencilFunc, this.stencilRef = e.stencilRef, this.stencilFuncMask = e.stencilFuncMask, this.stencilFail = e.stencilFail, this.stencilZFail = e.stencilZFail, this.stencilZPass = e.stencilZPass, this.stencilWrite = e.stencilWrite;+ const t = e.clippingPlanes;+ let n = null;+ if (t !== null) {+ const s = t.length;+ n = new Array(s);+ for (let r = 0; r !== s; ++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.visible = e.visible, this.toneMapped = e.toneMapped, this.userData = JSON.parse(JSON.stringify(e.userData)), this;+ }+ /**+ * Frees the GPU-related resources allocated by this instance. Call this+ * method whenever this instance is no longer used in your app.+ *+ * @fires Material#dispose+ */+ dispose() {+ this.dispatchEvent({ type: "dispose" });+ }+ /**+ * Setting this property to `true` indicates the engine the material+ * needs to be recompiled.+ *+ * @type {boolean}+ * @default false+ * @param {boolean} value+ */+ set needsUpdate(e) {+ e === !0 && this.version++;+ }+}+class Ns extends Li {+ /**+ * Constructs a new mesh basic material.+ *+ * @param {Object} [parameters] - An object with one or more properties+ * defining the material's appearance. Any property of the material+ * (including any property from inherited materials) can be passed+ * in here. Color values can be passed any type of value accepted+ * by {@link Color#set}.+ */+ constructor(e) {+ super(), this.isMeshBasicMaterial = !0, this.type = "MeshBasicMaterial", this.color = new je(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 Pi(), this.combine = zm, this.reflectivity = 1, this.refractionRatio = 0.98, this.wireframe = !1, this.wireframeLinewidth = 1, this.wireframeLinecap = "round", this.wireframeLinejoin = "round", this.fog = !0, this.setValues(e);+ }+ copy(e) {+ return super.copy(e), this.color.copy(e.color), this.map = e.map, this.lightMap = e.lightMap, this.lightMapIntensity = e.lightMapIntensity, this.aoMap = e.aoMap, this.aoMapIntensity = e.aoMapIntensity, this.specularMap = e.specularMap, this.alphaMap = e.alphaMap, this.envMap = e.envMap, this.envMapRotation.copy(e.envMapRotation), this.combine = e.combine, this.reflectivity = e.reflectivity, this.refractionRatio = e.refractionRatio, this.wireframe = e.wireframe, this.wireframeLinewidth = e.wireframeLinewidth, this.wireframeLinecap = e.wireframeLinecap, this.wireframeLinejoin = e.wireframeLinejoin, this.fog = e.fog, this;+ }+}+const $i = /* @__PURE__ */ WE();+function WE() {+ const i = new ArrayBuffer(4), e = new Float32Array(i), t = new Uint32Array(i), n = new Uint32Array(512), s = new Uint32Array(512);+ for (let c = 0; c < 256; ++c) {+ const l = c - 127;+ l < -27 ? (n[c] = 0, n[c | 256] = 32768, s[c] = 24, s[c | 256] = 24) : l < -14 ? (n[c] = 1024 >> -l - 14, n[c | 256] = 1024 >> -l - 14 | 32768, s[c] = -l - 1, s[c | 256] = -l - 1) : l <= 15 ? (n[c] = l + 15 << 10, n[c | 256] = l + 15 << 10 | 32768, s[c] = 13, s[c | 256] = 13) : l < 128 ? (n[c] = 31744, n[c | 256] = 64512, s[c] = 24, s[c | 256] = 24) : (n[c] = 31744, n[c | 256] = 64512, s[c] = 13, s[c | 256] = 13);+ }+ const r = new Uint32Array(2048), a = new Uint32Array(64), o = new Uint32Array(64);+ for (let c = 1; c < 1024; ++c) {+ let l = c << 13, h = 0;+ for (; (l & 8388608) === 0; )+ l <<= 1, h -= 8388608;+ l &= -8388609, h += 947912704, r[c] = l | h;+ }+ for (let c = 1024; c < 2048; ++c)+ r[c] = 939524096 + (c - 1024 << 13);+ for (let c = 1; c < 31; ++c)+ a[c] = c << 23;+ a[31] = 1199570944, a[32] = 2147483648;+ for (let c = 33; c < 63; ++c)+ a[c] = 2147483648 + (c - 32 << 23);+ a[63] = 3347054592;+ for (let c = 1; c < 64; ++c)+ c !== 32 && (o[c] = 1024);+ return {+ floatView: e,+ uint32View: t,+ baseTable: n,+ shiftTable: s,+ mantissaTable: r,+ exponentTable: a,+ offsetTable: o+ };+}+function qE(i) {+ Math.abs(i) > 65504 && console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."), i = ct(i, -65504, 65504), $i.floatView[0] = i;+ const e = $i.uint32View[0], t = e >> 23 & 511;+ return $i.baseTable[t] + ((e & 8388607) >> $i.shiftTable[t]);+}+function KE(i) {+ const e = i >> 10;+ return $i.uint32View[0] = $i.mantissaTable[$i.offsetTable[e] + (i & 1023)] + $i.exponentTable[e], $i.floatView[0];+}+class Rp {+ /**+ * Returns a half precision floating point value (FP16) from the given single+ * precision floating point value (FP32).+ *+ * @param {number} val - A single precision floating point value.+ * @return {number} The FP16 value.+ */+ static toHalfFloat(e) {+ return qE(e);+ }+ /**+ * Returns a single precision floating point value (FP32) from the given half+ * precision floating point value (FP16).+ *+ * @param {number} val - A half precision floating point value.+ * @return {number} The FP32 value.+ */+ static fromHalfFloat(e) {+ return KE(e);+ }+}+const Yt = /* @__PURE__ */ new H(), Ec = /* @__PURE__ */ new Ze();+let jE = 0;+class En {+ /**+ * Constructs a new buffer attribute.+ *+ * @param {TypedArray} array - The array holding the attribute data.+ * @param {number} itemSize - The item size.+ * @param {boolean} [normalized=false] - Whether the data are normalized or not.+ */+ constructor(e, t, n = !1) {+ if (Array.isArray(e))+ throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");+ this.isBufferAttribute = !0, Object.defineProperty(this, "id", { value: jE++ }), this.name = "", this.array = e, this.itemSize = t, this.count = e !== void 0 ? e.length / t : 0, this.normalized = n, this.usage = xd, this.updateRanges = [], this.gpuType = an, this.version = 0;+ }+ /**+ * A callback function that is executed after the renderer has transferred the attribute+ * array data to the GPU.+ */+ onUploadCallback() {+ }+ /**+ * Flag to indicate that this attribute has changed and should be re-sent to+ * the GPU. Set this to `true` when you modify the value of the array.+ *+ * @type {number}+ * @default false+ * @param {boolean} value+ */+ set needsUpdate(e) {+ e === !0 && this.version++;+ }+ /**+ * Sets the usage of this buffer attribute.+ *+ * @param {(StaticDrawUsage|DynamicDrawUsage|StreamDrawUsage|StaticReadUsage|DynamicReadUsage|StreamReadUsage|StaticCopyUsage|DynamicCopyUsage|StreamCopyUsage)} value - The usage to set.+ * @return {BufferAttribute} A reference to this buffer attribute.+ */+ setUsage(e) {+ return this.usage = e, this;+ }+ /**+ * Adds a range of data in the data array to be updated on the GPU.+ *+ * @param {number} start - Position at which to start update.+ * @param {number} count - The number of components to update.+ */+ addUpdateRange(e, t) {+ this.updateRanges.push({ start: e, count: t });+ }+ /**+ * Clears the update ranges.+ */+ clearUpdateRanges() {+ this.updateRanges.length = 0;+ }+ /**+ * Copies the values of the given buffer attribute to this instance.+ *+ * @param {BufferAttribute} source - The buffer attribute to copy.+ * @return {BufferAttribute} A reference to this instance.+ */+ 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;+ }+ /**+ * Copies a vector from the given buffer attribute to this one. The start+ * and destination position in the attribute buffers are represented by the+ * given indices.+ *+ * @param {number} index1 - The destination index into this buffer attribute.+ * @param {BufferAttribute} attribute - The buffer attribute to copy from.+ * @param {number} index2 - The source index into the given buffer attribute.+ * @return {BufferAttribute} A reference to this instance.+ */+ copyAt(e, t, n) {+ e *= this.itemSize, n *= t.itemSize;+ for (let s = 0, r = this.itemSize; s < r; s++)+ this.array[e + s] = t.array[n + s];+ return this;+ }+ /**+ * Copies the given array data into this buffer attribute.+ *+ * @param {(TypedArray|Array)} array - The array to copy.+ * @return {BufferAttribute} A reference to this instance.+ */+ copyArray(e) {+ return this.array.set(e), this;+ }+ /**+ * Applies the given 3x3 matrix to the given attribute. Works with+ * item size `2` and `3`.+ *+ * @param {Matrix3} m - The matrix to apply.+ * @return {BufferAttribute} A reference to this instance.+ */+ applyMatrix3(e) {+ if (this.itemSize === 2)+ for (let t = 0, n = this.count; t < n; t++)+ Ec.fromBufferAttribute(this, t), Ec.applyMatrix3(e), this.setXY(t, Ec.x, Ec.y);+ else if (this.itemSize === 3)+ for (let t = 0, n = this.count; t < n; t++)+ Yt.fromBufferAttribute(this, t), Yt.applyMatrix3(e), this.setXYZ(t, Yt.x, Yt.y, Yt.z);+ return this;+ }+ /**+ * Applies the given 4x4 matrix to the given attribute. Only works with+ * item size `3`.+ *+ * @param {Matrix4} m - The matrix to apply.+ * @return {BufferAttribute} A reference to this instance.+ */+ applyMatrix4(e) {+ for (let t = 0, n = this.count; t < n; t++)+ Yt.fromBufferAttribute(this, t), Yt.applyMatrix4(e), this.setXYZ(t, Yt.x, Yt.y, Yt.z);+ return this;+ }+ /**+ * Applies the given 3x3 normal matrix to the given attribute. Only works with+ * item size `3`.+ *+ * @param {Matrix3} m - The normal matrix to apply.+ * @return {BufferAttribute} A reference to this instance.+ */+ applyNormalMatrix(e) {+ for (let t = 0, n = this.count; t < n; t++)+ Yt.fromBufferAttribute(this, t), Yt.applyNormalMatrix(e), this.setXYZ(t, Yt.x, Yt.y, Yt.z);+ return this;+ }+ /**+ * Applies the given 4x4 matrix to the given attribute. Only works with+ * item size `3` and with direction vectors.+ *+ * @param {Matrix4} m - The matrix to apply.+ * @return {BufferAttribute} A reference to this instance.+ */+ transformDirection(e) {+ for (let t = 0, n = this.count; t < n; t++)+ Yt.fromBufferAttribute(this, t), Yt.transformDirection(e), this.setXYZ(t, Yt.x, Yt.y, Yt.z);+ return this;+ }+ /**+ * Sets the given array data in the buffer attribute.+ *+ * @param {(TypedArray|Array)} value - The array data to set.+ * @param {number} [offset=0] - The offset in this buffer attribute's array.+ * @return {BufferAttribute} A reference to this instance.+ */+ set(e, t = 0) {+ return this.array.set(e, t), this;+ }+ /**+ * Returns the given component of the vector at the given index.+ *+ * @param {number} index - The index into the buffer attribute.+ * @param {number} component - The component index.+ * @return {number} The returned value.+ */+ getComponent(e, t) {+ let n = this.array[e * this.itemSize + t];+ return this.normalized && (n = mi(n, this.array)), n;+ }+ /**+ * Sets the given value to the given component of the vector at the given index.+ *+ * @param {number} index - The index into the buffer attribute.+ * @param {number} component - The component index.+ * @param {number} value - The value to set.+ * @return {BufferAttribute} A reference to this instance.+ */+ setComponent(e, t, n) {+ return this.normalized && (n = It(n, this.array)), this.array[e * this.itemSize + t] = n, this;+ }+ /**+ * Returns the x component of the vector at the given index.+ *+ * @param {number} index - The index into the buffer attribute.+ * @return {number} The x component.+ */+ getX(e) {+ let t = this.array[e * this.itemSize];+ return this.normalized && (t = mi(t, this.array)), t;+ }+ /**+ * Sets the x component of the vector at the given index.+ *+ * @param {number} index - The index into the buffer attribute.+ * @param {number} x - The value to set.+ * @return {BufferAttribute} A reference to this instance.+ */+ setX(e, t) {+ return this.normalized && (t = It(t, this.array)), this.array[e * this.itemSize] = t, this;+ }+ /**+ * Returns the y component of the vector at the given index.+ *+ * @param {number} index - The index into the buffer attribute.+ * @return {number} The y component.+ */+ getY(e) {+ let t = this.array[e * this.itemSize + 1];+ return this.normalized && (t = mi(t, this.array)), t;+ }+ /**+ * Sets the y component of the vector at the given index.+ *+ * @param {number} index - The index into the buffer attribute.+ * @param {number} y - The value to set.+ * @return {BufferAttribute} A reference to this instance.+ */+ setY(e, t) {+ return this.normalized && (t = It(t, this.array)), this.array[e * this.itemSize + 1] = t, this;+ }+ /**+ * Returns the z component of the vector at the given index.+ *+ * @param {number} index - The index into the buffer attribute.+ * @return {number} The z component.+ */+ getZ(e) {+ let t = this.array[e * this.itemSize + 2];+ return this.normalized && (t = mi(t, this.array)), t;+ }+ /**+ * Sets the z component of the vector at the given index.+ *+ * @param {number} index - The index into the buffer attribute.+ * @param {number} z - The value to set.+ * @return {BufferAttribute} A reference to this instance.+ */+ setZ(e, t) {+ return this.normalized && (t = It(t, this.array)), this.array[e * this.itemSize + 2] = t, this;+ }+ /**+ * Returns the w component of the vector at the given index.+ *+ * @param {number} index - The index into the buffer attribute.+ * @return {number} The w component.+ */+ getW(e) {+ let t = this.array[e * this.itemSize + 3];+ return this.normalized && (t = mi(t, this.array)), t;+ }+ /**+ * Sets the w component of the vector at the given index.+ *+ * @param {number} index - The index into the buffer attribute.+ * @param {number} w - The value to set.+ * @return {BufferAttribute} A reference to this instance.+ */+ setW(e, t) {+ return this.normalized && (t = It(t, this.array)), this.array[e * this.itemSize + 3] = t, this;+ }+ /**+ * Sets the x and y component of the vector at the given index.+ *+ * @param {number} index - The index into the buffer attribute.+ * @param {number} x - The value for the x component to set.+ * @param {number} y - The value for the y component to set.+ * @return {BufferAttribute} A reference to this instance.+ */+ setXY(e, t, n) {+ return e *= this.itemSize, this.normalized && (t = It(t, this.array), n = It(n, this.array)), this.array[e + 0] = t, this.array[e + 1] = n, this;+ }+ /**+ * Sets the x, y and z component of the vector at the given index.+ *+ * @param {number} index - The index into the buffer attribute.+ * @param {number} x - The value for the x component to set.+ * @param {number} y - The value for the y component to set.+ * @param {number} z - The value for the z component to set.+ * @return {BufferAttribute} A reference to this instance.+ */+ setXYZ(e, t, n, s) {+ return e *= this.itemSize, this.normalized && (t = It(t, this.array), n = It(n, this.array), s = It(s, this.array)), this.array[e + 0] = t, this.array[e + 1] = n, this.array[e + 2] = s, this;+ }+ /**+ * Sets the x, y, z and w component of the vector at the given index.+ *+ * @param {number} index - The index into the buffer attribute.+ * @param {number} x - The value for the x component to set.+ * @param {number} y - The value for the y component to set.+ * @param {number} z - The value for the z component to set.+ * @param {number} w - The value for the w component to set.+ * @return {BufferAttribute} A reference to this instance.+ */+ setXYZW(e, t, n, s, r) {+ return e *= this.itemSize, this.normalized && (t = It(t, this.array), n = It(n, this.array), s = It(s, this.array), r = It(r, this.array)), this.array[e + 0] = t, this.array[e + 1] = n, this.array[e + 2] = s, this.array[e + 3] = r, this;+ }+ /**+ * Sets the given callback function that is executed after the Renderer has transferred+ * the attribute array data to the GPU. Can be used to perform clean-up operations after+ * the upload when attribute data are not needed anymore on the CPU side.+ *+ * @param {Function} callback - The `onUpload()` callback.+ * @return {BufferAttribute} A reference to this instance.+ */+ onUpload(e) {+ return this.onUploadCallback = e, this;+ }+ /**+ * Returns a new buffer attribute with copied values from this instance.+ *+ * @return {BufferAttribute} A clone of this instance.+ */+ clone() {+ return new this.constructor(this.array, this.itemSize).copy(this);+ }+ /**+ * Serializes the buffer attribute into JSON.+ *+ * @return {Object} A JSON object representing the serialized buffer attribute.+ */+ toJSON() {+ const e = {+ itemSize: this.itemSize,+ type: this.array.constructor.name,+ array: Array.from(this.array),+ normalized: this.normalized+ };+ return this.name !== "" && (e.name = this.name), this.usage !== xd && (e.usage = this.usage), e;+ }+}+class h0 extends En {+ /**+ * Constructs a new buffer attribute.+ *+ * @param {(Array<number>|Uint16Array)} array - The array holding the attribute data.+ * @param {number} itemSize - The item size.+ * @param {boolean} [normalized=false] - Whether the data are normalized or not.+ */+ constructor(e, t, n) {+ super(new Uint16Array(e), t, n);+ }+}+class u0 extends En {+ /**+ * Constructs a new buffer attribute.+ *+ * @param {(Array<number>|Uint32Array)} array - The array holding the attribute data.+ * @param {number} itemSize - The item size.+ * @param {boolean} [normalized=false] - Whether the data are normalized or not.+ */+ constructor(e, t, n) {+ super(new Uint32Array(e), t, n);+ }+}+class Un extends En {+ /**+ * Constructs a new buffer attribute.+ *+ * @param {(Array<number>|Float32Array)} array - The array holding the attribute data.+ * @param {number} itemSize - The item size.+ * @param {boolean} [normalized=false] - Whether the data are normalized or not.+ */+ constructor(e, t, n) {+ super(new Float32Array(e), t, n);+ }+}+let XE = 0;+const Jn = /* @__PURE__ */ new et(), Uh = /* @__PURE__ */ new kt(), Wr = /* @__PURE__ */ new H(), qn = /* @__PURE__ */ new yi(), Za = /* @__PURE__ */ new yi(), An = /* @__PURE__ */ new H();+class zn extends zs {+ /**+ * Constructs a new geometry.+ */+ constructor() {+ super(), this.isBufferGeometry = !0, Object.defineProperty(this, "id", { value: XE++ }), this.uuid = Ei(), this.name = "", this.type = "BufferGeometry", this.index = null, this.indirect = null, this.attributes = {}, this.morphAttributes = {}, this.morphTargetsRelative = !1, this.groups = [], this.boundingBox = null, this.boundingSphere = null, this.drawRange = { start: 0, count: 1 / 0 }, this.userData = {};+ }+ /**+ * Returns the index of this geometry.+ *+ * @return {?BufferAttribute} The index. Returns `null` if no index is defined.+ */+ getIndex() {+ return this.index;+ }+ /**+ * Sets the given index to this geometry.+ *+ * @param {Array<number>|BufferAttribute} index - The index to set.+ * @return {BufferGeometry} A reference to this instance.+ */+ setIndex(e) {+ return Array.isArray(e) ? this.index = new (r0(e) ? u0 : h0)(e, 1) : this.index = e, this;+ }+ /**+ * Sets the given indirect attribute to this geometry.+ *+ * @param {BufferAttribute} indirect - The attribute holding indirect draw calls.+ * @return {BufferGeometry} A reference to this instance.+ */+ setIndirect(e) {+ return this.indirect = e, this;+ }+ /**+ * Returns the indirect attribute of this geometry.+ *+ * @return {?BufferAttribute} The indirect attribute. Returns `null` if no indirect attribute is defined.+ */+ getIndirect() {+ return this.indirect;+ }+ /**+ * Returns the buffer attribute for the given name.+ *+ * @param {string} name - The attribute name.+ * @return {BufferAttribute|InterleavedBufferAttribute|undefined} The buffer attribute.+ * Returns `undefined` if not attribute has been found.+ */+ getAttribute(e) {+ return this.attributes[e];+ }+ /**+ * Sets the given attribute for the given name.+ *+ * @param {string} name - The attribute name.+ * @param {BufferAttribute|InterleavedBufferAttribute} attribute - The attribute to set.+ * @return {BufferGeometry} A reference to this instance.+ */+ setAttribute(e, t) {+ return this.attributes[e] = t, this;+ }+ /**+ * Deletes the attribute for the given name.+ *+ * @param {string} name - The attribute name to delete.+ * @return {BufferGeometry} A reference to this instance.+ */+ deleteAttribute(e) {+ return delete this.attributes[e], this;+ }+ /**+ * Returns `true` if this geometry has an attribute for the given name.+ *+ * @param {string} name - The attribute name.+ * @return {boolean} Whether this geometry has an attribute for the given name or not.+ */+ hasAttribute(e) {+ return this.attributes[e] !== void 0;+ }+ /**+ * Adds a group to this geometry.+ *+ * @param {number} start - The first element in this draw call. That is the first+ * vertex for non-indexed geometry, otherwise the first triangle index.+ * @param {number} count - Specifies how many vertices (or indices) are part of this group.+ * @param {number} [materialIndex=0] - The material array index to use.+ */+ addGroup(e, t, n = 0) {+ this.groups.push({+ start: e,+ count: t,+ materialIndex: n+ });+ }+ /**+ * Clears all groups.+ */+ clearGroups() {+ this.groups = [];+ }+ /**+ * Sets the draw range for this geometry.+ *+ * @param {number} start - The first vertex for non-indexed geometry, otherwise the first triangle index.+ * @param {number} count - For non-indexed BufferGeometry, `count` is the number of vertices to render.+ * For indexed BufferGeometry, `count` is the number of indices to render.+ */+ setDrawRange(e, t) {+ this.drawRange.start = e, this.drawRange.count = t;+ }+ /**+ * Applies the given 4x4 transformation matrix to the geometry.+ *+ * @param {Matrix4} matrix - The matrix to apply.+ * @return {BufferGeometry} A reference to this instance.+ */+ applyMatrix4(e) {+ const t = this.attributes.position;+ t !== void 0 && (t.applyMatrix4(e), t.needsUpdate = !0);+ const n = this.attributes.normal;+ if (n !== void 0) {+ const r = new rt().getNormalMatrix(e);+ n.applyNormalMatrix(r), n.needsUpdate = !0;+ }+ const s = this.attributes.tangent;+ return s !== void 0 && (s.transformDirection(e), s.needsUpdate = !0), this.boundingBox !== null && this.computeBoundingBox(), this.boundingSphere !== null && this.computeBoundingSphere(), this;+ }+ /**+ * Applies the rotation represented by the Quaternion to the geometry.+ *+ * @param {Quaternion} q - The Quaternion to apply.+ * @return {BufferGeometry} A reference to this instance.+ */+ applyQuaternion(e) {+ return Jn.makeRotationFromQuaternion(e), this.applyMatrix4(Jn), this;+ }+ /**+ * Rotates the geometry about the X axis. This is typically done as a one time+ * operation, and not during a loop. Use {@link Object3D#rotation} for typical+ * real-time mesh rotation.+ *+ * @param {number} angle - The angle in radians.+ * @return {BufferGeometry} A reference to this instance.+ */+ rotateX(e) {+ return Jn.makeRotationX(e), this.applyMatrix4(Jn), this;+ }+ /**+ * Rotates the geometry about the Y axis. This is typically done as a one time+ * operation, and not during a loop. Use {@link Object3D#rotation} for typical+ * real-time mesh rotation.+ *+ * @param {number} angle - The angle in radians.+ * @return {BufferGeometry} A reference to this instance.+ */+ rotateY(e) {+ return Jn.makeRotationY(e), this.applyMatrix4(Jn), this;+ }+ /**+ * Rotates the geometry about the Z axis. This is typically done as a one time+ * operation, and not during a loop. Use {@link Object3D#rotation} for typical+ * real-time mesh rotation.+ *+ * @param {number} angle - The angle in radians.+ * @return {BufferGeometry} A reference to this instance.+ */+ rotateZ(e) {+ return Jn.makeRotationZ(e), this.applyMatrix4(Jn), this;+ }+ /**+ * Translates the geometry. This is typically done as a one time+ * operation, and not during a loop. Use {@link Object3D#position} for typical+ * real-time mesh rotation.+ *+ * @param {number} x - The x offset.+ * @param {number} y - The y offset.+ * @param {number} z - The z offset.+ * @return {BufferGeometry} A reference to this instance.+ */+ translate(e, t, n) {+ return Jn.makeTranslation(e, t, n), this.applyMatrix4(Jn), this;+ }+ /**+ * Scales the geometry. This is typically done as a one time+ * operation, and not during a loop. Use {@link Object3D#scale} for typical+ * real-time mesh rotation.+ *+ * @param {number} x - The x scale.+ * @param {number} y - The y scale.+ * @param {number} z - The z scale.+ * @return {BufferGeometry} A reference to this instance.+ */+ scale(e, t, n) {+ return Jn.makeScale(e, t, n), this.applyMatrix4(Jn), this;+ }+ /**+ * Rotates the geometry to face a point in 3D space. This is typically done as a one time+ * operation, and not during a loop. Use {@link Object3D#lookAt} for typical+ * real-time mesh rotation.+ *+ * @param {Vector3} vector - The target point.+ * @return {BufferGeometry} A reference to this instance.+ */+ lookAt(e) {+ return Uh.lookAt(e), Uh.updateMatrix(), this.applyMatrix4(Uh.matrix), this;+ }+ /**+ * Center the geometry based on its bounding box.+ *+ * @return {BufferGeometry} A reference to this instance.+ */+ center() {+ return this.computeBoundingBox(), this.boundingBox.getCenter(Wr).negate(), this.translate(Wr.x, Wr.y, Wr.z), this;+ }+ /**+ * Defines a geometry by creating a `position` attribute based on the given array of points. The array+ * can hold 2D or 3D vectors. When using two-dimensional data, the `z` coordinate for all vertices is+ * set to `0`.+ *+ * If the method is used with an existing `position` attribute, the vertex data are overwritten with the+ * data from the array. The length of the array must match the vertex count.+ *+ * @param {Array<Vector2>|Array<Vector3>} points - The points.+ * @return {BufferGeometry} A reference to this instance.+ */+ setFromPoints(e) {+ const t = this.getAttribute("position");+ if (t === void 0) {+ const n = [];+ for (let s = 0, r = e.length; s < r; s++) {+ const a = e[s];+ n.push(a.x, a.y, a.z || 0);+ }+ this.setAttribute("position", new Un(n, 3));+ } else {+ const n = Math.min(e.length, t.count);+ for (let s = 0; s < n; s++) {+ const r = e[s];+ t.setXYZ(s, r.x, r.y, r.z || 0);+ }+ e.length > t.count && console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."), t.needsUpdate = !0;+ }+ return this;+ }+ /**+ * Computes the bounding box of the geometry, and updates the `boundingBox` member.+ * The bounding box is not computed by the engine; it must be computed by your app.+ * You may need to recompute the bounding box if the geometry vertices are modified.+ */+ computeBoundingBox() {+ this.boundingBox === null && (this.boundingBox = new yi());+ const e = this.attributes.position, t = this.morphAttributes.position;+ if (e && e.isGLBufferAttribute) {+ console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.", this), this.boundingBox.set(+ new H(-1 / 0, -1 / 0, -1 / 0),+ new H(1 / 0, 1 / 0, 1 / 0)+ );+ return;+ }+ if (e !== void 0) {+ if (this.boundingBox.setFromBufferAttribute(e), t)+ for (let n = 0, s = t.length; n < s; n++) {+ const r = t[n];+ qn.setFromBufferAttribute(r), this.morphTargetsRelative ? (An.addVectors(this.boundingBox.min, qn.min), this.boundingBox.expandByPoint(An), An.addVectors(this.boundingBox.max, qn.max), this.boundingBox.expandByPoint(An)) : (this.boundingBox.expandByPoint(qn.min), this.boundingBox.expandByPoint(qn.max));+ }+ } else+ this.boundingBox.makeEmpty();+ (isNaN(this.boundingBox.min.x) || isNaN(this.boundingBox.min.y) || isNaN(this.boundingBox.min.z)) && console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.', this);+ }+ /**+ * Computes the bounding sphere of the geometry, and updates the `boundingSphere` member.+ * The engine automatically computes the bounding sphere when it is needed, e.g., for ray casting or view frustum culling.+ * You may need to recompute the bounding sphere if the geometry vertices are modified.+ */+ computeBoundingSphere() {+ this.boundingSphere === null && (this.boundingSphere = new Ui());+ const e = this.attributes.position, t = this.morphAttributes.position;+ if (e && e.isGLBufferAttribute) {+ console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.", this), this.boundingSphere.set(new H(), 1 / 0);+ return;+ }+ if (e) {+ const n = this.boundingSphere.center;+ if (qn.setFromBufferAttribute(e), t)+ for (let r = 0, a = t.length; r < a; r++) {+ const o = t[r];+ Za.setFromBufferAttribute(o), this.morphTargetsRelative ? (An.addVectors(qn.min, Za.min), qn.expandByPoint(An), An.addVectors(qn.max, Za.max), qn.expandByPoint(An)) : (qn.expandByPoint(Za.min), qn.expandByPoint(Za.max));+ }+ qn.getCenter(n);+ let s = 0;+ for (let r = 0, a = e.count; r < a; r++)+ An.fromBufferAttribute(e, r), s = Math.max(s, n.distanceToSquared(An));+ if (t)+ for (let r = 0, a = t.length; r < a; r++) {+ const o = t[r], c = this.morphTargetsRelative;+ for (let l = 0, h = o.count; l < h; l++)+ An.fromBufferAttribute(o, l), c && (Wr.fromBufferAttribute(e, l), An.add(Wr)), s = Math.max(s, n.distanceToSquared(An));+ }+ this.boundingSphere.radius = Math.sqrt(s), isNaN(this.boundingSphere.radius) && console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.', this);+ }+ }+ /**+ * Calculates and adds a tangent attribute to this geometry.+ *+ * The computation is only supported for indexed geometries and if position, normal, and uv attributes+ * are defined. When using a tangent space normal map, prefer the MikkTSpace algorithm provided by+ * {@link BufferGeometryUtils#computeMikkTSpaceTangents} instead.+ */+ computeTangents() {+ const e = this.index, t = this.attributes;+ if (e === null || t.position === void 0 || t.normal === void 0 || t.uv === void 0) {+ console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");+ return;+ }+ const n = t.position, s = t.normal, r = t.uv;+ this.hasAttribute("tangent") === !1 && this.setAttribute("tangent", new En(new Float32Array(4 * n.count), 4));+ const a = this.getAttribute("tangent"), o = [], c = [];+ for (let T = 0; T < n.count; T++)+ o[T] = new H(), c[T] = new H();+ const l = new H(), h = new H(), u = new H(), d = new Ze(), f = new Ze(), m = new Ze(), A = new H(), g = new H();+ function p(T, C, v) {+ l.fromBufferAttribute(n, T), h.fromBufferAttribute(n, C), u.fromBufferAttribute(n, v), d.fromBufferAttribute(r, T), f.fromBufferAttribute(r, C), m.fromBufferAttribute(r, v), h.sub(l), u.sub(l), f.sub(d), m.sub(d);+ const F = 1 / (f.x * m.y - m.x * f.y);+ isFinite(F) && (A.copy(h).multiplyScalar(m.y).addScaledVector(u, -f.y).multiplyScalar(F), g.copy(u).multiplyScalar(f.x).addScaledVector(h, -m.x).multiplyScalar(F), o[T].add(A), o[C].add(A), o[v].add(A), c[T].add(g), c[C].add(g), c[v].add(g));+ }+ let y = this.groups;+ y.length === 0 && (y = [{+ start: 0,+ count: e.count+ }]);+ for (let T = 0, C = y.length; T < C; ++T) {+ const v = y[T], F = v.start, K = v.count;+ for (let q = F, $ = F + K; q < $; q += 3)+ p(+ e.getX(q + 0),+ e.getX(q + 1),+ e.getX(q + 2)+ );+ }+ const b = new H(), E = new H(), M = new H(), w = new H();+ function S(T) {+ M.fromBufferAttribute(s, T), w.copy(M);+ const C = o[T];+ b.copy(C), b.sub(M.multiplyScalar(M.dot(C))).normalize(), E.crossVectors(w, C);+ const F = E.dot(c[T]) < 0 ? -1 : 1;+ a.setXYZW(T, b.x, b.y, b.z, F);+ }+ for (let T = 0, C = y.length; T < C; ++T) {+ const v = y[T], F = v.start, K = v.count;+ for (let q = F, $ = F + K; q < $; q += 3)+ S(e.getX(q + 0)), S(e.getX(q + 1)), S(e.getX(q + 2));+ }+ }+ /**+ * Computes vertex normals for the given vertex data. For indexed geometries, the method sets+ * each vertex normal to be the average of the face normals of the faces that share that vertex.+ * For non-indexed geometries, vertices are not shared, and the method sets each vertex normal+ * to be the same as the face normal.+ */+ computeVertexNormals() {+ const e = this.index, t = this.getAttribute("position");+ if (t !== void 0) {+ let n = this.getAttribute("normal");+ if (n === void 0)+ n = new En(new Float32Array(t.count * 3), 3), this.setAttribute("normal", n);+ else+ for (let d = 0, f = n.count; d < f; d++)+ n.setXYZ(d, 0, 0, 0);+ const s = new H(), r = new H(), a = new H(), o = new H(), c = new H(), l = new H(), h = new H(), u = new H();+ if (e)+ for (let d = 0, f = e.count; d < f; d += 3) {+ const m = e.getX(d + 0), A = e.getX(d + 1), g = e.getX(d + 2);+ s.fromBufferAttribute(t, m), r.fromBufferAttribute(t, A), a.fromBufferAttribute(t, g), h.subVectors(a, r), u.subVectors(s, r), h.cross(u), o.fromBufferAttribute(n, m), c.fromBufferAttribute(n, A), l.fromBufferAttribute(n, g), o.add(h), c.add(h), l.add(h), n.setXYZ(m, o.x, o.y, o.z), n.setXYZ(A, c.x, c.y, c.z), n.setXYZ(g, l.x, l.y, l.z);+ }+ else+ for (let d = 0, f = t.count; d < f; d += 3)+ s.fromBufferAttribute(t, d + 0), r.fromBufferAttribute(t, d + 1), a.fromBufferAttribute(t, d + 2), h.subVectors(a, r), u.subVectors(s, r), h.cross(u), n.setXYZ(d + 0, h.x, h.y, h.z), n.setXYZ(d + 1, h.x, h.y, h.z), n.setXYZ(d + 2, h.x, h.y, h.z);+ this.normalizeNormals(), n.needsUpdate = !0;+ }+ }+ /**+ * Ensures every normal vector in a geometry will have a magnitude of `1`. This will+ * correct lighting on the geometry surfaces.+ */+ normalizeNormals() {+ const e = this.attributes.normal;+ for (let t = 0, n = e.count; t < n; t++)+ An.fromBufferAttribute(e, t), An.normalize(), e.setXYZ(t, An.x, An.y, An.z);+ }+ /**+ * Return a new non-index version of this indexed geometry. If the geometry+ * is already non-indexed, the method is a NOOP.+ *+ * @return {BufferGeometry} The non-indexed version of this indexed geometry.+ */+ toNonIndexed() {+ function e(o, c) {+ const l = o.array, h = o.itemSize, u = o.normalized, d = new l.constructor(c.length * h);+ let f = 0, m = 0;+ for (let A = 0, g = c.length; A < g; A++) {+ o.isInterleavedBufferAttribute ? f = c[A] * o.data.stride + o.offset : f = c[A] * h;+ for (let p = 0; p < h; p++)+ d[m++] = l[f++];+ }+ return new En(d, h, u);+ }+ if (this.index === null)+ return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."), this;+ const t = new zn(), n = this.index.array, s = this.attributes;+ for (const o in s) {+ const c = s[o], l = e(c, n);+ t.setAttribute(o, l);+ }+ const r = this.morphAttributes;+ for (const o in r) {+ const c = [], l = r[o];+ for (let h = 0, u = l.length; h < u; h++) {+ const d = l[h], f = e(d, n);+ c.push(f);+ }+ t.morphAttributes[o] = c;+ }+ t.morphTargetsRelative = this.morphTargetsRelative;+ const a = this.groups;+ for (let o = 0, c = a.length; o < c; o++) {+ const l = a[o];+ t.addGroup(l.start, l.count, l.materialIndex);+ }+ return t;+ }+ /**+ * Serializes the geometry into JSON.+ *+ * @return {Object} A JSON object representing the serialized geometry.+ */+ toJSON() {+ const e = {+ metadata: {+ version: 4.6,+ type: "BufferGeometry",+ generator: "BufferGeometry.toJSON"+ }+ };+ if (e.uuid = this.uuid, e.type = this.type, this.name !== "" && (e.name = this.name), Object.keys(this.userData).length > 0 && (e.userData = this.userData), this.parameters !== void 0) {+ const c = this.parameters;+ for (const l in c)+ c[l] !== void 0 && (e[l] = c[l]);+ return e;+ }+ e.data = { attributes: {} };+ const t = this.index;+ t !== null && (e.data.index = {+ type: t.array.constructor.name,+ array: Array.prototype.slice.call(t.array)+ });+ const n = this.attributes;+ for (const c in n) {+ const l = n[c];+ e.data.attributes[c] = l.toJSON(e.data);+ }+ const s = {};+ let r = !1;+ for (const c in this.morphAttributes) {+ const l = this.morphAttributes[c], h = [];+ for (let u = 0, d = l.length; u < d; u++) {+ const f = l[u];+ h.push(f.toJSON(e.data));+ }+ h.length > 0 && (s[c] = h, r = !0);+ }+ r && (e.data.morphAttributes = s, e.data.morphTargetsRelative = this.morphTargetsRelative);+ const a = this.groups;+ a.length > 0 && (e.data.groups = JSON.parse(JSON.stringify(a)));+ const o = this.boundingSphere;+ return o !== null && (e.data.boundingSphere = {+ center: o.center.toArray(),+ radius: o.radius+ }), e;+ }+ /**+ * Returns a new geometry with copied values from this instance.+ *+ * @return {BufferGeometry} A clone of this instance.+ */+ clone() {+ return new this.constructor().copy(this);+ }+ /**+ * Copies the values of the given geometry to this instance.+ *+ * @param {BufferGeometry} source - The geometry to copy.+ * @return {BufferGeometry} A reference to this instance.+ */+ copy(e) {+ this.index = null, this.attributes = {}, this.morphAttributes = {}, this.groups = [], this.boundingBox = null, this.boundingSphere = null;+ const t = {};+ this.name = e.name;+ const n = e.index;+ n !== null && this.setIndex(n.clone());+ const s = e.attributes;+ for (const l in s) {+ const h = s[l];+ this.setAttribute(l, h.clone(t));+ }+ const r = e.morphAttributes;+ for (const l in r) {+ const h = [], u = r[l];+ for (let d = 0, f = u.length; d < f; d++)+ h.push(u[d].clone(t));+ this.morphAttributes[l] = h;+ }+ this.morphTargetsRelative = e.morphTargetsRelative;+ const a = e.groups;+ for (let l = 0, h = a.length; l < h; l++) {+ const u = a[l];+ this.addGroup(u.start, u.count, u.materialIndex);+ }+ const o = e.boundingBox;+ o !== null && (this.boundingBox = o.clone());+ const c = e.boundingSphere;+ return c !== null && (this.boundingSphere = c.clone()), this.drawRange.start = e.drawRange.start, this.drawRange.count = e.drawRange.count, this.userData = e.userData, this;+ }+ /**+ * Frees the GPU-related resources allocated by this instance. Call this+ * method whenever this instance is no longer used in your app.+ *+ * @fires BufferGeometry#dispose+ */+ dispose() {+ this.dispatchEvent({ type: "dispose" });+ }+}+const Np = /* @__PURE__ */ new et(), Ys = /* @__PURE__ */ new Jo(), yc = /* @__PURE__ */ new Ui(), Fp = /* @__PURE__ */ new H(), wc = /* @__PURE__ */ new H(), vc = /* @__PURE__ */ new H(), Cc = /* @__PURE__ */ new H(), Oh = /* @__PURE__ */ new H(), Sc = /* @__PURE__ */ new H(), Dp = /* @__PURE__ */ new H(), Ic = /* @__PURE__ */ new H();+class Jt extends kt {+ /**+ * Constructs a new mesh.+ *+ * @param {BufferGeometry} [geometry] - The mesh geometry.+ * @param {Material|Array<Material>} [material] - The mesh material.+ */+ constructor(e = new zn(), t = new Ns()) {+ super(), this.isMesh = !0, this.type = "Mesh", this.geometry = e, this.material = t, this.morphTargetDictionary = void 0, this.morphTargetInfluences = void 0, this.updateMorphTargets();+ }+ copy(e, t) {+ return super.copy(e, t), e.morphTargetInfluences !== void 0 && (this.morphTargetInfluences = e.morphTargetInfluences.slice()), e.morphTargetDictionary !== void 0 && (this.morphTargetDictionary = Object.assign({}, e.morphTargetDictionary)), this.material = Array.isArray(e.material) ? e.material.slice() : e.material, this.geometry = e.geometry, this;+ }+ /**+ * Sets the values of {@link Mesh#morphTargetDictionary} and {@link Mesh#morphTargetInfluences}+ * to make sure existing morph targets can influence this 3D object.+ */+ updateMorphTargets() {+ const t = this.geometry.morphAttributes, n = Object.keys(t);+ if (n.length > 0) {+ const s = t[n[0]];+ if (s !== void 0) {+ this.morphTargetInfluences = [], this.morphTargetDictionary = {};+ for (let r = 0, a = s.length; r < a; r++) {+ const o = s[r].name || String(r);+ this.morphTargetInfluences.push(0), this.morphTargetDictionary[o] = r;+ }+ }+ }+ }+ /**+ * Returns the local-space position of the vertex at the given index, taking into+ * account the current animation state of both morph targets and skinning.+ *+ * @param {number} index - The vertex index.+ * @param {Vector3} target - The target object that is used to store the method's result.+ * @return {Vector3} The vertex position in local space.+ */+ getVertexPosition(e, t) {+ const n = this.geometry, s = n.attributes.position, r = n.morphAttributes.position, a = n.morphTargetsRelative;+ t.fromBufferAttribute(s, e);+ const o = this.morphTargetInfluences;+ if (r && o) {+ Sc.set(0, 0, 0);+ for (let c = 0, l = r.length; c < l; c++) {+ const h = o[c], u = r[c];+ h !== 0 && (Oh.fromBufferAttribute(u, e), a ? Sc.addScaledVector(Oh, h) : Sc.addScaledVector(Oh.sub(t), h));+ }+ t.add(Sc);+ }+ return t;+ }+ /**+ * Computes intersection points between a casted ray and this line.+ *+ * @param {Raycaster} raycaster - The raycaster.+ * @param {Array<Object>} intersects - The target array that holds the intersection points.+ */+ raycast(e, t) {+ const n = this.geometry, s = this.material, r = this.matrixWorld;+ s !== void 0 && (n.boundingSphere === null && n.computeBoundingSphere(), yc.copy(n.boundingSphere), yc.applyMatrix4(r), Ys.copy(e.ray).recast(e.near), !(yc.containsPoint(Ys.origin) === !1 && (Ys.intersectSphere(yc, Fp) === null || Ys.origin.distanceToSquared(Fp) > (e.far - e.near) ** 2)) && (Np.copy(r).invert(), Ys.copy(e.ray).applyMatrix4(Np), !(n.boundingBox !== null && Ys.intersectsBox(n.boundingBox) === !1) && this._computeIntersections(e, t, Ys)));+ }+ _computeIntersections(e, t, n) {+ let s;+ const r = this.geometry, a = this.material, o = r.index, c = r.attributes.position, l = r.attributes.uv, h = r.attributes.uv1, u = r.attributes.normal, d = r.groups, f = r.drawRange;+ if (o !== null)+ if (Array.isArray(a))+ for (let m = 0, A = d.length; m < A; m++) {+ const g = d[m], p = a[g.materialIndex], y = Math.max(g.start, f.start), b = Math.min(o.count, Math.min(g.start + g.count, f.start + f.count));+ for (let E = y, M = b; E < M; E += 3) {+ const w = o.getX(E), S = o.getX(E + 1), T = o.getX(E + 2);+ s = Mc(this, p, e, n, l, h, u, w, S, T), s && (s.faceIndex = Math.floor(E / 3), s.face.materialIndex = g.materialIndex, t.push(s));+ }+ }+ else {+ const m = Math.max(0, f.start), A = Math.min(o.count, f.start + f.count);+ for (let g = m, p = A; g < p; g += 3) {+ const y = o.getX(g), b = o.getX(g + 1), E = o.getX(g + 2);+ s = Mc(this, a, e, n, l, h, u, y, b, E), s && (s.faceIndex = Math.floor(g / 3), t.push(s));+ }+ }+ else if (c !== void 0)+ if (Array.isArray(a))+ for (let m = 0, A = d.length; m < A; m++) {+ const g = d[m], p = a[g.materialIndex], y = Math.max(g.start, f.start), b = Math.min(c.count, Math.min(g.start + g.count, f.start + f.count));+ for (let E = y, M = b; E < M; E += 3) {+ const w = E, S = E + 1, T = E + 2;+ s = Mc(this, p, e, n, l, h, u, w, S, T), s && (s.faceIndex = Math.floor(E / 3), s.face.materialIndex = g.materialIndex, t.push(s));+ }+ }+ else {+ const m = Math.max(0, f.start), A = Math.min(c.count, f.start + f.count);+ for (let g = m, p = A; g < p; g += 3) {+ const y = g, b = g + 1, E = g + 2;+ s = Mc(this, a, e, n, l, h, u, y, b, E), s && (s.faceIndex = Math.floor(g / 3), t.push(s));+ }+ }+ }+}+function YE(i, e, t, n, s, r, a, o) {+ let c;+ if (e.side === Pn ? c = n.intersectTriangle(a, r, s, !0, o) : c = n.intersectTriangle(s, r, a, e.side === us, o), c === null) return null;+ Ic.copy(o), Ic.applyMatrix4(i.matrixWorld);+ const l = t.ray.origin.distanceTo(Ic);+ return l < t.near || l > t.far ? null : {+ distance: l,+ point: Ic.clone(),+ object: i+ };+}+function Mc(i, e, t, n, s, r, a, o, c, l) {+ i.getVertexPosition(o, wc), i.getVertexPosition(c, vc), i.getVertexPosition(l, Cc);+ const h = YE(i, e, t, n, wc, vc, Cc, Dp);+ if (h) {+ const u = new H();+ bi.getBarycoord(Dp, wc, vc, Cc, u), s && (h.uv = bi.getInterpolatedAttribute(s, o, c, l, u, new Ze())), r && (h.uv1 = bi.getInterpolatedAttribute(r, o, c, l, u, new Ze())), a && (h.normal = bi.getInterpolatedAttribute(a, o, c, l, u, new H()), h.normal.dot(n.direction) > 0 && h.normal.multiplyScalar(-1));+ const d = {+ a: o,+ b: c,+ c: l,+ normal: new H(),+ materialIndex: 0+ };+ bi.getNormal(wc, vc, Cc, d.normal), h.face = d, h.barycoord = u;+ }+ return h;+}+class Ua extends zn {+ /**+ * Constructs a new box geometry.+ *+ * @param {number} [width=1] - The width. That is, the length of the edges parallel to the X axis.+ * @param {number} [height=1] - The height. That is, the length of the edges parallel to the Y axis.+ * @param {number} [depth=1] - The depth. That is, the length of the edges parallel to the Z axis.+ * @param {number} [widthSegments=1] - Number of segmented rectangular faces along the width of the sides.+ * @param {number} [heightSegments=1] - Number of segmented rectangular faces along the height of the sides.+ * @param {number} [depthSegments=1] - Number of segmented rectangular faces along the depth of the sides.+ */+ constructor(e = 1, t = 1, n = 1, s = 1, r = 1, a = 1) {+ super(), this.type = "BoxGeometry", this.parameters = {+ width: e,+ height: t,+ depth: n,+ widthSegments: s,+ heightSegments: r,+ depthSegments: a+ };+ const o = this;+ s = Math.floor(s), r = Math.floor(r), a = Math.floor(a);+ const c = [], l = [], h = [], u = [];+ let d = 0, f = 0;+ m("z", "y", "x", -1, -1, n, t, e, a, r, 0), m("z", "y", "x", 1, -1, n, t, -e, a, r, 1), m("x", "z", "y", 1, 1, e, n, t, s, a, 2), m("x", "z", "y", 1, -1, e, n, -t, s, a, 3), m("x", "y", "z", 1, -1, e, t, n, s, r, 4), m("x", "y", "z", -1, -1, e, t, -n, s, r, 5), this.setIndex(c), this.setAttribute("position", new Un(l, 3)), this.setAttribute("normal", new Un(h, 3)), this.setAttribute("uv", new Un(u, 2));+ function m(A, g, p, y, b, E, M, w, S, T, C) {+ const v = E / S, F = M / T, K = E / 2, q = M / 2, $ = w / 2, D = S + 1, O = T + 1;+ let Y = 0, Q = 0;+ const J = new H();+ for (let ee = 0; ee < O; ee++) {+ const ae = ee * F - q;+ for (let ye = 0; ye < D; ye++) {+ const Me = ye * v - K;+ J[A] = Me * y, J[g] = ae * b, J[p] = $, l.push(J.x, J.y, J.z), J[A] = 0, J[g] = 0, J[p] = w > 0 ? 1 : -1, h.push(J.x, J.y, J.z), u.push(ye / S), u.push(1 - ee / T), Y += 1;+ }+ }+ for (let ee = 0; ee < T; ee++)+ for (let ae = 0; ae < S; ae++) {+ const ye = d + ae + D * ee, Me = d + ae + D * (ee + 1), se = d + (ae + 1) + D * (ee + 1), me = d + (ae + 1) + D * ee;+ c.push(ye, Me, me), c.push(Me, se, me), Q += 6;+ }+ o.addGroup(f, Q, C), f += Q, d += Y;+ }+ }+ copy(e) {+ return super.copy(e), this.parameters = Object.assign({}, e.parameters), this;+ }+ /**+ * Factory method for creating an instance of this class from the given+ * JSON object.+ *+ * @param {Object} data - A JSON object representing the serialized geometry.+ * @return {BoxGeometry} A new instance.+ */+ static fromJSON(e) {+ return new Ua(e.width, e.height, e.depth, e.widthSegments, e.heightSegments, e.depthSegments);+ }+}+function Ia(i) {+ const e = {};+ for (const t in i) {+ e[t] = {};+ for (const n in i[t]) {+ const s = i[t][n];+ s && (s.isColor || s.isMatrix3 || s.isMatrix4 || s.isVector2 || s.isVector3 || s.isVector4 || s.isTexture || s.isQuaternion) ? s.isRenderTargetTexture ? (console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."), e[t][n] = null) : e[t][n] = s.clone() : Array.isArray(s) ? e[t][n] = s.slice() : e[t][n] = s;+ }+ }+ return e;+}+function Bn(i) {+ const e = {};+ for (let t = 0; t < i.length; t++) {+ const n = Ia(i[t]);+ for (const s in n)+ e[s] = n[s];+ }+ return e;+}+function JE(i) {+ const e = [];+ for (let t = 0; t < i.length; t++)+ e.push(i[t].clone());+ return e;+}+function d0(i) {+ const e = i.getRenderTarget();+ return e === null ? i.outputColorSpace : e.isXRRenderTarget === !0 ? e.texture.colorSpace : mt.workingColorSpace;+}+const ZE = { clone: Ia, merge: Bn };+var $E = `void main() {+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );+}`, ey = `void main() {+ gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );+}`;+class Os extends Li {+ /**+ * Constructs a new shader material.+ *+ * @param {Object} [parameters] - An object with one or more properties+ * defining the material's appearance. Any property of the material+ * (including any property from inherited materials) can be passed+ * in here. Color values can be passed any type of value accepted+ * by {@link Color#set}.+ */+ constructor(e) {+ super(), this.isShaderMaterial = !0, this.type = "ShaderMaterial", this.defines = {}, this.uniforms = {}, this.uniformsGroups = [], this.vertexShader = $E, this.fragmentShader = ey, 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,+ // set to use vertex shader clipping+ multiDraw: !1+ // set to use vertex shader multi_draw / enable gl_DrawID+ }, 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 = Ia(e.uniforms), this.uniformsGroups = JE(e.uniformsGroups), this.defines = Object.assign({}, e.defines), this.wireframe = e.wireframe, this.wireframeLinewidth = e.wireframeLinewidth, this.fog = e.fog, this.lights = e.lights, this.clipping = e.clipping, this.extensions = Object.assign({}, e.extensions), this.glslVersion = e.glslVersion, this;+ }+ toJSON(e) {+ const t = super.toJSON(e);+ t.glslVersion = this.glslVersion, t.uniforms = {};+ for (const s in this.uniforms) {+ const a = this.uniforms[s].value;+ a && a.isTexture ? t.uniforms[s] = {+ type: "t",+ value: a.toJSON(e).uuid+ } : a && a.isColor ? t.uniforms[s] = {+ type: "c",+ value: a.getHex()+ } : a && a.isVector2 ? t.uniforms[s] = {+ type: "v2",+ value: a.toArray()+ } : a && a.isVector3 ? t.uniforms[s] = {+ type: "v3",+ value: a.toArray()+ } : a && a.isVector4 ? t.uniforms[s] = {+ type: "v4",+ value: a.toArray()+ } : a && a.isMatrix3 ? t.uniforms[s] = {+ type: "m3",+ value: a.toArray()+ } : a && a.isMatrix4 ? t.uniforms[s] = {+ type: "m4",+ value: a.toArray()+ } : t.uniforms[s] = {+ value: a+ };+ }+ 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;+ const n = {};+ for (const s in this.extensions)+ this.extensions[s] === !0 && (n[s] = !0);+ return Object.keys(n).length > 0 && (t.extensions = n), t;+ }+}+class f0 extends kt {+ /**+ * Constructs a new camera.+ */+ constructor() {+ super(), this.isCamera = !0, this.type = "Camera", this.matrixWorldInverse = new et(), this.projectionMatrix = new et(), this.projectionMatrixInverse = new et(), this.coordinateSystem = is;+ }+ 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;+ }+ /**+ * Returns a vector representing the ("look") direction of the 3D object in world space.+ *+ * This method is overwritten since cameras have a different forward vector compared to other+ * 3D objects. A camera looks down its local, negative z-axis by default.+ *+ * @param {Vector3} target - The target vector the result is stored to.+ * @return {Vector3} The 3D object's direction in world space.+ */+ getWorldDirection(e) {+ return super.getWorldDirection(e).negate();+ }+ updateMatrixWorld(e) {+ super.updateMatrixWorld(e), this.matrixWorldInverse.copy(this.matrixWorld).invert();+ }+ updateWorldMatrix(e, t) {+ super.updateWorldMatrix(e, t), this.matrixWorldInverse.copy(this.matrixWorld).invert();+ }+ clone() {+ return new this.constructor().copy(this);+ }+}+const ys = /* @__PURE__ */ new H(), Lp = /* @__PURE__ */ new Ze(), Pp = /* @__PURE__ */ new Ze();+class vn extends f0 {+ /**+ * Constructs a new perspective camera.+ *+ * @param {number} [fov=50] - The vertical field of view.+ * @param {number} [aspect=1] - The aspect ratio.+ * @param {number} [near=0.1] - The camera's near plane.+ * @param {number} [far=2000] - The camera's far plane.+ */+ constructor(e = 50, t = 1, n = 0.1, s = 2e3) {+ super(), this.isPerspectiveCamera = !0, this.type = "PerspectiveCamera", this.fov = e, this.zoom = 1, this.near = n, this.far = s, 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;+ }+ /**+ * Sets the FOV by focal length in respect to the current {@link PerspectiveCamera#filmGauge}.+ *+ * The default film gauge is 35, so that the focal length can be specified for+ * a 35mm (full frame) camera.+ *+ * @param {number} focalLength - Values for focal length and film gauge must have the same unit.+ */+ setFocalLength(e) {+ const t = 0.5 * this.getFilmHeight() / e;+ this.fov = Sa * 2 * Math.atan(t), this.updateProjectionMatrix();+ }+ /**+ * Returns the focal length from the current {@link PerspectiveCamera#fov} and+ * {@link PerspectiveCamera#filmGauge}.+ *+ * @return {number} The computed focal length.+ */+ getFocalLength() {+ const e = Math.tan(yo * 0.5 * this.fov);+ return 0.5 * this.getFilmHeight() / e;+ }+ /**+ * Returns the current vertical field of view angle in degrees considering {@link PerspectiveCamera#zoom}.+ *+ * @return {number} The effective FOV.+ */+ getEffectiveFOV() {+ return Sa * 2 * Math.atan(+ Math.tan(yo * 0.5 * this.fov) / this.zoom+ );+ }+ /**+ * Returns the width of the image on the film. If {@link PerspectiveCamera#aspect} is greater than or+ * equal to one (landscape format), the result equals {@link PerspectiveCamera#filmGauge}.+ *+ * @return {number} The film width.+ */+ getFilmWidth() {+ return this.filmGauge * Math.min(this.aspect, 1);+ }+ /**+ * Returns the height of the image on the film. If {@link PerspectiveCamera#aspect} is greater than or+ * equal to one (landscape format), the result equals {@link PerspectiveCamera#filmGauge}.+ *+ * @return {number} The film width.+ */+ getFilmHeight() {+ return this.filmGauge / Math.max(this.aspect, 1);+ }+ /**+ * Computes the 2D bounds of the camera's viewable rectangle at a given distance along the viewing direction.+ * Sets `minTarget` and `maxTarget` to the coordinates of the lower-left and upper-right corners of the view rectangle.+ *+ * @param {number} distance - The viewing distance.+ * @param {Vector2} minTarget - The lower-left corner of the view rectangle is written into this vector.+ * @param {Vector2} maxTarget - The upper-right corner of the view rectangle is written into this vector.+ */+ getViewBounds(e, t, n) {+ ys.set(-1, -1, 0.5).applyMatrix4(this.projectionMatrixInverse), t.set(ys.x, ys.y).multiplyScalar(-e / ys.z), ys.set(1, 1, 0.5).applyMatrix4(this.projectionMatrixInverse), n.set(ys.x, ys.y).multiplyScalar(-e / ys.z);+ }+ /**+ * Computes the width and height of the camera's viewable rectangle at a given distance along the viewing direction.+ *+ * @param {number} distance - The viewing distance.+ * @param {Vector2} target - The target vector that is used to store result where x is width and y is height.+ * @returns {Vector2} The view size.+ */+ getViewSize(e, t) {+ return this.getViewBounds(e, Lp, Pp), t.subVectors(Pp, Lp);+ }+ /**+ * Sets an offset in a larger frustum. This is useful for multi-window or+ * multi-monitor/multi-machine setups.+ *+ * For example, if you have 3x2 monitors and each monitor is 1920x1080 and+ * the monitors are in grid like this+ *```+ * +---+---+---++ * | A | B | C |+ * +---+---+---++ * | D | E | F |+ * +---+---+---++ *```+ * then for each monitor you would call it like this:+ *```js+ * const w = 1920;+ * const h = 1080;+ * const fullWidth = w * 3;+ * const fullHeight = h * 2;+ *+ * // --A--+ * camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 0, w, h );+ * // --B--+ * camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 0, w, h );+ * // --C--+ * camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 0, w, h );+ * // --D--+ * camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 1, w, h );+ * // --E--+ * camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 1, w, h );+ * // --F--+ * camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 1, w, h );+ * ```+ *+ * Note there is no reason monitors have to be the same size or in a grid.+ *+ * @param {number} fullWidth - The full width of multiview setup.+ * @param {number} fullHeight - The full height of multiview setup.+ * @param {number} x - The horizontal offset of the subcamera.+ * @param {number} y - The vertical offset of the subcamera.+ * @param {number} width - The width of subcamera.+ * @param {number} height - The height of subcamera.+ */+ setViewOffset(e, t, n, s, r, 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 = s, this.view.width = r, this.view.height = a, this.updateProjectionMatrix();+ }+ /**+ * Removes the view offset from the projection matrix.+ */+ clearViewOffset() {+ this.view !== null && (this.view.enabled = !1), this.updateProjectionMatrix();+ }+ /**+ * Updates the camera's projection matrix. Must be called after any change of+ * camera properties.+ */+ updateProjectionMatrix() {+ const e = this.near;+ let t = e * Math.tan(yo * 0.5 * this.fov) / this.zoom, n = 2 * t, s = this.aspect * n, r = -0.5 * s;+ const a = this.view;+ if (this.view !== null && this.view.enabled) {+ const c = a.fullWidth, l = a.fullHeight;+ r += a.offsetX * s / c, t -= a.offsetY * n / l, s *= a.width / c, n *= a.height / l;+ }+ const o = this.filmOffset;+ o !== 0 && (r += e * o / this.getFilmWidth()), this.projectionMatrix.makePerspective(r, r + s, t, t - n, e, this.far, this.coordinateSystem), this.projectionMatrixInverse.copy(this.projectionMatrix).invert();+ }+ toJSON(e) {+ const 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;+ }+}+const qr = -90, Kr = 1;+class ty extends kt {+ /**+ * Constructs a new cube camera.+ *+ * @param {number} near - The camera's near plane.+ * @param {number} far - The camera's far plane.+ * @param {WebGLCubeRenderTarget} renderTarget - The cube render target.+ */+ constructor(e, t, n) {+ super(), this.type = "CubeCamera", this.renderTarget = n, this.coordinateSystem = null, this.activeMipmapLevel = 0;+ const s = new vn(qr, Kr, e, t);+ s.layers = this.layers, this.add(s);+ const r = new vn(qr, Kr, e, t);+ r.layers = this.layers, this.add(r);+ const a = new vn(qr, Kr, e, t);+ a.layers = this.layers, this.add(a);+ const o = new vn(qr, Kr, e, t);+ o.layers = this.layers, this.add(o);+ const c = new vn(qr, Kr, e, t);+ c.layers = this.layers, this.add(c);+ const l = new vn(qr, Kr, e, t);+ l.layers = this.layers, this.add(l);+ }+ /**+ * Must be called when the coordinate system of the cube camera is changed.+ */+ updateCoordinateSystem() {+ const e = this.coordinateSystem, t = this.children.concat(), [n, s, r, a, o, c] = t;+ for (const l of t) this.remove(l);+ if (e === is)+ n.up.set(0, 1, 0), n.lookAt(1, 0, 0), s.up.set(0, 1, 0), s.lookAt(-1, 0, 0), r.up.set(0, 0, -1), r.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), c.up.set(0, 1, 0), c.lookAt(0, 0, -1);+ else if (e === Tl)+ n.up.set(0, -1, 0), n.lookAt(-1, 0, 0), s.up.set(0, -1, 0), s.lookAt(1, 0, 0), r.up.set(0, 0, 1), r.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), c.up.set(0, -1, 0), c.lookAt(0, 0, -1);+ else+ throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: " + e);+ for (const l of t)+ this.add(l), l.updateMatrixWorld();+ }+ /**+ * Calling this method will render the given scene with the given renderer+ * into the cube render target of the camera.+ *+ * @param {(Renderer|WebGLRenderer)} renderer - The renderer.+ * @param {Scene} scene - The scene to render.+ */+ update(e, t) {+ this.parent === null && this.updateMatrixWorld();+ const { renderTarget: n, activeMipmapLevel: s } = this;+ this.coordinateSystem !== e.coordinateSystem && (this.coordinateSystem = e.coordinateSystem, this.updateCoordinateSystem());+ const [r, a, o, c, l, h] = this.children, u = e.getRenderTarget(), d = e.getActiveCubeFace(), f = e.getActiveMipmapLevel(), m = e.xr.enabled;+ e.xr.enabled = !1;+ const A = n.texture.generateMipmaps;+ n.texture.generateMipmaps = !1, e.setRenderTarget(n, 0, s), e.render(t, r), e.setRenderTarget(n, 1, s), e.render(t, a), e.setRenderTarget(n, 2, s), e.render(t, o), e.setRenderTarget(n, 3, s), e.render(t, c), e.setRenderTarget(n, 4, s), e.render(t, l), n.texture.generateMipmaps = A, e.setRenderTarget(n, 5, s), e.render(t, h), e.setRenderTarget(u, d, f), e.xr.enabled = m, n.texture.needsPMREMUpdate = !0;+ }+}+class p0 extends cn {+ /**+ * Constructs a new cube texture.+ *+ * @param {Array<Image>} [images=[]] - An array holding a image for each side of a cube.+ * @param {number} [mapping=CubeReflectionMapping] - The texture mapping.+ * @param {number} [wrapS=ClampToEdgeWrapping] - The wrapS value.+ * @param {number} [wrapT=ClampToEdgeWrapping] - The wrapT value.+ * @param {number} [magFilter=LinearFilter] - The mag filter value.+ * @param {number} [minFilter=LinearMipmapLinearFilter] - The min filter value.+ * @param {number} [format=RGBAFormat] - The texture format.+ * @param {number} [type=UnsignedByteType] - The texture type.+ * @param {number} [anisotropy=Texture.DEFAULT_ANISOTROPY] - The anisotropy value.+ * @param {string} [colorSpace=NoColorSpace] - The color space value.+ */+ constructor(e = [], t = Er, n, s, r, a, o, c, l, h) {+ super(e, t, n, s, r, a, o, c, l, h), this.isCubeTexture = !0, this.flipY = !1;+ }+ /**+ * Alias for {@link CubeTexture#image}.+ *+ * @type {Array<Image>}+ */+ get images() {+ return this.image;+ }+ set images(e) {+ this.image = e;+ }+}+class ny extends wr {+ /**+ * Constructs a new cube render target.+ *+ * @param {number} [size=1] - The size of the render target.+ * @param {RenderTarget~Options} [options] - The configuration object.+ */+ constructor(e = 1, t = {}) {+ super(e, e, t), this.isWebGLCubeRenderTarget = !0;+ const n = { width: e, height: e, depth: 1 }, s = [n, n, n, n, n, n];+ this.texture = new p0(s, t.mapping, t.wrapS, t.wrapT, t.magFilter, t.minFilter, t.format, t.type, t.anisotropy, t.colorSpace), this.texture.isRenderTargetTexture = !0, this.texture.generateMipmaps = t.generateMipmaps !== void 0 ? t.generateMipmaps : !1, this.texture.minFilter = t.minFilter !== void 0 ? t.minFilter : qt;+ }+ /**+ * Converts the given equirectangular texture to a cube map.+ *+ * @param {WebGLRenderer} renderer - The renderer.+ * @param {Texture} texture - The equirectangular texture.+ * @return {WebGLCubeRenderTarget} A reference to this cube render target.+ */+ 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;+ const n = {+ uniforms: {+ tEquirect: { value: null }+ },+ vertexShader: (+ /* glsl */+ `++ varying vec3 vWorldDirection;++ vec3 transformDirection( in vec3 dir, in mat4 matrix ) {++ return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );++ }++ void main() {++ vWorldDirection = transformDirection( position, modelMatrix );++ #include <begin_vertex>+ #include <project_vertex>++ }+ `+ ),+ fragmentShader: (+ /* glsl */+ `++ uniform sampler2D tEquirect;++ varying vec3 vWorldDirection;++ #include <common>++ void main() {++ vec3 direction = normalize( vWorldDirection );++ vec2 sampleUV = equirectUv( direction );++ gl_FragColor = texture2D( tEquirect, sampleUV );++ }+ `+ )+ }, s = new Ua(5, 5, 5), r = new Os({+ name: "CubemapFromEquirect",+ uniforms: Ia(n.uniforms),+ vertexShader: n.vertexShader,+ fragmentShader: n.fragmentShader,+ side: Pn,+ blending: Ds+ });+ r.uniforms.tEquirect.value = t;+ const a = new Jt(s, r), o = t.minFilter;+ return t.minFilter === si && (t.minFilter = qt), new ty(1, 10, this).update(e, a), t.minFilter = o, a.geometry.dispose(), a.material.dispose(), this;+ }+ /**+ * Clears this cube render target.+ *+ * @param {WebGLRenderer} renderer - The renderer.+ * @param {boolean} [color=true] - Whether the color buffer should be cleared or not.+ * @param {boolean} [depth=true] - Whether the depth buffer should be cleared or not.+ * @param {boolean} [stencil=true] - Whether the stencil buffer should be cleared or not.+ */+ clear(e, t = !0, n = !0, s = !0) {+ const r = e.getRenderTarget();+ for (let a = 0; a < 6; a++)+ e.setRenderTarget(this, a), e.clear(t, n, s);+ e.setRenderTarget(r);+ }+}+class fr extends kt {+ constructor() {+ super(), this.isGroup = !0, this.type = "Group";+ }+}+const iy = { type: "move" };+class Qh {+ /**+ * Constructs a new XR controller.+ */+ constructor() {+ this._targetRay = null, this._grip = null, this._hand = null;+ }+ /**+ * Returns a group representing the hand space of the XR controller.+ *+ * @return {Group} A group representing the hand space of the XR controller.+ */+ getHandSpace() {+ return this._hand === null && (this._hand = new fr(), this._hand.matrixAutoUpdate = !1, this._hand.visible = !1, this._hand.joints = {}, this._hand.inputState = { pinching: !1 }), this._hand;+ }+ /**+ * Returns a group representing the target ray space of the XR controller.+ *+ * @return {Group} A group representing the target ray space of the XR controller.+ */+ getTargetRaySpace() {+ return this._targetRay === null && (this._targetRay = new fr(), this._targetRay.matrixAutoUpdate = !1, this._targetRay.visible = !1, this._targetRay.hasLinearVelocity = !1, this._targetRay.linearVelocity = new H(), this._targetRay.hasAngularVelocity = !1, this._targetRay.angularVelocity = new H()), this._targetRay;+ }+ /**+ * Returns a group representing the grip space of the XR controller.+ *+ * @return {Group} A group representing the grip space of the XR controller.+ */+ getGripSpace() {+ return this._grip === null && (this._grip = new fr(), this._grip.matrixAutoUpdate = !1, this._grip.visible = !1, this._grip.hasLinearVelocity = !1, this._grip.linearVelocity = new H(), this._grip.hasAngularVelocity = !1, this._grip.angularVelocity = new H()), this._grip;+ }+ /**+ * Dispatches the given event to the groups representing+ * the different coordinate spaces of the XR controller.+ *+ * @param {Object} event - The event to dispatch.+ * @return {WebXRController} A reference to this instance.+ */+ 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;+ }+ /**+ * Connects the controller with the given XR input source.+ *+ * @param {XRInputSource} inputSource - The input source.+ * @return {WebXRController} A reference to this instance.+ */+ connect(e) {+ if (e && e.hand) {+ const t = this._hand;+ if (t)+ for (const n of e.hand.values())+ this._getHandJoint(t, n);+ }+ return this.dispatchEvent({ type: "connected", data: e }), this;+ }+ /**+ * Disconnects the controller from the given XR input source.+ *+ * @param {XRInputSource} inputSource - The input source.+ * @return {WebXRController} A reference to this instance.+ */+ 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;+ }+ /**+ * Updates the controller with the given input source, XR frame and reference space.+ * This updates the transformations of the groups that represent the different+ * coordinate systems of the controller.+ *+ * @param {XRInputSource} inputSource - The input source.+ * @param {XRFrame} frame - The XR frame.+ * @param {XRReferenceSpace} referenceSpace - The reference space.+ * @return {WebXRController} A reference to this instance.+ */+ update(e, t, n) {+ let s = null, r = null, a = null;+ const o = this._targetRay, c = this._grip, l = this._hand;+ if (e && t.session.visibilityState !== "visible-blurred") {+ if (l && e.hand) {+ a = !0;+ for (const A of e.hand.values()) {+ const g = t.getJointPose(A, n), p = this._getHandJoint(l, A);+ g !== null && (p.matrix.fromArray(g.transform.matrix), p.matrix.decompose(p.position, p.rotation, p.scale), p.matrixWorldNeedsUpdate = !0, p.jointRadius = g.radius), p.visible = g !== null;+ }+ const h = l.joints["index-finger-tip"], u = l.joints["thumb-tip"], d = h.position.distanceTo(u.position), f = 0.02, m = 5e-3;+ l.inputState.pinching && d > f + m ? (l.inputState.pinching = !1, this.dispatchEvent({+ type: "pinchend",+ handedness: e.handedness,+ target: this+ })) : !l.inputState.pinching && d <= f - m && (l.inputState.pinching = !0, this.dispatchEvent({+ type: "pinchstart",+ handedness: e.handedness,+ target: this+ }));+ } else+ c !== null && e.gripSpace && (r = t.getPose(e.gripSpace, n), r !== null && (c.matrix.fromArray(r.transform.matrix), c.matrix.decompose(c.position, c.rotation, c.scale), c.matrixWorldNeedsUpdate = !0, r.linearVelocity ? (c.hasLinearVelocity = !0, c.linearVelocity.copy(r.linearVelocity)) : c.hasLinearVelocity = !1, r.angularVelocity ? (c.hasAngularVelocity = !0, c.angularVelocity.copy(r.angularVelocity)) : c.hasAngularVelocity = !1));+ o !== null && (s = t.getPose(e.targetRaySpace, n), s === null && r !== null && (s = r), s !== null && (o.matrix.fromArray(s.transform.matrix), o.matrix.decompose(o.position, o.rotation, o.scale), o.matrixWorldNeedsUpdate = !0, s.linearVelocity ? (o.hasLinearVelocity = !0, o.linearVelocity.copy(s.linearVelocity)) : o.hasLinearVelocity = !1, s.angularVelocity ? (o.hasAngularVelocity = !0, o.angularVelocity.copy(s.angularVelocity)) : o.hasAngularVelocity = !1, this.dispatchEvent(iy)));+ }+ return o !== null && (o.visible = s !== null), c !== null && (c.visible = r !== null), l !== null && (l.visible = a !== null), this;+ }+ /**+ * Returns a group representing the hand joint for the given input joint.+ *+ * @private+ * @param {Group} hand - The group representing the hand space.+ * @param {XRJointSpace} inputjoint - The hand joint data.+ * @return {Group} A group representing the hand joint for the given input joint.+ */+ _getHandJoint(e, t) {+ if (e.joints[t.jointName] === void 0) {+ const n = new fr();+ n.matrixAutoUpdate = !1, n.visible = !1, e.joints[t.jointName] = n, e.add(n);+ }+ return e.joints[t.jointName];+ }+}+class _d extends kt {+ /**+ * Constructs a new scene.+ */+ 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 Pi(), this.environmentIntensity = 1, this.environmentRotation = new Pi(), this.overrideMaterial = null, typeof __THREE_DEVTOOLS__ < "u" && __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe", { detail: this }));+ }+ copy(e, t) {+ return super.copy(e, t), e.background !== null && (this.background = e.background.clone()), e.environment !== null && (this.environment = e.environment.clone()), e.fog !== null && (this.fog = e.fog.clone()), this.backgroundBlurriness = e.backgroundBlurriness, this.backgroundIntensity = e.backgroundIntensity, this.backgroundRotation.copy(e.backgroundRotation), this.environmentIntensity = e.environmentIntensity, this.environmentRotation.copy(e.environmentRotation), e.overrideMaterial !== null && (this.overrideMaterial = e.overrideMaterial.clone()), this.matrixAutoUpdate = e.matrixAutoUpdate, this;+ }+ toJSON(e) {+ const t = super.toJSON(e);+ return this.fog !== null && (t.object.fog = this.fog.toJSON()), this.backgroundBlurriness > 0 && (t.object.backgroundBlurriness = this.backgroundBlurriness), this.backgroundIntensity !== 1 && (t.object.backgroundIntensity = this.backgroundIntensity), t.object.backgroundRotation = this.backgroundRotation.toArray(), this.environmentIntensity !== 1 && (t.object.environmentIntensity = this.environmentIntensity), t.object.environmentRotation = this.environmentRotation.toArray(), t;+ }+}+class sy {+ /**+ * Constructs a new interleaved buffer.+ *+ * @param {TypedArray} array - A typed array with a shared buffer storing attribute data.+ * @param {number} stride - The number of typed-array elements per vertex.+ */+ constructor(e, t) {+ this.isInterleavedBuffer = !0, this.array = e, this.stride = t, this.count = e !== void 0 ? e.length / t : 0, this.usage = xd, this.updateRanges = [], this.version = 0, this.uuid = Ei();+ }+ /**+ * A callback function that is executed after the renderer has transferred the attribute array+ * data to the GPU.+ */+ onUploadCallback() {+ }+ /**+ * Flag to indicate that this attribute has changed and should be re-sent to+ * the GPU. Set this to `true` when you modify the value of the array.+ *+ * @type {number}+ * @default false+ * @param {boolean} value+ */+ set needsUpdate(e) {+ e === !0 && this.version++;+ }+ /**+ * Sets the usage of this interleaved buffer.+ *+ * @param {(StaticDrawUsage|DynamicDrawUsage|StreamDrawUsage|StaticReadUsage|DynamicReadUsage|StreamReadUsage|StaticCopyUsage|DynamicCopyUsage|StreamCopyUsage)} value - The usage to set.+ * @return {InterleavedBuffer} A reference to this interleaved buffer.+ */+ setUsage(e) {+ return this.usage = e, this;+ }+ /**+ * Adds a range of data in the data array to be updated on the GPU.+ *+ * @param {number} start - Position at which to start update.+ * @param {number} count - The number of components to update.+ */+ addUpdateRange(e, t) {+ this.updateRanges.push({ start: e, count: t });+ }+ /**+ * Clears the update ranges.+ */+ clearUpdateRanges() {+ this.updateRanges.length = 0;+ }+ /**+ * Copies the values of the given interleaved buffer to this instance.+ *+ * @param {InterleavedBuffer} source - The interleaved buffer to copy.+ * @return {InterleavedBuffer} A reference to this instance.+ */+ copy(e) {+ return this.array = new e.array.constructor(e.array), this.count = e.count, this.stride = e.stride, this.usage = e.usage, this;+ }+ /**+ * Copies a vector from the given interleaved buffer to this one. The start+ * and destination position in the attribute buffers are represented by the+ * given indices.+ *+ * @param {number} index1 - The destination index into this interleaved buffer.+ * @param {InterleavedBuffer} interleavedBuffer - The interleaved buffer to copy from.+ * @param {number} index2 - The source index into the given interleaved buffer.+ * @return {InterleavedBuffer} A reference to this instance.+ */+ copyAt(e, t, n) {+ e *= this.stride, n *= t.stride;+ for (let s = 0, r = this.stride; s < r; s++)+ this.array[e + s] = t.array[n + s];+ return this;+ }+ /**+ * Sets the given array data in the interleaved buffer.+ *+ * @param {(TypedArray|Array)} value - The array data to set.+ * @param {number} [offset=0] - The offset in this interleaved buffer's array.+ * @return {InterleavedBuffer} A reference to this instance.+ */+ set(e, t = 0) {+ return this.array.set(e, t), this;+ }+ /**+ * Returns a new interleaved buffer with copied values from this instance.+ *+ * @param {Object} [data] - An object with shared array buffers that allows to retain shared structures.+ * @return {InterleavedBuffer} A clone of this instance.+ */+ clone(e) {+ e.arrayBuffers === void 0 && (e.arrayBuffers = {}), this.array.buffer._uuid === void 0 && (this.array.buffer._uuid = Ei()), e.arrayBuffers[this.array.buffer._uuid] === void 0 && (e.arrayBuffers[this.array.buffer._uuid] = this.array.slice(0).buffer);+ const t = new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]), n = new this.constructor(t, this.stride);+ return n.setUsage(this.usage), n;+ }+ /**+ * Sets the given callback function that is executed after the Renderer has transferred+ * the array data to the GPU. Can be used to perform clean-up operations after+ * the upload when data are not needed anymore on the CPU side.+ *+ * @param {Function} callback - The `onUpload()` callback.+ * @return {InterleavedBuffer} A reference to this instance.+ */+ onUpload(e) {+ return this.onUploadCallback = e, this;+ }+ /**+ * Serializes the interleaved buffer into JSON.+ *+ * @param {Object} [data] - An optional value holding meta information about the serialization.+ * @return {Object} A JSON object representing the serialized interleaved buffer.+ */+ toJSON(e) {+ return e.arrayBuffers === void 0 && (e.arrayBuffers = {}), this.array.buffer._uuid === void 0 && (this.array.buffer._uuid = Ei()), e.arrayBuffers[this.array.buffer._uuid] === void 0 && (e.arrayBuffers[this.array.buffer._uuid] = Array.from(new Uint32Array(this.array.buffer))), {+ uuid: this.uuid,+ buffer: this.array.buffer._uuid,+ type: this.array.constructor.name,+ stride: this.stride+ };+ }+}+const Sn = /* @__PURE__ */ new H();+class yf {+ /**+ * Constructs a new interleaved buffer attribute.+ *+ * @param {InterleavedBuffer} interleavedBuffer - The buffer holding the interleaved data.+ * @param {number} itemSize - The item size.+ * @param {number} offset - The attribute offset into the buffer.+ * @param {boolean} [normalized=false] - Whether the data are normalized or not.+ */+ constructor(e, t, n, s = !1) {+ this.isInterleavedBufferAttribute = !0, this.name = "", this.data = e, this.itemSize = t, this.offset = n, this.normalized = s;+ }+ /**+ * The item count of this buffer attribute.+ *+ * @type {number}+ * @readonly+ */+ get count() {+ return this.data.count;+ }+ /**+ * The array holding the interleaved buffer attribute data.+ *+ * @type {TypedArray}+ */+ get array() {+ return this.data.array;+ }+ /**+ * Flag to indicate that this attribute has changed and should be re-sent to+ * the GPU. Set this to `true` when you modify the value of the array.+ *+ * @type {number}+ * @default false+ * @param {boolean} value+ */+ set needsUpdate(e) {+ this.data.needsUpdate = e;+ }+ /**+ * Applies the given 4x4 matrix to the given attribute. Only works with+ * item size `3`.+ *+ * @param {Matrix4} m - The matrix to apply.+ * @return {InterleavedBufferAttribute} A reference to this instance.+ */+ applyMatrix4(e) {+ for (let t = 0, n = this.data.count; t < n; t++)+ Sn.fromBufferAttribute(this, t), Sn.applyMatrix4(e), this.setXYZ(t, Sn.x, Sn.y, Sn.z);+ return this;+ }+ /**+ * Applies the given 3x3 normal matrix to the given attribute. Only works with+ * item size `3`.+ *+ * @param {Matrix3} m - The normal matrix to apply.+ * @return {InterleavedBufferAttribute} A reference to this instance.+ */+ applyNormalMatrix(e) {+ for (let t = 0, n = this.count; t < n; t++)+ Sn.fromBufferAttribute(this, t), Sn.applyNormalMatrix(e), this.setXYZ(t, Sn.x, Sn.y, Sn.z);+ return this;+ }+ /**+ * Applies the given 4x4 matrix to the given attribute. Only works with+ * item size `3` and with direction vectors.+ *+ * @param {Matrix4} m - The matrix to apply.+ * @return {InterleavedBufferAttribute} A reference to this instance.+ */+ transformDirection(e) {+ for (let t = 0, n = this.count; t < n; t++)+ Sn.fromBufferAttribute(this, t), Sn.transformDirection(e), this.setXYZ(t, Sn.x, Sn.y, Sn.z);+ return this;+ }+ /**+ * Returns the given component of the vector at the given index.+ *+ * @param {number} index - The index into the buffer attribute.+ * @param {number} component - The component index.+ * @return {number} The returned value.+ */+ getComponent(e, t) {+ let n = this.array[e * this.data.stride + this.offset + t];+ return this.normalized && (n = mi(n, this.array)), n;+ }+ /**+ * Sets the given value to the given component of the vector at the given index.+ *+ * @param {number} index - The index into the buffer attribute.+ * @param {number} component - The component index.+ * @param {number} value - The value to set.+ * @return {InterleavedBufferAttribute} A reference to this instance.+ */+ setComponent(e, t, n) {+ return this.normalized && (n = It(n, this.array)), this.data.array[e * this.data.stride + this.offset + t] = n, this;+ }+ /**+ * Sets the x component of the vector at the given index.+ *+ * @param {number} index - The index into the buffer attribute.+ * @param {number} x - The value to set.+ * @return {InterleavedBufferAttribute} A reference to this instance.+ */+ setX(e, t) {+ return this.normalized && (t = It(t, this.array)), this.data.array[e * this.data.stride + this.offset] = t, this;+ }+ /**+ * Sets the y component of the vector at the given index.+ *+ * @param {number} index - The index into the buffer attribute.+ * @param {number} y - The value to set.+ * @return {InterleavedBufferAttribute} A reference to this instance.+ */+ setY(e, t) {+ return this.normalized && (t = It(t, this.array)), this.data.array[e * this.data.stride + this.offset + 1] = t, this;+ }+ /**+ * Sets the z component of the vector at the given index.+ *+ * @param {number} index - The index into the buffer attribute.+ * @param {number} z - The value to set.+ * @return {InterleavedBufferAttribute} A reference to this instance.+ */+ setZ(e, t) {+ return this.normalized && (t = It(t, this.array)), this.data.array[e * this.data.stride + this.offset + 2] = t, this;+ }+ /**+ * Sets the w component of the vector at the given index.+ *+ * @param {number} index - The index into the buffer attribute.+ * @param {number} w - The value to set.+ * @return {InterleavedBufferAttribute} A reference to this instance.+ */+ setW(e, t) {+ return this.normalized && (t = It(t, this.array)), this.data.array[e * this.data.stride + this.offset + 3] = t, this;+ }+ /**+ * Returns the x component of the vector at the given index.+ *+ * @param {number} index - The index into the buffer attribute.+ * @return {number} The x component.+ */+ getX(e) {+ let t = this.data.array[e * this.data.stride + this.offset];+ return this.normalized && (t = mi(t, this.array)), t;+ }+ /**+ * Returns the y component of the vector at the given index.+ *+ * @param {number} index - The index into the buffer attribute.+ * @return {number} The y component.+ */+ getY(e) {+ let t = this.data.array[e * this.data.stride + this.offset + 1];+ return this.normalized && (t = mi(t, this.array)), t;+ }+ /**+ * Returns the z component of the vector at the given index.+ *+ * @param {number} index - The index into the buffer attribute.+ * @return {number} The z component.+ */+ getZ(e) {+ let t = this.data.array[e * this.data.stride + this.offset + 2];+ return this.normalized && (t = mi(t, this.array)), t;+ }+ /**+ * Returns the w component of the vector at the given index.+ *+ * @param {number} index - The index into the buffer attribute.+ * @return {number} The w component.+ */+ getW(e) {+ let t = this.data.array[e * this.data.stride + this.offset + 3];+ return this.normalized && (t = mi(t, this.array)), t;+ }+ /**+ * Sets the x and y component of the vector at the given index.+ *+ * @param {number} index - The index into the buffer attribute.+ * @param {number} x - The value for the x component to set.+ * @param {number} y - The value for the y component to set.+ * @return {InterleavedBufferAttribute} A reference to this instance.+ */+ setXY(e, t, n) {+ return e = e * this.data.stride + this.offset, this.normalized && (t = It(t, this.array), n = It(n, this.array)), this.data.array[e + 0] = t, this.data.array[e + 1] = n, this;+ }+ /**+ * Sets the x, y and z component of the vector at the given index.+ *+ * @param {number} index - The index into the buffer attribute.+ * @param {number} x - The value for the x component to set.+ * @param {number} y - The value for the y component to set.+ * @param {number} z - The value for the z component to set.+ * @return {InterleavedBufferAttribute} A reference to this instance.+ */+ setXYZ(e, t, n, s) {+ return e = e * this.data.stride + this.offset, this.normalized && (t = It(t, this.array), n = It(n, this.array), s = It(s, this.array)), this.data.array[e + 0] = t, this.data.array[e + 1] = n, this.data.array[e + 2] = s, this;+ }+ /**+ * Sets the x, y, z and w component of the vector at the given index.+ *+ * @param {number} index - The index into the buffer attribute.+ * @param {number} x - The value for the x component to set.+ * @param {number} y - The value for the y component to set.+ * @param {number} z - The value for the z component to set.+ * @param {number} w - The value for the w component to set.+ * @return {InterleavedBufferAttribute} A reference to this instance.+ */+ setXYZW(e, t, n, s, r) {+ return e = e * this.data.stride + this.offset, this.normalized && (t = It(t, this.array), n = It(n, this.array), s = It(s, this.array), r = It(r, this.array)), this.data.array[e + 0] = t, this.data.array[e + 1] = n, this.data.array[e + 2] = s, this.data.array[e + 3] = r, this;+ }+ /**+ * Returns a new buffer attribute with copied values from this instance.+ *+ * If no parameter is provided, cloning an interleaved buffer attribute will de-interleave buffer data.+ *+ * @param {Object} [data] - An object with interleaved buffers that allows to retain the interleaved property.+ * @return {BufferAttribute|InterleavedBufferAttribute} A clone of this instance.+ */+ clone(e) {+ if (e === void 0) {+ console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");+ const t = [];+ for (let n = 0; n < this.count; n++) {+ const s = n * this.data.stride + this.offset;+ for (let r = 0; r < this.itemSize; r++)+ t.push(this.data.array[s + r]);+ }+ return new En(new this.array.constructor(t), this.itemSize, this.normalized);+ } else+ return e.interleavedBuffers === void 0 && (e.interleavedBuffers = {}), e.interleavedBuffers[this.data.uuid] === void 0 && (e.interleavedBuffers[this.data.uuid] = this.data.clone(e)), new yf(e.interleavedBuffers[this.data.uuid], this.itemSize, this.offset, this.normalized);+ }+ /**+ * Serializes the buffer attribute into JSON.+ *+ * If no parameter is provided, cloning an interleaved buffer attribute will de-interleave buffer data.+ *+ * @param {Object} [data] - An optional value holding meta information about the serialization.+ * @return {Object} A JSON object representing the serialized buffer attribute.+ */+ toJSON(e) {+ if (e === void 0) {+ console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");+ const t = [];+ for (let n = 0; n < this.count; n++) {+ const s = n * this.data.stride + this.offset;+ for (let r = 0; r < this.itemSize; r++)+ t.push(this.data.array[s + r]);+ }+ return {+ itemSize: this.itemSize,+ type: this.array.constructor.name,+ array: t,+ normalized: this.normalized+ };+ } else+ return e.interleavedBuffers === void 0 && (e.interleavedBuffers = {}), e.interleavedBuffers[this.data.uuid] === void 0 && (e.interleavedBuffers[this.data.uuid] = this.data.toJSON(e)), {+ isInterleavedBufferAttribute: !0,+ itemSize: this.itemSize,+ data: this.data.uuid,+ offset: this.offset,+ normalized: this.normalized+ };+ }+}+const kp = /* @__PURE__ */ new H(), Up = /* @__PURE__ */ new wt(), Op = /* @__PURE__ */ new wt(), ry = /* @__PURE__ */ new H(), Qp = /* @__PURE__ */ new et(), Bc = /* @__PURE__ */ new H(), Gh = /* @__PURE__ */ new Ui(), Gp = /* @__PURE__ */ new et(), Hh = /* @__PURE__ */ new Jo();+class ay extends Jt {+ /**+ * Constructs a new skinned mesh.+ *+ * @param {BufferGeometry} [geometry] - The mesh geometry.+ * @param {Material|Array<Material>} [material] - The mesh material.+ */+ constructor(e, t) {+ super(e, t), this.isSkinnedMesh = !0, this.type = "SkinnedMesh", this.bindMode = Ap, this.bindMatrix = new et(), this.bindMatrixInverse = new et(), this.boundingBox = null, this.boundingSphere = null;+ }+ /**+ * Computes the bounding box of the skinned mesh, and updates {@link SkinnedMesh#boundingBox}.+ * The bounding box is not automatically computed by the engine; this method must be called by your app.+ * If the skinned mesh is animated, the bounding box should be recomputed per frame in order to reflect+ * the current animation state.+ */+ computeBoundingBox() {+ const e = this.geometry;+ this.boundingBox === null && (this.boundingBox = new yi()), this.boundingBox.makeEmpty();+ const t = e.getAttribute("position");+ for (let n = 0; n < t.count; n++)+ this.getVertexPosition(n, Bc), this.boundingBox.expandByPoint(Bc);+ }+ /**+ * Computes the bounding sphere of the skinned mesh, and updates {@link SkinnedMesh#boundingSphere}.+ * The bounding sphere is automatically computed by the engine once when it is needed, e.g., for ray casting+ * and view frustum culling. If the skinned mesh is animated, the bounding sphere should be recomputed+ * per frame in order to reflect the current animation state.+ */+ computeBoundingSphere() {+ const e = this.geometry;+ this.boundingSphere === null && (this.boundingSphere = new Ui()), this.boundingSphere.makeEmpty();+ const t = e.getAttribute("position");+ for (let n = 0; n < t.count; n++)+ this.getVertexPosition(n, Bc), this.boundingSphere.expandByPoint(Bc);+ }+ copy(e, t) {+ return super.copy(e, t), this.bindMode = e.bindMode, this.bindMatrix.copy(e.bindMatrix), this.bindMatrixInverse.copy(e.bindMatrixInverse), this.skeleton = e.skeleton, e.boundingBox !== null && (this.boundingBox = e.boundingBox.clone()), e.boundingSphere !== null && (this.boundingSphere = e.boundingSphere.clone()), this;+ }+ raycast(e, t) {+ const n = this.material, s = this.matrixWorld;+ n !== void 0 && (this.boundingSphere === null && this.computeBoundingSphere(), Gh.copy(this.boundingSphere), Gh.applyMatrix4(s), e.ray.intersectsSphere(Gh) !== !1 && (Gp.copy(s).invert(), Hh.copy(e.ray).applyMatrix4(Gp), !(this.boundingBox !== null && Hh.intersectsBox(this.boundingBox) === !1) && this._computeIntersections(e, t, Hh)));+ }+ getVertexPosition(e, t) {+ return super.getVertexPosition(e, t), this.applyBoneTransform(e, t), t;+ }+ /**+ * Binds the given skeleton to the skinned mesh.+ *+ * @param {Skeleton} skeleton - The skeleton to bind.+ * @param {Matrix4} [bindMatrix] - The bind matrix. If no bind matrix is provided,+ * the skinned mesh's world matrix will be used instead.+ */+ bind(e, t) {+ this.skeleton = e, t === void 0 && (this.updateMatrixWorld(!0), this.skeleton.calculateInverses(), t = this.matrixWorld), this.bindMatrix.copy(t), this.bindMatrixInverse.copy(t).invert();+ }+ /**+ * This method sets the skinned mesh in the rest pose).+ */+ pose() {+ this.skeleton.pose();+ }+ /**+ * Normalizes the skin weights which are defined as a buffer attribute+ * in the skinned mesh's geometry.+ */+ normalizeSkinWeights() {+ const e = new wt(), t = this.geometry.attributes.skinWeight;+ for (let n = 0, s = t.count; n < s; n++) {+ e.fromBufferAttribute(t, n);+ const r = 1 / e.manhattanLength();+ r !== 1 / 0 ? e.multiplyScalar(r) : e.set(1, 0, 0, 0), t.setXYZW(n, e.x, e.y, e.z, e.w);+ }+ }+ updateMatrixWorld(e) {+ super.updateMatrixWorld(e), this.bindMode === Ap ? this.bindMatrixInverse.copy(this.matrixWorld).invert() : this.bindMode === Z_ ? this.bindMatrixInverse.copy(this.bindMatrix).invert() : console.warn("THREE.SkinnedMesh: Unrecognized bindMode: " + this.bindMode);+ }+ /**+ * Applies the bone transform associated with the given index to the given+ * vertex position. Returns the updated vector.+ *+ * @param {number} index - The vertex index.+ * @param {Vector3} target - The target object that is used to store the method's result.+ * the skinned mesh's world matrix will be used instead.+ * @return {Vector3} The updated vertex position.+ */+ applyBoneTransform(e, t) {+ const n = this.skeleton, s = this.geometry;+ Up.fromBufferAttribute(s.attributes.skinIndex, e), Op.fromBufferAttribute(s.attributes.skinWeight, e), kp.copy(t).applyMatrix4(this.bindMatrix), t.set(0, 0, 0);+ for (let r = 0; r < 4; r++) {+ const a = Op.getComponent(r);+ if (a !== 0) {+ const o = Up.getComponent(r);+ Qp.multiplyMatrices(n.bones[o].matrixWorld, n.boneInverses[o]), t.addScaledVector(ry.copy(kp).applyMatrix4(Qp), a);+ }+ }+ return t.applyMatrix4(this.bindMatrixInverse);+ }+}+class A0 extends kt {+ /**+ * Constructs a new bone.+ */+ constructor() {+ super(), this.isBone = !0, this.type = "Bone";+ }+}+class Xl extends cn {+ /**+ * Constructs a new data texture.+ *+ * @param {?TypedArray} [data=null] - The buffer data.+ * @param {number} [width=1] - The width of the texture.+ * @param {number} [height=1] - The height of the texture.+ * @param {number} [format=RGBAFormat] - The texture format.+ * @param {number} [type=UnsignedByteType] - The texture type.+ * @param {number} [mapping=Texture.DEFAULT_MAPPING] - The texture mapping.+ * @param {number} [wrapS=ClampToEdgeWrapping] - The wrapS value.+ * @param {number} [wrapT=ClampToEdgeWrapping] - The wrapT value.+ * @param {number} [magFilter=NearestFilter] - The mag filter value.+ * @param {number} [minFilter=NearestFilter] - The min filter value.+ * @param {number} [anisotropy=Texture.DEFAULT_ANISOTROPY] - The anisotropy value.+ * @param {string} [colorSpace=NoColorSpace] - The color space.+ */+ constructor(e = null, t = 1, n = 1, s, r, a, o, c, l = kn, h = kn, u, d) {+ super(null, a, o, c, l, h, s, r, u, d), this.isDataTexture = !0, this.image = { data: e, width: t, height: n }, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1;+ }+}+const Hp = /* @__PURE__ */ new et(), oy = /* @__PURE__ */ new et();+class wf {+ /**+ * Constructs a new skeleton.+ *+ * @param {Array<Bone>} [bones] - An array of bones.+ * @param {Array<Matrix4>} [boneInverses] - An array of bone inverse matrices.+ * If not provided, these matrices will be computed automatically via {@link Skeleton#calculateInverses}.+ */+ constructor(e = [], t = []) {+ this.uuid = Ei(), this.bones = e.slice(0), this.boneInverses = t, this.boneMatrices = null, this.boneTexture = null, this.init();+ }+ /**+ * Initializes the skeleton. This method gets automatically called by the constructor+ * but depending on how the skeleton is created it might be necessary to call this method+ * manually.+ */+ init() {+ const e = this.bones, t = this.boneInverses;+ if (this.boneMatrices = new Float32Array(e.length * 16), t.length === 0)+ this.calculateInverses();+ else if (e.length !== t.length) {+ console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."), this.boneInverses = [];+ for (let n = 0, s = this.bones.length; n < s; n++)+ this.boneInverses.push(new et());+ }+ }+ /**+ * Computes the bone inverse matrices. This method resets {@link Skeleton#boneInverses}+ * and fills it with new matrices.+ */+ calculateInverses() {+ this.boneInverses.length = 0;+ for (let e = 0, t = this.bones.length; e < t; e++) {+ const n = new et();+ this.bones[e] && n.copy(this.bones[e].matrixWorld).invert(), this.boneInverses.push(n);+ }+ }+ /**+ * Resets the skeleton to the base pose.+ */+ pose() {+ for (let e = 0, t = this.bones.length; e < t; e++) {+ const n = this.bones[e];+ n && n.matrixWorld.copy(this.boneInverses[e]).invert();+ }+ for (let e = 0, t = this.bones.length; e < t; e++) {+ const n = this.bones[e];+ n && (n.parent && n.parent.isBone ? (n.matrix.copy(n.parent.matrixWorld).invert(), n.matrix.multiply(n.matrixWorld)) : n.matrix.copy(n.matrixWorld), n.matrix.decompose(n.position, n.quaternion, n.scale));+ }+ }+ /**+ * Resets the skeleton to the base pose.+ */+ update() {+ const e = this.bones, t = this.boneInverses, n = this.boneMatrices, s = this.boneTexture;+ for (let r = 0, a = e.length; r < a; r++) {+ const o = e[r] ? e[r].matrixWorld : oy;+ Hp.multiplyMatrices(o, t[r]), Hp.toArray(n, r * 16);+ }+ s !== null && (s.needsUpdate = !0);+ }+ /**+ * Returns a new skeleton with copied values from this instance.+ *+ * @return {Skeleton} A clone of this instance.+ */+ clone() {+ return new wf(this.bones, this.boneInverses);+ }+ /**+ * Computes a data texture for passing bone data to the vertex shader.+ *+ * @return {Skeleton} A reference of this instance.+ */+ computeBoneTexture() {+ let e = Math.sqrt(this.bones.length * 4);+ e = Math.ceil(e / 4) * 4, e = Math.max(e, 4);+ const t = new Float32Array(e * e * 4);+ t.set(this.boneMatrices);+ const n = new Xl(t, e, e, on, an);+ return n.needsUpdate = !0, this.boneMatrices = t, this.boneTexture = n, this;+ }+ /**+ * Searches through the skeleton's bone array and returns the first with a+ * matching name.+ *+ * @param {string} name - The name of the bone.+ * @return {Bone|undefined} The found bone. `undefined` if no bone has been found.+ */+ getBoneByName(e) {+ for (let t = 0, n = this.bones.length; t < n; t++) {+ const s = this.bones[t];+ if (s.name === e)+ return s;+ }+ }+ /**+ * Frees the GPU-related resources allocated by this instance. Call this+ * method whenever this instance is no longer used in your app.+ */+ dispose() {+ this.boneTexture !== null && (this.boneTexture.dispose(), this.boneTexture = null);+ }+ /**+ * Setups the skeleton by the given JSON and bones.+ *+ * @param {Object} json - The skeleton as serialized JSON.+ * @param {Object<string, Bone>} bones - An array of bones.+ * @return {Skeleton} A reference of this instance.+ */+ fromJSON(e, t) {+ this.uuid = e.uuid;+ for (let n = 0, s = e.bones.length; n < s; n++) {+ const r = e.bones[n];+ let a = t[r];+ a === void 0 && (console.warn("THREE.Skeleton: No bone found with UUID:", r), a = new A0()), this.bones.push(a), this.boneInverses.push(new et().fromArray(e.boneInverses[n]));+ }+ return this.init(), this;+ }+ /**+ * Serializes the skeleton into JSON.+ *+ * @return {Object} A JSON object representing the serialized skeleton.+ * @see {@link ObjectLoader#parse}+ */+ toJSON() {+ const e = {+ metadata: {+ version: 4.6,+ type: "Skeleton",+ generator: "Skeleton.toJSON"+ },+ bones: [],+ boneInverses: []+ };+ e.uuid = this.uuid;+ const t = this.bones, n = this.boneInverses;+ for (let s = 0, r = t.length; s < r; s++) {+ const a = t[s];+ e.bones.push(a.uuid);+ const o = n[s];+ e.boneInverses.push(o.toArray());+ }+ return e;+ }+}+class Ed extends En {+ /**+ * Constructs a new instanced buffer attribute.+ *+ * @param {TypedArray} array - The array holding the attribute data.+ * @param {number} itemSize - The item size.+ * @param {boolean} [normalized=false] - Whether the data are normalized or not.+ * @param {number} [meshPerAttribute=1] - How often a value of this buffer attribute should be repeated.+ */+ constructor(e, t, n, s = 1) {+ super(e, t, n), this.isInstancedBufferAttribute = !0, this.meshPerAttribute = s;+ }+ copy(e) {+ return super.copy(e), this.meshPerAttribute = e.meshPerAttribute, this;+ }+ toJSON() {+ const e = super.toJSON();+ return e.meshPerAttribute = this.meshPerAttribute, e.isInstancedBufferAttribute = !0, e;+ }+}+const jr = /* @__PURE__ */ new et(), zp = /* @__PURE__ */ new et(), Tc = [], Vp = /* @__PURE__ */ new yi(), cy = /* @__PURE__ */ new et(), $a = /* @__PURE__ */ new Jt(), eo = /* @__PURE__ */ new Ui();+class g0 extends Jt {+ /**+ * Constructs a new instanced mesh.+ *+ * @param {BufferGeometry} [geometry] - The mesh geometry.+ * @param {Material|Array<Material>} [material] - The mesh material.+ * @param {number} count - The number of instances.+ */+ constructor(e, t, n) {+ super(e, t), this.isInstancedMesh = !0, this.instanceMatrix = new Ed(new Float32Array(n * 16), 16), this.instanceColor = null, this.morphTexture = null, this.count = n, this.boundingBox = null, this.boundingSphere = null;+ for (let s = 0; s < n; s++)+ this.setMatrixAt(s, cy);+ }+ /**+ * Computes the bounding box of the instanced mesh, and updates {@link InstancedMesh#boundingBox}.+ * The bounding box is not automatically computed by the engine; this method must be called by your app.+ * You may need to recompute the bounding box if an instance is transformed via {@link InstancedMesh#setMatrixAt}.+ */+ computeBoundingBox() {+ const e = this.geometry, t = this.count;+ this.boundingBox === null && (this.boundingBox = new yi()), e.boundingBox === null && e.computeBoundingBox(), this.boundingBox.makeEmpty();+ for (let n = 0; n < t; n++)+ this.getMatrixAt(n, jr), Vp.copy(e.boundingBox).applyMatrix4(jr), this.boundingBox.union(Vp);+ }+ /**+ * Computes the bounding sphere of the instanced mesh, and updates {@link InstancedMesh#boundingSphere}+ * The engine automatically computes the bounding sphere when it is needed, e.g., for ray casting or view frustum culling.+ * You may need to recompute the bounding sphere if an instance is transformed via {@link InstancedMesh#setMatrixAt}.+ */+ computeBoundingSphere() {+ const e = this.geometry, t = this.count;+ this.boundingSphere === null && (this.boundingSphere = new Ui()), e.boundingSphere === null && e.computeBoundingSphere(), this.boundingSphere.makeEmpty();+ for (let n = 0; n < t; n++)+ this.getMatrixAt(n, jr), eo.copy(e.boundingSphere).applyMatrix4(jr), this.boundingSphere.union(eo);+ }+ copy(e, t) {+ return super.copy(e, t), this.instanceMatrix.copy(e.instanceMatrix), e.morphTexture !== null && (this.morphTexture = e.morphTexture.clone()), e.instanceColor !== null && (this.instanceColor = e.instanceColor.clone()), this.count = e.count, e.boundingBox !== null && (this.boundingBox = e.boundingBox.clone()), e.boundingSphere !== null && (this.boundingSphere = e.boundingSphere.clone()), this;+ }+ /**+ * Gets the color of the defined instance.+ *+ * @param {number} index - The instance index.+ * @param {Color} color - The target object that is used to store the method's result.+ */+ getColorAt(e, t) {+ t.fromArray(this.instanceColor.array, e * 3);+ }+ /**+ * Gets the local transformation matrix of the defined instance.+ *+ * @param {number} index - The instance index.+ * @param {Matrix4} matrix - The target object that is used to store the method's result.+ */+ getMatrixAt(e, t) {+ t.fromArray(this.instanceMatrix.array, e * 16);+ }+ /**+ * Gets the morph target weights of the defined instance.+ *+ * @param {number} index - The instance index.+ * @param {Mesh} object - The target object that is used to store the method's result.+ */+ getMorphAt(e, t) {+ const n = t.morphTargetInfluences, s = this.morphTexture.source.data.data, r = n.length + 1, a = e * r + 1;+ for (let o = 0; o < n.length; o++)+ n[o] = s[a + o];+ }+ raycast(e, t) {+ const n = this.matrixWorld, s = this.count;+ if ($a.geometry = this.geometry, $a.material = this.material, $a.material !== void 0 && (this.boundingSphere === null && this.computeBoundingSphere(), eo.copy(this.boundingSphere), eo.applyMatrix4(n), e.ray.intersectsSphere(eo) !== !1))+ for (let r = 0; r < s; r++) {+ this.getMatrixAt(r, jr), zp.multiplyMatrices(n, jr), $a.matrixWorld = zp, $a.raycast(e, Tc);+ for (let a = 0, o = Tc.length; a < o; a++) {+ const c = Tc[a];+ c.instanceId = r, c.object = this, t.push(c);+ }+ Tc.length = 0;+ }+ }+ /**+ * Sets the given color to the defined instance. Make sure you set the `needsUpdate` flag of+ * {@link InstancedMesh#instanceColor} to `true` after updating all the colors.+ *+ * @param {number} index - The instance index.+ * @param {Color} color - The instance color.+ */+ setColorAt(e, t) {+ this.instanceColor === null && (this.instanceColor = new Ed(new Float32Array(this.instanceMatrix.count * 3).fill(1), 3)), t.toArray(this.instanceColor.array, e * 3);+ }+ /**+ * Sets the given local transformation matrix to the defined instance. Make sure you set the `needsUpdate` flag of+ * {@link InstancedMesh#instanceMatrix} to `true` after updating all the colors.+ *+ * @param {number} index - The instance index.+ * @param {Matrix4} matrix - The local transformation.+ */+ setMatrixAt(e, t) {+ t.toArray(this.instanceMatrix.array, e * 16);+ }+ /**+ * Sets the morph target weights to the defined instance. Make sure you set the `needsUpdate` flag of+ * {@link InstancedMesh#morphTexture} to `true` after updating all the influences.+ *+ * @param {number} index - The instance index.+ * @param {Mesh} object - A mesh which `morphTargetInfluences` property containing the morph target weights+ * of a single instance.+ */+ setMorphAt(e, t) {+ const n = t.morphTargetInfluences, s = n.length + 1;+ this.morphTexture === null && (this.morphTexture = new Xl(new Float32Array(s * this.count), s, this.count, ns, an));+ const r = this.morphTexture.source.data.data;+ let a = 0;+ for (let l = 0; l < n.length; l++)+ a += n[l];+ const o = this.geometry.morphTargetsRelative ? 1 : 1 - a, c = s * e;+ r[c] = o, r.set(n, c + 1);+ }+ updateMorphTargets() {+ }+ /**+ * Frees the GPU-related resources allocated by this instance. Call this+ * method whenever this instance is no longer used in your app.+ */+ dispose() {+ this.dispatchEvent({ type: "dispose" }), this.morphTexture !== null && (this.morphTexture.dispose(), this.morphTexture = null);+ }+}+const zh = /* @__PURE__ */ new H(), ly = /* @__PURE__ */ new H(), hy = /* @__PURE__ */ new rt();+class Rs {+ /**+ * Constructs a new plane.+ *+ * @param {Vector3} [normal=(1,0,0)] - A unit length vector defining the normal of the plane.+ * @param {number} [constant=0] - The signed distance from the origin to the plane.+ */+ constructor(e = new H(1, 0, 0), t = 0) {+ this.isPlane = !0, this.normal = e, this.constant = t;+ }+ /**+ * Sets the plane components by copying the given values.+ *+ * @param {Vector3} normal - The normal.+ * @param {number} constant - The constant.+ * @return {Plane} A reference to this plane.+ */+ set(e, t) {+ return this.normal.copy(e), this.constant = t, this;+ }+ /**+ * Sets the plane components by defining `x`, `y`, `z` as the+ * plane normal and `w` as the constant.+ *+ * @param {number} x - The value for the normal's x component.+ * @param {number} y - The value for the normal's y component.+ * @param {number} z - The value for the normal's z component.+ * @param {number} w - The constant value.+ * @return {Plane} A reference to this plane.+ */+ setComponents(e, t, n, s) {+ return this.normal.set(e, t, n), this.constant = s, this;+ }+ /**+ * Sets the plane from the given normal and coplanar point (that is a point+ * that lies onto the plane).+ *+ * @param {Vector3} normal - The normal.+ * @param {Vector3} point - A coplanar point.+ * @return {Plane} A reference to this plane.+ */+ setFromNormalAndCoplanarPoint(e, t) {+ return this.normal.copy(e), this.constant = -t.dot(this.normal), this;+ }+ /**+ * Sets the plane from three coplanar points. The winding order is+ * assumed to be counter-clockwise, and determines the direction of+ * the plane normal.+ *+ * @param {Vector3} a - The first coplanar point.+ * @param {Vector3} b - The second coplanar point.+ * @param {Vector3} c - The third coplanar point.+ * @return {Plane} A reference to this plane.+ */+ setFromCoplanarPoints(e, t, n) {+ const s = zh.subVectors(n, t).cross(ly.subVectors(e, t)).normalize();+ return this.setFromNormalAndCoplanarPoint(s, e), this;+ }+ /**+ * Copies the values of the given plane to this instance.+ *+ * @param {Plane} plane - The plane to copy.+ * @return {Plane} A reference to this plane.+ */+ copy(e) {+ return this.normal.copy(e.normal), this.constant = e.constant, this;+ }+ /**+ * Normalizes the plane normal and adjusts the constant accordingly.+ *+ * @return {Plane} A reference to this plane.+ */+ normalize() {+ const e = 1 / this.normal.length();+ return this.normal.multiplyScalar(e), this.constant *= e, this;+ }+ /**+ * Negates both the plane normal and the constant.+ *+ * @return {Plane} A reference to this plane.+ */+ negate() {+ return this.constant *= -1, this.normal.negate(), this;+ }+ /**+ * Returns the signed distance from the given point to this plane.+ *+ * @param {Vector3} point - The point to compute the distance for.+ * @return {number} The signed distance.+ */+ distanceToPoint(e) {+ return this.normal.dot(e) + this.constant;+ }+ /**+ * Returns the signed distance from the given sphere to this plane.+ *+ * @param {Sphere} sphere - The sphere to compute the distance for.+ * @return {number} The signed distance.+ */+ distanceToSphere(e) {+ return this.distanceToPoint(e.center) - e.radius;+ }+ /**+ * Projects a the given point onto the plane.+ *+ * @param {Vector3} point - The point to project.+ * @param {Vector3} target - The target vector that is used to store the method's result.+ * @return {Vector3} The projected point on the plane.+ */+ projectPoint(e, t) {+ return t.copy(e).addScaledVector(this.normal, -this.distanceToPoint(e));+ }+ /**+ * Returns the intersection point of the passed line and the plane. Returns+ * `null` if the line does not intersect. Returns the line's starting point if+ * the line is coplanar with the plane.+ *+ * @param {Line3} line - The line to compute the intersection for.+ * @param {Vector3} target - The target vector that is used to store the method's result.+ * @return {?Vector3} The intersection point.+ */+ intersectLine(e, t) {+ const n = e.delta(zh), s = this.normal.dot(n);+ if (s === 0)+ return this.distanceToPoint(e.start) === 0 ? t.copy(e.start) : null;+ const r = -(e.start.dot(this.normal) + this.constant) / s;+ return r < 0 || r > 1 ? null : t.copy(e.start).addScaledVector(n, r);+ }+ /**+ * Returns `true` if the given line segment intersects with (passes through) the plane.+ *+ * @param {Line3} line - The line to test.+ * @return {boolean} Whether the given line segment intersects with the plane or not.+ */+ intersectsLine(e) {+ const t = this.distanceToPoint(e.start), n = this.distanceToPoint(e.end);+ return t < 0 && n > 0 || n < 0 && t > 0;+ }+ /**+ * Returns `true` if the given bounding box intersects with the plane.+ *+ * @param {Box3} box - The bounding box to test.+ * @return {boolean} Whether the given bounding box intersects with the plane or not.+ */+ intersectsBox(e) {+ return e.intersectsPlane(this);+ }+ /**+ * Returns `true` if the given bounding sphere intersects with the plane.+ *+ * @param {Sphere} sphere - The bounding sphere to test.+ * @return {boolean} Whether the given bounding sphere intersects with the plane or not.+ */+ intersectsSphere(e) {+ return e.intersectsPlane(this);+ }+ /**+ * Returns a coplanar vector to the plane, by calculating the+ * projection of the normal at the origin onto the plane.+ *+ * @param {Vector3} target - The target vector that is used to store the method's result.+ * @return {Vector3} The coplanar point.+ */+ coplanarPoint(e) {+ return e.copy(this.normal).multiplyScalar(-this.constant);+ }+ /**+ * Apply a 4x4 matrix to the plane. The matrix must be an affine, homogeneous transform.+ *+ * The optional normal matrix can be pre-computed like so:+ * ```js+ * const optionalNormalMatrix = new THREE.Matrix3().getNormalMatrix( matrix );+ * ```+ *+ * @param {Matrix4} matrix - The transformation matrix.+ * @param {Matrix4} [optionalNormalMatrix] - A pre-computed normal matrix.+ * @return {Plane} A reference to this plane.+ */+ applyMatrix4(e, t) {+ const n = t || hy.getNormalMatrix(e), s = this.coplanarPoint(zh).applyMatrix4(e), r = this.normal.applyMatrix3(n).normalize();+ return this.constant = -s.dot(r), this;+ }+ /**+ * Translates the plane by the distance defined by the given offset vector.+ * Note that this only affects the plane constant and will not affect the normal vector.+ *+ * @param {Vector3} offset - The offset vector.+ * @return {Plane} A reference to this plane.+ */+ translate(e) {+ return this.constant -= e.dot(this.normal), this;+ }+ /**+ * Returns `true` if this plane is equal with the given one.+ *+ * @param {Plane} plane - The plane to test for equality.+ * @return {boolean} Whether this plane is equal with the given one.+ */+ equals(e) {+ return e.normal.equals(this.normal) && e.constant === this.constant;+ }+ /**+ * Returns a new plane with copied values from this instance.+ *+ * @return {Plane} A clone of this instance.+ */+ clone() {+ return new this.constructor().copy(this);+ }+}+const Js = /* @__PURE__ */ new Ui(), Rc = /* @__PURE__ */ new H();+class vf {+ /**+ * Constructs a new frustum.+ *+ * @param {Plane} [p0] - The first plane that encloses the frustum.+ * @param {Plane} [p1] - The second plane that encloses the frustum.+ * @param {Plane} [p2] - The third plane that encloses the frustum.+ * @param {Plane} [p3] - The fourth plane that encloses the frustum.+ * @param {Plane} [p4] - The fifth plane that encloses the frustum.+ * @param {Plane} [p5] - The sixth plane that encloses the frustum.+ */+ constructor(e = new Rs(), t = new Rs(), n = new Rs(), s = new Rs(), r = new Rs(), a = new Rs()) {+ this.planes = [e, t, n, s, r, a];+ }+ /**+ * Sets the frustum planes by copying the given planes.+ *+ * @param {Plane} [p0] - The first plane that encloses the frustum.+ * @param {Plane} [p1] - The second plane that encloses the frustum.+ * @param {Plane} [p2] - The third plane that encloses the frustum.+ * @param {Plane} [p3] - The fourth plane that encloses the frustum.+ * @param {Plane} [p4] - The fifth plane that encloses the frustum.+ * @param {Plane} [p5] - The sixth plane that encloses the frustum.+ * @return {Frustum} A reference to this frustum.+ */+ set(e, t, n, s, r, a) {+ const o = this.planes;+ return o[0].copy(e), o[1].copy(t), o[2].copy(n), o[3].copy(s), o[4].copy(r), o[5].copy(a), this;+ }+ /**+ * Copies the values of the given frustum to this instance.+ *+ * @param {Frustum} frustum - The frustum to copy.+ * @return {Frustum} A reference to this frustum.+ */+ copy(e) {+ const t = this.planes;+ for (let n = 0; n < 6; n++)+ t[n].copy(e.planes[n]);+ return this;+ }+ /**+ * Sets the frustum planes from the given projection matrix.+ *+ * @param {Matrix4} m - The projection matrix.+ * @param {(WebGLCoordinateSystem|WebGPUCoordinateSystem)} coordinateSystem - The coordinate system.+ * @return {Frustum} A reference to this frustum.+ */+ setFromProjectionMatrix(e, t = is) {+ const n = this.planes, s = e.elements, r = s[0], a = s[1], o = s[2], c = s[3], l = s[4], h = s[5], u = s[6], d = s[7], f = s[8], m = s[9], A = s[10], g = s[11], p = s[12], y = s[13], b = s[14], E = s[15];+ if (n[0].setComponents(c - r, d - l, g - f, E - p).normalize(), n[1].setComponents(c + r, d + l, g + f, E + p).normalize(), n[2].setComponents(c + a, d + h, g + m, E + y).normalize(), n[3].setComponents(c - a, d - h, g - m, E - y).normalize(), n[4].setComponents(c - o, d - u, g - A, E - b).normalize(), t === is)+ n[5].setComponents(c + o, d + u, g + A, E + b).normalize();+ else if (t === Tl)+ n[5].setComponents(o, u, A, b).normalize();+ else+ throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: " + t);+ return this;+ }+ /**+ * Returns `true` if the 3D object's bounding sphere is intersecting this frustum.+ *+ * Note that the 3D object must have a geometry so that the bounding sphere can be calculated.+ *+ * @param {Object3D} object - The 3D object to test.+ * @return {boolean} Whether the 3D object's bounding sphere is intersecting this frustum or not.+ */+ intersectsObject(e) {+ if (e.boundingSphere !== void 0)+ e.boundingSphere === null && e.computeBoundingSphere(), Js.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);+ else {+ const t = e.geometry;+ t.boundingSphere === null && t.computeBoundingSphere(), Js.copy(t.boundingSphere).applyMatrix4(e.matrixWorld);+ }+ return this.intersectsSphere(Js);+ }+ /**+ * Returns `true` if the given sprite is intersecting this frustum.+ *+ * @param {Sprite} sprite - The sprite to test.+ * @return {boolean} Whether the sprite is intersecting this frustum or not.+ */+ intersectsSprite(e) {+ return Js.center.set(0, 0, 0), Js.radius = 0.7071067811865476, Js.applyMatrix4(e.matrixWorld), this.intersectsSphere(Js);+ }+ /**+ * Returns `true` if the given bounding sphere is intersecting this frustum.+ *+ * @param {Sphere} sphere - The bounding sphere to test.+ * @return {boolean} Whether the bounding sphere is intersecting this frustum or not.+ */+ intersectsSphere(e) {+ const t = this.planes, n = e.center, s = -e.radius;+ for (let r = 0; r < 6; r++)+ if (t[r].distanceToPoint(n) < s)+ return !1;+ return !0;+ }+ /**+ * Returns `true` if the given bounding box is intersecting this frustum.+ *+ * @param {Box3} box - The bounding box to test.+ * @return {boolean} Whether the bounding box is intersecting this frustum or not.+ */+ intersectsBox(e) {+ const t = this.planes;+ for (let n = 0; n < 6; n++) {+ const s = t[n];+ if (Rc.x = s.normal.x > 0 ? e.max.x : e.min.x, Rc.y = s.normal.y > 0 ? e.max.y : e.min.y, Rc.z = s.normal.z > 0 ? e.max.z : e.min.z, s.distanceToPoint(Rc) < 0)+ return !1;+ }+ return !0;+ }+ /**+ * Returns `true` if the given point lies within the frustum.+ *+ * @param {Vector3} point - The point to test.+ * @return {boolean} Whether the point lies within this frustum or not.+ */+ containsPoint(e) {+ const t = this.planes;+ for (let n = 0; n < 6; n++)+ if (t[n].distanceToPoint(e) < 0)+ return !1;+ return !0;+ }+ /**+ * Returns a new frustum with copied values from this instance.+ *+ * @return {Frustum} A clone of this instance.+ */+ clone() {+ return new this.constructor().copy(this);+ }+}+class Zo extends Li {+ /**+ * Constructs a new line basic material.+ *+ * @param {Object} [parameters] - An object with one or more properties+ * defining the material's appearance. Any property of the material+ * (including any property from inherited materials) can be passed+ * in here. Color values can be passed any type of value accepted+ * by {@link Color#set}.+ */+ constructor(e) {+ super(), this.isLineBasicMaterial = !0, this.type = "LineBasicMaterial", this.color = new je(16777215), this.map = null, this.linewidth = 1, this.linecap = "round", this.linejoin = "round", this.fog = !0, this.setValues(e);+ }+ copy(e) {+ return super.copy(e), this.color.copy(e.color), this.map = e.map, this.linewidth = e.linewidth, this.linecap = e.linecap, this.linejoin = e.linejoin, this.fog = e.fog, this;+ }+}+const Rl = /* @__PURE__ */ new H(), Nl = /* @__PURE__ */ new H(), Wp = /* @__PURE__ */ new et(), to = /* @__PURE__ */ new Jo(), Nc = /* @__PURE__ */ new Ui(), Vh = /* @__PURE__ */ new H(), qp = /* @__PURE__ */ new H();+class Cf extends kt {+ /**+ * Constructs a new line.+ *+ * @param {BufferGeometry} [geometry] - The line geometry.+ * @param {Material|Array<Material>} [material] - The line material.+ */+ constructor(e = new zn(), t = new Zo()) {+ super(), this.isLine = !0, this.type = "Line", this.geometry = e, this.material = t, this.morphTargetDictionary = void 0, this.morphTargetInfluences = void 0, this.updateMorphTargets();+ }+ copy(e, t) {+ return super.copy(e, t), this.material = Array.isArray(e.material) ? e.material.slice() : e.material, this.geometry = e.geometry, this;+ }+ /**+ * Computes an array of distance values which are necessary for rendering dashed lines.+ * For each vertex in the geometry, the method calculates the cumulative length from the+ * current point to the very beginning of the line.+ *+ * @return {Line} A reference to this line.+ */+ computeLineDistances() {+ const e = this.geometry;+ if (e.index === null) {+ const t = e.attributes.position, n = [0];+ for (let s = 1, r = t.count; s < r; s++)+ Rl.fromBufferAttribute(t, s - 1), Nl.fromBufferAttribute(t, s), n[s] = n[s - 1], n[s] += Rl.distanceTo(Nl);+ e.setAttribute("lineDistance", new Un(n, 1));+ } else+ console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");+ return this;+ }+ /**+ * Computes intersection points between a casted ray and this line.+ *+ * @param {Raycaster} raycaster - The raycaster.+ * @param {Array<Object>} intersects - The target array that holds the intersection points.+ */+ raycast(e, t) {+ const n = this.geometry, s = this.matrixWorld, r = e.params.Line.threshold, a = n.drawRange;+ if (n.boundingSphere === null && n.computeBoundingSphere(), Nc.copy(n.boundingSphere), Nc.applyMatrix4(s), Nc.radius += r, e.ray.intersectsSphere(Nc) === !1) return;+ Wp.copy(s).invert(), to.copy(e.ray).applyMatrix4(Wp);+ const o = r / ((this.scale.x + this.scale.y + this.scale.z) / 3), c = o * o, l = this.isLineSegments ? 2 : 1, h = n.index, d = n.attributes.position;+ if (h !== null) {+ const f = Math.max(0, a.start), m = Math.min(h.count, a.start + a.count);+ for (let A = f, g = m - 1; A < g; A += l) {+ const p = h.getX(A), y = h.getX(A + 1), b = Fc(this, e, to, c, p, y, A);+ b && t.push(b);+ }+ if (this.isLineLoop) {+ const A = h.getX(m - 1), g = h.getX(f), p = Fc(this, e, to, c, A, g, m - 1);+ p && t.push(p);+ }+ } else {+ const f = Math.max(0, a.start), m = Math.min(d.count, a.start + a.count);+ for (let A = f, g = m - 1; A < g; A += l) {+ const p = Fc(this, e, to, c, A, A + 1, A);+ p && t.push(p);+ }+ if (this.isLineLoop) {+ const A = Fc(this, e, to, c, m - 1, f, m - 1);+ A && t.push(A);+ }+ }+ }+ /**+ * Sets the values of {@link Line#morphTargetDictionary} and {@link Line#morphTargetInfluences}+ * to make sure existing morph targets can influence this 3D object.+ */+ updateMorphTargets() {+ const t = this.geometry.morphAttributes, n = Object.keys(t);+ if (n.length > 0) {+ const s = t[n[0]];+ if (s !== void 0) {+ this.morphTargetInfluences = [], this.morphTargetDictionary = {};+ for (let r = 0, a = s.length; r < a; r++) {+ const o = s[r].name || String(r);+ this.morphTargetInfluences.push(0), this.morphTargetDictionary[o] = r;+ }+ }+ }+ }+}+function Fc(i, e, t, n, s, r, a) {+ const o = i.geometry.attributes.position;+ if (Rl.fromBufferAttribute(o, s), Nl.fromBufferAttribute(o, r), t.distanceSqToSegment(Rl, Nl, Vh, qp) > n) return;+ Vh.applyMatrix4(i.matrixWorld);+ const l = e.ray.origin.distanceTo(Vh);+ if (!(l < e.near || l > e.far))+ return {+ distance: l,+ // What do we want? intersection point on the ray or on the segment??+ // point: raycaster.ray.at( distance ),+ point: qp.clone().applyMatrix4(i.matrixWorld),+ index: a,+ face: null,+ faceIndex: null,+ barycoord: null,+ object: i+ };+}+const Kp = /* @__PURE__ */ new H(), jp = /* @__PURE__ */ new H();+class Yl extends Cf {+ /**+ * Constructs a new line segments.+ *+ * @param {BufferGeometry} [geometry] - The line geometry.+ * @param {Material|Array<Material>} [material] - The line material.+ */+ constructor(e, t) {+ super(e, t), this.isLineSegments = !0, this.type = "LineSegments";+ }+ computeLineDistances() {+ const e = this.geometry;+ if (e.index === null) {+ const t = e.attributes.position, n = [];+ for (let s = 0, r = t.count; s < r; s += 2)+ Kp.fromBufferAttribute(t, s), jp.fromBufferAttribute(t, s + 1), n[s] = s === 0 ? 0 : n[s - 1], n[s + 1] = n[s] + Kp.distanceTo(jp);+ e.setAttribute("lineDistance", new Un(n, 1));+ } else+ console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");+ return this;+ }+}+class uy extends Cf {+ /**+ * Constructs a new line loop.+ *+ * @param {BufferGeometry} [geometry] - The line geometry.+ * @param {Material|Array<Material>} [material] - The line material.+ */+ constructor(e, t) {+ super(e, t), this.isLineLoop = !0, this.type = "LineLoop";+ }+}+class Sf extends Li {+ /**+ * Constructs a new points material.+ *+ * @param {Object} [parameters] - An object with one or more properties+ * defining the material's appearance. Any property of the material+ * (including any property from inherited materials) can be passed+ * in here. Color values can be passed any type of value accepted+ * by {@link Color#set}.+ */+ constructor(e) {+ super(), this.isPointsMaterial = !0, this.type = "PointsMaterial", this.color = new je(16777215), this.map = null, this.alphaMap = null, this.size = 1, this.sizeAttenuation = !0, this.fog = !0, this.setValues(e);+ }+ copy(e) {+ return super.copy(e), this.color.copy(e.color), this.map = e.map, this.alphaMap = e.alphaMap, this.size = e.size, this.sizeAttenuation = e.sizeAttenuation, this.fog = e.fog, this;+ }+}+const Xp = /* @__PURE__ */ new et(), yd = /* @__PURE__ */ new Jo(), Dc = /* @__PURE__ */ new Ui(), Lc = /* @__PURE__ */ new H();+class dy extends kt {+ /**+ * Constructs a new point cloud.+ *+ * @param {BufferGeometry} [geometry] - The points geometry.+ * @param {Material|Array<Material>} [material] - The points material.+ */+ constructor(e = new zn(), t = new Sf()) {+ super(), this.isPoints = !0, this.type = "Points", this.geometry = e, this.material = t, this.morphTargetDictionary = void 0, this.morphTargetInfluences = void 0, this.updateMorphTargets();+ }+ copy(e, t) {+ return super.copy(e, t), this.material = Array.isArray(e.material) ? e.material.slice() : e.material, this.geometry = e.geometry, this;+ }+ /**+ * Computes intersection points between a casted ray and this point cloud.+ *+ * @param {Raycaster} raycaster - The raycaster.+ * @param {Array<Object>} intersects - The target array that holds the intersection points.+ */+ raycast(e, t) {+ const n = this.geometry, s = this.matrixWorld, r = e.params.Points.threshold, a = n.drawRange;+ if (n.boundingSphere === null && n.computeBoundingSphere(), Dc.copy(n.boundingSphere), Dc.applyMatrix4(s), Dc.radius += r, e.ray.intersectsSphere(Dc) === !1) return;+ Xp.copy(s).invert(), yd.copy(e.ray).applyMatrix4(Xp);+ const o = r / ((this.scale.x + this.scale.y + this.scale.z) / 3), c = o * o, l = n.index, u = n.attributes.position;+ if (l !== null) {+ const d = Math.max(0, a.start), f = Math.min(l.count, a.start + a.count);+ for (let m = d, A = f; m < A; m++) {+ const g = l.getX(m);+ Lc.fromBufferAttribute(u, g), Yp(Lc, g, c, s, e, t, this);+ }+ } else {+ const d = Math.max(0, a.start), f = Math.min(u.count, a.start + a.count);+ for (let m = d, A = f; m < A; m++)+ Lc.fromBufferAttribute(u, m), Yp(Lc, m, c, s, e, t, this);+ }+ }+ /**+ * Sets the values of {@link Points#morphTargetDictionary} and {@link Points#morphTargetInfluences}+ * to make sure existing morph targets can influence this 3D object.+ */+ updateMorphTargets() {+ const t = this.geometry.morphAttributes, n = Object.keys(t);+ if (n.length > 0) {+ const s = t[n[0]];+ if (s !== void 0) {+ this.morphTargetInfluences = [], this.morphTargetDictionary = {};+ for (let r = 0, a = s.length; r < a; r++) {+ const o = s[r].name || String(r);+ this.morphTargetInfluences.push(0), this.morphTargetDictionary[o] = r;+ }+ }+ }+ }+}+function Yp(i, e, t, n, s, r, a) {+ const o = yd.distanceSqToPoint(i);+ if (o < t) {+ const c = new H();+ yd.closestPointToPoint(i, c), c.applyMatrix4(n);+ const l = s.ray.origin.distanceTo(c);+ if (l < s.near || l > s.far) return;+ r.push({+ distance: l,+ distanceToRay: Math.sqrt(o),+ point: c,+ index: e,+ face: null,+ faceIndex: null,+ barycoord: null,+ object: a+ });+ }+}+class Jl extends cn {+ /**+ * Constructs a new compressed texture.+ *+ * @param {Array<Object>} mipmaps - This array holds for all mipmaps (including the bases mip)+ * the data and dimensions.+ * @param {number} width - The width of the texture.+ * @param {number} height - The height of the texture.+ * @param {number} [format=RGBAFormat] - The texture format.+ * @param {number} [type=UnsignedByteType] - The texture type.+ * @param {number} [mapping=Texture.DEFAULT_MAPPING] - The texture mapping.+ * @param {number} [wrapS=ClampToEdgeWrapping] - The wrapS value.+ * @param {number} [wrapT=ClampToEdgeWrapping] - The wrapT value.+ * @param {number} [magFilter=LinearFilter] - The mag filter value.+ * @param {number} [minFilter=LinearMipmapLinearFilter] - The min filter value.+ * @param {number} [anisotropy=Texture.DEFAULT_ANISOTROPY] - The anisotropy value.+ * @param {string} [colorSpace=NoColorSpace] - The color space.+ */+ constructor(e, t, n, s, r, a, o, c, l, h, u, d) {+ super(null, a, o, c, l, h, s, r, u, d), this.isCompressedTexture = !0, this.image = { width: t, height: n }, this.mipmaps = e, this.flipY = !1, this.generateMipmaps = !1;+ }+}+class fy extends Jl {+ /**+ * Constructs a new compressed array texture.+ *+ * @param {Array<Object>} mipmaps - This array holds for all mipmaps (including the bases mip)+ * the data and dimensions.+ * @param {number} width - The width of the texture.+ * @param {number} height - The height of the texture.+ * @param {number} depth - The depth of the texture.+ * @param {number} [format=RGBAFormat] - The min filter value.+ * @param {number} [type=UnsignedByteType] - The min filter value.+ */+ constructor(e, t, n, s, r, a) {+ super(e, t, n, r, a), this.isCompressedArrayTexture = !0, this.image.depth = s, this.wrapR = _i, this.layerUpdates = /* @__PURE__ */ new Set();+ }+ /**+ * Describes that a specific layer of the texture needs to be updated.+ * Normally when {@link Texture#needsUpdate} is set to `true`, the+ * entire compressed texture array is sent to the GPU. Marking specific+ * layers will only transmit subsets of all mipmaps associated with a+ * specific depth in the array which is often much more performant.+ *+ * @param {number} layerIndex - The layer index that should be updated.+ */+ addLayerUpdate(e) {+ this.layerUpdates.add(e);+ }+ /**+ * Resets the layer updates registry.+ */+ clearLayerUpdates() {+ this.layerUpdates.clear();+ }+}+class py extends Jl {+ /**+ * Constructs a new compressed texture.+ *+ * @param {Array<CompressedTexture>} images - An array of compressed textures.+ * @param {number} [format=RGBAFormat] - The texture format.+ * @param {number} [type=UnsignedByteType] - The texture type.+ */+ constructor(e, t, n) {+ super(void 0, e[0].width, e[0].height, t, n, Er), this.isCompressedCubeTexture = !0, this.isCubeTexture = !0, this.image = e;+ }+}+class m0 extends cn {+ /**+ * Constructs a new depth texture.+ *+ * @param {number} width - The width of the texture.+ * @param {number} height - The height of the texture.+ * @param {number} [type=UnsignedIntType] - The texture type.+ * @param {number} [mapping=Texture.DEFAULT_MAPPING] - The texture mapping.+ * @param {number} [wrapS=ClampToEdgeWrapping] - The wrapS value.+ * @param {number} [wrapT=ClampToEdgeWrapping] - The wrapT value.+ * @param {number} [magFilter=LinearFilter] - The mag filter value.+ * @param {number} [minFilter=LinearFilter] - The min filter value.+ * @param {number} [anisotropy=Texture.DEFAULT_ANISOTROPY] - The anisotropy value.+ * @param {number} [format=DepthFormat] - The texture format.+ */+ constructor(e, t, n = yr, s, r, a, o = kn, c = kn, l, h = No) {+ if (h !== No && h !== Fo)+ throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");+ super(null, s, r, a, o, c, h, n, l), this.isDepthTexture = !0, this.image = { width: e, height: t }, this.flipY = !1, this.generateMipmaps = !1, this.compareFunction = null;+ }+ copy(e) {+ return super.copy(e), this.source = new Ef(Object.assign({}, e.image)), this.compareFunction = e.compareFunction, this;+ }+ toJSON(e) {+ const t = super.toJSON(e);+ return this.compareFunction !== null && (t.compareFunction = this.compareFunction), t;+ }+}+class Zl extends zn {+ /**+ * Constructs a new plane geometry.+ *+ * @param {number} [width=1] - The width along the X axis.+ * @param {number} [height=1] - The height along the Y axis+ * @param {number} [widthSegments=1] - The number of segments along the X axis.+ * @param {number} [heightSegments=1] - The number of segments along the Y axis.+ */+ constructor(e = 1, t = 1, n = 1, s = 1) {+ super(), this.type = "PlaneGeometry", this.parameters = {+ width: e,+ height: t,+ widthSegments: n,+ heightSegments: s+ };+ const r = e / 2, a = t / 2, o = Math.floor(n), c = Math.floor(s), l = o + 1, h = c + 1, u = e / o, d = t / c, f = [], m = [], A = [], g = [];+ for (let p = 0; p < h; p++) {+ const y = p * d - a;+ for (let b = 0; b < l; b++) {+ const E = b * u - r;+ m.push(E, -y, 0), A.push(0, 0, 1), g.push(b / o), g.push(1 - p / c);+ }+ }+ for (let p = 0; p < c; p++)+ for (let y = 0; y < o; y++) {+ const b = y + l * p, E = y + l * (p + 1), M = y + 1 + l * (p + 1), w = y + 1 + l * p;+ f.push(b, E, w), f.push(E, M, w);+ }+ this.setIndex(f), this.setAttribute("position", new Un(m, 3)), this.setAttribute("normal", new Un(A, 3)), this.setAttribute("uv", new Un(g, 2));+ }+ copy(e) {+ return super.copy(e), this.parameters = Object.assign({}, e.parameters), this;+ }+ /**+ * Factory method for creating an instance of this class from the given+ * JSON object.+ *+ * @param {Object} data - A JSON object representing the serialized geometry.+ * @return {PlaneGeometry} A new instance.+ */+ static fromJSON(e) {+ return new Zl(e.width, e.height, e.widthSegments, e.heightSegments);+ }+}+class Oo extends Li {+ /**+ * Constructs a new mesh standard material.+ *+ * @param {Object} [parameters] - An object with one or more properties+ * defining the material's appearance. Any property of the material+ * (including any property from inherited materials) can be passed+ * in here. Color values can be passed any type of value accepted+ * by {@link Color#set}.+ */+ constructor(e) {+ super(), this.isMeshStandardMaterial = !0, this.type = "MeshStandardMaterial", this.defines = { STANDARD: "" }, this.color = new je(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 je(0), this.emissiveIntensity = 1, this.emissiveMap = null, this.bumpMap = null, this.bumpScale = 1, this.normalMap = null, this.normalMapType = n0, this.normalScale = new Ze(1, 1), this.displacementMap = null, this.displacementScale = 1, this.displacementBias = 0, this.roughnessMap = null, this.metalnessMap = null, this.alphaMap = null, this.envMap = null, this.envMapRotation = new Pi(), this.envMapIntensity = 1, this.wireframe = !1, this.wireframeLinewidth = 1, this.wireframeLinecap = "round", this.wireframeLinejoin = "round", this.flatShading = !1, this.fog = !0, this.setValues(e);+ }+ copy(e) {+ return super.copy(e), this.defines = { STANDARD: "" }, this.color.copy(e.color), this.roughness = e.roughness, this.metalness = e.metalness, this.map = e.map, this.lightMap = e.lightMap, this.lightMapIntensity = e.lightMapIntensity, this.aoMap = e.aoMap, this.aoMapIntensity = e.aoMapIntensity, this.emissive.copy(e.emissive), this.emissiveMap = e.emissiveMap, this.emissiveIntensity = e.emissiveIntensity, this.bumpMap = e.bumpMap, this.bumpScale = e.bumpScale, this.normalMap = e.normalMap, this.normalMapType = e.normalMapType, this.normalScale.copy(e.normalScale), this.displacementMap = e.displacementMap, this.displacementScale = e.displacementScale, this.displacementBias = e.displacementBias, this.roughnessMap = e.roughnessMap, this.metalnessMap = e.metalnessMap, this.alphaMap = e.alphaMap, this.envMap = e.envMap, this.envMapRotation.copy(e.envMapRotation), this.envMapIntensity = e.envMapIntensity, this.wireframe = e.wireframe, this.wireframeLinewidth = e.wireframeLinewidth, this.wireframeLinecap = e.wireframeLinecap, this.wireframeLinejoin = e.wireframeLinejoin, this.flatShading = e.flatShading, this.fog = e.fog, this;+ }+}+class Oi extends Oo {+ /**+ * Constructs a new mesh physical material.+ *+ * @param {Object} [parameters] - An object with one or more properties+ * defining the material's appearance. Any property of the material+ * (including any property from inherited materials) can be passed+ * in here. Color values can be passed any type of value accepted+ * by {@link Color#set}.+ */+ 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 Ze(1, 1), this.clearcoatNormalMap = null, this.ior = 1.5, Object.defineProperty(this, "reflectivity", {+ get: function() {+ return ct(2.5 * (this.ior - 1) / (this.ior + 1), 0, 1);+ },+ set: function(t) {+ this.ior = (1 + 0.4 * t) / (1 - 0.4 * t);+ }+ }), this.iridescenceMap = null, this.iridescenceIOR = 1.3, this.iridescenceThicknessRange = [100, 400], this.iridescenceThicknessMap = null, this.sheenColor = new je(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 je(1, 1, 1), this.specularIntensity = 1, this.specularIntensityMap = null, this.specularColor = new je(1, 1, 1), this.specularColorMap = null, this._anisotropy = 0, this._clearcoat = 0, this._dispersion = 0, this._iridescence = 0, this._sheen = 0, this._transmission = 0, this.setValues(e);+ }+ /**+ * The anisotropy strength.+ *+ * @type {number}+ * @default 0+ */+ get anisotropy() {+ return this._anisotropy;+ }+ set anisotropy(e) {+ this._anisotropy > 0 != e > 0 && this.version++, this._anisotropy = e;+ }+ /**+ * Represents the intensity of the clear coat layer, from `0.0` to `1.0`. Use+ * clear coat related properties to enable multilayer materials that have a+ * thin translucent layer over the base layer.+ *+ * @type {number}+ * @default 0+ */+ get clearcoat() {+ return this._clearcoat;+ }+ set clearcoat(e) {+ this._clearcoat > 0 != e > 0 && this.version++, this._clearcoat = e;+ }+ /**+ * The intensity of the iridescence layer, simulating RGB color shift based on the angle between+ * the surface and the viewer, from `0.0` to `1.0`.+ *+ * @type {number}+ * @default 0+ */+ get iridescence() {+ return this._iridescence;+ }+ set iridescence(e) {+ this._iridescence > 0 != e > 0 && this.version++, this._iridescence = e;+ }+ /**+ * Defines the strength of the angular separation of colors (chromatic aberration) transmitting+ * through a relatively clear volume. Any value zero or larger is valid, the typical range of+ * realistic values is `[0, 1]`. This property can be only be used with transmissive objects.+ *+ * @type {number}+ * @default 0+ */+ get dispersion() {+ return this._dispersion;+ }+ set dispersion(e) {+ this._dispersion > 0 != e > 0 && this.version++, this._dispersion = e;+ }+ /**+ * The intensity of the sheen layer, from `0.0` to `1.0`.+ *+ * @type {number}+ * @default 0+ */+ get sheen() {+ return this._sheen;+ }+ set sheen(e) {+ this._sheen > 0 != e > 0 && this.version++, this._sheen = e;+ }+ /**+ * Degree of transmission (or optical transparency), from `0.0` to `1.0`.+ *+ * Thin, transparent or semitransparent, plastic or glass materials remain+ * largely reflective even if they are fully transmissive. The transmission+ * property can be used to model these materials.+ *+ * When transmission is non-zero, `opacity` should be set to `1`.+ *+ * @type {number}+ * @default 0+ */+ get transmission() {+ return this._transmission;+ }+ set transmission(e) {+ this._transmission > 0 != e > 0 && this.version++, this._transmission = e;+ }+ copy(e) {+ return super.copy(e), this.defines = {+ STANDARD: "",+ PHYSICAL: ""+ }, this.anisotropy = e.anisotropy, this.anisotropyRotation = e.anisotropyRotation, this.anisotropyMap = e.anisotropyMap, this.clearcoat = e.clearcoat, this.clearcoatMap = e.clearcoatMap, this.clearcoatRoughness = e.clearcoatRoughness, this.clearcoatRoughnessMap = e.clearcoatRoughnessMap, this.clearcoatNormalMap = e.clearcoatNormalMap, this.clearcoatNormalScale.copy(e.clearcoatNormalScale), this.dispersion = e.dispersion, this.ior = e.ior, this.iridescence = e.iridescence, this.iridescenceMap = e.iridescenceMap, this.iridescenceIOR = e.iridescenceIOR, this.iridescenceThicknessRange = [...e.iridescenceThicknessRange], this.iridescenceThicknessMap = e.iridescenceThicknessMap, this.sheen = e.sheen, this.sheenColor.copy(e.sheenColor), this.sheenColorMap = e.sheenColorMap, this.sheenRoughness = e.sheenRoughness, this.sheenRoughnessMap = e.sheenRoughnessMap, this.transmission = e.transmission, this.transmissionMap = e.transmissionMap, this.thickness = e.thickness, this.thicknessMap = e.thicknessMap, this.attenuationDistance = e.attenuationDistance, this.attenuationColor.copy(e.attenuationColor), this.specularIntensity = e.specularIntensity, this.specularIntensityMap = e.specularIntensityMap, this.specularColor.copy(e.specularColor), this.specularColorMap = e.specularColorMap, this;+ }+}+class Ay extends Li {+ /**+ * Constructs a new mesh depth material.+ *+ * @param {Object} [parameters] - An object with one or more properties+ * defining the material's appearance. Any property of the material+ * (including any property from inherited materials) can be passed+ * in here. Color values can be passed any type of value accepted+ * by {@link Color#set}.+ */+ constructor(e) {+ super(), this.isMeshDepthMaterial = !0, this.type = "MeshDepthMaterial", this.depthPacking = nE, this.map = null, this.alphaMap = null, this.displacementMap = null, this.displacementScale = 1, this.displacementBias = 0, this.wireframe = !1, this.wireframeLinewidth = 1, this.setValues(e);+ }+ copy(e) {+ return super.copy(e), this.depthPacking = e.depthPacking, this.map = e.map, this.alphaMap = e.alphaMap, this.displacementMap = e.displacementMap, this.displacementScale = e.displacementScale, this.displacementBias = e.displacementBias, this.wireframe = e.wireframe, this.wireframeLinewidth = e.wireframeLinewidth, this;+ }+}+class gy extends Li {+ /**+ * Constructs a new mesh distance material.+ *+ * @param {Object} [parameters] - An object with one or more properties+ * defining the material's appearance. Any property of the material+ * (including any property from inherited materials) can be passed+ * in here. Color values can be passed any type of value accepted+ * by {@link Color#set}.+ */+ 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 Pc(i, e) {+ return !i || i.constructor === e ? i : typeof e.BYTES_PER_ELEMENT == "number" ? new e(i) : Array.prototype.slice.call(i);+}+function my(i) {+ return ArrayBuffer.isView(i) && !(i instanceof DataView);+}+function by(i) {+ function e(s, r) {+ return i[s] - i[r];+ }+ const t = i.length, n = new Array(t);+ for (let s = 0; s !== t; ++s) n[s] = s;+ return n.sort(e), n;+}+function Jp(i, e, t) {+ const n = i.length, s = new i.constructor(n);+ for (let r = 0, a = 0; a !== n; ++r) {+ const o = t[r] * e;+ for (let c = 0; c !== e; ++c)+ s[a++] = i[o + c];+ }+ return s;+}+function b0(i, e, t, n) {+ let s = 1, r = i[0];+ for (; r !== void 0 && r[n] === void 0; )+ r = i[s++];+ if (r === void 0) return;+ let a = r[n];+ if (a !== void 0)+ if (Array.isArray(a))+ do+ a = r[n], a !== void 0 && (e.push(r.time), t.push(...a)), r = i[s++];+ while (r !== void 0);+ else if (a.toArray !== void 0)+ do+ a = r[n], a !== void 0 && (e.push(r.time), a.toArray(t, t.length)), r = i[s++];+ while (r !== void 0);+ else+ do+ a = r[n], a !== void 0 && (e.push(r.time), t.push(a)), r = i[s++];+ while (r !== void 0);+}+class $o {+ /**+ * Constructs a new interpolant.+ *+ * @param {TypedArray} parameterPositions - The parameter positions hold the interpolation factors.+ * @param {TypedArray} sampleValues - The sample values.+ * @param {number} sampleSize - The sample size+ * @param {TypedArray} [resultBuffer] - The result buffer.+ */+ constructor(e, t, n, s) {+ this.parameterPositions = e, this._cachedIndex = 0, this.resultBuffer = s !== void 0 ? s : new t.constructor(n), this.sampleValues = t, this.valueSize = n, this.settings = null, this.DefaultSettings_ = {};+ }+ /**+ * Evaluate the interpolant at position `t`.+ *+ * @param {number} t - The interpolation factor.+ * @return {TypedArray} The result buffer.+ */+ evaluate(e) {+ const t = this.parameterPositions;+ let n = this._cachedIndex, s = t[n], r = t[n - 1];+ e: {+ t: {+ let a;+ n: {+ i: if (!(e < s)) {+ for (let o = n + 2; ; ) {+ if (s === void 0) {+ if (e < r) break i;+ return n = t.length, this._cachedIndex = n, this.copySampleValue_(n - 1);+ }+ if (n === o) break;+ if (r = s, s = t[++n], e < s)+ break t;+ }+ a = t.length;+ break n;+ }+ if (!(e >= r)) {+ const o = t[1];+ e < o && (n = 2, r = o);+ for (let c = n - 2; ; ) {+ if (r === void 0)+ return this._cachedIndex = 0, this.copySampleValue_(0);+ if (n === c) break;+ if (s = r, r = t[--n - 1], e >= r)+ break t;+ }+ a = n, n = 0;+ break n;+ }+ break e;+ }+ for (; n < a; ) {+ const o = n + a >>> 1;+ e < t[o] ? a = o : n = o + 1;+ }+ if (s = t[n], r = t[n - 1], r === void 0)+ return this._cachedIndex = 0, this.copySampleValue_(0);+ if (s === void 0)+ return n = t.length, this._cachedIndex = n, this.copySampleValue_(n - 1);+ }+ this._cachedIndex = n, this.intervalChanged_(n, r, s);+ }+ return this.interpolate_(n, r, e, s);+ }+ /**+ * Returns the interpolation settings.+ *+ * @return {Object} The interpolation settings.+ */+ getSettings_() {+ return this.settings || this.DefaultSettings_;+ }+ /**+ * Copies a sample value to the result buffer.+ *+ * @param {number} index - An index into the sample value buffer.+ * @return {TypedArray} The result buffer.+ */+ copySampleValue_(e) {+ const t = this.resultBuffer, n = this.sampleValues, s = this.valueSize, r = e * s;+ for (let a = 0; a !== s; ++a)+ t[a] = n[r + a];+ return t;+ }+ /**+ * Copies a sample value to the result buffer.+ *+ * @abstract+ * @param {number} i1 - An index into the sample value buffer.+ * @param {number} t0 - The previous interpolation factor.+ * @param {number} t - The current interpolation factor.+ * @param {number} t1 - The next interpolation factor.+ * @return {TypedArray} The result buffer.+ */+ interpolate_() {+ throw new Error("call to abstract method");+ }+ /**+ * Optional method that is executed when the interval has changed.+ *+ * @param {number} i1 - An index into the sample value buffer.+ * @param {number} t0 - The previous interpolation factor.+ * @param {number} t - The current interpolation factor.+ */+ intervalChanged_() {+ }+}+class xy extends $o {+ /**+ * Constructs a new cubic interpolant.+ *+ * @param {TypedArray} parameterPositions - The parameter positions hold the interpolation factors.+ * @param {TypedArray} sampleValues - The sample values.+ * @param {number} sampleSize - The sample size+ * @param {TypedArray} [resultBuffer] - The result buffer.+ */+ constructor(e, t, n, s) {+ super(e, t, n, s), this._weightPrev = -0, this._offsetPrev = -0, this._weightNext = -0, this._offsetNext = -0, this.DefaultSettings_ = {+ endingStart: ra,+ endingEnd: ra+ };+ }+ intervalChanged_(e, t, n) {+ const s = this.parameterPositions;+ let r = e - 2, a = e + 1, o = s[r], c = s[a];+ if (o === void 0)+ switch (this.getSettings_().endingStart) {+ case aa:+ r = e, o = 2 * t - n;+ break;+ case Ml:+ r = s.length - 2, o = t + s[r] - s[r + 1];+ break;+ default:+ r = e, o = n;+ }+ if (c === void 0)+ switch (this.getSettings_().endingEnd) {+ case aa:+ a = e, c = 2 * n - t;+ break;+ case Ml:+ a = 1, c = n + s[1] - s[0];+ break;+ default:+ a = e - 1, c = t;+ }+ const l = (n - t) * 0.5, h = this.valueSize;+ this._weightPrev = l / (t - o), this._weightNext = l / (c - n), this._offsetPrev = r * h, this._offsetNext = a * h;+ }+ interpolate_(e, t, n, s) {+ const r = this.resultBuffer, a = this.sampleValues, o = this.valueSize, c = e * o, l = c - o, h = this._offsetPrev, u = this._offsetNext, d = this._weightPrev, f = this._weightNext, m = (n - t) / (s - t), A = m * m, g = A * m, p = -d * g + 2 * d * A - d * m, y = (1 + d) * g + (-1.5 - 2 * d) * A + (-0.5 + d) * m + 1, b = (-1 - f) * g + (1.5 + f) * A + 0.5 * m, E = f * g - f * A;+ for (let M = 0; M !== o; ++M)+ r[M] = p * a[h + M] + y * a[l + M] + b * a[c + M] + E * a[u + M];+ return r;+ }+}+class x0 extends $o {+ /**+ * Constructs a new linear interpolant.+ *+ * @param {TypedArray} parameterPositions - The parameter positions hold the interpolation factors.+ * @param {TypedArray} sampleValues - The sample values.+ * @param {number} sampleSize - The sample size+ * @param {TypedArray} [resultBuffer] - The result buffer.+ */+ constructor(e, t, n, s) {+ super(e, t, n, s);+ }+ interpolate_(e, t, n, s) {+ const r = this.resultBuffer, a = this.sampleValues, o = this.valueSize, c = e * o, l = c - o, h = (n - t) / (s - t), u = 1 - h;+ for (let d = 0; d !== o; ++d)+ r[d] = a[l + d] * u + a[c + d] * h;+ return r;+ }+}+class _y extends $o {+ /**+ * Constructs a new discrete interpolant.+ *+ * @param {TypedArray} parameterPositions - The parameter positions hold the interpolation factors.+ * @param {TypedArray} sampleValues - The sample values.+ * @param {number} sampleSize - The sample size+ * @param {TypedArray} [resultBuffer] - The result buffer.+ */+ constructor(e, t, n, s) {+ super(e, t, n, s);+ }+ interpolate_(e) {+ return this.copySampleValue_(e - 1);+ }+}+class wi {+ /**+ * Constructs a new keyframe track.+ *+ * @param {string} name - The keyframe track's name.+ * @param {Array<number>} times - A list of keyframe times.+ * @param {Array<number>} values - A list of keyframe values.+ * @param {(InterpolateLinear|InterpolateDiscrete|InterpolateSmooth)} [interpolation] - The interpolation type.+ */+ constructor(e, t, n, s) {+ if (e === void 0) throw new Error("THREE.KeyframeTrack: track name is undefined");+ if (t === void 0 || t.length === 0) throw new Error("THREE.KeyframeTrack: no keyframes in track named " + e);+ this.name = e, this.times = Pc(t, this.TimeBufferType), this.values = Pc(n, this.ValueBufferType), this.setInterpolation(s || this.DefaultInterpolation);+ }+ /**+ * Converts the keyframe track to JSON.+ *+ * @static+ * @param {KeyframeTrack} track - The keyframe track to serialize.+ * @return {Object} The serialized keyframe track as JSON.+ */+ static toJSON(e) {+ const t = e.constructor;+ let n;+ if (t.toJSON !== this.toJSON)+ n = t.toJSON(e);+ else {+ n = {+ name: e.name,+ times: Pc(e.times, Array),+ values: Pc(e.values, Array)+ };+ const s = e.getInterpolation();+ s !== e.DefaultInterpolation && (n.interpolation = s);+ }+ return n.type = e.ValueTypeName, n;+ }+ /**+ * Factory method for creating a new discrete interpolant.+ *+ * @static+ * @param {TypedArray} [result] - The result buffer.+ * @return {DiscreteInterpolant} The new interpolant.+ */+ InterpolantFactoryMethodDiscrete(e) {+ return new _y(this.times, this.values, this.getValueSize(), e);+ }+ /**+ * Factory method for creating a new linear interpolant.+ *+ * @static+ * @param {TypedArray} [result] - The result buffer.+ * @return {LinearInterpolant} The new interpolant.+ */+ InterpolantFactoryMethodLinear(e) {+ return new x0(this.times, this.values, this.getValueSize(), e);+ }+ /**+ * Factory method for creating a new smooth interpolant.+ *+ * @static+ * @param {TypedArray} [result] - The result buffer.+ * @return {CubicInterpolant} The new interpolant.+ */+ InterpolantFactoryMethodSmooth(e) {+ return new xy(this.times, this.values, this.getValueSize(), e);+ }+ /**+ * Defines the interpolation factor method for this keyframe track.+ *+ * @param {(InterpolateLinear|InterpolateDiscrete|InterpolateSmooth)} interpolation - The interpolation type.+ * @return {KeyframeTrack} A reference to this keyframe track.+ */+ setInterpolation(e) {+ let t;+ switch (e) {+ case Po:+ t = this.InterpolantFactoryMethodDiscrete;+ break;+ case ko:+ t = this.InterpolantFactoryMethodLinear;+ break;+ case _h:+ t = this.InterpolantFactoryMethodSmooth;+ break;+ }+ if (t === void 0) {+ const n = "unsupported interpolation for " + this.ValueTypeName + " keyframe track named " + this.name;+ if (this.createInterpolant === void 0)+ if (e !== this.DefaultInterpolation)+ this.setInterpolation(this.DefaultInterpolation);+ else+ throw new Error(n);+ return console.warn("THREE.KeyframeTrack:", n), this;+ }+ return this.createInterpolant = t, this;+ }+ /**+ * Returns the current interpolation type.+ *+ * @return {(InterpolateLinear|InterpolateDiscrete|InterpolateSmooth)} The interpolation type.+ */+ getInterpolation() {+ switch (this.createInterpolant) {+ case this.InterpolantFactoryMethodDiscrete:+ return Po;+ case this.InterpolantFactoryMethodLinear:+ return ko;+ case this.InterpolantFactoryMethodSmooth:+ return _h;+ }+ }+ /**+ * Returns the value size.+ *+ * @return {number} The value size.+ */+ getValueSize() {+ return this.values.length / this.times.length;+ }+ /**+ * Moves all keyframes either forward or backward in time.+ *+ * @param {number} timeOffset - The offset to move the time values.+ * @return {KeyframeTrack} A reference to this keyframe track.+ */+ shift(e) {+ if (e !== 0) {+ const t = this.times;+ for (let n = 0, s = t.length; n !== s; ++n)+ t[n] += e;+ }+ return this;+ }+ /**+ * Scale all keyframe times by a factor (useful for frame - seconds conversions).+ *+ * @param {number} timeScale - The time scale.+ * @return {KeyframeTrack} A reference to this keyframe track.+ */+ scale(e) {+ if (e !== 1) {+ const t = this.times;+ for (let n = 0, s = t.length; n !== s; ++n)+ t[n] *= e;+ }+ return this;+ }+ /**+ * Removes keyframes before and after animation without changing any values within the defined time range.+ *+ * Note: The method does not shift around keys to the start of the track time, because for interpolated+ * keys this will change their values+ *+ * @param {number} startTime - The start time.+ * @param {number} endTime - The end time.+ * @return {KeyframeTrack} A reference to this keyframe track.+ */+ trim(e, t) {+ const n = this.times, s = n.length;+ let r = 0, a = s - 1;+ for (; r !== s && n[r] < e; )+ ++r;+ for (; a !== -1 && n[a] > t; )+ --a;+ if (++a, r !== 0 || a !== s) {+ r >= a && (a = Math.max(a, 1), r = a - 1);+ const o = this.getValueSize();+ this.times = n.slice(r, a), this.values = this.values.slice(r * o, a * o);+ }+ return this;+ }+ /**+ * Performs minimal validation on the keyframe track. Returns `true` if the values+ * are valid.+ *+ * @return {boolean} Whether the keyframes are valid or not.+ */+ validate() {+ let e = !0;+ const t = this.getValueSize();+ t - Math.floor(t) !== 0 && (console.error("THREE.KeyframeTrack: Invalid value size in track.", this), e = !1);+ const n = this.times, s = this.values, r = n.length;+ r === 0 && (console.error("THREE.KeyframeTrack: Track is empty.", this), e = !1);+ let a = null;+ for (let o = 0; o !== r; o++) {+ const c = n[o];+ if (typeof c == "number" && isNaN(c)) {+ console.error("THREE.KeyframeTrack: Time is not a valid number.", this, o, c), e = !1;+ break;+ }+ if (a !== null && a > c) {+ console.error("THREE.KeyframeTrack: Out of order keys.", this, o, c, a), e = !1;+ break;+ }+ a = c;+ }+ if (s !== void 0 && my(s))+ for (let o = 0, c = s.length; o !== c; ++o) {+ const l = s[o];+ if (isNaN(l)) {+ console.error("THREE.KeyframeTrack: Value is not a valid number.", this, o, l), e = !1;+ break;+ }+ }+ return e;+ }+ /**+ * Optimizes this keyframe track by removing equivalent sequential keys (which are+ * common in morph target sequences).+ *+ * @return {AnimationClip} A reference to this animation clip.+ */+ optimize() {+ const e = this.times.slice(), t = this.values.slice(), n = this.getValueSize(), s = this.getInterpolation() === _h, r = e.length - 1;+ let a = 1;+ for (let o = 1; o < r; ++o) {+ let c = !1;+ const l = e[o], h = e[o + 1];+ if (l !== h && (o !== 1 || l !== e[0]))+ if (s)+ c = !0;+ else {+ const u = o * n, d = u - n, f = u + n;+ for (let m = 0; m !== n; ++m) {+ const A = t[u + m];+ if (A !== t[d + m] || A !== t[f + m]) {+ c = !0;+ break;+ }+ }+ }+ if (c) {+ if (o !== a) {+ e[a] = e[o];+ const u = o * n, d = a * n;+ for (let f = 0; f !== n; ++f)+ t[d + f] = t[u + f];+ }+ ++a;+ }+ }+ if (r > 0) {+ e[a] = e[r];+ for (let o = r * n, c = a * n, l = 0; l !== n; ++l)+ t[c + l] = t[o + l];+ ++a;+ }+ return a !== e.length ? (this.times = e.slice(0, a), this.values = t.slice(0, a * n)) : (this.times = e, this.values = t), this;+ }+ /**+ * Returns a new keyframe track with copied values from this instance.+ *+ * @return {KeyframeTrack} A clone of this instance.+ */+ clone() {+ const e = this.times.slice(), t = this.values.slice(), n = this.constructor, s = new n(this.name, e, t);+ return s.createInterpolant = this.createInterpolant, s;+ }+}+wi.prototype.ValueTypeName = "";+wi.prototype.TimeBufferType = Float32Array;+wi.prototype.ValueBufferType = Float32Array;+wi.prototype.DefaultInterpolation = ko;+class Oa extends wi {+ /**+ * Constructs a new boolean keyframe track.+ *+ * This keyframe track type has no `interpolation` parameter because the+ * interpolation is always discrete.+ *+ * @param {string} name - The keyframe track's name.+ * @param {Array<number>} times - A list of keyframe times.+ * @param {Array<number>} values - A list of keyframe values.+ */+ constructor(e, t, n) {+ super(e, t, n);+ }+}+Oa.prototype.ValueTypeName = "bool";+Oa.prototype.ValueBufferType = Array;+Oa.prototype.DefaultInterpolation = Po;+Oa.prototype.InterpolantFactoryMethodLinear = void 0;+Oa.prototype.InterpolantFactoryMethodSmooth = void 0;+class _0 extends wi {+ /**+ * Constructs a new color keyframe track.+ *+ * @param {string} name - The keyframe track's name.+ * @param {Array<number>} times - A list of keyframe times.+ * @param {Array<number>} values - A list of keyframe values.+ * @param {(InterpolateLinear|InterpolateDiscrete|InterpolateSmooth)} [interpolation] - The interpolation type.+ */+ constructor(e, t, n, s) {+ super(e, t, n, s);+ }+}+_0.prototype.ValueTypeName = "color";+class Ma extends wi {+ /**+ * Constructs a new number keyframe track.+ *+ * @param {string} name - The keyframe track's name.+ * @param {Array<number>} times - A list of keyframe times.+ * @param {Array<number>} values - A list of keyframe values.+ * @param {(InterpolateLinear|InterpolateDiscrete|InterpolateSmooth)} [interpolation] - The interpolation type.+ */+ constructor(e, t, n, s) {+ super(e, t, n, s);+ }+}+Ma.prototype.ValueTypeName = "number";+class Ey extends $o {+ /**+ * Constructs a new SLERP interpolant.+ *+ * @param {TypedArray} parameterPositions - The parameter positions hold the interpolation factors.+ * @param {TypedArray} sampleValues - The sample values.+ * @param {number} sampleSize - The sample size+ * @param {TypedArray} [resultBuffer] - The result buffer.+ */+ constructor(e, t, n, s) {+ super(e, t, n, s);+ }+ interpolate_(e, t, n, s) {+ const r = this.resultBuffer, a = this.sampleValues, o = this.valueSize, c = (n - t) / (s - t);+ let l = e * o;+ for (let h = l + o; l !== h; l += 4)+ Yn.slerpFlat(r, 0, a, l - o, a, l, c);+ return r;+ }+}+class Ba extends wi {+ /**+ * Constructs a new Quaternion keyframe track.+ *+ * @param {string} name - The keyframe track's name.+ * @param {Array<number>} times - A list of keyframe times.+ * @param {Array<number>} values - A list of keyframe values.+ * @param {(InterpolateLinear|InterpolateDiscrete|InterpolateSmooth)} [interpolation] - The interpolation type.+ */+ constructor(e, t, n, s) {+ super(e, t, n, s);+ }+ /**+ * Overwritten so the method returns Quaternion based interpolant.+ *+ * @static+ * @param {TypedArray} [result] - The result buffer.+ * @return {QuaternionLinearInterpolant} The new interpolant.+ */+ InterpolantFactoryMethodLinear(e) {+ return new Ey(this.times, this.values, this.getValueSize(), e);+ }+}+Ba.prototype.ValueTypeName = "quaternion";+Ba.prototype.InterpolantFactoryMethodSmooth = void 0;+class Qa extends wi {+ /**+ * Constructs a new string keyframe track.+ *+ * This keyframe track type has no `interpolation` parameter because the+ * interpolation is always discrete.+ *+ * @param {string} name - The keyframe track's name.+ * @param {Array<number>} times - A list of keyframe times.+ * @param {Array<number>} values - A list of keyframe values.+ */+ constructor(e, t, n) {+ super(e, t, n);+ }+}+Qa.prototype.ValueTypeName = "string";+Qa.prototype.ValueBufferType = Array;+Qa.prototype.DefaultInterpolation = Po;+Qa.prototype.InterpolantFactoryMethodLinear = void 0;+Qa.prototype.InterpolantFactoryMethodSmooth = void 0;+class Ta extends wi {+ /**+ * Constructs a new vector keyframe track.+ *+ * @param {string} name - The keyframe track's name.+ * @param {Array<number>} times - A list of keyframe times.+ * @param {Array<number>} values - A list of keyframe values.+ * @param {(InterpolateLinear|InterpolateDiscrete|InterpolateSmooth)} [interpolation] - The interpolation type.+ */+ constructor(e, t, n, s) {+ super(e, t, n, s);+ }+}+Ta.prototype.ValueTypeName = "vector";+class Fl {+ /**+ * Constructs a new animation clip.+ *+ * Note: Instead of instantiating an AnimationClip directly with the constructor, you can+ * use the static interface of this class for creating clips. In most cases though, animation clips+ * will automatically be created by loaders when importing animated 3D assets.+ *+ * @param {string} [name=''] - The clip's name.+ * @param {number} [duration=-1] - The clip's duration in seconds. If a negative value is passed,+ * the duration will be calculated from the passed keyframes.+ * @param {Array<KeyframeTrack>} tracks - An array of keyframe tracks.+ * @param {(NormalAnimationBlendMode|AdditiveAnimationBlendMode)} [blendMode=NormalAnimationBlendMode] - Defines how the animation+ * is blended/combined when two or more animations are simultaneously played.+ */+ constructor(e = "", t = -1, n = [], s = xf) {+ this.name = e, this.tracks = n, this.duration = t, this.blendMode = s, this.uuid = Ei(), this.duration < 0 && this.resetDuration();+ }+ /**+ * Factory method for creating an animation clip from the given JSON.+ *+ * @static+ * @param {Object} json - The serialized animation clip.+ * @return {AnimationClip} The new animation clip.+ */+ static parse(e) {+ const t = [], n = e.tracks, s = 1 / (e.fps || 1);+ for (let a = 0, o = n.length; a !== o; ++a)+ t.push(wy(n[a]).scale(s));+ const r = new this(e.name, e.duration, t, e.blendMode);+ return r.uuid = e.uuid, r;+ }+ /**+ * Serializes the given animation clip into JSON.+ *+ * @static+ * @param {AnimationClip} clip - The animation clip to serialize.+ * @return {Object} The JSON object.+ */+ static toJSON(e) {+ const t = [], n = e.tracks, s = {+ name: e.name,+ duration: e.duration,+ tracks: t,+ uuid: e.uuid,+ blendMode: e.blendMode+ };+ for (let r = 0, a = n.length; r !== a; ++r)+ t.push(wi.toJSON(n[r]));+ return s;+ }+ /**+ * Returns a new animation clip from the passed morph targets array of a+ * geometry, taking a name and the number of frames per second.+ *+ * Note: The fps parameter is required, but the animation speed can be+ * overridden via {@link AnimationAction#setDuration}.+ *+ * @static+ * @param {string} name - The name of the animation clip.+ * @param {Array<Object>} morphTargetSequence - A sequence of morph targets.+ * @param {number} fps - The Frames-Per-Second value.+ * @param {boolean} noLoop - Whether the clip should be no loop or not.+ * @return {AnimationClip} The new animation clip.+ */+ static CreateFromMorphTargetSequence(e, t, n, s) {+ const r = t.length, a = [];+ for (let o = 0; o < r; o++) {+ let c = [], l = [];+ c.push(+ (o + r - 1) % r,+ o,+ (o + 1) % r+ ), l.push(0, 1, 0);+ const h = by(c);+ c = Jp(c, 1, h), l = Jp(l, 1, h), !s && c[0] === 0 && (c.push(r), l.push(l[0])), a.push(+ new Ma(+ ".morphTargetInfluences[" + t[o].name + "]",+ c,+ l+ ).scale(1 / n)+ );+ }+ return new this(e, -1, a);+ }+ /**+ * Searches for an animation clip by name, taking as its first parameter+ * either an array of clips, or a mesh or geometry that contains an+ * array named "animations" property.+ *+ * @static+ * @param {(Array<AnimationClip>|Object3D)} objectOrClipArray - The array or object to search through.+ * @param {string} name - The name to search for.+ * @return {?AnimationClip} The found animation clip. Returns `null` if no clip has been found.+ */+ static findByName(e, t) {+ let n = e;+ if (!Array.isArray(e)) {+ const s = e;+ n = s.geometry && s.geometry.animations || s.animations;+ }+ for (let s = 0; s < n.length; s++)+ if (n[s].name === t)+ return n[s];+ return null;+ }+ /**+ * Returns an array of new AnimationClips created from the morph target+ * sequences of a geometry, trying to sort morph target names into+ * animation-group-based patterns like "Walk_001, Walk_002, Run_001, Run_002...".+ *+ * See {@link MD2Loader#parse} as an example for how the method should be used.+ *+ * @static+ * @param {Array<Object>} morphTargets - A sequence of morph targets.+ * @param {number} fps - The Frames-Per-Second value.+ * @param {boolean} noLoop - Whether the clip should be no loop or not.+ * @return {Array<AnimationClip>} An array of new animation clips.+ */+ static CreateClipsFromMorphTargetSequences(e, t, n) {+ const s = {}, r = /^([\w-]*?)([\d]+)$/;+ for (let o = 0, c = e.length; o < c; o++) {+ const l = e[o], h = l.name.match(r);+ if (h && h.length > 1) {+ const u = h[1];+ let d = s[u];+ d || (s[u] = d = []), d.push(l);+ }+ }+ const a = [];+ for (const o in s)+ a.push(this.CreateFromMorphTargetSequence(o, s[o], t, n));+ return a;+ }+ /**+ * Parses the `animation.hierarchy` format and returns a new animation clip.+ *+ * @static+ * @deprecated since r175.+ * @param {Object} animation - A serialized animation clip as JSON.+ * @param {Array<Bones>} bones - An array of bones.+ * @return {?AnimationClip} The new animation clip.+ */+ static parseAnimation(e, t) {+ if (console.warn("THREE.AnimationClip: parseAnimation() is deprecated and will be removed with r185"), !e)+ return console.error("THREE.AnimationClip: No animation in JSONLoader data."), null;+ const n = function(u, d, f, m, A) {+ if (f.length !== 0) {+ const g = [], p = [];+ b0(f, g, p, m), g.length !== 0 && A.push(new u(d, g, p));+ }+ }, s = [], r = e.name || "default", a = e.fps || 30, o = e.blendMode;+ let c = e.length || -1;+ const l = e.hierarchy || [];+ for (let u = 0; u < l.length; u++) {+ const d = l[u].keys;+ if (!(!d || d.length === 0))+ if (d[0].morphTargets) {+ const f = {};+ let m;+ for (m = 0; m < d.length; m++)+ if (d[m].morphTargets)+ for (let A = 0; A < d[m].morphTargets.length; A++)+ f[d[m].morphTargets[A]] = -1;+ for (const A in f) {+ const g = [], p = [];+ for (let y = 0; y !== d[m].morphTargets.length; ++y) {+ const b = d[m];+ g.push(b.time), p.push(b.morphTarget === A ? 1 : 0);+ }+ s.push(new Ma(".morphTargetInfluence[" + A + "]", g, p));+ }+ c = f.length * a;+ } else {+ const f = ".bones[" + t[u].name + "]";+ n(+ Ta,+ f + ".position",+ d,+ "pos",+ s+ ), n(+ Ba,+ f + ".quaternion",+ d,+ "rot",+ s+ ), n(+ Ta,+ f + ".scale",+ d,+ "scl",+ s+ );+ }+ }+ return s.length === 0 ? null : new this(r, c, s, o);+ }+ /**+ * Sets the duration of this clip to the duration of its longest keyframe track.+ *+ * @return {AnimationClip} A reference to this animation clip.+ */+ resetDuration() {+ const e = this.tracks;+ let t = 0;+ for (let n = 0, s = e.length; n !== s; ++n) {+ const r = this.tracks[n];+ t = Math.max(t, r.times[r.times.length - 1]);+ }+ return this.duration = t, this;+ }+ /**+ * Trims all tracks to the clip's duration.+ *+ * @return {AnimationClip} A reference to this animation clip.+ */+ trim() {+ for (let e = 0; e < this.tracks.length; e++)+ this.tracks[e].trim(0, this.duration);+ return this;+ }+ /**+ * Performs minimal validation on each track in the clip. Returns `true` if all+ * tracks are valid.+ *+ * @return {boolean} Whether the clip's keyframes are valid or not.+ */+ validate() {+ let e = !0;+ for (let t = 0; t < this.tracks.length; t++)+ e = e && this.tracks[t].validate();+ return e;+ }+ /**+ * Optimizes each track by removing equivalent sequential keys (which are+ * common in morph target sequences).+ *+ * @return {AnimationClip} A reference to this animation clip.+ */+ optimize() {+ for (let e = 0; e < this.tracks.length; e++)+ this.tracks[e].optimize();+ return this;+ }+ /**+ * Returns a new animation clip with copied values from this instance.+ *+ * @return {AnimationClip} A clone of this instance.+ */+ clone() {+ const e = [];+ for (let t = 0; t < this.tracks.length; t++)+ e.push(this.tracks[t].clone());+ return new this.constructor(this.name, this.duration, e, this.blendMode);+ }+ /**+ * Serializes this animation clip into JSON.+ *+ * @return {Object} The JSON object.+ */+ toJSON() {+ return this.constructor.toJSON(this);+ }+}+function yy(i) {+ switch (i.toLowerCase()) {+ case "scalar":+ case "double":+ case "float":+ case "number":+ case "integer":+ return Ma;+ case "vector":+ case "vector2":+ case "vector3":+ case "vector4":+ return Ta;+ case "color":+ return _0;+ case "quaternion":+ return Ba;+ case "bool":+ case "boolean":+ return Oa;+ case "string":+ return Qa;+ }+ throw new Error("THREE.KeyframeTrack: Unsupported typeName: " + i);+}+function wy(i) {+ if (i.type === void 0)+ throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");+ const e = yy(i.type);+ if (i.times === void 0) {+ const t = [], n = [];+ b0(i.keys, t, n, "value"), i.times = t, i.values = n;+ }+ return e.parse !== void 0 ? e.parse(i) : new e(i.name, i.times, i.values, i.interpolation);+}+const ss = {+ /**+ * Whether caching is enabled or not.+ *+ * @static+ * @type {boolean}+ * @default false+ */+ enabled: !1,+ /**+ * A dictionary that holds cached files.+ *+ * @static+ * @type {Object<string,Object>}+ */+ files: {},+ /**+ * Adds a cache entry with a key to reference the file. If this key already+ * holds a file, it is overwritten.+ *+ * @static+ * @param {string} key - The key to reference the cached file.+ * @param {Object} file - The file to be cached.+ */+ add: function(i, e) {+ this.enabled !== !1 && (this.files[i] = e);+ },+ /**+ * Gets the cached value for the given key.+ *+ * @static+ * @param {string} key - The key to reference the cached file.+ * @return {Object|undefined} The cached file. If the key does not exist `undefined` is returned.+ */+ get: function(i) {+ if (this.enabled !== !1)+ return this.files[i];+ },+ /**+ * Removes the cached file associated with the given key.+ *+ * @static+ * @param {string} key - The key to reference the cached file.+ */+ remove: function(i) {+ delete this.files[i];+ },+ /**+ * Remove all values from the cache.+ *+ * @static+ */+ clear: function() {+ this.files = {};+ }+};+class E0 {+ /**+ * Constructs a new loading manager.+ *+ * @param {Function} [onLoad] - Executes when all items have been loaded.+ * @param {Function} [onProgress] - Executes when single items have been loaded.+ * @param {Function} [onError] - Executes when an error occurs.+ */+ constructor(e, t, n) {+ const s = this;+ let r = !1, a = 0, o = 0, c;+ const l = [];+ this.onStart = void 0, this.onLoad = e, this.onProgress = t, this.onError = n, this.itemStart = function(h) {+ o++, r === !1 && s.onStart !== void 0 && s.onStart(h, a, o), r = !0;+ }, this.itemEnd = function(h) {+ a++, s.onProgress !== void 0 && s.onProgress(h, a, o), a === o && (r = !1, s.onLoad !== void 0 && s.onLoad());+ }, this.itemError = function(h) {+ s.onError !== void 0 && s.onError(h);+ }, this.resolveURL = function(h) {+ return c ? c(h) : h;+ }, this.setURLModifier = function(h) {+ return c = h, this;+ }, this.addHandler = function(h, u) {+ return l.push(h, u), this;+ }, this.removeHandler = function(h) {+ const u = l.indexOf(h);+ return u !== -1 && l.splice(u, 2), this;+ }, this.getHandler = function(h) {+ for (let u = 0, d = l.length; u < d; u += 2) {+ const f = l[u], m = l[u + 1];+ if (f.global && (f.lastIndex = 0), f.test(h))+ return m;+ }+ return null;+ };+ }+}+const vy = /* @__PURE__ */ new E0();+class ps {+ /**+ * Constructs a new loader.+ *+ * @param {LoadingManager} [manager] - The loading manager.+ */+ constructor(e) {+ this.manager = e !== void 0 ? e : vy, this.crossOrigin = "anonymous", this.withCredentials = !1, this.path = "", this.resourcePath = "", this.requestHeader = {};+ }+ /**+ * This method needs to be implemented by all concrete loaders. It holds the+ * logic for loading assets from the backend.+ *+ * @param {string} url - The path/URL of the file to be loaded.+ * @param {Function} onLoad - Executed when the loading process has been finished.+ * @param {onProgressCallback} [onProgress] - Executed while the loading is in progress.+ * @param {onErrorCallback} [onError] - Executed when errors occur.+ */+ load() {+ }+ /**+ * A async version of {@link Loader#load}.+ *+ * @param {string} url - The path/URL of the file to be loaded.+ * @param {onProgressCallback} [onProgress] - Executed while the loading is in progress.+ * @return {Promise} A Promise that resolves when the asset has been loaded.+ */+ loadAsync(e, t) {+ const n = this;+ return new Promise(function(s, r) {+ n.load(e, s, t, r);+ });+ }+ /**+ * This method needs to be implemented by all concrete loaders. It holds the+ * logic for parsing the asset into three.js entities.+ *+ * @param {any} data - The data to parse.+ */+ parse() {+ }+ /**+ * Sets the `crossOrigin` String to implement CORS for loading the URL+ * from a different domain that allows CORS.+ *+ * @param {string} crossOrigin - The `crossOrigin` value.+ * @return {Loader} A reference to this instance.+ */+ setCrossOrigin(e) {+ return this.crossOrigin = e, this;+ }+ /**+ * Whether the XMLHttpRequest uses credentials such as cookies, authorization+ * headers or TLS client certificates, see [XMLHttpRequest.withCredentials]{@link https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials}.+ *+ * Note: This setting has no effect if you are loading files locally or from the same domain.+ *+ * @param {boolean} value - The `withCredentials` value.+ * @return {Loader} A reference to this instance.+ */+ setWithCredentials(e) {+ return this.withCredentials = e, this;+ }+ /**+ * Sets the base path for the asset.+ *+ * @param {string} path - The base path.+ * @return {Loader} A reference to this instance.+ */+ setPath(e) {+ return this.path = e, this;+ }+ /**+ * Sets the base path for dependent resources like textures.+ *+ * @param {string} resourcePath - The resource path.+ * @return {Loader} A reference to this instance.+ */+ setResourcePath(e) {+ return this.resourcePath = e, this;+ }+ /**+ * Sets the given request header.+ *+ * @param {Object} requestHeader - A [request header]{@link https://developer.mozilla.org/en-US/docs/Glossary/Request_header}+ * for configuring the HTTP request.+ * @return {Loader} A reference to this instance.+ */+ setRequestHeader(e) {+ return this.requestHeader = e, this;+ }+}+ps.DEFAULT_MATERIAL_NAME = "__DEFAULT";+const Ki = {};+class Cy extends Error {+ constructor(e, t) {+ super(e), this.response = t;+ }+}+class Ps extends ps {+ /**+ * Constructs a new file loader.+ *+ * @param {LoadingManager} [manager] - The loading manager.+ */+ constructor(e) {+ super(e), this.mimeType = "", this.responseType = "";+ }+ /**+ * Starts loading from the given URL and pass the loaded response to the `onLoad()` callback.+ *+ * @param {string} url - The path/URL of the file to be loaded. This can also be a data URI.+ * @param {function(any)} onLoad - Executed when the loading process has been finished.+ * @param {onProgressCallback} [onProgress] - Executed while the loading is in progress.+ * @param {onErrorCallback} [onError] - Executed when errors occur.+ * @return {any|undefined} The cached resource if available.+ */+ load(e, t, n, s) {+ e === void 0 && (e = ""), this.path !== void 0 && (e = this.path + e), e = this.manager.resolveURL(e);+ const r = ss.get(e);+ if (r !== void 0)+ return this.manager.itemStart(e), setTimeout(() => {+ t && t(r), this.manager.itemEnd(e);+ }, 0), r;+ if (Ki[e] !== void 0) {+ Ki[e].push({+ onLoad: t,+ onProgress: n,+ onError: s+ });+ return;+ }+ Ki[e] = [], Ki[e].push({+ onLoad: t,+ onProgress: n,+ onError: s+ });+ const a = new Request(e, {+ headers: new Headers(this.requestHeader),+ credentials: this.withCredentials ? "include" : "same-origin"+ // An abort controller could be added within a future PR+ }), o = this.mimeType, c = this.responseType;+ fetch(a).then((l) => {+ if (l.status === 200 || l.status === 0) {+ if (l.status === 0 && console.warn("THREE.FileLoader: HTTP Status 0 received."), typeof ReadableStream > "u" || l.body === void 0 || l.body.getReader === void 0)+ return l;+ const h = Ki[e], u = l.body.getReader(), d = l.headers.get("X-File-Size") || l.headers.get("Content-Length"), f = d ? parseInt(d) : 0, m = f !== 0;+ let A = 0;+ const g = new ReadableStream({+ start(p) {+ y();+ function y() {+ u.read().then(({ done: b, value: E }) => {+ if (b)+ p.close();+ else {+ A += E.byteLength;+ const M = new ProgressEvent("progress", { lengthComputable: m, loaded: A, total: f });+ for (let w = 0, S = h.length; w < S; w++) {+ const T = h[w];+ T.onProgress && T.onProgress(M);+ }+ p.enqueue(E), y();+ }+ }, (b) => {+ p.error(b);+ });+ }+ }+ });+ return new Response(g);+ } else+ throw new Cy(`fetch for "${l.url}" responded with ${l.status}: ${l.statusText}`, l);+ }).then((l) => {+ switch (c) {+ case "arraybuffer":+ return l.arrayBuffer();+ case "blob":+ return l.blob();+ case "document":+ return l.text().then((h) => new DOMParser().parseFromString(h, o));+ case "json":+ return l.json();+ default:+ if (o === "")+ return l.text();+ {+ const u = /charset="?([^;"\s]*)"?/i.exec(o), d = u && u[1] ? u[1].toLowerCase() : void 0, f = new TextDecoder(d);+ return l.arrayBuffer().then((m) => f.decode(m));+ }+ }+ }).then((l) => {+ ss.add(e, l);+ const h = Ki[e];+ delete Ki[e];+ for (let u = 0, d = h.length; u < d; u++) {+ const f = h[u];+ f.onLoad && f.onLoad(l);+ }+ }).catch((l) => {+ const h = Ki[e];+ if (h === void 0)+ throw this.manager.itemError(e), l;+ delete Ki[e];+ for (let u = 0, d = h.length; u < d; u++) {+ const f = h[u];+ f.onError && f.onError(l);+ }+ this.manager.itemError(e);+ }).finally(() => {+ this.manager.itemEnd(e);+ }), this.manager.itemStart(e);+ }+ /**+ * Sets the expected response type.+ *+ * @param {('arraybuffer'|'blob'|'document'|'json'|'')} value - The response type.+ * @return {FileLoader} A reference to this file loader.+ */+ setResponseType(e) {+ return this.responseType = e, this;+ }+ /**+ * Sets the expected mime type of the loaded file.+ *+ * @param {string} value - The mime type.+ * @return {FileLoader} A reference to this file loader.+ */+ setMimeType(e) {+ return this.mimeType = e, this;+ }+}+class Sy extends ps {+ /**+ * Constructs a new image loader.+ *+ * @param {LoadingManager} [manager] - The loading manager.+ */+ constructor(e) {+ super(e);+ }+ /**+ * Starts loading from the given URL and passes the loaded image+ * to the `onLoad()` callback. The method also returns a new `Image` object which can+ * directly be used for texture creation. If you do it this way, the texture+ * may pop up in your scene once the respective loading process is finished.+ *+ * @param {string} url - The path/URL of the file to be loaded. This can also be a data URI.+ * @param {function(Image)} onLoad - Executed when the loading process has been finished.+ * @param {onProgressCallback} onProgress - Unsupported in this loader.+ * @param {onErrorCallback} onError - Executed when errors occur.+ * @return {Image} The image.+ */+ load(e, t, n, s) {+ this.path !== void 0 && (e = this.path + e), e = this.manager.resolveURL(e);+ const r = this, a = ss.get(e);+ if (a !== void 0)+ return r.manager.itemStart(e), setTimeout(function() {+ t && t(a), r.manager.itemEnd(e);+ }, 0), a;+ const o = Uo("img");+ function c() {+ h(), ss.add(e, this), t && t(this), r.manager.itemEnd(e);+ }+ function l(u) {+ h(), s && s(u), r.manager.itemError(e), r.manager.itemEnd(e);+ }+ function h() {+ o.removeEventListener("load", c, !1), o.removeEventListener("error", l, !1);+ }+ return o.addEventListener("load", c, !1), o.addEventListener("error", l, !1), e.slice(0, 5) !== "data:" && this.crossOrigin !== void 0 && (o.crossOrigin = this.crossOrigin), r.manager.itemStart(e), o.src = e, o;+ }+}+class Iy extends ps {+ /**+ * Constructs a new data texture loader.+ *+ * @param {LoadingManager} [manager] - The loading manager.+ */+ constructor(e) {+ super(e);+ }+ /**+ * Starts loading from the given URL and passes the loaded data texture+ * to the `onLoad()` callback. The method also returns a new texture object which can+ * directly be used for material creation. If you do it this way, the texture+ * may pop up in your scene once the respective loading process is finished.+ *+ * @param {string} url - The path/URL of the file to be loaded. This can also be a data URI.+ * @param {function(DataTexture)} onLoad - Executed when the loading process has been finished.+ * @param {onProgressCallback} onProgress - Executed while the loading is in progress.+ * @param {onErrorCallback} onError - Executed when errors occur.+ * @return {DataTexture} The data texture.+ */+ load(e, t, n, s) {+ const r = this, a = new Xl(), o = new Ps(this.manager);+ return o.setResponseType("arraybuffer"), o.setRequestHeader(this.requestHeader), o.setPath(this.path), o.setWithCredentials(r.withCredentials), o.load(e, function(c) {+ let l;+ try {+ l = r.parse(c);+ } catch (h) {+ if (s !== void 0)+ s(h);+ else {+ console.error(h);+ return;+ }+ }+ l.image !== void 0 ? a.image = l.image : l.data !== void 0 && (a.image.width = l.width, a.image.height = l.height, a.image.data = l.data), a.wrapS = l.wrapS !== void 0 ? l.wrapS : _i, a.wrapT = l.wrapT !== void 0 ? l.wrapT : _i, a.magFilter = l.magFilter !== void 0 ? l.magFilter : qt, a.minFilter = l.minFilter !== void 0 ? l.minFilter : qt, a.anisotropy = l.anisotropy !== void 0 ? l.anisotropy : 1, l.colorSpace !== void 0 && (a.colorSpace = l.colorSpace), l.flipY !== void 0 && (a.flipY = l.flipY), l.format !== void 0 && (a.format = l.format), l.type !== void 0 && (a.type = l.type), l.mipmaps !== void 0 && (a.mipmaps = l.mipmaps, a.minFilter = si), l.mipmapCount === 1 && (a.minFilter = qt), l.generateMipmaps !== void 0 && (a.generateMipmaps = l.generateMipmaps), a.needsUpdate = !0, t && t(a, l);+ }, n, s), a;+ }+}+class My extends ps {+ /**+ * Constructs a new texture loader.+ *+ * @param {LoadingManager} [manager] - The loading manager.+ */+ constructor(e) {+ super(e);+ }+ /**+ * Starts loading from the given URL and pass the fully loaded texture+ * to the `onLoad()` callback. The method also returns a new texture object which can+ * directly be used for material creation. If you do it this way, the texture+ * may pop up in your scene once the respective loading process is finished.+ *+ * @param {string} url - The path/URL of the file to be loaded. This can also be a data URI.+ * @param {function(Texture)} onLoad - Executed when the loading process has been finished.+ * @param {onProgressCallback} onProgress - Unsupported in this loader.+ * @param {onErrorCallback} onError - Executed when errors occur.+ * @return {Texture} The texture.+ */+ load(e, t, n, s) {+ const r = new cn(), a = new Sy(this.manager);+ return a.setCrossOrigin(this.crossOrigin), a.setPath(this.path), a.load(e, function(o) {+ r.image = o, r.needsUpdate = !0, t !== void 0 && t(r);+ }, n, s), r;+ }+}+class ec extends kt {+ /**+ * Constructs a new light.+ *+ * @param {(number|Color|string)} [color=0xffffff] - The light's color.+ * @param {number} [intensity=1] - The light's strength/intensity.+ */+ constructor(e, t = 1) {+ super(), this.isLight = !0, this.type = "Light", this.color = new je(e), this.intensity = t;+ }+ /**+ * Frees the GPU-related resources allocated by this instance. Call this+ * method whenever this instance is no longer used in your app.+ */+ dispose() {+ }+ copy(e, t) {+ return super.copy(e, t), this.color.copy(e.color), this.intensity = e.intensity, this;+ }+ toJSON(e) {+ const t = super.toJSON(e);+ return t.object.color = this.color.getHex(), t.object.intensity = this.intensity, this.groundColor !== void 0 && (t.object.groundColor = this.groundColor.getHex()), this.distance !== void 0 && (t.object.distance = this.distance), this.angle !== void 0 && (t.object.angle = this.angle), this.decay !== void 0 && (t.object.decay = this.decay), this.penumbra !== void 0 && (t.object.penumbra = this.penumbra), this.shadow !== void 0 && (t.object.shadow = this.shadow.toJSON()), this.target !== void 0 && (t.object.target = this.target.uuid), t;+ }+}+class By extends ec {+ /**+ * Constructs a new hemisphere light.+ *+ * @param {(number|Color|string)} [skyColor=0xffffff] - The light's sky color.+ * @param {(number|Color|string)} [groundColor=0xffffff] - The light's ground color.+ * @param {number} [intensity=1] - The light's strength/intensity.+ */+ constructor(e, t, n) {+ super(e, n), this.isHemisphereLight = !0, this.type = "HemisphereLight", this.position.copy(kt.DEFAULT_UP), this.updateMatrix(), this.groundColor = new je(t);+ }+ copy(e, t) {+ return super.copy(e, t), this.groundColor.copy(e.groundColor), this;+ }+}+const Wh = /* @__PURE__ */ new et(), Zp = /* @__PURE__ */ new H(), $p = /* @__PURE__ */ new H();+class If {+ /**+ * Constructs a new light shadow.+ *+ * @param {Camera} camera - The light's view of the world.+ */+ constructor(e) {+ this.camera = e, this.intensity = 1, this.bias = 0, this.normalBias = 0, this.radius = 1, this.blurSamples = 8, this.mapSize = new Ze(512, 512), this.mapType = rn, this.map = null, this.mapPass = null, this.matrix = new et(), this.autoUpdate = !0, this.needsUpdate = !1, this._frustum = new vf(), this._frameExtents = new Ze(1, 1), this._viewportCount = 1, this._viewports = [+ new wt(0, 0, 1, 1)+ ];+ }+ /**+ * Used internally by the renderer to get the number of viewports that need+ * to be rendered for this shadow.+ *+ * @return {number} The viewport count.+ */+ getViewportCount() {+ return this._viewportCount;+ }+ /**+ * Gets the shadow cameras frustum. Used internally by the renderer to cull objects.+ *+ * @return {Frustum} The shadow camera frustum.+ */+ getFrustum() {+ return this._frustum;+ }+ /**+ * Update the matrices for the camera and shadow, used internally by the renderer.+ *+ * @param {Light} light - The light for which the shadow is being rendered.+ */+ updateMatrices(e) {+ const t = this.camera, n = this.matrix;+ Zp.setFromMatrixPosition(e.matrixWorld), t.position.copy(Zp), $p.setFromMatrixPosition(e.target.matrixWorld), t.lookAt($p), t.updateMatrixWorld(), Wh.multiplyMatrices(t.projectionMatrix, t.matrixWorldInverse), this._frustum.setFromProjectionMatrix(Wh), n.set(+ 0.5,+ 0,+ 0,+ 0.5,+ 0,+ 0.5,+ 0,+ 0.5,+ 0,+ 0,+ 0.5,+ 0.5,+ 0,+ 0,+ 0,+ 1+ ), n.multiply(Wh);+ }+ /**+ * Returns a viewport definition for the given viewport index.+ *+ * @param {number} viewportIndex - The viewport index.+ * @return {Vector4} The viewport.+ */+ getViewport(e) {+ return this._viewports[e];+ }+ /**+ * Returns the frame extends.+ *+ * @return {Vector2} The frame extends.+ */+ getFrameExtents() {+ return this._frameExtents;+ }+ /**+ * Frees the GPU-related resources allocated by this instance. Call this+ * method whenever this instance is no longer used in your app.+ */+ dispose() {+ this.map && this.map.dispose(), this.mapPass && this.mapPass.dispose();+ }+ /**+ * Copies the values of the given light shadow instance to this instance.+ *+ * @param {LightShadow} source - The light shadow to copy.+ * @return {LightShadow} A reference to this light shadow instance.+ */+ 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;+ }+ /**+ * Returns a new light shadow instance with copied values from this instance.+ *+ * @return {LightShadow} A clone of this instance.+ */+ clone() {+ return new this.constructor().copy(this);+ }+ /**+ * Serializes the light shadow into JSON.+ *+ * @return {Object} A JSON object representing the serialized light shadow.+ * @see {@link ObjectLoader#parse}+ */+ toJSON() {+ const e = {};+ return this.intensity !== 1 && (e.intensity = this.intensity), this.bias !== 0 && (e.bias = this.bias), this.normalBias !== 0 && (e.normalBias = this.normalBias), this.radius !== 1 && (e.radius = this.radius), (this.mapSize.x !== 512 || this.mapSize.y !== 512) && (e.mapSize = this.mapSize.toArray()), e.camera = this.camera.toJSON(!1).object, delete e.camera.matrix, e;+ }+}+class Ty extends If {+ /**+ * Constructs a new spot light shadow.+ */+ constructor() {+ super(new vn(50, 1, 0.5, 500)), this.isSpotLightShadow = !0, this.focus = 1;+ }+ updateMatrices(e) {+ const t = this.camera, n = Sa * 2 * e.angle * this.focus, s = this.mapSize.width / this.mapSize.height, r = e.distance || t.far;+ (n !== t.fov || s !== t.aspect || r !== t.far) && (t.fov = n, t.aspect = s, t.far = r, t.updateProjectionMatrix()), super.updateMatrices(e);+ }+ copy(e) {+ return super.copy(e), this.focus = e.focus, this;+ }+}+class Ry extends ec {+ /**+ * Constructs a new spot light.+ *+ * @param {(number|Color|string)} [color=0xffffff] - The light's color.+ * @param {number} [intensity=1] - The light's strength/intensity measured in candela (cd).+ * @param {number} [distance=0] - Maximum range of the light. `0` means no limit.+ * @param {number} [angle=Math.PI/3] - Maximum angle of light dispersion from its direction whose upper bound is `Math.PI/2`.+ * @param {number} [penumbra=0] - Percent of the spotlight cone that is attenuated due to penumbra. Value range is `[0,1]`.+ * @param {number} [decay=2] - The amount the light dims along the distance of the light.+ */+ constructor(e, t, n = 0, s = Math.PI / 3, r = 0, a = 2) {+ super(e, t), this.isSpotLight = !0, this.type = "SpotLight", this.position.copy(kt.DEFAULT_UP), this.updateMatrix(), this.target = new kt(), this.distance = n, this.angle = s, this.penumbra = r, this.decay = a, this.map = null, this.shadow = new Ty();+ }+ /**+ * The light's power. Power is the luminous power of the light measured in lumens (lm).+ * Changing the power will also change the light's intensity.+ *+ * @type {number}+ */+ get power() {+ return this.intensity * Math.PI;+ }+ set power(e) {+ this.intensity = e / Math.PI;+ }+ dispose() {+ this.shadow.dispose();+ }+ copy(e, t) {+ return super.copy(e, t), this.distance = e.distance, this.angle = e.angle, this.penumbra = e.penumbra, this.decay = e.decay, this.target = e.target.clone(), this.shadow = e.shadow.clone(), this;+ }+}+const eA = /* @__PURE__ */ new et(), no = /* @__PURE__ */ new H(), qh = /* @__PURE__ */ new H();+class Ny extends If {+ /**+ * Constructs a new point light shadow.+ */+ constructor() {+ super(new vn(90, 1, 0.5, 500)), this.isPointLightShadow = !0, this._frameExtents = new Ze(4, 2), this._viewportCount = 6, this._viewports = [+ // These viewports map a cube-map onto a 2D texture with the+ // following orientation:+ //+ // xzXZ+ // y Y+ //+ // X - Positive x direction+ // x - Negative x direction+ // Y - Positive y direction+ // y - Negative y direction+ // Z - Positive z direction+ // z - Negative z direction+ // positive X+ new wt(2, 1, 1, 1),+ // negative X+ new wt(0, 1, 1, 1),+ // positive Z+ new wt(3, 1, 1, 1),+ // negative Z+ new wt(1, 1, 1, 1),+ // positive Y+ new wt(3, 0, 1, 1),+ // negative Y+ new wt(1, 0, 1, 1)+ ], this._cubeDirections = [+ new H(1, 0, 0),+ new H(-1, 0, 0),+ new H(0, 0, 1),+ new H(0, 0, -1),+ new H(0, 1, 0),+ new H(0, -1, 0)+ ], this._cubeUps = [+ new H(0, 1, 0),+ new H(0, 1, 0),+ new H(0, 1, 0),+ new H(0, 1, 0),+ new H(0, 0, 1),+ new H(0, 0, -1)+ ];+ }+ /**+ * Update the matrices for the camera and shadow, used internally by the renderer.+ *+ * @param {Light} light - The light for which the shadow is being rendered.+ * @param {number} [viewportIndex=0] - The viewport index.+ */+ updateMatrices(e, t = 0) {+ const n = this.camera, s = this.matrix, r = e.distance || n.far;+ r !== n.far && (n.far = r, n.updateProjectionMatrix()), no.setFromMatrixPosition(e.matrixWorld), n.position.copy(no), qh.copy(n.position), qh.add(this._cubeDirections[t]), n.up.copy(this._cubeUps[t]), n.lookAt(qh), n.updateMatrixWorld(), s.makeTranslation(-no.x, -no.y, -no.z), eA.multiplyMatrices(n.projectionMatrix, n.matrixWorldInverse), this._frustum.setFromProjectionMatrix(eA);+ }+}+class y0 extends ec {+ /**+ * Constructs a new point light.+ *+ * @param {(number|Color|string)} [color=0xffffff] - The light's color.+ * @param {number} [intensity=1] - The light's strength/intensity measured in candela (cd).+ * @param {number} [distance=0] - Maximum range of the light. `0` means no limit.+ * @param {number} [decay=2] - The amount the light dims along the distance of the light.+ */+ constructor(e, t, n = 0, s = 2) {+ super(e, t), this.isPointLight = !0, this.type = "PointLight", this.distance = n, this.decay = s, this.shadow = new Ny();+ }+ /**+ * The light's power. Power is the luminous power of the light measured in lumens (lm).+ * Changing the power will also change the light's intensity.+ *+ * @type {number}+ */+ get power() {+ return this.intensity * 4 * Math.PI;+ }+ set power(e) {+ this.intensity = e / (4 * Math.PI);+ }+ 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;+ }+}+class Mf extends f0 {+ /**+ * Constructs a new orthographic camera.+ *+ * @param {number} [left=-1] - The left plane of the camera's frustum.+ * @param {number} [right=1] - The right plane of the camera's frustum.+ * @param {number} [top=1] - The top plane of the camera's frustum.+ * @param {number} [bottom=-1] - The bottom plane of the camera's frustum.+ * @param {number} [near=0.1] - The camera's near plane.+ * @param {number} [far=2000] - The camera's far plane.+ */+ constructor(e = -1, t = 1, n = 1, s = -1, r = 0.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 = s, this.near = r, 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;+ }+ /**+ * Sets an offset in a larger frustum. This is useful for multi-window or+ * multi-monitor/multi-machine setups.+ *+ * @param {number} fullWidth - The full width of multiview setup.+ * @param {number} fullHeight - The full height of multiview setup.+ * @param {number} x - The horizontal offset of the subcamera.+ * @param {number} y - The vertical offset of the subcamera.+ * @param {number} width - The width of subcamera.+ * @param {number} height - The height of subcamera.+ * @see {@link PerspectiveCamera#setViewOffset}+ */+ setViewOffset(e, t, n, s, r, 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 = s, this.view.width = r, this.view.height = a, this.updateProjectionMatrix();+ }+ /**+ * Removes the view offset from the projection matrix.+ */+ clearViewOffset() {+ this.view !== null && (this.view.enabled = !1), this.updateProjectionMatrix();+ }+ /**+ * Updates the camera's projection matrix. Must be called after any change of+ * camera properties.+ */+ updateProjectionMatrix() {+ const e = (this.right - this.left) / (2 * this.zoom), t = (this.top - this.bottom) / (2 * this.zoom), n = (this.right + this.left) / 2, s = (this.top + this.bottom) / 2;+ let r = n - e, a = n + e, o = s + t, c = s - t;+ if (this.view !== null && this.view.enabled) {+ const l = (this.right - this.left) / this.view.fullWidth / this.zoom, h = (this.top - this.bottom) / this.view.fullHeight / this.zoom;+ r += l * this.view.offsetX, a = r + l * this.view.width, o -= h * this.view.offsetY, c = o - h * this.view.height;+ }+ this.projectionMatrix.makeOrthographic(r, a, o, c, this.near, this.far, this.coordinateSystem), this.projectionMatrixInverse.copy(this.projectionMatrix).invert();+ }+ toJSON(e) {+ const 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;+ }+}+class Fy extends If {+ /**+ * Constructs a new directional light shadow.+ */+ constructor() {+ super(new Mf(-5, 5, 5, -5, 0.5, 500)), this.isDirectionalLightShadow = !0;+ }+}+class w0 extends ec {+ /**+ * Constructs a new directional light.+ *+ * @param {(number|Color|string)} [color=0xffffff] - The light's color.+ * @param {number} [intensity=1] - The light's strength/intensity.+ */+ constructor(e, t) {+ super(e, t), this.isDirectionalLight = !0, this.type = "DirectionalLight", this.position.copy(kt.DEFAULT_UP), this.updateMatrix(), this.target = new kt(), this.shadow = new Fy();+ }+ dispose() {+ this.shadow.dispose();+ }+ copy(e) {+ return super.copy(e), this.target = e.target.clone(), this.shadow = e.shadow.clone(), this;+ }+}+class Dy extends ec {+ /**+ * Constructs a new ambient light.+ *+ * @param {(number|Color|string)} [color=0xffffff] - The light's color.+ * @param {number} [intensity=1] - The light's strength/intensity.+ */+ constructor(e, t) {+ super(e, t), this.isAmbientLight = !0, this.type = "AmbientLight";+ }+}+class Aa {+ /**+ * Extracts the base URL from the given URL.+ *+ * @param {string} url -The URL to extract the base URL from.+ * @return {string} The extracted base URL.+ */+ static extractUrlBase(e) {+ const t = e.lastIndexOf("/");+ return t === -1 ? "./" : e.slice(0, t + 1);+ }+ /**+ * Resolves relative URLs against the given path. Absolute paths, data urls,+ * and blob URLs will be returned as is. Invalid URLs will return an empty+ * string.+ *+ * @param {string} url -The URL to resolve.+ * @param {string} path - The base path for relative URLs to be resolved against.+ * @return {string} The resolved URL.+ */+ static resolveURL(e, t) {+ return typeof e != "string" || e === "" ? "" : (/^https?:\/\//i.test(t) && /^\//.test(e) && (t = t.replace(/(^https?:\/\/[^\/]+).*/i, "$1")), /^(https?:)?\/\//i.test(e) || /^data:.*,.*$/i.test(e) || /^blob:.*$/i.test(e) ? e : t + e);+ }+}+class Ly extends ps {+ /**+ * Constructs a new image bitmap loader.+ *+ * @param {LoadingManager} [manager] - The loading manager.+ */+ constructor(e) {+ super(e), this.isImageBitmapLoader = !0, typeof createImageBitmap > "u" && console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."), typeof fetch > "u" && console.warn("THREE.ImageBitmapLoader: fetch() not supported."), this.options = { premultiplyAlpha: "none" };+ }+ /**+ * Sets the given loader options. The structure of the object must match the `options` parameter of+ * [createImageBitmap]{@link https://developer.mozilla.org/en-US/docs/Web/API/Window/createImageBitmap}.+ *+ * @param {Object} options - The loader options to set.+ * @return {ImageBitmapLoader} A reference to this image bitmap loader.+ */+ setOptions(e) {+ return this.options = e, this;+ }+ /**+ * Starts loading from the given URL and pass the loaded image bitmap to the `onLoad()` callback.+ *+ * @param {string} url - The path/URL of the file to be loaded. This can also be a data URI.+ * @param {function(ImageBitmap)} onLoad - Executed when the loading process has been finished.+ * @param {onProgressCallback} onProgress - Unsupported in this loader.+ * @param {onErrorCallback} onError - Executed when errors occur.+ * @return {ImageBitmap|undefined} The image bitmap.+ */+ load(e, t, n, s) {+ e === void 0 && (e = ""), this.path !== void 0 && (e = this.path + e), e = this.manager.resolveURL(e);+ const r = this, a = ss.get(e);+ if (a !== void 0) {+ if (r.manager.itemStart(e), a.then) {+ a.then((l) => {+ t && t(l), r.manager.itemEnd(e);+ }).catch((l) => {+ s && s(l);+ });+ return;+ }+ return setTimeout(function() {+ t && t(a), r.manager.itemEnd(e);+ }, 0), a;+ }+ const o = {};+ o.credentials = this.crossOrigin === "anonymous" ? "same-origin" : "include", o.headers = this.requestHeader;+ const c = fetch(e, o).then(function(l) {+ return l.blob();+ }).then(function(l) {+ return createImageBitmap(l, Object.assign(r.options, { colorSpaceConversion: "none" }));+ }).then(function(l) {+ return ss.add(e, l), t && t(l), r.manager.itemEnd(e), l;+ }).catch(function(l) {+ s && s(l), ss.remove(e), r.manager.itemError(e), r.manager.itemEnd(e);+ });+ ss.add(e, c), r.manager.itemStart(e);+ }+}+class Py extends vn {+ /**+ * Constructs a new array camera.+ *+ * @param {Array<PerspectiveCamera>} [array=[]] - An array of perspective sub cameras.+ */+ constructor(e = []) {+ super(), this.isArrayCamera = !0, this.isMultiViewCamera = !1, this.cameras = e;+ }+}+class ky {+ /**+ * Constructs a new property mixer.+ *+ * @param {PropertyBinding} binding - The property binding.+ * @param {string} typeName - The keyframe track type name.+ * @param {number} valueSize - The keyframe track value size.+ */+ constructor(e, t, n) {+ this.binding = e, this.valueSize = n;+ let s, r, a;+ switch (t) {+ case "quaternion":+ s = this._slerp, r = this._slerpAdditive, a = this._setAdditiveIdentityQuaternion, this.buffer = new Float64Array(n * 6), this._workIndex = 5;+ break;+ case "string":+ case "bool":+ s = this._select, r = this._select, a = this._setAdditiveIdentityOther, this.buffer = new Array(n * 5);+ break;+ default:+ s = this._lerp, r = this._lerpAdditive, a = this._setAdditiveIdentityNumeric, this.buffer = new Float64Array(n * 5);+ }+ this._mixBufferRegion = s, this._mixBufferRegionAdditive = r, this._setIdentity = a, this._origIndex = 3, this._addIndex = 4, this.cumulativeWeight = 0, this.cumulativeWeightAdditive = 0, this.useCount = 0, this.referenceCount = 0;+ }+ /**+ * Accumulates data in the `incoming` region into `accu<i>`.+ *+ * @param {number} accuIndex - The accumulation index.+ * @param {number} weight - The weight.+ */+ accumulate(e, t) {+ const n = this.buffer, s = this.valueSize, r = e * s + s;+ let a = this.cumulativeWeight;+ if (a === 0) {+ for (let o = 0; o !== s; ++o)+ n[r + o] = n[o];+ a = t;+ } else {+ a += t;+ const o = t / a;+ this._mixBufferRegion(n, r, 0, o, s);+ }+ this.cumulativeWeight = a;+ }+ /**+ * Accumulates data in the `incoming` region into `add`.+ *+ * @param {number} weight - The weight.+ */+ accumulateAdditive(e) {+ const t = this.buffer, n = this.valueSize, s = n * this._addIndex;+ this.cumulativeWeightAdditive === 0 && this._setIdentity(), this._mixBufferRegionAdditive(t, s, 0, e, n), this.cumulativeWeightAdditive += e;+ }+ /**+ * Applies the state of `accu<i>` to the binding when accus differ.+ *+ * @param {number} accuIndex - The accumulation index.+ */+ apply(e) {+ const t = this.valueSize, n = this.buffer, s = e * t + t, r = this.cumulativeWeight, a = this.cumulativeWeightAdditive, o = this.binding;+ if (this.cumulativeWeight = 0, this.cumulativeWeightAdditive = 0, r < 1) {+ const c = t * this._origIndex;+ this._mixBufferRegion(+ n,+ s,+ c,+ 1 - r,+ t+ );+ }+ a > 0 && this._mixBufferRegionAdditive(n, s, this._addIndex * t, 1, t);+ for (let c = t, l = t + t; c !== l; ++c)+ if (n[c] !== n[c + t]) {+ o.setValue(n, s);+ break;+ }+ }+ /**+ * Remembers the state of the bound property and copy it to both accus.+ */+ saveOriginalState() {+ const e = this.binding, t = this.buffer, n = this.valueSize, s = n * this._origIndex;+ e.getValue(t, s);+ for (let r = n, a = s; r !== a; ++r)+ t[r] = t[s + r % n];+ this._setIdentity(), this.cumulativeWeight = 0, this.cumulativeWeightAdditive = 0;+ }+ /**+ * Applies the state previously taken via {@link PropertyMixer#saveOriginalState} to the binding.+ */+ restoreOriginalState() {+ const e = this.valueSize * 3;+ this.binding.setValue(this.buffer, e);+ }+ // internals+ _setAdditiveIdentityNumeric() {+ const e = this._addIndex * this.valueSize, t = e + this.valueSize;+ for (let n = e; n < t; n++)+ this.buffer[n] = 0;+ }+ _setAdditiveIdentityQuaternion() {+ this._setAdditiveIdentityNumeric(), this.buffer[this._addIndex * this.valueSize + 3] = 1;+ }+ _setAdditiveIdentityOther() {+ const e = this._origIndex * this.valueSize, t = this._addIndex * this.valueSize;+ for (let n = 0; n < this.valueSize; n++)+ this.buffer[t + n] = this.buffer[e + n];+ }+ // mix functions+ _select(e, t, n, s, r) {+ if (s >= 0.5)+ for (let a = 0; a !== r; ++a)+ e[t + a] = e[n + a];+ }+ _slerp(e, t, n, s) {+ Yn.slerpFlat(e, t, e, t, e, n, s);+ }+ _slerpAdditive(e, t, n, s, r) {+ const a = this._workIndex * r;+ Yn.multiplyQuaternionsFlat(e, a, e, t, e, n), Yn.slerpFlat(e, t, e, t, e, a, s);+ }+ _lerp(e, t, n, s, r) {+ const a = 1 - s;+ for (let o = 0; o !== r; ++o) {+ const c = t + o;+ e[c] = e[c] * a + e[n + o] * s;+ }+ }+ _lerpAdditive(e, t, n, s, r) {+ for (let a = 0; a !== r; ++a) {+ const o = t + a;+ e[o] = e[o] + e[n + a] * s;+ }+ }+}+const Bf = "\\[\\]\\.:\\/", Uy = new RegExp("[" + Bf + "]", "g"), Tf = "[^" + Bf + "]", Oy = "[^" + Bf.replace("\\.", "") + "]", Qy = /* @__PURE__ */ /((?:WC+[\/:])*)/.source.replace("WC", Tf), Gy = /* @__PURE__ */ /(WCOD+)?/.source.replace("WCOD", Oy), Hy = /* @__PURE__ */ /(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC", Tf), zy = /* @__PURE__ */ /\.(WC+)(?:\[(.+)\])?/.source.replace("WC", Tf), Vy = new RegExp(+ "^" + Qy + Gy + Hy + zy + "$"+), Wy = ["material", "materials", "bones", "map"];+class qy {+ constructor(e, t, n) {+ const s = n || Ct.parseTrackName(t);+ this._targetGroup = e, this._bindings = e.subscribe_(t, s);+ }+ getValue(e, t) {+ this.bind();+ const n = this._targetGroup.nCachedObjects_, s = this._bindings[n];+ s !== void 0 && s.getValue(e, t);+ }+ setValue(e, t) {+ const n = this._bindings;+ for (let s = this._targetGroup.nCachedObjects_, r = n.length; s !== r; ++s)+ n[s].setValue(e, t);+ }+ bind() {+ const e = this._bindings;+ for (let t = this._targetGroup.nCachedObjects_, n = e.length; t !== n; ++t)+ e[t].bind();+ }+ unbind() {+ const e = this._bindings;+ for (let t = this._targetGroup.nCachedObjects_, n = e.length; t !== n; ++t)+ e[t].unbind();+ }+}+class Ct {+ /**+ * Constructs a new property binding.+ *+ * @param {Object} rootNode - The root node.+ * @param {string} path - The path.+ * @param {?Object} [parsedPath] - The parsed path.+ */+ constructor(e, t, n) {+ this.path = t, this.parsedPath = n || Ct.parseTrackName(t), this.node = Ct.findNode(e, this.parsedPath.nodeName), this.rootNode = e, this.getValue = this._getValue_unbound, this.setValue = this._setValue_unbound;+ }+ /**+ * Factory method for creating a property binding from the given parameters.+ *+ * @static+ * @param {Object} root - The root node.+ * @param {string} path - The path.+ * @param {?Object} [parsedPath] - The parsed path.+ * @return {PropertyBinding|Composite} The created property binding or composite.+ */+ static create(e, t, n) {+ return e && e.isAnimationObjectGroup ? new Ct.Composite(e, t, n) : new Ct(e, t, n);+ }+ /**+ * Replaces spaces with underscores and removes unsupported characters from+ * node names, to ensure compatibility with parseTrackName().+ *+ * @param {string} name - Node name to be sanitized.+ * @return {string} The sanitized node name.+ */+ static sanitizeNodeName(e) {+ return e.replace(/\s/g, "_").replace(Uy, "");+ }+ /**+ * Parses the given track name (an object path to an animated property) and+ * returns an object with information about the path. Matches strings in the following forms:+ *+ * - nodeName.property+ * - nodeName.property[accessor]+ * - nodeName.material.property[accessor]+ * - uuid.property[accessor]+ * - uuid.objectName[objectIndex].propertyName[propertyIndex]+ * - parentName/nodeName.property+ * - parentName/parentName/nodeName.property[index]+ * - .bone[Armature.DEF_cog].position+ * - scene:helium_balloon_model:helium_balloon_model.position+ *+ * @static+ * @param {string} trackName - The track name to parse.+ * @return {Object} The parsed track name as an object.+ */+ static parseTrackName(e) {+ const t = Vy.exec(e);+ if (t === null)+ throw new Error("PropertyBinding: Cannot parse trackName: " + e);+ const n = {+ // directoryName: matches[ 1 ], // (tschw) currently unused+ nodeName: t[2],+ objectName: t[3],+ objectIndex: t[4],+ propertyName: t[5],+ // required+ propertyIndex: t[6]+ }, s = n.nodeName && n.nodeName.lastIndexOf(".");+ if (s !== void 0 && s !== -1) {+ const r = n.nodeName.substring(s + 1);+ Wy.indexOf(r) !== -1 && (n.nodeName = n.nodeName.substring(0, s), n.objectName = r);+ }+ if (n.propertyName === null || n.propertyName.length === 0)+ throw new Error("PropertyBinding: can not parse propertyName from trackName: " + e);+ return n;+ }+ /**+ * Searches for a node in the hierarchy of the given root object by the given+ * node name.+ *+ * @static+ * @param {Object} root - The root object.+ * @param {string|number} nodeName - The name of the node.+ * @return {?Object} The found node. Returns `null` if no object was found.+ */+ static findNode(e, t) {+ if (t === void 0 || t === "" || t === "." || t === -1 || t === e.name || t === e.uuid)+ return e;+ if (e.skeleton) {+ const n = e.skeleton.getBoneByName(t);+ if (n !== void 0)+ return n;+ }+ if (e.children) {+ const n = function(r) {+ for (let a = 0; a < r.length; a++) {+ const o = r[a];+ if (o.name === t || o.uuid === t)+ return o;+ const c = n(o.children);+ if (c) return c;+ }+ return null;+ }, s = n(e.children);+ if (s)+ return s;+ }+ return null;+ }+ // these are used to "bind" a nonexistent property+ _getValue_unavailable() {+ }+ _setValue_unavailable() {+ }+ // Getters+ _getValue_direct(e, t) {+ e[t] = this.targetObject[this.propertyName];+ }+ _getValue_array(e, t) {+ const n = this.resolvedProperty;+ for (let s = 0, r = n.length; s !== r; ++s)+ e[t++] = n[s];+ }+ _getValue_arrayElement(e, t) {+ e[t] = this.resolvedProperty[this.propertyIndex];+ }+ _getValue_toArray(e, t) {+ this.resolvedProperty.toArray(e, t);+ }+ // Direct+ _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;+ }+ // EntireArray+ _setValue_array(e, t) {+ const n = this.resolvedProperty;+ for (let s = 0, r = n.length; s !== r; ++s)+ n[s] = e[t++];+ }+ _setValue_array_setNeedsUpdate(e, t) {+ const n = this.resolvedProperty;+ for (let s = 0, r = n.length; s !== r; ++s)+ n[s] = e[t++];+ this.targetObject.needsUpdate = !0;+ }+ _setValue_array_setMatrixWorldNeedsUpdate(e, t) {+ const n = this.resolvedProperty;+ for (let s = 0, r = n.length; s !== r; ++s)+ n[s] = e[t++];+ this.targetObject.matrixWorldNeedsUpdate = !0;+ }+ // ArrayElement+ _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;+ }+ // HasToFromArray+ _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);+ }+ /**+ * Creates a getter / setter pair for the property tracked by this binding.+ */+ bind() {+ let e = this.node;+ const t = this.parsedPath, n = t.objectName, s = t.propertyName;+ let r = t.propertyIndex;+ if (e || (e = Ct.findNode(this.rootNode, t.nodeName), this.node = e), this.getValue = this._getValue_unavailable, this.setValue = this._setValue_unavailable, !e) {+ console.warn("THREE.PropertyBinding: No target node found for track: " + this.path + ".");+ return;+ }+ if (n) {+ let l = t.objectIndex;+ switch (n) {+ case "materials":+ if (!e.material) {+ console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.", this);+ return;+ }+ if (!e.material.materials) {+ console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.", this);+ return;+ }+ e = e.material.materials;+ break;+ case "bones":+ if (!e.skeleton) {+ console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.", this);+ return;+ }+ e = e.skeleton.bones;+ for (let h = 0; h < e.length; h++)+ if (e[h].name === l) {+ l = h;+ break;+ }+ break;+ case "map":+ if ("map" in e) {+ e = e.map;+ break;+ }+ if (!e.material) {+ console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.", this);+ return;+ }+ if (!e.material.map) {+ console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.", this);+ return;+ }+ e = e.material.map;+ break;+ default:+ if (e[n] === void 0) {+ console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.", this);+ return;+ }+ e = e[n];+ }+ if (l !== void 0) {+ if (e[l] === void 0) {+ console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.", this, e);+ return;+ }+ e = e[l];+ }+ }+ const a = e[s];+ if (a === void 0) {+ const l = t.nodeName;+ console.error("THREE.PropertyBinding: Trying to update property for track: " + l + "." + s + " but it wasn't found.", e);+ return;+ }+ let o = this.Versioning.None;+ this.targetObject = e, e.isMaterial === !0 ? o = this.Versioning.NeedsUpdate : e.isObject3D === !0 && (o = this.Versioning.MatrixWorldNeedsUpdate);+ let c = this.BindingType.Direct;+ if (r !== void 0) {+ if (s === "morphTargetInfluences") {+ if (!e.geometry) {+ console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.", this);+ return;+ }+ if (!e.geometry.morphAttributes) {+ console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.", this);+ return;+ }+ e.morphTargetDictionary[r] !== void 0 && (r = e.morphTargetDictionary[r]);+ }+ c = this.BindingType.ArrayElement, this.resolvedProperty = a, this.propertyIndex = r;+ } else a.fromArray !== void 0 && a.toArray !== void 0 ? (c = this.BindingType.HasFromToArray, this.resolvedProperty = a) : Array.isArray(a) ? (c = this.BindingType.EntireArray, this.resolvedProperty = a) : this.propertyName = s;+ this.getValue = this.GetterByBindingType[c], this.setValue = this.SetterByBindingTypeAndVersioning[c][o];+ }+ /**+ * Unbinds the property.+ */+ unbind() {+ this.node = null, this.getValue = this._getValue_unbound, this.setValue = this._setValue_unbound;+ }+}+Ct.Composite = qy;+Ct.prototype.BindingType = {+ Direct: 0,+ EntireArray: 1,+ ArrayElement: 2,+ HasFromToArray: 3+};+Ct.prototype.Versioning = {+ None: 0,+ NeedsUpdate: 1,+ MatrixWorldNeedsUpdate: 2+};+Ct.prototype.GetterByBindingType = [+ Ct.prototype._getValue_direct,+ Ct.prototype._getValue_array,+ Ct.prototype._getValue_arrayElement,+ Ct.prototype._getValue_toArray+];+Ct.prototype.SetterByBindingTypeAndVersioning = [+ [+ // Direct+ Ct.prototype._setValue_direct,+ Ct.prototype._setValue_direct_setNeedsUpdate,+ Ct.prototype._setValue_direct_setMatrixWorldNeedsUpdate+ ],+ [+ // EntireArray+ Ct.prototype._setValue_array,+ Ct.prototype._setValue_array_setNeedsUpdate,+ Ct.prototype._setValue_array_setMatrixWorldNeedsUpdate+ ],+ [+ // ArrayElement+ Ct.prototype._setValue_arrayElement,+ Ct.prototype._setValue_arrayElement_setNeedsUpdate,+ Ct.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate+ ],+ [+ // HasToFromArray+ Ct.prototype._setValue_fromArray,+ Ct.prototype._setValue_fromArray_setNeedsUpdate,+ Ct.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate+ ]+];+class Ky {+ /**+ * Constructs a new animation action.+ *+ * @param {AnimationMixer} mixer - The mixer that is controlled by this action.+ * @param {AnimationClip} clip - The animation clip that holds the actual keyframes.+ * @param {?Object3D} [localRoot=null] - The root object on which this action is performed.+ * @param {(NormalAnimationBlendMode|AdditiveAnimationBlendMode)} [blendMode] - The blend mode.+ */+ constructor(e, t, n = null, s = t.blendMode) {+ this._mixer = e, this._clip = t, this._localRoot = n, this.blendMode = s;+ const r = t.tracks, a = r.length, o = new Array(a), c = {+ endingStart: ra,+ endingEnd: ra+ };+ for (let l = 0; l !== a; ++l) {+ const h = r[l].createInterpolant(null);+ o[l] = h, h.settings = c;+ }+ this._interpolantSettings = c, this._interpolants = o, this._propertyBindings = new Array(a), this._cacheIndex = null, this._byClipCacheIndex = null, this._timeScaleInterpolant = null, this._weightInterpolant = null, this.loop = e0, this._loopCount = -1, this._startTime = null, this.time = 0, this.timeScale = 1, this._effectiveTimeScale = 1, this.weight = 1, this._effectiveWeight = 1, this.repetitions = 1 / 0, this.paused = !1, this.enabled = !0, this.clampWhenFinished = !1, this.zeroSlopeAtStart = !0, this.zeroSlopeAtEnd = !0;+ }+ /**+ * Starts the playback of the animation.+ *+ * @return {AnimationAction} A reference to this animation action.+ */+ play() {+ return this._mixer._activateAction(this), this;+ }+ /**+ * Stops the playback of the animation.+ *+ * @return {AnimationAction} A reference to this animation action.+ */+ stop() {+ return this._mixer._deactivateAction(this), this.reset();+ }+ /**+ * Resets the playback of the animation.+ *+ * @return {AnimationAction} A reference to this animation action.+ */+ reset() {+ return this.paused = !1, this.enabled = !0, this.time = 0, this._loopCount = -1, this._startTime = null, this.stopFading().stopWarping();+ }+ /**+ * Returns `true` if the animation is running.+ *+ * @return {boolean} Whether the animation is running or not.+ */+ isRunning() {+ return this.enabled && !this.paused && this.timeScale !== 0 && this._startTime === null && this._mixer._isActiveAction(this);+ }+ /**+ * Returns `true` when {@link AnimationAction#play} has been called.+ *+ * @return {boolean} Whether the animation is scheduled or not.+ */+ isScheduled() {+ return this._mixer._isActiveAction(this);+ }+ /**+ * Defines the time when the animation should start.+ *+ * @param {number} time - The start time in seconds.+ * @return {AnimationAction} A reference to this animation action.+ */+ startAt(e) {+ return this._startTime = e, this;+ }+ /**+ * Configures the loop settings for this action.+ *+ * @param {(LoopRepeat|LoopOnce|LoopPingPong)} mode - The loop mode.+ * @param {number} repetitions - The number of repetitions.+ * @return {AnimationAction} A reference to this animation action.+ */+ setLoop(e, t) {+ return this.loop = e, this.repetitions = t, this;+ }+ /**+ * Sets the effective weight of this action.+ *+ * An action has no effect and thus an effective weight of zero when the+ * action is disabled.+ *+ * @param {number} weight - The weight to set.+ * @return {AnimationAction} A reference to this animation action.+ */+ setEffectiveWeight(e) {+ return this.weight = e, this._effectiveWeight = this.enabled ? e : 0, this.stopFading();+ }+ /**+ * Returns the effective weight of this action.+ *+ * @return {number} The effective weight.+ */+ getEffectiveWeight() {+ return this._effectiveWeight;+ }+ /**+ * Fades the animation in by increasing its weight gradually from `0` to `1`,+ * within the passed time interval.+ *+ * @param {number} duration - The duration of the fade.+ * @return {AnimationAction} A reference to this animation action.+ */+ fadeIn(e) {+ return this._scheduleFading(e, 0, 1);+ }+ /**+ * Fades the animation out by decreasing its weight gradually from `1` to `0`,+ * within the passed time interval.+ *+ * @param {number} duration - The duration of the fade.+ * @return {AnimationAction} A reference to this animation action.+ */+ fadeOut(e) {+ return this._scheduleFading(e, 1, 0);+ }+ /**+ * Causes this action to fade in and the given action to fade out,+ * within the passed time interval.+ *+ * @param {AnimationAction} fadeOutAction - The animation action to fade out.+ * @param {number} duration - The duration of the fade.+ * @param {boolean} [warp=false] - Whether warping should be used or not.+ * @return {AnimationAction} A reference to this animation action.+ */+ crossFadeFrom(e, t, n = !1) {+ if (e.fadeOut(t), this.fadeIn(t), n === !0) {+ const s = this._clip.duration, r = e._clip.duration, a = r / s, o = s / r;+ e.warp(1, a, t), this.warp(o, 1, t);+ }+ return this;+ }+ /**+ * Causes this action to fade out and the given action to fade in,+ * within the passed time interval.+ *+ * @param {AnimationAction} fadeInAction - The animation action to fade in.+ * @param {number} duration - The duration of the fade.+ * @param {boolean} [warp=false] - Whether warping should be used or not.+ * @return {AnimationAction} A reference to this animation action.+ */+ crossFadeTo(e, t, n = !1) {+ return e.crossFadeFrom(this, t, n);+ }+ /**+ * Stops any fading which is applied to this action.+ *+ * @return {AnimationAction} A reference to this animation action.+ */+ stopFading() {+ const e = this._weightInterpolant;+ return e !== null && (this._weightInterpolant = null, this._mixer._takeBackControlInterpolant(e)), this;+ }+ /**+ * Sets the effective time scale of this action.+ *+ * An action has no effect and thus an effective time scale of zero when the+ * action is paused.+ *+ * @param {number} timeScale - The time scale to set.+ * @return {AnimationAction} A reference to this animation action.+ */+ setEffectiveTimeScale(e) {+ return this.timeScale = e, this._effectiveTimeScale = this.paused ? 0 : e, this.stopWarping();+ }+ /**+ * Returns the effective time scale of this action.+ *+ * @return {number} The effective time scale.+ */+ getEffectiveTimeScale() {+ return this._effectiveTimeScale;+ }+ /**+ * Sets the duration for a single loop of this action.+ *+ * @param {number} duration - The duration to set.+ * @return {AnimationAction} A reference to this animation action.+ */+ setDuration(e) {+ return this.timeScale = this._clip.duration / e, this.stopWarping();+ }+ /**+ * Synchronizes this action with the passed other action.+ *+ * @param {AnimationAction} action - The action to sync with.+ * @return {AnimationAction} A reference to this animation action.+ */+ syncWith(e) {+ return this.time = e.time, this.timeScale = e.timeScale, this.stopWarping();+ }+ /**+ * Decelerates this animation's speed to `0` within the passed time interval.+ *+ * @param {number} duration - The duration.+ * @return {AnimationAction} A reference to this animation action.+ */+ halt(e) {+ return this.warp(this._effectiveTimeScale, 0, e);+ }+ /**+ * Changes the playback speed, within the passed time interval, by modifying+ * {@link AnimationAction#timeScale} gradually from `startTimeScale` to+ * `endTimeScale`.+ *+ * @param {number} startTimeScale - The start time scale.+ * @param {number} endTimeScale - The end time scale.+ * @param {number} duration - The duration.+ * @return {AnimationAction} A reference to this animation action.+ */+ warp(e, t, n) {+ const s = this._mixer, r = s.time, a = this.timeScale;+ let o = this._timeScaleInterpolant;+ o === null && (o = s._lendControlInterpolant(), this._timeScaleInterpolant = o);+ const c = o.parameterPositions, l = o.sampleValues;+ return c[0] = r, c[1] = r + n, l[0] = e / a, l[1] = t / a, this;+ }+ /**+ * Stops any scheduled warping which is applied to this action.+ *+ * @return {AnimationAction} A reference to this animation action.+ */+ stopWarping() {+ const e = this._timeScaleInterpolant;+ return e !== null && (this._timeScaleInterpolant = null, this._mixer._takeBackControlInterpolant(e)), this;+ }+ /**+ * Returns the animation mixer of this animation action.+ *+ * @return {AnimationMixer} The animation mixer.+ */+ getMixer() {+ return this._mixer;+ }+ /**+ * Returns the animation clip of this animation action.+ *+ * @return {AnimationClip} The animation clip.+ */+ getClip() {+ return this._clip;+ }+ /**+ * Returns the root object of this animation action.+ *+ * @return {Object3D} The root object.+ */+ getRoot() {+ return this._localRoot || this._mixer._root;+ }+ // Interna+ _update(e, t, n, s) {+ if (!this.enabled) {+ this._updateWeight(e);+ return;+ }+ const r = this._startTime;+ if (r !== null) {+ const c = (e - r) * n;+ c < 0 || n === 0 ? t = 0 : (this._startTime = null, t = n * c);+ }+ t *= this._updateTimeScale(e);+ const a = this._updateTime(t), o = this._updateWeight(e);+ if (o > 0) {+ const c = this._interpolants, l = this._propertyBindings;+ switch (this.blendMode) {+ case eE:+ for (let h = 0, u = c.length; h !== u; ++h)+ c[h].evaluate(a), l[h].accumulateAdditive(o);+ break;+ case xf:+ default:+ for (let h = 0, u = c.length; h !== u; ++h)+ c[h].evaluate(a), l[h].accumulate(s, o);+ }+ }+ }+ _updateWeight(e) {+ let t = 0;+ if (this.enabled) {+ t = this.weight;+ const n = this._weightInterpolant;+ if (n !== null) {+ const s = n.evaluate(e)[0];+ t *= s, e > n.parameterPositions[1] && (this.stopFading(), s === 0 && (this.enabled = !1));+ }+ }+ return this._effectiveWeight = t, t;+ }+ _updateTimeScale(e) {+ let t = 0;+ if (!this.paused) {+ t = this.timeScale;+ const n = this._timeScaleInterpolant;+ if (n !== null) {+ const s = n.evaluate(e)[0];+ t *= s, e > n.parameterPositions[1] && (this.stopWarping(), t === 0 ? this.paused = !0 : this.timeScale = t);+ }+ }+ return this._effectiveTimeScale = t, t;+ }+ _updateTime(e) {+ const t = this._clip.duration, n = this.loop;+ let s = this.time + e, r = this._loopCount;+ const a = n === $_;+ if (e === 0)+ return r === -1 ? s : a && (r & 1) === 1 ? t - s : s;+ if (n === $m) {+ r === -1 && (this._loopCount = 0, this._setEndings(!0, !0, !1));+ e: {+ if (s >= t)+ s = t;+ else if (s < 0)+ s = 0;+ else {+ this.time = s;+ break e;+ }+ this.clampWhenFinished ? this.paused = !0 : this.enabled = !1, this.time = s, this._mixer.dispatchEvent({+ type: "finished",+ action: this,+ direction: e < 0 ? -1 : 1+ });+ }+ } else {+ if (r === -1 && (e >= 0 ? (r = 0, this._setEndings(!0, this.repetitions === 0, a)) : this._setEndings(this.repetitions === 0, !0, a)), s >= t || s < 0) {+ const o = Math.floor(s / t);+ s -= t * o, r += Math.abs(o);+ const c = this.repetitions - r;+ if (c <= 0)+ this.clampWhenFinished ? this.paused = !0 : this.enabled = !1, s = e > 0 ? t : 0, this.time = s, this._mixer.dispatchEvent({+ type: "finished",+ action: this,+ direction: e > 0 ? 1 : -1+ });+ else {+ if (c === 1) {+ const l = e < 0;+ this._setEndings(l, !l, a);+ } else+ this._setEndings(!1, !1, a);+ this._loopCount = r, this.time = s, this._mixer.dispatchEvent({+ type: "loop",+ action: this,+ loopDelta: o+ });+ }+ } else+ this.time = s;+ if (a && (r & 1) === 1)+ return t - s;+ }+ return s;+ }+ _setEndings(e, t, n) {+ const s = this._interpolantSettings;+ n ? (s.endingStart = aa, s.endingEnd = aa) : (e ? s.endingStart = this.zeroSlopeAtStart ? aa : ra : s.endingStart = Ml, t ? s.endingEnd = this.zeroSlopeAtEnd ? aa : ra : s.endingEnd = Ml);+ }+ _scheduleFading(e, t, n) {+ const s = this._mixer, r = s.time;+ let a = this._weightInterpolant;+ a === null && (a = s._lendControlInterpolant(), this._weightInterpolant = a);+ const o = a.parameterPositions, c = a.sampleValues;+ return o[0] = r, c[0] = t, o[1] = r + e, c[1] = n, this;+ }+}+const jy = new Float32Array(1);+class v0 extends zs {+ /**+ * Constructs a new animation mixer.+ *+ * @param {Object3D} root - The object whose animations shall be played by this mixer.+ */+ constructor(e) {+ super(), this._root = e, this._initMemoryManager(), this._accuIndex = 0, this.time = 0, this.timeScale = 1;+ }+ _bindAction(e, t) {+ const n = e._localRoot || this._root, s = e._clip.tracks, r = s.length, a = e._propertyBindings, o = e._interpolants, c = n.uuid, l = this._bindingsByRootAndName;+ let h = l[c];+ h === void 0 && (h = {}, l[c] = h);+ for (let u = 0; u !== r; ++u) {+ const d = s[u], f = d.name;+ let m = h[f];+ if (m !== void 0)+ ++m.referenceCount, a[u] = m;+ else {+ if (m = a[u], m !== void 0) {+ m._cacheIndex === null && (++m.referenceCount, this._addInactiveBinding(m, c, f));+ continue;+ }+ const A = t && t._propertyBindings[u].binding.parsedPath;+ m = new ky(+ Ct.create(n, f, A),+ d.ValueTypeName,+ d.getValueSize()+ ), ++m.referenceCount, this._addInactiveBinding(m, c, f), a[u] = m;+ }+ o[u].resultBuffer = m.buffer;+ }+ }+ _activateAction(e) {+ if (!this._isActiveAction(e)) {+ if (e._cacheIndex === null) {+ const n = (e._localRoot || this._root).uuid, s = e._clip.uuid, r = this._actionsByClip[s];+ this._bindAction(+ e,+ r && r.knownActions[0]+ ), this._addInactiveAction(e, s, n);+ }+ const t = e._propertyBindings;+ for (let n = 0, s = t.length; n !== s; ++n) {+ const r = t[n];+ r.useCount++ === 0 && (this._lendBinding(r), r.saveOriginalState());+ }+ this._lendAction(e);+ }+ }+ _deactivateAction(e) {+ if (this._isActiveAction(e)) {+ const t = e._propertyBindings;+ for (let n = 0, s = t.length; n !== s; ++n) {+ const r = t[n];+ --r.useCount === 0 && (r.restoreOriginalState(), this._takeBackBinding(r));+ }+ this._takeBackAction(e);+ }+ }+ // Memory manager+ _initMemoryManager() {+ this._actions = [], this._nActiveActions = 0, this._actionsByClip = {}, this._bindings = [], this._nActiveBindings = 0, this._bindingsByRootAndName = {}, this._controlInterpolants = [], this._nActiveControlInterpolants = 0;+ const e = this;+ this.stats = {+ actions: {+ get total() {+ return e._actions.length;+ },+ get inUse() {+ return e._nActiveActions;+ }+ },+ bindings: {+ get total() {+ return e._bindings.length;+ },+ get inUse() {+ return e._nActiveBindings;+ }+ },+ controlInterpolants: {+ get total() {+ return e._controlInterpolants.length;+ },+ get inUse() {+ return e._nActiveControlInterpolants;+ }+ }+ };+ }+ // Memory management for AnimationAction objects+ _isActiveAction(e) {+ const t = e._cacheIndex;+ return t !== null && t < this._nActiveActions;+ }+ _addInactiveAction(e, t, n) {+ const s = this._actions, r = this._actionsByClip;+ let a = r[t];+ if (a === void 0)+ a = {+ knownActions: [e],+ actionByRoot: {}+ }, e._byClipCacheIndex = 0, r[t] = a;+ else {+ const o = a.knownActions;+ e._byClipCacheIndex = o.length, o.push(e);+ }+ e._cacheIndex = s.length, s.push(e), a.actionByRoot[n] = e;+ }+ _removeInactiveAction(e) {+ const t = this._actions, n = t[t.length - 1], s = e._cacheIndex;+ n._cacheIndex = s, t[s] = n, t.pop(), e._cacheIndex = null;+ const r = e._clip.uuid, a = this._actionsByClip, o = a[r], c = o.knownActions, l = c[c.length - 1], h = e._byClipCacheIndex;+ l._byClipCacheIndex = h, c[h] = l, c.pop(), e._byClipCacheIndex = null;+ const u = o.actionByRoot, d = (e._localRoot || this._root).uuid;+ delete u[d], c.length === 0 && delete a[r], this._removeInactiveBindingsForAction(e);+ }+ _removeInactiveBindingsForAction(e) {+ const t = e._propertyBindings;+ for (let n = 0, s = t.length; n !== s; ++n) {+ const r = t[n];+ --r.referenceCount === 0 && this._removeInactiveBinding(r);+ }+ }+ _lendAction(e) {+ const t = this._actions, n = e._cacheIndex, s = this._nActiveActions++, r = t[s];+ e._cacheIndex = s, t[s] = e, r._cacheIndex = n, t[n] = r;+ }+ _takeBackAction(e) {+ const t = this._actions, n = e._cacheIndex, s = --this._nActiveActions, r = t[s];+ e._cacheIndex = s, t[s] = e, r._cacheIndex = n, t[n] = r;+ }+ // Memory management for PropertyMixer objects+ _addInactiveBinding(e, t, n) {+ const s = this._bindingsByRootAndName, r = this._bindings;+ let a = s[t];+ a === void 0 && (a = {}, s[t] = a), a[n] = e, e._cacheIndex = r.length, r.push(e);+ }+ _removeInactiveBinding(e) {+ const t = this._bindings, n = e.binding, s = n.rootNode.uuid, r = n.path, a = this._bindingsByRootAndName, o = a[s], c = t[t.length - 1], l = e._cacheIndex;+ c._cacheIndex = l, t[l] = c, t.pop(), delete o[r], Object.keys(o).length === 0 && delete a[s];+ }+ _lendBinding(e) {+ const t = this._bindings, n = e._cacheIndex, s = this._nActiveBindings++, r = t[s];+ e._cacheIndex = s, t[s] = e, r._cacheIndex = n, t[n] = r;+ }+ _takeBackBinding(e) {+ const t = this._bindings, n = e._cacheIndex, s = --this._nActiveBindings, r = t[s];+ e._cacheIndex = s, t[s] = e, r._cacheIndex = n, t[n] = r;+ }+ // Memory management of Interpolants for weight and time scale+ _lendControlInterpolant() {+ const e = this._controlInterpolants, t = this._nActiveControlInterpolants++;+ let n = e[t];+ return n === void 0 && (n = new x0(+ new Float32Array(2),+ new Float32Array(2),+ 1,+ jy+ ), n.__cacheIndex = t, e[t] = n), n;+ }+ _takeBackControlInterpolant(e) {+ const t = this._controlInterpolants, n = e.__cacheIndex, s = --this._nActiveControlInterpolants, r = t[s];+ e.__cacheIndex = s, t[s] = e, r.__cacheIndex = n, t[n] = r;+ }+ /**+ * Returns an instance of {@link AnimationAction} for the passed clip.+ *+ * If an action fitting the clip and root parameters doesn't yet exist, it+ * will be created by this method. Calling this method several times with the+ * same clip and root parameters always returns the same action.+ *+ * @param {AnimationClip|string} clip - An animation clip or alternatively the name of the animation clip.+ * @param {Object3D} [optionalRoot] - An alternative root object.+ * @param {(NormalAnimationBlendMode|AdditiveAnimationBlendMode)} [blendMode] - The blend mode.+ * @return {?AnimationAction} The animation action.+ */+ clipAction(e, t, n) {+ const s = t || this._root, r = s.uuid;+ let a = typeof e == "string" ? Fl.findByName(s, e) : e;+ const o = a !== null ? a.uuid : e, c = this._actionsByClip[o];+ let l = null;+ if (n === void 0 && (a !== null ? n = a.blendMode : n = xf), c !== void 0) {+ const u = c.actionByRoot[r];+ if (u !== void 0 && u.blendMode === n)+ return u;+ l = c.knownActions[0], a === null && (a = l._clip);+ }+ if (a === null) return null;+ const h = new Ky(this, a, t, n);+ return this._bindAction(h, l), this._addInactiveAction(h, o, r), h;+ }+ /**+ * Returns an existing animation action for the passed clip.+ *+ * @param {AnimationClip|string} clip - An animation clip or alternatively the name of the animation clip.+ * @param {Object3D} [optionalRoot] - An alternative root object.+ * @return {?AnimationAction} The animation action. Returns `null` if no action was found.+ */+ existingAction(e, t) {+ const n = t || this._root, s = n.uuid, r = typeof e == "string" ? Fl.findByName(n, e) : e, a = r ? r.uuid : e, o = this._actionsByClip[a];+ return o !== void 0 && o.actionByRoot[s] || null;+ }+ /**+ * Deactivates all previously scheduled actions on this mixer.+ *+ * @return {AnimationMixer} A reference to thi animation mixer.+ */+ stopAllAction() {+ const e = this._actions, t = this._nActiveActions;+ for (let n = t - 1; n >= 0; --n)+ e[n].stop();+ return this;+ }+ /**+ * Advances the global mixer time and updates the animation.+ *+ * This is usually done in the render loop by passing the delta+ * time from {@link Clock} or {@link Timer}.+ *+ * @param {number} deltaTime - The delta time in seconds.+ * @return {AnimationMixer} A reference to thi animation mixer.+ */+ update(e) {+ e *= this.timeScale;+ const t = this._actions, n = this._nActiveActions, s = this.time += e, r = Math.sign(e), a = this._accuIndex ^= 1;+ for (let l = 0; l !== n; ++l)+ t[l]._update(s, e, r, a);+ const o = this._bindings, c = this._nActiveBindings;+ for (let l = 0; l !== c; ++l)+ o[l].apply(a);+ return this;+ }+ /**+ * Sets the global mixer to a specific time and updates the animation accordingly.+ *+ * This is useful when you need to jump to an exact time in an animation. The+ * input parameter will be scaled by {@link AnimationMixer#timeScale}+ *+ * @param {number} time - The time to set in seconds.+ * @return {AnimationMixer} A reference to thi animation mixer.+ */+ setTime(e) {+ this.time = 0;+ for (let t = 0; t < this._actions.length; t++)+ this._actions[t].time = 0;+ return this.update(e);+ }+ /**+ * Returns this mixer's root object.+ *+ * @return {Object3D} The mixer's root object.+ */+ getRoot() {+ return this._root;+ }+ /**+ * Deallocates all memory resources for a clip. Before using this method make+ * sure to call {@link AnimationAction#stop} for all related actions.+ *+ * @param {AnimationClip} clip - The clip to uncache.+ */+ uncacheClip(e) {+ const t = this._actions, n = e.uuid, s = this._actionsByClip, r = s[n];+ if (r !== void 0) {+ const a = r.knownActions;+ for (let o = 0, c = a.length; o !== c; ++o) {+ const l = a[o];+ this._deactivateAction(l);+ const h = l._cacheIndex, u = t[t.length - 1];+ l._cacheIndex = null, l._byClipCacheIndex = null, u._cacheIndex = h, t[h] = u, t.pop(), this._removeInactiveBindingsForAction(l);+ }+ delete s[n];+ }+ }+ /**+ * Deallocates all memory resources for a root object. Before using this+ * method make sure to call {@link AnimationAction#stop} for all related+ * actions or alternatively {@link AnimationMixer#stopAllAction} when the+ * mixer operates on a single root.+ *+ * @param {Object3D} root - The root object to uncache.+ */+ uncacheRoot(e) {+ const t = e.uuid, n = this._actionsByClip;+ for (const a in n) {+ const o = n[a].actionByRoot, c = o[t];+ c !== void 0 && (this._deactivateAction(c), this._removeInactiveAction(c));+ }+ const s = this._bindingsByRootAndName, r = s[t];+ if (r !== void 0)+ for (const a in r) {+ const o = r[a];+ o.restoreOriginalState(), this._removeInactiveBinding(o);+ }+ }+ /**+ * Deallocates all memory resources for an action. The action is identified by the+ * given clip and an optional root object. Before using this method make+ * sure to call {@link AnimationAction#stop} to deactivate the action.+ *+ * @param {AnimationClip|string} clip - An animation clip or alternatively the name of the animation clip.+ * @param {Object3D} [optionalRoot] - An alternative root object.+ */+ uncacheAction(e, t) {+ const n = this.existingAction(e, t);+ n !== null && (this._deactivateAction(n), this._removeInactiveAction(n));+ }+}+class tA {+ /**+ * Constructs a new spherical.+ *+ * @param {number} [radius=1] - The radius, or the Euclidean distance (straight-line distance) from the point to the origin.+ * @param {number} [phi=0] - The polar angle in radians from the y (up) axis.+ * @param {number} [theta=0] - The equator/azimuthal angle in radians around the y (up) axis.+ */+ constructor(e = 1, t = 0, n = 0) {+ this.radius = e, this.phi = t, this.theta = n;+ }+ /**+ * Sets the spherical components by copying the given values.+ *+ * @param {number} radius - The radius.+ * @param {number} phi - The polar angle.+ * @param {number} theta - The azimuthal angle.+ * @return {Spherical} A reference to this spherical.+ */+ set(e, t, n) {+ return this.radius = e, this.phi = t, this.theta = n, this;+ }+ /**+ * Copies the values of the given spherical to this instance.+ *+ * @param {Spherical} other - The spherical to copy.+ * @return {Spherical} A reference to this spherical.+ */+ copy(e) {+ return this.radius = e.radius, this.phi = e.phi, this.theta = e.theta, this;+ }+ /**+ * Restricts the polar angle [page:.phi phi] to be between `0.000001` and pi -+ * `0.000001`.+ *+ * @return {Spherical} A reference to this spherical.+ */+ makeSafe() {+ return this.phi = ct(this.phi, 1e-6, Math.PI - 1e-6), this;+ }+ /**+ * Sets the spherical components from the given vector which is assumed to hold+ * Cartesian coordinates.+ *+ * @param {Vector3} v - The vector to set.+ * @return {Spherical} A reference to this spherical.+ */+ setFromVector3(e) {+ return this.setFromCartesianCoords(e.x, e.y, e.z);+ }+ /**+ * Sets the spherical components from the given Cartesian coordinates.+ *+ * @param {number} x - The x value.+ * @param {number} y - The x value.+ * @param {number} z - The x value.+ * @return {Spherical} A reference to this spherical.+ */+ 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(ct(t / this.radius, -1, 1))), this;+ }+ /**+ * Returns a new spherical with copied values from this instance.+ *+ * @return {Spherical} A clone of this instance.+ */+ clone() {+ return new this.constructor().copy(this);+ }+}+const ws = /* @__PURE__ */ new H(), kc = /* @__PURE__ */ new et(), Kh = /* @__PURE__ */ new et();+class Xy extends Yl {+ /**+ * Constructs a new hemisphere light helper.+ *+ * @param {Object3D} object - Usually an instance of {@link SkinnedMesh}. However, any 3D object+ * can be used if it represents a hierarchy of bones (see {@link Bone}).+ */+ constructor(e) {+ const t = C0(e), n = new zn(), s = [], r = [], a = new je(0, 0, 1), o = new je(0, 1, 0);+ for (let l = 0; l < t.length; l++) {+ const h = t[l];+ h.parent && h.parent.isBone && (s.push(0, 0, 0), s.push(0, 0, 0), r.push(a.r, a.g, a.b), r.push(o.r, o.g, o.b));+ }+ n.setAttribute("position", new Un(s, 3)), n.setAttribute("color", new Un(r, 3));+ const c = new Zo({ vertexColors: !0, depthTest: !1, depthWrite: !1, toneMapped: !1, transparent: !0 });+ super(n, c), this.isSkeletonHelper = !0, this.type = "SkeletonHelper", this.root = e, this.bones = t, this.matrix = e.matrixWorld, this.matrixAutoUpdate = !1;+ }+ updateMatrixWorld(e) {+ const t = this.bones, n = this.geometry, s = n.getAttribute("position");+ Kh.copy(this.root.matrixWorld).invert();+ for (let r = 0, a = 0; r < t.length; r++) {+ const o = t[r];+ o.parent && o.parent.isBone && (kc.multiplyMatrices(Kh, o.matrixWorld), ws.setFromMatrixPosition(kc), s.setXYZ(a, ws.x, ws.y, ws.z), kc.multiplyMatrices(Kh, o.parent.matrixWorld), ws.setFromMatrixPosition(kc), s.setXYZ(a + 1, ws.x, ws.y, ws.z), a += 2);+ }+ n.getAttribute("position").needsUpdate = !0, super.updateMatrixWorld(e);+ }+ /**+ * Frees the GPU-related resources allocated by this instance. Call this+ * method whenever this instance is no longer used in your app.+ */+ dispose() {+ this.geometry.dispose(), this.material.dispose();+ }+}+function C0(i) {+ const e = [];+ i.isBone === !0 && e.push(i);+ for (let t = 0; t < i.children.length; t++)+ e.push(...C0(i.children[t]));+ return e;+}+class Yy extends Yl {+ /**+ * Constructs a new grid helper.+ *+ * @param {number} [size=10] - The size of the grid.+ * @param {number} [divisions=10] - The number of divisions across the grid.+ * @param {number|Color|string} [color1=0x444444] - The color of the center line.+ * @param {number|Color|string} [color2=0x888888] - The color of the lines of the grid.+ */+ constructor(e = 10, t = 10, n = 4473924, s = 8947848) {+ n = new je(n), s = new je(s);+ const r = t / 2, a = e / t, o = e / 2, c = [], l = [];+ for (let d = 0, f = 0, m = -o; d <= t; d++, m += a) {+ c.push(-o, 0, m, o, 0, m), c.push(m, 0, -o, m, 0, o);+ const A = d === r ? n : s;+ A.toArray(l, f), f += 3, A.toArray(l, f), f += 3, A.toArray(l, f), f += 3, A.toArray(l, f), f += 3;+ }+ const h = new zn();+ h.setAttribute("position", new Un(c, 3)), h.setAttribute("color", new Un(l, 3));+ const u = new Zo({ vertexColors: !0, toneMapped: !1 });+ super(h, u), this.type = "GridHelper";+ }+ /**+ * Frees the GPU-related resources allocated by this instance. Call this+ * method whenever this instance is no longer used in your app.+ */+ dispose() {+ this.geometry.dispose(), this.material.dispose();+ }+}+class nA extends Yl {+ /**+ * Constructs a new axes helper.+ *+ * @param {number} [size=1] - Size of the lines representing the axes.+ */+ constructor(e = 1) {+ const t = [+ 0,+ 0,+ 0,+ e,+ 0,+ 0,+ 0,+ 0,+ 0,+ 0,+ e,+ 0,+ 0,+ 0,+ 0,+ 0,+ 0,+ e+ ], n = [+ 1,+ 0,+ 0,+ 1,+ 0.6,+ 0,+ 0,+ 1,+ 0,+ 0.6,+ 1,+ 0,+ 0,+ 0,+ 1,+ 0,+ 0.6,+ 1+ ], s = new zn();+ s.setAttribute("position", new Un(t, 3)), s.setAttribute("color", new Un(n, 3));+ const r = new Zo({ vertexColors: !0, toneMapped: !1 });+ super(s, r), this.type = "AxesHelper";+ }+ /**+ * Defines the colors of the axes helper.+ *+ * @param {number|Color|string} xAxisColor - The color for the x axis.+ * @param {number|Color|string} yAxisColor - The color for the y axis.+ * @param {number|Color|string} zAxisColor - The color for the z axis.+ * @return {AxesHelper} A reference to this axes helper.+ */+ setColors(e, t, n) {+ const s = new je(), r = this.geometry.attributes.color.array;+ return s.set(e), s.toArray(r, 0), s.toArray(r, 3), s.set(t), s.toArray(r, 6), s.toArray(r, 9), s.set(n), s.toArray(r, 12), s.toArray(r, 15), this.geometry.attributes.color.needsUpdate = !0, this;+ }+ /**+ * Frees the GPU-related resources allocated by this instance. Call this+ * method whenever this instance is no longer used in your app.+ */+ dispose() {+ this.geometry.dispose(), this.material.dispose();+ }+}+class Jy extends zs {+ /**+ * Constructs a new controls instance.+ *+ * @param {Object3D} object - The object that is managed by the controls.+ * @param {?HTMLDOMElement} domElement - The HTML element used for event listeners.+ */+ 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 };+ }+ /**+ * Connects the controls to the DOM. This method has so called "side effects" since+ * it adds the module's event listeners to the DOM.+ *+ * @param {HTMLDOMElement} element - The DOM element to connect to.+ */+ connect(e) {+ if (e === void 0) {+ console.warn("THREE.Controls: connect() now requires an element.");+ return;+ }+ this.domElement !== null && this.disconnect(), this.domElement = e;+ }+ /**+ * Disconnects the controls from the DOM.+ */+ disconnect() {+ }+ /**+ * Call this method if you no longer want use to the controls. It frees all internal+ * resources and removes all event listeners.+ */+ dispose() {+ }+ /**+ * Controls should implement this method if they have to update their internal state+ * per simulation step.+ *+ * @param {number} [delta] - The time delta in seconds.+ */+ update() {+ }+}+function iA(i, e, t, n) {+ const s = Zy(n);+ switch (t) {+ // https://registry.khronos.org/OpenGL-Refpages/es3.0/html/glTexImage2D.xhtml+ case Ym:+ return i * e;+ case ns:+ return i * e / s.components * s.byteLength;+ case gf:+ return i * e / s.components * s.byteLength;+ case dr:+ return i * e * 2 / s.components * s.byteLength;+ case mf:+ return i * e * 2 / s.components * s.byteLength;+ case Jm:+ return i * e * 3 / s.components * s.byteLength;+ case on:+ return i * e * 4 / s.components * s.byteLength;+ case bf:+ return i * e * 4 / s.components * s.byteLength;+ // https://registry.khronos.org/webgl/extensions/WEBGL_compressed_texture_s3tc_srgb/+ case dl:+ case xo:+ return Math.floor((i + 3) / 4) * Math.floor((e + 3) / 4) * 8;+ case fl:+ case _o:+ return Math.floor((i + 3) / 4) * Math.floor((e + 3) / 4) * 16;+ // https://registry.khronos.org/webgl/extensions/WEBGL_compressed_texture_pvrtc/+ case ed:+ case td:+ return Math.max(i, 16) * Math.max(e, 8) / 4;+ case yl:+ case wl:+ return Math.max(i, 8) * Math.max(e, 8) / 2;+ // https://registry.khronos.org/webgl/extensions/WEBGL_compressed_texture_etc/+ case vl:+ case Cl:+ return Math.floor((i + 3) / 4) * Math.floor((e + 3) / 4) * 8;+ case Sl:+ return Math.floor((i + 3) / 4) * Math.floor((e + 3) / 4) * 16;+ // https://registry.khronos.org/webgl/extensions/WEBGL_compressed_texture_astc/+ case Do:+ return Math.floor((i + 3) / 4) * Math.floor((e + 3) / 4) * 16;+ case nd:+ return Math.floor((i + 4) / 5) * Math.floor((e + 3) / 4) * 16;+ case id:+ return Math.floor((i + 4) / 5) * Math.floor((e + 4) / 5) * 16;+ case sd:+ return Math.floor((i + 5) / 6) * Math.floor((e + 4) / 5) * 16;+ case Lo:+ return Math.floor((i + 5) / 6) * Math.floor((e + 5) / 6) * 16;+ case rd:+ return Math.floor((i + 7) / 8) * Math.floor((e + 4) / 5) * 16;+ case ad:+ return Math.floor((i + 7) / 8) * Math.floor((e + 5) / 6) * 16;+ case od:+ return Math.floor((i + 7) / 8) * Math.floor((e + 7) / 8) * 16;+ case cd:+ return Math.floor((i + 9) / 10) * Math.floor((e + 4) / 5) * 16;+ case ld:+ return Math.floor((i + 9) / 10) * Math.floor((e + 5) / 6) * 16;+ case hd:+ return Math.floor((i + 9) / 10) * Math.floor((e + 7) / 8) * 16;+ case ud:+ return Math.floor((i + 9) / 10) * Math.floor((e + 9) / 10) * 16;+ case dd:+ return Math.floor((i + 11) / 12) * Math.floor((e + 9) / 10) * 16;+ case fd:+ return Math.floor((i + 11) / 12) * Math.floor((e + 11) / 12) * 16;+ // https://registry.khronos.org/webgl/extensions/EXT_texture_compression_bptc/+ case Eo:+ case pd:+ case Il:+ return Math.ceil(i / 4) * Math.ceil(e / 4) * 16;+ // https://registry.khronos.org/webgl/extensions/EXT_texture_compression_rgtc/+ case Zm:+ case Ad:+ return Math.ceil(i / 4) * Math.ceil(e / 4) * 8;+ case gd:+ case md:+ return Math.ceil(i / 4) * Math.ceil(e / 4) * 16;+ }+ throw new Error(+ `Unable to determine texture byte length for ${t} format.`+ );+}+function Zy(i) {+ switch (i) {+ case rn:+ case Km:+ return { byteLength: 1, components: 1 };+ case To:+ case jm:+ case Nn:+ return { byteLength: 2, components: 1 };+ case pf:+ case Af:+ return { byteLength: 2, components: 4 };+ case yr:+ case ff:+ case an:+ return { byteLength: 4, components: 1 };+ case Xm:+ return { byteLength: 4, components: 3 };+ }+ throw new Error(`Unknown texture type ${i}.`);+}+typeof __THREE_DEVTOOLS__ < "u" && __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register", { detail: {+ revision: "176"+} }));+typeof window < "u" && (window.__THREE__ ? console.warn("WARNING: Multiple instances of Three.js being imported.") : window.__THREE__ = "176");+function S0() {+ let i = null, e = !1, t = null, n = null;+ function s(r, a) {+ t(r, a), n = i.requestAnimationFrame(s);+ }+ return {+ start: function() {+ e !== !0 && t !== null && (n = i.requestAnimationFrame(s), e = !0);+ },+ stop: function() {+ i.cancelAnimationFrame(n), e = !1;+ },+ setAnimationLoop: function(r) {+ t = r;+ },+ setContext: function(r) {+ i = r;+ }+ };+}+function $y(i) {+ const e = /* @__PURE__ */ new WeakMap();+ function t(o, c) {+ const l = o.array, h = o.usage, u = l.byteLength, d = i.createBuffer();+ i.bindBuffer(c, d), i.bufferData(c, l, h), o.onUploadCallback();+ let f;+ if (l instanceof Float32Array)+ f = i.FLOAT;+ else if (l instanceof Uint16Array)+ o.isFloat16BufferAttribute ? f = i.HALF_FLOAT : f = i.UNSIGNED_SHORT;+ else if (l instanceof Int16Array)+ f = i.SHORT;+ else if (l instanceof Uint32Array)+ f = i.UNSIGNED_INT;+ else if (l instanceof Int32Array)+ f = i.INT;+ else if (l instanceof Int8Array)+ f = i.BYTE;+ else if (l instanceof Uint8Array)+ f = i.UNSIGNED_BYTE;+ else if (l instanceof Uint8ClampedArray)+ f = i.UNSIGNED_BYTE;+ else+ throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: " + l);+ return {+ buffer: d,+ type: f,+ bytesPerElement: l.BYTES_PER_ELEMENT,+ version: o.version,+ size: u+ };+ }+ function n(o, c, l) {+ const h = c.array, u = c.updateRanges;+ if (i.bindBuffer(l, o), u.length === 0)+ i.bufferSubData(l, 0, h);+ else {+ u.sort((f, m) => f.start - m.start);+ let d = 0;+ for (let f = 1; f < u.length; f++) {+ const m = u[d], A = u[f];+ A.start <= m.start + m.count + 1 ? m.count = Math.max(+ m.count,+ A.start + A.count - m.start+ ) : (++d, u[d] = A);+ }+ u.length = d + 1;+ for (let f = 0, m = u.length; f < m; f++) {+ const A = u[f];+ i.bufferSubData(+ l,+ A.start * h.BYTES_PER_ELEMENT,+ h,+ A.start,+ A.count+ );+ }+ c.clearUpdateRanges();+ }+ c.onUploadCallback();+ }+ function s(o) {+ return o.isInterleavedBufferAttribute && (o = o.data), e.get(o);+ }+ function r(o) {+ o.isInterleavedBufferAttribute && (o = o.data);+ const c = e.get(o);+ c && (i.deleteBuffer(c.buffer), e.delete(o));+ }+ function a(o, c) {+ if (o.isInterleavedBufferAttribute && (o = o.data), o.isGLBufferAttribute) {+ const h = e.get(o);+ (!h || h.version < o.version) && e.set(o, {+ buffer: o.buffer,+ type: o.type,+ bytesPerElement: o.elementSize,+ version: o.version+ });+ return;+ }+ const l = e.get(o);+ if (l === void 0)+ e.set(o, t(o, c));+ else if (l.version < o.version) {+ if (l.size !== o.array.byteLength)+ throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");+ n(l.buffer, o, c), l.version = o.version;+ }+ }+ return {+ get: s,+ remove: r,+ update: a+ };+}+var ew = `#ifdef USE_ALPHAHASH+ if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;+#endif`, tw = `#ifdef USE_ALPHAHASH+ const float ALPHA_HASH_SCALE = 0.05;+ float hash2D( vec2 value ) {+ return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );+ }+ float hash3D( vec3 value ) {+ return hash2D( vec2( hash2D( value.xy ), value.z ) );+ }+ float getAlphaHashThreshold( vec3 position ) {+ float maxDeriv = max(+ length( dFdx( position.xyz ) ),+ length( dFdy( position.xyz ) )+ );+ float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );+ vec2 pixScales = vec2(+ exp2( floor( log2( pixScale ) ) ),+ exp2( ceil( log2( pixScale ) ) )+ );+ vec2 alpha = vec2(+ hash3D( floor( pixScales.x * position.xyz ) ),+ hash3D( floor( pixScales.y * position.xyz ) )+ );+ float lerpFactor = fract( log2( pixScale ) );+ float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;+ float a = min( lerpFactor, 1.0 - lerpFactor );+ vec3 cases = vec3(+ x * x / ( 2.0 * a * ( 1.0 - a ) ),+ ( x - 0.5 * a ) / ( 1.0 - a ),+ 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )+ );+ float threshold = ( x < ( 1.0 - a ) )+ ? ( ( x < a ) ? cases.x : cases.y )+ : cases.z;+ return clamp( threshold , 1.0e-6, 1.0 );+ }+#endif`, nw = `#ifdef USE_ALPHAMAP+ diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;+#endif`, iw = `#ifdef USE_ALPHAMAP+ uniform sampler2D alphaMap;+#endif`, sw = `#ifdef USE_ALPHATEST+ #ifdef ALPHA_TO_COVERAGE+ diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );+ if ( diffuseColor.a == 0.0 ) discard;+ #else+ if ( diffuseColor.a < alphaTest ) discard;+ #endif+#endif`, rw = `#ifdef USE_ALPHATEST+ uniform float alphaTest;+#endif`, aw = `#ifdef USE_AOMAP+ float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;+ reflectedLight.indirectDiffuse *= ambientOcclusion;+ #if defined( USE_CLEARCOAT )+ clearcoatSpecularIndirect *= ambientOcclusion;+ #endif+ #if defined( USE_SHEEN )+ sheenSpecularIndirect *= ambientOcclusion;+ #endif+ #if defined( USE_ENVMAP ) && defined( STANDARD )+ float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );+ reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );+ #endif+#endif`, ow = `#ifdef USE_AOMAP+ uniform sampler2D aoMap;+ uniform float aoMapIntensity;+#endif`, cw = `#ifdef USE_BATCHING+ #if ! defined( GL_ANGLE_multi_draw )+ #define gl_DrawID _gl_DrawID+ uniform int _gl_DrawID;+ #endif+ uniform highp sampler2D batchingTexture;+ uniform highp usampler2D batchingIdTexture;+ mat4 getBatchingMatrix( const in float i ) {+ int size = textureSize( batchingTexture, 0 ).x;+ int j = int( i ) * 4;+ int x = j % size;+ int y = j / size;+ vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );+ vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );+ vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );+ vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );+ return mat4( v1, v2, v3, v4 );+ }+ float getIndirectIndex( const in int i ) {+ int size = textureSize( batchingIdTexture, 0 ).x;+ int x = i % size;+ int y = i / size;+ return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );+ }+#endif+#ifdef USE_BATCHING_COLOR+ uniform sampler2D batchingColorTexture;+ vec3 getBatchingColor( const in float i ) {+ int size = textureSize( batchingColorTexture, 0 ).x;+ int j = int( i );+ int x = j % size;+ int y = j / size;+ return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;+ }+#endif`, lw = `#ifdef USE_BATCHING+ mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );+#endif`, hw = `vec3 transformed = vec3( position );+#ifdef USE_ALPHAHASH+ vPosition = vec3( position );+#endif`, uw = `vec3 objectNormal = vec3( normal );+#ifdef USE_TANGENT+ vec3 objectTangent = vec3( tangent.xyz );+#endif`, dw = `float G_BlinnPhong_Implicit( ) {+ return 0.25;+}+float D_BlinnPhong( const in float shininess, const in float dotNH ) {+ return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );+}+vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {+ vec3 halfDir = normalize( lightDir + viewDir );+ float dotNH = saturate( dot( normal, halfDir ) );+ float dotVH = saturate( dot( viewDir, halfDir ) );+ vec3 F = F_Schlick( specularColor, 1.0, dotVH );+ float G = G_BlinnPhong_Implicit( );+ float D = D_BlinnPhong( shininess, dotNH );+ return F * ( G * D );+} // validated`, fw = `#ifdef USE_IRIDESCENCE+ const mat3 XYZ_TO_REC709 = mat3(+ 3.2404542, -0.9692660, 0.0556434,+ -1.5371385, 1.8760108, -0.2040259,+ -0.4985314, 0.0415560, 1.0572252+ );+ vec3 Fresnel0ToIor( vec3 fresnel0 ) {+ vec3 sqrtF0 = sqrt( fresnel0 );+ return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );+ }+ vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {+ return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );+ }+ float IorToFresnel0( float transmittedIor, float incidentIor ) {+ return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));+ }+ vec3 evalSensitivity( float OPD, vec3 shift ) {+ float phase = 2.0 * PI * OPD * 1.0e-9;+ vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );+ vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );+ vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );+ vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );+ xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );+ xyz /= 1.0685e-7;+ vec3 rgb = XYZ_TO_REC709 * xyz;+ return rgb;+ }+ vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {+ vec3 I;+ float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );+ float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );+ float cosTheta2Sq = 1.0 - sinTheta2Sq;+ if ( cosTheta2Sq < 0.0 ) {+ return vec3( 1.0 );+ }+ float cosTheta2 = sqrt( cosTheta2Sq );+ float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );+ float R12 = F_Schlick( R0, 1.0, cosTheta1 );+ float T121 = 1.0 - R12;+ float phi12 = 0.0;+ if ( iridescenceIOR < outsideIOR ) phi12 = PI;+ float phi21 = PI - phi12;+ vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );+ vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );+ vec3 phi23 = vec3( 0.0 );+ if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;+ if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;+ if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;+ float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;+ vec3 phi = vec3( phi21 ) + phi23;+ vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );+ vec3 r123 = sqrt( R123 );+ vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );+ vec3 C0 = R12 + Rs;+ I = C0;+ vec3 Cm = Rs - T121;+ for ( int m = 1; m <= 2; ++ m ) {+ Cm *= r123;+ vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );+ I += Cm * Sm;+ }+ return max( I, vec3( 0.0 ) );+ }+#endif`, pw = `#ifdef USE_BUMPMAP+ uniform sampler2D bumpMap;+ uniform float bumpScale;+ vec2 dHdxy_fwd() {+ vec2 dSTdx = dFdx( vBumpMapUv );+ vec2 dSTdy = dFdy( vBumpMapUv );+ float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;+ float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;+ float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;+ return vec2( dBx, dBy );+ }+ vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {+ vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );+ vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );+ vec3 vN = surf_norm;+ vec3 R1 = cross( vSigmaY, vN );+ vec3 R2 = cross( vN, vSigmaX );+ float fDet = dot( vSigmaX, R1 ) * faceDirection;+ vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );+ return normalize( abs( fDet ) * surf_norm - vGrad );+ }+#endif`, Aw = `#if NUM_CLIPPING_PLANES > 0+ vec4 plane;+ #ifdef ALPHA_TO_COVERAGE+ float distanceToPlane, distanceGradient;+ float clipOpacity = 1.0;+ #pragma unroll_loop_start+ for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {+ plane = clippingPlanes[ i ];+ distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;+ distanceGradient = fwidth( distanceToPlane ) / 2.0;+ clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );+ if ( clipOpacity == 0.0 ) discard;+ }+ #pragma unroll_loop_end+ #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES+ float unionClipOpacity = 1.0;+ #pragma unroll_loop_start+ for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {+ plane = clippingPlanes[ i ];+ distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;+ distanceGradient = fwidth( distanceToPlane ) / 2.0;+ unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );+ }+ #pragma unroll_loop_end+ clipOpacity *= 1.0 - unionClipOpacity;+ #endif+ diffuseColor.a *= clipOpacity;+ if ( diffuseColor.a == 0.0 ) discard;+ #else+ #pragma unroll_loop_start+ for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {+ plane = clippingPlanes[ i ];+ if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;+ }+ #pragma unroll_loop_end+ #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES+ bool clipped = true;+ #pragma unroll_loop_start+ for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {+ plane = clippingPlanes[ i ];+ clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;+ }+ #pragma unroll_loop_end+ if ( clipped ) discard;+ #endif+ #endif+#endif`, gw = `#if NUM_CLIPPING_PLANES > 0+ varying vec3 vClipPosition;+ uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];+#endif`, mw = `#if NUM_CLIPPING_PLANES > 0+ varying vec3 vClipPosition;+#endif`, bw = `#if NUM_CLIPPING_PLANES > 0+ vClipPosition = - mvPosition.xyz;+#endif`, xw = `#if defined( USE_COLOR_ALPHA )+ diffuseColor *= vColor;+#elif defined( USE_COLOR )+ diffuseColor.rgb *= vColor;+#endif`, _w = `#if defined( USE_COLOR_ALPHA )+ varying vec4 vColor;+#elif defined( USE_COLOR )+ varying vec3 vColor;+#endif`, Ew = `#if defined( USE_COLOR_ALPHA )+ varying vec4 vColor;+#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )+ varying vec3 vColor;+#endif`, yw = `#if defined( USE_COLOR_ALPHA )+ vColor = vec4( 1.0 );+#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )+ vColor = vec3( 1.0 );+#endif+#ifdef USE_COLOR+ vColor *= color;+#endif+#ifdef USE_INSTANCING_COLOR+ vColor.xyz *= instanceColor.xyz;+#endif+#ifdef USE_BATCHING_COLOR+ vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );+ vColor.xyz *= batchingColor.xyz;+#endif`, ww = `#define PI 3.141592653589793+#define PI2 6.283185307179586+#define PI_HALF 1.5707963267948966+#define RECIPROCAL_PI 0.3183098861837907+#define RECIPROCAL_PI2 0.15915494309189535+#define EPSILON 1e-6+#ifndef saturate+#define saturate( a ) clamp( a, 0.0, 1.0 )+#endif+#define whiteComplement( a ) ( 1.0 - saturate( a ) )+float pow2( const in float x ) { return x*x; }+vec3 pow2( const in vec3 x ) { return x*x; }+float pow3( const in float x ) { return x*x*x; }+float pow4( const in float x ) { float x2 = x*x; return x2*x2; }+float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }+float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }+highp float rand( const in vec2 uv ) {+ const highp float a = 12.9898, b = 78.233, c = 43758.5453;+ highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );+ return fract( sin( sn ) * c );+}+#ifdef HIGH_PRECISION+ float precisionSafeLength( vec3 v ) { return length( v ); }+#else+ float precisionSafeLength( vec3 v ) {+ float maxComponent = max3( abs( v ) );+ return length( v / maxComponent ) * maxComponent;+ }+#endif+struct IncidentLight {+ vec3 color;+ vec3 direction;+ bool visible;+};+struct ReflectedLight {+ vec3 directDiffuse;+ vec3 directSpecular;+ vec3 indirectDiffuse;+ vec3 indirectSpecular;+};+#ifdef USE_ALPHAHASH+ varying vec3 vPosition;+#endif+vec3 transformDirection( in vec3 dir, in mat4 matrix ) {+ return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );+}+vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {+ return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );+}+mat3 transposeMat3( const in mat3 m ) {+ mat3 tmp;+ tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );+ tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );+ tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );+ return tmp;+}+bool isPerspectiveMatrix( mat4 m ) {+ return m[ 2 ][ 3 ] == - 1.0;+}+vec2 equirectUv( in vec3 dir ) {+ float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;+ float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;+ return vec2( u, v );+}+vec3 BRDF_Lambert( const in vec3 diffuseColor ) {+ return RECIPROCAL_PI * diffuseColor;+}+vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {+ float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );+ return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );+}+float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {+ float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );+ return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );+} // validated`, vw = `#ifdef ENVMAP_TYPE_CUBE_UV+ #define cubeUV_minMipLevel 4.0+ #define cubeUV_minTileSize 16.0+ float getFace( vec3 direction ) {+ vec3 absDirection = abs( direction );+ float face = - 1.0;+ if ( absDirection.x > absDirection.z ) {+ if ( absDirection.x > absDirection.y )+ face = direction.x > 0.0 ? 0.0 : 3.0;+ else+ face = direction.y > 0.0 ? 1.0 : 4.0;+ } else {+ if ( absDirection.z > absDirection.y )+ face = direction.z > 0.0 ? 2.0 : 5.0;+ else+ face = direction.y > 0.0 ? 1.0 : 4.0;+ }+ return face;+ }+ vec2 getUV( vec3 direction, float face ) {+ vec2 uv;+ if ( face == 0.0 ) {+ uv = vec2( direction.z, direction.y ) / abs( direction.x );+ } else if ( face == 1.0 ) {+ uv = vec2( - direction.x, - direction.z ) / abs( direction.y );+ } else if ( face == 2.0 ) {+ uv = vec2( - direction.x, direction.y ) / abs( direction.z );+ } else if ( face == 3.0 ) {+ uv = vec2( - direction.z, direction.y ) / abs( direction.x );+ } else if ( face == 4.0 ) {+ uv = vec2( - direction.x, direction.z ) / abs( direction.y );+ } else {+ uv = vec2( direction.x, direction.y ) / abs( direction.z );+ }+ return 0.5 * ( uv + 1.0 );+ }+ vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {+ float face = getFace( direction );+ float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );+ mipInt = max( mipInt, cubeUV_minMipLevel );+ float faceSize = exp2( mipInt );+ highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;+ if ( face > 2.0 ) {+ uv.y += faceSize;+ face -= 3.0;+ }+ uv.x += face * faceSize;+ uv.x += filterInt * 3.0 * cubeUV_minTileSize;+ uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );+ uv.x *= CUBEUV_TEXEL_WIDTH;+ uv.y *= CUBEUV_TEXEL_HEIGHT;+ #ifdef texture2DGradEXT+ return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;+ #else+ return texture2D( envMap, uv ).rgb;+ #endif+ }+ #define cubeUV_r0 1.0+ #define cubeUV_m0 - 2.0+ #define cubeUV_r1 0.8+ #define cubeUV_m1 - 1.0+ #define cubeUV_r4 0.4+ #define cubeUV_m4 2.0+ #define cubeUV_r5 0.305+ #define cubeUV_m5 3.0+ #define cubeUV_r6 0.21+ #define cubeUV_m6 4.0+ float roughnessToMip( float roughness ) {+ float mip = 0.0;+ if ( roughness >= cubeUV_r1 ) {+ mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;+ } else if ( roughness >= cubeUV_r4 ) {+ mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;+ } else if ( roughness >= cubeUV_r5 ) {+ mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;+ } else if ( roughness >= cubeUV_r6 ) {+ mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;+ } else {+ mip = - 2.0 * log2( 1.16 * roughness ); }+ return mip;+ }+ vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {+ float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );+ float mipF = fract( mip );+ float mipInt = floor( mip );+ vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );+ if ( mipF == 0.0 ) {+ return vec4( color0, 1.0 );+ } else {+ vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );+ return vec4( mix( color0, color1, mipF ), 1.0 );+ }+ }+#endif`, Cw = `vec3 transformedNormal = objectNormal;+#ifdef USE_TANGENT+ vec3 transformedTangent = objectTangent;+#endif+#ifdef USE_BATCHING+ mat3 bm = mat3( batchingMatrix );+ transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );+ transformedNormal = bm * transformedNormal;+ #ifdef USE_TANGENT+ transformedTangent = bm * transformedTangent;+ #endif+#endif+#ifdef USE_INSTANCING+ mat3 im = mat3( instanceMatrix );+ transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );+ transformedNormal = im * transformedNormal;+ #ifdef USE_TANGENT+ transformedTangent = im * transformedTangent;+ #endif+#endif+transformedNormal = normalMatrix * transformedNormal;+#ifdef FLIP_SIDED+ transformedNormal = - transformedNormal;+#endif+#ifdef USE_TANGENT+ transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;+ #ifdef FLIP_SIDED+ transformedTangent = - transformedTangent;+ #endif+#endif`, Sw = `#ifdef USE_DISPLACEMENTMAP+ uniform sampler2D displacementMap;+ uniform float displacementScale;+ uniform float displacementBias;+#endif`, Iw = `#ifdef USE_DISPLACEMENTMAP+ transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );+#endif`, Mw = `#ifdef USE_EMISSIVEMAP+ vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );+ #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE+ emissiveColor = sRGBTransferEOTF( emissiveColor );+ #endif+ totalEmissiveRadiance *= emissiveColor.rgb;+#endif`, Bw = `#ifdef USE_EMISSIVEMAP+ uniform sampler2D emissiveMap;+#endif`, Tw = "gl_FragColor = linearToOutputTexel( gl_FragColor );", Rw = `vec4 LinearTransferOETF( in vec4 value ) {+ return value;+}+vec4 sRGBTransferEOTF( in vec4 value ) {+ return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );+}+vec4 sRGBTransferOETF( in vec4 value ) {+ return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );+}`, Nw = `#ifdef USE_ENVMAP+ #ifdef ENV_WORLDPOS+ vec3 cameraToFrag;+ if ( isOrthographic ) {+ cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );+ } else {+ cameraToFrag = normalize( vWorldPosition - cameraPosition );+ }+ vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );+ #ifdef ENVMAP_MODE_REFLECTION+ vec3 reflectVec = reflect( cameraToFrag, worldNormal );+ #else+ vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );+ #endif+ #else+ vec3 reflectVec = vReflect;+ #endif+ #ifdef ENVMAP_TYPE_CUBE+ vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );+ #else+ vec4 envColor = vec4( 0.0 );+ #endif+ #ifdef ENVMAP_BLENDING_MULTIPLY+ outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );+ #elif defined( ENVMAP_BLENDING_MIX )+ outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );+ #elif defined( ENVMAP_BLENDING_ADD )+ outgoingLight += envColor.xyz * specularStrength * reflectivity;+ #endif+#endif`, Fw = `#ifdef USE_ENVMAP+ uniform float envMapIntensity;+ uniform float flipEnvMap;+ uniform mat3 envMapRotation;+ #ifdef ENVMAP_TYPE_CUBE+ uniform samplerCube envMap;+ #else+ uniform sampler2D envMap;+ #endif++#endif`, Dw = `#ifdef USE_ENVMAP+ uniform float reflectivity;+ #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )+ #define ENV_WORLDPOS+ #endif+ #ifdef ENV_WORLDPOS+ varying vec3 vWorldPosition;+ uniform float refractionRatio;+ #else+ varying vec3 vReflect;+ #endif+#endif`, Lw = `#ifdef USE_ENVMAP+ #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )+ #define ENV_WORLDPOS+ #endif+ #ifdef ENV_WORLDPOS++ varying vec3 vWorldPosition;+ #else+ varying vec3 vReflect;+ uniform float refractionRatio;+ #endif+#endif`, Pw = `#ifdef USE_ENVMAP+ #ifdef ENV_WORLDPOS+ vWorldPosition = worldPosition.xyz;+ #else+ vec3 cameraToVertex;+ if ( isOrthographic ) {+ cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );+ } else {+ cameraToVertex = normalize( worldPosition.xyz - cameraPosition );+ }+ vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );+ #ifdef ENVMAP_MODE_REFLECTION+ vReflect = reflect( cameraToVertex, worldNormal );+ #else+ vReflect = refract( cameraToVertex, worldNormal, refractionRatio );+ #endif+ #endif+#endif`, kw = `#ifdef USE_FOG+ vFogDepth = - mvPosition.z;+#endif`, Uw = `#ifdef USE_FOG+ varying float vFogDepth;+#endif`, Ow = `#ifdef USE_FOG+ #ifdef FOG_EXP2+ float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );+ #else+ float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );+ #endif+ gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );+#endif`, Qw = `#ifdef USE_FOG+ uniform vec3 fogColor;+ varying float vFogDepth;+ #ifdef FOG_EXP2+ uniform float fogDensity;+ #else+ uniform float fogNear;+ uniform float fogFar;+ #endif+#endif`, Gw = `#ifdef USE_GRADIENTMAP+ uniform sampler2D gradientMap;+#endif+vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {+ float dotNL = dot( normal, lightDirection );+ vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );+ #ifdef USE_GRADIENTMAP+ return vec3( texture2D( gradientMap, coord ).r );+ #else+ vec2 fw = fwidth( coord ) * 0.5;+ return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );+ #endif+}`, Hw = `#ifdef USE_LIGHTMAP+ uniform sampler2D lightMap;+ uniform float lightMapIntensity;+#endif`, zw = `LambertMaterial material;+material.diffuseColor = diffuseColor.rgb;+material.specularStrength = specularStrength;`, Vw = `varying vec3 vViewPosition;+struct LambertMaterial {+ vec3 diffuseColor;+ float specularStrength;+};+void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {+ float dotNL = saturate( dot( geometryNormal, directLight.direction ) );+ vec3 irradiance = dotNL * directLight.color;+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );+}+void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );+}+#define RE_Direct RE_Direct_Lambert+#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`, Ww = `uniform bool receiveShadow;+uniform vec3 ambientLightColor;+#if defined( USE_LIGHT_PROBES )+ uniform vec3 lightProbe[ 9 ];+#endif+vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {+ float x = normal.x, y = normal.y, z = normal.z;+ vec3 result = shCoefficients[ 0 ] * 0.886227;+ result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;+ result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;+ result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;+ result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;+ result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;+ result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );+ result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;+ result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );+ return result;+}+vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {+ vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );+ vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );+ return irradiance;+}+vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {+ vec3 irradiance = ambientLightColor;+ return irradiance;+}+float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {+ float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );+ if ( cutoffDistance > 0.0 ) {+ distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );+ }+ return distanceFalloff;+}+float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {+ return smoothstep( coneCosine, penumbraCosine, angleCosine );+}+#if NUM_DIR_LIGHTS > 0+ struct DirectionalLight {+ vec3 direction;+ vec3 color;+ };+ uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];+ void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {+ light.color = directionalLight.color;+ light.direction = directionalLight.direction;+ light.visible = true;+ }+#endif+#if NUM_POINT_LIGHTS > 0+ struct PointLight {+ vec3 position;+ vec3 color;+ float distance;+ float decay;+ };+ uniform PointLight pointLights[ NUM_POINT_LIGHTS ];+ void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {+ vec3 lVector = pointLight.position - geometryPosition;+ light.direction = normalize( lVector );+ float lightDistance = length( lVector );+ light.color = pointLight.color;+ light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );+ light.visible = ( light.color != vec3( 0.0 ) );+ }+#endif+#if NUM_SPOT_LIGHTS > 0+ struct SpotLight {+ vec3 position;+ vec3 direction;+ vec3 color;+ float distance;+ float decay;+ float coneCos;+ float penumbraCos;+ };+ uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];+ void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {+ vec3 lVector = spotLight.position - geometryPosition;+ light.direction = normalize( lVector );+ float angleCos = dot( light.direction, spotLight.direction );+ float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );+ if ( spotAttenuation > 0.0 ) {+ float lightDistance = length( lVector );+ light.color = spotLight.color * spotAttenuation;+ light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );+ light.visible = ( light.color != vec3( 0.0 ) );+ } else {+ light.color = vec3( 0.0 );+ light.visible = false;+ }+ }+#endif+#if NUM_RECT_AREA_LIGHTS > 0+ struct RectAreaLight {+ vec3 color;+ vec3 position;+ vec3 halfWidth;+ vec3 halfHeight;+ };+ uniform sampler2D ltc_1; uniform sampler2D ltc_2;+ uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];+#endif+#if NUM_HEMI_LIGHTS > 0+ struct HemisphereLight {+ vec3 direction;+ vec3 skyColor;+ vec3 groundColor;+ };+ uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];+ vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {+ float dotNL = dot( normal, hemiLight.direction );+ float hemiDiffuseWeight = 0.5 * dotNL + 0.5;+ vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );+ return irradiance;+ }+#endif`, qw = `#ifdef USE_ENVMAP+ vec3 getIBLIrradiance( const in vec3 normal ) {+ #ifdef ENVMAP_TYPE_CUBE_UV+ vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );+ vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );+ return PI * envMapColor.rgb * envMapIntensity;+ #else+ return vec3( 0.0 );+ #endif+ }+ vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {+ #ifdef ENVMAP_TYPE_CUBE_UV+ vec3 reflectVec = reflect( - viewDir, normal );+ reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );+ reflectVec = inverseTransformDirection( reflectVec, viewMatrix );+ vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );+ return envMapColor.rgb * envMapIntensity;+ #else+ return vec3( 0.0 );+ #endif+ }+ #ifdef USE_ANISOTROPY+ vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {+ #ifdef ENVMAP_TYPE_CUBE_UV+ vec3 bentNormal = cross( bitangent, viewDir );+ bentNormal = normalize( cross( bentNormal, bitangent ) );+ bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );+ return getIBLRadiance( viewDir, bentNormal, roughness );+ #else+ return vec3( 0.0 );+ #endif+ }+ #endif+#endif`, Kw = `ToonMaterial material;+material.diffuseColor = diffuseColor.rgb;`, jw = `varying vec3 vViewPosition;+struct ToonMaterial {+ vec3 diffuseColor;+};+void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {+ vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );+}+void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );+}+#define RE_Direct RE_Direct_Toon+#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`, Xw = `BlinnPhongMaterial material;+material.diffuseColor = diffuseColor.rgb;+material.specularColor = specular;+material.specularShininess = shininess;+material.specularStrength = specularStrength;`, Yw = `varying vec3 vViewPosition;+struct BlinnPhongMaterial {+ vec3 diffuseColor;+ vec3 specularColor;+ float specularShininess;+ float specularStrength;+};+void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {+ float dotNL = saturate( dot( geometryNormal, directLight.direction ) );+ vec3 irradiance = dotNL * directLight.color;+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );+ reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;+}+void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );+}+#define RE_Direct RE_Direct_BlinnPhong+#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`, Jw = `PhysicalMaterial material;+material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );+vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );+float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );+material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;+material.roughness = min( material.roughness, 1.0 );+#ifdef IOR+ material.ior = ior;+ #ifdef USE_SPECULAR+ float specularIntensityFactor = specularIntensity;+ vec3 specularColorFactor = specularColor;+ #ifdef USE_SPECULAR_COLORMAP+ specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;+ #endif+ #ifdef USE_SPECULAR_INTENSITYMAP+ specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;+ #endif+ material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );+ #else+ float specularIntensityFactor = 1.0;+ vec3 specularColorFactor = vec3( 1.0 );+ material.specularF90 = 1.0;+ #endif+ material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );+#else+ material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );+ material.specularF90 = 1.0;+#endif+#ifdef USE_CLEARCOAT+ material.clearcoat = clearcoat;+ material.clearcoatRoughness = clearcoatRoughness;+ material.clearcoatF0 = vec3( 0.04 );+ material.clearcoatF90 = 1.0;+ #ifdef USE_CLEARCOATMAP+ material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;+ #endif+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP+ material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;+ #endif+ material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );+ material.clearcoatRoughness += geometryRoughness;+ material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );+#endif+#ifdef USE_DISPERSION+ material.dispersion = dispersion;+#endif+#ifdef USE_IRIDESCENCE+ material.iridescence = iridescence;+ material.iridescenceIOR = iridescenceIOR;+ #ifdef USE_IRIDESCENCEMAP+ material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;+ #endif+ #ifdef USE_IRIDESCENCE_THICKNESSMAP+ material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;+ #else+ material.iridescenceThickness = iridescenceThicknessMaximum;+ #endif+#endif+#ifdef USE_SHEEN+ material.sheenColor = sheenColor;+ #ifdef USE_SHEEN_COLORMAP+ material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;+ #endif+ material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );+ #ifdef USE_SHEEN_ROUGHNESSMAP+ material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;+ #endif+#endif+#ifdef USE_ANISOTROPY+ #ifdef USE_ANISOTROPYMAP+ mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );+ vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;+ vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;+ #else+ vec2 anisotropyV = anisotropyVector;+ #endif+ material.anisotropy = length( anisotropyV );+ if( material.anisotropy == 0.0 ) {+ anisotropyV = vec2( 1.0, 0.0 );+ } else {+ anisotropyV /= material.anisotropy;+ material.anisotropy = saturate( material.anisotropy );+ }+ material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );+ material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;+ material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;+#endif`, Zw = `struct PhysicalMaterial {+ vec3 diffuseColor;+ float roughness;+ vec3 specularColor;+ float specularF90;+ float dispersion;+ #ifdef USE_CLEARCOAT+ float clearcoat;+ float clearcoatRoughness;+ vec3 clearcoatF0;+ float clearcoatF90;+ #endif+ #ifdef USE_IRIDESCENCE+ float iridescence;+ float iridescenceIOR;+ float iridescenceThickness;+ vec3 iridescenceFresnel;+ vec3 iridescenceF0;+ #endif+ #ifdef USE_SHEEN+ vec3 sheenColor;+ float sheenRoughness;+ #endif+ #ifdef IOR+ float ior;+ #endif+ #ifdef USE_TRANSMISSION+ float transmission;+ float transmissionAlpha;+ float thickness;+ float attenuationDistance;+ vec3 attenuationColor;+ #endif+ #ifdef USE_ANISOTROPY+ float anisotropy;+ float alphaT;+ vec3 anisotropyT;+ vec3 anisotropyB;+ #endif+};+vec3 clearcoatSpecularDirect = vec3( 0.0 );+vec3 clearcoatSpecularIndirect = vec3( 0.0 );+vec3 sheenSpecularDirect = vec3( 0.0 );+vec3 sheenSpecularIndirect = vec3(0.0 );+vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {+ float x = clamp( 1.0 - dotVH, 0.0, 1.0 );+ float x2 = x * x;+ float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );+ return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );+}+float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {+ float a2 = pow2( alpha );+ float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );+ float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );+ return 0.5 / max( gv + gl, EPSILON );+}+float D_GGX( const in float alpha, const in float dotNH ) {+ float a2 = pow2( alpha );+ float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;+ return RECIPROCAL_PI * a2 / pow2( denom );+}+#ifdef USE_ANISOTROPY+ float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {+ float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );+ float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );+ float v = 0.5 / ( gv + gl );+ return saturate(v);+ }+ float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {+ float a2 = alphaT * alphaB;+ highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );+ highp float v2 = dot( v, v );+ float w2 = a2 / v2;+ return RECIPROCAL_PI * a2 * pow2 ( w2 );+ }+#endif+#ifdef USE_CLEARCOAT+ vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {+ vec3 f0 = material.clearcoatF0;+ float f90 = material.clearcoatF90;+ float roughness = material.clearcoatRoughness;+ float alpha = pow2( roughness );+ vec3 halfDir = normalize( lightDir + viewDir );+ float dotNL = saturate( dot( normal, lightDir ) );+ float dotNV = saturate( dot( normal, viewDir ) );+ float dotNH = saturate( dot( normal, halfDir ) );+ float dotVH = saturate( dot( viewDir, halfDir ) );+ vec3 F = F_Schlick( f0, f90, dotVH );+ float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );+ float D = D_GGX( alpha, dotNH );+ return F * ( V * D );+ }+#endif+vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {+ vec3 f0 = material.specularColor;+ float f90 = material.specularF90;+ float roughness = material.roughness;+ float alpha = pow2( roughness );+ vec3 halfDir = normalize( lightDir + viewDir );+ float dotNL = saturate( dot( normal, lightDir ) );+ float dotNV = saturate( dot( normal, viewDir ) );+ float dotNH = saturate( dot( normal, halfDir ) );+ float dotVH = saturate( dot( viewDir, halfDir ) );+ vec3 F = F_Schlick( f0, f90, dotVH );+ #ifdef USE_IRIDESCENCE+ F = mix( F, material.iridescenceFresnel, material.iridescence );+ #endif+ #ifdef USE_ANISOTROPY+ float dotTL = dot( material.anisotropyT, lightDir );+ float dotTV = dot( material.anisotropyT, viewDir );+ float dotTH = dot( material.anisotropyT, halfDir );+ float dotBL = dot( material.anisotropyB, lightDir );+ float dotBV = dot( material.anisotropyB, viewDir );+ float dotBH = dot( material.anisotropyB, halfDir );+ float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );+ float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );+ #else+ float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );+ float D = D_GGX( alpha, dotNH );+ #endif+ return F * ( V * D );+}+vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {+ const float LUT_SIZE = 64.0;+ const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;+ const float LUT_BIAS = 0.5 / LUT_SIZE;+ float dotNV = saturate( dot( N, V ) );+ vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );+ uv = uv * LUT_SCALE + LUT_BIAS;+ return uv;+}+float LTC_ClippedSphereFormFactor( const in vec3 f ) {+ float l = length( f );+ return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );+}+vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {+ float x = dot( v1, v2 );+ float y = abs( x );+ float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;+ float b = 3.4175940 + ( 4.1616724 + y ) * y;+ float v = a / b;+ float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;+ return cross( v1, v2 ) * theta_sintheta;+}+vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {+ vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];+ vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];+ vec3 lightNormal = cross( v1, v2 );+ if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );+ vec3 T1, T2;+ T1 = normalize( V - N * dot( V, N ) );+ T2 = - cross( N, T1 );+ mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );+ vec3 coords[ 4 ];+ coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );+ coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );+ coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );+ coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );+ coords[ 0 ] = normalize( coords[ 0 ] );+ coords[ 1 ] = normalize( coords[ 1 ] );+ coords[ 2 ] = normalize( coords[ 2 ] );+ coords[ 3 ] = normalize( coords[ 3 ] );+ vec3 vectorFormFactor = vec3( 0.0 );+ vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );+ vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );+ vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );+ vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );+ float result = LTC_ClippedSphereFormFactor( vectorFormFactor );+ return vec3( result );+}+#if defined( USE_SHEEN )+float D_Charlie( float roughness, float dotNH ) {+ float alpha = pow2( roughness );+ float invAlpha = 1.0 / alpha;+ float cos2h = dotNH * dotNH;+ float sin2h = max( 1.0 - cos2h, 0.0078125 );+ return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );+}+float V_Neubelt( float dotNV, float dotNL ) {+ return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );+}+vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {+ vec3 halfDir = normalize( lightDir + viewDir );+ float dotNL = saturate( dot( normal, lightDir ) );+ float dotNV = saturate( dot( normal, viewDir ) );+ float dotNH = saturate( dot( normal, halfDir ) );+ float D = D_Charlie( sheenRoughness, dotNH );+ float V = V_Neubelt( dotNV, dotNL );+ return sheenColor * ( D * V );+}+#endif+float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {+ float dotNV = saturate( dot( normal, viewDir ) );+ float r2 = roughness * roughness;+ float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;+ float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;+ float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );+ return saturate( DG * RECIPROCAL_PI );+}+vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {+ float dotNV = saturate( dot( normal, viewDir ) );+ const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );+ const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );+ vec4 r = roughness * c0 + c1;+ float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;+ vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;+ return fab;+}+vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {+ vec2 fab = DFGApprox( normal, viewDir, roughness );+ return specularColor * fab.x + specularF90 * fab.y;+}+#ifdef USE_IRIDESCENCE+void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {+#else+void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {+#endif+ vec2 fab = DFGApprox( normal, viewDir, roughness );+ #ifdef USE_IRIDESCENCE+ vec3 Fr = mix( specularColor, iridescenceF0, iridescence );+ #else+ vec3 Fr = specularColor;+ #endif+ vec3 FssEss = Fr * fab.x + specularF90 * fab.y;+ float Ess = fab.x + fab.y;+ float Ems = 1.0 - Ess;+ vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );+ singleScatter += FssEss;+ multiScatter += Fms * Ems;+}+#if NUM_RECT_AREA_LIGHTS > 0+ void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {+ vec3 normal = geometryNormal;+ vec3 viewDir = geometryViewDir;+ vec3 position = geometryPosition;+ vec3 lightPos = rectAreaLight.position;+ vec3 halfWidth = rectAreaLight.halfWidth;+ vec3 halfHeight = rectAreaLight.halfHeight;+ vec3 lightColor = rectAreaLight.color;+ float roughness = material.roughness;+ vec3 rectCoords[ 4 ];+ rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;+ rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;+ rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;+ vec2 uv = LTC_Uv( normal, viewDir, roughness );+ vec4 t1 = texture2D( ltc_1, uv );+ vec4 t2 = texture2D( ltc_2, uv );+ mat3 mInv = mat3(+ vec3( t1.x, 0, t1.y ),+ vec3( 0, 1, 0 ),+ vec3( t1.z, 0, t1.w )+ );+ vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );+ reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );+ reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );+ }+#endif+void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {+ float dotNL = saturate( dot( geometryNormal, directLight.direction ) );+ vec3 irradiance = dotNL * directLight.color;+ #ifdef USE_CLEARCOAT+ float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );+ vec3 ccIrradiance = dotNLcc * directLight.color;+ clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );+ #endif+ #ifdef USE_SHEEN+ sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );+ #endif+ reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );+}+void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );+}+void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {+ #ifdef USE_CLEARCOAT+ clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );+ #endif+ #ifdef USE_SHEEN+ sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );+ #endif+ vec3 singleScattering = vec3( 0.0 );+ vec3 multiScattering = vec3( 0.0 );+ vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;+ #ifdef USE_IRIDESCENCE+ computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );+ #else+ computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );+ #endif+ vec3 totalScattering = singleScattering + multiScattering;+ vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );+ reflectedLight.indirectSpecular += radiance * singleScattering;+ reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;+ reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;+}+#define RE_Direct RE_Direct_Physical+#define RE_Direct_RectArea RE_Direct_RectArea_Physical+#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical+#define RE_IndirectSpecular RE_IndirectSpecular_Physical+float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {+ return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );+}`, $w = `+vec3 geometryPosition = - vViewPosition;+vec3 geometryNormal = normal;+vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );+vec3 geometryClearcoatNormal = vec3( 0.0 );+#ifdef USE_CLEARCOAT+ geometryClearcoatNormal = clearcoatNormal;+#endif+#ifdef USE_IRIDESCENCE+ float dotNVi = saturate( dot( normal, geometryViewDir ) );+ if ( material.iridescenceThickness == 0.0 ) {+ material.iridescence = 0.0;+ } else {+ material.iridescence = saturate( material.iridescence );+ }+ if ( material.iridescence > 0.0 ) {+ material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );+ material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );+ }+#endif+IncidentLight directLight;+#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )+ PointLight pointLight;+ #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0+ PointLightShadow pointLightShadow;+ #endif+ #pragma unroll_loop_start+ for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {+ pointLight = pointLights[ i ];+ getPointLightInfo( pointLight, geometryPosition, directLight );+ #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )+ pointLightShadow = pointLightShadows[ i ];+ directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;+ #endif+ RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );+ }+ #pragma unroll_loop_end+#endif+#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )+ SpotLight spotLight;+ vec4 spotColor;+ vec3 spotLightCoord;+ bool inSpotLightMap;+ #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0+ SpotLightShadow spotLightShadow;+ #endif+ #pragma unroll_loop_start+ for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {+ spotLight = spotLights[ i ];+ getSpotLightInfo( spotLight, geometryPosition, directLight );+ #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )+ #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX+ #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )+ #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS+ #else+ #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )+ #endif+ #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )+ spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;+ inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );+ spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );+ directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;+ #endif+ #undef SPOT_LIGHT_MAP_INDEX+ #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )+ spotLightShadow = spotLightShadows[ i ];+ directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;+ #endif+ RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );+ }+ #pragma unroll_loop_end+#endif+#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )+ DirectionalLight directionalLight;+ #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0+ DirectionalLightShadow directionalLightShadow;+ #endif+ #pragma unroll_loop_start+ for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {+ directionalLight = directionalLights[ i ];+ getDirectionalLightInfo( directionalLight, directLight );+ #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )+ directionalLightShadow = directionalLightShadows[ i ];+ directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;+ #endif+ RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );+ }+ #pragma unroll_loop_end+#endif+#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )+ RectAreaLight rectAreaLight;+ #pragma unroll_loop_start+ for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {+ rectAreaLight = rectAreaLights[ i ];+ RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );+ }+ #pragma unroll_loop_end+#endif+#if defined( RE_IndirectDiffuse )+ vec3 iblIrradiance = vec3( 0.0 );+ vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );+ #if defined( USE_LIGHT_PROBES )+ irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );+ #endif+ #if ( NUM_HEMI_LIGHTS > 0 )+ #pragma unroll_loop_start+ for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {+ irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );+ }+ #pragma unroll_loop_end+ #endif+#endif+#if defined( RE_IndirectSpecular )+ vec3 radiance = vec3( 0.0 );+ vec3 clearcoatRadiance = vec3( 0.0 );+#endif`, ev = `#if defined( RE_IndirectDiffuse )+ #ifdef USE_LIGHTMAP+ vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );+ vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;+ irradiance += lightMapIrradiance;+ #endif+ #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )+ iblIrradiance += getIBLIrradiance( geometryNormal );+ #endif+#endif+#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )+ #ifdef USE_ANISOTROPY+ radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );+ #else+ radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );+ #endif+ #ifdef USE_CLEARCOAT+ clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );+ #endif+#endif`, tv = `#if defined( RE_IndirectDiffuse )+ RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );+#endif+#if defined( RE_IndirectSpecular )+ RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );+#endif`, nv = `#if defined( USE_LOGDEPTHBUF )+ gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;+#endif`, iv = `#if defined( USE_LOGDEPTHBUF )+ uniform float logDepthBufFC;+ varying float vFragDepth;+ varying float vIsPerspective;+#endif`, sv = `#ifdef USE_LOGDEPTHBUF+ varying float vFragDepth;+ varying float vIsPerspective;+#endif`, rv = `#ifdef USE_LOGDEPTHBUF+ vFragDepth = 1.0 + gl_Position.w;+ vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );+#endif`, av = `#ifdef USE_MAP+ vec4 sampledDiffuseColor = texture2D( map, vMapUv );+ #ifdef DECODE_VIDEO_TEXTURE+ sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );+ #endif+ diffuseColor *= sampledDiffuseColor;+#endif`, ov = `#ifdef USE_MAP+ uniform sampler2D map;+#endif`, cv = `#if defined( USE_MAP ) || defined( USE_ALPHAMAP )+ #if defined( USE_POINTS_UV )+ vec2 uv = vUv;+ #else+ vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;+ #endif+#endif+#ifdef USE_MAP+ diffuseColor *= texture2D( map, uv );+#endif+#ifdef USE_ALPHAMAP+ diffuseColor.a *= texture2D( alphaMap, uv ).g;+#endif`, lv = `#if defined( USE_POINTS_UV )+ varying vec2 vUv;+#else+ #if defined( USE_MAP ) || defined( USE_ALPHAMAP )+ uniform mat3 uvTransform;+ #endif+#endif+#ifdef USE_MAP+ uniform sampler2D map;+#endif+#ifdef USE_ALPHAMAP+ uniform sampler2D alphaMap;+#endif`, hv = `float metalnessFactor = metalness;+#ifdef USE_METALNESSMAP+ vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );+ metalnessFactor *= texelMetalness.b;+#endif`, uv = `#ifdef USE_METALNESSMAP+ uniform sampler2D metalnessMap;+#endif`, dv = `#ifdef USE_INSTANCING_MORPH+ float morphTargetInfluences[ MORPHTARGETS_COUNT ];+ float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {+ morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;+ }+#endif`, fv = `#if defined( USE_MORPHCOLORS )+ vColor *= morphTargetBaseInfluence;+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {+ #if defined( USE_COLOR_ALPHA )+ if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];+ #elif defined( USE_COLOR )+ if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];+ #endif+ }+#endif`, pv = `#ifdef USE_MORPHNORMALS+ objectNormal *= morphTargetBaseInfluence;+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {+ if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];+ }+#endif`, Av = `#ifdef USE_MORPHTARGETS+ #ifndef USE_INSTANCING_MORPH+ uniform float morphTargetBaseInfluence;+ uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];+ #endif+ uniform sampler2DArray morphTargetsTexture;+ uniform ivec2 morphTargetsTextureSize;+ vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {+ int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;+ int y = texelIndex / morphTargetsTextureSize.x;+ int x = texelIndex - y * morphTargetsTextureSize.x;+ ivec3 morphUV = ivec3( x, y, morphTargetIndex );+ return texelFetch( morphTargetsTexture, morphUV, 0 );+ }+#endif`, gv = `#ifdef USE_MORPHTARGETS+ transformed *= morphTargetBaseInfluence;+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {+ if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];+ }+#endif`, mv = `float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;+#ifdef FLAT_SHADED+ vec3 fdx = dFdx( vViewPosition );+ vec3 fdy = dFdy( vViewPosition );+ vec3 normal = normalize( cross( fdx, fdy ) );+#else+ vec3 normal = normalize( vNormal );+ #ifdef DOUBLE_SIDED+ normal *= faceDirection;+ #endif+#endif+#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )+ #ifdef USE_TANGENT+ mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );+ #else+ mat3 tbn = getTangentFrame( - vViewPosition, normal,+ #if defined( USE_NORMALMAP )+ vNormalMapUv+ #elif defined( USE_CLEARCOAT_NORMALMAP )+ vClearcoatNormalMapUv+ #else+ vUv+ #endif+ );+ #endif+ #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )+ tbn[0] *= faceDirection;+ tbn[1] *= faceDirection;+ #endif+#endif+#ifdef USE_CLEARCOAT_NORMALMAP+ #ifdef USE_TANGENT+ mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );+ #else+ mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );+ #endif+ #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )+ tbn2[0] *= faceDirection;+ tbn2[1] *= faceDirection;+ #endif+#endif+vec3 nonPerturbedNormal = normal;`, bv = `#ifdef USE_NORMALMAP_OBJECTSPACE+ normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;+ #ifdef FLIP_SIDED+ normal = - normal;+ #endif+ #ifdef DOUBLE_SIDED+ normal = normal * faceDirection;+ #endif+ normal = normalize( normalMatrix * normal );+#elif defined( USE_NORMALMAP_TANGENTSPACE )+ vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;+ mapN.xy *= normalScale;+ normal = normalize( tbn * mapN );+#elif defined( USE_BUMPMAP )+ normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );+#endif`, xv = `#ifndef FLAT_SHADED+ varying vec3 vNormal;+ #ifdef USE_TANGENT+ varying vec3 vTangent;+ varying vec3 vBitangent;+ #endif+#endif`, _v = `#ifndef FLAT_SHADED+ varying vec3 vNormal;+ #ifdef USE_TANGENT+ varying vec3 vTangent;+ varying vec3 vBitangent;+ #endif+#endif`, Ev = `#ifndef FLAT_SHADED+ vNormal = normalize( transformedNormal );+ #ifdef USE_TANGENT+ vTangent = normalize( transformedTangent );+ vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );+ #endif+#endif`, yv = `#ifdef USE_NORMALMAP+ uniform sampler2D normalMap;+ uniform vec2 normalScale;+#endif+#ifdef USE_NORMALMAP_OBJECTSPACE+ uniform mat3 normalMatrix;+#endif+#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )+ mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {+ vec3 q0 = dFdx( eye_pos.xyz );+ vec3 q1 = dFdy( eye_pos.xyz );+ vec2 st0 = dFdx( uv.st );+ vec2 st1 = dFdy( uv.st );+ vec3 N = surf_norm;+ vec3 q1perp = cross( q1, N );+ vec3 q0perp = cross( N, q0 );+ vec3 T = q1perp * st0.x + q0perp * st1.x;+ vec3 B = q1perp * st0.y + q0perp * st1.y;+ float det = max( dot( T, T ), dot( B, B ) );+ float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );+ return mat3( T * scale, B * scale, N );+ }+#endif`, wv = `#ifdef USE_CLEARCOAT+ vec3 clearcoatNormal = nonPerturbedNormal;+#endif`, vv = `#ifdef USE_CLEARCOAT_NORMALMAP+ vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;+ clearcoatMapN.xy *= clearcoatNormalScale;+ clearcoatNormal = normalize( tbn2 * clearcoatMapN );+#endif`, Cv = `#ifdef USE_CLEARCOATMAP+ uniform sampler2D clearcoatMap;+#endif+#ifdef USE_CLEARCOAT_NORMALMAP+ uniform sampler2D clearcoatNormalMap;+ uniform vec2 clearcoatNormalScale;+#endif+#ifdef USE_CLEARCOAT_ROUGHNESSMAP+ uniform sampler2D clearcoatRoughnessMap;+#endif`, Sv = `#ifdef USE_IRIDESCENCEMAP+ uniform sampler2D iridescenceMap;+#endif+#ifdef USE_IRIDESCENCE_THICKNESSMAP+ uniform sampler2D iridescenceThicknessMap;+#endif`, Iv = `#ifdef OPAQUE+diffuseColor.a = 1.0;+#endif+#ifdef USE_TRANSMISSION+diffuseColor.a *= material.transmissionAlpha;+#endif+gl_FragColor = vec4( outgoingLight, diffuseColor.a );`, Mv = `vec3 packNormalToRGB( const in vec3 normal ) {+ return normalize( normal ) * 0.5 + 0.5;+}+vec3 unpackRGBToNormal( const in vec3 rgb ) {+ return 2.0 * rgb.xyz - 1.0;+}+const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;+const float Inv255 = 1. / 255.;+const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );+const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );+const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );+const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );+vec4 packDepthToRGBA( const in float v ) {+ if( v <= 0.0 )+ return vec4( 0., 0., 0., 0. );+ if( v >= 1.0 )+ return vec4( 1., 1., 1., 1. );+ float vuf;+ float af = modf( v * PackFactors.a, vuf );+ float bf = modf( vuf * ShiftRight8, vuf );+ float gf = modf( vuf * ShiftRight8, vuf );+ return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );+}+vec3 packDepthToRGB( const in float v ) {+ if( v <= 0.0 )+ return vec3( 0., 0., 0. );+ if( v >= 1.0 )+ return vec3( 1., 1., 1. );+ float vuf;+ float bf = modf( v * PackFactors.b, vuf );+ float gf = modf( vuf * ShiftRight8, vuf );+ return vec3( vuf * Inv255, gf * PackUpscale, bf );+}+vec2 packDepthToRG( const in float v ) {+ if( v <= 0.0 )+ return vec2( 0., 0. );+ if( v >= 1.0 )+ return vec2( 1., 1. );+ float vuf;+ float gf = modf( v * 256., vuf );+ return vec2( vuf * Inv255, gf );+}+float unpackRGBAToDepth( const in vec4 v ) {+ return dot( v, UnpackFactors4 );+}+float unpackRGBToDepth( const in vec3 v ) {+ return dot( v, UnpackFactors3 );+}+float unpackRGToDepth( const in vec2 v ) {+ return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;+}+vec4 pack2HalfToRGBA( const in vec2 v ) {+ vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );+ return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );+}+vec2 unpackRGBATo2Half( const in vec4 v ) {+ return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );+}+float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {+ return ( viewZ + near ) / ( near - far );+}+float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {+ return depth * ( near - far ) - near;+}+float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {+ return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );+}+float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {+ return ( near * far ) / ( ( far - near ) * depth - far );+}`, Bv = `#ifdef PREMULTIPLIED_ALPHA+ gl_FragColor.rgb *= gl_FragColor.a;+#endif`, Tv = `vec4 mvPosition = vec4( transformed, 1.0 );+#ifdef USE_BATCHING+ mvPosition = batchingMatrix * mvPosition;+#endif+#ifdef USE_INSTANCING+ mvPosition = instanceMatrix * mvPosition;+#endif+mvPosition = modelViewMatrix * mvPosition;+gl_Position = projectionMatrix * mvPosition;`, Rv = `#ifdef DITHERING+ gl_FragColor.rgb = dithering( gl_FragColor.rgb );+#endif`, Nv = `#ifdef DITHERING+ vec3 dithering( vec3 color ) {+ float grid_position = rand( gl_FragCoord.xy );+ vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );+ dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );+ return color + dither_shift_RGB;+ }+#endif`, Fv = `float roughnessFactor = roughness;+#ifdef USE_ROUGHNESSMAP+ vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );+ roughnessFactor *= texelRoughness.g;+#endif`, Dv = `#ifdef USE_ROUGHNESSMAP+ uniform sampler2D roughnessMap;+#endif`, Lv = `#if NUM_SPOT_LIGHT_COORDS > 0+ varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];+#endif+#if NUM_SPOT_LIGHT_MAPS > 0+ uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];+#endif+#ifdef USE_SHADOWMAP+ #if NUM_DIR_LIGHT_SHADOWS > 0+ uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];+ varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];+ struct DirectionalLightShadow {+ float shadowIntensity;+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ };+ uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];+ #endif+ #if NUM_SPOT_LIGHT_SHADOWS > 0+ uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];+ struct SpotLightShadow {+ float shadowIntensity;+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ };+ uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];+ #endif+ #if NUM_POINT_LIGHT_SHADOWS > 0+ uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];+ varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];+ struct PointLightShadow {+ float shadowIntensity;+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ float shadowCameraNear;+ float shadowCameraFar;+ };+ uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];+ #endif+ float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {+ return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );+ }+ vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {+ return unpackRGBATo2Half( texture2D( shadow, uv ) );+ }+ float VSMShadow (sampler2D shadow, vec2 uv, float compare ){+ float occlusion = 1.0;+ vec2 distribution = texture2DDistribution( shadow, uv );+ float hard_shadow = step( compare , distribution.x );+ if (hard_shadow != 1.0 ) {+ float distance = compare - distribution.x ;+ float variance = max( 0.00000, distribution.y * distribution.y );+ float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );+ }+ return occlusion;+ }+ float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {+ float shadow = 1.0;+ shadowCoord.xyz /= shadowCoord.w;+ shadowCoord.z += shadowBias;+ bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;+ bool frustumTest = inFrustum && shadowCoord.z <= 1.0;+ if ( frustumTest ) {+ #if defined( SHADOWMAP_TYPE_PCF )+ vec2 texelSize = vec2( 1.0 ) / shadowMapSize;+ float dx0 = - texelSize.x * shadowRadius;+ float dy0 = - texelSize.y * shadowRadius;+ float dx1 = + texelSize.x * shadowRadius;+ float dy1 = + texelSize.y * shadowRadius;+ float dx2 = dx0 / 2.0;+ float dy2 = dy0 / 2.0;+ float dx3 = dx1 / 2.0;+ float dy3 = dy1 / 2.0;+ shadow = (+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) ++ texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) ++ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) ++ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) ++ texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) ++ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) ++ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) ++ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) ++ texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) ++ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) ++ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) ++ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) ++ texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) ++ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) ++ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) ++ texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) ++ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )+ ) * ( 1.0 / 17.0 );+ #elif defined( SHADOWMAP_TYPE_PCF_SOFT )+ vec2 texelSize = vec2( 1.0 ) / shadowMapSize;+ float dx = texelSize.x;+ float dy = texelSize.y;+ vec2 uv = shadowCoord.xy;+ vec2 f = fract( uv * shadowMapSize + 0.5 );+ uv -= f * texelSize;+ shadow = (+ texture2DCompare( shadowMap, uv, shadowCoord.z ) ++ texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) ++ texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) ++ texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) ++ mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),+ texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),+ f.x ) ++ mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),+ texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),+ f.x ) ++ mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),+ texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),+ f.y ) ++ mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),+ texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),+ f.y ) ++ mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),+ texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),+ f.x ),+ mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),+ texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),+ f.x ),+ f.y )+ ) * ( 1.0 / 9.0 );+ #elif defined( SHADOWMAP_TYPE_VSM )+ shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );+ #else+ shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );+ #endif+ }+ return mix( 1.0, shadow, shadowIntensity );+ }+ vec2 cubeToUV( vec3 v, float texelSizeY ) {+ vec3 absV = abs( v );+ float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );+ absV *= scaleToCube;+ v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );+ vec2 planar = v.xy;+ float almostATexel = 1.5 * texelSizeY;+ float almostOne = 1.0 - almostATexel;+ if ( absV.z >= almostOne ) {+ if ( v.z > 0.0 )+ planar.x = 4.0 - v.x;+ } else if ( absV.x >= almostOne ) {+ float signX = sign( v.x );+ planar.x = v.z * signX + 2.0 * signX;+ } else if ( absV.y >= almostOne ) {+ float signY = sign( v.y );+ planar.x = v.x + 2.0 * signY + 2.0;+ planar.y = v.z * signY - 2.0;+ }+ return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );+ }+ float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {+ float shadow = 1.0;+ vec3 lightToPosition = shadowCoord.xyz;++ float lightToPositionLength = length( lightToPosition );+ if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {+ float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;+ vec3 bd3D = normalize( lightToPosition );+ vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );+ #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )+ vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;+ shadow = (+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) ++ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) ++ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) ++ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) ++ texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) ++ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) ++ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) ++ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) ++ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )+ ) * ( 1.0 / 9.0 );+ #else+ shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );+ #endif+ }+ return mix( 1.0, shadow, shadowIntensity );+ }+#endif`, Pv = `#if NUM_SPOT_LIGHT_COORDS > 0+ uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];+ varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];+#endif+#ifdef USE_SHADOWMAP+ #if NUM_DIR_LIGHT_SHADOWS > 0+ uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];+ varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];+ struct DirectionalLightShadow {+ float shadowIntensity;+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ };+ uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];+ #endif+ #if NUM_SPOT_LIGHT_SHADOWS > 0+ struct SpotLightShadow {+ float shadowIntensity;+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ };+ uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];+ #endif+ #if NUM_POINT_LIGHT_SHADOWS > 0+ uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];+ varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];+ struct PointLightShadow {+ float shadowIntensity;+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ float shadowCameraNear;+ float shadowCameraFar;+ };+ uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];+ #endif+#endif`, kv = `#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )+ vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );+ vec4 shadowWorldPosition;+#endif+#if defined( USE_SHADOWMAP )+ #if NUM_DIR_LIGHT_SHADOWS > 0+ #pragma unroll_loop_start+ for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {+ shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );+ vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;+ }+ #pragma unroll_loop_end+ #endif+ #if NUM_POINT_LIGHT_SHADOWS > 0+ #pragma unroll_loop_start+ for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {+ shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );+ vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;+ }+ #pragma unroll_loop_end+ #endif+#endif+#if NUM_SPOT_LIGHT_COORDS > 0+ #pragma unroll_loop_start+ for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {+ shadowWorldPosition = worldPosition;+ #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )+ shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;+ #endif+ vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;+ }+ #pragma unroll_loop_end+#endif`, Uv = `float getShadowMask() {+ float shadow = 1.0;+ #ifdef USE_SHADOWMAP+ #if NUM_DIR_LIGHT_SHADOWS > 0+ DirectionalLightShadow directionalLight;+ #pragma unroll_loop_start+ for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {+ directionalLight = directionalLightShadows[ i ];+ shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;+ }+ #pragma unroll_loop_end+ #endif+ #if NUM_SPOT_LIGHT_SHADOWS > 0+ SpotLightShadow spotLight;+ #pragma unroll_loop_start+ for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {+ spotLight = spotLightShadows[ i ];+ shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;+ }+ #pragma unroll_loop_end+ #endif+ #if NUM_POINT_LIGHT_SHADOWS > 0+ PointLightShadow pointLight;+ #pragma unroll_loop_start+ for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {+ pointLight = pointLightShadows[ i ];+ shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;+ }+ #pragma unroll_loop_end+ #endif+ #endif+ return shadow;+}`, Ov = `#ifdef USE_SKINNING+ mat4 boneMatX = getBoneMatrix( skinIndex.x );+ mat4 boneMatY = getBoneMatrix( skinIndex.y );+ mat4 boneMatZ = getBoneMatrix( skinIndex.z );+ mat4 boneMatW = getBoneMatrix( skinIndex.w );+#endif`, Qv = `#ifdef USE_SKINNING+ uniform mat4 bindMatrix;+ uniform mat4 bindMatrixInverse;+ uniform highp sampler2D boneTexture;+ mat4 getBoneMatrix( const in float i ) {+ int size = textureSize( boneTexture, 0 ).x;+ int j = int( i ) * 4;+ int x = j % size;+ int y = j / size;+ vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );+ vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );+ vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );+ vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );+ return mat4( v1, v2, v3, v4 );+ }+#endif`, Gv = `#ifdef USE_SKINNING+ vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );+ vec4 skinned = vec4( 0.0 );+ skinned += boneMatX * skinVertex * skinWeight.x;+ skinned += boneMatY * skinVertex * skinWeight.y;+ skinned += boneMatZ * skinVertex * skinWeight.z;+ skinned += boneMatW * skinVertex * skinWeight.w;+ transformed = ( bindMatrixInverse * skinned ).xyz;+#endif`, Hv = `#ifdef USE_SKINNING+ mat4 skinMatrix = mat4( 0.0 );+ skinMatrix += skinWeight.x * boneMatX;+ skinMatrix += skinWeight.y * boneMatY;+ skinMatrix += skinWeight.z * boneMatZ;+ skinMatrix += skinWeight.w * boneMatW;+ skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;+ objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;+ #ifdef USE_TANGENT+ objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;+ #endif+#endif`, zv = `float specularStrength;+#ifdef USE_SPECULARMAP+ vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );+ specularStrength = texelSpecular.r;+#else+ specularStrength = 1.0;+#endif`, Vv = `#ifdef USE_SPECULARMAP+ uniform sampler2D specularMap;+#endif`, Wv = `#if defined( TONE_MAPPING )+ gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );+#endif`, qv = `#ifndef saturate+#define saturate( a ) clamp( a, 0.0, 1.0 )+#endif+uniform float toneMappingExposure;+vec3 LinearToneMapping( vec3 color ) {+ return saturate( toneMappingExposure * color );+}+vec3 ReinhardToneMapping( vec3 color ) {+ color *= toneMappingExposure;+ return saturate( color / ( vec3( 1.0 ) + color ) );+}+vec3 CineonToneMapping( vec3 color ) {+ color *= toneMappingExposure;+ color = max( vec3( 0.0 ), color - 0.004 );+ return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );+}+vec3 RRTAndODTFit( vec3 v ) {+ vec3 a = v * ( v + 0.0245786 ) - 0.000090537;+ vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;+ return a / b;+}+vec3 ACESFilmicToneMapping( vec3 color ) {+ const mat3 ACESInputMat = mat3(+ vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),+ vec3( 0.04823, 0.01566, 0.83777 )+ );+ const mat3 ACESOutputMat = mat3(+ vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),+ vec3( -0.07367, -0.00605, 1.07602 )+ );+ color *= toneMappingExposure / 0.6;+ color = ACESInputMat * color;+ color = RRTAndODTFit( color );+ color = ACESOutputMat * color;+ return saturate( color );+}+const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(+ vec3( 1.6605, - 0.1246, - 0.0182 ),+ vec3( - 0.5876, 1.1329, - 0.1006 ),+ vec3( - 0.0728, - 0.0083, 1.1187 )+);+const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(+ vec3( 0.6274, 0.0691, 0.0164 ),+ vec3( 0.3293, 0.9195, 0.0880 ),+ vec3( 0.0433, 0.0113, 0.8956 )+);+vec3 agxDefaultContrastApprox( vec3 x ) {+ vec3 x2 = x * x;+ vec3 x4 = x2 * x2;+ return + 15.5 * x4 * x2+ - 40.14 * x4 * x+ + 31.96 * x4+ - 6.868 * x2 * x+ + 0.4298 * x2+ + 0.1191 * x+ - 0.00232;+}+vec3 AgXToneMapping( vec3 color ) {+ const mat3 AgXInsetMatrix = mat3(+ vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),+ vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),+ vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )+ );+ const mat3 AgXOutsetMatrix = mat3(+ vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),+ vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),+ vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )+ );+ const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;+ color *= toneMappingExposure;+ color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;+ color = AgXInsetMatrix * color;+ color = max( color, 1e-10 ); color = log2( color );+ color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );+ color = clamp( color, 0.0, 1.0 );+ color = agxDefaultContrastApprox( color );+ color = AgXOutsetMatrix * color;+ color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );+ color = LINEAR_REC2020_TO_LINEAR_SRGB * color;+ color = clamp( color, 0.0, 1.0 );+ return color;+}+vec3 NeutralToneMapping( vec3 color ) {+ const float StartCompression = 0.8 - 0.04;+ const float Desaturation = 0.15;+ color *= toneMappingExposure;+ float x = min( color.r, min( color.g, color.b ) );+ float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;+ color -= offset;+ float peak = max( color.r, max( color.g, color.b ) );+ if ( peak < StartCompression ) return color;+ float d = 1. - StartCompression;+ float newPeak = 1. - d * d / ( peak + d - StartCompression );+ color *= newPeak / peak;+ float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );+ return mix( color, vec3( newPeak ), g );+}+vec3 CustomToneMapping( vec3 color ) { return color; }`, Kv = `#ifdef USE_TRANSMISSION+ material.transmission = transmission;+ material.transmissionAlpha = 1.0;+ material.thickness = thickness;+ material.attenuationDistance = attenuationDistance;+ material.attenuationColor = attenuationColor;+ #ifdef USE_TRANSMISSIONMAP+ material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;+ #endif+ #ifdef USE_THICKNESSMAP+ material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;+ #endif+ vec3 pos = vWorldPosition;+ vec3 v = normalize( cameraPosition - pos );+ vec3 n = inverseTransformDirection( normal, viewMatrix );+ vec4 transmitted = getIBLVolumeRefraction(+ n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,+ pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,+ material.attenuationColor, material.attenuationDistance );+ material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );+ totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );+#endif`, jv = `#ifdef USE_TRANSMISSION+ uniform float transmission;+ uniform float thickness;+ uniform float attenuationDistance;+ uniform vec3 attenuationColor;+ #ifdef USE_TRANSMISSIONMAP+ uniform sampler2D transmissionMap;+ #endif+ #ifdef USE_THICKNESSMAP+ uniform sampler2D thicknessMap;+ #endif+ uniform vec2 transmissionSamplerSize;+ uniform sampler2D transmissionSamplerMap;+ uniform mat4 modelMatrix;+ uniform mat4 projectionMatrix;+ varying vec3 vWorldPosition;+ float w0( float a ) {+ return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );+ }+ float w1( float a ) {+ return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );+ }+ float w2( float a ){+ return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );+ }+ float w3( float a ) {+ return ( 1.0 / 6.0 ) * ( a * a * a );+ }+ float g0( float a ) {+ return w0( a ) + w1( a );+ }+ float g1( float a ) {+ return w2( a ) + w3( a );+ }+ float h0( float a ) {+ return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );+ }+ float h1( float a ) {+ return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );+ }+ vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {+ uv = uv * texelSize.zw + 0.5;+ vec2 iuv = floor( uv );+ vec2 fuv = fract( uv );+ float g0x = g0( fuv.x );+ float g1x = g1( fuv.x );+ float h0x = h0( fuv.x );+ float h1x = h1( fuv.x );+ float h0y = h0( fuv.y );+ float h1y = h1( fuv.y );+ vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;+ vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;+ vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;+ vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;+ return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) ++ g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );+ }+ vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {+ vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );+ vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );+ vec2 fLodSizeInv = 1.0 / fLodSize;+ vec2 cLodSizeInv = 1.0 / cLodSize;+ vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );+ vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );+ return mix( fSample, cSample, fract( lod ) );+ }+ vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {+ vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );+ vec3 modelScale;+ modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );+ modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );+ modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );+ return normalize( refractionVector ) * thickness * modelScale;+ }+ float applyIorToRoughness( const in float roughness, const in float ior ) {+ return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );+ }+ vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {+ float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );+ return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );+ }+ vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {+ if ( isinf( attenuationDistance ) ) {+ return vec3( 1.0 );+ } else {+ vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;+ vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;+ }+ }+ vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,+ const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,+ const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,+ const in vec3 attenuationColor, const in float attenuationDistance ) {+ vec4 transmittedLight;+ vec3 transmittance;+ #ifdef USE_DISPERSION+ float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;+ vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );+ for ( int i = 0; i < 3; i ++ ) {+ vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );+ vec3 refractedRayExit = position + transmissionRay;+ vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );+ vec2 refractionCoords = ndcPos.xy / ndcPos.w;+ refractionCoords += 1.0;+ refractionCoords /= 2.0;+ vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );+ transmittedLight[ i ] = transmissionSample[ i ];+ transmittedLight.a += transmissionSample.a;+ transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];+ }+ transmittedLight.a /= 3.0;+ #else+ vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );+ vec3 refractedRayExit = position + transmissionRay;+ vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );+ vec2 refractionCoords = ndcPos.xy / ndcPos.w;+ refractionCoords += 1.0;+ refractionCoords /= 2.0;+ transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );+ transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );+ #endif+ vec3 attenuatedColor = transmittance * transmittedLight.rgb;+ vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );+ float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;+ return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );+ }+#endif`, Xv = `#if defined( USE_UV ) || defined( USE_ANISOTROPY )+ varying vec2 vUv;+#endif+#ifdef USE_MAP+ varying vec2 vMapUv;+#endif+#ifdef USE_ALPHAMAP+ varying vec2 vAlphaMapUv;+#endif+#ifdef USE_LIGHTMAP+ varying vec2 vLightMapUv;+#endif+#ifdef USE_AOMAP+ varying vec2 vAoMapUv;+#endif+#ifdef USE_BUMPMAP+ varying vec2 vBumpMapUv;+#endif+#ifdef USE_NORMALMAP+ varying vec2 vNormalMapUv;+#endif+#ifdef USE_EMISSIVEMAP+ varying vec2 vEmissiveMapUv;+#endif+#ifdef USE_METALNESSMAP+ varying vec2 vMetalnessMapUv;+#endif+#ifdef USE_ROUGHNESSMAP+ varying vec2 vRoughnessMapUv;+#endif+#ifdef USE_ANISOTROPYMAP+ varying vec2 vAnisotropyMapUv;+#endif+#ifdef USE_CLEARCOATMAP+ varying vec2 vClearcoatMapUv;+#endif+#ifdef USE_CLEARCOAT_NORMALMAP+ varying vec2 vClearcoatNormalMapUv;+#endif+#ifdef USE_CLEARCOAT_ROUGHNESSMAP+ varying vec2 vClearcoatRoughnessMapUv;+#endif+#ifdef USE_IRIDESCENCEMAP+ varying vec2 vIridescenceMapUv;+#endif+#ifdef USE_IRIDESCENCE_THICKNESSMAP+ varying vec2 vIridescenceThicknessMapUv;+#endif+#ifdef USE_SHEEN_COLORMAP+ varying vec2 vSheenColorMapUv;+#endif+#ifdef USE_SHEEN_ROUGHNESSMAP+ varying vec2 vSheenRoughnessMapUv;+#endif+#ifdef USE_SPECULARMAP+ varying vec2 vSpecularMapUv;+#endif+#ifdef USE_SPECULAR_COLORMAP+ varying vec2 vSpecularColorMapUv;+#endif+#ifdef USE_SPECULAR_INTENSITYMAP+ varying vec2 vSpecularIntensityMapUv;+#endif+#ifdef USE_TRANSMISSIONMAP+ uniform mat3 transmissionMapTransform;+ varying vec2 vTransmissionMapUv;+#endif+#ifdef USE_THICKNESSMAP+ uniform mat3 thicknessMapTransform;+ varying vec2 vThicknessMapUv;+#endif`, Yv = `#if defined( USE_UV ) || defined( USE_ANISOTROPY )+ varying vec2 vUv;+#endif+#ifdef USE_MAP+ uniform mat3 mapTransform;+ varying vec2 vMapUv;+#endif+#ifdef USE_ALPHAMAP+ uniform mat3 alphaMapTransform;+ varying vec2 vAlphaMapUv;+#endif+#ifdef USE_LIGHTMAP+ uniform mat3 lightMapTransform;+ varying vec2 vLightMapUv;+#endif+#ifdef USE_AOMAP+ uniform mat3 aoMapTransform;+ varying vec2 vAoMapUv;+#endif+#ifdef USE_BUMPMAP+ uniform mat3 bumpMapTransform;+ varying vec2 vBumpMapUv;+#endif+#ifdef USE_NORMALMAP+ uniform mat3 normalMapTransform;+ varying vec2 vNormalMapUv;+#endif+#ifdef USE_DISPLACEMENTMAP+ uniform mat3 displacementMapTransform;+ varying vec2 vDisplacementMapUv;+#endif+#ifdef USE_EMISSIVEMAP+ uniform mat3 emissiveMapTransform;+ varying vec2 vEmissiveMapUv;+#endif+#ifdef USE_METALNESSMAP+ uniform mat3 metalnessMapTransform;+ varying vec2 vMetalnessMapUv;+#endif+#ifdef USE_ROUGHNESSMAP+ uniform mat3 roughnessMapTransform;+ varying vec2 vRoughnessMapUv;+#endif+#ifdef USE_ANISOTROPYMAP+ uniform mat3 anisotropyMapTransform;+ varying vec2 vAnisotropyMapUv;+#endif+#ifdef USE_CLEARCOATMAP+ uniform mat3 clearcoatMapTransform;+ varying vec2 vClearcoatMapUv;+#endif+#ifdef USE_CLEARCOAT_NORMALMAP+ uniform mat3 clearcoatNormalMapTransform;+ varying vec2 vClearcoatNormalMapUv;+#endif+#ifdef USE_CLEARCOAT_ROUGHNESSMAP+ uniform mat3 clearcoatRoughnessMapTransform;+ varying vec2 vClearcoatRoughnessMapUv;+#endif+#ifdef USE_SHEEN_COLORMAP+ uniform mat3 sheenColorMapTransform;+ varying vec2 vSheenColorMapUv;+#endif+#ifdef USE_SHEEN_ROUGHNESSMAP+ uniform mat3 sheenRoughnessMapTransform;+ varying vec2 vSheenRoughnessMapUv;+#endif+#ifdef USE_IRIDESCENCEMAP+ uniform mat3 iridescenceMapTransform;+ varying vec2 vIridescenceMapUv;+#endif+#ifdef USE_IRIDESCENCE_THICKNESSMAP+ uniform mat3 iridescenceThicknessMapTransform;+ varying vec2 vIridescenceThicknessMapUv;+#endif+#ifdef USE_SPECULARMAP+ uniform mat3 specularMapTransform;+ varying vec2 vSpecularMapUv;+#endif+#ifdef USE_SPECULAR_COLORMAP+ uniform mat3 specularColorMapTransform;+ varying vec2 vSpecularColorMapUv;+#endif+#ifdef USE_SPECULAR_INTENSITYMAP+ uniform mat3 specularIntensityMapTransform;+ varying vec2 vSpecularIntensityMapUv;+#endif+#ifdef USE_TRANSMISSIONMAP+ uniform mat3 transmissionMapTransform;+ varying vec2 vTransmissionMapUv;+#endif+#ifdef USE_THICKNESSMAP+ uniform mat3 thicknessMapTransform;+ varying vec2 vThicknessMapUv;+#endif`, Jv = `#if defined( USE_UV ) || defined( USE_ANISOTROPY )+ vUv = vec3( uv, 1 ).xy;+#endif+#ifdef USE_MAP+ vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;+#endif+#ifdef USE_ALPHAMAP+ vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;+#endif+#ifdef USE_LIGHTMAP+ vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;+#endif+#ifdef USE_AOMAP+ vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;+#endif+#ifdef USE_BUMPMAP+ vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;+#endif+#ifdef USE_NORMALMAP+ vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;+#endif+#ifdef USE_DISPLACEMENTMAP+ vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;+#endif+#ifdef USE_EMISSIVEMAP+ vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;+#endif+#ifdef USE_METALNESSMAP+ vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;+#endif+#ifdef USE_ROUGHNESSMAP+ vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;+#endif+#ifdef USE_ANISOTROPYMAP+ vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;+#endif+#ifdef USE_CLEARCOATMAP+ vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;+#endif+#ifdef USE_CLEARCOAT_NORMALMAP+ vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;+#endif+#ifdef USE_CLEARCOAT_ROUGHNESSMAP+ vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;+#endif+#ifdef USE_IRIDESCENCEMAP+ vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;+#endif+#ifdef USE_IRIDESCENCE_THICKNESSMAP+ vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;+#endif+#ifdef USE_SHEEN_COLORMAP+ vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;+#endif+#ifdef USE_SHEEN_ROUGHNESSMAP+ vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;+#endif+#ifdef USE_SPECULARMAP+ vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;+#endif+#ifdef USE_SPECULAR_COLORMAP+ vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;+#endif+#ifdef USE_SPECULAR_INTENSITYMAP+ vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;+#endif+#ifdef USE_TRANSMISSIONMAP+ vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;+#endif+#ifdef USE_THICKNESSMAP+ vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;+#endif`, Zv = `#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0+ vec4 worldPosition = vec4( transformed, 1.0 );+ #ifdef USE_BATCHING+ worldPosition = batchingMatrix * worldPosition;+ #endif+ #ifdef USE_INSTANCING+ worldPosition = instanceMatrix * worldPosition;+ #endif+ worldPosition = modelMatrix * worldPosition;+#endif`;+const $v = `varying vec2 vUv;+uniform mat3 uvTransform;+void main() {+ vUv = ( uvTransform * vec3( uv, 1 ) ).xy;+ gl_Position = vec4( position.xy, 1.0, 1.0 );+}`, eC = `uniform sampler2D t2D;+uniform float backgroundIntensity;+varying vec2 vUv;+void main() {+ vec4 texColor = texture2D( t2D, vUv );+ #ifdef DECODE_VIDEO_TEXTURE+ texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );+ #endif+ texColor.rgb *= backgroundIntensity;+ gl_FragColor = texColor;+ #include <tonemapping_fragment>+ #include <colorspace_fragment>+}`, tC = `varying vec3 vWorldDirection;+#include <common>+void main() {+ vWorldDirection = transformDirection( position, modelMatrix );+ #include <begin_vertex>+ #include <project_vertex>+ gl_Position.z = gl_Position.w;+}`, nC = `#ifdef ENVMAP_TYPE_CUBE+ uniform samplerCube envMap;+#elif defined( ENVMAP_TYPE_CUBE_UV )+ uniform sampler2D envMap;+#endif+uniform float flipEnvMap;+uniform float backgroundBlurriness;+uniform float backgroundIntensity;+uniform mat3 backgroundRotation;+varying vec3 vWorldDirection;+#include <cube_uv_reflection_fragment>+void main() {+ #ifdef ENVMAP_TYPE_CUBE+ vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );+ #elif defined( ENVMAP_TYPE_CUBE_UV )+ vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );+ #else+ vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );+ #endif+ texColor.rgb *= backgroundIntensity;+ gl_FragColor = texColor;+ #include <tonemapping_fragment>+ #include <colorspace_fragment>+}`, iC = `varying vec3 vWorldDirection;+#include <common>+void main() {+ vWorldDirection = transformDirection( position, modelMatrix );+ #include <begin_vertex>+ #include <project_vertex>+ gl_Position.z = gl_Position.w;+}`, sC = `uniform samplerCube tCube;+uniform float tFlip;+uniform float opacity;+varying vec3 vWorldDirection;+void main() {+ vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );+ gl_FragColor = texColor;+ gl_FragColor.a *= opacity;+ #include <tonemapping_fragment>+ #include <colorspace_fragment>+}`, rC = `#include <common>+#include <batching_pars_vertex>+#include <uv_pars_vertex>+#include <displacementmap_pars_vertex>+#include <morphtarget_pars_vertex>+#include <skinning_pars_vertex>+#include <logdepthbuf_pars_vertex>+#include <clipping_planes_pars_vertex>+varying vec2 vHighPrecisionZW;+void main() {+ #include <uv_vertex>+ #include <batching_vertex>+ #include <skinbase_vertex>+ #include <morphinstance_vertex>+ #ifdef USE_DISPLACEMENTMAP+ #include <beginnormal_vertex>+ #include <morphnormal_vertex>+ #include <skinnormal_vertex>+ #endif+ #include <begin_vertex>+ #include <morphtarget_vertex>+ #include <skinning_vertex>+ #include <displacementmap_vertex>+ #include <project_vertex>+ #include <logdepthbuf_vertex>+ #include <clipping_planes_vertex>+ vHighPrecisionZW = gl_Position.zw;+}`, aC = `#if DEPTH_PACKING == 3200+ uniform float opacity;+#endif+#include <common>+#include <packing>+#include <uv_pars_fragment>+#include <map_pars_fragment>+#include <alphamap_pars_fragment>+#include <alphatest_pars_fragment>+#include <alphahash_pars_fragment>+#include <logdepthbuf_pars_fragment>+#include <clipping_planes_pars_fragment>+varying vec2 vHighPrecisionZW;+void main() {+ vec4 diffuseColor = vec4( 1.0 );+ #include <clipping_planes_fragment>+ #if DEPTH_PACKING == 3200+ diffuseColor.a = opacity;+ #endif+ #include <map_fragment>+ #include <alphamap_fragment>+ #include <alphatest_fragment>+ #include <alphahash_fragment>+ #include <logdepthbuf_fragment>+ float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;+ #if DEPTH_PACKING == 3200+ gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );+ #elif DEPTH_PACKING == 3201+ gl_FragColor = packDepthToRGBA( fragCoordZ );+ #elif DEPTH_PACKING == 3202+ gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );+ #elif DEPTH_PACKING == 3203+ gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );+ #endif+}`, oC = `#define DISTANCE+varying vec3 vWorldPosition;+#include <common>+#include <batching_pars_vertex>+#include <uv_pars_vertex>+#include <displacementmap_pars_vertex>+#include <morphtarget_pars_vertex>+#include <skinning_pars_vertex>+#include <clipping_planes_pars_vertex>+void main() {+ #include <uv_vertex>+ #include <batching_vertex>+ #include <skinbase_vertex>+ #include <morphinstance_vertex>+ #ifdef USE_DISPLACEMENTMAP+ #include <beginnormal_vertex>+ #include <morphnormal_vertex>+ #include <skinnormal_vertex>+ #endif+ #include <begin_vertex>+ #include <morphtarget_vertex>+ #include <skinning_vertex>+ #include <displacementmap_vertex>+ #include <project_vertex>+ #include <worldpos_vertex>+ #include <clipping_planes_vertex>+ vWorldPosition = worldPosition.xyz;+}`, cC = `#define DISTANCE+uniform vec3 referencePosition;+uniform float nearDistance;+uniform float farDistance;+varying vec3 vWorldPosition;+#include <common>+#include <packing>+#include <uv_pars_fragment>+#include <map_pars_fragment>+#include <alphamap_pars_fragment>+#include <alphatest_pars_fragment>+#include <alphahash_pars_fragment>+#include <clipping_planes_pars_fragment>+void main () {+ vec4 diffuseColor = vec4( 1.0 );+ #include <clipping_planes_fragment>+ #include <map_fragment>+ #include <alphamap_fragment>+ #include <alphatest_fragment>+ #include <alphahash_fragment>+ float dist = length( vWorldPosition - referencePosition );+ dist = ( dist - nearDistance ) / ( farDistance - nearDistance );+ dist = saturate( dist );+ gl_FragColor = packDepthToRGBA( dist );+}`, lC = `varying vec3 vWorldDirection;+#include <common>+void main() {+ vWorldDirection = transformDirection( position, modelMatrix );+ #include <begin_vertex>+ #include <project_vertex>+}`, hC = `uniform sampler2D tEquirect;+varying vec3 vWorldDirection;+#include <common>+void main() {+ vec3 direction = normalize( vWorldDirection );+ vec2 sampleUV = equirectUv( direction );+ gl_FragColor = texture2D( tEquirect, sampleUV );+ #include <tonemapping_fragment>+ #include <colorspace_fragment>+}`, uC = `uniform float scale;+attribute float lineDistance;+varying float vLineDistance;+#include <common>+#include <uv_pars_vertex>+#include <color_pars_vertex>+#include <fog_pars_vertex>+#include <morphtarget_pars_vertex>+#include <logdepthbuf_pars_vertex>+#include <clipping_planes_pars_vertex>+void main() {+ vLineDistance = scale * lineDistance;+ #include <uv_vertex>+ #include <color_vertex>+ #include <morphinstance_vertex>+ #include <morphcolor_vertex>+ #include <begin_vertex>+ #include <morphtarget_vertex>+ #include <project_vertex>+ #include <logdepthbuf_vertex>+ #include <clipping_planes_vertex>+ #include <fog_vertex>+}`, dC = `uniform vec3 diffuse;+uniform float opacity;+uniform float dashSize;+uniform float totalSize;+varying float vLineDistance;+#include <common>+#include <color_pars_fragment>+#include <uv_pars_fragment>+#include <map_pars_fragment>+#include <fog_pars_fragment>+#include <logdepthbuf_pars_fragment>+#include <clipping_planes_pars_fragment>+void main() {+ vec4 diffuseColor = vec4( diffuse, opacity );+ #include <clipping_planes_fragment>+ if ( mod( vLineDistance, totalSize ) > dashSize ) {+ discard;+ }+ vec3 outgoingLight = vec3( 0.0 );+ #include <logdepthbuf_fragment>+ #include <map_fragment>+ #include <color_fragment>+ outgoingLight = diffuseColor.rgb;+ #include <opaque_fragment>+ #include <tonemapping_fragment>+ #include <colorspace_fragment>+ #include <fog_fragment>+ #include <premultiplied_alpha_fragment>+}`, fC = `#include <common>+#include <batching_pars_vertex>+#include <uv_pars_vertex>+#include <envmap_pars_vertex>+#include <color_pars_vertex>+#include <fog_pars_vertex>+#include <morphtarget_pars_vertex>+#include <skinning_pars_vertex>+#include <logdepthbuf_pars_vertex>+#include <clipping_planes_pars_vertex>+void main() {+ #include <uv_vertex>+ #include <color_vertex>+ #include <morphinstance_vertex>+ #include <morphcolor_vertex>+ #include <batching_vertex>+ #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )+ #include <beginnormal_vertex>+ #include <morphnormal_vertex>+ #include <skinbase_vertex>+ #include <skinnormal_vertex>+ #include <defaultnormal_vertex>+ #endif+ #include <begin_vertex>+ #include <morphtarget_vertex>+ #include <skinning_vertex>+ #include <project_vertex>+ #include <logdepthbuf_vertex>+ #include <clipping_planes_vertex>+ #include <worldpos_vertex>+ #include <envmap_vertex>+ #include <fog_vertex>+}`, pC = `uniform vec3 diffuse;+uniform float opacity;+#ifndef FLAT_SHADED+ varying vec3 vNormal;+#endif+#include <common>+#include <dithering_pars_fragment>+#include <color_pars_fragment>+#include <uv_pars_fragment>+#include <map_pars_fragment>+#include <alphamap_pars_fragment>+#include <alphatest_pars_fragment>+#include <alphahash_pars_fragment>+#include <aomap_pars_fragment>+#include <lightmap_pars_fragment>+#include <envmap_common_pars_fragment>+#include <envmap_pars_fragment>+#include <fog_pars_fragment>+#include <specularmap_pars_fragment>+#include <logdepthbuf_pars_fragment>+#include <clipping_planes_pars_fragment>+void main() {+ vec4 diffuseColor = vec4( diffuse, opacity );+ #include <clipping_planes_fragment>+ #include <logdepthbuf_fragment>+ #include <map_fragment>+ #include <color_fragment>+ #include <alphamap_fragment>+ #include <alphatest_fragment>+ #include <alphahash_fragment>+ #include <specularmap_fragment>+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );+ #ifdef USE_LIGHTMAP+ vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );+ reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;+ #else+ reflectedLight.indirectDiffuse += vec3( 1.0 );+ #endif+ #include <aomap_fragment>+ reflectedLight.indirectDiffuse *= diffuseColor.rgb;+ vec3 outgoingLight = reflectedLight.indirectDiffuse;+ #include <envmap_fragment>+ #include <opaque_fragment>+ #include <tonemapping_fragment>+ #include <colorspace_fragment>+ #include <fog_fragment>+ #include <premultiplied_alpha_fragment>+ #include <dithering_fragment>+}`, AC = `#define LAMBERT+varying vec3 vViewPosition;+#include <common>+#include <batching_pars_vertex>+#include <uv_pars_vertex>+#include <displacementmap_pars_vertex>+#include <envmap_pars_vertex>+#include <color_pars_vertex>+#include <fog_pars_vertex>+#include <normal_pars_vertex>+#include <morphtarget_pars_vertex>+#include <skinning_pars_vertex>+#include <shadowmap_pars_vertex>+#include <logdepthbuf_pars_vertex>+#include <clipping_planes_pars_vertex>+void main() {+ #include <uv_vertex>+ #include <color_vertex>+ #include <morphinstance_vertex>+ #include <morphcolor_vertex>+ #include <batching_vertex>+ #include <beginnormal_vertex>+ #include <morphnormal_vertex>+ #include <skinbase_vertex>+ #include <skinnormal_vertex>+ #include <defaultnormal_vertex>+ #include <normal_vertex>+ #include <begin_vertex>+ #include <morphtarget_vertex>+ #include <skinning_vertex>+ #include <displacementmap_vertex>+ #include <project_vertex>+ #include <logdepthbuf_vertex>+ #include <clipping_planes_vertex>+ vViewPosition = - mvPosition.xyz;+ #include <worldpos_vertex>+ #include <envmap_vertex>+ #include <shadowmap_vertex>+ #include <fog_vertex>+}`, gC = `#define LAMBERT+uniform vec3 diffuse;+uniform vec3 emissive;+uniform float opacity;+#include <common>+#include <packing>+#include <dithering_pars_fragment>+#include <color_pars_fragment>+#include <uv_pars_fragment>+#include <map_pars_fragment>+#include <alphamap_pars_fragment>+#include <alphatest_pars_fragment>+#include <alphahash_pars_fragment>+#include <aomap_pars_fragment>+#include <lightmap_pars_fragment>+#include <emissivemap_pars_fragment>+#include <envmap_common_pars_fragment>+#include <envmap_pars_fragment>+#include <fog_pars_fragment>+#include <bsdfs>+#include <lights_pars_begin>+#include <normal_pars_fragment>+#include <lights_lambert_pars_fragment>+#include <shadowmap_pars_fragment>+#include <bumpmap_pars_fragment>+#include <normalmap_pars_fragment>+#include <specularmap_pars_fragment>+#include <logdepthbuf_pars_fragment>+#include <clipping_planes_pars_fragment>+void main() {+ vec4 diffuseColor = vec4( diffuse, opacity );+ #include <clipping_planes_fragment>+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );+ vec3 totalEmissiveRadiance = emissive;+ #include <logdepthbuf_fragment>+ #include <map_fragment>+ #include <color_fragment>+ #include <alphamap_fragment>+ #include <alphatest_fragment>+ #include <alphahash_fragment>+ #include <specularmap_fragment>+ #include <normal_fragment_begin>+ #include <normal_fragment_maps>+ #include <emissivemap_fragment>+ #include <lights_lambert_fragment>+ #include <lights_fragment_begin>+ #include <lights_fragment_maps>+ #include <lights_fragment_end>+ #include <aomap_fragment>+ vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;+ #include <envmap_fragment>+ #include <opaque_fragment>+ #include <tonemapping_fragment>+ #include <colorspace_fragment>+ #include <fog_fragment>+ #include <premultiplied_alpha_fragment>+ #include <dithering_fragment>+}`, mC = `#define MATCAP+varying vec3 vViewPosition;+#include <common>+#include <batching_pars_vertex>+#include <uv_pars_vertex>+#include <color_pars_vertex>+#include <displacementmap_pars_vertex>+#include <fog_pars_vertex>+#include <normal_pars_vertex>+#include <morphtarget_pars_vertex>+#include <skinning_pars_vertex>+#include <logdepthbuf_pars_vertex>+#include <clipping_planes_pars_vertex>+void main() {+ #include <uv_vertex>+ #include <color_vertex>+ #include <morphinstance_vertex>+ #include <morphcolor_vertex>+ #include <batching_vertex>+ #include <beginnormal_vertex>+ #include <morphnormal_vertex>+ #include <skinbase_vertex>+ #include <skinnormal_vertex>+ #include <defaultnormal_vertex>+ #include <normal_vertex>+ #include <begin_vertex>+ #include <morphtarget_vertex>+ #include <skinning_vertex>+ #include <displacementmap_vertex>+ #include <project_vertex>+ #include <logdepthbuf_vertex>+ #include <clipping_planes_vertex>+ #include <fog_vertex>+ vViewPosition = - mvPosition.xyz;+}`, bC = `#define MATCAP+uniform vec3 diffuse;+uniform float opacity;+uniform sampler2D matcap;+varying vec3 vViewPosition;+#include <common>+#include <dithering_pars_fragment>+#include <color_pars_fragment>+#include <uv_pars_fragment>+#include <map_pars_fragment>+#include <alphamap_pars_fragment>+#include <alphatest_pars_fragment>+#include <alphahash_pars_fragment>+#include <fog_pars_fragment>+#include <normal_pars_fragment>+#include <bumpmap_pars_fragment>+#include <normalmap_pars_fragment>+#include <logdepthbuf_pars_fragment>+#include <clipping_planes_pars_fragment>+void main() {+ vec4 diffuseColor = vec4( diffuse, opacity );+ #include <clipping_planes_fragment>+ #include <logdepthbuf_fragment>+ #include <map_fragment>+ #include <color_fragment>+ #include <alphamap_fragment>+ #include <alphatest_fragment>+ #include <alphahash_fragment>+ #include <normal_fragment_begin>+ #include <normal_fragment_maps>+ vec3 viewDir = normalize( vViewPosition );+ vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );+ vec3 y = cross( viewDir, x );+ vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;+ #ifdef USE_MATCAP+ vec4 matcapColor = texture2D( matcap, uv );+ #else+ vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );+ #endif+ vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;+ #include <opaque_fragment>+ #include <tonemapping_fragment>+ #include <colorspace_fragment>+ #include <fog_fragment>+ #include <premultiplied_alpha_fragment>+ #include <dithering_fragment>+}`, xC = `#define NORMAL+#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )+ varying vec3 vViewPosition;+#endif+#include <common>+#include <batching_pars_vertex>+#include <uv_pars_vertex>+#include <displacementmap_pars_vertex>+#include <normal_pars_vertex>+#include <morphtarget_pars_vertex>+#include <skinning_pars_vertex>+#include <logdepthbuf_pars_vertex>+#include <clipping_planes_pars_vertex>+void main() {+ #include <uv_vertex>+ #include <batching_vertex>+ #include <beginnormal_vertex>+ #include <morphinstance_vertex>+ #include <morphnormal_vertex>+ #include <skinbase_vertex>+ #include <skinnormal_vertex>+ #include <defaultnormal_vertex>+ #include <normal_vertex>+ #include <begin_vertex>+ #include <morphtarget_vertex>+ #include <skinning_vertex>+ #include <displacementmap_vertex>+ #include <project_vertex>+ #include <logdepthbuf_vertex>+ #include <clipping_planes_vertex>+#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )+ vViewPosition = - mvPosition.xyz;+#endif+}`, _C = `#define NORMAL+uniform float opacity;+#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )+ varying vec3 vViewPosition;+#endif+#include <packing>+#include <uv_pars_fragment>+#include <normal_pars_fragment>+#include <bumpmap_pars_fragment>+#include <normalmap_pars_fragment>+#include <logdepthbuf_pars_fragment>+#include <clipping_planes_pars_fragment>+void main() {+ vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );+ #include <clipping_planes_fragment>+ #include <logdepthbuf_fragment>+ #include <normal_fragment_begin>+ #include <normal_fragment_maps>+ gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );+ #ifdef OPAQUE+ gl_FragColor.a = 1.0;+ #endif+}`, EC = `#define PHONG+varying vec3 vViewPosition;+#include <common>+#include <batching_pars_vertex>+#include <uv_pars_vertex>+#include <displacementmap_pars_vertex>+#include <envmap_pars_vertex>+#include <color_pars_vertex>+#include <fog_pars_vertex>+#include <normal_pars_vertex>+#include <morphtarget_pars_vertex>+#include <skinning_pars_vertex>+#include <shadowmap_pars_vertex>+#include <logdepthbuf_pars_vertex>+#include <clipping_planes_pars_vertex>+void main() {+ #include <uv_vertex>+ #include <color_vertex>+ #include <morphcolor_vertex>+ #include <batching_vertex>+ #include <beginnormal_vertex>+ #include <morphinstance_vertex>+ #include <morphnormal_vertex>+ #include <skinbase_vertex>+ #include <skinnormal_vertex>+ #include <defaultnormal_vertex>+ #include <normal_vertex>+ #include <begin_vertex>+ #include <morphtarget_vertex>+ #include <skinning_vertex>+ #include <displacementmap_vertex>+ #include <project_vertex>+ #include <logdepthbuf_vertex>+ #include <clipping_planes_vertex>+ vViewPosition = - mvPosition.xyz;+ #include <worldpos_vertex>+ #include <envmap_vertex>+ #include <shadowmap_vertex>+ #include <fog_vertex>+}`, yC = `#define PHONG+uniform vec3 diffuse;+uniform vec3 emissive;+uniform vec3 specular;+uniform float shininess;+uniform float opacity;+#include <common>+#include <packing>+#include <dithering_pars_fragment>+#include <color_pars_fragment>+#include <uv_pars_fragment>+#include <map_pars_fragment>+#include <alphamap_pars_fragment>+#include <alphatest_pars_fragment>+#include <alphahash_pars_fragment>+#include <aomap_pars_fragment>+#include <lightmap_pars_fragment>+#include <emissivemap_pars_fragment>+#include <envmap_common_pars_fragment>+#include <envmap_pars_fragment>+#include <fog_pars_fragment>+#include <bsdfs>+#include <lights_pars_begin>+#include <normal_pars_fragment>+#include <lights_phong_pars_fragment>+#include <shadowmap_pars_fragment>+#include <bumpmap_pars_fragment>+#include <normalmap_pars_fragment>+#include <specularmap_pars_fragment>+#include <logdepthbuf_pars_fragment>+#include <clipping_planes_pars_fragment>+void main() {+ vec4 diffuseColor = vec4( diffuse, opacity );+ #include <clipping_planes_fragment>+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );+ vec3 totalEmissiveRadiance = emissive;+ #include <logdepthbuf_fragment>+ #include <map_fragment>+ #include <color_fragment>+ #include <alphamap_fragment>+ #include <alphatest_fragment>+ #include <alphahash_fragment>+ #include <specularmap_fragment>+ #include <normal_fragment_begin>+ #include <normal_fragment_maps>+ #include <emissivemap_fragment>+ #include <lights_phong_fragment>+ #include <lights_fragment_begin>+ #include <lights_fragment_maps>+ #include <lights_fragment_end>+ #include <aomap_fragment>+ vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;+ #include <envmap_fragment>+ #include <opaque_fragment>+ #include <tonemapping_fragment>+ #include <colorspace_fragment>+ #include <fog_fragment>+ #include <premultiplied_alpha_fragment>+ #include <dithering_fragment>+}`, wC = `#define STANDARD+varying vec3 vViewPosition;+#ifdef USE_TRANSMISSION+ varying vec3 vWorldPosition;+#endif+#include <common>+#include <batching_pars_vertex>+#include <uv_pars_vertex>+#include <displacementmap_pars_vertex>+#include <color_pars_vertex>+#include <fog_pars_vertex>+#include <normal_pars_vertex>+#include <morphtarget_pars_vertex>+#include <skinning_pars_vertex>+#include <shadowmap_pars_vertex>+#include <logdepthbuf_pars_vertex>+#include <clipping_planes_pars_vertex>+void main() {+ #include <uv_vertex>+ #include <color_vertex>+ #include <morphinstance_vertex>+ #include <morphcolor_vertex>+ #include <batching_vertex>+ #include <beginnormal_vertex>+ #include <morphnormal_vertex>+ #include <skinbase_vertex>+ #include <skinnormal_vertex>+ #include <defaultnormal_vertex>+ #include <normal_vertex>+ #include <begin_vertex>+ #include <morphtarget_vertex>+ #include <skinning_vertex>+ #include <displacementmap_vertex>+ #include <project_vertex>+ #include <logdepthbuf_vertex>+ #include <clipping_planes_vertex>+ vViewPosition = - mvPosition.xyz;+ #include <worldpos_vertex>+ #include <shadowmap_vertex>+ #include <fog_vertex>+#ifdef USE_TRANSMISSION+ vWorldPosition = worldPosition.xyz;+#endif+}`, vC = `#define STANDARD+#ifdef PHYSICAL+ #define IOR+ #define USE_SPECULAR+#endif+uniform vec3 diffuse;+uniform vec3 emissive;+uniform float roughness;+uniform float metalness;+uniform float opacity;+#ifdef IOR+ uniform float ior;+#endif+#ifdef USE_SPECULAR+ uniform float specularIntensity;+ uniform vec3 specularColor;+ #ifdef USE_SPECULAR_COLORMAP+ uniform sampler2D specularColorMap;+ #endif+ #ifdef USE_SPECULAR_INTENSITYMAP+ uniform sampler2D specularIntensityMap;+ #endif+#endif+#ifdef USE_CLEARCOAT+ uniform float clearcoat;+ uniform float clearcoatRoughness;+#endif+#ifdef USE_DISPERSION+ uniform float dispersion;+#endif+#ifdef USE_IRIDESCENCE+ uniform float iridescence;+ uniform float iridescenceIOR;+ uniform float iridescenceThicknessMinimum;+ uniform float iridescenceThicknessMaximum;+#endif+#ifdef USE_SHEEN+ uniform vec3 sheenColor;+ uniform float sheenRoughness;+ #ifdef USE_SHEEN_COLORMAP+ uniform sampler2D sheenColorMap;+ #endif+ #ifdef USE_SHEEN_ROUGHNESSMAP+ uniform sampler2D sheenRoughnessMap;+ #endif+#endif+#ifdef USE_ANISOTROPY+ uniform vec2 anisotropyVector;+ #ifdef USE_ANISOTROPYMAP+ uniform sampler2D anisotropyMap;+ #endif+#endif+varying vec3 vViewPosition;+#include <common>+#include <packing>+#include <dithering_pars_fragment>+#include <color_pars_fragment>+#include <uv_pars_fragment>+#include <map_pars_fragment>+#include <alphamap_pars_fragment>+#include <alphatest_pars_fragment>+#include <alphahash_pars_fragment>+#include <aomap_pars_fragment>+#include <lightmap_pars_fragment>+#include <emissivemap_pars_fragment>+#include <iridescence_fragment>+#include <cube_uv_reflection_fragment>+#include <envmap_common_pars_fragment>+#include <envmap_physical_pars_fragment>+#include <fog_pars_fragment>+#include <lights_pars_begin>+#include <normal_pars_fragment>+#include <lights_physical_pars_fragment>+#include <transmission_pars_fragment>+#include <shadowmap_pars_fragment>+#include <bumpmap_pars_fragment>+#include <normalmap_pars_fragment>+#include <clearcoat_pars_fragment>+#include <iridescence_pars_fragment>+#include <roughnessmap_pars_fragment>+#include <metalnessmap_pars_fragment>+#include <logdepthbuf_pars_fragment>+#include <clipping_planes_pars_fragment>+void main() {+ vec4 diffuseColor = vec4( diffuse, opacity );+ #include <clipping_planes_fragment>+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );+ vec3 totalEmissiveRadiance = emissive;+ #include <logdepthbuf_fragment>+ #include <map_fragment>+ #include <color_fragment>+ #include <alphamap_fragment>+ #include <alphatest_fragment>+ #include <alphahash_fragment>+ #include <roughnessmap_fragment>+ #include <metalnessmap_fragment>+ #include <normal_fragment_begin>+ #include <normal_fragment_maps>+ #include <clearcoat_normal_fragment_begin>+ #include <clearcoat_normal_fragment_maps>+ #include <emissivemap_fragment>+ #include <lights_physical_fragment>+ #include <lights_fragment_begin>+ #include <lights_fragment_maps>+ #include <lights_fragment_end>+ #include <aomap_fragment>+ vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;+ vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;+ #include <transmission_fragment>+ vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;+ #ifdef USE_SHEEN+ float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );+ outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;+ #endif+ #ifdef USE_CLEARCOAT+ float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );+ vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );+ outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;+ #endif+ #include <opaque_fragment>+ #include <tonemapping_fragment>+ #include <colorspace_fragment>+ #include <fog_fragment>+ #include <premultiplied_alpha_fragment>+ #include <dithering_fragment>+}`, CC = `#define TOON+varying vec3 vViewPosition;+#include <common>+#include <batching_pars_vertex>+#include <uv_pars_vertex>+#include <displacementmap_pars_vertex>+#include <color_pars_vertex>+#include <fog_pars_vertex>+#include <normal_pars_vertex>+#include <morphtarget_pars_vertex>+#include <skinning_pars_vertex>+#include <shadowmap_pars_vertex>+#include <logdepthbuf_pars_vertex>+#include <clipping_planes_pars_vertex>+void main() {+ #include <uv_vertex>+ #include <color_vertex>+ #include <morphinstance_vertex>+ #include <morphcolor_vertex>+ #include <batching_vertex>+ #include <beginnormal_vertex>+ #include <morphnormal_vertex>+ #include <skinbase_vertex>+ #include <skinnormal_vertex>+ #include <defaultnormal_vertex>+ #include <normal_vertex>+ #include <begin_vertex>+ #include <morphtarget_vertex>+ #include <skinning_vertex>+ #include <displacementmap_vertex>+ #include <project_vertex>+ #include <logdepthbuf_vertex>+ #include <clipping_planes_vertex>+ vViewPosition = - mvPosition.xyz;+ #include <worldpos_vertex>+ #include <shadowmap_vertex>+ #include <fog_vertex>+}`, SC = `#define TOON+uniform vec3 diffuse;+uniform vec3 emissive;+uniform float opacity;+#include <common>+#include <packing>+#include <dithering_pars_fragment>+#include <color_pars_fragment>+#include <uv_pars_fragment>+#include <map_pars_fragment>+#include <alphamap_pars_fragment>+#include <alphatest_pars_fragment>+#include <alphahash_pars_fragment>+#include <aomap_pars_fragment>+#include <lightmap_pars_fragment>+#include <emissivemap_pars_fragment>+#include <gradientmap_pars_fragment>+#include <fog_pars_fragment>+#include <bsdfs>+#include <lights_pars_begin>+#include <normal_pars_fragment>+#include <lights_toon_pars_fragment>+#include <shadowmap_pars_fragment>+#include <bumpmap_pars_fragment>+#include <normalmap_pars_fragment>+#include <logdepthbuf_pars_fragment>+#include <clipping_planes_pars_fragment>+void main() {+ vec4 diffuseColor = vec4( diffuse, opacity );+ #include <clipping_planes_fragment>+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );+ vec3 totalEmissiveRadiance = emissive;+ #include <logdepthbuf_fragment>+ #include <map_fragment>+ #include <color_fragment>+ #include <alphamap_fragment>+ #include <alphatest_fragment>+ #include <alphahash_fragment>+ #include <normal_fragment_begin>+ #include <normal_fragment_maps>+ #include <emissivemap_fragment>+ #include <lights_toon_fragment>+ #include <lights_fragment_begin>+ #include <lights_fragment_maps>+ #include <lights_fragment_end>+ #include <aomap_fragment>+ vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;+ #include <opaque_fragment>+ #include <tonemapping_fragment>+ #include <colorspace_fragment>+ #include <fog_fragment>+ #include <premultiplied_alpha_fragment>+ #include <dithering_fragment>+}`, IC = `uniform float size;+uniform float scale;+#include <common>+#include <color_pars_vertex>+#include <fog_pars_vertex>+#include <morphtarget_pars_vertex>+#include <logdepthbuf_pars_vertex>+#include <clipping_planes_pars_vertex>+#ifdef USE_POINTS_UV+ varying vec2 vUv;+ uniform mat3 uvTransform;+#endif+void main() {+ #ifdef USE_POINTS_UV+ vUv = ( uvTransform * vec3( uv, 1 ) ).xy;+ #endif+ #include <color_vertex>+ #include <morphinstance_vertex>+ #include <morphcolor_vertex>+ #include <begin_vertex>+ #include <morphtarget_vertex>+ #include <project_vertex>+ gl_PointSize = size;+ #ifdef USE_SIZEATTENUATION+ bool isPerspective = isPerspectiveMatrix( projectionMatrix );+ if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );+ #endif+ #include <logdepthbuf_vertex>+ #include <clipping_planes_vertex>+ #include <worldpos_vertex>+ #include <fog_vertex>+}`, MC = `uniform vec3 diffuse;+uniform float opacity;+#include <common>+#include <color_pars_fragment>+#include <map_particle_pars_fragment>+#include <alphatest_pars_fragment>+#include <alphahash_pars_fragment>+#include <fog_pars_fragment>+#include <logdepthbuf_pars_fragment>+#include <clipping_planes_pars_fragment>+void main() {+ vec4 diffuseColor = vec4( diffuse, opacity );+ #include <clipping_planes_fragment>+ vec3 outgoingLight = vec3( 0.0 );+ #include <logdepthbuf_fragment>+ #include <map_particle_fragment>+ #include <color_fragment>+ #include <alphatest_fragment>+ #include <alphahash_fragment>+ outgoingLight = diffuseColor.rgb;+ #include <opaque_fragment>+ #include <tonemapping_fragment>+ #include <colorspace_fragment>+ #include <fog_fragment>+ #include <premultiplied_alpha_fragment>+}`, BC = `#include <common>+#include <batching_pars_vertex>+#include <fog_pars_vertex>+#include <morphtarget_pars_vertex>+#include <skinning_pars_vertex>+#include <logdepthbuf_pars_vertex>+#include <shadowmap_pars_vertex>+void main() {+ #include <batching_vertex>+ #include <beginnormal_vertex>+ #include <morphinstance_vertex>+ #include <morphnormal_vertex>+ #include <skinbase_vertex>+ #include <skinnormal_vertex>+ #include <defaultnormal_vertex>+ #include <begin_vertex>+ #include <morphtarget_vertex>+ #include <skinning_vertex>+ #include <project_vertex>+ #include <logdepthbuf_vertex>+ #include <worldpos_vertex>+ #include <shadowmap_vertex>+ #include <fog_vertex>+}`, TC = `uniform vec3 color;+uniform float opacity;+#include <common>+#include <packing>+#include <fog_pars_fragment>+#include <bsdfs>+#include <lights_pars_begin>+#include <logdepthbuf_pars_fragment>+#include <shadowmap_pars_fragment>+#include <shadowmask_pars_fragment>+void main() {+ #include <logdepthbuf_fragment>+ gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );+ #include <tonemapping_fragment>+ #include <colorspace_fragment>+ #include <fog_fragment>+}`, RC = `uniform float rotation;+uniform vec2 center;+#include <common>+#include <uv_pars_vertex>+#include <fog_pars_vertex>+#include <logdepthbuf_pars_vertex>+#include <clipping_planes_pars_vertex>+void main() {+ #include <uv_vertex>+ vec4 mvPosition = modelViewMatrix[ 3 ];+ vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );+ #ifndef USE_SIZEATTENUATION+ bool isPerspective = isPerspectiveMatrix( projectionMatrix );+ if ( isPerspective ) scale *= - mvPosition.z;+ #endif+ vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;+ vec2 rotatedPosition;+ rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;+ rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;+ mvPosition.xy += rotatedPosition;+ gl_Position = projectionMatrix * mvPosition;+ #include <logdepthbuf_vertex>+ #include <clipping_planes_vertex>+ #include <fog_vertex>+}`, NC = `uniform vec3 diffuse;+uniform float opacity;+#include <common>+#include <uv_pars_fragment>+#include <map_pars_fragment>+#include <alphamap_pars_fragment>+#include <alphatest_pars_fragment>+#include <alphahash_pars_fragment>+#include <fog_pars_fragment>+#include <logdepthbuf_pars_fragment>+#include <clipping_planes_pars_fragment>+void main() {+ vec4 diffuseColor = vec4( diffuse, opacity );+ #include <clipping_planes_fragment>+ vec3 outgoingLight = vec3( 0.0 );+ #include <logdepthbuf_fragment>+ #include <map_fragment>+ #include <alphamap_fragment>+ #include <alphatest_fragment>+ #include <alphahash_fragment>+ outgoingLight = diffuseColor.rgb;+ #include <opaque_fragment>+ #include <tonemapping_fragment>+ #include <colorspace_fragment>+ #include <fog_fragment>+}`, ot = {+ alphahash_fragment: ew,+ alphahash_pars_fragment: tw,+ alphamap_fragment: nw,+ alphamap_pars_fragment: iw,+ alphatest_fragment: sw,+ alphatest_pars_fragment: rw,+ aomap_fragment: aw,+ aomap_pars_fragment: ow,+ batching_pars_vertex: cw,+ batching_vertex: lw,+ begin_vertex: hw,+ beginnormal_vertex: uw,+ bsdfs: dw,+ iridescence_fragment: fw,+ bumpmap_pars_fragment: pw,+ clipping_planes_fragment: Aw,+ clipping_planes_pars_fragment: gw,+ clipping_planes_pars_vertex: mw,+ clipping_planes_vertex: bw,+ color_fragment: xw,+ color_pars_fragment: _w,+ color_pars_vertex: Ew,+ color_vertex: yw,+ common: ww,+ cube_uv_reflection_fragment: vw,+ defaultnormal_vertex: Cw,+ displacementmap_pars_vertex: Sw,+ displacementmap_vertex: Iw,+ emissivemap_fragment: Mw,+ emissivemap_pars_fragment: Bw,+ colorspace_fragment: Tw,+ colorspace_pars_fragment: Rw,+ envmap_fragment: Nw,+ envmap_common_pars_fragment: Fw,+ envmap_pars_fragment: Dw,+ envmap_pars_vertex: Lw,+ envmap_physical_pars_fragment: qw,+ envmap_vertex: Pw,+ fog_vertex: kw,+ fog_pars_vertex: Uw,+ fog_fragment: Ow,+ fog_pars_fragment: Qw,+ gradientmap_pars_fragment: Gw,+ lightmap_pars_fragment: Hw,+ lights_lambert_fragment: zw,+ lights_lambert_pars_fragment: Vw,+ lights_pars_begin: Ww,+ lights_toon_fragment: Kw,+ lights_toon_pars_fragment: jw,+ lights_phong_fragment: Xw,+ lights_phong_pars_fragment: Yw,+ lights_physical_fragment: Jw,+ lights_physical_pars_fragment: Zw,+ lights_fragment_begin: $w,+ lights_fragment_maps: ev,+ lights_fragment_end: tv,+ logdepthbuf_fragment: nv,+ logdepthbuf_pars_fragment: iv,+ logdepthbuf_pars_vertex: sv,+ logdepthbuf_vertex: rv,+ map_fragment: av,+ map_pars_fragment: ov,+ map_particle_fragment: cv,+ map_particle_pars_fragment: lv,+ metalnessmap_fragment: hv,+ metalnessmap_pars_fragment: uv,+ morphinstance_vertex: dv,+ morphcolor_vertex: fv,+ morphnormal_vertex: pv,+ morphtarget_pars_vertex: Av,+ morphtarget_vertex: gv,+ normal_fragment_begin: mv,+ normal_fragment_maps: bv,+ normal_pars_fragment: xv,+ normal_pars_vertex: _v,+ normal_vertex: Ev,+ normalmap_pars_fragment: yv,+ clearcoat_normal_fragment_begin: wv,+ clearcoat_normal_fragment_maps: vv,+ clearcoat_pars_fragment: Cv,+ iridescence_pars_fragment: Sv,+ opaque_fragment: Iv,+ packing: Mv,+ premultiplied_alpha_fragment: Bv,+ project_vertex: Tv,+ dithering_fragment: Rv,+ dithering_pars_fragment: Nv,+ roughnessmap_fragment: Fv,+ roughnessmap_pars_fragment: Dv,+ shadowmap_pars_fragment: Lv,+ shadowmap_pars_vertex: Pv,+ shadowmap_vertex: kv,+ shadowmask_pars_fragment: Uv,+ skinbase_vertex: Ov,+ skinning_pars_vertex: Qv,+ skinning_vertex: Gv,+ skinnormal_vertex: Hv,+ specularmap_fragment: zv,+ specularmap_pars_fragment: Vv,+ tonemapping_fragment: Wv,+ tonemapping_pars_fragment: qv,+ transmission_fragment: Kv,+ transmission_pars_fragment: jv,+ uv_pars_fragment: Xv,+ uv_pars_vertex: Yv,+ uv_vertex: Jv,+ worldpos_vertex: Zv,+ background_vert: $v,+ background_frag: eC,+ backgroundCube_vert: tC,+ backgroundCube_frag: nC,+ cube_vert: iC,+ cube_frag: sC,+ depth_vert: rC,+ depth_frag: aC,+ distanceRGBA_vert: oC,+ distanceRGBA_frag: cC,+ equirect_vert: lC,+ equirect_frag: hC,+ linedashed_vert: uC,+ linedashed_frag: dC,+ meshbasic_vert: fC,+ meshbasic_frag: pC,+ meshlambert_vert: AC,+ meshlambert_frag: gC,+ meshmatcap_vert: mC,+ meshmatcap_frag: bC,+ meshnormal_vert: xC,+ meshnormal_frag: _C,+ meshphong_vert: EC,+ meshphong_frag: yC,+ meshphysical_vert: wC,+ meshphysical_frag: vC,+ meshtoon_vert: CC,+ meshtoon_frag: SC,+ points_vert: IC,+ points_frag: MC,+ shadow_vert: BC,+ shadow_frag: TC,+ sprite_vert: RC,+ sprite_frag: NC+}, we = {+ common: {+ diffuse: { value: /* @__PURE__ */ new je(16777215) },+ opacity: { value: 1 },+ map: { value: null },+ mapTransform: { value: /* @__PURE__ */ new rt() },+ alphaMap: { value: null },+ alphaMapTransform: { value: /* @__PURE__ */ new rt() },+ alphaTest: { value: 0 }+ },+ specularmap: {+ specularMap: { value: null },+ specularMapTransform: { value: /* @__PURE__ */ new rt() }+ },+ envmap: {+ envMap: { value: null },+ envMapRotation: { value: /* @__PURE__ */ new rt() },+ flipEnvMap: { value: -1 },+ reflectivity: { value: 1 },+ // basic, lambert, phong+ ior: { value: 1.5 },+ // physical+ refractionRatio: { value: 0.98 }+ // basic, lambert, phong+ },+ aomap: {+ aoMap: { value: null },+ aoMapIntensity: { value: 1 },+ aoMapTransform: { value: /* @__PURE__ */ new rt() }+ },+ lightmap: {+ lightMap: { value: null },+ lightMapIntensity: { value: 1 },+ lightMapTransform: { value: /* @__PURE__ */ new rt() }+ },+ bumpmap: {+ bumpMap: { value: null },+ bumpMapTransform: { value: /* @__PURE__ */ new rt() },+ bumpScale: { value: 1 }+ },+ normalmap: {+ normalMap: { value: null },+ normalMapTransform: { value: /* @__PURE__ */ new rt() },+ normalScale: { value: /* @__PURE__ */ new Ze(1, 1) }+ },+ displacementmap: {+ displacementMap: { value: null },+ displacementMapTransform: { value: /* @__PURE__ */ new rt() },+ displacementScale: { value: 1 },+ displacementBias: { value: 0 }+ },+ emissivemap: {+ emissiveMap: { value: null },+ emissiveMapTransform: { value: /* @__PURE__ */ new rt() }+ },+ metalnessmap: {+ metalnessMap: { value: null },+ metalnessMapTransform: { value: /* @__PURE__ */ new rt() }+ },+ roughnessmap: {+ roughnessMap: { value: null },+ roughnessMapTransform: { value: /* @__PURE__ */ new rt() }+ },+ gradientmap: {+ gradientMap: { value: null }+ },+ fog: {+ fogDensity: { value: 25e-5 },+ fogNear: { value: 1 },+ fogFar: { value: 2e3 },+ fogColor: { value: /* @__PURE__ */ new je(16777215) }+ },+ lights: {+ ambientLightColor: { value: [] },+ lightProbe: { value: [] },+ directionalLights: { value: [], properties: {+ direction: {},+ color: {}+ } },+ directionalLightShadows: { value: [], properties: {+ shadowIntensity: 1,+ shadowBias: {},+ shadowNormalBias: {},+ shadowRadius: {},+ shadowMapSize: {}+ } },+ directionalShadowMap: { value: [] },+ directionalShadowMatrix: { value: [] },+ spotLights: { value: [], properties: {+ color: {},+ position: {},+ direction: {},+ distance: {},+ coneCos: {},+ penumbraCos: {},+ decay: {}+ } },+ spotLightShadows: { value: [], properties: {+ shadowIntensity: 1,+ shadowBias: {},+ shadowNormalBias: {},+ shadowRadius: {},+ shadowMapSize: {}+ } },+ spotLightMap: { value: [] },+ spotShadowMap: { value: [] },+ spotLightMatrix: { value: [] },+ pointLights: { value: [], properties: {+ color: {},+ position: {},+ decay: {},+ distance: {}+ } },+ pointLightShadows: { value: [], properties: {+ shadowIntensity: 1,+ shadowBias: {},+ shadowNormalBias: {},+ shadowRadius: {},+ shadowMapSize: {},+ shadowCameraNear: {},+ shadowCameraFar: {}+ } },+ pointShadowMap: { value: [] },+ pointShadowMatrix: { value: [] },+ hemisphereLights: { value: [], properties: {+ direction: {},+ skyColor: {},+ groundColor: {}+ } },+ // TODO (abelnation): RectAreaLight BRDF data needs to be moved from example to main src+ rectAreaLights: { value: [], properties: {+ color: {},+ position: {},+ width: {},+ height: {}+ } },+ ltc_1: { value: null },+ ltc_2: { value: null }+ },+ points: {+ diffuse: { value: /* @__PURE__ */ new je(16777215) },+ opacity: { value: 1 },+ size: { value: 1 },+ scale: { value: 1 },+ map: { value: null },+ alphaMap: { value: null },+ alphaMapTransform: { value: /* @__PURE__ */ new rt() },+ alphaTest: { value: 0 },+ uvTransform: { value: /* @__PURE__ */ new rt() }+ },+ sprite: {+ diffuse: { value: /* @__PURE__ */ new je(16777215) },+ opacity: { value: 1 },+ center: { value: /* @__PURE__ */ new Ze(0.5, 0.5) },+ rotation: { value: 0 },+ map: { value: null },+ mapTransform: { value: /* @__PURE__ */ new rt() },+ alphaMap: { value: null },+ alphaMapTransform: { value: /* @__PURE__ */ new rt() },+ alphaTest: { value: 0 }+ }+}, Ri = {+ basic: {+ uniforms: /* @__PURE__ */ Bn([+ we.common,+ we.specularmap,+ we.envmap,+ we.aomap,+ we.lightmap,+ we.fog+ ]),+ vertexShader: ot.meshbasic_vert,+ fragmentShader: ot.meshbasic_frag+ },+ lambert: {+ uniforms: /* @__PURE__ */ Bn([+ we.common,+ we.specularmap,+ we.envmap,+ we.aomap,+ we.lightmap,+ we.emissivemap,+ we.bumpmap,+ we.normalmap,+ we.displacementmap,+ we.fog,+ we.lights,+ {+ emissive: { value: /* @__PURE__ */ new je(0) }+ }+ ]),+ vertexShader: ot.meshlambert_vert,+ fragmentShader: ot.meshlambert_frag+ },+ phong: {+ uniforms: /* @__PURE__ */ Bn([+ we.common,+ we.specularmap,+ we.envmap,+ we.aomap,+ we.lightmap,+ we.emissivemap,+ we.bumpmap,+ we.normalmap,+ we.displacementmap,+ we.fog,+ we.lights,+ {+ emissive: { value: /* @__PURE__ */ new je(0) },+ specular: { value: /* @__PURE__ */ new je(1118481) },+ shininess: { value: 30 }+ }+ ]),+ vertexShader: ot.meshphong_vert,+ fragmentShader: ot.meshphong_frag+ },+ standard: {+ uniforms: /* @__PURE__ */ Bn([+ we.common,+ we.envmap,+ we.aomap,+ we.lightmap,+ we.emissivemap,+ we.bumpmap,+ we.normalmap,+ we.displacementmap,+ we.roughnessmap,+ we.metalnessmap,+ we.fog,+ we.lights,+ {+ emissive: { value: /* @__PURE__ */ new je(0) },+ roughness: { value: 1 },+ metalness: { value: 0 },+ envMapIntensity: { value: 1 }+ }+ ]),+ vertexShader: ot.meshphysical_vert,+ fragmentShader: ot.meshphysical_frag+ },+ toon: {+ uniforms: /* @__PURE__ */ Bn([+ we.common,+ we.aomap,+ we.lightmap,+ we.emissivemap,+ we.bumpmap,+ we.normalmap,+ we.displacementmap,+ we.gradientmap,+ we.fog,+ we.lights,+ {+ emissive: { value: /* @__PURE__ */ new je(0) }+ }+ ]),+ vertexShader: ot.meshtoon_vert,+ fragmentShader: ot.meshtoon_frag+ },+ matcap: {+ uniforms: /* @__PURE__ */ Bn([+ we.common,+ we.bumpmap,+ we.normalmap,+ we.displacementmap,+ we.fog,+ {+ matcap: { value: null }+ }+ ]),+ vertexShader: ot.meshmatcap_vert,+ fragmentShader: ot.meshmatcap_frag+ },+ points: {+ uniforms: /* @__PURE__ */ Bn([+ we.points,+ we.fog+ ]),+ vertexShader: ot.points_vert,+ fragmentShader: ot.points_frag+ },+ dashed: {+ uniforms: /* @__PURE__ */ Bn([+ we.common,+ we.fog,+ {+ scale: { value: 1 },+ dashSize: { value: 1 },+ totalSize: { value: 2 }+ }+ ]),+ vertexShader: ot.linedashed_vert,+ fragmentShader: ot.linedashed_frag+ },+ depth: {+ uniforms: /* @__PURE__ */ Bn([+ we.common,+ we.displacementmap+ ]),+ vertexShader: ot.depth_vert,+ fragmentShader: ot.depth_frag+ },+ normal: {+ uniforms: /* @__PURE__ */ Bn([+ we.common,+ we.bumpmap,+ we.normalmap,+ we.displacementmap,+ {+ opacity: { value: 1 }+ }+ ]),+ vertexShader: ot.meshnormal_vert,+ fragmentShader: ot.meshnormal_frag+ },+ sprite: {+ uniforms: /* @__PURE__ */ Bn([+ we.sprite,+ we.fog+ ]),+ vertexShader: ot.sprite_vert,+ fragmentShader: ot.sprite_frag+ },+ background: {+ uniforms: {+ uvTransform: { value: /* @__PURE__ */ new rt() },+ t2D: { value: null },+ backgroundIntensity: { value: 1 }+ },+ vertexShader: ot.background_vert,+ fragmentShader: ot.background_frag+ },+ backgroundCube: {+ uniforms: {+ envMap: { value: null },+ flipEnvMap: { value: -1 },+ backgroundBlurriness: { value: 0 },+ backgroundIntensity: { value: 1 },+ backgroundRotation: { value: /* @__PURE__ */ new rt() }+ },+ vertexShader: ot.backgroundCube_vert,+ fragmentShader: ot.backgroundCube_frag+ },+ cube: {+ uniforms: {+ tCube: { value: null },+ tFlip: { value: -1 },+ opacity: { value: 1 }+ },+ vertexShader: ot.cube_vert,+ fragmentShader: ot.cube_frag+ },+ equirect: {+ uniforms: {+ tEquirect: { value: null }+ },+ vertexShader: ot.equirect_vert,+ fragmentShader: ot.equirect_frag+ },+ distanceRGBA: {+ uniforms: /* @__PURE__ */ Bn([+ we.common,+ we.displacementmap,+ {+ referencePosition: { value: /* @__PURE__ */ new H() },+ nearDistance: { value: 1 },+ farDistance: { value: 1e3 }+ }+ ]),+ vertexShader: ot.distanceRGBA_vert,+ fragmentShader: ot.distanceRGBA_frag+ },+ shadow: {+ uniforms: /* @__PURE__ */ Bn([+ we.lights,+ we.fog,+ {+ color: { value: /* @__PURE__ */ new je(0) },+ opacity: { value: 1 }+ }+ ]),+ vertexShader: ot.shadow_vert,+ fragmentShader: ot.shadow_frag+ }+};+Ri.physical = {+ uniforms: /* @__PURE__ */ Bn([+ Ri.standard.uniforms,+ {+ clearcoat: { value: 0 },+ clearcoatMap: { value: null },+ clearcoatMapTransform: { value: /* @__PURE__ */ new rt() },+ clearcoatNormalMap: { value: null },+ clearcoatNormalMapTransform: { value: /* @__PURE__ */ new rt() },+ clearcoatNormalScale: { value: /* @__PURE__ */ new Ze(1, 1) },+ clearcoatRoughness: { value: 0 },+ clearcoatRoughnessMap: { value: null },+ clearcoatRoughnessMapTransform: { value: /* @__PURE__ */ new rt() },+ dispersion: { value: 0 },+ iridescence: { value: 0 },+ iridescenceMap: { value: null },+ iridescenceMapTransform: { value: /* @__PURE__ */ new rt() },+ iridescenceIOR: { value: 1.3 },+ iridescenceThicknessMinimum: { value: 100 },+ iridescenceThicknessMaximum: { value: 400 },+ iridescenceThicknessMap: { value: null },+ iridescenceThicknessMapTransform: { value: /* @__PURE__ */ new rt() },+ sheen: { value: 0 },+ sheenColor: { value: /* @__PURE__ */ new je(0) },+ sheenColorMap: { value: null },+ sheenColorMapTransform: { value: /* @__PURE__ */ new rt() },+ sheenRoughness: { value: 1 },+ sheenRoughnessMap: { value: null },+ sheenRoughnessMapTransform: { value: /* @__PURE__ */ new rt() },+ transmission: { value: 0 },+ transmissionMap: { value: null },+ transmissionMapTransform: { value: /* @__PURE__ */ new rt() },+ transmissionSamplerSize: { value: /* @__PURE__ */ new Ze() },+ transmissionSamplerMap: { value: null },+ thickness: { value: 0 },+ thicknessMap: { value: null },+ thicknessMapTransform: { value: /* @__PURE__ */ new rt() },+ attenuationDistance: { value: 0 },+ attenuationColor: { value: /* @__PURE__ */ new je(0) },+ specularColor: { value: /* @__PURE__ */ new je(1, 1, 1) },+ specularColorMap: { value: null },+ specularColorMapTransform: { value: /* @__PURE__ */ new rt() },+ specularIntensity: { value: 1 },+ specularIntensityMap: { value: null },+ specularIntensityMapTransform: { value: /* @__PURE__ */ new rt() },+ anisotropyVector: { value: /* @__PURE__ */ new Ze() },+ anisotropyMap: { value: null },+ anisotropyMapTransform: { value: /* @__PURE__ */ new rt() }+ }+ ]),+ vertexShader: ot.meshphysical_vert,+ fragmentShader: ot.meshphysical_frag+};+const Uc = { r: 0, b: 0, g: 0 }, Zs = /* @__PURE__ */ new Pi(), FC = /* @__PURE__ */ new et();+function DC(i, e, t, n, s, r, a) {+ const o = new je(0);+ let c = r === !0 ? 0 : 1, l, h, u = null, d = 0, f = null;+ function m(b) {+ let E = b.isScene === !0 ? b.background : null;+ return E && E.isTexture && (E = (b.backgroundBlurriness > 0 ? t : e).get(E)), E;+ }+ function A(b) {+ let E = !1;+ const M = m(b);+ M === null ? p(o, c) : M && M.isColor && (p(M, 1), E = !0);+ const w = i.xr.getEnvironmentBlendMode();+ w === "additive" ? n.buffers.color.setClear(0, 0, 0, 1, a) : w === "alpha-blend" && n.buffers.color.setClear(0, 0, 0, 0, a), (i.autoClear || E) && (n.buffers.depth.setTest(!0), n.buffers.depth.setMask(!0), n.buffers.color.setMask(!0), i.clear(i.autoClearColor, i.autoClearDepth, i.autoClearStencil));+ }+ function g(b, E) {+ const M = m(E);+ M && (M.isCubeTexture || M.mapping === jl) ? (h === void 0 && (h = new Jt(+ new Ua(1, 1, 1),+ new Os({+ name: "BackgroundCubeMaterial",+ uniforms: Ia(Ri.backgroundCube.uniforms),+ vertexShader: Ri.backgroundCube.vertexShader,+ fragmentShader: Ri.backgroundCube.fragmentShader,+ side: Pn,+ depthTest: !1,+ depthWrite: !1,+ fog: !1,+ allowOverride: !1+ })+ ), h.geometry.deleteAttribute("normal"), h.geometry.deleteAttribute("uv"), h.onBeforeRender = function(w, S, T) {+ this.matrixWorld.copyPosition(T.matrixWorld);+ }, Object.defineProperty(h.material, "envMap", {+ get: function() {+ return this.uniforms.envMap.value;+ }+ }), s.update(h)), Zs.copy(E.backgroundRotation), Zs.x *= -1, Zs.y *= -1, Zs.z *= -1, M.isCubeTexture && M.isRenderTargetTexture === !1 && (Zs.y *= -1, Zs.z *= -1), h.material.uniforms.envMap.value = M, h.material.uniforms.flipEnvMap.value = M.isCubeTexture && M.isRenderTargetTexture === !1 ? -1 : 1, h.material.uniforms.backgroundBlurriness.value = E.backgroundBlurriness, h.material.uniforms.backgroundIntensity.value = E.backgroundIntensity, h.material.uniforms.backgroundRotation.value.setFromMatrix4(FC.makeRotationFromEuler(Zs)), h.material.toneMapped = mt.getTransfer(M.colorSpace) !== Mt, (u !== M || d !== M.version || f !== i.toneMapping) && (h.material.needsUpdate = !0, u = M, d = M.version, f = i.toneMapping), h.layers.enableAll(), b.unshift(h, h.geometry, h.material, 0, 0, null)) : M && M.isTexture && (l === void 0 && (l = new Jt(+ new Zl(2, 2),+ new Os({+ name: "BackgroundMaterial",+ uniforms: Ia(Ri.background.uniforms),+ vertexShader: Ri.background.vertexShader,+ fragmentShader: Ri.background.fragmentShader,+ side: us,+ depthTest: !1,+ depthWrite: !1,+ fog: !1,+ allowOverride: !1+ })+ ), l.geometry.deleteAttribute("normal"), Object.defineProperty(l.material, "map", {+ get: function() {+ return this.uniforms.t2D.value;+ }+ }), s.update(l)), l.material.uniforms.t2D.value = M, l.material.uniforms.backgroundIntensity.value = E.backgroundIntensity, l.material.toneMapped = mt.getTransfer(M.colorSpace) !== Mt, M.matrixAutoUpdate === !0 && M.updateMatrix(), l.material.uniforms.uvTransform.value.copy(M.matrix), (u !== M || d !== M.version || f !== i.toneMapping) && (l.material.needsUpdate = !0, u = M, d = M.version, f = i.toneMapping), l.layers.enableAll(), b.unshift(l, l.geometry, l.material, 0, 0, null));+ }+ function p(b, E) {+ b.getRGB(Uc, d0(i)), n.buffers.color.setClear(Uc.r, Uc.g, Uc.b, E, a);+ }+ function y() {+ h !== void 0 && (h.geometry.dispose(), h.material.dispose(), h = void 0), l !== void 0 && (l.geometry.dispose(), l.material.dispose(), l = void 0);+ }+ return {+ getClearColor: function() {+ return o;+ },+ setClearColor: function(b, E = 1) {+ o.set(b), c = E, p(o, c);+ },+ getClearAlpha: function() {+ return c;+ },+ setClearAlpha: function(b) {+ c = b, p(o, c);+ },+ render: A,+ addToRenderList: g,+ dispose: y+ };+}+function LC(i, e) {+ const t = i.getParameter(i.MAX_VERTEX_ATTRIBS), n = {}, s = d(null);+ let r = s, a = !1;+ function o(v, F, K, q, $) {+ let D = !1;+ const O = u(q, K, F);+ r !== O && (r = O, l(r.object)), D = f(v, q, K, $), D && m(v, q, K, $), $ !== null && e.update($, i.ELEMENT_ARRAY_BUFFER), (D || a) && (a = !1, E(v, F, K, q), $ !== null && i.bindBuffer(i.ELEMENT_ARRAY_BUFFER, e.get($).buffer));+ }+ function c() {+ return i.createVertexArray();+ }+ function l(v) {+ return i.bindVertexArray(v);+ }+ function h(v) {+ return i.deleteVertexArray(v);+ }+ function u(v, F, K) {+ const q = K.wireframe === !0;+ let $ = n[v.id];+ $ === void 0 && ($ = {}, n[v.id] = $);+ let D = $[F.id];+ D === void 0 && (D = {}, $[F.id] = D);+ let O = D[q];+ return O === void 0 && (O = d(c()), D[q] = O), O;+ }+ function d(v) {+ const F = [], K = [], q = [];+ for (let $ = 0; $ < t; $++)+ F[$] = 0, K[$] = 0, q[$] = 0;+ return {+ // for backward compatibility on non-VAO support browser+ geometry: null,+ program: null,+ wireframe: !1,+ newAttributes: F,+ enabledAttributes: K,+ attributeDivisors: q,+ object: v,+ attributes: {},+ index: null+ };+ }+ function f(v, F, K, q) {+ const $ = r.attributes, D = F.attributes;+ let O = 0;+ const Y = K.getAttributes();+ for (const Q in Y)+ if (Y[Q].location >= 0) {+ const ee = $[Q];+ let ae = D[Q];+ if (ae === void 0 && (Q === "instanceMatrix" && v.instanceMatrix && (ae = v.instanceMatrix), Q === "instanceColor" && v.instanceColor && (ae = v.instanceColor)), ee === void 0 || ee.attribute !== ae || ae && ee.data !== ae.data) return !0;+ O++;+ }+ return r.attributesNum !== O || r.index !== q;+ }+ function m(v, F, K, q) {+ const $ = {}, D = F.attributes;+ let O = 0;+ const Y = K.getAttributes();+ for (const Q in Y)+ if (Y[Q].location >= 0) {+ let ee = D[Q];+ ee === void 0 && (Q === "instanceMatrix" && v.instanceMatrix && (ee = v.instanceMatrix), Q === "instanceColor" && v.instanceColor && (ee = v.instanceColor));+ const ae = {};+ ae.attribute = ee, ee && ee.data && (ae.data = ee.data), $[Q] = ae, O++;+ }+ r.attributes = $, r.attributesNum = O, r.index = q;+ }+ function A() {+ const v = r.newAttributes;+ for (let F = 0, K = v.length; F < K; F++)+ v[F] = 0;+ }+ function g(v) {+ p(v, 0);+ }+ function p(v, F) {+ const K = r.newAttributes, q = r.enabledAttributes, $ = r.attributeDivisors;+ K[v] = 1, q[v] === 0 && (i.enableVertexAttribArray(v), q[v] = 1), $[v] !== F && (i.vertexAttribDivisor(v, F), $[v] = F);+ }+ function y() {+ const v = r.newAttributes, F = r.enabledAttributes;+ for (let K = 0, q = F.length; K < q; K++)+ F[K] !== v[K] && (i.disableVertexAttribArray(K), F[K] = 0);+ }+ function b(v, F, K, q, $, D, O) {+ O === !0 ? i.vertexAttribIPointer(v, F, K, $, D) : i.vertexAttribPointer(v, F, K, q, $, D);+ }+ function E(v, F, K, q) {+ A();+ const $ = q.attributes, D = K.getAttributes(), O = F.defaultAttributeValues;+ for (const Y in D) {+ const Q = D[Y];+ if (Q.location >= 0) {+ let J = $[Y];+ if (J === void 0 && (Y === "instanceMatrix" && v.instanceMatrix && (J = v.instanceMatrix), Y === "instanceColor" && v.instanceColor && (J = v.instanceColor)), J !== void 0) {+ const ee = J.normalized, ae = J.itemSize, ye = e.get(J);+ if (ye === void 0) continue;+ const Me = ye.buffer, se = ye.type, me = ye.bytesPerElement, be = se === i.INT || se === i.UNSIGNED_INT || J.gpuType === ff;+ if (J.isInterleavedBufferAttribute) {+ const xe = J.data, Pe = xe.stride, $e = J.offset;+ if (xe.isInstancedInterleavedBuffer) {+ for (let Qe = 0; Qe < Q.locationSize; Qe++)+ p(Q.location + Qe, xe.meshPerAttribute);+ v.isInstancedMesh !== !0 && q._maxInstanceCount === void 0 && (q._maxInstanceCount = xe.meshPerAttribute * xe.count);+ } else+ for (let Qe = 0; Qe < Q.locationSize; Qe++)+ g(Q.location + Qe);+ i.bindBuffer(i.ARRAY_BUFFER, Me);+ for (let Qe = 0; Qe < Q.locationSize; Qe++)+ b(+ Q.location + Qe,+ ae / Q.locationSize,+ se,+ ee,+ Pe * me,+ ($e + ae / Q.locationSize * Qe) * me,+ be+ );+ } else {+ if (J.isInstancedBufferAttribute) {+ for (let xe = 0; xe < Q.locationSize; xe++)+ p(Q.location + xe, J.meshPerAttribute);+ v.isInstancedMesh !== !0 && q._maxInstanceCount === void 0 && (q._maxInstanceCount = J.meshPerAttribute * J.count);+ } else+ for (let xe = 0; xe < Q.locationSize; xe++)+ g(Q.location + xe);+ i.bindBuffer(i.ARRAY_BUFFER, Me);+ for (let xe = 0; xe < Q.locationSize; xe++)+ b(+ Q.location + xe,+ ae / Q.locationSize,+ se,+ ee,+ ae * me,+ ae / Q.locationSize * xe * me,+ be+ );+ }+ } else if (O !== void 0) {+ const ee = O[Y];+ if (ee !== void 0)+ switch (ee.length) {+ case 2:+ i.vertexAttrib2fv(Q.location, ee);+ break;+ case 3:+ i.vertexAttrib3fv(Q.location, ee);+ break;+ case 4:+ i.vertexAttrib4fv(Q.location, ee);+ break;+ default:+ i.vertexAttrib1fv(Q.location, ee);+ }+ }+ }+ }+ y();+ }+ function M() {+ T();+ for (const v in n) {+ const F = n[v];+ for (const K in F) {+ const q = F[K];+ for (const $ in q)+ h(q[$].object), delete q[$];+ delete F[K];+ }+ delete n[v];+ }+ }+ function w(v) {+ if (n[v.id] === void 0) return;+ const F = n[v.id];+ for (const K in F) {+ const q = F[K];+ for (const $ in q)+ h(q[$].object), delete q[$];+ delete F[K];+ }+ delete n[v.id];+ }+ function S(v) {+ for (const F in n) {+ const K = n[F];+ if (K[v.id] === void 0) continue;+ const q = K[v.id];+ for (const $ in q)+ h(q[$].object), delete q[$];+ delete K[v.id];+ }+ }+ function T() {+ C(), a = !0, r !== s && (r = s, l(r.object));+ }+ function C() {+ s.geometry = null, s.program = null, s.wireframe = !1;+ }+ return {+ setup: o,+ reset: T,+ resetDefaultState: C,+ dispose: M,+ releaseStatesOfGeometry: w,+ releaseStatesOfProgram: S,+ initAttributes: A,+ enableAttribute: g,+ disableUnusedAttributes: y+ };+}+function PC(i, e, t) {+ let n;+ function s(l) {+ n = l;+ }+ function r(l, h) {+ i.drawArrays(n, l, h), t.update(h, n, 1);+ }+ function a(l, h, u) {+ u !== 0 && (i.drawArraysInstanced(n, l, h, u), t.update(h, n, u));+ }+ function o(l, h, u) {+ if (u === 0) return;+ e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n, l, 0, h, 0, u);+ let f = 0;+ for (let m = 0; m < u; m++)+ f += h[m];+ t.update(f, n, 1);+ }+ function c(l, h, u, d) {+ if (u === 0) return;+ const f = e.get("WEBGL_multi_draw");+ if (f === null)+ for (let m = 0; m < l.length; m++)+ a(l[m], h[m], d[m]);+ else {+ f.multiDrawArraysInstancedWEBGL(n, l, 0, h, 0, d, 0, u);+ let m = 0;+ for (let A = 0; A < u; A++)+ m += h[A] * d[A];+ t.update(m, n, 1);+ }+ }+ this.setMode = s, this.render = r, this.renderInstances = a, this.renderMultiDraw = o, this.renderMultiDrawInstances = c;+}+function kC(i, e, t, n) {+ let s;+ function r() {+ if (s !== void 0) return s;+ if (e.has("EXT_texture_filter_anisotropic") === !0) {+ const S = e.get("EXT_texture_filter_anisotropic");+ s = i.getParameter(S.MAX_TEXTURE_MAX_ANISOTROPY_EXT);+ } else+ s = 0;+ return s;+ }+ function a(S) {+ return !(S !== on && n.convert(S) !== i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT));+ }+ function o(S) {+ const T = S === Nn && (e.has("EXT_color_buffer_half_float") || e.has("EXT_color_buffer_float"));+ return !(S !== rn && n.convert(S) !== i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE) && // Edge and Chrome Mac < 52 (#9513)+ S !== an && !T);+ }+ function c(S) {+ if (S === "highp") {+ if (i.getShaderPrecisionFormat(i.VERTEX_SHADER, i.HIGH_FLOAT).precision > 0 && i.getShaderPrecisionFormat(i.FRAGMENT_SHADER, i.HIGH_FLOAT).precision > 0)+ return "highp";+ S = "mediump";+ }+ return S === "mediump" && i.getShaderPrecisionFormat(i.VERTEX_SHADER, i.MEDIUM_FLOAT).precision > 0 && i.getShaderPrecisionFormat(i.FRAGMENT_SHADER, i.MEDIUM_FLOAT).precision > 0 ? "mediump" : "lowp";+ }+ let l = t.precision !== void 0 ? t.precision : "highp";+ const h = c(l);+ h !== l && (console.warn("THREE.WebGLRenderer:", l, "not supported, using", h, "instead."), l = h);+ const u = t.logarithmicDepthBuffer === !0, d = t.reverseDepthBuffer === !0 && e.has("EXT_clip_control"), f = i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS), m = i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS), A = i.getParameter(i.MAX_TEXTURE_SIZE), g = i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE), p = i.getParameter(i.MAX_VERTEX_ATTRIBS), y = i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS), b = i.getParameter(i.MAX_VARYING_VECTORS), E = i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS), M = m > 0, w = i.getParameter(i.MAX_SAMPLES);+ return {+ isWebGL2: !0,+ // keeping this for backwards compatibility+ getMaxAnisotropy: r,+ getMaxPrecision: c,+ textureFormatReadable: a,+ textureTypeReadable: o,+ precision: l,+ logarithmicDepthBuffer: u,+ reverseDepthBuffer: d,+ maxTextures: f,+ maxVertexTextures: m,+ maxTextureSize: A,+ maxCubemapSize: g,+ maxAttributes: p,+ maxVertexUniforms: y,+ maxVaryings: b,+ maxFragmentUniforms: E,+ vertexTextures: M,+ maxSamples: w+ };+}+function UC(i) {+ const e = this;+ let t = null, n = 0, s = !1, r = !1;+ const a = new Rs(), o = new rt(), c = { value: null, needsUpdate: !1 };+ this.uniform = c, this.numPlanes = 0, this.numIntersection = 0, this.init = function(u, d) {+ const f = u.length !== 0 || d || // enable state of previous frame - the clipping code has to+ // run another frame in order to reset the state:+ n !== 0 || s;+ return s = d, n = u.length, f;+ }, this.beginShadows = function() {+ r = !0, h(null);+ }, this.endShadows = function() {+ r = !1;+ }, this.setGlobalState = function(u, d) {+ t = h(u, d, 0);+ }, this.setState = function(u, d, f) {+ const m = u.clippingPlanes, A = u.clipIntersection, g = u.clipShadows, p = i.get(u);+ if (!s || m === null || m.length === 0 || r && !g)+ r ? h(null) : l();+ else {+ const y = r ? 0 : n, b = y * 4;+ let E = p.clippingState || null;+ c.value = E, E = h(m, d, b, f);+ for (let M = 0; M !== b; ++M)+ E[M] = t[M];+ p.clippingState = E, this.numIntersection = A ? this.numPlanes : 0, this.numPlanes += y;+ }+ };+ function l() {+ c.value !== t && (c.value = t, c.needsUpdate = n > 0), e.numPlanes = n, e.numIntersection = 0;+ }+ function h(u, d, f, m) {+ const A = u !== null ? u.length : 0;+ let g = null;+ if (A !== 0) {+ if (g = c.value, m !== !0 || g === null) {+ const p = f + A * 4, y = d.matrixWorldInverse;+ o.getNormalMatrix(y), (g === null || g.length < p) && (g = new Float32Array(p));+ for (let b = 0, E = f; b !== A; ++b, E += 4)+ a.copy(u[b]).applyMatrix4(y, o), a.normal.toArray(g, E), g[E + 3] = a.constant;+ }+ c.value = g, c.needsUpdate = !0;+ }+ return e.numPlanes = A, e.numIntersection = 0, g;+ }+}+function OC(i) {+ let e = /* @__PURE__ */ new WeakMap();+ function t(a, o) {+ return o === Zu ? a.mapping = Er : o === $u && (a.mapping = va), a;+ }+ function n(a) {+ if (a && a.isTexture) {+ const o = a.mapping;+ if (o === Zu || o === $u)+ if (e.has(a)) {+ const c = e.get(a).texture;+ return t(c, a.mapping);+ } else {+ const c = a.image;+ if (c && c.height > 0) {+ const l = new ny(c.height);+ return l.fromEquirectangularTexture(i, a), e.set(a, l), a.addEventListener("dispose", s), t(l.texture, a.mapping);+ } else+ return null;+ }+ }+ return a;+ }+ function s(a) {+ const o = a.target;+ o.removeEventListener("dispose", s);+ const c = e.get(o);+ c !== void 0 && (e.delete(o), c.dispose());+ }+ function r() {+ e = /* @__PURE__ */ new WeakMap();+ }+ return {+ get: n,+ dispose: r+ };+}+const oa = 4, sA = [0.125, 0.215, 0.35, 0.446, 0.526, 0.582], or = 20, jh = /* @__PURE__ */ new Mf(), rA = /* @__PURE__ */ new je();+let Xh = null, Yh = 0, Jh = 0, Zh = !1;+const sr = (1 + Math.sqrt(5)) / 2, Xr = 1 / sr, aA = [+ /* @__PURE__ */ new H(-sr, Xr, 0),+ /* @__PURE__ */ new H(sr, Xr, 0),+ /* @__PURE__ */ new H(-Xr, 0, sr),+ /* @__PURE__ */ new H(Xr, 0, sr),+ /* @__PURE__ */ new H(0, sr, -Xr),+ /* @__PURE__ */ new H(0, sr, Xr),+ /* @__PURE__ */ new H(-1, 1, -1),+ /* @__PURE__ */ new H(1, 1, -1),+ /* @__PURE__ */ new H(-1, 1, 1),+ /* @__PURE__ */ new H(1, 1, 1)+], QC = /* @__PURE__ */ new H();+class wd {+ /**+ * Constructs a new PMREM generator.+ *+ * @param {WebGLRenderer} renderer - The renderer.+ */+ constructor(e) {+ this._renderer = e, this._pingPongRenderTarget = null, this._lodMax = 0, this._cubeSize = 0, this._lodPlanes = [], this._sizeLods = [], this._sigmas = [], this._blurMaterial = null, this._cubemapMaterial = null, this._equirectMaterial = null, this._compileMaterial(this._blurMaterial);+ }+ /**+ * Generates a PMREM from a supplied Scene, which can be faster than using an+ * image if networking bandwidth is low. Optional sigma specifies a blur radius+ * in radians to be applied to the scene before PMREM generation. Optional near+ * and far planes ensure the scene is rendered in its entirety.+ *+ * @param {Scene} scene - The scene to be captured.+ * @param {number} [sigma=0] - The blur radius in radians.+ * @param {number} [near=0.1] - The near plane distance.+ * @param {number} [far=100] - The far plane distance.+ * @param {Object} [options={}] - The configuration options.+ * @param {number} [options.size=256] - The texture size of the PMREM.+ * @param {Vector3} [options.renderTarget=origin] - The position of the internal cube camera that renders the scene.+ * @return {WebGLRenderTarget} The resulting PMREM.+ */+ fromScene(e, t = 0, n = 0.1, s = 100, r = {}) {+ const {+ size: a = 256,+ position: o = QC+ } = r;+ Xh = this._renderer.getRenderTarget(), Yh = this._renderer.getActiveCubeFace(), Jh = this._renderer.getActiveMipmapLevel(), Zh = this._renderer.xr.enabled, this._renderer.xr.enabled = !1, this._setSize(a);+ const c = this._allocateTargets();+ return c.depthBuffer = !0, this._sceneToCubeUV(e, n, s, c, o), t > 0 && this._blur(c, 0, 0, t), this._applyPMREM(c), this._cleanup(c), c;+ }+ /**+ * Generates a PMREM from an equirectangular texture, which can be either LDR+ * or HDR. The ideal input image size is 1k (1024 x 512),+ * as this matches best with the 256 x 256 cubemap output.+ *+ * @param {Texture} equirectangular - The equirectangular texture to be converted.+ * @param {?WebGLRenderTarget} [renderTarget=null] - The render target to use.+ * @return {WebGLRenderTarget} The resulting PMREM.+ */+ fromEquirectangular(e, t = null) {+ return this._fromTexture(e, t);+ }+ /**+ * Generates a PMREM from an cubemap texture, which can be either LDR+ * or HDR. The ideal input cube size is 256 x 256,+ * as this matches best with the 256 x 256 cubemap output.+ *+ * @param {Texture} cubemap - The cubemap texture to be converted.+ * @param {?WebGLRenderTarget} [renderTarget=null] - The render target to use.+ * @return {WebGLRenderTarget} The resulting PMREM.+ */+ fromCubemap(e, t = null) {+ return this._fromTexture(e, t);+ }+ /**+ * Pre-compiles the cubemap shader. You can get faster start-up by invoking this method during+ * your texture's network fetch for increased concurrency.+ */+ compileCubemapShader() {+ this._cubemapMaterial === null && (this._cubemapMaterial = lA(), this._compileMaterial(this._cubemapMaterial));+ }+ /**+ * Pre-compiles the equirectangular shader. You can get faster start-up by invoking this method during+ * your texture's network fetch for increased concurrency.+ */+ compileEquirectangularShader() {+ this._equirectMaterial === null && (this._equirectMaterial = cA(), this._compileMaterial(this._equirectMaterial));+ }+ /**+ * Disposes of the PMREMGenerator's internal memory. Note that PMREMGenerator is a static class,+ * so you should not need more than one PMREMGenerator object. If you do, calling dispose() on+ * one of them will cause any others to also become unusable.+ */+ dispose() {+ this._dispose(), this._cubemapMaterial !== null && this._cubemapMaterial.dispose(), this._equirectMaterial !== null && this._equirectMaterial.dispose();+ }+ // private interface+ _setSize(e) {+ this._lodMax = Math.floor(Math.log2(e)), this._cubeSize = Math.pow(2, this._lodMax);+ }+ _dispose() {+ this._blurMaterial !== null && this._blurMaterial.dispose(), this._pingPongRenderTarget !== null && this._pingPongRenderTarget.dispose();+ for (let e = 0; e < this._lodPlanes.length; e++)+ this._lodPlanes[e].dispose();+ }+ _cleanup(e) {+ this._renderer.setRenderTarget(Xh, Yh, Jh), this._renderer.xr.enabled = Zh, e.scissorTest = !1, Oc(e, 0, 0, e.width, e.height);+ }+ _fromTexture(e, t) {+ e.mapping === Er || e.mapping === va ? this._setSize(e.image.length === 0 ? 16 : e.image[0].width || e.image[0].image.width) : this._setSize(e.image.width / 4), Xh = this._renderer.getRenderTarget(), Yh = this._renderer.getActiveCubeFace(), Jh = this._renderer.getActiveMipmapLevel(), Zh = this._renderer.xr.enabled, this._renderer.xr.enabled = !1;+ const n = t || this._allocateTargets();+ return this._textureToCubeUV(e, n), this._applyPMREM(n), this._cleanup(n), n;+ }+ _allocateTargets() {+ const e = 3 * Math.max(this._cubeSize, 112), t = 4 * this._cubeSize, n = {+ magFilter: qt,+ minFilter: qt,+ generateMipmaps: !1,+ type: Nn,+ format: on,+ colorSpace: ln,+ depthBuffer: !1+ }, s = oA(e, t, n);+ if (this._pingPongRenderTarget === null || this._pingPongRenderTarget.width !== e || this._pingPongRenderTarget.height !== t) {+ this._pingPongRenderTarget !== null && this._dispose(), this._pingPongRenderTarget = oA(e, t, n);+ const { _lodMax: r } = this;+ ({ sizeLods: this._sizeLods, lodPlanes: this._lodPlanes, sigmas: this._sigmas } = GC(r)), this._blurMaterial = HC(r, e, t);+ }+ return s;+ }+ _compileMaterial(e) {+ const t = new Jt(this._lodPlanes[0], e);+ this._renderer.compile(t, jh);+ }+ _sceneToCubeUV(e, t, n, s, r) {+ const c = new vn(90, 1, t, n), l = [1, -1, 1, 1, 1, 1], h = [1, 1, 1, -1, -1, -1], u = this._renderer, d = u.autoClear, f = u.toneMapping;+ u.getClearColor(rA), u.toneMapping = Ls, u.autoClear = !1;+ const m = new Ns({+ name: "PMREM.Background",+ side: Pn,+ depthWrite: !1,+ depthTest: !1+ }), A = new Jt(new Ua(), m);+ let g = !1;+ const p = e.background;+ p ? p.isColor && (m.color.copy(p), e.background = null, g = !0) : (m.color.copy(rA), g = !0);+ for (let y = 0; y < 6; y++) {+ const b = y % 3;+ b === 0 ? (c.up.set(0, l[y], 0), c.position.set(r.x, r.y, r.z), c.lookAt(r.x + h[y], r.y, r.z)) : b === 1 ? (c.up.set(0, 0, l[y]), c.position.set(r.x, r.y, r.z), c.lookAt(r.x, r.y + h[y], r.z)) : (c.up.set(0, l[y], 0), c.position.set(r.x, r.y, r.z), c.lookAt(r.x, r.y, r.z + h[y]));+ const E = this._cubeSize;+ Oc(s, b * E, y > 2 ? E : 0, E, E), u.setRenderTarget(s), g && u.render(A, c), u.render(e, c);+ }+ A.geometry.dispose(), A.material.dispose(), u.toneMapping = f, u.autoClear = d, e.background = p;+ }+ _textureToCubeUV(e, t) {+ const n = this._renderer, s = e.mapping === Er || e.mapping === va;+ s ? (this._cubemapMaterial === null && (this._cubemapMaterial = lA()), this._cubemapMaterial.uniforms.flipEnvMap.value = e.isRenderTargetTexture === !1 ? -1 : 1) : this._equirectMaterial === null && (this._equirectMaterial = cA());+ const r = s ? this._cubemapMaterial : this._equirectMaterial, a = new Jt(this._lodPlanes[0], r), o = r.uniforms;+ o.envMap.value = e;+ const c = this._cubeSize;+ Oc(t, 0, 0, 3 * c, 2 * c), n.setRenderTarget(t), n.render(a, jh);+ }+ _applyPMREM(e) {+ const t = this._renderer, n = t.autoClear;+ t.autoClear = !1;+ const s = this._lodPlanes.length;+ for (let r = 1; r < s; r++) {+ const a = Math.sqrt(this._sigmas[r] * this._sigmas[r] - this._sigmas[r - 1] * this._sigmas[r - 1]), o = aA[(s - r - 1) % aA.length];+ this._blur(e, r - 1, r, a, o);+ }+ t.autoClear = n;+ }+ /**+ * This is a two-pass Gaussian blur for a cubemap. Normally this is done+ * vertically and horizontally, but this breaks down on a cube. Here we apply+ * the blur latitudinally (around the poles), and then longitudinally (towards+ * the poles) to approximate the orthogonally-separable blur. It is least+ * accurate at the poles, but still does a decent job.+ *+ * @private+ * @param {WebGLRenderTarget} cubeUVRenderTarget+ * @param {number} lodIn+ * @param {number} lodOut+ * @param {number} sigma+ * @param {Vector3} [poleAxis]+ */+ _blur(e, t, n, s, r) {+ const a = this._pingPongRenderTarget;+ this._halfBlur(+ e,+ a,+ t,+ n,+ s,+ "latitudinal",+ r+ ), this._halfBlur(+ a,+ e,+ n,+ n,+ s,+ "longitudinal",+ r+ );+ }+ _halfBlur(e, t, n, s, r, a, o) {+ const c = this._renderer, l = this._blurMaterial;+ a !== "latitudinal" && a !== "longitudinal" && console.error(+ "blur direction must be either latitudinal or longitudinal!"+ );+ const h = 3, u = new Jt(this._lodPlanes[s], l), d = l.uniforms, f = this._sizeLods[n] - 1, m = isFinite(r) ? Math.PI / (2 * f) : 2 * Math.PI / (2 * or - 1), A = r / m, g = isFinite(r) ? 1 + Math.floor(h * A) : or;+ g > or && console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${or}`);+ const p = [];+ let y = 0;+ for (let S = 0; S < or; ++S) {+ const T = S / A, C = Math.exp(-T * T / 2);+ p.push(C), S === 0 ? y += C : S < g && (y += 2 * C);+ }+ for (let S = 0; S < p.length; S++)+ p[S] = p[S] / y;+ d.envMap.value = e.texture, d.samples.value = g, d.weights.value = p, d.latitudinal.value = a === "latitudinal", o && (d.poleAxis.value = o);+ const { _lodMax: b } = this;+ d.dTheta.value = m, d.mipInt.value = b - n;+ const E = this._sizeLods[s], M = 3 * E * (s > b - oa ? s - b + oa : 0), w = 4 * (this._cubeSize - E);+ Oc(t, M, w, 3 * E, 2 * E), c.setRenderTarget(t), c.render(u, jh);+ }+}+function GC(i) {+ const e = [], t = [], n = [];+ let s = i;+ const r = i - oa + 1 + sA.length;+ for (let a = 0; a < r; a++) {+ const o = Math.pow(2, s);+ t.push(o);+ let c = 1 / o;+ a > i - oa ? c = sA[a - i + oa - 1] : a === 0 && (c = 0), n.push(c);+ const l = 1 / (o - 2), h = -l, u = 1 + l, d = [h, h, u, h, u, u, h, h, u, u, h, u], f = 6, m = 6, A = 3, g = 2, p = 1, y = new Float32Array(A * m * f), b = new Float32Array(g * m * f), E = new Float32Array(p * m * f);+ for (let w = 0; w < f; w++) {+ const S = w % 3 * 2 / 3 - 1, T = w > 2 ? 0 : -1, C = [+ S,+ T,+ 0,+ S + 2 / 3,+ T,+ 0,+ S + 2 / 3,+ T + 1,+ 0,+ S,+ T,+ 0,+ S + 2 / 3,+ T + 1,+ 0,+ S,+ T + 1,+ 0+ ];+ y.set(C, A * m * w), b.set(d, g * m * w);+ const v = [w, w, w, w, w, w];+ E.set(v, p * m * w);+ }+ const M = new zn();+ M.setAttribute("position", new En(y, A)), M.setAttribute("uv", new En(b, g)), M.setAttribute("faceIndex", new En(E, p)), e.push(M), s > oa && s--;+ }+ return { lodPlanes: e, sizeLods: t, sigmas: n };+}+function oA(i, e, t) {+ const n = new wr(i, e, t);+ return n.texture.mapping = jl, n.texture.name = "PMREM.cubeUv", n.scissorTest = !0, n;+}+function Oc(i, e, t, n, s) {+ i.viewport.set(e, t, n, s), i.scissor.set(e, t, n, s);+}+function HC(i, e, t) {+ const n = new Float32Array(or), s = new H(0, 1, 0);+ return new Os({+ name: "SphericalGaussianBlur",+ defines: {+ n: or,+ CUBEUV_TEXEL_WIDTH: 1 / e,+ CUBEUV_TEXEL_HEIGHT: 1 / t,+ CUBEUV_MAX_MIP: `${i}.0`+ },+ uniforms: {+ envMap: { value: null },+ samples: { value: 1 },+ weights: { value: n },+ latitudinal: { value: !1 },+ dTheta: { value: 0 },+ mipInt: { value: 0 },+ poleAxis: { value: s }+ },+ vertexShader: Rf(),+ fragmentShader: (+ /* glsl */+ `++ precision mediump float;+ precision mediump int;++ varying vec3 vOutputDirection;++ uniform sampler2D envMap;+ uniform int samples;+ uniform float weights[ n ];+ uniform bool latitudinal;+ uniform float dTheta;+ uniform float mipInt;+ uniform vec3 poleAxis;++ #define ENVMAP_TYPE_CUBE_UV+ #include <cube_uv_reflection_fragment>++ vec3 getSample( float theta, vec3 axis ) {++ float cosTheta = cos( theta );+ // Rodrigues' axis-angle rotation+ vec3 sampleDirection = vOutputDirection * cosTheta+ + cross( axis, vOutputDirection ) * sin( theta )+ + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );++ return bilinearCubeUV( envMap, sampleDirection, mipInt );++ }++ void main() {++ vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );++ if ( all( equal( axis, vec3( 0.0 ) ) ) ) {++ axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );++ }++ axis = normalize( axis );++ gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );+ gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );++ for ( int i = 1; i < n; i++ ) {++ if ( i >= samples ) {++ break;++ }++ float theta = dTheta * float( i );+ gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );+ gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );++ }++ }+ `+ ),+ blending: Ds,+ depthTest: !1,+ depthWrite: !1+ });+}+function cA() {+ return new Os({+ name: "EquirectangularToCubeUV",+ uniforms: {+ envMap: { value: null }+ },+ vertexShader: Rf(),+ fragmentShader: (+ /* glsl */+ `++ precision mediump float;+ precision mediump int;++ varying vec3 vOutputDirection;++ uniform sampler2D envMap;++ #include <common>++ void main() {++ vec3 outputDirection = normalize( vOutputDirection );+ vec2 uv = equirectUv( outputDirection );++ gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );++ }+ `+ ),+ blending: Ds,+ depthTest: !1,+ depthWrite: !1+ });+}+function lA() {+ return new Os({+ name: "CubemapToCubeUV",+ uniforms: {+ envMap: { value: null },+ flipEnvMap: { value: -1 }+ },+ vertexShader: Rf(),+ fragmentShader: (+ /* glsl */+ `++ precision mediump float;+ precision mediump int;++ uniform float flipEnvMap;++ varying vec3 vOutputDirection;++ uniform samplerCube envMap;++ void main() {++ gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );++ }+ `+ ),+ blending: Ds,+ depthTest: !1,+ depthWrite: !1+ });+}+function Rf() {+ return (+ /* glsl */+ `++ precision mediump float;+ precision mediump int;++ attribute float faceIndex;++ varying vec3 vOutputDirection;++ // RH coordinate system; PMREM face-indexing convention+ vec3 getDirection( vec2 uv, float face ) {++ uv = 2.0 * uv - 1.0;++ vec3 direction = vec3( uv, 1.0 );++ if ( face == 0.0 ) {++ direction = direction.zyx; // ( 1, v, u ) pos x++ } else if ( face == 1.0 ) {++ direction = direction.xzy;+ direction.xz *= -1.0; // ( -u, 1, -v ) pos y++ } else if ( face == 2.0 ) {++ direction.x *= -1.0; // ( -u, v, 1 ) pos z++ } else if ( face == 3.0 ) {++ direction = direction.zyx;+ direction.xz *= -1.0; // ( -1, v, -u ) neg x++ } else if ( face == 4.0 ) {++ direction = direction.xzy;+ direction.xy *= -1.0; // ( -u, -1, v ) neg y++ } else if ( face == 5.0 ) {++ direction.z *= -1.0; // ( u, v, -1 ) neg z++ }++ return direction;++ }++ void main() {++ vOutputDirection = getDirection( uv, faceIndex );+ gl_Position = vec4( position, 1.0 );++ }+ `+ );+}+function zC(i) {+ let e = /* @__PURE__ */ new WeakMap(), t = null;+ function n(o) {+ if (o && o.isTexture) {+ const c = o.mapping, l = c === Zu || c === $u, h = c === Er || c === va;+ if (l || h) {+ let u = e.get(o);+ const d = u !== void 0 ? u.texture.pmremVersion : 0;+ if (o.isRenderTargetTexture && o.pmremVersion !== d)+ return t === null && (t = new wd(i)), u = l ? t.fromEquirectangular(o, u) : t.fromCubemap(o, u), u.texture.pmremVersion = o.pmremVersion, e.set(o, u), u.texture;+ if (u !== void 0)+ return u.texture;+ {+ const f = o.image;+ return l && f && f.height > 0 || h && f && s(f) ? (t === null && (t = new wd(i)), u = l ? t.fromEquirectangular(o) : t.fromCubemap(o), u.texture.pmremVersion = o.pmremVersion, e.set(o, u), o.addEventListener("dispose", r), u.texture) : null;+ }+ }+ }+ return o;+ }+ function s(o) {+ let c = 0;+ const l = 6;+ for (let h = 0; h < l; h++)+ o[h] !== void 0 && c++;+ return c === l;+ }+ function r(o) {+ const c = o.target;+ c.removeEventListener("dispose", r);+ const l = e.get(c);+ l !== void 0 && (e.delete(c), l.dispose());+ }+ function a() {+ e = /* @__PURE__ */ new WeakMap(), t !== null && (t.dispose(), t = null);+ }+ return {+ get: n,+ dispose: a+ };+}+function VC(i) {+ const e = {};+ function t(n) {+ if (e[n] !== void 0)+ return e[n];+ let s;+ switch (n) {+ case "WEBGL_depth_texture":+ s = i.getExtension("WEBGL_depth_texture") || i.getExtension("MOZ_WEBGL_depth_texture") || i.getExtension("WEBKIT_WEBGL_depth_texture");+ break;+ case "EXT_texture_filter_anisotropic":+ s = i.getExtension("EXT_texture_filter_anisotropic") || i.getExtension("MOZ_EXT_texture_filter_anisotropic") || i.getExtension("WEBKIT_EXT_texture_filter_anisotropic");+ break;+ case "WEBGL_compressed_texture_s3tc":+ s = i.getExtension("WEBGL_compressed_texture_s3tc") || i.getExtension("MOZ_WEBGL_compressed_texture_s3tc") || i.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");+ break;+ case "WEBGL_compressed_texture_pvrtc":+ s = i.getExtension("WEBGL_compressed_texture_pvrtc") || i.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");+ break;+ default:+ s = i.getExtension(n);+ }+ return e[n] = s, s;+ }+ return {+ has: function(n) {+ return t(n) !== null;+ },+ init: function() {+ t("EXT_color_buffer_float"), t("WEBGL_clip_cull_distance"), t("OES_texture_float_linear"), t("EXT_color_buffer_half_float"), t("WEBGL_multisampled_render_to_texture"), t("WEBGL_render_shared_exponent");+ },+ get: function(n) {+ const s = t(n);+ return s === null && pl("THREE.WebGLRenderer: " + n + " extension not supported."), s;+ }+ };+}+function WC(i, e, t, n) {+ const s = {}, r = /* @__PURE__ */ new WeakMap();+ function a(u) {+ const d = u.target;+ d.index !== null && e.remove(d.index);+ for (const m in d.attributes)+ e.remove(d.attributes[m]);+ d.removeEventListener("dispose", a), delete s[d.id];+ const f = r.get(d);+ f && (e.remove(f), r.delete(d)), n.releaseStatesOfGeometry(d), d.isInstancedBufferGeometry === !0 && delete d._maxInstanceCount, t.memory.geometries--;+ }+ function o(u, d) {+ return s[d.id] === !0 || (d.addEventListener("dispose", a), s[d.id] = !0, t.memory.geometries++), d;+ }+ function c(u) {+ const d = u.attributes;+ for (const f in d)+ e.update(d[f], i.ARRAY_BUFFER);+ }+ function l(u) {+ const d = [], f = u.index, m = u.attributes.position;+ let A = 0;+ if (f !== null) {+ const y = f.array;+ A = f.version;+ for (let b = 0, E = y.length; b < E; b += 3) {+ const M = y[b + 0], w = y[b + 1], S = y[b + 2];+ d.push(M, w, w, S, S, M);+ }+ } else if (m !== void 0) {+ const y = m.array;+ A = m.version;+ for (let b = 0, E = y.length / 3 - 1; b < E; b += 3) {+ const M = b + 0, w = b + 1, S = b + 2;+ d.push(M, w, w, S, S, M);+ }+ } else+ return;+ const g = new (r0(d) ? u0 : h0)(d, 1);+ g.version = A;+ const p = r.get(u);+ p && e.remove(p), r.set(u, g);+ }+ function h(u) {+ const d = r.get(u);+ if (d) {+ const f = u.index;+ f !== null && d.version < f.version && l(u);+ } else+ l(u);+ return r.get(u);+ }+ return {+ get: o,+ update: c,+ getWireframeAttribute: h+ };+}+function qC(i, e, t) {+ let n;+ function s(d) {+ n = d;+ }+ let r, a;+ function o(d) {+ r = d.type, a = d.bytesPerElement;+ }+ function c(d, f) {+ i.drawElements(n, f, r, d * a), t.update(f, n, 1);+ }+ function l(d, f, m) {+ m !== 0 && (i.drawElementsInstanced(n, f, r, d * a, m), t.update(f, n, m));+ }+ function h(d, f, m) {+ if (m === 0) return;+ e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n, f, 0, r, d, 0, m);+ let g = 0;+ for (let p = 0; p < m; p++)+ g += f[p];+ t.update(g, n, 1);+ }+ function u(d, f, m, A) {+ if (m === 0) return;+ const g = e.get("WEBGL_multi_draw");+ if (g === null)+ for (let p = 0; p < d.length; p++)+ l(d[p] / a, f[p], A[p]);+ else {+ g.multiDrawElementsInstancedWEBGL(n, f, 0, r, d, 0, A, 0, m);+ let p = 0;+ for (let y = 0; y < m; y++)+ p += f[y] * A[y];+ t.update(p, n, 1);+ }+ }+ this.setMode = s, this.setIndex = o, this.render = c, this.renderInstances = l, this.renderMultiDraw = h, this.renderMultiDrawInstances = u;+}+function KC(i) {+ const e = {+ geometries: 0,+ textures: 0+ }, t = {+ frame: 0,+ calls: 0,+ triangles: 0,+ points: 0,+ lines: 0+ };+ function n(r, a, o) {+ switch (t.calls++, a) {+ case i.TRIANGLES:+ t.triangles += o * (r / 3);+ break;+ case i.LINES:+ t.lines += o * (r / 2);+ break;+ case i.LINE_STRIP:+ t.lines += o * (r - 1);+ break;+ case i.LINE_LOOP:+ t.lines += o * r;+ break;+ case i.POINTS:+ t.points += o * r;+ break;+ default:+ console.error("THREE.WebGLInfo: Unknown draw mode:", a);+ break;+ }+ }+ function s() {+ t.calls = 0, t.triangles = 0, t.points = 0, t.lines = 0;+ }+ return {+ memory: e,+ render: t,+ programs: null,+ autoReset: !0,+ reset: s,+ update: n+ };+}+function jC(i, e, t) {+ const n = /* @__PURE__ */ new WeakMap(), s = new wt();+ function r(a, o, c) {+ const l = a.morphTargetInfluences, h = o.morphAttributes.position || o.morphAttributes.normal || o.morphAttributes.color, u = h !== void 0 ? h.length : 0;+ let d = n.get(o);+ if (d === void 0 || d.count !== u) {+ let C = function() {+ S.dispose(), n.delete(o), o.removeEventListener("dispose", C);+ };+ d !== void 0 && d.texture.dispose();+ const f = o.morphAttributes.position !== void 0, m = o.morphAttributes.normal !== void 0, A = o.morphAttributes.color !== void 0, g = o.morphAttributes.position || [], p = o.morphAttributes.normal || [], y = o.morphAttributes.color || [];+ let b = 0;+ f === !0 && (b = 1), m === !0 && (b = 2), A === !0 && (b = 3);+ let E = o.attributes.position.count * b, M = 1;+ E > e.maxTextureSize && (M = Math.ceil(E / e.maxTextureSize), E = e.maxTextureSize);+ const w = new Float32Array(E * M * 4 * u), S = new a0(w, E, M, u);+ S.type = an, S.needsUpdate = !0;+ const T = b * 4;+ for (let v = 0; v < u; v++) {+ const F = g[v], K = p[v], q = y[v], $ = E * M * 4 * v;+ for (let D = 0; D < F.count; D++) {+ const O = D * T;+ f === !0 && (s.fromBufferAttribute(F, D), w[$ + O + 0] = s.x, w[$ + O + 1] = s.y, w[$ + O + 2] = s.z, w[$ + O + 3] = 0), m === !0 && (s.fromBufferAttribute(K, D), w[$ + O + 4] = s.x, w[$ + O + 5] = s.y, w[$ + O + 6] = s.z, w[$ + O + 7] = 0), A === !0 && (s.fromBufferAttribute(q, D), w[$ + O + 8] = s.x, w[$ + O + 9] = s.y, w[$ + O + 10] = s.z, w[$ + O + 11] = q.itemSize === 4 ? s.w : 1);+ }+ }+ d = {+ count: u,+ texture: S,+ size: new Ze(E, M)+ }, n.set(o, d), o.addEventListener("dispose", C);+ }+ if (a.isInstancedMesh === !0 && a.morphTexture !== null)+ c.getUniforms().setValue(i, "morphTexture", a.morphTexture, t);+ else {+ let f = 0;+ for (let A = 0; A < l.length; A++)+ f += l[A];+ const m = o.morphTargetsRelative ? 1 : 1 - f;+ c.getUniforms().setValue(i, "morphTargetBaseInfluence", m), c.getUniforms().setValue(i, "morphTargetInfluences", l);+ }+ c.getUniforms().setValue(i, "morphTargetsTexture", d.texture, t), c.getUniforms().setValue(i, "morphTargetsTextureSize", d.size);+ }+ return {+ update: r+ };+}+function XC(i, e, t, n) {+ let s = /* @__PURE__ */ new WeakMap();+ function r(c) {+ const l = n.render.frame, h = c.geometry, u = e.get(c, h);+ if (s.get(u) !== l && (e.update(u), s.set(u, l)), c.isInstancedMesh && (c.hasEventListener("dispose", o) === !1 && c.addEventListener("dispose", o), s.get(c) !== l && (t.update(c.instanceMatrix, i.ARRAY_BUFFER), c.instanceColor !== null && t.update(c.instanceColor, i.ARRAY_BUFFER), s.set(c, l))), c.isSkinnedMesh) {+ const d = c.skeleton;+ s.get(d) !== l && (d.update(), s.set(d, l));+ }+ return u;+ }+ function a() {+ s = /* @__PURE__ */ new WeakMap();+ }+ function o(c) {+ const l = c.target;+ l.removeEventListener("dispose", o), t.remove(l.instanceMatrix), l.instanceColor !== null && t.remove(l.instanceColor);+ }+ return {+ update: r,+ dispose: a+ };+}+const I0 = /* @__PURE__ */ new cn(), hA = /* @__PURE__ */ new m0(1, 1), M0 = /* @__PURE__ */ new a0(), B0 = /* @__PURE__ */ new o0(), T0 = /* @__PURE__ */ new p0(), uA = [], dA = [], fA = new Float32Array(16), pA = new Float32Array(9), AA = new Float32Array(4);+function Ga(i, e, t) {+ const n = i[0];+ if (n <= 0 || n > 0) return i;+ const s = e * t;+ let r = uA[s];+ if (r === void 0 && (r = new Float32Array(s), uA[s] = r), e !== 0) {+ n.toArray(r, 0);+ for (let a = 1, o = 0; a !== e; ++a)+ o += t, i[a].toArray(r, o);+ }+ return r;+}+function hn(i, e) {+ if (i.length !== e.length) return !1;+ for (let t = 0, n = i.length; t < n; t++)+ if (i[t] !== e[t]) return !1;+ return !0;+}+function un(i, e) {+ for (let t = 0, n = e.length; t < n; t++)+ i[t] = e[t];+}+function $l(i, e) {+ let t = dA[e];+ t === void 0 && (t = new Int32Array(e), dA[e] = t);+ for (let n = 0; n !== e; ++n)+ t[n] = i.allocateTextureUnit();+ return t;+}+function YC(i, e) {+ const t = this.cache;+ t[0] !== e && (i.uniform1f(this.addr, e), t[0] = e);+}+function JC(i, e) {+ const t = this.cache;+ if (e.x !== void 0)+ (t[0] !== e.x || t[1] !== e.y) && (i.uniform2f(this.addr, e.x, e.y), t[0] = e.x, t[1] = e.y);+ else {+ if (hn(t, e)) return;+ i.uniform2fv(this.addr, e), un(t, e);+ }+}+function ZC(i, e) {+ const t = this.cache;+ if (e.x !== void 0)+ (t[0] !== e.x || t[1] !== e.y || t[2] !== e.z) && (i.uniform3f(this.addr, e.x, e.y, e.z), t[0] = e.x, t[1] = e.y, t[2] = e.z);+ else if (e.r !== void 0)+ (t[0] !== e.r || t[1] !== e.g || t[2] !== e.b) && (i.uniform3f(this.addr, e.r, e.g, e.b), t[0] = e.r, t[1] = e.g, t[2] = e.b);+ else {+ if (hn(t, e)) return;+ i.uniform3fv(this.addr, e), un(t, e);+ }+}+function $C(i, e) {+ const t = this.cache;+ if (e.x !== void 0)+ (t[0] !== e.x || t[1] !== e.y || t[2] !== e.z || t[3] !== e.w) && (i.uniform4f(this.addr, e.x, e.y, e.z, e.w), t[0] = e.x, t[1] = e.y, t[2] = e.z, t[3] = e.w);+ else {+ if (hn(t, e)) return;+ i.uniform4fv(this.addr, e), un(t, e);+ }+}+function eS(i, e) {+ const t = this.cache, n = e.elements;+ if (n === void 0) {+ if (hn(t, e)) return;+ i.uniformMatrix2fv(this.addr, !1, e), un(t, e);+ } else {+ if (hn(t, n)) return;+ AA.set(n), i.uniformMatrix2fv(this.addr, !1, AA), un(t, n);+ }+}+function tS(i, e) {+ const t = this.cache, n = e.elements;+ if (n === void 0) {+ if (hn(t, e)) return;+ i.uniformMatrix3fv(this.addr, !1, e), un(t, e);+ } else {+ if (hn(t, n)) return;+ pA.set(n), i.uniformMatrix3fv(this.addr, !1, pA), un(t, n);+ }+}+function nS(i, e) {+ const t = this.cache, n = e.elements;+ if (n === void 0) {+ if (hn(t, e)) return;+ i.uniformMatrix4fv(this.addr, !1, e), un(t, e);+ } else {+ if (hn(t, n)) return;+ fA.set(n), i.uniformMatrix4fv(this.addr, !1, fA), un(t, n);+ }+}+function iS(i, e) {+ const t = this.cache;+ t[0] !== e && (i.uniform1i(this.addr, e), t[0] = e);+}+function sS(i, e) {+ const t = this.cache;+ if (e.x !== void 0)+ (t[0] !== e.x || t[1] !== e.y) && (i.uniform2i(this.addr, e.x, e.y), t[0] = e.x, t[1] = e.y);+ else {+ if (hn(t, e)) return;+ i.uniform2iv(this.addr, e), un(t, e);+ }+}+function rS(i, e) {+ const t = this.cache;+ if (e.x !== void 0)+ (t[0] !== e.x || t[1] !== e.y || t[2] !== e.z) && (i.uniform3i(this.addr, e.x, e.y, e.z), t[0] = e.x, t[1] = e.y, t[2] = e.z);+ else {+ if (hn(t, e)) return;+ i.uniform3iv(this.addr, e), un(t, e);+ }+}+function aS(i, e) {+ const t = this.cache;+ if (e.x !== void 0)+ (t[0] !== e.x || t[1] !== e.y || t[2] !== e.z || t[3] !== e.w) && (i.uniform4i(this.addr, e.x, e.y, e.z, e.w), t[0] = e.x, t[1] = e.y, t[2] = e.z, t[3] = e.w);+ else {+ if (hn(t, e)) return;+ i.uniform4iv(this.addr, e), un(t, e);+ }+}+function oS(i, e) {+ const t = this.cache;+ t[0] !== e && (i.uniform1ui(this.addr, e), t[0] = e);+}+function cS(i, e) {+ const t = this.cache;+ if (e.x !== void 0)+ (t[0] !== e.x || t[1] !== e.y) && (i.uniform2ui(this.addr, e.x, e.y), t[0] = e.x, t[1] = e.y);+ else {+ if (hn(t, e)) return;+ i.uniform2uiv(this.addr, e), un(t, e);+ }+}+function lS(i, e) {+ const t = this.cache;+ if (e.x !== void 0)+ (t[0] !== e.x || t[1] !== e.y || t[2] !== e.z) && (i.uniform3ui(this.addr, e.x, e.y, e.z), t[0] = e.x, t[1] = e.y, t[2] = e.z);+ else {+ if (hn(t, e)) return;+ i.uniform3uiv(this.addr, e), un(t, e);+ }+}+function hS(i, e) {+ const t = this.cache;+ if (e.x !== void 0)+ (t[0] !== e.x || t[1] !== e.y || t[2] !== e.z || t[3] !== e.w) && (i.uniform4ui(this.addr, e.x, e.y, e.z, e.w), t[0] = e.x, t[1] = e.y, t[2] = e.z, t[3] = e.w);+ else {+ if (hn(t, e)) return;+ i.uniform4uiv(this.addr, e), un(t, e);+ }+}+function uS(i, e, t) {+ const n = this.cache, s = t.allocateTextureUnit();+ n[0] !== s && (i.uniform1i(this.addr, s), n[0] = s);+ let r;+ this.type === i.SAMPLER_2D_SHADOW ? (hA.compareFunction = i0, r = hA) : r = I0, t.setTexture2D(e || r, s);+}+function dS(i, e, t) {+ const n = this.cache, s = t.allocateTextureUnit();+ n[0] !== s && (i.uniform1i(this.addr, s), n[0] = s), t.setTexture3D(e || B0, s);+}+function fS(i, e, t) {+ const n = this.cache, s = t.allocateTextureUnit();+ n[0] !== s && (i.uniform1i(this.addr, s), n[0] = s), t.setTextureCube(e || T0, s);+}+function pS(i, e, t) {+ const n = this.cache, s = t.allocateTextureUnit();+ n[0] !== s && (i.uniform1i(this.addr, s), n[0] = s), t.setTexture2DArray(e || M0, s);+}+function AS(i) {+ switch (i) {+ case 5126:+ return YC;+ // FLOAT+ case 35664:+ return JC;+ // _VEC2+ case 35665:+ return ZC;+ // _VEC3+ case 35666:+ return $C;+ // _VEC4+ case 35674:+ return eS;+ // _MAT2+ case 35675:+ return tS;+ // _MAT3+ case 35676:+ return nS;+ // _MAT4+ case 5124:+ case 35670:+ return iS;+ // INT, BOOL+ case 35667:+ case 35671:+ return sS;+ // _VEC2+ case 35668:+ case 35672:+ return rS;+ // _VEC3+ case 35669:+ case 35673:+ return aS;+ // _VEC4+ case 5125:+ return oS;+ // UINT+ case 36294:+ return cS;+ // _VEC2+ case 36295:+ return lS;+ // _VEC3+ case 36296:+ return hS;+ // _VEC4+ case 35678:+ // SAMPLER_2D+ case 36198:+ // SAMPLER_EXTERNAL_OES+ case 36298:+ // INT_SAMPLER_2D+ case 36306:+ // UNSIGNED_INT_SAMPLER_2D+ case 35682:+ return uS;+ case 35679:+ // SAMPLER_3D+ case 36299:+ // INT_SAMPLER_3D+ case 36307:+ return dS;+ case 35680:+ // SAMPLER_CUBE+ case 36300:+ // INT_SAMPLER_CUBE+ case 36308:+ // UNSIGNED_INT_SAMPLER_CUBE+ case 36293:+ return fS;+ case 36289:+ // SAMPLER_2D_ARRAY+ case 36303:+ // INT_SAMPLER_2D_ARRAY+ case 36311:+ // UNSIGNED_INT_SAMPLER_2D_ARRAY+ case 36292:+ return pS;+ }+}+function gS(i, e) {+ i.uniform1fv(this.addr, e);+}+function mS(i, e) {+ const t = Ga(e, this.size, 2);+ i.uniform2fv(this.addr, t);+}+function bS(i, e) {+ const t = Ga(e, this.size, 3);+ i.uniform3fv(this.addr, t);+}+function xS(i, e) {+ const t = Ga(e, this.size, 4);+ i.uniform4fv(this.addr, t);+}+function _S(i, e) {+ const t = Ga(e, this.size, 4);+ i.uniformMatrix2fv(this.addr, !1, t);+}+function ES(i, e) {+ const t = Ga(e, this.size, 9);+ i.uniformMatrix3fv(this.addr, !1, t);+}+function yS(i, e) {+ const t = Ga(e, this.size, 16);+ i.uniformMatrix4fv(this.addr, !1, t);+}+function wS(i, e) {+ i.uniform1iv(this.addr, e);+}+function vS(i, e) {+ i.uniform2iv(this.addr, e);+}+function CS(i, e) {+ i.uniform3iv(this.addr, e);+}+function SS(i, e) {+ i.uniform4iv(this.addr, e);+}+function IS(i, e) {+ i.uniform1uiv(this.addr, e);+}+function MS(i, e) {+ i.uniform2uiv(this.addr, e);+}+function BS(i, e) {+ i.uniform3uiv(this.addr, e);+}+function TS(i, e) {+ i.uniform4uiv(this.addr, e);+}+function RS(i, e, t) {+ const n = this.cache, s = e.length, r = $l(t, s);+ hn(n, r) || (i.uniform1iv(this.addr, r), un(n, r));+ for (let a = 0; a !== s; ++a)+ t.setTexture2D(e[a] || I0, r[a]);+}+function NS(i, e, t) {+ const n = this.cache, s = e.length, r = $l(t, s);+ hn(n, r) || (i.uniform1iv(this.addr, r), un(n, r));+ for (let a = 0; a !== s; ++a)+ t.setTexture3D(e[a] || B0, r[a]);+}+function FS(i, e, t) {+ const n = this.cache, s = e.length, r = $l(t, s);+ hn(n, r) || (i.uniform1iv(this.addr, r), un(n, r));+ for (let a = 0; a !== s; ++a)+ t.setTextureCube(e[a] || T0, r[a]);+}+function DS(i, e, t) {+ const n = this.cache, s = e.length, r = $l(t, s);+ hn(n, r) || (i.uniform1iv(this.addr, r), un(n, r));+ for (let a = 0; a !== s; ++a)+ t.setTexture2DArray(e[a] || M0, r[a]);+}+function LS(i) {+ switch (i) {+ case 5126:+ return gS;+ // FLOAT+ case 35664:+ return mS;+ // _VEC2+ case 35665:+ return bS;+ // _VEC3+ case 35666:+ return xS;+ // _VEC4+ case 35674:+ return _S;+ // _MAT2+ case 35675:+ return ES;+ // _MAT3+ case 35676:+ return yS;+ // _MAT4+ case 5124:+ case 35670:+ return wS;+ // INT, BOOL+ case 35667:+ case 35671:+ return vS;+ // _VEC2+ case 35668:+ case 35672:+ return CS;+ // _VEC3+ case 35669:+ case 35673:+ return SS;+ // _VEC4+ case 5125:+ return IS;+ // UINT+ case 36294:+ return MS;+ // _VEC2+ case 36295:+ return BS;+ // _VEC3+ case 36296:+ return TS;+ // _VEC4+ case 35678:+ // SAMPLER_2D+ case 36198:+ // SAMPLER_EXTERNAL_OES+ case 36298:+ // INT_SAMPLER_2D+ case 36306:+ // UNSIGNED_INT_SAMPLER_2D+ case 35682:+ return RS;+ case 35679:+ // SAMPLER_3D+ case 36299:+ // INT_SAMPLER_3D+ case 36307:+ return NS;+ case 35680:+ // SAMPLER_CUBE+ case 36300:+ // INT_SAMPLER_CUBE+ case 36308:+ // UNSIGNED_INT_SAMPLER_CUBE+ case 36293:+ return FS;+ case 36289:+ // SAMPLER_2D_ARRAY+ case 36303:+ // INT_SAMPLER_2D_ARRAY+ case 36311:+ // UNSIGNED_INT_SAMPLER_2D_ARRAY+ case 36292:+ return DS;+ }+}+class PS {+ constructor(e, t, n) {+ this.id = e, this.addr = n, this.cache = [], this.type = t.type, this.setValue = AS(t.type);+ }+}+class kS {+ constructor(e, t, n) {+ this.id = e, this.addr = n, this.cache = [], this.type = t.type, this.size = t.size, this.setValue = LS(t.type);+ }+}+class US {+ constructor(e) {+ this.id = e, this.seq = [], this.map = {};+ }+ setValue(e, t, n) {+ const s = this.seq;+ for (let r = 0, a = s.length; r !== a; ++r) {+ const o = s[r];+ o.setValue(e, t[o.id], n);+ }+ }+}+const $h = /(\w+)(\])?(\[|\.)?/g;+function gA(i, e) {+ i.seq.push(e), i.map[e.id] = e;+}+function OS(i, e, t) {+ const n = i.name, s = n.length;+ for ($h.lastIndex = 0; ; ) {+ const r = $h.exec(n), a = $h.lastIndex;+ let o = r[1];+ const c = r[2] === "]", l = r[3];+ if (c && (o = o | 0), l === void 0 || l === "[" && a + 2 === s) {+ gA(t, l === void 0 ? new PS(o, i, e) : new kS(o, i, e));+ break;+ } else {+ let u = t.map[o];+ u === void 0 && (u = new US(o), gA(t, u)), t = u;+ }+ }+}+class Al {+ constructor(e, t) {+ this.seq = [], this.map = {};+ const n = e.getProgramParameter(t, e.ACTIVE_UNIFORMS);+ for (let s = 0; s < n; ++s) {+ const r = e.getActiveUniform(t, s), a = e.getUniformLocation(t, r.name);+ OS(r, a, this);+ }+ }+ setValue(e, t, n, s) {+ const r = this.map[t];+ r !== void 0 && r.setValue(e, n, s);+ }+ setOptional(e, t, n) {+ const s = t[n];+ s !== void 0 && this.setValue(e, n, s);+ }+ static upload(e, t, n, s) {+ for (let r = 0, a = t.length; r !== a; ++r) {+ const o = t[r], c = n[o.id];+ c.needsUpdate !== !1 && o.setValue(e, c.value, s);+ }+ }+ static seqWithValue(e, t) {+ const n = [];+ for (let s = 0, r = e.length; s !== r; ++s) {+ const a = e[s];+ a.id in t && n.push(a);+ }+ return n;+ }+}+function mA(i, e, t) {+ const n = i.createShader(e);+ return i.shaderSource(n, t), i.compileShader(n), n;+}+const QS = 37297;+let GS = 0;+function HS(i, e) {+ const t = i.split(`+`), n = [], s = Math.max(e - 6, 0), r = Math.min(e + 6, t.length);+ for (let a = s; a < r; a++) {+ const o = a + 1;+ n.push(`${o === e ? ">" : " "} ${o}: ${t[a]}`);+ }+ return n.join(`+`);+}+const bA = /* @__PURE__ */ new rt();+function zS(i) {+ mt._getMatrix(bA, mt.workingColorSpace, i);+ const e = `mat3( ${bA.elements.map((t) => t.toFixed(4))} )`;+ switch (mt.getTransfer(i)) {+ case Bl:+ return [e, "LinearTransferOETF"];+ case Mt:+ return [e, "sRGBTransferOETF"];+ default:+ return console.warn("THREE.WebGLProgram: Unsupported color space: ", i), [e, "LinearTransferOETF"];+ }+}+function xA(i, e, t) {+ const n = i.getShaderParameter(e, i.COMPILE_STATUS), s = i.getShaderInfoLog(e).trim();+ if (n && s === "") return "";+ const r = /ERROR: 0:(\d+)/.exec(s);+ if (r) {+ const a = parseInt(r[1]);+ return t.toUpperCase() + `++` + s + `++` + HS(i.getShaderSource(e), a);+ } else+ return s;+}+function VS(i, e) {+ const t = zS(e);+ return [+ `vec4 ${i}( vec4 value ) {`,+ ` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,+ "}"+ ].join(`+`);+}+function WS(i, e) {+ let t;+ switch (e) {+ case Ju:+ t = "Linear";+ break;+ case K_:+ t = "Reinhard";+ break;+ case j_:+ t = "Cineon";+ break;+ case Vm:+ t = "ACESFilmic";+ break;+ case Y_:+ t = "AgX";+ break;+ case J_:+ t = "Neutral";+ break;+ case X_:+ t = "Custom";+ break;+ default:+ console.warn("THREE.WebGLProgram: Unsupported toneMapping:", e), t = "Linear";+ }+ return "vec3 " + i + "( vec3 color ) { return " + t + "ToneMapping( color ); }";+}+const Qc = /* @__PURE__ */ new H();+function qS() {+ mt.getLuminanceCoefficients(Qc);+ const i = Qc.x.toFixed(4), e = Qc.y.toFixed(4), t = Qc.z.toFixed(4);+ return [+ "float luminance( const in vec3 rgb ) {",+ ` const vec3 weights = vec3( ${i}, ${e}, ${t} );`,+ " return dot( weights, rgb );",+ "}"+ ].join(`+`);+}+function KS(i) {+ return [+ i.extensionClipCullDistance ? "#extension GL_ANGLE_clip_cull_distance : require" : "",+ i.extensionMultiDraw ? "#extension GL_ANGLE_multi_draw : require" : ""+ ].filter(po).join(`+`);+}+function jS(i) {+ const e = [];+ for (const t in i) {+ const n = i[t];+ n !== !1 && e.push("#define " + t + " " + n);+ }+ return e.join(`+`);+}+function XS(i, e) {+ const t = {}, n = i.getProgramParameter(e, i.ACTIVE_ATTRIBUTES);+ for (let s = 0; s < n; s++) {+ const r = i.getActiveAttrib(e, s), a = r.name;+ let o = 1;+ r.type === i.FLOAT_MAT2 && (o = 2), r.type === i.FLOAT_MAT3 && (o = 3), r.type === i.FLOAT_MAT4 && (o = 4), t[a] = {+ type: r.type,+ location: i.getAttribLocation(e, a),+ locationSize: o+ };+ }+ return t;+}+function po(i) {+ return i !== "";+}+function _A(i, e) {+ const t = e.numSpotLightShadows + e.numSpotLightMaps - e.numSpotLightShadowsWithMaps;+ return i.replace(/NUM_DIR_LIGHTS/g, e.numDirLights).replace(/NUM_SPOT_LIGHTS/g, e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g, e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g, t).replace(/NUM_RECT_AREA_LIGHTS/g, e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g, e.numPointLights).replace(/NUM_HEMI_LIGHTS/g, e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g, e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g, e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g, e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g, e.numPointLightShadows);+}+function EA(i, e) {+ return i.replace(/NUM_CLIPPING_PLANES/g, e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g, e.numClippingPlanes - e.numClipIntersection);+}+const YS = /^[ \t]*#include +<([\w\d./]+)>/gm;+function vd(i) {+ return i.replace(YS, ZS);+}+const JS = /* @__PURE__ */ new Map();+function ZS(i, e) {+ let t = ot[e];+ if (t === void 0) {+ const n = JS.get(e);+ if (n !== void 0)+ t = ot[n], console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.', e, n);+ else+ throw new Error("Can not resolve #include <" + e + ">");+ }+ return vd(t);+}+const $S = /#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 yA(i) {+ return i.replace($S, eI);+}+function eI(i, e, t, n) {+ let s = "";+ for (let r = parseInt(e); r < parseInt(t); r++)+ s += n.replace(/\[\s*i\s*\]/g, "[ " + r + " ]").replace(/UNROLLED_LOOP_INDEX/g, r);+ return s;+}+function wA(i) {+ let e = `precision ${i.precision} float;+ precision ${i.precision} int;+ precision ${i.precision} sampler2D;+ precision ${i.precision} samplerCube;+ precision ${i.precision} sampler3D;+ precision ${i.precision} sampler2DArray;+ precision ${i.precision} sampler2DShadow;+ precision ${i.precision} samplerCubeShadow;+ precision ${i.precision} sampler2DArrayShadow;+ precision ${i.precision} isampler2D;+ precision ${i.precision} isampler3D;+ precision ${i.precision} isamplerCube;+ precision ${i.precision} isampler2DArray;+ precision ${i.precision} usampler2D;+ precision ${i.precision} usampler3D;+ precision ${i.precision} usamplerCube;+ precision ${i.precision} usampler2DArray;+ `;+ return i.precision === "highp" ? e += `+#define HIGH_PRECISION` : i.precision === "mediump" ? e += `+#define MEDIUM_PRECISION` : i.precision === "lowp" && (e += `+#define LOW_PRECISION`), e;+}+function tI(i) {+ let e = "SHADOWMAP_TYPE_BASIC";+ return i.shadowMapType === Hm ? e = "SHADOWMAP_TYPE_PCF" : i.shadowMapType === S_ ? e = "SHADOWMAP_TYPE_PCF_SOFT" : i.shadowMapType === ji && (e = "SHADOWMAP_TYPE_VSM"), e;+}+function nI(i) {+ let e = "ENVMAP_TYPE_CUBE";+ if (i.envMap)+ switch (i.envMapMode) {+ case Er:+ case va:+ e = "ENVMAP_TYPE_CUBE";+ break;+ case jl:+ e = "ENVMAP_TYPE_CUBE_UV";+ break;+ }+ return e;+}+function iI(i) {+ let e = "ENVMAP_MODE_REFLECTION";+ return i.envMap && i.envMapMode === va && (e = "ENVMAP_MODE_REFRACTION"), e;+}+function sI(i) {+ let e = "ENVMAP_BLENDING_NONE";+ if (i.envMap)+ switch (i.combine) {+ case zm:+ e = "ENVMAP_BLENDING_MULTIPLY";+ break;+ case W_:+ e = "ENVMAP_BLENDING_MIX";+ break;+ case q_:+ e = "ENVMAP_BLENDING_ADD";+ break;+ }+ return e;+}+function rI(i) {+ const e = i.envMapCubeUVHeight;+ if (e === null) return null;+ const t = Math.log2(e) - 2, n = 1 / e;+ return { texelWidth: 1 / (3 * Math.max(Math.pow(2, t), 112)), texelHeight: n, maxMip: t };+}+function aI(i, e, t, n) {+ const s = i.getContext(), r = t.defines;+ let a = t.vertexShader, o = t.fragmentShader;+ const c = tI(t), l = nI(t), h = iI(t), u = sI(t), d = rI(t), f = KS(t), m = jS(r), A = s.createProgram();+ let g, p, y = t.glslVersion ? "#version " + t.glslVersion + `+` : "";+ t.isRawShaderMaterial ? (g = [+ "#define SHADER_TYPE " + t.shaderType,+ "#define SHADER_NAME " + t.shaderName,+ m+ ].filter(po).join(`+`), g.length > 0 && (g += `+`), p = [+ "#define SHADER_TYPE " + t.shaderType,+ "#define SHADER_NAME " + t.shaderName,+ m+ ].filter(po).join(`+`), p.length > 0 && (p += `+`)) : (g = [+ wA(t),+ "#define SHADER_TYPE " + t.shaderType,+ "#define SHADER_NAME " + t.shaderName,+ m,+ t.extensionClipCullDistance ? "#define USE_CLIP_DISTANCE" : "",+ t.batching ? "#define USE_BATCHING" : "",+ t.batchingColor ? "#define USE_BATCHING_COLOR" : "",+ t.instancing ? "#define USE_INSTANCING" : "",+ t.instancingColor ? "#define USE_INSTANCING_COLOR" : "",+ t.instancingMorph ? "#define USE_INSTANCING_MORPH" : "",+ t.useFog && t.fog ? "#define USE_FOG" : "",+ t.useFog && t.fogExp2 ? "#define FOG_EXP2" : "",+ t.map ? "#define USE_MAP" : "",+ t.envMap ? "#define USE_ENVMAP" : "",+ t.envMap ? "#define " + h : "",+ t.lightMap ? "#define USE_LIGHTMAP" : "",+ t.aoMap ? "#define USE_AOMAP" : "",+ t.bumpMap ? "#define USE_BUMPMAP" : "",+ t.normalMap ? "#define USE_NORMALMAP" : "",+ t.normalMapObjectSpace ? "#define USE_NORMALMAP_OBJECTSPACE" : "",+ t.normalMapTangentSpace ? "#define USE_NORMALMAP_TANGENTSPACE" : "",+ t.displacementMap ? "#define USE_DISPLACEMENTMAP" : "",+ t.emissiveMap ? "#define USE_EMISSIVEMAP" : "",+ t.anisotropy ? "#define USE_ANISOTROPY" : "",+ t.anisotropyMap ? "#define USE_ANISOTROPYMAP" : "",+ t.clearcoatMap ? "#define USE_CLEARCOATMAP" : "",+ t.clearcoatRoughnessMap ? "#define USE_CLEARCOAT_ROUGHNESSMAP" : "",+ t.clearcoatNormalMap ? "#define USE_CLEARCOAT_NORMALMAP" : "",+ t.iridescenceMap ? "#define USE_IRIDESCENCEMAP" : "",+ t.iridescenceThicknessMap ? "#define USE_IRIDESCENCE_THICKNESSMAP" : "",+ t.specularMap ? "#define USE_SPECULARMAP" : "",+ t.specularColorMap ? "#define USE_SPECULAR_COLORMAP" : "",+ t.specularIntensityMap ? "#define USE_SPECULAR_INTENSITYMAP" : "",+ t.roughnessMap ? "#define USE_ROUGHNESSMAP" : "",+ t.metalnessMap ? "#define USE_METALNESSMAP" : "",+ t.alphaMap ? "#define USE_ALPHAMAP" : "",+ t.alphaHash ? "#define USE_ALPHAHASH" : "",+ t.transmission ? "#define USE_TRANSMISSION" : "",+ t.transmissionMap ? "#define USE_TRANSMISSIONMAP" : "",+ t.thicknessMap ? "#define USE_THICKNESSMAP" : "",+ t.sheenColorMap ? "#define USE_SHEEN_COLORMAP" : "",+ t.sheenRoughnessMap ? "#define USE_SHEEN_ROUGHNESSMAP" : "",+ //+ t.mapUv ? "#define MAP_UV " + t.mapUv : "",+ t.alphaMapUv ? "#define ALPHAMAP_UV " + t.alphaMapUv : "",+ t.lightMapUv ? "#define LIGHTMAP_UV " + t.lightMapUv : "",+ t.aoMapUv ? "#define AOMAP_UV " + t.aoMapUv : "",+ t.emissiveMapUv ? "#define EMISSIVEMAP_UV " + t.emissiveMapUv : "",+ t.bumpMapUv ? "#define BUMPMAP_UV " + t.bumpMapUv : "",+ t.normalMapUv ? "#define NORMALMAP_UV " + t.normalMapUv : "",+ t.displacementMapUv ? "#define DISPLACEMENTMAP_UV " + t.displacementMapUv : "",+ t.metalnessMapUv ? "#define METALNESSMAP_UV " + t.metalnessMapUv : "",+ t.roughnessMapUv ? "#define ROUGHNESSMAP_UV " + t.roughnessMapUv : "",+ t.anisotropyMapUv ? "#define ANISOTROPYMAP_UV " + t.anisotropyMapUv : "",+ t.clearcoatMapUv ? "#define CLEARCOATMAP_UV " + t.clearcoatMapUv : "",+ t.clearcoatNormalMapUv ? "#define CLEARCOAT_NORMALMAP_UV " + t.clearcoatNormalMapUv : "",+ t.clearcoatRoughnessMapUv ? "#define CLEARCOAT_ROUGHNESSMAP_UV " + t.clearcoatRoughnessMapUv : "",+ t.iridescenceMapUv ? "#define IRIDESCENCEMAP_UV " + t.iridescenceMapUv : "",+ t.iridescenceThicknessMapUv ? "#define IRIDESCENCE_THICKNESSMAP_UV " + t.iridescenceThicknessMapUv : "",+ t.sheenColorMapUv ? "#define SHEEN_COLORMAP_UV " + t.sheenColorMapUv : "",+ t.sheenRoughnessMapUv ? "#define SHEEN_ROUGHNESSMAP_UV " + t.sheenRoughnessMapUv : "",+ t.specularMapUv ? "#define SPECULARMAP_UV " + t.specularMapUv : "",+ t.specularColorMapUv ? "#define SPECULAR_COLORMAP_UV " + t.specularColorMapUv : "",+ t.specularIntensityMapUv ? "#define SPECULAR_INTENSITYMAP_UV " + t.specularIntensityMapUv : "",+ t.transmissionMapUv ? "#define TRANSMISSIONMAP_UV " + t.transmissionMapUv : "",+ t.thicknessMapUv ? "#define THICKNESSMAP_UV " + t.thicknessMapUv : "",+ //+ t.vertexTangents && t.flatShading === !1 ? "#define USE_TANGENT" : "",+ t.vertexColors ? "#define USE_COLOR" : "",+ t.vertexAlphas ? "#define USE_COLOR_ALPHA" : "",+ t.vertexUv1s ? "#define USE_UV1" : "",+ t.vertexUv2s ? "#define USE_UV2" : "",+ t.vertexUv3s ? "#define USE_UV3" : "",+ t.pointsUvs ? "#define USE_POINTS_UV" : "",+ t.flatShading ? "#define FLAT_SHADED" : "",+ t.skinning ? "#define USE_SKINNING" : "",+ t.morphTargets ? "#define USE_MORPHTARGETS" : "",+ t.morphNormals && t.flatShading === !1 ? "#define USE_MORPHNORMALS" : "",+ t.morphColors ? "#define USE_MORPHCOLORS" : "",+ t.morphTargetsCount > 0 ? "#define MORPHTARGETS_TEXTURE_STRIDE " + t.morphTextureStride : "",+ t.morphTargetsCount > 0 ? "#define MORPHTARGETS_COUNT " + t.morphTargetsCount : "",+ t.doubleSided ? "#define DOUBLE_SIDED" : "",+ t.flipSided ? "#define FLIP_SIDED" : "",+ t.shadowMapEnabled ? "#define USE_SHADOWMAP" : "",+ t.shadowMapEnabled ? "#define " + c : "",+ t.sizeAttenuation ? "#define USE_SIZEATTENUATION" : "",+ t.numLightProbes > 0 ? "#define USE_LIGHT_PROBES" : "",+ t.logarithmicDepthBuffer ? "#define USE_LOGDEPTHBUF" : "",+ t.reverseDepthBuffer ? "#define USE_REVERSEDEPTHBUF" : "",+ "uniform mat4 modelMatrix;",+ "uniform mat4 modelViewMatrix;",+ "uniform mat4 projectionMatrix;",+ "uniform mat4 viewMatrix;",+ "uniform mat3 normalMatrix;",+ "uniform vec3 cameraPosition;",+ "uniform bool isOrthographic;",+ "#ifdef USE_INSTANCING",+ " attribute mat4 instanceMatrix;",+ "#endif",+ "#ifdef USE_INSTANCING_COLOR",+ " attribute vec3 instanceColor;",+ "#endif",+ "#ifdef USE_INSTANCING_MORPH",+ " uniform sampler2D morphTexture;",+ "#endif",+ "attribute vec3 position;",+ "attribute vec3 normal;",+ "attribute vec2 uv;",+ "#ifdef USE_UV1",+ " attribute vec2 uv1;",+ "#endif",+ "#ifdef USE_UV2",+ " attribute vec2 uv2;",+ "#endif",+ "#ifdef USE_UV3",+ " attribute vec2 uv3;",+ "#endif",+ "#ifdef USE_TANGENT",+ " attribute vec4 tangent;",+ "#endif",+ "#if defined( USE_COLOR_ALPHA )",+ " attribute vec4 color;",+ "#elif defined( USE_COLOR )",+ " attribute vec3 color;",+ "#endif",+ "#ifdef USE_SKINNING",+ " attribute vec4 skinIndex;",+ " attribute vec4 skinWeight;",+ "#endif",+ `+`+ ].filter(po).join(`+`), p = [+ wA(t),+ "#define SHADER_TYPE " + t.shaderType,+ "#define SHADER_NAME " + t.shaderName,+ m,+ t.useFog && t.fog ? "#define USE_FOG" : "",+ t.useFog && t.fogExp2 ? "#define FOG_EXP2" : "",+ t.alphaToCoverage ? "#define ALPHA_TO_COVERAGE" : "",+ t.map ? "#define USE_MAP" : "",+ t.matcap ? "#define USE_MATCAP" : "",+ t.envMap ? "#define USE_ENVMAP" : "",+ t.envMap ? "#define " + l : "",+ t.envMap ? "#define " + h : "",+ t.envMap ? "#define " + u : "",+ d ? "#define CUBEUV_TEXEL_WIDTH " + d.texelWidth : "",+ d ? "#define CUBEUV_TEXEL_HEIGHT " + d.texelHeight : "",+ d ? "#define CUBEUV_MAX_MIP " + d.maxMip + ".0" : "",+ t.lightMap ? "#define USE_LIGHTMAP" : "",+ t.aoMap ? "#define USE_AOMAP" : "",+ t.bumpMap ? "#define USE_BUMPMAP" : "",+ t.normalMap ? "#define USE_NORMALMAP" : "",+ t.normalMapObjectSpace ? "#define USE_NORMALMAP_OBJECTSPACE" : "",+ t.normalMapTangentSpace ? "#define USE_NORMALMAP_TANGENTSPACE" : "",+ t.emissiveMap ? "#define USE_EMISSIVEMAP" : "",+ t.anisotropy ? "#define USE_ANISOTROPY" : "",+ t.anisotropyMap ? "#define USE_ANISOTROPYMAP" : "",+ t.clearcoat ? "#define USE_CLEARCOAT" : "",+ t.clearcoatMap ? "#define USE_CLEARCOATMAP" : "",+ t.clearcoatRoughnessMap ? "#define USE_CLEARCOAT_ROUGHNESSMAP" : "",+ t.clearcoatNormalMap ? "#define USE_CLEARCOAT_NORMALMAP" : "",+ t.dispersion ? "#define USE_DISPERSION" : "",+ t.iridescence ? "#define USE_IRIDESCENCE" : "",+ t.iridescenceMap ? "#define USE_IRIDESCENCEMAP" : "",+ t.iridescenceThicknessMap ? "#define USE_IRIDESCENCE_THICKNESSMAP" : "",+ t.specularMap ? "#define USE_SPECULARMAP" : "",+ t.specularColorMap ? "#define USE_SPECULAR_COLORMAP" : "",+ t.specularIntensityMap ? "#define USE_SPECULAR_INTENSITYMAP" : "",+ t.roughnessMap ? "#define USE_ROUGHNESSMAP" : "",+ t.metalnessMap ? "#define USE_METALNESSMAP" : "",+ t.alphaMap ? "#define USE_ALPHAMAP" : "",+ t.alphaTest ? "#define USE_ALPHATEST" : "",+ t.alphaHash ? "#define USE_ALPHAHASH" : "",+ t.sheen ? "#define USE_SHEEN" : "",+ t.sheenColorMap ? "#define USE_SHEEN_COLORMAP" : "",+ t.sheenRoughnessMap ? "#define USE_SHEEN_ROUGHNESSMAP" : "",+ t.transmission ? "#define USE_TRANSMISSION" : "",+ t.transmissionMap ? "#define USE_TRANSMISSIONMAP" : "",+ t.thicknessMap ? "#define USE_THICKNESSMAP" : "",+ t.vertexTangents && t.flatShading === !1 ? "#define USE_TANGENT" : "",+ t.vertexColors || t.instancingColor || t.batchingColor ? "#define USE_COLOR" : "",+ t.vertexAlphas ? "#define USE_COLOR_ALPHA" : "",+ t.vertexUv1s ? "#define USE_UV1" : "",+ t.vertexUv2s ? "#define USE_UV2" : "",+ t.vertexUv3s ? "#define USE_UV3" : "",+ t.pointsUvs ? "#define USE_POINTS_UV" : "",+ t.gradientMap ? "#define USE_GRADIENTMAP" : "",+ t.flatShading ? "#define FLAT_SHADED" : "",+ t.doubleSided ? "#define DOUBLE_SIDED" : "",+ t.flipSided ? "#define FLIP_SIDED" : "",+ t.shadowMapEnabled ? "#define USE_SHADOWMAP" : "",+ t.shadowMapEnabled ? "#define " + c : "",+ t.premultipliedAlpha ? "#define PREMULTIPLIED_ALPHA" : "",+ t.numLightProbes > 0 ? "#define USE_LIGHT_PROBES" : "",+ t.decodeVideoTexture ? "#define DECODE_VIDEO_TEXTURE" : "",+ t.decodeVideoTextureEmissive ? "#define DECODE_VIDEO_TEXTURE_EMISSIVE" : "",+ t.logarithmicDepthBuffer ? "#define USE_LOGDEPTHBUF" : "",+ t.reverseDepthBuffer ? "#define USE_REVERSEDEPTHBUF" : "",+ "uniform mat4 viewMatrix;",+ "uniform vec3 cameraPosition;",+ "uniform bool isOrthographic;",+ t.toneMapping !== Ls ? "#define TONE_MAPPING" : "",+ t.toneMapping !== Ls ? ot.tonemapping_pars_fragment : "",+ // this code is required here because it is used by the toneMapping() function defined below+ t.toneMapping !== Ls ? WS("toneMapping", t.toneMapping) : "",+ t.dithering ? "#define DITHERING" : "",+ t.opaque ? "#define OPAQUE" : "",+ ot.colorspace_pars_fragment,+ // this code is required here because it is used by the various encoding/decoding function defined below+ VS("linearToOutputTexel", t.outputColorSpace),+ qS(),+ t.useDepthPacking ? "#define DEPTH_PACKING " + t.depthPacking : "",+ `+`+ ].filter(po).join(`+`)), a = vd(a), a = _A(a, t), a = EA(a, t), o = vd(o), o = _A(o, t), o = EA(o, t), a = yA(a), o = yA(o), t.isRawShaderMaterial !== !0 && (y = `#version 300 es+`, g = [+ f,+ "#define attribute in",+ "#define varying out",+ "#define texture2D texture"+ ].join(`+`) + `+` + g, p = [+ "#define varying in",+ t.glslVersion === mp ? "" : "layout(location = 0) out highp vec4 pc_fragColor;",+ t.glslVersion === mp ? "" : "#define gl_FragColor pc_fragColor",+ "#define gl_FragDepthEXT gl_FragDepth",+ "#define texture2D texture",+ "#define textureCube texture",+ "#define texture2DProj textureProj",+ "#define texture2DLodEXT textureLod",+ "#define texture2DProjLodEXT textureProjLod",+ "#define textureCubeLodEXT textureLod",+ "#define texture2DGradEXT textureGrad",+ "#define texture2DProjGradEXT textureProjGrad",+ "#define textureCubeGradEXT textureGrad"+ ].join(`+`) + `+` + p);+ const b = y + g + a, E = y + p + o, M = mA(s, s.VERTEX_SHADER, b), w = mA(s, s.FRAGMENT_SHADER, E);+ s.attachShader(A, M), s.attachShader(A, w), t.index0AttributeName !== void 0 ? s.bindAttribLocation(A, 0, t.index0AttributeName) : t.morphTargets === !0 && s.bindAttribLocation(A, 0, "position"), s.linkProgram(A);+ function S(F) {+ if (i.debug.checkShaderErrors) {+ const K = s.getProgramInfoLog(A).trim(), q = s.getShaderInfoLog(M).trim(), $ = s.getShaderInfoLog(w).trim();+ let D = !0, O = !0;+ if (s.getProgramParameter(A, s.LINK_STATUS) === !1)+ if (D = !1, typeof i.debug.onShaderError == "function")+ i.debug.onShaderError(s, A, M, w);+ else {+ const Y = xA(s, M, "vertex"), Q = xA(s, w, "fragment");+ console.error(+ "THREE.WebGLProgram: Shader Error " + s.getError() + " - VALIDATE_STATUS " + s.getProgramParameter(A, s.VALIDATE_STATUS) + `++Material Name: ` + F.name + `+Material Type: ` + F.type + `++Program Info Log: ` + K + `+` + Y + `+` + Q+ );+ }+ else K !== "" ? console.warn("THREE.WebGLProgram: Program Info Log:", K) : (q === "" || $ === "") && (O = !1);+ O && (F.diagnostics = {+ runnable: D,+ programLog: K,+ vertexShader: {+ log: q,+ prefix: g+ },+ fragmentShader: {+ log: $,+ prefix: p+ }+ });+ }+ s.deleteShader(M), s.deleteShader(w), T = new Al(s, A), C = XS(s, A);+ }+ let T;+ this.getUniforms = function() {+ return T === void 0 && S(this), T;+ };+ let C;+ this.getAttributes = function() {+ return C === void 0 && S(this), C;+ };+ let v = t.rendererExtensionParallelShaderCompile === !1;+ return this.isReady = function() {+ return v === !1 && (v = s.getProgramParameter(A, QS)), v;+ }, this.destroy = function() {+ n.releaseStatesOfProgram(this), s.deleteProgram(A), this.program = void 0;+ }, this.type = t.shaderType, this.name = t.shaderName, this.id = GS++, this.cacheKey = e, this.usedTimes = 1, this.program = A, this.vertexShader = M, this.fragmentShader = w, this;+}+let oI = 0;+class cI {+ constructor() {+ this.shaderCache = /* @__PURE__ */ new Map(), this.materialCache = /* @__PURE__ */ new Map();+ }+ update(e) {+ const t = e.vertexShader, n = e.fragmentShader, s = this._getShaderStage(t), r = this._getShaderStage(n), a = this._getShaderCacheForMaterial(e);+ return a.has(s) === !1 && (a.add(s), s.usedTimes++), a.has(r) === !1 && (a.add(r), r.usedTimes++), this;+ }+ remove(e) {+ const t = this.materialCache.get(e);+ for (const n of t)+ n.usedTimes--, n.usedTimes === 0 && this.shaderCache.delete(n.code);+ return this.materialCache.delete(e), this;+ }+ getVertexShaderID(e) {+ return this._getShaderStage(e.vertexShader).id;+ }+ getFragmentShaderID(e) {+ return this._getShaderStage(e.fragmentShader).id;+ }+ dispose() {+ this.shaderCache.clear(), this.materialCache.clear();+ }+ _getShaderCacheForMaterial(e) {+ const t = this.materialCache;+ let n = t.get(e);+ return n === void 0 && (n = /* @__PURE__ */ new Set(), t.set(e, n)), n;+ }+ _getShaderStage(e) {+ const t = this.shaderCache;+ let n = t.get(e);+ return n === void 0 && (n = new lI(e), t.set(e, n)), n;+ }+}+class lI {+ constructor(e) {+ this.id = oI++, this.code = e, this.usedTimes = 0;+ }+}+function hI(i, e, t, n, s, r, a) {+ const o = new c0(), c = new cI(), l = /* @__PURE__ */ new Set(), h = [], u = s.logarithmicDepthBuffer, d = s.vertexTextures;+ let f = s.precision;+ const m = {+ MeshDepthMaterial: "depth",+ MeshDistanceMaterial: "distanceRGBA",+ MeshNormalMaterial: "normal",+ MeshBasicMaterial: "basic",+ MeshLambertMaterial: "lambert",+ MeshPhongMaterial: "phong",+ MeshToonMaterial: "toon",+ MeshStandardMaterial: "physical",+ MeshPhysicalMaterial: "physical",+ MeshMatcapMaterial: "matcap",+ LineBasicMaterial: "basic",+ LineDashedMaterial: "dashed",+ PointsMaterial: "points",+ ShadowMaterial: "shadow",+ SpriteMaterial: "sprite"+ };+ function A(C) {+ return l.add(C), C === 0 ? "uv" : `uv${C}`;+ }+ function g(C, v, F, K, q) {+ const $ = K.fog, D = q.geometry, O = C.isMeshStandardMaterial ? K.environment : null, Y = (C.isMeshStandardMaterial ? t : e).get(C.envMap || O), Q = Y && Y.mapping === jl ? Y.image.height : null, J = m[C.type];+ C.precision !== null && (f = s.getMaxPrecision(C.precision), f !== C.precision && console.warn("THREE.WebGLProgram.getParameters:", C.precision, "not supported, using", f, "instead."));+ const ee = D.morphAttributes.position || D.morphAttributes.normal || D.morphAttributes.color, ae = ee !== void 0 ? ee.length : 0;+ let ye = 0;+ D.morphAttributes.position !== void 0 && (ye = 1), D.morphAttributes.normal !== void 0 && (ye = 2), D.morphAttributes.color !== void 0 && (ye = 3);+ let Me, se, me, be;+ if (J) {+ const Et = Ri[J];+ Me = Et.vertexShader, se = Et.fragmentShader;+ } else+ Me = C.vertexShader, se = C.fragmentShader, c.update(C), me = c.getVertexShaderID(C), be = c.getFragmentShaderID(C);+ const xe = i.getRenderTarget(), Pe = i.state.buffers.depth.getReversed(), $e = q.isInstancedMesh === !0, Qe = q.isBatchedMesh === !0, vt = !!C.map, lt = !!C.matcap, Je = !!Y, G = !!C.aoMap, dn = !!C.lightMap, dt = !!C.bumpMap, pt = !!C.normalMap, ze = !!C.displacementMap, Rt = !!C.emissiveMap, Ge = !!C.metalnessMap, L = !!C.roughnessMap, I = C.anisotropy > 0, Z = C.clearcoat > 0, le = C.dispersion > 0, pe = C.iridescence > 0, oe = C.sheen > 0, Ue = C.transmission > 0, ve = I && !!C.anisotropyMap, Ve = Z && !!C.clearcoatMap, Ye = Z && !!C.clearcoatNormalMap, _e = Z && !!C.clearcoatRoughnessMap, Re = pe && !!C.iridescenceMap, ke = pe && !!C.iridescenceThicknessMap, Oe = oe && !!C.sheenColorMap, Be = oe && !!C.sheenRoughnessMap, tt = !!C.specularMap, We = !!C.specularColorMap, nt = !!C.specularIntensityMap, W = Ue && !!C.transmissionMap, ne = Ue && !!C.thicknessMap, re = !!C.gradientMap, de = !!C.alphaMap, Ie = C.alphaTest > 0, Ce = !!C.alphaHash, it = !!C.extensions;+ let Ut = Ls;+ C.toneMapped && (xe === null || xe.isXRRenderTarget === !0) && (Ut = i.toneMapping);+ const fn = {+ shaderID: J,+ shaderType: C.type,+ shaderName: C.name,+ vertexShader: Me,+ fragmentShader: se,+ defines: C.defines,+ customVertexShaderID: me,+ customFragmentShaderID: be,+ isRawShaderMaterial: C.isRawShaderMaterial === !0,+ glslVersion: C.glslVersion,+ precision: f,+ batching: Qe,+ batchingColor: Qe && q._colorsTexture !== null,+ instancing: $e,+ instancingColor: $e && q.instanceColor !== null,+ instancingMorph: $e && q.morphTexture !== null,+ supportsVertexTextures: d,+ outputColorSpace: xe === null ? i.outputColorSpace : xe.isXRRenderTarget === !0 ? xe.texture.colorSpace : ln,+ alphaToCoverage: !!C.alphaToCoverage,+ map: vt,+ matcap: lt,+ envMap: Je,+ envMapMode: Je && Y.mapping,+ envMapCubeUVHeight: Q,+ aoMap: G,+ lightMap: dn,+ bumpMap: dt,+ normalMap: pt,+ displacementMap: d && ze,+ emissiveMap: Rt,+ normalMapObjectSpace: pt && C.normalMapType === sE,+ normalMapTangentSpace: pt && C.normalMapType === n0,+ metalnessMap: Ge,+ roughnessMap: L,+ anisotropy: I,+ anisotropyMap: ve,+ clearcoat: Z,+ clearcoatMap: Ve,+ clearcoatNormalMap: Ye,+ clearcoatRoughnessMap: _e,+ dispersion: le,+ iridescence: pe,+ iridescenceMap: Re,+ iridescenceThicknessMap: ke,+ sheen: oe,+ sheenColorMap: Oe,+ sheenRoughnessMap: Be,+ specularMap: tt,+ specularColorMap: We,+ specularIntensityMap: nt,+ transmission: Ue,+ transmissionMap: W,+ thicknessMap: ne,+ gradientMap: re,+ opaque: C.transparent === !1 && C.blending === fa && C.alphaToCoverage === !1,+ alphaMap: de,+ alphaTest: Ie,+ alphaHash: Ce,+ combine: C.combine,+ //+ mapUv: vt && A(C.map.channel),+ aoMapUv: G && A(C.aoMap.channel),+ lightMapUv: dn && A(C.lightMap.channel),+ bumpMapUv: dt && A(C.bumpMap.channel),+ normalMapUv: pt && A(C.normalMap.channel),+ displacementMapUv: ze && A(C.displacementMap.channel),+ emissiveMapUv: Rt && A(C.emissiveMap.channel),+ metalnessMapUv: Ge && A(C.metalnessMap.channel),+ roughnessMapUv: L && A(C.roughnessMap.channel),+ anisotropyMapUv: ve && A(C.anisotropyMap.channel),+ clearcoatMapUv: Ve && A(C.clearcoatMap.channel),+ clearcoatNormalMapUv: Ye && A(C.clearcoatNormalMap.channel),+ clearcoatRoughnessMapUv: _e && A(C.clearcoatRoughnessMap.channel),+ iridescenceMapUv: Re && A(C.iridescenceMap.channel),+ iridescenceThicknessMapUv: ke && A(C.iridescenceThicknessMap.channel),+ sheenColorMapUv: Oe && A(C.sheenColorMap.channel),+ sheenRoughnessMapUv: Be && A(C.sheenRoughnessMap.channel),+ specularMapUv: tt && A(C.specularMap.channel),+ specularColorMapUv: We && A(C.specularColorMap.channel),+ specularIntensityMapUv: nt && A(C.specularIntensityMap.channel),+ transmissionMapUv: W && A(C.transmissionMap.channel),+ thicknessMapUv: ne && A(C.thicknessMap.channel),+ alphaMapUv: de && A(C.alphaMap.channel),+ //+ vertexTangents: !!D.attributes.tangent && (pt || I),+ vertexColors: C.vertexColors,+ vertexAlphas: C.vertexColors === !0 && !!D.attributes.color && D.attributes.color.itemSize === 4,+ pointsUvs: q.isPoints === !0 && !!D.attributes.uv && (vt || de),+ fog: !!$,+ useFog: C.fog === !0,+ fogExp2: !!$ && $.isFogExp2,+ flatShading: C.flatShading === !0,+ sizeAttenuation: C.sizeAttenuation === !0,+ logarithmicDepthBuffer: u,+ reverseDepthBuffer: Pe,+ skinning: q.isSkinnedMesh === !0,+ morphTargets: D.morphAttributes.position !== void 0,+ morphNormals: D.morphAttributes.normal !== void 0,+ morphColors: D.morphAttributes.color !== void 0,+ morphTargetsCount: ae,+ morphTextureStride: ye,+ numDirLights: v.directional.length,+ numPointLights: v.point.length,+ numSpotLights: v.spot.length,+ numSpotLightMaps: v.spotLightMap.length,+ numRectAreaLights: v.rectArea.length,+ numHemiLights: v.hemi.length,+ numDirLightShadows: v.directionalShadowMap.length,+ numPointLightShadows: v.pointShadowMap.length,+ numSpotLightShadows: v.spotShadowMap.length,+ numSpotLightShadowsWithMaps: v.numSpotLightShadowsWithMaps,+ numLightProbes: v.numLightProbes,+ numClippingPlanes: a.numPlanes,+ numClipIntersection: a.numIntersection,+ dithering: C.dithering,+ shadowMapEnabled: i.shadowMap.enabled && F.length > 0,+ shadowMapType: i.shadowMap.type,+ toneMapping: Ut,+ decodeVideoTexture: vt && C.map.isVideoTexture === !0 && mt.getTransfer(C.map.colorSpace) === Mt,+ decodeVideoTextureEmissive: Rt && C.emissiveMap.isVideoTexture === !0 && mt.getTransfer(C.emissiveMap.colorSpace) === Mt,+ premultipliedAlpha: C.premultipliedAlpha,+ doubleSided: C.side === Ni,+ flipSided: C.side === Pn,+ useDepthPacking: C.depthPacking >= 0,+ depthPacking: C.depthPacking || 0,+ index0AttributeName: C.index0AttributeName,+ extensionClipCullDistance: it && C.extensions.clipCullDistance === !0 && n.has("WEBGL_clip_cull_distance"),+ extensionMultiDraw: (it && C.extensions.multiDraw === !0 || Qe) && n.has("WEBGL_multi_draw"),+ rendererExtensionParallelShaderCompile: n.has("KHR_parallel_shader_compile"),+ customProgramCacheKey: C.customProgramCacheKey()+ };+ return fn.vertexUv1s = l.has(1), fn.vertexUv2s = l.has(2), fn.vertexUv3s = l.has(3), l.clear(), fn;+ }+ function p(C) {+ const v = [];+ if (C.shaderID ? v.push(C.shaderID) : (v.push(C.customVertexShaderID), v.push(C.customFragmentShaderID)), C.defines !== void 0)+ for (const F in C.defines)+ v.push(F), v.push(C.defines[F]);+ return C.isRawShaderMaterial === !1 && (y(v, C), b(v, C), v.push(i.outputColorSpace)), v.push(C.customProgramCacheKey), v.join();+ }+ function y(C, v) {+ C.push(v.precision), C.push(v.outputColorSpace), C.push(v.envMapMode), C.push(v.envMapCubeUVHeight), C.push(v.mapUv), C.push(v.alphaMapUv), C.push(v.lightMapUv), C.push(v.aoMapUv), C.push(v.bumpMapUv), C.push(v.normalMapUv), C.push(v.displacementMapUv), C.push(v.emissiveMapUv), C.push(v.metalnessMapUv), C.push(v.roughnessMapUv), C.push(v.anisotropyMapUv), C.push(v.clearcoatMapUv), C.push(v.clearcoatNormalMapUv), C.push(v.clearcoatRoughnessMapUv), C.push(v.iridescenceMapUv), C.push(v.iridescenceThicknessMapUv), C.push(v.sheenColorMapUv), C.push(v.sheenRoughnessMapUv), C.push(v.specularMapUv), C.push(v.specularColorMapUv), C.push(v.specularIntensityMapUv), C.push(v.transmissionMapUv), C.push(v.thicknessMapUv), C.push(v.combine), C.push(v.fogExp2), C.push(v.sizeAttenuation), C.push(v.morphTargetsCount), C.push(v.morphAttributeCount), C.push(v.numDirLights), C.push(v.numPointLights), C.push(v.numSpotLights), C.push(v.numSpotLightMaps), C.push(v.numHemiLights), C.push(v.numRectAreaLights), C.push(v.numDirLightShadows), C.push(v.numPointLightShadows), C.push(v.numSpotLightShadows), C.push(v.numSpotLightShadowsWithMaps), C.push(v.numLightProbes), C.push(v.shadowMapType), C.push(v.toneMapping), C.push(v.numClippingPlanes), C.push(v.numClipIntersection), C.push(v.depthPacking);+ }+ function b(C, v) {+ o.disableAll(), v.supportsVertexTextures && o.enable(0), v.instancing && o.enable(1), v.instancingColor && o.enable(2), v.instancingMorph && o.enable(3), v.matcap && o.enable(4), v.envMap && o.enable(5), v.normalMapObjectSpace && o.enable(6), v.normalMapTangentSpace && o.enable(7), v.clearcoat && o.enable(8), v.iridescence && o.enable(9), v.alphaTest && o.enable(10), v.vertexColors && o.enable(11), v.vertexAlphas && o.enable(12), v.vertexUv1s && o.enable(13), v.vertexUv2s && o.enable(14), v.vertexUv3s && o.enable(15), v.vertexTangents && o.enable(16), v.anisotropy && o.enable(17), v.alphaHash && o.enable(18), v.batching && o.enable(19), v.dispersion && o.enable(20), v.batchingColor && o.enable(21), C.push(o.mask), o.disableAll(), v.fog && o.enable(0), v.useFog && o.enable(1), v.flatShading && o.enable(2), v.logarithmicDepthBuffer && o.enable(3), v.reverseDepthBuffer && o.enable(4), v.skinning && o.enable(5), v.morphTargets && o.enable(6), v.morphNormals && o.enable(7), v.morphColors && o.enable(8), v.premultipliedAlpha && o.enable(9), v.shadowMapEnabled && o.enable(10), v.doubleSided && o.enable(11), v.flipSided && o.enable(12), v.useDepthPacking && o.enable(13), v.dithering && o.enable(14), v.transmission && o.enable(15), v.sheen && o.enable(16), v.opaque && o.enable(17), v.pointsUvs && o.enable(18), v.decodeVideoTexture && o.enable(19), v.decodeVideoTextureEmissive && o.enable(20), v.alphaToCoverage && o.enable(21), C.push(o.mask);+ }+ function E(C) {+ const v = m[C.type];+ let F;+ if (v) {+ const K = Ri[v];+ F = ZE.clone(K.uniforms);+ } else+ F = C.uniforms;+ return F;+ }+ function M(C, v) {+ let F;+ for (let K = 0, q = h.length; K < q; K++) {+ const $ = h[K];+ if ($.cacheKey === v) {+ F = $, ++F.usedTimes;+ break;+ }+ }+ return F === void 0 && (F = new aI(i, v, C, r), h.push(F)), F;+ }+ function w(C) {+ if (--C.usedTimes === 0) {+ const v = h.indexOf(C);+ h[v] = h[h.length - 1], h.pop(), C.destroy();+ }+ }+ function S(C) {+ c.remove(C);+ }+ function T() {+ c.dispose();+ }+ return {+ getParameters: g,+ getProgramCacheKey: p,+ getUniforms: E,+ acquireProgram: M,+ releaseProgram: w,+ releaseShaderCache: S,+ // Exposed for resource monitoring & error feedback via renderer.info:+ programs: h,+ dispose: T+ };+}+function uI() {+ let i = /* @__PURE__ */ new WeakMap();+ function e(a) {+ return i.has(a);+ }+ function t(a) {+ let o = i.get(a);+ return o === void 0 && (o = {}, i.set(a, o)), o;+ }+ function n(a) {+ i.delete(a);+ }+ function s(a, o, c) {+ i.get(a)[o] = c;+ }+ function r() {+ i = /* @__PURE__ */ new WeakMap();+ }+ return {+ has: e,+ get: t,+ remove: n,+ update: s,+ dispose: r+ };+}+function dI(i, e) {+ return i.groupOrder !== e.groupOrder ? i.groupOrder - e.groupOrder : i.renderOrder !== e.renderOrder ? i.renderOrder - e.renderOrder : i.material.id !== e.material.id ? i.material.id - e.material.id : i.z !== e.z ? i.z - e.z : i.id - e.id;+}+function vA(i, e) {+ return i.groupOrder !== e.groupOrder ? i.groupOrder - e.groupOrder : i.renderOrder !== e.renderOrder ? i.renderOrder - e.renderOrder : i.z !== e.z ? e.z - i.z : i.id - e.id;+}+function CA() {+ const i = [];+ let e = 0;+ const t = [], n = [], s = [];+ function r() {+ e = 0, t.length = 0, n.length = 0, s.length = 0;+ }+ function a(u, d, f, m, A, g) {+ let p = i[e];+ return p === void 0 ? (p = {+ id: u.id,+ object: u,+ geometry: d,+ material: f,+ groupOrder: m,+ renderOrder: u.renderOrder,+ z: A,+ group: g+ }, i[e] = p) : (p.id = u.id, p.object = u, p.geometry = d, p.material = f, p.groupOrder = m, p.renderOrder = u.renderOrder, p.z = A, p.group = g), e++, p;+ }+ function o(u, d, f, m, A, g) {+ const p = a(u, d, f, m, A, g);+ f.transmission > 0 ? n.push(p) : f.transparent === !0 ? s.push(p) : t.push(p);+ }+ function c(u, d, f, m, A, g) {+ const p = a(u, d, f, m, A, g);+ f.transmission > 0 ? n.unshift(p) : f.transparent === !0 ? s.unshift(p) : t.unshift(p);+ }+ function l(u, d) {+ t.length > 1 && t.sort(u || dI), n.length > 1 && n.sort(d || vA), s.length > 1 && s.sort(d || vA);+ }+ function h() {+ for (let u = e, d = i.length; u < d; u++) {+ const f = i[u];+ if (f.id === null) break;+ f.id = null, f.object = null, f.geometry = null, f.material = null, f.group = null;+ }+ }+ return {+ opaque: t,+ transmissive: n,+ transparent: s,+ init: r,+ push: o,+ unshift: c,+ finish: h,+ sort: l+ };+}+function fI() {+ let i = /* @__PURE__ */ new WeakMap();+ function e(n, s) {+ const r = i.get(n);+ let a;+ return r === void 0 ? (a = new CA(), i.set(n, [a])) : s >= r.length ? (a = new CA(), r.push(a)) : a = r[s], a;+ }+ function t() {+ i = /* @__PURE__ */ new WeakMap();+ }+ return {+ get: e,+ dispose: t+ };+}+function pI() {+ const i = {};+ return {+ get: function(e) {+ if (i[e.id] !== void 0)+ return i[e.id];+ let t;+ switch (e.type) {+ case "DirectionalLight":+ t = {+ direction: new H(),+ color: new je()+ };+ break;+ case "SpotLight":+ t = {+ position: new H(),+ direction: new H(),+ color: new je(),+ distance: 0,+ coneCos: 0,+ penumbraCos: 0,+ decay: 0+ };+ break;+ case "PointLight":+ t = {+ position: new H(),+ color: new je(),+ distance: 0,+ decay: 0+ };+ break;+ case "HemisphereLight":+ t = {+ direction: new H(),+ skyColor: new je(),+ groundColor: new je()+ };+ break;+ case "RectAreaLight":+ t = {+ color: new je(),+ position: new H(),+ halfWidth: new H(),+ halfHeight: new H()+ };+ break;+ }+ return i[e.id] = t, t;+ }+ };+}+function AI() {+ const i = {};+ return {+ get: function(e) {+ if (i[e.id] !== void 0)+ return i[e.id];+ let t;+ switch (e.type) {+ case "DirectionalLight":+ t = {+ shadowIntensity: 1,+ shadowBias: 0,+ shadowNormalBias: 0,+ shadowRadius: 1,+ shadowMapSize: new Ze()+ };+ break;+ case "SpotLight":+ t = {+ shadowIntensity: 1,+ shadowBias: 0,+ shadowNormalBias: 0,+ shadowRadius: 1,+ shadowMapSize: new Ze()+ };+ break;+ case "PointLight":+ t = {+ shadowIntensity: 1,+ shadowBias: 0,+ shadowNormalBias: 0,+ shadowRadius: 1,+ shadowMapSize: new Ze(),+ shadowCameraNear: 1,+ shadowCameraFar: 1e3+ };+ break;+ }+ return i[e.id] = t, t;+ }+ };+}+let gI = 0;+function mI(i, e) {+ return (e.castShadow ? 2 : 0) - (i.castShadow ? 2 : 0) + (e.map ? 1 : 0) - (i.map ? 1 : 0);+}+function bI(i) {+ const e = new pI(), t = AI(), n = {+ version: 0,+ hash: {+ directionalLength: -1,+ pointLength: -1,+ spotLength: -1,+ rectAreaLength: -1,+ hemiLength: -1,+ numDirectionalShadows: -1,+ numPointShadows: -1,+ numSpotShadows: -1,+ numSpotMaps: -1,+ numLightProbes: -1+ },+ ambient: [0, 0, 0],+ probe: [],+ directional: [],+ directionalShadow: [],+ directionalShadowMap: [],+ directionalShadowMatrix: [],+ spot: [],+ spotLightMap: [],+ spotShadow: [],+ spotShadowMap: [],+ spotLightMatrix: [],+ rectArea: [],+ rectAreaLTC1: null,+ rectAreaLTC2: null,+ point: [],+ pointShadow: [],+ pointShadowMap: [],+ pointShadowMatrix: [],+ hemi: [],+ numSpotLightShadowsWithMaps: 0,+ numLightProbes: 0+ };+ for (let l = 0; l < 9; l++) n.probe.push(new H());+ const s = new H(), r = new et(), a = new et();+ function o(l) {+ let h = 0, u = 0, d = 0;+ for (let C = 0; C < 9; C++) n.probe[C].set(0, 0, 0);+ let f = 0, m = 0, A = 0, g = 0, p = 0, y = 0, b = 0, E = 0, M = 0, w = 0, S = 0;+ l.sort(mI);+ for (let C = 0, v = l.length; C < v; C++) {+ const F = l[C], K = F.color, q = F.intensity, $ = F.distance, D = F.shadow && F.shadow.map ? F.shadow.map.texture : null;+ if (F.isAmbientLight)+ h += K.r * q, u += K.g * q, d += K.b * q;+ else if (F.isLightProbe) {+ for (let O = 0; O < 9; O++)+ n.probe[O].addScaledVector(F.sh.coefficients[O], q);+ S++;+ } else if (F.isDirectionalLight) {+ const O = e.get(F);+ if (O.color.copy(F.color).multiplyScalar(F.intensity), F.castShadow) {+ const Y = F.shadow, Q = t.get(F);+ Q.shadowIntensity = Y.intensity, Q.shadowBias = Y.bias, Q.shadowNormalBias = Y.normalBias, Q.shadowRadius = Y.radius, Q.shadowMapSize = Y.mapSize, n.directionalShadow[f] = Q, n.directionalShadowMap[f] = D, n.directionalShadowMatrix[f] = F.shadow.matrix, y++;+ }+ n.directional[f] = O, f++;+ } else if (F.isSpotLight) {+ const O = e.get(F);+ O.position.setFromMatrixPosition(F.matrixWorld), O.color.copy(K).multiplyScalar(q), O.distance = $, O.coneCos = Math.cos(F.angle), O.penumbraCos = Math.cos(F.angle * (1 - F.penumbra)), O.decay = F.decay, n.spot[A] = O;+ const Y = F.shadow;+ if (F.map && (n.spotLightMap[M] = F.map, M++, Y.updateMatrices(F), F.castShadow && w++), n.spotLightMatrix[A] = Y.matrix, F.castShadow) {+ const Q = t.get(F);+ Q.shadowIntensity = Y.intensity, Q.shadowBias = Y.bias, Q.shadowNormalBias = Y.normalBias, Q.shadowRadius = Y.radius, Q.shadowMapSize = Y.mapSize, n.spotShadow[A] = Q, n.spotShadowMap[A] = D, E++;+ }+ A++;+ } else if (F.isRectAreaLight) {+ const O = e.get(F);+ O.color.copy(K).multiplyScalar(q), O.halfWidth.set(F.width * 0.5, 0, 0), O.halfHeight.set(0, F.height * 0.5, 0), n.rectArea[g] = O, g++;+ } else if (F.isPointLight) {+ const O = e.get(F);+ if (O.color.copy(F.color).multiplyScalar(F.intensity), O.distance = F.distance, O.decay = F.decay, F.castShadow) {+ const Y = F.shadow, Q = t.get(F);+ Q.shadowIntensity = Y.intensity, Q.shadowBias = Y.bias, Q.shadowNormalBias = Y.normalBias, Q.shadowRadius = Y.radius, Q.shadowMapSize = Y.mapSize, Q.shadowCameraNear = Y.camera.near, Q.shadowCameraFar = Y.camera.far, n.pointShadow[m] = Q, n.pointShadowMap[m] = D, n.pointShadowMatrix[m] = F.shadow.matrix, b++;+ }+ n.point[m] = O, m++;+ } else if (F.isHemisphereLight) {+ const O = e.get(F);+ O.skyColor.copy(F.color).multiplyScalar(q), O.groundColor.copy(F.groundColor).multiplyScalar(q), n.hemi[p] = O, p++;+ }+ }+ g > 0 && (i.has("OES_texture_float_linear") === !0 ? (n.rectAreaLTC1 = we.LTC_FLOAT_1, n.rectAreaLTC2 = we.LTC_FLOAT_2) : (n.rectAreaLTC1 = we.LTC_HALF_1, n.rectAreaLTC2 = we.LTC_HALF_2)), n.ambient[0] = h, n.ambient[1] = u, n.ambient[2] = d;+ const T = n.hash;+ (T.directionalLength !== f || T.pointLength !== m || T.spotLength !== A || T.rectAreaLength !== g || T.hemiLength !== p || T.numDirectionalShadows !== y || T.numPointShadows !== b || T.numSpotShadows !== E || T.numSpotMaps !== M || T.numLightProbes !== S) && (n.directional.length = f, n.spot.length = A, n.rectArea.length = g, n.point.length = m, n.hemi.length = p, n.directionalShadow.length = y, n.directionalShadowMap.length = y, n.pointShadow.length = b, n.pointShadowMap.length = b, n.spotShadow.length = E, n.spotShadowMap.length = E, n.directionalShadowMatrix.length = y, n.pointShadowMatrix.length = b, n.spotLightMatrix.length = E + M - w, n.spotLightMap.length = M, n.numSpotLightShadowsWithMaps = w, n.numLightProbes = S, T.directionalLength = f, T.pointLength = m, T.spotLength = A, T.rectAreaLength = g, T.hemiLength = p, T.numDirectionalShadows = y, T.numPointShadows = b, T.numSpotShadows = E, T.numSpotMaps = M, T.numLightProbes = S, n.version = gI++);+ }+ function c(l, h) {+ let u = 0, d = 0, f = 0, m = 0, A = 0;+ const g = h.matrixWorldInverse;+ for (let p = 0, y = l.length; p < y; p++) {+ const b = l[p];+ if (b.isDirectionalLight) {+ const E = n.directional[u];+ E.direction.setFromMatrixPosition(b.matrixWorld), s.setFromMatrixPosition(b.target.matrixWorld), E.direction.sub(s), E.direction.transformDirection(g), u++;+ } else if (b.isSpotLight) {+ const E = n.spot[f];+ E.position.setFromMatrixPosition(b.matrixWorld), E.position.applyMatrix4(g), E.direction.setFromMatrixPosition(b.matrixWorld), s.setFromMatrixPosition(b.target.matrixWorld), E.direction.sub(s), E.direction.transformDirection(g), f++;+ } else if (b.isRectAreaLight) {+ const E = n.rectArea[m];+ E.position.setFromMatrixPosition(b.matrixWorld), E.position.applyMatrix4(g), a.identity(), r.copy(b.matrixWorld), r.premultiply(g), a.extractRotation(r), E.halfWidth.set(b.width * 0.5, 0, 0), E.halfHeight.set(0, b.height * 0.5, 0), E.halfWidth.applyMatrix4(a), E.halfHeight.applyMatrix4(a), m++;+ } else if (b.isPointLight) {+ const E = n.point[d];+ E.position.setFromMatrixPosition(b.matrixWorld), E.position.applyMatrix4(g), d++;+ } else if (b.isHemisphereLight) {+ const E = n.hemi[A];+ E.direction.setFromMatrixPosition(b.matrixWorld), E.direction.transformDirection(g), A++;+ }+ }+ }+ return {+ setup: o,+ setupView: c,+ state: n+ };+}+function SA(i) {+ const e = new bI(i), t = [], n = [];+ function s(h) {+ l.camera = h, t.length = 0, n.length = 0;+ }+ function r(h) {+ t.push(h);+ }+ function a(h) {+ n.push(h);+ }+ function o() {+ e.setup(t);+ }+ function c(h) {+ e.setupView(t, h);+ }+ const l = {+ lightsArray: t,+ shadowsArray: n,+ camera: null,+ lights: e,+ transmissionRenderTarget: {}+ };+ return {+ init: s,+ state: l,+ setupLights: o,+ setupLightsView: c,+ pushLight: r,+ pushShadow: a+ };+}+function xI(i) {+ let e = /* @__PURE__ */ new WeakMap();+ function t(s, r = 0) {+ const a = e.get(s);+ let o;+ return a === void 0 ? (o = new SA(i), e.set(s, [o])) : r >= a.length ? (o = new SA(i), a.push(o)) : o = a[r], o;+ }+ function n() {+ e = /* @__PURE__ */ new WeakMap();+ }+ return {+ get: t,+ dispose: n+ };+}+const _I = `void main() {+ gl_Position = vec4( position, 1.0 );+}`, EI = `uniform sampler2D shadow_pass;+uniform vec2 resolution;+uniform float radius;+#include <packing>+void main() {+ const float samples = float( VSM_SAMPLES );+ float mean = 0.0;+ float squared_mean = 0.0;+ float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );+ float uvStart = samples <= 1.0 ? 0.0 : - 1.0;+ for ( float i = 0.0; i < samples; i ++ ) {+ float uvOffset = uvStart + i * uvStride;+ #ifdef HORIZONTAL_PASS+ vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );+ mean += distribution.x;+ squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;+ #else+ float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );+ mean += depth;+ squared_mean += depth * depth;+ #endif+ }+ mean = mean / samples;+ squared_mean = squared_mean / samples;+ float std_dev = sqrt( squared_mean - mean * mean );+ gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );+}`;+function yI(i, e, t) {+ let n = new vf();+ const s = new Ze(), r = new Ze(), a = new wt(), o = new Ay({ depthPacking: iE }), c = new gy(), l = {}, h = t.maxTextureSize, u = { [us]: Pn, [Pn]: us, [Ni]: Ni }, d = new Os({+ defines: {+ VSM_SAMPLES: 8+ },+ uniforms: {+ shadow_pass: { value: null },+ resolution: { value: new Ze() },+ radius: { value: 4 }+ },+ vertexShader: _I,+ fragmentShader: EI+ }), f = d.clone();+ f.defines.HORIZONTAL_PASS = 1;+ const m = new zn();+ m.setAttribute(+ "position",+ new En(+ new Float32Array([-1, -1, 0.5, 3, -1, 0.5, -1, 3, 0.5]),+ 3+ )+ );+ const A = new Jt(m, d), g = this;+ this.enabled = !1, this.autoUpdate = !0, this.needsUpdate = !1, this.type = Hm;+ let p = this.type;+ this.render = function(w, S, T) {+ if (g.enabled === !1 || g.autoUpdate === !1 && g.needsUpdate === !1 || w.length === 0) return;+ const C = i.getRenderTarget(), v = i.getActiveCubeFace(), F = i.getActiveMipmapLevel(), K = i.state;+ K.setBlending(Ds), K.buffers.color.setClear(1, 1, 1, 1), K.buffers.depth.setTest(!0), K.setScissorTest(!1);+ const q = p !== ji && this.type === ji, $ = p === ji && this.type !== ji;+ for (let D = 0, O = w.length; D < O; D++) {+ const Y = w[D], Q = Y.shadow;+ if (Q === void 0) {+ console.warn("THREE.WebGLShadowMap:", Y, "has no shadow.");+ continue;+ }+ if (Q.autoUpdate === !1 && Q.needsUpdate === !1) continue;+ s.copy(Q.mapSize);+ const J = Q.getFrameExtents();+ if (s.multiply(J), r.copy(Q.mapSize), (s.x > h || s.y > h) && (s.x > h && (r.x = Math.floor(h / J.x), s.x = r.x * J.x, Q.mapSize.x = r.x), s.y > h && (r.y = Math.floor(h / J.y), s.y = r.y * J.y, Q.mapSize.y = r.y)), Q.map === null || q === !0 || $ === !0) {+ const ae = this.type !== ji ? { minFilter: kn, magFilter: kn } : {};+ Q.map !== null && Q.map.dispose(), Q.map = new wr(s.x, s.y, ae), Q.map.texture.name = Y.name + ".shadowMap", Q.camera.updateProjectionMatrix();+ }+ i.setRenderTarget(Q.map), i.clear();+ const ee = Q.getViewportCount();+ for (let ae = 0; ae < ee; ae++) {+ const ye = Q.getViewport(ae);+ a.set(+ r.x * ye.x,+ r.y * ye.y,+ r.x * ye.z,+ r.y * ye.w+ ), K.viewport(a), Q.updateMatrices(Y, ae), n = Q.getFrustum(), E(S, T, Q.camera, Y, this.type);+ }+ Q.isPointLightShadow !== !0 && this.type === ji && y(Q, T), Q.needsUpdate = !1;+ }+ p = this.type, g.needsUpdate = !1, i.setRenderTarget(C, v, F);+ };+ function y(w, S) {+ const T = e.update(A);+ d.defines.VSM_SAMPLES !== w.blurSamples && (d.defines.VSM_SAMPLES = w.blurSamples, f.defines.VSM_SAMPLES = w.blurSamples, d.needsUpdate = !0, f.needsUpdate = !0), w.mapPass === null && (w.mapPass = new wr(s.x, s.y)), d.uniforms.shadow_pass.value = w.map.texture, d.uniforms.resolution.value = w.mapSize, d.uniforms.radius.value = w.radius, i.setRenderTarget(w.mapPass), i.clear(), i.renderBufferDirect(S, null, T, d, A, null), f.uniforms.shadow_pass.value = w.mapPass.texture, f.uniforms.resolution.value = w.mapSize, f.uniforms.radius.value = w.radius, i.setRenderTarget(w.map), i.clear(), i.renderBufferDirect(S, null, T, f, A, null);+ }+ function b(w, S, T, C) {+ let v = null;+ const F = T.isPointLight === !0 ? w.customDistanceMaterial : w.customDepthMaterial;+ if (F !== void 0)+ v = F;+ else if (v = T.isPointLight === !0 ? c : o, i.localClippingEnabled && S.clipShadows === !0 && Array.isArray(S.clippingPlanes) && S.clippingPlanes.length !== 0 || S.displacementMap && S.displacementScale !== 0 || S.alphaMap && S.alphaTest > 0 || S.map && S.alphaTest > 0 || S.alphaToCoverage === !0) {+ const K = v.uuid, q = S.uuid;+ let $ = l[K];+ $ === void 0 && ($ = {}, l[K] = $);+ let D = $[q];+ D === void 0 && (D = v.clone(), $[q] = D, S.addEventListener("dispose", M)), v = D;+ }+ if (v.visible = S.visible, v.wireframe = S.wireframe, C === ji ? v.side = S.shadowSide !== null ? S.shadowSide : S.side : v.side = S.shadowSide !== null ? S.shadowSide : u[S.side], v.alphaMap = S.alphaMap, v.alphaTest = S.alphaToCoverage === !0 ? 0.5 : S.alphaTest, v.map = S.map, v.clipShadows = S.clipShadows, v.clippingPlanes = S.clippingPlanes, v.clipIntersection = S.clipIntersection, v.displacementMap = S.displacementMap, v.displacementScale = S.displacementScale, v.displacementBias = S.displacementBias, v.wireframeLinewidth = S.wireframeLinewidth, v.linewidth = S.linewidth, T.isPointLight === !0 && v.isMeshDistanceMaterial === !0) {+ const K = i.properties.get(v);+ K.light = T;+ }+ return v;+ }+ function E(w, S, T, C, v) {+ if (w.visible === !1) return;+ if (w.layers.test(S.layers) && (w.isMesh || w.isLine || w.isPoints) && (w.castShadow || w.receiveShadow && v === ji) && (!w.frustumCulled || n.intersectsObject(w))) {+ w.modelViewMatrix.multiplyMatrices(T.matrixWorldInverse, w.matrixWorld);+ const q = e.update(w), $ = w.material;+ if (Array.isArray($)) {+ const D = q.groups;+ for (let O = 0, Y = D.length; O < Y; O++) {+ const Q = D[O], J = $[Q.materialIndex];+ if (J && J.visible) {+ const ee = b(w, J, C, v);+ w.onBeforeShadow(i, w, S, T, q, ee, Q), i.renderBufferDirect(T, null, q, ee, w, Q), w.onAfterShadow(i, w, S, T, q, ee, Q);+ }+ }+ } else if ($.visible) {+ const D = b(w, $, C, v);+ w.onBeforeShadow(i, w, S, T, q, D, null), i.renderBufferDirect(T, null, q, D, w, null), w.onAfterShadow(i, w, S, T, q, D, null);+ }+ }+ const K = w.children;+ for (let q = 0, $ = K.length; q < $; q++)+ E(K[q], S, T, C, v);+ }+ function M(w) {+ w.target.removeEventListener("dispose", M);+ for (const T in l) {+ const C = l[T], v = w.target.uuid;+ v in C && (C[v].dispose(), delete C[v]);+ }+ }+}+const wI = {+ [Vu]: Wu,+ [qu]: Xu,+ [Ku]: Yu,+ [wa]: ju,+ [Wu]: Vu,+ [Xu]: qu,+ [Yu]: Ku,+ [ju]: wa+};+function vI(i, e) {+ function t() {+ let W = !1;+ const ne = new wt();+ let re = null;+ const de = new wt(0, 0, 0, 0);+ return {+ setMask: function(Ie) {+ re !== Ie && !W && (i.colorMask(Ie, Ie, Ie, Ie), re = Ie);+ },+ setLocked: function(Ie) {+ W = Ie;+ },+ setClear: function(Ie, Ce, it, Ut, fn) {+ fn === !0 && (Ie *= Ut, Ce *= Ut, it *= Ut), ne.set(Ie, Ce, it, Ut), de.equals(ne) === !1 && (i.clearColor(Ie, Ce, it, Ut), de.copy(ne));+ },+ reset: function() {+ W = !1, re = null, de.set(-1, 0, 0, 0);+ }+ };+ }+ function n() {+ let W = !1, ne = !1, re = null, de = null, Ie = null;+ return {+ setReversed: function(Ce) {+ if (ne !== Ce) {+ const it = e.get("EXT_clip_control");+ Ce ? it.clipControlEXT(it.LOWER_LEFT_EXT, it.ZERO_TO_ONE_EXT) : it.clipControlEXT(it.LOWER_LEFT_EXT, it.NEGATIVE_ONE_TO_ONE_EXT), ne = Ce;+ const Ut = Ie;+ Ie = null, this.setClear(Ut);+ }+ },+ getReversed: function() {+ return ne;+ },+ setTest: function(Ce) {+ Ce ? xe(i.DEPTH_TEST) : Pe(i.DEPTH_TEST);+ },+ setMask: function(Ce) {+ re !== Ce && !W && (i.depthMask(Ce), re = Ce);+ },+ setFunc: function(Ce) {+ if (ne && (Ce = wI[Ce]), de !== Ce) {+ switch (Ce) {+ case Vu:+ i.depthFunc(i.NEVER);+ break;+ case Wu:+ i.depthFunc(i.ALWAYS);+ break;+ case qu:+ i.depthFunc(i.LESS);+ break;+ case wa:+ i.depthFunc(i.LEQUAL);+ break;+ case Ku:+ i.depthFunc(i.EQUAL);+ break;+ case ju:+ i.depthFunc(i.GEQUAL);+ break;+ case Xu:+ i.depthFunc(i.GREATER);+ break;+ case Yu:+ i.depthFunc(i.NOTEQUAL);+ break;+ default:+ i.depthFunc(i.LEQUAL);+ }+ de = Ce;+ }+ },+ setLocked: function(Ce) {+ W = Ce;+ },+ setClear: function(Ce) {+ Ie !== Ce && (ne && (Ce = 1 - Ce), i.clearDepth(Ce), Ie = Ce);+ },+ reset: function() {+ W = !1, re = null, de = null, Ie = null, ne = !1;+ }+ };+ }+ function s() {+ let W = !1, ne = null, re = null, de = null, Ie = null, Ce = null, it = null, Ut = null, fn = null;+ return {+ setTest: function(Et) {+ W || (Et ? xe(i.STENCIL_TEST) : Pe(i.STENCIL_TEST));+ },+ setMask: function(Et) {+ ne !== Et && !W && (i.stencilMask(Et), ne = Et);+ },+ setFunc: function(Et, Vn, oi) {+ (re !== Et || de !== Vn || Ie !== oi) && (i.stencilFunc(Et, Vn, oi), re = Et, de = Vn, Ie = oi);+ },+ setOp: function(Et, Vn, oi) {+ (Ce !== Et || it !== Vn || Ut !== oi) && (i.stencilOp(Et, Vn, oi), Ce = Et, it = Vn, Ut = oi);+ },+ setLocked: function(Et) {+ W = Et;+ },+ setClear: function(Et) {+ fn !== Et && (i.clearStencil(Et), fn = Et);+ },+ reset: function() {+ W = !1, ne = null, re = null, de = null, Ie = null, Ce = null, it = null, Ut = null, fn = null;+ }+ };+ }+ const r = new t(), a = new n(), o = new s(), c = /* @__PURE__ */ new WeakMap(), l = /* @__PURE__ */ new WeakMap();+ let h = {}, u = {}, d = /* @__PURE__ */ new WeakMap(), f = [], m = null, A = !1, g = null, p = null, y = null, b = null, E = null, M = null, w = null, S = new je(0, 0, 0), T = 0, C = !1, v = null, F = null, K = null, q = null, $ = null;+ const D = i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS);+ let O = !1, Y = 0;+ const Q = i.getParameter(i.VERSION);+ Q.indexOf("WebGL") !== -1 ? (Y = parseFloat(/^WebGL (\d)/.exec(Q)[1]), O = Y >= 1) : Q.indexOf("OpenGL ES") !== -1 && (Y = parseFloat(/^OpenGL ES (\d)/.exec(Q)[1]), O = Y >= 2);+ let J = null, ee = {};+ const ae = i.getParameter(i.SCISSOR_BOX), ye = i.getParameter(i.VIEWPORT), Me = new wt().fromArray(ae), se = new wt().fromArray(ye);+ function me(W, ne, re, de) {+ const Ie = new Uint8Array(4), Ce = i.createTexture();+ i.bindTexture(W, Ce), i.texParameteri(W, i.TEXTURE_MIN_FILTER, i.NEAREST), i.texParameteri(W, i.TEXTURE_MAG_FILTER, i.NEAREST);+ for (let it = 0; it < re; it++)+ W === i.TEXTURE_3D || W === i.TEXTURE_2D_ARRAY ? i.texImage3D(ne, 0, i.RGBA, 1, 1, de, 0, i.RGBA, i.UNSIGNED_BYTE, Ie) : i.texImage2D(ne + it, 0, i.RGBA, 1, 1, 0, i.RGBA, i.UNSIGNED_BYTE, Ie);+ return Ce;+ }+ const be = {};+ be[i.TEXTURE_2D] = me(i.TEXTURE_2D, i.TEXTURE_2D, 1), be[i.TEXTURE_CUBE_MAP] = me(i.TEXTURE_CUBE_MAP, i.TEXTURE_CUBE_MAP_POSITIVE_X, 6), be[i.TEXTURE_2D_ARRAY] = me(i.TEXTURE_2D_ARRAY, i.TEXTURE_2D_ARRAY, 1, 1), be[i.TEXTURE_3D] = me(i.TEXTURE_3D, i.TEXTURE_3D, 1, 1), r.setClear(0, 0, 0, 1), a.setClear(1), o.setClear(0), xe(i.DEPTH_TEST), a.setFunc(wa), dt(!1), pt(up), xe(i.CULL_FACE), G(Ds);+ function xe(W) {+ h[W] !== !0 && (i.enable(W), h[W] = !0);+ }+ function Pe(W) {+ h[W] !== !1 && (i.disable(W), h[W] = !1);+ }+ function $e(W, ne) {+ return u[W] !== ne ? (i.bindFramebuffer(W, ne), u[W] = ne, W === i.DRAW_FRAMEBUFFER && (u[i.FRAMEBUFFER] = ne), W === i.FRAMEBUFFER && (u[i.DRAW_FRAMEBUFFER] = ne), !0) : !1;+ }+ function Qe(W, ne) {+ let re = f, de = !1;+ if (W) {+ re = d.get(ne), re === void 0 && (re = [], d.set(ne, re));+ const Ie = W.textures;+ if (re.length !== Ie.length || re[0] !== i.COLOR_ATTACHMENT0) {+ for (let Ce = 0, it = Ie.length; Ce < it; Ce++)+ re[Ce] = i.COLOR_ATTACHMENT0 + Ce;+ re.length = Ie.length, de = !0;+ }+ } else+ re[0] !== i.BACK && (re[0] = i.BACK, de = !0);+ de && i.drawBuffers(re);+ }+ function vt(W) {+ return m !== W ? (i.useProgram(W), m = W, !0) : !1;+ }+ const lt = {+ [ar]: i.FUNC_ADD,+ [M_]: i.FUNC_SUBTRACT,+ [B_]: i.FUNC_REVERSE_SUBTRACT+ };+ lt[T_] = i.MIN, lt[R_] = i.MAX;+ const Je = {+ [N_]: i.ZERO,+ [F_]: i.ONE,+ [D_]: i.SRC_COLOR,+ [Hu]: i.SRC_ALPHA,+ [Q_]: i.SRC_ALPHA_SATURATE,+ [U_]: i.DST_COLOR,+ [P_]: i.DST_ALPHA,+ [L_]: i.ONE_MINUS_SRC_COLOR,+ [zu]: i.ONE_MINUS_SRC_ALPHA,+ [O_]: i.ONE_MINUS_DST_COLOR,+ [k_]: i.ONE_MINUS_DST_ALPHA,+ [G_]: i.CONSTANT_COLOR,+ [H_]: i.ONE_MINUS_CONSTANT_COLOR,+ [z_]: i.CONSTANT_ALPHA,+ [V_]: i.ONE_MINUS_CONSTANT_ALPHA+ };+ function G(W, ne, re, de, Ie, Ce, it, Ut, fn, Et) {+ if (W === Ds) {+ A === !0 && (Pe(i.BLEND), A = !1);+ return;+ }+ if (A === !1 && (xe(i.BLEND), A = !0), W !== I_) {+ if (W !== g || Et !== C) {+ if ((p !== ar || E !== ar) && (i.blendEquation(i.FUNC_ADD), p = ar, E = ar), Et)+ switch (W) {+ case fa:+ i.blendFuncSeparate(i.ONE, i.ONE_MINUS_SRC_ALPHA, i.ONE, i.ONE_MINUS_SRC_ALPHA);+ break;+ case dp:+ i.blendFunc(i.ONE, i.ONE);+ break;+ case fp:+ i.blendFuncSeparate(i.ZERO, i.ONE_MINUS_SRC_COLOR, i.ZERO, i.ONE);+ break;+ case pp:+ i.blendFuncSeparate(i.ZERO, i.SRC_COLOR, i.ZERO, i.SRC_ALPHA);+ break;+ default:+ console.error("THREE.WebGLState: Invalid blending: ", W);+ break;+ }+ else+ switch (W) {+ case fa:+ i.blendFuncSeparate(i.SRC_ALPHA, i.ONE_MINUS_SRC_ALPHA, i.ONE, i.ONE_MINUS_SRC_ALPHA);+ break;+ case dp:+ i.blendFunc(i.SRC_ALPHA, i.ONE);+ break;+ case fp:+ i.blendFuncSeparate(i.ZERO, i.ONE_MINUS_SRC_COLOR, i.ZERO, i.ONE);+ break;+ case pp:+ i.blendFunc(i.ZERO, i.SRC_COLOR);+ break;+ default:+ console.error("THREE.WebGLState: Invalid blending: ", W);+ break;+ }+ y = null, b = null, M = null, w = null, S.set(0, 0, 0), T = 0, g = W, C = Et;+ }+ return;+ }+ Ie = Ie || ne, Ce = Ce || re, it = it || de, (ne !== p || Ie !== E) && (i.blendEquationSeparate(lt[ne], lt[Ie]), p = ne, E = Ie), (re !== y || de !== b || Ce !== M || it !== w) && (i.blendFuncSeparate(Je[re], Je[de], Je[Ce], Je[it]), y = re, b = de, M = Ce, w = it), (Ut.equals(S) === !1 || fn !== T) && (i.blendColor(Ut.r, Ut.g, Ut.b, fn), S.copy(Ut), T = fn), g = W, C = !1;+ }+ function dn(W, ne) {+ W.side === Ni ? Pe(i.CULL_FACE) : xe(i.CULL_FACE);+ let re = W.side === Pn;+ ne && (re = !re), dt(re), W.blending === fa && W.transparent === !1 ? G(Ds) : G(W.blending, W.blendEquation, W.blendSrc, W.blendDst, W.blendEquationAlpha, W.blendSrcAlpha, W.blendDstAlpha, W.blendColor, W.blendAlpha, W.premultipliedAlpha), a.setFunc(W.depthFunc), a.setTest(W.depthTest), a.setMask(W.depthWrite), r.setMask(W.colorWrite);+ const de = W.stencilWrite;+ o.setTest(de), de && (o.setMask(W.stencilWriteMask), o.setFunc(W.stencilFunc, W.stencilRef, W.stencilFuncMask), o.setOp(W.stencilFail, W.stencilZFail, W.stencilZPass)), Rt(W.polygonOffset, W.polygonOffsetFactor, W.polygonOffsetUnits), W.alphaToCoverage === !0 ? xe(i.SAMPLE_ALPHA_TO_COVERAGE) : Pe(i.SAMPLE_ALPHA_TO_COVERAGE);+ }+ function dt(W) {+ v !== W && (W ? i.frontFace(i.CW) : i.frontFace(i.CCW), v = W);+ }+ function pt(W) {+ W !== v_ ? (xe(i.CULL_FACE), W !== F && (W === up ? i.cullFace(i.BACK) : W === C_ ? i.cullFace(i.FRONT) : i.cullFace(i.FRONT_AND_BACK))) : Pe(i.CULL_FACE), F = W;+ }+ function ze(W) {+ W !== K && (O && i.lineWidth(W), K = W);+ }+ function Rt(W, ne, re) {+ W ? (xe(i.POLYGON_OFFSET_FILL), (q !== ne || $ !== re) && (i.polygonOffset(ne, re), q = ne, $ = re)) : Pe(i.POLYGON_OFFSET_FILL);+ }+ function Ge(W) {+ W ? xe(i.SCISSOR_TEST) : Pe(i.SCISSOR_TEST);+ }+ function L(W) {+ W === void 0 && (W = i.TEXTURE0 + D - 1), J !== W && (i.activeTexture(W), J = W);+ }+ function I(W, ne, re) {+ re === void 0 && (J === null ? re = i.TEXTURE0 + D - 1 : re = J);+ let de = ee[re];+ de === void 0 && (de = { type: void 0, texture: void 0 }, ee[re] = de), (de.type !== W || de.texture !== ne) && (J !== re && (i.activeTexture(re), J = re), i.bindTexture(W, ne || be[W]), de.type = W, de.texture = ne);+ }+ function Z() {+ const W = ee[J];+ W !== void 0 && W.type !== void 0 && (i.bindTexture(W.type, null), W.type = void 0, W.texture = void 0);+ }+ function le() {+ try {+ i.compressedTexImage2D(...arguments);+ } catch (W) {+ console.error("THREE.WebGLState:", W);+ }+ }+ function pe() {+ try {+ i.compressedTexImage3D(...arguments);+ } catch (W) {+ console.error("THREE.WebGLState:", W);+ }+ }+ function oe() {+ try {+ i.texSubImage2D(...arguments);+ } catch (W) {+ console.error("THREE.WebGLState:", W);+ }+ }+ function Ue() {+ try {+ i.texSubImage3D(...arguments);+ } catch (W) {+ console.error("THREE.WebGLState:", W);+ }+ }+ function ve() {+ try {+ i.compressedTexSubImage2D(...arguments);+ } catch (W) {+ console.error("THREE.WebGLState:", W);+ }+ }+ function Ve() {+ try {+ i.compressedTexSubImage3D(...arguments);+ } catch (W) {+ console.error("THREE.WebGLState:", W);+ }+ }+ function Ye() {+ try {+ i.texStorage2D(...arguments);+ } catch (W) {+ console.error("THREE.WebGLState:", W);+ }+ }+ function _e() {+ try {+ i.texStorage3D(...arguments);+ } catch (W) {+ console.error("THREE.WebGLState:", W);+ }+ }+ function Re() {+ try {+ i.texImage2D(...arguments);+ } catch (W) {+ console.error("THREE.WebGLState:", W);+ }+ }+ function ke() {+ try {+ i.texImage3D(...arguments);+ } catch (W) {+ console.error("THREE.WebGLState:", W);+ }+ }+ function Oe(W) {+ Me.equals(W) === !1 && (i.scissor(W.x, W.y, W.z, W.w), Me.copy(W));+ }+ function Be(W) {+ se.equals(W) === !1 && (i.viewport(W.x, W.y, W.z, W.w), se.copy(W));+ }+ function tt(W, ne) {+ let re = l.get(ne);+ re === void 0 && (re = /* @__PURE__ */ new WeakMap(), l.set(ne, re));+ let de = re.get(W);+ de === void 0 && (de = i.getUniformBlockIndex(ne, W.name), re.set(W, de));+ }+ function We(W, ne) {+ const de = l.get(ne).get(W);+ c.get(ne) !== de && (i.uniformBlockBinding(ne, de, W.__bindingPointIndex), c.set(ne, de));+ }+ function nt() {+ i.disable(i.BLEND), i.disable(i.CULL_FACE), i.disable(i.DEPTH_TEST), i.disable(i.POLYGON_OFFSET_FILL), i.disable(i.SCISSOR_TEST), i.disable(i.STENCIL_TEST), i.disable(i.SAMPLE_ALPHA_TO_COVERAGE), i.blendEquation(i.FUNC_ADD), i.blendFunc(i.ONE, i.ZERO), i.blendFuncSeparate(i.ONE, i.ZERO, i.ONE, i.ZERO), i.blendColor(0, 0, 0, 0), i.colorMask(!0, !0, !0, !0), i.clearColor(0, 0, 0, 0), i.depthMask(!0), i.depthFunc(i.LESS), a.setReversed(!1), i.clearDepth(1), i.stencilMask(4294967295), i.stencilFunc(i.ALWAYS, 0, 4294967295), i.stencilOp(i.KEEP, i.KEEP, i.KEEP), i.clearStencil(0), i.cullFace(i.BACK), i.frontFace(i.CCW), i.polygonOffset(0, 0), i.activeTexture(i.TEXTURE0), i.bindFramebuffer(i.FRAMEBUFFER, null), i.bindFramebuffer(i.DRAW_FRAMEBUFFER, null), i.bindFramebuffer(i.READ_FRAMEBUFFER, null), i.useProgram(null), i.lineWidth(1), i.scissor(0, 0, i.canvas.width, i.canvas.height), i.viewport(0, 0, i.canvas.width, i.canvas.height), h = {}, J = null, ee = {}, u = {}, d = /* @__PURE__ */ new WeakMap(), f = [], m = null, A = !1, g = null, p = null, y = null, b = null, E = null, M = null, w = null, S = new je(0, 0, 0), T = 0, C = !1, v = null, F = null, K = null, q = null, $ = null, Me.set(0, 0, i.canvas.width, i.canvas.height), se.set(0, 0, i.canvas.width, i.canvas.height), r.reset(), a.reset(), o.reset();+ }+ return {+ buffers: {+ color: r,+ depth: a,+ stencil: o+ },+ enable: xe,+ disable: Pe,+ bindFramebuffer: $e,+ drawBuffers: Qe,+ useProgram: vt,+ setBlending: G,+ setMaterial: dn,+ setFlipSided: dt,+ setCullFace: pt,+ setLineWidth: ze,+ setPolygonOffset: Rt,+ setScissorTest: Ge,+ activeTexture: L,+ bindTexture: I,+ unbindTexture: Z,+ compressedTexImage2D: le,+ compressedTexImage3D: pe,+ texImage2D: Re,+ texImage3D: ke,+ updateUBOMapping: tt,+ uniformBlockBinding: We,+ texStorage2D: Ye,+ texStorage3D: _e,+ texSubImage2D: oe,+ texSubImage3D: Ue,+ compressedTexSubImage2D: ve,+ compressedTexSubImage3D: Ve,+ scissor: Oe,+ viewport: Be,+ reset: nt+ };+}+function CI(i, e, t, n, s, r, a) {+ const o = e.has("WEBGL_multisampled_render_to_texture") ? e.get("WEBGL_multisampled_render_to_texture") : null, c = typeof navigator > "u" ? !1 : /OculusBrowser/g.test(navigator.userAgent), l = new Ze(), h = /* @__PURE__ */ new WeakMap();+ let u;+ const d = /* @__PURE__ */ new WeakMap();+ let f = !1;+ try {+ f = typeof OffscreenCanvas < "u" && new OffscreenCanvas(1, 1).getContext("2d") !== null;+ } catch {+ }+ function m(L, I) {+ return f ? (+ // eslint-disable-next-line compat/compat+ new OffscreenCanvas(L, I)+ ) : Uo("canvas");+ }+ function A(L, I, Z) {+ let le = 1;+ const pe = Ge(L);+ if ((pe.width > Z || pe.height > Z) && (le = Z / Math.max(pe.width, pe.height)), le < 1)+ if (typeof HTMLImageElement < "u" && L instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && L instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && L instanceof ImageBitmap || typeof VideoFrame < "u" && L instanceof VideoFrame) {+ const oe = Math.floor(le * pe.width), Ue = Math.floor(le * pe.height);+ u === void 0 && (u = m(oe, Ue));+ const ve = I ? m(oe, Ue) : u;+ return ve.width = oe, ve.height = Ue, ve.getContext("2d").drawImage(L, 0, 0, oe, Ue), console.warn("THREE.WebGLRenderer: Texture has been resized from (" + pe.width + "x" + pe.height + ") to (" + oe + "x" + Ue + ")."), ve;+ } else+ return "data" in L && console.warn("THREE.WebGLRenderer: Image in DataTexture is too big (" + pe.width + "x" + pe.height + ")."), L;+ return L;+ }+ function g(L) {+ return L.generateMipmaps;+ }+ function p(L) {+ i.generateMipmap(L);+ }+ function y(L) {+ return L.isWebGLCubeRenderTarget ? i.TEXTURE_CUBE_MAP : L.isWebGL3DRenderTarget ? i.TEXTURE_3D : L.isWebGLArrayRenderTarget || L.isCompressedArrayTexture ? i.TEXTURE_2D_ARRAY : i.TEXTURE_2D;+ }+ function b(L, I, Z, le, pe = !1) {+ if (L !== null) {+ if (i[L] !== void 0) return i[L];+ console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '" + L + "'");+ }+ let oe = I;+ if (I === i.RED && (Z === i.FLOAT && (oe = i.R32F), Z === i.HALF_FLOAT && (oe = i.R16F), Z === i.UNSIGNED_BYTE && (oe = i.R8)), I === i.RED_INTEGER && (Z === i.UNSIGNED_BYTE && (oe = i.R8UI), Z === i.UNSIGNED_SHORT && (oe = i.R16UI), Z === i.UNSIGNED_INT && (oe = i.R32UI), Z === i.BYTE && (oe = i.R8I), Z === i.SHORT && (oe = i.R16I), Z === i.INT && (oe = i.R32I)), I === i.RG && (Z === i.FLOAT && (oe = i.RG32F), Z === i.HALF_FLOAT && (oe = i.RG16F), Z === i.UNSIGNED_BYTE && (oe = i.RG8)), I === i.RG_INTEGER && (Z === i.UNSIGNED_BYTE && (oe = i.RG8UI), Z === i.UNSIGNED_SHORT && (oe = i.RG16UI), Z === i.UNSIGNED_INT && (oe = i.RG32UI), Z === i.BYTE && (oe = i.RG8I), Z === i.SHORT && (oe = i.RG16I), Z === i.INT && (oe = i.RG32I)), I === i.RGB_INTEGER && (Z === i.UNSIGNED_BYTE && (oe = i.RGB8UI), Z === i.UNSIGNED_SHORT && (oe = i.RGB16UI), Z === i.UNSIGNED_INT && (oe = i.RGB32UI), Z === i.BYTE && (oe = i.RGB8I), Z === i.SHORT && (oe = i.RGB16I), Z === i.INT && (oe = i.RGB32I)), I === i.RGBA_INTEGER && (Z === i.UNSIGNED_BYTE && (oe = i.RGBA8UI), Z === i.UNSIGNED_SHORT && (oe = i.RGBA16UI), Z === i.UNSIGNED_INT && (oe = i.RGBA32UI), Z === i.BYTE && (oe = i.RGBA8I), Z === i.SHORT && (oe = i.RGBA16I), Z === i.INT && (oe = i.RGBA32I)), I === i.RGB && Z === i.UNSIGNED_INT_5_9_9_9_REV && (oe = i.RGB9_E5), I === i.RGBA) {+ const Ue = pe ? Bl : mt.getTransfer(le);+ Z === i.FLOAT && (oe = i.RGBA32F), Z === i.HALF_FLOAT && (oe = i.RGBA16F), Z === i.UNSIGNED_BYTE && (oe = Ue === Mt ? i.SRGB8_ALPHA8 : i.RGBA8), Z === i.UNSIGNED_SHORT_4_4_4_4 && (oe = i.RGBA4), Z === i.UNSIGNED_SHORT_5_5_5_1 && (oe = i.RGB5_A1);+ }+ return (oe === i.R16F || oe === i.R32F || oe === i.RG16F || oe === i.RG32F || oe === i.RGBA16F || oe === i.RGBA32F) && e.get("EXT_color_buffer_float"), oe;+ }+ function E(L, I) {+ let Z;+ return L ? I === null || I === yr || I === Ro ? Z = i.DEPTH24_STENCIL8 : I === an ? Z = i.DEPTH32F_STENCIL8 : I === To && (Z = i.DEPTH24_STENCIL8, console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")) : I === null || I === yr || I === Ro ? Z = i.DEPTH_COMPONENT24 : I === an ? Z = i.DEPTH_COMPONENT32F : I === To && (Z = i.DEPTH_COMPONENT16), Z;+ }+ function M(L, I) {+ return g(L) === !0 || L.isFramebufferTexture && L.minFilter !== kn && L.minFilter !== qt ? Math.log2(Math.max(I.width, I.height)) + 1 : L.mipmaps !== void 0 && L.mipmaps.length > 0 ? L.mipmaps.length : L.isCompressedTexture && Array.isArray(L.image) ? I.mipmaps.length : 1;+ }+ function w(L) {+ const I = L.target;+ I.removeEventListener("dispose", w), T(I), I.isVideoTexture && h.delete(I);+ }+ function S(L) {+ const I = L.target;+ I.removeEventListener("dispose", S), v(I);+ }+ function T(L) {+ const I = n.get(L);+ if (I.__webglInit === void 0) return;+ const Z = L.source, le = d.get(Z);+ if (le) {+ const pe = le[I.__cacheKey];+ pe.usedTimes--, pe.usedTimes === 0 && C(L), Object.keys(le).length === 0 && d.delete(Z);+ }+ n.remove(L);+ }+ function C(L) {+ const I = n.get(L);+ i.deleteTexture(I.__webglTexture);+ const Z = L.source, le = d.get(Z);+ delete le[I.__cacheKey], a.memory.textures--;+ }+ function v(L) {+ const I = n.get(L);+ if (L.depthTexture && (L.depthTexture.dispose(), n.remove(L.depthTexture)), L.isWebGLCubeRenderTarget)+ for (let le = 0; le < 6; le++) {+ if (Array.isArray(I.__webglFramebuffer[le]))+ for (let pe = 0; pe < I.__webglFramebuffer[le].length; pe++) i.deleteFramebuffer(I.__webglFramebuffer[le][pe]);+ else+ i.deleteFramebuffer(I.__webglFramebuffer[le]);+ I.__webglDepthbuffer && i.deleteRenderbuffer(I.__webglDepthbuffer[le]);+ }+ else {+ if (Array.isArray(I.__webglFramebuffer))+ for (let le = 0; le < I.__webglFramebuffer.length; le++) i.deleteFramebuffer(I.__webglFramebuffer[le]);+ else+ i.deleteFramebuffer(I.__webglFramebuffer);+ if (I.__webglDepthbuffer && i.deleteRenderbuffer(I.__webglDepthbuffer), I.__webglMultisampledFramebuffer && i.deleteFramebuffer(I.__webglMultisampledFramebuffer), I.__webglColorRenderbuffer)+ for (let le = 0; le < I.__webglColorRenderbuffer.length; le++)+ I.__webglColorRenderbuffer[le] && i.deleteRenderbuffer(I.__webglColorRenderbuffer[le]);+ I.__webglDepthRenderbuffer && i.deleteRenderbuffer(I.__webglDepthRenderbuffer);+ }+ const Z = L.textures;+ for (let le = 0, pe = Z.length; le < pe; le++) {+ const oe = n.get(Z[le]);+ oe.__webglTexture && (i.deleteTexture(oe.__webglTexture), a.memory.textures--), n.remove(Z[le]);+ }+ n.remove(L);+ }+ let F = 0;+ function K() {+ F = 0;+ }+ function q() {+ const L = F;+ return L >= s.maxTextures && console.warn("THREE.WebGLTextures: Trying to use " + L + " texture units while this GPU supports only " + s.maxTextures), F += 1, L;+ }+ function $(L) {+ const I = [];+ return I.push(L.wrapS), I.push(L.wrapT), I.push(L.wrapR || 0), I.push(L.magFilter), I.push(L.minFilter), I.push(L.anisotropy), I.push(L.internalFormat), I.push(L.format), I.push(L.type), I.push(L.generateMipmaps), I.push(L.premultiplyAlpha), I.push(L.flipY), I.push(L.unpackAlignment), I.push(L.colorSpace), I.join();+ }+ function D(L, I) {+ const Z = n.get(L);+ if (L.isVideoTexture && ze(L), L.isRenderTargetTexture === !1 && L.version > 0 && Z.__version !== L.version) {+ const le = L.image;+ if (le === null)+ console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");+ else if (le.complete === !1)+ console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");+ else {+ se(Z, L, I);+ return;+ }+ }+ t.bindTexture(i.TEXTURE_2D, Z.__webglTexture, i.TEXTURE0 + I);+ }+ function O(L, I) {+ const Z = n.get(L);+ if (L.version > 0 && Z.__version !== L.version) {+ se(Z, L, I);+ return;+ }+ t.bindTexture(i.TEXTURE_2D_ARRAY, Z.__webglTexture, i.TEXTURE0 + I);+ }+ function Y(L, I) {+ const Z = n.get(L);+ if (L.version > 0 && Z.__version !== L.version) {+ se(Z, L, I);+ return;+ }+ t.bindTexture(i.TEXTURE_3D, Z.__webglTexture, i.TEXTURE0 + I);+ }+ function Q(L, I) {+ const Z = n.get(L);+ if (L.version > 0 && Z.__version !== L.version) {+ me(Z, L, I);+ return;+ }+ t.bindTexture(i.TEXTURE_CUBE_MAP, Z.__webglTexture, i.TEXTURE0 + I);+ }+ const J = {+ [Ca]: i.REPEAT,+ [_i]: i.CLAMP_TO_EDGE,+ [El]: i.MIRRORED_REPEAT+ }, ee = {+ [kn]: i.NEAREST,+ [qm]: i.NEAREST_MIPMAP_NEAREST,+ [fo]: i.NEAREST_MIPMAP_LINEAR,+ [qt]: i.LINEAR,+ [ul]: i.LINEAR_MIPMAP_NEAREST,+ [si]: i.LINEAR_MIPMAP_LINEAR+ }, ae = {+ [rE]: i.NEVER,+ [uE]: i.ALWAYS,+ [aE]: i.LESS,+ [i0]: i.LEQUAL,+ [oE]: i.EQUAL,+ [hE]: i.GEQUAL,+ [cE]: i.GREATER,+ [lE]: i.NOTEQUAL+ };+ function ye(L, I) {+ if (I.type === an && e.has("OES_texture_float_linear") === !1 && (I.magFilter === qt || I.magFilter === ul || I.magFilter === fo || I.magFilter === si || I.minFilter === qt || I.minFilter === ul || I.minFilter === fo || I.minFilter === si) && console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."), i.texParameteri(L, i.TEXTURE_WRAP_S, J[I.wrapS]), i.texParameteri(L, i.TEXTURE_WRAP_T, J[I.wrapT]), (L === i.TEXTURE_3D || L === i.TEXTURE_2D_ARRAY) && i.texParameteri(L, i.TEXTURE_WRAP_R, J[I.wrapR]), i.texParameteri(L, i.TEXTURE_MAG_FILTER, ee[I.magFilter]), i.texParameteri(L, i.TEXTURE_MIN_FILTER, ee[I.minFilter]), I.compareFunction && (i.texParameteri(L, i.TEXTURE_COMPARE_MODE, i.COMPARE_REF_TO_TEXTURE), i.texParameteri(L, i.TEXTURE_COMPARE_FUNC, ae[I.compareFunction])), e.has("EXT_texture_filter_anisotropic") === !0) {+ if (I.magFilter === kn || I.minFilter !== fo && I.minFilter !== si || I.type === an && e.has("OES_texture_float_linear") === !1) return;+ if (I.anisotropy > 1 || n.get(I).__currentAnisotropy) {+ const Z = e.get("EXT_texture_filter_anisotropic");+ i.texParameterf(L, Z.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(I.anisotropy, s.getMaxAnisotropy())), n.get(I).__currentAnisotropy = I.anisotropy;+ }+ }+ }+ function Me(L, I) {+ let Z = !1;+ L.__webglInit === void 0 && (L.__webglInit = !0, I.addEventListener("dispose", w));+ const le = I.source;+ let pe = d.get(le);+ pe === void 0 && (pe = {}, d.set(le, pe));+ const oe = $(I);+ if (oe !== L.__cacheKey) {+ pe[oe] === void 0 && (pe[oe] = {+ texture: i.createTexture(),+ usedTimes: 0+ }, a.memory.textures++, Z = !0), pe[oe].usedTimes++;+ const Ue = pe[L.__cacheKey];+ Ue !== void 0 && (pe[L.__cacheKey].usedTimes--, Ue.usedTimes === 0 && C(I)), L.__cacheKey = oe, L.__webglTexture = pe[oe].texture;+ }+ return Z;+ }+ function se(L, I, Z) {+ let le = i.TEXTURE_2D;+ (I.isDataArrayTexture || I.isCompressedArrayTexture) && (le = i.TEXTURE_2D_ARRAY), I.isData3DTexture && (le = i.TEXTURE_3D);+ const pe = Me(L, I), oe = I.source;+ t.bindTexture(le, L.__webglTexture, i.TEXTURE0 + Z);+ const Ue = n.get(oe);+ if (oe.version !== Ue.__version || pe === !0) {+ t.activeTexture(i.TEXTURE0 + Z);+ const ve = mt.getPrimaries(mt.workingColorSpace), Ve = I.colorSpace === gi ? null : mt.getPrimaries(I.colorSpace), Ye = I.colorSpace === gi || ve === Ve ? i.NONE : i.BROWSER_DEFAULT_WEBGL;+ i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, I.flipY), i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL, I.premultiplyAlpha), i.pixelStorei(i.UNPACK_ALIGNMENT, I.unpackAlignment), i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL, Ye);+ let _e = A(I.image, !1, s.maxTextureSize);+ _e = Rt(I, _e);+ const Re = r.convert(I.format, I.colorSpace), ke = r.convert(I.type);+ let Oe = b(I.internalFormat, Re, ke, I.colorSpace, I.isVideoTexture);+ ye(le, I);+ let Be;+ const tt = I.mipmaps, We = I.isVideoTexture !== !0, nt = Ue.__version === void 0 || pe === !0, W = oe.dataReady, ne = M(I, _e);+ if (I.isDepthTexture)+ Oe = E(I.format === Fo, I.type), nt && (We ? t.texStorage2D(i.TEXTURE_2D, 1, Oe, _e.width, _e.height) : t.texImage2D(i.TEXTURE_2D, 0, Oe, _e.width, _e.height, 0, Re, ke, null));+ else if (I.isDataTexture)+ if (tt.length > 0) {+ We && nt && t.texStorage2D(i.TEXTURE_2D, ne, Oe, tt[0].width, tt[0].height);+ for (let re = 0, de = tt.length; re < de; re++)+ Be = tt[re], We ? W && t.texSubImage2D(i.TEXTURE_2D, re, 0, 0, Be.width, Be.height, Re, ke, Be.data) : t.texImage2D(i.TEXTURE_2D, re, Oe, Be.width, Be.height, 0, Re, ke, Be.data);+ I.generateMipmaps = !1;+ } else+ We ? (nt && t.texStorage2D(i.TEXTURE_2D, ne, Oe, _e.width, _e.height), W && t.texSubImage2D(i.TEXTURE_2D, 0, 0, 0, _e.width, _e.height, Re, ke, _e.data)) : t.texImage2D(i.TEXTURE_2D, 0, Oe, _e.width, _e.height, 0, Re, ke, _e.data);+ else if (I.isCompressedTexture)+ if (I.isCompressedArrayTexture) {+ We && nt && t.texStorage3D(i.TEXTURE_2D_ARRAY, ne, Oe, tt[0].width, tt[0].height, _e.depth);+ for (let re = 0, de = tt.length; re < de; re++)+ if (Be = tt[re], I.format !== on)+ if (Re !== null)+ if (We) {+ if (W)+ if (I.layerUpdates.size > 0) {+ const Ie = iA(Be.width, Be.height, I.format, I.type);+ for (const Ce of I.layerUpdates) {+ const it = Be.data.subarray(+ Ce * Ie / Be.data.BYTES_PER_ELEMENT,+ (Ce + 1) * Ie / Be.data.BYTES_PER_ELEMENT+ );+ t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY, re, 0, 0, Ce, Be.width, Be.height, 1, Re, it);+ }+ I.clearLayerUpdates();+ } else+ t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY, re, 0, 0, 0, Be.width, Be.height, _e.depth, Re, Be.data);+ } else+ t.compressedTexImage3D(i.TEXTURE_2D_ARRAY, re, Oe, Be.width, Be.height, _e.depth, 0, Be.data, 0, 0);+ else+ console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");+ else+ We ? W && t.texSubImage3D(i.TEXTURE_2D_ARRAY, re, 0, 0, 0, Be.width, Be.height, _e.depth, Re, ke, Be.data) : t.texImage3D(i.TEXTURE_2D_ARRAY, re, Oe, Be.width, Be.height, _e.depth, 0, Re, ke, Be.data);+ } else {+ We && nt && t.texStorage2D(i.TEXTURE_2D, ne, Oe, tt[0].width, tt[0].height);+ for (let re = 0, de = tt.length; re < de; re++)+ Be = tt[re], I.format !== on ? Re !== null ? We ? W && t.compressedTexSubImage2D(i.TEXTURE_2D, re, 0, 0, Be.width, Be.height, Re, Be.data) : t.compressedTexImage2D(i.TEXTURE_2D, re, Oe, Be.width, Be.height, 0, Be.data) : console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()") : We ? W && t.texSubImage2D(i.TEXTURE_2D, re, 0, 0, Be.width, Be.height, Re, ke, Be.data) : t.texImage2D(i.TEXTURE_2D, re, Oe, Be.width, Be.height, 0, Re, ke, Be.data);+ }+ else if (I.isDataArrayTexture)+ if (We) {+ if (nt && t.texStorage3D(i.TEXTURE_2D_ARRAY, ne, Oe, _e.width, _e.height, _e.depth), W)+ if (I.layerUpdates.size > 0) {+ const re = iA(_e.width, _e.height, I.format, I.type);+ for (const de of I.layerUpdates) {+ const Ie = _e.data.subarray(+ de * re / _e.data.BYTES_PER_ELEMENT,+ (de + 1) * re / _e.data.BYTES_PER_ELEMENT+ );+ t.texSubImage3D(i.TEXTURE_2D_ARRAY, 0, 0, 0, de, _e.width, _e.height, 1, Re, ke, Ie);+ }+ I.clearLayerUpdates();+ } else+ t.texSubImage3D(i.TEXTURE_2D_ARRAY, 0, 0, 0, 0, _e.width, _e.height, _e.depth, Re, ke, _e.data);+ } else+ t.texImage3D(i.TEXTURE_2D_ARRAY, 0, Oe, _e.width, _e.height, _e.depth, 0, Re, ke, _e.data);+ else if (I.isData3DTexture)+ We ? (nt && t.texStorage3D(i.TEXTURE_3D, ne, Oe, _e.width, _e.height, _e.depth), W && t.texSubImage3D(i.TEXTURE_3D, 0, 0, 0, 0, _e.width, _e.height, _e.depth, Re, ke, _e.data)) : t.texImage3D(i.TEXTURE_3D, 0, Oe, _e.width, _e.height, _e.depth, 0, Re, ke, _e.data);+ else if (I.isFramebufferTexture) {+ if (nt)+ if (We)+ t.texStorage2D(i.TEXTURE_2D, ne, Oe, _e.width, _e.height);+ else {+ let re = _e.width, de = _e.height;+ for (let Ie = 0; Ie < ne; Ie++)+ t.texImage2D(i.TEXTURE_2D, Ie, Oe, re, de, 0, Re, ke, null), re >>= 1, de >>= 1;+ }+ } else if (tt.length > 0) {+ if (We && nt) {+ const re = Ge(tt[0]);+ t.texStorage2D(i.TEXTURE_2D, ne, Oe, re.width, re.height);+ }+ for (let re = 0, de = tt.length; re < de; re++)+ Be = tt[re], We ? W && t.texSubImage2D(i.TEXTURE_2D, re, 0, 0, Re, ke, Be) : t.texImage2D(i.TEXTURE_2D, re, Oe, Re, ke, Be);+ I.generateMipmaps = !1;+ } else if (We) {+ if (nt) {+ const re = Ge(_e);+ t.texStorage2D(i.TEXTURE_2D, ne, Oe, re.width, re.height);+ }+ W && t.texSubImage2D(i.TEXTURE_2D, 0, 0, 0, Re, ke, _e);+ } else+ t.texImage2D(i.TEXTURE_2D, 0, Oe, Re, ke, _e);+ g(I) && p(le), Ue.__version = oe.version, I.onUpdate && I.onUpdate(I);+ }+ L.__version = I.version;+ }+ function me(L, I, Z) {+ if (I.image.length !== 6) return;+ const le = Me(L, I), pe = I.source;+ t.bindTexture(i.TEXTURE_CUBE_MAP, L.__webglTexture, i.TEXTURE0 + Z);+ const oe = n.get(pe);+ if (pe.version !== oe.__version || le === !0) {+ t.activeTexture(i.TEXTURE0 + Z);+ const Ue = mt.getPrimaries(mt.workingColorSpace), ve = I.colorSpace === gi ? null : mt.getPrimaries(I.colorSpace), Ve = I.colorSpace === gi || Ue === ve ? i.NONE : i.BROWSER_DEFAULT_WEBGL;+ i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, I.flipY), i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL, I.premultiplyAlpha), i.pixelStorei(i.UNPACK_ALIGNMENT, I.unpackAlignment), i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL, Ve);+ const Ye = I.isCompressedTexture || I.image[0].isCompressedTexture, _e = I.image[0] && I.image[0].isDataTexture, Re = [];+ for (let de = 0; de < 6; de++)+ !Ye && !_e ? Re[de] = A(I.image[de], !0, s.maxCubemapSize) : Re[de] = _e ? I.image[de].image : I.image[de], Re[de] = Rt(I, Re[de]);+ const ke = Re[0], Oe = r.convert(I.format, I.colorSpace), Be = r.convert(I.type), tt = b(I.internalFormat, Oe, Be, I.colorSpace), We = I.isVideoTexture !== !0, nt = oe.__version === void 0 || le === !0, W = pe.dataReady;+ let ne = M(I, ke);+ ye(i.TEXTURE_CUBE_MAP, I);+ let re;+ if (Ye) {+ We && nt && t.texStorage2D(i.TEXTURE_CUBE_MAP, ne, tt, ke.width, ke.height);+ for (let de = 0; de < 6; de++) {+ re = Re[de].mipmaps;+ for (let Ie = 0; Ie < re.length; Ie++) {+ const Ce = re[Ie];+ I.format !== on ? Oe !== null ? We ? W && t.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + de, Ie, 0, 0, Ce.width, Ce.height, Oe, Ce.data) : t.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + de, Ie, tt, Ce.width, Ce.height, 0, Ce.data) : console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()") : We ? W && t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + de, Ie, 0, 0, Ce.width, Ce.height, Oe, Be, Ce.data) : t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + de, Ie, tt, Ce.width, Ce.height, 0, Oe, Be, Ce.data);+ }+ }+ } else {+ if (re = I.mipmaps, We && nt) {+ re.length > 0 && ne++;+ const de = Ge(Re[0]);+ t.texStorage2D(i.TEXTURE_CUBE_MAP, ne, tt, de.width, de.height);+ }+ for (let de = 0; de < 6; de++)+ if (_e) {+ We ? W && t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + de, 0, 0, 0, Re[de].width, Re[de].height, Oe, Be, Re[de].data) : t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + de, 0, tt, Re[de].width, Re[de].height, 0, Oe, Be, Re[de].data);+ for (let Ie = 0; Ie < re.length; Ie++) {+ const it = re[Ie].image[de].image;+ We ? W && t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + de, Ie + 1, 0, 0, it.width, it.height, Oe, Be, it.data) : t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + de, Ie + 1, tt, it.width, it.height, 0, Oe, Be, it.data);+ }+ } else {+ We ? W && t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + de, 0, 0, 0, Oe, Be, Re[de]) : t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + de, 0, tt, Oe, Be, Re[de]);+ for (let Ie = 0; Ie < re.length; Ie++) {+ const Ce = re[Ie];+ We ? W && t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + de, Ie + 1, 0, 0, Oe, Be, Ce.image[de]) : t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + de, Ie + 1, tt, Oe, Be, Ce.image[de]);+ }+ }+ }+ g(I) && p(i.TEXTURE_CUBE_MAP), oe.__version = pe.version, I.onUpdate && I.onUpdate(I);+ }+ L.__version = I.version;+ }+ function be(L, I, Z, le, pe, oe) {+ const Ue = r.convert(Z.format, Z.colorSpace), ve = r.convert(Z.type), Ve = b(Z.internalFormat, Ue, ve, Z.colorSpace), Ye = n.get(I), _e = n.get(Z);+ if (_e.__renderTarget = I, !Ye.__hasExternalTextures) {+ const Re = Math.max(1, I.width >> oe), ke = Math.max(1, I.height >> oe);+ pe === i.TEXTURE_3D || pe === i.TEXTURE_2D_ARRAY ? t.texImage3D(pe, oe, Ve, Re, ke, I.depth, 0, Ue, ve, null) : t.texImage2D(pe, oe, Ve, Re, ke, 0, Ue, ve, null);+ }+ t.bindFramebuffer(i.FRAMEBUFFER, L), pt(I) ? o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER, le, pe, _e.__webglTexture, 0, dt(I)) : (pe === i.TEXTURE_2D || pe >= i.TEXTURE_CUBE_MAP_POSITIVE_X && pe <= i.TEXTURE_CUBE_MAP_NEGATIVE_Z) && i.framebufferTexture2D(i.FRAMEBUFFER, le, pe, _e.__webglTexture, oe), t.bindFramebuffer(i.FRAMEBUFFER, null);+ }+ function xe(L, I, Z) {+ if (i.bindRenderbuffer(i.RENDERBUFFER, L), I.depthBuffer) {+ const le = I.depthTexture, pe = le && le.isDepthTexture ? le.type : null, oe = E(I.stencilBuffer, pe), Ue = I.stencilBuffer ? i.DEPTH_STENCIL_ATTACHMENT : i.DEPTH_ATTACHMENT, ve = dt(I);+ pt(I) ? o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER, ve, oe, I.width, I.height) : Z ? i.renderbufferStorageMultisample(i.RENDERBUFFER, ve, oe, I.width, I.height) : i.renderbufferStorage(i.RENDERBUFFER, oe, I.width, I.height), i.framebufferRenderbuffer(i.FRAMEBUFFER, Ue, i.RENDERBUFFER, L);+ } else {+ const le = I.textures;+ for (let pe = 0; pe < le.length; pe++) {+ const oe = le[pe], Ue = r.convert(oe.format, oe.colorSpace), ve = r.convert(oe.type), Ve = b(oe.internalFormat, Ue, ve, oe.colorSpace), Ye = dt(I);+ Z && pt(I) === !1 ? i.renderbufferStorageMultisample(i.RENDERBUFFER, Ye, Ve, I.width, I.height) : pt(I) ? o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER, Ye, Ve, I.width, I.height) : i.renderbufferStorage(i.RENDERBUFFER, Ve, I.width, I.height);+ }+ }+ i.bindRenderbuffer(i.RENDERBUFFER, null);+ }+ function Pe(L, I) {+ if (I && I.isWebGLCubeRenderTarget) throw new Error("Depth Texture with cube render targets is not supported");+ if (t.bindFramebuffer(i.FRAMEBUFFER, L), !(I.depthTexture && I.depthTexture.isDepthTexture))+ throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");+ const le = n.get(I.depthTexture);+ le.__renderTarget = I, (!le.__webglTexture || I.depthTexture.image.width !== I.width || I.depthTexture.image.height !== I.height) && (I.depthTexture.image.width = I.width, I.depthTexture.image.height = I.height, I.depthTexture.needsUpdate = !0), D(I.depthTexture, 0);+ const pe = le.__webglTexture, oe = dt(I);+ if (I.depthTexture.format === No)+ pt(I) ? o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER, i.DEPTH_ATTACHMENT, i.TEXTURE_2D, pe, 0, oe) : i.framebufferTexture2D(i.FRAMEBUFFER, i.DEPTH_ATTACHMENT, i.TEXTURE_2D, pe, 0);+ else if (I.depthTexture.format === Fo)+ pt(I) ? o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER, i.DEPTH_STENCIL_ATTACHMENT, i.TEXTURE_2D, pe, 0, oe) : i.framebufferTexture2D(i.FRAMEBUFFER, i.DEPTH_STENCIL_ATTACHMENT, i.TEXTURE_2D, pe, 0);+ else+ throw new Error("Unknown depthTexture format");+ }+ function $e(L) {+ const I = n.get(L), Z = L.isWebGLCubeRenderTarget === !0;+ if (I.__boundDepthTexture !== L.depthTexture) {+ const le = L.depthTexture;+ if (I.__depthDisposeCallback && I.__depthDisposeCallback(), le) {+ const pe = () => {+ delete I.__boundDepthTexture, delete I.__depthDisposeCallback, le.removeEventListener("dispose", pe);+ };+ le.addEventListener("dispose", pe), I.__depthDisposeCallback = pe;+ }+ I.__boundDepthTexture = le;+ }+ if (L.depthTexture && !I.__autoAllocateDepthBuffer) {+ if (Z) throw new Error("target.depthTexture not supported in Cube render targets");+ const le = L.texture.mipmaps;+ le && le.length > 0 ? Pe(I.__webglFramebuffer[0], L) : Pe(I.__webglFramebuffer, L);+ } else if (Z) {+ I.__webglDepthbuffer = [];+ for (let le = 0; le < 6; le++)+ if (t.bindFramebuffer(i.FRAMEBUFFER, I.__webglFramebuffer[le]), I.__webglDepthbuffer[le] === void 0)+ I.__webglDepthbuffer[le] = i.createRenderbuffer(), xe(I.__webglDepthbuffer[le], L, !1);+ else {+ const pe = L.stencilBuffer ? i.DEPTH_STENCIL_ATTACHMENT : i.DEPTH_ATTACHMENT, oe = I.__webglDepthbuffer[le];+ i.bindRenderbuffer(i.RENDERBUFFER, oe), i.framebufferRenderbuffer(i.FRAMEBUFFER, pe, i.RENDERBUFFER, oe);+ }+ } else {+ const le = L.texture.mipmaps;+ if (le && le.length > 0 ? t.bindFramebuffer(i.FRAMEBUFFER, I.__webglFramebuffer[0]) : t.bindFramebuffer(i.FRAMEBUFFER, I.__webglFramebuffer), I.__webglDepthbuffer === void 0)+ I.__webglDepthbuffer = i.createRenderbuffer(), xe(I.__webglDepthbuffer, L, !1);+ else {+ const pe = L.stencilBuffer ? i.DEPTH_STENCIL_ATTACHMENT : i.DEPTH_ATTACHMENT, oe = I.__webglDepthbuffer;+ i.bindRenderbuffer(i.RENDERBUFFER, oe), i.framebufferRenderbuffer(i.FRAMEBUFFER, pe, i.RENDERBUFFER, oe);+ }+ }+ t.bindFramebuffer(i.FRAMEBUFFER, null);+ }+ function Qe(L, I, Z) {+ const le = n.get(L);+ I !== void 0 && be(le.__webglFramebuffer, L, L.texture, i.COLOR_ATTACHMENT0, i.TEXTURE_2D, 0), Z !== void 0 && $e(L);+ }+ function vt(L) {+ const I = L.texture, Z = n.get(L), le = n.get(I);+ L.addEventListener("dispose", S);+ const pe = L.textures, oe = L.isWebGLCubeRenderTarget === !0, Ue = pe.length > 1;+ if (Ue || (le.__webglTexture === void 0 && (le.__webglTexture = i.createTexture()), le.__version = I.version, a.memory.textures++), oe) {+ Z.__webglFramebuffer = [];+ for (let ve = 0; ve < 6; ve++)+ if (I.mipmaps && I.mipmaps.length > 0) {+ Z.__webglFramebuffer[ve] = [];+ for (let Ve = 0; Ve < I.mipmaps.length; Ve++)+ Z.__webglFramebuffer[ve][Ve] = i.createFramebuffer();+ } else+ Z.__webglFramebuffer[ve] = i.createFramebuffer();+ } else {+ if (I.mipmaps && I.mipmaps.length > 0) {+ Z.__webglFramebuffer = [];+ for (let ve = 0; ve < I.mipmaps.length; ve++)+ Z.__webglFramebuffer[ve] = i.createFramebuffer();+ } else+ Z.__webglFramebuffer = i.createFramebuffer();+ if (Ue)+ for (let ve = 0, Ve = pe.length; ve < Ve; ve++) {+ const Ye = n.get(pe[ve]);+ Ye.__webglTexture === void 0 && (Ye.__webglTexture = i.createTexture(), a.memory.textures++);+ }+ if (L.samples > 0 && pt(L) === !1) {+ Z.__webglMultisampledFramebuffer = i.createFramebuffer(), Z.__webglColorRenderbuffer = [], t.bindFramebuffer(i.FRAMEBUFFER, Z.__webglMultisampledFramebuffer);+ for (let ve = 0; ve < pe.length; ve++) {+ const Ve = pe[ve];+ Z.__webglColorRenderbuffer[ve] = i.createRenderbuffer(), i.bindRenderbuffer(i.RENDERBUFFER, Z.__webglColorRenderbuffer[ve]);+ const Ye = r.convert(Ve.format, Ve.colorSpace), _e = r.convert(Ve.type), Re = b(Ve.internalFormat, Ye, _e, Ve.colorSpace, L.isXRRenderTarget === !0), ke = dt(L);+ i.renderbufferStorageMultisample(i.RENDERBUFFER, ke, Re, L.width, L.height), i.framebufferRenderbuffer(i.FRAMEBUFFER, i.COLOR_ATTACHMENT0 + ve, i.RENDERBUFFER, Z.__webglColorRenderbuffer[ve]);+ }+ i.bindRenderbuffer(i.RENDERBUFFER, null), L.depthBuffer && (Z.__webglDepthRenderbuffer = i.createRenderbuffer(), xe(Z.__webglDepthRenderbuffer, L, !0)), t.bindFramebuffer(i.FRAMEBUFFER, null);+ }+ }+ if (oe) {+ t.bindTexture(i.TEXTURE_CUBE_MAP, le.__webglTexture), ye(i.TEXTURE_CUBE_MAP, I);+ for (let ve = 0; ve < 6; ve++)+ if (I.mipmaps && I.mipmaps.length > 0)+ for (let Ve = 0; Ve < I.mipmaps.length; Ve++)+ be(Z.__webglFramebuffer[ve][Ve], L, I, i.COLOR_ATTACHMENT0, i.TEXTURE_CUBE_MAP_POSITIVE_X + ve, Ve);+ else+ be(Z.__webglFramebuffer[ve], L, I, i.COLOR_ATTACHMENT0, i.TEXTURE_CUBE_MAP_POSITIVE_X + ve, 0);+ g(I) && p(i.TEXTURE_CUBE_MAP), t.unbindTexture();+ } else if (Ue) {+ for (let ve = 0, Ve = pe.length; ve < Ve; ve++) {+ const Ye = pe[ve], _e = n.get(Ye);+ t.bindTexture(i.TEXTURE_2D, _e.__webglTexture), ye(i.TEXTURE_2D, Ye), be(Z.__webglFramebuffer, L, Ye, i.COLOR_ATTACHMENT0 + ve, i.TEXTURE_2D, 0), g(Ye) && p(i.TEXTURE_2D);+ }+ t.unbindTexture();+ } else {+ let ve = i.TEXTURE_2D;+ if ((L.isWebGL3DRenderTarget || L.isWebGLArrayRenderTarget) && (ve = L.isWebGL3DRenderTarget ? i.TEXTURE_3D : i.TEXTURE_2D_ARRAY), t.bindTexture(ve, le.__webglTexture), ye(ve, I), I.mipmaps && I.mipmaps.length > 0)+ for (let Ve = 0; Ve < I.mipmaps.length; Ve++)+ be(Z.__webglFramebuffer[Ve], L, I, i.COLOR_ATTACHMENT0, ve, Ve);+ else+ be(Z.__webglFramebuffer, L, I, i.COLOR_ATTACHMENT0, ve, 0);+ g(I) && p(ve), t.unbindTexture();+ }+ L.depthBuffer && $e(L);+ }+ function lt(L) {+ const I = L.textures;+ for (let Z = 0, le = I.length; Z < le; Z++) {+ const pe = I[Z];+ if (g(pe)) {+ const oe = y(L), Ue = n.get(pe).__webglTexture;+ t.bindTexture(oe, Ue), p(oe), t.unbindTexture();+ }+ }+ }+ const Je = [], G = [];+ function dn(L) {+ if (L.samples > 0) {+ if (pt(L) === !1) {+ const I = L.textures, Z = L.width, le = L.height;+ let pe = i.COLOR_BUFFER_BIT;+ const oe = L.stencilBuffer ? i.DEPTH_STENCIL_ATTACHMENT : i.DEPTH_ATTACHMENT, Ue = n.get(L), ve = I.length > 1;+ if (ve)+ for (let Ye = 0; Ye < I.length; Ye++)+ t.bindFramebuffer(i.FRAMEBUFFER, Ue.__webglMultisampledFramebuffer), i.framebufferRenderbuffer(i.FRAMEBUFFER, i.COLOR_ATTACHMENT0 + Ye, i.RENDERBUFFER, null), t.bindFramebuffer(i.FRAMEBUFFER, Ue.__webglFramebuffer), i.framebufferTexture2D(i.DRAW_FRAMEBUFFER, i.COLOR_ATTACHMENT0 + Ye, i.TEXTURE_2D, null, 0);+ t.bindFramebuffer(i.READ_FRAMEBUFFER, Ue.__webglMultisampledFramebuffer);+ const Ve = L.texture.mipmaps;+ Ve && Ve.length > 0 ? t.bindFramebuffer(i.DRAW_FRAMEBUFFER, Ue.__webglFramebuffer[0]) : t.bindFramebuffer(i.DRAW_FRAMEBUFFER, Ue.__webglFramebuffer);+ for (let Ye = 0; Ye < I.length; Ye++) {+ if (L.resolveDepthBuffer && (L.depthBuffer && (pe |= i.DEPTH_BUFFER_BIT), L.stencilBuffer && L.resolveStencilBuffer && (pe |= i.STENCIL_BUFFER_BIT)), ve) {+ i.framebufferRenderbuffer(i.READ_FRAMEBUFFER, i.COLOR_ATTACHMENT0, i.RENDERBUFFER, Ue.__webglColorRenderbuffer[Ye]);+ const _e = n.get(I[Ye]).__webglTexture;+ i.framebufferTexture2D(i.DRAW_FRAMEBUFFER, i.COLOR_ATTACHMENT0, i.TEXTURE_2D, _e, 0);+ }+ i.blitFramebuffer(0, 0, Z, le, 0, 0, Z, le, pe, i.NEAREST), c === !0 && (Je.length = 0, G.length = 0, Je.push(i.COLOR_ATTACHMENT0 + Ye), L.depthBuffer && L.resolveDepthBuffer === !1 && (Je.push(oe), G.push(oe), i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER, G)), i.invalidateFramebuffer(i.READ_FRAMEBUFFER, Je));+ }+ if (t.bindFramebuffer(i.READ_FRAMEBUFFER, null), t.bindFramebuffer(i.DRAW_FRAMEBUFFER, null), ve)+ for (let Ye = 0; Ye < I.length; Ye++) {+ t.bindFramebuffer(i.FRAMEBUFFER, Ue.__webglMultisampledFramebuffer), i.framebufferRenderbuffer(i.FRAMEBUFFER, i.COLOR_ATTACHMENT0 + Ye, i.RENDERBUFFER, Ue.__webglColorRenderbuffer[Ye]);+ const _e = n.get(I[Ye]).__webglTexture;+ t.bindFramebuffer(i.FRAMEBUFFER, Ue.__webglFramebuffer), i.framebufferTexture2D(i.DRAW_FRAMEBUFFER, i.COLOR_ATTACHMENT0 + Ye, i.TEXTURE_2D, _e, 0);+ }+ t.bindFramebuffer(i.DRAW_FRAMEBUFFER, Ue.__webglMultisampledFramebuffer);+ } else if (L.depthBuffer && L.resolveDepthBuffer === !1 && c) {+ const I = L.stencilBuffer ? i.DEPTH_STENCIL_ATTACHMENT : i.DEPTH_ATTACHMENT;+ i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER, [I]);+ }+ }+ }+ function dt(L) {+ return Math.min(s.maxSamples, L.samples);+ }+ function pt(L) {+ const I = n.get(L);+ return L.samples > 0 && e.has("WEBGL_multisampled_render_to_texture") === !0 && I.__useRenderToTexture !== !1;+ }+ function ze(L) {+ const I = a.render.frame;+ h.get(L) !== I && (h.set(L, I), L.update());+ }+ function Rt(L, I) {+ const Z = L.colorSpace, le = L.format, pe = L.type;+ return L.isCompressedTexture === !0 || L.isVideoTexture === !0 || Z !== ln && Z !== gi && (mt.getTransfer(Z) === Mt ? (le !== on || pe !== rn) && console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.") : console.error("THREE.WebGLTextures: Unsupported texture color space:", Z)), I;+ }+ function Ge(L) {+ return typeof HTMLImageElement < "u" && L instanceof HTMLImageElement ? (l.width = L.naturalWidth || L.width, l.height = L.naturalHeight || L.height) : typeof VideoFrame < "u" && L instanceof VideoFrame ? (l.width = L.displayWidth, l.height = L.displayHeight) : (l.width = L.width, l.height = L.height), l;+ }+ this.allocateTextureUnit = q, this.resetTextureUnits = K, this.setTexture2D = D, this.setTexture2DArray = O, this.setTexture3D = Y, this.setTextureCube = Q, this.rebindTextures = Qe, this.setupRenderTarget = vt, this.updateRenderTargetMipmap = lt, this.updateMultisampleRenderTarget = dn, this.setupDepthRenderbuffer = $e, this.setupFrameBufferTexture = be, this.useMultisampledRTT = pt;+}+function SI(i, e) {+ function t(n, s = gi) {+ let r;+ const a = mt.getTransfer(s);+ if (n === rn) return i.UNSIGNED_BYTE;+ if (n === pf) return i.UNSIGNED_SHORT_4_4_4_4;+ if (n === Af) return i.UNSIGNED_SHORT_5_5_5_1;+ if (n === Xm) return i.UNSIGNED_INT_5_9_9_9_REV;+ if (n === Km) return i.BYTE;+ if (n === jm) return i.SHORT;+ if (n === To) return i.UNSIGNED_SHORT;+ if (n === ff) return i.INT;+ if (n === yr) return i.UNSIGNED_INT;+ if (n === an) return i.FLOAT;+ if (n === Nn) return i.HALF_FLOAT;+ if (n === Ym) return i.ALPHA;+ if (n === Jm) return i.RGB;+ if (n === on) return i.RGBA;+ if (n === No) return i.DEPTH_COMPONENT;+ if (n === Fo) return i.DEPTH_STENCIL;+ if (n === ns) return i.RED;+ if (n === gf) return i.RED_INTEGER;+ if (n === dr) return i.RG;+ if (n === mf) return i.RG_INTEGER;+ if (n === bf) return i.RGBA_INTEGER;+ if (n === dl || n === xo || n === fl || n === _o)+ if (a === Mt)+ if (r = e.get("WEBGL_compressed_texture_s3tc_srgb"), r !== null) {+ if (n === dl) return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;+ if (n === xo) return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;+ if (n === fl) return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;+ if (n === _o) return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT;+ } else+ return null;+ else if (r = e.get("WEBGL_compressed_texture_s3tc"), r !== null) {+ if (n === dl) return r.COMPRESSED_RGB_S3TC_DXT1_EXT;+ if (n === xo) return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;+ if (n === fl) return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;+ if (n === _o) return r.COMPRESSED_RGBA_S3TC_DXT5_EXT;+ } else+ return null;+ if (n === yl || n === ed || n === wl || n === td)+ if (r = e.get("WEBGL_compressed_texture_pvrtc"), r !== null) {+ if (n === yl) return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;+ if (n === ed) return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;+ if (n === wl) return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;+ if (n === td) return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;+ } else+ return null;+ if (n === vl || n === Cl || n === Sl)+ if (r = e.get("WEBGL_compressed_texture_etc"), r !== null) {+ if (n === vl || n === Cl) return a === Mt ? r.COMPRESSED_SRGB8_ETC2 : r.COMPRESSED_RGB8_ETC2;+ if (n === Sl) return a === Mt ? r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC : r.COMPRESSED_RGBA8_ETC2_EAC;+ } else+ return null;+ if (n === Do || n === nd || n === id || n === sd || n === Lo || n === rd || n === ad || n === od || n === cd || n === ld || n === hd || n === ud || n === dd || n === fd)+ if (r = e.get("WEBGL_compressed_texture_astc"), r !== null) {+ if (n === Do) return a === Mt ? r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR : r.COMPRESSED_RGBA_ASTC_4x4_KHR;+ if (n === nd) return a === Mt ? r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR : r.COMPRESSED_RGBA_ASTC_5x4_KHR;+ if (n === id) return a === Mt ? r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR : r.COMPRESSED_RGBA_ASTC_5x5_KHR;+ if (n === sd) return a === Mt ? r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR : r.COMPRESSED_RGBA_ASTC_6x5_KHR;+ if (n === Lo) return a === Mt ? r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR : r.COMPRESSED_RGBA_ASTC_6x6_KHR;+ if (n === rd) return a === Mt ? r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR : r.COMPRESSED_RGBA_ASTC_8x5_KHR;+ if (n === ad) return a === Mt ? r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR : r.COMPRESSED_RGBA_ASTC_8x6_KHR;+ if (n === od) return a === Mt ? r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR : r.COMPRESSED_RGBA_ASTC_8x8_KHR;+ if (n === cd) return a === Mt ? r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR : r.COMPRESSED_RGBA_ASTC_10x5_KHR;+ if (n === ld) return a === Mt ? r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR : r.COMPRESSED_RGBA_ASTC_10x6_KHR;+ if (n === hd) return a === Mt ? r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR : r.COMPRESSED_RGBA_ASTC_10x8_KHR;+ if (n === ud) return a === Mt ? r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR : r.COMPRESSED_RGBA_ASTC_10x10_KHR;+ if (n === dd) return a === Mt ? r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR : r.COMPRESSED_RGBA_ASTC_12x10_KHR;+ if (n === fd) return a === Mt ? r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR : r.COMPRESSED_RGBA_ASTC_12x12_KHR;+ } else+ return null;+ if (n === Eo || n === pd || n === Il)+ if (r = e.get("EXT_texture_compression_bptc"), r !== null) {+ if (n === Eo) return a === Mt ? r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT : r.COMPRESSED_RGBA_BPTC_UNORM_EXT;+ if (n === pd) return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;+ if (n === Il) return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT;+ } else+ return null;+ if (n === Zm || n === Ad || n === gd || n === md)+ if (r = e.get("EXT_texture_compression_rgtc"), r !== null) {+ if (n === Eo) return r.COMPRESSED_RED_RGTC1_EXT;+ if (n === Ad) return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;+ if (n === gd) return r.COMPRESSED_RED_GREEN_RGTC2_EXT;+ if (n === md) return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT;+ } else+ return null;+ return n === Ro ? i.UNSIGNED_INT_24_8 : i[n] !== void 0 ? i[n] : null;+ }+ return { convert: t };+}+const II = `+void main() {++ gl_Position = vec4( position, 1.0 );++}`, MI = `+uniform sampler2DArray depthColor;+uniform float depthWidth;+uniform float depthHeight;++void main() {++ vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );++ if ( coord.x >= 1.0 ) {++ gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;++ } else {++ gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;++ }++}`;+class BI {+ /**+ * Constructs a new depth sensing module.+ */+ constructor() {+ this.texture = null, this.mesh = null, this.depthNear = 0, this.depthFar = 0;+ }+ /**+ * Inits the depth sensing module+ *+ * @param {WebGLRenderer} renderer - The renderer.+ * @param {XRWebGLDepthInformation} depthData - The XR depth data.+ * @param {XRRenderState} renderState - The XR render state.+ */+ init(e, t, n) {+ if (this.texture === null) {+ const s = new cn(), r = e.properties.get(s);+ r.__webglTexture = t.texture, (t.depthNear !== n.depthNear || t.depthFar !== n.depthFar) && (this.depthNear = t.depthNear, this.depthFar = t.depthFar), this.texture = s;+ }+ }+ /**+ * Returns a plane mesh that visualizes the depth texture.+ *+ * @param {ArrayCamera} cameraXR - The XR camera.+ * @return {?Mesh} The plane mesh.+ */+ getMesh(e) {+ if (this.texture !== null && this.mesh === null) {+ const t = e.cameras[0].viewport, n = new Os({+ vertexShader: II,+ fragmentShader: MI,+ uniforms: {+ depthColor: { value: this.texture },+ depthWidth: { value: t.z },+ depthHeight: { value: t.w }+ }+ });+ this.mesh = new Jt(new Zl(20, 20), n);+ }+ return this.mesh;+ }+ /**+ * Resets the module+ */+ reset() {+ this.texture = null, this.mesh = null;+ }+ /**+ * Returns a texture representing the depth of the user's environment.+ *+ * @return {?Texture} The depth texture.+ */+ getDepthTexture() {+ return this.texture;+ }+}+class TI extends zs {+ /**+ * Constructs a new WebGL renderer.+ *+ * @param {WebGLRenderer} renderer - The renderer.+ * @param {WebGL2RenderingContext} gl - The rendering context.+ */+ constructor(e, t) {+ super();+ const n = this;+ let s = null, r = 1, a = null, o = "local-floor", c = 1, l = null, h = null, u = null, d = null, f = null, m = null;+ const A = new BI(), g = t.getContextAttributes();+ let p = null, y = null;+ const b = [], E = [], M = new Ze();+ let w = null;+ const S = new vn();+ S.viewport = new wt();+ const T = new vn();+ T.viewport = new wt();+ const C = [S, T], v = new Py();+ let F = null, K = null;+ this.cameraAutoUpdate = !0, this.enabled = !1, this.isPresenting = !1, this.getController = function(se) {+ let me = b[se];+ return me === void 0 && (me = new Qh(), b[se] = me), me.getTargetRaySpace();+ }, this.getControllerGrip = function(se) {+ let me = b[se];+ return me === void 0 && (me = new Qh(), b[se] = me), me.getGripSpace();+ }, this.getHand = function(se) {+ let me = b[se];+ return me === void 0 && (me = new Qh(), b[se] = me), me.getHandSpace();+ };+ function q(se) {+ const me = E.indexOf(se.inputSource);+ if (me === -1)+ return;+ const be = b[me];+ be !== void 0 && (be.update(se.inputSource, se.frame, l || a), be.dispatchEvent({ type: se.type, data: se.inputSource }));+ }+ function $() {+ s.removeEventListener("select", q), s.removeEventListener("selectstart", q), s.removeEventListener("selectend", q), s.removeEventListener("squeeze", q), s.removeEventListener("squeezestart", q), s.removeEventListener("squeezeend", q), s.removeEventListener("end", $), s.removeEventListener("inputsourceschange", D);+ for (let se = 0; se < b.length; se++) {+ const me = E[se];+ me !== null && (E[se] = null, b[se].disconnect(me));+ }+ F = null, K = null, A.reset(), e.setRenderTarget(p), f = null, d = null, u = null, s = null, y = null, Me.stop(), n.isPresenting = !1, e.setPixelRatio(w), e.setSize(M.width, M.height, !1), n.dispatchEvent({ type: "sessionend" });+ }+ this.setFramebufferScaleFactor = function(se) {+ r = se, n.isPresenting === !0 && console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.");+ }, this.setReferenceSpaceType = function(se) {+ o = se, n.isPresenting === !0 && console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.");+ }, this.getReferenceSpace = function() {+ return l || a;+ }, this.setReferenceSpace = function(se) {+ l = se;+ }, this.getBaseLayer = function() {+ return d !== null ? d : f;+ }, this.getBinding = function() {+ return u;+ }, this.getFrame = function() {+ return m;+ }, this.getSession = function() {+ return s;+ }, this.setSession = async function(se) {+ if (s = se, s !== null) {+ if (p = e.getRenderTarget(), s.addEventListener("select", q), s.addEventListener("selectstart", q), s.addEventListener("selectend", q), s.addEventListener("squeeze", q), s.addEventListener("squeezestart", q), s.addEventListener("squeezeend", q), s.addEventListener("end", $), s.addEventListener("inputsourceschange", D), g.xrCompatible !== !0 && await t.makeXRCompatible(), w = e.getPixelRatio(), e.getSize(M), typeof XRWebGLBinding < "u" && "createProjectionLayer" in XRWebGLBinding.prototype) {+ let be = null, xe = null, Pe = null;+ g.depth && (Pe = g.stencil ? t.DEPTH24_STENCIL8 : t.DEPTH_COMPONENT24, be = g.stencil ? Fo : No, xe = g.stencil ? Ro : yr);+ const $e = {+ colorFormat: t.RGBA8,+ depthFormat: Pe,+ scaleFactor: r+ };+ u = new XRWebGLBinding(s, t), d = u.createProjectionLayer($e), s.updateRenderState({ layers: [d] }), e.setPixelRatio(1), e.setSize(d.textureWidth, d.textureHeight, !1), y = new wr(+ d.textureWidth,+ d.textureHeight,+ {+ format: on,+ type: rn,+ depthTexture: new m0(d.textureWidth, d.textureHeight, xe, void 0, void 0, void 0, void 0, void 0, void 0, be),+ stencilBuffer: g.stencil,+ colorSpace: e.outputColorSpace,+ samples: g.antialias ? 4 : 0,+ resolveDepthBuffer: d.ignoreDepthValues === !1,+ resolveStencilBuffer: d.ignoreDepthValues === !1+ }+ );+ } else {+ const be = {+ antialias: g.antialias,+ alpha: !0,+ depth: g.depth,+ stencil: g.stencil,+ framebufferScaleFactor: r+ };+ f = new XRWebGLLayer(s, t, be), s.updateRenderState({ baseLayer: f }), e.setPixelRatio(1), e.setSize(f.framebufferWidth, f.framebufferHeight, !1), y = new wr(+ f.framebufferWidth,+ f.framebufferHeight,+ {+ format: on,+ type: rn,+ colorSpace: e.outputColorSpace,+ stencilBuffer: g.stencil,+ resolveDepthBuffer: f.ignoreDepthValues === !1,+ resolveStencilBuffer: f.ignoreDepthValues === !1+ }+ );+ }+ y.isXRRenderTarget = !0, this.setFoveation(c), l = null, a = await s.requestReferenceSpace(o), Me.setContext(s), Me.start(), n.isPresenting = !0, n.dispatchEvent({ type: "sessionstart" });+ }+ }, this.getEnvironmentBlendMode = function() {+ if (s !== null)+ return s.environmentBlendMode;+ }, this.getDepthTexture = function() {+ return A.getDepthTexture();+ };+ function D(se) {+ for (let me = 0; me < se.removed.length; me++) {+ const be = se.removed[me], xe = E.indexOf(be);+ xe >= 0 && (E[xe] = null, b[xe].disconnect(be));+ }+ for (let me = 0; me < se.added.length; me++) {+ const be = se.added[me];+ let xe = E.indexOf(be);+ if (xe === -1) {+ for (let $e = 0; $e < b.length; $e++)+ if ($e >= E.length) {+ E.push(be), xe = $e;+ break;+ } else if (E[$e] === null) {+ E[$e] = be, xe = $e;+ break;+ }+ if (xe === -1) break;+ }+ const Pe = b[xe];+ Pe && Pe.connect(be);+ }+ }+ const O = new H(), Y = new H();+ function Q(se, me, be) {+ O.setFromMatrixPosition(me.matrixWorld), Y.setFromMatrixPosition(be.matrixWorld);+ const xe = O.distanceTo(Y), Pe = me.projectionMatrix.elements, $e = be.projectionMatrix.elements, Qe = Pe[14] / (Pe[10] - 1), vt = Pe[14] / (Pe[10] + 1), lt = (Pe[9] + 1) / Pe[5], Je = (Pe[9] - 1) / Pe[5], G = (Pe[8] - 1) / Pe[0], dn = ($e[8] + 1) / $e[0], dt = Qe * G, pt = Qe * dn, ze = xe / (-G + dn), Rt = ze * -G;+ if (me.matrixWorld.decompose(se.position, se.quaternion, se.scale), se.translateX(Rt), se.translateZ(ze), se.matrixWorld.compose(se.position, se.quaternion, se.scale), se.matrixWorldInverse.copy(se.matrixWorld).invert(), Pe[10] === -1)+ se.projectionMatrix.copy(me.projectionMatrix), se.projectionMatrixInverse.copy(me.projectionMatrixInverse);+ else {+ const Ge = Qe + ze, L = vt + ze, I = dt - Rt, Z = pt + (xe - Rt), le = lt * vt / L * Ge, pe = Je * vt / L * Ge;+ se.projectionMatrix.makePerspective(I, Z, le, pe, Ge, L), se.projectionMatrixInverse.copy(se.projectionMatrix).invert();+ }+ }+ function J(se, me) {+ me === null ? se.matrixWorld.copy(se.matrix) : se.matrixWorld.multiplyMatrices(me.matrixWorld, se.matrix), se.matrixWorldInverse.copy(se.matrixWorld).invert();+ }+ this.updateCamera = function(se) {+ if (s === null) return;+ let me = se.near, be = se.far;+ A.texture !== null && (A.depthNear > 0 && (me = A.depthNear), A.depthFar > 0 && (be = A.depthFar)), v.near = T.near = S.near = me, v.far = T.far = S.far = be, (F !== v.near || K !== v.far) && (s.updateRenderState({+ depthNear: v.near,+ depthFar: v.far+ }), F = v.near, K = v.far), S.layers.mask = se.layers.mask | 2, T.layers.mask = se.layers.mask | 4, v.layers.mask = S.layers.mask | T.layers.mask;+ const xe = se.parent, Pe = v.cameras;+ J(v, xe);+ for (let $e = 0; $e < Pe.length; $e++)+ J(Pe[$e], xe);+ Pe.length === 2 ? Q(v, S, T) : v.projectionMatrix.copy(S.projectionMatrix), ee(se, v, xe);+ };+ function ee(se, me, be) {+ be === null ? se.matrix.copy(me.matrixWorld) : (se.matrix.copy(be.matrixWorld), se.matrix.invert(), se.matrix.multiply(me.matrixWorld)), se.matrix.decompose(se.position, se.quaternion, se.scale), se.updateMatrixWorld(!0), se.projectionMatrix.copy(me.projectionMatrix), se.projectionMatrixInverse.copy(me.projectionMatrixInverse), se.isPerspectiveCamera && (se.fov = Sa * 2 * Math.atan(1 / se.projectionMatrix.elements[5]), se.zoom = 1);+ }+ this.getCamera = function() {+ return v;+ }, this.getFoveation = function() {+ if (!(d === null && f === null))+ return c;+ }, this.setFoveation = function(se) {+ c = se, d !== null && (d.fixedFoveation = se), f !== null && f.fixedFoveation !== void 0 && (f.fixedFoveation = se);+ }, this.hasDepthSensing = function() {+ return A.texture !== null;+ }, this.getDepthSensingMesh = function() {+ return A.getMesh(v);+ };+ let ae = null;+ function ye(se, me) {+ if (h = me.getViewerPose(l || a), m = me, h !== null) {+ const be = h.views;+ f !== null && (e.setRenderTargetFramebuffer(y, f.framebuffer), e.setRenderTarget(y));+ let xe = !1;+ be.length !== v.cameras.length && (v.cameras.length = 0, xe = !0);+ for (let Qe = 0; Qe < be.length; Qe++) {+ const vt = be[Qe];+ let lt = null;+ if (f !== null)+ lt = f.getViewport(vt);+ else {+ const G = u.getViewSubImage(d, vt);+ lt = G.viewport, Qe === 0 && (e.setRenderTargetTextures(+ y,+ G.colorTexture,+ G.depthStencilTexture+ ), e.setRenderTarget(y));+ }+ let Je = C[Qe];+ Je === void 0 && (Je = new vn(), Je.layers.enable(Qe), Je.viewport = new wt(), C[Qe] = Je), Je.matrix.fromArray(vt.transform.matrix), Je.matrix.decompose(Je.position, Je.quaternion, Je.scale), Je.projectionMatrix.fromArray(vt.projectionMatrix), Je.projectionMatrixInverse.copy(Je.projectionMatrix).invert(), Je.viewport.set(lt.x, lt.y, lt.width, lt.height), Qe === 0 && (v.matrix.copy(Je.matrix), v.matrix.decompose(v.position, v.quaternion, v.scale)), xe === !0 && v.cameras.push(Je);+ }+ const Pe = s.enabledFeatures;+ if (Pe && Pe.includes("depth-sensing") && s.depthUsage == "gpu-optimized" && u) {+ const Qe = u.getDepthInformation(be[0]);+ Qe && Qe.isValid && Qe.texture && A.init(e, Qe, s.renderState);+ }+ }+ for (let be = 0; be < b.length; be++) {+ const xe = E[be], Pe = b[be];+ xe !== null && Pe !== void 0 && Pe.update(xe, me, l || a);+ }+ ae && ae(se, me), me.detectedPlanes && n.dispatchEvent({ type: "planesdetected", data: me }), m = null;+ }+ const Me = new S0();+ Me.setAnimationLoop(ye), this.setAnimationLoop = function(se) {+ ae = se;+ }, this.dispose = function() {+ };+ }+}+const $s = /* @__PURE__ */ new Pi(), RI = /* @__PURE__ */ new et();+function NI(i, e) {+ function t(g, p) {+ g.matrixAutoUpdate === !0 && g.updateMatrix(), p.value.copy(g.matrix);+ }+ function n(g, p) {+ p.color.getRGB(g.fogColor.value, d0(i)), p.isFog ? (g.fogNear.value = p.near, g.fogFar.value = p.far) : p.isFogExp2 && (g.fogDensity.value = p.density);+ }+ function s(g, p, y, b, E) {+ p.isMeshBasicMaterial || p.isMeshLambertMaterial ? r(g, p) : p.isMeshToonMaterial ? (r(g, p), u(g, p)) : p.isMeshPhongMaterial ? (r(g, p), h(g, p)) : p.isMeshStandardMaterial ? (r(g, p), d(g, p), p.isMeshPhysicalMaterial && f(g, p, E)) : p.isMeshMatcapMaterial ? (r(g, p), m(g, p)) : p.isMeshDepthMaterial ? r(g, p) : p.isMeshDistanceMaterial ? (r(g, p), A(g, p)) : p.isMeshNormalMaterial ? r(g, p) : p.isLineBasicMaterial ? (a(g, p), p.isLineDashedMaterial && o(g, p)) : p.isPointsMaterial ? c(g, p, y, b) : p.isSpriteMaterial ? l(g, p) : p.isShadowMaterial ? (g.color.value.copy(p.color), g.opacity.value = p.opacity) : p.isShaderMaterial && (p.uniformsNeedUpdate = !1);+ }+ function r(g, p) {+ g.opacity.value = p.opacity, p.color && g.diffuse.value.copy(p.color), p.emissive && g.emissive.value.copy(p.emissive).multiplyScalar(p.emissiveIntensity), p.map && (g.map.value = p.map, t(p.map, g.mapTransform)), p.alphaMap && (g.alphaMap.value = p.alphaMap, t(p.alphaMap, g.alphaMapTransform)), p.bumpMap && (g.bumpMap.value = p.bumpMap, t(p.bumpMap, g.bumpMapTransform), g.bumpScale.value = p.bumpScale, p.side === Pn && (g.bumpScale.value *= -1)), p.normalMap && (g.normalMap.value = p.normalMap, t(p.normalMap, g.normalMapTransform), g.normalScale.value.copy(p.normalScale), p.side === Pn && g.normalScale.value.negate()), p.displacementMap && (g.displacementMap.value = p.displacementMap, t(p.displacementMap, g.displacementMapTransform), g.displacementScale.value = p.displacementScale, g.displacementBias.value = p.displacementBias), p.emissiveMap && (g.emissiveMap.value = p.emissiveMap, t(p.emissiveMap, g.emissiveMapTransform)), p.specularMap && (g.specularMap.value = p.specularMap, t(p.specularMap, g.specularMapTransform)), p.alphaTest > 0 && (g.alphaTest.value = p.alphaTest);+ const y = e.get(p), b = y.envMap, E = y.envMapRotation;+ b && (g.envMap.value = b, $s.copy(E), $s.x *= -1, $s.y *= -1, $s.z *= -1, b.isCubeTexture && b.isRenderTargetTexture === !1 && ($s.y *= -1, $s.z *= -1), g.envMapRotation.value.setFromMatrix4(RI.makeRotationFromEuler($s)), g.flipEnvMap.value = b.isCubeTexture && b.isRenderTargetTexture === !1 ? -1 : 1, g.reflectivity.value = p.reflectivity, g.ior.value = p.ior, g.refractionRatio.value = p.refractionRatio), p.lightMap && (g.lightMap.value = p.lightMap, g.lightMapIntensity.value = p.lightMapIntensity, t(p.lightMap, g.lightMapTransform)), p.aoMap && (g.aoMap.value = p.aoMap, g.aoMapIntensity.value = p.aoMapIntensity, t(p.aoMap, g.aoMapTransform));+ }+ function a(g, p) {+ g.diffuse.value.copy(p.color), g.opacity.value = p.opacity, p.map && (g.map.value = p.map, t(p.map, g.mapTransform));+ }+ function o(g, p) {+ g.dashSize.value = p.dashSize, g.totalSize.value = p.dashSize + p.gapSize, g.scale.value = p.scale;+ }+ function c(g, p, y, b) {+ g.diffuse.value.copy(p.color), g.opacity.value = p.opacity, g.size.value = p.size * y, g.scale.value = b * 0.5, p.map && (g.map.value = p.map, t(p.map, g.uvTransform)), p.alphaMap && (g.alphaMap.value = p.alphaMap, t(p.alphaMap, g.alphaMapTransform)), p.alphaTest > 0 && (g.alphaTest.value = p.alphaTest);+ }+ function l(g, p) {+ g.diffuse.value.copy(p.color), g.opacity.value = p.opacity, g.rotation.value = p.rotation, p.map && (g.map.value = p.map, t(p.map, g.mapTransform)), p.alphaMap && (g.alphaMap.value = p.alphaMap, t(p.alphaMap, g.alphaMapTransform)), p.alphaTest > 0 && (g.alphaTest.value = p.alphaTest);+ }+ function h(g, p) {+ g.specular.value.copy(p.specular), g.shininess.value = Math.max(p.shininess, 1e-4);+ }+ function u(g, p) {+ p.gradientMap && (g.gradientMap.value = p.gradientMap);+ }+ function d(g, p) {+ g.metalness.value = p.metalness, p.metalnessMap && (g.metalnessMap.value = p.metalnessMap, t(p.metalnessMap, g.metalnessMapTransform)), g.roughness.value = p.roughness, p.roughnessMap && (g.roughnessMap.value = p.roughnessMap, t(p.roughnessMap, g.roughnessMapTransform)), p.envMap && (g.envMapIntensity.value = p.envMapIntensity);+ }+ function f(g, p, y) {+ g.ior.value = p.ior, p.sheen > 0 && (g.sheenColor.value.copy(p.sheenColor).multiplyScalar(p.sheen), g.sheenRoughness.value = p.sheenRoughness, p.sheenColorMap && (g.sheenColorMap.value = p.sheenColorMap, t(p.sheenColorMap, g.sheenColorMapTransform)), p.sheenRoughnessMap && (g.sheenRoughnessMap.value = p.sheenRoughnessMap, t(p.sheenRoughnessMap, g.sheenRoughnessMapTransform))), p.clearcoat > 0 && (g.clearcoat.value = p.clearcoat, g.clearcoatRoughness.value = p.clearcoatRoughness, p.clearcoatMap && (g.clearcoatMap.value = p.clearcoatMap, t(p.clearcoatMap, g.clearcoatMapTransform)), p.clearcoatRoughnessMap && (g.clearcoatRoughnessMap.value = p.clearcoatRoughnessMap, t(p.clearcoatRoughnessMap, g.clearcoatRoughnessMapTransform)), p.clearcoatNormalMap && (g.clearcoatNormalMap.value = p.clearcoatNormalMap, t(p.clearcoatNormalMap, g.clearcoatNormalMapTransform), g.clearcoatNormalScale.value.copy(p.clearcoatNormalScale), p.side === Pn && g.clearcoatNormalScale.value.negate())), p.dispersion > 0 && (g.dispersion.value = p.dispersion), p.iridescence > 0 && (g.iridescence.value = p.iridescence, g.iridescenceIOR.value = p.iridescenceIOR, g.iridescenceThicknessMinimum.value = p.iridescenceThicknessRange[0], g.iridescenceThicknessMaximum.value = p.iridescenceThicknessRange[1], p.iridescenceMap && (g.iridescenceMap.value = p.iridescenceMap, t(p.iridescenceMap, g.iridescenceMapTransform)), p.iridescenceThicknessMap && (g.iridescenceThicknessMap.value = p.iridescenceThicknessMap, t(p.iridescenceThicknessMap, g.iridescenceThicknessMapTransform))), p.transmission > 0 && (g.transmission.value = p.transmission, g.transmissionSamplerMap.value = y.texture, g.transmissionSamplerSize.value.set(y.width, y.height), p.transmissionMap && (g.transmissionMap.value = p.transmissionMap, t(p.transmissionMap, g.transmissionMapTransform)), g.thickness.value = p.thickness, p.thicknessMap && (g.thicknessMap.value = p.thicknessMap, t(p.thicknessMap, g.thicknessMapTransform)), g.attenuationDistance.value = p.attenuationDistance, g.attenuationColor.value.copy(p.attenuationColor)), p.anisotropy > 0 && (g.anisotropyVector.value.set(p.anisotropy * Math.cos(p.anisotropyRotation), p.anisotropy * Math.sin(p.anisotropyRotation)), p.anisotropyMap && (g.anisotropyMap.value = p.anisotropyMap, t(p.anisotropyMap, g.anisotropyMapTransform))), g.specularIntensity.value = p.specularIntensity, g.specularColor.value.copy(p.specularColor), p.specularColorMap && (g.specularColorMap.value = p.specularColorMap, t(p.specularColorMap, g.specularColorMapTransform)), p.specularIntensityMap && (g.specularIntensityMap.value = p.specularIntensityMap, t(p.specularIntensityMap, g.specularIntensityMapTransform));+ }+ function m(g, p) {+ p.matcap && (g.matcap.value = p.matcap);+ }+ function A(g, p) {+ const y = e.get(p).light;+ g.referencePosition.value.setFromMatrixPosition(y.matrixWorld), g.nearDistance.value = y.shadow.camera.near, g.farDistance.value = y.shadow.camera.far;+ }+ return {+ refreshFogUniforms: n,+ refreshMaterialUniforms: s+ };+}+function FI(i, e, t, n) {+ let s = {}, r = {}, a = [];+ const o = i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);+ function c(y, b) {+ const E = b.program;+ n.uniformBlockBinding(y, E);+ }+ function l(y, b) {+ let E = s[y.id];+ E === void 0 && (m(y), E = h(y), s[y.id] = E, y.addEventListener("dispose", g));+ const M = b.program;+ n.updateUBOMapping(y, M);+ const w = e.render.frame;+ r[y.id] !== w && (d(y), r[y.id] = w);+ }+ function h(y) {+ const b = u();+ y.__bindingPointIndex = b;+ const E = i.createBuffer(), M = y.__size, w = y.usage;+ return i.bindBuffer(i.UNIFORM_BUFFER, E), i.bufferData(i.UNIFORM_BUFFER, M, w), i.bindBuffer(i.UNIFORM_BUFFER, null), i.bindBufferBase(i.UNIFORM_BUFFER, b, E), E;+ }+ function u() {+ for (let y = 0; y < o; y++)+ if (a.indexOf(y) === -1)+ return a.push(y), y;+ return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."), 0;+ }+ function d(y) {+ const b = s[y.id], E = y.uniforms, M = y.__cache;+ i.bindBuffer(i.UNIFORM_BUFFER, b);+ for (let w = 0, S = E.length; w < S; w++) {+ const T = Array.isArray(E[w]) ? E[w] : [E[w]];+ for (let C = 0, v = T.length; C < v; C++) {+ const F = T[C];+ if (f(F, w, C, M) === !0) {+ const K = F.__offset, q = Array.isArray(F.value) ? F.value : [F.value];+ let $ = 0;+ for (let D = 0; D < q.length; D++) {+ const O = q[D], Y = A(O);+ typeof O == "number" || typeof O == "boolean" ? (F.__data[0] = O, i.bufferSubData(i.UNIFORM_BUFFER, K + $, F.__data)) : O.isMatrix3 ? (F.__data[0] = O.elements[0], F.__data[1] = O.elements[1], F.__data[2] = O.elements[2], F.__data[3] = 0, F.__data[4] = O.elements[3], F.__data[5] = O.elements[4], F.__data[6] = O.elements[5], F.__data[7] = 0, F.__data[8] = O.elements[6], F.__data[9] = O.elements[7], F.__data[10] = O.elements[8], F.__data[11] = 0) : (O.toArray(F.__data, $), $ += Y.storage / Float32Array.BYTES_PER_ELEMENT);+ }+ i.bufferSubData(i.UNIFORM_BUFFER, K, F.__data);+ }+ }+ }+ i.bindBuffer(i.UNIFORM_BUFFER, null);+ }+ function f(y, b, E, M) {+ const w = y.value, S = b + "_" + E;+ if (M[S] === void 0)+ return typeof w == "number" || typeof w == "boolean" ? M[S] = w : M[S] = w.clone(), !0;+ {+ const T = M[S];+ if (typeof w == "number" || typeof w == "boolean") {+ if (T !== w)+ return M[S] = w, !0;+ } else if (T.equals(w) === !1)+ return T.copy(w), !0;+ }+ return !1;+ }+ function m(y) {+ const b = y.uniforms;+ let E = 0;+ const M = 16;+ for (let S = 0, T = b.length; S < T; S++) {+ const C = Array.isArray(b[S]) ? b[S] : [b[S]];+ for (let v = 0, F = C.length; v < F; v++) {+ const K = C[v], q = Array.isArray(K.value) ? K.value : [K.value];+ for (let $ = 0, D = q.length; $ < D; $++) {+ const O = q[$], Y = A(O), Q = E % M, J = Q % Y.boundary, ee = Q + J;+ E += J, ee !== 0 && M - ee < Y.storage && (E += M - ee), K.__data = new Float32Array(Y.storage / Float32Array.BYTES_PER_ELEMENT), K.__offset = E, E += Y.storage;+ }+ }+ }+ const w = E % M;+ return w > 0 && (E += M - w), y.__size = E, y.__cache = {}, this;+ }+ function A(y) {+ const b = {+ boundary: 0,+ // bytes+ storage: 0+ // bytes+ };+ return typeof y == "number" || typeof y == "boolean" ? (b.boundary = 4, b.storage = 4) : y.isVector2 ? (b.boundary = 8, b.storage = 8) : y.isVector3 || y.isColor ? (b.boundary = 16, b.storage = 12) : y.isVector4 ? (b.boundary = 16, b.storage = 16) : y.isMatrix3 ? (b.boundary = 48, b.storage = 48) : y.isMatrix4 ? (b.boundary = 64, b.storage = 64) : y.isTexture ? console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group.") : console.warn("THREE.WebGLRenderer: Unsupported uniform value type.", y), b;+ }+ function g(y) {+ const b = y.target;+ b.removeEventListener("dispose", g);+ const E = a.indexOf(b.__bindingPointIndex);+ a.splice(E, 1), i.deleteBuffer(s[b.id]), delete s[b.id], delete r[b.id];+ }+ function p() {+ for (const y in s)+ i.deleteBuffer(s[y]);+ a = [], s = {}, r = {};+ }+ return {+ bind: c,+ update: l,+ dispose: p+ };+}+class IA {+ /**+ * Constructs a new WebGL renderer.+ *+ * @param {WebGLRenderer~Options} [parameters] - The configuration parameter.+ */+ constructor(e = {}) {+ const {+ canvas: t = ME(),+ context: n = null,+ depth: s = !0,+ stencil: r = !1,+ alpha: a = !1,+ antialias: o = !1,+ premultipliedAlpha: c = !0,+ preserveDrawingBuffer: l = !1,+ powerPreference: h = "default",+ failIfMajorPerformanceCaveat: u = !1,+ reverseDepthBuffer: d = !1+ } = e;+ this.isWebGLRenderer = !0;+ let f;+ if (n !== null) {+ if (typeof WebGLRenderingContext < "u" && n instanceof WebGLRenderingContext)+ throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");+ f = n.getContextAttributes().alpha;+ } else+ f = a;+ const m = new Uint32Array(4), A = new Int32Array(4);+ let g = null, p = null;+ const y = [], b = [];+ this.domElement = t, this.debug = {+ /**+ * Enables error checking and reporting when shader programs are being compiled.+ * @type {boolean}+ */+ checkShaderErrors: !0,+ /**+ * Callback for custom error reporting.+ * @type {?Function}+ */+ onShaderError: null+ }, this.autoClear = !0, this.autoClearColor = !0, this.autoClearDepth = !0, this.autoClearStencil = !0, this.sortObjects = !0, this.clippingPlanes = [], this.localClippingEnabled = !1, this.toneMapping = Ls, this.toneMappingExposure = 1, this.transmissionResolutionScale = 1;+ const E = this;+ let M = !1;+ this._outputColorSpace = Kt;+ let w = 0, S = 0, T = null, C = -1, v = null;+ const F = new wt(), K = new wt();+ let q = null;+ const $ = new je(0);+ let D = 0, O = t.width, Y = t.height, Q = 1, J = null, ee = null;+ const ae = new wt(0, 0, O, Y), ye = new wt(0, 0, O, Y);+ let Me = !1;+ const se = new vf();+ let me = !1, be = !1;+ const xe = new et(), Pe = new et(), $e = new H(), Qe = new wt(), vt = { background: null, fog: null, environment: null, overrideMaterial: null, isScene: !0 };+ let lt = !1;+ function Je() {+ return T === null ? Q : 1;+ }+ let G = n;+ function dn(_, R) {+ return t.getContext(_, R);+ }+ try {+ const _ = {+ alpha: !0,+ depth: s,+ stencil: r,+ antialias: o,+ premultipliedAlpha: c,+ preserveDrawingBuffer: l,+ powerPreference: h,+ failIfMajorPerformanceCaveat: u+ };+ if ("setAttribute" in t && t.setAttribute("data-engine", "three.js r176"), t.addEventListener("webglcontextlost", de, !1), t.addEventListener("webglcontextrestored", Ie, !1), t.addEventListener("webglcontextcreationerror", Ce, !1), G === null) {+ const R = "webgl2";+ if (G = dn(R, _), G === null)+ throw dn(R) ? new Error("Error creating WebGL context with your selected attributes.") : new Error("Error creating WebGL context.");+ }+ } catch (_) {+ throw console.error("THREE.WebGLRenderer: " + _.message), _;+ }+ let dt, pt, ze, Rt, Ge, L, I, Z, le, pe, oe, Ue, ve, Ve, Ye, _e, Re, ke, Oe, Be, tt, We, nt, W;+ function ne() {+ dt = new VC(G), dt.init(), We = new SI(G, dt), pt = new kC(G, dt, e, We), ze = new vI(G, dt), pt.reverseDepthBuffer && d && ze.buffers.depth.setReversed(!0), Rt = new KC(G), Ge = new uI(), L = new CI(G, dt, ze, Ge, pt, We, Rt), I = new OC(E), Z = new zC(E), le = new $y(G), nt = new LC(G, le), pe = new WC(G, le, Rt, nt), oe = new XC(G, pe, le, Rt), Oe = new jC(G, pt, L), _e = new UC(Ge), Ue = new hI(E, I, Z, dt, pt, nt, _e), ve = new NI(E, Ge), Ve = new fI(), Ye = new xI(dt), ke = new DC(E, I, Z, ze, oe, f, c), Re = new yI(E, oe, pt), W = new FI(G, Rt, pt, ze), Be = new PC(G, dt, Rt), tt = new qC(G, dt, Rt), Rt.programs = Ue.programs, E.capabilities = pt, E.extensions = dt, E.properties = Ge, E.renderLists = Ve, E.shadowMap = Re, E.state = ze, E.info = Rt;+ }+ ne();+ const re = new TI(E, G);+ this.xr = re, this.getContext = function() {+ return G;+ }, this.getContextAttributes = function() {+ return G.getContextAttributes();+ }, this.forceContextLoss = function() {+ const _ = dt.get("WEBGL_lose_context");+ _ && _.loseContext();+ }, this.forceContextRestore = function() {+ const _ = dt.get("WEBGL_lose_context");+ _ && _.restoreContext();+ }, this.getPixelRatio = function() {+ return Q;+ }, this.setPixelRatio = function(_) {+ _ !== void 0 && (Q = _, this.setSize(O, Y, !1));+ }, this.getSize = function(_) {+ return _.set(O, Y);+ }, this.setSize = function(_, R, N = !0) {+ if (re.isPresenting) {+ console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");+ return;+ }+ O = _, Y = R, t.width = Math.floor(_ * Q), t.height = Math.floor(R * Q), N === !0 && (t.style.width = _ + "px", t.style.height = R + "px"), this.setViewport(0, 0, _, R);+ }, this.getDrawingBufferSize = function(_) {+ return _.set(O * Q, Y * Q).floor();+ }, this.setDrawingBufferSize = function(_, R, N) {+ O = _, Y = R, Q = N, t.width = Math.floor(_ * N), t.height = Math.floor(R * N), this.setViewport(0, 0, _, R);+ }, this.getCurrentViewport = function(_) {+ return _.copy(F);+ }, this.getViewport = function(_) {+ return _.copy(ae);+ }, this.setViewport = function(_, R, N, U) {+ _.isVector4 ? ae.set(_.x, _.y, _.z, _.w) : ae.set(_, R, N, U), ze.viewport(F.copy(ae).multiplyScalar(Q).round());+ }, this.getScissor = function(_) {+ return _.copy(ye);+ }, this.setScissor = function(_, R, N, U) {+ _.isVector4 ? ye.set(_.x, _.y, _.z, _.w) : ye.set(_, R, N, U), ze.scissor(K.copy(ye).multiplyScalar(Q).round());+ }, this.getScissorTest = function() {+ return Me;+ }, this.setScissorTest = function(_) {+ ze.setScissorTest(Me = _);+ }, this.setOpaqueSort = function(_) {+ J = _;+ }, this.setTransparentSort = function(_) {+ ee = _;+ }, this.getClearColor = function(_) {+ return _.copy(ke.getClearColor());+ }, this.setClearColor = function() {+ ke.setClearColor(...arguments);+ }, this.getClearAlpha = function() {+ return ke.getClearAlpha();+ }, this.setClearAlpha = function() {+ ke.setClearAlpha(...arguments);+ }, this.clear = function(_ = !0, R = !0, N = !0) {+ let U = 0;+ if (_) {+ let P = !1;+ if (T !== null) {+ const z = T.texture.format;+ P = z === bf || z === mf || z === gf;+ }+ if (P) {+ const z = T.texture.type, j = z === rn || z === yr || z === To || z === Ro || z === pf || z === Af, X = ke.getClearColor(), ie = ke.getClearAlpha(), he = X.r, ce = X.g, fe = X.b;+ j ? (m[0] = he, m[1] = ce, m[2] = fe, m[3] = ie, G.clearBufferuiv(G.COLOR, 0, m)) : (A[0] = he, A[1] = ce, A[2] = fe, A[3] = ie, G.clearBufferiv(G.COLOR, 0, A));+ } else+ U |= G.COLOR_BUFFER_BIT;+ }+ R && (U |= G.DEPTH_BUFFER_BIT), N && (U |= G.STENCIL_BUFFER_BIT, this.state.buffers.stencil.setMask(4294967295)), G.clear(U);+ }, this.clearColor = function() {+ this.clear(!0, !1, !1);+ }, this.clearDepth = function() {+ this.clear(!1, !0, !1);+ }, this.clearStencil = function() {+ this.clear(!1, !1, !0);+ }, this.dispose = function() {+ t.removeEventListener("webglcontextlost", de, !1), t.removeEventListener("webglcontextrestored", Ie, !1), t.removeEventListener("webglcontextcreationerror", Ce, !1), ke.dispose(), Ve.dispose(), Ye.dispose(), Ge.dispose(), I.dispose(), Z.dispose(), oe.dispose(), nt.dispose(), W.dispose(), Ue.dispose(), re.dispose(), re.removeEventListener("sessionstart", lc), re.removeEventListener("sessionend", hc), Qi.stop();+ };+ function de(_) {+ _.preventDefault(), console.log("THREE.WebGLRenderer: Context Lost."), M = !0;+ }+ function Ie() {+ console.log("THREE.WebGLRenderer: Context Restored."), M = !1;+ const _ = Rt.autoReset, R = Re.enabled, N = Re.autoUpdate, U = Re.needsUpdate, P = Re.type;+ ne(), Rt.autoReset = _, Re.enabled = R, Re.autoUpdate = N, Re.needsUpdate = U, Re.type = P;+ }+ function Ce(_) {+ console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ", _.statusMessage);+ }+ function it(_) {+ const R = _.target;+ R.removeEventListener("dispose", it), Ut(R);+ }+ function Ut(_) {+ fn(_), Ge.remove(_);+ }+ function fn(_) {+ const R = Ge.get(_).programs;+ R !== void 0 && (R.forEach(function(N) {+ Ue.releaseProgram(N);+ }), _.isShaderMaterial && Ue.releaseShaderCache(_));+ }+ this.renderBufferDirect = function(_, R, N, U, P, z) {+ R === null && (R = vt);+ const j = P.isMesh && P.matrixWorld.determinant() < 0, X = bh(_, R, N, U, P);+ ze.setMaterial(U, j);+ let ie = N.index, he = 1;+ if (U.wireframe === !0) {+ if (ie = pe.getWireframeAttribute(N), ie === void 0) return;+ he = 2;+ }+ const ce = N.drawRange, fe = N.attributes.position;+ let Ae = ce.start * he, Ee = (ce.start + ce.count) * he;+ z !== null && (Ae = Math.max(Ae, z.start * he), Ee = Math.min(Ee, (z.start + z.count) * he)), ie !== null ? (Ae = Math.max(Ae, 0), Ee = Math.min(Ee, ie.count)) : fe != null && (Ae = Math.max(Ae, 0), Ee = Math.min(Ee, fe.count));+ const De = Ee - Ae;+ if (De < 0 || De === 1 / 0) return;+ nt.setup(P, U, X, N, ie);+ let qe, He = Be;+ if (ie !== null && (qe = le.get(ie), He = tt, He.setIndex(qe)), P.isMesh)+ U.wireframe === !0 ? (ze.setLineWidth(U.wireframeLinewidth * Je()), He.setMode(G.LINES)) : He.setMode(G.TRIANGLES);+ else if (P.isLine) {+ let Ne = U.linewidth;+ Ne === void 0 && (Ne = 1), ze.setLineWidth(Ne * Je()), P.isLineSegments ? He.setMode(G.LINES) : P.isLineLoop ? He.setMode(G.LINE_LOOP) : He.setMode(G.LINE_STRIP);+ } else P.isPoints ? He.setMode(G.POINTS) : P.isSprite && He.setMode(G.TRIANGLES);+ if (P.isBatchedMesh)+ if (P._multiDrawInstances !== null)+ pl("THREE.WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."), He.renderMultiDrawInstances(P._multiDrawStarts, P._multiDrawCounts, P._multiDrawCount, P._multiDrawInstances);+ else if (dt.get("WEBGL_multi_draw"))+ He.renderMultiDraw(P._multiDrawStarts, P._multiDrawCounts, P._multiDrawCount);+ else {+ const Ne = P._multiDrawStarts, st = P._multiDrawCounts, Le = P._multiDrawCount, yt = ie ? le.get(ie).bytesPerElement : 1, en = Ge.get(U).currentProgram.getUniforms();+ for (let xt = 0; xt < Le; xt++)+ en.setValue(G, "_gl_DrawID", xt), He.render(Ne[xt] / yt, st[xt]);+ }+ else if (P.isInstancedMesh)+ He.renderInstances(Ae, De, P.count);+ else if (N.isInstancedBufferGeometry) {+ const Ne = N._maxInstanceCount !== void 0 ? N._maxInstanceCount : 1 / 0, st = Math.min(N.instanceCount, Ne);+ He.renderInstances(Ae, De, st);+ } else+ He.render(Ae, De);+ };+ function Et(_, R, N) {+ _.transparent === !0 && _.side === Ni && _.forceSinglePass === !1 ? (_.side = Pn, _.needsUpdate = !0, Dr(_, R, N), _.side = us, _.needsUpdate = !0, Dr(_, R, N), _.side = Ni) : Dr(_, R, N);+ }+ this.compile = function(_, R, N = null) {+ N === null && (N = _), p = Ye.get(N), p.init(R), b.push(p), N.traverseVisible(function(P) {+ P.isLight && P.layers.test(R.layers) && (p.pushLight(P), P.castShadow && p.pushShadow(P));+ }), _ !== N && _.traverseVisible(function(P) {+ P.isLight && P.layers.test(R.layers) && (p.pushLight(P), P.castShadow && p.pushShadow(P));+ }), p.setupLights();+ const U = /* @__PURE__ */ new Set();+ return _.traverse(function(P) {+ if (!(P.isMesh || P.isPoints || P.isLine || P.isSprite))+ return;+ const z = P.material;+ if (z)+ if (Array.isArray(z))+ for (let j = 0; j < z.length; j++) {+ const X = z[j];+ Et(X, N, P), U.add(X);+ }+ else+ Et(z, N, P), U.add(z);+ }), p = b.pop(), U;+ }, this.compileAsync = function(_, R, N = null) {+ const U = this.compile(_, R, N);+ return new Promise((P) => {+ function z() {+ if (U.forEach(function(j) {+ Ge.get(j).currentProgram.isReady() && U.delete(j);+ }), U.size === 0) {+ P(_);+ return;+ }+ setTimeout(z, 10);+ }+ dt.get("KHR_parallel_shader_compile") !== null ? z() : setTimeout(z, 10);+ });+ };+ let Vn = null;+ function oi(_) {+ Vn && Vn(_);+ }+ function lc() {+ Qi.stop();+ }+ function hc() {+ Qi.start();+ }+ const Qi = new S0();+ Qi.setAnimationLoop(oi), typeof self < "u" && Qi.setContext(self), this.setAnimationLoop = function(_) {+ Vn = _, re.setAnimationLoop(_), _ === null ? Qi.stop() : Qi.start();+ }, re.addEventListener("sessionstart", lc), re.addEventListener("sessionend", hc), this.render = function(_, R) {+ if (R !== void 0 && R.isCamera !== !0) {+ console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");+ return;+ }+ if (M === !0) return;+ if (_.matrixWorldAutoUpdate === !0 && _.updateMatrixWorld(), R.parent === null && R.matrixWorldAutoUpdate === !0 && R.updateMatrixWorld(), re.enabled === !0 && re.isPresenting === !0 && (re.cameraAutoUpdate === !0 && re.updateCamera(R), R = re.getCamera()), _.isScene === !0 && _.onBeforeRender(E, _, R, T), p = Ye.get(_, b.length), p.init(R), b.push(p), Pe.multiplyMatrices(R.projectionMatrix, R.matrixWorldInverse), se.setFromProjectionMatrix(Pe), be = this.localClippingEnabled, me = _e.init(this.clippingPlanes, be), g = Ve.get(_, y.length), g.init(), y.push(g), re.enabled === !0 && re.isPresenting === !0) {+ const z = E.xr.getDepthSensingMesh();+ z !== null && Wa(z, R, -1 / 0, E.sortObjects);+ }+ Wa(_, R, 0, E.sortObjects), g.finish(), E.sortObjects === !0 && g.sort(J, ee), lt = re.enabled === !1 || re.isPresenting === !1 || re.hasDepthSensing() === !1, lt && ke.addToRenderList(g, _), this.info.render.frame++, me === !0 && _e.beginShadows();+ const N = p.state.shadowsArray;+ Re.render(N, _, R), me === !0 && _e.endShadows(), this.info.autoReset === !0 && this.info.reset();+ const U = g.opaque, P = g.transmissive;+ if (p.setupLights(), R.isArrayCamera) {+ const z = R.cameras;+ if (P.length > 0)+ for (let j = 0, X = z.length; j < X; j++) {+ const ie = z[j];+ uc(U, P, _, ie);+ }+ lt && ke.render(_);+ for (let j = 0, X = z.length; j < X; j++) {+ const ie = z[j];+ qa(g, _, ie, ie.viewport);+ }+ } else+ P.length > 0 && uc(U, P, _, R), lt && ke.render(_), qa(g, _, R);+ T !== null && S === 0 && (L.updateMultisampleRenderTarget(T), L.updateRenderTargetMipmap(T)), _.isScene === !0 && _.onAfterRender(E, _, R), nt.resetDefaultState(), C = -1, v = null, b.pop(), b.length > 0 ? (p = b[b.length - 1], me === !0 && _e.setGlobalState(E.clippingPlanes, p.state.camera)) : p = null, y.pop(), y.length > 0 ? g = y[y.length - 1] : g = null;+ };+ function Wa(_, R, N, U) {+ if (_.visible === !1) return;+ if (_.layers.test(R.layers)) {+ if (_.isGroup)+ N = _.renderOrder;+ else if (_.isLOD)+ _.autoUpdate === !0 && _.update(R);+ else if (_.isLight)+ p.pushLight(_), _.castShadow && p.pushShadow(_);+ else if (_.isSprite) {+ if (!_.frustumCulled || se.intersectsSprite(_)) {+ U && Qe.setFromMatrixPosition(_.matrixWorld).applyMatrix4(Pe);+ const j = oe.update(_), X = _.material;+ X.visible && g.push(_, j, X, N, Qe.z, null);+ }+ } else if ((_.isMesh || _.isLine || _.isPoints) && (!_.frustumCulled || se.intersectsObject(_))) {+ const j = oe.update(_), X = _.material;+ if (U && (_.boundingSphere !== void 0 ? (_.boundingSphere === null && _.computeBoundingSphere(), Qe.copy(_.boundingSphere.center)) : (j.boundingSphere === null && j.computeBoundingSphere(), Qe.copy(j.boundingSphere.center)), Qe.applyMatrix4(_.matrixWorld).applyMatrix4(Pe)), Array.isArray(X)) {+ const ie = j.groups;+ for (let he = 0, ce = ie.length; he < ce; he++) {+ const fe = ie[he], Ae = X[fe.materialIndex];+ Ae && Ae.visible && g.push(_, j, Ae, N, Qe.z, fe);+ }+ } else X.visible && g.push(_, j, X, N, Qe.z, null);+ }+ }+ const z = _.children;+ for (let j = 0, X = z.length; j < X; j++)+ Wa(z[j], R, N, U);+ }+ function qa(_, R, N, U) {+ const P = _.opaque, z = _.transmissive, j = _.transparent;+ p.setupLightsView(N), me === !0 && _e.setGlobalState(E.clippingPlanes, N), U && ze.viewport(F.copy(U)), P.length > 0 && Fr(P, R, N), z.length > 0 && Fr(z, R, N), j.length > 0 && Fr(j, R, N), ze.buffers.depth.setTest(!0), ze.buffers.depth.setMask(!0), ze.buffers.color.setMask(!0), ze.setPolygonOffset(!1);+ }+ function uc(_, R, N, U) {+ if ((N.isScene === !0 ? N.overrideMaterial : null) !== null)+ return;+ p.state.transmissionRenderTarget[U.id] === void 0 && (p.state.transmissionRenderTarget[U.id] = new wr(1, 1, {+ generateMipmaps: !0,+ type: dt.has("EXT_color_buffer_half_float") || dt.has("EXT_color_buffer_float") ? Nn : rn,+ minFilter: si,+ samples: 4,+ stencilBuffer: r,+ resolveDepthBuffer: !1,+ resolveStencilBuffer: !1,+ colorSpace: mt.workingColorSpace+ }));+ const z = p.state.transmissionRenderTarget[U.id], j = U.viewport || F;+ z.setSize(j.z * E.transmissionResolutionScale, j.w * E.transmissionResolutionScale);+ const X = E.getRenderTarget();+ E.setRenderTarget(z), E.getClearColor($), D = E.getClearAlpha(), D < 1 && E.setClearColor(16777215, 0.5), E.clear(), lt && ke.render(N);+ const ie = E.toneMapping;+ E.toneMapping = Ls;+ const he = U.viewport;+ if (U.viewport !== void 0 && (U.viewport = void 0), p.setupLightsView(U), me === !0 && _e.setGlobalState(E.clippingPlanes, U), Fr(_, N, U), L.updateMultisampleRenderTarget(z), L.updateRenderTargetMipmap(z), dt.has("WEBGL_multisampled_render_to_texture") === !1) {+ let ce = !1;+ for (let fe = 0, Ae = R.length; fe < Ae; fe++) {+ const Ee = R[fe], De = Ee.object, qe = Ee.geometry, He = Ee.material, Ne = Ee.group;+ if (He.side === Ni && De.layers.test(U.layers)) {+ const st = He.side;+ He.side = Pn, He.needsUpdate = !0, dc(De, N, U, qe, He, Ne), He.side = st, He.needsUpdate = !0, ce = !0;+ }+ }+ ce === !0 && (L.updateMultisampleRenderTarget(z), L.updateRenderTargetMipmap(z));+ }+ E.setRenderTarget(X), E.setClearColor($, D), he !== void 0 && (U.viewport = he), E.toneMapping = ie;+ }+ function Fr(_, R, N) {+ const U = R.isScene === !0 ? R.overrideMaterial : null;+ for (let P = 0, z = _.length; P < z; P++) {+ const j = _[P], X = j.object, ie = j.geometry, he = j.group;+ let ce = j.material;+ ce.allowOverride === !0 && U !== null && (ce = U), X.layers.test(N.layers) && dc(X, R, N, ie, ce, he);+ }+ }+ function dc(_, R, N, U, P, z) {+ _.onBeforeRender(E, R, N, U, P, z), _.modelViewMatrix.multiplyMatrices(N.matrixWorldInverse, _.matrixWorld), _.normalMatrix.getNormalMatrix(_.modelViewMatrix), P.onBeforeRender(E, R, N, U, _, z), P.transparent === !0 && P.side === Ni && P.forceSinglePass === !1 ? (P.side = Pn, P.needsUpdate = !0, E.renderBufferDirect(N, R, U, P, _, z), P.side = us, P.needsUpdate = !0, E.renderBufferDirect(N, R, U, P, _, z), P.side = Ni) : E.renderBufferDirect(N, R, U, P, _, z), _.onAfterRender(E, R, N, U, P, z);+ }+ function Dr(_, R, N) {+ R.isScene !== !0 && (R = vt);+ const U = Ge.get(_), P = p.state.lights, z = p.state.shadowsArray, j = P.state.version, X = Ue.getParameters(_, P.state, z, R, N), ie = Ue.getProgramCacheKey(X);+ let he = U.programs;+ U.environment = _.isMeshStandardMaterial ? R.environment : null, U.fog = R.fog, U.envMap = (_.isMeshStandardMaterial ? Z : I).get(_.envMap || U.environment), U.envMapRotation = U.environment !== null && _.envMap === null ? R.environmentRotation : _.envMapRotation, he === void 0 && (_.addEventListener("dispose", it), he = /* @__PURE__ */ new Map(), U.programs = he);+ let ce = he.get(ie);+ if (ce !== void 0) {+ if (U.currentProgram === ce && U.lightsStateVersion === j)+ return ja(_, X), ce;+ } else+ X.uniforms = Ue.getUniforms(_), _.onBeforeCompile(X, E), ce = Ue.acquireProgram(X, ie), he.set(ie, ce), U.uniforms = X.uniforms;+ const fe = U.uniforms;+ return (!_.isShaderMaterial && !_.isRawShaderMaterial || _.clipping === !0) && (fe.clippingPlanes = _e.uniform), ja(_, X), U.needsLights = gs(_), U.lightsStateVersion = j, U.needsLights && (fe.ambientLightColor.value = P.state.ambient, fe.lightProbe.value = P.state.probe, fe.directionalLights.value = P.state.directional, fe.directionalLightShadows.value = P.state.directionalShadow, fe.spotLights.value = P.state.spot, fe.spotLightShadows.value = P.state.spotShadow, fe.rectAreaLights.value = P.state.rectArea, fe.ltc_1.value = P.state.rectAreaLTC1, fe.ltc_2.value = P.state.rectAreaLTC2, fe.pointLights.value = P.state.point, fe.pointLightShadows.value = P.state.pointShadow, fe.hemisphereLights.value = P.state.hemi, fe.directionalShadowMap.value = P.state.directionalShadowMap, fe.directionalShadowMatrix.value = P.state.directionalShadowMatrix, fe.spotShadowMap.value = P.state.spotShadowMap, fe.spotLightMatrix.value = P.state.spotLightMatrix, fe.spotLightMap.value = P.state.spotLightMap, fe.pointShadowMap.value = P.state.pointShadowMap, fe.pointShadowMatrix.value = P.state.pointShadowMatrix), U.currentProgram = ce, U.uniformsList = null, ce;+ }+ function Ka(_) {+ if (_.uniformsList === null) {+ const R = _.currentProgram.getUniforms();+ _.uniformsList = Al.seqWithValue(R.seq, _.uniforms);+ }+ return _.uniformsList;+ }+ function ja(_, R) {+ const N = Ge.get(_);+ N.outputColorSpace = R.outputColorSpace, N.batching = R.batching, N.batchingColor = R.batchingColor, N.instancing = R.instancing, N.instancingColor = R.instancingColor, N.instancingMorph = R.instancingMorph, N.skinning = R.skinning, N.morphTargets = R.morphTargets, N.morphNormals = R.morphNormals, N.morphColors = R.morphColors, N.morphTargetsCount = R.morphTargetsCount, N.numClippingPlanes = R.numClippingPlanes, N.numIntersection = R.numClipIntersection, N.vertexAlphas = R.vertexAlphas, N.vertexTangents = R.vertexTangents, N.toneMapping = R.toneMapping;+ }+ function bh(_, R, N, U, P) {+ R.isScene !== !0 && (R = vt), L.resetTextureUnits();+ const z = R.fog, j = U.isMeshStandardMaterial ? R.environment : null, X = T === null ? E.outputColorSpace : T.isXRRenderTarget === !0 ? T.texture.colorSpace : ln, ie = (U.isMeshStandardMaterial ? Z : I).get(U.envMap || j), he = U.vertexColors === !0 && !!N.attributes.color && N.attributes.color.itemSize === 4, ce = !!N.attributes.tangent && (!!U.normalMap || U.anisotropy > 0), fe = !!N.morphAttributes.position, Ae = !!N.morphAttributes.normal, Ee = !!N.morphAttributes.color;+ let De = Ls;+ U.toneMapped && (T === null || T.isXRRenderTarget === !0) && (De = E.toneMapping);+ const qe = N.morphAttributes.position || N.morphAttributes.normal || N.morphAttributes.color, He = qe !== void 0 ? qe.length : 0, Ne = Ge.get(U), st = p.state.lights;+ if (me === !0 && (be === !0 || _ !== v)) {+ const Nt = _ === v && U.id === C;+ _e.setState(U, _, Nt);+ }+ let Le = !1;+ U.version === Ne.__version ? (Ne.needsLights && Ne.lightsStateVersion !== st.state.version || Ne.outputColorSpace !== X || P.isBatchedMesh && Ne.batching === !1 || !P.isBatchedMesh && Ne.batching === !0 || P.isBatchedMesh && Ne.batchingColor === !0 && P.colorTexture === null || P.isBatchedMesh && Ne.batchingColor === !1 && P.colorTexture !== null || P.isInstancedMesh && Ne.instancing === !1 || !P.isInstancedMesh && Ne.instancing === !0 || P.isSkinnedMesh && Ne.skinning === !1 || !P.isSkinnedMesh && Ne.skinning === !0 || P.isInstancedMesh && Ne.instancingColor === !0 && P.instanceColor === null || P.isInstancedMesh && Ne.instancingColor === !1 && P.instanceColor !== null || P.isInstancedMesh && Ne.instancingMorph === !0 && P.morphTexture === null || P.isInstancedMesh && Ne.instancingMorph === !1 && P.morphTexture !== null || Ne.envMap !== ie || U.fog === !0 && Ne.fog !== z || Ne.numClippingPlanes !== void 0 && (Ne.numClippingPlanes !== _e.numPlanes || Ne.numIntersection !== _e.numIntersection) || Ne.vertexAlphas !== he || Ne.vertexTangents !== ce || Ne.morphTargets !== fe || Ne.morphNormals !== Ae || Ne.morphColors !== Ee || Ne.toneMapping !== De || Ne.morphTargetsCount !== He) && (Le = !0) : (Le = !0, Ne.__version = U.version);+ let yt = Ne.currentProgram;+ Le === !0 && (yt = Dr(U, R, P));+ let en = !1, xt = !1, At = !1;+ const Ke = yt.getUniforms(), zt = Ne.uniforms;+ if (ze.useProgram(yt.program) && (en = !0, xt = !0, At = !0), U.id !== C && (C = U.id, xt = !0), en || v !== _) {+ ze.buffers.depth.getReversed() ? (xe.copy(_.projectionMatrix), TE(xe), RE(xe), Ke.setValue(G, "projectionMatrix", xe)) : Ke.setValue(G, "projectionMatrix", _.projectionMatrix), Ke.setValue(G, "viewMatrix", _.matrixWorldInverse);+ const tn = Ke.map.cameraPosition;+ tn !== void 0 && tn.setValue(G, $e.setFromMatrixPosition(_.matrixWorld)), pt.logarithmicDepthBuffer && Ke.setValue(+ G,+ "logDepthBufFC",+ 2 / (Math.log(_.far + 1) / Math.LN2)+ ), (U.isMeshPhongMaterial || U.isMeshToonMaterial || U.isMeshLambertMaterial || U.isMeshBasicMaterial || U.isMeshStandardMaterial || U.isShaderMaterial) && Ke.setValue(G, "isOrthographic", _.isOrthographicCamera === !0), v !== _ && (v = _, xt = !0, At = !0);+ }+ if (P.isSkinnedMesh) {+ Ke.setOptional(G, P, "bindMatrix"), Ke.setOptional(G, P, "bindMatrixInverse");+ const Nt = P.skeleton;+ Nt && (Nt.boneTexture === null && Nt.computeBoneTexture(), Ke.setValue(G, "boneTexture", Nt.boneTexture, L));+ }+ P.isBatchedMesh && (Ke.setOptional(G, P, "batchingTexture"), Ke.setValue(G, "batchingTexture", P._matricesTexture, L), Ke.setOptional(G, P, "batchingIdTexture"), Ke.setValue(G, "batchingIdTexture", P._indirectTexture, L), Ke.setOptional(G, P, "batchingColorTexture"), P._colorsTexture !== null && Ke.setValue(G, "batchingColorTexture", P._colorsTexture, L));+ const pn = N.morphAttributes;+ if ((pn.position !== void 0 || pn.normal !== void 0 || pn.color !== void 0) && Oe.update(P, N, yt), (xt || Ne.receiveShadow !== P.receiveShadow) && (Ne.receiveShadow = P.receiveShadow, Ke.setValue(G, "receiveShadow", P.receiveShadow)), U.isMeshGouraudMaterial && U.envMap !== null && (zt.envMap.value = ie, zt.flipEnvMap.value = ie.isCubeTexture && ie.isRenderTargetTexture === !1 ? -1 : 1), U.isMeshStandardMaterial && U.envMap === null && R.environment !== null && (zt.envMapIntensity.value = R.environmentIntensity), xt && (Ke.setValue(G, "toneMappingExposure", E.toneMappingExposure), Ne.needsLights && Gi(zt, At), z && U.fog === !0 && ve.refreshFogUniforms(zt, z), ve.refreshMaterialUniforms(zt, U, Q, Y, p.state.transmissionRenderTarget[_.id]), Al.upload(G, Ka(Ne), zt, L)), U.isShaderMaterial && U.uniformsNeedUpdate === !0 && (Al.upload(G, Ka(Ne), zt, L), U.uniformsNeedUpdate = !1), U.isSpriteMaterial && Ke.setValue(G, "center", P.center), Ke.setValue(G, "modelViewMatrix", P.modelViewMatrix), Ke.setValue(G, "normalMatrix", P.normalMatrix), Ke.setValue(G, "modelMatrix", P.matrixWorld), U.isShaderMaterial || U.isRawShaderMaterial) {+ const Nt = U.uniformsGroups;+ for (let tn = 0, xh = Nt.length; tn < xh; tn++) {+ const Ks = Nt[tn];+ W.update(Ks, yt), W.bind(Ks, yt);+ }+ }+ return yt;+ }+ function Gi(_, R) {+ _.ambientLightColor.needsUpdate = R, _.lightProbe.needsUpdate = R, _.directionalLights.needsUpdate = R, _.directionalLightShadows.needsUpdate = R, _.pointLights.needsUpdate = R, _.pointLightShadows.needsUpdate = R, _.spotLights.needsUpdate = R, _.spotLightShadows.needsUpdate = R, _.rectAreaLights.needsUpdate = R, _.hemisphereLights.needsUpdate = R;+ }+ function gs(_) {+ return _.isMeshLambertMaterial || _.isMeshToonMaterial || _.isMeshPhongMaterial || _.isMeshStandardMaterial || _.isShadowMaterial || _.isShaderMaterial && _.lights === !0;+ }+ this.getActiveCubeFace = function() {+ return w;+ }, this.getActiveMipmapLevel = function() {+ return S;+ }, this.getRenderTarget = function() {+ return T;+ }, this.setRenderTargetTextures = function(_, R, N) {+ const U = Ge.get(_);+ U.__autoAllocateDepthBuffer = _.resolveDepthBuffer === !1, U.__autoAllocateDepthBuffer === !1 && (U.__useRenderToTexture = !1), Ge.get(_.texture).__webglTexture = R, Ge.get(_.depthTexture).__webglTexture = U.__autoAllocateDepthBuffer ? void 0 : N, U.__hasExternalTextures = !0;+ }, this.setRenderTargetFramebuffer = function(_, R) {+ const N = Ge.get(_);+ N.__webglFramebuffer = R, N.__useDefaultFramebuffer = R === void 0;+ };+ const x = G.createFramebuffer();+ this.setRenderTarget = function(_, R = 0, N = 0) {+ T = _, w = R, S = N;+ let U = !0, P = null, z = !1, j = !1;+ if (_) {+ const ie = Ge.get(_);+ if (ie.__useDefaultFramebuffer !== void 0)+ ze.bindFramebuffer(G.FRAMEBUFFER, null), U = !1;+ else if (ie.__webglFramebuffer === void 0)+ L.setupRenderTarget(_);+ else if (ie.__hasExternalTextures)+ L.rebindTextures(_, Ge.get(_.texture).__webglTexture, Ge.get(_.depthTexture).__webglTexture);+ else if (_.depthBuffer) {+ const fe = _.depthTexture;+ if (ie.__boundDepthTexture !== fe) {+ if (fe !== null && Ge.has(fe) && (_.width !== fe.image.width || _.height !== fe.image.height))+ throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");+ L.setupDepthRenderbuffer(_);+ }+ }+ const he = _.texture;+ (he.isData3DTexture || he.isDataArrayTexture || he.isCompressedArrayTexture) && (j = !0);+ const ce = Ge.get(_).__webglFramebuffer;+ _.isWebGLCubeRenderTarget ? (Array.isArray(ce[R]) ? P = ce[R][N] : P = ce[R], z = !0) : _.samples > 0 && L.useMultisampledRTT(_) === !1 ? P = Ge.get(_).__webglMultisampledFramebuffer : Array.isArray(ce) ? P = ce[N] : P = ce, F.copy(_.viewport), K.copy(_.scissor), q = _.scissorTest;+ } else+ F.copy(ae).multiplyScalar(Q).floor(), K.copy(ye).multiplyScalar(Q).floor(), q = Me;+ if (N !== 0 && (P = x), ze.bindFramebuffer(G.FRAMEBUFFER, P) && U && ze.drawBuffers(_, P), ze.viewport(F), ze.scissor(K), ze.setScissorTest(q), z) {+ const ie = Ge.get(_.texture);+ G.framebufferTexture2D(G.FRAMEBUFFER, G.COLOR_ATTACHMENT0, G.TEXTURE_CUBE_MAP_POSITIVE_X + R, ie.__webglTexture, N);+ } else if (j) {+ const ie = Ge.get(_.texture), he = R;+ G.framebufferTextureLayer(G.FRAMEBUFFER, G.COLOR_ATTACHMENT0, ie.__webglTexture, N, he);+ } else if (_ !== null && N !== 0) {+ const ie = Ge.get(_.texture);+ G.framebufferTexture2D(G.FRAMEBUFFER, G.COLOR_ATTACHMENT0, G.TEXTURE_2D, ie.__webglTexture, N);+ }+ C = -1;+ }, this.readRenderTargetPixels = function(_, R, N, U, P, z, j) {+ if (!(_ && _.isWebGLRenderTarget)) {+ console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");+ return;+ }+ let X = Ge.get(_).__webglFramebuffer;+ if (_.isWebGLCubeRenderTarget && j !== void 0 && (X = X[j]), X) {+ ze.bindFramebuffer(G.FRAMEBUFFER, X);+ try {+ const ie = _.texture, he = ie.format, ce = ie.type;+ if (!pt.textureFormatReadable(he)) {+ console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");+ return;+ }+ if (!pt.textureTypeReadable(ce)) {+ console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");+ return;+ }+ R >= 0 && R <= _.width - U && N >= 0 && N <= _.height - P && G.readPixels(R, N, U, P, We.convert(he), We.convert(ce), z);+ } finally {+ const ie = T !== null ? Ge.get(T).__webglFramebuffer : null;+ ze.bindFramebuffer(G.FRAMEBUFFER, ie);+ }+ }+ }, this.readRenderTargetPixelsAsync = async function(_, R, N, U, P, z, j) {+ if (!(_ && _.isWebGLRenderTarget))+ throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");+ let X = Ge.get(_).__webglFramebuffer;+ if (_.isWebGLCubeRenderTarget && j !== void 0 && (X = X[j]), X)+ if (R >= 0 && R <= _.width - U && N >= 0 && N <= _.height - P) {+ ze.bindFramebuffer(G.FRAMEBUFFER, X);+ const ie = _.texture, he = ie.format, ce = ie.type;+ if (!pt.textureFormatReadable(he))+ throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");+ if (!pt.textureTypeReadable(ce))+ throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");+ const fe = G.createBuffer();+ G.bindBuffer(G.PIXEL_PACK_BUFFER, fe), G.bufferData(G.PIXEL_PACK_BUFFER, z.byteLength, G.STREAM_READ), G.readPixels(R, N, U, P, We.convert(he), We.convert(ce), 0);+ const Ae = T !== null ? Ge.get(T).__webglFramebuffer : null;+ ze.bindFramebuffer(G.FRAMEBUFFER, Ae);+ const Ee = G.fenceSync(G.SYNC_GPU_COMMANDS_COMPLETE, 0);+ return G.flush(), await BE(G, Ee, 4), G.bindBuffer(G.PIXEL_PACK_BUFFER, fe), G.getBufferSubData(G.PIXEL_PACK_BUFFER, 0, z), G.deleteBuffer(fe), G.deleteSync(Ee), z;+ } else+ throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.");+ }, this.copyFramebufferToTexture = function(_, R = null, N = 0) {+ const U = Math.pow(2, -N), P = Math.floor(_.image.width * U), z = Math.floor(_.image.height * U), j = R !== null ? R.x : 0, X = R !== null ? R.y : 0;+ L.setTexture2D(_, 0), G.copyTexSubImage2D(G.TEXTURE_2D, N, 0, 0, j, X, P, z), ze.unbindTexture();+ };+ const B = G.createFramebuffer(), k = G.createFramebuffer();+ this.copyTextureToTexture = function(_, R, N = null, U = null, P = 0, z = null) {+ z === null && (P !== 0 ? (pl("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."), z = P, P = 0) : z = 0);+ let j, X, ie, he, ce, fe, Ae, Ee, De;+ const qe = _.isCompressedTexture ? _.mipmaps[z] : _.image;+ if (N !== null)+ j = N.max.x - N.min.x, X = N.max.y - N.min.y, ie = N.isBox3 ? N.max.z - N.min.z : 1, he = N.min.x, ce = N.min.y, fe = N.isBox3 ? N.min.z : 0;+ else {+ const pn = Math.pow(2, -P);+ j = Math.floor(qe.width * pn), X = Math.floor(qe.height * pn), _.isDataArrayTexture ? ie = qe.depth : _.isData3DTexture ? ie = Math.floor(qe.depth * pn) : ie = 1, he = 0, ce = 0, fe = 0;+ }+ U !== null ? (Ae = U.x, Ee = U.y, De = U.z) : (Ae = 0, Ee = 0, De = 0);+ const He = We.convert(R.format), Ne = We.convert(R.type);+ let st;+ R.isData3DTexture ? (L.setTexture3D(R, 0), st = G.TEXTURE_3D) : R.isDataArrayTexture || R.isCompressedArrayTexture ? (L.setTexture2DArray(R, 0), st = G.TEXTURE_2D_ARRAY) : (L.setTexture2D(R, 0), st = G.TEXTURE_2D), G.pixelStorei(G.UNPACK_FLIP_Y_WEBGL, R.flipY), G.pixelStorei(G.UNPACK_PREMULTIPLY_ALPHA_WEBGL, R.premultiplyAlpha), G.pixelStorei(G.UNPACK_ALIGNMENT, R.unpackAlignment);+ const Le = G.getParameter(G.UNPACK_ROW_LENGTH), yt = G.getParameter(G.UNPACK_IMAGE_HEIGHT), en = G.getParameter(G.UNPACK_SKIP_PIXELS), xt = G.getParameter(G.UNPACK_SKIP_ROWS), At = G.getParameter(G.UNPACK_SKIP_IMAGES);+ G.pixelStorei(G.UNPACK_ROW_LENGTH, qe.width), G.pixelStorei(G.UNPACK_IMAGE_HEIGHT, qe.height), G.pixelStorei(G.UNPACK_SKIP_PIXELS, he), G.pixelStorei(G.UNPACK_SKIP_ROWS, ce), G.pixelStorei(G.UNPACK_SKIP_IMAGES, fe);+ const Ke = _.isDataArrayTexture || _.isData3DTexture, zt = R.isDataArrayTexture || R.isData3DTexture;+ if (_.isDepthTexture) {+ const pn = Ge.get(_), Nt = Ge.get(R), tn = Ge.get(pn.__renderTarget), xh = Ge.get(Nt.__renderTarget);+ ze.bindFramebuffer(G.READ_FRAMEBUFFER, tn.__webglFramebuffer), ze.bindFramebuffer(G.DRAW_FRAMEBUFFER, xh.__webglFramebuffer);+ for (let Ks = 0; Ks < ie; Ks++)+ Ke && (G.framebufferTextureLayer(G.READ_FRAMEBUFFER, G.COLOR_ATTACHMENT0, Ge.get(_).__webglTexture, P, fe + Ks), G.framebufferTextureLayer(G.DRAW_FRAMEBUFFER, G.COLOR_ATTACHMENT0, Ge.get(R).__webglTexture, z, De + Ks)), G.blitFramebuffer(he, ce, j, X, Ae, Ee, j, X, G.DEPTH_BUFFER_BIT, G.NEAREST);+ ze.bindFramebuffer(G.READ_FRAMEBUFFER, null), ze.bindFramebuffer(G.DRAW_FRAMEBUFFER, null);+ } else if (P !== 0 || _.isRenderTargetTexture || Ge.has(_)) {+ const pn = Ge.get(_), Nt = Ge.get(R);+ ze.bindFramebuffer(G.READ_FRAMEBUFFER, B), ze.bindFramebuffer(G.DRAW_FRAMEBUFFER, k);+ for (let tn = 0; tn < ie; tn++)+ Ke ? G.framebufferTextureLayer(G.READ_FRAMEBUFFER, G.COLOR_ATTACHMENT0, pn.__webglTexture, P, fe + tn) : G.framebufferTexture2D(G.READ_FRAMEBUFFER, G.COLOR_ATTACHMENT0, G.TEXTURE_2D, pn.__webglTexture, P), zt ? G.framebufferTextureLayer(G.DRAW_FRAMEBUFFER, G.COLOR_ATTACHMENT0, Nt.__webglTexture, z, De + tn) : G.framebufferTexture2D(G.DRAW_FRAMEBUFFER, G.COLOR_ATTACHMENT0, G.TEXTURE_2D, Nt.__webglTexture, z), P !== 0 ? G.blitFramebuffer(he, ce, j, X, Ae, Ee, j, X, G.COLOR_BUFFER_BIT, G.NEAREST) : zt ? G.copyTexSubImage3D(st, z, Ae, Ee, De + tn, he, ce, j, X) : G.copyTexSubImage2D(st, z, Ae, Ee, he, ce, j, X);+ ze.bindFramebuffer(G.READ_FRAMEBUFFER, null), ze.bindFramebuffer(G.DRAW_FRAMEBUFFER, null);+ } else+ zt ? _.isDataTexture || _.isData3DTexture ? G.texSubImage3D(st, z, Ae, Ee, De, j, X, ie, He, Ne, qe.data) : R.isCompressedArrayTexture ? G.compressedTexSubImage3D(st, z, Ae, Ee, De, j, X, ie, He, qe.data) : G.texSubImage3D(st, z, Ae, Ee, De, j, X, ie, He, Ne, qe) : _.isDataTexture ? G.texSubImage2D(G.TEXTURE_2D, z, Ae, Ee, j, X, He, Ne, qe.data) : _.isCompressedTexture ? G.compressedTexSubImage2D(G.TEXTURE_2D, z, Ae, Ee, qe.width, qe.height, He, qe.data) : G.texSubImage2D(G.TEXTURE_2D, z, Ae, Ee, j, X, He, Ne, qe);+ G.pixelStorei(G.UNPACK_ROW_LENGTH, Le), G.pixelStorei(G.UNPACK_IMAGE_HEIGHT, yt), G.pixelStorei(G.UNPACK_SKIP_PIXELS, en), G.pixelStorei(G.UNPACK_SKIP_ROWS, xt), G.pixelStorei(G.UNPACK_SKIP_IMAGES, At), z === 0 && R.generateMipmaps && G.generateMipmap(st), ze.unbindTexture();+ }, this.copyTextureToTexture3D = function(_, R, N = null, U = null, P = 0) {+ return pl('WebGLRenderer: copyTextureToTexture3D function has been deprecated. Use "copyTextureToTexture" instead.'), this.copyTextureToTexture(_, R, N, U, P);+ }, this.initRenderTarget = function(_) {+ Ge.get(_).__webglFramebuffer === void 0 && L.setupRenderTarget(_);+ }, this.initTexture = function(_) {+ _.isCubeTexture ? L.setTextureCube(_, 0) : _.isData3DTexture ? L.setTexture3D(_, 0) : _.isDataArrayTexture || _.isCompressedArrayTexture ? L.setTexture2DArray(_, 0) : L.setTexture2D(_, 0), ze.unbindTexture();+ }, this.resetState = function() {+ w = 0, S = 0, T = null, ze.reset(), nt.reset();+ }, typeof __THREE_DEVTOOLS__ < "u" && __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe", { detail: this }));+ }+ /**+ * Defines the coordinate system of the renderer.+ *+ * In `WebGLRenderer`, the value is always `WebGLCoordinateSystem`.+ *+ * @type {WebGLCoordinateSystem|WebGPUCoordinateSystem}+ * @default WebGLCoordinateSystem+ * @readonly+ */+ get coordinateSystem() {+ return is;+ }+ /**+ * Defines the output color space of the renderer.+ *+ * @type {SRGBColorSpace|LinearSRGBColorSpace}+ * @default SRGBColorSpace+ */+ get outputColorSpace() {+ return this._outputColorSpace;+ }+ set outputColorSpace(e) {+ this._outputColorSpace = e;+ const t = this.getContext();+ t.drawingBufferColorSpace = mt._getDrawingBufferColorSpace(e), t.unpackColorSpace = mt._getUnpackColorSpace();+ }+}+var vo = function() {+ var i = 0, e = document.createElement("div");+ e.style.cssText = "position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000", e.addEventListener("click", function(h) {+ h.preventDefault(), n(++i % e.children.length);+ }, !1);+ function t(h) {+ return e.appendChild(h.dom), h;+ }+ function n(h) {+ for (var u = 0; u < e.children.length; u++)+ e.children[u].style.display = u === h ? "block" : "none";+ i = h;+ }+ var s = (performance || Date).now(), r = s, a = 0, o = t(new vo.Panel("FPS", "#0ff", "#002")), c = t(new vo.Panel("MS", "#0f0", "#020"));+ if (self.performance && self.performance.memory)+ var l = t(new vo.Panel("MB", "#f08", "#201"));+ return n(0), {+ REVISION: 16,+ dom: e,+ addPanel: t,+ showPanel: n,+ begin: function() {+ s = (performance || Date).now();+ },+ end: function() {+ a++;+ var h = (performance || Date).now();+ if (c.update(h - s, 200), h >= r + 1e3 && (o.update(a * 1e3 / (h - r), 100), r = h, a = 0, l)) {+ var u = performance.memory;+ l.update(u.usedJSHeapSize / 1048576, u.jsHeapSizeLimit / 1048576);+ }+ return h;+ },+ update: function() {+ s = this.end();+ },+ // Backwards Compatibility+ domElement: e,+ setMode: n+ };+};+vo.Panel = function(i, e, t) {+ var n = 1 / 0, s = 0, r = Math.round, a = r(window.devicePixelRatio || 1), o = 80 * a, c = 48 * a, l = 3 * a, h = 2 * a, u = 3 * a, d = 15 * a, f = 74 * a, m = 30 * a, A = document.createElement("canvas");+ A.width = o, A.height = c, A.style.cssText = "width:80px;height:48px";+ var g = A.getContext("2d");+ return g.font = "bold " + 9 * a + "px Helvetica,Arial,sans-serif", g.textBaseline = "top", g.fillStyle = t, g.fillRect(0, 0, o, c), g.fillStyle = e, g.fillText(i, l, h), g.fillRect(u, d, f, m), g.fillStyle = t, g.globalAlpha = 0.9, g.fillRect(u, d, f, m), {+ dom: A,+ update: function(p, y) {+ n = Math.min(n, p), s = Math.max(s, p), g.fillStyle = t, g.globalAlpha = 1, g.fillRect(0, 0, o, d), g.fillStyle = e, g.fillText(r(p) + " " + i + " (" + r(n) + "-" + r(s) + ")", l, h), g.drawImage(A, u + a, d, f - a, m, u, d, f - a, m), g.fillRect(u + f - a, d, a, m), g.fillStyle = t, g.globalAlpha = 0.9, g.fillRect(u + f - a, d, a, r((1 - p / y) * m));+ }+ };+};+function MA(i, e) {+ if (e === tE)+ return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."), i;+ if (e === bd || e === t0) {+ let t = i.getIndex();+ if (t === null) {+ const a = [], o = i.getAttribute("position");+ if (o !== void 0) {+ for (let c = 0; c < o.count; c++)+ a.push(c);+ i.setIndex(a), t = i.getIndex();+ } else+ return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."), i;+ }+ const n = t.count - 2, s = [];+ if (e === bd)+ for (let a = 1; a <= n; a++)+ s.push(t.getX(0)), s.push(t.getX(a)), s.push(t.getX(a + 1));+ else+ for (let a = 0; a < n; a++)+ a % 2 === 0 ? (s.push(t.getX(a)), s.push(t.getX(a + 1)), s.push(t.getX(a + 2))) : (s.push(t.getX(a + 2)), s.push(t.getX(a + 1)), s.push(t.getX(a)));+ s.length / 3 !== n && console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");+ const r = i.clone();+ return r.setIndex(s), r.clearGroups(), r;+ } else+ return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:", e), i;+}+class R0 extends ps {+ /**+ * Constructs a new glTF loader.+ *+ * @param {LoadingManager} [manager] - The loading manager.+ */+ constructor(e) {+ super(e), this.dracoLoader = null, this.ktx2Loader = null, this.meshoptDecoder = null, this.pluginCallbacks = [], this.register(function(t) {+ return new UI(t);+ }), this.register(function(t) {+ return new OI(t);+ }), this.register(function(t) {+ return new jI(t);+ }), this.register(function(t) {+ return new XI(t);+ }), this.register(function(t) {+ return new YI(t);+ }), this.register(function(t) {+ return new GI(t);+ }), this.register(function(t) {+ return new HI(t);+ }), this.register(function(t) {+ return new zI(t);+ }), this.register(function(t) {+ return new VI(t);+ }), this.register(function(t) {+ return new kI(t);+ }), this.register(function(t) {+ return new WI(t);+ }), this.register(function(t) {+ return new QI(t);+ }), this.register(function(t) {+ return new KI(t);+ }), this.register(function(t) {+ return new qI(t);+ }), this.register(function(t) {+ return new LI(t);+ }), this.register(function(t) {+ return new JI(t);+ }), this.register(function(t) {+ return new ZI(t);+ });+ }+ /**+ * Starts loading from the given URL and passes the loaded glTF asset+ * to the `onLoad()` callback.+ *+ * @param {string} url - The path/URL of the file to be loaded. This can also be a data URI.+ * @param {function(GLTFLoader~LoadObject)} onLoad - Executed when the loading process has been finished.+ * @param {onProgressCallback} onProgress - Executed while the loading is in progress.+ * @param {onErrorCallback} onError - Executed when errors occur.+ */+ load(e, t, n, s) {+ const r = this;+ let a;+ if (this.resourcePath !== "")+ a = this.resourcePath;+ else if (this.path !== "") {+ const l = Aa.extractUrlBase(e);+ a = Aa.resolveURL(l, this.path);+ } else+ a = Aa.extractUrlBase(e);+ this.manager.itemStart(e);+ const o = function(l) {+ s ? s(l) : console.error(l), r.manager.itemError(e), r.manager.itemEnd(e);+ }, c = new Ps(this.manager);+ c.setPath(this.path), c.setResponseType("arraybuffer"), c.setRequestHeader(this.requestHeader), c.setWithCredentials(this.withCredentials), c.load(e, function(l) {+ try {+ r.parse(l, a, function(h) {+ t(h), r.manager.itemEnd(e);+ }, o);+ } catch (h) {+ o(h);+ }+ }, n, o);+ }+ /**+ * Sets the given Draco loader to this loader. Required for decoding assets+ * compressed with the `KHR_draco_mesh_compression` extension.+ *+ * @param {DRACOLoader} dracoLoader - The Draco loader to set.+ * @return {GLTFLoader} A reference to this loader.+ */+ setDRACOLoader(e) {+ return this.dracoLoader = e, this;+ }+ /**+ * Sets the given KTX2 loader to this loader. Required for loading KTX2+ * compressed textures.+ *+ * @param {KTX2Loader} ktx2Loader - The KTX2 loader to set.+ * @return {GLTFLoader} A reference to this loader.+ */+ setKTX2Loader(e) {+ return this.ktx2Loader = e, this;+ }+ /**+ * Sets the given meshopt decoder. Required for decoding assets+ * compressed with the `EXT_meshopt_compression` extension.+ *+ * @param {Object} meshoptDecoder - The meshopt decoder to set.+ * @return {GLTFLoader} A reference to this loader.+ */+ setMeshoptDecoder(e) {+ return this.meshoptDecoder = e, this;+ }+ /**+ * Registers a plugin callback. This API is internally used to implement the various+ * glTF extensions but can also used by third-party code to add additional logic+ * to the loader.+ *+ * @param {function(parser:GLTFParser)} callback - The callback function to register.+ * @return {GLTFLoader} A reference to this loader.+ */+ register(e) {+ return this.pluginCallbacks.indexOf(e) === -1 && this.pluginCallbacks.push(e), this;+ }+ /**+ * Unregisters a plugin callback.+ *+ * @param {Function} callback - The callback function to unregister.+ * @return {GLTFLoader} A reference to this loader.+ */+ unregister(e) {+ return this.pluginCallbacks.indexOf(e) !== -1 && this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e), 1), this;+ }+ /**+ * Parses the given FBX data and returns the resulting group.+ *+ * @param {string|ArrayBuffer} data - The raw glTF data.+ * @param {string} path - The URL base path.+ * @param {function(GLTFLoader~LoadObject)} onLoad - Executed when the loading process has been finished.+ * @param {onErrorCallback} onError - Executed when errors occur.+ */+ parse(e, t, n, s) {+ let r;+ const a = {}, o = {}, c = new TextDecoder();+ if (typeof e == "string")+ r = JSON.parse(e);+ else if (e instanceof ArrayBuffer)+ if (c.decode(new Uint8Array(e, 0, 4)) === N0) {+ try {+ a[ft.KHR_BINARY_GLTF] = new $I(e);+ } catch (u) {+ s && s(u);+ return;+ }+ r = JSON.parse(a[ft.KHR_BINARY_GLTF].content);+ } else+ r = JSON.parse(c.decode(e));+ else+ r = e;+ if (r.asset === void 0 || r.asset.version[0] < 2) {+ s && s(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));+ return;+ }+ const l = new d1(r, {+ path: t || this.resourcePath || "",+ crossOrigin: this.crossOrigin,+ requestHeader: this.requestHeader,+ manager: this.manager,+ ktx2Loader: this.ktx2Loader,+ meshoptDecoder: this.meshoptDecoder+ });+ l.fileLoader.setRequestHeader(this.requestHeader);+ for (let h = 0; h < this.pluginCallbacks.length; h++) {+ const u = this.pluginCallbacks[h](l);+ u.name || console.error("THREE.GLTFLoader: Invalid plugin found: missing name"), o[u.name] = u, a[u.name] = !0;+ }+ if (r.extensionsUsed)+ for (let h = 0; h < r.extensionsUsed.length; ++h) {+ const u = r.extensionsUsed[h], d = r.extensionsRequired || [];+ switch (u) {+ case ft.KHR_MATERIALS_UNLIT:+ a[u] = new PI();+ break;+ case ft.KHR_DRACO_MESH_COMPRESSION:+ a[u] = new e1(r, this.dracoLoader);+ break;+ case ft.KHR_TEXTURE_TRANSFORM:+ a[u] = new t1();+ break;+ case ft.KHR_MESH_QUANTIZATION:+ a[u] = new n1();+ break;+ default:+ d.indexOf(u) >= 0 && o[u] === void 0 && console.warn('THREE.GLTFLoader: Unknown extension "' + u + '".');+ }+ }+ l.setExtensions(a), l.setPlugins(o), l.parse(n, s);+ }+ /**+ * Async version of {@link GLTFLoader#parse}.+ *+ * @async+ * @param {string|ArrayBuffer} data - The raw glTF data.+ * @param {string} path - The URL base path.+ * @return {Promise<GLTFLoader~LoadObject>} A Promise that resolves with the loaded glTF when the parsing has been finished.+ */+ parseAsync(e, t) {+ const n = this;+ return new Promise(function(s, r) {+ n.parse(e, t, s, r);+ });+ }+}+function DI() {+ let i = {};+ return {+ get: function(e) {+ return i[e];+ },+ add: function(e, t) {+ i[e] = t;+ },+ remove: function(e) {+ delete i[e];+ },+ removeAll: function() {+ i = {};+ }+ };+}+const ft = {+ KHR_BINARY_GLTF: "KHR_binary_glTF",+ KHR_DRACO_MESH_COMPRESSION: "KHR_draco_mesh_compression",+ KHR_LIGHTS_PUNCTUAL: "KHR_lights_punctual",+ KHR_MATERIALS_CLEARCOAT: "KHR_materials_clearcoat",+ KHR_MATERIALS_DISPERSION: "KHR_materials_dispersion",+ KHR_MATERIALS_IOR: "KHR_materials_ior",+ KHR_MATERIALS_SHEEN: "KHR_materials_sheen",+ KHR_MATERIALS_SPECULAR: "KHR_materials_specular",+ KHR_MATERIALS_TRANSMISSION: "KHR_materials_transmission",+ KHR_MATERIALS_IRIDESCENCE: "KHR_materials_iridescence",+ KHR_MATERIALS_ANISOTROPY: "KHR_materials_anisotropy",+ KHR_MATERIALS_UNLIT: "KHR_materials_unlit",+ KHR_MATERIALS_VOLUME: "KHR_materials_volume",+ KHR_TEXTURE_BASISU: "KHR_texture_basisu",+ KHR_TEXTURE_TRANSFORM: "KHR_texture_transform",+ KHR_MESH_QUANTIZATION: "KHR_mesh_quantization",+ KHR_MATERIALS_EMISSIVE_STRENGTH: "KHR_materials_emissive_strength",+ EXT_MATERIALS_BUMP: "EXT_materials_bump",+ EXT_TEXTURE_WEBP: "EXT_texture_webp",+ EXT_TEXTURE_AVIF: "EXT_texture_avif",+ EXT_MESHOPT_COMPRESSION: "EXT_meshopt_compression",+ EXT_MESH_GPU_INSTANCING: "EXT_mesh_gpu_instancing"+};+class LI {+ constructor(e) {+ this.parser = e, this.name = ft.KHR_LIGHTS_PUNCTUAL, this.cache = { refs: {}, uses: {} };+ }+ _markDefs() {+ const e = this.parser, t = this.parser.json.nodes || [];+ for (let n = 0, s = t.length; n < s; n++) {+ const r = t[n];+ r.extensions && r.extensions[this.name] && r.extensions[this.name].light !== void 0 && e._addNodeRef(this.cache, r.extensions[this.name].light);+ }+ }+ _loadLight(e) {+ const t = this.parser, n = "light:" + e;+ let s = t.cache.get(n);+ if (s) return s;+ const r = t.json, c = ((r.extensions && r.extensions[this.name] || {}).lights || [])[e];+ let l;+ const h = new je(16777215);+ c.color !== void 0 && h.setRGB(c.color[0], c.color[1], c.color[2], ln);+ const u = c.range !== void 0 ? c.range : 0;+ switch (c.type) {+ case "directional":+ l = new w0(h), l.target.position.set(0, 0, -1), l.add(l.target);+ break;+ case "point":+ l = new y0(h), l.distance = u;+ break;+ case "spot":+ l = new Ry(h), l.distance = u, c.spot = c.spot || {}, c.spot.innerConeAngle = c.spot.innerConeAngle !== void 0 ? c.spot.innerConeAngle : 0, c.spot.outerConeAngle = c.spot.outerConeAngle !== void 0 ? c.spot.outerConeAngle : Math.PI / 4, l.angle = c.spot.outerConeAngle, l.penumbra = 1 - c.spot.innerConeAngle / c.spot.outerConeAngle, l.target.position.set(0, 0, -1), l.add(l.target);+ break;+ default:+ throw new Error("THREE.GLTFLoader: Unexpected light type: " + c.type);+ }+ return l.position.set(0, 0, 0), Yi(l, c), c.intensity !== void 0 && (l.intensity = c.intensity), l.name = t.createUniqueName(c.name || "light_" + e), s = Promise.resolve(l), t.cache.add(n, s), s;+ }+ getDependency(e, t) {+ if (e === "light")+ return this._loadLight(t);+ }+ createNodeAttachment(e) {+ const t = this, n = this.parser, r = n.json.nodes[e], o = (r.extensions && r.extensions[this.name] || {}).light;+ return o === void 0 ? null : this._loadLight(o).then(function(c) {+ return n._getNodeRef(t.cache, o, c);+ });+ }+}+class PI {+ constructor() {+ this.name = ft.KHR_MATERIALS_UNLIT;+ }+ getMaterialType() {+ return Ns;+ }+ extendParams(e, t, n) {+ const s = [];+ e.color = new je(1, 1, 1), e.opacity = 1;+ const r = t.pbrMetallicRoughness;+ if (r) {+ if (Array.isArray(r.baseColorFactor)) {+ const a = r.baseColorFactor;+ e.color.setRGB(a[0], a[1], a[2], ln), e.opacity = a[3];+ }+ r.baseColorTexture !== void 0 && s.push(n.assignTexture(e, "map", r.baseColorTexture, Kt));+ }+ return Promise.all(s);+ }+}+class kI {+ constructor(e) {+ this.parser = e, this.name = ft.KHR_MATERIALS_EMISSIVE_STRENGTH;+ }+ extendMaterialParams(e, t) {+ const s = this.parser.json.materials[e];+ if (!s.extensions || !s.extensions[this.name])+ return Promise.resolve();+ const r = s.extensions[this.name].emissiveStrength;+ return r !== void 0 && (t.emissiveIntensity = r), Promise.resolve();+ }+}+class UI {+ constructor(e) {+ this.parser = e, this.name = ft.KHR_MATERIALS_CLEARCOAT;+ }+ getMaterialType(e) {+ const n = this.parser.json.materials[e];+ return !n.extensions || !n.extensions[this.name] ? null : Oi;+ }+ extendMaterialParams(e, t) {+ const n = this.parser, s = n.json.materials[e];+ if (!s.extensions || !s.extensions[this.name])+ return Promise.resolve();+ const r = [], a = s.extensions[this.name];+ if (a.clearcoatFactor !== void 0 && (t.clearcoat = a.clearcoatFactor), a.clearcoatTexture !== void 0 && r.push(n.assignTexture(t, "clearcoatMap", a.clearcoatTexture)), a.clearcoatRoughnessFactor !== void 0 && (t.clearcoatRoughness = a.clearcoatRoughnessFactor), a.clearcoatRoughnessTexture !== void 0 && r.push(n.assignTexture(t, "clearcoatRoughnessMap", a.clearcoatRoughnessTexture)), a.clearcoatNormalTexture !== void 0 && (r.push(n.assignTexture(t, "clearcoatNormalMap", a.clearcoatNormalTexture)), a.clearcoatNormalTexture.scale !== void 0)) {+ const o = a.clearcoatNormalTexture.scale;+ t.clearcoatNormalScale = new Ze(o, o);+ }+ return Promise.all(r);+ }+}+class OI {+ constructor(e) {+ this.parser = e, this.name = ft.KHR_MATERIALS_DISPERSION;+ }+ getMaterialType(e) {+ const n = this.parser.json.materials[e];+ return !n.extensions || !n.extensions[this.name] ? null : Oi;+ }+ extendMaterialParams(e, t) {+ const s = this.parser.json.materials[e];+ if (!s.extensions || !s.extensions[this.name])+ return Promise.resolve();+ const r = s.extensions[this.name];+ return t.dispersion = r.dispersion !== void 0 ? r.dispersion : 0, Promise.resolve();+ }+}+class QI {+ constructor(e) {+ this.parser = e, this.name = ft.KHR_MATERIALS_IRIDESCENCE;+ }+ getMaterialType(e) {+ const n = this.parser.json.materials[e];+ return !n.extensions || !n.extensions[this.name] ? null : Oi;+ }+ extendMaterialParams(e, t) {+ const n = this.parser, s = n.json.materials[e];+ if (!s.extensions || !s.extensions[this.name])+ return Promise.resolve();+ const r = [], a = s.extensions[this.name];+ return a.iridescenceFactor !== void 0 && (t.iridescence = a.iridescenceFactor), a.iridescenceTexture !== void 0 && r.push(n.assignTexture(t, "iridescenceMap", a.iridescenceTexture)), a.iridescenceIor !== void 0 && (t.iridescenceIOR = a.iridescenceIor), t.iridescenceThicknessRange === void 0 && (t.iridescenceThicknessRange = [100, 400]), a.iridescenceThicknessMinimum !== void 0 && (t.iridescenceThicknessRange[0] = a.iridescenceThicknessMinimum), a.iridescenceThicknessMaximum !== void 0 && (t.iridescenceThicknessRange[1] = a.iridescenceThicknessMaximum), a.iridescenceThicknessTexture !== void 0 && r.push(n.assignTexture(t, "iridescenceThicknessMap", a.iridescenceThicknessTexture)), Promise.all(r);+ }+}+class GI {+ constructor(e) {+ this.parser = e, this.name = ft.KHR_MATERIALS_SHEEN;+ }+ getMaterialType(e) {+ const n = this.parser.json.materials[e];+ return !n.extensions || !n.extensions[this.name] ? null : Oi;+ }+ extendMaterialParams(e, t) {+ const n = this.parser, s = n.json.materials[e];+ if (!s.extensions || !s.extensions[this.name])+ return Promise.resolve();+ const r = [];+ t.sheenColor = new je(0, 0, 0), t.sheenRoughness = 0, t.sheen = 1;+ const a = s.extensions[this.name];+ if (a.sheenColorFactor !== void 0) {+ const o = a.sheenColorFactor;+ t.sheenColor.setRGB(o[0], o[1], o[2], ln);+ }+ return a.sheenRoughnessFactor !== void 0 && (t.sheenRoughness = a.sheenRoughnessFactor), a.sheenColorTexture !== void 0 && r.push(n.assignTexture(t, "sheenColorMap", a.sheenColorTexture, Kt)), a.sheenRoughnessTexture !== void 0 && r.push(n.assignTexture(t, "sheenRoughnessMap", a.sheenRoughnessTexture)), Promise.all(r);+ }+}+class HI {+ constructor(e) {+ this.parser = e, this.name = ft.KHR_MATERIALS_TRANSMISSION;+ }+ getMaterialType(e) {+ const n = this.parser.json.materials[e];+ return !n.extensions || !n.extensions[this.name] ? null : Oi;+ }+ extendMaterialParams(e, t) {+ const n = this.parser, s = n.json.materials[e];+ if (!s.extensions || !s.extensions[this.name])+ return Promise.resolve();+ const r = [], a = s.extensions[this.name];+ return a.transmissionFactor !== void 0 && (t.transmission = a.transmissionFactor), a.transmissionTexture !== void 0 && r.push(n.assignTexture(t, "transmissionMap", a.transmissionTexture)), Promise.all(r);+ }+}+class zI {+ constructor(e) {+ this.parser = e, this.name = ft.KHR_MATERIALS_VOLUME;+ }+ getMaterialType(e) {+ const n = this.parser.json.materials[e];+ return !n.extensions || !n.extensions[this.name] ? null : Oi;+ }+ extendMaterialParams(e, t) {+ const n = this.parser, s = n.json.materials[e];+ if (!s.extensions || !s.extensions[this.name])+ return Promise.resolve();+ const r = [], a = s.extensions[this.name];+ t.thickness = a.thicknessFactor !== void 0 ? a.thicknessFactor : 0, a.thicknessTexture !== void 0 && r.push(n.assignTexture(t, "thicknessMap", a.thicknessTexture)), t.attenuationDistance = a.attenuationDistance || 1 / 0;+ const o = a.attenuationColor || [1, 1, 1];+ return t.attenuationColor = new je().setRGB(o[0], o[1], o[2], ln), Promise.all(r);+ }+}+class VI {+ constructor(e) {+ this.parser = e, this.name = ft.KHR_MATERIALS_IOR;+ }+ getMaterialType(e) {+ const n = this.parser.json.materials[e];+ return !n.extensions || !n.extensions[this.name] ? null : Oi;+ }+ extendMaterialParams(e, t) {+ const s = this.parser.json.materials[e];+ if (!s.extensions || !s.extensions[this.name])+ return Promise.resolve();+ const r = s.extensions[this.name];+ return t.ior = r.ior !== void 0 ? r.ior : 1.5, Promise.resolve();+ }+}+class WI {+ constructor(e) {+ this.parser = e, this.name = ft.KHR_MATERIALS_SPECULAR;+ }+ getMaterialType(e) {+ const n = this.parser.json.materials[e];+ return !n.extensions || !n.extensions[this.name] ? null : Oi;+ }+ extendMaterialParams(e, t) {+ const n = this.parser, s = n.json.materials[e];+ if (!s.extensions || !s.extensions[this.name])+ return Promise.resolve();+ const r = [], a = s.extensions[this.name];+ t.specularIntensity = a.specularFactor !== void 0 ? a.specularFactor : 1, a.specularTexture !== void 0 && r.push(n.assignTexture(t, "specularIntensityMap", a.specularTexture));+ const o = a.specularColorFactor || [1, 1, 1];+ return t.specularColor = new je().setRGB(o[0], o[1], o[2], ln), a.specularColorTexture !== void 0 && r.push(n.assignTexture(t, "specularColorMap", a.specularColorTexture, Kt)), Promise.all(r);+ }+}+class qI {+ constructor(e) {+ this.parser = e, this.name = ft.EXT_MATERIALS_BUMP;+ }+ getMaterialType(e) {+ const n = this.parser.json.materials[e];+ return !n.extensions || !n.extensions[this.name] ? null : Oi;+ }+ extendMaterialParams(e, t) {+ const n = this.parser, s = n.json.materials[e];+ if (!s.extensions || !s.extensions[this.name])+ return Promise.resolve();+ const r = [], a = s.extensions[this.name];+ return t.bumpScale = a.bumpFactor !== void 0 ? a.bumpFactor : 1, a.bumpTexture !== void 0 && r.push(n.assignTexture(t, "bumpMap", a.bumpTexture)), Promise.all(r);+ }+}+class KI {+ constructor(e) {+ this.parser = e, this.name = ft.KHR_MATERIALS_ANISOTROPY;+ }+ getMaterialType(e) {+ const n = this.parser.json.materials[e];+ return !n.extensions || !n.extensions[this.name] ? null : Oi;+ }+ extendMaterialParams(e, t) {+ const n = this.parser, s = n.json.materials[e];+ if (!s.extensions || !s.extensions[this.name])+ return Promise.resolve();+ const r = [], a = s.extensions[this.name];+ return a.anisotropyStrength !== void 0 && (t.anisotropy = a.anisotropyStrength), a.anisotropyRotation !== void 0 && (t.anisotropyRotation = a.anisotropyRotation), a.anisotropyTexture !== void 0 && r.push(n.assignTexture(t, "anisotropyMap", a.anisotropyTexture)), Promise.all(r);+ }+}+class jI {+ constructor(e) {+ this.parser = e, this.name = ft.KHR_TEXTURE_BASISU;+ }+ loadTexture(e) {+ const t = this.parser, n = t.json, s = n.textures[e];+ if (!s.extensions || !s.extensions[this.name])+ return null;+ const r = s.extensions[this.name], a = t.options.ktx2Loader;+ if (!a) {+ if (n.extensionsRequired && n.extensionsRequired.indexOf(this.name) >= 0)+ throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");+ return null;+ }+ return t.loadTextureImage(e, r.source, a);+ }+}+class XI {+ constructor(e) {+ this.parser = e, this.name = ft.EXT_TEXTURE_WEBP;+ }+ loadTexture(e) {+ const t = this.name, n = this.parser, s = n.json, r = s.textures[e];+ if (!r.extensions || !r.extensions[t])+ return null;+ const a = r.extensions[t], o = s.images[a.source];+ let c = n.textureLoader;+ if (o.uri) {+ const l = n.options.manager.getHandler(o.uri);+ l !== null && (c = l);+ }+ return n.loadTextureImage(e, a.source, c);+ }+}+class YI {+ constructor(e) {+ this.parser = e, this.name = ft.EXT_TEXTURE_AVIF;+ }+ loadTexture(e) {+ const t = this.name, n = this.parser, s = n.json, r = s.textures[e];+ if (!r.extensions || !r.extensions[t])+ return null;+ const a = r.extensions[t], o = s.images[a.source];+ let c = n.textureLoader;+ if (o.uri) {+ const l = n.options.manager.getHandler(o.uri);+ l !== null && (c = l);+ }+ return n.loadTextureImage(e, a.source, c);+ }+}+class JI {+ constructor(e) {+ this.name = ft.EXT_MESHOPT_COMPRESSION, this.parser = e;+ }+ loadBufferView(e) {+ const t = this.parser.json, n = t.bufferViews[e];+ if (n.extensions && n.extensions[this.name]) {+ const s = n.extensions[this.name], r = this.parser.getDependency("buffer", s.buffer), a = this.parser.options.meshoptDecoder;+ if (!a || !a.supported) {+ if (t.extensionsRequired && t.extensionsRequired.indexOf(this.name) >= 0)+ throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");+ return null;+ }+ return r.then(function(o) {+ const c = s.byteOffset || 0, l = s.byteLength || 0, h = s.count, u = s.byteStride, d = new Uint8Array(o, c, l);+ return a.decodeGltfBufferAsync ? a.decodeGltfBufferAsync(h, u, d, s.mode, s.filter).then(function(f) {+ return f.buffer;+ }) : a.ready.then(function() {+ const f = new ArrayBuffer(h * u);+ return a.decodeGltfBuffer(new Uint8Array(f), h, u, d, s.mode, s.filter), f;+ });+ });+ } else+ return null;+ }+}+class ZI {+ constructor(e) {+ this.name = ft.EXT_MESH_GPU_INSTANCING, this.parser = e;+ }+ createNodeMesh(e) {+ const t = this.parser.json, n = t.nodes[e];+ if (!n.extensions || !n.extensions[this.name] || n.mesh === void 0)+ return null;+ const s = t.meshes[n.mesh];+ for (const l of s.primitives)+ if (l.mode !== $n.TRIANGLES && l.mode !== $n.TRIANGLE_STRIP && l.mode !== $n.TRIANGLE_FAN && l.mode !== void 0)+ return null;+ const a = n.extensions[this.name].attributes, o = [], c = {};+ for (const l in a)+ o.push(this.parser.getDependency("accessor", a[l]).then((h) => (c[l] = h, c[l])));+ return o.length < 1 ? null : (o.push(this.parser.createNodeMesh(e)), Promise.all(o).then((l) => {+ const h = l.pop(), u = h.isGroup ? h.children : [h], d = l[0].count, f = [];+ for (const m of u) {+ const A = new et(), g = new H(), p = new Yn(), y = new H(1, 1, 1), b = new g0(m.geometry, m.material, d);+ for (let E = 0; E < d; E++)+ c.TRANSLATION && g.fromBufferAttribute(c.TRANSLATION, E), c.ROTATION && p.fromBufferAttribute(c.ROTATION, E), c.SCALE && y.fromBufferAttribute(c.SCALE, E), b.setMatrixAt(E, A.compose(g, p, y));+ for (const E in c)+ if (E === "_COLOR_0") {+ const M = c[E];+ b.instanceColor = new Ed(M.array, M.itemSize, M.normalized);+ } else E !== "TRANSLATION" && E !== "ROTATION" && E !== "SCALE" && m.geometry.setAttribute(E, c[E]);+ kt.prototype.copy.call(b, m), this.parser.assignFinalMaterial(b), f.push(b);+ }+ return h.isGroup ? (h.clear(), h.add(...f), h) : f[0];+ }));+ }+}+const N0 = "glTF", io = 12, BA = { JSON: 1313821514, BIN: 5130562 };+class $I {+ constructor(e) {+ this.name = ft.KHR_BINARY_GLTF, this.content = null, this.body = null;+ const t = new DataView(e, 0, io), n = new TextDecoder();+ if (this.header = {+ magic: n.decode(new Uint8Array(e.slice(0, 4))),+ version: t.getUint32(4, !0),+ length: t.getUint32(8, !0)+ }, this.header.magic !== N0)+ throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");+ if (this.header.version < 2)+ throw new Error("THREE.GLTFLoader: Legacy binary file detected.");+ const s = this.header.length - io, r = new DataView(e, io);+ let a = 0;+ for (; a < s; ) {+ const o = r.getUint32(a, !0);+ a += 4;+ const c = r.getUint32(a, !0);+ if (a += 4, c === BA.JSON) {+ const l = new Uint8Array(e, io + a, o);+ this.content = n.decode(l);+ } else if (c === BA.BIN) {+ const l = io + a;+ this.body = e.slice(l, l + o);+ }+ a += o;+ }+ if (this.content === null)+ throw new Error("THREE.GLTFLoader: JSON content not found.");+ }+}+class e1 {+ constructor(e, t) {+ if (!t)+ throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");+ this.name = ft.KHR_DRACO_MESH_COMPRESSION, this.json = e, this.dracoLoader = t, this.dracoLoader.preload();+ }+ decodePrimitive(e, t) {+ const n = this.json, s = this.dracoLoader, r = e.extensions[this.name].bufferView, a = e.extensions[this.name].attributes, o = {}, c = {}, l = {};+ for (const h in a) {+ const u = Cd[h] || h.toLowerCase();+ o[u] = a[h];+ }+ for (const h in e.attributes) {+ const u = Cd[h] || h.toLowerCase();+ if (a[h] !== void 0) {+ const d = n.accessors[e.attributes[h]], f = ga[d.componentType];+ l[u] = f.name, c[u] = d.normalized === !0;+ }+ }+ return t.getDependency("bufferView", r).then(function(h) {+ return new Promise(function(u, d) {+ s.decodeDracoFile(h, function(f) {+ for (const m in f.attributes) {+ const A = f.attributes[m], g = c[m];+ g !== void 0 && (A.normalized = g);+ }+ u(f);+ }, o, l, ln, d);+ });+ });+ }+}+class t1 {+ constructor() {+ this.name = ft.KHR_TEXTURE_TRANSFORM;+ }+ extendTexture(e, t) {+ return (t.texCoord === void 0 || t.texCoord === e.channel) && t.offset === void 0 && t.rotation === void 0 && t.scale === void 0 || (e = e.clone(), t.texCoord !== void 0 && (e.channel = t.texCoord), t.offset !== void 0 && e.offset.fromArray(t.offset), t.rotation !== void 0 && (e.rotation = t.rotation), t.scale !== void 0 && e.repeat.fromArray(t.scale), e.needsUpdate = !0), e;+ }+}+class n1 {+ constructor() {+ this.name = ft.KHR_MESH_QUANTIZATION;+ }+}+class F0 extends $o {+ constructor(e, t, n, s) {+ super(e, t, n, s);+ }+ copySampleValue_(e) {+ const t = this.resultBuffer, n = this.sampleValues, s = this.valueSize, r = e * s * 3 + s;+ for (let a = 0; a !== s; a++)+ t[a] = n[r + a];+ return t;+ }+ interpolate_(e, t, n, s) {+ const r = this.resultBuffer, a = this.sampleValues, o = this.valueSize, c = o * 2, l = o * 3, h = s - t, u = (n - t) / h, d = u * u, f = d * u, m = e * l, A = m - l, g = -2 * f + 3 * d, p = f - d, y = 1 - g, b = p - d + u;+ for (let E = 0; E !== o; E++) {+ const M = a[A + E + o], w = a[A + E + c] * h, S = a[m + E + o], T = a[m + E] * h;+ r[E] = y * M + b * w + g * S + p * T;+ }+ return r;+ }+}+const i1 = new Yn();+class s1 extends F0 {+ interpolate_(e, t, n, s) {+ const r = super.interpolate_(e, t, n, s);+ return i1.fromArray(r).normalize().toArray(r), r;+ }+}+const $n = {+ POINTS: 0,+ LINES: 1,+ LINE_LOOP: 2,+ LINE_STRIP: 3,+ TRIANGLES: 4,+ TRIANGLE_STRIP: 5,+ TRIANGLE_FAN: 6+}, ga = {+ 5120: Int8Array,+ 5121: Uint8Array,+ 5122: Int16Array,+ 5123: Uint16Array,+ 5125: Uint32Array,+ 5126: Float32Array+}, TA = {+ 9728: kn,+ 9729: qt,+ 9984: qm,+ 9985: ul,+ 9986: fo,+ 9987: si+}, RA = {+ 33071: _i,+ 33648: El,+ 10497: Ca+}, eu = {+ SCALAR: 1,+ VEC2: 2,+ VEC3: 3,+ VEC4: 4,+ MAT2: 4,+ MAT3: 9,+ MAT4: 16+}, Cd = {+ POSITION: "position",+ NORMAL: "normal",+ TANGENT: "tangent",+ TEXCOORD_0: "uv",+ TEXCOORD_1: "uv1",+ TEXCOORD_2: "uv2",+ TEXCOORD_3: "uv3",+ COLOR_0: "color",+ WEIGHTS_0: "skinWeight",+ JOINTS_0: "skinIndex"+}, vs = {+ scale: "scale",+ translation: "position",+ rotation: "quaternion",+ weights: "morphTargetInfluences"+}, r1 = {+ CUBICSPLINE: void 0,+ // We use a custom interpolant (GLTFCubicSplineInterpolation) for CUBICSPLINE tracks. Each+ // keyframe track will be initialized with a default interpolation type, then modified.+ LINEAR: ko,+ STEP: Po+}, tu = {+ OPAQUE: "OPAQUE",+ MASK: "MASK",+ BLEND: "BLEND"+};+function a1(i) {+ return i.DefaultMaterial === void 0 && (i.DefaultMaterial = new Oo({+ color: 16777215,+ emissive: 0,+ metalness: 1,+ roughness: 1,+ transparent: !1,+ depthTest: !0,+ side: us+ })), i.DefaultMaterial;+}+function er(i, e, t) {+ for (const n in t.extensions)+ i[n] === void 0 && (e.userData.gltfExtensions = e.userData.gltfExtensions || {}, e.userData.gltfExtensions[n] = t.extensions[n]);+}+function Yi(i, e) {+ e.extras !== void 0 && (typeof e.extras == "object" ? Object.assign(i.userData, e.extras) : console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, " + e.extras));+}+function o1(i, e, t) {+ let n = !1, s = !1, r = !1;+ for (let l = 0, h = e.length; l < h; l++) {+ const u = e[l];+ if (u.POSITION !== void 0 && (n = !0), u.NORMAL !== void 0 && (s = !0), u.COLOR_0 !== void 0 && (r = !0), n && s && r) break;+ }+ if (!n && !s && !r) return Promise.resolve(i);+ const a = [], o = [], c = [];+ for (let l = 0, h = e.length; l < h; l++) {+ const u = e[l];+ if (n) {+ const d = u.POSITION !== void 0 ? t.getDependency("accessor", u.POSITION) : i.attributes.position;+ a.push(d);+ }+ if (s) {+ const d = u.NORMAL !== void 0 ? t.getDependency("accessor", u.NORMAL) : i.attributes.normal;+ o.push(d);+ }+ if (r) {+ const d = u.COLOR_0 !== void 0 ? t.getDependency("accessor", u.COLOR_0) : i.attributes.color;+ c.push(d);+ }+ }+ return Promise.all([+ Promise.all(a),+ Promise.all(o),+ Promise.all(c)+ ]).then(function(l) {+ const h = l[0], u = l[1], d = l[2];+ return n && (i.morphAttributes.position = h), s && (i.morphAttributes.normal = u), r && (i.morphAttributes.color = d), i.morphTargetsRelative = !0, i;+ });+}+function c1(i, e) {+ if (i.updateMorphTargets(), e.weights !== void 0)+ for (let t = 0, n = e.weights.length; t < n; t++)+ i.morphTargetInfluences[t] = e.weights[t];+ if (e.extras && Array.isArray(e.extras.targetNames)) {+ const t = e.extras.targetNames;+ if (i.morphTargetInfluences.length === t.length) {+ i.morphTargetDictionary = {};+ for (let n = 0, s = t.length; n < s; n++)+ i.morphTargetDictionary[t[n]] = n;+ } else+ console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.");+ }+}+function l1(i) {+ let e;+ const t = i.extensions && i.extensions[ft.KHR_DRACO_MESH_COMPRESSION];+ if (t ? e = "draco:" + t.bufferView + ":" + t.indices + ":" + nu(t.attributes) : e = i.indices + ":" + nu(i.attributes) + ":" + i.mode, i.targets !== void 0)+ for (let n = 0, s = i.targets.length; n < s; n++)+ e += ":" + nu(i.targets[n]);+ return e;+}+function nu(i) {+ let e = "";+ const t = Object.keys(i).sort();+ for (let n = 0, s = t.length; n < s; n++)+ e += t[n] + ":" + i[t[n]] + ";";+ return e;+}+function Sd(i) {+ switch (i) {+ case Int8Array:+ return 1 / 127;+ case Uint8Array:+ return 1 / 255;+ case Int16Array:+ return 1 / 32767;+ case Uint16Array:+ return 1 / 65535;+ default:+ throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.");+ }+}+function h1(i) {+ return i.search(/\.jpe?g($|\?)/i) > 0 || i.search(/^data\:image\/jpeg/) === 0 ? "image/jpeg" : i.search(/\.webp($|\?)/i) > 0 || i.search(/^data\:image\/webp/) === 0 ? "image/webp" : i.search(/\.ktx2($|\?)/i) > 0 || i.search(/^data\:image\/ktx2/) === 0 ? "image/ktx2" : "image/png";+}+const u1 = new et();+class d1 {+ constructor(e = {}, t = {}) {+ this.json = e, this.extensions = {}, this.plugins = {}, this.options = t, this.cache = new DI(), this.associations = /* @__PURE__ */ new Map(), this.primitiveCache = {}, this.nodeCache = {}, this.meshCache = { refs: {}, uses: {} }, this.cameraCache = { refs: {}, uses: {} }, this.lightCache = { refs: {}, uses: {} }, this.sourceCache = {}, this.textureCache = {}, this.nodeNamesUsed = {};+ let n = !1, s = -1, r = !1, a = -1;+ if (typeof navigator < "u") {+ const o = navigator.userAgent;+ n = /^((?!chrome|android).)*safari/i.test(o) === !0;+ const c = o.match(/Version\/(\d+)/);+ s = n && c ? parseInt(c[1], 10) : -1, r = o.indexOf("Firefox") > -1, a = r ? o.match(/Firefox\/([0-9]+)\./)[1] : -1;+ }+ typeof createImageBitmap > "u" || n && s < 17 || r && a < 98 ? this.textureLoader = new My(this.options.manager) : this.textureLoader = new Ly(this.options.manager), this.textureLoader.setCrossOrigin(this.options.crossOrigin), this.textureLoader.setRequestHeader(this.options.requestHeader), this.fileLoader = new Ps(this.options.manager), this.fileLoader.setResponseType("arraybuffer"), this.options.crossOrigin === "use-credentials" && this.fileLoader.setWithCredentials(!0);+ }+ setExtensions(e) {+ this.extensions = e;+ }+ setPlugins(e) {+ this.plugins = e;+ }+ parse(e, t) {+ const n = this, s = this.json, r = this.extensions;+ this.cache.removeAll(), this.nodeCache = {}, this._invokeAll(function(a) {+ return a._markDefs && a._markDefs();+ }), Promise.all(this._invokeAll(function(a) {+ return a.beforeRoot && a.beforeRoot();+ })).then(function() {+ return Promise.all([+ n.getDependencies("scene"),+ n.getDependencies("animation"),+ n.getDependencies("camera")+ ]);+ }).then(function(a) {+ const o = {+ scene: a[0][s.scene || 0],+ scenes: a[0],+ animations: a[1],+ cameras: a[2],+ asset: s.asset,+ parser: n,+ userData: {}+ };+ return er(r, o, s), Yi(o, s), Promise.all(n._invokeAll(function(c) {+ return c.afterRoot && c.afterRoot(o);+ })).then(function() {+ for (const c of o.scenes)+ c.updateMatrixWorld();+ e(o);+ });+ }).catch(t);+ }+ /**+ * Marks the special nodes/meshes in json for efficient parse.+ *+ * @private+ */+ _markDefs() {+ const e = this.json.nodes || [], t = this.json.skins || [], n = this.json.meshes || [];+ for (let s = 0, r = t.length; s < r; s++) {+ const a = t[s].joints;+ for (let o = 0, c = a.length; o < c; o++)+ e[a[o]].isBone = !0;+ }+ for (let s = 0, r = e.length; s < r; s++) {+ const a = e[s];+ a.mesh !== void 0 && (this._addNodeRef(this.meshCache, a.mesh), a.skin !== void 0 && (n[a.mesh].isSkinnedMesh = !0)), a.camera !== void 0 && this._addNodeRef(this.cameraCache, a.camera);+ }+ }+ /**+ * Counts references to shared node / Object3D resources. These resources+ * can be reused, or "instantiated", at multiple nodes in the scene+ * hierarchy. Mesh, Camera, and Light instances are instantiated and must+ * be marked. Non-scenegraph resources (like Materials, Geometries, and+ * Textures) can be reused directly and are not marked here.+ *+ * Example: CesiumMilkTruck sample model reuses "Wheel" meshes.+ *+ * @private+ * @param {Object} cache+ * @param {Object3D} index+ */+ _addNodeRef(e, t) {+ t !== void 0 && (e.refs[t] === void 0 && (e.refs[t] = e.uses[t] = 0), e.refs[t]++);+ }+ /**+ * Returns a reference to a shared resource, cloning it if necessary.+ *+ * @private+ * @param {Object} cache+ * @param {number} index+ * @param {Object} object+ * @return {Object}+ */+ _getNodeRef(e, t, n) {+ if (e.refs[t] <= 1) return n;+ const s = n.clone(), r = (a, o) => {+ const c = this.associations.get(a);+ c != null && this.associations.set(o, c);+ for (const [l, h] of a.children.entries())+ r(h, o.children[l]);+ };+ return r(n, s), s.name += "_instance_" + e.uses[t]++, s;+ }+ _invokeOne(e) {+ const t = Object.values(this.plugins);+ t.push(this);+ for (let n = 0; n < t.length; n++) {+ const s = e(t[n]);+ if (s) return s;+ }+ return null;+ }+ _invokeAll(e) {+ const t = Object.values(this.plugins);+ t.unshift(this);+ const n = [];+ for (let s = 0; s < t.length; s++) {+ const r = e(t[s]);+ r && n.push(r);+ }+ return n;+ }+ /**+ * Requests the specified dependency asynchronously, with caching.+ *+ * @private+ * @param {string} type+ * @param {number} index+ * @return {Promise<Object3D|Material|THREE.Texture|AnimationClip|ArrayBuffer|Object>}+ */+ getDependency(e, t) {+ const n = e + ":" + t;+ let s = this.cache.get(n);+ if (!s) {+ switch (e) {+ case "scene":+ s = this.loadScene(t);+ break;+ case "node":+ s = this._invokeOne(function(r) {+ return r.loadNode && r.loadNode(t);+ });+ break;+ case "mesh":+ s = this._invokeOne(function(r) {+ return r.loadMesh && r.loadMesh(t);+ });+ break;+ case "accessor":+ s = this.loadAccessor(t);+ break;+ case "bufferView":+ s = this._invokeOne(function(r) {+ return r.loadBufferView && r.loadBufferView(t);+ });+ break;+ case "buffer":+ s = this.loadBuffer(t);+ break;+ case "material":+ s = this._invokeOne(function(r) {+ return r.loadMaterial && r.loadMaterial(t);+ });+ break;+ case "texture":+ s = this._invokeOne(function(r) {+ return r.loadTexture && r.loadTexture(t);+ });+ break;+ case "skin":+ s = this.loadSkin(t);+ break;+ case "animation":+ s = this._invokeOne(function(r) {+ return r.loadAnimation && r.loadAnimation(t);+ });+ break;+ case "camera":+ s = this.loadCamera(t);+ break;+ default:+ if (s = this._invokeOne(function(r) {+ return r != this && r.getDependency && r.getDependency(e, t);+ }), !s)+ throw new Error("Unknown type: " + e);+ break;+ }+ this.cache.add(n, s);+ }+ return s;+ }+ /**+ * Requests all dependencies of the specified type asynchronously, with caching.+ *+ * @private+ * @param {string} type+ * @return {Promise<Array<Object>>}+ */+ getDependencies(e) {+ let t = this.cache.get(e);+ if (!t) {+ const n = this, s = this.json[e + (e === "mesh" ? "es" : "s")] || [];+ t = Promise.all(s.map(function(r, a) {+ return n.getDependency(e, a);+ })), this.cache.add(e, t);+ }+ return t;+ }+ /**+ * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views+ *+ * @private+ * @param {number} bufferIndex+ * @return {Promise<ArrayBuffer>}+ */+ loadBuffer(e) {+ const t = this.json.buffers[e], n = this.fileLoader;+ if (t.type && t.type !== "arraybuffer")+ throw new Error("THREE.GLTFLoader: " + t.type + " buffer type is not supported.");+ if (t.uri === void 0 && e === 0)+ return Promise.resolve(this.extensions[ft.KHR_BINARY_GLTF].body);+ const s = this.options;+ return new Promise(function(r, a) {+ n.load(Aa.resolveURL(t.uri, s.path), r, void 0, function() {+ a(new Error('THREE.GLTFLoader: Failed to load buffer "' + t.uri + '".'));+ });+ });+ }+ /**+ * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views+ *+ * @private+ * @param {number} bufferViewIndex+ * @return {Promise<ArrayBuffer>}+ */+ loadBufferView(e) {+ const t = this.json.bufferViews[e];+ return this.getDependency("buffer", t.buffer).then(function(n) {+ const s = t.byteLength || 0, r = t.byteOffset || 0;+ return n.slice(r, r + s);+ });+ }+ /**+ * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#accessors+ *+ * @private+ * @param {number} accessorIndex+ * @return {Promise<BufferAttribute|InterleavedBufferAttribute>}+ */+ loadAccessor(e) {+ const t = this, n = this.json, s = this.json.accessors[e];+ if (s.bufferView === void 0 && s.sparse === void 0) {+ const a = eu[s.type], o = ga[s.componentType], c = s.normalized === !0, l = new o(s.count * a);+ return Promise.resolve(new En(l, a, c));+ }+ const r = [];+ return s.bufferView !== void 0 ? r.push(this.getDependency("bufferView", s.bufferView)) : r.push(null), s.sparse !== void 0 && (r.push(this.getDependency("bufferView", s.sparse.indices.bufferView)), r.push(this.getDependency("bufferView", s.sparse.values.bufferView))), Promise.all(r).then(function(a) {+ const o = a[0], c = eu[s.type], l = ga[s.componentType], h = l.BYTES_PER_ELEMENT, u = h * c, d = s.byteOffset || 0, f = s.bufferView !== void 0 ? n.bufferViews[s.bufferView].byteStride : void 0, m = s.normalized === !0;+ let A, g;+ if (f && f !== u) {+ const p = Math.floor(d / f), y = "InterleavedBuffer:" + s.bufferView + ":" + s.componentType + ":" + p + ":" + s.count;+ let b = t.cache.get(y);+ b || (A = new l(o, p * f, s.count * f / h), b = new sy(A, f / h), t.cache.add(y, b)), g = new yf(b, c, d % f / h, m);+ } else+ o === null ? A = new l(s.count * c) : A = new l(o, d, s.count * c), g = new En(A, c, m);+ if (s.sparse !== void 0) {+ const p = eu.SCALAR, y = ga[s.sparse.indices.componentType], b = s.sparse.indices.byteOffset || 0, E = s.sparse.values.byteOffset || 0, M = new y(a[1], b, s.sparse.count * p), w = new l(a[2], E, s.sparse.count * c);+ o !== null && (g = new En(g.array.slice(), g.itemSize, g.normalized)), g.normalized = !1;+ for (let S = 0, T = M.length; S < T; S++) {+ const C = M[S];+ if (g.setX(C, w[S * c]), c >= 2 && g.setY(C, w[S * c + 1]), c >= 3 && g.setZ(C, w[S * c + 2]), c >= 4 && g.setW(C, w[S * c + 3]), c >= 5) throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.");+ }+ g.normalized = m;+ }+ return g;+ });+ }+ /**+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#textures+ *+ * @private+ * @param {number} textureIndex+ * @return {Promise<THREE.Texture|null>}+ */+ loadTexture(e) {+ const t = this.json, n = this.options, r = t.textures[e].source, a = t.images[r];+ let o = this.textureLoader;+ if (a.uri) {+ const c = n.manager.getHandler(a.uri);+ c !== null && (o = c);+ }+ return this.loadTextureImage(e, r, o);+ }+ loadTextureImage(e, t, n) {+ const s = this, r = this.json, a = r.textures[e], o = r.images[t], c = (o.uri || o.bufferView) + ":" + a.sampler;+ if (this.textureCache[c])+ return this.textureCache[c];+ const l = this.loadImageSource(t, n).then(function(h) {+ h.flipY = !1, h.name = a.name || o.name || "", h.name === "" && typeof o.uri == "string" && o.uri.startsWith("data:image/") === !1 && (h.name = o.uri);+ const d = (r.samplers || {})[a.sampler] || {};+ return h.magFilter = TA[d.magFilter] || qt, h.minFilter = TA[d.minFilter] || si, h.wrapS = RA[d.wrapS] || Ca, h.wrapT = RA[d.wrapT] || Ca, h.generateMipmaps = !h.isCompressedTexture && h.minFilter !== kn && h.minFilter !== qt, s.associations.set(h, { textures: e }), h;+ }).catch(function() {+ return null;+ });+ return this.textureCache[c] = l, l;+ }+ loadImageSource(e, t) {+ const n = this, s = this.json, r = this.options;+ if (this.sourceCache[e] !== void 0)+ return this.sourceCache[e].then((u) => u.clone());+ const a = s.images[e], o = self.URL || self.webkitURL;+ let c = a.uri || "", l = !1;+ if (a.bufferView !== void 0)+ c = n.getDependency("bufferView", a.bufferView).then(function(u) {+ l = !0;+ const d = new Blob([u], { type: a.mimeType });+ return c = o.createObjectURL(d), c;+ });+ else if (a.uri === void 0)+ throw new Error("THREE.GLTFLoader: Image " + e + " is missing URI and bufferView");+ const h = Promise.resolve(c).then(function(u) {+ return new Promise(function(d, f) {+ let m = d;+ t.isImageBitmapLoader === !0 && (m = function(A) {+ const g = new cn(A);+ g.needsUpdate = !0, d(g);+ }), t.load(Aa.resolveURL(u, r.path), m, void 0, f);+ });+ }).then(function(u) {+ return l === !0 && o.revokeObjectURL(c), Yi(u, a), u.userData.mimeType = a.mimeType || h1(a.uri), u;+ }).catch(function(u) {+ throw console.error("THREE.GLTFLoader: Couldn't load texture", c), u;+ });+ return this.sourceCache[e] = h, h;+ }+ /**+ * Asynchronously assigns a texture to the given material parameters.+ *+ * @private+ * @param {Object} materialParams+ * @param {string} mapName+ * @param {Object} mapDef+ * @param {string} [colorSpace]+ * @return {Promise<Texture>}+ */+ assignTexture(e, t, n, s) {+ const r = this;+ return this.getDependency("texture", n.index).then(function(a) {+ if (!a) return null;+ if (n.texCoord !== void 0 && n.texCoord > 0 && (a = a.clone(), a.channel = n.texCoord), r.extensions[ft.KHR_TEXTURE_TRANSFORM]) {+ const o = n.extensions !== void 0 ? n.extensions[ft.KHR_TEXTURE_TRANSFORM] : void 0;+ if (o) {+ const c = r.associations.get(a);+ a = r.extensions[ft.KHR_TEXTURE_TRANSFORM].extendTexture(a, o), r.associations.set(a, c);+ }+ }+ return s !== void 0 && (a.colorSpace = s), e[t] = a, a;+ });+ }+ /**+ * Assigns final material to a Mesh, Line, or Points instance. The instance+ * already has a material (generated from the glTF material options alone)+ * but reuse of the same glTF material may require multiple threejs materials+ * to accommodate different primitive types, defines, etc. New materials will+ * be created if necessary, and reused from a cache.+ *+ * @private+ * @param {Object3D} mesh Mesh, Line, or Points instance.+ */+ assignFinalMaterial(e) {+ const t = e.geometry;+ let n = e.material;+ const s = t.attributes.tangent === void 0, r = t.attributes.color !== void 0, a = t.attributes.normal === void 0;+ if (e.isPoints) {+ const o = "PointsMaterial:" + n.uuid;+ let c = this.cache.get(o);+ c || (c = new Sf(), Li.prototype.copy.call(c, n), c.color.copy(n.color), c.map = n.map, c.sizeAttenuation = !1, this.cache.add(o, c)), n = c;+ } else if (e.isLine) {+ const o = "LineBasicMaterial:" + n.uuid;+ let c = this.cache.get(o);+ c || (c = new Zo(), Li.prototype.copy.call(c, n), c.color.copy(n.color), c.map = n.map, this.cache.add(o, c)), n = c;+ }+ if (s || r || a) {+ let o = "ClonedMaterial:" + n.uuid + ":";+ s && (o += "derivative-tangents:"), r && (o += "vertex-colors:"), a && (o += "flat-shading:");+ let c = this.cache.get(o);+ c || (c = n.clone(), r && (c.vertexColors = !0), a && (c.flatShading = !0), s && (c.normalScale && (c.normalScale.y *= -1), c.clearcoatNormalScale && (c.clearcoatNormalScale.y *= -1)), this.cache.add(o, c), this.associations.set(c, this.associations.get(n))), n = c;+ }+ e.material = n;+ }+ getMaterialType() {+ return Oo;+ }+ /**+ * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#materials+ *+ * @private+ * @param {number} materialIndex+ * @return {Promise<Material>}+ */+ loadMaterial(e) {+ const t = this, n = this.json, s = this.extensions, r = n.materials[e];+ let a;+ const o = {}, c = r.extensions || {}, l = [];+ if (c[ft.KHR_MATERIALS_UNLIT]) {+ const u = s[ft.KHR_MATERIALS_UNLIT];+ a = u.getMaterialType(), l.push(u.extendParams(o, r, t));+ } else {+ const u = r.pbrMetallicRoughness || {};+ if (o.color = new je(1, 1, 1), o.opacity = 1, Array.isArray(u.baseColorFactor)) {+ const d = u.baseColorFactor;+ o.color.setRGB(d[0], d[1], d[2], ln), o.opacity = d[3];+ }+ u.baseColorTexture !== void 0 && l.push(t.assignTexture(o, "map", u.baseColorTexture, Kt)), o.metalness = u.metallicFactor !== void 0 ? u.metallicFactor : 1, o.roughness = u.roughnessFactor !== void 0 ? u.roughnessFactor : 1, u.metallicRoughnessTexture !== void 0 && (l.push(t.assignTexture(o, "metalnessMap", u.metallicRoughnessTexture)), l.push(t.assignTexture(o, "roughnessMap", u.metallicRoughnessTexture))), a = this._invokeOne(function(d) {+ return d.getMaterialType && d.getMaterialType(e);+ }), l.push(Promise.all(this._invokeAll(function(d) {+ return d.extendMaterialParams && d.extendMaterialParams(e, o);+ })));+ }+ r.doubleSided === !0 && (o.side = Ni);+ const h = r.alphaMode || tu.OPAQUE;+ if (h === tu.BLEND ? (o.transparent = !0, o.depthWrite = !1) : (o.transparent = !1, h === tu.MASK && (o.alphaTest = r.alphaCutoff !== void 0 ? r.alphaCutoff : 0.5)), r.normalTexture !== void 0 && a !== Ns && (l.push(t.assignTexture(o, "normalMap", r.normalTexture)), o.normalScale = new Ze(1, 1), r.normalTexture.scale !== void 0)) {+ const u = r.normalTexture.scale;+ o.normalScale.set(u, u);+ }+ if (r.occlusionTexture !== void 0 && a !== Ns && (l.push(t.assignTexture(o, "aoMap", r.occlusionTexture)), r.occlusionTexture.strength !== void 0 && (o.aoMapIntensity = r.occlusionTexture.strength)), r.emissiveFactor !== void 0 && a !== Ns) {+ const u = r.emissiveFactor;+ o.emissive = new je().setRGB(u[0], u[1], u[2], ln);+ }+ return r.emissiveTexture !== void 0 && a !== Ns && l.push(t.assignTexture(o, "emissiveMap", r.emissiveTexture, Kt)), Promise.all(l).then(function() {+ const u = new a(o);+ return r.name && (u.name = r.name), Yi(u, r), t.associations.set(u, { materials: e }), r.extensions && er(s, u, r), u;+ });+ }+ /**+ * When Object3D instances are targeted by animation, they need unique names.+ *+ * @private+ * @param {string} originalName+ * @return {string}+ */+ createUniqueName(e) {+ const t = Ct.sanitizeNodeName(e || "");+ return t in this.nodeNamesUsed ? t + "_" + ++this.nodeNamesUsed[t] : (this.nodeNamesUsed[t] = 0, t);+ }+ /**+ * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#geometry+ *+ * Creates BufferGeometries from primitives.+ *+ * @private+ * @param {Array<GLTF.Primitive>} primitives+ * @return {Promise<Array<BufferGeometry>>}+ */+ loadGeometries(e) {+ const t = this, n = this.extensions, s = this.primitiveCache;+ function r(o) {+ return n[ft.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o, t).then(function(c) {+ return NA(c, o, t);+ });+ }+ const a = [];+ for (let o = 0, c = e.length; o < c; o++) {+ const l = e[o], h = l1(l), u = s[h];+ if (u)+ a.push(u.promise);+ else {+ let d;+ l.extensions && l.extensions[ft.KHR_DRACO_MESH_COMPRESSION] ? d = r(l) : d = NA(new zn(), l, t), s[h] = { primitive: l, promise: d }, a.push(d);+ }+ }+ return Promise.all(a);+ }+ /**+ * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#meshes+ *+ * @private+ * @param {number} meshIndex+ * @return {Promise<Group|Mesh|SkinnedMesh|Line|Points>}+ */+ loadMesh(e) {+ const t = this, n = this.json, s = this.extensions, r = n.meshes[e], a = r.primitives, o = [];+ for (let c = 0, l = a.length; c < l; c++) {+ const h = a[c].material === void 0 ? a1(this.cache) : this.getDependency("material", a[c].material);+ o.push(h);+ }+ return o.push(t.loadGeometries(a)), Promise.all(o).then(function(c) {+ const l = c.slice(0, c.length - 1), h = c[c.length - 1], u = [];+ for (let f = 0, m = h.length; f < m; f++) {+ const A = h[f], g = a[f];+ let p;+ const y = l[f];+ if (g.mode === $n.TRIANGLES || g.mode === $n.TRIANGLE_STRIP || g.mode === $n.TRIANGLE_FAN || g.mode === void 0)+ p = r.isSkinnedMesh === !0 ? new ay(A, y) : new Jt(A, y), p.isSkinnedMesh === !0 && p.normalizeSkinWeights(), g.mode === $n.TRIANGLE_STRIP ? p.geometry = MA(p.geometry, t0) : g.mode === $n.TRIANGLE_FAN && (p.geometry = MA(p.geometry, bd));+ else if (g.mode === $n.LINES)+ p = new Yl(A, y);+ else if (g.mode === $n.LINE_STRIP)+ p = new Cf(A, y);+ else if (g.mode === $n.LINE_LOOP)+ p = new uy(A, y);+ else if (g.mode === $n.POINTS)+ p = new dy(A, y);+ else+ throw new Error("THREE.GLTFLoader: Primitive mode unsupported: " + g.mode);+ Object.keys(p.geometry.morphAttributes).length > 0 && c1(p, r), p.name = t.createUniqueName(r.name || "mesh_" + e), Yi(p, r), g.extensions && er(s, p, g), t.assignFinalMaterial(p), u.push(p);+ }+ for (let f = 0, m = u.length; f < m; f++)+ t.associations.set(u[f], {+ meshes: e,+ primitives: f+ });+ if (u.length === 1)+ return r.extensions && er(s, u[0], r), u[0];+ const d = new fr();+ r.extensions && er(s, d, r), t.associations.set(d, { meshes: e });+ for (let f = 0, m = u.length; f < m; f++)+ d.add(u[f]);+ return d;+ });+ }+ /**+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#cameras+ *+ * @private+ * @param {number} cameraIndex+ * @return {Promise<THREE.Camera>}+ */+ loadCamera(e) {+ let t;+ const n = this.json.cameras[e], s = n[n.type];+ if (!s) {+ console.warn("THREE.GLTFLoader: Missing camera parameters.");+ return;+ }+ return n.type === "perspective" ? t = new vn(s0.radToDeg(s.yfov), s.aspectRatio || 1, s.znear || 1, s.zfar || 2e6) : n.type === "orthographic" && (t = new Mf(-s.xmag, s.xmag, s.ymag, -s.ymag, s.znear, s.zfar)), n.name && (t.name = this.createUniqueName(n.name)), Yi(t, n), Promise.resolve(t);+ }+ /**+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins+ *+ * @private+ * @param {number} skinIndex+ * @return {Promise<Skeleton>}+ */+ loadSkin(e) {+ const t = this.json.skins[e], n = [];+ for (let s = 0, r = t.joints.length; s < r; s++)+ n.push(this._loadNodeShallow(t.joints[s]));+ return t.inverseBindMatrices !== void 0 ? n.push(this.getDependency("accessor", t.inverseBindMatrices)) : n.push(null), Promise.all(n).then(function(s) {+ const r = s.pop(), a = s, o = [], c = [];+ for (let l = 0, h = a.length; l < h; l++) {+ const u = a[l];+ if (u) {+ o.push(u);+ const d = new et();+ r !== null && d.fromArray(r.array, l * 16), c.push(d);+ } else+ console.warn('THREE.GLTFLoader: Joint "%s" could not be found.', t.joints[l]);+ }+ return new wf(o, c);+ });+ }+ /**+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#animations+ *+ * @private+ * @param {number} animationIndex+ * @return {Promise<AnimationClip>}+ */+ loadAnimation(e) {+ const t = this.json, n = this, s = t.animations[e], r = s.name ? s.name : "animation_" + e, a = [], o = [], c = [], l = [], h = [];+ for (let u = 0, d = s.channels.length; u < d; u++) {+ const f = s.channels[u], m = s.samplers[f.sampler], A = f.target, g = A.node, p = s.parameters !== void 0 ? s.parameters[m.input] : m.input, y = s.parameters !== void 0 ? s.parameters[m.output] : m.output;+ A.node !== void 0 && (a.push(this.getDependency("node", g)), o.push(this.getDependency("accessor", p)), c.push(this.getDependency("accessor", y)), l.push(m), h.push(A));+ }+ return Promise.all([+ Promise.all(a),+ Promise.all(o),+ Promise.all(c),+ Promise.all(l),+ Promise.all(h)+ ]).then(function(u) {+ const d = u[0], f = u[1], m = u[2], A = u[3], g = u[4], p = [];+ for (let y = 0, b = d.length; y < b; y++) {+ const E = d[y], M = f[y], w = m[y], S = A[y], T = g[y];+ if (E === void 0) continue;+ E.updateMatrix && E.updateMatrix();+ const C = n._createAnimationTracks(E, M, w, S, T);+ if (C)+ for (let v = 0; v < C.length; v++)+ p.push(C[v]);+ }+ return new Fl(r, void 0, p);+ });+ }+ createNodeMesh(e) {+ const t = this.json, n = this, s = t.nodes[e];+ return s.mesh === void 0 ? null : n.getDependency("mesh", s.mesh).then(function(r) {+ const a = n._getNodeRef(n.meshCache, s.mesh, r);+ return s.weights !== void 0 && a.traverse(function(o) {+ if (o.isMesh)+ for (let c = 0, l = s.weights.length; c < l; c++)+ o.morphTargetInfluences[c] = s.weights[c];+ }), a;+ });+ }+ /**+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#nodes-and-hierarchy+ *+ * @private+ * @param {number} nodeIndex+ * @return {Promise<Object3D>}+ */+ loadNode(e) {+ const t = this.json, n = this, s = t.nodes[e], r = n._loadNodeShallow(e), a = [], o = s.children || [];+ for (let l = 0, h = o.length; l < h; l++)+ a.push(n.getDependency("node", o[l]));+ const c = s.skin === void 0 ? Promise.resolve(null) : n.getDependency("skin", s.skin);+ return Promise.all([+ r,+ Promise.all(a),+ c+ ]).then(function(l) {+ const h = l[0], u = l[1], d = l[2];+ d !== null && h.traverse(function(f) {+ f.isSkinnedMesh && f.bind(d, u1);+ });+ for (let f = 0, m = u.length; f < m; f++)+ h.add(u[f]);+ return h;+ });+ }+ // ._loadNodeShallow() parses a single node.+ // skin and child nodes are created and added in .loadNode() (no '_' prefix).+ _loadNodeShallow(e) {+ const t = this.json, n = this.extensions, s = this;+ if (this.nodeCache[e] !== void 0)+ return this.nodeCache[e];+ const r = t.nodes[e], a = r.name ? s.createUniqueName(r.name) : "", o = [], c = s._invokeOne(function(l) {+ return l.createNodeMesh && l.createNodeMesh(e);+ });+ return c && o.push(c), r.camera !== void 0 && o.push(s.getDependency("camera", r.camera).then(function(l) {+ return s._getNodeRef(s.cameraCache, r.camera, l);+ })), s._invokeAll(function(l) {+ return l.createNodeAttachment && l.createNodeAttachment(e);+ }).forEach(function(l) {+ o.push(l);+ }), this.nodeCache[e] = Promise.all(o).then(function(l) {+ let h;+ if (r.isBone === !0 ? h = new A0() : l.length > 1 ? h = new fr() : l.length === 1 ? h = l[0] : h = new kt(), h !== l[0])+ for (let u = 0, d = l.length; u < d; u++)+ h.add(l[u]);+ if (r.name && (h.userData.name = r.name, h.name = a), Yi(h, r), r.extensions && er(n, h, r), r.matrix !== void 0) {+ const u = new et();+ u.fromArray(r.matrix), h.applyMatrix4(u);+ } else+ r.translation !== void 0 && h.position.fromArray(r.translation), r.rotation !== void 0 && h.quaternion.fromArray(r.rotation), r.scale !== void 0 && h.scale.fromArray(r.scale);+ return s.associations.has(h) || s.associations.set(h, {}), s.associations.get(h).nodes = e, h;+ }), this.nodeCache[e];+ }+ /**+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#scenes+ *+ * @private+ * @param {number} sceneIndex+ * @return {Promise<Group>}+ */+ loadScene(e) {+ const t = this.extensions, n = this.json.scenes[e], s = this, r = new fr();+ n.name && (r.name = s.createUniqueName(n.name)), Yi(r, n), n.extensions && er(t, r, n);+ const a = n.nodes || [], o = [];+ for (let c = 0, l = a.length; c < l; c++)+ o.push(s.getDependency("node", a[c]));+ return Promise.all(o).then(function(c) {+ for (let h = 0, u = c.length; h < u; h++)+ r.add(c[h]);+ const l = (h) => {+ const u = /* @__PURE__ */ new Map();+ for (const [d, f] of s.associations)+ (d instanceof Li || d instanceof cn) && u.set(d, f);+ return h.traverse((d) => {+ const f = s.associations.get(d);+ f != null && u.set(d, f);+ }), u;+ };+ return s.associations = l(r), r;+ });+ }+ _createAnimationTracks(e, t, n, s, r) {+ const a = [], o = e.name ? e.name : e.uuid, c = [];+ vs[r.path] === vs.weights ? e.traverse(function(d) {+ d.morphTargetInfluences && c.push(d.name ? d.name : d.uuid);+ }) : c.push(o);+ let l;+ switch (vs[r.path]) {+ case vs.weights:+ l = Ma;+ break;+ case vs.rotation:+ l = Ba;+ break;+ case vs.translation:+ case vs.scale:+ l = Ta;+ break;+ default:+ n.itemSize === 1 ? l = Ma : l = Ta;+ break;+ }+ const h = s.interpolation !== void 0 ? r1[s.interpolation] : ko, u = this._getArrayFromAccessor(n);+ for (let d = 0, f = c.length; d < f; d++) {+ const m = new l(+ c[d] + "." + vs[r.path],+ t.array,+ u,+ h+ );+ s.interpolation === "CUBICSPLINE" && this._createCubicSplineTrackInterpolant(m), a.push(m);+ }+ return a;+ }+ _getArrayFromAccessor(e) {+ let t = e.array;+ if (e.normalized) {+ const n = Sd(t.constructor), s = new Float32Array(t.length);+ for (let r = 0, a = t.length; r < a; r++)+ s[r] = t[r] * n;+ t = s;+ }+ return t;+ }+ _createCubicSplineTrackInterpolant(e) {+ e.createInterpolant = function(n) {+ const s = this instanceof Ba ? s1 : F0;+ return new s(this.times, this.values, this.getValueSize() / 3, n);+ }, e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline = !0;+ }+}+function f1(i, e, t) {+ const n = e.attributes, s = new yi();+ if (n.POSITION !== void 0) {+ const o = t.json.accessors[n.POSITION], c = o.min, l = o.max;+ if (c !== void 0 && l !== void 0) {+ if (s.set(+ new H(c[0], c[1], c[2]),+ new H(l[0], l[1], l[2])+ ), o.normalized) {+ const h = Sd(ga[o.componentType]);+ s.min.multiplyScalar(h), s.max.multiplyScalar(h);+ }+ } else {+ console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");+ return;+ }+ } else+ return;+ const r = e.targets;+ if (r !== void 0) {+ const o = new H(), c = new H();+ for (let l = 0, h = r.length; l < h; l++) {+ const u = r[l];+ if (u.POSITION !== void 0) {+ const d = t.json.accessors[u.POSITION], f = d.min, m = d.max;+ if (f !== void 0 && m !== void 0) {+ if (c.setX(Math.max(Math.abs(f[0]), Math.abs(m[0]))), c.setY(Math.max(Math.abs(f[1]), Math.abs(m[1]))), c.setZ(Math.max(Math.abs(f[2]), Math.abs(m[2]))), d.normalized) {+ const A = Sd(ga[d.componentType]);+ c.multiplyScalar(A);+ }+ o.max(c);+ } else+ console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");+ }+ }+ s.expandByVector(o);+ }+ i.boundingBox = s;+ const a = new Ui();+ s.getCenter(a.center), a.radius = s.min.distanceTo(s.max) / 2, i.boundingSphere = a;+}+function NA(i, e, t) {+ const n = e.attributes, s = [];+ function r(a, o) {+ return t.getDependency("accessor", a).then(function(c) {+ i.setAttribute(o, c);+ });+ }+ for (const a in n) {+ const o = Cd[a] || a.toLowerCase();+ o in i.attributes || s.push(r(n[a], o));+ }+ if (e.indices !== void 0 && !i.index) {+ const a = t.getDependency("accessor", e.indices).then(function(o) {+ i.setIndex(o);+ });+ s.push(a);+ }+ return mt.workingColorSpace !== ln && "COLOR_0" in n && console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${mt.workingColorSpace}" not supported.`), Yi(i, e), f1(i, e, t), Promise.all(s).then(function() {+ return e.targets !== void 0 ? o1(i, e.targets, t) : i;+ });+}+const FA = { type: "change" }, Nf = { type: "start" }, D0 = { type: "end" }, Gc = new Jo(), DA = new Rs(), p1 = Math.cos(70 * s0.DEG2RAD), nn = new H(), On = 2 * Math.PI, Bt = {+ NONE: -1,+ ROTATE: 0,+ DOLLY: 1,+ PAN: 2,+ TOUCH_ROTATE: 3,+ TOUCH_PAN: 4,+ TOUCH_DOLLY_PAN: 5,+ TOUCH_DOLLY_ROTATE: 6+}, iu = 1e-6;+class A1 extends Jy {+ /**+ * Constructs a new controls instance.+ *+ * @param {Object3D} object - The object that is managed by the controls.+ * @param {?HTMLDOMElement} domElement - The HTML element used for event listeners.+ */+ constructor(e, t = null) {+ super(e, t), this.state = Bt.NONE, this.target = new H(), this.cursor = new H(), 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 = 0.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: da.ROTATE, MIDDLE: da.DOLLY, RIGHT: da.PAN }, this.touches = { ONE: sa.ROTATE, TWO: sa.DOLLY_PAN }, this.target0 = this.target.clone(), this.position0 = this.object.position.clone(), this.zoom0 = this.object.zoom, this._domElementKeyEvents = null, this._lastPosition = new H(), this._lastQuaternion = new Yn(), this._lastTargetPosition = new H(), this._quat = new Yn().setFromUnitVectors(e.up, new H(0, 1, 0)), this._quatInverse = this._quat.clone().invert(), this._spherical = new tA(), this._sphericalDelta = new tA(), this._scale = 1, this._panOffset = new H(), this._rotateStart = new Ze(), this._rotateEnd = new Ze(), this._rotateDelta = new Ze(), this._panStart = new Ze(), this._panEnd = new Ze(), this._panDelta = new Ze(), this._dollyStart = new Ze(), this._dollyEnd = new Ze(), this._dollyDelta = new Ze(), this._dollyDirection = new H(), this._mouse = new Ze(), this._performCursorZoom = !1, this._pointers = [], this._pointerPositions = {}, this._controlActive = !1, this._onPointerMove = m1.bind(this), this._onPointerDown = g1.bind(this), this._onPointerUp = b1.bind(this), this._onContextMenu = C1.bind(this), this._onMouseWheel = E1.bind(this), this._onKeyDown = y1.bind(this), this._onTouchStart = w1.bind(this), this._onTouchMove = v1.bind(this), this._onMouseDown = x1.bind(this), this._onMouseMove = _1.bind(this), this._interceptControlDown = S1.bind(this), this._interceptControlUp = I1.bind(this), this.domElement !== null && this.connect(this.domElement), this.update();+ }+ connect(e) {+ super.connect(e), this.domElement.addEventListener("pointerdown", this._onPointerDown), this.domElement.addEventListener("pointercancel", this._onPointerUp), this.domElement.addEventListener("contextmenu", this._onContextMenu), this.domElement.addEventListener("wheel", this._onMouseWheel, { passive: !1 }), this.domElement.getRootNode().addEventListener("keydown", this._interceptControlDown, { passive: !0, capture: !0 }), this.domElement.style.touchAction = "none";+ }+ disconnect() {+ this.domElement.removeEventListener("pointerdown", this._onPointerDown), this.domElement.removeEventListener("pointermove", this._onPointerMove), this.domElement.removeEventListener("pointerup", this._onPointerUp), this.domElement.removeEventListener("pointercancel", this._onPointerUp), this.domElement.removeEventListener("wheel", this._onMouseWheel), this.domElement.removeEventListener("contextmenu", this._onContextMenu), this.stopListenToKeyEvents(), this.domElement.getRootNode().removeEventListener("keydown", this._interceptControlDown, { capture: !0 }), this.domElement.style.touchAction = "auto";+ }+ dispose() {+ this.disconnect();+ }+ /**+ * Get the current vertical rotation, in radians.+ *+ * @return {number} The current vertical rotation, in radians.+ */+ getPolarAngle() {+ return this._spherical.phi;+ }+ /**+ * Get the current horizontal rotation, in radians.+ *+ * @return {number} The current horizontal rotation, in radians.+ */+ getAzimuthalAngle() {+ return this._spherical.theta;+ }+ /**+ * Returns the distance from the camera to the target.+ *+ * @return {number} The distance from the camera to the target.+ */+ getDistance() {+ return this.object.position.distanceTo(this.target);+ }+ /**+ * Adds key event listeners to the given DOM element.+ * `window` is a recommended argument for using this method.+ *+ * @param {HTMLDOMElement} domElement - The DOM element+ */+ listenToKeyEvents(e) {+ e.addEventListener("keydown", this._onKeyDown), this._domElementKeyEvents = e;+ }+ /**+ * Removes the key event listener previously defined with `listenToKeyEvents()`.+ */+ stopListenToKeyEvents() {+ this._domElementKeyEvents !== null && (this._domElementKeyEvents.removeEventListener("keydown", this._onKeyDown), this._domElementKeyEvents = null);+ }+ /**+ * Save the current state of the controls. This can later be recovered with `reset()`.+ */+ saveState() {+ this.target0.copy(this.target), this.position0.copy(this.object.position), this.zoom0 = this.object.zoom;+ }+ /**+ * Reset the controls to their state from either the last time the `saveState()`+ * was called, or the initial state.+ */+ reset() {+ this.target.copy(this.target0), this.object.position.copy(this.position0), this.object.zoom = this.zoom0, this.object.updateProjectionMatrix(), this.dispatchEvent(FA), this.update(), this.state = Bt.NONE;+ }+ update(e = null) {+ const t = this.object.position;+ nn.copy(t).sub(this.target), nn.applyQuaternion(this._quat), this._spherical.setFromVector3(nn), this.autoRotate && this.state === Bt.NONE && this._rotateLeft(this._getAutoRotationAngle(e)), this.enableDamping ? (this._spherical.theta += this._sphericalDelta.theta * this.dampingFactor, this._spherical.phi += this._sphericalDelta.phi * this.dampingFactor) : (this._spherical.theta += this._sphericalDelta.theta, this._spherical.phi += this._sphericalDelta.phi);+ let n = this.minAzimuthAngle, s = this.maxAzimuthAngle;+ isFinite(n) && isFinite(s) && (n < -Math.PI ? n += On : n > Math.PI && (n -= On), s < -Math.PI ? s += On : s > Math.PI && (s -= On), n <= s ? this._spherical.theta = Math.max(n, Math.min(s, this._spherical.theta)) : this._spherical.theta = this._spherical.theta > (n + s) / 2 ? Math.max(n, this._spherical.theta) : Math.min(s, 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 r = !1;+ if (this.zoomToCursor && this._performCursorZoom || this.object.isOrthographicCamera)+ this._spherical.radius = this._clampDistance(this._spherical.radius);+ else {+ const a = this._spherical.radius;+ this._spherical.radius = this._clampDistance(this._spherical.radius * this._scale), r = a != this._spherical.radius;+ }+ if (nn.setFromSpherical(this._spherical), nn.applyQuaternion(this._quatInverse), t.copy(this.target).add(nn), 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 a = null;+ if (this.object.isPerspectiveCamera) {+ const o = nn.length();+ a = this._clampDistance(o * this._scale);+ const c = o - a;+ this.object.position.addScaledVector(this._dollyDirection, c), this.object.updateMatrixWorld(), r = !!c;+ } else if (this.object.isOrthographicCamera) {+ const o = new H(this._mouse.x, this._mouse.y, 0);+ o.unproject(this.object);+ const c = this.object.zoom;+ this.object.zoom = Math.max(this.minZoom, Math.min(this.maxZoom, this.object.zoom / this._scale)), this.object.updateProjectionMatrix(), r = c !== this.object.zoom;+ const l = new H(this._mouse.x, this._mouse.y, 0);+ l.unproject(this.object), this.object.position.sub(l).add(o), this.object.updateMatrixWorld(), a = nn.length();+ } else+ console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."), this.zoomToCursor = !1;+ a !== null && (this.screenSpacePanning ? this.target.set(0, 0, -1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position) : (Gc.origin.copy(this.object.position), Gc.direction.set(0, 0, -1).transformDirection(this.object.matrix), Math.abs(this.object.up.dot(Gc.direction)) < p1 ? this.object.lookAt(this.target) : (DA.setFromNormalAndCoplanarPoint(this.object.up, this.target), Gc.intersectPlane(DA, this.target))));+ } else if (this.object.isOrthographicCamera) {+ const a = this.object.zoom;+ this.object.zoom = Math.max(this.minZoom, Math.min(this.maxZoom, this.object.zoom / this._scale)), a !== this.object.zoom && (this.object.updateProjectionMatrix(), r = !0);+ }+ return this._scale = 1, this._performCursorZoom = !1, r || this._lastPosition.distanceToSquared(this.object.position) > iu || 8 * (1 - this._lastQuaternion.dot(this.object.quaternion)) > iu || this._lastTargetPosition.distanceToSquared(this.target) > iu ? (this.dispatchEvent(FA), this._lastPosition.copy(this.object.position), this._lastQuaternion.copy(this.object.quaternion), this._lastTargetPosition.copy(this.target), !0) : !1;+ }+ _getAutoRotationAngle(e) {+ return e !== null ? On / 60 * this.autoRotateSpeed * e : On / 60 / 60 * this.autoRotateSpeed;+ }+ _getZoomScale(e) {+ const t = Math.abs(e * 0.01);+ return Math.pow(0.95, this.zoomSpeed * t);+ }+ _rotateLeft(e) {+ this._sphericalDelta.theta -= e;+ }+ _rotateUp(e) {+ this._sphericalDelta.phi -= e;+ }+ _panLeft(e, t) {+ nn.setFromMatrixColumn(t, 0), nn.multiplyScalar(-e), this._panOffset.add(nn);+ }+ _panUp(e, t) {+ this.screenSpacePanning === !0 ? nn.setFromMatrixColumn(t, 1) : (nn.setFromMatrixColumn(t, 0), nn.crossVectors(this.object.up, nn)), nn.multiplyScalar(e), this._panOffset.add(nn);+ }+ // deltaX and deltaY are in pixels; right and down are positive+ _pan(e, t) {+ const n = this.domElement;+ if (this.object.isPerspectiveCamera) {+ const s = this.object.position;+ nn.copy(s).sub(this.target);+ let r = nn.length();+ r *= Math.tan(this.object.fov / 2 * Math.PI / 180), this._panLeft(2 * e * r / n.clientHeight, this.object.matrix), this._panUp(2 * t * r / 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;+ const n = this.domElement.getBoundingClientRect(), s = e - n.left, r = t - n.top, a = n.width, o = n.height;+ this._mouse.x = s / a * 2 - 1, this._mouse.y = -(r / 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));+ }+ //+ // event callbacks - update the object state+ //+ _handleMouseDownRotate(e) {+ this._rotateStart.set(e.clientX, e.clientY);+ }+ _handleMouseDownDolly(e) {+ this._updateZoomParameters(e.clientX, e.clientX), this._dollyStart.set(e.clientX, e.clientY);+ }+ _handleMouseDownPan(e) {+ this._panStart.set(e.clientX, e.clientY);+ }+ _handleMouseMoveRotate(e) {+ this._rotateEnd.set(e.clientX, e.clientY), this._rotateDelta.subVectors(this._rotateEnd, this._rotateStart).multiplyScalar(this.rotateSpeed);+ const t = this.domElement;+ this._rotateLeft(On * this._rotateDelta.x / t.clientHeight), this._rotateUp(On * this._rotateDelta.y / t.clientHeight), this._rotateStart.copy(this._rotateEnd), this.update();+ }+ _handleMouseMoveDolly(e) {+ this._dollyEnd.set(e.clientX, e.clientY), this._dollyDelta.subVectors(this._dollyEnd, this._dollyStart), this._dollyDelta.y > 0 ? this._dollyOut(this._getZoomScale(this._dollyDelta.y)) : this._dollyDelta.y < 0 && this._dollyIn(this._getZoomScale(this._dollyDelta.y)), this._dollyStart.copy(this._dollyEnd), this.update();+ }+ _handleMouseMovePan(e) {+ this._panEnd.set(e.clientX, e.clientY), this._panDelta.subVectors(this._panEnd, this._panStart).multiplyScalar(this.panSpeed), this._pan(this._panDelta.x, this._panDelta.y), this._panStart.copy(this._panEnd), this.update();+ }+ _handleMouseWheel(e) {+ this._updateZoomParameters(e.clientX, e.clientY), e.deltaY < 0 ? this._dollyIn(this._getZoomScale(e.deltaY)) : e.deltaY > 0 && this._dollyOut(this._getZoomScale(e.deltaY)), this.update();+ }+ _handleKeyDown(e) {+ let t = !1;+ switch (e.code) {+ case this.keys.UP:+ e.ctrlKey || e.metaKey || e.shiftKey ? this.enableRotate && this._rotateUp(On * 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(-On * 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(On * 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(-On * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(-this.keyPanSpeed, 0), t = !0;+ break;+ }+ t && (e.preventDefault(), this.update());+ }+ _handleTouchStartRotate(e) {+ if (this._pointers.length === 1)+ this._rotateStart.set(e.pageX, e.pageY);+ else {+ const t = this._getSecondPointerPosition(e), n = 0.5 * (e.pageX + t.x), s = 0.5 * (e.pageY + t.y);+ this._rotateStart.set(n, s);+ }+ }+ _handleTouchStartPan(e) {+ if (this._pointers.length === 1)+ this._panStart.set(e.pageX, e.pageY);+ else {+ const t = this._getSecondPointerPosition(e), n = 0.5 * (e.pageX + t.x), s = 0.5 * (e.pageY + t.y);+ this._panStart.set(n, s);+ }+ }+ _handleTouchStartDolly(e) {+ const t = this._getSecondPointerPosition(e), n = e.pageX - t.x, s = e.pageY - t.y, r = Math.sqrt(n * n + s * s);+ this._dollyStart.set(0, r);+ }+ _handleTouchStartDollyPan(e) {+ this.enableZoom && this._handleTouchStartDolly(e), this.enablePan && this._handleTouchStartPan(e);+ }+ _handleTouchStartDollyRotate(e) {+ this.enableZoom && this._handleTouchStartDolly(e), this.enableRotate && this._handleTouchStartRotate(e);+ }+ _handleTouchMoveRotate(e) {+ if (this._pointers.length == 1)+ this._rotateEnd.set(e.pageX, e.pageY);+ else {+ const n = this._getSecondPointerPosition(e), s = 0.5 * (e.pageX + n.x), r = 0.5 * (e.pageY + n.y);+ this._rotateEnd.set(s, r);+ }+ this._rotateDelta.subVectors(this._rotateEnd, this._rotateStart).multiplyScalar(this.rotateSpeed);+ const t = this.domElement;+ this._rotateLeft(On * this._rotateDelta.x / t.clientHeight), this._rotateUp(On * 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 {+ const t = this._getSecondPointerPosition(e), n = 0.5 * (e.pageX + t.x), s = 0.5 * (e.pageY + t.y);+ this._panEnd.set(n, s);+ }+ this._panDelta.subVectors(this._panEnd, this._panStart).multiplyScalar(this.panSpeed), this._pan(this._panDelta.x, this._panDelta.y), this._panStart.copy(this._panEnd);+ }+ _handleTouchMoveDolly(e) {+ const t = this._getSecondPointerPosition(e), n = e.pageX - t.x, s = e.pageY - t.y, r = Math.sqrt(n * n + s * s);+ this._dollyEnd.set(0, r), this._dollyDelta.set(0, Math.pow(this._dollyEnd.y / this._dollyStart.y, this.zoomSpeed)), this._dollyOut(this._dollyDelta.y), this._dollyStart.copy(this._dollyEnd);+ const a = (e.pageX + t.x) * 0.5, o = (e.pageY + t.y) * 0.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);+ }+ // pointers+ _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 Ze(), this._pointerPositions[e.pointerId] = t), t.set(e.pageX, e.pageY);+ }+ _getSecondPointerPosition(e) {+ const t = e.pointerId === this._pointers[0] ? this._pointers[1] : this._pointers[0];+ return this._pointerPositions[t];+ }+ //+ _customWheelEvent(e) {+ const 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;+ break;+ }+ return e.ctrlKey && !this._controlActive && (n.deltaY *= 10), n;+ }+}+function g1(i) {+ this.enabled !== !1 && (this._pointers.length === 0 && (this.domElement.setPointerCapture(i.pointerId), this.domElement.addEventListener("pointermove", this._onPointerMove), this.domElement.addEventListener("pointerup", this._onPointerUp)), !this._isTrackingPointer(i) && (this._addPointer(i), i.pointerType === "touch" ? this._onTouchStart(i) : this._onMouseDown(i)));+}+function m1(i) {+ this.enabled !== !1 && (i.pointerType === "touch" ? this._onTouchMove(i) : this._onMouseMove(i));+}+function b1(i) {+ switch (this._removePointer(i), this._pointers.length) {+ case 0:+ this.domElement.releasePointerCapture(i.pointerId), this.domElement.removeEventListener("pointermove", this._onPointerMove), this.domElement.removeEventListener("pointerup", this._onPointerUp), this.dispatchEvent(D0), this.state = Bt.NONE;+ break;+ case 1:+ const e = this._pointers[0], t = this._pointerPositions[e];+ this._onTouchStart({ pointerId: e, pageX: t.x, pageY: t.y });+ break;+ }+}+function x1(i) {+ let e;+ switch (i.button) {+ case 0:+ e = this.mouseButtons.LEFT;+ break;+ case 1:+ e = this.mouseButtons.MIDDLE;+ break;+ case 2:+ e = this.mouseButtons.RIGHT;+ break;+ default:+ e = -1;+ }+ switch (e) {+ case da.DOLLY:+ if (this.enableZoom === !1) return;+ this._handleMouseDownDolly(i), this.state = Bt.DOLLY;+ break;+ case da.ROTATE:+ if (i.ctrlKey || i.metaKey || i.shiftKey) {+ if (this.enablePan === !1) return;+ this._handleMouseDownPan(i), this.state = Bt.PAN;+ } else {+ if (this.enableRotate === !1) return;+ this._handleMouseDownRotate(i), this.state = Bt.ROTATE;+ }+ break;+ case da.PAN:+ if (i.ctrlKey || i.metaKey || i.shiftKey) {+ if (this.enableRotate === !1) return;+ this._handleMouseDownRotate(i), this.state = Bt.ROTATE;+ } else {+ if (this.enablePan === !1) return;+ this._handleMouseDownPan(i), this.state = Bt.PAN;+ }+ break;+ default:+ this.state = Bt.NONE;+ }+ this.state !== Bt.NONE && this.dispatchEvent(Nf);+}+function _1(i) {+ switch (this.state) {+ case Bt.ROTATE:+ if (this.enableRotate === !1) return;+ this._handleMouseMoveRotate(i);+ break;+ case Bt.DOLLY:+ if (this.enableZoom === !1) return;+ this._handleMouseMoveDolly(i);+ break;+ case Bt.PAN:+ if (this.enablePan === !1) return;+ this._handleMouseMovePan(i);+ break;+ }+}+function E1(i) {+ this.enabled === !1 || this.enableZoom === !1 || this.state !== Bt.NONE || (i.preventDefault(), this.dispatchEvent(Nf), this._handleMouseWheel(this._customWheelEvent(i)), this.dispatchEvent(D0));+}+function y1(i) {+ this.enabled !== !1 && this._handleKeyDown(i);+}+function w1(i) {+ switch (this._trackPointer(i), this._pointers.length) {+ case 1:+ switch (this.touches.ONE) {+ case sa.ROTATE:+ if (this.enableRotate === !1) return;+ this._handleTouchStartRotate(i), this.state = Bt.TOUCH_ROTATE;+ break;+ case sa.PAN:+ if (this.enablePan === !1) return;+ this._handleTouchStartPan(i), this.state = Bt.TOUCH_PAN;+ break;+ default:+ this.state = Bt.NONE;+ }+ break;+ case 2:+ switch (this.touches.TWO) {+ case sa.DOLLY_PAN:+ if (this.enableZoom === !1 && this.enablePan === !1) return;+ this._handleTouchStartDollyPan(i), this.state = Bt.TOUCH_DOLLY_PAN;+ break;+ case sa.DOLLY_ROTATE:+ if (this.enableZoom === !1 && this.enableRotate === !1) return;+ this._handleTouchStartDollyRotate(i), this.state = Bt.TOUCH_DOLLY_ROTATE;+ break;+ default:+ this.state = Bt.NONE;+ }+ break;+ default:+ this.state = Bt.NONE;+ }+ this.state !== Bt.NONE && this.dispatchEvent(Nf);+}+function v1(i) {+ switch (this._trackPointer(i), this.state) {+ case Bt.TOUCH_ROTATE:+ if (this.enableRotate === !1) return;+ this._handleTouchMoveRotate(i), this.update();+ break;+ case Bt.TOUCH_PAN:+ if (this.enablePan === !1) return;+ this._handleTouchMovePan(i), this.update();+ break;+ case Bt.TOUCH_DOLLY_PAN:+ if (this.enableZoom === !1 && this.enablePan === !1) return;+ this._handleTouchMoveDollyPan(i), this.update();+ break;+ case Bt.TOUCH_DOLLY_ROTATE:+ if (this.enableZoom === !1 && this.enableRotate === !1) return;+ this._handleTouchMoveDollyRotate(i), this.update();+ break;+ default:+ this.state = Bt.NONE;+ }+}+function C1(i) {+ this.enabled !== !1 && i.preventDefault();+}+function S1(i) {+ i.key === "Control" && (this._controlActive = !0, this.domElement.getRootNode().addEventListener("keyup", this._interceptControlUp, { passive: !0, capture: !0 }));+}+function I1(i) {+ i.key === "Control" && (this._controlActive = !1, this.domElement.getRootNode().removeEventListener("keyup", this._interceptControlUp, { passive: !0, capture: !0 }));+}+class M1 extends _d {+ constructor() {+ super();+ const e = new Ua();+ e.deleteAttribute("uv");+ const t = new Oo({ side: Pn }), n = new Oo(), s = new y0(16777215, 900, 28, 2);+ s.position.set(0.418, 16.199, 0.3), this.add(s);+ const r = new Jt(e, t);+ r.position.set(-0.757, 13.219, 0.717), r.scale.set(31.713, 28.305, 28.591), this.add(r);+ const a = new g0(e, n, 6), o = new kt();+ o.position.set(-10.906, 2.009, 1.846), o.rotation.set(0, -0.195, 0), o.scale.set(2.328, 7.905, 4.651), o.updateMatrix(), a.setMatrixAt(0, o.matrix), o.position.set(-5.607, -0.754, -0.758), o.rotation.set(0, 0.994, 0), o.scale.set(1.97, 1.534, 3.955), o.updateMatrix(), a.setMatrixAt(1, o.matrix), o.position.set(6.167, 0.857, 7.803), o.rotation.set(0, 0.561, 0), o.scale.set(3.927, 6.285, 3.687), o.updateMatrix(), a.setMatrixAt(2, o.matrix), o.position.set(-2.017, 0.018, 6.124), o.rotation.set(0, 0.333, 0), o.scale.set(2.002, 4.566, 2.064), o.updateMatrix(), a.setMatrixAt(3, o.matrix), o.position.set(2.291, -0.756, -2.621), o.rotation.set(0, -0.286, 0), o.scale.set(1.546, 1.552, 1.496), o.updateMatrix(), a.setMatrixAt(4, o.matrix), o.position.set(-2.193, -0.369, -5.547), o.rotation.set(0, 0.516, 0), o.scale.set(3.875, 3.487, 2.986), o.updateMatrix(), a.setMatrixAt(5, o.matrix), this.add(a);+ const c = new Jt(e, Yr(50));+ c.position.set(-16.116, 14.37, 8.208), c.scale.set(0.1, 2.428, 2.739), this.add(c);+ const l = new Jt(e, Yr(50));+ l.position.set(-16.109, 18.021, -8.207), l.scale.set(0.1, 2.425, 2.751), this.add(l);+ const h = new Jt(e, Yr(17));+ h.position.set(14.904, 12.198, -1.832), h.scale.set(0.15, 4.265, 6.331), this.add(h);+ const u = new Jt(e, Yr(43));+ u.position.set(-0.462, 8.89, 14.52), u.scale.set(4.38, 5.441, 0.088), this.add(u);+ const d = new Jt(e, Yr(20));+ d.position.set(3.235, 11.486, -12.541), d.scale.set(2.5, 2, 0.1), this.add(d);+ const f = new Jt(e, Yr(100));+ f.position.set(0, 20, 0), f.scale.set(1, 0.1, 1), this.add(f);+ }+ /**+ * Frees internal resources. This method should be called+ * when the environment is no longer required.+ */+ dispose() {+ const e = /* @__PURE__ */ new Set();+ this.traverse((t) => {+ t.isMesh && (e.add(t.geometry), e.add(t.material));+ });+ for (const t of e)+ t.dispose();+ }+}+function Yr(i) {+ const e = new Ns();+ return e.color.setScalar(i), e;+}+function B1(i) {+ if (!(typeof window > "u")) {+ var e = document.createElement("style");+ return e.setAttribute("type", "text/css"), e.innerHTML = i, document.head.appendChild(e), i;+ }+}+function ca(i, e) {+ var t = i.__state.conversionName.toString(), n = Math.round(i.r), s = Math.round(i.g), r = Math.round(i.b), a = i.a, o = Math.round(i.h), c = i.s.toFixed(1), l = i.v.toFixed(1);+ if (e || t === "THREE_CHAR_HEX" || t === "SIX_CHAR_HEX") {+ for (var h = i.hex.toString(16); h.length < 6; )+ h = "0" + h;+ return "#" + h;+ } else {+ if (t === "CSS_RGB")+ return "rgb(" + n + "," + s + "," + r + ")";+ if (t === "CSS_RGBA")+ return "rgba(" + n + "," + s + "," + r + "," + a + ")";+ if (t === "HEX")+ return "0x" + i.hex.toString(16);+ if (t === "RGB_ARRAY")+ return "[" + n + "," + s + "," + r + "]";+ if (t === "RGBA_ARRAY")+ return "[" + n + "," + s + "," + r + "," + a + "]";+ if (t === "RGB_OBJ")+ return "{r:" + n + ",g:" + s + ",b:" + r + "}";+ if (t === "RGBA_OBJ")+ return "{r:" + n + ",g:" + s + ",b:" + r + ",a:" + a + "}";+ if (t === "HSV_OBJ")+ return "{h:" + o + ",s:" + c + ",v:" + l + "}";+ if (t === "HSVA_OBJ")+ return "{h:" + o + ",s:" + c + ",v:" + l + ",a:" + a + "}";+ }+ return "unknown format";+}+var LA = Array.prototype.forEach, so = Array.prototype.slice, ue = {+ BREAK: {},+ extend: function(e) {+ return this.each(so.call(arguments, 1), function(t) {+ var n = this.isObject(t) ? Object.keys(t) : [];+ n.forEach((function(s) {+ this.isUndefined(t[s]) || (e[s] = t[s]);+ }).bind(this));+ }, this), e;+ },+ defaults: function(e) {+ return this.each(so.call(arguments, 1), function(t) {+ var n = this.isObject(t) ? Object.keys(t) : [];+ n.forEach((function(s) {+ this.isUndefined(e[s]) && (e[s] = t[s]);+ }).bind(this));+ }, this), e;+ },+ compose: function() {+ var e = so.call(arguments);+ return function() {+ for (var t = so.call(arguments), n = e.length - 1; n >= 0; n--)+ t = [e[n].apply(this, t)];+ return t[0];+ };+ },+ each: function(e, t, n) {+ if (e) {+ if (LA && e.forEach && e.forEach === LA)+ e.forEach(t, n);+ else if (e.length === e.length + 0) {+ var s = void 0, r = void 0;+ for (s = 0, r = e.length; s < r; s++)+ if (s in e && t.call(n, e[s], s) === this.BREAK)+ return;+ } else+ for (var a in e)+ if (t.call(n, e[a], a) === this.BREAK)+ return;+ }+ },+ defer: function(e) {+ setTimeout(e, 0);+ },+ debounce: function(e, t, n) {+ var s = void 0;+ return function() {+ var r = this, a = arguments;+ function o() {+ s = null, n || e.apply(r, a);+ }+ var c = n || !s;+ clearTimeout(s), s = setTimeout(o, t), c && e.apply(r, a);+ };+ },+ toArray: function(e) {+ return e.toArray ? e.toArray() : so.call(e);+ },+ isUndefined: function(e) {+ return e === void 0;+ },+ isNull: function(e) {+ return e === null;+ },+ isNaN: (function(i) {+ function e(t) {+ return i.apply(this, arguments);+ }+ return e.toString = function() {+ return i.toString();+ }, e;+ })(function(i) {+ return isNaN(i);+ }),+ isArray: Array.isArray || function(i) {+ return i.constructor === Array;+ },+ isObject: function(e) {+ return e === Object(e);+ },+ isNumber: function(e) {+ return e === e + 0;+ },+ isString: function(e) {+ return e === e + "";+ },+ isBoolean: function(e) {+ return e === !1 || e === !0;+ },+ isFunction: function(e) {+ return e instanceof Function;+ }+}, T1 = [+ {+ litmus: ue.isString,+ conversions: {+ THREE_CHAR_HEX: {+ read: function(e) {+ var t = e.match(/^#([A-F0-9])([A-F0-9])([A-F0-9])$/i);+ return t === null ? !1 : {+ space: "HEX",+ hex: parseInt("0x" + t[1].toString() + t[1].toString() + t[2].toString() + t[2].toString() + t[3].toString() + t[3].toString(), 0)+ };+ },+ write: ca+ },+ SIX_CHAR_HEX: {+ read: function(e) {+ var t = e.match(/^#([A-F0-9]{6})$/i);+ return t === null ? !1 : {+ space: "HEX",+ hex: parseInt("0x" + t[1].toString(), 0)+ };+ },+ write: ca+ },+ CSS_RGB: {+ read: function(e) {+ var t = e.match(/^rgb\(\s*(\S+)\s*,\s*(\S+)\s*,\s*(\S+)\s*\)/);+ return t === null ? !1 : {+ space: "RGB",+ r: parseFloat(t[1]),+ g: parseFloat(t[2]),+ b: parseFloat(t[3])+ };+ },+ write: ca+ },+ CSS_RGBA: {+ read: function(e) {+ var t = e.match(/^rgba\(\s*(\S+)\s*,\s*(\S+)\s*,\s*(\S+)\s*,\s*(\S+)\s*\)/);+ return t === null ? !1 : {+ space: "RGB",+ r: parseFloat(t[1]),+ g: parseFloat(t[2]),+ b: parseFloat(t[3]),+ a: parseFloat(t[4])+ };+ },+ write: ca+ }+ }+ },+ {+ litmus: ue.isNumber,+ conversions: {+ HEX: {+ read: function(e) {+ return {+ space: "HEX",+ hex: e,+ conversionName: "HEX"+ };+ },+ write: function(e) {+ return e.hex;+ }+ }+ }+ },+ {+ litmus: ue.isArray,+ conversions: {+ RGB_ARRAY: {+ read: function(e) {+ return e.length !== 3 ? !1 : {+ space: "RGB",+ r: e[0],+ g: e[1],+ b: e[2]+ };+ },+ write: function(e) {+ return [e.r, e.g, e.b];+ }+ },+ RGBA_ARRAY: {+ read: function(e) {+ return e.length !== 4 ? !1 : {+ space: "RGB",+ r: e[0],+ g: e[1],+ b: e[2],+ a: e[3]+ };+ },+ write: function(e) {+ return [e.r, e.g, e.b, e.a];+ }+ }+ }+ },+ {+ litmus: ue.isObject,+ conversions: {+ RGBA_OBJ: {+ read: function(e) {+ return ue.isNumber(e.r) && ue.isNumber(e.g) && ue.isNumber(e.b) && ue.isNumber(e.a) ? {+ space: "RGB",+ r: e.r,+ g: e.g,+ b: e.b,+ a: e.a+ } : !1;+ },+ write: function(e) {+ return {+ r: e.r,+ g: e.g,+ b: e.b,+ a: e.a+ };+ }+ },+ RGB_OBJ: {+ read: function(e) {+ return ue.isNumber(e.r) && ue.isNumber(e.g) && ue.isNumber(e.b) ? {+ space: "RGB",+ r: e.r,+ g: e.g,+ b: e.b+ } : !1;+ },+ write: function(e) {+ return {+ r: e.r,+ g: e.g,+ b: e.b+ };+ }+ },+ HSVA_OBJ: {+ read: function(e) {+ return ue.isNumber(e.h) && ue.isNumber(e.s) && ue.isNumber(e.v) && ue.isNumber(e.a) ? {+ space: "HSV",+ h: e.h,+ s: e.s,+ v: e.v,+ a: e.a+ } : !1;+ },+ write: function(e) {+ return {+ h: e.h,+ s: e.s,+ v: e.v,+ a: e.a+ };+ }+ },+ HSV_OBJ: {+ read: function(e) {+ return ue.isNumber(e.h) && ue.isNumber(e.s) && ue.isNumber(e.v) ? {+ space: "HSV",+ h: e.h,+ s: e.s,+ v: e.v+ } : !1;+ },+ write: function(e) {+ return {+ h: e.h,+ s: e.s,+ v: e.v+ };+ }+ }+ }+ }+], ro = void 0, Hc = void 0, Id = function() {+ Hc = !1;+ var e = arguments.length > 1 ? ue.toArray(arguments) : arguments[0];+ return ue.each(T1, function(t) {+ if (t.litmus(e))+ return ue.each(t.conversions, function(n, s) {+ if (ro = n.read(e), Hc === !1 && ro !== !1)+ return Hc = ro, ro.conversionName = s, ro.conversion = n, ue.BREAK;+ }), ue.BREAK;+ }), Hc;+}, PA = void 0, Dl = {+ hsv_to_rgb: function(e, t, n) {+ var s = Math.floor(e / 60) % 6, r = e / 60 - Math.floor(e / 60), a = n * (1 - t), o = n * (1 - r * t), c = n * (1 - (1 - r) * t), l = [[n, c, a], [o, n, a], [a, n, c], [a, o, n], [c, a, n], [n, a, o]][s];+ return {+ r: l[0] * 255,+ g: l[1] * 255,+ b: l[2] * 255+ };+ },+ rgb_to_hsv: function(e, t, n) {+ var s = Math.min(e, t, n), r = Math.max(e, t, n), a = r - s, o = void 0, c = void 0;+ if (r !== 0)+ c = a / r;+ else+ return {+ h: NaN,+ s: 0,+ v: 0+ };+ return e === r ? o = (t - n) / a : t === r ? o = 2 + (n - e) / a : o = 4 + (e - t) / a, o /= 6, o < 0 && (o += 1), {+ h: o * 360,+ s: c,+ v: r / 255+ };+ },+ rgb_to_hex: function(e, t, n) {+ var s = this.hex_with_component(0, 2, e);+ return s = this.hex_with_component(s, 1, t), s = this.hex_with_component(s, 0, n), s;+ },+ component_from_hex: function(e, t) {+ return e >> t * 8 & 255;+ },+ hex_with_component: function(e, t, n) {+ return n << (PA = t * 8) | e & ~(255 << PA);+ }+}, R1 = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(i) {+ return typeof i;+} : function(i) {+ return i && typeof Symbol == "function" && i.constructor === Symbol && i !== Symbol.prototype ? "symbol" : typeof i;+}, vi = function(i, e) {+ if (!(i instanceof e))+ throw new TypeError("Cannot call a class as a function");+}, Ci = /* @__PURE__ */ (function() {+ function i(e, t) {+ for (var n = 0; n < t.length; n++) {+ var s = t[n];+ s.enumerable = s.enumerable || !1, s.configurable = !0, "value" in s && (s.writable = !0), Object.defineProperty(e, s.key, s);+ }+ }+ return function(e, t, n) {+ return t && i(e.prototype, t), n && i(e, n), e;+ };+})(), Qs = function i(e, t, n) {+ e === null && (e = Function.prototype);+ var s = Object.getOwnPropertyDescriptor(e, t);+ if (s === void 0) {+ var r = Object.getPrototypeOf(e);+ return r === null ? void 0 : i(r, t, n);+ } else {+ if ("value" in s)+ return s.value;+ var a = s.get;+ return a === void 0 ? void 0 : a.call(n);+ }+}, Vs = function(i, e) {+ if (typeof e != "function" && e !== null)+ throw new TypeError("Super expression must either be null or a function, not " + typeof e);+ i.prototype = Object.create(e && e.prototype, {+ constructor: {+ value: i,+ enumerable: !1,+ writable: !0,+ configurable: !0+ }+ }), e && (Object.setPrototypeOf ? Object.setPrototypeOf(i, e) : i.__proto__ = e);+}, Ws = function(i, e) {+ if (!i)+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");+ return e && (typeof e == "object" || typeof e == "function") ? e : i;+}, bn = (function() {+ function i() {+ if (vi(this, i), this.__state = Id.apply(this, arguments), this.__state === !1)+ throw new Error("Failed to interpret color arguments");+ this.__state.a = this.__state.a || 1;+ }+ return Ci(i, [{+ key: "toString",+ value: function() {+ return ca(this);+ }+ }, {+ key: "toHexString",+ value: function() {+ return ca(this, !0);+ }+ }, {+ key: "toOriginal",+ value: function() {+ return this.__state.conversion.write(this);+ }+ }]), i;+})();+function Ff(i, e, t) {+ Object.defineProperty(i, e, {+ get: function() {+ return this.__state.space === "RGB" ? this.__state[e] : (bn.recalculateRGB(this, e, t), this.__state[e]);+ },+ set: function(s) {+ this.__state.space !== "RGB" && (bn.recalculateRGB(this, e, t), this.__state.space = "RGB"), this.__state[e] = s;+ }+ });+}+function Df(i, e) {+ Object.defineProperty(i, e, {+ get: function() {+ return this.__state.space === "HSV" ? this.__state[e] : (bn.recalculateHSV(this), this.__state[e]);+ },+ set: function(n) {+ this.__state.space !== "HSV" && (bn.recalculateHSV(this), this.__state.space = "HSV"), this.__state[e] = n;+ }+ });+}+bn.recalculateRGB = function(i, e, t) {+ if (i.__state.space === "HEX")+ i.__state[e] = Dl.component_from_hex(i.__state.hex, t);+ else if (i.__state.space === "HSV")+ ue.extend(i.__state, Dl.hsv_to_rgb(i.__state.h, i.__state.s, i.__state.v));+ else+ throw new Error("Corrupted color state");+};+bn.recalculateHSV = function(i) {+ var e = Dl.rgb_to_hsv(i.r, i.g, i.b);+ ue.extend(i.__state, {+ s: e.s,+ v: e.v+ }), ue.isNaN(e.h) ? ue.isUndefined(i.__state.h) && (i.__state.h = 0) : i.__state.h = e.h;+};+bn.COMPONENTS = ["r", "g", "b", "h", "s", "v", "hex", "a"];+Ff(bn.prototype, "r", 2);+Ff(bn.prototype, "g", 1);+Ff(bn.prototype, "b", 0);+Df(bn.prototype, "h");+Df(bn.prototype, "s");+Df(bn.prototype, "v");+Object.defineProperty(bn.prototype, "a", {+ get: function() {+ return this.__state.a;+ },+ set: function(e) {+ this.__state.a = e;+ }+});+Object.defineProperty(bn.prototype, "hex", {+ get: function() {+ return this.__state.space !== "HEX" && (this.__state.hex = Dl.rgb_to_hex(this.r, this.g, this.b), this.__state.space = "HEX"), this.__state.hex;+ },+ set: function(e) {+ this.__state.space = "HEX", this.__state.hex = e;+ }+});+var Tr = (function() {+ function i(e, t) {+ vi(this, i), this.initialValue = e[t], this.domElement = document.createElement("div"), this.object = e, this.property = t, this.__onChange = void 0, this.__onFinishChange = void 0;+ }+ return Ci(i, [{+ key: "onChange",+ value: function(t) {+ return this.__onChange = t, this;+ }+ }, {+ key: "onFinishChange",+ value: function(t) {+ return this.__onFinishChange = t, this;+ }+ }, {+ key: "setValue",+ value: function(t) {+ return this.object[this.property] = t, this.__onChange && this.__onChange.call(this, t), this.updateDisplay(), this;+ }+ }, {+ key: "getValue",+ value: function() {+ return this.object[this.property];+ }+ }, {+ key: "updateDisplay",+ value: function() {+ return this;+ }+ }, {+ key: "isModified",+ value: function() {+ return this.initialValue !== this.getValue();+ }+ }]), i;+})(), N1 = {+ HTMLEvents: ["change"],+ MouseEvents: ["click", "mousemove", "mousedown", "mouseup", "mouseover"],+ KeyboardEvents: ["keydown"]+}, L0 = {};+ue.each(N1, function(i, e) {+ ue.each(i, function(t) {+ L0[t] = e;+ });+});+var F1 = /(\d+(\.\d+)?)px/;+function Ii(i) {+ if (i === "0" || ue.isUndefined(i))+ return 0;+ var e = i.match(F1);+ return ue.isNull(e) ? 0 : parseFloat(e[1]);+}+var te = {+ makeSelectable: function(e, t) {+ e === void 0 || e.style === void 0 || (e.onselectstart = t ? function() {+ return !1;+ } : function() {+ }, e.style.MozUserSelect = t ? "auto" : "none", e.style.KhtmlUserSelect = t ? "auto" : "none", e.unselectable = t ? "on" : "off");+ },+ makeFullscreen: function(e, t, n) {+ var s = n, r = t;+ ue.isUndefined(r) && (r = !0), ue.isUndefined(s) && (s = !0), e.style.position = "absolute", r && (e.style.left = 0, e.style.right = 0), s && (e.style.top = 0, e.style.bottom = 0);+ },+ fakeEvent: function(e, t, n, s) {+ var r = n || {}, a = L0[t];+ if (!a)+ throw new Error("Event type " + t + " not supported.");+ var o = document.createEvent(a);+ switch (a) {+ case "MouseEvents": {+ var c = r.x || r.clientX || 0, l = r.y || r.clientY || 0;+ o.initMouseEvent(+ t,+ r.bubbles || !1,+ r.cancelable || !0,+ window,+ r.clickCount || 1,+ 0,+ 0,+ c,+ l,+ !1,+ !1,+ !1,+ !1,+ 0,+ null+ );+ break;+ }+ case "KeyboardEvents": {+ var h = o.initKeyboardEvent || o.initKeyEvent;+ ue.defaults(r, {+ cancelable: !0,+ ctrlKey: !1,+ altKey: !1,+ shiftKey: !1,+ metaKey: !1,+ keyCode: void 0,+ charCode: void 0+ }), h(t, r.bubbles || !1, r.cancelable, window, r.ctrlKey, r.altKey, r.shiftKey, r.metaKey, r.keyCode, r.charCode);+ break;+ }+ default: {+ o.initEvent(t, r.bubbles || !1, r.cancelable || !0);+ break;+ }+ }+ ue.defaults(o, s), e.dispatchEvent(o);+ },+ bind: function(e, t, n, s) {+ var r = s || !1;+ return e.addEventListener ? e.addEventListener(t, n, r) : e.attachEvent && e.attachEvent("on" + t, n), te;+ },+ unbind: function(e, t, n, s) {+ var r = s || !1;+ return e.removeEventListener ? e.removeEventListener(t, n, r) : e.detachEvent && e.detachEvent("on" + t, n), te;+ },+ addClass: function(e, t) {+ if (e.className === void 0)+ e.className = t;+ else if (e.className !== t) {+ var n = e.className.split(/ +/);+ n.indexOf(t) === -1 && (n.push(t), e.className = n.join(" ").replace(/^\s+/, "").replace(/\s+$/, ""));+ }+ return te;+ },+ removeClass: function(e, t) {+ if (t)+ if (e.className === t)+ e.removeAttribute("class");+ else {+ var n = e.className.split(/ +/), s = n.indexOf(t);+ s !== -1 && (n.splice(s, 1), e.className = n.join(" "));+ }+ else+ e.className = void 0;+ return te;+ },+ hasClass: function(e, t) {+ return new RegExp("(?:^|\\s+)" + t + "(?:\\s+|$)").test(e.className) || !1;+ },+ getWidth: function(e) {+ var t = getComputedStyle(e);+ return Ii(t["border-left-width"]) + Ii(t["border-right-width"]) + Ii(t["padding-left"]) + Ii(t["padding-right"]) + Ii(t.width);+ },+ getHeight: function(e) {+ var t = getComputedStyle(e);+ return Ii(t["border-top-width"]) + Ii(t["border-bottom-width"]) + Ii(t["padding-top"]) + Ii(t["padding-bottom"]) + Ii(t.height);+ },+ getOffset: function(e) {+ var t = e, n = { left: 0, top: 0 };+ if (t.offsetParent)+ do+ n.left += t.offsetLeft, n.top += t.offsetTop, t = t.offsetParent;+ while (t);+ return n;+ },+ isActive: function(e) {+ return e === document.activeElement && (e.type || e.href);+ }+}, P0 = (function(i) {+ Vs(e, i);+ function e(t, n) {+ vi(this, e);+ var s = Ws(this, (e.__proto__ || Object.getPrototypeOf(e)).call(this, t, n)), r = s;+ s.__prev = s.getValue(), s.__checkbox = document.createElement("input"), s.__checkbox.setAttribute("type", "checkbox");+ function a() {+ r.setValue(!r.__prev);+ }+ return te.bind(s.__checkbox, "change", a, !1), s.domElement.appendChild(s.__checkbox), s.updateDisplay(), s;+ }+ return Ci(e, [{+ key: "setValue",+ value: function(n) {+ var s = Qs(e.prototype.__proto__ || Object.getPrototypeOf(e.prototype), "setValue", this).call(this, n);+ return this.__onFinishChange && this.__onFinishChange.call(this, this.getValue()), this.__prev = this.getValue(), s;+ }+ }, {+ key: "updateDisplay",+ value: function() {+ return this.getValue() === !0 ? (this.__checkbox.setAttribute("checked", "checked"), this.__checkbox.checked = !0, this.__prev = !0) : (this.__checkbox.checked = !1, this.__prev = !1), Qs(e.prototype.__proto__ || Object.getPrototypeOf(e.prototype), "updateDisplay", this).call(this);+ }+ }]), e;+})(Tr), D1 = (function(i) {+ Vs(e, i);+ function e(t, n, s) {+ vi(this, e);+ var r = Ws(this, (e.__proto__ || Object.getPrototypeOf(e)).call(this, t, n)), a = s, o = r;+ if (r.__select = document.createElement("select"), ue.isArray(a)) {+ var c = {};+ ue.each(a, function(l) {+ c[l] = l;+ }), a = c;+ }+ return ue.each(a, function(l, h) {+ var u = document.createElement("option");+ u.innerHTML = h, u.setAttribute("value", l), o.__select.appendChild(u);+ }), r.updateDisplay(), te.bind(r.__select, "change", function() {+ var l = this.options[this.selectedIndex].value;+ o.setValue(l);+ }), r.domElement.appendChild(r.__select), r;+ }+ return Ci(e, [{+ key: "setValue",+ value: function(n) {+ var s = Qs(e.prototype.__proto__ || Object.getPrototypeOf(e.prototype), "setValue", this).call(this, n);+ return this.__onFinishChange && this.__onFinishChange.call(this, this.getValue()), s;+ }+ }, {+ key: "updateDisplay",+ value: function() {+ return te.isActive(this.__select) ? this : (this.__select.value = this.getValue(), Qs(e.prototype.__proto__ || Object.getPrototypeOf(e.prototype), "updateDisplay", this).call(this));+ }+ }]), e;+})(Tr), L1 = (function(i) {+ Vs(e, i);+ function e(t, n) {+ vi(this, e);+ var s = Ws(this, (e.__proto__ || Object.getPrototypeOf(e)).call(this, t, n)), r = s;+ function a() {+ r.setValue(r.__input.value);+ }+ function o() {+ r.__onFinishChange && r.__onFinishChange.call(r, r.getValue());+ }+ return s.__input = document.createElement("input"), s.__input.setAttribute("type", "text"), te.bind(s.__input, "keyup", a), te.bind(s.__input, "change", a), te.bind(s.__input, "blur", o), te.bind(s.__input, "keydown", function(c) {+ c.keyCode === 13 && this.blur();+ }), s.updateDisplay(), s.domElement.appendChild(s.__input), s;+ }+ return Ci(e, [{+ key: "updateDisplay",+ value: function() {+ return te.isActive(this.__input) || (this.__input.value = this.getValue()), Qs(e.prototype.__proto__ || Object.getPrototypeOf(e.prototype), "updateDisplay", this).call(this);+ }+ }]), e;+})(Tr);+function kA(i) {+ var e = i.toString();+ return e.indexOf(".") > -1 ? e.length - e.indexOf(".") - 1 : 0;+}+var k0 = (function(i) {+ Vs(e, i);+ function e(t, n, s) {+ vi(this, e);+ var r = Ws(this, (e.__proto__ || Object.getPrototypeOf(e)).call(this, t, n)), a = s || {};+ return r.__min = a.min, r.__max = a.max, r.__step = a.step, ue.isUndefined(r.__step) ? r.initialValue === 0 ? r.__impliedStep = 1 : r.__impliedStep = Math.pow(10, Math.floor(Math.log(Math.abs(r.initialValue)) / Math.LN10)) / 10 : r.__impliedStep = r.__step, r.__precision = kA(r.__impliedStep), r;+ }+ return Ci(e, [{+ key: "setValue",+ value: function(n) {+ var s = n;+ return this.__min !== void 0 && s < this.__min ? s = this.__min : this.__max !== void 0 && s > this.__max && (s = this.__max), this.__step !== void 0 && s % this.__step !== 0 && (s = Math.round(s / this.__step) * this.__step), Qs(e.prototype.__proto__ || Object.getPrototypeOf(e.prototype), "setValue", this).call(this, s);+ }+ }, {+ key: "min",+ value: function(n) {+ return this.__min = n, this;+ }+ }, {+ key: "max",+ value: function(n) {+ return this.__max = n, this;+ }+ }, {+ key: "step",+ value: function(n) {+ return this.__step = n, this.__impliedStep = n, this.__precision = kA(n), this;+ }+ }]), e;+})(Tr);+function P1(i, e) {+ var t = Math.pow(10, e);+ return Math.round(i * t) / t;+}+var Ll = (function(i) {+ Vs(e, i);+ function e(t, n, s) {+ vi(this, e);+ var r = Ws(this, (e.__proto__ || Object.getPrototypeOf(e)).call(this, t, n, s));+ r.__truncationSuspended = !1;+ var a = r, o = void 0;+ function c() {+ var m = parseFloat(a.__input.value);+ ue.isNaN(m) || a.setValue(m);+ }+ function l() {+ a.__onFinishChange && a.__onFinishChange.call(a, a.getValue());+ }+ function h() {+ l();+ }+ function u(m) {+ var A = o - m.clientY;+ a.setValue(a.getValue() + A * a.__impliedStep), o = m.clientY;+ }+ function d() {+ te.unbind(window, "mousemove", u), te.unbind(window, "mouseup", d), l();+ }+ function f(m) {+ te.bind(window, "mousemove", u), te.bind(window, "mouseup", d), o = m.clientY;+ }+ return r.__input = document.createElement("input"), r.__input.setAttribute("type", "text"), te.bind(r.__input, "change", c), te.bind(r.__input, "blur", h), te.bind(r.__input, "mousedown", f), te.bind(r.__input, "keydown", function(m) {+ m.keyCode === 13 && (a.__truncationSuspended = !0, this.blur(), a.__truncationSuspended = !1, l());+ }), r.updateDisplay(), r.domElement.appendChild(r.__input), r;+ }+ return Ci(e, [{+ key: "updateDisplay",+ value: function() {+ return this.__input.value = this.__truncationSuspended ? this.getValue() : P1(this.getValue(), this.__precision), Qs(e.prototype.__proto__ || Object.getPrototypeOf(e.prototype), "updateDisplay", this).call(this);+ }+ }]), e;+})(k0);+function UA(i, e, t, n, s) {+ return n + (s - n) * ((i - e) / (t - e));+}+var Md = (function(i) {+ Vs(e, i);+ function e(t, n, s, r, a) {+ vi(this, e);+ var o = Ws(this, (e.__proto__ || Object.getPrototypeOf(e)).call(this, t, n, { min: s, max: r, step: a })), c = o;+ o.__background = document.createElement("div"), o.__foreground = document.createElement("div"), te.bind(o.__background, "mousedown", l), te.bind(o.__background, "touchstart", d), te.addClass(o.__background, "slider"), te.addClass(o.__foreground, "slider-fg");+ function l(A) {+ document.activeElement.blur(), te.bind(window, "mousemove", h), te.bind(window, "mouseup", u), h(A);+ }+ function h(A) {+ A.preventDefault();+ var g = c.__background.getBoundingClientRect();+ return c.setValue(UA(A.clientX, g.left, g.right, c.__min, c.__max)), !1;+ }+ function u() {+ te.unbind(window, "mousemove", h), te.unbind(window, "mouseup", u), c.__onFinishChange && c.__onFinishChange.call(c, c.getValue());+ }+ function d(A) {+ A.touches.length === 1 && (te.bind(window, "touchmove", f), te.bind(window, "touchend", m), f(A));+ }+ function f(A) {+ var g = A.touches[0].clientX, p = c.__background.getBoundingClientRect();+ c.setValue(UA(g, p.left, p.right, c.__min, c.__max));+ }+ function m() {+ te.unbind(window, "touchmove", f), te.unbind(window, "touchend", m), c.__onFinishChange && c.__onFinishChange.call(c, c.getValue());+ }+ return o.updateDisplay(), o.__background.appendChild(o.__foreground), o.domElement.appendChild(o.__background), o;+ }+ return Ci(e, [{+ key: "updateDisplay",+ value: function() {+ var n = (this.getValue() - this.__min) / (this.__max - this.__min);+ return this.__foreground.style.width = n * 100 + "%", Qs(e.prototype.__proto__ || Object.getPrototypeOf(e.prototype), "updateDisplay", this).call(this);+ }+ }]), e;+})(k0), U0 = (function(i) {+ Vs(e, i);+ function e(t, n, s) {+ vi(this, e);+ var r = Ws(this, (e.__proto__ || Object.getPrototypeOf(e)).call(this, t, n)), a = r;+ return r.__button = document.createElement("div"), r.__button.innerHTML = s === void 0 ? "Fire" : s, te.bind(r.__button, "click", function(o) {+ return o.preventDefault(), a.fire(), !1;+ }), te.addClass(r.__button, "button"), r.domElement.appendChild(r.__button), r;+ }+ return Ci(e, [{+ key: "fire",+ value: function() {+ this.__onChange && this.__onChange.call(this), this.getValue().call(this.object), this.__onFinishChange && this.__onFinishChange.call(this, this.getValue());+ }+ }]), e;+})(Tr), Bd = (function(i) {+ Vs(e, i);+ function e(t, n) {+ vi(this, e);+ var s = Ws(this, (e.__proto__ || Object.getPrototypeOf(e)).call(this, t, n));+ s.__color = new bn(s.getValue()), s.__temp = new bn(0);+ var r = s;+ s.domElement = document.createElement("div"), te.makeSelectable(s.domElement, !1), s.__selector = document.createElement("div"), s.__selector.className = "selector", s.__saturation_field = document.createElement("div"), s.__saturation_field.className = "saturation-field", s.__field_knob = document.createElement("div"), s.__field_knob.className = "field-knob", s.__field_knob_border = "2px solid ", s.__hue_knob = document.createElement("div"), s.__hue_knob.className = "hue-knob", s.__hue_field = document.createElement("div"), s.__hue_field.className = "hue-field", s.__input = document.createElement("input"), s.__input.type = "text", s.__input_textShadow = "0 1px 1px ", te.bind(s.__input, "keydown", function(A) {+ A.keyCode === 13 && u.call(this);+ }), te.bind(s.__input, "blur", u), te.bind(s.__selector, "mousedown", function() {+ te.addClass(this, "drag").bind(window, "mouseup", function() {+ te.removeClass(r.__selector, "drag");+ });+ }), te.bind(s.__selector, "touchstart", function() {+ te.addClass(this, "drag").bind(window, "touchend", function() {+ te.removeClass(r.__selector, "drag");+ });+ });+ var a = document.createElement("div");+ ue.extend(s.__selector.style, {+ width: "122px",+ height: "102px",+ padding: "3px",+ backgroundColor: "#222",+ boxShadow: "0px 1px 3px rgba(0,0,0,0.3)"+ }), ue.extend(s.__field_knob.style, {+ position: "absolute",+ width: "12px",+ height: "12px",+ border: s.__field_knob_border + (s.__color.v < 0.5 ? "#fff" : "#000"),+ boxShadow: "0px 1px 3px rgba(0,0,0,0.5)",+ borderRadius: "12px",+ zIndex: 1+ }), ue.extend(s.__hue_knob.style, {+ position: "absolute",+ width: "15px",+ height: "2px",+ borderRight: "4px solid #fff",+ zIndex: 1+ }), ue.extend(s.__saturation_field.style, {+ width: "100px",+ height: "100px",+ border: "1px solid #555",+ marginRight: "3px",+ display: "inline-block",+ cursor: "pointer"+ }), ue.extend(a.style, {+ width: "100%",+ height: "100%",+ background: "none"+ }), OA(a, "top", "rgba(0,0,0,0)", "#000"), ue.extend(s.__hue_field.style, {+ width: "15px",+ height: "100px",+ border: "1px solid #555",+ cursor: "ns-resize",+ position: "absolute",+ top: "3px",+ right: "3px"+ }), U1(s.__hue_field), ue.extend(s.__input.style, {+ outline: "none",+ textAlign: "center",+ color: "#fff",+ border: 0,+ fontWeight: "bold",+ textShadow: s.__input_textShadow + "rgba(0,0,0,0.7)"+ }), te.bind(s.__saturation_field, "mousedown", o), te.bind(s.__saturation_field, "touchstart", o), te.bind(s.__field_knob, "mousedown", o), te.bind(s.__field_knob, "touchstart", o), te.bind(s.__hue_field, "mousedown", c), te.bind(s.__hue_field, "touchstart", c);+ function o(A) {+ f(A), te.bind(window, "mousemove", f), te.bind(window, "touchmove", f), te.bind(window, "mouseup", l), te.bind(window, "touchend", l);+ }+ function c(A) {+ m(A), te.bind(window, "mousemove", m), te.bind(window, "touchmove", m), te.bind(window, "mouseup", h), te.bind(window, "touchend", h);+ }+ function l() {+ te.unbind(window, "mousemove", f), te.unbind(window, "touchmove", f), te.unbind(window, "mouseup", l), te.unbind(window, "touchend", l), d();+ }+ function h() {+ te.unbind(window, "mousemove", m), te.unbind(window, "touchmove", m), te.unbind(window, "mouseup", h), te.unbind(window, "touchend", h), d();+ }+ function u() {+ var A = Id(this.value);+ A !== !1 ? (r.__color.__state = A, r.setValue(r.__color.toOriginal())) : this.value = r.__color.toString();+ }+ function d() {+ r.__onFinishChange && r.__onFinishChange.call(r, r.__color.toOriginal());+ }+ s.__saturation_field.appendChild(a), s.__selector.appendChild(s.__field_knob), s.__selector.appendChild(s.__saturation_field), s.__selector.appendChild(s.__hue_field), s.__hue_field.appendChild(s.__hue_knob), s.domElement.appendChild(s.__input), s.domElement.appendChild(s.__selector), s.updateDisplay();+ function f(A) {+ A.type.indexOf("touch") === -1 && A.preventDefault();+ var g = r.__saturation_field.getBoundingClientRect(), p = A.touches && A.touches[0] || A, y = p.clientX, b = p.clientY, E = (y - g.left) / (g.right - g.left), M = 1 - (b - g.top) / (g.bottom - g.top);+ return M > 1 ? M = 1 : M < 0 && (M = 0), E > 1 ? E = 1 : E < 0 && (E = 0), r.__color.v = M, r.__color.s = E, r.setValue(r.__color.toOriginal()), !1;+ }+ function m(A) {+ A.type.indexOf("touch") === -1 && A.preventDefault();+ var g = r.__hue_field.getBoundingClientRect(), p = A.touches && A.touches[0] || A, y = p.clientY, b = 1 - (y - g.top) / (g.bottom - g.top);+ return b > 1 ? b = 1 : b < 0 && (b = 0), r.__color.h = b * 360, r.setValue(r.__color.toOriginal()), !1;+ }+ return s;+ }+ return Ci(e, [{+ key: "updateDisplay",+ value: function() {+ var n = Id(this.getValue());+ if (n !== !1) {+ var s = !1;+ ue.each(bn.COMPONENTS, function(o) {+ if (!ue.isUndefined(n[o]) && !ue.isUndefined(this.__color.__state[o]) && n[o] !== this.__color.__state[o])+ return s = !0, {};+ }, this), s && ue.extend(this.__color.__state, n);+ }+ ue.extend(this.__temp.__state, this.__color.__state), this.__temp.a = 1;+ var r = this.__color.v < 0.5 || this.__color.s > 0.5 ? 255 : 0, a = 255 - r;+ ue.extend(this.__field_knob.style, {+ marginLeft: 100 * this.__color.s - 7 + "px",+ marginTop: 100 * (1 - this.__color.v) - 7 + "px",+ backgroundColor: this.__temp.toHexString(),+ border: this.__field_knob_border + "rgb(" + r + "," + r + "," + r + ")"+ }), this.__hue_knob.style.marginTop = (1 - this.__color.h / 360) * 100 + "px", this.__temp.s = 1, this.__temp.v = 1, OA(this.__saturation_field, "left", "#fff", this.__temp.toHexString()), this.__input.value = this.__color.toString(), ue.extend(this.__input.style, {+ backgroundColor: this.__color.toHexString(),+ color: "rgb(" + r + "," + r + "," + r + ")",+ textShadow: this.__input_textShadow + "rgba(" + a + "," + a + "," + a + ",.7)"+ });+ }+ }]), e;+})(Tr), k1 = ["-moz-", "-o-", "-webkit-", "-ms-", ""];+function OA(i, e, t, n) {+ i.style.background = "", ue.each(k1, function(s) {+ i.style.cssText += "background: " + s + "linear-gradient(" + e + ", " + t + " 0%, " + n + " 100%); ";+ });+}+function U1(i) {+ i.style.background = "", i.style.cssText += "background: -moz-linear-gradient(top, #ff0000 0%, #ff00ff 17%, #0000ff 34%, #00ffff 50%, #00ff00 67%, #ffff00 84%, #ff0000 100%);", i.style.cssText += "background: -webkit-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);", i.style.cssText += "background: -o-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);", i.style.cssText += "background: -ms-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);", i.style.cssText += "background: linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);";+}+var O1 = {+ load: function(e, t) {+ var n = t || document, s = n.createElement("link");+ s.type = "text/css", s.rel = "stylesheet", s.href = e, n.getElementsByTagName("head")[0].appendChild(s);+ },+ inject: function(e, t) {+ var n = t || document, s = document.createElement("style");+ s.type = "text/css", s.innerHTML = e;+ var r = n.getElementsByTagName("head")[0];+ try {+ r.appendChild(s);+ } catch {+ }+ }+}, Q1 = `<div id="dg-save" class="dg dialogue">++ Here's the new load parameter for your <code>GUI</code>'s constructor:++ <textarea id="dg-new-constructor"></textarea>++ <div id="dg-save-locally">++ <input id="dg-local-storage" type="checkbox"/> Automatically save+ values to <code>localStorage</code> on exit.++ <div id="dg-local-explain">The values saved to <code>localStorage</code> will+ override those passed to <code>dat.GUI</code>'s constructor. This makes it+ easier to work incrementally, but <code>localStorage</code> is fragile,+ and your friends may not see the same values you do.++ </div>++ </div>++</div>`, G1 = function(e, t) {+ var n = e[t];+ return ue.isArray(arguments[2]) || ue.isObject(arguments[2]) ? new D1(e, t, arguments[2]) : ue.isNumber(n) ? ue.isNumber(arguments[2]) && ue.isNumber(arguments[3]) ? ue.isNumber(arguments[4]) ? new Md(e, t, arguments[2], arguments[3], arguments[4]) : new Md(e, t, arguments[2], arguments[3]) : ue.isNumber(arguments[4]) ? new Ll(e, t, { min: arguments[2], max: arguments[3], step: arguments[4] }) : new Ll(e, t, { min: arguments[2], max: arguments[3] }) : ue.isString(n) ? new L1(e, t) : ue.isFunction(n) ? new U0(e, t, "") : ue.isBoolean(n) ? new P0(e, t) : null;+};+function H1(i) {+ setTimeout(i, 1e3 / 60);+}+var z1 = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || H1, V1 = (function() {+ function i() {+ vi(this, i), this.backgroundElement = document.createElement("div"), ue.extend(this.backgroundElement.style, {+ backgroundColor: "rgba(0,0,0,0.8)",+ top: 0,+ left: 0,+ display: "none",+ zIndex: "1000",+ opacity: 0,+ WebkitTransition: "opacity 0.2s linear",+ transition: "opacity 0.2s linear"+ }), te.makeFullscreen(this.backgroundElement), this.backgroundElement.style.position = "fixed", this.domElement = document.createElement("div"), ue.extend(this.domElement.style, {+ position: "fixed",+ display: "none",+ zIndex: "1001",+ opacity: 0,+ WebkitTransition: "-webkit-transform 0.2s ease-out, opacity 0.2s linear",+ transition: "transform 0.2s ease-out, opacity 0.2s linear"+ }), document.body.appendChild(this.backgroundElement), document.body.appendChild(this.domElement);+ var e = this;+ te.bind(this.backgroundElement, "click", function() {+ e.hide();+ });+ }+ return Ci(i, [{+ key: "show",+ value: function() {+ var t = this;+ this.backgroundElement.style.display = "block", this.domElement.style.display = "block", this.domElement.style.opacity = 0, this.domElement.style.webkitTransform = "scale(1.1)", this.layout(), ue.defer(function() {+ t.backgroundElement.style.opacity = 1, t.domElement.style.opacity = 1, t.domElement.style.webkitTransform = "scale(1)";+ });+ }+ }, {+ key: "hide",+ value: function() {+ var t = this, n = function s() {+ t.domElement.style.display = "none", t.backgroundElement.style.display = "none", te.unbind(t.domElement, "webkitTransitionEnd", s), te.unbind(t.domElement, "transitionend", s), te.unbind(t.domElement, "oTransitionEnd", s);+ };+ te.bind(this.domElement, "webkitTransitionEnd", n), te.bind(this.domElement, "transitionend", n), te.bind(this.domElement, "oTransitionEnd", n), this.backgroundElement.style.opacity = 0, this.domElement.style.opacity = 0, this.domElement.style.webkitTransform = "scale(1.1)";+ }+ }, {+ key: "layout",+ value: function() {+ this.domElement.style.left = window.innerWidth / 2 - te.getWidth(this.domElement) / 2 + "px", this.domElement.style.top = window.innerHeight / 2 - te.getHeight(this.domElement) / 2 + "px";+ }+ }]), i;+})(), W1 = B1(`.dg ul{list-style:none;margin:0;padding:0;width:100%;clear:both}.dg.ac{position:fixed;top:0;left:0;right:0;height:0;z-index:0}.dg:not(.ac) .main{overflow:hidden}.dg.main{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear}.dg.main.taller-than-window{overflow-y:auto}.dg.main.taller-than-window .close-button{opacity:1;margin-top:-1px;border-top:1px solid #2c2c2c}.dg.main ul.closed .close-button{opacity:1 !important}.dg.main:hover .close-button,.dg.main .close-button.drag{opacity:1}.dg.main .close-button{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear;border:0;line-height:19px;height:20px;cursor:pointer;text-align:center;background-color:#000}.dg.main .close-button.close-top{position:relative}.dg.main .close-button.close-bottom{position:absolute}.dg.main .close-button:hover{background-color:#111}.dg.a{float:right;margin-right:15px;overflow-y:visible}.dg.a.has-save>ul.close-top{margin-top:0}.dg.a.has-save>ul.close-bottom{margin-top:27px}.dg.a.has-save>ul.closed{margin-top:0}.dg.a .save-row{top:0;z-index:1002}.dg.a .save-row.close-top{position:relative}.dg.a .save-row.close-bottom{position:fixed}.dg li{-webkit-transition:height .1s ease-out;-o-transition:height .1s ease-out;-moz-transition:height .1s ease-out;transition:height .1s ease-out;-webkit-transition:overflow .1s linear;-o-transition:overflow .1s linear;-moz-transition:overflow .1s linear;transition:overflow .1s linear}.dg li:not(.folder){cursor:auto;height:27px;line-height:27px;padding:0 4px 0 5px}.dg li.folder{padding:0;border-left:4px solid rgba(0,0,0,0)}.dg li.title{cursor:pointer;margin-left:-4px}.dg .closed li:not(.title),.dg .closed ul li,.dg .closed ul li>*{height:0;overflow:hidden;border:0}.dg .cr{clear:both;padding-left:3px;height:27px;overflow:hidden}.dg .property-name{cursor:default;float:left;clear:left;width:40%;overflow:hidden;text-overflow:ellipsis}.dg .cr.function .property-name{width:100%}.dg .c{float:left;width:60%;position:relative}.dg .c input[type=text]{border:0;margin-top:4px;padding:3px;width:100%;float:right}.dg .has-slider input[type=text]{width:30%;margin-left:0}.dg .slider{float:left;width:66%;margin-left:-5px;margin-right:0;height:19px;margin-top:4px}.dg .slider-fg{height:100%}.dg .c input[type=checkbox]{margin-top:7px}.dg .c select{margin-top:5px}.dg .cr.function,.dg .cr.function .property-name,.dg .cr.function *,.dg .cr.boolean,.dg .cr.boolean *{cursor:pointer}.dg .cr.color{overflow:visible}.dg .selector{display:none;position:absolute;margin-left:-9px;margin-top:23px;z-index:10}.dg .c:hover .selector,.dg .selector.drag{display:block}.dg li.save-row{padding:0}.dg li.save-row .button{display:inline-block;padding:0px 6px}.dg.dialogue{background-color:#222;width:460px;padding:15px;font-size:13px;line-height:15px}#dg-new-constructor{padding:10px;color:#222;font-family:Monaco, monospace;font-size:10px;border:0;resize:none;box-shadow:inset 1px 1px 1px #888;word-wrap:break-word;margin:12px 0;display:block;width:440px;overflow-y:scroll;height:100px;position:relative}#dg-local-explain{display:none;font-size:11px;line-height:17px;border-radius:3px;background-color:#333;padding:8px;margin-top:10px}#dg-local-explain code{font-size:10px}#dat-gui-save-locally{display:none}.dg{color:#eee;font:11px 'Lucida Grande', sans-serif;text-shadow:0 -1px 0 #111}.dg.main::-webkit-scrollbar{width:5px;background:#1a1a1a}.dg.main::-webkit-scrollbar-corner{height:0;display:none}.dg.main::-webkit-scrollbar-thumb{border-radius:5px;background:#676767}.dg li:not(.folder){background:#1a1a1a;border-bottom:1px solid #2c2c2c}.dg li.save-row{line-height:25px;background:#dad5cb;border:0}.dg li.save-row select{margin-left:5px;width:108px}.dg li.save-row .button{margin-left:5px;margin-top:1px;border-radius:2px;font-size:9px;line-height:7px;padding:4px 4px 5px 4px;background:#c5bdad;color:#fff;text-shadow:0 1px 0 #b0a58f;box-shadow:0 -1px 0 #b0a58f;cursor:pointer}.dg li.save-row .button.gears{background:#c5bdad url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAANCAYAAAB/9ZQ7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQJJREFUeNpiYKAU/P//PwGIC/ApCABiBSAW+I8AClAcgKxQ4T9hoMAEUrxx2QSGN6+egDX+/vWT4e7N82AMYoPAx/evwWoYoSYbACX2s7KxCxzcsezDh3evFoDEBYTEEqycggWAzA9AuUSQQgeYPa9fPv6/YWm/Acx5IPb7ty/fw+QZblw67vDs8R0YHyQhgObx+yAJkBqmG5dPPDh1aPOGR/eugW0G4vlIoTIfyFcA+QekhhHJhPdQxbiAIguMBTQZrPD7108M6roWYDFQiIAAv6Aow/1bFwXgis+f2LUAynwoIaNcz8XNx3Dl7MEJUDGQpx9gtQ8YCueB+D26OECAAQDadt7e46D42QAAAABJRU5ErkJggg==) 2px 1px no-repeat;height:7px;width:8px}.dg li.save-row .button:hover{background-color:#bab19e;box-shadow:0 -1px 0 #b0a58f}.dg li.folder{border-bottom:0}.dg li.title{padding-left:16px;background:#000 url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlI+hKgFxoCgAOw==) 6px 10px no-repeat;cursor:pointer;border-bottom:1px solid rgba(255,255,255,0.2)}.dg .closed li.title{background-image:url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlGIWqMCbWAEAOw==)}.dg .cr.boolean{border-left:3px solid #806787}.dg .cr.color{border-left:3px solid}.dg .cr.function{border-left:3px solid #e61d5f}.dg .cr.number{border-left:3px solid #2FA1D6}.dg .cr.number input[type=text]{color:#2FA1D6}.dg .cr.string{border-left:3px solid #1ed36f}.dg .cr.string input[type=text]{color:#1ed36f}.dg .cr.function:hover,.dg .cr.boolean:hover{background:#111}.dg .c input[type=text]{background:#303030;outline:none}.dg .c input[type=text]:hover{background:#3c3c3c}.dg .c input[type=text]:focus{background:#494949;color:#fff}.dg .c .slider{background:#303030;cursor:ew-resize}.dg .c .slider-fg{background:#2FA1D6;max-width:100%}.dg .c .slider:hover{background:#3c3c3c}.dg .c .slider:hover .slider-fg{background:#44abda}+`);+O1.inject(W1);+var QA = "dg", GA = 72, HA = 20, Qo = "Default", Ao = (function() {+ try {+ return !!window.localStorage;+ } catch {+ return !1;+ }+})(), Co = void 0, zA = !0, ta = void 0, su = !1, O0 = [], Dt = function i(e) {+ var t = this, n = e || {};+ this.domElement = document.createElement("div"), this.__ul = document.createElement("ul"), this.domElement.appendChild(this.__ul), te.addClass(this.domElement, QA), this.__folders = {}, this.__controllers = [], this.__rememberedObjects = [], this.__rememberedObjectIndecesToControllers = [], this.__listening = [], n = ue.defaults(n, {+ closeOnTop: !1,+ autoPlace: !0,+ width: i.DEFAULT_WIDTH+ }), n = ue.defaults(n, {+ resizable: n.autoPlace,+ hideable: n.autoPlace+ }), ue.isUndefined(n.load) ? n.load = { preset: Qo } : n.preset && (n.load.preset = n.preset), ue.isUndefined(n.parent) && n.hideable && O0.push(this), n.resizable = ue.isUndefined(n.parent) && n.resizable, n.autoPlace && ue.isUndefined(n.scrollable) && (n.scrollable = !0);+ var s = Ao && localStorage.getItem(na(this, "isLocal")) === "true", r = void 0, a = void 0;+ if (Object.defineProperties(+ this,+ {+ parent: {+ get: function() {+ return n.parent;+ }+ },+ scrollable: {+ get: function() {+ return n.scrollable;+ }+ },+ autoPlace: {+ get: function() {+ return n.autoPlace;+ }+ },+ closeOnTop: {+ get: function() {+ return n.closeOnTop;+ }+ },+ preset: {+ get: function() {+ return t.parent ? t.getRoot().preset : n.load.preset;+ },+ set: function(d) {+ t.parent ? t.getRoot().preset = d : n.load.preset = d, X1(this), t.revert();+ }+ },+ width: {+ get: function() {+ return n.width;+ },+ set: function(d) {+ n.width = d, Nd(t, d);+ }+ },+ name: {+ get: function() {+ return n.name;+ },+ set: function(d) {+ n.name = d, a && (a.innerHTML = n.name);+ }+ },+ closed: {+ get: function() {+ return n.closed;+ },+ set: function(d) {+ n.closed = d, n.closed ? te.addClass(t.__ul, i.CLASS_CLOSED) : te.removeClass(t.__ul, i.CLASS_CLOSED), this.onResize(), t.__closeButton && (t.__closeButton.innerHTML = d ? i.TEXT_OPEN : i.TEXT_CLOSED);+ }+ },+ load: {+ get: function() {+ return n.load;+ }+ },+ useLocalStorage: {+ get: function() {+ return s;+ },+ set: function(d) {+ Ao && (s = d, d ? te.bind(window, "unload", r) : te.unbind(window, "unload", r), localStorage.setItem(na(t, "isLocal"), d));+ }+ }+ }+ ), ue.isUndefined(n.parent)) {+ if (this.closed = n.closed || !1, te.addClass(this.domElement, i.CLASS_MAIN), te.makeSelectable(this.domElement, !1), Ao && s) {+ t.useLocalStorage = !0;+ var o = localStorage.getItem(na(this, "gui"));+ o && (n.load = JSON.parse(o));+ }+ this.__closeButton = document.createElement("div"), this.__closeButton.innerHTML = i.TEXT_CLOSED, te.addClass(this.__closeButton, i.CLASS_CLOSE_BUTTON), n.closeOnTop ? (te.addClass(this.__closeButton, i.CLASS_CLOSE_TOP), this.domElement.insertBefore(this.__closeButton, this.domElement.childNodes[0])) : (te.addClass(this.__closeButton, i.CLASS_CLOSE_BOTTOM), this.domElement.appendChild(this.__closeButton)), te.bind(this.__closeButton, "click", function() {+ t.closed = !t.closed;+ });+ } else {+ n.closed === void 0 && (n.closed = !0);+ var c = document.createTextNode(n.name);+ te.addClass(c, "controller-name"), a = Lf(t, c);+ var l = function(d) {+ return d.preventDefault(), t.closed = !t.closed, !1;+ };+ te.addClass(this.__ul, i.CLASS_CLOSED), te.addClass(a, "title"), te.bind(a, "click", l), n.closed || (this.closed = !1);+ }+ n.autoPlace && (ue.isUndefined(n.parent) && (zA && (ta = document.createElement("div"), te.addClass(ta, QA), te.addClass(ta, i.CLASS_AUTO_PLACE_CONTAINER), document.body.appendChild(ta), zA = !1), ta.appendChild(this.domElement), te.addClass(this.domElement, i.CLASS_AUTO_PLACE)), this.parent || Nd(t, n.width)), this.__resizeHandler = function() {+ t.onResizeDebounced();+ }, te.bind(window, "resize", this.__resizeHandler), te.bind(this.__ul, "webkitTransitionEnd", this.__resizeHandler), te.bind(this.__ul, "transitionend", this.__resizeHandler), te.bind(this.__ul, "oTransitionEnd", this.__resizeHandler), this.onResize(), n.resizable && j1(this), r = function() {+ Ao && localStorage.getItem(na(t, "isLocal")) === "true" && localStorage.setItem(na(t, "gui"), JSON.stringify(t.getSaveObject()));+ }, this.saveToLocalStorageIfPossible = r;+ function h() {+ var u = t.getRoot();+ u.width += 1, ue.defer(function() {+ u.width -= 1;+ });+ }+ n.parent || h();+};+Dt.toggleHide = function() {+ su = !su, ue.each(O0, function(i) {+ i.domElement.style.display = su ? "none" : "";+ });+};+Dt.CLASS_AUTO_PLACE = "a";+Dt.CLASS_AUTO_PLACE_CONTAINER = "ac";+Dt.CLASS_MAIN = "main";+Dt.CLASS_CONTROLLER_ROW = "cr";+Dt.CLASS_TOO_TALL = "taller-than-window";+Dt.CLASS_CLOSED = "closed";+Dt.CLASS_CLOSE_BUTTON = "close-button";+Dt.CLASS_CLOSE_TOP = "close-top";+Dt.CLASS_CLOSE_BOTTOM = "close-bottom";+Dt.CLASS_DRAG = "drag";+Dt.DEFAULT_WIDTH = 245;+Dt.TEXT_CLOSED = "Close Controls";+Dt.TEXT_OPEN = "Open Controls";+Dt._keydownHandler = function(i) {+ document.activeElement.type !== "text" && (i.which === GA || i.keyCode === GA) && Dt.toggleHide();+};+te.bind(window, "keydown", Dt._keydownHandler, !1);+ue.extend(+ Dt.prototype,+ {+ add: function(e, t) {+ return So(this, e, t, {+ factoryArgs: Array.prototype.slice.call(arguments, 2)+ });+ },+ addColor: function(e, t) {+ return So(this, e, t, {+ color: !0+ });+ },+ remove: function(e) {+ this.__ul.removeChild(e.__li), this.__controllers.splice(this.__controllers.indexOf(e), 1);+ var t = this;+ ue.defer(function() {+ t.onResize();+ });+ },+ destroy: function() {+ if (this.parent)+ throw new Error("Only the root GUI should be removed with .destroy(). For subfolders, use gui.removeFolder(folder) instead.");+ this.autoPlace && ta.removeChild(this.domElement);+ var e = this;+ ue.each(this.__folders, function(t) {+ e.removeFolder(t);+ }), te.unbind(window, "keydown", Dt._keydownHandler, !1), VA(this);+ },+ addFolder: function(e) {+ if (this.__folders[e] !== void 0)+ throw new Error('You already have a folder in this GUI by the name "' + e + '"');+ var t = { name: e, parent: this };+ t.autoPlace = this.autoPlace, this.load && this.load.folders && this.load.folders[e] && (t.closed = this.load.folders[e].closed, t.load = this.load.folders[e]);+ var n = new Dt(t);+ this.__folders[e] = n;+ var s = Lf(this, n.domElement);+ return te.addClass(s, "folder"), n;+ },+ removeFolder: function(e) {+ this.__ul.removeChild(e.domElement.parentElement), delete this.__folders[e.name], this.load && this.load.folders && this.load.folders[e.name] && delete this.load.folders[e.name], VA(e);+ var t = this;+ ue.each(e.__folders, function(n) {+ e.removeFolder(n);+ }), ue.defer(function() {+ t.onResize();+ });+ },+ open: function() {+ this.closed = !1;+ },+ close: function() {+ this.closed = !0;+ },+ hide: function() {+ this.domElement.style.display = "none";+ },+ show: function() {+ this.domElement.style.display = "";+ },+ onResize: function() {+ var e = this.getRoot();+ if (e.scrollable) {+ var t = te.getOffset(e.__ul).top, n = 0;+ ue.each(e.__ul.childNodes, function(s) {+ e.autoPlace && s === e.__save_row || (n += te.getHeight(s));+ }), window.innerHeight - t - HA < n ? (te.addClass(e.domElement, Dt.CLASS_TOO_TALL), e.__ul.style.height = window.innerHeight - t - HA + "px") : (te.removeClass(e.domElement, Dt.CLASS_TOO_TALL), e.__ul.style.height = "auto");+ }+ e.__resize_handle && ue.defer(function() {+ e.__resize_handle.style.height = e.__ul.offsetHeight + "px";+ }), e.__closeButton && (e.__closeButton.style.width = e.width + "px");+ },+ onResizeDebounced: ue.debounce(function() {+ this.onResize();+ }, 50),+ remember: function() {+ if (ue.isUndefined(Co) && (Co = new V1(), Co.domElement.innerHTML = Q1), this.parent)+ throw new Error("You can only call remember on a top level GUI.");+ var e = this;+ ue.each(Array.prototype.slice.call(arguments), function(t) {+ e.__rememberedObjects.length === 0 && K1(e), e.__rememberedObjects.indexOf(t) === -1 && e.__rememberedObjects.push(t);+ }), this.autoPlace && Nd(this, this.width);+ },+ getRoot: function() {+ for (var e = this; e.parent; )+ e = e.parent;+ return e;+ },+ getSaveObject: function() {+ var e = this.load;+ return e.closed = this.closed, this.__rememberedObjects.length > 0 && (e.preset = this.preset, e.remembered || (e.remembered = {}), e.remembered[this.preset] = zc(this)), e.folders = {}, ue.each(this.__folders, function(t, n) {+ e.folders[n] = t.getSaveObject();+ }), e;+ },+ save: function() {+ this.load.remembered || (this.load.remembered = {}), this.load.remembered[this.preset] = zc(this), Td(this, !1), this.saveToLocalStorageIfPossible();+ },+ saveAs: function(e) {+ this.load.remembered || (this.load.remembered = {}, this.load.remembered[Qo] = zc(this, !0)), this.load.remembered[e] = zc(this), this.preset = e, Rd(this, e, !0), this.saveToLocalStorageIfPossible();+ },+ revert: function(e) {+ ue.each(this.__controllers, function(t) {+ this.getRoot().load.remembered ? Q0(e || this.getRoot(), t) : t.setValue(t.initialValue), t.__onFinishChange && t.__onFinishChange.call(t, t.getValue());+ }, this), ue.each(this.__folders, function(t) {+ t.revert(t);+ }), e || Td(this.getRoot(), !1);+ },+ listen: function(e) {+ var t = this.__listening.length === 0;+ this.__listening.push(e), t && G0(this.__listening);+ },+ updateDisplay: function() {+ ue.each(this.__controllers, function(e) {+ e.updateDisplay();+ }), ue.each(this.__folders, function(e) {+ e.updateDisplay();+ });+ }+ }+);+function Lf(i, e, t) {+ var n = document.createElement("li");+ return e && n.appendChild(e), t ? i.__ul.insertBefore(n, t) : i.__ul.appendChild(n), i.onResize(), n;+}+function VA(i) {+ te.unbind(window, "resize", i.__resizeHandler), i.saveToLocalStorageIfPossible && te.unbind(window, "unload", i.saveToLocalStorageIfPossible);+}+function Td(i, e) {+ var t = i.__preset_select[i.__preset_select.selectedIndex];+ e ? t.innerHTML = t.value + "*" : t.innerHTML = t.value;+}+function q1(i, e, t) {+ if (t.__li = e, t.__gui = i, ue.extend(t, {+ options: function(a) {+ if (arguments.length > 1) {+ var o = t.__li.nextElementSibling;+ return t.remove(), So(i, t.object, t.property, {+ before: o,+ factoryArgs: [ue.toArray(arguments)]+ });+ }+ if (ue.isArray(a) || ue.isObject(a)) {+ var c = t.__li.nextElementSibling;+ return t.remove(), So(i, t.object, t.property, {+ before: c,+ factoryArgs: [a]+ });+ }+ },+ name: function(a) {+ return t.__li.firstElementChild.firstElementChild.innerHTML = a, t;+ },+ listen: function() {+ return t.__gui.listen(t), t;+ },+ remove: function() {+ return t.__gui.remove(t), t;+ }+ }), t instanceof Md) {+ var n = new Ll(t.object, t.property, { min: t.__min, max: t.__max, step: t.__step });+ ue.each(["updateDisplay", "onChange", "onFinishChange", "step", "min", "max"], function(r) {+ var a = t[r], o = n[r];+ t[r] = n[r] = function() {+ var c = Array.prototype.slice.call(arguments);+ return o.apply(n, c), a.apply(t, c);+ };+ }), te.addClass(e, "has-slider"), t.domElement.insertBefore(n.domElement, t.domElement.firstElementChild);+ } else if (t instanceof Ll) {+ var s = function(a) {+ if (ue.isNumber(t.__min) && ue.isNumber(t.__max)) {+ var o = t.__li.firstElementChild.firstElementChild.innerHTML, c = t.__gui.__listening.indexOf(t) > -1;+ t.remove();+ var l = So(i, t.object, t.property, {+ before: t.__li.nextElementSibling,+ factoryArgs: [t.__min, t.__max, t.__step]+ });+ return l.name(o), c && l.listen(), l;+ }+ return a;+ };+ t.min = ue.compose(s, t.min), t.max = ue.compose(s, t.max);+ } else t instanceof P0 ? (te.bind(e, "click", function() {+ te.fakeEvent(t.__checkbox, "click");+ }), te.bind(t.__checkbox, "click", function(r) {+ r.stopPropagation();+ })) : t instanceof U0 ? (te.bind(e, "click", function() {+ te.fakeEvent(t.__button, "click");+ }), te.bind(e, "mouseover", function() {+ te.addClass(t.__button, "hover");+ }), te.bind(e, "mouseout", function() {+ te.removeClass(t.__button, "hover");+ })) : t instanceof Bd && (te.addClass(e, "color"), t.updateDisplay = ue.compose(function(r) {+ return e.style.borderLeftColor = t.__color.toString(), r;+ }, t.updateDisplay), t.updateDisplay());+ t.setValue = ue.compose(function(r) {+ return i.getRoot().__preset_select && t.isModified() && Td(i.getRoot(), !0), r;+ }, t.setValue);+}+function Q0(i, e) {+ var t = i.getRoot(), n = t.__rememberedObjects.indexOf(e.object);+ if (n !== -1) {+ var s = t.__rememberedObjectIndecesToControllers[n];+ if (s === void 0 && (s = {}, t.__rememberedObjectIndecesToControllers[n] = s), s[e.property] = e, t.load && t.load.remembered) {+ var r = t.load.remembered, a = void 0;+ if (r[i.preset])+ a = r[i.preset];+ else if (r[Qo])+ a = r[Qo];+ else+ return;+ if (a[n] && a[n][e.property] !== void 0) {+ var o = a[n][e.property];+ e.initialValue = o, e.setValue(o);+ }+ }+ }+}+function So(i, e, t, n) {+ if (e[t] === void 0)+ throw new Error('Object "' + e + '" has no property "' + t + '"');+ var s = void 0;+ if (n.color)+ s = new Bd(e, t);+ else {+ var r = [e, t].concat(n.factoryArgs);+ s = G1.apply(i, r);+ }+ n.before instanceof Tr && (n.before = n.before.__li), Q0(i, s), te.addClass(s.domElement, "c");+ var a = document.createElement("span");+ te.addClass(a, "property-name"), a.innerHTML = s.property;+ var o = document.createElement("div");+ o.appendChild(a), o.appendChild(s.domElement);+ var c = Lf(i, o, n.before);+ return te.addClass(c, Dt.CLASS_CONTROLLER_ROW), s instanceof Bd ? te.addClass(c, "color") : te.addClass(c, R1(s.getValue())), q1(i, c, s), i.__controllers.push(s), s;+}+function na(i, e) {+ return document.location.href + "." + e;+}+function Rd(i, e, t) {+ var n = document.createElement("option");+ n.innerHTML = e, n.value = e, i.__preset_select.appendChild(n), t && (i.__preset_select.selectedIndex = i.__preset_select.length - 1);+}+function WA(i, e) {+ e.style.display = i.useLocalStorage ? "block" : "none";+}+function K1(i) {+ var e = i.__save_row = document.createElement("li");+ te.addClass(i.domElement, "has-save"), i.__ul.insertBefore(e, i.__ul.firstChild), te.addClass(e, "save-row");+ var t = document.createElement("span");+ t.innerHTML = " ", te.addClass(t, "button gears");+ var n = document.createElement("span");+ n.innerHTML = "Save", te.addClass(n, "button"), te.addClass(n, "save");+ var s = document.createElement("span");+ s.innerHTML = "New", te.addClass(s, "button"), te.addClass(s, "save-as");+ var r = document.createElement("span");+ r.innerHTML = "Revert", te.addClass(r, "button"), te.addClass(r, "revert");+ var a = i.__preset_select = document.createElement("select");+ if (i.load && i.load.remembered ? ue.each(i.load.remembered, function(u, d) {+ Rd(i, d, d === i.preset);+ }) : Rd(i, Qo, !1), te.bind(a, "change", function() {+ for (var u = 0; u < i.__preset_select.length; u++)+ i.__preset_select[u].innerHTML = i.__preset_select[u].value;+ i.preset = this.value;+ }), e.appendChild(a), e.appendChild(t), e.appendChild(n), e.appendChild(s), e.appendChild(r), Ao) {+ var o = document.getElementById("dg-local-explain"), c = document.getElementById("dg-local-storage"), l = document.getElementById("dg-save-locally");+ l.style.display = "block", localStorage.getItem(na(i, "isLocal")) === "true" && c.setAttribute("checked", "checked"), WA(i, o), te.bind(c, "change", function() {+ i.useLocalStorage = !i.useLocalStorage, WA(i, o);+ });+ }+ var h = document.getElementById("dg-new-constructor");+ te.bind(h, "keydown", function(u) {+ u.metaKey && (u.which === 67 || u.keyCode === 67) && Co.hide();+ }), te.bind(t, "click", function() {+ h.innerHTML = JSON.stringify(i.getSaveObject(), void 0, 2), Co.show(), h.focus(), h.select();+ }), te.bind(n, "click", function() {+ i.save();+ }), te.bind(s, "click", function() {+ var u = prompt("Enter a new preset name.");+ u && i.saveAs(u);+ }), te.bind(r, "click", function() {+ i.revert();+ });+}+function j1(i) {+ var e = void 0;+ i.__resize_handle = document.createElement("div"), ue.extend(i.__resize_handle.style, {+ width: "6px",+ marginLeft: "-3px",+ height: "200px",+ cursor: "ew-resize",+ position: "absolute"+ });+ function t(r) {+ return r.preventDefault(), i.width += e - r.clientX, i.onResize(), e = r.clientX, !1;+ }+ function n() {+ te.removeClass(i.__closeButton, Dt.CLASS_DRAG), te.unbind(window, "mousemove", t), te.unbind(window, "mouseup", n);+ }+ function s(r) {+ return r.preventDefault(), e = r.clientX, te.addClass(i.__closeButton, Dt.CLASS_DRAG), te.bind(window, "mousemove", t), te.bind(window, "mouseup", n), !1;+ }+ te.bind(i.__resize_handle, "mousedown", s), te.bind(i.__closeButton, "mousedown", s), i.domElement.insertBefore(i.__resize_handle, i.domElement.firstElementChild);+}+function Nd(i, e) {+ i.domElement.style.width = e + "px", i.__save_row && i.autoPlace && (i.__save_row.style.width = e + "px"), i.__closeButton && (i.__closeButton.style.width = e + "px");+}+function zc(i, e) {+ var t = {};+ return ue.each(i.__rememberedObjects, function(n, s) {+ var r = {}, a = i.__rememberedObjectIndecesToControllers[s];+ ue.each(a, function(o, c) {+ r[c] = e ? o.initialValue : o.getValue();+ }), t[s] = r;+ }), t;+}+function X1(i) {+ for (var e = 0; e < i.__preset_select.length; e++)+ i.__preset_select[e].value === i.preset && (i.__preset_select.selectedIndex = e);+}+function G0(i) {+ i.length !== 0 && z1.call(window, function() {+ G0(i);+ }), ue.each(i, function(e) {+ e.updateDisplay();+ });+}+var Y1 = Dt;+const Vc = [+ {+ id: "",+ name: "None",+ path: null+ },+ {+ id: "neutral",+ // THREE.RoomEnvironment+ name: "Neutral",+ path: null+ },+ {+ id: "venice-sunset",+ name: "Venice Sunset",+ path: "https://storage.googleapis.com/donmccurdy-static/venice_sunset_1k.exr",+ format: ".exr"+ },+ {+ id: "footprint-court",+ name: "Footprint Court (HDR Labs)",+ path: "https://storage.googleapis.com/donmccurdy-static/footprint_court_2k.exr",+ format: ".exr"+ }+], J1 = [+ "BN",+ "BN",+ "BN",+ "BN",+ "BN",+ "BN",+ "BN",+ "BN",+ "BN",+ "S",+ "B",+ "S",+ "WS",+ "B",+ "BN",+ "BN",+ "BN",+ "BN",+ "BN",+ "BN",+ "BN",+ "BN",+ "BN",+ "BN",+ "BN",+ "BN",+ "BN",+ "BN",+ "B",+ "B",+ "B",+ "S",+ "WS",+ "ON",+ "ON",+ "ET",+ "ET",+ "ET",+ "ON",+ "ON",+ "ON",+ "ON",+ "ON",+ "ES",+ "CS",+ "ES",+ "CS",+ "CS",+ "EN",+ "EN",+ "EN",+ "EN",+ "EN",+ "EN",+ "EN",+ "EN",+ "EN",+ "EN",+ "CS",+ "ON",+ "ON",+ "ON",+ "ON",+ "ON",+ "ON",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "ON",+ "ON",+ "ON",+ "ON",+ "ON",+ "ON",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "ON",+ "ON",+ "ON",+ "ON",+ "BN",+ "BN",+ "BN",+ "BN",+ "BN",+ "BN",+ "B",+ "BN",+ "BN",+ "BN",+ "BN",+ "BN",+ "BN",+ "BN",+ "BN",+ "BN",+ "BN",+ "BN",+ "BN",+ "BN",+ "BN",+ "BN",+ "BN",+ "BN",+ "BN",+ "BN",+ "BN",+ "BN",+ "BN",+ "BN",+ "BN",+ "BN",+ "BN",+ "CS",+ "ON",+ "ET",+ "ET",+ "ET",+ "ET",+ "ON",+ "ON",+ "ON",+ "ON",+ "L",+ "ON",+ "ON",+ "BN",+ "ON",+ "ON",+ "ET",+ "ET",+ "EN",+ "EN",+ "ON",+ "L",+ "ON",+ "ON",+ "ON",+ "EN",+ "L",+ "ON",+ "ON",+ "ON",+ "ON",+ "ON",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "ON",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "ON",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L",+ "L"+], qA = [+ [697, 698, "ON"],+ [706, 719, "ON"],+ [722, 735, "ON"],+ [741, 749, "ON"],+ [751, 767, "ON"],+ [768, 879, "NSM"],+ [884, 885, "ON"],+ [894, 894, "ON"],+ [900, 901, "ON"],+ [903, 903, "ON"],+ [1014, 1014, "ON"],+ [1155, 1161, "NSM"],+ [1418, 1418, "ON"],+ [1421, 1422, "ON"],+ [1423, 1423, "ET"],+ [1424, 1424, "R"],+ [1425, 1469, "NSM"],+ [1470, 1470, "R"],+ [1471, 1471, "NSM"],+ [1472, 1472, "R"],+ [1473, 1474, "NSM"],+ [1475, 1475, "R"],+ [1476, 1477, "NSM"],+ [1478, 1478, "R"],+ [1479, 1479, "NSM"],+ [1480, 1535, "R"],+ [1536, 1541, "AN"],+ [1542, 1543, "ON"],+ [1544, 1544, "AL"],+ [1545, 1546, "ET"],+ [1547, 1547, "AL"],+ [1548, 1548, "CS"],+ [1549, 1549, "AL"],+ [1550, 1551, "ON"],+ [1552, 1562, "NSM"],+ [1563, 1610, "AL"],+ [1611, 1631, "NSM"],+ [1632, 1641, "AN"],+ [1642, 1642, "ET"],+ [1643, 1644, "AN"],+ [1645, 1647, "AL"],+ [1648, 1648, "NSM"],+ [1649, 1749, "AL"],+ [1750, 1756, "NSM"],+ [1757, 1757, "AN"],+ [1758, 1758, "ON"],+ [1759, 1764, "NSM"],+ [1765, 1766, "AL"],+ [1767, 1768, "NSM"],+ [1769, 1769, "ON"],+ [1770, 1773, "NSM"],+ [1774, 1775, "AL"],+ [1776, 1785, "EN"],+ [1786, 1808, "AL"],+ [1809, 1809, "NSM"],+ [1810, 1839, "AL"],+ [1840, 1866, "NSM"],+ [1867, 1957, "AL"],+ [1958, 1968, "NSM"],+ [1969, 1983, "AL"],+ [1984, 2026, "R"],+ [2027, 2035, "NSM"],+ [2036, 2037, "R"],+ [2038, 2041, "ON"],+ [2042, 2044, "R"],+ [2045, 2045, "NSM"],+ [2046, 2069, "R"],+ [2070, 2073, "NSM"],+ [2074, 2074, "R"],+ [2075, 2083, "NSM"],+ [2084, 2084, "R"],+ [2085, 2087, "NSM"],+ [2088, 2088, "R"],+ [2089, 2093, "NSM"],+ [2094, 2136, "R"],+ [2137, 2139, "NSM"],+ [2140, 2143, "R"],+ [2144, 2191, "AL"],+ [2192, 2193, "AN"],+ [2194, 2198, "AL"],+ [2199, 2207, "NSM"],+ [2208, 2249, "AL"],+ [2250, 2273, "NSM"],+ [2274, 2274, "AN"],+ [2275, 2306, "NSM"],+ [2362, 2362, "NSM"],+ [2364, 2364, "NSM"],+ [2369, 2376, "NSM"],+ [2381, 2381, "NSM"],+ [2385, 2391, "NSM"],+ [2402, 2403, "NSM"],+ [2433, 2433, "NSM"],+ [2492, 2492, "NSM"],+ [2497, 2500, "NSM"],+ [2509, 2509, "NSM"],+ [2530, 2531, "NSM"],+ [2546, 2547, "ET"],+ [2555, 2555, "ET"],+ [2558, 2558, "NSM"],+ [2561, 2562, "NSM"],+ [2620, 2620, "NSM"],+ [2625, 2626, "NSM"],+ [2631, 2632, "NSM"],+ [2635, 2637, "NSM"],+ [2641, 2641, "NSM"],+ [2672, 2673, "NSM"],+ [2677, 2677, "NSM"],+ [2689, 2690, "NSM"],+ [2748, 2748, "NSM"],+ [2753, 2757, "NSM"],+ [2759, 2760, "NSM"],+ [2765, 2765, "NSM"],+ [2786, 2787, "NSM"],+ [2801, 2801, "ET"],+ [2810, 2815, "NSM"],+ [2817, 2817, "NSM"],+ [2876, 2876, "NSM"],+ [2879, 2879, "NSM"],+ [2881, 2884, "NSM"],+ [2893, 2893, "NSM"],+ [2901, 2902, "NSM"],+ [2914, 2915, "NSM"],+ [2946, 2946, "NSM"],+ [3008, 3008, "NSM"],+ [3021, 3021, "NSM"],+ [3059, 3064, "ON"],+ [3065, 3065, "ET"],+ [3066, 3066, "ON"],+ [3072, 3072, "NSM"],+ [3076, 3076, "NSM"],+ [3132, 3132, "NSM"],+ [3134, 3136, "NSM"],+ [3142, 3144, "NSM"],+ [3146, 3149, "NSM"],+ [3157, 3158, "NSM"],+ [3170, 3171, "NSM"],+ [3192, 3198, "ON"],+ [3201, 3201, "NSM"],+ [3260, 3260, "NSM"],+ [3276, 3277, "NSM"],+ [3298, 3299, "NSM"],+ [3328, 3329, "NSM"],+ [3387, 3388, "NSM"],+ [3393, 3396, "NSM"],+ [3405, 3405, "NSM"],+ [3426, 3427, "NSM"],+ [3457, 3457, "NSM"],+ [3530, 3530, "NSM"],+ [3538, 3540, "NSM"],+ [3542, 3542, "NSM"],+ [3633, 3633, "NSM"],+ [3636, 3642, "NSM"],+ [3647, 3647, "ET"],+ [3655, 3662, "NSM"],+ [3761, 3761, "NSM"],+ [3764, 3772, "NSM"],+ [3784, 3790, "NSM"],+ [3864, 3865, "NSM"],+ [3893, 3893, "NSM"],+ [3895, 3895, "NSM"],+ [3897, 3897, "NSM"],+ [3898, 3901, "ON"],+ [3953, 3966, "NSM"],+ [3968, 3972, "NSM"],+ [3974, 3975, "NSM"],+ [3981, 3991, "NSM"],+ [3993, 4028, "NSM"],+ [4038, 4038, "NSM"],+ [4141, 4144, "NSM"],+ [4146, 4151, "NSM"],+ [4153, 4154, "NSM"],+ [4157, 4158, "NSM"],+ [4184, 4185, "NSM"],+ [4190, 4192, "NSM"],+ [4209, 4212, "NSM"],+ [4226, 4226, "NSM"],+ [4229, 4230, "NSM"],+ [4237, 4237, "NSM"],+ [4253, 4253, "NSM"],+ [4957, 4959, "NSM"],+ [5008, 5017, "ON"],+ [5120, 5120, "ON"],+ [5760, 5760, "WS"],+ [5787, 5788, "ON"],+ [5906, 5908, "NSM"],+ [5938, 5939, "NSM"],+ [5970, 5971, "NSM"],+ [6002, 6003, "NSM"],+ [6068, 6069, "NSM"],+ [6071, 6077, "NSM"],+ [6086, 6086, "NSM"],+ [6089, 6099, "NSM"],+ [6107, 6107, "ET"],+ [6109, 6109, "NSM"],+ [6128, 6137, "ON"],+ [6144, 6154, "ON"],+ [6155, 6157, "NSM"],+ [6158, 6158, "BN"],+ [6159, 6159, "NSM"],+ [6277, 6278, "NSM"],+ [6313, 6313, "NSM"],+ [6432, 6434, "NSM"],+ [6439, 6440, "NSM"],+ [6450, 6450, "NSM"],+ [6457, 6459, "NSM"],+ [6464, 6464, "ON"],+ [6468, 6469, "ON"],+ [6622, 6655, "ON"],+ [6679, 6680, "NSM"],+ [6683, 6683, "NSM"],+ [6742, 6742, "NSM"],+ [6744, 6750, "NSM"],+ [6752, 6752, "NSM"],+ [6754, 6754, "NSM"],+ [6757, 6764, "NSM"],+ [6771, 6780, "NSM"],+ [6783, 6783, "NSM"],+ [6832, 6877, "NSM"],+ [6880, 6891, "NSM"],+ [6912, 6915, "NSM"],+ [6964, 6964, "NSM"],+ [6966, 6970, "NSM"],+ [6972, 6972, "NSM"],+ [6978, 6978, "NSM"],+ [7019, 7027, "NSM"],+ [7040, 7041, "NSM"],+ [7074, 7077, "NSM"],+ [7080, 7081, "NSM"],+ [7083, 7085, "NSM"],+ [7142, 7142, "NSM"],+ [7144, 7145, "NSM"],+ [7149, 7149, "NSM"],+ [7151, 7153, "NSM"],+ [7212, 7219, "NSM"],+ [7222, 7223, "NSM"],+ [7376, 7378, "NSM"],+ [7380, 7392, "NSM"],+ [7394, 7400, "NSM"],+ [7405, 7405, "NSM"],+ [7412, 7412, "NSM"],+ [7416, 7417, "NSM"],+ [7616, 7679, "NSM"],+ [8125, 8125, "ON"],+ [8127, 8129, "ON"],+ [8141, 8143, "ON"],+ [8157, 8159, "ON"],+ [8173, 8175, "ON"],+ [8189, 8190, "ON"],+ [8192, 8202, "WS"],+ [8203, 8205, "BN"],+ [8207, 8207, "R"],+ [8208, 8231, "ON"],+ [8232, 8232, "WS"],+ [8233, 8233, "B"],+ [8234, 8238, "BN"],+ [8239, 8239, "CS"],+ [8240, 8244, "ET"],+ [8245, 8259, "ON"],+ [8260, 8260, "CS"],+ [8261, 8286, "ON"],+ [8287, 8287, "WS"],+ [8288, 8303, "BN"],+ [8304, 8304, "EN"],+ [8308, 8313, "EN"],+ [8314, 8315, "ES"],+ [8316, 8318, "ON"],+ [8320, 8329, "EN"],+ [8330, 8331, "ES"],+ [8332, 8334, "ON"],+ [8352, 8399, "ET"],+ [8400, 8432, "NSM"],+ [8448, 8449, "ON"],+ [8451, 8454, "ON"],+ [8456, 8457, "ON"],+ [8468, 8468, "ON"],+ [8470, 8472, "ON"],+ [8478, 8483, "ON"],+ [8485, 8485, "ON"],+ [8487, 8487, "ON"],+ [8489, 8489, "ON"],+ [8494, 8494, "ET"],+ [8506, 8507, "ON"],+ [8512, 8516, "ON"],+ [8522, 8525, "ON"],+ [8528, 8543, "ON"],+ [8585, 8587, "ON"],+ [8592, 8721, "ON"],+ [8722, 8722, "ES"],+ [8723, 8723, "ET"],+ [8724, 9013, "ON"],+ [9083, 9108, "ON"],+ [9110, 9257, "ON"],+ [9280, 9290, "ON"],+ [9312, 9351, "ON"],+ [9352, 9371, "EN"],+ [9450, 9899, "ON"],+ [9901, 10239, "ON"],+ [10496, 11123, "ON"],+ [11126, 11263, "ON"],+ [11493, 11498, "ON"],+ [11503, 11505, "NSM"],+ [11513, 11519, "ON"],+ [11647, 11647, "NSM"],+ [11744, 11775, "NSM"],+ [11776, 11869, "ON"],+ [11904, 11929, "ON"],+ [11931, 12019, "ON"],+ [12032, 12245, "ON"],+ [12272, 12287, "ON"],+ [12288, 12288, "WS"],+ [12289, 12292, "ON"],+ [12296, 12320, "ON"],+ [12330, 12333, "NSM"],+ [12336, 12336, "ON"],+ [12342, 12343, "ON"],+ [12349, 12351, "ON"],+ [12441, 12442, "NSM"],+ [12443, 12444, "ON"],+ [12448, 12448, "ON"],+ [12539, 12539, "ON"],+ [12736, 12773, "ON"],+ [12783, 12783, "ON"],+ [12829, 12830, "ON"],+ [12880, 12895, "ON"],+ [12924, 12926, "ON"],+ [12977, 12991, "ON"],+ [13004, 13007, "ON"],+ [13175, 13178, "ON"],+ [13278, 13279, "ON"],+ [13311, 13311, "ON"],+ [19904, 19967, "ON"],+ [42128, 42182, "ON"],+ [42509, 42511, "ON"],+ [42607, 42610, "NSM"],+ [42611, 42611, "ON"],+ [42612, 42621, "NSM"],+ [42622, 42623, "ON"],+ [42654, 42655, "NSM"],+ [42736, 42737, "NSM"],+ [42752, 42785, "ON"],+ [42888, 42888, "ON"],+ [43010, 43010, "NSM"],+ [43014, 43014, "NSM"],+ [43019, 43019, "NSM"],+ [43045, 43046, "NSM"],+ [43048, 43051, "ON"],+ [43052, 43052, "NSM"],+ [43064, 43065, "ET"],+ [43124, 43127, "ON"],+ [43204, 43205, "NSM"],+ [43232, 43249, "NSM"],+ [43263, 43263, "NSM"],+ [43302, 43309, "NSM"],+ [43335, 43345, "NSM"],+ [43392, 43394, "NSM"],+ [43443, 43443, "NSM"],+ [43446, 43449, "NSM"],+ [43452, 43453, "NSM"],+ [43493, 43493, "NSM"],+ [43561, 43566, "NSM"],+ [43569, 43570, "NSM"],+ [43573, 43574, "NSM"],+ [43587, 43587, "NSM"],+ [43596, 43596, "NSM"],+ [43644, 43644, "NSM"],+ [43696, 43696, "NSM"],+ [43698, 43700, "NSM"],+ [43703, 43704, "NSM"],+ [43710, 43711, "NSM"],+ [43713, 43713, "NSM"],+ [43756, 43757, "NSM"],+ [43766, 43766, "NSM"],+ [43882, 43883, "ON"],+ [44005, 44005, "NSM"],+ [44008, 44008, "NSM"],+ [44013, 44013, "NSM"],+ [64285, 64285, "R"],+ [64286, 64286, "NSM"],+ [64287, 64296, "R"],+ [64297, 64297, "ES"],+ [64298, 64335, "R"],+ [64336, 64450, "AL"],+ [64451, 64466, "ON"],+ [64467, 64829, "AL"],+ [64830, 64847, "ON"],+ [64848, 64911, "AL"],+ [64912, 64913, "ON"],+ [64914, 64967, "AL"],+ [64968, 64975, "ON"],+ [64976, 65007, "BN"],+ [65008, 65020, "AL"],+ [65021, 65023, "ON"],+ [65024, 65039, "NSM"],+ [65040, 65049, "ON"],+ [65056, 65071, "NSM"],+ [65072, 65103, "ON"],+ [65104, 65104, "CS"],+ [65105, 65105, "ON"],+ [65106, 65106, "CS"],+ [65108, 65108, "ON"],+ [65109, 65109, "CS"],+ [65110, 65118, "ON"],+ [65119, 65119, "ET"],+ [65120, 65121, "ON"],+ [65122, 65123, "ES"],+ [65124, 65126, "ON"],+ [65128, 65128, "ON"],+ [65129, 65130, "ET"],+ [65131, 65131, "ON"],+ [65136, 65278, "AL"],+ [65279, 65279, "BN"],+ [65281, 65282, "ON"],+ [65283, 65285, "ET"],+ [65286, 65290, "ON"],+ [65291, 65291, "ES"],+ [65292, 65292, "CS"],+ [65293, 65293, "ES"],+ [65294, 65295, "CS"],+ [65296, 65305, "EN"],+ [65306, 65306, "CS"],+ [65307, 65312, "ON"],+ [65339, 65344, "ON"],+ [65371, 65381, "ON"],+ [65504, 65505, "ET"],+ [65506, 65508, "ON"],+ [65509, 65510, "ET"],+ [65512, 65518, "ON"],+ [65520, 65528, "BN"],+ [65529, 65533, "ON"],+ [65534, 65535, "BN"],+ [65793, 65793, "ON"],+ [65856, 65932, "ON"],+ [65936, 65948, "ON"],+ [65952, 65952, "ON"],+ [66045, 66045, "NSM"],+ [66272, 66272, "NSM"],+ [66273, 66299, "EN"],+ [66422, 66426, "NSM"],+ [67584, 67870, "R"],+ [67871, 67871, "ON"],+ [67872, 68096, "R"],+ [68097, 68099, "NSM"],+ [68100, 68100, "R"],+ [68101, 68102, "NSM"],+ [68103, 68107, "R"],+ [68108, 68111, "NSM"],+ [68112, 68151, "R"],+ [68152, 68154, "NSM"],+ [68155, 68158, "R"],+ [68159, 68159, "NSM"],+ [68160, 68324, "R"],+ [68325, 68326, "NSM"],+ [68327, 68408, "R"],+ [68409, 68415, "ON"],+ [68416, 68863, "R"],+ [68864, 68899, "AL"],+ [68900, 68903, "NSM"],+ [68904, 68911, "AL"],+ [68912, 68921, "AN"],+ [68922, 68927, "AL"],+ [68928, 68937, "AN"],+ [68938, 68968, "R"],+ [68969, 68973, "NSM"],+ [68974, 68974, "ON"],+ [68975, 69215, "R"],+ [69216, 69246, "AN"],+ [69247, 69290, "R"],+ [69291, 69292, "NSM"],+ [69293, 69311, "R"],+ [69312, 69327, "AL"],+ [69328, 69336, "ON"],+ [69337, 69369, "AL"],+ [69370, 69375, "NSM"],+ [69376, 69423, "R"],+ [69424, 69445, "AL"],+ [69446, 69456, "NSM"],+ [69457, 69487, "AL"],+ [69488, 69505, "R"],+ [69506, 69509, "NSM"],+ [69510, 69631, "R"],+ [69633, 69633, "NSM"],+ [69688, 69702, "NSM"],+ [69714, 69733, "ON"],+ [69744, 69744, "NSM"],+ [69747, 69748, "NSM"],+ [69759, 69761, "NSM"],+ [69811, 69814, "NSM"],+ [69817, 69818, "NSM"],+ [69826, 69826, "NSM"],+ [69888, 69890, "NSM"],+ [69927, 69931, "NSM"],+ [69933, 69940, "NSM"],+ [70003, 70003, "NSM"],+ [70016, 70017, "NSM"],+ [70070, 70078, "NSM"],+ [70089, 70092, "NSM"],+ [70095, 70095, "NSM"],+ [70191, 70193, "NSM"],+ [70196, 70196, "NSM"],+ [70198, 70199, "NSM"],+ [70206, 70206, "NSM"],+ [70209, 70209, "NSM"],+ [70367, 70367, "NSM"],+ [70371, 70378, "NSM"],+ [70400, 70401, "NSM"],+ [70459, 70460, "NSM"],+ [70464, 70464, "NSM"],+ [70502, 70508, "NSM"],+ [70512, 70516, "NSM"],+ [70587, 70592, "NSM"],+ [70606, 70606, "NSM"],+ [70608, 70608, "NSM"],+ [70610, 70610, "NSM"],+ [70625, 70626, "NSM"],+ [70712, 70719, "NSM"],+ [70722, 70724, "NSM"],+ [70726, 70726, "NSM"],+ [70750, 70750, "NSM"],+ [70835, 70840, "NSM"],+ [70842, 70842, "NSM"],+ [70847, 70848, "NSM"],+ [70850, 70851, "NSM"],+ [71090, 71093, "NSM"],+ [71100, 71101, "NSM"],+ [71103, 71104, "NSM"],+ [71132, 71133, "NSM"],+ [71219, 71226, "NSM"],+ [71229, 71229, "NSM"],+ [71231, 71232, "NSM"],+ [71264, 71276, "ON"],+ [71339, 71339, "NSM"],+ [71341, 71341, "NSM"],+ [71344, 71349, "NSM"],+ [71351, 71351, "NSM"],+ [71453, 71453, "NSM"],+ [71455, 71455, "NSM"],+ [71458, 71461, "NSM"],+ [71463, 71467, "NSM"],+ [71727, 71735, "NSM"],+ [71737, 71738, "NSM"],+ [71995, 71996, "NSM"],+ [71998, 71998, "NSM"],+ [72003, 72003, "NSM"],+ [72148, 72151, "NSM"],+ [72154, 72155, "NSM"],+ [72160, 72160, "NSM"],+ [72193, 72198, "NSM"],+ [72201, 72202, "NSM"],+ [72243, 72248, "NSM"],+ [72251, 72254, "NSM"],+ [72263, 72263, "NSM"],+ [72273, 72278, "NSM"],+ [72281, 72283, "NSM"],+ [72330, 72342, "NSM"],+ [72344, 72345, "NSM"],+ [72544, 72544, "NSM"],+ [72546, 72548, "NSM"],+ [72550, 72550, "NSM"],+ [72752, 72758, "NSM"],+ [72760, 72765, "NSM"],+ [72850, 72871, "NSM"],+ [72874, 72880, "NSM"],+ [72882, 72883, "NSM"],+ [72885, 72886, "NSM"],+ [73009, 73014, "NSM"],+ [73018, 73018, "NSM"],+ [73020, 73021, "NSM"],+ [73023, 73029, "NSM"],+ [73031, 73031, "NSM"],+ [73104, 73105, "NSM"],+ [73109, 73109, "NSM"],+ [73111, 73111, "NSM"],+ [73459, 73460, "NSM"],+ [73472, 73473, "NSM"],+ [73526, 73530, "NSM"],+ [73536, 73536, "NSM"],+ [73538, 73538, "NSM"],+ [73562, 73562, "NSM"],+ [73685, 73692, "ON"],+ [73693, 73696, "ET"],+ [73697, 73713, "ON"],+ [78912, 78912, "NSM"],+ [78919, 78933, "NSM"],+ [90398, 90409, "NSM"],+ [90413, 90415, "NSM"],+ [92912, 92916, "NSM"],+ [92976, 92982, "NSM"],+ [94031, 94031, "NSM"],+ [94095, 94098, "NSM"],+ [94178, 94178, "ON"],+ [94180, 94180, "NSM"],+ [113821, 113822, "NSM"],+ [113824, 113827, "BN"],+ [117760, 117973, "ON"],+ [118e3, 118009, "EN"],+ [118010, 118012, "ON"],+ [118016, 118451, "ON"],+ [118458, 118480, "ON"],+ [118496, 118512, "ON"],+ [118528, 118573, "NSM"],+ [118576, 118598, "NSM"],+ [119143, 119145, "NSM"],+ [119155, 119162, "BN"],+ [119163, 119170, "NSM"],+ [119173, 119179, "NSM"],+ [119210, 119213, "NSM"],+ [119273, 119274, "ON"],+ [119296, 119361, "ON"],+ [119362, 119364, "NSM"],+ [119365, 119365, "ON"],+ [119552, 119638, "ON"],+ [120513, 120513, "ON"],+ [120539, 120539, "ON"],+ [120571, 120571, "ON"],+ [120597, 120597, "ON"],+ [120629, 120629, "ON"],+ [120655, 120655, "ON"],+ [120687, 120687, "ON"],+ [120713, 120713, "ON"],+ [120745, 120745, "ON"],+ [120771, 120771, "ON"],+ [120782, 120831, "EN"],+ [121344, 121398, "NSM"],+ [121403, 121452, "NSM"],+ [121461, 121461, "NSM"],+ [121476, 121476, "NSM"],+ [121499, 121503, "NSM"],+ [121505, 121519, "NSM"],+ [122880, 122886, "NSM"],+ [122888, 122904, "NSM"],+ [122907, 122913, "NSM"],+ [122915, 122916, "NSM"],+ [122918, 122922, "NSM"],+ [123023, 123023, "NSM"],+ [123184, 123190, "NSM"],+ [123566, 123566, "NSM"],+ [123628, 123631, "NSM"],+ [123647, 123647, "ET"],+ [124140, 124143, "NSM"],+ [124398, 124399, "NSM"],+ [124643, 124643, "NSM"],+ [124646, 124646, "NSM"],+ [124654, 124655, "NSM"],+ [124661, 124661, "NSM"],+ [124928, 125135, "R"],+ [125136, 125142, "NSM"],+ [125143, 125251, "R"],+ [125252, 125258, "NSM"],+ [125259, 126063, "R"],+ [126064, 126143, "AL"],+ [126144, 126207, "R"],+ [126208, 126287, "AL"],+ [126288, 126463, "R"],+ [126464, 126703, "AL"],+ [126704, 126705, "ON"],+ [126706, 126719, "AL"],+ [126720, 126975, "R"],+ [126976, 127019, "ON"],+ [127024, 127123, "ON"],+ [127136, 127150, "ON"],+ [127153, 127167, "ON"],+ [127169, 127183, "ON"],+ [127185, 127221, "ON"],+ [127232, 127242, "EN"],+ [127243, 127247, "ON"],+ [127279, 127279, "ON"],+ [127338, 127343, "ON"],+ [127405, 127405, "ON"],+ [127584, 127589, "ON"],+ [127744, 128728, "ON"],+ [128732, 128748, "ON"],+ [128752, 128764, "ON"],+ [128768, 128985, "ON"],+ [128992, 129003, "ON"],+ [129008, 129008, "ON"],+ [129024, 129035, "ON"],+ [129040, 129095, "ON"],+ [129104, 129113, "ON"],+ [129120, 129159, "ON"],+ [129168, 129197, "ON"],+ [129200, 129211, "ON"],+ [129216, 129217, "ON"],+ [129232, 129240, "ON"],+ [129280, 129623, "ON"],+ [129632, 129645, "ON"],+ [129648, 129660, "ON"],+ [129664, 129674, "ON"],+ [129678, 129734, "ON"],+ [129736, 129736, "ON"],+ [129741, 129756, "ON"],+ [129759, 129770, "ON"],+ [129775, 129784, "ON"],+ [129792, 129938, "ON"],+ [129940, 130031, "ON"],+ [130032, 130041, "EN"],+ [130042, 130042, "ON"],+ [131070, 131071, "BN"],+ [196606, 196607, "BN"],+ [262142, 262143, "BN"],+ [327678, 327679, "BN"],+ [393214, 393215, "BN"],+ [458750, 458751, "BN"],+ [524286, 524287, "BN"],+ [589822, 589823, "BN"],+ [655358, 655359, "BN"],+ [720894, 720895, "BN"],+ [786430, 786431, "BN"],+ [851966, 851967, "BN"],+ [917502, 917759, "BN"],+ [917760, 917999, "NSM"],+ [918e3, 921599, "BN"],+ [983038, 983039, "BN"],+ [1048574, 1048575, "BN"],+ [1114110, 1114111, "BN"]+];+function Z1(i) {+ if (i <= 255)+ return J1[i];+ let e = 0, t = qA.length - 1;+ for (; e <= t; ) {+ const n = e + t >> 1, s = qA[n];+ if (i < s[0]) {+ t = n - 1;+ continue;+ }+ if (i > s[1]) {+ e = n + 1;+ continue;+ }+ return s[2];+ }+ return "L";+}+function $1(i) {+ const e = i.length;+ if (e === 0)+ return null;+ const t = new Array(e);+ let n = !1;+ for (let l = 0; l < e; ) {+ const h = i.charCodeAt(l);+ let u = h, d = 1;+ if (h >= 55296 && h <= 56319 && l + 1 < e) {+ const m = i.charCodeAt(l + 1);+ m >= 56320 && m <= 57343 && (u = (h - 55296 << 10) + (m - 56320) + 65536, d = 2);+ }+ const f = Z1(u);+ (f === "R" || f === "AL" || f === "AN") && (n = !0);+ for (let m = 0; m < d; m++)+ t[l + m] = f;+ l += d;+ }+ if (!n)+ return null;+ let s = 0;+ for (let l = 0; l < e; l++) {+ const h = t[l];+ if (h === "L") {+ s = 0;+ break;+ }+ if (h === "R" || h === "AL") {+ s = 1;+ break;+ }+ }+ const r = new Int8Array(e);+ for (let l = 0; l < e; l++)+ r[l] = s;+ const a = s & 1 ? "R" : "L", o = a;+ let c = o;+ for (let l = 0; l < e; l++)+ t[l] === "NSM" ? t[l] = c : c = t[l];+ c = o;+ for (let l = 0; l < e; l++) {+ const h = t[l];+ h === "EN" ? t[l] = c === "AL" ? "AN" : "EN" : (h === "R" || h === "L" || h === "AL") && (c = h);+ }+ for (let l = 0; l < e; l++)+ t[l] === "AL" && (t[l] = "R");+ for (let l = 1; l < e - 1; l++)+ t[l] === "ES" && t[l - 1] === "EN" && t[l + 1] === "EN" && (t[l] = "EN"), t[l] === "CS" && (t[l - 1] === "EN" || t[l - 1] === "AN") && t[l + 1] === t[l - 1] && (t[l] = t[l - 1]);+ for (let l = 0; l < e; l++) {+ if (t[l] !== "EN")+ continue;+ let h;+ for (h = l - 1; h >= 0 && t[h] === "ET"; h--)+ t[h] = "EN";+ for (h = l + 1; h < e && t[h] === "ET"; h++)+ t[h] = "EN";+ }+ for (let l = 0; l < e; l++) {+ const h = t[l];+ (h === "WS" || h === "ES" || h === "ET" || h === "CS") && (t[l] = "ON");+ }+ c = o;+ for (let l = 0; l < e; l++) {+ const h = t[l];+ h === "EN" ? t[l] = c === "L" ? "L" : "EN" : (h === "R" || h === "L") && (c = h);+ }+ for (let l = 0; l < e; l++) {+ if (t[l] !== "ON")+ continue;+ let h = l + 1;+ for (; h < e && t[h] === "ON"; )+ h++;+ const u = l > 0 ? t[l - 1] : o, d = h < e ? t[h] : o, f = u !== "L" ? "R" : "L";+ if (f === (d !== "L" ? "R" : "L"))+ for (let A = l; A < h; A++)+ t[A] = f;+ l = h - 1;+ }+ for (let l = 0; l < e; l++)+ t[l] === "ON" && (t[l] = a);+ for (let l = 0; l < e; l++) {+ const h = t[l];+ (r[l] & 1) === 0 ? h === "R" ? r[l]++ : (h === "AN" || h === "EN") && (r[l] += 2) : (h === "L" || h === "AN" || h === "EN") && r[l]++;+ }+ return r;+}+function eM(i, e) {+ const t = $1(i);+ if (t === null)+ return null;+ const n = new Int8Array(e.length);+ for (let s = 0; s < e.length; s++)+ n[s] = t[e[s]];+ return n;+}+const tM = /[ \t\n\r\f]+/g, nM = /[\t\n\r\f]| {2,}|^ | $/;+function iM(i) {+ const e = i ?? "normal";+ return e === "pre-wrap" ? { mode: e, preserveOrdinarySpaces: !0, preserveHardBreaks: !0 } : { mode: e, preserveOrdinarySpaces: !1, preserveHardBreaks: !1 };+}+function sM(i) {+ if (!nM.test(i))+ return i;+ let e = i.replace(tM, " ");+ return e.charCodeAt(0) === 32 && (e = e.slice(1)), e.length > 0 && e.charCodeAt(e.length - 1) === 32 && (e = e.slice(0, -1)), e;+}+function rM(i) {+ return /[\r\f]/.test(i) ? i.replace(/\r\n/g, `+`).replace(/[\r\f]/g, `+`) : i.replace(/\r\n/g, `+`);+}+let ru = null, aM;+function oM() {+ return ru === null && (ru = new Intl.Segmenter(aM, { granularity: "word" })), ru;+}+const cM = new RegExp("\\p{Script=Arabic}", "u"), eh = new RegExp("\\p{M}", "u"), H0 = new RegExp("\\p{Nd}", "u");+function KA(i) {+ return cM.test(i);+}+function jA(i) {+ return i >= 19968 && i <= 40959 || i >= 13312 && i <= 19903 || i >= 131072 && i <= 173791 || i >= 173824 && i <= 177983 || i >= 177984 && i <= 178207 || i >= 178208 && i <= 183983 || i >= 183984 && i <= 191471 || i >= 191472 && i <= 192093 || i >= 194560 && i <= 195103 || i >= 196608 && i <= 201551 || i >= 201552 && i <= 205743 || i >= 205744 && i <= 210041 || i >= 63744 && i <= 64255 || i >= 12288 && i <= 12351 || i >= 12352 && i <= 12447 || i >= 12448 && i <= 12543 || i >= 44032 && i <= 55215 || i >= 65280 && i <= 65519;+}+function vr(i) {+ for (let e = 0; e < i.length; e++) {+ const t = i.charCodeAt(e);+ if (!(t < 12288)) {+ if (t >= 55296 && t <= 56319 && e + 1 < i.length) {+ const n = i.charCodeAt(e + 1);+ if (n >= 56320 && n <= 57343) {+ const s = (t - 55296 << 10) + (n - 56320) + 65536;+ if (jA(s))+ return !0;+ e++;+ continue;+ }+ }+ if (jA(t))+ return !0;+ }+ }+ return !1;+}+function lM(i) {+ const e = nh(i);+ return e !== null && (Pf.has(e) || Cr.has(e));+}+const hM = /* @__PURE__ */ new Set([+ " ",+ " ",+ "",+ "\uFEFF"+]);+function uM(i) {+ return vr(i);+}+function dM(i) {+ const e = nh(i);+ return e !== null && hM.has(e);+}+function fM(i) {+ return !lM(i) && !dM(i);+}+const Pf = /* @__PURE__ */ new Set([+ ",",+ ".",+ "!",+ ":",+ ";",+ "?",+ "、",+ "。",+ "・",+ ")",+ "〕",+ "〉",+ "》",+ "」",+ "』",+ "】",+ "〗",+ "〙",+ "〛",+ "ー",+ "々",+ "〻",+ "ゝ",+ "ゞ",+ "ヽ",+ "ヾ"+]), th = /* @__PURE__ */ new Set([+ '"',+ "(",+ "[",+ "{",+ "“",+ "‘",+ "«",+ "‹",+ "(",+ "〔",+ "〈",+ "《",+ "「",+ "『",+ "【",+ "〖",+ "〘",+ "〚"+]), kf = /* @__PURE__ */ new Set([+ "'",+ "’"+]), Cr = /* @__PURE__ */ new Set([+ ".",+ ",",+ "!",+ "?",+ ":",+ ";",+ "،",+ "؛",+ "؟",+ "।",+ "॥",+ "၊",+ "။",+ "၌",+ "၍",+ "၏",+ ")",+ "]",+ "}",+ "%",+ '"',+ "”",+ "’",+ "»",+ "›",+ "…"+]), pM = /* @__PURE__ */ new Set([+ ":",+ ".",+ "،",+ "؛"+]), AM = /* @__PURE__ */ new Set([+ "၏"+]), gM = /* @__PURE__ */ new Set([+ "”",+ "’",+ "»",+ "›",+ "」",+ "』",+ "】",+ "》",+ "〉",+ "〕",+ ")"+]);+function mM(i) {+ if (Uf(i))+ return !0;+ let e = !1;+ for (const t of i) {+ if (Cr.has(t)) {+ e = !0;+ continue;+ }+ if (!(e && eh.test(t)))+ return !1;+ }+ return e;+}+function bM(i) {+ for (const e of i)+ if (!Pf.has(e) && !Cr.has(e))+ return !1;+ return i.length > 0;+}+function xM(i) {+ if (Uf(i))+ return !0;+ for (const e of i)+ if (!th.has(e) && !kf.has(e) && !eh.test(e))+ return !1;+ return i.length > 0;+}+function Uf(i) {+ let e = !1;+ for (const t of i)+ if (!(t === "\\" || eh.test(t))) {+ if (th.has(t) || Cr.has(t) || kf.has(t)) {+ e = !0;+ continue;+ }+ return !1;+ }+ return e;+}+function z0(i, e) {+ const t = e - 1;+ if (t <= 0)+ return Math.max(t, 0);+ const n = i.charCodeAt(t);+ if (n < 56320 || n > 57343)+ return t;+ const s = t - 1;+ if (s < 0)+ return t;+ const r = i.charCodeAt(s);+ return r >= 55296 && r <= 56319 ? s : t;+}+function nh(i) {+ if (i.length === 0)+ return null;+ const e = z0(i, i.length);+ return i.slice(e);+}+function _M(i) {+ const e = Array.from(i);+ let t = e.length;+ for (; t > 0; ) {+ const n = e[t - 1];+ if (eh.test(n)) {+ t--;+ continue;+ }+ if (th.has(n) || kf.has(n)) {+ t--;+ continue;+ }+ break;+ }+ return t <= 0 || t === e.length ? null : {+ head: e.slice(0, t).join(""),+ tail: e.slice(t).join("")+ };+}+function EM(i, e, t) {+ return t === "text" && !e && i.length === 1 && i !== "-" && i !== "—" ? i : null;+}+function XA(i, e, t, n) {+ const s = e[n], r = i[n];+ if (s == null)+ return r;+ const a = t[n];+ if (r.length === a)+ return r;+ const o = s.repeat(a);+ return i[n] = o, o;+}+function YA(i, e) {+ return i && e !== null && pM.has(e);+}+function yM(i) {+ const e = nh(i);+ return e !== null && AM.has(e);+}+function wM(i) {+ if (i.length < 2 || i[0] !== " ")+ return null;+ const e = i.slice(1);+ return new RegExp("^\\p{M}+$", "u").test(e) ? { space: " ", marks: e } : null;+}+function Fd(i) {+ let e = i.length;+ for (; e > 0; ) {+ const t = z0(i, e), n = i.slice(t, e);+ if (gM.has(n))+ return !0;+ if (!Cr.has(n))+ return !1;+ e = t;+ }+ return !1;+}+function vM(i, e) {+ if (e.preserveOrdinarySpaces || e.preserveHardBreaks) {+ if (i === " ")+ return "preserved-space";+ if (i === " ")+ return "tab";+ if (e.preserveHardBreaks && i === `+`)+ return "hard-break";+ }+ return i === " " ? "space" : i === " " || i === " " || i === "" || i === "\uFEFF" ? "glue" : i === "" ? "zero-width-break" : i === "" ? "soft-hyphen" : "text";+}+const CM = /[\x20\t\n\xA0\xAD\u200B\u202F\u2060\uFEFF]/;+function ri(i) {+ return i.length === 1 ? i[0] : i.join("");+}+function SM(i, e) {+ const t = [];+ for (let n = i.length - 1; n >= 0; n--)+ t.push(i[n]);+ return t.push(e), ri(t);+}+function IM(i, e, t, n) {+ if (!CM.test(i))+ return [{ text: i, isWordLike: e, kind: "text", start: t }];+ const s = [];+ let r = null, a = [], o = t, c = !1, l = 0;+ for (const h of i) {+ const u = vM(h, n), d = u === "text" && e;+ if (r !== null && u === r && d === c) {+ a.push(h), l += h.length;+ continue;+ }+ r !== null && s.push({+ text: ri(a),+ isWordLike: c,+ kind: r,+ start: o+ }), r = u, a = [h], o = t + l, c = d, l += h.length;+ }+ return r !== null && s.push({+ text: ri(a),+ isWordLike: c,+ kind: r,+ start: o+ }), s;+}+function Dd(i) {+ return i === "space" || i === "preserved-space" || i === "zero-width-break" || i === "hard-break";+}+const MM = /^[A-Za-z][A-Za-z0-9+.-]*:$/;+function BM(i, e) {+ const t = i.texts[e];+ return t.startsWith("www.") ? !0 : MM.test(t) && e + 1 < i.len && i.kinds[e + 1] === "text" && i.texts[e + 1] === "//";+}+function TM(i) {+ return i.includes("?") && (i.includes("://") || i.startsWith("www."));+}+function RM(i) {+ const e = i.texts.slice(), t = i.isWordLike.slice(), n = i.kinds.slice(), s = i.starts.slice();+ for (let a = 0; a < i.len; a++) {+ if (n[a] !== "text" || !BM(i, a))+ continue;+ const o = [e[a]];+ let c = a + 1;+ for (; c < i.len && !Dd(n[c]); ) {+ o.push(e[c]), t[a] = !0;+ const l = e[c].includes("?");+ if (n[c] = "text", e[c] = "", c++, l)+ break;+ }+ e[a] = ri(o);+ }+ let r = 0;+ for (let a = 0; a < e.length; a++) {+ const o = e[a];+ o.length !== 0 && (r !== a && (e[r] = o, t[r] = t[a], n[r] = n[a], s[r] = s[a]), r++);+ }+ return e.length = r, t.length = r, n.length = r, s.length = r, {+ len: r,+ texts: e,+ isWordLike: t,+ kinds: n,+ starts: s+ };+}+function NM(i) {+ const e = [], t = [], n = [], s = [];+ for (let r = 0; r < i.len; r++) {+ const a = i.texts[r];+ if (e.push(a), t.push(i.isWordLike[r]), n.push(i.kinds[r]), s.push(i.starts[r]), !TM(a))+ continue;+ const o = r + 1;+ if (o >= i.len || Dd(i.kinds[o]))+ continue;+ const c = [], l = i.starts[o];+ let h = o;+ for (; h < i.len && !Dd(i.kinds[h]); )+ c.push(i.texts[h]), h++;+ c.length > 0 && (e.push(ri(c)), t.push(!0), n.push("text"), s.push(l), r = h - 1);+ }+ return {+ len: e.length,+ texts: e,+ isWordLike: t,+ kinds: n,+ starts: s+ };+}+const FM = /* @__PURE__ */ new Set([+ ":",+ "-",+ "/",+ "×",+ ",",+ ".",+ "+",+ "–",+ "—"+]), JA = /^[A-Za-z0-9_]+[,:;]*$/, ZA = /[,:;]+$/;+function V0(i) {+ for (const e of i)+ if (H0.test(e))+ return !0;+ return !1;+}+function Pl(i) {+ if (i.length === 0)+ return !1;+ for (const e of i)+ if (!(H0.test(e) || FM.has(e)))+ return !1;+ return !0;+}+function DM(i) {+ const e = [], t = [], n = [], s = [];+ for (let r = 0; r < i.len; r++) {+ const a = i.texts[r], o = i.kinds[r];+ if (o === "text" && Pl(a) && V0(a)) {+ const c = [a];+ let l = r + 1;+ for (; l < i.len && i.kinds[l] === "text" && Pl(i.texts[l]); )+ c.push(i.texts[l]), l++;+ e.push(ri(c)), t.push(!0), n.push("text"), s.push(i.starts[r]), r = l - 1;+ continue;+ }+ e.push(a), t.push(i.isWordLike[r]), n.push(o), s.push(i.starts[r]);+ }+ return {+ len: e.length,+ texts: e,+ isWordLike: t,+ kinds: n,+ starts: s+ };+}+function LM(i) {+ const e = [], t = [], n = [], s = [];+ for (let r = 0; r < i.len; r++) {+ const a = i.texts[r], o = i.kinds[r], c = i.isWordLike[r];+ if (o === "text" && c && JA.test(a)) {+ const l = [a];+ let h = ZA.test(a), u = r + 1;+ for (; h && u < i.len && i.kinds[u] === "text" && i.isWordLike[u] && JA.test(i.texts[u]); ) {+ const d = i.texts[u];+ l.push(d), h = ZA.test(d), u++;+ }+ e.push(ri(l)), t.push(!0), n.push("text"), s.push(i.starts[r]), r = u - 1;+ continue;+ }+ e.push(a), t.push(c), n.push(o), s.push(i.starts[r]);+ }+ return {+ len: e.length,+ texts: e,+ isWordLike: t,+ kinds: n,+ starts: s+ };+}+function PM(i) {+ const e = [], t = [], n = [], s = [];+ for (let r = 0; r < i.len; r++) {+ const a = i.texts[r];+ if (i.kinds[r] === "text" && a.includes("-")) {+ const o = a.split("-");+ let c = o.length > 1;+ for (let l = 0; l < o.length; l++) {+ const h = o[l];+ if (!c)+ break;+ (h.length === 0 || !V0(h) || !Pl(h)) && (c = !1);+ }+ if (c) {+ let l = 0;+ for (let h = 0; h < o.length; h++) {+ const u = o[h], d = h < o.length - 1 ? `${u}-` : u;+ e.push(d), t.push(!0), n.push("text"), s.push(i.starts[r] + l), l += d.length;+ }+ continue;+ }+ }+ e.push(a), t.push(i.isWordLike[r]), n.push(i.kinds[r]), s.push(i.starts[r]);+ }+ return {+ len: e.length,+ texts: e,+ isWordLike: t,+ kinds: n,+ starts: s+ };+}+function kM(i) {+ const e = [], t = [], n = [], s = [];+ let r = 0;+ for (; r < i.len; ) {+ const a = [i.texts[r]];+ let o = i.isWordLike[r], c = i.kinds[r], l = i.starts[r];+ if (c === "glue") {+ const h = [a[0]], u = l;+ for (r++; r < i.len && i.kinds[r] === "glue"; )+ h.push(i.texts[r]), r++;+ const d = ri(h);+ if (r < i.len && i.kinds[r] === "text")+ a[0] = d, a.push(i.texts[r]), o = i.isWordLike[r], c = "text", l = u, r++;+ else {+ e.push(d), t.push(!1), n.push("glue"), s.push(u);+ continue;+ }+ } else+ r++;+ if (c === "text")+ for (; r < i.len && i.kinds[r] === "glue"; ) {+ const h = [];+ for (; r < i.len && i.kinds[r] === "glue"; )+ h.push(i.texts[r]), r++;+ const u = ri(h);+ if (r < i.len && i.kinds[r] === "text") {+ a.push(u, i.texts[r]), o = o || i.isWordLike[r], r++;+ continue;+ }+ a.push(u);+ }+ e.push(ri(a)), t.push(o), n.push(c), s.push(l);+ }+ return {+ len: e.length,+ texts: e,+ isWordLike: t,+ kinds: n,+ starts: s+ };+}+function UM(i) {+ const e = i.texts.slice(), t = i.isWordLike.slice(), n = i.kinds.slice(), s = i.starts.slice();+ for (let r = 0; r < e.length - 1; r++) {+ if (n[r] !== "text" || n[r + 1] !== "text" || !vr(e[r]) || !vr(e[r + 1]))+ continue;+ const a = _M(e[r]);+ a !== null && (e[r] = a.head, e[r + 1] = a.tail + e[r + 1], s[r + 1] = s[r] + a.head.length);+ }+ return {+ len: e.length,+ texts: e,+ isWordLike: t,+ kinds: n,+ starts: s+ };+}+function $A(i, e, t) {+ const n = oM();+ let s = 0;+ const r = [], a = [], o = [], c = [], l = [], h = [], u = [], d = [], f = [], m = [], A = [], g = [];+ for (const w of n.segment(i))+ for (const S of IM(w.segment, w.isWordLike ?? !1, w.index, t)) {+ let O = function() {+ h[D] !== null && (a[D] = [+ XA(r, h, u, D)+ ], h[D] = null), a[D].push(S.text), o[D] = o[D] || S.isWordLike, d[D] = d[D] || v, f[D] = f[D] || F, m[D] = q, A[D] = $, g[D] = YA(f[D], K);+ };+ const T = S.kind === "text", C = EM(S.text, S.isWordLike, S.kind), v = vr(S.text), F = KA(S.text), K = nh(S.text), q = Fd(S.text), $ = yM(S.text), D = s - 1;+ e.carryCJKAfterClosingQuote && T && s > 0 && c[D] === "text" && v && d[D] && m[D] || T && s > 0 && c[D] === "text" && bM(S.text) && d[D] || T && s > 0 && c[D] === "text" && A[D] ? O() : T && s > 0 && c[D] === "text" && S.isWordLike && F && g[D] ? (O(), o[D] = !0) : C !== null && s > 0 && c[D] === "text" && h[D] === C ? u[D] = (u[D] ?? 1) + 1 : T && !S.isWordLike && s > 0 && c[D] === "text" && (mM(S.text) || S.text === "-" && o[D]) ? O() : (r[s] = S.text, a[s] = [S.text], o[s] = S.isWordLike, c[s] = S.kind, l[s] = S.start, h[s] = C, u[s] = C === null ? 0 : 1, d[s] = v, f[s] = F, m[s] = q, A[s] = $, g[s] = YA(F, K), s++);+ }+ for (let w = 0; w < s; w++) {+ if (h[w] !== null) {+ r[w] = XA(r, h, u, w);+ continue;+ }+ r[w] = ri(a[w]);+ }+ for (let w = 1; w < s; w++)+ c[w] === "text" && !o[w] && Uf(r[w]) && c[w - 1] === "text" && (r[w - 1] += r[w], o[w - 1] = o[w - 1] || o[w], r[w] = "");+ const p = Array.from({ length: s }, () => null);+ let y = -1;+ for (let w = s - 1; w >= 0; w--) {+ const S = r[w];+ if (S.length !== 0) {+ if (c[w] === "text" && !o[w] && xM(S) && y >= 0 && c[y] === "text") {+ const T = p[y] ?? [];+ T.push(S), p[y] = T, l[y] = l[w], r[w] = "";+ continue;+ }+ y = w;+ }+ }+ for (let w = 0; w < s; w++) {+ const S = p[w];+ S != null && (r[w] = SM(S, r[w]));+ }+ let b = 0;+ for (let w = 0; w < s; w++) {+ const S = r[w];+ S.length !== 0 && (b !== w && (r[b] = S, o[b] = o[w], c[b] = c[w], l[b] = l[w]), b++);+ }+ r.length = b, o.length = b, c.length = b, l.length = b;+ const E = kM({+ len: b,+ texts: r,+ isWordLike: o,+ kinds: c,+ starts: l+ }), M = UM(LM(PM(DM(NM(RM(E))))));+ for (let w = 0; w < M.len - 1; w++) {+ const S = wM(M.texts[w]);+ S !== null && (M.kinds[w] !== "space" && M.kinds[w] !== "preserved-space" || M.kinds[w + 1] !== "text" || !KA(M.texts[w + 1]) || (M.texts[w] = S.space, M.isWordLike[w] = !1, M.kinds[w] = M.kinds[w] === "preserved-space" ? "preserved-space" : "space", M.texts[w + 1] = S.marks + M.texts[w + 1], M.starts[w + 1] = M.starts[w] + S.space.length));+ }+ return M;+}+function OM(i, e) {+ if (i.len === 0)+ return [];+ if (!e.preserveHardBreaks)+ return [{+ startSegmentIndex: 0,+ endSegmentIndex: i.len,+ consumedEndSegmentIndex: i.len+ }];+ const t = [];+ let n = 0;+ for (let s = 0; s < i.len; s++)+ i.kinds[s] === "hard-break" && (t.push({+ startSegmentIndex: n,+ endSegmentIndex: s,+ consumedEndSegmentIndex: s + 1+ }), n = s + 1);+ return n < i.len && t.push({+ startSegmentIndex: n,+ endSegmentIndex: i.len,+ consumedEndSegmentIndex: i.len+ }), t;+}+function QM(i) {+ if (i.len <= 1)+ return i;+ const e = [], t = [], n = [], s = [];+ let r = null, a = !1, o = 0, c = !1, l = !1;+ function h() {+ r !== null && (e.push(ri(r)), t.push(a), n.push("text"), s.push(o), r = null);+ }+ for (let u = 0; u < i.len; u++) {+ const d = i.texts[u], f = i.kinds[u], m = i.isWordLike[u], A = i.starts[u];+ if (f === "text") {+ const g = uM(d), p = fM(d);+ if (r !== null && c && l) {+ r.push(d), a = a || m, c = c || g, l = p;+ continue;+ }+ h(), r = [d], a = m, o = A, c = g, l = p;+ continue;+ }+ h(), e.push(d), t.push(m), n.push(f), s.push(A);+ }+ return h(), {+ len: e.length,+ texts: e,+ isWordLike: t,+ kinds: n,+ starts: s+ };+}+function GM(i, e, t = "normal", n = "normal") {+ const s = iM(t), r = s.mode === "pre-wrap" ? rM(i) : sM(i);+ if (r.length === 0)+ return {+ normalized: r,+ chunks: [],+ len: 0,+ texts: [],+ isWordLike: [],+ kinds: [],+ starts: []+ };+ const a = n === "keep-all" ? QM($A(r, e, s)) : $A(r, e, s);+ return {+ normalized: r,+ chunks: OM(a, s),+ ...a+ };+}+let Jr = null;+const eg = /* @__PURE__ */ new Map();+let Zr = null;+const HM = 96, zM = new RegExp("\\p{Emoji_Presentation}", "u"), VM = /[\p{Emoji_Presentation}\p{Extended_Pictographic}\p{Regional_Indicator}\uFE0F\u20E3]/u;+let au = null;+const tg = /* @__PURE__ */ new Map();+function Of() {+ if (Jr !== null)+ return Jr;+ if (typeof OffscreenCanvas < "u")+ return Jr = new OffscreenCanvas(1, 1).getContext("2d"), Jr;+ if (typeof document < "u")+ return Jr = document.createElement("canvas").getContext("2d"), Jr;+ throw new Error("Text measurement requires OffscreenCanvas or a DOM canvas context.");+}+function WM(i) {+ let e = eg.get(i);+ return e || (e = /* @__PURE__ */ new Map(), eg.set(i, e)), e;+}+function Fs(i, e) {+ let t = e.get(i);+ return t === void 0 && (t = {+ width: Of().measureText(i).width,+ containsCJK: vr(i)+ }, e.set(i, t)), t;+}+function Ha() {+ if (Zr !== null)+ return Zr;+ if (typeof navigator > "u")+ return Zr = {+ lineFitEpsilon: 5e-3,+ carryCJKAfterClosingQuote: !1,+ preferPrefixWidthsForBreakableRuns: !1,+ preferEarlySoftHyphenBreak: !1+ }, Zr;+ const i = navigator.userAgent, t = navigator.vendor === "Apple Computer, Inc." && i.includes("Safari/") && !i.includes("Chrome/") && !i.includes("Chromium/") && !i.includes("CriOS/") && !i.includes("FxiOS/") && !i.includes("EdgiOS/"), n = i.includes("Chrome/") || i.includes("Chromium/") || i.includes("CriOS/") || i.includes("Edg/");+ return Zr = {+ lineFitEpsilon: t ? 1 / 64 : 5e-3,+ carryCJKAfterClosingQuote: n,+ preferPrefixWidthsForBreakableRuns: t,+ preferEarlySoftHyphenBreak: t+ }, Zr;+}+function qM(i) {+ const e = i.match(/(\d+(?:\.\d+)?)\s*px/);+ return e ? parseFloat(e[1]) : 16;+}+function W0() {+ return au === null && (au = new Intl.Segmenter(void 0, { granularity: "grapheme" })), au;+}+function KM(i) {+ return zM.test(i) || i.includes("️");+}+function jM(i) {+ return VM.test(i);+}+function XM(i, e) {+ let t = tg.get(i);+ if (t !== void 0)+ return t;+ const n = Of();+ n.font = i;+ const s = n.measureText("😀").width;+ if (t = 0, s > e + 0.5 && typeof document < "u" && document.body !== null) {+ const r = document.createElement("span");+ r.style.font = i, r.style.display = "inline-block", r.style.visibility = "hidden", r.style.position = "absolute", r.textContent = "😀", document.body.appendChild(r);+ const a = r.getBoundingClientRect().width;+ document.body.removeChild(r), s - a > 0.5 && (t = s - a);+ }+ return tg.set(i, t), t;+}+function YM(i) {+ let e = 0;+ const t = W0();+ for (const n of t.segment(i))+ KM(n.segment) && e++;+ return e;+}+function JM(i, e) {+ return e.emojiCount === void 0 && (e.emojiCount = YM(i)), e.emojiCount;+}+function pr(i, e, t) {+ return t === 0 ? e.width : e.width - JM(i, e) * t;+}+function ZM(i, e, t, n, s) {+ if (e.breakableFitAdvances !== void 0)+ return e.breakableFitAdvances;+ const r = W0(), a = [];+ for (const h of r.segment(i))+ a.push(h.segment);+ if (a.length <= 1)+ return e.breakableFitAdvances = null, e.breakableFitAdvances;+ if (s === "sum-graphemes") {+ const h = [];+ for (const u of a) {+ const d = Fs(u, t);+ h.push(pr(u, d, n));+ }+ return e.breakableFitAdvances = h, e.breakableFitAdvances;+ }+ if (s === "pair-context" || a.length > HM) {+ const h = [];+ let u = null, d = 0;+ for (const f of a) {+ const m = Fs(f, t), A = pr(f, m, n);+ if (u === null)+ h.push(A);+ else {+ const g = u + f, p = Fs(g, t);+ h.push(pr(g, p, n) - d);+ }+ u = f, d = A;+ }+ return e.breakableFitAdvances = h, e.breakableFitAdvances;+ }+ const o = [];+ let c = "", l = 0;+ for (const h of a) {+ c += h;+ const u = Fs(c, t), d = pr(c, u, n);+ o.push(d - l), l = d;+ }+ return e.breakableFitAdvances = o, e.breakableFitAdvances;+}+function $M(i, e) {+ const t = Of();+ t.font = i;+ const n = WM(i), s = qM(i), r = e ? XM(i, s) : 0;+ return { cache: n, fontSize: s, emojiCorrection: r };+}+function eB(i, e) {+ for (; e < i.widths.length; ) {+ const t = i.kinds[e];+ if (t !== "space" && t !== "zero-width-break" && t !== "soft-hyphen")+ break;+ e++;+ }+ return e;+}+function q0(i, e) {+ if (e <= 0)+ return 0;+ const t = i % e;+ return Math.abs(t) <= 1e-6 ? e : e - t;+}+function K0(i, e, t, n, s) {+ let r = 0, a = e;+ for (; r < i.length; ) {+ const o = a + i[r];+ if ((r + 1 < i.length ? o + s : o) > t + n)+ break;+ a = o, r++;+ }+ return { fitCount: r, fittedWidth: a };+}+function tB(i, e) {+ let t = 0, n = i.chunks.length;+ for (; t < n; ) {+ const s = Math.floor((t + n) / 2);+ e < i.chunks[s].consumedEndSegmentIndex ? n = s : t = s + 1;+ }+ return t < i.chunks.length ? t : -1;+}+function j0(i, e, t) {+ let n = t.segmentIndex;+ if (t.graphemeIndex > 0)+ return e;+ const s = i.chunks[e];+ if (s.startSegmentIndex === s.endSegmentIndex && n === s.startSegmentIndex)+ return t.segmentIndex = n, t.graphemeIndex = 0, e;+ for (n < s.startSegmentIndex && (n = s.startSegmentIndex); n < s.endSegmentIndex; ) {+ const r = i.kinds[n];+ if (r !== "space" && r !== "zero-width-break" && r !== "soft-hyphen")+ return t.segmentIndex = n, t.graphemeIndex = 0, e;+ n++;+ }+ return s.consumedEndSegmentIndex >= i.widths.length ? -1 : (t.segmentIndex = s.consumedEndSegmentIndex, t.graphemeIndex = 0, e + 1);+}+function Qf(i, e) {+ if (e.segmentIndex >= i.widths.length)+ return -1;+ const t = tB(i, e.segmentIndex);+ return t < 0 ? -1 : j0(i, t, e);+}+function nB(i, e, t) {+ if (t.segmentIndex >= i.widths.length)+ return -1;+ let n = e;+ for (; n < i.chunks.length && t.segmentIndex >= i.chunks[n].consumedEndSegmentIndex; )+ n++;+ return n >= i.chunks.length ? -1 : j0(i, n, t);+}+function iB(i, e) {+ return i.simpleLineWalkFastPath ? X0(i, e) : Gf(i, e);+}+function X0(i, e, t) {+ const { widths: n, kinds: s, breakableFitAdvances: r } = i;+ if (n.length === 0)+ return 0;+ const o = Ha().lineFitEpsilon, c = e + o;+ let l = 0, h = 0, u = !1, d = 0, f = 0, m = 0, A = 0, g = -1, p = 0;+ function y() {+ g = -1, p = 0;+ }+ function b(C = m, v = A, F = h) {+ l++, t?.({+ startSegmentIndex: d,+ startGraphemeIndex: f,+ endSegmentIndex: C,+ endGraphemeIndex: v,+ width: F+ }), h = 0, u = !1, y();+ }+ function E(C, v) {+ u = !0, d = C, f = 0, m = C + 1, A = 0, h = v;+ }+ function M(C, v, F) {+ u = !0, d = C, f = v, m = C, A = v + 1, h = F;+ }+ function w(C, v) {+ if (!u) {+ E(C, v);+ return;+ }+ h += v, m = C + 1, A = 0;+ }+ function S(C, v) {+ const F = r[C];+ for (let K = v; K < F.length; K++) {+ const q = F[K];+ u ? h + q > c ? (b(), M(C, K, q)) : (h += q, m = C, A = K + 1) : M(C, K, q);+ }+ u && m === C && A === F.length && (m = C + 1, A = 0);+ }+ let T = 0;+ for (; T < n.length && !(!u && (T = eB(i, T), T >= n.length)); ) {+ const C = n[T], v = s[T], F = v === "space" || v === "preserved-space" || v === "tab" || v === "zero-width-break" || v === "soft-hyphen";+ if (!u) {+ C > e && r[T] !== null ? S(T, 0) : E(T, C), F && (g = T + 1, p = h - C), T++;+ continue;+ }+ if (h + C > c) {+ if (F) {+ w(T, C), b(T + 1, 0, h - C), T++;+ continue;+ }+ if (g >= 0) {+ if (m > g || m === g && A > 0) {+ b();+ continue;+ }+ b(g, 0, p);+ continue;+ }+ if (C > e && r[T] !== null) {+ b(), S(T, 0), T++;+ continue;+ }+ b();+ continue;+ }+ w(T, C), F && (g = T + 1, p = h - C), T++;+ }+ return u && b(), l;+}+function Gf(i, e, t) {+ if (i.simpleLineWalkFastPath)+ return X0(i, e, t);+ const { widths: n, lineEndFitAdvances: s, lineEndPaintAdvances: r, kinds: a, breakableFitAdvances: o, discretionaryHyphenWidth: c, tabStopAdvance: l, chunks: h } = i;+ if (n.length === 0 || h.length === 0)+ return 0;+ const u = Ha(), d = u.lineFitEpsilon, f = e + d;+ let m = 0, A = 0, g = !1, p = 0, y = 0, b = 0, E = 0, M = -1, w = 0, S = 0, T = null;+ function C() {+ M = -1, w = 0, S = 0, T = null;+ }+ function v(Q = b, J = E, ee = A) {+ m++, t?.({+ startSegmentIndex: p,+ startGraphemeIndex: y,+ endSegmentIndex: Q,+ endGraphemeIndex: J,+ width: ee+ }), A = 0, g = !1, C();+ }+ function F(Q, J) {+ g = !0, p = Q, y = 0, b = Q + 1, E = 0, A = J;+ }+ function K(Q, J, ee) {+ g = !0, p = Q, y = J, b = Q, E = J + 1, A = ee;+ }+ function q(Q, J) {+ if (!g) {+ F(Q, J);+ return;+ }+ A += J, b = Q + 1, E = 0;+ }+ function $(Q, J, ee, ae) {+ if (!J)+ return;+ const ye = Q === "tab" ? 0 : s[ee], Me = Q === "tab" ? ae : r[ee];+ M = ee + 1, w = A - ae + ye, S = A - ae + Me, T = Q;+ }+ function D(Q, J) {+ const ee = o[Q];+ for (let ae = J; ae < ee.length; ae++) {+ const ye = ee[ae];+ g ? A + ye > f ? (v(), K(Q, ae, ye)) : (A += ye, b = Q, E = ae + 1) : K(Q, ae, ye);+ }+ g && b === Q && E === ee.length && (b = Q + 1, E = 0);+ }+ function O(Q) {+ if (T !== "soft-hyphen")+ return !1;+ const J = o[Q];+ if (J == null)+ return !1;+ const { fitCount: ee, fittedWidth: ae } = K0(J, A, e, d, c);+ return ee === 0 ? !1 : (A = ae, b = Q, E = ee, C(), ee === J.length ? (b = Q + 1, E = 0, !0) : (v(Q, ee, ae + c), D(Q, ee), !0));+ }+ function Y(Q) {+ m++, t?.({+ startSegmentIndex: Q.startSegmentIndex,+ startGraphemeIndex: 0,+ endSegmentIndex: Q.consumedEndSegmentIndex,+ endGraphemeIndex: 0,+ width: 0+ }), C();+ }+ for (let Q = 0; Q < h.length; Q++) {+ const J = h[Q];+ if (J.startSegmentIndex === J.endSegmentIndex) {+ Y(J);+ continue;+ }+ g = !1, A = 0, p = J.startSegmentIndex, y = 0, b = J.startSegmentIndex, E = 0, C();+ let ee = J.startSegmentIndex;+ for (; ee < J.endSegmentIndex; ) {+ const ae = a[ee], ye = ae === "space" || ae === "preserved-space" || ae === "tab" || ae === "zero-width-break" || ae === "soft-hyphen", Me = ae === "tab" ? q0(A, l) : n[ee];+ if (ae === "soft-hyphen") {+ g && (b = ee + 1, E = 0, M = ee + 1, w = A + c, S = A + c, T = ae), ee++;+ continue;+ }+ if (!g) {+ Me > e && o[ee] !== null ? D(ee, 0) : F(ee, Me), $(ae, ye, ee, Me), ee++;+ continue;+ }+ if (A + Me > f) {+ const me = A + (ae === "tab" ? 0 : s[ee]), be = A + (ae === "tab" ? Me : r[ee]);+ if (T === "soft-hyphen" && u.preferEarlySoftHyphenBreak && w <= f) {+ v(M, 0, S);+ continue;+ }+ if (T === "soft-hyphen" && O(ee)) {+ ee++;+ continue;+ }+ if (ye && me <= f) {+ q(ee, Me), v(ee + 1, 0, be), ee++;+ continue;+ }+ if (M >= 0 && w <= f) {+ if (b > M || b === M && E > 0) {+ v();+ continue;+ }+ const xe = M;+ v(xe, 0, S), ee = xe;+ continue;+ }+ if (Me > e && o[ee] !== null) {+ v(), D(ee, 0), ee++;+ continue;+ }+ v();+ continue;+ }+ q(ee, Me), $(ae, ye, ee, Me), ee++;+ }+ if (g) {+ const ae = M === J.consumedEndSegmentIndex ? S : A;+ v(J.consumedEndSegmentIndex, 0, ae);+ }+ }+ return m;+}+function Hf(i, e, t, n) {+ const s = i.chunks[t];+ if (s.startSegmentIndex === s.endSegmentIndex)+ return e.segmentIndex = s.consumedEndSegmentIndex, e.graphemeIndex = 0, 0;+ const { widths: r, lineEndFitAdvances: a, lineEndPaintAdvances: o, kinds: c, breakableFitAdvances: l, discretionaryHyphenWidth: h, tabStopAdvance: u } = i, d = Ha(), f = d.lineFitEpsilon, m = n + f;+ let A = 0, g = !1, p = e.segmentIndex, y = e.graphemeIndex, b = -1, E = 0, M = 0, w = null;+ function S() {+ b = -1, E = 0, M = 0, w = null;+ }+ function T(D = p, O = y, Y = A) {+ return g ? (e.segmentIndex = D, e.graphemeIndex = O, Y) : null;+ }+ function C(D, O) {+ g = !0, p = D + 1, y = 0, A = O;+ }+ function v(D, O, Y) {+ g = !0, p = D, y = O + 1, A = Y;+ }+ function F(D, O) {+ if (!g) {+ C(D, O);+ return;+ }+ A += O, p = D + 1, y = 0;+ }+ function K(D, O, Y, Q) {+ if (!O)+ return;+ const J = D === "tab" ? 0 : a[Y], ee = D === "tab" ? Q : o[Y];+ b = Y + 1, E = A - Q + J, M = A - Q + ee, w = D;+ }+ function q(D, O) {+ const Y = l[D];+ for (let Q = O; Q < Y.length; Q++) {+ const J = Y[Q];+ if (!g)+ v(D, Q, J);+ else {+ if (A + J > m)+ return T();+ A += J, p = D, y = Q + 1;+ }+ }+ return g && p === D && y === Y.length && (p = D + 1, y = 0), null;+ }+ function $(D) {+ if (w !== "soft-hyphen" || b < 0)+ return null;+ const O = l[D] ?? null;+ if (O !== null) {+ const { fitCount: Y, fittedWidth: Q } = K0(O, A, n, f, h);+ if (Y === O.length)+ return A = Q, p = D + 1, y = 0, S(), null;+ if (Y > 0)+ return T(D, Y, Q + h);+ }+ return E <= m ? T(b, 0, M) : null;+ }+ for (let D = e.segmentIndex; D < s.endSegmentIndex; D++) {+ const O = c[D], Y = O === "space" || O === "preserved-space" || O === "tab" || O === "zero-width-break" || O === "soft-hyphen", Q = D === e.segmentIndex ? e.graphemeIndex : 0, J = O === "tab" ? q0(A, u) : r[D];+ if (O === "soft-hyphen" && Q === 0) {+ g && (p = D + 1, y = 0, b = D + 1, E = A + h, M = A + h, w = O);+ continue;+ }+ if (!g) {+ if (Q > 0) {+ const ae = q(D, Q);+ if (ae !== null)+ return ae;+ } else if (J > n && l[D] !== null) {+ const ae = q(D, 0);+ if (ae !== null)+ return ae;+ } else+ C(D, J);+ K(O, Y, D, J);+ continue;+ }+ if (A + J > m) {+ const ae = A + (O === "tab" ? 0 : a[D]), ye = A + (O === "tab" ? J : o[D]);+ if (w === "soft-hyphen" && d.preferEarlySoftHyphenBreak && E <= m)+ return T(b, 0, M);+ const Me = $(D);+ if (Me !== null)+ return Me;+ if (Y && ae <= m)+ return F(D, J), T(D + 1, 0, ye);+ if (b >= 0 && E <= m)+ return p > b || p === b && y > 0 ? T() : T(b, 0, M);+ if (J > n && l[D] !== null) {+ const se = T();+ if (se !== null)+ return se;+ const me = q(D, 0);+ if (me !== null)+ return me;+ }+ return T();+ }+ F(D, J), K(O, Y, D, J);+ }+ return b === s.consumedEndSegmentIndex && y === 0 ? T(s.consumedEndSegmentIndex, 0, M) : T(s.consumedEndSegmentIndex, 0, A);+}+function Y0(i, e, t) {+ const { widths: n, kinds: s, breakableFitAdvances: r } = i, o = Ha().lineFitEpsilon, c = t + o;+ let l = 0, h = !1, u = e.segmentIndex, d = e.graphemeIndex, f = -1, m = 0;+ for (let A = e.segmentIndex; A < n.length; A++) {+ const g = n[A], p = s[A], y = p === "space" || p === "preserved-space" || p === "tab" || p === "zero-width-break" || p === "soft-hyphen", b = A === e.segmentIndex ? e.graphemeIndex : 0, E = r[A];+ if (!h) {+ if (b > 0 || g > t && E !== null) {+ const M = E, w = M[b];+ h = !0, l = w, u = A, d = b + 1;+ for (let S = b + 1; S < M.length; S++) {+ const T = M[S];+ if (l + T > c)+ return e.segmentIndex = u, e.graphemeIndex = d, l;+ l += T, u = A, d = S + 1;+ }+ u === A && d === M.length && (u = A + 1, d = 0);+ } else+ h = !0, l = g, u = A + 1, d = 0;+ y && (f = A + 1, m = l - g);+ continue;+ }+ if (l + g > c)+ return y ? (e.segmentIndex = A + 1, e.graphemeIndex = 0, l) : f >= 0 ? u > f || u === f && d > 0 ? (e.segmentIndex = u, e.graphemeIndex = d, l) : (e.segmentIndex = f, e.graphemeIndex = 0, m) : (e.segmentIndex = u, e.graphemeIndex = d, l);+ l += g, u = A + 1, d = 0, y && (f = A + 1, m = l - g);+ }+ return h ? (e.segmentIndex = u, e.graphemeIndex = d, l) : null;+}+function Ld(i, e, t) {+ const n = {+ segmentIndex: e.segmentIndex,+ graphemeIndex: e.graphemeIndex+ }, s = Qf(i, n);+ if (s < 0)+ return null;+ const r = n.segmentIndex, a = n.graphemeIndex, o = i.simpleLineWalkFastPath ? Y0(i, n, t) : Hf(i, n, s, t);+ return o === null ? null : {+ startSegmentIndex: r,+ startGraphemeIndex: a,+ endSegmentIndex: n.segmentIndex,+ endGraphemeIndex: n.graphemeIndex,+ width: o+ };+}+function sB(i, e, t) {+ const n = Qf(i, e);+ return n < 0 ? null : i.simpleLineWalkFastPath ? Y0(i, e, t) : Hf(i, e, n, t);+}+function rB(i, e) {+ if (i.widths.length === 0)+ return {+ lineCount: 0,+ maxLineWidth: 0+ };+ const t = {+ segmentIndex: 0,+ graphemeIndex: 0+ };+ let n = 0, s = 0;+ if (!i.simpleLineWalkFastPath) {+ let r = Qf(i, t);+ for (; r >= 0; ) {+ const a = Hf(i, t, r, e);+ if (a === null)+ return {+ lineCount: n,+ maxLineWidth: s+ };+ n++, a > s && (s = a), r = nB(i, r, t);+ }+ return {+ lineCount: n,+ maxLineWidth: s+ };+ }+ for (; ; ) {+ const r = sB(i, t, e);+ if (r === null)+ return {+ lineCount: n,+ maxLineWidth: s+ };+ n++, r > s && (s = r);+ }+}+let ou = null, ng = /* @__PURE__ */ new WeakMap();+function J0() {+ return ou === null && (ou = new Intl.Segmenter(void 0, { granularity: "grapheme" })), ou;+}+function aB(i) {+ return i ? {+ widths: [],+ lineEndFitAdvances: [],+ lineEndPaintAdvances: [],+ kinds: [],+ simpleLineWalkFastPath: !0,+ segLevels: null,+ breakableFitAdvances: [],+ discretionaryHyphenWidth: 0,+ tabStopAdvance: 0,+ chunks: [],+ segments: []+ } : {+ widths: [],+ lineEndFitAdvances: [],+ lineEndPaintAdvances: [],+ kinds: [],+ simpleLineWalkFastPath: !0,+ segLevels: null,+ breakableFitAdvances: [],+ discretionaryHyphenWidth: 0,+ tabStopAdvance: 0,+ chunks: []+ };+}+function oB(i, e) {+ const t = [];+ let n = [], s = 0, r = !1, a = !1, o = !1;+ function c() {+ n.length !== 0 && (t.push({+ text: n.length === 1 ? n[0] : n.join(""),+ start: s+ }), n = [], r = !1, a = !1, o = !1);+ }+ function l(u, d, f) {+ n = [u], s = d, r = f, a = Fd(u), o = th.has(u);+ }+ function h(u, d) {+ n.push(u), r = r || d;+ const f = Fd(u);+ u.length === 1 && Cr.has(u) ? a = a || f : a = f, o = !1;+ }+ for (const u of J0().segment(i)) {+ const d = u.segment, f = vr(d);+ if (n.length === 0) {+ l(d, u.index, f);+ continue;+ }+ if (o || Pf.has(d) || Cr.has(d) || e.carryCJKAfterClosingQuote && f && a) {+ h(d, f);+ continue;+ }+ if (!r && !f) {+ h(d, f);+ continue;+ }+ c(), l(d, u.index, f);+ }+ return c(), t;+}+function cB(i, e, t, n) {+ const s = Ha(), { cache: r, emojiCorrection: a } = $M(e, jM(i.normalized)), o = pr("-", Fs("-", r), a), l = pr(" ", Fs(" ", r), a) * 8;+ if (i.len === 0)+ return aB(t);+ const h = [], u = [], d = [], f = [];+ let m = i.chunks.length <= 1;+ const A = t ? [] : null, g = [], p = t ? [] : null, y = Array.from({ length: i.len });+ function b(S, T, C, v, F, K, q) {+ F !== "text" && F !== "space" && F !== "zero-width-break" && (m = !1), h.push(T), u.push(C), d.push(v), f.push(F), A?.push(K), g.push(q), p !== null && p.push(S);+ }+ function E(S, T, C, v, F) {+ const K = Fs(S, r), q = pr(S, K, a), $ = T === "space" || T === "preserved-space" || T === "zero-width-break" ? 0 : q, D = T === "space" || T === "zero-width-break" ? 0 : q;+ if (F && v && S.length > 1) {+ let O = "sum-graphemes";+ Pl(S) ? O = "pair-context" : s.preferPrefixWidthsForBreakableRuns && (O = "segment-prefixes");+ const Y = ZM(S, K, r, a, O);+ b(S, q, $, D, T, C, Y);+ return;+ }+ b(S, q, $, D, T, C, null);+ }+ for (let S = 0; S < i.len; S++) {+ y[S] = h.length;+ const T = i.texts[S], C = i.isWordLike[S], v = i.kinds[S], F = i.starts[S];+ if (v === "soft-hyphen") {+ b(T, 0, o, o, v, F, null);+ continue;+ }+ if (v === "hard-break") {+ b(T, 0, 0, 0, v, F, null);+ continue;+ }+ if (v === "tab") {+ b(T, 0, 0, 0, v, F, null);+ continue;+ }+ const K = Fs(T, r);+ if (v === "text" && K.containsCJK) {+ const $ = oB(T, s);+ for (let D = 0; D < $.length; D++) {+ const O = $[D];+ E(O.text, "text", F + O.start, C, !vr(O.text));+ }+ continue;+ }+ E(T, v, F, C, !0);+ }+ const M = lB(i.chunks, y, h.length), w = A === null ? null : eM(i.normalized, A);+ return p !== null ? {+ widths: h,+ lineEndFitAdvances: u,+ lineEndPaintAdvances: d,+ kinds: f,+ simpleLineWalkFastPath: m,+ segLevels: w,+ breakableFitAdvances: g,+ discretionaryHyphenWidth: o,+ tabStopAdvance: l,+ chunks: M,+ segments: p+ } : {+ widths: h,+ lineEndFitAdvances: u,+ lineEndPaintAdvances: d,+ kinds: f,+ simpleLineWalkFastPath: m,+ segLevels: w,+ breakableFitAdvances: g,+ discretionaryHyphenWidth: o,+ tabStopAdvance: l,+ chunks: M+ };+}+function lB(i, e, t) {+ const n = [];+ for (let s = 0; s < i.length; s++) {+ const r = i[s], a = r.startSegmentIndex < e.length ? e[r.startSegmentIndex] : t, o = r.endSegmentIndex < e.length ? e[r.endSegmentIndex] : t, c = r.consumedEndSegmentIndex < e.length ? e[r.consumedEndSegmentIndex] : t;+ n.push({+ startSegmentIndex: a,+ endSegmentIndex: o,+ consumedEndSegmentIndex: c+ });+ }+ return n;+}+function Z0(i, e, t, n) {+ const r = GM(i, Ha(), n?.whiteSpace, "normal");+ return cB(r, e, t);+}+function Wc(i, e, t) {+ return Z0(i, e, !1, t);+}+function kl(i, e, t) {+ return Z0(i, e, !0, t);+}+function hB(i, e, t) {+ const n = iB(i, e);+ return { lineCount: n, height: n * t };+}+function ig(i, e, t) {+ let n = t.get(i);+ if (n !== void 0)+ return n;+ n = [];+ const s = J0();+ for (const r of s.segment(e[i]))+ n.push(r.segment);+ return t.set(i, n), n;+}+function $0(i) {+ let e = ng.get(i);+ return e !== void 0 || (e = /* @__PURE__ */ new Map(), ng.set(i, e)), e;+}+function uB(i, e, t, n) {+ return n > 0 && i[n - 1] === "soft-hyphen" && !(e === n && t > 0);+}+function dB(i, e, t, n, s, r, a) {+ let o = "";+ const c = uB(e, n, s, r);+ for (let l = n; l < r; l++)+ e[l] === "soft-hyphen" || e[l] === "hard-break" || (l === n && s > 0 ? o += ig(l, i, t).slice(s).join("") : o += i[l]);+ return a > 0 ? (c && (o += "-"), o += ig(r, i, t).slice(n === r ? s : 0, a).join("")) : c && (o += "-"), o;+}+function eb(i, e, t, n, s, r, a) {+ return {+ text: dB(i.segments, i.kinds, e, n, s, r, a),+ width: t,+ start: {+ segmentIndex: n,+ graphemeIndex: s+ },+ end: {+ segmentIndex: r,+ graphemeIndex: a+ }+ };+}+function fB(i, e, t) {+ return eb(i, e, t.width, t.startSegmentIndex, t.startGraphemeIndex, t.endSegmentIndex, t.endGraphemeIndex);+}+function pB(i) {+ return {+ width: i.width,+ start: {+ segmentIndex: i.startSegmentIndex,+ graphemeIndex: i.startGraphemeIndex+ },+ end: {+ segmentIndex: i.endSegmentIndex,+ graphemeIndex: i.endGraphemeIndex+ }+ };+}+function AB(i, e) {+ return eb(i, $0(i), e.width, e.start.segmentIndex, e.start.graphemeIndex, e.end.segmentIndex, e.end.graphemeIndex);+}+function gB(i, e, t) {+ return i.widths.length === 0 ? 0 : Gf(i, e, (n) => {+ t(pB(n));+ });+}+function cu(i, e) {+ return rB(i, e);+}+function sg(i) {+ let e = 0;+ return gB(i, Number.POSITIVE_INFINITY, (t) => {+ t.width > e && (e = t.width);+ }), e;+}+function mB(i, e, t) {+ const n = [];+ if (i.widths.length === 0)+ return { lineCount: 0, height: 0, lines: n };+ const s = $0(i), r = Gf(i, e, (a) => {+ n.push(fB(i, s, a));+ });+ return { lineCount: r, height: r * t, lines: n };+}+const bB = /[ \t\n\f\r]+/, rg = /^[ \t\n\f\r]+/, ag = /[ \t\n\f\r]+$/, gl = { segmentIndex: 0, graphemeIndex: 0 }, tb = {+ itemIndex: 0,+ segmentIndex: 0,+ graphemeIndex: 0+};+function lu(i) {+ return {+ segmentIndex: i.segmentIndex,+ graphemeIndex: i.graphemeIndex+ };+}+function og(i) {+ return i.segmentIndex === 0 && i.graphemeIndex === 0;+}+function qc(i, e) {+ const t = e.get(i);+ if (t !== void 0)+ return t;+ const n = sg(kl("A A", i)), s = sg(kl("AA", i)), r = Math.max(0, n - s);+ return e.set(i, r), r;+}+function xB(i) {+ const e = Ld(i, gl, Number.POSITIVE_INFINITY);+ return e === null ? null : {+ endGraphemeIndex: e.endGraphemeIndex,+ endSegmentIndex: e.endSegmentIndex,+ width: e.width+ };+}+function _B(i, e) {+ return i === 0 && e > 0;+}+function nb(i) {+ const e = [], t = Array.from({ length: i.length }), n = /* @__PURE__ */ new Map();+ let s = 0;+ for (let r = 0; r < i.length; r++) {+ const a = i[r], o = rg.test(a.text), c = ag.test(a.text), l = a.text.replace(rg, "").replace(ag, "");+ if (l.length === 0) {+ bB.test(a.text) && s === 0 && (s = qc(a.font, n));+ continue;+ }+ const h = s > 0 ? s : o ? qc(a.font, n) : 0, u = kl(l, a.font), d = xB(u);+ if (d === null) {+ s = c ? qc(a.font, n) : 0;+ continue;+ }+ const f = {+ break: a.break ?? "normal",+ endGraphemeIndex: d.endGraphemeIndex,+ endSegmentIndex: d.endSegmentIndex,+ extraWidth: a.extraWidth ?? 0,+ gapBefore: h,+ naturalWidth: d.width,+ prepared: u,+ sourceItemIndex: r+ };+ e.push(f), t[r] = f, s = c ? qc(a.font, n) : 0;+ }+ return {+ items: e,+ itemsBySourceItemIndex: t+ };+}+function EB(i, e, t, n) {+ if (i.items.length === 0 || t.itemIndex >= i.items.length)+ return null;+ const s = Math.max(1, e);+ let r = 0, a = s, o = t.itemIndex;+ const c = {+ segmentIndex: t.segmentIndex,+ graphemeIndex: t.graphemeIndex+ };+ e: for (; o < i.items.length; ) {+ const l = i.items[o];+ if (!og(c) && c.segmentIndex === l.endSegmentIndex && c.graphemeIndex === l.endGraphemeIndex) {+ o++, c.segmentIndex = 0, c.graphemeIndex = 0;+ continue;+ }+ const h = r === 0 ? 0 : l.gapBefore, u = og(c);+ if (l.break === "never") {+ if (!u) {+ o++, c.segmentIndex = 0, c.graphemeIndex = 0;+ continue;+ }+ const A = l.naturalWidth + l.extraWidth, g = h + A;+ if (r > 0 && g > a)+ break e;+ n?.(l, h, A, lu(gl), {+ segmentIndex: l.endSegmentIndex,+ graphemeIndex: l.endGraphemeIndex+ }), r += g, a = Math.max(0, s - r), o++, c.segmentIndex = 0, c.graphemeIndex = 0;+ continue;+ }+ const d = h + l.extraWidth;+ if (r > 0 && d >= a)+ break e;+ if (u) {+ const A = d + l.naturalWidth;+ if (A <= a) {+ n?.(l, h, l.naturalWidth + l.extraWidth, lu(gl), {+ segmentIndex: l.endSegmentIndex,+ graphemeIndex: l.endGraphemeIndex+ }), r += A, a = Math.max(0, s - r), o++, c.segmentIndex = 0, c.graphemeIndex = 0;+ continue;+ }+ }+ const f = Math.max(1, a - d), m = Ld(l.prepared, c, f);+ if (m === null) {+ o++, c.segmentIndex = 0, c.graphemeIndex = 0;+ continue;+ }+ if (c.segmentIndex === m.endSegmentIndex && c.graphemeIndex === m.endGraphemeIndex) {+ o++, c.segmentIndex = 0, c.graphemeIndex = 0;+ continue;+ }+ if (r > 0 && u && h > 0 && _B(m.endSegmentIndex, m.endGraphemeIndex)) {+ const A = Ld(l.prepared, gl, Math.max(1, s - l.extraWidth));+ if (A !== null && (A.endSegmentIndex > m.endSegmentIndex || A.endSegmentIndex === m.endSegmentIndex && A.endGraphemeIndex > m.endGraphemeIndex))+ break e;+ }+ if (n?.(l, h, m.width + l.extraWidth, lu(c), {+ segmentIndex: m.endSegmentIndex,+ graphemeIndex: m.endGraphemeIndex+ }), r += h + m.width + l.extraWidth, a = Math.max(0, s - r), m.endSegmentIndex === l.endSegmentIndex && m.endGraphemeIndex === l.endGraphemeIndex) {+ o++, c.segmentIndex = 0, c.graphemeIndex = 0;+ continue;+ }+ c.segmentIndex = m.endSegmentIndex, c.graphemeIndex = m.endGraphemeIndex;+ break;+ }+ return r === 0 ? null : (t.itemIndex = o, t.segmentIndex = c.segmentIndex, t.graphemeIndex = c.graphemeIndex, r);+}+function yB(i, e, t = tb) {+ const n = i, s = {+ itemIndex: t.itemIndex,+ segmentIndex: t.segmentIndex,+ graphemeIndex: t.graphemeIndex+ }, r = [], a = EB(n, e, s, (o, c, l, h, u) => {+ r.push({+ itemIndex: o.sourceItemIndex,+ gapBefore: c,+ occupiedWidth: l,+ start: h,+ end: u+ });+ });+ return a === null ? null : {+ fragments: r,+ width: a,+ end: s+ };+}+function wB(i, e) {+ return AB(i.prepared, {+ width: e.occupiedWidth - i.extraWidth,+ start: e.start,+ end: e.end+ }).text;+}+function ib(i, e) {+ const t = i;+ return {+ fragments: e.fragments.map((n) => {+ const s = t.itemsBySourceItemIndex[n.itemIndex];+ if (s === void 0)+ throw new Error("Missing rich-text inline item for fragment");+ return {+ ...n,+ text: wB(s, n)+ };+ }),+ width: e.width,+ end: e.end+ };+}+function sb(i, e, t) {+ let n = 0, s = tb;+ for (; ; ) {+ const r = yB(i, e, s);+ if (r === null)+ return n;+ t(r), n++, s = r.end;+ }+}+const cg = "500 14px Inter, sans-serif", hu = "600 10px Inter, sans-serif", uu = "300 13px Inter, sans-serif", lg = "600 10px Inter, sans-serif", hg = "300 12px Inter, sans-serif", ao = 18, Kc = 16, sn = 16, Mi = 6, ug = 12, jc = Math.min(window.devicePixelRatio || 1, 2), vB = "rgba(0, 0, 0, 0.75)", CB = "rgba(255, 255, 255, 0.08)", SB = "rgba(255, 255, 255, 0.9)", IB = "rgba(255, 255, 255, 0.30)", MB = "rgba(255, 255, 255, 0.85)", dg = "rgba(255, 255, 255, 0.08)", BB = "rgba(255, 255, 255, 0.45)", TB = "rgba(255, 255, 255, 0.08)", RB = "rgba(255, 255, 255, 0.7)";+function NB(i) {+ let e = 0, t = 0, n = 0;+ const s = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set();+ let o = !1, c = !1;+ return i.traverse((l) => {+ if (l.isMesh || l.isPoints || l.isLine) {+ n++;+ const h = l.geometry;+ h && (h.index ? t += h.index.count / 3 : h.attributes.position && (t += h.attributes.position.count / 3), h.attributes.position && (e += h.attributes.position.count)), l.skeleton && (o = !0), l.morphTargetInfluences && l.morphTargetInfluences.length > 0 && (c = !0), (Array.isArray(l.material) ? l.material : [l.material]).forEach((d) => {+ if (d) {+ s.add(d.uuid), a.add(d.type.replace("Material", ""));+ for (const f in d)+ d[f] && d[f].isTexture && r.add(d[f].uuid);+ }+ });+ }+ }), {+ vertices: e,+ triangles: Math.floor(t),+ meshes: n,+ materials: s.size,+ textures: r.size,+ materialTypes: Array.from(a),+ hasSkinning: o,+ hasMorphs: c+ };+}+function oo(i) {+ return i >= 1e6 ? (i / 1e6).toFixed(1) + "M" : i >= 1e3 ? (i / 1e3).toFixed(1) + "K" : i.toString();+}+function FB(i, e) {+ const t = [];+ return i.hasSkinning && t.push("skinned"), i.hasMorphs && t.push("morph targets"), e && e.length > 0 && t.push(`${e.length} animation${e.length > 1 ? "s" : ""}`), i.materialTypes.length > 0 && t.push(i.materialTypes.join(", ")), t.length > 0 ? t.join(" · ") : "";+}+function DB(i, e, t) {+ const n = NB(e), s = FB(n, t), r = [+ { label: "MESHES", value: oo(n.meshes) },+ { label: "VERTICES", value: oo(n.vertices) },+ { label: "TRIANGLES", value: oo(n.triangles) },+ { label: "MATERIALS", value: oo(n.materials) },+ { label: "TEXTURES", value: oo(n.textures) }+ ];+ t && t.length > 0 && r.push({ label: "ANIMATIONS", value: t.length.toString() });+ const a = [];+ n.materialTypes.forEach((w) => a.push(w)), n.hasSkinning && a.push("Skinned"), n.hasMorphs && a.push("Morph"), t && t.length > 0 && a.push("Animated");+ const o = 200, c = Wc("Model Info", cg), l = hB(c, o, ao + 2), h = r.map((w) => {+ const S = [+ { text: w.label + " ", font: hu },+ { text: w.value, font: uu }+ ], T = nb(S), C = Wc(w.label, hu), v = cu(C, o), F = Wc(w.value, uu), K = cu(F, o);+ return {+ ...w,+ labelWidth: v.maxLineWidth,+ valueWidth: K.maxLineWidth,+ richPrepared: T+ };+ }), u = a.map((w) => {+ const S = Wc(w, lg), T = cu(S, 300);+ return { text: w, width: T.maxLineWidth + ug };+ });+ let d = [], f = 0;+ if (s) {+ const w = kl(s, hg), S = mB(w, o - sn, ao);+ d = S.lines, f = S.height;+ }+ const m = Math.max(+ l.width + sn * 2,+ ...h.map((w) => w.labelWidth + w.valueWidth + sn * 3)+ ), A = Math.max(m, 180);+ let g = 0;+ if (u.length > 0) {+ let w = 0, S = 1;+ u.forEach((T) => {+ w > 0 && w + T.width > A - sn * 2 && (S++, w = 0), w += T.width + 6;+ }), g = S * (Kc + 6) + Mi;+ }+ const p = sn + l.height + Mi + // title+ Mi + // separator+ h.length * (ao + Mi) + // stat rows+ g + // chips+ (f > 0 ? Mi + f : 0) + // description+ sn, y = document.createElement("canvas");+ y.width = A * jc, y.height = p * jc, y.style.width = A + "px", y.style.height = p + "px";+ const b = y.getContext("2d");+ b.scale(jc, jc), b.fillStyle = vB, du(b, 0, 0, A, p, 10), b.fill(), b.strokeStyle = CB, b.lineWidth = 1, du(b, 0.5, 0.5, A - 1, p - 1, 10), b.stroke();+ let E = sn;+ if (b.font = cg, b.fillStyle = SB, b.textBaseline = "top", b.fillText("Model Info", sn, E), E += l.height + Mi, b.strokeStyle = dg, b.beginPath(), b.moveTo(sn, E), b.lineTo(A - sn, E), b.stroke(), E += Mi, h.forEach((w) => {+ b.font = hu, b.fillStyle = IB, b.textAlign = "left", b.fillText(w.label, sn, E), b.font = uu, b.fillStyle = MB, b.textAlign = "right", b.fillText(w.value, A - sn, E), b.textAlign = "left", E += ao + Mi;+ }), u.length > 0) {+ let w = sn;+ u.forEach((S) => {+ w > sn && w + S.width > A - sn && (w = sn, E += Kc + 6), b.fillStyle = TB, du(b, w, E, S.width, Kc, 4), b.fill(), b.font = lg, b.fillStyle = RB, b.textBaseline = "top", b.fillText(S.text, w + ug / 2, E + 3), w += S.width + 6;+ }), E += Kc + Mi + 4;+ }+ d.length > 0 && (b.strokeStyle = dg, b.beginPath(), b.moveTo(sn, E), b.lineTo(A - sn, E), b.stroke(), E += Mi, b.font = hg, b.fillStyle = BB, b.textBaseline = "top", d.forEach((w) => {+ b.fillText(w.text, sn, E), E += ao;+ }));+ const M = document.createElement("div");+ return M.classList.add("model-info"), M.appendChild(y), i.appendChild(M), {+ el: M,+ canvas: y,+ remove() {+ M.remove();+ }+ };+}+function du(i, e, t, n, s, r) {+ i.beginPath(), i.moveTo(e + r, t), i.lineTo(e + n - r, t), i.quadraticCurveTo(e + n, t, e + n, t + r), i.lineTo(e + n, t + s - r), i.quadraticCurveTo(e + n, t + s, e + n - r, t + s), i.lineTo(e + r, t + s), i.quadraticCurveTo(e, t + s, e, t + s - r), i.lineTo(e, t + r), i.quadraticCurveTo(e, t, e + r, t), i.closePath();+}+function LB() {+ return /iphone|ipad|ipod/i.test(navigator.userAgent) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1;+}+function fg() {+ return LB();+}+function PB(i) {+ const e = document.createElement("a");+ e.rel = "ar", e.href = i, e.appendChild(document.createElement("img")), e.click();+}+function kB() {+ return /android/i.test(navigator.userAgent);+}+function pg() {+ return kB();+}+function UB(i, { title: e = "", link: t = "" } = {}) {+ const n = new URLSearchParams({ file: i, mode: "ar_preferred" });+ e && n.set("title", e), t && n.set("link", t);+ const s = encodeURIComponent(location.href), r = `intent://arvr.google.com/scene-viewer/1.2?${n.toString()}#Intent;scheme=https;package=com.google.ar.core;action=android.intent.action.VIEW;S.browser_fallback_url=${s};end;`;+ location.href = r;+}+class Ag {+ constructor(e, { onEnd: t } = {}) {+ this._viewer = e, this._onEnd = t, this._session = null, this._hitTestSource = null, this._localSpace = null, this._anchored = !1, this._userPosition = new H(), this._savedBg = null, this._savedPos = null, this._savedRot = null, this._handleEnd = this._handleEnd.bind(this), this._handleSelect = this._handleSelect.bind(this);+ }+ static async isSupported() {+ try {+ return !!(navigator.xr && await navigator.xr.isSessionSupported("immersive-ar"));+ } catch {+ return !1;+ }+ }+ async start() {+ const e = this._viewer, t = e.renderer;+ t.xr.enabled = !0;+ const n = await navigator.xr.requestSession("immersive-ar", {+ requiredFeatures: ["hit-test"]+ });+ this._session = n, n.addEventListener("end", this._handleEnd), n.addEventListener("select", this._handleSelect), await t.xr.setSession(n), this._localSpace = await n.requestReferenceSpace("local");+ const s = await n.requestReferenceSpace("viewer");+ this._hitTestSource = await n.requestHitTestSource({ space: s }), this._savedBg = e.scene.background, e.scene.background = null, t.setClearColor(0, 0);+ const r = e.content;+ this._savedPos = r?.position.clone() ?? null, this._savedRot = r?.rotation.clone() ?? null, e._rafId !== null && (cancelAnimationFrame(e._rafId), e._rafId = null), e.controls.enabled = !1, t.setAnimationLoop((a, o) => this._tick(a, o));+ }+ _tick(e, t) {+ const n = this._viewer, s = n.renderer, r = n.prevTime ? (e - n.prevTime) / 1e3 : 0.016;+ if (n.prevTime = e, n.mixer && n.mixer.update(r), n.animationManager.update(r), n._afterAnimateHooks)+ for (const o of n._afterAnimateHooks) o(r);+ const a = s.xr.getCamera();+ if (a && this._userPosition.setFromMatrixPosition(a.matrixWorld), !this._anchored && t && this._hitTestSource) {+ const o = t.getHitTestResults(this._hitTestSource);+ if (o.length > 0 && n.content) {+ const c = o[0].getPose(this._localSpace);+ c && n.content.position.setFromMatrixPosition(+ new et().fromArray(c.transform.matrix)+ );+ }+ }+ s.render(n.scene, n.activeCamera);+ }+ // First tap anchors the agent at the current hit-test position+ _handleSelect() {+ this._anchored = !0;+ }+ // Returns the current XR camera (user head) position for lookAt('user')+ getUserPosition() {+ return this._userPosition.clone();+ }+ async end() {+ if (this._session)+ try {+ await this._session.end();+ } catch {+ }+ }+ _handleEnd() {+ const e = this._viewer, t = e.renderer;+ if (t.setAnimationLoop(null), t.xr.enabled = !1, this._hitTestSource) {+ try {+ this._hitTestSource.cancel();+ } catch {+ }+ this._hitTestSource = null;+ }+ this._session = null, this._anchored = !1, e.scene.background = this._savedBg, t.setClearColor(0, 1), e.content && this._savedPos && e.content.position.copy(this._savedPos), e.content && this._savedRot && e.content.rotation.copy(this._savedRot), e.controls.enabled = !0, e._needsRender = !0, e._updateRenderLoop(), this._onEnd?.();+ }+}+const OB = "500 11px Inter, sans-serif", gg = "300 10px Inter, sans-serif", Pd = 10, rb = 6, ab = 14, Xc = Math.min(window.devicePixelRatio || 1, 2), QB = 8;+function GB(i) {+ const e = [];+ return i.traverse((t) => {+ if (e.length >= QB || !t.isMesh || !t.name || t.name.startsWith("_")) return;+ const n = t.geometry, s = Array.isArray(t.material) ? t.material[0] : t.material, r = n && n.attributes.position ? n.attributes.position.count : 0, a = s ? s.type.replace("Material", "") : "", o = [{ text: t.name, font: OB }];+ r > 0 && o.push({ text: " " + zB(r) + " verts", font: gg }), a && o.push({ text: " " + a, font: gg });+ const c = nb(o);+ let l = 0, h = 0;+ sb(c, 300, (A) => {+ const g = ib(c, A);+ l = Math.max(l, g.width), h++;+ });+ const u = l + Pd * 2, d = h * ab + rb * 2;+ n && n.computeBoundingBox();+ const f = n ? n.boundingBox : null, m = new H();+ f ? (f.getCenter(m), m.applyMatrix4(t.matrixWorld)) : t.getWorldPosition(m), e.push({+ name: t.name,+ items: o,+ prepared: c,+ labelWidth: u,+ labelHeight: d,+ position: m,+ vertCount: r,+ matType: a+ });+ }), e;+}+function HB(i) {+ const { labelWidth: e, labelHeight: t, items: n, prepared: s } = i, r = document.createElement("canvas");+ r.width = e * Xc, r.height = t * Xc, r.style.width = e + "px", r.style.height = t + "px";+ const a = r.getContext("2d");+ a.scale(Xc, Xc), a.fillStyle = "rgba(0, 0, 0, 0.8)", mg(a, 0, 0, e, t, 6), a.fill(), a.strokeStyle = "rgba(255, 255, 255, 0.1)", a.lineWidth = 1, mg(a, 0.5, 0.5, e - 1, t - 1, 6), a.stroke(), a.textBaseline = "top";+ let o = rb;+ return sb(s, e - Pd * 2, (c) => {+ const l = ib(s, c);+ let h = Pd;+ l.fragments.forEach((u) => {+ h += u.gapBefore;+ const d = n[u.itemIndex];+ a.font = d.font, a.fillStyle = u.itemIndex === 0 ? "rgba(255, 255, 255, 0.9)" : "rgba(255, 255, 255, 0.45)", a.fillText(u.text, h, o), h += u.occupiedWidth;+ }), o += ab;+ }), r;+}+function zB(i) {+ return i >= 1e6 ? (i / 1e6).toFixed(1) + "M" : i >= 1e3 ? (i / 1e3).toFixed(1) + "K" : i.toString();+}+function mg(i, e, t, n, s, r) {+ i.beginPath(), i.moveTo(e + r, t), i.lineTo(e + n - r, t), i.quadraticCurveTo(e + n, t, e + n, t + r), i.lineTo(e + n, t + s - r), i.quadraticCurveTo(e + n, t + s, e + n - r, t + s), i.lineTo(e + r, t + s), i.quadraticCurveTo(e, t + s, e, t + s - r), i.lineTo(e, t + r), i.quadraticCurveTo(e, t, e + r, t), i.closePath();+}+const Yc = "[default]", kd = { ASSET_GENERATOR: "assetgenerator" }, Ul = new E0(), bg = "https://unpkg.com/[email protected]";+let Jc = null;+function VB() {+ return Jc || (Jc = Promise.all([+ Promise.resolve().then(() => a2),+ Promise.resolve().then(() => E2),+ Promise.resolve().then(() => w2)+ ]).then(([i, e, t]) => {+ const n = new i.DRACOLoader(Ul).setDecoderPath(+ `${bg}/examples/jsm/libs/draco/gltf/`+ ), s = new e.KTX2Loader(Ul).setTranscoderPath(+ `${bg}/examples/jsm/libs/basis/`+ );+ return { dracoLoader: n, ktx2Loader: s, meshoptDecoder: t.MeshoptDecoder };+ }), Jc);+}+function xg(i, e) {+ const t = /* @__PURE__ */ new Set();+ i.traverse((n) => {+ if (!n.geometry) return;+ (Array.isArray(n.material) ? n.material : [n.material]).forEach((r) => {+ r && !t.has(r.uuid) && (t.add(r.uuid), e(r));+ });+ });+}+function WB(i) {+ const { state: e, options: t } = i;+ if (t.preset === kd.ASSET_GENERATOR) {+ const r = new By();+ r.name = "hemi_light", i.scene.add(r), i.lights.push(r);+ return;+ }+ const n = new Dy(e.ambientColor, e.ambientIntensity);+ n.name = "ambient_light", i.defaultCamera.add(n);+ const s = new w0(e.directColor, e.directIntensity);+ s.position.set(0.5, 0, 0.866), s.name = "main_light", i.defaultCamera.add(s), i.lights.push(n, s);+}+function qB(i) {+ i.lights.forEach((e) => e.parent.remove(e)), i.lights.length = 0;+}+var ti = Uint8Array, la = Uint16Array, KB = Int32Array, ob = new ti([+ 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,+ /* unused */+ 0,+ 0,+ /* impossible */+ 0+]), cb = new ti([+ 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,+ /* unused */+ 0,+ 0+]), jB = new ti([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]), lb = function(i, e) {+ for (var t = new la(31), n = 0; n < 31; ++n)+ t[n] = e += 1 << i[n - 1];+ for (var s = new KB(t[30]), n = 1; n < 30; ++n)+ for (var r = t[n]; r < t[n + 1]; ++r)+ s[r] = r - t[n] << 5 | n;+ return { b: t, r: s };+}, hb = lb(ob, 2), ub = hb.b, XB = hb.r;+ub[28] = 258, XB[258] = 28;+var YB = lb(cb, 0), JB = YB.b, Ud = new la(32768);+for (var Pt = 0; Pt < 32768; ++Pt) {+ var Cs = (Pt & 43690) >> 1 | (Pt & 21845) << 1;+ Cs = (Cs & 52428) >> 2 | (Cs & 13107) << 2, Cs = (Cs & 61680) >> 4 | (Cs & 3855) << 4, Ud[Pt] = ((Cs & 65280) >> 8 | (Cs & 255) << 8) >> 1;+}+var Io = (function(i, e, t) {+ for (var n = i.length, s = 0, r = new la(e); s < n; ++s)+ i[s] && ++r[i[s] - 1];+ var a = new la(e);+ for (s = 1; s < e; ++s)+ a[s] = a[s - 1] + r[s - 1] << 1;+ var o;+ if (t) {+ o = new la(1 << e);+ var c = 15 - e;+ for (s = 0; s < n; ++s)+ if (i[s])+ for (var l = s << 4 | i[s], h = e - i[s], u = a[i[s] - 1]++ << h, d = u | (1 << h) - 1; u <= d; ++u)+ o[Ud[u] >> c] = l;+ } else+ for (o = new la(n), s = 0; s < n; ++s)+ i[s] && (o[s] = Ud[a[i[s] - 1]++] >> 15 - i[s]);+ return o;+}), tc = new ti(288);+for (var Pt = 0; Pt < 144; ++Pt)+ tc[Pt] = 8;+for (var Pt = 144; Pt < 256; ++Pt)+ tc[Pt] = 9;+for (var Pt = 256; Pt < 280; ++Pt)+ tc[Pt] = 7;+for (var Pt = 280; Pt < 288; ++Pt)+ tc[Pt] = 8;+var db = new ti(32);+for (var Pt = 0; Pt < 32; ++Pt)+ db[Pt] = 5;+var ZB = /* @__PURE__ */ Io(tc, 9, 1), $B = /* @__PURE__ */ Io(db, 5, 1), fu = function(i) {+ for (var e = i[0], t = 1; t < i.length; ++t)+ i[t] > e && (e = i[t]);+ return e;+}, ui = function(i, e, t) {+ var n = e / 8 | 0;+ return (i[n] | i[n + 1] << 8) >> (e & 7) & t;+}, pu = function(i, e) {+ var t = e / 8 | 0;+ return (i[t] | i[t + 1] << 8 | i[t + 2] << 16) >> (e & 7);+}, eT = function(i) {+ return (i + 7) / 8 | 0;+}, tT = function(i, e, t) {+ return (t == null || t > i.length) && (t = i.length), new ti(i.subarray(e, t));+}, nT = [+ "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"+ // determined by unknown compression method+], di = function(i, e, t) {+ var n = new Error(e || nT[i]);+ if (n.code = i, Error.captureStackTrace && Error.captureStackTrace(n, di), !t)+ throw n;+ return n;+}, iT = function(i, e, t, n) {+ var s = i.length, r = 0;+ if (!s || e.f && !e.l)+ return t || new ti(0);+ var a = !t, o = a || e.i != 2, c = e.i;+ a && (t = new ti(s * 3));+ var l = function(vt) {+ var lt = t.length;+ if (vt > lt) {+ var Je = new ti(Math.max(lt * 2, vt));+ Je.set(t), t = Je;+ }+ }, h = e.f || 0, u = e.p || 0, d = e.b || 0, f = e.l, m = e.d, A = e.m, g = e.n, p = s * 8;+ do {+ if (!f) {+ h = ui(i, u, 1);+ var y = ui(i, u + 1, 3);+ if (u += 3, y)+ if (y == 1)+ f = ZB, m = $B, A = 9, g = 5;+ else if (y == 2) {+ var w = ui(i, u, 31) + 257, S = ui(i, u + 10, 15) + 4, T = w + ui(i, u + 5, 31) + 1;+ u += 14;+ for (var C = new ti(T), v = new ti(19), F = 0; F < S; ++F)+ v[jB[F]] = ui(i, u + F * 3, 7);+ u += S * 3;+ for (var K = fu(v), q = (1 << K) - 1, $ = Io(v, K, 1), F = 0; F < T; ) {+ var D = $[ui(i, u, q)];+ u += D & 15;+ var b = D >> 4;+ if (b < 16)+ C[F++] = b;+ else {+ var O = 0, Y = 0;+ for (b == 16 ? (Y = 3 + ui(i, u, 3), u += 2, O = C[F - 1]) : b == 17 ? (Y = 3 + ui(i, u, 7), u += 3) : b == 18 && (Y = 11 + ui(i, u, 127), u += 7); Y--; )+ C[F++] = O;+ }+ }+ var Q = C.subarray(0, w), J = C.subarray(w);+ A = fu(Q), g = fu(J), f = Io(Q, A, 1), m = Io(J, g, 1);+ } else+ di(1);+ else {+ var b = eT(u) + 4, E = i[b - 4] | i[b - 3] << 8, M = b + E;+ if (M > s) {+ c && di(0);+ break;+ }+ o && l(d + E), t.set(i.subarray(b, M), d), e.b = d += E, e.p = u = M * 8, e.f = h;+ continue;+ }+ if (u > p) {+ c && di(0);+ break;+ }+ }+ o && l(d + 131072);+ for (var ee = (1 << A) - 1, ae = (1 << g) - 1, ye = u; ; ye = u) {+ var O = f[pu(i, u) & ee], Me = O >> 4;+ if (u += O & 15, u > p) {+ c && di(0);+ break;+ }+ if (O || di(2), Me < 256)+ t[d++] = Me;+ else if (Me == 256) {+ ye = u, f = null;+ break;+ } else {+ var se = Me - 254;+ if (Me > 264) {+ var F = Me - 257, me = ob[F];+ se = ui(i, u, (1 << me) - 1) + ub[F], u += me;+ }+ var be = m[pu(i, u) & ae], xe = be >> 4;+ be || di(3), u += be & 15;+ var J = JB[xe];+ if (xe > 3) {+ var me = cb[xe];+ J += pu(i, u) & (1 << me) - 1, u += me;+ }+ if (u > p) {+ c && di(0);+ break;+ }+ o && l(d + 131072);+ var Pe = d + se;+ if (d < J) {+ var $e = r - J, Qe = Math.min(J, Pe);+ for ($e + d < 0 && di(3); d < Qe; ++d)+ t[d] = n[$e + d];+ }+ for (; d < Pe; ++d)+ t[d] = t[d - J];+ }+ }+ e.l = f, e.p = ye, e.b = d, e.f = h, f && (h = 1, e.m = A, e.d = m, e.n = g);+ } while (!h);+ return d != t.length && a ? tT(t, 0, d) : t.subarray(0, d);+}, sT = /* @__PURE__ */ new ti(0), rT = function(i, e) {+ return ((i[0] & 15) != 8 || i[0] >> 4 > 7 || (i[0] << 8 | i[1]) % 31) && di(6, "invalid zlib data"), (i[1] >> 5 & 1) == 1 && di(6, "invalid zlib data: " + (i[1] & 32 ? "need" : "unexpected") + " dictionary"), (i[1] >> 3 & 4) + 2;+};+function Zc(i, e) {+ return iT(i.subarray(rT(i), -4), { i: 2 }, e, e);+}+var aT = typeof TextDecoder < "u" && /* @__PURE__ */ new TextDecoder(), oT = 0;+try {+ aT.decode(sT, { stream: !0 }), oT = 1;+} catch {+}+class cT extends Iy {+ /**+ * Constructs a new EXR loader.+ *+ * @param {LoadingManager} [manager] - The loading manager.+ */+ constructor(e) {+ super(e), this.type = Nn;+ }+ /**+ * Parses the given EXR texture data.+ *+ * @param {ArrayBuffer} buffer - The raw texture data.+ * @return {DataTextureLoader~TexData} An object representing the parsed texture data.+ */+ parse(e) {+ const C = Math.pow(2.7182818, 2.2);+ function v(x, B) {+ let k = 0;+ for (let R = 0; R < 65536; ++R)+ (R == 0 || x[R >> 3] & 1 << (R & 7)) && (B[k++] = R);+ const _ = k - 1;+ for (; k < 65536; ) B[k++] = 0;+ return _;+ }+ function F(x) {+ for (let B = 0; B < 16384; B++)+ x[B] = {}, x[B].len = 0, x[B].lit = 0, x[B].p = null;+ }+ const K = { l: 0, c: 0, lc: 0 };+ function q(x, B, k, _, R) {+ for (; k < x; )+ B = B << 8 | Be(_, R), k += 8;+ k -= x, K.l = B >> k & (1 << x) - 1, K.c = B, K.lc = k;+ }+ const $ = new Array(59);+ function D(x) {+ for (let k = 0; k <= 58; ++k) $[k] = 0;+ for (let k = 0; k < 65537; ++k) $[x[k]] += 1;+ let B = 0;+ for (let k = 58; k > 0; --k) {+ const _ = B + $[k] >> 1;+ $[k] = B, B = _;+ }+ for (let k = 0; k < 65537; ++k) {+ const _ = x[k];+ _ > 0 && (x[k] = _ | $[_]++ << 6);+ }+ }+ function O(x, B, k, _, R, N) {+ const U = B;+ let P = 0, z = 0;+ for (; _ <= R; _++) {+ if (U.value - B.value > k) return !1;+ q(6, P, z, x, U);+ const j = K.l;+ if (P = K.c, z = K.lc, N[_] = j, j == 63) {+ if (U.value - B.value > k)+ throw new Error("Something wrong with hufUnpackEncTable");+ q(8, P, z, x, U);+ let X = K.l + 6;+ if (P = K.c, z = K.lc, _ + X > R + 1)+ throw new Error("Something wrong with hufUnpackEncTable");+ for (; X--; ) N[_++] = 0;+ _--;+ } else if (j >= 59) {+ let X = j - 59 + 2;+ if (_ + X > R + 1)+ throw new Error("Something wrong with hufUnpackEncTable");+ for (; X--; ) N[_++] = 0;+ _--;+ }+ }+ D(N);+ }+ function Y(x) {+ return x & 63;+ }+ function Q(x) {+ return x >> 6;+ }+ function J(x, B, k, _) {+ for (; B <= k; B++) {+ const R = Q(x[B]), N = Y(x[B]);+ if (R >> N)+ throw new Error("Invalid table entry");+ if (N > 14) {+ const U = _[R >> N - 14];+ if (U.len)+ throw new Error("Invalid table entry");+ if (U.lit++, U.p) {+ const P = U.p;+ U.p = new Array(U.lit);+ for (let z = 0; z < U.lit - 1; ++z)+ U.p[z] = P[z];+ } else+ U.p = new Array(1);+ U.p[U.lit - 1] = B;+ } else if (N) {+ let U = 0;+ for (let P = 1 << 14 - N; P > 0; P--) {+ const z = _[(R << 14 - N) + U];+ if (z.len || z.p)+ throw new Error("Invalid table entry");+ z.len = N, z.lit = B, U++;+ }+ }+ }+ return !0;+ }+ const ee = { c: 0, lc: 0 };+ function ae(x, B, k, _) {+ x = x << 8 | Be(k, _), B += 8, ee.c = x, ee.lc = B;+ }+ const ye = { c: 0, lc: 0 };+ function Me(x, B, k, _, R, N, U, P, z) {+ if (x == B) {+ _ < 8 && (ae(k, _, R, N), k = ee.c, _ = ee.lc), _ -= 8;+ let j = k >> _;+ if (j = new Uint8Array([j])[0], P.value + j > z)+ return !1;+ const X = U[P.value - 1];+ for (; j-- > 0; )+ U[P.value++] = X;+ } else if (P.value < z)+ U[P.value++] = x;+ else+ return !1;+ ye.c = k, ye.lc = _;+ }+ function se(x) {+ return x & 65535;+ }+ function me(x) {+ const B = se(x);+ return B > 32767 ? B - 65536 : B;+ }+ const be = { a: 0, b: 0 };+ function xe(x, B) {+ const k = me(x), R = me(B), N = k + (R & 1) + (R >> 1), U = N, P = N - R;+ be.a = U, be.b = P;+ }+ function Pe(x, B) {+ const k = se(x), _ = se(B), R = k - (_ >> 1) & 65535, N = _ + R - 32768 & 65535;+ be.a = N, be.b = R;+ }+ function $e(x, B, k, _, R, N, U) {+ const P = U < 16384, z = k > R ? R : k;+ let j = 1, X, ie;+ for (; j <= z; ) j <<= 1;+ for (j >>= 1, X = j, j >>= 1; j >= 1; ) {+ ie = 0;+ const he = ie + N * (R - X), ce = N * j, fe = N * X, Ae = _ * j, Ee = _ * X;+ let De, qe, He, Ne;+ for (; ie <= he; ie += fe) {+ let st = ie;+ const Le = ie + _ * (k - X);+ for (; st <= Le; st += Ee) {+ const yt = st + Ae, en = st + ce, xt = en + Ae;+ P ? (xe(x[st + B], x[en + B]), De = be.a, He = be.b, xe(x[yt + B], x[xt + B]), qe = be.a, Ne = be.b, xe(De, qe), x[st + B] = be.a, x[yt + B] = be.b, xe(He, Ne), x[en + B] = be.a, x[xt + B] = be.b) : (Pe(x[st + B], x[en + B]), De = be.a, He = be.b, Pe(x[yt + B], x[xt + B]), qe = be.a, Ne = be.b, Pe(De, qe), x[st + B] = be.a, x[yt + B] = be.b, Pe(He, Ne), x[en + B] = be.a, x[xt + B] = be.b);+ }+ if (k & j) {+ const yt = st + ce;+ P ? xe(x[st + B], x[yt + B]) : Pe(x[st + B], x[yt + B]), De = be.a, x[yt + B] = be.b, x[st + B] = De;+ }+ }+ if (R & j) {+ let st = ie;+ const Le = ie + _ * (k - X);+ for (; st <= Le; st += Ee) {+ const yt = st + Ae;+ P ? xe(x[st + B], x[yt + B]) : Pe(x[st + B], x[yt + B]), De = be.a, x[yt + B] = be.b, x[st + B] = De;+ }+ }+ X = j, j >>= 1;+ }+ return ie;+ }+ function Qe(x, B, k, _, R, N, U, P, z) {+ let j = 0, X = 0;+ const ie = U, he = Math.trunc(_.value + (R + 7) / 8);+ for (; _.value < he; )+ for (ae(j, X, k, _), j = ee.c, X = ee.lc; X >= 14; ) {+ const fe = j >> X - 14 & 16383, Ae = B[fe];+ if (Ae.len)+ X -= Ae.len, Me(Ae.lit, N, j, X, k, _, P, z, ie), j = ye.c, X = ye.lc;+ else {+ if (!Ae.p)+ throw new Error("hufDecode issues");+ let Ee;+ for (Ee = 0; Ee < Ae.lit; Ee++) {+ const De = Y(x[Ae.p[Ee]]);+ for (; X < De && _.value < he; )+ ae(j, X, k, _), j = ee.c, X = ee.lc;+ if (X >= De && Q(x[Ae.p[Ee]]) == (j >> X - De & (1 << De) - 1)) {+ X -= De, Me(Ae.p[Ee], N, j, X, k, _, P, z, ie), j = ye.c, X = ye.lc;+ break;+ }+ }+ if (Ee == Ae.lit)+ throw new Error("hufDecode issues");+ }+ }+ const ce = 8 - R & 7;+ for (j >>= ce, X -= ce; X > 0; ) {+ const fe = B[j << 14 - X & 16383];+ if (fe.len)+ X -= fe.len, Me(fe.lit, N, j, X, k, _, P, z, ie), j = ye.c, X = ye.lc;+ else+ throw new Error("hufDecode issues");+ }+ return !0;+ }+ function vt(x, B, k, _, R, N) {+ const U = { value: 0 }, P = k.value, z = Oe(B, k), j = Oe(B, k);+ k.value += 4;+ const X = Oe(B, k);+ if (k.value += 4, z < 0 || z >= 65537 || j < 0 || j >= 65537)+ throw new Error("Something wrong with HUF_ENCSIZE");+ const ie = new Array(65537), he = new Array(16384);+ F(he);+ const ce = _ - (k.value - P);+ if (O(x, k, ce, z, j, ie), X > 8 * (_ - (k.value - P)))+ throw new Error("Something wrong with hufUncompress");+ J(ie, z, j, he), Qe(ie, he, x, k, X, j, N, R, U);+ }+ function lt(x, B, k) {+ for (let _ = 0; _ < k; ++_)+ B[_] = x[B[_]];+ }+ function Je(x) {+ for (let B = 1; B < x.length; B++) {+ const k = x[B - 1] + x[B] - 128;+ x[B] = k;+ }+ }+ function G(x, B) {+ let k = 0, _ = Math.floor((x.length + 1) / 2), R = 0;+ const N = x.length - 1;+ for (; !(R > N || (B[R++] = x[k++], R > N)); )+ B[R++] = x[_++];+ }+ function dn(x) {+ let B = x.byteLength;+ const k = new Array();+ let _ = 0;+ const R = new DataView(x);+ for (; B > 0; ) {+ const N = R.getInt8(_++);+ if (N < 0) {+ const U = -N;+ B -= U + 1;+ for (let P = 0; P < U; P++)+ k.push(R.getUint8(_++));+ } else {+ const U = N;+ B -= 2;+ const P = R.getUint8(_++);+ for (let z = 0; z < U + 1; z++)+ k.push(P);+ }+ }+ return k;+ }+ function dt(x, B, k, _, R, N) {+ let U = new DataView(N.buffer);+ const P = k[x.idx[0]].width, z = k[x.idx[0]].height, j = 3, X = Math.floor(P / 8), ie = Math.ceil(P / 8), he = Math.ceil(z / 8), ce = P - (ie - 1) * 8, fe = z - (he - 1) * 8, Ae = { value: 0 }, Ee = new Array(j), De = new Array(j), qe = new Array(j), He = new Array(j), Ne = new Array(j);+ for (let Le = 0; Le < j; ++Le)+ Ne[Le] = B[x.idx[Le]], Ee[Le] = Le < 1 ? 0 : Ee[Le - 1] + ie * he, De[Le] = new Float32Array(64), qe[Le] = new Uint16Array(64), He[Le] = new Uint16Array(ie * 64);+ for (let Le = 0; Le < he; ++Le) {+ let yt = 8;+ Le == he - 1 && (yt = fe);+ let en = 8;+ for (let At = 0; At < ie; ++At) {+ At == ie - 1 && (en = ce);+ for (let Ke = 0; Ke < j; ++Ke)+ qe[Ke].fill(0), qe[Ke][0] = R[Ee[Ke]++], pt(Ae, _, qe[Ke]), ze(qe[Ke], De[Ke]), Rt(De[Ke]);+ Ge(De);+ for (let Ke = 0; Ke < j; ++Ke)+ L(De[Ke], He[Ke], At * 64);+ }+ let xt = 0;+ for (let At = 0; At < j; ++At) {+ const Ke = k[x.idx[At]].type;+ for (let zt = 8 * Le; zt < 8 * Le + yt; ++zt) {+ xt = Ne[At][zt];+ for (let pn = 0; pn < X; ++pn) {+ const Nt = pn * 64 + (zt & 7) * 8;+ U.setUint16(xt + 0 * Ke, He[At][Nt + 0], !0), U.setUint16(xt + 2 * Ke, He[At][Nt + 1], !0), U.setUint16(xt + 4 * Ke, He[At][Nt + 2], !0), U.setUint16(xt + 6 * Ke, He[At][Nt + 3], !0), U.setUint16(xt + 8 * Ke, He[At][Nt + 4], !0), U.setUint16(xt + 10 * Ke, He[At][Nt + 5], !0), U.setUint16(xt + 12 * Ke, He[At][Nt + 6], !0), U.setUint16(xt + 14 * Ke, He[At][Nt + 7], !0), xt += 16 * Ke;+ }+ }+ if (X != ie)+ for (let zt = 8 * Le; zt < 8 * Le + yt; ++zt) {+ const pn = Ne[At][zt] + 8 * X * 2 * Ke, Nt = X * 64 + (zt & 7) * 8;+ for (let tn = 0; tn < en; ++tn)+ U.setUint16(pn + tn * 2 * Ke, He[At][Nt + tn], !0);+ }+ }+ }+ const st = new Uint16Array(P);+ U = new DataView(N.buffer);+ for (let Le = 0; Le < j; ++Le) {+ k[x.idx[Le]].decoded = !0;+ const yt = k[x.idx[Le]].type;+ if (k[Le].type == 2)+ for (let en = 0; en < z; ++en) {+ const xt = Ne[Le][en];+ for (let At = 0; At < P; ++At)+ st[At] = U.getUint16(xt + At * 2 * yt, !0);+ for (let At = 0; At < P; ++At)+ U.setFloat32(xt + At * 2 * yt, ne(st[At]), !0);+ }+ }+ }+ function pt(x, B, k) {+ let _, R = 1;+ for (; R < 64; )+ _ = B[x.value], _ == 65280 ? R = 64 : _ >> 8 == 255 ? R += _ & 255 : (k[R] = _, R++), x.value++;+ }+ function ze(x, B) {+ B[0] = ne(x[0]), B[1] = ne(x[1]), B[2] = ne(x[5]), B[3] = ne(x[6]), B[4] = ne(x[14]), B[5] = ne(x[15]), B[6] = ne(x[27]), B[7] = ne(x[28]), B[8] = ne(x[2]), B[9] = ne(x[4]), B[10] = ne(x[7]), B[11] = ne(x[13]), B[12] = ne(x[16]), B[13] = ne(x[26]), B[14] = ne(x[29]), B[15] = ne(x[42]), B[16] = ne(x[3]), B[17] = ne(x[8]), B[18] = ne(x[12]), B[19] = ne(x[17]), B[20] = ne(x[25]), B[21] = ne(x[30]), B[22] = ne(x[41]), B[23] = ne(x[43]), B[24] = ne(x[9]), B[25] = ne(x[11]), B[26] = ne(x[18]), B[27] = ne(x[24]), B[28] = ne(x[31]), B[29] = ne(x[40]), B[30] = ne(x[44]), B[31] = ne(x[53]), B[32] = ne(x[10]), B[33] = ne(x[19]), B[34] = ne(x[23]), B[35] = ne(x[32]), B[36] = ne(x[39]), B[37] = ne(x[45]), B[38] = ne(x[52]), B[39] = ne(x[54]), B[40] = ne(x[20]), B[41] = ne(x[22]), B[42] = ne(x[33]), B[43] = ne(x[38]), B[44] = ne(x[46]), B[45] = ne(x[51]), B[46] = ne(x[55]), B[47] = ne(x[60]), B[48] = ne(x[21]), B[49] = ne(x[34]), B[50] = ne(x[37]), B[51] = ne(x[47]), B[52] = ne(x[50]), B[53] = ne(x[56]), B[54] = ne(x[59]), B[55] = ne(x[61]), B[56] = ne(x[35]), B[57] = ne(x[36]), B[58] = ne(x[48]), B[59] = ne(x[49]), B[60] = ne(x[57]), B[61] = ne(x[58]), B[62] = ne(x[62]), B[63] = ne(x[63]);+ }+ function Rt(x) {+ const B = 0.5 * Math.cos(0.7853975), k = 0.5 * Math.cos(3.14159 / 16), _ = 0.5 * Math.cos(3.14159 / 8), R = 0.5 * Math.cos(3 * 3.14159 / 16), N = 0.5 * Math.cos(5 * 3.14159 / 16), U = 0.5 * Math.cos(3 * 3.14159 / 8), P = 0.5 * Math.cos(7 * 3.14159 / 16), z = new Array(4), j = new Array(4), X = new Array(4), ie = new Array(4);+ for (let he = 0; he < 8; ++he) {+ const ce = he * 8;+ z[0] = _ * x[ce + 2], z[1] = U * x[ce + 2], z[2] = _ * x[ce + 6], z[3] = U * x[ce + 6], j[0] = k * x[ce + 1] + R * x[ce + 3] + N * x[ce + 5] + P * x[ce + 7], j[1] = R * x[ce + 1] - P * x[ce + 3] - k * x[ce + 5] - N * x[ce + 7], j[2] = N * x[ce + 1] - k * x[ce + 3] + P * x[ce + 5] + R * x[ce + 7], j[3] = P * x[ce + 1] - N * x[ce + 3] + R * x[ce + 5] - k * x[ce + 7], X[0] = B * (x[ce + 0] + x[ce + 4]), X[3] = B * (x[ce + 0] - x[ce + 4]), X[1] = z[0] + z[3], X[2] = z[1] - z[2], ie[0] = X[0] + X[1], ie[1] = X[3] + X[2], ie[2] = X[3] - X[2], ie[3] = X[0] - X[1], x[ce + 0] = ie[0] + j[0], x[ce + 1] = ie[1] + j[1], x[ce + 2] = ie[2] + j[2], x[ce + 3] = ie[3] + j[3], x[ce + 4] = ie[3] - j[3], x[ce + 5] = ie[2] - j[2], x[ce + 6] = ie[1] - j[1], x[ce + 7] = ie[0] - j[0];+ }+ for (let he = 0; he < 8; ++he)+ z[0] = _ * x[16 + he], z[1] = U * x[16 + he], z[2] = _ * x[48 + he], z[3] = U * x[48 + he], j[0] = k * x[8 + he] + R * x[24 + he] + N * x[40 + he] + P * x[56 + he], j[1] = R * x[8 + he] - P * x[24 + he] - k * x[40 + he] - N * x[56 + he], j[2] = N * x[8 + he] - k * x[24 + he] + P * x[40 + he] + R * x[56 + he], j[3] = P * x[8 + he] - N * x[24 + he] + R * x[40 + he] - k * x[56 + he], X[0] = B * (x[he] + x[32 + he]), X[3] = B * (x[he] - x[32 + he]), X[1] = z[0] + z[3], X[2] = z[1] - z[2], ie[0] = X[0] + X[1], ie[1] = X[3] + X[2], ie[2] = X[3] - X[2], ie[3] = X[0] - X[1], x[0 + he] = ie[0] + j[0], x[8 + he] = ie[1] + j[1], x[16 + he] = ie[2] + j[2], x[24 + he] = ie[3] + j[3], x[32 + he] = ie[3] - j[3], x[40 + he] = ie[2] - j[2], x[48 + he] = ie[1] - j[1], x[56 + he] = ie[0] - j[0];+ }+ function Ge(x) {+ for (let B = 0; B < 64; ++B) {+ const k = x[0][B], _ = x[1][B], R = x[2][B];+ x[0][B] = k + 1.5747 * R, x[1][B] = k - 0.1873 * _ - 0.4682 * R, x[2][B] = k + 1.8556 * _;+ }+ }+ function L(x, B, k) {+ for (let _ = 0; _ < 64; ++_)+ B[k + _] = Rp.toHalfFloat(I(x[_]));+ }+ function I(x) {+ return x <= 1 ? Math.sign(x) * Math.pow(Math.abs(x), 2.2) : Math.sign(x) * Math.pow(C, Math.abs(x) - 1);+ }+ function Z(x) {+ return new DataView(x.array.buffer, x.offset.value, x.size);+ }+ function le(x) {+ const B = x.viewer.buffer.slice(x.offset.value, x.offset.value + x.size), k = new Uint8Array(dn(B)), _ = new Uint8Array(k.length);+ return Je(k), G(k, _), new DataView(_.buffer);+ }+ function pe(x) {+ const B = x.array.slice(x.offset.value, x.offset.value + x.size), k = Zc(B), _ = new Uint8Array(k.length);+ return Je(k), G(k, _), new DataView(_.buffer);+ }+ function oe(x) {+ const B = x.viewer, k = { value: x.offset.value }, _ = new Uint16Array(x.columns * x.lines * (x.inputChannels.length * x.type)), R = new Uint8Array(8192);+ let N = 0;+ const U = new Array(x.inputChannels.length);+ for (let fe = 0, Ae = x.inputChannels.length; fe < Ae; fe++)+ U[fe] = {}, U[fe].start = N, U[fe].end = U[fe].start, U[fe].nx = x.columns, U[fe].ny = x.lines, U[fe].size = x.type, N += U[fe].nx * U[fe].ny * U[fe].size;+ const P = re(B, k), z = re(B, k);+ if (z >= 8192)+ throw new Error("Something is wrong with PIZ_COMPRESSION BITMAP_SIZE");+ if (P <= z)+ for (let fe = 0; fe < z - P + 1; fe++)+ R[fe + P] = tt(B, k);+ const j = new Uint16Array(65536), X = v(R, j), ie = Oe(B, k);+ vt(x.array, B, k, ie, _, N);+ for (let fe = 0; fe < x.inputChannels.length; ++fe) {+ const Ae = U[fe];+ for (let Ee = 0; Ee < U[fe].size; ++Ee)+ $e(+ _,+ Ae.start + Ee,+ Ae.nx,+ Ae.size,+ Ae.ny,+ Ae.nx * Ae.size,+ X+ );+ }+ lt(j, _, N);+ let he = 0;+ const ce = new Uint8Array(_.buffer.byteLength);+ for (let fe = 0; fe < x.lines; fe++)+ for (let Ae = 0; Ae < x.inputChannels.length; Ae++) {+ const Ee = U[Ae], De = Ee.nx * Ee.size, qe = new Uint8Array(_.buffer, Ee.end * 2, De * 2);+ ce.set(qe, he), he += De * 2, Ee.end += De;+ }+ return new DataView(ce.buffer);+ }+ function Ue(x) {+ const B = x.array.slice(x.offset.value, x.offset.value + x.size), k = Zc(B), _ = x.inputChannels.length * x.lines * x.columns * x.totalBytes, R = new ArrayBuffer(_), N = new DataView(R);+ let U = 0, P = 0;+ const z = new Array(4);+ for (let j = 0; j < x.lines; j++)+ for (let X = 0; X < x.inputChannels.length; X++) {+ let ie = 0;+ switch (x.inputChannels[X].pixelType) {+ case 1:+ z[0] = U, z[1] = z[0] + x.columns, U = z[1] + x.columns;+ for (let ce = 0; ce < x.columns; ++ce) {+ const fe = k[z[0]++] << 8 | k[z[1]++];+ ie += fe, N.setUint16(P, ie, !0), P += 2;+ }+ break;+ case 2:+ z[0] = U, z[1] = z[0] + x.columns, z[2] = z[1] + x.columns, U = z[2] + x.columns;+ for (let ce = 0; ce < x.columns; ++ce) {+ const fe = k[z[0]++] << 24 | k[z[1]++] << 16 | k[z[2]++] << 8;+ ie += fe, N.setUint32(P, ie, !0), P += 4;+ }+ break;+ }+ }+ return N;+ }+ function ve(x) {+ const B = x.viewer, k = { value: x.offset.value }, _ = new Uint8Array(x.columns * x.lines * (x.inputChannels.length * x.type * 2)), R = {+ version: We(B, k),+ unknownUncompressedSize: We(B, k),+ unknownCompressedSize: We(B, k),+ acCompressedSize: We(B, k),+ dcCompressedSize: We(B, k),+ rleCompressedSize: We(B, k),+ rleUncompressedSize: We(B, k),+ rleRawSize: We(B, k),+ totalAcUncompressedCount: We(B, k),+ totalDcUncompressedCount: We(B, k),+ acCompression: We(B, k)+ };+ if (R.version < 2)+ throw new Error("EXRLoader.parse: " + Gi.compression + " version " + R.version + " is unsupported");+ const N = new Array();+ let U = re(B, k) - 2;+ for (; U > 0; ) {+ const Ae = Ve(B.buffer, k), Ee = tt(B, k), De = Ee >> 2 & 3, qe = (Ee >> 4) - 1, He = new Int8Array([qe])[0], Ne = tt(B, k);+ N.push({+ name: Ae,+ index: He,+ type: Ne,+ compression: De+ }), U -= Ae.length + 3;+ }+ const P = Gi.channels, z = new Array(x.inputChannels.length);+ for (let Ae = 0; Ae < x.inputChannels.length; ++Ae) {+ const Ee = z[Ae] = {}, De = P[Ae];+ Ee.name = De.name, Ee.compression = 0, Ee.decoded = !1, Ee.type = De.pixelType, Ee.pLinear = De.pLinear, Ee.width = x.columns, Ee.height = x.lines;+ }+ const j = {+ idx: new Array(3)+ };+ for (let Ae = 0; Ae < x.inputChannels.length; ++Ae) {+ const Ee = z[Ae];+ for (let De = 0; De < N.length; ++De) {+ const qe = N[De];+ Ee.name == qe.name && (Ee.compression = qe.compression, qe.index >= 0 && (j.idx[qe.index] = Ae), Ee.offset = Ae);+ }+ }+ let X, ie, he;+ if (R.acCompressedSize > 0)+ switch (R.acCompression) {+ case 0:+ X = new Uint16Array(R.totalAcUncompressedCount), vt(x.array, B, k, R.acCompressedSize, X, R.totalAcUncompressedCount);+ break;+ case 1:+ const Ae = x.array.slice(k.value, k.value + R.totalAcUncompressedCount), Ee = Zc(Ae);+ X = new Uint16Array(Ee.buffer), k.value += R.totalAcUncompressedCount;+ break;+ }+ if (R.dcCompressedSize > 0) {+ const Ae = {+ array: x.array,+ offset: k,+ size: R.dcCompressedSize+ };+ ie = new Uint16Array(pe(Ae).buffer), k.value += R.dcCompressedSize;+ }+ if (R.rleRawSize > 0) {+ const Ae = x.array.slice(k.value, k.value + R.rleCompressedSize), Ee = Zc(Ae);+ he = dn(Ee.buffer), k.value += R.rleCompressedSize;+ }+ let ce = 0;+ const fe = new Array(z.length);+ for (let Ae = 0; Ae < fe.length; ++Ae)+ fe[Ae] = new Array();+ for (let Ae = 0; Ae < x.lines; ++Ae)+ for (let Ee = 0; Ee < z.length; ++Ee)+ fe[Ee].push(ce), ce += z[Ee].width * x.type * 2;+ dt(j, fe, z, X, ie, _);+ for (let Ae = 0; Ae < z.length; ++Ae) {+ const Ee = z[Ae];+ if (!Ee.decoded)+ switch (Ee.compression) {+ case 2:+ let De = 0, qe = 0;+ for (let He = 0; He < x.lines; ++He) {+ let Ne = fe[Ae][De];+ for (let st = 0; st < Ee.width; ++st) {+ for (let Le = 0; Le < 2 * Ee.type; ++Le)+ _[Ne++] = he[qe + Le * Ee.width * Ee.height];+ qe++;+ }+ De++;+ }+ break;+ // skip+ default:+ throw new Error("EXRLoader.parse: unsupported channel compression");+ }+ }+ return new DataView(_.buffer);+ }+ function Ve(x, B) {+ const k = new Uint8Array(x);+ let _ = 0;+ for (; k[B.value + _] != 0; )+ _ += 1;+ const R = new TextDecoder().decode(+ k.slice(B.value, B.value + _)+ );+ return B.value = B.value + _ + 1, R;+ }+ function Ye(x, B, k) {+ const _ = new TextDecoder().decode(+ new Uint8Array(x).slice(B.value, B.value + k)+ );+ return B.value = B.value + k, _;+ }+ function _e(x, B) {+ const k = ke(x, B), _ = Oe(x, B);+ return [k, _];+ }+ function Re(x, B) {+ const k = Oe(x, B), _ = Oe(x, B);+ return [k, _];+ }+ function ke(x, B) {+ const k = x.getInt32(B.value, !0);+ return B.value = B.value + 4, k;+ }+ function Oe(x, B) {+ const k = x.getUint32(B.value, !0);+ return B.value = B.value + 4, k;+ }+ function Be(x, B) {+ const k = x[B.value];+ return B.value = B.value + 1, k;+ }+ function tt(x, B) {+ const k = x.getUint8(B.value);+ return B.value = B.value + 1, k;+ }+ const We = function(x, B) {+ let k;+ return "getBigInt64" in DataView.prototype ? k = Number(x.getBigInt64(B.value, !0)) : k = x.getUint32(B.value + 4, !0) + Number(x.getUint32(B.value, !0) << 32), B.value += 8, k;+ };+ function nt(x, B) {+ const k = x.getFloat32(B.value, !0);+ return B.value += 4, k;+ }+ function W(x, B) {+ return Rp.toHalfFloat(nt(x, B));+ }+ function ne(x) {+ const B = (x & 31744) >> 10, k = x & 1023;+ return (x >> 15 ? -1 : 1) * (B ? B === 31 ? k ? NaN : 1 / 0 : Math.pow(2, B - 15) * (1 + k / 1024) : 6103515625e-14 * (k / 1024));+ }+ function re(x, B) {+ const k = x.getUint16(B.value, !0);+ return B.value += 2, k;+ }+ function de(x, B) {+ return ne(re(x, B));+ }+ function Ie(x, B, k, _) {+ const R = k.value, N = [];+ for (; k.value < R + _ - 1; ) {+ const U = Ve(B, k), P = ke(x, k), z = tt(x, k);+ k.value += 3;+ const j = ke(x, k), X = ke(x, k);+ N.push({+ name: U,+ pixelType: P,+ pLinear: z,+ xSampling: j,+ ySampling: X+ });+ }+ return k.value += 1, N;+ }+ function Ce(x, B) {+ const k = nt(x, B), _ = nt(x, B), R = nt(x, B), N = nt(x, B), U = nt(x, B), P = nt(x, B), z = nt(x, B), j = nt(x, B);+ return { redX: k, redY: _, greenX: R, greenY: N, blueX: U, blueY: P, whiteX: z, whiteY: j };+ }+ function it(x, B) {+ const k = [+ "NO_COMPRESSION",+ "RLE_COMPRESSION",+ "ZIPS_COMPRESSION",+ "ZIP_COMPRESSION",+ "PIZ_COMPRESSION",+ "PXR24_COMPRESSION",+ "B44_COMPRESSION",+ "B44A_COMPRESSION",+ "DWAA_COMPRESSION",+ "DWAB_COMPRESSION"+ ], _ = tt(x, B);+ return k[_];+ }+ function Ut(x, B) {+ const k = ke(x, B), _ = ke(x, B), R = ke(x, B), N = ke(x, B);+ return { xMin: k, yMin: _, xMax: R, yMax: N };+ }+ function fn(x, B) {+ const k = [+ "INCREASING_Y",+ "DECREASING_Y",+ "RANDOM_Y"+ ], _ = tt(x, B);+ return k[_];+ }+ function Et(x, B) {+ const k = [+ "ENVMAP_LATLONG",+ "ENVMAP_CUBE"+ ], _ = tt(x, B);+ return k[_];+ }+ function Vn(x, B) {+ const k = [+ "ONE_LEVEL",+ "MIPMAP_LEVELS",+ "RIPMAP_LEVELS"+ ], _ = [+ "ROUND_DOWN",+ "ROUND_UP"+ ], R = Oe(x, B), N = Oe(x, B), U = tt(x, B);+ return {+ xSize: R,+ ySize: N,+ levelMode: k[U & 15],+ roundingMode: _[U >> 4]+ };+ }+ function oi(x, B) {+ const k = nt(x, B), _ = nt(x, B);+ return [k, _];+ }+ function lc(x, B) {+ const k = nt(x, B), _ = nt(x, B), R = nt(x, B);+ return [k, _, R];+ }+ function hc(x, B, k, _, R) {+ if (_ === "string" || _ === "stringvector" || _ === "iccProfile")+ return Ye(B, k, R);+ if (_ === "chlist")+ return Ie(x, B, k, R);+ if (_ === "chromaticities")+ return Ce(x, k);+ if (_ === "compression")+ return it(x, k);+ if (_ === "box2i")+ return Ut(x, k);+ if (_ === "envmap")+ return Et(x, k);+ if (_ === "tiledesc")+ return Vn(x, k);+ if (_ === "lineOrder")+ return fn(x, k);+ if (_ === "float")+ return nt(x, k);+ if (_ === "v2f")+ return oi(x, k);+ if (_ === "v3f")+ return lc(x, k);+ if (_ === "int")+ return ke(x, k);+ if (_ === "rational")+ return _e(x, k);+ if (_ === "timecode")+ return Re(x, k);+ if (_ === "preview")+ return k.value += R, "skipped";+ k.value += R;+ }+ function Qi(x, B) {+ const k = Math.log2(x);+ return B == "ROUND_DOWN" ? Math.floor(k) : Math.ceil(k);+ }+ function Wa(x, B, k) {+ let _ = 0;+ switch (x.levelMode) {+ case "ONE_LEVEL":+ _ = 1;+ break;+ case "MIPMAP_LEVELS":+ _ = Qi(Math.max(B, k), x.roundingMode) + 1;+ break;+ case "RIPMAP_LEVELS":+ throw new Error("THREE.EXRLoader: RIPMAP_LEVELS tiles currently unsupported.");+ }+ return _;+ }+ function qa(x, B, k, _) {+ const R = new Array(x);+ for (let N = 0; N < x; N++) {+ const U = 1 << N;+ let P = B / U | 0;+ _ == "ROUND_UP" && P * U < B && (P += 1);+ const z = Math.max(P, 1);+ R[N] = (z + k - 1) / k | 0;+ }+ return R;+ }+ function uc() {+ const x = this, B = x.offset, k = { value: 0 };+ for (let _ = 0; _ < x.tileCount; _++) {+ const R = ke(x.viewer, B), N = ke(x.viewer, B);+ B.value += 8, x.size = Oe(x.viewer, B);+ const U = R * x.blockWidth, P = N * x.blockHeight;+ x.columns = U + x.blockWidth > x.width ? x.width - U : x.blockWidth, x.lines = P + x.blockHeight > x.height ? x.height - P : x.blockHeight;+ const z = x.columns * x.totalBytes, X = x.size < x.lines * z ? x.uncompress(x) : Z(x);+ B.value += x.size;+ for (let ie = 0; ie < x.lines; ie++) {+ const he = ie * x.columns * x.totalBytes;+ for (let ce = 0; ce < x.inputChannels.length; ce++) {+ const fe = Gi.channels[ce].name, Ae = x.channelByteOffsets[fe] * x.columns, Ee = x.decodeChannels[fe];+ if (Ee === void 0) continue;+ k.value = he + Ae;+ const De = (x.height - (1 + P + ie)) * x.outLineWidth;+ for (let qe = 0; qe < x.columns; qe++) {+ const He = De + (qe + U) * x.outputChannels + Ee;+ x.byteArray[He] = x.getter(X, k);+ }+ }+ }+ }+ }+ function Fr() {+ const x = this, B = x.offset, k = { value: 0 };+ for (let _ = 0; _ < x.height / x.blockHeight; _++) {+ const R = ke(x.viewer, B) - Gi.dataWindow.yMin;+ x.size = Oe(x.viewer, B), x.lines = R + x.blockHeight > x.height ? x.height - R : x.blockHeight;+ const N = x.columns * x.totalBytes, P = x.size < x.lines * N ? x.uncompress(x) : Z(x);+ B.value += x.size;+ for (let z = 0; z < x.blockHeight; z++) {+ const j = _ * x.blockHeight, X = z + x.scanOrder(j);+ if (X >= x.height) continue;+ const ie = z * N, he = (x.height - 1 - X) * x.outLineWidth;+ for (let ce = 0; ce < x.inputChannels.length; ce++) {+ const fe = Gi.channels[ce].name, Ae = x.channelByteOffsets[fe] * x.columns, Ee = x.decodeChannels[fe];+ if (Ee !== void 0) {+ k.value = ie + Ae;+ for (let De = 0; De < x.columns; De++) {+ const qe = he + De * x.outputChannels + Ee;+ x.byteArray[qe] = x.getter(P, k);+ }+ }+ }+ }+ }+ }+ function dc(x, B, k) {+ const _ = {};+ if (x.getUint32(0, !0) != 20000630)+ throw new Error("THREE.EXRLoader: Provided file doesn't appear to be in OpenEXR format.");+ _.version = x.getUint8(4);+ const R = x.getUint8(5);+ _.spec = {+ singleTile: !!(R & 2),+ longName: !!(R & 4),+ deepFormat: !!(R & 8),+ multiPart: !!(R & 16)+ }, k.value = 8;+ let N = !0;+ for (; N; ) {+ const U = Ve(B, k);+ if (U === "")+ N = !1;+ else {+ const P = Ve(B, k), z = Oe(x, k), j = hc(x, B, k, P, z);+ j === void 0 ? console.warn(`THREE.EXRLoader: Skipped unknown header attribute type '${P}'.`) : _[U] = j;+ }+ }+ if ((R & -7) != 0)+ throw console.error("THREE.EXRHeader:", _), new Error("THREE.EXRLoader: Provided file is currently unsupported.");+ return _;+ }+ function Dr(x, B, k, _, R) {+ const N = {+ size: 0,+ viewer: B,+ array: k,+ offset: _,+ width: x.dataWindow.xMax - x.dataWindow.xMin + 1,+ height: x.dataWindow.yMax - x.dataWindow.yMin + 1,+ inputChannels: x.channels,+ channelByteOffsets: {},+ scanOrder: null,+ totalBytes: null,+ columns: null,+ lines: null,+ type: null,+ uncompress: null,+ getter: null,+ format: null,+ colorSpace: ln+ };+ switch (x.compression) {+ case "NO_COMPRESSION":+ N.blockHeight = 1, N.uncompress = Z;+ break;+ case "RLE_COMPRESSION":+ N.blockHeight = 1, N.uncompress = le;+ break;+ case "ZIPS_COMPRESSION":+ N.blockHeight = 1, N.uncompress = pe;+ break;+ case "ZIP_COMPRESSION":+ N.blockHeight = 16, N.uncompress = pe;+ break;+ case "PIZ_COMPRESSION":+ N.blockHeight = 32, N.uncompress = oe;+ break;+ case "PXR24_COMPRESSION":+ N.blockHeight = 16, N.uncompress = Ue;+ break;+ case "DWAA_COMPRESSION":+ N.blockHeight = 32, N.uncompress = ve;+ break;+ case "DWAB_COMPRESSION":+ N.blockHeight = 256, N.uncompress = ve;+ break;+ default:+ throw new Error("EXRLoader.parse: " + x.compression + " is unsupported");+ }+ const U = {};+ for (const X of x.channels)+ switch (X.name) {+ case "Y":+ case "R":+ case "G":+ case "B":+ case "A":+ U[X.name] = !0, N.type = X.pixelType;+ }+ let P = !1;+ if (U.R && U.G && U.B)+ P = !U.A, N.outputChannels = 4, N.decodeChannels = { R: 0, G: 1, B: 2, A: 3 };+ else if (U.Y)+ N.outputChannels = 1, N.decodeChannels = { Y: 0 };+ else+ throw new Error("EXRLoader.parse: file contains unsupported data channels.");+ if (N.type == 1)+ switch (R) {+ case an:+ N.getter = de;+ break;+ case Nn:+ N.getter = re;+ break;+ }+ else if (N.type == 2)+ switch (R) {+ case an:+ N.getter = nt;+ break;+ case Nn:+ N.getter = W;+ }+ else+ throw new Error("EXRLoader.parse: unsupported pixelType " + N.type + " for " + x.compression + ".");+ N.columns = N.width;+ const z = N.width * N.height * N.outputChannels;+ switch (R) {+ case an:+ N.byteArray = new Float32Array(z), P && N.byteArray.fill(1, 0, z);+ break;+ case Nn:+ N.byteArray = new Uint16Array(z), P && N.byteArray.fill(15360, 0, z);+ break;+ default:+ console.error("THREE.EXRLoader: unsupported type: ", R);+ break;+ }+ let j = 0;+ for (const X of x.channels)+ N.decodeChannels[X.name] !== void 0 && (N.channelByteOffsets[X.name] = j), j += X.pixelType * 2;+ if (N.totalBytes = j, N.outLineWidth = N.width * N.outputChannels, x.lineOrder === "INCREASING_Y" ? N.scanOrder = (X) => X : N.scanOrder = (X) => N.height - 1 - X, N.outputChannels == 4 ? (N.format = on, N.colorSpace = ln) : (N.format = ns, N.colorSpace = gi), x.spec.singleTile) {+ N.blockHeight = x.tiles.ySize, N.blockWidth = x.tiles.xSize;+ const X = Wa(x.tiles, N.width, N.height), ie = qa(X, N.width, x.tiles.xSize, x.tiles.roundingMode), he = qa(X, N.height, x.tiles.ySize, x.tiles.roundingMode);+ N.tileCount = ie[0] * he[0];+ for (let ce = 0; ce < X; ce++)+ for (let fe = 0; fe < he[ce]; fe++)+ for (let Ae = 0; Ae < ie[ce]; Ae++)+ We(B, _);+ N.decode = uc.bind(N);+ } else {+ N.blockWidth = N.width;+ const X = Math.ceil(N.height / N.blockHeight);+ for (let ie = 0; ie < X; ie++)+ We(B, _);+ N.decode = Fr.bind(N);+ }+ return N;+ }+ const Ka = { value: 0 }, ja = new DataView(e), bh = new Uint8Array(e), Gi = dc(ja, e, Ka), gs = Dr(Gi, ja, bh, Ka, this.type);+ return gs.decode(), {+ header: Gi,+ width: gs.width,+ height: gs.height,+ data: gs.byteArray,+ format: gs.format,+ colorSpace: gs.colorSpace,+ type: this.type+ };+ }+ /**+ * Sets the texture type.+ *+ * @param {(HalfFloatType|FloatType)} value - The texture type to set.+ * @return {RGBMLoader} A reference to this loader.+ */+ setDataType(e) {+ return this.type = e, this;+ }+ load(e, t, n, s) {+ function r(a, o) {+ a.colorSpace = o.colorSpace, a.minFilter = qt, a.magFilter = qt, a.generateMipmaps = !1, a.flipY = !1, t && t(a, o);+ }+ return super.load(e, r, n, s);+ }+}+function lT(i, e) {+ const { id: t, path: n } = e;+ return t === "neutral" ? Promise.resolve({ envMap: i.neutralEnvironment }) : t === "" ? Promise.resolve({ envMap: null }) : new Promise((s, r) => {+ new cT().load(+ n,+ (a) => {+ const o = i.pmremGenerator.fromEquirectangular(a).texture;+ a.dispose(), i._loadedEnvironment && i._loadedEnvironment !== o && i._loadedEnvironment.dispose(), i._loadedEnvironment = o, s({ envMap: o });+ },+ void 0,+ r+ );+ });+}+function hT(i) {+ i.renderer.render(i.scene, i.activeCamera), i.renderer.domElement.toBlob((e) => {+ if (!e) return;+ const t = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-").slice(0, 19), n = URL.createObjectURL(e), s = document.createElement("a");+ s.download = `3d-screenshot-${t}.png`, s.href = n, s.click(), URL.revokeObjectURL(n);+ }, "image/png"), uT(i);+}+function uT(i) {+ const e = document.createElement("div");+ e.className = "screenshot-flash", i.el.appendChild(e), e.addEventListener("animationend", () => e.remove());+}+function dT(i, e) {+ i.mixer && (i.mixer.stopAllAction(), i.mixer.uncacheRoot(i.mixer.getRoot()), i.mixer = null), i.clips = e, e.length && (i.mixer = new v0(i.content));+}+function fT(i) {+ i.clips.forEach((e) => {+ i.mixer.clipAction(e).reset().play(), i.state.actionStates[e.name] = !0;+ }), i.invalidate();+}+const pT = 0.35;+class AT {+ constructor() {+ this.model = null, this.mixer = null, this.clips = /* @__PURE__ */ new Map(), this.actions = /* @__PURE__ */ new Map(), this.currentName = null, this.currentAction = null, this.onChange = null, this._animationDefs = [], this._failed = /* @__PURE__ */ new Set();+ }+ // ── Model binding ──────────────────────────────────────────────────────────+ /**+ * Attach to a loaded model. Call this every time a new model is loaded.+ * Re-creates actions for any clips that are already in memory.+ * @param {THREE.Object3D} model+ */+ attach(e) {+ this.detach(), this.model = e, this.mixer = new v0(e), this.actions.clear(), this.currentAction = null, this.currentName = null;+ for (const [t, n] of this.clips) {+ const s = this.mixer.clipAction(n);+ s.enabled = !0, this.actions.set(t, s);+ }+ }+ /** Detach, stop all actions, dispose mixer. */+ detach() {+ this.mixer && (this.mixer.stopAllAction(), this.mixer.uncacheRoot(this.mixer.getRoot()), this.mixer = null), this.model = null, this.actions.clear(), this.currentAction = null, this.currentName = null;+ }+ // ── Definitions ────────────────────────────────────────────────────────────+ /**+ * Register animation definitions (from manifest.json).+ * @param {Array<{name:string, url:string, label?:string, icon?:string, loop?:boolean}>} defs+ */+ setAnimationDefs(e) {+ this._animationDefs = e;+ }+ /** @returns {Array} */+ getAnimationDefs() {+ return this._animationDefs;+ }+ /** @param {string} name @returns {boolean} */+ isFailed(e) {+ return this._failed.has(e);+ }+ // ── Loading ────────────────────────────────────────────────────────────────+ /**+ * Load a single clip from a pre-baked JSON URL and register it.+ * Idempotent — returns the cached clip if already loaded.+ *+ * @param {string} name+ * @param {string} url URL to a clip JSON produced by build-animations.mjs+ * @param {{ loop?: boolean }} [opts]+ * @returns {Promise<THREE.AnimationClip>}+ */+ async loadAnimation(e, t, n = {}) {+ if (this.clips.has(e)) return this.clips.get(e);+ const s = new AbortController(), r = setTimeout(() => s.abort(), 1e4);+ let a;+ try {+ a = await fetch(t, { signal: s.signal });+ } finally {+ clearTimeout(r);+ }+ if (!a.ok) throw new Error(`HTTP ${a.status} loading animation ${e}`);+ const o = await a.json(), c = Fl.parse(o);+ if (c.name = e, this.clips.set(e, c), this.model && this.mixer) {+ const l = this.mixer.clipAction(c);+ l.enabled = !0, l.setLoop(n.loop === !1 ? $m : e0), n.loop === !1 && (l.clampWhenFinished = !0), this.actions.set(e, l);+ }+ return c;+ }+ /**+ * Load all registered definitions in parallel.+ * Failed clips are logged and added to _failed; they do not throw.+ */+ async loadAll() {+ const t = [...this._animationDefs], n = async () => {+ let s;+ for (; s = t.shift(); )+ try {+ await this.loadAnimation(s.name, s.url, { loop: s.loop !== !1 });+ } catch (r) {+ console.warn(`[AnimationManager] failed to load "${s.name}":`, r.message), this._failed.add(s.name);+ }+ };+ await Promise.all(Array.from({ length: 4 }, n));+ }+ /**+ * Lazily load a single clip by name (from registered defs) if not yet loaded.+ * Used so the first click on a strip button triggers a load without blocking startup.+ * @param {string} name+ * @returns {Promise<boolean>} true if ready+ */+ async ensureLoaded(e) {+ if (this.clips.has(e)) return !0;+ if (this._failed.has(e)) return !1;+ const t = this._animationDefs.find((n) => n.name === e);+ if (!t) return !1;+ try {+ return await this.loadAnimation(t.name, t.url, { loop: t.loop !== !1 }), !0;+ } catch {+ return this._failed.add(e), !1;+ }+ }+ // ── Playback ───────────────────────────────────────────────────────────────+ /**+ * Play a named clip immediately (hard cut, no crossfade).+ * Lazily loads if not yet in memory.+ * @param {string} name+ */+ async play(e) {+ if (!await this.ensureLoaded(e)) {+ console.warn(`[AnimationManager] "${e}" unavailable`);+ return;+ }+ const n = this.actions.get(e);+ if (n) {+ this.currentAction && this.currentAction !== n && this.currentAction.fadeOut(0.01), n.reset().fadeIn(0.01).play(), this.currentAction = n, this.currentName = e;+ try {+ this.onChange?.(e);+ } catch (s) {+ console.warn("[AnimationManager] onChange threw:", s);+ }+ }+ }+ /**+ * Crossfade from the current clip to a named clip.+ * Lazily loads if not yet in memory.+ * @param {string} name+ * @param {number} [duration] seconds+ */+ async crossfadeTo(e, t = pT) {+ if (t = Math.max(0, Math.min(t, 5)), e === this.currentName) return;+ if (!await this.ensureLoaded(e)) {+ console.warn(`[AnimationManager] "${e}" unavailable`);+ return;+ }+ const s = this.actions.get(e);+ if (s) {+ s.reset().play(), this.currentAction ? this.currentAction.crossFadeTo(s, t, !0) : s.fadeIn(t), this.currentAction = s, this.currentName = e;+ try {+ this.onChange?.(e);+ } catch (r) {+ console.warn("[AnimationManager] onChange threw:", r);+ }+ }+ }+ /** Stop all animations. */+ stopAll() {+ this.mixer?.stopAllAction(), this.currentAction = null, this.currentName = null;+ try {+ this.onChange?.(null);+ } catch (e) {+ console.warn("[AnimationManager] onChange threw:", e);+ }+ }+ /**+ * Tick the mixer. Call from the render loop.+ * @param {number} delta seconds since last frame+ */+ update(e) {+ this.mixer?.update(e);+ }+ /** @returns {string[]} */+ getLoadedNames() {+ return [...this.clips.keys()];+ }+ /** @param {string} name @returns {boolean} */+ isLoaded(e) {+ return this.clips.has(e);+ }+ dispose() {+ this.detach(), this.clips.clear(), this._animationDefs = [], this._failed.clear();+ }+}+ss.enabled = !0;+class fb {+ constructor(e, t) {+ this.el = e, this.options = t, this.lights = [], this.content = null, this.mixer = null, this.clips = [], this.gui = null, this.animationManager = new AT(), this._animPanelEl = null, this.state = {+ environment: t.preset === kd.ASSET_GENERATOR ? Vc.find((r) => r.id === "footprint-court").name : Vc[1].name,+ background: !1,+ playbackSpeed: 1,+ actionStates: {},+ camera: Yc,+ wireframe: !1,+ skeleton: !1,+ grid: !1,+ autoRotate: !1,+ // Lights+ punctualLights: !0,+ exposure: 0,+ toneMapping: Ju,+ ambientIntensity: 0.3,+ ambientColor: "#FFFFFF",+ directIntensity: 0.8 * Math.PI,+ // TODO(#116)+ directColor: "#FFFFFF",+ bgColor: "#000000",+ transparentBg: !1,+ pointSize: 1,+ // Info overlay+ showInfo: !0,+ showLabels: !1,+ // Avatar follow mode+ followMode: "mouse"+ }, this.prevTime = 0, this.stats = new vo(), this.stats.dom.height = "48px", [].forEach.call(this.stats.dom.children, (r) => r.style.display = ""), this.backgroundColor = new je(this.state.bgColor), this.scene = new _d(), this.scene.background = this.backgroundColor;+ const n = t.preset === kd.ASSET_GENERATOR ? 0.8 * 180 / Math.PI : 60, s = e.clientHeight > 0 ? e.clientWidth / e.clientHeight : 1;+ this.defaultCamera = new vn(n, s, 0.01, 1e3), this.activeCamera = this.defaultCamera, this.scene.add(this.defaultCamera), this.renderer = window.renderer = new IA({ antialias: !0, alpha: !0 }), this.renderer.setClearColor(0, 1), this.renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2)), this.renderer.setSize(e.clientWidth, e.clientHeight), this.pmremGenerator = new wd(this.renderer), this.pmremGenerator.compileEquirectangularShader(), this.neutralEnvironment = this.pmremGenerator.fromScene(new M1()).texture, this.controls = new A1(this.defaultCamera, this.renderer.domElement), this.controls.screenSpacePanning = !0, this._onControlsChange = () => this.invalidate(), this.controls.addEventListener("change", this._onControlsChange), this.el.appendChild(this.renderer.domElement), this.cameraCtrl = null, this.cameraFolder = null, this.animFolder = null, this.animCtrls = [], this.morphFolder = null, this.morphCtrls = [], this.skeletonHelpers = [], this.gridHelper = null, this.axesHelper = null, this.modelInfo = null, this.annotationEls = [], this._tempVec = new H(), this.addAxesHelper(), this.addGUI(), t.kiosk && this.gui.close(), this.animate = this.animate.bind(this), this._rafId = null, this._visible = !0, this._tabVisible = !document.hidden, this._disposed = !1, this._loadedEnvironment = null, this._guiWrap = null, this._needsRender = !0, this._animating = !1, this._onVisibilityChange = () => {+ const r = !this._tabVisible;+ this._tabVisible = !document.hidden, r && this._tabVisible && (this._needsRender = !0), this._updateRenderLoop();+ }, document.addEventListener("visibilitychange", this._onVisibilityChange), typeof IntersectionObserver < "u" && (this._intersectionObserver = new IntersectionObserver(+ (r) => {+ const a = !this._visible;+ this._visible = r[r.length - 1].isIntersecting, a && this._visible && (this._needsRender = !0), this._updateRenderLoop();+ },+ { threshold: 0 }+ ), this._intersectionObserver.observe(this.el)), this._onResize = this.resize.bind(this), this._onKeyDown = (r) => {+ this.isInputFocused() || (r.key === "p" || r.key === "P" ? this.takeScreenshot() : r.code === "Space" ? (r.preventDefault(), this.toggleAnimationPlayback()) : (r.key === "f" || r.key === "F") && this.frameContent());+ }, this._onDblClick = () => this.frameContent({ animate: !0 }), this._updateRenderLoop(), window.addEventListener("resize", this._onResize, !1), window.addEventListener("keydown", this._onKeyDown), this.renderer.domElement.addEventListener("dblclick", this._onDblClick);+ }+ invalidate() {+ this._disposed || (this._needsRender = !0, this._updateRenderLoop());+ }+ // Per-agent scene preferences (background, environment, exposure, etc.)+ // persisted to localStorage. Call attachScenePrefs(agentId) once per+ // session — it restores the saved values into state and starts auto-saving+ // future tweaks.+ attachScenePrefs(e) {+ if (!e || typeof window > "u") return;+ this._prefsKey = `3dagent:scene:${e}`;+ try {+ const s = localStorage.getItem(this._prefsKey);+ if (s) {+ const r = JSON.parse(s), a = [+ "background",+ "transparentBg",+ "bgColor",+ "autoRotate",+ "exposure",+ "environment"+ ];+ let o = !1;+ for (const c of a)+ r[c] !== void 0 && r[c] !== this.state[c] && (this.state[c] = r[c], o = !0);+ o && (this.backgroundColor.set(this.state.bgColor), this.updateLights(), this.updateEnvironment(), this.updateDisplay(), this.updateBackground(), this.updateGUI?.());+ }+ } catch {+ }+ const t = () => {+ if (this._prefsKey)+ try {+ const s = {+ background: this.state.background,+ transparentBg: this.state.transparentBg,+ bgColor: this.state.bgColor,+ autoRotate: this.state.autoRotate,+ exposure: this.state.exposure,+ environment: this.state.environment+ };+ localStorage.setItem(this._prefsKey, JSON.stringify(s));+ } catch {+ }+ };+ let n = null;+ this._scenePrefsSave = () => {+ n && clearTimeout(n), n = setTimeout(t, 250);+ };+ }+ // Public hook — controllers (dat.gui, drawer UI) call this after a state+ // change so we persist the latest value.+ notifyScenePrefChange() {+ this._scenePrefsSave && this._scenePrefsSave();+ }+ // Spacebar handler: pause/resume the active animation, or play the first+ // available one if nothing is currently selected.+ toggleAnimationPlayback() {+ const e = this.animationManager;+ if (!e) return;+ if (e.currentAction) {+ e.currentAction.paused = !e.currentAction.paused, this.invalidate(), this._recomputeAnimating(), this._updateRenderLoop();+ return;+ }+ const n = (e.getAnimationDefs?.() || []).find((s) => e.isLoaded?.(s.name));+ n && (e.play(n.name), this.invalidate(), this._recomputeAnimating(), this._updateRenderLoop());+ }+ // Frame the loaded model with a flattering 3/4 angle. Optionally animates+ // the camera over a short duration ("F" key snaps; double-click animates).+ frameContent({ animate: e = !1, durationMs: t = 600 } = {}) {+ if (!this.content || !this.defaultCamera || !this.controls) return;+ const n = new yi().setFromObject(this.content), s = n.getSize(new H()), r = s.length();+ if (!isFinite(r) || r === 0) return;+ const a = n.getCenter(new H()), o = this.defaultCamera.fov * (Math.PI / 180), c = Math.max(this.defaultCamera.aspect, 0.01), l = 2 * Math.atan(Math.tan(o / 2) * c), h = s.y / 2 * 1.15 / Math.tan(o / 2), u = s.x / 2 * 1.15 / Math.tan(l / 2), d = Math.max(h, u), f = a.y + s.y * 0.1, m = new H(a.x, f, a.z), A = new H(a.x + d * 0.12, f, a.z + d), g = this._panelBiasY(d);+ m.y -= g, A.y -= g, e ? this._tweenCamera(A, m, t) : (this.defaultCamera.position.copy(A), this.controls.target.copy(m), this.controls.update(), this.invalidate());+ }+ /** Returns the Y world-space shift needed to keep the model above the animation panel. */+ _panelBiasY(e) {+ if (!this._animPanelEl) return 0;+ const t = this._animPanelEl.offsetHeight, n = parseFloat(getComputedStyle(this._animPanelEl).bottom) || 0, s = this.renderer.domElement.clientHeight;+ return s ? (t + n) / s * Math.tan(this.defaultCamera.fov / 2 * (Math.PI / 180)) * e : 0;+ }+ // Smooth ease-out camera tween. Both position and OrbitControls.target+ // are interpolated together so the framing stays correct mid-flight.+ _tweenCamera(e, t, n = 600) {+ this._cameraTweenRaf && cancelAnimationFrame(this._cameraTweenRaf);+ const s = this.defaultCamera.position.clone(), r = this.controls.target.clone(), a = performance.now(), o = (l) => 1 - Math.pow(1 - l, 3), c = (l) => {+ const h = Math.min(1, (l - a) / n), u = o(h);+ this.defaultCamera.position.lerpVectors(s, e, u), this.controls.target.lerpVectors(r, t, u), this.controls.update(), this.invalidate(), h < 1 && !this._disposed ? this._cameraTweenRaf = requestAnimationFrame(c) : this._cameraTweenRaf = null;+ };+ this._cameraTweenRaf = requestAnimationFrame(c);+ }+ _recomputeAnimating() {+ let e = !1;+ if (this.state && this.state.autoRotate && (e = !0), !e && this.mixer && this.state) {+ for (const t in this.state.actionStates)+ if (this.state.actionStates[t]) {+ e = !0;+ break;+ }+ }+ !e && this.animationManager.currentAction && (e = !0), this._animating = e;+ }+ _updateRenderLoop() {+ if (this._disposed) return;+ const e = this._visible && this._tabVisible;+ e && (this._needsRender || this._animating) && this._rafId === null ? (this.prevTime = performance.now(), this._rafId = requestAnimationFrame(this.animate)) : !e && this._rafId !== null && (cancelAnimationFrame(this._rafId), this._rafId = null);+ }+ animate(e) {+ const t = (e - this.prevTime) / 1e3;+ if (this.prevTime = e, this._recomputeAnimating(), this.controls.update(), this.stats.update(), this.mixer && this.mixer.update(t), this.animationManager.update(t), this._afterAnimateHooks)+ for (let n = 0; n < this._afterAnimateHooks.length; n++)+ this._afterAnimateHooks[n](t);+ this.render(), this._needsRender = !1, this._animating && this._visible && this._tabVisible && !this._disposed ? this._rafId = requestAnimationFrame(this.animate) : this._rafId = null;+ }+ isInputFocused() {+ const e = document.activeElement;+ return e && (e.tagName === "INPUT" || e.tagName === "TEXTAREA" || e.isContentEditable);+ }+ render() {+ this.renderer.render(this.scene, this.activeCamera), this.state.grid && (this.axesCamera.position.copy(this.defaultCamera.position), this.axesCamera.lookAt(this.axesScene.position), this.axesRenderer.render(this.axesScene, this.axesCamera)), this.projectAnnotations();+ }+ takeScreenshot() {+ hT(this);+ }+ /**+ * Update the AR button visibility and target URLs after a model loads.+ * @param {string|null} glbUrl — absolute or relative URL to the GLB (for Android/WebXR)+ * @param {string|null} usdzUrl — absolute or relative URL to a USDZ (for iOS Quick Look)+ */+ async setARTarget(e, t = null) {+ if (this._arGlbUrl = e, this._arUsdzUrl = t, !this._arBtn) return;+ const n = !!e, r = !!t && fg(), a = n && pg(), o = n && await Ag.isSupported();+ this._arBtn.hidden = !(r || a || o);+ }+ async _launchAR() {+ if (fg() && this._arUsdzUrl)+ PB(this._arUsdzUrl);+ else if (pg() && this._arGlbUrl)+ UB(this._arGlbUrl);+ else if (this._arGlbUrl) {+ if (this._xrSession) {+ await this._xrSession.end(), this._xrSession = null, this._arBtn.classList.remove("ar-btn--active");+ return;+ }+ this._xrSession = new Ag(this, {+ onEnd: () => {+ this._xrSession = null, this._arBtn.classList.remove("ar-btn--active");+ }+ }), await this._xrSession.start(), this._arBtn.classList.add("ar-btn--active");+ }+ }+ resize() {+ const { clientHeight: e, clientWidth: t } = this.el;+ t === 0 || e === 0 || (this.defaultCamera.aspect = t / e, this.defaultCamera.updateProjectionMatrix(), this.renderer.setSize(t, e), this.axesCamera.aspect = this.axesDiv.clientWidth / this.axesDiv.clientHeight, this.axesCamera.updateProjectionMatrix(), this.axesRenderer.setSize(this.axesDiv.clientWidth, this.axesDiv.clientHeight), this.invalidate());+ }+ load(e, t, n) {+ const s = Aa.extractUrlBase(e);+ return new Promise((r, a) => {+ Ul.setURLModifier((c, l) => {+ const h = t + decodeURI(c).replace(s, "").replace(/^(\.?\/)/, "");+ if (n.has(h)) {+ const u = n.get(h), d = URL.createObjectURL(u);+ return o.push(d), d;+ }+ return (l || "") + c;+ });+ const o = [];+ VB().then(({ dracoLoader: c, ktx2Loader: l, meshoptDecoder: h }) => {+ new R0(Ul).setCrossOrigin("anonymous").setDRACOLoader(c).setKTX2Loader(l.detectSupport(this.renderer)).setMeshoptDecoder(h).load(+ e,+ (d) => {+ window.VIEWER.json = d;+ const f = d.scene || d.scenes[0], m = d.animations || [];+ if (!f)+ throw new Error(+ "This model contains no scene, and cannot be viewed here. However, it may contain individual 3D resources."+ );+ this.setContent(f, m), o.forEach(URL.revokeObjectURL), r(d);+ },+ void 0,+ a+ );+ }, a);+ });+ }+ /**+ * @param {THREE.Object3D} object+ * @param {Array<THREE.AnimationClip} clips+ */+ setContent(e, t) {+ this.clear(), e.updateMatrixWorld();+ const n = new yi().setFromObject(e), s = n.getSize(new H()).length(), r = n.getCenter(new H());+ this.controls.reset(), e.position.x -= r.x, e.position.y -= r.y, e.position.z -= r.z, this.controls.maxDistance = s * 10, this.defaultCamera.near = s / 100, this.defaultCamera.far = s * 100, this.defaultCamera.updateProjectionMatrix();+ const a = n.getSize(new H()), o = this.defaultCamera.fov * (Math.PI / 180), c = Math.max(this.defaultCamera.aspect, 0.01), l = 2 * Math.atan(Math.tan(o / 2) * c), h = a.y / 2 * 1.15 / Math.tan(o / 2), u = a.x / 2 * 1.15 / Math.tan(l / 2), d = Math.max(h, u), f = a.y * 0.1, m = new H();+ this.options.cameraPosition ? m.fromArray(this.options.cameraPosition) : m.set(d * 0.12, f, d);+ const A = this.options.cameraPosition ? new H() : new H(0, f, 0);+ if (this.options.kiosk || this.options.cameraPosition || this._hasRevealed === !0)+ this.defaultCamera.position.copy(m), this.defaultCamera.lookAt(A);+ else {+ const y = new H().subVectors(m, A).multiplyScalar(1.4).add(A);+ y.y += s / 8, this.defaultCamera.position.copy(y), this.defaultCamera.lookAt(A), this._pendingReveal = { framedPos: m.clone(), target: A.clone() }, this._hasRevealed = !0;+ }+ this.setCamera(Yc), this.axesCamera.position.copy(this.defaultCamera.position), this.axesCamera.lookAt(this.axesScene.position), this.axesCamera.near = s / 100, this.axesCamera.far = s * 100, this.axesCamera.updateProjectionMatrix(), this.axesCorner.scale.set(s, s, s), this.controls.saveState(), this.scene.add(e), this.content = e, this.state.punctualLights = !0, this.content.traverse((y) => {+ y.isLight && (this.state.punctualLights = !1);+ }), this.setClips(t), this.animationManager.attach(this.content), this._setupAnimationPanel();+ const p = this._panelBiasY(d);+ if (p > 0 && (this.controls.target.y -= p, this.defaultCamera.position.y -= p, this._pendingReveal && (this._pendingReveal.framedPos.y -= p, this._pendingReveal.target.y -= p), this.controls.update()), this.updateLights(), this.updateGUI(), this.updateEnvironment(), this.updateDisplay(), this.updateModelInfo(e, t), this.updateAnnotations(), window.VIEWER.scene = this.content, this.invalidate(), this._pendingReveal) {+ const { framedPos: y, target: b } = this._pendingReveal;+ this._pendingReveal = null, this._tweenCamera(y, b, 1500);+ }+ }+ setClips(e) {+ dT(this, e);+ }+ playAllClips() {+ fT(this);+ }+ /**+ * @param {string} name+ */+ setCamera(e) {+ e === Yc ? (this.controls.enabled = !0, this.activeCamera = this.defaultCamera) : (this.controls.enabled = !1, this.content.traverse((t) => {+ t.isCamera && t.name === e && (this.activeCamera = t);+ })), this.invalidate();+ }+ updateLights() {+ const e = this.state, t = this.lights;+ e.punctualLights && !t.length ? WB(this) : !e.punctualLights && t.length && qB(this), this.renderer.toneMapping = Number(e.toneMapping), this.renderer.toneMappingExposure = Math.pow(2, e.exposure), t.length === 2 && (t[0].intensity = e.ambientIntensity, t[0].color.set(e.ambientColor), t[1].intensity = e.directIntensity, t[1].color.set(e.directColor)), this.invalidate();+ }+ updateEnvironment() {+ const e = Vc.filter(+ (t) => t.name === this.state.environment+ )[0];+ lT(this, e).then(({ envMap: t }) => {+ this._disposed || !this.scene || (this.scene.environment = t, this.scene.background = this.state.transparentBg ? null : this.state.background ? t : this.backgroundColor, this.invalidate());+ });+ }+ updateDisplay() {+ this.skeletonHelpers.length && this.skeletonHelpers.forEach((e) => this.scene.remove(e)), xg(this.content, (e) => {+ e.wireframe = this.state.wireframe, e instanceof Sf && (e.size = this.state.pointSize);+ }), this.content.traverse((e) => {+ if (e.geometry && e.skeleton && this.state.skeleton) {+ const t = new Xy(e.skeleton.bones[0].parent);+ t.material.linewidth = 3, this.scene.add(t), this.skeletonHelpers.push(t);+ }+ }), this.state.grid !== !!this.gridHelper && (this.state.grid ? (this.gridHelper = new Yy(), this.axesHelper = new nA(), this.axesHelper.renderOrder = 999, this.axesHelper.onBeforeRender = (e) => e.clearDepth(), this.scene.add(this.gridHelper), this.scene.add(this.axesHelper)) : (this.scene.remove(this.gridHelper), this.scene.remove(this.axesHelper), this.gridHelper = null, this.axesHelper = null, this.axesRenderer.clear())), this.controls.autoRotate = this.state.autoRotate, this.invalidate();+ }+ updateBackground() {+ this.backgroundColor.set(this.state.bgColor), this.state.transparentBg ? (this.scene.background = null, this.renderer.setClearColor(0, 0)) : (this.scene.background = this.backgroundColor, this.renderer.setClearColor(0, 1), this.updateEnvironment()), this.invalidate();+ }+ /**+ * Public setter for the scene background color. Used by the widget runtime+ * + Studio postMessage bridge to apply brand config without touching dat.gui.+ * @param {string|number} color CSS color string or hex int.+ */+ setBackgroundColor(e) {+ this.state.bgColor = typeof e == "string" ? e : "#" + e.toString(16).padStart(6, "0"), this.state.transparentBg = !1, this.updateBackground();+ }+ /**+ * Adds AxesHelper.+ *+ * See: https://stackoverflow.com/q/16226693/1314762+ */+ updateModelInfo(e, t) {+ this.modelInfo && (this.modelInfo.remove(), this.modelInfo = null), this.state.showInfo && e && (this.modelInfo = DB(this.el, e, t));+ }+ updateAnnotations() {+ if (this.annotationEls.forEach((t) => t.el.remove()), this.annotationEls = [], !this.state.showLabels || !this.content) return;+ GB(this.content).forEach((t) => {+ const n = HB(t), s = document.createElement("div");+ s.classList.add("annotation-label"), s.appendChild(n), this.el.appendChild(s), this.annotationEls.push({ el: s, position: t.position });+ }), this.invalidate();+ }+ projectAnnotations() {+ if (this.annotationEls.length === 0) return;+ const e = this.el.clientWidth, t = this.el.clientHeight, n = e / 2, s = t / 2, r = this._tempVec;+ this.annotationEls.forEach(({ el: a, position: o }) => {+ if (r.copy(o), r.project(this.activeCamera), r.z > 1) {+ a.style.display = "none";+ return;+ }+ const c = r.x * n + n, l = -(r.y * s) + s;+ a.style.display = "", a.style.left = c + "px", a.style.top = l + "px";+ });+ }+ addAxesHelper() {+ this.axesDiv = document.createElement("div"), this.el.appendChild(this.axesDiv), this.axesDiv.classList.add("axes");+ const { clientWidth: e, clientHeight: t } = this.axesDiv;+ this.axesScene = new _d(), this.axesCamera = new vn(50, e / t, 0.1, 10), this.axesScene.add(this.axesCamera), this.axesRenderer = new IA({ alpha: !0 }), this.axesRenderer.setPixelRatio(window.devicePixelRatio), this.axesRenderer.setSize(this.axesDiv.clientWidth, this.axesDiv.clientHeight), this.axesCamera.up = this.defaultCamera.up, this.axesCorner = new nA(5), this.axesScene.add(this.axesCorner), this.axesDiv.appendChild(this.axesRenderer.domElement);+ }+ addGUI() {+ const e = window.innerWidth <= 700, t = this.gui = new Y1({+ autoPlace: !1,+ width: e ? 220 : 260,+ hideable: !0+ }), n = t.addFolder("Display");+ n.add(this.state, "background").onChange(() => {+ this.updateEnvironment(), this.notifyScenePrefChange();+ }), n.add(this.state, "autoRotate").onChange(() => {+ this.updateDisplay(), this.notifyScenePrefChange();+ }), n.add(this.state, "wireframe").onChange(() => this.updateDisplay()), n.add(this.state, "skeleton").onChange(() => this.updateDisplay()), n.add(this.state, "grid").onChange(() => this.updateDisplay()), n.add(this.controls, "screenSpacePanning"), n.add(this.state, "pointSize", 1, 16).onChange(() => this.updateDisplay()), n.add(this.state, "transparentBg").name("transparent bg").onChange(() => {+ this.updateBackground(), this.notifyScenePrefChange();+ }), n.addColor(this.state, "bgColor").onChange(() => {+ this.updateBackground(), this.notifyScenePrefChange();+ }), n.add({ screenshot: () => this.takeScreenshot() }, "screenshot").name("Screenshot [P]"), n.add(this.state, "showInfo").name("model info").onChange(() => this.updateModelInfo(this.content, this.clips)), n.add(this.state, "showLabels").name("mesh labels").onChange(() => this.updateAnnotations());+ const m = t.addFolder("Lighting");+ m.add(+ this.state,+ "environment",+ Vc.map((T) => T.name)+ ).onChange(() => {+ this.updateEnvironment(), this.notifyScenePrefChange();+ }), m.add(this.state, "exposure", -10, 10, 0.01).onChange(() => {+ this.updateLights(), this.notifyScenePrefChange();+ }), [+ m.add(this.state, "toneMapping", {+ Linear: Ju,+ "ACES Filmic": Vm+ }),+ m.add(this.state, "punctualLights").listen(),+ m.add(this.state, "ambientIntensity", 0, 2),+ m.addColor(this.state, "ambientColor"),+ m.add(this.state, "directIntensity", 0, 4),+ // TODO(#116)+ m.addColor(this.state, "directColor")+ ].forEach((T) => T.onChange(() => this.updateLights())), this.animFolder = t.addFolder("Animation"), this.animFolder.domElement.style.display = "none", this.animFolder.add(this.state, "playbackSpeed", 0, 1).onChange((T) => {+ this.mixer && (this.mixer.timeScale = T);+ }), this.animFolder.add({ playAll: () => this.playAllClips() }, "playAll"), this.morphFolder = t.addFolder("Morph Targets"), this.morphFolder.domElement.style.display = "none", this.cameraFolder = t.addFolder("Cameras"), this.cameraFolder.domElement.style.display = "none", t.addFolder("Agent").add(this.state, "followMode", {+ None: "none",+ "Follow Mouse": "mouse",+ "Follow Keystrokes": "keystrokes"+ }).name("follow mode");+ const b = t.addFolder("Performance"), E = document.createElement("li");+ this.stats.dom.style.position = "static", E.appendChild(this.stats.dom), E.classList.add("gui-stats"), b.__ul.appendChild(E);+ const M = document.createElement("div");+ this.el.appendChild(M), M.classList.add("gui-wrap"), M.classList.add("gui-wrap--hidden"), M.appendChild(t.domElement), this._guiWrap = M;+ const w = document.createElement("button");+ w.className = "gui-toggle", w.setAttribute("title", "Toggle advanced controls"), w.setAttribute("aria-label", "Toggle advanced controls"), w.innerHTML = '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="3"></circle><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"></path></svg><span class="gui-toggle__label">Controls</span>', w.addEventListener("click", () => {+ const T = M.classList.toggle("gui-wrap--hidden");+ w.classList.toggle("gui-toggle--active", !T);+ }), this.el.appendChild(w), this._guiToggle = w;+ const S = document.createElement("button");+ S.className = "ar-btn", S.setAttribute("title", "View in AR"), S.setAttribute("aria-label", "View in AR"), S.innerHTML = '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M1 6l5-3 5 3v5l-5 3-5-3z"></path><path d="M11 3l5 3v5l-5-3z"></path><path d="M1 11l5 3 5-3"></path><path d="M6 9v5"></path><path d="M16 6v5l5 3v-5z"></path><path d="M11 8l5 3"></path></svg><span class="ar-btn__label">AR</span>', S.hidden = !0, S.addEventListener("click", () => this._launchAR()), this.el.appendChild(S), this._arBtn = S, this._arGlbUrl = null, this._arUsdzUrl = null, this._xrSession = null, e ? t.close() : t.open();+ }+ updateGUI() {+ this.cameraFolder.domElement.style.display = "none", this.morphCtrls.forEach((n) => n.remove()), this.morphCtrls.length = 0, this.morphFolder.domElement.style.display = "none", this.animCtrls.forEach((n) => n.remove()), this.animCtrls.length = 0, this.animFolder.domElement.style.display = "none";+ const e = [], t = [];+ if (this.content.traverse((n) => {+ n.geometry && n.morphTargetInfluences && t.push(n), n.isCamera && (n.name = n.name || `VIEWER__camera_${e.length + 1}`, e.push(n.name));+ }), e.length) {+ this.cameraFolder.domElement.style.display = "", this.cameraCtrl && this.cameraCtrl.remove();+ const n = [Yc].concat(e);+ this.cameraCtrl = this.cameraFolder.add(this.state, "camera", n), this.cameraCtrl.onChange((s) => this.setCamera(s));+ }+ if (t.length && (this.morphFolder.domElement.style.display = "", t.forEach((n) => {+ if (n.morphTargetInfluences.length) {+ const s = this.morphFolder.add(+ { name: n.name || "Untitled" },+ "name"+ );+ this.morphCtrls.push(s);+ }+ for (let s = 0; s < n.morphTargetInfluences.length; s++) {+ const r = this.morphFolder.add(n.morphTargetInfluences, s, 0, 1, 0.01).listen();+ Object.keys(n.morphTargetDictionary).forEach((a) => {+ a && n.morphTargetDictionary[a] === s && r.name(a);+ }), this.morphCtrls.push(r);+ }+ })), this.clips.length) {+ this.animFolder.domElement.style.display = "";+ const n = this.state.actionStates = {};+ this.clips.forEach((s, r) => {+ s.name = `${r + 1}. ${s.name}`;+ let a;+ r === 0 ? (n[s.name] = !0, a = this.mixer.clipAction(s), a.play()) : n[s.name] = !1;+ const o = this.animFolder.add(n, s.name).listen();+ o.onChange((c) => {+ a = a || this.mixer.clipAction(s), a.setEffectiveTimeScale(1), c ? a.play() : a.stop(), this.invalidate();+ }), this.animCtrls.push(o);+ });+ }+ }+ // ── External Animation Panel (Mixamo-style) ─────────────────────────────+ /**+ * Register a list of external animation definitions (name + URL).+ * @param {Array<{name: string, url: string, label?: string, icon?: string, loop?: boolean}>} defs+ */+ setAnimationDefs(e) {+ this.animationManager.setAnimationDefs(e), this.content && this._setupAnimationPanel();+ }+ /**+ * Create / rebuild the animation selector panel.+ * @private+ */+ _setupAnimationPanel() {+ if (this._animPanelEl && (this._animPanelEl.remove(), this._animPanelEl = null), this.animationManager.getAnimationDefs().length === 0) return;+ let t = !1;+ if (this.content.traverse((s) => {+ s.isSkinnedMesh && (t = !0);+ }), !t) return;+ const n = document.createElement("div");+ n.className = "anim-panel", n.innerHTML = '<div class="anim-panel__header"><span class="anim-panel__title">Animations</span><button class="anim-panel__stop" title="Stop all">⏹</button></div><div class="anim-panel__grid"></div>', this.el.appendChild(n), this._animPanelEl = n, this._renderAnimButtons(), this.animationManager.loadAll().then(() => {+ this._renderAnimButtons();+ }), n.querySelector(".anim-panel__stop").addEventListener("click", () => {+ this.animationManager.stopAll(), this._renderAnimButtons(), this.invalidate();+ }), this.animationManager.onChange = () => {+ this._renderAnimButtons();+ };+ }+ /**+ * Render / re-render animation buttons in the panel.+ * @private+ */+ _renderAnimButtons() {+ if (!this._animPanelEl) return;+ const e = this._animPanelEl.querySelector(".anim-panel__grid"), t = this.animationManager.getAnimationDefs(), n = this.animationManager.currentName, s = {+ idle: "🧍",+ breathing: "🧍",+ standing: "🧍",+ walking: "🚶",+ walk: "🚶",+ running: "🏃",+ run: "🏃",+ waving: "👋",+ wave: "👋",+ dancing: "💃",+ dance: "💃",+ sitting: "🪑",+ sit: "🪑",+ jumping: "🦘",+ jump: "🦘",+ talking: "🗣️",+ talk: "🗣️",+ clapping: "👏",+ clap: "👏",+ punching: "👊",+ punch: "👊",+ kicking: "🦵",+ kick: "🦵"+ };+ e.innerHTML = t.map((r, a) => {+ const o = this.animationManager.isLoaded(r.name), c = n === r.name, l = r.icon || s[r.name.toLowerCase()] || "▶", h = r.label || r.name.charAt(0).toUpperCase() + r.name.slice(1), u = a < 9 ? a + 1 : "";+ return '<button class="anim-btn' + (c ? " anim-btn--active" : "") + (o ? "" : " anim-btn--loading") + '" data-anim="' + r.name + '" title="' + h + (u ? " — press " + u : "") + '"' + (o ? "" : " disabled") + ">" + (u ? '<span class="anim-btn__key">' + u + "</span>" : "") + '<span class="anim-btn__icon">' + l + '</span><span class="anim-btn__label">' + h + "</span></button>";+ }).join(""), e.querySelectorAll(".anim-btn:not([disabled])").forEach((r) => {+ r.addEventListener("click", () => {+ const a = r.dataset.anim;+ this.animationManager.crossfadeTo(a), this.invalidate(), this._recomputeAnimating(), this._updateRenderLoop();+ });+ }), this._onAnimHotkey || (this._onAnimHotkey = (r) => {+ if (r.target && /INPUT|TEXTAREA|SELECT/.test(r.target.tagName) || r.metaKey || r.ctrlKey || r.altKey) return;+ const a = parseInt(r.key, 10);+ if (!a || a < 1 || a > 9) return;+ const c = this.animationManager.getAnimationDefs()[a - 1];+ !c || !this.animationManager.isLoaded(c.name) || (this.animationManager.crossfadeTo(c.name), this.invalidate(), this._recomputeAnimating(), this._updateRenderLoop());+ }, document.addEventListener("keydown", this._onAnimHotkey));+ }+ clear() {+ this.content && (this.animationManager.detach(), this._animPanelEl && (this._animPanelEl.remove(), this._animPanelEl = null), this.modelInfo && (this.modelInfo.remove(), this.modelInfo = null), this.annotationEls.forEach((e) => e.el.remove()), this.annotationEls = [], this.scene.remove(this.content), this.content.traverse((e) => {+ e.geometry && e.geometry.dispose();+ }), xg(this.content, (e) => {+ for (const t in e)+ t !== "envMap" && e[t] && e[t].isTexture && e[t].dispose();+ }), this.content = null, this._disposed || this.invalidate());+ }+ dispose() {+ if (!this._disposed) {+ if (this._disposed = !0, this._rafId !== null && (cancelAnimationFrame(this._rafId), this._rafId = null), document.removeEventListener("visibilitychange", this._onVisibilityChange), window.removeEventListener("resize", this._onResize, !1), window.removeEventListener("keydown", this._onKeyDown), this._onDblClick && this.renderer?.domElement && this.renderer.domElement.removeEventListener("dblclick", this._onDblClick), this._cameraTweenRaf && cancelAnimationFrame(this._cameraTweenRaf), this._onAnimHotkey && (document.removeEventListener("keydown", this._onAnimHotkey), this._onAnimHotkey = null), this._intersectionObserver && (this._intersectionObserver.disconnect(), this._intersectionObserver = null), this.clear(), this.mixer) {+ this.mixer.stopAllAction();+ const e = this.mixer.getRoot();+ e && this.mixer.uncacheRoot(e), this.mixer = null;+ }+ this.clips = [], this.animationManager.dispose(), this._animPanelEl && (this._animPanelEl.remove(), this._animPanelEl = null), this.skeletonHelpers.length && (this.skeletonHelpers.forEach((e) => {+ this.scene.remove(e), e.dispose?.();+ }), this.skeletonHelpers.length = 0), this.gridHelper && (this.scene.remove(this.gridHelper), this.gridHelper.geometry?.dispose(), this.gridHelper.material?.dispose(), this.gridHelper = null), this.axesHelper && (this.scene.remove(this.axesHelper), this.axesHelper.geometry?.dispose(), this.axesHelper.material?.dispose(), this.axesHelper = null), this.axesCorner && (this.axesScene?.remove(this.axesCorner), this.axesCorner.geometry?.dispose(), this.axesCorner.material?.dispose(), this.axesCorner = null), this.lights.forEach((e) => e.parent?.remove(e)), this.lights = [], this.annotationEls.length && (this.annotationEls.forEach((e) => e.el.remove()), this.annotationEls = []), this.modelInfo && (this.modelInfo.remove(), this.modelInfo = null), this.gui && (this.gui.destroy(), this.gui = null), this._guiWrap && (this._guiWrap.remove(), this._guiWrap = null), this._guiToggle && (this._guiToggle.remove(), this._guiToggle = null), this.stats?.dom && this.stats.dom.remove(), this.controls && (this._onControlsChange && (this.controls.removeEventListener("change", this._onControlsChange), this._onControlsChange = null), this.controls.dispose(), this.controls = null), this._loadedEnvironment && (this._loadedEnvironment.dispose(), this._loadedEnvironment = null), this.neutralEnvironment && (this.neutralEnvironment.dispose(), this.neutralEnvironment = null), this.scene && (this.scene.environment = null, this.scene.background = null), this.pmremGenerator && (this.pmremGenerator.dispose(), this.pmremGenerator = null), this.axesRenderer && (this.axesRenderer.dispose(), this.axesRenderer.forceContextLoss?.(), this.axesRenderer.domElement?.remove(), this.axesRenderer = null), this.axesDiv && (this.axesDiv.remove(), this.axesDiv = null), this.axesScene = null, this.axesCamera = null, this.renderer && (this.renderer.dispose(), this.renderer.forceContextLoss?.(), this.renderer.domElement?.remove(), window.renderer === this.renderer && (window.renderer = null), this.renderer = null), this.scene = null, this.content = null, this.activeCamera = null, this.defaultCamera = null, this._afterAnimateHooks = null;+ }+ }+}+class gT {+ constructor({+ model: e = "claude-opus-4-6",+ proxyURL: t,+ apiKey: n,+ agentId: s,+ apiOrigin: r,+ temperature: a = 0.7,+ maxTokens: o = 4096,+ thinking: c = "auto"+ } = {}) {+ this.model = e, this.apiKey = n, this.temperature = a, this.maxTokens = o, this.thinking = c, t ? this.proxyURL = t : !n && s && r ? this.proxyURL = `${r}/api/llm/anthropic?agent=${encodeURIComponent(s)}` : this.proxyURL = null;+ }+ async complete({ system: e, messages: t, tools: n }) {+ const s = {+ model: this.model,+ max_tokens: this.maxTokens,+ temperature: this.temperature,+ system: e,+ messages: t+ };+ n && n.length && (s.tools = n), this.thinking === "always" && (s.thinking = { type: "enabled", budget_tokens: 2048 });+ const r = this.proxyURL || "https://api.anthropic.com/v1/messages", a = { "content-type": "application/json" };+ this.apiKey && (a["x-api-key"] = this.apiKey, a["anthropic-version"] = "2023-06-01", a["anthropic-dangerous-direct-browser-access"] = "true");+ const o = await fetch(r, { method: "POST", headers: a, body: JSON.stringify(s) });+ if (!o.ok) {+ const l = await o.text();+ throw new Error(`Anthropic ${o.status}: ${l}`);+ }+ const c = await o.json();+ return this._normalize(c);+ }+ _normalize(e) {+ const t = { text: "", toolCalls: [], thinking: "", stopReason: e.stop_reason };+ for (const n of e.content || [])+ n.type === "text" ? t.text += n.text : n.type === "thinking" ? t.thinking += n.thinking || "" : n.type === "tool_use" && t.toolCalls.push({ id: n.id, name: n.name, input: n.input });+ return t;+ }+ // Convert normalized tool results back into a user-role message+ formatToolResults(e) {+ return {+ role: "user",+ content: e.map((t) => ({+ type: "tool_result",+ tool_use_id: t.id,+ content: typeof t.output == "string" ? t.output : JSON.stringify(t.output),+ is_error: !!t.isError+ }))+ };+ }+ formatAssistantWithToolCalls(e, t) {+ const n = [];+ e && n.push({ type: "text", text: e });+ for (const s of t)+ n.push({ type: "tool_use", id: s.id, name: s.name, input: s.input });+ return { role: "assistant", content: n };+ }+}+class mT {+ // Used when brain.provider === "none" — skills drive the agent.+ async complete() {+ return { text: "", toolCalls: [], stopReason: "end_turn" };+ }+ formatToolResults() {+ return { role: "user", content: [] };+ }+ formatAssistantWithToolCalls(e) {+ return { role: "assistant", content: e || "" };+ }+}+function bT(i = {}) {+ const e = i.provider || "anthropic";+ if (e === "anthropic") return new gT(i);+ if (e === "none") return new mT();+ throw new Error(`Unsupported provider: ${e}. Supported: anthropic, none`);+}+class xT {+ constructor({ voiceId: e = "default", rate: t = 1, pitch: n = 1, lang: s = "en-US" } = {}) {+ this.voiceId = e, this.rate = t, this.pitch = n, this.lang = s, this._queue = [], this._speaking = !1;+ }+ async speak(e, { onStart: t, onEnd: n } = {}) {+ if ("speechSynthesis" in window)+ return new Promise((s) => {+ const r = new SpeechSynthesisUtterance(e);+ r.rate = this.rate, r.pitch = this.pitch, r.lang = this.lang;+ const a = this._pickVoice();+ a && (r.voice = a), r.onstart = () => {+ this._speaking = !0, t?.();+ }, r.onend = () => {+ this._speaking = !1, n?.(), s();+ }, r.onerror = () => {+ this._speaking = !1, s();+ }, window.speechSynthesis.speak(r);+ });+ }+ cancel() {+ "speechSynthesis" in window && window.speechSynthesis.cancel(), this._speaking = !1;+ }+ get speaking() {+ return this._speaking;+ }+ _pickVoice() {+ if (!("speechSynthesis" in window)) return null;+ const e = window.speechSynthesis.getVoices();+ if (this.voiceId && this.voiceId !== "default") {+ const t = e.find(+ (n) => n.name === this.voiceId || n.voiceURI === this.voiceId+ );+ if (t) return t;+ }+ return e.find((t) => t.lang?.startsWith(this.lang.slice(0, 2))) || null;+ }+}+class _T {+ constructor({ language: e = "en-US", continuous: t = !1, interimResults: n = !0 } = {}) {+ this.language = e, this.continuous = t, this.interimResults = n, this._recognition = null, this._listening = !1;+ }+ _ensure() {+ if (this._recognition) return this._recognition;+ const e = window.SpeechRecognition || window.webkitSpeechRecognition;+ if (!e) return null;+ const t = new e();+ return t.lang = this.language, t.continuous = this.continuous, t.interimResults = this.interimResults, this._recognition = t, t;+ }+ async listen({ onInterim: e, onFinal: t } = {}) {+ const n = this._ensure();+ if (!n) throw new Error("SpeechRecognition unavailable in this browser");+ return new Promise((s, r) => {+ let a = "";+ n.onresult = (o) => {+ for (let c = o.resultIndex; c < o.results.length; c++) {+ const l = o.results[c], h = l[0].transcript;+ l.isFinal ? (a += h, t?.(h)) : e?.(h);+ }+ }, n.onerror = (o) => {+ this._listening = !1, r(o.error);+ }, n.onend = () => {+ this._listening = !1, s(a.trim());+ }, this._listening = !0;+ try {+ n.start();+ } catch (o) {+ this._listening = !1, r(o);+ }+ });+ }+ stop() {+ this._recognition && this._listening && this._recognition.stop();+ }+ get listening() {+ return this._listening;+ }+}+class ET {+ constructor({+ voiceId: e,+ modelId: t = "eleven_turbo_v2_5",+ apiKey: n = null,+ proxyURL: s = null,+ rate: r = 1,+ pitch: a = 1,+ lang: o = "en-US",+ stability: c = 0.5,+ similarityBoost: l = 0.75,+ useSpeakerBoost: h = !0+ } = {}) {+ if (!e) throw new Error("ElevenLabsTTS requires voiceId");+ this.voiceId = e, this.modelId = t, this.apiKey = n, this.proxyURL = s, this.rate = r, this.pitch = a, this.lang = o, this.stability = c, this.similarityBoost = l, this.useSpeakerBoost = h, this._speaking = !1, this._abort = null, this._audio = null, this._mediaSourceURL = null, this._onEnd = null;+ }+ async speak(e, { onStart: t, onEnd: n } = {}) {+ if (this.cancel(), !e) return;+ this._abort = new AbortController(), this._speaking = !0;+ const s = this.proxyURL || `https://api.elevenlabs.io/v1/text-to-speech/${encodeURIComponent(this.voiceId)}/stream`, r = { "content-type": "application/json", accept: "audio/mpeg" };+ !this.proxyURL && this.apiKey && (r["xi-api-key"] = this.apiKey);+ const a = Math.min(1.5, Math.max(0.5, this.rate)), o = Math.min(1, Math.max(0, (a - 0.5) / 1)), c = JSON.stringify({+ text: e,+ model_id: this.modelId,+ voice_settings: {+ stability: this.stability,+ similarity_boost: this.similarityBoost,+ style: o,+ use_speaker_boost: this.useSpeakerBoost+ },+ // Forwarded for proxies that prefer a single endpoint+ voiceId: this.voiceId,+ modelId: this.modelId+ });+ let l;+ try {+ l = await fetch(s, {+ method: "POST",+ headers: r,+ body: c,+ signal: this._abort.signal+ });+ } catch (d) {+ if (this._speaking = !1, d.name === "AbortError") return;+ throw d;+ }+ if (!l.ok)+ throw this._speaking = !1, new Error(`ElevenLabs TTS HTTP ${l.status}`);+ const h = typeof MediaSource < "u" && MediaSource.isTypeSupported("audio/mpeg"), u = (d) => {+ this._startedFired || (this._startedFired = !0, d?.());+ };+ return this._startedFired = !1, new Promise((d) => {+ this._onEnd = () => {+ this._speaking = !1, this._cleanupAudio(), n?.(), this._onEnd = null, d();+ };+ const f = () => {+ this._onEnd && this._onEnd();+ };+ h && l.body ? this._playStreamingMSE(l.body, () => u(t), f) : this._playBuffered(l, () => u(t), f);+ });+ }+ cancel() {+ if (this._abort) {+ try {+ this._abort.abort();+ } catch {+ }+ this._abort = null;+ }+ this._cleanupAudio(), this._speaking = !1, this._onEnd && this._onEnd();+ }+ get speaking() {+ return this._speaking;+ }+ // ── Internal: streaming via MediaSource ────────────────────────────────+ _playStreamingMSE(e, t, n) {+ const s = new MediaSource();+ this._mediaSourceURL = URL.createObjectURL(s);+ const r = new Audio(this._mediaSourceURL);+ this._audio = r, r.preload = "auto", r.addEventListener("playing", t, { once: !0 }), r.addEventListener("ended", () => this._onEnd?.(), { once: !0 }), r.addEventListener("error", () => n?.(), { once: !0 }), s.addEventListener("sourceopen", async () => {+ let a;+ try {+ a = s.addSourceBuffer("audio/mpeg");+ } catch {+ n?.();+ return;+ }+ const o = e.getReader(), c = [];+ let l = !0;+ const h = () => {+ if (!l || a.updating) return;+ const u = c.shift();+ if (u)+ try {+ a.appendBuffer(u);+ } catch {+ l = !1;+ try {+ s.endOfStream();+ } catch {+ }+ }+ };+ a.addEventListener("updateend", h);+ try {+ for (; l; ) {+ const { value: u, done: d } = await o.read();+ if (d) {+ l = !1;+ const f = () => {+ if (a.updating || c.length)+ setTimeout(f, 30);+ else+ try {+ s.endOfStream();+ } catch {+ }+ };+ f();+ break;+ }+ c.push(u), h();+ }+ } catch (u) {+ u.name !== "AbortError" && n?.();+ }+ }), r.play().catch(n);+ }+ // ── Internal: buffered playback fallback (Safari) ──────────────────────+ async _playBuffered(e, t, n) {+ try {+ const s = await e.blob(), r = URL.createObjectURL(s);+ this._mediaSourceURL = r;+ const a = new Audio(r);+ this._audio = a, a.addEventListener("playing", t, { once: !0 }), a.addEventListener("ended", () => this._onEnd?.(), { once: !0 }), a.addEventListener("error", () => n?.(), { once: !0 }), await a.play();+ } catch (s) {+ s.name !== "AbortError" && n?.();+ }+ }+ _cleanupAudio() {+ if (this._audio) {+ try {+ this._audio.pause();+ } catch {+ }+ this._audio.src = "", this._audio = null;+ }+ if (this._mediaSourceURL) {+ try {+ URL.revokeObjectURL(this._mediaSourceURL);+ } catch {+ }+ this._mediaSourceURL = null;+ }+ this._startedFired = !1;+ }+}+function yT(i = {}) {+ const e = i.provider || "browser";+ if (e === "none") return null;+ if (e === "browser") return new xT(i);+ if (e === "elevenlabs") return new ET(i);+ throw new Error(`TTS provider "${e}" not implemented yet`);+}+function wT(i = {}) {+ const e = i.provider || "browser";+ if (e === "none") return null;+ if (e === "browser") return new _T(i);+ throw new Error(`STT provider "${e}" not implemented yet`);+}+const _g = [+ {+ name: "wave",+ description: "Wave at the user. Use for greetings, farewells, or acknowledgments.",+ input_schema: {+ type: "object",+ properties: {+ duration_ms: { type: "integer", minimum: 500, maximum: 5e3, default: 1500 }+ }+ }+ },+ {+ name: "lookAt",+ description: "Direct the agent's gaze toward a target.",+ input_schema: {+ type: "object",+ properties: {+ target: {+ type: "string",+ enum: ["user", "camera", "center"],+ description: "Where to look"+ }+ },+ required: ["target"]+ }+ },+ {+ name: "play_clip",+ description: "Play a named animation clip from the loaded body.",+ input_schema: {+ type: "object",+ properties: {+ name: { type: "string" },+ loop: { type: "boolean", default: !1 },+ fade_ms: { type: "integer", default: 200 }+ },+ required: ["name"]+ }+ },+ {+ name: "setExpression",+ description: "Set facial expression via morph target preset.",+ input_schema: {+ type: "object",+ properties: {+ preset: {+ type: "string",+ enum: ["neutral", "happy", "sad", "surprised", "confused", "focused"]+ },+ intensity: { type: "number", minimum: 0, maximum: 1, default: 1 }+ },+ required: ["preset"]+ }+ },+ {+ name: "speak",+ description: "Say something out loud via TTS. Use this instead of plain text when voice is on.",+ input_schema: {+ type: "object",+ properties: { text: { type: "string" } },+ required: ["text"]+ }+ },+ {+ name: "remember",+ description: "Save a durable memory about the user, a feedback rule, a project fact, or a reference.",+ input_schema: {+ type: "object",+ properties: {+ key: { type: "string", description: 'short snake_case filename, e.g. "user_role"' },+ name: { type: "string" },+ description: { type: "string" },+ type: { type: "string", enum: ["user", "feedback", "project", "reference"] },+ body: { type: "string" }+ },+ required: ["key", "name", "description", "type", "body"]+ }+ }+], vT = [+ {+ name: "observe_agents",+ description: "List the other agents currently sharing this stage, with their names and positions.",+ input_schema: { type: "object", properties: {} }+ },+ {+ name: "say_to_agent",+ description: "Send a message to another agent on the same stage. The target agent will receive it as a user turn and reply in their own chat chrome.",+ input_schema: {+ type: "object",+ properties: {+ agentId: {+ type: "string",+ description: "Target agent id as returned by observe_agents."+ },+ text: { type: "string" }+ },+ required: ["agentId", "text"]+ }+ }+], CT = {+ async wave(i, e) {+ const t = i.duration_ms || 1500;+ return await e.viewer.playAnimationByHint?.("wave", { duration: t }), e.memory.note("waved", { duration_ms: t }), { ok: !0 };+ },+ async lookAt(i, e) {+ const t = i.target || "user";+ return e.viewer.lookAt?.(t), { ok: !0, target: t };+ },+ async play_clip(i, e) {+ const { name: t, loop: n = !1, fade_ms: s = 200 } = i, r = e.viewer.resolveAnimationSlot?.(t) ?? t;+ return e.viewer.playClipByName?.(r, { loop: n, fade_ms: s }) ? { ok: !0, name: t, resolved: r } : (r !== t && console.warn(`[play_clip] slot "${t}" → "${r}" not found in library`), { ok: !1, error: `No clip named "${r}"` });+ },+ async setExpression(i, e) {+ const { preset: t, intensity: n = 1 } = i;+ return e.viewer.setExpression?.(t, n), { ok: !0, preset: t };+ },+ async speak(i, e) {+ return await e.speak(i.text), { ok: !0 };+ },+ async remember(i, e) {+ const { key: t, name: n, description: s, type: r, body: a } = i;+ return e.memory.write(t, { name: n, description: s, type: r, body: a }), { ok: !0, saved: t };+ },+ async observe_agents(i, e) {+ return e.stage ? { ok: !0, agents: e.stage.getAgents().filter((n) => n.agentId !== e.agentId).map(({ agentId: n, name: s, position: r }) => ({ agentId: n, name: s, position: r })) } : { ok: !1, error: "not on a stage" };+ },+ async say_to_agent(i, e) {+ if (!e.stage) return { ok: !1, error: "not on a stage" };+ const { agentId: t, text: n } = i;+ if (!t || !n) return { ok: !1, error: "agentId and text required" };+ const s = e.agentId || "anon";+ return e.stage.broadcast(s, { kind: "direct", to: t, text: n }), e.stage.routeMessage(s, t, n);+ }+}, ST = 8;+class IT extends EventTarget {+ constructor({+ manifest: e,+ viewer: t,+ memory: n,+ skills: s,+ providerConfig: r = {},+ voiceConfig: a = {},+ stage: o = null,+ agentId: c = null+ } = {}) {+ super(), this.manifest = e || {}, this.viewer = t, this.memory = n, this.skills = s, this.stage = o, this.agentId = c, this.provider = bT({+ ...this.manifest.brain,+ ...r+ }), this.tts = yT({ ...this.manifest.voice?.tts, ...a.tts }), this.stt = wT({ ...this.manifest.voice?.stt, ...a.stt }), this.messages = [], this._busy = !1;+ }+ get systemPrompt() {+ const e = [];+ return this.manifest.instructions && e.push(this.manifest.instructions), this.memory && e.push(+ `++<memory>+` + this.memory.contextBlock({+ maxTokens: this.manifest.memory?.maxTokens || 8192+ }) + `+</memory>`+ ), this.skills && e.push(this.skills.systemPrompt()), e.join("");+ }+ get tools() {+ const e = new Set(this.manifest.tools || _g.map((r) => r.name)), t = _g.filter((r) => e.has(r.name)), n = this.skills ? this.skills.allTools() : [], s = this.stage ? vT : [];+ return [...t, ...s, ...n];+ }+ async send(e, { voice: t = !1 } = {}) {+ if (this._busy)+ throw new Error("Runtime busy — wait for current turn to finish");+ this._busy = !0;+ try {+ this.memory?.note("user_said", { text: e }), this.messages.push({ role: "user", content: e }), this.dispatchEvent(+ new CustomEvent("brain:message", {+ detail: { role: "user", content: e }+ })+ );+ const n = await this._loop();+ return t && n.text && this.tts && (this.dispatchEvent(+ new CustomEvent("voice:speech-start", { detail: { text: n.text } })+ ), await this.tts.speak(n.text), this.dispatchEvent(new CustomEvent("voice:speech-end", {}))), n;+ } finally {+ this._busy = !1;+ }+ }+ async _loop() {+ let e = 0, t = "";+ for (; e++ < ST; ) {+ const n = await this.provider.complete({+ system: this.systemPrompt,+ messages: this.messages,+ tools: this.tools+ });+ if (n.thinking && this.dispatchEvent(+ new CustomEvent("brain:thinking", { detail: { content: n.thinking } })+ ), !n.toolCalls.length) {+ t = n.text, this.messages.push({ role: "assistant", content: n.text }), this.dispatchEvent(+ new CustomEvent("brain:message", {+ detail: { role: "assistant", content: n.text }+ })+ );+ break;+ }+ this.messages.push(+ this.provider.formatAssistantWithToolCalls(n.text, n.toolCalls)+ ), n.text && this.dispatchEvent(+ new CustomEvent("brain:message", {+ detail: { role: "assistant", content: n.text }+ })+ );+ const s = [];+ for (const r of n.toolCalls) {+ let a, o = !1;+ try {+ a = await this._dispatchTool(r);+ } catch (c) {+ a = { error: c.message || String(c) }, o = !0;+ }+ this.dispatchEvent(+ new CustomEvent("skill:tool-called", {+ detail: { tool: r.name, args: r.input, result: a }+ })+ ), s.push({ id: r.id, output: a, isError: o });+ }+ this.messages.push(this.provider.formatToolResults(s));+ }+ return { text: t };+ }+ async _dispatchTool(e) {+ const t = this._context(), n = this.skills?.findSkillForTool(e.name);+ if (n) return n.invoke(e.name, e.input, t);+ const s = CT[e.name];+ if (!s) throw new Error(`Unknown tool: ${e.name}`);+ return s(e.input, t);+ }+ _context() {+ return this.skills, {+ viewer: this.viewer,+ memory: this.memory,+ llm: {+ complete: (e, t) => this.provider.complete({+ system: t?.system || "",+ messages: [{ role: "user", content: e }],+ tools: t?.tools+ })+ },+ speak: async (e) => {+ this.tts && (this.dispatchEvent(new CustomEvent("voice:speech-start", { detail: { text: e } })), await this.tts.speak(e), this.dispatchEvent(new CustomEvent("voice:speech-end", {})));+ },+ listen: (e) => this.stt?.listen(e),+ fetch: (e, t) => fetch(e, t),+ loadGLB: async (e) => this.viewer.loadGLB?.(e),+ loadClip: async (e) => this.viewer.loadClip?.(e),+ loadJSON: async (e) => (await fetch(e)).json(),+ call: async (e, t) => this._dispatchTool({ name: e, input: t }),+ stage: this.stage,+ agentId: this.agentId+ };+ }+ async listen({ onInterim: e, onFinal: t } = {}) {+ if (!this.stt) throw new Error("STT not configured");+ return this.dispatchEvent(new CustomEvent("voice:listen-start", {})), await this.stt.listen({+ onInterim: (s) => {+ this.dispatchEvent(+ new CustomEvent("voice:transcript", { detail: { text: s, final: !1 } })+ ), e?.(s);+ },+ onFinal: (s) => {+ this.dispatchEvent(+ new CustomEvent("voice:transcript", { detail: { text: s, final: !0 } })+ ), t?.(s);+ }+ });+ }+ clearConversation() {+ this.messages = [];+ }+ pause() {+ this.tts?.cancel(), this.stt?.stop();+ }+ destroy() {+ this.pause(), this.messages = [];+ }+}+const Od = [+ "https://dweb.link/ipfs/",+ "https://cloudflare-ipfs.com/ipfs/",+ "https://ipfs.io/ipfs/"+], MT = "https://arweave.net/";+function Gs(i, e = 0) {+ if (!i) return i;+ const t = i.match(/^ipfs:\/\/(.+)$/i);+ if (t)+ return Od[e % Od.length] + t[1];+ const n = i.match(/^ar:\/\/(.+)$/i);+ return n ? MT + n[1] : i;+}+async function BT(i) {+ let e;+ for (let t = 0; t < Od.length; t++) {+ const n = Gs(i, t);+ try {+ const s = await fetch(n);+ if (s.ok) return s;+ } catch (s) {+ e = s;+ }+ }+ throw e || new Error("All IPFS gateways failed for " + i);+}+const TT = {+ idle: "idle",+ wave: "reaction",+ nod: "reaction",+ shake: "angry",+ think: "pray",+ celebrate: "celebrate",+ concern: "defeated",+ bow: "sitclap",+ point: "reaction",+ shrug: "defeated"+};+function RT(i, e) {+ return e && e[i] ? e[i] : TT[i] ?? i;+}+const Eg = {+ neutral: {+ /* reset all */+ },+ happy: { mouthSmile: 1, browInnerUp: 0.3, cheekSquintL: 0.4, cheekSquintR: 0.4 },+ sad: { mouthFrownL: 0.8, mouthFrownR: 0.8, browDownL: 0.6, browDownR: 0.6 },+ surprised: { jawOpen: 0.5, eyeWideL: 0.8, eyeWideR: 0.8, browInnerUp: 0.9 },+ confused: { browInnerUp: 0.5, browOuterUpL: 0.4, mouthPressL: 0.3, mouthPressR: 0.3 },+ focused: { browDownL: 0.4, browDownR: 0.4, eyeSquintL: 0.3, eyeSquintR: 0.3 }+};+class NT {+ constructor(e) {+ this.viewer = e, this._loader = new R0(), this._userTarget = new H(0, 1.6, 2), this._animationMap = {}, this._group = null, this._groupMixer = null, this._groupClips = null, this._mixerHook = null;+ }+ // Expose the underlying Three.js handles skills may need+ get scene() {+ return this.viewer.scene;+ }+ get mixer() {+ return this._groupMixer || this.viewer.mixer;+ }+ get clips() {+ return this._groupClips || this.viewer.clips || [];+ }+ get content() {+ return this._group || this.viewer.content;+ }+ // Scope all scene operations to a sub-group (used by <agent-stage>).+ setGroup(e, { mixer: t = null, clips: n = null } = {}) {+ this._group = e, this._groupMixer = t, this._groupClips = n, t && (this._mixerHook = (s) => {+ t.update(s), this.viewer._animating = !0, this.viewer.invalidate();+ }, this._addHook(this._mixerHook));+ }+ dispose() {+ if (this._mixerHook && this._removeHook(this._mixerHook), this._groupMixer) {+ try {+ this._groupMixer.stopAllAction();+ } catch {+ }+ try {+ this._groupMixer.uncacheRoot(this._group);+ } catch {+ }+ }+ this._mixerHook = null, this._groupMixer = null, this._groupClips = null, this._group = null;+ }+ /**+ * Set the agent's animation slot override map (from meta.edits.animations).+ * @param {Object|null} map — { slotName: clipName, … }+ */+ setAnimationMap(e) {+ this._animationMap = e || {};+ }+ /**+ * Resolve a slot name (e.g. 'celebrate') to the actual clip name.+ * Falls back to DEFAULT_ANIMATION_MAP, then the slot name itself.+ * @param {string} name+ * @returns {string}+ */+ resolveAnimationSlot(e) {+ return RT(e, this._animationMap);+ }+ // Delegate raw load for ad-hoc cases+ async load(e, t = "", n = /* @__PURE__ */ new Map()) {+ return this.viewer.load(e, t, n);+ }+ // --- Animation ---+ playClipByName(e, { loop: t = !1, fade_ms: n = 200 } = {}) {+ const s = this._findClip(e), r = this.mixer;+ if (s && r) {+ const o = r.clipAction(s);+ return o.reset(), o.setLoop(+ t ? 2201 : 2200+ /* LoopOnce */+ ), o.clampWhenFinished = !t, o.fadeIn(n / 1e3), o.play(), this._group || (this.viewer.state.actionStates[s.name] = !0), this.viewer._animating = !0, this.viewer.invalidate(), !0;+ }+ const a = this.viewer?.animationManager;+ return !a || a.isFailed(e) ? !1 : (t ? a.crossfadeTo(e, n / 1e3) : a.play(e), !0);+ }+ playAnimationByHint(e, t) {+ const n = e.toLowerCase(), s = this.clips.find((a) => a.name.toLowerCase().includes(n));+ if (s) return this.playClipByName(s.name, t);+ const r = this.viewer?.animationManager;+ if (r) {+ for (const a of r.clips.keys())+ if (a.toLowerCase().includes(n))+ return this.playClipByName(a, t);+ }+ return !1;+ }+ stopClip(e) {+ const t = this.mixer;+ if (!t) return;+ const n = e ? this._findClip(e) : null;+ if (n) {+ const s = t.existingAction(n);+ s && s.fadeOut(0.2), this._group || (this.viewer.state.actionStates[n.name] = !1);+ } else if (t.stopAllAction(), !this._group)+ for (const s in this.viewer.state.actionStates)+ this.viewer.state.actionStates[s] = !1;+ this.viewer.invalidate();+ }+ async play(e, t) {+ if (typeof e == "string") return this.playClipByName(e, t);+ const n = this.mixer;+ if (!n || !e) return !1;+ const s = n.clipAction(e);+ return s.reset(), s.fadeIn(t?.blend ?? 0.2), s.play(), this.viewer._animating = !0, this.viewer.invalidate(), !0;+ }+ async loadClip(e) {+ const t = Gs(e);+ return new Promise((n, s) => {+ this._loader.load(+ t,+ (r) => n(r.animations?.[0] || null),+ void 0,+ s+ );+ });+ }+ async loadGLB(e) {+ const t = Gs(e);+ return new Promise((n, s) => {+ this._loader.load(t, n, void 0, s);+ });+ }+ // --- Gaze ---+ lookAt(e) {+ const t = this._resolveTarget(e);+ if (!t) {+ e != null && console.warn(`[SceneController] unknown lookAt target: "${e}"`);+ return;+ }+ if (!this.viewer.content) return;+ const n = this._findBone(["Head", "head", "mixamorigHead"]);+ n ? n.lookAt(t) : this.viewer.content.lookAt(t.x, this.viewer.content.position.y, t.z), this.viewer.invalidate();+ }+ _resolveTarget(e) {+ return e instanceof H ? e : e === "camera" ? this.viewer.activeCamera.position.clone() : e === "center" ? new H(0, 1, 0) : e === "user" ? this.viewer.renderer?.xr?.isPresenting ? this.viewer.renderer.xr.getCamera().position.clone() : this._userTarget.clone() : null;+ }+ _findBone(e) {+ if (!this.viewer.content) return null;+ (!this._boneCache || this._boneCacheContent !== this.viewer.content) && (this._boneCache = /* @__PURE__ */ new Map(), this._boneCacheContent = this.viewer.content);+ const t = e.join(",");+ if (this._boneCache.has(t)) return this._boneCache.get(t);+ let n = null;+ return this.viewer.content.traverse((s) => {+ n || s.isBone && e.includes(s.name) && (n = s);+ }), this._boneCache.set(t, n), n;+ }+ // --- Expression (morph targets) ---+ setExpression(e, t = 1) {+ const n = Eg[e] || Eg.neutral;+ this.viewer.content && (this.viewer.content.traverse((s) => {+ if (!(!s.morphTargetDictionary || !s.morphTargetInfluences)) {+ for (let r = 0; r < s.morphTargetInfluences.length; r++)+ s.morphTargetInfluences[r] = 0;+ for (const [r, a] of Object.entries(n)) {+ const o = s.morphTargetDictionary[r];+ o !== void 0 && (s.morphTargetInfluences[o] = a * t);+ }+ }+ }), this.viewer.invalidate());+ }+ // --- Movement ---+ moveTo(e, { duration: t = 600 } = {}) {+ if (!this.viewer.content) return;+ this._moveToHook && (this._removeHook(this._moveToHook), this._moveToHook = null);+ const n = this.viewer.content.position.clone(), s = new H(e.x || 0, e.y || n.y, e.z || 0), r = performance.now(), a = (o) => {+ const c = performance.now() - r, l = Math.min(c / t, 1), h = l < 0.5 ? 2 * l * l : 1 - Math.pow(-2 * l + 2, 2) / 2;+ this.viewer.content.position.lerpVectors(n, s, h), this.viewer.invalidate(), l >= 1 && (this._removeHook(a), this._moveToHook = null);+ };+ this._moveToHook = a, this._addHook(a);+ }+ // --- Per-frame hooks (uses Viewer._afterAnimateHooks extension point) ---+ _addHook(e) {+ this.viewer._afterAnimateHooks || (this.viewer._afterAnimateHooks = []), this.viewer._afterAnimateHooks.push(e), this.viewer._animating = !0, this.viewer.invalidate();+ }+ _removeHook(e) {+ const t = this.viewer._afterAnimateHooks;+ if (!t) return;+ const n = t.indexOf(e);+ n >= 0 && t.splice(n, 1);+ }+ // --- Helpers ---+ _findClip(e) {+ if (!this.clips.length) return null;+ const t = this.clips.find((s) => s.name === e);+ if (t) return t;+ const n = e.toLowerCase();+ return this.clips.find((s) => s.name.toLowerCase() === n) || this.clips.find((s) => s.name.toLowerCase().includes(n));+ }+}+const FT = `// Sandbox worker — executes skill handlers in an isolated Web Worker scope.+// No DOM, no window, no document. Only ctx.* and native worker APIs.++/** @type {Map<string, object>} skillURI → module exports */+const _skillHandlers = new Map();++/** @type {Map<number, { resolve: Function, reject: Function, timeoutId: number }>} */+const _pendingRequests = new Map();++/** @type {Map<string, Promise<void>>} skillURI → install promise (deduplication) */+const _installPromises = new Map();++/** @type {Map<string, { resolve: Function, reject: Function }>} */+const _installCallbacks = new Map();++let _requestId = 0;++self.onmessage = ({ data }) => {+ switch (data.type) {+ case 'install':+ _install(data);+ break;+ case 'invoke':+ _invoke(data);+ break;+ case 'response':+ _handleResponse(data);+ break;+ }+};++async function _install({ skillURI, handlersSrc }) {+ // Deduplicate concurrent install requests for the same skill+ if (_installPromises.has(skillURI)) return;++ const promise = new Promise((resolve, reject) => {+ _installCallbacks.set(skillURI, { resolve, reject });+ });+ _installPromises.set(skillURI, promise);++ let url;+ try {+ const blob = new Blob([handlersSrc], { type: 'text/javascript' });+ url = URL.createObjectURL(blob);+ // Dynamic import from blob URL — works in module workers+ const mod = await import(/* @vite-ignore */ url);+ _skillHandlers.set(skillURI, mod);+ _installCallbacks.get(skillURI)?.resolve();+ self.postMessage({ type: 'install-ack', skillURI, ok: true });+ } catch (err) {+ _installPromises.delete(skillURI);+ _installCallbacks.get(skillURI)?.reject(err);+ _installCallbacks.delete(skillURI);+ self.postMessage({ type: 'install-ack', skillURI, ok: false, error: err.message });+ } finally {+ if (url) URL.revokeObjectURL(url);+ }+}++function _makeCtx(invocationId, skillBaseURI) {+ // Each method sends a request to main thread and awaits a structured-cloneable response.+ // Non-serializable objects (AnimationClip, GLTF) are stored in the host's handle registry+ // and represented here as opaque "@h:N" strings.+ const proxy = (method, args) =>+ new Promise((resolve, reject) => {+ const id = ++_requestId;+ const timeoutId = setTimeout(() => {+ _pendingRequests.delete(id);+ reject(new Error(\`ctx.\${method} timed out after 30s\`));+ }, 30_000);+ _pendingRequests.set(id, { resolve, reject, timeoutId });+ self.postMessage({ type: 'request', invocationId, requestId: id, method, args });+ });++ return {+ viewer: {+ play: (clip, opts) => proxy('viewer.play', [clip, opts]),+ stop: (clipName) => proxy('viewer.stop', [clipName]),+ setExpression: (preset, intensity) =>+ proxy('viewer.setExpression', [preset, intensity]),+ lookAt: (target) => proxy('viewer.lookAt', [target]),+ moveTo: (position, opts) => proxy('viewer.moveTo', [position, opts]),+ playAnimationByHint: (hint, opts) => proxy('viewer.playAnimationByHint', [hint, opts]),+ playClipByName: (name, opts) => proxy('viewer.playClipByName', [name, opts]),+ },+ llm: {+ complete: (prompt, opts) => proxy('llm.complete', [prompt, opts]),+ embed: (text) => proxy('llm.embed', [text]),+ },+ memory: {+ read: (key) => proxy('memory.read', [key]),+ write: (key, value) => proxy('memory.write', [key, value]),+ note: (type, data) => proxy('memory.note', [type, data]),+ recall: (query) => proxy('memory.recall', [query]),+ },+ // Asset loading — results are opaque handle strings; pass back to viewer.play etc.+ loadClip: (uri) => proxy('loadClip', [uri]),+ loadGLB: (uri) => proxy('loadGLB', [uri]),+ // fetch and loadJSON use native worker fetch — no proxy needed+ fetch: (uri, opts) => fetch(uri, opts),+ loadJSON: async (uri) => (await fetch(uri)).json(),+ call: (toolName, toolArgs) => proxy('call', [toolName, toolArgs]),+ speak: (text) => proxy('speak', [text]),+ listen: (opts) => proxy('listen', [opts]),+ skillBaseURI,+ };+}++async function _invoke({ invocationId, skillURI, toolName, args, skillBaseURI }) {+ // Wait for install to complete (handles the install→invoke race)+ const installPromise = _installPromises.get(skillURI);+ if (installPromise) {+ try {+ await installPromise;+ } catch (err) {+ self.postMessage({+ type: 'invoke-result',+ invocationId,+ error: \`Install failed: \${err.message}\`,+ });+ return;+ }+ }++ const mod = _skillHandlers.get(skillURI);+ if (!mod) {+ self.postMessage({+ type: 'invoke-result',+ invocationId,+ error: \`Skill not installed: \${skillURI}\`,+ });+ return;+ }++ const fn = mod[toolName];+ if (typeof fn !== 'function') {+ self.postMessage({+ type: 'invoke-result',+ invocationId,+ error: \`No handler "\${toolName}" in skill "\${skillURI}"\`,+ });+ return;+ }++ try {+ const ctx = _makeCtx(invocationId, skillBaseURI);+ const result = await fn(args, ctx);+ self.postMessage({ type: 'invoke-result', invocationId, result: result ?? null });+ } catch (err) {+ self.postMessage({+ type: 'invoke-result',+ invocationId,+ error: err.message || String(err),+ });+ }+}++function _handleResponse({ requestId, result, error }) {+ const pending = _pendingRequests.get(requestId);+ if (!pending) return;+ clearTimeout(pending.timeoutId);+ _pendingRequests.delete(requestId);+ if (error !== undefined) {+ pending.reject(new Error(error));+ } else {+ pending.resolve(result);+ }+}+`;+let ni = null, ma = null;+const ba = /* @__PURE__ */ new Map(), Go = /* @__PURE__ */ new Map(), ks = /* @__PURE__ */ new Map(), ih = /* @__PURE__ */ new Map();+let DT = 0, LT = 0;+function yg(i) {+ if (i == null) return null;+ const e = `@h:${++DT}`;+ return ih.set(e, i), e;+}+function PT(i) {+ return typeof i == "string" && i.startsWith("@h:") ? ih.get(i) ?? i : i;+}+function kT(i) {+ return Array.isArray(i) ? i.map(PT) : i;+}+function pb() {+ if (!ni) {+ if (!ma) {+ const i = new Blob([FT], { type: "text/javascript" });+ ma = URL.createObjectURL(i);+ }+ ni = new Worker(ma), ni.onmessage = OT, ni.onerror = UT;+ }+ return ni;+}+function UT(i) {+ console.error("[sandbox] worker crashed:", i), ni = null, ba.clear(), Go.clear(), ih.clear();+ for (const [, e] of ks) e.reject(new Error("Sandbox worker crashed"));+ ks.clear();+}+function OT({ data: i }) {+ switch (i.type) {+ case "install-ack": {+ const e = Go.get(i.skillURI);+ Go.delete(i.skillURI), i.ok ? e?.resolve() : (ba.delete(i.skillURI), e?.reject(new Error(i.error || "Install failed")));+ break;+ }+ case "request": {+ const { invocationId: e, requestId: t, method: n, args: s } = i, r = ks.get(e);+ if (!r) {+ ni?.postMessage({+ type: "response",+ requestId: t,+ error: "No active invocation"+ });+ return;+ }+ QT(n, s, r.mainCtx).then(+ (a) => ni?.postMessage({ type: "response", requestId: t, result: a ?? null }),+ (a) => ni?.postMessage({+ type: "response",+ requestId: t,+ error: a.message || String(a)+ })+ );+ break;+ }+ case "invoke-result": {+ const { invocationId: e, result: t, error: n } = i, s = ks.get(e);+ if (!s) return;+ ks.delete(e), n !== void 0 ? s.reject(new Error(n)) : s.resolve(t);+ break;+ }+ }+}+async function QT(i, e, t) {+ const n = kT(e);+ switch (i) {+ // viewer+ case "viewer.play":+ return t.viewer?.play?.(n[0], n[1]);+ case "viewer.stop":+ return t.viewer?.stop?.(n[0]);+ case "viewer.setExpression":+ return t.viewer?.setExpression?.(n[0], n[1]);+ case "viewer.lookAt":+ return t.viewer?.lookAt?.(n[0]);+ case "viewer.moveTo":+ return t.viewer?.moveTo?.(n[0], n[1]);+ case "viewer.playAnimationByHint":+ return t.viewer?.playAnimationByHint?.(n[0], n[1]);+ case "viewer.playClipByName":+ return t.viewer?.playClipByName?.(n[0], n[1]);+ // memory+ case "memory.read":+ return t.memory?.read?.(n[0]);+ case "memory.write":+ return t.memory?.write?.(n[0], n[1]);+ case "memory.note":+ return t.memory?.note?.(n[0], n[1]);+ case "memory.recall":+ return t.memory?.recall?.(n[0]);+ // llm+ case "llm.complete":+ return t.llm?.complete?.(n[0], n[1]);+ case "llm.embed":+ return t.llm?.embed?.(n[0]);+ // asset loading — results stored as handles because they're non-serializable+ case "loadClip": {+ const s = await t.loadClip?.(n[0]);+ return yg(s);+ }+ case "loadGLB": {+ const s = await t.loadGLB?.(n[0]);+ return yg(s);+ }+ // speech+ case "speak":+ return t.speak?.(n[0]);+ case "listen":+ return t.listen?.(n[0]);+ // cross-skill call+ case "call":+ return t.call?.(n[0], n[1]);+ default:+ throw new Error(`Unknown ctx method: ${i}`);+ }+}+async function GT(i, e) {+ if (ba.has(i)) return ba.get(i);+ const t = new Promise((n, s) => {+ Go.set(i, { resolve: n, reject: s });+ });+ return ba.set(i, t), pb().postMessage({ type: "install", skillURI: i, handlersSrc: e }), t;+}+async function HT(i, e, t, n, s) {+ await GT(i, n);+ const r = ++LT, a = pb();+ return new Promise((o, c) => {+ ks.set(r, { resolve: o, reject: c, mainCtx: s }), a.postMessage({+ type: "invoke",+ invocationId: r,+ skillURI: i,+ toolName: e,+ args: t,+ skillBaseURI: s.skillBaseURI || i+ });+ });+}+function zT() {+ if (ni) {+ ni.terminate(), ni = null, ma && (URL.revokeObjectURL(ma), ma = null), ba.clear(), Go.clear(), ih.clear();+ for (const [, i] of ks) i.reject(new Error("Sandbox terminated"));+ ks.clear();+ }+}+function VT() {+ return { invoke: HT, terminate: zT };+}+function WT(i, e) {+ return /^([a-z]+:|\/)/i.test(e) ? e : (i.endsWith("/") || (i += "/"), i + e);+}+class qT {+ constructor({ uri: e, manifest: t, instructions: n, tools: s, handlers: r, handlersSrc: a }) {+ this.uri = e, this.manifest = t, this.name = t.name, this.version = t.version, this.instructions = n, this.tools = s || [], this.handlers = r || {}, this.handlersSrc = a || null;+ }+ async invoke(e, t, n) {+ const s = { ...n, skillBaseURI: this.uri };+ if (this.manifest.sandboxPolicy === "trusted-main-thread") {+ const r = this.handlers[e];+ if (!r)+ throw new Error(`Skill "${this.name}" has no handler for tool "${e}"`);+ return r(t, s);+ }+ if (!this.handlersSrc)+ throw new Error(`Skill "${this.name}" has no handler source for tool "${e}"`);+ return VT().invoke(this.uri, e, t, this.handlersSrc, s);+ }+ systemPromptFragment() {+ return this.instructions ? `++<skill name="${this.name}" version="${this.version}">+${this.instructions}+</skill>` : "";+ }+}+class KT {+ constructor({ fetchFn: e = fetch.bind(globalThis), trust: t = "owned-only", ownerAddress: n } = {}) {+ this.fetchFn = e, this.trust = t, this.ownerAddress = n?.toLowerCase(), this.skills = /* @__PURE__ */ new Map();+ }+ async install(e, { bundleBase: t } = {}) {+ const n = this._resolveBundleURI(e.uri, t);+ if (this.skills.has(n)) return this.skills.get(n);+ const s = await this._fetchJSON(`${n}manifest.json`);+ this._enforceTrust(s);+ const r = s.sandboxPolicy === "trusted-main-thread", [a, o, c] = await Promise.all([+ this._fetchText(`${n}SKILL.md`).catch(() => ""),+ this._fetchJSON(`${n}tools.json`).catch(() => ({ tools: [] })),+ r ? this._fetchHandlers(`${n}handlers.js`).catch(() => null) : this._fetchHandlersSrc(`${n}handlers.js`).catch(() => null)+ ]), l = new qT({+ uri: n,+ manifest: s,+ instructions: a,+ tools: o.tools || [],+ handlers: r ? c || {} : {},+ handlersSrc: r ? null : c+ });+ if (s.dependencies)+ for (const [h, u] of Object.entries(s.dependencies))+ await this.install({ uri: h, version: u });+ return this.skills.set(n, l), l;+ }+ uninstall(e) {+ for (const [t, n] of this.skills)+ if (n.name === e)+ return this.skills.delete(t), !0;+ return !1;+ }+ all() {+ return Array.from(this.skills.values());+ }+ allTools() {+ const e = /* @__PURE__ */ new Map();+ for (const t of this.skills.values())+ for (const n of t.tools)+ e.has(n.name) && console.warn(+ `[skills] tool "${n.name}" overridden by skill "${t.name}"`+ ), e.set(n.name, { ...n, _skill: t.name });+ return Array.from(e.values());+ }+ findSkillForTool(e) {+ for (const t of this.skills.values())+ if (t.tools.some((n) => n.name === e)) return t;+ return null;+ }+ systemPrompt() {+ return this.all().map((e) => e.systemPromptFragment()).join("");+ }+ _resolveBundleURI(e, t) {+ let n = e;+ return !/^([a-z]+:|\/)/i.test(e) && t && (n = WT(t, e)), n.endsWith("/") || (n += "/"), (n.startsWith("ipfs://") || n.startsWith("ar://")) && (n = Gs(n)), n;+ }+ async _fetchJSON(e) {+ const t = await this.fetchFn(e);+ if (!t.ok) throw new Error(`Fetch failed: ${e} (${t.status})`);+ return t.json();+ }+ async _fetchText(e) {+ const t = await this.fetchFn(e);+ if (!t.ok) throw new Error(`Fetch failed: ${e} (${t.status})`);+ return t.text();+ }+ async _fetchHandlers(e) {+ try {+ return await import(+ /* @vite-ignore */+ e+ );+ } catch (t) {+ return console.warn(`[skills] handlers load failed: ${e}`, t), null;+ }+ }+ async _fetchHandlersSrc(e) {+ const t = await this.fetchFn(e);+ if (!t.ok) throw new Error(`Fetch failed: ${e} (${t.status})`);+ return t.text();+ }+ _enforceTrust(e) {+ if (this.trust !== "any") {+ if (this.trust === "owned-only") {+ const t = (e.author || "").toLowerCase();+ if (t && this.ownerAddress && t !== this.ownerAddress)+ throw new Error(+ `Skill "${e.name}" author ${t} not trusted under owned-only policy`+ );+ }+ this.trust;+ }+ }+}+const jT = /^---\n([\s\S]*?)\n---\n?([\s\S]*)$/;+function $c(i) {+ const e = i.match(jT);+ if (!e) return { meta: {}, body: i };+ const t = {};+ for (const n of e[1].split(`+`)) {+ const [s, ...r] = n.split(":");+ s && (t[s.trim()] = r.join(":").trim());+ }+ return { meta: t, body: e[2] };+}+function XT(i, e) {+ const t = ["---"];+ for (const [n, s] of Object.entries(i)) t.push(`${n}: ${s}`);+ return t.push("---", "", e), t.join(`+`);+}+class Ti {+ constructor({ mode: e = "local", namespace: t, index: n = {}, files: s = {}, timeline: r = [] } = {}) {+ this.mode = e, this.namespace = t, this.files = new Map(Object.entries(s)), this.timeline = r, this.indexText = n.text || "", this._dirty = !1;+ }+ static async load({ mode: e = "local", namespace: t, manifestURI: n, fetchFn: s }) {+ if (e === "none") return new Ti({ mode: "none", namespace: t });+ if (e === "local") return Ti._loadLocal(t);+ if (e === "ipfs" || e === "encrypted-ipfs")+ return Ti._loadIPFS({ mode: e, namespace: t, manifestURI: n, fetchFn: s });+ throw new Error(`Unknown memory mode: ${e}`);+ }+ static _loadLocal(e) {+ const t = `agent:${e}:memory`;+ try {+ const n = localStorage.getItem(t);+ if (!n) return new Ti({ mode: "local", namespace: e });+ const s = JSON.parse(n);+ return new Ti({ mode: "local", namespace: e, ...s });+ } catch {+ return new Ti({ mode: "local", namespace: e });+ }+ }+ static async _loadIPFS({ mode: e, namespace: t, manifestURI: n, fetchFn: s }) {+ const r = n.replace(/manifest\.json$/, "");+ try {+ const a = await s(`${r}memory/MEMORY.md`), o = a.ok ? await a.text() : "", c = {}, l = /\[([^\]]+)\]\(([^)]+\.md)\)/g;+ let h;+ for (; h = l.exec(o); ) {+ const u = h[2];+ try {+ const d = await s(`${r}memory/${u}`);+ d.ok && (c[u] = await d.text());+ } catch {+ }+ }+ return new Ti({ mode: e, namespace: t, index: { text: o }, files: c });+ } catch {+ return new Ti({ mode: e, namespace: t });+ }+ }+ read(e) {+ const t = e.endsWith(".md") ? e : `${e}.md`, n = this.files.get(t);+ return n ? $c(n) : null;+ }+ write(e, { name: t, description: n, type: s, body: r, decay: a }) {+ const o = e.endsWith(".md") ? e : `${e}.md`, c = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10), l = this.files.get(o), h = l && $c(l).meta.created || c, u = { name: t, description: n, type: s, created: h, updated: c };+ a && (u.decay = a), this.files.set(o, XT(u, r || "")), this._rebuildIndex(), this._dirty = !0, this._persist();+ }+ note(e, t) {+ const n = { ts: (/* @__PURE__ */ new Date()).toISOString(), type: e, ...t };+ this.timeline.push(n), this.timeline.length > 1e3 && (this.timeline = this.timeline.slice(-1e3)), this._dirty = !0, this._persist();+ }+ async recall(e, { limit: t = 5 } = {}) {+ const n = e.toLowerCase(), s = [];+ for (const [r, a] of this.files) {+ const { meta: o, body: c } = $c(a), l = `${o.name || ""} ${o.description || ""} ${c}`.toLowerCase();+ l.includes(n) && s.push({ file: r, meta: o, body: c, score: l.split(n).length - 1 });+ }+ return s.sort((r, a) => a.score - r.score).slice(0, t);+ }+ _rebuildIndex() {+ const e = { user: [], feedback: [], project: [], reference: [] };+ for (const [s, r] of this.files) {+ const { meta: a } = $c(r), o = a.type || "user";+ e[o] || (e[o] = []), e[o].push({ file: s, name: a.name || s, description: a.description || "" });+ }+ const t = ["# Memory", ""], n = {+ user: "## User",+ feedback: "## Feedback",+ project: "## Project",+ reference: "## Reference"+ };+ for (const [s, r] of Object.entries(e))+ if (r.length) {+ t.push(n[s] || `## ${s}`);+ for (const a of r) t.push(`- [${a.name}](${a.file}) — ${a.description}`);+ t.push("");+ }+ this.indexText = t.join(`+`);+ }+ _persist() {+ if (this.mode !== "local" || !this.namespace) return;+ const e = `agent:${this.namespace}:memory`, t = {+ index: { text: this.indexText },+ files: Object.fromEntries(this.files),+ timeline: this.timeline.slice(-200)+ // persist only recent timeline+ };+ try {+ localStorage.setItem(e, JSON.stringify(t));+ } catch (n) {+ console.warn("[memory] persist failed", n);+ }+ }+ // Budget-aware context serialization for LLM injection+ contextBlock({ maxTokens: e = 8192 } = {}) {+ const t = e * 4, n = ["# Agent Memory", "", this.indexText];+ let s = n.join(`+`).length;+ for (const [r, a] of this.files) {+ if (s + a.length > t) break;+ n.push("", `## ${r}`, a), s += a.length;+ }+ if (this.timeline.length) {+ const a = this.timeline.slice(-20).map((o) => JSON.stringify(o)).join(`+`);+ s + a.length < t && n.push("", "## Recent timeline", "```", a, "```");+ }+ return n.join(`+`);+ }+ async export() {+ return {+ version: "memory/0.1",+ index: this.indexText,+ files: Object.fromEntries(this.files),+ timeline: this.timeline+ };+ }+ async import(e, { strategy: t = "merge" } = {}) {+ if (t === "replace")+ this.files = new Map(Object.entries(e.files || {})), this.timeline = e.timeline || [];+ else {+ for (const [n, s] of Object.entries(e.files || {}))+ this.files.has(n) || this.files.set(n, s);+ this.timeline = [...this.timeline, ...e.timeline || []].slice(-1e3);+ }+ this._rebuildIndex(), this._persist();+ }+}+const YT = "6.16.0";+function JT(i, e, t) {+ const n = e.split("|").map((r) => r.trim());+ for (let r = 0; r < n.length; r++)+ switch (e) {+ case "any":+ return;+ case "bigint":+ case "boolean":+ case "number":+ case "string":+ if (typeof i === e)+ return;+ }+ const s = new Error(`invalid value for type ${e}`);+ throw s.code = "INVALID_ARGUMENT", s.argument = `value.${t}`, s.value = i, s;+}+async function Tn(i) {+ const e = Object.keys(i);+ return (await Promise.all(e.map((n) => Promise.resolve(i[n])))).reduce((n, s, r) => (n[e[r]] = s, n), {});+}+function Xe(i, e, t) {+ for (let n in e) {+ let s = e[n];+ const r = t ? t[n] : null;+ r && JT(s, r, n), Object.defineProperty(i, n, { enumerable: !0, value: s, writable: !1 });+ }+}+function ha(i, e) {+ if (i == null)+ return "null";+ if (e == null && (e = /* @__PURE__ */ new Set()), typeof i == "object") {+ if (e.has(i))+ return "[Circular]";+ e.add(i);+ }+ if (Array.isArray(i))+ return "[ " + i.map((t) => ha(t, e)).join(", ") + " ]";+ if (i instanceof Uint8Array) {+ const t = "0123456789abcdef";+ let n = "0x";+ for (let s = 0; s < i.length; s++)+ n += t[i[s] >> 4], n += t[i[s] & 15];+ return n;+ }+ if (typeof i == "object" && typeof i.toJSON == "function")+ return ha(i.toJSON(), e);+ switch (typeof i) {+ case "boolean":+ case "number":+ case "symbol":+ return i.toString();+ case "bigint":+ return BigInt(i).toString();+ case "string":+ return JSON.stringify(i);+ case "object": {+ const t = Object.keys(i);+ return t.sort(), "{ " + t.map((n) => `${ha(n, e)}: ${ha(i[n], e)}`).join(", ") + " }";+ }+ }+ return "[ COULD NOT SERIALIZE ]";+}+function _n(i, e) {+ return i && i.code === e;+}+function zf(i) {+ return _n(i, "CALL_EXCEPTION");+}+function Ot(i, e, t) {+ let n = i;+ {+ const r = [];+ if (t) {+ if ("message" in t || "code" in t || "name" in t)+ throw new Error(`value will overwrite populated values: ${ha(t)}`);+ for (const a in t) {+ if (a === "shortMessage")+ continue;+ const o = t[a];+ r.push(a + "=" + ha(o));+ }+ }+ r.push(`code=${e}`), r.push(`version=${YT}`), r.length && (i += " (" + r.join(", ") + ")");+ }+ let s;+ switch (e) {+ case "INVALID_ARGUMENT":+ s = new TypeError(i);+ break;+ case "NUMERIC_FAULT":+ case "BUFFER_OVERRUN":+ s = new RangeError(i);+ break;+ default:+ s = new Error(i);+ }+ return Xe(s, { code: e }), t && Object.assign(s, t), s.shortMessage == null && Xe(s, { shortMessage: n }), s;+}+function ge(i, e, t, n) {+ if (!i)+ throw Ot(e, t, n);+}+function V(i, e, t, n) {+ ge(i, e, "INVALID_ARGUMENT", { argument: t, value: n });+}+function Ab(i, e, t) {+ t == null && (t = ""), t && (t = ": " + t), ge(i >= e, "missing argument" + t, "MISSING_ARGUMENT", {+ count: i,+ expectedCount: e+ }), ge(i <= e, "too many arguments" + t, "UNEXPECTED_ARGUMENT", {+ count: i,+ expectedCount: e+ });+}+["NFD", "NFC", "NFKD", "NFKC"].reduce((i, e) => {+ try {+ if ("test".normalize(e) !== "test")+ throw new Error("bad");+ if (e === "NFD" && "é".normalize("NFD") !== "é")+ throw new Error("broken");+ i.push(e);+ } catch {+ }+ return i;+}, []);+function sh(i, e, t) {+ if (t == null && (t = ""), i !== e) {+ let n = t, s = "new";+ t && (n += ".", s += " " + t), ge(!1, `private constructor; use ${n}from* methods`, "UNSUPPORTED_OPERATION", {+ operation: s+ });+ }+}+function gb(i, e, t) {+ if (i instanceof Uint8Array)+ return t ? new Uint8Array(i) : i;+ if (typeof i == "string" && i.length % 2 === 0 && i.match(/^0x[0-9a-f]*$/i)) {+ const n = new Uint8Array((i.length - 2) / 2);+ let s = 2;+ for (let r = 0; r < n.length; r++)+ n[r] = parseInt(i.substring(s, s + 2), 16), s += 2;+ return n;+ }+ V(!1, "invalid BytesLike value", e || "value", i);+}+function ht(i, e) {+ return gb(i, e, !1);+}+function Rn(i, e) {+ return gb(i, e, !0);+}+function Lt(i, e) {+ return !(typeof i != "string" || !i.match(/^0x[0-9A-Fa-f]*$/) || typeof e == "number" && i.length !== 2 + 2 * e || e === !0 && i.length % 2 !== 0);+}+function Vf(i) {+ return Lt(i, !0) || i instanceof Uint8Array;+}+const wg = "0123456789abcdef";+function Se(i) {+ const e = ht(i);+ let t = "0x";+ for (let n = 0; n < e.length; n++) {+ const s = e[n];+ t += wg[(s & 240) >> 4] + wg[s & 15];+ }+ return t;+}+function Qt(i) {+ return "0x" + i.map((e) => Se(e).substring(2)).join("");+}+function xa(i) {+ return Lt(i, !0) ? (i.length - 2) / 2 : ht(i).length;+}+function Vt(i, e, t) {+ const n = ht(i);+ return t != null && t > n.length && ge(!1, "cannot slice beyond data bounds", "BUFFER_OVERRUN", {+ buffer: n,+ length: n.length,+ offset: t+ }), Se(n.slice(e ?? 0, t ?? n.length));+}+function mb(i, e, t) {+ const n = ht(i);+ ge(e >= n.length, "padding exceeds data length", "BUFFER_OVERRUN", {+ buffer: new Uint8Array(n),+ length: e,+ offset: e + 1+ });+ const s = new Uint8Array(e);+ return s.fill(0), t ? s.set(n, e - n.length) : s.set(n, 0), Se(s);+}+function ds(i, e) {+ return mb(i, e, !0);+}+function ZT(i, e) {+ return mb(i, e, !1);+}+const nc = BigInt(0), xi = BigInt(1), ua = 9007199254740991;+function $T(i, e) {+ const t = rh(i, "value"), n = BigInt(ut(e, "width"));+ if (ge(t >> n === nc, "overflow", "NUMERIC_FAULT", {+ operation: "fromTwos",+ fault: "overflow",+ value: i+ }), t >> n - xi) {+ const s = (xi << n) - xi;+ return -((~t & s) + xi);+ }+ return t;+}+function bb(i, e) {+ let t = Fe(i, "value");+ const n = BigInt(ut(e, "width")), s = xi << n - xi;+ if (t < nc) {+ t = -t, ge(t <= s, "too low", "NUMERIC_FAULT", {+ operation: "toTwos",+ fault: "overflow",+ value: i+ });+ const r = (xi << n) - xi;+ return (~t & r) + xi;+ } else+ ge(t < s, "too high", "NUMERIC_FAULT", {+ operation: "toTwos",+ fault: "overflow",+ value: i+ });+ return t;+}+function go(i, e) {+ const t = rh(i, "value"), n = BigInt(ut(e, "bits"));+ return t & (xi << n) - xi;+}+function Fe(i, e) {+ switch (typeof i) {+ case "bigint":+ return i;+ case "number":+ return V(Number.isInteger(i), "underflow", e || "value", i), V(i >= -ua && i <= ua, "overflow", e || "value", i), BigInt(i);+ case "string":+ try {+ if (i === "")+ throw new Error("empty string");+ return i[0] === "-" && i[1] !== "-" ? -BigInt(i.substring(1)) : BigInt(i);+ } catch (t) {+ V(!1, `invalid BigNumberish string: ${t.message}`, e || "value", i);+ }+ }+ V(!1, "invalid BigNumberish value", e || "value", i);+}+function rh(i, e) {+ const t = Fe(i, e);+ return ge(t >= nc, "unsigned value cannot be negative", "NUMERIC_FAULT", {+ fault: "overflow",+ operation: "getUint",+ value: i+ }), t;+}+const vg = "0123456789abcdef";+function Wf(i) {+ if (i instanceof Uint8Array) {+ let e = "0x0";+ for (const t of i)+ e += vg[t >> 4], e += vg[t & 15];+ return BigInt(e);+ }+ return Fe(i);+}+function ut(i, e) {+ switch (typeof i) {+ case "bigint":+ return V(i >= -ua && i <= ua, "overflow", e || "value", i), Number(i);+ case "number":+ return V(Number.isInteger(i), "underflow", e || "value", i), V(i >= -ua && i <= ua, "overflow", e || "value", i), i;+ case "string":+ try {+ if (i === "")+ throw new Error("empty string");+ return ut(BigInt(i), e);+ } catch (t) {+ V(!1, `invalid numeric string: ${t.message}`, e || "value", i);+ }+ }+ V(!1, "invalid numeric value", e || "value", i);+}+function eR(i) {+ return ut(Wf(i));+}+function Hs(i, e) {+ const t = rh(i, "value");+ let n = t.toString(16);+ if (e == null)+ n.length % 2 && (n = "0" + n);+ else {+ const s = ut(e, "width");+ if (s === 0 && t === nc)+ return "0x";+ for (ge(s * 2 >= n.length, `value exceeds width (${s} bytes)`, "NUMERIC_FAULT", {+ operation: "toBeHex",+ fault: "overflow",+ value: i+ }); n.length < s * 2; )+ n = "0" + n;+ }+ return "0x" + n;+}+function $t(i, e) {+ const t = rh(i, "value");+ if (t === nc)+ return new Uint8Array(0);+ let n = t.toString(16);+ n.length % 2 && (n = "0" + n);+ const s = new Uint8Array(n.length / 2);+ for (let r = 0; r < s.length; r++) {+ const a = r * 2;+ s[r] = parseInt(n.substring(a, a + 2), 16);+ }+ return s;+}+function Ai(i) {+ let e = Se(Vf(i) ? i : $t(i)).substring(2);+ for (; e.startsWith("0"); )+ e = e.substring(1);+ return e === "" && (e = "0"), "0x" + e;+}+const Cg = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";+BigInt(0);+const Sg = BigInt(58);+function tR(i) {+ const e = ht(i);+ let t = Wf(e), n = "";+ for (; t; )+ n = Cg[Number(t % Sg)] + n, t /= Sg;+ for (let s = 0; s < e.length && !e[s]; s++)+ n = Cg[0] + n;+ return n;+}+function nR(i) {+ i = atob(i);+ const e = new Uint8Array(i.length);+ for (let t = 0; t < i.length; t++)+ e[t] = i.charCodeAt(t);+ return ht(e);+}+function iR(i) {+ const e = ht(i);+ let t = "";+ for (let n = 0; n < e.length; n++)+ t += String.fromCharCode(e[n]);+ return btoa(t);+}+class xb {+ /**+ * The event filter.+ */+ filter;+ /**+ * The **EventEmitterable**.+ */+ emitter;+ #e;+ /**+ * Create a new **EventPayload** for %%emitter%% with+ * the %%listener%% and for %%filter%%.+ */+ constructor(e, t, n) {+ this.#e = t, Xe(this, { emitter: e, filter: n });+ }+ /**+ * Unregister the triggered listener for future events.+ */+ async removeListener() {+ this.#e != null && await this.emitter.off(this.filter, this.#e);+ }+}+function sR(i, e, t, n, s) {+ V(!1, `invalid codepoint at offset ${e}; ${i}`, "bytes", t);+}+function _b(i, e, t, n, s) {+ if (i === "BAD_PREFIX" || i === "UNEXPECTED_CONTINUE") {+ let r = 0;+ for (let a = e + 1; a < t.length && t[a] >> 6 === 2; a++)+ r++;+ return r;+ }+ return i === "OVERRUN" ? t.length - e - 1 : 0;+}+function rR(i, e, t, n, s) {+ return i === "OVERLONG" ? (V(typeof s == "number", "invalid bad code point for replacement", "badCodepoint", s), n.push(s), 0) : (n.push(65533), _b(i, e, t));+}+const aR = Object.freeze({+ error: sR,+ ignore: _b,+ replace: rR+});+function oR(i, e) {+ e == null && (e = aR.error);+ const t = ht(i, "bytes"), n = [];+ let s = 0;+ for (; s < t.length; ) {+ const r = t[s++];+ if (r >> 7 === 0) {+ n.push(r);+ continue;+ }+ let a = null, o = null;+ if ((r & 224) === 192)+ a = 1, o = 127;+ else if ((r & 240) === 224)+ a = 2, o = 2047;+ else if ((r & 248) === 240)+ a = 3, o = 65535;+ else {+ (r & 192) === 128 ? s += e("UNEXPECTED_CONTINUE", s - 1, t, n) : s += e("BAD_PREFIX", s - 1, t, n);+ continue;+ }+ if (s - 1 + a >= t.length) {+ s += e("OVERRUN", s - 1, t, n);+ continue;+ }+ let c = r & (1 << 8 - a - 1) - 1;+ for (let l = 0; l < a; l++) {+ let h = t[s];+ if ((h & 192) != 128) {+ s += e("MISSING_CONTINUE", s, t, n), c = null;+ break;+ }+ c = c << 6 | h & 63, s++;+ }+ if (c !== null) {+ if (c > 1114111) {+ s += e("OUT_OF_RANGE", s - 1 - a, t, n, c);+ continue;+ }+ if (c >= 55296 && c <= 57343) {+ s += e("UTF16_SURROGATE", s - 1 - a, t, n, c);+ continue;+ }+ if (c <= o) {+ s += e("OVERLONG", s - 1 - a, t, n, c);+ continue;+ }+ n.push(c);+ }+ }+ return n;+}+function cs(i, e) {+ V(typeof i == "string", "invalid string value", "str", i);+ let t = [];+ for (let n = 0; n < i.length; n++) {+ const s = i.charCodeAt(n);+ if (s < 128)+ t.push(s);+ else if (s < 2048)+ t.push(s >> 6 | 192), t.push(s & 63 | 128);+ else if ((s & 64512) == 55296) {+ n++;+ const r = i.charCodeAt(n);+ V(n < i.length && (r & 64512) === 56320, "invalid surrogate pair", "str", i);+ const a = 65536 + ((s & 1023) << 10) + (r & 1023);+ t.push(a >> 18 | 240), t.push(a >> 12 & 63 | 128), t.push(a >> 6 & 63 | 128), t.push(a & 63 | 128);+ } else+ t.push(s >> 12 | 224), t.push(s >> 6 & 63 | 128), t.push(s & 63 | 128);+ }+ return new Uint8Array(t);+}+function cR(i) {+ return i.map((e) => e <= 65535 ? String.fromCharCode(e) : (e -= 65536, String.fromCharCode((e >> 10 & 1023) + 55296, (e & 1023) + 56320))).join("");+}+function Ol(i, e) {+ return cR(oR(i, e));+}+function Eb(i) {+ async function e(t, n) {+ ge(n == null || !n.cancelled, "request cancelled before sending", "CANCELLED");+ const s = t.url.split(":")[0].toLowerCase();+ ge(s === "http" || s === "https", `unsupported protocol ${s}`, "UNSUPPORTED_OPERATION", {+ info: { protocol: s },+ operation: "request"+ }), ge(s === "https" || !t.credentials || t.allowInsecureAuthentication, "insecure authorized connections unsupported", "UNSUPPORTED_OPERATION", {+ operation: "request"+ });+ let r = null;+ const a = new AbortController(), o = setTimeout(() => {+ r = Ot("request timeout", "TIMEOUT"), a.abort();+ }, t.timeout);+ n && n.addListener(() => {+ r = Ot("request cancelled", "CANCELLED"), a.abort();+ });+ const c = Object.assign({}, i, {+ method: t.method,+ headers: new Headers(Array.from(t)),+ body: t.body || void 0,+ signal: a.signal+ });+ let l;+ try {+ l = await fetch(t.url, c);+ } catch (f) {+ throw clearTimeout(o), r || f;+ }+ clearTimeout(o);+ const h = {};+ l.headers.forEach((f, m) => {+ h[m.toLowerCase()] = f;+ });+ const u = await l.arrayBuffer(), d = u == null ? null : new Uint8Array(u);+ return {+ statusCode: l.status,+ statusMessage: l.statusText,+ headers: h,+ body: d+ };+ }+ return e;+}+const lR = 12, hR = 250;+let Ig = Eb();+const uR = new RegExp("^data:([^;:]*)?(;base64)?,(.*)$", "i"), dR = new RegExp("^ipfs://(ipfs/)?(.*)$", "i");+let Au = !1;+async function yb(i, e) {+ try {+ const t = i.match(uR);+ if (!t)+ throw new Error("invalid data");+ return new Us(200, "OK", {+ "content-type": t[1] || "text/plain"+ }, t[2] ? nR(t[3]) : pR(t[3]));+ } catch {+ return new Us(599, "BAD REQUEST (invalid data: URI)", {}, null, new ki(i));+ }+}+function wb(i) {+ async function e(t, n) {+ try {+ const s = t.match(dR);+ if (!s)+ throw new Error("invalid link");+ return new ki(`${i}${s[2]}`);+ } catch {+ return new Us(599, "BAD REQUEST (invalid IPFS URI)", {}, null, new ki(t));+ }+ }+ return e;+}+const el = {+ data: yb,+ ipfs: wb("https://gateway.ipfs.io/ipfs/")+}, vb = /* @__PURE__ */ new WeakMap();+class fR {+ #e;+ #t;+ constructor(e) {+ this.#e = [], this.#t = !1, vb.set(e, () => {+ if (!this.#t) {+ this.#t = !0;+ for (const t of this.#e)+ setTimeout(() => {+ t();+ }, 0);+ this.#e = [];+ }+ });+ }+ addListener(e) {+ ge(!this.#t, "singal already cancelled", "UNSUPPORTED_OPERATION", {+ operation: "fetchCancelSignal.addCancelListener"+ }), this.#e.push(e);+ }+ get cancelled() {+ return this.#t;+ }+ checkSignal() {+ ge(!this.cancelled, "cancelled", "CANCELLED", {});+ }+}+function tl(i) {+ if (i == null)+ throw new Error("missing signal; should not happen");+ return i.checkSignal(), i;+}+class ki {+ #e;+ #t;+ #n;+ #i;+ #s;+ #a;+ #r;+ #o;+ #f;+ // Hooks+ #l;+ #p;+ #A;+ #c;+ #h;+ #u;+ /**+ * The fetch URL to request.+ */+ get url() {+ return this.#a;+ }+ set url(e) {+ this.#a = String(e);+ }+ /**+ * The fetch body, if any, to send as the request body. //(default: null)//+ *+ * When setting a body, the intrinsic ``Content-Type`` is automatically+ * set and will be used if **not overridden** by setting a custom+ * header.+ *+ * If %%body%% is null, the body is cleared (along with the+ * intrinsic ``Content-Type``).+ *+ * If %%body%% is a string, the intrinsic ``Content-Type`` is set to+ * ``text/plain``.+ *+ * If %%body%% is a Uint8Array, the intrinsic ``Content-Type`` is set to+ * ``application/octet-stream``.+ *+ * If %%body%% is any other object, the intrinsic ``Content-Type`` is+ * set to ``application/json``.+ */+ get body() {+ return this.#r == null ? null : new Uint8Array(this.#r);+ }+ set body(e) {+ if (e == null)+ this.#r = void 0, this.#o = void 0;+ else if (typeof e == "string")+ this.#r = cs(e), this.#o = "text/plain";+ else if (e instanceof Uint8Array)+ this.#r = e, this.#o = "application/octet-stream";+ else if (typeof e == "object")+ this.#r = cs(JSON.stringify(e)), this.#o = "application/json";+ else+ throw new Error("invalid body");+ }+ /**+ * Returns true if the request has a body.+ */+ hasBody() {+ return this.#r != null;+ }+ /**+ * The HTTP method to use when requesting the URI. If no method+ * has been explicitly set, then ``GET`` is used if the body is+ * null and ``POST`` otherwise.+ */+ get method() {+ return this.#i ? this.#i : this.hasBody() ? "POST" : "GET";+ }+ set method(e) {+ e == null && (e = ""), this.#i = String(e).toUpperCase();+ }+ /**+ * The headers that will be used when requesting the URI. All+ * keys are lower-case.+ *+ * This object is a copy, so any changes will **NOT** be reflected+ * in the ``FetchRequest``.+ *+ * To set a header entry, use the ``setHeader`` method.+ */+ get headers() {+ const e = Object.assign({}, this.#n);+ return this.#f && (e.authorization = `Basic ${iR(cs(this.#f))}`), this.allowGzip && (e["accept-encoding"] = "gzip"), e["content-type"] == null && this.#o && (e["content-type"] = this.#o), this.body && (e["content-length"] = String(this.body.length)), e;+ }+ /**+ * Get the header for %%key%%, ignoring case.+ */+ getHeader(e) {+ return this.headers[e.toLowerCase()];+ }+ /**+ * Set the header for %%key%% to %%value%%. All values are coerced+ * to a string.+ */+ setHeader(e, t) {+ this.#n[String(e).toLowerCase()] = String(t);+ }+ /**+ * Clear all headers, resetting all intrinsic headers.+ */+ clearHeaders() {+ this.#n = {};+ }+ [Symbol.iterator]() {+ const e = this.headers, t = Object.keys(e);+ let n = 0;+ return {+ next: () => {+ if (n < t.length) {+ const s = t[n++];+ return {+ value: [s, e[s]],+ done: !1+ };+ }+ return { value: void 0, done: !0 };+ }+ };+ }+ /**+ * The value that will be sent for the ``Authorization`` header.+ *+ * To set the credentials, use the ``setCredentials`` method.+ */+ get credentials() {+ return this.#f || null;+ }+ /**+ * Sets an ``Authorization`` for %%username%% with %%password%%.+ */+ setCredentials(e, t) {+ V(!e.match(/:/), "invalid basic authentication username", "username", "[REDACTED]"), this.#f = `${e}:${t}`;+ }+ /**+ * Enable and request gzip-encoded responses. The response will+ * automatically be decompressed. //(default: true)//+ */+ get allowGzip() {+ return this.#t;+ }+ set allowGzip(e) {+ this.#t = !!e;+ }+ /**+ * Allow ``Authentication`` credentials to be sent over insecure+ * channels. //(default: false)//+ */+ get allowInsecureAuthentication() {+ return !!this.#e;+ }+ set allowInsecureAuthentication(e) {+ this.#e = !!e;+ }+ /**+ * The timeout (in milliseconds) to wait for a complete response.+ * //(default: 5 minutes)//+ */+ get timeout() {+ return this.#s;+ }+ set timeout(e) {+ V(e >= 0, "timeout must be non-zero", "timeout", e), this.#s = e;+ }+ /**+ * This function is called prior to each request, for example+ * during a redirection or retry in case of server throttling.+ *+ * This offers an opportunity to populate headers or update+ * content before sending a request.+ */+ get preflightFunc() {+ return this.#l || null;+ }+ set preflightFunc(e) {+ this.#l = e;+ }+ /**+ * This function is called after each response, offering an+ * opportunity to provide client-level throttling or updating+ * response data.+ *+ * Any error thrown in this causes the ``send()`` to throw.+ *+ * To schedule a retry attempt (assuming the maximum retry limit+ * has not been reached), use [[response.throwThrottleError]].+ */+ get processFunc() {+ return this.#p || null;+ }+ set processFunc(e) {+ this.#p = e;+ }+ /**+ * This function is called on each retry attempt.+ */+ get retryFunc() {+ return this.#A || null;+ }+ set retryFunc(e) {+ this.#A = e;+ }+ /**+ * This function is called to fetch content from HTTP and+ * HTTPS URLs and is platform specific (e.g. nodejs vs+ * browsers).+ *+ * This is by default the currently registered global getUrl+ * function, which can be changed using [[registerGetUrl]].+ * If this has been set, setting is to ``null`` will cause+ * this FetchRequest (and any future clones) to revert back to+ * using the currently registered global getUrl function.+ *+ * Setting this is generally not necessary, but may be useful+ * for developers that wish to intercept requests or to+ * configurege a proxy or other agent.+ */+ get getUrlFunc() {+ return this.#u || Ig;+ }+ set getUrlFunc(e) {+ this.#u = e;+ }+ /**+ * Create a new FetchRequest instance with default values.+ *+ * Once created, each property may be set before issuing a+ * ``.send()`` to make the request.+ */+ constructor(e) {+ this.#a = String(e), this.#e = !1, this.#t = !0, this.#n = {}, this.#i = "", this.#s = 3e5, this.#h = {+ slotInterval: hR,+ maxAttempts: lR+ }, this.#u = null;+ }+ toString() {+ return `<FetchRequest method=${JSON.stringify(this.method)} url=${JSON.stringify(this.url)} headers=${JSON.stringify(this.headers)} body=${this.#r ? Se(this.#r) : "null"}>`;+ }+ /**+ * Update the throttle parameters used to determine maximum+ * attempts and exponential-backoff properties.+ */+ setThrottleParams(e) {+ e.slotInterval != null && (this.#h.slotInterval = e.slotInterval), e.maxAttempts != null && (this.#h.maxAttempts = e.maxAttempts);+ }+ async #d(e, t, n, s, r) {+ if (e >= this.#h.maxAttempts)+ return r.makeServerError("exceeded maximum retry limit");+ ge(Mg() <= t, "timeout", "TIMEOUT", {+ operation: "request.send",+ reason: "timeout",+ request: s+ }), n > 0 && await AR(n);+ let a = this.clone();+ const o = (a.url.split(":")[0] || "").toLowerCase();+ if (o in el) {+ const h = await el[o](a.url, tl(s.#c));+ if (h instanceof Us) {+ let u = h;+ if (this.processFunc) {+ tl(s.#c);+ try {+ u = await this.processFunc(a, u);+ } catch (d) {+ (d.throttle == null || typeof d.stall != "number") && u.makeServerError("error in post-processing function", d).assertOk();+ }+ }+ return u;+ }+ a = h;+ }+ this.preflightFunc && (a = await this.preflightFunc(a));+ const c = await this.getUrlFunc(a, tl(s.#c));+ let l = new Us(c.statusCode, c.statusMessage, c.headers, c.body, s);+ if (l.statusCode === 301 || l.statusCode === 302) {+ try {+ const h = l.headers.location || "";+ return a.redirect(h).#d(e + 1, t, 0, s, l);+ } catch {+ }+ return l;+ } else if (l.statusCode === 429 && (this.retryFunc == null || await this.retryFunc(a, l, e))) {+ const h = l.headers["retry-after"];+ let u = this.#h.slotInterval * Math.trunc(Math.random() * Math.pow(2, e));+ return typeof h == "string" && h.match(/^[1-9][0-9]*$/) && (u = parseInt(h)), a.clone().#d(e + 1, t, u, s, l);+ }+ if (this.processFunc) {+ tl(s.#c);+ try {+ l = await this.processFunc(a, l);+ } catch (h) {+ (h.throttle == null || typeof h.stall != "number") && l.makeServerError("error in post-processing function", h).assertOk();+ let u = this.#h.slotInterval * Math.trunc(Math.random() * Math.pow(2, e));+ return h.stall >= 0 && (u = h.stall), a.clone().#d(e + 1, t, u, s, l);+ }+ }+ return l;+ }+ /**+ * Resolves to the response by sending the request.+ */+ send() {+ return ge(this.#c == null, "request already sent", "UNSUPPORTED_OPERATION", { operation: "fetchRequest.send" }), this.#c = new fR(this), this.#d(0, Mg() + this.timeout, 0, this, new Us(0, "", {}, null, this));+ }+ /**+ * Cancels the inflight response, causing a ``CANCELLED``+ * error to be rejected from the [[send]].+ */+ cancel() {+ ge(this.#c != null, "request has not been sent", "UNSUPPORTED_OPERATION", { operation: "fetchRequest.cancel" });+ const e = vb.get(this);+ if (!e)+ throw new Error("missing signal; should not happen");+ e();+ }+ /**+ * Returns a new [[FetchRequest]] that represents the redirection+ * to %%location%%.+ */+ redirect(e) {+ const t = this.url.split(":")[0].toLowerCase(), n = e.split(":")[0].toLowerCase();+ ge(this.method === "GET" && (t !== "https" || n !== "http") && e.match(/^https?:/), "unsupported redirect", "UNSUPPORTED_OPERATION", {+ operation: `redirect(${this.method} ${JSON.stringify(this.url)} => ${JSON.stringify(e)})`+ });+ const s = new ki(e);+ return s.method = "GET", s.allowGzip = this.allowGzip, s.timeout = this.timeout, s.#n = Object.assign({}, this.#n), this.#r && (s.#r = new Uint8Array(this.#r)), s.#o = this.#o, s;+ }+ /**+ * Create a new copy of this request.+ */+ clone() {+ const e = new ki(this.url);+ return e.#i = this.#i, this.#r && (e.#r = this.#r), e.#o = this.#o, e.#n = Object.assign({}, this.#n), e.#f = this.#f, this.allowGzip && (e.allowGzip = !0), e.timeout = this.timeout, this.allowInsecureAuthentication && (e.allowInsecureAuthentication = !0), e.#l = this.#l, e.#p = this.#p, e.#A = this.#A, e.#h = Object.assign({}, this.#h), e.#u = this.#u, e;+ }+ /**+ * Locks all static configuration for gateways and FetchGetUrlFunc+ * registration.+ */+ static lockConfig() {+ Au = !0;+ }+ /**+ * Get the current Gateway function for %%scheme%%.+ */+ static getGateway(e) {+ return el[e.toLowerCase()] || null;+ }+ /**+ * Use the %%func%% when fetching URIs using %%scheme%%.+ *+ * This method affects all requests globally.+ *+ * If [[lockConfig]] has been called, no change is made and this+ * throws.+ */+ static registerGateway(e, t) {+ if (e = e.toLowerCase(), e === "http" || e === "https")+ throw new Error(`cannot intercept ${e}; use registerGetUrl`);+ if (Au)+ throw new Error("gateways locked");+ el[e] = t;+ }+ /**+ * Use %%getUrl%% when fetching URIs over HTTP and HTTPS requests.+ *+ * This method affects all requests globally.+ *+ * If [[lockConfig]] has been called, no change is made and this+ * throws.+ */+ static registerGetUrl(e) {+ if (Au)+ throw new Error("gateways locked");+ Ig = e;+ }+ /**+ * Creates a getUrl function that fetches content from HTTP and+ * HTTPS URLs.+ *+ * The available %%options%% are dependent on the platform+ * implementation of the default getUrl function.+ *+ * This is not generally something that is needed, but is useful+ * when trying to customize simple behaviour when fetching HTTP+ * content.+ */+ static createGetUrlFunc(e) {+ return Eb(e);+ }+ /**+ * Creates a function that can "fetch" data URIs.+ *+ * Note that this is automatically done internally to support+ * data URIs, so it is not necessary to register it.+ *+ * This is not generally something that is needed, but may+ * be useful in a wrapper to perfom custom data URI functionality.+ */+ static createDataGateway() {+ return yb;+ }+ /**+ * Creates a function that will fetch IPFS (unvalidated) from+ * a custom gateway baseUrl.+ *+ * The default IPFS gateway used internally is+ * ``"https:/\/gateway.ipfs.io/ipfs/"``.+ */+ static createIpfsGatewayFunc(e) {+ return wb(e);+ }+}+class Us {+ #e;+ #t;+ #n;+ #i;+ #s;+ #a;+ toString() {+ return `<FetchResponse status=${this.statusCode} body=${this.#i ? Se(this.#i) : "null"}>`;+ }+ /**+ * The response status code.+ */+ get statusCode() {+ return this.#e;+ }+ /**+ * The response status message.+ */+ get statusMessage() {+ return this.#t;+ }+ /**+ * The response headers. All keys are lower-case.+ */+ get headers() {+ return Object.assign({}, this.#n);+ }+ /**+ * The response body, or ``null`` if there was no body.+ */+ get body() {+ return this.#i == null ? null : new Uint8Array(this.#i);+ }+ /**+ * The response body as a UTF-8 encoded string, or the empty+ * string (i.e. ``""``) if there was no body.+ *+ * An error is thrown if the body is invalid UTF-8 data.+ */+ get bodyText() {+ try {+ return this.#i == null ? "" : Ol(this.#i);+ } catch {+ ge(!1, "response body is not valid UTF-8 data", "UNSUPPORTED_OPERATION", {+ operation: "bodyText",+ info: { response: this }+ });+ }+ }+ /**+ * The response body, decoded as JSON.+ *+ * An error is thrown if the body is invalid JSON-encoded data+ * or if there was no body.+ */+ get bodyJson() {+ try {+ return JSON.parse(this.bodyText);+ } catch {+ ge(!1, "response body is not valid JSON", "UNSUPPORTED_OPERATION", {+ operation: "bodyJson",+ info: { response: this }+ });+ }+ }+ [Symbol.iterator]() {+ const e = this.headers, t = Object.keys(e);+ let n = 0;+ return {+ next: () => {+ if (n < t.length) {+ const s = t[n++];+ return {+ value: [s, e[s]],+ done: !1+ };+ }+ return { value: void 0, done: !0 };+ }+ };+ }+ constructor(e, t, n, s, r) {+ this.#e = e, this.#t = t, this.#n = Object.keys(n).reduce((a, o) => (a[o.toLowerCase()] = String(n[o]), a), {}), this.#i = s == null ? null : new Uint8Array(s), this.#s = r || null, this.#a = { message: "" };+ }+ /**+ * Return a Response with matching headers and body, but with+ * an error status code (i.e. 599) and %%message%% with an+ * optional %%error%%.+ */+ makeServerError(e, t) {+ let n;+ e ? n = `CLIENT ESCALATED SERVER ERROR (${this.statusCode} ${this.statusMessage}; ${e})` : (e = `${this.statusCode} ${this.statusMessage}`, n = `CLIENT ESCALATED SERVER ERROR (${e})`);+ const s = new Us(599, n, this.headers, this.body, this.#s || void 0);+ return s.#a = { message: e, error: t }, s;+ }+ /**+ * If called within a [request.processFunc](FetchRequest-processFunc)+ * call, causes the request to retry as if throttled for %%stall%%+ * milliseconds.+ */+ throwThrottleError(e, t) {+ t == null ? t = -1 : V(Number.isInteger(t) && t >= 0, "invalid stall timeout", "stall", t);+ const n = new Error(e || "throttling requests");+ throw Xe(n, { stall: t, throttle: !0 }), n;+ }+ /**+ * Get the header value for %%key%%, ignoring case.+ */+ getHeader(e) {+ return this.headers[e.toLowerCase()];+ }+ /**+ * Returns true if the response has a body.+ */+ hasBody() {+ return this.#i != null;+ }+ /**+ * The request made for this response.+ */+ get request() {+ return this.#s;+ }+ /**+ * Returns true if this response was a success statusCode.+ */+ ok() {+ return this.#a.message === "" && this.statusCode >= 200 && this.statusCode < 300;+ }+ /**+ * Throws a ``SERVER_ERROR`` if this response is not ok.+ */+ assertOk() {+ if (this.ok())+ return;+ let { message: e, error: t } = this.#a;+ e === "" && (e = `server response ${this.statusCode} ${this.statusMessage}`);+ let n = null;+ this.request && (n = this.request.url);+ let s = null;+ try {+ this.#i && (s = Ol(this.#i));+ } catch {+ }+ ge(!1, e, "SERVER_ERROR", {+ request: this.request || "unknown request",+ response: this,+ error: t,+ info: {+ requestUrl: n,+ responseBody: s,+ responseStatus: `${this.statusCode} ${this.statusMessage}`+ }+ });+ }+}+function Mg() {+ return (/* @__PURE__ */ new Date()).getTime();+}+function pR(i) {+ return cs(i.replace(/%([0-9a-f][0-9a-f])/gi, (e, t) => String.fromCharCode(parseInt(t, 16))));+}+function AR(i) {+ return new Promise((e) => setTimeout(e, i));+}+function gR(i) {+ let e = i.toString(16);+ for (; e.length < 2; )+ e = "0" + e;+ return "0x" + e;+}+function Bg(i, e, t) {+ let n = 0;+ for (let s = 0; s < t; s++)+ n = n * 256 + i[e + s];+ return n;+}+function Tg(i, e, t, n) {+ const s = [];+ for (; t < e + 1 + n; ) {+ const r = Cb(i, t);+ s.push(r.result), t += r.consumed, ge(t <= e + 1 + n, "child data too short", "BUFFER_OVERRUN", {+ buffer: i,+ length: n,+ offset: e+ });+ }+ return { consumed: 1 + n, result: s };+}+function Cb(i, e) {+ ge(i.length !== 0, "data too short", "BUFFER_OVERRUN", {+ buffer: i,+ length: 0,+ offset: 1+ });+ const t = (n) => {+ ge(n <= i.length, "data short segment too short", "BUFFER_OVERRUN", {+ buffer: i,+ length: i.length,+ offset: n+ });+ };+ if (i[e] >= 248) {+ const n = i[e] - 247;+ t(e + 1 + n);+ const s = Bg(i, e + 1, n);+ return t(e + 1 + n + s), Tg(i, e, e + 1 + n, n + s);+ } else if (i[e] >= 192) {+ const n = i[e] - 192;+ return t(e + 1 + n), Tg(i, e, e + 1, n);+ } else if (i[e] >= 184) {+ const n = i[e] - 183;+ t(e + 1 + n);+ const s = Bg(i, e + 1, n);+ t(e + 1 + n + s);+ const r = Se(i.slice(e + 1 + n, e + 1 + n + s));+ return { consumed: 1 + n + s, result: r };+ } else if (i[e] >= 128) {+ const n = i[e] - 128;+ t(e + 1 + n);+ const s = Se(i.slice(e + 1, e + 1 + n));+ return { consumed: 1 + n, result: s };+ }+ return { consumed: 1, result: gR(i[e]) };+}+function ic(i) {+ const e = ht(i, "data"), t = Cb(e, 0);+ return V(t.consumed === e.length, "unexpected junk after rlp payload", "data", i), t.result;+}+function Rg(i) {+ const e = [];+ for (; i; )+ e.unshift(i & 255), i >>= 8;+ return e;+}+function Sb(i) {+ if (Array.isArray(i)) {+ let n = [];+ if (i.forEach(function(r) {+ n = n.concat(Sb(r));+ }), n.length <= 55)+ return n.unshift(192 + n.length), n;+ const s = Rg(n.length);+ return s.unshift(247 + s.length), s.concat(n);+ }+ const e = Array.prototype.slice.call(ht(i, "object"));+ if (e.length === 1 && e[0] <= 127)+ return e;+ if (e.length <= 55)+ return e.unshift(128 + e.length), e;+ const t = Rg(e.length);+ return t.unshift(183 + t.length), t.concat(e);+}+const Ng = "0123456789abcdef";+function ls(i) {+ let e = "0x";+ for (const t of Sb(i))+ e += Ng[t >> 4], e += Ng[t & 15];+ return e;+}+const Fn = 32, Qd = new Uint8Array(Fn), mR = ["then"], nl = {}, Ib = /* @__PURE__ */ new WeakMap();+function cr(i) {+ return Ib.get(i);+}+function Fg(i, e) {+ Ib.set(i, e);+}+function co(i, e) {+ const t = new Error(`deferred error during ABI decoding triggered accessing ${i}`);+ throw t.error = e, t;+}+function Gd(i, e, t) {+ return i.indexOf(null) >= 0 ? e.map((n, s) => n instanceof rs ? Gd(cr(n), n, t) : n) : i.reduce((n, s, r) => {+ let a = e.getValue(s);+ return s in n || (t && a instanceof rs && (a = Gd(cr(a), a, t)), n[s] = a), n;+ }, {});+}+class rs extends Array {+ // No longer used; but cannot be removed as it will remove the+ // #private field from the .d.ts which may break backwards+ // compatibility+ #e;+ /**+ * @private+ */+ constructor(...e) {+ const t = e[0];+ let n = e[1], s = (e[2] || []).slice(), r = !0;+ t !== nl && (n = e, s = [], r = !1), super(n.length), n.forEach((c, l) => {+ this[l] = c;+ });+ const a = s.reduce((c, l) => (typeof l == "string" && c.set(l, (c.get(l) || 0) + 1), c), /* @__PURE__ */ new Map());+ if (Fg(this, Object.freeze(n.map((c, l) => {+ const h = s[l];+ return h != null && a.get(h) === 1 ? h : null;+ }))), this.#e = [], this.#e == null && this.#e, !r)+ return;+ Object.freeze(this);+ const o = new Proxy(this, {+ get: (c, l, h) => {+ if (typeof l == "string") {+ if (l.match(/^[0-9]+$/)) {+ const d = ut(l, "%index");+ if (d < 0 || d >= this.length)+ throw new RangeError("out of result range");+ const f = c[d];+ return f instanceof Error && co(`index ${d}`, f), f;+ }+ if (mR.indexOf(l) >= 0)+ return Reflect.get(c, l, h);+ const u = c[l];+ if (u instanceof Function)+ return function(...d) {+ return u.apply(this === h ? c : this, d);+ };+ if (!(l in c))+ return c.getValue.apply(this === h ? c : this, [l]);+ }+ return Reflect.get(c, l, h);+ }+ });+ return Fg(o, cr(this)), o;+ }+ /**+ * Returns the Result as a normal Array. If %%deep%%, any children+ * which are Result objects are also converted to a normal Array.+ *+ * This will throw if there are any outstanding deferred+ * errors.+ */+ toArray(e) {+ const t = [];+ return this.forEach((n, s) => {+ n instanceof Error && co(`index ${s}`, n), e && n instanceof rs && (n = n.toArray(e)), t.push(n);+ }), t;+ }+ /**+ * Returns the Result as an Object with each name-value pair. If+ * %%deep%%, any children which are Result objects are also+ * converted to an Object.+ *+ * This will throw if any value is unnamed, or if there are+ * any outstanding deferred errors.+ */+ toObject(e) {+ const t = cr(this);+ return t.reduce((n, s, r) => (ge(s != null, `value at index ${r} unnamed`, "UNSUPPORTED_OPERATION", {+ operation: "toObject()"+ }), Gd(t, this, e)), {});+ }+ /**+ * @_ignore+ */+ slice(e, t) {+ e == null && (e = 0), e < 0 && (e += this.length, e < 0 && (e = 0)), t == null && (t = this.length), t < 0 && (t += this.length, t < 0 && (t = 0)), t > this.length && (t = this.length);+ const n = cr(this), s = [], r = [];+ for (let a = e; a < t; a++)+ s.push(this[a]), r.push(n[a]);+ return new rs(nl, s, r);+ }+ /**+ * @_ignore+ */+ filter(e, t) {+ const n = cr(this), s = [], r = [];+ for (let a = 0; a < this.length; a++) {+ const o = this[a];+ o instanceof Error && co(`index ${a}`, o), e.call(t, o, a, this) && (s.push(o), r.push(n[a]));+ }+ return new rs(nl, s, r);+ }+ /**+ * @_ignore+ */+ map(e, t) {+ const n = [];+ for (let s = 0; s < this.length; s++) {+ const r = this[s];+ r instanceof Error && co(`index ${s}`, r), n.push(e.call(t, r, s, this));+ }+ return n;+ }+ /**+ * Returns the value for %%name%%.+ *+ * Since it is possible to have a key whose name conflicts with+ * a method on a [[Result]] or its superclass Array, or any+ * JavaScript keyword, this ensures all named values are still+ * accessible by name.+ */+ getValue(e) {+ const t = cr(this).indexOf(e);+ if (t === -1)+ return;+ const n = this[t];+ return n instanceof Error && co(`property ${JSON.stringify(e)}`, n.error), n;+ }+ /**+ * Creates a new [[Result]] for %%items%% with each entry+ * also accessible by its corresponding name in %%keys%%.+ */+ static fromItems(e, t) {+ return new rs(nl, e, t);+ }+}+function Dg(i) {+ let e = $t(i);+ return ge(e.length <= Fn, "value out-of-bounds", "BUFFER_OVERRUN", { buffer: e, length: Fn, offset: e.length }), e.length !== Fn && (e = Rn(Qt([Qd.slice(e.length % Fn), e]))), e;+}+class As {+ // The coder name:+ // - address, uint256, tuple, array, etc.+ name;+ // The fully expanded type, including composite types:+ // - address, uint256, tuple(address,bytes), uint256[3][4][], etc.+ type;+ // The localName bound in the signature, in this example it is "baz":+ // - tuple(address foo, uint bar) baz+ localName;+ // Whether this type is dynamic:+ // - Dynamic: bytes, string, address[], tuple(boolean[]), etc.+ // - Not Dynamic: address, uint256, boolean[3], tuple(address, uint8)+ dynamic;+ constructor(e, t, n, s) {+ Xe(this, { name: e, type: t, localName: n, dynamic: s }, {+ name: "string",+ type: "string",+ localName: "string",+ dynamic: "boolean"+ });+ }+ _throwError(e, t) {+ V(!1, e, this.localName, t);+ }+}+class Hd {+ // An array of WordSize lengthed objects to concatenation+ #e;+ #t;+ constructor() {+ this.#e = [], this.#t = 0;+ }+ get data() {+ return Qt(this.#e);+ }+ get length() {+ return this.#t;+ }+ #n(e) {+ return this.#e.push(e), this.#t += e.length, e.length;+ }+ appendWriter(e) {+ return this.#n(Rn(e.data));+ }+ // Arrayish item; pad on the right to *nearest* WordSize+ writeBytes(e) {+ let t = Rn(e);+ const n = t.length % Fn;+ return n && (t = Rn(Qt([t, Qd.slice(n)]))), this.#n(t);+ }+ // Numeric item; pad on the left *to* WordSize+ writeValue(e) {+ return this.#n(Dg(e));+ }+ // Inserts a numeric place-holder, returning a callback that can+ // be used to asjust the value later+ writeUpdatableValue() {+ const e = this.#e.length;+ return this.#e.push(Qd), this.#t += Fn, (t) => {+ this.#e[e] = Dg(t);+ };+ }+}+class qf {+ // Allows incomplete unpadded data to be read; otherwise an error+ // is raised if attempting to overrun the buffer. This is required+ // to deal with an old Solidity bug, in which event data for+ // external (not public thoguh) was tightly packed.+ allowLoose;+ #e;+ #t;+ #n;+ #i;+ #s;+ constructor(e, t, n) {+ Xe(this, { allowLoose: !!t }), this.#e = Rn(e), this.#n = 0, this.#i = null, this.#s = n ?? 1024, this.#t = 0;+ }+ get data() {+ return Se(this.#e);+ }+ get dataLength() {+ return this.#e.length;+ }+ get consumed() {+ return this.#t;+ }+ get bytes() {+ return new Uint8Array(this.#e);+ }+ #a(e) {+ if (this.#i)+ return this.#i.#a(e);+ this.#n += e, ge(this.#s < 1 || this.#n <= this.#s * this.dataLength, `compressed ABI data exceeds inflation ratio of ${this.#s} ( see: https://github.com/ethers-io/ethers.js/issues/4537 )`, "BUFFER_OVERRUN", {+ buffer: Rn(this.#e),+ offset: this.#t,+ length: e,+ info: {+ bytesRead: this.#n,+ dataLength: this.dataLength+ }+ });+ }+ #r(e, t, n) {+ let s = Math.ceil(t / Fn) * Fn;+ return this.#t + s > this.#e.length && (this.allowLoose && n && this.#t + t <= this.#e.length ? s = t : ge(!1, "data out-of-bounds", "BUFFER_OVERRUN", {+ buffer: Rn(this.#e),+ length: this.#e.length,+ offset: this.#t + s+ })), this.#e.slice(this.#t, this.#t + s);+ }+ // Create a sub-reader with the same underlying data, but offset+ subReader(e) {+ const t = new qf(this.#e.slice(this.#t + e), this.allowLoose, this.#s);+ return t.#i = this, t;+ }+ // Read bytes+ readBytes(e, t) {+ let n = this.#r(0, e, !!t);+ return this.#a(e), this.#t += n.length, n.slice(0, e);+ }+ // Read a numeric values+ readValue() {+ return Wf(this.readBytes(Fn));+ }+ readIndex() {+ return eR(this.readBytes(Fn));+ }+}+function Ql(i) {+ if (!Number.isSafeInteger(i) || i < 0)+ throw new Error(`Wrong positive integer: ${i}`);+}+function Kf(i, ...e) {+ if (!(i instanceof Uint8Array))+ throw new Error("Expected Uint8Array");+ if (e.length > 0 && !e.includes(i.length))+ throw new Error(`Expected Uint8Array of length ${e}, not of length=${i.length}`);+}+function bR(i) {+ if (typeof i != "function" || typeof i.create != "function")+ throw new Error("Hash should be wrapped by utils.wrapConstructor");+ Ql(i.outputLen), Ql(i.blockLen);+}+function Ra(i, e = !0) {+ if (i.destroyed)+ throw new Error("Hash instance has been destroyed");+ if (e && i.finished)+ throw new Error("Hash#digest() has already been called");+}+function Mb(i, e) {+ Kf(i);+ const t = e.outputLen;+ if (i.length < t)+ throw new Error(`digestInto() expects output buffer of length at least ${t}`);+}+const gu = typeof globalThis == "object" && "crypto" in globalThis ? globalThis.crypto : void 0;+const Bb = (i) => i instanceof Uint8Array, xR = (i) => new Uint32Array(i.buffer, i.byteOffset, Math.floor(i.byteLength / 4)), mu = (i) => new DataView(i.buffer, i.byteOffset, i.byteLength), Bi = (i, e) => i << 32 - e | i >>> e, _R = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;+if (!_R)+ throw new Error("Non little-endian hardware is not supported");+function ER(i) {+ if (typeof i != "string")+ throw new Error(`utf8ToBytes expected string, got ${typeof i}`);+ return new Uint8Array(new TextEncoder().encode(i));+}+function ah(i) {+ if (typeof i == "string" && (i = ER(i)), !Bb(i))+ throw new Error(`expected Uint8Array, got ${typeof i}`);+ return i;+}+function yR(...i) {+ const e = new Uint8Array(i.reduce((n, s) => n + s.length, 0));+ let t = 0;+ return i.forEach((n) => {+ if (!Bb(n))+ throw new Error("Uint8Array expected");+ e.set(n, t), t += n.length;+ }), e;+}+class jf {+ // Safe version that clones internal state+ clone() {+ return this._cloneInto();+ }+}+function Xf(i) {+ const e = (n) => i().update(ah(n)).digest(), t = i();+ return e.outputLen = t.outputLen, e.blockLen = t.blockLen, e.create = () => i(), e;+}+function wR(i = 32) {+ if (gu && typeof gu.getRandomValues == "function")+ return gu.getRandomValues(new Uint8Array(i));+ throw new Error("crypto.getRandomValues must be defined");+}+class Tb extends jf {+ constructor(e, t) {+ super(), this.finished = !1, this.destroyed = !1, bR(e);+ const n = ah(t);+ if (this.iHash = e.create(), typeof this.iHash.update != "function")+ throw new Error("Expected instance of class which extends utils.Hash");+ this.blockLen = this.iHash.blockLen, this.outputLen = this.iHash.outputLen;+ const s = this.blockLen, r = new Uint8Array(s);+ r.set(n.length > s ? e.create().update(n).digest() : n);+ for (let a = 0; a < r.length; a++)+ r[a] ^= 54;+ this.iHash.update(r), this.oHash = e.create();+ for (let a = 0; a < r.length; a++)+ r[a] ^= 106;+ this.oHash.update(r), r.fill(0);+ }+ update(e) {+ return Ra(this), this.iHash.update(e), this;+ }+ digestInto(e) {+ Ra(this), Kf(e, this.outputLen), this.finished = !0, this.iHash.digestInto(e), this.oHash.update(e), this.oHash.digestInto(e), this.destroy();+ }+ digest() {+ const e = new Uint8Array(this.oHash.outputLen);+ return this.digestInto(e), e;+ }+ _cloneInto(e) {+ e || (e = Object.create(Object.getPrototypeOf(this), {}));+ const { oHash: t, iHash: n, finished: s, destroyed: r, blockLen: a, outputLen: o } = this;+ return e = e, e.finished = s, e.destroyed = r, e.blockLen = a, e.outputLen = o, e.oHash = t._cloneInto(e.oHash), e.iHash = n._cloneInto(e.iHash), e;+ }+ destroy() {+ this.destroyed = !0, this.oHash.destroy(), this.iHash.destroy();+ }+}+const Rb = (i, e, t) => new Tb(i, e).update(t).digest();+Rb.create = (i, e) => new Tb(i, e);+function vR(i, e, t, n) {+ if (typeof i.setBigUint64 == "function")+ return i.setBigUint64(e, t, n);+ const s = BigInt(32), r = BigInt(4294967295), a = Number(t >> s & r), o = Number(t & r), c = n ? 4 : 0, l = n ? 0 : 4;+ i.setUint32(e + c, a, n), i.setUint32(e + l, o, n);+}+class Nb extends jf {+ constructor(e, t, n, s) {+ super(), this.blockLen = e, this.outputLen = t, this.padOffset = n, this.isLE = s, this.finished = !1, this.length = 0, this.pos = 0, this.destroyed = !1, this.buffer = new Uint8Array(e), this.view = mu(this.buffer);+ }+ update(e) {+ Ra(this);+ const { view: t, buffer: n, blockLen: s } = this;+ e = ah(e);+ const r = e.length;+ for (let a = 0; a < r; ) {+ const o = Math.min(s - this.pos, r - a);+ if (o === s) {+ const c = mu(e);+ for (; s <= r - a; a += s)+ this.process(c, a);+ continue;+ }+ n.set(e.subarray(a, a + o), this.pos), this.pos += o, a += o, this.pos === s && (this.process(t, 0), this.pos = 0);+ }+ return this.length += e.length, this.roundClean(), this;+ }+ digestInto(e) {+ Ra(this), Mb(e, this), this.finished = !0;+ const { buffer: t, view: n, blockLen: s, isLE: r } = this;+ let { pos: a } = this;+ t[a++] = 128, this.buffer.subarray(a).fill(0), this.padOffset > s - a && (this.process(n, 0), a = 0);+ for (let u = a; u < s; u++)+ t[u] = 0;+ vR(n, s - 8, BigInt(this.length * 8), r), this.process(n, 0);+ const o = mu(e), c = this.outputLen;+ if (c % 4)+ throw new Error("_sha2: outputLen should be aligned to 32bit");+ const l = c / 4, h = this.get();+ if (l > h.length)+ throw new Error("_sha2: outputLen bigger than state");+ for (let u = 0; u < l; u++)+ o.setUint32(4 * u, h[u], r);+ }+ digest() {+ const { buffer: e, outputLen: t } = this;+ this.digestInto(e);+ const n = e.slice(0, t);+ return this.destroy(), n;+ }+ _cloneInto(e) {+ e || (e = new this.constructor()), e.set(...this.get());+ const { blockLen: t, buffer: n, length: s, finished: r, destroyed: a, pos: o } = this;+ return e.length = s, e.pos = o, e.finished = r, e.destroyed = a, s % t && e.buffer.set(n), e;+ }+}+const CR = (i, e, t) => i & e ^ ~i & t, SR = (i, e, t) => i & e ^ i & t ^ e & t, IR = /* @__PURE__ */ new Uint32Array([+ 1116352408,+ 1899447441,+ 3049323471,+ 3921009573,+ 961987163,+ 1508970993,+ 2453635748,+ 2870763221,+ 3624381080,+ 310598401,+ 607225278,+ 1426881987,+ 1925078388,+ 2162078206,+ 2614888103,+ 3248222580,+ 3835390401,+ 4022224774,+ 264347078,+ 604807628,+ 770255983,+ 1249150122,+ 1555081692,+ 1996064986,+ 2554220882,+ 2821834349,+ 2952996808,+ 3210313671,+ 3336571891,+ 3584528711,+ 113926993,+ 338241895,+ 666307205,+ 773529912,+ 1294757372,+ 1396182291,+ 1695183700,+ 1986661051,+ 2177026350,+ 2456956037,+ 2730485921,+ 2820302411,+ 3259730800,+ 3345764771,+ 3516065817,+ 3600352804,+ 4094571909,+ 275423344,+ 430227734,+ 506948616,+ 659060556,+ 883997877,+ 958139571,+ 1322822218,+ 1537002063,+ 1747873779,+ 1955562222,+ 2024104815,+ 2227730452,+ 2361852424,+ 2428436474,+ 2756734187,+ 3204031479,+ 3329325298+]), Ss = /* @__PURE__ */ new Uint32Array([+ 1779033703,+ 3144134277,+ 1013904242,+ 2773480762,+ 1359893119,+ 2600822924,+ 528734635,+ 1541459225+]), Is = /* @__PURE__ */ new Uint32Array(64);+class MR extends Nb {+ constructor() {+ super(64, 32, 8, !1), this.A = Ss[0] | 0, this.B = Ss[1] | 0, this.C = Ss[2] | 0, this.D = Ss[3] | 0, this.E = Ss[4] | 0, this.F = Ss[5] | 0, this.G = Ss[6] | 0, this.H = Ss[7] | 0;+ }+ get() {+ const { A: e, B: t, C: n, D: s, E: r, F: a, G: o, H: c } = this;+ return [e, t, n, s, r, a, o, c];+ }+ // prettier-ignore+ set(e, t, n, s, r, a, o, c) {+ this.A = e | 0, this.B = t | 0, this.C = n | 0, this.D = s | 0, this.E = r | 0, this.F = a | 0, this.G = o | 0, this.H = c | 0;+ }+ process(e, t) {+ for (let u = 0; u < 16; u++, t += 4)+ Is[u] = e.getUint32(t, !1);+ for (let u = 16; u < 64; u++) {+ const d = Is[u - 15], f = Is[u - 2], m = Bi(d, 7) ^ Bi(d, 18) ^ d >>> 3, A = Bi(f, 17) ^ Bi(f, 19) ^ f >>> 10;+ Is[u] = A + Is[u - 7] + m + Is[u - 16] | 0;+ }+ let { A: n, B: s, C: r, D: a, E: o, F: c, G: l, H: h } = this;+ for (let u = 0; u < 64; u++) {+ const d = Bi(o, 6) ^ Bi(o, 11) ^ Bi(o, 25), f = h + d + CR(o, c, l) + IR[u] + Is[u] | 0, A = (Bi(n, 2) ^ Bi(n, 13) ^ Bi(n, 22)) + SR(n, s, r) | 0;+ h = l, l = c, c = o, o = a + f | 0, a = r, r = s, s = n, n = f + A | 0;+ }+ n = n + this.A | 0, s = s + this.B | 0, r = r + this.C | 0, a = a + this.D | 0, o = o + this.E | 0, c = c + this.F | 0, l = l + this.G | 0, h = h + this.H | 0, this.set(n, s, r, a, o, c, l, h);+ }+ roundClean() {+ Is.fill(0);+ }+ destroy() {+ this.set(0, 0, 0, 0, 0, 0, 0, 0), this.buffer.fill(0);+ }+}+const Fb = /* @__PURE__ */ Xf(() => new MR()), il = /* @__PURE__ */ BigInt(2 ** 32 - 1), zd = /* @__PURE__ */ BigInt(32);+function Db(i, e = !1) {+ return e ? { h: Number(i & il), l: Number(i >> zd & il) } : { h: Number(i >> zd & il) | 0, l: Number(i & il) | 0 };+}+function Lb(i, e = !1) {+ let t = new Uint32Array(i.length), n = new Uint32Array(i.length);+ for (let s = 0; s < i.length; s++) {+ const { h: r, l: a } = Db(i[s], e);+ [t[s], n[s]] = [r, a];+ }+ return [t, n];+}+const BR = (i, e) => BigInt(i >>> 0) << zd | BigInt(e >>> 0), TR = (i, e, t) => i >>> t, RR = (i, e, t) => i << 32 - t | e >>> t, NR = (i, e, t) => i >>> t | e << 32 - t, FR = (i, e, t) => i << 32 - t | e >>> t, DR = (i, e, t) => i << 64 - t | e >>> t - 32, LR = (i, e, t) => i >>> t - 32 | e << 64 - t, PR = (i, e) => e, kR = (i, e) => i, Pb = (i, e, t) => i << t | e >>> 32 - t, kb = (i, e, t) => e << t | i >>> 32 - t, Ub = (i, e, t) => e << t - 32 | i >>> 64 - t, Ob = (i, e, t) => i << t - 32 | e >>> 64 - t;+function UR(i, e, t, n) {+ const s = (e >>> 0) + (n >>> 0);+ return { h: i + t + (s / 2 ** 32 | 0) | 0, l: s | 0 };+}+const OR = (i, e, t) => (i >>> 0) + (e >>> 0) + (t >>> 0), QR = (i, e, t, n) => e + t + n + (i / 2 ** 32 | 0) | 0, GR = (i, e, t, n) => (i >>> 0) + (e >>> 0) + (t >>> 0) + (n >>> 0), HR = (i, e, t, n, s) => e + t + n + s + (i / 2 ** 32 | 0) | 0, zR = (i, e, t, n, s) => (i >>> 0) + (e >>> 0) + (t >>> 0) + (n >>> 0) + (s >>> 0), VR = (i, e, t, n, s, r) => e + t + n + s + r + (i / 2 ** 32 | 0) | 0, at = {+ fromBig: Db,+ split: Lb,+ toBig: BR,+ shrSH: TR,+ shrSL: RR,+ rotrSH: NR,+ rotrSL: FR,+ rotrBH: DR,+ rotrBL: LR,+ rotr32H: PR,+ rotr32L: kR,+ rotlSH: Pb,+ rotlSL: kb,+ rotlBH: Ub,+ rotlBL: Ob,+ add: UR,+ add3L: OR,+ add3H: QR,+ add4L: GR,+ add4H: HR,+ add5H: VR,+ add5L: zR+}, [WR, qR] = at.split([+ "0x428a2f98d728ae22",+ "0x7137449123ef65cd",+ "0xb5c0fbcfec4d3b2f",+ "0xe9b5dba58189dbbc",+ "0x3956c25bf348b538",+ "0x59f111f1b605d019",+ "0x923f82a4af194f9b",+ "0xab1c5ed5da6d8118",+ "0xd807aa98a3030242",+ "0x12835b0145706fbe",+ "0x243185be4ee4b28c",+ "0x550c7dc3d5ffb4e2",+ "0x72be5d74f27b896f",+ "0x80deb1fe3b1696b1",+ "0x9bdc06a725c71235",+ "0xc19bf174cf692694",+ "0xe49b69c19ef14ad2",+ "0xefbe4786384f25e3",+ "0x0fc19dc68b8cd5b5",+ "0x240ca1cc77ac9c65",+ "0x2de92c6f592b0275",+ "0x4a7484aa6ea6e483",+ "0x5cb0a9dcbd41fbd4",+ "0x76f988da831153b5",+ "0x983e5152ee66dfab",+ "0xa831c66d2db43210",+ "0xb00327c898fb213f",+ "0xbf597fc7beef0ee4",+ "0xc6e00bf33da88fc2",+ "0xd5a79147930aa725",+ "0x06ca6351e003826f",+ "0x142929670a0e6e70",+ "0x27b70a8546d22ffc",+ "0x2e1b21385c26c926",+ "0x4d2c6dfc5ac42aed",+ "0x53380d139d95b3df",+ "0x650a73548baf63de",+ "0x766a0abb3c77b2a8",+ "0x81c2c92e47edaee6",+ "0x92722c851482353b",+ "0xa2bfe8a14cf10364",+ "0xa81a664bbc423001",+ "0xc24b8b70d0f89791",+ "0xc76c51a30654be30",+ "0xd192e819d6ef5218",+ "0xd69906245565a910",+ "0xf40e35855771202a",+ "0x106aa07032bbd1b8",+ "0x19a4c116b8d2d0c8",+ "0x1e376c085141ab53",+ "0x2748774cdf8eeb99",+ "0x34b0bcb5e19b48a8",+ "0x391c0cb3c5c95a63",+ "0x4ed8aa4ae3418acb",+ "0x5b9cca4f7763e373",+ "0x682e6ff3d6b2b8a3",+ "0x748f82ee5defb2fc",+ "0x78a5636f43172f60",+ "0x84c87814a1f0ab72",+ "0x8cc702081a6439ec",+ "0x90befffa23631e28",+ "0xa4506cebde82bde9",+ "0xbef9a3f7b2c67915",+ "0xc67178f2e372532b",+ "0xca273eceea26619c",+ "0xd186b8c721c0c207",+ "0xeada7dd6cde0eb1e",+ "0xf57d4f7fee6ed178",+ "0x06f067aa72176fba",+ "0x0a637dc5a2c898a6",+ "0x113f9804bef90dae",+ "0x1b710b35131c471b",+ "0x28db77f523047d84",+ "0x32caab7b40c72493",+ "0x3c9ebe0a15c9bebc",+ "0x431d67c49c100d4c",+ "0x4cc5d4becb3e42b6",+ "0x597f299cfc657e2a",+ "0x5fcb6fab3ad6faec",+ "0x6c44198c4a475817"+].map((i) => BigInt(i))), Ms = /* @__PURE__ */ new Uint32Array(80), Bs = /* @__PURE__ */ new Uint32Array(80);+class KR extends Nb {+ constructor() {+ super(128, 64, 16, !1), this.Ah = 1779033703, this.Al = -205731576, this.Bh = -1150833019, this.Bl = -2067093701, this.Ch = 1013904242, this.Cl = -23791573, this.Dh = -1521486534, this.Dl = 1595750129, this.Eh = 1359893119, this.El = -1377402159, this.Fh = -1694144372, this.Fl = 725511199, this.Gh = 528734635, this.Gl = -79577749, this.Hh = 1541459225, this.Hl = 327033209;+ }+ // prettier-ignore+ get() {+ const { Ah: e, Al: t, Bh: n, Bl: s, Ch: r, Cl: a, Dh: o, Dl: c, Eh: l, El: h, Fh: u, Fl: d, Gh: f, Gl: m, Hh: A, Hl: g } = this;+ return [e, t, n, s, r, a, o, c, l, h, u, d, f, m, A, g];+ }+ // prettier-ignore+ set(e, t, n, s, r, a, o, c, l, h, u, d, f, m, A, g) {+ this.Ah = e | 0, this.Al = t | 0, this.Bh = n | 0, this.Bl = s | 0, this.Ch = r | 0, this.Cl = a | 0, this.Dh = o | 0, this.Dl = c | 0, this.Eh = l | 0, this.El = h | 0, this.Fh = u | 0, this.Fl = d | 0, this.Gh = f | 0, this.Gl = m | 0, this.Hh = A | 0, this.Hl = g | 0;+ }+ process(e, t) {+ for (let b = 0; b < 16; b++, t += 4)+ Ms[b] = e.getUint32(t), Bs[b] = e.getUint32(t += 4);+ for (let b = 16; b < 80; b++) {+ const E = Ms[b - 15] | 0, M = Bs[b - 15] | 0, w = at.rotrSH(E, M, 1) ^ at.rotrSH(E, M, 8) ^ at.shrSH(E, M, 7), S = at.rotrSL(E, M, 1) ^ at.rotrSL(E, M, 8) ^ at.shrSL(E, M, 7), T = Ms[b - 2] | 0, C = Bs[b - 2] | 0, v = at.rotrSH(T, C, 19) ^ at.rotrBH(T, C, 61) ^ at.shrSH(T, C, 6), F = at.rotrSL(T, C, 19) ^ at.rotrBL(T, C, 61) ^ at.shrSL(T, C, 6), K = at.add4L(S, F, Bs[b - 7], Bs[b - 16]), q = at.add4H(K, w, v, Ms[b - 7], Ms[b - 16]);+ Ms[b] = q | 0, Bs[b] = K | 0;+ }+ let { Ah: n, Al: s, Bh: r, Bl: a, Ch: o, Cl: c, Dh: l, Dl: h, Eh: u, El: d, Fh: f, Fl: m, Gh: A, Gl: g, Hh: p, Hl: y } = this;+ for (let b = 0; b < 80; b++) {+ const E = at.rotrSH(u, d, 14) ^ at.rotrSH(u, d, 18) ^ at.rotrBH(u, d, 41), M = at.rotrSL(u, d, 14) ^ at.rotrSL(u, d, 18) ^ at.rotrBL(u, d, 41), w = u & f ^ ~u & A, S = d & m ^ ~d & g, T = at.add5L(y, M, S, qR[b], Bs[b]), C = at.add5H(T, p, E, w, WR[b], Ms[b]), v = T | 0, F = at.rotrSH(n, s, 28) ^ at.rotrBH(n, s, 34) ^ at.rotrBH(n, s, 39), K = at.rotrSL(n, s, 28) ^ at.rotrBL(n, s, 34) ^ at.rotrBL(n, s, 39), q = n & r ^ n & o ^ r & o, $ = s & a ^ s & c ^ a & c;+ p = A | 0, y = g | 0, A = f | 0, g = m | 0, f = u | 0, m = d | 0, { h: u, l: d } = at.add(l | 0, h | 0, C | 0, v | 0), l = o | 0, h = c | 0, o = r | 0, c = a | 0, r = n | 0, a = s | 0;+ const D = at.add3L(v, K, $);+ n = at.add3H(D, C, F, q), s = D | 0;+ }+ ({ h: n, l: s } = at.add(this.Ah | 0, this.Al | 0, n | 0, s | 0)), { h: r, l: a } = at.add(this.Bh | 0, this.Bl | 0, r | 0, a | 0), { h: o, l: c } = at.add(this.Ch | 0, this.Cl | 0, o | 0, c | 0), { h: l, l: h } = at.add(this.Dh | 0, this.Dl | 0, l | 0, h | 0), { h: u, l: d } = at.add(this.Eh | 0, this.El | 0, u | 0, d | 0), { h: f, l: m } = at.add(this.Fh | 0, this.Fl | 0, f | 0, m | 0), { h: A, l: g } = at.add(this.Gh | 0, this.Gl | 0, A | 0, g | 0), { h: p, l: y } = at.add(this.Hh | 0, this.Hl | 0, p | 0, y | 0), this.set(n, s, r, a, o, c, l, h, u, d, f, m, A, g, p, y);+ }+ roundClean() {+ Ms.fill(0), Bs.fill(0);+ }+ destroy() {+ this.buffer.fill(0), this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);+ }+}+const jR = /* @__PURE__ */ Xf(() => new KR());+function XR() {+ if (typeof self < "u")+ return self;+ if (typeof window < "u")+ return window;+ if (typeof global < "u")+ return global;+ throw new Error("unable to locate global object");+}+const Lg = XR();+Lg.crypto || Lg.msCrypto;+function YR(i) {+ switch (i) {+ case "sha256":+ return Fb.create();+ case "sha512":+ return jR.create();+ }+ V(!1, "invalid hashing algorithm name", "algorithm", i);+}+const [Qb, Gb, Hb] = [[], [], []], JR = /* @__PURE__ */ BigInt(0), lo = /* @__PURE__ */ BigInt(1), ZR = /* @__PURE__ */ BigInt(2), $R = /* @__PURE__ */ BigInt(7), eN = /* @__PURE__ */ BigInt(256), tN = /* @__PURE__ */ BigInt(113);+for (let i = 0, e = lo, t = 1, n = 0; i < 24; i++) {+ [t, n] = [n, (2 * t + 3 * n) % 5], Qb.push(2 * (5 * n + t)), Gb.push((i + 1) * (i + 2) / 2 % 64);+ let s = JR;+ for (let r = 0; r < 7; r++)+ e = (e << lo ^ (e >> $R) * tN) % eN, e & ZR && (s ^= lo << (lo << /* @__PURE__ */ BigInt(r)) - lo);+ Hb.push(s);+}+const [nN, iN] = /* @__PURE__ */ Lb(Hb, !0), Pg = (i, e, t) => t > 32 ? Ub(i, e, t) : Pb(i, e, t), kg = (i, e, t) => t > 32 ? Ob(i, e, t) : kb(i, e, t);+function sN(i, e = 24) {+ const t = new Uint32Array(10);+ for (let n = 24 - e; n < 24; n++) {+ for (let a = 0; a < 10; a++)+ t[a] = i[a] ^ i[a + 10] ^ i[a + 20] ^ i[a + 30] ^ i[a + 40];+ for (let a = 0; a < 10; a += 2) {+ const o = (a + 8) % 10, c = (a + 2) % 10, l = t[c], h = t[c + 1], u = Pg(l, h, 1) ^ t[o], d = kg(l, h, 1) ^ t[o + 1];+ for (let f = 0; f < 50; f += 10)+ i[a + f] ^= u, i[a + f + 1] ^= d;+ }+ let s = i[2], r = i[3];+ for (let a = 0; a < 24; a++) {+ const o = Gb[a], c = Pg(s, r, o), l = kg(s, r, o), h = Qb[a];+ s = i[h], r = i[h + 1], i[h] = c, i[h + 1] = l;+ }+ for (let a = 0; a < 50; a += 10) {+ for (let o = 0; o < 10; o++)+ t[o] = i[a + o];+ for (let o = 0; o < 10; o++)+ i[a + o] ^= ~t[(o + 2) % 10] & t[(o + 4) % 10];+ }+ i[0] ^= nN[n], i[1] ^= iN[n];+ }+ t.fill(0);+}+class Yf extends jf {+ // NOTE: we accept arguments in bytes instead of bits here.+ constructor(e, t, n, s = !1, r = 24) {+ if (super(), this.blockLen = e, this.suffix = t, this.outputLen = n, this.enableXOF = s, this.rounds = r, this.pos = 0, this.posOut = 0, this.finished = !1, this.destroyed = !1, Ql(n), 0 >= this.blockLen || this.blockLen >= 200)+ throw new Error("Sha3 supports only keccak-f1600 function");+ this.state = new Uint8Array(200), this.state32 = xR(this.state);+ }+ keccak() {+ sN(this.state32, this.rounds), this.posOut = 0, this.pos = 0;+ }+ update(e) {+ Ra(this);+ const { blockLen: t, state: n } = this;+ e = ah(e);+ const s = e.length;+ for (let r = 0; r < s; ) {+ const a = Math.min(t - this.pos, s - r);+ for (let o = 0; o < a; o++)+ n[this.pos++] ^= e[r++];+ this.pos === t && this.keccak();+ }+ return this;+ }+ finish() {+ if (this.finished)+ return;+ this.finished = !0;+ const { state: e, suffix: t, pos: n, blockLen: s } = this;+ e[n] ^= t, (t & 128) !== 0 && n === s - 1 && this.keccak(), e[s - 1] ^= 128, this.keccak();+ }+ writeInto(e) {+ Ra(this, !1), Kf(e), this.finish();+ const t = this.state, { blockLen: n } = this;+ for (let s = 0, r = e.length; s < r; ) {+ this.posOut >= n && this.keccak();+ const a = Math.min(n - this.posOut, r - s);+ e.set(t.subarray(this.posOut, this.posOut + a), s), this.posOut += a, s += a;+ }+ return e;+ }+ xofInto(e) {+ if (!this.enableXOF)+ throw new Error("XOF is not possible for this instance");+ return this.writeInto(e);+ }+ xof(e) {+ return Ql(e), this.xofInto(new Uint8Array(e));+ }+ digestInto(e) {+ if (Mb(e, this), this.finished)+ throw new Error("digest() was already called");+ return this.writeInto(e), this.destroy(), e;+ }+ digest() {+ return this.digestInto(new Uint8Array(this.outputLen));+ }+ destroy() {+ this.destroyed = !0, this.state.fill(0);+ }+ _cloneInto(e) {+ const { blockLen: t, suffix: n, outputLen: s, rounds: r, enableXOF: a } = this;+ return e || (e = new Yf(t, n, s, a, r)), e.state32.set(this.state32), e.pos = this.pos, e.posOut = this.posOut, e.finished = this.finished, e.rounds = r, e.suffix = n, e.outputLen = s, e.enableXOF = a, e.destroyed = this.destroyed, e;+ }+}+const rN = (i, e, t) => Xf(() => new Yf(e, i, t)), aN = /* @__PURE__ */ rN(1, 136, 256 / 8);+let zb = !1;+const Vb = function(i) {+ return aN(i);+};+let Wb = Vb;+function Zt(i) {+ const e = ht(i, "data");+ return Se(Wb(e));+}+Zt._ = Vb;+Zt.lock = function() {+ zb = !0;+};+Zt.register = function(i) {+ if (zb)+ throw new TypeError("keccak256 is locked");+ Wb = i;+};+Object.freeze(Zt);+const qb = function(i) {+ return YR("sha256").update(i).digest();+};+let Kb = qb, jb = !1;+function za(i) {+ const e = ht(i, "data");+ return Se(Kb(e));+}+za._ = qb;+za.lock = function() {+ jb = !0;+};+za.register = function(i) {+ if (jb)+ throw new Error("sha256 is locked");+ Kb = i;+};+Object.freeze(za);+Object.freeze(za);+BigInt(0);+const oN = BigInt(1), cN = BigInt(2), oh = (i) => i instanceof Uint8Array, lN = /* @__PURE__ */ Array.from({ length: 256 }, (i, e) => e.toString(16).padStart(2, "0"));+function Na(i) {+ if (!oh(i))+ throw new Error("Uint8Array expected");+ let e = "";+ for (let t = 0; t < i.length; t++)+ e += lN[i[t]];+ return e;+}+function Jf(i) {+ if (typeof i != "string")+ throw new Error("hex string expected, got " + typeof i);+ return BigInt(i === "" ? "0" : `0x${i}`);+}+function Ho(i) {+ if (typeof i != "string")+ throw new Error("hex string expected, got " + typeof i);+ const e = i.length;+ if (e % 2)+ throw new Error("padded hex string expected, got unpadded hex of length " + e);+ const t = new Uint8Array(e / 2);+ for (let n = 0; n < t.length; n++) {+ const s = n * 2, r = i.slice(s, s + 2), a = Number.parseInt(r, 16);+ if (Number.isNaN(a) || a < 0)+ throw new Error("Invalid byte sequence");+ t[n] = a;+ }+ return t;+}+function br(i) {+ return Jf(Na(i));+}+function Zf(i) {+ if (!oh(i))+ throw new Error("Uint8Array expected");+ return Jf(Na(Uint8Array.from(i).reverse()));+}+function Fa(i, e) {+ return Ho(i.toString(16).padStart(e * 2, "0"));+}+function $f(i, e) {+ return Fa(i, e).reverse();+}+function fi(i, e, t) {+ let n;+ if (typeof e == "string")+ try {+ n = Ho(e);+ } catch (r) {+ throw new Error(`${i} must be valid hex string, got "${e}". Cause: ${r}`);+ }+ else if (oh(e))+ n = Uint8Array.from(e);+ else+ throw new Error(`${i} must be hex string or Uint8Array`);+ const s = n.length;+ if (typeof t == "number" && s !== t)+ throw new Error(`${i} expected ${t} bytes, got ${s}`);+ return n;+}+function zo(...i) {+ const e = new Uint8Array(i.reduce((n, s) => n + s.length, 0));+ let t = 0;+ return i.forEach((n) => {+ if (!oh(n))+ throw new Error("Uint8Array expected");+ e.set(n, t), t += n.length;+ }), e;+}+const ep = (i) => (cN << BigInt(i - 1)) - oN, bu = (i) => new Uint8Array(i), Ug = (i) => Uint8Array.from(i);+function Xb(i, e, t) {+ if (typeof i != "number" || i < 2)+ throw new Error("hashLen must be a number");+ if (typeof e != "number" || e < 2)+ throw new Error("qByteLen must be a number");+ if (typeof t != "function")+ throw new Error("hmacFn must be a function");+ let n = bu(i), s = bu(i), r = 0;+ const a = () => {+ n.fill(1), s.fill(0), r = 0;+ }, o = (...u) => t(s, n, ...u), c = (u = bu()) => {+ s = o(Ug([0]), u), n = o(), u.length !== 0 && (s = o(Ug([1]), u), n = o());+ }, l = () => {+ if (r++ >= 1e3)+ throw new Error("drbg: tried 1000 values");+ let u = 0;+ const d = [];+ for (; u < e; ) {+ n = o();+ const f = n.slice();+ d.push(f), u += n.length;+ }+ return zo(...d);+ };+ return (u, d) => {+ a(), c(u);+ let f;+ for (; !(f = d(l())); )+ c();+ return a(), f;+ };+}+const hN = {+ bigint: (i) => typeof i == "bigint",+ function: (i) => typeof i == "function",+ boolean: (i) => typeof i == "boolean",+ string: (i) => typeof i == "string",+ stringOrUint8Array: (i) => typeof i == "string" || i instanceof Uint8Array,+ isSafeInteger: (i) => Number.isSafeInteger(i),+ array: (i) => Array.isArray(i),+ field: (i, e) => e.Fp.isValid(i),+ hash: (i) => typeof i == "function" && Number.isSafeInteger(i.outputLen)+};+function sc(i, e, t = {}) {+ const n = (s, r, a) => {+ const o = hN[r];+ if (typeof o != "function")+ throw new Error(`Invalid validator "${r}", expected function`);+ const c = i[s];+ if (!(a && c === void 0) && !o(c, i))+ throw new Error(`Invalid param ${String(s)}=${c} (${typeof c}), expected ${r}`);+ };+ for (const [s, r] of Object.entries(e))+ n(s, r, !1);+ for (const [s, r] of Object.entries(t))+ n(s, r, !0);+ return i;+}+const uN = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({+ __proto__: null,+ bitMask: ep,+ bytesToHex: Na,+ bytesToNumberBE: br,+ bytesToNumberLE: Zf,+ concatBytes: zo,+ createHmacDrbg: Xb,+ ensureBytes: fi,+ hexToBytes: Ho,+ hexToNumber: Jf,+ numberToBytesBE: Fa,+ numberToBytesLE: $f,+ validateObject: sc+}, Symbol.toStringTag, { value: "Module" }));+const mn = BigInt(0), Xt = BigInt(1), lr = BigInt(2), dN = BigInt(3), Vd = BigInt(4), Og = BigInt(5), Qg = BigInt(8);+BigInt(9);+BigInt(16);+function Qn(i, e) {+ const t = i % e;+ return t >= mn ? t : e + t;+}+function fN(i, e, t) {+ if (t <= mn || e < mn)+ throw new Error("Expected power/modulo > 0");+ if (t === Xt)+ return mn;+ let n = Xt;+ for (; e > mn; )+ e & Xt && (n = n * i % t), i = i * i % t, e >>= Xt;+ return n;+}+function Zn(i, e, t) {+ let n = i;+ for (; e-- > mn; )+ n *= n, n %= t;+ return n;+}+function Wd(i, e) {+ if (i === mn || e <= mn)+ throw new Error(`invert: expected positive integers, got n=${i} mod=${e}`);+ let t = Qn(i, e), n = e, s = mn, r = Xt;+ for (; t !== mn; ) {+ const o = n / t, c = n % t, l = s - r * o;+ n = t, t = c, s = r, r = l;+ }+ if (n !== Xt)+ throw new Error("invert: does not exist");+ return Qn(s, e);+}+function pN(i) {+ const e = (i - Xt) / lr;+ let t, n, s;+ for (t = i - Xt, n = 0; t % lr === mn; t /= lr, n++)+ ;+ for (s = lr; s < i && fN(s, e, i) !== i - Xt; s++)+ ;+ if (n === 1) {+ const a = (i + Xt) / Vd;+ return function(c, l) {+ const h = c.pow(l, a);+ if (!c.eql(c.sqr(h), l))+ throw new Error("Cannot find square root");+ return h;+ };+ }+ const r = (t + Xt) / lr;+ return function(o, c) {+ if (o.pow(c, e) === o.neg(o.ONE))+ throw new Error("Cannot find square root");+ let l = n, h = o.pow(o.mul(o.ONE, s), t), u = o.pow(c, r), d = o.pow(c, t);+ for (; !o.eql(d, o.ONE); ) {+ if (o.eql(d, o.ZERO))+ return o.ZERO;+ let f = 1;+ for (let A = o.sqr(d); f < l && !o.eql(A, o.ONE); f++)+ A = o.sqr(A);+ const m = o.pow(h, Xt << BigInt(l - f - 1));+ h = o.sqr(m), u = o.mul(u, m), d = o.mul(d, h), l = f;+ }+ return u;+ };+}+function AN(i) {+ if (i % Vd === dN) {+ const e = (i + Xt) / Vd;+ return function(n, s) {+ const r = n.pow(s, e);+ if (!n.eql(n.sqr(r), s))+ throw new Error("Cannot find square root");+ return r;+ };+ }+ if (i % Qg === Og) {+ const e = (i - Og) / Qg;+ return function(n, s) {+ const r = n.mul(s, lr), a = n.pow(r, e), o = n.mul(s, a), c = n.mul(n.mul(o, lr), a), l = n.mul(o, n.sub(c, n.ONE));+ if (!n.eql(n.sqr(l), s))+ throw new Error("Cannot find square root");+ return l;+ };+ }+ return pN(i);+}+const gN = [+ "create",+ "isValid",+ "is0",+ "neg",+ "inv",+ "sqrt",+ "sqr",+ "eql",+ "add",+ "sub",+ "mul",+ "pow",+ "div",+ "addN",+ "subN",+ "mulN",+ "sqrN"+];+function mN(i) {+ const e = {+ ORDER: "bigint",+ MASK: "bigint",+ BYTES: "isSafeInteger",+ BITS: "isSafeInteger"+ }, t = gN.reduce((n, s) => (n[s] = "function", n), e);+ return sc(i, t);+}+function bN(i, e, t) {+ if (t < mn)+ throw new Error("Expected power > 0");+ if (t === mn)+ return i.ONE;+ if (t === Xt)+ return e;+ let n = i.ONE, s = e;+ for (; t > mn; )+ t & Xt && (n = i.mul(n, s)), s = i.sqr(s), t >>= Xt;+ return n;+}+function xN(i, e) {+ const t = new Array(e.length), n = e.reduce((r, a, o) => i.is0(a) ? r : (t[o] = r, i.mul(r, a)), i.ONE), s = i.inv(n);+ return e.reduceRight((r, a, o) => i.is0(a) ? r : (t[o] = i.mul(r, t[o]), i.mul(r, a)), s), t;+}+function Yb(i, e) {+ const t = e !== void 0 ? e : i.toString(2).length, n = Math.ceil(t / 8);+ return { nBitLength: t, nByteLength: n };+}+function _N(i, e, t = !1, n = {}) {+ if (i <= mn)+ throw new Error(`Expected Field ORDER > 0, got ${i}`);+ const { nBitLength: s, nByteLength: r } = Yb(i, e);+ if (r > 2048)+ throw new Error("Field lengths over 2048 bytes are not supported");+ const a = AN(i), o = Object.freeze({+ ORDER: i,+ BITS: s,+ BYTES: r,+ MASK: ep(s),+ ZERO: mn,+ ONE: Xt,+ create: (c) => Qn(c, i),+ isValid: (c) => {+ if (typeof c != "bigint")+ throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);+ return mn <= c && c < i;+ },+ is0: (c) => c === mn,+ isOdd: (c) => (c & Xt) === Xt,+ neg: (c) => Qn(-c, i),+ eql: (c, l) => c === l,+ sqr: (c) => Qn(c * c, i),+ add: (c, l) => Qn(c + l, i),+ sub: (c, l) => Qn(c - l, i),+ mul: (c, l) => Qn(c * l, i),+ pow: (c, l) => bN(o, c, l),+ div: (c, l) => Qn(c * Wd(l, i), i),+ // Same as above, but doesn't normalize+ sqrN: (c) => c * c,+ addN: (c, l) => c + l,+ subN: (c, l) => c - l,+ mulN: (c, l) => c * l,+ inv: (c) => Wd(c, i),+ sqrt: n.sqrt || ((c) => a(o, c)),+ invertBatch: (c) => xN(o, c),+ // TODO: do we really need constant cmov?+ // We don't have const-time bigints anyway, so probably will be not very useful+ cmov: (c, l, h) => h ? l : c,+ toBytes: (c) => t ? $f(c, r) : Fa(c, r),+ fromBytes: (c) => {+ if (c.length !== r)+ throw new Error(`Fp.fromBytes: expected ${r}, got ${c.length}`);+ return t ? Zf(c) : br(c);+ }+ });+ return Object.freeze(o);+}+function Jb(i) {+ if (typeof i != "bigint")+ throw new Error("field order must be bigint");+ const e = i.toString(2).length;+ return Math.ceil(e / 8);+}+function Zb(i) {+ const e = Jb(i);+ return e + Math.ceil(e / 2);+}+function EN(i, e, t = !1) {+ const n = i.length, s = Jb(e), r = Zb(e);+ if (n < 16 || n < r || n > 1024)+ throw new Error(`expected ${r}-1024 bytes of input, got ${n}`);+ const a = t ? br(i) : Zf(i), o = Qn(a, e - Xt) + Xt;+ return t ? $f(o, s) : Fa(o, s);+}+const yN = BigInt(0), xu = BigInt(1);+function wN(i, e) {+ const t = (s, r) => {+ const a = r.negate();+ return s ? a : r;+ }, n = (s) => {+ const r = Math.ceil(e / s) + 1, a = 2 ** (s - 1);+ return { windows: r, windowSize: a };+ };+ return {+ constTimeNegate: t,+ // non-const time multiplication ladder+ unsafeLadder(s, r) {+ let a = i.ZERO, o = s;+ for (; r > yN; )+ r & xu && (a = a.add(o)), o = o.double(), r >>= xu;+ return a;+ },+ /**+ * Creates a wNAF precomputation window. Used for caching.+ * Default window size is set by `utils.precompute()` and is equal to 8.+ * Number of precomputed points depends on the curve size:+ * 2^(𝑊−1) * (Math.ceil(𝑛 / 𝑊) + 1), where:+ * - 𝑊 is the window size+ * - 𝑛 is the bitlength of the curve order.+ * For a 256-bit curve and window size 8, the number of precomputed points is 128 * 33 = 4224.+ * @returns precomputed point tables flattened to a single array+ */+ precomputeWindow(s, r) {+ const { windows: a, windowSize: o } = n(r), c = [];+ let l = s, h = l;+ for (let u = 0; u < a; u++) {+ h = l, c.push(h);+ for (let d = 1; d < o; d++)+ h = h.add(l), c.push(h);+ l = h.double();+ }+ return c;+ },+ /**+ * Implements ec multiplication using precomputed tables and w-ary non-adjacent form.+ * @param W window size+ * @param precomputes precomputed tables+ * @param n scalar (we don't check here, but should be less than curve order)+ * @returns real and fake (for const-time) points+ */+ wNAF(s, r, a) {+ const { windows: o, windowSize: c } = n(s);+ let l = i.ZERO, h = i.BASE;+ const u = BigInt(2 ** s - 1), d = 2 ** s, f = BigInt(s);+ for (let m = 0; m < o; m++) {+ const A = m * c;+ let g = Number(a & u);+ a >>= f, g > c && (g -= d, a += xu);+ const p = A, y = A + Math.abs(g) - 1, b = m % 2 !== 0, E = g < 0;+ g === 0 ? h = h.add(t(b, r[p])) : l = l.add(t(E, r[y]));+ }+ return { p: l, f: h };+ },+ wNAFCached(s, r, a, o) {+ const c = s._WINDOW_SIZE || 1;+ let l = r.get(s);+ return l || (l = this.precomputeWindow(s, c), c !== 1 && r.set(s, o(l))), this.wNAF(c, l, a);+ }+ };+}+function $b(i) {+ return mN(i.Fp), sc(i, {+ n: "bigint",+ h: "bigint",+ Gx: "field",+ Gy: "field"+ }, {+ nBitLength: "isSafeInteger",+ nByteLength: "isSafeInteger"+ }), Object.freeze({+ ...Yb(i.n, i.nBitLength),+ ...i,+ p: i.Fp.ORDER+ });+}+function vN(i) {+ const e = $b(i);+ sc(e, {+ a: "field",+ b: "field"+ }, {+ allowedPrivateKeyLengths: "array",+ wrapPrivateKey: "boolean",+ isTorsionFree: "function",+ clearCofactor: "function",+ allowInfinityPoint: "boolean",+ fromBytes: "function",+ toBytes: "function"+ });+ const { endo: t, Fp: n, a: s } = e;+ if (t) {+ if (!n.eql(s, n.ZERO))+ throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");+ if (typeof t != "object" || typeof t.beta != "bigint" || typeof t.splitScalar != "function")+ throw new Error("Expected endomorphism with beta: bigint and splitScalar: function");+ }+ return Object.freeze({ ...e });+}+const { bytesToNumberBE: CN, hexToBytes: SN } = uN, Ar = {+ // asn.1 DER encoding utils+ Err: class extends Error {+ constructor(e = "") {+ super(e);+ }+ },+ _parseInt(i) {+ const { Err: e } = Ar;+ if (i.length < 2 || i[0] !== 2)+ throw new e("Invalid signature integer tag");+ const t = i[1], n = i.subarray(2, t + 2);+ if (!t || n.length !== t)+ throw new e("Invalid signature integer: wrong length");+ if (n[0] & 128)+ throw new e("Invalid signature integer: negative");+ if (n[0] === 0 && !(n[1] & 128))+ throw new e("Invalid signature integer: unnecessary leading zero");+ return { d: CN(n), l: i.subarray(t + 2) };+ },+ toSig(i) {+ const { Err: e } = Ar, t = typeof i == "string" ? SN(i) : i;+ if (!(t instanceof Uint8Array))+ throw new Error("ui8a expected");+ let n = t.length;+ if (n < 2 || t[0] != 48)+ throw new e("Invalid signature tag");+ if (t[1] !== n - 2)+ throw new e("Invalid signature: incorrect length");+ const { d: s, l: r } = Ar._parseInt(t.subarray(2)), { d: a, l: o } = Ar._parseInt(r);+ if (o.length)+ throw new e("Invalid signature: left bytes after parsing");+ return { r: s, s: a };+ },+ hexFromSig(i) {+ const e = (l) => Number.parseInt(l[0], 16) & 8 ? "00" + l : l, t = (l) => {+ const h = l.toString(16);+ return h.length & 1 ? `0${h}` : h;+ }, n = e(t(i.s)), s = e(t(i.r)), r = n.length / 2, a = s.length / 2, o = t(r), c = t(a);+ return `30${t(a + r + 4)}02${c}${s}02${o}${n}`;+ }+}, es = BigInt(0), ei = BigInt(1);+BigInt(2);+const Gg = BigInt(3);+BigInt(4);+function IN(i) {+ const e = vN(i), { Fp: t } = e, n = e.toBytes || ((m, A, g) => {+ const p = A.toAffine();+ return zo(Uint8Array.from([4]), t.toBytes(p.x), t.toBytes(p.y));+ }), s = e.fromBytes || ((m) => {+ const A = m.subarray(1), g = t.fromBytes(A.subarray(0, t.BYTES)), p = t.fromBytes(A.subarray(t.BYTES, 2 * t.BYTES));+ return { x: g, y: p };+ });+ function r(m) {+ const { a: A, b: g } = e, p = t.sqr(m), y = t.mul(p, m);+ return t.add(t.add(y, t.mul(m, A)), g);+ }+ if (!t.eql(t.sqr(e.Gy), r(e.Gx)))+ throw new Error("bad generator point: equation left != right");+ function a(m) {+ return typeof m == "bigint" && es < m && m < e.n;+ }+ function o(m) {+ if (!a(m))+ throw new Error("Expected valid bigint: 0 < bigint < curve.n");+ }+ function c(m) {+ const { allowedPrivateKeyLengths: A, nByteLength: g, wrapPrivateKey: p, n: y } = e;+ if (A && typeof m != "bigint") {+ if (m instanceof Uint8Array && (m = Na(m)), typeof m != "string" || !A.includes(m.length))+ throw new Error("Invalid key");+ m = m.padStart(g * 2, "0");+ }+ let b;+ try {+ b = typeof m == "bigint" ? m : br(fi("private key", m, g));+ } catch {+ throw new Error(`private key must be ${g} bytes, hex or bigint, not ${typeof m}`);+ }+ return p && (b = Qn(b, y)), o(b), b;+ }+ const l = /* @__PURE__ */ new Map();+ function h(m) {+ if (!(m instanceof u))+ throw new Error("ProjectivePoint expected");+ }+ class u {+ constructor(A, g, p) {+ if (this.px = A, this.py = g, this.pz = p, A == null || !t.isValid(A))+ throw new Error("x required");+ if (g == null || !t.isValid(g))+ throw new Error("y required");+ if (p == null || !t.isValid(p))+ throw new Error("z required");+ }+ // Does not validate if the point is on-curve.+ // Use fromHex instead, or call assertValidity() later.+ static fromAffine(A) {+ const { x: g, y: p } = A || {};+ if (!A || !t.isValid(g) || !t.isValid(p))+ throw new Error("invalid affine point");+ if (A instanceof u)+ throw new Error("projective point not allowed");+ const y = (b) => t.eql(b, t.ZERO);+ return y(g) && y(p) ? u.ZERO : new u(g, p, t.ONE);+ }+ get x() {+ return this.toAffine().x;+ }+ get y() {+ return this.toAffine().y;+ }+ /**+ * Takes a bunch of Projective Points but executes only one+ * inversion on all of them. Inversion is very slow operation,+ * so this improves performance massively.+ * Optimization: converts a list of projective points to a list of identical points with Z=1.+ */+ static normalizeZ(A) {+ const g = t.invertBatch(A.map((p) => p.pz));+ return A.map((p, y) => p.toAffine(g[y])).map(u.fromAffine);+ }+ /**+ * Converts hash string or Uint8Array to Point.+ * @param hex short/long ECDSA hex+ */+ static fromHex(A) {+ const g = u.fromAffine(s(fi("pointHex", A)));+ return g.assertValidity(), g;+ }+ // Multiplies generator point by privateKey.+ static fromPrivateKey(A) {+ return u.BASE.multiply(c(A));+ }+ // "Private method", don't use it directly+ _setWindowSize(A) {+ this._WINDOW_SIZE = A, l.delete(this);+ }+ // A point on curve is valid if it conforms to equation.+ assertValidity() {+ if (this.is0()) {+ if (e.allowInfinityPoint && !t.is0(this.py))+ return;+ throw new Error("bad point: ZERO");+ }+ const { x: A, y: g } = this.toAffine();+ if (!t.isValid(A) || !t.isValid(g))+ throw new Error("bad point: x or y not FE");+ const p = t.sqr(g), y = r(A);+ if (!t.eql(p, y))+ throw new Error("bad point: equation left != right");+ if (!this.isTorsionFree())+ throw new Error("bad point: not in prime-order subgroup");+ }+ hasEvenY() {+ const { y: A } = this.toAffine();+ if (t.isOdd)+ return !t.isOdd(A);+ throw new Error("Field doesn't support isOdd");+ }+ /**+ * Compare one point to another.+ */+ equals(A) {+ h(A);+ const { px: g, py: p, pz: y } = this, { px: b, py: E, pz: M } = A, w = t.eql(t.mul(g, M), t.mul(b, y)), S = t.eql(t.mul(p, M), t.mul(E, y));+ return w && S;+ }+ /**+ * Flips point to one corresponding to (x, -y) in Affine coordinates.+ */+ negate() {+ return new u(this.px, t.neg(this.py), this.pz);+ }+ // Renes-Costello-Batina exception-free doubling formula.+ // There is 30% faster Jacobian formula, but it is not complete.+ // https://eprint.iacr.org/2015/1060, algorithm 3+ // Cost: 8M + 3S + 3*a + 2*b3 + 15add.+ double() {+ const { a: A, b: g } = e, p = t.mul(g, Gg), { px: y, py: b, pz: E } = this;+ let M = t.ZERO, w = t.ZERO, S = t.ZERO, T = t.mul(y, y), C = t.mul(b, b), v = t.mul(E, E), F = t.mul(y, b);+ return F = t.add(F, F), S = t.mul(y, E), S = t.add(S, S), M = t.mul(A, S), w = t.mul(p, v), w = t.add(M, w), M = t.sub(C, w), w = t.add(C, w), w = t.mul(M, w), M = t.mul(F, M), S = t.mul(p, S), v = t.mul(A, v), F = t.sub(T, v), F = t.mul(A, F), F = t.add(F, S), S = t.add(T, T), T = t.add(S, T), T = t.add(T, v), T = t.mul(T, F), w = t.add(w, T), v = t.mul(b, E), v = t.add(v, v), T = t.mul(v, F), M = t.sub(M, T), S = t.mul(v, C), S = t.add(S, S), S = t.add(S, S), new u(M, w, S);+ }+ // Renes-Costello-Batina exception-free addition formula.+ // There is 30% faster Jacobian formula, but it is not complete.+ // https://eprint.iacr.org/2015/1060, algorithm 1+ // Cost: 12M + 0S + 3*a + 3*b3 + 23add.+ add(A) {+ h(A);+ const { px: g, py: p, pz: y } = this, { px: b, py: E, pz: M } = A;+ let w = t.ZERO, S = t.ZERO, T = t.ZERO;+ const C = e.a, v = t.mul(e.b, Gg);+ let F = t.mul(g, b), K = t.mul(p, E), q = t.mul(y, M), $ = t.add(g, p), D = t.add(b, E);+ $ = t.mul($, D), D = t.add(F, K), $ = t.sub($, D), D = t.add(g, y);+ let O = t.add(b, M);+ return D = t.mul(D, O), O = t.add(F, q), D = t.sub(D, O), O = t.add(p, y), w = t.add(E, M), O = t.mul(O, w), w = t.add(K, q), O = t.sub(O, w), T = t.mul(C, D), w = t.mul(v, q), T = t.add(w, T), w = t.sub(K, T), T = t.add(K, T), S = t.mul(w, T), K = t.add(F, F), K = t.add(K, F), q = t.mul(C, q), D = t.mul(v, D), K = t.add(K, q), q = t.sub(F, q), q = t.mul(C, q), D = t.add(D, q), F = t.mul(K, D), S = t.add(S, F), F = t.mul(O, D), w = t.mul($, w), w = t.sub(w, F), F = t.mul($, K), T = t.mul(O, T), T = t.add(T, F), new u(w, S, T);+ }+ subtract(A) {+ return this.add(A.negate());+ }+ is0() {+ return this.equals(u.ZERO);+ }+ wNAF(A) {+ return f.wNAFCached(this, l, A, (g) => {+ const p = t.invertBatch(g.map((y) => y.pz));+ return g.map((y, b) => y.toAffine(p[b])).map(u.fromAffine);+ });+ }+ /**+ * Non-constant-time multiplication. Uses double-and-add algorithm.+ * It's faster, but should only be used when you don't care about+ * an exposed private key e.g. sig verification, which works over *public* keys.+ */+ multiplyUnsafe(A) {+ const g = u.ZERO;+ if (A === es)+ return g;+ if (o(A), A === ei)+ return this;+ const { endo: p } = e;+ if (!p)+ return f.unsafeLadder(this, A);+ let { k1neg: y, k1: b, k2neg: E, k2: M } = p.splitScalar(A), w = g, S = g, T = this;+ for (; b > es || M > es; )+ b & ei && (w = w.add(T)), M & ei && (S = S.add(T)), T = T.double(), b >>= ei, M >>= ei;+ return y && (w = w.negate()), E && (S = S.negate()), S = new u(t.mul(S.px, p.beta), S.py, S.pz), w.add(S);+ }+ /**+ * Constant time multiplication.+ * Uses wNAF method. Windowed method may be 10% faster,+ * but takes 2x longer to generate and consumes 2x memory.+ * Uses precomputes when available.+ * Uses endomorphism for Koblitz curves.+ * @param scalar by which the point would be multiplied+ * @returns New point+ */+ multiply(A) {+ o(A);+ let g = A, p, y;+ const { endo: b } = e;+ if (b) {+ const { k1neg: E, k1: M, k2neg: w, k2: S } = b.splitScalar(g);+ let { p: T, f: C } = this.wNAF(M), { p: v, f: F } = this.wNAF(S);+ T = f.constTimeNegate(E, T), v = f.constTimeNegate(w, v), v = new u(t.mul(v.px, b.beta), v.py, v.pz), p = T.add(v), y = C.add(F);+ } else {+ const { p: E, f: M } = this.wNAF(g);+ p = E, y = M;+ }+ return u.normalizeZ([p, y])[0];+ }+ /**+ * Efficiently calculate `aP + bQ`. Unsafe, can expose private key, if used incorrectly.+ * Not using Strauss-Shamir trick: precomputation tables are faster.+ * The trick could be useful if both P and Q are not G (not in our case).+ * @returns non-zero affine point+ */+ multiplyAndAddUnsafe(A, g, p) {+ const y = u.BASE, b = (M, w) => w === es || w === ei || !M.equals(y) ? M.multiplyUnsafe(w) : M.multiply(w), E = b(this, g).add(b(A, p));+ return E.is0() ? void 0 : E;+ }+ // Converts Projective point to affine (x, y) coordinates.+ // Can accept precomputed Z^-1 - for example, from invertBatch.+ // (x, y, z) ∋ (x=x/z, y=y/z)+ toAffine(A) {+ const { px: g, py: p, pz: y } = this, b = this.is0();+ A == null && (A = b ? t.ONE : t.inv(y));+ const E = t.mul(g, A), M = t.mul(p, A), w = t.mul(y, A);+ if (b)+ return { x: t.ZERO, y: t.ZERO };+ if (!t.eql(w, t.ONE))+ throw new Error("invZ was invalid");+ return { x: E, y: M };+ }+ isTorsionFree() {+ const { h: A, isTorsionFree: g } = e;+ if (A === ei)+ return !0;+ if (g)+ return g(u, this);+ throw new Error("isTorsionFree() has not been declared for the elliptic curve");+ }+ clearCofactor() {+ const { h: A, clearCofactor: g } = e;+ return A === ei ? this : g ? g(u, this) : this.multiplyUnsafe(e.h);+ }+ toRawBytes(A = !0) {+ return this.assertValidity(), n(u, this, A);+ }+ toHex(A = !0) {+ return Na(this.toRawBytes(A));+ }+ }+ u.BASE = new u(e.Gx, e.Gy, t.ONE), u.ZERO = new u(t.ZERO, t.ONE, t.ZERO);+ const d = e.nBitLength, f = wN(u, e.endo ? Math.ceil(d / 2) : d);+ return {+ CURVE: e,+ ProjectivePoint: u,+ normPrivateKeyToScalar: c,+ weierstrassEquation: r,+ isWithinCurveOrder: a+ };+}+function MN(i) {+ const e = $b(i);+ return sc(e, {+ hash: "hash",+ hmac: "function",+ randomBytes: "function"+ }, {+ bits2int: "function",+ bits2int_modN: "function",+ lowS: "boolean"+ }), Object.freeze({ lowS: !0, ...e });+}+function BN(i) {+ const e = MN(i), { Fp: t, n } = e, s = t.BYTES + 1, r = 2 * t.BYTES + 1;+ function a(D) {+ return es < D && D < t.ORDER;+ }+ function o(D) {+ return Qn(D, n);+ }+ function c(D) {+ return Wd(D, n);+ }+ const { ProjectivePoint: l, normPrivateKeyToScalar: h, weierstrassEquation: u, isWithinCurveOrder: d } = IN({+ ...e,+ toBytes(D, O, Y) {+ const Q = O.toAffine(), J = t.toBytes(Q.x), ee = zo;+ return Y ? ee(Uint8Array.from([O.hasEvenY() ? 2 : 3]), J) : ee(Uint8Array.from([4]), J, t.toBytes(Q.y));+ },+ fromBytes(D) {+ const O = D.length, Y = D[0], Q = D.subarray(1);+ if (O === s && (Y === 2 || Y === 3)) {+ const J = br(Q);+ if (!a(J))+ throw new Error("Point is not on curve");+ const ee = u(J);+ let ae = t.sqrt(ee);+ const ye = (ae & ei) === ei;+ return (Y & 1) === 1 !== ye && (ae = t.neg(ae)), { x: J, y: ae };+ } else if (O === r && Y === 4) {+ const J = t.fromBytes(Q.subarray(0, t.BYTES)), ee = t.fromBytes(Q.subarray(t.BYTES, 2 * t.BYTES));+ return { x: J, y: ee };+ } else+ throw new Error(`Point of length ${O} was invalid. Expected ${s} compressed bytes or ${r} uncompressed bytes`);+ }+ }), f = (D) => Na(Fa(D, e.nByteLength));+ function m(D) {+ const O = n >> ei;+ return D > O;+ }+ function A(D) {+ return m(D) ? o(-D) : D;+ }+ const g = (D, O, Y) => br(D.slice(O, Y));+ class p {+ constructor(O, Y, Q) {+ this.r = O, this.s = Y, this.recovery = Q, this.assertValidity();+ }+ // pair (bytes of r, bytes of s)+ static fromCompact(O) {+ const Y = e.nByteLength;+ return O = fi("compactSignature", O, Y * 2), new p(g(O, 0, Y), g(O, Y, 2 * Y));+ }+ // DER encoded ECDSA signature+ // https://bitcoin.stackexchange.com/questions/57644/what-are-the-parts-of-a-bitcoin-transaction-input-script+ static fromDER(O) {+ const { r: Y, s: Q } = Ar.toSig(fi("DER", O));+ return new p(Y, Q);+ }+ assertValidity() {+ if (!d(this.r))+ throw new Error("r must be 0 < r < CURVE.n");+ if (!d(this.s))+ throw new Error("s must be 0 < s < CURVE.n");+ }+ addRecoveryBit(O) {+ return new p(this.r, this.s, O);+ }+ recoverPublicKey(O) {+ const { r: Y, s: Q, recovery: J } = this, ee = S(fi("msgHash", O));+ if (J == null || ![0, 1, 2, 3].includes(J))+ throw new Error("recovery id invalid");+ const ae = J === 2 || J === 3 ? Y + e.n : Y;+ if (ae >= t.ORDER)+ throw new Error("recovery id 2 or 3 invalid");+ const ye = (J & 1) === 0 ? "02" : "03", Me = l.fromHex(ye + f(ae)), se = c(ae), me = o(-ee * se), be = o(Q * se), xe = l.BASE.multiplyAndAddUnsafe(Me, me, be);+ if (!xe)+ throw new Error("point at infinify");+ return xe.assertValidity(), xe;+ }+ // Signatures should be low-s, to prevent malleability.+ hasHighS() {+ return m(this.s);+ }+ normalizeS() {+ return this.hasHighS() ? new p(this.r, o(-this.s), this.recovery) : this;+ }+ // DER-encoded+ toDERRawBytes() {+ return Ho(this.toDERHex());+ }+ toDERHex() {+ return Ar.hexFromSig({ r: this.r, s: this.s });+ }+ // padded bytes of r, then padded bytes of s+ toCompactRawBytes() {+ return Ho(this.toCompactHex());+ }+ toCompactHex() {+ return f(this.r) + f(this.s);+ }+ }+ const y = {+ isValidPrivateKey(D) {+ try {+ return h(D), !0;+ } catch {+ return !1;+ }+ },+ normPrivateKeyToScalar: h,+ /**+ * Produces cryptographically secure private key from random of size+ * (groupLen + ceil(groupLen / 2)) with modulo bias being negligible.+ */+ randomPrivateKey: () => {+ const D = Zb(e.n);+ return EN(e.randomBytes(D), e.n);+ },+ /**+ * Creates precompute table for an arbitrary EC point. Makes point "cached".+ * Allows to massively speed-up `point.multiply(scalar)`.+ * @returns cached point+ * @example+ * const fast = utils.precompute(8, ProjectivePoint.fromHex(someonesPubKey));+ * fast.multiply(privKey); // much faster ECDH now+ */+ precompute(D = 8, O = l.BASE) {+ return O._setWindowSize(D), O.multiply(BigInt(3)), O;+ }+ };+ function b(D, O = !0) {+ return l.fromPrivateKey(D).toRawBytes(O);+ }+ function E(D) {+ const O = D instanceof Uint8Array, Y = typeof D == "string", Q = (O || Y) && D.length;+ return O ? Q === s || Q === r : Y ? Q === 2 * s || Q === 2 * r : D instanceof l;+ }+ function M(D, O, Y = !0) {+ if (E(D))+ throw new Error("first arg must be private key");+ if (!E(O))+ throw new Error("second arg must be public key");+ return l.fromHex(O).multiply(h(D)).toRawBytes(Y);+ }+ const w = e.bits2int || function(D) {+ const O = br(D), Y = D.length * 8 - e.nBitLength;+ return Y > 0 ? O >> BigInt(Y) : O;+ }, S = e.bits2int_modN || function(D) {+ return o(w(D));+ }, T = ep(e.nBitLength);+ function C(D) {+ if (typeof D != "bigint")+ throw new Error("bigint expected");+ if (!(es <= D && D < T))+ throw new Error(`bigint expected < 2^${e.nBitLength}`);+ return Fa(D, e.nByteLength);+ }+ function v(D, O, Y = F) {+ if (["recovered", "canonical"].some(($e) => $e in Y))+ throw new Error("sign() legacy options not supported");+ const { hash: Q, randomBytes: J } = e;+ let { lowS: ee, prehash: ae, extraEntropy: ye } = Y;+ ee == null && (ee = !0), D = fi("msgHash", D), ae && (D = fi("prehashed msgHash", Q(D)));+ const Me = S(D), se = h(O), me = [C(se), C(Me)];+ if (ye != null) {+ const $e = ye === !0 ? J(t.BYTES) : ye;+ me.push(fi("extraEntropy", $e));+ }+ const be = zo(...me), xe = Me;+ function Pe($e) {+ const Qe = w($e);+ if (!d(Qe))+ return;+ const vt = c(Qe), lt = l.BASE.multiply(Qe).toAffine(), Je = o(lt.x);+ if (Je === es)+ return;+ const G = o(vt * o(xe + Je * se));+ if (G === es)+ return;+ let dn = (lt.x === Je ? 0 : 2) | Number(lt.y & ei), dt = G;+ return ee && m(G) && (dt = A(G), dn ^= 1), new p(Je, dt, dn);+ }+ return { seed: be, k2sig: Pe };+ }+ const F = { lowS: e.lowS, prehash: !1 }, K = { lowS: e.lowS, prehash: !1 };+ function q(D, O, Y = F) {+ const { seed: Q, k2sig: J } = v(D, O, Y), ee = e;+ return Xb(ee.hash.outputLen, ee.nByteLength, ee.hmac)(Q, J);+ }+ l.BASE._setWindowSize(8);+ function $(D, O, Y, Q = K) {+ const J = D;+ if (O = fi("msgHash", O), Y = fi("publicKey", Y), "strict" in Q)+ throw new Error("options.strict was renamed to lowS");+ const { lowS: ee, prehash: ae } = Q;+ let ye, Me;+ try {+ if (typeof J == "string" || J instanceof Uint8Array)+ try {+ ye = p.fromDER(J);+ } catch (lt) {+ if (!(lt instanceof Ar.Err))+ throw lt;+ ye = p.fromCompact(J);+ }+ else if (typeof J == "object" && typeof J.r == "bigint" && typeof J.s == "bigint") {+ const { r: lt, s: Je } = J;+ ye = new p(lt, Je);+ } else+ throw new Error("PARSE");+ Me = l.fromHex(Y);+ } catch (lt) {+ if (lt.message === "PARSE")+ throw new Error("signature must be Signature instance, Uint8Array or hex string");+ return !1;+ }+ if (ee && ye.hasHighS())+ return !1;+ ae && (O = e.hash(O));+ const { r: se, s: me } = ye, be = S(O), xe = c(me), Pe = o(be * xe), $e = o(se * xe), Qe = l.BASE.multiplyAndAddUnsafe(Me, Pe, $e)?.toAffine();+ return Qe ? o(Qe.x) === se : !1;+ }+ return {+ CURVE: e,+ getPublicKey: b,+ getSharedSecret: M,+ sign: q,+ verify: $,+ ProjectivePoint: l,+ Signature: p,+ utils: y+ };+}+function TN(i) {+ return {+ hash: i,+ hmac: (e, ...t) => Rb(i, e, yR(...t)),+ randomBytes: wR+ };+}+function RN(i, e) {+ const t = (n) => BN({ ...i, ...TN(n) });+ return Object.freeze({ ...t(e), create: t });+}+const ex = BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"), Hg = BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"), NN = BigInt(1), qd = BigInt(2), zg = (i, e) => (i + e / qd) / e;+function FN(i) {+ const e = ex, t = BigInt(3), n = BigInt(6), s = BigInt(11), r = BigInt(22), a = BigInt(23), o = BigInt(44), c = BigInt(88), l = i * i * i % e, h = l * l * i % e, u = Zn(h, t, e) * h % e, d = Zn(u, t, e) * h % e, f = Zn(d, qd, e) * l % e, m = Zn(f, s, e) * f % e, A = Zn(m, r, e) * m % e, g = Zn(A, o, e) * A % e, p = Zn(g, c, e) * g % e, y = Zn(p, o, e) * A % e, b = Zn(y, t, e) * h % e, E = Zn(b, a, e) * m % e, M = Zn(E, n, e) * l % e, w = Zn(M, qd, e);+ if (!Kd.eql(Kd.sqr(w), i))+ throw new Error("Cannot find square root");+ return w;+}+const Kd = _N(ex, void 0, void 0, { sqrt: FN }), Ts = RN({+ a: BigInt(0),+ b: BigInt(7),+ Fp: Kd,+ n: Hg,+ // Base point (x, y) aka generator point+ Gx: BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),+ Gy: BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),+ h: BigInt(1),+ lowS: !0,+ /**+ * secp256k1 belongs to Koblitz curves: it has efficiently computable endomorphism.+ * Endomorphism uses 2x less RAM, speeds up precomputation by 2x and ECDH / key recovery by 20%.+ * For precomputed wNAF it trades off 1/2 init time & 1/3 ram for 20% perf hit.+ * Explanation: https://gist.github.com/paulmillr/eb670806793e84df628a7c434a873066+ */+ endo: {+ beta: BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),+ splitScalar: (i) => {+ const e = Hg, t = BigInt("0x3086d221a7d46bcde86c90e49284eb15"), n = -NN * BigInt("0xe4437ed6010e88286f547fa90abfe4c3"), s = BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"), r = t, a = BigInt("0x100000000000000000000000000000000"), o = zg(r * i, e), c = zg(-n * i, e);+ let l = Qn(i - o * t - c * s, e), h = Qn(-o * n - c * r, e);+ const u = l > a, d = h > a;+ if (u && (l = e - l), d && (h = e - h), l > a || h > a)+ throw new Error("splitScalar: Endomorphism failed, k=" + i);+ return { k1neg: u, k1: l, k2neg: d, k2: h };+ }+ }+}, Fb);+BigInt(0);+Ts.ProjectivePoint;+const Vo = "0x0000000000000000000000000000000000000000", Vg = "0x0000000000000000000000000000000000000000000000000000000000000000", Wg = BigInt(0), qg = BigInt(1), jd = BigInt(2), Kg = BigInt(27), jg = BigInt(28), sl = BigInt(35), tx = BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"), DN = tx / jd, LN = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom"), tr = {};+function _u(i) {+ return ds($t(i), 32);+}+class Gt {+ #e;+ #t;+ #n;+ #i;+ /**+ * The ``r`` value for a signature.+ *+ * This represents the ``x`` coordinate of a "reference" or+ * challenge point, from which the ``y`` can be computed.+ */+ get r() {+ return this.#e;+ }+ set r(e) {+ V(xa(e) === 32, "invalid r", "value", e), this.#e = Se(e);+ }+ /**+ * The ``s`` value for a signature.+ */+ get s() {+ return V(parseInt(this.#t.substring(0, 3)) < 8, "non-canonical s; use ._s", "s", this.#t), this.#t;+ }+ set s(e) {+ V(xa(e) === 32, "invalid s", "value", e), this.#t = Se(e);+ }+ /**+ * Return the s value, unchecked for EIP-2 compliance.+ *+ * This should generally not be used and is for situations where+ * a non-canonical S value might be relevant, such as Frontier blocks+ * that were mined prior to EIP-2 or invalid Authorization List+ * signatures.+ */+ get _s() {+ return this.#t;+ }+ /**+ * Returns true if the Signature is valid for [[link-eip-2]] signatures.+ */+ isValid() {+ return BigInt(this.#t) <= DN;+ }+ /**+ * The ``v`` value for a signature.+ *+ * Since a given ``x`` value for ``r`` has two possible values for+ * its correspondin ``y``, the ``v`` indicates which of the two ``y``+ * values to use.+ *+ * It is normalized to the values ``27`` or ``28`` for legacy+ * purposes.+ */+ get v() {+ return this.#n;+ }+ set v(e) {+ const t = ut(e, "value");+ V(t === 27 || t === 28, "invalid v", "v", e), this.#n = t;+ }+ /**+ * The EIP-155 ``v`` for legacy transactions. For non-legacy+ * transactions, this value is ``null``.+ */+ get networkV() {+ return this.#i;+ }+ /**+ * The chain ID for EIP-155 legacy transactions. For non-legacy+ * transactions, this value is ``null``.+ */+ get legacyChainId() {+ const e = this.networkV;+ return e == null ? null : Gt.getChainId(e);+ }+ /**+ * The ``yParity`` for the signature.+ *+ * See ``v`` for more details on how this value is used.+ */+ get yParity() {+ return this.v === 27 ? 0 : 1;+ }+ /**+ * The [[link-eip-2098]] compact representation of the ``yParity``+ * and ``s`` compacted into a single ``bytes32``.+ */+ get yParityAndS() {+ const e = ht(this.s);+ return this.yParity && (e[0] |= 128), Se(e);+ }+ /**+ * The [[link-eip-2098]] compact representation.+ */+ get compactSerialized() {+ return Qt([this.r, this.yParityAndS]);+ }+ /**+ * The serialized representation.+ */+ get serialized() {+ return Qt([this.r, this.s, this.yParity ? "0x1c" : "0x1b"]);+ }+ /**+ * @private+ */+ constructor(e, t, n, s) {+ sh(e, tr, "Signature"), this.#e = t, this.#t = n, this.#n = s, this.#i = null;+ }+ /**+ * Returns the canonical signature.+ *+ * This is only necessary when dealing with legacy transaction which+ * did not enforce canonical S values (i.e. [[link-eip-2]]. Most+ * developers should never require this.+ */+ getCanonical() {+ if (this.isValid())+ return this;+ const e = tx - BigInt(this._s), t = 55 - this.v, n = new Gt(tr, this.r, _u(e), t);+ return this.networkV && (n.#i = this.networkV), n;+ }+ /**+ * Returns a new identical [[Signature]].+ */+ clone() {+ const e = new Gt(tr, this.r, this._s, this.v);+ return this.networkV && (e.#i = this.networkV), e;+ }+ /**+ * Returns a representation that is compatible with ``JSON.stringify``.+ */+ toJSON() {+ const e = this.networkV;+ return {+ _type: "signature",+ networkV: e != null ? e.toString() : null,+ r: this.r,+ s: this._s,+ v: this.v+ };+ }+ [LN]() {+ return this.toString();+ }+ toString() {+ return this.isValid() ? `Signature { r: ${this.r}, s: ${this._s}, v: ${this.v} }` : `Signature { r: ${this.r}, s: ${this._s}, v: ${this.v}, valid: false }`;+ }+ /**+ * Compute the chain ID from the ``v`` in a legacy EIP-155 transactions.+ *+ * @example:+ * Signature.getChainId(45)+ * //_result:+ *+ * Signature.getChainId(46)+ * //_result:+ */+ static getChainId(e) {+ const t = Fe(e, "v");+ return t == Kg || t == jg ? Wg : (V(t >= sl, "invalid EIP-155 v", "v", e), (t - sl) / jd);+ }+ /**+ * Compute the ``v`` for a chain ID for a legacy EIP-155 transactions.+ *+ * Legacy transactions which use [[link-eip-155]] hijack the ``v``+ * property to include the chain ID.+ *+ * @example:+ * Signature.getChainIdV(5, 27)+ * //_result:+ *+ * Signature.getChainIdV(5, 28)+ * //_result:+ *+ */+ static getChainIdV(e, t) {+ return Fe(e) * jd + BigInt(35 + t - 27);+ }+ /**+ * Compute the normalized legacy transaction ``v`` from a ``yParirty``,+ * a legacy transaction ``v`` or a legacy [[link-eip-155]] transaction.+ *+ * @example:+ * // The values 0 and 1 imply v is actually yParity+ * Signature.getNormalizedV(0)+ * //_result:+ *+ * // Legacy non-EIP-1559 transaction (i.e. 27 or 28)+ * Signature.getNormalizedV(27)+ * //_result:+ *+ * // Legacy EIP-155 transaction (i.e. >= 35)+ * Signature.getNormalizedV(46)+ * //_result:+ *+ * // Invalid values throw+ * Signature.getNormalizedV(5)+ * //_error:+ */+ static getNormalizedV(e) {+ const t = Fe(e);+ return t === Wg || t === Kg ? 27 : t === qg || t === jg ? 28 : (V(t >= sl, "invalid v", "v", e), t & qg ? 27 : 28);+ }+ /**+ * Creates a new [[Signature]].+ *+ * If no %%sig%% is provided, a new [[Signature]] is created+ * with default values.+ *+ * If %%sig%% is a string, it is parsed.+ */+ static from(e) {+ function t(l, h) {+ V(l, h, "signature", e);+ }+ if (e == null)+ return new Gt(tr, Vg, Vg, 27);+ if (typeof e == "string") {+ const l = ht(e, "signature");+ if (l.length === 64) {+ const h = Se(l.slice(0, 32)), u = l.slice(32, 64), d = u[0] & 128 ? 28 : 27;+ return u[0] &= 127, new Gt(tr, h, Se(u), d);+ }+ if (l.length === 65) {+ const h = Se(l.slice(0, 32)), u = Se(l.slice(32, 64)), d = Gt.getNormalizedV(l[64]);+ return new Gt(tr, h, u, d);+ }+ t(!1, "invalid raw signature length");+ }+ if (e instanceof Gt)+ return e.clone();+ const n = e.r;+ t(n != null, "missing r");+ const s = _u(n), r = (function(l, h) {+ if (l != null)+ return _u(l);+ if (h != null) {+ t(Lt(h, 32), "invalid yParityAndS");+ const u = ht(h);+ return u[0] &= 127, Se(u);+ }+ t(!1, "missing s");+ })(e.s, e.yParityAndS), { networkV: a, v: o } = (function(l, h, u) {+ if (l != null) {+ const d = Fe(l);+ return {+ networkV: d >= sl ? d : void 0,+ v: Gt.getNormalizedV(d)+ };+ }+ if (h != null)+ return t(Lt(h, 32), "invalid yParityAndS"), { v: ht(h)[0] & 128 ? 28 : 27 };+ if (u != null) {+ switch (ut(u, "sig.yParity")) {+ case 0:+ return { v: 27 };+ case 1:+ return { v: 28 };+ }+ t(!1, "invalid yParity");+ }+ t(!1, "missing v");+ })(e.v, e.yParityAndS, e.yParity), c = new Gt(tr, s, r, o);+ return a && (c.#i = a), t(e.yParity == null || ut(e.yParity, "sig.yParity") === c.yParity, "yParity mismatch"), t(e.yParityAndS == null || e.yParityAndS === c.yParityAndS, "yParityAndS mismatch"), c;+ }+}+class ts {+ #e;+ /**+ * Creates a new **SigningKey** for %%privateKey%%.+ */+ constructor(e) {+ V(xa(e) === 32, "invalid private key", "privateKey", "[REDACTED]"), this.#e = Se(e);+ }+ /**+ * The private key.+ */+ get privateKey() {+ return this.#e;+ }+ /**+ * The uncompressed public key.+ *+ * This will always begin with the prefix ``0x04`` and be 132+ * characters long (the ``0x`` prefix and 130 hexadecimal nibbles).+ */+ get publicKey() {+ return ts.computePublicKey(this.#e);+ }+ /**+ * The compressed public key.+ *+ * This will always begin with either the prefix ``0x02`` or ``0x03``+ * and be 68 characters long (the ``0x`` prefix and 33 hexadecimal+ * nibbles)+ */+ get compressedPublicKey() {+ return ts.computePublicKey(this.#e, !0);+ }+ /**+ * Return the signature of the signed %%digest%%.+ */+ sign(e) {+ V(xa(e) === 32, "invalid digest length", "digest", e);+ const t = Ts.sign(Rn(e), Rn(this.#e), {+ lowS: !0+ });+ return Gt.from({+ r: Hs(t.r, 32),+ s: Hs(t.s, 32),+ v: t.recovery ? 28 : 27+ });+ }+ /**+ * Returns the [[link-wiki-ecdh]] shared secret between this+ * private key and the %%other%% key.+ *+ * The %%other%% key may be any type of key, a raw public key,+ * a compressed/uncompressed pubic key or aprivate key.+ *+ * Best practice is usually to use a cryptographic hash on the+ * returned value before using it as a symetric secret.+ *+ * @example:+ * sign1 = new SigningKey(id("some-secret-1"))+ * sign2 = new SigningKey(id("some-secret-2"))+ *+ * // Notice that privA.computeSharedSecret(pubB)...+ * sign1.computeSharedSecret(sign2.publicKey)+ * //_result:+ *+ * // ...is equal to privB.computeSharedSecret(pubA).+ * sign2.computeSharedSecret(sign1.publicKey)+ * //_result:+ */+ computeSharedSecret(e) {+ const t = ts.computePublicKey(e);+ return Se(Ts.getSharedSecret(Rn(this.#e), ht(t), !1));+ }+ /**+ * Compute the public key for %%key%%, optionally %%compressed%%.+ *+ * The %%key%% may be any type of key, a raw public key, a+ * compressed/uncompressed public key or private key.+ *+ * @example:+ * sign = new SigningKey(id("some-secret"));+ *+ * // Compute the uncompressed public key for a private key+ * SigningKey.computePublicKey(sign.privateKey)+ * //_result:+ *+ * // Compute the compressed public key for a private key+ * SigningKey.computePublicKey(sign.privateKey, true)+ * //_result:+ *+ * // Compute the uncompressed public key+ * SigningKey.computePublicKey(sign.publicKey, false);+ * //_result:+ *+ * // Compute the Compressed a public key+ * SigningKey.computePublicKey(sign.publicKey, true);+ * //_result:+ */+ static computePublicKey(e, t) {+ let n = ht(e, "key");+ if (n.length === 32) {+ const r = Ts.getPublicKey(n, !!t);+ return Se(r);+ }+ if (n.length === 64) {+ const r = new Uint8Array(65);+ r[0] = 4, r.set(n, 1), n = r;+ }+ const s = Ts.ProjectivePoint.fromHex(n);+ return Se(s.toRawBytes(t));+ }+ /**+ * Returns the public key for the private key which produced the+ * %%signature%% for the given %%digest%%.+ *+ * @example:+ * key = new SigningKey(id("some-secret"))+ * digest = id("hello world")+ * sig = key.sign(digest)+ *+ * // Notice the signer public key...+ * key.publicKey+ * //_result:+ *+ * // ...is equal to the recovered public key+ * SigningKey.recoverPublicKey(digest, sig)+ * //_result:+ *+ */+ static recoverPublicKey(e, t) {+ V(xa(e) === 32, "invalid digest length", "digest", e);+ const n = Gt.from(t);+ let s = Ts.Signature.fromCompact(Rn(Qt([n.r, n.s])));+ s = s.addRecoveryBit(n.yParity);+ const r = s.recoverPublicKey(Rn(e));+ return V(r != null, "invalid signature for digest", "signature", t), "0x" + r.toHex(!1);+ }+ /**+ * Returns the point resulting from adding the ellipic curve points+ * %%p0%% and %%p1%%.+ *+ * This is not a common function most developers should require, but+ * can be useful for certain privacy-specific techniques.+ *+ * For example, it is used by [[HDNodeWallet]] to compute child+ * addresses from parent public keys and chain codes.+ */+ static addPoints(e, t, n) {+ const s = Ts.ProjectivePoint.fromHex(ts.computePublicKey(e).substring(2)), r = Ts.ProjectivePoint.fromHex(ts.computePublicKey(t).substring(2));+ return "0x" + s.add(r).toHex(!!n);+ }+}+const PN = BigInt(0), kN = BigInt(36);+function Xg(i) {+ i = i.toLowerCase();+ const e = i.substring(2).split(""), t = new Uint8Array(40);+ for (let s = 0; s < 40; s++)+ t[s] = e[s].charCodeAt(0);+ const n = ht(Zt(t));+ for (let s = 0; s < 40; s += 2)+ n[s >> 1] >> 4 >= 8 && (e[s] = e[s].toUpperCase()), (n[s >> 1] & 15) >= 8 && (e[s + 1] = e[s + 1].toUpperCase());+ return "0x" + e.join("");+}+const tp = {};+for (let i = 0; i < 10; i++)+ tp[String(i)] = String(i);+for (let i = 0; i < 26; i++)+ tp[String.fromCharCode(65 + i)] = String(10 + i);+const Yg = 15;+function UN(i) {+ i = i.toUpperCase(), i = i.substring(4) + i.substring(0, 2) + "00";+ let e = i.split("").map((n) => tp[n]).join("");+ for (; e.length >= Yg; ) {+ let n = e.substring(0, Yg);+ e = parseInt(n, 10) % 97 + e.substring(n.length);+ }+ let t = String(98 - parseInt(e, 10) % 97);+ for (; t.length < 2; )+ t = "0" + t;+ return t;+}+const ON = (function() {+ const i = {};+ for (let e = 0; e < 36; e++) {+ const t = "0123456789abcdefghijklmnopqrstuvwxyz"[e];+ i[t] = BigInt(e);+ }+ return i;+})();+function QN(i) {+ i = i.toLowerCase();+ let e = PN;+ for (let t = 0; t < i.length; t++)+ e = e * kN + ON[i[t]];+ return e;+}+function St(i) {+ if (V(typeof i == "string", "invalid address", "address", i), i.match(/^(0x)?[0-9a-fA-F]{40}$/)) {+ i.startsWith("0x") || (i = "0x" + i);+ const e = Xg(i);+ return V(!i.match(/([A-F].*[a-f])|([a-f].*[A-F])/) || e === i, "bad address checksum", "address", i), e;+ }+ if (i.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)) {+ V(i.substring(2, 4) === UN(i), "bad icap checksum", "address", i);+ let e = QN(i.substring(4)).toString(16);+ for (; e.length < 40; )+ e = "0" + e;+ return Xg("0x" + e);+ }+ V(!1, "invalid address", "address", i);+}+function GN(i) {+ const e = St(i.from);+ let n = Fe(i.nonce, "tx.nonce").toString(16);+ return n === "0" ? n = "0x" : n.length % 2 ? n = "0x0" + n : n = "0x" + n, St(Vt(Zt(ls([e, n])), 12));+}+function nx(i) {+ return i && typeof i.getAddress == "function";+}+async function Eu(i, e) {+ const t = await e;+ return (t == null || t === "0x0000000000000000000000000000000000000000") && (ge(typeof i != "string", "unconfigured name", "UNCONFIGURED_NAME", { value: i }), V(!1, "invalid AddressLike value; did not resolve to a value address", "target", i)), St(t);+}+function Dn(i, e) {+ if (typeof i == "string")+ return i.match(/^0x[0-9a-f]{40}$/i) ? St(i) : (ge(e != null, "ENS resolution requires a provider", "UNSUPPORTED_OPERATION", { operation: "resolveName" }), Eu(i, e.resolveName(i)));+ if (nx(i))+ return Eu(i, i.getAddress());+ if (i && typeof i.then == "function")+ return Eu(i, i);+ V(!1, "unsupported addressable value", "target", i);+}+const Ji = {};+function Te(i, e) {+ let t = !1;+ return e < 0 && (t = !0, e *= -1), new Wt(Ji, `${t ? "" : "u"}int${e}`, i, { signed: t, width: e });+}+function _t(i, e) {+ return new Wt(Ji, `bytes${e || ""}`, i, { size: e });+}+const Jg = /* @__PURE__ */ Symbol.for("_ethers_typed");+class Wt {+ /**+ * The type, as a Solidity-compatible type.+ */+ type;+ /**+ * The actual value.+ */+ value;+ #e;+ /**+ * @_ignore:+ */+ _typedSymbol;+ /**+ * @_ignore:+ */+ constructor(e, t, n, s) {+ s == null && (s = null), sh(Ji, e, "Typed"), Xe(this, { _typedSymbol: Jg, type: t, value: n }), this.#e = s, this.format();+ }+ /**+ * Format the type as a Human-Readable type.+ */+ format() {+ if (this.type === "array")+ throw new Error("");+ if (this.type === "dynamicArray")+ throw new Error("");+ return this.type === "tuple" ? `tuple(${this.value.map((e) => e.format()).join(",")})` : this.type;+ }+ /**+ * The default value returned by this type.+ */+ defaultValue() {+ return 0;+ }+ /**+ * The minimum value for numeric types.+ */+ minValue() {+ return 0;+ }+ /**+ * The maximum value for numeric types.+ */+ maxValue() {+ return 0;+ }+ /**+ * Returns ``true`` and provides a type guard is this is a [[TypedBigInt]].+ */+ isBigInt() {+ return !!this.type.match(/^u?int[0-9]+$/);+ }+ /**+ * Returns ``true`` and provides a type guard is this is a [[TypedData]].+ */+ isData() {+ return this.type.startsWith("bytes");+ }+ /**+ * Returns ``true`` and provides a type guard is this is a [[TypedString]].+ */+ isString() {+ return this.type === "string";+ }+ /**+ * Returns the tuple name, if this is a tuple. Throws otherwise.+ */+ get tupleName() {+ if (this.type !== "tuple")+ throw TypeError("not a tuple");+ return this.#e;+ }+ // Returns the length of this type as an array+ // - `null` indicates the length is unforced, it could be dynamic+ // - `-1` indicates the length is dynamic+ // - any other value indicates it is a static array and is its length+ /**+ * Returns the length of the array type or ``-1`` if it is dynamic.+ *+ * Throws if the type is not an array.+ */+ get arrayLength() {+ if (this.type !== "array")+ throw TypeError("not an array");+ return this.#e === !0 ? -1 : this.#e === !1 ? this.value.length : null;+ }+ /**+ * Returns a new **Typed** of %%type%% with the %%value%%.+ */+ static from(e, t) {+ return new Wt(Ji, e, t);+ }+ /**+ * Return a new ``uint8`` type for %%v%%.+ */+ static uint8(e) {+ return Te(e, 8);+ }+ /**+ * Return a new ``uint16`` type for %%v%%.+ */+ static uint16(e) {+ return Te(e, 16);+ }+ /**+ * Return a new ``uint24`` type for %%v%%.+ */+ static uint24(e) {+ return Te(e, 24);+ }+ /**+ * Return a new ``uint32`` type for %%v%%.+ */+ static uint32(e) {+ return Te(e, 32);+ }+ /**+ * Return a new ``uint40`` type for %%v%%.+ */+ static uint40(e) {+ return Te(e, 40);+ }+ /**+ * Return a new ``uint48`` type for %%v%%.+ */+ static uint48(e) {+ return Te(e, 48);+ }+ /**+ * Return a new ``uint56`` type for %%v%%.+ */+ static uint56(e) {+ return Te(e, 56);+ }+ /**+ * Return a new ``uint64`` type for %%v%%.+ */+ static uint64(e) {+ return Te(e, 64);+ }+ /**+ * Return a new ``uint72`` type for %%v%%.+ */+ static uint72(e) {+ return Te(e, 72);+ }+ /**+ * Return a new ``uint80`` type for %%v%%.+ */+ static uint80(e) {+ return Te(e, 80);+ }+ /**+ * Return a new ``uint88`` type for %%v%%.+ */+ static uint88(e) {+ return Te(e, 88);+ }+ /**+ * Return a new ``uint96`` type for %%v%%.+ */+ static uint96(e) {+ return Te(e, 96);+ }+ /**+ * Return a new ``uint104`` type for %%v%%.+ */+ static uint104(e) {+ return Te(e, 104);+ }+ /**+ * Return a new ``uint112`` type for %%v%%.+ */+ static uint112(e) {+ return Te(e, 112);+ }+ /**+ * Return a new ``uint120`` type for %%v%%.+ */+ static uint120(e) {+ return Te(e, 120);+ }+ /**+ * Return a new ``uint128`` type for %%v%%.+ */+ static uint128(e) {+ return Te(e, 128);+ }+ /**+ * Return a new ``uint136`` type for %%v%%.+ */+ static uint136(e) {+ return Te(e, 136);+ }+ /**+ * Return a new ``uint144`` type for %%v%%.+ */+ static uint144(e) {+ return Te(e, 144);+ }+ /**+ * Return a new ``uint152`` type for %%v%%.+ */+ static uint152(e) {+ return Te(e, 152);+ }+ /**+ * Return a new ``uint160`` type for %%v%%.+ */+ static uint160(e) {+ return Te(e, 160);+ }+ /**+ * Return a new ``uint168`` type for %%v%%.+ */+ static uint168(e) {+ return Te(e, 168);+ }+ /**+ * Return a new ``uint176`` type for %%v%%.+ */+ static uint176(e) {+ return Te(e, 176);+ }+ /**+ * Return a new ``uint184`` type for %%v%%.+ */+ static uint184(e) {+ return Te(e, 184);+ }+ /**+ * Return a new ``uint192`` type for %%v%%.+ */+ static uint192(e) {+ return Te(e, 192);+ }+ /**+ * Return a new ``uint200`` type for %%v%%.+ */+ static uint200(e) {+ return Te(e, 200);+ }+ /**+ * Return a new ``uint208`` type for %%v%%.+ */+ static uint208(e) {+ return Te(e, 208);+ }+ /**+ * Return a new ``uint216`` type for %%v%%.+ */+ static uint216(e) {+ return Te(e, 216);+ }+ /**+ * Return a new ``uint224`` type for %%v%%.+ */+ static uint224(e) {+ return Te(e, 224);+ }+ /**+ * Return a new ``uint232`` type for %%v%%.+ */+ static uint232(e) {+ return Te(e, 232);+ }+ /**+ * Return a new ``uint240`` type for %%v%%.+ */+ static uint240(e) {+ return Te(e, 240);+ }+ /**+ * Return a new ``uint248`` type for %%v%%.+ */+ static uint248(e) {+ return Te(e, 248);+ }+ /**+ * Return a new ``uint256`` type for %%v%%.+ */+ static uint256(e) {+ return Te(e, 256);+ }+ /**+ * Return a new ``uint256`` type for %%v%%.+ */+ static uint(e) {+ return Te(e, 256);+ }+ /**+ * Return a new ``int8`` type for %%v%%.+ */+ static int8(e) {+ return Te(e, -8);+ }+ /**+ * Return a new ``int16`` type for %%v%%.+ */+ static int16(e) {+ return Te(e, -16);+ }+ /**+ * Return a new ``int24`` type for %%v%%.+ */+ static int24(e) {+ return Te(e, -24);+ }+ /**+ * Return a new ``int32`` type for %%v%%.+ */+ static int32(e) {+ return Te(e, -32);+ }+ /**+ * Return a new ``int40`` type for %%v%%.+ */+ static int40(e) {+ return Te(e, -40);+ }+ /**+ * Return a new ``int48`` type for %%v%%.+ */+ static int48(e) {+ return Te(e, -48);+ }+ /**+ * Return a new ``int56`` type for %%v%%.+ */+ static int56(e) {+ return Te(e, -56);+ }+ /**+ * Return a new ``int64`` type for %%v%%.+ */+ static int64(e) {+ return Te(e, -64);+ }+ /**+ * Return a new ``int72`` type for %%v%%.+ */+ static int72(e) {+ return Te(e, -72);+ }+ /**+ * Return a new ``int80`` type for %%v%%.+ */+ static int80(e) {+ return Te(e, -80);+ }+ /**+ * Return a new ``int88`` type for %%v%%.+ */+ static int88(e) {+ return Te(e, -88);+ }+ /**+ * Return a new ``int96`` type for %%v%%.+ */+ static int96(e) {+ return Te(e, -96);+ }+ /**+ * Return a new ``int104`` type for %%v%%.+ */+ static int104(e) {+ return Te(e, -104);+ }+ /**+ * Return a new ``int112`` type for %%v%%.+ */+ static int112(e) {+ return Te(e, -112);+ }+ /**+ * Return a new ``int120`` type for %%v%%.+ */+ static int120(e) {+ return Te(e, -120);+ }+ /**+ * Return a new ``int128`` type for %%v%%.+ */+ static int128(e) {+ return Te(e, -128);+ }+ /**+ * Return a new ``int136`` type for %%v%%.+ */+ static int136(e) {+ return Te(e, -136);+ }+ /**+ * Return a new ``int144`` type for %%v%%.+ */+ static int144(e) {+ return Te(e, -144);+ }+ /**+ * Return a new ``int52`` type for %%v%%.+ */+ static int152(e) {+ return Te(e, -152);+ }+ /**+ * Return a new ``int160`` type for %%v%%.+ */+ static int160(e) {+ return Te(e, -160);+ }+ /**+ * Return a new ``int168`` type for %%v%%.+ */+ static int168(e) {+ return Te(e, -168);+ }+ /**+ * Return a new ``int176`` type for %%v%%.+ */+ static int176(e) {+ return Te(e, -176);+ }+ /**+ * Return a new ``int184`` type for %%v%%.+ */+ static int184(e) {+ return Te(e, -184);+ }+ /**+ * Return a new ``int92`` type for %%v%%.+ */+ static int192(e) {+ return Te(e, -192);+ }+ /**+ * Return a new ``int200`` type for %%v%%.+ */+ static int200(e) {+ return Te(e, -200);+ }+ /**+ * Return a new ``int208`` type for %%v%%.+ */+ static int208(e) {+ return Te(e, -208);+ }+ /**+ * Return a new ``int216`` type for %%v%%.+ */+ static int216(e) {+ return Te(e, -216);+ }+ /**+ * Return a new ``int224`` type for %%v%%.+ */+ static int224(e) {+ return Te(e, -224);+ }+ /**+ * Return a new ``int232`` type for %%v%%.+ */+ static int232(e) {+ return Te(e, -232);+ }+ /**+ * Return a new ``int240`` type for %%v%%.+ */+ static int240(e) {+ return Te(e, -240);+ }+ /**+ * Return a new ``int248`` type for %%v%%.+ */+ static int248(e) {+ return Te(e, -248);+ }+ /**+ * Return a new ``int256`` type for %%v%%.+ */+ static int256(e) {+ return Te(e, -256);+ }+ /**+ * Return a new ``int256`` type for %%v%%.+ */+ static int(e) {+ return Te(e, -256);+ }+ /**+ * Return a new ``bytes1`` type for %%v%%.+ */+ static bytes1(e) {+ return _t(e, 1);+ }+ /**+ * Return a new ``bytes2`` type for %%v%%.+ */+ static bytes2(e) {+ return _t(e, 2);+ }+ /**+ * Return a new ``bytes3`` type for %%v%%.+ */+ static bytes3(e) {+ return _t(e, 3);+ }+ /**+ * Return a new ``bytes4`` type for %%v%%.+ */+ static bytes4(e) {+ return _t(e, 4);+ }+ /**+ * Return a new ``bytes5`` type for %%v%%.+ */+ static bytes5(e) {+ return _t(e, 5);+ }+ /**+ * Return a new ``bytes6`` type for %%v%%.+ */+ static bytes6(e) {+ return _t(e, 6);+ }+ /**+ * Return a new ``bytes7`` type for %%v%%.+ */+ static bytes7(e) {+ return _t(e, 7);+ }+ /**+ * Return a new ``bytes8`` type for %%v%%.+ */+ static bytes8(e) {+ return _t(e, 8);+ }+ /**+ * Return a new ``bytes9`` type for %%v%%.+ */+ static bytes9(e) {+ return _t(e, 9);+ }+ /**+ * Return a new ``bytes10`` type for %%v%%.+ */+ static bytes10(e) {+ return _t(e, 10);+ }+ /**+ * Return a new ``bytes11`` type for %%v%%.+ */+ static bytes11(e) {+ return _t(e, 11);+ }+ /**+ * Return a new ``bytes12`` type for %%v%%.+ */+ static bytes12(e) {+ return _t(e, 12);+ }+ /**+ * Return a new ``bytes13`` type for %%v%%.+ */+ static bytes13(e) {+ return _t(e, 13);+ }+ /**+ * Return a new ``bytes14`` type for %%v%%.+ */+ static bytes14(e) {+ return _t(e, 14);+ }+ /**+ * Return a new ``bytes15`` type for %%v%%.+ */+ static bytes15(e) {+ return _t(e, 15);+ }+ /**+ * Return a new ``bytes16`` type for %%v%%.+ */+ static bytes16(e) {+ return _t(e, 16);+ }+ /**+ * Return a new ``bytes17`` type for %%v%%.+ */+ static bytes17(e) {+ return _t(e, 17);+ }+ /**+ * Return a new ``bytes18`` type for %%v%%.+ */+ static bytes18(e) {+ return _t(e, 18);+ }+ /**+ * Return a new ``bytes19`` type for %%v%%.+ */+ static bytes19(e) {+ return _t(e, 19);+ }+ /**+ * Return a new ``bytes20`` type for %%v%%.+ */+ static bytes20(e) {+ return _t(e, 20);+ }+ /**+ * Return a new ``bytes21`` type for %%v%%.+ */+ static bytes21(e) {+ return _t(e, 21);+ }+ /**+ * Return a new ``bytes22`` type for %%v%%.+ */+ static bytes22(e) {+ return _t(e, 22);+ }+ /**+ * Return a new ``bytes23`` type for %%v%%.+ */+ static bytes23(e) {+ return _t(e, 23);+ }+ /**+ * Return a new ``bytes24`` type for %%v%%.+ */+ static bytes24(e) {+ return _t(e, 24);+ }+ /**+ * Return a new ``bytes25`` type for %%v%%.+ */+ static bytes25(e) {+ return _t(e, 25);+ }+ /**+ * Return a new ``bytes26`` type for %%v%%.+ */+ static bytes26(e) {+ return _t(e, 26);+ }+ /**+ * Return a new ``bytes27`` type for %%v%%.+ */+ static bytes27(e) {+ return _t(e, 27);+ }+ /**+ * Return a new ``bytes28`` type for %%v%%.+ */+ static bytes28(e) {+ return _t(e, 28);+ }+ /**+ * Return a new ``bytes29`` type for %%v%%.+ */+ static bytes29(e) {+ return _t(e, 29);+ }+ /**+ * Return a new ``bytes30`` type for %%v%%.+ */+ static bytes30(e) {+ return _t(e, 30);+ }+ /**+ * Return a new ``bytes31`` type for %%v%%.+ */+ static bytes31(e) {+ return _t(e, 31);+ }+ /**+ * Return a new ``bytes32`` type for %%v%%.+ */+ static bytes32(e) {+ return _t(e, 32);+ }+ /**+ * Return a new ``address`` type for %%v%%.+ */+ static address(e) {+ return new Wt(Ji, "address", e);+ }+ /**+ * Return a new ``bool`` type for %%v%%.+ */+ static bool(e) {+ return new Wt(Ji, "bool", !!e);+ }+ /**+ * Return a new ``bytes`` type for %%v%%.+ */+ static bytes(e) {+ return new Wt(Ji, "bytes", e);+ }+ /**+ * Return a new ``string`` type for %%v%%.+ */+ static string(e) {+ return new Wt(Ji, "string", e);+ }+ /**+ * Return a new ``array`` type for %%v%%, allowing %%dynamic%% length.+ */+ static array(e, t) {+ throw new Error("not implemented yet");+ }+ /**+ * Return a new ``tuple`` type for %%v%%, with the optional %%name%%.+ */+ static tuple(e, t) {+ throw new Error("not implemented yet");+ }+ /**+ * Return a new ``uint8`` type for %%v%%.+ */+ static overrides(e) {+ return new Wt(Ji, "overrides", Object.assign({}, e));+ }+ /**+ * Returns true only if %%value%% is a [[Typed]] instance.+ */+ static isTyped(e) {+ return e && typeof e == "object" && "_typedSymbol" in e && e._typedSymbol === Jg;+ }+ /**+ * If the value is a [[Typed]] instance, validates the underlying value+ * and returns it, otherwise returns value directly.+ *+ * This is useful for functions that with to accept either a [[Typed]]+ * object or values.+ */+ static dereference(e, t) {+ if (Wt.isTyped(e)) {+ if (e.type !== t)+ throw new Error(`invalid type: expecetd ${t}, got ${e.type}`);+ return e.value;+ }+ return e;+ }+}+class HN extends As {+ constructor(e) {+ super("address", "address", e, !1);+ }+ defaultValue() {+ return "0x0000000000000000000000000000000000000000";+ }+ encode(e, t) {+ let n = Wt.dereference(t, "string");+ try {+ n = St(n);+ } catch (s) {+ return this._throwError(s.message, t);+ }+ return e.writeValue(n);+ }+ decode(e) {+ return St(Hs(e.readValue(), 20));+ }+}+class zN extends As {+ coder;+ constructor(e) {+ super(e.name, e.type, "_", e.dynamic), this.coder = e;+ }+ defaultValue() {+ return this.coder.defaultValue();+ }+ encode(e, t) {+ return this.coder.encode(e, t);+ }+ decode(e) {+ return this.coder.decode(e);+ }+}+function ix(i, e, t) {+ let n = [];+ if (Array.isArray(t))+ n = t;+ else if (t && typeof t == "object") {+ let c = {};+ n = e.map((l) => {+ const h = l.localName;+ return ge(h, "cannot encode object for signature with missing names", "INVALID_ARGUMENT", { argument: "values", info: { coder: l }, value: t }), ge(!c[h], "cannot encode object for signature with duplicate names", "INVALID_ARGUMENT", { argument: "values", info: { coder: l }, value: t }), c[h] = !0, t[h];+ });+ } else+ V(!1, "invalid tuple value", "tuple", t);+ V(e.length === n.length, "types/value length mismatch", "tuple", t);+ let s = new Hd(), r = new Hd(), a = [];+ e.forEach((c, l) => {+ let h = n[l];+ if (c.dynamic) {+ let u = r.length;+ c.encode(r, h);+ let d = s.writeUpdatableValue();+ a.push((f) => {+ d(f + u);+ });+ } else+ c.encode(s, h);+ }), a.forEach((c) => {+ c(s.length);+ });+ let o = i.appendWriter(s);+ return o += i.appendWriter(r), o;+}+function sx(i, e) {+ let t = [], n = [], s = i.subReader(0);+ return e.forEach((r) => {+ let a = null;+ if (r.dynamic) {+ let o = i.readIndex(), c = s.subReader(o);+ try {+ a = r.decode(c);+ } catch (l) {+ if (_n(l, "BUFFER_OVERRUN"))+ throw l;+ a = l, a.baseType = r.name, a.name = r.localName, a.type = r.type;+ }+ } else+ try {+ a = r.decode(i);+ } catch (o) {+ if (_n(o, "BUFFER_OVERRUN"))+ throw o;+ a = o, a.baseType = r.name, a.name = r.localName, a.type = r.type;+ }+ if (a == null)+ throw new Error("investigate");+ t.push(a), n.push(r.localName || null);+ }), rs.fromItems(t, n);+}+class VN extends As {+ coder;+ length;+ constructor(e, t, n) {+ const s = e.type + "[" + (t >= 0 ? t : "") + "]", r = t === -1 || e.dynamic;+ super("array", s, n, r), Xe(this, { coder: e, length: t });+ }+ defaultValue() {+ const e = this.coder.defaultValue(), t = [];+ for (let n = 0; n < this.length; n++)+ t.push(e);+ return t;+ }+ encode(e, t) {+ const n = Wt.dereference(t, "array");+ Array.isArray(n) || this._throwError("expected array value", n);+ let s = this.length;+ s === -1 && (s = n.length, e.writeValue(n.length)), Ab(n.length, s, "coder array" + (this.localName ? " " + this.localName : ""));+ let r = [];+ for (let a = 0; a < n.length; a++)+ r.push(this.coder);+ return ix(e, r, n);+ }+ decode(e) {+ let t = this.length;+ t === -1 && (t = e.readIndex(), ge(t * Fn <= e.dataLength, "insufficient data length", "BUFFER_OVERRUN", { buffer: e.bytes, offset: t * Fn, length: e.dataLength }));+ let n = [];+ for (let s = 0; s < t; s++)+ n.push(new zN(this.coder));+ return sx(e, n);+ }+}+class WN extends As {+ constructor(e) {+ super("bool", "bool", e, !1);+ }+ defaultValue() {+ return !1;+ }+ encode(e, t) {+ const n = Wt.dereference(t, "bool");+ return e.writeValue(n ? 1 : 0);+ }+ decode(e) {+ return !!e.readValue();+ }+}+class rx extends As {+ constructor(e, t) {+ super(e, e, t, !0);+ }+ defaultValue() {+ return "0x";+ }+ encode(e, t) {+ t = Rn(t);+ let n = e.writeValue(t.length);+ return n += e.writeBytes(t), n;+ }+ decode(e) {+ return e.readBytes(e.readIndex(), !0);+ }+}+class qN extends rx {+ constructor(e) {+ super("bytes", e);+ }+ decode(e) {+ return Se(super.decode(e));+ }+}+class KN extends As {+ size;+ constructor(e, t) {+ let n = "bytes" + String(e);+ super(n, n, t, !1), Xe(this, { size: e }, { size: "number" });+ }+ defaultValue() {+ return "0x0000000000000000000000000000000000000000000000000000000000000000".substring(0, 2 + this.size * 2);+ }+ encode(e, t) {+ let n = Rn(Wt.dereference(t, this.type));+ return n.length !== this.size && this._throwError("incorrect data length", t), e.writeBytes(n);+ }+ decode(e) {+ return Se(e.readBytes(this.size));+ }+}+const jN = new Uint8Array([]);+class XN extends As {+ constructor(e) {+ super("null", "", e, !1);+ }+ defaultValue() {+ return null;+ }+ encode(e, t) {+ return t != null && this._throwError("not null", t), e.writeBytes(jN);+ }+ decode(e) {+ return e.readBytes(0), null;+ }+}+const YN = BigInt(0), JN = BigInt(1), ZN = BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");+class $N extends As {+ size;+ signed;+ constructor(e, t, n) {+ const s = (t ? "int" : "uint") + e * 8;+ super(s, s, n, !1), Xe(this, { size: e, signed: t }, { size: "number", signed: "boolean" });+ }+ defaultValue() {+ return 0;+ }+ encode(e, t) {+ let n = Fe(Wt.dereference(t, this.type)), s = go(ZN, Fn * 8);+ if (this.signed) {+ let r = go(s, this.size * 8 - 1);+ (n > r || n < -(r + JN)) && this._throwError("value out-of-bounds", t), n = bb(n, 8 * Fn);+ } else (n < YN || n > go(s, this.size * 8)) && this._throwError("value out-of-bounds", t);+ return e.writeValue(n);+ }+ decode(e) {+ let t = go(e.readValue(), this.size * 8);+ return this.signed && (t = $T(t, this.size * 8)), t;+ }+}+class eF extends rx {+ constructor(e) {+ super("string", e);+ }+ defaultValue() {+ return "";+ }+ encode(e, t) {+ return super.encode(e, cs(Wt.dereference(t, "string")));+ }+ decode(e) {+ return Ol(super.decode(e));+ }+}+class rl extends As {+ coders;+ constructor(e, t) {+ let n = !1;+ const s = [];+ e.forEach((a) => {+ a.dynamic && (n = !0), s.push(a.type);+ });+ const r = "tuple(" + s.join(",") + ")";+ super("tuple", r, t, n), Xe(this, { coders: Object.freeze(e.slice()) });+ }+ defaultValue() {+ const e = [];+ this.coders.forEach((n) => {+ e.push(n.defaultValue());+ });+ const t = this.coders.reduce((n, s) => {+ const r = s.localName;+ return r && (n[r] || (n[r] = 0), n[r]++), n;+ }, {});+ return this.coders.forEach((n, s) => {+ let r = n.localName;+ !r || t[r] !== 1 || (r === "length" && (r = "_length"), e[r] == null && (e[r] = e[s]));+ }), Object.freeze(e);+ }+ encode(e, t) {+ const n = Wt.dereference(t, "tuple");+ return ix(e, this.coders, n);+ }+ decode(e) {+ return sx(e, this.coders);+ }+}+function yu(i, e) {+ return {+ address: St(i),+ storageKeys: e.map((t, n) => (V(Lt(t, 32), "invalid slot", `storageKeys[${n}]`, t), t.toLowerCase()))+ };+}+function Rr(i) {+ if (Array.isArray(i))+ return i.map((t, n) => Array.isArray(t) ? (V(t.length === 2, "invalid slot set", `value[${n}]`, t), yu(t[0], t[1])) : (V(t != null && typeof t == "object", "invalid address-slot set", "value", i), yu(t.address, t.storageKeys)));+ V(i != null && typeof i == "object", "invalid access list", "value", i);+ const e = Object.keys(i).map((t) => {+ const n = i[t].reduce((s, r) => (s[r] = !0, s), {});+ return yu(t, Object.keys(n).sort());+ });+ return e.sort((t, n) => t.address.localeCompare(n.address)), e;+}+function ax(i) {+ return {+ address: St(i.address),+ nonce: Fe(i.nonce != null ? i.nonce : 0),+ chainId: Fe(i.chainId != null ? i.chainId : 0),+ signature: Gt.from(i.signature)+ };+}+function tF(i) {+ let e;+ return typeof i == "string" ? e = ts.computePublicKey(i, !1) : e = i.publicKey, St(Zt("0x" + e.substring(4)).substring(26));+}+function nF(i, e) {+ return tF(ts.recoverPublicKey(i, e));+}+const gn = BigInt(0), iF = BigInt(2), sF = BigInt(27), rF = BigInt(28), aF = BigInt(35), oF = BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"), cF = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom"), wu = 4096 * 32, ml = 128;+function lF(i) {+ return { blobToKzgCommitment: (n) => {+ if ("computeBlobProof" in i) {+ if ("blobToKzgCommitment" in i && typeof i.blobToKzgCommitment == "function")+ return ht(i.blobToKzgCommitment(Se(n)));+ } else if ("blobToKzgCommitment" in i && typeof i.blobToKzgCommitment == "function")+ return ht(i.blobToKzgCommitment(n));+ if ("blobToKZGCommitment" in i && typeof i.blobToKZGCommitment == "function")+ return ht(i.blobToKZGCommitment(Se(n)));+ V(!1, "unsupported KZG library", "kzg", i);+ }, computeBlobKzgProof: (n, s) => {+ if ("computeBlobProof" in i && typeof i.computeBlobProof == "function")+ return ht(i.computeBlobProof(Se(n), Se(s)));+ if ("computeBlobKzgProof" in i && typeof i.computeBlobKzgProof == "function")+ return i.computeBlobKzgProof(n, s);+ if ("computeBlobKZGProof" in i && typeof i.computeBlobKZGProof == "function")+ return ht(i.computeBlobKZGProof(Se(n), Se(s)));+ V(!1, "unsupported KZG library", "kzg", i);+ } };+}+function Zg(i, e) {+ let t = i.toString(16);+ for (; t.length < 2; )+ t = "0" + t;+ return t += za(e).substring(4), "0x" + t;+}+function Va(i) {+ return i === "0x" ? null : St(i);+}+function ch(i, e) {+ try {+ return Rr(i);+ } catch (t) {+ V(!1, t.message, e, i);+ }+}+function hF(i, e) {+ try {+ if (!Array.isArray(i))+ throw new Error("authorizationList: invalid array");+ const t = [];+ for (let n = 0; n < i.length; n++) {+ const s = i[n];+ if (!Array.isArray(s))+ throw new Error(`authorization[${n}]: invalid array`);+ if (s.length !== 6)+ throw new Error(`authorization[${n}]: wrong length`);+ if (!s[1])+ throw new Error(`authorization[${n}]: null address`);+ t.push({+ address: Va(s[1]),+ nonce: Tt(s[2], "nonce"),+ chainId: Tt(s[0], "chainId"),+ signature: Gt.from({+ yParity: Nr(s[3], "yParity"),+ r: ds(s[4], 32),+ s: ds(s[5], 32)+ })+ });+ }+ return t;+ } catch (t) {+ V(!1, t.message, e, i);+ }+}+function Nr(i, e) {+ return i === "0x" ? 0 : ut(i, e);+}+function Tt(i, e) {+ if (i === "0x")+ return gn;+ const t = Fe(i, e);+ return V(t <= oF, "value exceeds uint size", e, t), t;+}+function bt(i, e) {+ const t = Fe(i, "value"), n = $t(t);+ return V(n.length <= 32, "value too large", `tx.${e}`, t), n;+}+function lh(i) {+ return Rr(i).map((e) => [e.address, e.storageKeys]);+}+function uF(i) {+ return i.map((e) => [+ bt(e.chainId, "chainId"),+ e.address,+ bt(e.nonce, "nonce"),+ bt(e.signature.yParity, "yParity"),+ $t(e.signature.r),+ $t(e.signature._s)+ ]);+}+function dF(i, e) {+ V(Array.isArray(i), `invalid ${e}`, "value", i);+ for (let t = 0; t < i.length; t++)+ V(Lt(i[t], 32), "invalid ${ param } hash", `value[${t}]`, i[t]);+ return i;+}+function fF(i) {+ const e = ic(i);+ V(Array.isArray(e) && (e.length === 9 || e.length === 6), "invalid field count for legacy transaction", "data", i);+ const t = {+ type: 0,+ nonce: Nr(e[0], "nonce"),+ gasPrice: Tt(e[1], "gasPrice"),+ gasLimit: Tt(e[2], "gasLimit"),+ to: Va(e[3]),+ value: Tt(e[4], "value"),+ data: Se(e[5]),+ chainId: gn+ };+ if (e.length === 6)+ return t;+ const n = Tt(e[6], "v"), s = Tt(e[7], "r"), r = Tt(e[8], "s");+ if (s === gn && r === gn)+ t.chainId = n;+ else {+ let a = (n - aF) / iF;+ a < gn && (a = gn), t.chainId = a, V(a !== gn || n === sF || n === rF, "non-canonical legacy v", "v", e[6]), t.signature = Gt.from({+ r: ds(e[7], 32),+ s: ds(e[8], 32),+ v: n+ });+ }+ return t;+}+function pF(i, e) {+ const t = [+ bt(i.nonce, "nonce"),+ bt(i.gasPrice || 0, "gasPrice"),+ bt(i.gasLimit, "gasLimit"),+ i.to || "0x",+ bt(i.value, "value"),+ i.data+ ];+ let n = gn;+ if (i.chainId != gn)+ n = Fe(i.chainId, "tx.chainId"), V(!e || e.networkV == null || e.legacyChainId === n, "tx.chainId/sig.v mismatch", "sig", e);+ else if (i.signature) {+ const r = i.signature.legacyChainId;+ r != null && (n = r);+ }+ if (!e)+ return n !== gn && (t.push($t(n)), t.push("0x"), t.push("0x")), ls(t);+ let s = BigInt(27 + e.yParity);+ return n !== gn ? s = Gt.getChainIdV(n, e.v) : BigInt(e.v) !== s && V(!1, "tx.chainId/sig.v mismatch", "sig", e), t.push($t(s)), t.push($t(e.r)), t.push($t(e._s)), ls(t);+}+function hh(i, e) {+ let t;+ try {+ if (t = Nr(e[0], "yParity"), t !== 0 && t !== 1)+ throw new Error("bad yParity");+ } catch {+ V(!1, "invalid yParity", "yParity", e[0]);+ }+ const n = ds(e[1], 32), s = ds(e[2], 32), r = Gt.from({ r: n, s, yParity: t });+ i.signature = r;+}+function AF(i) {+ const e = ic(ht(i).slice(1));+ V(Array.isArray(e) && (e.length === 9 || e.length === 12), "invalid field count for transaction type: 2", "data", Se(i));+ const t = {+ type: 2,+ chainId: Tt(e[0], "chainId"),+ nonce: Nr(e[1], "nonce"),+ maxPriorityFeePerGas: Tt(e[2], "maxPriorityFeePerGas"),+ maxFeePerGas: Tt(e[3], "maxFeePerGas"),+ gasPrice: null,+ gasLimit: Tt(e[4], "gasLimit"),+ to: Va(e[5]),+ value: Tt(e[6], "value"),+ data: Se(e[7]),+ accessList: ch(e[8], "accessList")+ };+ return e.length === 9 || hh(t, e.slice(9)), t;+}+function gF(i, e) {+ const t = [+ bt(i.chainId, "chainId"),+ bt(i.nonce, "nonce"),+ bt(i.maxPriorityFeePerGas || 0, "maxPriorityFeePerGas"),+ bt(i.maxFeePerGas || 0, "maxFeePerGas"),+ bt(i.gasLimit, "gasLimit"),+ i.to || "0x",+ bt(i.value, "value"),+ i.data,+ lh(i.accessList || [])+ ];+ return e && (t.push(bt(e.yParity, "yParity")), t.push($t(e.r)), t.push($t(e.s))), Qt(["0x02", ls(t)]);+}+function mF(i) {+ const e = ic(ht(i).slice(1));+ V(Array.isArray(e) && (e.length === 8 || e.length === 11), "invalid field count for transaction type: 1", "data", Se(i));+ const t = {+ type: 1,+ chainId: Tt(e[0], "chainId"),+ nonce: Nr(e[1], "nonce"),+ gasPrice: Tt(e[2], "gasPrice"),+ gasLimit: Tt(e[3], "gasLimit"),+ to: Va(e[4]),+ value: Tt(e[5], "value"),+ data: Se(e[6]),+ accessList: ch(e[7], "accessList")+ };+ return e.length === 8 || hh(t, e.slice(8)), t;+}+function bF(i, e) {+ const t = [+ bt(i.chainId, "chainId"),+ bt(i.nonce, "nonce"),+ bt(i.gasPrice || 0, "gasPrice"),+ bt(i.gasLimit, "gasLimit"),+ i.to || "0x",+ bt(i.value, "value"),+ i.data,+ lh(i.accessList || [])+ ];+ return e && (t.push(bt(e.yParity, "recoveryParam")), t.push($t(e.r)), t.push($t(e.s))), Qt(["0x01", ls(t)]);+}+function xF(i) {+ let e = ic(ht(i).slice(1)), t = "3", n = null, s = null;+ if (e.length === 4 && Array.isArray(e[0])) {+ t = "3 (network format)";+ const a = e[1], o = e[2], c = e[3];+ V(Array.isArray(a), "invalid network format: blobs not an array", "fields[1]", a), V(Array.isArray(o), "invalid network format: commitments not an array", "fields[2]", o), V(Array.isArray(c), "invalid network format: proofs not an array", "fields[3]", c), V(a.length === o.length, "invalid network format: blobs/commitments length mismatch", "fields", e), V(a.length === c.length, "invalid network format: blobs/proofs length mismatch", "fields", e), s = [];+ for (let l = 0; l < e[1].length; l++)+ s.push({+ data: a[l],+ commitment: o[l],+ proof: c[l]+ });+ e = e[0];+ } else if (e.length === 5 && Array.isArray(e[0])) {+ t = "3 (EIP-7594 network format)", n = ut(e[1]);+ const a = e[2], o = e[3], c = e[4];+ V(n === 1, `unsupported EIP-7594 network format version: ${n}`, "fields[1]", n), V(Array.isArray(a), "invalid EIP-7594 network format: blobs not an array", "fields[2]", a), V(Array.isArray(o), "invalid EIP-7594 network format: commitments not an array", "fields[3]", o), V(Array.isArray(c), "invalid EIP-7594 network format: proofs not an array", "fields[4]", c), V(a.length === o.length, "invalid network format: blobs/commitments length mismatch", "fields", e), V(a.length * ml === c.length, "invalid network format: blobs/proofs length mismatch", "fields", e), s = [];+ for (let l = 0; l < a.length; l++) {+ const h = [];+ for (let u = 0; u < ml; u++)+ h.push(c[l * ml + u]);+ s.push({+ data: a[l],+ commitment: o[l],+ proof: Qt(h)+ });+ }+ e = e[0];+ }+ V(Array.isArray(e) && (e.length === 11 || e.length === 14), `invalid field count for transaction type: ${t}`, "data", Se(i));+ const r = {+ type: 3,+ chainId: Tt(e[0], "chainId"),+ nonce: Nr(e[1], "nonce"),+ maxPriorityFeePerGas: Tt(e[2], "maxPriorityFeePerGas"),+ maxFeePerGas: Tt(e[3], "maxFeePerGas"),+ gasPrice: null,+ gasLimit: Tt(e[4], "gasLimit"),+ to: Va(e[5]),+ value: Tt(e[6], "value"),+ data: Se(e[7]),+ accessList: ch(e[8], "accessList"),+ maxFeePerBlobGas: Tt(e[9], "maxFeePerBlobGas"),+ blobVersionedHashes: e[10],+ blobWrapperVersion: n+ };+ s && (r.blobs = s), V(r.to != null, `invalid address for transaction type: ${t}`, "data", i), V(Array.isArray(r.blobVersionedHashes), "invalid blobVersionedHashes: must be an array", "data", i);+ for (let a = 0; a < r.blobVersionedHashes.length; a++)+ V(Lt(r.blobVersionedHashes[a], 32), `invalid blobVersionedHash at index ${a}: must be length 32`, "data", i);+ return e.length === 11 || hh(r, e.slice(11)), r;+}+function _F(i, e, t) {+ const n = [+ bt(i.chainId, "chainId"),+ bt(i.nonce, "nonce"),+ bt(i.maxPriorityFeePerGas || 0, "maxPriorityFeePerGas"),+ bt(i.maxFeePerGas || 0, "maxFeePerGas"),+ bt(i.gasLimit, "gasLimit"),+ i.to || Vo,+ bt(i.value, "value"),+ i.data,+ lh(i.accessList || []),+ bt(i.maxFeePerBlobGas || 0, "maxFeePerBlobGas"),+ dF(i.blobVersionedHashes || [], "blobVersionedHashes")+ ];+ if (e && (n.push(bt(e.yParity, "yParity")), n.push($t(e.r)), n.push($t(e.s)), t)) {+ if (i.blobWrapperVersion != null) {+ const s = $t(i.blobWrapperVersion), r = [];+ for (const { proof: a } of t) {+ const o = ht(a), c = o.length / ml;+ for (let l = 0; l < o.length; l += c)+ r.push(o.subarray(l, l + c));+ }+ return Qt([+ "0x03",+ ls([+ n,+ s,+ t.map((a) => a.data),+ t.map((a) => a.commitment),+ r+ ])+ ]);+ }+ return Qt([+ "0x03",+ ls([+ n,+ t.map((s) => s.data),+ t.map((s) => s.commitment),+ t.map((s) => s.proof)+ ])+ ]);+ }+ return Qt(["0x03", ls(n)]);+}+function EF(i) {+ const e = ic(ht(i).slice(1));+ V(Array.isArray(e) && (e.length === 10 || e.length === 13), "invalid field count for transaction type: 4", "data", Se(i));+ const t = {+ type: 4,+ chainId: Tt(e[0], "chainId"),+ nonce: Nr(e[1], "nonce"),+ maxPriorityFeePerGas: Tt(e[2], "maxPriorityFeePerGas"),+ maxFeePerGas: Tt(e[3], "maxFeePerGas"),+ gasPrice: null,+ gasLimit: Tt(e[4], "gasLimit"),+ to: Va(e[5]),+ value: Tt(e[6], "value"),+ data: Se(e[7]),+ accessList: ch(e[8], "accessList"),+ authorizationList: hF(e[9], "authorizationList")+ };+ return e.length === 10 || hh(t, e.slice(10)), t;+}+function yF(i, e) {+ const t = [+ bt(i.chainId, "chainId"),+ bt(i.nonce, "nonce"),+ bt(i.maxPriorityFeePerGas || 0, "maxPriorityFeePerGas"),+ bt(i.maxFeePerGas || 0, "maxFeePerGas"),+ bt(i.gasLimit, "gasLimit"),+ i.to || "0x",+ bt(i.value, "value"),+ i.data,+ lh(i.accessList || []),+ uF(i.authorizationList || [])+ ];+ return e && (t.push(bt(e.yParity, "yParity")), t.push($t(e.r)), t.push($t(e.s))), Qt(["0x04", ls(t)]);+}+class pi {+ #e;+ #t;+ #n;+ #i;+ #s;+ #a;+ #r;+ #o;+ #f;+ #l;+ #p;+ #A;+ #c;+ #h;+ #u;+ #d;+ #b;+ #g;+ /**+ * The transaction type.+ *+ * If null, the type will be automatically inferred based on+ * explicit properties.+ */+ get type() {+ return this.#e;+ }+ set type(e) {+ switch (e) {+ case null:+ this.#e = null;+ break;+ case 0:+ case "legacy":+ this.#e = 0;+ break;+ case 1:+ case "berlin":+ case "eip-2930":+ this.#e = 1;+ break;+ case 2:+ case "london":+ case "eip-1559":+ this.#e = 2;+ break;+ case 3:+ case "cancun":+ case "eip-4844":+ this.#e = 3;+ break;+ case 4:+ case "pectra":+ case "eip-7702":+ this.#e = 4;+ break;+ default:+ V(!1, "unsupported transaction type", "type", e);+ }+ }+ /**+ * The name of the transaction type.+ */+ get typeName() {+ switch (this.type) {+ case 0:+ return "legacy";+ case 1:+ return "eip-2930";+ case 2:+ return "eip-1559";+ case 3:+ return "eip-4844";+ case 4:+ return "eip-7702";+ }+ return null;+ }+ /**+ * The ``to`` address for the transaction or ``null`` if the+ * transaction is an ``init`` transaction.+ */+ get to() {+ const e = this.#t;+ return e == null && this.type === 3 ? Vo : e;+ }+ set to(e) {+ this.#t = e == null ? null : St(e);+ }+ /**+ * The transaction nonce.+ */+ get nonce() {+ return this.#i;+ }+ set nonce(e) {+ this.#i = ut(e, "value");+ }+ /**+ * The gas limit.+ */+ get gasLimit() {+ return this.#s;+ }+ set gasLimit(e) {+ this.#s = Fe(e);+ }+ /**+ * The gas price.+ *+ * On legacy networks this defines the fee that will be paid. On+ * EIP-1559 networks, this should be ``null``.+ */+ get gasPrice() {+ const e = this.#a;+ return e == null && (this.type === 0 || this.type === 1) ? gn : e;+ }+ set gasPrice(e) {+ this.#a = e == null ? null : Fe(e, "gasPrice");+ }+ /**+ * The maximum priority fee per unit of gas to pay. On legacy+ * networks this should be ``null``.+ */+ get maxPriorityFeePerGas() {+ const e = this.#r;+ return e ?? (this.type === 2 || this.type === 3 ? gn : null);+ }+ set maxPriorityFeePerGas(e) {+ this.#r = e == null ? null : Fe(e, "maxPriorityFeePerGas");+ }+ /**+ * The maximum total fee per unit of gas to pay. On legacy+ * networks this should be ``null``.+ */+ get maxFeePerGas() {+ const e = this.#o;+ return e ?? (this.type === 2 || this.type === 3 ? gn : null);+ }+ set maxFeePerGas(e) {+ this.#o = e == null ? null : Fe(e, "maxFeePerGas");+ }+ /**+ * The transaction data. For ``init`` transactions this is the+ * deployment code.+ */+ get data() {+ return this.#n;+ }+ set data(e) {+ this.#n = Se(e);+ }+ /**+ * The amount of ether (in wei) to send in this transactions.+ */+ get value() {+ return this.#f;+ }+ set value(e) {+ this.#f = Fe(e, "value");+ }+ /**+ * The chain ID this transaction is valid on.+ */+ get chainId() {+ return this.#l;+ }+ set chainId(e) {+ this.#l = Fe(e);+ }+ /**+ * If signed, the signature for this transaction.+ */+ get signature() {+ return this.#p || null;+ }+ set signature(e) {+ this.#p = e == null ? null : Gt.from(e);+ }+ isValid() {+ const e = this.signature;+ if (e && !e.isValid())+ return !1;+ const t = this.authorizationList;+ if (t) {+ for (const n of t)+ if (!n.signature.isValid())+ return !1;+ }+ return !0;+ }+ /**+ * The access list.+ *+ * An access list permits discounted (but pre-paid) access to+ * bytecode and state variable access within contract execution.+ */+ get accessList() {+ const e = this.#A || null;+ return e ?? (this.type === 1 || this.type === 2 || this.type === 3 ? [] : null);+ }+ set accessList(e) {+ this.#A = e == null ? null : Rr(e);+ }+ get authorizationList() {+ const e = this.#b || null;+ return e == null && this.type === 4 ? [] : e;+ }+ set authorizationList(e) {+ this.#b = e == null ? null : e.map((t) => ax(t));+ }+ /**+ * The max fee per blob gas for Cancun transactions.+ */+ get maxFeePerBlobGas() {+ const e = this.#c;+ return e == null && this.type === 3 ? gn : e;+ }+ set maxFeePerBlobGas(e) {+ this.#c = e == null ? null : Fe(e, "maxFeePerBlobGas");+ }+ /**+ * The BLOb versioned hashes for Cancun transactions.+ */+ get blobVersionedHashes() {+ let e = this.#h;+ return e == null && this.type === 3 ? [] : e;+ }+ set blobVersionedHashes(e) {+ if (e != null) {+ V(Array.isArray(e), "blobVersionedHashes must be an Array", "value", e), e = e.slice();+ for (let t = 0; t < e.length; t++)+ V(Lt(e[t], 32), "invalid blobVersionedHash", `value[${t}]`, e[t]);+ }+ this.#h = e;+ }+ /**+ * The BLObs for the Transaction, if any.+ *+ * If ``blobs`` is non-``null``, then the [[seriailized]]+ * will return the network formatted sidecar, otherwise it+ * will return the standard [[link-eip-2718]] payload. The+ * [[unsignedSerialized]] is unaffected regardless.+ *+ * When setting ``blobs``, either fully valid [[Blob]] objects+ * may be specified (i.e. correctly padded, with correct+ * committments and proofs) or a raw [[BytesLike]] may+ * be provided.+ *+ * If raw [[BytesLike]] are provided, the [[kzg]] property **must**+ * be already set. The blob will be correctly padded and the+ * [[KzgLibrary]] will be used to compute the committment and+ * proof for the blob.+ *+ * A BLOb is a sequence of field elements, each of which must+ * be within the BLS field modulo, so some additional processing+ * may be required to encode arbitrary data to ensure each 32 byte+ * field is within the valid range.+ *+ * Setting this automatically populates [[blobVersionedHashes]],+ * overwriting any existing values. Setting this to ``null``+ * does **not** remove the [[blobVersionedHashes]], leaving them+ * present.+ */+ get blobs() {+ return this.#d == null ? null : this.#d.map((e) => Object.assign({}, e));+ }+ set blobs(e) {+ if (e == null) {+ this.#d = null;+ return;+ }+ const t = [], n = [];+ for (let s = 0; s < e.length; s++) {+ const r = e[s];+ if (Vf(r)) {+ ge(this.#u, "adding a raw blob requires a KZG library", "UNSUPPORTED_OPERATION", {+ operation: "set blobs()"+ });+ let a = ht(r);+ if (V(a.length <= wu, "blob is too large", `blobs[${s}]`, r), a.length !== wu) {+ const l = new Uint8Array(wu);+ l.set(a), a = l;+ }+ const o = this.#u.blobToKzgCommitment(a), c = Se(this.#u.computeBlobKzgProof(a, o));+ t.push({+ data: Se(a),+ commitment: Se(o),+ proof: c+ }), n.push(Zg(1, o));+ } else {+ const a = Se(r.data), o = Se(r.commitment), c = Se(r.proof);+ t.push({ data: a, commitment: o, proof: c }), n.push(Zg(1, o));+ }+ }+ this.#d = t, this.#h = n;+ }+ get kzg() {+ return this.#u;+ }+ set kzg(e) {+ e == null ? this.#u = null : this.#u = lF(e);+ }+ get blobWrapperVersion() {+ return this.#g;+ }+ set blobWrapperVersion(e) {+ this.#g = e;+ }+ /**+ * Creates a new Transaction with default values.+ */+ constructor() {+ this.#e = null, this.#t = null, this.#i = 0, this.#s = gn, this.#a = null, this.#r = null, this.#o = null, this.#n = "0x", this.#f = gn, this.#l = gn, this.#p = null, this.#A = null, this.#c = null, this.#h = null, this.#u = null, this.#d = null, this.#b = null, this.#g = null;+ }+ /**+ * The transaction hash, if signed. Otherwise, ``null``.+ */+ get hash() {+ return this.signature == null ? null : Zt(this.#m(!0, !1));+ }+ /**+ * The pre-image hash of this transaction.+ *+ * This is the digest that a [[Signer]] must sign to authorize+ * this transaction.+ */+ get unsignedHash() {+ return Zt(this.unsignedSerialized);+ }+ /**+ * The sending address, if signed. Otherwise, ``null``.+ */+ get from() {+ return this.signature == null ? null : nF(this.unsignedHash, this.signature.getCanonical());+ }+ /**+ * The public key of the sender, if signed. Otherwise, ``null``.+ */+ get fromPublicKey() {+ return this.signature == null ? null : ts.recoverPublicKey(this.unsignedHash, this.signature.getCanonical());+ }+ /**+ * Returns true if signed.+ *+ * This provides a Type Guard that properties requiring a signed+ * transaction are non-null.+ */+ isSigned() {+ return this.signature != null;+ }+ #m(e, t) {+ ge(!e || this.signature != null, "cannot serialize unsigned transaction; maybe you meant .unsignedSerialized", "UNSUPPORTED_OPERATION", { operation: ".serialized" });+ const n = e ? this.signature : null;+ switch (this.inferType()) {+ case 0:+ return pF(this, n);+ case 1:+ return bF(this, n);+ case 2:+ return gF(this, n);+ case 3:+ return _F(this, n, t ? this.blobs : null);+ case 4:+ return yF(this, n);+ }+ ge(!1, "unsupported transaction type", "UNSUPPORTED_OPERATION", { operation: ".serialized" });+ }+ /**+ * The serialized transaction.+ *+ * This throws if the transaction is unsigned. For the pre-image,+ * use [[unsignedSerialized]].+ */+ get serialized() {+ return this.#m(!0, !0);+ }+ /**+ * The transaction pre-image.+ *+ * The hash of this is the digest which needs to be signed to+ * authorize this transaction.+ */+ get unsignedSerialized() {+ return this.#m(!1, !1);+ }+ /**+ * Return the most "likely" type; currently the highest+ * supported transaction type.+ */+ inferType() {+ const e = this.inferTypes();+ return e.indexOf(2) >= 0 ? 2 : e.pop();+ }+ /**+ * Validates the explicit properties and returns a list of compatible+ * transaction types.+ */+ inferTypes() {+ const e = this.gasPrice != null, t = this.maxFeePerGas != null || this.maxPriorityFeePerGas != null, n = this.accessList != null, s = this.#c != null || this.#h;+ this.maxFeePerGas != null && this.maxPriorityFeePerGas != null && ge(this.maxFeePerGas >= this.maxPriorityFeePerGas, "priorityFee cannot be more than maxFee", "BAD_DATA", { value: this }), ge(!t || this.type !== 0 && this.type !== 1, "transaction type cannot have maxFeePerGas or maxPriorityFeePerGas", "BAD_DATA", { value: this }), ge(this.type !== 0 || !n, "legacy transaction cannot have accessList", "BAD_DATA", { value: this });+ const r = [];+ return this.type != null ? r.push(this.type) : this.authorizationList && this.authorizationList.length ? r.push(4) : t ? r.push(2) : e ? (r.push(1), n || r.push(0)) : n ? (r.push(1), r.push(2)) : (s && this.to || (r.push(0), r.push(1), r.push(2)), r.push(3)), r.sort(), r;+ }+ /**+ * Returns true if this transaction is a legacy transaction (i.e.+ * ``type === 0``).+ *+ * This provides a Type Guard that the related properties are+ * non-null.+ */+ isLegacy() {+ return this.type === 0;+ }+ /**+ * Returns true if this transaction is berlin hardform transaction (i.e.+ * ``type === 1``).+ *+ * This provides a Type Guard that the related properties are+ * non-null.+ */+ isBerlin() {+ return this.type === 1;+ }+ /**+ * Returns true if this transaction is london hardform transaction (i.e.+ * ``type === 2``).+ *+ * This provides a Type Guard that the related properties are+ * non-null.+ */+ isLondon() {+ return this.type === 2;+ }+ /**+ * Returns true if this transaction is an [[link-eip-4844]] BLOB+ * transaction.+ *+ * This provides a Type Guard that the related properties are+ * non-null.+ */+ isCancun() {+ return this.type === 3;+ }+ /**+ * Create a copy of this transaciton.+ */+ clone() {+ return pi.from(this);+ }+ /**+ * Return a JSON-friendly object.+ */+ toJSON() {+ const e = (t) => t == null ? null : t.toString();+ return {+ type: this.type,+ to: this.to,+ // from: this.from,+ data: this.data,+ nonce: this.nonce,+ gasLimit: e(this.gasLimit),+ gasPrice: e(this.gasPrice),+ maxPriorityFeePerGas: e(this.maxPriorityFeePerGas),+ maxFeePerGas: e(this.maxFeePerGas),+ value: e(this.value),+ chainId: e(this.chainId),+ sig: this.signature ? this.signature.toJSON() : null,+ accessList: this.accessList+ };+ }+ [cF]() {+ return this.toString();+ }+ toString() {+ const e = [], t = (s) => {+ let r = this[s];+ typeof r == "string" && (r = JSON.stringify(r)), e.push(`${s}: ${r}`);+ };+ this.type && t("type"), t("to"), t("data"), t("nonce"), t("gasLimit"), t("value"), this.chainId != null && t("chainId"), this.signature && (t("from"), e.push(`signature: ${this.signature.toString()}`));+ const n = this.authorizationList;+ if (n) {+ const s = [];+ for (const r of n) {+ const a = [];+ a.push(`address: ${JSON.stringify(r.address)}`), r.nonce != null && a.push(`nonce: ${r.nonce}`), r.chainId != null && a.push(`chainId: ${r.chainId}`), r.signature && a.push(`signature: ${r.signature.toString()}`), s.push(`Authorization { ${a.join(", ")} }`);+ }+ e.push(`authorizations: [ ${s.join(", ")} ]`);+ }+ return `Transaction { ${e.join(", ")} }`;+ }+ /**+ * Create a **Transaction** from a serialized transaction or a+ * Transaction-like object.+ */+ static from(e) {+ if (e == null)+ return new pi();+ if (typeof e == "string") {+ const n = ht(e);+ if (n[0] >= 127)+ return pi.from(fF(n));+ switch (n[0]) {+ case 1:+ return pi.from(mF(n));+ case 2:+ return pi.from(AF(n));+ case 3:+ return pi.from(xF(n));+ case 4:+ return pi.from(EF(n));+ }+ ge(!1, "unsupported transaction type", "UNSUPPORTED_OPERATION", { operation: "from" });+ }+ const t = new pi();+ return e.type != null && (t.type = e.type), e.to != null && (t.to = e.to), e.nonce != null && (t.nonce = e.nonce), e.gasLimit != null && (t.gasLimit = e.gasLimit), e.gasPrice != null && (t.gasPrice = e.gasPrice), e.maxPriorityFeePerGas != null && (t.maxPriorityFeePerGas = e.maxPriorityFeePerGas), e.maxFeePerGas != null && (t.maxFeePerGas = e.maxFeePerGas), e.maxFeePerBlobGas != null && (t.maxFeePerBlobGas = e.maxFeePerBlobGas), e.data != null && (t.data = e.data), e.value != null && (t.value = e.value), e.chainId != null && (t.chainId = e.chainId), e.signature != null && (t.signature = Gt.from(e.signature)), e.accessList != null && (t.accessList = e.accessList), e.authorizationList != null && (t.authorizationList = e.authorizationList), e.blobVersionedHashes != null && (t.blobVersionedHashes = e.blobVersionedHashes), e.kzg != null && (t.kzg = e.kzg), e.blobWrapperVersion != null && (t.blobWrapperVersion = e.blobWrapperVersion), e.blobs != null && (t.blobs = e.blobs), e.hash != null && (V(t.isSigned(), "unsigned transaction cannot define '.hash'", "tx", e), V(t.hash === e.hash, "hash mismatch", "tx", e)), e.from != null && (V(t.isSigned(), "unsigned transaction cannot define '.from'", "tx", e), V(t.from.toLowerCase() === (e.from || "").toLowerCase(), "from mismatch", "tx", e)), t;+ }+}+function Sr(i) {+ return Zt(cs(i));+}+var wF = "AEEUdwmgDS8BxQKKAP4BOgDjATAAngDUAIMAoABoAOAAagCOAEQAhABMAHIAOwA9ACsANgAmAGIAHgAuACgAJwAXAC0AGgAjAB8ALwAUACkAEgAeAAkAGwARABkAFgA5ACgALQArADcAFQApABAAHgAiABAAGgAeABMAGAUhBe8BFxREN8sF2wC5AK5HAW8ArQkDzQCuhzc3NzcBP68NEfMABQdHBuw5BV8FYAA9MzkI9r4ZBg7QyQAWA9CeOwLNCjcCjqkChuA/lm+RAsXTAoP6ASfnEQDytQFJAjWVCkeXAOsA6godAB/cwdAUE0WlBCN/AQUCQRjFD/MRBjHxDQSJbw0jBzUAswBxme+tnIcAYwabAysG8QAjAEMMmxcDqgPKQyDXCMMxA7kUQwD3NXOrAKmFIAAfBC0D3x4BJQDBGdUFAhEgVD8JnwmQJiNWYUzrg0oAGwAUAB0AFnNcACkAFgBP9h3gPfsDOWDKneY2ChglX1UDYD30ABsAFAAdABZzIGRAnwDD8wAjAEEMzRbDqgMB2sAFYwXqAtCnAsS4AwpUJKRtFHsadUz9AMMVbwLpABM1NJEX0ZkCgYMBEyMAxRVvAukAEzUBUFAtmUwSAy4DBTER33EftQHfSwB5MxJ/AjkWKQLzL8E/cwBB6QH9LQDPDtO9ASNriQC5DQANAwCK21EFI91zHwCoL9kBqQcHBwcHKzUDowBvAQohPvU3fAQgHwCyAc8CKQMA5zMSezr7ULgFmDp/LzVQBgEGAi8FYQVgt8AFcTtlQhpCWEmfe5tmZ6IAExsDzQ8t+X8rBKtTAltbAn0jsy8Bl6utPWMDTR8Ei2kRANkDBrNHNysDBzECQWUAcwFpJ3kAiyUhAJ0BUb8AL3EfAbfNAz81KUsFWwF3YQZtAm0A+VEfAzEJDQBRSQCzAQBlAHsAM70GD/v3IZWHBwARKQAxALsjTwHZAeMPEzmXgIHwABIAGQA8AEUAQDt3gdvIEGcQZAkGTRFMdEIVEwK0D64L7REdDNkq09PgADSxB/MDWwfzA1sDWwfzB/MDWwfzA1sDWwNbA1scEvAi28gQZw9QBHUFlgWTBN4IiyZREYkHMAjaVBV0JhxPA00BBCMtSSQ7mzMTJUpMFE0LCAQ2SmyvfUADTzGzVP2QqgPTMlc5dAkGHnkSqAAyD3skNb1OhnpPcagKU0+2tYdJak5vAsY6sEAACikJm2/Dd1YGRRAfJ6kQ+ww3AbkBPw3xS9wE9QY/BM0fgRkdD9GVoAipLeEM8SbnLqWAXiP5KocF8Uv4POELUVFsD10LaQnnOmeBUgMlAREijwrhDT0IcRD3Cs1vDekRSQc9A9lJngCpBwULFR05FbkmFGKwCw05ewb/GvoLkyazEy17AAXXGiUGUQEtGwMA0y7rhbRaNVwgT2MGBwspI8sUrFAkDSlAu3hMGh8HGSWtApVDdEqLUToelyH6PEENai4XUYAH+TwJGVMLhTyiRq9FEhHWPpE9TCJNTDAEOYMsMyePCdMPiQy9fHYBXQklCbUMdRM1ERs3yQg9Bx0xlygnGQglRplgngT7owP3E9UDDwVDCUUHFwO5HDETMhUtBRGBKNsC9zbZLrcCk1aEARsFzw8pH+MQVEfkDu0InwJpA4cl7wAxFSUAGyKfCEdnAGOP3FMJLs8Iy2pwI3gDaxTrZRF3B5UOWwerHDcVwxzlcMxeD4YMKKezCV8BeQmdAWME5wgNNV+MpCBFZ1eLXBifIGVBQ14AAjUMaRWjRMGHfAKPD28SHwE5AXcHPQ0FAnsR8RFvEJkI74YINbkz/DopBFMhhyAVCisDU2zSCysm/Qz8bQGnEmYDEDRBd/Jnr2C6KBgBBx0yyUFkIfULlk/RDKAaxRhGVDIZ6AfDA/ca9yfuQVsGAwOnBxc6UTPyBMELbQiPCUMATQ6nGwfbGG4KdYzUATWPAbudA1uVhwJzkwY7Bw8Aaw+LBX3pACECqwinAAkA0wNbAD0CsQehAB0AiUUBQQMrMwEl6QKTA5cINc8BmTMB9y0EH8cMGQD7O25OAsO1AoBuZqYF4VwCkgJNOQFRKQQJUktVA7N15QDfAE8GF+NLARmvTs8e50cB43MvAMsA/wAJOQcJRQHRAfdxALsBYws1Caa3uQFR7S0AhwAZbwHbAo0A4QA5AIP1AVcAUQVd/QXXAlNNARU1HC9bZQG/AyMBNwERAH0Gz5GpzQsjBHEH1wIQHxXlAu8yB7kFAyLjE9FCyQK94lkAMhoKPAqrCqpgX2Q3CjV2PVQAEh+sPss/UgVVO1c7XDtXO1w7VztcO1c7XDtXO1wDm8Pmw+YKcF9JYe8Mqg3YRMw6TRPfYFVgNhPMLbsUxRXSJVoZQRrAJwkl6FUNDwgt12Y0CDA0eRfAAEMpbINFY4oeNApPHOtTlVT8LR8AtUumM7MNsBsZREQFS3XxYi4WEgomAmSFAmJGX1GzAV83JAKh+wJonAJmDQKfiDgfDwJmPwJmKgRyBIMDfxcDfpY5Cjl7GzmGOicnAmwhAjI6OA4CbcsCbbLzjgM3a0kvAWsA4gDlAE4JB5wMkQECD8YAEbkCdzMCdqZDAnlPRwJ4viFg30WyRvcCfEMCeswCfQ0CfPRIBEiBZygALxlJXEpfGRtK0ALRBQLQ0EsrA4hTA4fqRMmRNgLypV0HAwOyS9JMMSkH001QTbMCi0MCitzFHwshR2sJuwKOOwKOYESbhQKO3QKOYHxRuFM5AQ5S2FSJApP/ApMQAO0AIFUiVbNV1AosHymZijLleGpFPz0Cl6MC77ZYJawAXSkClpMCloCgAK1ZsFoNhVEAPwKWuQKWUlxIXNUCmc8CmWhczl0LHQKcnznGOqECnBoCn58CnryOACETNS4TAp31Ap6WALlBYThh8wKe1wKgcgGtAp6jIwKeUqljzGQrKS8CJ7MCJoICoP8CoFDbAqYzAqXSAqgDAIECp/ZogGi1AAdNaiBq1QKs5wKssgKtawKtBgJXIQJV4AKx5dsDH1JsmwKywRECsuwbbORtZ21MYwMl0QK2YD9DbpQDKUkCuGICuUsZArkue3A6cOUCvR0DLbYDMhUCvoxyBgMzdQK+HnMmc1MCw88CwwhzhnRPOUl05AM8qwEDPJ4DPcMCxYACxksCxhSNAshtVQLISALJUwLJMgJkoQLd1nh9ZXiyeSlL1AMYp2cGAmH4GfeVKHsPXpZevxUCz28Cz3AzT1fW9xejAMqxAs93AS3uA04Wfk8JAtwrAtuOAtJTA1JgA1NjAQUDVZCAjUMEzxrxZEl5A4LSg5EC2ssC2eKEFIRNp0ADhqkAMwNkEoZ1Xf0AWQLfaQLevHd7AuIz7RgB8zQrAfSfAfLWiwLr9wLpdH0DAur9AuroAP1LAb0C7o0C66CWrpcHAu5DA4XkmH1w5HGlAvMHAG0DjhqZlwL3FwORcgOSiwL3nAL53QL4apogmq+/O5siA52HAv7+AR8APZ8gAZ+3AwWRA6ZuA6bdANXJAwZuoYyiCQ0DDE0BEwEjB3EGZb1rCQC/BG/DFY8etxEAG3k9ACcDNxJRA42DAWcrJQCM8wAlAOanC6OVCLsGI6fJBgCvBRnDBvElRUYFFoAFcD9GSDNCKUK8X3kZX8QAls0FOgCQVCGbwTsuYDoZutcONxjOGJHJ/gVfBWAFXwVgBWsFYAVfBWAFXwVgBV8FYAVfBWBOHQjfjW8KCgoKbF7xMwTRA7kGN8PDAMMEr8MA70gxFroFTj5xPnhCR0K+X30/X/AAWBkzswCNBsxzzASm70aCRS4rDDMeLz49fnXfcsH5GcoscQFz13Y4HwVnBXLJycnACNdRYwgICAqEXoWTxgA7P4kACxbZBu21Kw0AjMsTAwkVAOVtJUUsJ1JCuULESUArXy9gPi9AKwnJRQYKTD9LPoA+iT54PnkCkULEUUpDX9NWV3JVEjQAc1w3A3IBE3YnX+g7QiMJb6MKaiszRCUuQrNCxDPMCcwEX9EWJzYREBEEBwIHKn6l33JCNVIfybPJtAltydPUCmhBZw/tEKsZAJOVJU1CLRuxbUHOQAo7P0s+eEJHHA8SJVRPdGM0NVrpvBoKhfUlM0JHHGUQUhEWO1xLSj8MO0ucNAqJIzVCRxv9EFsqKyA4OQgNj2nwZgp5ZNFgE2A1K3YHS2AhQQojJmC7DgpzGG1WYFUZCQYHZO9gHWCdYIVgu2BTYJlwFh8GvRbcXbG8YgtDHrMBwzPVyQonHQgkCyYBgQJ0Ajc4nVqIAwGSCsBPIgDsK3SWEtIVBa5N8gGjAo+kVwVIZwD/AEUSCDweX4ITrRQsJ8K3TwBXFDwEAB0TvzVcAtoTS20RIwDgVgZ9BBImYgA5AL4Coi8LFnezOkCnIQFjAY4KBAPh9RcGsgZSBsEAJctdsWIRu2kTkQstRw7DAcMBKgpPBGIGMDAwKCYnKTQaLg4AKRSVAFwCdl+YUZ0JdicFD3lPAdt1F9ZZKCGxuE3yBxkFVGcA/wBFEgiCBwAOLHQSjxOtQDg1z7deFRMAZ8QTAGtKb1ApIiPHADkAvgKiLy1DFtYCmBiDAlDDWNB0eo7fpaMO/aEVRRv0ATEQZBIODyMEAc8JQhCbDRgzFD4TAEMAu9YBCgCsAOkAm5I3ABwAYxvONnR+MhXJAxgKQyxL2+kkJhMbhQKDBMkSsvF0AD9BNQ6uQC7WqSQHwxEAEEIu1hkhAH2z4iQPwyJPHNWpdyYBRSpnJALzoBAEVPPsH20MxA0CCEQKRgAFyAtFAlMNwwjEDUQJRArELtapMg7DDZgJIw+TGukEIwvDFkMAqAtDEMMMBhioe+QAO3MMRAACrgnEBSPY9Q0FDnbSBoMAB8MSYxkSxAEJAPIJAAB8FWMOFtMc/HcXwxhDAC7DAvOowwAewwJdKDKHAAHDAALrFUQVwwAbwyvzpWMWv8wA/ABpAy++bcYDUKPD0KhDCwKmJ1MAAmMA5+UZwxAagwipBRL/eADfw6fDGOMCGsOjk3l6BwOpo4sAEsMOGxMAA5sAbcMOAAvDp0MJGkMDwgipnNIPAwfIqUMGAOGDAAPzABXDAAcDAAnDAGmTABrDAA7DChjDjnEWAwABYwAOcwAuUyYABsMAF8MIKQANUgC6wy4AA8MADqMq8wCyYgAcIwAB8wqpAAXOCx0V4wAHowBCwwEKAGnDAAuDAB3DAAjDCakABdIAbqcZ3QCZCCkABdIAAAFDAAfjAB2jCCkABqIACYMAGzMAbSMA5sOIAAhjAAhDABTDBAkpAAbSAOOTAAlDC6kOzPtnAAdDAG6kQFAATwAKwwwAA0MACbUDPwAHIwAZgwACE6cDAAojAApDAAoDp/MGwwAJIwADEwAQQwgAFEMAEXMAD5MADfMADcMAGRMOFiMAFUMAbqMWuwHDAMIAE0MLAGkzEgDhUwACQwAEWgAXgwUjAAbYABjDBSYBgzBaAEFNALcQBxUMegAwMngBrA0IZgJ0KxQHBREPd1N0ZzKRJwaIHAZqNT4DqQq8BwngAB4DAwt2AX56T1ocKQNXAh1GATQGC3tOxYNagkgAMQA5CQADAQEAWxLjAIOYNAEzAH7tFRk6TglSAF8NAAlYAQ+S1ACAQwQorQBiAN4dAJ1wPyeTANVzuQDX3AIeEMp9eyMgXiUAEdkBkJizKltbVVAaRMqRAAEAhyQ/SDEz6BmfVwB6ATEsOClKIRcDOF0E/832AFNt5AByAnkCRxGCOs94NjXdAwINGBonDBwPALW2AwICAgAAAAAAAAYDBQMDARrUAwAtAAAAAgEGBgYGBgYFBQUFBQUEBQYHCAkEBQUFBQQAAAICAAAAIgCNAJAAlT0A6gC7ANwApEQAwgCyAK0AqADuAKYA2gCjAOcBCAEDAMcAgQBiANIA1AEDAN4A8gCQAKkBMQDqAN8A3AsBCQ8yO9ra2tq8xuLT1tRJOB0BUgFcNU0BWgFpAWgBWwFMUUlLbhMBUxsNEAs6PhMOACcUKy0vMj5AQENDQ0RFFEYGJFdXV1dZWVhZL1pbXVxcI2NnZ2ZoZypsbnZ1eHh4eHh4enp6enp6enp6enp8fH18e2IARPIASQCaAHgAMgBm+ACOAFcAVwA3AnbvAIsABfj4AGQAk/IAnwBPAGIAZP//sACFAIUAaQBWALEAJAC2AIMCQAJDAPwA5wD+AP4A6AD/AOkA6QDoAOYALwJ7AVEBQAE+AVQBPgE+AT4BOQE4ATgBOAEcAVgXADEQCAEAUx8SHgsdHhYAjgCWAKYAUQBqIAIxAHYAbwCXAxUDJzIDIUlGTzEAkQJPAMcCVwKkAMAClgKWApYClgKWApYCiwKWApYClgKWApYClgKVApUCmAKgApcClgKWApQClAKUApQCkgKVAnUB1AKXAp8ClgKWApUeAIETBQD+DQOfAmECOh8BVBg9AuIZEjMbAU4/G1WZAXusRAFpYQEFA0FPAQYAmTEeIJdyADFoAHEANgCRA5zMk/C2jGINwjMWygIZCaXdfDILBCs5dAE7YnQBugDlhoiHhoiGiYqKhouOjIaNkI6Ij4qQipGGkoaThpSSlYaWhpeKmIaZhpqGm4aci52QnoqfhuIC4XTpAt90AIp0LHSoAIsAdHQEQwRABEIERQRDBEkERgRBBEcESQRIBEQERgRJAJ5udACrA490ALxuAQ10ANFZdHQA13QCFHQA/mJ0AP4BIQD+APwA/AD9APwDhGZ03ASMK23HAP4A/AD8AP0A/CR0dACRYnQA/gCRASEA/gCRAvQA/gCRA4RmdNwEjCttxyR0AP9idAEhAP4A/gD8APwA/QD8AP8A/AD8AP0A/AOEZnTcBIwrbcckdHQAkWJ0ASEA/gCRAP4AkQL0AP4AkQOEZnTcBIwrbcckdAJLAT50AlIBQXQCU8l0dAJfdHQDpgL0A6YDpgOnA6cDpwOnA4RmdNwEjCttxyR0dACRYnQBIQOmAJEDpgCRAvQDpgCRA4RmdNwEjCttxyR0BDh0AJEEOQCRDpU5dSgCADR03gV2CwArdAEFAM5iCnR0AF1iAAYcOgp0dACRCnQAXAEIwWZ0CnRmdHQAkWZ0CnRmdEXgAFF03gp0dEY0tlT2u3SOAQTwscwhjZZKrhYcBSfFp9XNbKiVDOD2b+cpe4/Z17mQnbtzzhaeQtE2GGj0IDNTjRUSyTxxw/RPHW/+vS7d1NfRt9z9QPZg4X7QFfhCnkvgNPIItOsC2eV6hPannZNHlZ9xrwZXIMOlu3jSoQSq78WEjwLjw1ELSlF1aBvfzwk5ZX7AUvQzjPQKbDuQ+sm4wNOp4A6AdVuRS0t1y/DZpg4R6m7FNjM9HgvW7Bi88zaMjOo6lM8wtBBdj8LP4ylv3zCXPhebMKJc066o9sF71oFW/8JXu86HJbwDID5lzw5GWLR/LhT0Qqnp2JQxNZNfcbLIzPy+YypqRm/lBmGmex+82+PisxUumSeJkALIT6rJezxMH+CTJmQtt5uwTVbL3ptmjDUQzlSIvWi8Tl7ng1NpuRn1Ng4n14Qc+3Iil7OwkvNWogLSPkn3pihIFytyIGmMhOe3n1tWsuMy9BdKyqF4Z3v2SgggTL9KVvMXPnCbRe+oOuFFP3HejBG/w9gvmfNYvg6JuWia2lcSSN1uIjBktzoIazOHPJZ7kKHPz8mRWVdW3lA8WGF9dQF6Bm673boov3BUWDU2JNcahR23GtfHKLOz/viZ+rYnZFaIznXO67CYEJ1fXuTRpZhYZkKe54xeoagkNGLs+NTZHE0rX45/XvQ2RGADX6vcAvdxIUBV27wxGm2zjZo4X3ILgAlrOFheuZ6wtsvaIj4yLY7qqawlliaIcrz2G+c3vscAnCkCuMzMmZvMfu9lLwTvfX+3cVSyPdN9ZwgDZhfjRgNJcLiJ67b9xx8JHswprbiE3v9UphotAPIgnXVIN5KmMc0piXhc6cChPnN+MRhG9adtdttQTTwSIpl8I4/j//d3sz1326qTBTpPRM/Hgh3kzqEXs8ZAk4ErQhNO8hzrQ0DLkWMA/N+91tn2MdOJnWC2FCZehkQrwzwbKOjhvZsbM95QoeL9skYyMf4srVPVJSgg7pOLUtr/n9eT99oe9nLtFRpjA9okV2Kj8h9k5HaC0oivRD8VyXkJ81tcd4fHNXPCfloIQasxsuO18/46dR2jgul/UIet2G0kRvnyONMKhHs6J26FEoqSqd+rfYjeEGwHWVDpX1fh1jBBcKGMqRepju9Y00mDVHC+Xdij/j44rKfvfjGinNs1jO/0F3jB83XCDINN/HB84axlP+3E/klktRo+vl3U/aiyMJbIodE1XSsDn6UAzIoMtUObY2+k/4gY/l+AkZJ5Sj2vQrkyLm3FoxjhDX+31UXBFf9XrAH31fFqoBmDEZvhvvpnZ87N+oZEu7U9O/nnk+QWj3x8uyoRbEnf+O5UMr9i0nHP38IF5AvzrBW8YWBUR0mIAzIvndQq9N3v/Jto3aPjPXUPl8ASdPPyAp7jENf8bk7VMM9ol9XGmlBmeDMuGqt+WzuL6CXAxXjIhCPM5vACchgMJ/8XBGLO/D1isVvGhwwHHr1DLaI5mn2Jr/b1pUD90uciDaS8cXNDzCWvNmT/PhQe5e8nTnnnkt8Ds/SIjibcum/fqDhKopxAY8AkSrPn+IGDEKOO+U3XOP6djFs2H5N9+orhOahiQk5KnEUWa+CzkVzhp8bMHRbg81qhjjXuIKbHjSLSIBKWqockGtKinY+z4/RdBUF6pcc3JmnlxVcNgrI4SEzKUZSwcD2QCyxzKve+gAmg6ZuSRkpPFa6mfThu7LJNu3H5K42uCpNvPAsoedolKV/LHe/eJ+BbaG5MG0NaSGVPRUmNFMFFSSpXEcXwbVh7UETOZZtoVNRGOIbbkig3McEtR68cG0RZAoJevWYo7Dg/lZ1CQzblWeUvVHmr8fY4Nqd9JJiH/zEX24mJviH60fAyFr0A3c4bC1j3yZU60VgJxXn8JgJXLUIsiBnmKmMYz+7yBQFBvqb2eYnuW59joZBf56/wXvWIR4R8wTmV80i1mZy+S4+BUES+hzjk0uXpC///z/IlqHZ1monzlXp8aCfhGKMti73FI1KbL1q6IKO4fuBuZ59gagjn5xU79muMpHXg6S+e+gDM/U9BKLHbl9l6o8czQKl4RUkJJiqftQG2i3BMg/TQlUYFkJDYBOOvAugYuzYSDnZbDDd/aSd9x0Oe6F+bJcHfl9+gp6L5/TgA+BdFFovbfCrQ40s5vMPw8866pNX8zyFGeFWdxIpPVp9Rg1UPOVFbFZrvaFq/YAzHQgqMWpahMYfqHpmwXfHL1/kpYmGuHFwT55mQu0dylfNuq2Oq0hTMCPwqfxnuBIPLXfci4Y1ANy+1CUipQxld/izVh16WyG2Q0CQQ9NqtAnx1HCHwDj7sYxOSB0wopZSnOzxQOcExmxrVTF2BkOthVpGfuhaGECfCJpJKpjnihY+xOT2QJxN61+9K6QSqtv2Shr82I3jgJrqBg0wELFZPjvHpvzTtaJnLK6Vb97Yn933koO/saN7fsjwNKzp4l2lJVx2orjCGzC/4ZL4zCver6aQYtC5sdoychuFE6ufOiog+VWi5UDkbmvmtah/3aArEBIi39s5ILUnlFLgilcGuz9CQshEY7fw2ouoILAYPVT/gyAIq3TFAIwVsl+ktkRz/qGfnCDGrm5gsl/l9QdvCWGsjPz3dU7XuqKfdUrr/6XIgjp4rey6AJBmCmUJMjITHVdFb5m1p+dLMCL8t55zD42cmftmLEJC0Da04YiRCVUBLLa8D071/N5UBNBXDh0LFsmhV/5B5ExOB4j3WVG/S3lfK5o+V6ELHvy6RR9n4ac+VsK4VE4yphPvV+kG9FegTBH4ZRXL2HytUHCduJazB/KykjfetYxOXTLws267aGOd+I+JhKP//+VnXmS90OD/jvLcVu0asyqcuYN1mSb6XTlCkqv1vigZPIYwNF/zpWcT1GR/6aEIRjkh0yhg4LXJfaGobYJTY4JI58KiAKgmmgAKWdl5nYCeLqavRJGQNuYuZtZFGx+IkI4w4NS2xwbetNMunOjBu/hmKCI/w7tfiiyUd//4rbTeWt4izBY8YvGIN6vyKYmP/8X8wHKCeN+WRcKM70+tXKNGyevU9H2Dg5BsljnTf8YbsJ1TmMs74Ce2XlHisleguhyeg44rQOHZuw/6HTkhnnurK2d62q6yS7210SsAIaR+jXMQA+svkrLpsUY+F30Uw89uOdGAR6vo4FIME0EfVVeHTu6eKicfhSqOeXJhbftcd08sWEnNUL1C9fnprTgd83IMut8onVUF0hvqzZfHduPjbjwEXIcoYmy+P6tcJZHmeOv6VrvEdkHDJecjHuHeWANe79VG662qTjA/HCvumVv3qL+LrOcpqGps2ZGwQdFJ7PU4iuyRlBrwfO+xnPyr47s2cXVbWzAyznDiBGjCM3ksxjjqM62GE9C8f5U38kB3VjtabKp/nRdvMESPGDG90bWRLAt1Qk5DyLuazRR1YzdC1c+hZXvAWV8xA72S4A8B67vjVhbba3MMop293FeEXpe7zItMWrJG/LOH9ByOXmYnNJfjmfuX9KbrpgLOba4nZ+fl8Gbdv/ihv+6wFGKHCYrVwmhFC0J3V2bn2tIB1wCc1CST3d3X2OyxhguXcs4sm679UngzofuSeBewMFJboIQHbUh/m2JhW2hG9DIvG2t7yZIzKBTz9wBtnNC+2pCRYhSIuQ1j8xsz5VvqnyUIthvuoyyu7fNIrg/KQUVmGQaqkqZk/Vx5b33/gsEs8yX7SC1J+NV4icz6bvIE7C5G6McBaI8rVg56q5QBJWxn/87Q1sPK4+sQa8fLU5gXo4paaq4cOcQ4wR0VBHPGjKh+UlPCbA1nLXyEUX45qZ8J7/Ln4FPJE2TdzD0Z8MLSNQiykMMmSyOCiFfy84Rq60emYB2vD09KjYwsoIpeDcBDTElBbXxND72yhd9pC/1CMid/5HUMvAL27OtcIJDzNKpRPNqPOpyt2aPGz9QWIs9hQ9LiX5s8m9hjTUu/f7MyIatjjd+tSfQ3ufZxPpmJhTaBtZtKLUcfOCUqADuO+QoH8B9v6U+P0HV1GLQmtoNFTb3s74ivZgjES0qfK+8RdGgBbcCMSy8eBvh98+et1KIFqSe1KQPyXULBMTsIYnysIwiZBJYdI20vseV+wuJkcqGemehKjaAb9L57xZm3g2zX0bZ2xk/fU+bCo7TlnbW7JuF1YdURo/2Gw7VclDG1W7LOtas2LX4upifZ/23rzpsnY/ALfRgrcWP5hYmV9VxVOQA1fZvp9F2UNU+7d7xRyVm5wiLp3/0dlV7vdw1PMiZrbDAYzIVqEjRY2YU03sJhPnlwIPcZUG5ltL6S8XCxU1eYS5cjr34veBmXAvy7yN4ZjArIG0dfD/5UpBNlX1ZPoxJOwyqRi3wQWtOzd4oNKh0LkoTm8cwqgIfKhqqGOhwo71I+zXnMemTv2B2AUzABWyFztGgGULjDDzWYwJUVBTjKCn5K2QGMK1CQT7SzziOjo+BhAmqBjzuc3xYym2eedGeOIRJVyTwDw37iCMe4g5Vbnsb5ZBdxOAnMT7HU4DHpxWGuQ7GeiY30Cpbvzss55+5Km1YsbD5ea3NI9QNYIXol5apgSu9dZ8f8xS5dtHpido5BclDuLWY4lhik0tbJa07yJhH0BOyEut/GRbYTS6RfiTYWGMCkNpfSHi7HvdiTglEVHKZXaVhezH4kkXiIvKopYAlPusftpE4a5IZwvw1x/eLvoDIh/zpo9FiQInsTb2SAkKHV42XYBjpJDg4374XiVb3ws4qM0s9eSQ5HzsMU4OZJKuopFjBM+dAZEl8RUMx5uU2N486Kr141tVsGQfGjORYMCJAMsxELeNT4RmWjRcpdTGBwcx6XN9drWqPmJzcrGrH4+DRc7+n1w3kPZwu0BkNr6hQrqgo7JTB9A5kdJ/H7P4cWBMwsmuixAzJB3yrQpnGIq90lxAXLzDCdn1LPibsRt7rHNjgQBklRgPZ8vTbjXdgXrTWQsK5MdrXXQVPp0Rinq3frzZKJ0qD6Qhc40VzAraUXlob1gvkhK3vpmHgI6FRlQZNx6eRqkp0zy4AQlX813fAPtL3jMRaitGFFjo0zmErloC+h+YYdVQ6k4F/epxAoF0BmqEoKNTt6j4vQZNQ2BoqF9Vj53TOIoNmDiu9Xp15RkIgQIGcoLpfoIbenzpGUAtqFJp5W+LLnx38jHeECTJ/navKY1NWfN0sY1T8/pB8kIH3DU3DX+u6W3YwpypBMYOhbSxGjq84RZ84fWJow8pyHqn4S/9J15EcCMsXqrfwyd9mhiu3+rEo9pPpoJkdZqHjra4NvzFwuThNKy6hao/SlLw3ZADUcUp3w3SRVfW2rhl80zOgTYnKE0Hs2qp1J6H3xqPqIkvUDRMFDYyRbsFI3M9MEyovPk8rlw7/0a81cDVLmBsR2ze2pBuKb23fbeZC0uXoIvDppfTwIDxk1Oq2dGesGc+oJXWJLGkOha3CX+DUnzgAp9HGH9RsPZN63Hn4RMA5eSVhPHO+9RcRb/IOgtW31V1Q5IPGtoxPjC+MEJbVlIMYADd9aHYWUIQKopuPOHmoqSkubnAKnzgKHqgIOfW5RdAgotN6BN+O2ZYHkuemLnvQ8U9THVrS1RtLmKbcC7PeeDsYznvqzeg6VCNwmr0Yyx1wnLjyT84BZz3EJyCptD3yeueAyDWIs0L2qs/VQ3HUyqfrja0V1LdDzqAikeWuV4sc7RLIB69jEIBjCkyZedoUHqCrOvShVzyd73OdrJW0hPOuQv2qOoHDc9xVb6Yu6uq3Xqp2ZaH46A7lzevbxQEmfrzvAYSJuZ4WDk1Hz3QX1LVdiUK0EvlAGAYlG3Md30r7dcPN63yqBCIj25prpvZP0nI4+EgWoFG95V596CurXpKRBGRjQlHCvy5Ib/iW8nZJWwrET3mgd6mEhfP4KCuaLjopWs7h+MdXFdIv8dHQJgg1xi1eYqB0uDYjxwVmri0Sv5XKut/onqapC+FQiC2C1lvYJ9MVco6yDYsS3AANUfMtvtbYI2hfwZatiSsnoUeMZd34GVjkMMKA+XnjJpXgRW2SHTZplVowPmJsvXy6w3cfO1AK2dvtZEKTkC/TY9LFiKHCG0DnrMQdGm2lzlBHM9iEYynH2UcVMhUEjsc0oDBTgo2ZSQ1gzkAHeWeBXYFjYLuuf8yzTCy7/RFR81WDjXMbq2BOH5dURnxo6oivmxL3cKzKInlZkD31nvpHB9Kk7GfcfE1t+1V64b9LtgeJGlpRFxQCAqWJ5DoY77ski8gsOEOr2uywZaoO/NGa0X0y1pNQHBi3b2SUGNpcZxDT7rLbBf1FSnQ8guxGW3W+36BW0gBje4DOz6Ba6SVk0xiKgt+q2JOFyr4SYfnu+Ic1QZYIuwHBrgzr6UvOcSCzPTOo7D6IC4ISeS7zkl4h+2VoeHpnG/uWR3+ysNgPcOIXQbv0n4mr3BwQcdKJxgPSeyuP/z1Jjg4e9nUvoXegqQVIE30EHx5GHv+FAVUNTowYDJgyFhf5IvlYmEqRif6+WN1MkEJmDcQITx9FX23a4mxy1AQRsOHO/+eImX9l8EMJI3oPWzVXxSOeHU1dUWYr2uAA7AMb+vAEZSbU3qob9ibCyXeypEMpZ6863o6QPqlqGHZkuWABSTVNd4cOh9hv3qEpSx2Zy/DJMP6cItEmiBJ5PFqQnDEIt3NrA3COlOSgz43D7gpNFNJ5MBh4oFzhDPiglC2ypsNU4ISywY2erkyb1NC3Qh/IfWj0eDgZI4/ln8WPfBsT3meTjq1Uqt1E7Zl/qftqkx6aM9KueMCekSnMrcHj1CqTWWzEzPsZGcDe3Ue4Ws+XFYVxNbOFF8ezkvQGR6ZOtOLU2lQEnMBStx47vE6Pb7AYMBRj2OOfZXfisjJnpTfSNjo6sZ6qSvNxZNmDeS7Gk3yYyCk1HtKN2UnhMIjOXUzAqDv90lx9O/q/AT1ZMnit5XQe9wmQxnE/WSH0CqZ9/2Hy+Sfmpeg8RwsHI5Z8kC8H293m/LHVVM/BA7HaTJYg5Enk7M/xWpq0192ACfBai2LA/qrCjCr6Dh1BIMzMXINBmX96MJ5Hn2nxln/RXPFhwHxUmSV0EV2V0jm86/dxxuYSU1W7sVkEbN9EzkG0QFwPhyHKyb3t+Fj5WoUUTErcazE/N6EW6Lvp0d//SDPj7EV9UdJN+Amnf3Wwk3A0SlJ9Z00yvXZ7n3z70G47Hfsow8Wq1JXcfwnA+Yxa5mFsgV464KKP4T31wqIgzFPd3eCe3j5ory5fBF2hgCFyVFrLzI9eetNXvM7oQqyFgDo4CTp/hDV9NMX9JDHQ/nyHTLvZLNLF6ftn2OxjGm8+PqOwhxnPHWipkE/8wbtyri80Sr7pMNkQGMfo4ZYK9OcCC4ESVFFbLMIvlxSoRqWie0wxqnLfcLSXMSpMMQEJYDVObYsXIQNv4TGNwjq1kvT1UOkicTrG3IaBZ3XdScS3u8sgeZPVpOLkbiF940FjbCeNRINNvDbd01EPBrTCPpm12m43ze1bBB59Ia6Ovhnur/Nvx3IxwSWol+3H2qfCJR8df6aQf4v6WiONxkK+IqT4pKQrZK/LplgDI/PJZbOep8dtbV7oCr6CgfpWa8NczOkPx81iSHbsNhVSJBOtrLIMrL31LK9TqHqAbAHe0RLmmV806kRLDLNEhUEJfm9u0sxpkL93Zgd6rw+tqBfTMi59xqXHLXSHwSbSBl0EK0+loECOPtrl+/nsaFe197di4yUgoe4jKoAJDXc6DGDjrQOoFDWZJ9HXwt8xDrQP+7aRwWKWI1GF8s8O4KzxWBBcwnl3vnl1Oez3oh6Ea1vjR7/z7DDTrFtqU2W/KAEzAuXDNZ7MY73MF216dzdSbWmUp4lcm7keJfWaMHgut9x5C9mj66Z0lJ+yhsjVvyiWrfk1lzPOTdhG15Y7gQlXtacvI7qv/XNSscDwqkgwHT/gUsD5yB7LdRRvJxQGYINn9hTpodKFVSTPrtGvyQw+HlRFXIkodErAGu9Iy1YpfSPc3jkFh5CX3lPxv7aqjE/JAfTIpEjGb/H7MO0e2vsViSW1qa/Lmi4/n4DEI3g7lYrcanspDfEpKkdV1OjSLOy0BCUqVoECaB55vs06rXl4jqmLsPsFM/7vYJ0vrBhDCm/00A/H81l1uekJ/6Lml3Hb9+NKiLqATJmDpyzfYZFHumEjC662L0Bwkxi7E9U4cQA0XMVDuMYAIeLMPgQaMVOd8fmt5SflFIfuBoszeAw7ow5gXPE2Y/yBc/7jExARUf/BxIHQBF5Sn3i61w4z5xJdCyO1F1X3+3ax+JSvMeZ7S6QSKp1Fp/sjYz6Z+VgCZzibGeEoujryfMulH7Rai5kAft9ebcW50DyJr2uo2z97mTWIu45YsSnNSMrrNUuG1XsYBtD9TDYzQffKB87vWbkM4EbPAFgoBV4GQS+vtFDUqOFAoi1nTtmIOvg38N4hT2Sn8r8clmBCXspBlMBYTnrqFJGBT3wZOzAyJDre9dHH7+x7qaaKDOB4UQALD5ecS0DE4obubQEiuJZ0EpBVpLuYcce8Aa4PYd/V4DLDAJBYKQPCWTcrEaZ5HYbJi11Gd6hjGom1ii18VHYnG28NKpkz2UKVPxlhYSp8uZr367iOmoy7zsxehW9wzcy2zG0a80PBMCRQMb32hnaHeOR8fnNDzZhaNYhkOdDsBUZ3loDMa1YP0uS0cjUP3b/6DBlqmZOeNABDsLl5BI5QJups8uxAuWJdkUB/pO6Zax6tsg7fN5mjjDgMGngO+DPcKqiHIDbFIGudxtPTIyDi9SFMKBDcfdGQRv41q1AqmxgkVfJMnP8w/Bc7N9/TR6C7mGObFqFkIEom8sKi2xYqJLTCHK7cxzaZvqODo22c3wisBCP4HeAgcRbNPAsBkNRhSmD48dHupdBRw4mIvtS5oeF6zeT1KMCyhMnmhpkFAGWnGscoNkwvQ8ZM5lE/vgTHFYL99OuNxdFBxTEDd5v2qLR8y9WkXsWgG6kZNndFG+pO/UAkOCipqIhL3hq7cRSdrCq7YhUsTocEcnaFa6nVkhnSeRYUA1YO0z5itF9Sly3VlxYDw239TJJH6f3EUfYO5lb7bcFcz8Bp7Oo8QmnsUHOz/fagVUBtKEw1iT88j+aKkv8cscKNkMxjYr8344D1kFoZ7/td1W6LCNYN594301tUGRmFjAzeRg5vyoM1F6+bJZ/Q54jN/k8SFd3DxPTYaAUsivsBfgTn7Mx8H2SpPt4GOdYRnEJOH6jHM2p6SgB0gzIRq6fHxGMmSmqaPCmlfwxiuloaVIitLGN8wie2CDWhkzLoCJcODh7KIOAqbHEvXdUxaS4TTTs07Clzj/6GmVs9kiZDerMxEnhUB6QQPlcfqkG9882RqHoLiHGBoHfQuXIsAG8GTAtao2KVwRnvvam8jo1e312GQAKWEa4sUVEAMG4G6ckcONDwRcg1e2D3+ohXgY4UAWF8wHKQMrSnzCgfFpsxh+aHXMGtPQroQasRY4U6UdG0rz1Vjbka0MekOGRZQEvqQFlxseFor8zWFgHek3v29+WqN6gaK5gZOTOMZzpQIC1201LkMCXild3vWXSc5UX9xcFYfbRPzGFa1FDcPfPB/jUEq/FeGt419CI3YmBlVoHsa4KdcwQP5ZSwHHhFJ7/Ph/Rap/4vmG91eDwPP0lDfCDRCLszTqfzM71xpmiKi2HwS4WlqvGNwtvwF5Dqpn6KTq8ax00UMPkxDcZrEEEsIvHiUXXEphdb4GB4FymlPwBz4Gperqq5pW7TQ6/yNRhW8VT5NhuP0udlxo4gILq5ZxAZk8ZGh3g4CqxJlPKY7AQxupfUcVpWT5VItp1+30UqoyP4wWsRo3olRRgkWZZ2ZN6VC3OZFeXB8NbnUrSdikNptD1QiGuKkr8EmSR/AK9Rw+FF3s5uwuPbvHGiPeFOViltMK7AUaOsq9+x9cndk3iJEE5LKZRlWJbKOZweROzmPNVPkjE3K/TyA57Rs68TkZ3MR8akKpm7cFjnjPd/DdkWjgYoKHSr5Wu5ssoBYU4acRs5g2DHxUmdq8VXOXRbunD8QN0LhgkssgahcdoYsNvuXGUK/KXD/7oFb+VGdhqIn02veuM5bLudJOc2Ky0GMaG4W/xWBxIJcL7yliJOXOpx0AkBqUgzlDczmLT4iILXDxxtRR1oZa2JWFgiAb43obrJnG/TZC2KSK2wqOzRZTXavZZFMb1f3bXvVaNaK828w9TO610gk8JNf3gMfETzXXsbcvRGCG9JWQZ6+cDPqc4466Yo2RcKH+PILeKOqtnlbInR3MmBeGG3FH10yzkybuqEC2HSQwpA0An7d9+73BkDUTm30bZmoP/RGbgFN+GrCOfADgqr0WbI1a1okpFms8iHYw9hm0zUvlEMivBRxModrbJJ+9/p3jUdQQ9BCtQdxnOGrT5dzRUmw0593/mbRSdBg0nRvRZM5/E16m7ZHmDEtWhwvfdZCZ8J8M12W0yRMszXamWfQTwIZ4ayYktrnscQuWr8idp3PjT2eF/jmtdhIfcpMnb+IfZY2FebW6UY/AK3jP4u3Tu4zE4qlnQgLFbM19EBIsNf7KhjdbqQ/D6yiDb+NlEi2SKD+ivXVUK8ib0oBo366gXkR8ZxGjpJIDcEgZPa9TcYe0TIbiPl/rPUQDu3XBJ9X/GNq3FAUsKsll57DzaGMrjcT+gctp+9MLYXCq+sqP81eVQ0r9lt+gcQfZbACRbEjvlMskztZG8gbC8Qn9tt26Q7y7nDrbZq/LEz7kR6Jc6pg3N9rVX8Y5MJrGlML9p9lU4jbTkKqCveeZUJjHB03m2KRKR2TytoFkTXOLg7keU1s1lrPMQJpoOKLuAAC+y1HlJucU6ysB5hsXhvSPPLq5J7JtnqHKZ4vYjC4Vy8153QY+6780xDuGARsGbOs1WqzH0QS765rnSKEbbKlkO8oI/VDwUd0is13tKpqILu1mDJFNy/iJAWcvDgjxvusIT+PGz3ST/J9r9Mtfd0jpaGeiLYIqXc7DiHSS8TcjFVksi66PEkxW1z6ujbLLUGNNYnzOWpH8BZGK4bCK7iR+MbIv8ncDAz1u4StN3vTTzewr9IQjk9wxFxn+6N1ddKs0vffJiS08N3a4G1SVrlZ97Q/M+8G9fe5AP6d9/Qq4WRnORVhofPIKEdCr3llspUfE0oKIIYoByBRPh+bX1HLS3JWGJRhIvE1aW4NTd8ePi4Z+kXb+Z8snYfSNcqijhAgVsx4RCM54cXUiYkjeBmmC4ajOHrChoELscJJC7+9jjMjw5BagZKlgRMiSNYz7h7vvZIoQqbtQmspc0cUk1G/73iXtSpROl5wtLgQi0mW2Ex8i3WULhcggx6E1LMVHUsdc9GHI1PH3U2Ko0PyGdn9KdVOLm7FPBui0i9a0HpA60MsewVE4z8CAt5d401Gv6zXlIT5Ybit1VIA0FCs7wtvYreru1fUyW3oLAZ/+aTnZrOcYRNVA8spoRtlRoWflsRClFcgzkqiHOrf0/SVw+EpVaFlJ0g4Kxq1MMOmiQdpMNpte8lMMQqm6cIFXlnGbfJllysKDi+0JJMotkqgIxOSQgU9dn/lWkeVf8nUm3iwX2Nl3WDw9i6AUK3vBAbZZrcJpDQ/N64AVwjT07Jef30GSSmtNu2WlW7YoyW2FlWfZFQUwk867EdLYKk9VG6JgEnBiBxkY7LMo4YLQJJlAo9l/oTvJkSARDF/XtyAzM8O2t3eT/iXa6wDN3WewNmQHdPfsxChU/KtLG2Mn8i4ZqKdSlIaBZadxJmRzVS/o4yA65RTSViq60oa395Lqw0pzY4SipwE0SXXsKV+GZraGSkr/RW08wPRvqvSUkYBMA9lPx4m24az+IHmCbXA+0faxTRE9wuGeO06DIXa6QlKJ3puIyiuAVfPr736vzo2pBirS+Vxel3TMm3JKhz9o2ZoRvaFVpIkykb0Hcm4oHFBMcNSNj7/4GJt43ogonY2Vg4nsDQIWxAcorpXACzgBqQPjYsE/VUpXpwNManEru4NwMCFPkXvMoqvoeLN3qyu/N1eWEHttMD65v19l/0kH2mR35iv/FI+yjoHJ9gPMz67af3Mq/BoWXqu3rphiWMXVkmnPSEkpGpUI2h1MThideGFEOK6YZHPwYzMBvpNC7+ZHxPb7epfefGyIB4JzO9DTNEYnDLVVHdQyvOEVefrk6Uv5kTQYVYWWdqrdcIl7yljwwIWdfQ/y+2QB3eR/qxYObuYyB4gTbo2in4PzarU1sO9nETkmj9/AoxDA+JM3GMqQtJR4jtduHtnoCLxd1gQUscHRB/MoRYIEsP2pDZ9KvHgtlk1iTbWWbHhohwFEYX7y51fUV2nuUmnoUcqnWIQAAgl9LTVX+Bc0QGNEhChxHR4YjfE51PUdGfsSFE6ck7BL3/hTf9jLq4G1IafINxOLKeAtO7quulYvH5YOBc+zX7CrMgWnW47/jfRsWnJjYYoE7xMfWV2HN2iyIqLI";+const $g = /* @__PURE__ */ new Map([[8217, "apostrophe"], [8260, "fraction slash"], [12539, "middle dot"]]), em = 4;+function vF(i) {+ let e = 0;+ function t() {+ return i[e++] << 8 | i[e++];+ }+ let n = t(), s = 1, r = [0, 1];+ for (let M = 1; M < n; M++)+ r.push(s += t());+ let a = t(), o = e;+ e += a;+ let c = 0, l = 0;+ function h() {+ return c == 0 && (l = l << 8 | i[e++], c = 8), l >> --c & 1;+ }+ const u = 31, d = 2 ** u, f = d >>> 1, m = f >> 1, A = d - 1;+ let g = 0;+ for (let M = 0; M < u; M++) g = g << 1 | h();+ let p = [], y = 0, b = d;+ for (; ; ) {+ let M = Math.floor(((g - y + 1) * s - 1) / b), w = 0, S = n;+ for (; S - w > 1; ) {+ let v = w + S >>> 1;+ M < r[v] ? S = v : w = v;+ }+ if (w == 0) break;+ p.push(w);+ let T = y + Math.floor(b * r[w] / s), C = y + Math.floor(b * r[w + 1] / s) - 1;+ for (; ((T ^ C) & f) == 0; )+ g = g << 1 & A | h(), T = T << 1 & A, C = C << 1 & A | 1;+ for (; T & ~C & m; )+ g = g & f | g << 1 & A >>> 1 | h(), T = T << 1 ^ f, C = (C ^ f) << 1 | f | 1;+ y = T, b = 1 + C - T;+ }+ let E = n - 4;+ return p.map((M) => {+ switch (M - E) {+ case 3:+ return E + 65792 + (i[o++] << 16 | i[o++] << 8 | i[o++]);+ case 2:+ return E + 256 + (i[o++] << 8 | i[o++]);+ case 1:+ return E + i[o++];+ default:+ return M - 1;+ }+ });+}+function CF(i) {+ let e = 0;+ return () => i[e++];+}+function ox(i) {+ return CF(vF(SF(i)));+}+function SF(i) {+ let e = [];+ [..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"].forEach((s, r) => e[s.charCodeAt(0)] = r);+ let t = i.length, n = new Uint8Array(6 * t >> 3);+ for (let s = 0, r = 0, a = 0, o = 0; s < t; s++)+ o = o << 6 | e[i.charCodeAt(s)], a += 6, a >= 8 && (n[r++] = o >> (a -= 8));+ return n;+}+function IF(i) {+ return i & 1 ? ~i >> 1 : i >> 1;+}+function MF(i, e) {+ let t = Array(i);+ for (let n = 0, s = 0; n < i; n++) t[n] = s += IF(e());+ return t;+}+function Wo(i, e = 0) {+ let t = [];+ for (; ; ) {+ let n = i(), s = i();+ if (!s) break;+ e += n;+ for (let r = 0; r < s; r++)+ t.push(e + r);+ e += s + 1;+ }+ return t;+}+function cx(i) {+ return qo(() => {+ let e = Wo(i);+ if (e.length) return e;+ });+}+function lx(i) {+ let e = [];+ for (; ; ) {+ let t = i();+ if (t == 0) break;+ e.push(BF(t, i));+ }+ for (; ; ) {+ let t = i() - 1;+ if (t < 0) break;+ e.push(TF(t, i));+ }+ return e.flat();+}+function qo(i) {+ let e = [];+ for (; ; ) {+ let t = i(e.length);+ if (!t) break;+ e.push(t);+ }+ return e;+}+function hx(i, e, t) {+ let n = Array(i).fill().map(() => []);+ for (let s = 0; s < e; s++)+ MF(i, t).forEach((r, a) => n[a].push(r));+ return n;+}+function BF(i, e) {+ let t = 1 + e(), n = e(), s = qo(e);+ return hx(s.length, 1 + i, e).flatMap((a, o) => {+ let [c, ...l] = a;+ return Array(s[o]).fill().map((h, u) => {+ let d = u * n;+ return [c + u * t, l.map((f) => f + d)];+ });+ });+}+function TF(i, e) {+ let t = 1 + e();+ return hx(t, 1 + i, e).map((s) => [s[0], s.slice(1)]);+}+function RF(i) {+ let e = [], t = Wo(i);+ return s(n([]), []), e;+ function n(r) {+ let a = i(), o = qo(() => {+ let c = Wo(i).map((l) => t[l]);+ if (c.length) return n(c);+ });+ return { S: a, B: o, Q: r };+ }+ function s({ S: r, B: a }, o, c) {+ if (!(r & 4 && c === o[o.length - 1])) {+ r & 2 && (c = o[o.length - 1]), r & 1 && e.push(o);+ for (let l of a)+ for (let h of l.Q)+ s(l, [...o, h], c);+ }+ }+}+function NF(i) {+ return i.toString(16).toUpperCase().padStart(2, "0");+}+function ux(i) {+ return `{${NF(i)}}`;+}+function FF(i) {+ let e = [];+ for (let t = 0, n = i.length; t < n; ) {+ let s = i.codePointAt(t);+ t += s < 65536 ? 1 : 2, e.push(s);+ }+ return e;+}+function Da(i) {+ let t = i.length;+ if (t < 4096) return String.fromCodePoint(...i);+ let n = [];+ for (let s = 0; s < t; )+ n.push(String.fromCodePoint(...i.slice(s, s += 4096)));+ return n.join("");+}+function DF(i, e) {+ let t = i.length, n = t - e.length;+ for (let s = 0; n == 0 && s < t; s++) n = i[s] - e[s];+ return n;+}+var LF = "AEUDTAHBCFQATQDRADAAcgAgADQAFAAsABQAHwAOACQADQARAAoAFwAHABIACAAPAAUACwAFAAwABAAQAAMABwAEAAoABQAIAAIACgABAAQAFAALAAIACwABAAIAAQAHAAMAAwAEAAsADAAMAAwACgANAA0AAwAKAAkABAAdAAYAZwDSAdsDJgC0CkMB8xhZAqfoC190UGcThgBurwf7PT09Pb09AjgJum8OjDllxHYUKXAPxzq6tABAxgK8ysUvWAgMPT09PT09PSs6LT2HcgWXWwFLoSMEEEl5RFVMKvO0XQ8ExDdJMnIgsj26PTQyy8FfEQ8AY8IPAGcEbwRwBHEEcgRzBHQEdQR2BHcEeAR6BHsEfAR+BIAEgfndBQoBYgULAWIFDAFiBNcE2ATZBRAFEQUvBdALFAsVDPcNBw13DYcOMA4xDjMB4BllHI0B2grbAMDpHLkQ7QHVAPRNQQFnGRUEg0yEB2uaJF8AJpIBpob5AERSMAKNoAXqaQLUBMCzEiACnwRZEkkVsS7tANAsBG0RuAQLEPABv9HICTUBXigPZwRBApMDOwAamhtaABqEAY8KvKx3LQ4ArAB8UhwEBAVSagD8AEFZADkBIadVj2UMUgx5Il4ANQC9AxIB1BlbEPMAs30CGxlXAhwZKQIECBc6EbsCoxngzv7UzRQA8M0BawL6ZwkN7wABAD33OQRcsgLJCjMCjqUChtw/km+NAsXPAoP2BT84PwURAK0RAvptb6cApQS/OMMey5HJS84UdxpxTPkCogVFITaTOwERAK5pAvkNBOVyA7q3BKlOJSALAgUIBRcEdASpBXqzABXFSWZOawLCOqw//AolCZdvv3dSBkEQGyelEPcMMwG1ATsN7UvYBPEGOwTJH30ZGQ/NlZwIpS3dDO0m4y6hgFoj9SqDBe1L9DzdC01RaA9ZC2UJ4zpjgU4DIQENIosK3Q05CG0Q8wrJaw3lEUUHOQPVSZoApQcBCxEdNRW1JhBirAsJOXcG+xr2C48mrxMpevwF0xohBk0BKRr/AM8u54WwWjFcHE9fBgMLJSPHFKhQIA0lQLd4SBobBxUlqQKRQ3BKh1E2HpMh9jw9DWYuE1F8B/U8BRlPC4E8nkarRQ4R0j6NPUgiSUwsBDV/LC8niwnPD4UMuXxyAVkJIQmxDHETMREXN8UIOQcZLZckJxUIIUaVYJoE958D8xPRAwsFPwlBBxMDtRwtEy4VKQUNgSTXAvM21S6zAo9WgAEXBcsPJR/fEFBH4A7pCJsCZQODJesALRUhABcimwhDYwBfj9hTBS7LCMdqbCN0A2cU52ERcweRDlcHpxwzFb8c4XDIXguGCCijrwlbAXUJmQFfBOMICTVbjKAgQWdTi1gYmyBhQT9d/AIxDGUVn0S9h3gCiw9rEhsBNQFzBzkNAQJ3Ee0RaxCVCOuGBDW1M/g6JQRPIYMgEQonA09szgsnJvkM+GkBoxJiAww0PXfuZ6tgtiQX/QcZMsVBYCHxC5JPzQycGsEYQlQuGeQHvwPzGvMn6kFXBf8DowMTOk0z7gS9C2kIiwk/AEkOoxcH1xhqCnGM0AExiwG3mQNXkYMCb48GNwcLAGcLhwV55QAdAqcIowAFAM8DVwA5Aq0HnQAZAIVBAT0DJy8BIeUCjwOTCDHLAZUvAfMpBBvDDBUA9zduSgLDsQKAamaiBd1YAo4CSTUBTSUEBU5HUQOvceEA2wBLBhPfRwEVq0rLGuNDAd9vKwDHAPsABTUHBUEBzQHzbQC3AV8LMQmis7UBTekpAIMAFWsB1wKJAN0ANQB/8QFTAE0FWfkF0wJPSQERMRgrV2EBuwMfATMBDQB5BsuNpckHHwRtB9MCEBsV4QLvLge1AQMi3xPNQsUCvd5VoWACZIECYkJbTa9bNyACofcCaJgCZgkCn4Q4GwsCZjsCZiYEbgR/A38TA36SOQY5dxc5gjojIwJsHQIyNjgKAm3HAm2u74ozZ0UrAWcA3gDhAEoFB5gMjQD+C8IADbUCdy8CdqI/AnlLQwJ4uh1c20WuRtcCfD8CesgCfQkCfPAFWQUgSABIfWMkAoFtAoAAAoAFAn+uSVhKWxUXSswC0QEC0MxLJwOITwOH5kTFkTIC8qFdAwMDrkvOTC0lA89NTE2vAos/AorYwRsHHUNnBbcCjjcCjlxAl4ECjtkCjlx4UbRTNQpS1FSFApP7ApMMAOkAHFUeVa9V0AYsGymVhjLheGZFOzkCl58C77JYIagAWSUClo8ClnycAKlZrFoJgU0AOwKWtQKWTlxEXNECmcsCmWRcyl0HGQKcmznCOp0CnBYCn5sCnriKAB0PMSoPAp3xAp6SALU9YTRh7wKe0wKgbgGpAp6fHwKeTqVjyGQnJSsCJ68CJn4CoPsCoEwCot0CocQCpi8Cpc4Cp/8AfQKn8mh8aLEAA0lqHGrRAqzjAqyuAq1nAq0CAlcdAlXcArHh1wMfTmyXArK9DQKy6Bds4G1jbUhfAyXNArZcOz9ukAMpRQK4XgK5RxUCuSp3cDZw4QK9GQK72nCWAzIRAr6IcgIDM3ECvhpzInNPAsPLAsMEc4J0SzVFdOADPKcDPJoDPb8CxXwCxkcCxhCJAshpUQLIRALJTwLJLgJknQLd0nh5YXiueSVL0AMYo2cCAmH0GfOVJHsLXpJeuxECz2sCz2wvS1PS8xOfAMatAs9zASnqA04SfksFAtwnAtuKAtJPA1JcA1NfAQEDVYyAiT8AyxbtYEWCHILTgs6DjQLaxwLZ3oQQhEmnPAOGpQAvA2QOhnFZ+QBVAt9lAt64c3cC4i/tFAHzMCcB9JsB8tKHAuvzAulweQLq+QLq5AD5RwG5Au6JAuuclqqXAwLuPwOF4Jh5cOBxoQLzAwBpA44WmZMC9xMDkW4DkocC95gC+dkC+GaaHJqruzebHgOdgwL++gEbADmfHJ+zAwWNA6ZqA6bZANHFAwZqoYiiBQkDDEkCwAA/AwDhQRdTARHzA2sHl2cFAJMtK7evvdsBiZkUfxEEOQH7KQUhDp0JnwCS/SlXxQL3AZ0AtwW5AG8LbUEuFCaNLgFDAYD8AbUmAHUDDgRtACwCFgyhAAAKAj0CagPdA34EkQEgRQUhfAoABQBEABMANhICdwEABdUDa+8KxQIA9wqfJ7+xt+UBkSFBQgHpFH8RNMCJAAQAGwBaAkUChIsABjpTOpSNbQC4Oo860ACNOME63AClAOgAywE6gTo7Ofw5+Tt2iTpbO56JOm85GAFWATMBbAUvNV01njWtNWY1dTW2NcU1gjWRNdI14TWeNa017jX9NbI1wTYCNhE1xjXVNhY2JzXeNe02LjY9Ni41LSE2OjY9Njw2yTcIBJA8VzY4Nt03IDcPNsogN4k3MAoEsDxnNiQ3GTdsOo03IULUQwdC4EMLHA8PCZsobShRVQYA6X8A6bABFCnXAukBowC9BbcAbwNzBL8MDAMMAQgDAAkKCwsLCQoGBAVVBI/DvwDz9b29kaUCb0QtsRTNLt4eGBcSHAMZFhYZEhYEARAEBUEcQRxBHEEcQRxBHEEaQRxBHEFCSTxBPElISUhBNkM2QTYbNklISVmBVIgBFLWZAu0BhQCjBcEAbykBvwGJAaQcEZ0ePCklMAAhMvAIMAL54gC7Bm8EescjzQMpARQpKgDUABavAj626xQAJP0A3etzuf4NNRA7efy2Z9NQrCnC0OSyANz5BBIbJ5IFDR6miIavYS6tprjjmuKebxm5C74Q225X1pkaYYPb6f1DK4k3xMEBb9S2WMjEibTNWhsRJIA+vwNVEiXTE5iXs/wezV66oFLfp9NZGYW+Gk19J2+bCT6Ye2w6LDYdgzKMUabk595eLBCXANz9HUpWbATq9vqXVx9XDg+Pc9Xp4+bsS005SVM/BJBM4687WUuf+Uj9dEi8aDNaPxtpbDxcG1THTImUMZq4UCaaNYpsVqraNyKLJXDYsFZ/5jl7bLRtO88t7P3xZaAxhb5OdPMXqsSkp1WCieG8jXm1U99+blvLlXzPCS+M93VnJCiK+09LfaSaBAVBomyDgJua8dfUzR7ga34IvR2Nvj+A9heJ6lsl1KG4NkI1032Cnff1m1wof2B9oHJK4bi6JkEdSqeNeiuo6QoZZincoc73/TH9SXF8sCE7XyuYyW8WSgbGFCjPV0ihLKhdPs08Tx82fYAkLLc4I2wdl4apY7GU5lHRFzRWJep7Ww3wbeA3qmd59/86P4xuNaqDpygXt6M85glSBHOCGgJDnt+pN9bK7HApMguX6+06RZNjzVmcZJ+wcUrJ9//bpRNxNuKpNl9uFds+S9tdx7LaM5ZkIrPj6nIU9mnbFtVbs9s/uLgl8MVczAwet+iOEzzBlYW7RCMgE6gyNLeq6+1tIx4dpgZnd0DksJS5f+JNDpwwcPNXaaVspq1fbQajOrJgK0ofKtJ1Ne90L6VO4MOl5S886p7u6xo7OLjG8TGL+HU1JXGJgppg4nNbNJ5nlzSpuPYy21JUEcUA94PoFiZfjZue+QnyQ80ekOuZVkxx4g+cvhJfHgNl4hy1/a6+RKcKlar/J29y//EztlbVPHVUeQ1zX86eQVAjR/M3dA9w4W8LfaXp4EgM85wOWasli837PzVMOnsLzR+k3o75/lRPAJSE1xAKQzEi5v10ke+VBvRt1cwQRMd+U5mLCTGVd6XiZtgBG5cDi0w22GKcVNvHiu5LQbZEDVtz0onn7k5+heuKXVsZtSzilkLRAUmjMXEMB3J9YC50XBxPiz53SC+EhnPl9WsKCv92SM/OFFIMJZYfl0WW8tIO3UxYcwdMAj7FSmgrsZ2aAZO03BOhP1bNNZItyXYQFTpC3SG1VuPDqH9GkiCDmE+JwxyIVSO5siDErAOpEXFgjy6PQtOVDj+s6e1r8heWVvmZnTciuf4EiNZzCAd7SOMhXERIOlsHIMG399i9aLTy3m2hRLZjJVDNLS53iGIK11dPqQt0zBDyg6qc7YqkDm2M5Ve6dCWCaCbTXX2rToaIgz6+zh4lYUi/+6nqcFMAkQJKHYLK0wYk5N9szV6xihDbDDFr45lN1K4aCXBq/FitPSud9gLt5ZVn+ZqGX7cwm2z5EGMgfFpIFyhGGuDPmso6TItTMwny+7uPnLCf4W6goFQFV0oQSsc9VfMmVLcLr6ZetDZbaSFTLqnSO/bIPjA3/zAUoqgGFAEQS4IhuMzEp2I3jJzbzkk/IEmyax+rhZTwd6f+CGtwPixu8IvzACquPWPREu9ZvGkUzpRwvRRuaNN6cr0W1wWits9ICdYJ7ltbgMiSL3sTPeufgNcVqMVWFkCPDH4jG2jA0XcVgQj62Cb29v9f/z/+2KbYvIv/zzjpQAPkliaVDzNrW57TZ/ZOyZD0nlfMmAIBIAGAI0D3k/mdN4xr9v85ZbZbbqfH2jGd5hUqNZWwl5SPfoGmfElmazUIeNL1j/mkF7VNAzTq4jNt8JoQ11NQOcmhprXoxSxfRGJ9LDEOAQ+dmxAQH90iti9e2u/MoeuaGcDTHoC+xsmEeWmxEKefQuIzHbpw5Tc5cEocboAD09oipWQhtTO1wivf/O+DRe2rpl/E9wlrzBorjJsOeG1B/XPW4EaJEFdNlECEZga5ZoGRHXgYouGRuVkm8tDESiEyFNo+3s5M5puSdTyUL2llnINVHEt91XUNW4ewdMgJ4boJfEyt/iY5WXqbA+A2Fkt5Z0lutiWhe9nZIyIUjyXDC3UsaG1t+eNx6z4W/OYoTB7A6x+dNSTOi9AInctbESqm5gvOLww7OWXPrmHwVZasrl4eD113pm+JtT7JVOvnCXqdzzdTRHgJ0PiGTFYW5Gvt9R9LD6Lzfs0v/TZZHSmyVNq7viIHE6DBK7Qp07Iz55EM8SYtQvZf/obBniTWi5C2/ovHfw4VndkE5XYdjOhCMRjDeOEfXeN/CwfGduiUIfsoFeUxXeQXba7c7972XNv8w+dTjjUM0QeNAReW+J014dKAD/McQYXT7c0GQPIkn3Ll6R7gGjuiQoZD0TEeEqQpKoZ15g/0OPQI17QiSv9AUROa/V/TQN3dvLArec3RrsYlvBm1b8LWzltdugsC50lNKYLEp2a+ZZYqPejULRlOJh5zj/LVMyTDvwKhMxxwuDkxJ1QpoNI0OTWLom4Z71SNzI9TV1iXJrIu9Wcnd+MCaAw8o1jSXd94YU/1gnkrC9BUEOtQvEIQ7g0i6h+KL2JKk8Ydl7HruvgWMSAmNe+LshGhV4qnWHhO9/RIPQzY1tHRj2VqOyNsDpK0cww+56AdDC4gsWwY0XxoucIWIqs/GcwnWqlaT0KPr8mbK5U94/301i1WLt4YINTVvCFBrFZbIbY8eycOdeJ2teD5IfPLCRg7jjcFTwlMFNl9zdh/o3E/hHPwj7BWg0MU09pPrBLbrCgm54A6H+I6v27+jL5gkjWg/iYdks9jbfVP5y/n0dlgWEMlKasl7JvFZd56LfybW1eeaVO0gxTfXZwD8G4SI116yx7UKVRgui6Ya1YpixqXeNLc8IxtAwCU5IhwQgn+NqHnRaDv61CxKhOq4pOX7M6pkA+Pmpd4j1vn6ACUALoLLc4vpXci8VidLxzm7qFBe7s+quuJs6ETYmnpgS3LwSZxPIltgBDXz8M1k/W2ySNv2f9/NPhxLGK2D21dkHeSGmenRT3Yqcdl0m/h3OYr8V+lXNYGf8aCCpd4bWjE4QIPj7vUKN4Nrfs7ML6Y2OyS830JCnofg/k7lpFpt4SqZc5HGg1HCOrHvOdC8bP6FGDbE/VV0mX4IakzbdS/op+Kt3G24/8QbBV7y86sGSQ/vZzU8FXs7u6jIvwchsEP2BpIhW3G8uWNwa3HmjfH/ZjhhCWvluAcF+nMf14ClKg5hGgtPLJ98ueNAkc5Hs2WZlk2QHvfreCK1CCGO6nMZVSb99VM/ajr8WHTte9JSmkXq/i/U943HEbdzW6Re/S88dKgg8pGOLlAeNiqrcLkUR3/aClFpMXcOUP3rmETcWSfMXZE3TUOi8i+fqRnTYLflVx/Vb/6GJ7eIRZUA6k3RYR3iFSK9c4iDdNwJuZL2FKz/IK5VimcNWEqdXjSoxSgmF0UPlDoUlNrPcM7ftmA8Y9gKiqKEHuWN+AZRIwtVSxye2Kf8rM3lhJ5XcBXU9n4v0Oy1RU2M+4qM8AQPVwse8ErNSob5oFPWxuqZnVzo1qB/IBxkM3EVUKFUUlO3e51259GgNcJbCmlvrdjtoTW7rChm1wyCKzpCTwozUUEOIcWLneRLgMXh+SjGSFkAllzbGS5HK7LlfCMRNRDSvbQPjcXaenNYxCvu2Qyznz6StuxVj66SgI0T8B6/sfHAJYZaZ78thjOSIFumNWLQbeZixDCCC+v0YBtkxiBB3jefHqZ/dFHU+crbj6OvS1x/JDD7vlm7zOVPwpUC01nhxZuY/63E7g";+const Ko = 44032, Gl = 4352, Hl = 4449, zl = 4519, dx = 19, fx = 21, La = 28, Vl = fx * La, PF = dx * Vl, kF = Ko + PF, UF = Gl + dx, OF = Hl + fx, QF = zl + La;+function mo(i) {+ return i >> 24 & 255;+}+function px(i) {+ return i & 16777215;+}+let Xd, tm, Yd, bl;+function GF() {+ let i = ox(LF);+ Xd = new Map(cx(i).flatMap((e, t) => e.map((n) => [n, t + 1 << 24]))), tm = new Set(Wo(i)), Yd = /* @__PURE__ */ new Map(), bl = /* @__PURE__ */ new Map();+ for (let [e, t] of lx(i)) {+ if (!tm.has(e) && t.length == 2) {+ let [n, s] = t, r = bl.get(n);+ r || (r = /* @__PURE__ */ new Map(), bl.set(n, r)), r.set(s, e);+ }+ Yd.set(e, t.reverse());+ }+}+function Ax(i) {+ return i >= Ko && i < kF;+}+function HF(i, e) {+ if (i >= Gl && i < UF && e >= Hl && e < OF)+ return Ko + (i - Gl) * Vl + (e - Hl) * La;+ if (Ax(i) && e > zl && e < QF && (i - Ko) % La == 0)+ return i + (e - zl);+ {+ let t = bl.get(i);+ return t && (t = t.get(e), t) ? t : -1;+ }+}+function gx(i) {+ Xd || GF();+ let e = [], t = [], n = !1;+ function s(r) {+ let a = Xd.get(r);+ a && (n = !0, r |= a), e.push(r);+ }+ for (let r of i)+ for (; ; ) {+ if (r < 128)+ e.push(r);+ else if (Ax(r)) {+ let a = r - Ko, o = a / Vl | 0, c = a % Vl / La | 0, l = a % La;+ s(Gl + o), s(Hl + c), l > 0 && s(zl + l);+ } else {+ let a = Yd.get(r);+ a ? t.push(...a) : s(r);+ }+ if (!t.length) break;+ r = t.pop();+ }+ if (n && e.length > 1) {+ let r = mo(e[0]);+ for (let a = 1; a < e.length; a++) {+ let o = mo(e[a]);+ if (o == 0 || r <= o) {+ r = o;+ continue;+ }+ let c = a - 1;+ for (; ; ) {+ let l = e[c + 1];+ if (e[c + 1] = e[c], e[c] = l, !c || (r = mo(e[--c]), r <= o)) break;+ }+ r = mo(e[a]);+ }+ }+ return e;+}+function zF(i) {+ let e = [], t = [], n = -1, s = 0;+ for (let r of i) {+ let a = mo(r), o = px(r);+ if (n == -1)+ a == 0 ? n = o : e.push(o);+ else if (s > 0 && s >= a)+ a == 0 ? (e.push(n, ...t), t.length = 0, n = o) : t.push(o), s = a;+ else {+ let c = HF(n, o);+ c >= 0 ? n = c : s == 0 && a == 0 ? (e.push(n), n = o) : (t.push(o), s = a);+ }+ }+ return n >= 0 && e.push(n, ...t), e;+}+function mx(i) {+ return gx(i).map(px);+}+function VF(i) {+ return zF(gx(i));+}+const nm = 45, bx = ".", xx = 65039, _x = 1, Wl = (i) => Array.from(i);+function jo(i, e) {+ return i.P.has(e) || i.Q.has(e);+}+class WF extends Array {+ get is_emoji() {+ return !0;+ }+ // free tagging system+}+let Jd, Ex, gr, Zd, yx, _a, vu, ia, rr, im, $d;+function np() {+ if (Jd) return;+ let i = ox(wF);+ const e = () => Wo(i), t = () => new Set(e()), n = (h, u) => u.forEach((d) => h.add(d));+ Jd = new Map(lx(i)), Ex = t(), gr = e(), Zd = new Set(e().map((h) => gr[h])), gr = new Set(gr), yx = t(), t();+ let s = cx(i), r = i();+ const a = () => {+ let h = /* @__PURE__ */ new Set();+ return e().forEach((u) => n(h, s[u])), n(h, e()), h;+ };+ _a = qo((h) => {+ let u = qo(i).map((d) => d + 96);+ if (u.length) {+ let d = h >= r;+ u[0] -= 32, u = Da(u), d && (u = `Restricted[${u}]`);+ let f = a(), m = a(), A = !i();+ return { N: u, P: f, Q: m, M: A, R: d };+ }+ }), vu = t(), ia = /* @__PURE__ */ new Map();+ let o = e().concat(Wl(vu)).sort((h, u) => h - u);+ o.forEach((h, u) => {+ let d = i(), f = o[u] = d ? o[u - d] : { V: [], M: /* @__PURE__ */ new Map() };+ f.V.push(h), vu.has(h) || ia.set(h, f);+ });+ for (let { V: h, M: u } of new Set(ia.values())) {+ let d = [];+ for (let m of h) {+ let A = _a.filter((p) => jo(p, m)), g = d.find(({ G: p }) => A.some((y) => p.has(y)));+ g || (g = { G: /* @__PURE__ */ new Set(), V: [] }, d.push(g)), g.V.push(m), n(g.G, A);+ }+ let f = d.flatMap((m) => Wl(m.G));+ for (let { G: m, V: A } of d) {+ let g = new Set(f.filter((p) => !m.has(p)));+ for (let p of A)+ u.set(p, g);+ }+ }+ rr = /* @__PURE__ */ new Set();+ let c = /* @__PURE__ */ new Set();+ const l = (h) => rr.has(h) ? c.add(h) : rr.add(h);+ for (let h of _a) {+ for (let u of h.P) l(u);+ for (let u of h.Q) l(u);+ }+ for (let h of rr)+ !ia.has(h) && !c.has(h) && ia.set(h, _x);+ n(rr, mx(rr)), im = RF(i).map((h) => WF.from(h)).sort(DF), $d = /* @__PURE__ */ new Map();+ for (let h of im) {+ let u = [$d];+ for (let d of h) {+ let f = u.map((m) => {+ let A = m.get(d);+ return A || (A = /* @__PURE__ */ new Map(), m.set(d, A)), A;+ });+ d === xx ? u.push(...f) : u = f;+ }+ for (let d of u)+ d.V = h;+ }+}+function ip(i) {+ return (wx(i) ? "" : `${sp(uh([i]))} `) + ux(i);+}+function sp(i) {+ return `"${i}"`;+}+function qF(i) {+ if (i.length >= 4 && i[2] == nm && i[3] == nm)+ throw new Error(`invalid label extension: "${Da(i.slice(0, 4))}"`);+}+function KF(i) {+ for (let t = i.lastIndexOf(95); t > 0; )+ if (i[--t] !== 95)+ throw new Error("underscore allowed only at start");+}+function jF(i) {+ let e = i[0], t = $g.get(e);+ if (t) throw Mo(`leading ${t}`);+ let n = i.length, s = -1;+ for (let r = 1; r < n; r++) {+ e = i[r];+ let a = $g.get(e);+ if (a) {+ if (s == r) throw Mo(`${t} + ${a}`);+ s = r + 1, t = a;+ }+ }+ if (s == n) throw Mo(`trailing ${t}`);+}+function uh(i, e = 1 / 0, t = ux) {+ let n = [];+ XF(i[0]) && n.push("◌"), i.length > e && (e >>= 1, i = [...i.slice(0, e), 8230, ...i.slice(-e)]);+ let s = 0, r = i.length;+ for (let a = 0; a < r; a++) {+ let o = i[a];+ wx(o) && (n.push(Da(i.slice(s, a))), n.push(t(o)), s = a + 1);+ }+ return n.push(Da(i.slice(s, r))), n.join("");+}+function XF(i) {+ return np(), gr.has(i);+}+function wx(i) {+ return np(), yx.has(i);+}+function YF(i) {+ return eD(JF(i, VF, iD));+}+function JF(i, e, t) {+ if (!i) return [];+ np();+ let n = 0;+ return i.split(bx).map((s) => {+ let r = FF(s), a = {+ input: r,+ offset: n+ // codepoint, not substring!+ };+ n += r.length + 1;+ try {+ let o = a.tokens = nD(r, e, t), c = o.length, l;+ if (!c)+ throw new Error("empty label");+ let h = a.output = o.flat();+ if (KF(h), !(a.emoji = c > 1 || o[0].is_emoji) && h.every((d) => d < 128))+ qF(h), l = "ASCII";+ else {+ let d = o.flatMap((f) => f.is_emoji ? [] : f);+ if (!d.length)+ l = "Emoji";+ else {+ if (gr.has(h[0])) throw Mo("leading combining mark");+ for (let A = 1; A < c; A++) {+ let g = o[A];+ if (!g.is_emoji && gr.has(g[0]))+ throw Mo(`emoji + combining mark: "${Da(o[A - 1])} + ${uh([g[0]])}"`);+ }+ jF(h);+ let f = Wl(new Set(d)), [m] = $F(f);+ tD(m, d), ZF(m, f), l = m.N;+ }+ }+ a.type = l;+ } catch (o) {+ a.error = o;+ }+ return a;+ });+}+function ZF(i, e) {+ let t, n = [];+ for (let s of e) {+ let r = ia.get(s);+ if (r === _x) return;+ if (r) {+ let a = r.M.get(s);+ if (t = t ? t.filter((o) => a.has(o)) : Wl(a), !t.length) return;+ } else+ n.push(s);+ }+ if (t) {+ for (let s of t)+ if (n.every((r) => jo(s, r)))+ throw new Error(`whole-script confusable: ${i.N}/${s.N}`);+ }+}+function $F(i) {+ let e = _a;+ for (let t of i) {+ let n = e.filter((s) => jo(s, t));+ if (!n.length)+ throw _a.some((s) => jo(s, t)) ? Cx(e[0], t) : vx(t);+ if (e = n, n.length == 1) break;+ }+ return e;+}+function eD(i) {+ return i.map(({ input: e, error: t, output: n }) => {+ if (t) {+ let s = t.message;+ throw new Error(i.length == 1 ? s : `Invalid label ${sp(uh(e, 63))}: ${s}`);+ }+ return Da(n);+ }).join(bx);+}+function vx(i) {+ return new Error(`disallowed character: ${ip(i)}`);+}+function Cx(i, e) {+ let t = ip(e), n = _a.find((s) => s.P.has(e));+ return n && (t = `${n.N} ${t}`), new Error(`illegal mixture: ${i.N} + ${t}`);+}+function Mo(i) {+ return new Error(`illegal placement: ${i}`);+}+function tD(i, e) {+ for (let t of e)+ if (!jo(i, t))+ throw Cx(i, t);+ if (i.M) {+ let t = mx(e);+ for (let n = 1, s = t.length; n < s; n++)+ if (Zd.has(t[n])) {+ let r = n + 1;+ for (let a; r < s && Zd.has(a = t[r]); r++)+ for (let o = n; o < r; o++)+ if (t[o] == a)+ throw new Error(`duplicate non-spacing marks: ${ip(a)}`);+ if (r - n > em)+ throw new Error(`excessive non-spacing marks: ${sp(uh(t.slice(n - 1, r)))} (${r - n}/${em})`);+ n = r;+ }+ }+}+function nD(i, e, t) {+ let n = [], s = [];+ for (i = i.slice().reverse(); i.length; ) {+ let r = sD(i);+ if (r)+ s.length && (n.push(e(s)), s = []), n.push(t(r));+ else {+ let a = i.pop();+ if (rr.has(a))+ s.push(a);+ else {+ let o = Jd.get(a);+ if (o)+ s.push(...o);+ else if (!Ex.has(a))+ throw vx(a);+ }+ }+ }+ return s.length && n.push(e(s)), n;+}+function iD(i) {+ return i.filter((e) => e != xx);+}+function sD(i, e) {+ let t = $d, n, s = i.length;+ for (; s && (t = t.get(i[--s]), !!t); ) {+ let { V: r } = t;+ r && (n = r, i.length = s);+ }+ return n;+}+const Sx = new Uint8Array(32);+Sx.fill(0);+function sm(i) {+ return V(i.length !== 0, "invalid ENS name; empty component", "comp", i), i;+}+function Ix(i) {+ const e = cs(rD(i)), t = [];+ if (i.length === 0)+ return t;+ let n = 0;+ for (let s = 0; s < e.length; s++)+ e[s] === 46 && (t.push(sm(e.slice(n, s))), n = s + 1);+ return V(n < e.length, "invalid ENS name; empty component", "name", i), t.push(sm(e.slice(n))), t;+}+function rD(i) {+ try {+ if (i.length === 0)+ throw new Error("empty label");+ return YF(i);+ } catch (e) {+ V(!1, `invalid ENS name (${e.message})`, "name", i);+ }+}+function ef(i) {+ V(typeof i == "string", "invalid ENS name; not a string", "name", i), V(i.length, "invalid ENS name (empty label)", "name", i);+ let e = Sx;+ const t = Ix(i);+ for (; t.length; )+ e = Zt(Qt([e, Zt(t.pop())]));+ return Se(e);+}+function aD(i, e) {+ const t = e;+ return V(t <= 255, "DNS encoded label cannot exceed 255", "length", t), Se(Qt(Ix(i).map((n) => {+ V(n.length <= t, `label ${JSON.stringify(i)} exceeds ${t} bytes`, "name", i);+ const s = new Uint8Array(n.length + 1);+ return s.set(n, 1), s[0] = s.length - 1, s;+ }))) + "00";+}+const Mx = new Uint8Array(32);+Mx.fill(0);+const oD = BigInt(-1), Bx = BigInt(0), Tx = BigInt(1), cD = BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");+function lD(i) {+ const e = ht(i), t = e.length % 32;+ return t ? Qt([e, Mx.slice(t)]) : Se(e);+}+const hD = Hs(Tx, 32), uD = Hs(Bx, 32), rm = {+ name: "string",+ version: "string",+ chainId: "uint256",+ verifyingContract: "address",+ salt: "bytes32"+}, Cu = [+ "name",+ "version",+ "chainId",+ "verifyingContract",+ "salt"+];+function am(i) {+ return function(e) {+ return V(typeof e == "string", `invalid domain value for ${JSON.stringify(i)}`, `domain.${i}`, e), e;+ };+}+const dD = {+ name: am("name"),+ version: am("version"),+ chainId: function(i) {+ const e = Fe(i, "domain.chainId");+ return V(e >= 0, "invalid chain ID", "domain.chainId", i), Number.isSafeInteger(e) ? Number(e) : Ai(e);+ },+ verifyingContract: function(i) {+ try {+ return St(i).toLowerCase();+ } catch {+ }+ V(!1, 'invalid domain value "verifyingContract"', "domain.verifyingContract", i);+ },+ salt: function(i) {+ const e = ht(i, "domain.salt");+ return V(e.length === 32, 'invalid domain value "salt"', "domain.salt", i), Se(e);+ }+};+function Su(i) {+ {+ const e = i.match(/^(u?)int(\d+)$/);+ if (e) {+ const t = e[1] === "", n = parseInt(e[2]);+ V(n % 8 === 0 && n !== 0 && n <= 256 && e[2] === String(n), "invalid numeric width", "type", i);+ const s = go(cD, t ? n - 1 : n), r = t ? (s + Tx) * oD : Bx;+ return function(a) {+ const o = Fe(a, "value");+ return V(o >= r && o <= s, `value out-of-bounds for ${i}`, "value", o), Hs(t ? bb(o, 256) : o, 32);+ };+ }+ }+ {+ const e = i.match(/^bytes(\d+)$/);+ if (e) {+ const t = parseInt(e[1]);+ return V(t !== 0 && t <= 32 && e[1] === String(t), "invalid bytes width", "type", i), function(n) {+ const s = ht(n);+ return V(s.length === t, `invalid length for ${i}`, "value", n), lD(n);+ };+ }+ }+ switch (i) {+ case "address":+ return function(e) {+ return ds(St(e), 32);+ };+ case "bool":+ return function(e) {+ return e ? hD : uD;+ };+ case "bytes":+ return function(e) {+ return Zt(e);+ };+ case "string":+ return function(e) {+ return Sr(e);+ };+ }+ return null;+}+function om(i, e) {+ return `${i}(${e.map(({ name: t, type: n }) => n + " " + t).join(",")})`;+}+function al(i) {+ const e = i.match(/^([^\x5b]*)((\x5b\d*\x5d)*)(\x5b(\d*)\x5d)$/);+ return e ? {+ base: e[1],+ index: e[2] + e[4],+ array: {+ base: e[1],+ prefix: e[1] + e[2],+ count: e[5] ? parseInt(e[5]) : -1+ }+ } : { base: i };+}+class Kn {+ /**+ * The primary type for the structured [[types]].+ *+ * This is derived automatically from the [[types]], since no+ * recursion is possible, once the DAG for the types is consturcted+ * internally, the primary type must be the only remaining type with+ * no parent nodes.+ */+ primaryType;+ #e;+ /**+ * The types.+ */+ get types() {+ return JSON.parse(this.#e);+ }+ #t;+ #n;+ /**+ * Create a new **TypedDataEncoder** for %%types%%.+ *+ * This performs all necessary checking that types are valid and+ * do not violate the [[link-eip-712]] structural constraints as+ * well as computes the [[primaryType]].+ */+ constructor(e) {+ this.#t = /* @__PURE__ */ new Map(), this.#n = /* @__PURE__ */ new Map();+ const t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), r = {};+ Object.keys(e).forEach((c) => {+ r[c] = e[c].map(({ name: l, type: h }) => {+ let { base: u, index: d } = al(h);+ return u === "int" && !e.int && (u = "int256"), u === "uint" && !e.uint && (u = "uint256"), { name: l, type: u + (d || "") };+ }), t.set(c, /* @__PURE__ */ new Set()), n.set(c, []), s.set(c, /* @__PURE__ */ new Set());+ }), this.#e = JSON.stringify(r);+ for (const c in r) {+ const l = /* @__PURE__ */ new Set();+ for (const h of r[c]) {+ V(!l.has(h.name), `duplicate variable name ${JSON.stringify(h.name)} in ${JSON.stringify(c)}`, "types", e), l.add(h.name);+ const u = al(h.type).base;+ V(u !== c, `circular type reference to ${JSON.stringify(u)}`, "types", e), !Su(u) && (V(n.has(u), `unknown type ${JSON.stringify(u)}`, "types", e), n.get(u).push(c), t.get(c).add(u));+ }+ }+ const a = Array.from(n.keys()).filter((c) => n.get(c).length === 0);+ V(a.length !== 0, "missing primary type", "types", e), V(a.length === 1, `ambiguous primary types or unused types: ${a.map((c) => JSON.stringify(c)).join(", ")}`, "types", e), Xe(this, { primaryType: a[0] });+ function o(c, l) {+ V(!l.has(c), `circular type reference to ${JSON.stringify(c)}`, "types", e), l.add(c);+ for (const h of t.get(c))+ if (n.has(h)) {+ o(h, l);+ for (const u of l)+ s.get(u).add(h);+ }+ l.delete(c);+ }+ o(this.primaryType, /* @__PURE__ */ new Set());+ for (const [c, l] of s) {+ const h = Array.from(l);+ h.sort(), this.#t.set(c, om(c, r[c]) + h.map((u) => om(u, r[u])).join(""));+ }+ }+ /**+ * Returnthe encoder for the specific %%type%%.+ */+ getEncoder(e) {+ let t = this.#n.get(e);+ return t || (t = this.#i(e), this.#n.set(e, t)), t;+ }+ #i(e) {+ {+ const s = Su(e);+ if (s)+ return s;+ }+ const t = al(e).array;+ if (t) {+ const s = t.prefix, r = this.getEncoder(s);+ return (a) => {+ V(t.count === -1 || t.count === a.length, `array length mismatch; expected length ${t.count}`, "value", a);+ let o = a.map(r);+ return this.#t.has(s) && (o = o.map(Zt)), Zt(Qt(o));+ };+ }+ const n = this.types[e];+ if (n) {+ const s = Sr(this.#t.get(e));+ return (r) => {+ const a = n.map(({ name: o, type: c }) => {+ const l = this.getEncoder(c)(r[o]);+ return this.#t.has(c) ? Zt(l) : l;+ });+ return a.unshift(s), Qt(a);+ };+ }+ V(!1, `unknown type: ${e}`, "type", e);+ }+ /**+ * Return the full type for %%name%%.+ */+ encodeType(e) {+ const t = this.#t.get(e);+ return V(t, `unknown type: ${JSON.stringify(e)}`, "name", e), t;+ }+ /**+ * Return the encoded %%value%% for the %%type%%.+ */+ encodeData(e, t) {+ return this.getEncoder(e)(t);+ }+ /**+ * Returns the hash of %%value%% for the type of %%name%%.+ */+ hashStruct(e, t) {+ return Zt(this.encodeData(e, t));+ }+ /**+ * Return the fulled encoded %%value%% for the [[types]].+ */+ encode(e) {+ return this.encodeData(this.primaryType, e);+ }+ /**+ * Return the hash of the fully encoded %%value%% for the [[types]].+ */+ hash(e) {+ return this.hashStruct(this.primaryType, e);+ }+ /**+ * @_ignore:+ */+ _visit(e, t, n) {+ if (Su(e))+ return n(e, t);+ const s = al(e).array;+ if (s)+ return V(s.count === -1 || s.count === t.length, `array length mismatch; expected length ${s.count}`, "value", t), t.map((a) => this._visit(s.prefix, a, n));+ const r = this.types[e];+ if (r)+ return r.reduce((a, { name: o, type: c }) => (a[o] = this._visit(c, t[o], n), a), {});+ V(!1, `unknown type: ${e}`, "type", e);+ }+ /**+ * Call %%calback%% for each value in %%value%%, passing the type and+ * component within %%value%%.+ *+ * This is useful for replacing addresses or other transformation that+ * may be desired on each component, based on its type.+ */+ visit(e, t) {+ return this._visit(this.primaryType, e, t);+ }+ /**+ * Create a new **TypedDataEncoder** for %%types%%.+ */+ static from(e) {+ return new Kn(e);+ }+ /**+ * Return the primary type for %%types%%.+ */+ static getPrimaryType(e) {+ return Kn.from(e).primaryType;+ }+ /**+ * Return the hashed struct for %%value%% using %%types%% and %%name%%.+ */+ static hashStruct(e, t, n) {+ return Kn.from(t).hashStruct(e, n);+ }+ /**+ * Return the domain hash for %%domain%%.+ */+ static hashDomain(e) {+ const t = [];+ for (const n in e) {+ if (e[n] == null)+ continue;+ const s = rm[n];+ V(s, `invalid typed-data domain key: ${JSON.stringify(n)}`, "domain", e), t.push({ name: n, type: s });+ }+ return t.sort((n, s) => Cu.indexOf(n.name) - Cu.indexOf(s.name)), Kn.hashStruct("EIP712Domain", { EIP712Domain: t }, e);+ }+ /**+ * Return the fully encoded [[link-eip-712]] %%value%% for %%types%% with %%domain%%.+ */+ static encode(e, t, n) {+ return Qt([+ "0x1901",+ Kn.hashDomain(e),+ Kn.from(t).hash(n)+ ]);+ }+ /**+ * Return the hash of the fully encoded [[link-eip-712]] %%value%% for %%types%% with %%domain%%.+ */+ static hash(e, t, n) {+ return Zt(Kn.encode(e, t, n));+ }+ // Replaces all address types with ENS names with their looked up address+ /**+ * Resolves to the value from resolving all addresses in %%value%% for+ * %%types%% and the %%domain%%.+ */+ static async resolveNames(e, t, n, s) {+ e = Object.assign({}, e);+ for (const o in e)+ e[o] == null && delete e[o];+ const r = {};+ e.verifyingContract && !Lt(e.verifyingContract, 20) && (r[e.verifyingContract] = "0x");+ const a = Kn.from(t);+ a.visit(n, (o, c) => (o === "address" && !Lt(c, 20) && (r[c] = "0x"), c));+ for (const o in r)+ r[o] = await s(o);+ return e.verifyingContract && r[e.verifyingContract] && (e.verifyingContract = r[e.verifyingContract]), n = a.visit(n, (o, c) => o === "address" && r[c] ? r[c] : c), { domain: e, value: n };+ }+ /**+ * Returns the JSON-encoded payload expected by nodes which implement+ * the JSON-RPC [[link-eip-712]] method.+ */+ static getPayload(e, t, n) {+ Kn.hashDomain(e);+ const s = {}, r = [];+ Cu.forEach((c) => {+ const l = e[c];+ l != null && (s[c] = dD[c](l), r.push({ name: c, type: rm[c] }));+ });+ const a = Kn.from(t);+ t = a.types;+ const o = Object.assign({}, t);+ return V(o.EIP712Domain == null, "types must not contain EIP712Domain type", "types.EIP712Domain", t), o.EIP712Domain = r, a.encode(n), {+ types: o,+ domain: s,+ primaryType: a.primaryType,+ message: a.visit(n, (c, l) => {+ if (c.match(/^bytes(\d*)/))+ return Se(ht(l));+ if (c.match(/^u?int/))+ return Fe(l).toString();+ switch (c) {+ case "address":+ return l.toLowerCase();+ case "bool":+ return !!l;+ case "string":+ return V(typeof l == "string", "invalid string", "value", l), l;+ }+ V(!1, "unsupported type", "type", c);+ })+ };+ }+}+function Ln(i) {+ const e = /* @__PURE__ */ new Set();+ return i.forEach((t) => e.add(t)), Object.freeze(e);+}+const fD = "external public payable override", pD = Ln(fD.split(" ")), Rx = "constant external internal payable private public pure view override", AD = Ln(Rx.split(" ")), Nx = "constructor error event fallback function receive struct", Fx = Ln(Nx.split(" ")), Dx = "calldata memory storage payable indexed", gD = Ln(Dx.split(" ")), mD = "tuple returns", bD = [Nx, Dx, mD, Rx].join(" "), xD = Ln(bD.split(" ")), _D = {+ "(": "OPEN_PAREN",+ ")": "CLOSE_PAREN",+ "[": "OPEN_BRACKET",+ "]": "CLOSE_BRACKET",+ ",": "COMMA",+ "@": "AT"+}, ED = new RegExp("^(\\s*)"), yD = new RegExp("^([0-9]+)"), wD = new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)"), Lx = new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)$"), Px = new RegExp("^(address|bool|bytes([0-9]*)|string|u?int([0-9]*))$");+class ai {+ #e;+ #t;+ get offset() {+ return this.#e;+ }+ get length() {+ return this.#t.length - this.#e;+ }+ constructor(e) {+ this.#e = 0, this.#t = e.slice();+ }+ clone() {+ return new ai(this.#t);+ }+ reset() {+ this.#e = 0;+ }+ #n(e = 0, t = 0) {+ return new ai(this.#t.slice(e, t).map((n) => Object.freeze(Object.assign({}, n, {+ match: n.match - e,+ linkBack: n.linkBack - e,+ linkNext: n.linkNext - e+ }))));+ }+ // Pops and returns the value of the next token, if it is a keyword in allowed; throws if out of tokens+ popKeyword(e) {+ const t = this.peek();+ if (t.type !== "KEYWORD" || !e.has(t.text))+ throw new Error(`expected keyword ${t.text}`);+ return this.pop().text;+ }+ // Pops and returns the value of the next token if it is `type`; throws if out of tokens+ popType(e) {+ if (this.peek().type !== e) {+ const t = this.peek();+ throw new Error(`expected ${e}; got ${t.type} ${JSON.stringify(t.text)}`);+ }+ return this.pop().text;+ }+ // Pops and returns a "(" TOKENS ")"+ popParen() {+ const e = this.peek();+ if (e.type !== "OPEN_PAREN")+ throw new Error("bad start");+ const t = this.#n(this.#e + 1, e.match + 1);+ return this.#e = e.match + 1, t;+ }+ // Pops and returns the items within "(" ITEM1 "," ITEM2 "," ... ")"+ popParams() {+ const e = this.peek();+ if (e.type !== "OPEN_PAREN")+ throw new Error("bad start");+ const t = [];+ for (; this.#e < e.match - 1; ) {+ const n = this.peek().linkNext;+ t.push(this.#n(this.#e + 1, n)), this.#e = n;+ }+ return this.#e = e.match + 1, t;+ }+ // Returns the top Token, throwing if out of tokens+ peek() {+ if (this.#e >= this.#t.length)+ throw new Error("out-of-bounds");+ return this.#t[this.#e];+ }+ // Returns the next value, if it is a keyword in `allowed`+ peekKeyword(e) {+ const t = this.peekType("KEYWORD");+ return t != null && e.has(t) ? t : null;+ }+ // Returns the value of the next token if it is `type`+ peekType(e) {+ if (this.length === 0)+ return null;+ const t = this.peek();+ return t.type === e ? t.text : null;+ }+ // Returns the next token; throws if out of tokens+ pop() {+ const e = this.peek();+ return this.#e++, e;+ }+ toString() {+ const e = [];+ for (let t = this.#e; t < this.#t.length; t++) {+ const n = this.#t[t];+ e.push(`${n.type}:${n.text}`);+ }+ return `<TokenString ${e.join(" ")}>`;+ }+}+function qs(i) {+ const e = [], t = (a) => {+ const o = r < i.length ? JSON.stringify(i[r]) : "$EOI";+ throw new Error(`invalid token ${o} at ${r}: ${a}`);+ };+ let n = [], s = [], r = 0;+ for (; r < i.length; ) {+ let a = i.substring(r), o = a.match(ED);+ o && (r += o[1].length, a = i.substring(r));+ const c = { depth: n.length, linkBack: -1, linkNext: -1, match: -1, type: "", text: "", offset: r, value: -1 };+ e.push(c);+ let l = _D[a[0]] || "";+ if (l) {+ if (c.type = l, c.text = a[0], r++, l === "OPEN_PAREN")+ n.push(e.length - 1), s.push(e.length - 1);+ else if (l == "CLOSE_PAREN")+ n.length === 0 && t("no matching open bracket"), c.match = n.pop(), e[c.match].match = e.length - 1, c.depth--, c.linkBack = s.pop(), e[c.linkBack].linkNext = e.length - 1;+ else if (l === "COMMA")+ c.linkBack = s.pop(), e[c.linkBack].linkNext = e.length - 1, s.push(e.length - 1);+ else if (l === "OPEN_BRACKET")+ c.type = "BRACKET";+ else if (l === "CLOSE_BRACKET") {+ let h = e.pop().text;+ if (e.length > 0 && e[e.length - 1].type === "NUMBER") {+ const u = e.pop().text;+ h = u + h, e[e.length - 1].value = ut(u);+ }+ if (e.length === 0 || e[e.length - 1].type !== "BRACKET")+ throw new Error("missing opening bracket");+ e[e.length - 1].text += h;+ }+ continue;+ }+ if (o = a.match(wD), o) {+ if (c.text = o[1], r += c.text.length, xD.has(c.text)) {+ c.type = "KEYWORD";+ continue;+ }+ if (c.text.match(Px)) {+ c.type = "TYPE";+ continue;+ }+ c.type = "ID";+ continue;+ }+ if (o = a.match(yD), o) {+ c.text = o[1], c.type = "NUMBER", r += c.text.length;+ continue;+ }+ throw new Error(`unexpected token ${JSON.stringify(a[0])} at position ${r}`);+ }+ return new ai(e.map((a) => Object.freeze(a)));+}+function cm(i, e) {+ let t = [];+ for (const n in e.keys())+ i.has(n) && t.push(n);+ if (t.length > 1)+ throw new Error(`conflicting types: ${t.join(", ")}`);+}+function dh(i, e) {+ if (e.peekKeyword(Fx)) {+ const t = e.pop().text;+ if (t !== i)+ throw new Error(`expected ${i}, got ${t}`);+ }+ return e.popType("ID");+}+function fs(i, e) {+ const t = /* @__PURE__ */ new Set();+ for (; ; ) {+ const n = i.peekType("KEYWORD");+ if (n == null || e && !e.has(n))+ break;+ if (i.pop(), t.has(n))+ throw new Error(`duplicate keywords: ${JSON.stringify(n)}`);+ t.add(n);+ }+ return Object.freeze(t);+}+function kx(i) {+ let e = fs(i, AD);+ return cm(e, Ln("constant payable nonpayable".split(" "))), cm(e, Ln("pure view payable nonpayable".split(" "))), e.has("view") ? "view" : e.has("pure") ? "pure" : e.has("payable") ? "payable" : e.has("nonpayable") ? "nonpayable" : e.has("constant") ? "view" : "nonpayable";+}+function hs(i, e) {+ return i.popParams().map((t) => Ft.from(t, e));+}+function Ux(i) {+ if (i.peekType("AT")) {+ if (i.pop(), i.peekType("NUMBER"))+ return Fe(i.pop().text);+ throw new Error("invalid gas");+ }+ return null;+}+function Ir(i) {+ if (i.length)+ throw new Error(`unexpected tokens at offset ${i.offset}: ${i.toString()}`);+}+const vD = new RegExp(/^(.*)\[([0-9]*)\]$/);+function lm(i) {+ const e = i.match(Px);+ if (V(e, "invalid type", "type", i), i === "uint")+ return "uint256";+ if (i === "int")+ return "int256";+ if (e[2]) {+ const t = parseInt(e[2]);+ V(t !== 0 && t <= 32, "invalid bytes length", "type", i);+ } else if (e[3]) {+ const t = parseInt(e[3]);+ V(t !== 0 && t <= 256 && t % 8 === 0, "invalid numeric width", "type", i);+ }+ return i;+}+const Ht = {}, Hn = /* @__PURE__ */ Symbol.for("_ethers_internal"), hm = "_ParamTypeInternal", um = "_ErrorInternal", dm = "_EventInternal", fm = "_ConstructorInternal", pm = "_FallbackInternal", Am = "_FunctionInternal", gm = "_StructInternal";+class Ft {+ /**+ * The local name of the parameter (or ``""`` if unbound)+ */+ name;+ /**+ * The fully qualified type (e.g. ``"address"``, ``"tuple(address)"``,+ * ``"uint256[3][]"``)+ */+ type;+ /**+ * The base type (e.g. ``"address"``, ``"tuple"``, ``"array"``)+ */+ baseType;+ /**+ * True if the parameters is indexed.+ *+ * For non-indexable types this is ``null``.+ */+ indexed;+ /**+ * The components for the tuple.+ *+ * For non-tuple types this is ``null``.+ */+ components;+ /**+ * The array length, or ``-1`` for dynamic-lengthed arrays.+ *+ * For non-array types this is ``null``.+ */+ arrayLength;+ /**+ * The type of each child in the array.+ *+ * For non-array types this is ``null``.+ */+ arrayChildren;+ /**+ * @private+ */+ constructor(e, t, n, s, r, a, o, c) {+ if (sh(e, Ht, "ParamType"), Object.defineProperty(this, Hn, { value: hm }), a && (a = Object.freeze(a.slice())), s === "array") {+ if (o == null || c == null)+ throw new Error("");+ } else if (o != null || c != null)+ throw new Error("");+ if (s === "tuple") {+ if (a == null)+ throw new Error("");+ } else if (a != null)+ throw new Error("");+ Xe(this, {+ name: t,+ type: n,+ baseType: s,+ indexed: r,+ components: a,+ arrayLength: o,+ arrayChildren: c+ });+ }+ /**+ * Return a string representation of this type.+ *+ * For example,+ *+ * ``sighash" => "(uint256,address)"``+ *+ * ``"minimal" => "tuple(uint256,address) indexed"``+ *+ * ``"full" => "tuple(uint256 foo, address bar) indexed baz"``+ */+ format(e) {+ if (e == null && (e = "sighash"), e === "json") {+ const n = this.name || "";+ if (this.isArray()) {+ const r = JSON.parse(this.arrayChildren.format("json"));+ return r.name = n, r.type += `[${this.arrayLength < 0 ? "" : String(this.arrayLength)}]`, JSON.stringify(r);+ }+ const s = {+ type: this.baseType === "tuple" ? "tuple" : this.type,+ name: n+ };+ return typeof this.indexed == "boolean" && (s.indexed = this.indexed), this.isTuple() && (s.components = this.components.map((r) => JSON.parse(r.format(e)))), JSON.stringify(s);+ }+ let t = "";+ return this.isArray() ? (t += this.arrayChildren.format(e), t += `[${this.arrayLength < 0 ? "" : String(this.arrayLength)}]`) : this.isTuple() ? t += "(" + this.components.map((n) => n.format(e)).join(e === "full" ? ", " : ",") + ")" : t += this.type, e !== "sighash" && (this.indexed === !0 && (t += " indexed"), e === "full" && this.name && (t += " " + this.name)), t;+ }+ /**+ * Returns true if %%this%% is an Array type.+ *+ * This provides a type gaurd ensuring that [[arrayChildren]]+ * and [[arrayLength]] are non-null.+ */+ isArray() {+ return this.baseType === "array";+ }+ /**+ * Returns true if %%this%% is a Tuple type.+ *+ * This provides a type gaurd ensuring that [[components]]+ * is non-null.+ */+ isTuple() {+ return this.baseType === "tuple";+ }+ /**+ * Returns true if %%this%% is an Indexable type.+ *+ * This provides a type gaurd ensuring that [[indexed]]+ * is non-null.+ */+ isIndexable() {+ return this.indexed != null;+ }+ /**+ * Walks the **ParamType** with %%value%%, calling %%process%%+ * on each type, destructing the %%value%% recursively.+ */+ walk(e, t) {+ if (this.isArray()) {+ if (!Array.isArray(e))+ throw new Error("invalid array value");+ if (this.arrayLength !== -1 && e.length !== this.arrayLength)+ throw new Error("array is wrong length");+ const n = this;+ return e.map((s) => n.arrayChildren.walk(s, t));+ }+ if (this.isTuple()) {+ if (!Array.isArray(e))+ throw new Error("invalid tuple value");+ if (e.length !== this.components.length)+ throw new Error("array is wrong length");+ const n = this;+ return e.map((s, r) => n.components[r].walk(s, t));+ }+ return t(this.type, e);+ }+ #e(e, t, n, s) {+ if (this.isArray()) {+ if (!Array.isArray(t))+ throw new Error("invalid array value");+ if (this.arrayLength !== -1 && t.length !== this.arrayLength)+ throw new Error("array is wrong length");+ const a = this.arrayChildren, o = t.slice();+ o.forEach((c, l) => {+ a.#e(e, c, n, (h) => {+ o[l] = h;+ });+ }), s(o);+ return;+ }+ if (this.isTuple()) {+ const a = this.components;+ let o;+ if (Array.isArray(t))+ o = t.slice();+ else {+ if (t == null || typeof t != "object")+ throw new Error("invalid tuple value");+ o = a.map((c) => {+ if (!c.name)+ throw new Error("cannot use object value with unnamed components");+ if (!(c.name in t))+ throw new Error(`missing value for component ${c.name}`);+ return t[c.name];+ });+ }+ if (o.length !== this.components.length)+ throw new Error("array is wrong length");+ o.forEach((c, l) => {+ a[l].#e(e, c, n, (h) => {+ o[l] = h;+ });+ }), s(o);+ return;+ }+ const r = n(this.type, t);+ r.then ? e.push((async function() {+ s(await r);+ })()) : s(r);+ }+ /**+ * Walks the **ParamType** with %%value%%, asynchronously calling+ * %%process%% on each type, destructing the %%value%% recursively.+ *+ * This can be used to resolve ENS names by walking and resolving each+ * ``"address"`` type.+ */+ async walkAsync(e, t) {+ const n = [], s = [e];+ return this.#e(n, e, t, (r) => {+ s[0] = r;+ }), n.length && await Promise.all(n), s[0];+ }+ /**+ * Creates a new **ParamType** for %%obj%%.+ *+ * If %%allowIndexed%% then the ``indexed`` keyword is permitted,+ * otherwise the ``indexed`` keyword will throw an error.+ */+ static from(e, t) {+ if (Ft.isParamType(e))+ return e;+ if (typeof e == "string")+ try {+ return Ft.from(qs(e), t);+ } catch {+ V(!1, "invalid param type", "obj", e);+ }+ else if (e instanceof ai) {+ let o = "", c = "", l = null;+ fs(e, Ln(["tuple"])).has("tuple") || e.peekType("OPEN_PAREN") ? (c = "tuple", l = e.popParams().map((A) => Ft.from(A)), o = `tuple(${l.map((A) => A.format()).join(",")})`) : (o = lm(e.popType("TYPE")), c = o);+ let h = null, u = null;+ for (; e.length && e.peekType("BRACKET"); ) {+ const A = e.pop();+ h = new Ft(Ht, "", o, c, null, l, u, h), u = A.value, o += A.text, c = "array", l = null;+ }+ let d = null;+ if (fs(e, gD).has("indexed")) {+ if (!t)+ throw new Error("");+ d = !0;+ }+ const m = e.peekType("ID") ? e.pop().text : "";+ if (e.length)+ throw new Error("leftover tokens");+ return new Ft(Ht, m, o, c, d, l, u, h);+ }+ const n = e.name;+ V(!n || typeof n == "string" && n.match(Lx), "invalid name", "obj.name", n);+ let s = e.indexed;+ s != null && (V(t, "parameter cannot be indexed", "obj.indexed", e.indexed), s = !!s);+ let r = e.type, a = r.match(vD);+ if (a) {+ const o = parseInt(a[2] || "-1"), c = Ft.from({+ type: a[1],+ components: e.components+ });+ return new Ft(Ht, n || "", r, "array", s, null, o, c);+ }+ if (r === "tuple" || r.startsWith(+ "tuple("+ /* fix: ) */+ ) || r.startsWith(+ "("+ /* fix: ) */+ )) {+ const o = e.components != null ? e.components.map((l) => Ft.from(l)) : null;+ return new Ft(Ht, n || "", r, "tuple", s, o, null, null);+ }+ return r = lm(e.type), new Ft(Ht, n || "", r, r, s, null, null, null);+ }+ /**+ * Returns true if %%value%% is a **ParamType**.+ */+ static isParamType(e) {+ return e && e[Hn] === hm;+ }+}+class Mr {+ /**+ * The type of the fragment.+ */+ type;+ /**+ * The inputs for the fragment.+ */+ inputs;+ /**+ * @private+ */+ constructor(e, t, n) {+ sh(e, Ht, "Fragment"), n = Object.freeze(n.slice()), Xe(this, { type: t, inputs: n });+ }+ /**+ * Creates a new **Fragment** for %%obj%%, wich can be any supported+ * ABI frgament type.+ */+ static from(e) {+ if (typeof e == "string") {+ try {+ Mr.from(JSON.parse(e));+ } catch {+ }+ return Mr.from(qs(e));+ }+ if (e instanceof ai)+ switch (e.peekKeyword(Fx)) {+ case "constructor":+ return as.from(e);+ case "error":+ return Gn.from(e);+ case "event":+ return Fi.from(e);+ case "fallback":+ case "receive":+ return Zi.from(e);+ case "function":+ return Di.from(e);+ case "struct":+ return xr.from(e);+ }+ else if (typeof e == "object") {+ switch (e.type) {+ case "constructor":+ return as.from(e);+ case "error":+ return Gn.from(e);+ case "event":+ return Fi.from(e);+ case "fallback":+ case "receive":+ return Zi.from(e);+ case "function":+ return Di.from(e);+ case "struct":+ return xr.from(e);+ }+ ge(!1, `unsupported type: ${e.type}`, "UNSUPPORTED_OPERATION", {+ operation: "Fragment.from"+ });+ }+ V(!1, "unsupported frgament object", "obj", e);+ }+ /**+ * Returns true if %%value%% is a [[ConstructorFragment]].+ */+ static isConstructor(e) {+ return as.isFragment(e);+ }+ /**+ * Returns true if %%value%% is an [[ErrorFragment]].+ */+ static isError(e) {+ return Gn.isFragment(e);+ }+ /**+ * Returns true if %%value%% is an [[EventFragment]].+ */+ static isEvent(e) {+ return Fi.isFragment(e);+ }+ /**+ * Returns true if %%value%% is a [[FunctionFragment]].+ */+ static isFunction(e) {+ return Di.isFragment(e);+ }+ /**+ * Returns true if %%value%% is a [[StructFragment]].+ */+ static isStruct(e) {+ return xr.isFragment(e);+ }+}+class fh extends Mr {+ /**+ * The name of the fragment.+ */+ name;+ /**+ * @private+ */+ constructor(e, t, n, s) {+ super(e, t, s), V(typeof n == "string" && n.match(Lx), "invalid identifier", "name", n), s = Object.freeze(s.slice()), Xe(this, { name: n });+ }+}+function Xo(i, e) {+ return "(" + e.map((t) => t.format(i)).join(i === "full" ? ", " : ",") + ")";+}+class Gn extends fh {+ /**+ * @private+ */+ constructor(e, t, n) {+ super(e, "error", t, n), Object.defineProperty(this, Hn, { value: um });+ }+ /**+ * The Custom Error selector.+ */+ get selector() {+ return Sr(this.format("sighash")).substring(0, 10);+ }+ /**+ * Returns a string representation of this fragment as %%format%%.+ */+ format(e) {+ if (e == null && (e = "sighash"), e === "json")+ return JSON.stringify({+ type: "error",+ name: this.name,+ inputs: this.inputs.map((n) => JSON.parse(n.format(e)))+ });+ const t = [];+ return e !== "sighash" && t.push("error"), t.push(this.name + Xo(e, this.inputs)), t.join(" ");+ }+ /**+ * Returns a new **ErrorFragment** for %%obj%%.+ */+ static from(e) {+ if (Gn.isFragment(e))+ return e;+ if (typeof e == "string")+ return Gn.from(qs(e));+ if (e instanceof ai) {+ const t = dh("error", e), n = hs(e);+ return Ir(e), new Gn(Ht, t, n);+ }+ return new Gn(Ht, e.name, e.inputs ? e.inputs.map(Ft.from) : []);+ }+ /**+ * Returns ``true`` and provides a type guard if %%value%% is an+ * **ErrorFragment**.+ */+ static isFragment(e) {+ return e && e[Hn] === um;+ }+}+class Fi extends fh {+ /**+ * Whether this event is anonymous.+ */+ anonymous;+ /**+ * @private+ */+ constructor(e, t, n, s) {+ super(e, "event", t, n), Object.defineProperty(this, Hn, { value: dm }), Xe(this, { anonymous: s });+ }+ /**+ * The Event topic hash.+ */+ get topicHash() {+ return Sr(this.format("sighash"));+ }+ /**+ * Returns a string representation of this event as %%format%%.+ */+ format(e) {+ if (e == null && (e = "sighash"), e === "json")+ return JSON.stringify({+ type: "event",+ anonymous: this.anonymous,+ name: this.name,+ inputs: this.inputs.map((n) => JSON.parse(n.format(e)))+ });+ const t = [];+ return e !== "sighash" && t.push("event"), t.push(this.name + Xo(e, this.inputs)), e !== "sighash" && this.anonymous && t.push("anonymous"), t.join(" ");+ }+ /**+ * Return the topic hash for an event with %%name%% and %%params%%.+ */+ static getTopicHash(e, t) {+ return t = (t || []).map((s) => Ft.from(s)), new Fi(Ht, e, t, !1).topicHash;+ }+ /**+ * Returns a new **EventFragment** for %%obj%%.+ */+ static from(e) {+ if (Fi.isFragment(e))+ return e;+ if (typeof e == "string")+ try {+ return Fi.from(qs(e));+ } catch {+ V(!1, "invalid event fragment", "obj", e);+ }+ else if (e instanceof ai) {+ const t = dh("event", e), n = hs(e, !0), s = !!fs(e, Ln(["anonymous"])).has("anonymous");+ return Ir(e), new Fi(Ht, t, n, s);+ }+ return new Fi(Ht, e.name, e.inputs ? e.inputs.map((t) => Ft.from(t, !0)) : [], !!e.anonymous);+ }+ /**+ * Returns ``true`` and provides a type guard if %%value%% is an+ * **EventFragment**.+ */+ static isFragment(e) {+ return e && e[Hn] === dm;+ }+}+class as extends Mr {+ /**+ * Whether the constructor can receive an endowment.+ */+ payable;+ /**+ * The recommended gas limit for deployment or ``null``.+ */+ gas;+ /**+ * @private+ */+ constructor(e, t, n, s, r) {+ super(e, t, n), Object.defineProperty(this, Hn, { value: fm }), Xe(this, { payable: s, gas: r });+ }+ /**+ * Returns a string representation of this constructor as %%format%%.+ */+ format(e) {+ if (ge(e != null && e !== "sighash", "cannot format a constructor for sighash", "UNSUPPORTED_OPERATION", { operation: "format(sighash)" }), e === "json")+ return JSON.stringify({+ type: "constructor",+ stateMutability: this.payable ? "payable" : "undefined",+ payable: this.payable,+ gas: this.gas != null ? this.gas : void 0,+ inputs: this.inputs.map((n) => JSON.parse(n.format(e)))+ });+ const t = [`constructor${Xo(e, this.inputs)}`];+ return this.payable && t.push("payable"), this.gas != null && t.push(`@${this.gas.toString()}`), t.join(" ");+ }+ /**+ * Returns a new **ConstructorFragment** for %%obj%%.+ */+ static from(e) {+ if (as.isFragment(e))+ return e;+ if (typeof e == "string")+ try {+ return as.from(qs(e));+ } catch {+ V(!1, "invalid constuctor fragment", "obj", e);+ }+ else if (e instanceof ai) {+ fs(e, Ln(["constructor"]));+ const t = hs(e), n = !!fs(e, pD).has("payable"), s = Ux(e);+ return Ir(e), new as(Ht, "constructor", t, n, s);+ }+ return new as(Ht, "constructor", e.inputs ? e.inputs.map(Ft.from) : [], !!e.payable, e.gas != null ? e.gas : null);+ }+ /**+ * Returns ``true`` and provides a type guard if %%value%% is a+ * **ConstructorFragment**.+ */+ static isFragment(e) {+ return e && e[Hn] === fm;+ }+}+class Zi extends Mr {+ /**+ * If the function can be sent value during invocation.+ */+ payable;+ constructor(e, t, n) {+ super(e, "fallback", t), Object.defineProperty(this, Hn, { value: pm }), Xe(this, { payable: n });+ }+ /**+ * Returns a string representation of this fallback as %%format%%.+ */+ format(e) {+ const t = this.inputs.length === 0 ? "receive" : "fallback";+ if (e === "json") {+ const n = this.payable ? "payable" : "nonpayable";+ return JSON.stringify({ type: t, stateMutability: n });+ }+ return `${t}()${this.payable ? " payable" : ""}`;+ }+ /**+ * Returns a new **FallbackFragment** for %%obj%%.+ */+ static from(e) {+ if (Zi.isFragment(e))+ return e;+ if (typeof e == "string")+ try {+ return Zi.from(qs(e));+ } catch {+ V(!1, "invalid fallback fragment", "obj", e);+ }+ else if (e instanceof ai) {+ const t = e.toString(), n = e.peekKeyword(Ln(["fallback", "receive"]));+ if (V(n, "type must be fallback or receive", "obj", t), e.popKeyword(Ln(["fallback", "receive"])) === "receive") {+ const o = hs(e);+ return V(o.length === 0, "receive cannot have arguments", "obj.inputs", o), fs(e, Ln(["payable"])), Ir(e), new Zi(Ht, [], !0);+ }+ let r = hs(e);+ r.length ? V(r.length === 1 && r[0].type === "bytes", "invalid fallback inputs", "obj.inputs", r.map((o) => o.format("minimal")).join(", ")) : r = [Ft.from("bytes")];+ const a = kx(e);+ if (V(a === "nonpayable" || a === "payable", "fallback cannot be constants", "obj.stateMutability", a), fs(e, Ln(["returns"])).has("returns")) {+ const o = hs(e);+ V(o.length === 1 && o[0].type === "bytes", "invalid fallback outputs", "obj.outputs", o.map((c) => c.format("minimal")).join(", "));+ }+ return Ir(e), new Zi(Ht, r, a === "payable");+ }+ if (e.type === "receive")+ return new Zi(Ht, [], !0);+ if (e.type === "fallback") {+ const t = [Ft.from("bytes")], n = e.stateMutability === "payable";+ return new Zi(Ht, t, n);+ }+ V(!1, "invalid fallback description", "obj", e);+ }+ /**+ * Returns ``true`` and provides a type guard if %%value%% is a+ * **FallbackFragment**.+ */+ static isFragment(e) {+ return e && e[Hn] === pm;+ }+}+class Di extends fh {+ /**+ * If the function is constant (e.g. ``pure`` or ``view`` functions).+ */+ constant;+ /**+ * The returned types for the result of calling this function.+ */+ outputs;+ /**+ * The state mutability (e.g. ``payable``, ``nonpayable``, ``view``+ * or ``pure``)+ */+ stateMutability;+ /**+ * If the function can be sent value during invocation.+ */+ payable;+ /**+ * The recommended gas limit to send when calling this function.+ */+ gas;+ /**+ * @private+ */+ constructor(e, t, n, s, r, a) {+ super(e, "function", t, s), Object.defineProperty(this, Hn, { value: Am }), r = Object.freeze(r.slice()), Xe(this, { constant: n === "view" || n === "pure", gas: a, outputs: r, payable: n === "payable", stateMutability: n });+ }+ /**+ * The Function selector.+ */+ get selector() {+ return Sr(this.format("sighash")).substring(0, 10);+ }+ /**+ * Returns a string representation of this function as %%format%%.+ */+ format(e) {+ if (e == null && (e = "sighash"), e === "json")+ return JSON.stringify({+ type: "function",+ name: this.name,+ constant: this.constant,+ stateMutability: this.stateMutability !== "nonpayable" ? this.stateMutability : void 0,+ payable: this.payable,+ gas: this.gas != null ? this.gas : void 0,+ inputs: this.inputs.map((n) => JSON.parse(n.format(e))),+ outputs: this.outputs.map((n) => JSON.parse(n.format(e)))+ });+ const t = [];+ return e !== "sighash" && t.push("function"), t.push(this.name + Xo(e, this.inputs)), e !== "sighash" && (this.stateMutability !== "nonpayable" && t.push(this.stateMutability), this.outputs && this.outputs.length && (t.push("returns"), t.push(Xo(e, this.outputs))), this.gas != null && t.push(`@${this.gas.toString()}`)), t.join(" ");+ }+ /**+ * Return the selector for a function with %%name%% and %%params%%.+ */+ static getSelector(e, t) {+ return t = (t || []).map((s) => Ft.from(s)), new Di(Ht, e, "view", t, [], null).selector;+ }+ /**+ * Returns a new **FunctionFragment** for %%obj%%.+ */+ static from(e) {+ if (Di.isFragment(e))+ return e;+ if (typeof e == "string")+ try {+ return Di.from(qs(e));+ } catch {+ V(!1, "invalid function fragment", "obj", e);+ }+ else if (e instanceof ai) {+ const n = dh("function", e), s = hs(e), r = kx(e);+ let a = [];+ fs(e, Ln(["returns"])).has("returns") && (a = hs(e));+ const o = Ux(e);+ return Ir(e), new Di(Ht, n, r, s, a, o);+ }+ let t = e.stateMutability;+ return t == null && (t = "payable", typeof e.constant == "boolean" ? (t = "view", e.constant || (t = "payable", typeof e.payable == "boolean" && !e.payable && (t = "nonpayable"))) : typeof e.payable == "boolean" && !e.payable && (t = "nonpayable")), new Di(Ht, e.name, t, e.inputs ? e.inputs.map(Ft.from) : [], e.outputs ? e.outputs.map(Ft.from) : [], e.gas != null ? e.gas : null);+ }+ /**+ * Returns ``true`` and provides a type guard if %%value%% is a+ * **FunctionFragment**.+ */+ static isFragment(e) {+ return e && e[Hn] === Am;+ }+}+class xr extends fh {+ /**+ * @private+ */+ constructor(e, t, n) {+ super(e, "struct", t, n), Object.defineProperty(this, Hn, { value: gm });+ }+ /**+ * Returns a string representation of this struct as %%format%%.+ */+ format() {+ throw new Error("@TODO");+ }+ /**+ * Returns a new **StructFragment** for %%obj%%.+ */+ static from(e) {+ if (typeof e == "string")+ try {+ return xr.from(qs(e));+ } catch {+ V(!1, "invalid struct fragment", "obj", e);+ }+ else if (e instanceof ai) {+ const t = dh("struct", e), n = hs(e);+ return Ir(e), new xr(Ht, t, n);+ }+ return new xr(Ht, e.name, e.inputs ? e.inputs.map(Ft.from) : []);+ }+ // @TODO: fix this return type+ /**+ * Returns ``true`` and provides a type guard if %%value%% is a+ * **StructFragment**.+ */+ static isFragment(e) {+ return e && e[Hn] === gm;+ }+}+const Si = /* @__PURE__ */ new Map();+Si.set(0, "GENERIC_PANIC");+Si.set(1, "ASSERT_FALSE");+Si.set(17, "OVERFLOW");+Si.set(18, "DIVIDE_BY_ZERO");+Si.set(33, "ENUM_RANGE_ERROR");+Si.set(34, "BAD_STORAGE_DATA");+Si.set(49, "STACK_UNDERFLOW");+Si.set(50, "ARRAY_RANGE_ERROR");+Si.set(65, "OUT_OF_MEMORY");+Si.set(81, "UNINITIALIZED_FUNCTION_CALL");+const CD = new RegExp(/^bytes([0-9]*)$/), SD = new RegExp(/^(u?int)([0-9]*)$/);+let Iu = null, mm = 1024;+function ID(i, e, t, n) {+ let s = "missing revert data", r = null;+ const a = null;+ let o = null;+ if (t) {+ s = "execution reverted";+ const l = ht(t);+ if (t = Se(t), l.length === 0)+ s += " (no data present; likely require(false) occurred", r = "require(false)";+ else if (l.length % 32 !== 4)+ s += " (could not decode reason; invalid data length)";+ else if (Se(l.slice(0, 4)) === "0x08c379a0")+ try {+ r = n.decode(["string"], l.slice(4))[0], o = {+ signature: "Error(string)",+ name: "Error",+ args: [r]+ }, s += `: ${JSON.stringify(r)}`;+ } catch {+ s += " (could not decode reason; invalid string data)";+ }+ else if (Se(l.slice(0, 4)) === "0x4e487b71")+ try {+ const h = Number(n.decode(["uint256"], l.slice(4))[0]);+ o = {+ signature: "Panic(uint256)",+ name: "Panic",+ args: [h]+ }, r = `Panic due to ${Si.get(h) || "UNKNOWN"}(${h})`, s += `: ${r}`;+ } catch {+ s += " (could not decode panic code)";+ }+ else+ s += " (unknown custom error)";+ }+ const c = {+ to: e.to ? St(e.to) : null,+ data: e.data || "0x"+ };+ return e.from && (c.from = St(e.from)), Ot(s, "CALL_EXCEPTION", {+ action: i,+ data: t,+ reason: r,+ transaction: c,+ invocation: a,+ revert: o+ });+}+class Pa {+ #e(e) {+ if (e.isArray())+ return new VN(this.#e(e.arrayChildren), e.arrayLength, e.name);+ if (e.isTuple())+ return new rl(e.components.map((n) => this.#e(n)), e.name);+ switch (e.baseType) {+ case "address":+ return new HN(e.name);+ case "bool":+ return new WN(e.name);+ case "string":+ return new eF(e.name);+ case "bytes":+ return new qN(e.name);+ case "":+ return new XN(e.name);+ }+ let t = e.type.match(SD);+ if (t) {+ let n = parseInt(t[2] || "256");+ return V(n !== 0 && n <= 256 && n % 8 === 0, "invalid " + t[1] + " bit length", "param", e), new $N(n / 8, t[1] === "int", e.name);+ }+ if (t = e.type.match(CD), t) {+ let n = parseInt(t[1]);+ return V(n !== 0 && n <= 32, "invalid bytes length", "param", e), new KN(n, e.name);+ }+ V(!1, "invalid type", "type", e.type);+ }+ /**+ * Get the default values for the given %%types%%.+ *+ * For example, a ``uint`` is by default ``0`` and ``bool``+ * is by default ``false``.+ */+ getDefaultValue(e) {+ const t = e.map((s) => this.#e(Ft.from(s)));+ return new rl(t, "_").defaultValue();+ }+ /**+ * Encode the %%values%% as the %%types%% into ABI data.+ *+ * @returns DataHexstring+ */+ encode(e, t) {+ Ab(t.length, e.length, "types/values length mismatch");+ const n = e.map((a) => this.#e(Ft.from(a))), s = new rl(n, "_"), r = new Hd();+ return s.encode(r, t), r.data;+ }+ /**+ * Decode the ABI %%data%% as the %%types%% into values.+ *+ * If %%loose%% decoding is enabled, then strict padding is+ * not enforced. Some older versions of Solidity incorrectly+ * padded event data emitted from ``external`` functions.+ */+ decode(e, t, n) {+ const s = e.map((a) => this.#e(Ft.from(a)));+ return new rl(s, "_").decode(new qf(t, n, mm));+ }+ static _setDefaultMaxInflation(e) {+ V(typeof e == "number" && Number.isInteger(e), "invalid defaultMaxInflation factor", "value", e), mm = e;+ }+ /**+ * Returns the shared singleton instance of a default [[AbiCoder]].+ *+ * On the first call, the instance is created internally.+ */+ static defaultAbiCoder() {+ return Iu == null && (Iu = new Pa()), Iu;+ }+ /**+ * Returns an ethers-compatible [[CallExceptionError]] Error for the given+ * result %%data%% for the [[CallExceptionAction]] %%action%% against+ * the Transaction %%tx%%.+ */+ static getBuiltinCallException(e, t, n) {+ return ID(e, t, n, Pa.defaultAbiCoder());+ }+}+class MD {+ /**+ * The matching fragment for the ``topic0``.+ */+ fragment;+ /**+ * The name of the Event.+ */+ name;+ /**+ * The full Event signature.+ */+ signature;+ /**+ * The topic hash for the Event.+ */+ topic;+ /**+ * The arguments passed into the Event with ``emit``.+ */+ args;+ /**+ * @_ignore:+ */+ constructor(e, t, n) {+ const s = e.name, r = e.format();+ Xe(this, {+ fragment: e,+ name: s,+ signature: r,+ topic: t,+ args: n+ });+ }+}+class BD {+ /**+ * The matching fragment from the transaction ``data``.+ */+ fragment;+ /**+ * The name of the Function from the transaction ``data``.+ */+ name;+ /**+ * The arguments passed to the Function from the transaction ``data``.+ */+ args;+ /**+ * The full Function signature from the transaction ``data``.+ */+ signature;+ /**+ * The selector for the Function from the transaction ``data``.+ */+ selector;+ /**+ * The ``value`` (in wei) from the transaction.+ */+ value;+ /**+ * @_ignore:+ */+ constructor(e, t, n, s) {+ const r = e.name, a = e.format();+ Xe(this, {+ fragment: e,+ name: r,+ args: n,+ signature: a,+ selector: t,+ value: s+ });+ }+}+class TD {+ /**+ * The matching fragment.+ */+ fragment;+ /**+ * The name of the Error.+ */+ name;+ /**+ * The arguments passed to the Error with ``revert``.+ */+ args;+ /**+ * The full Error signature.+ */+ signature;+ /**+ * The selector for the Error.+ */+ selector;+ /**+ * @_ignore:+ */+ constructor(e, t, n) {+ const s = e.name, r = e.format();+ Xe(this, {+ fragment: e,+ name: s,+ args: n,+ signature: r,+ selector: t+ });+ }+}+class bm {+ /**+ * The ``keccak256`` of the value logged.+ */+ hash;+ /**+ * @_ignore:+ */+ _isIndexed;+ /**+ * Returns ``true`` if %%value%% is an **Indexed**.+ *+ * This provides a Type Guard for property access.+ */+ static isIndexed(e) {+ return !!(e && e._isIndexed);+ }+ /**+ * @_ignore:+ */+ constructor(e) {+ Xe(this, { hash: e, _isIndexed: !0 });+ }+}+const xm = {+ 0: "generic panic",+ 1: "assert(false)",+ 17: "arithmetic overflow",+ 18: "division or modulo by zero",+ 33: "enum overflow",+ 34: "invalid encoded storage byte array accessed",+ 49: "out-of-bounds array access; popping on an empty array",+ 50: "out-of-bounds access of an array or bytesN",+ 65: "out of memory",+ 81: "uninitialized function"+}, _m = {+ "0x08c379a0": {+ signature: "Error(string)",+ name: "Error",+ inputs: ["string"],+ reason: (i) => `reverted with reason string ${JSON.stringify(i)}`+ },+ "0x4e487b71": {+ signature: "Panic(uint256)",+ name: "Panic",+ inputs: ["uint256"],+ reason: (i) => {+ let e = "unknown panic code";+ return i >= 0 && i <= 255 && xm[i.toString()] && (e = xm[i.toString()]), `reverted with panic code 0x${i.toString(16)} (${e})`;+ }+ }+};+class hr {+ /**+ * All the Contract ABI members (i.e. methods, events, errors, etc).+ */+ fragments;+ /**+ * The Contract constructor.+ */+ deploy;+ /**+ * The Fallback method, if any.+ */+ fallback;+ /**+ * If receiving ether is supported.+ */+ receive;+ #e;+ #t;+ #n;+ // #structs: Map<string, StructFragment>;+ #i;+ /**+ * Create a new Interface for the %%fragments%%.+ */+ constructor(e) {+ let t = [];+ typeof e == "string" ? t = JSON.parse(e) : t = e, this.#n = /* @__PURE__ */ new Map(), this.#e = /* @__PURE__ */ new Map(), this.#t = /* @__PURE__ */ new Map();+ const n = [];+ for (const a of t)+ try {+ n.push(Mr.from(a));+ } catch (o) {+ console.log(`[Warning] Invalid Fragment ${JSON.stringify(a)}:`, o.message);+ }+ Xe(this, {+ fragments: Object.freeze(n)+ });+ let s = null, r = !1;+ this.#i = this.getAbiCoder(), this.fragments.forEach((a, o) => {+ let c;+ switch (a.type) {+ case "constructor":+ if (this.deploy) {+ console.log("duplicate definition - constructor");+ return;+ }+ Xe(this, { deploy: a });+ return;+ case "fallback":+ a.inputs.length === 0 ? r = !0 : (V(!s || a.payable !== s.payable, "conflicting fallback fragments", `fragments[${o}]`, a), s = a, r = s.payable);+ return;+ case "function":+ c = this.#n;+ break;+ case "event":+ c = this.#t;+ break;+ case "error":+ c = this.#e;+ break;+ default:+ return;+ }+ const l = a.format();+ c.has(l) || c.set(l, a);+ }), this.deploy || Xe(this, {+ deploy: as.from("constructor()")+ }), Xe(this, { fallback: s, receive: r });+ }+ /**+ * Returns the entire Human-Readable ABI, as an array of+ * signatures, optionally as %%minimal%% strings, which+ * removes parameter names and unneceesary spaces.+ */+ format(e) {+ const t = e ? "minimal" : "full";+ return this.fragments.map((s) => s.format(t));+ }+ /**+ * Return the JSON-encoded ABI. This is the format Solidiy+ * returns.+ */+ formatJson() {+ const e = this.fragments.map((t) => t.format("json"));+ return JSON.stringify(e.map((t) => JSON.parse(t)));+ }+ /**+ * The ABI coder that will be used to encode and decode binary+ * data.+ */+ getAbiCoder() {+ return Pa.defaultAbiCoder();+ }+ // Find a function definition by any means necessary (unless it is ambiguous)+ #s(e, t, n) {+ if (Lt(e)) {+ const r = e.toLowerCase();+ for (const a of this.#n.values())+ if (r === a.selector)+ return a;+ return null;+ }+ if (e.indexOf("(") === -1) {+ const r = [];+ for (const [a, o] of this.#n)+ a.split(+ "("+ /* fix:) */+ )[0] === e && r.push(o);+ if (t) {+ const a = t.length > 0 ? t[t.length - 1] : null;+ let o = t.length, c = !0;+ Wt.isTyped(a) && a.type === "overrides" && (c = !1, o--);+ for (let l = r.length - 1; l >= 0; l--) {+ const h = r[l].inputs.length;+ h !== o && (!c || h !== o - 1) && r.splice(l, 1);+ }+ for (let l = r.length - 1; l >= 0; l--) {+ const h = r[l].inputs;+ for (let u = 0; u < t.length; u++)+ if (Wt.isTyped(t[u])) {+ if (u >= h.length) {+ if (t[u].type === "overrides")+ continue;+ r.splice(l, 1);+ break;+ }+ if (t[u].type !== h[u].baseType) {+ r.splice(l, 1);+ break;+ }+ }+ }+ }+ if (r.length === 1 && t && t.length !== r[0].inputs.length) {+ const a = t[t.length - 1];+ (a == null || Array.isArray(a) || typeof a != "object") && r.splice(0, 1);+ }+ if (r.length === 0)+ return null;+ if (r.length > 1 && n) {+ const a = r.map((o) => JSON.stringify(o.format())).join(", ");+ V(!1, `ambiguous function description (i.e. matches ${a})`, "key", e);+ }+ return r[0];+ }+ const s = this.#n.get(Di.from(e).format());+ return s || null;+ }+ /**+ * Get the function name for %%key%%, which may be a function selector,+ * function name or function signature that belongs to the ABI.+ */+ getFunctionName(e) {+ const t = this.#s(e, null, !1);+ return V(t, "no matching function", "key", e), t.name;+ }+ /**+ * Returns true if %%key%% (a function selector, function name or+ * function signature) is present in the ABI.+ *+ * In the case of a function name, the name may be ambiguous, so+ * accessing the [[FunctionFragment]] may require refinement.+ */+ hasFunction(e) {+ return !!this.#s(e, null, !1);+ }+ /**+ * Get the [[FunctionFragment]] for %%key%%, which may be a function+ * selector, function name or function signature that belongs to the ABI.+ *+ * If %%values%% is provided, it will use the Typed API to handle+ * ambiguous cases where multiple functions match by name.+ *+ * If the %%key%% and %%values%% do not refine to a single function in+ * the ABI, this will throw.+ */+ getFunction(e, t) {+ return this.#s(e, t || null, !0);+ }+ /**+ * Iterate over all functions, calling %%callback%%, sorted by their name.+ */+ forEachFunction(e) {+ const t = Array.from(this.#n.keys());+ t.sort((n, s) => n.localeCompare(s));+ for (let n = 0; n < t.length; n++) {+ const s = t[n];+ e(this.#n.get(s), n);+ }+ }+ // Find an event definition by any means necessary (unless it is ambiguous)+ #a(e, t, n) {+ if (Lt(e)) {+ const r = e.toLowerCase();+ for (const a of this.#t.values())+ if (r === a.topicHash)+ return a;+ return null;+ }+ if (e.indexOf("(") === -1) {+ const r = [];+ for (const [a, o] of this.#t)+ a.split(+ "("+ /* fix:) */+ )[0] === e && r.push(o);+ if (t) {+ for (let a = r.length - 1; a >= 0; a--)+ r[a].inputs.length < t.length && r.splice(a, 1);+ for (let a = r.length - 1; a >= 0; a--) {+ const o = r[a].inputs;+ for (let c = 0; c < t.length; c++)+ if (Wt.isTyped(t[c]) && t[c].type !== o[c].baseType) {+ r.splice(a, 1);+ break;+ }+ }+ }+ if (r.length === 0)+ return null;+ if (r.length > 1 && n) {+ const a = r.map((o) => JSON.stringify(o.format())).join(", ");+ V(!1, `ambiguous event description (i.e. matches ${a})`, "key", e);+ }+ return r[0];+ }+ const s = this.#t.get(Fi.from(e).format());+ return s || null;+ }+ /**+ * Get the event name for %%key%%, which may be a topic hash,+ * event name or event signature that belongs to the ABI.+ */+ getEventName(e) {+ const t = this.#a(e, null, !1);+ return V(t, "no matching event", "key", e), t.name;+ }+ /**+ * Returns true if %%key%% (an event topic hash, event name or+ * event signature) is present in the ABI.+ *+ * In the case of an event name, the name may be ambiguous, so+ * accessing the [[EventFragment]] may require refinement.+ */+ hasEvent(e) {+ return !!this.#a(e, null, !1);+ }+ /**+ * Get the [[EventFragment]] for %%key%%, which may be a topic hash,+ * event name or event signature that belongs to the ABI.+ *+ * If %%values%% is provided, it will use the Typed API to handle+ * ambiguous cases where multiple events match by name.+ *+ * If the %%key%% and %%values%% do not refine to a single event in+ * the ABI, this will throw.+ */+ getEvent(e, t) {+ return this.#a(e, t || null, !0);+ }+ /**+ * Iterate over all events, calling %%callback%%, sorted by their name.+ */+ forEachEvent(e) {+ const t = Array.from(this.#t.keys());+ t.sort((n, s) => n.localeCompare(s));+ for (let n = 0; n < t.length; n++) {+ const s = t[n];+ e(this.#t.get(s), n);+ }+ }+ /**+ * Get the [[ErrorFragment]] for %%key%%, which may be an error+ * selector, error name or error signature that belongs to the ABI.+ *+ * If %%values%% is provided, it will use the Typed API to handle+ * ambiguous cases where multiple errors match by name.+ *+ * If the %%key%% and %%values%% do not refine to a single error in+ * the ABI, this will throw.+ */+ getError(e, t) {+ if (Lt(e)) {+ const s = e.toLowerCase();+ if (_m[s])+ return Gn.from(_m[s].signature);+ for (const r of this.#e.values())+ if (s === r.selector)+ return r;+ return null;+ }+ if (e.indexOf("(") === -1) {+ const s = [];+ for (const [r, a] of this.#e)+ r.split(+ "("+ /* fix:) */+ )[0] === e && s.push(a);+ if (s.length === 0)+ return e === "Error" ? Gn.from("error Error(string)") : e === "Panic" ? Gn.from("error Panic(uint256)") : null;+ if (s.length > 1) {+ const r = s.map((a) => JSON.stringify(a.format())).join(", ");+ V(!1, `ambiguous error description (i.e. ${r})`, "name", e);+ }+ return s[0];+ }+ if (e = Gn.from(e).format(), e === "Error(string)")+ return Gn.from("error Error(string)");+ if (e === "Panic(uint256)")+ return Gn.from("error Panic(uint256)");+ const n = this.#e.get(e);+ return n || null;+ }+ /**+ * Iterate over all errors, calling %%callback%%, sorted by their name.+ */+ forEachError(e) {+ const t = Array.from(this.#e.keys());+ t.sort((n, s) => n.localeCompare(s));+ for (let n = 0; n < t.length; n++) {+ const s = t[n];+ e(this.#e.get(s), n);+ }+ }+ // Get the 4-byte selector used by Solidity to identify a function+ /*+ getSelector(fragment: ErrorFragment | FunctionFragment): string {+ if (typeof(fragment) === "string") {+ const matches: Array<Fragment> = [ ];++ try { matches.push(this.getFunction(fragment)); } catch (error) { }+ try { matches.push(this.getError(<string>fragment)); } catch (_) { }++ if (matches.length === 0) {+ logger.throwArgumentError("unknown fragment", "key", fragment);+ } else if (matches.length > 1) {+ logger.throwArgumentError("ambiguous fragment matches function and error", "key", fragment);+ }++ fragment = matches[0];+ }++ return dataSlice(id(fragment.format()), 0, 4);+ }+ */+ // Get the 32-byte topic hash used by Solidity to identify an event+ /*+ getEventTopic(fragment: EventFragment): string {+ //if (typeof(fragment) === "string") { fragment = this.getEvent(eventFragment); }+ return id(fragment.format());+ }+ */+ _decodeParams(e, t) {+ return this.#i.decode(e, t);+ }+ _encodeParams(e, t) {+ return this.#i.encode(e, t);+ }+ /**+ * Encodes a ``tx.data`` object for deploying the Contract with+ * the %%values%% as the constructor arguments.+ */+ encodeDeploy(e) {+ return this._encodeParams(this.deploy.inputs, e || []);+ }+ /**+ * Decodes the result %%data%% (e.g. from an ``eth_call``) for the+ * specified error (see [[getError]] for valid values for+ * %%key%%).+ *+ * Most developers should prefer the [[parseCallResult]] method instead,+ * which will automatically detect a ``CALL_EXCEPTION`` and throw the+ * corresponding error.+ */+ decodeErrorResult(e, t) {+ if (typeof e == "string") {+ const n = this.getError(e);+ V(n, "unknown error", "fragment", e), e = n;+ }+ return V(Vt(t, 0, 4) === e.selector, `data signature does not match error ${e.name}.`, "data", t), this._decodeParams(e.inputs, Vt(t, 4));+ }+ /**+ * Encodes the transaction revert data for a call result that+ * reverted from the the Contract with the sepcified %%error%%+ * (see [[getError]] for valid values for %%fragment%%) with the %%values%%.+ *+ * This is generally not used by most developers, unless trying to mock+ * a result from a Contract.+ */+ encodeErrorResult(e, t) {+ if (typeof e == "string") {+ const n = this.getError(e);+ V(n, "unknown error", "fragment", e), e = n;+ }+ return Qt([+ e.selector,+ this._encodeParams(e.inputs, t || [])+ ]);+ }+ /**+ * Decodes the %%data%% from a transaction ``tx.data`` for+ * the function specified (see [[getFunction]] for valid values+ * for %%fragment%%).+ *+ * Most developers should prefer the [[parseTransaction]] method+ * instead, which will automatically detect the fragment.+ */+ decodeFunctionData(e, t) {+ if (typeof e == "string") {+ const n = this.getFunction(e);+ V(n, "unknown function", "fragment", e), e = n;+ }+ return V(Vt(t, 0, 4) === e.selector, `data signature does not match function ${e.name}.`, "data", t), this._decodeParams(e.inputs, Vt(t, 4));+ }+ /**+ * Encodes the ``tx.data`` for a transaction that calls the function+ * specified (see [[getFunction]] for valid values for %%fragment%%) with+ * the %%values%%.+ */+ encodeFunctionData(e, t) {+ if (typeof e == "string") {+ const n = this.getFunction(e);+ V(n, "unknown function", "fragment", e), e = n;+ }+ return Qt([+ e.selector,+ this._encodeParams(e.inputs, t || [])+ ]);+ }+ /**+ * Decodes the result %%data%% (e.g. from an ``eth_call``) for the+ * specified function (see [[getFunction]] for valid values for+ * %%key%%).+ *+ * Most developers should prefer the [[parseCallResult]] method instead,+ * which will automatically detect a ``CALL_EXCEPTION`` and throw the+ * corresponding error.+ */+ decodeFunctionResult(e, t) {+ if (typeof e == "string") {+ const r = this.getFunction(e);+ V(r, "unknown function", "fragment", e), e = r;+ }+ let n = "invalid length for result data";+ const s = Rn(t);+ if (s.length % 32 === 0)+ try {+ return this.#i.decode(e.outputs, s);+ } catch {+ n = "could not decode result data";+ }+ ge(!1, n, "BAD_DATA", {+ value: Se(s),+ info: { method: e.name, signature: e.format() }+ });+ }+ makeError(e, t) {+ const n = ht(e, "data"), s = Pa.getBuiltinCallException("call", t, n);+ if (s.message.startsWith("execution reverted (unknown custom error)")) {+ const o = Se(n.slice(0, 4)), c = this.getError(o);+ if (c)+ try {+ const l = this.#i.decode(c.inputs, n.slice(4));+ s.revert = {+ name: c.name,+ signature: c.format(),+ args: l+ }, s.reason = s.revert.signature, s.message = `execution reverted: ${s.reason}`;+ } catch {+ s.message = "execution reverted (coult not decode custom error)";+ }+ }+ const a = this.parseTransaction(t);+ return a && (s.invocation = {+ method: a.name,+ signature: a.signature,+ args: a.args+ }), s;+ }+ /**+ * Encodes the result data (e.g. from an ``eth_call``) for the+ * specified function (see [[getFunction]] for valid values+ * for %%fragment%%) with %%values%%.+ *+ * This is generally not used by most developers, unless trying to mock+ * a result from a Contract.+ */+ encodeFunctionResult(e, t) {+ if (typeof e == "string") {+ const n = this.getFunction(e);+ V(n, "unknown function", "fragment", e), e = n;+ }+ return Se(this.#i.encode(e.outputs, t || []));+ }+ /*+ spelunk(inputs: Array<ParamType>, values: ReadonlyArray<any>, processfunc: (type: string, value: any) => Promise<any>): Promise<Array<any>> {+ const promises: Array<Promise<>> = [ ];+ const process = function(type: ParamType, value: any): any {+ if (type.baseType === "array") {+ return descend(type.child+ }+ if (type. === "address") {+ }+ };++ const descend = function (inputs: Array<ParamType>, values: ReadonlyArray<any>) {+ if (inputs.length !== values.length) { throw new Error("length mismatch"); }++ };++ const result: Array<any> = [ ];+ values.forEach((value, index) => {+ if (value == null) {+ topics.push(null);+ } else if (param.baseType === "array" || param.baseType === "tuple") {+ logger.throwArgumentError("filtering with tuples or arrays not supported", ("contract." + param.name), value);+ } else if (Array.isArray(value)) {+ topics.push(value.map((value) => encodeTopic(param, value)));+ } else {+ topics.push(encodeTopic(param, value));+ }+ });+ }+ */+ // Create the filter for the event with search criteria (e.g. for eth_filterLog)+ encodeFilterTopics(e, t) {+ if (typeof e == "string") {+ const r = this.getEvent(e);+ V(r, "unknown event", "eventFragment", e), e = r;+ }+ ge(t.length <= e.inputs.length, `too many arguments for ${e.format()}`, "UNEXPECTED_ARGUMENT", { count: t.length, expectedCount: e.inputs.length });+ const n = [];+ e.anonymous || n.push(e.topicHash);+ const s = (r, a) => r.type === "string" ? Sr(a) : r.type === "bytes" ? Zt(Se(a)) : (r.type === "bool" && typeof a == "boolean" ? a = a ? "0x01" : "0x00" : r.type.match(/^u?int/) ? a = Hs(a) : r.type.match(/^bytes/) ? a = ZT(a, 32) : r.type === "address" && this.#i.encode(["address"], [a]), ds(Se(a), 32));+ for (t.forEach((r, a) => {+ const o = e.inputs[a];+ if (!o.indexed) {+ V(r == null, "cannot filter non-indexed parameters; must be null", "contract." + o.name, r);+ return;+ }+ r == null ? n.push(null) : o.baseType === "array" || o.baseType === "tuple" ? V(!1, "filtering with tuples or arrays not supported", "contract." + o.name, r) : Array.isArray(r) ? n.push(r.map((c) => s(o, c))) : n.push(s(o, r));+ }); n.length && n[n.length - 1] === null; )+ n.pop();+ return n;+ }+ encodeEventLog(e, t) {+ if (typeof e == "string") {+ const a = this.getEvent(e);+ V(a, "unknown event", "eventFragment", e), e = a;+ }+ const n = [], s = [], r = [];+ return e.anonymous || n.push(e.topicHash), V(t.length === e.inputs.length, "event arguments/values mismatch", "values", t), e.inputs.forEach((a, o) => {+ const c = t[o];+ if (a.indexed)+ if (a.type === "string")+ n.push(Sr(c));+ else if (a.type === "bytes")+ n.push(Zt(c));+ else {+ if (a.baseType === "tuple" || a.baseType === "array")+ throw new Error("not implemented");+ n.push(this.#i.encode([a.type], [c]));+ }+ else+ s.push(a), r.push(c);+ }), {+ data: this.#i.encode(s, r),+ topics: n+ };+ }+ // Decode a filter for the event and the search criteria+ decodeEventLog(e, t, n) {+ if (typeof e == "string") {+ const f = this.getEvent(e);+ V(f, "unknown event", "eventFragment", e), e = f;+ }+ if (n != null && !e.anonymous) {+ const f = e.topicHash;+ V(Lt(n[0], 32) && n[0].toLowerCase() === f, "fragment/topic mismatch", "topics[0]", n[0]), n = n.slice(1);+ }+ const s = [], r = [], a = [];+ e.inputs.forEach((f, m) => {+ f.indexed ? f.type === "string" || f.type === "bytes" || f.baseType === "tuple" || f.baseType === "array" ? (s.push(Ft.from({ type: "bytes32", name: f.name })), a.push(!0)) : (s.push(f), a.push(!1)) : (r.push(f), a.push(!1));+ });+ const o = n != null ? this.#i.decode(s, Qt(n)) : null, c = this.#i.decode(r, t, !0), l = [], h = [];+ let u = 0, d = 0;+ return e.inputs.forEach((f, m) => {+ let A = null;+ if (f.indexed)+ if (o == null)+ A = new bm(null);+ else if (a[m])+ A = new bm(o[d++]);+ else+ try {+ A = o[d++];+ } catch (g) {+ A = g;+ }+ else+ try {+ A = c[u++];+ } catch (g) {+ A = g;+ }+ l.push(A), h.push(f.name || null);+ }), rs.fromItems(l, h);+ }+ /**+ * Parses a transaction, finding the matching function and extracts+ * the parameter values along with other useful function details.+ *+ * If the matching function cannot be found, return null.+ */+ parseTransaction(e) {+ const t = ht(e.data, "tx.data"), n = Fe(e.value != null ? e.value : 0, "tx.value"), s = this.getFunction(Se(t.slice(0, 4)));+ if (!s)+ return null;+ const r = this.#i.decode(s.inputs, t.slice(4));+ return new BD(s, s.selector, r, n);+ }+ parseCallResult(e) {+ throw new Error("@TODO");+ }+ /**+ * Parses a receipt log, finding the matching event and extracts+ * the parameter values along with other useful event details.+ *+ * If the matching event cannot be found, returns null.+ */+ parseLog(e) {+ const t = this.getEvent(e.topics[0]);+ return !t || t.anonymous ? null : new MD(t, t.topicHash, this.decodeEventLog(t, e.data, e.topics));+ }+ /**+ * Parses a revert data, finding the matching error and extracts+ * the parameter values along with other useful error details.+ *+ * If the matching error cannot be found, returns null.+ */+ parseError(e) {+ const t = Se(e), n = this.getError(Vt(t, 0, 4));+ if (!n)+ return null;+ const s = this.#i.decode(n.inputs, Vt(t, 4));+ return new TD(n, n.selector, s);+ }+ /**+ * Creates a new [[Interface]] from the ABI %%value%%.+ *+ * The %%value%% may be provided as an existing [[Interface]] object,+ * a JSON-encoded ABI or any Human-Readable ABI format.+ */+ static from(e) {+ return e instanceof hr ? e : typeof e == "string" ? new hr(JSON.parse(e)) : typeof e.formatJson == "function" ? new hr(e.formatJson()) : typeof e.format == "function" ? new hr(e.format("json")) : new hr(e);+ }+}+const Ox = BigInt(0);+function Ea(i) {+ return i ?? null;+}+function jt(i) {+ return i == null ? null : i.toString();+}+class Em {+ /**+ * The gas price for legacy networks.+ */+ gasPrice;+ /**+ * The maximum fee to pay per gas.+ *+ * The base fee per gas is defined by the network and based on+ * congestion, increasing the cost during times of heavy load+ * and lowering when less busy.+ *+ * The actual fee per gas will be the base fee for the block+ * and the priority fee, up to the max fee per gas.+ *+ * This will be ``null`` on legacy networks (i.e. [pre-EIP-1559](link-eip-1559))+ */+ maxFeePerGas;+ /**+ * The additional amout to pay per gas to encourage a validator+ * to include the transaction.+ *+ * The purpose of this is to compensate the validator for the+ * adjusted risk for including a given transaction.+ *+ * This will be ``null`` on legacy networks (i.e. [pre-EIP-1559](link-eip-1559))+ */+ maxPriorityFeePerGas;+ /**+ * Creates a new FeeData for %%gasPrice%%, %%maxFeePerGas%% and+ * %%maxPriorityFeePerGas%%.+ */+ constructor(e, t, n) {+ Xe(this, {+ gasPrice: Ea(e),+ maxFeePerGas: Ea(t),+ maxPriorityFeePerGas: Ea(n)+ });+ }+ /**+ * Returns a JSON-friendly value.+ */+ toJSON() {+ const { gasPrice: e, maxFeePerGas: t, maxPriorityFeePerGas: n } = this;+ return {+ _type: "FeeData",+ gasPrice: jt(e),+ maxFeePerGas: jt(t),+ maxPriorityFeePerGas: jt(n)+ };+ }+}+function ql(i) {+ const e = {};+ i.to && (e.to = i.to), i.from && (e.from = i.from), i.data && (e.data = Se(i.data));+ const t = "chainId,gasLimit,gasPrice,maxFeePerBlobGas,maxFeePerGas,maxPriorityFeePerGas,value".split(/,/);+ for (const s of t)+ !(s in i) || i[s] == null || (e[s] = Fe(i[s], `request.${s}`));+ const n = "type,nonce".split(/,/);+ for (const s of n)+ !(s in i) || i[s] == null || (e[s] = ut(i[s], `request.${s}`));+ return i.accessList && (e.accessList = Rr(i.accessList)), i.authorizationList && (e.authorizationList = i.authorizationList.slice()), "blockTag" in i && (e.blockTag = i.blockTag), "enableCcipRead" in i && (e.enableCcipRead = !!i.enableCcipRead), "customData" in i && (e.customData = i.customData), "blobVersionedHashes" in i && i.blobVersionedHashes && (e.blobVersionedHashes = i.blobVersionedHashes.slice()), "kzg" in i && (e.kzg = i.kzg), "blobWrapperVersion" in i && (e.blobWrapperVersion = i.blobWrapperVersion), "blobs" in i && i.blobs && (e.blobs = i.blobs.map((s) => Vf(s) ? Se(s) : Object.assign({}, s))), e;+}+class RD {+ /**+ * The provider connected to the block used to fetch additional details+ * if necessary.+ */+ provider;+ /**+ * The block number, sometimes called the block height. This is a+ * sequential number that is one higher than the parent block.+ */+ number;+ /**+ * The block hash.+ *+ * This hash includes all properties, so can be safely used to identify+ * an exact set of block properties.+ */+ hash;+ /**+ * The timestamp for this block, which is the number of seconds since+ * epoch that this block was included.+ */+ timestamp;+ /**+ * The block hash of the parent block.+ */+ parentHash;+ /**+ * The hash tree root of the parent beacon block for the given+ * execution block. See [[link-eip-4788]].+ */+ parentBeaconBlockRoot;+ /**+ * The nonce.+ *+ * On legacy networks, this is the random number inserted which+ * permitted the difficulty target to be reached.+ */+ nonce;+ /**+ * The difficulty target.+ *+ * On legacy networks, this is the proof-of-work target required+ * for a block to meet the protocol rules to be included.+ *+ * On modern networks, this is a random number arrived at using+ * randao. @TODO: Find links?+ */+ difficulty;+ /**+ * The total gas limit for this block.+ */+ gasLimit;+ /**+ * The total gas used in this block.+ */+ gasUsed;+ /**+ * The root hash for the global state after applying changes+ * in this block.+ */+ stateRoot;+ /**+ * The hash of the transaction receipts trie.+ */+ receiptsRoot;+ /**+ * The total amount of blob gas consumed by the transactions+ * within the block. See [[link-eip-4844]].+ */+ blobGasUsed;+ /**+ * The running total of blob gas consumed in excess of the+ * target, prior to the block. See [[link-eip-4844]].+ */+ excessBlobGas;+ /**+ * The miner coinbase address, wihch receives any subsidies for+ * including this block.+ */+ miner;+ /**+ * The latest RANDAO mix of the post beacon state of+ * the previous block.+ */+ prevRandao;+ /**+ * Any extra data the validator wished to include.+ */+ extraData;+ /**+ * The base fee per gas that all transactions in this block were+ * charged.+ *+ * This adjusts after each block, depending on how congested the network+ * is.+ */+ baseFeePerGas;+ #e;+ /**+ * Create a new **Block** object.+ *+ * This should generally not be necessary as the unless implementing a+ * low-level library.+ */+ constructor(e, t) {+ this.#e = e.transactions.map((n) => typeof n != "string" ? new ac(n, t) : n), Xe(this, {+ provider: t,+ hash: Ea(e.hash),+ number: e.number,+ timestamp: e.timestamp,+ parentHash: e.parentHash,+ parentBeaconBlockRoot: e.parentBeaconBlockRoot,+ nonce: e.nonce,+ difficulty: e.difficulty,+ gasLimit: e.gasLimit,+ gasUsed: e.gasUsed,+ blobGasUsed: e.blobGasUsed,+ excessBlobGas: e.excessBlobGas,+ miner: e.miner,+ prevRandao: Ea(e.prevRandao),+ extraData: e.extraData,+ baseFeePerGas: Ea(e.baseFeePerGas),+ stateRoot: e.stateRoot,+ receiptsRoot: e.receiptsRoot+ });+ }+ /**+ * Returns the list of transaction hashes, in the order+ * they were executed within the block.+ */+ get transactions() {+ return this.#e.map((e) => typeof e == "string" ? e : e.hash);+ }+ /**+ * Returns the complete transactions, in the order they+ * were executed within the block.+ *+ * This is only available for blocks which prefetched+ * transactions, by passing ``true`` to %%prefetchTxs%%+ * into [[Provider-getBlock]].+ */+ get prefetchedTransactions() {+ const e = this.#e.slice();+ return e.length === 0 ? [] : (ge(typeof e[0] == "object", "transactions were not prefetched with block request", "UNSUPPORTED_OPERATION", {+ operation: "transactionResponses()"+ }), e);+ }+ /**+ * Returns a JSON-friendly value.+ */+ toJSON() {+ const { baseFeePerGas: e, difficulty: t, extraData: n, gasLimit: s, gasUsed: r, hash: a, miner: o, prevRandao: c, nonce: l, number: h, parentHash: u, parentBeaconBlockRoot: d, stateRoot: f, receiptsRoot: m, timestamp: A, transactions: g } = this;+ return {+ _type: "Block",+ baseFeePerGas: jt(e),+ difficulty: jt(t),+ extraData: n,+ gasLimit: jt(s),+ gasUsed: jt(r),+ blobGasUsed: jt(this.blobGasUsed),+ excessBlobGas: jt(this.excessBlobGas),+ hash: a,+ miner: o,+ prevRandao: c,+ nonce: l,+ number: h,+ parentHash: u,+ timestamp: A,+ parentBeaconBlockRoot: d,+ stateRoot: f,+ receiptsRoot: m,+ transactions: g+ };+ }+ [Symbol.iterator]() {+ let e = 0;+ const t = this.transactions;+ return {+ next: () => e < this.length ? {+ value: t[e++],+ done: !1+ } : { value: void 0, done: !0 }+ };+ }+ /**+ * The number of transactions in this block.+ */+ get length() {+ return this.#e.length;+ }+ /**+ * The [[link-js-date]] this block was included at.+ */+ get date() {+ return this.timestamp == null ? null : new Date(this.timestamp * 1e3);+ }+ /**+ * Get the transaction at %%indexe%% within this block.+ */+ async getTransaction(e) {+ let t;+ if (typeof e == "number")+ t = this.#e[e];+ else {+ const n = e.toLowerCase();+ for (const s of this.#e)+ if (typeof s == "string") {+ if (s !== n)+ continue;+ t = s;+ break;+ } else {+ if (s.hash !== n)+ continue;+ t = s;+ break;+ }+ }+ if (t == null)+ throw new Error("no such tx");+ return typeof t == "string" ? await this.provider.getTransaction(t) : t;+ }+ /**+ * If a **Block** was fetched with a request to include the transactions+ * this will allow synchronous access to those transactions.+ *+ * If the transactions were not prefetched, this will throw.+ */+ getPrefetchedTransaction(e) {+ const t = this.prefetchedTransactions;+ if (typeof e == "number")+ return t[e];+ e = e.toLowerCase();+ for (const n of t)+ if (n.hash === e)+ return n;+ V(!1, "no matching transaction", "indexOrHash", e);+ }+ /**+ * Returns true if this block been mined. This provides a type guard+ * for all properties on a [[MinedBlock]].+ */+ isMined() {+ return !!this.hash;+ }+ /**+ * Returns true if this block is an [[link-eip-2930]] block.+ */+ isLondon() {+ return !!this.baseFeePerGas;+ }+ /**+ * @_ignore:+ */+ orphanedEvent() {+ if (!this.isMined())+ throw new Error("");+ return ND(this);+ }+}+class rc {+ /**+ * The provider connected to the log used to fetch additional details+ * if necessary.+ */+ provider;+ /**+ * The transaction hash of the transaction this log occurred in. Use the+ * [[Log-getTransaction]] to get the [[TransactionResponse]].+ */+ transactionHash;+ /**+ * The block hash of the block this log occurred in. Use the+ * [[Log-getBlock]] to get the [[Block]].+ */+ blockHash;+ /**+ * The block number of the block this log occurred in. It is preferred+ * to use the [[Block-hash]] when fetching the related [[Block]],+ * since in the case of an orphaned block, the block at that height may+ * have changed.+ */+ blockNumber;+ /**+ * If the **Log** represents a block that was removed due to an orphaned+ * block, this will be true.+ *+ * This can only happen within an orphan event listener.+ */+ removed;+ /**+ * The address of the contract that emitted this log.+ */+ address;+ /**+ * The data included in this log when it was emitted.+ */+ data;+ /**+ * The indexed topics included in this log when it was emitted.+ *+ * All topics are included in the bloom filters, so they can be+ * efficiently filtered using the [[Provider-getLogs]] method.+ */+ topics;+ /**+ * The index within the block this log occurred at. This is generally+ * not useful to developers, but can be used with the various roots+ * to proof inclusion within a block.+ */+ index;+ /**+ * The index within the transaction of this log.+ */+ transactionIndex;+ /**+ * @_ignore:+ */+ constructor(e, t) {+ this.provider = t;+ const n = Object.freeze(e.topics.slice());+ Xe(this, {+ transactionHash: e.transactionHash,+ blockHash: e.blockHash,+ blockNumber: e.blockNumber,+ removed: e.removed,+ address: e.address,+ data: e.data,+ topics: n,+ index: e.index,+ transactionIndex: e.transactionIndex+ });+ }+ /**+ * Returns a JSON-compatible object.+ */+ toJSON() {+ const { address: e, blockHash: t, blockNumber: n, data: s, index: r, removed: a, topics: o, transactionHash: c, transactionIndex: l } = this;+ return {+ _type: "log",+ address: e,+ blockHash: t,+ blockNumber: n,+ data: s,+ index: r,+ removed: a,+ topics: o,+ transactionHash: c,+ transactionIndex: l+ };+ }+ /**+ * Returns the block that this log occurred in.+ */+ async getBlock() {+ const e = await this.provider.getBlock(this.blockHash);+ return ge(!!e, "failed to find transaction", "UNKNOWN_ERROR", {}), e;+ }+ /**+ * Returns the transaction that this log occurred in.+ */+ async getTransaction() {+ const e = await this.provider.getTransaction(this.transactionHash);+ return ge(!!e, "failed to find transaction", "UNKNOWN_ERROR", {}), e;+ }+ /**+ * Returns the transaction receipt fot the transaction that this+ * log occurred in.+ */+ async getTransactionReceipt() {+ const e = await this.provider.getTransactionReceipt(this.transactionHash);+ return ge(!!e, "failed to find transaction receipt", "UNKNOWN_ERROR", {}), e;+ }+ /**+ * @_ignore:+ */+ removedEvent() {+ return FD(this);+ }+}+class Qx {+ /**+ * The provider connected to the log used to fetch additional details+ * if necessary.+ */+ provider;+ /**+ * The address the transaction was sent to.+ */+ to;+ /**+ * The sender of the transaction.+ */+ from;+ /**+ * The address of the contract if the transaction was directly+ * responsible for deploying one.+ *+ * This is non-null **only** if the ``to`` is empty and the ``data``+ * was successfully executed as initcode.+ */+ contractAddress;+ /**+ * The transaction hash.+ */+ hash;+ /**+ * The index of this transaction within the block transactions.+ */+ index;+ /**+ * The block hash of the [[Block]] this transaction was included in.+ */+ blockHash;+ /**+ * The block number of the [[Block]] this transaction was included in.+ */+ blockNumber;+ /**+ * The bloom filter bytes that represent all logs that occurred within+ * this transaction. This is generally not useful for most developers,+ * but can be used to validate the included logs.+ */+ logsBloom;+ /**+ * The actual amount of gas used by this transaction.+ *+ * When creating a transaction, the amount of gas that will be used can+ * only be approximated, but the sender must pay the gas fee for the+ * entire gas limit. After the transaction, the difference is refunded.+ */+ gasUsed;+ /**+ * The gas used for BLObs. See [[link-eip-4844]].+ */+ blobGasUsed;+ /**+ * The amount of gas used by all transactions within the block for this+ * and all transactions with a lower ``index``.+ *+ * This is generally not useful for developers but can be used to+ * validate certain aspects of execution.+ */+ cumulativeGasUsed;+ /**+ * The actual gas price used during execution.+ *+ * Due to the complexity of [[link-eip-1559]] this value can only+ * be caluclated after the transaction has been mined, snce the base+ * fee is protocol-enforced.+ */+ gasPrice;+ /**+ * The price paid per BLOB in gas. See [[link-eip-4844]].+ */+ blobGasPrice;+ /**+ * The [[link-eip-2718]] transaction type.+ */+ type;+ //readonly byzantium!: boolean;+ /**+ * The status of this transaction, indicating success (i.e. ``1``) or+ * a revert (i.e. ``0``).+ *+ * This is available in post-byzantium blocks, but some backends may+ * backfill this value.+ */+ status;+ /**+ * The root hash of this transaction.+ *+ * This is no present and was only included in pre-byzantium blocks, but+ * could be used to validate certain parts of the receipt.+ */+ root;+ #e;+ /**+ * @_ignore:+ */+ constructor(e, t) {+ this.#e = Object.freeze(e.logs.map((s) => new rc(s, t)));+ let n = Ox;+ e.effectiveGasPrice != null ? n = e.effectiveGasPrice : e.gasPrice != null && (n = e.gasPrice), Xe(this, {+ provider: t,+ to: e.to,+ from: e.from,+ contractAddress: e.contractAddress,+ hash: e.hash,+ index: e.index,+ blockHash: e.blockHash,+ blockNumber: e.blockNumber,+ logsBloom: e.logsBloom,+ gasUsed: e.gasUsed,+ cumulativeGasUsed: e.cumulativeGasUsed,+ blobGasUsed: e.blobGasUsed,+ gasPrice: n,+ blobGasPrice: e.blobGasPrice,+ type: e.type,+ //byzantium: tx.byzantium,+ status: e.status,+ root: e.root+ });+ }+ /**+ * The logs for this transaction.+ */+ get logs() {+ return this.#e;+ }+ /**+ * Returns a JSON-compatible representation.+ */+ toJSON() {+ const {+ to: e,+ from: t,+ contractAddress: n,+ hash: s,+ index: r,+ blockHash: a,+ blockNumber: o,+ logsBloom: c,+ logs: l,+ //byzantium,+ status: h,+ root: u+ } = this;+ return {+ _type: "TransactionReceipt",+ blockHash: a,+ blockNumber: o,+ //byzantium,+ contractAddress: n,+ cumulativeGasUsed: jt(this.cumulativeGasUsed),+ from: t,+ gasPrice: jt(this.gasPrice),+ blobGasUsed: jt(this.blobGasUsed),+ blobGasPrice: jt(this.blobGasPrice),+ gasUsed: jt(this.gasUsed),+ hash: s,+ index: r,+ logs: l,+ logsBloom: c,+ root: u,+ status: h,+ to: e+ };+ }+ /**+ * @_ignore:+ */+ get length() {+ return this.logs.length;+ }+ [Symbol.iterator]() {+ let e = 0;+ return {+ next: () => e < this.length ? { value: this.logs[e++], done: !1 } : { value: void 0, done: !0 }+ };+ }+ /**+ * The total fee for this transaction, in wei.+ */+ get fee() {+ return this.gasUsed * this.gasPrice;+ }+ /**+ * Resolves to the block this transaction occurred in.+ */+ async getBlock() {+ const e = await this.provider.getBlock(this.blockHash);+ if (e == null)+ throw new Error("TODO");+ return e;+ }+ /**+ * Resolves to the transaction this transaction occurred in.+ */+ async getTransaction() {+ const e = await this.provider.getTransaction(this.hash);+ if (e == null)+ throw new Error("TODO");+ return e;+ }+ /**+ * Resolves to the return value of the execution of this transaction.+ *+ * Support for this feature is limited, as it requires an archive node+ * with the ``debug_`` or ``trace_`` API enabled.+ */+ async getResult() {+ return await this.provider.getTransactionResult(this.hash);+ }+ /**+ * Resolves to the number of confirmations this transaction has.+ */+ async confirmations() {+ return await this.provider.getBlockNumber() - this.blockNumber + 1;+ }+ /**+ * @_ignore:+ */+ removedEvent() {+ return Hx(this);+ }+ /**+ * @_ignore:+ */+ reorderedEvent(e) {+ return ge(!e || e.isMined(), "unmined 'other' transction cannot be orphaned", "UNSUPPORTED_OPERATION", { operation: "reorderedEvent(other)" }), Gx(this, e);+ }+}+class ac {+ /**+ * The provider this is connected to, which will influence how its+ * methods will resolve its async inspection methods.+ */+ provider;+ /**+ * The block number of the block that this transaction was included in.+ *+ * This is ``null`` for pending transactions.+ */+ blockNumber;+ /**+ * The blockHash of the block that this transaction was included in.+ *+ * This is ``null`` for pending transactions.+ */+ blockHash;+ /**+ * The index within the block that this transaction resides at.+ */+ index;+ /**+ * The transaction hash.+ */+ hash;+ /**+ * The [[link-eip-2718]] transaction envelope type. This is+ * ``0`` for legacy transactions types.+ */+ type;+ /**+ * The receiver of this transaction.+ *+ * If ``null``, then the transaction is an initcode transaction.+ * This means the result of executing the [[data]] will be deployed+ * as a new contract on chain (assuming it does not revert) and the+ * address may be computed using [[getCreateAddress]].+ */+ to;+ /**+ * The sender of this transaction. It is implicitly computed+ * from the transaction pre-image hash (as the digest) and the+ * [[signature]] using ecrecover.+ */+ from;+ /**+ * The nonce, which is used to prevent replay attacks and offer+ * a method to ensure transactions from a given sender are explicitly+ * ordered.+ *+ * When sending a transaction, this must be equal to the number of+ * transactions ever sent by [[from]].+ */+ nonce;+ /**+ * The maximum units of gas this transaction can consume. If execution+ * exceeds this, the entries transaction is reverted and the sender+ * is charged for the full amount, despite not state changes being made.+ */+ gasLimit;+ /**+ * The gas price can have various values, depending on the network.+ *+ * In modern networks, for transactions that are included this is+ * the //effective gas price// (the fee per gas that was actually+ * charged), while for transactions that have not been included yet+ * is the [[maxFeePerGas]].+ *+ * For legacy transactions, or transactions on legacy networks, this+ * is the fee that will be charged per unit of gas the transaction+ * consumes.+ */+ gasPrice;+ /**+ * The maximum priority fee (per unit of gas) to allow a+ * validator to charge the sender. This is inclusive of the+ * [[maxFeeFeePerGas]].+ */+ maxPriorityFeePerGas;+ /**+ * The maximum fee (per unit of gas) to allow this transaction+ * to charge the sender.+ */+ maxFeePerGas;+ /**+ * The [[link-eip-4844]] max fee per BLOb gas.+ */+ maxFeePerBlobGas;+ /**+ * The data.+ */+ data;+ /**+ * The value, in wei. Use [[formatEther]] to format this value+ * as ether.+ */+ value;+ /**+ * The chain ID.+ */+ chainId;+ /**+ * The signature.+ */+ signature;+ /**+ * The [[link-eip-2930]] access list for transaction types that+ * support it, otherwise ``null``.+ */+ accessList;+ /**+ * The [[link-eip-4844]] BLOb versioned hashes.+ */+ blobVersionedHashes;+ /**+ * The [[link-eip-7702]] authorizations (if any).+ */+ authorizationList;+ #e;+ /**+ * @_ignore:+ */+ constructor(e, t) {+ this.provider = t, this.blockNumber = e.blockNumber != null ? e.blockNumber : null, this.blockHash = e.blockHash != null ? e.blockHash : null, this.hash = e.hash, this.index = e.index, this.type = e.type, this.from = e.from, this.to = e.to || null, this.gasLimit = e.gasLimit, this.nonce = e.nonce, this.data = e.data, this.value = e.value, this.gasPrice = e.gasPrice, this.maxPriorityFeePerGas = e.maxPriorityFeePerGas != null ? e.maxPriorityFeePerGas : null, this.maxFeePerGas = e.maxFeePerGas != null ? e.maxFeePerGas : null, this.maxFeePerBlobGas = e.maxFeePerBlobGas != null ? e.maxFeePerBlobGas : null, this.chainId = e.chainId, this.signature = e.signature, this.accessList = e.accessList != null ? e.accessList : null, this.blobVersionedHashes = e.blobVersionedHashes != null ? e.blobVersionedHashes : null, this.authorizationList = e.authorizationList != null ? e.authorizationList : null, this.#e = -1;+ }+ /**+ * Returns a JSON-compatible representation of this transaction.+ */+ toJSON() {+ const { blockNumber: e, blockHash: t, index: n, hash: s, type: r, to: a, from: o, nonce: c, data: l, signature: h, accessList: u, blobVersionedHashes: d } = this;+ return {+ _type: "TransactionResponse",+ accessList: u,+ blockNumber: e,+ blockHash: t,+ blobVersionedHashes: d,+ chainId: jt(this.chainId),+ data: l,+ from: o,+ gasLimit: jt(this.gasLimit),+ gasPrice: jt(this.gasPrice),+ hash: s,+ maxFeePerGas: jt(this.maxFeePerGas),+ maxPriorityFeePerGas: jt(this.maxPriorityFeePerGas),+ maxFeePerBlobGas: jt(this.maxFeePerBlobGas),+ nonce: c,+ signature: h,+ to: a,+ index: n,+ type: r,+ value: jt(this.value)+ };+ }+ /**+ * Resolves to the Block that this transaction was included in.+ *+ * This will return null if the transaction has not been included yet.+ */+ async getBlock() {+ let e = this.blockNumber;+ if (e == null) {+ const n = await this.getTransaction();+ n && (e = n.blockNumber);+ }+ if (e == null)+ return null;+ const t = this.provider.getBlock(e);+ if (t == null)+ throw new Error("TODO");+ return t;+ }+ /**+ * Resolves to this transaction being re-requested from the+ * provider. This can be used if you have an unmined transaction+ * and wish to get an up-to-date populated instance.+ */+ async getTransaction() {+ return this.provider.getTransaction(this.hash);+ }+ /**+ * Resolve to the number of confirmations this transaction has.+ */+ async confirmations() {+ if (this.blockNumber == null) {+ const { tx: t, blockNumber: n } = await Tn({+ tx: this.getTransaction(),+ blockNumber: this.provider.getBlockNumber()+ });+ return t == null || t.blockNumber == null ? 0 : n - t.blockNumber + 1;+ }+ return await this.provider.getBlockNumber() - this.blockNumber + 1;+ }+ /**+ * Resolves once this transaction has been mined and has+ * %%confirms%% blocks including it (default: ``1``) with an+ * optional %%timeout%%.+ *+ * This can resolve to ``null`` only if %%confirms%% is ``0``+ * and the transaction has not been mined, otherwise this will+ * wait until enough confirmations have completed.+ */+ async wait(e, t) {+ const n = e ?? 1, s = t ?? 0;+ let r = this.#e, a = -1, o = r === -1;+ const c = async () => {+ if (o)+ return null;+ const { blockNumber: d, nonce: f } = await Tn({+ blockNumber: this.provider.getBlockNumber(),+ nonce: this.provider.getTransactionCount(this.from)+ });+ if (f < this.nonce) {+ r = d;+ return;+ }+ if (o)+ return null;+ const m = await this.getTransaction();+ if (!(m && m.blockNumber != null))+ for (a === -1 && (a = r - 3, a < this.#e && (a = this.#e)); a <= d; ) {+ if (o)+ return null;+ const A = await this.provider.getBlock(a, !0);+ if (A == null)+ return;+ for (const g of A)+ if (g === this.hash)+ return;+ for (let g = 0; g < A.length; g++) {+ const p = await A.getTransaction(g);+ if (p.from === this.from && p.nonce === this.nonce) {+ if (o)+ return null;+ const y = await this.provider.getTransactionReceipt(p.hash);+ if (y == null || d - y.blockNumber + 1 < n)+ return;+ let b = "replaced";+ p.data === this.data && p.to === this.to && p.value === this.value ? b = "repriced" : p.data === "0x" && p.from === p.to && p.value === Ox && (b = "cancelled"), ge(!1, "transaction was replaced", "TRANSACTION_REPLACED", {+ cancelled: b === "replaced" || b === "cancelled",+ reason: b,+ replacement: p.replaceableTransaction(r),+ hash: p.hash,+ receipt: y+ });+ }+ }+ a++;+ }+ }, l = (d) => {+ if (d == null || d.status !== 0)+ return d;+ ge(!1, "transaction execution reverted", "CALL_EXCEPTION", {+ action: "sendTransaction",+ data: null,+ reason: null,+ invocation: null,+ revert: null,+ transaction: {+ to: d.to,+ from: d.from,+ data: ""+ // @TODO: in v7, split out sendTransaction properties+ },+ receipt: d+ });+ }, h = await this.provider.getTransactionReceipt(this.hash);+ if (n === 0)+ return l(h);+ if (h) {+ if (n === 1 || await h.confirmations() >= n)+ return l(h);+ } else if (await c(), n === 0)+ return null;+ return await new Promise((d, f) => {+ const m = [], A = () => {+ m.forEach((p) => p());+ };+ if (m.push(() => {+ o = !0;+ }), s > 0) {+ const p = setTimeout(() => {+ A(), f(Ot("wait for transaction timeout", "TIMEOUT"));+ }, s);+ m.push(() => {+ clearTimeout(p);+ });+ }+ const g = async (p) => {+ if (await p.confirmations() >= n) {+ A();+ try {+ d(l(p));+ } catch (y) {+ f(y);+ }+ }+ };+ if (m.push(() => {+ this.provider.off(this.hash, g);+ }), this.provider.on(this.hash, g), r >= 0) {+ const p = async () => {+ try {+ await c();+ } catch (y) {+ if (_n(y, "TRANSACTION_REPLACED")) {+ A(), f(y);+ return;+ }+ }+ o || this.provider.once("block", p);+ };+ m.push(() => {+ this.provider.off("block", p);+ }), this.provider.once("block", p);+ }+ });+ }+ /**+ * Returns ``true`` if this transaction has been included.+ *+ * This is effective only as of the time the TransactionResponse+ * was instantiated. To get up-to-date information, use+ * [[getTransaction]].+ *+ * This provides a Type Guard that this transaction will have+ * non-null property values for properties that are null for+ * unmined transactions.+ */+ isMined() {+ return this.blockHash != null;+ }+ /**+ * Returns true if the transaction is a legacy (i.e. ``type == 0``)+ * transaction.+ *+ * This provides a Type Guard that this transaction will have+ * the ``null``-ness for hardfork-specific properties set correctly.+ */+ isLegacy() {+ return this.type === 0;+ }+ /**+ * Returns true if the transaction is a Berlin (i.e. ``type == 1``)+ * transaction. See [[link-eip-2070]].+ *+ * This provides a Type Guard that this transaction will have+ * the ``null``-ness for hardfork-specific properties set correctly.+ */+ isBerlin() {+ return this.type === 1;+ }+ /**+ * Returns true if the transaction is a London (i.e. ``type == 2``)+ * transaction. See [[link-eip-1559]].+ *+ * This provides a Type Guard that this transaction will have+ * the ``null``-ness for hardfork-specific properties set correctly.+ */+ isLondon() {+ return this.type === 2;+ }+ /**+ * Returns true if hte transaction is a Cancun (i.e. ``type == 3``)+ * transaction. See [[link-eip-4844]].+ */+ isCancun() {+ return this.type === 3;+ }+ /**+ * Returns a filter which can be used to listen for orphan events+ * that evict this transaction.+ */+ removedEvent() {+ return ge(this.isMined(), "unmined transaction canot be orphaned", "UNSUPPORTED_OPERATION", { operation: "removeEvent()" }), Hx(this);+ }+ /**+ * Returns a filter which can be used to listen for orphan events+ * that re-order this event against %%other%%.+ */+ reorderedEvent(e) {+ return ge(this.isMined(), "unmined transaction canot be orphaned", "UNSUPPORTED_OPERATION", { operation: "removeEvent()" }), ge(!e || e.isMined(), "unmined 'other' transaction canot be orphaned", "UNSUPPORTED_OPERATION", { operation: "removeEvent()" }), Gx(this, e);+ }+ /**+ * Returns a new TransactionResponse instance which has the ability to+ * detect (and throw an error) if the transaction is replaced, which+ * will begin scanning at %%startBlock%%.+ *+ * This should generally not be used by developers and is intended+ * primarily for internal use. Setting an incorrect %%startBlock%% can+ * have devastating performance consequences if used incorrectly.+ */+ replaceableTransaction(e) {+ V(Number.isInteger(e) && e >= 0, "invalid startBlock", "startBlock", e);+ const t = new ac(this, this.provider);+ return t.#e = e, t;+ }+}+function ND(i) {+ return { orphan: "drop-block", hash: i.hash, number: i.number };+}+function Gx(i, e) {+ return { orphan: "reorder-transaction", tx: i, other: e };+}+function Hx(i) {+ return { orphan: "drop-transaction", tx: i };+}+function FD(i) {+ return { orphan: "drop-log", log: {+ transactionHash: i.transactionHash,+ blockHash: i.blockHash,+ blockNumber: i.blockNumber,+ address: i.address,+ data: i.data,+ topics: Object.freeze(i.topics.slice()),+ index: i.index+ } };+}+class rp extends rc {+ /**+ * The Contract Interface.+ */+ interface;+ /**+ * The matching event.+ */+ fragment;+ /**+ * The parsed arguments passed to the event by ``emit``.+ */+ args;+ /**+ * @_ignore:+ */+ constructor(e, t, n) {+ super(e, e.provider);+ const s = t.decodeEventLog(n, e.data, e.topics);+ Xe(this, { args: s, fragment: n, interface: t });+ }+ /**+ * The name of the event.+ */+ get eventName() {+ return this.fragment.name;+ }+ /**+ * The signature of the event.+ */+ get eventSignature() {+ return this.fragment.format();+ }+}+class zx extends rc {+ /**+ * The error encounted when trying to decode the log.+ */+ error;+ /**+ * @_ignore:+ */+ constructor(e, t) {+ super(e, e.provider), Xe(this, { error: t });+ }+}+class DD extends Qx {+ #e;+ /**+ * @_ignore:+ */+ constructor(e, t, n) {+ super(n, t), this.#e = e;+ }+ /**+ * The parsed logs for any [[Log]] which has a matching event in the+ * Contract ABI.+ */+ get logs() {+ return super.logs.map((e) => {+ const t = e.topics.length ? this.#e.getEvent(e.topics[0]) : null;+ if (t)+ try {+ return new rp(e, this.#e, t);+ } catch (n) {+ return new zx(e, n);+ }+ return e;+ });+ }+}+class ap extends ac {+ #e;+ /**+ * @_ignore:+ */+ constructor(e, t, n) {+ super(n, t), this.#e = e;+ }+ /**+ * Resolves once this transaction has been mined and has+ * %%confirms%% blocks including it (default: ``1``) with an+ * optional %%timeout%%.+ *+ * This can resolve to ``null`` only if %%confirms%% is ``0``+ * and the transaction has not been mined, otherwise this will+ * wait until enough confirmations have completed.+ */+ async wait(e, t) {+ const n = await super.wait(e, t);+ return n == null ? null : new DD(this.#e, this.provider, n);+ }+}+class Vx extends xb {+ /**+ * The log with no matching events.+ */+ log;+ /**+ * @_event:+ */+ constructor(e, t, n, s) {+ super(e, t, n), Xe(this, { log: s });+ }+ /**+ * Resolves to the block the event occured in.+ */+ async getBlock() {+ return await this.log.getBlock();+ }+ /**+ * Resolves to the transaction the event occured in.+ */+ async getTransaction() {+ return await this.log.getTransaction();+ }+ /**+ * Resolves to the transaction receipt the event occured in.+ */+ async getTransactionReceipt() {+ return await this.log.getTransactionReceipt();+ }+}+class LD extends Vx {+ /**+ * @_ignore:+ */+ constructor(e, t, n, s, r) {+ super(e, t, n, new rp(r, e.interface, s));+ const a = e.interface.decodeEventLog(s, this.log.data, this.log.topics);+ Xe(this, { args: a, fragment: s });+ }+ /**+ * The event name.+ */+ get eventName() {+ return this.fragment.name;+ }+ /**+ * The event signature.+ */+ get eventSignature() {+ return this.fragment.format();+ }+}+const ym = BigInt(0);+function Wx(i) {+ return i && typeof i.call == "function";+}+function qx(i) {+ return i && typeof i.estimateGas == "function";+}+function ph(i) {+ return i && typeof i.resolveName == "function";+}+function Kx(i) {+ return i && typeof i.sendTransaction == "function";+}+function jx(i) {+ if (i != null) {+ if (ph(i))+ return i;+ if (i.provider)+ return i.provider;+ }+}+class PD {+ #e;+ fragment;+ constructor(e, t, n) {+ if (Xe(this, { fragment: t }), t.inputs.length < n.length)+ throw new Error("too many arguments");+ const s = Br(e.runner, "resolveName"), r = ph(s) ? s : null;+ this.#e = (async function() {+ const a = await Promise.all(t.inputs.map((o, c) => n[c] == null ? null : o.walkAsync(n[c], (h, u) => h === "address" ? Array.isArray(u) ? Promise.all(u.map((d) => Dn(d, r))) : Dn(u, r) : u)));+ return e.interface.encodeFilterTopics(t, a);+ })();+ }+ getTopicFilter() {+ return this.#e;+ }+}+function Br(i, e) {+ return i == null ? null : typeof i[e] == "function" ? i : i.provider && typeof i.provider[e] == "function" ? i.provider : null;+}+function mr(i) {+ return i == null ? null : i.provider || null;+}+async function Xx(i, e) {+ const t = Wt.dereference(i, "overrides");+ V(typeof t == "object", "invalid overrides parameter", "overrides", i);+ const n = ql(t);+ return V(n.to == null || (e || []).indexOf("to") >= 0, "cannot override to", "overrides.to", n.to), V(n.data == null || (e || []).indexOf("data") >= 0, "cannot override data", "overrides.data", n.data), n.from && (n.from = n.from), n;+}+async function kD(i, e, t) {+ const n = Br(i, "resolveName"), s = ph(n) ? n : null;+ return await Promise.all(e.map((r, a) => r.walkAsync(t[a], (o, c) => (c = Wt.dereference(c, o), o === "address" ? Dn(c, s) : c))));+}+function UD(i) {+ const e = async function(a) {+ const o = await Xx(a, ["data"]);+ o.to = await i.getAddress(), o.from && (o.from = await Dn(o.from, jx(i.runner)));+ const c = i.interface, l = Fe(o.value || ym, "overrides.value") === ym, h = (o.data || "0x") === "0x";+ c.fallback && !c.fallback.payable && c.receive && !h && !l && V(!1, "cannot send data to receive or send value to non-payable fallback", "overrides", a), V(c.fallback || h, "cannot send data to receive-only contract", "overrides.data", o.data);+ const u = c.receive || c.fallback && c.fallback.payable;+ return V(u || l, "cannot send value to non-payable fallback", "overrides.value", o.value), V(c.fallback || h, "cannot send data to receive-only contract", "overrides.data", o.data), o;+ }, t = async function(a) {+ const o = Br(i.runner, "call");+ ge(Wx(o), "contract runner does not support calling", "UNSUPPORTED_OPERATION", { operation: "call" });+ const c = await e(a);+ try {+ return await o.call(c);+ } catch (l) {+ throw zf(l) && l.data ? i.interface.makeError(l.data, c) : l;+ }+ }, n = async function(a) {+ const o = i.runner;+ ge(Kx(o), "contract runner does not support sending transactions", "UNSUPPORTED_OPERATION", { operation: "sendTransaction" });+ const c = await o.sendTransaction(await e(a)), l = mr(i.runner);+ return new ap(i.interface, l, c);+ }, s = async function(a) {+ const o = Br(i.runner, "estimateGas");+ return ge(qx(o), "contract runner does not support gas estimation", "UNSUPPORTED_OPERATION", { operation: "estimateGas" }), await o.estimateGas(await e(a));+ }, r = async (a) => await n(a);+ return Xe(r, {+ _contract: i,+ estimateGas: s,+ populateTransaction: e,+ send: n,+ staticCall: t+ }), r;+}+function OD(i, e) {+ const t = function(...l) {+ const h = i.interface.getFunction(e, l);+ return ge(h, "no matching fragment", "UNSUPPORTED_OPERATION", {+ operation: "fragment",+ info: { key: e, args: l }+ }), h;+ }, n = async function(...l) {+ const h = t(...l);+ let u = {};+ if (h.inputs.length + 1 === l.length && (u = await Xx(l.pop()), u.from && (u.from = await Dn(u.from, jx(i.runner)))), h.inputs.length !== l.length)+ throw new Error("internal error: fragment inputs doesn't match arguments; should not happen");+ const d = await kD(i.runner, h.inputs, l);+ return Object.assign({}, u, await Tn({+ to: i.getAddress(),+ data: i.interface.encodeFunctionData(h, d)+ }));+ }, s = async function(...l) {+ const h = await o(...l);+ return h.length === 1 ? h[0] : h;+ }, r = async function(...l) {+ const h = i.runner;+ ge(Kx(h), "contract runner does not support sending transactions", "UNSUPPORTED_OPERATION", { operation: "sendTransaction" });+ const u = await h.sendTransaction(await n(...l)), d = mr(i.runner);+ return new ap(i.interface, d, u);+ }, a = async function(...l) {+ const h = Br(i.runner, "estimateGas");+ return ge(qx(h), "contract runner does not support gas estimation", "UNSUPPORTED_OPERATION", { operation: "estimateGas" }), await h.estimateGas(await n(...l));+ }, o = async function(...l) {+ const h = Br(i.runner, "call");+ ge(Wx(h), "contract runner does not support calling", "UNSUPPORTED_OPERATION", { operation: "call" });+ const u = await n(...l);+ let d = "0x";+ try {+ d = await h.call(u);+ } catch (m) {+ throw zf(m) && m.data ? i.interface.makeError(m.data, u) : m;+ }+ const f = t(...l);+ return i.interface.decodeFunctionResult(f, d);+ }, c = async (...l) => t(...l).constant ? await s(...l) : await r(...l);+ return Xe(c, {+ name: i.interface.getFunctionName(e),+ _contract: i,+ _key: e,+ getFragment: t,+ estimateGas: a,+ populateTransaction: n,+ send: r,+ staticCall: s,+ staticCallResult: o+ }), Object.defineProperty(c, "fragment", {+ configurable: !1,+ enumerable: !0,+ get: () => {+ const l = i.interface.getFunction(e);+ return ge(l, "no matching fragment", "UNSUPPORTED_OPERATION", {+ operation: "fragment",+ info: { key: e }+ }), l;+ }+ }), c;+}+function QD(i, e) {+ const t = function(...s) {+ const r = i.interface.getEvent(e, s);+ return ge(r, "no matching fragment", "UNSUPPORTED_OPERATION", {+ operation: "fragment",+ info: { key: e, args: s }+ }), r;+ }, n = function(...s) {+ return new PD(i, t(...s), s);+ };+ return Xe(n, {+ name: i.interface.getEventName(e),+ _contract: i,+ _key: e,+ getFragment: t+ }), Object.defineProperty(n, "fragment", {+ configurable: !1,+ enumerable: !0,+ get: () => {+ const s = i.interface.getEvent(e);+ return ge(s, "no matching fragment", "UNSUPPORTED_OPERATION", {+ operation: "fragment",+ info: { key: e }+ }), s;+ }+ }), n;+}+const Kl = /* @__PURE__ */ Symbol.for("_ethersInternal_contract"), Yx = /* @__PURE__ */ new WeakMap();+function GD(i, e) {+ Yx.set(i[Kl], e);+}+function jn(i) {+ return Yx.get(i[Kl]);+}+function HD(i) {+ return i && typeof i == "object" && "getTopicFilter" in i && typeof i.getTopicFilter == "function" && i.fragment;+}+async function op(i, e) {+ let t, n = null;+ if (Array.isArray(e)) {+ const r = function(a) {+ if (Lt(a, 32))+ return a;+ const o = i.interface.getEvent(a);+ return V(o, "unknown fragment", "name", a), o.topicHash;+ };+ t = e.map((a) => a == null ? null : Array.isArray(a) ? a.map(r) : r(a));+ } else e === "*" ? t = [null] : typeof e == "string" ? Lt(e, 32) ? t = [e] : (n = i.interface.getEvent(e), V(n, "unknown fragment", "event", e), t = [n.topicHash]) : HD(e) ? t = await e.getTopicFilter() : "fragment" in e ? (n = e.fragment, t = [n.topicHash]) : V(!1, "unknown event name", "event", e);+ t = t.map((r) => {+ if (r == null)+ return null;+ if (Array.isArray(r)) {+ const a = Array.from(new Set(r.map((o) => o.toLowerCase())).values());+ return a.length === 1 ? a[0] : (a.sort(), a);+ }+ return r.toLowerCase();+ });+ const s = t.map((r) => r == null ? "null" : Array.isArray(r) ? r.join("|") : r).join("&");+ return { fragment: n, tag: s, topics: t };+}+async function bo(i, e) {+ const { subs: t } = jn(i);+ return t.get((await op(i, e)).tag) || null;+}+async function wm(i, e, t) {+ const n = mr(i.runner);+ ge(n, "contract runner does not support subscribing", "UNSUPPORTED_OPERATION", { operation: e });+ const { fragment: s, tag: r, topics: a } = await op(i, t), { addr: o, subs: c } = jn(i);+ let l = c.get(r);+ if (!l) {+ const u = { address: o || i, topics: a }, d = (g) => {+ let p = s;+ if (p == null)+ try {+ p = i.interface.getEvent(g.topics[0]);+ } catch {+ }+ if (p) {+ const y = p, b = s ? i.interface.decodeEventLog(s, g.data, g.topics) : [];+ nf(i, t, b, (E) => new LD(i, E, t, y, g));+ } else+ nf(i, t, [], (y) => new Vx(i, y, t, g));+ };+ let f = [];+ l = { tag: r, listeners: [], start: () => {+ f.length || f.push(n.on(u, d));+ }, stop: async () => {+ if (f.length == 0)+ return;+ let g = f;+ f = [], await Promise.all(g), n.off(u, d);+ } }, c.set(r, l);+ }+ return l;+}+let tf = Promise.resolve();+async function zD(i, e, t, n) {+ await tf;+ const s = await bo(i, e);+ if (!s)+ return !1;+ const r = s.listeners.length;+ return s.listeners = s.listeners.filter(({ listener: a, once: o }) => {+ const c = Array.from(t);+ n && c.push(n(o ? null : a));+ try {+ a.call(i, ...c);+ } catch {+ }+ return !o;+ }), s.listeners.length === 0 && (s.stop(), jn(i).subs.delete(s.tag)), r > 0;+}+async function nf(i, e, t, n) {+ try {+ await tf;+ } catch {+ }+ const s = zD(i, e, t, n);+ return tf = s, await s;+}+const ol = ["then"];+class Bo {+ /**+ * The target to connect to.+ *+ * This can be an address, ENS name or any [[Addressable]], such as+ * another contract. To get the resolved address, use the ``getAddress``+ * method.+ */+ target;+ /**+ * The contract Interface.+ */+ interface;+ /**+ * The connected runner. This is generally a [[Provider]] or a+ * [[Signer]], which dictates what operations are supported.+ *+ * For example, a **Contract** connected to a [[Provider]] may+ * only execute read-only operations.+ */+ runner;+ /**+ * All the Events available on this contract.+ */+ filters;+ /**+ * @_ignore:+ */+ [Kl];+ /**+ * The fallback or receive function if any.+ */+ fallback;+ /**+ * Creates a new contract connected to %%target%% with the %%abi%% and+ * optionally connected to a %%runner%% to perform operations on behalf+ * of.+ */+ constructor(e, t, n, s) {+ V(typeof e == "string" || nx(e), "invalid value for Contract target", "target", e), n == null && (n = null);+ const r = hr.from(t);+ Xe(this, { target: e, runner: n, interface: r }), Object.defineProperty(this, Kl, { value: {} });+ let a, o = null, c = null;+ if (s) {+ const u = mr(n);+ c = new ap(this.interface, u, s);+ }+ let l = /* @__PURE__ */ new Map();+ if (typeof e == "string")+ if (Lt(e))+ o = e, a = Promise.resolve(e);+ else {+ const u = Br(n, "resolveName");+ if (!ph(u))+ throw Ot("contract runner does not support name resolution", "UNSUPPORTED_OPERATION", {+ operation: "resolveName"+ });+ a = u.resolveName(e).then((d) => {+ if (d == null)+ throw Ot("an ENS name used for a contract target must be correctly configured", "UNCONFIGURED_NAME", {+ value: e+ });+ return jn(this).addr = d, d;+ });+ }+ else+ a = e.getAddress().then((u) => {+ if (u == null)+ throw new Error("TODO");+ return jn(this).addr = u, u;+ });+ GD(this, { addrPromise: a, addr: o, deployTx: c, subs: l });+ const h = new Proxy({}, {+ get: (u, d, f) => {+ if (typeof d == "symbol" || ol.indexOf(d) >= 0)+ return Reflect.get(u, d, f);+ try {+ return this.getEvent(d);+ } catch (m) {+ if (!_n(m, "INVALID_ARGUMENT") || m.argument !== "key")+ throw m;+ }+ },+ has: (u, d) => ol.indexOf(d) >= 0 ? Reflect.has(u, d) : Reflect.has(u, d) || this.interface.hasEvent(String(d))+ });+ return Xe(this, { filters: h }), Xe(this, {+ fallback: r.receive || r.fallback ? UD(this) : null+ }), new Proxy(this, {+ get: (u, d, f) => {+ if (typeof d == "symbol" || d in u || ol.indexOf(d) >= 0)+ return Reflect.get(u, d, f);+ try {+ return u.getFunction(d);+ } catch (m) {+ if (!_n(m, "INVALID_ARGUMENT") || m.argument !== "key")+ throw m;+ }+ },+ has: (u, d) => typeof d == "symbol" || d in u || ol.indexOf(d) >= 0 ? Reflect.has(u, d) : u.interface.hasFunction(d)+ });+ }+ /**+ * Return a new Contract instance with the same target and ABI, but+ * a different %%runner%%.+ */+ connect(e) {+ return new Bo(this.target, this.interface, e);+ }+ /**+ * Return a new Contract instance with the same ABI and runner, but+ * a different %%target%%.+ */+ attach(e) {+ return new Bo(e, this.interface, this.runner);+ }+ /**+ * Return the resolved address of this Contract.+ */+ async getAddress() {+ return await jn(this).addrPromise;+ }+ /**+ * Return the deployed bytecode or null if no bytecode is found.+ */+ async getDeployedCode() {+ const e = mr(this.runner);+ ge(e, "runner does not support .provider", "UNSUPPORTED_OPERATION", { operation: "getDeployedCode" });+ const t = await e.getCode(await this.getAddress());+ return t === "0x" ? null : t;+ }+ /**+ * Resolve to this Contract once the bytecode has been deployed, or+ * resolve immediately if already deployed.+ */+ async waitForDeployment() {+ const e = this.deploymentTransaction();+ if (e)+ return await e.wait(), this;+ if (await this.getDeployedCode() != null)+ return this;+ const n = mr(this.runner);+ return ge(n != null, "contract runner does not support .provider", "UNSUPPORTED_OPERATION", { operation: "waitForDeployment" }), new Promise((s, r) => {+ const a = async () => {+ try {+ if (await this.getDeployedCode() != null)+ return s(this);+ n.once("block", a);+ } catch (o) {+ r(o);+ }+ };+ a();+ });+ }+ /**+ * Return the transaction used to deploy this contract.+ *+ * This is only available if this instance was returned from a+ * [[ContractFactory]].+ */+ deploymentTransaction() {+ return jn(this).deployTx;+ }+ /**+ * Return the function for a given name. This is useful when a contract+ * method name conflicts with a JavaScript name such as ``prototype`` or+ * when using a Contract programmatically.+ */+ getFunction(e) {+ return typeof e != "string" && (e = e.format()), OD(this, e);+ }+ /**+ * Return the event for a given name. This is useful when a contract+ * event name conflicts with a JavaScript name such as ``prototype`` or+ * when using a Contract programmatically.+ */+ getEvent(e) {+ return typeof e != "string" && (e = e.format()), QD(this, e);+ }+ /**+ * @_ignore:+ */+ async queryTransaction(e) {+ throw new Error("@TODO");+ }+ /*+ // @TODO: this is a non-backwards compatible change, but will be added+ // in v7 and in a potential SmartContract class in an upcoming+ // v6 release+ async getTransactionReceipt(hash: string): Promise<null | ContractTransactionReceipt> {+ const provider = getProvider(this.runner);+ assert(provider, "contract runner does not have a provider",+ "UNSUPPORTED_OPERATION", { operation: "queryTransaction" });++ const receipt = await provider.getTransactionReceipt(hash);+ if (receipt == null) { return null; }++ return new ContractTransactionReceipt(this.interface, provider, receipt);+ }+ */+ /**+ * Provide historic access to event data for %%event%% in the range+ * %%fromBlock%% (default: ``0``) to %%toBlock%% (default: ``"latest"``)+ * inclusive.+ */+ async queryFilter(e, t, n) {+ t == null && (t = 0), n == null && (n = "latest");+ const { addr: s, addrPromise: r } = jn(this), a = s || await r, { fragment: o, topics: c } = await op(this, e), l = { address: a, topics: c, fromBlock: t, toBlock: n }, h = mr(this.runner);+ return ge(h, "contract runner does not have a provider", "UNSUPPORTED_OPERATION", { operation: "queryFilter" }), (await h.getLogs(l)).map((u) => {+ let d = o;+ if (d == null)+ try {+ d = this.interface.getEvent(u.topics[0]);+ } catch {+ }+ if (d)+ try {+ return new rp(u, this.interface, d);+ } catch (f) {+ return new zx(u, f);+ }+ return new rc(u, h);+ });+ }+ /**+ * Add an event %%listener%% for the %%event%%.+ */+ async on(e, t) {+ const n = await wm(this, "on", e);+ return n.listeners.push({ listener: t, once: !1 }), n.start(), this;+ }+ /**+ * Add an event %%listener%% for the %%event%%, but remove the listener+ * after it is fired once.+ */+ async once(e, t) {+ const n = await wm(this, "once", e);+ return n.listeners.push({ listener: t, once: !0 }), n.start(), this;+ }+ /**+ * Emit an %%event%% calling all listeners with %%args%%.+ *+ * Resolves to ``true`` if any listeners were called.+ */+ async emit(e, ...t) {+ return await nf(this, e, t, null);+ }+ /**+ * Resolves to the number of listeners of %%event%% or the total number+ * of listeners if unspecified.+ */+ async listenerCount(e) {+ if (e) {+ const s = await bo(this, e);+ return s ? s.listeners.length : 0;+ }+ const { subs: t } = jn(this);+ let n = 0;+ for (const { listeners: s } of t.values())+ n += s.length;+ return n;+ }+ /**+ * Resolves to the listeners subscribed to %%event%% or all listeners+ * if unspecified.+ */+ async listeners(e) {+ if (e) {+ const s = await bo(this, e);+ return s ? s.listeners.map(({ listener: r }) => r) : [];+ }+ const { subs: t } = jn(this);+ let n = [];+ for (const { listeners: s } of t.values())+ n = n.concat(s.map(({ listener: r }) => r));+ return n;+ }+ /**+ * Remove the %%listener%% from the listeners for %%event%% or remove+ * all listeners if unspecified.+ */+ async off(e, t) {+ const n = await bo(this, e);+ if (!n)+ return this;+ if (t) {+ const s = n.listeners.map(({ listener: r }) => r).indexOf(t);+ s >= 0 && n.listeners.splice(s, 1);+ }+ return (t == null || n.listeners.length === 0) && (n.stop(), jn(this).subs.delete(n.tag)), this;+ }+ /**+ * Remove all the listeners for %%event%% or remove all listeners if+ * unspecified.+ */+ async removeAllListeners(e) {+ if (e) {+ const t = await bo(this, e);+ if (!t)+ return this;+ t.stop(), jn(this).subs.delete(t.tag);+ } else {+ const { subs: t } = jn(this);+ for (const { tag: n, stop: s } of t.values())+ s(), t.delete(n);+ }+ return this;+ }+ /**+ * Alias for [on].+ */+ async addListener(e, t) {+ return await this.on(e, t);+ }+ /**+ * Alias for [off].+ */+ async removeListener(e, t) {+ return await this.off(e, t);+ }+ /**+ * Create a new Class for the %%abi%%.+ */+ static buildClass(e) {+ class t extends Bo {+ constructor(s, r = null) {+ super(s, e, r);+ }+ }+ return t;+ }+ /**+ * Create a new BaseContract with a specified Interface.+ */+ static from(e, t, n) {+ return n == null && (n = null), new this(e, t, n);+ }+}+function VD() {+ return Bo;+}+class _r extends VD() {+}+function Mu(i) {+ return i.match(/^ipfs:\/\/ipfs\//i) ? i = i.substring(12) : i.match(/^ipfs:\/\//i) ? i = i.substring(7) : V(!1, "unsupported IPFS format", "link", i), `https://gateway.ipfs.io/ipfs/${i}`;+}+class WD {+ /**+ * The name.+ */+ name;+ /**+ * Creates a new **MulticoinProviderPluing** for %%name%%.+ */+ constructor(e) {+ Xe(this, { name: e });+ }+ connect(e) {+ return this;+ }+ /**+ * Returns ``true`` if %%coinType%% is supported by this plugin.+ */+ supportsCoinType(e) {+ return !1;+ }+ /**+ * Resolves to the encoded %%address%% for %%coinType%%.+ */+ async encodeAddress(e, t) {+ throw new Error("unsupported coin");+ }+ /**+ * Resolves to the decoded %%data%% for %%coinType%%.+ */+ async decodeAddress(e, t) {+ throw new Error("unsupported coin");+ }+}+const Jx = new RegExp("^(ipfs)://(.*)$", "i"), vm = [+ new RegExp("^(https)://(.*)$", "i"),+ new RegExp("^(data):(.*)$", "i"),+ Jx,+ new RegExp("^eip155:[0-9]+/(erc[0-9]+):(.*)$", "i")+];+class ya {+ /**+ * The connected provider.+ */+ provider;+ /**+ * The address of the resolver.+ */+ address;+ /**+ * The name this resolver was resolved against.+ */+ name;+ // For EIP-2544 names, the ancestor that provided the resolver+ #e;+ #t;+ constructor(e, t, n) {+ Xe(this, { provider: e, address: t, name: n }), this.#e = null, this.#t = new _r(t, [+ "function supportsInterface(bytes4) view returns (bool)",+ "function resolve(bytes, bytes) view returns (bytes)",+ "function addr(bytes32) view returns (address)",+ "function addr(bytes32, uint) view returns (bytes)",+ "function text(bytes32, string) view returns (string)",+ "function contenthash(bytes32) view returns (bytes)"+ ], e);+ }+ /**+ * Resolves to true if the resolver supports wildcard resolution.+ */+ async supportsWildcard() {+ return this.#e == null && (this.#e = (async () => {+ try {+ return await this.#t.supportsInterface("0x9061b923");+ } catch (e) {+ if (_n(e, "CALL_EXCEPTION"))+ return !1;+ throw this.#e = null, e;+ }+ })()), await this.#e;+ }+ async #n(e, t) {+ t = (t || []).slice();+ const n = this.#t.interface;+ t.unshift(ef(this.name));+ let s = null;+ await this.supportsWildcard() && (s = n.getFunction(e), ge(s, "missing fragment", "UNKNOWN_ERROR", {+ info: { funcName: e }+ }), t = [+ aD(this.name, 255),+ n.encodeFunctionData(s, t)+ ], e = "resolve(bytes,bytes)"), t.push({+ enableCcipRead: !0+ });+ try {+ const r = await this.#t[e](...t);+ return s ? n.decodeFunctionResult(s, r)[0] : r;+ } catch (r) {+ if (!_n(r, "CALL_EXCEPTION"))+ throw r;+ }+ return null;+ }+ /**+ * Resolves to the address for %%coinType%% or null if the+ * provided %%coinType%% has not been configured.+ */+ async getAddress(e) {+ if (e == null && (e = 60), e === 60)+ try {+ const r = await this.#n("addr(bytes32)");+ return r == null || r === Vo ? null : r;+ } catch (r) {+ if (_n(r, "CALL_EXCEPTION"))+ return null;+ throw r;+ }+ if (e >= 0 && e < 2147483648) {+ let r = e + 2147483648;+ const a = await this.#n("addr(bytes32,uint)", [r]);+ if (Lt(a, 20))+ return St(a);+ }+ let t = null;+ for (const r of this.provider.plugins)+ if (r instanceof WD && r.supportsCoinType(e)) {+ t = r;+ break;+ }+ if (t == null)+ return null;+ const n = await this.#n("addr(bytes32,uint)", [e]);+ if (n == null || n === "0x")+ return null;+ const s = await t.decodeAddress(e, n);+ if (s != null)+ return s;+ ge(!1, "invalid coin data", "UNSUPPORTED_OPERATION", {+ operation: `getAddress(${e})`,+ info: { coinType: e, data: n }+ });+ }+ /**+ * Resolves to the EIP-634 text record for %%key%%, or ``null``+ * if unconfigured.+ */+ async getText(e) {+ const t = await this.#n("text(bytes32,string)", [e]);+ return t == null || t === "0x" ? null : t;+ }+ /**+ * Rsolves to the content-hash or ``null`` if unconfigured.+ */+ async getContentHash() {+ const e = await this.#n("contenthash(bytes32)");+ if (e == null || e === "0x")+ return null;+ const t = e.match(/^0x(e3010170|e5010172)(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);+ if (t) {+ const s = t[1] === "e3010170" ? "ipfs" : "ipns", r = parseInt(t[4], 16);+ if (t[5].length === r * 2)+ return `${s}://${tR("0x" + t[2])}`;+ }+ const n = e.match(/^0xe40101fa011b20([0-9a-f]*)$/);+ if (n && n[1].length === 64)+ return `bzz://${n[1]}`;+ ge(!1, "invalid or unsupported content hash data", "UNSUPPORTED_OPERATION", {+ operation: "getContentHash()",+ info: { data: e }+ });+ }+ /**+ * Resolves to the avatar url or ``null`` if the avatar is either+ * unconfigured or incorrectly configured (e.g. references an NFT+ * not owned by the address).+ *+ * If diagnosing issues with configurations, the [[_getAvatar]]+ * method may be useful.+ */+ async getAvatar() {+ return (await this._getAvatar()).url;+ }+ /**+ * When resolving an avatar, there are many steps involved, such+ * fetching metadata and possibly validating ownership of an+ * NFT.+ *+ * This method can be used to examine each step and the value it+ * was working from.+ */+ async _getAvatar() {+ const e = [{ type: "name", value: this.name }];+ try {+ const t = await this.getText("avatar");+ if (t == null)+ return e.push({ type: "!avatar", value: "" }), { url: null, linkage: e };+ e.push({ type: "avatar", value: t });+ for (let n = 0; n < vm.length; n++) {+ const s = t.match(vm[n]);+ if (s == null)+ continue;+ const r = s[1].toLowerCase();+ switch (r) {+ case "https":+ case "data":+ return e.push({ type: "url", value: t }), { linkage: e, url: t };+ case "ipfs": {+ const a = Mu(t);+ return e.push({ type: "ipfs", value: t }), e.push({ type: "url", value: a }), { linkage: e, url: a };+ }+ case "erc721":+ case "erc1155": {+ const a = r === "erc721" ? "tokenURI(uint256)" : "uri(uint256)";+ e.push({ type: r, value: t });+ const o = await this.getAddress();+ if (o == null)+ return e.push({ type: "!owner", value: "" }), { url: null, linkage: e };+ const c = (s[2] || "").split("/");+ if (c.length !== 2)+ return e.push({ type: `!${r}caip`, value: s[2] || "" }), { url: null, linkage: e };+ const l = c[1], h = new _r(c[0], [+ // ERC-721+ "function tokenURI(uint) view returns (string)",+ "function ownerOf(uint) view returns (address)",+ // ERC-1155+ "function uri(uint) view returns (string)",+ "function balanceOf(address, uint256) view returns (uint)"+ ], this.provider);+ if (r === "erc721") {+ const A = await h.ownerOf(l);+ if (o !== A)+ return e.push({ type: "!owner", value: A }), { url: null, linkage: e };+ e.push({ type: "owner", value: A });+ } else if (r === "erc1155") {+ const A = await h.balanceOf(o, l);+ if (!A)+ return e.push({ type: "!balance", value: "0" }), { url: null, linkage: e };+ e.push({ type: "balance", value: A.toString() });+ }+ let u = await h[a](l);+ if (u == null || u === "0x")+ return e.push({ type: "!metadata-url", value: "" }), { url: null, linkage: e };+ e.push({ type: "metadata-url-base", value: u }), r === "erc1155" && (u = u.replace("{id}", Hs(l, 32).substring(2)), e.push({ type: "metadata-url-expanded", value: u })), u.match(/^ipfs:/i) && (u = Mu(u)), e.push({ type: "metadata-url", value: u });+ let d = {};+ const f = await new ki(u).send();+ f.assertOk();+ try {+ d = f.bodyJson;+ } catch {+ try {+ e.push({ type: "!metadata", value: f.bodyText });+ } catch {+ const p = f.body;+ return p && e.push({ type: "!metadata", value: Se(p) }), { url: null, linkage: e };+ }+ return { url: null, linkage: e };+ }+ if (!d)+ return e.push({ type: "!metadata", value: "" }), { url: null, linkage: e };+ e.push({ type: "metadata", value: JSON.stringify(d) });+ let m = d.image;+ if (typeof m != "string")+ return e.push({ type: "!imageUrl", value: "" }), { url: null, linkage: e };+ if (!m.match(/^(https:\/\/|data:)/i)) {+ if (m.match(Jx) == null)+ return e.push({ type: "!imageUrl-ipfs", value: m }), { url: null, linkage: e };+ e.push({ type: "imageUrl-ipfs", value: m }), m = Mu(m);+ }+ return e.push({ type: "url", value: m }), { linkage: e, url: m };+ }+ }+ }+ } catch {+ }+ return { linkage: e, url: null };+ }+ static async getEnsAddress(e) {+ const t = await e.getNetwork(), n = t.getPlugin("org.ethers.plugins.network.Ens");+ return ge(n, "network does not support ENS", "UNSUPPORTED_OPERATION", {+ operation: "getEnsAddress",+ info: { network: t }+ }), n.address;+ }+ static async #i(e, t) {+ const n = await ya.getEnsAddress(e);+ try {+ const r = await new _r(n, [+ "function resolver(bytes32) view returns (address)"+ ], e).resolver(ef(t), {+ enableCcipRead: !0+ });+ return r === Vo ? null : r;+ } catch (s) {+ throw s;+ }+ return null;+ }+ /**+ * Resolve to the ENS resolver for %%name%% using %%provider%% or+ * ``null`` if unconfigured.+ */+ static async fromName(e, t) {+ let n = t;+ for (; ; ) {+ if (n === "" || n === "." || t !== "eth" && n === "eth")+ return null;+ const s = await ya.#i(e, n);+ if (s != null) {+ const r = new ya(e, s, t);+ return n !== t && !await r.supportsWildcard() ? null : r;+ }+ n = n.split(".").slice(1).join(".");+ }+ }+}+const Cm = BigInt(0);+function gt(i, e) {+ return (function(t) {+ return t == null ? e : i(t);+ });+}+function Yo(i, e) {+ return ((t) => {+ if (e && t == null)+ return null;+ if (!Array.isArray(t))+ throw new Error("not an array");+ return t.map((n) => i(n));+ });+}+function oc(i, e) {+ return ((t) => {+ const n = {};+ for (const s in i) {+ let r = s;+ if (e && s in e && !(r in t)) {+ for (const a of e[s])+ if (a in t) {+ r = a;+ break;+ }+ }+ try {+ const a = i[s](t[r]);+ a !== void 0 && (n[s] = a);+ } catch (a) {+ const o = a instanceof Error ? a.message : "not-an-error";+ ge(!1, `invalid value for value.${s} (${o})`, "BAD_DATA", { value: t });+ }+ }+ return n;+ });+}+function qD(i) {+ switch (i) {+ case !0:+ case "true":+ return !0;+ case !1:+ case "false":+ return !1;+ }+ V(!1, `invalid boolean; ${JSON.stringify(i)}`, "value", i);+}+function ka(i) {+ return V(Lt(i, !0), "invalid data", "value", i), i;+}+function xn(i) {+ return V(Lt(i, 32), "invalid hash", "value", i), i;+}+const KD = oc({+ address: St,+ blockHash: xn,+ blockNumber: ut,+ data: ka,+ index: ut,+ removed: gt(qD, !1),+ topics: Yo(xn),+ transactionHash: xn,+ transactionIndex: ut+}, {+ index: ["logIndex"]+});+function jD(i) {+ return KD(i);+}+const XD = oc({+ hash: gt(xn),+ parentHash: xn,+ parentBeaconBlockRoot: gt(xn, null),+ number: ut,+ timestamp: ut,+ nonce: gt(ka),+ difficulty: Fe,+ gasLimit: Fe,+ gasUsed: Fe,+ stateRoot: gt(xn, null),+ receiptsRoot: gt(xn, null),+ blobGasUsed: gt(Fe, null),+ excessBlobGas: gt(Fe, null),+ miner: gt(St),+ prevRandao: gt(xn, null),+ extraData: ka,+ baseFeePerGas: gt(Fe)+}, {+ prevRandao: ["mixHash"]+});+function YD(i) {+ const e = XD(i);+ return e.transactions = i.transactions.map((t) => typeof t == "string" ? t : Zx(t)), e;+}+const JD = oc({+ transactionIndex: ut,+ blockNumber: ut,+ transactionHash: xn,+ address: St,+ topics: Yo(xn),+ data: ka,+ index: ut,+ blockHash: xn+}, {+ index: ["logIndex"]+});+function ZD(i) {+ return JD(i);+}+const $D = oc({+ to: gt(St, null),+ from: gt(St, null),+ contractAddress: gt(St, null),+ // should be allowNull(hash), but broken-EIP-658 support is handled in receipt+ index: ut,+ root: gt(Se),+ gasUsed: Fe,+ blobGasUsed: gt(Fe, null),+ logsBloom: gt(ka),+ blockHash: xn,+ hash: xn,+ logs: Yo(ZD),+ blockNumber: ut,+ //confirmations: allowNull(getNumber, null),+ cumulativeGasUsed: Fe,+ effectiveGasPrice: gt(Fe),+ blobGasPrice: gt(Fe, null),+ status: gt(ut),+ type: gt(ut, 0)+}, {+ effectiveGasPrice: ["gasPrice"],+ hash: ["transactionHash"],+ index: ["transactionIndex"]+});+function eL(i) {+ return $D(i);+}+function Zx(i) {+ i.to && Fe(i.to) === Cm && (i.to = "0x0000000000000000000000000000000000000000");+ const e = oc({+ hash: xn,+ // Some nodes do not return this, usually test nodes (like Ganache)+ index: gt(ut, void 0),+ type: (t) => t === "0x" || t == null ? 0 : ut(t),+ accessList: gt(Rr, null),+ blobVersionedHashes: gt(Yo(xn, !0), null),+ authorizationList: gt(Yo((t) => {+ let n;+ if (t.signature)+ n = t.signature;+ else {+ let s = t.yParity;+ s === "0x1b" ? s = 0 : s === "0x1c" && (s = 1), n = Object.assign({}, t, { yParity: s });+ }+ return {+ address: St(t.address),+ chainId: Fe(t.chainId),+ nonce: Fe(t.nonce),+ signature: Gt.from(n)+ };+ }, !1), null),+ blockHash: gt(xn, null),+ blockNumber: gt(ut, null),+ transactionIndex: gt(ut, null),+ from: St,+ // either (gasPrice) or (maxPriorityFeePerGas + maxFeePerGas) must be set+ gasPrice: gt(Fe),+ maxPriorityFeePerGas: gt(Fe),+ maxFeePerGas: gt(Fe),+ maxFeePerBlobGas: gt(Fe, null),+ gasLimit: Fe,+ to: gt(St, null),+ value: Fe,+ nonce: ut,+ data: ka,+ creates: gt(St, null),+ chainId: gt(Fe, null)+ }, {+ data: ["input"],+ gasLimit: ["gas"],+ index: ["transactionIndex"]+ })(i);+ if (e.to == null && e.creates == null && (e.creates = GN(e)), (i.type === 1 || i.type === 2) && i.accessList == null && (e.accessList = []), i.signature ? e.signature = Gt.from(i.signature) : e.signature = Gt.from(i), e.chainId == null) {+ const t = e.signature.legacyChainId;+ t != null && (e.chainId = t);+ }+ return e.blockHash && Fe(e.blockHash) === Cm && (e.blockHash = null), e;+}+const tL = "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";+class cc {+ /**+ * The name of the plugin.+ *+ * It is recommended to use reverse-domain-notation, which permits+ * unique names with a known authority as well as hierarchal entries.+ */+ name;+ /**+ * Creates a new **NetworkPlugin**.+ */+ constructor(e) {+ Xe(this, { name: e });+ }+ /**+ * Creates a copy of this plugin.+ */+ clone() {+ return new cc(this.name);+ }+}+class Ah extends cc {+ /**+ * The block number to treat these values as valid from.+ *+ * This allows a hardfork to have updated values included as well as+ * mulutiple hardforks to be supported.+ */+ effectiveBlock;+ /**+ * The transactions base fee.+ */+ txBase;+ /**+ * The fee for creating a new account.+ */+ txCreate;+ /**+ * The fee per zero-byte in the data.+ */+ txDataZero;+ /**+ * The fee per non-zero-byte in the data.+ */+ txDataNonzero;+ /**+ * The fee per storage key in the [[link-eip-2930]] access list.+ */+ txAccessListStorageKey;+ /**+ * The fee per address in the [[link-eip-2930]] access list.+ */+ txAccessListAddress;+ /**+ * Creates a new GasCostPlugin from %%effectiveBlock%% until the+ * latest block or another GasCostPlugin supercedes that block number,+ * with the associated %%costs%%.+ */+ constructor(e, t) {+ e == null && (e = 0), super(`org.ethers.network.plugins.GasCost#${e || 0}`);+ const n = { effectiveBlock: e };+ function s(r, a) {+ let o = (t || {})[r];+ o == null && (o = a), V(typeof o == "number", `invalud value for ${r}`, "costs", t), n[r] = o;+ }+ s("txBase", 21e3), s("txCreate", 32e3), s("txDataZero", 4), s("txDataNonzero", 16), s("txAccessListStorageKey", 1900), s("txAccessListAddress", 2400), Xe(this, n);+ }+ clone() {+ return new Ah(this.effectiveBlock, this);+ }+}+class gh extends cc {+ /**+ * The ENS Registrty Contract address.+ */+ address;+ /**+ * The chain ID that the ENS contract lives on.+ */+ targetNetwork;+ /**+ * Creates a new **EnsPlugin** connected to %%address%% on the+ * %%targetNetwork%%. The default ENS address and mainnet is used+ * if unspecified.+ */+ constructor(e, t) {+ super("org.ethers.plugins.network.Ens"), Xe(this, {+ address: e || tL,+ targetNetwork: t ?? 1+ });+ }+ clone() {+ return new gh(this.address, this.targetNetwork);+ }+}+class nL extends cc {+ #e;+ #t;+ /**+ * The URL to initialize the FetchRequest with in %%processFunc%%.+ */+ get url() {+ return this.#e;+ }+ /**+ * The callback to use when computing the FeeData.+ */+ get processFunc() {+ return this.#t;+ }+ /**+ * Creates a new **FetchUrlFeeDataNetworkPlugin** which will+ * be used when computing the fee data for the network.+ */+ constructor(e, t) {+ super("org.ethers.plugins.network.FetchUrlFeeDataPlugin"), this.#e = e, this.#t = t;+ }+ // We are immutable, so we can serve as our own clone+ clone() {+ return this;+ }+}+const Bu = /* @__PURE__ */ new Map();+class Xn {+ #e;+ #t;+ #n;+ /**+ * Creates a new **Network** for %%name%% and %%chainId%%.+ */+ constructor(e, t) {+ this.#e = e, this.#t = Fe(t), this.#n = /* @__PURE__ */ new Map();+ }+ /**+ * Returns a JSON-compatible representation of a Network.+ */+ toJSON() {+ return { name: this.name, chainId: String(this.chainId) };+ }+ /**+ * The network common name.+ *+ * This is the canonical name, as networks migh have multiple+ * names.+ */+ get name() {+ return this.#e;+ }+ set name(e) {+ this.#e = e;+ }+ /**+ * The network chain ID.+ */+ get chainId() {+ return this.#t;+ }+ set chainId(e) {+ this.#t = Fe(e, "chainId");+ }+ /**+ * Returns true if %%other%% matches this network. Any chain ID+ * must match, and if no chain ID is present, the name must match.+ *+ * This method does not currently check for additional properties,+ * such as ENS address or plug-in compatibility.+ */+ matches(e) {+ if (e == null)+ return !1;+ if (typeof e == "string") {+ try {+ return this.chainId === Fe(e);+ } catch {+ }+ return this.name === e;+ }+ if (typeof e == "number" || typeof e == "bigint") {+ try {+ return this.chainId === Fe(e);+ } catch {+ }+ return !1;+ }+ if (typeof e == "object") {+ if (e.chainId != null) {+ try {+ return this.chainId === Fe(e.chainId);+ } catch {+ }+ return !1;+ }+ return e.name != null ? this.name === e.name : !1;+ }+ return !1;+ }+ /**+ * Returns the list of plugins currently attached to this Network.+ */+ get plugins() {+ return Array.from(this.#n.values());+ }+ /**+ * Attach a new %%plugin%% to this Network. The network name+ * must be unique, excluding any fragment.+ */+ attachPlugin(e) {+ if (this.#n.get(e.name))+ throw new Error(`cannot replace existing plugin: ${e.name} `);+ return this.#n.set(e.name, e.clone()), this;+ }+ /**+ * Return the plugin, if any, matching %%name%% exactly. Plugins+ * with fragments will not be returned unless %%name%% includes+ * a fragment.+ */+ getPlugin(e) {+ return this.#n.get(e) || null;+ }+ /**+ * Gets a list of all plugins that match %%name%%, with otr without+ * a fragment.+ */+ getPlugins(e) {+ return this.plugins.filter((t) => t.name.split("#")[0] === e);+ }+ /**+ * Create a copy of this Network.+ */+ clone() {+ const e = new Xn(this.name, this.chainId);+ return this.plugins.forEach((t) => {+ e.attachPlugin(t.clone());+ }), e;+ }+ /**+ * Compute the intrinsic gas required for a transaction.+ *+ * A GasCostPlugin can be attached to override the default+ * values.+ */+ computeIntrinsicGas(e) {+ const t = this.getPlugin("org.ethers.plugins.network.GasCost") || new Ah();+ let n = t.txBase;+ if (e.to == null && (n += t.txCreate), e.data)+ for (let s = 2; s < e.data.length; s += 2)+ e.data.substring(s, s + 2) === "00" ? n += t.txDataZero : n += t.txDataNonzero;+ if (e.accessList) {+ const s = Rr(e.accessList);+ for (const r in s)+ n += t.txAccessListAddress + t.txAccessListStorageKey * s[r].storageKeys.length;+ }+ return n;+ }+ /**+ * Returns a new Network for the %%network%% name or chainId.+ */+ static from(e) {+ if (iL(), e == null)+ return Xn.from("mainnet");+ if (typeof e == "number" && (e = BigInt(e)), typeof e == "string" || typeof e == "bigint") {+ const t = Bu.get(e);+ if (t)+ return t();+ if (typeof e == "bigint")+ return new Xn("unknown", e);+ V(!1, "unknown network", "network", e);+ }+ if (typeof e.clone == "function")+ return e.clone();+ if (typeof e == "object") {+ V(typeof e.name == "string" && typeof e.chainId == "number", "invalid network object name or chainId", "network", e);+ const t = new Xn(e.name, e.chainId);+ return (e.ensAddress || e.ensNetwork != null) && t.attachPlugin(new gh(e.ensAddress, e.ensNetwork)), t;+ }+ V(!1, "invalid network", "network", e);+ }+ /**+ * Register %%nameOrChainId%% with a function which returns+ * an instance of a Network representing that chain.+ */+ static register(e, t) {+ typeof e == "number" && (e = BigInt(e));+ const n = Bu.get(e);+ n && V(!1, `conflicting network for ${JSON.stringify(n.name)}`, "nameOrChainId", e), Bu.set(e, t);+ }+}+function Sm(i, e) {+ const t = String(i);+ if (!t.match(/^[0-9.]+$/))+ throw new Error(`invalid gwei value: ${i}`);+ const n = t.split(".");+ if (n.length === 1 && n.push(""), n.length !== 2)+ throw new Error(`invalid gwei value: ${i}`);+ for (; n[1].length < e; )+ n[1] += "0";+ if (n[1].length > 9) {+ let s = BigInt(n[1].substring(0, 9));+ n[1].substring(9).match(/^0+$/) || s++, n[1] = s.toString();+ }+ return BigInt(n[0] + n[1]);+}+function Im(i) {+ return new nL(i, async (e, t, n) => {+ n.setHeader("User-Agent", "ethers");+ let s;+ try {+ const [r, a] = await Promise.all([+ n.send(),+ e()+ ]);+ s = r;+ const o = s.bodyJson.standard;+ return {+ gasPrice: a.gasPrice,+ maxFeePerGas: Sm(o.maxFee, 9),+ maxPriorityFeePerGas: Sm(o.maxPriorityFee, 9)+ };+ } catch (r) {+ ge(!1, `error encountered with polygon gas station (${JSON.stringify(n.url)})`, "SERVER_ERROR", { request: n, response: s, error: r });+ }+ });+}+let Mm = !1;+function iL() {+ if (Mm)+ return;+ Mm = !0;+ function i(e, t, n) {+ const s = function() {+ const r = new Xn(e, t);+ return n.ensNetwork != null && r.attachPlugin(new gh(null, n.ensNetwork)), r.attachPlugin(new Ah()), (n.plugins || []).forEach((a) => {+ r.attachPlugin(a);+ }), r;+ };+ Xn.register(e, s), Xn.register(t, s), n.altNames && n.altNames.forEach((r) => {+ Xn.register(r, s);+ });+ }+ i("mainnet", 1, { ensNetwork: 1, altNames: ["homestead"] }), i("ropsten", 3, { ensNetwork: 3 }), i("rinkeby", 4, { ensNetwork: 4 }), i("goerli", 5, { ensNetwork: 5 }), i("kovan", 42, { ensNetwork: 42 }), i("sepolia", 11155111, { ensNetwork: 11155111 }), i("holesky", 17e3, { ensNetwork: 17e3 }), i("classic", 61, {}), i("classicKotti", 6, {}), i("arbitrum", 42161, {+ ensNetwork: 1+ }), i("arbitrum-goerli", 421613, {}), i("arbitrum-sepolia", 421614, {}), i("base", 8453, { ensNetwork: 1 }), i("base-goerli", 84531, {}), i("base-sepolia", 84532, {}), i("bnb", 56, { ensNetwork: 1 }), i("bnbt", 97, {}), i("filecoin", 314, {}), i("filecoin-calibration", 314159, {}), i("linea", 59144, { ensNetwork: 1 }), i("linea-goerli", 59140, {}), i("linea-sepolia", 59141, {}), i("matic", 137, {+ ensNetwork: 1,+ plugins: [+ Im("https://gasstation.polygon.technology/v2")+ ]+ }), i("matic-amoy", 80002, {}), i("matic-mumbai", 80001, {+ altNames: ["maticMumbai", "maticmum"],+ plugins: [+ Im("https://gasstation-testnet.polygon.technology/v2")+ ]+ }), i("optimism", 10, {+ ensNetwork: 1,+ plugins: []+ }), i("optimism-goerli", 420, {}), i("optimism-sepolia", 11155420, {}), i("xdai", 100, { ensNetwork: 1 });+}+function sf(i) {+ return JSON.parse(JSON.stringify(i));+}+class sL {+ #e;+ #t;+ #n;+ // The most recent block we have scanned for events. The value -2+ // indicates we still need to fetch an initial block number+ #i;+ /**+ * Create a new **PollingBlockSubscriber** attached to %%provider%%.+ */+ constructor(e) {+ this.#e = e, this.#t = null, this.#n = 4e3, this.#i = -2;+ }+ /**+ * The polling interval.+ */+ get pollingInterval() {+ return this.#n;+ }+ set pollingInterval(e) {+ this.#n = e;+ }+ async #s() {+ try {+ const e = await this.#e.getBlockNumber();+ if (this.#i === -2) {+ this.#i = e;+ return;+ }+ if (e !== this.#i) {+ for (let t = this.#i + 1; t <= e; t++) {+ if (this.#t == null)+ return;+ await this.#e.emit("block", t);+ }+ this.#i = e;+ }+ } catch {+ }+ this.#t != null && (this.#t = this.#e._setTimeout(this.#s.bind(this), this.#n));+ }+ start() {+ this.#t || (this.#t = this.#e._setTimeout(this.#s.bind(this), this.#n), this.#s());+ }+ stop() {+ this.#t && (this.#e._clearTimeout(this.#t), this.#t = null);+ }+ pause(e) {+ this.stop(), e && (this.#i = -2);+ }+ resume() {+ this.start();+ }+}+class cp {+ #e;+ #t;+ #n;+ /**+ * Create a new **OnBlockSubscriber** attached to %%provider%%.+ */+ constructor(e) {+ this.#e = e, this.#n = !1, this.#t = (t) => {+ this._poll(t, this.#e);+ };+ }+ /**+ * Called on every new block.+ */+ async _poll(e, t) {+ throw new Error("sub-classes must override this");+ }+ start() {+ this.#n || (this.#n = !0, this.#t(-2), this.#e.on("block", this.#t));+ }+ stop() {+ this.#n && (this.#n = !1, this.#e.off("block", this.#t));+ }+ pause(e) {+ this.stop();+ }+ resume() {+ this.start();+ }+}+class rL extends cp {+ #e;+ #t;+ constructor(e, t) {+ super(e), this.#e = t, this.#t = -2;+ }+ pause(e) {+ e && (this.#t = -2), super.pause(e);+ }+ async _poll(e, t) {+ const n = await t.getBlock(this.#e);+ n != null && (this.#t === -2 ? this.#t = n.number : n.number > this.#t && (t.emit(this.#e, n.number), this.#t = n.number));+ }+}+class aL extends cp {+ #e;+ constructor(e, t) {+ super(e), this.#e = sf(t);+ }+ async _poll(e, t) {+ throw new Error("@TODO");+ }+}+class oL extends cp {+ #e;+ /**+ * Create a new **PollingTransactionSubscriber** attached to+ * %%provider%%, listening for %%hash%%.+ */+ constructor(e, t) {+ super(e), this.#e = t;+ }+ async _poll(e, t) {+ const n = await t.getTransactionReceipt(this.#e);+ n && t.emit(this.#e, n);+ }+}+class lp {+ #e;+ #t;+ #n;+ #i;+ // The most recent block we have scanned for events. The value -2+ // indicates we still need to fetch an initial block number+ #s;+ /**+ * Create a new **PollingTransactionSubscriber** attached to+ * %%provider%%, listening for %%filter%%.+ */+ constructor(e, t) {+ this.#e = e, this.#t = sf(t), this.#n = this.#a.bind(this), this.#i = !1, this.#s = -2;+ }+ async #a(e) {+ if (this.#s === -2)+ return;+ const t = sf(this.#t);+ t.fromBlock = this.#s + 1, t.toBlock = e;+ const n = await this.#e.getLogs(t);+ if (n.length === 0) {+ this.#s < e - 60 && (this.#s = e - 60);+ return;+ }+ for (const s of n)+ this.#e.emit(this.#t, s), this.#s = s.blockNumber;+ }+ start() {+ this.#i || (this.#i = !0, this.#s === -2 && this.#e.getBlockNumber().then((e) => {+ this.#s = e;+ }), this.#e.on("block", this.#n));+ }+ stop() {+ this.#i && (this.#i = !1, this.#e.off("block", this.#n));+ }+ pause(e) {+ this.stop(), e && (this.#s = -2);+ }+ resume() {+ this.start();+ }+}+const cL = BigInt(2), lL = 10;+function cl(i) {+ return i && typeof i.then == "function";+}+function xl(i, e) {+ return i + ":" + JSON.stringify(e, (t, n) => {+ if (n == null)+ return "null";+ if (typeof n == "bigint")+ return `bigint:${n.toString()}`;+ if (typeof n == "string")+ return n.toLowerCase();+ if (typeof n == "object" && !Array.isArray(n)) {+ const s = Object.keys(n);+ return s.sort(), s.reduce((r, a) => (r[a] = n[a], r), {});+ }+ return n;+ });+}+class $x {+ /**+ * The name fof the event.+ */+ name;+ /**+ * Create a new UnmanagedSubscriber with %%name%%.+ */+ constructor(e) {+ Xe(this, { name: e });+ }+ start() {+ }+ stop() {+ }+ pause(e) {+ }+ resume() {+ }+}+function hL(i) {+ return JSON.parse(JSON.stringify(i));+}+function rf(i) {+ return i = Array.from(new Set(i).values()), i.sort(), i;+}+async function Tu(i, e) {+ if (i == null)+ throw new Error("invalid event");+ if (Array.isArray(i) && (i = { topics: i }), typeof i == "string")+ switch (i) {+ case "block":+ case "debug":+ case "error":+ case "finalized":+ case "network":+ case "pending":+ case "safe":+ return { type: i, tag: i };+ }+ if (Lt(i, 32)) {+ const t = i.toLowerCase();+ return { type: "transaction", tag: xl("tx", { hash: t }), hash: t };+ }+ if (i.orphan) {+ const t = i;+ return { type: "orphan", tag: xl("orphan", t), filter: hL(t) };+ }+ if (i.address || i.topics) {+ const t = i, n = {+ topics: (t.topics || []).map((s) => s == null ? null : Array.isArray(s) ? rf(s.map((r) => r.toLowerCase())) : s.toLowerCase())+ };+ if (t.address) {+ const s = [], r = [], a = (o) => {+ Lt(o) ? s.push(o) : r.push((async () => {+ s.push(await Dn(o, e));+ })());+ };+ Array.isArray(t.address) ? t.address.forEach(a) : a(t.address), r.length && await Promise.all(r), n.address = rf(s.map((o) => o.toLowerCase()));+ }+ return { filter: n, tag: xl("event", n), type: "event" };+ }+ V(!1, "unknown ProviderEvent", "event", i);+}+function Ru() {+ return (/* @__PURE__ */ new Date()).getTime();+}+const uL = {+ cacheTimeout: 250,+ pollingInterval: 4e3+};+class dL {+ #e;+ #t;+ // null=unpaused, true=paused+dropWhilePaused, false=paused+ #n;+ #i;+ #s;+ #a;+ #r;+ // The most recent block number if running an event or -1 if no "block" event+ #o;+ #f;+ #l;+ #p;+ #A;+ /**+ * Create a new **AbstractProvider** connected to %%network%%, or+ * use the various network detection capabilities to discover the+ * [[Network]] if necessary.+ */+ constructor(e, t) {+ if (this.#A = Object.assign({}, uL, t || {}), e === "any")+ this.#a = !0, this.#s = null;+ else if (e) {+ const n = Xn.from(e);+ this.#a = !1, this.#s = Promise.resolve(n), setTimeout(() => {+ this.emit("network", n, null);+ }, 0);+ } else+ this.#a = !1, this.#s = null;+ this.#o = -1, this.#r = /* @__PURE__ */ new Map(), this.#e = /* @__PURE__ */ new Map(), this.#t = /* @__PURE__ */ new Map(), this.#n = null, this.#i = !1, this.#f = 1, this.#l = /* @__PURE__ */ new Map(), this.#p = !1;+ }+ get pollingInterval() {+ return this.#A.pollingInterval;+ }+ /**+ * Returns ``this``, to allow an **AbstractProvider** to implement+ * the [[ContractRunner]] interface.+ */+ get provider() {+ return this;+ }+ /**+ * Returns all the registered plug-ins.+ */+ get plugins() {+ return Array.from(this.#t.values());+ }+ /**+ * Attach a new plug-in.+ */+ attachPlugin(e) {+ if (this.#t.get(e.name))+ throw new Error(`cannot replace existing plugin: ${e.name} `);+ return this.#t.set(e.name, e.connect(this)), this;+ }+ /**+ * Get a plugin by name.+ */+ getPlugin(e) {+ return this.#t.get(e) || null;+ }+ /**+ * Prevent any CCIP-read operation, regardless of whether requested+ * in a [[call]] using ``enableCcipRead``.+ */+ get disableCcipRead() {+ return this.#p;+ }+ set disableCcipRead(e) {+ this.#p = !!e;+ }+ // Shares multiple identical requests made during the same 250ms+ async #c(e) {+ const t = this.#A.cacheTimeout;+ if (t < 0)+ return await this._perform(e);+ const n = xl(e.method, e);+ let s = this.#r.get(n);+ return s || (s = this._perform(e), this.#r.set(n, s), setTimeout(() => {+ this.#r.get(n) === s && this.#r.delete(n);+ }, t)), await s;+ }+ /**+ * Resolves to the data for executing the CCIP-read operations.+ */+ async ccipReadFetch(e, t, n) {+ if (this.disableCcipRead || n.length === 0 || e.to == null)+ return null;+ const s = e.to.toLowerCase(), r = t.toLowerCase(), a = [];+ for (let o = 0; o < n.length; o++) {+ const c = n[o], l = c.replace("{sender}", s).replace("{data}", r), h = new ki(l);+ c.indexOf("{data}") === -1 && (h.body = { data: r, sender: s }), this.emit("debug", { action: "sendCcipReadFetchRequest", request: h, index: o, urls: n });+ let u = "unknown error", d;+ try {+ d = await h.send();+ } catch (f) {+ a.push(f.message), this.emit("debug", { action: "receiveCcipReadFetchError", request: h, result: { error: f } });+ continue;+ }+ try {+ const f = d.bodyJson;+ if (f.data)+ return this.emit("debug", { action: "receiveCcipReadFetchResult", request: h, result: f }), f.data;+ f.message && (u = f.message), this.emit("debug", { action: "receiveCcipReadFetchError", request: h, result: f });+ } catch {+ }+ ge(d.statusCode < 400 || d.statusCode >= 500, `response not found during CCIP fetch: ${u}`, "OFFCHAIN_FAULT", { reason: "404_MISSING_RESOURCE", transaction: e, info: { url: c, errorMessage: u } }), a.push(u);+ }+ ge(!1, `error encountered during CCIP fetch: ${a.map((o) => JSON.stringify(o)).join(", ")}`, "OFFCHAIN_FAULT", {+ reason: "500_SERVER_ERROR",+ transaction: e,+ info: { urls: n, errorMessages: a }+ });+ }+ /**+ * Provides the opportunity for a sub-class to wrap a block before+ * returning it, to add additional properties or an alternate+ * sub-class of [[Block]].+ */+ _wrapBlock(e, t) {+ return new RD(YD(e), this);+ }+ /**+ * Provides the opportunity for a sub-class to wrap a log before+ * returning it, to add additional properties or an alternate+ * sub-class of [[Log]].+ */+ _wrapLog(e, t) {+ return new rc(jD(e), this);+ }+ /**+ * Provides the opportunity for a sub-class to wrap a transaction+ * receipt before returning it, to add additional properties or an+ * alternate sub-class of [[TransactionReceipt]].+ */+ _wrapTransactionReceipt(e, t) {+ return new Qx(eL(e), this);+ }+ /**+ * Provides the opportunity for a sub-class to wrap a transaction+ * response before returning it, to add additional properties or an+ * alternate sub-class of [[TransactionResponse]].+ */+ _wrapTransactionResponse(e, t) {+ return new ac(Zx(e), this);+ }+ /**+ * Resolves to the Network, forcing a network detection using whatever+ * technique the sub-class requires.+ *+ * Sub-classes **must** override this.+ */+ _detectNetwork() {+ ge(!1, "sub-classes must implement this", "UNSUPPORTED_OPERATION", {+ operation: "_detectNetwork"+ });+ }+ /**+ * Sub-classes should use this to perform all built-in operations. All+ * methods sanitizes and normalizes the values passed into this.+ *+ * Sub-classes **must** override this.+ */+ async _perform(e) {+ ge(!1, `unsupported method: ${e.method}`, "UNSUPPORTED_OPERATION", {+ operation: e.method,+ info: e+ });+ }+ // State+ async getBlockNumber() {+ const e = ut(await this.#c({ method: "getBlockNumber" }), "%response");+ return this.#o >= 0 && (this.#o = e), e;+ }+ /**+ * Returns or resolves to the address for %%address%%, resolving ENS+ * names and [[Addressable]] objects and returning if already an+ * address.+ */+ _getAddress(e) {+ return Dn(e, this);+ }+ /**+ * Returns or resolves to a valid block tag for %%blockTag%%, resolving+ * negative values and returning if already a valid block tag.+ */+ _getBlockTag(e) {+ if (e == null)+ return "latest";+ switch (e) {+ case "earliest":+ return "0x0";+ case "finalized":+ case "latest":+ case "pending":+ case "safe":+ return e;+ }+ if (Lt(e))+ return Lt(e, 32) ? e : Ai(e);+ if (typeof e == "bigint" && (e = ut(e, "blockTag")), typeof e == "number")+ return e >= 0 ? Ai(e) : this.#o >= 0 ? Ai(this.#o + e) : this.getBlockNumber().then((t) => Ai(t + e));+ V(!1, "invalid blockTag", "blockTag", e);+ }+ /**+ * Returns or resolves to a filter for %%filter%%, resolving any ENS+ * names or [[Addressable]] object and returning if already a valid+ * filter.+ */+ _getFilter(e) {+ const t = (e.topics || []).map((c) => c == null ? null : Array.isArray(c) ? rf(c.map((l) => l.toLowerCase())) : c.toLowerCase()), n = "blockHash" in e ? e.blockHash : void 0, s = (c, l, h) => {+ let u;+ switch (c.length) {+ case 0:+ break;+ case 1:+ u = c[0];+ break;+ default:+ c.sort(), u = c;+ }+ if (n && (l != null || h != null))+ throw new Error("invalid filter");+ const d = {};+ return u && (d.address = u), t.length && (d.topics = t), l && (d.fromBlock = l), h && (d.toBlock = h), n && (d.blockHash = n), d;+ };+ let r = [];+ if (e.address)+ if (Array.isArray(e.address))+ for (const c of e.address)+ r.push(this._getAddress(c));+ else+ r.push(this._getAddress(e.address));+ let a;+ "fromBlock" in e && (a = this._getBlockTag(e.fromBlock));+ let o;+ return "toBlock" in e && (o = this._getBlockTag(e.toBlock)), r.filter((c) => typeof c != "string").length || a != null && typeof a != "string" || o != null && typeof o != "string" ? Promise.all([Promise.all(r), a, o]).then((c) => s(c[0], c[1], c[2])) : s(r, a, o);+ }+ /**+ * Returns or resolves to a transaction for %%request%%, resolving+ * any ENS names or [[Addressable]] and returning if already a valid+ * transaction.+ */+ _getTransactionRequest(e) {+ const t = ql(e), n = [];+ if (["to", "from"].forEach((s) => {+ if (t[s] == null)+ return;+ const r = Dn(t[s], this);+ cl(r) ? n.push((async function() {+ t[s] = await r;+ })()) : t[s] = r;+ }), t.blockTag != null) {+ const s = this._getBlockTag(t.blockTag);+ cl(s) ? n.push((async function() {+ t.blockTag = await s;+ })()) : t.blockTag = s;+ }+ return n.length ? (async function() {+ return await Promise.all(n), t;+ })() : t;+ }+ async getNetwork() {+ if (this.#s == null) {+ const s = (async () => {+ try {+ const r = await this._detectNetwork();+ return this.emit("network", r, null), r;+ } catch (r) {+ throw this.#s === s && (this.#s = null), r;+ }+ })();+ return this.#s = s, (await s).clone();+ }+ const e = this.#s, [t, n] = await Promise.all([+ e,+ this._detectNetwork()+ // The actual connected network+ ]);+ return t.chainId !== n.chainId && (this.#a ? (this.emit("network", n, t), this.#s === e && (this.#s = Promise.resolve(n))) : ge(!1, `network changed: ${t.chainId} => ${n.chainId} `, "NETWORK_ERROR", {+ event: "changed"+ })), t.clone();+ }+ async getFeeData() {+ const e = await this.getNetwork(), t = async () => {+ const { _block: s, gasPrice: r, priorityFee: a } = await Tn({+ _block: this.#b("latest", !1),+ gasPrice: (async () => {+ try {+ const h = await this.#c({ method: "getGasPrice" });+ return Fe(h, "%response");+ } catch {+ }+ return null;+ })(),+ priorityFee: (async () => {+ try {+ const h = await this.#c({ method: "getPriorityFee" });+ return Fe(h, "%response");+ } catch {+ }+ return null;+ })()+ });+ let o = null, c = null;+ const l = this._wrapBlock(s, e);+ return l && l.baseFeePerGas && (c = a ?? BigInt("1000000000"), o = l.baseFeePerGas * cL + c), new Em(r, o, c);+ }, n = e.getPlugin("org.ethers.plugins.network.FetchUrlFeeDataPlugin");+ if (n) {+ const s = new ki(n.url), r = await n.processFunc(t, this, s);+ return new Em(r.gasPrice, r.maxFeePerGas, r.maxPriorityFeePerGas);+ }+ return await t();+ }+ async estimateGas(e) {+ let t = this._getTransactionRequest(e);+ return cl(t) && (t = await t), Fe(await this.#c({+ method: "estimateGas",+ transaction: t+ }), "%response");+ }+ async #h(e, t, n) {+ ge(n < lL, "CCIP read exceeded maximum redirections", "OFFCHAIN_FAULT", {+ reason: "TOO_MANY_REDIRECTS",+ transaction: Object.assign({}, e, { blockTag: t, enableCcipRead: !0 })+ });+ const s = ql(e);+ try {+ return Se(await this._perform({ method: "call", transaction: s, blockTag: t }));+ } catch (r) {+ if (!this.disableCcipRead && zf(r) && r.data && n >= 0 && t === "latest" && s.to != null && Vt(r.data, 0, 4) === "0x556f1830") {+ const a = r.data, o = await Dn(s.to, this);+ let c;+ try {+ c = mL(Vt(r.data, 4));+ } catch (u) {+ ge(!1, u.message, "OFFCHAIN_FAULT", {+ reason: "BAD_DATA",+ transaction: s,+ info: { data: a }+ });+ }+ ge(c.sender.toLowerCase() === o.toLowerCase(), "CCIP Read sender mismatch", "CALL_EXCEPTION", {+ action: "call",+ data: a,+ reason: "OffchainLookup",+ transaction: s,+ invocation: null,+ revert: {+ signature: "OffchainLookup(address,string[],bytes,bytes4,bytes)",+ name: "OffchainLookup",+ args: c.errorArgs+ }+ });+ const l = await this.ccipReadFetch(s, c.calldata, c.urls);+ ge(l != null, "CCIP Read failed to fetch data", "OFFCHAIN_FAULT", {+ reason: "FETCH_FAILED",+ transaction: s,+ info: { data: r.data, errorArgs: c.errorArgs }+ });+ const h = {+ to: o,+ data: Qt([c.selector, gL([l, c.extraData])])+ };+ this.emit("debug", { action: "sendCcipReadCall", transaction: h });+ try {+ const u = await this.#h(h, t, n + 1);+ return this.emit("debug", { action: "receiveCcipReadCallResult", transaction: Object.assign({}, h), result: u }), u;+ } catch (u) {+ throw this.emit("debug", { action: "receiveCcipReadCallError", transaction: Object.assign({}, h), error: u }), u;+ }+ }+ throw r;+ }+ }+ async #u(e) {+ const { value: t } = await Tn({+ network: this.getNetwork(),+ value: e+ });+ return t;+ }+ async call(e) {+ const { tx: t, blockTag: n } = await Tn({+ tx: this._getTransactionRequest(e),+ blockTag: this._getBlockTag(e.blockTag)+ });+ return await this.#u(this.#h(t, n, e.enableCcipRead ? 0 : -1));+ }+ // Account+ async #d(e, t, n) {+ let s = this._getAddress(t), r = this._getBlockTag(n);+ return (typeof s != "string" || typeof r != "string") && ([s, r] = await Promise.all([s, r])), await this.#u(this.#c(Object.assign(e, { address: s, blockTag: r })));+ }+ async getBalance(e, t) {+ return Fe(await this.#d({ method: "getBalance" }, e, t), "%response");+ }+ async getTransactionCount(e, t) {+ return ut(await this.#d({ method: "getTransactionCount" }, e, t), "%response");+ }+ async getCode(e, t) {+ return Se(await this.#d({ method: "getCode" }, e, t));+ }+ async getStorage(e, t, n) {+ const s = Fe(t, "position");+ return Se(await this.#d({ method: "getStorage", position: s }, e, n));+ }+ // Write+ async broadcastTransaction(e) {+ const { blockNumber: t, hash: n, network: s } = await Tn({+ blockNumber: this.getBlockNumber(),+ hash: this._perform({+ method: "broadcastTransaction",+ signedTransaction: e+ }),+ network: this.getNetwork()+ }), r = pi.from(e);+ if (r.hash !== n)+ throw new Error("@TODO: the returned hash did not match");+ return this._wrapTransactionResponse(r, s).replaceableTransaction(t);+ }+ async #b(e, t) {+ if (Lt(e, 32))+ return await this.#c({+ method: "getBlock",+ blockHash: e,+ includeTransactions: t+ });+ let n = this._getBlockTag(e);+ return typeof n != "string" && (n = await n), await this.#c({+ method: "getBlock",+ blockTag: n,+ includeTransactions: t+ });+ }+ // Queries+ async getBlock(e, t) {+ const { network: n, params: s } = await Tn({+ network: this.getNetwork(),+ params: this.#b(e, !!t)+ });+ return s == null ? null : this._wrapBlock(s, n);+ }+ async getTransaction(e) {+ const { network: t, params: n } = await Tn({+ network: this.getNetwork(),+ params: this.#c({ method: "getTransaction", hash: e })+ });+ return n == null ? null : this._wrapTransactionResponse(n, t);+ }+ async getTransactionReceipt(e) {+ const { network: t, params: n } = await Tn({+ network: this.getNetwork(),+ params: this.#c({ method: "getTransactionReceipt", hash: e })+ });+ if (n == null)+ return null;+ if (n.gasPrice == null && n.effectiveGasPrice == null) {+ const s = await this.#c({ method: "getTransaction", hash: e });+ if (s == null)+ throw new Error("report this; could not find tx or effectiveGasPrice");+ n.effectiveGasPrice = s.gasPrice;+ }+ return this._wrapTransactionReceipt(n, t);+ }+ async getTransactionResult(e) {+ const { result: t } = await Tn({+ network: this.getNetwork(),+ result: this.#c({ method: "getTransactionResult", hash: e })+ });+ return t == null ? null : Se(t);+ }+ // Bloom-filter Queries+ async getLogs(e) {+ let t = this._getFilter(e);+ cl(t) && (t = await t);+ const { network: n, params: s } = await Tn({+ network: this.getNetwork(),+ params: this.#c({ method: "getLogs", filter: t })+ });+ return s.map((r) => this._wrapLog(r, n));+ }+ // ENS+ _getProvider(e) {+ ge(!1, "provider cannot connect to target network", "UNSUPPORTED_OPERATION", {+ operation: "_getProvider()"+ });+ }+ async getResolver(e) {+ return await ya.fromName(this, e);+ }+ async getAvatar(e) {+ const t = await this.getResolver(e);+ return t ? await t.getAvatar() : null;+ }+ async resolveName(e) {+ const t = await this.getResolver(e);+ return t ? await t.getAddress() : null;+ }+ async lookupAddress(e) {+ e = St(e);+ const t = ef(e.substring(2).toLowerCase() + ".addr.reverse");+ try {+ const n = await ya.getEnsAddress(this), r = await new _r(n, [+ "function resolver(bytes32) view returns (address)"+ ], this).resolver(t);+ if (r == null || r === Vo)+ return null;+ const o = await new _r(r, [+ "function name(bytes32) view returns (string)"+ ], this).name(t);+ return await this.resolveName(o) !== e ? null : o;+ } catch (n) {+ if (_n(n, "BAD_DATA") && n.value === "0x" || _n(n, "CALL_EXCEPTION"))+ return null;+ throw n;+ }+ return null;+ }+ async waitForTransaction(e, t, n) {+ const s = t ?? 1;+ return s === 0 ? this.getTransactionReceipt(e) : new Promise(async (r, a) => {+ let o = null;+ const c = (async (l) => {+ try {+ const h = await this.getTransactionReceipt(e);+ if (h != null && l - h.blockNumber + 1 >= s) {+ r(h), o && (clearTimeout(o), o = null);+ return;+ }+ } catch (h) {+ console.log("EEE", h);+ }+ this.once("block", c);+ });+ n != null && (o = setTimeout(() => {+ o != null && (o = null, this.off("block", c), a(Ot("timeout", "TIMEOUT", { reason: "timeout" })));+ }, n)), c(await this.getBlockNumber());+ });+ }+ async waitForBlock(e) {+ ge(!1, "not implemented yet", "NOT_IMPLEMENTED", {+ operation: "waitForBlock"+ });+ }+ /**+ * Clear a timer created using the [[_setTimeout]] method.+ */+ _clearTimeout(e) {+ const t = this.#l.get(e);+ t && (t.timer && clearTimeout(t.timer), this.#l.delete(e));+ }+ /**+ * Create a timer that will execute %%func%% after at least %%timeout%%+ * (in ms). If %%timeout%% is unspecified, then %%func%% will execute+ * in the next event loop.+ *+ * [Pausing](AbstractProvider-paused) the provider will pause any+ * associated timers.+ */+ _setTimeout(e, t) {+ t == null && (t = 0);+ const n = this.#f++, s = () => {+ this.#l.delete(n), e();+ };+ if (this.paused)+ this.#l.set(n, { timer: null, func: s, time: t });+ else {+ const r = setTimeout(s, t);+ this.#l.set(n, { timer: r, func: s, time: Ru() });+ }+ return n;+ }+ /**+ * Perform %%func%% on each subscriber.+ */+ _forEachSubscriber(e) {+ for (const t of this.#e.values())+ e(t.subscriber);+ }+ /**+ * Sub-classes may override this to customize subscription+ * implementations.+ */+ _getSubscriber(e) {+ switch (e.type) {+ case "debug":+ case "error":+ case "network":+ return new $x(e.type);+ case "block": {+ const t = new sL(this);+ return t.pollingInterval = this.pollingInterval, t;+ }+ case "safe":+ case "finalized":+ return new rL(this, e.type);+ case "event":+ return new lp(this, e.filter);+ case "transaction":+ return new oL(this, e.hash);+ case "orphan":+ return new aL(this, e.filter);+ }+ throw new Error(`unsupported event: ${e.type}`);+ }+ /**+ * If a [[Subscriber]] fails and needs to replace itself, this+ * method may be used.+ *+ * For example, this is used for providers when using the+ * ``eth_getFilterChanges`` method, which can return null if state+ * filters are not supported by the backend, allowing the Subscriber+ * to swap in a [[PollingEventSubscriber]].+ */+ _recoverSubscriber(e, t) {+ for (const n of this.#e.values())+ if (n.subscriber === e) {+ n.started && n.subscriber.stop(), n.subscriber = t, n.started && t.start(), this.#n != null && t.pause(this.#n);+ break;+ }+ }+ async #g(e, t) {+ let n = await Tu(e, this);+ return n.type === "event" && t && t.length > 0 && t[0].removed === !0 && (n = await Tu({ orphan: "drop-log", log: t[0] }, this)), this.#e.get(n.tag) || null;+ }+ async #m(e) {+ const t = await Tu(e, this), n = t.tag;+ let s = this.#e.get(n);+ return s || (s = { subscriber: this._getSubscriber(t), tag: n, addressableMap: /* @__PURE__ */ new WeakMap(), nameMap: /* @__PURE__ */ new Map(), started: !1, listeners: [] }, this.#e.set(n, s)), s;+ }+ async on(e, t) {+ const n = await this.#m(e);+ return n.listeners.push({ listener: t, once: !1 }), n.started || (n.subscriber.start(), n.started = !0, this.#n != null && n.subscriber.pause(this.#n)), this;+ }+ async once(e, t) {+ const n = await this.#m(e);+ return n.listeners.push({ listener: t, once: !0 }), n.started || (n.subscriber.start(), n.started = !0, this.#n != null && n.subscriber.pause(this.#n)), this;+ }+ async emit(e, ...t) {+ const n = await this.#g(e, t);+ if (!n || n.listeners.length === 0)+ return !1;+ const s = n.listeners.length;+ return n.listeners = n.listeners.filter(({ listener: r, once: a }) => {+ const o = new xb(this, a ? null : r, e);+ try {+ r.call(this, ...t, o);+ } catch {+ }+ return !a;+ }), n.listeners.length === 0 && (n.started && n.subscriber.stop(), this.#e.delete(n.tag)), s > 0;+ }+ async listenerCount(e) {+ if (e) {+ const n = await this.#g(e);+ return n ? n.listeners.length : 0;+ }+ let t = 0;+ for (const { listeners: n } of this.#e.values())+ t += n.length;+ return t;+ }+ async listeners(e) {+ if (e) {+ const n = await this.#g(e);+ return n ? n.listeners.map(({ listener: s }) => s) : [];+ }+ let t = [];+ for (const { listeners: n } of this.#e.values())+ t = t.concat(n.map(({ listener: s }) => s));+ return t;+ }+ async off(e, t) {+ const n = await this.#g(e);+ if (!n)+ return this;+ if (t) {+ const s = n.listeners.map(({ listener: r }) => r).indexOf(t);+ s >= 0 && n.listeners.splice(s, 1);+ }+ return (!t || n.listeners.length === 0) && (n.started && n.subscriber.stop(), this.#e.delete(n.tag)), this;+ }+ async removeAllListeners(e) {+ if (e) {+ const { tag: t, started: n, subscriber: s } = await this.#m(e);+ n && s.stop(), this.#e.delete(t);+ } else+ for (const [t, { started: n, subscriber: s }] of this.#e)+ n && s.stop(), this.#e.delete(t);+ return this;+ }+ // Alias for "on"+ async addListener(e, t) {+ return await this.on(e, t);+ }+ // Alias for "off"+ async removeListener(e, t) {+ return this.off(e, t);+ }+ /**+ * If this provider has been destroyed using the [[destroy]] method.+ *+ * Once destroyed, all resources are reclaimed, internal event loops+ * and timers are cleaned up and no further requests may be sent to+ * the provider.+ */+ get destroyed() {+ return this.#i;+ }+ /**+ * Sub-classes may use this to shutdown any sockets or release their+ * resources and reject any pending requests.+ *+ * Sub-classes **must** call ``super.destroy()``.+ */+ destroy() {+ this.removeAllListeners();+ for (const e of this.#l.keys())+ this._clearTimeout(e);+ this.#i = !0;+ }+ /**+ * Whether the provider is currently paused.+ *+ * A paused provider will not emit any events, and generally should+ * not make any requests to the network, but that is up to sub-classes+ * to manage.+ *+ * Setting ``paused = true`` is identical to calling ``.pause(false)``,+ * which will buffer any events that occur while paused until the+ * provider is unpaused.+ */+ get paused() {+ return this.#n != null;+ }+ set paused(e) {+ !!e !== this.paused && (this.paused ? this.resume() : this.pause(!1));+ }+ /**+ * Pause the provider. If %%dropWhilePaused%%, any events that occur+ * while paused are dropped, otherwise all events will be emitted once+ * the provider is unpaused.+ */+ pause(e) {+ if (this.#o = -1, this.#n != null) {+ if (this.#n == !!e)+ return;+ ge(!1, "cannot change pause type; resume first", "UNSUPPORTED_OPERATION", {+ operation: "pause"+ });+ }+ this._forEachSubscriber((t) => t.pause(e)), this.#n = !!e;+ for (const t of this.#l.values())+ t.timer && clearTimeout(t.timer), t.time = Ru() - t.time;+ }+ /**+ * Resume the provider.+ */+ resume() {+ if (this.#n != null) {+ this._forEachSubscriber((e) => e.resume()), this.#n = null;+ for (const e of this.#l.values()) {+ let t = e.time;+ t < 0 && (t = 0), e.time = Ru(), setTimeout(e.func, t);+ }+ }+ }+}+function fL(i, e) {+ try {+ const t = af(i, e);+ if (t)+ return Ol(t);+ } catch {+ }+ return null;+}+function af(i, e) {+ if (i === "0x")+ return null;+ try {+ const t = ut(Vt(i, e, e + 32)), n = ut(Vt(i, t, t + 32));+ return Vt(i, t + 32, t + 32 + n);+ } catch {+ }+ return null;+}+function Bm(i) {+ const e = $t(i);+ if (e.length > 32)+ throw new Error("internal; should not happen");+ const t = new Uint8Array(32);+ return t.set(e, 32 - e.length), t;+}+function pL(i) {+ if (i.length % 32 === 0)+ return i;+ const e = new Uint8Array(Math.ceil(i.length / 32) * 32);+ return e.set(i), e;+}+const AL = new Uint8Array([]);+function gL(i) {+ const e = [];+ let t = 0;+ for (let n = 0; n < i.length; n++)+ e.push(AL), t += 32;+ for (let n = 0; n < i.length; n++) {+ const s = ht(i[n]);+ e[n] = Bm(t), e.push(Bm(s.length)), e.push(pL(s)), t += 32 + Math.ceil(s.length / 32) * 32;+ }+ return Qt(e);+}+const Tm = "0x0000000000000000000000000000000000000000000000000000000000000000";+function mL(i) {+ const e = {+ sender: "",+ urls: [],+ calldata: "",+ selector: "",+ extraData: "",+ errorArgs: []+ };+ ge(xa(i) >= 160, "insufficient OffchainLookup data", "OFFCHAIN_FAULT", {+ reason: "insufficient OffchainLookup data"+ });+ const t = Vt(i, 0, 32);+ ge(Vt(t, 0, 12) === Vt(Tm, 0, 12), "corrupt OffchainLookup sender", "OFFCHAIN_FAULT", {+ reason: "corrupt OffchainLookup sender"+ }), e.sender = Vt(t, 12);+ try {+ const n = [], s = ut(Vt(i, 32, 64)), r = ut(Vt(i, s, s + 32)), a = Vt(i, s + 32);+ for (let o = 0; o < r; o++) {+ const c = fL(a, o * 32);+ if (c == null)+ throw new Error("abort");+ n.push(c);+ }+ e.urls = n;+ } catch {+ ge(!1, "corrupt OffchainLookup urls", "OFFCHAIN_FAULT", {+ reason: "corrupt OffchainLookup urls"+ });+ }+ try {+ const n = af(i, 64);+ if (n == null)+ throw new Error("abort");+ e.calldata = n;+ } catch {+ ge(!1, "corrupt OffchainLookup calldata", "OFFCHAIN_FAULT", {+ reason: "corrupt OffchainLookup calldata"+ });+ }+ ge(Vt(i, 100, 128) === Vt(Tm, 0, 28), "corrupt OffchainLookup callbaackSelector", "OFFCHAIN_FAULT", {+ reason: "corrupt OffchainLookup callbaackSelector"+ }), e.selector = Vt(i, 96, 100);+ try {+ const n = af(i, 128);+ if (n == null)+ throw new Error("abort");+ e.extraData = n;+ } catch {+ ge(!1, "corrupt OffchainLookup extraData", "OFFCHAIN_FAULT", {+ reason: "corrupt OffchainLookup extraData"+ });+ }+ return e.errorArgs = "sender,urls,calldata,selector,extraData".split(/,/).map((n) => e[n]), e;+}+function nr(i, e) {+ if (i.provider)+ return i.provider;+ ge(!1, "missing provider", "UNSUPPORTED_OPERATION", { operation: e });+}+async function Rm(i, e) {+ let t = ql(e);+ if (t.to != null && (t.to = Dn(t.to, i)), t.from != null) {+ const n = t.from;+ t.from = Promise.all([+ i.getAddress(),+ Dn(n, i)+ ]).then(([s, r]) => (V(s.toLowerCase() === r.toLowerCase(), "transaction from mismatch", "tx.from", r), s));+ } else+ t.from = i.getAddress();+ return await Tn(t);+}+class bL {+ /**+ * The provider this signer is connected to.+ */+ provider;+ /**+ * Creates a new Signer connected to %%provider%%.+ */+ constructor(e) {+ Xe(this, { provider: e || null });+ }+ async getNonce(e) {+ return nr(this, "getTransactionCount").getTransactionCount(await this.getAddress(), e);+ }+ async populateCall(e) {+ return await Rm(this, e);+ }+ async populateTransaction(e) {+ const t = nr(this, "populateTransaction"), n = await Rm(this, e);+ n.nonce == null && (n.nonce = await this.getNonce("pending")), n.gasLimit == null && (n.gasLimit = await this.estimateGas(n));+ const s = await this.provider.getNetwork();+ if (n.chainId != null) {+ const a = Fe(n.chainId);+ V(a === s.chainId, "transaction chainId mismatch", "tx.chainId", e.chainId);+ } else+ n.chainId = s.chainId;+ const r = n.maxFeePerGas != null || n.maxPriorityFeePerGas != null;+ if (n.gasPrice != null && (n.type === 2 || r) ? V(!1, "eip-1559 transaction do not support gasPrice", "tx", e) : (n.type === 0 || n.type === 1) && r && V(!1, "pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas", "tx", e), (n.type === 2 || n.type == null) && n.maxFeePerGas != null && n.maxPriorityFeePerGas != null)+ n.type = 2;+ else if (n.type === 0 || n.type === 1) {+ const a = await t.getFeeData();+ ge(a.gasPrice != null, "network does not support gasPrice", "UNSUPPORTED_OPERATION", {+ operation: "getGasPrice"+ }), n.gasPrice == null && (n.gasPrice = a.gasPrice);+ } else {+ const a = await t.getFeeData();+ if (n.type == null)+ if (a.maxFeePerGas != null && a.maxPriorityFeePerGas != null)+ if (n.authorizationList && n.authorizationList.length ? n.type = 4 : n.type = 2, n.gasPrice != null) {+ const o = n.gasPrice;+ delete n.gasPrice, n.maxFeePerGas = o, n.maxPriorityFeePerGas = o;+ } else+ n.maxFeePerGas == null && (n.maxFeePerGas = a.maxFeePerGas), n.maxPriorityFeePerGas == null && (n.maxPriorityFeePerGas = a.maxPriorityFeePerGas);+ else a.gasPrice != null ? (ge(!r, "network does not support EIP-1559", "UNSUPPORTED_OPERATION", {+ operation: "populateTransaction"+ }), n.gasPrice == null && (n.gasPrice = a.gasPrice), n.type = 0) : ge(!1, "failed to get consistent fee data", "UNSUPPORTED_OPERATION", {+ operation: "signer.getFeeData"+ });+ else (n.type === 2 || n.type === 3 || n.type === 4) && (n.maxFeePerGas == null && (n.maxFeePerGas = a.maxFeePerGas), n.maxPriorityFeePerGas == null && (n.maxPriorityFeePerGas = a.maxPriorityFeePerGas));+ }+ return await Tn(n);+ }+ async populateAuthorization(e) {+ const t = Object.assign({}, e);+ return t.chainId == null && (t.chainId = (await nr(this, "getNetwork").getNetwork()).chainId), t.nonce == null && (t.nonce = await this.getNonce()), t;+ }+ async estimateGas(e) {+ return nr(this, "estimateGas").estimateGas(await this.populateCall(e));+ }+ async call(e) {+ return nr(this, "call").call(await this.populateCall(e));+ }+ async resolveName(e) {+ return await nr(this, "resolveName").resolveName(e);+ }+ async sendTransaction(e) {+ const t = nr(this, "sendTransaction"), n = await this.populateTransaction(e);+ delete n.from;+ const s = pi.from(n);+ return await t.broadcastTransaction(await this.signTransaction(s));+ }+ // @TODO: in v7 move this to be abstract+ authorize(e) {+ ge(!1, "authorization not implemented for this signer", "UNSUPPORTED_OPERATION", { operation: "authorize" });+ }+}+function xL(i) {+ return JSON.parse(JSON.stringify(i));+}+class e_ {+ #e;+ #t;+ #n;+ #i;+ #s;+ #a;+ /**+ * Creates a new **FilterIdSubscriber** which will used [[_subscribe]]+ * and [[_emitResults]] to setup the subscription and provide the event+ * to the %%provider%%.+ */+ constructor(e) {+ this.#e = e, this.#t = null, this.#n = this.#r.bind(this), this.#i = !1, this.#s = null, this.#a = !1;+ }+ /**+ * Sub-classes **must** override this to begin the subscription.+ */+ _subscribe(e) {+ throw new Error("subclasses must override this");+ }+ /**+ * Sub-classes **must** override this handle the events.+ */+ _emitResults(e, t) {+ throw new Error("subclasses must override this");+ }+ /**+ * Sub-classes **must** override this handle recovery on errors.+ */+ _recover(e) {+ throw new Error("subclasses must override this");+ }+ async #r(e) {+ try {+ this.#t == null && (this.#t = this._subscribe(this.#e));+ let t = null;+ try {+ t = await this.#t;+ } catch (r) {+ if (!_n(r, "UNSUPPORTED_OPERATION") || r.operation !== "eth_newFilter")+ throw r;+ }+ if (t == null) {+ this.#t = null, this.#e._recoverSubscriber(this, this._recover(this.#e));+ return;+ }+ const n = await this.#e.getNetwork();+ if (this.#s || (this.#s = n), this.#s.chainId !== n.chainId)+ throw new Error("chaid changed");+ if (this.#a)+ return;+ const s = await this.#e.send("eth_getFilterChanges", [t]);+ await this._emitResults(this.#e, s);+ } catch (t) {+ console.log("@TODO", t);+ }+ this.#e.once("block", this.#n);+ }+ #o() {+ const e = this.#t;+ e && (this.#t = null, e.then((t) => {+ this.#e.destroyed || this.#e.send("eth_uninstallFilter", [t]);+ }));+ }+ start() {+ this.#i || (this.#i = !0, this.#r(-2));+ }+ stop() {+ this.#i && (this.#i = !1, this.#a = !0, this.#o(), this.#e.off("block", this.#n));+ }+ pause(e) {+ e && this.#o(), this.#e.off("block", this.#n);+ }+ resume() {+ this.start();+ }+}+class _L extends e_ {+ #e;+ /**+ * Creates a new **FilterIdEventSubscriber** attached to %%provider%%+ * listening for %%filter%%.+ */+ constructor(e, t) {+ super(e), this.#e = xL(t);+ }+ _recover(e) {+ return new lp(e, this.#e);+ }+ async _subscribe(e) {+ return await e.send("eth_newFilter", [this.#e]);+ }+ async _emitResults(e, t) {+ for (const n of t)+ e.emit(this.#e, e._wrapLog(n, e._network));+ }+}+class EL extends e_ {+ async _subscribe(e) {+ return await e.send("eth_newPendingTransactionFilter", []);+ }+ async _emitResults(e, t) {+ for (const n of t)+ e.emit("pending", n);+ }+}+const yL = "bigint,boolean,function,number,string,symbol".split(/,/g);+function _l(i) {+ if (i == null || yL.indexOf(typeof i) >= 0 || typeof i.getAddress == "function")+ return i;+ if (Array.isArray(i))+ return i.map(_l);+ if (typeof i == "object")+ return Object.keys(i).reduce((e, t) => (e[t] = i[t], e), {});+ throw new Error(`should not happen: ${i} (${typeof i})`);+}+function wL(i) {+ return new Promise((e) => {+ setTimeout(e, i);+ });+}+function $r(i) {+ return i && i.toLowerCase();+}+function Nm(i) {+ return i && typeof i.pollingInterval == "number";+}+const t_ = {+ polling: !1,+ staticNetwork: null,+ batchStallTime: 10,+ batchMaxSize: 1 << 20,+ batchMaxCount: 100,+ cacheTimeout: 250,+ pollingInterval: 4e3+};+class Nu extends bL {+ address;+ constructor(e, t) {+ super(e), t = St(t), Xe(this, { address: t });+ }+ connect(e) {+ ge(!1, "cannot reconnect JsonRpcSigner", "UNSUPPORTED_OPERATION", {+ operation: "signer.connect"+ });+ }+ async getAddress() {+ return this.address;+ }+ // JSON-RPC will automatially fill in nonce, etc. so we just check from+ async populateTransaction(e) {+ return await this.populateCall(e);+ }+ // Returns just the hash of the transaction after sent, which is what+ // the bare JSON-RPC API does;+ async sendUncheckedTransaction(e) {+ const t = _l(e), n = [];+ if (t.from) {+ const r = t.from;+ n.push((async () => {+ const a = await Dn(r, this.provider);+ V(a != null && a.toLowerCase() === this.address.toLowerCase(), "from address mismatch", "transaction", e), t.from = a;+ })());+ } else+ t.from = this.address;+ if (t.gasLimit == null && n.push((async () => {+ t.gasLimit = await this.provider.estimateGas({ ...t, from: this.address });+ })()), t.to != null) {+ const r = t.to;+ n.push((async () => {+ t.to = await Dn(r, this.provider);+ })());+ }+ n.length && await Promise.all(n);+ const s = this.provider.getRpcTransaction(t);+ return this.provider.send("eth_sendTransaction", [s]);+ }+ async sendTransaction(e) {+ const t = await this.provider.getBlockNumber(), n = await this.sendUncheckedTransaction(e);+ return await new Promise((s, r) => {+ const a = [1e3, 100];+ let o = 0;+ const c = async () => {+ try {+ const l = await this.provider.getTransaction(n);+ if (l != null) {+ s(l.replaceableTransaction(t));+ return;+ }+ } catch (l) {+ if (_n(l, "CANCELLED") || _n(l, "BAD_DATA") || _n(l, "NETWORK_ERROR") || _n(l, "UNSUPPORTED_OPERATION")) {+ l.info == null && (l.info = {}), l.info.sendTransactionHash = n, r(l);+ return;+ }+ if (_n(l, "INVALID_ARGUMENT") && (o++, l.info == null && (l.info = {}), l.info.sendTransactionHash = n, o > 10)) {+ r(l);+ return;+ }+ this.provider.emit("error", Ot("failed to fetch transation after sending (will try again)", "UNKNOWN_ERROR", { error: l }));+ }+ this.provider._setTimeout(() => {+ c();+ }, a.pop() || 4e3);+ };+ c();+ });+ }+ async signTransaction(e) {+ const t = _l(e);+ if (t.from) {+ const s = await Dn(t.from, this.provider);+ V(s != null && s.toLowerCase() === this.address.toLowerCase(), "from address mismatch", "transaction", e), t.from = s;+ } else+ t.from = this.address;+ const n = this.provider.getRpcTransaction(t);+ return await this.provider.send("eth_signTransaction", [n]);+ }+ async signMessage(e) {+ const t = typeof e == "string" ? cs(e) : e;+ return await this.provider.send("personal_sign", [+ Se(t),+ this.address.toLowerCase()+ ]);+ }+ async signTypedData(e, t, n) {+ const s = _l(n), r = await Kn.resolveNames(e, t, s, async (a) => {+ const o = await Dn(a);+ return V(o != null, "TypedData does not support null address", "value", a), o;+ });+ return await this.provider.send("eth_signTypedData_v4", [+ this.address.toLowerCase(),+ JSON.stringify(Kn.getPayload(r.domain, t, r.value))+ ]);+ }+ async unlock(e) {+ return this.provider.send("personal_unlockAccount", [+ this.address.toLowerCase(),+ e,+ null+ ]);+ }+ // https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign+ async _legacySignMessage(e) {+ const t = typeof e == "string" ? cs(e) : e;+ return await this.provider.send("eth_sign", [+ this.address.toLowerCase(),+ Se(t)+ ]);+ }+}+class vL extends dL {+ #e;+ // The next ID to use for the JSON-RPC ID field+ #t;+ // Payloads are queued and triggered in batches using the drainTimer+ #n;+ #i;+ #s;+ #a;+ #r;+ #o() {+ if (this.#i)+ return;+ const e = this._getOption("batchMaxCount") === 1 ? 0 : this._getOption("batchStallTime");+ this.#i = setTimeout(() => {+ this.#i = null;+ const t = this.#n;+ for (this.#n = []; t.length; ) {+ const n = [t.shift()];+ for (; t.length && n.length !== this.#e.batchMaxCount; )+ if (n.push(t.shift()), JSON.stringify(n.map((r) => r.payload)).length > this.#e.batchMaxSize) {+ t.unshift(n.pop());+ break;+ }+ (async () => {+ const s = n.length === 1 ? n[0].payload : n.map((r) => r.payload);+ this.emit("debug", { action: "sendRpcPayload", payload: s });+ try {+ const r = await this._send(s);+ this.emit("debug", { action: "receiveRpcResult", result: r });+ for (const { resolve: a, reject: o, payload: c } of n) {+ if (this.destroyed) {+ o(Ot("provider destroyed; cancelled request", "UNSUPPORTED_OPERATION", { operation: c.method }));+ continue;+ }+ const l = r.filter((h) => h.id === c.id)[0];+ if (l == null) {+ const h = Ot("missing response for request", "BAD_DATA", {+ value: r,+ info: { payload: c }+ });+ this.emit("error", h), o(h);+ continue;+ }+ if ("error" in l) {+ o(this.getRpcError(c, l));+ continue;+ }+ a(l.result);+ }+ } catch (r) {+ this.emit("debug", { action: "receiveRpcError", error: r });+ for (const { reject: a } of n)+ a(r);+ }+ })();+ }+ }, e);+ }+ constructor(e, t) {+ super(e, t), this.#t = 1, this.#e = Object.assign({}, t_, t || {}), this.#n = [], this.#i = null, this.#a = null, this.#r = null;+ {+ let s = null;+ const r = new Promise((a) => {+ s = a;+ });+ this.#s = { promise: r, resolve: s };+ }+ const n = this._getOption("staticNetwork");+ typeof n == "boolean" ? (V(!n || e !== "any", "staticNetwork cannot be used on special network 'any'", "options", t), n && e != null && (this.#a = Xn.from(e))) : n && (V(e == null || n.matches(e), "staticNetwork MUST match network object", "options", t), this.#a = n);+ }+ /**+ * Returns the value associated with the option %%key%%.+ *+ * Sub-classes can use this to inquire about configuration options.+ */+ _getOption(e) {+ return this.#e[e];+ }+ /**+ * Gets the [[Network]] this provider has committed to. On each call, the network+ * is detected, and if it has changed, the call will reject.+ */+ get _network() {+ return ge(this.#a, "network is not available yet", "NETWORK_ERROR"), this.#a;+ }+ /**+ * Resolves to the non-normalized value by performing %%req%%.+ *+ * Sub-classes may override this to modify behavior of actions,+ * and should generally call ``super._perform`` as a fallback.+ */+ async _perform(e) {+ if (e.method === "call" || e.method === "estimateGas") {+ let n = e.transaction;+ if (n && n.type != null && Fe(n.type) && n.maxFeePerGas == null && n.maxPriorityFeePerGas == null) {+ const s = await this.getFeeData();+ s.maxFeePerGas == null && s.maxPriorityFeePerGas == null && (e = Object.assign({}, e, {+ transaction: Object.assign({}, n, { type: void 0 })+ }));+ }+ }+ const t = this.getRpcRequest(e);+ return t != null ? await this.send(t.method, t.args) : super._perform(e);+ }+ /**+ * Sub-classes may override this; it detects the *actual* network that+ * we are **currently** connected to.+ *+ * Keep in mind that [[send]] may only be used once [[ready]], otherwise the+ * _send primitive must be used instead.+ */+ async _detectNetwork() {+ const e = this._getOption("staticNetwork");+ if (e)+ if (e === !0) {+ if (this.#a)+ return this.#a;+ } else+ return e;+ return this.#r ? await this.#r : this.ready ? (this.#r = (async () => {+ try {+ const t = Xn.from(Fe(await this.send("eth_chainId", [])));+ return this.#r = null, t;+ } catch (t) {+ throw this.#r = null, t;+ }+ })(), await this.#r) : (this.#r = (async () => {+ const t = {+ id: this.#t++,+ method: "eth_chainId",+ params: [],+ jsonrpc: "2.0"+ };+ this.emit("debug", { action: "sendRpcPayload", payload: t });+ let n;+ try {+ n = (await this._send(t))[0], this.#r = null;+ } catch (s) {+ throw this.#r = null, this.emit("debug", { action: "receiveRpcError", error: s }), s;+ }+ if (this.emit("debug", { action: "receiveRpcResult", result: n }), "result" in n)+ return Xn.from(Fe(n.result));+ throw this.getRpcError(t, n);+ })(), await this.#r);+ }+ /**+ * Sub-classes **MUST** call this. Until [[_start]] has been called, no calls+ * will be passed to [[_send]] from [[send]]. If it is overridden, then+ * ``super._start()`` **MUST** be called.+ *+ * Calling it multiple times is safe and has no effect.+ */+ _start() {+ this.#s == null || this.#s.resolve == null || (this.#s.resolve(), this.#s = null, (async () => {+ for (; this.#a == null && !this.destroyed; )+ try {+ this.#a = await this._detectNetwork();+ } catch (e) {+ if (this.destroyed)+ break;+ console.log("JsonRpcProvider failed to detect network and cannot start up; retry in 1s (perhaps the URL is wrong or the node is not started)"), this.emit("error", Ot("failed to bootstrap network detection", "NETWORK_ERROR", { event: "initial-network-discovery", info: { error: e } })), await wL(1e3);+ }+ this.#o();+ })());+ }+ /**+ * Resolves once the [[_start]] has been called. This can be used in+ * sub-classes to defer sending data until the connection has been+ * established.+ */+ async _waitUntilReady() {+ if (this.#s != null)+ return await this.#s.promise;+ }+ /**+ * Return a Subscriber that will manage the %%sub%%.+ *+ * Sub-classes may override this to modify the behavior of+ * subscription management.+ */+ _getSubscriber(e) {+ return e.type === "pending" ? new EL(this) : e.type === "event" ? this._getOption("polling") ? new lp(this, e.filter) : new _L(this, e.filter) : e.type === "orphan" && e.filter.orphan === "drop-log" ? new $x("orphan") : super._getSubscriber(e);+ }+ /**+ * Returns true only if the [[_start]] has been called.+ */+ get ready() {+ return this.#s == null;+ }+ /**+ * Returns %%tx%% as a normalized JSON-RPC transaction request,+ * which has all values hexlified and any numeric values converted+ * to Quantity values.+ */+ getRpcTransaction(e) {+ const t = {};+ return ["chainId", "gasLimit", "gasPrice", "type", "maxFeePerGas", "maxPriorityFeePerGas", "nonce", "value"].forEach((n) => {+ if (e[n] == null)+ return;+ let s = n;+ n === "gasLimit" && (s = "gas"), t[s] = Ai(Fe(e[n], `tx.${n}`));+ }), ["from", "to", "data"].forEach((n) => {+ e[n] != null && (t[n] = Se(e[n]));+ }), e.accessList && (t.accessList = Rr(e.accessList)), e.blobVersionedHashes && (t.blobVersionedHashes = e.blobVersionedHashes.map((n) => n.toLowerCase())), e.authorizationList && (t.authorizationList = e.authorizationList.map((n) => {+ const s = ax(n);+ return {+ address: s.address,+ nonce: Ai(s.nonce),+ chainId: Ai(s.chainId),+ yParity: Ai(s.signature.yParity),+ r: Ai(s.signature.r),+ s: Ai(s.signature.s)+ };+ })), t;+ }+ /**+ * Returns the request method and arguments required to perform+ * %%req%%.+ */+ getRpcRequest(e) {+ switch (e.method) {+ case "chainId":+ return { method: "eth_chainId", args: [] };+ case "getBlockNumber":+ return { method: "eth_blockNumber", args: [] };+ case "getGasPrice":+ return { method: "eth_gasPrice", args: [] };+ case "getPriorityFee":+ return { method: "eth_maxPriorityFeePerGas", args: [] };+ case "getBalance":+ return {+ method: "eth_getBalance",+ args: [$r(e.address), e.blockTag]+ };+ case "getTransactionCount":+ return {+ method: "eth_getTransactionCount",+ args: [$r(e.address), e.blockTag]+ };+ case "getCode":+ return {+ method: "eth_getCode",+ args: [$r(e.address), e.blockTag]+ };+ case "getStorage":+ return {+ method: "eth_getStorageAt",+ args: [+ $r(e.address),+ "0x" + e.position.toString(16),+ e.blockTag+ ]+ };+ case "broadcastTransaction":+ return {+ method: "eth_sendRawTransaction",+ args: [e.signedTransaction]+ };+ case "getBlock":+ if ("blockTag" in e)+ return {+ method: "eth_getBlockByNumber",+ args: [e.blockTag, !!e.includeTransactions]+ };+ if ("blockHash" in e)+ return {+ method: "eth_getBlockByHash",+ args: [e.blockHash, !!e.includeTransactions]+ };+ break;+ case "getTransaction":+ return {+ method: "eth_getTransactionByHash",+ args: [e.hash]+ };+ case "getTransactionReceipt":+ return {+ method: "eth_getTransactionReceipt",+ args: [e.hash]+ };+ case "call":+ return {+ method: "eth_call",+ args: [this.getRpcTransaction(e.transaction), e.blockTag]+ };+ case "estimateGas":+ return {+ method: "eth_estimateGas",+ args: [this.getRpcTransaction(e.transaction)]+ };+ case "getLogs":+ return e.filter && e.filter.address != null && (Array.isArray(e.filter.address) ? e.filter.address = e.filter.address.map($r) : e.filter.address = $r(e.filter.address)), { method: "eth_getLogs", args: [e.filter] };+ }+ return null;+ }+ /**+ * Returns an ethers-style Error for the given JSON-RPC error+ * %%payload%%, coalescing the various strings and error shapes+ * that different nodes return, coercing them into a machine-readable+ * standardized error.+ */+ getRpcError(e, t) {+ const { method: n } = e, { error: s } = t;+ if (n === "eth_estimateGas" && s.message) {+ const o = s.message;+ if (!o.match(/revert/i) && o.match(/insufficient funds/i))+ return Ot("insufficient funds", "INSUFFICIENT_FUNDS", {+ transaction: e.params[0],+ info: { payload: e, error: s }+ });+ if (o.match(/nonce/i) && o.match(/too low/i))+ return Ot("nonce has already been used", "NONCE_EXPIRED", {+ transaction: e.params[0],+ info: { payload: e, error: s }+ });+ }+ if (n === "eth_call" || n === "eth_estimateGas") {+ const o = of(s), c = Pa.getBuiltinCallException(n === "eth_call" ? "call" : "estimateGas", e.params[0], o ? o.data : null);+ return c.info = { error: s, payload: e }, c;+ }+ const r = JSON.stringify(CL(s));+ if (typeof s.message == "string" && s.message.match(/user denied|ethers-user-denied/i))+ return Ot("user rejected action", "ACTION_REJECTED", {+ action: {+ eth_sign: "signMessage",+ personal_sign: "signMessage",+ eth_signTypedData_v4: "signTypedData",+ eth_signTransaction: "signTransaction",+ eth_sendTransaction: "sendTransaction",+ eth_requestAccounts: "requestAccess",+ wallet_requestAccounts: "requestAccess"+ }[n] || "unknown",+ reason: "rejected",+ info: { payload: e, error: s }+ });+ if (n === "eth_sendRawTransaction" || n === "eth_sendTransaction") {+ const o = e.params[0];+ if (r.match(/insufficient funds|base fee exceeds gas limit/i))+ return Ot("insufficient funds for intrinsic transaction cost", "INSUFFICIENT_FUNDS", {+ transaction: o,+ info: { error: s }+ });+ if (r.match(/nonce/i) && r.match(/too low/i))+ return Ot("nonce has already been used", "NONCE_EXPIRED", { transaction: o, info: { error: s } });+ if (r.match(/replacement transaction/i) && r.match(/underpriced/i))+ return Ot("replacement fee too low", "REPLACEMENT_UNDERPRICED", { transaction: o, info: { error: s } });+ if (r.match(/only replay-protected/i))+ return Ot("legacy pre-eip-155 transactions not supported", "UNSUPPORTED_OPERATION", {+ operation: n,+ info: { transaction: o, info: { error: s } }+ });+ }+ let a = !!r.match(/the method .* does not exist/i);+ return a || s && s.details && s.details.startsWith("Unauthorized method:") && (a = !0), a ? Ot("unsupported operation", "UNSUPPORTED_OPERATION", {+ operation: e.method,+ info: { error: s, payload: e }+ }) : Ot("could not coalesce error", "UNKNOWN_ERROR", { error: s, payload: e });+ }+ /**+ * Requests the %%method%% with %%params%% via the JSON-RPC protocol+ * over the underlying channel. This can be used to call methods+ * on the backend that do not have a high-level API within the Provider+ * API.+ *+ * This method queues requests according to the batch constraints+ * in the options, assigns the request a unique ID.+ *+ * **Do NOT override** this method in sub-classes; instead+ * override [[_send]] or force the options values in the+ * call to the constructor to modify this method's behavior.+ */+ send(e, t) {+ if (this.destroyed)+ return Promise.reject(Ot("provider destroyed; cancelled request", "UNSUPPORTED_OPERATION", { operation: e }));+ const n = this.#t++, s = new Promise((r, a) => {+ this.#n.push({+ resolve: r,+ reject: a,+ payload: { method: e, params: t, id: n, jsonrpc: "2.0" }+ });+ });+ return this.#o(), s;+ }+ /**+ * Resolves to the [[Signer]] account for %%address%% managed by+ * the client.+ *+ * If the %%address%% is a number, it is used as an index in the+ * the accounts from [[listAccounts]].+ *+ * This can only be used on clients which manage accounts (such as+ * Geth with imported account or MetaMask).+ *+ * Throws if the account doesn't exist.+ */+ async getSigner(e) {+ e == null && (e = 0);+ const t = this.send("eth_accounts", []);+ if (typeof e == "number") {+ const s = await t;+ if (e >= s.length)+ throw new Error("no such account");+ return new Nu(this, s[e]);+ }+ const { accounts: n } = await Tn({+ network: this.getNetwork(),+ accounts: t+ });+ e = St(e);+ for (const s of n)+ if (St(s) === e)+ return new Nu(this, e);+ throw new Error("invalid account");+ }+ async listAccounts() {+ return (await this.send("eth_accounts", [])).map((t) => new Nu(this, t));+ }+ destroy() {+ this.#i && (clearTimeout(this.#i), this.#i = null);+ for (const { payload: e, reject: t } of this.#n)+ t(Ot("provider destroyed; cancelled request", "UNSUPPORTED_OPERATION", { operation: e.method }));+ this.#n = [], super.destroy();+ }+}+class n_ extends vL {+ #e;+ constructor(e, t) {+ super(e, t);+ let n = this._getOption("pollingInterval");+ n == null && (n = t_.pollingInterval), this.#e = n;+ }+ _getSubscriber(e) {+ const t = super._getSubscriber(e);+ return Nm(t) && (t.pollingInterval = this.#e), t;+ }+ /**+ * The polling interval (default: 4000 ms)+ */+ get pollingInterval() {+ return this.#e;+ }+ set pollingInterval(e) {+ if (!Number.isInteger(e) || e < 0)+ throw new Error("invalid interval");+ this.#e = e, this._forEachSubscriber((t) => {+ Nm(t) && (t.pollingInterval = this.#e);+ });+ }+}+class i_ extends n_ {+ #e;+ constructor(e, t, n) {+ e == null && (e = "http://localhost:8545"), super(t, n), typeof e == "string" ? this.#e = new ki(e) : this.#e = e.clone();+ }+ _getConnection() {+ return this.#e.clone();+ }+ async send(e, t) {+ return await this._start(), await super.send(e, t);+ }+ async _send(e) {+ const t = this._getConnection();+ t.body = JSON.stringify(e), t.setHeader("content-type", "application/json");+ const n = await t.send();+ n.assertOk();+ let s = n.bodyJson;+ return Array.isArray(s) || (s = [s]), s;+ }+}+function of(i) {+ if (i == null)+ return null;+ if (typeof i.message == "string" && i.message.match(/revert/i) && Lt(i.data))+ return { message: i.message, data: i.data };+ if (typeof i == "object") {+ for (const e in i) {+ const t = of(i[e]);+ if (t)+ return t;+ }+ return null;+ }+ if (typeof i == "string")+ try {+ return of(JSON.parse(i));+ } catch {+ }+ return null;+}+function cf(i, e) {+ if (i != null) {+ if (typeof i.message == "string" && e.push(i.message), typeof i == "object")+ for (const t in i)+ cf(i[t], e);+ if (typeof i == "string")+ try {+ return cf(JSON.parse(i), e);+ } catch {+ }+ }+}+function CL(i) {+ const e = [];+ return cf(i, e), e;+}+class ur extends n_ {+ #e;+ #t;+ /**+ * Connect to the %%ethereum%% provider, optionally forcing the+ * %%network%%.+ */+ constructor(e, t, n) {+ const s = Object.assign({}, n ?? {}, { batchMaxCount: 1 });+ V(e && e.request, "invalid EIP-1193 provider", "ethereum", e), super(t, s), this.#t = null, n && n.providerInfo && (this.#t = n.providerInfo), this.#e = async (r, a) => {+ const o = { method: r, params: a };+ this.emit("debug", { action: "sendEip1193Request", payload: o });+ try {+ const c = await e.request(o);+ return this.emit("debug", { action: "receiveEip1193Result", result: c }), c;+ } catch (c) {+ const l = new Error(c.message);+ throw l.code = c.code, l.data = c.data, l.payload = o, this.emit("debug", { action: "receiveEip1193Error", error: l }), l;+ }+ };+ }+ get providerInfo() {+ return this.#t;+ }+ async send(e, t) {+ return await this._start(), await super.send(e, t);+ }+ async _send(e) {+ V(!Array.isArray(e), "EIP-1193 does not support batch request", "payload", e);+ try {+ const t = await this.#e(e.method, e.params || []);+ return [{ id: e.id, result: t }];+ } catch (t) {+ return [{+ id: e.id,+ error: { code: t.code, data: t.data, message: t.message }+ }];+ }+ }+ getRpcError(e, t) {+ switch (t = JSON.parse(JSON.stringify(t)), t.error.code || -1) {+ case 4001:+ t.error.message = `ethers-user-denied: ${t.error.message}`;+ break;+ case 4200:+ t.error.message = `ethers-unsupported: ${t.error.message}`;+ break;+ }+ return super.getRpcError(e, t);+ }+ /**+ * Resolves to ``true`` if the provider manages the %%address%%.+ */+ async hasSigner(e) {+ e == null && (e = 0);+ const t = await this.send("eth_accounts", []);+ return typeof e == "number" ? t.length > e : (e = e.toLowerCase(), t.filter((n) => n.toLowerCase() === e).length !== 0);+ }+ async getSigner(e) {+ if (e == null && (e = 0), !await this.hasSigner(e))+ try {+ await this.#e("eth_requestAccounts", []);+ } catch (t) {+ const n = t.payload;+ throw this.getRpcError(n, { id: n.id, error: t });+ }+ return await super.getSigner(e);+ }+ /**+ * Discover and connect to a Provider in the Browser using the+ * [[link-eip-6963]] discovery mechanism. If no providers are+ * present, ``null`` is resolved.+ */+ static async discover(e) {+ if (e == null && (e = {}), e.provider)+ return new ur(e.provider);+ const t = e.window ? e.window : typeof window < "u" ? window : null;+ if (t == null)+ return null;+ const n = e.anyProvider;+ if (n && t.ethereum)+ return new ur(t.ethereum);+ if (!("addEventListener" in t && "dispatchEvent" in t && "removeEventListener" in t))+ return null;+ const s = e.timeout ? e.timeout : 300;+ return s === 0 ? null : await new Promise((r, a) => {+ let o = [];+ const c = (u) => {+ o.push(u.detail), n && l();+ }, l = () => {+ if (clearTimeout(h), o.length)+ if (e && e.filter) {+ const u = e.filter(o.map((d) => Object.assign({}, d.info)));+ if (u == null)+ r(null);+ else if (u instanceof ur)+ r(u);+ else {+ let d = null;+ if (u.uuid && (d = o.filter((m) => u.uuid === m.info.uuid)[0]), d) {+ const { provider: f, info: m } = d;+ r(new ur(f, void 0, {+ providerInfo: m+ }));+ } else+ a(Ot("filter returned unknown info", "UNSUPPORTED_OPERATION", {+ value: u+ }));+ }+ } else {+ const { provider: u, info: d } = o[0];+ r(new ur(u, void 0, {+ providerInfo: d+ }));+ }+ else+ r(null);+ t.removeEventListener("eip6963:announceProvider", c);+ }, h = setTimeout(() => {+ l();+ }, s);+ t.addEventListener("eip6963:announceProvider", c), t.dispatchEvent(new Event("eip6963:requestProvider"));+ });+ }+}+const s_ = [+ // --- Registration ---+ "function register() external returns (uint256 agentId)",+ "function register(string agentURI) external returns (uint256 agentId)",+ "function register(string agentURI, tuple(string metadataKey, bytes metadataValue)[] metadata) external returns (uint256 agentId)",+ // --- URI ---+ "function setAgentURI(uint256 agentId, string newURI) external",+ "function tokenURI(uint256 tokenId) external view returns (string)",+ // --- Metadata ---+ "function setMetadata(uint256 agentId, string metadataKey, bytes metadataValue) external",+ "function getMetadata(uint256 agentId, string metadataKey) external view returns (bytes)",+ // --- Wallet ---+ "function getAgentWallet(uint256 agentId) external view returns (address)",+ // --- ERC-721 basics ---+ "function ownerOf(uint256 tokenId) external view returns (address)",+ "function balanceOf(address owner) external view returns (uint256)",+ "function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256)",+ "function totalSupply() external view returns (uint256)",+ "function name() external view returns (string)",+ "function symbol() external view returns (string)",+ "function getVersion() external pure returns (string)",+ // --- ERC-721 transfer ---+ "function transferFrom(address from, address to, uint256 tokenId) external",+ "function safeTransferFrom(address from, address to, uint256 tokenId) external",+ "function safeTransferFrom(address from, address to, uint256 tokenId, bytes data) external",+ "function approve(address to, uint256 tokenId) external",+ "function setApprovalForAll(address operator, bool approved) external",+ // --- Events ---+ "event Registered(uint256 indexed agentId, string agentURI, address indexed owner)",+ "event Transfer(address indexed from, address indexed to, uint256 indexed tokenId)"+], ir = {+ identityRegistry: "0x8004A818BFB912233c491871b3d84c89A494BD9e",+ reputationRegistry: "0x8004B663056A597Dffe9eCcC1965A193B7388713",+ validationRegistry: "0x8004Cb1BF31DAf7788923b405b754f57acEB4272"+}, In = {+ identityRegistry: "0x8004A169FB4a3325136EB29fA0ceB6D2e539a432",+ reputationRegistry: "0x8004BAa17C55a88189AE136b182e5fdA19dE9b63",+ validationRegistry: ""+ // not yet deployed on mainnet+}, mh = {+ // Mainnets+ 1: In,+ // Ethereum+ 10: In,+ // Optimism+ 56: In,+ // BSC+ 100: In,+ // Gnosis+ 137: In,+ // Polygon+ 250: In,+ // Fantom+ 324: In,+ // zkSync Era+ 1284: In,+ // Moonbeam+ 5e3: In,+ // Mantle+ 8453: In,+ // Base+ 42161: In,+ // Arbitrum One+ 42220: In,+ // Celo+ 43114: In,+ // Avalanche+ 59144: In,+ // Linea+ 534352: In,+ // Scroll+ // Testnets+ 97: ir,+ // BSC Testnet+ 11155111: ir,+ // Ethereum Sepolia+ 84532: ir,+ // Base Sepolia+ 421614: ir,+ // Arbitrum Sepolia+ 11155420: ir,+ // Optimism Sepolia+ 80002: ir,+ // Polygon Amoy+ 43113: ir+ // Avalanche Fuji+};+function SL(i, e) {+ return `eip155:${i}:${e}`;+}+const r_ = {+ // ── Mainnets ──────────────────────────────────────────────────────────+ 1: {+ name: "Ethereum",+ shortName: "ETH",+ currency: { name: "Ether", symbol: "ETH", decimals: 18 },+ rpcUrl: "https://ethereum-rpc.publicnode.com",+ explorer: "https://etherscan.io",+ testnet: !1+ },+ 10: {+ name: "Optimism",+ shortName: "OP",+ currency: { name: "Ether", symbol: "ETH", decimals: 18 },+ rpcUrl: "https://mainnet.optimism.io",+ explorer: "https://optimistic.etherscan.io",+ testnet: !1+ },+ 56: {+ name: "BNB Chain",+ shortName: "BSC",+ currency: { name: "BNB", symbol: "BNB", decimals: 18 },+ rpcUrl: "https://bsc-dataseed.bnbchain.org",+ explorer: "https://bscscan.com",+ testnet: !1+ },+ 100: {+ name: "Gnosis",+ shortName: "GNO",+ currency: { name: "xDAI", symbol: "xDAI", decimals: 18 },+ rpcUrl: "https://rpc.gnosischain.com",+ explorer: "https://gnosisscan.io",+ testnet: !1+ },+ 137: {+ name: "Polygon",+ shortName: "POL",+ currency: { name: "POL", symbol: "POL", decimals: 18 },+ rpcUrl: "https://polygon-rpc.com",+ explorer: "https://polygonscan.com",+ testnet: !1+ },+ 250: {+ name: "Fantom",+ shortName: "FTM",+ currency: { name: "Fantom", symbol: "FTM", decimals: 18 },+ rpcUrl: "https://rpc.ftm.tools",+ explorer: "https://ftmscan.com",+ testnet: !1+ },+ 324: {+ name: "zkSync Era",+ shortName: "zkSync",+ currency: { name: "Ether", symbol: "ETH", decimals: 18 },+ rpcUrl: "https://mainnet.era.zksync.io",+ explorer: "https://explorer.zksync.io",+ testnet: !1+ },+ 1284: {+ name: "Moonbeam",+ shortName: "GLMR",+ currency: { name: "Glimmer", symbol: "GLMR", decimals: 18 },+ rpcUrl: "https://rpc.api.moonbeam.network",+ explorer: "https://moonbeam.moonscan.io",+ testnet: !1+ },+ 5e3: {+ name: "Mantle",+ shortName: "MNT",+ currency: { name: "Mantle", symbol: "MNT", decimals: 18 },+ rpcUrl: "https://rpc.mantle.xyz",+ explorer: "https://explorer.mantle.xyz",+ testnet: !1+ },+ 8453: {+ name: "Base",+ shortName: "Base",+ currency: { name: "Ether", symbol: "ETH", decimals: 18 },+ rpcUrl: "https://mainnet.base.org",+ explorer: "https://basescan.org",+ testnet: !1+ },+ 42161: {+ name: "Arbitrum One",+ shortName: "ARB",+ currency: { name: "Ether", symbol: "ETH", decimals: 18 },+ rpcUrl: "https://arb1.arbitrum.io/rpc",+ explorer: "https://arbiscan.io",+ testnet: !1+ },+ 42220: {+ name: "Celo",+ shortName: "CELO",+ currency: { name: "Celo", symbol: "CELO", decimals: 18 },+ rpcUrl: "https://forno.celo.org",+ explorer: "https://celoscan.io",+ testnet: !1+ },+ 43114: {+ name: "Avalanche",+ shortName: "AVAX",+ currency: { name: "Avax", symbol: "AVAX", decimals: 18 },+ rpcUrl: "https://api.avax.network/ext/bc/C/rpc",+ explorer: "https://snowtrace.io",+ testnet: !1+ },+ 59144: {+ name: "Linea",+ shortName: "Linea",+ currency: { name: "Ether", symbol: "ETH", decimals: 18 },+ rpcUrl: "https://rpc.linea.build",+ explorer: "https://lineascan.build",+ testnet: !1+ },+ 534352: {+ name: "Scroll",+ shortName: "Scroll",+ currency: { name: "Ether", symbol: "ETH", decimals: 18 },+ rpcUrl: "https://rpc.scroll.io",+ explorer: "https://scrollscan.com",+ testnet: !1+ },+ // ── Testnets ──────────────────────────────────────────────────────────+ 97: {+ name: "BSC Testnet",+ shortName: "BSCt",+ currency: { name: "tBNB", symbol: "tBNB", decimals: 18 },+ rpcUrl: "https://bsc-testnet-rpc.publicnode.com",+ explorer: "https://testnet.bscscan.com",+ testnet: !0+ },+ 11155111: {+ name: "Ethereum Sepolia",+ shortName: "Sep",+ currency: { name: "SepETH", symbol: "ETH", decimals: 18 },+ rpcUrl: "https://ethereum-sepolia-rpc.publicnode.com",+ explorer: "https://sepolia.etherscan.io",+ testnet: !0+ },+ 84532: {+ name: "Base Sepolia",+ shortName: "BaseSep",+ currency: { name: "SepETH", symbol: "ETH", decimals: 18 },+ rpcUrl: "https://sepolia.base.org",+ explorer: "https://sepolia.basescan.org",+ testnet: !0+ },+ 421614: {+ name: "Arbitrum Sepolia",+ shortName: "ArbSep",+ currency: { name: "SepETH", symbol: "ETH", decimals: 18 },+ rpcUrl: "https://sepolia-rollup.arbitrum.io/rpc",+ explorer: "https://sepolia.arbiscan.io",+ testnet: !0+ },+ 11155420: {+ name: "Optimism Sepolia",+ shortName: "OpSep",+ currency: { name: "SepETH", symbol: "ETH", decimals: 18 },+ rpcUrl: "https://sepolia.optimism.io",+ explorer: "https://sepolia-optimism.etherscan.io",+ testnet: !0+ },+ 80002: {+ name: "Polygon Amoy",+ shortName: "Amoy",+ currency: { name: "POL", symbol: "POL", decimals: 18 },+ rpcUrl: "https://rpc-amoy.polygon.technology",+ explorer: "https://amoy.polygonscan.com",+ testnet: !0+ },+ 43113: {+ name: "Avalanche Fuji",+ shortName: "Fuji",+ currency: { name: "Avax", symbol: "AVAX", decimals: 18 },+ rpcUrl: "https://api.avax-test.network/ext/bc/C/rpc",+ explorer: "https://testnet.snowtrace.io",+ testnet: !0+ }+};+function IL(i, e) {+ if (e) return new ur(e);+ const t = r_[i];+ if (!t) throw new Error(`No RPC configured for chainId ${i}`);+ return new i_(t.rpcUrl, i);+}+function ML(i, e) {+ const t = mh[i];+ if (!t || !t.identityRegistry)+ throw new Error(`No Identity Registry for chainId ${i}`);+ const n = IL(i, e);+ return new _r(t.identityRegistry, s_, n);+}+async function BL({ chainId: i, agentId: e, ethProvider: t }) {+ const n = ML(i, t), [s, r] = await Promise.all([+ n.ownerOf(e).catch(() => null),+ n.tokenURI(e).catch(() => null)+ ]);+ return { agentId: BigInt(e), owner: s, uri: r };+}+function a_(i) {+ if (!i || typeof i != "object") return null;+ const e = Array.isArray(i.services) ? i.services : [];+ for (const n of e) {+ if (!n || typeof n != "object") continue;+ const s = String(n.endpoint || "").trim();+ if (!s) continue;+ const r = String(n.name || "").toLowerCase(), a = String(n.version || "").toLowerCase();+ if (r === "avatar" || r === "avatar-3d" || a.startsWith("gltf") || /\.(glb|gltf)(\?|#|$)/i.test(s)) return s;+ }+ const t = String(i.image || "").trim();+ return /\.(glb|gltf)(\?|#|$)/i.test(t) ? t : null;+}+async function TL(i) {+ if (!i) return { ok: !1, error: "empty uri" };+ if (i.startsWith("data:"))+ try {+ const t = i.match(/^data:application\/json(?:;base64)?,(.*)$/);+ if (!t) return { ok: !1, error: "unsupported data URI" };+ const n = /;base64,/.test(i) ? atob(t[1]) : decodeURIComponent(t[1]);+ return { ok: !0, data: JSON.parse(n), resolvedUrl: i };+ } catch (t) {+ return { ok: !1, error: "data URI parse failed: " + t.message };+ }+ let e = i;+ i.startsWith("ipfs://") ? e = "https://ipfs.io/ipfs/" + i.slice(7) : i.startsWith("ar://") && (e = "https://arweave.net/" + i.slice(5));+ try {+ const t = await fetch(e);+ return t.ok ? { ok: !0, data: await t.json(), resolvedUrl: e } : { ok: !1, error: `HTTP ${t.status}`, resolvedUrl: e };+ } catch (t) {+ return { ok: !1, error: t.message, resolvedUrl: e };+ }+}+const RL = {+ base: 8453,+ "base-mainnet": 8453,+ "base-sepolia": 84532,+ ethereum: 1,+ mainnet: 1+}, NL = {+ 8453: "https://mainnet.base.org",+ 84532: "https://sepolia.base.org",+ 1: "https://eth.llamarpc.com"+};+async function ll(i, { rpcURL: e, registry: t } = {}) {+ if (!i) throw new Error("loadManifest: source required");+ if (i.startsWith("agent://"))+ return FL(i, { rpcURL: e, registryOverride: t });+ if (i.startsWith("ipfs://") || i.startsWith("ar://")) {+ const n = Gs(i), s = await lf(n);+ return hf(s, { baseURI: uf(n) });+ }+ if (i.startsWith("http")) {+ const n = await lf(i);+ return hf(n, { baseURI: uf(i) });+ }+ throw new Error(`Unsupported manifest source: ${i}`);+}+async function FL(i, { rpcURL: e, registryOverride: t }) {+ const n = i.match(/^agent:\/\/([^/]+)\/(\d+)$/);+ if (!n) throw new Error(`Malformed agent URI: ${i}`);+ const [, s, r] = n, a = RL[s.toLowerCase()] || Number(s);+ if (!a) throw new Error(`Unknown chain: ${s}`);+ const o = mh[a], c = t || o?.identityRegistry;+ if (!c)+ throw new Error(`No registry deployed on chain ${a}. Pass registry= override.`);+ const l = new i_(e || NL[a]), h = new _r(c, s_, l), u = BigInt(r), d = await h.tokenURI(u);+ if (!d) throw new Error(`Agent ${r} on chain ${a} has no URI`);+ const f = Gs(d), m = await lf(f), A = hf(m, { baseURI: uf(f) });+ return A.id = {+ ...A.id,+ chain: s,+ chainId: a,+ registry: c,+ agentId: r+ }, A;+}+async function lf(i) {+ let e;+ try {+ e = await fetch(i);+ } catch {+ e = await BT(i);+ }+ if (!e.ok) throw new Error(`Manifest fetch failed: ${i} (${e.status})`);+ return e.json();+}+function hf(i, { baseURI: e = "" } = {}) {+ if (i.spec && i.spec.startsWith("agent-manifest/")) {+ const t = { ...i, _baseURI: e };+ return t.body = t.body || {}, !t.body.uri && t.image && (t.body.uri = t.image), t;+ }+ if (i.type && i.type.includes("eip-8004")) {+ const t = i.registrations?.[0] || {}, n = a_(i);+ return {+ spec: "agent-manifest/0.1",+ _baseURI: e,+ _source: "erc8004-registration",+ id: { agentId: t.agentId?.toString() },+ name: i.name,+ description: i.description,+ image: i.image,+ body: { uri: Gs(n || i.image || ""), format: "gltf-binary" },+ brain: { provider: "none" },+ voice: { tts: { provider: "browser" }, stt: { provider: "browser" } },+ skills: [],+ memory: { mode: "local" },+ tools: ["wave", "lookAt", "play_clip", "setExpression"],+ version: "0.1.0",+ services: Array.isArray(i.services) ? i.services : [],+ x402Support: !!i.x402Support,+ embedPolicy: i.embedPolicy || null+ };+ }+ return {+ spec: "agent-manifest/0.1",+ _baseURI: e,+ name: i.name || "Unnamed agent",+ description: i.description || "",+ body: {+ uri: i.body?.uri || i.image || i.model || "",+ format: i.body?.format || "gltf-binary"+ },+ brain: i.brain || { provider: "none" },+ voice: i.voice || { tts: { provider: "browser" }, stt: { provider: "browser" } },+ skills: i.skills || [],+ memory: i.memory || { mode: "local" },+ tools: i.tools || ["wave", "lookAt", "play_clip", "setExpression"],+ version: i.version || "0.1.0"+ };+}+function uf(i) {+ const e = i.lastIndexOf("/");+ return e >= 0 ? i.slice(0, e + 1) : i;+}+async function DL(i, e) {+ if (!i._baseURI) return null;+ try {+ const t = new URL(e, i._baseURI).href, n = await fetch(t);+ return n.ok ? n.text() : null;+ } catch {+ return null;+ }+}+class Cn extends Error {+ constructor(e, t, { status: n } = {}) {+ super(t), this.name = "AgentResolveError", this.code = e, n !== void 0 && (this.status = n);+ }+}+async function Fm(i, { fetchFn: e }) {+ let t;+ try {+ t = await e(i, { credentials: "include" });+ } catch (n) {+ throw new Cn(+ "network",+ `network error fetching ${i}: ${n.message || n}`+ );+ }+ if (t.status === 401 || t.status === 403)+ throw new Cn(+ "unauthorized",+ `unauthorized fetching ${i} (${t.status})`,+ { status: t.status }+ );+ if (t.status === 404)+ throw new Cn("not_found", `resource not found: ${i}`, { status: 404 });+ if (!t.ok)+ throw new Cn("network", `request failed: ${i} (${t.status})`, {+ status: t.status+ });+ try {+ return await t.json();+ } catch (n) {+ throw new Cn("network", `invalid JSON from ${i}: ${n.message || n}`);+ }+}+const ea = /* @__PURE__ */ new Map(), LL = 100;+async function PL(i, e) {+ if (!i) throw new Cn("not-found", "agentId required");+ if (ea.has(i)) return ea.get(i);+ const t = typeof location < "u" ? location.origin : "", n = `${t}/api/agents/${encodeURIComponent(i)}`;+ let s;+ try {+ s = await fetch(n, { credentials: "include", signal: e });+ } catch (c) {+ throw c?.name === "AbortError" ? c : new Cn(+ "network",+ `network error fetching ${n}: ${c.message || c}`+ );+ }+ if (s.status === 404)+ throw new Cn("not-found", `agent ${i} not found`, { status: 404 });+ if (s.status === 401 || s.status === 403)+ throw new Cn("unauthorized", `unauthorized (${s.status})`, {+ status: s.status+ });+ if (!s.ok)+ throw new Cn("network", `request failed (${s.status})`, {+ status: s.status+ });+ let r;+ try {+ r = await s.json();+ } catch {+ throw new Cn("network", `invalid JSON from ${n}`);+ }+ const a = r?.agent?.manifestUrl ?? null;+ let o = null;+ if (a)+ try {+ o = new URL(a, t).href;+ } catch {+ o = a;+ }+ return ea.size >= LL && ea.delete(ea.keys().next().value), ea.set(i, o), o;+}+async function kL(i, { origin: e = typeof location < "u" ? location.origin : "", fetchFn: t = fetch } = {}) {+ if (!i) throw new Cn("not_found", "agentId required");+ const n = t.bind(typeof globalThis < "u" ? globalThis : void 0), r = (await Fm(`${e}/api/agents/${encodeURIComponent(i)}`, {+ fetchFn: n+ }))?.agent;+ if (!r) throw new Cn("not_found", `agent ${i} not found`);+ if (!r.avatar_id)+ throw new Cn("no_avatar", `agent ${i} has no avatar bound`);+ const o = (await Fm(+ `${e}/api/avatars/${encodeURIComponent(r.avatar_id)}`,+ { fetchFn: n }+ ))?.avatar;+ if (!o || !o.url)+ throw new Cn("no_avatar", `avatar ${r.avatar_id} has no url`);+ const c = Array.isArray(r.skills) ? r.skills.map((l) => typeof l == "string" ? { name: l } : l).filter(Boolean) : [];+ return {+ spec: "agent-manifest/0.1",+ name: r.name || "Agent",+ description: r.description || "",+ id: {+ agentId: r.id,+ owner: r.wallet_address,+ chainId: r.chain_id,+ walletAddress: r.wallet_address+ },+ body: { uri: o.url, format: "gltf-binary" },+ brain: {},+ voice: { tts: { provider: "browser" }, stt: { provider: "browser" } },+ skills: c,+ memory: { mode: "remote", namespace: r.id },+ tools: ["wave", "lookAt", "play_clip", "setExpression", "speak", "remember"],+ version: "0.1.0",+ _baseURI: `${e}/agent/${r.id}/`,+ _source: "agent-id"+ };+}+function o_(i) {+ if (!i) return null;+ if (typeof i == "object")+ return i.chainId && i.agentId !== void 0 ? {+ chainId: Number(i.chainId),+ agentId: String(i.agentId),+ registry: i.registry || void 0+ } : null;+ const e = String(i).trim();+ if (!e) return null;+ let t = e.match(/^eip155:(\d+):(0x[0-9a-fA-F]{40}):(\d+)$/);+ return t ? { chainId: Number(t[1]), registry: t[2], agentId: t[3] } : (t = e.match(/^eip155:(\d+)\/erc721:(0x[0-9a-fA-F]{40})\/(\d+)$/), t ? { chainId: Number(t[1]), registry: t[2], agentId: t[3] } : (t = e.match(/^onchain:(\d+):(\d+)$/), t ? { chainId: Number(t[1]), agentId: t[2] } : (t = e.match(/^agent:\/\/(\d+)\/(\d+)$/), t ? { chainId: Number(t[1]), agentId: t[2] } : (t = e.match(/^\/?a\/(\d+)\/(\d+)(?:\/(embed))?\/?$/), t ? { chainId: Number(t[1]), agentId: t[2] } : (t = e.match(/^\/?a\/(\d+)\/(0x[0-9a-fA-F]{40})\/(\d+)\/?$/), t ? { chainId: Number(t[1]), registry: t[2], agentId: t[3] } : null)))));+}+function UL(i) {+ const e = i.registry || mh[i.chainId]?.identityRegistry;+ return e ? `eip155:${i.chainId}:${e}:${i.agentId}` : `onchain:${i.chainId}:${i.agentId}`;+}+function OL(i, { embed: e = !1, origin: t } = {}) {+ return `${t || (typeof location < "u" ? location.origin : "")}/a/${i.chainId}/${i.agentId}${e ? "/embed" : ""}`;+}+const QL = [+ "https://ipfs.io/ipfs/",+ "https://dweb.link/ipfs/",+ "https://cloudflare-ipfs.com/ipfs/",+ "https://gateway.pinata.cloud/ipfs/"+], GL = "https://arweave.net/";+function Dm(i) {+ return i ? i.startsWith("ipfs://") ? QL[0] + i.slice(7) : i.startsWith("ar://") ? GL + i.slice(5) : i : "";+}+const ho = /* @__PURE__ */ new Map();+function HL(i) {+ return `${i.chainId}:${i.agentId}`;+}+async function zL(i, { ethProvider: e, fresh: t = !1 } = {}) {+ const n = o_(i);+ if (!n) throw new Error(`Unrecognised agent reference: ${i}`);+ const s = {+ chainId: n.chainId,+ agentId: String(n.agentId),+ registry: n.registry || mh[n.chainId]?.identityRegistry || null+ };+ if (!s.registry) throw new Error(`No registry deployed on chain ${s.chainId}`);+ const r = HL(s);+ if (!t && ho.has(r)) return ho.get(r);+ const a = r_[s.chainId] || null, o = {+ ref: s,+ caip: UL(s),+ publicUrl: typeof location < "u" ? OL(s) : `/a/${s.chainId}/${s.agentId}`,+ chain: a ? { name: a.name, testnet: !!a.testnet, explorer: a.explorer } : null,+ onchain: { owner: null, uri: null },+ metadata: null,+ metadataUrl: null,+ image: null,+ glbUrl: null,+ name: `Agent #${s.agentId}`,+ description: "",+ services: []+ };+ try {+ const { owner: c, uri: l } = await BL({+ chainId: s.chainId,+ agentId: s.agentId,+ ethProvider: e+ });+ if (o.onchain = { owner: c, uri: l }, !l)+ return o.error = "agentURI not set", ho.set(r, o), o;+ const h = await TL(l);+ if (!h.ok)+ return o.error = h.error, o.metadataUrl = h.resolvedUrl || null, ho.set(r, o), o;+ const u = h.data;+ o.metadata = u, o.metadataUrl = h.resolvedUrl || null, o.name = u?.name && String(u.name) || o.name, o.description = u?.description && String(u.description) || "", o.image = u?.image ? String(u.image) : null, o.services = Array.isArray(u?.services) ? u.services : [], o.glbUrl = a_(u);+ } catch (c) {+ o.error = c.message || String(c);+ }+ return ho.set(r, o), o;+}+function VL(i) {+ const e = Array.isArray(i.services) ? i.services : [], t = e.find((a) => /brain|llm|chat/i.test(a?.name || a?.type || "")), n = e.filter((a) => /skill/i.test(a?.name || a?.type || "")), s = i.glbUrl ? Dm(i.glbUrl) : "", r = i.image ? Dm(i.image) : "";+ return {+ spec: "agent-manifest/0.1",+ _baseURI: i.metadataUrl ? WL(i.metadataUrl) : "",+ _source: "erc8004-resolver",+ id: {+ agentId: i.ref.agentId,+ chainId: i.ref.chainId,+ registry: i.ref.registry,+ owner: i.onchain.owner || void 0,+ walletAddress: i.onchain.owner || void 0,+ caip: i.caip,+ agentRegistry: SL(i.ref.chainId, i.ref.registry)+ },+ name: i.name,+ description: i.description,+ image: r,+ body: { uri: s || r, format: "gltf-binary" },+ brain: t ? { provider: "remote", endpoint: t.endpoint } : { provider: "none" },+ voice: { tts: { provider: "browser" }, stt: { provider: "browser" } },+ skills: n.map((a) => ({ name: a.name, uri: a.endpoint })),+ memory: { mode: "local", namespace: i.caip },+ tools: ["wave", "lookAt", "play_clip", "setExpression"],+ version: "0.1.0",+ services: e,+ x402Support: !!(i.metadata?.x402Support || i.metadata?.x402),+ embedPolicy: i.metadata?.embedPolicy || null+ };+}+function WL(i) {+ const e = i.lastIndexOf("/");+ return e >= 0 ? i.slice(0, e + 1) : i;+}+const Lm = 1, qL = 256;+function hl() {+ return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (i) => {+ const e = Math.random() * 16 | 0;+ return (i === "x" ? e : e & 3 | 8).toString(16);+ });+}+const Fu = {+ speak: "speak",+ gesture: "gesture",+ emote: "emote",+ look: "look-at"+};+class KL {+ /**+ * @param {{ protocol: object, avatar?: object, manifest: object, window: Window }} opts+ */+ constructor({ protocol: e, avatar: t = null, manifest: n, window: s }) {+ this._protocol = e, this._avatar = t, this._manifest = n, this._win = s, this._subscribed = !1, this._evtQueue = [], this._running = !1, this._onMessage = this._handleMessage.bind(this), this._onAction = this._handleAction.bind(this);+ }+ start() {+ if (this._running) return;+ this._running = !0, this._win.addEventListener("message", this._onMessage), this._protocol.on("*", this._onAction);+ const e = this._manifest?.id?.agentId || this._manifest?.agentId || "", t = [...Object.keys(Fu), "setAgent", "ping", "subscribe"];+ this._toParent({ kind: "event", op: "ready", payload: { agentId: e, capabilities: t } });+ }+ stop() {+ this._running && (this._running = !1, this._win.removeEventListener("message", this._onMessage), this._protocol.off("*", this._onAction), this._evtQueue = []);+ }+ // ── Helpers ───────────────────────────────────────────────────────────────+ _allowedOrigins() {+ const e = this._manifest?.policy;+ if (!e) return [];+ const t = e.origins || e.allowlist || [];+ return Array.isArray(t) ? t : [t];+ }+ _originAllowed(e) {+ const t = this._allowedOrigins();+ return t.length === 0 ? !0 : t.some((n) => {+ if (n === "*") return !0;+ try {+ return new URL(n).origin === e;+ } catch {+ return n === e;+ }+ });+ }+ _toParent(e) {+ this._win.parent.postMessage(+ { ...e, v: Lm, source: "agent-3d", id: e.id || hl() },+ "*"+ );+ }+ _reply(e, t) {+ this._toParent({+ id: hl(),+ inReplyTo: e.id,+ kind: "response",+ op: e.op === "ping" ? "pong" : e.op,+ payload: t+ });+ }+ _replyError(e, t, n) {+ this._toParent({+ id: hl(),+ inReplyTo: e.id,+ kind: "response",+ op: e.op,+ payload: { error: `${t}: ${n}` }+ });+ }+ // ── Incoming (host → agent) ───────────────────────────────────────────────+ _handleMessage(e) {+ if (e.source !== this._win.parent || !this._originAllowed(e.origin)) return;+ const t = e.data;+ if (!t || t.v !== Lm || t.source !== "agent-host" || t.kind !== "request") return;+ const { op: n, payload: s = {} } = t;+ if (n === "ping") {+ this._reply(t, { capabilities: [...Object.keys(Fu), "subscribe"] });+ return;+ }+ if (n === "subscribe") {+ this._subscribed = !0, this._reply(t, { ok: !0 });+ for (const a of this._evtQueue) this._toParent(a);+ this._evtQueue = [];+ return;+ }+ if (n === "setAgent") {+ this._replyError(+ t,+ "not_supported",+ "setAgent requires host to update the iframe src"+ );+ return;+ }+ const r = Fu[n];+ if (!r) {+ this._replyError(t, "unknown_op", `Unknown op "${n}"`);+ return;+ }+ try {+ this._protocol.emit({ type: r, payload: s }), this._reply(t, { ok: !0 });+ } catch (a) {+ this._replyError(t, "emit_failed", a?.message || String(a));+ }+ }+ // ── Outgoing (agent → host) ───────────────────────────────────────────────+ _handleAction(e) {+ if (!this._running) return;+ const t = {+ id: hl(),+ kind: "event",+ op: "action",+ payload: {+ type: e.type,+ payload: e.payload,+ agentId: e.agentId+ }+ };+ if (!this._subscribed) {+ this._evtQueue.length >= qL && this._evtQueue.shift(), this._evtQueue.push(t);+ return;+ }+ this._toParent(t);+ }+}+const jL = {+ EMOTE: "emote"+};+class XL extends EventTarget {+ constructor() {+ super(), this._history = [], this._maxHistory = 200;+ }+ /**+ * Emit a typed action to all listeners.+ * @param {Omit<ActionPayload, 'timestamp'>} action+ */+ emit(e) {+ const t = {+ type: e.type,+ payload: e.payload || {},+ timestamp: Date.now(),+ agentId: e.agentId || "default",+ sourceSkill: e.sourceSkill || null+ };+ this._history.push(t), this._history.length > this._maxHistory && this._history.shift(), this.dispatchEvent(new CustomEvent(t.type, { detail: t })), this.dispatchEvent(new CustomEvent("*", { detail: t }));+ }+ /**+ * Subscribe to a specific action type (or '*' for all).+ * @param {string} type+ * @param {(action: ActionPayload) => void} handler+ */+ on(e, t) {+ this._wrap(e, t, !1);+ }+ /**+ * Subscribe once.+ * @param {string} type+ * @param {(action: ActionPayload) => void} handler+ */+ once(e, t) {+ this._wrap(e, t, !0);+ }+ /**+ * Unsubscribe. Must pass the same handler reference as used in on().+ * @param {string} type+ * @param {Function} handler+ */+ off(e, t) {+ t.__protocolWrapped ? this.removeEventListener(e, t.__protocolWrapped) : this.removeEventListener(e, t);+ }+ /** @returns {ActionPayload[]} Recent action history (newest last) */+ get history() {+ return this._history.slice();+ }+ /** Returns last N actions of a given type */+ recent(e, t = 10) {+ return this._history.filter((n) => n.type === e).slice(-t);+ }+ _wrap(e, t, n) {+ const s = (r) => t(r.detail);+ t.__protocolWrapped = s, n ? this.addEventListener(e, s, { once: !0 }) : this.addEventListener(e, s);+ }+}+const Pm = new XL(), YL = ["inline", "floating", "section", "fullscreen"], km = (() => {+ try {+ return new URL(import.meta.url).origin;+ } catch {+ return "";+ }+})();+function JL(i, e, t = []) {+ if (!i) return !1;+ let n;+ try {+ n = new URL(i).hostname.toLowerCase();+ } catch {+ return !1;+ }+ if (t.some((o) => n === o || n.endsWith("." + o))) return !0;+ const s = e?.origins?.hosts ?? [], r = e?.origins?.mode ?? "allowlist", a = s.some((o) => {+ const c = o.toLowerCase();+ return c.startsWith("*.") ? n.endsWith(c.slice(1)) && n !== c.slice(2) : n === c;+ });+ return r === "allowlist" ? a : !a;+}+const ZL = `+ :host {+ display: block;+ position: relative;+ width: 100%;+ height: 480px;+ --agent-bubble-radius: 16px;+ --agent-accent: #3b82f6;+ --agent-surface: rgba(17, 24, 39, 0.92);+ --agent-on-surface: #f9fafb;+ --agent-chat-font: system-ui, -apple-system, sans-serif;+ --agent-mic-glow: #22c55e;+ --agent-shadow: 0 20px 60px rgba(0,0,0,0.3);+ contain: layout style;+ }+ :host([mode="floating"]) {+ position: fixed;+ z-index: 2147483000;+ width: var(--agent-width, 320px);+ height: var(--agent-height, 420px);+ border-radius: var(--agent-bubble-radius);+ overflow: hidden;+ box-shadow: var(--agent-shadow);+ transition:+ width 0.3s cubic-bezier(0.4, 0, 0.2, 1),+ height 0.3s cubic-bezier(0.4, 0, 0.2, 1),+ border-radius 0.3s cubic-bezier(0.4, 0, 0.2, 1);+ }+ @media (prefers-reduced-motion: reduce) {+ :host([mode="floating"]) { transition: none; }+ }+ /* Inline responsive: height follows width at a 3:4 portrait ratio */+ :host([mode="inline"][data-responsive]) {+ height: auto;+ aspect-ratio: var(--agent-aspect, 3/4);+ }+ :host([mode="fullscreen"]) {+ position: fixed;+ inset: 0;+ width: 100vw;+ height: 100vh;+ z-index: 2147483000;+ }+ :host([hidden]) { display: none; }+ .stage {+ position: absolute;+ inset: 0;+ width: 100%;+ height: 100%;+ }+ .stage canvas { display: block; }+ /* Pill tap target — shown when collapsed to pill on narrow viewports */+ .pill-btn {+ display: none;+ position: absolute;+ inset: 0;+ width: 100%;+ height: 100%;+ background: none;+ border: 0;+ cursor: pointer;+ border-radius: inherit;+ z-index: 10;+ }+ /* Swipe-down handle visible when bottom-sheet is expanded */+ .pill-drag {+ display: none;+ position: absolute;+ top: 8px;+ left: 50%;+ transform: translateX(-50%);+ width: 36px;+ height: 4px;+ border-radius: 2px;+ background: rgba(255,255,255,0.25);+ pointer-events: none;+ z-index: 20;+ }+ .chrome {+ position: absolute;+ left: 12px;+ right: 12px;+ bottom: 12px;+ display: flex;+ gap: 8px;+ align-items: flex-end;+ pointer-events: none;+ }+ .chrome > * { pointer-events: auto; }+ .chat {+ flex: 1;+ max-height: 40%;+ overflow-y: auto;+ background: var(--agent-surface);+ color: var(--agent-on-surface);+ font: 14px/1.4 var(--agent-chat-font);+ border-radius: 12px;+ padding: 10px 12px;+ backdrop-filter: blur(12px);+ }+ .chat:empty { display: none; }+ .msg { margin: 4px 0; }+ .msg .role { opacity: 0.55; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }+ .input-row {+ display: flex;+ gap: 6px;+ background: var(--agent-surface);+ border-radius: 999px;+ padding: 4px 4px 4px 14px;+ backdrop-filter: blur(12px);+ flex: 1;+ }+ .input-row input {+ flex: 1;+ background: transparent;+ border: 0;+ color: var(--agent-on-surface);+ font: 14px var(--agent-chat-font);+ outline: none;+ }+ button.icon {+ width: 36px;+ height: 36px;+ border-radius: 50%;+ border: 0;+ background: var(--agent-accent);+ color: white;+ cursor: pointer;+ display: inline-flex;+ align-items: center;+ justify-content: center;+ }+ button.icon.mic[data-listening="true"] { box-shadow: 0 0 0 4px var(--agent-mic-glow); }+ .poster {+ position: absolute;+ inset: 0;+ background-size: contain;+ background-position: center;+ background-repeat: no-repeat;+ transition: opacity 0.4s;+ pointer-events: none;+ }+ .loading {+ position: absolute;+ left: 50%;+ top: 50%;+ transform: translate(-50%, -50%);+ color: var(--agent-on-surface);+ font: 14px var(--agent-chat-font);+ background: var(--agent-surface);+ padding: 8px 14px;+ border-radius: 999px;+ }+ .error, .agent-3d-error {+ position: absolute;+ inset: 16px;+ display: grid;+ place-items: center;+ color: var(--agent-on-surface);+ background: var(--agent-surface);+ border-radius: 12px;+ padding: 16px;+ font: 14px var(--agent-chat-font);+ }+ /* Optional name plate overlay — toggled by the name-plate attribute. */+ .name-plate {+ position: absolute;+ left: 12px;+ bottom: 10px;+ z-index: 2;+ pointer-events: none;+ font: 11px/1 var(--agent-chat-font);+ letter-spacing: 0.04em;+ color: rgba(255, 255, 255, 0.6);+ text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);+ }+ .name-plate:empty,+ :host([name-plate="off"]) .name-plate { display: none; }+ /* Background variants — set on :host so the canvas composites over them. */+ :host([background="transparent"]) { background: transparent; }+ :host([background="dark"]) { background: #0b0d10; }+ :host([background="light"]) { background: #f5f5f5; }+ :host([background="light"]) .name-plate {+ color: rgba(0, 0, 0, 0.55);+ text-shadow: none;+ }+`;+class c_ extends HTMLElement {+ static get observedAttributes() {+ return [+ "src",+ "manifest",+ "body",+ "agent-id",+ "mode",+ "position",+ "width",+ "height",+ "voice",+ "api-key",+ "key-proxy",+ "responsive",+ "background",+ "name-plate"+ ];+ }+ constructor() {+ super(), this.attachShadow({ mode: "open" }), this._viewer = null, this._scene = null, this._runtime = null, this._memory = null, this._skills = null, this._manifest = null, this._mounted = !1, this._booting = !1, this._listening = !1, this._pillActive = !1, this._mqNarrow = null, this._mqNarrowHandler = null, this._ro = null, this._outsideTapHandler = null, this._autoResolvedManifest = !1, this._suppressAttrChange = !1;+ }+ connectedCallback() {+ this._renderShell(), this._applyLayout(), this._setupResponsive(), this._observeViewport(), this.hasAttribute("eager") && this._boot();+ }+ disconnectedCallback() {+ this._teardown();+ }+ attributeChangedCallback(e, t, n) {+ !this._mounted || this._suppressAttrChange || (["mode", "position", "width", "height", "responsive"].includes(e) && this._applyLayout(), e === "background" && this._applyBackground(), e === "name-plate" && this._applyNamePlate(), ["src", "manifest", "body", "agent-id"].includes(e) && (this._teardown(), this._boot()));+ }+ _renderShell() {+ const e = document.createElement("style");+ e.textContent = ZL, this.shadowRoot.appendChild(e);+ const t = document.createElement("div");+ t.className = "stage", t.part = "stage", this.shadowRoot.appendChild(t), this._stageEl = t;+ const n = document.createElement("div");+ n.className = "poster", this.getAttribute("poster") && (n.style.backgroundImage = `url(${this.getAttribute("poster")})`), this.shadowRoot.appendChild(n), this._posterEl = n;+ const s = document.createElement("div");+ s.className = "loading", s.textContent = "Loading...", s.hidden = !0, this.shadowRoot.appendChild(s), this._loadingEl = s;+ const r = document.createElement("div");+ r.className = "name-plate", r.part = "name-plate", this.shadowRoot.appendChild(r), this._nameplateEl = r;+ const a = document.createElement("button");+ a.className = "pill-btn", a.setAttribute("aria-label", "Open agent"), a.addEventListener("click", () => this._expandPill()), a.addEventListener("keydown", (c) => {+ (c.key === "Enter" || c.key === " ") && (c.preventDefault(), this._expandPill());+ }), this.shadowRoot.appendChild(a), this._pillBtn = a;+ const o = document.createElement("div");+ if (o.className = "pill-drag", this.shadowRoot.appendChild(o), this._pillDrag = o, !this.hasAttribute("kiosk")) {+ const c = document.createElement("div");+ c.className = "chrome", c.part = "chrome";+ const l = document.createElement("div");+ l.className = "chat", l.part = "chat";+ const h = document.createElement("div");+ h.className = "input-row";+ const u = document.createElement("input");+ u.type = "text", u.placeholder = "Say something...", u.addEventListener("keydown", (f) => {+ if (f.key === "Enter" && u.value.trim()) {+ const m = u.value.trim();+ u.value = "", this.say(m);+ }+ });+ const d = document.createElement("button");+ d.className = "icon mic", d.title = "Push to talk", d.innerHTML = "🎙", d.addEventListener("click", () => this._toggleMic()), h.appendChild(u), h.appendChild(d), c.appendChild(l), c.appendChild(h), this.shadowRoot.appendChild(c), this._chatEl = l, this._inputEl = u, this._micEl = d;+ }+ }+ _isResponsive() {+ return this.getAttribute("responsive") !== "false";+ }+ _clampWidth(e) {+ const t = _parsePx(e);+ if (!t) return e;+ const n = Math.round(Math.max(160, t * 0.65)), s = Math.round(t / 1440 * 100);+ return `clamp(${n}px, ${s}vw, ${t}px)`;+ }+ /**+ * Apply the `background` attribute. Mirrors the iframe embed semantics so+ * the snippet builder's options translate cleanly: 'transparent' → renderer+ * clears with alpha=0 and the scene background is unset; 'dark' / 'light' →+ * scene background is painted in the corresponding color so the agent+ * composites over it. The host element's CSS background is driven by the+ * `:host([background="..."])` rules in BASE_STYLE.+ *+ * Safe to call before the viewer exists — it no-ops in that case and is+ * re-run automatically once `_boot()` constructs the viewer.+ */+ _applyBackground() {+ const e = this._viewer;+ if (!e) return;+ const t = this.getAttribute("background") || "transparent";+ t === "transparent" ? (e.renderer?.setClearAlpha?.(0), e.scene && (e.scene.background = null)) : t === "dark" ? (e.renderer?.setClearAlpha?.(1), e.scene?.background?.set && e.scene.background.set("#0b0d10")) : t === "light" && (e.renderer?.setClearAlpha?.(1), e.scene?.background?.set && e.scene.background.set("#f5f5f5"));+ }+ /**+ * Apply the `name-plate` attribute. Visibility is purely CSS-driven via+ * `:host([name-plate="off"])`, so this method only needs to ensure the+ * element exists in the shadow DOM (it does, see `_renderShell`).+ *+ * Kept as a separate method so attributeChangedCallback has a clear hook,+ * and so future changes to plate position/style stay localised here.+ */+ _applyNamePlate() {+ }+ /** Update the plate text. Empty string hides the plate (`.name-plate:empty`). */+ _setNamePlateText(e) {+ this._nameplateEl && (this._nameplateEl.textContent = e || "");+ }+ _clampHeight(e) {+ const t = _parsePx(e);+ if (!t) return e;+ const n = Math.round(Math.max(200, t * 0.65)), s = Math.round(t / 900 * 100);+ return `clamp(${n}px, ${s}vh, ${t}px)`;+ }+ _applyLayout() {+ const e = this.getAttribute("mode") || "inline";+ if (!YL.includes(e)) return;+ const t = this._isResponsive();+ if (e === "floating") {+ if (!this._pillActive) {+ const r = this.getAttribute("position") || "bottom-right", a = (this.getAttribute("offset") || "24px 24px").split(/\s+/), [o, c] = [a[0], a[1] || a[0]];+ this.style.top = this.style.bottom = this.style.left = this.style.right = "", r.includes("top") ? this.style.top = o : this.style.bottom = o, r.includes("left") ? this.style.left = c : r.includes("right") ? this.style.right = c : r.includes("center") && (this.style.left = "50%", this.style.transform = "translateX(-50%)");+ }+ const n = this.getAttribute("width") || "320px", s = this.getAttribute("height") || "420px";+ this.style.setProperty("--agent-width", t ? this._clampWidth(n) : n), this.style.setProperty(+ "--agent-height",+ t ? this._clampHeight(s) : s+ );+ } else {+ this.style.top = this.style.bottom = this.style.left = this.style.right = this.style.transform = "";+ const n = this.getAttribute("width"), s = this.getAttribute("height");+ e === "inline" && (n && (this.style.width = t ? this._clampWidth(n) : n), s ? (this.style.height = s, this.removeAttribute("data-responsive")) : t && n && (this.style.height = "", this.setAttribute("data-responsive", ""))), n && this.style.setProperty(+ "--agent-width",+ t ? this._clampWidth(n) : n+ ), s && this.style.setProperty(+ "--agent-height",+ t ? this._clampHeight(s) : s+ );+ }+ }+ _setupResponsive() {+ const e = this.getAttribute("mode") || "inline";+ e === "inline" && typeof ResizeObserver < "u" && (this._ro = new ResizeObserver(() => this._applyLayout()), this._ro.observe(this)), e === "floating" && this._isResponsive() && typeof window < "u" && (this._mqNarrow = window.matchMedia("(max-width: 479px)"), this._mqNarrowHandler = (n) => this._updatePillState(n.matches), this._mqNarrow.addEventListener("change", this._mqNarrowHandler), this._updatePillState(this._mqNarrow.matches));+ let t = 0;+ this.shadowRoot.addEventListener(+ "touchstart",+ (n) => {+ t = n.touches[0].clientY;+ },+ { passive: !0 }+ ), this.shadowRoot.addEventListener(+ "touchend",+ (n) => {+ n.changedTouches[0].clientY - t > 60 && this._pillActive && this.getAttribute("aria-expanded") === "true" && this._collapsePill();+ },+ { passive: !0 }+ );+ }+ _updatePillState(e) {+ e && !this._pillActive ? (this._pillActive = !0, this._collapsePill()) : !e && this._pillActive && (this._pillActive = !1, this._restoreFromPill());+ }+ _collapsePill() {+ this.style.width = "56px", this.style.height = "56px", this.style.borderRadius = "50%", this.setAttribute("aria-expanded", "false"), this._pillBtn.style.display = "block", this._pillDrag.style.display = "none";+ const e = this.shadowRoot.querySelector(".chrome");+ e && (e.style.display = "none"), this._stageEl.style.display = "none", this._outsideTapHandler && (document.removeEventListener("pointerdown", this._outsideTapHandler), this._outsideTapHandler = null);+ }+ _expandPill() {+ if (!this._pillActive) return;+ this.style.width = "100vw", this.style.height = "70vh", this.style.borderRadius = "16px 16px 0 0", this.style.bottom = "0", this.style.top = "auto", this.style.left = "0", this.style.right = "0", this.style.transform = "none", this.setAttribute("aria-expanded", "true"), this._pillBtn.style.display = "none", this._pillDrag.style.display = "block";+ const e = this.shadowRoot.querySelector(".chrome");+ e && (e.style.display = ""), this._stageEl.style.display = "", this._outsideTapHandler = (t) => {+ t.composedPath().includes(this) || this._collapsePill();+ }, setTimeout(() => document.addEventListener("pointerdown", this._outsideTapHandler), 0);+ }+ _restoreFromPill() {+ this.removeAttribute("aria-expanded"), this._pillBtn.style.display = "none", this._pillDrag.style.display = "none";+ const e = this.shadowRoot.querySelector(".chrome");+ e && (e.style.display = ""), this._stageEl.style.display = "", this.style.width = this.style.height = this.style.borderRadius = "", this.style.bottom = this.style.top = this.style.left = this.style.right = this.style.transform = "", this._applyLayout(), this._outsideTapHandler && (document.removeEventListener("pointerdown", this._outsideTapHandler), this._outsideTapHandler = null);+ }+ _observeViewport() {+ if (!this.hasAttribute("eager")) {+ if (typeof IntersectionObserver > "u") {+ this._boot();+ return;+ }+ this._io = new IntersectionObserver((e) => {+ e.some((t) => t.isIntersecting) && (this._io.disconnect(), this._boot());+ }), this._io.observe(this);+ }+ }+ async _boot() {+ if (!(this._booting || this._mounted)) {+ this._booting = !0;+ try {+ this._loadingEl.hidden = !1, this.dispatchEvent(+ new CustomEvent("agent:load-progress", { detail: { phase: "manifest", pct: 0.1 } })+ );+ const e = await this._resolveManifest();+ if (this._manifest = e, this.dispatchEvent(+ new CustomEvent("agent:load-progress", { detail: { phase: "manifest", pct: 0.3 } })+ ), typeof e.brain?.instructions == "string" && e.brain.instructions.endsWith(".md")) {+ const l = await DL(e, e.brain.instructions);+ l && (e.instructions = $L(l));+ } else e.brain?.instructions && (e.instructions = e.brain.instructions);+ const t = (() => {+ const l = this.getAttribute("agent-id") || e.id?.agentId || "";+ return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(l) ? l : null;+ })();+ if (t)+ try {+ const l = km || window.location.origin, h = await fetch(+ `${l}/api/agents/${t}/embed-policy`,+ { credentials: "omit" }+ );+ if (h.ok) {+ const { policy: u } = await h.json();+ if (u) {+ if (u.surfaces?.script === !1) {+ this._fail(+ "embed_denied_surface",+ "This agent disallows the script-tag embed."+ );+ return;+ }+ const d = ["three.ws", "localhost"], f = window.location.origin;+ if (!f.startsWith("http://localhost") && !JL(f, u, d)) {+ this._fail(+ "embed_denied_origin",+ `This agent isn't permitted on ${f}.`+ );+ return;+ }+ }+ }+ } catch (l) {+ console.warn("[agent-3d] embed-policy fetch failed; continuing", l);+ }+ this.dispatchEvent(+ new CustomEvent("agent:load-progress", { detail: { phase: "body", pct: 0.45 } })+ );+ const n = new fb(this._stageEl, { kiosk: this.hasAttribute("kiosk") });+ this._viewer = n, this._applyBackground(), this._setNamePlateText(e.name || ""), this._applyNamePlate();+ const s = Gs(e.body?.uri);+ s && await n.load(s, "", /* @__PURE__ */ new Map()), this._scene = new NT(n), this.dispatchEvent(+ new CustomEvent("agent:load-progress", { detail: { phase: "memory", pct: 0.6 } })+ );+ const r = e.id?.agentId || this.getAttribute("memory-key") || e.name || "anon";+ this._memory = await Ti.load({+ mode: this.getAttribute("memory") || e.memory?.mode || "local",+ namespace: r,+ manifestURI: e._baseURI + "manifest.json",+ fetchFn: fetch.bind(globalThis)+ }), this.dispatchEvent(+ new CustomEvent("agent:load-progress", { detail: { phase: "skills", pct: 0.75 } })+ ), this._skills = new KT({+ trust: this.getAttribute("skill-trust") || "owned-only",+ ownerAddress: e.id?.owner+ });+ const a = e.skills || [];+ for (const l of a)+ try {+ const h = await this._skills.install(l, {+ bundleBase: e._baseURI+ });+ this.dispatchEvent(+ new CustomEvent("skill:loaded", {+ detail: { name: h.name, uri: h.uri }+ })+ );+ } catch (h) {+ console.warn("[agent-3d] skill load failed", l, h);+ }+ this.dispatchEvent(+ new CustomEvent("agent:load-progress", { detail: { phase: "brain", pct: 0.9 } })+ );+ const o = {+ apiKey: this.getAttribute("api-key") || void 0,+ proxyURL: this.getAttribute("key-proxy") || void 0,+ agentId: t || void 0,+ apiOrigin: km || window.location.origin+ }, c = this._parseTTSAttribute();+ c && (e.voice = e.voice || {}, e.voice.tts = { ...e.voice.tts || {}, ...c }), this._runtime = new IT({+ manifest: e,+ viewer: this._scene,+ memory: this._memory,+ skills: this._skills,+ providerConfig: o+ });+ for (const l of [+ "brain:thinking",+ "brain:message",+ "skill:tool-called",+ "voice:speech-start",+ "voice:speech-end",+ "voice:transcript",+ "voice:listen-start",+ "memory:write"+ ])+ this._runtime.addEventListener(l, (h) => {+ this.dispatchEvent(+ new CustomEvent(l, { detail: h.detail, bubbles: !0, composed: !0 })+ ), l === "brain:message" && this._chatEl && this._renderMessage(h.detail);+ });+ this._mounted = !0, window !== window.parent && (this._embedBridge = new KL({+ protocol: Pm,+ manifest: this._manifest,+ window+ }), this._embedBridge.start()), this._loadingEl.hidden = !0, this._pillActive || (this._posterEl.style.opacity = "0"), this.dispatchEvent(+ new CustomEvent("agent:ready", {+ detail: { agent: this, manifest: e },+ bubbles: !0,+ composed: !0+ })+ );+ } catch (e) {+ if (console.error("[agent-3d] boot failed", e), this._loadingEl.hidden = !0, e instanceof Cn && e.code === "not-found") {+ const t = document.createElement("div");+ t.className = "agent-3d-error", t.textContent = "Agent not found", this.shadowRoot.appendChild(t);+ } else+ this._showError(e);+ this.dispatchEvent(+ new CustomEvent("agent:error", {+ detail: { phase: "boot", error: e },+ bubbles: !0,+ composed: !0+ })+ );+ } finally {+ this._booting = !1;+ }+ }+ }+ async _resolveManifest() {+ const e = this.getAttribute("src"), t = this.getAttribute("manifest"), n = this.getAttribute("body"), s = this.getAttribute("agent-id"), r = this.getAttribute("chain-id");+ if (e)+ return s && console.warn("[agent-3d] both src and agent-id provided; using src"), ll(e, {+ rpcURL: this.getAttribute("rpc-url"),+ registry: this.getAttribute("registry")+ });+ if (s) {+ const a = r ? {+ chainId: Number(r),+ agentId: s,+ registry: this.getAttribute("registry") || void 0+ } : s, o = o_(a);+ if (o) {+ const l = await zL(o);+ if (l.error && !l.glbUrl)+ throw new Error(`On-chain resolve failed: ${l.error}`);+ return VL(l);+ }+ if (t) return ll(t);+ const c = await PL(s);+ return c ? (this._autoResolvedManifest = !0, this.setAttribute("manifest", c), ll(c)) : kL(s);+ }+ if (t) return ll(t);+ if (n) {+ const a = this.getAttribute("instructions");+ return {+ spec: "agent-manifest/0.1",+ _baseURI: "",+ name: this.getAttribute("name") || "Agent",+ body: { uri: n, format: "gltf-binary" },+ brain: {+ provider: this.getAttribute("brain") ? "anthropic" : "none",+ model: this.getAttribute("brain") || void 0,+ instructions: a || "You are an embodied three.ws."+ },+ instructions: a || "You are an embodied three.ws.",+ voice: { tts: { provider: "browser" }, stt: { provider: "browser" } },+ skills: (this.getAttribute("skills") || "").split(",").map((o) => o.trim()).filter(Boolean).map((o) => ({ uri: o })),+ memory: { mode: this.getAttribute("memory") || "local" },+ tools: ["wave", "lookAt", "play_clip", "setExpression", "speak", "remember"],+ version: "0.1.0"+ };+ }+ throw new Error("<agent-3d> requires src=, manifest=, or body= attribute");+ }+ _renderMessage({ role: e, content: t }) {+ if (!this._chatEl || !t) return;+ const n = document.createElement("div");+ n.className = "msg", n.innerHTML = `<div class="role">${e}</div><div class="body"></div>`, n.querySelector(".body").textContent = t, this._chatEl.appendChild(n), this._chatEl.scrollTop = this._chatEl.scrollHeight;+ }+ _showError(e) {+ const t = document.createElement("div");+ t.className = "error", t.textContent = `Couldn't load agent: ${e.message || e}`, this.shadowRoot.appendChild(t);+ }+ _fail(e, t) {+ this._loadingEl.hidden = !0;+ const n = document.createElement("div");+ n.className = "error", n.textContent = t, this.shadowRoot.appendChild(n), this.dispatchEvent(+ new CustomEvent("agent:error", {+ detail: { phase: "policy", error: { code: e, message: t } },+ bubbles: !0,+ composed: !0+ })+ );+ }+ async _toggleMic() {+ if (this._runtime) {+ if (this._listening) {+ this._runtime.stt?.stop(), this._listening = !1, this._micEl.dataset.listening = "false";+ return;+ }+ this._listening = !0, this._micEl.dataset.listening = "true";+ try {+ const e = await this._runtime.listen();+ e && await this.say(e, { voice: !0 });+ } catch (e) {+ console.warn("[agent-3d] listen failed", e);+ } finally {+ this._listening = !1, this._micEl.dataset.listening = "false";+ }+ }+ }+ _teardown() {+ if (this._autoResolvedManifest) {+ this._suppressAttrChange = !0;+ try {+ this.removeAttribute("manifest");+ } finally {+ this._suppressAttrChange = !1;+ }+ this._autoResolvedManifest = !1;+ }+ try {+ this._io?.disconnect();+ } catch {+ }+ try {+ this._ro?.disconnect();+ } catch {+ }+ try {+ this._mqNarrow && this._mqNarrowHandler && this._mqNarrow.removeEventListener("change", this._mqNarrowHandler);+ } catch {+ }+ this._outsideTapHandler && (document.removeEventListener("pointerdown", this._outsideTapHandler), this._outsideTapHandler = null), this._embedBridge?.stop(), this._embedBridge = null;+ try {+ this._runtime?.destroy();+ } catch {+ }+ try {+ this._viewer?.dispose?.();+ } catch {+ }+ this._mounted = !1, this._pillActive = !1, this._runtime = this._viewer = this._scene = this._memory = this._skills = null;+ }+ // --- Public JS API ---+ async say(e, t = {}) {+ return this._runtime || await this._waitForReady(), this._runtime.send(e, { voice: t.voice ?? this.hasAttribute("voice") });+ }+ // Play speak animation — tries 'talk', falls back to 'yes', then 'wave'.+ speak(e, t = {}) {+ const n = Math.max(1.5, (e?.split(" ").length ?? 3) * 0.3), s = this._scene;+ s && (s.playAnimationByHint("talk", { duration: n }) || s.playAnimationByHint("yes", { duration: n }) || s.playAnimationByHint("wave", { duration: n }));+ }+ async ask(e, t = {}) {+ return (await this.say(e, t))?.text || "";+ }+ clearConversation() {+ this._runtime?.clearConversation();+ }+ async wave(e) {+ return this._scene?.playAnimationByHint("wave", e);+ }+ async lookAt(e) {+ return this._scene?.lookAt(e);+ }+ async play(e, t) {+ return this._scene?.playClipByName(e, t);+ }+ async installSkill(e) {+ if (!this._skills) throw new Error("Agent not mounted");+ return this._skills.install({ uri: e });+ }+ uninstallSkill(e) {+ return this._skills?.uninstall(e);+ }+ get skills() {+ return this._skills?.all() || [];+ }+ get memory() {+ return this._memory;+ }+ get manifest() {+ return this._manifest;+ }+ get runtime() {+ return this._runtime;+ }+ setMode(e) {+ this.setAttribute("mode", e);+ }+ setPosition(e, t) {+ this.setAttribute("position", e), t && this.setAttribute("offset", t);+ }+ setSize(e, t) {+ this.setAttribute("width", e), this.setAttribute("height", t);+ }+ pause() {+ this._runtime?.pause();+ }+ resume() {+ }+ destroy() {+ this._teardown();+ }+ /**+ * Trigger an emotion stimulus on the running avatar(s) via the protocol bus.+ * Trigger names match the avatar's emotion vocabulary:+ * 'celebration' | 'concern' | 'curiosity' | 'empathy' | 'patience'+ * Weight is clamped to [0, 1] by the avatar; defaults to 0.7.+ * No-op if the agent hasn't booted yet.+ */+ expressEmotion(e, t = 0.7) {+ return e ? (Pm.emit(jL.EMOTE, {+ trigger: e,+ weight: Math.max(0, Math.min(1, Number(t) || 0)),+ agentId: this._manifest?.id?.agentId+ }), !0) : !1;+ }+ _waitForReady() {+ return this._mounted ? Promise.resolve() : new Promise((e) => {+ const t = () => {+ this.removeEventListener("agent:ready", t), e();+ };+ this.addEventListener("agent:ready", t), this._booting || this._boot();+ });+ }+}+function $L(i) {+ const e = i.match(/^---\n[\s\S]*?\n---\n?([\s\S]*)$/);+ return e ? e[1] : i;+}+customElements.get("agent-3d") || customElements.define("agent-3d", c_);+const e2 = ["row", "circle", "freeform"], t2 = `+ :host {+ display: block;+ position: relative;+ width: 100%;+ height: 480px;+ contain: layout style;+ }+ :host([hidden]) { display: none; }+ .stage-canvas {+ position: absolute;+ inset: 0;+ width: 100%;+ height: 100%;+ }+ .stage-canvas canvas { display: block; }+ ::slotted(agent-3d) {+ position: absolute;+ pointer-events: none;+ }+`;+class n2 extends HTMLElement {+ static get observedAttributes() {+ return ["formation"];+ }+ constructor() {+ super(), this.attachShadow({ mode: "open" }), this._viewer = null, this._agents = [], this._initialized = !1;+ }+ connectedCallback() {+ this._renderShell(), this._initViewer(), this._mo = new MutationObserver(() => this._repositionAll()), this._mo.observe(this, { childList: !0 });+ }+ disconnectedCallback() {+ try {+ this._mo?.disconnect();+ } catch {+ }+ for (const e of [...this._agents]) this.unregisterAgent(e.element);+ try {+ this._viewer?.dispose?.();+ } catch {+ }+ this._viewer = null, this._initialized = !1;+ }+ attributeChangedCallback(e) {+ e === "formation" && this._repositionAll();+ }+ get formation() {+ const e = this.getAttribute("formation") || "row";+ return e2.includes(e) ? e : "row";+ }+ get viewer() {+ return this._viewer;+ }+ _renderShell() {+ const e = document.createElement("style");+ e.textContent = t2, this.shadowRoot.appendChild(e);+ const t = document.createElement("div");+ t.className = "stage-canvas", t.part = "stage", this.shadowRoot.appendChild(t), this._canvasBox = t;+ const n = document.createElement("slot");+ this.shadowRoot.appendChild(n);+ }+ _initViewer() {+ if (!this._initialized) {+ this._viewer = new fb(this._canvasBox, { kiosk: !0 }), this._viewer.defaultCamera.position.set(0, 1.55, 3.4), this._viewer.defaultCamera.lookAt(0, 1.2, 0), this._viewer.controls.target.set(0, 1.2, 0), this._viewer.controls.update();+ try {+ this._viewer.updateLights?.();+ } catch {+ }+ try {+ this._viewer.updateEnvironment?.();+ } catch {+ }+ this._viewer.invalidate(), this._initialized = !0;+ }+ }+ // --- Called by <agent-3d> children that detect this parent stage ---+ registerAgent(e, { id: t, group: n, manifest: s }) {+ const r = this._uniqueId(t || s?.name || "agent"), a = { id: r, element: e, group: n, manifest: s };+ return this._agents.push(a), this._viewer?.scene.add(n), this._repositionAll(), this.dispatchEvent(+ new CustomEvent("stage:agent-joined", {+ detail: { agentId: r, element: e, manifest: s },+ bubbles: !0,+ composed: !0+ })+ ), r;+ }+ unregisterAgent(e) {+ const t = this._agents.findIndex((s) => s.element === e);+ if (t < 0) return;+ const [n] = this._agents.splice(t, 1);+ try {+ this._viewer?.scene.remove(n.group);+ } catch {+ }+ i2(n.group), this._repositionAll(), this.dispatchEvent(+ new CustomEvent("stage:agent-left", {+ detail: { agentId: n.id, element: n.element },+ bubbles: !0,+ composed: !0+ })+ );+ }+ _uniqueId(e) {+ let t = e, n = 1;+ const s = new Set(this._agents.map((r) => r.id));+ for (; s.has(t); ) t = `${e}-${n++}`;+ return t;+ }+ // --- Public API ---+ getAgents() {+ return this._agents.map(({ id: e, group: t, manifest: n, element: s }) => ({+ agentId: e,+ name: n?.name || e,+ position: [+ +t.position.x.toFixed(3),+ +t.position.y.toFixed(3),+ +t.position.z.toFixed(3)+ ],+ element: s+ }));+ }+ broadcast(e, t) {+ const n = { from: e, event: t };+ for (const s of this._agents)+ s.id !== e && s.element.dispatchEvent(new CustomEvent("stage:message", { detail: n }));+ this.dispatchEvent(+ new CustomEvent("stage:message", {+ detail: n,+ bubbles: !0,+ composed: !0+ })+ );+ }+ async routeMessage(e, t, n) {+ const s = this._agents.find((r) => r.id === t);+ if (!s) return { ok: !1, error: `No agent "${t}" on stage` };+ try {+ return { ok: !0, reply: (await s.element.say(`[from ${e}] ${n}`))?.text || "" };+ } catch (r) {+ return { ok: !1, error: r?.message || String(r) };+ }+ }+ async addAgent(e) {+ const t = document.createElement("agent-3d");+ return e && typeof e == "object" && (t._inlineManifest = e), t.hasAttribute("eager") || t.setAttribute("eager", ""), this.appendChild(t), t;+ }+ removeAgent(e) {+ const t = this._agents.find((n) => n.id === e);+ t && t.element.remove();+ }+ // --- Formation / layout ---+ _repositionAll() {+ const e = this._agents.length;+ if (!(!e || !this._viewer)) {+ for (let t = 0; t < e; t++) {+ const { element: n, group: s, manifest: r } = this._agents[t], a = this._slotFor(t, e);+ s.position.copy(a.world), s.lookAt(0, a.world.y + 1, a.world.z + 5), n.style.position = "absolute", n.style.left = a.dom.left, n.style.top = a.dom.top, n.style.width = a.dom.width, n.style.height = a.dom.height, n.style.pointerEvents = "none";+ }+ this._viewer.invalidate();+ }+ }+ _slotFor(e, t) {+ const n = this.formation, s = 1 / Math.max(t, 1);+ if (n === "circle") {+ const o = e / t * Math.PI * 2, c = Math.max(0.8, 0.4 * t);+ return {+ world: new H(Math.sin(o) * c, 0, -Math.cos(o) * c + c * 0.5),+ dom: {+ left: `${e * s * 100}%`,+ top: "0",+ width: `${s * 100}%`,+ height: "100%"+ }+ };+ }+ if (n === "freeform")+ return {+ world: new H(0, 0, 0),+ dom: { left: "0", top: "0", width: "100%", height: "100%" }+ };+ const a = (e - (t - 1) / 2) * 1.1;+ return {+ world: new H(a, 0, 0),+ dom: {+ left: `${e * s * 100}%`,+ top: "0",+ width: `${s * 100}%`,+ height: "100%"+ }+ };+ }+}+function i2(i) {+ i.traverse((e) => {+ if (e.geometry)+ try {+ e.geometry.dispose();+ } catch {+ }+ if (e.material) {+ const t = Array.isArray(e.material) ? e.material : [e.material];+ for (const n of t) {+ for (const s of Object.keys(n)) {+ const r = n[s];+ if (r && r.isTexture)+ try {+ r.dispose();+ } catch {+ }+ }+ try {+ n.dispose();+ } catch {+ }+ }+ }+ }), i.parent && i.parent.remove(i);+}+customElements.get("agent-stage") || customElements.define("agent-stage", n2);+const S2 = (i = "agent-3d") => {+ customElements.get(i) || customElements.define(i, c_);+}, Du = /* @__PURE__ */ new WeakMap();+class s2 extends ps {+ /**+ * Constructs a new Draco loader.+ *+ * @param {LoadingManager} [manager] - The loading manager.+ */+ constructor(e) {+ super(e), this.decoderPath = "", this.decoderConfig = {}, this.decoderBinary = null, this.decoderPending = null, this.workerLimit = 4, this.workerPool = [], this.workerNextTaskID = 1, this.workerSourceURL = "", this.defaultAttributeIDs = {+ position: "POSITION",+ normal: "NORMAL",+ color: "COLOR",+ uv: "TEX_COORD"+ }, this.defaultAttributeTypes = {+ position: "Float32Array",+ normal: "Float32Array",+ color: "Float32Array",+ uv: "Float32Array"+ };+ }+ /**+ * Provides configuration for the decoder libraries. Configuration cannot be changed after decoding begins.+ *+ * @param {string} path - The decoder path.+ * @return {DRACOLoader} A reference to this loader.+ */+ setDecoderPath(e) {+ return this.decoderPath = e, this;+ }+ /**+ * Provides configuration for the decoder libraries. Configuration cannot be changed after decoding begins.+ *+ * @param {{type:('js'|'wasm')}} config - The decoder config.+ * @return {DRACOLoader} A reference to this loader.+ */+ setDecoderConfig(e) {+ return this.decoderConfig = e, this;+ }+ /**+ * Sets the maximum number of Web Workers to be used during decoding.+ * A lower limit may be preferable if workers are also for other tasks in the application.+ *+ * @param {number} workerLimit - The worker limit.+ * @return {DRACOLoader} A reference to this loader.+ */+ setWorkerLimit(e) {+ return this.workerLimit = e, this;+ }+ /**+ * Starts loading from the given URL and passes the loaded Draco asset+ * to the `onLoad()` callback.+ *+ * @param {string} url - The path/URL of the file to be loaded. This can also be a data URI.+ * @param {function(BufferGeometry)} onLoad - Executed when the loading process has been finished.+ * @param {onProgressCallback} onProgress - Executed while the loading is in progress.+ * @param {onErrorCallback} onError - Executed when errors occur.+ */+ load(e, t, n, s) {+ const r = new Ps(this.manager);+ r.setPath(this.path), r.setResponseType("arraybuffer"), r.setRequestHeader(this.requestHeader), r.setWithCredentials(this.withCredentials), r.load(e, (a) => {+ this.parse(a, t, s);+ }, n, s);+ }+ /**+ * Parses the given Draco data.+ *+ * @param {ArrayBuffer} buffer - The raw Draco data as an array buffer.+ * @param {function(BufferGeometry)} onLoad - Executed when the loading/parsing process has been finished.+ * @param {onErrorCallback} onError - Executed when errors occur.+ */+ parse(e, t, n = () => {+ }) {+ this.decodeDracoFile(e, t, null, null, Kt, n).catch(n);+ }+ //+ decodeDracoFile(e, t, n, s, r = ln, a = () => {+ }) {+ const o = {+ attributeIDs: n || this.defaultAttributeIDs,+ attributeTypes: s || this.defaultAttributeTypes,+ useUniqueIDs: !!n,+ vertexColorSpace: r+ };+ return this.decodeGeometry(e, o).then(t).catch(a);+ }+ decodeGeometry(e, t) {+ const n = JSON.stringify(t);+ if (Du.has(e)) {+ const c = Du.get(e);+ if (c.key === n)+ return c.promise;+ if (e.byteLength === 0)+ throw new Error(+ "THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred."+ );+ }+ let s;+ const r = this.workerNextTaskID++, a = e.byteLength, o = this._getWorker(r, a).then((c) => (s = c, new Promise((l, h) => {+ s._callbacks[r] = { resolve: l, reject: h }, s.postMessage({ type: "decode", id: r, taskConfig: t, buffer: e }, [e]);+ }))).then((c) => this._createGeometry(c.geometry));+ return o.catch(() => !0).then(() => {+ s && r && this._releaseTask(s, r);+ }), Du.set(e, {+ key: n,+ promise: o+ }), o;+ }+ _createGeometry(e) {+ const t = new zn();+ e.index && t.setIndex(new En(e.index.array, 1));+ for (let n = 0; n < e.attributes.length; n++) {+ const s = e.attributes[n], r = s.name, a = s.array, o = s.itemSize, c = new En(a, o);+ r === "color" && (this._assignVertexColorSpace(c, s.vertexColorSpace), c.normalized = !(a instanceof Float32Array)), t.setAttribute(r, c);+ }+ return t;+ }+ _assignVertexColorSpace(e, t) {+ if (t !== Kt) return;+ const n = new je();+ for (let s = 0, r = e.count; s < r; s++)+ n.fromBufferAttribute(e, s), mt.toWorkingColorSpace(n, Kt), e.setXYZ(s, n.r, n.g, n.b);+ }+ _loadLibrary(e, t) {+ const n = new Ps(this.manager);+ return n.setPath(this.decoderPath), n.setResponseType(t), n.setWithCredentials(this.withCredentials), new Promise((s, r) => {+ n.load(e, s, void 0, r);+ });+ }+ preload() {+ return this._initDecoder(), this;+ }+ _initDecoder() {+ if (this.decoderPending) return this.decoderPending;+ const e = typeof WebAssembly != "object" || this.decoderConfig.type === "js", t = [];+ return e ? t.push(this._loadLibrary("draco_decoder.js", "text")) : (t.push(this._loadLibrary("draco_wasm_wrapper.js", "text")), t.push(this._loadLibrary("draco_decoder.wasm", "arraybuffer"))), this.decoderPending = Promise.all(t).then((n) => {+ const s = n[0];+ e || (this.decoderConfig.wasmBinary = n[1]);+ const r = r2.toString(), a = [+ "/* draco decoder */",+ s,+ "",+ "/* worker */",+ r.substring(r.indexOf("{") + 1, r.lastIndexOf("}"))+ ].join(`+`);+ this.workerSourceURL = URL.createObjectURL(new Blob([a]));+ }), this.decoderPending;+ }+ _getWorker(e, t) {+ return this._initDecoder().then(() => {+ if (this.workerPool.length < this.workerLimit) {+ const s = new Worker(this.workerSourceURL);+ s._callbacks = {}, s._taskCosts = {}, s._taskLoad = 0, s.postMessage({ type: "init", decoderConfig: this.decoderConfig }), s.onmessage = function(r) {+ const a = r.data;+ switch (a.type) {+ case "decode":+ s._callbacks[a.id].resolve(a);+ break;+ case "error":+ s._callbacks[a.id].reject(a);+ break;+ default:+ console.error('THREE.DRACOLoader: Unexpected message, "' + a.type + '"');+ }+ }, this.workerPool.push(s);+ } else+ this.workerPool.sort(function(s, r) {+ return s._taskLoad > r._taskLoad ? -1 : 1;+ });+ const n = this.workerPool[this.workerPool.length - 1];+ return n._taskCosts[e] = t, n._taskLoad += t, n;+ });+ }+ _releaseTask(e, t) {+ e._taskLoad -= e._taskCosts[t], delete e._callbacks[t], delete e._taskCosts[t];+ }+ debug() {+ console.log("Task load: ", this.workerPool.map((e) => e._taskLoad));+ }+ dispose() {+ for (let e = 0; e < this.workerPool.length; ++e)+ this.workerPool[e].terminate();+ return this.workerPool.length = 0, this.workerSourceURL !== "" && URL.revokeObjectURL(this.workerSourceURL), this;+ }+}+function r2() {+ let i, e;+ onmessage = function(a) {+ const o = a.data;+ switch (o.type) {+ case "init":+ i = o.decoderConfig, e = new Promise(function(h) {+ i.onModuleLoaded = function(u) {+ h({ draco: u });+ }, DracoDecoderModule(i);+ });+ break;+ case "decode":+ const c = o.buffer, l = o.taskConfig;+ e.then((h) => {+ const u = h.draco, d = new u.Decoder();+ try {+ const f = t(u, d, new Int8Array(c), l), m = f.attributes.map((A) => A.array.buffer);+ f.index && m.push(f.index.array.buffer), self.postMessage({ type: "decode", id: o.id, geometry: f }, m);+ } catch (f) {+ console.error(f), self.postMessage({ type: "error", id: o.id, error: f.message });+ } finally {+ u.destroy(d);+ }+ });+ break;+ }+ };+ function t(a, o, c, l) {+ const h = l.attributeIDs, u = l.attributeTypes;+ let d, f;+ const m = o.GetEncodedGeometryType(c);+ if (m === a.TRIANGULAR_MESH)+ d = new a.Mesh(), f = o.DecodeArrayToMesh(c, c.byteLength, d);+ else if (m === a.POINT_CLOUD)+ d = new a.PointCloud(), f = o.DecodeArrayToPointCloud(c, c.byteLength, d);+ else+ throw new Error("THREE.DRACOLoader: Unexpected geometry type.");+ if (!f.ok() || d.ptr === 0)+ throw new Error("THREE.DRACOLoader: Decoding failed: " + f.error_msg());+ const A = { index: null, attributes: [] };+ for (const g in h) {+ const p = self[u[g]];+ let y, b;+ if (l.useUniqueIDs)+ b = h[g], y = o.GetAttributeByUniqueId(d, b);+ else {+ if (b = o.GetAttributeId(d, a[h[g]]), b === -1) continue;+ y = o.GetAttribute(d, b);+ }+ const E = s(a, o, d, g, p, y);+ g === "color" && (E.vertexColorSpace = l.vertexColorSpace), A.attributes.push(E);+ }+ return m === a.TRIANGULAR_MESH && (A.index = n(a, o, d)), a.destroy(d), A;+ }+ function n(a, o, c) {+ const h = c.num_faces() * 3, u = h * 4, d = a._malloc(u);+ o.GetTrianglesUInt32Array(c, u, d);+ const f = new Uint32Array(a.HEAPF32.buffer, d, h).slice();+ return a._free(d), { array: f, itemSize: 1 };+ }+ function s(a, o, c, l, h, u) {+ const d = u.num_components(), m = c.num_points() * d, A = m * h.BYTES_PER_ELEMENT, g = r(a, h), p = a._malloc(A);+ o.GetAttributeDataArrayForAllPoints(c, u, g, A, p);+ const y = new h(a.HEAPF32.buffer, p, m).slice();+ return a._free(p), {+ name: l,+ array: y,+ itemSize: d+ };+ }+ function r(a, o) {+ switch (o) {+ case Float32Array:+ return a.DT_FLOAT32;+ case Int8Array:+ return a.DT_INT8;+ case Int16Array:+ return a.DT_INT16;+ case Int32Array:+ return a.DT_INT32;+ case Uint8Array:+ return a.DT_UINT8;+ case Uint16Array:+ return a.DT_UINT16;+ case Uint32Array:+ return a.DT_UINT32;+ }+ }+}+const a2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({+ __proto__: null,+ DRACOLoader: s2+}, Symbol.toStringTag, { value: "Module" }));+class o2 {+ /**+ * Constructs a new Worker pool.+ *+ * @param {number} [pool=4] - The size of the pool.+ */+ constructor(e = 4) {+ this.pool = e, this.queue = [], this.workers = [], this.workersResolve = [], this.workerStatus = 0, this.workerCreator = null;+ }+ _initWorker(e) {+ if (!this.workers[e]) {+ const t = this.workerCreator();+ t.addEventListener("message", this._onMessage.bind(this, e)), this.workers[e] = t;+ }+ }+ _getIdleWorker() {+ for (let e = 0; e < this.pool; e++)+ if (!(this.workerStatus & 1 << e)) return e;+ return -1;+ }+ _onMessage(e, t) {+ const n = this.workersResolve[e];+ if (n && n(t), this.queue.length) {+ const { resolve: s, msg: r, transfer: a } = this.queue.shift();+ this.workersResolve[e] = s, this.workers[e].postMessage(r, a);+ } else+ this.workerStatus ^= 1 << e;+ }+ /**+ * Sets a function that is responsible for creating Workers.+ *+ * @param {Function} workerCreator - The worker creator function.+ */+ setWorkerCreator(e) {+ this.workerCreator = e;+ }+ /**+ * Sets the Worker limit+ *+ * @param {number} pool - The size of the pool.+ */+ setWorkerLimit(e) {+ this.pool = e;+ }+ /**+ * Post a message to an idle Worker. If no Worker is available,+ * the message is pushed into a message queue for later processing.+ *+ * @param {Object} msg - The message.+ * @param {Array<ArrayBuffer>} transfer - An array with array buffers for data transfer.+ * @return {Promise} A Promise that resolves when the message has been processed.+ */+ postMessage(e, t) {+ return new Promise((n) => {+ const s = this._getIdleWorker();+ s !== -1 ? (this._initWorker(s), this.workerStatus |= 1 << s, this.workersResolve[s] = n, this.workers[s].postMessage(e, t)) : this.queue.push({ resolve: n, msg: e, transfer: t });+ });+ }+ /**+ * Terminates all Workers of this pool. Call this method whenever this+ * Worker pool is no longer used in your app.+ */+ dispose() {+ this.workers.forEach((e) => e.terminate()), this.workersResolve.length = 0, this.workers.length = 0, this.queue.length = 0, this.workerStatus = 0;+ }+}+const c2 = 0, Um = 2, l2 = 1, Om = 2, h2 = 0, u2 = 1, d2 = 10, f2 = 0, l_ = 9, h_ = 15, u_ = 16, d_ = 22, f_ = 37, p_ = 43, A_ = 76, g_ = 83, m_ = 97, b_ = 100, x_ = 103, __ = 109, E_ = 165, y_ = 166, hp = 1000066e3;+class p2 {+ constructor() {+ this.vkFormat = 0, this.typeSize = 1, this.pixelWidth = 0, this.pixelHeight = 0, this.pixelDepth = 0, this.layerCount = 0, this.faceCount = 1, this.supercompressionScheme = 0, this.levels = [], this.dataFormatDescriptor = [{ vendorId: 0, descriptorType: 0, descriptorBlockSize: 0, versionNumber: 2, colorModel: 0, colorPrimaries: 1, transferFunction: 2, flags: 0, texelBlockDimension: [0, 0, 0, 0], bytesPlane: [0, 0, 0, 0, 0, 0, 0, 0], samples: [] }], this.keyValue = {}, this.globalData = null;+ }+}+class uo {+ constructor(e, t, n, s) {+ this._dataView = void 0, this._littleEndian = void 0, this._offset = void 0, this._dataView = new DataView(e.buffer, e.byteOffset + t, n), this._littleEndian = s, this._offset = 0;+ }+ _nextUint8() {+ const e = this._dataView.getUint8(this._offset);+ return this._offset += 1, e;+ }+ _nextUint16() {+ const e = this._dataView.getUint16(this._offset, this._littleEndian);+ return this._offset += 2, e;+ }+ _nextUint32() {+ const e = this._dataView.getUint32(this._offset, this._littleEndian);+ return this._offset += 4, e;+ }+ _nextUint64() {+ const e = this._dataView.getUint32(this._offset, this._littleEndian) + 4294967296 * this._dataView.getUint32(this._offset + 4, this._littleEndian);+ return this._offset += 8, e;+ }+ _nextInt32() {+ const e = this._dataView.getInt32(this._offset, this._littleEndian);+ return this._offset += 4, e;+ }+ _nextUint8Array(e) {+ const t = new Uint8Array(this._dataView.buffer, this._dataView.byteOffset + this._offset, e);+ return this._offset += e, t;+ }+ _skip(e) {+ return this._offset += e, this;+ }+ _scan(e, t) {+ t === void 0 && (t = 0);+ const n = this._offset;+ let s = 0;+ for (; this._dataView.getUint8(this._offset) !== t && s < e; ) s++, this._offset++;+ return s < e && this._offset++, new Uint8Array(this._dataView.buffer, this._dataView.byteOffset + n, s);+ }+}+const Mn = [171, 75, 84, 88, 32, 50, 48, 187, 13, 10, 26, 10];+function Qm(i) {+ return new TextDecoder().decode(i);+}+function A2(i) {+ const e = new Uint8Array(i.buffer, i.byteOffset, Mn.length);+ if (e[0] !== Mn[0] || e[1] !== Mn[1] || e[2] !== Mn[2] || e[3] !== Mn[3] || e[4] !== Mn[4] || e[5] !== Mn[5] || e[6] !== Mn[6] || e[7] !== Mn[7] || e[8] !== Mn[8] || e[9] !== Mn[9] || e[10] !== Mn[10] || e[11] !== Mn[11]) throw new Error("Missing KTX 2.0 identifier.");+ const t = new p2(), n = 17 * Uint32Array.BYTES_PER_ELEMENT, s = new uo(i, Mn.length, n, !0);+ t.vkFormat = s._nextUint32(), t.typeSize = s._nextUint32(), t.pixelWidth = s._nextUint32(), t.pixelHeight = s._nextUint32(), t.pixelDepth = s._nextUint32(), t.layerCount = s._nextUint32(), t.faceCount = s._nextUint32();+ const r = s._nextUint32();+ t.supercompressionScheme = s._nextUint32();+ const a = s._nextUint32(), o = s._nextUint32(), c = s._nextUint32(), l = s._nextUint32(), h = s._nextUint64(), u = s._nextUint64(), d = new uo(i, Mn.length + n, 3 * r * 8, !0);+ for (let Y = 0; Y < r; Y++) t.levels.push({ levelData: new Uint8Array(i.buffer, i.byteOffset + d._nextUint64(), d._nextUint64()), uncompressedByteLength: d._nextUint64() });+ const f = new uo(i, a, o, !0), m = { vendorId: f._skip(4)._nextUint16(), descriptorType: f._nextUint16(), versionNumber: f._nextUint16(), descriptorBlockSize: f._nextUint16(), colorModel: f._nextUint8(), colorPrimaries: f._nextUint8(), transferFunction: f._nextUint8(), flags: f._nextUint8(), texelBlockDimension: [f._nextUint8(), f._nextUint8(), f._nextUint8(), f._nextUint8()], bytesPlane: [f._nextUint8(), f._nextUint8(), f._nextUint8(), f._nextUint8(), f._nextUint8(), f._nextUint8(), f._nextUint8(), f._nextUint8()], samples: [] }, A = (m.descriptorBlockSize / 4 - 6) / 4;+ for (let Y = 0; Y < A; Y++) {+ const Q = { bitOffset: f._nextUint16(), bitLength: f._nextUint8(), channelType: f._nextUint8(), samplePosition: [f._nextUint8(), f._nextUint8(), f._nextUint8(), f._nextUint8()], sampleLower: -1 / 0, sampleUpper: 1 / 0 };+ 64 & Q.channelType ? (Q.sampleLower = f._nextInt32(), Q.sampleUpper = f._nextInt32()) : (Q.sampleLower = f._nextUint32(), Q.sampleUpper = f._nextUint32()), m.samples[Y] = Q;+ }+ t.dataFormatDescriptor.length = 0, t.dataFormatDescriptor.push(m);+ const g = new uo(i, c, l, !0);+ for (; g._offset < l; ) {+ const Y = g._nextUint32(), Q = g._scan(Y), J = Qm(Q);+ if (t.keyValue[J] = g._nextUint8Array(Y - Q.byteLength - 1), J.match(/^ktx/i)) {+ const ee = Qm(t.keyValue[J]);+ t.keyValue[J] = ee.substring(0, ee.lastIndexOf("\0"));+ }+ g._skip(Y % 4 ? 4 - Y % 4 : 0);+ }+ if (u <= 0) return t;+ const p = new uo(i, h, u, !0), y = p._nextUint16(), b = p._nextUint16(), E = p._nextUint32(), M = p._nextUint32(), w = p._nextUint32(), S = p._nextUint32(), T = [];+ for (let Y = 0; Y < r; Y++) T.push({ imageFlags: p._nextUint32(), rgbSliceByteOffset: p._nextUint32(), rgbSliceByteLength: p._nextUint32(), alphaSliceByteOffset: p._nextUint32(), alphaSliceByteLength: p._nextUint32() });+ const C = h + p._offset, v = C + E, F = v + M, K = F + w, q = new Uint8Array(i.buffer, i.byteOffset + C, E), $ = new Uint8Array(i.buffer, i.byteOffset + v, M), D = new Uint8Array(i.buffer, i.byteOffset + F, w), O = new Uint8Array(i.buffer, i.byteOffset + K, S);+ return t.globalData = { endpointCount: y, selectorCount: b, imageDescs: T, endpointsData: q, selectorsData: $, tablesData: D, extendedData: O }, t;+}+let Lu, Xi, df;+const Pu = { env: { emscripten_notify_memory_growth: function(i) {+ df = new Uint8Array(Xi.exports.memory.buffer);+} } };+class g2 {+ init() {+ return Lu || (Lu = typeof fetch < "u" ? fetch("data:application/wasm;base64," + Gm).then((e) => e.arrayBuffer()).then((e) => WebAssembly.instantiate(e, Pu)).then(this._init) : WebAssembly.instantiate(Buffer.from(Gm, "base64"), Pu).then(this._init), Lu);+ }+ _init(e) {+ Xi = e.instance, Pu.env.emscripten_notify_memory_growth(0);+ }+ decode(e, t = 0) {+ if (!Xi) throw new Error("ZSTDDecoder: Await .init() before decoding.");+ const n = e.byteLength, s = Xi.exports.malloc(n);+ df.set(e, s), t = t || Number(Xi.exports.ZSTD_findDecompressedSize(s, n));+ const r = Xi.exports.malloc(t), a = Xi.exports.ZSTD_decompress(r, t, s, n), o = df.slice(r, r + a);+ return Xi.exports.free(s), Xi.exports.free(r), o;+ }+}+const Gm = "AGFzbQEAAAABpQEVYAF/AX9gAn9/AGADf39/AX9gBX9/f39/AX9gAX8AYAJ/fwF/YAR/f39/AX9gA39/fwBgBn9/f39/fwF/YAd/f39/f39/AX9gAn9/AX5gAn5+AX5gAABgBX9/f39/AGAGf39/f39/AGAIf39/f39/f38AYAl/f39/f39/f38AYAABf2AIf39/f39/f38Bf2ANf39/f39/f39/f39/fwF/YAF/AX4CJwEDZW52H2Vtc2NyaXB0ZW5fbm90aWZ5X21lbW9yeV9ncm93dGgABANpaAEFAAAFAgEFCwACAQABAgIFBQcAAwABDgsBAQcAEhMHAAUBDAQEAAANBwQCAgYCBAgDAwMDBgEACQkHBgICAAYGAgQUBwYGAwIGAAMCAQgBBwUGCgoEEQAEBAEIAwgDBQgDEA8IAAcABAUBcAECAgUEAQCAAgYJAX8BQaCgwAILB2AHBm1lbW9yeQIABm1hbGxvYwAoBGZyZWUAJgxaU1REX2lzRXJyb3IAaBlaU1REX2ZpbmREZWNvbXByZXNzZWRTaXplAFQPWlNURF9kZWNvbXByZXNzAEoGX3N0YXJ0ACQJBwEAQQELASQKussBaA8AIAAgACgCBCABajYCBAsZACAAKAIAIAAoAgRBH3F0QQAgAWtBH3F2CwgAIABBiH9LC34BBH9BAyEBIAAoAgQiA0EgTQRAIAAoAggiASAAKAIQTwRAIAAQDQ8LIAAoAgwiAiABRgRAQQFBAiADQSBJGw8LIAAgASABIAJrIANBA3YiBCABIARrIAJJIgEbIgJrIgQ2AgggACADIAJBA3RrNgIEIAAgBCgAADYCAAsgAQsUAQF/IAAgARACIQIgACABEAEgAgv3AQECfyACRQRAIABCADcCACAAQQA2AhAgAEIANwIIQbh/DwsgACABNgIMIAAgAUEEajYCECACQQRPBEAgACABIAJqIgFBfGoiAzYCCCAAIAMoAAA2AgAgAUF/ai0AACIBBEAgAEEIIAEQFGs2AgQgAg8LIABBADYCBEF/DwsgACABNgIIIAAgAS0AACIDNgIAIAJBfmoiBEEBTQRAIARBAWtFBEAgACABLQACQRB0IANyIgM2AgALIAAgAS0AAUEIdCADajYCAAsgASACakF/ai0AACIBRQRAIABBADYCBEFsDwsgAEEoIAEQFCACQQN0ams2AgQgAgsWACAAIAEpAAA3AAAgACABKQAINwAICy8BAX8gAUECdEGgHWooAgAgACgCAEEgIAEgACgCBGprQR9xdnEhAiAAIAEQASACCyEAIAFCz9bTvtLHq9lCfiAAfEIfiUKHla+vmLbem55/fgsdAQF/IAAoAgggACgCDEYEfyAAKAIEQSBGBUEACwuCBAEDfyACQYDAAE8EQCAAIAEgAhBnIAAPCyAAIAJqIQMCQCAAIAFzQQNxRQRAAkAgAkEBSARAIAAhAgwBCyAAQQNxRQRAIAAhAgwBCyAAIQIDQCACIAEtAAA6AAAgAUEBaiEBIAJBAWoiAiADTw0BIAJBA3ENAAsLAkAgA0F8cSIEQcAASQ0AIAIgBEFAaiIFSw0AA0AgAiABKAIANgIAIAIgASgCBDYCBCACIAEoAgg2AgggAiABKAIMNgIMIAIgASgCEDYCECACIAEoAhQ2AhQgAiABKAIYNgIYIAIgASgCHDYCHCACIAEoAiA2AiAgAiABKAIkNgIkIAIgASgCKDYCKCACIAEoAiw2AiwgAiABKAIwNgIwIAIgASgCNDYCNCACIAEoAjg2AjggAiABKAI8NgI8IAFBQGshASACQUBrIgIgBU0NAAsLIAIgBE8NAQNAIAIgASgCADYCACABQQRqIQEgAkEEaiICIARJDQALDAELIANBBEkEQCAAIQIMAQsgA0F8aiIEIABJBEAgACECDAELIAAhAgNAIAIgAS0AADoAACACIAEtAAE6AAEgAiABLQACOgACIAIgAS0AAzoAAyABQQRqIQEgAkEEaiICIARNDQALCyACIANJBEADQCACIAEtAAA6AAAgAUEBaiEBIAJBAWoiAiADRw0ACwsgAAsMACAAIAEpAAA3AAALQQECfyAAKAIIIgEgACgCEEkEQEEDDwsgACAAKAIEIgJBB3E2AgQgACABIAJBA3ZrIgE2AgggACABKAAANgIAQQALDAAgACABKAIANgAAC/cCAQJ/AkAgACABRg0AAkAgASACaiAASwRAIAAgAmoiBCABSw0BCyAAIAEgAhALDwsgACABc0EDcSEDAkACQCAAIAFJBEAgAwRAIAAhAwwDCyAAQQNxRQRAIAAhAwwCCyAAIQMDQCACRQ0EIAMgAS0AADoAACABQQFqIQEgAkF/aiECIANBAWoiA0EDcQ0ACwwBCwJAIAMNACAEQQNxBEADQCACRQ0FIAAgAkF/aiICaiIDIAEgAmotAAA6AAAgA0EDcQ0ACwsgAkEDTQ0AA0AgACACQXxqIgJqIAEgAmooAgA2AgAgAkEDSw0ACwsgAkUNAgNAIAAgAkF/aiICaiABIAJqLQAAOgAAIAINAAsMAgsgAkEDTQ0AIAIhBANAIAMgASgCADYCACABQQRqIQEgA0EEaiEDIARBfGoiBEEDSw0ACyACQQNxIQILIAJFDQADQCADIAEtAAA6AAAgA0EBaiEDIAFBAWohASACQX9qIgINAAsLIAAL8wICAn8BfgJAIAJFDQAgACACaiIDQX9qIAE6AAAgACABOgAAIAJBA0kNACADQX5qIAE6AAAgACABOgABIANBfWogAToAACAAIAE6AAIgAkEHSQ0AIANBfGogAToAACAAIAE6AAMgAkEJSQ0AIABBACAAa0EDcSIEaiIDIAFB/wFxQYGChAhsIgE2AgAgAyACIARrQXxxIgRqIgJBfGogATYCACAEQQlJDQAgAyABNgIIIAMgATYCBCACQXhqIAE2AgAgAkF0aiABNgIAIARBGUkNACADIAE2AhggAyABNgIUIAMgATYCECADIAE2AgwgAkFwaiABNgIAIAJBbGogATYCACACQWhqIAE2AgAgAkFkaiABNgIAIAQgA0EEcUEYciIEayICQSBJDQAgAa0iBUIghiAFhCEFIAMgBGohAQNAIAEgBTcDGCABIAU3AxAgASAFNwMIIAEgBTcDACABQSBqIQEgAkFgaiICQR9LDQALCyAACy8BAn8gACgCBCAAKAIAQQJ0aiICLQACIQMgACACLwEAIAEgAi0AAxAIajYCACADCy8BAn8gACgCBCAAKAIAQQJ0aiICLQACIQMgACACLwEAIAEgAi0AAxAFajYCACADCx8AIAAgASACKAIEEAg2AgAgARAEGiAAIAJBCGo2AgQLCAAgAGdBH3MLugUBDX8jAEEQayIKJAACfyAEQQNNBEAgCkEANgIMIApBDGogAyAEEAsaIAAgASACIApBDGpBBBAVIgBBbCAAEAMbIAAgACAESxsMAQsgAEEAIAEoAgBBAXRBAmoQECENQVQgAygAACIGQQ9xIgBBCksNABogAiAAQQVqNgIAIAMgBGoiAkF8aiEMIAJBeWohDiACQXtqIRAgAEEGaiELQQQhBSAGQQR2IQRBICAAdCIAQQFyIQkgASgCACEPQQAhAiADIQYCQANAIAlBAkggAiAPS3JFBEAgAiEHAkAgCARAA0AgBEH//wNxQf//A0YEQCAHQRhqIQcgBiAQSQR/IAZBAmoiBigAACAFdgUgBUEQaiEFIARBEHYLIQQMAQsLA0AgBEEDcSIIQQNGBEAgBUECaiEFIARBAnYhBCAHQQNqIQcMAQsLIAcgCGoiByAPSw0EIAVBAmohBQNAIAIgB0kEQCANIAJBAXRqQQA7AQAgAkEBaiECDAELCyAGIA5LQQAgBiAFQQN1aiIHIAxLG0UEQCAHKAAAIAVBB3EiBXYhBAwCCyAEQQJ2IQQLIAYhBwsCfyALQX9qIAQgAEF/anEiBiAAQQF0QX9qIgggCWsiEUkNABogBCAIcSIEQQAgESAEIABIG2shBiALCyEIIA0gAkEBdGogBkF/aiIEOwEAIAlBASAGayAEIAZBAUgbayEJA0AgCSAASARAIABBAXUhACALQX9qIQsMAQsLAn8gByAOS0EAIAcgBSAIaiIFQQN1aiIGIAxLG0UEQCAFQQdxDAELIAUgDCIGIAdrQQN0awshBSACQQFqIQIgBEUhCCAGKAAAIAVBH3F2IQQMAQsLQWwgCUEBRyAFQSBKcg0BGiABIAJBf2o2AgAgBiAFQQdqQQN1aiADawwBC0FQCyEAIApBEGokACAACwkAQQFBBSAAGwsMACAAIAEoAAA2AAALqgMBCn8jAEHwAGsiCiQAIAJBAWohDiAAQQhqIQtBgIAEIAVBf2p0QRB1IQxBACECQQEhBkEBIAV0IglBf2oiDyEIA0AgAiAORkUEQAJAIAEgAkEBdCINai8BACIHQf//A0YEQCALIAhBA3RqIAI2AgQgCEF/aiEIQQEhBwwBCyAGQQAgDCAHQRB0QRB1ShshBgsgCiANaiAHOwEAIAJBAWohAgwBCwsgACAFNgIEIAAgBjYCACAJQQN2IAlBAXZqQQNqIQxBACEAQQAhBkEAIQIDQCAGIA5GBEADQAJAIAAgCUYNACAKIAsgAEEDdGoiASgCBCIGQQF0aiICIAIvAQAiAkEBajsBACABIAUgAhAUayIIOgADIAEgAiAIQf8BcXQgCWs7AQAgASAEIAZBAnQiAmooAgA6AAIgASACIANqKAIANgIEIABBAWohAAwBCwsFIAEgBkEBdGouAQAhDUEAIQcDQCAHIA1ORQRAIAsgAkEDdGogBjYCBANAIAIgDGogD3EiAiAISw0ACyAHQQFqIQcMAQsLIAZBAWohBgwBCwsgCkHwAGokAAsjAEIAIAEQCSAAhUKHla+vmLbem55/fkLj3MqV/M7y9YV/fAsQACAAQn43AwggACABNgIACyQBAX8gAARAIAEoAgQiAgRAIAEoAgggACACEQEADwsgABAmCwsfACAAIAEgAi8BABAINgIAIAEQBBogACACQQRqNgIEC0oBAX9BoCAoAgAiASAAaiIAQX9MBEBBiCBBMDYCAEF/DwsCQCAAPwBBEHRNDQAgABBmDQBBiCBBMDYCAEF/DwtBoCAgADYCACABC9cBAQh/Qbp/IQoCQCACKAIEIgggAigCACIJaiIOIAEgAGtLDQBBbCEKIAkgBCADKAIAIgtrSw0AIAAgCWoiBCACKAIIIgxrIQ0gACABQWBqIg8gCyAJQQAQKSADIAkgC2o2AgACQAJAIAwgBCAFa00EQCANIQUMAQsgDCAEIAZrSw0CIAcgDSAFayIAaiIBIAhqIAdNBEAgBCABIAgQDxoMAgsgBCABQQAgAGsQDyEBIAIgACAIaiIINgIEIAEgAGshBAsgBCAPIAUgCEEBECkLIA4hCgsgCgubAgEBfyMAQYABayINJAAgDSADNgJ8AkAgAkEDSwRAQX8hCQwBCwJAAkACQAJAIAJBAWsOAwADAgELIAZFBEBBuH8hCQwEC0FsIQkgBS0AACICIANLDQMgACAHIAJBAnQiAmooAgAgAiAIaigCABA7IAEgADYCAEEBIQkMAwsgASAJNgIAQQAhCQwCCyAKRQRAQWwhCQwCC0EAIQkgC0UgDEEZSHINAUEIIAR0QQhqIQBBACECA0AgAiAATw0CIAJBQGshAgwAAAsAC0FsIQkgDSANQfwAaiANQfgAaiAFIAYQFSICEAMNACANKAJ4IgMgBEsNACAAIA0gDSgCfCAHIAggAxAYIAEgADYCACACIQkLIA1BgAFqJAAgCQsLACAAIAEgAhALGgsQACAALwAAIAAtAAJBEHRyCy8AAn9BuH8gAUEISQ0AGkFyIAAoAAQiAEF3Sw0AGkG4fyAAQQhqIgAgACABSxsLCwkAIAAgATsAAAsDAAELigYBBX8gACAAKAIAIgVBfnE2AgBBACAAIAVBAXZqQYQgKAIAIgQgAEYbIQECQAJAIAAoAgQiAkUNACACKAIAIgNBAXENACACQQhqIgUgA0EBdkF4aiIDQQggA0EISxtnQR9zQQJ0QYAfaiIDKAIARgRAIAMgAigCDDYCAAsgAigCCCIDBEAgAyACKAIMNgIECyACKAIMIgMEQCADIAIoAgg2AgALIAIgAigCACAAKAIAQX5xajYCAEGEICEAAkACQCABRQ0AIAEgAjYCBCABKAIAIgNBAXENASADQQF2QXhqIgNBCCADQQhLG2dBH3NBAnRBgB9qIgMoAgAgAUEIakYEQCADIAEoAgw2AgALIAEoAggiAwRAIAMgASgCDDYCBAsgASgCDCIDBEAgAyABKAIINgIAQYQgKAIAIQQLIAIgAigCACABKAIAQX5xajYCACABIARGDQAgASABKAIAQQF2akEEaiEACyAAIAI2AgALIAIoAgBBAXZBeGoiAEEIIABBCEsbZ0Efc0ECdEGAH2oiASgCACEAIAEgBTYCACACIAA2AgwgAkEANgIIIABFDQEgACAFNgIADwsCQCABRQ0AIAEoAgAiAkEBcQ0AIAJBAXZBeGoiAkEIIAJBCEsbZ0Efc0ECdEGAH2oiAigCACABQQhqRgRAIAIgASgCDDYCAAsgASgCCCICBEAgAiABKAIMNgIECyABKAIMIgIEQCACIAEoAgg2AgBBhCAoAgAhBAsgACAAKAIAIAEoAgBBfnFqIgI2AgACQCABIARHBEAgASABKAIAQQF2aiAANgIEIAAoAgAhAgwBC0GEICAANgIACyACQQF2QXhqIgFBCCABQQhLG2dBH3NBAnRBgB9qIgIoAgAhASACIABBCGoiAjYCACAAIAE2AgwgAEEANgIIIAFFDQEgASACNgIADwsgBUEBdkF4aiIBQQggAUEISxtnQR9zQQJ0QYAfaiICKAIAIQEgAiAAQQhqIgI2AgAgACABNgIMIABBADYCCCABRQ0AIAEgAjYCAAsLDgAgAARAIABBeGoQJQsLgAIBA38CQCAAQQ9qQXhxQYQgKAIAKAIAQQF2ayICEB1Bf0YNAAJAQYQgKAIAIgAoAgAiAUEBcQ0AIAFBAXZBeGoiAUEIIAFBCEsbZ0Efc0ECdEGAH2oiASgCACAAQQhqRgRAIAEgACgCDDYCAAsgACgCCCIBBEAgASAAKAIMNgIECyAAKAIMIgFFDQAgASAAKAIINgIAC0EBIQEgACAAKAIAIAJBAXRqIgI2AgAgAkEBcQ0AIAJBAXZBeGoiAkEIIAJBCEsbZ0Efc0ECdEGAH2oiAygCACECIAMgAEEIaiIDNgIAIAAgAjYCDCAAQQA2AgggAkUNACACIAM2AgALIAELtwIBA38CQAJAIABBASAAGyICEDgiAA0AAkACQEGEICgCACIARQ0AIAAoAgAiA0EBcQ0AIAAgA0EBcjYCACADQQF2QXhqIgFBCCABQQhLG2dBH3NBAnRBgB9qIgEoAgAgAEEIakYEQCABIAAoAgw2AgALIAAoAggiAQRAIAEgACgCDDYCBAsgACgCDCIBBEAgASAAKAIINgIACyACECchAkEAIQFBhCAoAgAhACACDQEgACAAKAIAQX5xNgIAQQAPCyACQQ9qQXhxIgMQHSICQX9GDQIgAkEHakF4cSIAIAJHBEAgACACaxAdQX9GDQMLAkBBhCAoAgAiAUUEQEGAICAANgIADAELIAAgATYCBAtBhCAgADYCACAAIANBAXRBAXI2AgAMAQsgAEUNAQsgAEEIaiEBCyABC7kDAQJ/IAAgA2ohBQJAIANBB0wEQANAIAAgBU8NAiAAIAItAAA6AAAgAEEBaiEAIAJBAWohAgwAAAsACyAEQQFGBEACQCAAIAJrIgZBB00EQCAAIAItAAA6AAAgACACLQABOgABIAAgAi0AAjoAAiAAIAItAAM6AAMgAEEEaiACIAZBAnQiBkHAHmooAgBqIgIQFyACIAZB4B5qKAIAayECDAELIAAgAhAMCyACQQhqIQIgAEEIaiEACwJAAkACQAJAIAUgAU0EQCAAIANqIQEgBEEBRyAAIAJrQQ9Kcg0BA0AgACACEAwgAkEIaiECIABBCGoiACABSQ0ACwwFCyAAIAFLBEAgACEBDAQLIARBAUcgACACa0EPSnINASAAIQMgAiEEA0AgAyAEEAwgBEEIaiEEIANBCGoiAyABSQ0ACwwCCwNAIAAgAhAHIAJBEGohAiAAQRBqIgAgAUkNAAsMAwsgACEDIAIhBANAIAMgBBAHIARBEGohBCADQRBqIgMgAUkNAAsLIAIgASAAa2ohAgsDQCABIAVPDQEgASACLQAAOgAAIAFBAWohASACQQFqIQIMAAALAAsLQQECfyAAIAAoArjgASIDNgLE4AEgACgCvOABIQQgACABNgK84AEgACABIAJqNgK44AEgACABIAQgA2tqNgLA4AELpgEBAX8gACAAKALs4QEQFjYCyOABIABCADcD+OABIABCADcDuOABIABBwOABakIANwMAIABBqNAAaiIBQYyAgOAANgIAIABBADYCmOIBIABCADcDiOEBIABCAzcDgOEBIABBrNABakHgEikCADcCACAAQbTQAWpB6BIoAgA2AgAgACABNgIMIAAgAEGYIGo2AgggACAAQaAwajYCBCAAIABBEGo2AgALYQEBf0G4fyEDAkAgAUEDSQ0AIAIgABAhIgFBA3YiADYCCCACIAFBAXE2AgQgAiABQQF2QQNxIgM2AgACQCADQX9qIgFBAksNAAJAIAFBAWsOAgEAAgtBbA8LIAAhAwsgAwsMACAAIAEgAkEAEC4LiAQCA38CfiADEBYhBCAAQQBBKBAQIQAgBCACSwRAIAQPCyABRQRAQX8PCwJAAkAgA0EBRg0AIAEoAAAiBkGo6r5pRg0AQXYhAyAGQXBxQdDUtMIBRw0BQQghAyACQQhJDQEgAEEAQSgQECEAIAEoAAQhASAAQQE2AhQgACABrTcDAEEADwsgASACIAMQLyIDIAJLDQAgACADNgIYQXIhAyABIARqIgVBf2otAAAiAkEIcQ0AIAJBIHEiBkUEQEFwIQMgBS0AACIFQacBSw0BIAVBB3GtQgEgBUEDdkEKaq2GIgdCA4h+IAd8IQggBEEBaiEECyACQQZ2IQMgAkECdiEFAkAgAkEDcUF/aiICQQJLBEBBACECDAELAkACQAJAIAJBAWsOAgECAAsgASAEai0AACECIARBAWohBAwCCyABIARqLwAAIQIgBEECaiEEDAELIAEgBGooAAAhAiAEQQRqIQQLIAVBAXEhBQJ+AkACQAJAIANBf2oiA0ECTQRAIANBAWsOAgIDAQtCfyAGRQ0DGiABIARqMQAADAMLIAEgBGovAACtQoACfAwCCyABIARqKAAArQwBCyABIARqKQAACyEHIAAgBTYCICAAIAI2AhwgACAHNwMAQQAhAyAAQQA2AhQgACAHIAggBhsiBzcDCCAAIAdCgIAIIAdCgIAIVBs+AhALIAMLWwEBf0G4fyEDIAIQFiICIAFNBH8gACACakF/ai0AACIAQQNxQQJ0QaAeaigCACACaiAAQQZ2IgFBAnRBsB5qKAIAaiAAQSBxIgBFaiABRSAAQQV2cWoFQbh/CwsdACAAKAKQ4gEQWiAAQQA2AqDiASAAQgA3A5DiAQu1AwEFfyMAQZACayIKJABBuH8hBgJAIAVFDQAgBCwAACIIQf8BcSEHAkAgCEF/TARAIAdBgn9qQQF2IgggBU8NAkFsIQYgB0GBf2oiBUGAAk8NAiAEQQFqIQdBACEGA0AgBiAFTwRAIAUhBiAIIQcMAwUgACAGaiAHIAZBAXZqIgQtAABBBHY6AAAgACAGQQFyaiAELQAAQQ9xOgAAIAZBAmohBgwBCwAACwALIAcgBU8NASAAIARBAWogByAKEFMiBhADDQELIAYhBEEAIQYgAUEAQTQQECEJQQAhBQNAIAQgBkcEQCAAIAZqIggtAAAiAUELSwRAQWwhBgwDBSAJIAFBAnRqIgEgASgCAEEBajYCACAGQQFqIQZBASAILQAAdEEBdSAFaiEFDAILAAsLQWwhBiAFRQ0AIAUQFEEBaiIBQQxLDQAgAyABNgIAQQFBASABdCAFayIDEBQiAXQgA0cNACAAIARqIAFBAWoiADoAACAJIABBAnRqIgAgACgCAEEBajYCACAJKAIEIgBBAkkgAEEBcXINACACIARBAWo2AgAgB0EBaiEGCyAKQZACaiQAIAYLxhEBDH8jAEHwAGsiBSQAQWwhCwJAIANBCkkNACACLwAAIQogAi8AAiEJIAIvAAQhByAFQQhqIAQQDgJAIAMgByAJIApqakEGaiIMSQ0AIAUtAAohCCAFQdgAaiACQQZqIgIgChAGIgsQAw0BIAVBQGsgAiAKaiICIAkQBiILEAMNASAFQShqIAIgCWoiAiAHEAYiCxADDQEgBUEQaiACIAdqIAMgDGsQBiILEAMNASAAIAFqIg9BfWohECAEQQRqIQZBASELIAAgAUEDakECdiIDaiIMIANqIgIgA2oiDiEDIAIhBCAMIQcDQCALIAMgEElxBEAgACAGIAVB2ABqIAgQAkECdGoiCS8BADsAACAFQdgAaiAJLQACEAEgCS0AAyELIAcgBiAFQUBrIAgQAkECdGoiCS8BADsAACAFQUBrIAktAAIQASAJLQADIQogBCAGIAVBKGogCBACQQJ0aiIJLwEAOwAAIAVBKGogCS0AAhABIAktAAMhCSADIAYgBUEQaiAIEAJBAnRqIg0vAQA7AAAgBUEQaiANLQACEAEgDS0AAyENIAAgC2oiCyAGIAVB2ABqIAgQAkECdGoiAC8BADsAACAFQdgAaiAALQACEAEgAC0AAyEAIAcgCmoiCiAGIAVBQGsgCBACQQJ0aiIHLwEAOwAAIAVBQGsgBy0AAhABIActAAMhByAEIAlqIgkgBiAFQShqIAgQAkECdGoiBC8BADsAACAFQShqIAQtAAIQASAELQADIQQgAyANaiIDIAYgBUEQaiAIEAJBAnRqIg0vAQA7AAAgBUEQaiANLQACEAEgACALaiEAIAcgCmohByAEIAlqIQQgAyANLQADaiEDIAVB2ABqEA0gBUFAaxANciAFQShqEA1yIAVBEGoQDXJFIQsMAQsLIAQgDksgByACS3INAEFsIQsgACAMSw0BIAxBfWohCQNAQQAgACAJSSAFQdgAahAEGwRAIAAgBiAFQdgAaiAIEAJBAnRqIgovAQA7AAAgBUHYAGogCi0AAhABIAAgCi0AA2oiACAGIAVB2ABqIAgQAkECdGoiCi8BADsAACAFQdgAaiAKLQACEAEgACAKLQADaiEADAEFIAxBfmohCgNAIAVB2ABqEAQgACAKS3JFBEAgACAGIAVB2ABqIAgQAkECdGoiCS8BADsAACAFQdgAaiAJLQACEAEgACAJLQADaiEADAELCwNAIAAgCk0EQCAAIAYgBUHYAGogCBACQQJ0aiIJLwEAOwAAIAVB2ABqIAktAAIQASAAIAktAANqIQAMAQsLAkAgACAMTw0AIAAgBiAFQdgAaiAIEAIiAEECdGoiDC0AADoAACAMLQADQQFGBEAgBUHYAGogDC0AAhABDAELIAUoAlxBH0sNACAFQdgAaiAGIABBAnRqLQACEAEgBSgCXEEhSQ0AIAVBIDYCXAsgAkF9aiEMA0BBACAHIAxJIAVBQGsQBBsEQCAHIAYgBUFAayAIEAJBAnRqIgAvAQA7AAAgBUFAayAALQACEAEgByAALQADaiIAIAYgBUFAayAIEAJBAnRqIgcvAQA7AAAgBUFAayAHLQACEAEgACAHLQADaiEHDAEFIAJBfmohDANAIAVBQGsQBCAHIAxLckUEQCAHIAYgBUFAayAIEAJBAnRqIgAvAQA7AAAgBUFAayAALQACEAEgByAALQADaiEHDAELCwNAIAcgDE0EQCAHIAYgBUFAayAIEAJBAnRqIgAvAQA7AAAgBUFAayAALQACEAEgByAALQADaiEHDAELCwJAIAcgAk8NACAHIAYgBUFAayAIEAIiAEECdGoiAi0AADoAACACLQADQQFGBEAgBUFAayACLQACEAEMAQsgBSgCREEfSw0AIAVBQGsgBiAAQQJ0ai0AAhABIAUoAkRBIUkNACAFQSA2AkQLIA5BfWohAgNAQQAgBCACSSAFQShqEAQbBEAgBCAGIAVBKGogCBACQQJ0aiIALwEAOwAAIAVBKGogAC0AAhABIAQgAC0AA2oiACAGIAVBKGogCBACQQJ0aiIELwEAOwAAIAVBKGogBC0AAhABIAAgBC0AA2ohBAwBBSAOQX5qIQIDQCAFQShqEAQgBCACS3JFBEAgBCAGIAVBKGogCBACQQJ0aiIALwEAOwAAIAVBKGogAC0AAhABIAQgAC0AA2ohBAwBCwsDQCAEIAJNBEAgBCAGIAVBKGogCBACQQJ0aiIALwEAOwAAIAVBKGogAC0AAhABIAQgAC0AA2ohBAwBCwsCQCAEIA5PDQAgBCAGIAVBKGogCBACIgBBAnRqIgItAAA6AAAgAi0AA0EBRgRAIAVBKGogAi0AAhABDAELIAUoAixBH0sNACAFQShqIAYgAEECdGotAAIQASAFKAIsQSFJDQAgBUEgNgIsCwNAQQAgAyAQSSAFQRBqEAQbBEAgAyAGIAVBEGogCBACQQJ0aiIALwEAOwAAIAVBEGogAC0AAhABIAMgAC0AA2oiACAGIAVBEGogCBACQQJ0aiICLwEAOwAAIAVBEGogAi0AAhABIAAgAi0AA2ohAwwBBSAPQX5qIQIDQCAFQRBqEAQgAyACS3JFBEAgAyAGIAVBEGogCBACQQJ0aiIALwEAOwAAIAVBEGogAC0AAhABIAMgAC0AA2ohAwwBCwsDQCADIAJNBEAgAyAGIAVBEGogCBACQQJ0aiIALwEAOwAAIAVBEGogAC0AAhABIAMgAC0AA2ohAwwBCwsCQCADIA9PDQAgAyAGIAVBEGogCBACIgBBAnRqIgItAAA6AAAgAi0AA0EBRgRAIAVBEGogAi0AAhABDAELIAUoAhRBH0sNACAFQRBqIAYgAEECdGotAAIQASAFKAIUQSFJDQAgBUEgNgIUCyABQWwgBUHYAGoQCiAFQUBrEApxIAVBKGoQCnEgBUEQahAKcRshCwwJCwAACwALAAALAAsAAAsACwAACwALQWwhCwsgBUHwAGokACALC7UEAQ5/IwBBEGsiBiQAIAZBBGogABAOQVQhBQJAIARB3AtJDQAgBi0ABCEHIANB8ARqQQBB7AAQECEIIAdBDEsNACADQdwJaiIJIAggBkEIaiAGQQxqIAEgAhAxIhAQA0UEQCAGKAIMIgQgB0sNASADQdwFaiEPIANBpAVqIREgAEEEaiESIANBqAVqIQEgBCEFA0AgBSICQX9qIQUgCCACQQJ0aigCAEUNAAsgAkEBaiEOQQEhBQNAIAUgDk9FBEAgCCAFQQJ0IgtqKAIAIQwgASALaiAKNgIAIAVBAWohBSAKIAxqIQoMAQsLIAEgCjYCAEEAIQUgBigCCCELA0AgBSALRkUEQCABIAUgCWotAAAiDEECdGoiDSANKAIAIg1BAWo2AgAgDyANQQF0aiINIAw6AAEgDSAFOgAAIAVBAWohBQwBCwtBACEBIANBADYCqAUgBEF/cyAHaiEJQQEhBQNAIAUgDk9FBEAgCCAFQQJ0IgtqKAIAIQwgAyALaiABNgIAIAwgBSAJanQgAWohASAFQQFqIQUMAQsLIAcgBEEBaiIBIAJrIgRrQQFqIQgDQEEBIQUgBCAIT0UEQANAIAUgDk9FBEAgBUECdCIJIAMgBEE0bGpqIAMgCWooAgAgBHY2AgAgBUEBaiEFDAELCyAEQQFqIQQMAQsLIBIgByAPIAogESADIAIgARBkIAZBAToABSAGIAc6AAYgACAGKAIENgIACyAQIQULIAZBEGokACAFC8ENAQt/IwBB8ABrIgUkAEFsIQkCQCADQQpJDQAgAi8AACEKIAIvAAIhDCACLwAEIQYgBUEIaiAEEA4CQCADIAYgCiAMampBBmoiDUkNACAFLQAKIQcgBUHYAGogAkEGaiICIAoQBiIJEAMNASAFQUBrIAIgCmoiAiAMEAYiCRADDQEgBUEoaiACIAxqIgIgBhAGIgkQAw0BIAVBEGogAiAGaiADIA1rEAYiCRADDQEgACABaiIOQX1qIQ8gBEEEaiEGQQEhCSAAIAFBA2pBAnYiAmoiCiACaiIMIAJqIg0hAyAMIQQgCiECA0AgCSADIA9JcQRAIAYgBUHYAGogBxACQQF0aiIILQAAIQsgBUHYAGogCC0AARABIAAgCzoAACAGIAVBQGsgBxACQQF0aiIILQAAIQsgBUFAayAILQABEAEgAiALOgAAIAYgBUEoaiAHEAJBAXRqIggtAAAhCyAFQShqIAgtAAEQASAEIAs6AAAgBiAFQRBqIAcQAkEBdGoiCC0AACELIAVBEGogCC0AARABIAMgCzoAACAGIAVB2ABqIAcQAkEBdGoiCC0AACELIAVB2ABqIAgtAAEQASAAIAs6AAEgBiAFQUBrIAcQAkEBdGoiCC0AACELIAVBQGsgCC0AARABIAIgCzoAASAGIAVBKGogBxACQQF0aiIILQAAIQsgBUEoaiAILQABEAEgBCALOgABIAYgBUEQaiAHEAJBAXRqIggtAAAhCyAFQRBqIAgtAAEQASADIAs6AAEgA0ECaiEDIARBAmohBCACQQJqIQIgAEECaiEAIAkgBUHYAGoQDUVxIAVBQGsQDUVxIAVBKGoQDUVxIAVBEGoQDUVxIQkMAQsLIAQgDUsgAiAMS3INAEFsIQkgACAKSw0BIApBfWohCQNAIAVB2ABqEAQgACAJT3JFBEAgBiAFQdgAaiAHEAJBAXRqIggtAAAhCyAFQdgAaiAILQABEAEgACALOgAAIAYgBUHYAGogBxACQQF0aiIILQAAIQsgBUHYAGogCC0AARABIAAgCzoAASAAQQJqIQAMAQsLA0AgBUHYAGoQBCAAIApPckUEQCAGIAVB2ABqIAcQAkEBdGoiCS0AACEIIAVB2ABqIAktAAEQASAAIAg6AAAgAEEBaiEADAELCwNAIAAgCkkEQCAGIAVB2ABqIAcQAkEBdGoiCS0AACEIIAVB2ABqIAktAAEQASAAIAg6AAAgAEEBaiEADAELCyAMQX1qIQADQCAFQUBrEAQgAiAAT3JFBEAgBiAFQUBrIAcQAkEBdGoiCi0AACEJIAVBQGsgCi0AARABIAIgCToAACAGIAVBQGsgBxACQQF0aiIKLQAAIQkgBUFAayAKLQABEAEgAiAJOgABIAJBAmohAgwBCwsDQCAFQUBrEAQgAiAMT3JFBEAgBiAFQUBrIAcQAkEBdGoiAC0AACEKIAVBQGsgAC0AARABIAIgCjoAACACQQFqIQIMAQsLA0AgAiAMSQRAIAYgBUFAayAHEAJBAXRqIgAtAAAhCiAFQUBrIAAtAAEQASACIAo6AAAgAkEBaiECDAELCyANQX1qIQADQCAFQShqEAQgBCAAT3JFBEAgBiAFQShqIAcQAkEBdGoiAi0AACEKIAVBKGogAi0AARABIAQgCjoAACAGIAVBKGogBxACQQF0aiICLQAAIQogBUEoaiACLQABEAEgBCAKOgABIARBAmohBAwBCwsDQCAFQShqEAQgBCANT3JFBEAgBiAFQShqIAcQAkEBdGoiAC0AACECIAVBKGogAC0AARABIAQgAjoAACAEQQFqIQQMAQsLA0AgBCANSQRAIAYgBUEoaiAHEAJBAXRqIgAtAAAhAiAFQShqIAAtAAEQASAEIAI6AAAgBEEBaiEEDAELCwNAIAVBEGoQBCADIA9PckUEQCAGIAVBEGogBxACQQF0aiIALQAAIQIgBUEQaiAALQABEAEgAyACOgAAIAYgBUEQaiAHEAJBAXRqIgAtAAAhAiAFQRBqIAAtAAEQASADIAI6AAEgA0ECaiEDDAELCwNAIAVBEGoQBCADIA5PckUEQCAGIAVBEGogBxACQQF0aiIALQAAIQIgBUEQaiAALQABEAEgAyACOgAAIANBAWohAwwBCwsDQCADIA5JBEAgBiAFQRBqIAcQAkEBdGoiAC0AACECIAVBEGogAC0AARABIAMgAjoAACADQQFqIQMMAQsLIAFBbCAFQdgAahAKIAVBQGsQCnEgBUEoahAKcSAFQRBqEApxGyEJDAELQWwhCQsgBUHwAGokACAJC8oCAQR/IwBBIGsiBSQAIAUgBBAOIAUtAAIhByAFQQhqIAIgAxAGIgIQA0UEQCAEQQRqIQIgACABaiIDQX1qIQQDQCAFQQhqEAQgACAET3JFBEAgAiAFQQhqIAcQAkEBdGoiBi0AACEIIAVBCGogBi0AARABIAAgCDoAACACIAVBCGogBxACQQF0aiIGLQAAIQggBUEIaiAGLQABEAEgACAIOgABIABBAmohAAwBCwsDQCAFQQhqEAQgACADT3JFBEAgAiAFQQhqIAcQAkEBdGoiBC0AACEGIAVBCGogBC0AARABIAAgBjoAACAAQQFqIQAMAQsLA0AgACADT0UEQCACIAVBCGogBxACQQF0aiIELQAAIQYgBUEIaiAELQABEAEgACAGOgAAIABBAWohAAwBCwsgAUFsIAVBCGoQChshAgsgBUEgaiQAIAILtgMBCX8jAEEQayIGJAAgBkEANgIMIAZBADYCCEFUIQQCQAJAIANBQGsiDCADIAZBCGogBkEMaiABIAIQMSICEAMNACAGQQRqIAAQDiAGKAIMIgcgBi0ABEEBaksNASAAQQRqIQogBkEAOgAFIAYgBzoABiAAIAYoAgQ2AgAgB0EBaiEJQQEhBANAIAQgCUkEQCADIARBAnRqIgEoAgAhACABIAU2AgAgACAEQX9qdCAFaiEFIARBAWohBAwBCwsgB0EBaiEHQQAhBSAGKAIIIQkDQCAFIAlGDQEgAyAFIAxqLQAAIgRBAnRqIgBBASAEdEEBdSILIAAoAgAiAWoiADYCACAHIARrIQhBACEEAkAgC0EDTQRAA0AgBCALRg0CIAogASAEakEBdGoiACAIOgABIAAgBToAACAEQQFqIQQMAAALAAsDQCABIABPDQEgCiABQQF0aiIEIAg6AAEgBCAFOgAAIAQgCDoAAyAEIAU6AAIgBCAIOgAFIAQgBToABCAEIAg6AAcgBCAFOgAGIAFBBGohAQwAAAsACyAFQQFqIQUMAAALAAsgAiEECyAGQRBqJAAgBAutAQECfwJAQYQgKAIAIABHIAAoAgBBAXYiAyABa0F4aiICQXhxQQhHcgR/IAIFIAMQJ0UNASACQQhqC0EQSQ0AIAAgACgCACICQQFxIAAgAWpBD2pBeHEiASAAa0EBdHI2AgAgASAANgIEIAEgASgCAEEBcSAAIAJBAXZqIAFrIgJBAXRyNgIAQYQgIAEgAkH/////B3FqQQRqQYQgKAIAIABGGyABNgIAIAEQJQsLygIBBX8CQAJAAkAgAEEIIABBCEsbZ0EfcyAAaUEBR2oiAUEESSAAIAF2cg0AIAFBAnRB/B5qKAIAIgJFDQADQCACQXhqIgMoAgBBAXZBeGoiBSAATwRAIAIgBUEIIAVBCEsbZ0Efc0ECdEGAH2oiASgCAEYEQCABIAIoAgQ2AgALDAMLIARBHksNASAEQQFqIQQgAigCBCICDQALC0EAIQMgAUEgTw0BA0AgAUECdEGAH2ooAgAiAkUEQCABQR5LIQIgAUEBaiEBIAJFDQEMAwsLIAIgAkF4aiIDKAIAQQF2QXhqIgFBCCABQQhLG2dBH3NBAnRBgB9qIgEoAgBGBEAgASACKAIENgIACwsgAigCACIBBEAgASACKAIENgIECyACKAIEIgEEQCABIAIoAgA2AgALIAMgAygCAEEBcjYCACADIAAQNwsgAwvhCwINfwV+IwBB8ABrIgckACAHIAAoAvDhASIINgJcIAEgAmohDSAIIAAoAoDiAWohDwJAAkAgBUUEQCABIQQMAQsgACgCxOABIRAgACgCwOABIREgACgCvOABIQ4gAEEBNgKM4QFBACEIA0AgCEEDRwRAIAcgCEECdCICaiAAIAJqQazQAWooAgA2AkQgCEEBaiEIDAELC0FsIQwgB0EYaiADIAQQBhADDQEgB0EsaiAHQRhqIAAoAgAQEyAHQTRqIAdBGGogACgCCBATIAdBPGogB0EYaiAAKAIEEBMgDUFgaiESIAEhBEEAIQwDQCAHKAIwIAcoAixBA3RqKQIAIhRCEIinQf8BcSEIIAcoAkAgBygCPEEDdGopAgAiFUIQiKdB/wFxIQsgBygCOCAHKAI0QQN0aikCACIWQiCIpyEJIBVCIIghFyAUQiCIpyECAkAgFkIQiKdB/wFxIgNBAk8EQAJAIAZFIANBGUlyRQRAIAkgB0EYaiADQSAgBygCHGsiCiAKIANLGyIKEAUgAyAKayIDdGohCSAHQRhqEAQaIANFDQEgB0EYaiADEAUgCWohCQwBCyAHQRhqIAMQBSAJaiEJIAdBGGoQBBoLIAcpAkQhGCAHIAk2AkQgByAYNwNIDAELAkAgA0UEQCACBEAgBygCRCEJDAMLIAcoAkghCQwBCwJAAkAgB0EYakEBEAUgCSACRWpqIgNBA0YEQCAHKAJEQX9qIgMgA0VqIQkMAQsgA0ECdCAHaigCRCIJIAlFaiEJIANBAUYNAQsgByAHKAJINgJMCwsgByAHKAJENgJIIAcgCTYCRAsgF6chAyALBEAgB0EYaiALEAUgA2ohAwsgCCALakEUTwRAIAdBGGoQBBoLIAgEQCAHQRhqIAgQBSACaiECCyAHQRhqEAQaIAcgB0EYaiAUQhiIp0H/AXEQCCAUp0H//wNxajYCLCAHIAdBGGogFUIYiKdB/wFxEAggFadB//8DcWo2AjwgB0EYahAEGiAHIAdBGGogFkIYiKdB/wFxEAggFqdB//8DcWo2AjQgByACNgJgIAcoAlwhCiAHIAk2AmggByADNgJkAkACQAJAIAQgAiADaiILaiASSw0AIAIgCmoiEyAPSw0AIA0gBGsgC0Egak8NAQsgByAHKQNoNwMQIAcgBykDYDcDCCAEIA0gB0EIaiAHQdwAaiAPIA4gESAQEB4hCwwBCyACIARqIQggBCAKEAcgAkERTwRAIARBEGohAgNAIAIgCkEQaiIKEAcgAkEQaiICIAhJDQALCyAIIAlrIQIgByATNgJcIAkgCCAOa0sEQCAJIAggEWtLBEBBbCELDAILIBAgAiAOayICaiIKIANqIBBNBEAgCCAKIAMQDxoMAgsgCCAKQQAgAmsQDyEIIAcgAiADaiIDNgJkIAggAmshCCAOIQILIAlBEE8EQCADIAhqIQMDQCAIIAIQByACQRBqIQIgCEEQaiIIIANJDQALDAELAkAgCUEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgCUECdCIDQcAeaigCAGoiAhAXIAIgA0HgHmooAgBrIQIgBygCZCEDDAELIAggAhAMCyADQQlJDQAgAyAIaiEDIAhBCGoiCCACQQhqIgJrQQ9MBEADQCAIIAIQDCACQQhqIQIgCEEIaiIIIANJDQAMAgALAAsDQCAIIAIQByACQRBqIQIgCEEQaiIIIANJDQALCyAHQRhqEAQaIAsgDCALEAMiAhshDCAEIAQgC2ogAhshBCAFQX9qIgUNAAsgDBADDQFBbCEMIAdBGGoQBEECSQ0BQQAhCANAIAhBA0cEQCAAIAhBAnQiAmpBrNABaiACIAdqKAJENgIAIAhBAWohCAwBCwsgBygCXCEIC0G6fyEMIA8gCGsiACANIARrSw0AIAQEfyAEIAggABALIABqBUEACyABayEMCyAHQfAAaiQAIAwLkRcCFn8FfiMAQdABayIHJAAgByAAKALw4QEiCDYCvAEgASACaiESIAggACgCgOIBaiETAkACQCAFRQRAIAEhAwwBCyAAKALE4AEhESAAKALA4AEhFSAAKAK84AEhDyAAQQE2AozhAUEAIQgDQCAIQQNHBEAgByAIQQJ0IgJqIAAgAmpBrNABaigCADYCVCAIQQFqIQgMAQsLIAcgETYCZCAHIA82AmAgByABIA9rNgJoQWwhECAHQShqIAMgBBAGEAMNASAFQQQgBUEESBshFyAHQTxqIAdBKGogACgCABATIAdBxABqIAdBKGogACgCCBATIAdBzABqIAdBKGogACgCBBATQQAhBCAHQeAAaiEMIAdB5ABqIQoDQCAHQShqEARBAksgBCAXTnJFBEAgBygCQCAHKAI8QQN0aikCACIdQhCIp0H/AXEhCyAHKAJQIAcoAkxBA3RqKQIAIh5CEIinQf8BcSEJIAcoAkggBygCREEDdGopAgAiH0IgiKchCCAeQiCIISAgHUIgiKchAgJAIB9CEIinQf8BcSIDQQJPBEACQCAGRSADQRlJckUEQCAIIAdBKGogA0EgIAcoAixrIg0gDSADSxsiDRAFIAMgDWsiA3RqIQggB0EoahAEGiADRQ0BIAdBKGogAxAFIAhqIQgMAQsgB0EoaiADEAUgCGohCCAHQShqEAQaCyAHKQJUISEgByAINgJUIAcgITcDWAwBCwJAIANFBEAgAgRAIAcoAlQhCAwDCyAHKAJYIQgMAQsCQAJAIAdBKGpBARAFIAggAkVqaiIDQQNGBEAgBygCVEF/aiIDIANFaiEIDAELIANBAnQgB2ooAlQiCCAIRWohCCADQQFGDQELIAcgBygCWDYCXAsLIAcgBygCVDYCWCAHIAg2AlQLICCnIQMgCQRAIAdBKGogCRAFIANqIQMLIAkgC2pBFE8EQCAHQShqEAQaCyALBEAgB0EoaiALEAUgAmohAgsgB0EoahAEGiAHIAcoAmggAmoiCSADajYCaCAKIAwgCCAJSxsoAgAhDSAHIAdBKGogHUIYiKdB/wFxEAggHadB//8DcWo2AjwgByAHQShqIB5CGIinQf8BcRAIIB6nQf//A3FqNgJMIAdBKGoQBBogB0EoaiAfQhiIp0H/AXEQCCEOIAdB8ABqIARBBHRqIgsgCSANaiAIazYCDCALIAg2AgggCyADNgIEIAsgAjYCACAHIA4gH6dB//8DcWo2AkQgBEEBaiEEDAELCyAEIBdIDQEgEkFgaiEYIAdB4ABqIRogB0HkAGohGyABIQMDQCAHQShqEARBAksgBCAFTnJFBEAgBygCQCAHKAI8QQN0aikCACIdQhCIp0H/AXEhCyAHKAJQIAcoAkxBA3RqKQIAIh5CEIinQf8BcSEIIAcoAkggBygCREEDdGopAgAiH0IgiKchCSAeQiCIISAgHUIgiKchDAJAIB9CEIinQf8BcSICQQJPBEACQCAGRSACQRlJckUEQCAJIAdBKGogAkEgIAcoAixrIgogCiACSxsiChAFIAIgCmsiAnRqIQkgB0EoahAEGiACRQ0BIAdBKGogAhAFIAlqIQkMAQsgB0EoaiACEAUgCWohCSAHQShqEAQaCyAHKQJUISEgByAJNgJUIAcgITcDWAwBCwJAIAJFBEAgDARAIAcoAlQhCQwDCyAHKAJYIQkMAQsCQAJAIAdBKGpBARAFIAkgDEVqaiICQQNGBEAgBygCVEF/aiICIAJFaiEJDAELIAJBAnQgB2ooAlQiCSAJRWohCSACQQFGDQELIAcgBygCWDYCXAsLIAcgBygCVDYCWCAHIAk2AlQLICCnIRQgCARAIAdBKGogCBAFIBRqIRQLIAggC2pBFE8EQCAHQShqEAQaCyALBEAgB0EoaiALEAUgDGohDAsgB0EoahAEGiAHIAcoAmggDGoiGSAUajYCaCAbIBogCSAZSxsoAgAhHCAHIAdBKGogHUIYiKdB/wFxEAggHadB//8DcWo2AjwgByAHQShqIB5CGIinQf8BcRAIIB6nQf//A3FqNgJMIAdBKGoQBBogByAHQShqIB9CGIinQf8BcRAIIB+nQf//A3FqNgJEIAcgB0HwAGogBEEDcUEEdGoiDSkDCCIdNwPIASAHIA0pAwAiHjcDwAECQAJAAkAgBygCvAEiDiAepyICaiIWIBNLDQAgAyAHKALEASIKIAJqIgtqIBhLDQAgEiADayALQSBqTw0BCyAHIAcpA8gBNwMQIAcgBykDwAE3AwggAyASIAdBCGogB0G8AWogEyAPIBUgERAeIQsMAQsgAiADaiEIIAMgDhAHIAJBEU8EQCADQRBqIQIDQCACIA5BEGoiDhAHIAJBEGoiAiAISQ0ACwsgCCAdpyIOayECIAcgFjYCvAEgDiAIIA9rSwRAIA4gCCAVa0sEQEFsIQsMAgsgESACIA9rIgJqIhYgCmogEU0EQCAIIBYgChAPGgwCCyAIIBZBACACaxAPIQggByACIApqIgo2AsQBIAggAmshCCAPIQILIA5BEE8EQCAIIApqIQoDQCAIIAIQByACQRBqIQIgCEEQaiIIIApJDQALDAELAkAgDkEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgDkECdCIKQcAeaigCAGoiAhAXIAIgCkHgHmooAgBrIQIgBygCxAEhCgwBCyAIIAIQDAsgCkEJSQ0AIAggCmohCiAIQQhqIgggAkEIaiICa0EPTARAA0AgCCACEAwgAkEIaiECIAhBCGoiCCAKSQ0ADAIACwALA0AgCCACEAcgAkEQaiECIAhBEGoiCCAKSQ0ACwsgCxADBEAgCyEQDAQFIA0gDDYCACANIBkgHGogCWs2AgwgDSAJNgIIIA0gFDYCBCAEQQFqIQQgAyALaiEDDAILAAsLIAQgBUgNASAEIBdrIQtBACEEA0AgCyAFSARAIAcgB0HwAGogC0EDcUEEdGoiAikDCCIdNwPIASAHIAIpAwAiHjcDwAECQAJAAkAgBygCvAEiDCAepyICaiIKIBNLDQAgAyAHKALEASIJIAJqIhBqIBhLDQAgEiADayAQQSBqTw0BCyAHIAcpA8gBNwMgIAcgBykDwAE3AxggAyASIAdBGGogB0G8AWogEyAPIBUgERAeIRAMAQsgAiADaiEIIAMgDBAHIAJBEU8EQCADQRBqIQIDQCACIAxBEGoiDBAHIAJBEGoiAiAISQ0ACwsgCCAdpyIGayECIAcgCjYCvAEgBiAIIA9rSwRAIAYgCCAVa0sEQEFsIRAMAgsgESACIA9rIgJqIgwgCWogEU0EQCAIIAwgCRAPGgwCCyAIIAxBACACaxAPIQggByACIAlqIgk2AsQBIAggAmshCCAPIQILIAZBEE8EQCAIIAlqIQYDQCAIIAIQByACQRBqIQIgCEEQaiIIIAZJDQALDAELAkAgBkEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgBkECdCIGQcAeaigCAGoiAhAXIAIgBkHgHmooAgBrIQIgBygCxAEhCQwBCyAIIAIQDAsgCUEJSQ0AIAggCWohBiAIQQhqIgggAkEIaiICa0EPTARAA0AgCCACEAwgAkEIaiECIAhBCGoiCCAGSQ0ADAIACwALA0AgCCACEAcgAkEQaiECIAhBEGoiCCAGSQ0ACwsgEBADDQMgC0EBaiELIAMgEGohAwwBCwsDQCAEQQNHBEAgACAEQQJ0IgJqQazQAWogAiAHaigCVDYCACAEQQFqIQQMAQsLIAcoArwBIQgLQbp/IRAgEyAIayIAIBIgA2tLDQAgAwR/IAMgCCAAEAsgAGoFQQALIAFrIRALIAdB0AFqJAAgEAslACAAQgA3AgAgAEEAOwEIIABBADoACyAAIAE2AgwgACACOgAKC7QFAQN/IwBBMGsiBCQAIABB/wFqIgVBfWohBgJAIAMvAQIEQCAEQRhqIAEgAhAGIgIQAw0BIARBEGogBEEYaiADEBwgBEEIaiAEQRhqIAMQHCAAIQMDQAJAIARBGGoQBCADIAZPckUEQCADIARBEGogBEEYahASOgAAIAMgBEEIaiAEQRhqEBI6AAEgBEEYahAERQ0BIANBAmohAwsgBUF+aiEFAn8DQEG6fyECIAMiASAFSw0FIAEgBEEQaiAEQRhqEBI6AAAgAUEBaiEDIARBGGoQBEEDRgRAQQIhAiAEQQhqDAILIAMgBUsNBSABIARBCGogBEEYahASOgABIAFBAmohA0EDIQIgBEEYahAEQQNHDQALIARBEGoLIQUgAyAFIARBGGoQEjoAACABIAJqIABrIQIMAwsgAyAEQRBqIARBGGoQEjoAAiADIARBCGogBEEYahASOgADIANBBGohAwwAAAsACyAEQRhqIAEgAhAGIgIQAw0AIARBEGogBEEYaiADEBwgBEEIaiAEQRhqIAMQHCAAIQMDQAJAIARBGGoQBCADIAZPckUEQCADIARBEGogBEEYahAROgAAIAMgBEEIaiAEQRhqEBE6AAEgBEEYahAERQ0BIANBAmohAwsgBUF+aiEFAn8DQEG6fyECIAMiASAFSw0EIAEgBEEQaiAEQRhqEBE6AAAgAUEBaiEDIARBGGoQBEEDRgRAQQIhAiAEQQhqDAILIAMgBUsNBCABIARBCGogBEEYahAROgABIAFBAmohA0EDIQIgBEEYahAEQQNHDQALIARBEGoLIQUgAyAFIARBGGoQEToAACABIAJqIABrIQIMAgsgAyAEQRBqIARBGGoQEToAAiADIARBCGogBEEYahAROgADIANBBGohAwwAAAsACyAEQTBqJAAgAgtpAQF/An8CQAJAIAJBB00NACABKAAAQbfIwuF+Rw0AIAAgASgABDYCmOIBQWIgAEEQaiABIAIQPiIDEAMNAhogAEKBgICAEDcDiOEBIAAgASADaiACIANrECoMAQsgACABIAIQKgtBAAsLrQMBBn8jAEGAAWsiAyQAQWIhCAJAIAJBCUkNACAAQZjQAGogAUEIaiIEIAJBeGogAEGY0AAQMyIFEAMiBg0AIANBHzYCfCADIANB/ABqIANB+ABqIAQgBCAFaiAGGyIEIAEgAmoiAiAEaxAVIgUQAw0AIAMoAnwiBkEfSw0AIAMoAngiB0EJTw0AIABBiCBqIAMgBkGAC0GADCAHEBggA0E0NgJ8IAMgA0H8AGogA0H4AGogBCAFaiIEIAIgBGsQFSIFEAMNACADKAJ8IgZBNEsNACADKAJ4IgdBCk8NACAAQZAwaiADIAZBgA1B4A4gBxAYIANBIzYCfCADIANB/ABqIANB+ABqIAQgBWoiBCACIARrEBUiBRADDQAgAygCfCIGQSNLDQAgAygCeCIHQQpPDQAgACADIAZBwBBB0BEgBxAYIAQgBWoiBEEMaiIFIAJLDQAgAiAFayEFQQAhAgNAIAJBA0cEQCAEKAAAIgZBf2ogBU8NAiAAIAJBAnRqQZzQAWogBjYCACACQQFqIQIgBEEEaiEEDAELCyAEIAFrIQgLIANBgAFqJAAgCAtGAQN/IABBCGohAyAAKAIEIQJBACEAA0AgACACdkUEQCABIAMgAEEDdGotAAJBFktqIQEgAEEBaiEADAELCyABQQggAmt0C4YDAQV/Qbh/IQcCQCADRQ0AIAItAAAiBEUEQCABQQA2AgBBAUG4fyADQQFGGw8LAn8gAkEBaiIFIARBGHRBGHUiBkF/Sg0AGiAGQX9GBEAgA0EDSA0CIAUvAABBgP4BaiEEIAJBA2oMAQsgA0ECSA0BIAItAAEgBEEIdHJBgIB+aiEEIAJBAmoLIQUgASAENgIAIAVBAWoiASACIANqIgNLDQBBbCEHIABBEGogACAFLQAAIgVBBnZBI0EJIAEgAyABa0HAEEHQEUHwEiAAKAKM4QEgACgCnOIBIAQQHyIGEAMiCA0AIABBmCBqIABBCGogBUEEdkEDcUEfQQggASABIAZqIAgbIgEgAyABa0GAC0GADEGAFyAAKAKM4QEgACgCnOIBIAQQHyIGEAMiCA0AIABBoDBqIABBBGogBUECdkEDcUE0QQkgASABIAZqIAgbIgEgAyABa0GADUHgDkGQGSAAKAKM4QEgACgCnOIBIAQQHyIAEAMNACAAIAFqIAJrIQcLIAcLrQMBCn8jAEGABGsiCCQAAn9BUiACQf8BSw0AGkFUIANBDEsNABogAkEBaiELIABBBGohCUGAgAQgA0F/anRBEHUhCkEAIQJBASEEQQEgA3QiB0F/aiIMIQUDQCACIAtGRQRAAkAgASACQQF0Ig1qLwEAIgZB//8DRgRAIAkgBUECdGogAjoAAiAFQX9qIQVBASEGDAELIARBACAKIAZBEHRBEHVKGyEECyAIIA1qIAY7AQAgAkEBaiECDAELCyAAIAQ7AQIgACADOwEAIAdBA3YgB0EBdmpBA2ohBkEAIQRBACECA0AgBCALRkUEQCABIARBAXRqLgEAIQpBACEAA0AgACAKTkUEQCAJIAJBAnRqIAQ6AAIDQCACIAZqIAxxIgIgBUsNAAsgAEEBaiEADAELCyAEQQFqIQQMAQsLQX8gAg0AGkEAIQIDfyACIAdGBH9BAAUgCCAJIAJBAnRqIgAtAAJBAXRqIgEgAS8BACIBQQFqOwEAIAAgAyABEBRrIgU6AAMgACABIAVB/wFxdCAHazsBACACQQFqIQIMAQsLCyEFIAhBgARqJAAgBQvjBgEIf0FsIQcCQCACQQNJDQACQAJAAkACQCABLQAAIgNBA3EiCUEBaw4DAwEAAgsgACgCiOEBDQBBYg8LIAJBBUkNAkEDIQYgASgAACEFAn8CQAJAIANBAnZBA3EiCEF+aiIEQQFNBEAgBEEBaw0BDAILIAVBDnZB/wdxIQQgBUEEdkH/B3EhAyAIRQwCCyAFQRJ2IQRBBCEGIAVBBHZB//8AcSEDQQAMAQsgBUEEdkH//w9xIgNBgIAISw0DIAEtAARBCnQgBUEWdnIhBEEFIQZBAAshBSAEIAZqIgogAksNAgJAIANBgQZJDQAgACgCnOIBRQ0AQQAhAgNAIAJBg4ABSw0BIAJBQGshAgwAAAsACwJ/IAlBA0YEQCABIAZqIQEgAEHw4gFqIQIgACgCDCEGIAUEQCACIAMgASAEIAYQXwwCCyACIAMgASAEIAYQXQwBCyAAQbjQAWohAiABIAZqIQEgAEHw4gFqIQYgAEGo0ABqIQggBQRAIAggBiADIAEgBCACEF4MAQsgCCAGIAMgASAEIAIQXAsQAw0CIAAgAzYCgOIBIABBATYCiOEBIAAgAEHw4gFqNgLw4QEgCUECRgRAIAAgAEGo0ABqNgIMCyAAIANqIgBBiOMBakIANwAAIABBgOMBakIANwAAIABB+OIBakIANwAAIABB8OIBakIANwAAIAoPCwJ/AkACQAJAIANBAnZBA3FBf2oiBEECSw0AIARBAWsOAgACAQtBASEEIANBA3YMAgtBAiEEIAEvAABBBHYMAQtBAyEEIAEQIUEEdgsiAyAEaiIFQSBqIAJLBEAgBSACSw0CIABB8OIBaiABIARqIAMQCyEBIAAgAzYCgOIBIAAgATYC8OEBIAEgA2oiAEIANwAYIABCADcAECAAQgA3AAggAEIANwAAIAUPCyAAIAM2AoDiASAAIAEgBGo2AvDhASAFDwsCfwJAAkACQCADQQJ2QQNxQX9qIgRBAksNACAEQQFrDgIAAgELQQEhByADQQN2DAILQQIhByABLwAAQQR2DAELIAJBBEkgARAhIgJBj4CAAUtyDQFBAyEHIAJBBHYLIQIgAEHw4gFqIAEgB2otAAAgAkEgahAQIQEgACACNgKA4gEgACABNgLw4QEgB0EBaiEHCyAHC0sAIABC+erQ0OfJoeThADcDICAAQgA3AxggAELP1tO+0ser2UI3AxAgAELW64Lu6v2J9eAANwMIIABCADcDACAAQShqQQBBKBAQGgviAgICfwV+IABBKGoiASAAKAJIaiECAn4gACkDACIDQiBaBEAgACkDECIEQgeJIAApAwgiBUIBiXwgACkDGCIGQgyJfCAAKQMgIgdCEol8IAUQGSAEEBkgBhAZIAcQGQwBCyAAKQMYQsXP2bLx5brqJ3wLIAN8IQMDQCABQQhqIgAgAk0EQEIAIAEpAAAQCSADhUIbiUKHla+vmLbem55/fkLj3MqV/M7y9YV/fCEDIAAhAQwBCwsCQCABQQRqIgAgAksEQCABIQAMAQsgASgAAK1Ch5Wvr5i23puef34gA4VCF4lCz9bTvtLHq9lCfkL5893xmfaZqxZ8IQMLA0AgACACSQRAIAAxAABCxc/ZsvHluuonfiADhUILiUKHla+vmLbem55/fiEDIABBAWohAAwBCwsgA0IhiCADhULP1tO+0ser2UJ+IgNCHYggA4VC+fPd8Zn2masWfiIDQiCIIAOFC+8CAgJ/BH4gACAAKQMAIAKtfDcDAAJAAkAgACgCSCIDIAJqIgRBH00EQCABRQ0BIAAgA2pBKGogASACECAgACgCSCACaiEEDAELIAEgAmohAgJ/IAMEQCAAQShqIgQgA2ogAUEgIANrECAgACAAKQMIIAQpAAAQCTcDCCAAIAApAxAgACkAMBAJNwMQIAAgACkDGCAAKQA4EAk3AxggACAAKQMgIABBQGspAAAQCTcDICAAKAJIIQMgAEEANgJIIAEgA2tBIGohAQsgAUEgaiACTQsEQCACQWBqIQMgACkDICEFIAApAxghBiAAKQMQIQcgACkDCCEIA0AgCCABKQAAEAkhCCAHIAEpAAgQCSEHIAYgASkAEBAJIQYgBSABKQAYEAkhBSABQSBqIgEgA00NAAsgACAFNwMgIAAgBjcDGCAAIAc3AxAgACAINwMICyABIAJPDQEgAEEoaiABIAIgAWsiBBAgCyAAIAQ2AkgLCy8BAX8gAEUEQEG2f0EAIAMbDwtBun8hBCADIAFNBH8gACACIAMQEBogAwVBun8LCy8BAX8gAEUEQEG2f0EAIAMbDwtBun8hBCADIAFNBH8gACACIAMQCxogAwVBun8LC6gCAQZ/IwBBEGsiByQAIABB2OABaikDAEKAgIAQViEIQbh/IQUCQCAEQf//B0sNACAAIAMgBBBCIgUQAyIGDQAgACgCnOIBIQkgACAHQQxqIAMgAyAFaiAGGyIKIARBACAFIAYbayIGEEAiAxADBEAgAyEFDAELIAcoAgwhBCABRQRAQbp/IQUgBEEASg0BCyAGIANrIQUgAyAKaiEDAkAgCQRAIABBADYCnOIBDAELAkACQAJAIARBBUgNACAAQdjgAWopAwBCgICACFgNAAwBCyAAQQA2ApziAQwBCyAAKAIIED8hBiAAQQA2ApziASAGQRRPDQELIAAgASACIAMgBSAEIAgQOSEFDAELIAAgASACIAMgBSAEIAgQOiEFCyAHQRBqJAAgBQtnACAAQdDgAWogASACIAAoAuzhARAuIgEQAwRAIAEPC0G4fyECAkAgAQ0AIABB7OABaigCACIBBEBBYCECIAAoApjiASABRw0BC0EAIQIgAEHw4AFqKAIARQ0AIABBkOEBahBDCyACCycBAX8QVyIERQRAQUAPCyAEIAAgASACIAMgBBBLEE8hACAEEFYgAAs/AQF/AkACQAJAIAAoAqDiAUEBaiIBQQJLDQAgAUEBaw4CAAECCyAAEDBBAA8LIABBADYCoOIBCyAAKAKU4gELvAMCB38BfiMAQRBrIgkkAEG4fyEGAkAgBCgCACIIQQVBCSAAKALs4QEiBRtJDQAgAygCACIHQQFBBSAFGyAFEC8iBRADBEAgBSEGDAELIAggBUEDakkNACAAIAcgBRBJIgYQAw0AIAEgAmohCiAAQZDhAWohCyAIIAVrIQIgBSAHaiEHIAEhBQNAIAcgAiAJECwiBhADDQEgAkF9aiICIAZJBEBBuH8hBgwCCyAJKAIAIghBAksEQEFsIQYMAgsgB0EDaiEHAn8CQAJAAkAgCEEBaw4CAgABCyAAIAUgCiAFayAHIAYQSAwCCyAFIAogBWsgByAGEEcMAQsgBSAKIAVrIActAAAgCSgCCBBGCyIIEAMEQCAIIQYMAgsgACgC8OABBEAgCyAFIAgQRQsgAiAGayECIAYgB2ohByAFIAhqIQUgCSgCBEUNAAsgACkD0OABIgxCf1IEQEFsIQYgDCAFIAFrrFINAQsgACgC8OABBEBBaiEGIAJBBEkNASALEEQhDCAHKAAAIAynRw0BIAdBBGohByACQXxqIQILIAMgBzYCACAEIAI2AgAgBSABayEGCyAJQRBqJAAgBgsuACAAECsCf0EAQQAQAw0AGiABRSACRXJFBEBBYiAAIAEgAhA9EAMNARoLQQALCzcAIAEEQCAAIAAoAsTgASABKAIEIAEoAghqRzYCnOIBCyAAECtBABADIAFFckUEQCAAIAEQWwsL0QIBB38jAEEQayIGJAAgBiAENgIIIAYgAzYCDCAFBEAgBSgCBCEKIAUoAgghCQsgASEIAkACQANAIAAoAuzhARAWIQsCQANAIAQgC0kNASADKAAAQXBxQdDUtMIBRgRAIAMgBBAiIgcQAw0EIAQgB2shBCADIAdqIQMMAQsLIAYgAzYCDCAGIAQ2AggCQCAFBEAgACAFEE5BACEHQQAQA0UNAQwFCyAAIAogCRBNIgcQAw0ECyAAIAgQUCAMQQFHQQAgACAIIAIgBkEMaiAGQQhqEEwiByIDa0EAIAMQAxtBCkdyRQRAQbh/IQcMBAsgBxADDQMgAiAHayECIAcgCGohCEEBIQwgBigCDCEDIAYoAgghBAwBCwsgBiADNgIMIAYgBDYCCEG4fyEHIAQNASAIIAFrIQcMAQsgBiADNgIMIAYgBDYCCAsgBkEQaiQAIAcLRgECfyABIAAoArjgASICRwRAIAAgAjYCxOABIAAgATYCuOABIAAoArzgASEDIAAgATYCvOABIAAgASADIAJrajYCwOABCwutAgIEfwF+IwBBQGoiBCQAAkACQCACQQhJDQAgASgAAEFwcUHQ1LTCAUcNACABIAIQIiEBIABCADcDCCAAQQA2AgQgACABNgIADAELIARBGGogASACEC0iAxADBEAgACADEBoMAQsgAwRAIABBuH8QGgwBCyACIAQoAjAiA2shAiABIANqIQMDQAJAIAAgAyACIARBCGoQLCIFEAMEfyAFBSACIAVBA2oiBU8NAUG4fwsQGgwCCyAGQQFqIQYgAiAFayECIAMgBWohAyAEKAIMRQ0ACyAEKAI4BEAgAkEDTQRAIABBuH8QGgwCCyADQQRqIQMLIAQoAighAiAEKQMYIQcgAEEANgIEIAAgAyABazYCACAAIAIgBmytIAcgB0J/URs3AwgLIARBQGskAAslAQF/IwBBEGsiAiQAIAIgACABEFEgAigCACEAIAJBEGokACAAC30BBH8jAEGQBGsiBCQAIARB/wE2AggCQCAEQRBqIARBCGogBEEMaiABIAIQFSIGEAMEQCAGIQUMAQtBVCEFIAQoAgwiB0EGSw0AIAMgBEEQaiAEKAIIIAcQQSIFEAMNACAAIAEgBmogAiAGayADEDwhBQsgBEGQBGokACAFC4cBAgJ/An5BABAWIQMCQANAIAEgA08EQAJAIAAoAABBcHFB0NS0wgFGBEAgACABECIiAhADRQ0BQn4PCyAAIAEQVSIEQn1WDQMgBCAFfCIFIARUIQJCfiEEIAINAyAAIAEQUiICEAMNAwsgASACayEBIAAgAmohAAwBCwtCfiAFIAEbIQQLIAQLPwIBfwF+IwBBMGsiAiQAAn5CfiACQQhqIAAgARAtDQAaQgAgAigCHEEBRg0AGiACKQMICyEDIAJBMGokACADC40BAQJ/IwBBMGsiASQAAkAgAEUNACAAKAKI4gENACABIABB/OEBaigCADYCKCABIAApAvThATcDICAAEDAgACgCqOIBIQIgASABKAIoNgIYIAEgASkDIDcDECACIAFBEGoQGyAAQQA2AqjiASABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALKgECfyMAQRBrIgAkACAAQQA2AgggAEIANwMAIAAQWCEBIABBEGokACABC4cBAQN/IwBBEGsiAiQAAkAgACgCAEUgACgCBEVzDQAgAiAAKAIINgIIIAIgACkCADcDAAJ/IAIoAgAiAQRAIAIoAghBqOMJIAERBQAMAQtBqOMJECgLIgFFDQAgASAAKQIANwL04QEgAUH84QFqIAAoAgg2AgAgARBZIAEhAwsgAkEQaiQAIAMLywEBAn8jAEEgayIBJAAgAEGBgIDAADYCtOIBIABBADYCiOIBIABBADYC7OEBIABCADcDkOIBIABBADYCpOMJIABBADYC3OIBIABCADcCzOIBIABBADYCvOIBIABBADYCxOABIABCADcCnOIBIABBpOIBakIANwIAIABBrOIBakEANgIAIAFCADcCECABQgA3AhggASABKQMYNwMIIAEgASkDEDcDACABKAIIQQh2QQFxIQIgAEEANgLg4gEgACACNgKM4gEgAUEgaiQAC3YBA38jAEEwayIBJAAgAARAIAEgAEHE0AFqIgIoAgA2AiggASAAKQK80AE3AyAgACgCACEDIAEgAigCADYCGCABIAApArzQATcDECADIAFBEGoQGyABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALzAEBAX8gACABKAK00AE2ApjiASAAIAEoAgQiAjYCwOABIAAgAjYCvOABIAAgAiABKAIIaiICNgK44AEgACACNgLE4AEgASgCuNABBEAgAEKBgICAEDcDiOEBIAAgAUGk0ABqNgIMIAAgAUGUIGo2AgggACABQZwwajYCBCAAIAFBDGo2AgAgAEGs0AFqIAFBqNABaigCADYCACAAQbDQAWogAUGs0AFqKAIANgIAIABBtNABaiABQbDQAWooAgA2AgAPCyAAQgA3A4jhAQs7ACACRQRAQbp/DwsgBEUEQEFsDwsgAiAEEGAEQCAAIAEgAiADIAQgBRBhDwsgACABIAIgAyAEIAUQZQtGAQF/IwBBEGsiBSQAIAVBCGogBBAOAn8gBS0ACQRAIAAgASACIAMgBBAyDAELIAAgASACIAMgBBA0CyEAIAVBEGokACAACzQAIAAgAyAEIAUQNiIFEAMEQCAFDwsgBSAESQR/IAEgAiADIAVqIAQgBWsgABA1BUG4fwsLRgEBfyMAQRBrIgUkACAFQQhqIAQQDgJ/IAUtAAkEQCAAIAEgAiADIAQQYgwBCyAAIAEgAiADIAQQNQshACAFQRBqJAAgAAtZAQF/QQ8hAiABIABJBEAgAUEEdCAAbiECCyAAQQh2IgEgAkEYbCIAQYwIaigCAGwgAEGICGooAgBqIgJBA3YgAmogAEGACGooAgAgAEGECGooAgAgAWxqSQs3ACAAIAMgBCAFQYAQEDMiBRADBEAgBQ8LIAUgBEkEfyABIAIgAyAFaiAEIAVrIAAQMgVBuH8LC78DAQN/IwBBIGsiBSQAIAVBCGogAiADEAYiAhADRQRAIAAgAWoiB0F9aiEGIAUgBBAOIARBBGohAiAFLQACIQMDQEEAIAAgBkkgBUEIahAEGwRAIAAgAiAFQQhqIAMQAkECdGoiBC8BADsAACAFQQhqIAQtAAIQASAAIAQtAANqIgQgAiAFQQhqIAMQAkECdGoiAC8BADsAACAFQQhqIAAtAAIQASAEIAAtAANqIQAMAQUgB0F+aiEEA0AgBUEIahAEIAAgBEtyRQRAIAAgAiAFQQhqIAMQAkECdGoiBi8BADsAACAFQQhqIAYtAAIQASAAIAYtAANqIQAMAQsLA0AgACAES0UEQCAAIAIgBUEIaiADEAJBAnRqIgYvAQA7AAAgBUEIaiAGLQACEAEgACAGLQADaiEADAELCwJAIAAgB08NACAAIAIgBUEIaiADEAIiA0ECdGoiAC0AADoAACAALQADQQFGBEAgBUEIaiAALQACEAEMAQsgBSgCDEEfSw0AIAVBCGogAiADQQJ0ai0AAhABIAUoAgxBIUkNACAFQSA2AgwLIAFBbCAFQQhqEAobIQILCwsgBUEgaiQAIAILkgIBBH8jAEFAaiIJJAAgCSADQTQQCyEDAkAgBEECSA0AIAMgBEECdGooAgAhCSADQTxqIAgQIyADQQE6AD8gAyACOgA+QQAhBCADKAI8IQoDQCAEIAlGDQEgACAEQQJ0aiAKNgEAIARBAWohBAwAAAsAC0EAIQkDQCAGIAlGRQRAIAMgBSAJQQF0aiIKLQABIgtBAnRqIgwoAgAhBCADQTxqIAotAABBCHQgCGpB//8DcRAjIANBAjoAPyADIAcgC2siCiACajoAPiAEQQEgASAKa3RqIQogAygCPCELA0AgACAEQQJ0aiALNgEAIARBAWoiBCAKSQ0ACyAMIAo2AgAgCUEBaiEJDAELCyADQUBrJAALowIBCX8jAEHQAGsiCSQAIAlBEGogBUE0EAsaIAcgBmshDyAHIAFrIRADQAJAIAMgCkcEQEEBIAEgByACIApBAXRqIgYtAAEiDGsiCGsiC3QhDSAGLQAAIQ4gCUEQaiAMQQJ0aiIMKAIAIQYgCyAPTwRAIAAgBkECdGogCyAIIAUgCEE0bGogCCAQaiIIQQEgCEEBShsiCCACIAQgCEECdGooAgAiCEEBdGogAyAIayAHIA4QYyAGIA1qIQgMAgsgCUEMaiAOECMgCUEBOgAPIAkgCDoADiAGIA1qIQggCSgCDCELA0AgBiAITw0CIAAgBkECdGogCzYBACAGQQFqIQYMAAALAAsgCUHQAGokAA8LIAwgCDYCACAKQQFqIQoMAAALAAs0ACAAIAMgBCAFEDYiBRADBEAgBQ8LIAUgBEkEfyABIAIgAyAFaiAEIAVrIAAQNAVBuH8LCyMAIAA/AEEQdGtB//8DakEQdkAAQX9GBEBBAA8LQQAQAEEBCzsBAX8gAgRAA0AgACABIAJBgCAgAkGAIEkbIgMQCyEAIAFBgCBqIQEgAEGAIGohACACIANrIgINAAsLCwYAIAAQAwsLqBUJAEGICAsNAQAAAAEAAAACAAAAAgBBoAgLswYBAAAAAQAAAAIAAAACAAAAJgAAAIIAAAAhBQAASgAAAGcIAAAmAAAAwAEAAIAAAABJBQAASgAAAL4IAAApAAAALAIAAIAAAABJBQAASgAAAL4IAAAvAAAAygIAAIAAAACKBQAASgAAAIQJAAA1AAAAcwMAAIAAAACdBQAASgAAAKAJAAA9AAAAgQMAAIAAAADrBQAASwAAAD4KAABEAAAAngMAAIAAAABNBgAASwAAAKoKAABLAAAAswMAAIAAAADBBgAATQAAAB8NAABNAAAAUwQAAIAAAAAjCAAAUQAAAKYPAABUAAAAmQQAAIAAAABLCQAAVwAAALESAABYAAAA2gQAAIAAAABvCQAAXQAAACMUAABUAAAARQUAAIAAAABUCgAAagAAAIwUAABqAAAArwUAAIAAAAB2CQAAfAAAAE4QAAB8AAAA0gIAAIAAAABjBwAAkQAAAJAHAACSAAAAAAAAAAEAAAABAAAABQAAAA0AAAAdAAAAPQAAAH0AAAD9AAAA/QEAAP0DAAD9BwAA/Q8AAP0fAAD9PwAA/X8AAP3/AAD9/wEA/f8DAP3/BwD9/w8A/f8fAP3/PwD9/38A/f//AP3//wH9//8D/f//B/3//w/9//8f/f//P/3//38AAAAAAQAAAAIAAAADAAAABAAAAAUAAAAGAAAABwAAAAgAAAAJAAAACgAAAAsAAAAMAAAADQAAAA4AAAAPAAAAEAAAABEAAAASAAAAEwAAABQAAAAVAAAAFgAAABcAAAAYAAAAGQAAABoAAAAbAAAAHAAAAB0AAAAeAAAAHwAAAAMAAAAEAAAABQAAAAYAAAAHAAAACAAAAAkAAAAKAAAACwAAAAwAAAANAAAADgAAAA8AAAAQAAAAEQAAABIAAAATAAAAFAAAABUAAAAWAAAAFwAAABgAAAAZAAAAGgAAABsAAAAcAAAAHQAAAB4AAAAfAAAAIAAAACEAAAAiAAAAIwAAACUAAAAnAAAAKQAAACsAAAAvAAAAMwAAADsAAABDAAAAUwAAAGMAAACDAAAAAwEAAAMCAAADBAAAAwgAAAMQAAADIAAAA0AAAAOAAAADAAEAQeAPC1EBAAAAAQAAAAEAAAABAAAAAgAAAAIAAAADAAAAAwAAAAQAAAAEAAAABQAAAAcAAAAIAAAACQAAAAoAAAALAAAADAAAAA0AAAAOAAAADwAAABAAQcQQC4sBAQAAAAIAAAADAAAABAAAAAUAAAAGAAAABwAAAAgAAAAJAAAACgAAAAsAAAAMAAAADQAAAA4AAAAPAAAAEAAAABIAAAAUAAAAFgAAABgAAAAcAAAAIAAAACgAAAAwAAAAQAAAAIAAAAAAAQAAAAIAAAAEAAAACAAAABAAAAAgAAAAQAAAAIAAAAAAAQBBkBIL5gQBAAAAAQAAAAEAAAABAAAAAgAAAAIAAAADAAAAAwAAAAQAAAAGAAAABwAAAAgAAAAJAAAACgAAAAsAAAAMAAAADQAAAA4AAAAPAAAAEAAAAAEAAAAEAAAACAAAAAAAAAABAAEBBgAAAAAAAAQAAAAAEAAABAAAAAAgAAAFAQAAAAAAAAUDAAAAAAAABQQAAAAAAAAFBgAAAAAAAAUHAAAAAAAABQkAAAAAAAAFCgAAAAAAAAUMAAAAAAAABg4AAAAAAAEFEAAAAAAAAQUUAAAAAAABBRYAAAAAAAIFHAAAAAAAAwUgAAAAAAAEBTAAAAAgAAYFQAAAAAAABwWAAAAAAAAIBgABAAAAAAoGAAQAAAAADAYAEAAAIAAABAAAAAAAAAAEAQAAAAAAAAUCAAAAIAAABQQAAAAAAAAFBQAAACAAAAUHAAAAAAAABQgAAAAgAAAFCgAAAAAAAAULAAAAAAAABg0AAAAgAAEFEAAAAAAAAQUSAAAAIAABBRYAAAAAAAIFGAAAACAAAwUgAAAAAAADBSgAAAAAAAYEQAAAABAABgRAAAAAIAAHBYAAAAAAAAkGAAIAAAAACwYACAAAMAAABAAAAAAQAAAEAQAAACAAAAUCAAAAIAAABQMAAAAgAAAFBQAAACAAAAUGAAAAIAAABQgAAAAgAAAFCQAAACAAAAULAAAAIAAABQwAAAAAAAAGDwAAACAAAQUSAAAAIAABBRQAAAAgAAIFGAAAACAAAgUcAAAAIAADBSgAAAAgAAQFMAAAAAAAEAYAAAEAAAAPBgCAAAAAAA4GAEAAAAAADQYAIABBgBcLhwIBAAEBBQAAAAAAAAUAAAAAAAAGBD0AAAAAAAkF/QEAAAAADwX9fwAAAAAVBf3/HwAAAAMFBQAAAAAABwR9AAAAAAAMBf0PAAAAABIF/f8DAAAAFwX9/38AAAAFBR0AAAAAAAgE/QAAAAAADgX9PwAAAAAUBf3/DwAAAAIFAQAAABAABwR9AAAAAAALBf0HAAAAABEF/f8BAAAAFgX9/z8AAAAEBQ0AAAAQAAgE/QAAAAAADQX9HwAAAAATBf3/BwAAAAEFAQAAABAABgQ9AAAAAAAKBf0DAAAAABAF/f8AAAAAHAX9//8PAAAbBf3//wcAABoF/f//AwAAGQX9//8BAAAYBf3//wBBkBkLhgQBAAEBBgAAAAAAAAYDAAAAAAAABAQAAAAgAAAFBQAAAAAAAAUGAAAAAAAABQgAAAAAAAAFCQAAAAAAAAULAAAAAAAABg0AAAAAAAAGEAAAAAAAAAYTAAAAAAAABhYAAAAAAAAGGQAAAAAAAAYcAAAAAAAABh8AAAAAAAAGIgAAAAAAAQYlAAAAAAABBikAAAAAAAIGLwAAAAAAAwY7AAAAAAAEBlMAAAAAAAcGgwAAAAAACQYDAgAAEAAABAQAAAAAAAAEBQAAACAAAAUGAAAAAAAABQcAAAAgAAAFCQAAAAAAAAUKAAAAAAAABgwAAAAAAAAGDwAAAAAAAAYSAAAAAAAABhUAAAAAAAAGGAAAAAAAAAYbAAAAAAAABh4AAAAAAAAGIQAAAAAAAQYjAAAAAAABBicAAAAAAAIGKwAAAAAAAwYzAAAAAAAEBkMAAAAAAAUGYwAAAAAACAYDAQAAIAAABAQAAAAwAAAEBAAAABAAAAQFAAAAIAAABQcAAAAgAAAFCAAAACAAAAUKAAAAIAAABQsAAAAAAAAGDgAAAAAAAAYRAAAAAAAABhQAAAAAAAAGFwAAAAAAAAYaAAAAAAAABh0AAAAAAAAGIAAAAAAAEAYDAAEAAAAPBgOAAAAAAA4GA0AAAAAADQYDIAAAAAAMBgMQAAAAAAsGAwgAAAAACgYDBABBpB0L2QEBAAAAAwAAAAcAAAAPAAAAHwAAAD8AAAB/AAAA/wAAAP8BAAD/AwAA/wcAAP8PAAD/HwAA/z8AAP9/AAD//wAA//8BAP//AwD//wcA//8PAP//HwD//z8A//9/AP///wD///8B////A////wf///8P////H////z////9/AAAAAAEAAAACAAAABAAAAAAAAAACAAAABAAAAAgAAAAAAAAAAQAAAAIAAAABAAAABAAAAAQAAAAEAAAABAAAAAgAAAAIAAAACAAAAAcAAAAIAAAACQAAAAoAAAALAEGgIAsDwBBQ", m2 = "display-p3", b2 = "display-p3-linear", ku = /* @__PURE__ */ new WeakMap();+let Uu = 0, Ou;+class ii extends ps {+ /**+ * Constructs a new KTX2 loader.+ *+ * @param {LoadingManager} [manager] - The loading manager.+ */+ constructor(e) {+ super(e), this.transcoderPath = "", this.transcoderBinary = null, this.transcoderPending = null, this.workerPool = new o2(), this.workerSourceURL = "", this.workerConfig = null, typeof MSC_TRANSCODER < "u" && console.warn(+ 'THREE.KTX2Loader: Please update to latest "basis_transcoder". "msc_basis_transcoder" is no longer supported in three.js r125+.'+ );+ }+ /**+ * Sets the transcoder path.+ *+ * The WASM transcoder and JS wrapper are available from the `examples/jsm/libs/basis` directory.+ *+ * @param {string} path - The transcoder path to set.+ * @return {KTX2Loader} A reference to this loader.+ */+ setTranscoderPath(e) {+ return this.transcoderPath = e, this;+ }+ /**+ * Sets the maximum number of Web Workers to be allocated by this instance.+ *+ * @param {number} workerLimit - The worker limit.+ * @return {KTX2Loader} A reference to this loader.+ */+ setWorkerLimit(e) {+ return this.workerPool.setWorkerLimit(e), this;+ }+ /**+ * Async version of {@link KTX2Loader#detectSupport}.+ *+ * @async+ * @param {WebGPURenderer|WebGLRenderer} renderer - The renderer.+ * @return {Promise} A Promise that resolves when the support has been detected.+ */+ async detectSupportAsync(e) {+ return this.workerConfig = {+ astcSupported: await e.hasFeatureAsync("texture-compression-astc"),+ astcHDRSupported: !1,+ // https://github.com/gpuweb/gpuweb/issues/3856+ etc1Supported: await e.hasFeatureAsync("texture-compression-etc1"),+ etc2Supported: await e.hasFeatureAsync("texture-compression-etc2"),+ dxtSupported: await e.hasFeatureAsync("texture-compression-bc"),+ bptcSupported: await e.hasFeatureAsync("texture-compression-bptc"),+ pvrtcSupported: await e.hasFeatureAsync("texture-compression-pvrtc")+ }, this;+ }+ /**+ * Detects hardware support for available compressed texture formats, to determine+ * the output format for the transcoder. Must be called before loading a texture.+ *+ * @param {WebGPURenderer|WebGLRenderer} renderer - The renderer.+ * @return {KTX2Loader} A reference to this loader.+ */+ detectSupport(e) {+ return e.isWebGPURenderer === !0 ? this.workerConfig = {+ astcSupported: e.hasFeature("texture-compression-astc"),+ astcHDRSupported: !1,+ // https://github.com/gpuweb/gpuweb/issues/3856+ etc1Supported: e.hasFeature("texture-compression-etc1"),+ etc2Supported: e.hasFeature("texture-compression-etc2"),+ dxtSupported: e.hasFeature("texture-compression-bc"),+ bptcSupported: e.hasFeature("texture-compression-bptc"),+ pvrtcSupported: e.hasFeature("texture-compression-pvrtc")+ } : this.workerConfig = {+ astcSupported: e.extensions.has("WEBGL_compressed_texture_astc"),+ astcHDRSupported: e.extensions.has("WEBGL_compressed_texture_astc") && e.extensions.get("WEBGL_compressed_texture_astc").getSupportedProfiles().includes("hdr"),+ etc1Supported: e.extensions.has("WEBGL_compressed_texture_etc1"),+ etc2Supported: e.extensions.has("WEBGL_compressed_texture_etc"),+ dxtSupported: e.extensions.has("WEBGL_compressed_texture_s3tc"),+ bptcSupported: e.extensions.has("EXT_texture_compression_bptc"),+ pvrtcSupported: e.extensions.has("WEBGL_compressed_texture_pvrtc") || e.extensions.has("WEBKIT_WEBGL_compressed_texture_pvrtc")+ }, this;+ }+ // TODO: Make this method private+ init() {+ if (!this.transcoderPending) {+ const e = new Ps(this.manager);+ e.setPath(this.transcoderPath), e.setWithCredentials(this.withCredentials);+ const t = e.loadAsync("basis_transcoder.js"), n = new Ps(this.manager);+ n.setPath(this.transcoderPath), n.setResponseType("arraybuffer"), n.setWithCredentials(this.withCredentials);+ const s = n.loadAsync("basis_transcoder.wasm");+ this.transcoderPending = Promise.all([t, s]).then(([r, a]) => {+ const o = ii.BasisWorker.toString(), c = [+ "/* constants */",+ "let _EngineFormat = " + JSON.stringify(ii.EngineFormat),+ "let _EngineType = " + JSON.stringify(ii.EngineType),+ "let _TranscoderFormat = " + JSON.stringify(ii.TranscoderFormat),+ "let _BasisFormat = " + JSON.stringify(ii.BasisFormat),+ "/* basis_transcoder.js */",+ r,+ "/* worker */",+ o.substring(o.indexOf("{") + 1, o.lastIndexOf("}"))+ ].join(`+`);+ this.workerSourceURL = URL.createObjectURL(new Blob([c])), this.transcoderBinary = a, this.workerPool.setWorkerCreator(() => {+ const l = new Worker(this.workerSourceURL), h = this.transcoderBinary.slice(0);+ return l.postMessage({ type: "init", config: this.workerConfig, transcoderBinary: h }, [h]), l;+ });+ }), Uu > 0 && console.warn(+ "THREE.KTX2Loader: Multiple active KTX2 loaders may cause performance issues. Use a single KTX2Loader instance, or call .dispose() on old instances."+ ), Uu++;+ }+ return this.transcoderPending;+ }+ /**+ * Starts loading from the given URL and passes the loaded KTX2 texture+ * to the `onLoad()` callback.+ *+ * @param {string} url - The path/URL of the file to be loaded. This can also be a data URI.+ * @param {function(CompressedTexture)} onLoad - Executed when the loading process has been finished.+ * @param {onProgressCallback} onProgress - Executed while the loading is in progress.+ * @param {onErrorCallback} onError - Executed when errors occur.+ */+ load(e, t, n, s) {+ if (this.workerConfig === null)+ throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");+ const r = new Ps(this.manager);+ r.setResponseType("arraybuffer"), r.setWithCredentials(this.withCredentials), r.load(e, (a) => {+ this.parse(a, t, s);+ }, n, s);+ }+ /**+ * Parses the given KTX2 data.+ *+ * @param {ArrayBuffer} buffer - The raw KTX2 data as an array buffer.+ * @param {function(CompressedTexture)} onLoad - Executed when the loading/parsing process has been finished.+ * @param {onErrorCallback} onError - Executed when errors occur.+ * @returns {Promise} A Promise that resolves when the parsing has been finished.+ */+ parse(e, t, n) {+ if (this.workerConfig === null)+ throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");+ if (ku.has(e))+ return ku.get(e).promise.then(t).catch(n);+ this._createTexture(e).then((s) => t ? t(s) : null).catch(n);+ }+ _createTextureFrom(e, t) {+ const { type: n, error: s, data: { faces: r, width: a, height: o, format: c, type: l, dfdFlags: h } } = e;+ if (n === "error") return Promise.reject(s);+ let u;+ if (t.faceCount === 6)+ u = new py(r, c, l);+ else {+ const d = r[0].mipmaps;+ u = t.layerCount > 1 ? new fy(d, a, o, t.layerCount, c, l) : new Jl(d, a, o, c, l);+ }+ return u.minFilter = r[0].mipmaps.length === 1 ? qt : si, u.magFilter = qt, u.generateMipmaps = !1, u.needsUpdate = !0, u.colorSpace = w_(t), u.premultiplyAlpha = !!(h & l2), u;+ }+ /**+ * @private+ * @param {ArrayBuffer} buffer+ * @param {?Object} config+ * @return {Promise<CompressedTexture|CompressedArrayTexture|DataTexture|Data3DTexture>}+ */+ async _createTexture(e, t = {}) {+ const n = A2(new Uint8Array(e)), s = n.vkFormat === hp && n.dataFormatDescriptor[0].colorModel === 167;+ if (!(n.vkFormat === f2 || s && !this.workerConfig.astcHDRSupported))+ return _2(n);+ const a = t, o = this.init().then(() => this.workerPool.postMessage({ type: "transcode", buffer: e, taskConfig: a }, [e])).then((c) => this._createTextureFrom(c.data, n));+ return ku.set(e, { promise: o }), o;+ }+ /**+ * Frees internal resources. This method should be called+ * when the loader is no longer required.+ */+ dispose() {+ this.workerPool.dispose(), this.workerSourceURL && URL.revokeObjectURL(this.workerSourceURL), Uu--;+ }+}+ii.BasisFormat = {+ ETC1S: 0,+ UASTC: 1,+ UASTC_HDR: 2+};+ii.TranscoderFormat = {+ ETC1: 0,+ ETC2: 1,+ BC1: 2,+ BC3: 3,+ BC4: 4,+ BC5: 5,+ BC7_M6_OPAQUE_ONLY: 6,+ BC7_M5: 7,+ PVRTC1_4_RGB: 8,+ PVRTC1_4_RGBA: 9,+ ASTC_4x4: 10,+ ATC_RGB: 11,+ ATC_RGBA_INTERPOLATED_ALPHA: 12,+ RGBA32: 13,+ RGB565: 14,+ BGR565: 15,+ RGBA4444: 16,+ BC6H: 22,+ RGB_HALF: 24,+ RGBA_HALF: 25+};+ii.EngineFormat = {+ RGBAFormat: on,+ RGBA_ASTC_4x4_Format: Do,+ RGB_BPTC_UNSIGNED_Format: Il,+ RGBA_BPTC_Format: Eo,+ RGBA_ETC2_EAC_Format: Sl,+ RGBA_PVRTC_4BPPV1_Format: wl,+ RGBA_S3TC_DXT5_Format: _o,+ RGB_ETC1_Format: vl,+ RGB_ETC2_Format: Cl,+ RGB_PVRTC_4BPPV1_Format: yl,+ RGBA_S3TC_DXT1_Format: xo+};+ii.EngineType = {+ UnsignedByteType: rn,+ HalfFloatType: Nn,+ FloatType: an+};+ii.BasisWorker = function() {+ let i, e, t;+ const n = _EngineFormat, s = _EngineType, r = _TranscoderFormat, a = _BasisFormat;+ self.addEventListener("message", function(m) {+ const A = m.data;+ switch (A.type) {+ case "init":+ i = A.config, o(A.transcoderBinary);+ break;+ case "transcode":+ e.then(() => {+ try {+ const { faces: g, buffers: p, width: y, height: b, hasAlpha: E, format: M, type: w, dfdFlags: S } = c(A.buffer);+ self.postMessage({ type: "transcode", id: A.id, data: { faces: g, width: y, height: b, hasAlpha: E, format: M, type: w, dfdFlags: S } }, p);+ } catch (g) {+ console.error(g), self.postMessage({ type: "error", id: A.id, error: g.message });+ }+ });+ break;+ }+ });+ function o(m) {+ e = new Promise((A) => {+ t = { wasmBinary: m, onRuntimeInitialized: A }, BASIS(t);+ }).then(() => {+ t.initializeBasis(), t.KTX2File === void 0 && console.warn("THREE.KTX2Loader: Please update Basis Universal transcoder.");+ });+ }+ function c(m) {+ const A = new t.KTX2File(new Uint8Array(m));+ function g() {+ A.close(), A.delete();+ }+ if (!A.isValid())+ throw g(), new Error("THREE.KTX2Loader: Invalid or unsupported .ktx2 file");+ let p;+ if (A.isUASTC())+ p = a.UASTC;+ else if (A.isETC1S())+ p = a.ETC1S;+ else if (A.isHDR())+ p = a.UASTC_HDR;+ else+ throw new Error("THREE.KTX2Loader: Unknown Basis encoding");+ const y = A.getWidth(), b = A.getHeight(), E = A.getLayers() || 1, M = A.getLevels(), w = A.getFaces(), S = A.getHasAlpha(), T = A.getDFDFlags(), { transcoderFormat: C, engineFormat: v, engineType: F } = u(p, y, b, S);+ if (!y || !b || !M)+ throw g(), new Error("THREE.KTX2Loader: Invalid texture");+ if (!A.startTranscoding())+ throw g(), new Error("THREE.KTX2Loader: .startTranscoding failed");+ const K = [], q = [];+ for (let $ = 0; $ < w; $++) {+ const D = [];+ for (let O = 0; O < M; O++) {+ const Y = [];+ let Q, J;+ for (let ae = 0; ae < E; ae++) {+ const ye = A.getImageLevelInfo(O, ae, $);+ $ === 0 && O === 0 && ae === 0 && (ye.origWidth % 4 !== 0 || ye.origHeight % 4 !== 0) && console.warn("THREE.KTX2Loader: ETC1S and UASTC textures should use multiple-of-four dimensions."), M > 1 ? (Q = ye.origWidth, J = ye.origHeight) : (Q = ye.width, J = ye.height);+ let Me = new Uint8Array(A.getImageTranscodedSizeInBytes(O, ae, 0, C));+ const se = A.transcodeImage(Me, O, ae, $, C, 0, -1, -1);+ if (F === s.HalfFloatType && (Me = new Uint16Array(Me.buffer, Me.byteOffset, Me.byteLength / Uint16Array.BYTES_PER_ELEMENT)), !se)+ throw g(), new Error("THREE.KTX2Loader: .transcodeImage failed.");+ Y.push(Me);+ }+ const ee = f(Y);+ D.push({ data: ee, width: Q, height: J }), q.push(ee.buffer);+ }+ K.push({ mipmaps: D, width: y, height: b, format: v, type: F });+ }+ return g(), { faces: K, buffers: q, width: y, height: b, hasAlpha: S, dfdFlags: T, format: v, type: F };+ }+ const l = [+ {+ if: "astcSupported",+ basisFormat: [a.UASTC],+ transcoderFormat: [r.ASTC_4x4, r.ASTC_4x4],+ engineFormat: [n.RGBA_ASTC_4x4_Format, n.RGBA_ASTC_4x4_Format],+ engineType: [s.UnsignedByteType],+ priorityETC1S: 1 / 0,+ priorityUASTC: 1,+ needsPowerOfTwo: !1+ },+ {+ if: "bptcSupported",+ basisFormat: [a.ETC1S, a.UASTC],+ transcoderFormat: [r.BC7_M5, r.BC7_M5],+ engineFormat: [n.RGBA_BPTC_Format, n.RGBA_BPTC_Format],+ engineType: [s.UnsignedByteType],+ priorityETC1S: 3,+ priorityUASTC: 2,+ needsPowerOfTwo: !1+ },+ {+ if: "dxtSupported",+ basisFormat: [a.ETC1S, a.UASTC],+ transcoderFormat: [r.BC1, r.BC3],+ engineFormat: [n.RGBA_S3TC_DXT1_Format, n.RGBA_S3TC_DXT5_Format],+ engineType: [s.UnsignedByteType],+ priorityETC1S: 4,+ priorityUASTC: 5,+ needsPowerOfTwo: !1+ },+ {+ if: "etc2Supported",+ basisFormat: [a.ETC1S, a.UASTC],+ transcoderFormat: [r.ETC1, r.ETC2],+ engineFormat: [n.RGB_ETC2_Format, n.RGBA_ETC2_EAC_Format],+ engineType: [s.UnsignedByteType],+ priorityETC1S: 1,+ priorityUASTC: 3,+ needsPowerOfTwo: !1+ },+ {+ if: "etc1Supported",+ basisFormat: [a.ETC1S, a.UASTC],+ transcoderFormat: [r.ETC1],+ engineFormat: [n.RGB_ETC1_Format],+ engineType: [s.UnsignedByteType],+ priorityETC1S: 2,+ priorityUASTC: 4,+ needsPowerOfTwo: !1+ },+ {+ if: "pvrtcSupported",+ basisFormat: [a.ETC1S, a.UASTC],+ transcoderFormat: [r.PVRTC1_4_RGB, r.PVRTC1_4_RGBA],+ engineFormat: [n.RGB_PVRTC_4BPPV1_Format, n.RGBA_PVRTC_4BPPV1_Format],+ engineType: [s.UnsignedByteType],+ priorityETC1S: 5,+ priorityUASTC: 6,+ needsPowerOfTwo: !0+ },+ {+ if: "bptcSupported",+ basisFormat: [a.UASTC_HDR],+ transcoderFormat: [r.BC6H],+ engineFormat: [n.RGB_BPTC_UNSIGNED_Format],+ engineType: [s.HalfFloatType],+ priorityHDR: 1,+ needsPowerOfTwo: !1+ },+ // Uncompressed fallbacks.+ {+ basisFormat: [a.ETC1S, a.UASTC],+ transcoderFormat: [r.RGBA32, r.RGBA32],+ engineFormat: [n.RGBAFormat, n.RGBAFormat],+ engineType: [s.UnsignedByteType, s.UnsignedByteType],+ priorityETC1S: 100,+ priorityUASTC: 100,+ needsPowerOfTwo: !1+ },+ {+ basisFormat: [a.UASTC_HDR],+ transcoderFormat: [r.RGBA_HALF],+ engineFormat: [n.RGBAFormat],+ engineType: [s.HalfFloatType],+ priorityHDR: 100,+ needsPowerOfTwo: !1+ }+ ], h = {+ // TODO: For ETC1S we intentionally sort by _UASTC_ priority, preserving+ // a historical accident shown to avoid performance pitfalls for Linux with+ // Firefox & AMD GPU (RadeonSI). Further work needed.+ // See https://github.com/mrdoob/three.js/pull/29730.+ [a.ETC1S]: l.filter((m) => m.basisFormat.includes(a.ETC1S)).sort((m, A) => m.priorityUASTC - A.priorityUASTC),+ [a.UASTC]: l.filter((m) => m.basisFormat.includes(a.UASTC)).sort((m, A) => m.priorityUASTC - A.priorityUASTC),+ [a.UASTC_HDR]: l.filter((m) => m.basisFormat.includes(a.UASTC_HDR)).sort((m, A) => m.priorityHDR - A.priorityHDR)+ };+ function u(m, A, g, p) {+ const y = h[m];+ for (let b = 0; b < y.length; b++) {+ const E = y[b];+ if (E.if && !i[E.if] || !E.basisFormat.includes(m) || p && E.transcoderFormat.length < 2 || E.needsPowerOfTwo && !(d(A) && d(g))) continue;+ const M = E.transcoderFormat[p ? 1 : 0], w = E.engineFormat[p ? 1 : 0], S = E.engineType[0];+ return { transcoderFormat: M, engineFormat: w, engineType: S };+ }+ throw new Error("THREE.KTX2Loader: Failed to identify transcoding target.");+ }+ function d(m) {+ return m <= 2 ? !0 : (m & m - 1) === 0 && m !== 0;+ }+ function f(m) {+ if (m.length === 1) return m[0];+ let A = 0;+ for (let y = 0; y < m.length; y++) {+ const b = m[y];+ A += b.byteLength;+ }+ const g = new Uint8Array(A);+ let p = 0;+ for (let y = 0; y < m.length; y++) {+ const b = m[y];+ g.set(b, p), p += b.byteLength;+ }+ return g;+ }+};+const x2 = /* @__PURE__ */ new Set([on, dr, ns]), Qu = {+ [__]: on,+ [m_]: on,+ [f_]: on,+ [p_]: on,+ [x_]: dr,+ [g_]: dr,+ [u_]: dr,+ [d_]: dr,+ [b_]: ns,+ [A_]: ns,+ [h_]: ns,+ [l_]: ns,+ [hp]: Do,+ [y_]: Lo,+ [E_]: Lo+}, Gu = {+ [__]: an,+ [m_]: Nn,+ [f_]: rn,+ [p_]: rn,+ [x_]: an,+ [g_]: Nn,+ [u_]: rn,+ [d_]: rn,+ [b_]: an,+ [A_]: Nn,+ [h_]: rn,+ [l_]: rn,+ [hp]: Nn,+ [y_]: rn,+ [E_]: rn+};+async function _2(i) {+ const { vkFormat: e } = i;+ if (Qu[e] === void 0)+ throw new Error("THREE.KTX2Loader: Unsupported vkFormat.");+ let t;+ i.supercompressionScheme === Um && (Ou || (Ou = new Promise(async (r) => {+ const a = new g2();+ await a.init(), r(a);+ })), t = await Ou);+ const n = [];+ for (let r = 0; r < i.levels.length; r++) {+ const a = Math.max(1, i.pixelWidth >> r), o = Math.max(1, i.pixelHeight >> r), c = i.pixelDepth ? Math.max(1, i.pixelDepth >> r) : 0, l = i.levels[r];+ let h;+ if (i.supercompressionScheme === c2)+ h = l.levelData;+ else if (i.supercompressionScheme === Um)+ h = t.decode(l.levelData, l.uncompressedByteLength);+ else+ throw new Error("THREE.KTX2Loader: Unsupported supercompressionScheme.");+ let u;+ Gu[e] === an ? u = new Float32Array(+ h.buffer,+ h.byteOffset,+ h.byteLength / Float32Array.BYTES_PER_ELEMENT+ ) : Gu[e] === Nn ? u = new Uint16Array(+ h.buffer,+ h.byteOffset,+ h.byteLength / Uint16Array.BYTES_PER_ELEMENT+ ) : u = h, n.push({+ data: u,+ width: a,+ height: o,+ depth: c+ });+ }+ let s;+ if (x2.has(Qu[e]))+ s = i.pixelDepth === 0 ? new Xl(n[0].data, i.pixelWidth, i.pixelHeight) : new o0(n[0].data, i.pixelWidth, i.pixelHeight, i.pixelDepth);+ else {+ if (i.pixelDepth > 0) throw new Error("THREE.KTX2Loader: Unsupported pixelDepth.");+ s = new Jl(n, i.pixelWidth, i.pixelHeight), s.minFilter = n.length === 1 ? qt : si, s.magFilter = qt;+ }+ return s.mipmaps = n, s.type = Gu[e], s.format = Qu[e], s.colorSpace = w_(i), s.needsUpdate = !0, Promise.resolve(s);+}+function w_(i) {+ const e = i.dataFormatDescriptor[0];+ return e.colorPrimaries === u2 ? e.transferFunction === Om ? Kt : ln : e.colorPrimaries === d2 ? e.transferFunction === Om ? m2 : b2 : (e.colorPrimaries === h2 || console.warn(`THREE.KTX2Loader: Unsupported color primaries, "${e.colorPrimaries}"`), gi);+}+const E2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({+ __proto__: null,+ KTX2Loader: ii+}, Symbol.toStringTag, { value: "Module" }));+var y2 = (function() {+ var i = "b9H79Tebbbe8Fv9Gbb9Gvuuuuueu9Giuuub9Geueu9Giuuueuikqbeeedddillviebeoweuec:q;iekr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbeY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVbdE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbiL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtblK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbol79IV9Rbrq:P8Yqdbk;3sezu8Jjjjjbcj;eb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Radz1jjjbhwcj;abad9UhoaicefhldnadTmbaoc;WFbGgocjdaocjd6EhDcbhqinaqae9pmeaDaeaq9RaqaDfae6Egkcsfgocl4cifcd4hxdndndndnaoc9WGgmTmbcbhPcehsawcjdfhzalhHinaraH9Rax6midnaraHaxfgl9RcK6mbczhoinawcj;cbfaogifgoc9WfhOdndndndndnaHaic9WfgAco4fRbbaAci4coG4ciGPlbedibkaO9cb83ibaOcwf9cb83ibxikaOalRblalRbbgAco4gCaCciSgCE86bbaocGfalclfaCfgORbbaAcl4ciGgCaCciSgCE86bbaocVfaOaCfgORbbaAcd4ciGgCaCciSgCE86bbaoc7faOaCfgORbbaAciGgAaAciSgAE86bbaoctfaOaAfgARbbalRbegOco4gCaCciSgCE86bbaoc91faAaCfgARbbaOcl4ciGgCaCciSgCE86bbaoc4faAaCfgARbbaOcd4ciGgCaCciSgCE86bbaoc93faAaCfgARbbaOciGgOaOciSgOE86bbaoc94faAaOfgARbbalRbdgOco4gCaCciSgCE86bbaoc95faAaCfgARbbaOcl4ciGgCaCciSgCE86bbaoc96faAaCfgARbbaOcd4ciGgCaCciSgCE86bbaoc97faAaCfgARbbaOciGgOaOciSgOE86bbaoc98faAaOfgORbbalRbiglco4gAaAciSgAE86bbaoc99faOaAfgORbbalcl4ciGgAaAciSgAE86bbaoc9:faOaAfgORbbalcd4ciGgAaAciSgAE86bbaocufaOaAfgoRbbalciGglalciSglE86bbaoalfhlxdkaOalRbwalRbbgAcl4gCaCcsSgCE86bbaocGfalcwfaCfgORbbaAcsGgAaAcsSgAE86bbaocVfaOaAfgORbbalRbegAcl4gCaCcsSgCE86bbaoc7faOaCfgORbbaAcsGgAaAcsSgAE86bbaoctfaOaAfgORbbalRbdgAcl4gCaCcsSgCE86bbaoc91faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc4faOaAfgORbbalRbigAcl4gCaCcsSgCE86bbaoc93faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc94faOaAfgORbbalRblgAcl4gCaCcsSgCE86bbaoc95faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc96faOaAfgORbbalRbvgAcl4gCaCcsSgCE86bbaoc97faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc98faOaAfgORbbalRbogAcl4gCaCcsSgCE86bbaoc99faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc9:faOaAfgORbbalRbrglcl4gAaAcsSgAE86bbaocufaOaAfgoRbbalcsGglalcsSglE86bbaoalfhlxekaOal8Pbb83bbaOcwfalcwf8Pbb83bbalczfhlkdnaiam9pmbaiczfhoaral9RcL0mekkaiam6mialTmidnakTmbawaPfRbbhOcbhoazhiinaiawcj;cbfaofRbbgAce4cbaAceG9R7aOfgO86bbaiadfhiaocefgoak9hmbkkazcefhzaPcefgPad6hsalhHaPad9hmexvkkcbhlasceGmdxikalaxad2fhCdnakTmbcbhHcehsawcjdfhminaral9Rax6mialTmdalaxfhlawaHfRbbhOcbhoamhiinaiawcj;cbfaofRbbgAce4cbaAceG9R7aOfgO86bbaiadfhiaocefgoak9hmbkamcefhmaHcefgHad6hsaHad9hmbkaChlxikcbhocehsinaral9Rax6mdalTmealaxfhlaocefgoad6hsadao9hmbkaChlxdkcbhlasceGTmekc9:hoxikabaqad2fawcjdfakad2z1jjjb8Aawawcjdfakcufad2fadz1jjjb8Aakaqfhqalmbkc9:hoxekcbc99aral9Radcaadca0ESEhokavcj;ebf8Kjjjjbaok;yzeHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecjez:jjjjb8AavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhodnaeTmbcmcsaDceSEhkcbhxcbhmcbhDcbhicbhlindnaoaq9nmbc9:hoxikdndnawRbbgrc;Ve0mbavc;abfalarcl4cu7fcsGcitfgPydlhsaPydbhzdnarcsGgPak9pmbavaiarcu7fcsGcdtfydbaxaPEhraPThPdndnadcd9hmbabaDcetfgHaz87ebaHcdfas87ebaHclfar87ebxekabaDcdtfgHazBdbaHclfasBdbaHcwfarBdbkaxaPfhxavc;abfalcitfgHarBdbaHasBdlavaicdtfarBdbavc;abfalcefcsGglcitfgHazBdbaHarBdlaiaPfhialcefhlxdkdndnaPcsSmbamaPfaPc987fcefhmxekaocefhrao8SbbgPcFeGhHdndnaPcu9mmbarhoxekaocvfhoaHcFbGhHcrhPdninar8SbbgOcFbGaPtaHVhHaOcu9kmearcefhraPcrfgPc8J9hmbxdkkarcefhokaHce4cbaHceG9R7amfhmkdndnadcd9hmbabaDcetfgraz87ebarcdfas87ebarclfam87ebxekabaDcdtfgrazBdbarclfasBdbarcwfamBdbkavc;abfalcitfgramBdbarasBdlavaicdtfamBdbavc;abfalcefcsGglcitfgrazBdbaramBdlaicefhialcefhlxekdnarcpe0mbaxcefgOavaiaqarcsGfRbbgPcl49RcsGcdtfydbaPcz6gHEhravaiaP9RcsGcdtfydbaOaHfgsaPcsGgOEhPaOThOdndnadcd9hmbabaDcetfgzax87ebazcdfar87ebazclfaP87ebxekabaDcdtfgzaxBdbazclfarBdbazcwfaPBdbkavaicdtfaxBdbavc;abfalcitfgzarBdbazaxBdlavaicefgicsGcdtfarBdbavc;abfalcefcsGcitfgzaPBdbazarBdlavaiaHfcsGgicdtfaPBdbavc;abfalcdfcsGglcitfgraxBdbaraPBdlalcefhlaiaOfhiasaOfhxxekaxcbaoRbbgzEgAarc;:eSgrfhsazcsGhCazcl4hXdndnazcs0mbascefhOxekashOavaiaX9RcsGcdtfydbhskdndnaCmbaOcefhxxekaOhxavaiaz9RcsGcdtfydbhOkdndnarTmbaocefhrxekaocdfhrao8SbegHcFeGhPdnaHcu9kmbaocofhAaPcFbGhPcrhodninar8SbbgHcFbGaotaPVhPaHcu9kmearcefhraocrfgoc8J9hmbkaAhrxekarcefhrkaPce4cbaPceG9R7amfgmhAkdndnaXcsSmbarhPxekarcefhPar8SbbgocFeGhHdnaocu9kmbarcvfhsaHcFbGhHcrhodninaP8SbbgrcFbGaotaHVhHarcu9kmeaPcefhPaocrfgoc8J9hmbkashPxekaPcefhPkaHce4cbaHceG9R7amfgmhskdndnaCcsSmbaPhoxekaPcefhoaP8SbbgrcFeGhHdnarcu9kmbaPcvfhOaHcFbGhHcrhrdninao8SbbgPcFbGartaHVhHaPcu9kmeaocefhoarcrfgrc8J9hmbkaOhoxekaocefhokaHce4cbaHceG9R7amfgmhOkdndnadcd9hmbabaDcetfgraA87ebarcdfas87ebarclfaO87ebxekabaDcdtfgraABdbarclfasBdbarcwfaOBdbkavc;abfalcitfgrasBdbaraABdlavaicdtfaABdbavc;abfalcefcsGcitfgraOBdbarasBdlavaicefgicsGcdtfasBdbavc;abfalcdfcsGcitfgraABdbaraOBdlavaiazcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhialcifhlkawcefhwalcsGhlaicsGhiaDcifgDae6mbkkcbc99aoaqSEhokavc;aef8Kjjjjbaok:llevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:Lvoeue99dud99eud99dndnadcl9hmbaeTmeindndnabcdfgd8Sbb:Yab8Sbbgi:Ygl:l:tabcefgv8Sbbgo:Ygr:l:tgwJbb;:9cawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai86bbdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad86bbdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad86bbabclfhbaecufgembxdkkaeTmbindndnabclfgd8Ueb:Yab8Uebgi:Ygl:l:tabcdfgv8Uebgo:Ygr:l:tgwJb;:FSawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai87ebdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad87ebdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad87ebabcwfhbaecufgembkkk;siliui99iue99dnaeTmbcbhiabhlindndnJ;Zl81Zalcof8UebgvciV:Y:vgoal8Ueb:YNgrJb;:FSNJbbbZJbbb:;arJbbbb9GEMgw:lJbbb9p9DTmbaw:OhDxekcjjjj94hDkalclf8Uebhqalcdf8UebhkabavcefciGaiVcetfaD87ebdndnaoak:YNgwJb;:FSNJbbbZJbbb:;awJbbbb9GEMgx:lJbbb9p9DTmbax:Ohkxekcjjjj94hkkabavcdfciGaiVcetfak87ebdndnaoaq:YNgoJb;:FSNJbbbZJbbb:;aoJbbbb9GEMgx:lJbbb9p9DTmbax:Ohqxekcjjjj94hqkabavcufciGaiVcetfaq87ebdndnJbbjZararN:tawawN:taoaoN:tgrJbbbbarJbbbb9GE:rJb;:FSNJbbbZMgr:lJbbb9p9DTmbar:Ohqxekcjjjj94hqkabavciGaiVcetfaq87ebalcwfhlaiclfhiaecufgembkkk9mbdnadcd4ae2geTmbinababydbgdcwtcw91:Yadce91cjjj;8ifcjjj98G::NUdbabclfhbaecufgembkkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaiczfhiaeczfheadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabkkkebcjwklz9Kbb", e = "b9H79TebbbeKl9Gbb9Gvuuuuueu9Giuuub9Geueuikqbbebeedddilve9Weeeviebeoweuec:q;Aekr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbdY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVblE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtboK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbrL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbwl79IV9RbDq;t9tqlbzik9:evu8Jjjjjbcz9Rhbcbheincbhdcbhiinabcwfadfaicjuaead4ceGglE86bbaialfhiadcefgdcw9hmbkaec:q:yjjbfai86bbaecitc:q1jjbfab8Piw83ibaecefgecjd9hmbkk;h8JlHud97euo978Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Rad;8qbbcj;abad9UhoaicefhldnadTmbaoc;WFbGgocjdaocjd6EhwcbhDinaDae9pmeawaeaD9RaDawfae6Egqcsfgoc9WGgkci2hxakcethmaocl4cifcd4hPabaDad2fhscbhzdnincehHalhOcbhAdninaraO9RaP6miavcj;cbfaAak2fhCaOaPfhlcbhidnakc;ab6mbaral9Rc;Gb6mbcbhoinaCaofhidndndndndnaOaoco4fRbbgXciGPlbedibkaipxbbbbbbbbbbbbbbbbpklbxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklbalczfhlkdndndndndnaXcd4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklzxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklzalczfhlkdndndndndnaXcl4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklaxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklaalczfhlkdndndndndnaXco4Plbedibkaipxbbbbbbbbbbbbbbbbpkl8WxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WalclfaYpQbfaXc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WalcwfaYpQbfaXc:q:yjjbfRbbfhlxekaialpbbbpkl8Walczfhlkaoc;abfhiaocjefak0meaihoaral9Rc;Fb0mbkkdndnaiak9pmbaici4hoinaral9RcK6mdaCaifhXdndndndndnaOaico4fRbbaocoG4ciGPlbedibkaXpxbbbbbbbbbbbbbbbbpklbxikaXalpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaXalpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaXalpbbbpklbalczfhlkaocdfhoaiczfgiak6mbkkalTmbaAci6hHalhOaAcefgohAaoclSmdxekkcbhlaHceGmdkdnakTmbavcjdfazfhiavazfpbdbhYcbhXinaiavcj;cbfaXfgopblbgLcep9TaLpxeeeeeeeeeeeeeeeegQp9op9Hp9rgLaoakfpblbg8Acep9Ta8AaQp9op9Hp9rg8ApmbzeHdOiAlCvXoQrLgEaoamfpblbg3cep9Ta3aQp9op9Hp9rg3aoaxfpblbg5cep9Ta5aQp9op9Hp9rg5pmbzeHdOiAlCvXoQrLg8EpmbezHdiOAlvCXorQLgQaQpmbedibedibedibediaYp9UgYp9AdbbaiadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaEa8EpmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaLa8ApmwKDYq8AkEx3m5P8Es8FgLa3a5pmwKDYq8AkEx3m5P8Es8Fg8ApmbezHdiOAlvCXorQLgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaLa8ApmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfhiaXczfgXak6mbkkazclfgzad6mbkasavcjdfaqad2;8qbbavavcjdfaqcufad2fad;8qbbaqaDfhDc9:hoalmexikkc9:hoxekcbc99aral9Radcaadca0ESEhokavcj;kbf8Kjjjjbaokwbz:bjjjbk;uzeHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecje;8kbavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhodnaeTmbcmcsaDceSEhkcbhxcbhmcbhDcbhicbhlindnaoaq9nmbc9:hoxikdndnawRbbgrc;Ve0mbavc;abfalarcl4cu7fcsGcitfgPydlhsaPydbhzdnarcsGgPak9pmbavaiarcu7fcsGcdtfydbaxaPEhraPThPdndnadcd9hmbabaDcetfgHaz87ebaHcdfas87ebaHclfar87ebxekabaDcdtfgHazBdbaHclfasBdbaHcwfarBdbkaxaPfhxavc;abfalcitfgHarBdbaHasBdlavaicdtfarBdbavc;abfalcefcsGglcitfgHazBdbaHarBdlaiaPfhialcefhlxdkdndnaPcsSmbamaPfaPc987fcefhmxekaocefhrao8SbbgPcFeGhHdndnaPcu9mmbarhoxekaocvfhoaHcFbGhHcrhPdninar8SbbgOcFbGaPtaHVhHaOcu9kmearcefhraPcrfgPc8J9hmbxdkkarcefhokaHce4cbaHceG9R7amfhmkdndnadcd9hmbabaDcetfgraz87ebarcdfas87ebarclfam87ebxekabaDcdtfgrazBdbarclfasBdbarcwfamBdbkavc;abfalcitfgramBdbarasBdlavaicdtfamBdbavc;abfalcefcsGglcitfgrazBdbaramBdlaicefhialcefhlxekdnarcpe0mbaxcefgOavaiaqarcsGfRbbgPcl49RcsGcdtfydbaPcz6gHEhravaiaP9RcsGcdtfydbaOaHfgsaPcsGgOEhPaOThOdndnadcd9hmbabaDcetfgzax87ebazcdfar87ebazclfaP87ebxekabaDcdtfgzaxBdbazclfarBdbazcwfaPBdbkavaicdtfaxBdbavc;abfalcitfgzarBdbazaxBdlavaicefgicsGcdtfarBdbavc;abfalcefcsGcitfgzaPBdbazarBdlavaiaHfcsGgicdtfaPBdbavc;abfalcdfcsGglcitfgraxBdbaraPBdlalcefhlaiaOfhiasaOfhxxekaxcbaoRbbgzEgAarc;:eSgrfhsazcsGhCazcl4hXdndnazcs0mbascefhOxekashOavaiaX9RcsGcdtfydbhskdndnaCmbaOcefhxxekaOhxavaiaz9RcsGcdtfydbhOkdndnarTmbaocefhrxekaocdfhrao8SbegHcFeGhPdnaHcu9kmbaocofhAaPcFbGhPcrhodninar8SbbgHcFbGaotaPVhPaHcu9kmearcefhraocrfgoc8J9hmbkaAhrxekarcefhrkaPce4cbaPceG9R7amfgmhAkdndnaXcsSmbarhPxekarcefhPar8SbbgocFeGhHdnaocu9kmbarcvfhsaHcFbGhHcrhodninaP8SbbgrcFbGaotaHVhHarcu9kmeaPcefhPaocrfgoc8J9hmbkashPxekaPcefhPkaHce4cbaHceG9R7amfgmhskdndnaCcsSmbaPhoxekaPcefhoaP8SbbgrcFeGhHdnarcu9kmbaPcvfhOaHcFbGhHcrhrdninao8SbbgPcFbGartaHVhHaPcu9kmeaocefhoarcrfgrc8J9hmbkaOhoxekaocefhokaHce4cbaHceG9R7amfgmhOkdndnadcd9hmbabaDcetfgraA87ebarcdfas87ebarclfaO87ebxekabaDcdtfgraABdbarclfasBdbarcwfaOBdbkavc;abfalcitfgrasBdbaraABdlavaicdtfaABdbavc;abfalcefcsGcitfgraOBdbarasBdlavaicefgicsGcdtfasBdbavc;abfalcdfcsGcitfgraABdbaraOBdlavaiazcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhialcifhlkawcefhwalcsGhlaicsGhiaDcifgDae6mbkkcbc99aoaqSEhokavc;aef8Kjjjjbaok:llevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:EPliuo97eue978Jjjjjbca9Rhidndnadcl9hmbdnaec98GglTmbcbhvabhdinadadpbbbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpkbbadczfhdavclfgval6mbkkalae9pmeaiaeciGgvcdtgdVcbczad9R;8kbaiabalcdtfglad;8qbbdnavTmbaiaipblbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpklbkalaiad;8qbbskdnaec98GgxTmbcbhvabhdinadczfglalpbbbgopxbbbbbbFFbbbbbbFFgkp9oadpbbbgDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eaDaopmbediwDqkzHOAKY8AEgoczp:Sep;6egrp;Geaoczp:Reczp:Sep;6egwp;Gep;Kep;Legopxb;:FSb;:FSb;:FSb;:FSawaopxbbbbbbbbbbbbbbbbp:2egqawpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegwawp;Meaoaop;Mearaqaramp9op9rp;Kegoaop;Mep;Kep;Kep;Jep;Negrp;Mepxbbn0bbn0bbn0bbn0gqp;Keczp:Reawarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9op9qgwaoarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogopmwDKYqk8AExm35Ps8E8Fp9qpkbbadaDakp9oawaopmbezHdiOAlvCXorQLp9qpkbbadcafhdavclfgvax6mbkkaxae9pmbaiaeciGgvcitgdfcbcaad9R;8kbaiabaxcitfglad;8qbbdnavTmbaiaipblzgopxbbbbbbFFbbbbbbFFgkp9oaipblbgDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eaDaopmbediwDqkzHOAKY8AEgoczp:Sep;6egrp;Geaoczp:Reczp:Sep;6egwp;Gep;Kep;Legopxb;:FSb;:FSb;:FSb;:FSawaopxbbbbbbbbbbbbbbbbp:2egqawpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegwawp;Meaoaop;Mearaqaramp9op9rp;Kegoaop;Mep;Kep;Kep;Jep;Negrp;Mepxbbn0bbn0bbn0bbn0gqp;Keczp:Reawarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9op9qgwaoarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogopmwDKYqk8AExm35Ps8E8Fp9qpklzaiaDakp9oawaopmbezHdiOAlvCXorQLp9qpklbkalaiad;8qbbkk;4wllue97euv978Jjjjjbc8W9Rhidnaec98GglTmbcbhvabhoinaiaopbbbgraoczfgwpbbbgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklbaopxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaqakp;Mearp;Keczp:ReaDakp;Mearp;Keamp9op9qgkpmbezHdiOAlvCXorQLgrp5baipblbpEb:T:j83ibaocwfarp5eaipblbpEe:T:j83ibawaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblbpEd:T:j83ibaocKfakp5eaipblbpEi:T:j83ibaocafhoavclfgval6mbkkdnalae9pmbaiaeciGgvcitgofcbcaao9R;8kbaiabalcitfgwao;8qbbdnavTmbaiaipblbgraipblzgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklaaipxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaqakp;Mearp;Keczp:ReaDakp;Mearp;Keamp9op9qgkpmbezHdiOAlvCXorQLgrp5baipblapEb:T:j83ibaiarp5eaipblapEe:T:j83iwaiaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblapEd:T:j83izaiakp5eaipblapEi:T:j83iKkawaiao;8qbbkk:Pddiue978Jjjjjbc;ab9Rhidnadcd4ae2glc98GgvTmbcbhdabheinaeaepbbbgocwp:Recwp:Sep;6eaocep:SepxbbjZbbjZbbjZbbjZp:UepxbbjFbbjFbbjFbbjFp9op;Mepkbbaeczfheadclfgdav6mbkkdnaval9pmbaialciGgdcdtgeVcbc;abae9R;8kbaiabavcdtfgvae;8qbbdnadTmbaiaipblbgocwp:Recwp:Sep;6eaocep:SepxbbjZbbjZbbjZbbjZp:UepxbbjFbbjFbbjFbbjFp9op;Mepklbkavaiae;8qbbkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikkkebcjwklz9Tbb", t = new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 3, 2, 0, 0, 5, 3, 1, 0, 1, 12, 1, 0, 10, 22, 2, 12, 0, 65, 0, 65, 0, 65, 0, 252, 10, 0, 0, 11, 7, 0, 65, 0, 253, 15, 26, 11]), n = new Uint8Array([32, 0, 65, 2, 1, 106, 34, 33, 3, 128, 11, 4, 13, 64, 6, 253, 10, 7, 15, 116, 127, 5, 8, 12, 40, 16, 19, 54, 20, 9, 27, 255, 113, 17, 42, 67, 24, 23, 146, 148, 18, 14, 22, 45, 70, 69, 56, 114, 101, 21, 25, 63, 75, 136, 108, 28, 118, 29, 73, 115]);+ if (typeof WebAssembly != "object")+ return {+ supported: !1+ };+ var s = WebAssembly.validate(t) ? e : i, r, a = WebAssembly.instantiate(o(s), {}).then(function(p) {+ r = p.instance, r.exports.__wasm_call_ctors();+ });+ function o(p) {+ for (var y = new Uint8Array(p.length), b = 0; b < p.length; ++b) {+ var E = p.charCodeAt(b);+ y[b] = E > 96 ? E - 97 : E > 64 ? E - 39 : E + 4;+ }+ for (var M = 0, b = 0; b < p.length; ++b)+ y[M++] = y[b] < 60 ? n[y[b]] : (y[b] - 60) * 64 + y[++b];+ return y.buffer.slice(0, M);+ }+ function c(p, y, b, E, M, w) {+ var S = r.exports.sbrk, T = b + 3 & -4, C = S(T * E), v = S(M.length), F = new Uint8Array(r.exports.memory.buffer);+ F.set(M, v);+ var K = p(C, b, E, v, M.length);+ if (K == 0 && w && w(C, T, E), y.set(F.subarray(C, C + b * E)), S(C - S(0)), K != 0)+ throw new Error("Malformed buffer data: " + K);+ }+ var l = {+ NONE: "",+ OCTAHEDRAL: "meshopt_decodeFilterOct",+ QUATERNION: "meshopt_decodeFilterQuat",+ EXPONENTIAL: "meshopt_decodeFilterExp"+ }, h = {+ ATTRIBUTES: "meshopt_decodeVertexBuffer",+ TRIANGLES: "meshopt_decodeIndexBuffer",+ INDICES: "meshopt_decodeIndexSequence"+ }, u = [], d = 0;+ function f(p) {+ var y = {+ object: new Worker(p),+ pending: 0,+ requests: {}+ };+ return y.object.onmessage = function(b) {+ var E = b.data;+ y.pending -= E.count, y.requests[E.id][E.action](E.value), delete y.requests[E.id];+ }, y;+ }+ function m(p) {+ for (var y = "var instance; var ready = WebAssembly.instantiate(new Uint8Array([" + new Uint8Array(o(s)) + "]), {}).then(function(result) { instance = result.instance; instance.exports.__wasm_call_ctors(); });self.onmessage = workerProcess;" + c.toString() + g.toString(), b = new Blob([y], { type: "text/javascript" }), E = URL.createObjectURL(b), M = 0; M < p; ++M)+ u[M] = f(E);+ URL.revokeObjectURL(E);+ }+ function A(p, y, b, E, M) {+ for (var w = u[0], S = 1; S < u.length; ++S)+ u[S].pending < w.pending && (w = u[S]);+ return new Promise(function(T, C) {+ var v = new Uint8Array(b), F = d++;+ w.pending += p, w.requests[F] = { resolve: T, reject: C }, w.object.postMessage({ id: F, count: p, size: y, source: v, mode: E, filter: M }, [v.buffer]);+ });+ }+ function g(p) {+ a.then(function() {+ var y = p.data;+ try {+ var b = new Uint8Array(y.count * y.size);+ c(r.exports[y.mode], b, y.count, y.size, y.source, r.exports[y.filter]), self.postMessage({ id: y.id, count: y.count, action: "resolve", value: b }, [b.buffer]);+ } catch (E) {+ self.postMessage({ id: y.id, count: y.count, action: "reject", value: E });+ }+ });+ }+ return {+ ready: a,+ supported: !0,+ useWorkers: function(p) {+ m(p);+ },+ decodeVertexBuffer: function(p, y, b, E, M) {+ c(r.exports.meshopt_decodeVertexBuffer, p, y, b, E, r.exports[l[M]]);+ },+ decodeIndexBuffer: function(p, y, b, E) {+ c(r.exports.meshopt_decodeIndexBuffer, p, y, b, E);+ },+ decodeIndexSequence: function(p, y, b, E) {+ c(r.exports.meshopt_decodeIndexSequence, p, y, b, E);+ },+ decodeGltfBuffer: function(p, y, b, E, M, w) {+ c(r.exports[h[M]], p, y, b, E, r.exports[l[w]]);+ },+ decodeGltfBufferAsync: function(p, y, b, E, M) {+ return u.length > 0 ? A(p, y, b, h[E], l[M]) : a.then(function() {+ var w = new Uint8Array(p * y);+ return c(r.exports[h[E]], w, p, y, b, r.exports[l[M]]), w;+ });+ }+ };+})();+const w2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({+ __proto__: null,+ MeshoptDecoder: y2+}, Symbol.toStringTag, { value: "Module" }));+export {+ c_ as Agent3DElement,+ n2 as AgentStageElement,+ Ti as Memory,+ IT as Runtime,+ NT as SceneController,+ qT as Skill,+ KT as SkillRegistry,+ fb as Viewer,+ S2 as defineElement,+ DL as fetchRelative,+ BT as fetchWithFallback,+ ll as loadManifest,+ hf as normalize,+ Gs as resolveURI+};diff --git a/publish/agent-3d.umd.cjs b/publish/agent-3d.umd.cjsnew file mode 100644index 000000000..1b45cbb29--- /dev/null+++ b/publish/agent-3d.umd.cjs@@ -0,0 +1,4234 @@+(function(en,js){typeof exports=="object"&&typeof module<"u"?js(exports):typeof define=="function"&&define.amd?define(["exports"],js):(en=typeof globalThis<"u"?globalThis:en||self,js(en.Agent3D={}))})(this,(function(en){"use strict";var js=typeof document<"u"?document.currentScript:null;const dc="176",Lr={ROTATE:0,DOLLY:1,PAN:2},Pr={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},D_=0,gp=1,L_=2,mp=1,P_=2,Gi=3,Hi=0,In=1,Bi=2,bs=0,kr=1,bp=2,xp=3,_p=4,k_=5,Xs=100,U_=101,O_=102,Q_=103,G_=104,H_=200,z_=201,V_=202,W_=203,yh=204,wh=205,q_=206,K_=207,j_=208,X_=209,Y_=210,J_=211,Z_=212,$_=213,eE=214,vh=0,Ch=1,Sh=2,Ur=3,Ih=4,Mh=5,Bh=6,Th=7,Ep=0,tE=1,nE=2,xs=0,Rh=1,iE=2,sE=3,yp=4,rE=5,aE=6,oE=7,wp="attached",cE="detached",vp=300,Ys=301,Or=302,Nh=303,Fh=304,fc=306,Qr=1e3,ci=1001,pc=1002,Mn=1003,Cp=1004,Ka=1005,zt=1006,Ac=1007,Zn=1008,tn=1009,Sp=1010,Ip=1011,ja=1012,Dh=1013,Js=1014,nn=1015,Bn=1016,Lh=1017,Ph=1018,Xa=1020,Mp=35902,Bp=1021,Tp=1022,sn=1023,Ya=1026,Ja=1027,zi=1028,kh=1029,Zs=1030,Uh=1031,Oh=1033,gc=33776,Za=33777,mc=33778,$a=33779,bc=35840,Qh=35841,xc=35842,Gh=35843,_c=36196,Ec=37492,yc=37496,eo=37808,Hh=37809,zh=37810,Vh=37811,to=37812,Wh=37813,qh=37814,Kh=37815,jh=37816,Xh=37817,Yh=37818,Jh=37819,Zh=37820,$h=37821,no=36492,eu=36494,wc=36495,Rp=36283,tu=36284,nu=36285,iu=36286,Np=2200,Fp=2201,lE=2202,io=2300,so=2301,su=2302,Gr=2400,Hr=2401,vc=2402,ru=2500,hE=2501,uE=0,Dp=1,au=2,dE=3200,fE=3201,Lp=0,pE=1,li="",Kt="srgb",rn="srgb-linear",Cc="linear",Mt="srgb",zr=7680,Pp=519,AE=512,gE=513,mE=514,kp=515,bE=516,xE=517,_E=518,EE=519,ou=35044,Up="300 es",Vi=2e3,Sc=2001;class _s{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){const n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const n=this._listeners;if(n===void 0)return;const s=n[e];if(s!==void 0){const r=s.indexOf(t);r!==-1&&s.splice(r,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const n=t[e.type];if(n!==void 0){e.target=this;const s=n.slice(0);for(let r=0,a=s.length;r<a;r++)s[r].call(this,e);e.target=null}}}const wn=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let Op=1234567;const ro=Math.PI/180,Vr=180/Math.PI;function hi(){const i=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(wn[i&255]+wn[i>>8&255]+wn[i>>16&255]+wn[i>>24&255]+"-"+wn[e&255]+wn[e>>8&255]+"-"+wn[e>>16&15|64]+wn[e>>24&255]+"-"+wn[t&63|128]+wn[t>>8&255]+"-"+wn[t>>16&255]+wn[t>>24&255]+wn[n&255]+wn[n>>8&255]+wn[n>>16&255]+wn[n>>24&255]).toLowerCase()}function at(i,e,t){return Math.max(e,Math.min(t,i))}function cu(i,e){return(i%e+e)%e}function yE(i,e,t,n,s){return n+(i-e)*(s-n)/(t-e)}function wE(i,e,t){return i!==e?(t-i)/(e-i):0}function ao(i,e,t){return(1-t)*i+t*e}function vE(i,e,t,n){return ao(i,e,1-Math.exp(-t*n))}function CE(i,e=1){return e-Math.abs(cu(i,e*2)-e)}function SE(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*(3-2*i))}function IE(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*i*(i*(i*6-15)+10))}function ME(i,e){return i+Math.floor(Math.random()*(e-i+1))}function BE(i,e){return i+Math.random()*(e-i)}function TE(i){return i*(.5-Math.random())}function RE(i){i!==void 0&&(Op=i);let e=Op+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function NE(i){return i*ro}function FE(i){return i*Vr}function DE(i){return(i&i-1)===0&&i!==0}function LE(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function PE(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function kE(i,e,t,n,s){const r=Math.cos,a=Math.sin,o=r(t/2),c=a(t/2),l=r((e+n)/2),h=a((e+n)/2),u=r((e-n)/2),d=a((e-n)/2),f=r((n-e)/2),m=a((n-e)/2);switch(s){case"XYX":i.set(o*h,c*u,c*d,o*l);break;case"YZY":i.set(c*d,o*h,c*u,o*l);break;case"ZXZ":i.set(c*u,c*d,o*h,o*l);break;case"XZX":i.set(o*h,c*m,c*f,o*l);break;case"YXY":i.set(c*f,o*h,c*m,o*l);break;case"ZYZ":i.set(c*m,c*f,o*h,o*l);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function ui(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("Invalid component type.")}}function It(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("Invalid component type.")}}const Qp={DEG2RAD:ro,RAD2DEG:Vr,generateUUID:hi,clamp:at,euclideanModulo:cu,mapLinear:yE,inverseLerp:wE,lerp:ao,damp:vE,pingpong:CE,smoothstep:SE,smootherstep:IE,randInt:ME,randFloat:BE,randFloatSpread:TE,seededRandom:RE,degToRad:NE,radToDeg:FE,isPowerOfTwo:DE,ceilPowerOfTwo:LE,floorPowerOfTwo:PE,setQuaternionFromProperEuler:kE,normalize:It,denormalize:ui};class Ze{constructor(e=0,t=0){Ze.prototype.isVector2=!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 new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,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){const t=this.x,n=this.y,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6],this.y=s[1]*t+s[4]*n+s[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=at(this.x,e.x,t.x),this.y=at(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=at(this.x,e,t),this.y=at(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(at(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){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(at(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const 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){const n=Math.cos(t),s=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*n-a*s+e.x,this.y=r*s+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class rt{constructor(e,t,n,s,r,a,o,c,l){rt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,s,r,a,o,c,l)}set(e,t,n,s,r,a,o,c,l){const h=this.elements;return h[0]=e,h[1]=s,h[2]=o,h[3]=t,h[4]=r,h[5]=c,h[6]=n,h[7]=a,h[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const 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){const 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){const n=e.elements,s=t.elements,r=this.elements,a=n[0],o=n[3],c=n[6],l=n[1],h=n[4],u=n[7],d=n[2],f=n[5],m=n[8],A=s[0],g=s[3],p=s[6],y=s[1],b=s[4],E=s[7],M=s[2],w=s[5],S=s[8];return r[0]=a*A+o*y+c*M,r[3]=a*g+o*b+c*w,r[6]=a*p+o*E+c*S,r[1]=l*A+h*y+u*M,r[4]=l*g+h*b+u*w,r[7]=l*p+h*E+u*S,r[2]=d*A+f*y+m*M,r[5]=d*g+f*b+m*w,r[8]=d*p+f*E+m*S,this}multiplyScalar(e){const 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(){const e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],a=e[4],o=e[5],c=e[6],l=e[7],h=e[8];return t*a*h-t*o*l-n*r*h+n*o*c+s*r*l-s*a*c}invert(){const e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],a=e[4],o=e[5],c=e[6],l=e[7],h=e[8],u=h*a-o*l,d=o*c-h*r,f=l*r-a*c,m=t*u+n*d+s*f;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);const A=1/m;return e[0]=u*A,e[1]=(s*l-h*n)*A,e[2]=(o*n-s*a)*A,e[3]=d*A,e[4]=(h*t-s*c)*A,e[5]=(s*r-o*t)*A,e[6]=f*A,e[7]=(n*c-l*t)*A,e[8]=(a*t-n*r)*A,this}transpose(){let e;const 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){const 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,s,r,a,o){const c=Math.cos(r),l=Math.sin(r);return this.set(n*c,n*l,-n*(c*a+l*o)+a+e,-s*l,s*c,-s*(-l*a+c*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(lu.makeScale(e,t)),this}rotate(e){return this.premultiply(lu.makeRotation(-e)),this}translate(e,t){return this.premultiply(lu.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){const 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){const t=this.elements,n=e.elements;for(let s=0;s<9;s++)if(t[s]!==n[s])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){const 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)}}const lu=new rt;function Gp(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function oo(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function UE(){const i=oo("canvas");return i.style.display="block",i}const Hp={};function Ic(i){i in Hp||(Hp[i]=!0,console.warn(i))}function OE(i,e,t){return new Promise(function(n,s){function r(){switch(i.clientWaitSync(e,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:s();break;case i.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:n()}}setTimeout(r,t)})}function QE(i){const e=i.elements;e[2]=.5*e[2]+.5*e[3],e[6]=.5*e[6]+.5*e[7],e[10]=.5*e[10]+.5*e[11],e[14]=.5*e[14]+.5*e[15]}function GE(i){const e=i.elements;e[11]===-1?(e[10]=-e[10]-1,e[14]=-e[14]):(e[10]=-e[10],e[14]=-e[14]+1)}const zp=new rt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Vp=new rt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function HE(){const i={enabled:!0,workingColorSpace:rn,spaces:{},convert:function(s,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===Mt&&(s.r=Wi(s.r),s.g=Wi(s.g),s.b=Wi(s.b)),this.spaces[r].primaries!==this.spaces[a].primaries&&(s.applyMatrix3(this.spaces[r].toXYZ),s.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Mt&&(s.r=Wr(s.r),s.g=Wr(s.g),s.b=Wr(s.b))),s},fromWorkingColorSpace:function(s,r){return this.convert(s,this.workingColorSpace,r)},toWorkingColorSpace:function(s,r){return this.convert(s,r,this.workingColorSpace)},getPrimaries:function(s){return this.spaces[s].primaries},getTransfer:function(s){return s===li?Cc:this.spaces[s].transfer},getLuminanceCoefficients:function(s,r=this.workingColorSpace){return s.fromArray(this.spaces[r].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,r,a){return s.copy(this.spaces[r].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[rn]:{primaries:e,whitePoint:n,transfer:Cc,toXYZ:zp,fromXYZ:Vp,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Kt},outputColorSpaceConfig:{drawingBufferColorSpace:Kt}},[Kt]:{primaries:e,whitePoint:n,transfer:Mt,toXYZ:zp,fromXYZ:Vp,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Kt}}}),i}const At=HE();function Wi(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function Wr(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let qr;class zE{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{qr===void 0&&(qr=oo("canvas")),qr.width=e.width,qr.height=e.height;const s=qr.getContext("2d");e instanceof ImageData?s.putImageData(e,0,0):s.drawImage(e,0,0,e.width,e.height),n=qr}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){const t=oo("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const s=n.getImageData(0,0,e.width,e.height),r=s.data;for(let a=0;a<r.length;a++)r[a]=Wi(r[a]/255)*255;return n.putImageData(s,0,0),t}else if(e.data){const t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(Wi(t[n]/255)*255):t[n]=Wi(t[n]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let VE=0;class hu{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:VE++}),this.uuid=hi(),this.data=e,this.dataReady=!0,this.version=0}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const n={uuid:this.uuid,url:""},s=this.data;if(s!==null){let r;if(Array.isArray(s)){r=[];for(let a=0,o=s.length;a<o;a++)s[a].isDataTexture?r.push(uu(s[a].image)):r.push(uu(s[a]))}else r=uu(s);n.url=r}return t||(e.images[this.uuid]=n),n}}function uu(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?zE.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let WE=0;class an extends _s{constructor(e=an.DEFAULT_IMAGE,t=an.DEFAULT_MAPPING,n=ci,s=ci,r=zt,a=Zn,o=sn,c=tn,l=an.DEFAULT_ANISOTROPY,h=li){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:WE++}),this.uuid=hi(),this.name="",this.source=new hu(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=s,this.magFilter=r,this.minFilter=a,this.anisotropy=l,this.format=o,this.internalFormat=null,this.type=c,this.offset=new Ze(0,0),this.repeat=new Ze(1,1),this.center=new Ze(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new rt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isTextureArray=!1,this.pmremVersion=0}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isTextureArray=e.isTextureArray,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const n={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==vp)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Qr:e.x=e.x-Math.floor(e.x);break;case ci:e.x=e.x<0?0:1;break;case pc:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Qr:e.y=e.y-Math.floor(e.y);break;case ci:e.y=e.y<0?0:1;break;case pc:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}an.DEFAULT_IMAGE=null,an.DEFAULT_MAPPING=vp,an.DEFAULT_ANISOTROPY=1;class Et{constructor(e=0,t=0,n=0,s=1){Et.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=s}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,s){return this.x=e,this.y=t,this.z=n,this.w=s,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 new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,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){const t=this.x,n=this.y,s=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*s+a[12]*r,this.y=a[1]*t+a[5]*n+a[9]*s+a[13]*r,this.z=a[2]*t+a[6]*n+a[10]*s+a[14]*r,this.w=a[3]*t+a[7]*n+a[11]*s+a[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const 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,s,r;const c=e.elements,l=c[0],h=c[4],u=c[8],d=c[1],f=c[5],m=c[9],A=c[2],g=c[6],p=c[10];if(Math.abs(h-d)<.01&&Math.abs(u-A)<.01&&Math.abs(m-g)<.01){if(Math.abs(h+d)<.1&&Math.abs(u+A)<.1&&Math.abs(m+g)<.1&&Math.abs(l+f+p-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const b=(l+1)/2,E=(f+1)/2,M=(p+1)/2,w=(h+d)/4,S=(u+A)/4,T=(m+g)/4;return b>E&&b>M?b<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(b),s=w/n,r=S/n):E>M?E<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(E),n=w/s,r=T/s):M<.01?(n=.707106781,s=.707106781,r=0):(r=Math.sqrt(M),n=S/r,s=T/r),this.set(n,s,r,t),this}let y=Math.sqrt((g-m)*(g-m)+(u-A)*(u-A)+(d-h)*(d-h));return Math.abs(y)<.001&&(y=1),this.x=(g-m)/y,this.y=(u-A)/y,this.z=(d-h)/y,this.w=Math.acos((l+f+p-1)/2),this}setFromMatrixPosition(e){const 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=at(this.x,e.x,t.x),this.y=at(this.y,e.y,t.y),this.z=at(this.z,e.z,t.z),this.w=at(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=at(this.x,e,t),this.y=at(this.y,e,t),this.z=at(this.z,e,t),this.w=at(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(at(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}}class qE extends _s{constructor(e=1,t=1,n={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth?n.depth:1,this.scissor=new Et(0,0,e,t),this.scissorTest=!1,this.viewport=new Et(0,0,e,t);const s={width:e,height:t,depth:this.depth};n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:zt,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,multiview:!1},n);const r=new an(s,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace);r.flipY=!1,r.generateMipmaps=n.generateMipmaps,r.internalFormat=n.internalFormat,this.textures=[];const a=n.count;for(let o=0;o<a;o++)this.textures[o]=r.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let s=0,r=this.textures.length;s<r;s++)this.textures[s].image.width=e,this.textures[s].image.height=t,this.textures[s].image.depth=n;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;const s=Object.assign({},e.textures[t].image);this.textures[t].source=new hu(s)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class $s extends qE{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class Wp extends an{constructor(e=null,t=1,n=1,s=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:s},this.magFilter=Mn,this.minFilter=Mn,this.wrapR=ci,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class qp extends an{constructor(e=null,t=1,n=1,s=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:s},this.magFilter=Mn,this.minFilter=Mn,this.wrapR=ci,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Wn{constructor(e=0,t=0,n=0,s=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=s}static slerpFlat(e,t,n,s,r,a,o){let c=n[s+0],l=n[s+1],h=n[s+2],u=n[s+3];const d=r[a+0],f=r[a+1],m=r[a+2],A=r[a+3];if(o===0){e[t+0]=c,e[t+1]=l,e[t+2]=h,e[t+3]=u;return}if(o===1){e[t+0]=d,e[t+1]=f,e[t+2]=m,e[t+3]=A;return}if(u!==A||c!==d||l!==f||h!==m){let g=1-o;const p=c*d+l*f+h*m+u*A,y=p>=0?1:-1,b=1-p*p;if(b>Number.EPSILON){const M=Math.sqrt(b),w=Math.atan2(M,p*y);g=Math.sin(g*w)/M,o=Math.sin(o*w)/M}const E=o*y;if(c=c*g+d*E,l=l*g+f*E,h=h*g+m*E,u=u*g+A*E,g===1-o){const M=1/Math.sqrt(c*c+l*l+h*h+u*u);c*=M,l*=M,h*=M,u*=M}}e[t]=c,e[t+1]=l,e[t+2]=h,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,s,r,a){const o=n[s],c=n[s+1],l=n[s+2],h=n[s+3],u=r[a],d=r[a+1],f=r[a+2],m=r[a+3];return e[t]=o*m+h*u+c*f-l*d,e[t+1]=c*m+h*d+l*u-o*f,e[t+2]=l*m+h*f+o*d-c*u,e[t+3]=h*m-o*u-c*d-l*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,s){return this._x=e,this._y=t,this._z=n,this._w=s,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){const n=e._x,s=e._y,r=e._z,a=e._order,o=Math.cos,c=Math.sin,l=o(n/2),h=o(s/2),u=o(r/2),d=c(n/2),f=c(s/2),m=c(r/2);switch(a){case"XYZ":this._x=d*h*u+l*f*m,this._y=l*f*u-d*h*m,this._z=l*h*m+d*f*u,this._w=l*h*u-d*f*m;break;case"YXZ":this._x=d*h*u+l*f*m,this._y=l*f*u-d*h*m,this._z=l*h*m-d*f*u,this._w=l*h*u+d*f*m;break;case"ZXY":this._x=d*h*u-l*f*m,this._y=l*f*u+d*h*m,this._z=l*h*m+d*f*u,this._w=l*h*u-d*f*m;break;case"ZYX":this._x=d*h*u-l*f*m,this._y=l*f*u+d*h*m,this._z=l*h*m-d*f*u,this._w=l*h*u+d*f*m;break;case"YZX":this._x=d*h*u+l*f*m,this._y=l*f*u+d*h*m,this._z=l*h*m-d*f*u,this._w=l*h*u-d*f*m;break;case"XZY":this._x=d*h*u-l*f*m,this._y=l*f*u-d*h*m,this._z=l*h*m+d*f*u,this._w=l*h*u+d*f*m;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,s=Math.sin(n);return this._x=e.x*s,this._y=e.y*s,this._z=e.z*s,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],s=t[4],r=t[8],a=t[1],o=t[5],c=t[9],l=t[2],h=t[6],u=t[10],d=n+o+u;if(d>0){const f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(h-c)*f,this._y=(r-l)*f,this._z=(a-s)*f}else if(n>o&&n>u){const f=2*Math.sqrt(1+n-o-u);this._w=(h-c)/f,this._x=.25*f,this._y=(s+a)/f,this._z=(r+l)/f}else if(o>u){const f=2*Math.sqrt(1+o-n-u);this._w=(r-l)/f,this._x=(s+a)/f,this._y=.25*f,this._z=(c+h)/f}else{const f=2*Math.sqrt(1+u-n-o);this._w=(a-s)/f,this._x=(r+l)/f,this._y=(c+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<Number.EPSILON?(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(at(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const s=Math.min(1,t/n);return this.slerp(e,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,s=e._y,r=e._z,a=e._w,o=t._x,c=t._y,l=t._z,h=t._w;return this._x=n*h+a*o+s*l-r*c,this._y=s*h+a*c+r*o-n*l,this._z=r*h+a*l+n*c-s*o,this._w=a*h-n*o-s*c-r*l,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const n=this._x,s=this._y,r=this._z,a=this._w;let o=a*e._w+n*e._x+s*e._y+r*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=n,this._y=s,this._z=r,this;const c=1-o*o;if(c<=Number.EPSILON){const f=1-t;return this._w=f*a+t*this._w,this._x=f*n+t*this._x,this._y=f*s+t*this._y,this._z=f*r+t*this._z,this.normalize(),this}const l=Math.sqrt(c),h=Math.atan2(l,o),u=Math.sin((1-t)*h)/l,d=Math.sin(t*h)/l;return this._w=a*u+this._w*d,this._x=n*u+this._x*d,this._y=s*u+this._y*d,this._z=r*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),s=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(s*Math.sin(e),s*Math.cos(e),r*Math.sin(t),r*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}}class H{constructor(e=0,t=0,n=0){H.prototype.isVector3=!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 new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,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(Kp.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Kp.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*s,this.y=r[1]*t+r[4]*n+r[7]*s,this.z=r[2]*t+r[5]*n+r[8]*s,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,s=this.z,r=e.elements,a=1/(r[3]*t+r[7]*n+r[11]*s+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*s+r[12])*a,this.y=(r[1]*t+r[5]*n+r[9]*s+r[13])*a,this.z=(r[2]*t+r[6]*n+r[10]*s+r[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,s=this.z,r=e.x,a=e.y,o=e.z,c=e.w,l=2*(a*s-o*n),h=2*(o*t-r*s),u=2*(r*n-a*t);return this.x=t+c*l+a*u-o*h,this.y=n+c*h+o*l-r*u,this.z=s+c*u+r*h-a*l,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*s,this.y=r[1]*t+r[5]*n+r[9]*s,this.z=r[2]*t+r[6]*n+r[10]*s,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=at(this.x,e.x,t.x),this.y=at(this.y,e.y,t.y),this.z=at(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=at(this.x,e,t),this.y=at(this.y,e,t),this.z=at(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(at(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){const n=e.x,s=e.y,r=e.z,a=t.x,o=t.y,c=t.z;return this.x=s*c-r*o,this.y=r*a-n*c,this.z=n*o-s*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return du.copy(this).projectOnVector(e),this.sub(du)}reflect(e){return this.sub(du.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(at(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,s=this.z-e.z;return t*t+n*n+s*s}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){const s=Math.sin(t)*e;return this.x=s*Math.sin(n),this.y=Math.cos(t)*e,this.z=s*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){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),s=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=s,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(){const 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}}const du=new H,Kp=new Wn;class di{constructor(e=new H(1/0,1/0,1/0),t=new H(-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(fi.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(fi.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){const n=fi.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);const n=e.geometry;if(n!==void 0){const r=n.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=r.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,fi):fi.fromBufferAttribute(r,a),fi.applyMatrix4(e.matrixWorld),this.expandByPoint(fi);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Mc.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),Mc.copy(n.boundingBox)),Mc.applyMatrix4(e.matrixWorld),this.union(Mc)}const s=e.children;for(let r=0,a=s.length;r<a;r++)this.expandByObject(s[r],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,fi),fi.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(co),Bc.subVectors(this.max,co),Kr.subVectors(e.a,co),jr.subVectors(e.b,co),Xr.subVectors(e.c,co),Es.subVectors(jr,Kr),ys.subVectors(Xr,jr),er.subVectors(Kr,Xr);let t=[0,-Es.z,Es.y,0,-ys.z,ys.y,0,-er.z,er.y,Es.z,0,-Es.x,ys.z,0,-ys.x,er.z,0,-er.x,-Es.y,Es.x,0,-ys.y,ys.x,0,-er.y,er.x,0];return!fu(t,Kr,jr,Xr,Bc)||(t=[1,0,0,0,1,0,0,0,1],!fu(t,Kr,jr,Xr,Bc))?!1:(Tc.crossVectors(Es,ys),t=[Tc.x,Tc.y,Tc.z],fu(t,Kr,jr,Xr,Bc))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,fi).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(fi).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(qi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),qi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),qi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),qi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),qi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),qi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),qi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),qi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(qi),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const qi=[new H,new H,new H,new H,new H,new H,new H,new H],fi=new H,Mc=new di,Kr=new H,jr=new H,Xr=new H,Es=new H,ys=new H,er=new H,co=new H,Bc=new H,Tc=new H,tr=new H;function fu(i,e,t,n,s){for(let r=0,a=i.length-3;r<=a;r+=3){tr.fromArray(i,r);const o=s.x*Math.abs(tr.x)+s.y*Math.abs(tr.y)+s.z*Math.abs(tr.z),c=e.dot(tr),l=t.dot(tr),h=n.dot(tr);if(Math.max(-Math.max(c,l,h),Math.min(c,l,h))>o)return!1}return!0}const KE=new di,lo=new H,pu=new H;class Ti{constructor(e=new H,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){const n=this.center;t!==void 0?n.copy(t):KE.setFromPoints(e).getCenter(n);let s=0;for(let r=0,a=e.length;r<a;r++)s=Math.max(s,n.distanceToSquared(e[r]));return this.radius=Math.sqrt(s),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const 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){const 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=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;lo.subVectors(e,this.center);const t=lo.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),s=(n-this.radius)*.5;this.center.addScaledVector(lo,s/n),this.radius+=s}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):(pu.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(lo.copy(e.center).add(pu)),this.expandByPoint(lo.copy(e.center).sub(pu))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const Ki=new H,Au=new H,Rc=new H,ws=new H,gu=new H,Nc=new H,mu=new H;class ho{constructor(e=new H,t=new H(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,Ki)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const 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){const t=Ki.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Ki.copy(this.origin).addScaledVector(this.direction,t),Ki.distanceToSquared(e))}distanceSqToSegment(e,t,n,s){Au.copy(e).add(t).multiplyScalar(.5),Rc.copy(t).sub(e).normalize(),ws.copy(this.origin).sub(Au);const r=e.distanceTo(t)*.5,a=-this.direction.dot(Rc),o=ws.dot(this.direction),c=-ws.dot(Rc),l=ws.lengthSq(),h=Math.abs(1-a*a);let u,d,f,m;if(h>0)if(u=a*c-o,d=a*o-c,m=r*h,u>=0)if(d>=-m)if(d<=m){const A=1/h;u*=A,d*=A,f=u*(u+a*d+2*o)+d*(a*u+d+2*c)+l}else d=r,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*c)+l;else d=-r,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*c)+l;else d<=-m?(u=Math.max(0,-(-a*r+o)),d=u>0?-r:Math.min(Math.max(-r,-c),r),f=-u*u+d*(d+2*c)+l):d<=m?(u=0,d=Math.min(Math.max(-r,-c),r),f=d*(d+2*c)+l):(u=Math.max(0,-(a*r+o)),d=u>0?r:Math.min(Math.max(-r,-c),r),f=-u*u+d*(d+2*c)+l);else d=a>0?-r:r,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*c)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,u),s&&s.copy(Au).addScaledVector(Rc,d),f}intersectSphere(e,t){Ki.subVectors(e.center,this.origin);const n=Ki.dot(this.direction),s=Ki.dot(Ki)-n*n,r=e.radius*e.radius;if(s>r)return null;const a=Math.sqrt(r-s),o=n-a,c=n+a;return c<0?null:o<0?this.at(c,t):this.at(o,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,s,r,a,o,c;const l=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return l>=0?(n=(e.min.x-d.x)*l,s=(e.max.x-d.x)*l):(n=(e.max.x-d.x)*l,s=(e.min.x-d.x)*l),h>=0?(r=(e.min.y-d.y)*h,a=(e.max.y-d.y)*h):(r=(e.max.y-d.y)*h,a=(e.min.y-d.y)*h),n>a||r>s||((r>n||isNaN(n))&&(n=r),(a<s||isNaN(s))&&(s=a),u>=0?(o=(e.min.z-d.z)*u,c=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,c=(e.min.z-d.z)*u),n>c||o>s)||((o>n||n!==n)&&(n=o),(c<s||s!==s)&&(s=c),s<0)?null:this.at(n>=0?n:s,t)}intersectsBox(e){return this.intersectBox(e,Ki)!==null}intersectTriangle(e,t,n,s,r){gu.subVectors(t,e),Nc.subVectors(n,e),mu.crossVectors(gu,Nc);let a=this.direction.dot(mu),o;if(a>0){if(s)return null;o=1}else if(a<0)o=-1,a=-a;else return null;ws.subVectors(this.origin,e);const c=o*this.direction.dot(Nc.crossVectors(ws,Nc));if(c<0)return null;const l=o*this.direction.dot(gu.cross(ws));if(l<0||c+l>a)return null;const h=-o*ws.dot(mu);return h<0?null:this.at(h/a,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class $e{constructor(e,t,n,s,r,a,o,c,l,h,u,d,f,m,A,g){$e.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,s,r,a,o,c,l,h,u,d,f,m,A,g)}set(e,t,n,s,r,a,o,c,l,h,u,d,f,m,A,g){const p=this.elements;return p[0]=e,p[4]=t,p[8]=n,p[12]=s,p[1]=r,p[5]=a,p[9]=o,p[13]=c,p[2]=l,p[6]=h,p[10]=u,p[14]=d,p[3]=f,p[7]=m,p[11]=A,p[15]=g,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new $e().fromArray(this.elements)}copy(e){const 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){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const 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 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){const t=this.elements,n=e.elements,s=1/Yr.setFromMatrixColumn(e,0).length(),r=1/Yr.setFromMatrixColumn(e,1).length(),a=1/Yr.setFromMatrixColumn(e,2).length();return t[0]=n[0]*s,t[1]=n[1]*s,t[2]=n[2]*s,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,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){const t=this.elements,n=e.x,s=e.y,r=e.z,a=Math.cos(n),o=Math.sin(n),c=Math.cos(s),l=Math.sin(s),h=Math.cos(r),u=Math.sin(r);if(e.order==="XYZ"){const d=a*h,f=a*u,m=o*h,A=o*u;t[0]=c*h,t[4]=-c*u,t[8]=l,t[1]=f+m*l,t[5]=d-A*l,t[9]=-o*c,t[2]=A-d*l,t[6]=m+f*l,t[10]=a*c}else if(e.order==="YXZ"){const d=c*h,f=c*u,m=l*h,A=l*u;t[0]=d+A*o,t[4]=m*o-f,t[8]=a*l,t[1]=a*u,t[5]=a*h,t[9]=-o,t[2]=f*o-m,t[6]=A+d*o,t[10]=a*c}else if(e.order==="ZXY"){const d=c*h,f=c*u,m=l*h,A=l*u;t[0]=d-A*o,t[4]=-a*u,t[8]=m+f*o,t[1]=f+m*o,t[5]=a*h,t[9]=A-d*o,t[2]=-a*l,t[6]=o,t[10]=a*c}else if(e.order==="ZYX"){const d=a*h,f=a*u,m=o*h,A=o*u;t[0]=c*h,t[4]=m*l-f,t[8]=d*l+A,t[1]=c*u,t[5]=A*l+d,t[9]=f*l-m,t[2]=-l,t[6]=o*c,t[10]=a*c}else if(e.order==="YZX"){const d=a*c,f=a*l,m=o*c,A=o*l;t[0]=c*h,t[4]=A-d*u,t[8]=m*u+f,t[1]=u,t[5]=a*h,t[9]=-o*h,t[2]=-l*h,t[6]=f*u+m,t[10]=d-A*u}else if(e.order==="XZY"){const d=a*c,f=a*l,m=o*c,A=o*l;t[0]=c*h,t[4]=-u,t[8]=l*h,t[1]=d*u+A,t[5]=a*h,t[9]=f*u-m,t[2]=m*u-f,t[6]=o*h,t[10]=A*u+d}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(jE,e,XE)}lookAt(e,t,n){const s=this.elements;return qn.subVectors(e,t),qn.lengthSq()===0&&(qn.z=1),qn.normalize(),vs.crossVectors(n,qn),vs.lengthSq()===0&&(Math.abs(n.z)===1?qn.x+=1e-4:qn.z+=1e-4,qn.normalize(),vs.crossVectors(n,qn)),vs.normalize(),Fc.crossVectors(qn,vs),s[0]=vs.x,s[4]=Fc.x,s[8]=qn.x,s[1]=vs.y,s[5]=Fc.y,s[9]=qn.y,s[2]=vs.z,s[6]=Fc.z,s[10]=qn.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,s=t.elements,r=this.elements,a=n[0],o=n[4],c=n[8],l=n[12],h=n[1],u=n[5],d=n[9],f=n[13],m=n[2],A=n[6],g=n[10],p=n[14],y=n[3],b=n[7],E=n[11],M=n[15],w=s[0],S=s[4],T=s[8],C=s[12],v=s[1],F=s[5],K=s[9],q=s[13],$=s[2],D=s[6],O=s[10],Y=s[14],Q=s[3],J=s[7],ee=s[11],ae=s[15];return r[0]=a*w+o*v+c*$+l*Q,r[4]=a*S+o*F+c*D+l*J,r[8]=a*T+o*K+c*O+l*ee,r[12]=a*C+o*q+c*Y+l*ae,r[1]=h*w+u*v+d*$+f*Q,r[5]=h*S+u*F+d*D+f*J,r[9]=h*T+u*K+d*O+f*ee,r[13]=h*C+u*q+d*Y+f*ae,r[2]=m*w+A*v+g*$+p*Q,r[6]=m*S+A*F+g*D+p*J,r[10]=m*T+A*K+g*O+p*ee,r[14]=m*C+A*q+g*Y+p*ae,r[3]=y*w+b*v+E*$+M*Q,r[7]=y*S+b*F+E*D+M*J,r[11]=y*T+b*K+E*O+M*ee,r[15]=y*C+b*q+E*Y+M*ae,this}multiplyScalar(e){const 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(){const e=this.elements,t=e[0],n=e[4],s=e[8],r=e[12],a=e[1],o=e[5],c=e[9],l=e[13],h=e[2],u=e[6],d=e[10],f=e[14],m=e[3],A=e[7],g=e[11],p=e[15];return m*(+r*c*u-s*l*u-r*o*d+n*l*d+s*o*f-n*c*f)+A*(+t*c*f-t*l*d+r*a*d-s*a*f+s*l*h-r*c*h)+g*(+t*l*u-t*o*f-r*a*u+n*a*f+r*o*h-n*l*h)+p*(-s*o*h-t*c*u+t*o*d+s*a*u-n*a*d+n*c*h)}transpose(){const e=this.elements;let 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){const s=this.elements;return e.isVector3?(s[12]=e.x,s[13]=e.y,s[14]=e.z):(s[12]=e,s[13]=t,s[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],a=e[4],o=e[5],c=e[6],l=e[7],h=e[8],u=e[9],d=e[10],f=e[11],m=e[12],A=e[13],g=e[14],p=e[15],y=u*g*l-A*d*l+A*c*f-o*g*f-u*c*p+o*d*p,b=m*d*l-h*g*l-m*c*f+a*g*f+h*c*p-a*d*p,E=h*A*l-m*u*l+m*o*f-a*A*f-h*o*p+a*u*p,M=m*u*c-h*A*c-m*o*d+a*A*d+h*o*g-a*u*g,w=t*y+n*b+s*E+r*M;if(w===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const S=1/w;return e[0]=y*S,e[1]=(A*d*r-u*g*r-A*s*f+n*g*f+u*s*p-n*d*p)*S,e[2]=(o*g*r-A*c*r+A*s*l-n*g*l-o*s*p+n*c*p)*S,e[3]=(u*c*r-o*d*r-u*s*l+n*d*l+o*s*f-n*c*f)*S,e[4]=b*S,e[5]=(h*g*r-m*d*r+m*s*f-t*g*f-h*s*p+t*d*p)*S,e[6]=(m*c*r-a*g*r-m*s*l+t*g*l+a*s*p-t*c*p)*S,e[7]=(a*d*r-h*c*r+h*s*l-t*d*l-a*s*f+t*c*f)*S,e[8]=E*S,e[9]=(m*u*r-h*A*r-m*n*f+t*A*f+h*n*p-t*u*p)*S,e[10]=(a*A*r-m*o*r+m*n*l-t*A*l-a*n*p+t*o*p)*S,e[11]=(h*o*r-a*u*r-h*n*l+t*u*l+a*n*f-t*o*f)*S,e[12]=M*S,e[13]=(h*A*s-m*u*s+m*n*d-t*A*d-h*n*g+t*u*g)*S,e[14]=(m*o*s-a*A*s-m*n*c+t*A*c+a*n*g-t*o*g)*S,e[15]=(a*u*s-h*o*s+h*n*c-t*u*c-a*n*d+t*o*d)*S,this}scale(e){const t=this.elements,n=e.x,s=e.y,r=e.z;return t[0]*=n,t[4]*=s,t[8]*=r,t[1]*=n,t[5]*=s,t[9]*=r,t[2]*=n,t[6]*=s,t[10]*=r,t[3]*=n,t[7]*=s,t[11]*=r,this}getMaxScaleOnAxis(){const 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],s=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,s))}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){const 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){const 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){const 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){const n=Math.cos(t),s=Math.sin(t),r=1-n,a=e.x,o=e.y,c=e.z,l=r*a,h=r*o;return this.set(l*a+n,l*o-s*c,l*c+s*o,0,l*o+s*c,h*o+n,h*c-s*a,0,l*c-s*o,h*c+s*a,r*c*c+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,s,r,a){return this.set(1,n,r,0,e,1,a,0,t,s,1,0,0,0,0,1),this}compose(e,t,n){const s=this.elements,r=t._x,a=t._y,o=t._z,c=t._w,l=r+r,h=a+a,u=o+o,d=r*l,f=r*h,m=r*u,A=a*h,g=a*u,p=o*u,y=c*l,b=c*h,E=c*u,M=n.x,w=n.y,S=n.z;return s[0]=(1-(A+p))*M,s[1]=(f+E)*M,s[2]=(m-b)*M,s[3]=0,s[4]=(f-E)*w,s[5]=(1-(d+p))*w,s[6]=(g+y)*w,s[7]=0,s[8]=(m+b)*S,s[9]=(g-y)*S,s[10]=(1-(d+A))*S,s[11]=0,s[12]=e.x,s[13]=e.y,s[14]=e.z,s[15]=1,this}decompose(e,t,n){const s=this.elements;let r=Yr.set(s[0],s[1],s[2]).length();const a=Yr.set(s[4],s[5],s[6]).length(),o=Yr.set(s[8],s[9],s[10]).length();this.determinant()<0&&(r=-r),e.x=s[12],e.y=s[13],e.z=s[14],pi.copy(this);const l=1/r,h=1/a,u=1/o;return pi.elements[0]*=l,pi.elements[1]*=l,pi.elements[2]*=l,pi.elements[4]*=h,pi.elements[5]*=h,pi.elements[6]*=h,pi.elements[8]*=u,pi.elements[9]*=u,pi.elements[10]*=u,t.setFromRotationMatrix(pi),n.x=r,n.y=a,n.z=o,this}makePerspective(e,t,n,s,r,a,o=Vi){const c=this.elements,l=2*r/(t-e),h=2*r/(n-s),u=(t+e)/(t-e),d=(n+s)/(n-s);let f,m;if(o===Vi)f=-(a+r)/(a-r),m=-2*a*r/(a-r);else if(o===Sc)f=-a/(a-r),m=-a*r/(a-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=l,c[4]=0,c[8]=u,c[12]=0,c[1]=0,c[5]=h,c[9]=d,c[13]=0,c[2]=0,c[6]=0,c[10]=f,c[14]=m,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,s,r,a,o=Vi){const c=this.elements,l=1/(t-e),h=1/(n-s),u=1/(a-r),d=(t+e)*l,f=(n+s)*h;let m,A;if(o===Vi)m=(a+r)*u,A=-2*u;else if(o===Sc)m=r*u,A=-1*u;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=2*l,c[4]=0,c[8]=0,c[12]=-d,c[1]=0,c[5]=2*h,c[9]=0,c[13]=-f,c[2]=0,c[6]=0,c[10]=A,c[14]=-m,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let s=0;s<16;s++)if(t[s]!==n[s])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){const 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}}const Yr=new H,pi=new $e,jE=new H(0,0,0),XE=new H(1,1,1),vs=new H,Fc=new H,qn=new H,jp=new $e,Xp=new Wn;class Ri{constructor(e=0,t=0,n=0,s=Ri.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=s}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,s=this._order){return this._x=e,this._y=t,this._z=n,this._order=s,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){const s=e.elements,r=s[0],a=s[4],o=s[8],c=s[1],l=s[5],h=s[9],u=s[2],d=s[6],f=s[10];switch(t){case"XYZ":this._y=Math.asin(at(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,f),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-at(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-u,r),this._z=0);break;case"ZXY":this._x=Math.asin(at(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(c,r));break;case"ZYX":this._y=Math.asin(-at(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(c,r)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(at(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-u,r)):(this._x=0,this._y=Math.atan2(o,f));break;case"XZY":this._z=Math.asin(-at(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-h,f),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return jp.makeRotationFromQuaternion(e),this.setFromRotationMatrix(jp,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Xp.setFromEuler(this),this.setFromQuaternion(Xp,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}}Ri.DEFAULT_ORDER="XYZ";class Yp{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let YE=0;const Jp=new H,Jr=new Wn,ji=new $e,Dc=new H,uo=new H,JE=new H,ZE=new Wn,Zp=new H(1,0,0),$p=new H(0,1,0),eA=new H(0,0,1),tA={type:"added"},$E={type:"removed"},Zr={type:"childadded",child:null},bu={type:"childremoved",child:null};class Pt extends _s{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:YE++}),this.uuid=hi(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Pt.DEFAULT_UP.clone();const e=new H,t=new Ri,n=new Wn,s=new H(1,1,1);function r(){n.setFromEuler(t,!1)}function a(){t.setFromQuaternion(n,void 0,!1)}t._onChange(r),n._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:s},modelViewMatrix:{value:new $e},normalMatrix:{value:new rt}}),this.matrix=new $e,this.matrixWorld=new $e,this.matrixAutoUpdate=Pt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Pt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Yp,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.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,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 Jr.setFromAxisAngle(e,t),this.quaternion.multiply(Jr),this}rotateOnWorldAxis(e,t){return Jr.setFromAxisAngle(e,t),this.quaternion.premultiply(Jr),this}rotateX(e){return this.rotateOnAxis(Zp,e)}rotateY(e){return this.rotateOnAxis($p,e)}rotateZ(e){return this.rotateOnAxis(eA,e)}translateOnAxis(e,t){return Jp.copy(e).applyQuaternion(this.quaternion),this.position.add(Jp.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Zp,e)}translateY(e){return this.translateOnAxis($p,e)}translateZ(e){return this.translateOnAxis(eA,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(ji.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Dc.copy(e):Dc.set(e,t,n);const s=this.parent;this.updateWorldMatrix(!0,!1),uo.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?ji.lookAt(uo,Dc,this.up):ji.lookAt(Dc,uo,this.up),this.quaternion.setFromRotationMatrix(ji),s&&(ji.extractRotation(s.matrixWorld),Jr.setFromRotationMatrix(ji),this.quaternion.premultiply(Jr.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(tA),Zr.child=e,this.dispatchEvent(Zr),Zr.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent($E),bu.child=e,this.dispatchEvent(bu),bu.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),ji.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),ji.multiply(e.parent.matrixWorld)),e.applyMatrix4(ji),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(tA),Zr.child=e,this.dispatchEvent(Zr),Zr.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,s=this.children.length;n<s;n++){const a=this.children[n].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);const s=this.children;for(let r=0,a=s.length;r<a;r++)s[r].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(uo,e,JE),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(uo,ZE,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let n=0,s=t.length;n<s;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let n=0,s=t.length;n<s;n++)t[n].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let n=0,s=t.length;n<s;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t){const n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){const s=this.children;for(let r=0,a=s.length;r<a;r++)s[r].updateWorldMatrix(!1,!0)}}toJSON(e){const t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const s={};s.uuid=this.uuid,s.type=this.type,this.name!==""&&(s.name=this.name),this.castShadow===!0&&(s.castShadow=!0),this.receiveShadow===!0&&(s.receiveShadow=!0),this.visible===!1&&(s.visible=!1),this.frustumCulled===!1&&(s.frustumCulled=!1),this.renderOrder!==0&&(s.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?{min:o.boundingBox.min.toArray(),max:o.boundingBox.max.toArray()}:void 0,boundingSphere:o.boundingSphere?{radius:o.boundingSphere.radius,center:o.boundingSphere.center.toArray()}:void 0})),s.instanceInfo=this._instanceInfo.map(o=>({...o})),s.availableInstanceIds=this._availableInstanceIds.slice(),s.availableGeometryIds=this._availableGeometryIds.slice(),s.nextIndexStart=this._nextIndexStart,s.nextVertexStart=this._nextVertexStart,s.geometryCount=this._geometryCount,s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.matricesTexture=this._matricesTexture.toJSON(e),s.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(s.boundingSphere={center:this.boundingSphere.center.toArray(),radius:this.boundingSphere.radius}),this.boundingBox!==null&&(s.boundingBox={min:this.boundingBox.min.toArray(),max:this.boundingBox.max.toArray()}));function r(o,c){return o[c.uuid]===void 0&&(o[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const c=o.shapes;if(Array.isArray(c))for(let l=0,h=c.length;l<h;l++){const u=c[l];r(e.shapes,u)}else r(e.shapes,c)}}if(this.isSkinnedMesh&&(s.bindMode=this.bindMode,s.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(e.skeletons,this.skeleton),s.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let c=0,l=this.material.length;c<l;c++)o.push(r(e.materials,this.material[c]));s.material=o}else s.material=r(e.materials,this.material);if(this.children.length>0){s.children=[];for(let o=0;o<this.children.length;o++)s.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){s.animations=[];for(let o=0;o<this.animations.length;o++){const c=this.animations[o];s.animations.push(r(e.animations,c))}}if(t){const o=a(e.geometries),c=a(e.materials),l=a(e.textures),h=a(e.images),u=a(e.shapes),d=a(e.skeletons),f=a(e.animations),m=a(e.nodes);o.length>0&&(n.geometries=o),c.length>0&&(n.materials=c),l.length>0&&(n.textures=l),h.length>0&&(n.images=h),u.length>0&&(n.shapes=u),d.length>0&&(n.skeletons=d),f.length>0&&(n.animations=f),m.length>0&&(n.nodes=m)}return n.object=s,n;function a(o){const c=[];for(const l in o){const h=o[l];delete h.metadata,c.push(h)}return c}}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.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){const s=e.children[n];this.add(s.clone())}return this}}Pt.DEFAULT_UP=new H(0,1,0),Pt.DEFAULT_MATRIX_AUTO_UPDATE=!0,Pt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Ai=new H,Xi=new H,xu=new H,Yi=new H,$r=new H,ea=new H,nA=new H,_u=new H,Eu=new H,yu=new H,wu=new Et,vu=new Et,Cu=new Et;class gi{constructor(e=new H,t=new H,n=new H){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,s){s.subVectors(n,t),Ai.subVectors(e,t),s.cross(Ai);const r=s.lengthSq();return r>0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(e,t,n,s,r){Ai.subVectors(s,t),Xi.subVectors(n,t),xu.subVectors(e,t);const a=Ai.dot(Ai),o=Ai.dot(Xi),c=Ai.dot(xu),l=Xi.dot(Xi),h=Xi.dot(xu),u=a*l-o*o;if(u===0)return r.set(0,0,0),null;const d=1/u,f=(l*c-o*h)*d,m=(a*h-o*c)*d;return r.set(1-f-m,m,f)}static containsPoint(e,t,n,s){return this.getBarycoord(e,t,n,s,Yi)===null?!1:Yi.x>=0&&Yi.y>=0&&Yi.x+Yi.y<=1}static getInterpolation(e,t,n,s,r,a,o,c){return this.getBarycoord(e,t,n,s,Yi)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(r,Yi.x),c.addScaledVector(a,Yi.y),c.addScaledVector(o,Yi.z),c)}static getInterpolatedAttribute(e,t,n,s,r,a){return wu.setScalar(0),vu.setScalar(0),Cu.setScalar(0),wu.fromBufferAttribute(e,t),vu.fromBufferAttribute(e,n),Cu.fromBufferAttribute(e,s),a.setScalar(0),a.addScaledVector(wu,r.x),a.addScaledVector(vu,r.y),a.addScaledVector(Cu,r.z),a}static isFrontFacing(e,t,n,s){return Ai.subVectors(n,t),Xi.subVectors(e,t),Ai.cross(Xi).dot(s)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,s){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[s]),this}setFromAttributeAndIndices(e,t,n,s){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,s),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 Ai.subVectors(this.c,this.b),Xi.subVectors(this.a,this.b),Ai.cross(Xi).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return gi.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return gi.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,s,r){return gi.getInterpolation(e,this.a,this.b,this.c,t,n,s,r)}containsPoint(e){return gi.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return gi.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,s=this.b,r=this.c;let a,o;$r.subVectors(s,n),ea.subVectors(r,n),_u.subVectors(e,n);const c=$r.dot(_u),l=ea.dot(_u);if(c<=0&&l<=0)return t.copy(n);Eu.subVectors(e,s);const h=$r.dot(Eu),u=ea.dot(Eu);if(h>=0&&u<=h)return t.copy(s);const d=c*u-h*l;if(d<=0&&c>=0&&h<=0)return a=c/(c-h),t.copy(n).addScaledVector($r,a);yu.subVectors(e,r);const f=$r.dot(yu),m=ea.dot(yu);if(m>=0&&f<=m)return t.copy(r);const A=f*l-c*m;if(A<=0&&l>=0&&m<=0)return o=l/(l-m),t.copy(n).addScaledVector(ea,o);const g=h*m-f*u;if(g<=0&&u-h>=0&&f-m>=0)return nA.subVectors(r,s),o=(u-h)/(u-h+(f-m)),t.copy(s).addScaledVector(nA,o);const p=1/(g+A+d);return a=A*p,o=d*p,t.copy(n).addScaledVector($r,a).addScaledVector(ea,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const iA={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},Cs={h:0,s:0,l:0},Lc={h:0,s:0,l:0};function Su(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*6*(2/3-t):i}let qe=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){const s=e;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Kt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,At.toWorkingColorSpace(this,t),this}setRGB(e,t,n,s=At.workingColorSpace){return this.r=e,this.g=t,this.b=n,At.toWorkingColorSpace(this,s),this}setHSL(e,t,n,s=At.workingColorSpace){if(e=cu(e,1),t=at(t,0,1),n=at(n,0,1),t===0)this.r=this.g=this.b=n;else{const r=n<=.5?n*(1+t):n+t-n*t,a=2*n-r;this.r=Su(a,r,e+1/3),this.g=Su(a,r,e),this.b=Su(a,r,e-1/3)}return At.toWorkingColorSpace(this,s),this}setStyle(e,t=Kt){function n(r){r!==void 0&&parseFloat(r)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const a=s[1],o=s[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(e)){const r=s[1],a=r.length;if(a===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(r,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Kt){const n=iA[e.toLowerCase()];return n!==void 0?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Wi(e.r),this.g=Wi(e.g),this.b=Wi(e.b),this}copyLinearToSRGB(e){return this.r=Wr(e.r),this.g=Wr(e.g),this.b=Wr(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Kt){return At.fromWorkingColorSpace(vn.copy(this),e),Math.round(at(vn.r*255,0,255))*65536+Math.round(at(vn.g*255,0,255))*256+Math.round(at(vn.b*255,0,255))}getHexString(e=Kt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=At.workingColorSpace){At.fromWorkingColorSpace(vn.copy(this),t);const n=vn.r,s=vn.g,r=vn.b,a=Math.max(n,s,r),o=Math.min(n,s,r);let c,l;const h=(o+a)/2;if(o===a)c=0,l=0;else{const u=a-o;switch(l=h<=.5?u/(a+o):u/(2-a-o),a){case n:c=(s-r)/u+(s<r?6:0);break;case s:c=(r-n)/u+2;break;case r:c=(n-s)/u+4;break}c/=6}return e.h=c,e.s=l,e.l=h,e}getRGB(e,t=At.workingColorSpace){return At.fromWorkingColorSpace(vn.copy(this),t),e.r=vn.r,e.g=vn.g,e.b=vn.b,e}getStyle(e=Kt){At.fromWorkingColorSpace(vn.copy(this),e);const t=vn.r,n=vn.g,s=vn.b;return e!==Kt?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${s.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(s*255)})`}offsetHSL(e,t,n){return this.getHSL(Cs),this.setHSL(Cs.h+e,Cs.s+t,Cs.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(Cs),e.getHSL(Lc);const n=ao(Cs.h,Lc.h,t),s=ao(Cs.s,Lc.s,t),r=ao(Cs.l,Lc.l,t);return this.setHSL(n,s,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,n=this.g,s=this.b,r=e.elements;return this.r=r[0]*t+r[3]*n+r[6]*s,this.g=r[1]*t+r[4]*n+r[7]*s,this.b=r[2]*t+r[5]*n+r[8]*s,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}};const vn=new qe;qe.NAMES=iA;let ey=0;class Ni extends _s{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:ey++}),this.uuid=hi(),this.name="",this.type="Material",this.blending=kr,this.side=Hi,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=yh,this.blendDst=wh,this.blendEquation=Xs,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new qe(0,0,0),this.blendAlpha=0,this.depthFunc=Ur,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Pp,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=zr,this.stencilZFail=zr,this.stencilZPass=zr,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(n):s&&s.isVector3&&n&&n.isVector3?s.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==kr&&(n.blending=this.blending),this.side!==Hi&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==yh&&(n.blendSrc=this.blendSrc),this.blendDst!==wh&&(n.blendDst=this.blendDst),this.blendEquation!==Xs&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==Ur&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Pp&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==zr&&(n.stencilFail=this.stencilFail),this.stencilZFail!==zr&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==zr&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function s(r){const a=[];for(const o in r){const c=r[o];delete c.metadata,a.push(c)}return a}if(t){const r=s(e.textures),a=s(e.images);r.length>0&&(n.textures=r),a.length>0&&(n.images=a)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(t!==null){const s=t.length;n=new Array(s);for(let r=0;r!==s;++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.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++}}class Ss extends Ni{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new qe(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 Ri,this.combine=Ep,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const Ji=ty();function ty(){const i=new ArrayBuffer(4),e=new Float32Array(i),t=new Uint32Array(i),n=new Uint32Array(512),s=new Uint32Array(512);for(let c=0;c<256;++c){const l=c-127;l<-27?(n[c]=0,n[c|256]=32768,s[c]=24,s[c|256]=24):l<-14?(n[c]=1024>>-l-14,n[c|256]=1024>>-l-14|32768,s[c]=-l-1,s[c|256]=-l-1):l<=15?(n[c]=l+15<<10,n[c|256]=l+15<<10|32768,s[c]=13,s[c|256]=13):l<128?(n[c]=31744,n[c|256]=64512,s[c]=24,s[c|256]=24):(n[c]=31744,n[c|256]=64512,s[c]=13,s[c|256]=13)}const r=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let c=1;c<1024;++c){let l=c<<13,h=0;for(;(l&8388608)===0;)l<<=1,h-=8388608;l&=-8388609,h+=947912704,r[c]=l|h}for(let c=1024;c<2048;++c)r[c]=939524096+(c-1024<<13);for(let c=1;c<31;++c)a[c]=c<<23;a[31]=1199570944,a[32]=2147483648;for(let c=33;c<63;++c)a[c]=2147483648+(c-32<<23);a[63]=3347054592;for(let c=1;c<64;++c)c!==32&&(o[c]=1024);return{floatView:e,uint32View:t,baseTable:n,shiftTable:s,mantissaTable:r,exponentTable:a,offsetTable:o}}function ny(i){Math.abs(i)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),i=at(i,-65504,65504),Ji.floatView[0]=i;const e=Ji.uint32View[0],t=e>>23&511;return Ji.baseTable[t]+((e&8388607)>>Ji.shiftTable[t])}function iy(i){const e=i>>10;return Ji.uint32View[0]=Ji.mantissaTable[Ji.offsetTable[e]+(i&1023)]+Ji.exponentTable[e],Ji.floatView[0]}class sA{static toHalfFloat(e){return ny(e)}static fromHalfFloat(e){return iy(e)}}const Yt=new H,Pc=new Ze;let sy=0;class _n{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:sy++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=ou,this.updateRanges=[],this.gpuType=nn,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let s=0,r=this.itemSize;s<r;s++)this.array[e+s]=t.array[n+s];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++)Pc.fromBufferAttribute(this,t),Pc.applyMatrix3(e),this.setXY(t,Pc.x,Pc.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)Yt.fromBufferAttribute(this,t),Yt.applyMatrix3(e),this.setXYZ(t,Yt.x,Yt.y,Yt.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)Yt.fromBufferAttribute(this,t),Yt.applyMatrix4(e),this.setXYZ(t,Yt.x,Yt.y,Yt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Yt.fromBufferAttribute(this,t),Yt.applyNormalMatrix(e),this.setXYZ(t,Yt.x,Yt.y,Yt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Yt.fromBufferAttribute(this,t),Yt.transformDirection(e),this.setXYZ(t,Yt.x,Yt.y,Yt.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=ui(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=It(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=ui(t,this.array)),t}setX(e,t){return this.normalized&&(t=It(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=ui(t,this.array)),t}setY(e,t){return this.normalized&&(t=It(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=ui(t,this.array)),t}setZ(e,t){return this.normalized&&(t=It(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=ui(t,this.array)),t}setW(e,t){return this.normalized&&(t=It(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=It(t,this.array),n=It(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,s){return e*=this.itemSize,this.normalized&&(t=It(t,this.array),n=It(n,this.array),s=It(s,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=s,this}setXYZW(e,t,n,s,r){return e*=this.itemSize,this.normalized&&(t=It(t,this.array),n=It(n,this.array),s=It(s,this.array),r=It(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=s,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==ou&&(e.usage=this.usage),e}}class rA extends _n{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class aA extends _n{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class Tn extends _n{constructor(e,t,n){super(new Float32Array(e),t,n)}}let ry=0;const $n=new $e,Iu=new Pt,ta=new H,Kn=new di,fo=new di,fn=new H;class Qn extends _s{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:ry++}),this.uuid=hi(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(Gp(e)?aA:rA)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,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){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const r=new rt().getNormalMatrix(e);n.applyNormalMatrix(r),n.needsUpdate=!0}const s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(e),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return $n.makeRotationFromQuaternion(e),this.applyMatrix4($n),this}rotateX(e){return $n.makeRotationX(e),this.applyMatrix4($n),this}rotateY(e){return $n.makeRotationY(e),this.applyMatrix4($n),this}rotateZ(e){return $n.makeRotationZ(e),this.applyMatrix4($n),this}translate(e,t,n){return $n.makeTranslation(e,t,n),this.applyMatrix4($n),this}scale(e,t,n){return $n.makeScale(e,t,n),this.applyMatrix4($n),this}lookAt(e){return Iu.lookAt(e),Iu.updateMatrix(),this.applyMatrix4(Iu.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ta).negate(),this.translate(ta.x,ta.y,ta.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const n=[];for(let s=0,r=e.length;s<r;s++){const a=e[s];n.push(a.x,a.y,a.z||0)}this.setAttribute("position",new Tn(n,3))}else{const n=Math.min(e.length,t.count);for(let s=0;s<n;s++){const r=e[s];t.setXYZ(s,r.x,r.y,r.z||0)}e.length>t.count&&console.warn("THREE.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 di);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new H(-1/0,-1/0,-1/0),new H(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,s=t.length;n<s;n++){const r=t[n];Kn.setFromBufferAttribute(r),this.morphTargetsRelative?(fn.addVectors(this.boundingBox.min,Kn.min),this.boundingBox.expandByPoint(fn),fn.addVectors(this.boundingBox.max,Kn.max),this.boundingBox.expandByPoint(fn)):(this.boundingBox.expandByPoint(Kn.min),this.boundingBox.expandByPoint(Kn.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Ti);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new H,1/0);return}if(e){const n=this.boundingSphere.center;if(Kn.setFromBufferAttribute(e),t)for(let r=0,a=t.length;r<a;r++){const o=t[r];fo.setFromBufferAttribute(o),this.morphTargetsRelative?(fn.addVectors(Kn.min,fo.min),Kn.expandByPoint(fn),fn.addVectors(Kn.max,fo.max),Kn.expandByPoint(fn)):(Kn.expandByPoint(fo.min),Kn.expandByPoint(fo.max))}Kn.getCenter(n);let s=0;for(let r=0,a=e.count;r<a;r++)fn.fromBufferAttribute(e,r),s=Math.max(s,n.distanceToSquared(fn));if(t)for(let r=0,a=t.length;r<a;r++){const o=t[r],c=this.morphTargetsRelative;for(let l=0,h=o.count;l<h;l++)fn.fromBufferAttribute(o,l),c&&(ta.fromBufferAttribute(e,l),fn.add(ta)),s=Math.max(s,n.distanceToSquared(fn))}this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=t.position,s=t.normal,r=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new _n(new Float32Array(4*n.count),4));const a=this.getAttribute("tangent"),o=[],c=[];for(let T=0;T<n.count;T++)o[T]=new H,c[T]=new H;const l=new H,h=new H,u=new H,d=new Ze,f=new Ze,m=new Ze,A=new H,g=new H;function p(T,C,v){l.fromBufferAttribute(n,T),h.fromBufferAttribute(n,C),u.fromBufferAttribute(n,v),d.fromBufferAttribute(r,T),f.fromBufferAttribute(r,C),m.fromBufferAttribute(r,v),h.sub(l),u.sub(l),f.sub(d),m.sub(d);const F=1/(f.x*m.y-m.x*f.y);isFinite(F)&&(A.copy(h).multiplyScalar(m.y).addScaledVector(u,-f.y).multiplyScalar(F),g.copy(u).multiplyScalar(f.x).addScaledVector(h,-m.x).multiplyScalar(F),o[T].add(A),o[C].add(A),o[v].add(A),c[T].add(g),c[C].add(g),c[v].add(g))}let y=this.groups;y.length===0&&(y=[{start:0,count:e.count}]);for(let T=0,C=y.length;T<C;++T){const v=y[T],F=v.start,K=v.count;for(let q=F,$=F+K;q<$;q+=3)p(e.getX(q+0),e.getX(q+1),e.getX(q+2))}const b=new H,E=new H,M=new H,w=new H;function S(T){M.fromBufferAttribute(s,T),w.copy(M);const C=o[T];b.copy(C),b.sub(M.multiplyScalar(M.dot(C))).normalize(),E.crossVectors(w,C);const F=E.dot(c[T])<0?-1:1;a.setXYZW(T,b.x,b.y,b.z,F)}for(let T=0,C=y.length;T<C;++T){const v=y[T],F=v.start,K=v.count;for(let q=F,$=F+K;q<$;q+=3)S(e.getX(q+0)),S(e.getX(q+1)),S(e.getX(q+2))}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new _n(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let d=0,f=n.count;d<f;d++)n.setXYZ(d,0,0,0);const s=new H,r=new H,a=new H,o=new H,c=new H,l=new H,h=new H,u=new H;if(e)for(let d=0,f=e.count;d<f;d+=3){const m=e.getX(d+0),A=e.getX(d+1),g=e.getX(d+2);s.fromBufferAttribute(t,m),r.fromBufferAttribute(t,A),a.fromBufferAttribute(t,g),h.subVectors(a,r),u.subVectors(s,r),h.cross(u),o.fromBufferAttribute(n,m),c.fromBufferAttribute(n,A),l.fromBufferAttribute(n,g),o.add(h),c.add(h),l.add(h),n.setXYZ(m,o.x,o.y,o.z),n.setXYZ(A,c.x,c.y,c.z),n.setXYZ(g,l.x,l.y,l.z)}else for(let d=0,f=t.count;d<f;d+=3)s.fromBufferAttribute(t,d+0),r.fromBufferAttribute(t,d+1),a.fromBufferAttribute(t,d+2),h.subVectors(a,r),u.subVectors(s,r),h.cross(u),n.setXYZ(d+0,h.x,h.y,h.z),n.setXYZ(d+1,h.x,h.y,h.z),n.setXYZ(d+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)fn.fromBufferAttribute(e,t),fn.normalize(),e.setXYZ(t,fn.x,fn.y,fn.z)}toNonIndexed(){function e(o,c){const l=o.array,h=o.itemSize,u=o.normalized,d=new l.constructor(c.length*h);let f=0,m=0;for(let A=0,g=c.length;A<g;A++){o.isInterleavedBufferAttribute?f=c[A]*o.data.stride+o.offset:f=c[A]*h;for(let p=0;p<h;p++)d[m++]=l[f++]}return new _n(d,h,u)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new Qn,n=this.index.array,s=this.attributes;for(const o in s){const c=s[o],l=e(c,n);t.setAttribute(o,l)}const r=this.morphAttributes;for(const o in r){const c=[],l=r[o];for(let h=0,u=l.length;h<u;h++){const d=l[h],f=e(d,n);c.push(f)}t.morphAttributes[o]=c}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,c=a.length;o<c;o++){const l=a[o];t.addGroup(l.start,l.count,l.materialIndex)}return t}toJSON(){const e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const c=this.parameters;for(const l in c)c[l]!==void 0&&(e[l]=c[l]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const c in n){const l=n[c];e.data.attributes[c]=l.toJSON(e.data)}const s={};let r=!1;for(const c in this.morphAttributes){const l=this.morphAttributes[c],h=[];for(let u=0,d=l.length;u<d;u++){const f=l[u];h.push(f.toJSON(e.data))}h.length>0&&(s[c]=h,r=!0)}r&&(e.data.morphAttributes=s,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone());const s=e.attributes;for(const l in s){const h=s[l];this.setAttribute(l,h.clone(t))}const r=e.morphAttributes;for(const l in r){const h=[],u=r[l];for(let d=0,f=u.length;d<f;d++)h.push(u[d].clone(t));this.morphAttributes[l]=h}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let l=0,h=a.length;l<h;l++){const u=a[l];this.addGroup(u.start,u.count,u.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const oA=new $e,nr=new ho,kc=new Ti,cA=new H,Uc=new H,Oc=new H,Qc=new H,Mu=new H,Gc=new H,lA=new H,Hc=new H;class Jt extends Pt{constructor(e=new Qn,t=new Ss){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r<a;r++){const o=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}getVertexPosition(e,t){const n=this.geometry,s=n.attributes.position,r=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(s,e);const o=this.morphTargetInfluences;if(r&&o){Gc.set(0,0,0);for(let c=0,l=r.length;c<l;c++){const h=o[c],u=r[c];h!==0&&(Mu.fromBufferAttribute(u,e),a?Gc.addScaledVector(Mu,h):Gc.addScaledVector(Mu.sub(t),h))}t.add(Gc)}return t}raycast(e,t){const n=this.geometry,s=this.material,r=this.matrixWorld;s!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),kc.copy(n.boundingSphere),kc.applyMatrix4(r),nr.copy(e.ray).recast(e.near),!(kc.containsPoint(nr.origin)===!1&&(nr.intersectSphere(kc,cA)===null||nr.origin.distanceToSquared(cA)>(e.far-e.near)**2))&&(oA.copy(r).invert(),nr.copy(e.ray).applyMatrix4(oA),!(n.boundingBox!==null&&nr.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,nr)))}_computeIntersections(e,t,n){let s;const r=this.geometry,a=this.material,o=r.index,c=r.attributes.position,l=r.attributes.uv,h=r.attributes.uv1,u=r.attributes.normal,d=r.groups,f=r.drawRange;if(o!==null)if(Array.isArray(a))for(let m=0,A=d.length;m<A;m++){const g=d[m],p=a[g.materialIndex],y=Math.max(g.start,f.start),b=Math.min(o.count,Math.min(g.start+g.count,f.start+f.count));for(let E=y,M=b;E<M;E+=3){const w=o.getX(E),S=o.getX(E+1),T=o.getX(E+2);s=zc(this,p,e,n,l,h,u,w,S,T),s&&(s.faceIndex=Math.floor(E/3),s.face.materialIndex=g.materialIndex,t.push(s))}}else{const m=Math.max(0,f.start),A=Math.min(o.count,f.start+f.count);for(let g=m,p=A;g<p;g+=3){const y=o.getX(g),b=o.getX(g+1),E=o.getX(g+2);s=zc(this,a,e,n,l,h,u,y,b,E),s&&(s.faceIndex=Math.floor(g/3),t.push(s))}}else if(c!==void 0)if(Array.isArray(a))for(let m=0,A=d.length;m<A;m++){const g=d[m],p=a[g.materialIndex],y=Math.max(g.start,f.start),b=Math.min(c.count,Math.min(g.start+g.count,f.start+f.count));for(let E=y,M=b;E<M;E+=3){const w=E,S=E+1,T=E+2;s=zc(this,p,e,n,l,h,u,w,S,T),s&&(s.faceIndex=Math.floor(E/3),s.face.materialIndex=g.materialIndex,t.push(s))}}else{const m=Math.max(0,f.start),A=Math.min(c.count,f.start+f.count);for(let g=m,p=A;g<p;g+=3){const y=g,b=g+1,E=g+2;s=zc(this,a,e,n,l,h,u,y,b,E),s&&(s.faceIndex=Math.floor(g/3),t.push(s))}}}}function ay(i,e,t,n,s,r,a,o){let c;if(e.side===In?c=n.intersectTriangle(a,r,s,!0,o):c=n.intersectTriangle(s,r,a,e.side===Hi,o),c===null)return null;Hc.copy(o),Hc.applyMatrix4(i.matrixWorld);const l=t.ray.origin.distanceTo(Hc);return l<t.near||l>t.far?null:{distance:l,point:Hc.clone(),object:i}}function zc(i,e,t,n,s,r,a,o,c,l){i.getVertexPosition(o,Uc),i.getVertexPosition(c,Oc),i.getVertexPosition(l,Qc);const h=ay(i,e,t,n,Uc,Oc,Qc,lA);if(h){const u=new H;gi.getBarycoord(lA,Uc,Oc,Qc,u),s&&(h.uv=gi.getInterpolatedAttribute(s,o,c,l,u,new Ze)),r&&(h.uv1=gi.getInterpolatedAttribute(r,o,c,l,u,new Ze)),a&&(h.normal=gi.getInterpolatedAttribute(a,o,c,l,u,new H),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));const d={a:o,b:c,c:l,normal:new H,materialIndex:0};gi.getNormal(Uc,Oc,Qc,d.normal),h.face=d,h.barycoord=u}return h}class na extends Qn{constructor(e=1,t=1,n=1,s=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:s,heightSegments:r,depthSegments:a};const o=this;s=Math.floor(s),r=Math.floor(r),a=Math.floor(a);const c=[],l=[],h=[],u=[];let d=0,f=0;m("z","y","x",-1,-1,n,t,e,a,r,0),m("z","y","x",1,-1,n,t,-e,a,r,1),m("x","z","y",1,1,e,n,t,s,a,2),m("x","z","y",1,-1,e,n,-t,s,a,3),m("x","y","z",1,-1,e,t,n,s,r,4),m("x","y","z",-1,-1,e,t,-n,s,r,5),this.setIndex(c),this.setAttribute("position",new Tn(l,3)),this.setAttribute("normal",new Tn(h,3)),this.setAttribute("uv",new Tn(u,2));function m(A,g,p,y,b,E,M,w,S,T,C){const v=E/S,F=M/T,K=E/2,q=M/2,$=w/2,D=S+1,O=T+1;let Y=0,Q=0;const J=new H;for(let ee=0;ee<O;ee++){const ae=ee*F-q;for(let ye=0;ye<D;ye++){const Me=ye*v-K;J[A]=Me*y,J[g]=ae*b,J[p]=$,l.push(J.x,J.y,J.z),J[A]=0,J[g]=0,J[p]=w>0?1:-1,h.push(J.x,J.y,J.z),u.push(ye/S),u.push(1-ee/T),Y+=1}}for(let ee=0;ee<T;ee++)for(let ae=0;ae<S;ae++){const ye=d+ae+D*ee,Me=d+ae+D*(ee+1),se=d+(ae+1)+D*(ee+1),me=d+(ae+1)+D*ee;c.push(ye,Me,me),c.push(Me,se,me),Q+=6}o.addGroup(f,Q,C),f+=Q,d+=Y}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new na(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function ia(i){const e={};for(const t in i){e[t]={};for(const n in i[t]){const s=i[t][n];s&&(s.isColor||s.isMatrix3||s.isMatrix4||s.isVector2||s.isVector3||s.isVector4||s.isTexture||s.isQuaternion)?s.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=s.clone():Array.isArray(s)?e[t][n]=s.slice():e[t][n]=s}}return e}function Rn(i){const e={};for(let t=0;t<i.length;t++){const n=ia(i[t]);for(const s in n)e[s]=n[s]}return e}function oy(i){const e=[];for(let t=0;t<i.length;t++)e.push(i[t].clone());return e}function hA(i){const e=i.getRenderTarget();return e===null?i.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:At.workingColorSpace}const cy={clone:ia,merge:Rn};var ly=`void main() {+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );+}`,hy=`void main() {+ gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );+}`;class Is extends Ni{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=ly,this.fragmentShader=hy,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=ia(e.uniforms),this.uniformsGroups=oy(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const s in this.uniforms){const a=this.uniforms[s].value;a&&a.isTexture?t.uniforms[s]={type:"t",value:a.toJSON(e).uuid}:a&&a.isColor?t.uniforms[s]={type:"c",value:a.getHex()}:a&&a.isVector2?t.uniforms[s]={type:"v2",value:a.toArray()}:a&&a.isVector3?t.uniforms[s]={type:"v3",value:a.toArray()}:a&&a.isVector4?t.uniforms[s]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?t.uniforms[s]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?t.uniforms[s]={type:"m4",value:a.toArray()}:t.uniforms[s]={value:a}}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;const n={};for(const s in this.extensions)this.extensions[s]===!0&&(n[s]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class uA extends Pt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new $e,this.projectionMatrix=new $e,this.projectionMatrixInverse=new $e,this.coordinateSystem=Vi}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.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const Ms=new H,dA=new Ze,fA=new Ze;class Cn extends uA{constructor(e=50,t=1,n=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=s,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){const t=.5*this.getFilmHeight()/e;this.fov=Vr*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(ro*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Vr*2*Math.atan(Math.tan(ro*.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){Ms.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Ms.x,Ms.y).multiplyScalar(-e/Ms.z),Ms.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Ms.x,Ms.y).multiplyScalar(-e/Ms.z)}getViewSize(e,t){return this.getViewBounds(e,dA,fA),t.subVectors(fA,dA)}setViewOffset(e,t,n,s,r,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=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(ro*.5*this.fov)/this.zoom,n=2*t,s=this.aspect*n,r=-.5*s;const a=this.view;if(this.view!==null&&this.view.enabled){const c=a.fullWidth,l=a.fullHeight;r+=a.offsetX*s/c,t-=a.offsetY*n/l,s*=a.width/c,n*=a.height/l}const o=this.filmOffset;o!==0&&(r+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+s,t,t-n,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const 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}}const sa=-90,ra=1;class uy extends Pt{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const s=new Cn(sa,ra,e,t);s.layers=this.layers,this.add(s);const r=new Cn(sa,ra,e,t);r.layers=this.layers,this.add(r);const a=new Cn(sa,ra,e,t);a.layers=this.layers,this.add(a);const o=new Cn(sa,ra,e,t);o.layers=this.layers,this.add(o);const c=new Cn(sa,ra,e,t);c.layers=this.layers,this.add(c);const l=new Cn(sa,ra,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,s,r,a,o,c]=t;for(const l of t)this.remove(l);if(e===Vi)n.up.set(0,1,0),n.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),r.up.set(0,0,-1),r.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),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===Sc)n.up.set(0,-1,0),n.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),r.up.set(0,0,1),r.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),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const l of t)this.add(l),l.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:s}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,a,o,c,l,h]=this.children,u=e.getRenderTarget(),d=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),m=e.xr.enabled;e.xr.enabled=!1;const A=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,s),e.render(t,r),e.setRenderTarget(n,1,s),e.render(t,a),e.setRenderTarget(n,2,s),e.render(t,o),e.setRenderTarget(n,3,s),e.render(t,c),e.setRenderTarget(n,4,s),e.render(t,l),n.texture.generateMipmaps=A,e.setRenderTarget(n,5,s),e.render(t,h),e.setRenderTarget(u,d,f),e.xr.enabled=m,n.texture.needsPMREMUpdate=!0}}class pA extends an{constructor(e=[],t=Ys,n,s,r,a,o,c,l,h){super(e,t,n,s,r,a,o,c,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class dy extends $s{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},s=[n,n,n,n,n,n];this.texture=new pA(s,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:zt}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;const n={uniforms:{tEquirect:{value:null}},vertexShader:`++ varying vec3 vWorldDirection;++ vec3 transformDirection( in vec3 dir, in mat4 matrix ) {++ return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );++ }++ void main() {++ vWorldDirection = transformDirection( position, modelMatrix );++ #include <begin_vertex>+ #include <project_vertex>++ }+ `,fragmentShader:`++ uniform sampler2D tEquirect;++ varying vec3 vWorldDirection;++ #include <common>++ void main() {++ vec3 direction = normalize( vWorldDirection );++ vec2 sampleUV = equirectUv( direction );++ gl_FragColor = texture2D( tEquirect, sampleUV );++ }+ `},s=new na(5,5,5),r=new Is({name:"CubemapFromEquirect",uniforms:ia(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:In,blending:bs});r.uniforms.tEquirect.value=t;const a=new Jt(s,r),o=t.minFilter;return t.minFilter===Zn&&(t.minFilter=zt),new uy(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,n=!0,s=!0){const r=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,s);e.setRenderTarget(r)}}class ir extends Pt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const fy={type:"move"};class Bu{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new ir,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 ir,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new H,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new H),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new ir,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new H,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new H),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const 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 s=null,r=null,a=null;const o=this._targetRay,c=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){a=!0;for(const A of e.hand.values()){const g=t.getJointPose(A,n),p=this._getHandJoint(l,A);g!==null&&(p.matrix.fromArray(g.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=g.radius),p.visible=g!==null}const h=l.joints["index-finger-tip"],u=l.joints["thumb-tip"],d=h.position.distanceTo(u.position),f=.02,m=.005;l.inputState.pinching&&d>f+m?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&d<=f-m&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,n),r!==null&&(c.matrix.fromArray(r.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,r.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(r.linearVelocity)):c.hasLinearVelocity=!1,r.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(r.angularVelocity)):c.hasAngularVelocity=!1));o!==null&&(s=t.getPose(e.targetRaySpace,n),s===null&&r!==null&&(s=r),s!==null&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(fy)))}return o!==null&&(o.visible=s!==null),c!==null&&(c.visible=r!==null),l!==null&&(l.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new ir;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class Tu extends Pt{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 Ri,this.environmentIntensity=1,this.environmentRotation=new Ri,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class py{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=ou,this.updateRanges=[],this.version=0,this.uuid=hi()}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 s=0,r=this.stride;s<r;s++)this.array[e+s]=t.array[n+s];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=hi()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=hi()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const Nn=new H;class Ru{constructor(e,t,n,s=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=s}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++)Nn.fromBufferAttribute(this,t),Nn.applyMatrix4(e),this.setXYZ(t,Nn.x,Nn.y,Nn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Nn.fromBufferAttribute(this,t),Nn.applyNormalMatrix(e),this.setXYZ(t,Nn.x,Nn.y,Nn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Nn.fromBufferAttribute(this,t),Nn.transformDirection(e),this.setXYZ(t,Nn.x,Nn.y,Nn.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=ui(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=It(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=It(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=It(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=It(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=It(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=ui(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=ui(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=ui(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=ui(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=It(t,this.array),n=It(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=It(t,this.array),n=It(n,this.array),s=It(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=s,this}setXYZW(e,t,n,s,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=It(t,this.array),n=It(n,this.array),s=It(s,this.array),r=It(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=s,this.data.array[e+3]=r,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const s=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[s+r])}return new _n(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new Ru(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const s=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[s+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}const AA=new H,gA=new Et,mA=new Et,Ay=new H,bA=new $e,Vc=new H,Nu=new Ti,xA=new $e,Fu=new ho;class gy extends Jt{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=wp,this.bindMatrix=new $e,this.bindMatrixInverse=new $e,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new di),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Vc),this.boundingBox.expandByPoint(Vc)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Ti),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Vc),this.boundingSphere.expandByPoint(Vc)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const n=this.material,s=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Nu.copy(this.boundingSphere),Nu.applyMatrix4(s),e.ray.intersectsSphere(Nu)!==!1&&(xA.copy(s).invert(),Fu.copy(e.ray).applyMatrix4(xA),!(this.boundingBox!==null&&Fu.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,Fu)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new Et,t=this.geometry.attributes.skinWeight;for(let n=0,s=t.count;n<s;n++){e.fromBufferAttribute(t,n);const r=1/e.manhattanLength();r!==1/0?e.multiplyScalar(r):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===wp?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===cE?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const n=this.skeleton,s=this.geometry;gA.fromBufferAttribute(s.attributes.skinIndex,e),mA.fromBufferAttribute(s.attributes.skinWeight,e),AA.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let r=0;r<4;r++){const a=mA.getComponent(r);if(a!==0){const o=gA.getComponent(r);bA.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),t.addScaledVector(Ay.copy(AA).applyMatrix4(bA),a)}}return t.applyMatrix4(this.bindMatrixInverse)}}class _A extends Pt{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Wc extends an{constructor(e=null,t=1,n=1,s,r,a,o,c,l=Mn,h=Mn,u,d){super(null,a,o,c,l,h,s,r,u,d),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const EA=new $e,my=new $e;class Du{constructor(e=[],t=[]){this.uuid=hi(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,s=this.bones.length;n<s;n++)this.boneInverses.push(new $e)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const n=new $e;this.bones[e]&&n.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){const e=this.bones,t=this.boneInverses,n=this.boneMatrices,s=this.boneTexture;for(let r=0,a=e.length;r<a;r++){const o=e[r]?e[r].matrixWorld:my;EA.multiplyMatrices(o,t[r]),EA.toArray(n,r*16)}s!==null&&(s.needsUpdate=!0)}clone(){return new Du(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const n=new Wc(t,e,e,sn,nn);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){const s=this.bones[t];if(s.name===e)return s}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,s=e.bones.length;n<s;n++){const r=e.bones[n];let a=t[r];a===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",r),a=new _A),this.bones.push(a),this.boneInverses.push(new $e().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){const e={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,n=this.boneInverses;for(let s=0,r=t.length;s<r;s++){const a=t[s];e.bones.push(a.uuid);const o=n[s];e.boneInverses.push(o.toArray())}return e}}class Lu extends _n{constructor(e,t,n,s=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=s}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const aa=new $e,yA=new $e,qc=[],wA=new di,by=new $e,po=new Jt,Ao=new Ti;class vA extends Jt{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Lu(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let s=0;s<n;s++)this.setMatrixAt(s,by)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new di),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,aa),wA.copy(e.boundingBox).applyMatrix4(aa),this.boundingBox.union(wA)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new Ti),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,aa),Ao.copy(e.boundingSphere).applyMatrix4(aa),this.boundingSphere.union(Ao)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){const n=t.morphTargetInfluences,s=this.morphTexture.source.data.data,r=n.length+1,a=e*r+1;for(let o=0;o<n.length;o++)n[o]=s[a+o]}raycast(e,t){const n=this.matrixWorld,s=this.count;if(po.geometry=this.geometry,po.material=this.material,po.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Ao.copy(this.boundingSphere),Ao.applyMatrix4(n),e.ray.intersectsSphere(Ao)!==!1))for(let r=0;r<s;r++){this.getMatrixAt(r,aa),yA.multiplyMatrices(n,aa),po.matrixWorld=yA,po.raycast(e,qc);for(let a=0,o=qc.length;a<o;a++){const c=qc[a];c.instanceId=r,c.object=this,t.push(c)}qc.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Lu(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){const n=t.morphTargetInfluences,s=n.length+1;this.morphTexture===null&&(this.morphTexture=new Wc(new Float32Array(s*this.count),s,this.count,zi,nn));const r=this.morphTexture.source.data.data;let a=0;for(let l=0;l<n.length;l++)a+=n[l];const o=this.geometry.morphTargetsRelative?1:1-a,c=s*e;r[c]=o,r.set(n,c+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const Pu=new H,xy=new H,_y=new rt;class Bs{constructor(e=new H(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,s){return this.normal.set(e,t,n),this.constant=s,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const s=Pu.subVectors(n,t).cross(xy.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(s,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const n=e.delta(Pu),s=this.normal.dot(n);if(s===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const r=-(e.start.dot(this.normal)+this.constant)/s;return r<0||r>1?null:t.copy(e.start).addScaledVector(n,r)}intersectsLine(e){const 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){const n=t||_y.getNormalMatrix(e),s=this.coplanarPoint(Pu).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-s.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const sr=new Ti,Kc=new H;class ku{constructor(e=new Bs,t=new Bs,n=new Bs,s=new Bs,r=new Bs,a=new Bs){this.planes=[e,t,n,s,r,a]}set(e,t,n,s,r,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(s),o[4].copy(r),o[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=Vi){const n=this.planes,s=e.elements,r=s[0],a=s[1],o=s[2],c=s[3],l=s[4],h=s[5],u=s[6],d=s[7],f=s[8],m=s[9],A=s[10],g=s[11],p=s[12],y=s[13],b=s[14],E=s[15];if(n[0].setComponents(c-r,d-l,g-f,E-p).normalize(),n[1].setComponents(c+r,d+l,g+f,E+p).normalize(),n[2].setComponents(c+a,d+h,g+m,E+y).normalize(),n[3].setComponents(c-a,d-h,g-m,E-y).normalize(),n[4].setComponents(c-o,d-u,g-A,E-b).normalize(),t===Vi)n[5].setComponents(c+o,d+u,g+A,E+b).normalize();else if(t===Sc)n[5].setComponents(o,u,A,b).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),sr.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),sr.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(sr)}intersectsSprite(e){return sr.center.set(0,0,0),sr.radius=.7071067811865476,sr.applyMatrix4(e.matrixWorld),this.intersectsSphere(sr)}intersectsSphere(e){const t=this.planes,n=e.center,s=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)<s)return!1;return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const s=t[n];if(Kc.x=s.normal.x>0?e.max.x:e.min.x,Kc.y=s.normal.y>0?e.max.y:e.min.y,Kc.z=s.normal.z>0?e.max.z:e.min.z,s.distanceToPoint(Kc)<0)return!1}return!0}containsPoint(e){const 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)}}class go extends Ni{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new qe(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const jc=new H,Xc=new H,CA=new $e,mo=new ho,Yc=new Ti,Uu=new H,SA=new H;class Ou extends Pt{constructor(e=new Qn,t=new go){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[0];for(let s=1,r=t.count;s<r;s++)jc.fromBufferAttribute(t,s-1),Xc.fromBufferAttribute(t,s),n[s]=n[s-1],n[s]+=jc.distanceTo(Xc);e.setAttribute("lineDistance",new Tn(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,s=this.matrixWorld,r=e.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Yc.copy(n.boundingSphere),Yc.applyMatrix4(s),Yc.radius+=r,e.ray.intersectsSphere(Yc)===!1)return;CA.copy(s).invert(),mo.copy(e.ray).applyMatrix4(CA);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,l=this.isLineSegments?2:1,h=n.index,d=n.attributes.position;if(h!==null){const f=Math.max(0,a.start),m=Math.min(h.count,a.start+a.count);for(let A=f,g=m-1;A<g;A+=l){const p=h.getX(A),y=h.getX(A+1),b=Jc(this,e,mo,c,p,y,A);b&&t.push(b)}if(this.isLineLoop){const A=h.getX(m-1),g=h.getX(f),p=Jc(this,e,mo,c,A,g,m-1);p&&t.push(p)}}else{const f=Math.max(0,a.start),m=Math.min(d.count,a.start+a.count);for(let A=f,g=m-1;A<g;A+=l){const p=Jc(this,e,mo,c,A,A+1,A);p&&t.push(p)}if(this.isLineLoop){const A=Jc(this,e,mo,c,m-1,f,m-1);A&&t.push(A)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r<a;r++){const o=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function Jc(i,e,t,n,s,r,a){const o=i.geometry.attributes.position;if(jc.fromBufferAttribute(o,s),Xc.fromBufferAttribute(o,r),t.distanceSqToSegment(jc,Xc,Uu,SA)>n)return;Uu.applyMatrix4(i.matrixWorld);const l=e.ray.origin.distanceTo(Uu);if(!(l<e.near||l>e.far))return{distance:l,point:SA.clone().applyMatrix4(i.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:i}}const IA=new H,MA=new H;class Zc extends Ou{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[];for(let s=0,r=t.count;s<r;s+=2)IA.fromBufferAttribute(t,s),MA.fromBufferAttribute(t,s+1),n[s]=s===0?0:n[s-1],n[s+1]=n[s]+IA.distanceTo(MA);e.setAttribute("lineDistance",new Tn(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class Ey extends Ou{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class Qu extends Ni{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new qe(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const BA=new $e,Gu=new ho,$c=new Ti,el=new H;class yy extends Pt{constructor(e=new Qn,t=new Qu){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const n=this.geometry,s=this.matrixWorld,r=e.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),$c.copy(n.boundingSphere),$c.applyMatrix4(s),$c.radius+=r,e.ray.intersectsSphere($c)===!1)return;BA.copy(s).invert(),Gu.copy(e.ray).applyMatrix4(BA);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,l=n.index,u=n.attributes.position;if(l!==null){const d=Math.max(0,a.start),f=Math.min(l.count,a.start+a.count);for(let m=d,A=f;m<A;m++){const g=l.getX(m);el.fromBufferAttribute(u,g),TA(el,g,c,s,e,t,this)}}else{const d=Math.max(0,a.start),f=Math.min(u.count,a.start+a.count);for(let m=d,A=f;m<A;m++)el.fromBufferAttribute(u,m),TA(el,m,c,s,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r<a;r++){const o=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function TA(i,e,t,n,s,r,a){const o=Gu.distanceSqToPoint(i);if(o<t){const c=new H;Gu.closestPointToPoint(i,c),c.applyMatrix4(n);const l=s.ray.origin.distanceTo(c);if(l<s.near||l>s.far)return;r.push({distance:l,distanceToRay:Math.sqrt(o),point:c,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class tl extends an{constructor(e,t,n,s,r,a,o,c,l,h,u,d){super(null,a,o,c,l,h,s,r,u,d),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class wy extends tl{constructor(e,t,n,s,r,a){super(e,t,n,r,a),this.isCompressedArrayTexture=!0,this.image.depth=s,this.wrapR=ci,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class vy extends tl{constructor(e,t,n){super(void 0,e[0].width,e[0].height,t,n,Ys),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class RA extends an{constructor(e,t,n=Js,s,r,a,o=Mn,c=Mn,l,h=Ya){if(h!==Ya&&h!==Ja)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");super(null,s,r,a,o,c,h,n,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new hu(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class nl extends Qn{constructor(e=1,t=1,n=1,s=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:s};const r=e/2,a=t/2,o=Math.floor(n),c=Math.floor(s),l=o+1,h=c+1,u=e/o,d=t/c,f=[],m=[],A=[],g=[];for(let p=0;p<h;p++){const y=p*d-a;for(let b=0;b<l;b++){const E=b*u-r;m.push(E,-y,0),A.push(0,0,1),g.push(b/o),g.push(1-p/c)}}for(let p=0;p<c;p++)for(let y=0;y<o;y++){const b=y+l*p,E=y+l*(p+1),M=y+1+l*(p+1),w=y+1+l*p;f.push(b,E,w),f.push(E,M,w)}this.setIndex(f),this.setAttribute("position",new Tn(m,3)),this.setAttribute("normal",new Tn(A,3)),this.setAttribute("uv",new Tn(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new nl(e.width,e.height,e.widthSegments,e.heightSegments)}}class bo extends Ni{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new qe(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 qe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Lp,this.normalScale=new Ze(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ri,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Fi extends bo{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 Ze(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return at(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new qe(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 qe(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new qe(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class Cy extends Ni{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=dE,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Sy extends Ni{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 il(i,e){return!i||i.constructor===e?i:typeof e.BYTES_PER_ELEMENT=="number"?new e(i):Array.prototype.slice.call(i)}function Iy(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function My(i){function e(s,r){return i[s]-i[r]}const t=i.length,n=new Array(t);for(let s=0;s!==t;++s)n[s]=s;return n.sort(e),n}function NA(i,e,t){const n=i.length,s=new i.constructor(n);for(let r=0,a=0;a!==n;++r){const o=t[r]*e;for(let c=0;c!==e;++c)s[a++]=i[o+c]}return s}function FA(i,e,t,n){let s=1,r=i[0];for(;r!==void 0&&r[n]===void 0;)r=i[s++];if(r===void 0)return;let a=r[n];if(a!==void 0)if(Array.isArray(a))do a=r[n],a!==void 0&&(e.push(r.time),t.push(...a)),r=i[s++];while(r!==void 0);else if(a.toArray!==void 0)do a=r[n],a!==void 0&&(e.push(r.time),a.toArray(t,t.length)),r=i[s++];while(r!==void 0);else do a=r[n],a!==void 0&&(e.push(r.time),t.push(a)),r=i[s++];while(r!==void 0)}class xo{constructor(e,t,n,s){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=s!==void 0?s:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let n=this._cachedIndex,s=t[n],r=t[n-1];e:{t:{let a;n:{i:if(!(e<s)){for(let o=n+2;;){if(s===void 0){if(e<r)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(r=s,s=t[++n],e<s)break t}a=t.length;break n}if(!(e>=r)){const o=t[1];e<o&&(n=2,r=o);for(let c=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===c)break;if(s=r,r=t[--n-1],e>=r)break t}a=n,n=0;break n}break e}for(;n<a;){const o=n+a>>>1;e<t[o]?a=o:n=o+1}if(s=t[n],r=t[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(s===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,s)}return this.interpolate_(n,r,e,s)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,s=this.valueSize,r=e*s;for(let a=0;a!==s;++a)t[a]=n[r+a];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class By extends xo{constructor(e,t,n,s){super(e,t,n,s),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Gr,endingEnd:Gr}}intervalChanged_(e,t,n){const s=this.parameterPositions;let r=e-2,a=e+1,o=s[r],c=s[a];if(o===void 0)switch(this.getSettings_().endingStart){case Hr:r=e,o=2*t-n;break;case vc:r=s.length-2,o=t+s[r]-s[r+1];break;default:r=e,o=n}if(c===void 0)switch(this.getSettings_().endingEnd){case Hr:a=e,c=2*n-t;break;case vc:a=1,c=n+s[1]-s[0];break;default:a=e-1,c=t}const l=(n-t)*.5,h=this.valueSize;this._weightPrev=l/(t-o),this._weightNext=l/(c-n),this._offsetPrev=r*h,this._offsetNext=a*h}interpolate_(e,t,n,s){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=e*o,l=c-o,h=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,f=this._weightNext,m=(n-t)/(s-t),A=m*m,g=A*m,p=-d*g+2*d*A-d*m,y=(1+d)*g+(-1.5-2*d)*A+(-.5+d)*m+1,b=(-1-f)*g+(1.5+f)*A+.5*m,E=f*g-f*A;for(let M=0;M!==o;++M)r[M]=p*a[h+M]+y*a[l+M]+b*a[c+M]+E*a[u+M];return r}}class DA extends xo{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e,t,n,s){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=e*o,l=c-o,h=(n-t)/(s-t),u=1-h;for(let d=0;d!==o;++d)r[d]=a[l+d]*u+a[c+d]*h;return r}}class Ty extends xo{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e){return this.copySampleValue_(e-1)}}class mi{constructor(e,t,n,s){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=il(t,this.TimeBufferType),this.values=il(n,this.ValueBufferType),this.setInterpolation(s||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:il(e.times,Array),values:il(e.values,Array)};const s=e.getInterpolation();s!==e.DefaultInterpolation&&(n.interpolation=s)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new Ty(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new DA(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new By(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case io:t=this.InterpolantFactoryMethodDiscrete;break;case so:t=this.InterpolantFactoryMethodLinear;break;case su:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){const n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return io;case this.InterpolantFactoryMethodLinear:return so;case this.InterpolantFactoryMethodSmooth:return su}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let n=0,s=t.length;n!==s;++n)t[n]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let n=0,s=t.length;n!==s;++n)t[n]*=e}return this}trim(e,t){const n=this.times,s=n.length;let r=0,a=s-1;for(;r!==s&&n[r]<e;)++r;for(;a!==-1&&n[a]>t;)--a;if(++a,r!==0||a!==s){r>=a&&(a=Math.max(a,1),r=a-1);const o=this.getValueSize();this.times=n.slice(r,a),this.values=this.values.slice(r*o,a*o)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,s=this.values,r=n.length;r===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let o=0;o!==r;o++){const c=n[o];if(typeof c=="number"&&isNaN(c)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,c),e=!1;break}if(a!==null&&a>c){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,c,a),e=!1;break}a=c}if(s!==void 0&&Iy(s))for(let o=0,c=s.length;o!==c;++o){const l=s[o];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,l),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),s=this.getInterpolation()===su,r=e.length-1;let a=1;for(let o=1;o<r;++o){let c=!1;const l=e[o],h=e[o+1];if(l!==h&&(o!==1||l!==e[0]))if(s)c=!0;else{const u=o*n,d=u-n,f=u+n;for(let m=0;m!==n;++m){const A=t[u+m];if(A!==t[d+m]||A!==t[f+m]){c=!0;break}}}if(c){if(o!==a){e[a]=e[o];const u=o*n,d=a*n;for(let f=0;f!==n;++f)t[d+f]=t[u+f]}++a}}if(r>0){e[a]=e[r];for(let o=r*n,c=a*n,l=0;l!==n;++l)t[c+l]=t[o+l];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*n)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),n=this.constructor,s=new n(this.name,e,t);return s.createInterpolant=this.createInterpolant,s}}mi.prototype.ValueTypeName="",mi.prototype.TimeBufferType=Float32Array,mi.prototype.ValueBufferType=Float32Array,mi.prototype.DefaultInterpolation=so;class oa extends mi{constructor(e,t,n){super(e,t,n)}}oa.prototype.ValueTypeName="bool",oa.prototype.ValueBufferType=Array,oa.prototype.DefaultInterpolation=io,oa.prototype.InterpolantFactoryMethodLinear=void 0,oa.prototype.InterpolantFactoryMethodSmooth=void 0;class LA extends mi{constructor(e,t,n,s){super(e,t,n,s)}}LA.prototype.ValueTypeName="color";class ca extends mi{constructor(e,t,n,s){super(e,t,n,s)}}ca.prototype.ValueTypeName="number";class Ry extends xo{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e,t,n,s){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=(n-t)/(s-t);let l=e*o;for(let h=l+o;l!==h;l+=4)Wn.slerpFlat(r,0,a,l-o,a,l,c);return r}}class la extends mi{constructor(e,t,n,s){super(e,t,n,s)}InterpolantFactoryMethodLinear(e){return new Ry(this.times,this.values,this.getValueSize(),e)}}la.prototype.ValueTypeName="quaternion",la.prototype.InterpolantFactoryMethodSmooth=void 0;class ha extends mi{constructor(e,t,n){super(e,t,n)}}ha.prototype.ValueTypeName="string",ha.prototype.ValueBufferType=Array,ha.prototype.DefaultInterpolation=io,ha.prototype.InterpolantFactoryMethodLinear=void 0,ha.prototype.InterpolantFactoryMethodSmooth=void 0;class ua extends mi{constructor(e,t,n,s){super(e,t,n,s)}}ua.prototype.ValueTypeName="vector";class sl{constructor(e="",t=-1,n=[],s=ru){this.name=e,this.tracks=n,this.duration=t,this.blendMode=s,this.uuid=hi(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,s=1/(e.fps||1);for(let a=0,o=n.length;a!==o;++a)t.push(Fy(n[a]).scale(s));const r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r}static toJSON(e){const t=[],n=e.tracks,s={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let r=0,a=n.length;r!==a;++r)t.push(mi.toJSON(n[r]));return s}static CreateFromMorphTargetSequence(e,t,n,s){const r=t.length,a=[];for(let o=0;o<r;o++){let c=[],l=[];c.push((o+r-1)%r,o,(o+1)%r),l.push(0,1,0);const h=My(c);c=NA(c,1,h),l=NA(l,1,h),!s&&c[0]===0&&(c.push(r),l.push(l[0])),a.push(new ca(".morphTargetInfluences["+t[o].name+"]",c,l).scale(1/n))}return new this(e,-1,a)}static findByName(e,t){let n=e;if(!Array.isArray(e)){const s=e;n=s.geometry&&s.geometry.animations||s.animations}for(let s=0;s<n.length;s++)if(n[s].name===t)return n[s];return null}static CreateClipsFromMorphTargetSequences(e,t,n){const s={},r=/^([\w-]*?)([\d]+)$/;for(let o=0,c=e.length;o<c;o++){const l=e[o],h=l.name.match(r);if(h&&h.length>1){const u=h[1];let d=s[u];d||(s[u]=d=[]),d.push(l)}}const a=[];for(const o in s)a.push(this.CreateFromMorphTargetSequence(o,s[o],t,n));return a}static parseAnimation(e,t){if(console.warn("THREE.AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(u,d,f,m,A){if(f.length!==0){const g=[],p=[];FA(f,g,p,m),g.length!==0&&A.push(new u(d,g,p))}},s=[],r=e.name||"default",a=e.fps||30,o=e.blendMode;let c=e.length||-1;const l=e.hierarchy||[];for(let u=0;u<l.length;u++){const d=l[u].keys;if(!(!d||d.length===0))if(d[0].morphTargets){const f={};let m;for(m=0;m<d.length;m++)if(d[m].morphTargets)for(let A=0;A<d[m].morphTargets.length;A++)f[d[m].morphTargets[A]]=-1;for(const A in f){const g=[],p=[];for(let y=0;y!==d[m].morphTargets.length;++y){const b=d[m];g.push(b.time),p.push(b.morphTarget===A?1:0)}s.push(new ca(".morphTargetInfluence["+A+"]",g,p))}c=f.length*a}else{const f=".bones["+t[u].name+"]";n(ua,f+".position",d,"pos",s),n(la,f+".quaternion",d,"rot",s),n(ua,f+".scale",d,"scl",s)}}return s.length===0?null:new this(r,c,s,o)}resetDuration(){const e=this.tracks;let t=0;for(let n=0,s=e.length;n!==s;++n){const r=this.tracks[n];t=Math.max(t,r.times[r.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function Ny(i){switch(i.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return ca;case"vector":case"vector2":case"vector3":case"vector4":return ua;case"color":return LA;case"quaternion":return la;case"bool":case"boolean":return oa;case"string":return ha}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+i)}function Fy(i){if(i.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=Ny(i.type);if(i.times===void 0){const t=[],n=[];FA(i.keys,t,n,"value"),i.times=t,i.values=n}return e.parse!==void 0?e.parse(i):new e(i.name,i.times,i.values,i.interpolation)}const Zi={enabled:!1,files:{},add:function(i,e){this.enabled!==!1&&(this.files[i]=e)},get:function(i){if(this.enabled!==!1)return this.files[i]},remove:function(i){delete this.files[i]},clear:function(){this.files={}}};class PA{constructor(e,t,n){const s=this;let r=!1,a=0,o=0,c;const l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(h){o++,r===!1&&s.onStart!==void 0&&s.onStart(h,a,o),r=!0},this.itemEnd=function(h){a++,s.onProgress!==void 0&&s.onProgress(h,a,o),a===o&&(r=!1,s.onLoad!==void 0&&s.onLoad())},this.itemError=function(h){s.onError!==void 0&&s.onError(h)},this.resolveURL=function(h){return c?c(h):h},this.setURLModifier=function(h){return c=h,this},this.addHandler=function(h,u){return l.push(h,u),this},this.removeHandler=function(h){const u=l.indexOf(h);return u!==-1&&l.splice(u,2),this},this.getHandler=function(h){for(let u=0,d=l.length;u<d;u+=2){const f=l[u],m=l[u+1];if(f.global&&(f.lastIndex=0),f.test(h))return m}return null}}}const Dy=new PA;class $i{constructor(e){this.manager=e!==void 0?e:Dy,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const n=this;return new Promise(function(s,r){n.load(e,s,t,r)})}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}}$i.DEFAULT_MATERIAL_NAME="__DEFAULT";const es={};class Ly extends Error{constructor(e,t){super(e),this.response=t}}class Ts extends $i{constructor(e){super(e),this.mimeType="",this.responseType=""}load(e,t,n,s){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=Zi.get(e);if(r!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(r),this.manager.itemEnd(e)},0),r;if(es[e]!==void 0){es[e].push({onLoad:t,onProgress:n,onError:s});return}es[e]=[],es[e].push({onLoad:t,onProgress:n,onError:s});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),o=this.mimeType,c=this.responseType;fetch(a).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;const h=es[e],u=l.body.getReader(),d=l.headers.get("X-File-Size")||l.headers.get("Content-Length"),f=d?parseInt(d):0,m=f!==0;let A=0;const g=new ReadableStream({start(p){y();function y(){u.read().then(({done:b,value:E})=>{if(b)p.close();else{A+=E.byteLength;const M=new ProgressEvent("progress",{lengthComputable:m,loaded:A,total:f});for(let w=0,S=h.length;w<S;w++){const T=h[w];T.onProgress&&T.onProgress(M)}p.enqueue(E),y()}},b=>{p.error(b)})}}});return new Response(g)}else throw new Ly(`fetch for "${l.url}" responded with ${l.status}: ${l.statusText}`,l)}).then(l=>{switch(c){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(h=>new DOMParser().parseFromString(h,o));case"json":return l.json();default:if(o==="")return l.text();{const u=/charset="?([^;"\s]*)"?/i.exec(o),d=u&&u[1]?u[1].toLowerCase():void 0,f=new TextDecoder(d);return l.arrayBuffer().then(m=>f.decode(m))}}}).then(l=>{Zi.add(e,l);const h=es[e];delete es[e];for(let u=0,d=h.length;u<d;u++){const f=h[u];f.onLoad&&f.onLoad(l)}}).catch(l=>{const h=es[e];if(h===void 0)throw this.manager.itemError(e),l;delete es[e];for(let u=0,d=h.length;u<d;u++){const f=h[u];f.onError&&f.onError(l)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class Py extends $i{constructor(e){super(e)}load(e,t,n,s){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,a=Zi.get(e);if(a!==void 0)return r.manager.itemStart(e),setTimeout(function(){t&&t(a),r.manager.itemEnd(e)},0),a;const o=oo("img");function c(){h(),Zi.add(e,this),t&&t(this),r.manager.itemEnd(e)}function l(u){h(),s&&s(u),r.manager.itemError(e),r.manager.itemEnd(e)}function h(){o.removeEventListener("load",c,!1),o.removeEventListener("error",l,!1)}return o.addEventListener("load",c,!1),o.addEventListener("error",l,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),r.manager.itemStart(e),o.src=e,o}}class ky extends $i{constructor(e){super(e)}load(e,t,n,s){const r=this,a=new Wc,o=new Ts(this.manager);return o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setPath(this.path),o.setWithCredentials(r.withCredentials),o.load(e,function(c){let l;try{l=r.parse(c)}catch(h){if(s!==void 0)s(h);else{console.error(h);return}}l.image!==void 0?a.image=l.image:l.data!==void 0&&(a.image.width=l.width,a.image.height=l.height,a.image.data=l.data),a.wrapS=l.wrapS!==void 0?l.wrapS:ci,a.wrapT=l.wrapT!==void 0?l.wrapT:ci,a.magFilter=l.magFilter!==void 0?l.magFilter:zt,a.minFilter=l.minFilter!==void 0?l.minFilter:zt,a.anisotropy=l.anisotropy!==void 0?l.anisotropy:1,l.colorSpace!==void 0&&(a.colorSpace=l.colorSpace),l.flipY!==void 0&&(a.flipY=l.flipY),l.format!==void 0&&(a.format=l.format),l.type!==void 0&&(a.type=l.type),l.mipmaps!==void 0&&(a.mipmaps=l.mipmaps,a.minFilter=Zn),l.mipmapCount===1&&(a.minFilter=zt),l.generateMipmaps!==void 0&&(a.generateMipmaps=l.generateMipmaps),a.needsUpdate=!0,t&&t(a,l)},n,s),a}}class Uy extends $i{constructor(e){super(e)}load(e,t,n,s){const r=new an,a=new Py(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(o){r.image=o,r.needsUpdate=!0,t!==void 0&&t(r)},n,s),r}}class _o extends Pt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new qe(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(t.object.target=this.target.uuid),t}}class Oy extends _o{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Pt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new qe(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}}const Hu=new $e,kA=new H,UA=new H;class zu{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Ze(512,512),this.mapType=tn,this.map=null,this.mapPass=null,this.matrix=new $e,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new ku,this._frameExtents=new Ze(1,1),this._viewportCount=1,this._viewports=[new Et(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;kA.setFromMatrixPosition(e.matrixWorld),t.position.copy(kA),UA.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(UA),t.updateMatrixWorld(),Hu.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Hu),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Hu)}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}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class Qy extends zu{constructor(){super(new Cn(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,n=Vr*2*e.angle*this.focus,s=this.mapSize.width/this.mapSize.height,r=e.distance||t.far;(n!==t.fov||s!==t.aspect||r!==t.far)&&(t.fov=n,t.aspect=s,t.far=r,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class Gy extends _o{constructor(e,t,n=0,s=Math.PI/3,r=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Pt.DEFAULT_UP),this.updateMatrix(),this.target=new Pt,this.distance=n,this.angle=s,this.penumbra=r,this.decay=a,this.map=null,this.shadow=new Qy}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}const OA=new $e,Eo=new H,Vu=new H;class Hy extends zu{constructor(){super(new Cn(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Ze(4,2),this._viewportCount=6,this._viewports=[new Et(2,1,1,1),new Et(0,1,1,1),new Et(3,1,1,1),new Et(1,1,1,1),new Et(3,0,1,1),new Et(1,0,1,1)],this._cubeDirections=[new H(1,0,0),new H(-1,0,0),new H(0,0,1),new H(0,0,-1),new H(0,1,0),new H(0,-1,0)],this._cubeUps=[new H(0,1,0),new H(0,1,0),new H(0,1,0),new H(0,1,0),new H(0,0,1),new H(0,0,-1)]}updateMatrices(e,t=0){const n=this.camera,s=this.matrix,r=e.distance||n.far;r!==n.far&&(n.far=r,n.updateProjectionMatrix()),Eo.setFromMatrixPosition(e.matrixWorld),n.position.copy(Eo),Vu.copy(n.position),Vu.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(Vu),n.updateMatrixWorld(),s.makeTranslation(-Eo.x,-Eo.y,-Eo.z),OA.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(OA)}}class QA extends _o{constructor(e,t,n=0,s=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=s,this.shadow=new Hy}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}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}}class Wu extends uA{constructor(e=-1,t=1,n=1,s=-1,r=.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=s,this.near=r,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,s,r,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=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,s=(this.top+this.bottom)/2;let r=n-e,a=n+e,o=s+t,c=s-t;if(this.view!==null&&this.view.enabled){const l=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=l*this.view.offsetX,a=r+l*this.view.width,o-=h*this.view.offsetY,c=o-h*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,c,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const 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}}class zy extends zu{constructor(){super(new Wu(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class GA extends _o{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Pt.DEFAULT_UP),this.updateMatrix(),this.target=new Pt,this.shadow=new zy}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class Vy extends _o{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class da{static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}class Wy extends $i{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,n,s){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,a=Zi.get(e);if(a!==void 0){if(r.manager.itemStart(e),a.then){a.then(l=>{t&&t(l),r.manager.itemEnd(e)}).catch(l=>{s&&s(l)});return}return setTimeout(function(){t&&t(a),r.manager.itemEnd(e)},0),a}const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader;const c=fetch(e,o).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign(r.options,{colorSpaceConversion:"none"}))}).then(function(l){return Zi.add(e,l),t&&t(l),r.manager.itemEnd(e),l}).catch(function(l){s&&s(l),Zi.remove(e),r.manager.itemError(e),r.manager.itemEnd(e)});Zi.add(e,c),r.manager.itemStart(e)}}class qy extends Cn{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class Ky{constructor(e,t,n){this.binding=e,this.valueSize=n;let s,r,a;switch(t){case"quaternion":s=this._slerp,r=this._slerpAdditive,a=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":s=this._select,r=this._select,a=this._setAdditiveIdentityOther,this.buffer=new Array(n*5);break;default:s=this._lerp,r=this._lerpAdditive,a=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=s,this._mixBufferRegionAdditive=r,this._setIdentity=a,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){const n=this.buffer,s=this.valueSize,r=e*s+s;let a=this.cumulativeWeight;if(a===0){for(let o=0;o!==s;++o)n[r+o]=n[o];a=t}else{a+=t;const o=t/a;this._mixBufferRegion(n,r,0,o,s)}this.cumulativeWeight=a}accumulateAdditive(e){const t=this.buffer,n=this.valueSize,s=n*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,s,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){const t=this.valueSize,n=this.buffer,s=e*t+t,r=this.cumulativeWeight,a=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){const c=t*this._origIndex;this._mixBufferRegion(n,s,c,1-r,t)}a>0&&this._mixBufferRegionAdditive(n,s,this._addIndex*t,1,t);for(let c=t,l=t+t;c!==l;++c)if(n[c]!==n[c+t]){o.setValue(n,s);break}}saveOriginalState(){const e=this.binding,t=this.buffer,n=this.valueSize,s=n*this._origIndex;e.getValue(t,s);for(let r=n,a=s;r!==a;++r)t[r]=t[s+r%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n<t;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[t+n]=this.buffer[e+n]}_select(e,t,n,s,r){if(s>=.5)for(let a=0;a!==r;++a)e[t+a]=e[n+a]}_slerp(e,t,n,s){Wn.slerpFlat(e,t,e,t,e,n,s)}_slerpAdditive(e,t,n,s,r){const a=this._workIndex*r;Wn.multiplyQuaternionsFlat(e,a,e,t,e,n),Wn.slerpFlat(e,t,e,t,e,a,s)}_lerp(e,t,n,s,r){const a=1-s;for(let o=0;o!==r;++o){const c=t+o;e[c]=e[c]*a+e[n+o]*s}}_lerpAdditive(e,t,n,s,r){for(let a=0;a!==r;++a){const o=t+a;e[o]=e[o]+e[n+a]*s}}}const qu="\\[\\]\\.:\\/",jy=new RegExp("["+qu+"]","g"),Ku="[^"+qu+"]",Xy="[^"+qu.replace("\\.","")+"]",Yy=/((?:WC+[\/:])*)/.source.replace("WC",Ku),Jy=/(WCOD+)?/.source.replace("WCOD",Xy),Zy=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Ku),$y=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Ku),ew=new RegExp("^"+Yy+Jy+Zy+$y+"$"),tw=["material","materials","bones","map"];class nw{constructor(e,t,n){const s=n||vt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,s)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,s=this._bindings[n];s!==void 0&&s.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let s=this._targetGroup.nCachedObjects_,r=n.length;s!==r;++s)n[s].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class vt{constructor(e,t,n){this.path=t,this.parsedPath=n||vt.parseTrackName(t),this.node=vt.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new vt.Composite(e,t,n):new vt(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(jy,"")}static parseTrackName(e){const t=ew.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},s=n.nodeName&&n.nodeName.lastIndexOf(".");if(s!==void 0&&s!==-1){const r=n.nodeName.substring(s+1);tw.indexOf(r)!==-1&&(n.nodeName=n.nodeName.substring(0,s),n.objectName=r)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){const n=function(r){for(let a=0;a<r.length;a++){const o=r[a];if(o.name===t||o.uuid===t)return o;const c=n(o.children);if(c)return c}return null},s=n(e.children);if(s)return s}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)e[t++]=n[s]}_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){const n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=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 e=this.node;const t=this.parsedPath,n=t.objectName,s=t.propertyName;let r=t.propertyIndex;if(e||(e=vt.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let l=t.objectIndex;switch(n){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let h=0;h<e.length;h++)if(e[h].name===l){l=h;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(l!==void 0){if(e[l]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[l]}}const a=e[s];if(a===void 0){const l=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+l+"."+s+" but it wasn't found.",e);return}let o=this.Versioning.None;this.targetObject=e,e.isMaterial===!0?o=this.Versioning.NeedsUpdate:e.isObject3D===!0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(r!==void 0){if(s==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[r]!==void 0&&(r=e.morphTargetDictionary[r])}c=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=r}else a.fromArray!==void 0&&a.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(c=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=s;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}vt.Composite=nw,vt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},vt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},vt.prototype.GetterByBindingType=[vt.prototype._getValue_direct,vt.prototype._getValue_array,vt.prototype._getValue_arrayElement,vt.prototype._getValue_toArray],vt.prototype.SetterByBindingTypeAndVersioning=[[vt.prototype._setValue_direct,vt.prototype._setValue_direct_setNeedsUpdate,vt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[vt.prototype._setValue_array,vt.prototype._setValue_array_setNeedsUpdate,vt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[vt.prototype._setValue_arrayElement,vt.prototype._setValue_arrayElement_setNeedsUpdate,vt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[vt.prototype._setValue_fromArray,vt.prototype._setValue_fromArray_setNeedsUpdate,vt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class iw{constructor(e,t,n=null,s=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=s;const r=t.tracks,a=r.length,o=new Array(a),c={endingStart:Gr,endingEnd:Gr};for(let l=0;l!==a;++l){const h=r[l].createInterpolant(null);o[l]=h,h.settings=c}this._interpolantSettings=c,this._interpolants=o,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=Fp,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n=!1){if(e.fadeOut(t),this.fadeIn(t),n===!0){const s=this._clip.duration,r=e._clip.duration,a=r/s,o=s/r;e.warp(1,a,t),this.warp(o,1,t)}return this}crossFadeTo(e,t,n=!1){return e.crossFadeFrom(this,t,n)}stopFading(){const e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){const s=this._mixer,r=s.time,a=this.timeScale;let o=this._timeScaleInterpolant;o===null&&(o=s._lendControlInterpolant(),this._timeScaleInterpolant=o);const c=o.parameterPositions,l=o.sampleValues;return c[0]=r,c[1]=r+n,l[0]=e/a,l[1]=t/a,this}stopWarping(){const e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,s){if(!this.enabled){this._updateWeight(e);return}const r=this._startTime;if(r!==null){const c=(e-r)*n;c<0||n===0?t=0:(this._startTime=null,t=n*c)}t*=this._updateTimeScale(e);const a=this._updateTime(t),o=this._updateWeight(e);if(o>0){const c=this._interpolants,l=this._propertyBindings;switch(this.blendMode){case hE:for(let h=0,u=c.length;h!==u;++h)c[h].evaluate(a),l[h].accumulateAdditive(o);break;case ru:default:for(let h=0,u=c.length;h!==u;++h)c[h].evaluate(a),l[h].accumulate(s,o)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const n=this._weightInterpolant;if(n!==null){const s=n.evaluate(e)[0];t*=s,e>n.parameterPositions[1]&&(this.stopFading(),s===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const n=this._timeScaleInterpolant;if(n!==null){const s=n.evaluate(e)[0];t*=s,e>n.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,n=this.loop;let s=this.time+e,r=this._loopCount;const a=n===lE;if(e===0)return r===-1?s:a&&(r&1)===1?t-s:s;if(n===Np){r===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(s>=t)s=t;else if(s<0)s=0;else{this.time=s;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=s,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(r===-1&&(e>=0?(r=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),s>=t||s<0){const o=Math.floor(s/t);s-=t*o,r+=Math.abs(o);const c=this.repetitions-r;if(c<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,s=e>0?t:0,this.time=s,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(c===1){const l=e<0;this._setEndings(l,!l,a)}else this._setEndings(!1,!1,a);this._loopCount=r,this.time=s,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=s;if(a&&(r&1)===1)return t-s}return s}_setEndings(e,t,n){const s=this._interpolantSettings;n?(s.endingStart=Hr,s.endingEnd=Hr):(e?s.endingStart=this.zeroSlopeAtStart?Hr:Gr:s.endingStart=vc,t?s.endingEnd=this.zeroSlopeAtEnd?Hr:Gr:s.endingEnd=vc)}_scheduleFading(e,t,n){const s=this._mixer,r=s.time;let a=this._weightInterpolant;a===null&&(a=s._lendControlInterpolant(),this._weightInterpolant=a);const o=a.parameterPositions,c=a.sampleValues;return o[0]=r,c[0]=t,o[1]=r+e,c[1]=n,this}}const sw=new Float32Array(1);class HA extends _s{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const n=e._localRoot||this._root,s=e._clip.tracks,r=s.length,a=e._propertyBindings,o=e._interpolants,c=n.uuid,l=this._bindingsByRootAndName;let h=l[c];h===void 0&&(h={},l[c]=h);for(let u=0;u!==r;++u){const d=s[u],f=d.name;let m=h[f];if(m!==void 0)++m.referenceCount,a[u]=m;else{if(m=a[u],m!==void 0){m._cacheIndex===null&&(++m.referenceCount,this._addInactiveBinding(m,c,f));continue}const A=t&&t._propertyBindings[u].binding.parsedPath;m=new Ky(vt.create(n,f,A),d.ValueTypeName,d.getValueSize()),++m.referenceCount,this._addInactiveBinding(m,c,f),a[u]=m}o[u].resultBuffer=m.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const n=(e._localRoot||this._root).uuid,s=e._clip.uuid,r=this._actionsByClip[s];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,s,n)}const t=e._propertyBindings;for(let n=0,s=t.length;n!==s;++n){const r=t[n];r.useCount++===0&&(this._lendBinding(r),r.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let n=0,s=t.length;n!==s;++n){const r=t[n];--r.useCount===0&&(r.restoreOriginalState(),this._takeBackBinding(r))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,n){const s=this._actions,r=this._actionsByClip;let a=r[t];if(a===void 0)a={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,r[t]=a;else{const o=a.knownActions;e._byClipCacheIndex=o.length,o.push(e)}e._cacheIndex=s.length,s.push(e),a.actionByRoot[n]=e}_removeInactiveAction(e){const t=this._actions,n=t[t.length-1],s=e._cacheIndex;n._cacheIndex=s,t[s]=n,t.pop(),e._cacheIndex=null;const r=e._clip.uuid,a=this._actionsByClip,o=a[r],c=o.knownActions,l=c[c.length-1],h=e._byClipCacheIndex;l._byClipCacheIndex=h,c[h]=l,c.pop(),e._byClipCacheIndex=null;const u=o.actionByRoot,d=(e._localRoot||this._root).uuid;delete u[d],c.length===0&&delete a[r],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){const t=e._propertyBindings;for(let n=0,s=t.length;n!==s;++n){const r=t[n];--r.referenceCount===0&&this._removeInactiveBinding(r)}}_lendAction(e){const t=this._actions,n=e._cacheIndex,s=this._nActiveActions++,r=t[s];e._cacheIndex=s,t[s]=e,r._cacheIndex=n,t[n]=r}_takeBackAction(e){const t=this._actions,n=e._cacheIndex,s=--this._nActiveActions,r=t[s];e._cacheIndex=s,t[s]=e,r._cacheIndex=n,t[n]=r}_addInactiveBinding(e,t,n){const s=this._bindingsByRootAndName,r=this._bindings;let a=s[t];a===void 0&&(a={},s[t]=a),a[n]=e,e._cacheIndex=r.length,r.push(e)}_removeInactiveBinding(e){const t=this._bindings,n=e.binding,s=n.rootNode.uuid,r=n.path,a=this._bindingsByRootAndName,o=a[s],c=t[t.length-1],l=e._cacheIndex;c._cacheIndex=l,t[l]=c,t.pop(),delete o[r],Object.keys(o).length===0&&delete a[s]}_lendBinding(e){const t=this._bindings,n=e._cacheIndex,s=this._nActiveBindings++,r=t[s];e._cacheIndex=s,t[s]=e,r._cacheIndex=n,t[n]=r}_takeBackBinding(e){const t=this._bindings,n=e._cacheIndex,s=--this._nActiveBindings,r=t[s];e._cacheIndex=s,t[s]=e,r._cacheIndex=n,t[n]=r}_lendControlInterpolant(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let n=e[t];return n===void 0&&(n=new DA(new Float32Array(2),new Float32Array(2),1,sw),n.__cacheIndex=t,e[t]=n),n}_takeBackControlInterpolant(e){const t=this._controlInterpolants,n=e.__cacheIndex,s=--this._nActiveControlInterpolants,r=t[s];e.__cacheIndex=s,t[s]=e,r.__cacheIndex=n,t[n]=r}clipAction(e,t,n){const s=t||this._root,r=s.uuid;let a=typeof e=="string"?sl.findByName(s,e):e;const o=a!==null?a.uuid:e,c=this._actionsByClip[o];let l=null;if(n===void 0&&(a!==null?n=a.blendMode:n=ru),c!==void 0){const u=c.actionByRoot[r];if(u!==void 0&&u.blendMode===n)return u;l=c.knownActions[0],a===null&&(a=l._clip)}if(a===null)return null;const h=new iw(this,a,t,n);return this._bindAction(h,l),this._addInactiveAction(h,o,r),h}existingAction(e,t){const n=t||this._root,s=n.uuid,r=typeof e=="string"?sl.findByName(n,e):e,a=r?r.uuid:e,o=this._actionsByClip[a];return o!==void 0&&o.actionByRoot[s]||null}stopAllAction(){const e=this._actions,t=this._nActiveActions;for(let n=t-1;n>=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;const t=this._actions,n=this._nActiveActions,s=this.time+=e,r=Math.sign(e),a=this._accuIndex^=1;for(let l=0;l!==n;++l)t[l]._update(s,e,r,a);const o=this._bindings,c=this._nActiveBindings;for(let l=0;l!==c;++l)o[l].apply(a);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){const t=this._actions,n=e.uuid,s=this._actionsByClip,r=s[n];if(r!==void 0){const a=r.knownActions;for(let o=0,c=a.length;o!==c;++o){const l=a[o];this._deactivateAction(l);const h=l._cacheIndex,u=t[t.length-1];l._cacheIndex=null,l._byClipCacheIndex=null,u._cacheIndex=h,t[h]=u,t.pop(),this._removeInactiveBindingsForAction(l)}delete s[n]}}uncacheRoot(e){const t=e.uuid,n=this._actionsByClip;for(const a in n){const o=n[a].actionByRoot,c=o[t];c!==void 0&&(this._deactivateAction(c),this._removeInactiveAction(c))}const s=this._bindingsByRootAndName,r=s[t];if(r!==void 0)for(const a in r){const o=r[a];o.restoreOriginalState(),this._removeInactiveBinding(o)}}uncacheAction(e,t){const n=this.existingAction(e,t);n!==null&&(this._deactivateAction(n),this._removeInactiveAction(n))}}class zA{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(){return this.phi=at(this.phi,1e-6,Math.PI-1e-6),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(at(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const Rs=new H,rl=new $e,ju=new $e;class rw extends Zc{constructor(e){const t=VA(e),n=new Qn,s=[],r=[],a=new qe(0,0,1),o=new qe(0,1,0);for(let l=0;l<t.length;l++){const h=t[l];h.parent&&h.parent.isBone&&(s.push(0,0,0),s.push(0,0,0),r.push(a.r,a.g,a.b),r.push(o.r,o.g,o.b))}n.setAttribute("position",new Tn(s,3)),n.setAttribute("color",new Tn(r,3));const c=new go({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(n,c),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(e){const t=this.bones,n=this.geometry,s=n.getAttribute("position");ju.copy(this.root.matrixWorld).invert();for(let r=0,a=0;r<t.length;r++){const o=t[r];o.parent&&o.parent.isBone&&(rl.multiplyMatrices(ju,o.matrixWorld),Rs.setFromMatrixPosition(rl),s.setXYZ(a,Rs.x,Rs.y,Rs.z),rl.multiplyMatrices(ju,o.parent.matrixWorld),Rs.setFromMatrixPosition(rl),s.setXYZ(a+1,Rs.x,Rs.y,Rs.z),a+=2)}n.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose()}}function VA(i){const e=[];i.isBone===!0&&e.push(i);for(let t=0;t<i.children.length;t++)e.push(...VA(i.children[t]));return e}class aw extends Zc{constructor(e=10,t=10,n=4473924,s=8947848){n=new qe(n),s=new qe(s);const r=t/2,a=e/t,o=e/2,c=[],l=[];for(let d=0,f=0,m=-o;d<=t;d++,m+=a){c.push(-o,0,m,o,0,m),c.push(m,0,-o,m,0,o);const A=d===r?n:s;A.toArray(l,f),f+=3,A.toArray(l,f),f+=3,A.toArray(l,f),f+=3,A.toArray(l,f),f+=3}const h=new Qn;h.setAttribute("position",new Tn(c,3)),h.setAttribute("color",new Tn(l,3));const u=new go({vertexColors:!0,toneMapped:!1});super(h,u),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class WA extends Zc{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],s=new Qn;s.setAttribute("position",new Tn(t,3)),s.setAttribute("color",new Tn(n,3));const r=new go({vertexColors:!0,toneMapped:!1});super(s,r),this.type="AxesHelper"}setColors(e,t,n){const s=new qe,r=this.geometry.attributes.color.array;return s.set(e),s.toArray(r,0),s.toArray(r,3),s.set(t),s.toArray(r,6),s.toArray(r,9),s.set(n),s.toArray(r,12),s.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class ow extends _s{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(e===void 0){console.warn("THREE.Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function qA(i,e,t,n){const s=cw(n);switch(t){case Bp:return i*e;case zi:return i*e/s.components*s.byteLength;case kh:return i*e/s.components*s.byteLength;case Zs:return i*e*2/s.components*s.byteLength;case Uh:return i*e*2/s.components*s.byteLength;case Tp:return i*e*3/s.components*s.byteLength;case sn:return i*e*4/s.components*s.byteLength;case Oh:return i*e*4/s.components*s.byteLength;case gc:case Za:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case mc:case $a:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Qh:case Gh:return Math.max(i,16)*Math.max(e,8)/4;case bc:case xc:return Math.max(i,8)*Math.max(e,8)/2;case _c:case Ec:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case yc:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case eo:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Hh:return Math.floor((i+4)/5)*Math.floor((e+3)/4)*16;case zh:return Math.floor((i+4)/5)*Math.floor((e+4)/5)*16;case Vh:return Math.floor((i+5)/6)*Math.floor((e+4)/5)*16;case to:return Math.floor((i+5)/6)*Math.floor((e+5)/6)*16;case Wh:return Math.floor((i+7)/8)*Math.floor((e+4)/5)*16;case qh:return Math.floor((i+7)/8)*Math.floor((e+5)/6)*16;case Kh:return Math.floor((i+7)/8)*Math.floor((e+7)/8)*16;case jh:return Math.floor((i+9)/10)*Math.floor((e+4)/5)*16;case Xh:return Math.floor((i+9)/10)*Math.floor((e+5)/6)*16;case Yh:return Math.floor((i+9)/10)*Math.floor((e+7)/8)*16;case Jh:return Math.floor((i+9)/10)*Math.floor((e+9)/10)*16;case Zh:return Math.floor((i+11)/12)*Math.floor((e+9)/10)*16;case $h:return Math.floor((i+11)/12)*Math.floor((e+11)/12)*16;case no:case eu:case wc:return Math.ceil(i/4)*Math.ceil(e/4)*16;case Rp:case tu:return Math.ceil(i/4)*Math.ceil(e/4)*8;case nu:case iu:return Math.ceil(i/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function cw(i){switch(i){case tn:case Sp:return{byteLength:1,components:1};case ja:case Ip:case Bn:return{byteLength:2,components:1};case Lh:case Ph:return{byteLength:2,components:4};case Js:case Dh:case nn:return{byteLength:4,components:1};case Mp:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${i}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:dc}})),typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=dc);function KA(){let i=null,e=!1,t=null,n=null;function s(r,a){t(r,a),n=i.requestAnimationFrame(s)}return{start:function(){e!==!0&&t!==null&&(n=i.requestAnimationFrame(s),e=!0)},stop:function(){i.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(r){t=r},setContext:function(r){i=r}}}function lw(i){const e=new WeakMap;function t(o,c){const l=o.array,h=o.usage,u=l.byteLength,d=i.createBuffer();i.bindBuffer(c,d),i.bufferData(c,l,h),o.onUploadCallback();let f;if(l instanceof Float32Array)f=i.FLOAT;else if(l instanceof Uint16Array)o.isFloat16BufferAttribute?f=i.HALF_FLOAT:f=i.UNSIGNED_SHORT;else if(l instanceof Int16Array)f=i.SHORT;else if(l instanceof Uint32Array)f=i.UNSIGNED_INT;else if(l instanceof Int32Array)f=i.INT;else if(l instanceof Int8Array)f=i.BYTE;else if(l instanceof Uint8Array)f=i.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)f=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:d,type:f,bytesPerElement:l.BYTES_PER_ELEMENT,version:o.version,size:u}}function n(o,c,l){const h=c.array,u=c.updateRanges;if(i.bindBuffer(l,o),u.length===0)i.bufferSubData(l,0,h);else{u.sort((f,m)=>f.start-m.start);let d=0;for(let f=1;f<u.length;f++){const m=u[d],A=u[f];A.start<=m.start+m.count+1?m.count=Math.max(m.count,A.start+A.count-m.start):(++d,u[d]=A)}u.length=d+1;for(let f=0,m=u.length;f<m;f++){const A=u[f];i.bufferSubData(l,A.start*h.BYTES_PER_ELEMENT,h,A.start,A.count)}c.clearUpdateRanges()}c.onUploadCallback()}function s(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function r(o){o.isInterleavedBufferAttribute&&(o=o.data);const c=e.get(o);c&&(i.deleteBuffer(c.buffer),e.delete(o))}function a(o,c){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const h=e.get(o);(!h||h.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}const l=e.get(o);if(l===void 0)e.set(o,t(o,c));else if(l.version<o.version){if(l.size!==o.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");n(l.buffer,o,c),l.version=o.version}}return{get:s,remove:r,update:a}}var hw=`#ifdef USE_ALPHAHASH+ if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;+#endif`,uw=`#ifdef USE_ALPHAHASH+ const float ALPHA_HASH_SCALE = 0.05;+ float hash2D( vec2 value ) {+ return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );+ }+ float hash3D( vec3 value ) {+ return hash2D( vec2( hash2D( value.xy ), value.z ) );+ }+ float getAlphaHashThreshold( vec3 position ) {+ float maxDeriv = max(+ length( dFdx( position.xyz ) ),+ length( dFdy( position.xyz ) )+ );+ float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );+ vec2 pixScales = vec2(+ exp2( floor( log2( pixScale ) ) ),+ exp2( ceil( log2( pixScale ) ) )+ );+ vec2 alpha = vec2(+ hash3D( floor( pixScales.x * position.xyz ) ),+ hash3D( floor( pixScales.y * position.xyz ) )+ );+ float lerpFactor = fract( log2( pixScale ) );+ float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;+ float a = min( lerpFactor, 1.0 - lerpFactor );+ vec3 cases = vec3(+ x * x / ( 2.0 * a * ( 1.0 - a ) ),+ ( x - 0.5 * a ) / ( 1.0 - a ),+ 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )+ );+ float threshold = ( x < ( 1.0 - a ) )+ ? ( ( x < a ) ? cases.x : cases.y )+ : cases.z;+ return clamp( threshold , 1.0e-6, 1.0 );+ }+#endif`,dw=`#ifdef USE_ALPHAMAP+ diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;+#endif`,fw=`#ifdef USE_ALPHAMAP+ uniform sampler2D alphaMap;+#endif`,pw=`#ifdef USE_ALPHATEST+ #ifdef ALPHA_TO_COVERAGE+ diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );+ if ( diffuseColor.a == 0.0 ) discard;+ #else+ if ( diffuseColor.a < alphaTest ) discard;+ #endif+#endif`,Aw=`#ifdef USE_ALPHATEST+ uniform float alphaTest;+#endif`,gw=`#ifdef USE_AOMAP+ float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;+ reflectedLight.indirectDiffuse *= ambientOcclusion;+ #if defined( USE_CLEARCOAT )+ clearcoatSpecularIndirect *= ambientOcclusion;+ #endif+ #if defined( USE_SHEEN )+ sheenSpecularIndirect *= ambientOcclusion;+ #endif+ #if defined( USE_ENVMAP ) && defined( STANDARD )+ float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );+ reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );+ #endif+#endif`,mw=`#ifdef USE_AOMAP+ uniform sampler2D aoMap;+ uniform float aoMapIntensity;+#endif`,bw=`#ifdef USE_BATCHING+ #if ! defined( GL_ANGLE_multi_draw )+ #define gl_DrawID _gl_DrawID+ uniform int _gl_DrawID;+ #endif+ uniform highp sampler2D batchingTexture;+ uniform highp usampler2D batchingIdTexture;+ mat4 getBatchingMatrix( const in float i ) {+ int size = textureSize( batchingTexture, 0 ).x;+ int j = int( i ) * 4;+ int x = j % size;+ int y = j / size;+ vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );+ vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );+ vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );+ vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );+ return mat4( v1, v2, v3, v4 );+ }+ float getIndirectIndex( const in int i ) {+ int size = textureSize( batchingIdTexture, 0 ).x;+ int x = i % size;+ int y = i / size;+ return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );+ }+#endif+#ifdef USE_BATCHING_COLOR+ uniform sampler2D batchingColorTexture;+ vec3 getBatchingColor( const in float i ) {+ int size = textureSize( batchingColorTexture, 0 ).x;+ int j = int( i );+ int x = j % size;+ int y = j / size;+ return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;+ }+#endif`,xw=`#ifdef USE_BATCHING+ mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );+#endif`,_w=`vec3 transformed = vec3( position );+#ifdef USE_ALPHAHASH+ vPosition = vec3( position );+#endif`,Ew=`vec3 objectNormal = vec3( normal );+#ifdef USE_TANGENT+ vec3 objectTangent = vec3( tangent.xyz );+#endif`,yw=`float G_BlinnPhong_Implicit( ) {+ return 0.25;+}+float D_BlinnPhong( const in float shininess, const in float dotNH ) {+ return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );+}+vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {+ vec3 halfDir = normalize( lightDir + viewDir );+ float dotNH = saturate( dot( normal, halfDir ) );+ float dotVH = saturate( dot( viewDir, halfDir ) );+ vec3 F = F_Schlick( specularColor, 1.0, dotVH );+ float G = G_BlinnPhong_Implicit( );+ float D = D_BlinnPhong( shininess, dotNH );+ return F * ( G * D );+} // validated`,ww=`#ifdef USE_IRIDESCENCE+ const mat3 XYZ_TO_REC709 = mat3(+ 3.2404542, -0.9692660, 0.0556434,+ -1.5371385, 1.8760108, -0.2040259,+ -0.4985314, 0.0415560, 1.0572252+ );+ vec3 Fresnel0ToIor( vec3 fresnel0 ) {+ vec3 sqrtF0 = sqrt( fresnel0 );+ return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );+ }+ vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {+ return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );+ }+ float IorToFresnel0( float transmittedIor, float incidentIor ) {+ return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));+ }+ vec3 evalSensitivity( float OPD, vec3 shift ) {+ float phase = 2.0 * PI * OPD * 1.0e-9;+ vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );+ vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );+ vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );+ vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );+ xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );+ xyz /= 1.0685e-7;+ vec3 rgb = XYZ_TO_REC709 * xyz;+ return rgb;+ }+ vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {+ vec3 I;+ float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );+ float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );+ float cosTheta2Sq = 1.0 - sinTheta2Sq;+ if ( cosTheta2Sq < 0.0 ) {+ return vec3( 1.0 );+ }+ float cosTheta2 = sqrt( cosTheta2Sq );+ float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );+ float R12 = F_Schlick( R0, 1.0, cosTheta1 );+ float T121 = 1.0 - R12;+ float phi12 = 0.0;+ if ( iridescenceIOR < outsideIOR ) phi12 = PI;+ float phi21 = PI - phi12;+ vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );+ vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );+ vec3 phi23 = vec3( 0.0 );+ if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;+ if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;+ if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;+ float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;+ vec3 phi = vec3( phi21 ) + phi23;+ vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );+ vec3 r123 = sqrt( R123 );+ vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );+ vec3 C0 = R12 + Rs;+ I = C0;+ vec3 Cm = Rs - T121;+ for ( int m = 1; m <= 2; ++ m ) {+ Cm *= r123;+ vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );+ I += Cm * Sm;+ }+ return max( I, vec3( 0.0 ) );+ }+#endif`,vw=`#ifdef USE_BUMPMAP+ uniform sampler2D bumpMap;+ uniform float bumpScale;+ vec2 dHdxy_fwd() {+ vec2 dSTdx = dFdx( vBumpMapUv );+ vec2 dSTdy = dFdy( vBumpMapUv );+ float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;+ float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;+ float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;+ return vec2( dBx, dBy );+ }+ vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {+ vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );+ vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );+ vec3 vN = surf_norm;+ vec3 R1 = cross( vSigmaY, vN );+ vec3 R2 = cross( vN, vSigmaX );+ float fDet = dot( vSigmaX, R1 ) * faceDirection;+ vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );+ return normalize( abs( fDet ) * surf_norm - vGrad );+ }+#endif`,Cw=`#if NUM_CLIPPING_PLANES > 0+ vec4 plane;+ #ifdef ALPHA_TO_COVERAGE+ float distanceToPlane, distanceGradient;+ float clipOpacity = 1.0;+ #pragma unroll_loop_start+ for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {+ plane = clippingPlanes[ i ];+ distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;+ distanceGradient = fwidth( distanceToPlane ) / 2.0;+ clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );+ if ( clipOpacity == 0.0 ) discard;+ }+ #pragma unroll_loop_end+ #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES+ float unionClipOpacity = 1.0;+ #pragma unroll_loop_start+ for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {+ plane = clippingPlanes[ i ];+ distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;+ distanceGradient = fwidth( distanceToPlane ) / 2.0;+ unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );+ }+ #pragma unroll_loop_end+ clipOpacity *= 1.0 - unionClipOpacity;+ #endif+ diffuseColor.a *= clipOpacity;+ if ( diffuseColor.a == 0.0 ) discard;+ #else+ #pragma unroll_loop_start+ for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {+ plane = clippingPlanes[ i ];+ if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;+ }+ #pragma unroll_loop_end+ #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES+ bool clipped = true;+ #pragma unroll_loop_start+ for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {+ plane = clippingPlanes[ i ];+ clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;+ }+ #pragma unroll_loop_end+ if ( clipped ) discard;+ #endif+ #endif+#endif`,Sw=`#if NUM_CLIPPING_PLANES > 0+ varying vec3 vClipPosition;+ uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];+#endif`,Iw=`#if NUM_CLIPPING_PLANES > 0+ varying vec3 vClipPosition;+#endif`,Mw=`#if NUM_CLIPPING_PLANES > 0+ vClipPosition = - mvPosition.xyz;+#endif`,Bw=`#if defined( USE_COLOR_ALPHA )+ diffuseColor *= vColor;+#elif defined( USE_COLOR )+ diffuseColor.rgb *= vColor;+#endif`,Tw=`#if defined( USE_COLOR_ALPHA )+ varying vec4 vColor;+#elif defined( USE_COLOR )+ varying vec3 vColor;+#endif`,Rw=`#if defined( USE_COLOR_ALPHA )+ varying vec4 vColor;+#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )+ varying vec3 vColor;+#endif`,Nw=`#if defined( USE_COLOR_ALPHA )+ vColor = vec4( 1.0 );+#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )+ vColor = vec3( 1.0 );+#endif+#ifdef USE_COLOR+ vColor *= color;+#endif+#ifdef USE_INSTANCING_COLOR+ vColor.xyz *= instanceColor.xyz;+#endif+#ifdef USE_BATCHING_COLOR+ vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );+ vColor.xyz *= batchingColor.xyz;+#endif`,Fw=`#define PI 3.141592653589793+#define PI2 6.283185307179586+#define PI_HALF 1.5707963267948966+#define RECIPROCAL_PI 0.3183098861837907+#define RECIPROCAL_PI2 0.15915494309189535+#define EPSILON 1e-6+#ifndef saturate+#define saturate( a ) clamp( a, 0.0, 1.0 )+#endif+#define whiteComplement( a ) ( 1.0 - saturate( a ) )+float pow2( const in float x ) { return x*x; }+vec3 pow2( const in vec3 x ) { return x*x; }+float pow3( const in float x ) { return x*x*x; }+float pow4( const in float x ) { float x2 = x*x; return x2*x2; }+float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }+float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }+highp float rand( const in vec2 uv ) {+ const highp float a = 12.9898, b = 78.233, c = 43758.5453;+ highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );+ return fract( sin( sn ) * c );+}+#ifdef HIGH_PRECISION+ float precisionSafeLength( vec3 v ) { return length( v ); }+#else+ float precisionSafeLength( vec3 v ) {+ float maxComponent = max3( abs( v ) );+ return length( v / maxComponent ) * maxComponent;+ }+#endif+struct IncidentLight {+ vec3 color;+ vec3 direction;+ bool visible;+};+struct ReflectedLight {+ vec3 directDiffuse;+ vec3 directSpecular;+ vec3 indirectDiffuse;+ vec3 indirectSpecular;+};+#ifdef USE_ALPHAHASH+ varying vec3 vPosition;+#endif+vec3 transformDirection( in vec3 dir, in mat4 matrix ) {+ return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );+}+vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {+ return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );+}+mat3 transposeMat3( const in mat3 m ) {+ mat3 tmp;+ tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );+ tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );+ tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );+ return tmp;+}+bool isPerspectiveMatrix( mat4 m ) {+ return m[ 2 ][ 3 ] == - 1.0;+}+vec2 equirectUv( in vec3 dir ) {+ float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;+ float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;+ return vec2( u, v );+}+vec3 BRDF_Lambert( const in vec3 diffuseColor ) {+ return RECIPROCAL_PI * diffuseColor;+}+vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {+ float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );+ return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );+}+float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {+ float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );+ return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );+} // validated`,Dw=`#ifdef ENVMAP_TYPE_CUBE_UV+ #define cubeUV_minMipLevel 4.0+ #define cubeUV_minTileSize 16.0+ float getFace( vec3 direction ) {+ vec3 absDirection = abs( direction );+ float face = - 1.0;+ if ( absDirection.x > absDirection.z ) {+ if ( absDirection.x > absDirection.y )+ face = direction.x > 0.0 ? 0.0 : 3.0;+ else+ face = direction.y > 0.0 ? 1.0 : 4.0;+ } else {+ if ( absDirection.z > absDirection.y )+ face = direction.z > 0.0 ? 2.0 : 5.0;+ else+ face = direction.y > 0.0 ? 1.0 : 4.0;+ }+ return face;+ }+ vec2 getUV( vec3 direction, float face ) {+ vec2 uv;+ if ( face == 0.0 ) {+ uv = vec2( direction.z, direction.y ) / abs( direction.x );+ } else if ( face == 1.0 ) {+ uv = vec2( - direction.x, - direction.z ) / abs( direction.y );+ } else if ( face == 2.0 ) {+ uv = vec2( - direction.x, direction.y ) / abs( direction.z );+ } else if ( face == 3.0 ) {+ uv = vec2( - direction.z, direction.y ) / abs( direction.x );+ } else if ( face == 4.0 ) {+ uv = vec2( - direction.x, direction.z ) / abs( direction.y );+ } else {+ uv = vec2( direction.x, direction.y ) / abs( direction.z );+ }+ return 0.5 * ( uv + 1.0 );+ }+ vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {+ float face = getFace( direction );+ float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );+ mipInt = max( mipInt, cubeUV_minMipLevel );+ float faceSize = exp2( mipInt );+ highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;+ if ( face > 2.0 ) {+ uv.y += faceSize;+ face -= 3.0;+ }+ uv.x += face * faceSize;+ uv.x += filterInt * 3.0 * cubeUV_minTileSize;+ uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );+ uv.x *= CUBEUV_TEXEL_WIDTH;+ uv.y *= CUBEUV_TEXEL_HEIGHT;+ #ifdef texture2DGradEXT+ return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;+ #else+ return texture2D( envMap, uv ).rgb;+ #endif+ }+ #define cubeUV_r0 1.0+ #define cubeUV_m0 - 2.0+ #define cubeUV_r1 0.8+ #define cubeUV_m1 - 1.0+ #define cubeUV_r4 0.4+ #define cubeUV_m4 2.0+ #define cubeUV_r5 0.305+ #define cubeUV_m5 3.0+ #define cubeUV_r6 0.21+ #define cubeUV_m6 4.0+ float roughnessToMip( float roughness ) {+ float mip = 0.0;+ if ( roughness >= cubeUV_r1 ) {+ mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;+ } else if ( roughness >= cubeUV_r4 ) {+ mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;+ } else if ( roughness >= cubeUV_r5 ) {+ mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;+ } else if ( roughness >= cubeUV_r6 ) {+ mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;+ } else {+ mip = - 2.0 * log2( 1.16 * roughness ); }+ return mip;+ }+ vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {+ float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );+ float mipF = fract( mip );+ float mipInt = floor( mip );+ vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );+ if ( mipF == 0.0 ) {+ return vec4( color0, 1.0 );+ } else {+ vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );+ return vec4( mix( color0, color1, mipF ), 1.0 );+ }+ }+#endif`,Lw=`vec3 transformedNormal = objectNormal;+#ifdef USE_TANGENT+ vec3 transformedTangent = objectTangent;+#endif+#ifdef USE_BATCHING+ mat3 bm = mat3( batchingMatrix );+ transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );+ transformedNormal = bm * transformedNormal;+ #ifdef USE_TANGENT+ transformedTangent = bm * transformedTangent;+ #endif+#endif+#ifdef USE_INSTANCING+ mat3 im = mat3( instanceMatrix );+ transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );+ transformedNormal = im * transformedNormal;+ #ifdef USE_TANGENT+ transformedTangent = im * transformedTangent;+ #endif+#endif+transformedNormal = normalMatrix * transformedNormal;+#ifdef FLIP_SIDED+ transformedNormal = - transformedNormal;+#endif+#ifdef USE_TANGENT+ transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;+ #ifdef FLIP_SIDED+ transformedTangent = - transformedTangent;+ #endif+#endif`,Pw=`#ifdef USE_DISPLACEMENTMAP+ uniform sampler2D displacementMap;+ uniform float displacementScale;+ uniform float displacementBias;+#endif`,kw=`#ifdef USE_DISPLACEMENTMAP+ transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );+#endif`,Uw=`#ifdef USE_EMISSIVEMAP+ vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );+ #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE+ emissiveColor = sRGBTransferEOTF( emissiveColor );+ #endif+ totalEmissiveRadiance *= emissiveColor.rgb;+#endif`,Ow=`#ifdef USE_EMISSIVEMAP+ uniform sampler2D emissiveMap;+#endif`,Qw="gl_FragColor = linearToOutputTexel( gl_FragColor );",Gw=`vec4 LinearTransferOETF( in vec4 value ) {+ return value;+}+vec4 sRGBTransferEOTF( in vec4 value ) {+ return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );+}+vec4 sRGBTransferOETF( in vec4 value ) {+ return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );+}`,Hw=`#ifdef USE_ENVMAP+ #ifdef ENV_WORLDPOS+ vec3 cameraToFrag;+ if ( isOrthographic ) {+ cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );+ } else {+ cameraToFrag = normalize( vWorldPosition - cameraPosition );+ }+ vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );+ #ifdef ENVMAP_MODE_REFLECTION+ vec3 reflectVec = reflect( cameraToFrag, worldNormal );+ #else+ vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );+ #endif+ #else+ vec3 reflectVec = vReflect;+ #endif+ #ifdef ENVMAP_TYPE_CUBE+ vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );+ #else+ vec4 envColor = vec4( 0.0 );+ #endif+ #ifdef ENVMAP_BLENDING_MULTIPLY+ outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );+ #elif defined( ENVMAP_BLENDING_MIX )+ outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );+ #elif defined( ENVMAP_BLENDING_ADD )+ outgoingLight += envColor.xyz * specularStrength * reflectivity;+ #endif+#endif`,zw=`#ifdef USE_ENVMAP+ uniform float envMapIntensity;+ uniform float flipEnvMap;+ uniform mat3 envMapRotation;+ #ifdef ENVMAP_TYPE_CUBE+ uniform samplerCube envMap;+ #else+ uniform sampler2D envMap;+ #endif++#endif`,Vw=`#ifdef USE_ENVMAP+ uniform float reflectivity;+ #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )+ #define ENV_WORLDPOS+ #endif+ #ifdef ENV_WORLDPOS+ varying vec3 vWorldPosition;+ uniform float refractionRatio;+ #else+ varying vec3 vReflect;+ #endif+#endif`,Ww=`#ifdef USE_ENVMAP+ #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )+ #define ENV_WORLDPOS+ #endif+ #ifdef ENV_WORLDPOS++ varying vec3 vWorldPosition;+ #else+ varying vec3 vReflect;+ uniform float refractionRatio;+ #endif+#endif`,qw=`#ifdef USE_ENVMAP+ #ifdef ENV_WORLDPOS+ vWorldPosition = worldPosition.xyz;+ #else+ vec3 cameraToVertex;+ if ( isOrthographic ) {+ cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );+ } else {+ cameraToVertex = normalize( worldPosition.xyz - cameraPosition );+ }+ vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );+ #ifdef ENVMAP_MODE_REFLECTION+ vReflect = reflect( cameraToVertex, worldNormal );+ #else+ vReflect = refract( cameraToVertex, worldNormal, refractionRatio );+ #endif+ #endif+#endif`,Kw=`#ifdef USE_FOG+ vFogDepth = - mvPosition.z;+#endif`,jw=`#ifdef USE_FOG+ varying float vFogDepth;+#endif`,Xw=`#ifdef USE_FOG+ #ifdef FOG_EXP2+ float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );+ #else+ float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );+ #endif+ gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );+#endif`,Yw=`#ifdef USE_FOG+ uniform vec3 fogColor;+ varying float vFogDepth;+ #ifdef FOG_EXP2+ uniform float fogDensity;+ #else+ uniform float fogNear;+ uniform float fogFar;+ #endif+#endif`,Jw=`#ifdef USE_GRADIENTMAP+ uniform sampler2D gradientMap;+#endif+vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {+ float dotNL = dot( normal, lightDirection );+ vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );+ #ifdef USE_GRADIENTMAP+ return vec3( texture2D( gradientMap, coord ).r );+ #else+ vec2 fw = fwidth( coord ) * 0.5;+ return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );+ #endif+}`,Zw=`#ifdef USE_LIGHTMAP+ uniform sampler2D lightMap;+ uniform float lightMapIntensity;+#endif`,$w=`LambertMaterial material;+material.diffuseColor = diffuseColor.rgb;+material.specularStrength = specularStrength;`,ev=`varying vec3 vViewPosition;+struct LambertMaterial {+ vec3 diffuseColor;+ float specularStrength;+};+void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {+ float dotNL = saturate( dot( geometryNormal, directLight.direction ) );+ vec3 irradiance = dotNL * directLight.color;+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );+}+void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );+}+#define RE_Direct RE_Direct_Lambert+#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,tv=`uniform bool receiveShadow;+uniform vec3 ambientLightColor;+#if defined( USE_LIGHT_PROBES )+ uniform vec3 lightProbe[ 9 ];+#endif+vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {+ float x = normal.x, y = normal.y, z = normal.z;+ vec3 result = shCoefficients[ 0 ] * 0.886227;+ result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;+ result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;+ result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;+ result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;+ result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;+ result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );+ result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;+ result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );+ return result;+}+vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {+ vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );+ vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );+ return irradiance;+}+vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {+ vec3 irradiance = ambientLightColor;+ return irradiance;+}+float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {+ float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );+ if ( cutoffDistance > 0.0 ) {+ distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );+ }+ return distanceFalloff;+}+float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {+ return smoothstep( coneCosine, penumbraCosine, angleCosine );+}+#if NUM_DIR_LIGHTS > 0+ struct DirectionalLight {+ vec3 direction;+ vec3 color;+ };+ uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];+ void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {+ light.color = directionalLight.color;+ light.direction = directionalLight.direction;+ light.visible = true;+ }+#endif+#if NUM_POINT_LIGHTS > 0+ struct PointLight {+ vec3 position;+ vec3 color;+ float distance;+ float decay;+ };+ uniform PointLight pointLights[ NUM_POINT_LIGHTS ];+ void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {+ vec3 lVector = pointLight.position - geometryPosition;+ light.direction = normalize( lVector );+ float lightDistance = length( lVector );+ light.color = pointLight.color;+ light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );+ light.visible = ( light.color != vec3( 0.0 ) );+ }+#endif+#if NUM_SPOT_LIGHTS > 0+ struct SpotLight {+ vec3 position;+ vec3 direction;+ vec3 color;+ float distance;+ float decay;+ float coneCos;+ float penumbraCos;+ };+ uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];+ void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {+ vec3 lVector = spotLight.position - geometryPosition;+ light.direction = normalize( lVector );+ float angleCos = dot( light.direction, spotLight.direction );+ float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );+ if ( spotAttenuation > 0.0 ) {+ float lightDistance = length( lVector );+ light.color = spotLight.color * spotAttenuation;+ light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );+ light.visible = ( light.color != vec3( 0.0 ) );+ } else {+ light.color = vec3( 0.0 );+ light.visible = false;+ }+ }+#endif+#if NUM_RECT_AREA_LIGHTS > 0+ struct RectAreaLight {+ vec3 color;+ vec3 position;+ vec3 halfWidth;+ vec3 halfHeight;+ };+ uniform sampler2D ltc_1; uniform sampler2D ltc_2;+ uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];+#endif+#if NUM_HEMI_LIGHTS > 0+ struct HemisphereLight {+ vec3 direction;+ vec3 skyColor;+ vec3 groundColor;+ };+ uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];+ vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {+ float dotNL = dot( normal, hemiLight.direction );+ float hemiDiffuseWeight = 0.5 * dotNL + 0.5;+ vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );+ return irradiance;+ }+#endif`,nv=`#ifdef USE_ENVMAP+ vec3 getIBLIrradiance( const in vec3 normal ) {+ #ifdef ENVMAP_TYPE_CUBE_UV+ vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );+ vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );+ return PI * envMapColor.rgb * envMapIntensity;+ #else+ return vec3( 0.0 );+ #endif+ }+ vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {+ #ifdef ENVMAP_TYPE_CUBE_UV+ vec3 reflectVec = reflect( - viewDir, normal );+ reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );+ reflectVec = inverseTransformDirection( reflectVec, viewMatrix );+ vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );+ return envMapColor.rgb * envMapIntensity;+ #else+ return vec3( 0.0 );+ #endif+ }+ #ifdef USE_ANISOTROPY+ vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {+ #ifdef ENVMAP_TYPE_CUBE_UV+ vec3 bentNormal = cross( bitangent, viewDir );+ bentNormal = normalize( cross( bentNormal, bitangent ) );+ bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );+ return getIBLRadiance( viewDir, bentNormal, roughness );+ #else+ return vec3( 0.0 );+ #endif+ }+ #endif+#endif`,iv=`ToonMaterial material;+material.diffuseColor = diffuseColor.rgb;`,sv=`varying vec3 vViewPosition;+struct ToonMaterial {+ vec3 diffuseColor;+};+void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {+ vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );+}+void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );+}+#define RE_Direct RE_Direct_Toon+#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,rv=`BlinnPhongMaterial material;+material.diffuseColor = diffuseColor.rgb;+material.specularColor = specular;+material.specularShininess = shininess;+material.specularStrength = specularStrength;`,av=`varying vec3 vViewPosition;+struct BlinnPhongMaterial {+ vec3 diffuseColor;+ vec3 specularColor;+ float specularShininess;+ float specularStrength;+};+void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {+ float dotNL = saturate( dot( geometryNormal, directLight.direction ) );+ vec3 irradiance = dotNL * directLight.color;+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );+ reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;+}+void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );+}+#define RE_Direct RE_Direct_BlinnPhong+#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,ov=`PhysicalMaterial material;+material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );+vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );+float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );+material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;+material.roughness = min( material.roughness, 1.0 );+#ifdef IOR+ material.ior = ior;+ #ifdef USE_SPECULAR+ float specularIntensityFactor = specularIntensity;+ vec3 specularColorFactor = specularColor;+ #ifdef USE_SPECULAR_COLORMAP+ specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;+ #endif+ #ifdef USE_SPECULAR_INTENSITYMAP+ specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;+ #endif+ material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );+ #else+ float specularIntensityFactor = 1.0;+ vec3 specularColorFactor = vec3( 1.0 );+ material.specularF90 = 1.0;+ #endif+ material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );+#else+ material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );+ material.specularF90 = 1.0;+#endif+#ifdef USE_CLEARCOAT+ material.clearcoat = clearcoat;+ material.clearcoatRoughness = clearcoatRoughness;+ material.clearcoatF0 = vec3( 0.04 );+ material.clearcoatF90 = 1.0;+ #ifdef USE_CLEARCOATMAP+ material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;+ #endif+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP+ material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;+ #endif+ material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );+ material.clearcoatRoughness += geometryRoughness;+ material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );+#endif+#ifdef USE_DISPERSION+ material.dispersion = dispersion;+#endif+#ifdef USE_IRIDESCENCE+ material.iridescence = iridescence;+ material.iridescenceIOR = iridescenceIOR;+ #ifdef USE_IRIDESCENCEMAP+ material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;+ #endif+ #ifdef USE_IRIDESCENCE_THICKNESSMAP+ material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;+ #else+ material.iridescenceThickness = iridescenceThicknessMaximum;+ #endif+#endif+#ifdef USE_SHEEN+ material.sheenColor = sheenColor;+ #ifdef USE_SHEEN_COLORMAP+ material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;+ #endif+ material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );+ #ifdef USE_SHEEN_ROUGHNESSMAP+ material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;+ #endif+#endif+#ifdef USE_ANISOTROPY+ #ifdef USE_ANISOTROPYMAP+ mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );+ vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;+ vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;+ #else+ vec2 anisotropyV = anisotropyVector;+ #endif+ material.anisotropy = length( anisotropyV );+ if( material.anisotropy == 0.0 ) {+ anisotropyV = vec2( 1.0, 0.0 );+ } else {+ anisotropyV /= material.anisotropy;+ material.anisotropy = saturate( material.anisotropy );+ }+ material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );+ material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;+ material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;+#endif`,cv=`struct PhysicalMaterial {+ vec3 diffuseColor;+ float roughness;+ vec3 specularColor;+ float specularF90;+ float dispersion;+ #ifdef USE_CLEARCOAT+ float clearcoat;+ float clearcoatRoughness;+ vec3 clearcoatF0;+ float clearcoatF90;+ #endif+ #ifdef USE_IRIDESCENCE+ float iridescence;+ float iridescenceIOR;+ float iridescenceThickness;+ vec3 iridescenceFresnel;+ vec3 iridescenceF0;+ #endif+ #ifdef USE_SHEEN+ vec3 sheenColor;+ float sheenRoughness;+ #endif+ #ifdef IOR+ float ior;+ #endif+ #ifdef USE_TRANSMISSION+ float transmission;+ float transmissionAlpha;+ float thickness;+ float attenuationDistance;+ vec3 attenuationColor;+ #endif+ #ifdef USE_ANISOTROPY+ float anisotropy;+ float alphaT;+ vec3 anisotropyT;+ vec3 anisotropyB;+ #endif+};+vec3 clearcoatSpecularDirect = vec3( 0.0 );+vec3 clearcoatSpecularIndirect = vec3( 0.0 );+vec3 sheenSpecularDirect = vec3( 0.0 );+vec3 sheenSpecularIndirect = vec3(0.0 );+vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {+ float x = clamp( 1.0 - dotVH, 0.0, 1.0 );+ float x2 = x * x;+ float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );+ return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );+}+float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {+ float a2 = pow2( alpha );+ float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );+ float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );+ return 0.5 / max( gv + gl, EPSILON );+}+float D_GGX( const in float alpha, const in float dotNH ) {+ float a2 = pow2( alpha );+ float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;+ return RECIPROCAL_PI * a2 / pow2( denom );+}+#ifdef USE_ANISOTROPY+ float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {+ float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );+ float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );+ float v = 0.5 / ( gv + gl );+ return saturate(v);+ }+ float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {+ float a2 = alphaT * alphaB;+ highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );+ highp float v2 = dot( v, v );+ float w2 = a2 / v2;+ return RECIPROCAL_PI * a2 * pow2 ( w2 );+ }+#endif+#ifdef USE_CLEARCOAT+ vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {+ vec3 f0 = material.clearcoatF0;+ float f90 = material.clearcoatF90;+ float roughness = material.clearcoatRoughness;+ float alpha = pow2( roughness );+ vec3 halfDir = normalize( lightDir + viewDir );+ float dotNL = saturate( dot( normal, lightDir ) );+ float dotNV = saturate( dot( normal, viewDir ) );+ float dotNH = saturate( dot( normal, halfDir ) );+ float dotVH = saturate( dot( viewDir, halfDir ) );+ vec3 F = F_Schlick( f0, f90, dotVH );+ float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );+ float D = D_GGX( alpha, dotNH );+ return F * ( V * D );+ }+#endif+vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {+ vec3 f0 = material.specularColor;+ float f90 = material.specularF90;+ float roughness = material.roughness;+ float alpha = pow2( roughness );+ vec3 halfDir = normalize( lightDir + viewDir );+ float dotNL = saturate( dot( normal, lightDir ) );+ float dotNV = saturate( dot( normal, viewDir ) );+ float dotNH = saturate( dot( normal, halfDir ) );+ float dotVH = saturate( dot( viewDir, halfDir ) );+ vec3 F = F_Schlick( f0, f90, dotVH );+ #ifdef USE_IRIDESCENCE+ F = mix( F, material.iridescenceFresnel, material.iridescence );+ #endif+ #ifdef USE_ANISOTROPY+ float dotTL = dot( material.anisotropyT, lightDir );+ float dotTV = dot( material.anisotropyT, viewDir );+ float dotTH = dot( material.anisotropyT, halfDir );+ float dotBL = dot( material.anisotropyB, lightDir );+ float dotBV = dot( material.anisotropyB, viewDir );+ float dotBH = dot( material.anisotropyB, halfDir );+ float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );+ float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );+ #else+ float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );+ float D = D_GGX( alpha, dotNH );+ #endif+ return F * ( V * D );+}+vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {+ const float LUT_SIZE = 64.0;+ const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;+ const float LUT_BIAS = 0.5 / LUT_SIZE;+ float dotNV = saturate( dot( N, V ) );+ vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );+ uv = uv * LUT_SCALE + LUT_BIAS;+ return uv;+}+float LTC_ClippedSphereFormFactor( const in vec3 f ) {+ float l = length( f );+ return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );+}+vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {+ float x = dot( v1, v2 );+ float y = abs( x );+ float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;+ float b = 3.4175940 + ( 4.1616724 + y ) * y;+ float v = a / b;+ float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;+ return cross( v1, v2 ) * theta_sintheta;+}+vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {+ vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];+ vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];+ vec3 lightNormal = cross( v1, v2 );+ if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );+ vec3 T1, T2;+ T1 = normalize( V - N * dot( V, N ) );+ T2 = - cross( N, T1 );+ mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );+ vec3 coords[ 4 ];+ coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );+ coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );+ coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );+ coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );+ coords[ 0 ] = normalize( coords[ 0 ] );+ coords[ 1 ] = normalize( coords[ 1 ] );+ coords[ 2 ] = normalize( coords[ 2 ] );+ coords[ 3 ] = normalize( coords[ 3 ] );+ vec3 vectorFormFactor = vec3( 0.0 );+ vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );+ vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );+ vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );+ vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );+ float result = LTC_ClippedSphereFormFactor( vectorFormFactor );+ return vec3( result );+}+#if defined( USE_SHEEN )+float D_Charlie( float roughness, float dotNH ) {+ float alpha = pow2( roughness );+ float invAlpha = 1.0 / alpha;+ float cos2h = dotNH * dotNH;+ float sin2h = max( 1.0 - cos2h, 0.0078125 );+ return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );+}+float V_Neubelt( float dotNV, float dotNL ) {+ return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );+}+vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {+ vec3 halfDir = normalize( lightDir + viewDir );+ float dotNL = saturate( dot( normal, lightDir ) );+ float dotNV = saturate( dot( normal, viewDir ) );+ float dotNH = saturate( dot( normal, halfDir ) );+ float D = D_Charlie( sheenRoughness, dotNH );+ float V = V_Neubelt( dotNV, dotNL );+ return sheenColor * ( D * V );+}+#endif+float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {+ float dotNV = saturate( dot( normal, viewDir ) );+ float r2 = roughness * roughness;+ float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;+ float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;+ float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );+ return saturate( DG * RECIPROCAL_PI );+}+vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {+ float dotNV = saturate( dot( normal, viewDir ) );+ const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );+ const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );+ vec4 r = roughness * c0 + c1;+ float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;+ vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;+ return fab;+}+vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {+ vec2 fab = DFGApprox( normal, viewDir, roughness );+ return specularColor * fab.x + specularF90 * fab.y;+}+#ifdef USE_IRIDESCENCE+void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {+#else+void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {+#endif+ vec2 fab = DFGApprox( normal, viewDir, roughness );+ #ifdef USE_IRIDESCENCE+ vec3 Fr = mix( specularColor, iridescenceF0, iridescence );+ #else+ vec3 Fr = specularColor;+ #endif+ vec3 FssEss = Fr * fab.x + specularF90 * fab.y;+ float Ess = fab.x + fab.y;+ float Ems = 1.0 - Ess;+ vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );+ singleScatter += FssEss;+ multiScatter += Fms * Ems;+}+#if NUM_RECT_AREA_LIGHTS > 0+ void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {+ vec3 normal = geometryNormal;+ vec3 viewDir = geometryViewDir;+ vec3 position = geometryPosition;+ vec3 lightPos = rectAreaLight.position;+ vec3 halfWidth = rectAreaLight.halfWidth;+ vec3 halfHeight = rectAreaLight.halfHeight;+ vec3 lightColor = rectAreaLight.color;+ float roughness = material.roughness;+ vec3 rectCoords[ 4 ];+ rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;+ rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;+ rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;+ vec2 uv = LTC_Uv( normal, viewDir, roughness );+ vec4 t1 = texture2D( ltc_1, uv );+ vec4 t2 = texture2D( ltc_2, uv );+ mat3 mInv = mat3(+ vec3( t1.x, 0, t1.y ),+ vec3( 0, 1, 0 ),+ vec3( t1.z, 0, t1.w )+ );+ vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );+ reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );+ reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );+ }+#endif+void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {+ float dotNL = saturate( dot( geometryNormal, directLight.direction ) );+ vec3 irradiance = dotNL * directLight.color;+ #ifdef USE_CLEARCOAT+ float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );+ vec3 ccIrradiance = dotNLcc * directLight.color;+ clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );+ #endif+ #ifdef USE_SHEEN+ sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );+ #endif+ reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );+}+void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );+}+void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {+ #ifdef USE_CLEARCOAT+ clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );+ #endif+ #ifdef USE_SHEEN+ sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );+ #endif+ vec3 singleScattering = vec3( 0.0 );+ vec3 multiScattering = vec3( 0.0 );+ vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;+ #ifdef USE_IRIDESCENCE+ computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );+ #else+ computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );+ #endif+ vec3 totalScattering = singleScattering + multiScattering;+ vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );+ reflectedLight.indirectSpecular += radiance * singleScattering;+ reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;+ reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;+}+#define RE_Direct RE_Direct_Physical+#define RE_Direct_RectArea RE_Direct_RectArea_Physical+#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical+#define RE_IndirectSpecular RE_IndirectSpecular_Physical+float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {+ return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );+}`,lv=`+vec3 geometryPosition = - vViewPosition;+vec3 geometryNormal = normal;+vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );+vec3 geometryClearcoatNormal = vec3( 0.0 );+#ifdef USE_CLEARCOAT+ geometryClearcoatNormal = clearcoatNormal;+#endif+#ifdef USE_IRIDESCENCE+ float dotNVi = saturate( dot( normal, geometryViewDir ) );+ if ( material.iridescenceThickness == 0.0 ) {+ material.iridescence = 0.0;+ } else {+ material.iridescence = saturate( material.iridescence );+ }+ if ( material.iridescence > 0.0 ) {+ material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );+ material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );+ }+#endif+IncidentLight directLight;+#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )+ PointLight pointLight;+ #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0+ PointLightShadow pointLightShadow;+ #endif+ #pragma unroll_loop_start+ for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {+ pointLight = pointLights[ i ];+ getPointLightInfo( pointLight, geometryPosition, directLight );+ #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )+ pointLightShadow = pointLightShadows[ i ];+ directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;+ #endif+ RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );+ }+ #pragma unroll_loop_end+#endif+#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )+ SpotLight spotLight;+ vec4 spotColor;+ vec3 spotLightCoord;+ bool inSpotLightMap;+ #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0+ SpotLightShadow spotLightShadow;+ #endif+ #pragma unroll_loop_start+ for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {+ spotLight = spotLights[ i ];+ getSpotLightInfo( spotLight, geometryPosition, directLight );+ #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )+ #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX+ #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )+ #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS+ #else+ #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )+ #endif+ #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )+ spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;+ inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );+ spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );+ directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;+ #endif+ #undef SPOT_LIGHT_MAP_INDEX+ #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )+ spotLightShadow = spotLightShadows[ i ];+ directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;+ #endif+ RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );+ }+ #pragma unroll_loop_end+#endif+#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )+ DirectionalLight directionalLight;+ #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0+ DirectionalLightShadow directionalLightShadow;+ #endif+ #pragma unroll_loop_start+ for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {+ directionalLight = directionalLights[ i ];+ getDirectionalLightInfo( directionalLight, directLight );+ #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )+ directionalLightShadow = directionalLightShadows[ i ];+ directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;+ #endif+ RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );+ }+ #pragma unroll_loop_end+#endif+#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )+ RectAreaLight rectAreaLight;+ #pragma unroll_loop_start+ for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {+ rectAreaLight = rectAreaLights[ i ];+ RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );+ }+ #pragma unroll_loop_end+#endif+#if defined( RE_IndirectDiffuse )+ vec3 iblIrradiance = vec3( 0.0 );+ vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );+ #if defined( USE_LIGHT_PROBES )+ irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );+ #endif+ #if ( NUM_HEMI_LIGHTS > 0 )+ #pragma unroll_loop_start+ for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {+ irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );+ }+ #pragma unroll_loop_end+ #endif+#endif+#if defined( RE_IndirectSpecular )+ vec3 radiance = vec3( 0.0 );+ vec3 clearcoatRadiance = vec3( 0.0 );+#endif`,hv=`#if defined( RE_IndirectDiffuse )+ #ifdef USE_LIGHTMAP+ vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );+ vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;+ irradiance += lightMapIrradiance;+ #endif+ #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )+ iblIrradiance += getIBLIrradiance( geometryNormal );+ #endif+#endif+#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )+ #ifdef USE_ANISOTROPY+ radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );+ #else+ radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );+ #endif+ #ifdef USE_CLEARCOAT+ clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );+ #endif+#endif`,uv=`#if defined( RE_IndirectDiffuse )+ RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );+#endif+#if defined( RE_IndirectSpecular )+ RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );+#endif`,dv=`#if defined( USE_LOGDEPTHBUF )+ gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;+#endif`,fv=`#if defined( USE_LOGDEPTHBUF )+ uniform float logDepthBufFC;+ varying float vFragDepth;+ varying float vIsPerspective;+#endif`,pv=`#ifdef USE_LOGDEPTHBUF+ varying float vFragDepth;+ varying float vIsPerspective;+#endif`,Av=`#ifdef USE_LOGDEPTHBUF+ vFragDepth = 1.0 + gl_Position.w;+ vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );+#endif`,gv=`#ifdef USE_MAP+ vec4 sampledDiffuseColor = texture2D( map, vMapUv );+ #ifdef DECODE_VIDEO_TEXTURE+ sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );+ #endif+ diffuseColor *= sampledDiffuseColor;+#endif`,mv=`#ifdef USE_MAP+ uniform sampler2D map;+#endif`,bv=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )+ #if defined( USE_POINTS_UV )+ vec2 uv = vUv;+ #else+ vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;+ #endif+#endif+#ifdef USE_MAP+ diffuseColor *= texture2D( map, uv );+#endif+#ifdef USE_ALPHAMAP+ diffuseColor.a *= texture2D( alphaMap, uv ).g;+#endif`,xv=`#if defined( USE_POINTS_UV )+ varying vec2 vUv;+#else+ #if defined( USE_MAP ) || defined( USE_ALPHAMAP )+ uniform mat3 uvTransform;+ #endif+#endif+#ifdef USE_MAP+ uniform sampler2D map;+#endif+#ifdef USE_ALPHAMAP+ uniform sampler2D alphaMap;+#endif`,_v=`float metalnessFactor = metalness;+#ifdef USE_METALNESSMAP+ vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );+ metalnessFactor *= texelMetalness.b;+#endif`,Ev=`#ifdef USE_METALNESSMAP+ uniform sampler2D metalnessMap;+#endif`,yv=`#ifdef USE_INSTANCING_MORPH+ float morphTargetInfluences[ MORPHTARGETS_COUNT ];+ float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {+ morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;+ }+#endif`,wv=`#if defined( USE_MORPHCOLORS )+ vColor *= morphTargetBaseInfluence;+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {+ #if defined( USE_COLOR_ALPHA )+ if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];+ #elif defined( USE_COLOR )+ if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];+ #endif+ }+#endif`,vv=`#ifdef USE_MORPHNORMALS+ objectNormal *= morphTargetBaseInfluence;+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {+ if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];+ }+#endif`,Cv=`#ifdef USE_MORPHTARGETS+ #ifndef USE_INSTANCING_MORPH+ uniform float morphTargetBaseInfluence;+ uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];+ #endif+ uniform sampler2DArray morphTargetsTexture;+ uniform ivec2 morphTargetsTextureSize;+ vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {+ int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;+ int y = texelIndex / morphTargetsTextureSize.x;+ int x = texelIndex - y * morphTargetsTextureSize.x;+ ivec3 morphUV = ivec3( x, y, morphTargetIndex );+ return texelFetch( morphTargetsTexture, morphUV, 0 );+ }+#endif`,Sv=`#ifdef USE_MORPHTARGETS+ transformed *= morphTargetBaseInfluence;+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {+ if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];+ }+#endif`,Iv=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;+#ifdef FLAT_SHADED+ vec3 fdx = dFdx( vViewPosition );+ vec3 fdy = dFdy( vViewPosition );+ vec3 normal = normalize( cross( fdx, fdy ) );+#else+ vec3 normal = normalize( vNormal );+ #ifdef DOUBLE_SIDED+ normal *= faceDirection;+ #endif+#endif+#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )+ #ifdef USE_TANGENT+ mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );+ #else+ mat3 tbn = getTangentFrame( - vViewPosition, normal,+ #if defined( USE_NORMALMAP )+ vNormalMapUv+ #elif defined( USE_CLEARCOAT_NORMALMAP )+ vClearcoatNormalMapUv+ #else+ vUv+ #endif+ );+ #endif+ #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )+ tbn[0] *= faceDirection;+ tbn[1] *= faceDirection;+ #endif+#endif+#ifdef USE_CLEARCOAT_NORMALMAP+ #ifdef USE_TANGENT+ mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );+ #else+ mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );+ #endif+ #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )+ tbn2[0] *= faceDirection;+ tbn2[1] *= faceDirection;+ #endif+#endif+vec3 nonPerturbedNormal = normal;`,Mv=`#ifdef USE_NORMALMAP_OBJECTSPACE+ normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;+ #ifdef FLIP_SIDED+ normal = - normal;+ #endif+ #ifdef DOUBLE_SIDED+ normal = normal * faceDirection;+ #endif+ normal = normalize( normalMatrix * normal );+#elif defined( USE_NORMALMAP_TANGENTSPACE )+ vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;+ mapN.xy *= normalScale;+ normal = normalize( tbn * mapN );+#elif defined( USE_BUMPMAP )+ normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );+#endif`,Bv=`#ifndef FLAT_SHADED+ varying vec3 vNormal;+ #ifdef USE_TANGENT+ varying vec3 vTangent;+ varying vec3 vBitangent;+ #endif+#endif`,Tv=`#ifndef FLAT_SHADED+ varying vec3 vNormal;+ #ifdef USE_TANGENT+ varying vec3 vTangent;+ varying vec3 vBitangent;+ #endif+#endif`,Rv=`#ifndef FLAT_SHADED+ vNormal = normalize( transformedNormal );+ #ifdef USE_TANGENT+ vTangent = normalize( transformedTangent );+ vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );+ #endif+#endif`,Nv=`#ifdef USE_NORMALMAP+ uniform sampler2D normalMap;+ uniform vec2 normalScale;+#endif+#ifdef USE_NORMALMAP_OBJECTSPACE+ uniform mat3 normalMatrix;+#endif+#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )+ mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {+ vec3 q0 = dFdx( eye_pos.xyz );+ vec3 q1 = dFdy( eye_pos.xyz );+ vec2 st0 = dFdx( uv.st );+ vec2 st1 = dFdy( uv.st );+ vec3 N = surf_norm;+ vec3 q1perp = cross( q1, N );+ vec3 q0perp = cross( N, q0 );+ vec3 T = q1perp * st0.x + q0perp * st1.x;+ vec3 B = q1perp * st0.y + q0perp * st1.y;+ float det = max( dot( T, T ), dot( B, B ) );+ float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );+ return mat3( T * scale, B * scale, N );+ }+#endif`,Fv=`#ifdef USE_CLEARCOAT+ vec3 clearcoatNormal = nonPerturbedNormal;+#endif`,Dv=`#ifdef USE_CLEARCOAT_NORMALMAP+ vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;+ clearcoatMapN.xy *= clearcoatNormalScale;+ clearcoatNormal = normalize( tbn2 * clearcoatMapN );+#endif`,Lv=`#ifdef USE_CLEARCOATMAP+ uniform sampler2D clearcoatMap;+#endif+#ifdef USE_CLEARCOAT_NORMALMAP+ uniform sampler2D clearcoatNormalMap;+ uniform vec2 clearcoatNormalScale;+#endif+#ifdef USE_CLEARCOAT_ROUGHNESSMAP+ uniform sampler2D clearcoatRoughnessMap;+#endif`,Pv=`#ifdef USE_IRIDESCENCEMAP+ uniform sampler2D iridescenceMap;+#endif+#ifdef USE_IRIDESCENCE_THICKNESSMAP+ uniform sampler2D iridescenceThicknessMap;+#endif`,kv=`#ifdef OPAQUE+diffuseColor.a = 1.0;+#endif+#ifdef USE_TRANSMISSION+diffuseColor.a *= material.transmissionAlpha;+#endif+gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Uv=`vec3 packNormalToRGB( const in vec3 normal ) {+ return normalize( normal ) * 0.5 + 0.5;+}+vec3 unpackRGBToNormal( const in vec3 rgb ) {+ return 2.0 * rgb.xyz - 1.0;+}+const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;+const float Inv255 = 1. / 255.;+const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );+const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );+const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );+const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );+vec4 packDepthToRGBA( const in float v ) {+ if( v <= 0.0 )+ return vec4( 0., 0., 0., 0. );+ if( v >= 1.0 )+ return vec4( 1., 1., 1., 1. );+ float vuf;+ float af = modf( v * PackFactors.a, vuf );+ float bf = modf( vuf * ShiftRight8, vuf );+ float gf = modf( vuf * ShiftRight8, vuf );+ return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );+}+vec3 packDepthToRGB( const in float v ) {+ if( v <= 0.0 )+ return vec3( 0., 0., 0. );+ if( v >= 1.0 )+ return vec3( 1., 1., 1. );+ float vuf;+ float bf = modf( v * PackFactors.b, vuf );+ float gf = modf( vuf * ShiftRight8, vuf );+ return vec3( vuf * Inv255, gf * PackUpscale, bf );+}+vec2 packDepthToRG( const in float v ) {+ if( v <= 0.0 )+ return vec2( 0., 0. );+ if( v >= 1.0 )+ return vec2( 1., 1. );+ float vuf;+ float gf = modf( v * 256., vuf );+ return vec2( vuf * Inv255, gf );+}+float unpackRGBAToDepth( const in vec4 v ) {+ return dot( v, UnpackFactors4 );+}+float unpackRGBToDepth( const in vec3 v ) {+ return dot( v, UnpackFactors3 );+}+float unpackRGToDepth( const in vec2 v ) {+ return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;+}+vec4 pack2HalfToRGBA( const in vec2 v ) {+ vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );+ return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );+}+vec2 unpackRGBATo2Half( const in vec4 v ) {+ return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );+}+float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {+ return ( viewZ + near ) / ( near - far );+}+float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {+ return depth * ( near - far ) - near;+}+float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {+ return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );+}+float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {+ return ( near * far ) / ( ( far - near ) * depth - far );+}`,Ov=`#ifdef PREMULTIPLIED_ALPHA+ gl_FragColor.rgb *= gl_FragColor.a;+#endif`,Qv=`vec4 mvPosition = vec4( transformed, 1.0 );+#ifdef USE_BATCHING+ mvPosition = batchingMatrix * mvPosition;+#endif+#ifdef USE_INSTANCING+ mvPosition = instanceMatrix * mvPosition;+#endif+mvPosition = modelViewMatrix * mvPosition;+gl_Position = projectionMatrix * mvPosition;`,Gv=`#ifdef DITHERING+ gl_FragColor.rgb = dithering( gl_FragColor.rgb );+#endif`,Hv=`#ifdef DITHERING+ vec3 dithering( vec3 color ) {+ float grid_position = rand( gl_FragCoord.xy );+ vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );+ dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );+ return color + dither_shift_RGB;+ }+#endif`,zv=`float roughnessFactor = roughness;+#ifdef USE_ROUGHNESSMAP+ vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );+ roughnessFactor *= texelRoughness.g;+#endif`,Vv=`#ifdef USE_ROUGHNESSMAP+ uniform sampler2D roughnessMap;+#endif`,Wv=`#if NUM_SPOT_LIGHT_COORDS > 0+ varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];+#endif+#if NUM_SPOT_LIGHT_MAPS > 0+ uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];+#endif+#ifdef USE_SHADOWMAP+ #if NUM_DIR_LIGHT_SHADOWS > 0+ uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];+ varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];+ struct DirectionalLightShadow {+ float shadowIntensity;+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ };+ uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];+ #endif+ #if NUM_SPOT_LIGHT_SHADOWS > 0+ uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];+ struct SpotLightShadow {+ float shadowIntensity;+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ };+ uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];+ #endif+ #if NUM_POINT_LIGHT_SHADOWS > 0+ uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];+ varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];+ struct PointLightShadow {+ float shadowIntensity;+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ float shadowCameraNear;+ float shadowCameraFar;+ };+ uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];+ #endif+ float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {+ return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );+ }+ vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {+ return unpackRGBATo2Half( texture2D( shadow, uv ) );+ }+ float VSMShadow (sampler2D shadow, vec2 uv, float compare ){+ float occlusion = 1.0;+ vec2 distribution = texture2DDistribution( shadow, uv );+ float hard_shadow = step( compare , distribution.x );+ if (hard_shadow != 1.0 ) {+ float distance = compare - distribution.x ;+ float variance = max( 0.00000, distribution.y * distribution.y );+ float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );+ }+ return occlusion;+ }+ float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {+ float shadow = 1.0;+ shadowCoord.xyz /= shadowCoord.w;+ shadowCoord.z += shadowBias;+ bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;+ bool frustumTest = inFrustum && shadowCoord.z <= 1.0;+ if ( frustumTest ) {+ #if defined( SHADOWMAP_TYPE_PCF )+ vec2 texelSize = vec2( 1.0 ) / shadowMapSize;+ float dx0 = - texelSize.x * shadowRadius;+ float dy0 = - texelSize.y * shadowRadius;+ float dx1 = + texelSize.x * shadowRadius;+ float dy1 = + texelSize.y * shadowRadius;+ float dx2 = dx0 / 2.0;+ float dy2 = dy0 / 2.0;+ float dx3 = dx1 / 2.0;+ float dy3 = dy1 / 2.0;+ shadow = (+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) ++ texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) ++ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) ++ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) ++ texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) ++ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) ++ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) ++ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) ++ texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) ++ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) ++ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) ++ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) ++ texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) ++ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) ++ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) ++ texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) ++ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )+ ) * ( 1.0 / 17.0 );+ #elif defined( SHADOWMAP_TYPE_PCF_SOFT )+ vec2 texelSize = vec2( 1.0 ) / shadowMapSize;+ float dx = texelSize.x;+ float dy = texelSize.y;+ vec2 uv = shadowCoord.xy;+ vec2 f = fract( uv * shadowMapSize + 0.5 );+ uv -= f * texelSize;+ shadow = (+ texture2DCompare( shadowMap, uv, shadowCoord.z ) ++ texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) ++ texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) ++ texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) ++ mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),+ texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),+ f.x ) ++ mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),+ texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),+ f.x ) ++ mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),+ texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),+ f.y ) ++ mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),+ texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),+ f.y ) ++ mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),+ texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),+ f.x ),+ mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),+ texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),+ f.x ),+ f.y )+ ) * ( 1.0 / 9.0 );+ #elif defined( SHADOWMAP_TYPE_VSM )+ shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );+ #else+ shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );+ #endif+ }+ return mix( 1.0, shadow, shadowIntensity );+ }+ vec2 cubeToUV( vec3 v, float texelSizeY ) {+ vec3 absV = abs( v );+ float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );+ absV *= scaleToCube;+ v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );+ vec2 planar = v.xy;+ float almostATexel = 1.5 * texelSizeY;+ float almostOne = 1.0 - almostATexel;+ if ( absV.z >= almostOne ) {+ if ( v.z > 0.0 )+ planar.x = 4.0 - v.x;+ } else if ( absV.x >= almostOne ) {+ float signX = sign( v.x );+ planar.x = v.z * signX + 2.0 * signX;+ } else if ( absV.y >= almostOne ) {+ float signY = sign( v.y );+ planar.x = v.x + 2.0 * signY + 2.0;+ planar.y = v.z * signY - 2.0;+ }+ return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );+ }+ float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {+ float shadow = 1.0;+ vec3 lightToPosition = shadowCoord.xyz;++ float lightToPositionLength = length( lightToPosition );+ if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {+ float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;+ vec3 bd3D = normalize( lightToPosition );+ vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );+ #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )+ vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;+ shadow = (+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) ++ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) ++ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) ++ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) ++ texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) ++ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) ++ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) ++ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) ++ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )+ ) * ( 1.0 / 9.0 );+ #else+ shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );+ #endif+ }+ return mix( 1.0, shadow, shadowIntensity );+ }+#endif`,qv=`#if NUM_SPOT_LIGHT_COORDS > 0+ uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];+ varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];+#endif+#ifdef USE_SHADOWMAP+ #if NUM_DIR_LIGHT_SHADOWS > 0+ uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];+ varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];+ struct DirectionalLightShadow {+ float shadowIntensity;+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ };+ uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];+ #endif+ #if NUM_SPOT_LIGHT_SHADOWS > 0+ struct SpotLightShadow {+ float shadowIntensity;+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ };+ uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];+ #endif+ #if NUM_POINT_LIGHT_SHADOWS > 0+ uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];+ varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];+ struct PointLightShadow {+ float shadowIntensity;+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ float shadowCameraNear;+ float shadowCameraFar;+ };+ uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];+ #endif+#endif`,Kv=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )+ vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );+ vec4 shadowWorldPosition;+#endif+#if defined( USE_SHADOWMAP )+ #if NUM_DIR_LIGHT_SHADOWS > 0+ #pragma unroll_loop_start+ for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {+ shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );+ vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;+ }+ #pragma unroll_loop_end+ #endif+ #if NUM_POINT_LIGHT_SHADOWS > 0+ #pragma unroll_loop_start+ for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {+ shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );+ vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;+ }+ #pragma unroll_loop_end+ #endif+#endif+#if NUM_SPOT_LIGHT_COORDS > 0+ #pragma unroll_loop_start+ for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {+ shadowWorldPosition = worldPosition;+ #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )+ shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;+ #endif+ vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;+ }+ #pragma unroll_loop_end+#endif`,jv=`float getShadowMask() {+ float shadow = 1.0;+ #ifdef USE_SHADOWMAP+ #if NUM_DIR_LIGHT_SHADOWS > 0+ DirectionalLightShadow directionalLight;+ #pragma unroll_loop_start+ for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {+ directionalLight = directionalLightShadows[ i ];+ shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;+ }+ #pragma unroll_loop_end+ #endif+ #if NUM_SPOT_LIGHT_SHADOWS > 0+ SpotLightShadow spotLight;+ #pragma unroll_loop_start+ for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {+ spotLight = spotLightShadows[ i ];+ shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;+ }+ #pragma unroll_loop_end+ #endif+ #if NUM_POINT_LIGHT_SHADOWS > 0+ PointLightShadow pointLight;+ #pragma unroll_loop_start+ for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {+ pointLight = pointLightShadows[ i ];+ shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;+ }+ #pragma unroll_loop_end+ #endif+ #endif+ return shadow;+}`,Xv=`#ifdef USE_SKINNING+ mat4 boneMatX = getBoneMatrix( skinIndex.x );+ mat4 boneMatY = getBoneMatrix( skinIndex.y );+ mat4 boneMatZ = getBoneMatrix( skinIndex.z );+ mat4 boneMatW = getBoneMatrix( skinIndex.w );+#endif`,Yv=`#ifdef USE_SKINNING+ uniform mat4 bindMatrix;+ uniform mat4 bindMatrixInverse;+ uniform highp sampler2D boneTexture;+ mat4 getBoneMatrix( const in float i ) {+ int size = textureSize( boneTexture, 0 ).x;+ int j = int( i ) * 4;+ int x = j % size;+ int y = j / size;+ vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );+ vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );+ vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );+ vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );+ return mat4( v1, v2, v3, v4 );+ }+#endif`,Jv=`#ifdef USE_SKINNING+ vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );+ vec4 skinned = vec4( 0.0 );+ skinned += boneMatX * skinVertex * skinWeight.x;+ skinned += boneMatY * skinVertex * skinWeight.y;+ skinned += boneMatZ * skinVertex * skinWeight.z;+ skinned += boneMatW * skinVertex * skinWeight.w;+ transformed = ( bindMatrixInverse * skinned ).xyz;+#endif`,Zv=`#ifdef USE_SKINNING+ mat4 skinMatrix = mat4( 0.0 );+ skinMatrix += skinWeight.x * boneMatX;+ skinMatrix += skinWeight.y * boneMatY;+ skinMatrix += skinWeight.z * boneMatZ;+ skinMatrix += skinWeight.w * boneMatW;+ skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;+ objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;+ #ifdef USE_TANGENT+ objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;+ #endif+#endif`,$v=`float specularStrength;+#ifdef USE_SPECULARMAP+ vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );+ specularStrength = texelSpecular.r;+#else+ specularStrength = 1.0;+#endif`,eC=`#ifdef USE_SPECULARMAP+ uniform sampler2D specularMap;+#endif`,tC=`#if defined( TONE_MAPPING )+ gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );+#endif`,nC=`#ifndef saturate+#define saturate( a ) clamp( a, 0.0, 1.0 )+#endif+uniform float toneMappingExposure;+vec3 LinearToneMapping( vec3 color ) {+ return saturate( toneMappingExposure * color );+}+vec3 ReinhardToneMapping( vec3 color ) {+ color *= toneMappingExposure;+ return saturate( color / ( vec3( 1.0 ) + color ) );+}+vec3 CineonToneMapping( vec3 color ) {+ color *= toneMappingExposure;+ color = max( vec3( 0.0 ), color - 0.004 );+ return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );+}+vec3 RRTAndODTFit( vec3 v ) {+ vec3 a = v * ( v + 0.0245786 ) - 0.000090537;+ vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;+ return a / b;+}+vec3 ACESFilmicToneMapping( vec3 color ) {+ const mat3 ACESInputMat = mat3(+ vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),+ vec3( 0.04823, 0.01566, 0.83777 )+ );+ const mat3 ACESOutputMat = mat3(+ vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),+ vec3( -0.07367, -0.00605, 1.07602 )+ );+ color *= toneMappingExposure / 0.6;+ color = ACESInputMat * color;+ color = RRTAndODTFit( color );+ color = ACESOutputMat * color;+ return saturate( color );+}+const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(+ vec3( 1.6605, - 0.1246, - 0.0182 ),+ vec3( - 0.5876, 1.1329, - 0.1006 ),+ vec3( - 0.0728, - 0.0083, 1.1187 )+);+const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(+ vec3( 0.6274, 0.0691, 0.0164 ),+ vec3( 0.3293, 0.9195, 0.0880 ),+ vec3( 0.0433, 0.0113, 0.8956 )+);+vec3 agxDefaultContrastApprox( vec3 x ) {+ vec3 x2 = x * x;+ vec3 x4 = x2 * x2;+ return + 15.5 * x4 * x2+ - 40.14 * x4 * x+ + 31.96 * x4+ - 6.868 * x2 * x+ + 0.4298 * x2+ + 0.1191 * x+ - 0.00232;+}+vec3 AgXToneMapping( vec3 color ) {+ const mat3 AgXInsetMatrix = mat3(+ vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),+ vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),+ vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )+ );+ const mat3 AgXOutsetMatrix = mat3(+ vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),+ vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),+ vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )+ );+ const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;+ color *= toneMappingExposure;+ color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;+ color = AgXInsetMatrix * color;+ color = max( color, 1e-10 ); color = log2( color );+ color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );+ color = clamp( color, 0.0, 1.0 );+ color = agxDefaultContrastApprox( color );+ color = AgXOutsetMatrix * color;+ color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );+ color = LINEAR_REC2020_TO_LINEAR_SRGB * color;+ color = clamp( color, 0.0, 1.0 );+ return color;+}+vec3 NeutralToneMapping( vec3 color ) {+ const float StartCompression = 0.8 - 0.04;+ const float Desaturation = 0.15;+ color *= toneMappingExposure;+ float x = min( color.r, min( color.g, color.b ) );+ float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;+ color -= offset;+ float peak = max( color.r, max( color.g, color.b ) );+ if ( peak < StartCompression ) return color;+ float d = 1. - StartCompression;+ float newPeak = 1. - d * d / ( peak + d - StartCompression );+ color *= newPeak / peak;+ float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );+ return mix( color, vec3( newPeak ), g );+}+vec3 CustomToneMapping( vec3 color ) { return color; }`,iC=`#ifdef USE_TRANSMISSION+ material.transmission = transmission;+ material.transmissionAlpha = 1.0;+ material.thickness = thickness;+ material.attenuationDistance = attenuationDistance;+ material.attenuationColor = attenuationColor;+ #ifdef USE_TRANSMISSIONMAP+ material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;+ #endif+ #ifdef USE_THICKNESSMAP+ material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;+ #endif+ vec3 pos = vWorldPosition;+ vec3 v = normalize( cameraPosition - pos );+ vec3 n = inverseTransformDirection( normal, viewMatrix );+ vec4 transmitted = getIBLVolumeRefraction(+ n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,+ pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,+ material.attenuationColor, material.attenuationDistance );+ material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );+ totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );+#endif`,sC=`#ifdef USE_TRANSMISSION+ uniform float transmission;+ uniform float thickness;+ uniform float attenuationDistance;+ uniform vec3 attenuationColor;+ #ifdef USE_TRANSMISSIONMAP+ uniform sampler2D transmissionMap;+ #endif+ #ifdef USE_THICKNESSMAP+ uniform sampler2D thicknessMap;+ #endif+ uniform vec2 transmissionSamplerSize;+ uniform sampler2D transmissionSamplerMap;+ uniform mat4 modelMatrix;+ uniform mat4 projectionMatrix;+ varying vec3 vWorldPosition;+ float w0( float a ) {+ return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );+ }+ float w1( float a ) {+ return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );+ }+ float w2( float a ){+ return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );+ }+ float w3( float a ) {+ return ( 1.0 / 6.0 ) * ( a * a * a );+ }+ float g0( float a ) {+ return w0( a ) + w1( a );+ }+ float g1( float a ) {+ return w2( a ) + w3( a );+ }+ float h0( float a ) {+ return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );+ }+ float h1( float a ) {+ return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );+ }+ vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {+ uv = uv * texelSize.zw + 0.5;+ vec2 iuv = floor( uv );+ vec2 fuv = fract( uv );+ float g0x = g0( fuv.x );+ float g1x = g1( fuv.x );+ float h0x = h0( fuv.x );+ float h1x = h1( fuv.x );+ float h0y = h0( fuv.y );+ float h1y = h1( fuv.y );+ vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;+ vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;+ vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;+ vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;+ return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) ++ g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );+ }+ vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {+ vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );+ vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );+ vec2 fLodSizeInv = 1.0 / fLodSize;+ vec2 cLodSizeInv = 1.0 / cLodSize;+ vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );+ vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );+ return mix( fSample, cSample, fract( lod ) );+ }+ vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {+ vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );+ vec3 modelScale;+ modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );+ modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );+ modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );+ return normalize( refractionVector ) * thickness * modelScale;+ }+ float applyIorToRoughness( const in float roughness, const in float ior ) {+ return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );+ }+ vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {+ float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );+ return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );+ }+ vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {+ if ( isinf( attenuationDistance ) ) {+ return vec3( 1.0 );+ } else {+ vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;+ vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;+ }+ }+ vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,+ const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,+ const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,+ const in vec3 attenuationColor, const in float attenuationDistance ) {+ vec4 transmittedLight;+ vec3 transmittance;+ #ifdef USE_DISPERSION+ float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;+ vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );+ for ( int i = 0; i < 3; i ++ ) {+ vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );+ vec3 refractedRayExit = position + transmissionRay;+ vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );+ vec2 refractionCoords = ndcPos.xy / ndcPos.w;+ refractionCoords += 1.0;+ refractionCoords /= 2.0;+ vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );+ transmittedLight[ i ] = transmissionSample[ i ];+ transmittedLight.a += transmissionSample.a;+ transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];+ }+ transmittedLight.a /= 3.0;+ #else+ vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );+ vec3 refractedRayExit = position + transmissionRay;+ vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );+ vec2 refractionCoords = ndcPos.xy / ndcPos.w;+ refractionCoords += 1.0;+ refractionCoords /= 2.0;+ transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );+ transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );+ #endif+ vec3 attenuatedColor = transmittance * transmittedLight.rgb;+ vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );+ float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;+ return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );+ }+#endif`,rC=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )+ varying vec2 vUv;+#endif+#ifdef USE_MAP+ varying vec2 vMapUv;+#endif+#ifdef USE_ALPHAMAP+ varying vec2 vAlphaMapUv;+#endif+#ifdef USE_LIGHTMAP+ varying vec2 vLightMapUv;+#endif+#ifdef USE_AOMAP+ varying vec2 vAoMapUv;+#endif+#ifdef USE_BUMPMAP+ varying vec2 vBumpMapUv;+#endif+#ifdef USE_NORMALMAP+ varying vec2 vNormalMapUv;+#endif+#ifdef USE_EMISSIVEMAP+ varying vec2 vEmissiveMapUv;+#endif+#ifdef USE_METALNESSMAP+ varying vec2 vMetalnessMapUv;+#endif+#ifdef USE_ROUGHNESSMAP+ varying vec2 vRoughnessMapUv;+#endif+#ifdef USE_ANISOTROPYMAP+ varying vec2 vAnisotropyMapUv;+#endif+#ifdef USE_CLEARCOATMAP+ varying vec2 vClearcoatMapUv;+#endif+#ifdef USE_CLEARCOAT_NORMALMAP+ varying vec2 vClearcoatNormalMapUv;+#endif+#ifdef USE_CLEARCOAT_ROUGHNESSMAP+ varying vec2 vClearcoatRoughnessMapUv;+#endif+#ifdef USE_IRIDESCENCEMAP+ varying vec2 vIridescenceMapUv;+#endif+#ifdef USE_IRIDESCENCE_THICKNESSMAP+ varying vec2 vIridescenceThicknessMapUv;+#endif+#ifdef USE_SHEEN_COLORMAP+ varying vec2 vSheenColorMapUv;+#endif+#ifdef USE_SHEEN_ROUGHNESSMAP+ varying vec2 vSheenRoughnessMapUv;+#endif+#ifdef USE_SPECULARMAP+ varying vec2 vSpecularMapUv;+#endif+#ifdef USE_SPECULAR_COLORMAP+ varying vec2 vSpecularColorMapUv;+#endif+#ifdef USE_SPECULAR_INTENSITYMAP+ varying vec2 vSpecularIntensityMapUv;+#endif+#ifdef USE_TRANSMISSIONMAP+ uniform mat3 transmissionMapTransform;+ varying vec2 vTransmissionMapUv;+#endif+#ifdef USE_THICKNESSMAP+ uniform mat3 thicknessMapTransform;+ varying vec2 vThicknessMapUv;+#endif`,aC=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )+ varying vec2 vUv;+#endif+#ifdef USE_MAP+ uniform mat3 mapTransform;+ varying vec2 vMapUv;+#endif+#ifdef USE_ALPHAMAP+ uniform mat3 alphaMapTransform;+ varying vec2 vAlphaMapUv;+#endif+#ifdef USE_LIGHTMAP+ uniform mat3 lightMapTransform;+ varying vec2 vLightMapUv;+#endif+#ifdef USE_AOMAP+ uniform mat3 aoMapTransform;+ varying vec2 vAoMapUv;+#endif+#ifdef USE_BUMPMAP+ uniform mat3 bumpMapTransform;+ varying vec2 vBumpMapUv;+#endif+#ifdef USE_NORMALMAP+ uniform mat3 normalMapTransform;+ varying vec2 vNormalMapUv;+#endif+#ifdef USE_DISPLACEMENTMAP+ uniform mat3 displacementMapTransform;+ varying vec2 vDisplacementMapUv;+#endif+#ifdef USE_EMISSIVEMAP+ uniform mat3 emissiveMapTransform;+ varying vec2 vEmissiveMapUv;+#endif+#ifdef USE_METALNESSMAP+ uniform mat3 metalnessMapTransform;+ varying vec2 vMetalnessMapUv;+#endif+#ifdef USE_ROUGHNESSMAP+ uniform mat3 roughnessMapTransform;+ varying vec2 vRoughnessMapUv;+#endif+#ifdef USE_ANISOTROPYMAP+ uniform mat3 anisotropyMapTransform;+ varying vec2 vAnisotropyMapUv;+#endif+#ifdef USE_CLEARCOATMAP+ uniform mat3 clearcoatMapTransform;+ varying vec2 vClearcoatMapUv;+#endif+#ifdef USE_CLEARCOAT_NORMALMAP+ uniform mat3 clearcoatNormalMapTransform;+ varying vec2 vClearcoatNormalMapUv;+#endif+#ifdef USE_CLEARCOAT_ROUGHNESSMAP+ uniform mat3 clearcoatRoughnessMapTransform;+ varying vec2 vClearcoatRoughnessMapUv;+#endif+#ifdef USE_SHEEN_COLORMAP+ uniform mat3 sheenColorMapTransform;+ varying vec2 vSheenColorMapUv;+#endif+#ifdef USE_SHEEN_ROUGHNESSMAP+ uniform mat3 sheenRoughnessMapTransform;+ varying vec2 vSheenRoughnessMapUv;+#endif+#ifdef USE_IRIDESCENCEMAP+ uniform mat3 iridescenceMapTransform;+ varying vec2 vIridescenceMapUv;+#endif+#ifdef USE_IRIDESCENCE_THICKNESSMAP+ uniform mat3 iridescenceThicknessMapTransform;+ varying vec2 vIridescenceThicknessMapUv;+#endif+#ifdef USE_SPECULARMAP+ uniform mat3 specularMapTransform;+ varying vec2 vSpecularMapUv;+#endif+#ifdef USE_SPECULAR_COLORMAP+ uniform mat3 specularColorMapTransform;+ varying vec2 vSpecularColorMapUv;+#endif+#ifdef USE_SPECULAR_INTENSITYMAP+ uniform mat3 specularIntensityMapTransform;+ varying vec2 vSpecularIntensityMapUv;+#endif+#ifdef USE_TRANSMISSIONMAP+ uniform mat3 transmissionMapTransform;+ varying vec2 vTransmissionMapUv;+#endif+#ifdef USE_THICKNESSMAP+ uniform mat3 thicknessMapTransform;+ varying vec2 vThicknessMapUv;+#endif`,oC=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )+ vUv = vec3( uv, 1 ).xy;+#endif+#ifdef USE_MAP+ vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;+#endif+#ifdef USE_ALPHAMAP+ vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;+#endif+#ifdef USE_LIGHTMAP+ vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;+#endif+#ifdef USE_AOMAP+ vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;+#endif+#ifdef USE_BUMPMAP+ vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;+#endif+#ifdef USE_NORMALMAP+ vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;+#endif+#ifdef USE_DISPLACEMENTMAP+ vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;+#endif+#ifdef USE_EMISSIVEMAP+ vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;+#endif+#ifdef USE_METALNESSMAP+ vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;+#endif+#ifdef USE_ROUGHNESSMAP+ vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;+#endif+#ifdef USE_ANISOTROPYMAP+ vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;+#endif+#ifdef USE_CLEARCOATMAP+ vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;+#endif+#ifdef USE_CLEARCOAT_NORMALMAP+ vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;+#endif+#ifdef USE_CLEARCOAT_ROUGHNESSMAP+ vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;+#endif+#ifdef USE_IRIDESCENCEMAP+ vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;+#endif+#ifdef USE_IRIDESCENCE_THICKNESSMAP+ vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;+#endif+#ifdef USE_SHEEN_COLORMAP+ vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;+#endif+#ifdef USE_SHEEN_ROUGHNESSMAP+ vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;+#endif+#ifdef USE_SPECULARMAP+ vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;+#endif+#ifdef USE_SPECULAR_COLORMAP+ vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;+#endif+#ifdef USE_SPECULAR_INTENSITYMAP+ vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;+#endif+#ifdef USE_TRANSMISSIONMAP+ vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;+#endif+#ifdef USE_THICKNESSMAP+ vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;+#endif`,cC=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0+ vec4 worldPosition = vec4( transformed, 1.0 );+ #ifdef USE_BATCHING+ worldPosition = batchingMatrix * worldPosition;+ #endif+ #ifdef USE_INSTANCING+ worldPosition = instanceMatrix * worldPosition;+ #endif+ worldPosition = modelMatrix * worldPosition;+#endif`;const ot={alphahash_fragment:hw,alphahash_pars_fragment:uw,alphamap_fragment:dw,alphamap_pars_fragment:fw,alphatest_fragment:pw,alphatest_pars_fragment:Aw,aomap_fragment:gw,aomap_pars_fragment:mw,batching_pars_vertex:bw,batching_vertex:xw,begin_vertex:_w,beginnormal_vertex:Ew,bsdfs:yw,iridescence_fragment:ww,bumpmap_pars_fragment:vw,clipping_planes_fragment:Cw,clipping_planes_pars_fragment:Sw,clipping_planes_pars_vertex:Iw,clipping_planes_vertex:Mw,color_fragment:Bw,color_pars_fragment:Tw,color_pars_vertex:Rw,color_vertex:Nw,common:Fw,cube_uv_reflection_fragment:Dw,defaultnormal_vertex:Lw,displacementmap_pars_vertex:Pw,displacementmap_vertex:kw,emissivemap_fragment:Uw,emissivemap_pars_fragment:Ow,colorspace_fragment:Qw,colorspace_pars_fragment:Gw,envmap_fragment:Hw,envmap_common_pars_fragment:zw,envmap_pars_fragment:Vw,envmap_pars_vertex:Ww,envmap_physical_pars_fragment:nv,envmap_vertex:qw,fog_vertex:Kw,fog_pars_vertex:jw,fog_fragment:Xw,fog_pars_fragment:Yw,gradientmap_pars_fragment:Jw,lightmap_pars_fragment:Zw,lights_lambert_fragment:$w,lights_lambert_pars_fragment:ev,lights_pars_begin:tv,lights_toon_fragment:iv,lights_toon_pars_fragment:sv,lights_phong_fragment:rv,lights_phong_pars_fragment:av,lights_physical_fragment:ov,lights_physical_pars_fragment:cv,lights_fragment_begin:lv,lights_fragment_maps:hv,lights_fragment_end:uv,logdepthbuf_fragment:dv,logdepthbuf_pars_fragment:fv,logdepthbuf_pars_vertex:pv,logdepthbuf_vertex:Av,map_fragment:gv,map_pars_fragment:mv,map_particle_fragment:bv,map_particle_pars_fragment:xv,metalnessmap_fragment:_v,metalnessmap_pars_fragment:Ev,morphinstance_vertex:yv,morphcolor_vertex:wv,morphnormal_vertex:vv,morphtarget_pars_vertex:Cv,morphtarget_vertex:Sv,normal_fragment_begin:Iv,normal_fragment_maps:Mv,normal_pars_fragment:Bv,normal_pars_vertex:Tv,normal_vertex:Rv,normalmap_pars_fragment:Nv,clearcoat_normal_fragment_begin:Fv,clearcoat_normal_fragment_maps:Dv,clearcoat_pars_fragment:Lv,iridescence_pars_fragment:Pv,opaque_fragment:kv,packing:Uv,premultiplied_alpha_fragment:Ov,project_vertex:Qv,dithering_fragment:Gv,dithering_pars_fragment:Hv,roughnessmap_fragment:zv,roughnessmap_pars_fragment:Vv,shadowmap_pars_fragment:Wv,shadowmap_pars_vertex:qv,shadowmap_vertex:Kv,shadowmask_pars_fragment:jv,skinbase_vertex:Xv,skinning_pars_vertex:Yv,skinning_vertex:Jv,skinnormal_vertex:Zv,specularmap_fragment:$v,specularmap_pars_fragment:eC,tonemapping_fragment:tC,tonemapping_pars_fragment:nC,transmission_fragment:iC,transmission_pars_fragment:sC,uv_pars_fragment:rC,uv_pars_vertex:aC,uv_vertex:oC,worldpos_vertex:cC,background_vert:`varying vec2 vUv;+uniform mat3 uvTransform;+void main() {+ vUv = ( uvTransform * vec3( uv, 1 ) ).xy;+ gl_Position = vec4( position.xy, 1.0, 1.0 );+}`,background_frag:`uniform sampler2D t2D;+uniform float backgroundIntensity;+varying vec2 vUv;+void main() {+ vec4 texColor = texture2D( t2D, vUv );+ #ifdef DECODE_VIDEO_TEXTURE+ texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );+ #endif+ texColor.rgb *= backgroundIntensity;+ gl_FragColor = texColor;+ #include <tonemapping_fragment>+ #include <colorspace_fragment>+}`,backgroundCube_vert:`varying vec3 vWorldDirection;+#include <common>+void main() {+ vWorldDirection = transformDirection( position, modelMatrix );+ #include <begin_vertex>+ #include <project_vertex>+ gl_Position.z = gl_Position.w;+}`,backgroundCube_frag:`#ifdef ENVMAP_TYPE_CUBE+ uniform samplerCube envMap;+#elif defined( ENVMAP_TYPE_CUBE_UV )+ uniform sampler2D envMap;+#endif+uniform float flipEnvMap;+uniform float backgroundBlurriness;+uniform float backgroundIntensity;+uniform mat3 backgroundRotation;+varying vec3 vWorldDirection;+#include <cube_uv_reflection_fragment>+void main() {+ #ifdef ENVMAP_TYPE_CUBE+ vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );+ #elif defined( ENVMAP_TYPE_CUBE_UV )+ vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );+ #else+ vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );+ #endif+ texColor.rgb *= backgroundIntensity;+ gl_FragColor = texColor;+ #include <tonemapping_fragment>+ #include <colorspace_fragment>+}`,cube_vert:`varying vec3 vWorldDirection;+#include <common>+void main() {+ vWorldDirection = transformDirection( position, modelMatrix );+ #include <begin_vertex>+ #include <project_vertex>+ gl_Position.z = gl_Position.w;+}`,cube_frag:`uniform samplerCube tCube;+uniform float tFlip;+uniform float opacity;+varying vec3 vWorldDirection;+void main() {+ vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );+ gl_FragColor = texColor;+ gl_FragColor.a *= opacity;+ #include <tonemapping_fragment>+ #include <colorspace_fragment>+}`,depth_vert:`#include <common>+#include <batching_pars_vertex>+#include <uv_pars_vertex>+#include <displacementmap_pars_vertex>+#include <morphtarget_pars_vertex>+#include <skinning_pars_vertex>+#include <logdepthbuf_pars_vertex>+#include <clipping_planes_pars_vertex>+varying vec2 vHighPrecisionZW;+void main() {+ #include <uv_vertex>+ #include <batching_vertex>+ #include <skinbase_vertex>+ #include <morphinstance_vertex>+ #ifdef USE_DISPLACEMENTMAP+ #include <beginnormal_vertex>+ #include <morphnormal_vertex>+ #include <skinnormal_vertex>+ #endif+ #include <begin_vertex>+ #include <morphtarget_vertex>+ #include <skinning_vertex>+ #include <displacementmap_vertex>+ #include <project_vertex>+ #include <logdepthbuf_vertex>+ #include <clipping_planes_vertex>+ vHighPrecisionZW = gl_Position.zw;+}`,depth_frag:`#if DEPTH_PACKING == 3200+ uniform float opacity;+#endif+#include <common>+#include <packing>+#include <uv_pars_fragment>+#include <map_pars_fragment>+#include <alphamap_pars_fragment>+#include <alphatest_pars_fragment>+#include <alphahash_pars_fragment>+#include <logdepthbuf_pars_fragment>+#include <clipping_planes_pars_fragment>+varying vec2 vHighPrecisionZW;+void main() {+ vec4 diffuseColor = vec4( 1.0 );+ #include <clipping_planes_fragment>+ #if DEPTH_PACKING == 3200+ diffuseColor.a = opacity;+ #endif+ #include <map_fragment>+ #include <alphamap_fragment>+ #include <alphatest_fragment>+ #include <alphahash_fragment>+ #include <logdepthbuf_fragment>+ float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;+ #if DEPTH_PACKING == 3200+ gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );+ #elif DEPTH_PACKING == 3201+ gl_FragColor = packDepthToRGBA( fragCoordZ );+ #elif DEPTH_PACKING == 3202+ gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );+ #elif DEPTH_PACKING == 3203+ gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );+ #endif+}`,distanceRGBA_vert:`#define DISTANCE+varying vec3 vWorldPosition;+#include <common>+#include <batching_pars_vertex>+#include <uv_pars_vertex>+#include <displacementmap_pars_vertex>+#include <morphtarget_pars_vertex>+#include <skinning_pars_vertex>+#include <clipping_planes_pars_vertex>+void main() {+ #include <uv_vertex>+ #include <batching_vertex>+ #include <skinbase_vertex>+ #include <morphinstance_vertex>+ #ifdef USE_DISPLACEMENTMAP+ #include <beginnormal_vertex>+ #include <morphnormal_vertex>+ #include <skinnormal_vertex>+ #endif+ #include <begin_vertex>+ #include <morphtarget_vertex>+ #include <skinning_vertex>+ #include <displacementmap_vertex>+ #include <project_vertex>+ #include <worldpos_vertex>+ #include <clipping_planes_vertex>+ vWorldPosition = worldPosition.xyz;+}`,distanceRGBA_frag:`#define DISTANCE+uniform vec3 referencePosition;+uniform float nearDistance;+uniform float farDistance;+varying vec3 vWorldPosition;+#include <common>+#include <packing>+#include <uv_pars_fragment>+#include <map_pars_fragment>+#include <alphamap_pars_fragment>+#include <alphatest_pars_fragment>+#include <alphahash_pars_fragment>+#include <clipping_planes_pars_fragment>+void main () {+ vec4 diffuseColor = vec4( 1.0 );+ #include <clipping_planes_fragment>+ #include <map_fragment>+ #include <alphamap_fragment>+ #include <alphatest_fragment>+ #include <alphahash_fragment>+ float dist = length( vWorldPosition - referencePosition );+ dist = ( dist - nearDistance ) / ( farDistance - nearDistance );+ dist = saturate( dist );+ gl_FragColor = packDepthToRGBA( dist );+}`,equirect_vert:`varying vec3 vWorldDirection;+#include <common>+void main() {+ vWorldDirection = transformDirection( position, modelMatrix );+ #include <begin_vertex>+ #include <project_vertex>+}`,equirect_frag:`uniform sampler2D tEquirect;+varying vec3 vWorldDirection;+#include <common>+void main() {+ vec3 direction = normalize( vWorldDirection );+ vec2 sampleUV = equirectUv( direction );+ gl_FragColor = texture2D( tEquirect, sampleUV );+ #include <tonemapping_fragment>+ #include <colorspace_fragment>+}`,linedashed_vert:`uniform float scale;+attribute float lineDistance;+varying float vLineDistance;+#include <common>+#include <uv_pars_vertex>+#include <color_pars_vertex>+#include <fog_pars_vertex>+#include <morphtarget_pars_vertex>+#include <logdepthbuf_pars_vertex>+#include <clipping_planes_pars_vertex>+void main() {+ vLineDistance = scale * lineDistance;+ #include <uv_vertex>+ #include <color_vertex>+ #include <morphinstance_vertex>+ #include <morphcolor_vertex>+ #include <begin_vertex>+ #include <morphtarget_vertex>+ #include <project_vertex>+ #include <logdepthbuf_vertex>+ #include <clipping_planes_vertex>+ #include <fog_vertex>+}`,linedashed_frag:`uniform vec3 diffuse;+uniform float opacity;+uniform float dashSize;+uniform float totalSize;+varying float vLineDistance;+#include <common>+#include <color_pars_fragment>+#include <uv_pars_fragment>+#include <map_pars_fragment>+#include <fog_pars_fragment>+#include <logdepthbuf_pars_fragment>+#include <clipping_planes_pars_fragment>+void main() {+ vec4 diffuseColor = vec4( diffuse, opacity );+ #include <clipping_planes_fragment>+ if ( mod( vLineDistance, totalSize ) > dashSize ) {+ discard;+ }+ vec3 outgoingLight = vec3( 0.0 );+ #include <logdepthbuf_fragment>+ #include <map_fragment>+ #include <color_fragment>+ outgoingLight = diffuseColor.rgb;+ #include <opaque_fragment>+ #include <tonemapping_fragment>+ #include <colorspace_fragment>+ #include <fog_fragment>+ #include <premultiplied_alpha_fragment>+}`,meshbasic_vert:`#include <common>+#include <batching_pars_vertex>+#include <uv_pars_vertex>+#include <envmap_pars_vertex>+#include <color_pars_vertex>+#include <fog_pars_vertex>+#include <morphtarget_pars_vertex>+#include <skinning_pars_vertex>+#include <logdepthbuf_pars_vertex>+#include <clipping_planes_pars_vertex>+void main() {+ #include <uv_vertex>+ #include <color_vertex>+ #include <morphinstance_vertex>+ #include <morphcolor_vertex>+ #include <batching_vertex>+ #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )+ #include <beginnormal_vertex>+ #include <morphnormal_vertex>+ #include <skinbase_vertex>+ #include <skinnormal_vertex>+ #include <defaultnormal_vertex>+ #endif+ #include <begin_vertex>+ #include <morphtarget_vertex>+ #include <skinning_vertex>+ #include <project_vertex>+ #include <logdepthbuf_vertex>+ #include <clipping_planes_vertex>+ #include <worldpos_vertex>+ #include <envmap_vertex>+ #include <fog_vertex>+}`,meshbasic_frag:`uniform vec3 diffuse;+uniform float opacity;+#ifndef FLAT_SHADED+ varying vec3 vNormal;+#endif+#include <common>+#include <dithering_pars_fragment>+#include <color_pars_fragment>+#include <uv_pars_fragment>+#include <map_pars_fragment>+#include <alphamap_pars_fragment>+#include <alphatest_pars_fragment>+#include <alphahash_pars_fragment>+#include <aomap_pars_fragment>+#include <lightmap_pars_fragment>+#include <envmap_common_pars_fragment>+#include <envmap_pars_fragment>+#include <fog_pars_fragment>+#include <specularmap_pars_fragment>+#include <logdepthbuf_pars_fragment>+#include <clipping_planes_pars_fragment>+void main() {+ vec4 diffuseColor = vec4( diffuse, opacity );+ #include <clipping_planes_fragment>+ #include <logdepthbuf_fragment>+ #include <map_fragment>+ #include <color_fragment>+ #include <alphamap_fragment>+ #include <alphatest_fragment>+ #include <alphahash_fragment>+ #include <specularmap_fragment>+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );+ #ifdef USE_LIGHTMAP+ vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );+ reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;+ #else+ reflectedLight.indirectDiffuse += vec3( 1.0 );+ #endif+ #include <aomap_fragment>+ reflectedLight.indirectDiffuse *= diffuseColor.rgb;+ vec3 outgoingLight = reflectedLight.indirectDiffuse;+ #include <envmap_fragment>+ #include <opaque_fragment>+ #include <tonemapping_fragment>+ #include <colorspace_fragment>+ #include <fog_fragment>+ #include <premultiplied_alpha_fragment>+ #include <dithering_fragment>+}`,meshlambert_vert:`#define LAMBERT+varying vec3 vViewPosition;+#include <common>+#include <batching_pars_vertex>+#include <uv_pars_vertex>+#include <displacementmap_pars_vertex>+#include <envmap_pars_vertex>+#include <color_pars_vertex>+#include <fog_pars_vertex>+#include <normal_pars_vertex>+#include <morphtarget_pars_vertex>+#include <skinning_pars_vertex>+#include <shadowmap_pars_vertex>+#include <logdepthbuf_pars_vertex>+#include <clipping_planes_pars_vertex>+void main() {+ #include <uv_vertex>+ #include <color_vertex>+ #include <morphinstance_vertex>+ #include <morphcolor_vertex>+ #include <batching_vertex>+ #include <beginnormal_vertex>+ #include <morphnormal_vertex>+ #include <skinbase_vertex>+ #include <skinnormal_vertex>+ #include <defaultnormal_vertex>+ #include <normal_vertex>+ #include <begin_vertex>+ #include <morphtarget_vertex>+ #include <skinning_vertex>+ #include <displacementmap_vertex>+ #include <project_vertex>+ #include <logdepthbuf_vertex>+ #include <clipping_planes_vertex>+ vViewPosition = - mvPosition.xyz;+ #include <worldpos_vertex>+ #include <envmap_vertex>+ #include <shadowmap_vertex>+ #include <fog_vertex>+}`,meshlambert_frag:`#define LAMBERT+uniform vec3 diffuse;+uniform vec3 emissive;+uniform float opacity;+#include <common>+#include <packing>+#include <dithering_pars_fragment>+#include <color_pars_fragment>+#include <uv_pars_fragment>+#include <map_pars_fragment>+#include <alphamap_pars_fragment>+#include <alphatest_pars_fragment>+#include <alphahash_pars_fragment>+#include <aomap_pars_fragment>+#include <lightmap_pars_fragment>+#include <emissivemap_pars_fragment>+#include <envmap_common_pars_fragment>+#include <envmap_pars_fragment>+#include <fog_pars_fragment>+#include <bsdfs>+#include <lights_pars_begin>+#include <normal_pars_fragment>+#include <lights_lambert_pars_fragment>+#include <shadowmap_pars_fragment>+#include <bumpmap_pars_fragment>+#include <normalmap_pars_fragment>+#include <specularmap_pars_fragment>+#include <logdepthbuf_pars_fragment>+#include <clipping_planes_pars_fragment>+void main() {+ vec4 diffuseColor = vec4( diffuse, opacity );+ #include <clipping_planes_fragment>+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );+ vec3 totalEmissiveRadiance = emissive;+ #include <logdepthbuf_fragment>+ #include <map_fragment>+ #include <color_fragment>+ #include <alphamap_fragment>+ #include <alphatest_fragment>+ #include <alphahash_fragment>+ #include <specularmap_fragment>+ #include <normal_fragment_begin>+ #include <normal_fragment_maps>+ #include <emissivemap_fragment>+ #include <lights_lambert_fragment>+ #include <lights_fragment_begin>+ #include <lights_fragment_maps>+ #include <lights_fragment_end>+ #include <aomap_fragment>+ vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;+ #include <envmap_fragment>+ #include <opaque_fragment>+ #include <tonemapping_fragment>+ #include <colorspace_fragment>+ #include <fog_fragment>+ #include <premultiplied_alpha_fragment>+ #include <dithering_fragment>+}`,meshmatcap_vert:`#define MATCAP+varying vec3 vViewPosition;+#include <common>+#include <batching_pars_vertex>+#include <uv_pars_vertex>+#include <color_pars_vertex>+#include <displacementmap_pars_vertex>+#include <fog_pars_vertex>+#include <normal_pars_vertex>+#include <morphtarget_pars_vertex>+#include <skinning_pars_vertex>+#include <logdepthbuf_pars_vertex>+#include <clipping_planes_pars_vertex>+void main() {+ #include <uv_vertex>+ #include <color_vertex>+ #include <morphinstance_vertex>+ #include <morphcolor_vertex>+ #include <batching_vertex>+ #include <beginnormal_vertex>+ #include <morphnormal_vertex>+ #include <skinbase_vertex>+ #include <skinnormal_vertex>+ #include <defaultnormal_vertex>+ #include <normal_vertex>+ #include <begin_vertex>+ #include <morphtarget_vertex>+ #include <skinning_vertex>+ #include <displacementmap_vertex>+ #include <project_vertex>+ #include <logdepthbuf_vertex>+ #include <clipping_planes_vertex>+ #include <fog_vertex>+ vViewPosition = - mvPosition.xyz;+}`,meshmatcap_frag:`#define MATCAP+uniform vec3 diffuse;+uniform float opacity;+uniform sampler2D matcap;+varying vec3 vViewPosition;+#include <common>+#include <dithering_pars_fragment>+#include <color_pars_fragment>+#include <uv_pars_fragment>+#include <map_pars_fragment>+#include <alphamap_pars_fragment>+#include <alphatest_pars_fragment>+#include <alphahash_pars_fragment>+#include <fog_pars_fragment>+#include <normal_pars_fragment>+#include <bumpmap_pars_fragment>+#include <normalmap_pars_fragment>+#include <logdepthbuf_pars_fragment>+#include <clipping_planes_pars_fragment>+void main() {+ vec4 diffuseColor = vec4( diffuse, opacity );+ #include <clipping_planes_fragment>+ #include <logdepthbuf_fragment>+ #include <map_fragment>+ #include <color_fragment>+ #include <alphamap_fragment>+ #include <alphatest_fragment>+ #include <alphahash_fragment>+ #include <normal_fragment_begin>+ #include <normal_fragment_maps>+ vec3 viewDir = normalize( vViewPosition );+ vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );+ vec3 y = cross( viewDir, x );+ vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;+ #ifdef USE_MATCAP+ vec4 matcapColor = texture2D( matcap, uv );+ #else+ vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );+ #endif+ vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;+ #include <opaque_fragment>+ #include <tonemapping_fragment>+ #include <colorspace_fragment>+ #include <fog_fragment>+ #include <premultiplied_alpha_fragment>+ #include <dithering_fragment>+}`,meshnormal_vert:`#define NORMAL+#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )+ varying vec3 vViewPosition;+#endif+#include <common>+#include <batching_pars_vertex>+#include <uv_pars_vertex>+#include <displacementmap_pars_vertex>+#include <normal_pars_vertex>+#include <morphtarget_pars_vertex>+#include <skinning_pars_vertex>+#include <logdepthbuf_pars_vertex>+#include <clipping_planes_pars_vertex>+void main() {+ #include <uv_vertex>+ #include <batching_vertex>+ #include <beginnormal_vertex>+ #include <morphinstance_vertex>+ #include <morphnormal_vertex>+ #include <skinbase_vertex>+ #include <skinnormal_vertex>+ #include <defaultnormal_vertex>+ #include <normal_vertex>+ #include <begin_vertex>+ #include <morphtarget_vertex>+ #include <skinning_vertex>+ #include <displacementmap_vertex>+ #include <project_vertex>+ #include <logdepthbuf_vertex>+ #include <clipping_planes_vertex>+#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )+ vViewPosition = - mvPosition.xyz;+#endif+}`,meshnormal_frag:`#define NORMAL+uniform float opacity;+#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )+ varying vec3 vViewPosition;+#endif+#include <packing>+#include <uv_pars_fragment>+#include <normal_pars_fragment>+#include <bumpmap_pars_fragment>+#include <normalmap_pars_fragment>+#include <logdepthbuf_pars_fragment>+#include <clipping_planes_pars_fragment>+void main() {+ vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );+ #include <clipping_planes_fragment>+ #include <logdepthbuf_fragment>+ #include <normal_fragment_begin>+ #include <normal_fragment_maps>+ gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );+ #ifdef OPAQUE+ gl_FragColor.a = 1.0;+ #endif+}`,meshphong_vert:`#define PHONG+varying vec3 vViewPosition;+#include <common>+#include <batching_pars_vertex>+#include <uv_pars_vertex>+#include <displacementmap_pars_vertex>+#include <envmap_pars_vertex>+#include <color_pars_vertex>+#include <fog_pars_vertex>+#include <normal_pars_vertex>+#include <morphtarget_pars_vertex>+#include <skinning_pars_vertex>+#include <shadowmap_pars_vertex>+#include <logdepthbuf_pars_vertex>+#include <clipping_planes_pars_vertex>+void main() {+ #include <uv_vertex>+ #include <color_vertex>+ #include <morphcolor_vertex>+ #include <batching_vertex>+ #include <beginnormal_vertex>+ #include <morphinstance_vertex>+ #include <morphnormal_vertex>+ #include <skinbase_vertex>+ #include <skinnormal_vertex>+ #include <defaultnormal_vertex>+ #include <normal_vertex>+ #include <begin_vertex>+ #include <morphtarget_vertex>+ #include <skinning_vertex>+ #include <displacementmap_vertex>+ #include <project_vertex>+ #include <logdepthbuf_vertex>+ #include <clipping_planes_vertex>+ vViewPosition = - mvPosition.xyz;+ #include <worldpos_vertex>+ #include <envmap_vertex>+ #include <shadowmap_vertex>+ #include <fog_vertex>+}`,meshphong_frag:`#define PHONG+uniform vec3 diffuse;+uniform vec3 emissive;+uniform vec3 specular;+uniform float shininess;+uniform float opacity;+#include <common>+#include <packing>+#include <dithering_pars_fragment>+#include <color_pars_fragment>+#include <uv_pars_fragment>+#include <map_pars_fragment>+#include <alphamap_pars_fragment>+#include <alphatest_pars_fragment>+#include <alphahash_pars_fragment>+#include <aomap_pars_fragment>+#include <lightmap_pars_fragment>+#include <emissivemap_pars_fragment>+#include <envmap_common_pars_fragment>+#include <envmap_pars_fragment>+#include <fog_pars_fragment>+#include <bsdfs>+#include <lights_pars_begin>+#include <normal_pars_fragment>+#include <lights_phong_pars_fragment>+#include <shadowmap_pars_fragment>+#include <bumpmap_pars_fragment>+#include <normalmap_pars_fragment>+#include <specularmap_pars_fragment>+#include <logdepthbuf_pars_fragment>+#include <clipping_planes_pars_fragment>+void main() {+ vec4 diffuseColor = vec4( diffuse, opacity );+ #include <clipping_planes_fragment>+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );+ vec3 totalEmissiveRadiance = emissive;+ #include <logdepthbuf_fragment>+ #include <map_fragment>+ #include <color_fragment>+ #include <alphamap_fragment>+ #include <alphatest_fragment>+ #include <alphahash_fragment>+ #include <specularmap_fragment>+ #include <normal_fragment_begin>+ #include <normal_fragment_maps>+ #include <emissivemap_fragment>+ #include <lights_phong_fragment>+ #include <lights_fragment_begin>+ #include <lights_fragment_maps>+ #include <lights_fragment_end>+ #include <aomap_fragment>+ vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;+ #include <envmap_fragment>+ #include <opaque_fragment>+ #include <tonemapping_fragment>+ #include <colorspace_fragment>+ #include <fog_fragment>+ #include <premultiplied_alpha_fragment>+ #include <dithering_fragment>+}`,meshphysical_vert:`#define STANDARD+varying vec3 vViewPosition;+#ifdef USE_TRANSMISSION+ varying vec3 vWorldPosition;+#endif+#include <common>+#include <batching_pars_vertex>+#include <uv_pars_vertex>+#include <displacementmap_pars_vertex>+#include <color_pars_vertex>+#include <fog_pars_vertex>+#include <normal_pars_vertex>+#include <morphtarget_pars_vertex>+#include <skinning_pars_vertex>+#include <shadowmap_pars_vertex>+#include <logdepthbuf_pars_vertex>+#include <clipping_planes_pars_vertex>+void main() {+ #include <uv_vertex>+ #include <color_vertex>+ #include <morphinstance_vertex>+ #include <morphcolor_vertex>+ #include <batching_vertex>+ #include <beginnormal_vertex>+ #include <morphnormal_vertex>+ #include <skinbase_vertex>+ #include <skinnormal_vertex>+ #include <defaultnormal_vertex>+ #include <normal_vertex>+ #include <begin_vertex>+ #include <morphtarget_vertex>+ #include <skinning_vertex>+ #include <displacementmap_vertex>+ #include <project_vertex>+ #include <logdepthbuf_vertex>+ #include <clipping_planes_vertex>+ vViewPosition = - mvPosition.xyz;+ #include <worldpos_vertex>+ #include <shadowmap_vertex>+ #include <fog_vertex>+#ifdef USE_TRANSMISSION+ vWorldPosition = worldPosition.xyz;+#endif+}`,meshphysical_frag:`#define STANDARD+#ifdef PHYSICAL+ #define IOR+ #define USE_SPECULAR+#endif+uniform vec3 diffuse;+uniform vec3 emissive;+uniform float roughness;+uniform float metalness;+uniform float opacity;+#ifdef IOR+ uniform float ior;+#endif+#ifdef USE_SPECULAR+ uniform float specularIntensity;+ uniform vec3 specularColor;+ #ifdef USE_SPECULAR_COLORMAP+ uniform sampler2D specularColorMap;+ #endif+ #ifdef USE_SPECULAR_INTENSITYMAP+ uniform sampler2D specularIntensityMap;+ #endif+#endif+#ifdef USE_CLEARCOAT+ uniform float clearcoat;+ uniform float clearcoatRoughness;+#endif+#ifdef USE_DISPERSION+ uniform float dispersion;+#endif+#ifdef USE_IRIDESCENCE+ uniform float iridescence;+ uniform float iridescenceIOR;+ uniform float iridescenceThicknessMinimum;+ uniform float iridescenceThicknessMaximum;+#endif+#ifdef USE_SHEEN+ uniform vec3 sheenColor;+ uniform float sheenRoughness;+ #ifdef USE_SHEEN_COLORMAP+ uniform sampler2D sheenColorMap;+ #endif+ #ifdef USE_SHEEN_ROUGHNESSMAP+ uniform sampler2D sheenRoughnessMap;+ #endif+#endif+#ifdef USE_ANISOTROPY+ uniform vec2 anisotropyVector;+ #ifdef USE_ANISOTROPYMAP+ uniform sampler2D anisotropyMap;+ #endif+#endif+varying vec3 vViewPosition;+#include <common>+#include <packing>+#include <dithering_pars_fragment>+#include <color_pars_fragment>+#include <uv_pars_fragment>+#include <map_pars_fragment>+#include <alphamap_pars_fragment>+#include <alphatest_pars_fragment>+#include <alphahash_pars_fragment>+#include <aomap_pars_fragment>+#include <lightmap_pars_fragment>+#include <emissivemap_pars_fragment>+#include <iridescence_fragment>+#include <cube_uv_reflection_fragment>+#include <envmap_common_pars_fragment>+#include <envmap_physical_pars_fragment>+#include <fog_pars_fragment>+#include <lights_pars_begin>+#include <normal_pars_fragment>+#include <lights_physical_pars_fragment>+#include <transmission_pars_fragment>+#include <shadowmap_pars_fragment>+#include <bumpmap_pars_fragment>+#include <normalmap_pars_fragment>+#include <clearcoat_pars_fragment>+#include <iridescence_pars_fragment>+#include <roughnessmap_pars_fragment>+#include <metalnessmap_pars_fragment>+#include <logdepthbuf_pars_fragment>+#include <clipping_planes_pars_fragment>+void main() {+ vec4 diffuseColor = vec4( diffuse, opacity );+ #include <clipping_planes_fragment>+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );+ vec3 totalEmissiveRadiance = emissive;+ #include <logdepthbuf_fragment>+ #include <map_fragment>+ #include <color_fragment>+ #include <alphamap_fragment>+ #include <alphatest_fragment>+ #include <alphahash_fragment>+ #include <roughnessmap_fragment>+ #include <metalnessmap_fragment>+ #include <normal_fragment_begin>+ #include <normal_fragment_maps>+ #include <clearcoat_normal_fragment_begin>+ #include <clearcoat_normal_fragment_maps>+ #include <emissivemap_fragment>+ #include <lights_physical_fragment>+ #include <lights_fragment_begin>+ #include <lights_fragment_maps>+ #include <lights_fragment_end>+ #include <aomap_fragment>+ vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;+ vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;+ #include <transmission_fragment>+ vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;+ #ifdef USE_SHEEN+ float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );+ outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;+ #endif+ #ifdef USE_CLEARCOAT+ float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );+ vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );+ outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;+ #endif+ #include <opaque_fragment>+ #include <tonemapping_fragment>+ #include <colorspace_fragment>+ #include <fog_fragment>+ #include <premultiplied_alpha_fragment>+ #include <dithering_fragment>+}`,meshtoon_vert:`#define TOON+varying vec3 vViewPosition;+#include <common>+#include <batching_pars_vertex>+#include <uv_pars_vertex>+#include <displacementmap_pars_vertex>+#include <color_pars_vertex>+#include <fog_pars_vertex>+#include <normal_pars_vertex>+#include <morphtarget_pars_vertex>+#include <skinning_pars_vertex>+#include <shadowmap_pars_vertex>+#include <logdepthbuf_pars_vertex>+#include <clipping_planes_pars_vertex>+void main() {+ #include <uv_vertex>+ #include <color_vertex>+ #include <morphinstance_vertex>+ #include <morphcolor_vertex>+ #include <batching_vertex>+ #include <beginnormal_vertex>+ #include <morphnormal_vertex>+ #include <skinbase_vertex>+ #include <skinnormal_vertex>+ #include <defaultnormal_vertex>+ #include <normal_vertex>+ #include <begin_vertex>+ #include <morphtarget_vertex>+ #include <skinning_vertex>+ #include <displacementmap_vertex>+ #include <project_vertex>+ #include <logdepthbuf_vertex>+ #include <clipping_planes_vertex>+ vViewPosition = - mvPosition.xyz;+ #include <worldpos_vertex>+ #include <shadowmap_vertex>+ #include <fog_vertex>+}`,meshtoon_frag:`#define TOON+uniform vec3 diffuse;+uniform vec3 emissive;+uniform float opacity;+#include <common>+#include <packing>+#include <dithering_pars_fragment>+#include <color_pars_fragment>+#include <uv_pars_fragment>+#include <map_pars_fragment>+#include <alphamap_pars_fragment>+#include <alphatest_pars_fragment>+#include <alphahash_pars_fragment>+#include <aomap_pars_fragment>+#include <lightmap_pars_fragment>+#include <emissivemap_pars_fragment>+#include <gradientmap_pars_fragment>+#include <fog_pars_fragment>+#include <bsdfs>+#include <lights_pars_begin>+#include <normal_pars_fragment>+#include <lights_toon_pars_fragment>+#include <shadowmap_pars_fragment>+#include <bumpmap_pars_fragment>+#include <normalmap_pars_fragment>+#include <logdepthbuf_pars_fragment>+#include <clipping_planes_pars_fragment>+void main() {+ vec4 diffuseColor = vec4( diffuse, opacity );+ #include <clipping_planes_fragment>+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );+ vec3 totalEmissiveRadiance = emissive;+ #include <logdepthbuf_fragment>+ #include <map_fragment>+ #include <color_fragment>+ #include <alphamap_fragment>+ #include <alphatest_fragment>+ #include <alphahash_fragment>+ #include <normal_fragment_begin>+ #include <normal_fragment_maps>+ #include <emissivemap_fragment>+ #include <lights_toon_fragment>+ #include <lights_fragment_begin>+ #include <lights_fragment_maps>+ #include <lights_fragment_end>+ #include <aomap_fragment>+ vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;+ #include <opaque_fragment>+ #include <tonemapping_fragment>+ #include <colorspace_fragment>+ #include <fog_fragment>+ #include <premultiplied_alpha_fragment>+ #include <dithering_fragment>+}`,points_vert:`uniform float size;+uniform float scale;+#include <common>+#include <color_pars_vertex>+#include <fog_pars_vertex>+#include <morphtarget_pars_vertex>+#include <logdepthbuf_pars_vertex>+#include <clipping_planes_pars_vertex>+#ifdef USE_POINTS_UV+ varying vec2 vUv;+ uniform mat3 uvTransform;+#endif+void main() {+ #ifdef USE_POINTS_UV+ vUv = ( uvTransform * vec3( uv, 1 ) ).xy;+ #endif+ #include <color_vertex>+ #include <morphinstance_vertex>+ #include <morphcolor_vertex>+ #include <begin_vertex>+ #include <morphtarget_vertex>+ #include <project_vertex>+ gl_PointSize = size;+ #ifdef USE_SIZEATTENUATION+ bool isPerspective = isPerspectiveMatrix( projectionMatrix );+ if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );+ #endif+ #include <logdepthbuf_vertex>+ #include <clipping_planes_vertex>+ #include <worldpos_vertex>+ #include <fog_vertex>+}`,points_frag:`uniform vec3 diffuse;+uniform float opacity;+#include <common>+#include <color_pars_fragment>+#include <map_particle_pars_fragment>+#include <alphatest_pars_fragment>+#include <alphahash_pars_fragment>+#include <fog_pars_fragment>+#include <logdepthbuf_pars_fragment>+#include <clipping_planes_pars_fragment>+void main() {+ vec4 diffuseColor = vec4( diffuse, opacity );+ #include <clipping_planes_fragment>+ vec3 outgoingLight = vec3( 0.0 );+ #include <logdepthbuf_fragment>+ #include <map_particle_fragment>+ #include <color_fragment>+ #include <alphatest_fragment>+ #include <alphahash_fragment>+ outgoingLight = diffuseColor.rgb;+ #include <opaque_fragment>+ #include <tonemapping_fragment>+ #include <colorspace_fragment>+ #include <fog_fragment>+ #include <premultiplied_alpha_fragment>+}`,shadow_vert:`#include <common>+#include <batching_pars_vertex>+#include <fog_pars_vertex>+#include <morphtarget_pars_vertex>+#include <skinning_pars_vertex>+#include <logdepthbuf_pars_vertex>+#include <shadowmap_pars_vertex>+void main() {+ #include <batching_vertex>+ #include <beginnormal_vertex>+ #include <morphinstance_vertex>+ #include <morphnormal_vertex>+ #include <skinbase_vertex>+ #include <skinnormal_vertex>+ #include <defaultnormal_vertex>+ #include <begin_vertex>+ #include <morphtarget_vertex>+ #include <skinning_vertex>+ #include <project_vertex>+ #include <logdepthbuf_vertex>+ #include <worldpos_vertex>+ #include <shadowmap_vertex>+ #include <fog_vertex>+}`,shadow_frag:`uniform vec3 color;+uniform float opacity;+#include <common>+#include <packing>+#include <fog_pars_fragment>+#include <bsdfs>+#include <lights_pars_begin>+#include <logdepthbuf_pars_fragment>+#include <shadowmap_pars_fragment>+#include <shadowmask_pars_fragment>+void main() {+ #include <logdepthbuf_fragment>+ gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );+ #include <tonemapping_fragment>+ #include <colorspace_fragment>+ #include <fog_fragment>+}`,sprite_vert:`uniform float rotation;+uniform vec2 center;+#include <common>+#include <uv_pars_vertex>+#include <fog_pars_vertex>+#include <logdepthbuf_pars_vertex>+#include <clipping_planes_pars_vertex>+void main() {+ #include <uv_vertex>+ vec4 mvPosition = modelViewMatrix[ 3 ];+ vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );+ #ifndef USE_SIZEATTENUATION+ bool isPerspective = isPerspectiveMatrix( projectionMatrix );+ if ( isPerspective ) scale *= - mvPosition.z;+ #endif+ vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;+ vec2 rotatedPosition;+ rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;+ rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;+ mvPosition.xy += rotatedPosition;+ gl_Position = projectionMatrix * mvPosition;+ #include <logdepthbuf_vertex>+ #include <clipping_planes_vertex>+ #include <fog_vertex>+}`,sprite_frag:`uniform vec3 diffuse;+uniform float opacity;+#include <common>+#include <uv_pars_fragment>+#include <map_pars_fragment>+#include <alphamap_pars_fragment>+#include <alphatest_pars_fragment>+#include <alphahash_pars_fragment>+#include <fog_pars_fragment>+#include <logdepthbuf_pars_fragment>+#include <clipping_planes_pars_fragment>+void main() {+ vec4 diffuseColor = vec4( diffuse, opacity );+ #include <clipping_planes_fragment>+ vec3 outgoingLight = vec3( 0.0 );+ #include <logdepthbuf_fragment>+ #include <map_fragment>+ #include <alphamap_fragment>+ #include <alphatest_fragment>+ #include <alphahash_fragment>+ outgoingLight = diffuseColor.rgb;+ #include <opaque_fragment>+ #include <tonemapping_fragment>+ #include <colorspace_fragment>+ #include <fog_fragment>+}`},we={common:{diffuse:{value:new qe(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new rt},alphaMap:{value:null},alphaMapTransform:{value:new rt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new rt}},envmap:{envMap:{value:null},envMapRotation:{value:new rt},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new rt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new rt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new rt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new rt},normalScale:{value:new Ze(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new rt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new rt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new rt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new rt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new qe(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new qe(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new rt},alphaTest:{value:0},uvTransform:{value:new rt}},sprite:{diffuse:{value:new qe(16777215)},opacity:{value:1},center:{value:new Ze(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new rt},alphaMap:{value:null},alphaMapTransform:{value:new rt},alphaTest:{value:0}}},Di={basic:{uniforms:Rn([we.common,we.specularmap,we.envmap,we.aomap,we.lightmap,we.fog]),vertexShader:ot.meshbasic_vert,fragmentShader:ot.meshbasic_frag},lambert:{uniforms:Rn([we.common,we.specularmap,we.envmap,we.aomap,we.lightmap,we.emissivemap,we.bumpmap,we.normalmap,we.displacementmap,we.fog,we.lights,{emissive:{value:new qe(0)}}]),vertexShader:ot.meshlambert_vert,fragmentShader:ot.meshlambert_frag},phong:{uniforms:Rn([we.common,we.specularmap,we.envmap,we.aomap,we.lightmap,we.emissivemap,we.bumpmap,we.normalmap,we.displacementmap,we.fog,we.lights,{emissive:{value:new qe(0)},specular:{value:new qe(1118481)},shininess:{value:30}}]),vertexShader:ot.meshphong_vert,fragmentShader:ot.meshphong_frag},standard:{uniforms:Rn([we.common,we.envmap,we.aomap,we.lightmap,we.emissivemap,we.bumpmap,we.normalmap,we.displacementmap,we.roughnessmap,we.metalnessmap,we.fog,we.lights,{emissive:{value:new qe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:ot.meshphysical_vert,fragmentShader:ot.meshphysical_frag},toon:{uniforms:Rn([we.common,we.aomap,we.lightmap,we.emissivemap,we.bumpmap,we.normalmap,we.displacementmap,we.gradientmap,we.fog,we.lights,{emissive:{value:new qe(0)}}]),vertexShader:ot.meshtoon_vert,fragmentShader:ot.meshtoon_frag},matcap:{uniforms:Rn([we.common,we.bumpmap,we.normalmap,we.displacementmap,we.fog,{matcap:{value:null}}]),vertexShader:ot.meshmatcap_vert,fragmentShader:ot.meshmatcap_frag},points:{uniforms:Rn([we.points,we.fog]),vertexShader:ot.points_vert,fragmentShader:ot.points_frag},dashed:{uniforms:Rn([we.common,we.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ot.linedashed_vert,fragmentShader:ot.linedashed_frag},depth:{uniforms:Rn([we.common,we.displacementmap]),vertexShader:ot.depth_vert,fragmentShader:ot.depth_frag},normal:{uniforms:Rn([we.common,we.bumpmap,we.normalmap,we.displacementmap,{opacity:{value:1}}]),vertexShader:ot.meshnormal_vert,fragmentShader:ot.meshnormal_frag},sprite:{uniforms:Rn([we.sprite,we.fog]),vertexShader:ot.sprite_vert,fragmentShader:ot.sprite_frag},background:{uniforms:{uvTransform:{value:new rt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:ot.background_vert,fragmentShader:ot.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new rt}},vertexShader:ot.backgroundCube_vert,fragmentShader:ot.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:ot.cube_vert,fragmentShader:ot.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ot.equirect_vert,fragmentShader:ot.equirect_frag},distanceRGBA:{uniforms:Rn([we.common,we.displacementmap,{referencePosition:{value:new H},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:ot.distanceRGBA_vert,fragmentShader:ot.distanceRGBA_frag},shadow:{uniforms:Rn([we.lights,we.fog,{color:{value:new qe(0)},opacity:{value:1}}]),vertexShader:ot.shadow_vert,fragmentShader:ot.shadow_frag}};Di.physical={uniforms:Rn([Di.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new rt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new rt},clearcoatNormalScale:{value:new Ze(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new rt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new rt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new rt},sheen:{value:0},sheenColor:{value:new qe(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new rt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new rt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new rt},transmissionSamplerSize:{value:new Ze},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new rt},attenuationDistance:{value:0},attenuationColor:{value:new qe(0)},specularColor:{value:new qe(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new rt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new rt},anisotropyVector:{value:new Ze},anisotropyMap:{value:null},anisotropyMapTransform:{value:new rt}}]),vertexShader:ot.meshphysical_vert,fragmentShader:ot.meshphysical_frag};const al={r:0,b:0,g:0},rr=new Ri,lC=new $e;function hC(i,e,t,n,s,r,a){const o=new qe(0);let c=r===!0?0:1,l,h,u=null,d=0,f=null;function m(b){let E=b.isScene===!0?b.background:null;return E&&E.isTexture&&(E=(b.backgroundBlurriness>0?t:e).get(E)),E}function A(b){let E=!1;const M=m(b);M===null?p(o,c):M&&M.isColor&&(p(M,1),E=!0);const w=i.xr.getEnvironmentBlendMode();w==="additive"?n.buffers.color.setClear(0,0,0,1,a):w==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,a),(i.autoClear||E)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function g(b,E){const M=m(E);M&&(M.isCubeTexture||M.mapping===fc)?(h===void 0&&(h=new Jt(new na(1,1,1),new Is({name:"BackgroundCubeMaterial",uniforms:ia(Di.backgroundCube.uniforms),vertexShader:Di.backgroundCube.vertexShader,fragmentShader:Di.backgroundCube.fragmentShader,side:In,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(w,S,T){this.matrixWorld.copyPosition(T.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),s.update(h)),rr.copy(E.backgroundRotation),rr.x*=-1,rr.y*=-1,rr.z*=-1,M.isCubeTexture&&M.isRenderTargetTexture===!1&&(rr.y*=-1,rr.z*=-1),h.material.uniforms.envMap.value=M,h.material.uniforms.flipEnvMap.value=M.isCubeTexture&&M.isRenderTargetTexture===!1?-1:1,h.material.uniforms.backgroundBlurriness.value=E.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=E.backgroundIntensity,h.material.uniforms.backgroundRotation.value.setFromMatrix4(lC.makeRotationFromEuler(rr)),h.material.toneMapped=At.getTransfer(M.colorSpace)!==Mt,(u!==M||d!==M.version||f!==i.toneMapping)&&(h.material.needsUpdate=!0,u=M,d=M.version,f=i.toneMapping),h.layers.enableAll(),b.unshift(h,h.geometry,h.material,0,0,null)):M&&M.isTexture&&(l===void 0&&(l=new Jt(new nl(2,2),new Is({name:"BackgroundMaterial",uniforms:ia(Di.background.uniforms),vertexShader:Di.background.vertexShader,fragmentShader:Di.background.fragmentShader,side:Hi,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),s.update(l)),l.material.uniforms.t2D.value=M,l.material.uniforms.backgroundIntensity.value=E.backgroundIntensity,l.material.toneMapped=At.getTransfer(M.colorSpace)!==Mt,M.matrixAutoUpdate===!0&&M.updateMatrix(),l.material.uniforms.uvTransform.value.copy(M.matrix),(u!==M||d!==M.version||f!==i.toneMapping)&&(l.material.needsUpdate=!0,u=M,d=M.version,f=i.toneMapping),l.layers.enableAll(),b.unshift(l,l.geometry,l.material,0,0,null))}function p(b,E){b.getRGB(al,hA(i)),n.buffers.color.setClear(al.r,al.g,al.b,E,a)}function y(){h!==void 0&&(h.geometry.dispose(),h.material.dispose(),h=void 0),l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0)}return{getClearColor:function(){return o},setClearColor:function(b,E=1){o.set(b),c=E,p(o,c)},getClearAlpha:function(){return c},setClearAlpha:function(b){c=b,p(o,c)},render:A,addToRenderList:g,dispose:y}}function uC(i,e){const t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},s=d(null);let r=s,a=!1;function o(v,F,K,q,$){let D=!1;const O=u(q,K,F);r!==O&&(r=O,l(r.object)),D=f(v,q,K,$),D&&m(v,q,K,$),$!==null&&e.update($,i.ELEMENT_ARRAY_BUFFER),(D||a)&&(a=!1,E(v,F,K,q),$!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get($).buffer))}function c(){return i.createVertexArray()}function l(v){return i.bindVertexArray(v)}function h(v){return i.deleteVertexArray(v)}function u(v,F,K){const q=K.wireframe===!0;let $=n[v.id];$===void 0&&($={},n[v.id]=$);let D=$[F.id];D===void 0&&(D={},$[F.id]=D);let O=D[q];return O===void 0&&(O=d(c()),D[q]=O),O}function d(v){const F=[],K=[],q=[];for(let $=0;$<t;$++)F[$]=0,K[$]=0,q[$]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:F,enabledAttributes:K,attributeDivisors:q,object:v,attributes:{},index:null}}function f(v,F,K,q){const $=r.attributes,D=F.attributes;let O=0;const Y=K.getAttributes();for(const Q in Y)if(Y[Q].location>=0){const ee=$[Q];let ae=D[Q];if(ae===void 0&&(Q==="instanceMatrix"&&v.instanceMatrix&&(ae=v.instanceMatrix),Q==="instanceColor"&&v.instanceColor&&(ae=v.instanceColor)),ee===void 0||ee.attribute!==ae||ae&&ee.data!==ae.data)return!0;O++}return r.attributesNum!==O||r.index!==q}function m(v,F,K,q){const $={},D=F.attributes;let O=0;const Y=K.getAttributes();for(const Q in Y)if(Y[Q].location>=0){let ee=D[Q];ee===void 0&&(Q==="instanceMatrix"&&v.instanceMatrix&&(ee=v.instanceMatrix),Q==="instanceColor"&&v.instanceColor&&(ee=v.instanceColor));const ae={};ae.attribute=ee,ee&&ee.data&&(ae.data=ee.data),$[Q]=ae,O++}r.attributes=$,r.attributesNum=O,r.index=q}function A(){const v=r.newAttributes;for(let F=0,K=v.length;F<K;F++)v[F]=0}function g(v){p(v,0)}function p(v,F){const K=r.newAttributes,q=r.enabledAttributes,$=r.attributeDivisors;K[v]=1,q[v]===0&&(i.enableVertexAttribArray(v),q[v]=1),$[v]!==F&&(i.vertexAttribDivisor(v,F),$[v]=F)}function y(){const v=r.newAttributes,F=r.enabledAttributes;for(let K=0,q=F.length;K<q;K++)F[K]!==v[K]&&(i.disableVertexAttribArray(K),F[K]=0)}function b(v,F,K,q,$,D,O){O===!0?i.vertexAttribIPointer(v,F,K,$,D):i.vertexAttribPointer(v,F,K,q,$,D)}function E(v,F,K,q){A();const $=q.attributes,D=K.getAttributes(),O=F.defaultAttributeValues;for(const Y in D){const Q=D[Y];if(Q.location>=0){let J=$[Y];if(J===void 0&&(Y==="instanceMatrix"&&v.instanceMatrix&&(J=v.instanceMatrix),Y==="instanceColor"&&v.instanceColor&&(J=v.instanceColor)),J!==void 0){const ee=J.normalized,ae=J.itemSize,ye=e.get(J);if(ye===void 0)continue;const Me=ye.buffer,se=ye.type,me=ye.bytesPerElement,be=se===i.INT||se===i.UNSIGNED_INT||J.gpuType===Dh;if(J.isInterleavedBufferAttribute){const xe=J.data,Pe=xe.stride,et=J.offset;if(xe.isInstancedInterleavedBuffer){for(let Qe=0;Qe<Q.locationSize;Qe++)p(Q.location+Qe,xe.meshPerAttribute);v.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=xe.meshPerAttribute*xe.count)}else for(let Qe=0;Qe<Q.locationSize;Qe++)g(Q.location+Qe);i.bindBuffer(i.ARRAY_BUFFER,Me);for(let Qe=0;Qe<Q.locationSize;Qe++)b(Q.location+Qe,ae/Q.locationSize,se,ee,Pe*me,(et+ae/Q.locationSize*Qe)*me,be)}else{if(J.isInstancedBufferAttribute){for(let xe=0;xe<Q.locationSize;xe++)p(Q.location+xe,J.meshPerAttribute);v.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=J.meshPerAttribute*J.count)}else for(let xe=0;xe<Q.locationSize;xe++)g(Q.location+xe);i.bindBuffer(i.ARRAY_BUFFER,Me);for(let xe=0;xe<Q.locationSize;xe++)b(Q.location+xe,ae/Q.locationSize,se,ee,ae*me,ae/Q.locationSize*xe*me,be)}}else if(O!==void 0){const ee=O[Y];if(ee!==void 0)switch(ee.length){case 2:i.vertexAttrib2fv(Q.location,ee);break;case 3:i.vertexAttrib3fv(Q.location,ee);break;case 4:i.vertexAttrib4fv(Q.location,ee);break;default:i.vertexAttrib1fv(Q.location,ee)}}}}y()}function M(){T();for(const v in n){const F=n[v];for(const K in F){const q=F[K];for(const $ in q)h(q[$].object),delete q[$];delete F[K]}delete n[v]}}function w(v){if(n[v.id]===void 0)return;const F=n[v.id];for(const K in F){const q=F[K];for(const $ in q)h(q[$].object),delete q[$];delete F[K]}delete n[v.id]}function S(v){for(const F in n){const K=n[F];if(K[v.id]===void 0)continue;const q=K[v.id];for(const $ in q)h(q[$].object),delete q[$];delete K[v.id]}}function T(){C(),a=!0,r!==s&&(r=s,l(r.object))}function C(){s.geometry=null,s.program=null,s.wireframe=!1}return{setup:o,reset:T,resetDefaultState:C,dispose:M,releaseStatesOfGeometry:w,releaseStatesOfProgram:S,initAttributes:A,enableAttribute:g,disableUnusedAttributes:y}}function dC(i,e,t){let n;function s(l){n=l}function r(l,h){i.drawArrays(n,l,h),t.update(h,n,1)}function a(l,h,u){u!==0&&(i.drawArraysInstanced(n,l,h,u),t.update(h,n,u))}function o(l,h,u){if(u===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,l,0,h,0,u);let f=0;for(let m=0;m<u;m++)f+=h[m];t.update(f,n,1)}function c(l,h,u,d){if(u===0)return;const f=e.get("WEBGL_multi_draw");if(f===null)for(let m=0;m<l.length;m++)a(l[m],h[m],d[m]);else{f.multiDrawArraysInstancedWEBGL(n,l,0,h,0,d,0,u);let m=0;for(let A=0;A<u;A++)m+=h[A]*d[A];t.update(m,n,1)}}this.setMode=s,this.render=r,this.renderInstances=a,this.renderMultiDraw=o,this.renderMultiDrawInstances=c}function fC(i,e,t,n){let s;function r(){if(s!==void 0)return s;if(e.has("EXT_texture_filter_anisotropic")===!0){const S=e.get("EXT_texture_filter_anisotropic");s=i.getParameter(S.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else s=0;return s}function a(S){return!(S!==sn&&n.convert(S)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(S){const T=S===Bn&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(S!==tn&&n.convert(S)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&S!==nn&&!T)}function c(S){if(S==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";S="mediump"}return S==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let l=t.precision!==void 0?t.precision:"highp";const h=c(l);h!==l&&(console.warn("THREE.WebGLRenderer:",l,"not supported, using",h,"instead."),l=h);const u=t.logarithmicDepthBuffer===!0,d=t.reverseDepthBuffer===!0&&e.has("EXT_clip_control"),f=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),m=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),A=i.getParameter(i.MAX_TEXTURE_SIZE),g=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),p=i.getParameter(i.MAX_VERTEX_ATTRIBS),y=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),b=i.getParameter(i.MAX_VARYING_VECTORS),E=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),M=m>0,w=i.getParameter(i.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:c,textureFormatReadable:a,textureTypeReadable:o,precision:l,logarithmicDepthBuffer:u,reverseDepthBuffer:d,maxTextures:f,maxVertexTextures:m,maxTextureSize:A,maxCubemapSize:g,maxAttributes:p,maxVertexUniforms:y,maxVaryings:b,maxFragmentUniforms:E,vertexTextures:M,maxSamples:w}}function pC(i){const e=this;let t=null,n=0,s=!1,r=!1;const a=new Bs,o=new rt,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(u,d){const f=u.length!==0||d||n!==0||s;return s=d,n=u.length,f},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(u,d){t=h(u,d,0)},this.setState=function(u,d,f){const m=u.clippingPlanes,A=u.clipIntersection,g=u.clipShadows,p=i.get(u);if(!s||m===null||m.length===0||r&&!g)r?h(null):l();else{const y=r?0:n,b=y*4;let E=p.clippingState||null;c.value=E,E=h(m,d,b,f);for(let M=0;M!==b;++M)E[M]=t[M];p.clippingState=E,this.numIntersection=A?this.numPlanes:0,this.numPlanes+=y}};function l(){c.value!==t&&(c.value=t,c.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function h(u,d,f,m){const A=u!==null?u.length:0;let g=null;if(A!==0){if(g=c.value,m!==!0||g===null){const p=f+A*4,y=d.matrixWorldInverse;o.getNormalMatrix(y),(g===null||g.length<p)&&(g=new Float32Array(p));for(let b=0,E=f;b!==A;++b,E+=4)a.copy(u[b]).applyMatrix4(y,o),a.normal.toArray(g,E),g[E+3]=a.constant}c.value=g,c.needsUpdate=!0}return e.numPlanes=A,e.numIntersection=0,g}}function AC(i){let e=new WeakMap;function t(a,o){return o===Nh?a.mapping=Ys:o===Fh&&(a.mapping=Or),a}function n(a){if(a&&a.isTexture){const o=a.mapping;if(o===Nh||o===Fh)if(e.has(a)){const c=e.get(a).texture;return t(c,a.mapping)}else{const c=a.image;if(c&&c.height>0){const l=new dy(c.height);return l.fromEquirectangularTexture(i,a),e.set(a,l),a.addEventListener("dispose",s),t(l.texture,a.mapping)}else return null}}return a}function s(a){const o=a.target;o.removeEventListener("dispose",s);const c=e.get(o);c!==void 0&&(e.delete(o),c.dispose())}function r(){e=new WeakMap}return{get:n,dispose:r}}const fa=4,jA=[.125,.215,.35,.446,.526,.582],ar=20,Xu=new Wu,XA=new qe;let Yu=null,Ju=0,Zu=0,$u=!1;const or=(1+Math.sqrt(5))/2,pa=1/or,YA=[new H(-or,pa,0),new H(or,pa,0),new H(-pa,0,or),new H(pa,0,or),new H(0,or,-pa),new H(0,or,pa),new H(-1,1,-1),new H(1,1,-1),new H(-1,1,1),new H(1,1,1)],gC=new H;class ed{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,s=100,r={}){const{size:a=256,position:o=gC}=r;Yu=this._renderer.getRenderTarget(),Ju=this._renderer.getActiveCubeFace(),Zu=this._renderer.getActiveMipmapLevel(),$u=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const c=this._allocateTargets();return c.depthBuffer=!0,this._sceneToCubeUV(e,n,s,c,o),t>0&&this._blur(c,0,0,t),this._applyPMREM(c),this._cleanup(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=$A(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=ZA(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(Yu,Ju,Zu),this._renderer.xr.enabled=$u,e.scissorTest=!1,ol(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===Ys||e.mapping===Or?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Yu=this._renderer.getRenderTarget(),Ju=this._renderer.getActiveCubeFace(),Zu=this._renderer.getActiveMipmapLevel(),$u=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:zt,minFilter:zt,generateMipmaps:!1,type:Bn,format:sn,colorSpace:rn,depthBuffer:!1},s=JA(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=JA(e,t,n);const{_lodMax:r}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=mC(r)),this._blurMaterial=bC(r,e,t)}return s}_compileMaterial(e){const t=new Jt(this._lodPlanes[0],e);this._renderer.compile(t,Xu)}_sceneToCubeUV(e,t,n,s,r){const c=new Cn(90,1,t,n),l=[1,-1,1,1,1,1],h=[1,1,1,-1,-1,-1],u=this._renderer,d=u.autoClear,f=u.toneMapping;u.getClearColor(XA),u.toneMapping=xs,u.autoClear=!1;const m=new Ss({name:"PMREM.Background",side:In,depthWrite:!1,depthTest:!1}),A=new Jt(new na,m);let g=!1;const p=e.background;p?p.isColor&&(m.color.copy(p),e.background=null,g=!0):(m.color.copy(XA),g=!0);for(let y=0;y<6;y++){const b=y%3;b===0?(c.up.set(0,l[y],0),c.position.set(r.x,r.y,r.z),c.lookAt(r.x+h[y],r.y,r.z)):b===1?(c.up.set(0,0,l[y]),c.position.set(r.x,r.y,r.z),c.lookAt(r.x,r.y+h[y],r.z)):(c.up.set(0,l[y],0),c.position.set(r.x,r.y,r.z),c.lookAt(r.x,r.y,r.z+h[y]));const E=this._cubeSize;ol(s,b*E,y>2?E:0,E,E),u.setRenderTarget(s),g&&u.render(A,c),u.render(e,c)}A.geometry.dispose(),A.material.dispose(),u.toneMapping=f,u.autoClear=d,e.background=p}_textureToCubeUV(e,t){const n=this._renderer,s=e.mapping===Ys||e.mapping===Or;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=$A()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=ZA());const r=s?this._cubemapMaterial:this._equirectMaterial,a=new Jt(this._lodPlanes[0],r),o=r.uniforms;o.envMap.value=e;const c=this._cubeSize;ol(t,0,0,3*c,2*c),n.setRenderTarget(t),n.render(a,Xu)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const s=this._lodPlanes.length;for(let r=1;r<s;r++){const a=Math.sqrt(this._sigmas[r]*this._sigmas[r]-this._sigmas[r-1]*this._sigmas[r-1]),o=YA[(s-r-1)%YA.length];this._blur(e,r-1,r,a,o)}t.autoClear=n}_blur(e,t,n,s,r){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,s,"latitudinal",r),this._halfBlur(a,e,n,n,s,"longitudinal",r)}_halfBlur(e,t,n,s,r,a,o){const c=this._renderer,l=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const h=3,u=new Jt(this._lodPlanes[s],l),d=l.uniforms,f=this._sizeLods[n]-1,m=isFinite(r)?Math.PI/(2*f):2*Math.PI/(2*ar-1),A=r/m,g=isFinite(r)?1+Math.floor(h*A):ar;g>ar&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${ar}`);const p=[];let y=0;for(let S=0;S<ar;++S){const T=S/A,C=Math.exp(-T*T/2);p.push(C),S===0?y+=C:S<g&&(y+=2*C)}for(let S=0;S<p.length;S++)p[S]=p[S]/y;d.envMap.value=e.texture,d.samples.value=g,d.weights.value=p,d.latitudinal.value=a==="latitudinal",o&&(d.poleAxis.value=o);const{_lodMax:b}=this;d.dTheta.value=m,d.mipInt.value=b-n;const E=this._sizeLods[s],M=3*E*(s>b-fa?s-b+fa:0),w=4*(this._cubeSize-E);ol(t,M,w,3*E,2*E),c.setRenderTarget(t),c.render(u,Xu)}}function mC(i){const e=[],t=[],n=[];let s=i;const r=i-fa+1+jA.length;for(let a=0;a<r;a++){const o=Math.pow(2,s);t.push(o);let c=1/o;a>i-fa?c=jA[a-i+fa-1]:a===0&&(c=0),n.push(c);const l=1/(o-2),h=-l,u=1+l,d=[h,h,u,h,u,u,h,h,u,u,h,u],f=6,m=6,A=3,g=2,p=1,y=new Float32Array(A*m*f),b=new Float32Array(g*m*f),E=new Float32Array(p*m*f);for(let w=0;w<f;w++){const S=w%3*2/3-1,T=w>2?0:-1,C=[S,T,0,S+2/3,T,0,S+2/3,T+1,0,S,T,0,S+2/3,T+1,0,S,T+1,0];y.set(C,A*m*w),b.set(d,g*m*w);const v=[w,w,w,w,w,w];E.set(v,p*m*w)}const M=new Qn;M.setAttribute("position",new _n(y,A)),M.setAttribute("uv",new _n(b,g)),M.setAttribute("faceIndex",new _n(E,p)),e.push(M),s>fa&&s--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function JA(i,e,t){const n=new $s(i,e,t);return n.texture.mapping=fc,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function ol(i,e,t,n,s){i.viewport.set(e,t,n,s),i.scissor.set(e,t,n,s)}function bC(i,e,t){const n=new Float32Array(ar),s=new H(0,1,0);return new Is({name:"SphericalGaussianBlur",defines:{n:ar,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:td(),fragmentShader:`++ precision mediump float;+ precision mediump int;++ varying vec3 vOutputDirection;++ uniform sampler2D envMap;+ uniform int samples;+ uniform float weights[ n ];+ uniform bool latitudinal;+ uniform float dTheta;+ uniform float mipInt;+ uniform vec3 poleAxis;++ #define ENVMAP_TYPE_CUBE_UV+ #include <cube_uv_reflection_fragment>++ vec3 getSample( float theta, vec3 axis ) {++ float cosTheta = cos( theta );+ // Rodrigues' axis-angle rotation+ vec3 sampleDirection = vOutputDirection * cosTheta+ + cross( axis, vOutputDirection ) * sin( theta )+ + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );++ return bilinearCubeUV( envMap, sampleDirection, mipInt );++ }++ void main() {++ vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );++ if ( all( equal( axis, vec3( 0.0 ) ) ) ) {++ axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );++ }++ axis = normalize( axis );++ gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );+ gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );++ for ( int i = 1; i < n; i++ ) {++ if ( i >= samples ) {++ break;++ }++ float theta = dTheta * float( i );+ gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );+ gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );++ }++ }+ `,blending:bs,depthTest:!1,depthWrite:!1})}function ZA(){return new Is({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:td(),fragmentShader:`++ precision mediump float;+ precision mediump int;++ varying vec3 vOutputDirection;++ uniform sampler2D envMap;++ #include <common>++ void main() {++ vec3 outputDirection = normalize( vOutputDirection );+ vec2 uv = equirectUv( outputDirection );++ gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );++ }+ `,blending:bs,depthTest:!1,depthWrite:!1})}function $A(){return new Is({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:td(),fragmentShader:`++ precision mediump float;+ precision mediump int;++ uniform float flipEnvMap;++ varying vec3 vOutputDirection;++ uniform samplerCube envMap;++ void main() {++ gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );++ }+ `,blending:bs,depthTest:!1,depthWrite:!1})}function td(){return`++ precision mediump float;+ precision mediump int;++ attribute float faceIndex;++ varying vec3 vOutputDirection;++ // RH coordinate system; PMREM face-indexing convention+ vec3 getDirection( vec2 uv, float face ) {++ uv = 2.0 * uv - 1.0;++ vec3 direction = vec3( uv, 1.0 );++ if ( face == 0.0 ) {++ direction = direction.zyx; // ( 1, v, u ) pos x++ } else if ( face == 1.0 ) {++ direction = direction.xzy;+ direction.xz *= -1.0; // ( -u, 1, -v ) pos y++ } else if ( face == 2.0 ) {++ direction.x *= -1.0; // ( -u, v, 1 ) pos z++ } else if ( face == 3.0 ) {++ direction = direction.zyx;+ direction.xz *= -1.0; // ( -1, v, -u ) neg x++ } else if ( face == 4.0 ) {++ direction = direction.xzy;+ direction.xy *= -1.0; // ( -u, -1, v ) neg y++ } else if ( face == 5.0 ) {++ direction.z *= -1.0; // ( u, v, -1 ) neg z++ }++ return direction;++ }++ void main() {++ vOutputDirection = getDirection( uv, faceIndex );+ gl_Position = vec4( position, 1.0 );++ }+ `}function xC(i){let e=new WeakMap,t=null;function n(o){if(o&&o.isTexture){const c=o.mapping,l=c===Nh||c===Fh,h=c===Ys||c===Or;if(l||h){let u=e.get(o);const d=u!==void 0?u.texture.pmremVersion:0;if(o.isRenderTargetTexture&&o.pmremVersion!==d)return t===null&&(t=new ed(i)),u=l?t.fromEquirectangular(o,u):t.fromCubemap(o,u),u.texture.pmremVersion=o.pmremVersion,e.set(o,u),u.texture;if(u!==void 0)return u.texture;{const f=o.image;return l&&f&&f.height>0||h&&f&&s(f)?(t===null&&(t=new ed(i)),u=l?t.fromEquirectangular(o):t.fromCubemap(o),u.texture.pmremVersion=o.pmremVersion,e.set(o,u),o.addEventListener("dispose",r),u.texture):null}}}return o}function s(o){let c=0;const l=6;for(let h=0;h<l;h++)o[h]!==void 0&&c++;return c===l}function r(o){const c=o.target;c.removeEventListener("dispose",r);const l=e.get(c);l!==void 0&&(e.delete(c),l.dispose())}function a(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:n,dispose:a}}function _C(i){const e={};function t(n){if(e[n]!==void 0)return e[n];let s;switch(n){case"WEBGL_depth_texture":s=i.getExtension("WEBGL_depth_texture")||i.getExtension("MOZ_WEBGL_depth_texture")||i.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":s=i.getExtension("EXT_texture_filter_anisotropic")||i.getExtension("MOZ_EXT_texture_filter_anisotropic")||i.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":s=i.getExtension("WEBGL_compressed_texture_s3tc")||i.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":s=i.getExtension("WEBGL_compressed_texture_pvrtc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:s=i.getExtension(n)}return e[n]=s,s}return{has:function(n){return t(n)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(n){const s=t(n);return s===null&&Ic("THREE.WebGLRenderer: "+n+" extension not supported."),s}}}function EC(i,e,t,n){const s={},r=new WeakMap;function a(u){const d=u.target;d.index!==null&&e.remove(d.index);for(const m in d.attributes)e.remove(d.attributes[m]);d.removeEventListener("dispose",a),delete s[d.id];const f=r.get(d);f&&(e.remove(f),r.delete(d)),n.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,t.memory.geometries--}function o(u,d){return s[d.id]===!0||(d.addEventListener("dispose",a),s[d.id]=!0,t.memory.geometries++),d}function c(u){const d=u.attributes;for(const f in d)e.update(d[f],i.ARRAY_BUFFER)}function l(u){const d=[],f=u.index,m=u.attributes.position;let A=0;if(f!==null){const y=f.array;A=f.version;for(let b=0,E=y.length;b<E;b+=3){const M=y[b+0],w=y[b+1],S=y[b+2];d.push(M,w,w,S,S,M)}}else if(m!==void 0){const y=m.array;A=m.version;for(let b=0,E=y.length/3-1;b<E;b+=3){const M=b+0,w=b+1,S=b+2;d.push(M,w,w,S,S,M)}}else return;const g=new(Gp(d)?aA:rA)(d,1);g.version=A;const p=r.get(u);p&&e.remove(p),r.set(u,g)}function h(u){const d=r.get(u);if(d){const f=u.index;f!==null&&d.version<f.version&&l(u)}else l(u);return r.get(u)}return{get:o,update:c,getWireframeAttribute:h}}function yC(i,e,t){let n;function s(d){n=d}let r,a;function o(d){r=d.type,a=d.bytesPerElement}function c(d,f){i.drawElements(n,f,r,d*a),t.update(f,n,1)}function l(d,f,m){m!==0&&(i.drawElementsInstanced(n,f,r,d*a,m),t.update(f,n,m))}function h(d,f,m){if(m===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,f,0,r,d,0,m);let g=0;for(let p=0;p<m;p++)g+=f[p];t.update(g,n,1)}function u(d,f,m,A){if(m===0)return;const g=e.get("WEBGL_multi_draw");if(g===null)for(let p=0;p<d.length;p++)l(d[p]/a,f[p],A[p]);else{g.multiDrawElementsInstancedWEBGL(n,f,0,r,d,0,A,0,m);let p=0;for(let y=0;y<m;y++)p+=f[y]*A[y];t.update(p,n,1)}}this.setMode=s,this.setIndex=o,this.render=c,this.renderInstances=l,this.renderMultiDraw=h,this.renderMultiDrawInstances=u}function wC(i){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(r,a,o){switch(t.calls++,a){case i.TRIANGLES:t.triangles+=o*(r/3);break;case i.LINES:t.lines+=o*(r/2);break;case i.LINE_STRIP:t.lines+=o*(r-1);break;case i.LINE_LOOP:t.lines+=o*r;break;case i.POINTS:t.points+=o*r;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",a);break}}function s(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:s,update:n}}function vC(i,e,t){const n=new WeakMap,s=new Et;function r(a,o,c){const l=a.morphTargetInfluences,h=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,u=h!==void 0?h.length:0;let d=n.get(o);if(d===void 0||d.count!==u){let C=function(){S.dispose(),n.delete(o),o.removeEventListener("dispose",C)};d!==void 0&&d.texture.dispose();const f=o.morphAttributes.position!==void 0,m=o.morphAttributes.normal!==void 0,A=o.morphAttributes.color!==void 0,g=o.morphAttributes.position||[],p=o.morphAttributes.normal||[],y=o.morphAttributes.color||[];let b=0;f===!0&&(b=1),m===!0&&(b=2),A===!0&&(b=3);let E=o.attributes.position.count*b,M=1;E>e.maxTextureSize&&(M=Math.ceil(E/e.maxTextureSize),E=e.maxTextureSize);const w=new Float32Array(E*M*4*u),S=new Wp(w,E,M,u);S.type=nn,S.needsUpdate=!0;const T=b*4;for(let v=0;v<u;v++){const F=g[v],K=p[v],q=y[v],$=E*M*4*v;for(let D=0;D<F.count;D++){const O=D*T;f===!0&&(s.fromBufferAttribute(F,D),w[$+O+0]=s.x,w[$+O+1]=s.y,w[$+O+2]=s.z,w[$+O+3]=0),m===!0&&(s.fromBufferAttribute(K,D),w[$+O+4]=s.x,w[$+O+5]=s.y,w[$+O+6]=s.z,w[$+O+7]=0),A===!0&&(s.fromBufferAttribute(q,D),w[$+O+8]=s.x,w[$+O+9]=s.y,w[$+O+10]=s.z,w[$+O+11]=q.itemSize===4?s.w:1)}}d={count:u,texture:S,size:new Ze(E,M)},n.set(o,d),o.addEventListener("dispose",C)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)c.getUniforms().setValue(i,"morphTexture",a.morphTexture,t);else{let f=0;for(let A=0;A<l.length;A++)f+=l[A];const m=o.morphTargetsRelative?1:1-f;c.getUniforms().setValue(i,"morphTargetBaseInfluence",m),c.getUniforms().setValue(i,"morphTargetInfluences",l)}c.getUniforms().setValue(i,"morphTargetsTexture",d.texture,t),c.getUniforms().setValue(i,"morphTargetsTextureSize",d.size)}return{update:r}}function CC(i,e,t,n){let s=new WeakMap;function r(c){const l=n.render.frame,h=c.geometry,u=e.get(c,h);if(s.get(u)!==l&&(e.update(u),s.set(u,l)),c.isInstancedMesh&&(c.hasEventListener("dispose",o)===!1&&c.addEventListener("dispose",o),s.get(c)!==l&&(t.update(c.instanceMatrix,i.ARRAY_BUFFER),c.instanceColor!==null&&t.update(c.instanceColor,i.ARRAY_BUFFER),s.set(c,l))),c.isSkinnedMesh){const d=c.skeleton;s.get(d)!==l&&(d.update(),s.set(d,l))}return u}function a(){s=new WeakMap}function o(c){const l=c.target;l.removeEventListener("dispose",o),t.remove(l.instanceMatrix),l.instanceColor!==null&&t.remove(l.instanceColor)}return{update:r,dispose:a}}const eg=new an,tg=new RA(1,1),ng=new Wp,ig=new qp,sg=new pA,rg=[],ag=[],og=new Float32Array(16),cg=new Float32Array(9),lg=new Float32Array(4);function Aa(i,e,t){const n=i[0];if(n<=0||n>0)return i;const s=e*t;let r=rg[s];if(r===void 0&&(r=new Float32Array(s),rg[s]=r),e!==0){n.toArray(r,0);for(let a=1,o=0;a!==e;++a)o+=t,i[a].toArray(r,o)}return r}function on(i,e){if(i.length!==e.length)return!1;for(let t=0,n=i.length;t<n;t++)if(i[t]!==e[t])return!1;return!0}function cn(i,e){for(let t=0,n=e.length;t<n;t++)i[t]=e[t]}function cl(i,e){let t=ag[e];t===void 0&&(t=new Int32Array(e),ag[e]=t);for(let n=0;n!==e;++n)t[n]=i.allocateTextureUnit();return t}function SC(i,e){const t=this.cache;t[0]!==e&&(i.uniform1f(this.addr,e),t[0]=e)}function IC(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(on(t,e))return;i.uniform2fv(this.addr,e),cn(t,e)}}function MC(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(i.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(on(t,e))return;i.uniform3fv(this.addr,e),cn(t,e)}}function BC(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(on(t,e))return;i.uniform4fv(this.addr,e),cn(t,e)}}function TC(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(on(t,e))return;i.uniformMatrix2fv(this.addr,!1,e),cn(t,e)}else{if(on(t,n))return;lg.set(n),i.uniformMatrix2fv(this.addr,!1,lg),cn(t,n)}}function RC(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(on(t,e))return;i.uniformMatrix3fv(this.addr,!1,e),cn(t,e)}else{if(on(t,n))return;cg.set(n),i.uniformMatrix3fv(this.addr,!1,cg),cn(t,n)}}function NC(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(on(t,e))return;i.uniformMatrix4fv(this.addr,!1,e),cn(t,e)}else{if(on(t,n))return;og.set(n),i.uniformMatrix4fv(this.addr,!1,og),cn(t,n)}}function FC(i,e){const t=this.cache;t[0]!==e&&(i.uniform1i(this.addr,e),t[0]=e)}function DC(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(on(t,e))return;i.uniform2iv(this.addr,e),cn(t,e)}}function LC(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(on(t,e))return;i.uniform3iv(this.addr,e),cn(t,e)}}function PC(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(on(t,e))return;i.uniform4iv(this.addr,e),cn(t,e)}}function kC(i,e){const t=this.cache;t[0]!==e&&(i.uniform1ui(this.addr,e),t[0]=e)}function UC(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(on(t,e))return;i.uniform2uiv(this.addr,e),cn(t,e)}}function OC(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(on(t,e))return;i.uniform3uiv(this.addr,e),cn(t,e)}}function QC(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(on(t,e))return;i.uniform4uiv(this.addr,e),cn(t,e)}}function GC(i,e,t){const n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s);let r;this.type===i.SAMPLER_2D_SHADOW?(tg.compareFunction=kp,r=tg):r=eg,t.setTexture2D(e||r,s)}function HC(i,e,t){const n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTexture3D(e||ig,s)}function zC(i,e,t){const n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTextureCube(e||sg,s)}function VC(i,e,t){const n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTexture2DArray(e||ng,s)}function WC(i){switch(i){case 5126:return SC;case 35664:return IC;case 35665:return MC;case 35666:return BC;case 35674:return TC;case 35675:return RC;case 35676:return NC;case 5124:case 35670:return FC;case 35667:case 35671:return DC;case 35668:case 35672:return LC;case 35669:case 35673:return PC;case 5125:return kC;case 36294:return UC;case 36295:return OC;case 36296:return QC;case 35678:case 36198:case 36298:case 36306:case 35682:return GC;case 35679:case 36299:case 36307:return HC;case 35680:case 36300:case 36308:case 36293:return zC;case 36289:case 36303:case 36311:case 36292:return VC}}function qC(i,e){i.uniform1fv(this.addr,e)}function KC(i,e){const t=Aa(e,this.size,2);i.uniform2fv(this.addr,t)}function jC(i,e){const t=Aa(e,this.size,3);i.uniform3fv(this.addr,t)}function XC(i,e){const t=Aa(e,this.size,4);i.uniform4fv(this.addr,t)}function YC(i,e){const t=Aa(e,this.size,4);i.uniformMatrix2fv(this.addr,!1,t)}function JC(i,e){const t=Aa(e,this.size,9);i.uniformMatrix3fv(this.addr,!1,t)}function ZC(i,e){const t=Aa(e,this.size,16);i.uniformMatrix4fv(this.addr,!1,t)}function $C(i,e){i.uniform1iv(this.addr,e)}function eS(i,e){i.uniform2iv(this.addr,e)}function tS(i,e){i.uniform3iv(this.addr,e)}function nS(i,e){i.uniform4iv(this.addr,e)}function iS(i,e){i.uniform1uiv(this.addr,e)}function sS(i,e){i.uniform2uiv(this.addr,e)}function rS(i,e){i.uniform3uiv(this.addr,e)}function aS(i,e){i.uniform4uiv(this.addr,e)}function oS(i,e,t){const n=this.cache,s=e.length,r=cl(t,s);on(n,r)||(i.uniform1iv(this.addr,r),cn(n,r));for(let a=0;a!==s;++a)t.setTexture2D(e[a]||eg,r[a])}function cS(i,e,t){const n=this.cache,s=e.length,r=cl(t,s);on(n,r)||(i.uniform1iv(this.addr,r),cn(n,r));for(let a=0;a!==s;++a)t.setTexture3D(e[a]||ig,r[a])}function lS(i,e,t){const n=this.cache,s=e.length,r=cl(t,s);on(n,r)||(i.uniform1iv(this.addr,r),cn(n,r));for(let a=0;a!==s;++a)t.setTextureCube(e[a]||sg,r[a])}function hS(i,e,t){const n=this.cache,s=e.length,r=cl(t,s);on(n,r)||(i.uniform1iv(this.addr,r),cn(n,r));for(let a=0;a!==s;++a)t.setTexture2DArray(e[a]||ng,r[a])}function uS(i){switch(i){case 5126:return qC;case 35664:return KC;case 35665:return jC;case 35666:return XC;case 35674:return YC;case 35675:return JC;case 35676:return ZC;case 5124:case 35670:return $C;case 35667:case 35671:return eS;case 35668:case 35672:return tS;case 35669:case 35673:return nS;case 5125:return iS;case 36294:return sS;case 36295:return rS;case 36296:return aS;case 35678:case 36198:case 36298:case 36306:case 35682:return oS;case 35679:case 36299:case 36307:return cS;case 35680:case 36300:case 36308:case 36293:return lS;case 36289:case 36303:case 36311:case 36292:return hS}}class dS{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=WC(t.type)}}class fS{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=uS(t.type)}}class pS{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){const s=this.seq;for(let r=0,a=s.length;r!==a;++r){const o=s[r];o.setValue(e,t[o.id],n)}}}const nd=/(\w+)(\])?(\[|\.)?/g;function hg(i,e){i.seq.push(e),i.map[e.id]=e}function AS(i,e,t){const n=i.name,s=n.length;for(nd.lastIndex=0;;){const r=nd.exec(n),a=nd.lastIndex;let o=r[1];const c=r[2]==="]",l=r[3];if(c&&(o=o|0),l===void 0||l==="["&&a+2===s){hg(t,l===void 0?new dS(o,i,e):new fS(o,i,e));break}else{let u=t.map[o];u===void 0&&(u=new pS(o),hg(t,u)),t=u}}}class ll{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let s=0;s<n;++s){const r=e.getActiveUniform(t,s),a=e.getUniformLocation(t,r.name);AS(r,a,this)}}setValue(e,t,n,s){const r=this.map[t];r!==void 0&&r.setValue(e,n,s)}setOptional(e,t,n){const s=t[n];s!==void 0&&this.setValue(e,n,s)}static upload(e,t,n,s){for(let r=0,a=t.length;r!==a;++r){const o=t[r],c=n[o.id];c.needsUpdate!==!1&&o.setValue(e,c.value,s)}}static seqWithValue(e,t){const n=[];for(let s=0,r=e.length;s!==r;++s){const a=e[s];a.id in t&&n.push(a)}return n}}function ug(i,e,t){const n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}const gS=37297;let mS=0;function bS(i,e){const t=i.split(`+`),n=[],s=Math.max(e-6,0),r=Math.min(e+6,t.length);for(let a=s;a<r;a++){const o=a+1;n.push(`${o===e?">":" "} ${o}: ${t[a]}`)}return n.join(`+`)}const dg=new rt;function xS(i){At._getMatrix(dg,At.workingColorSpace,i);const e=`mat3( ${dg.elements.map(t=>t.toFixed(4))} )`;switch(At.getTransfer(i)){case Cc:return[e,"LinearTransferOETF"];case Mt:return[e,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",i),[e,"LinearTransferOETF"]}}function fg(i,e,t){const n=i.getShaderParameter(e,i.COMPILE_STATUS),s=i.getShaderInfoLog(e).trim();if(n&&s==="")return"";const r=/ERROR: 0:(\d+)/.exec(s);if(r){const a=parseInt(r[1]);return t.toUpperCase()+`++`+s+`++`+bS(i.getShaderSource(e),a)}else return s}function _S(i,e){const t=xS(e);return[`vec4 ${i}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`+`)}function ES(i,e){let t;switch(e){case Rh:t="Linear";break;case iE:t="Reinhard";break;case sE:t="Cineon";break;case yp:t="ACESFilmic";break;case aE:t="AgX";break;case oE:t="Neutral";break;case rE:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const hl=new H;function yS(){At.getLuminanceCoefficients(hl);const i=hl.x.toFixed(4),e=hl.y.toFixed(4),t=hl.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`+`)}function wS(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(yo).join(`+`)}function vS(i){const e=[];for(const t in i){const n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`+`)}function CS(i,e){const t={},n=i.getProgramParameter(e,i.ACTIVE_ATTRIBUTES);for(let s=0;s<n;s++){const r=i.getActiveAttrib(e,s),a=r.name;let o=1;r.type===i.FLOAT_MAT2&&(o=2),r.type===i.FLOAT_MAT3&&(o=3),r.type===i.FLOAT_MAT4&&(o=4),t[a]={type:r.type,location:i.getAttribLocation(e,a),locationSize:o}}return t}function yo(i){return i!==""}function pg(i,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return i.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function Ag(i,e){return i.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const SS=/^[ \t]*#include +<([\w\d./]+)>/gm;function id(i){return i.replace(SS,MS)}const IS=new Map;function MS(i,e){let t=ot[e];if(t===void 0){const n=IS.get(e);if(n!==void 0)t=ot[n],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("Can not resolve #include <"+e+">")}return id(t)}const BS=/#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 gg(i){return i.replace(BS,TS)}function TS(i,e,t,n){let s="";for(let r=parseInt(e);r<parseInt(t);r++)s+=n.replace(/\[\s*i\s*\]/g,"[ "+r+" ]").replace(/UNROLLED_LOOP_INDEX/g,r);return s}function mg(i){let e=`precision ${i.precision} float;+ precision ${i.precision} int;+ precision ${i.precision} sampler2D;+ precision ${i.precision} samplerCube;+ precision ${i.precision} sampler3D;+ precision ${i.precision} sampler2DArray;+ precision ${i.precision} sampler2DShadow;+ precision ${i.precision} samplerCubeShadow;+ precision ${i.precision} sampler2DArrayShadow;+ precision ${i.precision} isampler2D;+ precision ${i.precision} isampler3D;+ precision ${i.precision} isamplerCube;+ precision ${i.precision} isampler2DArray;+ precision ${i.precision} usampler2D;+ precision ${i.precision} usampler3D;+ precision ${i.precision} usamplerCube;+ precision ${i.precision} usampler2DArray;+ `;return i.precision==="highp"?e+=`+#define HIGH_PRECISION`:i.precision==="mediump"?e+=`+#define MEDIUM_PRECISION`:i.precision==="lowp"&&(e+=`+#define LOW_PRECISION`),e}function RS(i){let e="SHADOWMAP_TYPE_BASIC";return i.shadowMapType===mp?e="SHADOWMAP_TYPE_PCF":i.shadowMapType===P_?e="SHADOWMAP_TYPE_PCF_SOFT":i.shadowMapType===Gi&&(e="SHADOWMAP_TYPE_VSM"),e}function NS(i){let e="ENVMAP_TYPE_CUBE";if(i.envMap)switch(i.envMapMode){case Ys:case Or:e="ENVMAP_TYPE_CUBE";break;case fc:e="ENVMAP_TYPE_CUBE_UV";break}return e}function FS(i){let e="ENVMAP_MODE_REFLECTION";return i.envMap&&i.envMapMode===Or&&(e="ENVMAP_MODE_REFRACTION"),e}function DS(i){let e="ENVMAP_BLENDING_NONE";if(i.envMap)switch(i.combine){case Ep:e="ENVMAP_BLENDING_MULTIPLY";break;case tE:e="ENVMAP_BLENDING_MIX";break;case nE:e="ENVMAP_BLENDING_ADD";break}return e}function LS(i){const e=i.envMapCubeUVHeight;if(e===null)return null;const t=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:n,maxMip:t}}function PS(i,e,t,n){const s=i.getContext(),r=t.defines;let a=t.vertexShader,o=t.fragmentShader;const c=RS(t),l=NS(t),h=FS(t),u=DS(t),d=LS(t),f=wS(t),m=vS(r),A=s.createProgram();let g,p,y=t.glslVersion?"#version "+t.glslVersion+`+`:"";t.isRawShaderMaterial?(g=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m].filter(yo).join(`+`),g.length>0&&(g+=`+`),p=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m].filter(yo).join(`+`),p.length>0&&(p+=`+`)):(g=[mg(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+h:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`+`].filter(yo).join(`+`),p=[mg(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+l:"",t.envMap?"#define "+h:"",t.envMap?"#define "+u:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor||t.batchingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==xs?"#define TONE_MAPPING":"",t.toneMapping!==xs?ot.tonemapping_pars_fragment:"",t.toneMapping!==xs?ES("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",ot.colorspace_pars_fragment,_S("linearToOutputTexel",t.outputColorSpace),yS(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`+`].filter(yo).join(`+`)),a=id(a),a=pg(a,t),a=Ag(a,t),o=id(o),o=pg(o,t),o=Ag(o,t),a=gg(a),o=gg(o),t.isRawShaderMaterial!==!0&&(y=`#version 300 es+`,g=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(`+`)+`+`+g,p=["#define varying in",t.glslVersion===Up?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===Up?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`+`)+`+`+p);const b=y+g+a,E=y+p+o,M=ug(s,s.VERTEX_SHADER,b),w=ug(s,s.FRAGMENT_SHADER,E);s.attachShader(A,M),s.attachShader(A,w),t.index0AttributeName!==void 0?s.bindAttribLocation(A,0,t.index0AttributeName):t.morphTargets===!0&&s.bindAttribLocation(A,0,"position"),s.linkProgram(A);function S(F){if(i.debug.checkShaderErrors){const K=s.getProgramInfoLog(A).trim(),q=s.getShaderInfoLog(M).trim(),$=s.getShaderInfoLog(w).trim();let D=!0,O=!0;if(s.getProgramParameter(A,s.LINK_STATUS)===!1)if(D=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(s,A,M,w);else{const Y=fg(s,M,"vertex"),Q=fg(s,w,"fragment");console.error("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(A,s.VALIDATE_STATUS)+`++Material Name: `+F.name+`+Material Type: `+F.type+`++Program Info Log: `+K+`+`+Y+`+`+Q)}else K!==""?console.warn("THREE.WebGLProgram: Program Info Log:",K):(q===""||$==="")&&(O=!1);O&&(F.diagnostics={runnable:D,programLog:K,vertexShader:{log:q,prefix:g},fragmentShader:{log:$,prefix:p}})}s.deleteShader(M),s.deleteShader(w),T=new ll(s,A),C=CS(s,A)}let T;this.getUniforms=function(){return T===void 0&&S(this),T};let C;this.getAttributes=function(){return C===void 0&&S(this),C};let v=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return v===!1&&(v=s.getProgramParameter(A,gS)),v},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(A),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=mS++,this.cacheKey=e,this.usedTimes=1,this.program=A,this.vertexShader=M,this.fragmentShader=w,this}let kS=0;class US{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,s=this._getShaderStage(t),r=this._getShaderStage(n),a=this._getShaderCacheForMaterial(e);return a.has(s)===!1&&(a.add(s),s.usedTimes++),a.has(r)===!1&&(a.add(r),r.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return n===void 0&&(n=new OS(e),t.set(e,n)),n}}class OS{constructor(e){this.id=kS++,this.code=e,this.usedTimes=0}}function QS(i,e,t,n,s,r,a){const o=new Yp,c=new US,l=new Set,h=[],u=s.logarithmicDepthBuffer,d=s.vertexTextures;let f=s.precision;const m={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function A(C){return l.add(C),C===0?"uv":`uv${C}`}function g(C,v,F,K,q){const $=K.fog,D=q.geometry,O=C.isMeshStandardMaterial?K.environment:null,Y=(C.isMeshStandardMaterial?t:e).get(C.envMap||O),Q=Y&&Y.mapping===fc?Y.image.height:null,J=m[C.type];C.precision!==null&&(f=s.getMaxPrecision(C.precision),f!==C.precision&&console.warn("THREE.WebGLProgram.getParameters:",C.precision,"not supported, using",f,"instead."));const ee=D.morphAttributes.position||D.morphAttributes.normal||D.morphAttributes.color,ae=ee!==void 0?ee.length:0;let ye=0;D.morphAttributes.position!==void 0&&(ye=1),D.morphAttributes.normal!==void 0&&(ye=2),D.morphAttributes.color!==void 0&&(ye=3);let Me,se,me,be;if(J){const yt=Di[J];Me=yt.vertexShader,se=yt.fragmentShader}else Me=C.vertexShader,se=C.fragmentShader,c.update(C),me=c.getVertexShaderID(C),be=c.getFragmentShaderID(C);const xe=i.getRenderTarget(),Pe=i.state.buffers.depth.getReversed(),et=q.isInstancedMesh===!0,Qe=q.isBatchedMesh===!0,St=!!C.map,ut=!!C.matcap,Je=!!Y,G=!!C.aoMap,mn=!!C.lightMap,dt=!!C.bumpMap,pt=!!C.normalMap,ze=!!C.displacementMap,Rt=!!C.emissiveMap,Ge=!!C.metalnessMap,L=!!C.roughnessMap,I=C.anisotropy>0,Z=C.clearcoat>0,le=C.dispersion>0,Ae=C.iridescence>0,oe=C.sheen>0,Ue=C.transmission>0,ve=I&&!!C.anisotropyMap,Ve=Z&&!!C.clearcoatMap,Ye=Z&&!!C.clearcoatNormalMap,_e=Z&&!!C.clearcoatRoughnessMap,Ne=Ae&&!!C.iridescenceMap,ke=Ae&&!!C.iridescenceThicknessMap,Oe=oe&&!!C.sheenColorMap,Te=oe&&!!C.sheenRoughnessMap,tt=!!C.specularMap,We=!!C.specularColorMap,nt=!!C.specularIntensityMap,W=Ue&&!!C.transmissionMap,ne=Ue&&!!C.thicknessMap,re=!!C.gradientMap,de=!!C.alphaMap,Ie=C.alphaTest>0,Se=!!C.alphaHash,it=!!C.extensions;let Qt=xs;C.toneMapped&&(xe===null||xe.isXRRenderTarget===!0)&&(Qt=i.toneMapping);const bn={shaderID:J,shaderType:C.type,shaderName:C.name,vertexShader:Me,fragmentShader:se,defines:C.defines,customVertexShaderID:me,customFragmentShaderID:be,isRawShaderMaterial:C.isRawShaderMaterial===!0,glslVersion:C.glslVersion,precision:f,batching:Qe,batchingColor:Qe&&q._colorsTexture!==null,instancing:et,instancingColor:et&&q.instanceColor!==null,instancingMorph:et&&q.morphTexture!==null,supportsVertexTextures:d,outputColorSpace:xe===null?i.outputColorSpace:xe.isXRRenderTarget===!0?xe.texture.colorSpace:rn,alphaToCoverage:!!C.alphaToCoverage,map:St,matcap:ut,envMap:Je,envMapMode:Je&&Y.mapping,envMapCubeUVHeight:Q,aoMap:G,lightMap:mn,bumpMap:dt,normalMap:pt,displacementMap:d&&ze,emissiveMap:Rt,normalMapObjectSpace:pt&&C.normalMapType===pE,normalMapTangentSpace:pt&&C.normalMapType===Lp,metalnessMap:Ge,roughnessMap:L,anisotropy:I,anisotropyMap:ve,clearcoat:Z,clearcoatMap:Ve,clearcoatNormalMap:Ye,clearcoatRoughnessMap:_e,dispersion:le,iridescence:Ae,iridescenceMap:Ne,iridescenceThicknessMap:ke,sheen:oe,sheenColorMap:Oe,sheenRoughnessMap:Te,specularMap:tt,specularColorMap:We,specularIntensityMap:nt,transmission:Ue,transmissionMap:W,thicknessMap:ne,gradientMap:re,opaque:C.transparent===!1&&C.blending===kr&&C.alphaToCoverage===!1,alphaMap:de,alphaTest:Ie,alphaHash:Se,combine:C.combine,mapUv:St&&A(C.map.channel),aoMapUv:G&&A(C.aoMap.channel),lightMapUv:mn&&A(C.lightMap.channel),bumpMapUv:dt&&A(C.bumpMap.channel),normalMapUv:pt&&A(C.normalMap.channel),displacementMapUv:ze&&A(C.displacementMap.channel),emissiveMapUv:Rt&&A(C.emissiveMap.channel),metalnessMapUv:Ge&&A(C.metalnessMap.channel),roughnessMapUv:L&&A(C.roughnessMap.channel),anisotropyMapUv:ve&&A(C.anisotropyMap.channel),clearcoatMapUv:Ve&&A(C.clearcoatMap.channel),clearcoatNormalMapUv:Ye&&A(C.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:_e&&A(C.clearcoatRoughnessMap.channel),iridescenceMapUv:Ne&&A(C.iridescenceMap.channel),iridescenceThicknessMapUv:ke&&A(C.iridescenceThicknessMap.channel),sheenColorMapUv:Oe&&A(C.sheenColorMap.channel),sheenRoughnessMapUv:Te&&A(C.sheenRoughnessMap.channel),specularMapUv:tt&&A(C.specularMap.channel),specularColorMapUv:We&&A(C.specularColorMap.channel),specularIntensityMapUv:nt&&A(C.specularIntensityMap.channel),transmissionMapUv:W&&A(C.transmissionMap.channel),thicknessMapUv:ne&&A(C.thicknessMap.channel),alphaMapUv:de&&A(C.alphaMap.channel),vertexTangents:!!D.attributes.tangent&&(pt||I),vertexColors:C.vertexColors,vertexAlphas:C.vertexColors===!0&&!!D.attributes.color&&D.attributes.color.itemSize===4,pointsUvs:q.isPoints===!0&&!!D.attributes.uv&&(St||de),fog:!!$,useFog:C.fog===!0,fogExp2:!!$&&$.isFogExp2,flatShading:C.flatShading===!0,sizeAttenuation:C.sizeAttenuation===!0,logarithmicDepthBuffer:u,reverseDepthBuffer:Pe,skinning:q.isSkinnedMesh===!0,morphTargets:D.morphAttributes.position!==void 0,morphNormals:D.morphAttributes.normal!==void 0,morphColors:D.morphAttributes.color!==void 0,morphTargetsCount:ae,morphTextureStride:ye,numDirLights:v.directional.length,numPointLights:v.point.length,numSpotLights:v.spot.length,numSpotLightMaps:v.spotLightMap.length,numRectAreaLights:v.rectArea.length,numHemiLights:v.hemi.length,numDirLightShadows:v.directionalShadowMap.length,numPointLightShadows:v.pointShadowMap.length,numSpotLightShadows:v.spotShadowMap.length,numSpotLightShadowsWithMaps:v.numSpotLightShadowsWithMaps,numLightProbes:v.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:C.dithering,shadowMapEnabled:i.shadowMap.enabled&&F.length>0,shadowMapType:i.shadowMap.type,toneMapping:Qt,decodeVideoTexture:St&&C.map.isVideoTexture===!0&&At.getTransfer(C.map.colorSpace)===Mt,decodeVideoTextureEmissive:Rt&&C.emissiveMap.isVideoTexture===!0&&At.getTransfer(C.emissiveMap.colorSpace)===Mt,premultipliedAlpha:C.premultipliedAlpha,doubleSided:C.side===Bi,flipSided:C.side===In,useDepthPacking:C.depthPacking>=0,depthPacking:C.depthPacking||0,index0AttributeName:C.index0AttributeName,extensionClipCullDistance:it&&C.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(it&&C.extensions.multiDraw===!0||Qe)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:C.customProgramCacheKey()};return bn.vertexUv1s=l.has(1),bn.vertexUv2s=l.has(2),bn.vertexUv3s=l.has(3),l.clear(),bn}function p(C){const v=[];if(C.shaderID?v.push(C.shaderID):(v.push(C.customVertexShaderID),v.push(C.customFragmentShaderID)),C.defines!==void 0)for(const F in C.defines)v.push(F),v.push(C.defines[F]);return C.isRawShaderMaterial===!1&&(y(v,C),b(v,C),v.push(i.outputColorSpace)),v.push(C.customProgramCacheKey),v.join()}function y(C,v){C.push(v.precision),C.push(v.outputColorSpace),C.push(v.envMapMode),C.push(v.envMapCubeUVHeight),C.push(v.mapUv),C.push(v.alphaMapUv),C.push(v.lightMapUv),C.push(v.aoMapUv),C.push(v.bumpMapUv),C.push(v.normalMapUv),C.push(v.displacementMapUv),C.push(v.emissiveMapUv),C.push(v.metalnessMapUv),C.push(v.roughnessMapUv),C.push(v.anisotropyMapUv),C.push(v.clearcoatMapUv),C.push(v.clearcoatNormalMapUv),C.push(v.clearcoatRoughnessMapUv),C.push(v.iridescenceMapUv),C.push(v.iridescenceThicknessMapUv),C.push(v.sheenColorMapUv),C.push(v.sheenRoughnessMapUv),C.push(v.specularMapUv),C.push(v.specularColorMapUv),C.push(v.specularIntensityMapUv),C.push(v.transmissionMapUv),C.push(v.thicknessMapUv),C.push(v.combine),C.push(v.fogExp2),C.push(v.sizeAttenuation),C.push(v.morphTargetsCount),C.push(v.morphAttributeCount),C.push(v.numDirLights),C.push(v.numPointLights),C.push(v.numSpotLights),C.push(v.numSpotLightMaps),C.push(v.numHemiLights),C.push(v.numRectAreaLights),C.push(v.numDirLightShadows),C.push(v.numPointLightShadows),C.push(v.numSpotLightShadows),C.push(v.numSpotLightShadowsWithMaps),C.push(v.numLightProbes),C.push(v.shadowMapType),C.push(v.toneMapping),C.push(v.numClippingPlanes),C.push(v.numClipIntersection),C.push(v.depthPacking)}function b(C,v){o.disableAll(),v.supportsVertexTextures&&o.enable(0),v.instancing&&o.enable(1),v.instancingColor&&o.enable(2),v.instancingMorph&&o.enable(3),v.matcap&&o.enable(4),v.envMap&&o.enable(5),v.normalMapObjectSpace&&o.enable(6),v.normalMapTangentSpace&&o.enable(7),v.clearcoat&&o.enable(8),v.iridescence&&o.enable(9),v.alphaTest&&o.enable(10),v.vertexColors&&o.enable(11),v.vertexAlphas&&o.enable(12),v.vertexUv1s&&o.enable(13),v.vertexUv2s&&o.enable(14),v.vertexUv3s&&o.enable(15),v.vertexTangents&&o.enable(16),v.anisotropy&&o.enable(17),v.alphaHash&&o.enable(18),v.batching&&o.enable(19),v.dispersion&&o.enable(20),v.batchingColor&&o.enable(21),C.push(o.mask),o.disableAll(),v.fog&&o.enable(0),v.useFog&&o.enable(1),v.flatShading&&o.enable(2),v.logarithmicDepthBuffer&&o.enable(3),v.reverseDepthBuffer&&o.enable(4),v.skinning&&o.enable(5),v.morphTargets&&o.enable(6),v.morphNormals&&o.enable(7),v.morphColors&&o.enable(8),v.premultipliedAlpha&&o.enable(9),v.shadowMapEnabled&&o.enable(10),v.doubleSided&&o.enable(11),v.flipSided&&o.enable(12),v.useDepthPacking&&o.enable(13),v.dithering&&o.enable(14),v.transmission&&o.enable(15),v.sheen&&o.enable(16),v.opaque&&o.enable(17),v.pointsUvs&&o.enable(18),v.decodeVideoTexture&&o.enable(19),v.decodeVideoTextureEmissive&&o.enable(20),v.alphaToCoverage&&o.enable(21),C.push(o.mask)}function E(C){const v=m[C.type];let F;if(v){const K=Di[v];F=cy.clone(K.uniforms)}else F=C.uniforms;return F}function M(C,v){let F;for(let K=0,q=h.length;K<q;K++){const $=h[K];if($.cacheKey===v){F=$,++F.usedTimes;break}}return F===void 0&&(F=new PS(i,v,C,r),h.push(F)),F}function w(C){if(--C.usedTimes===0){const v=h.indexOf(C);h[v]=h[h.length-1],h.pop(),C.destroy()}}function S(C){c.remove(C)}function T(){c.dispose()}return{getParameters:g,getProgramCacheKey:p,getUniforms:E,acquireProgram:M,releaseProgram:w,releaseShaderCache:S,programs:h,dispose:T}}function GS(){let i=new WeakMap;function e(a){return i.has(a)}function t(a){let o=i.get(a);return o===void 0&&(o={},i.set(a,o)),o}function n(a){i.delete(a)}function s(a,o,c){i.get(a)[o]=c}function r(){i=new WeakMap}return{has:e,get:t,remove:n,update:s,dispose:r}}function HS(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.material.id!==e.material.id?i.material.id-e.material.id:i.z!==e.z?i.z-e.z:i.id-e.id}function bg(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?e.z-i.z:i.id-e.id}function xg(){const i=[];let e=0;const t=[],n=[],s=[];function r(){e=0,t.length=0,n.length=0,s.length=0}function a(u,d,f,m,A,g){let p=i[e];return p===void 0?(p={id:u.id,object:u,geometry:d,material:f,groupOrder:m,renderOrder:u.renderOrder,z:A,group:g},i[e]=p):(p.id=u.id,p.object=u,p.geometry=d,p.material=f,p.groupOrder=m,p.renderOrder=u.renderOrder,p.z=A,p.group=g),e++,p}function o(u,d,f,m,A,g){const p=a(u,d,f,m,A,g);f.transmission>0?n.push(p):f.transparent===!0?s.push(p):t.push(p)}function c(u,d,f,m,A,g){const p=a(u,d,f,m,A,g);f.transmission>0?n.unshift(p):f.transparent===!0?s.unshift(p):t.unshift(p)}function l(u,d){t.length>1&&t.sort(u||HS),n.length>1&&n.sort(d||bg),s.length>1&&s.sort(d||bg)}function h(){for(let u=e,d=i.length;u<d;u++){const f=i[u];if(f.id===null)break;f.id=null,f.object=null,f.geometry=null,f.material=null,f.group=null}}return{opaque:t,transmissive:n,transparent:s,init:r,push:o,unshift:c,finish:h,sort:l}}function zS(){let i=new WeakMap;function e(n,s){const r=i.get(n);let a;return r===void 0?(a=new xg,i.set(n,[a])):s>=r.length?(a=new xg,r.push(a)):a=r[s],a}function t(){i=new WeakMap}return{get:e,dispose:t}}function VS(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new H,color:new qe};break;case"SpotLight":t={position:new H,direction:new H,color:new qe,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new H,color:new qe,distance:0,decay:0};break;case"HemisphereLight":t={direction:new H,skyColor:new qe,groundColor:new qe};break;case"RectAreaLight":t={color:new qe,position:new H,halfWidth:new H,halfHeight:new H};break}return i[e.id]=t,t}}}function WS(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ze};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ze};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ze,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}let qS=0;function KS(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function jS(i){const e=new VS,t=WS(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let l=0;l<9;l++)n.probe.push(new H);const s=new H,r=new $e,a=new $e;function o(l){let h=0,u=0,d=0;for(let C=0;C<9;C++)n.probe[C].set(0,0,0);let f=0,m=0,A=0,g=0,p=0,y=0,b=0,E=0,M=0,w=0,S=0;l.sort(KS);for(let C=0,v=l.length;C<v;C++){const F=l[C],K=F.color,q=F.intensity,$=F.distance,D=F.shadow&&F.shadow.map?F.shadow.map.texture:null;if(F.isAmbientLight)h+=K.r*q,u+=K.g*q,d+=K.b*q;else if(F.isLightProbe){for(let O=0;O<9;O++)n.probe[O].addScaledVector(F.sh.coefficients[O],q);S++}else if(F.isDirectionalLight){const O=e.get(F);if(O.color.copy(F.color).multiplyScalar(F.intensity),F.castShadow){const Y=F.shadow,Q=t.get(F);Q.shadowIntensity=Y.intensity,Q.shadowBias=Y.bias,Q.shadowNormalBias=Y.normalBias,Q.shadowRadius=Y.radius,Q.shadowMapSize=Y.mapSize,n.directionalShadow[f]=Q,n.directionalShadowMap[f]=D,n.directionalShadowMatrix[f]=F.shadow.matrix,y++}n.directional[f]=O,f++}else if(F.isSpotLight){const O=e.get(F);O.position.setFromMatrixPosition(F.matrixWorld),O.color.copy(K).multiplyScalar(q),O.distance=$,O.coneCos=Math.cos(F.angle),O.penumbraCos=Math.cos(F.angle*(1-F.penumbra)),O.decay=F.decay,n.spot[A]=O;const Y=F.shadow;if(F.map&&(n.spotLightMap[M]=F.map,M++,Y.updateMatrices(F),F.castShadow&&w++),n.spotLightMatrix[A]=Y.matrix,F.castShadow){const Q=t.get(F);Q.shadowIntensity=Y.intensity,Q.shadowBias=Y.bias,Q.shadowNormalBias=Y.normalBias,Q.shadowRadius=Y.radius,Q.shadowMapSize=Y.mapSize,n.spotShadow[A]=Q,n.spotShadowMap[A]=D,E++}A++}else if(F.isRectAreaLight){const O=e.get(F);O.color.copy(K).multiplyScalar(q),O.halfWidth.set(F.width*.5,0,0),O.halfHeight.set(0,F.height*.5,0),n.rectArea[g]=O,g++}else if(F.isPointLight){const O=e.get(F);if(O.color.copy(F.color).multiplyScalar(F.intensity),O.distance=F.distance,O.decay=F.decay,F.castShadow){const Y=F.shadow,Q=t.get(F);Q.shadowIntensity=Y.intensity,Q.shadowBias=Y.bias,Q.shadowNormalBias=Y.normalBias,Q.shadowRadius=Y.radius,Q.shadowMapSize=Y.mapSize,Q.shadowCameraNear=Y.camera.near,Q.shadowCameraFar=Y.camera.far,n.pointShadow[m]=Q,n.pointShadowMap[m]=D,n.pointShadowMatrix[m]=F.shadow.matrix,b++}n.point[m]=O,m++}else if(F.isHemisphereLight){const O=e.get(F);O.skyColor.copy(F.color).multiplyScalar(q),O.groundColor.copy(F.groundColor).multiplyScalar(q),n.hemi[p]=O,p++}}g>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=we.LTC_FLOAT_1,n.rectAreaLTC2=we.LTC_FLOAT_2):(n.rectAreaLTC1=we.LTC_HALF_1,n.rectAreaLTC2=we.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=u,n.ambient[2]=d;const T=n.hash;(T.directionalLength!==f||T.pointLength!==m||T.spotLength!==A||T.rectAreaLength!==g||T.hemiLength!==p||T.numDirectionalShadows!==y||T.numPointShadows!==b||T.numSpotShadows!==E||T.numSpotMaps!==M||T.numLightProbes!==S)&&(n.directional.length=f,n.spot.length=A,n.rectArea.length=g,n.point.length=m,n.hemi.length=p,n.directionalShadow.length=y,n.directionalShadowMap.length=y,n.pointShadow.length=b,n.pointShadowMap.length=b,n.spotShadow.length=E,n.spotShadowMap.length=E,n.directionalShadowMatrix.length=y,n.pointShadowMatrix.length=b,n.spotLightMatrix.length=E+M-w,n.spotLightMap.length=M,n.numSpotLightShadowsWithMaps=w,n.numLightProbes=S,T.directionalLength=f,T.pointLength=m,T.spotLength=A,T.rectAreaLength=g,T.hemiLength=p,T.numDirectionalShadows=y,T.numPointShadows=b,T.numSpotShadows=E,T.numSpotMaps=M,T.numLightProbes=S,n.version=qS++)}function c(l,h){let u=0,d=0,f=0,m=0,A=0;const g=h.matrixWorldInverse;for(let p=0,y=l.length;p<y;p++){const b=l[p];if(b.isDirectionalLight){const E=n.directional[u];E.direction.setFromMatrixPosition(b.matrixWorld),s.setFromMatrixPosition(b.target.matrixWorld),E.direction.sub(s),E.direction.transformDirection(g),u++}else if(b.isSpotLight){const E=n.spot[f];E.position.setFromMatrixPosition(b.matrixWorld),E.position.applyMatrix4(g),E.direction.setFromMatrixPosition(b.matrixWorld),s.setFromMatrixPosition(b.target.matrixWorld),E.direction.sub(s),E.direction.transformDirection(g),f++}else if(b.isRectAreaLight){const E=n.rectArea[m];E.position.setFromMatrixPosition(b.matrixWorld),E.position.applyMatrix4(g),a.identity(),r.copy(b.matrixWorld),r.premultiply(g),a.extractRotation(r),E.halfWidth.set(b.width*.5,0,0),E.halfHeight.set(0,b.height*.5,0),E.halfWidth.applyMatrix4(a),E.halfHeight.applyMatrix4(a),m++}else if(b.isPointLight){const E=n.point[d];E.position.setFromMatrixPosition(b.matrixWorld),E.position.applyMatrix4(g),d++}else if(b.isHemisphereLight){const E=n.hemi[A];E.direction.setFromMatrixPosition(b.matrixWorld),E.direction.transformDirection(g),A++}}}return{setup:o,setupView:c,state:n}}function _g(i){const e=new jS(i),t=[],n=[];function s(h){l.camera=h,t.length=0,n.length=0}function r(h){t.push(h)}function a(h){n.push(h)}function o(){e.setup(t)}function c(h){e.setupView(t,h)}const l={lightsArray:t,shadowsArray:n,camera:null,lights:e,transmissionRenderTarget:{}};return{init:s,state:l,setupLights:o,setupLightsView:c,pushLight:r,pushShadow:a}}function XS(i){let e=new WeakMap;function t(s,r=0){const a=e.get(s);let o;return a===void 0?(o=new _g(i),e.set(s,[o])):r>=a.length?(o=new _g(i),a.push(o)):o=a[r],o}function n(){e=new WeakMap}return{get:t,dispose:n}}const YS=`void main() {+ gl_Position = vec4( position, 1.0 );+}`,JS=`uniform sampler2D shadow_pass;+uniform vec2 resolution;+uniform float radius;+#include <packing>+void main() {+ const float samples = float( VSM_SAMPLES );+ float mean = 0.0;+ float squared_mean = 0.0;+ float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );+ float uvStart = samples <= 1.0 ? 0.0 : - 1.0;+ for ( float i = 0.0; i < samples; i ++ ) {+ float uvOffset = uvStart + i * uvStride;+ #ifdef HORIZONTAL_PASS+ vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );+ mean += distribution.x;+ squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;+ #else+ float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );+ mean += depth;+ squared_mean += depth * depth;+ #endif+ }+ mean = mean / samples;+ squared_mean = squared_mean / samples;+ float std_dev = sqrt( squared_mean - mean * mean );+ gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );+}`;function ZS(i,e,t){let n=new ku;const s=new Ze,r=new Ze,a=new Et,o=new Cy({depthPacking:fE}),c=new Sy,l={},h=t.maxTextureSize,u={[Hi]:In,[In]:Hi,[Bi]:Bi},d=new Is({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ze},radius:{value:4}},vertexShader:YS,fragmentShader:JS}),f=d.clone();f.defines.HORIZONTAL_PASS=1;const m=new Qn;m.setAttribute("position",new _n(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const A=new Jt(m,d),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=mp;let p=this.type;this.render=function(w,S,T){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||w.length===0)return;const C=i.getRenderTarget(),v=i.getActiveCubeFace(),F=i.getActiveMipmapLevel(),K=i.state;K.setBlending(bs),K.buffers.color.setClear(1,1,1,1),K.buffers.depth.setTest(!0),K.setScissorTest(!1);const q=p!==Gi&&this.type===Gi,$=p===Gi&&this.type!==Gi;for(let D=0,O=w.length;D<O;D++){const Y=w[D],Q=Y.shadow;if(Q===void 0){console.warn("THREE.WebGLShadowMap:",Y,"has no shadow.");continue}if(Q.autoUpdate===!1&&Q.needsUpdate===!1)continue;s.copy(Q.mapSize);const J=Q.getFrameExtents();if(s.multiply(J),r.copy(Q.mapSize),(s.x>h||s.y>h)&&(s.x>h&&(r.x=Math.floor(h/J.x),s.x=r.x*J.x,Q.mapSize.x=r.x),s.y>h&&(r.y=Math.floor(h/J.y),s.y=r.y*J.y,Q.mapSize.y=r.y)),Q.map===null||q===!0||$===!0){const ae=this.type!==Gi?{minFilter:Mn,magFilter:Mn}:{};Q.map!==null&&Q.map.dispose(),Q.map=new $s(s.x,s.y,ae),Q.map.texture.name=Y.name+".shadowMap",Q.camera.updateProjectionMatrix()}i.setRenderTarget(Q.map),i.clear();const ee=Q.getViewportCount();for(let ae=0;ae<ee;ae++){const ye=Q.getViewport(ae);a.set(r.x*ye.x,r.y*ye.y,r.x*ye.z,r.y*ye.w),K.viewport(a),Q.updateMatrices(Y,ae),n=Q.getFrustum(),E(S,T,Q.camera,Y,this.type)}Q.isPointLightShadow!==!0&&this.type===Gi&&y(Q,T),Q.needsUpdate=!1}p=this.type,g.needsUpdate=!1,i.setRenderTarget(C,v,F)};function y(w,S){const T=e.update(A);d.defines.VSM_SAMPLES!==w.blurSamples&&(d.defines.VSM_SAMPLES=w.blurSamples,f.defines.VSM_SAMPLES=w.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),w.mapPass===null&&(w.mapPass=new $s(s.x,s.y)),d.uniforms.shadow_pass.value=w.map.texture,d.uniforms.resolution.value=w.mapSize,d.uniforms.radius.value=w.radius,i.setRenderTarget(w.mapPass),i.clear(),i.renderBufferDirect(S,null,T,d,A,null),f.uniforms.shadow_pass.value=w.mapPass.texture,f.uniforms.resolution.value=w.mapSize,f.uniforms.radius.value=w.radius,i.setRenderTarget(w.map),i.clear(),i.renderBufferDirect(S,null,T,f,A,null)}function b(w,S,T,C){let v=null;const F=T.isPointLight===!0?w.customDistanceMaterial:w.customDepthMaterial;if(F!==void 0)v=F;else if(v=T.isPointLight===!0?c:o,i.localClippingEnabled&&S.clipShadows===!0&&Array.isArray(S.clippingPlanes)&&S.clippingPlanes.length!==0||S.displacementMap&&S.displacementScale!==0||S.alphaMap&&S.alphaTest>0||S.map&&S.alphaTest>0||S.alphaToCoverage===!0){const K=v.uuid,q=S.uuid;let $=l[K];$===void 0&&($={},l[K]=$);let D=$[q];D===void 0&&(D=v.clone(),$[q]=D,S.addEventListener("dispose",M)),v=D}if(v.visible=S.visible,v.wireframe=S.wireframe,C===Gi?v.side=S.shadowSide!==null?S.shadowSide:S.side:v.side=S.shadowSide!==null?S.shadowSide:u[S.side],v.alphaMap=S.alphaMap,v.alphaTest=S.alphaToCoverage===!0?.5:S.alphaTest,v.map=S.map,v.clipShadows=S.clipShadows,v.clippingPlanes=S.clippingPlanes,v.clipIntersection=S.clipIntersection,v.displacementMap=S.displacementMap,v.displacementScale=S.displacementScale,v.displacementBias=S.displacementBias,v.wireframeLinewidth=S.wireframeLinewidth,v.linewidth=S.linewidth,T.isPointLight===!0&&v.isMeshDistanceMaterial===!0){const K=i.properties.get(v);K.light=T}return v}function E(w,S,T,C,v){if(w.visible===!1)return;if(w.layers.test(S.layers)&&(w.isMesh||w.isLine||w.isPoints)&&(w.castShadow||w.receiveShadow&&v===Gi)&&(!w.frustumCulled||n.intersectsObject(w))){w.modelViewMatrix.multiplyMatrices(T.matrixWorldInverse,w.matrixWorld);const q=e.update(w),$=w.material;if(Array.isArray($)){const D=q.groups;for(let O=0,Y=D.length;O<Y;O++){const Q=D[O],J=$[Q.materialIndex];if(J&&J.visible){const ee=b(w,J,C,v);w.onBeforeShadow(i,w,S,T,q,ee,Q),i.renderBufferDirect(T,null,q,ee,w,Q),w.onAfterShadow(i,w,S,T,q,ee,Q)}}}else if($.visible){const D=b(w,$,C,v);w.onBeforeShadow(i,w,S,T,q,D,null),i.renderBufferDirect(T,null,q,D,w,null),w.onAfterShadow(i,w,S,T,q,D,null)}}const K=w.children;for(let q=0,$=K.length;q<$;q++)E(K[q],S,T,C,v)}function M(w){w.target.removeEventListener("dispose",M);for(const T in l){const C=l[T],v=w.target.uuid;v in C&&(C[v].dispose(),delete C[v])}}}const $S={[vh]:Ch,[Sh]:Bh,[Ih]:Th,[Ur]:Mh,[Ch]:vh,[Bh]:Sh,[Th]:Ih,[Mh]:Ur};function eI(i,e){function t(){let W=!1;const ne=new Et;let re=null;const de=new Et(0,0,0,0);return{setMask:function(Ie){re!==Ie&&!W&&(i.colorMask(Ie,Ie,Ie,Ie),re=Ie)},setLocked:function(Ie){W=Ie},setClear:function(Ie,Se,it,Qt,bn){bn===!0&&(Ie*=Qt,Se*=Qt,it*=Qt),ne.set(Ie,Se,it,Qt),de.equals(ne)===!1&&(i.clearColor(Ie,Se,it,Qt),de.copy(ne))},reset:function(){W=!1,re=null,de.set(-1,0,0,0)}}}function n(){let W=!1,ne=!1,re=null,de=null,Ie=null;return{setReversed:function(Se){if(ne!==Se){const it=e.get("EXT_clip_control");Se?it.clipControlEXT(it.LOWER_LEFT_EXT,it.ZERO_TO_ONE_EXT):it.clipControlEXT(it.LOWER_LEFT_EXT,it.NEGATIVE_ONE_TO_ONE_EXT),ne=Se;const Qt=Ie;Ie=null,this.setClear(Qt)}},getReversed:function(){return ne},setTest:function(Se){Se?xe(i.DEPTH_TEST):Pe(i.DEPTH_TEST)},setMask:function(Se){re!==Se&&!W&&(i.depthMask(Se),re=Se)},setFunc:function(Se){if(ne&&(Se=$S[Se]),de!==Se){switch(Se){case vh:i.depthFunc(i.NEVER);break;case Ch:i.depthFunc(i.ALWAYS);break;case Sh:i.depthFunc(i.LESS);break;case Ur:i.depthFunc(i.LEQUAL);break;case Ih:i.depthFunc(i.EQUAL);break;case Mh:i.depthFunc(i.GEQUAL);break;case Bh:i.depthFunc(i.GREATER);break;case Th:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}de=Se}},setLocked:function(Se){W=Se},setClear:function(Se){Ie!==Se&&(ne&&(Se=1-Se),i.clearDepth(Se),Ie=Se)},reset:function(){W=!1,re=null,de=null,Ie=null,ne=!1}}}function s(){let W=!1,ne=null,re=null,de=null,Ie=null,Se=null,it=null,Qt=null,bn=null;return{setTest:function(yt){W||(yt?xe(i.STENCIL_TEST):Pe(i.STENCIL_TEST))},setMask:function(yt){ne!==yt&&!W&&(i.stencilMask(yt),ne=yt)},setFunc:function(yt,Jn,Mi){(re!==yt||de!==Jn||Ie!==Mi)&&(i.stencilFunc(yt,Jn,Mi),re=yt,de=Jn,Ie=Mi)},setOp:function(yt,Jn,Mi){(Se!==yt||it!==Jn||Qt!==Mi)&&(i.stencilOp(yt,Jn,Mi),Se=yt,it=Jn,Qt=Mi)},setLocked:function(yt){W=yt},setClear:function(yt){bn!==yt&&(i.clearStencil(yt),bn=yt)},reset:function(){W=!1,ne=null,re=null,de=null,Ie=null,Se=null,it=null,Qt=null,bn=null}}}const r=new t,a=new n,o=new s,c=new WeakMap,l=new WeakMap;let h={},u={},d=new WeakMap,f=[],m=null,A=!1,g=null,p=null,y=null,b=null,E=null,M=null,w=null,S=new qe(0,0,0),T=0,C=!1,v=null,F=null,K=null,q=null,$=null;const D=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let O=!1,Y=0;const Q=i.getParameter(i.VERSION);Q.indexOf("WebGL")!==-1?(Y=parseFloat(/^WebGL (\d)/.exec(Q)[1]),O=Y>=1):Q.indexOf("OpenGL ES")!==-1&&(Y=parseFloat(/^OpenGL ES (\d)/.exec(Q)[1]),O=Y>=2);let J=null,ee={};const ae=i.getParameter(i.SCISSOR_BOX),ye=i.getParameter(i.VIEWPORT),Me=new Et().fromArray(ae),se=new Et().fromArray(ye);function me(W,ne,re,de){const Ie=new Uint8Array(4),Se=i.createTexture();i.bindTexture(W,Se),i.texParameteri(W,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(W,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let it=0;it<re;it++)W===i.TEXTURE_3D||W===i.TEXTURE_2D_ARRAY?i.texImage3D(ne,0,i.RGBA,1,1,de,0,i.RGBA,i.UNSIGNED_BYTE,Ie):i.texImage2D(ne+it,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,Ie);return Se}const be={};be[i.TEXTURE_2D]=me(i.TEXTURE_2D,i.TEXTURE_2D,1),be[i.TEXTURE_CUBE_MAP]=me(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),be[i.TEXTURE_2D_ARRAY]=me(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),be[i.TEXTURE_3D]=me(i.TEXTURE_3D,i.TEXTURE_3D,1,1),r.setClear(0,0,0,1),a.setClear(1),o.setClear(0),xe(i.DEPTH_TEST),a.setFunc(Ur),dt(!1),pt(gp),xe(i.CULL_FACE),G(bs);function xe(W){h[W]!==!0&&(i.enable(W),h[W]=!0)}function Pe(W){h[W]!==!1&&(i.disable(W),h[W]=!1)}function et(W,ne){return u[W]!==ne?(i.bindFramebuffer(W,ne),u[W]=ne,W===i.DRAW_FRAMEBUFFER&&(u[i.FRAMEBUFFER]=ne),W===i.FRAMEBUFFER&&(u[i.DRAW_FRAMEBUFFER]=ne),!0):!1}function Qe(W,ne){let re=f,de=!1;if(W){re=d.get(ne),re===void 0&&(re=[],d.set(ne,re));const Ie=W.textures;if(re.length!==Ie.length||re[0]!==i.COLOR_ATTACHMENT0){for(let Se=0,it=Ie.length;Se<it;Se++)re[Se]=i.COLOR_ATTACHMENT0+Se;re.length=Ie.length,de=!0}}else re[0]!==i.BACK&&(re[0]=i.BACK,de=!0);de&&i.drawBuffers(re)}function St(W){return m!==W?(i.useProgram(W),m=W,!0):!1}const ut={[Xs]:i.FUNC_ADD,[U_]:i.FUNC_SUBTRACT,[O_]:i.FUNC_REVERSE_SUBTRACT};ut[Q_]=i.MIN,ut[G_]=i.MAX;const Je={[H_]:i.ZERO,[z_]:i.ONE,[V_]:i.SRC_COLOR,[yh]:i.SRC_ALPHA,[Y_]:i.SRC_ALPHA_SATURATE,[j_]:i.DST_COLOR,[q_]:i.DST_ALPHA,[W_]:i.ONE_MINUS_SRC_COLOR,[wh]:i.ONE_MINUS_SRC_ALPHA,[X_]:i.ONE_MINUS_DST_COLOR,[K_]:i.ONE_MINUS_DST_ALPHA,[J_]:i.CONSTANT_COLOR,[Z_]:i.ONE_MINUS_CONSTANT_COLOR,[$_]:i.CONSTANT_ALPHA,[eE]:i.ONE_MINUS_CONSTANT_ALPHA};function G(W,ne,re,de,Ie,Se,it,Qt,bn,yt){if(W===bs){A===!0&&(Pe(i.BLEND),A=!1);return}if(A===!1&&(xe(i.BLEND),A=!0),W!==k_){if(W!==g||yt!==C){if((p!==Xs||E!==Xs)&&(i.blendEquation(i.FUNC_ADD),p=Xs,E=Xs),yt)switch(W){case kr:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case bp:i.blendFunc(i.ONE,i.ONE);break;case xp:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case _p:i.blendFuncSeparate(i.ZERO,i.SRC_COLOR,i.ZERO,i.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",W);break}else switch(W){case kr:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case bp:i.blendFunc(i.SRC_ALPHA,i.ONE);break;case xp:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case _p:i.blendFunc(i.ZERO,i.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",W);break}y=null,b=null,M=null,w=null,S.set(0,0,0),T=0,g=W,C=yt}return}Ie=Ie||ne,Se=Se||re,it=it||de,(ne!==p||Ie!==E)&&(i.blendEquationSeparate(ut[ne],ut[Ie]),p=ne,E=Ie),(re!==y||de!==b||Se!==M||it!==w)&&(i.blendFuncSeparate(Je[re],Je[de],Je[Se],Je[it]),y=re,b=de,M=Se,w=it),(Qt.equals(S)===!1||bn!==T)&&(i.blendColor(Qt.r,Qt.g,Qt.b,bn),S.copy(Qt),T=bn),g=W,C=!1}function mn(W,ne){W.side===Bi?Pe(i.CULL_FACE):xe(i.CULL_FACE);let re=W.side===In;ne&&(re=!re),dt(re),W.blending===kr&&W.transparent===!1?G(bs):G(W.blending,W.blendEquation,W.blendSrc,W.blendDst,W.blendEquationAlpha,W.blendSrcAlpha,W.blendDstAlpha,W.blendColor,W.blendAlpha,W.premultipliedAlpha),a.setFunc(W.depthFunc),a.setTest(W.depthTest),a.setMask(W.depthWrite),r.setMask(W.colorWrite);const de=W.stencilWrite;o.setTest(de),de&&(o.setMask(W.stencilWriteMask),o.setFunc(W.stencilFunc,W.stencilRef,W.stencilFuncMask),o.setOp(W.stencilFail,W.stencilZFail,W.stencilZPass)),Rt(W.polygonOffset,W.polygonOffsetFactor,W.polygonOffsetUnits),W.alphaToCoverage===!0?xe(i.SAMPLE_ALPHA_TO_COVERAGE):Pe(i.SAMPLE_ALPHA_TO_COVERAGE)}function dt(W){v!==W&&(W?i.frontFace(i.CW):i.frontFace(i.CCW),v=W)}function pt(W){W!==D_?(xe(i.CULL_FACE),W!==F&&(W===gp?i.cullFace(i.BACK):W===L_?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):Pe(i.CULL_FACE),F=W}function ze(W){W!==K&&(O&&i.lineWidth(W),K=W)}function Rt(W,ne,re){W?(xe(i.POLYGON_OFFSET_FILL),(q!==ne||$!==re)&&(i.polygonOffset(ne,re),q=ne,$=re)):Pe(i.POLYGON_OFFSET_FILL)}function Ge(W){W?xe(i.SCISSOR_TEST):Pe(i.SCISSOR_TEST)}function L(W){W===void 0&&(W=i.TEXTURE0+D-1),J!==W&&(i.activeTexture(W),J=W)}function I(W,ne,re){re===void 0&&(J===null?re=i.TEXTURE0+D-1:re=J);let de=ee[re];de===void 0&&(de={type:void 0,texture:void 0},ee[re]=de),(de.type!==W||de.texture!==ne)&&(J!==re&&(i.activeTexture(re),J=re),i.bindTexture(W,ne||be[W]),de.type=W,de.texture=ne)}function Z(){const W=ee[J];W!==void 0&&W.type!==void 0&&(i.bindTexture(W.type,null),W.type=void 0,W.texture=void 0)}function le(){try{i.compressedTexImage2D(...arguments)}catch(W){console.error("THREE.WebGLState:",W)}}function Ae(){try{i.compressedTexImage3D(...arguments)}catch(W){console.error("THREE.WebGLState:",W)}}function oe(){try{i.texSubImage2D(...arguments)}catch(W){console.error("THREE.WebGLState:",W)}}function Ue(){try{i.texSubImage3D(...arguments)}catch(W){console.error("THREE.WebGLState:",W)}}function ve(){try{i.compressedTexSubImage2D(...arguments)}catch(W){console.error("THREE.WebGLState:",W)}}function Ve(){try{i.compressedTexSubImage3D(...arguments)}catch(W){console.error("THREE.WebGLState:",W)}}function Ye(){try{i.texStorage2D(...arguments)}catch(W){console.error("THREE.WebGLState:",W)}}function _e(){try{i.texStorage3D(...arguments)}catch(W){console.error("THREE.WebGLState:",W)}}function Ne(){try{i.texImage2D(...arguments)}catch(W){console.error("THREE.WebGLState:",W)}}function ke(){try{i.texImage3D(...arguments)}catch(W){console.error("THREE.WebGLState:",W)}}function Oe(W){Me.equals(W)===!1&&(i.scissor(W.x,W.y,W.z,W.w),Me.copy(W))}function Te(W){se.equals(W)===!1&&(i.viewport(W.x,W.y,W.z,W.w),se.copy(W))}function tt(W,ne){let re=l.get(ne);re===void 0&&(re=new WeakMap,l.set(ne,re));let de=re.get(W);de===void 0&&(de=i.getUniformBlockIndex(ne,W.name),re.set(W,de))}function We(W,ne){const de=l.get(ne).get(W);c.get(ne)!==de&&(i.uniformBlockBinding(ne,de,W.__bindingPointIndex),c.set(ne,de))}function nt(){i.disable(i.BLEND),i.disable(i.CULL_FACE),i.disable(i.DEPTH_TEST),i.disable(i.POLYGON_OFFSET_FILL),i.disable(i.SCISSOR_TEST),i.disable(i.STENCIL_TEST),i.disable(i.SAMPLE_ALPHA_TO_COVERAGE),i.blendEquation(i.FUNC_ADD),i.blendFunc(i.ONE,i.ZERO),i.blendFuncSeparate(i.ONE,i.ZERO,i.ONE,i.ZERO),i.blendColor(0,0,0,0),i.colorMask(!0,!0,!0,!0),i.clearColor(0,0,0,0),i.depthMask(!0),i.depthFunc(i.LESS),a.setReversed(!1),i.clearDepth(1),i.stencilMask(4294967295),i.stencilFunc(i.ALWAYS,0,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.KEEP),i.clearStencil(0),i.cullFace(i.BACK),i.frontFace(i.CCW),i.polygonOffset(0,0),i.activeTexture(i.TEXTURE0),i.bindFramebuffer(i.FRAMEBUFFER,null),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),i.bindFramebuffer(i.READ_FRAMEBUFFER,null),i.useProgram(null),i.lineWidth(1),i.scissor(0,0,i.canvas.width,i.canvas.height),i.viewport(0,0,i.canvas.width,i.canvas.height),h={},J=null,ee={},u={},d=new WeakMap,f=[],m=null,A=!1,g=null,p=null,y=null,b=null,E=null,M=null,w=null,S=new qe(0,0,0),T=0,C=!1,v=null,F=null,K=null,q=null,$=null,Me.set(0,0,i.canvas.width,i.canvas.height),se.set(0,0,i.canvas.width,i.canvas.height),r.reset(),a.reset(),o.reset()}return{buffers:{color:r,depth:a,stencil:o},enable:xe,disable:Pe,bindFramebuffer:et,drawBuffers:Qe,useProgram:St,setBlending:G,setMaterial:mn,setFlipSided:dt,setCullFace:pt,setLineWidth:ze,setPolygonOffset:Rt,setScissorTest:Ge,activeTexture:L,bindTexture:I,unbindTexture:Z,compressedTexImage2D:le,compressedTexImage3D:Ae,texImage2D:Ne,texImage3D:ke,updateUBOMapping:tt,uniformBlockBinding:We,texStorage2D:Ye,texStorage3D:_e,texSubImage2D:oe,texSubImage3D:Ue,compressedTexSubImage2D:ve,compressedTexSubImage3D:Ve,scissor:Oe,viewport:Te,reset:nt}}function tI(i,e,t,n,s,r,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new Ze,h=new WeakMap;let u;const d=new WeakMap;let f=!1;try{f=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function m(L,I){return f?new OffscreenCanvas(L,I):oo("canvas")}function A(L,I,Z){let le=1;const Ae=Ge(L);if((Ae.width>Z||Ae.height>Z)&&(le=Z/Math.max(Ae.width,Ae.height)),le<1)if(typeof HTMLImageElement<"u"&&L instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&L instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&L instanceof ImageBitmap||typeof VideoFrame<"u"&&L instanceof VideoFrame){const oe=Math.floor(le*Ae.width),Ue=Math.floor(le*Ae.height);u===void 0&&(u=m(oe,Ue));const ve=I?m(oe,Ue):u;return ve.width=oe,ve.height=Ue,ve.getContext("2d").drawImage(L,0,0,oe,Ue),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+Ae.width+"x"+Ae.height+") to ("+oe+"x"+Ue+")."),ve}else return"data"in L&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+Ae.width+"x"+Ae.height+")."),L;return L}function g(L){return L.generateMipmaps}function p(L){i.generateMipmap(L)}function y(L){return L.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:L.isWebGL3DRenderTarget?i.TEXTURE_3D:L.isWebGLArrayRenderTarget||L.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function b(L,I,Z,le,Ae=!1){if(L!==null){if(i[L]!==void 0)return i[L];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+L+"'")}let oe=I;if(I===i.RED&&(Z===i.FLOAT&&(oe=i.R32F),Z===i.HALF_FLOAT&&(oe=i.R16F),Z===i.UNSIGNED_BYTE&&(oe=i.R8)),I===i.RED_INTEGER&&(Z===i.UNSIGNED_BYTE&&(oe=i.R8UI),Z===i.UNSIGNED_SHORT&&(oe=i.R16UI),Z===i.UNSIGNED_INT&&(oe=i.R32UI),Z===i.BYTE&&(oe=i.R8I),Z===i.SHORT&&(oe=i.R16I),Z===i.INT&&(oe=i.R32I)),I===i.RG&&(Z===i.FLOAT&&(oe=i.RG32F),Z===i.HALF_FLOAT&&(oe=i.RG16F),Z===i.UNSIGNED_BYTE&&(oe=i.RG8)),I===i.RG_INTEGER&&(Z===i.UNSIGNED_BYTE&&(oe=i.RG8UI),Z===i.UNSIGNED_SHORT&&(oe=i.RG16UI),Z===i.UNSIGNED_INT&&(oe=i.RG32UI),Z===i.BYTE&&(oe=i.RG8I),Z===i.SHORT&&(oe=i.RG16I),Z===i.INT&&(oe=i.RG32I)),I===i.RGB_INTEGER&&(Z===i.UNSIGNED_BYTE&&(oe=i.RGB8UI),Z===i.UNSIGNED_SHORT&&(oe=i.RGB16UI),Z===i.UNSIGNED_INT&&(oe=i.RGB32UI),Z===i.BYTE&&(oe=i.RGB8I),Z===i.SHORT&&(oe=i.RGB16I),Z===i.INT&&(oe=i.RGB32I)),I===i.RGBA_INTEGER&&(Z===i.UNSIGNED_BYTE&&(oe=i.RGBA8UI),Z===i.UNSIGNED_SHORT&&(oe=i.RGBA16UI),Z===i.UNSIGNED_INT&&(oe=i.RGBA32UI),Z===i.BYTE&&(oe=i.RGBA8I),Z===i.SHORT&&(oe=i.RGBA16I),Z===i.INT&&(oe=i.RGBA32I)),I===i.RGB&&Z===i.UNSIGNED_INT_5_9_9_9_REV&&(oe=i.RGB9_E5),I===i.RGBA){const Ue=Ae?Cc:At.getTransfer(le);Z===i.FLOAT&&(oe=i.RGBA32F),Z===i.HALF_FLOAT&&(oe=i.RGBA16F),Z===i.UNSIGNED_BYTE&&(oe=Ue===Mt?i.SRGB8_ALPHA8:i.RGBA8),Z===i.UNSIGNED_SHORT_4_4_4_4&&(oe=i.RGBA4),Z===i.UNSIGNED_SHORT_5_5_5_1&&(oe=i.RGB5_A1)}return(oe===i.R16F||oe===i.R32F||oe===i.RG16F||oe===i.RG32F||oe===i.RGBA16F||oe===i.RGBA32F)&&e.get("EXT_color_buffer_float"),oe}function E(L,I){let Z;return L?I===null||I===Js||I===Xa?Z=i.DEPTH24_STENCIL8:I===nn?Z=i.DEPTH32F_STENCIL8:I===ja&&(Z=i.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):I===null||I===Js||I===Xa?Z=i.DEPTH_COMPONENT24:I===nn?Z=i.DEPTH_COMPONENT32F:I===ja&&(Z=i.DEPTH_COMPONENT16),Z}function M(L,I){return g(L)===!0||L.isFramebufferTexture&&L.minFilter!==Mn&&L.minFilter!==zt?Math.log2(Math.max(I.width,I.height))+1:L.mipmaps!==void 0&&L.mipmaps.length>0?L.mipmaps.length:L.isCompressedTexture&&Array.isArray(L.image)?I.mipmaps.length:1}function w(L){const I=L.target;I.removeEventListener("dispose",w),T(I),I.isVideoTexture&&h.delete(I)}function S(L){const I=L.target;I.removeEventListener("dispose",S),v(I)}function T(L){const I=n.get(L);if(I.__webglInit===void 0)return;const Z=L.source,le=d.get(Z);if(le){const Ae=le[I.__cacheKey];Ae.usedTimes--,Ae.usedTimes===0&&C(L),Object.keys(le).length===0&&d.delete(Z)}n.remove(L)}function C(L){const I=n.get(L);i.deleteTexture(I.__webglTexture);const Z=L.source,le=d.get(Z);delete le[I.__cacheKey],a.memory.textures--}function v(L){const I=n.get(L);if(L.depthTexture&&(L.depthTexture.dispose(),n.remove(L.depthTexture)),L.isWebGLCubeRenderTarget)for(let le=0;le<6;le++){if(Array.isArray(I.__webglFramebuffer[le]))for(let Ae=0;Ae<I.__webglFramebuffer[le].length;Ae++)i.deleteFramebuffer(I.__webglFramebuffer[le][Ae]);else i.deleteFramebuffer(I.__webglFramebuffer[le]);I.__webglDepthbuffer&&i.deleteRenderbuffer(I.__webglDepthbuffer[le])}else{if(Array.isArray(I.__webglFramebuffer))for(let le=0;le<I.__webglFramebuffer.length;le++)i.deleteFramebuffer(I.__webglFramebuffer[le]);else i.deleteFramebuffer(I.__webglFramebuffer);if(I.__webglDepthbuffer&&i.deleteRenderbuffer(I.__webglDepthbuffer),I.__webglMultisampledFramebuffer&&i.deleteFramebuffer(I.__webglMultisampledFramebuffer),I.__webglColorRenderbuffer)for(let le=0;le<I.__webglColorRenderbuffer.length;le++)I.__webglColorRenderbuffer[le]&&i.deleteRenderbuffer(I.__webglColorRenderbuffer[le]);I.__webglDepthRenderbuffer&&i.deleteRenderbuffer(I.__webglDepthRenderbuffer)}const Z=L.textures;for(let le=0,Ae=Z.length;le<Ae;le++){const oe=n.get(Z[le]);oe.__webglTexture&&(i.deleteTexture(oe.__webglTexture),a.memory.textures--),n.remove(Z[le])}n.remove(L)}let F=0;function K(){F=0}function q(){const L=F;return L>=s.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+L+" texture units while this GPU supports only "+s.maxTextures),F+=1,L}function $(L){const I=[];return I.push(L.wrapS),I.push(L.wrapT),I.push(L.wrapR||0),I.push(L.magFilter),I.push(L.minFilter),I.push(L.anisotropy),I.push(L.internalFormat),I.push(L.format),I.push(L.type),I.push(L.generateMipmaps),I.push(L.premultiplyAlpha),I.push(L.flipY),I.push(L.unpackAlignment),I.push(L.colorSpace),I.join()}function D(L,I){const Z=n.get(L);if(L.isVideoTexture&&ze(L),L.isRenderTargetTexture===!1&&L.version>0&&Z.__version!==L.version){const le=L.image;if(le===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(le.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{se(Z,L,I);return}}t.bindTexture(i.TEXTURE_2D,Z.__webglTexture,i.TEXTURE0+I)}function O(L,I){const Z=n.get(L);if(L.version>0&&Z.__version!==L.version){se(Z,L,I);return}t.bindTexture(i.TEXTURE_2D_ARRAY,Z.__webglTexture,i.TEXTURE0+I)}function Y(L,I){const Z=n.get(L);if(L.version>0&&Z.__version!==L.version){se(Z,L,I);return}t.bindTexture(i.TEXTURE_3D,Z.__webglTexture,i.TEXTURE0+I)}function Q(L,I){const Z=n.get(L);if(L.version>0&&Z.__version!==L.version){me(Z,L,I);return}t.bindTexture(i.TEXTURE_CUBE_MAP,Z.__webglTexture,i.TEXTURE0+I)}const J={[Qr]:i.REPEAT,[ci]:i.CLAMP_TO_EDGE,[pc]:i.MIRRORED_REPEAT},ee={[Mn]:i.NEAREST,[Cp]:i.NEAREST_MIPMAP_NEAREST,[Ka]:i.NEAREST_MIPMAP_LINEAR,[zt]:i.LINEAR,[Ac]:i.LINEAR_MIPMAP_NEAREST,[Zn]:i.LINEAR_MIPMAP_LINEAR},ae={[AE]:i.NEVER,[EE]:i.ALWAYS,[gE]:i.LESS,[kp]:i.LEQUAL,[mE]:i.EQUAL,[_E]:i.GEQUAL,[bE]:i.GREATER,[xE]:i.NOTEQUAL};function ye(L,I){if(I.type===nn&&e.has("OES_texture_float_linear")===!1&&(I.magFilter===zt||I.magFilter===Ac||I.magFilter===Ka||I.magFilter===Zn||I.minFilter===zt||I.minFilter===Ac||I.minFilter===Ka||I.minFilter===Zn)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(L,i.TEXTURE_WRAP_S,J[I.wrapS]),i.texParameteri(L,i.TEXTURE_WRAP_T,J[I.wrapT]),(L===i.TEXTURE_3D||L===i.TEXTURE_2D_ARRAY)&&i.texParameteri(L,i.TEXTURE_WRAP_R,J[I.wrapR]),i.texParameteri(L,i.TEXTURE_MAG_FILTER,ee[I.magFilter]),i.texParameteri(L,i.TEXTURE_MIN_FILTER,ee[I.minFilter]),I.compareFunction&&(i.texParameteri(L,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(L,i.TEXTURE_COMPARE_FUNC,ae[I.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(I.magFilter===Mn||I.minFilter!==Ka&&I.minFilter!==Zn||I.type===nn&&e.has("OES_texture_float_linear")===!1)return;if(I.anisotropy>1||n.get(I).__currentAnisotropy){const Z=e.get("EXT_texture_filter_anisotropic");i.texParameterf(L,Z.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(I.anisotropy,s.getMaxAnisotropy())),n.get(I).__currentAnisotropy=I.anisotropy}}}function Me(L,I){let Z=!1;L.__webglInit===void 0&&(L.__webglInit=!0,I.addEventListener("dispose",w));const le=I.source;let Ae=d.get(le);Ae===void 0&&(Ae={},d.set(le,Ae));const oe=$(I);if(oe!==L.__cacheKey){Ae[oe]===void 0&&(Ae[oe]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,Z=!0),Ae[oe].usedTimes++;const Ue=Ae[L.__cacheKey];Ue!==void 0&&(Ae[L.__cacheKey].usedTimes--,Ue.usedTimes===0&&C(I)),L.__cacheKey=oe,L.__webglTexture=Ae[oe].texture}return Z}function se(L,I,Z){let le=i.TEXTURE_2D;(I.isDataArrayTexture||I.isCompressedArrayTexture)&&(le=i.TEXTURE_2D_ARRAY),I.isData3DTexture&&(le=i.TEXTURE_3D);const Ae=Me(L,I),oe=I.source;t.bindTexture(le,L.__webglTexture,i.TEXTURE0+Z);const Ue=n.get(oe);if(oe.version!==Ue.__version||Ae===!0){t.activeTexture(i.TEXTURE0+Z);const ve=At.getPrimaries(At.workingColorSpace),Ve=I.colorSpace===li?null:At.getPrimaries(I.colorSpace),Ye=I.colorSpace===li||ve===Ve?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,I.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,I.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,I.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ye);let _e=A(I.image,!1,s.maxTextureSize);_e=Rt(I,_e);const Ne=r.convert(I.format,I.colorSpace),ke=r.convert(I.type);let Oe=b(I.internalFormat,Ne,ke,I.colorSpace,I.isVideoTexture);ye(le,I);let Te;const tt=I.mipmaps,We=I.isVideoTexture!==!0,nt=Ue.__version===void 0||Ae===!0,W=oe.dataReady,ne=M(I,_e);if(I.isDepthTexture)Oe=E(I.format===Ja,I.type),nt&&(We?t.texStorage2D(i.TEXTURE_2D,1,Oe,_e.width,_e.height):t.texImage2D(i.TEXTURE_2D,0,Oe,_e.width,_e.height,0,Ne,ke,null));else if(I.isDataTexture)if(tt.length>0){We&&nt&&t.texStorage2D(i.TEXTURE_2D,ne,Oe,tt[0].width,tt[0].height);for(let re=0,de=tt.length;re<de;re++)Te=tt[re],We?W&&t.texSubImage2D(i.TEXTURE_2D,re,0,0,Te.width,Te.height,Ne,ke,Te.data):t.texImage2D(i.TEXTURE_2D,re,Oe,Te.width,Te.height,0,Ne,ke,Te.data);I.generateMipmaps=!1}else We?(nt&&t.texStorage2D(i.TEXTURE_2D,ne,Oe,_e.width,_e.height),W&&t.texSubImage2D(i.TEXTURE_2D,0,0,0,_e.width,_e.height,Ne,ke,_e.data)):t.texImage2D(i.TEXTURE_2D,0,Oe,_e.width,_e.height,0,Ne,ke,_e.data);else if(I.isCompressedTexture)if(I.isCompressedArrayTexture){We&&nt&&t.texStorage3D(i.TEXTURE_2D_ARRAY,ne,Oe,tt[0].width,tt[0].height,_e.depth);for(let re=0,de=tt.length;re<de;re++)if(Te=tt[re],I.format!==sn)if(Ne!==null)if(We){if(W)if(I.layerUpdates.size>0){const Ie=qA(Te.width,Te.height,I.format,I.type);for(const Se of I.layerUpdates){const it=Te.data.subarray(Se*Ie/Te.data.BYTES_PER_ELEMENT,(Se+1)*Ie/Te.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,re,0,0,Se,Te.width,Te.height,1,Ne,it)}I.clearLayerUpdates()}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,re,0,0,0,Te.width,Te.height,_e.depth,Ne,Te.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,re,Oe,Te.width,Te.height,_e.depth,0,Te.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else We?W&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,re,0,0,0,Te.width,Te.height,_e.depth,Ne,ke,Te.data):t.texImage3D(i.TEXTURE_2D_ARRAY,re,Oe,Te.width,Te.height,_e.depth,0,Ne,ke,Te.data)}else{We&&nt&&t.texStorage2D(i.TEXTURE_2D,ne,Oe,tt[0].width,tt[0].height);for(let re=0,de=tt.length;re<de;re++)Te=tt[re],I.format!==sn?Ne!==null?We?W&&t.compressedTexSubImage2D(i.TEXTURE_2D,re,0,0,Te.width,Te.height,Ne,Te.data):t.compressedTexImage2D(i.TEXTURE_2D,re,Oe,Te.width,Te.height,0,Te.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):We?W&&t.texSubImage2D(i.TEXTURE_2D,re,0,0,Te.width,Te.height,Ne,ke,Te.data):t.texImage2D(i.TEXTURE_2D,re,Oe,Te.width,Te.height,0,Ne,ke,Te.data)}else if(I.isDataArrayTexture)if(We){if(nt&&t.texStorage3D(i.TEXTURE_2D_ARRAY,ne,Oe,_e.width,_e.height,_e.depth),W)if(I.layerUpdates.size>0){const re=qA(_e.width,_e.height,I.format,I.type);for(const de of I.layerUpdates){const Ie=_e.data.subarray(de*re/_e.data.BYTES_PER_ELEMENT,(de+1)*re/_e.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,de,_e.width,_e.height,1,Ne,ke,Ie)}I.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,_e.width,_e.height,_e.depth,Ne,ke,_e.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,Oe,_e.width,_e.height,_e.depth,0,Ne,ke,_e.data);else if(I.isData3DTexture)We?(nt&&t.texStorage3D(i.TEXTURE_3D,ne,Oe,_e.width,_e.height,_e.depth),W&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,_e.width,_e.height,_e.depth,Ne,ke,_e.data)):t.texImage3D(i.TEXTURE_3D,0,Oe,_e.width,_e.height,_e.depth,0,Ne,ke,_e.data);else if(I.isFramebufferTexture){if(nt)if(We)t.texStorage2D(i.TEXTURE_2D,ne,Oe,_e.width,_e.height);else{let re=_e.width,de=_e.height;for(let Ie=0;Ie<ne;Ie++)t.texImage2D(i.TEXTURE_2D,Ie,Oe,re,de,0,Ne,ke,null),re>>=1,de>>=1}}else if(tt.length>0){if(We&&nt){const re=Ge(tt[0]);t.texStorage2D(i.TEXTURE_2D,ne,Oe,re.width,re.height)}for(let re=0,de=tt.length;re<de;re++)Te=tt[re],We?W&&t.texSubImage2D(i.TEXTURE_2D,re,0,0,Ne,ke,Te):t.texImage2D(i.TEXTURE_2D,re,Oe,Ne,ke,Te);I.generateMipmaps=!1}else if(We){if(nt){const re=Ge(_e);t.texStorage2D(i.TEXTURE_2D,ne,Oe,re.width,re.height)}W&&t.texSubImage2D(i.TEXTURE_2D,0,0,0,Ne,ke,_e)}else t.texImage2D(i.TEXTURE_2D,0,Oe,Ne,ke,_e);g(I)&&p(le),Ue.__version=oe.version,I.onUpdate&&I.onUpdate(I)}L.__version=I.version}function me(L,I,Z){if(I.image.length!==6)return;const le=Me(L,I),Ae=I.source;t.bindTexture(i.TEXTURE_CUBE_MAP,L.__webglTexture,i.TEXTURE0+Z);const oe=n.get(Ae);if(Ae.version!==oe.__version||le===!0){t.activeTexture(i.TEXTURE0+Z);const Ue=At.getPrimaries(At.workingColorSpace),ve=I.colorSpace===li?null:At.getPrimaries(I.colorSpace),Ve=I.colorSpace===li||Ue===ve?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,I.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,I.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,I.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ve);const Ye=I.isCompressedTexture||I.image[0].isCompressedTexture,_e=I.image[0]&&I.image[0].isDataTexture,Ne=[];for(let de=0;de<6;de++)!Ye&&!_e?Ne[de]=A(I.image[de],!0,s.maxCubemapSize):Ne[de]=_e?I.image[de].image:I.image[de],Ne[de]=Rt(I,Ne[de]);const ke=Ne[0],Oe=r.convert(I.format,I.colorSpace),Te=r.convert(I.type),tt=b(I.internalFormat,Oe,Te,I.colorSpace),We=I.isVideoTexture!==!0,nt=oe.__version===void 0||le===!0,W=Ae.dataReady;let ne=M(I,ke);ye(i.TEXTURE_CUBE_MAP,I);let re;if(Ye){We&&nt&&t.texStorage2D(i.TEXTURE_CUBE_MAP,ne,tt,ke.width,ke.height);for(let de=0;de<6;de++){re=Ne[de].mipmaps;for(let Ie=0;Ie<re.length;Ie++){const Se=re[Ie];I.format!==sn?Oe!==null?We?W&&t.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+de,Ie,0,0,Se.width,Se.height,Oe,Se.data):t.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+de,Ie,tt,Se.width,Se.height,0,Se.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):We?W&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+de,Ie,0,0,Se.width,Se.height,Oe,Te,Se.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+de,Ie,tt,Se.width,Se.height,0,Oe,Te,Se.data)}}}else{if(re=I.mipmaps,We&&nt){re.length>0&&ne++;const de=Ge(Ne[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,ne,tt,de.width,de.height)}for(let de=0;de<6;de++)if(_e){We?W&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+de,0,0,0,Ne[de].width,Ne[de].height,Oe,Te,Ne[de].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+de,0,tt,Ne[de].width,Ne[de].height,0,Oe,Te,Ne[de].data);for(let Ie=0;Ie<re.length;Ie++){const it=re[Ie].image[de].image;We?W&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+de,Ie+1,0,0,it.width,it.height,Oe,Te,it.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+de,Ie+1,tt,it.width,it.height,0,Oe,Te,it.data)}}else{We?W&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+de,0,0,0,Oe,Te,Ne[de]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+de,0,tt,Oe,Te,Ne[de]);for(let Ie=0;Ie<re.length;Ie++){const Se=re[Ie];We?W&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+de,Ie+1,0,0,Oe,Te,Se.image[de]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+de,Ie+1,tt,Oe,Te,Se.image[de])}}}g(I)&&p(i.TEXTURE_CUBE_MAP),oe.__version=Ae.version,I.onUpdate&&I.onUpdate(I)}L.__version=I.version}function be(L,I,Z,le,Ae,oe){const Ue=r.convert(Z.format,Z.colorSpace),ve=r.convert(Z.type),Ve=b(Z.internalFormat,Ue,ve,Z.colorSpace),Ye=n.get(I),_e=n.get(Z);if(_e.__renderTarget=I,!Ye.__hasExternalTextures){const Ne=Math.max(1,I.width>>oe),ke=Math.max(1,I.height>>oe);Ae===i.TEXTURE_3D||Ae===i.TEXTURE_2D_ARRAY?t.texImage3D(Ae,oe,Ve,Ne,ke,I.depth,0,Ue,ve,null):t.texImage2D(Ae,oe,Ve,Ne,ke,0,Ue,ve,null)}t.bindFramebuffer(i.FRAMEBUFFER,L),pt(I)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,le,Ae,_e.__webglTexture,0,dt(I)):(Ae===i.TEXTURE_2D||Ae>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&Ae<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,le,Ae,_e.__webglTexture,oe),t.bindFramebuffer(i.FRAMEBUFFER,null)}function xe(L,I,Z){if(i.bindRenderbuffer(i.RENDERBUFFER,L),I.depthBuffer){const le=I.depthTexture,Ae=le&&le.isDepthTexture?le.type:null,oe=E(I.stencilBuffer,Ae),Ue=I.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ve=dt(I);pt(I)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,ve,oe,I.width,I.height):Z?i.renderbufferStorageMultisample(i.RENDERBUFFER,ve,oe,I.width,I.height):i.renderbufferStorage(i.RENDERBUFFER,oe,I.width,I.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,Ue,i.RENDERBUFFER,L)}else{const le=I.textures;for(let Ae=0;Ae<le.length;Ae++){const oe=le[Ae],Ue=r.convert(oe.format,oe.colorSpace),ve=r.convert(oe.type),Ve=b(oe.internalFormat,Ue,ve,oe.colorSpace),Ye=dt(I);Z&&pt(I)===!1?i.renderbufferStorageMultisample(i.RENDERBUFFER,Ye,Ve,I.width,I.height):pt(I)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,Ye,Ve,I.width,I.height):i.renderbufferStorage(i.RENDERBUFFER,Ve,I.width,I.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function Pe(L,I){if(I&&I.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(i.FRAMEBUFFER,L),!(I.depthTexture&&I.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const le=n.get(I.depthTexture);le.__renderTarget=I,(!le.__webglTexture||I.depthTexture.image.width!==I.width||I.depthTexture.image.height!==I.height)&&(I.depthTexture.image.width=I.width,I.depthTexture.image.height=I.height,I.depthTexture.needsUpdate=!0),D(I.depthTexture,0);const Ae=le.__webglTexture,oe=dt(I);if(I.depthTexture.format===Ya)pt(I)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,Ae,0,oe):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,Ae,0);else if(I.depthTexture.format===Ja)pt(I)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,Ae,0,oe):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,Ae,0);else throw new Error("Unknown depthTexture format")}function et(L){const I=n.get(L),Z=L.isWebGLCubeRenderTarget===!0;if(I.__boundDepthTexture!==L.depthTexture){const le=L.depthTexture;if(I.__depthDisposeCallback&&I.__depthDisposeCallback(),le){const Ae=()=>{delete I.__boundDepthTexture,delete I.__depthDisposeCallback,le.removeEventListener("dispose",Ae)};le.addEventListener("dispose",Ae),I.__depthDisposeCallback=Ae}I.__boundDepthTexture=le}if(L.depthTexture&&!I.__autoAllocateDepthBuffer){if(Z)throw new Error("target.depthTexture not supported in Cube render targets");const le=L.texture.mipmaps;le&&le.length>0?Pe(I.__webglFramebuffer[0],L):Pe(I.__webglFramebuffer,L)}else if(Z){I.__webglDepthbuffer=[];for(let le=0;le<6;le++)if(t.bindFramebuffer(i.FRAMEBUFFER,I.__webglFramebuffer[le]),I.__webglDepthbuffer[le]===void 0)I.__webglDepthbuffer[le]=i.createRenderbuffer(),xe(I.__webglDepthbuffer[le],L,!1);else{const Ae=L.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,oe=I.__webglDepthbuffer[le];i.bindRenderbuffer(i.RENDERBUFFER,oe),i.framebufferRenderbuffer(i.FRAMEBUFFER,Ae,i.RENDERBUFFER,oe)}}else{const le=L.texture.mipmaps;if(le&&le.length>0?t.bindFramebuffer(i.FRAMEBUFFER,I.__webglFramebuffer[0]):t.bindFramebuffer(i.FRAMEBUFFER,I.__webglFramebuffer),I.__webglDepthbuffer===void 0)I.__webglDepthbuffer=i.createRenderbuffer(),xe(I.__webglDepthbuffer,L,!1);else{const Ae=L.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,oe=I.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,oe),i.framebufferRenderbuffer(i.FRAMEBUFFER,Ae,i.RENDERBUFFER,oe)}}t.bindFramebuffer(i.FRAMEBUFFER,null)}function Qe(L,I,Z){const le=n.get(L);I!==void 0&&be(le.__webglFramebuffer,L,L.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),Z!==void 0&&et(L)}function St(L){const I=L.texture,Z=n.get(L),le=n.get(I);L.addEventListener("dispose",S);const Ae=L.textures,oe=L.isWebGLCubeRenderTarget===!0,Ue=Ae.length>1;if(Ue||(le.__webglTexture===void 0&&(le.__webglTexture=i.createTexture()),le.__version=I.version,a.memory.textures++),oe){Z.__webglFramebuffer=[];for(let ve=0;ve<6;ve++)if(I.mipmaps&&I.mipmaps.length>0){Z.__webglFramebuffer[ve]=[];for(let Ve=0;Ve<I.mipmaps.length;Ve++)Z.__webglFramebuffer[ve][Ve]=i.createFramebuffer()}else Z.__webglFramebuffer[ve]=i.createFramebuffer()}else{if(I.mipmaps&&I.mipmaps.length>0){Z.__webglFramebuffer=[];for(let ve=0;ve<I.mipmaps.length;ve++)Z.__webglFramebuffer[ve]=i.createFramebuffer()}else Z.__webglFramebuffer=i.createFramebuffer();if(Ue)for(let ve=0,Ve=Ae.length;ve<Ve;ve++){const Ye=n.get(Ae[ve]);Ye.__webglTexture===void 0&&(Ye.__webglTexture=i.createTexture(),a.memory.textures++)}if(L.samples>0&&pt(L)===!1){Z.__webglMultisampledFramebuffer=i.createFramebuffer(),Z.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,Z.__webglMultisampledFramebuffer);for(let ve=0;ve<Ae.length;ve++){const Ve=Ae[ve];Z.__webglColorRenderbuffer[ve]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,Z.__webglColorRenderbuffer[ve]);const Ye=r.convert(Ve.format,Ve.colorSpace),_e=r.convert(Ve.type),Ne=b(Ve.internalFormat,Ye,_e,Ve.colorSpace,L.isXRRenderTarget===!0),ke=dt(L);i.renderbufferStorageMultisample(i.RENDERBUFFER,ke,Ne,L.width,L.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+ve,i.RENDERBUFFER,Z.__webglColorRenderbuffer[ve])}i.bindRenderbuffer(i.RENDERBUFFER,null),L.depthBuffer&&(Z.__webglDepthRenderbuffer=i.createRenderbuffer(),xe(Z.__webglDepthRenderbuffer,L,!0)),t.bindFramebuffer(i.FRAMEBUFFER,null)}}if(oe){t.bindTexture(i.TEXTURE_CUBE_MAP,le.__webglTexture),ye(i.TEXTURE_CUBE_MAP,I);for(let ve=0;ve<6;ve++)if(I.mipmaps&&I.mipmaps.length>0)for(let Ve=0;Ve<I.mipmaps.length;Ve++)be(Z.__webglFramebuffer[ve][Ve],L,I,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+ve,Ve);else be(Z.__webglFramebuffer[ve],L,I,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+ve,0);g(I)&&p(i.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(Ue){for(let ve=0,Ve=Ae.length;ve<Ve;ve++){const Ye=Ae[ve],_e=n.get(Ye);t.bindTexture(i.TEXTURE_2D,_e.__webglTexture),ye(i.TEXTURE_2D,Ye),be(Z.__webglFramebuffer,L,Ye,i.COLOR_ATTACHMENT0+ve,i.TEXTURE_2D,0),g(Ye)&&p(i.TEXTURE_2D)}t.unbindTexture()}else{let ve=i.TEXTURE_2D;if((L.isWebGL3DRenderTarget||L.isWebGLArrayRenderTarget)&&(ve=L.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(ve,le.__webglTexture),ye(ve,I),I.mipmaps&&I.mipmaps.length>0)for(let Ve=0;Ve<I.mipmaps.length;Ve++)be(Z.__webglFramebuffer[Ve],L,I,i.COLOR_ATTACHMENT0,ve,Ve);else be(Z.__webglFramebuffer,L,I,i.COLOR_ATTACHMENT0,ve,0);g(I)&&p(ve),t.unbindTexture()}L.depthBuffer&&et(L)}function ut(L){const I=L.textures;for(let Z=0,le=I.length;Z<le;Z++){const Ae=I[Z];if(g(Ae)){const oe=y(L),Ue=n.get(Ae).__webglTexture;t.bindTexture(oe,Ue),p(oe),t.unbindTexture()}}}const Je=[],G=[];function mn(L){if(L.samples>0){if(pt(L)===!1){const I=L.textures,Z=L.width,le=L.height;let Ae=i.COLOR_BUFFER_BIT;const oe=L.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,Ue=n.get(L),ve=I.length>1;if(ve)for(let Ye=0;Ye<I.length;Ye++)t.bindFramebuffer(i.FRAMEBUFFER,Ue.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+Ye,i.RENDERBUFFER,null),t.bindFramebuffer(i.FRAMEBUFFER,Ue.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+Ye,i.TEXTURE_2D,null,0);t.bindFramebuffer(i.READ_FRAMEBUFFER,Ue.__webglMultisampledFramebuffer);const Ve=L.texture.mipmaps;Ve&&Ve.length>0?t.bindFramebuffer(i.DRAW_FRAMEBUFFER,Ue.__webglFramebuffer[0]):t.bindFramebuffer(i.DRAW_FRAMEBUFFER,Ue.__webglFramebuffer);for(let Ye=0;Ye<I.length;Ye++){if(L.resolveDepthBuffer&&(L.depthBuffer&&(Ae|=i.DEPTH_BUFFER_BIT),L.stencilBuffer&&L.resolveStencilBuffer&&(Ae|=i.STENCIL_BUFFER_BIT)),ve){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,Ue.__webglColorRenderbuffer[Ye]);const _e=n.get(I[Ye]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,_e,0)}i.blitFramebuffer(0,0,Z,le,0,0,Z,le,Ae,i.NEAREST),c===!0&&(Je.length=0,G.length=0,Je.push(i.COLOR_ATTACHMENT0+Ye),L.depthBuffer&&L.resolveDepthBuffer===!1&&(Je.push(oe),G.push(oe),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,G)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,Je))}if(t.bindFramebuffer(i.READ_FRAMEBUFFER,null),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),ve)for(let Ye=0;Ye<I.length;Ye++){t.bindFramebuffer(i.FRAMEBUFFER,Ue.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+Ye,i.RENDERBUFFER,Ue.__webglColorRenderbuffer[Ye]);const _e=n.get(I[Ye]).__webglTexture;t.bindFramebuffer(i.FRAMEBUFFER,Ue.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+Ye,i.TEXTURE_2D,_e,0)}t.bindFramebuffer(i.DRAW_FRAMEBUFFER,Ue.__webglMultisampledFramebuffer)}else if(L.depthBuffer&&L.resolveDepthBuffer===!1&&c){const I=L.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[I])}}}function dt(L){return Math.min(s.maxSamples,L.samples)}function pt(L){const I=n.get(L);return L.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&I.__useRenderToTexture!==!1}function ze(L){const I=a.render.frame;h.get(L)!==I&&(h.set(L,I),L.update())}function Rt(L,I){const Z=L.colorSpace,le=L.format,Ae=L.type;return L.isCompressedTexture===!0||L.isVideoTexture===!0||Z!==rn&&Z!==li&&(At.getTransfer(Z)===Mt?(le!==sn||Ae!==tn)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",Z)),I}function Ge(L){return typeof HTMLImageElement<"u"&&L instanceof HTMLImageElement?(l.width=L.naturalWidth||L.width,l.height=L.naturalHeight||L.height):typeof VideoFrame<"u"&&L instanceof VideoFrame?(l.width=L.displayWidth,l.height=L.displayHeight):(l.width=L.width,l.height=L.height),l}this.allocateTextureUnit=q,this.resetTextureUnits=K,this.setTexture2D=D,this.setTexture2DArray=O,this.setTexture3D=Y,this.setTextureCube=Q,this.rebindTextures=Qe,this.setupRenderTarget=St,this.updateRenderTargetMipmap=ut,this.updateMultisampleRenderTarget=mn,this.setupDepthRenderbuffer=et,this.setupFrameBufferTexture=be,this.useMultisampledRTT=pt}function nI(i,e){function t(n,s=li){let r;const a=At.getTransfer(s);if(n===tn)return i.UNSIGNED_BYTE;if(n===Lh)return i.UNSIGNED_SHORT_4_4_4_4;if(n===Ph)return i.UNSIGNED_SHORT_5_5_5_1;if(n===Mp)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===Sp)return i.BYTE;if(n===Ip)return i.SHORT;if(n===ja)return i.UNSIGNED_SHORT;if(n===Dh)return i.INT;if(n===Js)return i.UNSIGNED_INT;if(n===nn)return i.FLOAT;if(n===Bn)return i.HALF_FLOAT;if(n===Bp)return i.ALPHA;if(n===Tp)return i.RGB;if(n===sn)return i.RGBA;if(n===Ya)return i.DEPTH_COMPONENT;if(n===Ja)return i.DEPTH_STENCIL;if(n===zi)return i.RED;if(n===kh)return i.RED_INTEGER;if(n===Zs)return i.RG;if(n===Uh)return i.RG_INTEGER;if(n===Oh)return i.RGBA_INTEGER;if(n===gc||n===Za||n===mc||n===$a)if(a===Mt)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===gc)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Za)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===mc)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===$a)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===gc)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Za)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===mc)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===$a)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===bc||n===Qh||n===xc||n===Gh)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===bc)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Qh)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===xc)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Gh)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===_c||n===Ec||n===yc)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(n===_c||n===Ec)return a===Mt?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===yc)return a===Mt?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===eo||n===Hh||n===zh||n===Vh||n===to||n===Wh||n===qh||n===Kh||n===jh||n===Xh||n===Yh||n===Jh||n===Zh||n===$h)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(n===eo)return a===Mt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Hh)return a===Mt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===zh)return a===Mt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Vh)return a===Mt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===to)return a===Mt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Wh)return a===Mt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===qh)return a===Mt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Kh)return a===Mt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===jh)return a===Mt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Xh)return a===Mt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Yh)return a===Mt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Jh)return a===Mt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Zh)return a===Mt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===$h)return a===Mt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===no||n===eu||n===wc)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(n===no)return a===Mt?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===eu)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===wc)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===Rp||n===tu||n===nu||n===iu)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(n===no)return r.COMPRESSED_RED_RGTC1_EXT;if(n===tu)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===nu)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===iu)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Xa?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}const iI=`+void main() {++ gl_Position = vec4( position, 1.0 );++}`,sI=`+uniform sampler2DArray depthColor;+uniform float depthWidth;+uniform float depthHeight;++void main() {++ vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );++ if ( coord.x >= 1.0 ) {++ gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;++ } else {++ gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;++ }++}`;class rI{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,n){if(this.texture===null){const s=new an,r=e.properties.get(s);r.__webglTexture=t.texture,(t.depthNear!==n.depthNear||t.depthFar!==n.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=s}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,n=new Is({vertexShader:iI,fragmentShader:sI,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Jt(new nl(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class aI extends _s{constructor(e,t){super();const n=this;let s=null,r=1,a=null,o="local-floor",c=1,l=null,h=null,u=null,d=null,f=null,m=null;const A=new rI,g=t.getContextAttributes();let p=null,y=null;const b=[],E=[],M=new Ze;let w=null;const S=new Cn;S.viewport=new Et;const T=new Cn;T.viewport=new Et;const C=[S,T],v=new qy;let F=null,K=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(se){let me=b[se];return me===void 0&&(me=new Bu,b[se]=me),me.getTargetRaySpace()},this.getControllerGrip=function(se){let me=b[se];return me===void 0&&(me=new Bu,b[se]=me),me.getGripSpace()},this.getHand=function(se){let me=b[se];return me===void 0&&(me=new Bu,b[se]=me),me.getHandSpace()};function q(se){const me=E.indexOf(se.inputSource);if(me===-1)return;const be=b[me];be!==void 0&&(be.update(se.inputSource,se.frame,l||a),be.dispatchEvent({type:se.type,data:se.inputSource}))}function $(){s.removeEventListener("select",q),s.removeEventListener("selectstart",q),s.removeEventListener("selectend",q),s.removeEventListener("squeeze",q),s.removeEventListener("squeezestart",q),s.removeEventListener("squeezeend",q),s.removeEventListener("end",$),s.removeEventListener("inputsourceschange",D);for(let se=0;se<b.length;se++){const me=E[se];me!==null&&(E[se]=null,b[se].disconnect(me))}F=null,K=null,A.reset(),e.setRenderTarget(p),f=null,d=null,u=null,s=null,y=null,Me.stop(),n.isPresenting=!1,e.setPixelRatio(w),e.setSize(M.width,M.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(se){r=se,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(se){o=se,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(se){l=se},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){return u},this.getFrame=function(){return m},this.getSession=function(){return s},this.setSession=async function(se){if(s=se,s!==null){if(p=e.getRenderTarget(),s.addEventListener("select",q),s.addEventListener("selectstart",q),s.addEventListener("selectend",q),s.addEventListener("squeeze",q),s.addEventListener("squeezestart",q),s.addEventListener("squeezeend",q),s.addEventListener("end",$),s.addEventListener("inputsourceschange",D),g.xrCompatible!==!0&&await t.makeXRCompatible(),w=e.getPixelRatio(),e.getSize(M),typeof XRWebGLBinding<"u"&&"createProjectionLayer"in XRWebGLBinding.prototype){let be=null,xe=null,Pe=null;g.depth&&(Pe=g.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,be=g.stencil?Ja:Ya,xe=g.stencil?Xa:Js);const et={colorFormat:t.RGBA8,depthFormat:Pe,scaleFactor:r};u=new XRWebGLBinding(s,t),d=u.createProjectionLayer(et),s.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),y=new $s(d.textureWidth,d.textureHeight,{format:sn,type:tn,depthTexture:new RA(d.textureWidth,d.textureHeight,xe,void 0,void 0,void 0,void 0,void 0,void 0,be),stencilBuffer:g.stencil,colorSpace:e.outputColorSpace,samples:g.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}else{const be={antialias:g.antialias,alpha:!0,depth:g.depth,stencil:g.stencil,framebufferScaleFactor:r};f=new XRWebGLLayer(s,t,be),s.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),y=new $s(f.framebufferWidth,f.framebufferHeight,{format:sn,type:tn,colorSpace:e.outputColorSpace,stencilBuffer:g.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}y.isXRRenderTarget=!0,this.setFoveation(c),l=null,a=await s.requestReferenceSpace(o),Me.setContext(s),Me.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(s!==null)return s.environmentBlendMode},this.getDepthTexture=function(){return A.getDepthTexture()};function D(se){for(let me=0;me<se.removed.length;me++){const be=se.removed[me],xe=E.indexOf(be);xe>=0&&(E[xe]=null,b[xe].disconnect(be))}for(let me=0;me<se.added.length;me++){const be=se.added[me];let xe=E.indexOf(be);if(xe===-1){for(let et=0;et<b.length;et++)if(et>=E.length){E.push(be),xe=et;break}else if(E[et]===null){E[et]=be,xe=et;break}if(xe===-1)break}const Pe=b[xe];Pe&&Pe.connect(be)}}const O=new H,Y=new H;function Q(se,me,be){O.setFromMatrixPosition(me.matrixWorld),Y.setFromMatrixPosition(be.matrixWorld);const xe=O.distanceTo(Y),Pe=me.projectionMatrix.elements,et=be.projectionMatrix.elements,Qe=Pe[14]/(Pe[10]-1),St=Pe[14]/(Pe[10]+1),ut=(Pe[9]+1)/Pe[5],Je=(Pe[9]-1)/Pe[5],G=(Pe[8]-1)/Pe[0],mn=(et[8]+1)/et[0],dt=Qe*G,pt=Qe*mn,ze=xe/(-G+mn),Rt=ze*-G;if(me.matrixWorld.decompose(se.position,se.quaternion,se.scale),se.translateX(Rt),se.translateZ(ze),se.matrixWorld.compose(se.position,se.quaternion,se.scale),se.matrixWorldInverse.copy(se.matrixWorld).invert(),Pe[10]===-1)se.projectionMatrix.copy(me.projectionMatrix),se.projectionMatrixInverse.copy(me.projectionMatrixInverse);else{const Ge=Qe+ze,L=St+ze,I=dt-Rt,Z=pt+(xe-Rt),le=ut*St/L*Ge,Ae=Je*St/L*Ge;se.projectionMatrix.makePerspective(I,Z,le,Ae,Ge,L),se.projectionMatrixInverse.copy(se.projectionMatrix).invert()}}function J(se,me){me===null?se.matrixWorld.copy(se.matrix):se.matrixWorld.multiplyMatrices(me.matrixWorld,se.matrix),se.matrixWorldInverse.copy(se.matrixWorld).invert()}this.updateCamera=function(se){if(s===null)return;let me=se.near,be=se.far;A.texture!==null&&(A.depthNear>0&&(me=A.depthNear),A.depthFar>0&&(be=A.depthFar)),v.near=T.near=S.near=me,v.far=T.far=S.far=be,(F!==v.near||K!==v.far)&&(s.updateRenderState({depthNear:v.near,depthFar:v.far}),F=v.near,K=v.far),S.layers.mask=se.layers.mask|2,T.layers.mask=se.layers.mask|4,v.layers.mask=S.layers.mask|T.layers.mask;const xe=se.parent,Pe=v.cameras;J(v,xe);for(let et=0;et<Pe.length;et++)J(Pe[et],xe);Pe.length===2?Q(v,S,T):v.projectionMatrix.copy(S.projectionMatrix),ee(se,v,xe)};function ee(se,me,be){be===null?se.matrix.copy(me.matrixWorld):(se.matrix.copy(be.matrixWorld),se.matrix.invert(),se.matrix.multiply(me.matrixWorld)),se.matrix.decompose(se.position,se.quaternion,se.scale),se.updateMatrixWorld(!0),se.projectionMatrix.copy(me.projectionMatrix),se.projectionMatrixInverse.copy(me.projectionMatrixInverse),se.isPerspectiveCamera&&(se.fov=Vr*2*Math.atan(1/se.projectionMatrix.elements[5]),se.zoom=1)}this.getCamera=function(){return v},this.getFoveation=function(){if(!(d===null&&f===null))return c},this.setFoveation=function(se){c=se,d!==null&&(d.fixedFoveation=se),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=se)},this.hasDepthSensing=function(){return A.texture!==null},this.getDepthSensingMesh=function(){return A.getMesh(v)};let ae=null;function ye(se,me){if(h=me.getViewerPose(l||a),m=me,h!==null){const be=h.views;f!==null&&(e.setRenderTargetFramebuffer(y,f.framebuffer),e.setRenderTarget(y));let xe=!1;be.length!==v.cameras.length&&(v.cameras.length=0,xe=!0);for(let Qe=0;Qe<be.length;Qe++){const St=be[Qe];let ut=null;if(f!==null)ut=f.getViewport(St);else{const G=u.getViewSubImage(d,St);ut=G.viewport,Qe===0&&(e.setRenderTargetTextures(y,G.colorTexture,G.depthStencilTexture),e.setRenderTarget(y))}let Je=C[Qe];Je===void 0&&(Je=new Cn,Je.layers.enable(Qe),Je.viewport=new Et,C[Qe]=Je),Je.matrix.fromArray(St.transform.matrix),Je.matrix.decompose(Je.position,Je.quaternion,Je.scale),Je.projectionMatrix.fromArray(St.projectionMatrix),Je.projectionMatrixInverse.copy(Je.projectionMatrix).invert(),Je.viewport.set(ut.x,ut.y,ut.width,ut.height),Qe===0&&(v.matrix.copy(Je.matrix),v.matrix.decompose(v.position,v.quaternion,v.scale)),xe===!0&&v.cameras.push(Je)}const Pe=s.enabledFeatures;if(Pe&&Pe.includes("depth-sensing")&&s.depthUsage=="gpu-optimized"&&u){const Qe=u.getDepthInformation(be[0]);Qe&&Qe.isValid&&Qe.texture&&A.init(e,Qe,s.renderState)}}for(let be=0;be<b.length;be++){const xe=E[be],Pe=b[be];xe!==null&&Pe!==void 0&&Pe.update(xe,me,l||a)}ae&&ae(se,me),me.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:me}),m=null}const Me=new KA;Me.setAnimationLoop(ye),this.setAnimationLoop=function(se){ae=se},this.dispose=function(){}}}const cr=new Ri,oI=new $e;function cI(i,e){function t(g,p){g.matrixAutoUpdate===!0&&g.updateMatrix(),p.value.copy(g.matrix)}function n(g,p){p.color.getRGB(g.fogColor.value,hA(i)),p.isFog?(g.fogNear.value=p.near,g.fogFar.value=p.far):p.isFogExp2&&(g.fogDensity.value=p.density)}function s(g,p,y,b,E){p.isMeshBasicMaterial||p.isMeshLambertMaterial?r(g,p):p.isMeshToonMaterial?(r(g,p),u(g,p)):p.isMeshPhongMaterial?(r(g,p),h(g,p)):p.isMeshStandardMaterial?(r(g,p),d(g,p),p.isMeshPhysicalMaterial&&f(g,p,E)):p.isMeshMatcapMaterial?(r(g,p),m(g,p)):p.isMeshDepthMaterial?r(g,p):p.isMeshDistanceMaterial?(r(g,p),A(g,p)):p.isMeshNormalMaterial?r(g,p):p.isLineBasicMaterial?(a(g,p),p.isLineDashedMaterial&&o(g,p)):p.isPointsMaterial?c(g,p,y,b):p.isSpriteMaterial?l(g,p):p.isShadowMaterial?(g.color.value.copy(p.color),g.opacity.value=p.opacity):p.isShaderMaterial&&(p.uniformsNeedUpdate=!1)}function r(g,p){g.opacity.value=p.opacity,p.color&&g.diffuse.value.copy(p.color),p.emissive&&g.emissive.value.copy(p.emissive).multiplyScalar(p.emissiveIntensity),p.map&&(g.map.value=p.map,t(p.map,g.mapTransform)),p.alphaMap&&(g.alphaMap.value=p.alphaMap,t(p.alphaMap,g.alphaMapTransform)),p.bumpMap&&(g.bumpMap.value=p.bumpMap,t(p.bumpMap,g.bumpMapTransform),g.bumpScale.value=p.bumpScale,p.side===In&&(g.bumpScale.value*=-1)),p.normalMap&&(g.normalMap.value=p.normalMap,t(p.normalMap,g.normalMapTransform),g.normalScale.value.copy(p.normalScale),p.side===In&&g.normalScale.value.negate()),p.displacementMap&&(g.displacementMap.value=p.displacementMap,t(p.displacementMap,g.displacementMapTransform),g.displacementScale.value=p.displacementScale,g.displacementBias.value=p.displacementBias),p.emissiveMap&&(g.emissiveMap.value=p.emissiveMap,t(p.emissiveMap,g.emissiveMapTransform)),p.specularMap&&(g.specularMap.value=p.specularMap,t(p.specularMap,g.specularMapTransform)),p.alphaTest>0&&(g.alphaTest.value=p.alphaTest);const y=e.get(p),b=y.envMap,E=y.envMapRotation;b&&(g.envMap.value=b,cr.copy(E),cr.x*=-1,cr.y*=-1,cr.z*=-1,b.isCubeTexture&&b.isRenderTargetTexture===!1&&(cr.y*=-1,cr.z*=-1),g.envMapRotation.value.setFromMatrix4(oI.makeRotationFromEuler(cr)),g.flipEnvMap.value=b.isCubeTexture&&b.isRenderTargetTexture===!1?-1:1,g.reflectivity.value=p.reflectivity,g.ior.value=p.ior,g.refractionRatio.value=p.refractionRatio),p.lightMap&&(g.lightMap.value=p.lightMap,g.lightMapIntensity.value=p.lightMapIntensity,t(p.lightMap,g.lightMapTransform)),p.aoMap&&(g.aoMap.value=p.aoMap,g.aoMapIntensity.value=p.aoMapIntensity,t(p.aoMap,g.aoMapTransform))}function a(g,p){g.diffuse.value.copy(p.color),g.opacity.value=p.opacity,p.map&&(g.map.value=p.map,t(p.map,g.mapTransform))}function o(g,p){g.dashSize.value=p.dashSize,g.totalSize.value=p.dashSize+p.gapSize,g.scale.value=p.scale}function c(g,p,y,b){g.diffuse.value.copy(p.color),g.opacity.value=p.opacity,g.size.value=p.size*y,g.scale.value=b*.5,p.map&&(g.map.value=p.map,t(p.map,g.uvTransform)),p.alphaMap&&(g.alphaMap.value=p.alphaMap,t(p.alphaMap,g.alphaMapTransform)),p.alphaTest>0&&(g.alphaTest.value=p.alphaTest)}function l(g,p){g.diffuse.value.copy(p.color),g.opacity.value=p.opacity,g.rotation.value=p.rotation,p.map&&(g.map.value=p.map,t(p.map,g.mapTransform)),p.alphaMap&&(g.alphaMap.value=p.alphaMap,t(p.alphaMap,g.alphaMapTransform)),p.alphaTest>0&&(g.alphaTest.value=p.alphaTest)}function h(g,p){g.specular.value.copy(p.specular),g.shininess.value=Math.max(p.shininess,1e-4)}function u(g,p){p.gradientMap&&(g.gradientMap.value=p.gradientMap)}function d(g,p){g.metalness.value=p.metalness,p.metalnessMap&&(g.metalnessMap.value=p.metalnessMap,t(p.metalnessMap,g.metalnessMapTransform)),g.roughness.value=p.roughness,p.roughnessMap&&(g.roughnessMap.value=p.roughnessMap,t(p.roughnessMap,g.roughnessMapTransform)),p.envMap&&(g.envMapIntensity.value=p.envMapIntensity)}function f(g,p,y){g.ior.value=p.ior,p.sheen>0&&(g.sheenColor.value.copy(p.sheenColor).multiplyScalar(p.sheen),g.sheenRoughness.value=p.sheenRoughness,p.sheenColorMap&&(g.sheenColorMap.value=p.sheenColorMap,t(p.sheenColorMap,g.sheenColorMapTransform)),p.sheenRoughnessMap&&(g.sheenRoughnessMap.value=p.sheenRoughnessMap,t(p.sheenRoughnessMap,g.sheenRoughnessMapTransform))),p.clearcoat>0&&(g.clearcoat.value=p.clearcoat,g.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap&&(g.clearcoatMap.value=p.clearcoatMap,t(p.clearcoatMap,g.clearcoatMapTransform)),p.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,t(p.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform)),p.clearcoatNormalMap&&(g.clearcoatNormalMap.value=p.clearcoatNormalMap,t(p.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===In&&g.clearcoatNormalScale.value.negate())),p.dispersion>0&&(g.dispersion.value=p.dispersion),p.iridescence>0&&(g.iridescence.value=p.iridescence,g.iridescenceIOR.value=p.iridescenceIOR,g.iridescenceThicknessMinimum.value=p.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=p.iridescenceThicknessRange[1],p.iridescenceMap&&(g.iridescenceMap.value=p.iridescenceMap,t(p.iridescenceMap,g.iridescenceMapTransform)),p.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=p.iridescenceThicknessMap,t(p.iridescenceThicknessMap,g.iridescenceThicknessMapTransform))),p.transmission>0&&(g.transmission.value=p.transmission,g.transmissionSamplerMap.value=y.texture,g.transmissionSamplerSize.value.set(y.width,y.height),p.transmissionMap&&(g.transmissionMap.value=p.transmissionMap,t(p.transmissionMap,g.transmissionMapTransform)),g.thickness.value=p.thickness,p.thicknessMap&&(g.thicknessMap.value=p.thicknessMap,t(p.thicknessMap,g.thicknessMapTransform)),g.attenuationDistance.value=p.attenuationDistance,g.attenuationColor.value.copy(p.attenuationColor)),p.anisotropy>0&&(g.anisotropyVector.value.set(p.anisotropy*Math.cos(p.anisotropyRotation),p.anisotropy*Math.sin(p.anisotropyRotation)),p.anisotropyMap&&(g.anisotropyMap.value=p.anisotropyMap,t(p.anisotropyMap,g.anisotropyMapTransform))),g.specularIntensity.value=p.specularIntensity,g.specularColor.value.copy(p.specularColor),p.specularColorMap&&(g.specularColorMap.value=p.specularColorMap,t(p.specularColorMap,g.specularColorMapTransform)),p.specularIntensityMap&&(g.specularIntensityMap.value=p.specularIntensityMap,t(p.specularIntensityMap,g.specularIntensityMapTransform))}function m(g,p){p.matcap&&(g.matcap.value=p.matcap)}function A(g,p){const y=e.get(p).light;g.referencePosition.value.setFromMatrixPosition(y.matrixWorld),g.nearDistance.value=y.shadow.camera.near,g.farDistance.value=y.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function lI(i,e,t,n){let s={},r={},a=[];const o=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function c(y,b){const E=b.program;n.uniformBlockBinding(y,E)}function l(y,b){let E=s[y.id];E===void 0&&(m(y),E=h(y),s[y.id]=E,y.addEventListener("dispose",g));const M=b.program;n.updateUBOMapping(y,M);const w=e.render.frame;r[y.id]!==w&&(d(y),r[y.id]=w)}function h(y){const b=u();y.__bindingPointIndex=b;const E=i.createBuffer(),M=y.__size,w=y.usage;return i.bindBuffer(i.UNIFORM_BUFFER,E),i.bufferData(i.UNIFORM_BUFFER,M,w),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,b,E),E}function u(){for(let y=0;y<o;y++)if(a.indexOf(y)===-1)return a.push(y),y;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(y){const b=s[y.id],E=y.uniforms,M=y.__cache;i.bindBuffer(i.UNIFORM_BUFFER,b);for(let w=0,S=E.length;w<S;w++){const T=Array.isArray(E[w])?E[w]:[E[w]];for(let C=0,v=T.length;C<v;C++){const F=T[C];if(f(F,w,C,M)===!0){const K=F.__offset,q=Array.isArray(F.value)?F.value:[F.value];let $=0;for(let D=0;D<q.length;D++){const O=q[D],Y=A(O);typeof O=="number"||typeof O=="boolean"?(F.__data[0]=O,i.bufferSubData(i.UNIFORM_BUFFER,K+$,F.__data)):O.isMatrix3?(F.__data[0]=O.elements[0],F.__data[1]=O.elements[1],F.__data[2]=O.elements[2],F.__data[3]=0,F.__data[4]=O.elements[3],F.__data[5]=O.elements[4],F.__data[6]=O.elements[5],F.__data[7]=0,F.__data[8]=O.elements[6],F.__data[9]=O.elements[7],F.__data[10]=O.elements[8],F.__data[11]=0):(O.toArray(F.__data,$),$+=Y.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(i.UNIFORM_BUFFER,K,F.__data)}}}i.bindBuffer(i.UNIFORM_BUFFER,null)}function f(y,b,E,M){const w=y.value,S=b+"_"+E;if(M[S]===void 0)return typeof w=="number"||typeof w=="boolean"?M[S]=w:M[S]=w.clone(),!0;{const T=M[S];if(typeof w=="number"||typeof w=="boolean"){if(T!==w)return M[S]=w,!0}else if(T.equals(w)===!1)return T.copy(w),!0}return!1}function m(y){const b=y.uniforms;let E=0;const M=16;for(let S=0,T=b.length;S<T;S++){const C=Array.isArray(b[S])?b[S]:[b[S]];for(let v=0,F=C.length;v<F;v++){const K=C[v],q=Array.isArray(K.value)?K.value:[K.value];for(let $=0,D=q.length;$<D;$++){const O=q[$],Y=A(O),Q=E%M,J=Q%Y.boundary,ee=Q+J;E+=J,ee!==0&&M-ee<Y.storage&&(E+=M-ee),K.__data=new Float32Array(Y.storage/Float32Array.BYTES_PER_ELEMENT),K.__offset=E,E+=Y.storage}}}const w=E%M;return w>0&&(E+=M-w),y.__size=E,y.__cache={},this}function A(y){const b={boundary:0,storage:0};return typeof y=="number"||typeof y=="boolean"?(b.boundary=4,b.storage=4):y.isVector2?(b.boundary=8,b.storage=8):y.isVector3||y.isColor?(b.boundary=16,b.storage=12):y.isVector4?(b.boundary=16,b.storage=16):y.isMatrix3?(b.boundary=48,b.storage=48):y.isMatrix4?(b.boundary=64,b.storage=64):y.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",y),b}function g(y){const b=y.target;b.removeEventListener("dispose",g);const E=a.indexOf(b.__bindingPointIndex);a.splice(E,1),i.deleteBuffer(s[b.id]),delete s[b.id],delete r[b.id]}function p(){for(const y in s)i.deleteBuffer(s[y]);a=[],s={},r={}}return{bind:c,update:l,dispose:p}}class Eg{constructor(e={}){const{canvas:t=UE(),context:n=null,depth:s=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1,reverseDepthBuffer:d=!1}=e;this.isWebGLRenderer=!0;let f;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");f=n.getContextAttributes().alpha}else f=a;const m=new Uint32Array(4),A=new Int32Array(4);let g=null,p=null;const y=[],b=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=xs,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const E=this;let M=!1;this._outputColorSpace=Kt;let w=0,S=0,T=null,C=-1,v=null;const F=new Et,K=new Et;let q=null;const $=new qe(0);let D=0,O=t.width,Y=t.height,Q=1,J=null,ee=null;const ae=new Et(0,0,O,Y),ye=new Et(0,0,O,Y);let Me=!1;const se=new ku;let me=!1,be=!1;const xe=new $e,Pe=new $e,et=new H,Qe=new Et,St={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let ut=!1;function Je(){return T===null?Q:1}let G=n;function mn(_,R){return t.getContext(_,R)}try{const _={alpha:!0,depth:s,stencil:r,antialias:o,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${dc}`),t.addEventListener("webglcontextlost",de,!1),t.addEventListener("webglcontextrestored",Ie,!1),t.addEventListener("webglcontextcreationerror",Se,!1),G===null){const R="webgl2";if(G=mn(R,_),G===null)throw mn(R)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(_){throw console.error("THREE.WebGLRenderer: "+_.message),_}let dt,pt,ze,Rt,Ge,L,I,Z,le,Ae,oe,Ue,ve,Ve,Ye,_e,Ne,ke,Oe,Te,tt,We,nt,W;function ne(){dt=new _C(G),dt.init(),We=new nI(G,dt),pt=new fC(G,dt,e,We),ze=new eI(G,dt),pt.reverseDepthBuffer&&d&&ze.buffers.depth.setReversed(!0),Rt=new wC(G),Ge=new GS,L=new tI(G,dt,ze,Ge,pt,We,Rt),I=new AC(E),Z=new xC(E),le=new lw(G),nt=new uC(G,le),Ae=new EC(G,le,Rt,nt),oe=new CC(G,Ae,le,Rt),Oe=new vC(G,pt,L),_e=new pC(Ge),Ue=new QS(E,I,Z,dt,pt,nt,_e),ve=new cI(E,Ge),Ve=new zS,Ye=new XS(dt),ke=new hC(E,I,Z,ze,oe,f,c),Ne=new ZS(E,oe,pt),W=new lI(G,Rt,pt,ze),Te=new dC(G,dt,Rt),tt=new yC(G,dt,Rt),Rt.programs=Ue.programs,E.capabilities=pt,E.extensions=dt,E.properties=Ge,E.renderLists=Ve,E.shadowMap=Ne,E.state=ze,E.info=Rt}ne();const re=new aI(E,G);this.xr=re,this.getContext=function(){return G},this.getContextAttributes=function(){return G.getContextAttributes()},this.forceContextLoss=function(){const _=dt.get("WEBGL_lose_context");_&&_.loseContext()},this.forceContextRestore=function(){const _=dt.get("WEBGL_lose_context");_&&_.restoreContext()},this.getPixelRatio=function(){return Q},this.setPixelRatio=function(_){_!==void 0&&(Q=_,this.setSize(O,Y,!1))},this.getSize=function(_){return _.set(O,Y)},this.setSize=function(_,R,N=!0){if(re.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}O=_,Y=R,t.width=Math.floor(_*Q),t.height=Math.floor(R*Q),N===!0&&(t.style.width=_+"px",t.style.height=R+"px"),this.setViewport(0,0,_,R)},this.getDrawingBufferSize=function(_){return _.set(O*Q,Y*Q).floor()},this.setDrawingBufferSize=function(_,R,N){O=_,Y=R,Q=N,t.width=Math.floor(_*N),t.height=Math.floor(R*N),this.setViewport(0,0,_,R)},this.getCurrentViewport=function(_){return _.copy(F)},this.getViewport=function(_){return _.copy(ae)},this.setViewport=function(_,R,N,U){_.isVector4?ae.set(_.x,_.y,_.z,_.w):ae.set(_,R,N,U),ze.viewport(F.copy(ae).multiplyScalar(Q).round())},this.getScissor=function(_){return _.copy(ye)},this.setScissor=function(_,R,N,U){_.isVector4?ye.set(_.x,_.y,_.z,_.w):ye.set(_,R,N,U),ze.scissor(K.copy(ye).multiplyScalar(Q).round())},this.getScissorTest=function(){return Me},this.setScissorTest=function(_){ze.setScissorTest(Me=_)},this.setOpaqueSort=function(_){J=_},this.setTransparentSort=function(_){ee=_},this.getClearColor=function(_){return _.copy(ke.getClearColor())},this.setClearColor=function(){ke.setClearColor(...arguments)},this.getClearAlpha=function(){return ke.getClearAlpha()},this.setClearAlpha=function(){ke.setClearAlpha(...arguments)},this.clear=function(_=!0,R=!0,N=!0){let U=0;if(_){let P=!1;if(T!==null){const z=T.texture.format;P=z===Oh||z===Uh||z===kh}if(P){const z=T.texture.type,j=z===tn||z===Js||z===ja||z===Xa||z===Lh||z===Ph,X=ke.getClearColor(),ie=ke.getClearAlpha(),he=X.r,ce=X.g,fe=X.b;j?(m[0]=he,m[1]=ce,m[2]=fe,m[3]=ie,G.clearBufferuiv(G.COLOR,0,m)):(A[0]=he,A[1]=ce,A[2]=fe,A[3]=ie,G.clearBufferiv(G.COLOR,0,A))}else U|=G.COLOR_BUFFER_BIT}R&&(U|=G.DEPTH_BUFFER_BIT),N&&(U|=G.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),G.clear(U)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",de,!1),t.removeEventListener("webglcontextrestored",Ie,!1),t.removeEventListener("webglcontextcreationerror",Se,!1),ke.dispose(),Ve.dispose(),Ye.dispose(),Ge.dispose(),I.dispose(),Z.dispose(),oe.dispose(),nt.dispose(),W.dispose(),Ue.dispose(),re.dispose(),re.removeEventListener("sessionstart",bh),re.removeEventListener("sessionend",xh),gs.stop()};function de(_){_.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),M=!0}function Ie(){console.log("THREE.WebGLRenderer: Context Restored."),M=!1;const _=Rt.autoReset,R=Ne.enabled,N=Ne.autoUpdate,U=Ne.needsUpdate,P=Ne.type;ne(),Rt.autoReset=_,Ne.enabled=R,Ne.autoUpdate=N,Ne.needsUpdate=U,Ne.type=P}function Se(_){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",_.statusMessage)}function it(_){const R=_.target;R.removeEventListener("dispose",it),Qt(R)}function Qt(_){bn(_),Ge.remove(_)}function bn(_){const R=Ge.get(_).programs;R!==void 0&&(R.forEach(function(N){Ue.releaseProgram(N)}),_.isShaderMaterial&&Ue.releaseShaderCache(_))}this.renderBufferDirect=function(_,R,N,U,P,z){R===null&&(R=St);const j=P.isMesh&&P.matrixWorld.determinant()<0,X=pp(_,R,N,U,P);ze.setMaterial(U,j);let ie=N.index,he=1;if(U.wireframe===!0){if(ie=Ae.getWireframeAttribute(N),ie===void 0)return;he=2}const ce=N.drawRange,fe=N.attributes.position;let ge=ce.start*he,Ee=(ce.start+ce.count)*he;z!==null&&(ge=Math.max(ge,z.start*he),Ee=Math.min(Ee,(z.start+z.count)*he)),ie!==null?(ge=Math.max(ge,0),Ee=Math.min(Ee,ie.count)):fe!=null&&(ge=Math.max(ge,0),Ee=Math.min(Ee,fe.count));const De=Ee-ge;if(De<0||De===1/0)return;nt.setup(P,U,X,N,ie);let Ke,He=Te;if(ie!==null&&(Ke=le.get(ie),He=tt,He.setIndex(Ke)),P.isMesh)U.wireframe===!0?(ze.setLineWidth(U.wireframeLinewidth*Je()),He.setMode(G.LINES)):He.setMode(G.TRIANGLES);else if(P.isLine){let Fe=U.linewidth;Fe===void 0&&(Fe=1),ze.setLineWidth(Fe*Je()),P.isLineSegments?He.setMode(G.LINES):P.isLineLoop?He.setMode(G.LINE_LOOP):He.setMode(G.LINE_STRIP)}else P.isPoints?He.setMode(G.POINTS):P.isSprite&&He.setMode(G.TRIANGLES);if(P.isBatchedMesh)if(P._multiDrawInstances!==null)Ic("THREE.WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),He.renderMultiDrawInstances(P._multiDrawStarts,P._multiDrawCounts,P._multiDrawCount,P._multiDrawInstances);else if(dt.get("WEBGL_multi_draw"))He.renderMultiDraw(P._multiDrawStarts,P._multiDrawCounts,P._multiDrawCount);else{const Fe=P._multiDrawStarts,st=P._multiDrawCounts,Le=P._multiDrawCount,wt=ie?le.get(ie).bytesPerElement:1,un=Ge.get(U).currentProgram.getUniforms();for(let _t=0;_t<Le;_t++)un.setValue(G,"_gl_DrawID",_t),He.render(Fe[_t]/wt,st[_t])}else if(P.isInstancedMesh)He.renderInstances(ge,De,P.count);else if(N.isInstancedBufferGeometry){const Fe=N._maxInstanceCount!==void 0?N._maxInstanceCount:1/0,st=Math.min(N.instanceCount,Fe);He.renderInstances(ge,De,st)}else He.render(ge,De)};function yt(_,R,N){_.transparent===!0&&_.side===Bi&&_.forceSinglePass===!1?(_.side=In,_.needsUpdate=!0,qa(_,R,N),_.side=Hi,_.needsUpdate=!0,qa(_,R,N),_.side=Bi):qa(_,R,N)}this.compile=function(_,R,N=null){N===null&&(N=_),p=Ye.get(N),p.init(R),b.push(p),N.traverseVisible(function(P){P.isLight&&P.layers.test(R.layers)&&(p.pushLight(P),P.castShadow&&p.pushShadow(P))}),_!==N&&_.traverseVisible(function(P){P.isLight&&P.layers.test(R.layers)&&(p.pushLight(P),P.castShadow&&p.pushShadow(P))}),p.setupLights();const U=new Set;return _.traverse(function(P){if(!(P.isMesh||P.isPoints||P.isLine||P.isSprite))return;const z=P.material;if(z)if(Array.isArray(z))for(let j=0;j<z.length;j++){const X=z[j];yt(X,N,P),U.add(X)}else yt(z,N,P),U.add(z)}),p=b.pop(),U},this.compileAsync=function(_,R,N=null){const U=this.compile(_,R,N);return new Promise(P=>{function z(){if(U.forEach(function(j){Ge.get(j).currentProgram.isReady()&&U.delete(j)}),U.size===0){P(_);return}setTimeout(z,10)}dt.get("KHR_parallel_shader_compile")!==null?z():setTimeout(z,10)})};let Jn=null;function Mi(_){Jn&&Jn(_)}function bh(){gs.stop()}function xh(){gs.start()}const gs=new KA;gs.setAnimationLoop(Mi),typeof self<"u"&&gs.setContext(self),this.setAnimationLoop=function(_){Jn=_,re.setAnimationLoop(_),_===null?gs.stop():gs.start()},re.addEventListener("sessionstart",bh),re.addEventListener("sessionend",xh),this.render=function(_,R){if(R!==void 0&&R.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(M===!0)return;if(_.matrixWorldAutoUpdate===!0&&_.updateMatrixWorld(),R.parent===null&&R.matrixWorldAutoUpdate===!0&&R.updateMatrixWorld(),re.enabled===!0&&re.isPresenting===!0&&(re.cameraAutoUpdate===!0&&re.updateCamera(R),R=re.getCamera()),_.isScene===!0&&_.onBeforeRender(E,_,R,T),p=Ye.get(_,b.length),p.init(R),b.push(p),Pe.multiplyMatrices(R.projectionMatrix,R.matrixWorldInverse),se.setFromProjectionMatrix(Pe),be=this.localClippingEnabled,me=_e.init(this.clippingPlanes,be),g=Ve.get(_,y.length),g.init(),y.push(g),re.enabled===!0&&re.isPresenting===!0){const z=E.xr.getDepthSensingMesh();z!==null&&cc(z,R,-1/0,E.sortObjects)}cc(_,R,0,E.sortObjects),g.finish(),E.sortObjects===!0&&g.sort(J,ee),ut=re.enabled===!1||re.isPresenting===!1||re.hasDepthSensing()===!1,ut&&ke.addToRenderList(g,_),this.info.render.frame++,me===!0&&_e.beginShadows();const N=p.state.shadowsArray;Ne.render(N,_,R),me===!0&&_e.endShadows(),this.info.autoReset===!0&&this.info.reset();const U=g.opaque,P=g.transmissive;if(p.setupLights(),R.isArrayCamera){const z=R.cameras;if(P.length>0)for(let j=0,X=z.length;j<X;j++){const ie=z[j];_h(U,P,_,ie)}ut&&ke.render(_);for(let j=0,X=z.length;j<X;j++){const ie=z[j];lc(g,_,ie,ie.viewport)}}else P.length>0&&_h(U,P,_,R),ut&&ke.render(_),lc(g,_,R);T!==null&&S===0&&(L.updateMultisampleRenderTarget(T),L.updateRenderTargetMipmap(T)),_.isScene===!0&&_.onAfterRender(E,_,R),nt.resetDefaultState(),C=-1,v=null,b.pop(),b.length>0?(p=b[b.length-1],me===!0&&_e.setGlobalState(E.clippingPlanes,p.state.camera)):p=null,y.pop(),y.length>0?g=y[y.length-1]:g=null};function cc(_,R,N,U){if(_.visible===!1)return;if(_.layers.test(R.layers)){if(_.isGroup)N=_.renderOrder;else if(_.isLOD)_.autoUpdate===!0&&_.update(R);else if(_.isLight)p.pushLight(_),_.castShadow&&p.pushShadow(_);else if(_.isSprite){if(!_.frustumCulled||se.intersectsSprite(_)){U&&Qe.setFromMatrixPosition(_.matrixWorld).applyMatrix4(Pe);const j=oe.update(_),X=_.material;X.visible&&g.push(_,j,X,N,Qe.z,null)}}else if((_.isMesh||_.isLine||_.isPoints)&&(!_.frustumCulled||se.intersectsObject(_))){const j=oe.update(_),X=_.material;if(U&&(_.boundingSphere!==void 0?(_.boundingSphere===null&&_.computeBoundingSphere(),Qe.copy(_.boundingSphere.center)):(j.boundingSphere===null&&j.computeBoundingSphere(),Qe.copy(j.boundingSphere.center)),Qe.applyMatrix4(_.matrixWorld).applyMatrix4(Pe)),Array.isArray(X)){const ie=j.groups;for(let he=0,ce=ie.length;he<ce;he++){const fe=ie[he],ge=X[fe.materialIndex];ge&&ge.visible&&g.push(_,j,ge,N,Qe.z,fe)}}else X.visible&&g.push(_,j,X,N,Qe.z,null)}}const z=_.children;for(let j=0,X=z.length;j<X;j++)cc(z[j],R,N,U)}function lc(_,R,N,U){const P=_.opaque,z=_.transmissive,j=_.transparent;p.setupLightsView(N),me===!0&&_e.setGlobalState(E.clippingPlanes,N),U&&ze.viewport(F.copy(U)),P.length>0&&Wa(P,R,N),z.length>0&&Wa(z,R,N),j.length>0&&Wa(j,R,N),ze.buffers.depth.setTest(!0),ze.buffers.depth.setMask(!0),ze.buffers.color.setMask(!0),ze.setPolygonOffset(!1)}function _h(_,R,N,U){if((N.isScene===!0?N.overrideMaterial:null)!==null)return;p.state.transmissionRenderTarget[U.id]===void 0&&(p.state.transmissionRenderTarget[U.id]=new $s(1,1,{generateMipmaps:!0,type:dt.has("EXT_color_buffer_half_float")||dt.has("EXT_color_buffer_float")?Bn:tn,minFilter:Zn,samples:4,stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:At.workingColorSpace}));const z=p.state.transmissionRenderTarget[U.id],j=U.viewport||F;z.setSize(j.z*E.transmissionResolutionScale,j.w*E.transmissionResolutionScale);const X=E.getRenderTarget();E.setRenderTarget(z),E.getClearColor($),D=E.getClearAlpha(),D<1&&E.setClearColor(16777215,.5),E.clear(),ut&&ke.render(N);const ie=E.toneMapping;E.toneMapping=xs;const he=U.viewport;if(U.viewport!==void 0&&(U.viewport=void 0),p.setupLightsView(U),me===!0&&_e.setGlobalState(E.clippingPlanes,U),Wa(_,N,U),L.updateMultisampleRenderTarget(z),L.updateRenderTargetMipmap(z),dt.has("WEBGL_multisampled_render_to_texture")===!1){let ce=!1;for(let fe=0,ge=R.length;fe<ge;fe++){const Ee=R[fe],De=Ee.object,Ke=Ee.geometry,He=Ee.material,Fe=Ee.group;if(He.side===Bi&&De.layers.test(U.layers)){const st=He.side;He.side=In,He.needsUpdate=!0,Eh(De,N,U,Ke,He,Fe),He.side=st,He.needsUpdate=!0,ce=!0}}ce===!0&&(L.updateMultisampleRenderTarget(z),L.updateRenderTargetMipmap(z))}E.setRenderTarget(X),E.setClearColor($,D),he!==void 0&&(U.viewport=he),E.toneMapping=ie}function Wa(_,R,N){const U=R.isScene===!0?R.overrideMaterial:null;for(let P=0,z=_.length;P<z;P++){const j=_[P],X=j.object,ie=j.geometry,he=j.group;let ce=j.material;ce.allowOverride===!0&&U!==null&&(ce=U),X.layers.test(N.layers)&&Eh(X,R,N,ie,ce,he)}}function Eh(_,R,N,U,P,z){_.onBeforeRender(E,R,N,U,P,z),_.modelViewMatrix.multiplyMatrices(N.matrixWorldInverse,_.matrixWorld),_.normalMatrix.getNormalMatrix(_.modelViewMatrix),P.onBeforeRender(E,R,N,U,_,z),P.transparent===!0&&P.side===Bi&&P.forceSinglePass===!1?(P.side=In,P.needsUpdate=!0,E.renderBufferDirect(N,R,U,P,_,z),P.side=Hi,P.needsUpdate=!0,E.renderBufferDirect(N,R,U,P,_,z),P.side=Bi):E.renderBufferDirect(N,R,U,P,_,z),_.onAfterRender(E,R,N,U,P,z)}function qa(_,R,N){R.isScene!==!0&&(R=St);const U=Ge.get(_),P=p.state.lights,z=p.state.shadowsArray,j=P.state.version,X=Ue.getParameters(_,P.state,z,R,N),ie=Ue.getProgramCacheKey(X);let he=U.programs;U.environment=_.isMeshStandardMaterial?R.environment:null,U.fog=R.fog,U.envMap=(_.isMeshStandardMaterial?Z:I).get(_.envMap||U.environment),U.envMapRotation=U.environment!==null&&_.envMap===null?R.environmentRotation:_.envMapRotation,he===void 0&&(_.addEventListener("dispose",it),he=new Map,U.programs=he);let ce=he.get(ie);if(ce!==void 0){if(U.currentProgram===ce&&U.lightsStateVersion===j)return uc(_,X),ce}else X.uniforms=Ue.getUniforms(_),_.onBeforeCompile(X,E),ce=Ue.acquireProgram(X,ie),he.set(ie,ce),U.uniforms=X.uniforms;const fe=U.uniforms;return(!_.isShaderMaterial&&!_.isRawShaderMaterial||_.clipping===!0)&&(fe.clippingPlanes=_e.uniform),uc(_,X),U.needsLights=Ks(_),U.lightsStateVersion=j,U.needsLights&&(fe.ambientLightColor.value=P.state.ambient,fe.lightProbe.value=P.state.probe,fe.directionalLights.value=P.state.directional,fe.directionalLightShadows.value=P.state.directionalShadow,fe.spotLights.value=P.state.spot,fe.spotLightShadows.value=P.state.spotShadow,fe.rectAreaLights.value=P.state.rectArea,fe.ltc_1.value=P.state.rectAreaLTC1,fe.ltc_2.value=P.state.rectAreaLTC2,fe.pointLights.value=P.state.point,fe.pointLightShadows.value=P.state.pointShadow,fe.hemisphereLights.value=P.state.hemi,fe.directionalShadowMap.value=P.state.directionalShadowMap,fe.directionalShadowMatrix.value=P.state.directionalShadowMatrix,fe.spotShadowMap.value=P.state.spotShadowMap,fe.spotLightMatrix.value=P.state.spotLightMatrix,fe.spotLightMap.value=P.state.spotLightMap,fe.pointShadowMap.value=P.state.pointShadowMap,fe.pointShadowMatrix.value=P.state.pointShadowMatrix),U.currentProgram=ce,U.uniformsList=null,ce}function hc(_){if(_.uniformsList===null){const R=_.currentProgram.getUniforms();_.uniformsList=ll.seqWithValue(R.seq,_.uniforms)}return _.uniformsList}function uc(_,R){const N=Ge.get(_);N.outputColorSpace=R.outputColorSpace,N.batching=R.batching,N.batchingColor=R.batchingColor,N.instancing=R.instancing,N.instancingColor=R.instancingColor,N.instancingMorph=R.instancingMorph,N.skinning=R.skinning,N.morphTargets=R.morphTargets,N.morphNormals=R.morphNormals,N.morphColors=R.morphColors,N.morphTargetsCount=R.morphTargetsCount,N.numClippingPlanes=R.numClippingPlanes,N.numIntersection=R.numClipIntersection,N.vertexAlphas=R.vertexAlphas,N.vertexTangents=R.vertexTangents,N.toneMapping=R.toneMapping}function pp(_,R,N,U,P){R.isScene!==!0&&(R=St),L.resetTextureUnits();const z=R.fog,j=U.isMeshStandardMaterial?R.environment:null,X=T===null?E.outputColorSpace:T.isXRRenderTarget===!0?T.texture.colorSpace:rn,ie=(U.isMeshStandardMaterial?Z:I).get(U.envMap||j),he=U.vertexColors===!0&&!!N.attributes.color&&N.attributes.color.itemSize===4,ce=!!N.attributes.tangent&&(!!U.normalMap||U.anisotropy>0),fe=!!N.morphAttributes.position,ge=!!N.morphAttributes.normal,Ee=!!N.morphAttributes.color;let De=xs;U.toneMapped&&(T===null||T.isXRRenderTarget===!0)&&(De=E.toneMapping);const Ke=N.morphAttributes.position||N.morphAttributes.normal||N.morphAttributes.color,He=Ke!==void 0?Ke.length:0,Fe=Ge.get(U),st=p.state.lights;if(me===!0&&(be===!0||_!==v)){const Lt=_===v&&U.id===C;_e.setState(U,_,Lt)}let Le=!1;U.version===Fe.__version?(Fe.needsLights&&Fe.lightsStateVersion!==st.state.version||Fe.outputColorSpace!==X||P.isBatchedMesh&&Fe.batching===!1||!P.isBatchedMesh&&Fe.batching===!0||P.isBatchedMesh&&Fe.batchingColor===!0&&P.colorTexture===null||P.isBatchedMesh&&Fe.batchingColor===!1&&P.colorTexture!==null||P.isInstancedMesh&&Fe.instancing===!1||!P.isInstancedMesh&&Fe.instancing===!0||P.isSkinnedMesh&&Fe.skinning===!1||!P.isSkinnedMesh&&Fe.skinning===!0||P.isInstancedMesh&&Fe.instancingColor===!0&&P.instanceColor===null||P.isInstancedMesh&&Fe.instancingColor===!1&&P.instanceColor!==null||P.isInstancedMesh&&Fe.instancingMorph===!0&&P.morphTexture===null||P.isInstancedMesh&&Fe.instancingMorph===!1&&P.morphTexture!==null||Fe.envMap!==ie||U.fog===!0&&Fe.fog!==z||Fe.numClippingPlanes!==void 0&&(Fe.numClippingPlanes!==_e.numPlanes||Fe.numIntersection!==_e.numIntersection)||Fe.vertexAlphas!==he||Fe.vertexTangents!==ce||Fe.morphTargets!==fe||Fe.morphNormals!==ge||Fe.morphColors!==Ee||Fe.toneMapping!==De||Fe.morphTargetsCount!==He)&&(Le=!0):(Le=!0,Fe.__version=U.version);let wt=Fe.currentProgram;Le===!0&&(wt=qa(U,R,P));let un=!1,_t=!1,bt=!1;const je=wt.getUniforms(),qt=Fe.uniforms;if(ze.useProgram(wt.program)&&(un=!0,_t=!0,bt=!0),U.id!==C&&(C=U.id,_t=!0),un||v!==_){ze.buffers.depth.getReversed()?(xe.copy(_.projectionMatrix),QE(xe),GE(xe),je.setValue(G,"projectionMatrix",xe)):je.setValue(G,"projectionMatrix",_.projectionMatrix),je.setValue(G,"viewMatrix",_.matrixWorldInverse);const dn=je.map.cameraPosition;dn!==void 0&&dn.setValue(G,et.setFromMatrixPosition(_.matrixWorld)),pt.logarithmicDepthBuffer&&je.setValue(G,"logDepthBufFC",2/(Math.log(_.far+1)/Math.LN2)),(U.isMeshPhongMaterial||U.isMeshToonMaterial||U.isMeshLambertMaterial||U.isMeshBasicMaterial||U.isMeshStandardMaterial||U.isShaderMaterial)&&je.setValue(G,"isOrthographic",_.isOrthographicCamera===!0),v!==_&&(v=_,_t=!0,bt=!0)}if(P.isSkinnedMesh){je.setOptional(G,P,"bindMatrix"),je.setOptional(G,P,"bindMatrixInverse");const Lt=P.skeleton;Lt&&(Lt.boneTexture===null&&Lt.computeBoneTexture(),je.setValue(G,"boneTexture",Lt.boneTexture,L))}P.isBatchedMesh&&(je.setOptional(G,P,"batchingTexture"),je.setValue(G,"batchingTexture",P._matricesTexture,L),je.setOptional(G,P,"batchingIdTexture"),je.setValue(G,"batchingIdTexture",P._indirectTexture,L),je.setOptional(G,P,"batchingColorTexture"),P._colorsTexture!==null&&je.setValue(G,"batchingColorTexture",P._colorsTexture,L));const xn=N.morphAttributes;if((xn.position!==void 0||xn.normal!==void 0||xn.color!==void 0)&&Oe.update(P,N,wt),(_t||Fe.receiveShadow!==P.receiveShadow)&&(Fe.receiveShadow=P.receiveShadow,je.setValue(G,"receiveShadow",P.receiveShadow)),U.isMeshGouraudMaterial&&U.envMap!==null&&(qt.envMap.value=ie,qt.flipEnvMap.value=ie.isCubeTexture&&ie.isRenderTargetTexture===!1?-1:1),U.isMeshStandardMaterial&&U.envMap===null&&R.environment!==null&&(qt.envMapIntensity.value=R.environmentIntensity),_t&&(je.setValue(G,"toneMappingExposure",E.toneMappingExposure),Fe.needsLights&&ms(qt,bt),z&&U.fog===!0&&ve.refreshFogUniforms(qt,z),ve.refreshMaterialUniforms(qt,U,Q,Y,p.state.transmissionRenderTarget[_.id]),ll.upload(G,hc(Fe),qt,L)),U.isShaderMaterial&&U.uniformsNeedUpdate===!0&&(ll.upload(G,hc(Fe),qt,L),U.uniformsNeedUpdate=!1),U.isSpriteMaterial&&je.setValue(G,"center",P.center),je.setValue(G,"modelViewMatrix",P.modelViewMatrix),je.setValue(G,"normalMatrix",P.normalMatrix),je.setValue(G,"modelMatrix",P.matrixWorld),U.isShaderMaterial||U.isRawShaderMaterial){const Lt=U.uniformsGroups;for(let dn=0,Ap=Lt.length;dn<Ap;dn++){const Dr=Lt[dn];W.update(Dr,wt),W.bind(Dr,wt)}}return wt}function ms(_,R){_.ambientLightColor.needsUpdate=R,_.lightProbe.needsUpdate=R,_.directionalLights.needsUpdate=R,_.directionalLightShadows.needsUpdate=R,_.pointLights.needsUpdate=R,_.pointLightShadows.needsUpdate=R,_.spotLights.needsUpdate=R,_.spotLightShadows.needsUpdate=R,_.rectAreaLights.needsUpdate=R,_.hemisphereLights.needsUpdate=R}function Ks(_){return _.isMeshLambertMaterial||_.isMeshToonMaterial||_.isMeshPhongMaterial||_.isMeshStandardMaterial||_.isShadowMaterial||_.isShaderMaterial&&_.lights===!0}this.getActiveCubeFace=function(){return w},this.getActiveMipmapLevel=function(){return S},this.getRenderTarget=function(){return T},this.setRenderTargetTextures=function(_,R,N){const U=Ge.get(_);U.__autoAllocateDepthBuffer=_.resolveDepthBuffer===!1,U.__autoAllocateDepthBuffer===!1&&(U.__useRenderToTexture=!1),Ge.get(_.texture).__webglTexture=R,Ge.get(_.depthTexture).__webglTexture=U.__autoAllocateDepthBuffer?void 0:N,U.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(_,R){const N=Ge.get(_);N.__webglFramebuffer=R,N.__useDefaultFramebuffer=R===void 0};const x=G.createFramebuffer();this.setRenderTarget=function(_,R=0,N=0){T=_,w=R,S=N;let U=!0,P=null,z=!1,j=!1;if(_){const ie=Ge.get(_);if(ie.__useDefaultFramebuffer!==void 0)ze.bindFramebuffer(G.FRAMEBUFFER,null),U=!1;else if(ie.__webglFramebuffer===void 0)L.setupRenderTarget(_);else if(ie.__hasExternalTextures)L.rebindTextures(_,Ge.get(_.texture).__webglTexture,Ge.get(_.depthTexture).__webglTexture);else if(_.depthBuffer){const fe=_.depthTexture;if(ie.__boundDepthTexture!==fe){if(fe!==null&&Ge.has(fe)&&(_.width!==fe.image.width||_.height!==fe.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");L.setupDepthRenderbuffer(_)}}const he=_.texture;(he.isData3DTexture||he.isDataArrayTexture||he.isCompressedArrayTexture)&&(j=!0);const ce=Ge.get(_).__webglFramebuffer;_.isWebGLCubeRenderTarget?(Array.isArray(ce[R])?P=ce[R][N]:P=ce[R],z=!0):_.samples>0&&L.useMultisampledRTT(_)===!1?P=Ge.get(_).__webglMultisampledFramebuffer:Array.isArray(ce)?P=ce[N]:P=ce,F.copy(_.viewport),K.copy(_.scissor),q=_.scissorTest}else F.copy(ae).multiplyScalar(Q).floor(),K.copy(ye).multiplyScalar(Q).floor(),q=Me;if(N!==0&&(P=x),ze.bindFramebuffer(G.FRAMEBUFFER,P)&&U&&ze.drawBuffers(_,P),ze.viewport(F),ze.scissor(K),ze.setScissorTest(q),z){const ie=Ge.get(_.texture);G.framebufferTexture2D(G.FRAMEBUFFER,G.COLOR_ATTACHMENT0,G.TEXTURE_CUBE_MAP_POSITIVE_X+R,ie.__webglTexture,N)}else if(j){const ie=Ge.get(_.texture),he=R;G.framebufferTextureLayer(G.FRAMEBUFFER,G.COLOR_ATTACHMENT0,ie.__webglTexture,N,he)}else if(_!==null&&N!==0){const ie=Ge.get(_.texture);G.framebufferTexture2D(G.FRAMEBUFFER,G.COLOR_ATTACHMENT0,G.TEXTURE_2D,ie.__webglTexture,N)}C=-1},this.readRenderTargetPixels=function(_,R,N,U,P,z,j){if(!(_&&_.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let X=Ge.get(_).__webglFramebuffer;if(_.isWebGLCubeRenderTarget&&j!==void 0&&(X=X[j]),X){ze.bindFramebuffer(G.FRAMEBUFFER,X);try{const ie=_.texture,he=ie.format,ce=ie.type;if(!pt.textureFormatReadable(he)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!pt.textureTypeReadable(ce)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}R>=0&&R<=_.width-U&&N>=0&&N<=_.height-P&&G.readPixels(R,N,U,P,We.convert(he),We.convert(ce),z)}finally{const ie=T!==null?Ge.get(T).__webglFramebuffer:null;ze.bindFramebuffer(G.FRAMEBUFFER,ie)}}},this.readRenderTargetPixelsAsync=async function(_,R,N,U,P,z,j){if(!(_&&_.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let X=Ge.get(_).__webglFramebuffer;if(_.isWebGLCubeRenderTarget&&j!==void 0&&(X=X[j]),X)if(R>=0&&R<=_.width-U&&N>=0&&N<=_.height-P){ze.bindFramebuffer(G.FRAMEBUFFER,X);const ie=_.texture,he=ie.format,ce=ie.type;if(!pt.textureFormatReadable(he))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!pt.textureTypeReadable(ce))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const fe=G.createBuffer();G.bindBuffer(G.PIXEL_PACK_BUFFER,fe),G.bufferData(G.PIXEL_PACK_BUFFER,z.byteLength,G.STREAM_READ),G.readPixels(R,N,U,P,We.convert(he),We.convert(ce),0);const ge=T!==null?Ge.get(T).__webglFramebuffer:null;ze.bindFramebuffer(G.FRAMEBUFFER,ge);const Ee=G.fenceSync(G.SYNC_GPU_COMMANDS_COMPLETE,0);return G.flush(),await OE(G,Ee,4),G.bindBuffer(G.PIXEL_PACK_BUFFER,fe),G.getBufferSubData(G.PIXEL_PACK_BUFFER,0,z),G.deleteBuffer(fe),G.deleteSync(Ee),z}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(_,R=null,N=0){const U=Math.pow(2,-N),P=Math.floor(_.image.width*U),z=Math.floor(_.image.height*U),j=R!==null?R.x:0,X=R!==null?R.y:0;L.setTexture2D(_,0),G.copyTexSubImage2D(G.TEXTURE_2D,N,0,0,j,X,P,z),ze.unbindTexture()};const B=G.createFramebuffer(),k=G.createFramebuffer();this.copyTextureToTexture=function(_,R,N=null,U=null,P=0,z=null){z===null&&(P!==0?(Ic("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),z=P,P=0):z=0);let j,X,ie,he,ce,fe,ge,Ee,De;const Ke=_.isCompressedTexture?_.mipmaps[z]:_.image;if(N!==null)j=N.max.x-N.min.x,X=N.max.y-N.min.y,ie=N.isBox3?N.max.z-N.min.z:1,he=N.min.x,ce=N.min.y,fe=N.isBox3?N.min.z:0;else{const xn=Math.pow(2,-P);j=Math.floor(Ke.width*xn),X=Math.floor(Ke.height*xn),_.isDataArrayTexture?ie=Ke.depth:_.isData3DTexture?ie=Math.floor(Ke.depth*xn):ie=1,he=0,ce=0,fe=0}U!==null?(ge=U.x,Ee=U.y,De=U.z):(ge=0,Ee=0,De=0);const He=We.convert(R.format),Fe=We.convert(R.type);let st;R.isData3DTexture?(L.setTexture3D(R,0),st=G.TEXTURE_3D):R.isDataArrayTexture||R.isCompressedArrayTexture?(L.setTexture2DArray(R,0),st=G.TEXTURE_2D_ARRAY):(L.setTexture2D(R,0),st=G.TEXTURE_2D),G.pixelStorei(G.UNPACK_FLIP_Y_WEBGL,R.flipY),G.pixelStorei(G.UNPACK_PREMULTIPLY_ALPHA_WEBGL,R.premultiplyAlpha),G.pixelStorei(G.UNPACK_ALIGNMENT,R.unpackAlignment);const Le=G.getParameter(G.UNPACK_ROW_LENGTH),wt=G.getParameter(G.UNPACK_IMAGE_HEIGHT),un=G.getParameter(G.UNPACK_SKIP_PIXELS),_t=G.getParameter(G.UNPACK_SKIP_ROWS),bt=G.getParameter(G.UNPACK_SKIP_IMAGES);G.pixelStorei(G.UNPACK_ROW_LENGTH,Ke.width),G.pixelStorei(G.UNPACK_IMAGE_HEIGHT,Ke.height),G.pixelStorei(G.UNPACK_SKIP_PIXELS,he),G.pixelStorei(G.UNPACK_SKIP_ROWS,ce),G.pixelStorei(G.UNPACK_SKIP_IMAGES,fe);const je=_.isDataArrayTexture||_.isData3DTexture,qt=R.isDataArrayTexture||R.isData3DTexture;if(_.isDepthTexture){const xn=Ge.get(_),Lt=Ge.get(R),dn=Ge.get(xn.__renderTarget),Ap=Ge.get(Lt.__renderTarget);ze.bindFramebuffer(G.READ_FRAMEBUFFER,dn.__webglFramebuffer),ze.bindFramebuffer(G.DRAW_FRAMEBUFFER,Ap.__webglFramebuffer);for(let Dr=0;Dr<ie;Dr++)je&&(G.framebufferTextureLayer(G.READ_FRAMEBUFFER,G.COLOR_ATTACHMENT0,Ge.get(_).__webglTexture,P,fe+Dr),G.framebufferTextureLayer(G.DRAW_FRAMEBUFFER,G.COLOR_ATTACHMENT0,Ge.get(R).__webglTexture,z,De+Dr)),G.blitFramebuffer(he,ce,j,X,ge,Ee,j,X,G.DEPTH_BUFFER_BIT,G.NEAREST);ze.bindFramebuffer(G.READ_FRAMEBUFFER,null),ze.bindFramebuffer(G.DRAW_FRAMEBUFFER,null)}else if(P!==0||_.isRenderTargetTexture||Ge.has(_)){const xn=Ge.get(_),Lt=Ge.get(R);ze.bindFramebuffer(G.READ_FRAMEBUFFER,B),ze.bindFramebuffer(G.DRAW_FRAMEBUFFER,k);for(let dn=0;dn<ie;dn++)je?G.framebufferTextureLayer(G.READ_FRAMEBUFFER,G.COLOR_ATTACHMENT0,xn.__webglTexture,P,fe+dn):G.framebufferTexture2D(G.READ_FRAMEBUFFER,G.COLOR_ATTACHMENT0,G.TEXTURE_2D,xn.__webglTexture,P),qt?G.framebufferTextureLayer(G.DRAW_FRAMEBUFFER,G.COLOR_ATTACHMENT0,Lt.__webglTexture,z,De+dn):G.framebufferTexture2D(G.DRAW_FRAMEBUFFER,G.COLOR_ATTACHMENT0,G.TEXTURE_2D,Lt.__webglTexture,z),P!==0?G.blitFramebuffer(he,ce,j,X,ge,Ee,j,X,G.COLOR_BUFFER_BIT,G.NEAREST):qt?G.copyTexSubImage3D(st,z,ge,Ee,De+dn,he,ce,j,X):G.copyTexSubImage2D(st,z,ge,Ee,he,ce,j,X);ze.bindFramebuffer(G.READ_FRAMEBUFFER,null),ze.bindFramebuffer(G.DRAW_FRAMEBUFFER,null)}else qt?_.isDataTexture||_.isData3DTexture?G.texSubImage3D(st,z,ge,Ee,De,j,X,ie,He,Fe,Ke.data):R.isCompressedArrayTexture?G.compressedTexSubImage3D(st,z,ge,Ee,De,j,X,ie,He,Ke.data):G.texSubImage3D(st,z,ge,Ee,De,j,X,ie,He,Fe,Ke):_.isDataTexture?G.texSubImage2D(G.TEXTURE_2D,z,ge,Ee,j,X,He,Fe,Ke.data):_.isCompressedTexture?G.compressedTexSubImage2D(G.TEXTURE_2D,z,ge,Ee,Ke.width,Ke.height,He,Ke.data):G.texSubImage2D(G.TEXTURE_2D,z,ge,Ee,j,X,He,Fe,Ke);G.pixelStorei(G.UNPACK_ROW_LENGTH,Le),G.pixelStorei(G.UNPACK_IMAGE_HEIGHT,wt),G.pixelStorei(G.UNPACK_SKIP_PIXELS,un),G.pixelStorei(G.UNPACK_SKIP_ROWS,_t),G.pixelStorei(G.UNPACK_SKIP_IMAGES,bt),z===0&&R.generateMipmaps&&G.generateMipmap(st),ze.unbindTexture()},this.copyTextureToTexture3D=function(_,R,N=null,U=null,P=0){return Ic('WebGLRenderer: copyTextureToTexture3D function has been deprecated. Use "copyTextureToTexture" instead.'),this.copyTextureToTexture(_,R,N,U,P)},this.initRenderTarget=function(_){Ge.get(_).__webglFramebuffer===void 0&&L.setupRenderTarget(_)},this.initTexture=function(_){_.isCubeTexture?L.setTextureCube(_,0):_.isData3DTexture?L.setTexture3D(_,0):_.isDataArrayTexture||_.isCompressedArrayTexture?L.setTexture2DArray(_,0):L.setTexture2D(_,0),ze.unbindTexture()},this.resetState=function(){w=0,S=0,T=null,ze.reset(),nt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Vi}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=At._getDrawingBufferColorSpace(e),t.unpackColorSpace=At._getUnpackColorSpace()}}var wo=function(){var i=0,e=document.createElement("div");e.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",e.addEventListener("click",function(h){h.preventDefault(),n(++i%e.children.length)},!1);function t(h){return e.appendChild(h.dom),h}function n(h){for(var u=0;u<e.children.length;u++)e.children[u].style.display=u===h?"block":"none";i=h}var s=(performance||Date).now(),r=s,a=0,o=t(new wo.Panel("FPS","#0ff","#002")),c=t(new wo.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var l=t(new wo.Panel("MB","#f08","#201"));return n(0),{REVISION:16,dom:e,addPanel:t,showPanel:n,begin:function(){s=(performance||Date).now()},end:function(){a++;var h=(performance||Date).now();if(c.update(h-s,200),h>=r+1e3&&(o.update(a*1e3/(h-r),100),r=h,a=0,l)){var u=performance.memory;l.update(u.usedJSHeapSize/1048576,u.jsHeapSizeLimit/1048576)}return h},update:function(){s=this.end()},domElement:e,setMode:n}};wo.Panel=function(i,e,t){var n=1/0,s=0,r=Math.round,a=r(window.devicePixelRatio||1),o=80*a,c=48*a,l=3*a,h=2*a,u=3*a,d=15*a,f=74*a,m=30*a,A=document.createElement("canvas");A.width=o,A.height=c,A.style.cssText="width:80px;height:48px";var g=A.getContext("2d");return g.font="bold "+9*a+"px Helvetica,Arial,sans-serif",g.textBaseline="top",g.fillStyle=t,g.fillRect(0,0,o,c),g.fillStyle=e,g.fillText(i,l,h),g.fillRect(u,d,f,m),g.fillStyle=t,g.globalAlpha=.9,g.fillRect(u,d,f,m),{dom:A,update:function(p,y){n=Math.min(n,p),s=Math.max(s,p),g.fillStyle=t,g.globalAlpha=1,g.fillRect(0,0,o,d),g.fillStyle=e,g.fillText(r(p)+" "+i+" ("+r(n)+"-"+r(s)+")",l,h),g.drawImage(A,u+a,d,f-a,m,u,d,f-a,m),g.fillRect(u+f-a,d,a,m),g.fillStyle=t,g.globalAlpha=.9,g.fillRect(u+f-a,d,a,r((1-p/y)*m))}}};function yg(i,e){if(e===uE)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),i;if(e===au||e===Dp){let t=i.getIndex();if(t===null){const a=[],o=i.getAttribute("position");if(o!==void 0){for(let c=0;c<o.count;c++)a.push(c);i.setIndex(a),t=i.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),i}const n=t.count-2,s=[];if(e===au)for(let a=1;a<=n;a++)s.push(t.getX(0)),s.push(t.getX(a)),s.push(t.getX(a+1));else for(let a=0;a<n;a++)a%2===0?(s.push(t.getX(a)),s.push(t.getX(a+1)),s.push(t.getX(a+2))):(s.push(t.getX(a+2)),s.push(t.getX(a+1)),s.push(t.getX(a)));s.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const r=i.clone();return r.setIndex(s),r.clearGroups(),r}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),i}class wg extends $i{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new pI(t)}),this.register(function(t){return new AI(t)}),this.register(function(t){return new vI(t)}),this.register(function(t){return new CI(t)}),this.register(function(t){return new SI(t)}),this.register(function(t){return new mI(t)}),this.register(function(t){return new bI(t)}),this.register(function(t){return new xI(t)}),this.register(function(t){return new _I(t)}),this.register(function(t){return new fI(t)}),this.register(function(t){return new EI(t)}),this.register(function(t){return new gI(t)}),this.register(function(t){return new wI(t)}),this.register(function(t){return new yI(t)}),this.register(function(t){return new uI(t)}),this.register(function(t){return new II(t)}),this.register(function(t){return new MI(t)})}load(e,t,n,s){const r=this;let a;if(this.resourcePath!=="")a=this.resourcePath;else if(this.path!==""){const l=da.extractUrlBase(e);a=da.resolveURL(l,this.path)}else a=da.extractUrlBase(e);this.manager.itemStart(e);const o=function(l){s?s(l):console.error(l),r.manager.itemError(e),r.manager.itemEnd(e)},c=new Ts(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(e,function(l){try{r.parse(l,a,function(h){t(h),r.manager.itemEnd(e)},o)}catch(h){o(h)}},n,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,s){let r;const a={},o={},c=new TextDecoder;if(typeof e=="string")r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(c.decode(new Uint8Array(e,0,4))===vg){try{a[ft.KHR_BINARY_GLTF]=new BI(e)}catch(u){s&&s(u);return}r=JSON.parse(a[ft.KHR_BINARY_GLTF].content)}else r=JSON.parse(c.decode(e));else r=e;if(r.asset===void 0||r.asset.version[0]<2){s&&s(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const l=new HI(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h<this.pluginCallbacks.length;h++){const u=this.pluginCallbacks[h](l);u.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),o[u.name]=u,a[u.name]=!0}if(r.extensionsUsed)for(let h=0;h<r.extensionsUsed.length;++h){const u=r.extensionsUsed[h],d=r.extensionsRequired||[];switch(u){case ft.KHR_MATERIALS_UNLIT:a[u]=new dI;break;case ft.KHR_DRACO_MESH_COMPRESSION:a[u]=new TI(r,this.dracoLoader);break;case ft.KHR_TEXTURE_TRANSFORM:a[u]=new RI;break;case ft.KHR_MESH_QUANTIZATION:a[u]=new NI;break;default:d.indexOf(u)>=0&&o[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}l.setExtensions(a),l.setPlugins(o),l.parse(n,s)}parseAsync(e,t){const n=this;return new Promise(function(s,r){n.parse(e,t,s,r)})}}function hI(){let i={};return{get:function(e){return i[e]},add:function(e,t){i[e]=t},remove:function(e){delete i[e]},removeAll:function(){i={}}}}const ft={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class uI{constructor(e){this.parser=e,this.name=ft.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,s=t.length;n<s;n++){const r=t[n];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let s=t.cache.get(n);if(s)return s;const r=t.json,c=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e];let l;const h=new qe(16777215);c.color!==void 0&&h.setRGB(c.color[0],c.color[1],c.color[2],rn);const u=c.range!==void 0?c.range:0;switch(c.type){case"directional":l=new GA(h),l.target.position.set(0,0,-1),l.add(l.target);break;case"point":l=new QA(h),l.distance=u;break;case"spot":l=new Gy(h),l.distance=u,c.spot=c.spot||{},c.spot.innerConeAngle=c.spot.innerConeAngle!==void 0?c.spot.innerConeAngle:0,c.spot.outerConeAngle=c.spot.outerConeAngle!==void 0?c.spot.outerConeAngle:Math.PI/4,l.angle=c.spot.outerConeAngle,l.penumbra=1-c.spot.innerConeAngle/c.spot.outerConeAngle,l.target.position.set(0,0,-1),l.add(l.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+c.type)}return l.position.set(0,0,0),ts(l,c),c.intensity!==void 0&&(l.intensity=c.intensity),l.name=t.createUniqueName(c.name||"light_"+e),s=Promise.resolve(l),t.cache.add(n,s),s}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,r=n.json.nodes[e],o=(r.extensions&&r.extensions[this.name]||{}).light;return o===void 0?null:this._loadLight(o).then(function(c){return n._getNodeRef(t.cache,o,c)})}}class dI{constructor(){this.name=ft.KHR_MATERIALS_UNLIT}getMaterialType(){return Ss}extendParams(e,t,n){const s=[];e.color=new qe(1,1,1),e.opacity=1;const r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const a=r.baseColorFactor;e.color.setRGB(a[0],a[1],a[2],rn),e.opacity=a[3]}r.baseColorTexture!==void 0&&s.push(n.assignTexture(e,"map",r.baseColorTexture,Kt))}return Promise.all(s)}}class fI{constructor(e){this.parser=e,this.name=ft.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=s.extensions[this.name].emissiveStrength;return r!==void 0&&(t.emissiveIntensity=r),Promise.resolve()}}class pI{constructor(e){this.parser=e,this.name=ft.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Fi}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],a=s.extensions[this.name];if(a.clearcoatFactor!==void 0&&(t.clearcoat=a.clearcoatFactor),a.clearcoatTexture!==void 0&&r.push(n.assignTexture(t,"clearcoatMap",a.clearcoatTexture)),a.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=a.clearcoatRoughnessFactor),a.clearcoatRoughnessTexture!==void 0&&r.push(n.assignTexture(t,"clearcoatRoughnessMap",a.clearcoatRoughnessTexture)),a.clearcoatNormalTexture!==void 0&&(r.push(n.assignTexture(t,"clearcoatNormalMap",a.clearcoatNormalTexture)),a.clearcoatNormalTexture.scale!==void 0)){const o=a.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Ze(o,o)}return Promise.all(r)}}class AI{constructor(e){this.parser=e,this.name=ft.KHR_MATERIALS_DISPERSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Fi}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=s.extensions[this.name];return t.dispersion=r.dispersion!==void 0?r.dispersion:0,Promise.resolve()}}class gI{constructor(e){this.parser=e,this.name=ft.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Fi}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],a=s.extensions[this.name];return a.iridescenceFactor!==void 0&&(t.iridescence=a.iridescenceFactor),a.iridescenceTexture!==void 0&&r.push(n.assignTexture(t,"iridescenceMap",a.iridescenceTexture)),a.iridescenceIor!==void 0&&(t.iridescenceIOR=a.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),a.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=a.iridescenceThicknessMinimum),a.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=a.iridescenceThicknessMaximum),a.iridescenceThicknessTexture!==void 0&&r.push(n.assignTexture(t,"iridescenceThicknessMap",a.iridescenceThicknessTexture)),Promise.all(r)}}class mI{constructor(e){this.parser=e,this.name=ft.KHR_MATERIALS_SHEEN}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Fi}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[];t.sheenColor=new qe(0,0,0),t.sheenRoughness=0,t.sheen=1;const a=s.extensions[this.name];if(a.sheenColorFactor!==void 0){const o=a.sheenColorFactor;t.sheenColor.setRGB(o[0],o[1],o[2],rn)}return a.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=a.sheenRoughnessFactor),a.sheenColorTexture!==void 0&&r.push(n.assignTexture(t,"sheenColorMap",a.sheenColorTexture,Kt)),a.sheenRoughnessTexture!==void 0&&r.push(n.assignTexture(t,"sheenRoughnessMap",a.sheenRoughnessTexture)),Promise.all(r)}}class bI{constructor(e){this.parser=e,this.name=ft.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Fi}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],a=s.extensions[this.name];return a.transmissionFactor!==void 0&&(t.transmission=a.transmissionFactor),a.transmissionTexture!==void 0&&r.push(n.assignTexture(t,"transmissionMap",a.transmissionTexture)),Promise.all(r)}}class xI{constructor(e){this.parser=e,this.name=ft.KHR_MATERIALS_VOLUME}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Fi}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],a=s.extensions[this.name];t.thickness=a.thicknessFactor!==void 0?a.thicknessFactor:0,a.thicknessTexture!==void 0&&r.push(n.assignTexture(t,"thicknessMap",a.thicknessTexture)),t.attenuationDistance=a.attenuationDistance||1/0;const o=a.attenuationColor||[1,1,1];return t.attenuationColor=new qe().setRGB(o[0],o[1],o[2],rn),Promise.all(r)}}class _I{constructor(e){this.parser=e,this.name=ft.KHR_MATERIALS_IOR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Fi}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=s.extensions[this.name];return t.ior=r.ior!==void 0?r.ior:1.5,Promise.resolve()}}class EI{constructor(e){this.parser=e,this.name=ft.KHR_MATERIALS_SPECULAR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Fi}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],a=s.extensions[this.name];t.specularIntensity=a.specularFactor!==void 0?a.specularFactor:1,a.specularTexture!==void 0&&r.push(n.assignTexture(t,"specularIntensityMap",a.specularTexture));const o=a.specularColorFactor||[1,1,1];return t.specularColor=new qe().setRGB(o[0],o[1],o[2],rn),a.specularColorTexture!==void 0&&r.push(n.assignTexture(t,"specularColorMap",a.specularColorTexture,Kt)),Promise.all(r)}}class yI{constructor(e){this.parser=e,this.name=ft.EXT_MATERIALS_BUMP}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Fi}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],a=s.extensions[this.name];return t.bumpScale=a.bumpFactor!==void 0?a.bumpFactor:1,a.bumpTexture!==void 0&&r.push(n.assignTexture(t,"bumpMap",a.bumpTexture)),Promise.all(r)}}class wI{constructor(e){this.parser=e,this.name=ft.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Fi}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],a=s.extensions[this.name];return a.anisotropyStrength!==void 0&&(t.anisotropy=a.anisotropyStrength),a.anisotropyRotation!==void 0&&(t.anisotropyRotation=a.anisotropyRotation),a.anisotropyTexture!==void 0&&r.push(n.assignTexture(t,"anisotropyMap",a.anisotropyTexture)),Promise.all(r)}}class vI{constructor(e){this.parser=e,this.name=ft.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,s=n.textures[e];if(!s.extensions||!s.extensions[this.name])return null;const r=s.extensions[this.name],a=t.options.ktx2Loader;if(!a){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,a)}}class CI{constructor(e){this.parser=e,this.name=ft.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,n=this.parser,s=n.json,r=s.textures[e];if(!r.extensions||!r.extensions[t])return null;const a=r.extensions[t],o=s.images[a.source];let c=n.textureLoader;if(o.uri){const l=n.options.manager.getHandler(o.uri);l!==null&&(c=l)}return n.loadTextureImage(e,a.source,c)}}class SI{constructor(e){this.parser=e,this.name=ft.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,n=this.parser,s=n.json,r=s.textures[e];if(!r.extensions||!r.extensions[t])return null;const a=r.extensions[t],o=s.images[a.source];let c=n.textureLoader;if(o.uri){const l=n.options.manager.getHandler(o.uri);l!==null&&(c=l)}return n.loadTextureImage(e,a.source,c)}}class II{constructor(e){this.name=ft.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const s=n.extensions[this.name],r=this.parser.getDependency("buffer",s.buffer),a=this.parser.options.meshoptDecoder;if(!a||!a.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then(function(o){const c=s.byteOffset||0,l=s.byteLength||0,h=s.count,u=s.byteStride,d=new Uint8Array(o,c,l);return a.decodeGltfBufferAsync?a.decodeGltfBufferAsync(h,u,d,s.mode,s.filter).then(function(f){return f.buffer}):a.ready.then(function(){const f=new ArrayBuffer(h*u);return a.decodeGltfBuffer(new Uint8Array(f),h,u,d,s.mode,s.filter),f})})}else return null}}class MI{constructor(e){this.name=ft.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const s=t.meshes[n.mesh];for(const l of s.primitives)if(l.mode!==ei.TRIANGLES&&l.mode!==ei.TRIANGLE_STRIP&&l.mode!==ei.TRIANGLE_FAN&&l.mode!==void 0)return null;const a=n.extensions[this.name].attributes,o=[],c={};for(const l in a)o.push(this.parser.getDependency("accessor",a[l]).then(h=>(c[l]=h,c[l])));return o.length<1?null:(o.push(this.parser.createNodeMesh(e)),Promise.all(o).then(l=>{const h=l.pop(),u=h.isGroup?h.children:[h],d=l[0].count,f=[];for(const m of u){const A=new $e,g=new H,p=new Wn,y=new H(1,1,1),b=new vA(m.geometry,m.material,d);for(let E=0;E<d;E++)c.TRANSLATION&&g.fromBufferAttribute(c.TRANSLATION,E),c.ROTATION&&p.fromBufferAttribute(c.ROTATION,E),c.SCALE&&y.fromBufferAttribute(c.SCALE,E),b.setMatrixAt(E,A.compose(g,p,y));for(const E in c)if(E==="_COLOR_0"){const M=c[E];b.instanceColor=new Lu(M.array,M.itemSize,M.normalized)}else E!=="TRANSLATION"&&E!=="ROTATION"&&E!=="SCALE"&&m.geometry.setAttribute(E,c[E]);Pt.prototype.copy.call(b,m),this.parser.assignFinalMaterial(b),f.push(b)}return h.isGroup?(h.clear(),h.add(...f),h):f[0]}))}}const vg="glTF",vo=12,Cg={JSON:1313821514,BIN:5130562};class BI{constructor(e){this.name=ft.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,vo),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==vg)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const s=this.header.length-vo,r=new DataView(e,vo);let a=0;for(;a<s;){const o=r.getUint32(a,!0);a+=4;const c=r.getUint32(a,!0);if(a+=4,c===Cg.JSON){const l=new Uint8Array(e,vo+a,o);this.content=n.decode(l)}else if(c===Cg.BIN){const l=vo+a;this.body=e.slice(l,l+o)}a+=o}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class TI{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=ft.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,s=this.dracoLoader,r=e.extensions[this.name].bufferView,a=e.extensions[this.name].attributes,o={},c={},l={};for(const h in a){const u=rd[h]||h.toLowerCase();o[u]=a[h]}for(const h in e.attributes){const u=rd[h]||h.toLowerCase();if(a[h]!==void 0){const d=n.accessors[e.attributes[h]],f=ga[d.componentType];l[u]=f.name,c[u]=d.normalized===!0}}return t.getDependency("bufferView",r).then(function(h){return new Promise(function(u,d){s.decodeDracoFile(h,function(f){for(const m in f.attributes){const A=f.attributes[m],g=c[m];g!==void 0&&(A.normalized=g)}u(f)},o,l,rn,d)})})}}class RI{constructor(){this.name=ft.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class NI{constructor(){this.name=ft.KHR_MESH_QUANTIZATION}}class Sg extends xo{constructor(e,t,n,s){super(e,t,n,s)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,s=this.valueSize,r=e*s*3+s;for(let a=0;a!==s;a++)t[a]=n[r+a];return t}interpolate_(e,t,n,s){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=o*2,l=o*3,h=s-t,u=(n-t)/h,d=u*u,f=d*u,m=e*l,A=m-l,g=-2*f+3*d,p=f-d,y=1-g,b=p-d+u;for(let E=0;E!==o;E++){const M=a[A+E+o],w=a[A+E+c]*h,S=a[m+E+o],T=a[m+E]*h;r[E]=y*M+b*w+g*S+p*T}return r}}const FI=new Wn;class DI extends Sg{interpolate_(e,t,n,s){const r=super.interpolate_(e,t,n,s);return FI.fromArray(r).normalize().toArray(r),r}}const ei={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},ga={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Ig={9728:Mn,9729:zt,9984:Cp,9985:Ac,9986:Ka,9987:Zn},Mg={33071:ci,33648:pc,10497:Qr},sd={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},rd={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Ns={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},LI={CUBICSPLINE:void 0,LINEAR:so,STEP:io},ad={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function PI(i){return i.DefaultMaterial===void 0&&(i.DefaultMaterial=new bo({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:Hi})),i.DefaultMaterial}function lr(i,e,t){for(const n in t.extensions)i[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function ts(i,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(i.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function kI(i,e,t){let n=!1,s=!1,r=!1;for(let l=0,h=e.length;l<h;l++){const u=e[l];if(u.POSITION!==void 0&&(n=!0),u.NORMAL!==void 0&&(s=!0),u.COLOR_0!==void 0&&(r=!0),n&&s&&r)break}if(!n&&!s&&!r)return Promise.resolve(i);const a=[],o=[],c=[];for(let l=0,h=e.length;l<h;l++){const u=e[l];if(n){const d=u.POSITION!==void 0?t.getDependency("accessor",u.POSITION):i.attributes.position;a.push(d)}if(s){const d=u.NORMAL!==void 0?t.getDependency("accessor",u.NORMAL):i.attributes.normal;o.push(d)}if(r){const d=u.COLOR_0!==void 0?t.getDependency("accessor",u.COLOR_0):i.attributes.color;c.push(d)}}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(c)]).then(function(l){const h=l[0],u=l[1],d=l[2];return n&&(i.morphAttributes.position=h),s&&(i.morphAttributes.normal=u),r&&(i.morphAttributes.color=d),i.morphTargetsRelative=!0,i})}function UI(i,e){if(i.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)i.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(i.morphTargetInfluences.length===t.length){i.morphTargetDictionary={};for(let n=0,s=t.length;n<s;n++)i.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function OI(i){let e;const t=i.extensions&&i.extensions[ft.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+od(t.attributes):e=i.indices+":"+od(i.attributes)+":"+i.mode,i.targets!==void 0)for(let n=0,s=i.targets.length;n<s;n++)e+=":"+od(i.targets[n]);return e}function od(i){let e="";const t=Object.keys(i).sort();for(let n=0,s=t.length;n<s;n++)e+=t[n]+":"+i[t[n]]+";";return e}function cd(i){switch(i){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function QI(i){return i.search(/\.jpe?g($|\?)/i)>0||i.search(/^data\:image\/jpeg/)===0?"image/jpeg":i.search(/\.webp($|\?)/i)>0||i.search(/^data\:image\/webp/)===0?"image/webp":i.search(/\.ktx2($|\?)/i)>0||i.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const GI=new $e;class HI{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new hI,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,s=-1,r=!1,a=-1;if(typeof navigator<"u"){const o=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(o)===!0;const c=o.match(/Version\/(\d+)/);s=n&&c?parseInt(c[1],10):-1,r=o.indexOf("Firefox")>-1,a=r?o.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||n&&s<17||r&&a<98?this.textureLoader=new Uy(this.options.manager):this.textureLoader=new Wy(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Ts(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,s=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(a){return a._markDefs&&a._markDefs()}),Promise.all(this._invokeAll(function(a){return a.beforeRoot&&a.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(a){const o={scene:a[0][s.scene||0],scenes:a[0],animations:a[1],cameras:a[2],asset:s.asset,parser:n,userData:{}};return lr(r,o,s),ts(o,s),Promise.all(n._invokeAll(function(c){return c.afterRoot&&c.afterRoot(o)})).then(function(){for(const c of o.scenes)c.updateMatrixWorld();e(o)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let s=0,r=t.length;s<r;s++){const a=t[s].joints;for(let o=0,c=a.length;o<c;o++)e[a[o]].isBone=!0}for(let s=0,r=e.length;s<r;s++){const a=e[s];a.mesh!==void 0&&(this._addNodeRef(this.meshCache,a.mesh),a.skin!==void 0&&(n[a.mesh].isSkinnedMesh=!0)),a.camera!==void 0&&this._addNodeRef(this.cameraCache,a.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const s=n.clone(),r=(a,o)=>{const c=this.associations.get(a);c!=null&&this.associations.set(o,c);for(const[l,h]of a.children.entries())r(h,o.children[l])};return r(n,s),s.name+="_instance_"+e.uses[t]++,s}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const s=e(t[n]);if(s)return s}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let s=0;s<t.length;s++){const r=e(t[s]);r&&n.push(r)}return n}getDependency(e,t){const n=e+":"+t;let s=this.cache.get(n);if(!s){switch(e){case"scene":s=this.loadScene(t);break;case"node":s=this._invokeOne(function(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":s=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":s=this.loadAccessor(t);break;case"bufferView":s=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":s=this.loadBuffer(t);break;case"material":s=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":s=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":s=this.loadSkin(t);break;case"animation":s=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":s=this.loadCamera(t);break;default:if(s=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)}),!s)throw new Error("Unknown type: "+e);break}this.cache.add(n,s)}return s}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,s=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(s.map(function(r,a){return n.getDependency(e,a)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[ft.KHR_BINARY_GLTF].body);const s=this.options;return new Promise(function(r,a){n.load(da.resolveURL(t.uri,s.path),r,void 0,function(){a(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){const s=t.byteLength||0,r=t.byteOffset||0;return n.slice(r,r+s)})}loadAccessor(e){const t=this,n=this.json,s=this.json.accessors[e];if(s.bufferView===void 0&&s.sparse===void 0){const a=sd[s.type],o=ga[s.componentType],c=s.normalized===!0,l=new o(s.count*a);return Promise.resolve(new _n(l,a,c))}const r=[];return s.bufferView!==void 0?r.push(this.getDependency("bufferView",s.bufferView)):r.push(null),s.sparse!==void 0&&(r.push(this.getDependency("bufferView",s.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",s.sparse.values.bufferView))),Promise.all(r).then(function(a){const o=a[0],c=sd[s.type],l=ga[s.componentType],h=l.BYTES_PER_ELEMENT,u=h*c,d=s.byteOffset||0,f=s.bufferView!==void 0?n.bufferViews[s.bufferView].byteStride:void 0,m=s.normalized===!0;let A,g;if(f&&f!==u){const p=Math.floor(d/f),y="InterleavedBuffer:"+s.bufferView+":"+s.componentType+":"+p+":"+s.count;let b=t.cache.get(y);b||(A=new l(o,p*f,s.count*f/h),b=new py(A,f/h),t.cache.add(y,b)),g=new Ru(b,c,d%f/h,m)}else o===null?A=new l(s.count*c):A=new l(o,d,s.count*c),g=new _n(A,c,m);if(s.sparse!==void 0){const p=sd.SCALAR,y=ga[s.sparse.indices.componentType],b=s.sparse.indices.byteOffset||0,E=s.sparse.values.byteOffset||0,M=new y(a[1],b,s.sparse.count*p),w=new l(a[2],E,s.sparse.count*c);o!==null&&(g=new _n(g.array.slice(),g.itemSize,g.normalized)),g.normalized=!1;for(let S=0,T=M.length;S<T;S++){const C=M[S];if(g.setX(C,w[S*c]),c>=2&&g.setY(C,w[S*c+1]),c>=3&&g.setZ(C,w[S*c+2]),c>=4&&g.setW(C,w[S*c+3]),c>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}g.normalized=m}return g})}loadTexture(e){const t=this.json,n=this.options,r=t.textures[e].source,a=t.images[r];let o=this.textureLoader;if(a.uri){const c=n.manager.getHandler(a.uri);c!==null&&(o=c)}return this.loadTextureImage(e,r,o)}loadTextureImage(e,t,n){const s=this,r=this.json,a=r.textures[e],o=r.images[t],c=(o.uri||o.bufferView)+":"+a.sampler;if(this.textureCache[c])return this.textureCache[c];const l=this.loadImageSource(t,n).then(function(h){h.flipY=!1,h.name=a.name||o.name||"",h.name===""&&typeof o.uri=="string"&&o.uri.startsWith("data:image/")===!1&&(h.name=o.uri);const d=(r.samplers||{})[a.sampler]||{};return h.magFilter=Ig[d.magFilter]||zt,h.minFilter=Ig[d.minFilter]||Zn,h.wrapS=Mg[d.wrapS]||Qr,h.wrapT=Mg[d.wrapT]||Qr,h.generateMipmaps=!h.isCompressedTexture&&h.minFilter!==Mn&&h.minFilter!==zt,s.associations.set(h,{textures:e}),h}).catch(function(){return null});return this.textureCache[c]=l,l}loadImageSource(e,t){const n=this,s=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(u=>u.clone());const a=s.images[e],o=self.URL||self.webkitURL;let c=a.uri||"",l=!1;if(a.bufferView!==void 0)c=n.getDependency("bufferView",a.bufferView).then(function(u){l=!0;const d=new Blob([u],{type:a.mimeType});return c=o.createObjectURL(d),c});else if(a.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const h=Promise.resolve(c).then(function(u){return new Promise(function(d,f){let m=d;t.isImageBitmapLoader===!0&&(m=function(A){const g=new an(A);g.needsUpdate=!0,d(g)}),t.load(da.resolveURL(u,r.path),m,void 0,f)})}).then(function(u){return l===!0&&o.revokeObjectURL(c),ts(u,a),u.userData.mimeType=a.mimeType||QI(a.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",c),u});return this.sourceCache[e]=h,h}assignTexture(e,t,n,s){const r=this;return this.getDependency("texture",n.index).then(function(a){if(!a)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(a=a.clone(),a.channel=n.texCoord),r.extensions[ft.KHR_TEXTURE_TRANSFORM]){const o=n.extensions!==void 0?n.extensions[ft.KHR_TEXTURE_TRANSFORM]:void 0;if(o){const c=r.associations.get(a);a=r.extensions[ft.KHR_TEXTURE_TRANSFORM].extendTexture(a,o),r.associations.set(a,c)}}return s!==void 0&&(a.colorSpace=s),e[t]=a,a})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const s=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,a=t.attributes.normal===void 0;if(e.isPoints){const o="PointsMaterial:"+n.uuid;let c=this.cache.get(o);c||(c=new Qu,Ni.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,c.sizeAttenuation=!1,this.cache.add(o,c)),n=c}else if(e.isLine){const o="LineBasicMaterial:"+n.uuid;let c=this.cache.get(o);c||(c=new go,Ni.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,this.cache.add(o,c)),n=c}if(s||r||a){let o="ClonedMaterial:"+n.uuid+":";s&&(o+="derivative-tangents:"),r&&(o+="vertex-colors:"),a&&(o+="flat-shading:");let c=this.cache.get(o);c||(c=n.clone(),r&&(c.vertexColors=!0),a&&(c.flatShading=!0),s&&(c.normalScale&&(c.normalScale.y*=-1),c.clearcoatNormalScale&&(c.clearcoatNormalScale.y*=-1)),this.cache.add(o,c),this.associations.set(c,this.associations.get(n))),n=c}e.material=n}getMaterialType(){return bo}loadMaterial(e){const t=this,n=this.json,s=this.extensions,r=n.materials[e];let a;const o={},c=r.extensions||{},l=[];if(c[ft.KHR_MATERIALS_UNLIT]){const u=s[ft.KHR_MATERIALS_UNLIT];a=u.getMaterialType(),l.push(u.extendParams(o,r,t))}else{const u=r.pbrMetallicRoughness||{};if(o.color=new qe(1,1,1),o.opacity=1,Array.isArray(u.baseColorFactor)){const d=u.baseColorFactor;o.color.setRGB(d[0],d[1],d[2],rn),o.opacity=d[3]}u.baseColorTexture!==void 0&&l.push(t.assignTexture(o,"map",u.baseColorTexture,Kt)),o.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,o.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(l.push(t.assignTexture(o,"metalnessMap",u.metallicRoughnessTexture)),l.push(t.assignTexture(o,"roughnessMap",u.metallicRoughnessTexture))),a=this._invokeOne(function(d){return d.getMaterialType&&d.getMaterialType(e)}),l.push(Promise.all(this._invokeAll(function(d){return d.extendMaterialParams&&d.extendMaterialParams(e,o)})))}r.doubleSided===!0&&(o.side=Bi);const h=r.alphaMode||ad.OPAQUE;if(h===ad.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,h===ad.MASK&&(o.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&a!==Ss&&(l.push(t.assignTexture(o,"normalMap",r.normalTexture)),o.normalScale=new Ze(1,1),r.normalTexture.scale!==void 0)){const u=r.normalTexture.scale;o.normalScale.set(u,u)}if(r.occlusionTexture!==void 0&&a!==Ss&&(l.push(t.assignTexture(o,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(o.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&a!==Ss){const u=r.emissiveFactor;o.emissive=new qe().setRGB(u[0],u[1],u[2],rn)}return r.emissiveTexture!==void 0&&a!==Ss&&l.push(t.assignTexture(o,"emissiveMap",r.emissiveTexture,Kt)),Promise.all(l).then(function(){const u=new a(o);return r.name&&(u.name=r.name),ts(u,r),t.associations.set(u,{materials:e}),r.extensions&&lr(s,u,r),u})}createUniqueName(e){const t=vt.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,s=this.primitiveCache;function r(o){return n[ft.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,t).then(function(c){return Bg(c,o,t)})}const a=[];for(let o=0,c=e.length;o<c;o++){const l=e[o],h=OI(l),u=s[h];if(u)a.push(u.promise);else{let d;l.extensions&&l.extensions[ft.KHR_DRACO_MESH_COMPRESSION]?d=r(l):d=Bg(new Qn,l,t),s[h]={primitive:l,promise:d},a.push(d)}}return Promise.all(a)}loadMesh(e){const t=this,n=this.json,s=this.extensions,r=n.meshes[e],a=r.primitives,o=[];for(let c=0,l=a.length;c<l;c++){const h=a[c].material===void 0?PI(this.cache):this.getDependency("material",a[c].material);o.push(h)}return o.push(t.loadGeometries(a)),Promise.all(o).then(function(c){const l=c.slice(0,c.length-1),h=c[c.length-1],u=[];for(let f=0,m=h.length;f<m;f++){const A=h[f],g=a[f];let p;const y=l[f];if(g.mode===ei.TRIANGLES||g.mode===ei.TRIANGLE_STRIP||g.mode===ei.TRIANGLE_FAN||g.mode===void 0)p=r.isSkinnedMesh===!0?new gy(A,y):new Jt(A,y),p.isSkinnedMesh===!0&&p.normalizeSkinWeights(),g.mode===ei.TRIANGLE_STRIP?p.geometry=yg(p.geometry,Dp):g.mode===ei.TRIANGLE_FAN&&(p.geometry=yg(p.geometry,au));else if(g.mode===ei.LINES)p=new Zc(A,y);else if(g.mode===ei.LINE_STRIP)p=new Ou(A,y);else if(g.mode===ei.LINE_LOOP)p=new Ey(A,y);else if(g.mode===ei.POINTS)p=new yy(A,y);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+g.mode);Object.keys(p.geometry.morphAttributes).length>0&&UI(p,r),p.name=t.createUniqueName(r.name||"mesh_"+e),ts(p,r),g.extensions&&lr(s,p,g),t.assignFinalMaterial(p),u.push(p)}for(let f=0,m=u.length;f<m;f++)t.associations.set(u[f],{meshes:e,primitives:f});if(u.length===1)return r.extensions&&lr(s,u[0],r),u[0];const d=new ir;r.extensions&&lr(s,d,r),t.associations.set(d,{meshes:e});for(let f=0,m=u.length;f<m;f++)d.add(u[f]);return d})}loadCamera(e){let t;const n=this.json.cameras[e],s=n[n.type];if(!s){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new Cn(Qp.radToDeg(s.yfov),s.aspectRatio||1,s.znear||1,s.zfar||2e6):n.type==="orthographic"&&(t=new Wu(-s.xmag,s.xmag,s.ymag,-s.ymag,s.znear,s.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),ts(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let s=0,r=t.joints.length;s<r;s++)n.push(this._loadNodeShallow(t.joints[s]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(s){const r=s.pop(),a=s,o=[],c=[];for(let l=0,h=a.length;l<h;l++){const u=a[l];if(u){o.push(u);const d=new $e;r!==null&&d.fromArray(r.array,l*16),c.push(d)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[l])}return new Du(o,c)})}loadAnimation(e){const t=this.json,n=this,s=t.animations[e],r=s.name?s.name:"animation_"+e,a=[],o=[],c=[],l=[],h=[];for(let u=0,d=s.channels.length;u<d;u++){const f=s.channels[u],m=s.samplers[f.sampler],A=f.target,g=A.node,p=s.parameters!==void 0?s.parameters[m.input]:m.input,y=s.parameters!==void 0?s.parameters[m.output]:m.output;A.node!==void 0&&(a.push(this.getDependency("node",g)),o.push(this.getDependency("accessor",p)),c.push(this.getDependency("accessor",y)),l.push(m),h.push(A))}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(c),Promise.all(l),Promise.all(h)]).then(function(u){const d=u[0],f=u[1],m=u[2],A=u[3],g=u[4],p=[];for(let y=0,b=d.length;y<b;y++){const E=d[y],M=f[y],w=m[y],S=A[y],T=g[y];if(E===void 0)continue;E.updateMatrix&&E.updateMatrix();const C=n._createAnimationTracks(E,M,w,S,T);if(C)for(let v=0;v<C.length;v++)p.push(C[v])}return new sl(r,void 0,p)})}createNodeMesh(e){const t=this.json,n=this,s=t.nodes[e];return s.mesh===void 0?null:n.getDependency("mesh",s.mesh).then(function(r){const a=n._getNodeRef(n.meshCache,s.mesh,r);return s.weights!==void 0&&a.traverse(function(o){if(o.isMesh)for(let c=0,l=s.weights.length;c<l;c++)o.morphTargetInfluences[c]=s.weights[c]}),a})}loadNode(e){const t=this.json,n=this,s=t.nodes[e],r=n._loadNodeShallow(e),a=[],o=s.children||[];for(let l=0,h=o.length;l<h;l++)a.push(n.getDependency("node",o[l]));const c=s.skin===void 0?Promise.resolve(null):n.getDependency("skin",s.skin);return Promise.all([r,Promise.all(a),c]).then(function(l){const h=l[0],u=l[1],d=l[2];d!==null&&h.traverse(function(f){f.isSkinnedMesh&&f.bind(d,GI)});for(let f=0,m=u.length;f<m;f++)h.add(u[f]);return h})}_loadNodeShallow(e){const t=this.json,n=this.extensions,s=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const r=t.nodes[e],a=r.name?s.createUniqueName(r.name):"",o=[],c=s._invokeOne(function(l){return l.createNodeMesh&&l.createNodeMesh(e)});return c&&o.push(c),r.camera!==void 0&&o.push(s.getDependency("camera",r.camera).then(function(l){return s._getNodeRef(s.cameraCache,r.camera,l)})),s._invokeAll(function(l){return l.createNodeAttachment&&l.createNodeAttachment(e)}).forEach(function(l){o.push(l)}),this.nodeCache[e]=Promise.all(o).then(function(l){let h;if(r.isBone===!0?h=new _A:l.length>1?h=new ir:l.length===1?h=l[0]:h=new Pt,h!==l[0])for(let u=0,d=l.length;u<d;u++)h.add(l[u]);if(r.name&&(h.userData.name=r.name,h.name=a),ts(h,r),r.extensions&&lr(n,h,r),r.matrix!==void 0){const u=new $e;u.fromArray(r.matrix),h.applyMatrix4(u)}else r.translation!==void 0&&h.position.fromArray(r.translation),r.rotation!==void 0&&h.quaternion.fromArray(r.rotation),r.scale!==void 0&&h.scale.fromArray(r.scale);return s.associations.has(h)||s.associations.set(h,{}),s.associations.get(h).nodes=e,h}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],s=this,r=new ir;n.name&&(r.name=s.createUniqueName(n.name)),ts(r,n),n.extensions&&lr(t,r,n);const a=n.nodes||[],o=[];for(let c=0,l=a.length;c<l;c++)o.push(s.getDependency("node",a[c]));return Promise.all(o).then(function(c){for(let h=0,u=c.length;h<u;h++)r.add(c[h]);const l=h=>{const u=new Map;for(const[d,f]of s.associations)(d instanceof Ni||d instanceof an)&&u.set(d,f);return h.traverse(d=>{const f=s.associations.get(d);f!=null&&u.set(d,f)}),u};return s.associations=l(r),r})}_createAnimationTracks(e,t,n,s,r){const a=[],o=e.name?e.name:e.uuid,c=[];Ns[r.path]===Ns.weights?e.traverse(function(d){d.morphTargetInfluences&&c.push(d.name?d.name:d.uuid)}):c.push(o);let l;switch(Ns[r.path]){case Ns.weights:l=ca;break;case Ns.rotation:l=la;break;case Ns.translation:case Ns.scale:l=ua;break;default:n.itemSize===1?l=ca:l=ua;break}const h=s.interpolation!==void 0?LI[s.interpolation]:so,u=this._getArrayFromAccessor(n);for(let d=0,f=c.length;d<f;d++){const m=new l(c[d]+"."+Ns[r.path],t.array,u,h);s.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(m),a.push(m)}return a}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=cd(t.constructor),s=new Float32Array(t.length);for(let r=0,a=t.length;r<a;r++)s[r]=t[r]*n;t=s}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){const s=this instanceof la?DI:Sg;return new s(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function zI(i,e,t){const n=e.attributes,s=new di;if(n.POSITION!==void 0){const o=t.json.accessors[n.POSITION],c=o.min,l=o.max;if(c!==void 0&&l!==void 0){if(s.set(new H(c[0],c[1],c[2]),new H(l[0],l[1],l[2])),o.normalized){const h=cd(ga[o.componentType]);s.min.multiplyScalar(h),s.max.multiplyScalar(h)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const r=e.targets;if(r!==void 0){const o=new H,c=new H;for(let l=0,h=r.length;l<h;l++){const u=r[l];if(u.POSITION!==void 0){const d=t.json.accessors[u.POSITION],f=d.min,m=d.max;if(f!==void 0&&m!==void 0){if(c.setX(Math.max(Math.abs(f[0]),Math.abs(m[0]))),c.setY(Math.max(Math.abs(f[1]),Math.abs(m[1]))),c.setZ(Math.max(Math.abs(f[2]),Math.abs(m[2]))),d.normalized){const A=cd(ga[d.componentType]);c.multiplyScalar(A)}o.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}s.expandByVector(o)}i.boundingBox=s;const a=new Ti;s.getCenter(a.center),a.radius=s.min.distanceTo(s.max)/2,i.boundingSphere=a}function Bg(i,e,t){const n=e.attributes,s=[];function r(a,o){return t.getDependency("accessor",a).then(function(c){i.setAttribute(o,c)})}for(const a in n){const o=rd[a]||a.toLowerCase();o in i.attributes||s.push(r(n[a],o))}if(e.indices!==void 0&&!i.index){const a=t.getDependency("accessor",e.indices).then(function(o){i.setIndex(o)});s.push(a)}return At.workingColorSpace!==rn&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${At.workingColorSpace}" not supported.`),ts(i,e),zI(i,e,t),Promise.all(s).then(function(){return e.targets!==void 0?kI(i,e.targets,t):i})}const Tg={type:"change"},ld={type:"start"},Rg={type:"end"},ul=new ho,Ng=new Bs,VI=Math.cos(70*Qp.DEG2RAD),ln=new H,Gn=2*Math.PI,Bt={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},hd=1e-6;class WI extends ow{constructor(e,t=null){super(e,t),this.state=Bt.NONE,this.target=new H,this.cursor=new H,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:Lr.ROTATE,MIDDLE:Lr.DOLLY,RIGHT:Lr.PAN},this.touches={ONE:Pr.ROTATE,TWO:Pr.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new H,this._lastQuaternion=new Wn,this._lastTargetPosition=new H,this._quat=new Wn().setFromUnitVectors(e.up,new H(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new zA,this._sphericalDelta=new zA,this._scale=1,this._panOffset=new H,this._rotateStart=new Ze,this._rotateEnd=new Ze,this._rotateDelta=new Ze,this._panStart=new Ze,this._panEnd=new Ze,this._panDelta=new Ze,this._dollyStart=new Ze,this._dollyEnd=new Ze,this._dollyDelta=new Ze,this._dollyDirection=new H,this._mouse=new Ze,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=KI.bind(this),this._onPointerDown=qI.bind(this),this._onPointerUp=jI.bind(this),this._onContextMenu=t1.bind(this),this._onMouseWheel=JI.bind(this),this._onKeyDown=ZI.bind(this),this._onTouchStart=$I.bind(this),this._onTouchMove=e1.bind(this),this._onMouseDown=XI.bind(this),this._onMouseMove=YI.bind(this),this._interceptControlDown=n1.bind(this),this._interceptControlUp=i1.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(Tg),this.update(),this.state=Bt.NONE}update(e=null){const t=this.object.position;ln.copy(t).sub(this.target),ln.applyQuaternion(this._quat),this._spherical.setFromVector3(ln),this.autoRotate&&this.state===Bt.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,s=this.maxAzimuthAngle;isFinite(n)&&isFinite(s)&&(n<-Math.PI?n+=Gn:n>Math.PI&&(n-=Gn),s<-Math.PI?s+=Gn:s>Math.PI&&(s-=Gn),n<=s?this._spherical.theta=Math.max(n,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+s)/2?Math.max(n,this._spherical.theta):Math.min(s,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 r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=a!=this._spherical.radius}if(ln.setFromSpherical(this._spherical),ln.applyQuaternion(this._quatInverse),t.copy(this.target).add(ln),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 a=null;if(this.object.isPerspectiveCamera){const o=ln.length();a=this._clampDistance(o*this._scale);const c=o-a;this.object.position.addScaledVector(this._dollyDirection,c),this.object.updateMatrixWorld(),r=!!c}else if(this.object.isOrthographicCamera){const o=new H(this._mouse.x,this._mouse.y,0);o.unproject(this.object);const c=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=c!==this.object.zoom;const l=new H(this._mouse.x,this._mouse.y,0);l.unproject(this.object),this.object.position.sub(l).add(o),this.object.updateMatrixWorld(),a=ln.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(ul.origin.copy(this.object.position),ul.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(ul.direction))<VI?this.object.lookAt(this.target):(Ng.setFromNormalAndCoplanarPoint(this.object.up,this.target),ul.intersectPlane(Ng,this.target))))}else if(this.object.isOrthographicCamera){const a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),a!==this.object.zoom&&(this.object.updateProjectionMatrix(),r=!0)}return this._scale=1,this._performCursorZoom=!1,r||this._lastPosition.distanceToSquared(this.object.position)>hd||8*(1-this._lastQuaternion.dot(this.object.quaternion))>hd||this._lastTargetPosition.distanceToSquared(this.target)>hd?(this.dispatchEvent(Tg),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Gn/60*this.autoRotateSpeed*e:Gn/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){ln.setFromMatrixColumn(t,0),ln.multiplyScalar(-e),this._panOffset.add(ln)}_panUp(e,t){this.screenSpacePanning===!0?ln.setFromMatrixColumn(t,1):(ln.setFromMatrixColumn(t,0),ln.crossVectors(this.object.up,ln)),ln.multiplyScalar(e),this._panOffset.add(ln)}_pan(e,t){const n=this.domElement;if(this.object.isPerspectiveCamera){const s=this.object.position;ln.copy(s).sub(this.target);let r=ln.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/n.clientHeight,this.object.matrix),this._panUp(2*t*r/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;const n=this.domElement.getBoundingClientRect(),s=e-n.left,r=t-n.top,a=n.width,o=n.height;this._mouse.x=s/a*2-1,this._mouse.y=-(r/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Gn*this._rotateDelta.x/t.clientHeight),this._rotateUp(Gn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(Gn*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(-Gn*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(Gn*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(-Gn*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._rotateStart.set(n,s)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panStart.set(n,s)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(n*n+s*s);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),s=.5*(e.pageX+n.x),r=.5*(e.pageY+n.y);this._rotateEnd.set(s,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Gn*this._rotateDelta.x/t.clientHeight),this._rotateUp(Gn*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{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panEnd.set(n,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(n*n+s*s);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const 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 Ze,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){const 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;break}return e.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}}function qI(i){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(i.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(i)&&(this._addPointer(i),i.pointerType==="touch"?this._onTouchStart(i):this._onMouseDown(i)))}function KI(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchMove(i):this._onMouseMove(i))}function jI(i){switch(this._removePointer(i),this._pointers.length){case 0:this.domElement.releasePointerCapture(i.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(Rg),this.state=Bt.NONE;break;case 1:const e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function XI(i){let e;switch(i.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case Lr.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(i),this.state=Bt.DOLLY;break;case Lr.ROTATE:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=Bt.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=Bt.ROTATE}break;case Lr.PAN:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=Bt.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=Bt.PAN}break;default:this.state=Bt.NONE}this.state!==Bt.NONE&&this.dispatchEvent(ld)}function YI(i){switch(this.state){case Bt.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(i);break;case Bt.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(i);break;case Bt.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(i);break}}function JI(i){this.enabled===!1||this.enableZoom===!1||this.state!==Bt.NONE||(i.preventDefault(),this.dispatchEvent(ld),this._handleMouseWheel(this._customWheelEvent(i)),this.dispatchEvent(Rg))}function ZI(i){this.enabled!==!1&&this._handleKeyDown(i)}function $I(i){switch(this._trackPointer(i),this._pointers.length){case 1:switch(this.touches.ONE){case Pr.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(i),this.state=Bt.TOUCH_ROTATE;break;case Pr.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(i),this.state=Bt.TOUCH_PAN;break;default:this.state=Bt.NONE}break;case 2:switch(this.touches.TWO){case Pr.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(i),this.state=Bt.TOUCH_DOLLY_PAN;break;case Pr.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(i),this.state=Bt.TOUCH_DOLLY_ROTATE;break;default:this.state=Bt.NONE}break;default:this.state=Bt.NONE}this.state!==Bt.NONE&&this.dispatchEvent(ld)}function e1(i){switch(this._trackPointer(i),this.state){case Bt.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(i),this.update();break;case Bt.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(i),this.update();break;case Bt.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(i),this.update();break;case Bt.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(i),this.update();break;default:this.state=Bt.NONE}}function t1(i){this.enabled!==!1&&i.preventDefault()}function n1(i){i.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function i1(i){i.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}class s1 extends Tu{constructor(){super();const e=new na;e.deleteAttribute("uv");const t=new bo({side:In}),n=new bo,s=new QA(16777215,900,28,2);s.position.set(.418,16.199,.3),this.add(s);const r=new Jt(e,t);r.position.set(-.757,13.219,.717),r.scale.set(31.713,28.305,28.591),this.add(r);const a=new vA(e,n,6),o=new Pt;o.position.set(-10.906,2.009,1.846),o.rotation.set(0,-.195,0),o.scale.set(2.328,7.905,4.651),o.updateMatrix(),a.setMatrixAt(0,o.matrix),o.position.set(-5.607,-.754,-.758),o.rotation.set(0,.994,0),o.scale.set(1.97,1.534,3.955),o.updateMatrix(),a.setMatrixAt(1,o.matrix),o.position.set(6.167,.857,7.803),o.rotation.set(0,.561,0),o.scale.set(3.927,6.285,3.687),o.updateMatrix(),a.setMatrixAt(2,o.matrix),o.position.set(-2.017,.018,6.124),o.rotation.set(0,.333,0),o.scale.set(2.002,4.566,2.064),o.updateMatrix(),a.setMatrixAt(3,o.matrix),o.position.set(2.291,-.756,-2.621),o.rotation.set(0,-.286,0),o.scale.set(1.546,1.552,1.496),o.updateMatrix(),a.setMatrixAt(4,o.matrix),o.position.set(-2.193,-.369,-5.547),o.rotation.set(0,.516,0),o.scale.set(3.875,3.487,2.986),o.updateMatrix(),a.setMatrixAt(5,o.matrix),this.add(a);const c=new Jt(e,ma(50));c.position.set(-16.116,14.37,8.208),c.scale.set(.1,2.428,2.739),this.add(c);const l=new Jt(e,ma(50));l.position.set(-16.109,18.021,-8.207),l.scale.set(.1,2.425,2.751),this.add(l);const h=new Jt(e,ma(17));h.position.set(14.904,12.198,-1.832),h.scale.set(.15,4.265,6.331),this.add(h);const u=new Jt(e,ma(43));u.position.set(-.462,8.89,14.52),u.scale.set(4.38,5.441,.088),this.add(u);const d=new Jt(e,ma(20));d.position.set(3.235,11.486,-12.541),d.scale.set(2.5,2,.1),this.add(d);const f=new Jt(e,ma(100));f.position.set(0,20,0),f.scale.set(1,.1,1),this.add(f)}dispose(){const e=new Set;this.traverse(t=>{t.isMesh&&(e.add(t.geometry),e.add(t.material))});for(const t of e)t.dispose()}}function ma(i){const e=new Ss;return e.color.setScalar(i),e}function r1(i){if(!(typeof window>"u")){var e=document.createElement("style");return e.setAttribute("type","text/css"),e.innerHTML=i,document.head.appendChild(e),i}}function ba(i,e){var t=i.__state.conversionName.toString(),n=Math.round(i.r),s=Math.round(i.g),r=Math.round(i.b),a=i.a,o=Math.round(i.h),c=i.s.toFixed(1),l=i.v.toFixed(1);if(e||t==="THREE_CHAR_HEX"||t==="SIX_CHAR_HEX"){for(var h=i.hex.toString(16);h.length<6;)h="0"+h;return"#"+h}else{if(t==="CSS_RGB")return"rgb("+n+","+s+","+r+")";if(t==="CSS_RGBA")return"rgba("+n+","+s+","+r+","+a+")";if(t==="HEX")return"0x"+i.hex.toString(16);if(t==="RGB_ARRAY")return"["+n+","+s+","+r+"]";if(t==="RGBA_ARRAY")return"["+n+","+s+","+r+","+a+"]";if(t==="RGB_OBJ")return"{r:"+n+",g:"+s+",b:"+r+"}";if(t==="RGBA_OBJ")return"{r:"+n+",g:"+s+",b:"+r+",a:"+a+"}";if(t==="HSV_OBJ")return"{h:"+o+",s:"+c+",v:"+l+"}";if(t==="HSVA_OBJ")return"{h:"+o+",s:"+c+",v:"+l+",a:"+a+"}"}return"unknown format"}var Fg=Array.prototype.forEach,Co=Array.prototype.slice,ue={BREAK:{},extend:function(e){return this.each(Co.call(arguments,1),function(t){var n=this.isObject(t)?Object.keys(t):[];n.forEach((function(s){this.isUndefined(t[s])||(e[s]=t[s])}).bind(this))},this),e},defaults:function(e){return this.each(Co.call(arguments,1),function(t){var n=this.isObject(t)?Object.keys(t):[];n.forEach((function(s){this.isUndefined(e[s])&&(e[s]=t[s])}).bind(this))},this),e},compose:function(){var e=Co.call(arguments);return function(){for(var t=Co.call(arguments),n=e.length-1;n>=0;n--)t=[e[n].apply(this,t)];return t[0]}},each:function(e,t,n){if(e){if(Fg&&e.forEach&&e.forEach===Fg)e.forEach(t,n);else if(e.length===e.length+0){var s=void 0,r=void 0;for(s=0,r=e.length;s<r;s++)if(s in e&&t.call(n,e[s],s)===this.BREAK)return}else for(var a in e)if(t.call(n,e[a],a)===this.BREAK)return}},defer:function(e){setTimeout(e,0)},debounce:function(e,t,n){var s=void 0;return function(){var r=this,a=arguments;function o(){s=null,n||e.apply(r,a)}var c=n||!s;clearTimeout(s),s=setTimeout(o,t),c&&e.apply(r,a)}},toArray:function(e){return e.toArray?e.toArray():Co.call(e)},isUndefined:function(e){return e===void 0},isNull:function(e){return e===null},isNaN:(function(i){function e(t){return i.apply(this,arguments)}return e.toString=function(){return i.toString()},e})(function(i){return isNaN(i)}),isArray:Array.isArray||function(i){return i.constructor===Array},isObject:function(e){return e===Object(e)},isNumber:function(e){return e===e+0},isString:function(e){return e===e+""},isBoolean:function(e){return e===!1||e===!0},isFunction:function(e){return e instanceof Function}},a1=[{litmus:ue.isString,conversions:{THREE_CHAR_HEX:{read:function(e){var t=e.match(/^#([A-F0-9])([A-F0-9])([A-F0-9])$/i);return t===null?!1:{space:"HEX",hex:parseInt("0x"+t[1].toString()+t[1].toString()+t[2].toString()+t[2].toString()+t[3].toString()+t[3].toString(),0)}},write:ba},SIX_CHAR_HEX:{read:function(e){var t=e.match(/^#([A-F0-9]{6})$/i);return t===null?!1:{space:"HEX",hex:parseInt("0x"+t[1].toString(),0)}},write:ba},CSS_RGB:{read:function(e){var t=e.match(/^rgb\(\s*(\S+)\s*,\s*(\S+)\s*,\s*(\S+)\s*\)/);return t===null?!1:{space:"RGB",r:parseFloat(t[1]),g:parseFloat(t[2]),b:parseFloat(t[3])}},write:ba},CSS_RGBA:{read:function(e){var t=e.match(/^rgba\(\s*(\S+)\s*,\s*(\S+)\s*,\s*(\S+)\s*,\s*(\S+)\s*\)/);return t===null?!1:{space:"RGB",r:parseFloat(t[1]),g:parseFloat(t[2]),b:parseFloat(t[3]),a:parseFloat(t[4])}},write:ba}}},{litmus:ue.isNumber,conversions:{HEX:{read:function(e){return{space:"HEX",hex:e,conversionName:"HEX"}},write:function(e){return e.hex}}}},{litmus:ue.isArray,conversions:{RGB_ARRAY:{read:function(e){return e.length!==3?!1:{space:"RGB",r:e[0],g:e[1],b:e[2]}},write:function(e){return[e.r,e.g,e.b]}},RGBA_ARRAY:{read:function(e){return e.length!==4?!1:{space:"RGB",r:e[0],g:e[1],b:e[2],a:e[3]}},write:function(e){return[e.r,e.g,e.b,e.a]}}}},{litmus:ue.isObject,conversions:{RGBA_OBJ:{read:function(e){return ue.isNumber(e.r)&&ue.isNumber(e.g)&&ue.isNumber(e.b)&&ue.isNumber(e.a)?{space:"RGB",r:e.r,g:e.g,b:e.b,a:e.a}:!1},write:function(e){return{r:e.r,g:e.g,b:e.b,a:e.a}}},RGB_OBJ:{read:function(e){return ue.isNumber(e.r)&&ue.isNumber(e.g)&&ue.isNumber(e.b)?{space:"RGB",r:e.r,g:e.g,b:e.b}:!1},write:function(e){return{r:e.r,g:e.g,b:e.b}}},HSVA_OBJ:{read:function(e){return ue.isNumber(e.h)&&ue.isNumber(e.s)&&ue.isNumber(e.v)&&ue.isNumber(e.a)?{space:"HSV",h:e.h,s:e.s,v:e.v,a:e.a}:!1},write:function(e){return{h:e.h,s:e.s,v:e.v,a:e.a}}},HSV_OBJ:{read:function(e){return ue.isNumber(e.h)&&ue.isNumber(e.s)&&ue.isNumber(e.v)?{space:"HSV",h:e.h,s:e.s,v:e.v}:!1},write:function(e){return{h:e.h,s:e.s,v:e.v}}}}}],So=void 0,dl=void 0,ud=function(){dl=!1;var e=arguments.length>1?ue.toArray(arguments):arguments[0];return ue.each(a1,function(t){if(t.litmus(e))return ue.each(t.conversions,function(n,s){if(So=n.read(e),dl===!1&&So!==!1)return dl=So,So.conversionName=s,So.conversion=n,ue.BREAK}),ue.BREAK}),dl},Dg=void 0,fl={hsv_to_rgb:function(e,t,n){var s=Math.floor(e/60)%6,r=e/60-Math.floor(e/60),a=n*(1-t),o=n*(1-r*t),c=n*(1-(1-r)*t),l=[[n,c,a],[o,n,a],[a,n,c],[a,o,n],[c,a,n],[n,a,o]][s];return{r:l[0]*255,g:l[1]*255,b:l[2]*255}},rgb_to_hsv:function(e,t,n){var s=Math.min(e,t,n),r=Math.max(e,t,n),a=r-s,o=void 0,c=void 0;if(r!==0)c=a/r;else return{h:NaN,s:0,v:0};return e===r?o=(t-n)/a:t===r?o=2+(n-e)/a:o=4+(e-t)/a,o/=6,o<0&&(o+=1),{h:o*360,s:c,v:r/255}},rgb_to_hex:function(e,t,n){var s=this.hex_with_component(0,2,e);return s=this.hex_with_component(s,1,t),s=this.hex_with_component(s,0,n),s},component_from_hex:function(e,t){return e>>t*8&255},hex_with_component:function(e,t,n){return n<<(Dg=t*8)|e&~(255<<Dg)}},o1=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(i){return typeof i}:function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},bi=function(i,e){if(!(i instanceof e))throw new TypeError("Cannot call a class as a function")},xi=(function(){function i(e,t){for(var n=0;n<t.length;n++){var s=t[n];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,s.key,s)}}return function(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),e}})(),Fs=function i(e,t,n){e===null&&(e=Function.prototype);var s=Object.getOwnPropertyDescriptor(e,t);if(s===void 0){var r=Object.getPrototypeOf(e);return r===null?void 0:i(r,t,n)}else{if("value"in s)return s.value;var a=s.get;return a===void 0?void 0:a.call(n)}},Ds=function(i,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof e);i.prototype=Object.create(e&&e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(i,e):i.__proto__=e)},Ls=function(i,e){if(!i)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e&&(typeof e=="object"||typeof e=="function")?e:i},pn=(function(){function i(){if(bi(this,i),this.__state=ud.apply(this,arguments),this.__state===!1)throw new Error("Failed to interpret color arguments");this.__state.a=this.__state.a||1}return xi(i,[{key:"toString",value:function(){return ba(this)}},{key:"toHexString",value:function(){return ba(this,!0)}},{key:"toOriginal",value:function(){return this.__state.conversion.write(this)}}]),i})();function dd(i,e,t){Object.defineProperty(i,e,{get:function(){return this.__state.space==="RGB"?this.__state[e]:(pn.recalculateRGB(this,e,t),this.__state[e])},set:function(s){this.__state.space!=="RGB"&&(pn.recalculateRGB(this,e,t),this.__state.space="RGB"),this.__state[e]=s}})}function fd(i,e){Object.defineProperty(i,e,{get:function(){return this.__state.space==="HSV"?this.__state[e]:(pn.recalculateHSV(this),this.__state[e])},set:function(n){this.__state.space!=="HSV"&&(pn.recalculateHSV(this),this.__state.space="HSV"),this.__state[e]=n}})}pn.recalculateRGB=function(i,e,t){if(i.__state.space==="HEX")i.__state[e]=fl.component_from_hex(i.__state.hex,t);else if(i.__state.space==="HSV")ue.extend(i.__state,fl.hsv_to_rgb(i.__state.h,i.__state.s,i.__state.v));else throw new Error("Corrupted color state")},pn.recalculateHSV=function(i){var e=fl.rgb_to_hsv(i.r,i.g,i.b);ue.extend(i.__state,{s:e.s,v:e.v}),ue.isNaN(e.h)?ue.isUndefined(i.__state.h)&&(i.__state.h=0):i.__state.h=e.h},pn.COMPONENTS=["r","g","b","h","s","v","hex","a"],dd(pn.prototype,"r",2),dd(pn.prototype,"g",1),dd(pn.prototype,"b",0),fd(pn.prototype,"h"),fd(pn.prototype,"s"),fd(pn.prototype,"v"),Object.defineProperty(pn.prototype,"a",{get:function(){return this.__state.a},set:function(e){this.__state.a=e}}),Object.defineProperty(pn.prototype,"hex",{get:function(){return this.__state.space!=="HEX"&&(this.__state.hex=fl.rgb_to_hex(this.r,this.g,this.b),this.__state.space="HEX"),this.__state.hex},set:function(e){this.__state.space="HEX",this.__state.hex=e}});var hr=(function(){function i(e,t){bi(this,i),this.initialValue=e[t],this.domElement=document.createElement("div"),this.object=e,this.property=t,this.__onChange=void 0,this.__onFinishChange=void 0}return xi(i,[{key:"onChange",value:function(t){return this.__onChange=t,this}},{key:"onFinishChange",value:function(t){return this.__onFinishChange=t,this}},{key:"setValue",value:function(t){return this.object[this.property]=t,this.__onChange&&this.__onChange.call(this,t),this.updateDisplay(),this}},{key:"getValue",value:function(){return this.object[this.property]}},{key:"updateDisplay",value:function(){return this}},{key:"isModified",value:function(){return this.initialValue!==this.getValue()}}]),i})(),c1={HTMLEvents:["change"],MouseEvents:["click","mousemove","mousedown","mouseup","mouseover"],KeyboardEvents:["keydown"]},Lg={};ue.each(c1,function(i,e){ue.each(i,function(t){Lg[t]=e})});var l1=/(\d+(\.\d+)?)px/;function Li(i){if(i==="0"||ue.isUndefined(i))return 0;var e=i.match(l1);return ue.isNull(e)?0:parseFloat(e[1])}var te={makeSelectable:function(e,t){e===void 0||e.style===void 0||(e.onselectstart=t?function(){return!1}:function(){},e.style.MozUserSelect=t?"auto":"none",e.style.KhtmlUserSelect=t?"auto":"none",e.unselectable=t?"on":"off")},makeFullscreen:function(e,t,n){var s=n,r=t;ue.isUndefined(r)&&(r=!0),ue.isUndefined(s)&&(s=!0),e.style.position="absolute",r&&(e.style.left=0,e.style.right=0),s&&(e.style.top=0,e.style.bottom=0)},fakeEvent:function(e,t,n,s){var r=n||{},a=Lg[t];if(!a)throw new Error("Event type "+t+" not supported.");var o=document.createEvent(a);switch(a){case"MouseEvents":{var c=r.x||r.clientX||0,l=r.y||r.clientY||0;o.initMouseEvent(t,r.bubbles||!1,r.cancelable||!0,window,r.clickCount||1,0,0,c,l,!1,!1,!1,!1,0,null);break}case"KeyboardEvents":{var h=o.initKeyboardEvent||o.initKeyEvent;ue.defaults(r,{cancelable:!0,ctrlKey:!1,altKey:!1,shiftKey:!1,metaKey:!1,keyCode:void 0,charCode:void 0}),h(t,r.bubbles||!1,r.cancelable,window,r.ctrlKey,r.altKey,r.shiftKey,r.metaKey,r.keyCode,r.charCode);break}default:{o.initEvent(t,r.bubbles||!1,r.cancelable||!0);break}}ue.defaults(o,s),e.dispatchEvent(o)},bind:function(e,t,n,s){var r=s||!1;return e.addEventListener?e.addEventListener(t,n,r):e.attachEvent&&e.attachEvent("on"+t,n),te},unbind:function(e,t,n,s){var r=s||!1;return e.removeEventListener?e.removeEventListener(t,n,r):e.detachEvent&&e.detachEvent("on"+t,n),te},addClass:function(e,t){if(e.className===void 0)e.className=t;else if(e.className!==t){var n=e.className.split(/ +/);n.indexOf(t)===-1&&(n.push(t),e.className=n.join(" ").replace(/^\s+/,"").replace(/\s+$/,""))}return te},removeClass:function(e,t){if(t)if(e.className===t)e.removeAttribute("class");else{var n=e.className.split(/ +/),s=n.indexOf(t);s!==-1&&(n.splice(s,1),e.className=n.join(" "))}else e.className=void 0;return te},hasClass:function(e,t){return new RegExp("(?:^|\\s+)"+t+"(?:\\s+|$)").test(e.className)||!1},getWidth:function(e){var t=getComputedStyle(e);return Li(t["border-left-width"])+Li(t["border-right-width"])+Li(t["padding-left"])+Li(t["padding-right"])+Li(t.width)},getHeight:function(e){var t=getComputedStyle(e);return Li(t["border-top-width"])+Li(t["border-bottom-width"])+Li(t["padding-top"])+Li(t["padding-bottom"])+Li(t.height)},getOffset:function(e){var t=e,n={left:0,top:0};if(t.offsetParent)do n.left+=t.offsetLeft,n.top+=t.offsetTop,t=t.offsetParent;while(t);return n},isActive:function(e){return e===document.activeElement&&(e.type||e.href)}},Pg=(function(i){Ds(e,i);function e(t,n){bi(this,e);var s=Ls(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n)),r=s;s.__prev=s.getValue(),s.__checkbox=document.createElement("input"),s.__checkbox.setAttribute("type","checkbox");function a(){r.setValue(!r.__prev)}return te.bind(s.__checkbox,"change",a,!1),s.domElement.appendChild(s.__checkbox),s.updateDisplay(),s}return xi(e,[{key:"setValue",value:function(n){var s=Fs(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"setValue",this).call(this,n);return this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue()),this.__prev=this.getValue(),s}},{key:"updateDisplay",value:function(){return this.getValue()===!0?(this.__checkbox.setAttribute("checked","checked"),this.__checkbox.checked=!0,this.__prev=!0):(this.__checkbox.checked=!1,this.__prev=!1),Fs(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"updateDisplay",this).call(this)}}]),e})(hr),h1=(function(i){Ds(e,i);function e(t,n,s){bi(this,e);var r=Ls(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n)),a=s,o=r;if(r.__select=document.createElement("select"),ue.isArray(a)){var c={};ue.each(a,function(l){c[l]=l}),a=c}return ue.each(a,function(l,h){var u=document.createElement("option");u.innerHTML=h,u.setAttribute("value",l),o.__select.appendChild(u)}),r.updateDisplay(),te.bind(r.__select,"change",function(){var l=this.options[this.selectedIndex].value;o.setValue(l)}),r.domElement.appendChild(r.__select),r}return xi(e,[{key:"setValue",value:function(n){var s=Fs(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"setValue",this).call(this,n);return this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue()),s}},{key:"updateDisplay",value:function(){return te.isActive(this.__select)?this:(this.__select.value=this.getValue(),Fs(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"updateDisplay",this).call(this))}}]),e})(hr),u1=(function(i){Ds(e,i);function e(t,n){bi(this,e);var s=Ls(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n)),r=s;function a(){r.setValue(r.__input.value)}function o(){r.__onFinishChange&&r.__onFinishChange.call(r,r.getValue())}return s.__input=document.createElement("input"),s.__input.setAttribute("type","text"),te.bind(s.__input,"keyup",a),te.bind(s.__input,"change",a),te.bind(s.__input,"blur",o),te.bind(s.__input,"keydown",function(c){c.keyCode===13&&this.blur()}),s.updateDisplay(),s.domElement.appendChild(s.__input),s}return xi(e,[{key:"updateDisplay",value:function(){return te.isActive(this.__input)||(this.__input.value=this.getValue()),Fs(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"updateDisplay",this).call(this)}}]),e})(hr);function kg(i){var e=i.toString();return e.indexOf(".")>-1?e.length-e.indexOf(".")-1:0}var Ug=(function(i){Ds(e,i);function e(t,n,s){bi(this,e);var r=Ls(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n)),a=s||{};return r.__min=a.min,r.__max=a.max,r.__step=a.step,ue.isUndefined(r.__step)?r.initialValue===0?r.__impliedStep=1:r.__impliedStep=Math.pow(10,Math.floor(Math.log(Math.abs(r.initialValue))/Math.LN10))/10:r.__impliedStep=r.__step,r.__precision=kg(r.__impliedStep),r}return xi(e,[{key:"setValue",value:function(n){var s=n;return this.__min!==void 0&&s<this.__min?s=this.__min:this.__max!==void 0&&s>this.__max&&(s=this.__max),this.__step!==void 0&&s%this.__step!==0&&(s=Math.round(s/this.__step)*this.__step),Fs(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"setValue",this).call(this,s)}},{key:"min",value:function(n){return this.__min=n,this}},{key:"max",value:function(n){return this.__max=n,this}},{key:"step",value:function(n){return this.__step=n,this.__impliedStep=n,this.__precision=kg(n),this}}]),e})(hr);function d1(i,e){var t=Math.pow(10,e);return Math.round(i*t)/t}var pl=(function(i){Ds(e,i);function e(t,n,s){bi(this,e);var r=Ls(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n,s));r.__truncationSuspended=!1;var a=r,o=void 0;function c(){var m=parseFloat(a.__input.value);ue.isNaN(m)||a.setValue(m)}function l(){a.__onFinishChange&&a.__onFinishChange.call(a,a.getValue())}function h(){l()}function u(m){var A=o-m.clientY;a.setValue(a.getValue()+A*a.__impliedStep),o=m.clientY}function d(){te.unbind(window,"mousemove",u),te.unbind(window,"mouseup",d),l()}function f(m){te.bind(window,"mousemove",u),te.bind(window,"mouseup",d),o=m.clientY}return r.__input=document.createElement("input"),r.__input.setAttribute("type","text"),te.bind(r.__input,"change",c),te.bind(r.__input,"blur",h),te.bind(r.__input,"mousedown",f),te.bind(r.__input,"keydown",function(m){m.keyCode===13&&(a.__truncationSuspended=!0,this.blur(),a.__truncationSuspended=!1,l())}),r.updateDisplay(),r.domElement.appendChild(r.__input),r}return xi(e,[{key:"updateDisplay",value:function(){return this.__input.value=this.__truncationSuspended?this.getValue():d1(this.getValue(),this.__precision),Fs(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"updateDisplay",this).call(this)}}]),e})(Ug);function Og(i,e,t,n,s){return n+(s-n)*((i-e)/(t-e))}var pd=(function(i){Ds(e,i);function e(t,n,s,r,a){bi(this,e);var o=Ls(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n,{min:s,max:r,step:a})),c=o;o.__background=document.createElement("div"),o.__foreground=document.createElement("div"),te.bind(o.__background,"mousedown",l),te.bind(o.__background,"touchstart",d),te.addClass(o.__background,"slider"),te.addClass(o.__foreground,"slider-fg");function l(A){document.activeElement.blur(),te.bind(window,"mousemove",h),te.bind(window,"mouseup",u),h(A)}function h(A){A.preventDefault();var g=c.__background.getBoundingClientRect();return c.setValue(Og(A.clientX,g.left,g.right,c.__min,c.__max)),!1}function u(){te.unbind(window,"mousemove",h),te.unbind(window,"mouseup",u),c.__onFinishChange&&c.__onFinishChange.call(c,c.getValue())}function d(A){A.touches.length===1&&(te.bind(window,"touchmove",f),te.bind(window,"touchend",m),f(A))}function f(A){var g=A.touches[0].clientX,p=c.__background.getBoundingClientRect();c.setValue(Og(g,p.left,p.right,c.__min,c.__max))}function m(){te.unbind(window,"touchmove",f),te.unbind(window,"touchend",m),c.__onFinishChange&&c.__onFinishChange.call(c,c.getValue())}return o.updateDisplay(),o.__background.appendChild(o.__foreground),o.domElement.appendChild(o.__background),o}return xi(e,[{key:"updateDisplay",value:function(){var n=(this.getValue()-this.__min)/(this.__max-this.__min);return this.__foreground.style.width=n*100+"%",Fs(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"updateDisplay",this).call(this)}}]),e})(Ug),Qg=(function(i){Ds(e,i);function e(t,n,s){bi(this,e);var r=Ls(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n)),a=r;return r.__button=document.createElement("div"),r.__button.innerHTML=s===void 0?"Fire":s,te.bind(r.__button,"click",function(o){return o.preventDefault(),a.fire(),!1}),te.addClass(r.__button,"button"),r.domElement.appendChild(r.__button),r}return xi(e,[{key:"fire",value:function(){this.__onChange&&this.__onChange.call(this),this.getValue().call(this.object),this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue())}}]),e})(hr),Ad=(function(i){Ds(e,i);function e(t,n){bi(this,e);var s=Ls(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n));s.__color=new pn(s.getValue()),s.__temp=new pn(0);var r=s;s.domElement=document.createElement("div"),te.makeSelectable(s.domElement,!1),s.__selector=document.createElement("div"),s.__selector.className="selector",s.__saturation_field=document.createElement("div"),s.__saturation_field.className="saturation-field",s.__field_knob=document.createElement("div"),s.__field_knob.className="field-knob",s.__field_knob_border="2px solid ",s.__hue_knob=document.createElement("div"),s.__hue_knob.className="hue-knob",s.__hue_field=document.createElement("div"),s.__hue_field.className="hue-field",s.__input=document.createElement("input"),s.__input.type="text",s.__input_textShadow="0 1px 1px ",te.bind(s.__input,"keydown",function(A){A.keyCode===13&&u.call(this)}),te.bind(s.__input,"blur",u),te.bind(s.__selector,"mousedown",function(){te.addClass(this,"drag").bind(window,"mouseup",function(){te.removeClass(r.__selector,"drag")})}),te.bind(s.__selector,"touchstart",function(){te.addClass(this,"drag").bind(window,"touchend",function(){te.removeClass(r.__selector,"drag")})});var a=document.createElement("div");ue.extend(s.__selector.style,{width:"122px",height:"102px",padding:"3px",backgroundColor:"#222",boxShadow:"0px 1px 3px rgba(0,0,0,0.3)"}),ue.extend(s.__field_knob.style,{position:"absolute",width:"12px",height:"12px",border:s.__field_knob_border+(s.__color.v<.5?"#fff":"#000"),boxShadow:"0px 1px 3px rgba(0,0,0,0.5)",borderRadius:"12px",zIndex:1}),ue.extend(s.__hue_knob.style,{position:"absolute",width:"15px",height:"2px",borderRight:"4px solid #fff",zIndex:1}),ue.extend(s.__saturation_field.style,{width:"100px",height:"100px",border:"1px solid #555",marginRight:"3px",display:"inline-block",cursor:"pointer"}),ue.extend(a.style,{width:"100%",height:"100%",background:"none"}),Gg(a,"top","rgba(0,0,0,0)","#000"),ue.extend(s.__hue_field.style,{width:"15px",height:"100px",border:"1px solid #555",cursor:"ns-resize",position:"absolute",top:"3px",right:"3px"}),p1(s.__hue_field),ue.extend(s.__input.style,{outline:"none",textAlign:"center",color:"#fff",border:0,fontWeight:"bold",textShadow:s.__input_textShadow+"rgba(0,0,0,0.7)"}),te.bind(s.__saturation_field,"mousedown",o),te.bind(s.__saturation_field,"touchstart",o),te.bind(s.__field_knob,"mousedown",o),te.bind(s.__field_knob,"touchstart",o),te.bind(s.__hue_field,"mousedown",c),te.bind(s.__hue_field,"touchstart",c);function o(A){f(A),te.bind(window,"mousemove",f),te.bind(window,"touchmove",f),te.bind(window,"mouseup",l),te.bind(window,"touchend",l)}function c(A){m(A),te.bind(window,"mousemove",m),te.bind(window,"touchmove",m),te.bind(window,"mouseup",h),te.bind(window,"touchend",h)}function l(){te.unbind(window,"mousemove",f),te.unbind(window,"touchmove",f),te.unbind(window,"mouseup",l),te.unbind(window,"touchend",l),d()}function h(){te.unbind(window,"mousemove",m),te.unbind(window,"touchmove",m),te.unbind(window,"mouseup",h),te.unbind(window,"touchend",h),d()}function u(){var A=ud(this.value);A!==!1?(r.__color.__state=A,r.setValue(r.__color.toOriginal())):this.value=r.__color.toString()}function d(){r.__onFinishChange&&r.__onFinishChange.call(r,r.__color.toOriginal())}s.__saturation_field.appendChild(a),s.__selector.appendChild(s.__field_knob),s.__selector.appendChild(s.__saturation_field),s.__selector.appendChild(s.__hue_field),s.__hue_field.appendChild(s.__hue_knob),s.domElement.appendChild(s.__input),s.domElement.appendChild(s.__selector),s.updateDisplay();function f(A){A.type.indexOf("touch")===-1&&A.preventDefault();var g=r.__saturation_field.getBoundingClientRect(),p=A.touches&&A.touches[0]||A,y=p.clientX,b=p.clientY,E=(y-g.left)/(g.right-g.left),M=1-(b-g.top)/(g.bottom-g.top);return M>1?M=1:M<0&&(M=0),E>1?E=1:E<0&&(E=0),r.__color.v=M,r.__color.s=E,r.setValue(r.__color.toOriginal()),!1}function m(A){A.type.indexOf("touch")===-1&&A.preventDefault();var g=r.__hue_field.getBoundingClientRect(),p=A.touches&&A.touches[0]||A,y=p.clientY,b=1-(y-g.top)/(g.bottom-g.top);return b>1?b=1:b<0&&(b=0),r.__color.h=b*360,r.setValue(r.__color.toOriginal()),!1}return s}return xi(e,[{key:"updateDisplay",value:function(){var n=ud(this.getValue());if(n!==!1){var s=!1;ue.each(pn.COMPONENTS,function(o){if(!ue.isUndefined(n[o])&&!ue.isUndefined(this.__color.__state[o])&&n[o]!==this.__color.__state[o])return s=!0,{}},this),s&&ue.extend(this.__color.__state,n)}ue.extend(this.__temp.__state,this.__color.__state),this.__temp.a=1;var r=this.__color.v<.5||this.__color.s>.5?255:0,a=255-r;ue.extend(this.__field_knob.style,{marginLeft:100*this.__color.s-7+"px",marginTop:100*(1-this.__color.v)-7+"px",backgroundColor:this.__temp.toHexString(),border:this.__field_knob_border+"rgb("+r+","+r+","+r+")"}),this.__hue_knob.style.marginTop=(1-this.__color.h/360)*100+"px",this.__temp.s=1,this.__temp.v=1,Gg(this.__saturation_field,"left","#fff",this.__temp.toHexString()),this.__input.value=this.__color.toString(),ue.extend(this.__input.style,{backgroundColor:this.__color.toHexString(),color:"rgb("+r+","+r+","+r+")",textShadow:this.__input_textShadow+"rgba("+a+","+a+","+a+",.7)"})}}]),e})(hr),f1=["-moz-","-o-","-webkit-","-ms-",""];function Gg(i,e,t,n){i.style.background="",ue.each(f1,function(s){i.style.cssText+="background: "+s+"linear-gradient("+e+", "+t+" 0%, "+n+" 100%); "})}function p1(i){i.style.background="",i.style.cssText+="background: -moz-linear-gradient(top, #ff0000 0%, #ff00ff 17%, #0000ff 34%, #00ffff 50%, #00ff00 67%, #ffff00 84%, #ff0000 100%);",i.style.cssText+="background: -webkit-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",i.style.cssText+="background: -o-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",i.style.cssText+="background: -ms-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",i.style.cssText+="background: linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);"}var A1={load:function(e,t){var n=t||document,s=n.createElement("link");s.type="text/css",s.rel="stylesheet",s.href=e,n.getElementsByTagName("head")[0].appendChild(s)},inject:function(e,t){var n=t||document,s=document.createElement("style");s.type="text/css",s.innerHTML=e;var r=n.getElementsByTagName("head")[0];try{r.appendChild(s)}catch{}}},g1=`<div id="dg-save" class="dg dialogue">++ Here's the new load parameter for your <code>GUI</code>'s constructor:++ <textarea id="dg-new-constructor"></textarea>++ <div id="dg-save-locally">++ <input id="dg-local-storage" type="checkbox"/> Automatically save+ values to <code>localStorage</code> on exit.++ <div id="dg-local-explain">The values saved to <code>localStorage</code> will+ override those passed to <code>dat.GUI</code>'s constructor. This makes it+ easier to work incrementally, but <code>localStorage</code> is fragile,+ and your friends may not see the same values you do.++ </div>++ </div>++</div>`,m1=function(e,t){var n=e[t];return ue.isArray(arguments[2])||ue.isObject(arguments[2])?new h1(e,t,arguments[2]):ue.isNumber(n)?ue.isNumber(arguments[2])&&ue.isNumber(arguments[3])?ue.isNumber(arguments[4])?new pd(e,t,arguments[2],arguments[3],arguments[4]):new pd(e,t,arguments[2],arguments[3]):ue.isNumber(arguments[4])?new pl(e,t,{min:arguments[2],max:arguments[3],step:arguments[4]}):new pl(e,t,{min:arguments[2],max:arguments[3]}):ue.isString(n)?new u1(e,t):ue.isFunction(n)?new Qg(e,t,""):ue.isBoolean(n)?new Pg(e,t):null};function b1(i){setTimeout(i,1e3/60)}var x1=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||b1,_1=(function(){function i(){bi(this,i),this.backgroundElement=document.createElement("div"),ue.extend(this.backgroundElement.style,{backgroundColor:"rgba(0,0,0,0.8)",top:0,left:0,display:"none",zIndex:"1000",opacity:0,WebkitTransition:"opacity 0.2s linear",transition:"opacity 0.2s linear"}),te.makeFullscreen(this.backgroundElement),this.backgroundElement.style.position="fixed",this.domElement=document.createElement("div"),ue.extend(this.domElement.style,{position:"fixed",display:"none",zIndex:"1001",opacity:0,WebkitTransition:"-webkit-transform 0.2s ease-out, opacity 0.2s linear",transition:"transform 0.2s ease-out, opacity 0.2s linear"}),document.body.appendChild(this.backgroundElement),document.body.appendChild(this.domElement);var e=this;te.bind(this.backgroundElement,"click",function(){e.hide()})}return xi(i,[{key:"show",value:function(){var t=this;this.backgroundElement.style.display="block",this.domElement.style.display="block",this.domElement.style.opacity=0,this.domElement.style.webkitTransform="scale(1.1)",this.layout(),ue.defer(function(){t.backgroundElement.style.opacity=1,t.domElement.style.opacity=1,t.domElement.style.webkitTransform="scale(1)"})}},{key:"hide",value:function(){var t=this,n=function s(){t.domElement.style.display="none",t.backgroundElement.style.display="none",te.unbind(t.domElement,"webkitTransitionEnd",s),te.unbind(t.domElement,"transitionend",s),te.unbind(t.domElement,"oTransitionEnd",s)};te.bind(this.domElement,"webkitTransitionEnd",n),te.bind(this.domElement,"transitionend",n),te.bind(this.domElement,"oTransitionEnd",n),this.backgroundElement.style.opacity=0,this.domElement.style.opacity=0,this.domElement.style.webkitTransform="scale(1.1)"}},{key:"layout",value:function(){this.domElement.style.left=window.innerWidth/2-te.getWidth(this.domElement)/2+"px",this.domElement.style.top=window.innerHeight/2-te.getHeight(this.domElement)/2+"px"}}]),i})(),E1=r1(`.dg ul{list-style:none;margin:0;padding:0;width:100%;clear:both}.dg.ac{position:fixed;top:0;left:0;right:0;height:0;z-index:0}.dg:not(.ac) .main{overflow:hidden}.dg.main{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear}.dg.main.taller-than-window{overflow-y:auto}.dg.main.taller-than-window .close-button{opacity:1;margin-top:-1px;border-top:1px solid #2c2c2c}.dg.main ul.closed .close-button{opacity:1 !important}.dg.main:hover .close-button,.dg.main .close-button.drag{opacity:1}.dg.main .close-button{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear;border:0;line-height:19px;height:20px;cursor:pointer;text-align:center;background-color:#000}.dg.main .close-button.close-top{position:relative}.dg.main .close-button.close-bottom{position:absolute}.dg.main .close-button:hover{background-color:#111}.dg.a{float:right;margin-right:15px;overflow-y:visible}.dg.a.has-save>ul.close-top{margin-top:0}.dg.a.has-save>ul.close-bottom{margin-top:27px}.dg.a.has-save>ul.closed{margin-top:0}.dg.a .save-row{top:0;z-index:1002}.dg.a .save-row.close-top{position:relative}.dg.a .save-row.close-bottom{position:fixed}.dg li{-webkit-transition:height .1s ease-out;-o-transition:height .1s ease-out;-moz-transition:height .1s ease-out;transition:height .1s ease-out;-webkit-transition:overflow .1s linear;-o-transition:overflow .1s linear;-moz-transition:overflow .1s linear;transition:overflow .1s linear}.dg li:not(.folder){cursor:auto;height:27px;line-height:27px;padding:0 4px 0 5px}.dg li.folder{padding:0;border-left:4px solid rgba(0,0,0,0)}.dg li.title{cursor:pointer;margin-left:-4px}.dg .closed li:not(.title),.dg .closed ul li,.dg .closed ul li>*{height:0;overflow:hidden;border:0}.dg .cr{clear:both;padding-left:3px;height:27px;overflow:hidden}.dg .property-name{cursor:default;float:left;clear:left;width:40%;overflow:hidden;text-overflow:ellipsis}.dg .cr.function .property-name{width:100%}.dg .c{float:left;width:60%;position:relative}.dg .c input[type=text]{border:0;margin-top:4px;padding:3px;width:100%;float:right}.dg .has-slider input[type=text]{width:30%;margin-left:0}.dg .slider{float:left;width:66%;margin-left:-5px;margin-right:0;height:19px;margin-top:4px}.dg .slider-fg{height:100%}.dg .c input[type=checkbox]{margin-top:7px}.dg .c select{margin-top:5px}.dg .cr.function,.dg .cr.function .property-name,.dg .cr.function *,.dg .cr.boolean,.dg .cr.boolean *{cursor:pointer}.dg .cr.color{overflow:visible}.dg .selector{display:none;position:absolute;margin-left:-9px;margin-top:23px;z-index:10}.dg .c:hover .selector,.dg .selector.drag{display:block}.dg li.save-row{padding:0}.dg li.save-row .button{display:inline-block;padding:0px 6px}.dg.dialogue{background-color:#222;width:460px;padding:15px;font-size:13px;line-height:15px}#dg-new-constructor{padding:10px;color:#222;font-family:Monaco, monospace;font-size:10px;border:0;resize:none;box-shadow:inset 1px 1px 1px #888;word-wrap:break-word;margin:12px 0;display:block;width:440px;overflow-y:scroll;height:100px;position:relative}#dg-local-explain{display:none;font-size:11px;line-height:17px;border-radius:3px;background-color:#333;padding:8px;margin-top:10px}#dg-local-explain code{font-size:10px}#dat-gui-save-locally{display:none}.dg{color:#eee;font:11px 'Lucida Grande', sans-serif;text-shadow:0 -1px 0 #111}.dg.main::-webkit-scrollbar{width:5px;background:#1a1a1a}.dg.main::-webkit-scrollbar-corner{height:0;display:none}.dg.main::-webkit-scrollbar-thumb{border-radius:5px;background:#676767}.dg li:not(.folder){background:#1a1a1a;border-bottom:1px solid #2c2c2c}.dg li.save-row{line-height:25px;background:#dad5cb;border:0}.dg li.save-row select{margin-left:5px;width:108px}.dg li.save-row .button{margin-left:5px;margin-top:1px;border-radius:2px;font-size:9px;line-height:7px;padding:4px 4px 5px 4px;background:#c5bdad;color:#fff;text-shadow:0 1px 0 #b0a58f;box-shadow:0 -1px 0 #b0a58f;cursor:pointer}.dg li.save-row .button.gears{background:#c5bdad url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAANCAYAAAB/9ZQ7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQJJREFUeNpiYKAU/P//PwGIC/ApCABiBSAW+I8AClAcgKxQ4T9hoMAEUrxx2QSGN6+egDX+/vWT4e7N82AMYoPAx/evwWoYoSYbACX2s7KxCxzcsezDh3evFoDEBYTEEqycggWAzA9AuUSQQgeYPa9fPv6/YWm/Acx5IPb7ty/fw+QZblw67vDs8R0YHyQhgObx+yAJkBqmG5dPPDh1aPOGR/eugW0G4vlIoTIfyFcA+QekhhHJhPdQxbiAIguMBTQZrPD7108M6roWYDFQiIAAv6Aow/1bFwXgis+f2LUAynwoIaNcz8XNx3Dl7MEJUDGQpx9gtQ8YCueB+D26OECAAQDadt7e46D42QAAAABJRU5ErkJggg==) 2px 1px no-repeat;height:7px;width:8px}.dg li.save-row .button:hover{background-color:#bab19e;box-shadow:0 -1px 0 #b0a58f}.dg li.folder{border-bottom:0}.dg li.title{padding-left:16px;background:#000 url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlI+hKgFxoCgAOw==) 6px 10px no-repeat;cursor:pointer;border-bottom:1px solid rgba(255,255,255,0.2)}.dg .closed li.title{background-image:url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlGIWqMCbWAEAOw==)}.dg .cr.boolean{border-left:3px solid #806787}.dg .cr.color{border-left:3px solid}.dg .cr.function{border-left:3px solid #e61d5f}.dg .cr.number{border-left:3px solid #2FA1D6}.dg .cr.number input[type=text]{color:#2FA1D6}.dg .cr.string{border-left:3px solid #1ed36f}.dg .cr.string input[type=text]{color:#1ed36f}.dg .cr.function:hover,.dg .cr.boolean:hover{background:#111}.dg .c input[type=text]{background:#303030;outline:none}.dg .c input[type=text]:hover{background:#3c3c3c}.dg .c input[type=text]:focus{background:#494949;color:#fff}.dg .c .slider{background:#303030;cursor:ew-resize}.dg .c .slider-fg{background:#2FA1D6;max-width:100%}.dg .c .slider:hover{background:#3c3c3c}.dg .c .slider:hover .slider-fg{background:#44abda}+`);A1.inject(E1);var Hg="dg",zg=72,Vg=20,Io="Default",Mo=(function(){try{return!!window.localStorage}catch{return!1}})(),Bo=void 0,Wg=!0,xa=void 0,gd=!1,qg=[],Nt=function i(e){var t=this,n=e||{};this.domElement=document.createElement("div"),this.__ul=document.createElement("ul"),this.domElement.appendChild(this.__ul),te.addClass(this.domElement,Hg),this.__folders={},this.__controllers=[],this.__rememberedObjects=[],this.__rememberedObjectIndecesToControllers=[],this.__listening=[],n=ue.defaults(n,{closeOnTop:!1,autoPlace:!0,width:i.DEFAULT_WIDTH}),n=ue.defaults(n,{resizable:n.autoPlace,hideable:n.autoPlace}),ue.isUndefined(n.load)?n.load={preset:Io}:n.preset&&(n.load.preset=n.preset),ue.isUndefined(n.parent)&&n.hideable&&qg.push(this),n.resizable=ue.isUndefined(n.parent)&&n.resizable,n.autoPlace&&ue.isUndefined(n.scrollable)&&(n.scrollable=!0);var s=Mo&&localStorage.getItem(_a(this,"isLocal"))==="true",r=void 0,a=void 0;if(Object.defineProperties(this,{parent:{get:function(){return n.parent}},scrollable:{get:function(){return n.scrollable}},autoPlace:{get:function(){return n.autoPlace}},closeOnTop:{get:function(){return n.closeOnTop}},preset:{get:function(){return t.parent?t.getRoot().preset:n.load.preset},set:function(d){t.parent?t.getRoot().preset=d:n.load.preset=d,C1(this),t.revert()}},width:{get:function(){return n.width},set:function(d){n.width=d,_d(t,d)}},name:{get:function(){return n.name},set:function(d){n.name=d,a&&(a.innerHTML=n.name)}},closed:{get:function(){return n.closed},set:function(d){n.closed=d,n.closed?te.addClass(t.__ul,i.CLASS_CLOSED):te.removeClass(t.__ul,i.CLASS_CLOSED),this.onResize(),t.__closeButton&&(t.__closeButton.innerHTML=d?i.TEXT_OPEN:i.TEXT_CLOSED)}},load:{get:function(){return n.load}},useLocalStorage:{get:function(){return s},set:function(d){Mo&&(s=d,d?te.bind(window,"unload",r):te.unbind(window,"unload",r),localStorage.setItem(_a(t,"isLocal"),d))}}}),ue.isUndefined(n.parent)){if(this.closed=n.closed||!1,te.addClass(this.domElement,i.CLASS_MAIN),te.makeSelectable(this.domElement,!1),Mo&&s){t.useLocalStorage=!0;var o=localStorage.getItem(_a(this,"gui"));o&&(n.load=JSON.parse(o))}this.__closeButton=document.createElement("div"),this.__closeButton.innerHTML=i.TEXT_CLOSED,te.addClass(this.__closeButton,i.CLASS_CLOSE_BUTTON),n.closeOnTop?(te.addClass(this.__closeButton,i.CLASS_CLOSE_TOP),this.domElement.insertBefore(this.__closeButton,this.domElement.childNodes[0])):(te.addClass(this.__closeButton,i.CLASS_CLOSE_BOTTOM),this.domElement.appendChild(this.__closeButton)),te.bind(this.__closeButton,"click",function(){t.closed=!t.closed})}else{n.closed===void 0&&(n.closed=!0);var c=document.createTextNode(n.name);te.addClass(c,"controller-name"),a=md(t,c);var l=function(d){return d.preventDefault(),t.closed=!t.closed,!1};te.addClass(this.__ul,i.CLASS_CLOSED),te.addClass(a,"title"),te.bind(a,"click",l),n.closed||(this.closed=!1)}n.autoPlace&&(ue.isUndefined(n.parent)&&(Wg&&(xa=document.createElement("div"),te.addClass(xa,Hg),te.addClass(xa,i.CLASS_AUTO_PLACE_CONTAINER),document.body.appendChild(xa),Wg=!1),xa.appendChild(this.domElement),te.addClass(this.domElement,i.CLASS_AUTO_PLACE)),this.parent||_d(t,n.width)),this.__resizeHandler=function(){t.onResizeDebounced()},te.bind(window,"resize",this.__resizeHandler),te.bind(this.__ul,"webkitTransitionEnd",this.__resizeHandler),te.bind(this.__ul,"transitionend",this.__resizeHandler),te.bind(this.__ul,"oTransitionEnd",this.__resizeHandler),this.onResize(),n.resizable&&v1(this),r=function(){Mo&&localStorage.getItem(_a(t,"isLocal"))==="true"&&localStorage.setItem(_a(t,"gui"),JSON.stringify(t.getSaveObject()))},this.saveToLocalStorageIfPossible=r;function h(){var u=t.getRoot();u.width+=1,ue.defer(function(){u.width-=1})}n.parent||h()};Nt.toggleHide=function(){gd=!gd,ue.each(qg,function(i){i.domElement.style.display=gd?"none":""})},Nt.CLASS_AUTO_PLACE="a",Nt.CLASS_AUTO_PLACE_CONTAINER="ac",Nt.CLASS_MAIN="main",Nt.CLASS_CONTROLLER_ROW="cr",Nt.CLASS_TOO_TALL="taller-than-window",Nt.CLASS_CLOSED="closed",Nt.CLASS_CLOSE_BUTTON="close-button",Nt.CLASS_CLOSE_TOP="close-top",Nt.CLASS_CLOSE_BOTTOM="close-bottom",Nt.CLASS_DRAG="drag",Nt.DEFAULT_WIDTH=245,Nt.TEXT_CLOSED="Close Controls",Nt.TEXT_OPEN="Open Controls",Nt._keydownHandler=function(i){document.activeElement.type!=="text"&&(i.which===zg||i.keyCode===zg)&&Nt.toggleHide()},te.bind(window,"keydown",Nt._keydownHandler,!1),ue.extend(Nt.prototype,{add:function(e,t){return To(this,e,t,{factoryArgs:Array.prototype.slice.call(arguments,2)})},addColor:function(e,t){return To(this,e,t,{color:!0})},remove:function(e){this.__ul.removeChild(e.__li),this.__controllers.splice(this.__controllers.indexOf(e),1);var t=this;ue.defer(function(){t.onResize()})},destroy:function(){if(this.parent)throw new Error("Only the root GUI should be removed with .destroy(). For subfolders, use gui.removeFolder(folder) instead.");this.autoPlace&&xa.removeChild(this.domElement);var e=this;ue.each(this.__folders,function(t){e.removeFolder(t)}),te.unbind(window,"keydown",Nt._keydownHandler,!1),Kg(this)},addFolder:function(e){if(this.__folders[e]!==void 0)throw new Error('You already have a folder in this GUI by the name "'+e+'"');var t={name:e,parent:this};t.autoPlace=this.autoPlace,this.load&&this.load.folders&&this.load.folders[e]&&(t.closed=this.load.folders[e].closed,t.load=this.load.folders[e]);var n=new Nt(t);this.__folders[e]=n;var s=md(this,n.domElement);return te.addClass(s,"folder"),n},removeFolder:function(e){this.__ul.removeChild(e.domElement.parentElement),delete this.__folders[e.name],this.load&&this.load.folders&&this.load.folders[e.name]&&delete this.load.folders[e.name],Kg(e);var t=this;ue.each(e.__folders,function(n){e.removeFolder(n)}),ue.defer(function(){t.onResize()})},open:function(){this.closed=!1},close:function(){this.closed=!0},hide:function(){this.domElement.style.display="none"},show:function(){this.domElement.style.display=""},onResize:function(){var e=this.getRoot();if(e.scrollable){var t=te.getOffset(e.__ul).top,n=0;ue.each(e.__ul.childNodes,function(s){e.autoPlace&&s===e.__save_row||(n+=te.getHeight(s))}),window.innerHeight-t-Vg<n?(te.addClass(e.domElement,Nt.CLASS_TOO_TALL),e.__ul.style.height=window.innerHeight-t-Vg+"px"):(te.removeClass(e.domElement,Nt.CLASS_TOO_TALL),e.__ul.style.height="auto")}e.__resize_handle&&ue.defer(function(){e.__resize_handle.style.height=e.__ul.offsetHeight+"px"}),e.__closeButton&&(e.__closeButton.style.width=e.width+"px")},onResizeDebounced:ue.debounce(function(){this.onResize()},50),remember:function(){if(ue.isUndefined(Bo)&&(Bo=new _1,Bo.domElement.innerHTML=g1),this.parent)throw new Error("You can only call remember on a top level GUI.");var e=this;ue.each(Array.prototype.slice.call(arguments),function(t){e.__rememberedObjects.length===0&&w1(e),e.__rememberedObjects.indexOf(t)===-1&&e.__rememberedObjects.push(t)}),this.autoPlace&&_d(this,this.width)},getRoot:function(){for(var e=this;e.parent;)e=e.parent;return e},getSaveObject:function(){var e=this.load;return e.closed=this.closed,this.__rememberedObjects.length>0&&(e.preset=this.preset,e.remembered||(e.remembered={}),e.remembered[this.preset]=Al(this)),e.folders={},ue.each(this.__folders,function(t,n){e.folders[n]=t.getSaveObject()}),e},save:function(){this.load.remembered||(this.load.remembered={}),this.load.remembered[this.preset]=Al(this),bd(this,!1),this.saveToLocalStorageIfPossible()},saveAs:function(e){this.load.remembered||(this.load.remembered={},this.load.remembered[Io]=Al(this,!0)),this.load.remembered[e]=Al(this),this.preset=e,xd(this,e,!0),this.saveToLocalStorageIfPossible()},revert:function(e){ue.each(this.__controllers,function(t){this.getRoot().load.remembered?jg(e||this.getRoot(),t):t.setValue(t.initialValue),t.__onFinishChange&&t.__onFinishChange.call(t,t.getValue())},this),ue.each(this.__folders,function(t){t.revert(t)}),e||bd(this.getRoot(),!1)},listen:function(e){var t=this.__listening.length===0;this.__listening.push(e),t&&Yg(this.__listening)},updateDisplay:function(){ue.each(this.__controllers,function(e){e.updateDisplay()}),ue.each(this.__folders,function(e){e.updateDisplay()})}});function md(i,e,t){var n=document.createElement("li");return e&&n.appendChild(e),t?i.__ul.insertBefore(n,t):i.__ul.appendChild(n),i.onResize(),n}function Kg(i){te.unbind(window,"resize",i.__resizeHandler),i.saveToLocalStorageIfPossible&&te.unbind(window,"unload",i.saveToLocalStorageIfPossible)}function bd(i,e){var t=i.__preset_select[i.__preset_select.selectedIndex];e?t.innerHTML=t.value+"*":t.innerHTML=t.value}function y1(i,e,t){if(t.__li=e,t.__gui=i,ue.extend(t,{options:function(a){if(arguments.length>1){var o=t.__li.nextElementSibling;return t.remove(),To(i,t.object,t.property,{before:o,factoryArgs:[ue.toArray(arguments)]})}if(ue.isArray(a)||ue.isObject(a)){var c=t.__li.nextElementSibling;return t.remove(),To(i,t.object,t.property,{before:c,factoryArgs:[a]})}},name:function(a){return t.__li.firstElementChild.firstElementChild.innerHTML=a,t},listen:function(){return t.__gui.listen(t),t},remove:function(){return t.__gui.remove(t),t}}),t instanceof pd){var n=new pl(t.object,t.property,{min:t.__min,max:t.__max,step:t.__step});ue.each(["updateDisplay","onChange","onFinishChange","step","min","max"],function(r){var a=t[r],o=n[r];t[r]=n[r]=function(){var c=Array.prototype.slice.call(arguments);return o.apply(n,c),a.apply(t,c)}}),te.addClass(e,"has-slider"),t.domElement.insertBefore(n.domElement,t.domElement.firstElementChild)}else if(t instanceof pl){var s=function(a){if(ue.isNumber(t.__min)&&ue.isNumber(t.__max)){var o=t.__li.firstElementChild.firstElementChild.innerHTML,c=t.__gui.__listening.indexOf(t)>-1;t.remove();var l=To(i,t.object,t.property,{before:t.__li.nextElementSibling,factoryArgs:[t.__min,t.__max,t.__step]});return l.name(o),c&&l.listen(),l}return a};t.min=ue.compose(s,t.min),t.max=ue.compose(s,t.max)}else t instanceof Pg?(te.bind(e,"click",function(){te.fakeEvent(t.__checkbox,"click")}),te.bind(t.__checkbox,"click",function(r){r.stopPropagation()})):t instanceof Qg?(te.bind(e,"click",function(){te.fakeEvent(t.__button,"click")}),te.bind(e,"mouseover",function(){te.addClass(t.__button,"hover")}),te.bind(e,"mouseout",function(){te.removeClass(t.__button,"hover")})):t instanceof Ad&&(te.addClass(e,"color"),t.updateDisplay=ue.compose(function(r){return e.style.borderLeftColor=t.__color.toString(),r},t.updateDisplay),t.updateDisplay());t.setValue=ue.compose(function(r){return i.getRoot().__preset_select&&t.isModified()&&bd(i.getRoot(),!0),r},t.setValue)}function jg(i,e){var t=i.getRoot(),n=t.__rememberedObjects.indexOf(e.object);if(n!==-1){var s=t.__rememberedObjectIndecesToControllers[n];if(s===void 0&&(s={},t.__rememberedObjectIndecesToControllers[n]=s),s[e.property]=e,t.load&&t.load.remembered){var r=t.load.remembered,a=void 0;if(r[i.preset])a=r[i.preset];else if(r[Io])a=r[Io];else return;if(a[n]&&a[n][e.property]!==void 0){var o=a[n][e.property];e.initialValue=o,e.setValue(o)}}}}function To(i,e,t,n){if(e[t]===void 0)throw new Error('Object "'+e+'" has no property "'+t+'"');var s=void 0;if(n.color)s=new Ad(e,t);else{var r=[e,t].concat(n.factoryArgs);s=m1.apply(i,r)}n.before instanceof hr&&(n.before=n.before.__li),jg(i,s),te.addClass(s.domElement,"c");var a=document.createElement("span");te.addClass(a,"property-name"),a.innerHTML=s.property;var o=document.createElement("div");o.appendChild(a),o.appendChild(s.domElement);var c=md(i,o,n.before);return te.addClass(c,Nt.CLASS_CONTROLLER_ROW),s instanceof Ad?te.addClass(c,"color"):te.addClass(c,o1(s.getValue())),y1(i,c,s),i.__controllers.push(s),s}function _a(i,e){return document.location.href+"."+e}function xd(i,e,t){var n=document.createElement("option");n.innerHTML=e,n.value=e,i.__preset_select.appendChild(n),t&&(i.__preset_select.selectedIndex=i.__preset_select.length-1)}function Xg(i,e){e.style.display=i.useLocalStorage?"block":"none"}function w1(i){var e=i.__save_row=document.createElement("li");te.addClass(i.domElement,"has-save"),i.__ul.insertBefore(e,i.__ul.firstChild),te.addClass(e,"save-row");var t=document.createElement("span");t.innerHTML=" ",te.addClass(t,"button gears");var n=document.createElement("span");n.innerHTML="Save",te.addClass(n,"button"),te.addClass(n,"save");var s=document.createElement("span");s.innerHTML="New",te.addClass(s,"button"),te.addClass(s,"save-as");var r=document.createElement("span");r.innerHTML="Revert",te.addClass(r,"button"),te.addClass(r,"revert");var a=i.__preset_select=document.createElement("select");if(i.load&&i.load.remembered?ue.each(i.load.remembered,function(u,d){xd(i,d,d===i.preset)}):xd(i,Io,!1),te.bind(a,"change",function(){for(var u=0;u<i.__preset_select.length;u++)i.__preset_select[u].innerHTML=i.__preset_select[u].value;i.preset=this.value}),e.appendChild(a),e.appendChild(t),e.appendChild(n),e.appendChild(s),e.appendChild(r),Mo){var o=document.getElementById("dg-local-explain"),c=document.getElementById("dg-local-storage"),l=document.getElementById("dg-save-locally");l.style.display="block",localStorage.getItem(_a(i,"isLocal"))==="true"&&c.setAttribute("checked","checked"),Xg(i,o),te.bind(c,"change",function(){i.useLocalStorage=!i.useLocalStorage,Xg(i,o)})}var h=document.getElementById("dg-new-constructor");te.bind(h,"keydown",function(u){u.metaKey&&(u.which===67||u.keyCode===67)&&Bo.hide()}),te.bind(t,"click",function(){h.innerHTML=JSON.stringify(i.getSaveObject(),void 0,2),Bo.show(),h.focus(),h.select()}),te.bind(n,"click",function(){i.save()}),te.bind(s,"click",function(){var u=prompt("Enter a new preset name.");u&&i.saveAs(u)}),te.bind(r,"click",function(){i.revert()})}function v1(i){var e=void 0;i.__resize_handle=document.createElement("div"),ue.extend(i.__resize_handle.style,{width:"6px",marginLeft:"-3px",height:"200px",cursor:"ew-resize",position:"absolute"});function t(r){return r.preventDefault(),i.width+=e-r.clientX,i.onResize(),e=r.clientX,!1}function n(){te.removeClass(i.__closeButton,Nt.CLASS_DRAG),te.unbind(window,"mousemove",t),te.unbind(window,"mouseup",n)}function s(r){return r.preventDefault(),e=r.clientX,te.addClass(i.__closeButton,Nt.CLASS_DRAG),te.bind(window,"mousemove",t),te.bind(window,"mouseup",n),!1}te.bind(i.__resize_handle,"mousedown",s),te.bind(i.__closeButton,"mousedown",s),i.domElement.insertBefore(i.__resize_handle,i.domElement.firstElementChild)}function _d(i,e){i.domElement.style.width=e+"px",i.__save_row&&i.autoPlace&&(i.__save_row.style.width=e+"px"),i.__closeButton&&(i.__closeButton.style.width=e+"px")}function Al(i,e){var t={};return ue.each(i.__rememberedObjects,function(n,s){var r={},a=i.__rememberedObjectIndecesToControllers[s];ue.each(a,function(o,c){r[c]=e?o.initialValue:o.getValue()}),t[s]=r}),t}function C1(i){for(var e=0;e<i.__preset_select.length;e++)i.__preset_select[e].value===i.preset&&(i.__preset_select.selectedIndex=e)}function Yg(i){i.length!==0&&x1.call(window,function(){Yg(i)}),ue.each(i,function(e){e.updateDisplay()})}var S1=Nt;const gl=[{id:"",name:"None",path:null},{id:"neutral",name:"Neutral",path:null},{id:"venice-sunset",name:"Venice Sunset",path:"https://storage.googleapis.com/donmccurdy-static/venice_sunset_1k.exr",format:".exr"},{id:"footprint-court",name:"Footprint Court (HDR Labs)",path:"https://storage.googleapis.com/donmccurdy-static/footprint_court_2k.exr",format:".exr"}],I1=["BN","BN","BN","BN","BN","BN","BN","BN","BN","S","B","S","WS","B","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","B","B","B","S","WS","ON","ON","ET","ET","ET","ON","ON","ON","ON","ON","ES","CS","ES","CS","CS","EN","EN","EN","EN","EN","EN","EN","EN","EN","EN","CS","ON","ON","ON","ON","ON","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","ON","ON","ON","ON","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","ON","ON","ON","BN","BN","BN","BN","BN","BN","B","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","CS","ON","ET","ET","ET","ET","ON","ON","ON","ON","L","ON","ON","BN","ON","ON","ET","ET","EN","EN","ON","L","ON","ON","ON","EN","L","ON","ON","ON","ON","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","L","L","L","L","L","L","L","L"],Jg=[[697,698,"ON"],[706,719,"ON"],[722,735,"ON"],[741,749,"ON"],[751,767,"ON"],[768,879,"NSM"],[884,885,"ON"],[894,894,"ON"],[900,901,"ON"],[903,903,"ON"],[1014,1014,"ON"],[1155,1161,"NSM"],[1418,1418,"ON"],[1421,1422,"ON"],[1423,1423,"ET"],[1424,1424,"R"],[1425,1469,"NSM"],[1470,1470,"R"],[1471,1471,"NSM"],[1472,1472,"R"],[1473,1474,"NSM"],[1475,1475,"R"],[1476,1477,"NSM"],[1478,1478,"R"],[1479,1479,"NSM"],[1480,1535,"R"],[1536,1541,"AN"],[1542,1543,"ON"],[1544,1544,"AL"],[1545,1546,"ET"],[1547,1547,"AL"],[1548,1548,"CS"],[1549,1549,"AL"],[1550,1551,"ON"],[1552,1562,"NSM"],[1563,1610,"AL"],[1611,1631,"NSM"],[1632,1641,"AN"],[1642,1642,"ET"],[1643,1644,"AN"],[1645,1647,"AL"],[1648,1648,"NSM"],[1649,1749,"AL"],[1750,1756,"NSM"],[1757,1757,"AN"],[1758,1758,"ON"],[1759,1764,"NSM"],[1765,1766,"AL"],[1767,1768,"NSM"],[1769,1769,"ON"],[1770,1773,"NSM"],[1774,1775,"AL"],[1776,1785,"EN"],[1786,1808,"AL"],[1809,1809,"NSM"],[1810,1839,"AL"],[1840,1866,"NSM"],[1867,1957,"AL"],[1958,1968,"NSM"],[1969,1983,"AL"],[1984,2026,"R"],[2027,2035,"NSM"],[2036,2037,"R"],[2038,2041,"ON"],[2042,2044,"R"],[2045,2045,"NSM"],[2046,2069,"R"],[2070,2073,"NSM"],[2074,2074,"R"],[2075,2083,"NSM"],[2084,2084,"R"],[2085,2087,"NSM"],[2088,2088,"R"],[2089,2093,"NSM"],[2094,2136,"R"],[2137,2139,"NSM"],[2140,2143,"R"],[2144,2191,"AL"],[2192,2193,"AN"],[2194,2198,"AL"],[2199,2207,"NSM"],[2208,2249,"AL"],[2250,2273,"NSM"],[2274,2274,"AN"],[2275,2306,"NSM"],[2362,2362,"NSM"],[2364,2364,"NSM"],[2369,2376,"NSM"],[2381,2381,"NSM"],[2385,2391,"NSM"],[2402,2403,"NSM"],[2433,2433,"NSM"],[2492,2492,"NSM"],[2497,2500,"NSM"],[2509,2509,"NSM"],[2530,2531,"NSM"],[2546,2547,"ET"],[2555,2555,"ET"],[2558,2558,"NSM"],[2561,2562,"NSM"],[2620,2620,"NSM"],[2625,2626,"NSM"],[2631,2632,"NSM"],[2635,2637,"NSM"],[2641,2641,"NSM"],[2672,2673,"NSM"],[2677,2677,"NSM"],[2689,2690,"NSM"],[2748,2748,"NSM"],[2753,2757,"NSM"],[2759,2760,"NSM"],[2765,2765,"NSM"],[2786,2787,"NSM"],[2801,2801,"ET"],[2810,2815,"NSM"],[2817,2817,"NSM"],[2876,2876,"NSM"],[2879,2879,"NSM"],[2881,2884,"NSM"],[2893,2893,"NSM"],[2901,2902,"NSM"],[2914,2915,"NSM"],[2946,2946,"NSM"],[3008,3008,"NSM"],[3021,3021,"NSM"],[3059,3064,"ON"],[3065,3065,"ET"],[3066,3066,"ON"],[3072,3072,"NSM"],[3076,3076,"NSM"],[3132,3132,"NSM"],[3134,3136,"NSM"],[3142,3144,"NSM"],[3146,3149,"NSM"],[3157,3158,"NSM"],[3170,3171,"NSM"],[3192,3198,"ON"],[3201,3201,"NSM"],[3260,3260,"NSM"],[3276,3277,"NSM"],[3298,3299,"NSM"],[3328,3329,"NSM"],[3387,3388,"NSM"],[3393,3396,"NSM"],[3405,3405,"NSM"],[3426,3427,"NSM"],[3457,3457,"NSM"],[3530,3530,"NSM"],[3538,3540,"NSM"],[3542,3542,"NSM"],[3633,3633,"NSM"],[3636,3642,"NSM"],[3647,3647,"ET"],[3655,3662,"NSM"],[3761,3761,"NSM"],[3764,3772,"NSM"],[3784,3790,"NSM"],[3864,3865,"NSM"],[3893,3893,"NSM"],[3895,3895,"NSM"],[3897,3897,"NSM"],[3898,3901,"ON"],[3953,3966,"NSM"],[3968,3972,"NSM"],[3974,3975,"NSM"],[3981,3991,"NSM"],[3993,4028,"NSM"],[4038,4038,"NSM"],[4141,4144,"NSM"],[4146,4151,"NSM"],[4153,4154,"NSM"],[4157,4158,"NSM"],[4184,4185,"NSM"],[4190,4192,"NSM"],[4209,4212,"NSM"],[4226,4226,"NSM"],[4229,4230,"NSM"],[4237,4237,"NSM"],[4253,4253,"NSM"],[4957,4959,"NSM"],[5008,5017,"ON"],[5120,5120,"ON"],[5760,5760,"WS"],[5787,5788,"ON"],[5906,5908,"NSM"],[5938,5939,"NSM"],[5970,5971,"NSM"],[6002,6003,"NSM"],[6068,6069,"NSM"],[6071,6077,"NSM"],[6086,6086,"NSM"],[6089,6099,"NSM"],[6107,6107,"ET"],[6109,6109,"NSM"],[6128,6137,"ON"],[6144,6154,"ON"],[6155,6157,"NSM"],[6158,6158,"BN"],[6159,6159,"NSM"],[6277,6278,"NSM"],[6313,6313,"NSM"],[6432,6434,"NSM"],[6439,6440,"NSM"],[6450,6450,"NSM"],[6457,6459,"NSM"],[6464,6464,"ON"],[6468,6469,"ON"],[6622,6655,"ON"],[6679,6680,"NSM"],[6683,6683,"NSM"],[6742,6742,"NSM"],[6744,6750,"NSM"],[6752,6752,"NSM"],[6754,6754,"NSM"],[6757,6764,"NSM"],[6771,6780,"NSM"],[6783,6783,"NSM"],[6832,6877,"NSM"],[6880,6891,"NSM"],[6912,6915,"NSM"],[6964,6964,"NSM"],[6966,6970,"NSM"],[6972,6972,"NSM"],[6978,6978,"NSM"],[7019,7027,"NSM"],[7040,7041,"NSM"],[7074,7077,"NSM"],[7080,7081,"NSM"],[7083,7085,"NSM"],[7142,7142,"NSM"],[7144,7145,"NSM"],[7149,7149,"NSM"],[7151,7153,"NSM"],[7212,7219,"NSM"],[7222,7223,"NSM"],[7376,7378,"NSM"],[7380,7392,"NSM"],[7394,7400,"NSM"],[7405,7405,"NSM"],[7412,7412,"NSM"],[7416,7417,"NSM"],[7616,7679,"NSM"],[8125,8125,"ON"],[8127,8129,"ON"],[8141,8143,"ON"],[8157,8159,"ON"],[8173,8175,"ON"],[8189,8190,"ON"],[8192,8202,"WS"],[8203,8205,"BN"],[8207,8207,"R"],[8208,8231,"ON"],[8232,8232,"WS"],[8233,8233,"B"],[8234,8238,"BN"],[8239,8239,"CS"],[8240,8244,"ET"],[8245,8259,"ON"],[8260,8260,"CS"],[8261,8286,"ON"],[8287,8287,"WS"],[8288,8303,"BN"],[8304,8304,"EN"],[8308,8313,"EN"],[8314,8315,"ES"],[8316,8318,"ON"],[8320,8329,"EN"],[8330,8331,"ES"],[8332,8334,"ON"],[8352,8399,"ET"],[8400,8432,"NSM"],[8448,8449,"ON"],[8451,8454,"ON"],[8456,8457,"ON"],[8468,8468,"ON"],[8470,8472,"ON"],[8478,8483,"ON"],[8485,8485,"ON"],[8487,8487,"ON"],[8489,8489,"ON"],[8494,8494,"ET"],[8506,8507,"ON"],[8512,8516,"ON"],[8522,8525,"ON"],[8528,8543,"ON"],[8585,8587,"ON"],[8592,8721,"ON"],[8722,8722,"ES"],[8723,8723,"ET"],[8724,9013,"ON"],[9083,9108,"ON"],[9110,9257,"ON"],[9280,9290,"ON"],[9312,9351,"ON"],[9352,9371,"EN"],[9450,9899,"ON"],[9901,10239,"ON"],[10496,11123,"ON"],[11126,11263,"ON"],[11493,11498,"ON"],[11503,11505,"NSM"],[11513,11519,"ON"],[11647,11647,"NSM"],[11744,11775,"NSM"],[11776,11869,"ON"],[11904,11929,"ON"],[11931,12019,"ON"],[12032,12245,"ON"],[12272,12287,"ON"],[12288,12288,"WS"],[12289,12292,"ON"],[12296,12320,"ON"],[12330,12333,"NSM"],[12336,12336,"ON"],[12342,12343,"ON"],[12349,12351,"ON"],[12441,12442,"NSM"],[12443,12444,"ON"],[12448,12448,"ON"],[12539,12539,"ON"],[12736,12773,"ON"],[12783,12783,"ON"],[12829,12830,"ON"],[12880,12895,"ON"],[12924,12926,"ON"],[12977,12991,"ON"],[13004,13007,"ON"],[13175,13178,"ON"],[13278,13279,"ON"],[13311,13311,"ON"],[19904,19967,"ON"],[42128,42182,"ON"],[42509,42511,"ON"],[42607,42610,"NSM"],[42611,42611,"ON"],[42612,42621,"NSM"],[42622,42623,"ON"],[42654,42655,"NSM"],[42736,42737,"NSM"],[42752,42785,"ON"],[42888,42888,"ON"],[43010,43010,"NSM"],[43014,43014,"NSM"],[43019,43019,"NSM"],[43045,43046,"NSM"],[43048,43051,"ON"],[43052,43052,"NSM"],[43064,43065,"ET"],[43124,43127,"ON"],[43204,43205,"NSM"],[43232,43249,"NSM"],[43263,43263,"NSM"],[43302,43309,"NSM"],[43335,43345,"NSM"],[43392,43394,"NSM"],[43443,43443,"NSM"],[43446,43449,"NSM"],[43452,43453,"NSM"],[43493,43493,"NSM"],[43561,43566,"NSM"],[43569,43570,"NSM"],[43573,43574,"NSM"],[43587,43587,"NSM"],[43596,43596,"NSM"],[43644,43644,"NSM"],[43696,43696,"NSM"],[43698,43700,"NSM"],[43703,43704,"NSM"],[43710,43711,"NSM"],[43713,43713,"NSM"],[43756,43757,"NSM"],[43766,43766,"NSM"],[43882,43883,"ON"],[44005,44005,"NSM"],[44008,44008,"NSM"],[44013,44013,"NSM"],[64285,64285,"R"],[64286,64286,"NSM"],[64287,64296,"R"],[64297,64297,"ES"],[64298,64335,"R"],[64336,64450,"AL"],[64451,64466,"ON"],[64467,64829,"AL"],[64830,64847,"ON"],[64848,64911,"AL"],[64912,64913,"ON"],[64914,64967,"AL"],[64968,64975,"ON"],[64976,65007,"BN"],[65008,65020,"AL"],[65021,65023,"ON"],[65024,65039,"NSM"],[65040,65049,"ON"],[65056,65071,"NSM"],[65072,65103,"ON"],[65104,65104,"CS"],[65105,65105,"ON"],[65106,65106,"CS"],[65108,65108,"ON"],[65109,65109,"CS"],[65110,65118,"ON"],[65119,65119,"ET"],[65120,65121,"ON"],[65122,65123,"ES"],[65124,65126,"ON"],[65128,65128,"ON"],[65129,65130,"ET"],[65131,65131,"ON"],[65136,65278,"AL"],[65279,65279,"BN"],[65281,65282,"ON"],[65283,65285,"ET"],[65286,65290,"ON"],[65291,65291,"ES"],[65292,65292,"CS"],[65293,65293,"ES"],[65294,65295,"CS"],[65296,65305,"EN"],[65306,65306,"CS"],[65307,65312,"ON"],[65339,65344,"ON"],[65371,65381,"ON"],[65504,65505,"ET"],[65506,65508,"ON"],[65509,65510,"ET"],[65512,65518,"ON"],[65520,65528,"BN"],[65529,65533,"ON"],[65534,65535,"BN"],[65793,65793,"ON"],[65856,65932,"ON"],[65936,65948,"ON"],[65952,65952,"ON"],[66045,66045,"NSM"],[66272,66272,"NSM"],[66273,66299,"EN"],[66422,66426,"NSM"],[67584,67870,"R"],[67871,67871,"ON"],[67872,68096,"R"],[68097,68099,"NSM"],[68100,68100,"R"],[68101,68102,"NSM"],[68103,68107,"R"],[68108,68111,"NSM"],[68112,68151,"R"],[68152,68154,"NSM"],[68155,68158,"R"],[68159,68159,"NSM"],[68160,68324,"R"],[68325,68326,"NSM"],[68327,68408,"R"],[68409,68415,"ON"],[68416,68863,"R"],[68864,68899,"AL"],[68900,68903,"NSM"],[68904,68911,"AL"],[68912,68921,"AN"],[68922,68927,"AL"],[68928,68937,"AN"],[68938,68968,"R"],[68969,68973,"NSM"],[68974,68974,"ON"],[68975,69215,"R"],[69216,69246,"AN"],[69247,69290,"R"],[69291,69292,"NSM"],[69293,69311,"R"],[69312,69327,"AL"],[69328,69336,"ON"],[69337,69369,"AL"],[69370,69375,"NSM"],[69376,69423,"R"],[69424,69445,"AL"],[69446,69456,"NSM"],[69457,69487,"AL"],[69488,69505,"R"],[69506,69509,"NSM"],[69510,69631,"R"],[69633,69633,"NSM"],[69688,69702,"NSM"],[69714,69733,"ON"],[69744,69744,"NSM"],[69747,69748,"NSM"],[69759,69761,"NSM"],[69811,69814,"NSM"],[69817,69818,"NSM"],[69826,69826,"NSM"],[69888,69890,"NSM"],[69927,69931,"NSM"],[69933,69940,"NSM"],[70003,70003,"NSM"],[70016,70017,"NSM"],[70070,70078,"NSM"],[70089,70092,"NSM"],[70095,70095,"NSM"],[70191,70193,"NSM"],[70196,70196,"NSM"],[70198,70199,"NSM"],[70206,70206,"NSM"],[70209,70209,"NSM"],[70367,70367,"NSM"],[70371,70378,"NSM"],[70400,70401,"NSM"],[70459,70460,"NSM"],[70464,70464,"NSM"],[70502,70508,"NSM"],[70512,70516,"NSM"],[70587,70592,"NSM"],[70606,70606,"NSM"],[70608,70608,"NSM"],[70610,70610,"NSM"],[70625,70626,"NSM"],[70712,70719,"NSM"],[70722,70724,"NSM"],[70726,70726,"NSM"],[70750,70750,"NSM"],[70835,70840,"NSM"],[70842,70842,"NSM"],[70847,70848,"NSM"],[70850,70851,"NSM"],[71090,71093,"NSM"],[71100,71101,"NSM"],[71103,71104,"NSM"],[71132,71133,"NSM"],[71219,71226,"NSM"],[71229,71229,"NSM"],[71231,71232,"NSM"],[71264,71276,"ON"],[71339,71339,"NSM"],[71341,71341,"NSM"],[71344,71349,"NSM"],[71351,71351,"NSM"],[71453,71453,"NSM"],[71455,71455,"NSM"],[71458,71461,"NSM"],[71463,71467,"NSM"],[71727,71735,"NSM"],[71737,71738,"NSM"],[71995,71996,"NSM"],[71998,71998,"NSM"],[72003,72003,"NSM"],[72148,72151,"NSM"],[72154,72155,"NSM"],[72160,72160,"NSM"],[72193,72198,"NSM"],[72201,72202,"NSM"],[72243,72248,"NSM"],[72251,72254,"NSM"],[72263,72263,"NSM"],[72273,72278,"NSM"],[72281,72283,"NSM"],[72330,72342,"NSM"],[72344,72345,"NSM"],[72544,72544,"NSM"],[72546,72548,"NSM"],[72550,72550,"NSM"],[72752,72758,"NSM"],[72760,72765,"NSM"],[72850,72871,"NSM"],[72874,72880,"NSM"],[72882,72883,"NSM"],[72885,72886,"NSM"],[73009,73014,"NSM"],[73018,73018,"NSM"],[73020,73021,"NSM"],[73023,73029,"NSM"],[73031,73031,"NSM"],[73104,73105,"NSM"],[73109,73109,"NSM"],[73111,73111,"NSM"],[73459,73460,"NSM"],[73472,73473,"NSM"],[73526,73530,"NSM"],[73536,73536,"NSM"],[73538,73538,"NSM"],[73562,73562,"NSM"],[73685,73692,"ON"],[73693,73696,"ET"],[73697,73713,"ON"],[78912,78912,"NSM"],[78919,78933,"NSM"],[90398,90409,"NSM"],[90413,90415,"NSM"],[92912,92916,"NSM"],[92976,92982,"NSM"],[94031,94031,"NSM"],[94095,94098,"NSM"],[94178,94178,"ON"],[94180,94180,"NSM"],[113821,113822,"NSM"],[113824,113827,"BN"],[117760,117973,"ON"],[118e3,118009,"EN"],[118010,118012,"ON"],[118016,118451,"ON"],[118458,118480,"ON"],[118496,118512,"ON"],[118528,118573,"NSM"],[118576,118598,"NSM"],[119143,119145,"NSM"],[119155,119162,"BN"],[119163,119170,"NSM"],[119173,119179,"NSM"],[119210,119213,"NSM"],[119273,119274,"ON"],[119296,119361,"ON"],[119362,119364,"NSM"],[119365,119365,"ON"],[119552,119638,"ON"],[120513,120513,"ON"],[120539,120539,"ON"],[120571,120571,"ON"],[120597,120597,"ON"],[120629,120629,"ON"],[120655,120655,"ON"],[120687,120687,"ON"],[120713,120713,"ON"],[120745,120745,"ON"],[120771,120771,"ON"],[120782,120831,"EN"],[121344,121398,"NSM"],[121403,121452,"NSM"],[121461,121461,"NSM"],[121476,121476,"NSM"],[121499,121503,"NSM"],[121505,121519,"NSM"],[122880,122886,"NSM"],[122888,122904,"NSM"],[122907,122913,"NSM"],[122915,122916,"NSM"],[122918,122922,"NSM"],[123023,123023,"NSM"],[123184,123190,"NSM"],[123566,123566,"NSM"],[123628,123631,"NSM"],[123647,123647,"ET"],[124140,124143,"NSM"],[124398,124399,"NSM"],[124643,124643,"NSM"],[124646,124646,"NSM"],[124654,124655,"NSM"],[124661,124661,"NSM"],[124928,125135,"R"],[125136,125142,"NSM"],[125143,125251,"R"],[125252,125258,"NSM"],[125259,126063,"R"],[126064,126143,"AL"],[126144,126207,"R"],[126208,126287,"AL"],[126288,126463,"R"],[126464,126703,"AL"],[126704,126705,"ON"],[126706,126719,"AL"],[126720,126975,"R"],[126976,127019,"ON"],[127024,127123,"ON"],[127136,127150,"ON"],[127153,127167,"ON"],[127169,127183,"ON"],[127185,127221,"ON"],[127232,127242,"EN"],[127243,127247,"ON"],[127279,127279,"ON"],[127338,127343,"ON"],[127405,127405,"ON"],[127584,127589,"ON"],[127744,128728,"ON"],[128732,128748,"ON"],[128752,128764,"ON"],[128768,128985,"ON"],[128992,129003,"ON"],[129008,129008,"ON"],[129024,129035,"ON"],[129040,129095,"ON"],[129104,129113,"ON"],[129120,129159,"ON"],[129168,129197,"ON"],[129200,129211,"ON"],[129216,129217,"ON"],[129232,129240,"ON"],[129280,129623,"ON"],[129632,129645,"ON"],[129648,129660,"ON"],[129664,129674,"ON"],[129678,129734,"ON"],[129736,129736,"ON"],[129741,129756,"ON"],[129759,129770,"ON"],[129775,129784,"ON"],[129792,129938,"ON"],[129940,130031,"ON"],[130032,130041,"EN"],[130042,130042,"ON"],[131070,131071,"BN"],[196606,196607,"BN"],[262142,262143,"BN"],[327678,327679,"BN"],[393214,393215,"BN"],[458750,458751,"BN"],[524286,524287,"BN"],[589822,589823,"BN"],[655358,655359,"BN"],[720894,720895,"BN"],[786430,786431,"BN"],[851966,851967,"BN"],[917502,917759,"BN"],[917760,917999,"NSM"],[918e3,921599,"BN"],[983038,983039,"BN"],[1048574,1048575,"BN"],[1114110,1114111,"BN"]];function M1(i){if(i<=255)return I1[i];let e=0,t=Jg.length-1;for(;e<=t;){const n=e+t>>1,s=Jg[n];if(i<s[0]){t=n-1;continue}if(i>s[1]){e=n+1;continue}return s[2]}return"L"}function B1(i){const e=i.length;if(e===0)return null;const t=new Array(e);let n=!1;for(let l=0;l<e;){const h=i.charCodeAt(l);let u=h,d=1;if(h>=55296&&h<=56319&&l+1<e){const m=i.charCodeAt(l+1);m>=56320&&m<=57343&&(u=(h-55296<<10)+(m-56320)+65536,d=2)}const f=M1(u);(f==="R"||f==="AL"||f==="AN")&&(n=!0);for(let m=0;m<d;m++)t[l+m]=f;l+=d}if(!n)return null;let s=0;for(let l=0;l<e;l++){const h=t[l];if(h==="L"){s=0;break}if(h==="R"||h==="AL"){s=1;break}}const r=new Int8Array(e);for(let l=0;l<e;l++)r[l]=s;const a=s&1?"R":"L",o=a;let c=o;for(let l=0;l<e;l++)t[l]==="NSM"?t[l]=c:c=t[l];c=o;for(let l=0;l<e;l++){const h=t[l];h==="EN"?t[l]=c==="AL"?"AN":"EN":(h==="R"||h==="L"||h==="AL")&&(c=h)}for(let l=0;l<e;l++)t[l]==="AL"&&(t[l]="R");for(let l=1;l<e-1;l++)t[l]==="ES"&&t[l-1]==="EN"&&t[l+1]==="EN"&&(t[l]="EN"),t[l]==="CS"&&(t[l-1]==="EN"||t[l-1]==="AN")&&t[l+1]===t[l-1]&&(t[l]=t[l-1]);for(let l=0;l<e;l++){if(t[l]!=="EN")continue;let h;for(h=l-1;h>=0&&t[h]==="ET";h--)t[h]="EN";for(h=l+1;h<e&&t[h]==="ET";h++)t[h]="EN"}for(let l=0;l<e;l++){const h=t[l];(h==="WS"||h==="ES"||h==="ET"||h==="CS")&&(t[l]="ON")}c=o;for(let l=0;l<e;l++){const h=t[l];h==="EN"?t[l]=c==="L"?"L":"EN":(h==="R"||h==="L")&&(c=h)}for(let l=0;l<e;l++){if(t[l]!=="ON")continue;let h=l+1;for(;h<e&&t[h]==="ON";)h++;const u=l>0?t[l-1]:o,d=h<e?t[h]:o,f=u!=="L"?"R":"L";if(f===(d!=="L"?"R":"L"))for(let A=l;A<h;A++)t[A]=f;l=h-1}for(let l=0;l<e;l++)t[l]==="ON"&&(t[l]=a);for(let l=0;l<e;l++){const h=t[l];(r[l]&1)===0?h==="R"?r[l]++:(h==="AN"||h==="EN")&&(r[l]+=2):(h==="L"||h==="AN"||h==="EN")&&r[l]++}return r}function T1(i,e){const t=B1(i);if(t===null)return null;const n=new Int8Array(e.length);for(let s=0;s<e.length;s++)n[s]=t[e[s]];return n}const R1=/[ \t\n\r\f]+/g,N1=/[\t\n\r\f]| {2,}|^ | $/;function F1(i){const e=i??"normal";return e==="pre-wrap"?{mode:e,preserveOrdinarySpaces:!0,preserveHardBreaks:!0}:{mode:e,preserveOrdinarySpaces:!1,preserveHardBreaks:!1}}function D1(i){if(!N1.test(i))return i;let e=i.replace(R1," ");return e.charCodeAt(0)===32&&(e=e.slice(1)),e.length>0&&e.charCodeAt(e.length-1)===32&&(e=e.slice(0,-1)),e}function L1(i){return/[\r\f]/.test(i)?i.replace(/\r\n/g,`+`).replace(/[\r\f]/g,`+`):i.replace(/\r\n/g,`+`)}let Ed=null,P1;function k1(){return Ed===null&&(Ed=new Intl.Segmenter(P1,{granularity:"word"})),Ed}const U1=new RegExp("\\p{Script=Arabic}","u"),ml=new RegExp("\\p{M}","u"),Zg=new RegExp("\\p{Nd}","u");function $g(i){return U1.test(i)}function em(i){return i>=19968&&i<=40959||i>=13312&&i<=19903||i>=131072&&i<=173791||i>=173824&&i<=177983||i>=177984&&i<=178207||i>=178208&&i<=183983||i>=183984&&i<=191471||i>=191472&&i<=192093||i>=194560&&i<=195103||i>=196608&&i<=201551||i>=201552&&i<=205743||i>=205744&&i<=210041||i>=63744&&i<=64255||i>=12288&&i<=12351||i>=12352&&i<=12447||i>=12448&&i<=12543||i>=44032&&i<=55215||i>=65280&&i<=65519}function ur(i){for(let e=0;e<i.length;e++){const t=i.charCodeAt(e);if(!(t<12288)){if(t>=55296&&t<=56319&&e+1<i.length){const n=i.charCodeAt(e+1);if(n>=56320&&n<=57343){const s=(t-55296<<10)+(n-56320)+65536;if(em(s))return!0;e++;continue}}if(em(t))return!0}}return!1}function O1(i){const e=xl(i);return e!==null&&(yd.has(e)||dr.has(e))}const Q1=new Set([" "," ","","\uFEFF"]);function G1(i){return ur(i)}function H1(i){const e=xl(i);return e!==null&&Q1.has(e)}function z1(i){return!O1(i)&&!H1(i)}const yd=new Set([",",".","!",":",";","?","、","。","・",")","〕","〉","》","」","』","】","〗","〙","〛","ー","々","〻","ゝ","ゞ","ヽ","ヾ"]),bl=new Set(['"',"(","[","{","“","‘","«","‹","(","〔","〈","《","「","『","【","〖","〘","〚"]),wd=new Set(["'","’"]),dr=new Set([".",",","!","?",":",";","،","؛","؟","।","॥","၊","။","၌","၍","၏",")","]","}","%",'"',"”","’","»","›","…"]),V1=new Set([":",".","،","؛"]),W1=new Set(["၏"]),q1=new Set(["”","’","»","›","」","』","】","》","〉","〕",")"]);function K1(i){if(vd(i))return!0;let e=!1;for(const t of i){if(dr.has(t)){e=!0;continue}if(!(e&&ml.test(t)))return!1}return e}function j1(i){for(const e of i)if(!yd.has(e)&&!dr.has(e))return!1;return i.length>0}function X1(i){if(vd(i))return!0;for(const e of i)if(!bl.has(e)&&!wd.has(e)&&!ml.test(e))return!1;return i.length>0}function vd(i){let e=!1;for(const t of i)if(!(t==="\\"||ml.test(t))){if(bl.has(t)||dr.has(t)||wd.has(t)){e=!0;continue}return!1}return e}function tm(i,e){const t=e-1;if(t<=0)return Math.max(t,0);const n=i.charCodeAt(t);if(n<56320||n>57343)return t;const s=t-1;if(s<0)return t;const r=i.charCodeAt(s);return r>=55296&&r<=56319?s:t}function xl(i){if(i.length===0)return null;const e=tm(i,i.length);return i.slice(e)}function Y1(i){const e=Array.from(i);let t=e.length;for(;t>0;){const n=e[t-1];if(ml.test(n)){t--;continue}if(bl.has(n)||wd.has(n)){t--;continue}break}return t<=0||t===e.length?null:{head:e.slice(0,t).join(""),tail:e.slice(t).join("")}}function J1(i,e,t){return t==="text"&&!e&&i.length===1&&i!=="-"&&i!=="—"?i:null}function nm(i,e,t,n){const s=e[n],r=i[n];if(s==null)return r;const a=t[n];if(r.length===a)return r;const o=s.repeat(a);return i[n]=o,o}function im(i,e){return i&&e!==null&&V1.has(e)}function Z1(i){const e=xl(i);return e!==null&&W1.has(e)}function $1(i){if(i.length<2||i[0]!==" ")return null;const e=i.slice(1);return new RegExp("^\\p{M}+$","u").test(e)?{space:" ",marks:e}:null}function Cd(i){let e=i.length;for(;e>0;){const t=tm(i,e),n=i.slice(t,e);if(q1.has(n))return!0;if(!dr.has(n))return!1;e=t}return!1}function eM(i,e){if(e.preserveOrdinarySpaces||e.preserveHardBreaks){if(i===" ")return"preserved-space";if(i===" ")return"tab";if(e.preserveHardBreaks&&i===`+`)return"hard-break"}return i===" "?"space":i===" "||i===" "||i===""||i==="\uFEFF"?"glue":i===""?"zero-width-break":i===""?"soft-hyphen":"text"}const tM=/[\x20\t\n\xA0\xAD\u200B\u202F\u2060\uFEFF]/;function ti(i){return i.length===1?i[0]:i.join("")}function nM(i,e){const t=[];for(let n=i.length-1;n>=0;n--)t.push(i[n]);return t.push(e),ti(t)}function iM(i,e,t,n){if(!tM.test(i))return[{text:i,isWordLike:e,kind:"text",start:t}];const s=[];let r=null,a=[],o=t,c=!1,l=0;for(const h of i){const u=eM(h,n),d=u==="text"&&e;if(r!==null&&u===r&&d===c){a.push(h),l+=h.length;continue}r!==null&&s.push({text:ti(a),isWordLike:c,kind:r,start:o}),r=u,a=[h],o=t+l,c=d,l+=h.length}return r!==null&&s.push({text:ti(a),isWordLike:c,kind:r,start:o}),s}function Sd(i){return i==="space"||i==="preserved-space"||i==="zero-width-break"||i==="hard-break"}const sM=/^[A-Za-z][A-Za-z0-9+.-]*:$/;function rM(i,e){const t=i.texts[e];return t.startsWith("www.")?!0:sM.test(t)&&e+1<i.len&&i.kinds[e+1]==="text"&&i.texts[e+1]==="//"}function aM(i){return i.includes("?")&&(i.includes("://")||i.startsWith("www."))}function oM(i){const e=i.texts.slice(),t=i.isWordLike.slice(),n=i.kinds.slice(),s=i.starts.slice();for(let a=0;a<i.len;a++){if(n[a]!=="text"||!rM(i,a))continue;const o=[e[a]];let c=a+1;for(;c<i.len&&!Sd(n[c]);){o.push(e[c]),t[a]=!0;const l=e[c].includes("?");if(n[c]="text",e[c]="",c++,l)break}e[a]=ti(o)}let r=0;for(let a=0;a<e.length;a++){const o=e[a];o.length!==0&&(r!==a&&(e[r]=o,t[r]=t[a],n[r]=n[a],s[r]=s[a]),r++)}return e.length=r,t.length=r,n.length=r,s.length=r,{len:r,texts:e,isWordLike:t,kinds:n,starts:s}}function cM(i){const e=[],t=[],n=[],s=[];for(let r=0;r<i.len;r++){const a=i.texts[r];if(e.push(a),t.push(i.isWordLike[r]),n.push(i.kinds[r]),s.push(i.starts[r]),!aM(a))continue;const o=r+1;if(o>=i.len||Sd(i.kinds[o]))continue;const c=[],l=i.starts[o];let h=o;for(;h<i.len&&!Sd(i.kinds[h]);)c.push(i.texts[h]),h++;c.length>0&&(e.push(ti(c)),t.push(!0),n.push("text"),s.push(l),r=h-1)}return{len:e.length,texts:e,isWordLike:t,kinds:n,starts:s}}const lM=new Set([":","-","/","×",",",".","+","–","—"]),sm=/^[A-Za-z0-9_]+[,:;]*$/,rm=/[,:;]+$/;function am(i){for(const e of i)if(Zg.test(e))return!0;return!1}function _l(i){if(i.length===0)return!1;for(const e of i)if(!(Zg.test(e)||lM.has(e)))return!1;return!0}function hM(i){const e=[],t=[],n=[],s=[];for(let r=0;r<i.len;r++){const a=i.texts[r],o=i.kinds[r];if(o==="text"&&_l(a)&&am(a)){const c=[a];let l=r+1;for(;l<i.len&&i.kinds[l]==="text"&&_l(i.texts[l]);)c.push(i.texts[l]),l++;e.push(ti(c)),t.push(!0),n.push("text"),s.push(i.starts[r]),r=l-1;continue}e.push(a),t.push(i.isWordLike[r]),n.push(o),s.push(i.starts[r])}return{len:e.length,texts:e,isWordLike:t,kinds:n,starts:s}}function uM(i){const e=[],t=[],n=[],s=[];for(let r=0;r<i.len;r++){const a=i.texts[r],o=i.kinds[r],c=i.isWordLike[r];if(o==="text"&&c&&sm.test(a)){const l=[a];let h=rm.test(a),u=r+1;for(;h&&u<i.len&&i.kinds[u]==="text"&&i.isWordLike[u]&&sm.test(i.texts[u]);){const d=i.texts[u];l.push(d),h=rm.test(d),u++}e.push(ti(l)),t.push(!0),n.push("text"),s.push(i.starts[r]),r=u-1;continue}e.push(a),t.push(c),n.push(o),s.push(i.starts[r])}return{len:e.length,texts:e,isWordLike:t,kinds:n,starts:s}}function dM(i){const e=[],t=[],n=[],s=[];for(let r=0;r<i.len;r++){const a=i.texts[r];if(i.kinds[r]==="text"&&a.includes("-")){const o=a.split("-");let c=o.length>1;for(let l=0;l<o.length;l++){const h=o[l];if(!c)break;(h.length===0||!am(h)||!_l(h))&&(c=!1)}if(c){let l=0;for(let h=0;h<o.length;h++){const u=o[h],d=h<o.length-1?`${u}-`:u;e.push(d),t.push(!0),n.push("text"),s.push(i.starts[r]+l),l+=d.length}continue}}e.push(a),t.push(i.isWordLike[r]),n.push(i.kinds[r]),s.push(i.starts[r])}return{len:e.length,texts:e,isWordLike:t,kinds:n,starts:s}}function fM(i){const e=[],t=[],n=[],s=[];let r=0;for(;r<i.len;){const a=[i.texts[r]];let o=i.isWordLike[r],c=i.kinds[r],l=i.starts[r];if(c==="glue"){const h=[a[0]],u=l;for(r++;r<i.len&&i.kinds[r]==="glue";)h.push(i.texts[r]),r++;const d=ti(h);if(r<i.len&&i.kinds[r]==="text")a[0]=d,a.push(i.texts[r]),o=i.isWordLike[r],c="text",l=u,r++;else{e.push(d),t.push(!1),n.push("glue"),s.push(u);continue}}else r++;if(c==="text")for(;r<i.len&&i.kinds[r]==="glue";){const h=[];for(;r<i.len&&i.kinds[r]==="glue";)h.push(i.texts[r]),r++;const u=ti(h);if(r<i.len&&i.kinds[r]==="text"){a.push(u,i.texts[r]),o=o||i.isWordLike[r],r++;continue}a.push(u)}e.push(ti(a)),t.push(o),n.push(c),s.push(l)}return{len:e.length,texts:e,isWordLike:t,kinds:n,starts:s}}function pM(i){const e=i.texts.slice(),t=i.isWordLike.slice(),n=i.kinds.slice(),s=i.starts.slice();for(let r=0;r<e.length-1;r++){if(n[r]!=="text"||n[r+1]!=="text"||!ur(e[r])||!ur(e[r+1]))continue;const a=Y1(e[r]);a!==null&&(e[r]=a.head,e[r+1]=a.tail+e[r+1],s[r+1]=s[r]+a.head.length)}return{len:e.length,texts:e,isWordLike:t,kinds:n,starts:s}}function om(i,e,t){const n=k1();let s=0;const r=[],a=[],o=[],c=[],l=[],h=[],u=[],d=[],f=[],m=[],A=[],g=[];for(const w of n.segment(i))for(const S of iM(w.segment,w.isWordLike??!1,w.index,t)){let O=function(){h[D]!==null&&(a[D]=[nm(r,h,u,D)],h[D]=null),a[D].push(S.text),o[D]=o[D]||S.isWordLike,d[D]=d[D]||v,f[D]=f[D]||F,m[D]=q,A[D]=$,g[D]=im(f[D],K)};const T=S.kind==="text",C=J1(S.text,S.isWordLike,S.kind),v=ur(S.text),F=$g(S.text),K=xl(S.text),q=Cd(S.text),$=Z1(S.text),D=s-1;e.carryCJKAfterClosingQuote&&T&&s>0&&c[D]==="text"&&v&&d[D]&&m[D]||T&&s>0&&c[D]==="text"&&j1(S.text)&&d[D]||T&&s>0&&c[D]==="text"&&A[D]?O():T&&s>0&&c[D]==="text"&&S.isWordLike&&F&&g[D]?(O(),o[D]=!0):C!==null&&s>0&&c[D]==="text"&&h[D]===C?u[D]=(u[D]??1)+1:T&&!S.isWordLike&&s>0&&c[D]==="text"&&(K1(S.text)||S.text==="-"&&o[D])?O():(r[s]=S.text,a[s]=[S.text],o[s]=S.isWordLike,c[s]=S.kind,l[s]=S.start,h[s]=C,u[s]=C===null?0:1,d[s]=v,f[s]=F,m[s]=q,A[s]=$,g[s]=im(F,K),s++)}for(let w=0;w<s;w++){if(h[w]!==null){r[w]=nm(r,h,u,w);continue}r[w]=ti(a[w])}for(let w=1;w<s;w++)c[w]==="text"&&!o[w]&&vd(r[w])&&c[w-1]==="text"&&(r[w-1]+=r[w],o[w-1]=o[w-1]||o[w],r[w]="");const p=Array.from({length:s},()=>null);let y=-1;for(let w=s-1;w>=0;w--){const S=r[w];if(S.length!==0){if(c[w]==="text"&&!o[w]&&X1(S)&&y>=0&&c[y]==="text"){const T=p[y]??[];T.push(S),p[y]=T,l[y]=l[w],r[w]="";continue}y=w}}for(let w=0;w<s;w++){const S=p[w];S!=null&&(r[w]=nM(S,r[w]))}let b=0;for(let w=0;w<s;w++){const S=r[w];S.length!==0&&(b!==w&&(r[b]=S,o[b]=o[w],c[b]=c[w],l[b]=l[w]),b++)}r.length=b,o.length=b,c.length=b,l.length=b;const E=fM({len:b,texts:r,isWordLike:o,kinds:c,starts:l}),M=pM(uM(dM(hM(cM(oM(E))))));for(let w=0;w<M.len-1;w++){const S=$1(M.texts[w]);S!==null&&(M.kinds[w]!=="space"&&M.kinds[w]!=="preserved-space"||M.kinds[w+1]!=="text"||!$g(M.texts[w+1])||(M.texts[w]=S.space,M.isWordLike[w]=!1,M.kinds[w]=M.kinds[w]==="preserved-space"?"preserved-space":"space",M.texts[w+1]=S.marks+M.texts[w+1],M.starts[w+1]=M.starts[w]+S.space.length))}return M}function AM(i,e){if(i.len===0)return[];if(!e.preserveHardBreaks)return[{startSegmentIndex:0,endSegmentIndex:i.len,consumedEndSegmentIndex:i.len}];const t=[];let n=0;for(let s=0;s<i.len;s++)i.kinds[s]==="hard-break"&&(t.push({startSegmentIndex:n,endSegmentIndex:s,consumedEndSegmentIndex:s+1}),n=s+1);return n<i.len&&t.push({startSegmentIndex:n,endSegmentIndex:i.len,consumedEndSegmentIndex:i.len}),t}function gM(i){if(i.len<=1)return i;const e=[],t=[],n=[],s=[];let r=null,a=!1,o=0,c=!1,l=!1;function h(){r!==null&&(e.push(ti(r)),t.push(a),n.push("text"),s.push(o),r=null)}for(let u=0;u<i.len;u++){const d=i.texts[u],f=i.kinds[u],m=i.isWordLike[u],A=i.starts[u];if(f==="text"){const g=G1(d),p=z1(d);if(r!==null&&c&&l){r.push(d),a=a||m,c=c||g,l=p;continue}h(),r=[d],a=m,o=A,c=g,l=p;continue}h(),e.push(d),t.push(m),n.push(f),s.push(A)}return h(),{len:e.length,texts:e,isWordLike:t,kinds:n,starts:s}}function mM(i,e,t="normal",n="normal"){const s=F1(t),r=s.mode==="pre-wrap"?L1(i):D1(i);if(r.length===0)return{normalized:r,chunks:[],len:0,texts:[],isWordLike:[],kinds:[],starts:[]};const a=n==="keep-all"?gM(om(r,e,s)):om(r,e,s);return{normalized:r,chunks:AM(a,s),...a}}let Ea=null;const cm=new Map;let ya=null;const bM=96,xM=new RegExp("\\p{Emoji_Presentation}","u"),_M=/[\p{Emoji_Presentation}\p{Extended_Pictographic}\p{Regional_Indicator}\uFE0F\u20E3]/u;let Id=null;const lm=new Map;function Md(){if(Ea!==null)return Ea;if(typeof OffscreenCanvas<"u")return Ea=new OffscreenCanvas(1,1).getContext("2d"),Ea;if(typeof document<"u")return Ea=document.createElement("canvas").getContext("2d"),Ea;throw new Error("Text measurement requires OffscreenCanvas or a DOM canvas context.")}function EM(i){let e=cm.get(i);return e||(e=new Map,cm.set(i,e)),e}function Ps(i,e){let t=e.get(i);return t===void 0&&(t={width:Md().measureText(i).width,containsCJK:ur(i)},e.set(i,t)),t}function wa(){if(ya!==null)return ya;if(typeof navigator>"u")return ya={lineFitEpsilon:.005,carryCJKAfterClosingQuote:!1,preferPrefixWidthsForBreakableRuns:!1,preferEarlySoftHyphenBreak:!1},ya;const i=navigator.userAgent,t=navigator.vendor==="Apple Computer, Inc."&&i.includes("Safari/")&&!i.includes("Chrome/")&&!i.includes("Chromium/")&&!i.includes("CriOS/")&&!i.includes("FxiOS/")&&!i.includes("EdgiOS/"),n=i.includes("Chrome/")||i.includes("Chromium/")||i.includes("CriOS/")||i.includes("Edg/");return ya={lineFitEpsilon:t?1/64:.005,carryCJKAfterClosingQuote:n,preferPrefixWidthsForBreakableRuns:t,preferEarlySoftHyphenBreak:t},ya}function yM(i){const e=i.match(/(\d+(?:\.\d+)?)\s*px/);return e?parseFloat(e[1]):16}function hm(){return Id===null&&(Id=new Intl.Segmenter(void 0,{granularity:"grapheme"})),Id}function wM(i){return xM.test(i)||i.includes("️")}function vM(i){return _M.test(i)}function CM(i,e){let t=lm.get(i);if(t!==void 0)return t;const n=Md();n.font=i;const s=n.measureText("😀").width;if(t=0,s>e+.5&&typeof document<"u"&&document.body!==null){const r=document.createElement("span");r.style.font=i,r.style.display="inline-block",r.style.visibility="hidden",r.style.position="absolute",r.textContent="😀",document.body.appendChild(r);const a=r.getBoundingClientRect().width;document.body.removeChild(r),s-a>.5&&(t=s-a)}return lm.set(i,t),t}function SM(i){let e=0;const t=hm();for(const n of t.segment(i))wM(n.segment)&&e++;return e}function IM(i,e){return e.emojiCount===void 0&&(e.emojiCount=SM(i)),e.emojiCount}function fr(i,e,t){return t===0?e.width:e.width-IM(i,e)*t}function MM(i,e,t,n,s){if(e.breakableFitAdvances!==void 0)return e.breakableFitAdvances;const r=hm(),a=[];for(const h of r.segment(i))a.push(h.segment);if(a.length<=1)return e.breakableFitAdvances=null,e.breakableFitAdvances;if(s==="sum-graphemes"){const h=[];for(const u of a){const d=Ps(u,t);h.push(fr(u,d,n))}return e.breakableFitAdvances=h,e.breakableFitAdvances}if(s==="pair-context"||a.length>bM){const h=[];let u=null,d=0;for(const f of a){const m=Ps(f,t),A=fr(f,m,n);if(u===null)h.push(A);else{const g=u+f,p=Ps(g,t);h.push(fr(g,p,n)-d)}u=f,d=A}return e.breakableFitAdvances=h,e.breakableFitAdvances}const o=[];let c="",l=0;for(const h of a){c+=h;const u=Ps(c,t),d=fr(c,u,n);o.push(d-l),l=d}return e.breakableFitAdvances=o,e.breakableFitAdvances}function BM(i,e){const t=Md();t.font=i;const n=EM(i),s=yM(i),r=e?CM(i,s):0;return{cache:n,fontSize:s,emojiCorrection:r}}function TM(i,e){for(;e<i.widths.length;){const t=i.kinds[e];if(t!=="space"&&t!=="zero-width-break"&&t!=="soft-hyphen")break;e++}return e}function um(i,e){if(e<=0)return 0;const t=i%e;return Math.abs(t)<=1e-6?e:e-t}function dm(i,e,t,n,s){let r=0,a=e;for(;r<i.length;){const o=a+i[r];if((r+1<i.length?o+s:o)>t+n)break;a=o,r++}return{fitCount:r,fittedWidth:a}}function RM(i,e){let t=0,n=i.chunks.length;for(;t<n;){const s=Math.floor((t+n)/2);e<i.chunks[s].consumedEndSegmentIndex?n=s:t=s+1}return t<i.chunks.length?t:-1}function fm(i,e,t){let n=t.segmentIndex;if(t.graphemeIndex>0)return e;const s=i.chunks[e];if(s.startSegmentIndex===s.endSegmentIndex&&n===s.startSegmentIndex)return t.segmentIndex=n,t.graphemeIndex=0,e;for(n<s.startSegmentIndex&&(n=s.startSegmentIndex);n<s.endSegmentIndex;){const r=i.kinds[n];if(r!=="space"&&r!=="zero-width-break"&&r!=="soft-hyphen")return t.segmentIndex=n,t.graphemeIndex=0,e;n++}return s.consumedEndSegmentIndex>=i.widths.length?-1:(t.segmentIndex=s.consumedEndSegmentIndex,t.graphemeIndex=0,e+1)}function Bd(i,e){if(e.segmentIndex>=i.widths.length)return-1;const t=RM(i,e.segmentIndex);return t<0?-1:fm(i,t,e)}function NM(i,e,t){if(t.segmentIndex>=i.widths.length)return-1;let n=e;for(;n<i.chunks.length&&t.segmentIndex>=i.chunks[n].consumedEndSegmentIndex;)n++;return n>=i.chunks.length?-1:fm(i,n,t)}function FM(i,e){return i.simpleLineWalkFastPath?pm(i,e):Td(i,e)}function pm(i,e,t){const{widths:n,kinds:s,breakableFitAdvances:r}=i;if(n.length===0)return 0;const o=wa().lineFitEpsilon,c=e+o;let l=0,h=0,u=!1,d=0,f=0,m=0,A=0,g=-1,p=0;function y(){g=-1,p=0}function b(C=m,v=A,F=h){l++,t?.({startSegmentIndex:d,startGraphemeIndex:f,endSegmentIndex:C,endGraphemeIndex:v,width:F}),h=0,u=!1,y()}function E(C,v){u=!0,d=C,f=0,m=C+1,A=0,h=v}function M(C,v,F){u=!0,d=C,f=v,m=C,A=v+1,h=F}function w(C,v){if(!u){E(C,v);return}h+=v,m=C+1,A=0}function S(C,v){const F=r[C];for(let K=v;K<F.length;K++){const q=F[K];u?h+q>c?(b(),M(C,K,q)):(h+=q,m=C,A=K+1):M(C,K,q)}u&&m===C&&A===F.length&&(m=C+1,A=0)}let T=0;for(;T<n.length&&!(!u&&(T=TM(i,T),T>=n.length));){const C=n[T],v=s[T],F=v==="space"||v==="preserved-space"||v==="tab"||v==="zero-width-break"||v==="soft-hyphen";if(!u){C>e&&r[T]!==null?S(T,0):E(T,C),F&&(g=T+1,p=h-C),T++;continue}if(h+C>c){if(F){w(T,C),b(T+1,0,h-C),T++;continue}if(g>=0){if(m>g||m===g&&A>0){b();continue}b(g,0,p);continue}if(C>e&&r[T]!==null){b(),S(T,0),T++;continue}b();continue}w(T,C),F&&(g=T+1,p=h-C),T++}return u&&b(),l}function Td(i,e,t){if(i.simpleLineWalkFastPath)return pm(i,e,t);const{widths:n,lineEndFitAdvances:s,lineEndPaintAdvances:r,kinds:a,breakableFitAdvances:o,discretionaryHyphenWidth:c,tabStopAdvance:l,chunks:h}=i;if(n.length===0||h.length===0)return 0;const u=wa(),d=u.lineFitEpsilon,f=e+d;let m=0,A=0,g=!1,p=0,y=0,b=0,E=0,M=-1,w=0,S=0,T=null;function C(){M=-1,w=0,S=0,T=null}function v(Q=b,J=E,ee=A){m++,t?.({startSegmentIndex:p,startGraphemeIndex:y,endSegmentIndex:Q,endGraphemeIndex:J,width:ee}),A=0,g=!1,C()}function F(Q,J){g=!0,p=Q,y=0,b=Q+1,E=0,A=J}function K(Q,J,ee){g=!0,p=Q,y=J,b=Q,E=J+1,A=ee}function q(Q,J){if(!g){F(Q,J);return}A+=J,b=Q+1,E=0}function $(Q,J,ee,ae){if(!J)return;const ye=Q==="tab"?0:s[ee],Me=Q==="tab"?ae:r[ee];M=ee+1,w=A-ae+ye,S=A-ae+Me,T=Q}function D(Q,J){const ee=o[Q];for(let ae=J;ae<ee.length;ae++){const ye=ee[ae];g?A+ye>f?(v(),K(Q,ae,ye)):(A+=ye,b=Q,E=ae+1):K(Q,ae,ye)}g&&b===Q&&E===ee.length&&(b=Q+1,E=0)}function O(Q){if(T!=="soft-hyphen")return!1;const J=o[Q];if(J==null)return!1;const{fitCount:ee,fittedWidth:ae}=dm(J,A,e,d,c);return ee===0?!1:(A=ae,b=Q,E=ee,C(),ee===J.length?(b=Q+1,E=0,!0):(v(Q,ee,ae+c),D(Q,ee),!0))}function Y(Q){m++,t?.({startSegmentIndex:Q.startSegmentIndex,startGraphemeIndex:0,endSegmentIndex:Q.consumedEndSegmentIndex,endGraphemeIndex:0,width:0}),C()}for(let Q=0;Q<h.length;Q++){const J=h[Q];if(J.startSegmentIndex===J.endSegmentIndex){Y(J);continue}g=!1,A=0,p=J.startSegmentIndex,y=0,b=J.startSegmentIndex,E=0,C();let ee=J.startSegmentIndex;for(;ee<J.endSegmentIndex;){const ae=a[ee],ye=ae==="space"||ae==="preserved-space"||ae==="tab"||ae==="zero-width-break"||ae==="soft-hyphen",Me=ae==="tab"?um(A,l):n[ee];if(ae==="soft-hyphen"){g&&(b=ee+1,E=0,M=ee+1,w=A+c,S=A+c,T=ae),ee++;continue}if(!g){Me>e&&o[ee]!==null?D(ee,0):F(ee,Me),$(ae,ye,ee,Me),ee++;continue}if(A+Me>f){const me=A+(ae==="tab"?0:s[ee]),be=A+(ae==="tab"?Me:r[ee]);if(T==="soft-hyphen"&&u.preferEarlySoftHyphenBreak&&w<=f){v(M,0,S);continue}if(T==="soft-hyphen"&&O(ee)){ee++;continue}if(ye&&me<=f){q(ee,Me),v(ee+1,0,be),ee++;continue}if(M>=0&&w<=f){if(b>M||b===M&&E>0){v();continue}const xe=M;v(xe,0,S),ee=xe;continue}if(Me>e&&o[ee]!==null){v(),D(ee,0),ee++;continue}v();continue}q(ee,Me),$(ae,ye,ee,Me),ee++}if(g){const ae=M===J.consumedEndSegmentIndex?S:A;v(J.consumedEndSegmentIndex,0,ae)}}return m}function Rd(i,e,t,n){const s=i.chunks[t];if(s.startSegmentIndex===s.endSegmentIndex)return e.segmentIndex=s.consumedEndSegmentIndex,e.graphemeIndex=0,0;const{widths:r,lineEndFitAdvances:a,lineEndPaintAdvances:o,kinds:c,breakableFitAdvances:l,discretionaryHyphenWidth:h,tabStopAdvance:u}=i,d=wa(),f=d.lineFitEpsilon,m=n+f;let A=0,g=!1,p=e.segmentIndex,y=e.graphemeIndex,b=-1,E=0,M=0,w=null;function S(){b=-1,E=0,M=0,w=null}function T(D=p,O=y,Y=A){return g?(e.segmentIndex=D,e.graphemeIndex=O,Y):null}function C(D,O){g=!0,p=D+1,y=0,A=O}function v(D,O,Y){g=!0,p=D,y=O+1,A=Y}function F(D,O){if(!g){C(D,O);return}A+=O,p=D+1,y=0}function K(D,O,Y,Q){if(!O)return;const J=D==="tab"?0:a[Y],ee=D==="tab"?Q:o[Y];b=Y+1,E=A-Q+J,M=A-Q+ee,w=D}function q(D,O){const Y=l[D];for(let Q=O;Q<Y.length;Q++){const J=Y[Q];if(!g)v(D,Q,J);else{if(A+J>m)return T();A+=J,p=D,y=Q+1}}return g&&p===D&&y===Y.length&&(p=D+1,y=0),null}function $(D){if(w!=="soft-hyphen"||b<0)return null;const O=l[D]??null;if(O!==null){const{fitCount:Y,fittedWidth:Q}=dm(O,A,n,f,h);if(Y===O.length)return A=Q,p=D+1,y=0,S(),null;if(Y>0)return T(D,Y,Q+h)}return E<=m?T(b,0,M):null}for(let D=e.segmentIndex;D<s.endSegmentIndex;D++){const O=c[D],Y=O==="space"||O==="preserved-space"||O==="tab"||O==="zero-width-break"||O==="soft-hyphen",Q=D===e.segmentIndex?e.graphemeIndex:0,J=O==="tab"?um(A,u):r[D];if(O==="soft-hyphen"&&Q===0){g&&(p=D+1,y=0,b=D+1,E=A+h,M=A+h,w=O);continue}if(!g){if(Q>0){const ae=q(D,Q);if(ae!==null)return ae}else if(J>n&&l[D]!==null){const ae=q(D,0);if(ae!==null)return ae}else C(D,J);K(O,Y,D,J);continue}if(A+J>m){const ae=A+(O==="tab"?0:a[D]),ye=A+(O==="tab"?J:o[D]);if(w==="soft-hyphen"&&d.preferEarlySoftHyphenBreak&&E<=m)return T(b,0,M);const Me=$(D);if(Me!==null)return Me;if(Y&&ae<=m)return F(D,J),T(D+1,0,ye);if(b>=0&&E<=m)return p>b||p===b&&y>0?T():T(b,0,M);if(J>n&&l[D]!==null){const se=T();if(se!==null)return se;const me=q(D,0);if(me!==null)return me}return T()}F(D,J),K(O,Y,D,J)}return b===s.consumedEndSegmentIndex&&y===0?T(s.consumedEndSegmentIndex,0,M):T(s.consumedEndSegmentIndex,0,A)}function Am(i,e,t){const{widths:n,kinds:s,breakableFitAdvances:r}=i,o=wa().lineFitEpsilon,c=t+o;let l=0,h=!1,u=e.segmentIndex,d=e.graphemeIndex,f=-1,m=0;for(let A=e.segmentIndex;A<n.length;A++){const g=n[A],p=s[A],y=p==="space"||p==="preserved-space"||p==="tab"||p==="zero-width-break"||p==="soft-hyphen",b=A===e.segmentIndex?e.graphemeIndex:0,E=r[A];if(!h){if(b>0||g>t&&E!==null){const M=E,w=M[b];h=!0,l=w,u=A,d=b+1;for(let S=b+1;S<M.length;S++){const T=M[S];if(l+T>c)return e.segmentIndex=u,e.graphemeIndex=d,l;l+=T,u=A,d=S+1}u===A&&d===M.length&&(u=A+1,d=0)}else h=!0,l=g,u=A+1,d=0;y&&(f=A+1,m=l-g);continue}if(l+g>c)return y?(e.segmentIndex=A+1,e.graphemeIndex=0,l):f>=0?u>f||u===f&&d>0?(e.segmentIndex=u,e.graphemeIndex=d,l):(e.segmentIndex=f,e.graphemeIndex=0,m):(e.segmentIndex=u,e.graphemeIndex=d,l);l+=g,u=A+1,d=0,y&&(f=A+1,m=l-g)}return h?(e.segmentIndex=u,e.graphemeIndex=d,l):null}function Nd(i,e,t){const n={segmentIndex:e.segmentIndex,graphemeIndex:e.graphemeIndex},s=Bd(i,n);if(s<0)return null;const r=n.segmentIndex,a=n.graphemeIndex,o=i.simpleLineWalkFastPath?Am(i,n,t):Rd(i,n,s,t);return o===null?null:{startSegmentIndex:r,startGraphemeIndex:a,endSegmentIndex:n.segmentIndex,endGraphemeIndex:n.graphemeIndex,width:o}}function DM(i,e,t){const n=Bd(i,e);return n<0?null:i.simpleLineWalkFastPath?Am(i,e,t):Rd(i,e,n,t)}function LM(i,e){if(i.widths.length===0)return{lineCount:0,maxLineWidth:0};const t={segmentIndex:0,graphemeIndex:0};let n=0,s=0;if(!i.simpleLineWalkFastPath){let r=Bd(i,t);for(;r>=0;){const a=Rd(i,t,r,e);if(a===null)return{lineCount:n,maxLineWidth:s};n++,a>s&&(s=a),r=NM(i,r,t)}return{lineCount:n,maxLineWidth:s}}for(;;){const r=DM(i,t,e);if(r===null)return{lineCount:n,maxLineWidth:s};n++,r>s&&(s=r)}}let Fd=null,gm=new WeakMap;function mm(){return Fd===null&&(Fd=new Intl.Segmenter(void 0,{granularity:"grapheme"})),Fd}function PM(i){return i?{widths:[],lineEndFitAdvances:[],lineEndPaintAdvances:[],kinds:[],simpleLineWalkFastPath:!0,segLevels:null,breakableFitAdvances:[],discretionaryHyphenWidth:0,tabStopAdvance:0,chunks:[],segments:[]}:{widths:[],lineEndFitAdvances:[],lineEndPaintAdvances:[],kinds:[],simpleLineWalkFastPath:!0,segLevels:null,breakableFitAdvances:[],discretionaryHyphenWidth:0,tabStopAdvance:0,chunks:[]}}function kM(i,e){const t=[];let n=[],s=0,r=!1,a=!1,o=!1;function c(){n.length!==0&&(t.push({text:n.length===1?n[0]:n.join(""),start:s}),n=[],r=!1,a=!1,o=!1)}function l(u,d,f){n=[u],s=d,r=f,a=Cd(u),o=bl.has(u)}function h(u,d){n.push(u),r=r||d;const f=Cd(u);u.length===1&&dr.has(u)?a=a||f:a=f,o=!1}for(const u of mm().segment(i)){const d=u.segment,f=ur(d);if(n.length===0){l(d,u.index,f);continue}if(o||yd.has(d)||dr.has(d)||e.carryCJKAfterClosingQuote&&f&&a){h(d,f);continue}if(!r&&!f){h(d,f);continue}c(),l(d,u.index,f)}return c(),t}function UM(i,e,t,n){const s=wa(),{cache:r,emojiCorrection:a}=BM(e,vM(i.normalized)),o=fr("-",Ps("-",r),a),l=fr(" ",Ps(" ",r),a)*8;if(i.len===0)return PM(t);const h=[],u=[],d=[],f=[];let m=i.chunks.length<=1;const A=t?[]:null,g=[],p=t?[]:null,y=Array.from({length:i.len});function b(S,T,C,v,F,K,q){F!=="text"&&F!=="space"&&F!=="zero-width-break"&&(m=!1),h.push(T),u.push(C),d.push(v),f.push(F),A?.push(K),g.push(q),p!==null&&p.push(S)}function E(S,T,C,v,F){const K=Ps(S,r),q=fr(S,K,a),$=T==="space"||T==="preserved-space"||T==="zero-width-break"?0:q,D=T==="space"||T==="zero-width-break"?0:q;if(F&&v&&S.length>1){let O="sum-graphemes";_l(S)?O="pair-context":s.preferPrefixWidthsForBreakableRuns&&(O="segment-prefixes");const Y=MM(S,K,r,a,O);b(S,q,$,D,T,C,Y);return}b(S,q,$,D,T,C,null)}for(let S=0;S<i.len;S++){y[S]=h.length;const T=i.texts[S],C=i.isWordLike[S],v=i.kinds[S],F=i.starts[S];if(v==="soft-hyphen"){b(T,0,o,o,v,F,null);continue}if(v==="hard-break"){b(T,0,0,0,v,F,null);continue}if(v==="tab"){b(T,0,0,0,v,F,null);continue}const K=Ps(T,r);if(v==="text"&&K.containsCJK){const $=kM(T,s);for(let D=0;D<$.length;D++){const O=$[D];E(O.text,"text",F+O.start,C,!ur(O.text))}continue}E(T,v,F,C,!0)}const M=OM(i.chunks,y,h.length),w=A===null?null:T1(i.normalized,A);return p!==null?{widths:h,lineEndFitAdvances:u,lineEndPaintAdvances:d,kinds:f,simpleLineWalkFastPath:m,segLevels:w,breakableFitAdvances:g,discretionaryHyphenWidth:o,tabStopAdvance:l,chunks:M,segments:p}:{widths:h,lineEndFitAdvances:u,lineEndPaintAdvances:d,kinds:f,simpleLineWalkFastPath:m,segLevels:w,breakableFitAdvances:g,discretionaryHyphenWidth:o,tabStopAdvance:l,chunks:M}}function OM(i,e,t){const n=[];for(let s=0;s<i.length;s++){const r=i[s],a=r.startSegmentIndex<e.length?e[r.startSegmentIndex]:t,o=r.endSegmentIndex<e.length?e[r.endSegmentIndex]:t,c=r.consumedEndSegmentIndex<e.length?e[r.consumedEndSegmentIndex]:t;n.push({startSegmentIndex:a,endSegmentIndex:o,consumedEndSegmentIndex:c})}return n}function bm(i,e,t,n){const r=mM(i,wa(),n?.whiteSpace,"normal");return UM(r,e,t)}function El(i,e,t){return bm(i,e,!1,t)}function yl(i,e,t){return bm(i,e,!0,t)}function b2(i){return i}function QM(i,e,t){const n=FM(i,e);return{lineCount:n,height:n*t}}function xm(i,e,t){let n=t.get(i);if(n!==void 0)return n;n=[];const s=mm();for(const r of s.segment(e[i]))n.push(r.segment);return t.set(i,n),n}function _m(i){let e=gm.get(i);return e!==void 0||(e=new Map,gm.set(i,e)),e}function GM(i,e,t,n){return n>0&&i[n-1]==="soft-hyphen"&&!(e===n&&t>0)}function HM(i,e,t,n,s,r,a){let o="";const c=GM(e,n,s,r);for(let l=n;l<r;l++)e[l]==="soft-hyphen"||e[l]==="hard-break"||(l===n&&s>0?o+=xm(l,i,t).slice(s).join(""):o+=i[l]);return a>0?(c&&(o+="-"),o+=xm(r,i,t).slice(n===r?s:0,a).join("")):c&&(o+="-"),o}function Em(i,e,t,n,s,r,a){return{text:HM(i.segments,i.kinds,e,n,s,r,a),width:t,start:{segmentIndex:n,graphemeIndex:s},end:{segmentIndex:r,graphemeIndex:a}}}function zM(i,e,t){return Em(i,e,t.width,t.startSegmentIndex,t.startGraphemeIndex,t.endSegmentIndex,t.endGraphemeIndex)}function VM(i){return{width:i.width,start:{segmentIndex:i.startSegmentIndex,graphemeIndex:i.startGraphemeIndex},end:{segmentIndex:i.endSegmentIndex,graphemeIndex:i.endGraphemeIndex}}}function WM(i,e){return Em(i,_m(i),e.width,e.start.segmentIndex,e.start.graphemeIndex,e.end.segmentIndex,e.end.graphemeIndex)}function qM(i,e,t){return i.widths.length===0?0:Td(i,e,n=>{t(VM(n))})}function Dd(i,e){return LM(i,e)}function ym(i){let e=0;return qM(i,Number.POSITIVE_INFINITY,t=>{t.width>e&&(e=t.width)}),e}function KM(i,e,t){const n=[];if(i.widths.length===0)return{lineCount:0,height:0,lines:n};const s=_m(i),r=Td(i,e,a=>{n.push(zM(i,s,a))});return{lineCount:r,height:r*t,lines:n}}const jM=/[ \t\n\f\r]+/,wm=/^[ \t\n\f\r]+/,vm=/[ \t\n\f\r]+$/,wl={segmentIndex:0,graphemeIndex:0},Cm={itemIndex:0,segmentIndex:0,graphemeIndex:0};function x2(i){return i}function Ld(i){return{segmentIndex:i.segmentIndex,graphemeIndex:i.graphemeIndex}}function Sm(i){return i.segmentIndex===0&&i.graphemeIndex===0}function vl(i,e){const t=e.get(i);if(t!==void 0)return t;const n=ym(yl("A A",i)),s=ym(yl("AA",i)),r=Math.max(0,n-s);return e.set(i,r),r}function XM(i){const e=Nd(i,wl,Number.POSITIVE_INFINITY);return e===null?null:{endGraphemeIndex:e.endGraphemeIndex,endSegmentIndex:e.endSegmentIndex,width:e.width}}function YM(i,e){return i===0&&e>0}function Im(i){const e=[],t=Array.from({length:i.length}),n=new Map;let s=0;for(let r=0;r<i.length;r++){const a=i[r],o=wm.test(a.text),c=vm.test(a.text),l=a.text.replace(wm,"").replace(vm,"");if(l.length===0){jM.test(a.text)&&s===0&&(s=vl(a.font,n));continue}const h=s>0?s:o?vl(a.font,n):0,u=yl(l,a.font),d=XM(u);if(d===null){s=c?vl(a.font,n):0;continue}const f={break:a.break??"normal",endGraphemeIndex:d.endGraphemeIndex,endSegmentIndex:d.endSegmentIndex,extraWidth:a.extraWidth??0,gapBefore:h,naturalWidth:d.width,prepared:u,sourceItemIndex:r};e.push(f),t[r]=f,s=c?vl(a.font,n):0}return{items:e,itemsBySourceItemIndex:t}}function JM(i,e,t,n){if(i.items.length===0||t.itemIndex>=i.items.length)return null;const s=Math.max(1,e);let r=0,a=s,o=t.itemIndex;const c={segmentIndex:t.segmentIndex,graphemeIndex:t.graphemeIndex};e:for(;o<i.items.length;){const l=i.items[o];if(!Sm(c)&&c.segmentIndex===l.endSegmentIndex&&c.graphemeIndex===l.endGraphemeIndex){o++,c.segmentIndex=0,c.graphemeIndex=0;continue}const h=r===0?0:l.gapBefore,u=Sm(c);if(l.break==="never"){if(!u){o++,c.segmentIndex=0,c.graphemeIndex=0;continue}const A=l.naturalWidth+l.extraWidth,g=h+A;if(r>0&&g>a)break e;n?.(l,h,A,Ld(wl),{segmentIndex:l.endSegmentIndex,graphemeIndex:l.endGraphemeIndex}),r+=g,a=Math.max(0,s-r),o++,c.segmentIndex=0,c.graphemeIndex=0;continue}const d=h+l.extraWidth;if(r>0&&d>=a)break e;if(u){const A=d+l.naturalWidth;if(A<=a){n?.(l,h,l.naturalWidth+l.extraWidth,Ld(wl),{segmentIndex:l.endSegmentIndex,graphemeIndex:l.endGraphemeIndex}),r+=A,a=Math.max(0,s-r),o++,c.segmentIndex=0,c.graphemeIndex=0;continue}}const f=Math.max(1,a-d),m=Nd(l.prepared,c,f);if(m===null){o++,c.segmentIndex=0,c.graphemeIndex=0;continue}if(c.segmentIndex===m.endSegmentIndex&&c.graphemeIndex===m.endGraphemeIndex){o++,c.segmentIndex=0,c.graphemeIndex=0;continue}if(r>0&&u&&h>0&&YM(m.endSegmentIndex,m.endGraphemeIndex)){const A=Nd(l.prepared,wl,Math.max(1,s-l.extraWidth));if(A!==null&&(A.endSegmentIndex>m.endSegmentIndex||A.endSegmentIndex===m.endSegmentIndex&&A.endGraphemeIndex>m.endGraphemeIndex))break e}if(n?.(l,h,m.width+l.extraWidth,Ld(c),{segmentIndex:m.endSegmentIndex,graphemeIndex:m.endGraphemeIndex}),r+=h+m.width+l.extraWidth,a=Math.max(0,s-r),m.endSegmentIndex===l.endSegmentIndex&&m.endGraphemeIndex===l.endGraphemeIndex){o++,c.segmentIndex=0,c.graphemeIndex=0;continue}c.segmentIndex=m.endSegmentIndex,c.graphemeIndex=m.endGraphemeIndex;break}return r===0?null:(t.itemIndex=o,t.segmentIndex=c.segmentIndex,t.graphemeIndex=c.graphemeIndex,r)}function ZM(i,e,t=Cm){const n=i,s={itemIndex:t.itemIndex,segmentIndex:t.segmentIndex,graphemeIndex:t.graphemeIndex},r=[],a=JM(n,e,s,(o,c,l,h,u)=>{r.push({itemIndex:o.sourceItemIndex,gapBefore:c,occupiedWidth:l,start:h,end:u})});return a===null?null:{fragments:r,width:a,end:s}}function $M(i,e){return WM(i.prepared,{width:e.occupiedWidth-i.extraWidth,start:e.start,end:e.end}).text}function Mm(i,e){const t=i;return{fragments:e.fragments.map(n=>{const s=t.itemsBySourceItemIndex[n.itemIndex];if(s===void 0)throw new Error("Missing rich-text inline item for fragment");return{...n,text:$M(s,n)}}),width:e.width,end:e.end}}function Bm(i,e,t){let n=0,s=Cm;for(;;){const r=ZM(i,e,s);if(r===null)return n;t(r),n++,s=r.end}}const Tm="500 14px Inter, sans-serif",Pd="600 10px Inter, sans-serif",kd="300 13px Inter, sans-serif",Rm="600 10px Inter, sans-serif",Nm="300 12px Inter, sans-serif",Ro=18,Cl=16,hn=16,Pi=6,Fm=12,Sl=Math.min(window.devicePixelRatio||1,2),eB="rgba(0, 0, 0, 0.75)",tB="rgba(255, 255, 255, 0.08)",nB="rgba(255, 255, 255, 0.9)",iB="rgba(255, 255, 255, 0.30)",sB="rgba(255, 255, 255, 0.85)",Dm="rgba(255, 255, 255, 0.08)",rB="rgba(255, 255, 255, 0.45)",aB="rgba(255, 255, 255, 0.08)",oB="rgba(255, 255, 255, 0.7)";function cB(i){let e=0,t=0,n=0;const s=new Set,r=new Set,a=new Set;let o=!1,c=!1;return i.traverse(l=>{if(l.isMesh||l.isPoints||l.isLine){n++;const h=l.geometry;h&&(h.index?t+=h.index.count/3:h.attributes.position&&(t+=h.attributes.position.count/3),h.attributes.position&&(e+=h.attributes.position.count)),l.skeleton&&(o=!0),l.morphTargetInfluences&&l.morphTargetInfluences.length>0&&(c=!0),(Array.isArray(l.material)?l.material:[l.material]).forEach(d=>{if(d){s.add(d.uuid),a.add(d.type.replace("Material",""));for(const f in d)d[f]&&d[f].isTexture&&r.add(d[f].uuid)}})}}),{vertices:e,triangles:Math.floor(t),meshes:n,materials:s.size,textures:r.size,materialTypes:Array.from(a),hasSkinning:o,hasMorphs:c}}function No(i){return i>=1e6?(i/1e6).toFixed(1)+"M":i>=1e3?(i/1e3).toFixed(1)+"K":i.toString()}function lB(i,e){const t=[];return i.hasSkinning&&t.push("skinned"),i.hasMorphs&&t.push("morph targets"),e&&e.length>0&&t.push(`${e.length} animation${e.length>1?"s":""}`),i.materialTypes.length>0&&t.push(i.materialTypes.join(", ")),t.length>0?t.join(" · "):""}function hB(i,e,t){const n=cB(e),s=lB(n,t),r=[{label:"MESHES",value:No(n.meshes)},{label:"VERTICES",value:No(n.vertices)},{label:"TRIANGLES",value:No(n.triangles)},{label:"MATERIALS",value:No(n.materials)},{label:"TEXTURES",value:No(n.textures)}];t&&t.length>0&&r.push({label:"ANIMATIONS",value:t.length.toString()});const a=[];n.materialTypes.forEach(w=>a.push(w)),n.hasSkinning&&a.push("Skinned"),n.hasMorphs&&a.push("Morph"),t&&t.length>0&&a.push("Animated");const o=200,c=El("Model Info",Tm),l=QM(c,o,Ro+2),h=r.map(w=>{const S=[{text:w.label+" ",font:Pd},{text:w.value,font:kd}],T=Im(S),C=El(w.label,Pd),v=Dd(C,o),F=El(w.value,kd),K=Dd(F,o);return{...w,labelWidth:v.maxLineWidth,valueWidth:K.maxLineWidth,richPrepared:T}}),u=a.map(w=>{const S=El(w,Rm),T=Dd(S,300);return{text:w,width:T.maxLineWidth+Fm}});let d=[],f=0;if(s){const w=yl(s,Nm),S=KM(w,o-hn,Ro);d=S.lines,f=S.height}const m=Math.max(l.width+hn*2,...h.map(w=>w.labelWidth+w.valueWidth+hn*3)),A=Math.max(m,180);let g=0;if(u.length>0){let w=0,S=1;u.forEach(T=>{w>0&&w+T.width>A-hn*2&&(S++,w=0),w+=T.width+6}),g=S*(Cl+6)+Pi}const p=hn+l.height+Pi+Pi+h.length*(Ro+Pi)+g+(f>0?Pi+f:0)+hn,y=document.createElement("canvas");y.width=A*Sl,y.height=p*Sl,y.style.width=A+"px",y.style.height=p+"px";const b=y.getContext("2d");b.scale(Sl,Sl),b.fillStyle=eB,Ud(b,0,0,A,p,10),b.fill(),b.strokeStyle=tB,b.lineWidth=1,Ud(b,.5,.5,A-1,p-1,10),b.stroke();let E=hn;if(b.font=Tm,b.fillStyle=nB,b.textBaseline="top",b.fillText("Model Info",hn,E),E+=l.height+Pi,b.strokeStyle=Dm,b.beginPath(),b.moveTo(hn,E),b.lineTo(A-hn,E),b.stroke(),E+=Pi,h.forEach(w=>{b.font=Pd,b.fillStyle=iB,b.textAlign="left",b.fillText(w.label,hn,E),b.font=kd,b.fillStyle=sB,b.textAlign="right",b.fillText(w.value,A-hn,E),b.textAlign="left",E+=Ro+Pi}),u.length>0){let w=hn;u.forEach(S=>{w>hn&&w+S.width>A-hn&&(w=hn,E+=Cl+6),b.fillStyle=aB,Ud(b,w,E,S.width,Cl,4),b.fill(),b.font=Rm,b.fillStyle=oB,b.textBaseline="top",b.fillText(S.text,w+Fm/2,E+3),w+=S.width+6}),E+=Cl+Pi+4}d.length>0&&(b.strokeStyle=Dm,b.beginPath(),b.moveTo(hn,E),b.lineTo(A-hn,E),b.stroke(),E+=Pi,b.font=Nm,b.fillStyle=rB,b.textBaseline="top",d.forEach(w=>{b.fillText(w.text,hn,E),E+=Ro}));const M=document.createElement("div");return M.classList.add("model-info"),M.appendChild(y),i.appendChild(M),{el:M,canvas:y,remove(){M.remove()}}}function Ud(i,e,t,n,s,r){i.beginPath(),i.moveTo(e+r,t),i.lineTo(e+n-r,t),i.quadraticCurveTo(e+n,t,e+n,t+r),i.lineTo(e+n,t+s-r),i.quadraticCurveTo(e+n,t+s,e+n-r,t+s),i.lineTo(e+r,t+s),i.quadraticCurveTo(e,t+s,e,t+s-r),i.lineTo(e,t+r),i.quadraticCurveTo(e,t,e+r,t),i.closePath()}function uB(){return/iphone|ipad|ipod/i.test(navigator.userAgent)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1}function Lm(){return uB()}function dB(i){const e=document.createElement("a");e.rel="ar",e.href=i,e.appendChild(document.createElement("img")),e.click()}function fB(){return/android/i.test(navigator.userAgent)}function Pm(){return fB()}function pB(i,{title:e="",link:t=""}={}){const n=new URLSearchParams({file:i,mode:"ar_preferred"});e&&n.set("title",e),t&&n.set("link",t);const s=encodeURIComponent(location.href),r=`intent://arvr.google.com/scene-viewer/1.2?${n.toString()}#Intent;scheme=https;package=com.google.ar.core;action=android.intent.action.VIEW;S.browser_fallback_url=${s};end;`;location.href=r}class km{constructor(e,{onEnd:t}={}){this._viewer=e,this._onEnd=t,this._session=null,this._hitTestSource=null,this._localSpace=null,this._anchored=!1,this._userPosition=new H,this._savedBg=null,this._savedPos=null,this._savedRot=null,this._handleEnd=this._handleEnd.bind(this),this._handleSelect=this._handleSelect.bind(this)}static async isSupported(){try{return!!(navigator.xr&&await navigator.xr.isSessionSupported("immersive-ar"))}catch{return!1}}async start(){const e=this._viewer,t=e.renderer;t.xr.enabled=!0;const n=await navigator.xr.requestSession("immersive-ar",{requiredFeatures:["hit-test"]});this._session=n,n.addEventListener("end",this._handleEnd),n.addEventListener("select",this._handleSelect),await t.xr.setSession(n),this._localSpace=await n.requestReferenceSpace("local");const s=await n.requestReferenceSpace("viewer");this._hitTestSource=await n.requestHitTestSource({space:s}),this._savedBg=e.scene.background,e.scene.background=null,t.setClearColor(0,0);const r=e.content;this._savedPos=r?.position.clone()??null,this._savedRot=r?.rotation.clone()??null,e._rafId!==null&&(cancelAnimationFrame(e._rafId),e._rafId=null),e.controls.enabled=!1,t.setAnimationLoop((a,o)=>this._tick(a,o))}_tick(e,t){const n=this._viewer,s=n.renderer,r=n.prevTime?(e-n.prevTime)/1e3:.016;if(n.prevTime=e,n.mixer&&n.mixer.update(r),n.animationManager.update(r),n._afterAnimateHooks)for(const o of n._afterAnimateHooks)o(r);const a=s.xr.getCamera();if(a&&this._userPosition.setFromMatrixPosition(a.matrixWorld),!this._anchored&&t&&this._hitTestSource){const o=t.getHitTestResults(this._hitTestSource);if(o.length>0&&n.content){const c=o[0].getPose(this._localSpace);c&&n.content.position.setFromMatrixPosition(new $e().fromArray(c.transform.matrix))}}s.render(n.scene,n.activeCamera)}_handleSelect(){this._anchored=!0}getUserPosition(){return this._userPosition.clone()}async end(){if(this._session)try{await this._session.end()}catch{}}_handleEnd(){const e=this._viewer,t=e.renderer;if(t.setAnimationLoop(null),t.xr.enabled=!1,this._hitTestSource){try{this._hitTestSource.cancel()}catch{}this._hitTestSource=null}this._session=null,this._anchored=!1,e.scene.background=this._savedBg,t.setClearColor(0,1),e.content&&this._savedPos&&e.content.position.copy(this._savedPos),e.content&&this._savedRot&&e.content.rotation.copy(this._savedRot),e.controls.enabled=!0,e._needsRender=!0,e._updateRenderLoop(),this._onEnd?.()}}const AB="500 11px Inter, sans-serif",Um="300 10px Inter, sans-serif",Od=10,Om=6,Qm=14,Il=Math.min(window.devicePixelRatio||1,2),gB=8;function mB(i){const e=[];return i.traverse(t=>{if(e.length>=gB||!t.isMesh||!t.name||t.name.startsWith("_"))return;const n=t.geometry,s=Array.isArray(t.material)?t.material[0]:t.material,r=n&&n.attributes.position?n.attributes.position.count:0,a=s?s.type.replace("Material",""):"",o=[{text:t.name,font:AB}];r>0&&o.push({text:" "+xB(r)+" verts",font:Um}),a&&o.push({text:" "+a,font:Um});const c=Im(o);let l=0,h=0;Bm(c,300,A=>{const g=Mm(c,A);l=Math.max(l,g.width),h++});const u=l+Od*2,d=h*Qm+Om*2;n&&n.computeBoundingBox();const f=n?n.boundingBox:null,m=new H;f?(f.getCenter(m),m.applyMatrix4(t.matrixWorld)):t.getWorldPosition(m),e.push({name:t.name,items:o,prepared:c,labelWidth:u,labelHeight:d,position:m,vertCount:r,matType:a})}),e}function bB(i){const{labelWidth:e,labelHeight:t,items:n,prepared:s}=i,r=document.createElement("canvas");r.width=e*Il,r.height=t*Il,r.style.width=e+"px",r.style.height=t+"px";const a=r.getContext("2d");a.scale(Il,Il),a.fillStyle="rgba(0, 0, 0, 0.8)",Gm(a,0,0,e,t,6),a.fill(),a.strokeStyle="rgba(255, 255, 255, 0.1)",a.lineWidth=1,Gm(a,.5,.5,e-1,t-1,6),a.stroke(),a.textBaseline="top";let o=Om;return Bm(s,e-Od*2,c=>{const l=Mm(s,c);let h=Od;l.fragments.forEach(u=>{h+=u.gapBefore;const d=n[u.itemIndex];a.font=d.font,a.fillStyle=u.itemIndex===0?"rgba(255, 255, 255, 0.9)":"rgba(255, 255, 255, 0.45)",a.fillText(u.text,h,o),h+=u.occupiedWidth}),o+=Qm}),r}function xB(i){return i>=1e6?(i/1e6).toFixed(1)+"M":i>=1e3?(i/1e3).toFixed(1)+"K":i.toString()}function Gm(i,e,t,n,s,r){i.beginPath(),i.moveTo(e+r,t),i.lineTo(e+n-r,t),i.quadraticCurveTo(e+n,t,e+n,t+r),i.lineTo(e+n,t+s-r),i.quadraticCurveTo(e+n,t+s,e+n-r,t+s),i.lineTo(e+r,t+s),i.quadraticCurveTo(e,t+s,e,t+s-r),i.lineTo(e,t+r),i.quadraticCurveTo(e,t,e+r,t),i.closePath()}const Ml="[default]",Qd={ASSET_GENERATOR:"assetgenerator"},Bl=new PA,Hm=`https://unpkg.com/three@0.${dc}.x`;let Tl=null;function _B(){return Tl||(Tl=Promise.all([Promise.resolve().then(()=>_L),Promise.resolve().then(()=>LL),Promise.resolve().then(()=>kL)]).then(([i,e,t])=>{const n=new i.DRACOLoader(Bl).setDecoderPath(`${Hm}/examples/jsm/libs/draco/gltf/`),s=new e.KTX2Loader(Bl).setTranscoderPath(`${Hm}/examples/jsm/libs/basis/`);return{dracoLoader:n,ktx2Loader:s,meshoptDecoder:t.MeshoptDecoder}}),Tl)}function zm(i,e){const t=new Set;i.traverse(n=>{if(!n.geometry)return;(Array.isArray(n.material)?n.material:[n.material]).forEach(r=>{r&&!t.has(r.uuid)&&(t.add(r.uuid),e(r))})})}function EB(i){const{state:e,options:t}=i;if(t.preset===Qd.ASSET_GENERATOR){const r=new Oy;r.name="hemi_light",i.scene.add(r),i.lights.push(r);return}const n=new Vy(e.ambientColor,e.ambientIntensity);n.name="ambient_light",i.defaultCamera.add(n);const s=new GA(e.directColor,e.directIntensity);s.position.set(.5,0,.866),s.name="main_light",i.defaultCamera.add(s),i.lights.push(n,s)}function yB(i){i.lights.forEach(e=>e.parent.remove(e)),i.lights.length=0}var ni=Uint8Array,va=Uint16Array,wB=Int32Array,Vm=new ni([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]),Wm=new ni([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]),vB=new ni([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),qm=function(i,e){for(var t=new va(31),n=0;n<31;++n)t[n]=e+=1<<i[n-1];for(var s=new wB(t[30]),n=1;n<30;++n)for(var r=t[n];r<t[n+1];++r)s[r]=r-t[n]<<5|n;return{b:t,r:s}},Km=qm(Vm,2),jm=Km.b,CB=Km.r;jm[28]=258,CB[258]=28;for(var SB=qm(Wm,0),IB=SB.b,Gd=new va(32768),kt=0;kt<32768;++kt){var ks=(kt&43690)>>1|(kt&21845)<<1;ks=(ks&52428)>>2|(ks&13107)<<2,ks=(ks&61680)>>4|(ks&3855)<<4,Gd[kt]=((ks&65280)>>8|(ks&255)<<8)>>1}for(var Fo=(function(i,e,t){for(var n=i.length,s=0,r=new va(e);s<n;++s)i[s]&&++r[i[s]-1];var a=new va(e);for(s=1;s<e;++s)a[s]=a[s-1]+r[s-1]<<1;var o;if(t){o=new va(1<<e);var c=15-e;for(s=0;s<n;++s)if(i[s])for(var l=s<<4|i[s],h=e-i[s],u=a[i[s]-1]++<<h,d=u|(1<<h)-1;u<=d;++u)o[Gd[u]>>c]=l}else for(o=new va(n),s=0;s<n;++s)i[s]&&(o[s]=Gd[a[i[s]-1]++]>>15-i[s]);return o}),Do=new ni(288),kt=0;kt<144;++kt)Do[kt]=8;for(var kt=144;kt<256;++kt)Do[kt]=9;for(var kt=256;kt<280;++kt)Do[kt]=7;for(var kt=280;kt<288;++kt)Do[kt]=8;for(var Xm=new ni(32),kt=0;kt<32;++kt)Xm[kt]=5;var MB=Fo(Do,9,1),BB=Fo(Xm,5,1),Hd=function(i){for(var e=i[0],t=1;t<i.length;++t)i[t]>e&&(e=i[t]);return e},_i=function(i,e,t){var n=e/8|0;return(i[n]|i[n+1]<<8)>>(e&7)&t},zd=function(i,e){var t=e/8|0;return(i[t]|i[t+1]<<8|i[t+2]<<16)>>(e&7)},TB=function(i){return(i+7)/8|0},RB=function(i,e,t){return(t==null||t>i.length)&&(t=i.length),new ni(i.subarray(e,t))},NB=["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"],Ei=function(i,e,t){var n=new Error(e||NB[i]);if(n.code=i,Error.captureStackTrace&&Error.captureStackTrace(n,Ei),!t)throw n;return n},FB=function(i,e,t,n){var s=i.length,r=0;if(!s||e.f&&!e.l)return t||new ni(0);var a=!t,o=a||e.i!=2,c=e.i;a&&(t=new ni(s*3));var l=function(St){var ut=t.length;if(St>ut){var Je=new ni(Math.max(ut*2,St));Je.set(t),t=Je}},h=e.f||0,u=e.p||0,d=e.b||0,f=e.l,m=e.d,A=e.m,g=e.n,p=s*8;do{if(!f){h=_i(i,u,1);var y=_i(i,u+1,3);if(u+=3,y)if(y==1)f=MB,m=BB,A=9,g=5;else if(y==2){var w=_i(i,u,31)+257,S=_i(i,u+10,15)+4,T=w+_i(i,u+5,31)+1;u+=14;for(var C=new ni(T),v=new ni(19),F=0;F<S;++F)v[vB[F]]=_i(i,u+F*3,7);u+=S*3;for(var K=Hd(v),q=(1<<K)-1,$=Fo(v,K,1),F=0;F<T;){var D=$[_i(i,u,q)];u+=D&15;var b=D>>4;if(b<16)C[F++]=b;else{var O=0,Y=0;for(b==16?(Y=3+_i(i,u,3),u+=2,O=C[F-1]):b==17?(Y=3+_i(i,u,7),u+=3):b==18&&(Y=11+_i(i,u,127),u+=7);Y--;)C[F++]=O}}var Q=C.subarray(0,w),J=C.subarray(w);A=Hd(Q),g=Hd(J),f=Fo(Q,A,1),m=Fo(J,g,1)}else Ei(1);else{var b=TB(u)+4,E=i[b-4]|i[b-3]<<8,M=b+E;if(M>s){c&&Ei(0);break}o&&l(d+E),t.set(i.subarray(b,M),d),e.b=d+=E,e.p=u=M*8,e.f=h;continue}if(u>p){c&&Ei(0);break}}o&&l(d+131072);for(var ee=(1<<A)-1,ae=(1<<g)-1,ye=u;;ye=u){var O=f[zd(i,u)&ee],Me=O>>4;if(u+=O&15,u>p){c&&Ei(0);break}if(O||Ei(2),Me<256)t[d++]=Me;else if(Me==256){ye=u,f=null;break}else{var se=Me-254;if(Me>264){var F=Me-257,me=Vm[F];se=_i(i,u,(1<<me)-1)+jm[F],u+=me}var be=m[zd(i,u)&ae],xe=be>>4;be||Ei(3),u+=be&15;var J=IB[xe];if(xe>3){var me=Wm[xe];J+=zd(i,u)&(1<<me)-1,u+=me}if(u>p){c&&Ei(0);break}o&&l(d+131072);var Pe=d+se;if(d<J){var et=r-J,Qe=Math.min(J,Pe);for(et+d<0&&Ei(3);d<Qe;++d)t[d]=n[et+d]}for(;d<Pe;++d)t[d]=t[d-J]}}e.l=f,e.p=ye,e.b=d,e.f=h,f&&(h=1,e.m=A,e.d=m,e.n=g)}while(!h);return d!=t.length&&a?RB(t,0,d):t.subarray(0,d)},DB=new ni(0),LB=function(i,e){return((i[0]&15)!=8||i[0]>>4>7||(i[0]<<8|i[1])%31)&&Ei(6,"invalid zlib data"),(i[1]>>5&1)==1&&Ei(6,"invalid zlib data: "+(i[1]&32?"need":"unexpected")+" dictionary"),(i[1]>>3&4)+2};function Rl(i,e){return FB(i.subarray(LB(i),-4),{i:2},e,e)}var PB=typeof TextDecoder<"u"&&new TextDecoder,kB=0;try{PB.decode(DB,{stream:!0}),kB=1}catch{}class UB extends ky{constructor(e){super(e),this.type=Bn}parse(e){const C=Math.pow(2.7182818,2.2);function v(x,B){let k=0;for(let R=0;R<65536;++R)(R==0||x[R>>3]&1<<(R&7))&&(B[k++]=R);const _=k-1;for(;k<65536;)B[k++]=0;return _}function F(x){for(let B=0;B<16384;B++)x[B]={},x[B].len=0,x[B].lit=0,x[B].p=null}const K={l:0,c:0,lc:0};function q(x,B,k,_,R){for(;k<x;)B=B<<8|Te(_,R),k+=8;k-=x,K.l=B>>k&(1<<x)-1,K.c=B,K.lc=k}const $=new Array(59);function D(x){for(let k=0;k<=58;++k)$[k]=0;for(let k=0;k<65537;++k)$[x[k]]+=1;let B=0;for(let k=58;k>0;--k){const _=B+$[k]>>1;$[k]=B,B=_}for(let k=0;k<65537;++k){const _=x[k];_>0&&(x[k]=_|$[_]++<<6)}}function O(x,B,k,_,R,N){const U=B;let P=0,z=0;for(;_<=R;_++){if(U.value-B.value>k)return!1;q(6,P,z,x,U);const j=K.l;if(P=K.c,z=K.lc,N[_]=j,j==63){if(U.value-B.value>k)throw new Error("Something wrong with hufUnpackEncTable");q(8,P,z,x,U);let X=K.l+6;if(P=K.c,z=K.lc,_+X>R+1)throw new Error("Something wrong with hufUnpackEncTable");for(;X--;)N[_++]=0;_--}else if(j>=59){let X=j-59+2;if(_+X>R+1)throw new Error("Something wrong with hufUnpackEncTable");for(;X--;)N[_++]=0;_--}}D(N)}function Y(x){return x&63}function Q(x){return x>>6}function J(x,B,k,_){for(;B<=k;B++){const R=Q(x[B]),N=Y(x[B]);if(R>>N)throw new Error("Invalid table entry");if(N>14){const U=_[R>>N-14];if(U.len)throw new Error("Invalid table entry");if(U.lit++,U.p){const P=U.p;U.p=new Array(U.lit);for(let z=0;z<U.lit-1;++z)U.p[z]=P[z]}else U.p=new Array(1);U.p[U.lit-1]=B}else if(N){let U=0;for(let P=1<<14-N;P>0;P--){const z=_[(R<<14-N)+U];if(z.len||z.p)throw new Error("Invalid table entry");z.len=N,z.lit=B,U++}}}return!0}const ee={c:0,lc:0};function ae(x,B,k,_){x=x<<8|Te(k,_),B+=8,ee.c=x,ee.lc=B}const ye={c:0,lc:0};function Me(x,B,k,_,R,N,U,P,z){if(x==B){_<8&&(ae(k,_,R,N),k=ee.c,_=ee.lc),_-=8;let j=k>>_;if(j=new Uint8Array([j])[0],P.value+j>z)return!1;const X=U[P.value-1];for(;j-- >0;)U[P.value++]=X}else if(P.value<z)U[P.value++]=x;else return!1;ye.c=k,ye.lc=_}function se(x){return x&65535}function me(x){const B=se(x);return B>32767?B-65536:B}const be={a:0,b:0};function xe(x,B){const k=me(x),R=me(B),N=k+(R&1)+(R>>1),U=N,P=N-R;be.a=U,be.b=P}function Pe(x,B){const k=se(x),_=se(B),R=k-(_>>1)&65535,N=_+R-32768&65535;be.a=N,be.b=R}function et(x,B,k,_,R,N,U){const P=U<16384,z=k>R?R:k;let j=1,X,ie;for(;j<=z;)j<<=1;for(j>>=1,X=j,j>>=1;j>=1;){ie=0;const he=ie+N*(R-X),ce=N*j,fe=N*X,ge=_*j,Ee=_*X;let De,Ke,He,Fe;for(;ie<=he;ie+=fe){let st=ie;const Le=ie+_*(k-X);for(;st<=Le;st+=Ee){const wt=st+ge,un=st+ce,_t=un+ge;P?(xe(x[st+B],x[un+B]),De=be.a,He=be.b,xe(x[wt+B],x[_t+B]),Ke=be.a,Fe=be.b,xe(De,Ke),x[st+B]=be.a,x[wt+B]=be.b,xe(He,Fe),x[un+B]=be.a,x[_t+B]=be.b):(Pe(x[st+B],x[un+B]),De=be.a,He=be.b,Pe(x[wt+B],x[_t+B]),Ke=be.a,Fe=be.b,Pe(De,Ke),x[st+B]=be.a,x[wt+B]=be.b,Pe(He,Fe),x[un+B]=be.a,x[_t+B]=be.b)}if(k&j){const wt=st+ce;P?xe(x[st+B],x[wt+B]):Pe(x[st+B],x[wt+B]),De=be.a,x[wt+B]=be.b,x[st+B]=De}}if(R&j){let st=ie;const Le=ie+_*(k-X);for(;st<=Le;st+=Ee){const wt=st+ge;P?xe(x[st+B],x[wt+B]):Pe(x[st+B],x[wt+B]),De=be.a,x[wt+B]=be.b,x[st+B]=De}}X=j,j>>=1}return ie}function Qe(x,B,k,_,R,N,U,P,z){let j=0,X=0;const ie=U,he=Math.trunc(_.value+(R+7)/8);for(;_.value<he;)for(ae(j,X,k,_),j=ee.c,X=ee.lc;X>=14;){const fe=j>>X-14&16383,ge=B[fe];if(ge.len)X-=ge.len,Me(ge.lit,N,j,X,k,_,P,z,ie),j=ye.c,X=ye.lc;else{if(!ge.p)throw new Error("hufDecode issues");let Ee;for(Ee=0;Ee<ge.lit;Ee++){const De=Y(x[ge.p[Ee]]);for(;X<De&&_.value<he;)ae(j,X,k,_),j=ee.c,X=ee.lc;if(X>=De&&Q(x[ge.p[Ee]])==(j>>X-De&(1<<De)-1)){X-=De,Me(ge.p[Ee],N,j,X,k,_,P,z,ie),j=ye.c,X=ye.lc;break}}if(Ee==ge.lit)throw new Error("hufDecode issues")}}const ce=8-R&7;for(j>>=ce,X-=ce;X>0;){const fe=B[j<<14-X&16383];if(fe.len)X-=fe.len,Me(fe.lit,N,j,X,k,_,P,z,ie),j=ye.c,X=ye.lc;else throw new Error("hufDecode issues")}return!0}function St(x,B,k,_,R,N){const U={value:0},P=k.value,z=Oe(B,k),j=Oe(B,k);k.value+=4;const X=Oe(B,k);if(k.value+=4,z<0||z>=65537||j<0||j>=65537)throw new Error("Something wrong with HUF_ENCSIZE");const ie=new Array(65537),he=new Array(16384);F(he);const ce=_-(k.value-P);if(O(x,k,ce,z,j,ie),X>8*(_-(k.value-P)))throw new Error("Something wrong with hufUncompress");J(ie,z,j,he),Qe(ie,he,x,k,X,j,N,R,U)}function ut(x,B,k){for(let _=0;_<k;++_)B[_]=x[B[_]]}function Je(x){for(let B=1;B<x.length;B++){const k=x[B-1]+x[B]-128;x[B]=k}}function G(x,B){let k=0,_=Math.floor((x.length+1)/2),R=0;const N=x.length-1;for(;!(R>N||(B[R++]=x[k++],R>N));)B[R++]=x[_++]}function mn(x){let B=x.byteLength;const k=new Array;let _=0;const R=new DataView(x);for(;B>0;){const N=R.getInt8(_++);if(N<0){const U=-N;B-=U+1;for(let P=0;P<U;P++)k.push(R.getUint8(_++))}else{const U=N;B-=2;const P=R.getUint8(_++);for(let z=0;z<U+1;z++)k.push(P)}}return k}function dt(x,B,k,_,R,N){let U=new DataView(N.buffer);const P=k[x.idx[0]].width,z=k[x.idx[0]].height,j=3,X=Math.floor(P/8),ie=Math.ceil(P/8),he=Math.ceil(z/8),ce=P-(ie-1)*8,fe=z-(he-1)*8,ge={value:0},Ee=new Array(j),De=new Array(j),Ke=new Array(j),He=new Array(j),Fe=new Array(j);for(let Le=0;Le<j;++Le)Fe[Le]=B[x.idx[Le]],Ee[Le]=Le<1?0:Ee[Le-1]+ie*he,De[Le]=new Float32Array(64),Ke[Le]=new Uint16Array(64),He[Le]=new Uint16Array(ie*64);for(let Le=0;Le<he;++Le){let wt=8;Le==he-1&&(wt=fe);let un=8;for(let bt=0;bt<ie;++bt){bt==ie-1&&(un=ce);for(let je=0;je<j;++je)Ke[je].fill(0),Ke[je][0]=R[Ee[je]++],pt(ge,_,Ke[je]),ze(Ke[je],De[je]),Rt(De[je]);Ge(De);for(let je=0;je<j;++je)L(De[je],He[je],bt*64)}let _t=0;for(let bt=0;bt<j;++bt){const je=k[x.idx[bt]].type;for(let qt=8*Le;qt<8*Le+wt;++qt){_t=Fe[bt][qt];for(let xn=0;xn<X;++xn){const Lt=xn*64+(qt&7)*8;U.setUint16(_t+0*je,He[bt][Lt+0],!0),U.setUint16(_t+2*je,He[bt][Lt+1],!0),U.setUint16(_t+4*je,He[bt][Lt+2],!0),U.setUint16(_t+6*je,He[bt][Lt+3],!0),U.setUint16(_t+8*je,He[bt][Lt+4],!0),U.setUint16(_t+10*je,He[bt][Lt+5],!0),U.setUint16(_t+12*je,He[bt][Lt+6],!0),U.setUint16(_t+14*je,He[bt][Lt+7],!0),_t+=16*je}}if(X!=ie)for(let qt=8*Le;qt<8*Le+wt;++qt){const xn=Fe[bt][qt]+8*X*2*je,Lt=X*64+(qt&7)*8;for(let dn=0;dn<un;++dn)U.setUint16(xn+dn*2*je,He[bt][Lt+dn],!0)}}}const st=new Uint16Array(P);U=new DataView(N.buffer);for(let Le=0;Le<j;++Le){k[x.idx[Le]].decoded=!0;const wt=k[x.idx[Le]].type;if(k[Le].type==2)for(let un=0;un<z;++un){const _t=Fe[Le][un];for(let bt=0;bt<P;++bt)st[bt]=U.getUint16(_t+bt*2*wt,!0);for(let bt=0;bt<P;++bt)U.setFloat32(_t+bt*2*wt,ne(st[bt]),!0)}}}function pt(x,B,k){let _,R=1;for(;R<64;)_=B[x.value],_==65280?R=64:_>>8==255?R+=_&255:(k[R]=_,R++),x.value++}function ze(x,B){B[0]=ne(x[0]),B[1]=ne(x[1]),B[2]=ne(x[5]),B[3]=ne(x[6]),B[4]=ne(x[14]),B[5]=ne(x[15]),B[6]=ne(x[27]),B[7]=ne(x[28]),B[8]=ne(x[2]),B[9]=ne(x[4]),B[10]=ne(x[7]),B[11]=ne(x[13]),B[12]=ne(x[16]),B[13]=ne(x[26]),B[14]=ne(x[29]),B[15]=ne(x[42]),B[16]=ne(x[3]),B[17]=ne(x[8]),B[18]=ne(x[12]),B[19]=ne(x[17]),B[20]=ne(x[25]),B[21]=ne(x[30]),B[22]=ne(x[41]),B[23]=ne(x[43]),B[24]=ne(x[9]),B[25]=ne(x[11]),B[26]=ne(x[18]),B[27]=ne(x[24]),B[28]=ne(x[31]),B[29]=ne(x[40]),B[30]=ne(x[44]),B[31]=ne(x[53]),B[32]=ne(x[10]),B[33]=ne(x[19]),B[34]=ne(x[23]),B[35]=ne(x[32]),B[36]=ne(x[39]),B[37]=ne(x[45]),B[38]=ne(x[52]),B[39]=ne(x[54]),B[40]=ne(x[20]),B[41]=ne(x[22]),B[42]=ne(x[33]),B[43]=ne(x[38]),B[44]=ne(x[46]),B[45]=ne(x[51]),B[46]=ne(x[55]),B[47]=ne(x[60]),B[48]=ne(x[21]),B[49]=ne(x[34]),B[50]=ne(x[37]),B[51]=ne(x[47]),B[52]=ne(x[50]),B[53]=ne(x[56]),B[54]=ne(x[59]),B[55]=ne(x[61]),B[56]=ne(x[35]),B[57]=ne(x[36]),B[58]=ne(x[48]),B[59]=ne(x[49]),B[60]=ne(x[57]),B[61]=ne(x[58]),B[62]=ne(x[62]),B[63]=ne(x[63])}function Rt(x){const B=.5*Math.cos(.7853975),k=.5*Math.cos(3.14159/16),_=.5*Math.cos(3.14159/8),R=.5*Math.cos(3*3.14159/16),N=.5*Math.cos(5*3.14159/16),U=.5*Math.cos(3*3.14159/8),P=.5*Math.cos(7*3.14159/16),z=new Array(4),j=new Array(4),X=new Array(4),ie=new Array(4);for(let he=0;he<8;++he){const ce=he*8;z[0]=_*x[ce+2],z[1]=U*x[ce+2],z[2]=_*x[ce+6],z[3]=U*x[ce+6],j[0]=k*x[ce+1]+R*x[ce+3]+N*x[ce+5]+P*x[ce+7],j[1]=R*x[ce+1]-P*x[ce+3]-k*x[ce+5]-N*x[ce+7],j[2]=N*x[ce+1]-k*x[ce+3]+P*x[ce+5]+R*x[ce+7],j[3]=P*x[ce+1]-N*x[ce+3]+R*x[ce+5]-k*x[ce+7],X[0]=B*(x[ce+0]+x[ce+4]),X[3]=B*(x[ce+0]-x[ce+4]),X[1]=z[0]+z[3],X[2]=z[1]-z[2],ie[0]=X[0]+X[1],ie[1]=X[3]+X[2],ie[2]=X[3]-X[2],ie[3]=X[0]-X[1],x[ce+0]=ie[0]+j[0],x[ce+1]=ie[1]+j[1],x[ce+2]=ie[2]+j[2],x[ce+3]=ie[3]+j[3],x[ce+4]=ie[3]-j[3],x[ce+5]=ie[2]-j[2],x[ce+6]=ie[1]-j[1],x[ce+7]=ie[0]-j[0]}for(let he=0;he<8;++he)z[0]=_*x[16+he],z[1]=U*x[16+he],z[2]=_*x[48+he],z[3]=U*x[48+he],j[0]=k*x[8+he]+R*x[24+he]+N*x[40+he]+P*x[56+he],j[1]=R*x[8+he]-P*x[24+he]-k*x[40+he]-N*x[56+he],j[2]=N*x[8+he]-k*x[24+he]+P*x[40+he]+R*x[56+he],j[3]=P*x[8+he]-N*x[24+he]+R*x[40+he]-k*x[56+he],X[0]=B*(x[he]+x[32+he]),X[3]=B*(x[he]-x[32+he]),X[1]=z[0]+z[3],X[2]=z[1]-z[2],ie[0]=X[0]+X[1],ie[1]=X[3]+X[2],ie[2]=X[3]-X[2],ie[3]=X[0]-X[1],x[0+he]=ie[0]+j[0],x[8+he]=ie[1]+j[1],x[16+he]=ie[2]+j[2],x[24+he]=ie[3]+j[3],x[32+he]=ie[3]-j[3],x[40+he]=ie[2]-j[2],x[48+he]=ie[1]-j[1],x[56+he]=ie[0]-j[0]}function Ge(x){for(let B=0;B<64;++B){const k=x[0][B],_=x[1][B],R=x[2][B];x[0][B]=k+1.5747*R,x[1][B]=k-.1873*_-.4682*R,x[2][B]=k+1.8556*_}}function L(x,B,k){for(let _=0;_<64;++_)B[k+_]=sA.toHalfFloat(I(x[_]))}function I(x){return x<=1?Math.sign(x)*Math.pow(Math.abs(x),2.2):Math.sign(x)*Math.pow(C,Math.abs(x)-1)}function Z(x){return new DataView(x.array.buffer,x.offset.value,x.size)}function le(x){const B=x.viewer.buffer.slice(x.offset.value,x.offset.value+x.size),k=new Uint8Array(mn(B)),_=new Uint8Array(k.length);return Je(k),G(k,_),new DataView(_.buffer)}function Ae(x){const B=x.array.slice(x.offset.value,x.offset.value+x.size),k=Rl(B),_=new Uint8Array(k.length);return Je(k),G(k,_),new DataView(_.buffer)}function oe(x){const B=x.viewer,k={value:x.offset.value},_=new Uint16Array(x.columns*x.lines*(x.inputChannels.length*x.type)),R=new Uint8Array(8192);let N=0;const U=new Array(x.inputChannels.length);for(let fe=0,ge=x.inputChannels.length;fe<ge;fe++)U[fe]={},U[fe].start=N,U[fe].end=U[fe].start,U[fe].nx=x.columns,U[fe].ny=x.lines,U[fe].size=x.type,N+=U[fe].nx*U[fe].ny*U[fe].size;const P=re(B,k),z=re(B,k);if(z>=8192)throw new Error("Something is wrong with PIZ_COMPRESSION BITMAP_SIZE");if(P<=z)for(let fe=0;fe<z-P+1;fe++)R[fe+P]=tt(B,k);const j=new Uint16Array(65536),X=v(R,j),ie=Oe(B,k);St(x.array,B,k,ie,_,N);for(let fe=0;fe<x.inputChannels.length;++fe){const ge=U[fe];for(let Ee=0;Ee<U[fe].size;++Ee)et(_,ge.start+Ee,ge.nx,ge.size,ge.ny,ge.nx*ge.size,X)}ut(j,_,N);let he=0;const ce=new Uint8Array(_.buffer.byteLength);for(let fe=0;fe<x.lines;fe++)for(let ge=0;ge<x.inputChannels.length;ge++){const Ee=U[ge],De=Ee.nx*Ee.size,Ke=new Uint8Array(_.buffer,Ee.end*2,De*2);ce.set(Ke,he),he+=De*2,Ee.end+=De}return new DataView(ce.buffer)}function Ue(x){const B=x.array.slice(x.offset.value,x.offset.value+x.size),k=Rl(B),_=x.inputChannels.length*x.lines*x.columns*x.totalBytes,R=new ArrayBuffer(_),N=new DataView(R);let U=0,P=0;const z=new Array(4);for(let j=0;j<x.lines;j++)for(let X=0;X<x.inputChannels.length;X++){let ie=0;switch(x.inputChannels[X].pixelType){case 1:z[0]=U,z[1]=z[0]+x.columns,U=z[1]+x.columns;for(let ce=0;ce<x.columns;++ce){const fe=k[z[0]++]<<8|k[z[1]++];ie+=fe,N.setUint16(P,ie,!0),P+=2}break;case 2:z[0]=U,z[1]=z[0]+x.columns,z[2]=z[1]+x.columns,U=z[2]+x.columns;for(let ce=0;ce<x.columns;++ce){const fe=k[z[0]++]<<24|k[z[1]++]<<16|k[z[2]++]<<8;ie+=fe,N.setUint32(P,ie,!0),P+=4}break}}return N}function ve(x){const B=x.viewer,k={value:x.offset.value},_=new Uint8Array(x.columns*x.lines*(x.inputChannels.length*x.type*2)),R={version:We(B,k),unknownUncompressedSize:We(B,k),unknownCompressedSize:We(B,k),acCompressedSize:We(B,k),dcCompressedSize:We(B,k),rleCompressedSize:We(B,k),rleUncompressedSize:We(B,k),rleRawSize:We(B,k),totalAcUncompressedCount:We(B,k),totalDcUncompressedCount:We(B,k),acCompression:We(B,k)};if(R.version<2)throw new Error("EXRLoader.parse: "+ms.compression+" version "+R.version+" is unsupported");const N=new Array;let U=re(B,k)-2;for(;U>0;){const ge=Ve(B.buffer,k),Ee=tt(B,k),De=Ee>>2&3,Ke=(Ee>>4)-1,He=new Int8Array([Ke])[0],Fe=tt(B,k);N.push({name:ge,index:He,type:Fe,compression:De}),U-=ge.length+3}const P=ms.channels,z=new Array(x.inputChannels.length);for(let ge=0;ge<x.inputChannels.length;++ge){const Ee=z[ge]={},De=P[ge];Ee.name=De.name,Ee.compression=0,Ee.decoded=!1,Ee.type=De.pixelType,Ee.pLinear=De.pLinear,Ee.width=x.columns,Ee.height=x.lines}const j={idx:new Array(3)};for(let ge=0;ge<x.inputChannels.length;++ge){const Ee=z[ge];for(let De=0;De<N.length;++De){const Ke=N[De];Ee.name==Ke.name&&(Ee.compression=Ke.compression,Ke.index>=0&&(j.idx[Ke.index]=ge),Ee.offset=ge)}}let X,ie,he;if(R.acCompressedSize>0)switch(R.acCompression){case 0:X=new Uint16Array(R.totalAcUncompressedCount),St(x.array,B,k,R.acCompressedSize,X,R.totalAcUncompressedCount);break;case 1:const ge=x.array.slice(k.value,k.value+R.totalAcUncompressedCount),Ee=Rl(ge);X=new Uint16Array(Ee.buffer),k.value+=R.totalAcUncompressedCount;break}if(R.dcCompressedSize>0){const ge={array:x.array,offset:k,size:R.dcCompressedSize};ie=new Uint16Array(Ae(ge).buffer),k.value+=R.dcCompressedSize}if(R.rleRawSize>0){const ge=x.array.slice(k.value,k.value+R.rleCompressedSize),Ee=Rl(ge);he=mn(Ee.buffer),k.value+=R.rleCompressedSize}let ce=0;const fe=new Array(z.length);for(let ge=0;ge<fe.length;++ge)fe[ge]=new Array;for(let ge=0;ge<x.lines;++ge)for(let Ee=0;Ee<z.length;++Ee)fe[Ee].push(ce),ce+=z[Ee].width*x.type*2;dt(j,fe,z,X,ie,_);for(let ge=0;ge<z.length;++ge){const Ee=z[ge];if(!Ee.decoded)switch(Ee.compression){case 2:let De=0,Ke=0;for(let He=0;He<x.lines;++He){let Fe=fe[ge][De];for(let st=0;st<Ee.width;++st){for(let Le=0;Le<2*Ee.type;++Le)_[Fe++]=he[Ke+Le*Ee.width*Ee.height];Ke++}De++}break;default:throw new Error("EXRLoader.parse: unsupported channel compression")}}return new DataView(_.buffer)}function Ve(x,B){const k=new Uint8Array(x);let _=0;for(;k[B.value+_]!=0;)_+=1;const R=new TextDecoder().decode(k.slice(B.value,B.value+_));return B.value=B.value+_+1,R}function Ye(x,B,k){const _=new TextDecoder().decode(new Uint8Array(x).slice(B.value,B.value+k));return B.value=B.value+k,_}function _e(x,B){const k=ke(x,B),_=Oe(x,B);return[k,_]}function Ne(x,B){const k=Oe(x,B),_=Oe(x,B);return[k,_]}function ke(x,B){const k=x.getInt32(B.value,!0);return B.value=B.value+4,k}function Oe(x,B){const k=x.getUint32(B.value,!0);return B.value=B.value+4,k}function Te(x,B){const k=x[B.value];return B.value=B.value+1,k}function tt(x,B){const k=x.getUint8(B.value);return B.value=B.value+1,k}const We=function(x,B){let k;return"getBigInt64"in DataView.prototype?k=Number(x.getBigInt64(B.value,!0)):k=x.getUint32(B.value+4,!0)+Number(x.getUint32(B.value,!0)<<32),B.value+=8,k};function nt(x,B){const k=x.getFloat32(B.value,!0);return B.value+=4,k}function W(x,B){return sA.toHalfFloat(nt(x,B))}function ne(x){const B=(x&31744)>>10,k=x&1023;return(x>>15?-1:1)*(B?B===31?k?NaN:1/0:Math.pow(2,B-15)*(1+k/1024):6103515625e-14*(k/1024))}function re(x,B){const k=x.getUint16(B.value,!0);return B.value+=2,k}function de(x,B){return ne(re(x,B))}function Ie(x,B,k,_){const R=k.value,N=[];for(;k.value<R+_-1;){const U=Ve(B,k),P=ke(x,k),z=tt(x,k);k.value+=3;const j=ke(x,k),X=ke(x,k);N.push({name:U,pixelType:P,pLinear:z,xSampling:j,ySampling:X})}return k.value+=1,N}function Se(x,B){const k=nt(x,B),_=nt(x,B),R=nt(x,B),N=nt(x,B),U=nt(x,B),P=nt(x,B),z=nt(x,B),j=nt(x,B);return{redX:k,redY:_,greenX:R,greenY:N,blueX:U,blueY:P,whiteX:z,whiteY:j}}function it(x,B){const k=["NO_COMPRESSION","RLE_COMPRESSION","ZIPS_COMPRESSION","ZIP_COMPRESSION","PIZ_COMPRESSION","PXR24_COMPRESSION","B44_COMPRESSION","B44A_COMPRESSION","DWAA_COMPRESSION","DWAB_COMPRESSION"],_=tt(x,B);return k[_]}function Qt(x,B){const k=ke(x,B),_=ke(x,B),R=ke(x,B),N=ke(x,B);return{xMin:k,yMin:_,xMax:R,yMax:N}}function bn(x,B){const k=["INCREASING_Y","DECREASING_Y","RANDOM_Y"],_=tt(x,B);return k[_]}function yt(x,B){const k=["ENVMAP_LATLONG","ENVMAP_CUBE"],_=tt(x,B);return k[_]}function Jn(x,B){const k=["ONE_LEVEL","MIPMAP_LEVELS","RIPMAP_LEVELS"],_=["ROUND_DOWN","ROUND_UP"],R=Oe(x,B),N=Oe(x,B),U=tt(x,B);return{xSize:R,ySize:N,levelMode:k[U&15],roundingMode:_[U>>4]}}function Mi(x,B){const k=nt(x,B),_=nt(x,B);return[k,_]}function bh(x,B){const k=nt(x,B),_=nt(x,B),R=nt(x,B);return[k,_,R]}function xh(x,B,k,_,R){if(_==="string"||_==="stringvector"||_==="iccProfile")return Ye(B,k,R);if(_==="chlist")return Ie(x,B,k,R);if(_==="chromaticities")return Se(x,k);if(_==="compression")return it(x,k);if(_==="box2i")return Qt(x,k);if(_==="envmap")return yt(x,k);if(_==="tiledesc")return Jn(x,k);if(_==="lineOrder")return bn(x,k);if(_==="float")return nt(x,k);if(_==="v2f")return Mi(x,k);if(_==="v3f")return bh(x,k);if(_==="int")return ke(x,k);if(_==="rational")return _e(x,k);if(_==="timecode")return Ne(x,k);if(_==="preview")return k.value+=R,"skipped";k.value+=R}function gs(x,B){const k=Math.log2(x);return B=="ROUND_DOWN"?Math.floor(k):Math.ceil(k)}function cc(x,B,k){let _=0;switch(x.levelMode){case"ONE_LEVEL":_=1;break;case"MIPMAP_LEVELS":_=gs(Math.max(B,k),x.roundingMode)+1;break;case"RIPMAP_LEVELS":throw new Error("THREE.EXRLoader: RIPMAP_LEVELS tiles currently unsupported.")}return _}function lc(x,B,k,_){const R=new Array(x);for(let N=0;N<x;N++){const U=1<<N;let P=B/U|0;_=="ROUND_UP"&&P*U<B&&(P+=1);const z=Math.max(P,1);R[N]=(z+k-1)/k|0}return R}function _h(){const x=this,B=x.offset,k={value:0};for(let _=0;_<x.tileCount;_++){const R=ke(x.viewer,B),N=ke(x.viewer,B);B.value+=8,x.size=Oe(x.viewer,B);const U=R*x.blockWidth,P=N*x.blockHeight;x.columns=U+x.blockWidth>x.width?x.width-U:x.blockWidth,x.lines=P+x.blockHeight>x.height?x.height-P:x.blockHeight;const z=x.columns*x.totalBytes,X=x.size<x.lines*z?x.uncompress(x):Z(x);B.value+=x.size;for(let ie=0;ie<x.lines;ie++){const he=ie*x.columns*x.totalBytes;for(let ce=0;ce<x.inputChannels.length;ce++){const fe=ms.channels[ce].name,ge=x.channelByteOffsets[fe]*x.columns,Ee=x.decodeChannels[fe];if(Ee===void 0)continue;k.value=he+ge;const De=(x.height-(1+P+ie))*x.outLineWidth;for(let Ke=0;Ke<x.columns;Ke++){const He=De+(Ke+U)*x.outputChannels+Ee;x.byteArray[He]=x.getter(X,k)}}}}}function Wa(){const x=this,B=x.offset,k={value:0};for(let _=0;_<x.height/x.blockHeight;_++){const R=ke(x.viewer,B)-ms.dataWindow.yMin;x.size=Oe(x.viewer,B),x.lines=R+x.blockHeight>x.height?x.height-R:x.blockHeight;const N=x.columns*x.totalBytes,P=x.size<x.lines*N?x.uncompress(x):Z(x);B.value+=x.size;for(let z=0;z<x.blockHeight;z++){const j=_*x.blockHeight,X=z+x.scanOrder(j);if(X>=x.height)continue;const ie=z*N,he=(x.height-1-X)*x.outLineWidth;for(let ce=0;ce<x.inputChannels.length;ce++){const fe=ms.channels[ce].name,ge=x.channelByteOffsets[fe]*x.columns,Ee=x.decodeChannels[fe];if(Ee!==void 0){k.value=ie+ge;for(let De=0;De<x.columns;De++){const Ke=he+De*x.outputChannels+Ee;x.byteArray[Ke]=x.getter(P,k)}}}}}}function Eh(x,B,k){const _={};if(x.getUint32(0,!0)!=20000630)throw new Error("THREE.EXRLoader: Provided file doesn't appear to be in OpenEXR format.");_.version=x.getUint8(4);const R=x.getUint8(5);_.spec={singleTile:!!(R&2),longName:!!(R&4),deepFormat:!!(R&8),multiPart:!!(R&16)},k.value=8;let N=!0;for(;N;){const U=Ve(B,k);if(U==="")N=!1;else{const P=Ve(B,k),z=Oe(x,k),j=xh(x,B,k,P,z);j===void 0?console.warn(`THREE.EXRLoader: Skipped unknown header attribute type '${P}'.`):_[U]=j}}if((R&-7)!=0)throw console.error("THREE.EXRHeader:",_),new Error("THREE.EXRLoader: Provided file is currently unsupported.");return _}function qa(x,B,k,_,R){const N={size:0,viewer:B,array:k,offset:_,width:x.dataWindow.xMax-x.dataWindow.xMin+1,height:x.dataWindow.yMax-x.dataWindow.yMin+1,inputChannels:x.channels,channelByteOffsets:{},scanOrder:null,totalBytes:null,columns:null,lines:null,type:null,uncompress:null,getter:null,format:null,colorSpace:rn};switch(x.compression){case"NO_COMPRESSION":N.blockHeight=1,N.uncompress=Z;break;case"RLE_COMPRESSION":N.blockHeight=1,N.uncompress=le;break;case"ZIPS_COMPRESSION":N.blockHeight=1,N.uncompress=Ae;break;case"ZIP_COMPRESSION":N.blockHeight=16,N.uncompress=Ae;break;case"PIZ_COMPRESSION":N.blockHeight=32,N.uncompress=oe;break;case"PXR24_COMPRESSION":N.blockHeight=16,N.uncompress=Ue;break;case"DWAA_COMPRESSION":N.blockHeight=32,N.uncompress=ve;break;case"DWAB_COMPRESSION":N.blockHeight=256,N.uncompress=ve;break;default:throw new Error("EXRLoader.parse: "+x.compression+" is unsupported")}const U={};for(const X of x.channels)switch(X.name){case"Y":case"R":case"G":case"B":case"A":U[X.name]=!0,N.type=X.pixelType}let P=!1;if(U.R&&U.G&&U.B)P=!U.A,N.outputChannels=4,N.decodeChannels={R:0,G:1,B:2,A:3};else if(U.Y)N.outputChannels=1,N.decodeChannels={Y:0};else throw new Error("EXRLoader.parse: file contains unsupported data channels.");if(N.type==1)switch(R){case nn:N.getter=de;break;case Bn:N.getter=re;break}else if(N.type==2)switch(R){case nn:N.getter=nt;break;case Bn:N.getter=W}else throw new Error("EXRLoader.parse: unsupported pixelType "+N.type+" for "+x.compression+".");N.columns=N.width;const z=N.width*N.height*N.outputChannels;switch(R){case nn:N.byteArray=new Float32Array(z),P&&N.byteArray.fill(1,0,z);break;case Bn:N.byteArray=new Uint16Array(z),P&&N.byteArray.fill(15360,0,z);break;default:console.error("THREE.EXRLoader: unsupported type: ",R);break}let j=0;for(const X of x.channels)N.decodeChannels[X.name]!==void 0&&(N.channelByteOffsets[X.name]=j),j+=X.pixelType*2;if(N.totalBytes=j,N.outLineWidth=N.width*N.outputChannels,x.lineOrder==="INCREASING_Y"?N.scanOrder=X=>X:N.scanOrder=X=>N.height-1-X,N.outputChannels==4?(N.format=sn,N.colorSpace=rn):(N.format=zi,N.colorSpace=li),x.spec.singleTile){N.blockHeight=x.tiles.ySize,N.blockWidth=x.tiles.xSize;const X=cc(x.tiles,N.width,N.height),ie=lc(X,N.width,x.tiles.xSize,x.tiles.roundingMode),he=lc(X,N.height,x.tiles.ySize,x.tiles.roundingMode);N.tileCount=ie[0]*he[0];for(let ce=0;ce<X;ce++)for(let fe=0;fe<he[ce];fe++)for(let ge=0;ge<ie[ce];ge++)We(B,_);N.decode=_h.bind(N)}else{N.blockWidth=N.width;const X=Math.ceil(N.height/N.blockHeight);for(let ie=0;ie<X;ie++)We(B,_);N.decode=Wa.bind(N)}return N}const hc={value:0},uc=new DataView(e),pp=new Uint8Array(e),ms=Eh(uc,e,hc),Ks=qa(ms,uc,pp,hc,this.type);return Ks.decode(),{header:ms,width:Ks.width,height:Ks.height,data:Ks.byteArray,format:Ks.format,colorSpace:Ks.colorSpace,type:this.type}}setDataType(e){return this.type=e,this}load(e,t,n,s){function r(a,o){a.colorSpace=o.colorSpace,a.minFilter=zt,a.magFilter=zt,a.generateMipmaps=!1,a.flipY=!1,t&&t(a,o)}return super.load(e,r,n,s)}}function OB(i,e){const{id:t,path:n}=e;return t==="neutral"?Promise.resolve({envMap:i.neutralEnvironment}):t===""?Promise.resolve({envMap:null}):new Promise((s,r)=>{new UB().load(n,a=>{const o=i.pmremGenerator.fromEquirectangular(a).texture;a.dispose(),i._loadedEnvironment&&i._loadedEnvironment!==o&&i._loadedEnvironment.dispose(),i._loadedEnvironment=o,s({envMap:o})},void 0,r)})}function QB(i){i.renderer.render(i.scene,i.activeCamera),i.renderer.domElement.toBlob(e=>{if(!e)return;const t=new Date().toISOString().replace(/[:.]/g,"-").slice(0,19),n=URL.createObjectURL(e),s=document.createElement("a");s.download=`3d-screenshot-${t}.png`,s.href=n,s.click(),URL.revokeObjectURL(n)},"image/png"),GB(i)}function GB(i){const e=document.createElement("div");e.className="screenshot-flash",i.el.appendChild(e),e.addEventListener("animationend",()=>e.remove())}function HB(i,e){i.mixer&&(i.mixer.stopAllAction(),i.mixer.uncacheRoot(i.mixer.getRoot()),i.mixer=null),i.clips=e,e.length&&(i.mixer=new HA(i.content))}function zB(i){i.clips.forEach(e=>{i.mixer.clipAction(e).reset().play(),i.state.actionStates[e.name]=!0}),i.invalidate()}const VB=.35;class WB{constructor(){this.model=null,this.mixer=null,this.clips=new Map,this.actions=new Map,this.currentName=null,this.currentAction=null,this.onChange=null,this._animationDefs=[],this._failed=new Set}attach(e){this.detach(),this.model=e,this.mixer=new HA(e),this.actions.clear(),this.currentAction=null,this.currentName=null;for(const[t,n]of this.clips){const s=this.mixer.clipAction(n);s.enabled=!0,this.actions.set(t,s)}}detach(){this.mixer&&(this.mixer.stopAllAction(),this.mixer.uncacheRoot(this.mixer.getRoot()),this.mixer=null),this.model=null,this.actions.clear(),this.currentAction=null,this.currentName=null}setAnimationDefs(e){this._animationDefs=e}getAnimationDefs(){return this._animationDefs}isFailed(e){return this._failed.has(e)}async loadAnimation(e,t,n={}){if(this.clips.has(e))return this.clips.get(e);const s=new AbortController,r=setTimeout(()=>s.abort(),1e4);let a;try{a=await fetch(t,{signal:s.signal})}finally{clearTimeout(r)}if(!a.ok)throw new Error(`HTTP ${a.status} loading animation ${e}`);const o=await a.json(),c=sl.parse(o);if(c.name=e,this.clips.set(e,c),this.model&&this.mixer){const l=this.mixer.clipAction(c);l.enabled=!0,l.setLoop(n.loop===!1?Np:Fp),n.loop===!1&&(l.clampWhenFinished=!0),this.actions.set(e,l)}return c}async loadAll(){const t=[...this._animationDefs],n=async()=>{let s;for(;s=t.shift();)try{await this.loadAnimation(s.name,s.url,{loop:s.loop!==!1})}catch(r){console.warn(`[AnimationManager] failed to load "${s.name}":`,r.message),this._failed.add(s.name)}};await Promise.all(Array.from({length:4},n))}async ensureLoaded(e){if(this.clips.has(e))return!0;if(this._failed.has(e))return!1;const t=this._animationDefs.find(n=>n.name===e);if(!t)return!1;try{return await this.loadAnimation(t.name,t.url,{loop:t.loop!==!1}),!0}catch{return this._failed.add(e),!1}}async play(e){if(!await this.ensureLoaded(e)){console.warn(`[AnimationManager] "${e}" unavailable`);return}const n=this.actions.get(e);if(n){this.currentAction&&this.currentAction!==n&&this.currentAction.fadeOut(.01),n.reset().fadeIn(.01).play(),this.currentAction=n,this.currentName=e;try{this.onChange?.(e)}catch(s){console.warn("[AnimationManager] onChange threw:",s)}}}async crossfadeTo(e,t=VB){if(t=Math.max(0,Math.min(t,5)),e===this.currentName)return;if(!await this.ensureLoaded(e)){console.warn(`[AnimationManager] "${e}" unavailable`);return}const s=this.actions.get(e);if(s){s.reset().play(),this.currentAction?this.currentAction.crossFadeTo(s,t,!0):s.fadeIn(t),this.currentAction=s,this.currentName=e;try{this.onChange?.(e)}catch(r){console.warn("[AnimationManager] onChange threw:",r)}}}stopAll(){this.mixer?.stopAllAction(),this.currentAction=null,this.currentName=null;try{this.onChange?.(null)}catch(e){console.warn("[AnimationManager] onChange threw:",e)}}update(e){this.mixer?.update(e)}getLoadedNames(){return[...this.clips.keys()]}isLoaded(e){return this.clips.has(e)}dispose(){this.detach(),this.clips.clear(),this._animationDefs=[],this._failed.clear()}}Zi.enabled=!0;class Vd{constructor(e,t){this.el=e,this.options=t,this.lights=[],this.content=null,this.mixer=null,this.clips=[],this.gui=null,this.animationManager=new WB,this._animPanelEl=null,this.state={environment:t.preset===Qd.ASSET_GENERATOR?gl.find(r=>r.id==="footprint-court").name:gl[1].name,background:!1,playbackSpeed:1,actionStates:{},camera:Ml,wireframe:!1,skeleton:!1,grid:!1,autoRotate:!1,punctualLights:!0,exposure:0,toneMapping:Rh,ambientIntensity:.3,ambientColor:"#FFFFFF",directIntensity:.8*Math.PI,directColor:"#FFFFFF",bgColor:"#000000",transparentBg:!1,pointSize:1,showInfo:!0,showLabels:!1,followMode:"mouse"},this.prevTime=0,this.stats=new wo,this.stats.dom.height="48px",[].forEach.call(this.stats.dom.children,r=>r.style.display=""),this.backgroundColor=new qe(this.state.bgColor),this.scene=new Tu,this.scene.background=this.backgroundColor;const n=t.preset===Qd.ASSET_GENERATOR?.8*180/Math.PI:60,s=e.clientHeight>0?e.clientWidth/e.clientHeight:1;this.defaultCamera=new Cn(n,s,.01,1e3),this.activeCamera=this.defaultCamera,this.scene.add(this.defaultCamera),this.renderer=window.renderer=new Eg({antialias:!0,alpha:!0}),this.renderer.setClearColor(0,1),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio,2)),this.renderer.setSize(e.clientWidth,e.clientHeight),this.pmremGenerator=new ed(this.renderer),this.pmremGenerator.compileEquirectangularShader(),this.neutralEnvironment=this.pmremGenerator.fromScene(new s1).texture,this.controls=new WI(this.defaultCamera,this.renderer.domElement),this.controls.screenSpacePanning=!0,this._onControlsChange=()=>this.invalidate(),this.controls.addEventListener("change",this._onControlsChange),this.el.appendChild(this.renderer.domElement),this.cameraCtrl=null,this.cameraFolder=null,this.animFolder=null,this.animCtrls=[],this.morphFolder=null,this.morphCtrls=[],this.skeletonHelpers=[],this.gridHelper=null,this.axesHelper=null,this.modelInfo=null,this.annotationEls=[],this._tempVec=new H,this.addAxesHelper(),this.addGUI(),t.kiosk&&this.gui.close(),this.animate=this.animate.bind(this),this._rafId=null,this._visible=!0,this._tabVisible=!document.hidden,this._disposed=!1,this._loadedEnvironment=null,this._guiWrap=null,this._needsRender=!0,this._animating=!1,this._onVisibilityChange=()=>{const r=!this._tabVisible;this._tabVisible=!document.hidden,r&&this._tabVisible&&(this._needsRender=!0),this._updateRenderLoop()},document.addEventListener("visibilitychange",this._onVisibilityChange),typeof IntersectionObserver<"u"&&(this._intersectionObserver=new IntersectionObserver(r=>{const a=!this._visible;this._visible=r[r.length-1].isIntersecting,a&&this._visible&&(this._needsRender=!0),this._updateRenderLoop()},{threshold:0}),this._intersectionObserver.observe(this.el)),this._onResize=this.resize.bind(this),this._onKeyDown=r=>{this.isInputFocused()||(r.key==="p"||r.key==="P"?this.takeScreenshot():r.code==="Space"?(r.preventDefault(),this.toggleAnimationPlayback()):(r.key==="f"||r.key==="F")&&this.frameContent())},this._onDblClick=()=>this.frameContent({animate:!0}),this._updateRenderLoop(),window.addEventListener("resize",this._onResize,!1),window.addEventListener("keydown",this._onKeyDown),this.renderer.domElement.addEventListener("dblclick",this._onDblClick)}invalidate(){this._disposed||(this._needsRender=!0,this._updateRenderLoop())}attachScenePrefs(e){if(!e||typeof window>"u")return;this._prefsKey=`3dagent:scene:${e}`;try{const s=localStorage.getItem(this._prefsKey);if(s){const r=JSON.parse(s),a=["background","transparentBg","bgColor","autoRotate","exposure","environment"];let o=!1;for(const c of a)r[c]!==void 0&&r[c]!==this.state[c]&&(this.state[c]=r[c],o=!0);o&&(this.backgroundColor.set(this.state.bgColor),this.updateLights(),this.updateEnvironment(),this.updateDisplay(),this.updateBackground(),this.updateGUI?.())}}catch{}const t=()=>{if(this._prefsKey)try{const s={background:this.state.background,transparentBg:this.state.transparentBg,bgColor:this.state.bgColor,autoRotate:this.state.autoRotate,exposure:this.state.exposure,environment:this.state.environment};localStorage.setItem(this._prefsKey,JSON.stringify(s))}catch{}};let n=null;this._scenePrefsSave=()=>{n&&clearTimeout(n),n=setTimeout(t,250)}}notifyScenePrefChange(){this._scenePrefsSave&&this._scenePrefsSave()}toggleAnimationPlayback(){const e=this.animationManager;if(!e)return;if(e.currentAction){e.currentAction.paused=!e.currentAction.paused,this.invalidate(),this._recomputeAnimating(),this._updateRenderLoop();return}const n=(e.getAnimationDefs?.()||[]).find(s=>e.isLoaded?.(s.name));n&&(e.play(n.name),this.invalidate(),this._recomputeAnimating(),this._updateRenderLoop())}frameContent({animate:e=!1,durationMs:t=600}={}){if(!this.content||!this.defaultCamera||!this.controls)return;const n=new di().setFromObject(this.content),s=n.getSize(new H),r=s.length();if(!isFinite(r)||r===0)return;const a=n.getCenter(new H),o=this.defaultCamera.fov*(Math.PI/180),c=Math.max(this.defaultCamera.aspect,.01),l=2*Math.atan(Math.tan(o/2)*c),h=s.y/2*1.15/Math.tan(o/2),u=s.x/2*1.15/Math.tan(l/2),d=Math.max(h,u),f=a.y+s.y*.1,m=new H(a.x,f,a.z),A=new H(a.x+d*.12,f,a.z+d),g=this._panelBiasY(d);m.y-=g,A.y-=g,e?this._tweenCamera(A,m,t):(this.defaultCamera.position.copy(A),this.controls.target.copy(m),this.controls.update(),this.invalidate())}_panelBiasY(e){if(!this._animPanelEl)return 0;const t=this._animPanelEl.offsetHeight,n=parseFloat(getComputedStyle(this._animPanelEl).bottom)||0,s=this.renderer.domElement.clientHeight;return s?(t+n)/s*Math.tan(this.defaultCamera.fov/2*(Math.PI/180))*e:0}_tweenCamera(e,t,n=600){this._cameraTweenRaf&&cancelAnimationFrame(this._cameraTweenRaf);const s=this.defaultCamera.position.clone(),r=this.controls.target.clone(),a=performance.now(),o=l=>1-Math.pow(1-l,3),c=l=>{const h=Math.min(1,(l-a)/n),u=o(h);this.defaultCamera.position.lerpVectors(s,e,u),this.controls.target.lerpVectors(r,t,u),this.controls.update(),this.invalidate(),h<1&&!this._disposed?this._cameraTweenRaf=requestAnimationFrame(c):this._cameraTweenRaf=null};this._cameraTweenRaf=requestAnimationFrame(c)}_recomputeAnimating(){let e=!1;if(this.state&&this.state.autoRotate&&(e=!0),!e&&this.mixer&&this.state){for(const t in this.state.actionStates)if(this.state.actionStates[t]){e=!0;break}}!e&&this.animationManager.currentAction&&(e=!0),this._animating=e}_updateRenderLoop(){if(this._disposed)return;const e=this._visible&&this._tabVisible;e&&(this._needsRender||this._animating)&&this._rafId===null?(this.prevTime=performance.now(),this._rafId=requestAnimationFrame(this.animate)):!e&&this._rafId!==null&&(cancelAnimationFrame(this._rafId),this._rafId=null)}animate(e){const t=(e-this.prevTime)/1e3;if(this.prevTime=e,this._recomputeAnimating(),this.controls.update(),this.stats.update(),this.mixer&&this.mixer.update(t),this.animationManager.update(t),this._afterAnimateHooks)for(let n=0;n<this._afterAnimateHooks.length;n++)this._afterAnimateHooks[n](t);this.render(),this._needsRender=!1,this._animating&&this._visible&&this._tabVisible&&!this._disposed?this._rafId=requestAnimationFrame(this.animate):this._rafId=null}isInputFocused(){const e=document.activeElement;return e&&(e.tagName==="INPUT"||e.tagName==="TEXTAREA"||e.isContentEditable)}render(){this.renderer.render(this.scene,this.activeCamera),this.state.grid&&(this.axesCamera.position.copy(this.defaultCamera.position),this.axesCamera.lookAt(this.axesScene.position),this.axesRenderer.render(this.axesScene,this.axesCamera)),this.projectAnnotations()}takeScreenshot(){QB(this)}async setARTarget(e,t=null){if(this._arGlbUrl=e,this._arUsdzUrl=t,!this._arBtn)return;const n=!!e,r=!!t&&Lm(),a=n&&Pm(),o=n&&await km.isSupported();this._arBtn.hidden=!(r||a||o)}async _launchAR(){if(Lm()&&this._arUsdzUrl)dB(this._arUsdzUrl);else if(Pm()&&this._arGlbUrl)pB(this._arGlbUrl);else if(this._arGlbUrl){if(this._xrSession){await this._xrSession.end(),this._xrSession=null,this._arBtn.classList.remove("ar-btn--active");return}this._xrSession=new km(this,{onEnd:()=>{this._xrSession=null,this._arBtn.classList.remove("ar-btn--active")}}),await this._xrSession.start(),this._arBtn.classList.add("ar-btn--active")}}resize(){const{clientHeight:e,clientWidth:t}=this.el;t===0||e===0||(this.defaultCamera.aspect=t/e,this.defaultCamera.updateProjectionMatrix(),this.renderer.setSize(t,e),this.axesCamera.aspect=this.axesDiv.clientWidth/this.axesDiv.clientHeight,this.axesCamera.updateProjectionMatrix(),this.axesRenderer.setSize(this.axesDiv.clientWidth,this.axesDiv.clientHeight),this.invalidate())}load(e,t,n){const s=da.extractUrlBase(e);return new Promise((r,a)=>{Bl.setURLModifier((c,l)=>{const h=t+decodeURI(c).replace(s,"").replace(/^(\.?\/)/,"");if(n.has(h)){const u=n.get(h),d=URL.createObjectURL(u);return o.push(d),d}return(l||"")+c});const o=[];_B().then(({dracoLoader:c,ktx2Loader:l,meshoptDecoder:h})=>{new wg(Bl).setCrossOrigin("anonymous").setDRACOLoader(c).setKTX2Loader(l.detectSupport(this.renderer)).setMeshoptDecoder(h).load(e,d=>{window.VIEWER.json=d;const f=d.scene||d.scenes[0],m=d.animations||[];if(!f)throw new Error("This model contains no scene, and cannot be viewed here. However, it may contain individual 3D resources.");this.setContent(f,m),o.forEach(URL.revokeObjectURL),r(d)},void 0,a)},a)})}setContent(e,t){this.clear(),e.updateMatrixWorld();const n=new di().setFromObject(e),s=n.getSize(new H).length(),r=n.getCenter(new H);this.controls.reset(),e.position.x-=r.x,e.position.y-=r.y,e.position.z-=r.z,this.controls.maxDistance=s*10,this.defaultCamera.near=s/100,this.defaultCamera.far=s*100,this.defaultCamera.updateProjectionMatrix();const a=n.getSize(new H),o=this.defaultCamera.fov*(Math.PI/180),c=Math.max(this.defaultCamera.aspect,.01),l=2*Math.atan(Math.tan(o/2)*c),h=a.y/2*1.15/Math.tan(o/2),u=a.x/2*1.15/Math.tan(l/2),d=Math.max(h,u),f=a.y*.1,m=new H;this.options.cameraPosition?m.fromArray(this.options.cameraPosition):m.set(d*.12,f,d);const A=this.options.cameraPosition?new H:new H(0,f,0);if(this.options.kiosk||this.options.cameraPosition||this._hasRevealed===!0)this.defaultCamera.position.copy(m),this.defaultCamera.lookAt(A);else{const y=new H().subVectors(m,A).multiplyScalar(1.4).add(A);y.y+=s/8,this.defaultCamera.position.copy(y),this.defaultCamera.lookAt(A),this._pendingReveal={framedPos:m.clone(),target:A.clone()},this._hasRevealed=!0}this.setCamera(Ml),this.axesCamera.position.copy(this.defaultCamera.position),this.axesCamera.lookAt(this.axesScene.position),this.axesCamera.near=s/100,this.axesCamera.far=s*100,this.axesCamera.updateProjectionMatrix(),this.axesCorner.scale.set(s,s,s),this.controls.saveState(),this.scene.add(e),this.content=e,this.state.punctualLights=!0,this.content.traverse(y=>{y.isLight&&(this.state.punctualLights=!1)}),this.setClips(t),this.animationManager.attach(this.content),this._setupAnimationPanel();const p=this._panelBiasY(d);if(p>0&&(this.controls.target.y-=p,this.defaultCamera.position.y-=p,this._pendingReveal&&(this._pendingReveal.framedPos.y-=p,this._pendingReveal.target.y-=p),this.controls.update()),this.updateLights(),this.updateGUI(),this.updateEnvironment(),this.updateDisplay(),this.updateModelInfo(e,t),this.updateAnnotations(),window.VIEWER.scene=this.content,this.invalidate(),this._pendingReveal){const{framedPos:y,target:b}=this._pendingReveal;this._pendingReveal=null,this._tweenCamera(y,b,1500)}}setClips(e){HB(this,e)}playAllClips(){zB(this)}setCamera(e){e===Ml?(this.controls.enabled=!0,this.activeCamera=this.defaultCamera):(this.controls.enabled=!1,this.content.traverse(t=>{t.isCamera&&t.name===e&&(this.activeCamera=t)})),this.invalidate()}updateLights(){const e=this.state,t=this.lights;e.punctualLights&&!t.length?EB(this):!e.punctualLights&&t.length&&yB(this),this.renderer.toneMapping=Number(e.toneMapping),this.renderer.toneMappingExposure=Math.pow(2,e.exposure),t.length===2&&(t[0].intensity=e.ambientIntensity,t[0].color.set(e.ambientColor),t[1].intensity=e.directIntensity,t[1].color.set(e.directColor)),this.invalidate()}updateEnvironment(){const e=gl.filter(t=>t.name===this.state.environment)[0];OB(this,e).then(({envMap:t})=>{this._disposed||!this.scene||(this.scene.environment=t,this.scene.background=this.state.transparentBg?null:this.state.background?t:this.backgroundColor,this.invalidate())})}updateDisplay(){this.skeletonHelpers.length&&this.skeletonHelpers.forEach(e=>this.scene.remove(e)),zm(this.content,e=>{e.wireframe=this.state.wireframe,e instanceof Qu&&(e.size=this.state.pointSize)}),this.content.traverse(e=>{if(e.geometry&&e.skeleton&&this.state.skeleton){const t=new rw(e.skeleton.bones[0].parent);t.material.linewidth=3,this.scene.add(t),this.skeletonHelpers.push(t)}}),this.state.grid!==!!this.gridHelper&&(this.state.grid?(this.gridHelper=new aw,this.axesHelper=new WA,this.axesHelper.renderOrder=999,this.axesHelper.onBeforeRender=e=>e.clearDepth(),this.scene.add(this.gridHelper),this.scene.add(this.axesHelper)):(this.scene.remove(this.gridHelper),this.scene.remove(this.axesHelper),this.gridHelper=null,this.axesHelper=null,this.axesRenderer.clear())),this.controls.autoRotate=this.state.autoRotate,this.invalidate()}updateBackground(){this.backgroundColor.set(this.state.bgColor),this.state.transparentBg?(this.scene.background=null,this.renderer.setClearColor(0,0)):(this.scene.background=this.backgroundColor,this.renderer.setClearColor(0,1),this.updateEnvironment()),this.invalidate()}setBackgroundColor(e){this.state.bgColor=typeof e=="string"?e:"#"+e.toString(16).padStart(6,"0"),this.state.transparentBg=!1,this.updateBackground()}updateModelInfo(e,t){this.modelInfo&&(this.modelInfo.remove(),this.modelInfo=null),this.state.showInfo&&e&&(this.modelInfo=hB(this.el,e,t))}updateAnnotations(){if(this.annotationEls.forEach(t=>t.el.remove()),this.annotationEls=[],!this.state.showLabels||!this.content)return;mB(this.content).forEach(t=>{const n=bB(t),s=document.createElement("div");s.classList.add("annotation-label"),s.appendChild(n),this.el.appendChild(s),this.annotationEls.push({el:s,position:t.position})}),this.invalidate()}projectAnnotations(){if(this.annotationEls.length===0)return;const e=this.el.clientWidth,t=this.el.clientHeight,n=e/2,s=t/2,r=this._tempVec;this.annotationEls.forEach(({el:a,position:o})=>{if(r.copy(o),r.project(this.activeCamera),r.z>1){a.style.display="none";return}const c=r.x*n+n,l=-(r.y*s)+s;a.style.display="",a.style.left=c+"px",a.style.top=l+"px"})}addAxesHelper(){this.axesDiv=document.createElement("div"),this.el.appendChild(this.axesDiv),this.axesDiv.classList.add("axes");const{clientWidth:e,clientHeight:t}=this.axesDiv;this.axesScene=new Tu,this.axesCamera=new Cn(50,e/t,.1,10),this.axesScene.add(this.axesCamera),this.axesRenderer=new Eg({alpha:!0}),this.axesRenderer.setPixelRatio(window.devicePixelRatio),this.axesRenderer.setSize(this.axesDiv.clientWidth,this.axesDiv.clientHeight),this.axesCamera.up=this.defaultCamera.up,this.axesCorner=new WA(5),this.axesScene.add(this.axesCorner),this.axesDiv.appendChild(this.axesRenderer.domElement)}addGUI(){const e=window.innerWidth<=700,t=this.gui=new S1({autoPlace:!1,width:e?220:260,hideable:!0}),n=t.addFolder("Display");n.add(this.state,"background").onChange(()=>{this.updateEnvironment(),this.notifyScenePrefChange()}),n.add(this.state,"autoRotate").onChange(()=>{this.updateDisplay(),this.notifyScenePrefChange()}),n.add(this.state,"wireframe").onChange(()=>this.updateDisplay()),n.add(this.state,"skeleton").onChange(()=>this.updateDisplay()),n.add(this.state,"grid").onChange(()=>this.updateDisplay()),n.add(this.controls,"screenSpacePanning"),n.add(this.state,"pointSize",1,16).onChange(()=>this.updateDisplay()),n.add(this.state,"transparentBg").name("transparent bg").onChange(()=>{this.updateBackground(),this.notifyScenePrefChange()}),n.addColor(this.state,"bgColor").onChange(()=>{this.updateBackground(),this.notifyScenePrefChange()}),n.add({screenshot:()=>this.takeScreenshot()},"screenshot").name("Screenshot [P]"),n.add(this.state,"showInfo").name("model info").onChange(()=>this.updateModelInfo(this.content,this.clips)),n.add(this.state,"showLabels").name("mesh labels").onChange(()=>this.updateAnnotations());const m=t.addFolder("Lighting");m.add(this.state,"environment",gl.map(T=>T.name)).onChange(()=>{this.updateEnvironment(),this.notifyScenePrefChange()}),m.add(this.state,"exposure",-10,10,.01).onChange(()=>{this.updateLights(),this.notifyScenePrefChange()}),[m.add(this.state,"toneMapping",{Linear:Rh,"ACES Filmic":yp}),m.add(this.state,"punctualLights").listen(),m.add(this.state,"ambientIntensity",0,2),m.addColor(this.state,"ambientColor"),m.add(this.state,"directIntensity",0,4),m.addColor(this.state,"directColor")].forEach(T=>T.onChange(()=>this.updateLights())),this.animFolder=t.addFolder("Animation"),this.animFolder.domElement.style.display="none",this.animFolder.add(this.state,"playbackSpeed",0,1).onChange(T=>{this.mixer&&(this.mixer.timeScale=T)}),this.animFolder.add({playAll:()=>this.playAllClips()},"playAll"),this.morphFolder=t.addFolder("Morph Targets"),this.morphFolder.domElement.style.display="none",this.cameraFolder=t.addFolder("Cameras"),this.cameraFolder.domElement.style.display="none",t.addFolder("Agent").add(this.state,"followMode",{None:"none","Follow Mouse":"mouse","Follow Keystrokes":"keystrokes"}).name("follow mode");const b=t.addFolder("Performance"),E=document.createElement("li");this.stats.dom.style.position="static",E.appendChild(this.stats.dom),E.classList.add("gui-stats"),b.__ul.appendChild(E);const M=document.createElement("div");this.el.appendChild(M),M.classList.add("gui-wrap"),M.classList.add("gui-wrap--hidden"),M.appendChild(t.domElement),this._guiWrap=M;const w=document.createElement("button");w.className="gui-toggle",w.setAttribute("title","Toggle advanced controls"),w.setAttribute("aria-label","Toggle advanced controls"),w.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="3"></circle><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"></path></svg><span class="gui-toggle__label">Controls</span>',w.addEventListener("click",()=>{const T=M.classList.toggle("gui-wrap--hidden");w.classList.toggle("gui-toggle--active",!T)}),this.el.appendChild(w),this._guiToggle=w;const S=document.createElement("button");S.className="ar-btn",S.setAttribute("title","View in AR"),S.setAttribute("aria-label","View in AR"),S.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M1 6l5-3 5 3v5l-5 3-5-3z"></path><path d="M11 3l5 3v5l-5-3z"></path><path d="M1 11l5 3 5-3"></path><path d="M6 9v5"></path><path d="M16 6v5l5 3v-5z"></path><path d="M11 8l5 3"></path></svg><span class="ar-btn__label">AR</span>',S.hidden=!0,S.addEventListener("click",()=>this._launchAR()),this.el.appendChild(S),this._arBtn=S,this._arGlbUrl=null,this._arUsdzUrl=null,this._xrSession=null,e?t.close():t.open()}updateGUI(){this.cameraFolder.domElement.style.display="none",this.morphCtrls.forEach(n=>n.remove()),this.morphCtrls.length=0,this.morphFolder.domElement.style.display="none",this.animCtrls.forEach(n=>n.remove()),this.animCtrls.length=0,this.animFolder.domElement.style.display="none";const e=[],t=[];if(this.content.traverse(n=>{n.geometry&&n.morphTargetInfluences&&t.push(n),n.isCamera&&(n.name=n.name||`VIEWER__camera_${e.length+1}`,e.push(n.name))}),e.length){this.cameraFolder.domElement.style.display="",this.cameraCtrl&&this.cameraCtrl.remove();const n=[Ml].concat(e);this.cameraCtrl=this.cameraFolder.add(this.state,"camera",n),this.cameraCtrl.onChange(s=>this.setCamera(s))}if(t.length&&(this.morphFolder.domElement.style.display="",t.forEach(n=>{if(n.morphTargetInfluences.length){const s=this.morphFolder.add({name:n.name||"Untitled"},"name");this.morphCtrls.push(s)}for(let s=0;s<n.morphTargetInfluences.length;s++){const r=this.morphFolder.add(n.morphTargetInfluences,s,0,1,.01).listen();Object.keys(n.morphTargetDictionary).forEach(a=>{a&&n.morphTargetDictionary[a]===s&&r.name(a)}),this.morphCtrls.push(r)}})),this.clips.length){this.animFolder.domElement.style.display="";const n=this.state.actionStates={};this.clips.forEach((s,r)=>{s.name=`${r+1}. ${s.name}`;let a;r===0?(n[s.name]=!0,a=this.mixer.clipAction(s),a.play()):n[s.name]=!1;const o=this.animFolder.add(n,s.name).listen();o.onChange(c=>{a=a||this.mixer.clipAction(s),a.setEffectiveTimeScale(1),c?a.play():a.stop(),this.invalidate()}),this.animCtrls.push(o)})}}setAnimationDefs(e){this.animationManager.setAnimationDefs(e),this.content&&this._setupAnimationPanel()}_setupAnimationPanel(){if(this._animPanelEl&&(this._animPanelEl.remove(),this._animPanelEl=null),this.animationManager.getAnimationDefs().length===0)return;let t=!1;if(this.content.traverse(s=>{s.isSkinnedMesh&&(t=!0)}),!t)return;const n=document.createElement("div");n.className="anim-panel",n.innerHTML='<div class="anim-panel__header"><span class="anim-panel__title">Animations</span><button class="anim-panel__stop" title="Stop all">⏹</button></div><div class="anim-panel__grid"></div>',this.el.appendChild(n),this._animPanelEl=n,this._renderAnimButtons(),this.animationManager.loadAll().then(()=>{this._renderAnimButtons()}),n.querySelector(".anim-panel__stop").addEventListener("click",()=>{this.animationManager.stopAll(),this._renderAnimButtons(),this.invalidate()}),this.animationManager.onChange=()=>{this._renderAnimButtons()}}_renderAnimButtons(){if(!this._animPanelEl)return;const e=this._animPanelEl.querySelector(".anim-panel__grid"),t=this.animationManager.getAnimationDefs(),n=this.animationManager.currentName,s={idle:"🧍",breathing:"🧍",standing:"🧍",walking:"🚶",walk:"🚶",running:"🏃",run:"🏃",waving:"👋",wave:"👋",dancing:"💃",dance:"💃",sitting:"🪑",sit:"🪑",jumping:"🦘",jump:"🦘",talking:"🗣️",talk:"🗣️",clapping:"👏",clap:"👏",punching:"👊",punch:"👊",kicking:"🦵",kick:"🦵"};e.innerHTML=t.map((r,a)=>{const o=this.animationManager.isLoaded(r.name),c=n===r.name,l=r.icon||s[r.name.toLowerCase()]||"▶",h=r.label||r.name.charAt(0).toUpperCase()+r.name.slice(1),u=a<9?a+1:"";return'<button class="anim-btn'+(c?" anim-btn--active":"")+(o?"":" anim-btn--loading")+'" data-anim="'+r.name+'" title="'+h+(u?" — press "+u:"")+'"'+(o?"":" disabled")+">"+(u?'<span class="anim-btn__key">'+u+"</span>":"")+'<span class="anim-btn__icon">'+l+'</span><span class="anim-btn__label">'+h+"</span></button>"}).join(""),e.querySelectorAll(".anim-btn:not([disabled])").forEach(r=>{r.addEventListener("click",()=>{const a=r.dataset.anim;this.animationManager.crossfadeTo(a),this.invalidate(),this._recomputeAnimating(),this._updateRenderLoop()})}),this._onAnimHotkey||(this._onAnimHotkey=r=>{if(r.target&&/INPUT|TEXTAREA|SELECT/.test(r.target.tagName)||r.metaKey||r.ctrlKey||r.altKey)return;const a=parseInt(r.key,10);if(!a||a<1||a>9)return;const c=this.animationManager.getAnimationDefs()[a-1];!c||!this.animationManager.isLoaded(c.name)||(this.animationManager.crossfadeTo(c.name),this.invalidate(),this._recomputeAnimating(),this._updateRenderLoop())},document.addEventListener("keydown",this._onAnimHotkey))}clear(){this.content&&(this.animationManager.detach(),this._animPanelEl&&(this._animPanelEl.remove(),this._animPanelEl=null),this.modelInfo&&(this.modelInfo.remove(),this.modelInfo=null),this.annotationEls.forEach(e=>e.el.remove()),this.annotationEls=[],this.scene.remove(this.content),this.content.traverse(e=>{e.geometry&&e.geometry.dispose()}),zm(this.content,e=>{for(const t in e)t!=="envMap"&&e[t]&&e[t].isTexture&&e[t].dispose()}),this.content=null,this._disposed||this.invalidate())}dispose(){if(!this._disposed){if(this._disposed=!0,this._rafId!==null&&(cancelAnimationFrame(this._rafId),this._rafId=null),document.removeEventListener("visibilitychange",this._onVisibilityChange),window.removeEventListener("resize",this._onResize,!1),window.removeEventListener("keydown",this._onKeyDown),this._onDblClick&&this.renderer?.domElement&&this.renderer.domElement.removeEventListener("dblclick",this._onDblClick),this._cameraTweenRaf&&cancelAnimationFrame(this._cameraTweenRaf),this._onAnimHotkey&&(document.removeEventListener("keydown",this._onAnimHotkey),this._onAnimHotkey=null),this._intersectionObserver&&(this._intersectionObserver.disconnect(),this._intersectionObserver=null),this.clear(),this.mixer){this.mixer.stopAllAction();const e=this.mixer.getRoot();e&&this.mixer.uncacheRoot(e),this.mixer=null}this.clips=[],this.animationManager.dispose(),this._animPanelEl&&(this._animPanelEl.remove(),this._animPanelEl=null),this.skeletonHelpers.length&&(this.skeletonHelpers.forEach(e=>{this.scene.remove(e),e.dispose?.()}),this.skeletonHelpers.length=0),this.gridHelper&&(this.scene.remove(this.gridHelper),this.gridHelper.geometry?.dispose(),this.gridHelper.material?.dispose(),this.gridHelper=null),this.axesHelper&&(this.scene.remove(this.axesHelper),this.axesHelper.geometry?.dispose(),this.axesHelper.material?.dispose(),this.axesHelper=null),this.axesCorner&&(this.axesScene?.remove(this.axesCorner),this.axesCorner.geometry?.dispose(),this.axesCorner.material?.dispose(),this.axesCorner=null),this.lights.forEach(e=>e.parent?.remove(e)),this.lights=[],this.annotationEls.length&&(this.annotationEls.forEach(e=>e.el.remove()),this.annotationEls=[]),this.modelInfo&&(this.modelInfo.remove(),this.modelInfo=null),this.gui&&(this.gui.destroy(),this.gui=null),this._guiWrap&&(this._guiWrap.remove(),this._guiWrap=null),this._guiToggle&&(this._guiToggle.remove(),this._guiToggle=null),this.stats?.dom&&this.stats.dom.remove(),this.controls&&(this._onControlsChange&&(this.controls.removeEventListener("change",this._onControlsChange),this._onControlsChange=null),this.controls.dispose(),this.controls=null),this._loadedEnvironment&&(this._loadedEnvironment.dispose(),this._loadedEnvironment=null),this.neutralEnvironment&&(this.neutralEnvironment.dispose(),this.neutralEnvironment=null),this.scene&&(this.scene.environment=null,this.scene.background=null),this.pmremGenerator&&(this.pmremGenerator.dispose(),this.pmremGenerator=null),this.axesRenderer&&(this.axesRenderer.dispose(),this.axesRenderer.forceContextLoss?.(),this.axesRenderer.domElement?.remove(),this.axesRenderer=null),this.axesDiv&&(this.axesDiv.remove(),this.axesDiv=null),this.axesScene=null,this.axesCamera=null,this.renderer&&(this.renderer.dispose(),this.renderer.forceContextLoss?.(),this.renderer.domElement?.remove(),window.renderer===this.renderer&&(window.renderer=null),this.renderer=null),this.scene=null,this.content=null,this.activeCamera=null,this.defaultCamera=null,this._afterAnimateHooks=null}}}class qB{constructor({model:e="claude-opus-4-6",proxyURL:t,apiKey:n,agentId:s,apiOrigin:r,temperature:a=.7,maxTokens:o=4096,thinking:c="auto"}={}){this.model=e,this.apiKey=n,this.temperature=a,this.maxTokens=o,this.thinking=c,t?this.proxyURL=t:!n&&s&&r?this.proxyURL=`${r}/api/llm/anthropic?agent=${encodeURIComponent(s)}`:this.proxyURL=null}async complete({system:e,messages:t,tools:n}){const s={model:this.model,max_tokens:this.maxTokens,temperature:this.temperature,system:e,messages:t};n&&n.length&&(s.tools=n),this.thinking==="always"&&(s.thinking={type:"enabled",budget_tokens:2048});const r=this.proxyURL||"https://api.anthropic.com/v1/messages",a={"content-type":"application/json"};this.apiKey&&(a["x-api-key"]=this.apiKey,a["anthropic-version"]="2023-06-01",a["anthropic-dangerous-direct-browser-access"]="true");const o=await fetch(r,{method:"POST",headers:a,body:JSON.stringify(s)});if(!o.ok){const l=await o.text();throw new Error(`Anthropic ${o.status}: ${l}`)}const c=await o.json();return this._normalize(c)}_normalize(e){const t={text:"",toolCalls:[],thinking:"",stopReason:e.stop_reason};for(const n of e.content||[])n.type==="text"?t.text+=n.text:n.type==="thinking"?t.thinking+=n.thinking||"":n.type==="tool_use"&&t.toolCalls.push({id:n.id,name:n.name,input:n.input});return t}formatToolResults(e){return{role:"user",content:e.map(t=>({type:"tool_result",tool_use_id:t.id,content:typeof t.output=="string"?t.output:JSON.stringify(t.output),is_error:!!t.isError}))}}formatAssistantWithToolCalls(e,t){const n=[];e&&n.push({type:"text",text:e});for(const s of t)n.push({type:"tool_use",id:s.id,name:s.name,input:s.input});return{role:"assistant",content:n}}}class KB{async complete(){return{text:"",toolCalls:[],stopReason:"end_turn"}}formatToolResults(){return{role:"user",content:[]}}formatAssistantWithToolCalls(e){return{role:"assistant",content:e||""}}}function jB(i={}){const e=i.provider||"anthropic";if(e==="anthropic")return new qB(i);if(e==="none")return new KB;throw new Error(`Unsupported provider: ${e}. Supported: anthropic, none`)}class XB{constructor({voiceId:e="default",rate:t=1,pitch:n=1,lang:s="en-US"}={}){this.voiceId=e,this.rate=t,this.pitch=n,this.lang=s,this._queue=[],this._speaking=!1}async speak(e,{onStart:t,onEnd:n}={}){if("speechSynthesis"in window)return new Promise(s=>{const r=new SpeechSynthesisUtterance(e);r.rate=this.rate,r.pitch=this.pitch,r.lang=this.lang;const a=this._pickVoice();a&&(r.voice=a),r.onstart=()=>{this._speaking=!0,t?.()},r.onend=()=>{this._speaking=!1,n?.(),s()},r.onerror=()=>{this._speaking=!1,s()},window.speechSynthesis.speak(r)})}cancel(){"speechSynthesis"in window&&window.speechSynthesis.cancel(),this._speaking=!1}get speaking(){return this._speaking}_pickVoice(){if(!("speechSynthesis"in window))return null;const e=window.speechSynthesis.getVoices();if(this.voiceId&&this.voiceId!=="default"){const t=e.find(n=>n.name===this.voiceId||n.voiceURI===this.voiceId);if(t)return t}return e.find(t=>t.lang?.startsWith(this.lang.slice(0,2)))||null}}class YB{constructor({language:e="en-US",continuous:t=!1,interimResults:n=!0}={}){this.language=e,this.continuous=t,this.interimResults=n,this._recognition=null,this._listening=!1}_ensure(){if(this._recognition)return this._recognition;const e=window.SpeechRecognition||window.webkitSpeechRecognition;if(!e)return null;const t=new e;return t.lang=this.language,t.continuous=this.continuous,t.interimResults=this.interimResults,this._recognition=t,t}async listen({onInterim:e,onFinal:t}={}){const n=this._ensure();if(!n)throw new Error("SpeechRecognition unavailable in this browser");return new Promise((s,r)=>{let a="";n.onresult=o=>{for(let c=o.resultIndex;c<o.results.length;c++){const l=o.results[c],h=l[0].transcript;l.isFinal?(a+=h,t?.(h)):e?.(h)}},n.onerror=o=>{this._listening=!1,r(o.error)},n.onend=()=>{this._listening=!1,s(a.trim())},this._listening=!0;try{n.start()}catch(o){this._listening=!1,r(o)}})}stop(){this._recognition&&this._listening&&this._recognition.stop()}get listening(){return this._listening}}class JB{constructor({voiceId:e,modelId:t="eleven_turbo_v2_5",apiKey:n=null,proxyURL:s=null,rate:r=1,pitch:a=1,lang:o="en-US",stability:c=.5,similarityBoost:l=.75,useSpeakerBoost:h=!0}={}){if(!e)throw new Error("ElevenLabsTTS requires voiceId");this.voiceId=e,this.modelId=t,this.apiKey=n,this.proxyURL=s,this.rate=r,this.pitch=a,this.lang=o,this.stability=c,this.similarityBoost=l,this.useSpeakerBoost=h,this._speaking=!1,this._abort=null,this._audio=null,this._mediaSourceURL=null,this._onEnd=null}async speak(e,{onStart:t,onEnd:n}={}){if(this.cancel(),!e)return;this._abort=new AbortController,this._speaking=!0;const s=this.proxyURL||`https://api.elevenlabs.io/v1/text-to-speech/${encodeURIComponent(this.voiceId)}/stream`,r={"content-type":"application/json",accept:"audio/mpeg"};!this.proxyURL&&this.apiKey&&(r["xi-api-key"]=this.apiKey);const a=Math.min(1.5,Math.max(.5,this.rate)),o=Math.min(1,Math.max(0,(a-.5)/1)),c=JSON.stringify({text:e,model_id:this.modelId,voice_settings:{stability:this.stability,similarity_boost:this.similarityBoost,style:o,use_speaker_boost:this.useSpeakerBoost},voiceId:this.voiceId,modelId:this.modelId});let l;try{l=await fetch(s,{method:"POST",headers:r,body:c,signal:this._abort.signal})}catch(d){if(this._speaking=!1,d.name==="AbortError")return;throw d}if(!l.ok)throw this._speaking=!1,new Error(`ElevenLabs TTS HTTP ${l.status}`);const h=typeof MediaSource<"u"&&MediaSource.isTypeSupported("audio/mpeg"),u=d=>{this._startedFired||(this._startedFired=!0,d?.())};return this._startedFired=!1,new Promise(d=>{this._onEnd=()=>{this._speaking=!1,this._cleanupAudio(),n?.(),this._onEnd=null,d()};const f=()=>{this._onEnd&&this._onEnd()};h&&l.body?this._playStreamingMSE(l.body,()=>u(t),f):this._playBuffered(l,()=>u(t),f)})}cancel(){if(this._abort){try{this._abort.abort()}catch{}this._abort=null}this._cleanupAudio(),this._speaking=!1,this._onEnd&&this._onEnd()}get speaking(){return this._speaking}_playStreamingMSE(e,t,n){const s=new MediaSource;this._mediaSourceURL=URL.createObjectURL(s);const r=new Audio(this._mediaSourceURL);this._audio=r,r.preload="auto",r.addEventListener("playing",t,{once:!0}),r.addEventListener("ended",()=>this._onEnd?.(),{once:!0}),r.addEventListener("error",()=>n?.(),{once:!0}),s.addEventListener("sourceopen",async()=>{let a;try{a=s.addSourceBuffer("audio/mpeg")}catch{n?.();return}const o=e.getReader(),c=[];let l=!0;const h=()=>{if(!l||a.updating)return;const u=c.shift();if(u)try{a.appendBuffer(u)}catch{l=!1;try{s.endOfStream()}catch{}}};a.addEventListener("updateend",h);try{for(;l;){const{value:u,done:d}=await o.read();if(d){l=!1;const f=()=>{if(a.updating||c.length)setTimeout(f,30);else try{s.endOfStream()}catch{}};f();break}c.push(u),h()}}catch(u){u.name!=="AbortError"&&n?.()}}),r.play().catch(n)}async _playBuffered(e,t,n){try{const s=await e.blob(),r=URL.createObjectURL(s);this._mediaSourceURL=r;const a=new Audio(r);this._audio=a,a.addEventListener("playing",t,{once:!0}),a.addEventListener("ended",()=>this._onEnd?.(),{once:!0}),a.addEventListener("error",()=>n?.(),{once:!0}),await a.play()}catch(s){s.name!=="AbortError"&&n?.()}}_cleanupAudio(){if(this._audio){try{this._audio.pause()}catch{}this._audio.src="",this._audio=null}if(this._mediaSourceURL){try{URL.revokeObjectURL(this._mediaSourceURL)}catch{}this._mediaSourceURL=null}this._startedFired=!1}}function ZB(i={}){const e=i.provider||"browser";if(e==="none")return null;if(e==="browser")return new XB(i);if(e==="elevenlabs")return new JB(i);throw new Error(`TTS provider "${e}" not implemented yet`)}function $B(i={}){const e=i.provider||"browser";if(e==="none")return null;if(e==="browser")return new YB(i);throw new Error(`STT provider "${e}" not implemented yet`)}const Ym=[{name:"wave",description:"Wave at the user. Use for greetings, farewells, or acknowledgments.",input_schema:{type:"object",properties:{duration_ms:{type:"integer",minimum:500,maximum:5e3,default:1500}}}},{name:"lookAt",description:"Direct the agent's gaze toward a target.",input_schema:{type:"object",properties:{target:{type:"string",enum:["user","camera","center"],description:"Where to look"}},required:["target"]}},{name:"play_clip",description:"Play a named animation clip from the loaded body.",input_schema:{type:"object",properties:{name:{type:"string"},loop:{type:"boolean",default:!1},fade_ms:{type:"integer",default:200}},required:["name"]}},{name:"setExpression",description:"Set facial expression via morph target preset.",input_schema:{type:"object",properties:{preset:{type:"string",enum:["neutral","happy","sad","surprised","confused","focused"]},intensity:{type:"number",minimum:0,maximum:1,default:1}},required:["preset"]}},{name:"speak",description:"Say something out loud via TTS. Use this instead of plain text when voice is on.",input_schema:{type:"object",properties:{text:{type:"string"}},required:["text"]}},{name:"remember",description:"Save a durable memory about the user, a feedback rule, a project fact, or a reference.",input_schema:{type:"object",properties:{key:{type:"string",description:'short snake_case filename, e.g. "user_role"'},name:{type:"string"},description:{type:"string"},type:{type:"string",enum:["user","feedback","project","reference"]},body:{type:"string"}},required:["key","name","description","type","body"]}}],eT=[{name:"observe_agents",description:"List the other agents currently sharing this stage, with their names and positions.",input_schema:{type:"object",properties:{}}},{name:"say_to_agent",description:"Send a message to another agent on the same stage. The target agent will receive it as a user turn and reply in their own chat chrome.",input_schema:{type:"object",properties:{agentId:{type:"string",description:"Target agent id as returned by observe_agents."},text:{type:"string"}},required:["agentId","text"]}}],tT={async wave(i,e){const t=i.duration_ms||1500;return await e.viewer.playAnimationByHint?.("wave",{duration:t}),e.memory.note("waved",{duration_ms:t}),{ok:!0}},async lookAt(i,e){const t=i.target||"user";return e.viewer.lookAt?.(t),{ok:!0,target:t}},async play_clip(i,e){const{name:t,loop:n=!1,fade_ms:s=200}=i,r=e.viewer.resolveAnimationSlot?.(t)??t;return e.viewer.playClipByName?.(r,{loop:n,fade_ms:s})?{ok:!0,name:t,resolved:r}:(r!==t&&console.warn(`[play_clip] slot "${t}" → "${r}" not found in library`),{ok:!1,error:`No clip named "${r}"`})},async setExpression(i,e){const{preset:t,intensity:n=1}=i;return e.viewer.setExpression?.(t,n),{ok:!0,preset:t}},async speak(i,e){return await e.speak(i.text),{ok:!0}},async remember(i,e){const{key:t,name:n,description:s,type:r,body:a}=i;return e.memory.write(t,{name:n,description:s,type:r,body:a}),{ok:!0,saved:t}},async observe_agents(i,e){return e.stage?{ok:!0,agents:e.stage.getAgents().filter(n=>n.agentId!==e.agentId).map(({agentId:n,name:s,position:r})=>({agentId:n,name:s,position:r}))}:{ok:!1,error:"not on a stage"}},async say_to_agent(i,e){if(!e.stage)return{ok:!1,error:"not on a stage"};const{agentId:t,text:n}=i;if(!t||!n)return{ok:!1,error:"agentId and text required"};const s=e.agentId||"anon";return e.stage.broadcast(s,{kind:"direct",to:t,text:n}),e.stage.routeMessage(s,t,n)}},nT=8;class Jm extends EventTarget{constructor({manifest:e,viewer:t,memory:n,skills:s,providerConfig:r={},voiceConfig:a={},stage:o=null,agentId:c=null}={}){super(),this.manifest=e||{},this.viewer=t,this.memory=n,this.skills=s,this.stage=o,this.agentId=c,this.provider=jB({...this.manifest.brain,...r}),this.tts=ZB({...this.manifest.voice?.tts,...a.tts}),this.stt=$B({...this.manifest.voice?.stt,...a.stt}),this.messages=[],this._busy=!1}get systemPrompt(){const e=[];return this.manifest.instructions&&e.push(this.manifest.instructions),this.memory&&e.push(`++<memory>+`+this.memory.contextBlock({maxTokens:this.manifest.memory?.maxTokens||8192})+`+</memory>`),this.skills&&e.push(this.skills.systemPrompt()),e.join("")}get tools(){const e=new Set(this.manifest.tools||Ym.map(r=>r.name)),t=Ym.filter(r=>e.has(r.name)),n=this.skills?this.skills.allTools():[],s=this.stage?eT:[];return[...t,...s,...n]}async send(e,{voice:t=!1}={}){if(this._busy)throw new Error("Runtime busy — wait for current turn to finish");this._busy=!0;try{this.memory?.note("user_said",{text:e}),this.messages.push({role:"user",content:e}),this.dispatchEvent(new CustomEvent("brain:message",{detail:{role:"user",content:e}}));const n=await this._loop();return t&&n.text&&this.tts&&(this.dispatchEvent(new CustomEvent("voice:speech-start",{detail:{text:n.text}})),await this.tts.speak(n.text),this.dispatchEvent(new CustomEvent("voice:speech-end",{}))),n}finally{this._busy=!1}}async _loop(){let e=0,t="";for(;e++<nT;){const n=await this.provider.complete({system:this.systemPrompt,messages:this.messages,tools:this.tools});if(n.thinking&&this.dispatchEvent(new CustomEvent("brain:thinking",{detail:{content:n.thinking}})),!n.toolCalls.length){t=n.text,this.messages.push({role:"assistant",content:n.text}),this.dispatchEvent(new CustomEvent("brain:message",{detail:{role:"assistant",content:n.text}}));break}this.messages.push(this.provider.formatAssistantWithToolCalls(n.text,n.toolCalls)),n.text&&this.dispatchEvent(new CustomEvent("brain:message",{detail:{role:"assistant",content:n.text}}));const s=[];for(const r of n.toolCalls){let a,o=!1;try{a=await this._dispatchTool(r)}catch(c){a={error:c.message||String(c)},o=!0}this.dispatchEvent(new CustomEvent("skill:tool-called",{detail:{tool:r.name,args:r.input,result:a}})),s.push({id:r.id,output:a,isError:o})}this.messages.push(this.provider.formatToolResults(s))}return{text:t}}async _dispatchTool(e){const t=this._context(),n=this.skills?.findSkillForTool(e.name);if(n)return n.invoke(e.name,e.input,t);const s=tT[e.name];if(!s)throw new Error(`Unknown tool: ${e.name}`);return s(e.input,t)}_context(){return this.skills,{viewer:this.viewer,memory:this.memory,llm:{complete:(e,t)=>this.provider.complete({system:t?.system||"",messages:[{role:"user",content:e}],tools:t?.tools})},speak:async e=>{this.tts&&(this.dispatchEvent(new CustomEvent("voice:speech-start",{detail:{text:e}})),await this.tts.speak(e),this.dispatchEvent(new CustomEvent("voice:speech-end",{})))},listen:e=>this.stt?.listen(e),fetch:(e,t)=>fetch(e,t),loadGLB:async e=>this.viewer.loadGLB?.(e),loadClip:async e=>this.viewer.loadClip?.(e),loadJSON:async e=>(await fetch(e)).json(),call:async(e,t)=>this._dispatchTool({name:e,input:t}),stage:this.stage,agentId:this.agentId}}async listen({onInterim:e,onFinal:t}={}){if(!this.stt)throw new Error("STT not configured");return this.dispatchEvent(new CustomEvent("voice:listen-start",{})),await this.stt.listen({onInterim:s=>{this.dispatchEvent(new CustomEvent("voice:transcript",{detail:{text:s,final:!1}})),e?.(s)},onFinal:s=>{this.dispatchEvent(new CustomEvent("voice:transcript",{detail:{text:s,final:!0}})),t?.(s)}})}clearConversation(){this.messages=[]}pause(){this.tts?.cancel(),this.stt?.stop()}destroy(){this.pause(),this.messages=[]}}const Wd=["https://dweb.link/ipfs/","https://cloudflare-ipfs.com/ipfs/","https://ipfs.io/ipfs/"],iT="https://arweave.net/";function ns(i,e=0){if(!i)return i;const t=i.match(/^ipfs:\/\/(.+)$/i);if(t)return Wd[e%Wd.length]+t[1];const n=i.match(/^ar:\/\/(.+)$/i);return n?iT+n[1]:i}async function Zm(i){let e;for(let t=0;t<Wd.length;t++){const n=ns(i,t);try{const s=await fetch(n);if(s.ok)return s}catch(s){e=s}}throw e||new Error("All IPFS gateways failed for "+i)}const sT={idle:"idle",wave:"reaction",nod:"reaction",shake:"angry",think:"pray",celebrate:"celebrate",concern:"defeated",bow:"sitclap",point:"reaction",shrug:"defeated"};function rT(i,e){return e&&e[i]?e[i]:sT[i]??i}const $m={neutral:{},happy:{mouthSmile:1,browInnerUp:.3,cheekSquintL:.4,cheekSquintR:.4},sad:{mouthFrownL:.8,mouthFrownR:.8,browDownL:.6,browDownR:.6},surprised:{jawOpen:.5,eyeWideL:.8,eyeWideR:.8,browInnerUp:.9},confused:{browInnerUp:.5,browOuterUpL:.4,mouthPressL:.3,mouthPressR:.3},focused:{browDownL:.4,browDownR:.4,eyeSquintL:.3,eyeSquintR:.3}};class e0{constructor(e){this.viewer=e,this._loader=new wg,this._userTarget=new H(0,1.6,2),this._animationMap={},this._group=null,this._groupMixer=null,this._groupClips=null,this._mixerHook=null}get scene(){return this.viewer.scene}get mixer(){return this._groupMixer||this.viewer.mixer}get clips(){return this._groupClips||this.viewer.clips||[]}get content(){return this._group||this.viewer.content}setGroup(e,{mixer:t=null,clips:n=null}={}){this._group=e,this._groupMixer=t,this._groupClips=n,t&&(this._mixerHook=s=>{t.update(s),this.viewer._animating=!0,this.viewer.invalidate()},this._addHook(this._mixerHook))}dispose(){if(this._mixerHook&&this._removeHook(this._mixerHook),this._groupMixer){try{this._groupMixer.stopAllAction()}catch{}try{this._groupMixer.uncacheRoot(this._group)}catch{}}this._mixerHook=null,this._groupMixer=null,this._groupClips=null,this._group=null}setAnimationMap(e){this._animationMap=e||{}}resolveAnimationSlot(e){return rT(e,this._animationMap)}async load(e,t="",n=new Map){return this.viewer.load(e,t,n)}playClipByName(e,{loop:t=!1,fade_ms:n=200}={}){const s=this._findClip(e),r=this.mixer;if(s&&r){const o=r.clipAction(s);return o.reset(),o.setLoop(t?2201:2200),o.clampWhenFinished=!t,o.fadeIn(n/1e3),o.play(),this._group||(this.viewer.state.actionStates[s.name]=!0),this.viewer._animating=!0,this.viewer.invalidate(),!0}const a=this.viewer?.animationManager;return!a||a.isFailed(e)?!1:(t?a.crossfadeTo(e,n/1e3):a.play(e),!0)}playAnimationByHint(e,t){const n=e.toLowerCase(),s=this.clips.find(a=>a.name.toLowerCase().includes(n));if(s)return this.playClipByName(s.name,t);const r=this.viewer?.animationManager;if(r){for(const a of r.clips.keys())if(a.toLowerCase().includes(n))return this.playClipByName(a,t)}return!1}stopClip(e){const t=this.mixer;if(!t)return;const n=e?this._findClip(e):null;if(n){const s=t.existingAction(n);s&&s.fadeOut(.2),this._group||(this.viewer.state.actionStates[n.name]=!1)}else if(t.stopAllAction(),!this._group)for(const s in this.viewer.state.actionStates)this.viewer.state.actionStates[s]=!1;this.viewer.invalidate()}async play(e,t){if(typeof e=="string")return this.playClipByName(e,t);const n=this.mixer;if(!n||!e)return!1;const s=n.clipAction(e);return s.reset(),s.fadeIn(t?.blend??.2),s.play(),this.viewer._animating=!0,this.viewer.invalidate(),!0}async loadClip(e){const t=ns(e);return new Promise((n,s)=>{this._loader.load(t,r=>n(r.animations?.[0]||null),void 0,s)})}async loadGLB(e){const t=ns(e);return new Promise((n,s)=>{this._loader.load(t,n,void 0,s)})}lookAt(e){const t=this._resolveTarget(e);if(!t){e!=null&&console.warn(`[SceneController] unknown lookAt target: "${e}"`);return}if(!this.viewer.content)return;const n=this._findBone(["Head","head","mixamorigHead"]);n?n.lookAt(t):this.viewer.content.lookAt(t.x,this.viewer.content.position.y,t.z),this.viewer.invalidate()}_resolveTarget(e){return e instanceof H?e:e==="camera"?this.viewer.activeCamera.position.clone():e==="center"?new H(0,1,0):e==="user"?this.viewer.renderer?.xr?.isPresenting?this.viewer.renderer.xr.getCamera().position.clone():this._userTarget.clone():null}_findBone(e){if(!this.viewer.content)return null;(!this._boneCache||this._boneCacheContent!==this.viewer.content)&&(this._boneCache=new Map,this._boneCacheContent=this.viewer.content);const t=e.join(",");if(this._boneCache.has(t))return this._boneCache.get(t);let n=null;return this.viewer.content.traverse(s=>{n||s.isBone&&e.includes(s.name)&&(n=s)}),this._boneCache.set(t,n),n}setExpression(e,t=1){const n=$m[e]||$m.neutral;this.viewer.content&&(this.viewer.content.traverse(s=>{if(!(!s.morphTargetDictionary||!s.morphTargetInfluences)){for(let r=0;r<s.morphTargetInfluences.length;r++)s.morphTargetInfluences[r]=0;for(const[r,a]of Object.entries(n)){const o=s.morphTargetDictionary[r];o!==void 0&&(s.morphTargetInfluences[o]=a*t)}}}),this.viewer.invalidate())}moveTo(e,{duration:t=600}={}){if(!this.viewer.content)return;this._moveToHook&&(this._removeHook(this._moveToHook),this._moveToHook=null);const n=this.viewer.content.position.clone(),s=new H(e.x||0,e.y||n.y,e.z||0),r=performance.now(),a=o=>{const c=performance.now()-r,l=Math.min(c/t,1),h=l<.5?2*l*l:1-Math.pow(-2*l+2,2)/2;this.viewer.content.position.lerpVectors(n,s,h),this.viewer.invalidate(),l>=1&&(this._removeHook(a),this._moveToHook=null)};this._moveToHook=a,this._addHook(a)}_addHook(e){this.viewer._afterAnimateHooks||(this.viewer._afterAnimateHooks=[]),this.viewer._afterAnimateHooks.push(e),this.viewer._animating=!0,this.viewer.invalidate()}_removeHook(e){const t=this.viewer._afterAnimateHooks;if(!t)return;const n=t.indexOf(e);n>=0&&t.splice(n,1)}_findClip(e){if(!this.clips.length)return null;const t=this.clips.find(s=>s.name===e);if(t)return t;const n=e.toLowerCase();return this.clips.find(s=>s.name.toLowerCase()===n)||this.clips.find(s=>s.name.toLowerCase().includes(n))}}const aT=`// Sandbox worker — executes skill handlers in an isolated Web Worker scope.+// No DOM, no window, no document. Only ctx.* and native worker APIs.++/** @type {Map<string, object>} skillURI → module exports */+const _skillHandlers = new Map();++/** @type {Map<number, { resolve: Function, reject: Function, timeoutId: number }>} */+const _pendingRequests = new Map();++/** @type {Map<string, Promise<void>>} skillURI → install promise (deduplication) */+const _installPromises = new Map();++/** @type {Map<string, { resolve: Function, reject: Function }>} */+const _installCallbacks = new Map();++let _requestId = 0;++self.onmessage = ({ data }) => {+ switch (data.type) {+ case 'install':+ _install(data);+ break;+ case 'invoke':+ _invoke(data);+ break;+ case 'response':+ _handleResponse(data);+ break;+ }+};++async function _install({ skillURI, handlersSrc }) {+ // Deduplicate concurrent install requests for the same skill+ if (_installPromises.has(skillURI)) return;++ const promise = new Promise((resolve, reject) => {+ _installCallbacks.set(skillURI, { resolve, reject });+ });+ _installPromises.set(skillURI, promise);++ let url;+ try {+ const blob = new Blob([handlersSrc], { type: 'text/javascript' });+ url = URL.createObjectURL(blob);+ // Dynamic import from blob URL — works in module workers+ const mod = await import(/* @vite-ignore */ url);+ _skillHandlers.set(skillURI, mod);+ _installCallbacks.get(skillURI)?.resolve();+ self.postMessage({ type: 'install-ack', skillURI, ok: true });+ } catch (err) {+ _installPromises.delete(skillURI);+ _installCallbacks.get(skillURI)?.reject(err);+ _installCallbacks.delete(skillURI);+ self.postMessage({ type: 'install-ack', skillURI, ok: false, error: err.message });+ } finally {+ if (url) URL.revokeObjectURL(url);+ }+}++function _makeCtx(invocationId, skillBaseURI) {+ // Each method sends a request to main thread and awaits a structured-cloneable response.+ // Non-serializable objects (AnimationClip, GLTF) are stored in the host's handle registry+ // and represented here as opaque "@h:N" strings.+ const proxy = (method, args) =>+ new Promise((resolve, reject) => {+ const id = ++_requestId;+ const timeoutId = setTimeout(() => {+ _pendingRequests.delete(id);+ reject(new Error(\`ctx.\${method} timed out after 30s\`));+ }, 30_000);+ _pendingRequests.set(id, { resolve, reject, timeoutId });+ self.postMessage({ type: 'request', invocationId, requestId: id, method, args });+ });++ return {+ viewer: {+ play: (clip, opts) => proxy('viewer.play', [clip, opts]),+ stop: (clipName) => proxy('viewer.stop', [clipName]),+ setExpression: (preset, intensity) =>+ proxy('viewer.setExpression', [preset, intensity]),+ lookAt: (target) => proxy('viewer.lookAt', [target]),+ moveTo: (position, opts) => proxy('viewer.moveTo', [position, opts]),+ playAnimationByHint: (hint, opts) => proxy('viewer.playAnimationByHint', [hint, opts]),+ playClipByName: (name, opts) => proxy('viewer.playClipByName', [name, opts]),+ },+ llm: {+ complete: (prompt, opts) => proxy('llm.complete', [prompt, opts]),+ embed: (text) => proxy('llm.embed', [text]),+ },+ memory: {+ read: (key) => proxy('memory.read', [key]),+ write: (key, value) => proxy('memory.write', [key, value]),+ note: (type, data) => proxy('memory.note', [type, data]),+ recall: (query) => proxy('memory.recall', [query]),+ },+ // Asset loading — results are opaque handle strings; pass back to viewer.play etc.+ loadClip: (uri) => proxy('loadClip', [uri]),+ loadGLB: (uri) => proxy('loadGLB', [uri]),+ // fetch and loadJSON use native worker fetch — no proxy needed+ fetch: (uri, opts) => fetch(uri, opts),+ loadJSON: async (uri) => (await fetch(uri)).json(),+ call: (toolName, toolArgs) => proxy('call', [toolName, toolArgs]),+ speak: (text) => proxy('speak', [text]),+ listen: (opts) => proxy('listen', [opts]),+ skillBaseURI,+ };+}++async function _invoke({ invocationId, skillURI, toolName, args, skillBaseURI }) {+ // Wait for install to complete (handles the install→invoke race)+ const installPromise = _installPromises.get(skillURI);+ if (installPromise) {+ try {+ await installPromise;+ } catch (err) {+ self.postMessage({+ type: 'invoke-result',+ invocationId,+ error: \`Install failed: \${err.message}\`,+ });+ return;+ }+ }++ const mod = _skillHandlers.get(skillURI);+ if (!mod) {+ self.postMessage({+ type: 'invoke-result',+ invocationId,+ error: \`Skill not installed: \${skillURI}\`,+ });+ return;+ }++ const fn = mod[toolName];+ if (typeof fn !== 'function') {+ self.postMessage({+ type: 'invoke-result',+ invocationId,+ error: \`No handler "\${toolName}" in skill "\${skillURI}"\`,+ });+ return;+ }++ try {+ const ctx = _makeCtx(invocationId, skillBaseURI);+ const result = await fn(args, ctx);+ self.postMessage({ type: 'invoke-result', invocationId, result: result ?? null });+ } catch (err) {+ self.postMessage({+ type: 'invoke-result',+ invocationId,+ error: err.message || String(err),+ });+ }+}++function _handleResponse({ requestId, result, error }) {+ const pending = _pendingRequests.get(requestId);+ if (!pending) return;+ clearTimeout(pending.timeoutId);+ _pendingRequests.delete(requestId);+ if (error !== undefined) {+ pending.reject(new Error(error));+ } else {+ pending.resolve(result);+ }+}+`;let ii=null,Ca=null;const Sa=new Map,Lo=new Map,Us=new Map,Nl=new Map;let oT=0,cT=0;function t0(i){if(i==null)return null;const e=`@h:${++oT}`;return Nl.set(e,i),e}function lT(i){return typeof i=="string"&&i.startsWith("@h:")?Nl.get(i)??i:i}function hT(i){return Array.isArray(i)?i.map(lT):i}function n0(){if(!ii){if(!Ca){const i=new Blob([aT],{type:"text/javascript"});Ca=URL.createObjectURL(i)}ii=new Worker(Ca),ii.onmessage=dT,ii.onerror=uT}return ii}function uT(i){console.error("[sandbox] worker crashed:",i),ii=null,Sa.clear(),Lo.clear(),Nl.clear();for(const[,e]of Us)e.reject(new Error("Sandbox worker crashed"));Us.clear()}function dT({data:i}){switch(i.type){case"install-ack":{const e=Lo.get(i.skillURI);Lo.delete(i.skillURI),i.ok?e?.resolve():(Sa.delete(i.skillURI),e?.reject(new Error(i.error||"Install failed")));break}case"request":{const{invocationId:e,requestId:t,method:n,args:s}=i,r=Us.get(e);if(!r){ii?.postMessage({type:"response",requestId:t,error:"No active invocation"});return}fT(n,s,r.mainCtx).then(a=>ii?.postMessage({type:"response",requestId:t,result:a??null}),a=>ii?.postMessage({type:"response",requestId:t,error:a.message||String(a)}));break}case"invoke-result":{const{invocationId:e,result:t,error:n}=i,s=Us.get(e);if(!s)return;Us.delete(e),n!==void 0?s.reject(new Error(n)):s.resolve(t);break}}}async function fT(i,e,t){const n=hT(e);switch(i){case"viewer.play":return t.viewer?.play?.(n[0],n[1]);case"viewer.stop":return t.viewer?.stop?.(n[0]);case"viewer.setExpression":return t.viewer?.setExpression?.(n[0],n[1]);case"viewer.lookAt":return t.viewer?.lookAt?.(n[0]);case"viewer.moveTo":return t.viewer?.moveTo?.(n[0],n[1]);case"viewer.playAnimationByHint":return t.viewer?.playAnimationByHint?.(n[0],n[1]);case"viewer.playClipByName":return t.viewer?.playClipByName?.(n[0],n[1]);case"memory.read":return t.memory?.read?.(n[0]);case"memory.write":return t.memory?.write?.(n[0],n[1]);case"memory.note":return t.memory?.note?.(n[0],n[1]);case"memory.recall":return t.memory?.recall?.(n[0]);case"llm.complete":return t.llm?.complete?.(n[0],n[1]);case"llm.embed":return t.llm?.embed?.(n[0]);case"loadClip":{const s=await t.loadClip?.(n[0]);return t0(s)}case"loadGLB":{const s=await t.loadGLB?.(n[0]);return t0(s)}case"speak":return t.speak?.(n[0]);case"listen":return t.listen?.(n[0]);case"call":return t.call?.(n[0],n[1]);default:throw new Error(`Unknown ctx method: ${i}`)}}async function pT(i,e){if(Sa.has(i))return Sa.get(i);const t=new Promise((n,s)=>{Lo.set(i,{resolve:n,reject:s})});return Sa.set(i,t),n0().postMessage({type:"install",skillURI:i,handlersSrc:e}),t}async function AT(i,e,t,n,s){await pT(i,n);const r=++cT,a=n0();return new Promise((o,c)=>{Us.set(r,{resolve:o,reject:c,mainCtx:s}),a.postMessage({type:"invoke",invocationId:r,skillURI:i,toolName:e,args:t,skillBaseURI:s.skillBaseURI||i})})}function gT(){if(ii){ii.terminate(),ii=null,Ca&&(URL.revokeObjectURL(Ca),Ca=null),Sa.clear(),Lo.clear(),Nl.clear();for(const[,i]of Us)i.reject(new Error("Sandbox terminated"));Us.clear()}}function mT(){return{invoke:AT,terminate:gT}}function bT(i,e){return/^([a-z]+:|\/)/i.test(e)?e:(i.endsWith("/")||(i+="/"),i+e)}class i0{constructor({uri:e,manifest:t,instructions:n,tools:s,handlers:r,handlersSrc:a}){this.uri=e,this.manifest=t,this.name=t.name,this.version=t.version,this.instructions=n,this.tools=s||[],this.handlers=r||{},this.handlersSrc=a||null}async invoke(e,t,n){const s={...n,skillBaseURI:this.uri};if(this.manifest.sandboxPolicy==="trusted-main-thread"){const r=this.handlers[e];if(!r)throw new Error(`Skill "${this.name}" has no handler for tool "${e}"`);return r(t,s)}if(!this.handlersSrc)throw new Error(`Skill "${this.name}" has no handler source for tool "${e}"`);return mT().invoke(this.uri,e,t,this.handlersSrc,s)}systemPromptFragment(){return this.instructions?`++<skill name="${this.name}" version="${this.version}">+${this.instructions}+</skill>`:""}}class s0{constructor({fetchFn:e=fetch.bind(globalThis),trust:t="owned-only",ownerAddress:n}={}){this.fetchFn=e,this.trust=t,this.ownerAddress=n?.toLowerCase(),this.skills=new Map}async install(e,{bundleBase:t}={}){const n=this._resolveBundleURI(e.uri,t);if(this.skills.has(n))return this.skills.get(n);const s=await this._fetchJSON(`${n}manifest.json`);this._enforceTrust(s);const r=s.sandboxPolicy==="trusted-main-thread",[a,o,c]=await Promise.all([this._fetchText(`${n}SKILL.md`).catch(()=>""),this._fetchJSON(`${n}tools.json`).catch(()=>({tools:[]})),r?this._fetchHandlers(`${n}handlers.js`).catch(()=>null):this._fetchHandlersSrc(`${n}handlers.js`).catch(()=>null)]),l=new i0({uri:n,manifest:s,instructions:a,tools:o.tools||[],handlers:r?c||{}:{},handlersSrc:r?null:c});if(s.dependencies)for(const[h,u]of Object.entries(s.dependencies))await this.install({uri:h,version:u});return this.skills.set(n,l),l}uninstall(e){for(const[t,n]of this.skills)if(n.name===e)return this.skills.delete(t),!0;return!1}all(){return Array.from(this.skills.values())}allTools(){const e=new Map;for(const t of this.skills.values())for(const n of t.tools)e.has(n.name)&&console.warn(`[skills] tool "${n.name}" overridden by skill "${t.name}"`),e.set(n.name,{...n,_skill:t.name});return Array.from(e.values())}findSkillForTool(e){for(const t of this.skills.values())if(t.tools.some(n=>n.name===e))return t;return null}systemPrompt(){return this.all().map(e=>e.systemPromptFragment()).join("")}_resolveBundleURI(e,t){let n=e;return!/^([a-z]+:|\/)/i.test(e)&&t&&(n=bT(t,e)),n.endsWith("/")||(n+="/"),(n.startsWith("ipfs://")||n.startsWith("ar://"))&&(n=ns(n)),n}async _fetchJSON(e){const t=await this.fetchFn(e);if(!t.ok)throw new Error(`Fetch failed: ${e} (${t.status})`);return t.json()}async _fetchText(e){const t=await this.fetchFn(e);if(!t.ok)throw new Error(`Fetch failed: ${e} (${t.status})`);return t.text()}async _fetchHandlers(e){try{return await import(e)}catch(t){return console.warn(`[skills] handlers load failed: ${e}`,t),null}}async _fetchHandlersSrc(e){const t=await this.fetchFn(e);if(!t.ok)throw new Error(`Fetch failed: ${e} (${t.status})`);return t.text()}_enforceTrust(e){if(this.trust!=="any"){if(this.trust==="owned-only"){const t=(e.author||"").toLowerCase();if(t&&this.ownerAddress&&t!==this.ownerAddress)throw new Error(`Skill "${e.name}" author ${t} not trusted under owned-only policy`)}this.trust}}}const xT=/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/;function Fl(i){const e=i.match(xT);if(!e)return{meta:{},body:i};const t={};for(const n of e[1].split(`+`)){const[s,...r]=n.split(":");s&&(t[s.trim()]=r.join(":").trim())}return{meta:t,body:e[2]}}function _T(i,e){const t=["---"];for(const[n,s]of Object.entries(i))t.push(`${n}: ${s}`);return t.push("---","",e),t.join(`+`)}class yi{constructor({mode:e="local",namespace:t,index:n={},files:s={},timeline:r=[]}={}){this.mode=e,this.namespace=t,this.files=new Map(Object.entries(s)),this.timeline=r,this.indexText=n.text||"",this._dirty=!1}static async load({mode:e="local",namespace:t,manifestURI:n,fetchFn:s}){if(e==="none")return new yi({mode:"none",namespace:t});if(e==="local")return yi._loadLocal(t);if(e==="ipfs"||e==="encrypted-ipfs")return yi._loadIPFS({mode:e,namespace:t,manifestURI:n,fetchFn:s});throw new Error(`Unknown memory mode: ${e}`)}static _loadLocal(e){const t=`agent:${e}:memory`;try{const n=localStorage.getItem(t);if(!n)return new yi({mode:"local",namespace:e});const s=JSON.parse(n);return new yi({mode:"local",namespace:e,...s})}catch{return new yi({mode:"local",namespace:e})}}static async _loadIPFS({mode:e,namespace:t,manifestURI:n,fetchFn:s}){const r=n.replace(/manifest\.json$/,"");try{const a=await s(`${r}memory/MEMORY.md`),o=a.ok?await a.text():"",c={},l=/\[([^\]]+)\]\(([^)]+\.md)\)/g;let h;for(;h=l.exec(o);){const u=h[2];try{const d=await s(`${r}memory/${u}`);d.ok&&(c[u]=await d.text())}catch{}}return new yi({mode:e,namespace:t,index:{text:o},files:c})}catch{return new yi({mode:e,namespace:t})}}read(e){const t=e.endsWith(".md")?e:`${e}.md`,n=this.files.get(t);return n?Fl(n):null}write(e,{name:t,description:n,type:s,body:r,decay:a}){const o=e.endsWith(".md")?e:`${e}.md`,c=new Date().toISOString().slice(0,10),l=this.files.get(o),h=l&&Fl(l).meta.created||c,u={name:t,description:n,type:s,created:h,updated:c};a&&(u.decay=a),this.files.set(o,_T(u,r||"")),this._rebuildIndex(),this._dirty=!0,this._persist()}note(e,t){const n={ts:new Date().toISOString(),type:e,...t};this.timeline.push(n),this.timeline.length>1e3&&(this.timeline=this.timeline.slice(-1e3)),this._dirty=!0,this._persist()}async recall(e,{limit:t=5}={}){const n=e.toLowerCase(),s=[];for(const[r,a]of this.files){const{meta:o,body:c}=Fl(a),l=`${o.name||""} ${o.description||""} ${c}`.toLowerCase();l.includes(n)&&s.push({file:r,meta:o,body:c,score:l.split(n).length-1})}return s.sort((r,a)=>a.score-r.score).slice(0,t)}_rebuildIndex(){const e={user:[],feedback:[],project:[],reference:[]};for(const[s,r]of this.files){const{meta:a}=Fl(r),o=a.type||"user";e[o]||(e[o]=[]),e[o].push({file:s,name:a.name||s,description:a.description||""})}const t=["# Memory",""],n={user:"## User",feedback:"## Feedback",project:"## Project",reference:"## Reference"};for(const[s,r]of Object.entries(e))if(r.length){t.push(n[s]||`## ${s}`);for(const a of r)t.push(`- [${a.name}](${a.file}) — ${a.description}`);t.push("")}this.indexText=t.join(`+`)}_persist(){if(this.mode!=="local"||!this.namespace)return;const e=`agent:${this.namespace}:memory`,t={index:{text:this.indexText},files:Object.fromEntries(this.files),timeline:this.timeline.slice(-200)};try{localStorage.setItem(e,JSON.stringify(t))}catch(n){console.warn("[memory] persist failed",n)}}contextBlock({maxTokens:e=8192}={}){const t=e*4,n=["# Agent Memory","",this.indexText];let s=n.join(`+`).length;for(const[r,a]of this.files){if(s+a.length>t)break;n.push("",`## ${r}`,a),s+=a.length}if(this.timeline.length){const a=this.timeline.slice(-20).map(o=>JSON.stringify(o)).join(`+`);s+a.length<t&&n.push("","## Recent timeline","```",a,"```")}return n.join(`+`)}async export(){return{version:"memory/0.1",index:this.indexText,files:Object.fromEntries(this.files),timeline:this.timeline}}async import(e,{strategy:t="merge"}={}){if(t==="replace")this.files=new Map(Object.entries(e.files||{})),this.timeline=e.timeline||[];else{for(const[n,s]of Object.entries(e.files||{}))this.files.has(n)||this.files.set(n,s);this.timeline=[...this.timeline,...e.timeline||[]].slice(-1e3)}this._rebuildIndex(),this._persist()}}const ET="6.16.0";function yT(i,e,t){const n=e.split("|").map(r=>r.trim());for(let r=0;r<n.length;r++)switch(e){case"any":return;case"bigint":case"boolean":case"number":case"string":if(typeof i===e)return}const s=new Error(`invalid value for type ${e}`);throw s.code="INVALID_ARGUMENT",s.argument=`value.${t}`,s.value=i,s}async function Fn(i){const e=Object.keys(i);return(await Promise.all(e.map(n=>Promise.resolve(i[n])))).reduce((n,s,r)=>(n[e[r]]=s,n),{})}function Xe(i,e,t){for(let n in e){let s=e[n];const r=t?t[n]:null;r&&yT(s,r,n),Object.defineProperty(i,n,{enumerable:!0,value:s,writable:!1})}}function Ia(i,e){if(i==null)return"null";if(e==null&&(e=new Set),typeof i=="object"){if(e.has(i))return"[Circular]";e.add(i)}if(Array.isArray(i))return"[ "+i.map(t=>Ia(t,e)).join(", ")+" ]";if(i instanceof Uint8Array){const t="0123456789abcdef";let n="0x";for(let s=0;s<i.length;s++)n+=t[i[s]>>4],n+=t[i[s]&15];return n}if(typeof i=="object"&&typeof i.toJSON=="function")return Ia(i.toJSON(),e);switch(typeof i){case"boolean":case"number":case"symbol":return i.toString();case"bigint":return BigInt(i).toString();case"string":return JSON.stringify(i);case"object":{const t=Object.keys(i);return t.sort(),"{ "+t.map(n=>`${Ia(n,e)}: ${Ia(i[n],e)}`).join(", ")+" }"}}return"[ COULD NOT SERIALIZE ]"}function En(i,e){return i&&i.code===e}function qd(i){return En(i,"CALL_EXCEPTION")}function Ut(i,e,t){let n=i;{const r=[];if(t){if("message"in t||"code"in t||"name"in t)throw new Error(`value will overwrite populated values: ${Ia(t)}`);for(const a in t){if(a==="shortMessage")continue;const o=t[a];r.push(a+"="+Ia(o))}}r.push(`code=${e}`),r.push(`version=${ET}`),r.length&&(i+=" ("+r.join(", ")+")")}let s;switch(e){case"INVALID_ARGUMENT":s=new TypeError(i);break;case"NUMERIC_FAULT":case"BUFFER_OVERRUN":s=new RangeError(i);break;default:s=new Error(i)}return Xe(s,{code:e}),t&&Object.assign(s,t),s.shortMessage==null&&Xe(s,{shortMessage:n}),s}function pe(i,e,t,n){if(!i)throw Ut(e,t,n)}function V(i,e,t,n){pe(i,e,"INVALID_ARGUMENT",{argument:t,value:n})}function r0(i,e,t){t==null&&(t=""),t&&(t=": "+t),pe(i>=e,"missing argument"+t,"MISSING_ARGUMENT",{count:i,expectedCount:e}),pe(i<=e,"too many arguments"+t,"UNEXPECTED_ARGUMENT",{count:i,expectedCount:e})}["NFD","NFC","NFKD","NFKC"].reduce((i,e)=>{try{if("test".normalize(e)!=="test")throw new Error("bad");if(e==="NFD"&&"é".normalize("NFD")!=="é")throw new Error("broken");i.push(e)}catch{}return i},[]);function Dl(i,e,t){if(t==null&&(t=""),i!==e){let n=t,s="new";t&&(n+=".",s+=" "+t),pe(!1,`private constructor; use ${n}from* methods`,"UNSUPPORTED_OPERATION",{operation:s})}}function a0(i,e,t){if(i instanceof Uint8Array)return t?new Uint8Array(i):i;if(typeof i=="string"&&i.length%2===0&&i.match(/^0x[0-9a-f]*$/i)){const n=new Uint8Array((i.length-2)/2);let s=2;for(let r=0;r<n.length;r++)n[r]=parseInt(i.substring(s,s+2),16),s+=2;return n}V(!1,"invalid BytesLike value",e||"value",i)}function lt(i,e){return a0(i,e,!1)}function Dn(i,e){return a0(i,e,!0)}function Ft(i,e){return!(typeof i!="string"||!i.match(/^0x[0-9A-Fa-f]*$/)||typeof e=="number"&&i.length!==2+2*e||e===!0&&i.length%2!==0)}function Kd(i){return Ft(i,!0)||i instanceof Uint8Array}const o0="0123456789abcdef";function Ce(i){const e=lt(i);let t="0x";for(let n=0;n<e.length;n++){const s=e[n];t+=o0[(s&240)>>4]+o0[s&15]}return t}function Ot(i){return"0x"+i.map(e=>Ce(e).substring(2)).join("")}function Ma(i){return Ft(i,!0)?(i.length-2)/2:lt(i).length}function Vt(i,e,t){const n=lt(i);return t!=null&&t>n.length&&pe(!1,"cannot slice beyond data bounds","BUFFER_OVERRUN",{buffer:n,length:n.length,offset:t}),Ce(n.slice(e??0,t??n.length))}function c0(i,e,t){const n=lt(i);pe(e>=n.length,"padding exceeds data length","BUFFER_OVERRUN",{buffer:new Uint8Array(n),length:e,offset:e+1});const s=new Uint8Array(e);return s.fill(0),t?s.set(n,e-n.length):s.set(n,0),Ce(s)}function is(i,e){return c0(i,e,!0)}function wT(i,e){return c0(i,e,!1)}const Po=BigInt(0),wi=BigInt(1),Ba=9007199254740991;function vT(i,e){const t=Ll(i,"value"),n=BigInt(ht(e,"width"));if(pe(t>>n===Po,"overflow","NUMERIC_FAULT",{operation:"fromTwos",fault:"overflow",value:i}),t>>n-wi){const s=(wi<<n)-wi;return-((~t&s)+wi)}return t}function l0(i,e){let t=Re(i,"value");const n=BigInt(ht(e,"width")),s=wi<<n-wi;if(t<Po){t=-t,pe(t<=s,"too low","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:i});const r=(wi<<n)-wi;return(~t&r)+wi}else pe(t<s,"too high","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:i});return t}function ko(i,e){const t=Ll(i,"value"),n=BigInt(ht(e,"bits"));return t&(wi<<n)-wi}function Re(i,e){switch(typeof i){case"bigint":return i;case"number":return V(Number.isInteger(i),"underflow",e||"value",i),V(i>=-Ba&&i<=Ba,"overflow",e||"value",i),BigInt(i);case"string":try{if(i==="")throw new Error("empty string");return i[0]==="-"&&i[1]!=="-"?-BigInt(i.substring(1)):BigInt(i)}catch(t){V(!1,`invalid BigNumberish string: ${t.message}`,e||"value",i)}}V(!1,"invalid BigNumberish value",e||"value",i)}function Ll(i,e){const t=Re(i,e);return pe(t>=Po,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:i}),t}const h0="0123456789abcdef";function jd(i){if(i instanceof Uint8Array){let e="0x0";for(const t of i)e+=h0[t>>4],e+=h0[t&15];return BigInt(e)}return Re(i)}function ht(i,e){switch(typeof i){case"bigint":return V(i>=-Ba&&i<=Ba,"overflow",e||"value",i),Number(i);case"number":return V(Number.isInteger(i),"underflow",e||"value",i),V(i>=-Ba&&i<=Ba,"overflow",e||"value",i),i;case"string":try{if(i==="")throw new Error("empty string");return ht(BigInt(i),e)}catch(t){V(!1,`invalid numeric string: ${t.message}`,e||"value",i)}}V(!1,"invalid numeric value",e||"value",i)}function CT(i){return ht(jd(i))}function Os(i,e){const t=Ll(i,"value");let n=t.toString(16);if(e==null)n.length%2&&(n="0"+n);else{const s=ht(e,"width");if(s===0&&t===Po)return"0x";for(pe(s*2>=n.length,`value exceeds width (${s} bytes)`,"NUMERIC_FAULT",{operation:"toBeHex",fault:"overflow",value:i});n.length<s*2;)n="0"+n}return"0x"+n}function Zt(i,e){const t=Ll(i,"value");if(t===Po)return new Uint8Array(0);let n=t.toString(16);n.length%2&&(n="0"+n);const s=new Uint8Array(n.length/2);for(let r=0;r<s.length;r++){const a=r*2;s[r]=parseInt(n.substring(a,a+2),16)}return s}function vi(i){let e=Ce(Kd(i)?i:Zt(i)).substring(2);for(;e.startsWith("0");)e=e.substring(1);return e===""&&(e="0"),"0x"+e}const u0="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";BigInt(0);const d0=BigInt(58);function ST(i){const e=lt(i);let t=jd(e),n="";for(;t;)n=u0[Number(t%d0)]+n,t/=d0;for(let s=0;s<e.length&&!e[s];s++)n=u0[0]+n;return n}function IT(i){i=atob(i);const e=new Uint8Array(i.length);for(let t=0;t<i.length;t++)e[t]=i.charCodeAt(t);return lt(e)}function MT(i){const e=lt(i);let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}class f0{filter;emitter;#e;constructor(e,t,n){this.#e=t,Xe(this,{emitter:e,filter:n})}async removeListener(){this.#e!=null&&await this.emitter.off(this.filter,this.#e)}}function BT(i,e,t,n,s){V(!1,`invalid codepoint at offset ${e}; ${i}`,"bytes",t)}function p0(i,e,t,n,s){if(i==="BAD_PREFIX"||i==="UNEXPECTED_CONTINUE"){let r=0;for(let a=e+1;a<t.length&&t[a]>>6===2;a++)r++;return r}return i==="OVERRUN"?t.length-e-1:0}function TT(i,e,t,n,s){return i==="OVERLONG"?(V(typeof s=="number","invalid bad code point for replacement","badCodepoint",s),n.push(s),0):(n.push(65533),p0(i,e,t))}const RT=Object.freeze({error:BT,ignore:p0,replace:TT});function NT(i,e){e==null&&(e=RT.error);const t=lt(i,"bytes"),n=[];let s=0;for(;s<t.length;){const r=t[s++];if(r>>7===0){n.push(r);continue}let a=null,o=null;if((r&224)===192)a=1,o=127;else if((r&240)===224)a=2,o=2047;else if((r&248)===240)a=3,o=65535;else{(r&192)===128?s+=e("UNEXPECTED_CONTINUE",s-1,t,n):s+=e("BAD_PREFIX",s-1,t,n);continue}if(s-1+a>=t.length){s+=e("OVERRUN",s-1,t,n);continue}let c=r&(1<<8-a-1)-1;for(let l=0;l<a;l++){let h=t[s];if((h&192)!=128){s+=e("MISSING_CONTINUE",s,t,n),c=null;break}c=c<<6|h&63,s++}if(c!==null){if(c>1114111){s+=e("OUT_OF_RANGE",s-1-a,t,n,c);continue}if(c>=55296&&c<=57343){s+=e("UTF16_SURROGATE",s-1-a,t,n,c);continue}if(c<=o){s+=e("OVERLONG",s-1-a,t,n,c);continue}n.push(c)}}return n}function ss(i,e){V(typeof i=="string","invalid string value","str",i);let t=[];for(let n=0;n<i.length;n++){const s=i.charCodeAt(n);if(s<128)t.push(s);else if(s<2048)t.push(s>>6|192),t.push(s&63|128);else if((s&64512)==55296){n++;const r=i.charCodeAt(n);V(n<i.length&&(r&64512)===56320,"invalid surrogate pair","str",i);const a=65536+((s&1023)<<10)+(r&1023);t.push(a>>18|240),t.push(a>>12&63|128),t.push(a>>6&63|128),t.push(a&63|128)}else t.push(s>>12|224),t.push(s>>6&63|128),t.push(s&63|128)}return new Uint8Array(t)}function FT(i){return i.map(e=>e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10&1023)+55296,(e&1023)+56320))).join("")}function Pl(i,e){return FT(NT(i,e))}function A0(i){async function e(t,n){pe(n==null||!n.cancelled,"request cancelled before sending","CANCELLED");const s=t.url.split(":")[0].toLowerCase();pe(s==="http"||s==="https",`unsupported protocol ${s}`,"UNSUPPORTED_OPERATION",{info:{protocol:s},operation:"request"}),pe(s==="https"||!t.credentials||t.allowInsecureAuthentication,"insecure authorized connections unsupported","UNSUPPORTED_OPERATION",{operation:"request"});let r=null;const a=new AbortController,o=setTimeout(()=>{r=Ut("request timeout","TIMEOUT"),a.abort()},t.timeout);n&&n.addListener(()=>{r=Ut("request cancelled","CANCELLED"),a.abort()});const c=Object.assign({},i,{method:t.method,headers:new Headers(Array.from(t)),body:t.body||void 0,signal:a.signal});let l;try{l=await fetch(t.url,c)}catch(f){throw clearTimeout(o),r||f}clearTimeout(o);const h={};l.headers.forEach((f,m)=>{h[m.toLowerCase()]=f});const u=await l.arrayBuffer(),d=u==null?null:new Uint8Array(u);return{statusCode:l.status,statusMessage:l.statusText,headers:h,body:d}}return e}const DT=12,LT=250;let g0=A0();const PT=new RegExp("^data:([^;:]*)?(;base64)?,(.*)$","i"),kT=new RegExp("^ipfs://(ipfs/)?(.*)$","i");let Xd=!1;async function m0(i,e){try{const t=i.match(PT);if(!t)throw new Error("invalid data");return new Qs(200,"OK",{"content-type":t[1]||"text/plain"},t[2]?IT(t[3]):OT(t[3]))}catch{return new Qs(599,"BAD REQUEST (invalid data: URI)",{},null,new ki(i))}}function b0(i){async function e(t,n){try{const s=t.match(kT);if(!s)throw new Error("invalid link");return new ki(`${i}${s[2]}`)}catch{return new Qs(599,"BAD REQUEST (invalid IPFS URI)",{},null,new ki(t))}}return e}const kl={data:m0,ipfs:b0("https://gateway.ipfs.io/ipfs/")},x0=new WeakMap;class UT{#e;#t;constructor(e){this.#e=[],this.#t=!1,x0.set(e,()=>{if(!this.#t){this.#t=!0;for(const t of this.#e)setTimeout(()=>{t()},0);this.#e=[]}})}addListener(e){pe(!this.#t,"singal already cancelled","UNSUPPORTED_OPERATION",{operation:"fetchCancelSignal.addCancelListener"}),this.#e.push(e)}get cancelled(){return this.#t}checkSignal(){pe(!this.cancelled,"cancelled","CANCELLED",{})}}function Ul(i){if(i==null)throw new Error("missing signal; should not happen");return i.checkSignal(),i}class ki{#e;#t;#n;#i;#s;#a;#r;#o;#f;#l;#p;#A;#c;#h;#u;get url(){return this.#a}set url(e){this.#a=String(e)}get body(){return this.#r==null?null:new Uint8Array(this.#r)}set body(e){if(e==null)this.#r=void 0,this.#o=void 0;else if(typeof e=="string")this.#r=ss(e),this.#o="text/plain";else if(e instanceof Uint8Array)this.#r=e,this.#o="application/octet-stream";else if(typeof e=="object")this.#r=ss(JSON.stringify(e)),this.#o="application/json";else throw new Error("invalid body")}hasBody(){return this.#r!=null}get method(){return this.#i?this.#i:this.hasBody()?"POST":"GET"}set method(e){e==null&&(e=""),this.#i=String(e).toUpperCase()}get headers(){const e=Object.assign({},this.#n);return this.#f&&(e.authorization=`Basic ${MT(ss(this.#f))}`),this.allowGzip&&(e["accept-encoding"]="gzip"),e["content-type"]==null&&this.#o&&(e["content-type"]=this.#o),this.body&&(e["content-length"]=String(this.body.length)),e}getHeader(e){return this.headers[e.toLowerCase()]}setHeader(e,t){this.#n[String(e).toLowerCase()]=String(t)}clearHeaders(){this.#n={}}[Symbol.iterator](){const e=this.headers,t=Object.keys(e);let n=0;return{next:()=>{if(n<t.length){const s=t[n++];return{value:[s,e[s]],done:!1}}return{value:void 0,done:!0}}}}get credentials(){return this.#f||null}setCredentials(e,t){V(!e.match(/:/),"invalid basic authentication username","username","[REDACTED]"),this.#f=`${e}:${t}`}get allowGzip(){return this.#t}set allowGzip(e){this.#t=!!e}get allowInsecureAuthentication(){return!!this.#e}set allowInsecureAuthentication(e){this.#e=!!e}get timeout(){return this.#s}set timeout(e){V(e>=0,"timeout must be non-zero","timeout",e),this.#s=e}get preflightFunc(){return this.#l||null}set preflightFunc(e){this.#l=e}get processFunc(){return this.#p||null}set processFunc(e){this.#p=e}get retryFunc(){return this.#A||null}set retryFunc(e){this.#A=e}get getUrlFunc(){return this.#u||g0}set getUrlFunc(e){this.#u=e}constructor(e){this.#a=String(e),this.#e=!1,this.#t=!0,this.#n={},this.#i="",this.#s=3e5,this.#h={slotInterval:LT,maxAttempts:DT},this.#u=null}toString(){return`<FetchRequest method=${JSON.stringify(this.method)} url=${JSON.stringify(this.url)} headers=${JSON.stringify(this.headers)} body=${this.#r?Ce(this.#r):"null"}>`}setThrottleParams(e){e.slotInterval!=null&&(this.#h.slotInterval=e.slotInterval),e.maxAttempts!=null&&(this.#h.maxAttempts=e.maxAttempts)}async#d(e,t,n,s,r){if(e>=this.#h.maxAttempts)return r.makeServerError("exceeded maximum retry limit");pe(_0()<=t,"timeout","TIMEOUT",{operation:"request.send",reason:"timeout",request:s}),n>0&&await QT(n);let a=this.clone();const o=(a.url.split(":")[0]||"").toLowerCase();if(o in kl){const h=await kl[o](a.url,Ul(s.#c));if(h instanceof Qs){let u=h;if(this.processFunc){Ul(s.#c);try{u=await this.processFunc(a,u)}catch(d){(d.throttle==null||typeof d.stall!="number")&&u.makeServerError("error in post-processing function",d).assertOk()}}return u}a=h}this.preflightFunc&&(a=await this.preflightFunc(a));const c=await this.getUrlFunc(a,Ul(s.#c));let l=new Qs(c.statusCode,c.statusMessage,c.headers,c.body,s);if(l.statusCode===301||l.statusCode===302){try{const h=l.headers.location||"";return a.redirect(h).#d(e+1,t,0,s,l)}catch{}return l}else if(l.statusCode===429&&(this.retryFunc==null||await this.retryFunc(a,l,e))){const h=l.headers["retry-after"];let u=this.#h.slotInterval*Math.trunc(Math.random()*Math.pow(2,e));return typeof h=="string"&&h.match(/^[1-9][0-9]*$/)&&(u=parseInt(h)),a.clone().#d(e+1,t,u,s,l)}if(this.processFunc){Ul(s.#c);try{l=await this.processFunc(a,l)}catch(h){(h.throttle==null||typeof h.stall!="number")&&l.makeServerError("error in post-processing function",h).assertOk();let u=this.#h.slotInterval*Math.trunc(Math.random()*Math.pow(2,e));return h.stall>=0&&(u=h.stall),a.clone().#d(e+1,t,u,s,l)}}return l}send(){return pe(this.#c==null,"request already sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.send"}),this.#c=new UT(this),this.#d(0,_0()+this.timeout,0,this,new Qs(0,"",{},null,this))}cancel(){pe(this.#c!=null,"request has not been sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.cancel"});const e=x0.get(this);if(!e)throw new Error("missing signal; should not happen");e()}redirect(e){const t=this.url.split(":")[0].toLowerCase(),n=e.split(":")[0].toLowerCase();pe(this.method==="GET"&&(t!=="https"||n!=="http")&&e.match(/^https?:/),"unsupported redirect","UNSUPPORTED_OPERATION",{operation:`redirect(${this.method} ${JSON.stringify(this.url)} => ${JSON.stringify(e)})`});const s=new ki(e);return s.method="GET",s.allowGzip=this.allowGzip,s.timeout=this.timeout,s.#n=Object.assign({},this.#n),this.#r&&(s.#r=new Uint8Array(this.#r)),s.#o=this.#o,s}clone(){const e=new ki(this.url);return e.#i=this.#i,this.#r&&(e.#r=this.#r),e.#o=this.#o,e.#n=Object.assign({},this.#n),e.#f=this.#f,this.allowGzip&&(e.allowGzip=!0),e.timeout=this.timeout,this.allowInsecureAuthentication&&(e.allowInsecureAuthentication=!0),e.#l=this.#l,e.#p=this.#p,e.#A=this.#A,e.#h=Object.assign({},this.#h),e.#u=this.#u,e}static lockConfig(){Xd=!0}static getGateway(e){return kl[e.toLowerCase()]||null}static registerGateway(e,t){if(e=e.toLowerCase(),e==="http"||e==="https")throw new Error(`cannot intercept ${e}; use registerGetUrl`);if(Xd)throw new Error("gateways locked");kl[e]=t}static registerGetUrl(e){if(Xd)throw new Error("gateways locked");g0=e}static createGetUrlFunc(e){return A0(e)}static createDataGateway(){return m0}static createIpfsGatewayFunc(e){return b0(e)}}class Qs{#e;#t;#n;#i;#s;#a;toString(){return`<FetchResponse status=${this.statusCode} body=${this.#i?Ce(this.#i):"null"}>`}get statusCode(){return this.#e}get statusMessage(){return this.#t}get headers(){return Object.assign({},this.#n)}get body(){return this.#i==null?null:new Uint8Array(this.#i)}get bodyText(){try{return this.#i==null?"":Pl(this.#i)}catch{pe(!1,"response body is not valid UTF-8 data","UNSUPPORTED_OPERATION",{operation:"bodyText",info:{response:this}})}}get bodyJson(){try{return JSON.parse(this.bodyText)}catch{pe(!1,"response body is not valid JSON","UNSUPPORTED_OPERATION",{operation:"bodyJson",info:{response:this}})}}[Symbol.iterator](){const e=this.headers,t=Object.keys(e);let n=0;return{next:()=>{if(n<t.length){const s=t[n++];return{value:[s,e[s]],done:!1}}return{value:void 0,done:!0}}}}constructor(e,t,n,s,r){this.#e=e,this.#t=t,this.#n=Object.keys(n).reduce((a,o)=>(a[o.toLowerCase()]=String(n[o]),a),{}),this.#i=s==null?null:new Uint8Array(s),this.#s=r||null,this.#a={message:""}}makeServerError(e,t){let n;e?n=`CLIENT ESCALATED SERVER ERROR (${this.statusCode} ${this.statusMessage}; ${e})`:(e=`${this.statusCode} ${this.statusMessage}`,n=`CLIENT ESCALATED SERVER ERROR (${e})`);const s=new Qs(599,n,this.headers,this.body,this.#s||void 0);return s.#a={message:e,error:t},s}throwThrottleError(e,t){t==null?t=-1:V(Number.isInteger(t)&&t>=0,"invalid stall timeout","stall",t);const n=new Error(e||"throttling requests");throw Xe(n,{stall:t,throttle:!0}),n}getHeader(e){return this.headers[e.toLowerCase()]}hasBody(){return this.#i!=null}get request(){return this.#s}ok(){return this.#a.message===""&&this.statusCode>=200&&this.statusCode<300}assertOk(){if(this.ok())return;let{message:e,error:t}=this.#a;e===""&&(e=`server response ${this.statusCode} ${this.statusMessage}`);let n=null;this.request&&(n=this.request.url);let s=null;try{this.#i&&(s=Pl(this.#i))}catch{}pe(!1,e,"SERVER_ERROR",{request:this.request||"unknown request",response:this,error:t,info:{requestUrl:n,responseBody:s,responseStatus:`${this.statusCode} ${this.statusMessage}`}})}}function _0(){return new Date().getTime()}function OT(i){return ss(i.replace(/%([0-9a-f][0-9a-f])/gi,(e,t)=>String.fromCharCode(parseInt(t,16))))}function QT(i){return new Promise(e=>setTimeout(e,i))}function GT(i){let e=i.toString(16);for(;e.length<2;)e="0"+e;return"0x"+e}function E0(i,e,t){let n=0;for(let s=0;s<t;s++)n=n*256+i[e+s];return n}function y0(i,e,t,n){const s=[];for(;t<e+1+n;){const r=w0(i,t);s.push(r.result),t+=r.consumed,pe(t<=e+1+n,"child data too short","BUFFER_OVERRUN",{buffer:i,length:n,offset:e})}return{consumed:1+n,result:s}}function w0(i,e){pe(i.length!==0,"data too short","BUFFER_OVERRUN",{buffer:i,length:0,offset:1});const t=n=>{pe(n<=i.length,"data short segment too short","BUFFER_OVERRUN",{buffer:i,length:i.length,offset:n})};if(i[e]>=248){const n=i[e]-247;t(e+1+n);const s=E0(i,e+1,n);return t(e+1+n+s),y0(i,e,e+1+n,n+s)}else if(i[e]>=192){const n=i[e]-192;return t(e+1+n),y0(i,e,e+1,n)}else if(i[e]>=184){const n=i[e]-183;t(e+1+n);const s=E0(i,e+1,n);t(e+1+n+s);const r=Ce(i.slice(e+1+n,e+1+n+s));return{consumed:1+n+s,result:r}}else if(i[e]>=128){const n=i[e]-128;t(e+1+n);const s=Ce(i.slice(e+1,e+1+n));return{consumed:1+n,result:s}}return{consumed:1,result:GT(i[e])}}function Uo(i){const e=lt(i,"data"),t=w0(e,0);return V(t.consumed===e.length,"unexpected junk after rlp payload","data",i),t.result}function v0(i){const e=[];for(;i;)e.unshift(i&255),i>>=8;return e}function C0(i){if(Array.isArray(i)){let n=[];if(i.forEach(function(r){n=n.concat(C0(r))}),n.length<=55)return n.unshift(192+n.length),n;const s=v0(n.length);return s.unshift(247+s.length),s.concat(n)}const e=Array.prototype.slice.call(lt(i,"object"));if(e.length===1&&e[0]<=127)return e;if(e.length<=55)return e.unshift(128+e.length),e;const t=v0(e.length);return t.unshift(183+t.length),t.concat(e)}const S0="0123456789abcdef";function rs(i){let e="0x";for(const t of C0(i))e+=S0[t>>4],e+=S0[t&15];return e}const Ln=32,Yd=new Uint8Array(Ln),HT=["then"],Ol={},I0=new WeakMap;function pr(i){return I0.get(i)}function M0(i,e){I0.set(i,e)}function Oo(i,e){const t=new Error(`deferred error during ABI decoding triggered accessing ${i}`);throw t.error=e,t}function Jd(i,e,t){return i.indexOf(null)>=0?e.map((n,s)=>n instanceof as?Jd(pr(n),n,t):n):i.reduce((n,s,r)=>{let a=e.getValue(s);return s in n||(t&&a instanceof as&&(a=Jd(pr(a),a,t)),n[s]=a),n},{})}class as extends Array{#e;constructor(...e){const t=e[0];let n=e[1],s=(e[2]||[]).slice(),r=!0;t!==Ol&&(n=e,s=[],r=!1),super(n.length),n.forEach((c,l)=>{this[l]=c});const a=s.reduce((c,l)=>(typeof l=="string"&&c.set(l,(c.get(l)||0)+1),c),new Map);if(M0(this,Object.freeze(n.map((c,l)=>{const h=s[l];return h!=null&&a.get(h)===1?h:null}))),this.#e=[],this.#e==null&&this.#e,!r)return;Object.freeze(this);const o=new Proxy(this,{get:(c,l,h)=>{if(typeof l=="string"){if(l.match(/^[0-9]+$/)){const d=ht(l,"%index");if(d<0||d>=this.length)throw new RangeError("out of result range");const f=c[d];return f instanceof Error&&Oo(`index ${d}`,f),f}if(HT.indexOf(l)>=0)return Reflect.get(c,l,h);const u=c[l];if(u instanceof Function)return function(...d){return u.apply(this===h?c:this,d)};if(!(l in c))return c.getValue.apply(this===h?c:this,[l])}return Reflect.get(c,l,h)}});return M0(o,pr(this)),o}toArray(e){const t=[];return this.forEach((n,s)=>{n instanceof Error&&Oo(`index ${s}`,n),e&&n instanceof as&&(n=n.toArray(e)),t.push(n)}),t}toObject(e){const t=pr(this);return t.reduce((n,s,r)=>(pe(s!=null,`value at index ${r} unnamed`,"UNSUPPORTED_OPERATION",{operation:"toObject()"}),Jd(t,this,e)),{})}slice(e,t){e==null&&(e=0),e<0&&(e+=this.length,e<0&&(e=0)),t==null&&(t=this.length),t<0&&(t+=this.length,t<0&&(t=0)),t>this.length&&(t=this.length);const n=pr(this),s=[],r=[];for(let a=e;a<t;a++)s.push(this[a]),r.push(n[a]);return new as(Ol,s,r)}filter(e,t){const n=pr(this),s=[],r=[];for(let a=0;a<this.length;a++){const o=this[a];o instanceof Error&&Oo(`index ${a}`,o),e.call(t,o,a,this)&&(s.push(o),r.push(n[a]))}return new as(Ol,s,r)}map(e,t){const n=[];for(let s=0;s<this.length;s++){const r=this[s];r instanceof Error&&Oo(`index ${s}`,r),n.push(e.call(t,r,s,this))}return n}getValue(e){const t=pr(this).indexOf(e);if(t===-1)return;const n=this[t];return n instanceof Error&&Oo(`property ${JSON.stringify(e)}`,n.error),n}static fromItems(e,t){return new as(Ol,e,t)}}function B0(i){let e=Zt(i);return pe(e.length<=Ln,"value out-of-bounds","BUFFER_OVERRUN",{buffer:e,length:Ln,offset:e.length}),e.length!==Ln&&(e=Dn(Ot([Yd.slice(e.length%Ln),e]))),e}class os{name;type;localName;dynamic;constructor(e,t,n,s){Xe(this,{name:e,type:t,localName:n,dynamic:s},{name:"string",type:"string",localName:"string",dynamic:"boolean"})}_throwError(e,t){V(!1,e,this.localName,t)}}class Zd{#e;#t;constructor(){this.#e=[],this.#t=0}get data(){return Ot(this.#e)}get length(){return this.#t}#n(e){return this.#e.push(e),this.#t+=e.length,e.length}appendWriter(e){return this.#n(Dn(e.data))}writeBytes(e){let t=Dn(e);const n=t.length%Ln;return n&&(t=Dn(Ot([t,Yd.slice(n)]))),this.#n(t)}writeValue(e){return this.#n(B0(e))}writeUpdatableValue(){const e=this.#e.length;return this.#e.push(Yd),this.#t+=Ln,t=>{this.#e[e]=B0(t)}}}class $d{allowLoose;#e;#t;#n;#i;#s;constructor(e,t,n){Xe(this,{allowLoose:!!t}),this.#e=Dn(e),this.#n=0,this.#i=null,this.#s=n??1024,this.#t=0}get data(){return Ce(this.#e)}get dataLength(){return this.#e.length}get consumed(){return this.#t}get bytes(){return new Uint8Array(this.#e)}#a(e){if(this.#i)return this.#i.#a(e);this.#n+=e,pe(this.#s<1||this.#n<=this.#s*this.dataLength,`compressed ABI data exceeds inflation ratio of ${this.#s} ( see: https://github.com/ethers-io/ethers.js/issues/4537 )`,"BUFFER_OVERRUN",{buffer:Dn(this.#e),offset:this.#t,length:e,info:{bytesRead:this.#n,dataLength:this.dataLength}})}#r(e,t,n){let s=Math.ceil(t/Ln)*Ln;return this.#t+s>this.#e.length&&(this.allowLoose&&n&&this.#t+t<=this.#e.length?s=t:pe(!1,"data out-of-bounds","BUFFER_OVERRUN",{buffer:Dn(this.#e),length:this.#e.length,offset:this.#t+s})),this.#e.slice(this.#t,this.#t+s)}subReader(e){const t=new $d(this.#e.slice(this.#t+e),this.allowLoose,this.#s);return t.#i=this,t}readBytes(e,t){let n=this.#r(0,e,!!t);return this.#a(e),this.#t+=n.length,n.slice(0,e)}readValue(){return jd(this.readBytes(Ln))}readIndex(){return CT(this.readBytes(Ln))}}function Ql(i){if(!Number.isSafeInteger(i)||i<0)throw new Error(`Wrong positive integer: ${i}`)}function ef(i,...e){if(!(i instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(i.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${i.length}`)}function zT(i){if(typeof i!="function"||typeof i.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Ql(i.outputLen),Ql(i.blockLen)}function Ta(i,e=!0){if(i.destroyed)throw new Error("Hash instance has been destroyed");if(e&&i.finished)throw new Error("Hash#digest() has already been called")}function T0(i,e){ef(i);const t=e.outputLen;if(i.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}const tf=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;const R0=i=>i instanceof Uint8Array,VT=i=>new Uint32Array(i.buffer,i.byteOffset,Math.floor(i.byteLength/4)),nf=i=>new DataView(i.buffer,i.byteOffset,i.byteLength),Ui=(i,e)=>i<<32-e|i>>>e;if(!(new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68))throw new Error("Non little-endian hardware is not supported");function WT(i){if(typeof i!="string")throw new Error(`utf8ToBytes expected string, got ${typeof i}`);return new Uint8Array(new TextEncoder().encode(i))}function Gl(i){if(typeof i=="string"&&(i=WT(i)),!R0(i))throw new Error(`expected Uint8Array, got ${typeof i}`);return i}function qT(...i){const e=new Uint8Array(i.reduce((n,s)=>n+s.length,0));let t=0;return i.forEach(n=>{if(!R0(n))throw new Error("Uint8Array expected");e.set(n,t),t+=n.length}),e}class sf{clone(){return this._cloneInto()}}function rf(i){const e=n=>i().update(Gl(n)).digest(),t=i();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>i(),e}function KT(i=32){if(tf&&typeof tf.getRandomValues=="function")return tf.getRandomValues(new Uint8Array(i));throw new Error("crypto.getRandomValues must be defined")}class N0 extends sf{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,zT(e);const n=Gl(t);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,r=new Uint8Array(s);r.set(n.length>s?e.create().update(n).digest():n);for(let a=0;a<r.length;a++)r[a]^=54;this.iHash.update(r),this.oHash=e.create();for(let a=0;a<r.length;a++)r[a]^=106;this.oHash.update(r),r.fill(0)}update(e){return Ta(this),this.iHash.update(e),this}digestInto(e){Ta(this),ef(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:n,finished:s,destroyed:r,blockLen:a,outputLen:o}=this;return e=e,e.finished=s,e.destroyed=r,e.blockLen=a,e.outputLen=o,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const F0=(i,e,t)=>new N0(i,e).update(t).digest();F0.create=(i,e)=>new N0(i,e);function jT(i,e,t,n){if(typeof i.setBigUint64=="function")return i.setBigUint64(e,t,n);const s=BigInt(32),r=BigInt(4294967295),a=Number(t>>s&r),o=Number(t&r),c=n?4:0,l=n?0:4;i.setUint32(e+c,a,n),i.setUint32(e+l,o,n)}class D0 extends sf{constructor(e,t,n,s){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=nf(this.buffer)}update(e){Ta(this);const{view:t,buffer:n,blockLen:s}=this;e=Gl(e);const r=e.length;for(let a=0;a<r;){const o=Math.min(s-this.pos,r-a);if(o===s){const c=nf(e);for(;s<=r-a;a+=s)this.process(c,a);continue}n.set(e.subarray(a,a+o),this.pos),this.pos+=o,a+=o,this.pos===s&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Ta(this),T0(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:s,isLE:r}=this;let{pos:a}=this;t[a++]=128,this.buffer.subarray(a).fill(0),this.padOffset>s-a&&(this.process(n,0),a=0);for(let u=a;u<s;u++)t[u]=0;jT(n,s-8,BigInt(this.length*8),r),this.process(n,0);const o=nf(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=c/4,h=this.get();if(l>h.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<l;u++)o.setUint32(4*u,h[u],r)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:s,finished:r,destroyed:a,pos:o}=this;return e.length=s,e.pos=o,e.finished=r,e.destroyed=a,s%t&&e.buffer.set(n),e}}const XT=(i,e,t)=>i&e^~i&t,YT=(i,e,t)=>i&e^i&t^e&t,JT=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Gs=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Hs=new Uint32Array(64);class ZT extends D0{constructor(){super(64,32,8,!1),this.A=Gs[0]|0,this.B=Gs[1]|0,this.C=Gs[2]|0,this.D=Gs[3]|0,this.E=Gs[4]|0,this.F=Gs[5]|0,this.G=Gs[6]|0,this.H=Gs[7]|0}get(){const{A:e,B:t,C:n,D:s,E:r,F:a,G:o,H:c}=this;return[e,t,n,s,r,a,o,c]}set(e,t,n,s,r,a,o,c){this.A=e|0,this.B=t|0,this.C=n|0,this.D=s|0,this.E=r|0,this.F=a|0,this.G=o|0,this.H=c|0}process(e,t){for(let u=0;u<16;u++,t+=4)Hs[u]=e.getUint32(t,!1);for(let u=16;u<64;u++){const d=Hs[u-15],f=Hs[u-2],m=Ui(d,7)^Ui(d,18)^d>>>3,A=Ui(f,17)^Ui(f,19)^f>>>10;Hs[u]=A+Hs[u-7]+m+Hs[u-16]|0}let{A:n,B:s,C:r,D:a,E:o,F:c,G:l,H:h}=this;for(let u=0;u<64;u++){const d=Ui(o,6)^Ui(o,11)^Ui(o,25),f=h+d+XT(o,c,l)+JT[u]+Hs[u]|0,A=(Ui(n,2)^Ui(n,13)^Ui(n,22))+YT(n,s,r)|0;h=l,l=c,c=o,o=a+f|0,a=r,r=s,s=n,n=f+A|0}n=n+this.A|0,s=s+this.B|0,r=r+this.C|0,a=a+this.D|0,o=o+this.E|0,c=c+this.F|0,l=l+this.G|0,h=h+this.H|0,this.set(n,s,r,a,o,c,l,h)}roundClean(){Hs.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const L0=rf(()=>new ZT),Hl=BigInt(2**32-1),af=BigInt(32);function P0(i,e=!1){return e?{h:Number(i&Hl),l:Number(i>>af&Hl)}:{h:Number(i>>af&Hl)|0,l:Number(i&Hl)|0}}function k0(i,e=!1){let t=new Uint32Array(i.length),n=new Uint32Array(i.length);for(let s=0;s<i.length;s++){const{h:r,l:a}=P0(i[s],e);[t[s],n[s]]=[r,a]}return[t,n]}const $T=(i,e)=>BigInt(i>>>0)<<af|BigInt(e>>>0),eR=(i,e,t)=>i>>>t,tR=(i,e,t)=>i<<32-t|e>>>t,nR=(i,e,t)=>i>>>t|e<<32-t,iR=(i,e,t)=>i<<32-t|e>>>t,sR=(i,e,t)=>i<<64-t|e>>>t-32,rR=(i,e,t)=>i>>>t-32|e<<64-t,aR=(i,e)=>e,oR=(i,e)=>i,U0=(i,e,t)=>i<<t|e>>>32-t,O0=(i,e,t)=>e<<t|i>>>32-t,Q0=(i,e,t)=>e<<t-32|i>>>64-t,G0=(i,e,t)=>i<<t-32|e>>>64-t;function cR(i,e,t,n){const s=(e>>>0)+(n>>>0);return{h:i+t+(s/2**32|0)|0,l:s|0}}const ct={fromBig:P0,split:k0,toBig:$T,shrSH:eR,shrSL:tR,rotrSH:nR,rotrSL:iR,rotrBH:sR,rotrBL:rR,rotr32H:aR,rotr32L:oR,rotlSH:U0,rotlSL:O0,rotlBH:Q0,rotlBL:G0,add:cR,add3L:(i,e,t)=>(i>>>0)+(e>>>0)+(t>>>0),add3H:(i,e,t,n)=>e+t+n+(i/2**32|0)|0,add4L:(i,e,t,n)=>(i>>>0)+(e>>>0)+(t>>>0)+(n>>>0),add4H:(i,e,t,n,s)=>e+t+n+s+(i/2**32|0)|0,add5H:(i,e,t,n,s,r)=>e+t+n+s+r+(i/2**32|0)|0,add5L:(i,e,t,n,s)=>(i>>>0)+(e>>>0)+(t>>>0)+(n>>>0)+(s>>>0)},[lR,hR]=ct.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(i=>BigInt(i))),zs=new Uint32Array(80),Vs=new Uint32Array(80);class uR extends D0{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:e,Al:t,Bh:n,Bl:s,Ch:r,Cl:a,Dh:o,Dl:c,Eh:l,El:h,Fh:u,Fl:d,Gh:f,Gl:m,Hh:A,Hl:g}=this;return[e,t,n,s,r,a,o,c,l,h,u,d,f,m,A,g]}set(e,t,n,s,r,a,o,c,l,h,u,d,f,m,A,g){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=s|0,this.Ch=r|0,this.Cl=a|0,this.Dh=o|0,this.Dl=c|0,this.Eh=l|0,this.El=h|0,this.Fh=u|0,this.Fl=d|0,this.Gh=f|0,this.Gl=m|0,this.Hh=A|0,this.Hl=g|0}process(e,t){for(let b=0;b<16;b++,t+=4)zs[b]=e.getUint32(t),Vs[b]=e.getUint32(t+=4);for(let b=16;b<80;b++){const E=zs[b-15]|0,M=Vs[b-15]|0,w=ct.rotrSH(E,M,1)^ct.rotrSH(E,M,8)^ct.shrSH(E,M,7),S=ct.rotrSL(E,M,1)^ct.rotrSL(E,M,8)^ct.shrSL(E,M,7),T=zs[b-2]|0,C=Vs[b-2]|0,v=ct.rotrSH(T,C,19)^ct.rotrBH(T,C,61)^ct.shrSH(T,C,6),F=ct.rotrSL(T,C,19)^ct.rotrBL(T,C,61)^ct.shrSL(T,C,6),K=ct.add4L(S,F,Vs[b-7],Vs[b-16]),q=ct.add4H(K,w,v,zs[b-7],zs[b-16]);zs[b]=q|0,Vs[b]=K|0}let{Ah:n,Al:s,Bh:r,Bl:a,Ch:o,Cl:c,Dh:l,Dl:h,Eh:u,El:d,Fh:f,Fl:m,Gh:A,Gl:g,Hh:p,Hl:y}=this;for(let b=0;b<80;b++){const E=ct.rotrSH(u,d,14)^ct.rotrSH(u,d,18)^ct.rotrBH(u,d,41),M=ct.rotrSL(u,d,14)^ct.rotrSL(u,d,18)^ct.rotrBL(u,d,41),w=u&f^~u&A,S=d&m^~d&g,T=ct.add5L(y,M,S,hR[b],Vs[b]),C=ct.add5H(T,p,E,w,lR[b],zs[b]),v=T|0,F=ct.rotrSH(n,s,28)^ct.rotrBH(n,s,34)^ct.rotrBH(n,s,39),K=ct.rotrSL(n,s,28)^ct.rotrBL(n,s,34)^ct.rotrBL(n,s,39),q=n&r^n&o^r&o,$=s&a^s&c^a&c;p=A|0,y=g|0,A=f|0,g=m|0,f=u|0,m=d|0,{h:u,l:d}=ct.add(l|0,h|0,C|0,v|0),l=o|0,h=c|0,o=r|0,c=a|0,r=n|0,a=s|0;const D=ct.add3L(v,K,$);n=ct.add3H(D,C,F,q),s=D|0}({h:n,l:s}=ct.add(this.Ah|0,this.Al|0,n|0,s|0)),{h:r,l:a}=ct.add(this.Bh|0,this.Bl|0,r|0,a|0),{h:o,l:c}=ct.add(this.Ch|0,this.Cl|0,o|0,c|0),{h:l,l:h}=ct.add(this.Dh|0,this.Dl|0,l|0,h|0),{h:u,l:d}=ct.add(this.Eh|0,this.El|0,u|0,d|0),{h:f,l:m}=ct.add(this.Fh|0,this.Fl|0,f|0,m|0),{h:A,l:g}=ct.add(this.Gh|0,this.Gl|0,A|0,g|0),{h:p,l:y}=ct.add(this.Hh|0,this.Hl|0,p|0,y|0),this.set(n,s,r,a,o,c,l,h,u,d,f,m,A,g,p,y)}roundClean(){zs.fill(0),Vs.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const dR=rf(()=>new uR);function fR(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("unable to locate global object")}const H0=fR();H0.crypto||H0.msCrypto;function pR(i){switch(i){case"sha256":return L0.create();case"sha512":return dR.create()}V(!1,"invalid hashing algorithm name","algorithm",i)}const[z0,V0,W0]=[[],[],[]],AR=BigInt(0),Qo=BigInt(1),gR=BigInt(2),mR=BigInt(7),bR=BigInt(256),xR=BigInt(113);for(let i=0,e=Qo,t=1,n=0;i<24;i++){[t,n]=[n,(2*t+3*n)%5],z0.push(2*(5*n+t)),V0.push((i+1)*(i+2)/2%64);let s=AR;for(let r=0;r<7;r++)e=(e<<Qo^(e>>mR)*xR)%bR,e&gR&&(s^=Qo<<(Qo<<BigInt(r))-Qo);W0.push(s)}const[_R,ER]=k0(W0,!0),q0=(i,e,t)=>t>32?Q0(i,e,t):U0(i,e,t),K0=(i,e,t)=>t>32?G0(i,e,t):O0(i,e,t);function yR(i,e=24){const t=new Uint32Array(10);for(let n=24-e;n<24;n++){for(let a=0;a<10;a++)t[a]=i[a]^i[a+10]^i[a+20]^i[a+30]^i[a+40];for(let a=0;a<10;a+=2){const o=(a+8)%10,c=(a+2)%10,l=t[c],h=t[c+1],u=q0(l,h,1)^t[o],d=K0(l,h,1)^t[o+1];for(let f=0;f<50;f+=10)i[a+f]^=u,i[a+f+1]^=d}let s=i[2],r=i[3];for(let a=0;a<24;a++){const o=V0[a],c=q0(s,r,o),l=K0(s,r,o),h=z0[a];s=i[h],r=i[h+1],i[h]=c,i[h+1]=l}for(let a=0;a<50;a+=10){for(let o=0;o<10;o++)t[o]=i[a+o];for(let o=0;o<10;o++)i[a+o]^=~t[(o+2)%10]&t[(o+4)%10]}i[0]^=_R[n],i[1]^=ER[n]}t.fill(0)}class of extends sf{constructor(e,t,n,s=!1,r=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=s,this.rounds=r,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Ql(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=VT(this.state)}keccak(){yR(this.state32,this.rounds),this.posOut=0,this.pos=0}update(e){Ta(this);const{blockLen:t,state:n}=this;e=Gl(e);const s=e.length;for(let r=0;r<s;){const a=Math.min(t-this.pos,s-r);for(let o=0;o<a;o++)n[this.pos++]^=e[r++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:n,blockLen:s}=this;e[n]^=t,(t&128)!==0&&n===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){Ta(this,!1),ef(e),this.finish();const t=this.state,{blockLen:n}=this;for(let s=0,r=e.length;s<r;){this.posOut>=n&&this.keccak();const a=Math.min(n-this.posOut,r-s);e.set(t.subarray(this.posOut,this.posOut+a),s),this.posOut+=a,s+=a}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Ql(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(T0(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:n,outputLen:s,rounds:r,enableXOF:a}=this;return e||(e=new of(t,n,s,a,r)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=r,e.suffix=n,e.outputLen=s,e.enableXOF=a,e.destroyed=this.destroyed,e}}const wR=((i,e,t)=>rf(()=>new of(e,i,t)))(1,136,256/8);let j0=!1;const X0=function(i){return wR(i)};let Y0=X0;function $t(i){const e=lt(i,"data");return Ce(Y0(e))}$t._=X0,$t.lock=function(){j0=!0},$t.register=function(i){if(j0)throw new TypeError("keccak256 is locked");Y0=i},Object.freeze($t);const J0=function(i){return pR("sha256").update(i).digest()};let Z0=J0,$0=!1;function Ra(i){const e=lt(i,"data");return Ce(Z0(e))}Ra._=J0,Ra.lock=function(){$0=!0},Ra.register=function(i){if($0)throw new Error("sha256 is locked");Z0=i},Object.freeze(Ra),Object.freeze(Ra);BigInt(0);const vR=BigInt(1),CR=BigInt(2),zl=i=>i instanceof Uint8Array,SR=Array.from({length:256},(i,e)=>e.toString(16).padStart(2,"0"));function Na(i){if(!zl(i))throw new Error("Uint8Array expected");let e="";for(let t=0;t<i.length;t++)e+=SR[i[t]];return e}function cf(i){if(typeof i!="string")throw new Error("hex string expected, got "+typeof i);return BigInt(i===""?"0":`0x${i}`)}function Go(i){if(typeof i!="string")throw new Error("hex string expected, got "+typeof i);const e=i.length;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const t=new Uint8Array(e/2);for(let n=0;n<t.length;n++){const s=n*2,r=i.slice(s,s+2),a=Number.parseInt(r,16);if(Number.isNaN(a)||a<0)throw new Error("Invalid byte sequence");t[n]=a}return t}function Ar(i){return cf(Na(i))}function lf(i){if(!zl(i))throw new Error("Uint8Array expected");return cf(Na(Uint8Array.from(i).reverse()))}function Fa(i,e){return Go(i.toString(16).padStart(e*2,"0"))}function hf(i,e){return Fa(i,e).reverse()}function Ci(i,e,t){let n;if(typeof e=="string")try{n=Go(e)}catch(r){throw new Error(`${i} must be valid hex string, got "${e}". Cause: ${r}`)}else if(zl(e))n=Uint8Array.from(e);else throw new Error(`${i} must be hex string or Uint8Array`);const s=n.length;if(typeof t=="number"&&s!==t)throw new Error(`${i} expected ${t} bytes, got ${s}`);return n}function Ho(...i){const e=new Uint8Array(i.reduce((n,s)=>n+s.length,0));let t=0;return i.forEach(n=>{if(!zl(n))throw new Error("Uint8Array expected");e.set(n,t),t+=n.length}),e}const uf=i=>(CR<<BigInt(i-1))-vR,df=i=>new Uint8Array(i),eb=i=>Uint8Array.from(i);function tb(i,e,t){if(typeof i!="number"||i<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof t!="function")throw new Error("hmacFn must be a function");let n=df(i),s=df(i),r=0;const a=()=>{n.fill(1),s.fill(0),r=0},o=(...u)=>t(s,n,...u),c=(u=df())=>{s=o(eb([0]),u),n=o(),u.length!==0&&(s=o(eb([1]),u),n=o())},l=()=>{if(r++>=1e3)throw new Error("drbg: tried 1000 values");let u=0;const d=[];for(;u<e;){n=o();const f=n.slice();d.push(f),u+=n.length}return Ho(...d)};return(u,d)=>{a(),c(u);let f;for(;!(f=d(l()));)c();return a(),f}}const IR={bigint:i=>typeof i=="bigint",function:i=>typeof i=="function",boolean:i=>typeof i=="boolean",string:i=>typeof i=="string",stringOrUint8Array:i=>typeof i=="string"||i instanceof Uint8Array,isSafeInteger:i=>Number.isSafeInteger(i),array:i=>Array.isArray(i),field:(i,e)=>e.Fp.isValid(i),hash:i=>typeof i=="function"&&Number.isSafeInteger(i.outputLen)};function zo(i,e,t={}){const n=(s,r,a)=>{const o=IR[r];if(typeof o!="function")throw new Error(`Invalid validator "${r}", expected function`);const c=i[s];if(!(a&&c===void 0)&&!o(c,i))throw new Error(`Invalid param ${String(s)}=${c} (${typeof c}), expected ${r}`)};for(const[s,r]of Object.entries(e))n(s,r,!1);for(const[s,r]of Object.entries(t))n(s,r,!0);return i}const MR=Object.freeze(Object.defineProperty({__proto__:null,bitMask:uf,bytesToHex:Na,bytesToNumberBE:Ar,bytesToNumberLE:lf,concatBytes:Ho,createHmacDrbg:tb,ensureBytes:Ci,hexToBytes:Go,hexToNumber:cf,numberToBytesBE:Fa,numberToBytesLE:hf,validateObject:zo},Symbol.toStringTag,{value:"Module"}));const An=BigInt(0),jt=BigInt(1),gr=BigInt(2),BR=BigInt(3),ff=BigInt(4),nb=BigInt(5),ib=BigInt(8);BigInt(9),BigInt(16);function Hn(i,e){const t=i%e;return t>=An?t:e+t}function TR(i,e,t){if(t<=An||e<An)throw new Error("Expected power/modulo > 0");if(t===jt)return An;let n=jt;for(;e>An;)e&jt&&(n=n*i%t),i=i*i%t,e>>=jt;return n}function si(i,e,t){let n=i;for(;e-- >An;)n*=n,n%=t;return n}function pf(i,e){if(i===An||e<=An)throw new Error(`invert: expected positive integers, got n=${i} mod=${e}`);let t=Hn(i,e),n=e,s=An,r=jt;for(;t!==An;){const o=n/t,c=n%t,l=s-r*o;n=t,t=c,s=r,r=l}if(n!==jt)throw new Error("invert: does not exist");return Hn(s,e)}function RR(i){const e=(i-jt)/gr;let t,n,s;for(t=i-jt,n=0;t%gr===An;t/=gr,n++);for(s=gr;s<i&&TR(s,e,i)!==i-jt;s++);if(n===1){const a=(i+jt)/ff;return function(c,l){const h=c.pow(l,a);if(!c.eql(c.sqr(h),l))throw new Error("Cannot find square root");return h}}const r=(t+jt)/gr;return function(o,c){if(o.pow(c,e)===o.neg(o.ONE))throw new Error("Cannot find square root");let l=n,h=o.pow(o.mul(o.ONE,s),t),u=o.pow(c,r),d=o.pow(c,t);for(;!o.eql(d,o.ONE);){if(o.eql(d,o.ZERO))return o.ZERO;let f=1;for(let A=o.sqr(d);f<l&&!o.eql(A,o.ONE);f++)A=o.sqr(A);const m=o.pow(h,jt<<BigInt(l-f-1));h=o.sqr(m),u=o.mul(u,m),d=o.mul(d,h),l=f}return u}}function NR(i){if(i%ff===BR){const e=(i+jt)/ff;return function(n,s){const r=n.pow(s,e);if(!n.eql(n.sqr(r),s))throw new Error("Cannot find square root");return r}}if(i%ib===nb){const e=(i-nb)/ib;return function(n,s){const r=n.mul(s,gr),a=n.pow(r,e),o=n.mul(s,a),c=n.mul(n.mul(o,gr),a),l=n.mul(o,n.sub(c,n.ONE));if(!n.eql(n.sqr(l),s))throw new Error("Cannot find square root");return l}}return RR(i)}const FR=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function DR(i){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=FR.reduce((n,s)=>(n[s]="function",n),e);return zo(i,t)}function LR(i,e,t){if(t<An)throw new Error("Expected power > 0");if(t===An)return i.ONE;if(t===jt)return e;let n=i.ONE,s=e;for(;t>An;)t&jt&&(n=i.mul(n,s)),s=i.sqr(s),t>>=jt;return n}function PR(i,e){const t=new Array(e.length),n=e.reduce((r,a,o)=>i.is0(a)?r:(t[o]=r,i.mul(r,a)),i.ONE),s=i.inv(n);return e.reduceRight((r,a,o)=>i.is0(a)?r:(t[o]=i.mul(r,t[o]),i.mul(r,a)),s),t}function sb(i,e){const t=e!==void 0?e:i.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function kR(i,e,t=!1,n={}){if(i<=An)throw new Error(`Expected Field ORDER > 0, got ${i}`);const{nBitLength:s,nByteLength:r}=sb(i,e);if(r>2048)throw new Error("Field lengths over 2048 bytes are not supported");const a=NR(i),o=Object.freeze({ORDER:i,BITS:s,BYTES:r,MASK:uf(s),ZERO:An,ONE:jt,create:c=>Hn(c,i),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return An<=c&&c<i},is0:c=>c===An,isOdd:c=>(c&jt)===jt,neg:c=>Hn(-c,i),eql:(c,l)=>c===l,sqr:c=>Hn(c*c,i),add:(c,l)=>Hn(c+l,i),sub:(c,l)=>Hn(c-l,i),mul:(c,l)=>Hn(c*l,i),pow:(c,l)=>LR(o,c,l),div:(c,l)=>Hn(c*pf(l,i),i),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>pf(c,i),sqrt:n.sqrt||(c=>a(o,c)),invertBatch:c=>PR(o,c),cmov:(c,l,h)=>h?l:c,toBytes:c=>t?hf(c,r):Fa(c,r),fromBytes:c=>{if(c.length!==r)throw new Error(`Fp.fromBytes: expected ${r}, got ${c.length}`);return t?lf(c):Ar(c)}});return Object.freeze(o)}function rb(i){if(typeof i!="bigint")throw new Error("field order must be bigint");const e=i.toString(2).length;return Math.ceil(e/8)}function ab(i){const e=rb(i);return e+Math.ceil(e/2)}function UR(i,e,t=!1){const n=i.length,s=rb(e),r=ab(e);if(n<16||n<r||n>1024)throw new Error(`expected ${r}-1024 bytes of input, got ${n}`);const a=t?Ar(i):lf(i),o=Hn(a,e-jt)+jt;return t?hf(o,s):Fa(o,s)}const OR=BigInt(0),Af=BigInt(1);function QR(i,e){const t=(s,r)=>{const a=r.negate();return s?a:r},n=s=>{const r=Math.ceil(e/s)+1,a=2**(s-1);return{windows:r,windowSize:a}};return{constTimeNegate:t,unsafeLadder(s,r){let a=i.ZERO,o=s;for(;r>OR;)r&Af&&(a=a.add(o)),o=o.double(),r>>=Af;return a},precomputeWindow(s,r){const{windows:a,windowSize:o}=n(r),c=[];let l=s,h=l;for(let u=0;u<a;u++){h=l,c.push(h);for(let d=1;d<o;d++)h=h.add(l),c.push(h);l=h.double()}return c},wNAF(s,r,a){const{windows:o,windowSize:c}=n(s);let l=i.ZERO,h=i.BASE;const u=BigInt(2**s-1),d=2**s,f=BigInt(s);for(let m=0;m<o;m++){const A=m*c;let g=Number(a&u);a>>=f,g>c&&(g-=d,a+=Af);const p=A,y=A+Math.abs(g)-1,b=m%2!==0,E=g<0;g===0?h=h.add(t(b,r[p])):l=l.add(t(E,r[y]))}return{p:l,f:h}},wNAFCached(s,r,a,o){const c=s._WINDOW_SIZE||1;let l=r.get(s);return l||(l=this.precomputeWindow(s,c),c!==1&&r.set(s,o(l))),this.wNAF(c,l,a)}}}function ob(i){return DR(i.Fp),zo(i,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...sb(i.n,i.nBitLength),...i,p:i.Fp.ORDER})}function GR(i){const e=ob(i);zo(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:t,Fp:n,a:s}=e;if(t){if(!n.eql(s,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}const{bytesToNumberBE:HR,hexToBytes:zR}=MR,mr={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(i){const{Err:e}=mr;if(i.length<2||i[0]!==2)throw new e("Invalid signature integer tag");const t=i[1],n=i.subarray(2,t+2);if(!t||n.length!==t)throw new e("Invalid signature integer: wrong length");if(n[0]&128)throw new e("Invalid signature integer: negative");if(n[0]===0&&!(n[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return{d:HR(n),l:i.subarray(t+2)}},toSig(i){const{Err:e}=mr,t=typeof i=="string"?zR(i):i;if(!(t instanceof Uint8Array))throw new Error("ui8a expected");let n=t.length;if(n<2||t[0]!=48)throw new e("Invalid signature tag");if(t[1]!==n-2)throw new e("Invalid signature: incorrect length");const{d:s,l:r}=mr._parseInt(t.subarray(2)),{d:a,l:o}=mr._parseInt(r);if(o.length)throw new e("Invalid signature: left bytes after parsing");return{r:s,s:a}},hexFromSig(i){const e=l=>Number.parseInt(l[0],16)&8?"00"+l:l,t=l=>{const h=l.toString(16);return h.length&1?`0${h}`:h},n=e(t(i.s)),s=e(t(i.r)),r=n.length/2,a=s.length/2,o=t(r),c=t(a);return`30${t(a+r+4)}02${c}${s}02${o}${n}`}},cs=BigInt(0),ri=BigInt(1);BigInt(2);const cb=BigInt(3);BigInt(4);function VR(i){const e=GR(i),{Fp:t}=e,n=e.toBytes||((m,A,g)=>{const p=A.toAffine();return Ho(Uint8Array.from([4]),t.toBytes(p.x),t.toBytes(p.y))}),s=e.fromBytes||(m=>{const A=m.subarray(1),g=t.fromBytes(A.subarray(0,t.BYTES)),p=t.fromBytes(A.subarray(t.BYTES,2*t.BYTES));return{x:g,y:p}});function r(m){const{a:A,b:g}=e,p=t.sqr(m),y=t.mul(p,m);return t.add(t.add(y,t.mul(m,A)),g)}if(!t.eql(t.sqr(e.Gy),r(e.Gx)))throw new Error("bad generator point: equation left != right");function a(m){return typeof m=="bigint"&&cs<m&&m<e.n}function o(m){if(!a(m))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function c(m){const{allowedPrivateKeyLengths:A,nByteLength:g,wrapPrivateKey:p,n:y}=e;if(A&&typeof m!="bigint"){if(m instanceof Uint8Array&&(m=Na(m)),typeof m!="string"||!A.includes(m.length))throw new Error("Invalid key");m=m.padStart(g*2,"0")}let b;try{b=typeof m=="bigint"?m:Ar(Ci("private key",m,g))}catch{throw new Error(`private key must be ${g} bytes, hex or bigint, not ${typeof m}`)}return p&&(b=Hn(b,y)),o(b),b}const l=new Map;function h(m){if(!(m instanceof u))throw new Error("ProjectivePoint expected")}class u{constructor(A,g,p){if(this.px=A,this.py=g,this.pz=p,A==null||!t.isValid(A))throw new Error("x required");if(g==null||!t.isValid(g))throw new Error("y required");if(p==null||!t.isValid(p))throw new Error("z required")}static fromAffine(A){const{x:g,y:p}=A||{};if(!A||!t.isValid(g)||!t.isValid(p))throw new Error("invalid affine point");if(A instanceof u)throw new Error("projective point not allowed");const y=b=>t.eql(b,t.ZERO);return y(g)&&y(p)?u.ZERO:new u(g,p,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(A){const g=t.invertBatch(A.map(p=>p.pz));return A.map((p,y)=>p.toAffine(g[y])).map(u.fromAffine)}static fromHex(A){const g=u.fromAffine(s(Ci("pointHex",A)));return g.assertValidity(),g}static fromPrivateKey(A){return u.BASE.multiply(c(A))}_setWindowSize(A){this._WINDOW_SIZE=A,l.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!t.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:A,y:g}=this.toAffine();if(!t.isValid(A)||!t.isValid(g))throw new Error("bad point: x or y not FE");const p=t.sqr(g),y=r(A);if(!t.eql(p,y))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:A}=this.toAffine();if(t.isOdd)return!t.isOdd(A);throw new Error("Field doesn't support isOdd")}equals(A){h(A);const{px:g,py:p,pz:y}=this,{px:b,py:E,pz:M}=A,w=t.eql(t.mul(g,M),t.mul(b,y)),S=t.eql(t.mul(p,M),t.mul(E,y));return w&&S}negate(){return new u(this.px,t.neg(this.py),this.pz)}double(){const{a:A,b:g}=e,p=t.mul(g,cb),{px:y,py:b,pz:E}=this;let M=t.ZERO,w=t.ZERO,S=t.ZERO,T=t.mul(y,y),C=t.mul(b,b),v=t.mul(E,E),F=t.mul(y,b);return F=t.add(F,F),S=t.mul(y,E),S=t.add(S,S),M=t.mul(A,S),w=t.mul(p,v),w=t.add(M,w),M=t.sub(C,w),w=t.add(C,w),w=t.mul(M,w),M=t.mul(F,M),S=t.mul(p,S),v=t.mul(A,v),F=t.sub(T,v),F=t.mul(A,F),F=t.add(F,S),S=t.add(T,T),T=t.add(S,T),T=t.add(T,v),T=t.mul(T,F),w=t.add(w,T),v=t.mul(b,E),v=t.add(v,v),T=t.mul(v,F),M=t.sub(M,T),S=t.mul(v,C),S=t.add(S,S),S=t.add(S,S),new u(M,w,S)}add(A){h(A);const{px:g,py:p,pz:y}=this,{px:b,py:E,pz:M}=A;let w=t.ZERO,S=t.ZERO,T=t.ZERO;const C=e.a,v=t.mul(e.b,cb);let F=t.mul(g,b),K=t.mul(p,E),q=t.mul(y,M),$=t.add(g,p),D=t.add(b,E);$=t.mul($,D),D=t.add(F,K),$=t.sub($,D),D=t.add(g,y);let O=t.add(b,M);return D=t.mul(D,O),O=t.add(F,q),D=t.sub(D,O),O=t.add(p,y),w=t.add(E,M),O=t.mul(O,w),w=t.add(K,q),O=t.sub(O,w),T=t.mul(C,D),w=t.mul(v,q),T=t.add(w,T),w=t.sub(K,T),T=t.add(K,T),S=t.mul(w,T),K=t.add(F,F),K=t.add(K,F),q=t.mul(C,q),D=t.mul(v,D),K=t.add(K,q),q=t.sub(F,q),q=t.mul(C,q),D=t.add(D,q),F=t.mul(K,D),S=t.add(S,F),F=t.mul(O,D),w=t.mul($,w),w=t.sub(w,F),F=t.mul($,K),T=t.mul(O,T),T=t.add(T,F),new u(w,S,T)}subtract(A){return this.add(A.negate())}is0(){return this.equals(u.ZERO)}wNAF(A){return f.wNAFCached(this,l,A,g=>{const p=t.invertBatch(g.map(y=>y.pz));return g.map((y,b)=>y.toAffine(p[b])).map(u.fromAffine)})}multiplyUnsafe(A){const g=u.ZERO;if(A===cs)return g;if(o(A),A===ri)return this;const{endo:p}=e;if(!p)return f.unsafeLadder(this,A);let{k1neg:y,k1:b,k2neg:E,k2:M}=p.splitScalar(A),w=g,S=g,T=this;for(;b>cs||M>cs;)b&ri&&(w=w.add(T)),M&ri&&(S=S.add(T)),T=T.double(),b>>=ri,M>>=ri;return y&&(w=w.negate()),E&&(S=S.negate()),S=new u(t.mul(S.px,p.beta),S.py,S.pz),w.add(S)}multiply(A){o(A);let g=A,p,y;const{endo:b}=e;if(b){const{k1neg:E,k1:M,k2neg:w,k2:S}=b.splitScalar(g);let{p:T,f:C}=this.wNAF(M),{p:v,f:F}=this.wNAF(S);T=f.constTimeNegate(E,T),v=f.constTimeNegate(w,v),v=new u(t.mul(v.px,b.beta),v.py,v.pz),p=T.add(v),y=C.add(F)}else{const{p:E,f:M}=this.wNAF(g);p=E,y=M}return u.normalizeZ([p,y])[0]}multiplyAndAddUnsafe(A,g,p){const y=u.BASE,b=(M,w)=>w===cs||w===ri||!M.equals(y)?M.multiplyUnsafe(w):M.multiply(w),E=b(this,g).add(b(A,p));return E.is0()?void 0:E}toAffine(A){const{px:g,py:p,pz:y}=this,b=this.is0();A==null&&(A=b?t.ONE:t.inv(y));const E=t.mul(g,A),M=t.mul(p,A),w=t.mul(y,A);if(b)return{x:t.ZERO,y:t.ZERO};if(!t.eql(w,t.ONE))throw new Error("invZ was invalid");return{x:E,y:M}}isTorsionFree(){const{h:A,isTorsionFree:g}=e;if(A===ri)return!0;if(g)return g(u,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:A,clearCofactor:g}=e;return A===ri?this:g?g(u,this):this.multiplyUnsafe(e.h)}toRawBytes(A=!0){return this.assertValidity(),n(u,this,A)}toHex(A=!0){return Na(this.toRawBytes(A))}}u.BASE=new u(e.Gx,e.Gy,t.ONE),u.ZERO=new u(t.ZERO,t.ONE,t.ZERO);const d=e.nBitLength,f=QR(u,e.endo?Math.ceil(d/2):d);return{CURVE:e,ProjectivePoint:u,normPrivateKeyToScalar:c,weierstrassEquation:r,isWithinCurveOrder:a}}function WR(i){const e=ob(i);return zo(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function qR(i){const e=WR(i),{Fp:t,n}=e,s=t.BYTES+1,r=2*t.BYTES+1;function a(D){return cs<D&&D<t.ORDER}function o(D){return Hn(D,n)}function c(D){return pf(D,n)}const{ProjectivePoint:l,normPrivateKeyToScalar:h,weierstrassEquation:u,isWithinCurveOrder:d}=VR({...e,toBytes(D,O,Y){const Q=O.toAffine(),J=t.toBytes(Q.x),ee=Ho;return Y?ee(Uint8Array.from([O.hasEvenY()?2:3]),J):ee(Uint8Array.from([4]),J,t.toBytes(Q.y))},fromBytes(D){const O=D.length,Y=D[0],Q=D.subarray(1);if(O===s&&(Y===2||Y===3)){const J=Ar(Q);if(!a(J))throw new Error("Point is not on curve");const ee=u(J);let ae=t.sqrt(ee);const ye=(ae&ri)===ri;return(Y&1)===1!==ye&&(ae=t.neg(ae)),{x:J,y:ae}}else if(O===r&&Y===4){const J=t.fromBytes(Q.subarray(0,t.BYTES)),ee=t.fromBytes(Q.subarray(t.BYTES,2*t.BYTES));return{x:J,y:ee}}else throw new Error(`Point of length ${O} was invalid. Expected ${s} compressed bytes or ${r} uncompressed bytes`)}}),f=D=>Na(Fa(D,e.nByteLength));function m(D){const O=n>>ri;return D>O}function A(D){return m(D)?o(-D):D}const g=(D,O,Y)=>Ar(D.slice(O,Y));class p{constructor(O,Y,Q){this.r=O,this.s=Y,this.recovery=Q,this.assertValidity()}static fromCompact(O){const Y=e.nByteLength;return O=Ci("compactSignature",O,Y*2),new p(g(O,0,Y),g(O,Y,2*Y))}static fromDER(O){const{r:Y,s:Q}=mr.toSig(Ci("DER",O));return new p(Y,Q)}assertValidity(){if(!d(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!d(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(O){return new p(this.r,this.s,O)}recoverPublicKey(O){const{r:Y,s:Q,recovery:J}=this,ee=S(Ci("msgHash",O));if(J==null||![0,1,2,3].includes(J))throw new Error("recovery id invalid");const ae=J===2||J===3?Y+e.n:Y;if(ae>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");const ye=(J&1)===0?"02":"03",Me=l.fromHex(ye+f(ae)),se=c(ae),me=o(-ee*se),be=o(Q*se),xe=l.BASE.multiplyAndAddUnsafe(Me,me,be);if(!xe)throw new Error("point at infinify");return xe.assertValidity(),xe}hasHighS(){return m(this.s)}normalizeS(){return this.hasHighS()?new p(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return Go(this.toDERHex())}toDERHex(){return mr.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Go(this.toCompactHex())}toCompactHex(){return f(this.r)+f(this.s)}}const y={isValidPrivateKey(D){try{return h(D),!0}catch{return!1}},normPrivateKeyToScalar:h,randomPrivateKey:()=>{const D=ab(e.n);return UR(e.randomBytes(D),e.n)},precompute(D=8,O=l.BASE){return O._setWindowSize(D),O.multiply(BigInt(3)),O}};function b(D,O=!0){return l.fromPrivateKey(D).toRawBytes(O)}function E(D){const O=D instanceof Uint8Array,Y=typeof D=="string",Q=(O||Y)&&D.length;return O?Q===s||Q===r:Y?Q===2*s||Q===2*r:D instanceof l}function M(D,O,Y=!0){if(E(D))throw new Error("first arg must be private key");if(!E(O))throw new Error("second arg must be public key");return l.fromHex(O).multiply(h(D)).toRawBytes(Y)}const w=e.bits2int||function(D){const O=Ar(D),Y=D.length*8-e.nBitLength;return Y>0?O>>BigInt(Y):O},S=e.bits2int_modN||function(D){return o(w(D))},T=uf(e.nBitLength);function C(D){if(typeof D!="bigint")throw new Error("bigint expected");if(!(cs<=D&&D<T))throw new Error(`bigint expected < 2^${e.nBitLength}`);return Fa(D,e.nByteLength)}function v(D,O,Y=F){if(["recovered","canonical"].some(et=>et in Y))throw new Error("sign() legacy options not supported");const{hash:Q,randomBytes:J}=e;let{lowS:ee,prehash:ae,extraEntropy:ye}=Y;ee==null&&(ee=!0),D=Ci("msgHash",D),ae&&(D=Ci("prehashed msgHash",Q(D)));const Me=S(D),se=h(O),me=[C(se),C(Me)];if(ye!=null){const et=ye===!0?J(t.BYTES):ye;me.push(Ci("extraEntropy",et))}const be=Ho(...me),xe=Me;function Pe(et){const Qe=w(et);if(!d(Qe))return;const St=c(Qe),ut=l.BASE.multiply(Qe).toAffine(),Je=o(ut.x);if(Je===cs)return;const G=o(St*o(xe+Je*se));if(G===cs)return;let mn=(ut.x===Je?0:2)|Number(ut.y&ri),dt=G;return ee&&m(G)&&(dt=A(G),mn^=1),new p(Je,dt,mn)}return{seed:be,k2sig:Pe}}const F={lowS:e.lowS,prehash:!1},K={lowS:e.lowS,prehash:!1};function q(D,O,Y=F){const{seed:Q,k2sig:J}=v(D,O,Y),ee=e;return tb(ee.hash.outputLen,ee.nByteLength,ee.hmac)(Q,J)}l.BASE._setWindowSize(8);function $(D,O,Y,Q=K){const J=D;if(O=Ci("msgHash",O),Y=Ci("publicKey",Y),"strict"in Q)throw new Error("options.strict was renamed to lowS");const{lowS:ee,prehash:ae}=Q;let ye,Me;try{if(typeof J=="string"||J instanceof Uint8Array)try{ye=p.fromDER(J)}catch(ut){if(!(ut instanceof mr.Err))throw ut;ye=p.fromCompact(J)}else if(typeof J=="object"&&typeof J.r=="bigint"&&typeof J.s=="bigint"){const{r:ut,s:Je}=J;ye=new p(ut,Je)}else throw new Error("PARSE");Me=l.fromHex(Y)}catch(ut){if(ut.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(ee&&ye.hasHighS())return!1;ae&&(O=e.hash(O));const{r:se,s:me}=ye,be=S(O),xe=c(me),Pe=o(be*xe),et=o(se*xe),Qe=l.BASE.multiplyAndAddUnsafe(Me,Pe,et)?.toAffine();return Qe?o(Qe.x)===se:!1}return{CURVE:e,getPublicKey:b,getSharedSecret:M,sign:q,verify:$,ProjectivePoint:l,Signature:p,utils:y}}function KR(i){return{hash:i,hmac:(e,...t)=>F0(i,e,qT(...t)),randomBytes:KT}}function jR(i,e){const t=n=>qR({...i,...KR(n)});return Object.freeze({...t(e),create:t})}const lb=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),hb=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),XR=BigInt(1),gf=BigInt(2),ub=(i,e)=>(i+e/gf)/e;function YR(i){const e=lb,t=BigInt(3),n=BigInt(6),s=BigInt(11),r=BigInt(22),a=BigInt(23),o=BigInt(44),c=BigInt(88),l=i*i*i%e,h=l*l*i%e,u=si(h,t,e)*h%e,d=si(u,t,e)*h%e,f=si(d,gf,e)*l%e,m=si(f,s,e)*f%e,A=si(m,r,e)*m%e,g=si(A,o,e)*A%e,p=si(g,c,e)*g%e,y=si(p,o,e)*A%e,b=si(y,t,e)*h%e,E=si(b,a,e)*m%e,M=si(E,n,e)*l%e,w=si(M,gf,e);if(!mf.eql(mf.sqr(w),i))throw new Error("Cannot find square root");return w}const mf=kR(lb,void 0,void 0,{sqrt:YR}),Ws=jR({a:BigInt(0),b:BigInt(7),Fp:mf,n:hb,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:i=>{const e=hb,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-XR*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),r=t,a=BigInt("0x100000000000000000000000000000000"),o=ub(r*i,e),c=ub(-n*i,e);let l=Hn(i-o*t-c*s,e),h=Hn(-o*n-c*r,e);const u=l>a,d=h>a;if(u&&(l=e-l),d&&(h=e-h),l>a||h>a)throw new Error("splitScalar: Endomorphism failed, k="+i);return{k1neg:u,k1:l,k2neg:d,k2:h}}}},L0);BigInt(0),Ws.ProjectivePoint;const Vo="0x0000000000000000000000000000000000000000",db="0x0000000000000000000000000000000000000000000000000000000000000000",fb=BigInt(0),pb=BigInt(1),bf=BigInt(2),Ab=BigInt(27),gb=BigInt(28),Vl=BigInt(35),mb=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),JR=mb/bf,ZR=Symbol.for("nodejs.util.inspect.custom"),br={};function xf(i){return is(Zt(i),32)}class Gt{#e;#t;#n;#i;get r(){return this.#e}set r(e){V(Ma(e)===32,"invalid r","value",e),this.#e=Ce(e)}get s(){return V(parseInt(this.#t.substring(0,3))<8,"non-canonical s; use ._s","s",this.#t),this.#t}set s(e){V(Ma(e)===32,"invalid s","value",e),this.#t=Ce(e)}get _s(){return this.#t}isValid(){return BigInt(this.#t)<=JR}get v(){return this.#n}set v(e){const t=ht(e,"value");V(t===27||t===28,"invalid v","v",e),this.#n=t}get networkV(){return this.#i}get legacyChainId(){const e=this.networkV;return e==null?null:Gt.getChainId(e)}get yParity(){return this.v===27?0:1}get yParityAndS(){const e=lt(this.s);return this.yParity&&(e[0]|=128),Ce(e)}get compactSerialized(){return Ot([this.r,this.yParityAndS])}get serialized(){return Ot([this.r,this.s,this.yParity?"0x1c":"0x1b"])}constructor(e,t,n,s){Dl(e,br,"Signature"),this.#e=t,this.#t=n,this.#n=s,this.#i=null}getCanonical(){if(this.isValid())return this;const e=mb-BigInt(this._s),t=55-this.v,n=new Gt(br,this.r,xf(e),t);return this.networkV&&(n.#i=this.networkV),n}clone(){const e=new Gt(br,this.r,this._s,this.v);return this.networkV&&(e.#i=this.networkV),e}toJSON(){const e=this.networkV;return{_type:"signature",networkV:e!=null?e.toString():null,r:this.r,s:this._s,v:this.v}}[ZR](){return this.toString()}toString(){return this.isValid()?`Signature { r: ${this.r}, s: ${this._s}, v: ${this.v} }`:`Signature { r: ${this.r}, s: ${this._s}, v: ${this.v}, valid: false }`}static getChainId(e){const t=Re(e,"v");return t==Ab||t==gb?fb:(V(t>=Vl,"invalid EIP-155 v","v",e),(t-Vl)/bf)}static getChainIdV(e,t){return Re(e)*bf+BigInt(35+t-27)}static getNormalizedV(e){const t=Re(e);return t===fb||t===Ab?27:t===pb||t===gb?28:(V(t>=Vl,"invalid v","v",e),t&pb?27:28)}static from(e){function t(l,h){V(l,h,"signature",e)}if(e==null)return new Gt(br,db,db,27);if(typeof e=="string"){const l=lt(e,"signature");if(l.length===64){const h=Ce(l.slice(0,32)),u=l.slice(32,64),d=u[0]&128?28:27;return u[0]&=127,new Gt(br,h,Ce(u),d)}if(l.length===65){const h=Ce(l.slice(0,32)),u=Ce(l.slice(32,64)),d=Gt.getNormalizedV(l[64]);return new Gt(br,h,u,d)}t(!1,"invalid raw signature length")}if(e instanceof Gt)return e.clone();const n=e.r;t(n!=null,"missing r");const s=xf(n),r=(function(l,h){if(l!=null)return xf(l);if(h!=null){t(Ft(h,32),"invalid yParityAndS");const u=lt(h);return u[0]&=127,Ce(u)}t(!1,"missing s")})(e.s,e.yParityAndS),{networkV:a,v:o}=(function(l,h,u){if(l!=null){const d=Re(l);return{networkV:d>=Vl?d:void 0,v:Gt.getNormalizedV(d)}}if(h!=null)return t(Ft(h,32),"invalid yParityAndS"),{v:lt(h)[0]&128?28:27};if(u!=null){switch(ht(u,"sig.yParity")){case 0:return{v:27};case 1:return{v:28}}t(!1,"invalid yParity")}t(!1,"missing v")})(e.v,e.yParityAndS,e.yParity),c=new Gt(br,s,r,o);return a&&(c.#i=a),t(e.yParity==null||ht(e.yParity,"sig.yParity")===c.yParity,"yParity mismatch"),t(e.yParityAndS==null||e.yParityAndS===c.yParityAndS,"yParityAndS mismatch"),c}}class ls{#e;constructor(e){V(Ma(e)===32,"invalid private key","privateKey","[REDACTED]"),this.#e=Ce(e)}get privateKey(){return this.#e}get publicKey(){return ls.computePublicKey(this.#e)}get compressedPublicKey(){return ls.computePublicKey(this.#e,!0)}sign(e){V(Ma(e)===32,"invalid digest length","digest",e);const t=Ws.sign(Dn(e),Dn(this.#e),{lowS:!0});return Gt.from({r:Os(t.r,32),s:Os(t.s,32),v:t.recovery?28:27})}computeSharedSecret(e){const t=ls.computePublicKey(e);return Ce(Ws.getSharedSecret(Dn(this.#e),lt(t),!1))}static computePublicKey(e,t){let n=lt(e,"key");if(n.length===32){const r=Ws.getPublicKey(n,!!t);return Ce(r)}if(n.length===64){const r=new Uint8Array(65);r[0]=4,r.set(n,1),n=r}const s=Ws.ProjectivePoint.fromHex(n);return Ce(s.toRawBytes(t))}static recoverPublicKey(e,t){V(Ma(e)===32,"invalid digest length","digest",e);const n=Gt.from(t);let s=Ws.Signature.fromCompact(Dn(Ot([n.r,n.s])));s=s.addRecoveryBit(n.yParity);const r=s.recoverPublicKey(Dn(e));return V(r!=null,"invalid signature for digest","signature",t),"0x"+r.toHex(!1)}static addPoints(e,t,n){const s=Ws.ProjectivePoint.fromHex(ls.computePublicKey(e).substring(2)),r=Ws.ProjectivePoint.fromHex(ls.computePublicKey(t).substring(2));return"0x"+s.add(r).toHex(!!n)}}const $R=BigInt(0),eN=BigInt(36);function bb(i){i=i.toLowerCase();const e=i.substring(2).split(""),t=new Uint8Array(40);for(let s=0;s<40;s++)t[s]=e[s].charCodeAt(0);const n=lt($t(t));for(let s=0;s<40;s+=2)n[s>>1]>>4>=8&&(e[s]=e[s].toUpperCase()),(n[s>>1]&15)>=8&&(e[s+1]=e[s+1].toUpperCase());return"0x"+e.join("")}const _f={};for(let i=0;i<10;i++)_f[String(i)]=String(i);for(let i=0;i<26;i++)_f[String.fromCharCode(65+i)]=String(10+i);const xb=15;function tN(i){i=i.toUpperCase(),i=i.substring(4)+i.substring(0,2)+"00";let e=i.split("").map(n=>_f[n]).join("");for(;e.length>=xb;){let n=e.substring(0,xb);e=parseInt(n,10)%97+e.substring(n.length)}let t=String(98-parseInt(e,10)%97);for(;t.length<2;)t="0"+t;return t}const nN=(function(){const i={};for(let e=0;e<36;e++){const t="0123456789abcdefghijklmnopqrstuvwxyz"[e];i[t]=BigInt(e)}return i})();function iN(i){i=i.toLowerCase();let e=$R;for(let t=0;t<i.length;t++)e=e*eN+nN[i[t]];return e}function Ct(i){if(V(typeof i=="string","invalid address","address",i),i.match(/^(0x)?[0-9a-fA-F]{40}$/)){i.startsWith("0x")||(i="0x"+i);const e=bb(i);return V(!i.match(/([A-F].*[a-f])|([a-f].*[A-F])/)||e===i,"bad address checksum","address",i),e}if(i.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){V(i.substring(2,4)===tN(i),"bad icap checksum","address",i);let e=iN(i.substring(4)).toString(16);for(;e.length<40;)e="0"+e;return bb("0x"+e)}V(!1,"invalid address","address",i)}function sN(i){const e=Ct(i.from);let n=Re(i.nonce,"tx.nonce").toString(16);return n==="0"?n="0x":n.length%2?n="0x0"+n:n="0x"+n,Ct(Vt($t(rs([e,n])),12))}function _b(i){return i&&typeof i.getAddress=="function"}async function Ef(i,e){const t=await e;return(t==null||t==="0x0000000000000000000000000000000000000000")&&(pe(typeof i!="string","unconfigured name","UNCONFIGURED_NAME",{value:i}),V(!1,"invalid AddressLike value; did not resolve to a value address","target",i)),Ct(t)}function Pn(i,e){if(typeof i=="string")return i.match(/^0x[0-9a-f]{40}$/i)?Ct(i):(pe(e!=null,"ENS resolution requires a provider","UNSUPPORTED_OPERATION",{operation:"resolveName"}),Ef(i,e.resolveName(i)));if(_b(i))return Ef(i,i.getAddress());if(i&&typeof i.then=="function")return Ef(i,i);V(!1,"unsupported addressable value","target",i)}const hs={};function Be(i,e){let t=!1;return e<0&&(t=!0,e*=-1),new Wt(hs,`${t?"":"u"}int${e}`,i,{signed:t,width:e})}function xt(i,e){return new Wt(hs,`bytes${e||""}`,i,{size:e})}const Eb=Symbol.for("_ethers_typed");class Wt{type;value;#e;_typedSymbol;constructor(e,t,n,s){s==null&&(s=null),Dl(hs,e,"Typed"),Xe(this,{_typedSymbol:Eb,type:t,value:n}),this.#e=s,this.format()}format(){if(this.type==="array")throw new Error("");if(this.type==="dynamicArray")throw new Error("");return this.type==="tuple"?`tuple(${this.value.map(e=>e.format()).join(",")})`:this.type}defaultValue(){return 0}minValue(){return 0}maxValue(){return 0}isBigInt(){return!!this.type.match(/^u?int[0-9]+$/)}isData(){return this.type.startsWith("bytes")}isString(){return this.type==="string"}get tupleName(){if(this.type!=="tuple")throw TypeError("not a tuple");return this.#e}get arrayLength(){if(this.type!=="array")throw TypeError("not an array");return this.#e===!0?-1:this.#e===!1?this.value.length:null}static from(e,t){return new Wt(hs,e,t)}static uint8(e){return Be(e,8)}static uint16(e){return Be(e,16)}static uint24(e){return Be(e,24)}static uint32(e){return Be(e,32)}static uint40(e){return Be(e,40)}static uint48(e){return Be(e,48)}static uint56(e){return Be(e,56)}static uint64(e){return Be(e,64)}static uint72(e){return Be(e,72)}static uint80(e){return Be(e,80)}static uint88(e){return Be(e,88)}static uint96(e){return Be(e,96)}static uint104(e){return Be(e,104)}static uint112(e){return Be(e,112)}static uint120(e){return Be(e,120)}static uint128(e){return Be(e,128)}static uint136(e){return Be(e,136)}static uint144(e){return Be(e,144)}static uint152(e){return Be(e,152)}static uint160(e){return Be(e,160)}static uint168(e){return Be(e,168)}static uint176(e){return Be(e,176)}static uint184(e){return Be(e,184)}static uint192(e){return Be(e,192)}static uint200(e){return Be(e,200)}static uint208(e){return Be(e,208)}static uint216(e){return Be(e,216)}static uint224(e){return Be(e,224)}static uint232(e){return Be(e,232)}static uint240(e){return Be(e,240)}static uint248(e){return Be(e,248)}static uint256(e){return Be(e,256)}static uint(e){return Be(e,256)}static int8(e){return Be(e,-8)}static int16(e){return Be(e,-16)}static int24(e){return Be(e,-24)}static int32(e){return Be(e,-32)}static int40(e){return Be(e,-40)}static int48(e){return Be(e,-48)}static int56(e){return Be(e,-56)}static int64(e){return Be(e,-64)}static int72(e){return Be(e,-72)}static int80(e){return Be(e,-80)}static int88(e){return Be(e,-88)}static int96(e){return Be(e,-96)}static int104(e){return Be(e,-104)}static int112(e){return Be(e,-112)}static int120(e){return Be(e,-120)}static int128(e){return Be(e,-128)}static int136(e){return Be(e,-136)}static int144(e){return Be(e,-144)}static int152(e){return Be(e,-152)}static int160(e){return Be(e,-160)}static int168(e){return Be(e,-168)}static int176(e){return Be(e,-176)}static int184(e){return Be(e,-184)}static int192(e){return Be(e,-192)}static int200(e){return Be(e,-200)}static int208(e){return Be(e,-208)}static int216(e){return Be(e,-216)}static int224(e){return Be(e,-224)}static int232(e){return Be(e,-232)}static int240(e){return Be(e,-240)}static int248(e){return Be(e,-248)}static int256(e){return Be(e,-256)}static int(e){return Be(e,-256)}static bytes1(e){return xt(e,1)}static bytes2(e){return xt(e,2)}static bytes3(e){return xt(e,3)}static bytes4(e){return xt(e,4)}static bytes5(e){return xt(e,5)}static bytes6(e){return xt(e,6)}static bytes7(e){return xt(e,7)}static bytes8(e){return xt(e,8)}static bytes9(e){return xt(e,9)}static bytes10(e){return xt(e,10)}static bytes11(e){return xt(e,11)}static bytes12(e){return xt(e,12)}static bytes13(e){return xt(e,13)}static bytes14(e){return xt(e,14)}static bytes15(e){return xt(e,15)}static bytes16(e){return xt(e,16)}static bytes17(e){return xt(e,17)}static bytes18(e){return xt(e,18)}static bytes19(e){return xt(e,19)}static bytes20(e){return xt(e,20)}static bytes21(e){return xt(e,21)}static bytes22(e){return xt(e,22)}static bytes23(e){return xt(e,23)}static bytes24(e){return xt(e,24)}static bytes25(e){return xt(e,25)}static bytes26(e){return xt(e,26)}static bytes27(e){return xt(e,27)}static bytes28(e){return xt(e,28)}static bytes29(e){return xt(e,29)}static bytes30(e){return xt(e,30)}static bytes31(e){return xt(e,31)}static bytes32(e){return xt(e,32)}static address(e){return new Wt(hs,"address",e)}static bool(e){return new Wt(hs,"bool",!!e)}static bytes(e){return new Wt(hs,"bytes",e)}static string(e){return new Wt(hs,"string",e)}static array(e,t){throw new Error("not implemented yet")}static tuple(e,t){throw new Error("not implemented yet")}static overrides(e){return new Wt(hs,"overrides",Object.assign({},e))}static isTyped(e){return e&&typeof e=="object"&&"_typedSymbol"in e&&e._typedSymbol===Eb}static dereference(e,t){if(Wt.isTyped(e)){if(e.type!==t)throw new Error(`invalid type: expecetd ${t}, got ${e.type}`);return e.value}return e}}class rN extends os{constructor(e){super("address","address",e,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(e,t){let n=Wt.dereference(t,"string");try{n=Ct(n)}catch(s){return this._throwError(s.message,t)}return e.writeValue(n)}decode(e){return Ct(Os(e.readValue(),20))}}class aN extends os{coder;constructor(e){super(e.name,e.type,"_",e.dynamic),this.coder=e}defaultValue(){return this.coder.defaultValue()}encode(e,t){return this.coder.encode(e,t)}decode(e){return this.coder.decode(e)}}function yb(i,e,t){let n=[];if(Array.isArray(t))n=t;else if(t&&typeof t=="object"){let c={};n=e.map(l=>{const h=l.localName;return pe(h,"cannot encode object for signature with missing names","INVALID_ARGUMENT",{argument:"values",info:{coder:l},value:t}),pe(!c[h],"cannot encode object for signature with duplicate names","INVALID_ARGUMENT",{argument:"values",info:{coder:l},value:t}),c[h]=!0,t[h]})}else V(!1,"invalid tuple value","tuple",t);V(e.length===n.length,"types/value length mismatch","tuple",t);let s=new Zd,r=new Zd,a=[];e.forEach((c,l)=>{let h=n[l];if(c.dynamic){let u=r.length;c.encode(r,h);let d=s.writeUpdatableValue();a.push(f=>{d(f+u)})}else c.encode(s,h)}),a.forEach(c=>{c(s.length)});let o=i.appendWriter(s);return o+=i.appendWriter(r),o}function wb(i,e){let t=[],n=[],s=i.subReader(0);return e.forEach(r=>{let a=null;if(r.dynamic){let o=i.readIndex(),c=s.subReader(o);try{a=r.decode(c)}catch(l){if(En(l,"BUFFER_OVERRUN"))throw l;a=l,a.baseType=r.name,a.name=r.localName,a.type=r.type}}else try{a=r.decode(i)}catch(o){if(En(o,"BUFFER_OVERRUN"))throw o;a=o,a.baseType=r.name,a.name=r.localName,a.type=r.type}if(a==null)throw new Error("investigate");t.push(a),n.push(r.localName||null)}),as.fromItems(t,n)}class oN extends os{coder;length;constructor(e,t,n){const s=e.type+"["+(t>=0?t:"")+"]",r=t===-1||e.dynamic;super("array",s,n,r),Xe(this,{coder:e,length:t})}defaultValue(){const e=this.coder.defaultValue(),t=[];for(let n=0;n<this.length;n++)t.push(e);return t}encode(e,t){const n=Wt.dereference(t,"array");Array.isArray(n)||this._throwError("expected array value",n);let s=this.length;s===-1&&(s=n.length,e.writeValue(n.length)),r0(n.length,s,"coder array"+(this.localName?" "+this.localName:""));let r=[];for(let a=0;a<n.length;a++)r.push(this.coder);return yb(e,r,n)}decode(e){let t=this.length;t===-1&&(t=e.readIndex(),pe(t*Ln<=e.dataLength,"insufficient data length","BUFFER_OVERRUN",{buffer:e.bytes,offset:t*Ln,length:e.dataLength}));let n=[];for(let s=0;s<t;s++)n.push(new aN(this.coder));return wb(e,n)}}class cN extends os{constructor(e){super("bool","bool",e,!1)}defaultValue(){return!1}encode(e,t){const n=Wt.dereference(t,"bool");return e.writeValue(n?1:0)}decode(e){return!!e.readValue()}}class vb extends os{constructor(e,t){super(e,e,t,!0)}defaultValue(){return"0x"}encode(e,t){t=Dn(t);let n=e.writeValue(t.length);return n+=e.writeBytes(t),n}decode(e){return e.readBytes(e.readIndex(),!0)}}class lN extends vb{constructor(e){super("bytes",e)}decode(e){return Ce(super.decode(e))}}class hN extends os{size;constructor(e,t){let n="bytes"+String(e);super(n,n,t,!1),Xe(this,{size:e},{size:"number"})}defaultValue(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+this.size*2)}encode(e,t){let n=Dn(Wt.dereference(t,this.type));return n.length!==this.size&&this._throwError("incorrect data length",t),e.writeBytes(n)}decode(e){return Ce(e.readBytes(this.size))}}const uN=new Uint8Array([]);class dN extends os{constructor(e){super("null","",e,!1)}defaultValue(){return null}encode(e,t){return t!=null&&this._throwError("not null",t),e.writeBytes(uN)}decode(e){return e.readBytes(0),null}}const fN=BigInt(0),pN=BigInt(1),AN=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");class gN extends os{size;signed;constructor(e,t,n){const s=(t?"int":"uint")+e*8;super(s,s,n,!1),Xe(this,{size:e,signed:t},{size:"number",signed:"boolean"})}defaultValue(){return 0}encode(e,t){let n=Re(Wt.dereference(t,this.type)),s=ko(AN,Ln*8);if(this.signed){let r=ko(s,this.size*8-1);(n>r||n<-(r+pN))&&this._throwError("value out-of-bounds",t),n=l0(n,8*Ln)}else(n<fN||n>ko(s,this.size*8))&&this._throwError("value out-of-bounds",t);return e.writeValue(n)}decode(e){let t=ko(e.readValue(),this.size*8);return this.signed&&(t=vT(t,this.size*8)),t}}class mN extends vb{constructor(e){super("string",e)}defaultValue(){return""}encode(e,t){return super.encode(e,ss(Wt.dereference(t,"string")))}decode(e){return Pl(super.decode(e))}}class Wl extends os{coders;constructor(e,t){let n=!1;const s=[];e.forEach(a=>{a.dynamic&&(n=!0),s.push(a.type)});const r="tuple("+s.join(",")+")";super("tuple",r,t,n),Xe(this,{coders:Object.freeze(e.slice())})}defaultValue(){const e=[];this.coders.forEach(n=>{e.push(n.defaultValue())});const t=this.coders.reduce((n,s)=>{const r=s.localName;return r&&(n[r]||(n[r]=0),n[r]++),n},{});return this.coders.forEach((n,s)=>{let r=n.localName;!r||t[r]!==1||(r==="length"&&(r="_length"),e[r]==null&&(e[r]=e[s]))}),Object.freeze(e)}encode(e,t){const n=Wt.dereference(t,"tuple");return yb(e,this.coders,n)}decode(e){return wb(e,this.coders)}}function yf(i,e){return{address:Ct(i),storageKeys:e.map((t,n)=>(V(Ft(t,32),"invalid slot",`storageKeys[${n}]`,t),t.toLowerCase()))}}function xr(i){if(Array.isArray(i))return i.map((t,n)=>Array.isArray(t)?(V(t.length===2,"invalid slot set",`value[${n}]`,t),yf(t[0],t[1])):(V(t!=null&&typeof t=="object","invalid address-slot set","value",i),yf(t.address,t.storageKeys)));V(i!=null&&typeof i=="object","invalid access list","value",i);const e=Object.keys(i).map(t=>{const n=i[t].reduce((s,r)=>(s[r]=!0,s),{});return yf(t,Object.keys(n).sort())});return e.sort((t,n)=>t.address.localeCompare(n.address)),e}function Cb(i){return{address:Ct(i.address),nonce:Re(i.nonce!=null?i.nonce:0),chainId:Re(i.chainId!=null?i.chainId:0),signature:Gt.from(i.signature)}}function bN(i){let e;return typeof i=="string"?e=ls.computePublicKey(i,!1):e=i.publicKey,Ct($t("0x"+e.substring(4)).substring(26))}function xN(i,e){return bN(ls.recoverPublicKey(i,e))}const gn=BigInt(0),_N=BigInt(2),EN=BigInt(27),yN=BigInt(28),wN=BigInt(35),vN=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),CN=Symbol.for("nodejs.util.inspect.custom"),wf=4096*32,ql=128;function SN(i){return{blobToKzgCommitment:n=>{if("computeBlobProof"in i){if("blobToKzgCommitment"in i&&typeof i.blobToKzgCommitment=="function")return lt(i.blobToKzgCommitment(Ce(n)))}else if("blobToKzgCommitment"in i&&typeof i.blobToKzgCommitment=="function")return lt(i.blobToKzgCommitment(n));if("blobToKZGCommitment"in i&&typeof i.blobToKZGCommitment=="function")return lt(i.blobToKZGCommitment(Ce(n)));V(!1,"unsupported KZG library","kzg",i)},computeBlobKzgProof:(n,s)=>{if("computeBlobProof"in i&&typeof i.computeBlobProof=="function")return lt(i.computeBlobProof(Ce(n),Ce(s)));if("computeBlobKzgProof"in i&&typeof i.computeBlobKzgProof=="function")return i.computeBlobKzgProof(n,s);if("computeBlobKZGProof"in i&&typeof i.computeBlobKZGProof=="function")return lt(i.computeBlobKZGProof(Ce(n),Ce(s)));V(!1,"unsupported KZG library","kzg",i)}}}function Sb(i,e){let t=i.toString(16);for(;t.length<2;)t="0"+t;return t+=Ra(e).substring(4),"0x"+t}function Da(i){return i==="0x"?null:Ct(i)}function Kl(i,e){try{return xr(i)}catch(t){V(!1,t.message,e,i)}}function IN(i,e){try{if(!Array.isArray(i))throw new Error("authorizationList: invalid array");const t=[];for(let n=0;n<i.length;n++){const s=i[n];if(!Array.isArray(s))throw new Error(`authorization[${n}]: invalid array`);if(s.length!==6)throw new Error(`authorization[${n}]: wrong length`);if(!s[1])throw new Error(`authorization[${n}]: null address`);t.push({address:Da(s[1]),nonce:Tt(s[2],"nonce"),chainId:Tt(s[0],"chainId"),signature:Gt.from({yParity:_r(s[3],"yParity"),r:is(s[4],32),s:is(s[5],32)})})}return t}catch(t){V(!1,t.message,e,i)}}function _r(i,e){return i==="0x"?0:ht(i,e)}function Tt(i,e){if(i==="0x")return gn;const t=Re(i,e);return V(t<=vN,"value exceeds uint size",e,t),t}function gt(i,e){const t=Re(i,"value"),n=Zt(t);return V(n.length<=32,"value too large",`tx.${e}`,t),n}function jl(i){return xr(i).map(e=>[e.address,e.storageKeys])}function MN(i){return i.map(e=>[gt(e.chainId,"chainId"),e.address,gt(e.nonce,"nonce"),gt(e.signature.yParity,"yParity"),Zt(e.signature.r),Zt(e.signature._s)])}function BN(i,e){V(Array.isArray(i),`invalid ${e}`,"value",i);for(let t=0;t<i.length;t++)V(Ft(i[t],32),"invalid ${ param } hash",`value[${t}]`,i[t]);return i}function TN(i){const e=Uo(i);V(Array.isArray(e)&&(e.length===9||e.length===6),"invalid field count for legacy transaction","data",i);const t={type:0,nonce:_r(e[0],"nonce"),gasPrice:Tt(e[1],"gasPrice"),gasLimit:Tt(e[2],"gasLimit"),to:Da(e[3]),value:Tt(e[4],"value"),data:Ce(e[5]),chainId:gn};if(e.length===6)return t;const n=Tt(e[6],"v"),s=Tt(e[7],"r"),r=Tt(e[8],"s");if(s===gn&&r===gn)t.chainId=n;else{let a=(n-wN)/_N;a<gn&&(a=gn),t.chainId=a,V(a!==gn||n===EN||n===yN,"non-canonical legacy v","v",e[6]),t.signature=Gt.from({r:is(e[7],32),s:is(e[8],32),v:n})}return t}function RN(i,e){const t=[gt(i.nonce,"nonce"),gt(i.gasPrice||0,"gasPrice"),gt(i.gasLimit,"gasLimit"),i.to||"0x",gt(i.value,"value"),i.data];let n=gn;if(i.chainId!=gn)n=Re(i.chainId,"tx.chainId"),V(!e||e.networkV==null||e.legacyChainId===n,"tx.chainId/sig.v mismatch","sig",e);else if(i.signature){const r=i.signature.legacyChainId;r!=null&&(n=r)}if(!e)return n!==gn&&(t.push(Zt(n)),t.push("0x"),t.push("0x")),rs(t);let s=BigInt(27+e.yParity);return n!==gn?s=Gt.getChainIdV(n,e.v):BigInt(e.v)!==s&&V(!1,"tx.chainId/sig.v mismatch","sig",e),t.push(Zt(s)),t.push(Zt(e.r)),t.push(Zt(e._s)),rs(t)}function Xl(i,e){let t;try{if(t=_r(e[0],"yParity"),t!==0&&t!==1)throw new Error("bad yParity")}catch{V(!1,"invalid yParity","yParity",e[0])}const n=is(e[1],32),s=is(e[2],32),r=Gt.from({r:n,s,yParity:t});i.signature=r}function NN(i){const e=Uo(lt(i).slice(1));V(Array.isArray(e)&&(e.length===9||e.length===12),"invalid field count for transaction type: 2","data",Ce(i));const t={type:2,chainId:Tt(e[0],"chainId"),nonce:_r(e[1],"nonce"),maxPriorityFeePerGas:Tt(e[2],"maxPriorityFeePerGas"),maxFeePerGas:Tt(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:Tt(e[4],"gasLimit"),to:Da(e[5]),value:Tt(e[6],"value"),data:Ce(e[7]),accessList:Kl(e[8],"accessList")};return e.length===9||Xl(t,e.slice(9)),t}function FN(i,e){const t=[gt(i.chainId,"chainId"),gt(i.nonce,"nonce"),gt(i.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),gt(i.maxFeePerGas||0,"maxFeePerGas"),gt(i.gasLimit,"gasLimit"),i.to||"0x",gt(i.value,"value"),i.data,jl(i.accessList||[])];return e&&(t.push(gt(e.yParity,"yParity")),t.push(Zt(e.r)),t.push(Zt(e.s))),Ot(["0x02",rs(t)])}function DN(i){const e=Uo(lt(i).slice(1));V(Array.isArray(e)&&(e.length===8||e.length===11),"invalid field count for transaction type: 1","data",Ce(i));const t={type:1,chainId:Tt(e[0],"chainId"),nonce:_r(e[1],"nonce"),gasPrice:Tt(e[2],"gasPrice"),gasLimit:Tt(e[3],"gasLimit"),to:Da(e[4]),value:Tt(e[5],"value"),data:Ce(e[6]),accessList:Kl(e[7],"accessList")};return e.length===8||Xl(t,e.slice(8)),t}function LN(i,e){const t=[gt(i.chainId,"chainId"),gt(i.nonce,"nonce"),gt(i.gasPrice||0,"gasPrice"),gt(i.gasLimit,"gasLimit"),i.to||"0x",gt(i.value,"value"),i.data,jl(i.accessList||[])];return e&&(t.push(gt(e.yParity,"recoveryParam")),t.push(Zt(e.r)),t.push(Zt(e.s))),Ot(["0x01",rs(t)])}function PN(i){let e=Uo(lt(i).slice(1)),t="3",n=null,s=null;if(e.length===4&&Array.isArray(e[0])){t="3 (network format)";const a=e[1],o=e[2],c=e[3];V(Array.isArray(a),"invalid network format: blobs not an array","fields[1]",a),V(Array.isArray(o),"invalid network format: commitments not an array","fields[2]",o),V(Array.isArray(c),"invalid network format: proofs not an array","fields[3]",c),V(a.length===o.length,"invalid network format: blobs/commitments length mismatch","fields",e),V(a.length===c.length,"invalid network format: blobs/proofs length mismatch","fields",e),s=[];for(let l=0;l<e[1].length;l++)s.push({data:a[l],commitment:o[l],proof:c[l]});e=e[0]}else if(e.length===5&&Array.isArray(e[0])){t="3 (EIP-7594 network format)",n=ht(e[1]);const a=e[2],o=e[3],c=e[4];V(n===1,`unsupported EIP-7594 network format version: ${n}`,"fields[1]",n),V(Array.isArray(a),"invalid EIP-7594 network format: blobs not an array","fields[2]",a),V(Array.isArray(o),"invalid EIP-7594 network format: commitments not an array","fields[3]",o),V(Array.isArray(c),"invalid EIP-7594 network format: proofs not an array","fields[4]",c),V(a.length===o.length,"invalid network format: blobs/commitments length mismatch","fields",e),V(a.length*ql===c.length,"invalid network format: blobs/proofs length mismatch","fields",e),s=[];for(let l=0;l<a.length;l++){const h=[];for(let u=0;u<ql;u++)h.push(c[l*ql+u]);s.push({data:a[l],commitment:o[l],proof:Ot(h)})}e=e[0]}V(Array.isArray(e)&&(e.length===11||e.length===14),`invalid field count for transaction type: ${t}`,"data",Ce(i));const r={type:3,chainId:Tt(e[0],"chainId"),nonce:_r(e[1],"nonce"),maxPriorityFeePerGas:Tt(e[2],"maxPriorityFeePerGas"),maxFeePerGas:Tt(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:Tt(e[4],"gasLimit"),to:Da(e[5]),value:Tt(e[6],"value"),data:Ce(e[7]),accessList:Kl(e[8],"accessList"),maxFeePerBlobGas:Tt(e[9],"maxFeePerBlobGas"),blobVersionedHashes:e[10],blobWrapperVersion:n};s&&(r.blobs=s),V(r.to!=null,`invalid address for transaction type: ${t}`,"data",i),V(Array.isArray(r.blobVersionedHashes),"invalid blobVersionedHashes: must be an array","data",i);for(let a=0;a<r.blobVersionedHashes.length;a++)V(Ft(r.blobVersionedHashes[a],32),`invalid blobVersionedHash at index ${a}: must be length 32`,"data",i);return e.length===11||Xl(r,e.slice(11)),r}function kN(i,e,t){const n=[gt(i.chainId,"chainId"),gt(i.nonce,"nonce"),gt(i.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),gt(i.maxFeePerGas||0,"maxFeePerGas"),gt(i.gasLimit,"gasLimit"),i.to||Vo,gt(i.value,"value"),i.data,jl(i.accessList||[]),gt(i.maxFeePerBlobGas||0,"maxFeePerBlobGas"),BN(i.blobVersionedHashes||[],"blobVersionedHashes")];if(e&&(n.push(gt(e.yParity,"yParity")),n.push(Zt(e.r)),n.push(Zt(e.s)),t)){if(i.blobWrapperVersion!=null){const s=Zt(i.blobWrapperVersion),r=[];for(const{proof:a}of t){const o=lt(a),c=o.length/ql;for(let l=0;l<o.length;l+=c)r.push(o.subarray(l,l+c))}return Ot(["0x03",rs([n,s,t.map(a=>a.data),t.map(a=>a.commitment),r])])}return Ot(["0x03",rs([n,t.map(s=>s.data),t.map(s=>s.commitment),t.map(s=>s.proof)])])}return Ot(["0x03",rs(n)])}function UN(i){const e=Uo(lt(i).slice(1));V(Array.isArray(e)&&(e.length===10||e.length===13),"invalid field count for transaction type: 4","data",Ce(i));const t={type:4,chainId:Tt(e[0],"chainId"),nonce:_r(e[1],"nonce"),maxPriorityFeePerGas:Tt(e[2],"maxPriorityFeePerGas"),maxFeePerGas:Tt(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:Tt(e[4],"gasLimit"),to:Da(e[5]),value:Tt(e[6],"value"),data:Ce(e[7]),accessList:Kl(e[8],"accessList"),authorizationList:IN(e[9],"authorizationList")};return e.length===10||Xl(t,e.slice(10)),t}function ON(i,e){const t=[gt(i.chainId,"chainId"),gt(i.nonce,"nonce"),gt(i.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),gt(i.maxFeePerGas||0,"maxFeePerGas"),gt(i.gasLimit,"gasLimit"),i.to||"0x",gt(i.value,"value"),i.data,jl(i.accessList||[]),MN(i.authorizationList||[])];return e&&(t.push(gt(e.yParity,"yParity")),t.push(Zt(e.r)),t.push(Zt(e.s))),Ot(["0x04",rs(t)])}class Si{#e;#t;#n;#i;#s;#a;#r;#o;#f;#l;#p;#A;#c;#h;#u;#d;#b;#g;get type(){return this.#e}set type(e){switch(e){case null:this.#e=null;break;case 0:case"legacy":this.#e=0;break;case 1:case"berlin":case"eip-2930":this.#e=1;break;case 2:case"london":case"eip-1559":this.#e=2;break;case 3:case"cancun":case"eip-4844":this.#e=3;break;case 4:case"pectra":case"eip-7702":this.#e=4;break;default:V(!1,"unsupported transaction type","type",e)}}get typeName(){switch(this.type){case 0:return"legacy";case 1:return"eip-2930";case 2:return"eip-1559";case 3:return"eip-4844";case 4:return"eip-7702"}return null}get to(){const e=this.#t;return e==null&&this.type===3?Vo:e}set to(e){this.#t=e==null?null:Ct(e)}get nonce(){return this.#i}set nonce(e){this.#i=ht(e,"value")}get gasLimit(){return this.#s}set gasLimit(e){this.#s=Re(e)}get gasPrice(){const e=this.#a;return e==null&&(this.type===0||this.type===1)?gn:e}set gasPrice(e){this.#a=e==null?null:Re(e,"gasPrice")}get maxPriorityFeePerGas(){const e=this.#r;return e??(this.type===2||this.type===3?gn:null)}set maxPriorityFeePerGas(e){this.#r=e==null?null:Re(e,"maxPriorityFeePerGas")}get maxFeePerGas(){const e=this.#o;return e??(this.type===2||this.type===3?gn:null)}set maxFeePerGas(e){this.#o=e==null?null:Re(e,"maxFeePerGas")}get data(){return this.#n}set data(e){this.#n=Ce(e)}get value(){return this.#f}set value(e){this.#f=Re(e,"value")}get chainId(){return this.#l}set chainId(e){this.#l=Re(e)}get signature(){return this.#p||null}set signature(e){this.#p=e==null?null:Gt.from(e)}isValid(){const e=this.signature;if(e&&!e.isValid())return!1;const t=this.authorizationList;if(t){for(const n of t)if(!n.signature.isValid())return!1}return!0}get accessList(){const e=this.#A||null;return e??(this.type===1||this.type===2||this.type===3?[]:null)}set accessList(e){this.#A=e==null?null:xr(e)}get authorizationList(){const e=this.#b||null;return e==null&&this.type===4?[]:e}set authorizationList(e){this.#b=e==null?null:e.map(t=>Cb(t))}get maxFeePerBlobGas(){const e=this.#c;return e==null&&this.type===3?gn:e}set maxFeePerBlobGas(e){this.#c=e==null?null:Re(e,"maxFeePerBlobGas")}get blobVersionedHashes(){let e=this.#h;return e==null&&this.type===3?[]:e}set blobVersionedHashes(e){if(e!=null){V(Array.isArray(e),"blobVersionedHashes must be an Array","value",e),e=e.slice();for(let t=0;t<e.length;t++)V(Ft(e[t],32),"invalid blobVersionedHash",`value[${t}]`,e[t])}this.#h=e}get blobs(){return this.#d==null?null:this.#d.map(e=>Object.assign({},e))}set blobs(e){if(e==null){this.#d=null;return}const t=[],n=[];for(let s=0;s<e.length;s++){const r=e[s];if(Kd(r)){pe(this.#u,"adding a raw blob requires a KZG library","UNSUPPORTED_OPERATION",{operation:"set blobs()"});let a=lt(r);if(V(a.length<=wf,"blob is too large",`blobs[${s}]`,r),a.length!==wf){const l=new Uint8Array(wf);l.set(a),a=l}const o=this.#u.blobToKzgCommitment(a),c=Ce(this.#u.computeBlobKzgProof(a,o));t.push({data:Ce(a),commitment:Ce(o),proof:c}),n.push(Sb(1,o))}else{const a=Ce(r.data),o=Ce(r.commitment),c=Ce(r.proof);t.push({data:a,commitment:o,proof:c}),n.push(Sb(1,o))}}this.#d=t,this.#h=n}get kzg(){return this.#u}set kzg(e){e==null?this.#u=null:this.#u=SN(e)}get blobWrapperVersion(){return this.#g}set blobWrapperVersion(e){this.#g=e}constructor(){this.#e=null,this.#t=null,this.#i=0,this.#s=gn,this.#a=null,this.#r=null,this.#o=null,this.#n="0x",this.#f=gn,this.#l=gn,this.#p=null,this.#A=null,this.#c=null,this.#h=null,this.#u=null,this.#d=null,this.#b=null,this.#g=null}get hash(){return this.signature==null?null:$t(this.#m(!0,!1))}get unsignedHash(){return $t(this.unsignedSerialized)}get from(){return this.signature==null?null:xN(this.unsignedHash,this.signature.getCanonical())}get fromPublicKey(){return this.signature==null?null:ls.recoverPublicKey(this.unsignedHash,this.signature.getCanonical())}isSigned(){return this.signature!=null}#m(e,t){pe(!e||this.signature!=null,"cannot serialize unsigned transaction; maybe you meant .unsignedSerialized","UNSUPPORTED_OPERATION",{operation:".serialized"});const n=e?this.signature:null;switch(this.inferType()){case 0:return RN(this,n);case 1:return LN(this,n);case 2:return FN(this,n);case 3:return kN(this,n,t?this.blobs:null);case 4:return ON(this,n)}pe(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:".serialized"})}get serialized(){return this.#m(!0,!0)}get unsignedSerialized(){return this.#m(!1,!1)}inferType(){const e=this.inferTypes();return e.indexOf(2)>=0?2:e.pop()}inferTypes(){const e=this.gasPrice!=null,t=this.maxFeePerGas!=null||this.maxPriorityFeePerGas!=null,n=this.accessList!=null,s=this.#c!=null||this.#h;this.maxFeePerGas!=null&&this.maxPriorityFeePerGas!=null&&pe(this.maxFeePerGas>=this.maxPriorityFeePerGas,"priorityFee cannot be more than maxFee","BAD_DATA",{value:this}),pe(!t||this.type!==0&&this.type!==1,"transaction type cannot have maxFeePerGas or maxPriorityFeePerGas","BAD_DATA",{value:this}),pe(this.type!==0||!n,"legacy transaction cannot have accessList","BAD_DATA",{value:this});const r=[];return this.type!=null?r.push(this.type):this.authorizationList&&this.authorizationList.length?r.push(4):t?r.push(2):e?(r.push(1),n||r.push(0)):n?(r.push(1),r.push(2)):(s&&this.to||(r.push(0),r.push(1),r.push(2)),r.push(3)),r.sort(),r}isLegacy(){return this.type===0}isBerlin(){return this.type===1}isLondon(){return this.type===2}isCancun(){return this.type===3}clone(){return Si.from(this)}toJSON(){const e=t=>t==null?null:t.toString();return{type:this.type,to:this.to,data:this.data,nonce:this.nonce,gasLimit:e(this.gasLimit),gasPrice:e(this.gasPrice),maxPriorityFeePerGas:e(this.maxPriorityFeePerGas),maxFeePerGas:e(this.maxFeePerGas),value:e(this.value),chainId:e(this.chainId),sig:this.signature?this.signature.toJSON():null,accessList:this.accessList}}[CN](){return this.toString()}toString(){const e=[],t=s=>{let r=this[s];typeof r=="string"&&(r=JSON.stringify(r)),e.push(`${s}: ${r}`)};this.type&&t("type"),t("to"),t("data"),t("nonce"),t("gasLimit"),t("value"),this.chainId!=null&&t("chainId"),this.signature&&(t("from"),e.push(`signature: ${this.signature.toString()}`));const n=this.authorizationList;if(n){const s=[];for(const r of n){const a=[];a.push(`address: ${JSON.stringify(r.address)}`),r.nonce!=null&&a.push(`nonce: ${r.nonce}`),r.chainId!=null&&a.push(`chainId: ${r.chainId}`),r.signature&&a.push(`signature: ${r.signature.toString()}`),s.push(`Authorization { ${a.join(", ")} }`)}e.push(`authorizations: [ ${s.join(", ")} ]`)}return`Transaction { ${e.join(", ")} }`}static from(e){if(e==null)return new Si;if(typeof e=="string"){const n=lt(e);if(n[0]>=127)return Si.from(TN(n));switch(n[0]){case 1:return Si.from(DN(n));case 2:return Si.from(NN(n));case 3:return Si.from(PN(n));case 4:return Si.from(UN(n))}pe(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:"from"})}const t=new Si;return e.type!=null&&(t.type=e.type),e.to!=null&&(t.to=e.to),e.nonce!=null&&(t.nonce=e.nonce),e.gasLimit!=null&&(t.gasLimit=e.gasLimit),e.gasPrice!=null&&(t.gasPrice=e.gasPrice),e.maxPriorityFeePerGas!=null&&(t.maxPriorityFeePerGas=e.maxPriorityFeePerGas),e.maxFeePerGas!=null&&(t.maxFeePerGas=e.maxFeePerGas),e.maxFeePerBlobGas!=null&&(t.maxFeePerBlobGas=e.maxFeePerBlobGas),e.data!=null&&(t.data=e.data),e.value!=null&&(t.value=e.value),e.chainId!=null&&(t.chainId=e.chainId),e.signature!=null&&(t.signature=Gt.from(e.signature)),e.accessList!=null&&(t.accessList=e.accessList),e.authorizationList!=null&&(t.authorizationList=e.authorizationList),e.blobVersionedHashes!=null&&(t.blobVersionedHashes=e.blobVersionedHashes),e.kzg!=null&&(t.kzg=e.kzg),e.blobWrapperVersion!=null&&(t.blobWrapperVersion=e.blobWrapperVersion),e.blobs!=null&&(t.blobs=e.blobs),e.hash!=null&&(V(t.isSigned(),"unsigned transaction cannot define '.hash'","tx",e),V(t.hash===e.hash,"hash mismatch","tx",e)),e.from!=null&&(V(t.isSigned(),"unsigned transaction cannot define '.from'","tx",e),V(t.from.toLowerCase()===(e.from||"").toLowerCase(),"from mismatch","tx",e)),t}}function Er(i){return $t(ss(i))}var QN="AEEUdwmgDS8BxQKKAP4BOgDjATAAngDUAIMAoABoAOAAagCOAEQAhABMAHIAOwA9ACsANgAmAGIAHgAuACgAJwAXAC0AGgAjAB8ALwAUACkAEgAeAAkAGwARABkAFgA5ACgALQArADcAFQApABAAHgAiABAAGgAeABMAGAUhBe8BFxREN8sF2wC5AK5HAW8ArQkDzQCuhzc3NzcBP68NEfMABQdHBuw5BV8FYAA9MzkI9r4ZBg7QyQAWA9CeOwLNCjcCjqkChuA/lm+RAsXTAoP6ASfnEQDytQFJAjWVCkeXAOsA6godAB/cwdAUE0WlBCN/AQUCQRjFD/MRBjHxDQSJbw0jBzUAswBxme+tnIcAYwabAysG8QAjAEMMmxcDqgPKQyDXCMMxA7kUQwD3NXOrAKmFIAAfBC0D3x4BJQDBGdUFAhEgVD8JnwmQJiNWYUzrg0oAGwAUAB0AFnNcACkAFgBP9h3gPfsDOWDKneY2ChglX1UDYD30ABsAFAAdABZzIGRAnwDD8wAjAEEMzRbDqgMB2sAFYwXqAtCnAsS4AwpUJKRtFHsadUz9AMMVbwLpABM1NJEX0ZkCgYMBEyMAxRVvAukAEzUBUFAtmUwSAy4DBTER33EftQHfSwB5MxJ/AjkWKQLzL8E/cwBB6QH9LQDPDtO9ASNriQC5DQANAwCK21EFI91zHwCoL9kBqQcHBwcHKzUDowBvAQohPvU3fAQgHwCyAc8CKQMA5zMSezr7ULgFmDp/LzVQBgEGAi8FYQVgt8AFcTtlQhpCWEmfe5tmZ6IAExsDzQ8t+X8rBKtTAltbAn0jsy8Bl6utPWMDTR8Ei2kRANkDBrNHNysDBzECQWUAcwFpJ3kAiyUhAJ0BUb8AL3EfAbfNAz81KUsFWwF3YQZtAm0A+VEfAzEJDQBRSQCzAQBlAHsAM70GD/v3IZWHBwARKQAxALsjTwHZAeMPEzmXgIHwABIAGQA8AEUAQDt3gdvIEGcQZAkGTRFMdEIVEwK0D64L7REdDNkq09PgADSxB/MDWwfzA1sDWwfzB/MDWwfzA1sDWwNbA1scEvAi28gQZw9QBHUFlgWTBN4IiyZREYkHMAjaVBV0JhxPA00BBCMtSSQ7mzMTJUpMFE0LCAQ2SmyvfUADTzGzVP2QqgPTMlc5dAkGHnkSqAAyD3skNb1OhnpPcagKU0+2tYdJak5vAsY6sEAACikJm2/Dd1YGRRAfJ6kQ+ww3AbkBPw3xS9wE9QY/BM0fgRkdD9GVoAipLeEM8SbnLqWAXiP5KocF8Uv4POELUVFsD10LaQnnOmeBUgMlAREijwrhDT0IcRD3Cs1vDekRSQc9A9lJngCpBwULFR05FbkmFGKwCw05ewb/GvoLkyazEy17AAXXGiUGUQEtGwMA0y7rhbRaNVwgT2MGBwspI8sUrFAkDSlAu3hMGh8HGSWtApVDdEqLUToelyH6PEENai4XUYAH+TwJGVMLhTyiRq9FEhHWPpE9TCJNTDAEOYMsMyePCdMPiQy9fHYBXQklCbUMdRM1ERs3yQg9Bx0xlygnGQglRplgngT7owP3E9UDDwVDCUUHFwO5HDETMhUtBRGBKNsC9zbZLrcCk1aEARsFzw8pH+MQVEfkDu0InwJpA4cl7wAxFSUAGyKfCEdnAGOP3FMJLs8Iy2pwI3gDaxTrZRF3B5UOWwerHDcVwxzlcMxeD4YMKKezCV8BeQmdAWME5wgNNV+MpCBFZ1eLXBifIGVBQ14AAjUMaRWjRMGHfAKPD28SHwE5AXcHPQ0FAnsR8RFvEJkI74YINbkz/DopBFMhhyAVCisDU2zSCysm/Qz8bQGnEmYDEDRBd/Jnr2C6KBgBBx0yyUFkIfULlk/RDKAaxRhGVDIZ6AfDA/ca9yfuQVsGAwOnBxc6UTPyBMELbQiPCUMATQ6nGwfbGG4KdYzUATWPAbudA1uVhwJzkwY7Bw8Aaw+LBX3pACECqwinAAkA0wNbAD0CsQehAB0AiUUBQQMrMwEl6QKTA5cINc8BmTMB9y0EH8cMGQD7O25OAsO1AoBuZqYF4VwCkgJNOQFRKQQJUktVA7N15QDfAE8GF+NLARmvTs8e50cB43MvAMsA/wAJOQcJRQHRAfdxALsBYws1Caa3uQFR7S0AhwAZbwHbAo0A4QA5AIP1AVcAUQVd/QXXAlNNARU1HC9bZQG/AyMBNwERAH0Gz5GpzQsjBHEH1wIQHxXlAu8yB7kFAyLjE9FCyQK94lkAMhoKPAqrCqpgX2Q3CjV2PVQAEh+sPss/UgVVO1c7XDtXO1w7VztcO1c7XDtXO1wDm8Pmw+YKcF9JYe8Mqg3YRMw6TRPfYFVgNhPMLbsUxRXSJVoZQRrAJwkl6FUNDwgt12Y0CDA0eRfAAEMpbINFY4oeNApPHOtTlVT8LR8AtUumM7MNsBsZREQFS3XxYi4WEgomAmSFAmJGX1GzAV83JAKh+wJonAJmDQKfiDgfDwJmPwJmKgRyBIMDfxcDfpY5Cjl7GzmGOicnAmwhAjI6OA4CbcsCbbLzjgM3a0kvAWsA4gDlAE4JB5wMkQECD8YAEbkCdzMCdqZDAnlPRwJ4viFg30WyRvcCfEMCeswCfQ0CfPRIBEiBZygALxlJXEpfGRtK0ALRBQLQ0EsrA4hTA4fqRMmRNgLypV0HAwOyS9JMMSkH001QTbMCi0MCitzFHwshR2sJuwKOOwKOYESbhQKO3QKOYHxRuFM5AQ5S2FSJApP/ApMQAO0AIFUiVbNV1AosHymZijLleGpFPz0Cl6MC77ZYJawAXSkClpMCloCgAK1ZsFoNhVEAPwKWuQKWUlxIXNUCmc8CmWhczl0LHQKcnznGOqECnBoCn58CnryOACETNS4TAp31Ap6WALlBYThh8wKe1wKgcgGtAp6jIwKeUqljzGQrKS8CJ7MCJoICoP8CoFDbAqYzAqXSAqgDAIECp/ZogGi1AAdNaiBq1QKs5wKssgKtawKtBgJXIQJV4AKx5dsDH1JsmwKywRECsuwbbORtZ21MYwMl0QK2YD9DbpQDKUkCuGICuUsZArkue3A6cOUCvR0DLbYDMhUCvoxyBgMzdQK+HnMmc1MCw88CwwhzhnRPOUl05AM8qwEDPJ4DPcMCxYACxksCxhSNAshtVQLISALJUwLJMgJkoQLd1nh9ZXiyeSlL1AMYp2cGAmH4GfeVKHsPXpZevxUCz28Cz3AzT1fW9xejAMqxAs93AS3uA04Wfk8JAtwrAtuOAtJTA1JgA1NjAQUDVZCAjUMEzxrxZEl5A4LSg5EC2ssC2eKEFIRNp0ADhqkAMwNkEoZ1Xf0AWQLfaQLevHd7AuIz7RgB8zQrAfSfAfLWiwLr9wLpdH0DAur9AuroAP1LAb0C7o0C66CWrpcHAu5DA4XkmH1w5HGlAvMHAG0DjhqZlwL3FwORcgOSiwL3nAL53QL4apogmq+/O5siA52HAv7+AR8APZ8gAZ+3AwWRA6ZuA6bdANXJAwZuoYyiCQ0DDE0BEwEjB3EGZb1rCQC/BG/DFY8etxEAG3k9ACcDNxJRA42DAWcrJQCM8wAlAOanC6OVCLsGI6fJBgCvBRnDBvElRUYFFoAFcD9GSDNCKUK8X3kZX8QAls0FOgCQVCGbwTsuYDoZutcONxjOGJHJ/gVfBWAFXwVgBWsFYAVfBWAFXwVgBV8FYAVfBWBOHQjfjW8KCgoKbF7xMwTRA7kGN8PDAMMEr8MA70gxFroFTj5xPnhCR0K+X30/X/AAWBkzswCNBsxzzASm70aCRS4rDDMeLz49fnXfcsH5GcoscQFz13Y4HwVnBXLJycnACNdRYwgICAqEXoWTxgA7P4kACxbZBu21Kw0AjMsTAwkVAOVtJUUsJ1JCuULESUArXy9gPi9AKwnJRQYKTD9LPoA+iT54PnkCkULEUUpDX9NWV3JVEjQAc1w3A3IBE3YnX+g7QiMJb6MKaiszRCUuQrNCxDPMCcwEX9EWJzYREBEEBwIHKn6l33JCNVIfybPJtAltydPUCmhBZw/tEKsZAJOVJU1CLRuxbUHOQAo7P0s+eEJHHA8SJVRPdGM0NVrpvBoKhfUlM0JHHGUQUhEWO1xLSj8MO0ucNAqJIzVCRxv9EFsqKyA4OQgNj2nwZgp5ZNFgE2A1K3YHS2AhQQojJmC7DgpzGG1WYFUZCQYHZO9gHWCdYIVgu2BTYJlwFh8GvRbcXbG8YgtDHrMBwzPVyQonHQgkCyYBgQJ0Ajc4nVqIAwGSCsBPIgDsK3SWEtIVBa5N8gGjAo+kVwVIZwD/AEUSCDweX4ITrRQsJ8K3TwBXFDwEAB0TvzVcAtoTS20RIwDgVgZ9BBImYgA5AL4Coi8LFnezOkCnIQFjAY4KBAPh9RcGsgZSBsEAJctdsWIRu2kTkQstRw7DAcMBKgpPBGIGMDAwKCYnKTQaLg4AKRSVAFwCdl+YUZ0JdicFD3lPAdt1F9ZZKCGxuE3yBxkFVGcA/wBFEgiCBwAOLHQSjxOtQDg1z7deFRMAZ8QTAGtKb1ApIiPHADkAvgKiLy1DFtYCmBiDAlDDWNB0eo7fpaMO/aEVRRv0ATEQZBIODyMEAc8JQhCbDRgzFD4TAEMAu9YBCgCsAOkAm5I3ABwAYxvONnR+MhXJAxgKQyxL2+kkJhMbhQKDBMkSsvF0AD9BNQ6uQC7WqSQHwxEAEEIu1hkhAH2z4iQPwyJPHNWpdyYBRSpnJALzoBAEVPPsH20MxA0CCEQKRgAFyAtFAlMNwwjEDUQJRArELtapMg7DDZgJIw+TGukEIwvDFkMAqAtDEMMMBhioe+QAO3MMRAACrgnEBSPY9Q0FDnbSBoMAB8MSYxkSxAEJAPIJAAB8FWMOFtMc/HcXwxhDAC7DAvOowwAewwJdKDKHAAHDAALrFUQVwwAbwyvzpWMWv8wA/ABpAy++bcYDUKPD0KhDCwKmJ1MAAmMA5+UZwxAagwipBRL/eADfw6fDGOMCGsOjk3l6BwOpo4sAEsMOGxMAA5sAbcMOAAvDp0MJGkMDwgipnNIPAwfIqUMGAOGDAAPzABXDAAcDAAnDAGmTABrDAA7DChjDjnEWAwABYwAOcwAuUyYABsMAF8MIKQANUgC6wy4AA8MADqMq8wCyYgAcIwAB8wqpAAXOCx0V4wAHowBCwwEKAGnDAAuDAB3DAAjDCakABdIAbqcZ3QCZCCkABdIAAAFDAAfjAB2jCCkABqIACYMAGzMAbSMA5sOIAAhjAAhDABTDBAkpAAbSAOOTAAlDC6kOzPtnAAdDAG6kQFAATwAKwwwAA0MACbUDPwAHIwAZgwACE6cDAAojAApDAAoDp/MGwwAJIwADEwAQQwgAFEMAEXMAD5MADfMADcMAGRMOFiMAFUMAbqMWuwHDAMIAE0MLAGkzEgDhUwACQwAEWgAXgwUjAAbYABjDBSYBgzBaAEFNALcQBxUMegAwMngBrA0IZgJ0KxQHBREPd1N0ZzKRJwaIHAZqNT4DqQq8BwngAB4DAwt2AX56T1ocKQNXAh1GATQGC3tOxYNagkgAMQA5CQADAQEAWxLjAIOYNAEzAH7tFRk6TglSAF8NAAlYAQ+S1ACAQwQorQBiAN4dAJ1wPyeTANVzuQDX3AIeEMp9eyMgXiUAEdkBkJizKltbVVAaRMqRAAEAhyQ/SDEz6BmfVwB6ATEsOClKIRcDOF0E/832AFNt5AByAnkCRxGCOs94NjXdAwINGBonDBwPALW2AwICAgAAAAAAAAYDBQMDARrUAwAtAAAAAgEGBgYGBgYFBQUFBQUEBQYHCAkEBQUFBQQAAAICAAAAIgCNAJAAlT0A6gC7ANwApEQAwgCyAK0AqADuAKYA2gCjAOcBCAEDAMcAgQBiANIA1AEDAN4A8gCQAKkBMQDqAN8A3AsBCQ8yO9ra2tq8xuLT1tRJOB0BUgFcNU0BWgFpAWgBWwFMUUlLbhMBUxsNEAs6PhMOACcUKy0vMj5AQENDQ0RFFEYGJFdXV1dZWVhZL1pbXVxcI2NnZ2ZoZypsbnZ1eHh4eHh4enp6enp6enp6enp8fH18e2IARPIASQCaAHgAMgBm+ACOAFcAVwA3AnbvAIsABfj4AGQAk/IAnwBPAGIAZP//sACFAIUAaQBWALEAJAC2AIMCQAJDAPwA5wD+AP4A6AD/AOkA6QDoAOYALwJ7AVEBQAE+AVQBPgE+AT4BOQE4ATgBOAEcAVgXADEQCAEAUx8SHgsdHhYAjgCWAKYAUQBqIAIxAHYAbwCXAxUDJzIDIUlGTzEAkQJPAMcCVwKkAMAClgKWApYClgKWApYCiwKWApYClgKWApYClgKVApUCmAKgApcClgKWApQClAKUApQCkgKVAnUB1AKXAp8ClgKWApUeAIETBQD+DQOfAmECOh8BVBg9AuIZEjMbAU4/G1WZAXusRAFpYQEFA0FPAQYAmTEeIJdyADFoAHEANgCRA5zMk/C2jGINwjMWygIZCaXdfDILBCs5dAE7YnQBugDlhoiHhoiGiYqKhouOjIaNkI6Ij4qQipGGkoaThpSSlYaWhpeKmIaZhpqGm4aci52QnoqfhuIC4XTpAt90AIp0LHSoAIsAdHQEQwRABEIERQRDBEkERgRBBEcESQRIBEQERgRJAJ5udACrA490ALxuAQ10ANFZdHQA13QCFHQA/mJ0AP4BIQD+APwA/AD9APwDhGZ03ASMK23HAP4A/AD8AP0A/CR0dACRYnQA/gCRASEA/gCRAvQA/gCRA4RmdNwEjCttxyR0AP9idAEhAP4A/gD8APwA/QD8AP8A/AD8AP0A/AOEZnTcBIwrbcckdHQAkWJ0ASEA/gCRAP4AkQL0AP4AkQOEZnTcBIwrbcckdAJLAT50AlIBQXQCU8l0dAJfdHQDpgL0A6YDpgOnA6cDpwOnA4RmdNwEjCttxyR0dACRYnQBIQOmAJEDpgCRAvQDpgCRA4RmdNwEjCttxyR0BDh0AJEEOQCRDpU5dSgCADR03gV2CwArdAEFAM5iCnR0AF1iAAYcOgp0dACRCnQAXAEIwWZ0CnRmdHQAkWZ0CnRmdEXgAFF03gp0dEY0tlT2u3SOAQTwscwhjZZKrhYcBSfFp9XNbKiVDOD2b+cpe4/Z17mQnbtzzhaeQtE2GGj0IDNTjRUSyTxxw/RPHW/+vS7d1NfRt9z9QPZg4X7QFfhCnkvgNPIItOsC2eV6hPannZNHlZ9xrwZXIMOlu3jSoQSq78WEjwLjw1ELSlF1aBvfzwk5ZX7AUvQzjPQKbDuQ+sm4wNOp4A6AdVuRS0t1y/DZpg4R6m7FNjM9HgvW7Bi88zaMjOo6lM8wtBBdj8LP4ylv3zCXPhebMKJc066o9sF71oFW/8JXu86HJbwDID5lzw5GWLR/LhT0Qqnp2JQxNZNfcbLIzPy+YypqRm/lBmGmex+82+PisxUumSeJkALIT6rJezxMH+CTJmQtt5uwTVbL3ptmjDUQzlSIvWi8Tl7ng1NpuRn1Ng4n14Qc+3Iil7OwkvNWogLSPkn3pihIFytyIGmMhOe3n1tWsuMy9BdKyqF4Z3v2SgggTL9KVvMXPnCbRe+oOuFFP3HejBG/w9gvmfNYvg6JuWia2lcSSN1uIjBktzoIazOHPJZ7kKHPz8mRWVdW3lA8WGF9dQF6Bm673boov3BUWDU2JNcahR23GtfHKLOz/viZ+rYnZFaIznXO67CYEJ1fXuTRpZhYZkKe54xeoagkNGLs+NTZHE0rX45/XvQ2RGADX6vcAvdxIUBV27wxGm2zjZo4X3ILgAlrOFheuZ6wtsvaIj4yLY7qqawlliaIcrz2G+c3vscAnCkCuMzMmZvMfu9lLwTvfX+3cVSyPdN9ZwgDZhfjRgNJcLiJ67b9xx8JHswprbiE3v9UphotAPIgnXVIN5KmMc0piXhc6cChPnN+MRhG9adtdttQTTwSIpl8I4/j//d3sz1326qTBTpPRM/Hgh3kzqEXs8ZAk4ErQhNO8hzrQ0DLkWMA/N+91tn2MdOJnWC2FCZehkQrwzwbKOjhvZsbM95QoeL9skYyMf4srVPVJSgg7pOLUtr/n9eT99oe9nLtFRpjA9okV2Kj8h9k5HaC0oivRD8VyXkJ81tcd4fHNXPCfloIQasxsuO18/46dR2jgul/UIet2G0kRvnyONMKhHs6J26FEoqSqd+rfYjeEGwHWVDpX1fh1jBBcKGMqRepju9Y00mDVHC+Xdij/j44rKfvfjGinNs1jO/0F3jB83XCDINN/HB84axlP+3E/klktRo+vl3U/aiyMJbIodE1XSsDn6UAzIoMtUObY2+k/4gY/l+AkZJ5Sj2vQrkyLm3FoxjhDX+31UXBFf9XrAH31fFqoBmDEZvhvvpnZ87N+oZEu7U9O/nnk+QWj3x8uyoRbEnf+O5UMr9i0nHP38IF5AvzrBW8YWBUR0mIAzIvndQq9N3v/Jto3aPjPXUPl8ASdPPyAp7jENf8bk7VMM9ol9XGmlBmeDMuGqt+WzuL6CXAxXjIhCPM5vACchgMJ/8XBGLO/D1isVvGhwwHHr1DLaI5mn2Jr/b1pUD90uciDaS8cXNDzCWvNmT/PhQe5e8nTnnnkt8Ds/SIjibcum/fqDhKopxAY8AkSrPn+IGDEKOO+U3XOP6djFs2H5N9+orhOahiQk5KnEUWa+CzkVzhp8bMHRbg81qhjjXuIKbHjSLSIBKWqockGtKinY+z4/RdBUF6pcc3JmnlxVcNgrI4SEzKUZSwcD2QCyxzKve+gAmg6ZuSRkpPFa6mfThu7LJNu3H5K42uCpNvPAsoedolKV/LHe/eJ+BbaG5MG0NaSGVPRUmNFMFFSSpXEcXwbVh7UETOZZtoVNRGOIbbkig3McEtR68cG0RZAoJevWYo7Dg/lZ1CQzblWeUvVHmr8fY4Nqd9JJiH/zEX24mJviH60fAyFr0A3c4bC1j3yZU60VgJxXn8JgJXLUIsiBnmKmMYz+7yBQFBvqb2eYnuW59joZBf56/wXvWIR4R8wTmV80i1mZy+S4+BUES+hzjk0uXpC///z/IlqHZ1monzlXp8aCfhGKMti73FI1KbL1q6IKO4fuBuZ59gagjn5xU79muMpHXg6S+e+gDM/U9BKLHbl9l6o8czQKl4RUkJJiqftQG2i3BMg/TQlUYFkJDYBOOvAugYuzYSDnZbDDd/aSd9x0Oe6F+bJcHfl9+gp6L5/TgA+BdFFovbfCrQ40s5vMPw8866pNX8zyFGeFWdxIpPVp9Rg1UPOVFbFZrvaFq/YAzHQgqMWpahMYfqHpmwXfHL1/kpYmGuHFwT55mQu0dylfNuq2Oq0hTMCPwqfxnuBIPLXfci4Y1ANy+1CUipQxld/izVh16WyG2Q0CQQ9NqtAnx1HCHwDj7sYxOSB0wopZSnOzxQOcExmxrVTF2BkOthVpGfuhaGECfCJpJKpjnihY+xOT2QJxN61+9K6QSqtv2Shr82I3jgJrqBg0wELFZPjvHpvzTtaJnLK6Vb97Yn933koO/saN7fsjwNKzp4l2lJVx2orjCGzC/4ZL4zCver6aQYtC5sdoychuFE6ufOiog+VWi5UDkbmvmtah/3aArEBIi39s5ILUnlFLgilcGuz9CQshEY7fw2ouoILAYPVT/gyAIq3TFAIwVsl+ktkRz/qGfnCDGrm5gsl/l9QdvCWGsjPz3dU7XuqKfdUrr/6XIgjp4rey6AJBmCmUJMjITHVdFb5m1p+dLMCL8t55zD42cmftmLEJC0Da04YiRCVUBLLa8D071/N5UBNBXDh0LFsmhV/5B5ExOB4j3WVG/S3lfK5o+V6ELHvy6RR9n4ac+VsK4VE4yphPvV+kG9FegTBH4ZRXL2HytUHCduJazB/KykjfetYxOXTLws267aGOd+I+JhKP//+VnXmS90OD/jvLcVu0asyqcuYN1mSb6XTlCkqv1vigZPIYwNF/zpWcT1GR/6aEIRjkh0yhg4LXJfaGobYJTY4JI58KiAKgmmgAKWdl5nYCeLqavRJGQNuYuZtZFGx+IkI4w4NS2xwbetNMunOjBu/hmKCI/w7tfiiyUd//4rbTeWt4izBY8YvGIN6vyKYmP/8X8wHKCeN+WRcKM70+tXKNGyevU9H2Dg5BsljnTf8YbsJ1TmMs74Ce2XlHisleguhyeg44rQOHZuw/6HTkhnnurK2d62q6yS7210SsAIaR+jXMQA+svkrLpsUY+F30Uw89uOdGAR6vo4FIME0EfVVeHTu6eKicfhSqOeXJhbftcd08sWEnNUL1C9fnprTgd83IMut8onVUF0hvqzZfHduPjbjwEXIcoYmy+P6tcJZHmeOv6VrvEdkHDJecjHuHeWANe79VG662qTjA/HCvumVv3qL+LrOcpqGps2ZGwQdFJ7PU4iuyRlBrwfO+xnPyr47s2cXVbWzAyznDiBGjCM3ksxjjqM62GE9C8f5U38kB3VjtabKp/nRdvMESPGDG90bWRLAt1Qk5DyLuazRR1YzdC1c+hZXvAWV8xA72S4A8B67vjVhbba3MMop293FeEXpe7zItMWrJG/LOH9ByOXmYnNJfjmfuX9KbrpgLOba4nZ+fl8Gbdv/ihv+6wFGKHCYrVwmhFC0J3V2bn2tIB1wCc1CST3d3X2OyxhguXcs4sm679UngzofuSeBewMFJboIQHbUh/m2JhW2hG9DIvG2t7yZIzKBTz9wBtnNC+2pCRYhSIuQ1j8xsz5VvqnyUIthvuoyyu7fNIrg/KQUVmGQaqkqZk/Vx5b33/gsEs8yX7SC1J+NV4icz6bvIE7C5G6McBaI8rVg56q5QBJWxn/87Q1sPK4+sQa8fLU5gXo4paaq4cOcQ4wR0VBHPGjKh+UlPCbA1nLXyEUX45qZ8J7/Ln4FPJE2TdzD0Z8MLSNQiykMMmSyOCiFfy84Rq60emYB2vD09KjYwsoIpeDcBDTElBbXxND72yhd9pC/1CMid/5HUMvAL27OtcIJDzNKpRPNqPOpyt2aPGz9QWIs9hQ9LiX5s8m9hjTUu/f7MyIatjjd+tSfQ3ufZxPpmJhTaBtZtKLUcfOCUqADuO+QoH8B9v6U+P0HV1GLQmtoNFTb3s74ivZgjES0qfK+8RdGgBbcCMSy8eBvh98+et1KIFqSe1KQPyXULBMTsIYnysIwiZBJYdI20vseV+wuJkcqGemehKjaAb9L57xZm3g2zX0bZ2xk/fU+bCo7TlnbW7JuF1YdURo/2Gw7VclDG1W7LOtas2LX4upifZ/23rzpsnY/ALfRgrcWP5hYmV9VxVOQA1fZvp9F2UNU+7d7xRyVm5wiLp3/0dlV7vdw1PMiZrbDAYzIVqEjRY2YU03sJhPnlwIPcZUG5ltL6S8XCxU1eYS5cjr34veBmXAvy7yN4ZjArIG0dfD/5UpBNlX1ZPoxJOwyqRi3wQWtOzd4oNKh0LkoTm8cwqgIfKhqqGOhwo71I+zXnMemTv2B2AUzABWyFztGgGULjDDzWYwJUVBTjKCn5K2QGMK1CQT7SzziOjo+BhAmqBjzuc3xYym2eedGeOIRJVyTwDw37iCMe4g5Vbnsb5ZBdxOAnMT7HU4DHpxWGuQ7GeiY30Cpbvzss55+5Km1YsbD5ea3NI9QNYIXol5apgSu9dZ8f8xS5dtHpido5BclDuLWY4lhik0tbJa07yJhH0BOyEut/GRbYTS6RfiTYWGMCkNpfSHi7HvdiTglEVHKZXaVhezH4kkXiIvKopYAlPusftpE4a5IZwvw1x/eLvoDIh/zpo9FiQInsTb2SAkKHV42XYBjpJDg4374XiVb3ws4qM0s9eSQ5HzsMU4OZJKuopFjBM+dAZEl8RUMx5uU2N486Kr141tVsGQfGjORYMCJAMsxELeNT4RmWjRcpdTGBwcx6XN9drWqPmJzcrGrH4+DRc7+n1w3kPZwu0BkNr6hQrqgo7JTB9A5kdJ/H7P4cWBMwsmuixAzJB3yrQpnGIq90lxAXLzDCdn1LPibsRt7rHNjgQBklRgPZ8vTbjXdgXrTWQsK5MdrXXQVPp0Rinq3frzZKJ0qD6Qhc40VzAraUXlob1gvkhK3vpmHgI6FRlQZNx6eRqkp0zy4AQlX813fAPtL3jMRaitGFFjo0zmErloC+h+YYdVQ6k4F/epxAoF0BmqEoKNTt6j4vQZNQ2BoqF9Vj53TOIoNmDiu9Xp15RkIgQIGcoLpfoIbenzpGUAtqFJp5W+LLnx38jHeECTJ/navKY1NWfN0sY1T8/pB8kIH3DU3DX+u6W3YwpypBMYOhbSxGjq84RZ84fWJow8pyHqn4S/9J15EcCMsXqrfwyd9mhiu3+rEo9pPpoJkdZqHjra4NvzFwuThNKy6hao/SlLw3ZADUcUp3w3SRVfW2rhl80zOgTYnKE0Hs2qp1J6H3xqPqIkvUDRMFDYyRbsFI3M9MEyovPk8rlw7/0a81cDVLmBsR2ze2pBuKb23fbeZC0uXoIvDppfTwIDxk1Oq2dGesGc+oJXWJLGkOha3CX+DUnzgAp9HGH9RsPZN63Hn4RMA5eSVhPHO+9RcRb/IOgtW31V1Q5IPGtoxPjC+MEJbVlIMYADd9aHYWUIQKopuPOHmoqSkubnAKnzgKHqgIOfW5RdAgotN6BN+O2ZYHkuemLnvQ8U9THVrS1RtLmKbcC7PeeDsYznvqzeg6VCNwmr0Yyx1wnLjyT84BZz3EJyCptD3yeueAyDWIs0L2qs/VQ3HUyqfrja0V1LdDzqAikeWuV4sc7RLIB69jEIBjCkyZedoUHqCrOvShVzyd73OdrJW0hPOuQv2qOoHDc9xVb6Yu6uq3Xqp2ZaH46A7lzevbxQEmfrzvAYSJuZ4WDk1Hz3QX1LVdiUK0EvlAGAYlG3Md30r7dcPN63yqBCIj25prpvZP0nI4+EgWoFG95V596CurXpKRBGRjQlHCvy5Ib/iW8nZJWwrET3mgd6mEhfP4KCuaLjopWs7h+MdXFdIv8dHQJgg1xi1eYqB0uDYjxwVmri0Sv5XKut/onqapC+FQiC2C1lvYJ9MVco6yDYsS3AANUfMtvtbYI2hfwZatiSsnoUeMZd34GVjkMMKA+XnjJpXgRW2SHTZplVowPmJsvXy6w3cfO1AK2dvtZEKTkC/TY9LFiKHCG0DnrMQdGm2lzlBHM9iEYynH2UcVMhUEjsc0oDBTgo2ZSQ1gzkAHeWeBXYFjYLuuf8yzTCy7/RFR81WDjXMbq2BOH5dURnxo6oivmxL3cKzKInlZkD31nvpHB9Kk7GfcfE1t+1V64b9LtgeJGlpRFxQCAqWJ5DoY77ski8gsOEOr2uywZaoO/NGa0X0y1pNQHBi3b2SUGNpcZxDT7rLbBf1FSnQ8guxGW3W+36BW0gBje4DOz6Ba6SVk0xiKgt+q2JOFyr4SYfnu+Ic1QZYIuwHBrgzr6UvOcSCzPTOo7D6IC4ISeS7zkl4h+2VoeHpnG/uWR3+ysNgPcOIXQbv0n4mr3BwQcdKJxgPSeyuP/z1Jjg4e9nUvoXegqQVIE30EHx5GHv+FAVUNTowYDJgyFhf5IvlYmEqRif6+WN1MkEJmDcQITx9FX23a4mxy1AQRsOHO/+eImX9l8EMJI3oPWzVXxSOeHU1dUWYr2uAA7AMb+vAEZSbU3qob9ibCyXeypEMpZ6863o6QPqlqGHZkuWABSTVNd4cOh9hv3qEpSx2Zy/DJMP6cItEmiBJ5PFqQnDEIt3NrA3COlOSgz43D7gpNFNJ5MBh4oFzhDPiglC2ypsNU4ISywY2erkyb1NC3Qh/IfWj0eDgZI4/ln8WPfBsT3meTjq1Uqt1E7Zl/qftqkx6aM9KueMCekSnMrcHj1CqTWWzEzPsZGcDe3Ue4Ws+XFYVxNbOFF8ezkvQGR6ZOtOLU2lQEnMBStx47vE6Pb7AYMBRj2OOfZXfisjJnpTfSNjo6sZ6qSvNxZNmDeS7Gk3yYyCk1HtKN2UnhMIjOXUzAqDv90lx9O/q/AT1ZMnit5XQe9wmQxnE/WSH0CqZ9/2Hy+Sfmpeg8RwsHI5Z8kC8H293m/LHVVM/BA7HaTJYg5Enk7M/xWpq0192ACfBai2LA/qrCjCr6Dh1BIMzMXINBmX96MJ5Hn2nxln/RXPFhwHxUmSV0EV2V0jm86/dxxuYSU1W7sVkEbN9EzkG0QFwPhyHKyb3t+Fj5WoUUTErcazE/N6EW6Lvp0d//SDPj7EV9UdJN+Amnf3Wwk3A0SlJ9Z00yvXZ7n3z70G47Hfsow8Wq1JXcfwnA+Yxa5mFsgV464KKP4T31wqIgzFPd3eCe3j5ory5fBF2hgCFyVFrLzI9eetNXvM7oQqyFgDo4CTp/hDV9NMX9JDHQ/nyHTLvZLNLF6ftn2OxjGm8+PqOwhxnPHWipkE/8wbtyri80Sr7pMNkQGMfo4ZYK9OcCC4ESVFFbLMIvlxSoRqWie0wxqnLfcLSXMSpMMQEJYDVObYsXIQNv4TGNwjq1kvT1UOkicTrG3IaBZ3XdScS3u8sgeZPVpOLkbiF940FjbCeNRINNvDbd01EPBrTCPpm12m43ze1bBB59Ia6Ovhnur/Nvx3IxwSWol+3H2qfCJR8df6aQf4v6WiONxkK+IqT4pKQrZK/LplgDI/PJZbOep8dtbV7oCr6CgfpWa8NczOkPx81iSHbsNhVSJBOtrLIMrL31LK9TqHqAbAHe0RLmmV806kRLDLNEhUEJfm9u0sxpkL93Zgd6rw+tqBfTMi59xqXHLXSHwSbSBl0EK0+loECOPtrl+/nsaFe197di4yUgoe4jKoAJDXc6DGDjrQOoFDWZJ9HXwt8xDrQP+7aRwWKWI1GF8s8O4KzxWBBcwnl3vnl1Oez3oh6Ea1vjR7/z7DDTrFtqU2W/KAEzAuXDNZ7MY73MF216dzdSbWmUp4lcm7keJfWaMHgut9x5C9mj66Z0lJ+yhsjVvyiWrfk1lzPOTdhG15Y7gQlXtacvI7qv/XNSscDwqkgwHT/gUsD5yB7LdRRvJxQGYINn9hTpodKFVSTPrtGvyQw+HlRFXIkodErAGu9Iy1YpfSPc3jkFh5CX3lPxv7aqjE/JAfTIpEjGb/H7MO0e2vsViSW1qa/Lmi4/n4DEI3g7lYrcanspDfEpKkdV1OjSLOy0BCUqVoECaB55vs06rXl4jqmLsPsFM/7vYJ0vrBhDCm/00A/H81l1uekJ/6Lml3Hb9+NKiLqATJmDpyzfYZFHumEjC662L0Bwkxi7E9U4cQA0XMVDuMYAIeLMPgQaMVOd8fmt5SflFIfuBoszeAw7ow5gXPE2Y/yBc/7jExARUf/BxIHQBF5Sn3i61w4z5xJdCyO1F1X3+3ax+JSvMeZ7S6QSKp1Fp/sjYz6Z+VgCZzibGeEoujryfMulH7Rai5kAft9ebcW50DyJr2uo2z97mTWIu45YsSnNSMrrNUuG1XsYBtD9TDYzQffKB87vWbkM4EbPAFgoBV4GQS+vtFDUqOFAoi1nTtmIOvg38N4hT2Sn8r8clmBCXspBlMBYTnrqFJGBT3wZOzAyJDre9dHH7+x7qaaKDOB4UQALD5ecS0DE4obubQEiuJZ0EpBVpLuYcce8Aa4PYd/V4DLDAJBYKQPCWTcrEaZ5HYbJi11Gd6hjGom1ii18VHYnG28NKpkz2UKVPxlhYSp8uZr367iOmoy7zsxehW9wzcy2zG0a80PBMCRQMb32hnaHeOR8fnNDzZhaNYhkOdDsBUZ3loDMa1YP0uS0cjUP3b/6DBlqmZOeNABDsLl5BI5QJups8uxAuWJdkUB/pO6Zax6tsg7fN5mjjDgMGngO+DPcKqiHIDbFIGudxtPTIyDi9SFMKBDcfdGQRv41q1AqmxgkVfJMnP8w/Bc7N9/TR6C7mGObFqFkIEom8sKi2xYqJLTCHK7cxzaZvqODo22c3wisBCP4HeAgcRbNPAsBkNRhSmD48dHupdBRw4mIvtS5oeF6zeT1KMCyhMnmhpkFAGWnGscoNkwvQ8ZM5lE/vgTHFYL99OuNxdFBxTEDd5v2qLR8y9WkXsWgG6kZNndFG+pO/UAkOCipqIhL3hq7cRSdrCq7YhUsTocEcnaFa6nVkhnSeRYUA1YO0z5itF9Sly3VlxYDw239TJJH6f3EUfYO5lb7bcFcz8Bp7Oo8QmnsUHOz/fagVUBtKEw1iT88j+aKkv8cscKNkMxjYr8344D1kFoZ7/td1W6LCNYN594301tUGRmFjAzeRg5vyoM1F6+bJZ/Q54jN/k8SFd3DxPTYaAUsivsBfgTn7Mx8H2SpPt4GOdYRnEJOH6jHM2p6SgB0gzIRq6fHxGMmSmqaPCmlfwxiuloaVIitLGN8wie2CDWhkzLoCJcODh7KIOAqbHEvXdUxaS4TTTs07Clzj/6GmVs9kiZDerMxEnhUB6QQPlcfqkG9882RqHoLiHGBoHfQuXIsAG8GTAtao2KVwRnvvam8jo1e312GQAKWEa4sUVEAMG4G6ckcONDwRcg1e2D3+ohXgY4UAWF8wHKQMrSnzCgfFpsxh+aHXMGtPQroQasRY4U6UdG0rz1Vjbka0MekOGRZQEvqQFlxseFor8zWFgHek3v29+WqN6gaK5gZOTOMZzpQIC1201LkMCXild3vWXSc5UX9xcFYfbRPzGFa1FDcPfPB/jUEq/FeGt419CI3YmBlVoHsa4KdcwQP5ZSwHHhFJ7/Ph/Rap/4vmG91eDwPP0lDfCDRCLszTqfzM71xpmiKi2HwS4WlqvGNwtvwF5Dqpn6KTq8ax00UMPkxDcZrEEEsIvHiUXXEphdb4GB4FymlPwBz4Gperqq5pW7TQ6/yNRhW8VT5NhuP0udlxo4gILq5ZxAZk8ZGh3g4CqxJlPKY7AQxupfUcVpWT5VItp1+30UqoyP4wWsRo3olRRgkWZZ2ZN6VC3OZFeXB8NbnUrSdikNptD1QiGuKkr8EmSR/AK9Rw+FF3s5uwuPbvHGiPeFOViltMK7AUaOsq9+x9cndk3iJEE5LKZRlWJbKOZweROzmPNVPkjE3K/TyA57Rs68TkZ3MR8akKpm7cFjnjPd/DdkWjgYoKHSr5Wu5ssoBYU4acRs5g2DHxUmdq8VXOXRbunD8QN0LhgkssgahcdoYsNvuXGUK/KXD/7oFb+VGdhqIn02veuM5bLudJOc2Ky0GMaG4W/xWBxIJcL7yliJOXOpx0AkBqUgzlDczmLT4iILXDxxtRR1oZa2JWFgiAb43obrJnG/TZC2KSK2wqOzRZTXavZZFMb1f3bXvVaNaK828w9TO610gk8JNf3gMfETzXXsbcvRGCG9JWQZ6+cDPqc4466Yo2RcKH+PILeKOqtnlbInR3MmBeGG3FH10yzkybuqEC2HSQwpA0An7d9+73BkDUTm30bZmoP/RGbgFN+GrCOfADgqr0WbI1a1okpFms8iHYw9hm0zUvlEMivBRxModrbJJ+9/p3jUdQQ9BCtQdxnOGrT5dzRUmw0593/mbRSdBg0nRvRZM5/E16m7ZHmDEtWhwvfdZCZ8J8M12W0yRMszXamWfQTwIZ4ayYktrnscQuWr8idp3PjT2eF/jmtdhIfcpMnb+IfZY2FebW6UY/AK3jP4u3Tu4zE4qlnQgLFbM19EBIsNf7KhjdbqQ/D6yiDb+NlEi2SKD+ivXVUK8ib0oBo366gXkR8ZxGjpJIDcEgZPa9TcYe0TIbiPl/rPUQDu3XBJ9X/GNq3FAUsKsll57DzaGMrjcT+gctp+9MLYXCq+sqP81eVQ0r9lt+gcQfZbACRbEjvlMskztZG8gbC8Qn9tt26Q7y7nDrbZq/LEz7kR6Jc6pg3N9rVX8Y5MJrGlML9p9lU4jbTkKqCveeZUJjHB03m2KRKR2TytoFkTXOLg7keU1s1lrPMQJpoOKLuAAC+y1HlJucU6ysB5hsXhvSPPLq5J7JtnqHKZ4vYjC4Vy8153QY+6780xDuGARsGbOs1WqzH0QS765rnSKEbbKlkO8oI/VDwUd0is13tKpqILu1mDJFNy/iJAWcvDgjxvusIT+PGz3ST/J9r9Mtfd0jpaGeiLYIqXc7DiHSS8TcjFVksi66PEkxW1z6ujbLLUGNNYnzOWpH8BZGK4bCK7iR+MbIv8ncDAz1u4StN3vTTzewr9IQjk9wxFxn+6N1ddKs0vffJiS08N3a4G1SVrlZ97Q/M+8G9fe5AP6d9/Qq4WRnORVhofPIKEdCr3llspUfE0oKIIYoByBRPh+bX1HLS3JWGJRhIvE1aW4NTd8ePi4Z+kXb+Z8snYfSNcqijhAgVsx4RCM54cXUiYkjeBmmC4ajOHrChoELscJJC7+9jjMjw5BagZKlgRMiSNYz7h7vvZIoQqbtQmspc0cUk1G/73iXtSpROl5wtLgQi0mW2Ex8i3WULhcggx6E1LMVHUsdc9GHI1PH3U2Ko0PyGdn9KdVOLm7FPBui0i9a0HpA60MsewVE4z8CAt5d401Gv6zXlIT5Ybit1VIA0FCs7wtvYreru1fUyW3oLAZ/+aTnZrOcYRNVA8spoRtlRoWflsRClFcgzkqiHOrf0/SVw+EpVaFlJ0g4Kxq1MMOmiQdpMNpte8lMMQqm6cIFXlnGbfJllysKDi+0JJMotkqgIxOSQgU9dn/lWkeVf8nUm3iwX2Nl3WDw9i6AUK3vBAbZZrcJpDQ/N64AVwjT07Jef30GSSmtNu2WlW7YoyW2FlWfZFQUwk867EdLYKk9VG6JgEnBiBxkY7LMo4YLQJJlAo9l/oTvJkSARDF/XtyAzM8O2t3eT/iXa6wDN3WewNmQHdPfsxChU/KtLG2Mn8i4ZqKdSlIaBZadxJmRzVS/o4yA65RTSViq60oa395Lqw0pzY4SipwE0SXXsKV+GZraGSkr/RW08wPRvqvSUkYBMA9lPx4m24az+IHmCbXA+0faxTRE9wuGeO06DIXa6QlKJ3puIyiuAVfPr736vzo2pBirS+Vxel3TMm3JKhz9o2ZoRvaFVpIkykb0Hcm4oHFBMcNSNj7/4GJt43ogonY2Vg4nsDQIWxAcorpXACzgBqQPjYsE/VUpXpwNManEru4NwMCFPkXvMoqvoeLN3qyu/N1eWEHttMD65v19l/0kH2mR35iv/FI+yjoHJ9gPMz67af3Mq/BoWXqu3rphiWMXVkmnPSEkpGpUI2h1MThideGFEOK6YZHPwYzMBvpNC7+ZHxPb7epfefGyIB4JzO9DTNEYnDLVVHdQyvOEVefrk6Uv5kTQYVYWWdqrdcIl7yljwwIWdfQ/y+2QB3eR/qxYObuYyB4gTbo2in4PzarU1sO9nETkmj9/AoxDA+JM3GMqQtJR4jtduHtnoCLxd1gQUscHRB/MoRYIEsP2pDZ9KvHgtlk1iTbWWbHhohwFEYX7y51fUV2nuUmnoUcqnWIQAAgl9LTVX+Bc0QGNEhChxHR4YjfE51PUdGfsSFE6ck7BL3/hTf9jLq4G1IafINxOLKeAtO7quulYvH5YOBc+zX7CrMgWnW47/jfRsWnJjYYoE7xMfWV2HN2iyIqLI";const Ib=new Map([[8217,"apostrophe"],[8260,"fraction slash"],[12539,"middle dot"]]),Mb=4;function GN(i){let e=0;function t(){return i[e++]<<8|i[e++]}let n=t(),s=1,r=[0,1];for(let M=1;M<n;M++)r.push(s+=t());let a=t(),o=e;e+=a;let c=0,l=0;function h(){return c==0&&(l=l<<8|i[e++],c=8),l>>--c&1}const u=31,d=2**u,f=d>>>1,m=f>>1,A=d-1;let g=0;for(let M=0;M<u;M++)g=g<<1|h();let p=[],y=0,b=d;for(;;){let M=Math.floor(((g-y+1)*s-1)/b),w=0,S=n;for(;S-w>1;){let v=w+S>>>1;M<r[v]?S=v:w=v}if(w==0)break;p.push(w);let T=y+Math.floor(b*r[w]/s),C=y+Math.floor(b*r[w+1]/s)-1;for(;((T^C)&f)==0;)g=g<<1&A|h(),T=T<<1&A,C=C<<1&A|1;for(;T&~C&m;)g=g&f|g<<1&A>>>1|h(),T=T<<1^f,C=(C^f)<<1|f|1;y=T,b=1+C-T}let E=n-4;return p.map(M=>{switch(M-E){case 3:return E+65792+(i[o++]<<16|i[o++]<<8|i[o++]);case 2:return E+256+(i[o++]<<8|i[o++]);case 1:return E+i[o++];default:return M-1}})}function HN(i){let e=0;return()=>i[e++]}function Bb(i){return HN(GN(zN(i)))}function zN(i){let e=[];[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"].forEach((s,r)=>e[s.charCodeAt(0)]=r);let t=i.length,n=new Uint8Array(6*t>>3);for(let s=0,r=0,a=0,o=0;s<t;s++)o=o<<6|e[i.charCodeAt(s)],a+=6,a>=8&&(n[r++]=o>>(a-=8));return n}function VN(i){return i&1?~i>>1:i>>1}function WN(i,e){let t=Array(i);for(let n=0,s=0;n<i;n++)t[n]=s+=VN(e());return t}function Wo(i,e=0){let t=[];for(;;){let n=i(),s=i();if(!s)break;e+=n;for(let r=0;r<s;r++)t.push(e+r);e+=s+1}return t}function Tb(i){return qo(()=>{let e=Wo(i);if(e.length)return e})}function Rb(i){let e=[];for(;;){let t=i();if(t==0)break;e.push(qN(t,i))}for(;;){let t=i()-1;if(t<0)break;e.push(KN(t,i))}return e.flat()}function qo(i){let e=[];for(;;){let t=i(e.length);if(!t)break;e.push(t)}return e}function Nb(i,e,t){let n=Array(i).fill().map(()=>[]);for(let s=0;s<e;s++)WN(i,t).forEach((r,a)=>n[a].push(r));return n}function qN(i,e){let t=1+e(),n=e(),s=qo(e);return Nb(s.length,1+i,e).flatMap((a,o)=>{let[c,...l]=a;return Array(s[o]).fill().map((h,u)=>{let d=u*n;return[c+u*t,l.map(f=>f+d)]})})}function KN(i,e){let t=1+e();return Nb(t,1+i,e).map(s=>[s[0],s.slice(1)])}function jN(i){let e=[],t=Wo(i);return s(n([]),[]),e;function n(r){let a=i(),o=qo(()=>{let c=Wo(i).map(l=>t[l]);if(c.length)return n(c)});return{S:a,B:o,Q:r}}function s({S:r,B:a},o,c){if(!(r&4&&c===o[o.length-1])){r&2&&(c=o[o.length-1]),r&1&&e.push(o);for(let l of a)for(let h of l.Q)s(l,[...o,h],c)}}}function XN(i){return i.toString(16).toUpperCase().padStart(2,"0")}function Fb(i){return`{${XN(i)}}`}function YN(i){let e=[];for(let t=0,n=i.length;t<n;){let s=i.codePointAt(t);t+=s<65536?1:2,e.push(s)}return e}function La(i){let t=i.length;if(t<4096)return String.fromCodePoint(...i);let n=[];for(let s=0;s<t;)n.push(String.fromCodePoint(...i.slice(s,s+=4096)));return n.join("")}function JN(i,e){let t=i.length,n=t-e.length;for(let s=0;n==0&&s<t;s++)n=i[s]-e[s];return n}var ZN="AEUDTAHBCFQATQDRADAAcgAgADQAFAAsABQAHwAOACQADQARAAoAFwAHABIACAAPAAUACwAFAAwABAAQAAMABwAEAAoABQAIAAIACgABAAQAFAALAAIACwABAAIAAQAHAAMAAwAEAAsADAAMAAwACgANAA0AAwAKAAkABAAdAAYAZwDSAdsDJgC0CkMB8xhZAqfoC190UGcThgBurwf7PT09Pb09AjgJum8OjDllxHYUKXAPxzq6tABAxgK8ysUvWAgMPT09PT09PSs6LT2HcgWXWwFLoSMEEEl5RFVMKvO0XQ8ExDdJMnIgsj26PTQyy8FfEQ8AY8IPAGcEbwRwBHEEcgRzBHQEdQR2BHcEeAR6BHsEfAR+BIAEgfndBQoBYgULAWIFDAFiBNcE2ATZBRAFEQUvBdALFAsVDPcNBw13DYcOMA4xDjMB4BllHI0B2grbAMDpHLkQ7QHVAPRNQQFnGRUEg0yEB2uaJF8AJpIBpob5AERSMAKNoAXqaQLUBMCzEiACnwRZEkkVsS7tANAsBG0RuAQLEPABv9HICTUBXigPZwRBApMDOwAamhtaABqEAY8KvKx3LQ4ArAB8UhwEBAVSagD8AEFZADkBIadVj2UMUgx5Il4ANQC9AxIB1BlbEPMAs30CGxlXAhwZKQIECBc6EbsCoxngzv7UzRQA8M0BawL6ZwkN7wABAD33OQRcsgLJCjMCjqUChtw/km+NAsXPAoP2BT84PwURAK0RAvptb6cApQS/OMMey5HJS84UdxpxTPkCogVFITaTOwERAK5pAvkNBOVyA7q3BKlOJSALAgUIBRcEdASpBXqzABXFSWZOawLCOqw//AolCZdvv3dSBkEQGyelEPcMMwG1ATsN7UvYBPEGOwTJH30ZGQ/NlZwIpS3dDO0m4y6hgFoj9SqDBe1L9DzdC01RaA9ZC2UJ4zpjgU4DIQENIosK3Q05CG0Q8wrJaw3lEUUHOQPVSZoApQcBCxEdNRW1JhBirAsJOXcG+xr2C48mrxMpevwF0xohBk0BKRr/AM8u54WwWjFcHE9fBgMLJSPHFKhQIA0lQLd4SBobBxUlqQKRQ3BKh1E2HpMh9jw9DWYuE1F8B/U8BRlPC4E8nkarRQ4R0j6NPUgiSUwsBDV/LC8niwnPD4UMuXxyAVkJIQmxDHETMREXN8UIOQcZLZckJxUIIUaVYJoE958D8xPRAwsFPwlBBxMDtRwtEy4VKQUNgSTXAvM21S6zAo9WgAEXBcsPJR/fEFBH4A7pCJsCZQODJesALRUhABcimwhDYwBfj9hTBS7LCMdqbCN0A2cU52ERcweRDlcHpxwzFb8c4XDIXguGCCijrwlbAXUJmQFfBOMICTVbjKAgQWdTi1gYmyBhQT9d/AIxDGUVn0S9h3gCiw9rEhsBNQFzBzkNAQJ3Ee0RaxCVCOuGBDW1M/g6JQRPIYMgEQonA09szgsnJvkM+GkBoxJiAww0PXfuZ6tgtiQX/QcZMsVBYCHxC5JPzQycGsEYQlQuGeQHvwPzGvMn6kFXBf8DowMTOk0z7gS9C2kIiwk/AEkOoxcH1xhqCnGM0AExiwG3mQNXkYMCb48GNwcLAGcLhwV55QAdAqcIowAFAM8DVwA5Aq0HnQAZAIVBAT0DJy8BIeUCjwOTCDHLAZUvAfMpBBvDDBUA9zduSgLDsQKAamaiBd1YAo4CSTUBTSUEBU5HUQOvceEA2wBLBhPfRwEVq0rLGuNDAd9vKwDHAPsABTUHBUEBzQHzbQC3AV8LMQmis7UBTekpAIMAFWsB1wKJAN0ANQB/8QFTAE0FWfkF0wJPSQERMRgrV2EBuwMfATMBDQB5BsuNpckHHwRtB9MCEBsV4QLvLge1AQMi3xPNQsUCvd5VoWACZIECYkJbTa9bNyACofcCaJgCZgkCn4Q4GwsCZjsCZiYEbgR/A38TA36SOQY5dxc5gjojIwJsHQIyNjgKAm3HAm2u74ozZ0UrAWcA3gDhAEoFB5gMjQD+C8IADbUCdy8CdqI/AnlLQwJ4uh1c20WuRtcCfD8CesgCfQkCfPAFWQUgSABIfWMkAoFtAoAAAoAFAn+uSVhKWxUXSswC0QEC0MxLJwOITwOH5kTFkTIC8qFdAwMDrkvOTC0lA89NTE2vAos/AorYwRsHHUNnBbcCjjcCjlxAl4ECjtkCjlx4UbRTNQpS1FSFApP7ApMMAOkAHFUeVa9V0AYsGymVhjLheGZFOzkCl58C77JYIagAWSUClo8ClnycAKlZrFoJgU0AOwKWtQKWTlxEXNECmcsCmWRcyl0HGQKcmznCOp0CnBYCn5sCnriKAB0PMSoPAp3xAp6SALU9YTRh7wKe0wKgbgGpAp6fHwKeTqVjyGQnJSsCJ68CJn4CoPsCoEwCot0CocQCpi8Cpc4Cp/8AfQKn8mh8aLEAA0lqHGrRAqzjAqyuAq1nAq0CAlcdAlXcArHh1wMfTmyXArK9DQKy6Bds4G1jbUhfAyXNArZcOz9ukAMpRQK4XgK5RxUCuSp3cDZw4QK9GQK72nCWAzIRAr6IcgIDM3ECvhpzInNPAsPLAsMEc4J0SzVFdOADPKcDPJoDPb8CxXwCxkcCxhCJAshpUQLIRALJTwLJLgJknQLd0nh5YXiueSVL0AMYo2cCAmH0GfOVJHsLXpJeuxECz2sCz2wvS1PS8xOfAMatAs9zASnqA04SfksFAtwnAtuKAtJPA1JcA1NfAQEDVYyAiT8AyxbtYEWCHILTgs6DjQLaxwLZ3oQQhEmnPAOGpQAvA2QOhnFZ+QBVAt9lAt64c3cC4i/tFAHzMCcB9JsB8tKHAuvzAulweQLq+QLq5AD5RwG5Au6JAuuclqqXAwLuPwOF4Jh5cOBxoQLzAwBpA44WmZMC9xMDkW4DkocC95gC+dkC+GaaHJqruzebHgOdgwL++gEbADmfHJ+zAwWNA6ZqA6bZANHFAwZqoYiiBQkDDEkCwAA/AwDhQRdTARHzA2sHl2cFAJMtK7evvdsBiZkUfxEEOQH7KQUhDp0JnwCS/SlXxQL3AZ0AtwW5AG8LbUEuFCaNLgFDAYD8AbUmAHUDDgRtACwCFgyhAAAKAj0CagPdA34EkQEgRQUhfAoABQBEABMANhICdwEABdUDa+8KxQIA9wqfJ7+xt+UBkSFBQgHpFH8RNMCJAAQAGwBaAkUChIsABjpTOpSNbQC4Oo860ACNOME63AClAOgAywE6gTo7Ofw5+Tt2iTpbO56JOm85GAFWATMBbAUvNV01njWtNWY1dTW2NcU1gjWRNdI14TWeNa017jX9NbI1wTYCNhE1xjXVNhY2JzXeNe02LjY9Ni41LSE2OjY9Njw2yTcIBJA8VzY4Nt03IDcPNsogN4k3MAoEsDxnNiQ3GTdsOo03IULUQwdC4EMLHA8PCZsobShRVQYA6X8A6bABFCnXAukBowC9BbcAbwNzBL8MDAMMAQgDAAkKCwsLCQoGBAVVBI/DvwDz9b29kaUCb0QtsRTNLt4eGBcSHAMZFhYZEhYEARAEBUEcQRxBHEEcQRxBHEEaQRxBHEFCSTxBPElISUhBNkM2QTYbNklISVmBVIgBFLWZAu0BhQCjBcEAbykBvwGJAaQcEZ0ePCklMAAhMvAIMAL54gC7Bm8EescjzQMpARQpKgDUABavAj626xQAJP0A3etzuf4NNRA7efy2Z9NQrCnC0OSyANz5BBIbJ5IFDR6miIavYS6tprjjmuKebxm5C74Q225X1pkaYYPb6f1DK4k3xMEBb9S2WMjEibTNWhsRJIA+vwNVEiXTE5iXs/wezV66oFLfp9NZGYW+Gk19J2+bCT6Ye2w6LDYdgzKMUabk595eLBCXANz9HUpWbATq9vqXVx9XDg+Pc9Xp4+bsS005SVM/BJBM4687WUuf+Uj9dEi8aDNaPxtpbDxcG1THTImUMZq4UCaaNYpsVqraNyKLJXDYsFZ/5jl7bLRtO88t7P3xZaAxhb5OdPMXqsSkp1WCieG8jXm1U99+blvLlXzPCS+M93VnJCiK+09LfaSaBAVBomyDgJua8dfUzR7ga34IvR2Nvj+A9heJ6lsl1KG4NkI1032Cnff1m1wof2B9oHJK4bi6JkEdSqeNeiuo6QoZZincoc73/TH9SXF8sCE7XyuYyW8WSgbGFCjPV0ihLKhdPs08Tx82fYAkLLc4I2wdl4apY7GU5lHRFzRWJep7Ww3wbeA3qmd59/86P4xuNaqDpygXt6M85glSBHOCGgJDnt+pN9bK7HApMguX6+06RZNjzVmcZJ+wcUrJ9//bpRNxNuKpNl9uFds+S9tdx7LaM5ZkIrPj6nIU9mnbFtVbs9s/uLgl8MVczAwet+iOEzzBlYW7RCMgE6gyNLeq6+1tIx4dpgZnd0DksJS5f+JNDpwwcPNXaaVspq1fbQajOrJgK0ofKtJ1Ne90L6VO4MOl5S886p7u6xo7OLjG8TGL+HU1JXGJgppg4nNbNJ5nlzSpuPYy21JUEcUA94PoFiZfjZue+QnyQ80ekOuZVkxx4g+cvhJfHgNl4hy1/a6+RKcKlar/J29y//EztlbVPHVUeQ1zX86eQVAjR/M3dA9w4W8LfaXp4EgM85wOWasli837PzVMOnsLzR+k3o75/lRPAJSE1xAKQzEi5v10ke+VBvRt1cwQRMd+U5mLCTGVd6XiZtgBG5cDi0w22GKcVNvHiu5LQbZEDVtz0onn7k5+heuKXVsZtSzilkLRAUmjMXEMB3J9YC50XBxPiz53SC+EhnPl9WsKCv92SM/OFFIMJZYfl0WW8tIO3UxYcwdMAj7FSmgrsZ2aAZO03BOhP1bNNZItyXYQFTpC3SG1VuPDqH9GkiCDmE+JwxyIVSO5siDErAOpEXFgjy6PQtOVDj+s6e1r8heWVvmZnTciuf4EiNZzCAd7SOMhXERIOlsHIMG399i9aLTy3m2hRLZjJVDNLS53iGIK11dPqQt0zBDyg6qc7YqkDm2M5Ve6dCWCaCbTXX2rToaIgz6+zh4lYUi/+6nqcFMAkQJKHYLK0wYk5N9szV6xihDbDDFr45lN1K4aCXBq/FitPSud9gLt5ZVn+ZqGX7cwm2z5EGMgfFpIFyhGGuDPmso6TItTMwny+7uPnLCf4W6goFQFV0oQSsc9VfMmVLcLr6ZetDZbaSFTLqnSO/bIPjA3/zAUoqgGFAEQS4IhuMzEp2I3jJzbzkk/IEmyax+rhZTwd6f+CGtwPixu8IvzACquPWPREu9ZvGkUzpRwvRRuaNN6cr0W1wWits9ICdYJ7ltbgMiSL3sTPeufgNcVqMVWFkCPDH4jG2jA0XcVgQj62Cb29v9f/z/+2KbYvIv/zzjpQAPkliaVDzNrW57TZ/ZOyZD0nlfMmAIBIAGAI0D3k/mdN4xr9v85ZbZbbqfH2jGd5hUqNZWwl5SPfoGmfElmazUIeNL1j/mkF7VNAzTq4jNt8JoQ11NQOcmhprXoxSxfRGJ9LDEOAQ+dmxAQH90iti9e2u/MoeuaGcDTHoC+xsmEeWmxEKefQuIzHbpw5Tc5cEocboAD09oipWQhtTO1wivf/O+DRe2rpl/E9wlrzBorjJsOeG1B/XPW4EaJEFdNlECEZga5ZoGRHXgYouGRuVkm8tDESiEyFNo+3s5M5puSdTyUL2llnINVHEt91XUNW4ewdMgJ4boJfEyt/iY5WXqbA+A2Fkt5Z0lutiWhe9nZIyIUjyXDC3UsaG1t+eNx6z4W/OYoTB7A6x+dNSTOi9AInctbESqm5gvOLww7OWXPrmHwVZasrl4eD113pm+JtT7JVOvnCXqdzzdTRHgJ0PiGTFYW5Gvt9R9LD6Lzfs0v/TZZHSmyVNq7viIHE6DBK7Qp07Iz55EM8SYtQvZf/obBniTWi5C2/ovHfw4VndkE5XYdjOhCMRjDeOEfXeN/CwfGduiUIfsoFeUxXeQXba7c7972XNv8w+dTjjUM0QeNAReW+J014dKAD/McQYXT7c0GQPIkn3Ll6R7gGjuiQoZD0TEeEqQpKoZ15g/0OPQI17QiSv9AUROa/V/TQN3dvLArec3RrsYlvBm1b8LWzltdugsC50lNKYLEp2a+ZZYqPejULRlOJh5zj/LVMyTDvwKhMxxwuDkxJ1QpoNI0OTWLom4Z71SNzI9TV1iXJrIu9Wcnd+MCaAw8o1jSXd94YU/1gnkrC9BUEOtQvEIQ7g0i6h+KL2JKk8Ydl7HruvgWMSAmNe+LshGhV4qnWHhO9/RIPQzY1tHRj2VqOyNsDpK0cww+56AdDC4gsWwY0XxoucIWIqs/GcwnWqlaT0KPr8mbK5U94/301i1WLt4YINTVvCFBrFZbIbY8eycOdeJ2teD5IfPLCRg7jjcFTwlMFNl9zdh/o3E/hHPwj7BWg0MU09pPrBLbrCgm54A6H+I6v27+jL5gkjWg/iYdks9jbfVP5y/n0dlgWEMlKasl7JvFZd56LfybW1eeaVO0gxTfXZwD8G4SI116yx7UKVRgui6Ya1YpixqXeNLc8IxtAwCU5IhwQgn+NqHnRaDv61CxKhOq4pOX7M6pkA+Pmpd4j1vn6ACUALoLLc4vpXci8VidLxzm7qFBe7s+quuJs6ETYmnpgS3LwSZxPIltgBDXz8M1k/W2ySNv2f9/NPhxLGK2D21dkHeSGmenRT3Yqcdl0m/h3OYr8V+lXNYGf8aCCpd4bWjE4QIPj7vUKN4Nrfs7ML6Y2OyS830JCnofg/k7lpFpt4SqZc5HGg1HCOrHvOdC8bP6FGDbE/VV0mX4IakzbdS/op+Kt3G24/8QbBV7y86sGSQ/vZzU8FXs7u6jIvwchsEP2BpIhW3G8uWNwa3HmjfH/ZjhhCWvluAcF+nMf14ClKg5hGgtPLJ98ueNAkc5Hs2WZlk2QHvfreCK1CCGO6nMZVSb99VM/ajr8WHTte9JSmkXq/i/U943HEbdzW6Re/S88dKgg8pGOLlAeNiqrcLkUR3/aClFpMXcOUP3rmETcWSfMXZE3TUOi8i+fqRnTYLflVx/Vb/6GJ7eIRZUA6k3RYR3iFSK9c4iDdNwJuZL2FKz/IK5VimcNWEqdXjSoxSgmF0UPlDoUlNrPcM7ftmA8Y9gKiqKEHuWN+AZRIwtVSxye2Kf8rM3lhJ5XcBXU9n4v0Oy1RU2M+4qM8AQPVwse8ErNSob5oFPWxuqZnVzo1qB/IBxkM3EVUKFUUlO3e51259GgNcJbCmlvrdjtoTW7rChm1wyCKzpCTwozUUEOIcWLneRLgMXh+SjGSFkAllzbGS5HK7LlfCMRNRDSvbQPjcXaenNYxCvu2Qyznz6StuxVj66SgI0T8B6/sfHAJYZaZ78thjOSIFumNWLQbeZixDCCC+v0YBtkxiBB3jefHqZ/dFHU+crbj6OvS1x/JDD7vlm7zOVPwpUC01nhxZuY/63E7g";const Ko=44032,Yl=4352,Jl=4449,Zl=4519,Db=19,Lb=21,Pa=28,$l=Lb*Pa,$N=Db*$l,eF=Ko+$N,tF=Yl+Db,nF=Jl+Lb,iF=Zl+Pa;function jo(i){return i>>24&255}function Pb(i){return i&16777215}let vf,kb,Cf,eh;function sF(){let i=Bb(ZN);vf=new Map(Tb(i).flatMap((e,t)=>e.map(n=>[n,t+1<<24]))),kb=new Set(Wo(i)),Cf=new Map,eh=new Map;for(let[e,t]of Rb(i)){if(!kb.has(e)&&t.length==2){let[n,s]=t,r=eh.get(n);r||(r=new Map,eh.set(n,r)),r.set(s,e)}Cf.set(e,t.reverse())}}function Ub(i){return i>=Ko&&i<eF}function rF(i,e){if(i>=Yl&&i<tF&&e>=Jl&&e<nF)return Ko+(i-Yl)*$l+(e-Jl)*Pa;if(Ub(i)&&e>Zl&&e<iF&&(i-Ko)%Pa==0)return i+(e-Zl);{let t=eh.get(i);return t&&(t=t.get(e),t)?t:-1}}function Ob(i){vf||sF();let e=[],t=[],n=!1;function s(r){let a=vf.get(r);a&&(n=!0,r|=a),e.push(r)}for(let r of i)for(;;){if(r<128)e.push(r);else if(Ub(r)){let a=r-Ko,o=a/$l|0,c=a%$l/Pa|0,l=a%Pa;s(Yl+o),s(Jl+c),l>0&&s(Zl+l)}else{let a=Cf.get(r);a?t.push(...a):s(r)}if(!t.length)break;r=t.pop()}if(n&&e.length>1){let r=jo(e[0]);for(let a=1;a<e.length;a++){let o=jo(e[a]);if(o==0||r<=o){r=o;continue}let c=a-1;for(;;){let l=e[c+1];if(e[c+1]=e[c],e[c]=l,!c||(r=jo(e[--c]),r<=o))break}r=jo(e[a])}}return e}function aF(i){let e=[],t=[],n=-1,s=0;for(let r of i){let a=jo(r),o=Pb(r);if(n==-1)a==0?n=o:e.push(o);else if(s>0&&s>=a)a==0?(e.push(n,...t),t.length=0,n=o):t.push(o),s=a;else{let c=rF(n,o);c>=0?n=c:s==0&&a==0?(e.push(n),n=o):(t.push(o),s=a)}}return n>=0&&e.push(n,...t),e}function Qb(i){return Ob(i).map(Pb)}function oF(i){return aF(Ob(i))}const Gb=45,Hb=".",zb=65039,Vb=1,th=i=>Array.from(i);function Xo(i,e){return i.P.has(e)||i.Q.has(e)}class cF extends Array{get is_emoji(){return!0}}let Sf,Wb,yr,If,qb,ka,Mf,Ua,wr,Kb,Bf;function Tf(){if(Sf)return;let i=Bb(QN);const e=()=>Wo(i),t=()=>new Set(e()),n=(h,u)=>u.forEach(d=>h.add(d));Sf=new Map(Rb(i)),Wb=t(),yr=e(),If=new Set(e().map(h=>yr[h])),yr=new Set(yr),qb=t(),t();let s=Tb(i),r=i();const a=()=>{let h=new Set;return e().forEach(u=>n(h,s[u])),n(h,e()),h};ka=qo(h=>{let u=qo(i).map(d=>d+96);if(u.length){let d=h>=r;u[0]-=32,u=La(u),d&&(u=`Restricted[${u}]`);let f=a(),m=a(),A=!i();return{N:u,P:f,Q:m,M:A,R:d}}}),Mf=t(),Ua=new Map;let o=e().concat(th(Mf)).sort((h,u)=>h-u);o.forEach((h,u)=>{let d=i(),f=o[u]=d?o[u-d]:{V:[],M:new Map};f.V.push(h),Mf.has(h)||Ua.set(h,f)});for(let{V:h,M:u}of new Set(Ua.values())){let d=[];for(let m of h){let A=ka.filter(p=>Xo(p,m)),g=d.find(({G:p})=>A.some(y=>p.has(y)));g||(g={G:new Set,V:[]},d.push(g)),g.V.push(m),n(g.G,A)}let f=d.flatMap(m=>th(m.G));for(let{G:m,V:A}of d){let g=new Set(f.filter(p=>!m.has(p)));for(let p of A)u.set(p,g)}}wr=new Set;let c=new Set;const l=h=>wr.has(h)?c.add(h):wr.add(h);for(let h of ka){for(let u of h.P)l(u);for(let u of h.Q)l(u)}for(let h of wr)!Ua.has(h)&&!c.has(h)&&Ua.set(h,Vb);n(wr,Qb(wr)),Kb=jN(i).map(h=>cF.from(h)).sort(JN),Bf=new Map;for(let h of Kb){let u=[Bf];for(let d of h){let f=u.map(m=>{let A=m.get(d);return A||(A=new Map,m.set(d,A)),A});d===zb?u.push(...f):u=f}for(let d of u)d.V=h}}function Rf(i){return(jb(i)?"":`${Nf(nh([i]))} `)+Fb(i)}function Nf(i){return`"${i}"`}function lF(i){if(i.length>=4&&i[2]==Gb&&i[3]==Gb)throw new Error(`invalid label extension: "${La(i.slice(0,4))}"`)}function hF(i){for(let t=i.lastIndexOf(95);t>0;)if(i[--t]!==95)throw new Error("underscore allowed only at start")}function uF(i){let e=i[0],t=Ib.get(e);if(t)throw Yo(`leading ${t}`);let n=i.length,s=-1;for(let r=1;r<n;r++){e=i[r];let a=Ib.get(e);if(a){if(s==r)throw Yo(`${t} + ${a}`);s=r+1,t=a}}if(s==n)throw Yo(`trailing ${t}`)}function nh(i,e=1/0,t=Fb){let n=[];dF(i[0])&&n.push("◌"),i.length>e&&(e>>=1,i=[...i.slice(0,e),8230,...i.slice(-e)]);let s=0,r=i.length;for(let a=0;a<r;a++){let o=i[a];jb(o)&&(n.push(La(i.slice(s,a))),n.push(t(o)),s=a+1)}return n.push(La(i.slice(s,r))),n.join("")}function dF(i){return Tf(),yr.has(i)}function jb(i){return Tf(),qb.has(i)}function fF(i){return mF(pF(i,oF,_F))}function pF(i,e,t){if(!i)return[];Tf();let n=0;return i.split(Hb).map(s=>{let r=YN(s),a={input:r,offset:n};n+=r.length+1;try{let o=a.tokens=xF(r,e,t),c=o.length,l;if(!c)throw new Error("empty label");let h=a.output=o.flat();if(hF(h),!(a.emoji=c>1||o[0].is_emoji)&&h.every(d=>d<128))lF(h),l="ASCII";else{let d=o.flatMap(f=>f.is_emoji?[]:f);if(!d.length)l="Emoji";else{if(yr.has(h[0]))throw Yo("leading combining mark");for(let A=1;A<c;A++){let g=o[A];if(!g.is_emoji&&yr.has(g[0]))throw Yo(`emoji + combining mark: "${La(o[A-1])} + ${nh([g[0]])}"`)}uF(h);let f=th(new Set(d)),[m]=gF(f);bF(m,d),AF(m,f),l=m.N}}a.type=l}catch(o){a.error=o}return a})}function AF(i,e){let t,n=[];for(let s of e){let r=Ua.get(s);if(r===Vb)return;if(r){let a=r.M.get(s);if(t=t?t.filter(o=>a.has(o)):th(a),!t.length)return}else n.push(s)}if(t){for(let s of t)if(n.every(r=>Xo(s,r)))throw new Error(`whole-script confusable: ${i.N}/${s.N}`)}}function gF(i){let e=ka;for(let t of i){let n=e.filter(s=>Xo(s,t));if(!n.length)throw ka.some(s=>Xo(s,t))?Yb(e[0],t):Xb(t);if(e=n,n.length==1)break}return e}function mF(i){return i.map(({input:e,error:t,output:n})=>{if(t){let s=t.message;throw new Error(i.length==1?s:`Invalid label ${Nf(nh(e,63))}: ${s}`)}return La(n)}).join(Hb)}function Xb(i){return new Error(`disallowed character: ${Rf(i)}`)}function Yb(i,e){let t=Rf(e),n=ka.find(s=>s.P.has(e));return n&&(t=`${n.N} ${t}`),new Error(`illegal mixture: ${i.N} + ${t}`)}function Yo(i){return new Error(`illegal placement: ${i}`)}function bF(i,e){for(let t of e)if(!Xo(i,t))throw Yb(i,t);if(i.M){let t=Qb(e);for(let n=1,s=t.length;n<s;n++)if(If.has(t[n])){let r=n+1;for(let a;r<s&&If.has(a=t[r]);r++)for(let o=n;o<r;o++)if(t[o]==a)throw new Error(`duplicate non-spacing marks: ${Rf(a)}`);if(r-n>Mb)throw new Error(`excessive non-spacing marks: ${Nf(nh(t.slice(n-1,r)))} (${r-n}/${Mb})`);n=r}}}function xF(i,e,t){let n=[],s=[];for(i=i.slice().reverse();i.length;){let r=EF(i);if(r)s.length&&(n.push(e(s)),s=[]),n.push(t(r));else{let a=i.pop();if(wr.has(a))s.push(a);else{let o=Sf.get(a);if(o)s.push(...o);else if(!Wb.has(a))throw Xb(a)}}}return s.length&&n.push(e(s)),n}function _F(i){return i.filter(e=>e!=zb)}function EF(i,e){let t=Bf,n,s=i.length;for(;s&&(t=t.get(i[--s]),!!t);){let{V:r}=t;r&&(n=r,i.length=s)}return n}const Jb=new Uint8Array(32);Jb.fill(0);function Zb(i){return V(i.length!==0,"invalid ENS name; empty component","comp",i),i}function $b(i){const e=ss(yF(i)),t=[];if(i.length===0)return t;let n=0;for(let s=0;s<e.length;s++)e[s]===46&&(t.push(Zb(e.slice(n,s))),n=s+1);return V(n<e.length,"invalid ENS name; empty component","name",i),t.push(Zb(e.slice(n))),t}function yF(i){try{if(i.length===0)throw new Error("empty label");return fF(i)}catch(e){V(!1,`invalid ENS name (${e.message})`,"name",i)}}function Ff(i){V(typeof i=="string","invalid ENS name; not a string","name",i),V(i.length,"invalid ENS name (empty label)","name",i);let e=Jb;const t=$b(i);for(;t.length;)e=$t(Ot([e,$t(t.pop())]));return Ce(e)}function wF(i,e){const t=e;return V(t<=255,"DNS encoded label cannot exceed 255","length",t),Ce(Ot($b(i).map(n=>{V(n.length<=t,`label ${JSON.stringify(i)} exceeds ${t} bytes`,"name",i);const s=new Uint8Array(n.length+1);return s.set(n,1),s[0]=s.length-1,s})))+"00"}const ex=new Uint8Array(32);ex.fill(0);const vF=BigInt(-1),tx=BigInt(0),nx=BigInt(1),CF=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function SF(i){const e=lt(i),t=e.length%32;return t?Ot([e,ex.slice(t)]):Ce(e)}const IF=Os(nx,32),MF=Os(tx,32),ix={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},Df=["name","version","chainId","verifyingContract","salt"];function sx(i){return function(e){return V(typeof e=="string",`invalid domain value for ${JSON.stringify(i)}`,`domain.${i}`,e),e}}const BF={name:sx("name"),version:sx("version"),chainId:function(i){const e=Re(i,"domain.chainId");return V(e>=0,"invalid chain ID","domain.chainId",i),Number.isSafeInteger(e)?Number(e):vi(e)},verifyingContract:function(i){try{return Ct(i).toLowerCase()}catch{}V(!1,'invalid domain value "verifyingContract"',"domain.verifyingContract",i)},salt:function(i){const e=lt(i,"domain.salt");return V(e.length===32,'invalid domain value "salt"',"domain.salt",i),Ce(e)}};function Lf(i){{const e=i.match(/^(u?)int(\d+)$/);if(e){const t=e[1]==="",n=parseInt(e[2]);V(n%8===0&&n!==0&&n<=256&&e[2]===String(n),"invalid numeric width","type",i);const s=ko(CF,t?n-1:n),r=t?(s+nx)*vF:tx;return function(a){const o=Re(a,"value");return V(o>=r&&o<=s,`value out-of-bounds for ${i}`,"value",o),Os(t?l0(o,256):o,32)}}}{const e=i.match(/^bytes(\d+)$/);if(e){const t=parseInt(e[1]);return V(t!==0&&t<=32&&e[1]===String(t),"invalid bytes width","type",i),function(n){const s=lt(n);return V(s.length===t,`invalid length for ${i}`,"value",n),SF(n)}}}switch(i){case"address":return function(e){return is(Ct(e),32)};case"bool":return function(e){return e?IF:MF};case"bytes":return function(e){return $t(e)};case"string":return function(e){return Er(e)}}return null}function rx(i,e){return`${i}(${e.map(({name:t,type:n})=>n+" "+t).join(",")})`}function ih(i){const e=i.match(/^([^\x5b]*)((\x5b\d*\x5d)*)(\x5b(\d*)\x5d)$/);return e?{base:e[1],index:e[2]+e[4],array:{base:e[1],prefix:e[1]+e[2],count:e[5]?parseInt(e[5]):-1}}:{base:i}}class jn{primaryType;#e;get types(){return JSON.parse(this.#e)}#t;#n;constructor(e){this.#t=new Map,this.#n=new Map;const t=new Map,n=new Map,s=new Map,r={};Object.keys(e).forEach(c=>{r[c]=e[c].map(({name:l,type:h})=>{let{base:u,index:d}=ih(h);return u==="int"&&!e.int&&(u="int256"),u==="uint"&&!e.uint&&(u="uint256"),{name:l,type:u+(d||"")}}),t.set(c,new Set),n.set(c,[]),s.set(c,new Set)}),this.#e=JSON.stringify(r);for(const c in r){const l=new Set;for(const h of r[c]){V(!l.has(h.name),`duplicate variable name ${JSON.stringify(h.name)} in ${JSON.stringify(c)}`,"types",e),l.add(h.name);const u=ih(h.type).base;V(u!==c,`circular type reference to ${JSON.stringify(u)}`,"types",e),!Lf(u)&&(V(n.has(u),`unknown type ${JSON.stringify(u)}`,"types",e),n.get(u).push(c),t.get(c).add(u))}}const a=Array.from(n.keys()).filter(c=>n.get(c).length===0);V(a.length!==0,"missing primary type","types",e),V(a.length===1,`ambiguous primary types or unused types: ${a.map(c=>JSON.stringify(c)).join(", ")}`,"types",e),Xe(this,{primaryType:a[0]});function o(c,l){V(!l.has(c),`circular type reference to ${JSON.stringify(c)}`,"types",e),l.add(c);for(const h of t.get(c))if(n.has(h)){o(h,l);for(const u of l)s.get(u).add(h)}l.delete(c)}o(this.primaryType,new Set);for(const[c,l]of s){const h=Array.from(l);h.sort(),this.#t.set(c,rx(c,r[c])+h.map(u=>rx(u,r[u])).join(""))}}getEncoder(e){let t=this.#n.get(e);return t||(t=this.#i(e),this.#n.set(e,t)),t}#i(e){{const s=Lf(e);if(s)return s}const t=ih(e).array;if(t){const s=t.prefix,r=this.getEncoder(s);return a=>{V(t.count===-1||t.count===a.length,`array length mismatch; expected length ${t.count}`,"value",a);let o=a.map(r);return this.#t.has(s)&&(o=o.map($t)),$t(Ot(o))}}const n=this.types[e];if(n){const s=Er(this.#t.get(e));return r=>{const a=n.map(({name:o,type:c})=>{const l=this.getEncoder(c)(r[o]);return this.#t.has(c)?$t(l):l});return a.unshift(s),Ot(a)}}V(!1,`unknown type: ${e}`,"type",e)}encodeType(e){const t=this.#t.get(e);return V(t,`unknown type: ${JSON.stringify(e)}`,"name",e),t}encodeData(e,t){return this.getEncoder(e)(t)}hashStruct(e,t){return $t(this.encodeData(e,t))}encode(e){return this.encodeData(this.primaryType,e)}hash(e){return this.hashStruct(this.primaryType,e)}_visit(e,t,n){if(Lf(e))return n(e,t);const s=ih(e).array;if(s)return V(s.count===-1||s.count===t.length,`array length mismatch; expected length ${s.count}`,"value",t),t.map(a=>this._visit(s.prefix,a,n));const r=this.types[e];if(r)return r.reduce((a,{name:o,type:c})=>(a[o]=this._visit(c,t[o],n),a),{});V(!1,`unknown type: ${e}`,"type",e)}visit(e,t){return this._visit(this.primaryType,e,t)}static from(e){return new jn(e)}static getPrimaryType(e){return jn.from(e).primaryType}static hashStruct(e,t,n){return jn.from(t).hashStruct(e,n)}static hashDomain(e){const t=[];for(const n in e){if(e[n]==null)continue;const s=ix[n];V(s,`invalid typed-data domain key: ${JSON.stringify(n)}`,"domain",e),t.push({name:n,type:s})}return t.sort((n,s)=>Df.indexOf(n.name)-Df.indexOf(s.name)),jn.hashStruct("EIP712Domain",{EIP712Domain:t},e)}static encode(e,t,n){return Ot(["0x1901",jn.hashDomain(e),jn.from(t).hash(n)])}static hash(e,t,n){return $t(jn.encode(e,t,n))}static async resolveNames(e,t,n,s){e=Object.assign({},e);for(const o in e)e[o]==null&&delete e[o];const r={};e.verifyingContract&&!Ft(e.verifyingContract,20)&&(r[e.verifyingContract]="0x");const a=jn.from(t);a.visit(n,(o,c)=>(o==="address"&&!Ft(c,20)&&(r[c]="0x"),c));for(const o in r)r[o]=await s(o);return e.verifyingContract&&r[e.verifyingContract]&&(e.verifyingContract=r[e.verifyingContract]),n=a.visit(n,(o,c)=>o==="address"&&r[c]?r[c]:c),{domain:e,value:n}}static getPayload(e,t,n){jn.hashDomain(e);const s={},r=[];Df.forEach(c=>{const l=e[c];l!=null&&(s[c]=BF[c](l),r.push({name:c,type:ix[c]}))});const a=jn.from(t);t=a.types;const o=Object.assign({},t);return V(o.EIP712Domain==null,"types must not contain EIP712Domain type","types.EIP712Domain",t),o.EIP712Domain=r,a.encode(n),{types:o,domain:s,primaryType:a.primaryType,message:a.visit(n,(c,l)=>{if(c.match(/^bytes(\d*)/))return Ce(lt(l));if(c.match(/^u?int/))return Re(l).toString();switch(c){case"address":return l.toLowerCase();case"bool":return!!l;case"string":return V(typeof l=="string","invalid string","value",l),l}V(!1,"unsupported type","type",c)})}}}function kn(i){const e=new Set;return i.forEach(t=>e.add(t)),Object.freeze(e)}const TF=kn("external public payable override".split(" ")),ax="constant external internal payable private public pure view override",RF=kn(ax.split(" ")),ox="constructor error event fallback function receive struct",cx=kn(ox.split(" ")),lx="calldata memory storage payable indexed",NF=kn(lx.split(" ")),FF=[ox,lx,"tuple returns",ax].join(" "),DF=kn(FF.split(" ")),LF={"(":"OPEN_PAREN",")":"CLOSE_PAREN","[":"OPEN_BRACKET","]":"CLOSE_BRACKET",",":"COMMA","@":"AT"},PF=new RegExp("^(\\s*)"),kF=new RegExp("^([0-9]+)"),UF=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)"),hx=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)$"),ux=new RegExp("^(address|bool|bytes([0-9]*)|string|u?int([0-9]*))$");class ai{#e;#t;get offset(){return this.#e}get length(){return this.#t.length-this.#e}constructor(e){this.#e=0,this.#t=e.slice()}clone(){return new ai(this.#t)}reset(){this.#e=0}#n(e=0,t=0){return new ai(this.#t.slice(e,t).map(n=>Object.freeze(Object.assign({},n,{match:n.match-e,linkBack:n.linkBack-e,linkNext:n.linkNext-e}))))}popKeyword(e){const t=this.peek();if(t.type!=="KEYWORD"||!e.has(t.text))throw new Error(`expected keyword ${t.text}`);return this.pop().text}popType(e){if(this.peek().type!==e){const t=this.peek();throw new Error(`expected ${e}; got ${t.type} ${JSON.stringify(t.text)}`)}return this.pop().text}popParen(){const e=this.peek();if(e.type!=="OPEN_PAREN")throw new Error("bad start");const t=this.#n(this.#e+1,e.match+1);return this.#e=e.match+1,t}popParams(){const e=this.peek();if(e.type!=="OPEN_PAREN")throw new Error("bad start");const t=[];for(;this.#e<e.match-1;){const n=this.peek().linkNext;t.push(this.#n(this.#e+1,n)),this.#e=n}return this.#e=e.match+1,t}peek(){if(this.#e>=this.#t.length)throw new Error("out-of-bounds");return this.#t[this.#e]}peekKeyword(e){const t=this.peekType("KEYWORD");return t!=null&&e.has(t)?t:null}peekType(e){if(this.length===0)return null;const t=this.peek();return t.type===e?t.text:null}pop(){const e=this.peek();return this.#e++,e}toString(){const e=[];for(let t=this.#e;t<this.#t.length;t++){const n=this.#t[t];e.push(`${n.type}:${n.text}`)}return`<TokenString ${e.join(" ")}>`}}function qs(i){const e=[],t=a=>{const o=r<i.length?JSON.stringify(i[r]):"$EOI";throw new Error(`invalid token ${o} at ${r}: ${a}`)};let n=[],s=[],r=0;for(;r<i.length;){let a=i.substring(r),o=a.match(PF);o&&(r+=o[1].length,a=i.substring(r));const c={depth:n.length,linkBack:-1,linkNext:-1,match:-1,type:"",text:"",offset:r,value:-1};e.push(c);let l=LF[a[0]]||"";if(l){if(c.type=l,c.text=a[0],r++,l==="OPEN_PAREN")n.push(e.length-1),s.push(e.length-1);else if(l=="CLOSE_PAREN")n.length===0&&t("no matching open bracket"),c.match=n.pop(),e[c.match].match=e.length-1,c.depth--,c.linkBack=s.pop(),e[c.linkBack].linkNext=e.length-1;else if(l==="COMMA")c.linkBack=s.pop(),e[c.linkBack].linkNext=e.length-1,s.push(e.length-1);else if(l==="OPEN_BRACKET")c.type="BRACKET";else if(l==="CLOSE_BRACKET"){let h=e.pop().text;if(e.length>0&&e[e.length-1].type==="NUMBER"){const u=e.pop().text;h=u+h,e[e.length-1].value=ht(u)}if(e.length===0||e[e.length-1].type!=="BRACKET")throw new Error("missing opening bracket");e[e.length-1].text+=h}continue}if(o=a.match(UF),o){if(c.text=o[1],r+=c.text.length,DF.has(c.text)){c.type="KEYWORD";continue}if(c.text.match(ux)){c.type="TYPE";continue}c.type="ID";continue}if(o=a.match(kF),o){c.text=o[1],c.type="NUMBER",r+=c.text.length;continue}throw new Error(`unexpected token ${JSON.stringify(a[0])} at position ${r}`)}return new ai(e.map(a=>Object.freeze(a)))}function dx(i,e){let t=[];for(const n in e.keys())i.has(n)&&t.push(n);if(t.length>1)throw new Error(`conflicting types: ${t.join(", ")}`)}function sh(i,e){if(e.peekKeyword(cx)){const t=e.pop().text;if(t!==i)throw new Error(`expected ${i}, got ${t}`)}return e.popType("ID")}function us(i,e){const t=new Set;for(;;){const n=i.peekType("KEYWORD");if(n==null||e&&!e.has(n))break;if(i.pop(),t.has(n))throw new Error(`duplicate keywords: ${JSON.stringify(n)}`);t.add(n)}return Object.freeze(t)}function fx(i){let e=us(i,RF);return dx(e,kn("constant payable nonpayable".split(" "))),dx(e,kn("pure view payable nonpayable".split(" "))),e.has("view")?"view":e.has("pure")?"pure":e.has("payable")?"payable":e.has("nonpayable")?"nonpayable":e.has("constant")?"view":"nonpayable"}function ds(i,e){return i.popParams().map(t=>Dt.from(t,e))}function px(i){if(i.peekType("AT")){if(i.pop(),i.peekType("NUMBER"))return Re(i.pop().text);throw new Error("invalid gas")}return null}function vr(i){if(i.length)throw new Error(`unexpected tokens at offset ${i.offset}: ${i.toString()}`)}const OF=new RegExp(/^(.*)\[([0-9]*)\]$/);function Ax(i){const e=i.match(ux);if(V(e,"invalid type","type",i),i==="uint")return"uint256";if(i==="int")return"int256";if(e[2]){const t=parseInt(e[2]);V(t!==0&&t<=32,"invalid bytes length","type",i)}else if(e[3]){const t=parseInt(e[3]);V(t!==0&&t<=256&&t%8===0,"invalid numeric width","type",i)}return i}const Ht={},zn=Symbol.for("_ethers_internal"),gx="_ParamTypeInternal",mx="_ErrorInternal",bx="_EventInternal",xx="_ConstructorInternal",_x="_FallbackInternal",Ex="_FunctionInternal",yx="_StructInternal";class Dt{name;type;baseType;indexed;components;arrayLength;arrayChildren;constructor(e,t,n,s,r,a,o,c){if(Dl(e,Ht,"ParamType"),Object.defineProperty(this,zn,{value:gx}),a&&(a=Object.freeze(a.slice())),s==="array"){if(o==null||c==null)throw new Error("")}else if(o!=null||c!=null)throw new Error("");if(s==="tuple"){if(a==null)throw new Error("")}else if(a!=null)throw new Error("");Xe(this,{name:t,type:n,baseType:s,indexed:r,components:a,arrayLength:o,arrayChildren:c})}format(e){if(e==null&&(e="sighash"),e==="json"){const n=this.name||"";if(this.isArray()){const r=JSON.parse(this.arrayChildren.format("json"));return r.name=n,r.type+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`,JSON.stringify(r)}const s={type:this.baseType==="tuple"?"tuple":this.type,name:n};return typeof this.indexed=="boolean"&&(s.indexed=this.indexed),this.isTuple()&&(s.components=this.components.map(r=>JSON.parse(r.format(e)))),JSON.stringify(s)}let t="";return this.isArray()?(t+=this.arrayChildren.format(e),t+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`):this.isTuple()?t+="("+this.components.map(n=>n.format(e)).join(e==="full"?", ":",")+")":t+=this.type,e!=="sighash"&&(this.indexed===!0&&(t+=" indexed"),e==="full"&&this.name&&(t+=" "+this.name)),t}isArray(){return this.baseType==="array"}isTuple(){return this.baseType==="tuple"}isIndexable(){return this.indexed!=null}walk(e,t){if(this.isArray()){if(!Array.isArray(e))throw new Error("invalid array value");if(this.arrayLength!==-1&&e.length!==this.arrayLength)throw new Error("array is wrong length");const n=this;return e.map(s=>n.arrayChildren.walk(s,t))}if(this.isTuple()){if(!Array.isArray(e))throw new Error("invalid tuple value");if(e.length!==this.components.length)throw new Error("array is wrong length");const n=this;return e.map((s,r)=>n.components[r].walk(s,t))}return t(this.type,e)}#e(e,t,n,s){if(this.isArray()){if(!Array.isArray(t))throw new Error("invalid array value");if(this.arrayLength!==-1&&t.length!==this.arrayLength)throw new Error("array is wrong length");const a=this.arrayChildren,o=t.slice();o.forEach((c,l)=>{a.#e(e,c,n,h=>{o[l]=h})}),s(o);return}if(this.isTuple()){const a=this.components;let o;if(Array.isArray(t))o=t.slice();else{if(t==null||typeof t!="object")throw new Error("invalid tuple value");o=a.map(c=>{if(!c.name)throw new Error("cannot use object value with unnamed components");if(!(c.name in t))throw new Error(`missing value for component ${c.name}`);return t[c.name]})}if(o.length!==this.components.length)throw new Error("array is wrong length");o.forEach((c,l)=>{a[l].#e(e,c,n,h=>{o[l]=h})}),s(o);return}const r=n(this.type,t);r.then?e.push((async function(){s(await r)})()):s(r)}async walkAsync(e,t){const n=[],s=[e];return this.#e(n,e,t,r=>{s[0]=r}),n.length&&await Promise.all(n),s[0]}static from(e,t){if(Dt.isParamType(e))return e;if(typeof e=="string")try{return Dt.from(qs(e),t)}catch{V(!1,"invalid param type","obj",e)}else if(e instanceof ai){let o="",c="",l=null;us(e,kn(["tuple"])).has("tuple")||e.peekType("OPEN_PAREN")?(c="tuple",l=e.popParams().map(A=>Dt.from(A)),o=`tuple(${l.map(A=>A.format()).join(",")})`):(o=Ax(e.popType("TYPE")),c=o);let h=null,u=null;for(;e.length&&e.peekType("BRACKET");){const A=e.pop();h=new Dt(Ht,"",o,c,null,l,u,h),u=A.value,o+=A.text,c="array",l=null}let d=null;if(us(e,NF).has("indexed")){if(!t)throw new Error("");d=!0}const m=e.peekType("ID")?e.pop().text:"";if(e.length)throw new Error("leftover tokens");return new Dt(Ht,m,o,c,d,l,u,h)}const n=e.name;V(!n||typeof n=="string"&&n.match(hx),"invalid name","obj.name",n);let s=e.indexed;s!=null&&(V(t,"parameter cannot be indexed","obj.indexed",e.indexed),s=!!s);let r=e.type,a=r.match(OF);if(a){const o=parseInt(a[2]||"-1"),c=Dt.from({type:a[1],components:e.components});return new Dt(Ht,n||"",r,"array",s,null,o,c)}if(r==="tuple"||r.startsWith("tuple(")||r.startsWith("(")){const o=e.components!=null?e.components.map(l=>Dt.from(l)):null;return new Dt(Ht,n||"",r,"tuple",s,o,null,null)}return r=Ax(e.type),new Dt(Ht,n||"",r,r,s,null,null,null)}static isParamType(e){return e&&e[zn]===gx}}class Cr{type;inputs;constructor(e,t,n){Dl(e,Ht,"Fragment"),n=Object.freeze(n.slice()),Xe(this,{type:t,inputs:n})}static from(e){if(typeof e=="string"){try{Cr.from(JSON.parse(e))}catch{}return Cr.from(qs(e))}if(e instanceof ai)switch(e.peekKeyword(cx)){case"constructor":return fs.from(e);case"error":return Vn.from(e);case"event":return Oi.from(e);case"fallback":case"receive":return ps.from(e);case"function":return Qi.from(e);case"struct":return Sr.from(e)}else if(typeof e=="object"){switch(e.type){case"constructor":return fs.from(e);case"error":return Vn.from(e);case"event":return Oi.from(e);case"fallback":case"receive":return ps.from(e);case"function":return Qi.from(e);case"struct":return Sr.from(e)}pe(!1,`unsupported type: ${e.type}`,"UNSUPPORTED_OPERATION",{operation:"Fragment.from"})}V(!1,"unsupported frgament object","obj",e)}static isConstructor(e){return fs.isFragment(e)}static isError(e){return Vn.isFragment(e)}static isEvent(e){return Oi.isFragment(e)}static isFunction(e){return Qi.isFragment(e)}static isStruct(e){return Sr.isFragment(e)}}class rh extends Cr{name;constructor(e,t,n,s){super(e,t,s),V(typeof n=="string"&&n.match(hx),"invalid identifier","name",n),s=Object.freeze(s.slice()),Xe(this,{name:n})}}function Jo(i,e){return"("+e.map(t=>t.format(i)).join(i==="full"?", ":",")+")"}class Vn extends rh{constructor(e,t,n){super(e,"error",t,n),Object.defineProperty(this,zn,{value:mx})}get selector(){return Er(this.format("sighash")).substring(0,10)}format(e){if(e==null&&(e="sighash"),e==="json")return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map(n=>JSON.parse(n.format(e)))});const t=[];return e!=="sighash"&&t.push("error"),t.push(this.name+Jo(e,this.inputs)),t.join(" ")}static from(e){if(Vn.isFragment(e))return e;if(typeof e=="string")return Vn.from(qs(e));if(e instanceof ai){const t=sh("error",e),n=ds(e);return vr(e),new Vn(Ht,t,n)}return new Vn(Ht,e.name,e.inputs?e.inputs.map(Dt.from):[])}static isFragment(e){return e&&e[zn]===mx}}class Oi extends rh{anonymous;constructor(e,t,n,s){super(e,"event",t,n),Object.defineProperty(this,zn,{value:bx}),Xe(this,{anonymous:s})}get topicHash(){return Er(this.format("sighash"))}format(e){if(e==null&&(e="sighash"),e==="json")return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map(n=>JSON.parse(n.format(e)))});const t=[];return e!=="sighash"&&t.push("event"),t.push(this.name+Jo(e,this.inputs)),e!=="sighash"&&this.anonymous&&t.push("anonymous"),t.join(" ")}static getTopicHash(e,t){return t=(t||[]).map(s=>Dt.from(s)),new Oi(Ht,e,t,!1).topicHash}static from(e){if(Oi.isFragment(e))return e;if(typeof e=="string")try{return Oi.from(qs(e))}catch{V(!1,"invalid event fragment","obj",e)}else if(e instanceof ai){const t=sh("event",e),n=ds(e,!0),s=!!us(e,kn(["anonymous"])).has("anonymous");return vr(e),new Oi(Ht,t,n,s)}return new Oi(Ht,e.name,e.inputs?e.inputs.map(t=>Dt.from(t,!0)):[],!!e.anonymous)}static isFragment(e){return e&&e[zn]===bx}}class fs extends Cr{payable;gas;constructor(e,t,n,s,r){super(e,t,n),Object.defineProperty(this,zn,{value:xx}),Xe(this,{payable:s,gas:r})}format(e){if(pe(e!=null&&e!=="sighash","cannot format a constructor for sighash","UNSUPPORTED_OPERATION",{operation:"format(sighash)"}),e==="json")return JSON.stringify({type:"constructor",stateMutability:this.payable?"payable":"undefined",payable:this.payable,gas:this.gas!=null?this.gas:void 0,inputs:this.inputs.map(n=>JSON.parse(n.format(e)))});const t=[`constructor${Jo(e,this.inputs)}`];return this.payable&&t.push("payable"),this.gas!=null&&t.push(`@${this.gas.toString()}`),t.join(" ")}static from(e){if(fs.isFragment(e))return e;if(typeof e=="string")try{return fs.from(qs(e))}catch{V(!1,"invalid constuctor fragment","obj",e)}else if(e instanceof ai){us(e,kn(["constructor"]));const t=ds(e),n=!!us(e,TF).has("payable"),s=px(e);return vr(e),new fs(Ht,"constructor",t,n,s)}return new fs(Ht,"constructor",e.inputs?e.inputs.map(Dt.from):[],!!e.payable,e.gas!=null?e.gas:null)}static isFragment(e){return e&&e[zn]===xx}}class ps extends Cr{payable;constructor(e,t,n){super(e,"fallback",t),Object.defineProperty(this,zn,{value:_x}),Xe(this,{payable:n})}format(e){const t=this.inputs.length===0?"receive":"fallback";if(e==="json"){const n=this.payable?"payable":"nonpayable";return JSON.stringify({type:t,stateMutability:n})}return`${t}()${this.payable?" payable":""}`}static from(e){if(ps.isFragment(e))return e;if(typeof e=="string")try{return ps.from(qs(e))}catch{V(!1,"invalid fallback fragment","obj",e)}else if(e instanceof ai){const t=e.toString(),n=e.peekKeyword(kn(["fallback","receive"]));if(V(n,"type must be fallback or receive","obj",t),e.popKeyword(kn(["fallback","receive"]))==="receive"){const o=ds(e);return V(o.length===0,"receive cannot have arguments","obj.inputs",o),us(e,kn(["payable"])),vr(e),new ps(Ht,[],!0)}let r=ds(e);r.length?V(r.length===1&&r[0].type==="bytes","invalid fallback inputs","obj.inputs",r.map(o=>o.format("minimal")).join(", ")):r=[Dt.from("bytes")];const a=fx(e);if(V(a==="nonpayable"||a==="payable","fallback cannot be constants","obj.stateMutability",a),us(e,kn(["returns"])).has("returns")){const o=ds(e);V(o.length===1&&o[0].type==="bytes","invalid fallback outputs","obj.outputs",o.map(c=>c.format("minimal")).join(", "))}return vr(e),new ps(Ht,r,a==="payable")}if(e.type==="receive")return new ps(Ht,[],!0);if(e.type==="fallback"){const t=[Dt.from("bytes")],n=e.stateMutability==="payable";return new ps(Ht,t,n)}V(!1,"invalid fallback description","obj",e)}static isFragment(e){return e&&e[zn]===_x}}class Qi extends rh{constant;outputs;stateMutability;payable;gas;constructor(e,t,n,s,r,a){super(e,"function",t,s),Object.defineProperty(this,zn,{value:Ex}),r=Object.freeze(r.slice()),Xe(this,{constant:n==="view"||n==="pure",gas:a,outputs:r,payable:n==="payable",stateMutability:n})}get selector(){return Er(this.format("sighash")).substring(0,10)}format(e){if(e==null&&(e="sighash"),e==="json")return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:this.stateMutability!=="nonpayable"?this.stateMutability:void 0,payable:this.payable,gas:this.gas!=null?this.gas:void 0,inputs:this.inputs.map(n=>JSON.parse(n.format(e))),outputs:this.outputs.map(n=>JSON.parse(n.format(e)))});const t=[];return e!=="sighash"&&t.push("function"),t.push(this.name+Jo(e,this.inputs)),e!=="sighash"&&(this.stateMutability!=="nonpayable"&&t.push(this.stateMutability),this.outputs&&this.outputs.length&&(t.push("returns"),t.push(Jo(e,this.outputs))),this.gas!=null&&t.push(`@${this.gas.toString()}`)),t.join(" ")}static getSelector(e,t){return t=(t||[]).map(s=>Dt.from(s)),new Qi(Ht,e,"view",t,[],null).selector}static from(e){if(Qi.isFragment(e))return e;if(typeof e=="string")try{return Qi.from(qs(e))}catch{V(!1,"invalid function fragment","obj",e)}else if(e instanceof ai){const n=sh("function",e),s=ds(e),r=fx(e);let a=[];us(e,kn(["returns"])).has("returns")&&(a=ds(e));const o=px(e);return vr(e),new Qi(Ht,n,r,s,a,o)}let t=e.stateMutability;return t==null&&(t="payable",typeof e.constant=="boolean"?(t="view",e.constant||(t="payable",typeof e.payable=="boolean"&&!e.payable&&(t="nonpayable"))):typeof e.payable=="boolean"&&!e.payable&&(t="nonpayable")),new Qi(Ht,e.name,t,e.inputs?e.inputs.map(Dt.from):[],e.outputs?e.outputs.map(Dt.from):[],e.gas!=null?e.gas:null)}static isFragment(e){return e&&e[zn]===Ex}}class Sr extends rh{constructor(e,t,n){super(e,"struct",t,n),Object.defineProperty(this,zn,{value:yx})}format(){throw new Error("@TODO")}static from(e){if(typeof e=="string")try{return Sr.from(qs(e))}catch{V(!1,"invalid struct fragment","obj",e)}else if(e instanceof ai){const t=sh("struct",e),n=ds(e);return vr(e),new Sr(Ht,t,n)}return new Sr(Ht,e.name,e.inputs?e.inputs.map(Dt.from):[])}static isFragment(e){return e&&e[zn]===yx}}const Ii=new Map;Ii.set(0,"GENERIC_PANIC"),Ii.set(1,"ASSERT_FALSE"),Ii.set(17,"OVERFLOW"),Ii.set(18,"DIVIDE_BY_ZERO"),Ii.set(33,"ENUM_RANGE_ERROR"),Ii.set(34,"BAD_STORAGE_DATA"),Ii.set(49,"STACK_UNDERFLOW"),Ii.set(50,"ARRAY_RANGE_ERROR"),Ii.set(65,"OUT_OF_MEMORY"),Ii.set(81,"UNINITIALIZED_FUNCTION_CALL");const QF=new RegExp(/^bytes([0-9]*)$/),GF=new RegExp(/^(u?int)([0-9]*)$/);let Pf=null,wx=1024;function HF(i,e,t,n){let s="missing revert data",r=null;const a=null;let o=null;if(t){s="execution reverted";const l=lt(t);if(t=Ce(t),l.length===0)s+=" (no data present; likely require(false) occurred",r="require(false)";else if(l.length%32!==4)s+=" (could not decode reason; invalid data length)";else if(Ce(l.slice(0,4))==="0x08c379a0")try{r=n.decode(["string"],l.slice(4))[0],o={signature:"Error(string)",name:"Error",args:[r]},s+=`: ${JSON.stringify(r)}`}catch{s+=" (could not decode reason; invalid string data)"}else if(Ce(l.slice(0,4))==="0x4e487b71")try{const h=Number(n.decode(["uint256"],l.slice(4))[0]);o={signature:"Panic(uint256)",name:"Panic",args:[h]},r=`Panic due to ${Ii.get(h)||"UNKNOWN"}(${h})`,s+=`: ${r}`}catch{s+=" (could not decode panic code)"}else s+=" (unknown custom error)"}const c={to:e.to?Ct(e.to):null,data:e.data||"0x"};return e.from&&(c.from=Ct(e.from)),Ut(s,"CALL_EXCEPTION",{action:i,data:t,reason:r,transaction:c,invocation:a,revert:o})}class Oa{#e(e){if(e.isArray())return new oN(this.#e(e.arrayChildren),e.arrayLength,e.name);if(e.isTuple())return new Wl(e.components.map(n=>this.#e(n)),e.name);switch(e.baseType){case"address":return new rN(e.name);case"bool":return new cN(e.name);case"string":return new mN(e.name);case"bytes":return new lN(e.name);case"":return new dN(e.name)}let t=e.type.match(GF);if(t){let n=parseInt(t[2]||"256");return V(n!==0&&n<=256&&n%8===0,"invalid "+t[1]+" bit length","param",e),new gN(n/8,t[1]==="int",e.name)}if(t=e.type.match(QF),t){let n=parseInt(t[1]);return V(n!==0&&n<=32,"invalid bytes length","param",e),new hN(n,e.name)}V(!1,"invalid type","type",e.type)}getDefaultValue(e){const t=e.map(s=>this.#e(Dt.from(s)));return new Wl(t,"_").defaultValue()}encode(e,t){r0(t.length,e.length,"types/values length mismatch");const n=e.map(a=>this.#e(Dt.from(a))),s=new Wl(n,"_"),r=new Zd;return s.encode(r,t),r.data}decode(e,t,n){const s=e.map(a=>this.#e(Dt.from(a)));return new Wl(s,"_").decode(new $d(t,n,wx))}static _setDefaultMaxInflation(e){V(typeof e=="number"&&Number.isInteger(e),"invalid defaultMaxInflation factor","value",e),wx=e}static defaultAbiCoder(){return Pf==null&&(Pf=new Oa),Pf}static getBuiltinCallException(e,t,n){return HF(e,t,n,Oa.defaultAbiCoder())}}class zF{fragment;name;signature;topic;args;constructor(e,t,n){const s=e.name,r=e.format();Xe(this,{fragment:e,name:s,signature:r,topic:t,args:n})}}class VF{fragment;name;args;signature;selector;value;constructor(e,t,n,s){const r=e.name,a=e.format();Xe(this,{fragment:e,name:r,args:n,signature:a,selector:t,value:s})}}class WF{fragment;name;args;signature;selector;constructor(e,t,n){const s=e.name,r=e.format();Xe(this,{fragment:e,name:s,args:n,signature:r,selector:t})}}class vx{hash;_isIndexed;static isIndexed(e){return!!(e&&e._isIndexed)}constructor(e){Xe(this,{hash:e,_isIndexed:!0})}}const Cx={0:"generic panic",1:"assert(false)",17:"arithmetic overflow",18:"division or modulo by zero",33:"enum overflow",34:"invalid encoded storage byte array accessed",49:"out-of-bounds array access; popping on an empty array",50:"out-of-bounds access of an array or bytesN",65:"out of memory",81:"uninitialized function"},Sx={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:i=>`reverted with reason string ${JSON.stringify(i)}`},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"],reason:i=>{let e="unknown panic code";return i>=0&&i<=255&&Cx[i.toString()]&&(e=Cx[i.toString()]),`reverted with panic code 0x${i.toString(16)} (${e})`}}};class Ir{fragments;deploy;fallback;receive;#e;#t;#n;#i;constructor(e){let t=[];typeof e=="string"?t=JSON.parse(e):t=e,this.#n=new Map,this.#e=new Map,this.#t=new Map;const n=[];for(const a of t)try{n.push(Cr.from(a))}catch(o){console.log(`[Warning] Invalid Fragment ${JSON.stringify(a)}:`,o.message)}Xe(this,{fragments:Object.freeze(n)});let s=null,r=!1;this.#i=this.getAbiCoder(),this.fragments.forEach((a,o)=>{let c;switch(a.type){case"constructor":if(this.deploy){console.log("duplicate definition - constructor");return}Xe(this,{deploy:a});return;case"fallback":a.inputs.length===0?r=!0:(V(!s||a.payable!==s.payable,"conflicting fallback fragments",`fragments[${o}]`,a),s=a,r=s.payable);return;case"function":c=this.#n;break;case"event":c=this.#t;break;case"error":c=this.#e;break;default:return}const l=a.format();c.has(l)||c.set(l,a)}),this.deploy||Xe(this,{deploy:fs.from("constructor()")}),Xe(this,{fallback:s,receive:r})}format(e){const t=e?"minimal":"full";return this.fragments.map(s=>s.format(t))}formatJson(){const e=this.fragments.map(t=>t.format("json"));return JSON.stringify(e.map(t=>JSON.parse(t)))}getAbiCoder(){return Oa.defaultAbiCoder()}#s(e,t,n){if(Ft(e)){const r=e.toLowerCase();for(const a of this.#n.values())if(r===a.selector)return a;return null}if(e.indexOf("(")===-1){const r=[];for(const[a,o]of this.#n)a.split("(")[0]===e&&r.push(o);if(t){const a=t.length>0?t[t.length-1]:null;let o=t.length,c=!0;Wt.isTyped(a)&&a.type==="overrides"&&(c=!1,o--);for(let l=r.length-1;l>=0;l--){const h=r[l].inputs.length;h!==o&&(!c||h!==o-1)&&r.splice(l,1)}for(let l=r.length-1;l>=0;l--){const h=r[l].inputs;for(let u=0;u<t.length;u++)if(Wt.isTyped(t[u])){if(u>=h.length){if(t[u].type==="overrides")continue;r.splice(l,1);break}if(t[u].type!==h[u].baseType){r.splice(l,1);break}}}}if(r.length===1&&t&&t.length!==r[0].inputs.length){const a=t[t.length-1];(a==null||Array.isArray(a)||typeof a!="object")&&r.splice(0,1)}if(r.length===0)return null;if(r.length>1&&n){const a=r.map(o=>JSON.stringify(o.format())).join(", ");V(!1,`ambiguous function description (i.e. matches ${a})`,"key",e)}return r[0]}const s=this.#n.get(Qi.from(e).format());return s||null}getFunctionName(e){const t=this.#s(e,null,!1);return V(t,"no matching function","key",e),t.name}hasFunction(e){return!!this.#s(e,null,!1)}getFunction(e,t){return this.#s(e,t||null,!0)}forEachFunction(e){const t=Array.from(this.#n.keys());t.sort((n,s)=>n.localeCompare(s));for(let n=0;n<t.length;n++){const s=t[n];e(this.#n.get(s),n)}}#a(e,t,n){if(Ft(e)){const r=e.toLowerCase();for(const a of this.#t.values())if(r===a.topicHash)return a;return null}if(e.indexOf("(")===-1){const r=[];for(const[a,o]of this.#t)a.split("(")[0]===e&&r.push(o);if(t){for(let a=r.length-1;a>=0;a--)r[a].inputs.length<t.length&&r.splice(a,1);for(let a=r.length-1;a>=0;a--){const o=r[a].inputs;for(let c=0;c<t.length;c++)if(Wt.isTyped(t[c])&&t[c].type!==o[c].baseType){r.splice(a,1);break}}}if(r.length===0)return null;if(r.length>1&&n){const a=r.map(o=>JSON.stringify(o.format())).join(", ");V(!1,`ambiguous event description (i.e. matches ${a})`,"key",e)}return r[0]}const s=this.#t.get(Oi.from(e).format());return s||null}getEventName(e){const t=this.#a(e,null,!1);return V(t,"no matching event","key",e),t.name}hasEvent(e){return!!this.#a(e,null,!1)}getEvent(e,t){return this.#a(e,t||null,!0)}forEachEvent(e){const t=Array.from(this.#t.keys());t.sort((n,s)=>n.localeCompare(s));for(let n=0;n<t.length;n++){const s=t[n];e(this.#t.get(s),n)}}getError(e,t){if(Ft(e)){const s=e.toLowerCase();if(Sx[s])return Vn.from(Sx[s].signature);for(const r of this.#e.values())if(s===r.selector)return r;return null}if(e.indexOf("(")===-1){const s=[];for(const[r,a]of this.#e)r.split("(")[0]===e&&s.push(a);if(s.length===0)return e==="Error"?Vn.from("error Error(string)"):e==="Panic"?Vn.from("error Panic(uint256)"):null;if(s.length>1){const r=s.map(a=>JSON.stringify(a.format())).join(", ");V(!1,`ambiguous error description (i.e. ${r})`,"name",e)}return s[0]}if(e=Vn.from(e).format(),e==="Error(string)")return Vn.from("error Error(string)");if(e==="Panic(uint256)")return Vn.from("error Panic(uint256)");const n=this.#e.get(e);return n||null}forEachError(e){const t=Array.from(this.#e.keys());t.sort((n,s)=>n.localeCompare(s));for(let n=0;n<t.length;n++){const s=t[n];e(this.#e.get(s),n)}}_decodeParams(e,t){return this.#i.decode(e,t)}_encodeParams(e,t){return this.#i.encode(e,t)}encodeDeploy(e){return this._encodeParams(this.deploy.inputs,e||[])}decodeErrorResult(e,t){if(typeof e=="string"){const n=this.getError(e);V(n,"unknown error","fragment",e),e=n}return V(Vt(t,0,4)===e.selector,`data signature does not match error ${e.name}.`,"data",t),this._decodeParams(e.inputs,Vt(t,4))}encodeErrorResult(e,t){if(typeof e=="string"){const n=this.getError(e);V(n,"unknown error","fragment",e),e=n}return Ot([e.selector,this._encodeParams(e.inputs,t||[])])}decodeFunctionData(e,t){if(typeof e=="string"){const n=this.getFunction(e);V(n,"unknown function","fragment",e),e=n}return V(Vt(t,0,4)===e.selector,`data signature does not match function ${e.name}.`,"data",t),this._decodeParams(e.inputs,Vt(t,4))}encodeFunctionData(e,t){if(typeof e=="string"){const n=this.getFunction(e);V(n,"unknown function","fragment",e),e=n}return Ot([e.selector,this._encodeParams(e.inputs,t||[])])}decodeFunctionResult(e,t){if(typeof e=="string"){const r=this.getFunction(e);V(r,"unknown function","fragment",e),e=r}let n="invalid length for result data";const s=Dn(t);if(s.length%32===0)try{return this.#i.decode(e.outputs,s)}catch{n="could not decode result data"}pe(!1,n,"BAD_DATA",{value:Ce(s),info:{method:e.name,signature:e.format()}})}makeError(e,t){const n=lt(e,"data"),s=Oa.getBuiltinCallException("call",t,n);if(s.message.startsWith("execution reverted (unknown custom error)")){const o=Ce(n.slice(0,4)),c=this.getError(o);if(c)try{const l=this.#i.decode(c.inputs,n.slice(4));s.revert={name:c.name,signature:c.format(),args:l},s.reason=s.revert.signature,s.message=`execution reverted: ${s.reason}`}catch{s.message="execution reverted (coult not decode custom error)"}}const a=this.parseTransaction(t);return a&&(s.invocation={method:a.name,signature:a.signature,args:a.args}),s}encodeFunctionResult(e,t){if(typeof e=="string"){const n=this.getFunction(e);V(n,"unknown function","fragment",e),e=n}return Ce(this.#i.encode(e.outputs,t||[]))}encodeFilterTopics(e,t){if(typeof e=="string"){const r=this.getEvent(e);V(r,"unknown event","eventFragment",e),e=r}pe(t.length<=e.inputs.length,`too many arguments for ${e.format()}`,"UNEXPECTED_ARGUMENT",{count:t.length,expectedCount:e.inputs.length});const n=[];e.anonymous||n.push(e.topicHash);const s=(r,a)=>r.type==="string"?Er(a):r.type==="bytes"?$t(Ce(a)):(r.type==="bool"&&typeof a=="boolean"?a=a?"0x01":"0x00":r.type.match(/^u?int/)?a=Os(a):r.type.match(/^bytes/)?a=wT(a,32):r.type==="address"&&this.#i.encode(["address"],[a]),is(Ce(a),32));for(t.forEach((r,a)=>{const o=e.inputs[a];if(!o.indexed){V(r==null,"cannot filter non-indexed parameters; must be null","contract."+o.name,r);return}r==null?n.push(null):o.baseType==="array"||o.baseType==="tuple"?V(!1,"filtering with tuples or arrays not supported","contract."+o.name,r):Array.isArray(r)?n.push(r.map(c=>s(o,c))):n.push(s(o,r))});n.length&&n[n.length-1]===null;)n.pop();return n}encodeEventLog(e,t){if(typeof e=="string"){const a=this.getEvent(e);V(a,"unknown event","eventFragment",e),e=a}const n=[],s=[],r=[];return e.anonymous||n.push(e.topicHash),V(t.length===e.inputs.length,"event arguments/values mismatch","values",t),e.inputs.forEach((a,o)=>{const c=t[o];if(a.indexed)if(a.type==="string")n.push(Er(c));else if(a.type==="bytes")n.push($t(c));else{if(a.baseType==="tuple"||a.baseType==="array")throw new Error("not implemented");n.push(this.#i.encode([a.type],[c]))}else s.push(a),r.push(c)}),{data:this.#i.encode(s,r),topics:n}}decodeEventLog(e,t,n){if(typeof e=="string"){const f=this.getEvent(e);V(f,"unknown event","eventFragment",e),e=f}if(n!=null&&!e.anonymous){const f=e.topicHash;V(Ft(n[0],32)&&n[0].toLowerCase()===f,"fragment/topic mismatch","topics[0]",n[0]),n=n.slice(1)}const s=[],r=[],a=[];e.inputs.forEach((f,m)=>{f.indexed?f.type==="string"||f.type==="bytes"||f.baseType==="tuple"||f.baseType==="array"?(s.push(Dt.from({type:"bytes32",name:f.name})),a.push(!0)):(s.push(f),a.push(!1)):(r.push(f),a.push(!1))});const o=n!=null?this.#i.decode(s,Ot(n)):null,c=this.#i.decode(r,t,!0),l=[],h=[];let u=0,d=0;return e.inputs.forEach((f,m)=>{let A=null;if(f.indexed)if(o==null)A=new vx(null);else if(a[m])A=new vx(o[d++]);else try{A=o[d++]}catch(g){A=g}else try{A=c[u++]}catch(g){A=g}l.push(A),h.push(f.name||null)}),as.fromItems(l,h)}parseTransaction(e){const t=lt(e.data,"tx.data"),n=Re(e.value!=null?e.value:0,"tx.value"),s=this.getFunction(Ce(t.slice(0,4)));if(!s)return null;const r=this.#i.decode(s.inputs,t.slice(4));return new VF(s,s.selector,r,n)}parseCallResult(e){throw new Error("@TODO")}parseLog(e){const t=this.getEvent(e.topics[0]);return!t||t.anonymous?null:new zF(t,t.topicHash,this.decodeEventLog(t,e.data,e.topics))}parseError(e){const t=Ce(e),n=this.getError(Vt(t,0,4));if(!n)return null;const s=this.#i.decode(n.inputs,Vt(t,4));return new WF(n,n.selector,s)}static from(e){return e instanceof Ir?e:typeof e=="string"?new Ir(JSON.parse(e)):typeof e.formatJson=="function"?new Ir(e.formatJson()):typeof e.format=="function"?new Ir(e.format("json")):new Ir(e)}}const Ix=BigInt(0);function Qa(i){return i??null}function Xt(i){return i==null?null:i.toString()}class Mx{gasPrice;maxFeePerGas;maxPriorityFeePerGas;constructor(e,t,n){Xe(this,{gasPrice:Qa(e),maxFeePerGas:Qa(t),maxPriorityFeePerGas:Qa(n)})}toJSON(){const{gasPrice:e,maxFeePerGas:t,maxPriorityFeePerGas:n}=this;return{_type:"FeeData",gasPrice:Xt(e),maxFeePerGas:Xt(t),maxPriorityFeePerGas:Xt(n)}}}function ah(i){const e={};i.to&&(e.to=i.to),i.from&&(e.from=i.from),i.data&&(e.data=Ce(i.data));const t="chainId,gasLimit,gasPrice,maxFeePerBlobGas,maxFeePerGas,maxPriorityFeePerGas,value".split(/,/);for(const s of t)!(s in i)||i[s]==null||(e[s]=Re(i[s],`request.${s}`));const n="type,nonce".split(/,/);for(const s of n)!(s in i)||i[s]==null||(e[s]=ht(i[s],`request.${s}`));return i.accessList&&(e.accessList=xr(i.accessList)),i.authorizationList&&(e.authorizationList=i.authorizationList.slice()),"blockTag"in i&&(e.blockTag=i.blockTag),"enableCcipRead"in i&&(e.enableCcipRead=!!i.enableCcipRead),"customData"in i&&(e.customData=i.customData),"blobVersionedHashes"in i&&i.blobVersionedHashes&&(e.blobVersionedHashes=i.blobVersionedHashes.slice()),"kzg"in i&&(e.kzg=i.kzg),"blobWrapperVersion"in i&&(e.blobWrapperVersion=i.blobWrapperVersion),"blobs"in i&&i.blobs&&(e.blobs=i.blobs.map(s=>Kd(s)?Ce(s):Object.assign({},s))),e}class qF{provider;number;hash;timestamp;parentHash;parentBeaconBlockRoot;nonce;difficulty;gasLimit;gasUsed;stateRoot;receiptsRoot;blobGasUsed;excessBlobGas;miner;prevRandao;extraData;baseFeePerGas;#e;constructor(e,t){this.#e=e.transactions.map(n=>typeof n!="string"?new $o(n,t):n),Xe(this,{provider:t,hash:Qa(e.hash),number:e.number,timestamp:e.timestamp,parentHash:e.parentHash,parentBeaconBlockRoot:e.parentBeaconBlockRoot,nonce:e.nonce,difficulty:e.difficulty,gasLimit:e.gasLimit,gasUsed:e.gasUsed,blobGasUsed:e.blobGasUsed,excessBlobGas:e.excessBlobGas,miner:e.miner,prevRandao:Qa(e.prevRandao),extraData:e.extraData,baseFeePerGas:Qa(e.baseFeePerGas),stateRoot:e.stateRoot,receiptsRoot:e.receiptsRoot})}get transactions(){return this.#e.map(e=>typeof e=="string"?e:e.hash)}get prefetchedTransactions(){const e=this.#e.slice();return e.length===0?[]:(pe(typeof e[0]=="object","transactions were not prefetched with block request","UNSUPPORTED_OPERATION",{operation:"transactionResponses()"}),e)}toJSON(){const{baseFeePerGas:e,difficulty:t,extraData:n,gasLimit:s,gasUsed:r,hash:a,miner:o,prevRandao:c,nonce:l,number:h,parentHash:u,parentBeaconBlockRoot:d,stateRoot:f,receiptsRoot:m,timestamp:A,transactions:g}=this;return{_type:"Block",baseFeePerGas:Xt(e),difficulty:Xt(t),extraData:n,gasLimit:Xt(s),gasUsed:Xt(r),blobGasUsed:Xt(this.blobGasUsed),excessBlobGas:Xt(this.excessBlobGas),hash:a,miner:o,prevRandao:c,nonce:l,number:h,parentHash:u,timestamp:A,parentBeaconBlockRoot:d,stateRoot:f,receiptsRoot:m,transactions:g}}[Symbol.iterator](){let e=0;const t=this.transactions;return{next:()=>e<this.length?{value:t[e++],done:!1}:{value:void 0,done:!0}}}get length(){return this.#e.length}get date(){return this.timestamp==null?null:new Date(this.timestamp*1e3)}async getTransaction(e){let t;if(typeof e=="number")t=this.#e[e];else{const n=e.toLowerCase();for(const s of this.#e)if(typeof s=="string"){if(s!==n)continue;t=s;break}else{if(s.hash!==n)continue;t=s;break}}if(t==null)throw new Error("no such tx");return typeof t=="string"?await this.provider.getTransaction(t):t}getPrefetchedTransaction(e){const t=this.prefetchedTransactions;if(typeof e=="number")return t[e];e=e.toLowerCase();for(const n of t)if(n.hash===e)return n;V(!1,"no matching transaction","indexOrHash",e)}isMined(){return!!this.hash}isLondon(){return!!this.baseFeePerGas}orphanedEvent(){if(!this.isMined())throw new Error("");return KF(this)}}class Zo{provider;transactionHash;blockHash;blockNumber;removed;address;data;topics;index;transactionIndex;constructor(e,t){this.provider=t;const n=Object.freeze(e.topics.slice());Xe(this,{transactionHash:e.transactionHash,blockHash:e.blockHash,blockNumber:e.blockNumber,removed:e.removed,address:e.address,data:e.data,topics:n,index:e.index,transactionIndex:e.transactionIndex})}toJSON(){const{address:e,blockHash:t,blockNumber:n,data:s,index:r,removed:a,topics:o,transactionHash:c,transactionIndex:l}=this;return{_type:"log",address:e,blockHash:t,blockNumber:n,data:s,index:r,removed:a,topics:o,transactionHash:c,transactionIndex:l}}async getBlock(){const e=await this.provider.getBlock(this.blockHash);return pe(!!e,"failed to find transaction","UNKNOWN_ERROR",{}),e}async getTransaction(){const e=await this.provider.getTransaction(this.transactionHash);return pe(!!e,"failed to find transaction","UNKNOWN_ERROR",{}),e}async getTransactionReceipt(){const e=await this.provider.getTransactionReceipt(this.transactionHash);return pe(!!e,"failed to find transaction receipt","UNKNOWN_ERROR",{}),e}removedEvent(){return jF(this)}}class Bx{provider;to;from;contractAddress;hash;index;blockHash;blockNumber;logsBloom;gasUsed;blobGasUsed;cumulativeGasUsed;gasPrice;blobGasPrice;type;status;root;#e;constructor(e,t){this.#e=Object.freeze(e.logs.map(s=>new Zo(s,t)));let n=Ix;e.effectiveGasPrice!=null?n=e.effectiveGasPrice:e.gasPrice!=null&&(n=e.gasPrice),Xe(this,{provider:t,to:e.to,from:e.from,contractAddress:e.contractAddress,hash:e.hash,index:e.index,blockHash:e.blockHash,blockNumber:e.blockNumber,logsBloom:e.logsBloom,gasUsed:e.gasUsed,cumulativeGasUsed:e.cumulativeGasUsed,blobGasUsed:e.blobGasUsed,gasPrice:n,blobGasPrice:e.blobGasPrice,type:e.type,status:e.status,root:e.root})}get logs(){return this.#e}toJSON(){const{to:e,from:t,contractAddress:n,hash:s,index:r,blockHash:a,blockNumber:o,logsBloom:c,logs:l,status:h,root:u}=this;return{_type:"TransactionReceipt",blockHash:a,blockNumber:o,contractAddress:n,cumulativeGasUsed:Xt(this.cumulativeGasUsed),from:t,gasPrice:Xt(this.gasPrice),blobGasUsed:Xt(this.blobGasUsed),blobGasPrice:Xt(this.blobGasPrice),gasUsed:Xt(this.gasUsed),hash:s,index:r,logs:l,logsBloom:c,root:u,status:h,to:e}}get length(){return this.logs.length}[Symbol.iterator](){let e=0;return{next:()=>e<this.length?{value:this.logs[e++],done:!1}:{value:void 0,done:!0}}}get fee(){return this.gasUsed*this.gasPrice}async getBlock(){const e=await this.provider.getBlock(this.blockHash);if(e==null)throw new Error("TODO");return e}async getTransaction(){const e=await this.provider.getTransaction(this.hash);if(e==null)throw new Error("TODO");return e}async getResult(){return await this.provider.getTransactionResult(this.hash)}async confirmations(){return await this.provider.getBlockNumber()-this.blockNumber+1}removedEvent(){return Rx(this)}reorderedEvent(e){return pe(!e||e.isMined(),"unmined 'other' transction cannot be orphaned","UNSUPPORTED_OPERATION",{operation:"reorderedEvent(other)"}),Tx(this,e)}}class $o{provider;blockNumber;blockHash;index;hash;type;to;from;nonce;gasLimit;gasPrice;maxPriorityFeePerGas;maxFeePerGas;maxFeePerBlobGas;data;value;chainId;signature;accessList;blobVersionedHashes;authorizationList;#e;constructor(e,t){this.provider=t,this.blockNumber=e.blockNumber!=null?e.blockNumber:null,this.blockHash=e.blockHash!=null?e.blockHash:null,this.hash=e.hash,this.index=e.index,this.type=e.type,this.from=e.from,this.to=e.to||null,this.gasLimit=e.gasLimit,this.nonce=e.nonce,this.data=e.data,this.value=e.value,this.gasPrice=e.gasPrice,this.maxPriorityFeePerGas=e.maxPriorityFeePerGas!=null?e.maxPriorityFeePerGas:null,this.maxFeePerGas=e.maxFeePerGas!=null?e.maxFeePerGas:null,this.maxFeePerBlobGas=e.maxFeePerBlobGas!=null?e.maxFeePerBlobGas:null,this.chainId=e.chainId,this.signature=e.signature,this.accessList=e.accessList!=null?e.accessList:null,this.blobVersionedHashes=e.blobVersionedHashes!=null?e.blobVersionedHashes:null,this.authorizationList=e.authorizationList!=null?e.authorizationList:null,this.#e=-1}toJSON(){const{blockNumber:e,blockHash:t,index:n,hash:s,type:r,to:a,from:o,nonce:c,data:l,signature:h,accessList:u,blobVersionedHashes:d}=this;return{_type:"TransactionResponse",accessList:u,blockNumber:e,blockHash:t,blobVersionedHashes:d,chainId:Xt(this.chainId),data:l,from:o,gasLimit:Xt(this.gasLimit),gasPrice:Xt(this.gasPrice),hash:s,maxFeePerGas:Xt(this.maxFeePerGas),maxPriorityFeePerGas:Xt(this.maxPriorityFeePerGas),maxFeePerBlobGas:Xt(this.maxFeePerBlobGas),nonce:c,signature:h,to:a,index:n,type:r,value:Xt(this.value)}}async getBlock(){let e=this.blockNumber;if(e==null){const n=await this.getTransaction();n&&(e=n.blockNumber)}if(e==null)return null;const t=this.provider.getBlock(e);if(t==null)throw new Error("TODO");return t}async getTransaction(){return this.provider.getTransaction(this.hash)}async confirmations(){if(this.blockNumber==null){const{tx:t,blockNumber:n}=await Fn({tx:this.getTransaction(),blockNumber:this.provider.getBlockNumber()});return t==null||t.blockNumber==null?0:n-t.blockNumber+1}return await this.provider.getBlockNumber()-this.blockNumber+1}async wait(e,t){const n=e??1,s=t??0;let r=this.#e,a=-1,o=r===-1;const c=async()=>{if(o)return null;const{blockNumber:d,nonce:f}=await Fn({blockNumber:this.provider.getBlockNumber(),nonce:this.provider.getTransactionCount(this.from)});if(f<this.nonce){r=d;return}if(o)return null;const m=await this.getTransaction();if(!(m&&m.blockNumber!=null))for(a===-1&&(a=r-3,a<this.#e&&(a=this.#e));a<=d;){if(o)return null;const A=await this.provider.getBlock(a,!0);if(A==null)return;for(const g of A)if(g===this.hash)return;for(let g=0;g<A.length;g++){const p=await A.getTransaction(g);if(p.from===this.from&&p.nonce===this.nonce){if(o)return null;const y=await this.provider.getTransactionReceipt(p.hash);if(y==null||d-y.blockNumber+1<n)return;let b="replaced";p.data===this.data&&p.to===this.to&&p.value===this.value?b="repriced":p.data==="0x"&&p.from===p.to&&p.value===Ix&&(b="cancelled"),pe(!1,"transaction was replaced","TRANSACTION_REPLACED",{cancelled:b==="replaced"||b==="cancelled",reason:b,replacement:p.replaceableTransaction(r),hash:p.hash,receipt:y})}}a++}},l=d=>{if(d==null||d.status!==0)return d;pe(!1,"transaction execution reverted","CALL_EXCEPTION",{action:"sendTransaction",data:null,reason:null,invocation:null,revert:null,transaction:{to:d.to,from:d.from,data:""},receipt:d})},h=await this.provider.getTransactionReceipt(this.hash);if(n===0)return l(h);if(h){if(n===1||await h.confirmations()>=n)return l(h)}else if(await c(),n===0)return null;return await new Promise((d,f)=>{const m=[],A=()=>{m.forEach(p=>p())};if(m.push(()=>{o=!0}),s>0){const p=setTimeout(()=>{A(),f(Ut("wait for transaction timeout","TIMEOUT"))},s);m.push(()=>{clearTimeout(p)})}const g=async p=>{if(await p.confirmations()>=n){A();try{d(l(p))}catch(y){f(y)}}};if(m.push(()=>{this.provider.off(this.hash,g)}),this.provider.on(this.hash,g),r>=0){const p=async()=>{try{await c()}catch(y){if(En(y,"TRANSACTION_REPLACED")){A(),f(y);return}}o||this.provider.once("block",p)};m.push(()=>{this.provider.off("block",p)}),this.provider.once("block",p)}})}isMined(){return this.blockHash!=null}isLegacy(){return this.type===0}isBerlin(){return this.type===1}isLondon(){return this.type===2}isCancun(){return this.type===3}removedEvent(){return pe(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),Rx(this)}reorderedEvent(e){return pe(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),pe(!e||e.isMined(),"unmined 'other' transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),Tx(this,e)}replaceableTransaction(e){V(Number.isInteger(e)&&e>=0,"invalid startBlock","startBlock",e);const t=new $o(this,this.provider);return t.#e=e,t}}function KF(i){return{orphan:"drop-block",hash:i.hash,number:i.number}}function Tx(i,e){return{orphan:"reorder-transaction",tx:i,other:e}}function Rx(i){return{orphan:"drop-transaction",tx:i}}function jF(i){return{orphan:"drop-log",log:{transactionHash:i.transactionHash,blockHash:i.blockHash,blockNumber:i.blockNumber,address:i.address,data:i.data,topics:Object.freeze(i.topics.slice()),index:i.index}}}class kf extends Zo{interface;fragment;args;constructor(e,t,n){super(e,e.provider);const s=t.decodeEventLog(n,e.data,e.topics);Xe(this,{args:s,fragment:n,interface:t})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}class Nx extends Zo{error;constructor(e,t){super(e,e.provider),Xe(this,{error:t})}}class XF extends Bx{#e;constructor(e,t,n){super(n,t),this.#e=e}get logs(){return super.logs.map(e=>{const t=e.topics.length?this.#e.getEvent(e.topics[0]):null;if(t)try{return new kf(e,this.#e,t)}catch(n){return new Nx(e,n)}return e})}}class Uf extends $o{#e;constructor(e,t,n){super(n,t),this.#e=e}async wait(e,t){const n=await super.wait(e,t);return n==null?null:new XF(this.#e,this.provider,n)}}class Fx extends f0{log;constructor(e,t,n,s){super(e,t,n),Xe(this,{log:s})}async getBlock(){return await this.log.getBlock()}async getTransaction(){return await this.log.getTransaction()}async getTransactionReceipt(){return await this.log.getTransactionReceipt()}}class YF extends Fx{constructor(e,t,n,s,r){super(e,t,n,new kf(r,e.interface,s));const a=e.interface.decodeEventLog(s,this.log.data,this.log.topics);Xe(this,{args:a,fragment:s})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}const Dx=BigInt(0);function Lx(i){return i&&typeof i.call=="function"}function Px(i){return i&&typeof i.estimateGas=="function"}function oh(i){return i&&typeof i.resolveName=="function"}function kx(i){return i&&typeof i.sendTransaction=="function"}function Ux(i){if(i!=null){if(oh(i))return i;if(i.provider)return i.provider}}class JF{#e;fragment;constructor(e,t,n){if(Xe(this,{fragment:t}),t.inputs.length<n.length)throw new Error("too many arguments");const s=Mr(e.runner,"resolveName"),r=oh(s)?s:null;this.#e=(async function(){const a=await Promise.all(t.inputs.map((o,c)=>n[c]==null?null:o.walkAsync(n[c],(h,u)=>h==="address"?Array.isArray(u)?Promise.all(u.map(d=>Pn(d,r))):Pn(u,r):u)));return e.interface.encodeFilterTopics(t,a)})()}getTopicFilter(){return this.#e}}function Mr(i,e){return i==null?null:typeof i[e]=="function"?i:i.provider&&typeof i.provider[e]=="function"?i.provider:null}function Br(i){return i==null?null:i.provider||null}async function Ox(i,e){const t=Wt.dereference(i,"overrides");V(typeof t=="object","invalid overrides parameter","overrides",i);const n=ah(t);return V(n.to==null||(e||[]).indexOf("to")>=0,"cannot override to","overrides.to",n.to),V(n.data==null||(e||[]).indexOf("data")>=0,"cannot override data","overrides.data",n.data),n.from&&(n.from=n.from),n}async function ZF(i,e,t){const n=Mr(i,"resolveName"),s=oh(n)?n:null;return await Promise.all(e.map((r,a)=>r.walkAsync(t[a],(o,c)=>(c=Wt.dereference(c,o),o==="address"?Pn(c,s):c))))}function $F(i){const e=async function(a){const o=await Ox(a,["data"]);o.to=await i.getAddress(),o.from&&(o.from=await Pn(o.from,Ux(i.runner)));const c=i.interface,l=Re(o.value||Dx,"overrides.value")===Dx,h=(o.data||"0x")==="0x";c.fallback&&!c.fallback.payable&&c.receive&&!h&&!l&&V(!1,"cannot send data to receive or send value to non-payable fallback","overrides",a),V(c.fallback||h,"cannot send data to receive-only contract","overrides.data",o.data);const u=c.receive||c.fallback&&c.fallback.payable;return V(u||l,"cannot send value to non-payable fallback","overrides.value",o.value),V(c.fallback||h,"cannot send data to receive-only contract","overrides.data",o.data),o},t=async function(a){const o=Mr(i.runner,"call");pe(Lx(o),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const c=await e(a);try{return await o.call(c)}catch(l){throw qd(l)&&l.data?i.interface.makeError(l.data,c):l}},n=async function(a){const o=i.runner;pe(kx(o),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const c=await o.sendTransaction(await e(a)),l=Br(i.runner);return new Uf(i.interface,l,c)},s=async function(a){const o=Mr(i.runner,"estimateGas");return pe(Px(o),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await o.estimateGas(await e(a))},r=async a=>await n(a);return Xe(r,{_contract:i,estimateGas:s,populateTransaction:e,send:n,staticCall:t}),r}function eD(i,e){const t=function(...l){const h=i.interface.getFunction(e,l);return pe(h,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e,args:l}}),h},n=async function(...l){const h=t(...l);let u={};if(h.inputs.length+1===l.length&&(u=await Ox(l.pop()),u.from&&(u.from=await Pn(u.from,Ux(i.runner)))),h.inputs.length!==l.length)throw new Error("internal error: fragment inputs doesn't match arguments; should not happen");const d=await ZF(i.runner,h.inputs,l);return Object.assign({},u,await Fn({to:i.getAddress(),data:i.interface.encodeFunctionData(h,d)}))},s=async function(...l){const h=await o(...l);return h.length===1?h[0]:h},r=async function(...l){const h=i.runner;pe(kx(h),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const u=await h.sendTransaction(await n(...l)),d=Br(i.runner);return new Uf(i.interface,d,u)},a=async function(...l){const h=Mr(i.runner,"estimateGas");return pe(Px(h),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await h.estimateGas(await n(...l))},o=async function(...l){const h=Mr(i.runner,"call");pe(Lx(h),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const u=await n(...l);let d="0x";try{d=await h.call(u)}catch(m){throw qd(m)&&m.data?i.interface.makeError(m.data,u):m}const f=t(...l);return i.interface.decodeFunctionResult(f,d)},c=async(...l)=>t(...l).constant?await s(...l):await r(...l);return Xe(c,{name:i.interface.getFunctionName(e),_contract:i,_key:e,getFragment:t,estimateGas:a,populateTransaction:n,send:r,staticCall:s,staticCallResult:o}),Object.defineProperty(c,"fragment",{configurable:!1,enumerable:!0,get:()=>{const l=i.interface.getFunction(e);return pe(l,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e}}),l}}),c}function tD(i,e){const t=function(...s){const r=i.interface.getEvent(e,s);return pe(r,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e,args:s}}),r},n=function(...s){return new JF(i,t(...s),s)};return Xe(n,{name:i.interface.getEventName(e),_contract:i,_key:e,getFragment:t}),Object.defineProperty(n,"fragment",{configurable:!1,enumerable:!0,get:()=>{const s=i.interface.getEvent(e);return pe(s,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e}}),s}}),n}const ch=Symbol.for("_ethersInternal_contract"),Qx=new WeakMap;function nD(i,e){Qx.set(i[ch],e)}function Xn(i){return Qx.get(i[ch])}function iD(i){return i&&typeof i=="object"&&"getTopicFilter"in i&&typeof i.getTopicFilter=="function"&&i.fragment}async function Of(i,e){let t,n=null;if(Array.isArray(e)){const r=function(a){if(Ft(a,32))return a;const o=i.interface.getEvent(a);return V(o,"unknown fragment","name",a),o.topicHash};t=e.map(a=>a==null?null:Array.isArray(a)?a.map(r):r(a))}else e==="*"?t=[null]:typeof e=="string"?Ft(e,32)?t=[e]:(n=i.interface.getEvent(e),V(n,"unknown fragment","event",e),t=[n.topicHash]):iD(e)?t=await e.getTopicFilter():"fragment"in e?(n=e.fragment,t=[n.topicHash]):V(!1,"unknown event name","event",e);t=t.map(r=>{if(r==null)return null;if(Array.isArray(r)){const a=Array.from(new Set(r.map(o=>o.toLowerCase())).values());return a.length===1?a[0]:(a.sort(),a)}return r.toLowerCase()});const s=t.map(r=>r==null?"null":Array.isArray(r)?r.join("|"):r).join("&");return{fragment:n,tag:s,topics:t}}async function ec(i,e){const{subs:t}=Xn(i);return t.get((await Of(i,e)).tag)||null}async function Gx(i,e,t){const n=Br(i.runner);pe(n,"contract runner does not support subscribing","UNSUPPORTED_OPERATION",{operation:e});const{fragment:s,tag:r,topics:a}=await Of(i,t),{addr:o,subs:c}=Xn(i);let l=c.get(r);if(!l){const u={address:o||i,topics:a},d=g=>{let p=s;if(p==null)try{p=i.interface.getEvent(g.topics[0])}catch{}if(p){const y=p,b=s?i.interface.decodeEventLog(s,g.data,g.topics):[];Gf(i,t,b,E=>new YF(i,E,t,y,g))}else Gf(i,t,[],y=>new Fx(i,y,t,g))};let f=[];l={tag:r,listeners:[],start:()=>{f.length||f.push(n.on(u,d))},stop:async()=>{if(f.length==0)return;let g=f;f=[],await Promise.all(g),n.off(u,d)}},c.set(r,l)}return l}let Qf=Promise.resolve();async function sD(i,e,t,n){await Qf;const s=await ec(i,e);if(!s)return!1;const r=s.listeners.length;return s.listeners=s.listeners.filter(({listener:a,once:o})=>{const c=Array.from(t);n&&c.push(n(o?null:a));try{a.call(i,...c)}catch{}return!o}),s.listeners.length===0&&(s.stop(),Xn(i).subs.delete(s.tag)),r>0}async function Gf(i,e,t,n){try{await Qf}catch{}const s=sD(i,e,t,n);return Qf=s,await s}const lh=["then"];class tc{target;interface;runner;filters;[ch];fallback;constructor(e,t,n,s){V(typeof e=="string"||_b(e),"invalid value for Contract target","target",e),n==null&&(n=null);const r=Ir.from(t);Xe(this,{target:e,runner:n,interface:r}),Object.defineProperty(this,ch,{value:{}});let a,o=null,c=null;if(s){const u=Br(n);c=new Uf(this.interface,u,s)}let l=new Map;if(typeof e=="string")if(Ft(e))o=e,a=Promise.resolve(e);else{const u=Mr(n,"resolveName");if(!oh(u))throw Ut("contract runner does not support name resolution","UNSUPPORTED_OPERATION",{operation:"resolveName"});a=u.resolveName(e).then(d=>{if(d==null)throw Ut("an ENS name used for a contract target must be correctly configured","UNCONFIGURED_NAME",{value:e});return Xn(this).addr=d,d})}else a=e.getAddress().then(u=>{if(u==null)throw new Error("TODO");return Xn(this).addr=u,u});nD(this,{addrPromise:a,addr:o,deployTx:c,subs:l});const h=new Proxy({},{get:(u,d,f)=>{if(typeof d=="symbol"||lh.indexOf(d)>=0)return Reflect.get(u,d,f);try{return this.getEvent(d)}catch(m){if(!En(m,"INVALID_ARGUMENT")||m.argument!=="key")throw m}},has:(u,d)=>lh.indexOf(d)>=0?Reflect.has(u,d):Reflect.has(u,d)||this.interface.hasEvent(String(d))});return Xe(this,{filters:h}),Xe(this,{fallback:r.receive||r.fallback?$F(this):null}),new Proxy(this,{get:(u,d,f)=>{if(typeof d=="symbol"||d in u||lh.indexOf(d)>=0)return Reflect.get(u,d,f);try{return u.getFunction(d)}catch(m){if(!En(m,"INVALID_ARGUMENT")||m.argument!=="key")throw m}},has:(u,d)=>typeof d=="symbol"||d in u||lh.indexOf(d)>=0?Reflect.has(u,d):u.interface.hasFunction(d)})}connect(e){return new tc(this.target,this.interface,e)}attach(e){return new tc(e,this.interface,this.runner)}async getAddress(){return await Xn(this).addrPromise}async getDeployedCode(){const e=Br(this.runner);pe(e,"runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"getDeployedCode"});const t=await e.getCode(await this.getAddress());return t==="0x"?null:t}async waitForDeployment(){const e=this.deploymentTransaction();if(e)return await e.wait(),this;if(await this.getDeployedCode()!=null)return this;const n=Br(this.runner);return pe(n!=null,"contract runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"waitForDeployment"}),new Promise((s,r)=>{const a=async()=>{try{if(await this.getDeployedCode()!=null)return s(this);n.once("block",a)}catch(o){r(o)}};a()})}deploymentTransaction(){return Xn(this).deployTx}getFunction(e){return typeof e!="string"&&(e=e.format()),eD(this,e)}getEvent(e){return typeof e!="string"&&(e=e.format()),tD(this,e)}async queryTransaction(e){throw new Error("@TODO")}async queryFilter(e,t,n){t==null&&(t=0),n==null&&(n="latest");const{addr:s,addrPromise:r}=Xn(this),a=s||await r,{fragment:o,topics:c}=await Of(this,e),l={address:a,topics:c,fromBlock:t,toBlock:n},h=Br(this.runner);return pe(h,"contract runner does not have a provider","UNSUPPORTED_OPERATION",{operation:"queryFilter"}),(await h.getLogs(l)).map(u=>{let d=o;if(d==null)try{d=this.interface.getEvent(u.topics[0])}catch{}if(d)try{return new kf(u,this.interface,d)}catch(f){return new Nx(u,f)}return new Zo(u,h)})}async on(e,t){const n=await Gx(this,"on",e);return n.listeners.push({listener:t,once:!1}),n.start(),this}async once(e,t){const n=await Gx(this,"once",e);return n.listeners.push({listener:t,once:!0}),n.start(),this}async emit(e,...t){return await Gf(this,e,t,null)}async listenerCount(e){if(e){const s=await ec(this,e);return s?s.listeners.length:0}const{subs:t}=Xn(this);let n=0;for(const{listeners:s}of t.values())n+=s.length;return n}async listeners(e){if(e){const s=await ec(this,e);return s?s.listeners.map(({listener:r})=>r):[]}const{subs:t}=Xn(this);let n=[];for(const{listeners:s}of t.values())n=n.concat(s.map(({listener:r})=>r));return n}async off(e,t){const n=await ec(this,e);if(!n)return this;if(t){const s=n.listeners.map(({listener:r})=>r).indexOf(t);s>=0&&n.listeners.splice(s,1)}return(t==null||n.listeners.length===0)&&(n.stop(),Xn(this).subs.delete(n.tag)),this}async removeAllListeners(e){if(e){const t=await ec(this,e);if(!t)return this;t.stop(),Xn(this).subs.delete(t.tag)}else{const{subs:t}=Xn(this);for(const{tag:n,stop:s}of t.values())s(),t.delete(n)}return this}async addListener(e,t){return await this.on(e,t)}async removeListener(e,t){return await this.off(e,t)}static buildClass(e){class t extends tc{constructor(s,r=null){super(s,e,r)}}return t}static from(e,t,n){return n==null&&(n=null),new this(e,t,n)}}function rD(){return tc}class Tr extends rD(){}function Hf(i){return i.match(/^ipfs:\/\/ipfs\//i)?i=i.substring(12):i.match(/^ipfs:\/\//i)?i=i.substring(7):V(!1,"unsupported IPFS format","link",i),`https://gateway.ipfs.io/ipfs/${i}`}class aD{name;constructor(e){Xe(this,{name:e})}connect(e){return this}supportsCoinType(e){return!1}async encodeAddress(e,t){throw new Error("unsupported coin")}async decodeAddress(e,t){throw new Error("unsupported coin")}}const Hx=new RegExp("^(ipfs)://(.*)$","i"),zx=[new RegExp("^(https)://(.*)$","i"),new RegExp("^(data):(.*)$","i"),Hx,new RegExp("^eip155:[0-9]+/(erc[0-9]+):(.*)$","i")];class Ga{provider;address;name;#e;#t;constructor(e,t,n){Xe(this,{provider:e,address:t,name:n}),this.#e=null,this.#t=new Tr(t,["function supportsInterface(bytes4) view returns (bool)","function resolve(bytes, bytes) view returns (bytes)","function addr(bytes32) view returns (address)","function addr(bytes32, uint) view returns (bytes)","function text(bytes32, string) view returns (string)","function contenthash(bytes32) view returns (bytes)"],e)}async supportsWildcard(){return this.#e==null&&(this.#e=(async()=>{try{return await this.#t.supportsInterface("0x9061b923")}catch(e){if(En(e,"CALL_EXCEPTION"))return!1;throw this.#e=null,e}})()),await this.#e}async#n(e,t){t=(t||[]).slice();const n=this.#t.interface;t.unshift(Ff(this.name));let s=null;await this.supportsWildcard()&&(s=n.getFunction(e),pe(s,"missing fragment","UNKNOWN_ERROR",{info:{funcName:e}}),t=[wF(this.name,255),n.encodeFunctionData(s,t)],e="resolve(bytes,bytes)"),t.push({enableCcipRead:!0});try{const r=await this.#t[e](...t);return s?n.decodeFunctionResult(s,r)[0]:r}catch(r){if(!En(r,"CALL_EXCEPTION"))throw r}return null}async getAddress(e){if(e==null&&(e=60),e===60)try{const r=await this.#n("addr(bytes32)");return r==null||r===Vo?null:r}catch(r){if(En(r,"CALL_EXCEPTION"))return null;throw r}if(e>=0&&e<2147483648){let r=e+2147483648;const a=await this.#n("addr(bytes32,uint)",[r]);if(Ft(a,20))return Ct(a)}let t=null;for(const r of this.provider.plugins)if(r instanceof aD&&r.supportsCoinType(e)){t=r;break}if(t==null)return null;const n=await this.#n("addr(bytes32,uint)",[e]);if(n==null||n==="0x")return null;const s=await t.decodeAddress(e,n);if(s!=null)return s;pe(!1,"invalid coin data","UNSUPPORTED_OPERATION",{operation:`getAddress(${e})`,info:{coinType:e,data:n}})}async getText(e){const t=await this.#n("text(bytes32,string)",[e]);return t==null||t==="0x"?null:t}async getContentHash(){const e=await this.#n("contenthash(bytes32)");if(e==null||e==="0x")return null;const t=e.match(/^0x(e3010170|e5010172)(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(t){const s=t[1]==="e3010170"?"ipfs":"ipns",r=parseInt(t[4],16);if(t[5].length===r*2)return`${s}://${ST("0x"+t[2])}`}const n=e.match(/^0xe40101fa011b20([0-9a-f]*)$/);if(n&&n[1].length===64)return`bzz://${n[1]}`;pe(!1,"invalid or unsupported content hash data","UNSUPPORTED_OPERATION",{operation:"getContentHash()",info:{data:e}})}async getAvatar(){return(await this._getAvatar()).url}async _getAvatar(){const e=[{type:"name",value:this.name}];try{const t=await this.getText("avatar");if(t==null)return e.push({type:"!avatar",value:""}),{url:null,linkage:e};e.push({type:"avatar",value:t});for(let n=0;n<zx.length;n++){const s=t.match(zx[n]);if(s==null)continue;const r=s[1].toLowerCase();switch(r){case"https":case"data":return e.push({type:"url",value:t}),{linkage:e,url:t};case"ipfs":{const a=Hf(t);return e.push({type:"ipfs",value:t}),e.push({type:"url",value:a}),{linkage:e,url:a}}case"erc721":case"erc1155":{const a=r==="erc721"?"tokenURI(uint256)":"uri(uint256)";e.push({type:r,value:t});const o=await this.getAddress();if(o==null)return e.push({type:"!owner",value:""}),{url:null,linkage:e};const c=(s[2]||"").split("/");if(c.length!==2)return e.push({type:`!${r}caip`,value:s[2]||""}),{url:null,linkage:e};const l=c[1],h=new Tr(c[0],["function tokenURI(uint) view returns (string)","function ownerOf(uint) view returns (address)","function uri(uint) view returns (string)","function balanceOf(address, uint256) view returns (uint)"],this.provider);if(r==="erc721"){const A=await h.ownerOf(l);if(o!==A)return e.push({type:"!owner",value:A}),{url:null,linkage:e};e.push({type:"owner",value:A})}else if(r==="erc1155"){const A=await h.balanceOf(o,l);if(!A)return e.push({type:"!balance",value:"0"}),{url:null,linkage:e};e.push({type:"balance",value:A.toString()})}let u=await h[a](l);if(u==null||u==="0x")return e.push({type:"!metadata-url",value:""}),{url:null,linkage:e};e.push({type:"metadata-url-base",value:u}),r==="erc1155"&&(u=u.replace("{id}",Os(l,32).substring(2)),e.push({type:"metadata-url-expanded",value:u})),u.match(/^ipfs:/i)&&(u=Hf(u)),e.push({type:"metadata-url",value:u});let d={};const f=await new ki(u).send();f.assertOk();try{d=f.bodyJson}catch{try{e.push({type:"!metadata",value:f.bodyText})}catch{const p=f.body;return p&&e.push({type:"!metadata",value:Ce(p)}),{url:null,linkage:e}}return{url:null,linkage:e}}if(!d)return e.push({type:"!metadata",value:""}),{url:null,linkage:e};e.push({type:"metadata",value:JSON.stringify(d)});let m=d.image;if(typeof m!="string")return e.push({type:"!imageUrl",value:""}),{url:null,linkage:e};if(!m.match(/^(https:\/\/|data:)/i)){if(m.match(Hx)==null)return e.push({type:"!imageUrl-ipfs",value:m}),{url:null,linkage:e};e.push({type:"imageUrl-ipfs",value:m}),m=Hf(m)}return e.push({type:"url",value:m}),{linkage:e,url:m}}}}}catch{}return{linkage:e,url:null}}static async getEnsAddress(e){const t=await e.getNetwork(),n=t.getPlugin("org.ethers.plugins.network.Ens");return pe(n,"network does not support ENS","UNSUPPORTED_OPERATION",{operation:"getEnsAddress",info:{network:t}}),n.address}static async#i(e,t){const n=await Ga.getEnsAddress(e);try{const r=await new Tr(n,["function resolver(bytes32) view returns (address)"],e).resolver(Ff(t),{enableCcipRead:!0});return r===Vo?null:r}catch(s){throw s}return null}static async fromName(e,t){let n=t;for(;;){if(n===""||n==="."||t!=="eth"&&n==="eth")return null;const s=await Ga.#i(e,n);if(s!=null){const r=new Ga(e,s,t);return n!==t&&!await r.supportsWildcard()?null:r}n=n.split(".").slice(1).join(".")}}}const Vx=BigInt(0);function mt(i,e){return(function(t){return t==null?e:i(t)})}function nc(i,e){return(t=>{if(e&&t==null)return null;if(!Array.isArray(t))throw new Error("not an array");return t.map(n=>i(n))})}function ic(i,e){return(t=>{const n={};for(const s in i){let r=s;if(e&&s in e&&!(r in t)){for(const a of e[s])if(a in t){r=a;break}}try{const a=i[s](t[r]);a!==void 0&&(n[s]=a)}catch(a){const o=a instanceof Error?a.message:"not-an-error";pe(!1,`invalid value for value.${s} (${o})`,"BAD_DATA",{value:t})}}return n})}function oD(i){switch(i){case!0:case"true":return!0;case!1:case"false":return!1}V(!1,`invalid boolean; ${JSON.stringify(i)}`,"value",i)}function Ha(i){return V(Ft(i,!0),"invalid data","value",i),i}function yn(i){return V(Ft(i,32),"invalid hash","value",i),i}const cD=ic({address:Ct,blockHash:yn,blockNumber:ht,data:Ha,index:ht,removed:mt(oD,!1),topics:nc(yn),transactionHash:yn,transactionIndex:ht},{index:["logIndex"]});function lD(i){return cD(i)}const hD=ic({hash:mt(yn),parentHash:yn,parentBeaconBlockRoot:mt(yn,null),number:ht,timestamp:ht,nonce:mt(Ha),difficulty:Re,gasLimit:Re,gasUsed:Re,stateRoot:mt(yn,null),receiptsRoot:mt(yn,null),blobGasUsed:mt(Re,null),excessBlobGas:mt(Re,null),miner:mt(Ct),prevRandao:mt(yn,null),extraData:Ha,baseFeePerGas:mt(Re)},{prevRandao:["mixHash"]});function uD(i){const e=hD(i);return e.transactions=i.transactions.map(t=>typeof t=="string"?t:Wx(t)),e}const dD=ic({transactionIndex:ht,blockNumber:ht,transactionHash:yn,address:Ct,topics:nc(yn),data:Ha,index:ht,blockHash:yn},{index:["logIndex"]});function fD(i){return dD(i)}const pD=ic({to:mt(Ct,null),from:mt(Ct,null),contractAddress:mt(Ct,null),index:ht,root:mt(Ce),gasUsed:Re,blobGasUsed:mt(Re,null),logsBloom:mt(Ha),blockHash:yn,hash:yn,logs:nc(fD),blockNumber:ht,cumulativeGasUsed:Re,effectiveGasPrice:mt(Re),blobGasPrice:mt(Re,null),status:mt(ht),type:mt(ht,0)},{effectiveGasPrice:["gasPrice"],hash:["transactionHash"],index:["transactionIndex"]});function AD(i){return pD(i)}function Wx(i){i.to&&Re(i.to)===Vx&&(i.to="0x0000000000000000000000000000000000000000");const e=ic({hash:yn,index:mt(ht,void 0),type:t=>t==="0x"||t==null?0:ht(t),accessList:mt(xr,null),blobVersionedHashes:mt(nc(yn,!0),null),authorizationList:mt(nc(t=>{let n;if(t.signature)n=t.signature;else{let s=t.yParity;s==="0x1b"?s=0:s==="0x1c"&&(s=1),n=Object.assign({},t,{yParity:s})}return{address:Ct(t.address),chainId:Re(t.chainId),nonce:Re(t.nonce),signature:Gt.from(n)}},!1),null),blockHash:mt(yn,null),blockNumber:mt(ht,null),transactionIndex:mt(ht,null),from:Ct,gasPrice:mt(Re),maxPriorityFeePerGas:mt(Re),maxFeePerGas:mt(Re),maxFeePerBlobGas:mt(Re,null),gasLimit:Re,to:mt(Ct,null),value:Re,nonce:ht,data:Ha,creates:mt(Ct,null),chainId:mt(Re,null)},{data:["input"],gasLimit:["gas"],index:["transactionIndex"]})(i);if(e.to==null&&e.creates==null&&(e.creates=sN(e)),(i.type===1||i.type===2)&&i.accessList==null&&(e.accessList=[]),i.signature?e.signature=Gt.from(i.signature):e.signature=Gt.from(i),e.chainId==null){const t=e.signature.legacyChainId;t!=null&&(e.chainId=t)}return e.blockHash&&Re(e.blockHash)===Vx&&(e.blockHash=null),e}const gD="0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";class sc{name;constructor(e){Xe(this,{name:e})}clone(){return new sc(this.name)}}class hh extends sc{effectiveBlock;txBase;txCreate;txDataZero;txDataNonzero;txAccessListStorageKey;txAccessListAddress;constructor(e,t){e==null&&(e=0),super(`org.ethers.network.plugins.GasCost#${e||0}`);const n={effectiveBlock:e};function s(r,a){let o=(t||{})[r];o==null&&(o=a),V(typeof o=="number",`invalud value for ${r}`,"costs",t),n[r]=o}s("txBase",21e3),s("txCreate",32e3),s("txDataZero",4),s("txDataNonzero",16),s("txAccessListStorageKey",1900),s("txAccessListAddress",2400),Xe(this,n)}clone(){return new hh(this.effectiveBlock,this)}}class uh extends sc{address;targetNetwork;constructor(e,t){super("org.ethers.plugins.network.Ens"),Xe(this,{address:e||gD,targetNetwork:t??1})}clone(){return new uh(this.address,this.targetNetwork)}}class mD extends sc{#e;#t;get url(){return this.#e}get processFunc(){return this.#t}constructor(e,t){super("org.ethers.plugins.network.FetchUrlFeeDataPlugin"),this.#e=e,this.#t=t}clone(){return this}}const zf=new Map;class Yn{#e;#t;#n;constructor(e,t){this.#e=e,this.#t=Re(t),this.#n=new Map}toJSON(){return{name:this.name,chainId:String(this.chainId)}}get name(){return this.#e}set name(e){this.#e=e}get chainId(){return this.#t}set chainId(e){this.#t=Re(e,"chainId")}matches(e){if(e==null)return!1;if(typeof e=="string"){try{return this.chainId===Re(e)}catch{}return this.name===e}if(typeof e=="number"||typeof e=="bigint"){try{return this.chainId===Re(e)}catch{}return!1}if(typeof e=="object"){if(e.chainId!=null){try{return this.chainId===Re(e.chainId)}catch{}return!1}return e.name!=null?this.name===e.name:!1}return!1}get plugins(){return Array.from(this.#n.values())}attachPlugin(e){if(this.#n.get(e.name))throw new Error(`cannot replace existing plugin: ${e.name} `);return this.#n.set(e.name,e.clone()),this}getPlugin(e){return this.#n.get(e)||null}getPlugins(e){return this.plugins.filter(t=>t.name.split("#")[0]===e)}clone(){const e=new Yn(this.name,this.chainId);return this.plugins.forEach(t=>{e.attachPlugin(t.clone())}),e}computeIntrinsicGas(e){const t=this.getPlugin("org.ethers.plugins.network.GasCost")||new hh;let n=t.txBase;if(e.to==null&&(n+=t.txCreate),e.data)for(let s=2;s<e.data.length;s+=2)e.data.substring(s,s+2)==="00"?n+=t.txDataZero:n+=t.txDataNonzero;if(e.accessList){const s=xr(e.accessList);for(const r in s)n+=t.txAccessListAddress+t.txAccessListStorageKey*s[r].storageKeys.length}return n}static from(e){if(bD(),e==null)return Yn.from("mainnet");if(typeof e=="number"&&(e=BigInt(e)),typeof e=="string"||typeof e=="bigint"){const t=zf.get(e);if(t)return t();if(typeof e=="bigint")return new Yn("unknown",e);V(!1,"unknown network","network",e)}if(typeof e.clone=="function")return e.clone();if(typeof e=="object"){V(typeof e.name=="string"&&typeof e.chainId=="number","invalid network object name or chainId","network",e);const t=new Yn(e.name,e.chainId);return(e.ensAddress||e.ensNetwork!=null)&&t.attachPlugin(new uh(e.ensAddress,e.ensNetwork)),t}V(!1,"invalid network","network",e)}static register(e,t){typeof e=="number"&&(e=BigInt(e));const n=zf.get(e);n&&V(!1,`conflicting network for ${JSON.stringify(n.name)}`,"nameOrChainId",e),zf.set(e,t)}}function qx(i,e){const t=String(i);if(!t.match(/^[0-9.]+$/))throw new Error(`invalid gwei value: ${i}`);const n=t.split(".");if(n.length===1&&n.push(""),n.length!==2)throw new Error(`invalid gwei value: ${i}`);for(;n[1].length<e;)n[1]+="0";if(n[1].length>9){let s=BigInt(n[1].substring(0,9));n[1].substring(9).match(/^0+$/)||s++,n[1]=s.toString()}return BigInt(n[0]+n[1])}function Kx(i){return new mD(i,async(e,t,n)=>{n.setHeader("User-Agent","ethers");let s;try{const[r,a]=await Promise.all([n.send(),e()]);s=r;const o=s.bodyJson.standard;return{gasPrice:a.gasPrice,maxFeePerGas:qx(o.maxFee,9),maxPriorityFeePerGas:qx(o.maxPriorityFee,9)}}catch(r){pe(!1,`error encountered with polygon gas station (${JSON.stringify(n.url)})`,"SERVER_ERROR",{request:n,response:s,error:r})}})}let jx=!1;function bD(){if(jx)return;jx=!0;function i(e,t,n){const s=function(){const r=new Yn(e,t);return n.ensNetwork!=null&&r.attachPlugin(new uh(null,n.ensNetwork)),r.attachPlugin(new hh),(n.plugins||[]).forEach(a=>{r.attachPlugin(a)}),r};Yn.register(e,s),Yn.register(t,s),n.altNames&&n.altNames.forEach(r=>{Yn.register(r,s)})}i("mainnet",1,{ensNetwork:1,altNames:["homestead"]}),i("ropsten",3,{ensNetwork:3}),i("rinkeby",4,{ensNetwork:4}),i("goerli",5,{ensNetwork:5}),i("kovan",42,{ensNetwork:42}),i("sepolia",11155111,{ensNetwork:11155111}),i("holesky",17e3,{ensNetwork:17e3}),i("classic",61,{}),i("classicKotti",6,{}),i("arbitrum",42161,{ensNetwork:1}),i("arbitrum-goerli",421613,{}),i("arbitrum-sepolia",421614,{}),i("base",8453,{ensNetwork:1}),i("base-goerli",84531,{}),i("base-sepolia",84532,{}),i("bnb",56,{ensNetwork:1}),i("bnbt",97,{}),i("filecoin",314,{}),i("filecoin-calibration",314159,{}),i("linea",59144,{ensNetwork:1}),i("linea-goerli",59140,{}),i("linea-sepolia",59141,{}),i("matic",137,{ensNetwork:1,plugins:[Kx("https://gasstation.polygon.technology/v2")]}),i("matic-amoy",80002,{}),i("matic-mumbai",80001,{altNames:["maticMumbai","maticmum"],plugins:[Kx("https://gasstation-testnet.polygon.technology/v2")]}),i("optimism",10,{ensNetwork:1,plugins:[]}),i("optimism-goerli",420,{}),i("optimism-sepolia",11155420,{}),i("xdai",100,{ensNetwork:1})}function Vf(i){return JSON.parse(JSON.stringify(i))}class xD{#e;#t;#n;#i;constructor(e){this.#e=e,this.#t=null,this.#n=4e3,this.#i=-2}get pollingInterval(){return this.#n}set pollingInterval(e){this.#n=e}async#s(){try{const e=await this.#e.getBlockNumber();if(this.#i===-2){this.#i=e;return}if(e!==this.#i){for(let t=this.#i+1;t<=e;t++){if(this.#t==null)return;await this.#e.emit("block",t)}this.#i=e}}catch{}this.#t!=null&&(this.#t=this.#e._setTimeout(this.#s.bind(this),this.#n))}start(){this.#t||(this.#t=this.#e._setTimeout(this.#s.bind(this),this.#n),this.#s())}stop(){this.#t&&(this.#e._clearTimeout(this.#t),this.#t=null)}pause(e){this.stop(),e&&(this.#i=-2)}resume(){this.start()}}class Wf{#e;#t;#n;constructor(e){this.#e=e,this.#n=!1,this.#t=t=>{this._poll(t,this.#e)}}async _poll(e,t){throw new Error("sub-classes must override this")}start(){this.#n||(this.#n=!0,this.#t(-2),this.#e.on("block",this.#t))}stop(){this.#n&&(this.#n=!1,this.#e.off("block",this.#t))}pause(e){this.stop()}resume(){this.start()}}class _D extends Wf{#e;#t;constructor(e,t){super(e),this.#e=t,this.#t=-2}pause(e){e&&(this.#t=-2),super.pause(e)}async _poll(e,t){const n=await t.getBlock(this.#e);n!=null&&(this.#t===-2?this.#t=n.number:n.number>this.#t&&(t.emit(this.#e,n.number),this.#t=n.number))}}class ED extends Wf{#e;constructor(e,t){super(e),this.#e=Vf(t)}async _poll(e,t){throw new Error("@TODO")}}class yD extends Wf{#e;constructor(e,t){super(e),this.#e=t}async _poll(e,t){const n=await t.getTransactionReceipt(this.#e);n&&t.emit(this.#e,n)}}class qf{#e;#t;#n;#i;#s;constructor(e,t){this.#e=e,this.#t=Vf(t),this.#n=this.#a.bind(this),this.#i=!1,this.#s=-2}async#a(e){if(this.#s===-2)return;const t=Vf(this.#t);t.fromBlock=this.#s+1,t.toBlock=e;const n=await this.#e.getLogs(t);if(n.length===0){this.#s<e-60&&(this.#s=e-60);return}for(const s of n)this.#e.emit(this.#t,s),this.#s=s.blockNumber}start(){this.#i||(this.#i=!0,this.#s===-2&&this.#e.getBlockNumber().then(e=>{this.#s=e}),this.#e.on("block",this.#n))}stop(){this.#i&&(this.#i=!1,this.#e.off("block",this.#n))}pause(e){this.stop(),e&&(this.#s=-2)}resume(){this.start()}}const wD=BigInt(2),vD=10;function dh(i){return i&&typeof i.then=="function"}function fh(i,e){return i+":"+JSON.stringify(e,(t,n)=>{if(n==null)return"null";if(typeof n=="bigint")return`bigint:${n.toString()}`;if(typeof n=="string")return n.toLowerCase();if(typeof n=="object"&&!Array.isArray(n)){const s=Object.keys(n);return s.sort(),s.reduce((r,a)=>(r[a]=n[a],r),{})}return n})}class Xx{name;constructor(e){Xe(this,{name:e})}start(){}stop(){}pause(e){}resume(){}}function CD(i){return JSON.parse(JSON.stringify(i))}function Kf(i){return i=Array.from(new Set(i).values()),i.sort(),i}async function jf(i,e){if(i==null)throw new Error("invalid event");if(Array.isArray(i)&&(i={topics:i}),typeof i=="string")switch(i){case"block":case"debug":case"error":case"finalized":case"network":case"pending":case"safe":return{type:i,tag:i}}if(Ft(i,32)){const t=i.toLowerCase();return{type:"transaction",tag:fh("tx",{hash:t}),hash:t}}if(i.orphan){const t=i;return{type:"orphan",tag:fh("orphan",t),filter:CD(t)}}if(i.address||i.topics){const t=i,n={topics:(t.topics||[]).map(s=>s==null?null:Array.isArray(s)?Kf(s.map(r=>r.toLowerCase())):s.toLowerCase())};if(t.address){const s=[],r=[],a=o=>{Ft(o)?s.push(o):r.push((async()=>{s.push(await Pn(o,e))})())};Array.isArray(t.address)?t.address.forEach(a):a(t.address),r.length&&await Promise.all(r),n.address=Kf(s.map(o=>o.toLowerCase()))}return{filter:n,tag:fh("event",n),type:"event"}}V(!1,"unknown ProviderEvent","event",i)}function Xf(){return new Date().getTime()}const SD={cacheTimeout:250,pollingInterval:4e3};class ID{#e;#t;#n;#i;#s;#a;#r;#o;#f;#l;#p;#A;constructor(e,t){if(this.#A=Object.assign({},SD,t||{}),e==="any")this.#a=!0,this.#s=null;else if(e){const n=Yn.from(e);this.#a=!1,this.#s=Promise.resolve(n),setTimeout(()=>{this.emit("network",n,null)},0)}else this.#a=!1,this.#s=null;this.#o=-1,this.#r=new Map,this.#e=new Map,this.#t=new Map,this.#n=null,this.#i=!1,this.#f=1,this.#l=new Map,this.#p=!1}get pollingInterval(){return this.#A.pollingInterval}get provider(){return this}get plugins(){return Array.from(this.#t.values())}attachPlugin(e){if(this.#t.get(e.name))throw new Error(`cannot replace existing plugin: ${e.name} `);return this.#t.set(e.name,e.connect(this)),this}getPlugin(e){return this.#t.get(e)||null}get disableCcipRead(){return this.#p}set disableCcipRead(e){this.#p=!!e}async#c(e){const t=this.#A.cacheTimeout;if(t<0)return await this._perform(e);const n=fh(e.method,e);let s=this.#r.get(n);return s||(s=this._perform(e),this.#r.set(n,s),setTimeout(()=>{this.#r.get(n)===s&&this.#r.delete(n)},t)),await s}async ccipReadFetch(e,t,n){if(this.disableCcipRead||n.length===0||e.to==null)return null;const s=e.to.toLowerCase(),r=t.toLowerCase(),a=[];for(let o=0;o<n.length;o++){const c=n[o],l=c.replace("{sender}",s).replace("{data}",r),h=new ki(l);c.indexOf("{data}")===-1&&(h.body={data:r,sender:s}),this.emit("debug",{action:"sendCcipReadFetchRequest",request:h,index:o,urls:n});let u="unknown error",d;try{d=await h.send()}catch(f){a.push(f.message),this.emit("debug",{action:"receiveCcipReadFetchError",request:h,result:{error:f}});continue}try{const f=d.bodyJson;if(f.data)return this.emit("debug",{action:"receiveCcipReadFetchResult",request:h,result:f}),f.data;f.message&&(u=f.message),this.emit("debug",{action:"receiveCcipReadFetchError",request:h,result:f})}catch{}pe(d.statusCode<400||d.statusCode>=500,`response not found during CCIP fetch: ${u}`,"OFFCHAIN_FAULT",{reason:"404_MISSING_RESOURCE",transaction:e,info:{url:c,errorMessage:u}}),a.push(u)}pe(!1,`error encountered during CCIP fetch: ${a.map(o=>JSON.stringify(o)).join(", ")}`,"OFFCHAIN_FAULT",{reason:"500_SERVER_ERROR",transaction:e,info:{urls:n,errorMessages:a}})}_wrapBlock(e,t){return new qF(uD(e),this)}_wrapLog(e,t){return new Zo(lD(e),this)}_wrapTransactionReceipt(e,t){return new Bx(AD(e),this)}_wrapTransactionResponse(e,t){return new $o(Wx(e),this)}_detectNetwork(){pe(!1,"sub-classes must implement this","UNSUPPORTED_OPERATION",{operation:"_detectNetwork"})}async _perform(e){pe(!1,`unsupported method: ${e.method}`,"UNSUPPORTED_OPERATION",{operation:e.method,info:e})}async getBlockNumber(){const e=ht(await this.#c({method:"getBlockNumber"}),"%response");return this.#o>=0&&(this.#o=e),e}_getAddress(e){return Pn(e,this)}_getBlockTag(e){if(e==null)return"latest";switch(e){case"earliest":return"0x0";case"finalized":case"latest":case"pending":case"safe":return e}if(Ft(e))return Ft(e,32)?e:vi(e);if(typeof e=="bigint"&&(e=ht(e,"blockTag")),typeof e=="number")return e>=0?vi(e):this.#o>=0?vi(this.#o+e):this.getBlockNumber().then(t=>vi(t+e));V(!1,"invalid blockTag","blockTag",e)}_getFilter(e){const t=(e.topics||[]).map(c=>c==null?null:Array.isArray(c)?Kf(c.map(l=>l.toLowerCase())):c.toLowerCase()),n="blockHash"in e?e.blockHash:void 0,s=(c,l,h)=>{let u;switch(c.length){case 0:break;case 1:u=c[0];break;default:c.sort(),u=c}if(n&&(l!=null||h!=null))throw new Error("invalid filter");const d={};return u&&(d.address=u),t.length&&(d.topics=t),l&&(d.fromBlock=l),h&&(d.toBlock=h),n&&(d.blockHash=n),d};let r=[];if(e.address)if(Array.isArray(e.address))for(const c of e.address)r.push(this._getAddress(c));else r.push(this._getAddress(e.address));let a;"fromBlock"in e&&(a=this._getBlockTag(e.fromBlock));let o;return"toBlock"in e&&(o=this._getBlockTag(e.toBlock)),r.filter(c=>typeof c!="string").length||a!=null&&typeof a!="string"||o!=null&&typeof o!="string"?Promise.all([Promise.all(r),a,o]).then(c=>s(c[0],c[1],c[2])):s(r,a,o)}_getTransactionRequest(e){const t=ah(e),n=[];if(["to","from"].forEach(s=>{if(t[s]==null)return;const r=Pn(t[s],this);dh(r)?n.push((async function(){t[s]=await r})()):t[s]=r}),t.blockTag!=null){const s=this._getBlockTag(t.blockTag);dh(s)?n.push((async function(){t.blockTag=await s})()):t.blockTag=s}return n.length?(async function(){return await Promise.all(n),t})():t}async getNetwork(){if(this.#s==null){const s=(async()=>{try{const r=await this._detectNetwork();return this.emit("network",r,null),r}catch(r){throw this.#s===s&&(this.#s=null),r}})();return this.#s=s,(await s).clone()}const e=this.#s,[t,n]=await Promise.all([e,this._detectNetwork()]);return t.chainId!==n.chainId&&(this.#a?(this.emit("network",n,t),this.#s===e&&(this.#s=Promise.resolve(n))):pe(!1,`network changed: ${t.chainId} => ${n.chainId} `,"NETWORK_ERROR",{event:"changed"})),t.clone()}async getFeeData(){const e=await this.getNetwork(),t=async()=>{const{_block:s,gasPrice:r,priorityFee:a}=await Fn({_block:this.#b("latest",!1),gasPrice:(async()=>{try{const h=await this.#c({method:"getGasPrice"});return Re(h,"%response")}catch{}return null})(),priorityFee:(async()=>{try{const h=await this.#c({method:"getPriorityFee"});return Re(h,"%response")}catch{}return null})()});let o=null,c=null;const l=this._wrapBlock(s,e);return l&&l.baseFeePerGas&&(c=a??BigInt("1000000000"),o=l.baseFeePerGas*wD+c),new Mx(r,o,c)},n=e.getPlugin("org.ethers.plugins.network.FetchUrlFeeDataPlugin");if(n){const s=new ki(n.url),r=await n.processFunc(t,this,s);return new Mx(r.gasPrice,r.maxFeePerGas,r.maxPriorityFeePerGas)}return await t()}async estimateGas(e){let t=this._getTransactionRequest(e);return dh(t)&&(t=await t),Re(await this.#c({method:"estimateGas",transaction:t}),"%response")}async#h(e,t,n){pe(n<vD,"CCIP read exceeded maximum redirections","OFFCHAIN_FAULT",{reason:"TOO_MANY_REDIRECTS",transaction:Object.assign({},e,{blockTag:t,enableCcipRead:!0})});const s=ah(e);try{return Ce(await this._perform({method:"call",transaction:s,blockTag:t}))}catch(r){if(!this.disableCcipRead&&qd(r)&&r.data&&n>=0&&t==="latest"&&s.to!=null&&Vt(r.data,0,4)==="0x556f1830"){const a=r.data,o=await Pn(s.to,this);let c;try{c=ND(Vt(r.data,4))}catch(u){pe(!1,u.message,"OFFCHAIN_FAULT",{reason:"BAD_DATA",transaction:s,info:{data:a}})}pe(c.sender.toLowerCase()===o.toLowerCase(),"CCIP Read sender mismatch","CALL_EXCEPTION",{action:"call",data:a,reason:"OffchainLookup",transaction:s,invocation:null,revert:{signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",name:"OffchainLookup",args:c.errorArgs}});const l=await this.ccipReadFetch(s,c.calldata,c.urls);pe(l!=null,"CCIP Read failed to fetch data","OFFCHAIN_FAULT",{reason:"FETCH_FAILED",transaction:s,info:{data:r.data,errorArgs:c.errorArgs}});const h={to:o,data:Ot([c.selector,RD([l,c.extraData])])};this.emit("debug",{action:"sendCcipReadCall",transaction:h});try{const u=await this.#h(h,t,n+1);return this.emit("debug",{action:"receiveCcipReadCallResult",transaction:Object.assign({},h),result:u}),u}catch(u){throw this.emit("debug",{action:"receiveCcipReadCallError",transaction:Object.assign({},h),error:u}),u}}throw r}}async#u(e){const{value:t}=await Fn({network:this.getNetwork(),value:e});return t}async call(e){const{tx:t,blockTag:n}=await Fn({tx:this._getTransactionRequest(e),blockTag:this._getBlockTag(e.blockTag)});return await this.#u(this.#h(t,n,e.enableCcipRead?0:-1))}async#d(e,t,n){let s=this._getAddress(t),r=this._getBlockTag(n);return(typeof s!="string"||typeof r!="string")&&([s,r]=await Promise.all([s,r])),await this.#u(this.#c(Object.assign(e,{address:s,blockTag:r})))}async getBalance(e,t){return Re(await this.#d({method:"getBalance"},e,t),"%response")}async getTransactionCount(e,t){return ht(await this.#d({method:"getTransactionCount"},e,t),"%response")}async getCode(e,t){return Ce(await this.#d({method:"getCode"},e,t))}async getStorage(e,t,n){const s=Re(t,"position");return Ce(await this.#d({method:"getStorage",position:s},e,n))}async broadcastTransaction(e){const{blockNumber:t,hash:n,network:s}=await Fn({blockNumber:this.getBlockNumber(),hash:this._perform({method:"broadcastTransaction",signedTransaction:e}),network:this.getNetwork()}),r=Si.from(e);if(r.hash!==n)throw new Error("@TODO: the returned hash did not match");return this._wrapTransactionResponse(r,s).replaceableTransaction(t)}async#b(e,t){if(Ft(e,32))return await this.#c({method:"getBlock",blockHash:e,includeTransactions:t});let n=this._getBlockTag(e);return typeof n!="string"&&(n=await n),await this.#c({method:"getBlock",blockTag:n,includeTransactions:t})}async getBlock(e,t){const{network:n,params:s}=await Fn({network:this.getNetwork(),params:this.#b(e,!!t)});return s==null?null:this._wrapBlock(s,n)}async getTransaction(e){const{network:t,params:n}=await Fn({network:this.getNetwork(),params:this.#c({method:"getTransaction",hash:e})});return n==null?null:this._wrapTransactionResponse(n,t)}async getTransactionReceipt(e){const{network:t,params:n}=await Fn({network:this.getNetwork(),params:this.#c({method:"getTransactionReceipt",hash:e})});if(n==null)return null;if(n.gasPrice==null&&n.effectiveGasPrice==null){const s=await this.#c({method:"getTransaction",hash:e});if(s==null)throw new Error("report this; could not find tx or effectiveGasPrice");n.effectiveGasPrice=s.gasPrice}return this._wrapTransactionReceipt(n,t)}async getTransactionResult(e){const{result:t}=await Fn({network:this.getNetwork(),result:this.#c({method:"getTransactionResult",hash:e})});return t==null?null:Ce(t)}async getLogs(e){let t=this._getFilter(e);dh(t)&&(t=await t);const{network:n,params:s}=await Fn({network:this.getNetwork(),params:this.#c({method:"getLogs",filter:t})});return s.map(r=>this._wrapLog(r,n))}_getProvider(e){pe(!1,"provider cannot connect to target network","UNSUPPORTED_OPERATION",{operation:"_getProvider()"})}async getResolver(e){return await Ga.fromName(this,e)}async getAvatar(e){const t=await this.getResolver(e);return t?await t.getAvatar():null}async resolveName(e){const t=await this.getResolver(e);return t?await t.getAddress():null}async lookupAddress(e){e=Ct(e);const t=Ff(e.substring(2).toLowerCase()+".addr.reverse");try{const n=await Ga.getEnsAddress(this),r=await new Tr(n,["function resolver(bytes32) view returns (address)"],this).resolver(t);if(r==null||r===Vo)return null;const o=await new Tr(r,["function name(bytes32) view returns (string)"],this).name(t);return await this.resolveName(o)!==e?null:o}catch(n){if(En(n,"BAD_DATA")&&n.value==="0x"||En(n,"CALL_EXCEPTION"))return null;throw n}return null}async waitForTransaction(e,t,n){const s=t??1;return s===0?this.getTransactionReceipt(e):new Promise(async(r,a)=>{let o=null;const c=(async l=>{try{const h=await this.getTransactionReceipt(e);if(h!=null&&l-h.blockNumber+1>=s){r(h),o&&(clearTimeout(o),o=null);return}}catch(h){console.log("EEE",h)}this.once("block",c)});n!=null&&(o=setTimeout(()=>{o!=null&&(o=null,this.off("block",c),a(Ut("timeout","TIMEOUT",{reason:"timeout"})))},n)),c(await this.getBlockNumber())})}async waitForBlock(e){pe(!1,"not implemented yet","NOT_IMPLEMENTED",{operation:"waitForBlock"})}_clearTimeout(e){const t=this.#l.get(e);t&&(t.timer&&clearTimeout(t.timer),this.#l.delete(e))}_setTimeout(e,t){t==null&&(t=0);const n=this.#f++,s=()=>{this.#l.delete(n),e()};if(this.paused)this.#l.set(n,{timer:null,func:s,time:t});else{const r=setTimeout(s,t);this.#l.set(n,{timer:r,func:s,time:Xf()})}return n}_forEachSubscriber(e){for(const t of this.#e.values())e(t.subscriber)}_getSubscriber(e){switch(e.type){case"debug":case"error":case"network":return new Xx(e.type);case"block":{const t=new xD(this);return t.pollingInterval=this.pollingInterval,t}case"safe":case"finalized":return new _D(this,e.type);case"event":return new qf(this,e.filter);case"transaction":return new yD(this,e.hash);case"orphan":return new ED(this,e.filter)}throw new Error(`unsupported event: ${e.type}`)}_recoverSubscriber(e,t){for(const n of this.#e.values())if(n.subscriber===e){n.started&&n.subscriber.stop(),n.subscriber=t,n.started&&t.start(),this.#n!=null&&t.pause(this.#n);break}}async#g(e,t){let n=await jf(e,this);return n.type==="event"&&t&&t.length>0&&t[0].removed===!0&&(n=await jf({orphan:"drop-log",log:t[0]},this)),this.#e.get(n.tag)||null}async#m(e){const t=await jf(e,this),n=t.tag;let s=this.#e.get(n);return s||(s={subscriber:this._getSubscriber(t),tag:n,addressableMap:new WeakMap,nameMap:new Map,started:!1,listeners:[]},this.#e.set(n,s)),s}async on(e,t){const n=await this.#m(e);return n.listeners.push({listener:t,once:!1}),n.started||(n.subscriber.start(),n.started=!0,this.#n!=null&&n.subscriber.pause(this.#n)),this}async once(e,t){const n=await this.#m(e);return n.listeners.push({listener:t,once:!0}),n.started||(n.subscriber.start(),n.started=!0,this.#n!=null&&n.subscriber.pause(this.#n)),this}async emit(e,...t){const n=await this.#g(e,t);if(!n||n.listeners.length===0)return!1;const s=n.listeners.length;return n.listeners=n.listeners.filter(({listener:r,once:a})=>{const o=new f0(this,a?null:r,e);try{r.call(this,...t,o)}catch{}return!a}),n.listeners.length===0&&(n.started&&n.subscriber.stop(),this.#e.delete(n.tag)),s>0}async listenerCount(e){if(e){const n=await this.#g(e);return n?n.listeners.length:0}let t=0;for(const{listeners:n}of this.#e.values())t+=n.length;return t}async listeners(e){if(e){const n=await this.#g(e);return n?n.listeners.map(({listener:s})=>s):[]}let t=[];for(const{listeners:n}of this.#e.values())t=t.concat(n.map(({listener:s})=>s));return t}async off(e,t){const n=await this.#g(e);if(!n)return this;if(t){const s=n.listeners.map(({listener:r})=>r).indexOf(t);s>=0&&n.listeners.splice(s,1)}return(!t||n.listeners.length===0)&&(n.started&&n.subscriber.stop(),this.#e.delete(n.tag)),this}async removeAllListeners(e){if(e){const{tag:t,started:n,subscriber:s}=await this.#m(e);n&&s.stop(),this.#e.delete(t)}else for(const[t,{started:n,subscriber:s}]of this.#e)n&&s.stop(),this.#e.delete(t);return this}async addListener(e,t){return await this.on(e,t)}async removeListener(e,t){return this.off(e,t)}get destroyed(){return this.#i}destroy(){this.removeAllListeners();for(const e of this.#l.keys())this._clearTimeout(e);this.#i=!0}get paused(){return this.#n!=null}set paused(e){!!e!==this.paused&&(this.paused?this.resume():this.pause(!1))}pause(e){if(this.#o=-1,this.#n!=null){if(this.#n==!!e)return;pe(!1,"cannot change pause type; resume first","UNSUPPORTED_OPERATION",{operation:"pause"})}this._forEachSubscriber(t=>t.pause(e)),this.#n=!!e;for(const t of this.#l.values())t.timer&&clearTimeout(t.timer),t.time=Xf()-t.time}resume(){if(this.#n!=null){this._forEachSubscriber(e=>e.resume()),this.#n=null;for(const e of this.#l.values()){let t=e.time;t<0&&(t=0),e.time=Xf(),setTimeout(e.func,t)}}}}function MD(i,e){try{const t=Yf(i,e);if(t)return Pl(t)}catch{}return null}function Yf(i,e){if(i==="0x")return null;try{const t=ht(Vt(i,e,e+32)),n=ht(Vt(i,t,t+32));return Vt(i,t+32,t+32+n)}catch{}return null}function Yx(i){const e=Zt(i);if(e.length>32)throw new Error("internal; should not happen");const t=new Uint8Array(32);return t.set(e,32-e.length),t}function BD(i){if(i.length%32===0)return i;const e=new Uint8Array(Math.ceil(i.length/32)*32);return e.set(i),e}const TD=new Uint8Array([]);function RD(i){const e=[];let t=0;for(let n=0;n<i.length;n++)e.push(TD),t+=32;for(let n=0;n<i.length;n++){const s=lt(i[n]);e[n]=Yx(t),e.push(Yx(s.length)),e.push(BD(s)),t+=32+Math.ceil(s.length/32)*32}return Ot(e)}const Jx="0x0000000000000000000000000000000000000000000000000000000000000000";function ND(i){const e={sender:"",urls:[],calldata:"",selector:"",extraData:"",errorArgs:[]};pe(Ma(i)>=160,"insufficient OffchainLookup data","OFFCHAIN_FAULT",{reason:"insufficient OffchainLookup data"});const t=Vt(i,0,32);pe(Vt(t,0,12)===Vt(Jx,0,12),"corrupt OffchainLookup sender","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup sender"}),e.sender=Vt(t,12);try{const n=[],s=ht(Vt(i,32,64)),r=ht(Vt(i,s,s+32)),a=Vt(i,s+32);for(let o=0;o<r;o++){const c=MD(a,o*32);if(c==null)throw new Error("abort");n.push(c)}e.urls=n}catch{pe(!1,"corrupt OffchainLookup urls","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup urls"})}try{const n=Yf(i,64);if(n==null)throw new Error("abort");e.calldata=n}catch{pe(!1,"corrupt OffchainLookup calldata","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup calldata"})}pe(Vt(i,100,128)===Vt(Jx,0,28),"corrupt OffchainLookup callbaackSelector","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup callbaackSelector"}),e.selector=Vt(i,96,100);try{const n=Yf(i,128);if(n==null)throw new Error("abort");e.extraData=n}catch{pe(!1,"corrupt OffchainLookup extraData","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup extraData"})}return e.errorArgs="sender,urls,calldata,selector,extraData".split(/,/).map(n=>e[n]),e}function Rr(i,e){if(i.provider)return i.provider;pe(!1,"missing provider","UNSUPPORTED_OPERATION",{operation:e})}async function Zx(i,e){let t=ah(e);if(t.to!=null&&(t.to=Pn(t.to,i)),t.from!=null){const n=t.from;t.from=Promise.all([i.getAddress(),Pn(n,i)]).then(([s,r])=>(V(s.toLowerCase()===r.toLowerCase(),"transaction from mismatch","tx.from",r),s))}else t.from=i.getAddress();return await Fn(t)}class FD{provider;constructor(e){Xe(this,{provider:e||null})}async getNonce(e){return Rr(this,"getTransactionCount").getTransactionCount(await this.getAddress(),e)}async populateCall(e){return await Zx(this,e)}async populateTransaction(e){const t=Rr(this,"populateTransaction"),n=await Zx(this,e);n.nonce==null&&(n.nonce=await this.getNonce("pending")),n.gasLimit==null&&(n.gasLimit=await this.estimateGas(n));const s=await this.provider.getNetwork();if(n.chainId!=null){const a=Re(n.chainId);V(a===s.chainId,"transaction chainId mismatch","tx.chainId",e.chainId)}else n.chainId=s.chainId;const r=n.maxFeePerGas!=null||n.maxPriorityFeePerGas!=null;if(n.gasPrice!=null&&(n.type===2||r)?V(!1,"eip-1559 transaction do not support gasPrice","tx",e):(n.type===0||n.type===1)&&r&&V(!1,"pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas","tx",e),(n.type===2||n.type==null)&&n.maxFeePerGas!=null&&n.maxPriorityFeePerGas!=null)n.type=2;else if(n.type===0||n.type===1){const a=await t.getFeeData();pe(a.gasPrice!=null,"network does not support gasPrice","UNSUPPORTED_OPERATION",{operation:"getGasPrice"}),n.gasPrice==null&&(n.gasPrice=a.gasPrice)}else{const a=await t.getFeeData();if(n.type==null)if(a.maxFeePerGas!=null&&a.maxPriorityFeePerGas!=null)if(n.authorizationList&&n.authorizationList.length?n.type=4:n.type=2,n.gasPrice!=null){const o=n.gasPrice;delete n.gasPrice,n.maxFeePerGas=o,n.maxPriorityFeePerGas=o}else n.maxFeePerGas==null&&(n.maxFeePerGas=a.maxFeePerGas),n.maxPriorityFeePerGas==null&&(n.maxPriorityFeePerGas=a.maxPriorityFeePerGas);else a.gasPrice!=null?(pe(!r,"network does not support EIP-1559","UNSUPPORTED_OPERATION",{operation:"populateTransaction"}),n.gasPrice==null&&(n.gasPrice=a.gasPrice),n.type=0):pe(!1,"failed to get consistent fee data","UNSUPPORTED_OPERATION",{operation:"signer.getFeeData"});else(n.type===2||n.type===3||n.type===4)&&(n.maxFeePerGas==null&&(n.maxFeePerGas=a.maxFeePerGas),n.maxPriorityFeePerGas==null&&(n.maxPriorityFeePerGas=a.maxPriorityFeePerGas))}return await Fn(n)}async populateAuthorization(e){const t=Object.assign({},e);return t.chainId==null&&(t.chainId=(await Rr(this,"getNetwork").getNetwork()).chainId),t.nonce==null&&(t.nonce=await this.getNonce()),t}async estimateGas(e){return Rr(this,"estimateGas").estimateGas(await this.populateCall(e))}async call(e){return Rr(this,"call").call(await this.populateCall(e))}async resolveName(e){return await Rr(this,"resolveName").resolveName(e)}async sendTransaction(e){const t=Rr(this,"sendTransaction"),n=await this.populateTransaction(e);delete n.from;const s=Si.from(n);return await t.broadcastTransaction(await this.signTransaction(s))}authorize(e){pe(!1,"authorization not implemented for this signer","UNSUPPORTED_OPERATION",{operation:"authorize"})}}function DD(i){return JSON.parse(JSON.stringify(i))}class $x{#e;#t;#n;#i;#s;#a;constructor(e){this.#e=e,this.#t=null,this.#n=this.#r.bind(this),this.#i=!1,this.#s=null,this.#a=!1}_subscribe(e){throw new Error("subclasses must override this")}_emitResults(e,t){throw new Error("subclasses must override this")}_recover(e){throw new Error("subclasses must override this")}async#r(e){try{this.#t==null&&(this.#t=this._subscribe(this.#e));let t=null;try{t=await this.#t}catch(r){if(!En(r,"UNSUPPORTED_OPERATION")||r.operation!=="eth_newFilter")throw r}if(t==null){this.#t=null,this.#e._recoverSubscriber(this,this._recover(this.#e));return}const n=await this.#e.getNetwork();if(this.#s||(this.#s=n),this.#s.chainId!==n.chainId)throw new Error("chaid changed");if(this.#a)return;const s=await this.#e.send("eth_getFilterChanges",[t]);await this._emitResults(this.#e,s)}catch(t){console.log("@TODO",t)}this.#e.once("block",this.#n)}#o(){const e=this.#t;e&&(this.#t=null,e.then(t=>{this.#e.destroyed||this.#e.send("eth_uninstallFilter",[t])}))}start(){this.#i||(this.#i=!0,this.#r(-2))}stop(){this.#i&&(this.#i=!1,this.#a=!0,this.#o(),this.#e.off("block",this.#n))}pause(e){e&&this.#o(),this.#e.off("block",this.#n)}resume(){this.start()}}class LD extends $x{#e;constructor(e,t){super(e),this.#e=DD(t)}_recover(e){return new qf(e,this.#e)}async _subscribe(e){return await e.send("eth_newFilter",[this.#e])}async _emitResults(e,t){for(const n of t)e.emit(this.#e,e._wrapLog(n,e._network))}}class PD extends $x{async _subscribe(e){return await e.send("eth_newPendingTransactionFilter",[])}async _emitResults(e,t){for(const n of t)e.emit("pending",n)}}const kD="bigint,boolean,function,number,string,symbol".split(/,/g);function ph(i){if(i==null||kD.indexOf(typeof i)>=0||typeof i.getAddress=="function")return i;if(Array.isArray(i))return i.map(ph);if(typeof i=="object")return Object.keys(i).reduce((e,t)=>(e[t]=i[t],e),{});throw new Error(`should not happen: ${i} (${typeof i})`)}function UD(i){return new Promise(e=>{setTimeout(e,i)})}function za(i){return i&&i.toLowerCase()}function e_(i){return i&&typeof i.pollingInterval=="number"}const t_={polling:!1,staticNetwork:null,batchStallTime:10,batchMaxSize:1<<20,batchMaxCount:100,cacheTimeout:250,pollingInterval:4e3};class Jf extends FD{address;constructor(e,t){super(e),t=Ct(t),Xe(this,{address:t})}connect(e){pe(!1,"cannot reconnect JsonRpcSigner","UNSUPPORTED_OPERATION",{operation:"signer.connect"})}async getAddress(){return this.address}async populateTransaction(e){return await this.populateCall(e)}async sendUncheckedTransaction(e){const t=ph(e),n=[];if(t.from){const r=t.from;n.push((async()=>{const a=await Pn(r,this.provider);V(a!=null&&a.toLowerCase()===this.address.toLowerCase(),"from address mismatch","transaction",e),t.from=a})())}else t.from=this.address;if(t.gasLimit==null&&n.push((async()=>{t.gasLimit=await this.provider.estimateGas({...t,from:this.address})})()),t.to!=null){const r=t.to;n.push((async()=>{t.to=await Pn(r,this.provider)})())}n.length&&await Promise.all(n);const s=this.provider.getRpcTransaction(t);return this.provider.send("eth_sendTransaction",[s])}async sendTransaction(e){const t=await this.provider.getBlockNumber(),n=await this.sendUncheckedTransaction(e);return await new Promise((s,r)=>{const a=[1e3,100];let o=0;const c=async()=>{try{const l=await this.provider.getTransaction(n);if(l!=null){s(l.replaceableTransaction(t));return}}catch(l){if(En(l,"CANCELLED")||En(l,"BAD_DATA")||En(l,"NETWORK_ERROR")||En(l,"UNSUPPORTED_OPERATION")){l.info==null&&(l.info={}),l.info.sendTransactionHash=n,r(l);return}if(En(l,"INVALID_ARGUMENT")&&(o++,l.info==null&&(l.info={}),l.info.sendTransactionHash=n,o>10)){r(l);return}this.provider.emit("error",Ut("failed to fetch transation after sending (will try again)","UNKNOWN_ERROR",{error:l}))}this.provider._setTimeout(()=>{c()},a.pop()||4e3)};c()})}async signTransaction(e){const t=ph(e);if(t.from){const s=await Pn(t.from,this.provider);V(s!=null&&s.toLowerCase()===this.address.toLowerCase(),"from address mismatch","transaction",e),t.from=s}else t.from=this.address;const n=this.provider.getRpcTransaction(t);return await this.provider.send("eth_signTransaction",[n])}async signMessage(e){const t=typeof e=="string"?ss(e):e;return await this.provider.send("personal_sign",[Ce(t),this.address.toLowerCase()])}async signTypedData(e,t,n){const s=ph(n),r=await jn.resolveNames(e,t,s,async a=>{const o=await Pn(a);return V(o!=null,"TypedData does not support null address","value",a),o});return await this.provider.send("eth_signTypedData_v4",[this.address.toLowerCase(),JSON.stringify(jn.getPayload(r.domain,t,r.value))])}async unlock(e){return this.provider.send("personal_unlockAccount",[this.address.toLowerCase(),e,null])}async _legacySignMessage(e){const t=typeof e=="string"?ss(e):e;return await this.provider.send("eth_sign",[this.address.toLowerCase(),Ce(t)])}}class OD extends ID{#e;#t;#n;#i;#s;#a;#r;#o(){if(this.#i)return;const e=this._getOption("batchMaxCount")===1?0:this._getOption("batchStallTime");this.#i=setTimeout(()=>{this.#i=null;const t=this.#n;for(this.#n=[];t.length;){const n=[t.shift()];for(;t.length&&n.length!==this.#e.batchMaxCount;)if(n.push(t.shift()),JSON.stringify(n.map(r=>r.payload)).length>this.#e.batchMaxSize){t.unshift(n.pop());break}(async()=>{const s=n.length===1?n[0].payload:n.map(r=>r.payload);this.emit("debug",{action:"sendRpcPayload",payload:s});try{const r=await this._send(s);this.emit("debug",{action:"receiveRpcResult",result:r});for(const{resolve:a,reject:o,payload:c}of n){if(this.destroyed){o(Ut("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:c.method}));continue}const l=r.filter(h=>h.id===c.id)[0];if(l==null){const h=Ut("missing response for request","BAD_DATA",{value:r,info:{payload:c}});this.emit("error",h),o(h);continue}if("error"in l){o(this.getRpcError(c,l));continue}a(l.result)}}catch(r){this.emit("debug",{action:"receiveRpcError",error:r});for(const{reject:a}of n)a(r)}})()}},e)}constructor(e,t){super(e,t),this.#t=1,this.#e=Object.assign({},t_,t||{}),this.#n=[],this.#i=null,this.#a=null,this.#r=null;{let s=null;const r=new Promise(a=>{s=a});this.#s={promise:r,resolve:s}}const n=this._getOption("staticNetwork");typeof n=="boolean"?(V(!n||e!=="any","staticNetwork cannot be used on special network 'any'","options",t),n&&e!=null&&(this.#a=Yn.from(e))):n&&(V(e==null||n.matches(e),"staticNetwork MUST match network object","options",t),this.#a=n)}_getOption(e){return this.#e[e]}get _network(){return pe(this.#a,"network is not available yet","NETWORK_ERROR"),this.#a}async _perform(e){if(e.method==="call"||e.method==="estimateGas"){let n=e.transaction;if(n&&n.type!=null&&Re(n.type)&&n.maxFeePerGas==null&&n.maxPriorityFeePerGas==null){const s=await this.getFeeData();s.maxFeePerGas==null&&s.maxPriorityFeePerGas==null&&(e=Object.assign({},e,{transaction:Object.assign({},n,{type:void 0})}))}}const t=this.getRpcRequest(e);return t!=null?await this.send(t.method,t.args):super._perform(e)}async _detectNetwork(){const e=this._getOption("staticNetwork");if(e)if(e===!0){if(this.#a)return this.#a}else return e;return this.#r?await this.#r:this.ready?(this.#r=(async()=>{try{const t=Yn.from(Re(await this.send("eth_chainId",[])));return this.#r=null,t}catch(t){throw this.#r=null,t}})(),await this.#r):(this.#r=(async()=>{const t={id:this.#t++,method:"eth_chainId",params:[],jsonrpc:"2.0"};this.emit("debug",{action:"sendRpcPayload",payload:t});let n;try{n=(await this._send(t))[0],this.#r=null}catch(s){throw this.#r=null,this.emit("debug",{action:"receiveRpcError",error:s}),s}if(this.emit("debug",{action:"receiveRpcResult",result:n}),"result"in n)return Yn.from(Re(n.result));throw this.getRpcError(t,n)})(),await this.#r)}_start(){this.#s==null||this.#s.resolve==null||(this.#s.resolve(),this.#s=null,(async()=>{for(;this.#a==null&&!this.destroyed;)try{this.#a=await this._detectNetwork()}catch(e){if(this.destroyed)break;console.log("JsonRpcProvider failed to detect network and cannot start up; retry in 1s (perhaps the URL is wrong or the node is not started)"),this.emit("error",Ut("failed to bootstrap network detection","NETWORK_ERROR",{event:"initial-network-discovery",info:{error:e}})),await UD(1e3)}this.#o()})())}async _waitUntilReady(){if(this.#s!=null)return await this.#s.promise}_getSubscriber(e){return e.type==="pending"?new PD(this):e.type==="event"?this._getOption("polling")?new qf(this,e.filter):new LD(this,e.filter):e.type==="orphan"&&e.filter.orphan==="drop-log"?new Xx("orphan"):super._getSubscriber(e)}get ready(){return this.#s==null}getRpcTransaction(e){const t={};return["chainId","gasLimit","gasPrice","type","maxFeePerGas","maxPriorityFeePerGas","nonce","value"].forEach(n=>{if(e[n]==null)return;let s=n;n==="gasLimit"&&(s="gas"),t[s]=vi(Re(e[n],`tx.${n}`))}),["from","to","data"].forEach(n=>{e[n]!=null&&(t[n]=Ce(e[n]))}),e.accessList&&(t.accessList=xr(e.accessList)),e.blobVersionedHashes&&(t.blobVersionedHashes=e.blobVersionedHashes.map(n=>n.toLowerCase())),e.authorizationList&&(t.authorizationList=e.authorizationList.map(n=>{const s=Cb(n);return{address:s.address,nonce:vi(s.nonce),chainId:vi(s.chainId),yParity:vi(s.signature.yParity),r:vi(s.signature.r),s:vi(s.signature.s)}})),t}getRpcRequest(e){switch(e.method){case"chainId":return{method:"eth_chainId",args:[]};case"getBlockNumber":return{method:"eth_blockNumber",args:[]};case"getGasPrice":return{method:"eth_gasPrice",args:[]};case"getPriorityFee":return{method:"eth_maxPriorityFeePerGas",args:[]};case"getBalance":return{method:"eth_getBalance",args:[za(e.address),e.blockTag]};case"getTransactionCount":return{method:"eth_getTransactionCount",args:[za(e.address),e.blockTag]};case"getCode":return{method:"eth_getCode",args:[za(e.address),e.blockTag]};case"getStorage":return{method:"eth_getStorageAt",args:[za(e.address),"0x"+e.position.toString(16),e.blockTag]};case"broadcastTransaction":return{method:"eth_sendRawTransaction",args:[e.signedTransaction]};case"getBlock":if("blockTag"in e)return{method:"eth_getBlockByNumber",args:[e.blockTag,!!e.includeTransactions]};if("blockHash"in e)return{method:"eth_getBlockByHash",args:[e.blockHash,!!e.includeTransactions]};break;case"getTransaction":return{method:"eth_getTransactionByHash",args:[e.hash]};case"getTransactionReceipt":return{method:"eth_getTransactionReceipt",args:[e.hash]};case"call":return{method:"eth_call",args:[this.getRpcTransaction(e.transaction),e.blockTag]};case"estimateGas":return{method:"eth_estimateGas",args:[this.getRpcTransaction(e.transaction)]};case"getLogs":return e.filter&&e.filter.address!=null&&(Array.isArray(e.filter.address)?e.filter.address=e.filter.address.map(za):e.filter.address=za(e.filter.address)),{method:"eth_getLogs",args:[e.filter]}}return null}getRpcError(e,t){const{method:n}=e,{error:s}=t;if(n==="eth_estimateGas"&&s.message){const o=s.message;if(!o.match(/revert/i)&&o.match(/insufficient funds/i))return Ut("insufficient funds","INSUFFICIENT_FUNDS",{transaction:e.params[0],info:{payload:e,error:s}});if(o.match(/nonce/i)&&o.match(/too low/i))return Ut("nonce has already been used","NONCE_EXPIRED",{transaction:e.params[0],info:{payload:e,error:s}})}if(n==="eth_call"||n==="eth_estimateGas"){const o=Zf(s),c=Oa.getBuiltinCallException(n==="eth_call"?"call":"estimateGas",e.params[0],o?o.data:null);return c.info={error:s,payload:e},c}const r=JSON.stringify(QD(s));if(typeof s.message=="string"&&s.message.match(/user denied|ethers-user-denied/i))return Ut("user rejected action","ACTION_REJECTED",{action:{eth_sign:"signMessage",personal_sign:"signMessage",eth_signTypedData_v4:"signTypedData",eth_signTransaction:"signTransaction",eth_sendTransaction:"sendTransaction",eth_requestAccounts:"requestAccess",wallet_requestAccounts:"requestAccess"}[n]||"unknown",reason:"rejected",info:{payload:e,error:s}});if(n==="eth_sendRawTransaction"||n==="eth_sendTransaction"){const o=e.params[0];if(r.match(/insufficient funds|base fee exceeds gas limit/i))return Ut("insufficient funds for intrinsic transaction cost","INSUFFICIENT_FUNDS",{transaction:o,info:{error:s}});if(r.match(/nonce/i)&&r.match(/too low/i))return Ut("nonce has already been used","NONCE_EXPIRED",{transaction:o,info:{error:s}});if(r.match(/replacement transaction/i)&&r.match(/underpriced/i))return Ut("replacement fee too low","REPLACEMENT_UNDERPRICED",{transaction:o,info:{error:s}});if(r.match(/only replay-protected/i))return Ut("legacy pre-eip-155 transactions not supported","UNSUPPORTED_OPERATION",{operation:n,info:{transaction:o,info:{error:s}}})}let a=!!r.match(/the method .* does not exist/i);return a||s&&s.details&&s.details.startsWith("Unauthorized method:")&&(a=!0),a?Ut("unsupported operation","UNSUPPORTED_OPERATION",{operation:e.method,info:{error:s,payload:e}}):Ut("could not coalesce error","UNKNOWN_ERROR",{error:s,payload:e})}send(e,t){if(this.destroyed)return Promise.reject(Ut("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:e}));const n=this.#t++,s=new Promise((r,a)=>{this.#n.push({resolve:r,reject:a,payload:{method:e,params:t,id:n,jsonrpc:"2.0"}})});return this.#o(),s}async getSigner(e){e==null&&(e=0);const t=this.send("eth_accounts",[]);if(typeof e=="number"){const s=await t;if(e>=s.length)throw new Error("no such account");return new Jf(this,s[e])}const{accounts:n}=await Fn({network:this.getNetwork(),accounts:t});e=Ct(e);for(const s of n)if(Ct(s)===e)return new Jf(this,e);throw new Error("invalid account")}async listAccounts(){return(await this.send("eth_accounts",[])).map(t=>new Jf(this,t))}destroy(){this.#i&&(clearTimeout(this.#i),this.#i=null);for(const{payload:e,reject:t}of this.#n)t(Ut("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:e.method}));this.#n=[],super.destroy()}}class n_ extends OD{#e;constructor(e,t){super(e,t);let n=this._getOption("pollingInterval");n==null&&(n=t_.pollingInterval),this.#e=n}_getSubscriber(e){const t=super._getSubscriber(e);return e_(t)&&(t.pollingInterval=this.#e),t}get pollingInterval(){return this.#e}set pollingInterval(e){if(!Number.isInteger(e)||e<0)throw new Error("invalid interval");this.#e=e,this._forEachSubscriber(t=>{e_(t)&&(t.pollingInterval=this.#e)})}}class i_ extends n_{#e;constructor(e,t,n){e==null&&(e="http://localhost:8545"),super(t,n),typeof e=="string"?this.#e=new ki(e):this.#e=e.clone()}_getConnection(){return this.#e.clone()}async send(e,t){return await this._start(),await super.send(e,t)}async _send(e){const t=this._getConnection();t.body=JSON.stringify(e),t.setHeader("content-type","application/json");const n=await t.send();n.assertOk();let s=n.bodyJson;return Array.isArray(s)||(s=[s]),s}}function Zf(i){if(i==null)return null;if(typeof i.message=="string"&&i.message.match(/revert/i)&&Ft(i.data))return{message:i.message,data:i.data};if(typeof i=="object"){for(const e in i){const t=Zf(i[e]);if(t)return t}return null}if(typeof i=="string")try{return Zf(JSON.parse(i))}catch{}return null}function $f(i,e){if(i!=null){if(typeof i.message=="string"&&e.push(i.message),typeof i=="object")for(const t in i)$f(i[t],e);if(typeof i=="string")try{return $f(JSON.parse(i),e)}catch{}}}function QD(i){const e=[];return $f(i,e),e}class Nr extends n_{#e;#t;constructor(e,t,n){const s=Object.assign({},n??{},{batchMaxCount:1});V(e&&e.request,"invalid EIP-1193 provider","ethereum",e),super(t,s),this.#t=null,n&&n.providerInfo&&(this.#t=n.providerInfo),this.#e=async(r,a)=>{const o={method:r,params:a};this.emit("debug",{action:"sendEip1193Request",payload:o});try{const c=await e.request(o);return this.emit("debug",{action:"receiveEip1193Result",result:c}),c}catch(c){const l=new Error(c.message);throw l.code=c.code,l.data=c.data,l.payload=o,this.emit("debug",{action:"receiveEip1193Error",error:l}),l}}}get providerInfo(){return this.#t}async send(e,t){return await this._start(),await super.send(e,t)}async _send(e){V(!Array.isArray(e),"EIP-1193 does not support batch request","payload",e);try{const t=await this.#e(e.method,e.params||[]);return[{id:e.id,result:t}]}catch(t){return[{id:e.id,error:{code:t.code,data:t.data,message:t.message}}]}}getRpcError(e,t){switch(t=JSON.parse(JSON.stringify(t)),t.error.code||-1){case 4001:t.error.message=`ethers-user-denied: ${t.error.message}`;break;case 4200:t.error.message=`ethers-unsupported: ${t.error.message}`;break}return super.getRpcError(e,t)}async hasSigner(e){e==null&&(e=0);const t=await this.send("eth_accounts",[]);return typeof e=="number"?t.length>e:(e=e.toLowerCase(),t.filter(n=>n.toLowerCase()===e).length!==0)}async getSigner(e){if(e==null&&(e=0),!await this.hasSigner(e))try{await this.#e("eth_requestAccounts",[])}catch(t){const n=t.payload;throw this.getRpcError(n,{id:n.id,error:t})}return await super.getSigner(e)}static async discover(e){if(e==null&&(e={}),e.provider)return new Nr(e.provider);const t=e.window?e.window:typeof window<"u"?window:null;if(t==null)return null;const n=e.anyProvider;if(n&&t.ethereum)return new Nr(t.ethereum);if(!("addEventListener"in t&&"dispatchEvent"in t&&"removeEventListener"in t))return null;const s=e.timeout?e.timeout:300;return s===0?null:await new Promise((r,a)=>{let o=[];const c=u=>{o.push(u.detail),n&&l()},l=()=>{if(clearTimeout(h),o.length)if(e&&e.filter){const u=e.filter(o.map(d=>Object.assign({},d.info)));if(u==null)r(null);else if(u instanceof Nr)r(u);else{let d=null;if(u.uuid&&(d=o.filter(m=>u.uuid===m.info.uuid)[0]),d){const{provider:f,info:m}=d;r(new Nr(f,void 0,{providerInfo:m}))}else a(Ut("filter returned unknown info","UNSUPPORTED_OPERATION",{value:u}))}}else{const{provider:u,info:d}=o[0];r(new Nr(u,void 0,{providerInfo:d}))}else r(null);t.removeEventListener("eip6963:announceProvider",c)},h=setTimeout(()=>{l()},s);t.addEventListener("eip6963:announceProvider",c),t.dispatchEvent(new Event("eip6963:requestProvider"))})}}const s_=["function register() external returns (uint256 agentId)","function register(string agentURI) external returns (uint256 agentId)","function register(string agentURI, tuple(string metadataKey, bytes metadataValue)[] metadata) external returns (uint256 agentId)","function setAgentURI(uint256 agentId, string newURI) external","function tokenURI(uint256 tokenId) external view returns (string)","function setMetadata(uint256 agentId, string metadataKey, bytes metadataValue) external","function getMetadata(uint256 agentId, string metadataKey) external view returns (bytes)","function getAgentWallet(uint256 agentId) external view returns (address)","function ownerOf(uint256 tokenId) external view returns (address)","function balanceOf(address owner) external view returns (uint256)","function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256)","function totalSupply() external view returns (uint256)","function name() external view returns (string)","function symbol() external view returns (string)","function getVersion() external pure returns (string)","function transferFrom(address from, address to, uint256 tokenId) external","function safeTransferFrom(address from, address to, uint256 tokenId) external","function safeTransferFrom(address from, address to, uint256 tokenId, bytes data) external","function approve(address to, uint256 tokenId) external","function setApprovalForAll(address operator, bool approved) external","event Registered(uint256 indexed agentId, string agentURI, address indexed owner)","event Transfer(address indexed from, address indexed to, uint256 indexed tokenId)"],Fr={identityRegistry:"0x8004A818BFB912233c491871b3d84c89A494BD9e",reputationRegistry:"0x8004B663056A597Dffe9eCcC1965A193B7388713",validationRegistry:"0x8004Cb1BF31DAf7788923b405b754f57acEB4272"},Un={identityRegistry:"0x8004A169FB4a3325136EB29fA0ceB6D2e539a432",reputationRegistry:"0x8004BAa17C55a88189AE136b182e5fdA19dE9b63",validationRegistry:""},Ah={1:Un,10:Un,56:Un,100:Un,137:Un,250:Un,324:Un,1284:Un,5e3:Un,8453:Un,42161:Un,42220:Un,43114:Un,59144:Un,534352:Un,97:Fr,11155111:Fr,84532:Fr,421614:Fr,11155420:Fr,80002:Fr,43113:Fr};function GD(i,e){return`eip155:${i}:${e}`}const r_={1:{name:"Ethereum",shortName:"ETH",currency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrl:"https://ethereum-rpc.publicnode.com",explorer:"https://etherscan.io",testnet:!1},10:{name:"Optimism",shortName:"OP",currency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrl:"https://mainnet.optimism.io",explorer:"https://optimistic.etherscan.io",testnet:!1},56:{name:"BNB Chain",shortName:"BSC",currency:{name:"BNB",symbol:"BNB",decimals:18},rpcUrl:"https://bsc-dataseed.bnbchain.org",explorer:"https://bscscan.com",testnet:!1},100:{name:"Gnosis",shortName:"GNO",currency:{name:"xDAI",symbol:"xDAI",decimals:18},rpcUrl:"https://rpc.gnosischain.com",explorer:"https://gnosisscan.io",testnet:!1},137:{name:"Polygon",shortName:"POL",currency:{name:"POL",symbol:"POL",decimals:18},rpcUrl:"https://polygon-rpc.com",explorer:"https://polygonscan.com",testnet:!1},250:{name:"Fantom",shortName:"FTM",currency:{name:"Fantom",symbol:"FTM",decimals:18},rpcUrl:"https://rpc.ftm.tools",explorer:"https://ftmscan.com",testnet:!1},324:{name:"zkSync Era",shortName:"zkSync",currency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrl:"https://mainnet.era.zksync.io",explorer:"https://explorer.zksync.io",testnet:!1},1284:{name:"Moonbeam",shortName:"GLMR",currency:{name:"Glimmer",symbol:"GLMR",decimals:18},rpcUrl:"https://rpc.api.moonbeam.network",explorer:"https://moonbeam.moonscan.io",testnet:!1},5e3:{name:"Mantle",shortName:"MNT",currency:{name:"Mantle",symbol:"MNT",decimals:18},rpcUrl:"https://rpc.mantle.xyz",explorer:"https://explorer.mantle.xyz",testnet:!1},8453:{name:"Base",shortName:"Base",currency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrl:"https://mainnet.base.org",explorer:"https://basescan.org",testnet:!1},42161:{name:"Arbitrum One",shortName:"ARB",currency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrl:"https://arb1.arbitrum.io/rpc",explorer:"https://arbiscan.io",testnet:!1},42220:{name:"Celo",shortName:"CELO",currency:{name:"Celo",symbol:"CELO",decimals:18},rpcUrl:"https://forno.celo.org",explorer:"https://celoscan.io",testnet:!1},43114:{name:"Avalanche",shortName:"AVAX",currency:{name:"Avax",symbol:"AVAX",decimals:18},rpcUrl:"https://api.avax.network/ext/bc/C/rpc",explorer:"https://snowtrace.io",testnet:!1},59144:{name:"Linea",shortName:"Linea",currency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrl:"https://rpc.linea.build",explorer:"https://lineascan.build",testnet:!1},534352:{name:"Scroll",shortName:"Scroll",currency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrl:"https://rpc.scroll.io",explorer:"https://scrollscan.com",testnet:!1},97:{name:"BSC Testnet",shortName:"BSCt",currency:{name:"tBNB",symbol:"tBNB",decimals:18},rpcUrl:"https://bsc-testnet-rpc.publicnode.com",explorer:"https://testnet.bscscan.com",testnet:!0},11155111:{name:"Ethereum Sepolia",shortName:"Sep",currency:{name:"SepETH",symbol:"ETH",decimals:18},rpcUrl:"https://ethereum-sepolia-rpc.publicnode.com",explorer:"https://sepolia.etherscan.io",testnet:!0},84532:{name:"Base Sepolia",shortName:"BaseSep",currency:{name:"SepETH",symbol:"ETH",decimals:18},rpcUrl:"https://sepolia.base.org",explorer:"https://sepolia.basescan.org",testnet:!0},421614:{name:"Arbitrum Sepolia",shortName:"ArbSep",currency:{name:"SepETH",symbol:"ETH",decimals:18},rpcUrl:"https://sepolia-rollup.arbitrum.io/rpc",explorer:"https://sepolia.arbiscan.io",testnet:!0},11155420:{name:"Optimism Sepolia",shortName:"OpSep",currency:{name:"SepETH",symbol:"ETH",decimals:18},rpcUrl:"https://sepolia.optimism.io",explorer:"https://sepolia-optimism.etherscan.io",testnet:!0},80002:{name:"Polygon Amoy",shortName:"Amoy",currency:{name:"POL",symbol:"POL",decimals:18},rpcUrl:"https://rpc-amoy.polygon.technology",explorer:"https://amoy.polygonscan.com",testnet:!0},43113:{name:"Avalanche Fuji",shortName:"Fuji",currency:{name:"Avax",symbol:"AVAX",decimals:18},rpcUrl:"https://api.avax-test.network/ext/bc/C/rpc",explorer:"https://testnet.snowtrace.io",testnet:!0}};function HD(i,e){if(e)return new Nr(e);const t=r_[i];if(!t)throw new Error(`No RPC configured for chainId ${i}`);return new i_(t.rpcUrl,i)}function zD(i,e){const t=Ah[i];if(!t||!t.identityRegistry)throw new Error(`No Identity Registry for chainId ${i}`);const n=HD(i,e);return new Tr(t.identityRegistry,s_,n)}async function VD({chainId:i,agentId:e,ethProvider:t}){const n=zD(i,t),[s,r]=await Promise.all([n.ownerOf(e).catch(()=>null),n.tokenURI(e).catch(()=>null)]);return{agentId:BigInt(e),owner:s,uri:r}}function a_(i){if(!i||typeof i!="object")return null;const e=Array.isArray(i.services)?i.services:[];for(const n of e){if(!n||typeof n!="object")continue;const s=String(n.endpoint||"").trim();if(!s)continue;const r=String(n.name||"").toLowerCase(),a=String(n.version||"").toLowerCase();if(r==="avatar"||r==="avatar-3d"||a.startsWith("gltf")||/\.(glb|gltf)(\?|#|$)/i.test(s))return s}const t=String(i.image||"").trim();return/\.(glb|gltf)(\?|#|$)/i.test(t)?t:null}async function WD(i){if(!i)return{ok:!1,error:"empty uri"};if(i.startsWith("data:"))try{const t=i.match(/^data:application\/json(?:;base64)?,(.*)$/);if(!t)return{ok:!1,error:"unsupported data URI"};const n=/;base64,/.test(i)?atob(t[1]):decodeURIComponent(t[1]);return{ok:!0,data:JSON.parse(n),resolvedUrl:i}}catch(t){return{ok:!1,error:"data URI parse failed: "+t.message}}let e=i;i.startsWith("ipfs://")?e="https://ipfs.io/ipfs/"+i.slice(7):i.startsWith("ar://")&&(e="https://arweave.net/"+i.slice(5));try{const t=await fetch(e);return t.ok?{ok:!0,data:await t.json(),resolvedUrl:e}:{ok:!1,error:`HTTP ${t.status}`,resolvedUrl:e}}catch(t){return{ok:!1,error:t.message,resolvedUrl:e}}}const qD={base:8453,"base-mainnet":8453,"base-sepolia":84532,ethereum:1,mainnet:1},KD={8453:"https://mainnet.base.org",84532:"https://sepolia.base.org",1:"https://eth.llamarpc.com"};async function rc(i,{rpcURL:e,registry:t}={}){if(!i)throw new Error("loadManifest: source required");if(i.startsWith("agent://"))return jD(i,{rpcURL:e,registryOverride:t});if(i.startsWith("ipfs://")||i.startsWith("ar://")){const n=ns(i),s=await ep(n);return gh(s,{baseURI:tp(n)})}if(i.startsWith("http")){const n=await ep(i);return gh(n,{baseURI:tp(i)})}throw new Error(`Unsupported manifest source: ${i}`)}async function jD(i,{rpcURL:e,registryOverride:t}){const n=i.match(/^agent:\/\/([^/]+)\/(\d+)$/);if(!n)throw new Error(`Malformed agent URI: ${i}`);const[,s,r]=n,a=qD[s.toLowerCase()]||Number(s);if(!a)throw new Error(`Unknown chain: ${s}`);const o=Ah[a],c=t||o?.identityRegistry;if(!c)throw new Error(`No registry deployed on chain ${a}. Pass registry= override.`);const l=new i_(e||KD[a]),h=new Tr(c,s_,l),u=BigInt(r),d=await h.tokenURI(u);if(!d)throw new Error(`Agent ${r} on chain ${a} has no URI`);const f=ns(d),m=await ep(f),A=gh(m,{baseURI:tp(f)});return A.id={...A.id,chain:s,chainId:a,registry:c,agentId:r},A}async function ep(i){let e;try{e=await fetch(i)}catch{e=await Zm(i)}if(!e.ok)throw new Error(`Manifest fetch failed: ${i} (${e.status})`);return e.json()}function gh(i,{baseURI:e=""}={}){if(i.spec&&i.spec.startsWith("agent-manifest/")){const t={...i,_baseURI:e};return t.body=t.body||{},!t.body.uri&&t.image&&(t.body.uri=t.image),t}if(i.type&&i.type.includes("eip-8004")){const t=i.registrations?.[0]||{},n=a_(i);return{spec:"agent-manifest/0.1",_baseURI:e,_source:"erc8004-registration",id:{agentId:t.agentId?.toString()},name:i.name,description:i.description,image:i.image,body:{uri:ns(n||i.image||""),format:"gltf-binary"},brain:{provider:"none"},voice:{tts:{provider:"browser"},stt:{provider:"browser"}},skills:[],memory:{mode:"local"},tools:["wave","lookAt","play_clip","setExpression"],version:"0.1.0",services:Array.isArray(i.services)?i.services:[],x402Support:!!i.x402Support,embedPolicy:i.embedPolicy||null}}return{spec:"agent-manifest/0.1",_baseURI:e,name:i.name||"Unnamed agent",description:i.description||"",body:{uri:i.body?.uri||i.image||i.model||"",format:i.body?.format||"gltf-binary"},brain:i.brain||{provider:"none"},voice:i.voice||{tts:{provider:"browser"},stt:{provider:"browser"}},skills:i.skills||[],memory:i.memory||{mode:"local"},tools:i.tools||["wave","lookAt","play_clip","setExpression"],version:i.version||"0.1.0"}}function tp(i){const e=i.lastIndexOf("/");return e>=0?i.slice(0,e+1):i}async function o_(i,e){if(!i._baseURI)return null;try{const t=new URL(e,i._baseURI).href,n=await fetch(t);return n.ok?n.text():null}catch{return null}}class Sn extends Error{constructor(e,t,{status:n}={}){super(t),this.name="AgentResolveError",this.code=e,n!==void 0&&(this.status=n)}}async function c_(i,{fetchFn:e}){let t;try{t=await e(i,{credentials:"include"})}catch(n){throw new Sn("network",`network error fetching ${i}: ${n.message||n}`)}if(t.status===401||t.status===403)throw new Sn("unauthorized",`unauthorized fetching ${i} (${t.status})`,{status:t.status});if(t.status===404)throw new Sn("not_found",`resource not found: ${i}`,{status:404});if(!t.ok)throw new Sn("network",`request failed: ${i} (${t.status})`,{status:t.status});try{return await t.json()}catch(n){throw new Sn("network",`invalid JSON from ${i}: ${n.message||n}`)}}const Va=new Map,XD=100;async function YD(i,e){if(!i)throw new Sn("not-found","agentId required");if(Va.has(i))return Va.get(i);const t=typeof location<"u"?location.origin:"",n=`${t}/api/agents/${encodeURIComponent(i)}`;let s;try{s=await fetch(n,{credentials:"include",signal:e})}catch(c){throw c?.name==="AbortError"?c:new Sn("network",`network error fetching ${n}: ${c.message||c}`)}if(s.status===404)throw new Sn("not-found",`agent ${i} not found`,{status:404});if(s.status===401||s.status===403)throw new Sn("unauthorized",`unauthorized (${s.status})`,{status:s.status});if(!s.ok)throw new Sn("network",`request failed (${s.status})`,{status:s.status});let r;try{r=await s.json()}catch{throw new Sn("network",`invalid JSON from ${n}`)}const a=r?.agent?.manifestUrl??null;let o=null;if(a)try{o=new URL(a,t).href}catch{o=a}return Va.size>=XD&&Va.delete(Va.keys().next().value),Va.set(i,o),o}async function JD(i,{origin:e=typeof location<"u"?location.origin:"",fetchFn:t=fetch}={}){if(!i)throw new Sn("not_found","agentId required");const n=t.bind(typeof globalThis<"u"?globalThis:void 0),r=(await c_(`${e}/api/agents/${encodeURIComponent(i)}`,{fetchFn:n}))?.agent;if(!r)throw new Sn("not_found",`agent ${i} not found`);if(!r.avatar_id)throw new Sn("no_avatar",`agent ${i} has no avatar bound`);const o=(await c_(`${e}/api/avatars/${encodeURIComponent(r.avatar_id)}`,{fetchFn:n}))?.avatar;if(!o||!o.url)throw new Sn("no_avatar",`avatar ${r.avatar_id} has no url`);const c=Array.isArray(r.skills)?r.skills.map(l=>typeof l=="string"?{name:l}:l).filter(Boolean):[];return{spec:"agent-manifest/0.1",name:r.name||"Agent",description:r.description||"",id:{agentId:r.id,owner:r.wallet_address,chainId:r.chain_id,walletAddress:r.wallet_address},body:{uri:o.url,format:"gltf-binary"},brain:{},voice:{tts:{provider:"browser"},stt:{provider:"browser"}},skills:c,memory:{mode:"remote",namespace:r.id},tools:["wave","lookAt","play_clip","setExpression","speak","remember"],version:"0.1.0",_baseURI:`${e}/agent/${r.id}/`,_source:"agent-id"}}function l_(i){if(!i)return null;if(typeof i=="object")return i.chainId&&i.agentId!==void 0?{chainId:Number(i.chainId),agentId:String(i.agentId),registry:i.registry||void 0}:null;const e=String(i).trim();if(!e)return null;let t=e.match(/^eip155:(\d+):(0x[0-9a-fA-F]{40}):(\d+)$/);return t?{chainId:Number(t[1]),registry:t[2],agentId:t[3]}:(t=e.match(/^eip155:(\d+)\/erc721:(0x[0-9a-fA-F]{40})\/(\d+)$/),t?{chainId:Number(t[1]),registry:t[2],agentId:t[3]}:(t=e.match(/^onchain:(\d+):(\d+)$/),t?{chainId:Number(t[1]),agentId:t[2]}:(t=e.match(/^agent:\/\/(\d+)\/(\d+)$/),t?{chainId:Number(t[1]),agentId:t[2]}:(t=e.match(/^\/?a\/(\d+)\/(\d+)(?:\/(embed))?\/?$/),t?{chainId:Number(t[1]),agentId:t[2]}:(t=e.match(/^\/?a\/(\d+)\/(0x[0-9a-fA-F]{40})\/(\d+)\/?$/),t?{chainId:Number(t[1]),registry:t[2],agentId:t[3]}:null)))))}function ZD(i){const e=i.registry||Ah[i.chainId]?.identityRegistry;return e?`eip155:${i.chainId}:${e}:${i.agentId}`:`onchain:${i.chainId}:${i.agentId}`}function $D(i,{embed:e=!1,origin:t}={}){return`${t||(typeof location<"u"?location.origin:"")}/a/${i.chainId}/${i.agentId}${e?"/embed":""}`}const eL=["https://ipfs.io/ipfs/","https://dweb.link/ipfs/","https://cloudflare-ipfs.com/ipfs/","https://gateway.pinata.cloud/ipfs/"],tL="https://arweave.net/";function h_(i){return i?i.startsWith("ipfs://")?eL[0]+i.slice(7):i.startsWith("ar://")?tL+i.slice(5):i:""}const ac=new Map;function nL(i){return`${i.chainId}:${i.agentId}`}async function iL(i,{ethProvider:e,fresh:t=!1}={}){const n=l_(i);if(!n)throw new Error(`Unrecognised agent reference: ${i}`);const s={chainId:n.chainId,agentId:String(n.agentId),registry:n.registry||Ah[n.chainId]?.identityRegistry||null};if(!s.registry)throw new Error(`No registry deployed on chain ${s.chainId}`);const r=nL(s);if(!t&&ac.has(r))return ac.get(r);const a=r_[s.chainId]||null,o={ref:s,caip:ZD(s),publicUrl:typeof location<"u"?$D(s):`/a/${s.chainId}/${s.agentId}`,chain:a?{name:a.name,testnet:!!a.testnet,explorer:a.explorer}:null,onchain:{owner:null,uri:null},metadata:null,metadataUrl:null,image:null,glbUrl:null,name:`Agent #${s.agentId}`,description:"",services:[]};try{const{owner:c,uri:l}=await VD({chainId:s.chainId,agentId:s.agentId,ethProvider:e});if(o.onchain={owner:c,uri:l},!l)return o.error="agentURI not set",ac.set(r,o),o;const h=await WD(l);if(!h.ok)return o.error=h.error,o.metadataUrl=h.resolvedUrl||null,ac.set(r,o),o;const u=h.data;o.metadata=u,o.metadataUrl=h.resolvedUrl||null,o.name=u?.name&&String(u.name)||o.name,o.description=u?.description&&String(u.description)||"",o.image=u?.image?String(u.image):null,o.services=Array.isArray(u?.services)?u.services:[],o.glbUrl=a_(u)}catch(c){o.error=c.message||String(c)}return ac.set(r,o),o}function sL(i){const e=Array.isArray(i.services)?i.services:[],t=e.find(a=>/brain|llm|chat/i.test(a?.name||a?.type||"")),n=e.filter(a=>/skill/i.test(a?.name||a?.type||"")),s=i.glbUrl?h_(i.glbUrl):"",r=i.image?h_(i.image):"";return{spec:"agent-manifest/0.1",_baseURI:i.metadataUrl?rL(i.metadataUrl):"",_source:"erc8004-resolver",id:{agentId:i.ref.agentId,chainId:i.ref.chainId,registry:i.ref.registry,owner:i.onchain.owner||void 0,walletAddress:i.onchain.owner||void 0,caip:i.caip,agentRegistry:GD(i.ref.chainId,i.ref.registry)},name:i.name,description:i.description,image:r,body:{uri:s||r,format:"gltf-binary"},brain:t?{provider:"remote",endpoint:t.endpoint}:{provider:"none"},voice:{tts:{provider:"browser"},stt:{provider:"browser"}},skills:n.map(a=>({name:a.name,uri:a.endpoint})),memory:{mode:"local",namespace:i.caip},tools:["wave","lookAt","play_clip","setExpression"],version:"0.1.0",services:e,x402Support:!!(i.metadata?.x402Support||i.metadata?.x402),embedPolicy:i.metadata?.embedPolicy||null}}function rL(i){const e=i.lastIndexOf("/");return e>=0?i.slice(0,e+1):i}const u_=1,aL=256;function mh(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,i=>{const e=Math.random()*16|0;return(i==="x"?e:e&3|8).toString(16)})}const np={speak:"speak",gesture:"gesture",emote:"emote",look:"look-at"};class oL{constructor({protocol:e,avatar:t=null,manifest:n,window:s}){this._protocol=e,this._avatar=t,this._manifest=n,this._win=s,this._subscribed=!1,this._evtQueue=[],this._running=!1,this._onMessage=this._handleMessage.bind(this),this._onAction=this._handleAction.bind(this)}start(){if(this._running)return;this._running=!0,this._win.addEventListener("message",this._onMessage),this._protocol.on("*",this._onAction);const e=this._manifest?.id?.agentId||this._manifest?.agentId||"",t=[...Object.keys(np),"setAgent","ping","subscribe"];this._toParent({kind:"event",op:"ready",payload:{agentId:e,capabilities:t}})}stop(){this._running&&(this._running=!1,this._win.removeEventListener("message",this._onMessage),this._protocol.off("*",this._onAction),this._evtQueue=[])}_allowedOrigins(){const e=this._manifest?.policy;if(!e)return[];const t=e.origins||e.allowlist||[];return Array.isArray(t)?t:[t]}_originAllowed(e){const t=this._allowedOrigins();return t.length===0?!0:t.some(n=>{if(n==="*")return!0;try{return new URL(n).origin===e}catch{return n===e}})}_toParent(e){this._win.parent.postMessage({...e,v:u_,source:"agent-3d",id:e.id||mh()},"*")}_reply(e,t){this._toParent({id:mh(),inReplyTo:e.id,kind:"response",op:e.op==="ping"?"pong":e.op,payload:t})}_replyError(e,t,n){this._toParent({id:mh(),inReplyTo:e.id,kind:"response",op:e.op,payload:{error:`${t}: ${n}`}})}_handleMessage(e){if(e.source!==this._win.parent||!this._originAllowed(e.origin))return;const t=e.data;if(!t||t.v!==u_||t.source!=="agent-host"||t.kind!=="request")return;const{op:n,payload:s={}}=t;if(n==="ping"){this._reply(t,{capabilities:[...Object.keys(np),"subscribe"]});return}if(n==="subscribe"){this._subscribed=!0,this._reply(t,{ok:!0});for(const a of this._evtQueue)this._toParent(a);this._evtQueue=[];return}if(n==="setAgent"){this._replyError(t,"not_supported","setAgent requires host to update the iframe src");return}const r=np[n];if(!r){this._replyError(t,"unknown_op",`Unknown op "${n}"`);return}try{this._protocol.emit({type:r,payload:s}),this._reply(t,{ok:!0})}catch(a){this._replyError(t,"emit_failed",a?.message||String(a))}}_handleAction(e){if(!this._running)return;const t={id:mh(),kind:"event",op:"action",payload:{type:e.type,payload:e.payload,agentId:e.agentId}};if(!this._subscribed){this._evtQueue.length>=aL&&this._evtQueue.shift(),this._evtQueue.push(t);return}this._toParent(t)}}const cL={EMOTE:"emote"};class lL extends EventTarget{constructor(){super(),this._history=[],this._maxHistory=200}emit(e){const t={type:e.type,payload:e.payload||{},timestamp:Date.now(),agentId:e.agentId||"default",sourceSkill:e.sourceSkill||null};this._history.push(t),this._history.length>this._maxHistory&&this._history.shift(),this.dispatchEvent(new CustomEvent(t.type,{detail:t})),this.dispatchEvent(new CustomEvent("*",{detail:t}))}on(e,t){this._wrap(e,t,!1)}once(e,t){this._wrap(e,t,!0)}off(e,t){t.__protocolWrapped?this.removeEventListener(e,t.__protocolWrapped):this.removeEventListener(e,t)}get history(){return this._history.slice()}recent(e,t=10){return this._history.filter(n=>n.type===e).slice(-t)}_wrap(e,t,n){const s=r=>t(r.detail);t.__protocolWrapped=s,n?this.addEventListener(e,s,{once:!0}):this.addEventListener(e,s)}}const d_=new lL,hL=["inline","floating","section","fullscreen"],f_=(()=>{try{return new URL(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:js&&js.tagName.toUpperCase()==="SCRIPT"&&js.src||new URL("agent-3d.umd.cjs",document.baseURI).href).origin}catch{return""}})();function uL(i,e,t=[]){if(!i)return!1;let n;try{n=new URL(i).hostname.toLowerCase()}catch{return!1}if(t.some(o=>n===o||n.endsWith("."+o)))return!0;const s=e?.origins?.hosts??[],r=e?.origins?.mode??"allowlist",a=s.some(o=>{const c=o.toLowerCase();return c.startsWith("*.")?n.endsWith(c.slice(1))&&n!==c.slice(2):n===c});return r==="allowlist"?a:!a}const dL=`+ :host {+ display: block;+ position: relative;+ width: 100%;+ height: 480px;+ --agent-bubble-radius: 16px;+ --agent-accent: #3b82f6;+ --agent-surface: rgba(17, 24, 39, 0.92);+ --agent-on-surface: #f9fafb;+ --agent-chat-font: system-ui, -apple-system, sans-serif;+ --agent-mic-glow: #22c55e;+ --agent-shadow: 0 20px 60px rgba(0,0,0,0.3);+ contain: layout style;+ }+ :host([mode="floating"]) {+ position: fixed;+ z-index: 2147483000;+ width: var(--agent-width, 320px);+ height: var(--agent-height, 420px);+ border-radius: var(--agent-bubble-radius);+ overflow: hidden;+ box-shadow: var(--agent-shadow);+ transition:+ width 0.3s cubic-bezier(0.4, 0, 0.2, 1),+ height 0.3s cubic-bezier(0.4, 0, 0.2, 1),+ border-radius 0.3s cubic-bezier(0.4, 0, 0.2, 1);+ }+ @media (prefers-reduced-motion: reduce) {+ :host([mode="floating"]) { transition: none; }+ }+ /* Inline responsive: height follows width at a 3:4 portrait ratio */+ :host([mode="inline"][data-responsive]) {+ height: auto;+ aspect-ratio: var(--agent-aspect, 3/4);+ }+ :host([mode="fullscreen"]) {+ position: fixed;+ inset: 0;+ width: 100vw;+ height: 100vh;+ z-index: 2147483000;+ }+ :host([hidden]) { display: none; }+ .stage {+ position: absolute;+ inset: 0;+ width: 100%;+ height: 100%;+ }+ .stage canvas { display: block; }+ /* Pill tap target — shown when collapsed to pill on narrow viewports */+ .pill-btn {+ display: none;+ position: absolute;+ inset: 0;+ width: 100%;+ height: 100%;+ background: none;+ border: 0;+ cursor: pointer;+ border-radius: inherit;+ z-index: 10;+ }+ /* Swipe-down handle visible when bottom-sheet is expanded */+ .pill-drag {+ display: none;+ position: absolute;+ top: 8px;+ left: 50%;+ transform: translateX(-50%);+ width: 36px;+ height: 4px;+ border-radius: 2px;+ background: rgba(255,255,255,0.25);+ pointer-events: none;+ z-index: 20;+ }+ .chrome {+ position: absolute;+ left: 12px;+ right: 12px;+ bottom: 12px;+ display: flex;+ gap: 8px;+ align-items: flex-end;+ pointer-events: none;+ }+ .chrome > * { pointer-events: auto; }+ .chat {+ flex: 1;+ max-height: 40%;+ overflow-y: auto;+ background: var(--agent-surface);+ color: var(--agent-on-surface);+ font: 14px/1.4 var(--agent-chat-font);+ border-radius: 12px;+ padding: 10px 12px;+ backdrop-filter: blur(12px);+ }+ .chat:empty { display: none; }+ .msg { margin: 4px 0; }+ .msg .role { opacity: 0.55; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }+ .input-row {+ display: flex;+ gap: 6px;+ background: var(--agent-surface);+ border-radius: 999px;+ padding: 4px 4px 4px 14px;+ backdrop-filter: blur(12px);+ flex: 1;+ }+ .input-row input {+ flex: 1;+ background: transparent;+ border: 0;+ color: var(--agent-on-surface);+ font: 14px var(--agent-chat-font);+ outline: none;+ }+ button.icon {+ width: 36px;+ height: 36px;+ border-radius: 50%;+ border: 0;+ background: var(--agent-accent);+ color: white;+ cursor: pointer;+ display: inline-flex;+ align-items: center;+ justify-content: center;+ }+ button.icon.mic[data-listening="true"] { box-shadow: 0 0 0 4px var(--agent-mic-glow); }+ .poster {+ position: absolute;+ inset: 0;+ background-size: contain;+ background-position: center;+ background-repeat: no-repeat;+ transition: opacity 0.4s;+ pointer-events: none;+ }+ .loading {+ position: absolute;+ left: 50%;+ top: 50%;+ transform: translate(-50%, -50%);+ color: var(--agent-on-surface);+ font: 14px var(--agent-chat-font);+ background: var(--agent-surface);+ padding: 8px 14px;+ border-radius: 999px;+ }+ .error, .agent-3d-error {+ position: absolute;+ inset: 16px;+ display: grid;+ place-items: center;+ color: var(--agent-on-surface);+ background: var(--agent-surface);+ border-radius: 12px;+ padding: 16px;+ font: 14px var(--agent-chat-font);+ }+ /* Optional name plate overlay — toggled by the name-plate attribute. */+ .name-plate {+ position: absolute;+ left: 12px;+ bottom: 10px;+ z-index: 2;+ pointer-events: none;+ font: 11px/1 var(--agent-chat-font);+ letter-spacing: 0.04em;+ color: rgba(255, 255, 255, 0.6);+ text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);+ }+ .name-plate:empty,+ :host([name-plate="off"]) .name-plate { display: none; }+ /* Background variants — set on :host so the canvas composites over them. */+ :host([background="transparent"]) { background: transparent; }+ :host([background="dark"]) { background: #0b0d10; }+ :host([background="light"]) { background: #f5f5f5; }+ :host([background="light"]) .name-plate {+ color: rgba(0, 0, 0, 0.55);+ text-shadow: none;+ }+`;class ip extends HTMLElement{static get observedAttributes(){return["src","manifest","body","agent-id","mode","position","width","height","voice","api-key","key-proxy","responsive","background","name-plate"]}constructor(){super(),this.attachShadow({mode:"open"}),this._viewer=null,this._scene=null,this._runtime=null,this._memory=null,this._skills=null,this._manifest=null,this._mounted=!1,this._booting=!1,this._listening=!1,this._pillActive=!1,this._mqNarrow=null,this._mqNarrowHandler=null,this._ro=null,this._outsideTapHandler=null,this._autoResolvedManifest=!1,this._suppressAttrChange=!1}connectedCallback(){this._renderShell(),this._applyLayout(),this._setupResponsive(),this._observeViewport(),this.hasAttribute("eager")&&this._boot()}disconnectedCallback(){this._teardown()}attributeChangedCallback(e,t,n){!this._mounted||this._suppressAttrChange||(["mode","position","width","height","responsive"].includes(e)&&this._applyLayout(),e==="background"&&this._applyBackground(),e==="name-plate"&&this._applyNamePlate(),["src","manifest","body","agent-id"].includes(e)&&(this._teardown(),this._boot()))}_renderShell(){const e=document.createElement("style");e.textContent=dL,this.shadowRoot.appendChild(e);const t=document.createElement("div");t.className="stage",t.part="stage",this.shadowRoot.appendChild(t),this._stageEl=t;const n=document.createElement("div");n.className="poster",this.getAttribute("poster")&&(n.style.backgroundImage=`url(${this.getAttribute("poster")})`),this.shadowRoot.appendChild(n),this._posterEl=n;const s=document.createElement("div");s.className="loading",s.textContent="Loading...",s.hidden=!0,this.shadowRoot.appendChild(s),this._loadingEl=s;const r=document.createElement("div");r.className="name-plate",r.part="name-plate",this.shadowRoot.appendChild(r),this._nameplateEl=r;const a=document.createElement("button");a.className="pill-btn",a.setAttribute("aria-label","Open agent"),a.addEventListener("click",()=>this._expandPill()),a.addEventListener("keydown",c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),this._expandPill())}),this.shadowRoot.appendChild(a),this._pillBtn=a;const o=document.createElement("div");if(o.className="pill-drag",this.shadowRoot.appendChild(o),this._pillDrag=o,!this.hasAttribute("kiosk")){const c=document.createElement("div");c.className="chrome",c.part="chrome";const l=document.createElement("div");l.className="chat",l.part="chat";const h=document.createElement("div");h.className="input-row";const u=document.createElement("input");u.type="text",u.placeholder="Say something...",u.addEventListener("keydown",f=>{if(f.key==="Enter"&&u.value.trim()){const m=u.value.trim();u.value="",this.say(m)}});const d=document.createElement("button");d.className="icon mic",d.title="Push to talk",d.innerHTML="🎙",d.addEventListener("click",()=>this._toggleMic()),h.appendChild(u),h.appendChild(d),c.appendChild(l),c.appendChild(h),this.shadowRoot.appendChild(c),this._chatEl=l,this._inputEl=u,this._micEl=d}}_isResponsive(){return this.getAttribute("responsive")!=="false"}_clampWidth(e){const t=_parsePx(e);if(!t)return e;const n=Math.round(Math.max(160,t*.65)),s=Math.round(t/1440*100);return`clamp(${n}px, ${s}vw, ${t}px)`}_applyBackground(){const e=this._viewer;if(!e)return;const t=this.getAttribute("background")||"transparent";t==="transparent"?(e.renderer?.setClearAlpha?.(0),e.scene&&(e.scene.background=null)):t==="dark"?(e.renderer?.setClearAlpha?.(1),e.scene?.background?.set&&e.scene.background.set("#0b0d10")):t==="light"&&(e.renderer?.setClearAlpha?.(1),e.scene?.background?.set&&e.scene.background.set("#f5f5f5"))}_applyNamePlate(){}_setNamePlateText(e){this._nameplateEl&&(this._nameplateEl.textContent=e||"")}_clampHeight(e){const t=_parsePx(e);if(!t)return e;const n=Math.round(Math.max(200,t*.65)),s=Math.round(t/900*100);return`clamp(${n}px, ${s}vh, ${t}px)`}_applyLayout(){const e=this.getAttribute("mode")||"inline";if(!hL.includes(e))return;const t=this._isResponsive();if(e==="floating"){if(!this._pillActive){const r=this.getAttribute("position")||"bottom-right",a=(this.getAttribute("offset")||"24px 24px").split(/\s+/),[o,c]=[a[0],a[1]||a[0]];this.style.top=this.style.bottom=this.style.left=this.style.right="",r.includes("top")?this.style.top=o:this.style.bottom=o,r.includes("left")?this.style.left=c:r.includes("right")?this.style.right=c:r.includes("center")&&(this.style.left="50%",this.style.transform="translateX(-50%)")}const n=this.getAttribute("width")||"320px",s=this.getAttribute("height")||"420px";this.style.setProperty("--agent-width",t?this._clampWidth(n):n),this.style.setProperty("--agent-height",t?this._clampHeight(s):s)}else{this.style.top=this.style.bottom=this.style.left=this.style.right=this.style.transform="";const n=this.getAttribute("width"),s=this.getAttribute("height");e==="inline"&&(n&&(this.style.width=t?this._clampWidth(n):n),s?(this.style.height=s,this.removeAttribute("data-responsive")):t&&n&&(this.style.height="",this.setAttribute("data-responsive",""))),n&&this.style.setProperty("--agent-width",t?this._clampWidth(n):n),s&&this.style.setProperty("--agent-height",t?this._clampHeight(s):s)}}_setupResponsive(){const e=this.getAttribute("mode")||"inline";e==="inline"&&typeof ResizeObserver<"u"&&(this._ro=new ResizeObserver(()=>this._applyLayout()),this._ro.observe(this)),e==="floating"&&this._isResponsive()&&typeof window<"u"&&(this._mqNarrow=window.matchMedia("(max-width: 479px)"),this._mqNarrowHandler=n=>this._updatePillState(n.matches),this._mqNarrow.addEventListener("change",this._mqNarrowHandler),this._updatePillState(this._mqNarrow.matches));let t=0;this.shadowRoot.addEventListener("touchstart",n=>{t=n.touches[0].clientY},{passive:!0}),this.shadowRoot.addEventListener("touchend",n=>{n.changedTouches[0].clientY-t>60&&this._pillActive&&this.getAttribute("aria-expanded")==="true"&&this._collapsePill()},{passive:!0})}_updatePillState(e){e&&!this._pillActive?(this._pillActive=!0,this._collapsePill()):!e&&this._pillActive&&(this._pillActive=!1,this._restoreFromPill())}_collapsePill(){this.style.width="56px",this.style.height="56px",this.style.borderRadius="50%",this.setAttribute("aria-expanded","false"),this._pillBtn.style.display="block",this._pillDrag.style.display="none";const e=this.shadowRoot.querySelector(".chrome");e&&(e.style.display="none"),this._stageEl.style.display="none",this._outsideTapHandler&&(document.removeEventListener("pointerdown",this._outsideTapHandler),this._outsideTapHandler=null)}_expandPill(){if(!this._pillActive)return;this.style.width="100vw",this.style.height="70vh",this.style.borderRadius="16px 16px 0 0",this.style.bottom="0",this.style.top="auto",this.style.left="0",this.style.right="0",this.style.transform="none",this.setAttribute("aria-expanded","true"),this._pillBtn.style.display="none",this._pillDrag.style.display="block";const e=this.shadowRoot.querySelector(".chrome");e&&(e.style.display=""),this._stageEl.style.display="",this._outsideTapHandler=t=>{t.composedPath().includes(this)||this._collapsePill()},setTimeout(()=>document.addEventListener("pointerdown",this._outsideTapHandler),0)}_restoreFromPill(){this.removeAttribute("aria-expanded"),this._pillBtn.style.display="none",this._pillDrag.style.display="none";const e=this.shadowRoot.querySelector(".chrome");e&&(e.style.display=""),this._stageEl.style.display="",this.style.width=this.style.height=this.style.borderRadius="",this.style.bottom=this.style.top=this.style.left=this.style.right=this.style.transform="",this._applyLayout(),this._outsideTapHandler&&(document.removeEventListener("pointerdown",this._outsideTapHandler),this._outsideTapHandler=null)}_observeViewport(){if(!this.hasAttribute("eager")){if(typeof IntersectionObserver>"u"){this._boot();return}this._io=new IntersectionObserver(e=>{e.some(t=>t.isIntersecting)&&(this._io.disconnect(),this._boot())}),this._io.observe(this)}}async _boot(){if(!(this._booting||this._mounted)){this._booting=!0;try{this._loadingEl.hidden=!1,this.dispatchEvent(new CustomEvent("agent:load-progress",{detail:{phase:"manifest",pct:.1}}));const e=await this._resolveManifest();if(this._manifest=e,this.dispatchEvent(new CustomEvent("agent:load-progress",{detail:{phase:"manifest",pct:.3}})),typeof e.brain?.instructions=="string"&&e.brain.instructions.endsWith(".md")){const l=await o_(e,e.brain.instructions);l&&(e.instructions=fL(l))}else e.brain?.instructions&&(e.instructions=e.brain.instructions);const t=(()=>{const l=this.getAttribute("agent-id")||e.id?.agentId||"";return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(l)?l:null})();if(t)try{const l=f_||window.location.origin,h=await fetch(`${l}/api/agents/${t}/embed-policy`,{credentials:"omit"});if(h.ok){const{policy:u}=await h.json();if(u){if(u.surfaces?.script===!1){this._fail("embed_denied_surface","This agent disallows the script-tag embed.");return}const d=["three.ws","localhost"],f=window.location.origin;if(!f.startsWith("http://localhost")&&!uL(f,u,d)){this._fail("embed_denied_origin",`This agent isn't permitted on ${f}.`);return}}}}catch(l){console.warn("[agent-3d] embed-policy fetch failed; continuing",l)}this.dispatchEvent(new CustomEvent("agent:load-progress",{detail:{phase:"body",pct:.45}}));const n=new Vd(this._stageEl,{kiosk:this.hasAttribute("kiosk")});this._viewer=n,this._applyBackground(),this._setNamePlateText(e.name||""),this._applyNamePlate();const s=ns(e.body?.uri);s&&await n.load(s,"",new Map),this._scene=new e0(n),this.dispatchEvent(new CustomEvent("agent:load-progress",{detail:{phase:"memory",pct:.6}}));const r=e.id?.agentId||this.getAttribute("memory-key")||e.name||"anon";this._memory=await yi.load({mode:this.getAttribute("memory")||e.memory?.mode||"local",namespace:r,manifestURI:e._baseURI+"manifest.json",fetchFn:fetch.bind(globalThis)}),this.dispatchEvent(new CustomEvent("agent:load-progress",{detail:{phase:"skills",pct:.75}})),this._skills=new s0({trust:this.getAttribute("skill-trust")||"owned-only",ownerAddress:e.id?.owner});const a=e.skills||[];for(const l of a)try{const h=await this._skills.install(l,{bundleBase:e._baseURI});this.dispatchEvent(new CustomEvent("skill:loaded",{detail:{name:h.name,uri:h.uri}}))}catch(h){console.warn("[agent-3d] skill load failed",l,h)}this.dispatchEvent(new CustomEvent("agent:load-progress",{detail:{phase:"brain",pct:.9}}));const o={apiKey:this.getAttribute("api-key")||void 0,proxyURL:this.getAttribute("key-proxy")||void 0,agentId:t||void 0,apiOrigin:f_||window.location.origin},c=this._parseTTSAttribute();c&&(e.voice=e.voice||{},e.voice.tts={...e.voice.tts||{},...c}),this._runtime=new Jm({manifest:e,viewer:this._scene,memory:this._memory,skills:this._skills,providerConfig:o});for(const l of["brain:thinking","brain:message","skill:tool-called","voice:speech-start","voice:speech-end","voice:transcript","voice:listen-start","memory:write"])this._runtime.addEventListener(l,h=>{this.dispatchEvent(new CustomEvent(l,{detail:h.detail,bubbles:!0,composed:!0})),l==="brain:message"&&this._chatEl&&this._renderMessage(h.detail)});this._mounted=!0,window!==window.parent&&(this._embedBridge=new oL({protocol:d_,manifest:this._manifest,window}),this._embedBridge.start()),this._loadingEl.hidden=!0,this._pillActive||(this._posterEl.style.opacity="0"),this.dispatchEvent(new CustomEvent("agent:ready",{detail:{agent:this,manifest:e},bubbles:!0,composed:!0}))}catch(e){if(console.error("[agent-3d] boot failed",e),this._loadingEl.hidden=!0,e instanceof Sn&&e.code==="not-found"){const t=document.createElement("div");t.className="agent-3d-error",t.textContent="Agent not found",this.shadowRoot.appendChild(t)}else this._showError(e);this.dispatchEvent(new CustomEvent("agent:error",{detail:{phase:"boot",error:e},bubbles:!0,composed:!0}))}finally{this._booting=!1}}}async _resolveManifest(){const e=this.getAttribute("src"),t=this.getAttribute("manifest"),n=this.getAttribute("body"),s=this.getAttribute("agent-id"),r=this.getAttribute("chain-id");if(e)return s&&console.warn("[agent-3d] both src and agent-id provided; using src"),rc(e,{rpcURL:this.getAttribute("rpc-url"),registry:this.getAttribute("registry")});if(s){const a=r?{chainId:Number(r),agentId:s,registry:this.getAttribute("registry")||void 0}:s,o=l_(a);if(o){const l=await iL(o);if(l.error&&!l.glbUrl)throw new Error(`On-chain resolve failed: ${l.error}`);return sL(l)}if(t)return rc(t);const c=await YD(s);return c?(this._autoResolvedManifest=!0,this.setAttribute("manifest",c),rc(c)):JD(s)}if(t)return rc(t);if(n){const a=this.getAttribute("instructions");return{spec:"agent-manifest/0.1",_baseURI:"",name:this.getAttribute("name")||"Agent",body:{uri:n,format:"gltf-binary"},brain:{provider:this.getAttribute("brain")?"anthropic":"none",model:this.getAttribute("brain")||void 0,instructions:a||"You are an embodied three.ws."},instructions:a||"You are an embodied three.ws.",voice:{tts:{provider:"browser"},stt:{provider:"browser"}},skills:(this.getAttribute("skills")||"").split(",").map(o=>o.trim()).filter(Boolean).map(o=>({uri:o})),memory:{mode:this.getAttribute("memory")||"local"},tools:["wave","lookAt","play_clip","setExpression","speak","remember"],version:"0.1.0"}}throw new Error("<agent-3d> requires src=, manifest=, or body= attribute")}_renderMessage({role:e,content:t}){if(!this._chatEl||!t)return;const n=document.createElement("div");n.className="msg",n.innerHTML=`<div class="role">${e}</div><div class="body"></div>`,n.querySelector(".body").textContent=t,this._chatEl.appendChild(n),this._chatEl.scrollTop=this._chatEl.scrollHeight}_showError(e){const t=document.createElement("div");t.className="error",t.textContent=`Couldn't load agent: ${e.message||e}`,this.shadowRoot.appendChild(t)}_fail(e,t){this._loadingEl.hidden=!0;const n=document.createElement("div");n.className="error",n.textContent=t,this.shadowRoot.appendChild(n),this.dispatchEvent(new CustomEvent("agent:error",{detail:{phase:"policy",error:{code:e,message:t}},bubbles:!0,composed:!0}))}async _toggleMic(){if(this._runtime){if(this._listening){this._runtime.stt?.stop(),this._listening=!1,this._micEl.dataset.listening="false";return}this._listening=!0,this._micEl.dataset.listening="true";try{const e=await this._runtime.listen();e&&await this.say(e,{voice:!0})}catch(e){console.warn("[agent-3d] listen failed",e)}finally{this._listening=!1,this._micEl.dataset.listening="false"}}}_teardown(){if(this._autoResolvedManifest){this._suppressAttrChange=!0;try{this.removeAttribute("manifest")}finally{this._suppressAttrChange=!1}this._autoResolvedManifest=!1}try{this._io?.disconnect()}catch{}try{this._ro?.disconnect()}catch{}try{this._mqNarrow&&this._mqNarrowHandler&&this._mqNarrow.removeEventListener("change",this._mqNarrowHandler)}catch{}this._outsideTapHandler&&(document.removeEventListener("pointerdown",this._outsideTapHandler),this._outsideTapHandler=null),this._embedBridge?.stop(),this._embedBridge=null;try{this._runtime?.destroy()}catch{}try{this._viewer?.dispose?.()}catch{}this._mounted=!1,this._pillActive=!1,this._runtime=this._viewer=this._scene=this._memory=this._skills=null}async say(e,t={}){return this._runtime||await this._waitForReady(),this._runtime.send(e,{voice:t.voice??this.hasAttribute("voice")})}speak(e,t={}){const n=Math.max(1.5,(e?.split(" ").length??3)*.3),s=this._scene;s&&(s.playAnimationByHint("talk",{duration:n})||s.playAnimationByHint("yes",{duration:n})||s.playAnimationByHint("wave",{duration:n}))}async ask(e,t={}){return(await this.say(e,t))?.text||""}clearConversation(){this._runtime?.clearConversation()}async wave(e){return this._scene?.playAnimationByHint("wave",e)}async lookAt(e){return this._scene?.lookAt(e)}async play(e,t){return this._scene?.playClipByName(e,t)}async installSkill(e){if(!this._skills)throw new Error("Agent not mounted");return this._skills.install({uri:e})}uninstallSkill(e){return this._skills?.uninstall(e)}get skills(){return this._skills?.all()||[]}get memory(){return this._memory}get manifest(){return this._manifest}get runtime(){return this._runtime}setMode(e){this.setAttribute("mode",e)}setPosition(e,t){this.setAttribute("position",e),t&&this.setAttribute("offset",t)}setSize(e,t){this.setAttribute("width",e),this.setAttribute("height",t)}pause(){this._runtime?.pause()}resume(){}destroy(){this._teardown()}expressEmotion(e,t=.7){return e?(d_.emit(cL.EMOTE,{trigger:e,weight:Math.max(0,Math.min(1,Number(t)||0)),agentId:this._manifest?.id?.agentId}),!0):!1}_waitForReady(){return this._mounted?Promise.resolve():new Promise(e=>{const t=()=>{this.removeEventListener("agent:ready",t),e()};this.addEventListener("agent:ready",t),this._booting||this._boot()})}}function fL(i){const e=i.match(/^---\n[\s\S]*?\n---\n?([\s\S]*)$/);return e?e[1]:i}customElements.get("agent-3d")||customElements.define("agent-3d",ip);const pL=["row","circle","freeform"],AL=`+ :host {+ display: block;+ position: relative;+ width: 100%;+ height: 480px;+ contain: layout style;+ }+ :host([hidden]) { display: none; }+ .stage-canvas {+ position: absolute;+ inset: 0;+ width: 100%;+ height: 100%;+ }+ .stage-canvas canvas { display: block; }+ ::slotted(agent-3d) {+ position: absolute;+ pointer-events: none;+ }+`;class p_ extends HTMLElement{static get observedAttributes(){return["formation"]}constructor(){super(),this.attachShadow({mode:"open"}),this._viewer=null,this._agents=[],this._initialized=!1}connectedCallback(){this._renderShell(),this._initViewer(),this._mo=new MutationObserver(()=>this._repositionAll()),this._mo.observe(this,{childList:!0})}disconnectedCallback(){try{this._mo?.disconnect()}catch{}for(const e of[...this._agents])this.unregisterAgent(e.element);try{this._viewer?.dispose?.()}catch{}this._viewer=null,this._initialized=!1}attributeChangedCallback(e){e==="formation"&&this._repositionAll()}get formation(){const e=this.getAttribute("formation")||"row";return pL.includes(e)?e:"row"}get viewer(){return this._viewer}_renderShell(){const e=document.createElement("style");e.textContent=AL,this.shadowRoot.appendChild(e);const t=document.createElement("div");t.className="stage-canvas",t.part="stage",this.shadowRoot.appendChild(t),this._canvasBox=t;const n=document.createElement("slot");this.shadowRoot.appendChild(n)}_initViewer(){if(!this._initialized){this._viewer=new Vd(this._canvasBox,{kiosk:!0}),this._viewer.defaultCamera.position.set(0,1.55,3.4),this._viewer.defaultCamera.lookAt(0,1.2,0),this._viewer.controls.target.set(0,1.2,0),this._viewer.controls.update();try{this._viewer.updateLights?.()}catch{}try{this._viewer.updateEnvironment?.()}catch{}this._viewer.invalidate(),this._initialized=!0}}registerAgent(e,{id:t,group:n,manifest:s}){const r=this._uniqueId(t||s?.name||"agent"),a={id:r,element:e,group:n,manifest:s};return this._agents.push(a),this._viewer?.scene.add(n),this._repositionAll(),this.dispatchEvent(new CustomEvent("stage:agent-joined",{detail:{agentId:r,element:e,manifest:s},bubbles:!0,composed:!0})),r}unregisterAgent(e){const t=this._agents.findIndex(s=>s.element===e);if(t<0)return;const[n]=this._agents.splice(t,1);try{this._viewer?.scene.remove(n.group)}catch{}gL(n.group),this._repositionAll(),this.dispatchEvent(new CustomEvent("stage:agent-left",{detail:{agentId:n.id,element:n.element},bubbles:!0,composed:!0}))}_uniqueId(e){let t=e,n=1;const s=new Set(this._agents.map(r=>r.id));for(;s.has(t);)t=`${e}-${n++}`;return t}getAgents(){return this._agents.map(({id:e,group:t,manifest:n,element:s})=>({agentId:e,name:n?.name||e,position:[+t.position.x.toFixed(3),+t.position.y.toFixed(3),+t.position.z.toFixed(3)],element:s}))}broadcast(e,t){const n={from:e,event:t};for(const s of this._agents)s.id!==e&&s.element.dispatchEvent(new CustomEvent("stage:message",{detail:n}));this.dispatchEvent(new CustomEvent("stage:message",{detail:n,bubbles:!0,composed:!0}))}async routeMessage(e,t,n){const s=this._agents.find(r=>r.id===t);if(!s)return{ok:!1,error:`No agent "${t}" on stage`};try{return{ok:!0,reply:(await s.element.say(`[from ${e}] ${n}`))?.text||""}}catch(r){return{ok:!1,error:r?.message||String(r)}}}async addAgent(e){const t=document.createElement("agent-3d");return e&&typeof e=="object"&&(t._inlineManifest=e),t.hasAttribute("eager")||t.setAttribute("eager",""),this.appendChild(t),t}removeAgent(e){const t=this._agents.find(n=>n.id===e);t&&t.element.remove()}_repositionAll(){const e=this._agents.length;if(!(!e||!this._viewer)){for(let t=0;t<e;t++){const{element:n,group:s,manifest:r}=this._agents[t],a=this._slotFor(t,e);s.position.copy(a.world),s.lookAt(0,a.world.y+1,a.world.z+5),n.style.position="absolute",n.style.left=a.dom.left,n.style.top=a.dom.top,n.style.width=a.dom.width,n.style.height=a.dom.height,n.style.pointerEvents="none"}this._viewer.invalidate()}}_slotFor(e,t){const n=this.formation,s=1/Math.max(t,1);if(n==="circle"){const o=e/t*Math.PI*2,c=Math.max(.8,.4*t);return{world:new H(Math.sin(o)*c,0,-Math.cos(o)*c+c*.5),dom:{left:`${e*s*100}%`,top:"0",width:`${s*100}%`,height:"100%"}}}if(n==="freeform")return{world:new H(0,0,0),dom:{left:"0",top:"0",width:"100%",height:"100%"}};const a=(e-(t-1)/2)*1.1;return{world:new H(a,0,0),dom:{left:`${e*s*100}%`,top:"0",width:`${s*100}%`,height:"100%"}}}}function gL(i){i.traverse(e=>{if(e.geometry)try{e.geometry.dispose()}catch{}if(e.material){const t=Array.isArray(e.material)?e.material:[e.material];for(const n of t){for(const s of Object.keys(n)){const r=n[s];if(r&&r.isTexture)try{r.dispose()}catch{}}try{n.dispose()}catch{}}}}),i.parent&&i.parent.remove(i)}customElements.get("agent-stage")||customElements.define("agent-stage",p_);const mL=(i="agent-3d")=>{customElements.get(i)||customElements.define(i,ip)},sp=new WeakMap;class bL extends $i{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,s){const r=new Ts(this.manager);r.setPath(this.path),r.setResponseType("arraybuffer"),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(e,a=>{this.parse(a,t,s)},n,s)}parse(e,t,n=()=>{}){this.decodeDracoFile(e,t,null,null,Kt,n).catch(n)}decodeDracoFile(e,t,n,s,r=rn,a=()=>{}){const o={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:s||this.defaultAttributeTypes,useUniqueIDs:!!n,vertexColorSpace:r};return this.decodeGeometry(e,o).then(t).catch(a)}decodeGeometry(e,t){const n=JSON.stringify(t);if(sp.has(e)){const c=sp.get(e);if(c.key===n)return c.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let s;const r=this.workerNextTaskID++,a=e.byteLength,o=this._getWorker(r,a).then(c=>(s=c,new Promise((l,h)=>{s._callbacks[r]={resolve:l,reject:h},s.postMessage({type:"decode",id:r,taskConfig:t,buffer:e},[e])}))).then(c=>this._createGeometry(c.geometry));return o.catch(()=>!0).then(()=>{s&&r&&this._releaseTask(s,r)}),sp.set(e,{key:n,promise:o}),o}_createGeometry(e){const t=new Qn;e.index&&t.setIndex(new _n(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const s=e.attributes[n],r=s.name,a=s.array,o=s.itemSize,c=new _n(a,o);r==="color"&&(this._assignVertexColorSpace(c,s.vertexColorSpace),c.normalized=!(a instanceof Float32Array)),t.setAttribute(r,c)}return t}_assignVertexColorSpace(e,t){if(t!==Kt)return;const n=new qe;for(let s=0,r=e.count;s<r;s++)n.fromBufferAttribute(e,s),At.toWorkingColorSpace(n,Kt),e.setXYZ(s,n.r,n.g,n.b)}_loadLibrary(e,t){const n=new Ts(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise((s,r)=>{n.load(e,s,void 0,r)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(n=>{const s=n[0];e||(this.decoderConfig.wasmBinary=n[1]);const r=xL.toString(),a=["/* draco decoder */",s,"","/* worker */",r.substring(r.indexOf("{")+1,r.lastIndexOf("}"))].join(`+`);this.workerSourceURL=URL.createObjectURL(new Blob([a]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const s=new Worker(this.workerSourceURL);s._callbacks={},s._taskCosts={},s._taskLoad=0,s.postMessage({type:"init",decoderConfig:this.decoderConfig}),s.onmessage=function(r){const a=r.data;switch(a.type){case"decode":s._callbacks[a.id].resolve(a);break;case"error":s._callbacks[a.id].reject(a);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+a.type+'"')}},this.workerPool.push(s)}else this.workerPool.sort(function(s,r){return s._taskLoad>r._taskLoad?-1:1});const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}}function xL(){let i,e;onmessage=function(a){const o=a.data;switch(o.type){case"init":i=o.decoderConfig,e=new Promise(function(h){i.onModuleLoaded=function(u){h({draco:u})},DracoDecoderModule(i)});break;case"decode":const c=o.buffer,l=o.taskConfig;e.then(h=>{const u=h.draco,d=new u.Decoder;try{const f=t(u,d,new Int8Array(c),l),m=f.attributes.map(A=>A.array.buffer);f.index&&m.push(f.index.array.buffer),self.postMessage({type:"decode",id:o.id,geometry:f},m)}catch(f){console.error(f),self.postMessage({type:"error",id:o.id,error:f.message})}finally{u.destroy(d)}});break}};function t(a,o,c,l){const h=l.attributeIDs,u=l.attributeTypes;let d,f;const m=o.GetEncodedGeometryType(c);if(m===a.TRIANGULAR_MESH)d=new a.Mesh,f=o.DecodeArrayToMesh(c,c.byteLength,d);else if(m===a.POINT_CLOUD)d=new a.PointCloud,f=o.DecodeArrayToPointCloud(c,c.byteLength,d);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!f.ok()||d.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+f.error_msg());const A={index:null,attributes:[]};for(const g in h){const p=self[u[g]];let y,b;if(l.useUniqueIDs)b=h[g],y=o.GetAttributeByUniqueId(d,b);else{if(b=o.GetAttributeId(d,a[h[g]]),b===-1)continue;y=o.GetAttribute(d,b)}const E=s(a,o,d,g,p,y);g==="color"&&(E.vertexColorSpace=l.vertexColorSpace),A.attributes.push(E)}return m===a.TRIANGULAR_MESH&&(A.index=n(a,o,d)),a.destroy(d),A}function n(a,o,c){const h=c.num_faces()*3,u=h*4,d=a._malloc(u);o.GetTrianglesUInt32Array(c,u,d);const f=new Uint32Array(a.HEAPF32.buffer,d,h).slice();return a._free(d),{array:f,itemSize:1}}function s(a,o,c,l,h,u){const d=u.num_components(),m=c.num_points()*d,A=m*h.BYTES_PER_ELEMENT,g=r(a,h),p=a._malloc(A);o.GetAttributeDataArrayForAllPoints(c,u,g,A,p);const y=new h(a.HEAPF32.buffer,p,m).slice();return a._free(p),{name:l,array:y,itemSize:d}}function r(a,o){switch(o){case Float32Array:return a.DT_FLOAT32;case Int8Array:return a.DT_INT8;case Int16Array:return a.DT_INT16;case Int32Array:return a.DT_INT32;case Uint8Array:return a.DT_UINT8;case Uint16Array:return a.DT_UINT16;case Uint32Array:return a.DT_UINT32}}}const _L=Object.freeze(Object.defineProperty({__proto__:null,DRACOLoader:bL},Symbol.toStringTag,{value:"Module"}));class EL{constructor(e=4){this.pool=e,this.queue=[],this.workers=[],this.workersResolve=[],this.workerStatus=0,this.workerCreator=null}_initWorker(e){if(!this.workers[e]){const t=this.workerCreator();t.addEventListener("message",this._onMessage.bind(this,e)),this.workers[e]=t}}_getIdleWorker(){for(let e=0;e<this.pool;e++)if(!(this.workerStatus&1<<e))return e;return-1}_onMessage(e,t){const n=this.workersResolve[e];if(n&&n(t),this.queue.length){const{resolve:s,msg:r,transfer:a}=this.queue.shift();this.workersResolve[e]=s,this.workers[e].postMessage(r,a)}else this.workerStatus^=1<<e}setWorkerCreator(e){this.workerCreator=e}setWorkerLimit(e){this.pool=e}postMessage(e,t){return new Promise(n=>{const s=this._getIdleWorker();s!==-1?(this._initWorker(s),this.workerStatus|=1<<s,this.workersResolve[s]=n,this.workers[s].postMessage(e,t)):this.queue.push({resolve:n,msg:e,transfer:t})})}dispose(){this.workers.forEach(e=>e.terminate()),this.workersResolve.length=0,this.workers.length=0,this.queue.length=0,this.workerStatus=0}}const yL=0,A_=2,wL=1,g_=2,vL=0,CL=1,SL=10,IL=0,m_=9,b_=15,x_=16,__=22,E_=37,y_=43,w_=76,v_=83,C_=97,S_=100,I_=103,M_=109,B_=165,T_=166,rp=1000066e3;class ML{constructor(){this.vkFormat=0,this.typeSize=1,this.pixelWidth=0,this.pixelHeight=0,this.pixelDepth=0,this.layerCount=0,this.faceCount=1,this.supercompressionScheme=0,this.levels=[],this.dataFormatDescriptor=[{vendorId:0,descriptorType:0,descriptorBlockSize:0,versionNumber:2,colorModel:0,colorPrimaries:1,transferFunction:2,flags:0,texelBlockDimension:[0,0,0,0],bytesPlane:[0,0,0,0,0,0,0,0],samples:[]}],this.keyValue={},this.globalData=null}}class oc{constructor(e,t,n,s){this._dataView=void 0,this._littleEndian=void 0,this._offset=void 0,this._dataView=new DataView(e.buffer,e.byteOffset+t,n),this._littleEndian=s,this._offset=0}_nextUint8(){const e=this._dataView.getUint8(this._offset);return this._offset+=1,e}_nextUint16(){const e=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,e}_nextUint32(){const e=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,e}_nextUint64(){const e=this._dataView.getUint32(this._offset,this._littleEndian)+4294967296*this._dataView.getUint32(this._offset+4,this._littleEndian);return this._offset+=8,e}_nextInt32(){const e=this._dataView.getInt32(this._offset,this._littleEndian);return this._offset+=4,e}_nextUint8Array(e){const t=new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+this._offset,e);return this._offset+=e,t}_skip(e){return this._offset+=e,this}_scan(e,t){t===void 0&&(t=0);const n=this._offset;let s=0;for(;this._dataView.getUint8(this._offset)!==t&&s<e;)s++,this._offset++;return s<e&&this._offset++,new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+n,s)}}const On=[171,75,84,88,32,50,48,187,13,10,26,10];function R_(i){return new TextDecoder().decode(i)}function BL(i){const e=new Uint8Array(i.buffer,i.byteOffset,On.length);if(e[0]!==On[0]||e[1]!==On[1]||e[2]!==On[2]||e[3]!==On[3]||e[4]!==On[4]||e[5]!==On[5]||e[6]!==On[6]||e[7]!==On[7]||e[8]!==On[8]||e[9]!==On[9]||e[10]!==On[10]||e[11]!==On[11])throw new Error("Missing KTX 2.0 identifier.");const t=new ML,n=17*Uint32Array.BYTES_PER_ELEMENT,s=new oc(i,On.length,n,!0);t.vkFormat=s._nextUint32(),t.typeSize=s._nextUint32(),t.pixelWidth=s._nextUint32(),t.pixelHeight=s._nextUint32(),t.pixelDepth=s._nextUint32(),t.layerCount=s._nextUint32(),t.faceCount=s._nextUint32();const r=s._nextUint32();t.supercompressionScheme=s._nextUint32();const a=s._nextUint32(),o=s._nextUint32(),c=s._nextUint32(),l=s._nextUint32(),h=s._nextUint64(),u=s._nextUint64(),d=new oc(i,On.length+n,3*r*8,!0);for(let Y=0;Y<r;Y++)t.levels.push({levelData:new Uint8Array(i.buffer,i.byteOffset+d._nextUint64(),d._nextUint64()),uncompressedByteLength:d._nextUint64()});const f=new oc(i,a,o,!0),m={vendorId:f._skip(4)._nextUint16(),descriptorType:f._nextUint16(),versionNumber:f._nextUint16(),descriptorBlockSize:f._nextUint16(),colorModel:f._nextUint8(),colorPrimaries:f._nextUint8(),transferFunction:f._nextUint8(),flags:f._nextUint8(),texelBlockDimension:[f._nextUint8(),f._nextUint8(),f._nextUint8(),f._nextUint8()],bytesPlane:[f._nextUint8(),f._nextUint8(),f._nextUint8(),f._nextUint8(),f._nextUint8(),f._nextUint8(),f._nextUint8(),f._nextUint8()],samples:[]},A=(m.descriptorBlockSize/4-6)/4;for(let Y=0;Y<A;Y++){const Q={bitOffset:f._nextUint16(),bitLength:f._nextUint8(),channelType:f._nextUint8(),samplePosition:[f._nextUint8(),f._nextUint8(),f._nextUint8(),f._nextUint8()],sampleLower:-1/0,sampleUpper:1/0};64&Q.channelType?(Q.sampleLower=f._nextInt32(),Q.sampleUpper=f._nextInt32()):(Q.sampleLower=f._nextUint32(),Q.sampleUpper=f._nextUint32()),m.samples[Y]=Q}t.dataFormatDescriptor.length=0,t.dataFormatDescriptor.push(m);const g=new oc(i,c,l,!0);for(;g._offset<l;){const Y=g._nextUint32(),Q=g._scan(Y),J=R_(Q);if(t.keyValue[J]=g._nextUint8Array(Y-Q.byteLength-1),J.match(/^ktx/i)){const ee=R_(t.keyValue[J]);t.keyValue[J]=ee.substring(0,ee.lastIndexOf("\0"))}g._skip(Y%4?4-Y%4:0)}if(u<=0)return t;const p=new oc(i,h,u,!0),y=p._nextUint16(),b=p._nextUint16(),E=p._nextUint32(),M=p._nextUint32(),w=p._nextUint32(),S=p._nextUint32(),T=[];for(let Y=0;Y<r;Y++)T.push({imageFlags:p._nextUint32(),rgbSliceByteOffset:p._nextUint32(),rgbSliceByteLength:p._nextUint32(),alphaSliceByteOffset:p._nextUint32(),alphaSliceByteLength:p._nextUint32()});const C=h+p._offset,v=C+E,F=v+M,K=F+w,q=new Uint8Array(i.buffer,i.byteOffset+C,E),$=new Uint8Array(i.buffer,i.byteOffset+v,M),D=new Uint8Array(i.buffer,i.byteOffset+F,w),O=new Uint8Array(i.buffer,i.byteOffset+K,S);return t.globalData={endpointCount:y,selectorCount:b,imageDescs:T,endpointsData:q,selectorsData:$,tablesData:D,extendedData:O},t}let ap,As,op;const cp={env:{emscripten_notify_memory_growth:function(i){op=new Uint8Array(As.exports.memory.buffer)}}};class TL{init(){return ap||(ap=typeof fetch<"u"?fetch("data:application/wasm;base64,"+N_).then(e=>e.arrayBuffer()).then(e=>WebAssembly.instantiate(e,cp)).then(this._init):WebAssembly.instantiate(Buffer.from(N_,"base64"),cp).then(this._init),ap)}_init(e){As=e.instance,cp.env.emscripten_notify_memory_growth(0)}decode(e,t=0){if(!As)throw new Error("ZSTDDecoder: Await .init() before decoding.");const n=e.byteLength,s=As.exports.malloc(n);op.set(e,s),t=t||Number(As.exports.ZSTD_findDecompressedSize(s,n));const r=As.exports.malloc(t),a=As.exports.ZSTD_decompress(r,t,s,n),o=op.slice(r,r+a);return As.exports.free(s),As.exports.free(r),o}}const N_="AGFzbQEAAAABpQEVYAF/AX9gAn9/AGADf39/AX9gBX9/f39/AX9gAX8AYAJ/fwF/YAR/f39/AX9gA39/fwBgBn9/f39/fwF/YAd/f39/f39/AX9gAn9/AX5gAn5+AX5gAABgBX9/f39/AGAGf39/f39/AGAIf39/f39/f38AYAl/f39/f39/f38AYAABf2AIf39/f39/f38Bf2ANf39/f39/f39/f39/fwF/YAF/AX4CJwEDZW52H2Vtc2NyaXB0ZW5fbm90aWZ5X21lbW9yeV9ncm93dGgABANpaAEFAAAFAgEFCwACAQABAgIFBQcAAwABDgsBAQcAEhMHAAUBDAQEAAANBwQCAgYCBAgDAwMDBgEACQkHBgICAAYGAgQUBwYGAwIGAAMCAQgBBwUGCgoEEQAEBAEIAwgDBQgDEA8IAAcABAUBcAECAgUEAQCAAgYJAX8BQaCgwAILB2AHBm1lbW9yeQIABm1hbGxvYwAoBGZyZWUAJgxaU1REX2lzRXJyb3IAaBlaU1REX2ZpbmREZWNvbXByZXNzZWRTaXplAFQPWlNURF9kZWNvbXByZXNzAEoGX3N0YXJ0ACQJBwEAQQELASQKussBaA8AIAAgACgCBCABajYCBAsZACAAKAIAIAAoAgRBH3F0QQAgAWtBH3F2CwgAIABBiH9LC34BBH9BAyEBIAAoAgQiA0EgTQRAIAAoAggiASAAKAIQTwRAIAAQDQ8LIAAoAgwiAiABRgRAQQFBAiADQSBJGw8LIAAgASABIAJrIANBA3YiBCABIARrIAJJIgEbIgJrIgQ2AgggACADIAJBA3RrNgIEIAAgBCgAADYCAAsgAQsUAQF/IAAgARACIQIgACABEAEgAgv3AQECfyACRQRAIABCADcCACAAQQA2AhAgAEIANwIIQbh/DwsgACABNgIMIAAgAUEEajYCECACQQRPBEAgACABIAJqIgFBfGoiAzYCCCAAIAMoAAA2AgAgAUF/ai0AACIBBEAgAEEIIAEQFGs2AgQgAg8LIABBADYCBEF/DwsgACABNgIIIAAgAS0AACIDNgIAIAJBfmoiBEEBTQRAIARBAWtFBEAgACABLQACQRB0IANyIgM2AgALIAAgAS0AAUEIdCADajYCAAsgASACakF/ai0AACIBRQRAIABBADYCBEFsDwsgAEEoIAEQFCACQQN0ams2AgQgAgsWACAAIAEpAAA3AAAgACABKQAINwAICy8BAX8gAUECdEGgHWooAgAgACgCAEEgIAEgACgCBGprQR9xdnEhAiAAIAEQASACCyEAIAFCz9bTvtLHq9lCfiAAfEIfiUKHla+vmLbem55/fgsdAQF/IAAoAgggACgCDEYEfyAAKAIEQSBGBUEACwuCBAEDfyACQYDAAE8EQCAAIAEgAhBnIAAPCyAAIAJqIQMCQCAAIAFzQQNxRQRAAkAgAkEBSARAIAAhAgwBCyAAQQNxRQRAIAAhAgwBCyAAIQIDQCACIAEtAAA6AAAgAUEBaiEBIAJBAWoiAiADTw0BIAJBA3ENAAsLAkAgA0F8cSIEQcAASQ0AIAIgBEFAaiIFSw0AA0AgAiABKAIANgIAIAIgASgCBDYCBCACIAEoAgg2AgggAiABKAIMNgIMIAIgASgCEDYCECACIAEoAhQ2AhQgAiABKAIYNgIYIAIgASgCHDYCHCACIAEoAiA2AiAgAiABKAIkNgIkIAIgASgCKDYCKCACIAEoAiw2AiwgAiABKAIwNgIwIAIgASgCNDYCNCACIAEoAjg2AjggAiABKAI8NgI8IAFBQGshASACQUBrIgIgBU0NAAsLIAIgBE8NAQNAIAIgASgCADYCACABQQRqIQEgAkEEaiICIARJDQALDAELIANBBEkEQCAAIQIMAQsgA0F8aiIEIABJBEAgACECDAELIAAhAgNAIAIgAS0AADoAACACIAEtAAE6AAEgAiABLQACOgACIAIgAS0AAzoAAyABQQRqIQEgAkEEaiICIARNDQALCyACIANJBEADQCACIAEtAAA6AAAgAUEBaiEBIAJBAWoiAiADRw0ACwsgAAsMACAAIAEpAAA3AAALQQECfyAAKAIIIgEgACgCEEkEQEEDDwsgACAAKAIEIgJBB3E2AgQgACABIAJBA3ZrIgE2AgggACABKAAANgIAQQALDAAgACABKAIANgAAC/cCAQJ/AkAgACABRg0AAkAgASACaiAASwRAIAAgAmoiBCABSw0BCyAAIAEgAhALDwsgACABc0EDcSEDAkACQCAAIAFJBEAgAwRAIAAhAwwDCyAAQQNxRQRAIAAhAwwCCyAAIQMDQCACRQ0EIAMgAS0AADoAACABQQFqIQEgAkF/aiECIANBAWoiA0EDcQ0ACwwBCwJAIAMNACAEQQNxBEADQCACRQ0FIAAgAkF/aiICaiIDIAEgAmotAAA6AAAgA0EDcQ0ACwsgAkEDTQ0AA0AgACACQXxqIgJqIAEgAmooAgA2AgAgAkEDSw0ACwsgAkUNAgNAIAAgAkF/aiICaiABIAJqLQAAOgAAIAINAAsMAgsgAkEDTQ0AIAIhBANAIAMgASgCADYCACABQQRqIQEgA0EEaiEDIARBfGoiBEEDSw0ACyACQQNxIQILIAJFDQADQCADIAEtAAA6AAAgA0EBaiEDIAFBAWohASACQX9qIgINAAsLIAAL8wICAn8BfgJAIAJFDQAgACACaiIDQX9qIAE6AAAgACABOgAAIAJBA0kNACADQX5qIAE6AAAgACABOgABIANBfWogAToAACAAIAE6AAIgAkEHSQ0AIANBfGogAToAACAAIAE6AAMgAkEJSQ0AIABBACAAa0EDcSIEaiIDIAFB/wFxQYGChAhsIgE2AgAgAyACIARrQXxxIgRqIgJBfGogATYCACAEQQlJDQAgAyABNgIIIAMgATYCBCACQXhqIAE2AgAgAkF0aiABNgIAIARBGUkNACADIAE2AhggAyABNgIUIAMgATYCECADIAE2AgwgAkFwaiABNgIAIAJBbGogATYCACACQWhqIAE2AgAgAkFkaiABNgIAIAQgA0EEcUEYciIEayICQSBJDQAgAa0iBUIghiAFhCEFIAMgBGohAQNAIAEgBTcDGCABIAU3AxAgASAFNwMIIAEgBTcDACABQSBqIQEgAkFgaiICQR9LDQALCyAACy8BAn8gACgCBCAAKAIAQQJ0aiICLQACIQMgACACLwEAIAEgAi0AAxAIajYCACADCy8BAn8gACgCBCAAKAIAQQJ0aiICLQACIQMgACACLwEAIAEgAi0AAxAFajYCACADCx8AIAAgASACKAIEEAg2AgAgARAEGiAAIAJBCGo2AgQLCAAgAGdBH3MLugUBDX8jAEEQayIKJAACfyAEQQNNBEAgCkEANgIMIApBDGogAyAEEAsaIAAgASACIApBDGpBBBAVIgBBbCAAEAMbIAAgACAESxsMAQsgAEEAIAEoAgBBAXRBAmoQECENQVQgAygAACIGQQ9xIgBBCksNABogAiAAQQVqNgIAIAMgBGoiAkF8aiEMIAJBeWohDiACQXtqIRAgAEEGaiELQQQhBSAGQQR2IQRBICAAdCIAQQFyIQkgASgCACEPQQAhAiADIQYCQANAIAlBAkggAiAPS3JFBEAgAiEHAkAgCARAA0AgBEH//wNxQf//A0YEQCAHQRhqIQcgBiAQSQR/IAZBAmoiBigAACAFdgUgBUEQaiEFIARBEHYLIQQMAQsLA0AgBEEDcSIIQQNGBEAgBUECaiEFIARBAnYhBCAHQQNqIQcMAQsLIAcgCGoiByAPSw0EIAVBAmohBQNAIAIgB0kEQCANIAJBAXRqQQA7AQAgAkEBaiECDAELCyAGIA5LQQAgBiAFQQN1aiIHIAxLG0UEQCAHKAAAIAVBB3EiBXYhBAwCCyAEQQJ2IQQLIAYhBwsCfyALQX9qIAQgAEF/anEiBiAAQQF0QX9qIgggCWsiEUkNABogBCAIcSIEQQAgESAEIABIG2shBiALCyEIIA0gAkEBdGogBkF/aiIEOwEAIAlBASAGayAEIAZBAUgbayEJA0AgCSAASARAIABBAXUhACALQX9qIQsMAQsLAn8gByAOS0EAIAcgBSAIaiIFQQN1aiIGIAxLG0UEQCAFQQdxDAELIAUgDCIGIAdrQQN0awshBSACQQFqIQIgBEUhCCAGKAAAIAVBH3F2IQQMAQsLQWwgCUEBRyAFQSBKcg0BGiABIAJBf2o2AgAgBiAFQQdqQQN1aiADawwBC0FQCyEAIApBEGokACAACwkAQQFBBSAAGwsMACAAIAEoAAA2AAALqgMBCn8jAEHwAGsiCiQAIAJBAWohDiAAQQhqIQtBgIAEIAVBf2p0QRB1IQxBACECQQEhBkEBIAV0IglBf2oiDyEIA0AgAiAORkUEQAJAIAEgAkEBdCINai8BACIHQf//A0YEQCALIAhBA3RqIAI2AgQgCEF/aiEIQQEhBwwBCyAGQQAgDCAHQRB0QRB1ShshBgsgCiANaiAHOwEAIAJBAWohAgwBCwsgACAFNgIEIAAgBjYCACAJQQN2IAlBAXZqQQNqIQxBACEAQQAhBkEAIQIDQCAGIA5GBEADQAJAIAAgCUYNACAKIAsgAEEDdGoiASgCBCIGQQF0aiICIAIvAQAiAkEBajsBACABIAUgAhAUayIIOgADIAEgAiAIQf8BcXQgCWs7AQAgASAEIAZBAnQiAmooAgA6AAIgASACIANqKAIANgIEIABBAWohAAwBCwsFIAEgBkEBdGouAQAhDUEAIQcDQCAHIA1ORQRAIAsgAkEDdGogBjYCBANAIAIgDGogD3EiAiAISw0ACyAHQQFqIQcMAQsLIAZBAWohBgwBCwsgCkHwAGokAAsjAEIAIAEQCSAAhUKHla+vmLbem55/fkLj3MqV/M7y9YV/fAsQACAAQn43AwggACABNgIACyQBAX8gAARAIAEoAgQiAgRAIAEoAgggACACEQEADwsgABAmCwsfACAAIAEgAi8BABAINgIAIAEQBBogACACQQRqNgIEC0oBAX9BoCAoAgAiASAAaiIAQX9MBEBBiCBBMDYCAEF/DwsCQCAAPwBBEHRNDQAgABBmDQBBiCBBMDYCAEF/DwtBoCAgADYCACABC9cBAQh/Qbp/IQoCQCACKAIEIgggAigCACIJaiIOIAEgAGtLDQBBbCEKIAkgBCADKAIAIgtrSw0AIAAgCWoiBCACKAIIIgxrIQ0gACABQWBqIg8gCyAJQQAQKSADIAkgC2o2AgACQAJAIAwgBCAFa00EQCANIQUMAQsgDCAEIAZrSw0CIAcgDSAFayIAaiIBIAhqIAdNBEAgBCABIAgQDxoMAgsgBCABQQAgAGsQDyEBIAIgACAIaiIINgIEIAEgAGshBAsgBCAPIAUgCEEBECkLIA4hCgsgCgubAgEBfyMAQYABayINJAAgDSADNgJ8AkAgAkEDSwRAQX8hCQwBCwJAAkACQAJAIAJBAWsOAwADAgELIAZFBEBBuH8hCQwEC0FsIQkgBS0AACICIANLDQMgACAHIAJBAnQiAmooAgAgAiAIaigCABA7IAEgADYCAEEBIQkMAwsgASAJNgIAQQAhCQwCCyAKRQRAQWwhCQwCC0EAIQkgC0UgDEEZSHINAUEIIAR0QQhqIQBBACECA0AgAiAATw0CIAJBQGshAgwAAAsAC0FsIQkgDSANQfwAaiANQfgAaiAFIAYQFSICEAMNACANKAJ4IgMgBEsNACAAIA0gDSgCfCAHIAggAxAYIAEgADYCACACIQkLIA1BgAFqJAAgCQsLACAAIAEgAhALGgsQACAALwAAIAAtAAJBEHRyCy8AAn9BuH8gAUEISQ0AGkFyIAAoAAQiAEF3Sw0AGkG4fyAAQQhqIgAgACABSxsLCwkAIAAgATsAAAsDAAELigYBBX8gACAAKAIAIgVBfnE2AgBBACAAIAVBAXZqQYQgKAIAIgQgAEYbIQECQAJAIAAoAgQiAkUNACACKAIAIgNBAXENACACQQhqIgUgA0EBdkF4aiIDQQggA0EISxtnQR9zQQJ0QYAfaiIDKAIARgRAIAMgAigCDDYCAAsgAigCCCIDBEAgAyACKAIMNgIECyACKAIMIgMEQCADIAIoAgg2AgALIAIgAigCACAAKAIAQX5xajYCAEGEICEAAkACQCABRQ0AIAEgAjYCBCABKAIAIgNBAXENASADQQF2QXhqIgNBCCADQQhLG2dBH3NBAnRBgB9qIgMoAgAgAUEIakYEQCADIAEoAgw2AgALIAEoAggiAwRAIAMgASgCDDYCBAsgASgCDCIDBEAgAyABKAIINgIAQYQgKAIAIQQLIAIgAigCACABKAIAQX5xajYCACABIARGDQAgASABKAIAQQF2akEEaiEACyAAIAI2AgALIAIoAgBBAXZBeGoiAEEIIABBCEsbZ0Efc0ECdEGAH2oiASgCACEAIAEgBTYCACACIAA2AgwgAkEANgIIIABFDQEgACAFNgIADwsCQCABRQ0AIAEoAgAiAkEBcQ0AIAJBAXZBeGoiAkEIIAJBCEsbZ0Efc0ECdEGAH2oiAigCACABQQhqRgRAIAIgASgCDDYCAAsgASgCCCICBEAgAiABKAIMNgIECyABKAIMIgIEQCACIAEoAgg2AgBBhCAoAgAhBAsgACAAKAIAIAEoAgBBfnFqIgI2AgACQCABIARHBEAgASABKAIAQQF2aiAANgIEIAAoAgAhAgwBC0GEICAANgIACyACQQF2QXhqIgFBCCABQQhLG2dBH3NBAnRBgB9qIgIoAgAhASACIABBCGoiAjYCACAAIAE2AgwgAEEANgIIIAFFDQEgASACNgIADwsgBUEBdkF4aiIBQQggAUEISxtnQR9zQQJ0QYAfaiICKAIAIQEgAiAAQQhqIgI2AgAgACABNgIMIABBADYCCCABRQ0AIAEgAjYCAAsLDgAgAARAIABBeGoQJQsLgAIBA38CQCAAQQ9qQXhxQYQgKAIAKAIAQQF2ayICEB1Bf0YNAAJAQYQgKAIAIgAoAgAiAUEBcQ0AIAFBAXZBeGoiAUEIIAFBCEsbZ0Efc0ECdEGAH2oiASgCACAAQQhqRgRAIAEgACgCDDYCAAsgACgCCCIBBEAgASAAKAIMNgIECyAAKAIMIgFFDQAgASAAKAIINgIAC0EBIQEgACAAKAIAIAJBAXRqIgI2AgAgAkEBcQ0AIAJBAXZBeGoiAkEIIAJBCEsbZ0Efc0ECdEGAH2oiAygCACECIAMgAEEIaiIDNgIAIAAgAjYCDCAAQQA2AgggAkUNACACIAM2AgALIAELtwIBA38CQAJAIABBASAAGyICEDgiAA0AAkACQEGEICgCACIARQ0AIAAoAgAiA0EBcQ0AIAAgA0EBcjYCACADQQF2QXhqIgFBCCABQQhLG2dBH3NBAnRBgB9qIgEoAgAgAEEIakYEQCABIAAoAgw2AgALIAAoAggiAQRAIAEgACgCDDYCBAsgACgCDCIBBEAgASAAKAIINgIACyACECchAkEAIQFBhCAoAgAhACACDQEgACAAKAIAQX5xNgIAQQAPCyACQQ9qQXhxIgMQHSICQX9GDQIgAkEHakF4cSIAIAJHBEAgACACaxAdQX9GDQMLAkBBhCAoAgAiAUUEQEGAICAANgIADAELIAAgATYCBAtBhCAgADYCACAAIANBAXRBAXI2AgAMAQsgAEUNAQsgAEEIaiEBCyABC7kDAQJ/IAAgA2ohBQJAIANBB0wEQANAIAAgBU8NAiAAIAItAAA6AAAgAEEBaiEAIAJBAWohAgwAAAsACyAEQQFGBEACQCAAIAJrIgZBB00EQCAAIAItAAA6AAAgACACLQABOgABIAAgAi0AAjoAAiAAIAItAAM6AAMgAEEEaiACIAZBAnQiBkHAHmooAgBqIgIQFyACIAZB4B5qKAIAayECDAELIAAgAhAMCyACQQhqIQIgAEEIaiEACwJAAkACQAJAIAUgAU0EQCAAIANqIQEgBEEBRyAAIAJrQQ9Kcg0BA0AgACACEAwgAkEIaiECIABBCGoiACABSQ0ACwwFCyAAIAFLBEAgACEBDAQLIARBAUcgACACa0EPSnINASAAIQMgAiEEA0AgAyAEEAwgBEEIaiEEIANBCGoiAyABSQ0ACwwCCwNAIAAgAhAHIAJBEGohAiAAQRBqIgAgAUkNAAsMAwsgACEDIAIhBANAIAMgBBAHIARBEGohBCADQRBqIgMgAUkNAAsLIAIgASAAa2ohAgsDQCABIAVPDQEgASACLQAAOgAAIAFBAWohASACQQFqIQIMAAALAAsLQQECfyAAIAAoArjgASIDNgLE4AEgACgCvOABIQQgACABNgK84AEgACABIAJqNgK44AEgACABIAQgA2tqNgLA4AELpgEBAX8gACAAKALs4QEQFjYCyOABIABCADcD+OABIABCADcDuOABIABBwOABakIANwMAIABBqNAAaiIBQYyAgOAANgIAIABBADYCmOIBIABCADcDiOEBIABCAzcDgOEBIABBrNABakHgEikCADcCACAAQbTQAWpB6BIoAgA2AgAgACABNgIMIAAgAEGYIGo2AgggACAAQaAwajYCBCAAIABBEGo2AgALYQEBf0G4fyEDAkAgAUEDSQ0AIAIgABAhIgFBA3YiADYCCCACIAFBAXE2AgQgAiABQQF2QQNxIgM2AgACQCADQX9qIgFBAksNAAJAIAFBAWsOAgEAAgtBbA8LIAAhAwsgAwsMACAAIAEgAkEAEC4LiAQCA38CfiADEBYhBCAAQQBBKBAQIQAgBCACSwRAIAQPCyABRQRAQX8PCwJAAkAgA0EBRg0AIAEoAAAiBkGo6r5pRg0AQXYhAyAGQXBxQdDUtMIBRw0BQQghAyACQQhJDQEgAEEAQSgQECEAIAEoAAQhASAAQQE2AhQgACABrTcDAEEADwsgASACIAMQLyIDIAJLDQAgACADNgIYQXIhAyABIARqIgVBf2otAAAiAkEIcQ0AIAJBIHEiBkUEQEFwIQMgBS0AACIFQacBSw0BIAVBB3GtQgEgBUEDdkEKaq2GIgdCA4h+IAd8IQggBEEBaiEECyACQQZ2IQMgAkECdiEFAkAgAkEDcUF/aiICQQJLBEBBACECDAELAkACQAJAIAJBAWsOAgECAAsgASAEai0AACECIARBAWohBAwCCyABIARqLwAAIQIgBEECaiEEDAELIAEgBGooAAAhAiAEQQRqIQQLIAVBAXEhBQJ+AkACQAJAIANBf2oiA0ECTQRAIANBAWsOAgIDAQtCfyAGRQ0DGiABIARqMQAADAMLIAEgBGovAACtQoACfAwCCyABIARqKAAArQwBCyABIARqKQAACyEHIAAgBTYCICAAIAI2AhwgACAHNwMAQQAhAyAAQQA2AhQgACAHIAggBhsiBzcDCCAAIAdCgIAIIAdCgIAIVBs+AhALIAMLWwEBf0G4fyEDIAIQFiICIAFNBH8gACACakF/ai0AACIAQQNxQQJ0QaAeaigCACACaiAAQQZ2IgFBAnRBsB5qKAIAaiAAQSBxIgBFaiABRSAAQQV2cWoFQbh/CwsdACAAKAKQ4gEQWiAAQQA2AqDiASAAQgA3A5DiAQu1AwEFfyMAQZACayIKJABBuH8hBgJAIAVFDQAgBCwAACIIQf8BcSEHAkAgCEF/TARAIAdBgn9qQQF2IgggBU8NAkFsIQYgB0GBf2oiBUGAAk8NAiAEQQFqIQdBACEGA0AgBiAFTwRAIAUhBiAIIQcMAwUgACAGaiAHIAZBAXZqIgQtAABBBHY6AAAgACAGQQFyaiAELQAAQQ9xOgAAIAZBAmohBgwBCwAACwALIAcgBU8NASAAIARBAWogByAKEFMiBhADDQELIAYhBEEAIQYgAUEAQTQQECEJQQAhBQNAIAQgBkcEQCAAIAZqIggtAAAiAUELSwRAQWwhBgwDBSAJIAFBAnRqIgEgASgCAEEBajYCACAGQQFqIQZBASAILQAAdEEBdSAFaiEFDAILAAsLQWwhBiAFRQ0AIAUQFEEBaiIBQQxLDQAgAyABNgIAQQFBASABdCAFayIDEBQiAXQgA0cNACAAIARqIAFBAWoiADoAACAJIABBAnRqIgAgACgCAEEBajYCACAJKAIEIgBBAkkgAEEBcXINACACIARBAWo2AgAgB0EBaiEGCyAKQZACaiQAIAYLxhEBDH8jAEHwAGsiBSQAQWwhCwJAIANBCkkNACACLwAAIQogAi8AAiEJIAIvAAQhByAFQQhqIAQQDgJAIAMgByAJIApqakEGaiIMSQ0AIAUtAAohCCAFQdgAaiACQQZqIgIgChAGIgsQAw0BIAVBQGsgAiAKaiICIAkQBiILEAMNASAFQShqIAIgCWoiAiAHEAYiCxADDQEgBUEQaiACIAdqIAMgDGsQBiILEAMNASAAIAFqIg9BfWohECAEQQRqIQZBASELIAAgAUEDakECdiIDaiIMIANqIgIgA2oiDiEDIAIhBCAMIQcDQCALIAMgEElxBEAgACAGIAVB2ABqIAgQAkECdGoiCS8BADsAACAFQdgAaiAJLQACEAEgCS0AAyELIAcgBiAFQUBrIAgQAkECdGoiCS8BADsAACAFQUBrIAktAAIQASAJLQADIQogBCAGIAVBKGogCBACQQJ0aiIJLwEAOwAAIAVBKGogCS0AAhABIAktAAMhCSADIAYgBUEQaiAIEAJBAnRqIg0vAQA7AAAgBUEQaiANLQACEAEgDS0AAyENIAAgC2oiCyAGIAVB2ABqIAgQAkECdGoiAC8BADsAACAFQdgAaiAALQACEAEgAC0AAyEAIAcgCmoiCiAGIAVBQGsgCBACQQJ0aiIHLwEAOwAAIAVBQGsgBy0AAhABIActAAMhByAEIAlqIgkgBiAFQShqIAgQAkECdGoiBC8BADsAACAFQShqIAQtAAIQASAELQADIQQgAyANaiIDIAYgBUEQaiAIEAJBAnRqIg0vAQA7AAAgBUEQaiANLQACEAEgACALaiEAIAcgCmohByAEIAlqIQQgAyANLQADaiEDIAVB2ABqEA0gBUFAaxANciAFQShqEA1yIAVBEGoQDXJFIQsMAQsLIAQgDksgByACS3INAEFsIQsgACAMSw0BIAxBfWohCQNAQQAgACAJSSAFQdgAahAEGwRAIAAgBiAFQdgAaiAIEAJBAnRqIgovAQA7AAAgBUHYAGogCi0AAhABIAAgCi0AA2oiACAGIAVB2ABqIAgQAkECdGoiCi8BADsAACAFQdgAaiAKLQACEAEgACAKLQADaiEADAEFIAxBfmohCgNAIAVB2ABqEAQgACAKS3JFBEAgACAGIAVB2ABqIAgQAkECdGoiCS8BADsAACAFQdgAaiAJLQACEAEgACAJLQADaiEADAELCwNAIAAgCk0EQCAAIAYgBUHYAGogCBACQQJ0aiIJLwEAOwAAIAVB2ABqIAktAAIQASAAIAktAANqIQAMAQsLAkAgACAMTw0AIAAgBiAFQdgAaiAIEAIiAEECdGoiDC0AADoAACAMLQADQQFGBEAgBUHYAGogDC0AAhABDAELIAUoAlxBH0sNACAFQdgAaiAGIABBAnRqLQACEAEgBSgCXEEhSQ0AIAVBIDYCXAsgAkF9aiEMA0BBACAHIAxJIAVBQGsQBBsEQCAHIAYgBUFAayAIEAJBAnRqIgAvAQA7AAAgBUFAayAALQACEAEgByAALQADaiIAIAYgBUFAayAIEAJBAnRqIgcvAQA7AAAgBUFAayAHLQACEAEgACAHLQADaiEHDAEFIAJBfmohDANAIAVBQGsQBCAHIAxLckUEQCAHIAYgBUFAayAIEAJBAnRqIgAvAQA7AAAgBUFAayAALQACEAEgByAALQADaiEHDAELCwNAIAcgDE0EQCAHIAYgBUFAayAIEAJBAnRqIgAvAQA7AAAgBUFAayAALQACEAEgByAALQADaiEHDAELCwJAIAcgAk8NACAHIAYgBUFAayAIEAIiAEECdGoiAi0AADoAACACLQADQQFGBEAgBUFAayACLQACEAEMAQsgBSgCREEfSw0AIAVBQGsgBiAAQQJ0ai0AAhABIAUoAkRBIUkNACAFQSA2AkQLIA5BfWohAgNAQQAgBCACSSAFQShqEAQbBEAgBCAGIAVBKGogCBACQQJ0aiIALwEAOwAAIAVBKGogAC0AAhABIAQgAC0AA2oiACAGIAVBKGogCBACQQJ0aiIELwEAOwAAIAVBKGogBC0AAhABIAAgBC0AA2ohBAwBBSAOQX5qIQIDQCAFQShqEAQgBCACS3JFBEAgBCAGIAVBKGogCBACQQJ0aiIALwEAOwAAIAVBKGogAC0AAhABIAQgAC0AA2ohBAwBCwsDQCAEIAJNBEAgBCAGIAVBKGogCBACQQJ0aiIALwEAOwAAIAVBKGogAC0AAhABIAQgAC0AA2ohBAwBCwsCQCAEIA5PDQAgBCAGIAVBKGogCBACIgBBAnRqIgItAAA6AAAgAi0AA0EBRgRAIAVBKGogAi0AAhABDAELIAUoAixBH0sNACAFQShqIAYgAEECdGotAAIQASAFKAIsQSFJDQAgBUEgNgIsCwNAQQAgAyAQSSAFQRBqEAQbBEAgAyAGIAVBEGogCBACQQJ0aiIALwEAOwAAIAVBEGogAC0AAhABIAMgAC0AA2oiACAGIAVBEGogCBACQQJ0aiICLwEAOwAAIAVBEGogAi0AAhABIAAgAi0AA2ohAwwBBSAPQX5qIQIDQCAFQRBqEAQgAyACS3JFBEAgAyAGIAVBEGogCBACQQJ0aiIALwEAOwAAIAVBEGogAC0AAhABIAMgAC0AA2ohAwwBCwsDQCADIAJNBEAgAyAGIAVBEGogCBACQQJ0aiIALwEAOwAAIAVBEGogAC0AAhABIAMgAC0AA2ohAwwBCwsCQCADIA9PDQAgAyAGIAVBEGogCBACIgBBAnRqIgItAAA6AAAgAi0AA0EBRgRAIAVBEGogAi0AAhABDAELIAUoAhRBH0sNACAFQRBqIAYgAEECdGotAAIQASAFKAIUQSFJDQAgBUEgNgIUCyABQWwgBUHYAGoQCiAFQUBrEApxIAVBKGoQCnEgBUEQahAKcRshCwwJCwAACwALAAALAAsAAAsACwAACwALQWwhCwsgBUHwAGokACALC7UEAQ5/IwBBEGsiBiQAIAZBBGogABAOQVQhBQJAIARB3AtJDQAgBi0ABCEHIANB8ARqQQBB7AAQECEIIAdBDEsNACADQdwJaiIJIAggBkEIaiAGQQxqIAEgAhAxIhAQA0UEQCAGKAIMIgQgB0sNASADQdwFaiEPIANBpAVqIREgAEEEaiESIANBqAVqIQEgBCEFA0AgBSICQX9qIQUgCCACQQJ0aigCAEUNAAsgAkEBaiEOQQEhBQNAIAUgDk9FBEAgCCAFQQJ0IgtqKAIAIQwgASALaiAKNgIAIAVBAWohBSAKIAxqIQoMAQsLIAEgCjYCAEEAIQUgBigCCCELA0AgBSALRkUEQCABIAUgCWotAAAiDEECdGoiDSANKAIAIg1BAWo2AgAgDyANQQF0aiINIAw6AAEgDSAFOgAAIAVBAWohBQwBCwtBACEBIANBADYCqAUgBEF/cyAHaiEJQQEhBQNAIAUgDk9FBEAgCCAFQQJ0IgtqKAIAIQwgAyALaiABNgIAIAwgBSAJanQgAWohASAFQQFqIQUMAQsLIAcgBEEBaiIBIAJrIgRrQQFqIQgDQEEBIQUgBCAIT0UEQANAIAUgDk9FBEAgBUECdCIJIAMgBEE0bGpqIAMgCWooAgAgBHY2AgAgBUEBaiEFDAELCyAEQQFqIQQMAQsLIBIgByAPIAogESADIAIgARBkIAZBAToABSAGIAc6AAYgACAGKAIENgIACyAQIQULIAZBEGokACAFC8ENAQt/IwBB8ABrIgUkAEFsIQkCQCADQQpJDQAgAi8AACEKIAIvAAIhDCACLwAEIQYgBUEIaiAEEA4CQCADIAYgCiAMampBBmoiDUkNACAFLQAKIQcgBUHYAGogAkEGaiICIAoQBiIJEAMNASAFQUBrIAIgCmoiAiAMEAYiCRADDQEgBUEoaiACIAxqIgIgBhAGIgkQAw0BIAVBEGogAiAGaiADIA1rEAYiCRADDQEgACABaiIOQX1qIQ8gBEEEaiEGQQEhCSAAIAFBA2pBAnYiAmoiCiACaiIMIAJqIg0hAyAMIQQgCiECA0AgCSADIA9JcQRAIAYgBUHYAGogBxACQQF0aiIILQAAIQsgBUHYAGogCC0AARABIAAgCzoAACAGIAVBQGsgBxACQQF0aiIILQAAIQsgBUFAayAILQABEAEgAiALOgAAIAYgBUEoaiAHEAJBAXRqIggtAAAhCyAFQShqIAgtAAEQASAEIAs6AAAgBiAFQRBqIAcQAkEBdGoiCC0AACELIAVBEGogCC0AARABIAMgCzoAACAGIAVB2ABqIAcQAkEBdGoiCC0AACELIAVB2ABqIAgtAAEQASAAIAs6AAEgBiAFQUBrIAcQAkEBdGoiCC0AACELIAVBQGsgCC0AARABIAIgCzoAASAGIAVBKGogBxACQQF0aiIILQAAIQsgBUEoaiAILQABEAEgBCALOgABIAYgBUEQaiAHEAJBAXRqIggtAAAhCyAFQRBqIAgtAAEQASADIAs6AAEgA0ECaiEDIARBAmohBCACQQJqIQIgAEECaiEAIAkgBUHYAGoQDUVxIAVBQGsQDUVxIAVBKGoQDUVxIAVBEGoQDUVxIQkMAQsLIAQgDUsgAiAMS3INAEFsIQkgACAKSw0BIApBfWohCQNAIAVB2ABqEAQgACAJT3JFBEAgBiAFQdgAaiAHEAJBAXRqIggtAAAhCyAFQdgAaiAILQABEAEgACALOgAAIAYgBUHYAGogBxACQQF0aiIILQAAIQsgBUHYAGogCC0AARABIAAgCzoAASAAQQJqIQAMAQsLA0AgBUHYAGoQBCAAIApPckUEQCAGIAVB2ABqIAcQAkEBdGoiCS0AACEIIAVB2ABqIAktAAEQASAAIAg6AAAgAEEBaiEADAELCwNAIAAgCkkEQCAGIAVB2ABqIAcQAkEBdGoiCS0AACEIIAVB2ABqIAktAAEQASAAIAg6AAAgAEEBaiEADAELCyAMQX1qIQADQCAFQUBrEAQgAiAAT3JFBEAgBiAFQUBrIAcQAkEBdGoiCi0AACEJIAVBQGsgCi0AARABIAIgCToAACAGIAVBQGsgBxACQQF0aiIKLQAAIQkgBUFAayAKLQABEAEgAiAJOgABIAJBAmohAgwBCwsDQCAFQUBrEAQgAiAMT3JFBEAgBiAFQUBrIAcQAkEBdGoiAC0AACEKIAVBQGsgAC0AARABIAIgCjoAACACQQFqIQIMAQsLA0AgAiAMSQRAIAYgBUFAayAHEAJBAXRqIgAtAAAhCiAFQUBrIAAtAAEQASACIAo6AAAgAkEBaiECDAELCyANQX1qIQADQCAFQShqEAQgBCAAT3JFBEAgBiAFQShqIAcQAkEBdGoiAi0AACEKIAVBKGogAi0AARABIAQgCjoAACAGIAVBKGogBxACQQF0aiICLQAAIQogBUEoaiACLQABEAEgBCAKOgABIARBAmohBAwBCwsDQCAFQShqEAQgBCANT3JFBEAgBiAFQShqIAcQAkEBdGoiAC0AACECIAVBKGogAC0AARABIAQgAjoAACAEQQFqIQQMAQsLA0AgBCANSQRAIAYgBUEoaiAHEAJBAXRqIgAtAAAhAiAFQShqIAAtAAEQASAEIAI6AAAgBEEBaiEEDAELCwNAIAVBEGoQBCADIA9PckUEQCAGIAVBEGogBxACQQF0aiIALQAAIQIgBUEQaiAALQABEAEgAyACOgAAIAYgBUEQaiAHEAJBAXRqIgAtAAAhAiAFQRBqIAAtAAEQASADIAI6AAEgA0ECaiEDDAELCwNAIAVBEGoQBCADIA5PckUEQCAGIAVBEGogBxACQQF0aiIALQAAIQIgBUEQaiAALQABEAEgAyACOgAAIANBAWohAwwBCwsDQCADIA5JBEAgBiAFQRBqIAcQAkEBdGoiAC0AACECIAVBEGogAC0AARABIAMgAjoAACADQQFqIQMMAQsLIAFBbCAFQdgAahAKIAVBQGsQCnEgBUEoahAKcSAFQRBqEApxGyEJDAELQWwhCQsgBUHwAGokACAJC8oCAQR/IwBBIGsiBSQAIAUgBBAOIAUtAAIhByAFQQhqIAIgAxAGIgIQA0UEQCAEQQRqIQIgACABaiIDQX1qIQQDQCAFQQhqEAQgACAET3JFBEAgAiAFQQhqIAcQAkEBdGoiBi0AACEIIAVBCGogBi0AARABIAAgCDoAACACIAVBCGogBxACQQF0aiIGLQAAIQggBUEIaiAGLQABEAEgACAIOgABIABBAmohAAwBCwsDQCAFQQhqEAQgACADT3JFBEAgAiAFQQhqIAcQAkEBdGoiBC0AACEGIAVBCGogBC0AARABIAAgBjoAACAAQQFqIQAMAQsLA0AgACADT0UEQCACIAVBCGogBxACQQF0aiIELQAAIQYgBUEIaiAELQABEAEgACAGOgAAIABBAWohAAwBCwsgAUFsIAVBCGoQChshAgsgBUEgaiQAIAILtgMBCX8jAEEQayIGJAAgBkEANgIMIAZBADYCCEFUIQQCQAJAIANBQGsiDCADIAZBCGogBkEMaiABIAIQMSICEAMNACAGQQRqIAAQDiAGKAIMIgcgBi0ABEEBaksNASAAQQRqIQogBkEAOgAFIAYgBzoABiAAIAYoAgQ2AgAgB0EBaiEJQQEhBANAIAQgCUkEQCADIARBAnRqIgEoAgAhACABIAU2AgAgACAEQX9qdCAFaiEFIARBAWohBAwBCwsgB0EBaiEHQQAhBSAGKAIIIQkDQCAFIAlGDQEgAyAFIAxqLQAAIgRBAnRqIgBBASAEdEEBdSILIAAoAgAiAWoiADYCACAHIARrIQhBACEEAkAgC0EDTQRAA0AgBCALRg0CIAogASAEakEBdGoiACAIOgABIAAgBToAACAEQQFqIQQMAAALAAsDQCABIABPDQEgCiABQQF0aiIEIAg6AAEgBCAFOgAAIAQgCDoAAyAEIAU6AAIgBCAIOgAFIAQgBToABCAEIAg6AAcgBCAFOgAGIAFBBGohAQwAAAsACyAFQQFqIQUMAAALAAsgAiEECyAGQRBqJAAgBAutAQECfwJAQYQgKAIAIABHIAAoAgBBAXYiAyABa0F4aiICQXhxQQhHcgR/IAIFIAMQJ0UNASACQQhqC0EQSQ0AIAAgACgCACICQQFxIAAgAWpBD2pBeHEiASAAa0EBdHI2AgAgASAANgIEIAEgASgCAEEBcSAAIAJBAXZqIAFrIgJBAXRyNgIAQYQgIAEgAkH/////B3FqQQRqQYQgKAIAIABGGyABNgIAIAEQJQsLygIBBX8CQAJAAkAgAEEIIABBCEsbZ0EfcyAAaUEBR2oiAUEESSAAIAF2cg0AIAFBAnRB/B5qKAIAIgJFDQADQCACQXhqIgMoAgBBAXZBeGoiBSAATwRAIAIgBUEIIAVBCEsbZ0Efc0ECdEGAH2oiASgCAEYEQCABIAIoAgQ2AgALDAMLIARBHksNASAEQQFqIQQgAigCBCICDQALC0EAIQMgAUEgTw0BA0AgAUECdEGAH2ooAgAiAkUEQCABQR5LIQIgAUEBaiEBIAJFDQEMAwsLIAIgAkF4aiIDKAIAQQF2QXhqIgFBCCABQQhLG2dBH3NBAnRBgB9qIgEoAgBGBEAgASACKAIENgIACwsgAigCACIBBEAgASACKAIENgIECyACKAIEIgEEQCABIAIoAgA2AgALIAMgAygCAEEBcjYCACADIAAQNwsgAwvhCwINfwV+IwBB8ABrIgckACAHIAAoAvDhASIINgJcIAEgAmohDSAIIAAoAoDiAWohDwJAAkAgBUUEQCABIQQMAQsgACgCxOABIRAgACgCwOABIREgACgCvOABIQ4gAEEBNgKM4QFBACEIA0AgCEEDRwRAIAcgCEECdCICaiAAIAJqQazQAWooAgA2AkQgCEEBaiEIDAELC0FsIQwgB0EYaiADIAQQBhADDQEgB0EsaiAHQRhqIAAoAgAQEyAHQTRqIAdBGGogACgCCBATIAdBPGogB0EYaiAAKAIEEBMgDUFgaiESIAEhBEEAIQwDQCAHKAIwIAcoAixBA3RqKQIAIhRCEIinQf8BcSEIIAcoAkAgBygCPEEDdGopAgAiFUIQiKdB/wFxIQsgBygCOCAHKAI0QQN0aikCACIWQiCIpyEJIBVCIIghFyAUQiCIpyECAkAgFkIQiKdB/wFxIgNBAk8EQAJAIAZFIANBGUlyRQRAIAkgB0EYaiADQSAgBygCHGsiCiAKIANLGyIKEAUgAyAKayIDdGohCSAHQRhqEAQaIANFDQEgB0EYaiADEAUgCWohCQwBCyAHQRhqIAMQBSAJaiEJIAdBGGoQBBoLIAcpAkQhGCAHIAk2AkQgByAYNwNIDAELAkAgA0UEQCACBEAgBygCRCEJDAMLIAcoAkghCQwBCwJAAkAgB0EYakEBEAUgCSACRWpqIgNBA0YEQCAHKAJEQX9qIgMgA0VqIQkMAQsgA0ECdCAHaigCRCIJIAlFaiEJIANBAUYNAQsgByAHKAJINgJMCwsgByAHKAJENgJIIAcgCTYCRAsgF6chAyALBEAgB0EYaiALEAUgA2ohAwsgCCALakEUTwRAIAdBGGoQBBoLIAgEQCAHQRhqIAgQBSACaiECCyAHQRhqEAQaIAcgB0EYaiAUQhiIp0H/AXEQCCAUp0H//wNxajYCLCAHIAdBGGogFUIYiKdB/wFxEAggFadB//8DcWo2AjwgB0EYahAEGiAHIAdBGGogFkIYiKdB/wFxEAggFqdB//8DcWo2AjQgByACNgJgIAcoAlwhCiAHIAk2AmggByADNgJkAkACQAJAIAQgAiADaiILaiASSw0AIAIgCmoiEyAPSw0AIA0gBGsgC0Egak8NAQsgByAHKQNoNwMQIAcgBykDYDcDCCAEIA0gB0EIaiAHQdwAaiAPIA4gESAQEB4hCwwBCyACIARqIQggBCAKEAcgAkERTwRAIARBEGohAgNAIAIgCkEQaiIKEAcgAkEQaiICIAhJDQALCyAIIAlrIQIgByATNgJcIAkgCCAOa0sEQCAJIAggEWtLBEBBbCELDAILIBAgAiAOayICaiIKIANqIBBNBEAgCCAKIAMQDxoMAgsgCCAKQQAgAmsQDyEIIAcgAiADaiIDNgJkIAggAmshCCAOIQILIAlBEE8EQCADIAhqIQMDQCAIIAIQByACQRBqIQIgCEEQaiIIIANJDQALDAELAkAgCUEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgCUECdCIDQcAeaigCAGoiAhAXIAIgA0HgHmooAgBrIQIgBygCZCEDDAELIAggAhAMCyADQQlJDQAgAyAIaiEDIAhBCGoiCCACQQhqIgJrQQ9MBEADQCAIIAIQDCACQQhqIQIgCEEIaiIIIANJDQAMAgALAAsDQCAIIAIQByACQRBqIQIgCEEQaiIIIANJDQALCyAHQRhqEAQaIAsgDCALEAMiAhshDCAEIAQgC2ogAhshBCAFQX9qIgUNAAsgDBADDQFBbCEMIAdBGGoQBEECSQ0BQQAhCANAIAhBA0cEQCAAIAhBAnQiAmpBrNABaiACIAdqKAJENgIAIAhBAWohCAwBCwsgBygCXCEIC0G6fyEMIA8gCGsiACANIARrSw0AIAQEfyAEIAggABALIABqBUEACyABayEMCyAHQfAAaiQAIAwLkRcCFn8FfiMAQdABayIHJAAgByAAKALw4QEiCDYCvAEgASACaiESIAggACgCgOIBaiETAkACQCAFRQRAIAEhAwwBCyAAKALE4AEhESAAKALA4AEhFSAAKAK84AEhDyAAQQE2AozhAUEAIQgDQCAIQQNHBEAgByAIQQJ0IgJqIAAgAmpBrNABaigCADYCVCAIQQFqIQgMAQsLIAcgETYCZCAHIA82AmAgByABIA9rNgJoQWwhECAHQShqIAMgBBAGEAMNASAFQQQgBUEESBshFyAHQTxqIAdBKGogACgCABATIAdBxABqIAdBKGogACgCCBATIAdBzABqIAdBKGogACgCBBATQQAhBCAHQeAAaiEMIAdB5ABqIQoDQCAHQShqEARBAksgBCAXTnJFBEAgBygCQCAHKAI8QQN0aikCACIdQhCIp0H/AXEhCyAHKAJQIAcoAkxBA3RqKQIAIh5CEIinQf8BcSEJIAcoAkggBygCREEDdGopAgAiH0IgiKchCCAeQiCIISAgHUIgiKchAgJAIB9CEIinQf8BcSIDQQJPBEACQCAGRSADQRlJckUEQCAIIAdBKGogA0EgIAcoAixrIg0gDSADSxsiDRAFIAMgDWsiA3RqIQggB0EoahAEGiADRQ0BIAdBKGogAxAFIAhqIQgMAQsgB0EoaiADEAUgCGohCCAHQShqEAQaCyAHKQJUISEgByAINgJUIAcgITcDWAwBCwJAIANFBEAgAgRAIAcoAlQhCAwDCyAHKAJYIQgMAQsCQAJAIAdBKGpBARAFIAggAkVqaiIDQQNGBEAgBygCVEF/aiIDIANFaiEIDAELIANBAnQgB2ooAlQiCCAIRWohCCADQQFGDQELIAcgBygCWDYCXAsLIAcgBygCVDYCWCAHIAg2AlQLICCnIQMgCQRAIAdBKGogCRAFIANqIQMLIAkgC2pBFE8EQCAHQShqEAQaCyALBEAgB0EoaiALEAUgAmohAgsgB0EoahAEGiAHIAcoAmggAmoiCSADajYCaCAKIAwgCCAJSxsoAgAhDSAHIAdBKGogHUIYiKdB/wFxEAggHadB//8DcWo2AjwgByAHQShqIB5CGIinQf8BcRAIIB6nQf//A3FqNgJMIAdBKGoQBBogB0EoaiAfQhiIp0H/AXEQCCEOIAdB8ABqIARBBHRqIgsgCSANaiAIazYCDCALIAg2AgggCyADNgIEIAsgAjYCACAHIA4gH6dB//8DcWo2AkQgBEEBaiEEDAELCyAEIBdIDQEgEkFgaiEYIAdB4ABqIRogB0HkAGohGyABIQMDQCAHQShqEARBAksgBCAFTnJFBEAgBygCQCAHKAI8QQN0aikCACIdQhCIp0H/AXEhCyAHKAJQIAcoAkxBA3RqKQIAIh5CEIinQf8BcSEIIAcoAkggBygCREEDdGopAgAiH0IgiKchCSAeQiCIISAgHUIgiKchDAJAIB9CEIinQf8BcSICQQJPBEACQCAGRSACQRlJckUEQCAJIAdBKGogAkEgIAcoAixrIgogCiACSxsiChAFIAIgCmsiAnRqIQkgB0EoahAEGiACRQ0BIAdBKGogAhAFIAlqIQkMAQsgB0EoaiACEAUgCWohCSAHQShqEAQaCyAHKQJUISEgByAJNgJUIAcgITcDWAwBCwJAIAJFBEAgDARAIAcoAlQhCQwDCyAHKAJYIQkMAQsCQAJAIAdBKGpBARAFIAkgDEVqaiICQQNGBEAgBygCVEF/aiICIAJFaiEJDAELIAJBAnQgB2ooAlQiCSAJRWohCSACQQFGDQELIAcgBygCWDYCXAsLIAcgBygCVDYCWCAHIAk2AlQLICCnIRQgCARAIAdBKGogCBAFIBRqIRQLIAggC2pBFE8EQCAHQShqEAQaCyALBEAgB0EoaiALEAUgDGohDAsgB0EoahAEGiAHIAcoAmggDGoiGSAUajYCaCAbIBogCSAZSxsoAgAhHCAHIAdBKGogHUIYiKdB/wFxEAggHadB//8DcWo2AjwgByAHQShqIB5CGIinQf8BcRAIIB6nQf//A3FqNgJMIAdBKGoQBBogByAHQShqIB9CGIinQf8BcRAIIB+nQf//A3FqNgJEIAcgB0HwAGogBEEDcUEEdGoiDSkDCCIdNwPIASAHIA0pAwAiHjcDwAECQAJAAkAgBygCvAEiDiAepyICaiIWIBNLDQAgAyAHKALEASIKIAJqIgtqIBhLDQAgEiADayALQSBqTw0BCyAHIAcpA8gBNwMQIAcgBykDwAE3AwggAyASIAdBCGogB0G8AWogEyAPIBUgERAeIQsMAQsgAiADaiEIIAMgDhAHIAJBEU8EQCADQRBqIQIDQCACIA5BEGoiDhAHIAJBEGoiAiAISQ0ACwsgCCAdpyIOayECIAcgFjYCvAEgDiAIIA9rSwRAIA4gCCAVa0sEQEFsIQsMAgsgESACIA9rIgJqIhYgCmogEU0EQCAIIBYgChAPGgwCCyAIIBZBACACaxAPIQggByACIApqIgo2AsQBIAggAmshCCAPIQILIA5BEE8EQCAIIApqIQoDQCAIIAIQByACQRBqIQIgCEEQaiIIIApJDQALDAELAkAgDkEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgDkECdCIKQcAeaigCAGoiAhAXIAIgCkHgHmooAgBrIQIgBygCxAEhCgwBCyAIIAIQDAsgCkEJSQ0AIAggCmohCiAIQQhqIgggAkEIaiICa0EPTARAA0AgCCACEAwgAkEIaiECIAhBCGoiCCAKSQ0ADAIACwALA0AgCCACEAcgAkEQaiECIAhBEGoiCCAKSQ0ACwsgCxADBEAgCyEQDAQFIA0gDDYCACANIBkgHGogCWs2AgwgDSAJNgIIIA0gFDYCBCAEQQFqIQQgAyALaiEDDAILAAsLIAQgBUgNASAEIBdrIQtBACEEA0AgCyAFSARAIAcgB0HwAGogC0EDcUEEdGoiAikDCCIdNwPIASAHIAIpAwAiHjcDwAECQAJAAkAgBygCvAEiDCAepyICaiIKIBNLDQAgAyAHKALEASIJIAJqIhBqIBhLDQAgEiADayAQQSBqTw0BCyAHIAcpA8gBNwMgIAcgBykDwAE3AxggAyASIAdBGGogB0G8AWogEyAPIBUgERAeIRAMAQsgAiADaiEIIAMgDBAHIAJBEU8EQCADQRBqIQIDQCACIAxBEGoiDBAHIAJBEGoiAiAISQ0ACwsgCCAdpyIGayECIAcgCjYCvAEgBiAIIA9rSwRAIAYgCCAVa0sEQEFsIRAMAgsgESACIA9rIgJqIgwgCWogEU0EQCAIIAwgCRAPGgwCCyAIIAxBACACaxAPIQggByACIAlqIgk2AsQBIAggAmshCCAPIQILIAZBEE8EQCAIIAlqIQYDQCAIIAIQByACQRBqIQIgCEEQaiIIIAZJDQALDAELAkAgBkEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgBkECdCIGQcAeaigCAGoiAhAXIAIgBkHgHmooAgBrIQIgBygCxAEhCQwBCyAIIAIQDAsgCUEJSQ0AIAggCWohBiAIQQhqIgggAkEIaiICa0EPTARAA0AgCCACEAwgAkEIaiECIAhBCGoiCCAGSQ0ADAIACwALA0AgCCACEAcgAkEQaiECIAhBEGoiCCAGSQ0ACwsgEBADDQMgC0EBaiELIAMgEGohAwwBCwsDQCAEQQNHBEAgACAEQQJ0IgJqQazQAWogAiAHaigCVDYCACAEQQFqIQQMAQsLIAcoArwBIQgLQbp/IRAgEyAIayIAIBIgA2tLDQAgAwR/IAMgCCAAEAsgAGoFQQALIAFrIRALIAdB0AFqJAAgEAslACAAQgA3AgAgAEEAOwEIIABBADoACyAAIAE2AgwgACACOgAKC7QFAQN/IwBBMGsiBCQAIABB/wFqIgVBfWohBgJAIAMvAQIEQCAEQRhqIAEgAhAGIgIQAw0BIARBEGogBEEYaiADEBwgBEEIaiAEQRhqIAMQHCAAIQMDQAJAIARBGGoQBCADIAZPckUEQCADIARBEGogBEEYahASOgAAIAMgBEEIaiAEQRhqEBI6AAEgBEEYahAERQ0BIANBAmohAwsgBUF+aiEFAn8DQEG6fyECIAMiASAFSw0FIAEgBEEQaiAEQRhqEBI6AAAgAUEBaiEDIARBGGoQBEEDRgRAQQIhAiAEQQhqDAILIAMgBUsNBSABIARBCGogBEEYahASOgABIAFBAmohA0EDIQIgBEEYahAEQQNHDQALIARBEGoLIQUgAyAFIARBGGoQEjoAACABIAJqIABrIQIMAwsgAyAEQRBqIARBGGoQEjoAAiADIARBCGogBEEYahASOgADIANBBGohAwwAAAsACyAEQRhqIAEgAhAGIgIQAw0AIARBEGogBEEYaiADEBwgBEEIaiAEQRhqIAMQHCAAIQMDQAJAIARBGGoQBCADIAZPckUEQCADIARBEGogBEEYahAROgAAIAMgBEEIaiAEQRhqEBE6AAEgBEEYahAERQ0BIANBAmohAwsgBUF+aiEFAn8DQEG6fyECIAMiASAFSw0EIAEgBEEQaiAEQRhqEBE6AAAgAUEBaiEDIARBGGoQBEEDRgRAQQIhAiAEQQhqDAILIAMgBUsNBCABIARBCGogBEEYahAROgABIAFBAmohA0EDIQIgBEEYahAEQQNHDQALIARBEGoLIQUgAyAFIARBGGoQEToAACABIAJqIABrIQIMAgsgAyAEQRBqIARBGGoQEToAAiADIARBCGogBEEYahAROgADIANBBGohAwwAAAsACyAEQTBqJAAgAgtpAQF/An8CQAJAIAJBB00NACABKAAAQbfIwuF+Rw0AIAAgASgABDYCmOIBQWIgAEEQaiABIAIQPiIDEAMNAhogAEKBgICAEDcDiOEBIAAgASADaiACIANrECoMAQsgACABIAIQKgtBAAsLrQMBBn8jAEGAAWsiAyQAQWIhCAJAIAJBCUkNACAAQZjQAGogAUEIaiIEIAJBeGogAEGY0AAQMyIFEAMiBg0AIANBHzYCfCADIANB/ABqIANB+ABqIAQgBCAFaiAGGyIEIAEgAmoiAiAEaxAVIgUQAw0AIAMoAnwiBkEfSw0AIAMoAngiB0EJTw0AIABBiCBqIAMgBkGAC0GADCAHEBggA0E0NgJ8IAMgA0H8AGogA0H4AGogBCAFaiIEIAIgBGsQFSIFEAMNACADKAJ8IgZBNEsNACADKAJ4IgdBCk8NACAAQZAwaiADIAZBgA1B4A4gBxAYIANBIzYCfCADIANB/ABqIANB+ABqIAQgBWoiBCACIARrEBUiBRADDQAgAygCfCIGQSNLDQAgAygCeCIHQQpPDQAgACADIAZBwBBB0BEgBxAYIAQgBWoiBEEMaiIFIAJLDQAgAiAFayEFQQAhAgNAIAJBA0cEQCAEKAAAIgZBf2ogBU8NAiAAIAJBAnRqQZzQAWogBjYCACACQQFqIQIgBEEEaiEEDAELCyAEIAFrIQgLIANBgAFqJAAgCAtGAQN/IABBCGohAyAAKAIEIQJBACEAA0AgACACdkUEQCABIAMgAEEDdGotAAJBFktqIQEgAEEBaiEADAELCyABQQggAmt0C4YDAQV/Qbh/IQcCQCADRQ0AIAItAAAiBEUEQCABQQA2AgBBAUG4fyADQQFGGw8LAn8gAkEBaiIFIARBGHRBGHUiBkF/Sg0AGiAGQX9GBEAgA0EDSA0CIAUvAABBgP4BaiEEIAJBA2oMAQsgA0ECSA0BIAItAAEgBEEIdHJBgIB+aiEEIAJBAmoLIQUgASAENgIAIAVBAWoiASACIANqIgNLDQBBbCEHIABBEGogACAFLQAAIgVBBnZBI0EJIAEgAyABa0HAEEHQEUHwEiAAKAKM4QEgACgCnOIBIAQQHyIGEAMiCA0AIABBmCBqIABBCGogBUEEdkEDcUEfQQggASABIAZqIAgbIgEgAyABa0GAC0GADEGAFyAAKAKM4QEgACgCnOIBIAQQHyIGEAMiCA0AIABBoDBqIABBBGogBUECdkEDcUE0QQkgASABIAZqIAgbIgEgAyABa0GADUHgDkGQGSAAKAKM4QEgACgCnOIBIAQQHyIAEAMNACAAIAFqIAJrIQcLIAcLrQMBCn8jAEGABGsiCCQAAn9BUiACQf8BSw0AGkFUIANBDEsNABogAkEBaiELIABBBGohCUGAgAQgA0F/anRBEHUhCkEAIQJBASEEQQEgA3QiB0F/aiIMIQUDQCACIAtGRQRAAkAgASACQQF0Ig1qLwEAIgZB//8DRgRAIAkgBUECdGogAjoAAiAFQX9qIQVBASEGDAELIARBACAKIAZBEHRBEHVKGyEECyAIIA1qIAY7AQAgAkEBaiECDAELCyAAIAQ7AQIgACADOwEAIAdBA3YgB0EBdmpBA2ohBkEAIQRBACECA0AgBCALRkUEQCABIARBAXRqLgEAIQpBACEAA0AgACAKTkUEQCAJIAJBAnRqIAQ6AAIDQCACIAZqIAxxIgIgBUsNAAsgAEEBaiEADAELCyAEQQFqIQQMAQsLQX8gAg0AGkEAIQIDfyACIAdGBH9BAAUgCCAJIAJBAnRqIgAtAAJBAXRqIgEgAS8BACIBQQFqOwEAIAAgAyABEBRrIgU6AAMgACABIAVB/wFxdCAHazsBACACQQFqIQIMAQsLCyEFIAhBgARqJAAgBQvjBgEIf0FsIQcCQCACQQNJDQACQAJAAkACQCABLQAAIgNBA3EiCUEBaw4DAwEAAgsgACgCiOEBDQBBYg8LIAJBBUkNAkEDIQYgASgAACEFAn8CQAJAIANBAnZBA3EiCEF+aiIEQQFNBEAgBEEBaw0BDAILIAVBDnZB/wdxIQQgBUEEdkH/B3EhAyAIRQwCCyAFQRJ2IQRBBCEGIAVBBHZB//8AcSEDQQAMAQsgBUEEdkH//w9xIgNBgIAISw0DIAEtAARBCnQgBUEWdnIhBEEFIQZBAAshBSAEIAZqIgogAksNAgJAIANBgQZJDQAgACgCnOIBRQ0AQQAhAgNAIAJBg4ABSw0BIAJBQGshAgwAAAsACwJ/IAlBA0YEQCABIAZqIQEgAEHw4gFqIQIgACgCDCEGIAUEQCACIAMgASAEIAYQXwwCCyACIAMgASAEIAYQXQwBCyAAQbjQAWohAiABIAZqIQEgAEHw4gFqIQYgAEGo0ABqIQggBQRAIAggBiADIAEgBCACEF4MAQsgCCAGIAMgASAEIAIQXAsQAw0CIAAgAzYCgOIBIABBATYCiOEBIAAgAEHw4gFqNgLw4QEgCUECRgRAIAAgAEGo0ABqNgIMCyAAIANqIgBBiOMBakIANwAAIABBgOMBakIANwAAIABB+OIBakIANwAAIABB8OIBakIANwAAIAoPCwJ/AkACQAJAIANBAnZBA3FBf2oiBEECSw0AIARBAWsOAgACAQtBASEEIANBA3YMAgtBAiEEIAEvAABBBHYMAQtBAyEEIAEQIUEEdgsiAyAEaiIFQSBqIAJLBEAgBSACSw0CIABB8OIBaiABIARqIAMQCyEBIAAgAzYCgOIBIAAgATYC8OEBIAEgA2oiAEIANwAYIABCADcAECAAQgA3AAggAEIANwAAIAUPCyAAIAM2AoDiASAAIAEgBGo2AvDhASAFDwsCfwJAAkACQCADQQJ2QQNxQX9qIgRBAksNACAEQQFrDgIAAgELQQEhByADQQN2DAILQQIhByABLwAAQQR2DAELIAJBBEkgARAhIgJBj4CAAUtyDQFBAyEHIAJBBHYLIQIgAEHw4gFqIAEgB2otAAAgAkEgahAQIQEgACACNgKA4gEgACABNgLw4QEgB0EBaiEHCyAHC0sAIABC+erQ0OfJoeThADcDICAAQgA3AxggAELP1tO+0ser2UI3AxAgAELW64Lu6v2J9eAANwMIIABCADcDACAAQShqQQBBKBAQGgviAgICfwV+IABBKGoiASAAKAJIaiECAn4gACkDACIDQiBaBEAgACkDECIEQgeJIAApAwgiBUIBiXwgACkDGCIGQgyJfCAAKQMgIgdCEol8IAUQGSAEEBkgBhAZIAcQGQwBCyAAKQMYQsXP2bLx5brqJ3wLIAN8IQMDQCABQQhqIgAgAk0EQEIAIAEpAAAQCSADhUIbiUKHla+vmLbem55/fkLj3MqV/M7y9YV/fCEDIAAhAQwBCwsCQCABQQRqIgAgAksEQCABIQAMAQsgASgAAK1Ch5Wvr5i23puef34gA4VCF4lCz9bTvtLHq9lCfkL5893xmfaZqxZ8IQMLA0AgACACSQRAIAAxAABCxc/ZsvHluuonfiADhUILiUKHla+vmLbem55/fiEDIABBAWohAAwBCwsgA0IhiCADhULP1tO+0ser2UJ+IgNCHYggA4VC+fPd8Zn2masWfiIDQiCIIAOFC+8CAgJ/BH4gACAAKQMAIAKtfDcDAAJAAkAgACgCSCIDIAJqIgRBH00EQCABRQ0BIAAgA2pBKGogASACECAgACgCSCACaiEEDAELIAEgAmohAgJ/IAMEQCAAQShqIgQgA2ogAUEgIANrECAgACAAKQMIIAQpAAAQCTcDCCAAIAApAxAgACkAMBAJNwMQIAAgACkDGCAAKQA4EAk3AxggACAAKQMgIABBQGspAAAQCTcDICAAKAJIIQMgAEEANgJIIAEgA2tBIGohAQsgAUEgaiACTQsEQCACQWBqIQMgACkDICEFIAApAxghBiAAKQMQIQcgACkDCCEIA0AgCCABKQAAEAkhCCAHIAEpAAgQCSEHIAYgASkAEBAJIQYgBSABKQAYEAkhBSABQSBqIgEgA00NAAsgACAFNwMgIAAgBjcDGCAAIAc3AxAgACAINwMICyABIAJPDQEgAEEoaiABIAIgAWsiBBAgCyAAIAQ2AkgLCy8BAX8gAEUEQEG2f0EAIAMbDwtBun8hBCADIAFNBH8gACACIAMQEBogAwVBun8LCy8BAX8gAEUEQEG2f0EAIAMbDwtBun8hBCADIAFNBH8gACACIAMQCxogAwVBun8LC6gCAQZ/IwBBEGsiByQAIABB2OABaikDAEKAgIAQViEIQbh/IQUCQCAEQf//B0sNACAAIAMgBBBCIgUQAyIGDQAgACgCnOIBIQkgACAHQQxqIAMgAyAFaiAGGyIKIARBACAFIAYbayIGEEAiAxADBEAgAyEFDAELIAcoAgwhBCABRQRAQbp/IQUgBEEASg0BCyAGIANrIQUgAyAKaiEDAkAgCQRAIABBADYCnOIBDAELAkACQAJAIARBBUgNACAAQdjgAWopAwBCgICACFgNAAwBCyAAQQA2ApziAQwBCyAAKAIIED8hBiAAQQA2ApziASAGQRRPDQELIAAgASACIAMgBSAEIAgQOSEFDAELIAAgASACIAMgBSAEIAgQOiEFCyAHQRBqJAAgBQtnACAAQdDgAWogASACIAAoAuzhARAuIgEQAwRAIAEPC0G4fyECAkAgAQ0AIABB7OABaigCACIBBEBBYCECIAAoApjiASABRw0BC0EAIQIgAEHw4AFqKAIARQ0AIABBkOEBahBDCyACCycBAX8QVyIERQRAQUAPCyAEIAAgASACIAMgBBBLEE8hACAEEFYgAAs/AQF/AkACQAJAIAAoAqDiAUEBaiIBQQJLDQAgAUEBaw4CAAECCyAAEDBBAA8LIABBADYCoOIBCyAAKAKU4gELvAMCB38BfiMAQRBrIgkkAEG4fyEGAkAgBCgCACIIQQVBCSAAKALs4QEiBRtJDQAgAygCACIHQQFBBSAFGyAFEC8iBRADBEAgBSEGDAELIAggBUEDakkNACAAIAcgBRBJIgYQAw0AIAEgAmohCiAAQZDhAWohCyAIIAVrIQIgBSAHaiEHIAEhBQNAIAcgAiAJECwiBhADDQEgAkF9aiICIAZJBEBBuH8hBgwCCyAJKAIAIghBAksEQEFsIQYMAgsgB0EDaiEHAn8CQAJAAkAgCEEBaw4CAgABCyAAIAUgCiAFayAHIAYQSAwCCyAFIAogBWsgByAGEEcMAQsgBSAKIAVrIActAAAgCSgCCBBGCyIIEAMEQCAIIQYMAgsgACgC8OABBEAgCyAFIAgQRQsgAiAGayECIAYgB2ohByAFIAhqIQUgCSgCBEUNAAsgACkD0OABIgxCf1IEQEFsIQYgDCAFIAFrrFINAQsgACgC8OABBEBBaiEGIAJBBEkNASALEEQhDCAHKAAAIAynRw0BIAdBBGohByACQXxqIQILIAMgBzYCACAEIAI2AgAgBSABayEGCyAJQRBqJAAgBgsuACAAECsCf0EAQQAQAw0AGiABRSACRXJFBEBBYiAAIAEgAhA9EAMNARoLQQALCzcAIAEEQCAAIAAoAsTgASABKAIEIAEoAghqRzYCnOIBCyAAECtBABADIAFFckUEQCAAIAEQWwsL0QIBB38jAEEQayIGJAAgBiAENgIIIAYgAzYCDCAFBEAgBSgCBCEKIAUoAgghCQsgASEIAkACQANAIAAoAuzhARAWIQsCQANAIAQgC0kNASADKAAAQXBxQdDUtMIBRgRAIAMgBBAiIgcQAw0EIAQgB2shBCADIAdqIQMMAQsLIAYgAzYCDCAGIAQ2AggCQCAFBEAgACAFEE5BACEHQQAQA0UNAQwFCyAAIAogCRBNIgcQAw0ECyAAIAgQUCAMQQFHQQAgACAIIAIgBkEMaiAGQQhqEEwiByIDa0EAIAMQAxtBCkdyRQRAQbh/IQcMBAsgBxADDQMgAiAHayECIAcgCGohCEEBIQwgBigCDCEDIAYoAgghBAwBCwsgBiADNgIMIAYgBDYCCEG4fyEHIAQNASAIIAFrIQcMAQsgBiADNgIMIAYgBDYCCAsgBkEQaiQAIAcLRgECfyABIAAoArjgASICRwRAIAAgAjYCxOABIAAgATYCuOABIAAoArzgASEDIAAgATYCvOABIAAgASADIAJrajYCwOABCwutAgIEfwF+IwBBQGoiBCQAAkACQCACQQhJDQAgASgAAEFwcUHQ1LTCAUcNACABIAIQIiEBIABCADcDCCAAQQA2AgQgACABNgIADAELIARBGGogASACEC0iAxADBEAgACADEBoMAQsgAwRAIABBuH8QGgwBCyACIAQoAjAiA2shAiABIANqIQMDQAJAIAAgAyACIARBCGoQLCIFEAMEfyAFBSACIAVBA2oiBU8NAUG4fwsQGgwCCyAGQQFqIQYgAiAFayECIAMgBWohAyAEKAIMRQ0ACyAEKAI4BEAgAkEDTQRAIABBuH8QGgwCCyADQQRqIQMLIAQoAighAiAEKQMYIQcgAEEANgIEIAAgAyABazYCACAAIAIgBmytIAcgB0J/URs3AwgLIARBQGskAAslAQF/IwBBEGsiAiQAIAIgACABEFEgAigCACEAIAJBEGokACAAC30BBH8jAEGQBGsiBCQAIARB/wE2AggCQCAEQRBqIARBCGogBEEMaiABIAIQFSIGEAMEQCAGIQUMAQtBVCEFIAQoAgwiB0EGSw0AIAMgBEEQaiAEKAIIIAcQQSIFEAMNACAAIAEgBmogAiAGayADEDwhBQsgBEGQBGokACAFC4cBAgJ/An5BABAWIQMCQANAIAEgA08EQAJAIAAoAABBcHFB0NS0wgFGBEAgACABECIiAhADRQ0BQn4PCyAAIAEQVSIEQn1WDQMgBCAFfCIFIARUIQJCfiEEIAINAyAAIAEQUiICEAMNAwsgASACayEBIAAgAmohAAwBCwtCfiAFIAEbIQQLIAQLPwIBfwF+IwBBMGsiAiQAAn5CfiACQQhqIAAgARAtDQAaQgAgAigCHEEBRg0AGiACKQMICyEDIAJBMGokACADC40BAQJ/IwBBMGsiASQAAkAgAEUNACAAKAKI4gENACABIABB/OEBaigCADYCKCABIAApAvThATcDICAAEDAgACgCqOIBIQIgASABKAIoNgIYIAEgASkDIDcDECACIAFBEGoQGyAAQQA2AqjiASABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALKgECfyMAQRBrIgAkACAAQQA2AgggAEIANwMAIAAQWCEBIABBEGokACABC4cBAQN/IwBBEGsiAiQAAkAgACgCAEUgACgCBEVzDQAgAiAAKAIINgIIIAIgACkCADcDAAJ/IAIoAgAiAQRAIAIoAghBqOMJIAERBQAMAQtBqOMJECgLIgFFDQAgASAAKQIANwL04QEgAUH84QFqIAAoAgg2AgAgARBZIAEhAwsgAkEQaiQAIAMLywEBAn8jAEEgayIBJAAgAEGBgIDAADYCtOIBIABBADYCiOIBIABBADYC7OEBIABCADcDkOIBIABBADYCpOMJIABBADYC3OIBIABCADcCzOIBIABBADYCvOIBIABBADYCxOABIABCADcCnOIBIABBpOIBakIANwIAIABBrOIBakEANgIAIAFCADcCECABQgA3AhggASABKQMYNwMIIAEgASkDEDcDACABKAIIQQh2QQFxIQIgAEEANgLg4gEgACACNgKM4gEgAUEgaiQAC3YBA38jAEEwayIBJAAgAARAIAEgAEHE0AFqIgIoAgA2AiggASAAKQK80AE3AyAgACgCACEDIAEgAigCADYCGCABIAApArzQATcDECADIAFBEGoQGyABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALzAEBAX8gACABKAK00AE2ApjiASAAIAEoAgQiAjYCwOABIAAgAjYCvOABIAAgAiABKAIIaiICNgK44AEgACACNgLE4AEgASgCuNABBEAgAEKBgICAEDcDiOEBIAAgAUGk0ABqNgIMIAAgAUGUIGo2AgggACABQZwwajYCBCAAIAFBDGo2AgAgAEGs0AFqIAFBqNABaigCADYCACAAQbDQAWogAUGs0AFqKAIANgIAIABBtNABaiABQbDQAWooAgA2AgAPCyAAQgA3A4jhAQs7ACACRQRAQbp/DwsgBEUEQEFsDwsgAiAEEGAEQCAAIAEgAiADIAQgBRBhDwsgACABIAIgAyAEIAUQZQtGAQF/IwBBEGsiBSQAIAVBCGogBBAOAn8gBS0ACQRAIAAgASACIAMgBBAyDAELIAAgASACIAMgBBA0CyEAIAVBEGokACAACzQAIAAgAyAEIAUQNiIFEAMEQCAFDwsgBSAESQR/IAEgAiADIAVqIAQgBWsgABA1BUG4fwsLRgEBfyMAQRBrIgUkACAFQQhqIAQQDgJ/IAUtAAkEQCAAIAEgAiADIAQQYgwBCyAAIAEgAiADIAQQNQshACAFQRBqJAAgAAtZAQF/QQ8hAiABIABJBEAgAUEEdCAAbiECCyAAQQh2IgEgAkEYbCIAQYwIaigCAGwgAEGICGooAgBqIgJBA3YgAmogAEGACGooAgAgAEGECGooAgAgAWxqSQs3ACAAIAMgBCAFQYAQEDMiBRADBEAgBQ8LIAUgBEkEfyABIAIgAyAFaiAEIAVrIAAQMgVBuH8LC78DAQN/IwBBIGsiBSQAIAVBCGogAiADEAYiAhADRQRAIAAgAWoiB0F9aiEGIAUgBBAOIARBBGohAiAFLQACIQMDQEEAIAAgBkkgBUEIahAEGwRAIAAgAiAFQQhqIAMQAkECdGoiBC8BADsAACAFQQhqIAQtAAIQASAAIAQtAANqIgQgAiAFQQhqIAMQAkECdGoiAC8BADsAACAFQQhqIAAtAAIQASAEIAAtAANqIQAMAQUgB0F+aiEEA0AgBUEIahAEIAAgBEtyRQRAIAAgAiAFQQhqIAMQAkECdGoiBi8BADsAACAFQQhqIAYtAAIQASAAIAYtAANqIQAMAQsLA0AgACAES0UEQCAAIAIgBUEIaiADEAJBAnRqIgYvAQA7AAAgBUEIaiAGLQACEAEgACAGLQADaiEADAELCwJAIAAgB08NACAAIAIgBUEIaiADEAIiA0ECdGoiAC0AADoAACAALQADQQFGBEAgBUEIaiAALQACEAEMAQsgBSgCDEEfSw0AIAVBCGogAiADQQJ0ai0AAhABIAUoAgxBIUkNACAFQSA2AgwLIAFBbCAFQQhqEAobIQILCwsgBUEgaiQAIAILkgIBBH8jAEFAaiIJJAAgCSADQTQQCyEDAkAgBEECSA0AIAMgBEECdGooAgAhCSADQTxqIAgQIyADQQE6AD8gAyACOgA+QQAhBCADKAI8IQoDQCAEIAlGDQEgACAEQQJ0aiAKNgEAIARBAWohBAwAAAsAC0EAIQkDQCAGIAlGRQRAIAMgBSAJQQF0aiIKLQABIgtBAnRqIgwoAgAhBCADQTxqIAotAABBCHQgCGpB//8DcRAjIANBAjoAPyADIAcgC2siCiACajoAPiAEQQEgASAKa3RqIQogAygCPCELA0AgACAEQQJ0aiALNgEAIARBAWoiBCAKSQ0ACyAMIAo2AgAgCUEBaiEJDAELCyADQUBrJAALowIBCX8jAEHQAGsiCSQAIAlBEGogBUE0EAsaIAcgBmshDyAHIAFrIRADQAJAIAMgCkcEQEEBIAEgByACIApBAXRqIgYtAAEiDGsiCGsiC3QhDSAGLQAAIQ4gCUEQaiAMQQJ0aiIMKAIAIQYgCyAPTwRAIAAgBkECdGogCyAIIAUgCEE0bGogCCAQaiIIQQEgCEEBShsiCCACIAQgCEECdGooAgAiCEEBdGogAyAIayAHIA4QYyAGIA1qIQgMAgsgCUEMaiAOECMgCUEBOgAPIAkgCDoADiAGIA1qIQggCSgCDCELA0AgBiAITw0CIAAgBkECdGogCzYBACAGQQFqIQYMAAALAAsgCUHQAGokAA8LIAwgCDYCACAKQQFqIQoMAAALAAs0ACAAIAMgBCAFEDYiBRADBEAgBQ8LIAUgBEkEfyABIAIgAyAFaiAEIAVrIAAQNAVBuH8LCyMAIAA/AEEQdGtB//8DakEQdkAAQX9GBEBBAA8LQQAQAEEBCzsBAX8gAgRAA0AgACABIAJBgCAgAkGAIEkbIgMQCyEAIAFBgCBqIQEgAEGAIGohACACIANrIgINAAsLCwYAIAAQAwsLqBUJAEGICAsNAQAAAAEAAAACAAAAAgBBoAgLswYBAAAAAQAAAAIAAAACAAAAJgAAAIIAAAAhBQAASgAAAGcIAAAmAAAAwAEAAIAAAABJBQAASgAAAL4IAAApAAAALAIAAIAAAABJBQAASgAAAL4IAAAvAAAAygIAAIAAAACKBQAASgAAAIQJAAA1AAAAcwMAAIAAAACdBQAASgAAAKAJAAA9AAAAgQMAAIAAAADrBQAASwAAAD4KAABEAAAAngMAAIAAAABNBgAASwAAAKoKAABLAAAAswMAAIAAAADBBgAATQAAAB8NAABNAAAAUwQAAIAAAAAjCAAAUQAAAKYPAABUAAAAmQQAAIAAAABLCQAAVwAAALESAABYAAAA2gQAAIAAAABvCQAAXQAAACMUAABUAAAARQUAAIAAAABUCgAAagAAAIwUAABqAAAArwUAAIAAAAB2CQAAfAAAAE4QAAB8AAAA0gIAAIAAAABjBwAAkQAAAJAHAACSAAAAAAAAAAEAAAABAAAABQAAAA0AAAAdAAAAPQAAAH0AAAD9AAAA/QEAAP0DAAD9BwAA/Q8AAP0fAAD9PwAA/X8AAP3/AAD9/wEA/f8DAP3/BwD9/w8A/f8fAP3/PwD9/38A/f//AP3//wH9//8D/f//B/3//w/9//8f/f//P/3//38AAAAAAQAAAAIAAAADAAAABAAAAAUAAAAGAAAABwAAAAgAAAAJAAAACgAAAAsAAAAMAAAADQAAAA4AAAAPAAAAEAAAABEAAAASAAAAEwAAABQAAAAVAAAAFgAAABcAAAAYAAAAGQAAABoAAAAbAAAAHAAAAB0AAAAeAAAAHwAAAAMAAAAEAAAABQAAAAYAAAAHAAAACAAAAAkAAAAKAAAACwAAAAwAAAANAAAADgAAAA8AAAAQAAAAEQAAABIAAAATAAAAFAAAABUAAAAWAAAAFwAAABgAAAAZAAAAGgAAABsAAAAcAAAAHQAAAB4AAAAfAAAAIAAAACEAAAAiAAAAIwAAACUAAAAnAAAAKQAAACsAAAAvAAAAMwAAADsAAABDAAAAUwAAAGMAAACDAAAAAwEAAAMCAAADBAAAAwgAAAMQAAADIAAAA0AAAAOAAAADAAEAQeAPC1EBAAAAAQAAAAEAAAABAAAAAgAAAAIAAAADAAAAAwAAAAQAAAAEAAAABQAAAAcAAAAIAAAACQAAAAoAAAALAAAADAAAAA0AAAAOAAAADwAAABAAQcQQC4sBAQAAAAIAAAADAAAABAAAAAUAAAAGAAAABwAAAAgAAAAJAAAACgAAAAsAAAAMAAAADQAAAA4AAAAPAAAAEAAAABIAAAAUAAAAFgAAABgAAAAcAAAAIAAAACgAAAAwAAAAQAAAAIAAAAAAAQAAAAIAAAAEAAAACAAAABAAAAAgAAAAQAAAAIAAAAAAAQBBkBIL5gQBAAAAAQAAAAEAAAABAAAAAgAAAAIAAAADAAAAAwAAAAQAAAAGAAAABwAAAAgAAAAJAAAACgAAAAsAAAAMAAAADQAAAA4AAAAPAAAAEAAAAAEAAAAEAAAACAAAAAAAAAABAAEBBgAAAAAAAAQAAAAAEAAABAAAAAAgAAAFAQAAAAAAAAUDAAAAAAAABQQAAAAAAAAFBgAAAAAAAAUHAAAAAAAABQkAAAAAAAAFCgAAAAAAAAUMAAAAAAAABg4AAAAAAAEFEAAAAAAAAQUUAAAAAAABBRYAAAAAAAIFHAAAAAAAAwUgAAAAAAAEBTAAAAAgAAYFQAAAAAAABwWAAAAAAAAIBgABAAAAAAoGAAQAAAAADAYAEAAAIAAABAAAAAAAAAAEAQAAAAAAAAUCAAAAIAAABQQAAAAAAAAFBQAAACAAAAUHAAAAAAAABQgAAAAgAAAFCgAAAAAAAAULAAAAAAAABg0AAAAgAAEFEAAAAAAAAQUSAAAAIAABBRYAAAAAAAIFGAAAACAAAwUgAAAAAAADBSgAAAAAAAYEQAAAABAABgRAAAAAIAAHBYAAAAAAAAkGAAIAAAAACwYACAAAMAAABAAAAAAQAAAEAQAAACAAAAUCAAAAIAAABQMAAAAgAAAFBQAAACAAAAUGAAAAIAAABQgAAAAgAAAFCQAAACAAAAULAAAAIAAABQwAAAAAAAAGDwAAACAAAQUSAAAAIAABBRQAAAAgAAIFGAAAACAAAgUcAAAAIAADBSgAAAAgAAQFMAAAAAAAEAYAAAEAAAAPBgCAAAAAAA4GAEAAAAAADQYAIABBgBcLhwIBAAEBBQAAAAAAAAUAAAAAAAAGBD0AAAAAAAkF/QEAAAAADwX9fwAAAAAVBf3/HwAAAAMFBQAAAAAABwR9AAAAAAAMBf0PAAAAABIF/f8DAAAAFwX9/38AAAAFBR0AAAAAAAgE/QAAAAAADgX9PwAAAAAUBf3/DwAAAAIFAQAAABAABwR9AAAAAAALBf0HAAAAABEF/f8BAAAAFgX9/z8AAAAEBQ0AAAAQAAgE/QAAAAAADQX9HwAAAAATBf3/BwAAAAEFAQAAABAABgQ9AAAAAAAKBf0DAAAAABAF/f8AAAAAHAX9//8PAAAbBf3//wcAABoF/f//AwAAGQX9//8BAAAYBf3//wBBkBkLhgQBAAEBBgAAAAAAAAYDAAAAAAAABAQAAAAgAAAFBQAAAAAAAAUGAAAAAAAABQgAAAAAAAAFCQAAAAAAAAULAAAAAAAABg0AAAAAAAAGEAAAAAAAAAYTAAAAAAAABhYAAAAAAAAGGQAAAAAAAAYcAAAAAAAABh8AAAAAAAAGIgAAAAAAAQYlAAAAAAABBikAAAAAAAIGLwAAAAAAAwY7AAAAAAAEBlMAAAAAAAcGgwAAAAAACQYDAgAAEAAABAQAAAAAAAAEBQAAACAAAAUGAAAAAAAABQcAAAAgAAAFCQAAAAAAAAUKAAAAAAAABgwAAAAAAAAGDwAAAAAAAAYSAAAAAAAABhUAAAAAAAAGGAAAAAAAAAYbAAAAAAAABh4AAAAAAAAGIQAAAAAAAQYjAAAAAAABBicAAAAAAAIGKwAAAAAAAwYzAAAAAAAEBkMAAAAAAAUGYwAAAAAACAYDAQAAIAAABAQAAAAwAAAEBAAAABAAAAQFAAAAIAAABQcAAAAgAAAFCAAAACAAAAUKAAAAIAAABQsAAAAAAAAGDgAAAAAAAAYRAAAAAAAABhQAAAAAAAAGFwAAAAAAAAYaAAAAAAAABh0AAAAAAAAGIAAAAAAAEAYDAAEAAAAPBgOAAAAAAA4GA0AAAAAADQYDIAAAAAAMBgMQAAAAAAsGAwgAAAAACgYDBABBpB0L2QEBAAAAAwAAAAcAAAAPAAAAHwAAAD8AAAB/AAAA/wAAAP8BAAD/AwAA/wcAAP8PAAD/HwAA/z8AAP9/AAD//wAA//8BAP//AwD//wcA//8PAP//HwD//z8A//9/AP///wD///8B////A////wf///8P////H////z////9/AAAAAAEAAAACAAAABAAAAAAAAAACAAAABAAAAAgAAAAAAAAAAQAAAAIAAAABAAAABAAAAAQAAAAEAAAABAAAAAgAAAAIAAAACAAAAAcAAAAIAAAACQAAAAoAAAALAEGgIAsDwBBQ",RL="display-p3",NL="display-p3-linear",lp=new WeakMap;let hp=0,up;class oi extends $i{constructor(e){super(e),this.transcoderPath="",this.transcoderBinary=null,this.transcoderPending=null,this.workerPool=new EL,this.workerSourceURL="",this.workerConfig=null,typeof MSC_TRANSCODER<"u"&&console.warn('THREE.KTX2Loader: Please update to latest "basis_transcoder". "msc_basis_transcoder" is no longer supported in three.js r125+.')}setTranscoderPath(e){return this.transcoderPath=e,this}setWorkerLimit(e){return this.workerPool.setWorkerLimit(e),this}async detectSupportAsync(e){return this.workerConfig={astcSupported:await e.hasFeatureAsync("texture-compression-astc"),astcHDRSupported:!1,etc1Supported:await e.hasFeatureAsync("texture-compression-etc1"),etc2Supported:await e.hasFeatureAsync("texture-compression-etc2"),dxtSupported:await e.hasFeatureAsync("texture-compression-bc"),bptcSupported:await e.hasFeatureAsync("texture-compression-bptc"),pvrtcSupported:await e.hasFeatureAsync("texture-compression-pvrtc")},this}detectSupport(e){return e.isWebGPURenderer===!0?this.workerConfig={astcSupported:e.hasFeature("texture-compression-astc"),astcHDRSupported:!1,etc1Supported:e.hasFeature("texture-compression-etc1"),etc2Supported:e.hasFeature("texture-compression-etc2"),dxtSupported:e.hasFeature("texture-compression-bc"),bptcSupported:e.hasFeature("texture-compression-bptc"),pvrtcSupported:e.hasFeature("texture-compression-pvrtc")}:this.workerConfig={astcSupported:e.extensions.has("WEBGL_compressed_texture_astc"),astcHDRSupported:e.extensions.has("WEBGL_compressed_texture_astc")&&e.extensions.get("WEBGL_compressed_texture_astc").getSupportedProfiles().includes("hdr"),etc1Supported:e.extensions.has("WEBGL_compressed_texture_etc1"),etc2Supported:e.extensions.has("WEBGL_compressed_texture_etc"),dxtSupported:e.extensions.has("WEBGL_compressed_texture_s3tc"),bptcSupported:e.extensions.has("EXT_texture_compression_bptc"),pvrtcSupported:e.extensions.has("WEBGL_compressed_texture_pvrtc")||e.extensions.has("WEBKIT_WEBGL_compressed_texture_pvrtc")},this}init(){if(!this.transcoderPending){const e=new Ts(this.manager);e.setPath(this.transcoderPath),e.setWithCredentials(this.withCredentials);const t=e.loadAsync("basis_transcoder.js"),n=new Ts(this.manager);n.setPath(this.transcoderPath),n.setResponseType("arraybuffer"),n.setWithCredentials(this.withCredentials);const s=n.loadAsync("basis_transcoder.wasm");this.transcoderPending=Promise.all([t,s]).then(([r,a])=>{const o=oi.BasisWorker.toString(),c=["/* constants */","let _EngineFormat = "+JSON.stringify(oi.EngineFormat),"let _EngineType = "+JSON.stringify(oi.EngineType),"let _TranscoderFormat = "+JSON.stringify(oi.TranscoderFormat),"let _BasisFormat = "+JSON.stringify(oi.BasisFormat),"/* basis_transcoder.js */",r,"/* worker */",o.substring(o.indexOf("{")+1,o.lastIndexOf("}"))].join(`+`);this.workerSourceURL=URL.createObjectURL(new Blob([c])),this.transcoderBinary=a,this.workerPool.setWorkerCreator(()=>{const l=new Worker(this.workerSourceURL),h=this.transcoderBinary.slice(0);return l.postMessage({type:"init",config:this.workerConfig,transcoderBinary:h},[h]),l})}),hp>0&&console.warn("THREE.KTX2Loader: Multiple active KTX2 loaders may cause performance issues. Use a single KTX2Loader instance, or call .dispose() on old instances."),hp++}return this.transcoderPending}load(e,t,n,s){if(this.workerConfig===null)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");const r=new Ts(this.manager);r.setResponseType("arraybuffer"),r.setWithCredentials(this.withCredentials),r.load(e,a=>{this.parse(a,t,s)},n,s)}parse(e,t,n){if(this.workerConfig===null)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");if(lp.has(e))return lp.get(e).promise.then(t).catch(n);this._createTexture(e).then(s=>t?t(s):null).catch(n)}_createTextureFrom(e,t){const{type:n,error:s,data:{faces:r,width:a,height:o,format:c,type:l,dfdFlags:h}}=e;if(n==="error")return Promise.reject(s);let u;if(t.faceCount===6)u=new vy(r,c,l);else{const d=r[0].mipmaps;u=t.layerCount>1?new wy(d,a,o,t.layerCount,c,l):new tl(d,a,o,c,l)}return u.minFilter=r[0].mipmaps.length===1?zt:Zn,u.magFilter=zt,u.generateMipmaps=!1,u.needsUpdate=!0,u.colorSpace=F_(t),u.premultiplyAlpha=!!(h&wL),u}async _createTexture(e,t={}){const n=BL(new Uint8Array(e)),s=n.vkFormat===rp&&n.dataFormatDescriptor[0].colorModel===167;if(!(n.vkFormat===IL||s&&!this.workerConfig.astcHDRSupported))return DL(n);const a=t,o=this.init().then(()=>this.workerPool.postMessage({type:"transcode",buffer:e,taskConfig:a},[e])).then(c=>this._createTextureFrom(c.data,n));return lp.set(e,{promise:o}),o}dispose(){this.workerPool.dispose(),this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),hp--}}oi.BasisFormat={ETC1S:0,UASTC:1,UASTC_HDR:2},oi.TranscoderFormat={ETC1:0,ETC2:1,BC1:2,BC3:3,BC4:4,BC5:5,BC7_M6_OPAQUE_ONLY:6,BC7_M5:7,PVRTC1_4_RGB:8,PVRTC1_4_RGBA:9,ASTC_4x4:10,ATC_RGB:11,ATC_RGBA_INTERPOLATED_ALPHA:12,RGBA32:13,RGB565:14,BGR565:15,RGBA4444:16,BC6H:22,RGB_HALF:24,RGBA_HALF:25},oi.EngineFormat={RGBAFormat:sn,RGBA_ASTC_4x4_Format:eo,RGB_BPTC_UNSIGNED_Format:wc,RGBA_BPTC_Format:no,RGBA_ETC2_EAC_Format:yc,RGBA_PVRTC_4BPPV1_Format:xc,RGBA_S3TC_DXT5_Format:$a,RGB_ETC1_Format:_c,RGB_ETC2_Format:Ec,RGB_PVRTC_4BPPV1_Format:bc,RGBA_S3TC_DXT1_Format:Za},oi.EngineType={UnsignedByteType:tn,HalfFloatType:Bn,FloatType:nn},oi.BasisWorker=function(){let i,e,t;const n=_EngineFormat,s=_EngineType,r=_TranscoderFormat,a=_BasisFormat;self.addEventListener("message",function(m){const A=m.data;switch(A.type){case"init":i=A.config,o(A.transcoderBinary);break;case"transcode":e.then(()=>{try{const{faces:g,buffers:p,width:y,height:b,hasAlpha:E,format:M,type:w,dfdFlags:S}=c(A.buffer);self.postMessage({type:"transcode",id:A.id,data:{faces:g,width:y,height:b,hasAlpha:E,format:M,type:w,dfdFlags:S}},p)}catch(g){console.error(g),self.postMessage({type:"error",id:A.id,error:g.message})}});break}});function o(m){e=new Promise(A=>{t={wasmBinary:m,onRuntimeInitialized:A},BASIS(t)}).then(()=>{t.initializeBasis(),t.KTX2File===void 0&&console.warn("THREE.KTX2Loader: Please update Basis Universal transcoder.")})}function c(m){const A=new t.KTX2File(new Uint8Array(m));function g(){A.close(),A.delete()}if(!A.isValid())throw g(),new Error("THREE.KTX2Loader: Invalid or unsupported .ktx2 file");let p;if(A.isUASTC())p=a.UASTC;else if(A.isETC1S())p=a.ETC1S;else if(A.isHDR())p=a.UASTC_HDR;else throw new Error("THREE.KTX2Loader: Unknown Basis encoding");const y=A.getWidth(),b=A.getHeight(),E=A.getLayers()||1,M=A.getLevels(),w=A.getFaces(),S=A.getHasAlpha(),T=A.getDFDFlags(),{transcoderFormat:C,engineFormat:v,engineType:F}=u(p,y,b,S);if(!y||!b||!M)throw g(),new Error("THREE.KTX2Loader: Invalid texture");if(!A.startTranscoding())throw g(),new Error("THREE.KTX2Loader: .startTranscoding failed");const K=[],q=[];for(let $=0;$<w;$++){const D=[];for(let O=0;O<M;O++){const Y=[];let Q,J;for(let ae=0;ae<E;ae++){const ye=A.getImageLevelInfo(O,ae,$);$===0&&O===0&&ae===0&&(ye.origWidth%4!==0||ye.origHeight%4!==0)&&console.warn("THREE.KTX2Loader: ETC1S and UASTC textures should use multiple-of-four dimensions."),M>1?(Q=ye.origWidth,J=ye.origHeight):(Q=ye.width,J=ye.height);let Me=new Uint8Array(A.getImageTranscodedSizeInBytes(O,ae,0,C));const se=A.transcodeImage(Me,O,ae,$,C,0,-1,-1);if(F===s.HalfFloatType&&(Me=new Uint16Array(Me.buffer,Me.byteOffset,Me.byteLength/Uint16Array.BYTES_PER_ELEMENT)),!se)throw g(),new Error("THREE.KTX2Loader: .transcodeImage failed.");Y.push(Me)}const ee=f(Y);D.push({data:ee,width:Q,height:J}),q.push(ee.buffer)}K.push({mipmaps:D,width:y,height:b,format:v,type:F})}return g(),{faces:K,buffers:q,width:y,height:b,hasAlpha:S,dfdFlags:T,format:v,type:F}}const l=[{if:"astcSupported",basisFormat:[a.UASTC],transcoderFormat:[r.ASTC_4x4,r.ASTC_4x4],engineFormat:[n.RGBA_ASTC_4x4_Format,n.RGBA_ASTC_4x4_Format],engineType:[s.UnsignedByteType],priorityETC1S:1/0,priorityUASTC:1,needsPowerOfTwo:!1},{if:"bptcSupported",basisFormat:[a.ETC1S,a.UASTC],transcoderFormat:[r.BC7_M5,r.BC7_M5],engineFormat:[n.RGBA_BPTC_Format,n.RGBA_BPTC_Format],engineType:[s.UnsignedByteType],priorityETC1S:3,priorityUASTC:2,needsPowerOfTwo:!1},{if:"dxtSupported",basisFormat:[a.ETC1S,a.UASTC],transcoderFormat:[r.BC1,r.BC3],engineFormat:[n.RGBA_S3TC_DXT1_Format,n.RGBA_S3TC_DXT5_Format],engineType:[s.UnsignedByteType],priorityETC1S:4,priorityUASTC:5,needsPowerOfTwo:!1},{if:"etc2Supported",basisFormat:[a.ETC1S,a.UASTC],transcoderFormat:[r.ETC1,r.ETC2],engineFormat:[n.RGB_ETC2_Format,n.RGBA_ETC2_EAC_Format],engineType:[s.UnsignedByteType],priorityETC1S:1,priorityUASTC:3,needsPowerOfTwo:!1},{if:"etc1Supported",basisFormat:[a.ETC1S,a.UASTC],transcoderFormat:[r.ETC1],engineFormat:[n.RGB_ETC1_Format],engineType:[s.UnsignedByteType],priorityETC1S:2,priorityUASTC:4,needsPowerOfTwo:!1},{if:"pvrtcSupported",basisFormat:[a.ETC1S,a.UASTC],transcoderFormat:[r.PVRTC1_4_RGB,r.PVRTC1_4_RGBA],engineFormat:[n.RGB_PVRTC_4BPPV1_Format,n.RGBA_PVRTC_4BPPV1_Format],engineType:[s.UnsignedByteType],priorityETC1S:5,priorityUASTC:6,needsPowerOfTwo:!0},{if:"bptcSupported",basisFormat:[a.UASTC_HDR],transcoderFormat:[r.BC6H],engineFormat:[n.RGB_BPTC_UNSIGNED_Format],engineType:[s.HalfFloatType],priorityHDR:1,needsPowerOfTwo:!1},{basisFormat:[a.ETC1S,a.UASTC],transcoderFormat:[r.RGBA32,r.RGBA32],engineFormat:[n.RGBAFormat,n.RGBAFormat],engineType:[s.UnsignedByteType,s.UnsignedByteType],priorityETC1S:100,priorityUASTC:100,needsPowerOfTwo:!1},{basisFormat:[a.UASTC_HDR],transcoderFormat:[r.RGBA_HALF],engineFormat:[n.RGBAFormat],engineType:[s.HalfFloatType],priorityHDR:100,needsPowerOfTwo:!1}],h={[a.ETC1S]:l.filter(m=>m.basisFormat.includes(a.ETC1S)).sort((m,A)=>m.priorityUASTC-A.priorityUASTC),[a.UASTC]:l.filter(m=>m.basisFormat.includes(a.UASTC)).sort((m,A)=>m.priorityUASTC-A.priorityUASTC),[a.UASTC_HDR]:l.filter(m=>m.basisFormat.includes(a.UASTC_HDR)).sort((m,A)=>m.priorityHDR-A.priorityHDR)};function u(m,A,g,p){const y=h[m];for(let b=0;b<y.length;b++){const E=y[b];if(E.if&&!i[E.if]||!E.basisFormat.includes(m)||p&&E.transcoderFormat.length<2||E.needsPowerOfTwo&&!(d(A)&&d(g)))continue;const M=E.transcoderFormat[p?1:0],w=E.engineFormat[p?1:0],S=E.engineType[0];return{transcoderFormat:M,engineFormat:w,engineType:S}}throw new Error("THREE.KTX2Loader: Failed to identify transcoding target.")}function d(m){return m<=2?!0:(m&m-1)===0&&m!==0}function f(m){if(m.length===1)return m[0];let A=0;for(let y=0;y<m.length;y++){const b=m[y];A+=b.byteLength}const g=new Uint8Array(A);let p=0;for(let y=0;y<m.length;y++){const b=m[y];g.set(b,p),p+=b.byteLength}return g}};const FL=new Set([sn,Zs,zi]),dp={[M_]:sn,[C_]:sn,[E_]:sn,[y_]:sn,[I_]:Zs,[v_]:Zs,[x_]:Zs,[__]:Zs,[S_]:zi,[w_]:zi,[b_]:zi,[m_]:zi,[rp]:eo,[T_]:to,[B_]:to},fp={[M_]:nn,[C_]:Bn,[E_]:tn,[y_]:tn,[I_]:nn,[v_]:Bn,[x_]:tn,[__]:tn,[S_]:nn,[w_]:Bn,[b_]:tn,[m_]:tn,[rp]:Bn,[T_]:tn,[B_]:tn};async function DL(i){const{vkFormat:e}=i;if(dp[e]===void 0)throw new Error("THREE.KTX2Loader: Unsupported vkFormat.");let t;i.supercompressionScheme===A_&&(up||(up=new Promise(async r=>{const a=new TL;await a.init(),r(a)})),t=await up);const n=[];for(let r=0;r<i.levels.length;r++){const a=Math.max(1,i.pixelWidth>>r),o=Math.max(1,i.pixelHeight>>r),c=i.pixelDepth?Math.max(1,i.pixelDepth>>r):0,l=i.levels[r];let h;if(i.supercompressionScheme===yL)h=l.levelData;else if(i.supercompressionScheme===A_)h=t.decode(l.levelData,l.uncompressedByteLength);else throw new Error("THREE.KTX2Loader: Unsupported supercompressionScheme.");let u;fp[e]===nn?u=new Float32Array(h.buffer,h.byteOffset,h.byteLength/Float32Array.BYTES_PER_ELEMENT):fp[e]===Bn?u=new Uint16Array(h.buffer,h.byteOffset,h.byteLength/Uint16Array.BYTES_PER_ELEMENT):u=h,n.push({data:u,width:a,height:o,depth:c})}let s;if(FL.has(dp[e]))s=i.pixelDepth===0?new Wc(n[0].data,i.pixelWidth,i.pixelHeight):new qp(n[0].data,i.pixelWidth,i.pixelHeight,i.pixelDepth);else{if(i.pixelDepth>0)throw new Error("THREE.KTX2Loader: Unsupported pixelDepth.");s=new tl(n,i.pixelWidth,i.pixelHeight),s.minFilter=n.length===1?zt:Zn,s.magFilter=zt}return s.mipmaps=n,s.type=fp[e],s.format=dp[e],s.colorSpace=F_(i),s.needsUpdate=!0,Promise.resolve(s)}function F_(i){const e=i.dataFormatDescriptor[0];return e.colorPrimaries===CL?e.transferFunction===g_?Kt:rn:e.colorPrimaries===SL?e.transferFunction===g_?RL:NL:(e.colorPrimaries===vL||console.warn(`THREE.KTX2Loader: Unsupported color primaries, "${e.colorPrimaries}"`),li)}const LL=Object.freeze(Object.defineProperty({__proto__:null,KTX2Loader:oi},Symbol.toStringTag,{value:"Module"}));var PL=(function(){var i="b9H79Tebbbe8Fv9Gbb9Gvuuuuueu9Giuuub9Geueu9Giuuueuikqbeeedddillviebeoweuec:q;iekr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbeY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVbdE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbiL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtblK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbol79IV9Rbrq:P8Yqdbk;3sezu8Jjjjjbcj;eb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Radz1jjjbhwcj;abad9UhoaicefhldnadTmbaoc;WFbGgocjdaocjd6EhDcbhqinaqae9pmeaDaeaq9RaqaDfae6Egkcsfgocl4cifcd4hxdndndndnaoc9WGgmTmbcbhPcehsawcjdfhzalhHinaraH9Rax6midnaraHaxfgl9RcK6mbczhoinawcj;cbfaogifgoc9WfhOdndndndndnaHaic9WfgAco4fRbbaAci4coG4ciGPlbedibkaO9cb83ibaOcwf9cb83ibxikaOalRblalRbbgAco4gCaCciSgCE86bbaocGfalclfaCfgORbbaAcl4ciGgCaCciSgCE86bbaocVfaOaCfgORbbaAcd4ciGgCaCciSgCE86bbaoc7faOaCfgORbbaAciGgAaAciSgAE86bbaoctfaOaAfgARbbalRbegOco4gCaCciSgCE86bbaoc91faAaCfgARbbaOcl4ciGgCaCciSgCE86bbaoc4faAaCfgARbbaOcd4ciGgCaCciSgCE86bbaoc93faAaCfgARbbaOciGgOaOciSgOE86bbaoc94faAaOfgARbbalRbdgOco4gCaCciSgCE86bbaoc95faAaCfgARbbaOcl4ciGgCaCciSgCE86bbaoc96faAaCfgARbbaOcd4ciGgCaCciSgCE86bbaoc97faAaCfgARbbaOciGgOaOciSgOE86bbaoc98faAaOfgORbbalRbiglco4gAaAciSgAE86bbaoc99faOaAfgORbbalcl4ciGgAaAciSgAE86bbaoc9:faOaAfgORbbalcd4ciGgAaAciSgAE86bbaocufaOaAfgoRbbalciGglalciSglE86bbaoalfhlxdkaOalRbwalRbbgAcl4gCaCcsSgCE86bbaocGfalcwfaCfgORbbaAcsGgAaAcsSgAE86bbaocVfaOaAfgORbbalRbegAcl4gCaCcsSgCE86bbaoc7faOaCfgORbbaAcsGgAaAcsSgAE86bbaoctfaOaAfgORbbalRbdgAcl4gCaCcsSgCE86bbaoc91faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc4faOaAfgORbbalRbigAcl4gCaCcsSgCE86bbaoc93faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc94faOaAfgORbbalRblgAcl4gCaCcsSgCE86bbaoc95faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc96faOaAfgORbbalRbvgAcl4gCaCcsSgCE86bbaoc97faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc98faOaAfgORbbalRbogAcl4gCaCcsSgCE86bbaoc99faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc9:faOaAfgORbbalRbrglcl4gAaAcsSgAE86bbaocufaOaAfgoRbbalcsGglalcsSglE86bbaoalfhlxekaOal8Pbb83bbaOcwfalcwf8Pbb83bbalczfhlkdnaiam9pmbaiczfhoaral9RcL0mekkaiam6mialTmidnakTmbawaPfRbbhOcbhoazhiinaiawcj;cbfaofRbbgAce4cbaAceG9R7aOfgO86bbaiadfhiaocefgoak9hmbkkazcefhzaPcefgPad6hsalhHaPad9hmexvkkcbhlasceGmdxikalaxad2fhCdnakTmbcbhHcehsawcjdfhminaral9Rax6mialTmdalaxfhlawaHfRbbhOcbhoamhiinaiawcj;cbfaofRbbgAce4cbaAceG9R7aOfgO86bbaiadfhiaocefgoak9hmbkamcefhmaHcefgHad6hsaHad9hmbkaChlxikcbhocehsinaral9Rax6mdalTmealaxfhlaocefgoad6hsadao9hmbkaChlxdkcbhlasceGTmekc9:hoxikabaqad2fawcjdfakad2z1jjjb8Aawawcjdfakcufad2fadz1jjjb8Aakaqfhqalmbkc9:hoxekcbc99aral9Radcaadca0ESEhokavcj;ebf8Kjjjjbaok;yzeHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecjez:jjjjb8AavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhodnaeTmbcmcsaDceSEhkcbhxcbhmcbhDcbhicbhlindnaoaq9nmbc9:hoxikdndnawRbbgrc;Ve0mbavc;abfalarcl4cu7fcsGcitfgPydlhsaPydbhzdnarcsGgPak9pmbavaiarcu7fcsGcdtfydbaxaPEhraPThPdndnadcd9hmbabaDcetfgHaz87ebaHcdfas87ebaHclfar87ebxekabaDcdtfgHazBdbaHclfasBdbaHcwfarBdbkaxaPfhxavc;abfalcitfgHarBdbaHasBdlavaicdtfarBdbavc;abfalcefcsGglcitfgHazBdbaHarBdlaiaPfhialcefhlxdkdndnaPcsSmbamaPfaPc987fcefhmxekaocefhrao8SbbgPcFeGhHdndnaPcu9mmbarhoxekaocvfhoaHcFbGhHcrhPdninar8SbbgOcFbGaPtaHVhHaOcu9kmearcefhraPcrfgPc8J9hmbxdkkarcefhokaHce4cbaHceG9R7amfhmkdndnadcd9hmbabaDcetfgraz87ebarcdfas87ebarclfam87ebxekabaDcdtfgrazBdbarclfasBdbarcwfamBdbkavc;abfalcitfgramBdbarasBdlavaicdtfamBdbavc;abfalcefcsGglcitfgrazBdbaramBdlaicefhialcefhlxekdnarcpe0mbaxcefgOavaiaqarcsGfRbbgPcl49RcsGcdtfydbaPcz6gHEhravaiaP9RcsGcdtfydbaOaHfgsaPcsGgOEhPaOThOdndnadcd9hmbabaDcetfgzax87ebazcdfar87ebazclfaP87ebxekabaDcdtfgzaxBdbazclfarBdbazcwfaPBdbkavaicdtfaxBdbavc;abfalcitfgzarBdbazaxBdlavaicefgicsGcdtfarBdbavc;abfalcefcsGcitfgzaPBdbazarBdlavaiaHfcsGgicdtfaPBdbavc;abfalcdfcsGglcitfgraxBdbaraPBdlalcefhlaiaOfhiasaOfhxxekaxcbaoRbbgzEgAarc;:eSgrfhsazcsGhCazcl4hXdndnazcs0mbascefhOxekashOavaiaX9RcsGcdtfydbhskdndnaCmbaOcefhxxekaOhxavaiaz9RcsGcdtfydbhOkdndnarTmbaocefhrxekaocdfhrao8SbegHcFeGhPdnaHcu9kmbaocofhAaPcFbGhPcrhodninar8SbbgHcFbGaotaPVhPaHcu9kmearcefhraocrfgoc8J9hmbkaAhrxekarcefhrkaPce4cbaPceG9R7amfgmhAkdndnaXcsSmbarhPxekarcefhPar8SbbgocFeGhHdnaocu9kmbarcvfhsaHcFbGhHcrhodninaP8SbbgrcFbGaotaHVhHarcu9kmeaPcefhPaocrfgoc8J9hmbkashPxekaPcefhPkaHce4cbaHceG9R7amfgmhskdndnaCcsSmbaPhoxekaPcefhoaP8SbbgrcFeGhHdnarcu9kmbaPcvfhOaHcFbGhHcrhrdninao8SbbgPcFbGartaHVhHaPcu9kmeaocefhoarcrfgrc8J9hmbkaOhoxekaocefhokaHce4cbaHceG9R7amfgmhOkdndnadcd9hmbabaDcetfgraA87ebarcdfas87ebarclfaO87ebxekabaDcdtfgraABdbarclfasBdbarcwfaOBdbkavc;abfalcitfgrasBdbaraABdlavaicdtfaABdbavc;abfalcefcsGcitfgraOBdbarasBdlavaicefgicsGcdtfasBdbavc;abfalcdfcsGcitfgraABdbaraOBdlavaiazcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhialcifhlkawcefhwalcsGhlaicsGhiaDcifgDae6mbkkcbc99aoaqSEhokavc;aef8Kjjjjbaok:llevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:Lvoeue99dud99eud99dndnadcl9hmbaeTmeindndnabcdfgd8Sbb:Yab8Sbbgi:Ygl:l:tabcefgv8Sbbgo:Ygr:l:tgwJbb;:9cawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai86bbdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad86bbdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad86bbabclfhbaecufgembxdkkaeTmbindndnabclfgd8Ueb:Yab8Uebgi:Ygl:l:tabcdfgv8Uebgo:Ygr:l:tgwJb;:FSawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai87ebdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad87ebdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad87ebabcwfhbaecufgembkkk;siliui99iue99dnaeTmbcbhiabhlindndnJ;Zl81Zalcof8UebgvciV:Y:vgoal8Ueb:YNgrJb;:FSNJbbbZJbbb:;arJbbbb9GEMgw:lJbbb9p9DTmbaw:OhDxekcjjjj94hDkalclf8Uebhqalcdf8UebhkabavcefciGaiVcetfaD87ebdndnaoak:YNgwJb;:FSNJbbbZJbbb:;awJbbbb9GEMgx:lJbbb9p9DTmbax:Ohkxekcjjjj94hkkabavcdfciGaiVcetfak87ebdndnaoaq:YNgoJb;:FSNJbbbZJbbb:;aoJbbbb9GEMgx:lJbbb9p9DTmbax:Ohqxekcjjjj94hqkabavcufciGaiVcetfaq87ebdndnJbbjZararN:tawawN:taoaoN:tgrJbbbbarJbbbb9GE:rJb;:FSNJbbbZMgr:lJbbb9p9DTmbar:Ohqxekcjjjj94hqkabavciGaiVcetfaq87ebalcwfhlaiclfhiaecufgembkkk9mbdnadcd4ae2geTmbinababydbgdcwtcw91:Yadce91cjjj;8ifcjjj98G::NUdbabclfhbaecufgembkkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaiczfhiaeczfheadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabkkkebcjwklz9Kbb",e="b9H79TebbbeKl9Gbb9Gvuuuuueu9Giuuub9Geueuikqbbebeedddilve9Weeeviebeoweuec:q;Aekr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbdY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVblE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtboK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbrL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbwl79IV9RbDq;t9tqlbzik9:evu8Jjjjjbcz9Rhbcbheincbhdcbhiinabcwfadfaicjuaead4ceGglE86bbaialfhiadcefgdcw9hmbkaec:q:yjjbfai86bbaecitc:q1jjbfab8Piw83ibaecefgecjd9hmbkk;h8JlHud97euo978Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Rad;8qbbcj;abad9UhoaicefhldnadTmbaoc;WFbGgocjdaocjd6EhwcbhDinaDae9pmeawaeaD9RaDawfae6Egqcsfgoc9WGgkci2hxakcethmaocl4cifcd4hPabaDad2fhscbhzdnincehHalhOcbhAdninaraO9RaP6miavcj;cbfaAak2fhCaOaPfhlcbhidnakc;ab6mbaral9Rc;Gb6mbcbhoinaCaofhidndndndndnaOaoco4fRbbgXciGPlbedibkaipxbbbbbbbbbbbbbbbbpklbxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklbalczfhlkdndndndndnaXcd4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklzxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklzalczfhlkdndndndndnaXcl4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklaxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklaalczfhlkdndndndndnaXco4Plbedibkaipxbbbbbbbbbbbbbbbbpkl8WxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WalclfaYpQbfaXc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WalcwfaYpQbfaXc:q:yjjbfRbbfhlxekaialpbbbpkl8Walczfhlkaoc;abfhiaocjefak0meaihoaral9Rc;Fb0mbkkdndnaiak9pmbaici4hoinaral9RcK6mdaCaifhXdndndndndnaOaico4fRbbaocoG4ciGPlbedibkaXpxbbbbbbbbbbbbbbbbpklbxikaXalpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaXalpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaXalpbbbpklbalczfhlkaocdfhoaiczfgiak6mbkkalTmbaAci6hHalhOaAcefgohAaoclSmdxekkcbhlaHceGmdkdnakTmbavcjdfazfhiavazfpbdbhYcbhXinaiavcj;cbfaXfgopblbgLcep9TaLpxeeeeeeeeeeeeeeeegQp9op9Hp9rgLaoakfpblbg8Acep9Ta8AaQp9op9Hp9rg8ApmbzeHdOiAlCvXoQrLgEaoamfpblbg3cep9Ta3aQp9op9Hp9rg3aoaxfpblbg5cep9Ta5aQp9op9Hp9rg5pmbzeHdOiAlCvXoQrLg8EpmbezHdiOAlvCXorQLgQaQpmbedibedibedibediaYp9UgYp9AdbbaiadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaEa8EpmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaLa8ApmwKDYq8AkEx3m5P8Es8FgLa3a5pmwKDYq8AkEx3m5P8Es8Fg8ApmbezHdiOAlvCXorQLgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaLa8ApmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfhiaXczfgXak6mbkkazclfgzad6mbkasavcjdfaqad2;8qbbavavcjdfaqcufad2fad;8qbbaqaDfhDc9:hoalmexikkc9:hoxekcbc99aral9Radcaadca0ESEhokavcj;kbf8Kjjjjbaokwbz:bjjjbk;uzeHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecje;8kbavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhodnaeTmbcmcsaDceSEhkcbhxcbhmcbhDcbhicbhlindnaoaq9nmbc9:hoxikdndnawRbbgrc;Ve0mbavc;abfalarcl4cu7fcsGcitfgPydlhsaPydbhzdnarcsGgPak9pmbavaiarcu7fcsGcdtfydbaxaPEhraPThPdndnadcd9hmbabaDcetfgHaz87ebaHcdfas87ebaHclfar87ebxekabaDcdtfgHazBdbaHclfasBdbaHcwfarBdbkaxaPfhxavc;abfalcitfgHarBdbaHasBdlavaicdtfarBdbavc;abfalcefcsGglcitfgHazBdbaHarBdlaiaPfhialcefhlxdkdndnaPcsSmbamaPfaPc987fcefhmxekaocefhrao8SbbgPcFeGhHdndnaPcu9mmbarhoxekaocvfhoaHcFbGhHcrhPdninar8SbbgOcFbGaPtaHVhHaOcu9kmearcefhraPcrfgPc8J9hmbxdkkarcefhokaHce4cbaHceG9R7amfhmkdndnadcd9hmbabaDcetfgraz87ebarcdfas87ebarclfam87ebxekabaDcdtfgrazBdbarclfasBdbarcwfamBdbkavc;abfalcitfgramBdbarasBdlavaicdtfamBdbavc;abfalcefcsGglcitfgrazBdbaramBdlaicefhialcefhlxekdnarcpe0mbaxcefgOavaiaqarcsGfRbbgPcl49RcsGcdtfydbaPcz6gHEhravaiaP9RcsGcdtfydbaOaHfgsaPcsGgOEhPaOThOdndnadcd9hmbabaDcetfgzax87ebazcdfar87ebazclfaP87ebxekabaDcdtfgzaxBdbazclfarBdbazcwfaPBdbkavaicdtfaxBdbavc;abfalcitfgzarBdbazaxBdlavaicefgicsGcdtfarBdbavc;abfalcefcsGcitfgzaPBdbazarBdlavaiaHfcsGgicdtfaPBdbavc;abfalcdfcsGglcitfgraxBdbaraPBdlalcefhlaiaOfhiasaOfhxxekaxcbaoRbbgzEgAarc;:eSgrfhsazcsGhCazcl4hXdndnazcs0mbascefhOxekashOavaiaX9RcsGcdtfydbhskdndnaCmbaOcefhxxekaOhxavaiaz9RcsGcdtfydbhOkdndnarTmbaocefhrxekaocdfhrao8SbegHcFeGhPdnaHcu9kmbaocofhAaPcFbGhPcrhodninar8SbbgHcFbGaotaPVhPaHcu9kmearcefhraocrfgoc8J9hmbkaAhrxekarcefhrkaPce4cbaPceG9R7amfgmhAkdndnaXcsSmbarhPxekarcefhPar8SbbgocFeGhHdnaocu9kmbarcvfhsaHcFbGhHcrhodninaP8SbbgrcFbGaotaHVhHarcu9kmeaPcefhPaocrfgoc8J9hmbkashPxekaPcefhPkaHce4cbaHceG9R7amfgmhskdndnaCcsSmbaPhoxekaPcefhoaP8SbbgrcFeGhHdnarcu9kmbaPcvfhOaHcFbGhHcrhrdninao8SbbgPcFbGartaHVhHaPcu9kmeaocefhoarcrfgrc8J9hmbkaOhoxekaocefhokaHce4cbaHceG9R7amfgmhOkdndnadcd9hmbabaDcetfgraA87ebarcdfas87ebarclfaO87ebxekabaDcdtfgraABdbarclfasBdbarcwfaOBdbkavc;abfalcitfgrasBdbaraABdlavaicdtfaABdbavc;abfalcefcsGcitfgraOBdbarasBdlavaicefgicsGcdtfasBdbavc;abfalcdfcsGcitfgraABdbaraOBdlavaiazcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhialcifhlkawcefhwalcsGhlaicsGhiaDcifgDae6mbkkcbc99aoaqSEhokavc;aef8Kjjjjbaok:llevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:EPliuo97eue978Jjjjjbca9Rhidndnadcl9hmbdnaec98GglTmbcbhvabhdinadadpbbbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpkbbadczfhdavclfgval6mbkkalae9pmeaiaeciGgvcdtgdVcbczad9R;8kbaiabalcdtfglad;8qbbdnavTmbaiaipblbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpklbkalaiad;8qbbskdnaec98GgxTmbcbhvabhdinadczfglalpbbbgopxbbbbbbFFbbbbbbFFgkp9oadpbbbgDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eaDaopmbediwDqkzHOAKY8AEgoczp:Sep;6egrp;Geaoczp:Reczp:Sep;6egwp;Gep;Kep;Legopxb;:FSb;:FSb;:FSb;:FSawaopxbbbbbbbbbbbbbbbbp:2egqawpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegwawp;Meaoaop;Mearaqaramp9op9rp;Kegoaop;Mep;Kep;Kep;Jep;Negrp;Mepxbbn0bbn0bbn0bbn0gqp;Keczp:Reawarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9op9qgwaoarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogopmwDKYqk8AExm35Ps8E8Fp9qpkbbadaDakp9oawaopmbezHdiOAlvCXorQLp9qpkbbadcafhdavclfgvax6mbkkaxae9pmbaiaeciGgvcitgdfcbcaad9R;8kbaiabaxcitfglad;8qbbdnavTmbaiaipblzgopxbbbbbbFFbbbbbbFFgkp9oaipblbgDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eaDaopmbediwDqkzHOAKY8AEgoczp:Sep;6egrp;Geaoczp:Reczp:Sep;6egwp;Gep;Kep;Legopxb;:FSb;:FSb;:FSb;:FSawaopxbbbbbbbbbbbbbbbbp:2egqawpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegwawp;Meaoaop;Mearaqaramp9op9rp;Kegoaop;Mep;Kep;Kep;Jep;Negrp;Mepxbbn0bbn0bbn0bbn0gqp;Keczp:Reawarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9op9qgwaoarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogopmwDKYqk8AExm35Ps8E8Fp9qpklzaiaDakp9oawaopmbezHdiOAlvCXorQLp9qpklbkalaiad;8qbbkk;4wllue97euv978Jjjjjbc8W9Rhidnaec98GglTmbcbhvabhoinaiaopbbbgraoczfgwpbbbgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklbaopxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaqakp;Mearp;Keczp:ReaDakp;Mearp;Keamp9op9qgkpmbezHdiOAlvCXorQLgrp5baipblbpEb:T:j83ibaocwfarp5eaipblbpEe:T:j83ibawaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblbpEd:T:j83ibaocKfakp5eaipblbpEi:T:j83ibaocafhoavclfgval6mbkkdnalae9pmbaiaeciGgvcitgofcbcaao9R;8kbaiabalcitfgwao;8qbbdnavTmbaiaipblbgraipblzgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklaaipxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaqakp;Mearp;Keczp:ReaDakp;Mearp;Keamp9op9qgkpmbezHdiOAlvCXorQLgrp5baipblapEb:T:j83ibaiarp5eaipblapEe:T:j83iwaiaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblapEd:T:j83izaiakp5eaipblapEi:T:j83iKkawaiao;8qbbkk:Pddiue978Jjjjjbc;ab9Rhidnadcd4ae2glc98GgvTmbcbhdabheinaeaepbbbgocwp:Recwp:Sep;6eaocep:SepxbbjZbbjZbbjZbbjZp:UepxbbjFbbjFbbjFbbjFp9op;Mepkbbaeczfheadclfgdav6mbkkdnaval9pmbaialciGgdcdtgeVcbc;abae9R;8kbaiabavcdtfgvae;8qbbdnadTmbaiaipblbgocwp:Recwp:Sep;6eaocep:SepxbbjZbbjZbbjZbbjZp:UepxbbjFbbjFbbjFbbjFp9op;Mepklbkavaiae;8qbbkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikkkebcjwklz9Tbb",t=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),n=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if(typeof WebAssembly!="object")return{supported:!1};var s=WebAssembly.validate(t)?e:i,r,a=WebAssembly.instantiate(o(s),{}).then(function(p){r=p.instance,r.exports.__wasm_call_ctors()});function o(p){for(var y=new Uint8Array(p.length),b=0;b<p.length;++b){var E=p.charCodeAt(b);y[b]=E>96?E-97:E>64?E-39:E+4}for(var M=0,b=0;b<p.length;++b)y[M++]=y[b]<60?n[y[b]]:(y[b]-60)*64+y[++b];return y.buffer.slice(0,M)}function c(p,y,b,E,M,w){var S=r.exports.sbrk,T=b+3&-4,C=S(T*E),v=S(M.length),F=new Uint8Array(r.exports.memory.buffer);F.set(M,v);var K=p(C,b,E,v,M.length);if(K==0&&w&&w(C,T,E),y.set(F.subarray(C,C+b*E)),S(C-S(0)),K!=0)throw new Error("Malformed buffer data: "+K)}var l={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},h={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"},u=[],d=0;function f(p){var y={object:new Worker(p),pending:0,requests:{}};return y.object.onmessage=function(b){var E=b.data;y.pending-=E.count,y.requests[E.id][E.action](E.value),delete y.requests[E.id]},y}function m(p){for(var y="var instance; var ready = WebAssembly.instantiate(new Uint8Array(["+new Uint8Array(o(s))+"]), {}).then(function(result) { instance = result.instance; instance.exports.__wasm_call_ctors(); });self.onmessage = workerProcess;"+c.toString()+g.toString(),b=new Blob([y],{type:"text/javascript"}),E=URL.createObjectURL(b),M=0;M<p;++M)u[M]=f(E);URL.revokeObjectURL(E)}function A(p,y,b,E,M){for(var w=u[0],S=1;S<u.length;++S)u[S].pending<w.pending&&(w=u[S]);return new Promise(function(T,C){var v=new Uint8Array(b),F=d++;w.pending+=p,w.requests[F]={resolve:T,reject:C},w.object.postMessage({id:F,count:p,size:y,source:v,mode:E,filter:M},[v.buffer])})}function g(p){a.then(function(){var y=p.data;try{var b=new Uint8Array(y.count*y.size);c(r.exports[y.mode],b,y.count,y.size,y.source,r.exports[y.filter]),self.postMessage({id:y.id,count:y.count,action:"resolve",value:b},[b.buffer])}catch(E){self.postMessage({id:y.id,count:y.count,action:"reject",value:E})}})}return{ready:a,supported:!0,useWorkers:function(p){m(p)},decodeVertexBuffer:function(p,y,b,E,M){c(r.exports.meshopt_decodeVertexBuffer,p,y,b,E,r.exports[l[M]])},decodeIndexBuffer:function(p,y,b,E){c(r.exports.meshopt_decodeIndexBuffer,p,y,b,E)},decodeIndexSequence:function(p,y,b,E){c(r.exports.meshopt_decodeIndexSequence,p,y,b,E)},decodeGltfBuffer:function(p,y,b,E,M,w){c(r.exports[h[M]],p,y,b,E,r.exports[l[w]])},decodeGltfBufferAsync:function(p,y,b,E,M){return u.length>0?A(p,y,b,h[E],l[M]):a.then(function(){var w=new Uint8Array(p*y);return c(r.exports[h[E]],w,p,y,b,r.exports[l[M]]),w})}}})();const kL=Object.freeze(Object.defineProperty({__proto__:null,MeshoptDecoder:PL},Symbol.toStringTag,{value:"Module"}));en.Agent3DElement=ip,en.AgentStageElement=p_,en.Memory=yi,en.Runtime=Jm,en.SceneController=e0,en.Skill=i0,en.SkillRegistry=s0,en.Viewer=Vd,en.defineElement=mL,en.fetchRelative=o_,en.fetchWithFallback=Zm,en.loadManifest=rc,en.normalize=gh,en.resolveURI=ns,Object.defineProperty(en,Symbol.toStringTag,{value:"Module"})}));diff --git a/publish/package.json b/publish/package.jsonnew file mode 100644index 000000000..b0790b752--- /dev/null+++ b/publish/package.json@@ -0,0 +1,42 @@+{+ "name": "three.ws",+ "version": "0.1.0",+ "description": "3D AI agent platform for the browser. Load any GLB/glTF avatar, give it an LLM brain, and embed it as a web component.",+ "author": "nirholas",+ "license": "Apache-2.0",+ "homepage": "https://github.com/nirholas/three.ws#readme",+ "repository": {+ "type": "git",+ "url": "git+https://github.com/nirholas/three.ws.git"+ },+ "bugs": {+ "url": "https://github.com/nirholas/three.ws/issues"+ },+ "keywords": [+ "3d",+ "threejs",+ "gltf",+ "glb",+ "avatar",+ "ai-agent",+ "web-component",+ "llm",+ "webgl"+ ],+ "type": "module",+ "main": "./agent-3d.umd.cjs",+ "module": "./agent-3d.js",+ "exports": {+ ".": {+ "import": "./agent-3d.js",+ "require": "./agent-3d.umd.cjs"+ }+ },+ "files": [+ "agent-3d.js",+ "agent-3d.umd.cjs",+ "LICENSE",+ "README.md"+ ],+ "sideEffects": false+}