PageSourceSearch

https://nammu.finance/vendor/rive-webgl2.min.js?v=20260405pg1

js nammu.finance collected 2026-10-06 03:32:15 UTC 313,578 bytes, 8,538 lines download raw bytes

vendor: 7,301 bytes, lines 1-196
1(function webpackUniversalModuleDefinition(root, factory) {
2	if(typeof exports === 'object' && typeof module === 'object')
3		module.exports = factory();
4	else if(typeof define === 'function' && define.amd)
5		define([], factory);
6	else if(typeof exports === 'object')
7		exports["rive"] = factory();
8	else
9		root["rive"] = factory();
10})(this, () => {
11return /******/ (() => { // webpackBootstrap
12/******/ 	"use strict";
13/******/ 	var __webpack_modules__ = ([
14/* 0 */,
15/* 1 */
16/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
17
18__webpack_require__.r(__webpack_exports__);
19/* harmony export */ __webpack_require__.d(__webpack_exports__, {
20/* harmony export */   Animation: () => (/* reexport safe */ _Animation__WEBPACK_IMPORTED_MODULE_0__.Animation)
21/* harmony export */ });
22/* harmony import */ var _Animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2);
23
24
25
26/***/ }),
27/* 2 */
28/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
29
30__webpack_require__.r(__webpack_exports__);
31/* harmony export */ __webpack_require__.d(__webpack_exports__, {
32/* harmony export */   Animation: () => (/* binding */ Animation)
33/* harmony export */ });
34/**
35 * Represents an animation that can be played on an Artboard.
36 * Wraps animations and instances from the runtime and keeps track of playback state.
37 *
38 * The `Animation` class manages the state and behavior of a single animation instance,
39 * including its current time, loop count, and ability to scrub to a specific time.
40 *
41 * The class provides methods to advance the animation, apply its interpolated keyframe
42 * values to the Artboard, and clean up the underlying animation instance when the
43 * animation is no longer needed.
44 */
45var Animation = /** @class */ (function () {
46    /**
47     * Constructs a new animation
48     * @constructor
49     * @param {any} animation: runtime animation object
50     * @param {any} instance: runtime animation instance object
51     */
52    function Animation(animation, artboard, runtime, playing) {
53        this.animation = animation;
54        this.artboard = artboard;
55        this.playing = playing;
56        this.loopCount = 0;
57        /**
58         * The time to which the animation should move to on the next render.
59         * If not null, the animation will scrub to this time instead of advancing by the given time.
60         */
61        this.scrubTo = null;
62        this.instance = new runtime.LinearAnimationInstance(animation, artboard);
63    }
64    Object.defineProperty(Animation.prototype, "name", {
65        /**
66         * Returns the animation's name
67         */
68        get: function () {
69            return this.animation.name;
70        },
71        enumerable: false,
72        configurable: true
73    });
74    Object.defineProperty(Animation.prototype, "time", {
75        /**
76         * Returns the animation's name
77         */
78        get: function () {
79            return this.instance.time;
80        },
81        /**
82         * Sets the animation's current time
83         */
84        set: function (value) {
85            this.instance.time = value;
86        },
87        enumerable: false,
88        configurable: true
89    });
90    Object.defineProperty(Animation.prototype, "loopValue", {
91        /**
92         * Returns the animation's loop type
93         */
94        get: function () {
95            return this.animation.loopValue;
96        },
97        enumerable: false,
98        configurable: true
99    });
100    Object.defineProperty(Animation.prototype, "needsScrub", {
101        /**
102         * Indicates whether the animation needs to be scrubbed.
103         * @returns `true` if the animation needs to be scrubbed, `false` otherwise.
104         */
105        get: function () {
106            return this.scrubTo !== null;
107        },
108        enumerable: false,
109        configurable: true
110    });
111    /**
112     * Advances the animation by the give time. If the animation needs scrubbing,
113     * time is ignored and the stored scrub value is used.
114     * @param time the time to advance the animation by if no scrubbing required
115     */
116    Animation.prototype.advance = function (time) {
117        if (this.scrubTo === null) {
118            this.instance.advance(time);
119        }
120        else {
121            this.instance.time = 0;
122            this.instance.advance(this.scrubTo);
123            this.scrubTo = null;
124        }
125    };
126    /**
127     * Apply interpolated keyframe values to the artboard. This should be called after calling
128     * .advance() on an animation instance so that new values are applied to properties.
129     *
130     * Note: This does not advance the artboard, which updates all objects on the artboard
131     * @param mix - Mix value for the animation from 0 to 1
132     */
133    Animation.prototype.apply = function (mix) {
134        this.instance.apply(mix);
135    };
136    /**
137     * Deletes the backing Wasm animation instance; once this is called, this
138     * animation is no more.
139     */
140    Animation.prototype.cleanup = function () {
141        this.instance.delete();
142    };
143    return Animation;
144}());
145
146
147
148/***/ }),
149/* 3 */
150/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
151
152__webpack_require__.r(__webpack_exports__);
153/* harmony export */ __webpack_require__.d(__webpack_exports__, {
154/* harmony export */   RuntimeLoader: () => (/* binding */ RuntimeLoader)
155/* harmony export */ });
156/* harmony import */ var _rive_advanced_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4);
157/* harmony import */ var package_json__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5);
158
159
160// Runtime singleton; use getInstance to provide a callback that returns the
161// Rive runtime
162var RuntimeLoader = /** @class */ (function () {
163    // Class is never instantiated
164    function RuntimeLoader() {
165    }
166    // Loads the runtime
167    RuntimeLoader.loadRuntime = function () {
168        if (RuntimeLoader.enablePerfMarks)
169            performance.mark('rive:wasm-init:start');
170        _rive_advanced_mjs__WEBPACK_IMPORTED_MODULE_0__["default"]({
171            // Loads Wasm bundle
172            locateFile: function () { return RuntimeLoader.wasmURL; },
173        })
174            .then(function (rive) {
175            var _a;
176            if (RuntimeLoader.enablePerfMarks) {
177                performance.mark('rive:wasm-init:end');
178                performance.measure('rive:wasm-init', 'rive:wasm-init:start', 'rive:wasm-init:end');
179            }
180            RuntimeLoader.runtime = rive;
181            // Fire all the callbacks
182            while (RuntimeLoader.callBackQueue.length > 0) {
183                (_a = RuntimeLoader.callBackQueue.shift()) === null || _a === void 0 ? void 0 : _a(RuntimeLoader.runtime);
184            }
185        })
186            .catch(function (error) {
187            // Capture specific error details
188            var errorDetails = {
189                message: (error === null || error === void 0 ? void 0 : error.message) || "Unknown error",
190                type: (error === null || error === void 0 ? void 0 : error.name) || "Error",
191                // Some browsers may provide additional WebAssembly-specific details
192                wasmError: error instanceof WebAssembly.CompileError ||
193                    error instanceof WebAssembly.RuntimeError,
194                originalError: error,
195            };
196            // Log detailed error for debugging
197            console.debug("Rive WASM load error details:", errorDetails);
198            // In case unpkg fails, or the wasm was not supported, we try to load the fallback module from jsdelivr.
199            // This `rive_fallback.wasm` is compiled to support older architecture.
200            // TODO: (Gordon): preemptively test browser support and load the correct wasm file. Then use jsdelvr only if unpkg fails.
201            var backupJsdelivrUrl = "https://cdn.jsdelivr.net/npm/".concat(package_json__WEBPACK_IMPORTED_MODULE_1__.name, "@").concat(package_json__WEBPACK_IMPORTED_MODULE_1__.version, "/rive_fallback.wasm");
202            if (RuntimeLoader.wasmURL.toLowerCase() !== backupJsdelivrUrl) {
203                console.warn("Failed to load WASM from ".concat(RuntimeLoader.wasmURL, " (").concat(errorDetails.message, "), trying jsdelivr as a backup"));
204                RuntimeLoader.setWasmUrl(backupJsdelivrUrl);
205                RuntimeLoader.loadRuntime();
206            }
207            else {
208                var errorMessage = [
209                    "Could not load Rive WASM file from ".concat(RuntimeLoader.wasmURL, " or ").concat(backupJsdelivrUrl, "."),
210                    "Possible reasons:",
211                    "- Network connection is down",
212                    "- WebAssembly is not supported in this environment",
213                    "- The WASM file is corrupted or incompatible",
214                    "\nError details:",
215                    "- Type: ".concat(errorDetails.type),
216                    "- Message: ".concat(errorDetails.message),
217                    "- WebAssembly-specific error: ".concat(errorDetails.wasmError),
218                    "\nTo resolve, you may need to:",
219                    "1. Check your network connection",
220                    "2. Set a new WASM source via RuntimeLoader.setWasmUrl()",
221                    "3. Call RuntimeLoader.loadRuntime() again",
222                ].join("\n");
223                console.error(errorMessage);
224            }
225        });
226    };
227    // Provides a runtime instance via a callback
228    RuntimeLoader.getInstance = function (callback) {
229        // If it's not loading, start loading runtime
230        if (!RuntimeLoader.isLoading) {
231            RuntimeLoader.isLoading = true;
232            RuntimeLoader.loadRuntime();
233        }
234        if (!RuntimeLoader.runtime) {
235            RuntimeLoader.callBackQueue.push(callback);
236        }
237        else {
238            callback(RuntimeLoader.runtime);
239        }
240    };
241    // Provides a runtime instance via a promise
242    RuntimeLoader.awaitInstance = function () {
243        return new Promise(function (resolve) {
244            return RuntimeLoader.getInstance(function (rive) { return resolve(rive); });
245        });
246    };
247    // Manually sets the wasm url
248    RuntimeLoader.setWasmUrl = function (url) {
249        RuntimeLoader.wasmURL = url;
250    };
251    // Gets the current wasm url
252    RuntimeLoader.getWasmUrl = function () {
253        return RuntimeLoader.wasmURL;
254    };
255    // Flag to indicate that loading has started/completed
256    RuntimeLoader.isLoading = false;
257    // List of callbacks for the runtime that come in while loading
258    RuntimeLoader.callBackQueue = [];
259    // Path to the Wasm file; default path works for testing only;
260    // if embedded wasm is used then this is never used.
261    RuntimeLoader.wasmURL = "https://unpkg.com/".concat(package_json__WEBPACK_IMPORTED_MODULE_1__.name, "@").concat(package_json__WEBPACK_IMPORTED_MODULE_1__.version, "/rive.wasm");
262    /**
263     * When true, performance.mark / performance.measure entries are emitted for
264     * WASM initialization.
265     */
266    RuntimeLoader.enablePerfMarks = false;
267    return RuntimeLoader;
268}());
269
270
271
272/***/ }),
273/* 4 */
274/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
275
276__webpack_require__.r(__webpack_exports__);
277/* harmony export */ __webpack_require__.d(__webpack_exports__, {
278/* harmony export */   "default": () => (__WEBPACK_DEFAULT_EXPORT__)
279/* harmony export */ });
280
281var Rive = (() => {
282  var _scriptName = typeof document != 'undefined' ? document.currentScript?.src : undefined;
283  
284  return (
285function(moduleArg = {}) {
286  var moduleRtn;
287
288var l = moduleArg, aa, ba, ca = new Promise((a, b) => {
289  aa = a;
290  ba = b;
291}), da = "object" == typeof window, ea = "function" == typeof importScripts;
292function fa() {
293  function a(g) {
294    const k = d;
295    c = b = 0;
296    d = new Map();
297    k.forEach(p => {
298      try {
299        p(g);
300      } catch (m) {
301        console.error(m);
302      }
303    });
304    this.mb();
305    e && e.Mb();
306  }
307  let b = 0, c = 0, d = new Map(), e = null, f = null;
308  this.requestAnimationFrame = function(g) {
309    b ||= requestAnimationFrame(a.bind(this));
310    const k = ++c;
311    d.set(k, g);
312    return k;
313  };
314  this.cancelAnimationFrame = function(g) {
315    d.delete(g);
316    b && 0 == d.size && (cancelAnimationFrame(b), b = 0);
317  };
318  this.Kb = function(g) {
319    f && (document.body.remove(f), f = null);
320    g || (f = document.createElement("div"), f.style.backgroundColor = "black", f.style.position = "fixed", f.style.right = 0, f.style.top = 0, f.style.color = "white", f.style.padding = "4px", f.innerHTML = "RIVE FPS", g = function(k) {
321      f.innerHTML = "RIVE FPS " + k.toFixed(1);
322    }, document.body.appendChild(f));
323    e = new function() {
324      let k = 0, p = 0;
325      this.Mb = function() {
326        var m = performance.now();
327        p ? (++k, m -= p, 1000 < m && (g(1000 * k / m), k = p = 0)) : (p = m, k = 0);
328      };
329    }();
330  };
331  this.mb = function() {
332  };
333}
334function ha() {
335  console.assert(!0);
336  const a = new Map();
337  let b = -Infinity;
338  this.push = function(c) {
339    c = c + 255 >> 8;
340    a.has(c) && clearTimeout(a.get(c));
341    a.set(c, setTimeout(function() {
342      a.delete(c);
343      0 == a.length ? b = -Infinity : c == b && (b = Math.max(...a.keys()), console.assert(b < c));
344    }, 1000));
345    b = Math.max(c, b);
346    return b << 8;
347  };
348}
349const ia = l.onRuntimeInitialized;
350l.onRuntimeInitialized = function() {
351  ia && ia();
352  let a = l.decodeAudio;
353  l.decodeAudio = function(f, g) {
354    f = a(f);
355    g(f);
356  };
357  let b = l.decodeFont;
358  l.decodeFont = function(f, g) {
359    f = b(f);
360    g(f);
361  };
362  let c = l.setFallbackFontCb;
363  l.setFallbackFontCallback = "function" === typeof c ? function(f) {
364    c(f);
365  } : function() {
366    console.warn("Module.setFallbackFontCallback called, but text support is not enabled in this build.");
367  };
368  const d = l.FileAssetLoader;
369  l.ptrToAsset = f => {
370    let g = l.ptrToFileAsset(f);
371    return g.isImage ? l.ptrToImageAsset(f) : g.isFont ? l.ptrToFontAsset(f) : g.isAudio ? l.ptrToAudioAsset(f) : g;
372  };
373  l.CustomFileAssetLoader = d.extend("CustomFileAssetLoader", {__construct:function({loadContents:f}) {
374    this.__parent.__construct.call(this);
375    this.Bb = f;
376  }, loadContents:function(f, g) {
377    f = l.ptrToAsset(f);
378    return this.Bb(f, g);
379  },});
380  l.CDNFileAssetLoader = d.extend("CDNFileAssetLoader", {__construct:function() {
381    this.__parent.__construct.call(this);
382  }, loadContents:function(f) {
383    let g = l.ptrToAsset(f);
384    f = g.cdnUuid;
385    if ("" === f) {
386      return !1;
387    }
388    (function(k, p) {
389      var m = new XMLHttpRequest();
390      m.responseType = "arraybuffer";
391      m.onreadystatechange = function() {
392        4 == m.readyState && 200 == m.status && p(m);
393      };
394      m.open("GET", k, !0);
395      m.send(null);
396    })(g.cdnBaseUrl + "/" + f, k => {
397      g.decode(new Uint8Array(k.response));
398    });
399    return !0;
400  },});
401  l.FallbackFileAssetLoader = d.extend("FallbackFileAssetLoader", {__construct:function() {
402    this.__parent.__construct.call(this);
403    this.ib = [];
404  }, addLoader:function(f) {
405    this.ib.push(f);
406  }, loadContents:function(f, g) {
407    for (let k of this.ib) {
408      if (k.loadContents(f, g)) {
409        return !0;
410      }
411    }
412    return !1;
413  },});
414  let e = l.computeAlignment;
415  l.computeAlignment = function(f, g, k, p, m = 1.0) {
416    return e.call(this, f, g, k, p, m);
417  };
418};
419const ja = l.onRuntimeInitialized;
420l.onRuntimeInitialized = function() {
421  function a(r) {
422    this.G = r;
423    this.Ab = r.getContext("2d");
424    this.Db = d;
425    this.S = [];
426    this.ka = 0;
427    this.clear = function() {
428      console.assert(0 == this.ka);
429      this.S = [];
430      e.delete(this);
431    };
432    this.save = function() {
433      ++this.ka;
434      this.S.push(d.save.bind(d));
435    };
436    this.restore = function() {
437      0 < this.ka && (this.S.push(d.restore.bind(d)), --this.ka);
438    };
439    this.transform = function(u) {
440      this.S.push(d.transform.bind(d, u));
441    };
442    this.align = function(u, z, A, C, G = 1.0) {
443      this.S.push(d.align.bind(d, u, z, A, C, G));
444    };
445    this.flush = function() {
446      console.assert(0 == this.ka);
447      e.add(this);
448      d.Ya || c();
449    };
450    this["delete"] = function() {
451    };
452  }
453  function b(r, u = !1) {
454    var z = {alpha:!0, depth:u, stencil:u, antialias:u, premultipliedAlpha:!0, preserveDrawingBuffer:0, powerPreference:"high-performance", failIfMajorPerformanceCaveat:0, enableExtensionsByDefault:!1, explicitSwapControl:0, renderViaOffscreenBackBuffer:0,};
455    u = r.getContext("webgl2", z);
456    if (!u) {
457      return null;
458    }
459    z = ka(u, z);
460    la(z);
461    const A = f(r.width, r.height);
462    A.La = z;
463    A.G = r;
464    A.Ma = r.width;
465    A.Za = r.height;
466    A.T = u;
467    var C = A.delete;
468    A.delete = function() {
469      C.call(this);
470      var G = this.La;
471      q === w[G] && (q = null);
472      "object" == typeof JSEvents && JSEvents.Kc(w[G].C.canvas);
473      w[G] && w[G].C.canvas && (w[G].C.canvas.zb = void 0);
474      this.La = this.G = this.Ma = this.T = w[G] = null;
475    };
476    return A;
477  }
478  function c() {
479    if (d) {
480      var r = d.Cb, u = 0, z = 0, A = 0, C = Array(e.size), G = 0;
481      for (var J of e) {
482        J.fa = Math.min(J.G.width, r), J.ea = Math.min(J.G.height, r), J.Ja = J.ea * J.fa, u = Math.max(u, J.fa), z = Math.max(z, J.ea), A += J.Ja, C[G++] = J;
483      }
484      e.clear();
485      if (!(0 >= A)) {
486        u = 1 << (0 >= u ? 0 : 32 - Math.clz32(u - 1));
487        for (z = 1 << (0 >= z ? 0 : 32 - Math.clz32(z - 1)); z * u < A;) {
488          u <= z ? u *= 2 : z *= 2;
489        }
490        u = Math.min(u, r);
491        u = Math.min(z, r);
492        C.sort((Z, ob) => ob.Ja - Z.Ja);
493        A = new l.DynamicRectanizer(r);
494        for (J = 0; J < C.length;) {
495          A.reset(u, z);
496          for (G = J; G < C.length; ++G) {
497            var K = C[G], I = A.addRect(K.fa, K.ea);
498            if (0 > I) {
499              console.assert(G > J);
500              break;
501            }
502            K.qa = I & 65535;
503            K.ra = I >> 16;
504          }
505          K = p.push(A.drawWidth());
506          I = m.push(A.drawHeight());
507          console.assert(K >= A.drawWidth());
508          console.assert(I >= A.drawHeight());
509          console.assert(K <= r);
510          console.assert(I <= r);
511          d.G.width != K && (d.G.width = K);
512          d.G.height != I && (d.G.height = I);
513          d.clear();
514          for (K = J; K < G; ++K) {
515            I = C[K];
516            d.saveClipRect(I.qa, I.ra, I.qa + I.fa, I.ra + I.ea);
517            let Z = new l.Mat2D();
518            Z.xx = I.fa / I.G.width;
519            Z.yy = I.ea / I.G.height;
520            Z.xy = Z.yx = 0;
521            Z.tx = I.qa;
522            Z.ty = I.ra;
523            d.transform(Z);
524            for (const ob of I.S) {
525              ob();
526            }
527            d.restoreClipRect();
528            I.S = [];
529          }
530          for (d.flush(); J < G; ++J) {
531            K = C[J], I = K.Ab, I.globalCompositeOperation = "copy", I.drawImage(d.G, K.qa, K.ra, K.fa, K.ea, 0, 0, K.G.width, K.G.height);
532          }
533          J = G;
534        }
535      }
536    }
537  }
538  ja && ja();
539  let d = null;
540  const e = new Set(), f = l.makeRenderer;
541  l.makeRenderer = function(r, u) {
542    if (!d) {
543      function z(A) {
544        var C = document.createElement("canvas");
545        C.width = 1;
546        C.height = 1;
547        d = b(C, A);
548        d.Ya = !!d.T.getExtension("WEBGL_shader_pixel_local_storage");
549        d.Cb = Math.min(d.T.getParameter(d.T.MAX_RENDERBUFFER_SIZE), d.T.getParameter(d.T.MAX_TEXTURE_SIZE));
550        d.Ka = !d.Ya;
551        if (A = d.T.getExtension("WEBGL_debug_renderer_info")) {
552          C = d.T.getParameter(A.UNMASKED_RENDERER_WEBGL), d.T.getParameter(A.UNMASKED_VENDOR_WEBGL).includes("Google") && C.includes("ANGLE Metal Renderer") && (d.Ka = !1);
553        }
554        return d;
555      }
556      d = z(!0);
557      d.Ka || (d = z(!1));
558    }
559    return u ? new a(r) : b(r, d.Ka);
560  };
561  const g = l.Artboard.prototype["delete"];
562  l.Artboard.prototype["delete"] = function() {
563    this.Eb = !0;
564    g.call(this);
565  };
566  const k = l.Artboard.prototype.draw;
567  l.Artboard.prototype.draw = function(r) {
568    r.S ? r.S.push(() => {
569      this.Eb || k.call(this, r.Db);
570    }) : k.call(this, r);
571  };
572  const p = new ha(), m = new ha(), t = new fa();
573  l.requestAnimationFrame = t.requestAnimationFrame.bind(t);
574  l.cancelAnimationFrame = t.cancelAnimationFrame.bind(t);
575  l.enableFPSCounter = t.Kb.bind(t);
576  t.mb = c;
577  l.resolveAnimationFrame = c;
578  let v = l.load;
579  l.load = function(r, u, z = !0) {
580    const A = new l.FallbackFileAssetLoader();
581    void 0 !== u && A.addLoader(u);
582    z && (u = new l.CDNFileAssetLoader(), A.addLoader(u));
583    return Promise.resolve(v(r, A));
584  };
585  const x = l.WebGL2Renderer.prototype.clear;
586  l.WebGL2Renderer.prototype.clear = function() {
587    la(this.La);
588    const r = this.G;
589    if (this.Ma != r.width || this.Za != r.height) {
590      this.resize(r.width, r.height), this.Ma = r.width, this.Za = r.height;
591    }
592    x.call(this);
593  };
594  l.decodeImage = function(r, u) {
595    r = l.decodeWebGL2Image(r);
596    u(r);
597  };
598  let n = l.Renderer.prototype.align;
599  l.Renderer.prototype.align = function(r, u, z, A, C = 1.0) {
600    n.call(this, r, u, z, A, C);
601  };
602};
603var ma = Object.assign({}, l), na = "./this.program", y = "", oa, pa;
604if (da || ea) {
605  ea ? y = self.location.href : "undefined" != typeof document && document.currentScript && (y = document.currentScript.src), _scriptName && (y = _scriptName), y.startsWith("blob:") ? y = "" : y = y.substr(0, y.replace(/[?#].*/, "").lastIndexOf("/") + 1), ea && (pa = a => {
606    var b = new XMLHttpRequest();
607    b.open("GET", a, !1);
608    b.responseType = "arraybuffer";
609    b.send(null);
610    return new Uint8Array(b.response);
611  }), oa = (a, b, c) => {
612    if (qa(a)) {
613      var d = new XMLHttpRequest();
614      d.open("GET", a, !0);
615      d.responseType = "arraybuffer";
616      d.onload = () => {
617        200 == d.status || 0 == d.status && d.response ? b(d.response) : c();
618      };
619      d.onerror = c;
620      d.send(null);
621    } else {
622      fetch(a, {credentials:"same-origin"}).then(e => e.ok ? e.arrayBuffer() : Promise.reject(Error(e.status + " : " + e.url))).then(b, c);
623    }
624  };
625}
626var ra = l.print || console.log.bind(console), sa = l.printErr || console.error.bind(console);
627Object.assign(l, ma);
628ma = null;
629l.thisProgram && (na = l.thisProgram);
630var ta;
631l.wasmBinary && (ta = l.wasmBinary);
632var ua, va = !1, B, D, E, wa, F, H, xa, ya;
633function za() {
634  var a = ua.buffer;
635  l.HEAP8 = B = new Int8Array(a);
636  l.HEAP16 = E = new Int16Array(a);
637  l.HEAPU8 = D = new Uint8Array(a);
638  l.HEAPU16 = wa = new Uint16Array(a);
639  l.HEAP32 = F = new Int32Array(a);
640  l.HEAPU32 = H = new Uint32Array(a);
641  l.HEAPF32 = xa = new Float32Array(a);
642  l.HEAPF64 = ya = new Float64Array(a);
643}
644var Aa = [], Ba = [], Ca = [];
645function Da() {
646  var a = l.preRun.shift();
647  Aa.unshift(a);
648}
649var Ea = 0, Fa = null, Ga = null;
650function Ha(a) {
651  l.onAbort?.(a);
652  a = "Aborted(" + a + ")";
653  sa(a);
654  va = !0;
655  a = new WebAssembly.RuntimeError(a + ". Build with -sASSERTIONS for more info.");
656  ba(a);
657  throw a;
658}
659var Ia = a => a.startsWith("data:application/octet-stream;base64,"), qa = a => a.startsWith("file://"), Ja;
660function Ka(a) {
661  if (a == Ja && ta) {
662    return new Uint8Array(ta);
663  }
664  if (pa) {
665    return pa(a);
666  }
667  throw "both async and sync fetching of the wasm failed";
668}
669function La(a) {
670  return ta ? Promise.resolve().then(() => Ka(a)) : new Promise((b, c) => {
671    oa(a, d => b(new Uint8Array(d)), () => {
672      try {
673        b(Ka(a));
674      } catch (d) {
675        c(d);
676      }
677    });
678  });
679}
680function Ma(a, b, c) {
681  return La(a).then(d => WebAssembly.instantiate(d, b)).then(c, d => {
682    sa(`failed to asynchronously prepare wasm: ${d}`);
683    Ha(d);
684  });
685}
686function Na(a, b) {
687  var c = Ja;
688  return ta || "function" != typeof WebAssembly.instantiateStreaming || Ia(c) || qa(c) || "function" != typeof fetch ? Ma(c, a, b) : fetch(c, {credentials:"same-origin"}).then(d => WebAssembly.instantiateStreaming(d, a).then(b, function(e) {
689    sa(`wasm streaming compile failed: ${e}`);
690    sa("falling back to ArrayBuffer instantiation");
691    return Ma(c, a, b);
692  }));
693}
694var Oa, Pa, Ta = {563953:(a, b, c, d, e) => {
695  if ("undefined" === typeof window || void 0 === (window.AudioContext || window.webkitAudioContext)) {
696    return 0;
697  }
698  if ("undefined" === typeof window.h) {
699    window.h = {Ea:0};
700    window.h.I = {};
701    window.h.I.Ca = a;
702    window.h.I.capture = b;
703    window.h.I.Pa = c;
704    window.h.ia = {};
705    window.h.ia.stopped = d;
706    window.h.ia.ub = e;
707    let f = window.h;
708    f.D = [];
709    f.lc = function(g) {
710      for (var k = 0; k < f.D.length; ++k) {
711        if (null == f.D[k]) {
712          return f.D[k] = g, k;
713        }
714      }
715      f.D.push(g);
716      return f.D.length - 1;
717    };
718    f.yb = function(g) {
719      for (f.D[g] = null; 0 < f.D.length;) {
720        if (null == f.D[f.D.length - 1]) {
721          f.D.pop();
722        } else {
723          break;
724        }
725      }
726    };
727    f.Mc = function(g) {
728      for (var k = 0; k < f.D.length; ++k) {
729        if (f.D[k] == g) {
730          return f.yb(k);
731        }
732      }
733    };
734    f.ta = function(g) {
735      return f.D[g];
736    };
737    f.Xa = ["touchend", "click"];
738    f.unlock = function() {
739      for (var g = 0; g < f.D.length; ++g) {
740        var k = f.D[g];
741        null != k && null != k.K && k.state === f.ia.ub && k.K.resume().then(() => {
742          Qa(k.nb);
743        }, p => {
744          console.error("Failed to resume audiocontext", p);
745        });
746      }
747      f.Xa.map(function(p) {
748        document.removeEventListener(p, f.unlock, !0);
749      });
750    };
751    f.Xa.map(function(g) {
752      document.addEventListener(g, f.unlock, !0);
753    });
754  }
755  window.h.Ea += 1;
756  return 1;
757}, 566131:() => {
758  "undefined" !== typeof window.h && (window.h.Xa.map(function(a) {
759    document.removeEventListener(a, window.h.unlock, !0);
760  }), --window.h.Ea, 0 === window.h.Ea && delete window.h);
761}, 566435:() => void 0 !== navigator.mediaDevices && void 0 !== navigator.mediaDevices.getUserMedia, 566539:() => {
762  try {
763    var a = new (window.AudioContext || window.webkitAudioContext)(), b = a.sampleRate;
764    a.close();
765    return b;
766  } catch (c) {
767    return 0;
768  }
769}, 566710:(a, b, c, d, e, f) => {
770  if ("undefined" === typeof window.h) {
771    return -1;
772  }
773  var g = {}, k = {};
774  a == window.h.I.Ca && 0 != c && (k.sampleRate = c);
775  g.K = new (window.AudioContext || window.webkitAudioContext)(k);
776  g.K.suspend();
777  g.state = window.h.ia.stopped;
778  c = 0;
779  a != window.h.I.Ca && (c = b);
780  g.Y = g.K.createScriptProcessor(d, c, b);
781  g.Y.onaudioprocess = function(p) {
782    if (null == g.ua || 0 == g.ua.length) {
783      g.ua = new Float32Array(xa.buffer, e, d * b);
784    }
785    if (a == window.h.I.capture || a == window.h.I.Pa) {
786      for (var m = 0; m < b; m += 1) {
787        for (var t = p.inputBuffer.getChannelData(m), v = g.ua, x = 0; x < d; x += 1) {
788          v[x * b + m] = t[x];
789        }
790      }
791      Ra(f, d, e);
792    }
793    if (a == window.h.I.Ca || a == window.h.I.Pa) {
794      for (Sa(f, d, e), m = 0; m < p.outputBuffer.numberOfChannels; ++m) {
795        for (t = p.outputBuffer.getChannelData(m), v = g.ua, x = 0; x < d; x += 1) {
796          t[x] = v[x * b + m];
797        }
798      }
799    } else {
800      for (m = 0; m < p.outputBuffer.numberOfChannels; ++m) {
801        p.outputBuffer.getChannelData(m).fill(0.0);
802      }
803    }
804  };
805  a != window.h.I.capture && a != window.h.I.Pa || navigator.mediaDevices.getUserMedia({audio:!0, video:!1}).then(function(p) {
806    g.Fa = g.K.createMediaStreamSource(p);
807    g.Fa.connect(g.Y);
808    g.Y.connect(g.K.destination);
809  }).catch(function(p) {
810    console.log("Failed to get user media: " + p);
811  });
812  a == window.h.I.Ca && g.Y.connect(g.K.destination);
813  g.nb = f;
814  return window.h.lc(g);
815}, 569587:a => window.h.ta(a).K.sampleRate, 569660:a => {
816  a = window.h.ta(a);
817  void 0 !== a.Y && (a.Y.onaudioprocess = function() {
818  }, a.Y.disconnect(), a.Y = void 0);
819  void 0 !== a.Fa && (a.Fa.disconnect(), a.Fa = void 0);
820  a.K.close();
821  a.K = void 0;
822  a.nb = void 0;
823}, 570060:a => {
824  window.h.yb(a);
825}, 570110:a => {
826  a = window.h.ta(a);
827  a.K.resume();
828  a.state = window.h.ia.ub;
829}, 570249:a => {
830  a = window.h.ta(a);
831  a.K.suspend();
832  a.state = window.h.ia.stopped;
833}}, Ua = a => {
834  for (; 0 < a.length;) {
835    a.shift()(l);
836  }
837};
838function Va() {
839  var a = F[+Wa >> 2];
840  Wa += 4;
841  return a;
842}
843var Xa = (a, b) => {
844  for (var c = 0, d = a.length - 1; 0 <= d; d--) {
845    var e = a[d];
846    "." === e ? a.splice(d, 1) : ".." === e ? (a.splice(d, 1), c++) : c && (a.splice(d, 1), c--);
847  }
848  if (b) {
849    for (; c; c--) {
850      a.unshift("..");
851    }
852  }
853  return a;
854}, Ya = a => {
855  var b = "/" === a.charAt(0), c = "/" === a.substr(-1);
856  (a = Xa(a.split("/").filter(d => !!d), !b).join("/")) || b || (a = ".");
857  a && c && (a += "/");
858  return (b ? "/" : "") + a;
859}, Za = a => {
860  var b = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(a).slice(1);
861  a = b[0];
862  b = b[1];
863  if (!a && !b) {
864    return ".";
865  }
866  b &&= b.substr(0, b.length - 1);
867  return a + b;
868}, $a = a => {
869  if ("/" === a) {
870    return "/";
871  }
872  a = Ya(a);
873  a = a.replace(/\/$/, "");
874  var b = a.lastIndexOf("/");
875  return -1 === b ? a : a.substr(b + 1);
876}, ab = () => {
877  if ("object" == typeof crypto && "function" == typeof crypto.getRandomValues) {
878    return a => crypto.getRandomValues(a);
879  }
880  Ha("initRandomDevice");
881}, bb = a => (bb = ab())(a), cb = (...a) => {
882  for (var b = "", c = !1, d = a.length - 1; -1 <= d && !c; d--) {
883    c = 0 <= d ? a[d] : "/";
884    if ("string" != typeof c) {
885      throw new TypeError("Arguments to path.resolve must be strings");
886    }
887    if (!c) {
888      return "";
889    }
890    b = c + "/" + b;
891    c = "/" === c.charAt(0);
892  }
893  b = Xa(b.split("/").filter(e => !!e), !c).join("/");
894  return (c ? "/" : "") + b || ".";
895}, db = "undefined" != typeof TextDecoder ? new TextDecoder("utf8") : void 0, L = (a, b, c) => {
896  var d = b + c;
897  for (c = b; a[c] && !(c >= d);) {
898    ++c;
899  }
900  if (16 < c - b && a.buffer && db) {
901    return db.decode(a.subarray(b, c));
902  }
903  for (d = ""; b < c;) {
904    var e = a[b++];
905    if (e & 128) {
906      var f = a[b++] & 63;
907      if (192 == (e & 224)) {
908        d += String.fromCharCode((e & 31) << 6 | f);
909      } else {
910        var g = a[b++] & 63;
911        e = 224 == (e & 240) ? (e & 15) << 12 | f << 6 | g : (e & 7) << 18 | f << 12 | g << 6 | a[b++] & 63;
912        65536 > e ? d += String.fromCharCode(e) : (e -= 65536, d += String.fromCharCode(55296 | e >> 10, 56320 | e & 1023));
913      }
914    } else {
915      d += String.fromCharCode(e);
916    }
917  }
918  return d;
919}, eb = [], fb = a => {
920  for (var b = 0, c = 0; c < a.length; ++c) {
921    var d = a.charCodeAt(c);
922    127 >= d ? b++ : 2047 >= d ? b += 2 : 55296 <= d && 57343 >= d ? (b += 4, ++c) : b += 3;
923  }
924  return b;
925}, gb = (a, b, c, d) => {
926  if (!(0 < d)) {
927    return 0;
928  }
929  var e = c;
930  d = c + d - 1;
931  for (var f = 0; f < a.length; ++f) {
932    var g = a.charCodeAt(f);
933    if (55296 <= g && 57343 >= g) {
934      var k = a.charCodeAt(++f);
935      g = 65536 + ((g & 1023) << 10) | k & 1023;
936    }
937    if (127 >= g) {
938      if (c >= d) {
939        break;
940      }
941      b[c++] = g;
942    } else {
943      if (2047 >= g) {
944        if (c + 1 >= d) {
945          break;
946        }
947        b[c++] = 192 | g >> 6;
948      } else {
949        if (65535 >= g) {
950          if (c + 2 >= d) {
951            break;
952          }
953          b[c++] = 224 | g >> 12;
954        } else {
955          if (c + 3 >= d) {
956            break;
957          }
958          b[c++] = 240 | g >> 18;
959          b[c++] = 128 | g >> 12 & 63;
960        }
961        b[c++] = 128 | g >> 6 & 63;
962      }
963      b[c++] = 128 | g & 63;
964    }
965  }
966  b[c] = 0;
967  return c - e;
968};
969function hb(a, b) {
970  var c = Array(fb(a) + 1);
971  a = gb(a, c, 0, c.length);
972  b && (c.length = a);
973  return c;
974}
975var ib = [];
976function jb(a, b) {
977  ib[a] = {input:[], H:[], V:b};
978  kb(a, lb);
979}
980var lb = {open(a) {
981  var b = ib[a.node.Da];
982  if (!b) {
983    throw new M(43);
984  }
985  a.s = b;
986  a.seekable = !1;
987}, close(a) {
988  a.s.V.sa(a.s);
989}, sa(a) {
990  a.s.V.sa(a.s);
991}, read(a, b, c, d) {
992  if (!a.s || !a.s.V.hb) {
993    throw new M(60);
994  }
995  for (var e = 0, f = 0; f < d; f++) {
996    try {
997      var g = a.s.V.hb(a.s);
998    } catch (k) {
999      throw new M(29);
1000    }
1001    if (void 0 === g && 0 === e) {
1002      throw new M(6);
1003    }
1004    if (null === g || void 0 === g) {
1005      break;
1006    }
1007    e++;
1008    b[c + f] = g;
1009  }
1010  e && (a.node.timestamp = Date.now());
1011  return e;
1012}, write(a, b, c, d) {
1013  if (!a.s || !a.s.V.Sa) {
1014    throw new M(60);
1015  }
1016  try {
1017    for (var e = 0; e < d; e++) {
1018      a.s.V.Sa(a.s, b[c + e]);
1019    }
1020  } catch (f) {
1021    throw new M(29);
1022  }
1023  d && (a.node.timestamp = Date.now());
1024  return e;
1025},}, mb = {hb() {
1026  a: {
1027    if (!eb.length) {
1028      var a = null;
1029      "undefined" != typeof window && "function" == typeof window.prompt && (a = window.prompt("Input: "), null !== a && (a += "\n"));
1030      if (!a) {
1031        a = null;
1032        break a;
1033      }
1034      eb = hb(a, !0);
1035    }
1036    a = eb.shift();
1037  }
1038  return a;
1039}, Sa(a, b) {
1040  null === b || 10 === b ? (ra(L(a.H, 0)), a.H = []) : 0 != b && a.H.push(b);
1041}, sa(a) {
1042  a.H && 0 < a.H.length && (ra(L(a.H, 0)), a.H = []);
1043}, Vb() {
1044  return {sc:25856, uc:5, rc:191, tc:35387, qc:[3, 28, 127, 21, 4, 0, 1, 0, 17, 19, 26, 0, 18, 15, 23, 22, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,]};
1045}, Wb() {
1046  return 0;
1047}, Xb() {
1048  return [24, 80];
1049},}, nb = {Sa(a, b) {
1050  null === b || 10 === b ? (sa(L(a.H, 0)), a.H = []) : 0 != b && a.H.push(b);
1051}, sa(a) {
1052  a.H && 0 < a.H.length && (sa(L(a.H, 0)), a.H = []);
1053},};
1054function pb(a, b) {
1055  var c = a.l ? a.l.length : 0;
1056  c >= b || (b = Math.max(b, c * (1048576 > c ? 2.0 : 1.125) >>> 0), 0 != c && (b = Math.max(b, 256)), c = a.l, a.l = new Uint8Array(b), 0 < a.v && a.l.set(c.subarray(0, a.v), 0));
1057}
1058var N = {N:null, U() {
1059  return N.createNode(null, "/", 16895, 0);
1060}, createNode(a, b, c, d) {
1061  if (24576 === (c & 61440) || 4096 === (c & 61440)) {
1062    throw new M(63);
1063  }
1064  N.N || (N.N = {dir:{node:{X:N.j.X, P:N.j.P, la:N.j.la, Aa:N.j.Aa, sb:N.j.sb, xb:N.j.xb, tb:N.j.tb, rb:N.j.rb, Ga:N.j.Ga}, stream:{aa:N.m.aa}}, file:{node:{X:N.j.X, P:N.j.P}, stream:{aa:N.m.aa, read:N.m.read, write:N.m.write, $a:N.m.$a, jb:N.m.jb, lb:N.m.lb}}, link:{node:{X:N.j.X, P:N.j.P, ma:N.j.ma}, stream:{}}, ab:{node:{X:N.j.X, P:N.j.P}, stream:qb}});
1065  c = rb(a, b, c, d);
1066  16384 === (c.mode & 61440) ? (c.j = N.N.dir.node, c.m = N.N.dir.stream, c.l = {}) : 32768 === (c.mode & 61440) ? (c.j = N.N.file.node, c.m = N.N.file.stream, c.v = 0, c.l = null) : 40960 === (c.mode & 61440) ? (c.j = N.N.link.node, c.m = N.N.link.stream) : 8192 === (c.mode & 61440) && (c.j = N.N.ab.node, c.m = N.N.ab.stream);
1067  c.timestamp = Date.now();
1068  a && (a.l[b] = c, a.timestamp = c.timestamp);
1069  return c;
1070}, Ac(a) {
1071  return a.l ? a.l.subarray ? a.l.subarray(0, a.v) : new Uint8Array(a.l) : new Uint8Array(0);
1072}, j:{X(a) {
1073  var b = {};
1074  b.xc = 8192 === (a.mode & 61440) ? a.id : 1;
1075  b.Cc = a.id;
1076  b.mode = a.mode;
1077  b.Hc = 1;
1078  b.uid = 0;
1079  b.Bc = 0;
1080  b.Da = a.Da;
1081  16384 === (a.mode & 61440) ? b.size = 4096 : 32768 === (a.mode & 61440) ? b.size = a.v : 40960 === (a.mode & 61440) ? b.size = a.link.length : b.size = 0;
1082  b.oc = new Date(a.timestamp);
1083  b.Gc = new Date(a.timestamp);
1084  b.vc = new Date(a.timestamp);
1085  b.Fb = 4096;
1086  b.pc = Math.ceil(b.size / b.Fb);
1087  return b;
1088}, P(a, b) {
1089  void 0 !== b.mode && (a.mode = b.mode);
1090  void 0 !== b.timestamp && (a.timestamp = b.timestamp);
1091  if (void 0 !== b.size && (b = b.size, a.v != b)) {
1092    if (0 == b) {
1093      a.l = null, a.v = 0;
1094    } else {
1095      var c = a.l;
1096      a.l = new Uint8Array(b);
1097      c && a.l.set(c.subarray(0, Math.min(b, a.v)));
1098      a.v = b;
1099    }
1100  }
1101}, la() {
1102  throw sb[44];
1103}, Aa(a, b, c, d) {
1104  return N.createNode(a, b, c, d);
1105}, sb(a, b, c) {
1106  if (16384 === (a.mode & 61440)) {
1107    try {
1108      var d = tb(b, c);
1109    } catch (f) {
1110    }
1111    if (d) {
1112      for (var e in d.l) {
1113        throw new M(55);
1114      }
1115    }
1116  }
1117  delete a.parent.l[a.name];
1118  a.parent.timestamp = Date.now();
1119  a.name = c;
1120  b.l[c] = a;
1121  b.timestamp = a.parent.timestamp;
1122}, xb(a, b) {
1123  delete a.l[b];
1124  a.timestamp = Date.now();
1125}, tb(a, b) {
1126  var c = tb(a, b), d;
1127  for (d in c.l) {
1128    throw new M(55);
1129  }
1130  delete a.l[b];
1131  a.timestamp = Date.now();
1132}, rb(a) {
1133  var b = [".", ".."], c;
1134  for (c of Object.keys(a.l)) {
1135    b.push(c);
1136  }
1137  return b;
1138}, Ga(a, b, c) {
1139  a = N.createNode(a, b, 41471, 0);
1140  a.link = c;
1141  return a;
1142}, ma(a) {
1143  if (40960 !== (a.mode & 61440)) {
1144    throw new M(28);
1145  }
1146  return a.link;
1147},}, m:{read(a, b, c, d, e) {
1148  var f = a.node.l;
1149  if (e >= a.node.v) {
1150    return 0;
1151  }
1152  a = Math.min(a.node.v - e, d);
1153  if (8 < a && f.subarray) {
1154    b.set(f.subarray(e, e + a), c);
1155  } else {
1156    for (d = 0; d < a; d++) {
1157      b[c + d] = f[e + d];
1158    }
1159  }
1160  return a;
1161}, write(a, b, c, d, e, f) {
1162  b.buffer === B.buffer && (f = !1);
1163  if (!d) {
1164    return 0;
1165  }
1166  a = a.node;
1167  a.timestamp = Date.now();
1168  if (b.subarray && (!a.l || a.l.subarray)) {
1169    if (f) {
1170      return a.l = b.subarray(c, c + d), a.v = d;
1171    }
1172    if (0 === a.v && 0 === e) {
1173      return a.l = b.slice(c, c + d), a.v = d;
1174    }
1175    if (e + d <= a.v) {
1176      return a.l.set(b.subarray(c, c + d), e), d;
1177    }
1178  }
1179  pb(a, e + d);
1180  if (a.l.subarray && b.subarray) {
1181    a.l.set(b.subarray(c, c + d), e);
1182  } else {
1183    for (f = 0; f < d; f++) {
1184      a.l[e + f] = b[c + f];
1185    }
1186  }
1187  a.v = Math.max(a.v, e + d);
1188  return d;
1189}, aa(a, b, c) {
1190  1 === c ? b += a.position : 2 === c && 32768 === (a.node.mode & 61440) && (b += a.node.v);
1191  if (0 > b) {
1192    throw new M(28);
1193  }
1194  return b;
1195}, $a(a, b, c) {
1196  pb(a.node, b + c);
1197  a.node.v = Math.max(a.node.v, b + c);
1198}, jb(a, b, c, d, e) {
1199  if (32768 !== (a.node.mode & 61440)) {
1200    throw new M(43);
1201  }
1202  a = a.node.l;
1203  if (e & 2 || a.buffer !== B.buffer) {
1204    if (0 < c || c + b < a.length) {
1205      a.subarray ? a = a.subarray(c, c + b) : a = Array.prototype.slice.call(a, c, c + b);
1206    }
1207    c = !0;
1208    Ha();
1209    b = void 0;
1210    if (!b) {
1211      throw new M(48);
1212    }
1213    B.set(a, b);
1214  } else {
1215    c = !1, b = a.byteOffset;
1216  }
1217  return {o:b, nc:c};
1218}, lb(a, b, c, d) {
1219  N.m.write(a, b, 0, d, c, !1);
1220  return 0;
1221},},}, ub = (a, b) => {
1222  var c = 0;
1223  a && (c |= 365);
1224  b && (c |= 146);
1225  return c;
1226}, vb = null, wb = {}, xb = [], yb = 1, zb = null, Ab = !0, M = class {
1227  constructor(a) {
1228    this.name = "ErrnoError";
1229    this.$ = a;
1230  }
1231}, sb = {}, Bb = class {
1232  constructor() {
1233    this.h = {};
1234    this.node = null;
1235  }
1236  get flags() {
1237    return this.h.flags;
1238  }
1239  set flags(a) {
1240    this.h.flags = a;
1241  }
1242  get position() {
1243    return this.h.position;
1244  }
1245  set position(a) {
1246    this.h.position = a;
1247  }
1248}, Cb = class {
1249  constructor(a, b, c, d) {
1250    a ||= this;
1251    this.parent = a;
1252    this.U = a.U;
1253    this.Ba = null;
1254    this.id = yb++;
1255    this.name = b;
1256    this.mode = c;
1257    this.j = {};
1258    this.m = {};
1259    this.Da = d;
1260  }
1261  get read() {
1262    return 365 === (this.mode & 365);
1263  }
1264  set read(a) {
1265    a ? this.mode |= 365 : this.mode &= -366;
1266  }
1267  get write() {
1268    return 146 === (this.mode & 146);
1269  }
1270  set write(a) {
1271    a ? this.mode |= 146 : this.mode &= -147;
1272  }
1273};
1274function Db(a, b = {}) {
1275  a = cb(a);
1276  if (!a) {
1277    return {path:"", node:null};
1278  }
1279  b = Object.assign({gb:!0, Ua:0}, b);
1280  if (8 < b.Ua) {
1281    throw new M(32);
1282  }
1283  a = a.split("/").filter(g => !!g);
1284  for (var c = vb, d = "/", e = 0; e < a.length; e++) {
1285    var f = e === a.length - 1;
1286    if (f && b.parent) {
1287      break;
1288    }
1289    c = tb(c, a[e]);
1290    d = Ya(d + "/" + a[e]);
1291    c.Ba && (!f || f && b.gb) && (c = c.Ba.root);
1292    if (!f || b.fb) {
1293      for (f = 0; 40960 === (c.mode & 61440);) {
1294        if (c = Eb(d), d = cb(Za(d), c), c = Db(d, {Ua:b.Ua + 1}).node, 40 < f++) {
1295          throw new M(32);
1296        }
1297      }
1298    }
1299  }
1300  return {path:d, node:c};
1301}
1302function Fb(a) {
1303  for (var b;;) {
1304    if (a === a.parent) {
1305      return a = a.U.kb, b ? "/" !== a[a.length - 1] ? `${a}/${b}` : a + b : a;
1306    }
1307    b = b ? `${a.name}/${b}` : a.name;
1308    a = a.parent;
1309  }
1310}
1311function Gb(a, b) {
1312  for (var c = 0, d = 0; d < b.length; d++) {
1313    c = (c << 5) - c + b.charCodeAt(d) | 0;
1314  }
1315  return (a + c >>> 0) % zb.length;
1316}
1317function tb(a, b) {
1318  var c = 16384 === (a.mode & 61440) ? (c = Hb(a, "x")) ? c : a.j.la ? 0 : 2 : 54;
1319  if (c) {
1320    throw new M(c);
1321  }
1322  for (c = zb[Gb(a.id, b)]; c; c = c.$b) {
1323    var d = c.name;
1324    if (c.parent.id === a.id && d === b) {
1325      return c;
1326    }
1327  }
1328  return a.j.la(a, b);
1329}
1330function rb(a, b, c, d) {
1331  a = new Cb(a, b, c, d);
1332  b = Gb(a.parent.id, a.name);
1333  a.$b = zb[b];
1334  return zb[b] = a;
1335}
1336function Ib(a) {
1337  var b = ["r", "w", "rw"][a & 3];
1338  a & 512 && (b += "w");
1339  return b;
1340}
1341function Hb(a, b) {
1342  if (Ab) {
1343    return 0;
1344  }
1345  if (!b.includes("r") || a.mode & 292) {
1346    if (b.includes("w") && !(a.mode & 146) || b.includes("x") && !(a.mode & 73)) {
1347      return 2;
1348    }
1349  } else {
1350    return 2;
1351  }
1352  return 0;
1353}
1354function Jb(a, b) {
1355  try {
1356    return tb(a, b), 20;
1357  } catch (c) {
1358  }
1359  return Hb(a, "wx");
1360}
1361function Kb(a) {
1362  a = xb[a];
1363  if (!a) {
1364    throw new M(8);
1365  }
1366  return a;
1367}
1368function Lb(a, b = -1) {
1369  a = Object.assign(new Bb(), a);
1370  if (-1 == b) {
1371    a: {
1372      for (b = 0; 4096 >= b; b++) {
1373        if (!xb[b]) {
1374          break a;
1375        }
1376      }
1377      throw new M(33);
1378    }
1379  }
1380  a.W = b;
1381  return xb[b] = a;
1382}
1383function Mb(a, b = -1) {
1384  a = Lb(a, b);
1385  a.m?.zc?.(a);
1386  return a;
1387}
1388var qb = {open(a) {
1389  a.m = wb[a.node.Da].m;
1390  a.m.open?.(a);
1391}, aa() {
1392  throw new M(70);
1393},};
1394function kb(a, b) {
1395  wb[a] = {m:b};
1396}
1397function Nb(a, b) {
1398  var c = "/" === b;
1399  if (c && vb) {
1400    throw new M(10);
1401  }
1402  if (!c && b) {
1403    var d = Db(b, {gb:!1});
1404    b = d.path;
1405    d = d.node;
1406    if (d.Ba) {
1407      throw new M(10);
1408    }
1409    if (16384 !== (d.mode & 61440)) {
1410      throw new M(54);
1411    }
1412  }
1413  b = {type:a, Jc:{}, kb:b, Yb:[]};
1414  a = a.U(b);
1415  a.U = b;
1416  b.root = a;
1417  c ? vb = a : d && (d.Ba = b, d.U && d.U.Yb.push(b));
1418}
1419function Ob(a, b, c) {
1420  var d = Db(a, {parent:!0}).node;
1421  a = $a(a);
1422  if (!a || "." === a || ".." === a) {
1423    throw new M(28);
1424  }
1425  var e = Jb(d, a);
1426  if (e) {
1427    throw new M(e);
1428  }
1429  if (!d.j.Aa) {
1430    throw new M(63);
1431  }
1432  return d.j.Aa(d, a, b, c);
1433}
1434function Pb(a) {
1435  return Ob(a, 16895, 0);
1436}
1437function Qb(a, b, c) {
1438  "undefined" == typeof c && (c = b, b = 438);
1439  Ob(a, b | 8192, c);
1440}
1441function Rb(a, b) {
1442  if (!cb(a)) {
1443    throw new M(44);
1444  }
1445  var c = Db(b, {parent:!0}).node;
1446  if (!c) {
1447    throw new M(44);
1448  }
1449  b = $a(b);
1450  var d = Jb(c, b);
1451  if (d) {
1452    throw new M(d);
1453  }
1454  if (!c.j.Ga) {
1455    throw new M(63);
1456  }
1457  c.j.Ga(c, b, a);
1458}
1459function Eb(a) {
1460  a = Db(a).node;
1461  if (!a) {
1462    throw new M(44);
1463  }
1464  if (!a.j.ma) {
1465    throw new M(28);
1466  }
1467  return cb(Fb(a.parent), a.j.ma(a));
1468}
1469function Sb(a, b, c) {
1470  if ("" === a) {
1471    throw new M(44);
1472  }
1473  if ("string" == typeof b) {
1474    var d = {r:0, "r+":2, w:577, "w+":578, a:1089, "a+":1090,}[b];
1475    if ("undefined" == typeof d) {
1476      throw Error(`Unknown file open mode: ${b}`);
1477    }
1478    b = d;
1479  }
1480  c = b & 64 ? ("undefined" == typeof c ? 438 : c) & 4095 | 32768 : 0;
1481  if ("object" == typeof a) {
1482    var e = a;
1483  } else {
1484    a = Ya(a);
1485    try {
1486      e = Db(a, {fb:!(b & 131072)}).node;
1487    } catch (f) {
1488    }
1489  }
1490  d = !1;
1491  if (b & 64) {
1492    if (e) {
1493      if (b & 128) {
1494        throw new M(20);
1495      }
1496    } else {
1497      e = Ob(a, c, 0), d = !0;
1498    }
1499  }
1500  if (!e) {
1501    throw new M(44);
1502  }
1503  8192 === (e.mode & 61440) && (b &= -513);
1504  if (b & 65536 && 16384 !== (e.mode & 61440)) {
1505    throw new M(54);
1506  }
1507  if (!d && (c = e ? 40960 === (e.mode & 61440) ? 32 : 16384 === (e.mode & 61440) && ("r" !== Ib(b) || b & 512) ? 31 : Hb(e, Ib(b)) : 44)) {
1508    throw new M(c);
1509  }
1510  if (b & 512 && !d) {
1511    c = e;
1512    c = "string" == typeof c ? Db(c, {fb:!0}).node : c;
1513    if (!c.j.P) {
1514      throw new M(63);
1515    }
1516    if (16384 === (c.mode & 61440)) {
1517      throw new M(31);
1518    }
1519    if (32768 !== (c.mode & 61440)) {
1520      throw new M(28);
1521    }
1522    if (d = Hb(c, "w")) {
1523      throw new M(d);
1524    }
1525    c.j.P(c, {size:0, timestamp:Date.now()});
1526  }
1527  b &= -131713;
1528  e = Lb({node:e, path:Fb(e), flags:b, seekable:!0, position:0, m:e.m, mc:[], error:!1});
1529  e.m.open && e.m.open(e);
1530  !l.logReadFiles || b & 1 || (Tb ||= {}, a in Tb || (Tb[a] = 1));
1531  return e;
1532}
1533function Ub(a, b, c) {
1534  if (null === a.W) {
1535    throw new M(8);
1536  }
1537  if (!a.seekable || !a.m.aa) {
1538    throw new M(70);
1539  }
1540  if (0 != c && 1 != c && 2 != c) {
1541    throw new M(28);
1542  }
1543  a.position = a.m.aa(a, b, c);
1544  a.mc = [];
1545}
1546var Vb;
1547function Wb(a, b, c) {
1548  a = Ya("/dev/" + a);
1549  var d = ub(!!b, !!c);
1550  Xb ||= 64;
1551  var e = Xb++ << 8 | 0;
1552  kb(e, {open(f) {
1553    f.seekable = !1;
1554  }, close() {
1555    c?.buffer?.length && c(10);
1556  }, read(f, g, k, p) {
1557    for (var m = 0, t = 0; t < p; t++) {
1558      try {
1559        var v = b();
1560      } catch (x) {
1561        throw new M(29);
1562      }
1563      if (void 0 === v && 0 === m) {
1564        throw new M(6);
1565      }
1566      if (null === v || void 0 === v) {
1567        break;
1568      }
1569      m++;
1570      g[k + t] = v;
1571    }
1572    m && (f.node.timestamp = Date.now());
1573    return m;
1574  }, write(f, g, k, p) {
1575    for (var m = 0; m < p; m++) {
1576      try {
1577        c(g[k + m]);
1578      } catch (t) {
1579        throw new M(29);
1580      }
1581    }
1582    p && (f.node.timestamp = Date.now());
1583    return m;
1584  }});
1585  Qb(a, d, e);
1586}
1587var Xb, Yb = {}, Tb, Wa = void 0, Zb = (a, b) => Object.defineProperty(b, "name", {value:a}), $b = [], O = [], P, Q = a => {
1588  if (!a) {
1589    throw new P("Cannot use deleted val. handle = " + a);
1590  }
1591  return O[a];
1592}, ac = a => {
1593  switch(a) {
1594    case void 0:
1595      return 2;
1596    case null:
1597      return 4;
1598    case !0:
1599      return 6;
1600    case !1:
1601      return 8;
1602    default:
1603      const b = $b.pop() || O.length;
1604      O[b] = a;
1605      O[b + 1] = 1;
1606      return b;
1607  }
1608}, bc = a => {
1609  var b = Error, c = Zb(a, function(d) {
1610    this.name = a;
1611    this.message = d;
1612    d = Error(d).stack;
1613    void 0 !== d && (this.stack = this.toString() + "\n" + d.replace(/^Error(:[^\n]*)?\n/, ""));
1614  });
1615  c.prototype = Object.create(b.prototype);
1616  c.prototype.constructor = c;
1617  c.prototype.toString = function() {
1618    return void 0 === this.message ? this.name : `${this.name}: ${this.message}`;
1619  };
1620  return c;
1621}, cc, dc, R = a => {
1622  for (var b = ""; D[a];) {
1623    b += dc[D[a++]];
1624  }
1625  return b;
1626}, ec = [], fc = () => {
1627  for (; ec.length;) {
1628    var a = ec.pop();
1629    a.g.ha = !1;
1630    a["delete"]();
1631  }
1632}, gc, hc = {}, ic = (a, b) => {
1633  if (void 0 === b) {
1634    throw new P("ptr should not be undefined");
1635  }
1636  for (; a.B;) {
1637    b = a.oa(b), a = a.B;
1638  }
1639  return b;
1640}, jc = {}, mc = a => {
1641  a = kc(a);
1642  var b = R(a);
1643  lc(a);
1644  return b;
1645}, nc = (a, b) => {
1646  var c = jc[a];
1647  if (void 0 === c) {
1648    throw a = `${b} has unknown type ${mc(a)}`, new P(a);
1649  }
1650  return c;
1651}, oc = () => {
1652}, pc = !1, qc = (a, b, c) => {
1653  if (b === c) {
1654    return a;
1655  }
1656  if (void 0 === c.B) {
1657    return null;
1658  }
1659  a = qc(a, b, c.B);
1660  return null === a ? null : c.Ib(a);
1661}, rc = {}, sc = (a, b) => {
1662  b = ic(a, b);
1663  return hc[b];
1664}, tc, vc = (a, b) => {
1665  if (!b.u || !b.o) {
1666    throw new tc("makeClassHandle requires ptr and ptrType");
1667  }
1668  if (!!b.J !== !!b.F) {
1669    throw new tc("Both smartPtrType and smartPtr must be specified");
1670  }
1671  b.count = {value:1};
1672  return uc(Object.create(a, {g:{value:b, writable:!0,},}));
1673}, uc = a => {
1674  if ("undefined" === typeof FinalizationRegistry) {
1675    return uc = b => b, a;
1676  }
1677  pc = new FinalizationRegistry(b => {
1678    b = b.g;
1679    --b.count.value;
1680    0 === b.count.value && (b.F ? b.J.O(b.F) : b.u.i.O(b.o));
1681  });
1682  uc = b => {
1683    var c = b.g;
1684    c.F && pc.register(b, {g:c}, b);
1685    return b;
1686  };
1687  oc = b => {
1688    pc.unregister(b);
1689  };
1690  return uc(a);
1691}, wc = {}, xc = a => {
1692  for (; a.length;) {
1693    var b = a.pop();
1694    a.pop()(b);
1695  }
1696};
1697function yc(a) {
1698  return this.fromWireType(H[a >> 2]);
1699}
1700var zc = {}, Ac = {}, T = (a, b, c) => {
1701  function d(k) {
1702    k = c(k);
1703    if (k.length !== a.length) {
1704      throw new tc("Mismatched type converter count");
1705    }
1706    for (var p = 0; p < a.length; ++p) {
1707      S(a[p], k[p]);
1708    }
1709  }
1710  a.forEach(function(k) {
1711    Ac[k] = b;
1712  });
1713  var e = Array(b.length), f = [], g = 0;
1714  b.forEach((k, p) => {
1715    jc.hasOwnProperty(k) ? e[p] = jc[k] : (f.push(k), zc.hasOwnProperty(k) || (zc[k] = []), zc[k].push(() => {
1716      e[p] = jc[k];
1717      ++g;
1718      g === f.length && d(e);
1719    }));
1720  });
1721  0 === f.length && d(e);
1722};
1723function Bc(a, b, c = {}) {
1724  var d = b.name;
1725  if (!a) {
1726    throw new P(`type "${d}" must have a positive integer typeid pointer`);
1727  }
1728  if (jc.hasOwnProperty(a)) {
1729    if (c.Sb) {
1730      return;
1731    }
1732    throw new P(`Cannot register type '${d}' twice`);
1733  }
1734  jc[a] = b;
1735  delete Ac[a];
1736  zc.hasOwnProperty(a) && (b = zc[a], delete zc[a], b.forEach(e => e()));
1737}
1738function S(a, b, c = {}) {
1739  if (!("argPackAdvance" in b)) {
1740    throw new TypeError("registerType registeredInstance requires argPackAdvance");
1741  }
1742  return Bc(a, b, c);
1743}
1744var Cc = a => {
1745  throw new P(a.g.u.i.name + " instance already deleted");
1746};
1747function Dc() {
1748}
1749var Ec = (a, b, c) => {
1750  if (void 0 === a[b].A) {
1751    var d = a[b];
1752    a[b] = function(...e) {
1753      if (!a[b].A.hasOwnProperty(e.length)) {
1754        throw new P(`Function '${c}
1754' called with an invalid number of arguments (${e.length}) - expects one of (${a[b].A})!`);
1755      }
1756      return a[b].A[e.length].apply(this, e);
1757    };
1758    a[b].A = [];
1759    a[b].A[d.ga] = d;
1760  }
1761}, Fc = (a, b, c) => {
1762  if (l.hasOwnProperty(a)) {
1763    if (void 0 === c || void 0 !== l[a].A && void 0 !== l[a].A[c]) {
1764      throw new P(`Cannot register public name '${a}' twice`);
1765    }
1766    Ec(l, a, a);
1767    if (l.hasOwnProperty(c)) {
1768      throw new P(`Cannot register multiple overloads of a function with the same number of arguments (${c})!`);
1769    }
1770    l[a].A[c] = b;
1771  } else {
1772    l[a] = b, void 0 !== c && (l[a].Ic = c);
1773  }
1774}, Gc = a => {
1775  if (void 0 === a) {
1776    return "_unknown";
1777  }
1778  a = a.replace(/[^a-zA-Z0-9_]/g, "$");
1779  var b = a.charCodeAt(0);
1780  return 48 <= b && 57 >= b ? `_${a}` : a;
1781};
1782function Hc(a, b, c, d, e, f, g, k) {
1783  this.name = a;
1784  this.constructor = b;
1785  this.M = c;
1786  this.O = d;
1787  this.B = e;
1788  this.Nb = f;
1789  this.oa = g;
1790  this.Ib = k;
1791  this.ob = [];
1792}
1793var Ic = (a, b, c) => {
1794  for (; b !== c;) {
1795    if (!b.oa) {
1796      throw new P(`Expected null or instance of ${c.name}, got an instance of ${b.name}`);
1797    }
1798    a = b.oa(a);
1799    b = b.B;
1800  }
1801  return a;
1802};
1803function Jc(a, b) {
1804  if (null === b) {
1805    if (this.Ra) {
1806      throw new P(`null is not a valid ${this.name}`);
1807    }
1808    return 0;
1809  }
1810  if (!b.g) {
1811    throw new P(`Cannot pass "${Kc(b)}" as a ${this.name}`);
1812  }
1813  if (!b.g.o) {
1814    throw new P(`Cannot pass deleted object as a pointer of type ${this.name}`);
1815  }
1816  return Ic(b.g.o, b.g.u.i, this.i);
1817}
1818function Lc(a, b) {
1819  if (null === b) {
1820    if (this.Ra) {
1821      throw new P(`null is not a valid ${this.name}`);
1822    }
1823    if (this.wa) {
1824      var c = this.Ta();
1825      null !== a && a.push(this.O, c);
1826      return c;
1827    }
1828    return 0;
1829  }
1830  if (!b || !b.g) {
1831    throw new P(`Cannot pass "${Kc(b)}" as a ${this.name}`);
1832  }
1833  if (!b.g.o) {
1834    throw new P(`Cannot pass deleted object as a pointer of type ${this.name}`);
1835  }
1836  if (!this.va && b.g.u.va) {
1837    throw new P(`Cannot convert argument of type ${b.g.J ? b.g.J.name : b.g.u.name} to parameter type ${this.name}`);
1838  }
1839  c = Ic(b.g.o, b.g.u.i, this.i);
1840  if (this.wa) {
1841    if (void 0 === b.g.F) {
1842      throw new P("Passing raw pointer to smart pointer is illegal");
1843    }
1844    switch(this.fc) {
1845      case 0:
1846        if (b.g.J === this) {
1847          c = b.g.F;
1848        } else {
1849          throw new P(`Cannot convert argument of type ${b.g.J ? b.g.J.name : b.g.u.name} to parameter type ${this.name}`);
1850        }
1851        break;
1852      case 1:
1853        c = b.g.F;
1854        break;
1855      case 2:
1856        if (b.g.J === this) {
1857          c = b.g.F;
1858        } else {
1859          var d = b.clone();
1860          c = this.bc(c, ac(() => d["delete"]()));
1861          null !== a && a.push(this.O, c);
1862        }
1863        break;
1864      default:
1865        throw new P("Unsupporting sharing policy");
1866    }
1867  }
1868  return c;
1869}
1870function Mc(a, b) {
1871  if (null === b) {
1872    if (this.Ra) {
1873      throw new P(`null is not a valid ${this.name}`);
1874    }
1875    return 0;
1876  }
1877  if (!b.g) {
1878    throw new P(`Cannot pass "${Kc(b)}" as a ${this.name}`);
1879  }
1880  if (!b.g.o) {
1881    throw new P(`Cannot pass deleted object as a pointer of type ${this.name}`);
1882  }
1883  if (b.g.u.va) {
1884    throw new P(`Cannot convert argument of type ${b.g.u.name} to parameter type ${this.name}`);
1885  }
1886  return Ic(b.g.o, b.g.u.i, this.i);
1887}
1888function Nc(a, b, c, d, e, f, g, k, p, m, t) {
1889  this.name = a;
1890  this.i = b;
1891  this.Ra = c;
1892  this.va = d;
1893  this.wa = e;
1894  this.ac = f;
1895  this.fc = g;
1896  this.qb = k;
1897  this.Ta = p;
1898  this.bc = m;
1899  this.O = t;
1900  e || void 0 !== b.B ? this.toWireType = Lc : (this.toWireType = d ? Jc : Mc, this.L = null);
1901}
1902var Oc = (a, b, c) => {
1903  if (!l.hasOwnProperty(a)) {
1904    throw new tc("Replacing nonexistent public symbol");
1905  }
1906  void 0 !== l[a].A && void 0 !== c ? l[a].A[c] = b : (l[a] = b, l[a].ga = c);
1907}, Pc = [], Qc, Rc = a => {
1908  var b = Pc[a];
1909  b || (a >= Pc.length && (Pc.length = a + 1), Pc[a] = b = Qc.get(a));
1910  return b;
1911}, Sc = (a, b, c = []) => {
1912  a.includes("j") ? (a = a.replace(/p/g, "i"), b = (0,l["dynCall_" + a])(b, ...c)) : b = Rc(b)(...c);
1913  return b;
1914}, Tc = (a, b) => (...c) => Sc(a, b, c), U = (a, b) => {
1915  a = R(a);
1916  var c = a.includes("j") ? Tc(a, b) : Rc(b);
1917  if ("function" != typeof c) {
1918    throw new P(`unknown function pointer with signature ${a}: ${b}`);
1919  }
1920  return c;
1921}, Uc, Vc = (a, b) => {
1922  function c(f) {
1923    e[f] || jc[f] || (Ac[f] ? Ac[f].forEach(c) : (d.push(f), e[f] = !0));
1924  }
1925  var d = [], e = {};
1926  b.forEach(c);
1927  throw new Uc(`${a}: ` + d.map(mc).join([", "]));
1928};
1929function Wc(a) {
1930  for (var b = 1; b < a.length; ++b) {
1931    if (null !== a[b] && void 0 === a[b].L) {
1932      return !0;
1933    }
1934  }
1935  return !1;
1936}
1937function Xc(a, b, c, d, e) {
1938  var f = b.length;
1939  if (2 > f) {
1940    throw new P("argTypes array size mismatch! Must at least get return value and 'this' types!");
1941  }
1942  var g = null !== b[1] && null !== c, k = Wc(b), p = "void" !== b[0].name, m = f - 2, t = Array(m), v = [], x = [];
1943  return Zb(a, function(...n) {
1944    if (n.length !== m) {
1945      throw new P(`function ${a} called with ${n.length} arguments, expected ${m}`);
1946    }
1947    x.length = 0;
1948    v.length = g ? 2 : 1;
1949    v[0] = e;
1950    if (g) {
1951      var r = b[1].toWireType(x, this);
1952      v[1] = r;
1953    }
1954    for (var u = 0; u < m; ++u) {
1955      t[u] = b[u + 2].toWireType(x, n[u]), v.push(t[u]);
1956    }
1957    n = d(...v);
1958    if (k) {
1959      xc(x);
1960    } else {
1961      for (u = g ? 1 : 2; u < b.length; u++) {
1962        var z = 1 === u ? r : t[u - 2];
1963        null !== b[u].L && b[u].L(z);
1964      }
1965    }
1966    r = p ? b[0].fromWireType(n) : void 0;
1967    return r;
1968  });
1969}
1970var Yc = (a, b) => {
1971  for (var c = [], d = 0; d < a; d++) {
1972    c.push(H[b + 4 * d >> 2]);
1973  }
1974  return c;
1975}, Zc = a => {
1976  a = a.trim();
1977  const b = a.indexOf("(");
1978  return -1 !== b ? a.substr(0, b) : a;
1979}, $c = (a, b, c) => {
1980  if (!(a instanceof Object)) {
1981    throw new P(`${c}
1981 with invalid "this": ${a}`);
1982  }
1983  if (!(a instanceof b.i.constructor)) {
1984    throw new P(`${c} incompatible with "this" of type ${a.constructor.name}`);
1985  }
1986  if (!a.g.o) {
1987    throw new P(`cannot call emscripten binding method ${c} on deleted object`);
1988  }
1989  return Ic(a.g.o, a.g.u.i, b.i);
1990}, ad = a => {
1991  9 < a && 0 === --O[a + 1] && (O[a] = void 0, $b.push(a));
1992}, bd = {name:"emscripten::val", fromWireType:a => {
1993  var b = Q(a);
1994  ad(a);
1995  return b;
1996}, toWireType:(a, b) => ac(b), argPackAdvance:8, readValueFromPointer:yc, L:null,}, cd = (a, b, c) => {
1997  switch(b) {
1998    case 1:
1999      return c ? function(d) {
2000        return this.fromWireType(B[d]);
2001      } : function(d) {
2002        return this.fromWireType(D[d]);
2003      };
2004    case 2:
2005      return c ? function(d) {
2006        return this.fromWireType(E[d >> 1]);
2007      } : function(d) {
2008        return this.fromWireType(wa[d >> 1]);
2009      };
2010    case 4:
2011      return c ? function(d) {
2012        return this.fromWireType(F[d >> 2]);
2013      } : function(d) {
2014        return this.fromWireType(H[d >> 2]);
2015      };
2016    default:
2017      throw new TypeError(`invalid integer width (${b}): ${a}`);
2018  }
2019}, Kc = a => {
2020  if (null === a) {
2021    return "null";
2022  }
2023  var b = typeof a;
2024  return "object" === b || "array" === b || "function" === b ? a.toString() : "" + a;
2025}, dd = (a, b) => {
2026  switch(b) {
2027    case 4:
2028      return function(c) {
2029        return this.fromWireType(xa[c >> 2]);
2030      };
2031    case 8:
2032      return function(c) {
2033        return this.fromWireType(ya[c >> 3]);
2034      };
2035    default:
2036      throw new TypeError(`invalid float width (${b}): ${a}`);
2037  }
2038}, ed = (a, b, c) => {
2039  switch(b) {
2040    case 1:
2041      return c ? d => B[d] : d => D[d];
2042    case 2:
2043      return c ? d => E[d >> 1] : d => wa[d >> 1];
2044    case 4:
2045      return c ? d => F[d >> 2] : d => H[d >> 2];
2046    default:
2047      throw new TypeError(`invalid integer width (${b}): ${a}`);
2048  }
2049}, fd = "undefined" != typeof TextDecoder ? new TextDecoder("utf-16le") : void 0, gd = (a, b) => {
2050  var c = a >> 1;
2051  for (var d = c + b / 2; !(c >= d) && wa[c];) {
2052    ++c;
2053  }
2054  c <<= 1;
2055  if (32 < c - a && fd) {
2056    return fd.decode(D.subarray(a, c));
2057  }
2058  c = "";
2059  for (d = 0; !(d >= b / 2); ++d) {
2060    var e = E[a + 2 * d >> 1];
2061    if (0 == e) {
2062      break;
2063    }
2064    c += String.fromCharCode(e);
2065  }
2066  return c;
2067}, hd = (a, b, c) => {
2068  c ??= 2147483647;
2069  if (2 > c) {
2070    return 0;
2071  }
2072  c -= 2;
2073  var d = b;
2074  c = c < 2 * a.length ? c / 2 : a.length;
2075  for (var e = 0; e < c; ++e) {
2076    E[b >> 1] = a.charCodeAt(e), b += 2;
2077  }
2078  E[b >> 1] = 0;
2079  return b - d;
2080}, jd = a => 2 * a.length, kd = (a, b) => {
2081  for (var c = 0, d = ""; !(c >= b / 4);) {
2082    var e = F[a + 4 * c >> 2];
2083    if (0 == e) {
2084      break;
2085    }
2086    ++c;
2087    65536 <= e ? (e -= 65536, d += String.fromCharCode(55296 | e >> 10, 56320 | e & 1023)) : d += String.fromCharCode(e);
2088  }
2089  return d;
2090}, ld = (a, b, c) => {
2091  c ??= 2147483647;
2092  if (4 > c) {
2093    return 0;
2094  }
2095  var d = b;
2096  c = d + c - 4;
2097  for (var e = 0; e < a.length; ++e) {
2098    var f = a.charCodeAt(e);
2099    if (55296 <= f && 57343 >= f) {
2100      var g = a.charCodeAt(++e);
2101      f = 65536 + ((f & 1023) << 10) | g & 1023;
2102    }
2103    F[b >> 2] = f;
2104    b += 4;
2105    if (b + 4 > c) {
2106      break;
2107    }
2108  }
2109  F[b >> 2] = 0;
2110  return b - d;
2111}, md = a => {
2112  for (var b = 0, c = 0; c < a.length; ++c) {
2113    var d = a.charCodeAt(c);
2114    55296 <= d && 57343 >= d && ++c;
2115    b += 4;
2116  }
2117  return b;
2118}, nd = (a, b, c) => {
2119  var d = [];
2120  a = a.toWireType(d, c);
2121  d.length && (H[b >> 2] = ac(d));
2122  return a;
2123}, od = [], pd = {}, qd = a => {
2124  var b = pd[a];
2125  return void 0 === b ? R(a) : b;
2126}, rd = a => {
2127  var b = od.length;
2128  od.push(a);
2129  return b;
2130}, sd = (a, b) => {
2131  for (var c = Array(a), d = 0; d < a; ++d) {
2132    c[d] = nc(H[b + 4 * d >> 2], "parameter " + d);
2133  }
2134  return c;
2135}, td = Reflect.construct, ud = a => 0 === a % 4 && (0 !== a % 100 || 0 === a % 400), vd = [0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335], wd = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334], xd = [], yd = a => {
2136  a.yc = a.getExtension("WEBGL_draw_instanced_base_vertex_base_instance");
2137}, zd = a => {
2138  a.Fc = a.getExtension("WEBGL_multi_draw_instanced_base_vertex_base_instance");
2139}, Ad = a => {
2140  var b = "EXT_color_buffer_float EXT_conservative_depth EXT_disjoint_timer_query_webgl2 EXT_texture_norm16 NV_shader_noperspective_interpolation WEBGL_clip_cull_distance EXT_color_buffer_half_float EXT_depth_clamp EXT_float_blend EXT_texture_compression_bptc EXT_texture_compression_rgtc EXT_texture_filter_anisotropic KHR_parallel_shader_compile OES_texture_float_linear WEBGL_blend_func_extended WEBGL_compressed_texture_astc WEBGL_compressed_texture_etc WEBGL_compressed_texture_etc1 WEBGL_compressed_texture_s3tc WEBGL_compressed_texture_s3tc_srgb WEBGL_debug_renderer_info WEBGL_debug_shaders WEBGL_lose_context WEBGL_multi_draw".split(" ");
2141  return (a.getSupportedExtensions() || []).filter(c => b.includes(c));
2142}, Bd = 1, Cd = [], V = [], Dd = [], Ed = [], Fd = [], Gd = [], Hd = [], w = [], Id = {}, Jd = 4, Kd = 0, Ld = a => {
2143  for (var b = Bd++, c = a.length; c < b; c++) {
2144    a[c] = null;
2145  }
2146  return b;
2147}, Md = (a, b, c, d) => {
2148  for (var e = 0; e < a; e++) {
2149    var f = W[c](), g = f && Ld(d);
2150    f ? (f.name = g, d[g] = f) : X ||= 1282;
2151    F[b + 4 * e >> 2] = g;
2152  }
2153}
2153, ka = (a, b) => {
2154  var c = Ld(w), d = {handle:c, attributes:b, version:b.Ec, C:a};
2155  a.canvas && (a.canvas.zb = d);
2156  w[c] = d;
2157  ("undefined" == typeof b.Jb || b.Jb) && Nd(d);
2158  return c;
2159}, la = a => {
2160  q = w[a];
2161  l.wc = W = q?.C;
2162  return !(a && !W);
2163}, Nd = a => {
2164  a ||= q;
2165  if (!a.Tb) {
2166    a.Tb = !0;
2167    var b = a.C;
2168    yd(b);
2169    zd(b);
2170    2 <= a.version && (b.cb = b.getExtension("EXT_disjoint_timer_query_webgl2"));
2171    if (2 > a.version || !b.cb) {
2172      b.cb = b.getExtension("EXT_disjoint_timer_query");
2173    }
2174    b.Zb = b.getExtension("WEBGL_multi_draw");
2175    Ad(b).forEach(c => {
2176      c.includes("lose_context") || c.includes("debug") || b.getExtension(c);
2177    });
2178  }
2179}, X, q, Od = {}, Qd = () => {
2180  if (!Pd) {
2181    var a = {USER:"web_user", LOGNAME:"web_user", PATH:"/", PWD:"/", HOME:"/home/web_user", LANG:("object" == typeof navigator && navigator.languages && navigator.languages[0] || "C").replace("-", "_") + ".UTF-8", _:na || "./this.program"}, b;
2182    for (b in Od) {
2183      void 0 === Od[b] ? delete a[b] : a[b] = Od[b];
2184    }
2185    var c = [];
2186    for (b in a) {
2187      c.push(`${b}=${a[b]}`);
2188    }
2189    Pd = c;
2190  }
2191  return Pd;
2192}, Pd, Rd = [];
2193function Sd() {
2194  var a = Ad(W);
2195  return a = a.concat(a.map(b => "GL_" + b));
2196}
2197var Td = (a, b) => {
2198  if (b) {
2199    var c = void 0;
2200    switch(a) {
2201      case 36346:
2202        c = 1;
2203        break;
2204      case 36344:
2205        return;
2206      case 34814:
2207      case 36345:
2208        c = 0;
2209        break;
2210      case 34466:
2211        var d = W.getParameter(34467);
2212        c = d ? d.length : 0;
2213        break;
2214      case 33309:
2215        if (2 > q.version) {
2216          X ||= 1282;
2217          return;
2218        }
2219        c = Sd().length;
2220        break;
2221      case 33307:
2222      case 33308:
2223        if (2 > q.version) {
2224          X ||= 1280;
2225          return;
2226        }
2227        c = 33307 == a ? 3 : 0;
2228    }
2229    if (void 0 === c) {
2230      switch(d = W.getParameter(a), typeof d) {
2231        case "number":
2232          c = d;
2233          break;
2234        case "boolean":
2235          c = d ? 1 : 0;
2236          break;
2237        case "string":
2238          X ||= 1280;
2239          return;
2240        case "object":
2241          if (null === d) {
2242            switch(a) {
2243              case 34964:
2244              case 35725:
2245              case 34965:
2246              case 36006:
2247              case 36007:
2248              case 32873:
2249              case 34229:
2250              case 36662:
2251              case 36663:
2252              case 35053:
2253              case 35055:
2254              case 36010:
2255              case 35097:
2256              case 35869:
2257              case 32874:
2258              case 36389:
2259              case 35983:
2260              case 35368:
2261              case 34068:
2262                c = 0;
2263                break;
2264              default:
2265                X ||= 1280;
2266                return;
2267            }
2268          } else {
2269            if (d instanceof Float32Array || d instanceof Uint32Array || d instanceof Int32Array || d instanceof Array) {
2270              for (a = 0; a < d.length; ++a) {
2271                F[b + 4 * a >> 2] = d[a];
2272              }
2273              return;
2274            }
2275            try {
2276              c = d.name | 0;
2277            } catch (e) {
2278              X ||= 1280;
2279              sa(`GL_INVALID_ENUM in glGet${0}v: Unknown object returned from WebGL getParameter(${a})! (error: ${e})`);
2280              return;
2281            }
2282          }
2283          break;
2284        default:
2285          X ||= 1280;
2286          sa(`GL_INVALID_ENUM in glGet${0}v: Native code calling glGet${0}v(${a}) and it returns ${d} of type ${typeof d}!`);
2287          return;
2288      }
2289    }
2290    F[b >> 2] = c;
2291  } else {
2292    X ||= 1281;
2293  }
2294}, Vd = a => {
2295  var b = fb(a) + 1, c = Ud(b);
2296  c && gb(a, D, c, b);
2297  return c;
2298}, Wd = a => "]" == a.slice(-1) && a.lastIndexOf("["), Xd = a => {
2299  a -= 5120;
2300  return 0 == a ? B : 1 == a ? D : 2 == a ? E : 4 == a ? F : 6 == a ? xa : 5 == a || 28922 == a || 28520 == a || 30779 == a || 30782 == a ? H : wa;
2301}, Yd = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], Zd = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], $d = (a, b, c, d) => {
2302  function e(n, r, u) {
2303    for (n = "number" == typeof n ? n.toString() : n || ""; n.length < r;) {
2304      n = u[0] + n;
2305    }
2306    return n;
2307  }
2308  function f(n, r) {
2309    return e(n, r, "0");
2310  }
2311  function g(n, r) {
2312    function u(A) {
2313      return 0 > A ? -1 : 0 < A ? 1 : 0;
2314    }
2315    var z;
2316    0 === (z = u(n.getFullYear() - r.getFullYear())) && 0 === (z = u(n.getMonth() - r.getMonth())) && (z = u(n.getDate() - r.getDate()));
2317    return z;
2318  }
2319  function k(n) {
2320    switch(n.getDay()) {
2321      case 0:
2322        return new Date(n.getFullYear() - 1, 11, 29);
2323      case 1:
2324        return n;
2325      case 2:
2326        return new Date(n.getFullYear(), 0, 3);
2327      case 3:
2328        return new Date(n.getFullYear(), 0, 2);
2329      case 4:
2330        return new Date(n.getFullYear(), 0, 1);
2331      case 5:
2332        return new Date(n.getFullYear() - 1, 11, 31);
2333      case 6:
2334        return new Date(n.getFullYear() - 1, 11, 30);
2335    }
2336  }
2337  function p(n) {
2338    var r = n.ca;
2339    for (n = new Date((new Date(n.da + 1900, 0, 1)).getTime()); 0 < r;) {
2340      var u = n.getMonth(), z = (ud(n.getFullYear()) ? Yd : Zd)[u];
2341      if (r > z - n.getDate()) {
2342        r -= z - n.getDate() + 1, n.setDate(1), 11 > u ? n.setMonth(u + 1) : (n.setMonth(0), n.setFullYear(n.getFullYear() + 1));
2343      } else {
2344        n.setDate(n.getDate() + r);
2345        break;
2346      }
2347    }
2348    u = new Date(n.getFullYear() + 1, 0, 4);
2349    r = k(new Date(n.getFullYear(), 0, 4));
2350    u = k(u);
2351    return 0 >= g(r, n) ? 0 >= g(u, n) ? n.getFullYear() + 1 : n.getFullYear() : n.getFullYear() - 1;
2352  }
2353  var m = H[d + 40 >> 2];
2354  d = {jc:F[d >> 2], ic:F[d + 4 >> 2], Ha:F[d + 8 >> 2], Va:F[d + 12 >> 2], Ia:F[d + 16 >> 2], da:F[d + 20 >> 2], R:F[d + 24 >> 2], ca:F[d + 28 >> 2], Lc:F[d + 32 >> 2], hc:F[d + 36 >> 2], kc:m ? m ? L(D, m) : "" : ""};
2355  c = c ? L(D, c) : "";
2356  m = {"%c":"%a %b %d %H:%M:%S %Y", "%D":"%m/%d/%y", "%F":"%Y-%m-%d", "%h":"%b", "%r":"%I:%M:%S %p", "%R":"%H:%M", "%T":"%H:%M:%S", "%x":"%m/%d/%y", "%X":"%H:%M:%S", "%Ec":"%c", "%EC":"%C", "%Ex":"%m/%d/%y", "%EX":"%H:%M:%S", "%Ey":"%y", "%EY":"%Y", "%Od":"%d", "%Oe":"%e", "%OH":"%H", "%OI":"%I", "%Om":"%m", "%OM":"%M", "%OS":"%S", "%Ou":"%u", "%OU":"%U", "%OV":"%V", "%Ow":"%w", "%OW":"%W", "%Oy":"%y",};
2357  for (var t in m) {
2358    c = c.replace(new RegExp(t, "g"), m[t]);
2359  }
2360  var v = "Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "), x = "January February March April May June July August September October November December".split(" ");
2361  m = {"%a":n => v[n.R].substring(0, 3), "%A":n => v[n.R], "%b":n => x[n.Ia].substring(0, 3), "%B":n => x[n.Ia], "%C":n => f((n.da + 1900) / 100 | 0, 2), "%d":n => f(n.Va, 2), "%e":n => e(n.Va, 2, " "), "%g":n => p(n).toString().substring(2), "%G":p, "%H":n => f(n.Ha, 2), "%I":n => {
2362    n = n.Ha;
2363    0 == n ? n = 12 : 12 < n && (n -= 12);
2364    return f(n, 2);
2365  }, "%j":n => {
2366    for (var r = 0, u = 0; u <= n.Ia - 1; r += (ud(n.da + 1900) ? Yd : Zd)[u++]) {
2367    }
2368    return f(n.Va + r, 3);
2369  }, "%m":n => f(n.Ia + 1, 2), "%M":n => f(n.ic, 2), "%n":() => "\n", "%p":n => 0 <= n.Ha && 12 > n.Ha ? "AM" : "PM", "%S":n => f(n.jc, 2), "%t":() => "\t", "%u":n => n.R || 7, "%U":n => f(Math.floor((n.ca + 7 - n.R) / 7), 2), "%V":n => {
2370    var r = Math.floor((n.ca + 7 - (n.R + 6) % 7) / 7);
2371    2 >= (n.R + 371 - n.ca - 2) % 7 && r++;
2372    if (r) {
2373      53 == r && (u = (n.R + 371 - n.ca) % 7, 4 == u || 3 == u && ud(n.da) || (r = 1));
2374    } else {
2375      r = 52;
2376      var u = (n.R + 7 - n.ca - 1) % 7;
2377      (4 == u || 5 == u && ud(n.da % 400 - 1)) && r++;
2378    }
2379    return f(r, 2);
2380  }, "%w":n => n.R, "%W":n => f(Math.floor((n.ca + 7 - (n.R + 6) % 7) / 7), 2), "%y":n => (n.da + 1900).toString().substring(2), "%Y":n => n.da + 1900, "%z":n => {
2381    n = n.hc;
2382    var r = 0 <= n;
2383    n = Math.abs(n) / 60;
2384    return (r ? "+" : "-") + String("0000" + (n / 60 * 100 + n % 60)).slice(-4);
2385  }, "%Z":n => n.kc, "%%":() => "%"};
2386  c = c.replace(/%%/g, "\x00\x00");
2387  for (t in m) {
2388    c.includes(t) && (c = c.replace(new RegExp(t, "g"), m[t](d)));
2389  }
2390  c = c.replace(/\0\0/g, "%");
2391  t = hb(c, !1);
2392  if (t.length > b) {
2393    return 0;
2394  }
2395  B.set(t, a);
2396  return t.length - 1;
2397};
2398[44].forEach(a => {
2399  sb[a] = new M(a);
2400  sb[a].stack = "<generic error, no stack>";
2401});
2402zb = Array(4096);
2403Nb(N, "/");
2404Pb("/tmp");
2405Pb("/home");
2406Pb("/home/web_user");
2407(function() {
2408  Pb("/dev");
2409  kb(259, {read:() => 0, write:(d, e, f, g) => g,});
2410  Qb("/dev/null", 259);
2411  jb(1280, mb);
2412  jb(1536, nb);
2413  Qb("/dev/tty", 1280);
2414  Qb("/dev/tty1", 1536);
2415  var a = new Uint8Array(1024), b = 0, c = () => {
2416    0 === b && (b = bb(a).byteLength);
2417    return a[--b];
2418  };
2419  Wb("random", c);
2420  Wb("urandom", c);
2421  Pb("/dev/shm");
2422  Pb("/dev/shm/tmp");
2423})();
2424(function() {
2425  Pb("/proc");
2426  var a = Pb("/proc/self");
2427  Pb("/proc/self/fd");
2428  Nb({U() {
2429    var b = rb(a, "fd", 16895, 73);
2430    b.j = {la(c, d) {
2431      var e = Kb(+d);
2432      c = {parent:null, U:{kb:"fake"}, j:{ma:() => e.path},};
2433      return c.parent = c;
2434    }};
2435    return b;
2436  }}, "/proc/self/fd");
2437})();
2438P = l.BindingError = class extends Error {
2439  constructor(a) {
2440    super(a);
2441    this.name = "BindingError";
2442  }
2443};
2444O.push(0, 1, void 0, 1, null, 1, !0, 1, !1, 1,);
2445l.count_emval_handles = () => O.length / 2 - 5 - $b.length;
2446cc = l.PureVirtualError = bc("PureVirtualError");
2447for (var ae = Array(256), be = 0; 256 > be; ++be) {
2448  ae[be] = String.fromCharCode(be);
2449}
2450dc = ae;
2451l.getInheritedInstanceCount = () => Object.keys(hc).length;
2452l.getLiveInheritedInstances = () => {
2453  var a = [], b;
2454  for (b in hc) {
2455    hc.hasOwnProperty(b) && a.push(hc[b]);
2456  }
2457  return a;
2458};
2459l.flushPendingDeletes = fc;
2460l.setDelayFunction = a => {
2461  gc = a;
2462  ec.length && gc && gc(fc);
2463};
2464tc = l.InternalError = class extends Error {
2465  constructor(a) {
2466    super(a);
2467    this.name = "InternalError";
2468  }
2469};
2470Object.assign(Dc.prototype, {isAliasOf:function(a) {
2471  if (!(this instanceof Dc && a instanceof Dc)) {
2472    return !1;
2473  }
2474  var b = this.g.u.i, c = this.g.o;
2475  a.g = a.g;
2476  var d = a.g.u.i;
2477  for (a = a.g.o; b.B;) {
2478    c = b.oa(c), b = b.B;
2479  }
2480  for (; d.B;) {
2481    a = d.oa(a), d = d.B;
2482  }
2483  return b === d && c === a;
2484}, clone:function() {
2485  this.g.o || Cc(this);
2486  if (this.g.ja) {
2487    return this.g.count.value += 1, this;
2488  }
2489  var a = uc, b = Object, c = b.create, d = Object.getPrototypeOf(this), e = this.g;
2490  a = a(c.call(b, d, {g:{value:{count:e.count, ha:e.ha, ja:e.ja, o:e.o, u:e.u, F:e.F, J:e.J,},}}));
2491  a.g.count.value += 1;
2492  a.g.ha = !1;
2493  return a;
2494}, ["delete"]() {
2495  this.g.o || Cc(this);
2496  if (this.g.ha && !this.g.ja) {
2497    throw new P("Object already scheduled for deletion");
2498  }
2499  oc(this);
2500  var a = this.g;
2501  --a.count.value;
2502  0 === a.count.value && (a.F ? a.J.O(a.F) : a.u.i.O(a.o));
2503  this.g.ja || (this.g.F = void 0, this.g.o = void 0);
2504}, isDeleted:function() {
2505  return !this.g.o;
2506}, deleteLater:function() {
2507  this.g.o || Cc(this);
2508  if (this.g.ha && !this.g.ja) {
2509    throw new P("Object already scheduled for deletion");
2510  }
2511  ec.push(this);
2512  1 === ec.length && gc && gc(fc);
2513  this.g.ha = !0;
2514  return this;
2515},});
2516Object.assign(Nc.prototype, {Ob(a) {
2517  this.qb && (a = this.qb(a));
2518  return a;
2519}, bb(a) {
2520  this.O?.(a);
2521}, argPackAdvance:8, readValueFromPointer:yc, fromWireType:function(a) {
2522  function b() {
2523    return this.wa ? vc(this.i.M, {u:this.ac, o:c, J:this, F:a,}) : vc(this.i.M, {u:this, o:a,});
2524  }
2525  var c = this.Ob(a);
2526  if (!c) {
2527    return this.bb(a), null;
2528  }
2529  var d = sc(this.i, c);
2530  if (void 0 !== d) {
2531    if (0 === d.g.count.value) {
2532      return d.g.o = c, d.g.F = a, d.clone();
2533    }
2534    d = d.clone();
2535    this.bb(a);
2536    return d;
2537  }
2538  d = this.i.Nb(c);
2539  d = rc[d];
2540  if (!d) {
2541    return b.call(this);
2542  }
2543  d = this.va ? d.Gb : d.pointerType;
2544  var e = qc(c, this.i, d.i);
2545  return null === e ? b.call(this) : this.wa ? vc(d.i.M, {u:d, o:e, J:this, F:a,}) : vc(d.i.M, {u:d, o:e,});
2546},});
2547Uc = l.UnboundTypeError = bc("UnboundTypeError");
2548for (var W, ce = 0; 32 > ce; ++ce) {
2549  Rd.push(Array(ce));
2550}
2551var ee = {__syscall_fcntl64:function(a, b, c) {
2552  Wa = c;
2553  try {
2554    var d = Kb(a);
2555    switch(b) {
2556      case 0:
2557        var e = Va();
2558        if (0 > e) {
2559          break;
2560        }
2561        for (; xb[e];) {
2562          e++;
2563        }
2564        return Mb(d, e).W;
2565      case 1:
2566      case 2:
2567        return 0;
2568      case 3:
2569        return d.flags;
2570      case 4:
2571        return e = Va(), d.flags |= e, 0;
2572      case 12:
2573        return e = Va(), E[e + 0 >> 1] = 2, 0;
2574      case 13:
2575      case 14:
2576        return 0;
2577    }
2578    return -28;
2579  } catch (f) {
2580    if ("undefined" == typeof Yb || "ErrnoError" !== f.name) {
2581      throw f;
2582    }
2583    return -f.$;
2584  }
2585}, __syscall_ioctl:function(a, b, c) {
2586  Wa = c;
2587  try {
2588    var d = Kb(a);
2589    switch(b) {
2590      case 21509:
2591        return d.s ? 0 : -59;
2592      case 21505:
2593        if (!d.s) {
2594          return -59;
2595        }
2596        if (d.s.V.Vb) {
2597          a = [3, 28, 127, 21, 4, 0, 1, 0, 17, 19, 26, 0, 18, 15, 23, 22, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,];
2598          var e = Va();
2599          F[e >> 2] = 25856;
2600          F[e + 4 >> 2] = 5;
2601          F[e + 8 >> 2] = 191;
2602          F[e + 12 >> 2] = 35387;
2603          for (var f = 0; 32 > f; f++) {
2604            B[e + f + 17] = a[f] || 0;
2605          }
2606        }
2607        return 0;
2608      case 21510:
2609      case 21511:
2610      case 21512:
2611        return d.s ? 0 : -59;
2612      case 21506:
2613      case 21507:
2614      case 21508:
2615        if (!d.s) {
2616          return -59;
2617        }
2618        if (d.s.V.Wb) {
2619          for (e = Va(), a = [], f = 0; 32 > f; f++) {
2620            a.push(B[e + f + 17]);
2621          }
2622        }
2623        return 0;
2624      case 21519:
2625        if (!d.s) {
2626          return -59;
2627        }
2628        e = Va();
2629        return F[e >> 2] = 0;
2630      case 21520:
2631        return d.s ? -28 : -59;
2632      case 21531:
2633        e = Va();
2634        if (!d.m.Ub) {
2635          throw new M(59);
2636        }
2637        return d.m.Ub(d, b, e);
2638      case 21523:
2639        if (!d.s) {
2640          return -59;
2641        }
2642        d.s.V.Xb && (f = [24, 80], e = Va(), E[e >> 1] = f[0], E[e + 2 >> 1] = f[1]);
2643        return 0;
2644      case 21524:
2645        return d.s ? 0 : -59;
2646      case 21515:
2647        return d.s ? 0 : -59;
2648      default:
2649        return -28;
2650    }
2651  } catch (g) {
2652    if ("undefined" == typeof Yb || "ErrnoError" !== g.name) {
2653      throw g;
2654    }
2655    return -g.$;
2656  }
2657}
2657, __syscall_openat:function(a, b, c, d) {
2658  Wa = d;
2659  try {
2660    b = b ? L(D, b) : "";
2661    var e = b;
2662    if ("/" === e.charAt(0)) {
2663      b = e;
2664    } else {
2665      var f = -100 === a ? "/" : Kb(a).path;
2666      if (0 == e.length) {
2667        throw new M(44);
2668      }
2669      b = Ya(f + "/" + e);
2670    }
2671    var g = d ? Va() : 0;
2672    return Sb(b, c, g).W;
2673  } catch (k) {
2674    if ("undefined" == typeof Yb || "ErrnoError" !== k.name) {
2675      throw k;
2676    }
2677    return -k.$;
2678  }
2679}, _abort_js:() => {
2680  Ha("");
2681}, _embind_create_inheriting_constructor:(a, b, c) => {
2682  a = R(a);
2683  b = nc(b, "wrapper");
2684  c = Q(c);
2685  var d = b.i, e = d.M, f = d.B.M, g = d.B.constructor;
2686  a = Zb(a, function(...k) {
2687    d.B.ob.forEach(function(p) {
2688      if (this[p] === f[p]) {
2689        throw new cc(`Pure virtual function ${p} must be implemented in JavaScript`);
2690      }
2691    }.bind(this));
2692    Object.defineProperty(this, "__parent", {value:e});
2693    this.__construct(...k);
2694  });
2695  e.__construct = function(...k) {
2696    if (this === e) {
2697      throw new P("Pass correct 'this' to __construct");
2698    }
2699    k = g.implement(this, ...k);
2700    oc(k);
2701    var p = k.g;
2702    k.notifyOnDestruction();
2703    p.ja = !0;
2704    Object.defineProperties(this, {g:{value:p}});
2705    uc(this);
2706    k = p.o;
2707    k = ic(d, k);
2708    if (hc.hasOwnProperty(k)) {
2709      throw new P(`Tried to register registered instance: ${k}`);
2710    }
2711    hc[k] = this;
2712  };
2713  e.__destruct = function() {
2714    if (this === e) {
2715      throw new P("Pass correct 'this' to __destruct");
2716    }
2717    oc(this);
2718    var k = this.g.o;
2719    k = ic(d, k);
2720    if (hc.hasOwnProperty(k)) {
2721      delete hc[k];
2722    } else {
2723      throw new P(`Tried to unregister unregistered instance: ${k}`);
2724    }
2725  };
2726  a.prototype = Object.create(e);
2727  Object.assign(a.prototype, c);
2728  return ac(a);
2729}, _embind_finalize_value_object:a => {
2730  var b = wc[a];
2731  delete wc[a];
2732  var c = b.Ta, d = b.O, e = b.eb, f = e.map(g => g.Rb).concat(e.map(g => g.dc));
2733  T([a], f, g => {
2734    var k = {};
2735    e.forEach((p, m) => {
2736      var t = g[m], v = p.Pb, x = p.Qb, n = g[m + e.length], r = p.cc, u = p.ec;
2737      k[p.Lb] = {read:z => t.fromWireType(v(x, z)), write:(z, A) => {
2738        var C = [];
2739        r(u, z, n.toWireType(C, A));
2740        xc(C);
2741      }};
2742    });
2743    return [{name:b.name, fromWireType:p => {
2744      var m = {}, t;
2745      for (t in k) {
2746        m[t] = k[t].read(p);
2747      }
2748      d(p);
2749      return m;
2750    }, toWireType:(p, m) => {
2751      for (var t in k) {
2752        if (!(t in m)) {
2753          throw new TypeError(`Missing field: "${t}"`);
2754        }
2755      }
2756      var v = c();
2757      for (t in k) {
2758        k[t].write(v, m[t]);
2759      }
2760      null !== p && p.push(d, v);
2761      return v;
2762    }, argPackAdvance:8, readValueFromPointer:yc, L:d,}];
2763  });
2764}, _embind_register_bigint:() => {
2765}, _embind_register_bool:(a, b, c, d) => {
2766  b = R(b);
2767  S(a, {name:b, fromWireType:function(e) {
2768    return !!e;
2769  }, toWireType:function(e, f) {
2770    return f ? c : d;
2771  }, argPackAdvance:8, readValueFromPointer:function(e) {
2772    return this.fromWireType(D[e]);
2773  }, L:null,});
2774}, _embind_register_class:(a, b, c, d, e, f, g, k, p, m, t, v, x) => {
2775  t = R(t);
2776  f = U(e, f);
2777  k &&= U(g, k);
2778  m &&= U(p, m);
2779  x = U(v, x);
2780  var n = Gc(t);
2781  Fc(n, function() {
2782    Vc(`Cannot construct ${t} due to unbound types`, [d]);
2783  });
2784  T([a, b, c], d ? [d] : [], r => {
2785    r = r[0];
2786    if (d) {
2787      var u = r.i;
2788      var z = u.M;
2789    } else {
2790      z = Dc.prototype;
2791    }
2792    r = Zb(t, function(...J) {
2793      if (Object.getPrototypeOf(this) !== A) {
2794        throw new P("Use 'new' to construct " + t);
2795      }
2796      if (void 0 === C.Z) {
2797        throw new P(t + " has no accessible constructor");
2798      }
2799      var K = C.Z[J.length];
2800      if (void 0 === K) {
2801        throw new P(`Tried to invoke ctor of ${t} with invalid number of parameters (${J.length}) - expected (${Object.keys(C.Z).toString()}) parameters instead!`);
2802      }
2803      return K.apply(this, J);
2804    });
2805    var A = Object.create(z, {constructor:{value:r},});
2806    r.prototype = A;
2807    var C = new Hc(t, r, A, x, u, f, k, m);
2808    if (C.B) {
2809      var G;
2810      (G = C.B).pa ?? (G.pa = []);
2811      C.B.pa.push(C);
2812    }
2813    u = new Nc(t, C, !0, !1, !1);
2814    G = new Nc(t + "*", C, !1, !1, !1);
2815    z = new Nc(t + " const*", C, !1, !0, !1);
2816    rc[a] = {pointerType:G, Gb:z};
2817    Oc(n, r);
2818    return [u, G, z];
2819  });
2820}, _embind_register_class_class_function:(a, b, c, d, e, f, g) => {
2821  var k = Yc(c, d);
2822  b = R(b);
2823  b = Zc(b);
2824  f = U(e, f);
2825  T([], [a], p => {
2826    function m() {
2827      Vc(`Cannot call ${t} due to unbound types`, k);
2828    }
2829    p = p[0];
2830    var t = `${p.name}.${b}`;
2831    b.startsWith("@@") && (b = Symbol[b.substring(2)]);
2832    var v = p.i.constructor;
2833    void 0 === v[b] ? (m.ga = c - 1, v[b] = m) : (Ec(v, b, t), v[b].A[c - 1] = m);
2834    T([], k, x => {
2835      x = Xc(t, [x[0], null].concat(x.slice(1)), null, f, g);
2836      void 0 === v[b].A ? (x.ga = c - 1, v[b] = x) : v[b].A[c - 1] = x;
2837      if (p.i.pa) {
2838        for (const n of p.i.pa) {
2839          n.constructor.hasOwnProperty(b) || (n.constructor[b] = x);
2840        }
2841      }
2842      return [];
2843    });
2844    return [];
2845  });
2846}, _embind_register_class_class_property:(a, b, c, d, e, f, g, k) => {
2847  b = R(b);
2848  f = U(e, f);
2849  T([], [a], p => {
2850    p = p[0];
2851    var m = `${p.name}.${b}`, t = {get() {
2852      Vc(`Cannot access ${m} due to unbound types`, [c]);
2853    }, enumerable:!0, configurable:!0};
2854    t.set = k ? () => {
2855      Vc(`Cannot access ${m} due to unbound types`, [c]);
2856    } : () => {
2857      throw new P(`${m} is a read-only property`);
2858    };
2859    Object.defineProperty(p.i.constructor, b, t);
2860    T([], [c], v => {
2861      v = v[0];
2862      var x = {get() {
2863        return v.fromWireType(f(d));
2864      }, enumerable:!0};
2865      k && (k = U(g, k), x.set = n => {
2866        var r = [];
2867        k(d, v.toWireType(r, n));
2868        xc(r);
2869      });
2870      Object.defineProperty(p.i.constructor, b, x);
2871      return [];
2872    });
2873    return [];
2874  });
2875}, _embind_register_class_constructor:(a, b, c, d, e, f) => {
2876  var g = Yc(b, c);
2877  e = U(d, e);
2878  T([], [a], k => {
2879    k = k[0];
2880    var p = `constructor ${k.name}`;
2881    void 0 === k.i.Z && (k.i.Z = []);
2882    if (void 0 !== k.i.Z[b - 1]) {
2883      throw new P(`Cannot register multiple constructors with identical number of parameters (${b - 1}) for class '${k.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);
2884    }
2885    k.i.Z[b - 1] = () => {
2886      Vc(`Cannot construct ${k.name} due to unbound types`, g);
2887    };
2888    T([], g, m => {
2889      m.splice(1, 0, null);
2890      k.i.Z[b - 1] = Xc(p, m, null, e, f);
2891      return [];
2892    });
2893    return [];
2894  });
2895}, _embind_register_class_function:(a, b, c, d, e, f, g, k) => {
2896  var p = Yc(c, d);
2897  b = R(b);
2898  b = Zc(b);
2899  f = U(e, f);
2900  T([], [a], m => {
2901    function t() {
2902      Vc(`Cannot call ${v} due to unbound types`, p);
2903    }
2904    m = m[0];
2905    var v = `${m.name}.${b}`;
2906    b.startsWith("@@") && (b = Symbol[b.substring(2)]);
2907    k && m.i.ob.push(b);
2908    var x = m.i.M, n = x[b];
2909    void 0 === n || void 0 === n.A && n.className !== m.name && n.ga === c - 2 ? (t.ga = c - 2, t.className = m.name, x[b] = t) : (Ec(x, b, v), x[b].A[c - 2] = t);
2910    T([], p, r => {
2911      r = Xc(v, r, m, f, g);
2912      void 0 === x[b].A ? (r.ga = c - 2, x[b] = r) : x[b].A[c - 2] = r;
2913      return [];
2914    });
2915    return [];
2916  });
2917}, _embind_register_class_property:(a, b, c, d, e, f, g, k, p, m) => {
2918  b = R(b);
2919  e = U(d, e);
2920  T([], [a], t => {
2921    t = t[0];
2922    var v = `${t.name}.${b}`, x = {get() {
2923      Vc(`Cannot access ${v} due to unbound types`, [c, g]);
2924    }, enumerable:!0, configurable:!0};
2925    x.set = p ? () => Vc(`Cannot access ${v} due to unbound types`, [c, g]) : () => {
2926      throw new P(v + " is a read-only property");
2927    };
2928    Object.defineProperty(t.i.M, b, x);
2929    T([], p ? [c, g] : [c], n => {
2930      var r = n[0], u = {get() {
2931        var A = $c(this, t, v + " getter");
2932        return r.fromWireType(e(f, A));
2933      }, enumerable:!0};
2934      if (p) {
2935        p = U(k, p);
2936        var z = n[1];
2937        u.set = function(A) {
2938          var C = $c(this, t, v + " setter"), G = [];
2939          p(m, C, z.toWireType(G, A));
2940          xc(G);
2941        };
2942      }
2943      Object.defineProperty(t.i.M, b, u);
2944      return [];
2945    });
2946    return [];
2947  });
2948}, _embind_register_emval:a => S(a, bd), _embind_register_enum:(a, b, c, d) => {
2949  function e() {
2950  }
2951  b = R(b);
2952  e.values = {};
2953  S(a, {name:b, constructor:e, fromWireType:function(f) {
2954    return this.constructor.values[f];
2955  }, toWireType:(f, g) => g.value, argPackAdvance:8, readValueFromPointer:cd(b, c, d), L:null,});
2956  Fc(b, e);
2957}, _embind_register_enum_value:(a, b, c) => {
2958  var d = nc(a, "enum");
2959  b = R(b);
2960  a = d.constructor;
2961  d = Object.create(d.constructor.prototype, {value:{value:c}, constructor:{value:Zb(`${d.name}_${b}`, function() {
2962  })},});
2963  a.values[c] = d;
2964  a[b] = d;
2965}, _embind_register_float:(a, b, c) => {
2966  b = R(b);
2967  S(a, {name:b, fromWireType:d => d, toWireType:(d, e) => e, argPackAdvance:8, readValueFromPointer:dd(b, c), L:null,});
2968}, _embind_register_function:(a, b, c, d, e, f) => {
2969  var g = Yc(b, c);
2970  a = R(a);
2971  a = Zc(a);
2972  e = U(d, e);
2973  Fc(a, function() {
2974    Vc(`Cannot call ${a} due to unbound types`, g);
2975  }, b - 1);
2976  T([], g, k => {
2977    Oc(a, Xc(a, [k[0], null].concat(k.slice(1)), null, e, f), b - 1);
2978    return [];
2979  });
2980}, _embind_register_integer:(a, b, c, d, e) => {
2981  b = R(b);
2982  -1 === e && (e = 4294967295);
2983  e = k => k;
2984  if (0 === d) {
2985    var f = 32 - 8 * c;
2986    e = k => k << f >>> f;
2987  }
2988  var g = b.includes("unsigned") ? function(k, p) {
2989    return p >>> 0;
2990  } : function(k, p) {
2991    return p;
2992  };
2993  S(a, {name:b, fromWireType:e, toWireType:g, argPackAdvance:8, readValueFromPointer:ed(b, c, 0 !== d), L:null,});
2994}, _embind_register_memory_view:(a, b, c) => {
2995  function d(f) {
2996    return new e(B.buffer, H[f + 4 >> 2], H[f >> 2]);
2997  }
2998  var e = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array,][b];
2999  c = R(c);
3000  S(a, {name:c, fromWireType:d, argPackAdvance:8, readValueFromPointer:d,}, {Sb:!0,});
3001}, _embind_register_std_string:(a, b) => {
3002  b = R(b);
3003  var c = "std::string" === b;
3004  S(a, {name:b, fromWireType:function(d) {
3005    var e = H[d >> 2], f = d + 4;
3006    if (c) {
3007      for (var g = f, k = 0; k <= e; ++k) {
3008        var p = f + k;
3009        if (k == e || 0 == D[p]) {
3010          g = g ? L(D, g, p - g) : "";
3011          if (void 0 === m) {
3012            var m = g;
3013          } else {
3014            m += String.fromCharCode(0), m += g;
3015          }
3016          g = p + 1;
3017        }
3018      }
3019    } else {
3020      m = Array(e);
3021      for (k = 0; k < e; ++k) {
3022        m[k] = String.fromCharCode(D[f + k]);
3023      }
3024      m = m.join("");
3025    }
3026    lc(d);
3027    return m;
3028  }, toWireType:function(d, e) {
3029    e instanceof ArrayBuffer && (e = new Uint8Array(e));
3030    var f = "string" == typeof e;
3031    if (!(f || e instanceof Uint8Array || e instanceof Uint8ClampedArray || e instanceof Int8Array)) {
3032      throw new P("Cannot pass non-string to std::string");
3033    }
3034    var g = c && f ? fb(e) : e.length;
3035    var k = Ud(4 + g + 1), p = k + 4;
3036    H[k >> 2] = g;
3037    if (c && f) {
3038      gb(e, D, p, g + 1);
3039    } else {
3040      if (f) {
3041        for (f = 0; f < g; ++f) {
3042          var m = e.charCodeAt(f);
3043          if (255 < m) {
3044            throw lc(p), new P("String has UTF-16 code units that do not fit in 8 bits");
3045          }
3046          D[p + f] = m;
3047        }
3048      } else {
3049        for (f = 0; f < g; ++f) {
3050          D[p + f] = e[f];
3051        }
3052      }
3053    }
3054    null !== d && d.push(lc, k);
3055    return k;
3056  }, argPackAdvance:8, readValueFromPointer:yc, L(d) {
3057    lc(d);
3058  },});
3059}, _embind_register_std_wstring:(a, b, c) => {
3060  c = R(c);
3061  if (2 === b) {
3062    var d = gd;
3063    var e = hd;
3064    var f = jd;
3065    var g = k => wa[k >> 1];
3066  } else {
3067    4 === b && (d = kd, e = ld, f = md, g = k => H[k >> 2]);
3068  }
3069  S(a, {name:c, fromWireType:k => {
3070    for (var p = H[k >> 2], m, t = k + 4, v = 0; v <= p; ++v) {
3071      var x = k + 4 + v * b;
3072      if (v == p || 0 == g(x)) {
3073        t = d(t, x - t), void 0 === m ? m = t : (m += String.fromCharCode(0), m += t), t = x + b;
3074      }
3075    }
3076    lc(k);
3077    return m;
3078  }, toWireType:(k, p) => {
3079    if ("string" != typeof p) {
3080      throw new P(`Cannot pass non-string to C++ string type ${c}`);
3081    }
3082    var m = f(p), t = Ud(4 + m + b);
3083    H[t >> 2] = m / b;
3084    e(p, t + 4, m + b);
3085    null !== k && k.push(lc, t);
3086    return t;
3087  }, argPackAdvance:8, readValueFromPointer:yc, L(k) {
3088    lc(k);
3089  }});
3090}, _embind_register_value_object:(a, b, c, d, e, f) => {
3091  wc[a] = {name:R(b), Ta:U(c, d), O:U(e, f), eb:[],};
3092}, _embind_register_value_object_field:(a, b, c, d, e, f, g, k, p, m) => {
3093  wc[a].eb.push({Lb:R(b), Rb:c, Pb:U(d, e), Qb:f, dc:g, cc:U(k, p), ec:m,});
3094}, _embind_register_void:(a, b) => {
3095  b = R(b);
3096  S(a, {Dc:!0, name:b, argPackAdvance:0, fromWireType:() => {
3097  }, toWireType:() => {
3098  },});
3099}, _emscripten_get_now_is_monotonic:() => 1, _emscripten_memcpy_js:(a, b, c) => D.copyWithin(a, b, b + c), _emscripten_throw_longjmp:() => {
3100  throw Infinity;
3101}, _emval_as:(a, b, c) => {
3102  a = Q(a);
3103  b = nc(b, "emval::as");
3104  return nd(b, c, a);
3105}, _emval_call:(a, b, c, d) => {
3106  a = od[a];
3107  b = Q(b);
3108  return a(null, b, c, d);
3109}, _emval_call_method:(a, b, c, d, e) => {
3110  a = od[a];
3111  b = Q(b);
3112  c = qd(c);
3113  return a(b, b[c], d, e);
3114}, _emval_decref:ad, _emval_get_method_caller:(a, b, c) => {
3115  var d = sd(a, b), e = d.shift();
3116  a--;
3117  var f = Array(a);
3118  b = `methodCaller<(${d.map(g => g.name).join(", ")}) => ${e.name}>`;
3119  return rd(Zb(b, (g, k, p, m) => {
3120    for (var t = 0, v = 0; v < a; ++v) {
3121      f[v] = d[v].readValueFromPointer(m + t), t += d[v].argPackAdvance;
3122    }
3123    g = 1 === c ? td(k, f) : k.apply(g, f);
3124    return nd(e, p, g);
3125  }));
3126}, _emval_get_property:(a, b) => {
3127  a = Q(a);
3128  b = Q(b);
3129  return ac(a[b]);
3130}, _emval_incref:a => {
3131  9 < a && (O[a + 1] += 1);
3132}, _emval_new_array:() => ac([]), _emval_new_cstring:a => ac(qd(a)), _emval_new_object:() => ac({}), _emval_run_destructors:a => {
3133  var b = Q(a);
3134  xc(b);
3135  ad(a);
3136}, _emval_set_property:(a, b, c) => {
3137  a = Q(a);
3138  b = Q(b);
3139  c = Q(c);
3140  a[b] = c;
3141}, _emval_take_value:(a, b) => {
3142  a = nc(a, "_emval_take_value");
3143  a = a.readValueFromPointer(b);
3144  return ac(a);
3145}, _gmtime_js:function(a, b, c) {
3146  a = new Date(1000 * (b + 2097152 >>> 0 < 4194305 - !!a ? (a >>> 0) + 4294967296 * b : NaN));
3147  F[c >> 2] = a.getUTCSeconds();
3148  F[c + 4 >> 2] = a.getUTCMinutes();
3149  F[c + 8 >> 2] = a.getUTCHours();
3150  F[c + 12 >> 2] = a.getUTCDate();
3151  F[c + 16 >> 2] = a.getUTCMonth();
3152  F[c + 20 >> 2] = a.getUTCFullYear() - 1900;
3153  F[c + 24 >> 2] = a.getUTCDay();
3154  F[c + 28 >> 2] = (a.getTime() - Date.UTC(a.getUTCFullYear(), 0, 1, 0, 0, 0, 0)) / 864E5 | 0;
3155}, _localtime_js:function(a, b, c) {
3156  a = new Date(1000 * (b + 2097152 >>> 0 < 4194305 - !!a ? (a >>> 0) + 4294967296 * b : NaN));
3157  F[c >> 2] = a.getSeconds();
3158  F[c + 4 >> 2] = a.getMinutes();
3159  F[c + 8 >> 2] = a.getHours();
3160  F[c + 12 >> 2] = a.getDate();
3161  F[c + 16 >> 2] = a.getMonth();
3162  F[c + 20 >> 2] = a.getFullYear() - 1900;
3163  F[c + 24 >> 2] = a.getDay();
3164  F[c + 28 >> 2] = (ud(a.getFullYear()) ? vd : wd)[a.getMonth()] + a.getDate() - 1 | 0;
3165  F[c + 36 >> 2] = -(60 * a.getTimezoneOffset());
3166  b = (new Date(a.getFullYear(), 6, 1)).getTimezoneOffset();
3167  var d = (new Date(a.getFullYear(), 0, 1)).getTimezoneOffset();
3168  F[c + 32 >> 2] = (b != d && a.getTimezoneOffset() == Math.min(d, b)) | 0;
3169}, _tzset_js:(a, b, c, d) => {
3170  var e = (new Date()).getFullYear(), f = new Date(e, 0, 1), g = new Date(e, 6, 1);
3171  e = f.getTimezoneOffset();
3172  var k = g.getTimezoneOffset();
3173  H[a >> 2] = 60 * Math.max(e, k);
3174  F[b >> 2] = Number(e != k);
3175  a = p => p.toLocaleTimeString(void 0, {hour12:!1, timeZoneName:"short"}).split(" ")[1];
3176  f = a(f);
3177  g = a(g);
3178  k < e ? (gb(f, D, c, 17), gb(g, D, d, 17)) : (gb(f, D, d, 17), gb(g, D, c, 17));
3179}, beginPixelLocalStorageWEBGL:function(a, b, c) {
3180  (a = w[a].C.ba) && a.beginPixelLocalStorageWEBGL(l.HEAPU32.subarray(c, c + b));
3181}, decode_image:function(a, b, c) {
3182  var d = l.images;
3183  d || (d = new Map(), l.images = d);
3184  var e = new Image();
3185  d.set(a, e);
3186  b = l.HEAP8.subarray(b, b + c);
3187  c = new Uint8Array(c);
3188  c.set(b);
3189  e.src = URL.createObjectURL(new Blob([c], {type:"image/png"}));
3190  e.onload = function() {
3191    l._setWebImage(a, e.width, e.height);
3192  };
3193}, delete_image:function(a) {
3194  var b = l.images;
3195  b && b.get(a) && b.delete(a);
3196}, emscripten_asm_const_int:(a, b, c) => {
3197  xd.length = 0;
3198  for (var d; d = D[b++];) {
3199    var e = 105 != d;
3200    e &= 112 != d;
3201    c += e && c % 8 ? 4 : 0;
3202    xd.push(112 == d ? H[c >> 2] : 105 == d ? F[c >> 2] : ya[c >> 3]);
3203    c += e ? 8 : 4;
3204  }
3205  return Ta[a](...xd);
3206}, emscripten_date_now:() => Date.now(), emscripten_get_now:() => performance.now(), emscripten_resize_heap:a => {
3207  var b = D.length;
3208  a >>>= 0;
3209  if (2147483648 < a) {
3210    return !1;
3211  }
3212  for (var c = 1; 4 >= c; c *= 2) {
3213    var d = b * (1 + 0.2 / c);
3214    d = Math.min(d, a + 100663296);
3215    var e = Math;
3216    d = Math.max(a, d);
3217    a: {
3218      e = (e.min.call(e, 2147483648, d + (65536 - d % 65536) % 65536) - ua.buffer.byteLength + 65535) / 65536;
3219      try {
3220        ua.grow(e);
3221        za();
3222        var f = 1;
3223        break a;
3224      } catch (g) {
3225      }
3226      f = void 0;
3227    }
3228    if (f) {
3229      return !0;
3230    }
3231  }
3232  return !1;
3233}, emscripten_webgl_enable_extension:(a, b) => {
3234  a = w[a];
3235  b = b ? L(D, b) : "";
3236  b.startsWith("GL_") && (b = b.substr(3));
3237  "WEBGL_draw_instanced_base_vertex_base_instance" == b && yd(W);
3238  "WEBGL_multi_draw_instanced_base_vertex_base_instance" == b && zd(W);
3239  "WEBGL_multi_draw" == b && (W.Zb = W.getExtension("WEBGL_multi_draw"));
3240  return !!a.C.getExtension(b);
3241}, emscripten_webgl_get_current_context:() => q ? q.handle : 0, emscripten_webgl_make_context_current:a => la(a) ? 0 : -5, enable_WEBGL_provoking_vertex:function(a) {
3242  a = w[a].C;
3243  a.pb = a.getExtension("WEBGL_provoking_vertex");
3244  return !!a.pb;
3245}, enable_WEBGL_shader_pixel_local_storage_coherent:function(a) {
3246  a = w[a].C;
3247  a.ba = a.getExtension("WEBGL_shader_pixel_local_storage");
3248  return !(!a.ba || !a.ba.isCoherent());
3249}, endPixelLocalStorageWEBGL:function(a, b, c) {
3250  (a = w[a].C.ba) && a.endPixelLocalStorageWEBGL(l.HEAPU32.subarray(c, c + b));
3251}, environ_get:(a, b) => {
3252  var c = 0;
3253  Qd().forEach((d, e) => {
3254    var f = b + c;
3255    e = H[a + 4 * e >> 2] = f;
3256    for (f = 0; f < d.length; ++f) {
3257      B[e++] = d.charCodeAt(f);
3258    }
3259    B[e] = 0;
3260    c += d.length + 1;
3261  });
3262  return 0;
3263}, environ_sizes_get:(a, b) => {
3264  var c = Qd();
3265  H[a >> 2] = c.length;
3266  var d = 0;
3267  c.forEach(e => d += e.length + 1);
3268  H[b >> 2] = d;
3269  return 0;
3270}, fd_close:function(a) {
3271  try {
3272    var b = Kb(a);
3273    if (null === b.W) {
3274      throw new M(8);
3275    }
3276    b.Qa && (b.Qa = null);
3277    try {
3278      b.m.close && b.m.close(b);
3279    } catch (c) {
3280      throw c;
3281    } finally {
3282      xb[b.W] = null;
3283    }
3284    b.W = null;
3285    return 0;
3286  } catch (c) {
3287    if ("undefined" == typeof Yb || "ErrnoError" !== c.name) {
3288      throw c;
3289    }
3290    return c.$;
3291  }
3292}, fd_read:function(a, b, c, d) {
3293  try {
3294    a: {
3295      var e = Kb(a);
3296      a = b;
3297      for (var f, g = b = 0; g < c; g++) {
3298        var k = H[a >> 2], p = H[a + 4 >> 2];
3299        a += 8;
3300        var m = e, t = f, v = B;
3301        if (0 > p || 0 > t) {
3302          throw new M(28);
3303        }
3304        if (null === m.W) {
3305          throw new M(8);
3306        }
3307        if (1 === (m.flags & 2097155)) {
3308          throw new M(8);
3309        }
3310        if (16384 === (m.node.mode & 61440)) {
3311          throw new M(31);
3312        }
3313        if (!m.m.read) {
3314          throw new M(28);
3315        }
3316        var x = "undefined" != typeof t;
3317        if (!x) {
3318          t = m.position;
3319        } else if (!m.seekable) {
3320          throw new M(70);
3321        }
3322        var n = m.m.read(m, v, k, p, t);
3323        x || (m.position += n);
3324        var r = n;
3325        if (0 > r) {
3326          var u = -1;
3327          break a;
3328        }
3329        b += r;
3330        if (r < p) {
3331          break;
3332        }
3333        "undefined" != typeof f && (f += r);
3334      }
3335      u = b;
3336    }
3337    H[d >> 2] = u;
3338    return 0;
3339  } catch (z) {
3340    if ("undefined" == typeof Yb || "ErrnoError" !== z.name) {
3341      throw z;
3342    }
3343    return z.$;
3344  }
3345}, fd_seek:function(a, b, c, d, e) {
3346  b = c + 2097152 >>> 0 < 4194305 - !!b ? (b >>> 0) + 4294967296 * c : NaN;
3347  try {
3348    if (isNaN(b)) {
3349      return 61;
3350    }
3351    var f = Kb(a);
3352    Ub(f, b, d);
3353    Pa = [f.position >>> 0, (Oa = f.position, 1.0 <= +Math.abs(Oa) ? 0.0 < Oa ? +Math.floor(Oa / 4294967296.0) >>> 0 : ~~+Math.ceil((Oa - +(~~Oa >>> 0)) / 4294967296.0) >>> 0 : 0)];
3354    F[e >> 2] = Pa[0];
3355    F[e + 4 >> 2] = Pa[1];
3356    f.Qa && 0 === b && 0 === d && (f.Qa = null);
3357    return 0;
3358  } catch (g) {
3359    if ("undefined" == typeof Yb || "ErrnoError" !== g.name) {
3360      throw g;
3361    }
3362    return g.$;
3363  }
3364}, fd_write:function(a, b, c, d) {
3365  try {
3366    a: {
3367      var e = Kb(a);
3368      a = b;
3369      for (var f, g = b = 0; g < c; g++) {
3370        var k = H[a >> 2], p = H[a + 4 >> 2];
3371        a += 8;
3372        var m = e, t = k, v = p, x = f, n = B;
3373        if (0 > v || 0 > x) {
3374          throw new M(28);
3375        }
3376        if (null === m.W) {
3377          throw new M(8);
3378        }
3379        if (0 === (m.flags & 2097155)) {
3380          throw new M(8);
3381        }
3382        if (16384 === (m.node.mode & 61440)) {
3383          throw new M(31);
3384        }
3385        if (!m.m.write) {
3386          throw new M(28);
3387        }
3388        m.seekable && m.flags & 1024 && Ub(m, 0, 2);
3389        var r = "undefined" != typeof x;
3390        if (!r) {
3391          x = m.position;
3392        } else if (!m.seekable) {
3393          throw new M(70);
3394        }
3395        var u = m.m.write(m, n, t, v, x, void 0);
3396        r || (m.position += u);
3397        var z = u;
3398        if (0 > z) {
3399          var A = -1;
3400          break a;
3401        }
3402        b += z;
3403        "undefined" != typeof f && (f += z);
3404      }
3405      A = b;
3406    }
3407    H[d >> 2] = A;
3408    return 0;
3409  } catch (C) {
3410    if ("undefined" == typeof Yb || "ErrnoError" !== C.name) {
3411      throw C;
3412    }
3413    return C.$;
3414  }
3415}, framebufferPixelLocalClearValuefvWEBGL:function(a, b, c, d, e, f) {
3416  (a = w[a].C.ba) && a.framebufferPixelLocalClearValuefvWEBGL(b, [c, d, e, f]);
3417}, framebufferTexturePixelLocalStorageWEBGL:function(a, b, c, d, e) {
3418  (a = w[a].C.ba) && a.framebufferTexturePixelLocalStorageWEBGL(b, Fd[c], d, e);
3419}, getFramebufferPixelLocalStorageParameterivWEBGL:function(a, b, c) {
3420  return (a = w[a].C.ba) ? a.getFramebufferPixelLocalStorageParameterWEBGL(b, c) : 0;
3421}, glActiveTexture:a => W.activeTexture(a), glAttachShader:(a, b) => {
3422  W.attachShader(V[a], Gd[b]);
3423}, glBindBuffer:(a, b) => {
3424  35051 == a ? W.Na = b : 35052 == a && (W.Oa = b);
3425  W.bindBuffer(a, Cd[b]);
3426}, glBindBufferRange:(a, b, c, d, e) => {
3427  W.bindBufferRange(a, b, Cd[c], d, e);
3428}, glBindFramebuffer:(a, b) => {
3429  W.bindFramebuffer(a, Dd[b]);
3430}, glBindRenderbuffer:(a, b) => {
3431  W.bindRenderbuffer(a, Ed[b]);
3432}, glBindTexture:(a, b) => {
3433  W.bindTexture(a, Fd[b]);
3434}, glBindVertexArray:a => {
3435  W.bindVertexArray(Hd[a]);
3436}, glBlendEquation:a => W.blendEquation(a), glBlendFunc:(a, b) => W.blendFunc(a, b), glBlitFramebuffer:(a, b, c, d, e, f, g, k, p, m) => W.blitFramebuffer(a, b, c, d, e, f, g, k, p, m), glBufferData:(a, b, c, d) => {
3437  c && b ? W.bufferData(a, D, d, c, b) : W.bufferData(a, b, d);
3438}, glBufferSubData:(a, b, c, d) => {
3439  c && W.bufferSubData(a, b, D, d, c);
3440}, glClear:a => W.clear(a), glClearBufferfv:(a, b, c) => {
3441  W.clearBufferfv(a, b, xa, c >> 2);
3442}, glClearBufferuiv:(a, b, c) => {
3443  W.clearBufferuiv(a, b, H, c >> 2);
3444}, glClearColor:(a, b, c, d) => W.clearColor(a, b, c, d), glClearDepthf:a => W.clearDepth(a), glClearStencil:a => W.clearStencil(a), glColorMask:(a, b, c, d) => {
3445  W.colorMask(!!a, !!b, !!c, !!d);
3446}, glCompileShader:a => {
3447  W.compileShader(Gd[a]);
3448}, glCreateProgram:() => {
3449  var a = Ld(V), b = W.createProgram();
3450  b.name = a;
3451  b.za = b.xa = b.ya = 0;
3452  b.Wa = 1;
3453  V[a] = b;
3454  return a;
3455}, glCreateShader:a => {
3456  var b = Ld(Gd);
3457  Gd[b] = W.createShader(a);
3458  return b;
3459}, glCullFace:a => W.cullFace(a), glDeleteBuffers:(a, b) => {
3460  for (var c = 0; c < a; c++) {
3461    var d = F[b + 4 * c >> 2], e = Cd[d];
3462    e && (W.deleteBuffer(e), e.name = 0, Cd[d] = null, d == W.Na && (W.Na = 0), d == W.Oa && (W.Oa = 0));
3463  }
3464}, glDeleteFramebuffers:(a, b) => {
3465  for (var c = 0; c < a; ++c) {
3466    var d = F[b + 4 * c >> 2], e = Dd[d];
3467    e && (W.deleteFramebuffer(e), e.name = 0, Dd[d] = null);
3468  }
3469}, glDeleteProgram:a => {
3470  if (a) {
3471    var b = V[a];
3472    b ? (W.deleteProgram(b), b.name = 0, V[a] = null) : X ||= 1281;
3473  }
3474}, glDeleteRenderbuffers:(a, b) => {
3475  for (var c = 0; c < a; c++) {
3476    var d = F[b + 4 * c >> 2], e = Ed[d];
3477    e && (W.deleteRenderbuffer(e), e.name = 0, Ed[d] = null);
3478  }
3479}, glDeleteShader:a => {
3480  if (a) {
3481    var b = Gd[a];
3482    b ? (W.deleteShader(b), Gd[a] = null) : X ||= 1281;
3483  }
3484}, glDeleteTextures:(a, b) => {
3485  for (var c = 0; c < a; c++) {
3486    var d = F[b + 4 * c >> 2], e = Fd[d];
3487    e && (W.deleteTexture(e), e.name = 0, Fd[d] = null);
3488  }
3489}, glDeleteVertexArrays:(a, b) => {
3490  for (var c = 0; c < a; c++) {
3491    var d = F[b + 4 * c >> 2];
3492    W.deleteVertexArray(Hd[d]);
3493    Hd[d] = null;
3494  }
3495}, glDepthFunc:a => W.depthFunc(a), glDepthMask:a => {
3496  W.depthMask(!!a);
3497}, glDepthRangef:(a, b) => W.depthRange(a, b), glDisable:a => W.disable(a), glDrawArrays:(a, b, c) => {
3498  W.drawArrays(a, b, c);
3499}, glDrawArraysInstanced:(a, b, c, d) => {
3500  W.drawArraysInstanced(a, b, c, d);
3501}, glDrawBuffers:(a, b) => {
3502  for (var c = Rd[a], d = 0; d < a; d++) {
3503    c[d] = F[b + 4 * d >> 2];
3504  }
3505  W.drawBuffers(c);
3506}, glDrawElements:(a, b, c, d) => {
3507  W.drawElements(a, b, c, d);
3508}, glDrawElementsInstanced:(a, b, c, d, e) => {
3509  W.drawElementsInstanced(a, b, c, d, e);
3510}, glEnable:a => W.enable(a), glEnableVertexAttribArray:a => {
3511  W.enableVertexAttribArray(a);
3512}, glFlush:() => W.flush(), glFramebufferRenderbuffer:(a, b, c, d) => {
3513  W.framebufferRenderbuffer(a, b, c, Ed[d]);
3514}, glFramebufferTexture2D:(a, b, c, d, e) => {
3515  W.framebufferTexture2D(a, b, c, Fd[d], e);
3516}, glFrontFace:a => W.frontFace(a), glGenBuffers:(a, b) => {
3517  Md(a, b, "createBuffer", Cd);
3518}, glGenFramebuffers:(a, b) => {
3519  Md(a, b, "createFramebuffer", Dd);
3520}, glGenRenderbuffers:(a, b) => {
3521  Md(a, b, "createRenderbuffer", Ed);
3522}, glGenTextures:(a, b) => {
3523  Md(a, b, "createTexture", Fd);
3524}, glGenVertexArrays:(a, b) => {
3525  Md(a, b, "createVertexArray", Hd);
3526}, glGenerateMipmap:a => W.generateMipmap(a), glGetError:() => {
3527  var a = W.getError() || X;
3528  X = 0;
3529  return a;
3530}, glGetIntegerv:(a, b) => Td(a, b), glGetProgramiv:(a, b, c) => {
3531  if (c) {
3532    if (a >= Bd) {
3533      X ||= 1281;
3534    } else {
3535      if (a = V[a], 35716 == b) {
3536        a = W.getProgramInfoLog(a), null === a && (a = "(unknown error)"), F[c >> 2] = a.length + 1;
3537      } else if (35719 == b) {
3538        if (!a.za) {
3539          for (b = 0; b < W.getProgramParameter(a, 35718); ++b) {
3540            a.za = Math.max(a.za, W.getActiveUniform(a, b).name.length + 1);
3541          }
3542        }
3543        F[c >> 2] = a.za;
3544      } else if (35722 == b) {
3545        if (!a.xa) {
3546          for (b = 0; b < W.getProgramParameter(a, 35721); ++b) {
3547            a.xa = Math.max(a.xa, W.getActiveAttrib(a, b).name.length + 1);
3548          }
3549        }
3550        F[c >> 2] = a.xa;
3551      } else if (35381 == b) {
3552        if (!a.ya) {
3553          for (b = 0; b < W.getProgramParameter(a, 35382); ++b) {
3554            a.ya = Math.max(a.ya, W.getActiveUniformBlockName(a, b).length + 1);
3555          }
3556        }
3557        F[c >> 2] = a.ya;
3558      } else {
3559        F[c >> 2] = W.getProgramParameter(a, b);
3560      }
3561    }
3562  } else {
3563    X ||= 1281;
3564  }
3565}, glGetString:a => {
3566  var b = Id[a];
3567  if (!b) {
3568    switch(a) {
3569      case 7939:
3570        b = Vd(Sd().join(" "));
3571        break;
3572      case 7936:
3573      case 7937:
3574      case 37445:
3575      case 37446:
3576        (b = W.getParameter(a)) || (X ||= 1280);
3577        b = b ? Vd(b) : 0;
3578        break;
3579      case 7938:
3580        b = Vd(`OpenGL ES 3.0 (${W.getParameter(7938)})`);
3581        break;
3582      case 35724:
3583        b = W.getParameter(35724);
3584        var c = b.match(/^WebGL GLSL ES ([0-9]\.[0-9][0-9]?)(?:$| .*)/);
3585        null !== c && (3 == c[1].length && (c[1] += "0"), b = `OpenGL ES GLSL ES ${c[1]} (${b})`);
3586        b = Vd(b);
3587        break;
3588      default:
3589        X ||= 1280;
3590    }
3591    Id[a] = b;
3592  }
3593  return b;
3594}, glGetUniformBlockIndex:(a, b) => W.getUniformBlockIndex(V[a], b ? L(D, b) : ""), glGetUniformLocation:(a, b) => {
3595  b = b ? L(D, b) : "";
3596  if (a = V[a]) {
3597    var c = a, d = c.na, e = c.wb, f;
3598    if (!d) {
3599      for (c.na = d = {}, c.vb = {}, f = 0; f < W.getProgramParameter(c, 35718); ++f) {
3600        var g = W.getActiveUniform(c, f);
3601        var k = g.name;
3602        g = g.size;
3603        var p = Wd(k);
3604        p = 0 < p ? k.slice(0, p) : k;
3605        var m = c.Wa;
3606        c.Wa += g;
3607        e[p] = [g, m];
3608        for (k = 0; k < g; ++k) {
3609          d[m] = k, c.vb[m++] = p;
3610        }
3611      }
3612    }
3613    c = a.na;
3614    d = 0;
3615    e = b;
3616    f = Wd(b);
3617    0 < f && (d = parseInt(b.slice(f + 1)) >>> 0, e = b.slice(0, f));
3618    if ((e = a.wb[e]) && d < e[0] && (d += e[1], c[d] = c[d] || W.getUniformLocation(a, b))) {
3619      return d;
3620    }
3621  } else {
3622    X ||= 1281;
3623  }
3624  return -1;
3625}, glInvalidateFramebuffer:(a, b, c) => {
3626  for (var d = Rd[b], e = 0; e < b; e++) {
3627    d[e] = F[c + 4 * e >> 2];
3628  }
3629  W.invalidateFramebuffer(a, d);
3630}, glLinkProgram:a => {
3631  a = V[a];
3632  W.linkProgram(a);
3633  a.na = 0;
3634  a.wb = {};
3635}, glPixelStorei:(a, b) => {
3636  3317 == a ? Jd = b : 3314 == a && (Kd = b);
3637  W.pixelStorei(a, b);
3638}, glReadPixels:(a, b, c, d, e, f, g) => {
3639  if (W.Na) {
3640    W.readPixels(a, b, c, d, e, f, g);
3641  } else {
3642    var k = Xd(f);
3643    g >>>= 31 - Math.clz32(k.BYTES_PER_ELEMENT);
3644    W.readPixels(a, b, c, d, e, f, k, g);
3645  }
3646}, glRenderbufferStorageMultisample:(a, b, c, d, e) => W.renderbufferStorageMultisample(a, b, c, d, e), glScissor:(a, b, c, d) => W.scissor(a, b, c, d), glShaderSource:(a, b, c, d) => {
3647  for (var e = "", f = 0; f < b; ++f) {
3648    var g = (g = H[c + 4 * f >> 2]) ? L(D, g, d ? H[d + 4 * f >> 2] : void 0) : "";
3649    e += g;
3650  }
3651  W.shaderSource(Gd[a], e);
3652}, glStencilFunc:(a, b, c) => W.stencilFunc(a, b, c), glStencilFuncSeparate:(a, b, c, d) => W.stencilFuncSeparate(a, b, c, d), glStencilMask:a => W.stencilMask(a), glStencilOp:(a, b, c) => W.stencilOp(a, b, c), glStencilOpSeparate:(a, b, c, d) => W.stencilOpSeparate(a, b, c, d), glTexParameteri:(a, b, c) => W.texParameteri(a, b, c), glTexStorage2D:(a, b, c, d, e) => W.texStorage2D(a, b, c, d, e), glTexStorage3D:(a, b, c, d, e, f) => W.texStorage3D(a, b, c, d, e, f), glTexSubImage2D:(a, b, c, d, e, 
3653f, g, k, p) => {
3654  if (W.Oa) {
3655    W.texSubImage2D(a, b, c, d, e, f, g, k, p);
3656  } else {
3657    if (p) {
3658      var m = Xd(k);
3659      W.texSubImage2D(a, b, c, d, e, f, g, k, m, p >>> 31 - Math.clz32(m.BYTES_PER_ELEMENT));
3660    } else {
3661      if (p) {
3662        m = Xd(k);
3663        var t = f * ((Kd || e) * ({5:3, 6:4, 8:2, 29502:3, 29504:4, 26917:2, 26918:2, 29846:3, 29847:4}[g - 6402] || 1) * m.BYTES_PER_ELEMENT + Jd - 1 & -Jd);
3664        p = m.subarray(p >>> 31 - Math.clz32(m.BYTES_PER_ELEMENT), p + t >>> 31 - Math.clz32(m.BYTES_PER_ELEMENT));
3665      } else {
3666        p = null;
3667      }
3668      W.texSubImage2D(a, b, c, d, e, f, g, k, p);
3669    }
3670  }
3671}, glUniform1i:(a, b) => {
3672  var c = W, d = c.uniform1i;
3673  var e = W.Hb;
3674  if (e) {
3675    var f = e.na[a];
3676    "number" == typeof f && (e.na[a] = f = W.getUniformLocation(e, e.vb[a] + (0 < f ? `[${f}]` : "")));
3677    a = f;
3678  } else {
3679    X ||= 1282, a = void 0;
3680  }
3681  d.call(c, a, b);
3682}, glUniformBlockBinding:(a, b, c) => {
3683  a = V[a];
3684  W.uniformBlockBinding(a, b, c);
3685}, glUseProgram:a => {
3686  a = V[a];
3687  W.useProgram(a);
3688  W.Hb = a;
3689}, glVertexAttribDivisor:(a, b) => {
3690  W.vertexAttribDivisor(a, b);
3691}, glVertexAttribIPointer:(a, b, c, d, e) => {
3692  W.vertexAttribIPointer(a, b, c, d, e);
3693}, glVertexAttribPointer:(a, b, c, d, e, f) => {
3694  W.vertexAttribPointer(a, b, c, !!d, e, f);
3695}, glViewport:(a, b, c, d) => W.viewport(a, b, c, d), invoke_vii:de, isWindowsBrowser:function() {
3696  return -1 < navigator.platform.indexOf("Win");
3697}, provokingVertexWEBGL:function(a, b) {
3698  (a = w[a].C.pb) && a.provokingVertexWEBGL(b);
3699}, strftime:$d, strftime_l:(a, b, c, d) => $d(a, b, c, d), upload_image:function(a, b) {
3700  var c = l.images;
3701  c && (b = c.get(b)) && (a = w[a].C, a.pixelStorei(a.UNPACK_PREMULTIPLY_ALPHA_WEBGL, !0), a.texImage2D(a.TEXTURE_2D, 0, a.RGBA, a.RGBA, a.UNSIGNED_BYTE, b), a.pixelStorei(a.UNPACK_PREMULTIPLY_ALPHA_WEBGL, !1));
3702}}, Y = function() {
3703  function a(c) {
3704    Y = c.exports;
3705    ua = Y.memory;
3706    za();
3707    Qc = Y.__indirect_function_table;
3708    Ba.unshift(Y.__wasm_call_ctors);
3709    Ea--;
3710    l.monitorRunDependencies?.(Ea);
3711    0 == Ea && (null !== Fa && (clearInterval(Fa), Fa = null), Ga && (c = Ga, Ga = null, c()));
3712    return Y;
3713  }
3714  var b = {env:ee, wasi_snapshot_preview1:ee,};
3715  Ea++;
3716  l.monitorRunDependencies?.(Ea);
3717  if (l.instantiateWasm) {
3718    try {
3719      return l.instantiateWasm(b, a);
3720    } catch (c) {
3721      sa(`Module.instantiateWasm callback failed with error: ${c}`), ba(c);
3722    }
3723  }
3724  Ja ||= Ia("webgl2_advanced.wasm") ? "webgl2_advanced.wasm" : l.locateFile ? l.locateFile("webgl2_advanced.wasm", y) : y + "webgl2_advanced.wasm";
3725  Na(b, function(c) {
3726    a(c.instance);
3727  }).catch(ba);
3728  return {};
3729}(), lc = a => (lc = Y.free)(a), Ud = a => (Ud = Y.malloc)(a);
3730l._setWebImage = (a, b, c) => (l._setWebImage = Y.setWebImage)(a, b, c);
3731var kc = a => (kc = Y.__getTypeName)(a), Qa = l._ma_device__on_notification_unlocked = a => (Qa = l._ma_device__on_notification_unlocked = Y.ma_device__on_notification_unlocked)(a);
3732l._ma_malloc_emscripten = (a, b) => (l._ma_malloc_emscripten = Y.ma_malloc_emscripten)(a, b);
3733l._ma_free_emscripten = (a, b) => (l._ma_free_emscripten = Y.ma_free_emscripten)(a, b);
3734var Ra = l._ma_device_process_pcm_frames_capture__webaudio = (a, b, c) => (Ra = l._ma_device_process_pcm_frames_capture__webaudio = Y.ma_device_process_pcm_frames_capture__webaudio)(a, b, c), Sa = l._ma_device_process_pcm_frames_playback__webaudio = (a, b, c) => (Sa = l._ma_device_process_pcm_frames_playback__webaudio = Y.ma_device_process_pcm_frames_playback__webaudio)(a, b, c), fe = (a, b) => (fe = Y.setThrew)(a, b), ge = a => (ge = Y._emscripten_stack_restore)(a), he = () => (he = Y.emscripten_stack_get_current)();
3735l.dynCall_iiiji = (a, b, c, d, e, f) => (l.dynCall_iiiji = Y.dynCall_iiiji)(a, b, c, d, e, f);
3736l.dynCall_iij = (a, b, c, d) => (l.dynCall_iij = Y.dynCall_iij)(a, b, c, d);
3737l.dynCall_iiji = (a, b, c, d, e) => (l.dynCall_iiji = Y.dynCall_iiji)(a, b, c, d, e);
3738l.dynCall_jii = (a, b, c) => (l.dynCall_jii = Y.dynCall_jii)(a, b, c);
3739l.dynCall_vijj = (a, b, c, d, e, f) => (l.dynCall_vijj = Y.dynCall_vijj)(a, b, c, d, e, f);
3740l.dynCall_jiji = (a, b, c, d, e) => (l.dynCall_jiji = Y.dynCall_jiji)(a, b, c, d, e);
3741l.dynCall_viijii = (a, b, c, d, e, f, g) => (l.dynCall_viijii = Y.dynCall_viijii)(a, b, c, d, e, f, g);
3742l.dynCall_iiiiij = (a, b, c, d, e, f, g) => (l.dynCall_iiiiij = Y.dynCall_iiiiij)(a, b, c, d, e, f, g);
3743l.dynCall_iiiiijj = (a, b, c, d, e, f, g, k, p) => (l.dynCall_iiiiijj = Y.dynCall_iiiiijj)(a, b, c, d, e, f, g, k, p);
3744l.dynCall_iiiiiijj = (a, b, c, d, e, f, g, k, p, m) => (l.dynCall_iiiiiijj = Y.dynCall_iiiiiijj)(a, b, c, d, e, f, g, k, p, m);
3745function de(a, b, c) {
3746  var d = he();
3747  try {
3748    Rc(a)(b, c);
3749  } catch (e) {
3750    ge(d);
3751    if (e !== e + 0) {
3752      throw e;
3753    }
3754    fe(1, 0);
3755  }
3756}
3757var ie;
3758Ga = function je() {
3759  ie || ke();
3760  ie || (Ga = je);
3761};
3762function ke() {
3763  function a() {
3764    if (!ie && (ie = !0, l.calledRun = !0, !va)) {
3765      l.noFSInit || Vb || (Vb = !0, l.stdin = l.stdin, l.stdout = l.stdout, l.stderr = l.stderr, l.stdin ? Wb("stdin", l.stdin) : Rb("/dev/tty", "/dev/stdin"), l.stdout ? Wb("stdout", null, l.stdout) : Rb("/dev/tty", "/dev/stdout"), l.stderr ? Wb("stderr", null, l.stderr) : Rb("/dev/tty1", "/dev/stderr"), Sb("/dev/stdin", 0), Sb("/dev/stdout", 1), Sb("/dev/stderr", 1));
3766      Ab = !1;
3767      Ua(Ba);
3768      aa(l);
3769      if (l.onRuntimeInitialized) {
3770        l.onRuntimeInitialized();
3771      }
3772      if (l.postRun) {
3773        for ("function" == typeof l.postRun && (l.postRun = [l.postRun]); l.postRun.length;) {
3774          var b = l.postRun.shift();
3775          Ca.unshift(b);
3776        }
3777      }
3778      Ua(Ca);
3779    }
3780  }
3781  if (!(0 < Ea)) {
3782    if (l.preRun) {
3783      for ("function" == typeof l.preRun && (l.preRun = [l.preRun]); l.preRun.length;) {
3784        Da();
3785      }
3786    }
3787    Ua(Aa);
3788    0 < Ea || (l.setStatus ? (l.setStatus("Running..."), setTimeout(function() {
3789      setTimeout(function() {
3790        l.setStatus("");
3791      }, 1);
3792      a();
3793    }, 1)) : a());
3794  }
3795}
3796if (l.preInit) {
3797  for ("function" == typeof l.preInit && (l.preInit = [l.preInit]); 0 < l.preInit.length;) {
3798    l.preInit.pop()();
3799  }
3800}
3801ke();
3802moduleRtn = ca;
3803
3804
3805
3806  return moduleRtn;
3807}
3808);
3809})();
3810/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Rive);
3811
3812
3813/***/ }),
3814/* 5 */
3815/***/ ((module) => {
3816
3817module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/webgl2","version":"2.37.0","description":"Rive\'s webgl2 based web api.","main":"rive.js","homepage":"https://rive.app","repository":{"type":"git","url":"https://github.com/rive-app/rive-wasm/tree/master/js"},"keywords":["rive","animation"],"author":"Rive","contributors":["Luigi Rosso <[email protected]> (https://rive.app)","Maxwell Talbot <[email protected]> (https://rive.app)","Arthur Vivian <[email protected]> (https://rive.app)","Umberto Sonnino <[email protected]> (https://rive.app)","Matthew Sullivan <[email protected]> (mailto:[email protected])","Chris Dalton <[email protected]> (https://rive.app)"],"license":"MIT","files":["rive.js","rive.wasm","rive.js.map","rive.d.ts","rive_advanced.mjs.d.ts"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
3818
3819/***/ }),
3820/* 6 */
3821/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3822
3823__webpack_require__.r(__webpack_exports__);
3824/* harmony export */ __webpack_require__.d(__webpack_exports__, {
3825/* harmony export */   AudioAssetWrapper: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_2__.AudioAssetWrapper),
3826/* harmony export */   AudioWrapper: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_2__.AudioWrapper),
3827/* harmony export */   BLANK_URL: () => (/* reexport safe */ _sanitizeUrl__WEBPACK_IMPORTED_MODULE_1__.BLANK_URL),
3828/* harmony export */   CustomFileAssetLoaderWrapper: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_2__.CustomFileAssetLoaderWrapper),
3829/* harmony export */   FileAssetWrapper: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_2__.FileAssetWrapper),
3830/* harmony export */   FileFinalizer: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_2__.FileFinalizer),
3831/* harmony export */   FontAssetWrapper: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_2__.FontAssetWrapper),
3832/* harmony export */   FontWrapper: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_2__.FontWrapper),
3833/* harmony export */   ImageAssetWrapper: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_2__.ImageAssetWrapper),
3834/* harmony export */   ImageWrapper: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_2__.ImageWrapper),
3835/* harmony export */   RiveFont: () => (/* reexport safe */ _riveFont__WEBPACK_IMPORTED_MODULE_3__.RiveFont),
3836/* harmony export */   createFinalization: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_2__.createFinalization),
3837/* harmony export */   finalizationRegistry: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_2__.finalizationRegistry),
3838/* harmony export */   registerTouchInteractions: () => (/* reexport safe */ _registerTouchInteractions__WEBPACK_IMPORTED_MODULE_0__.registerTouchInteractions),
3839/* harmony export */   sanitizeUrl: () => (/* reexport safe */ _sanitizeUrl__WEBPACK_IMPORTED_MODULE_1__.sanitizeUrl)
3840/* harmony export */ });
3841/* harmony import */ var _registerTouchInteractions__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7);
3842/* harmony import */ var _sanitizeUrl__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8);
3843/* harmony import */ var _finalizationRegistry__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(9);
3844/* harmony import */ var _riveFont__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(10);
3845
3846
3847
3848
3849
3850
3851/***/ }),
3852/* 7 */
3853/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3854
3855__webpack_require__.r(__webpack_exports__);
3856/* harmony export */ __webpack_require__.d(__webpack_exports__, {
3857/* harmony export */   registerTouchInteractions: () => (/* binding */ registerTouchInteractions)
3858/* harmony export */ });
3859var _this = undefined;
3860/**
3861 * Returns the clientX and clientY properties from touch or mouse events. Also
3862 * calls preventDefault() on the event if it is a touchstart or touchmove to prevent
3863 * scrolling the page on mobile devices
3864 * @param event - Either a TouchEvent or a MouseEvent
3865 * @returns - Coordinates of the clientX and clientY properties from the touch/mouse event
3866 */
3867var getClientCoordinates = function (event, isTouchScrollEnabled, enableMultiTouch) {
3868    var _a, _b;
3869    var coordinates = [];
3870    if (["touchstart", "touchmove"].indexOf(event.type) > -1 &&
3871        ((_a = event.changedTouches) === null || _a === void 0 ? void 0 : _a.length)) {
3872        // This flag, if false, prevents touch events on the canvas default behavior
3873        // which may prevent scrolling if a drag motion on the canvas is performed
3874        if (!isTouchScrollEnabled) {
3875            event.preventDefault();
3876        }
3877        var cnt = 0;
3878        var totalTouches = enableMultiTouch
3879            ? event.changedTouches.length
3880            : 1;
3881        while (cnt < totalTouches) {
3882            var touch = event.changedTouches[cnt];
3883            coordinates.push({
3884                clientX: touch.clientX,
3885                clientY: touch.clientY,
3886                identifier: touch.identifier,
3887            });
3888            cnt++;
3889        }
3890    }
3891    else if (event.type === "touchend" &&
3892        ((_b = event.changedTouches) === null || _b === void 0 ? void 0 : _b.length)) {
3893        var cnt = 0;
3894        var totalTouches = enableMultiTouch
3895            ? event.changedTouches.length
3896            : 1;
3897        while (cnt < totalTouches) {
3898            var touch = event.changedTouches[cnt];
3899            coordinates.push({
3900                clientX: touch.clientX,
3901                clientY: touch.clientY,
3902                identifier: touch.identifier,
3903            });
3904            cnt++;
3905        }
3906    }
3907    else {
3908        coordinates.push({
3909            clientX: event.clientX,
3910            clientY: event.clientY,
3911            identifier: 0,
3912        });
3913    }
3914    return coordinates;
3915};
3916/**
3917 * Registers mouse move/up/down callback handlers on the canvas to send meaningful coordinates to
3918 * the state machine pointer move/up/down functions based on cursor interaction
3919 */
3920var registerTouchInteractions = function (_a) {
3921    var canvas = _a.canvas, artboard = _a.artboard, _b = _a.stateMachines, stateMachines = _b === void 0 ? [] : _b, renderer = _a.renderer, rive = _a.rive, fit = _a.fit, alignment = _a.alignment, _c = _a.isTouchScrollEnabled, isTouchScrollEnabled = _c === void 0 ? false : _c, _d = _a.dispatchPointerExit, dispatchPointerExit = _d === void 0 ? true : _d, _e = _a.enableMultiTouch, enableMultiTouch = _e === void 0 ? false : _e, _f = _a.layoutScaleFactor, layoutScaleFactor = _f === void 0 ? 1.0 : _f;
3922    if (!canvas ||
3923        !stateMachines.length ||
3924        !renderer ||
3925        !rive ||
3926        !artboard ||
3927        typeof window === "undefined") {
3928        return null;
3929    }
3930    /**
3931     * After a touchend event, some browsers may fire synthetic mouse events
3932     * (mouseover, mousedown, mousemove, mouseup) if the touch interaction did not cause
3933     * any default action (such as scrolling).
3934     *
3935     * This is done to simulate the behavior of a mouse for applications that do not support
3936     * touch events.
3937     *
3938     * We're keeping track of the previous event to not send the synthetic mouse events if the
3939     * touch event was a click (touchstart -> touchend).
3940     *
3941     * This is only needed when `isTouchScrollEnabled` is false
3942     * When true, `preventDefault()` is called which prevents this behaviour.
3943     **/
3944    var _prevEventType = null;
3945    var _syntheticEventsActive = false;
vendor: 10,644 bytes, lines 3946-4174
3946    var processEventCallback = function (event) {
3947        // Exit early out of all synthetic mouse events
3948        // https://stackoverflow.com/questions/9656990/how-to-prevent-simulated-mouse-events-in-mobile-browsers
3949        // https://stackoverflow.com/questions/25572070/javascript-touchend-versus-click-dilemma
3950        if (_syntheticEventsActive && event instanceof MouseEvent) {
3951            // Synthetic event finished
3952            if (event.type == "mouseup") {
3953                _syntheticEventsActive = false;
3954            }
3955            return;
3956        }
3957        // Test if it's a "touch click". This could cause the browser to send
3958        // synthetic mouse events.
3959        _syntheticEventsActive =
3960            isTouchScrollEnabled &&
3961                event.type === "touchend" &&
3962                _prevEventType === "touchstart";
3963        _prevEventType = event.type;
3964        var boundingRect = event.currentTarget.getBoundingClientRect();
3965        var coordinateSets = getClientCoordinates(event, isTouchScrollEnabled, enableMultiTouch);
3966        var forwardMatrix = rive.computeAlignment(fit, alignment, {
3967            minX: 0,
3968            minY: 0,
3969            maxX: boundingRect.width,
3970            maxY: boundingRect.height,
3971        }, artboard.bounds, layoutScaleFactor);
3972        var invertedMatrix = new rive.Mat2D();
3973        forwardMatrix.invert(invertedMatrix);
3974        coordinateSets.forEach(function (coordinateSet) {
3975            var clientX = coordinateSet.clientX;
3976            var clientY = coordinateSet.clientY;
3977            if (!clientX && !clientY) {
3978                return;
3979            }
3980            var canvasX = clientX - boundingRect.left;
3981            var canvasY = clientY - boundingRect.top;
3982            var canvasCoordinatesVector = new rive.Vec2D(canvasX, canvasY);
3983            var transformedVector = rive.mapXY(invertedMatrix, canvasCoordinatesVector);
3984            var transformedX = transformedVector.x();
3985            var transformedY = transformedVector.y();
3986            coordinateSet.transformedX = transformedX;
3987            coordinateSet.transformedY = transformedY;
3988            transformedVector.delete();
3989            canvasCoordinatesVector.delete();
3990        });
3991        invertedMatrix.delete();
3992        forwardMatrix.delete();
3993        switch (event.type) {
3994            /**
3995             * There's a 2px buffer for a hitRadius when translating the pointer coordinates
3996             * down to the state machine. In cases where the hitbox is about that much away
3997             * from the Artboard border, we don't have exact precision on determining pointer
3998             * exit. We're therefore adding to the translated coordinates on mouseout of a canvas
3999             * to ensure that we report the mouse has truly exited the hitarea.
4000             * https://github.com/rive-app/rive-cpp/blob/master/src/animation/state_machine_instance.cpp#L336
4001             *
4002             */
4003            case "mouseout":
4004                var _loop_1 = function (stateMachine) {
4005                    if (dispatchPointerExit) {
4006                        coordinateSets.forEach(function (coordinateSet) {
4007                            stateMachine.pointerExit(coordinateSet.transformedX, coordinateSet.transformedY, coordinateSet.identifier);
4008                        });
4009                    }
4010                    else {
4011                        coordinateSets.forEach(function (coordinateSet) {
4012                            stateMachine.pointerMove(coordinateSet.transformedX, coordinateSet.transformedY, coordinateSet.identifier);
4013                        });
4014                    }
4015                };
4016                for (var _i = 0, stateMachines_1 = stateMachines; _i < stateMachines_1.length; _i++) {
4017                    var stateMachine = stateMachines_1[_i];
4018                    _loop_1(stateMachine);
4019                }
4020                break;
4021            // Pointer moving/hovering on the canvas
4022            case "touchmove":
4023            case "mouseover":
4024            case "mousemove": {
4025                var _loop_2 = function (stateMachine) {
4026                    coordinateSets.forEach(function (coordinateSet) {
4027                        stateMachine.pointerMove(coordinateSet.transformedX, coordinateSet.transformedY, coordinateSet.identifier);
4028                    });
4029                };
4030                for (var _a = 0, stateMachines_2 = stateMachines; _a < stateMachines_2.length; _a++) {
4031                    var stateMachine = stateMachines_2[_a];
4032                    _loop_2(stateMachine);
4033                }
4034                break;
4035            }
4036            // Pointer click initiated but not released yet on the canvas
4037            case "touchstart":
4038            case "mousedown": {
4039                var _loop_3 = function (stateMachine) {
4040                    coordinateSets.forEach(function (coordinateSet) {
4041                        stateMachine.pointerDown(coordinateSet.transformedX, coordinateSet.transformedY, coordinateSet.identifier);
4042                    });
4043                };
4044                for (var _b = 0, stateMachines_3 = stateMachines; _b < stateMachines_3.length; _b++) {
4045                    var stateMachine = stateMachines_3[_b];
4046                    _loop_3(stateMachine);
4047                }
4048                break;
4049            }
4050            // Pointer click released on the canvas
4051            case "touchend": {
4052                var _loop_4 = function (stateMachine) {
4053                    coordinateSets.forEach(function (coordinateSet) {
4054                        stateMachine.pointerUp(coordinateSet.transformedX, coordinateSet.transformedY, coordinateSet.identifier);
4055                        stateMachine.pointerExit(coordinateSet.transformedX, coordinateSet.transformedY, coordinateSet.identifier);
4056                    });
4057                };
4058                for (var _c = 0, stateMachines_4 = stateMachines; _c < stateMachines_4.length; _c++) {
4059                    var stateMachine = stateMachines_4[_c];
4060                    _loop_4(stateMachine);
4061                }
4062                break;
4063            }
4064            case "mouseup": {
4065                var _loop_5 = function (stateMachine) {
4066                    coordinateSets.forEach(function (coordinateSet) {
4067                        stateMachine.pointerUp(coordinateSet.transformedX, coordinateSet.transformedY, coordinateSet.identifier);
4068                    });
4069                };
4070                for (var _d = 0, stateMachines_5 = stateMachines; _d < stateMachines_5.length; _d++) {
4071                    var stateMachine = stateMachines_5[_d];
4072                    _loop_5(stateMachine);
4073                }
4074                break;
4075            }
4076            default:
4077        }
4078    };
4079    var callback = processEventCallback.bind(_this);
4080    canvas.addEventListener("mouseover", callback);
4081    canvas.addEventListener("mouseout", callback);
4082    canvas.addEventListener("mousemove", callback);
4083    canvas.addEventListener("mousedown", callback);
4084    canvas.addEventListener("mouseup", callback);
4085    canvas.addEventListener("touchmove", callback, {
4086        passive: isTouchScrollEnabled,
4087    });
4088    canvas.addEventListener("touchstart", callback, {
4089        passive: isTouchScrollEnabled,
4090    });
4091    canvas.addEventListener("touchend", callback);
4092    return function () {
4093        canvas.removeEventListener("mouseover", callback);
4094        canvas.removeEventListener("mouseout", callback);
4095        canvas.removeEventListener("mousemove", callback);
4096        canvas.removeEventListener("mousedown", callback);
4097        canvas.removeEventListener("mouseup", callback);
4098        canvas.removeEventListener("touchmove", callback);
4099        canvas.removeEventListener("touchstart", callback);
4100        canvas.removeEventListener("touchend", callback);
4101    };
4102};
4103
4104
4105/***/ }),
4106/* 8 */
4107/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
4108
4109__webpack_require__.r(__webpack_exports__);
4110/* harmony export */ __webpack_require__.d(__webpack_exports__, {
4111/* harmony export */   BLANK_URL: () => (/* binding */ BLANK_URL),
4112/* harmony export */   sanitizeUrl: () => (/* binding */ sanitizeUrl)
4113/* harmony export */ });
4114// Reference: https://github.com/braintree/sanitize-url/tree/main
4115var invalidProtocolRegex = /^([^\w]*)(javascript|data|vbscript)/im;
4116var htmlEntitiesRegex = /&#(\w+)(^\w|;)?/g;
4117var htmlCtrlEntityRegex = /&(newline|tab);/gi;
4118var ctrlCharactersRegex = /[\u0000-\u001F\u007F-\u009F\u2000-\u200D\uFEFF]/gim;
4119var urlSchemeRegex = /^.+(:|&colon;)/gim;
4120var relativeFirstCharacters = [".", "/"];
4121var BLANK_URL = "about:blank";
4122function isRelativeUrlWithoutProtocol(url) {
4123    return relativeFirstCharacters.indexOf(url[0]) > -1;
4124}
4125// adapted from https://stackoverflow.com/a/29824550/2601552
4126function decodeHtmlCharacters(str) {
4127    var removedNullByte = str.replace(ctrlCharactersRegex, "");
4128    return removedNullByte.replace(htmlEntitiesRegex, function (match, dec) {
4129        return String.fromCharCode(dec);
4130    });
4131}
4132function sanitizeUrl(url) {
4133    if (!url) {
4134        return BLANK_URL;
4135    }
4136    var sanitizedUrl = decodeHtmlCharacters(url)
4137        .replace(htmlCtrlEntityRegex, "")
4138        .replace(ctrlCharactersRegex, "")
4139        .trim();
4140    if (!sanitizedUrl) {
4141        return BLANK_URL;
4142    }
4143    if (isRelativeUrlWithoutProtocol(sanitizedUrl)) {
4144        return sanitizedUrl;
4145    }
4146    var urlSchemeParseResults = sanitizedUrl.match(urlSchemeRegex);
4147    if (!urlSchemeParseResults) {
4148        return sanitizedUrl;
4149    }
4150    var urlScheme = urlSchemeParseResults[0];
4151    if (invalidProtocolRegex.test(urlScheme)) {
4152        return BLANK_URL;
4153    }
4154    return sanitizedUrl;
4155}
4156
4157
4158/***/ }),
4159/* 9 */
4160/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
4161
4162__webpack_require__.r(__webpack_exports__);
4163/* harmony export */ __webpack_require__.d(__webpack_exports__, {
4164/* harmony export */   AudioAssetWrapper: () => (/* binding */ AudioAssetWrapper),
4165/* harmony export */   AudioWrapper: () => (/* binding */ AudioWrapper),
4166/* harmony export */   CustomFileAssetLoaderWrapper: () => (/* binding */ CustomFileAssetLoaderWrapper),
4167/* harmony export */   FileAssetWrapper: () => (/* binding */ FileAssetWrapper),
4168/* harmony export */   FileFinalizer: () => (/* binding */ FileFinalizer),
4169/* harmony export */   FontAssetWrapper: () => (/* binding */ FontAssetWrapper),
4170/* harmony export */   FontWrapper: () => (/* binding */ FontWrapper),
4171/* harmony export */   ImageAssetWrapper: () => (/* binding */ ImageAssetWrapper),
4172/* harmony export */   ImageWrapper: () => (/* binding */ ImageWrapper),
4173/* harmony export */   createFinalization: () => (/* binding */ createFinalization),
4174/* harmony export */   finalizationRegistry: () =>
4174 (/* binding */ finalizationRegistry)
4175/* harmony export */ });
4176var __extends = (undefined && undefined.__extends) || (function () {
4177    var extendStatics = function (d, b) {
4178        extendStatics = Object.setPrototypeOf ||
4179            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
4180            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
4181        return extendStatics(d, b);
4182    };
4183    return function (d, b) {
4184        if (typeof b !== "function" && b !== null)
4185            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
4186        extendStatics(d, b);
4187        function __() { this.constructor = d; }
4188        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
4189    };
4190})();
4191var FileFinalizer = /** @class */ (function () {
4192    function FileFinalizer(file) {
4193        this.selfUnref = false;
4194        this._file = file;
4195    }
4196    FileFinalizer.prototype.unref = function () {
4197        if (this._file) {
4198            this._file.unref();
4199        }
4200    };
4201    return FileFinalizer;
4202}());
4203var ObjectFinalizer = /** @class */ (function () {
4204    function ObjectFinalizer(finalizableObject) {
4205        this._finalizableObject = finalizableObject;
4206    }
4207    ObjectFinalizer.prototype.unref = function () {
4208        this._finalizableObject.unref();
4209    };
4210    return ObjectFinalizer;
4211}());
4212var AssetWrapper = /** @class */ (function () {
4213    function AssetWrapper() {
4214        this.selfUnref = false;
vendor: 41,869 bytes, lines 4215-5188
4215    }
4216    AssetWrapper.prototype.unref = function () { };
4217    return AssetWrapper;
4218}());
4219var ImageWrapper = /** @class */ (function (_super) {
4220    __extends(ImageWrapper, _super);
4221    function ImageWrapper(image) {
4222        var _this = _super.call(this) || this;
4223        _this._nativeImage = image;
4224        return _this;
4225    }
4226    Object.defineProperty(ImageWrapper.prototype, "nativeImage", {
4227        get: function () {
4228            return this._nativeImage;
4229        },
4230        enumerable: false,
4231        configurable: true
4232    });
4233    ImageWrapper.prototype.unref = function () {
4234        if (this.selfUnref) {
4235            this._nativeImage.unref();
4236        }
4237    };
4238    return ImageWrapper;
4239}(AssetWrapper));
4240var AudioWrapper = /** @class */ (function (_super) {
4241    __extends(AudioWrapper, _super);
4242    function AudioWrapper(audio) {
4243        var _this = _super.call(this) || this;
4244        _this._nativeAudio = audio;
4245        return _this;
4246    }
4247    Object.defineProperty(AudioWrapper.prototype, "nativeAudio", {
4248        get: function () {
4249            return this._nativeAudio;
4250        },
4251        enumerable: false,
4252        configurable: true
4253    });
4254    AudioWrapper.prototype.unref = function () {
4255        if (this.selfUnref) {
4256            this._nativeAudio.unref();
4257        }
4258    };
4259    return AudioWrapper;
4260}(AssetWrapper));
4261var FontWrapper = /** @class */ (function (_super) {
4262    __extends(FontWrapper, _super);
4263    function FontWrapper(font) {
4264        var _this = _super.call(this) || this;
4265        _this._nativeFont = font;
4266        return _this;
4267    }
4268    Object.defineProperty(FontWrapper.prototype, "nativeFont", {
4269        get: function () {
4270            return this._nativeFont;
4271        },
4272        enumerable: false,
4273        configurable: true
4274    });
4275    FontWrapper.prototype.unref = function () {
4276        if (this.selfUnref) {
4277            this._nativeFont.unref();
4278        }
4279    };
4280    return FontWrapper;
4281}(AssetWrapper));
4282var CustomFileAssetLoaderWrapper = /** @class */ (function () {
4283    function CustomFileAssetLoaderWrapper(runtime, loaderCallback) {
4284        this._assetLoaderCallback = loaderCallback;
4285        this.assetLoader = new runtime.CustomFileAssetLoader({
4286            loadContents: this.loadContents.bind(this),
4287        });
4288    }
4289    CustomFileAssetLoaderWrapper.prototype.loadContents = function (asset, bytes) {
4290        var assetWrapper;
4291        if (asset.isImage) {
4292            assetWrapper = new ImageAssetWrapper(asset);
4293        }
4294        else if (asset.isAudio) {
4295            assetWrapper = new AudioAssetWrapper(asset);
4296        }
4297        else if (asset.isFont) {
4298            assetWrapper = new FontAssetWrapper(asset);
4299        }
4300        return this._assetLoaderCallback(assetWrapper, bytes);
4301    };
4302    return CustomFileAssetLoaderWrapper;
4303}());
4304/**
4305 * Rive class representing a FileAsset with relevant metadata fields to describe
4306 * an asset associated wtih the Rive File
4307 */
4308var FileAssetWrapper = /** @class */ (function () {
4309    function FileAssetWrapper(nativeAsset) {
4310        this._nativeFileAsset = nativeAsset;
4311    }
4312    FileAssetWrapper.prototype.decode = function (bytes) {
4313        this._nativeFileAsset.decode(bytes);
4314    };
4315    Object.defineProperty(FileAssetWrapper.prototype, "name", {
4316        get: function () {
4317            return this._nativeFileAsset.name;
4318        },
4319        enumerable: false,
4320        configurable: true
4321    });
4322    Object.defineProperty(FileAssetWrapper.prototype, "fileExtension", {
4323        get: function () {
4324            return this._nativeFileAsset.fileExtension;
4325        },
4326        enumerable: false,
4327        configurable: true
4328    });
4329    Object.defineProperty(FileAssetWrapper.prototype, "uniqueFilename", {
4330        get: function () {
4331            return this._nativeFileAsset.uniqueFilename;
4332        },
4333        enumerable: false,
4334        configurable: true
4335    });
4336    Object.defineProperty(FileAssetWrapper.prototype, "isAudio", {
4337        get: function () {
4338            return this._nativeFileAsset.isAudio;
4339        },
4340        enumerable: false,
4341        configurable: true
4342    });
4343    Object.defineProperty(FileAssetWrapper.prototype, "isImage", {
4344        get: function () {
4345            return this._nativeFileAsset.isImage;
4346        },
4347        enumerable: false,
4348        configurable: true
4349    });
4350    Object.defineProperty(FileAssetWrapper.prototype, "isFont", {
4351        get: function () {
4352            return this._nativeFileAsset.isFont;
4353        },
4354        enumerable: false,
4355        configurable: true
4356    });
4357    Object.defineProperty(FileAssetWrapper.prototype, "cdnUuid", {
4358        get: function () {
4359            return this._nativeFileAsset.cdnUuid;
4360        },
4361        enumerable: false,
4362        configurable: true
4363    });
4364    Object.defineProperty(FileAssetWrapper.prototype, "nativeFileAsset", {
4365        get: function () {
4366            return this._nativeFileAsset;
4367        },
4368        enumerable: false,
4369        configurable: true
4370    });
4371    return FileAssetWrapper;
4372}());
4373/**
4374 * Rive class extending the FileAsset that exposes a `setRenderImage()` API with a
4375 * decoded Image (via the `decodeImage()` API) to set a new Image on the Rive FileAsset
4376 */
4377var ImageAssetWrapper = /** @class */ (function (_super) {
4378    __extends(ImageAssetWrapper, _super);
4379    function ImageAssetWrapper() {
4380        return _super !== null && _super.apply(this, arguments) || this;
4381    }
4382    ImageAssetWrapper.prototype.setRenderImage = function (image) {
4383        this._nativeFileAsset.setRenderImage(image.nativeImage);
4384    };
4385    return ImageAssetWrapper;
4386}(FileAssetWrapper));
4387/**
4388 * Rive class extending the FileAsset that exposes a `setAudioSource()` API with a
4389 * decoded Audio (via the `decodeAudio()` API) to set a new Audio on the Rive FileAsset
4390 */
4391var AudioAssetWrapper = /** @class */ (function (_super) {
4392    __extends(AudioAssetWrapper, _super);
4393    function AudioAssetWrapper() {
4394        return _super !== null && _super.apply(this, arguments) || this;
4395    }
4396    AudioAssetWrapper.prototype.setAudioSource = function (audio) {
4397        this._nativeFileAsset.setAudioSource(audio.nativeAudio);
4398    };
4399    return AudioAssetWrapper;
4400}(FileAssetWrapper));
4401/**
4402 * Rive class extending the FileAsset that exposes a `setFont()` API with a
4403 * decoded Font (via the `decodeFont()` API) to set a new Font on the Rive FileAsset
4404 */
4405var FontAssetWrapper = /** @class */ (function (_super) {
4406    __extends(FontAssetWrapper, _super);
4407    function FontAssetWrapper() {
4408        return _super !== null && _super.apply(this, arguments) || this;
4409    }
4410    FontAssetWrapper.prototype.setFont = function (font) {
4411        this._nativeFileAsset.setFont(font.nativeFont);
4412    };
4413    return FontAssetWrapper;
4414}(FileAssetWrapper));
4415var FakeFinalizationRegistry = /** @class */ (function () {
4416    function FakeFinalizationRegistry(_) {
4417    }
4418    FakeFinalizationRegistry.prototype.register = function (object) {
4419        object.selfUnref = true;
4420    };
4421    FakeFinalizationRegistry.prototype.unregister = function (_) { };
4422    return FakeFinalizationRegistry;
4423}());
4424var MyFinalizationRegistry = typeof FinalizationRegistry !== "undefined"
4425    ? FinalizationRegistry
4426    : FakeFinalizationRegistry;
4427var finalizationRegistry = new MyFinalizationRegistry(function (ob) {
4428    ob === null || ob === void 0 ? void 0 : ob.unref();
4429});
4430var createFinalization = function (target, finalizable) {
4431    var finalizer = new ObjectFinalizer(finalizable);
4432    finalizationRegistry.register(target, finalizer);
4433};
4434
4435
4436
4437/***/ }),
4438/* 10 */
4439/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
4440
4441__webpack_require__.r(__webpack_exports__);
4442/* harmony export */ __webpack_require__.d(__webpack_exports__, {
4443/* harmony export */   RiveFont: () => (/* binding */ RiveFont)
4444/* harmony export */ });
4445/* harmony import */ var _runtimeLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3);
4446
4447// Class to manage fallback fonts for Rive.
4448var RiveFont = /** @class */ (function () {
4449    // Class is never instantiated
4450    function RiveFont() {
4451    }
4452    /**
4453     * Set a callback to dynamically set a list of fallback fonts based on the missing glyph and/or style of the default font.
4454     * Set null to clear the callback.
4455     * @param fontCallback Callback to set a list of fallback fonts.
4456     */
4457    RiveFont.setFallbackFontCallback = function (fontCallback) {
4458        RiveFont._fallbackFontCallback = fontCallback !== null && fontCallback !== void 0 ? fontCallback : null;
4459        RiveFont._wireFallbackProc();
4460    };
4461    // Get the pointer value to the Embind Font object from FontWrapper
4462    RiveFont._fontToPtr = function (fontWrapper) {
4463        var _a;
4464        if (fontWrapper == null)
4465            return null;
4466        var embindFont = fontWrapper.nativeFont;
4467        var ptr = (_a = embindFont === null || embindFont === void 0 ? void 0 : embindFont.ptr) === null || _a === void 0 ? void 0 : _a.call(embindFont);
4468        return ptr !== null && ptr !== void 0 ? ptr : null;
4469    };
4470    RiveFont._getFallbackPtr = function (fonts, index) {
4471        if (index < 0 || index >= fonts.length)
4472            return null;
4473        return RiveFont._fontToPtr(fonts[index]);
4474    };
4475    // Create the callback Rive expects to use for fallback fonts (regardless if set via a user-supplied static list, or callback)
4476    // 1. Ensure WASM is ready
4477    // 2. Bias for checking user callback over static list of fonts and pass it down to Rive to store as reference
4478    //    - When calling the user callback, check if we have any fonts left to check, and if not, return null to indicate there are no more fallbacks to try.
4479    //    - If the user callback returns an array of fonts, pass the pointer value to Rive of the font to try
4480    // 3. If no callback is provided, or the callback returns null, try the static list of fonts if they set any
4481    // 4. If no fallback method is set, return null.
4482    RiveFont._wireFallbackProc = function () {
4483        _runtimeLoader__WEBPACK_IMPORTED_MODULE_0__.RuntimeLoader.getInstance(function (rive) {
4484            var cb = RiveFont._fallbackFontCallback;
4485            if (cb) {
4486                rive.setFallbackFontCallback((function (missingGlyph, fallbackFontIndex, weight) {
4487                    var fontsReturned = cb(missingGlyph, weight);
4488                    if (fontsReturned) {
4489                        if (Array.isArray(fontsReturned)) {
4490                            return RiveFont._getFallbackPtr(fontsReturned, fallbackFontIndex);
4491                        }
4492                        // If the user callback only returns a single font, provide it to Rive the first time, otherwise if Rive
4493                        // calls back a second time, return null to indicate there are no more fallbacks to try.
4494                        return fallbackFontIndex === 0 ? RiveFont._fontToPtr(fontsReturned) : null;
4495                    }
4496                    return null;
4497                }));
4498            }
4499            else {
4500                rive.setFallbackFontCallback(null);
4501            }
4502        });
4503    };
4504    RiveFont._fallbackFontCallback = null;
4505    return RiveFont;
4506}());
4507
4508
4509
4510/***/ })
4511/******/ 	]);
4512/************************************************************************/
4513/******/ 	// The module cache
4514/******/ 	var __webpack_module_cache__ = {};
4515/******/ 	
4516/******/ 	// The require function
4517/******/ 	function __webpack_require__(moduleId) {
4518/******/ 		// Check if module is in cache
4519/******/ 		var cachedModule = __webpack_module_cache__[moduleId];
4520/******/ 		if (cachedModule !== undefined) {
4521/******/ 			return cachedModule.exports;
4522/******/ 		}
4523/******/ 		// Create a new module (and put it into the cache)
4524/******/ 		var module = __webpack_module_cache__[moduleId] = {
4525/******/ 			// no module.id needed
4526/******/ 			// no module.loaded needed
4527/******/ 			exports: {}
4528/******/ 		};
4529/******/ 	
4530/******/ 		// Execute the module function
4531/******/ 		__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
4532/******/ 	
4533/******/ 		// Return the exports of the module
4534/******/ 		return module.exports;
4535/******/ 	}
4536/******/ 	
4537/************************************************************************/
4538/******/ 	/* webpack/runtime/define property getters */
4539/******/ 	(() => {
4540/******/ 		// define getter functions for harmony exports
4541/******/ 		__webpack_require__.d = (exports, definition) => {
4542/******/ 			for(var key in definition) {
4543/******/ 				if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
4544/******/ 					Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
4545/******/ 				}
4546/******/ 			}
4547/******/ 		};
4548/******/ 	})();
4549/******/ 	
4550/******/ 	/* webpack/runtime/hasOwnProperty shorthand */
4551/******/ 	(() => {
4552/******/ 		__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
4553/******/ 	})();
4554/******/ 	
4555/******/ 	/* webpack/runtime/make namespace object */
4556/******/ 	(() => {
4557/******/ 		// define __esModule on exports
4558/******/ 		__webpack_require__.r = (exports) => {
4559/******/ 			if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
4560/******/ 				Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4561/******/ 			}
4562/******/ 			Object.defineProperty(exports, '__esModule', { value: true });
4563/******/ 		};
4564/******/ 	})();
4565/******/ 	
4566/************************************************************************/
4567var __webpack_exports__ = {};
4568// This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
4569(() => {
4570__webpack_require__.r(__webpack_exports__);
4571/* harmony export */ __webpack_require__.d(__webpack_exports__, {
4572/* harmony export */   Alignment: () => (/* binding */ Alignment),
4573/* harmony export */   DataEnum: () => (/* binding */ DataEnum),
4574/* harmony export */   DataType: () => (/* binding */ DataType),
4575/* harmony export */   DrawOptimizationOptions: () => (/* binding */ DrawOptimizationOptions),
4576/* harmony export */   EventType: () => (/* binding */ EventType),
4577/* harmony export */   Fit: () => (/* binding */ Fit),
4578/* harmony export */   Layout: () => (/* binding */ Layout),
4579/* harmony export */   LoopType: () => (/* binding */ LoopType),
4580/* harmony export */   Rive: () => (/* binding */ Rive),
4581/* harmony export */   RiveEventType: () => (/* binding */ RiveEventType),
4582/* harmony export */   RiveFile: () => (/* binding */ RiveFile),
4583/* harmony export */   RiveFont: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_2__.RiveFont),
4584/* harmony export */   RuntimeLoader: () => (/* reexport safe */ _runtimeLoader__WEBPACK_IMPORTED_MODULE_1__.RuntimeLoader),
4585/* harmony export */   StateMachineInput: () => (/* binding */ StateMachineInput),
4586/* harmony export */   StateMachineInputType: () => (/* binding */ StateMachineInputType),
4587/* harmony export */   Testing: () => (/* binding */ Testing),
4588/* harmony export */   ViewModel: () => (/* binding */ ViewModel),
4589/* harmony export */   ViewModelInstance: () => (/* binding */ ViewModelInstance),
4590/* harmony export */   ViewModelInstanceArtboard: () => (/* binding */ ViewModelInstanceArtboard),
4591/* harmony export */   ViewModelInstanceAssetImage: () => (/* binding */ ViewModelInstanceAssetImage),
4592/* harmony export */   ViewModelInstanceBoolean: () => (/* binding */ ViewModelInstanceBoolean),
4593/* harmony export */   ViewModelInstanceColor: () => (/* binding */ ViewModelInstanceColor),
4594/* harmony export */   ViewModelInstanceEnum: () => (/* binding */ ViewModelInstanceEnum),
4595/* harmony export */   ViewModelInstanceList: () => (/* binding */ ViewModelInstanceList),
4596/* harmony export */   ViewModelInstanceNumber: () => (/* binding */ ViewModelInstanceNumber),
4597/* harmony export */   ViewModelInstanceString: () => (/* binding */ ViewModelInstanceString),
4598/* harmony export */   ViewModelInstanceTrigger: () => (/* binding */ ViewModelInstanceTrigger),
4599/* harmony export */   ViewModelInstanceValue: () => (/* binding */ ViewModelInstanceValue),
4600/* harmony export */   decodeAudio: () => (/* binding */ decodeAudio),
4601/* harmony export */   decodeFont: () => (/* binding */ decodeFont),
4602/* harmony export */   decodeImage: () => (/* binding */ decodeImage)
4603/* harmony export */ });
4604/* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1);
4605/* harmony import */ var _runtimeLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3);
4606/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6);
4607var __extends = (undefined && undefined.__extends) || (function () {
4608    var extendStatics = function (d, b) {
4609        extendStatics = Object.setPrototypeOf ||
4610            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
4611            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
4612        return extendStatics(d, b);
4613    };
4614    return function (d, b) {
4615        if (typeof b !== "function" && b !== null)
4616            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
4617        extendStatics(d, b);
4618        function __() { this.constructor = d; }
4619        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
4620    };
4621})();
4622var __assign = (undefined && undefined.__assign) || function () {
4623    __assign = Object.assign || function(t) {
4624        for (var s, i = 1, n = arguments.length; i < n; i++) {
4625            s = arguments[i];
4626            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
4627                t[p] = s[p];
4628        }
4629        return t;
4630    };
4631    return __assign.apply(this, arguments);
4632};
4633var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
4634    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4635    return new (P || (P = Promise))(function (resolve, reject) {
4636        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
4637        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
4638        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
4639        step((generator = generator.apply(thisArg, _arguments || [])).next());
4640    });
4641};
4642var __generator = (undefined && undefined.__generator) || function (thisArg, body) {
4643    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
4644    return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
4645    function verb(n) { return function (v) { return step([n, v]); }; }
4646    function step(op) {
4647        if (f) throw new TypeError("Generator is already executing.");
4648        while (g && (g = 0, op[0] && (_ = 0)), _) try {
4649            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
4650            if (y = 0, t) op = [op[0] & 2, t.value];
4651            switch (op[0]) {
4652                case 0: case 1: t = op; break;
4653                case 4: _.label++; return { value: op[1], done: false };
4654                case 5: _.label++; y = op[1]; op = [0]; continue;
4655                case 7: op = _.ops.pop(); _.trys.pop(); continue;
4656                default:
4657                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
4658                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
4659                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
4660                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
4661                    if (t[2]) _.ops.pop();
4662                    _.trys.pop(); continue;
4663            }
4664            op = body.call(thisArg, _);
4665        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
4666        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
4667    }
4668};
4669var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from, pack) {
4670    if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4671        if (ar || !(i in from)) {
4672            if (!ar) ar = Array.prototype.slice.call(from, 0, i);
4673            ar[i] = from[i];
4674        }
4675    }
4676    return to.concat(ar || Array.prototype.slice.call(from));
4677};
4678
4679
4680
4681var RiveError = /** @class */ (function (_super) {
4682    __extends(RiveError, _super);
4683    function RiveError() {
4684        var _this = _super !== null && _super.apply(this, arguments) || this;
4685        _this.isHandledError = true;
4686        return _this;
4687    }
4688    return RiveError;
4689}(Error));
4690
4691// #regions helpers
4692var resolveErrorMessage = function (error) {
4693    return error && error.isHandledError
4694        ? error.message
4695        : "Problem loading file; may be corrupt!";
4696};
4697// #region layout
4698// Fit options for the canvas
4699var Fit;
4700(function (Fit) {
4701    Fit["Cover"] = "cover";
4702    Fit["Contain"] = "contain";
4703    Fit["Fill"] = "fill";
4704    Fit["FitWidth"] = "fitWidth";
4705    Fit["FitHeight"] = "fitHeight";
4706    Fit["None"] = "none";
4707    Fit["ScaleDown"] = "scaleDown";
4708    Fit["Layout"] = "layout";
4709})(Fit || (Fit = {}));
4710// Alignment options for the canvas
4711var Alignment;
4712(function (Alignment) {
4713    Alignment["Center"] = "center";
4714    Alignment["TopLeft"] = "topLeft";
4715    Alignment["TopCenter"] = "topCenter";
4716    Alignment["TopRight"] = "topRight";
4717    Alignment["CenterLeft"] = "centerLeft";
4718    Alignment["CenterRight"] = "centerRight";
4719    Alignment["BottomLeft"] = "bottomLeft";
4720    Alignment["BottomCenter"] = "bottomCenter";
4721    Alignment["BottomRight"] = "bottomRight";
4722})(Alignment || (Alignment = {}));
4723// Drawing optimization options
4724var DrawOptimizationOptions;
4725(function (DrawOptimizationOptions) {
4726    DrawOptimizationOptions["AlwaysDraw"] = "alwaysDraw";
4727    DrawOptimizationOptions["DrawOnChanged"] = "drawOnChanged";
4728})(DrawOptimizationOptions || (DrawOptimizationOptions = {}));
4729// Alignment options for Rive animations in a HTML canvas
4730var Layout = /** @class */ (function () {
4731    function Layout(params) {
4732        var _a, _b, _c, _d, _e, _f, _g;
4733        this.fit = (_a = params === null || params === void 0 ? void 0 : params.fit) !== null && _a !== void 0 ? _a : Fit.Contain;
4734        this.alignment = (_b = params === null || params === void 0 ? void 0 : params.alignment) !== null && _b !== void 0 ? _b : Alignment.Center;
4735        this.layoutScaleFactor = (_c = params === null || params === void 0 ? void 0 : params.layoutScaleFactor) !== null && _c !== void 0 ? _c : 1;
4736        this.minX = (_d = params === null || params === void 0 ? void 0 : params.minX) !== null && _d !== void 0 ? _d : 0;
4737        this.minY = (_e = params === null || params === void 0 ? void 0 : params.minY) !== null && _e !== void 0 ? _e : 0;
4738        this.maxX = (_f = params === null || params === void 0 ? void 0 : params.maxX) !== null && _f !== void 0 ? _f : 0;
4739        this.maxY = (_g = params === null || params === void 0 ? void 0 : params.maxY) !== null && _g !== void 0 ? _g : 0;
4740    }
4741    // Alternative constructor to build a Layout from an interface/object
4742    Layout.new = function (_a) {
4743        var fit = _a.fit, alignment = _a.alignment, minX = _a.minX, minY = _a.minY, maxX = _a.maxX, maxY = _a.maxY;
4744        console.warn("This function is deprecated: please use `new Layout({})` instead");
4745        return new Layout({ fit: fit, alignment: alignment, minX: minX, minY: minY, maxX: maxX, maxY: maxY });
4746    };
4747    /**
4748     * Makes a copy of the layout, replacing any specified parameters
4749     */
4750    Layout.prototype.copyWith = function (_a) {
4751        var fit = _a.fit, alignment = _a.alignment, layoutScaleFactor = _a.layoutScaleFactor, minX = _a.minX, minY = _a.minY, maxX = _a.maxX, maxY = _a.maxY;
4752        return new Layout({
4753            fit: fit !== null && fit !== void 0 ? fit : this.fit,
4754            alignment: alignment !== null && alignment !== void 0 ? alignment : this.alignment,
4755            layoutScaleFactor: layoutScaleFactor !== null && layoutScaleFactor !== void 0 ? layoutScaleFactor : this.layoutScaleFactor,
4756            minX: minX !== null && minX !== void 0 ? minX : this.minX,
4757            minY: minY !== null && minY !== void 0 ? minY : this.minY,
4758            maxX: maxX !== null && maxX !== void 0 ? maxX : this.maxX,
4759            maxY: maxY !== null && maxY !== void 0 ? maxY : this.maxY,
4760        });
4761    };
4762    // Returns fit for the Wasm runtime format
4763    Layout.prototype.runtimeFit = function (rive) {
4764        if (this.cachedRuntimeFit)
4765            return this.cachedRuntimeFit;
4766        var fit;
4767        if (this.fit === Fit.Cover)
4768            fit = rive.Fit.cover;
4769        else if (this.fit === Fit.Contain)
4770            fit = rive.Fit.contain;
4771        else if (this.fit === Fit.Fill)
4772            fit = rive.Fit.fill;
4773        else if (this.fit === Fit.FitWidth)
4774            fit = rive.Fit.fitWidth;
4775        else if (this.fit === Fit.FitHeight)
4776            fit = rive.Fit.fitHeight;
4777        else if (this.fit === Fit.ScaleDown)
4778            fit = rive.Fit.scaleDown;
4779        else if (this.fit === Fit.Layout)
4780            fit = rive.Fit.layout;
4781        else
4782            fit = rive.Fit.none;
4783        this.cachedRuntimeFit = fit;
4784        return fit;
4785    };
4786    // Returns alignment for the Wasm runtime format
4787    Layout.prototype.runtimeAlignment = function (rive) {
4788        if (this.cachedRuntimeAlignment)
4789            return this.cachedRuntimeAlignment;
4790        var alignment;
4791        if (this.alignment === Alignment.TopLeft)
4792            alignment = rive.Alignment.topLeft;
4793        else if (this.alignment === Alignment.TopCenter)
4794            alignment = rive.Alignment.topCenter;
4795        else if (this.alignment === Alignment.TopRight)
4796            alignment = rive.Alignment.topRight;
4797        else if (this.alignment === Alignment.CenterLeft)
4798            alignment = rive.Alignment.centerLeft;
4799        else if (this.alignment === Alignment.CenterRight)
4800            alignment = rive.Alignment.centerRight;
4801        else if (this.alignment === Alignment.BottomLeft)
4802            alignment = rive.Alignment.bottomLeft;
4803        else if (this.alignment === Alignment.BottomCenter)
4804            alignment = rive.Alignment.bottomCenter;
4805        else if (this.alignment === Alignment.BottomRight)
4806            alignment = rive.Alignment.bottomRight;
4807        else
4808            alignment = rive.Alignment.center;
4809        this.cachedRuntimeAlignment = alignment;
4810        return alignment;
4811    };
4812    return Layout;
4813}());
4814
4815// #endregion
4816// #region runtime
4817
4818// #endregion
4819// #region state machines
4820var StateMachineInputType;
4821(function (StateMachineInputType) {
4822    StateMachineInputType[StateMachineInputType["Number"] = 56] = "Number";
4823    StateMachineInputType[StateMachineInputType["Trigger"] = 58] = "Trigger";
4824    StateMachineInputType[StateMachineInputType["Boolean"] = 59] = "Boolean";
4825})(StateMachineInputType || (StateMachineInputType = {}));
4826/**
4827 * An input for a state machine
4828 */
4829var StateMachineInput = /** @class */ (function () {
4830    function StateMachineInput(type, runtimeInput) {
4831        this.type = type;
4832        this.runtimeInput = runtimeInput;
4833    }
4834    Object.defineProperty(StateMachineInput.prototype, "name", {
4835        /**
4836         * Returns the name of the input
4837         */
4838        get: function () {
4839            return this.runtimeInput.name;
4840        },
4841        enumerable: false,
4842        configurable: true
4843    });
4844    Object.defineProperty(StateMachineInput.prototype, "value", {
4845        /**
4846         * Returns the current value of the input
4847         */
4848        get: function () {
4849            return this.runtimeInput.value;
4850        },
4851        /**
4852         * Sets the value of the input
4853         */
4854        set: function (value) {
4855            this.runtimeInput.value = value;
4856        },
4857        enumerable: false,
4858        configurable: true
4859    });
4860    /**
4861     * Fires a trigger; does nothing on Number or Boolean input types
4862     */
4863    StateMachineInput.prototype.fire = function () {
4864        if (this.type === StateMachineInputType.Trigger) {
4865            this.runtimeInput.fire();
4866        }
4867    };
4868    /**
4869     * Deletes the input
4870     */
4871    StateMachineInput.prototype.delete = function () {
4872        this.runtimeInput = null;
4873    };
4874    return StateMachineInput;
4875}());
4876
4877var RiveEventType;
4878(function (RiveEventType) {
4879    RiveEventType[RiveEventType["General"] = 128] = "General";
4880    RiveEventType[RiveEventType["OpenUrl"] = 131] = "OpenUrl";
4881})(RiveEventType || (RiveEventType = {}));
4882var BaseArtboard = /** @class */ (function () {
4883    function BaseArtboard(_isBindableArtboard) {
4884        this.isBindableArtboard = false;
4885        this.isBindableArtboard = _isBindableArtboard;
4886    }
4887    return BaseArtboard;
4888}());
4889var Artboard = /** @class */ (function (_super) {
4890    __extends(Artboard, _super);
4891    function Artboard(artboard, _file) {
4892        var _this = _super.call(this, false) || this;
4893        _this.nativeArtboard = artboard;
4894        _this.file = _file;
4895        return _this;
4896    }
4897    return Artboard;
4898}(BaseArtboard));
4899var BindableArtboard = /** @class */ (function (_super) {
4900    __extends(BindableArtboard, _super);
4901    function BindableArtboard(artboard) {
4902        var _this = _super.call(this, true) || this;
4903        _this.selfUnref = false;
4904        _this.nativeArtboard = artboard;
4905        return _this;
4906    }
4907    Object.defineProperty(BindableArtboard.prototype, "viewModel", {
4908        set: function (value) {
4909            this.nativeViewModel = value.nativeInstance;
4910        },
4911        enumerable: false,
4912        configurable: true
4913    });
4914    BindableArtboard.prototype.destroy = function () {
4915        var _a;
4916        if (this.selfUnref) {
4917            this.nativeArtboard.unref();
4918            (_a = this.nativeViewModel) === null || _a === void 0 ? void 0 : _a.unref();
4919        }
4920    };
4921    return BindableArtboard;
4922}(BaseArtboard));
4923var StateMachine = /** @class */ (function () {
4924    /**
4925     * @constructor
4926     * @param stateMachine runtime state machine object
4927     * @param instance runtime state machine instance object
4928     */
4929    function StateMachine(stateMachine, runtime, playing, artboard) {
4930        this.stateMachine = stateMachine;
4931        this.playing = playing;
4932        this.artboard = artboard;
4933        /**
4934         * Caches the inputs from the runtime
4935         */
4936        this.inputs = [];
4937        this.instance = new runtime.StateMachineInstance(stateMachine, artboard);
4938        this.initInputs(runtime);
4939    }
4940    Object.defineProperty(StateMachine.prototype, "name", {
4941        get: function () {
4942            return this.stateMachine.name;
4943        },
4944        enumerable: false,
4945        configurable: true
4946    });
4947    Object.defineProperty(StateMachine.prototype, "statesChanged", {
4948        /**
4949         * Returns a list of state names that have changed on this frame
4950         */
4951        get: function () {
4952            var names = [];
4953            for (var i = 0; i < this.instance.stateChangedCount(); i++) {
4954                names.push(this.instance.stateChangedNameByIndex(i));
4955            }
4956            return names;
4957        },
4958        enumerable: false,
4959        configurable: true
4960    });
4961    /**
4962     * Advances the state machine instance by a given time.
4963     * @param time - the time to advance the animation by in seconds
4964     */
4965    StateMachine.prototype.advance = function (time) {
4966        this.instance.advance(time);
4967    };
4968    /**
4969     * Advances the state machine instance by a given time and apply changes to artboard.
4970     * @param time - the time to advance the animation by in seconds
4971     */
4972    StateMachine.prototype.advanceAndApply = function (time) {
4973        this.instance.advanceAndApply(time);
4974    };
4975    /**
4976     * Returns the number of events reported from the last advance call
4977     * @returns Number of events reported
4978     */
4979    StateMachine.prototype.reportedEventCount = function () {
4980        return this.instance.reportedEventCount();
4981    };
4982    /**
4983     * Returns a RiveEvent object emitted from the last advance call at the given index
4984     * of a list of potentially multiple events. If an event at the index is not found,
4985     * undefined is returned.
4986     * @param i index of the event reported in a list of potentially multiple events
4987     * @returns RiveEvent or extended RiveEvent object returned, or undefined
4988     */
4989    StateMachine.prototype.reportedEventAt = function (i) {
4990        return this.instance.reportedEventAt(i);
4991    };
4992    /**
4993     * Fetches references to the state machine's inputs and caches them
4994     * @param runtime an instance of the runtime; needed for the SMIInput types
4995     */
4996    StateMachine.prototype.initInputs = function (runtime) {
4997        // Fetch the inputs from the runtime if we don't have them
4998        for (var i = 0; i < this.instance.inputCount(); i++) {
4999            var input = this.instance.input(i);
5000            this.inputs.push(this.mapRuntimeInput(input, runtime));
5001        }
5002    };
5003    /**
5004     * Maps a runtime input to it's appropriate type
5005     * @param input
5006     */
5007    StateMachine.prototype.mapRuntimeInput = function (input, runtime) {
5008        if (input.type === runtime.SMIInput.bool) {
5009            return new StateMachineInput(StateMachineInputType.Boolean, input.asBool());
5010        }
5011        else if (input.type === runtime.SMIInput.number) {
5012            return new StateMachineInput(StateMachineInputType.Number, input.asNumber());
5013        }
5014        else if (input.type === runtime.SMIInput.trigger) {
5015            return new StateMachineInput(StateMachineInputType.Trigger, input.asTrigger());
5016        }
5017    };
5018    /**
5019     * Deletes the backing Wasm state machine instance; once this is called, this
5020     * state machine is no more.
5021     */
5022    StateMachine.prototype.cleanup = function () {
5023        this.inputs.forEach(function (input) {
5024            input.delete();
5025        });
5026        this.inputs.length = 0;
5027        this.instance.delete();
5028    };
5029    StateMachine.prototype.bindViewModelInstance = function (viewModelInstance) {
5030        if (viewModelInstance.runtimeInstance != null) {
5031            this.instance.bindViewModelInstance(viewModelInstance.runtimeInstance);
5032        }
5033    };
5034    return StateMachine;
5035}());
5036// #endregion
5037// #region animator
5038/**
5039 * Manages animation
5040 */
5041var Animator = /** @class */ (function () {
5042    /**
5043     * Constructs a new animator
5044     * @constructor
5045     * @param runtime Rive runtime; needed to instance animations & state machines
5046     * @param artboard the artboard that holds all animations and state machines
5047     * @param animations optional list of animations
5048     * @param stateMachines optional list of state machines
5049     */
5050    function Animator(runtime, artboard, eventManager, animations, stateMachines) {
5051        if (animations === void 0) { animations = []; }
5052        if (stateMachines === void 0) { stateMachines = []; }
5053        this.runtime = runtime;
5054        this.artboard = artboard;
5055        this.eventManager = eventManager;
5056        this.animations = animations;
5057        this.stateMachines = stateMachines;
5058    }
5059    /**
5060     * Adds animations and state machines by their names. If names are shared
5061     * between animations & state machines, then the first one found will be
5062     * created. Best not to use the same names for these in your Rive file.
5063     * @param animatable the name(s) of animations and state machines to add
5064     * @returns a list of names of the playing animations and state machines
5065     */
5066    Animator.prototype.add = function (animatables, playing, fireEvent) {
5067        if (fireEvent === void 0) { fireEvent = true; }
5068        animatables = mapToStringArray(animatables);
5069        // If animatables is empty, play or pause everything
5070        if (animatables.length === 0) {
5071            this.animations.forEach(function (a) { return (a.playing = playing); });
5072            this.stateMachines.forEach(function (m) { return (m.playing = playing); });
5073        }
5074        else {
5075            // Play/pause already instanced items, or create new instances
5076            var instancedAnimationNames = this.animations.map(function (a) { return a.name; });
5077            var instancedMachineNames = this.stateMachines.map(function (m) { return m.name; });
5078            for (var i = 0; i < animatables.length; i++) {
5079                var aIndex = instancedAnimationNames.indexOf(animatables[i]);
5080                var mIndex = instancedMachineNames.indexOf(animatables[i]);
5081                if (aIndex >= 0 || mIndex >= 0) {
5082                    if (aIndex >= 0) {
5083                        // Animation is instanced, play/pause it
5084                        this.animations[aIndex].playing = playing;
5085                    }
5086                    else {
5087                        // State machine is instanced, play/pause it
5088                        this.stateMachines[mIndex].playing = playing;
5089                    }
5090                }
5091                else {
5092                    // Try to create a new animation instance
5093                    var anim = this.artboard.animationByName(animatables[i]);
5094                    if (anim) {
5095                        var newAnimation = new _animation__WEBPACK_IMPORTED_MODULE_0__.Animation(anim, this.artboard, this.runtime, playing);
5096                        // Display the first frame of the specified animation
5097                        newAnimation.advance(0);
5098                        newAnimation.apply(1.0);
5099                        this.animations.push(newAnimation);
5100                    }
5101                    else {
5102                        // Try to create a new state machine instance
5103                        var sm = this.artboard.stateMachineByName(animatables[i]);
5104                        if (sm) {
5105                            var newStateMachine = new StateMachine(sm, this.runtime, playing, this.artboard);
5106                            this.stateMachines.push(newStateMachine);
5107                        }
5108                    }
5109                }
5110            }
5111        }
5112        // Fire play/paused events for animations
5113        if (fireEvent) {
5114            if (playing) {
5115                this.eventManager.fire({
5116                    type: EventType.Play,
5117                    data: this.playing,
5118                });
5119            }
5120            else {
5121                this.eventManager.fire({
5122                    type: EventType.Pause,
5123                    data: this.paused,
5124                });
5125            }
5126        }
5127        return playing ? this.playing : this.paused;
5128    };
5129    /**
5130     * Adds linear animations by their names.
5131     * @param animatables the name(s) of animations to add
5132     * @param playing whether animations should play on instantiation
5133     */
5134    Animator.prototype.initLinearAnimations = function (animatables, playing) {
5135        // Play/pause already instanced items, or create new instances
5136        // This validation is kept to maintain compatibility with current behavior.
5137        // But given that it this is called during artboard initialization
5138        // it should probably be safe to remove.
5139        var instancedAnimationNames = this.animations.map(function (a) { return a.name; });
5140        for (var i = 0; i < animatables.length; i++) {
5141            var aIndex = instancedAnimationNames.indexOf(animatables[i]);
5142            if (aIndex >= 0) {
5143                this.animations[aIndex].playing = playing;
5144            }
5145            else {
5146                // Try to create a new animation instance
5147                var anim = this.artboard.animationByName(animatables[i]);
5148                if (anim) {
5149                    var newAnimation = new _animation__WEBPACK_IMPORTED_MODULE_0__.Animation(anim, this.artboard, this.runtime, playing);
5150                    // Display the first frame of the specified animation
5151                    newAnimation.advance(0);
5152                    newAnimation.apply(1.0);
5153                    this.animations.push(newAnimation);
5154                }
5155                else {
5156                    console.error("Animation with name ".concat(animatables[i], " not found."));
5157                }
5158            }
5159        }
5160    };
5161    /**
5162     * Adds state machines by their names.
5163     * @param animatables the name(s) of state machines to add
5164     * @param playing whether state machines should play on instantiation
5165     */
5166    Animator.prototype.initStateMachines = function (animatables, playing) {
5167        // Play/pause already instanced items, or create new instances
5168        // This validation is kept to maintain compatibility with current behavior.
5169        // But given that it this is called during artboard initialization
5170        // it should probably be safe to remove.
5171        var instancedStateMachineNames = this.stateMachines.map(function (a) { return a.name; });
5172        for (var i = 0; i < animatables.length; i++) {
5173            var aIndex = instancedStateMachineNames.indexOf(animatables[i]);
5174            if (aIndex >= 0) {
5175                this.stateMachines[aIndex].playing = playing;
5176            }
5177            else {
5178                // Try to create a new state machine instance
5179                var sm = this.artboard.stateMachineByName(animatables[i]);
5180                if (sm) {
5181                    var newStateMachine = new StateMachine(sm, this.runtime, playing, this.artboard);
5182                    this.stateMachines.push(newStateMachine);
5183                }
5184                else {
5185                    console.warn("State Machine with name ".concat(animatables[i], " not found."));
5186                    // In order to maintain compatibility with current behavior, if a state machine is not found
5187                    // we look for an animation with the same name
5188                    this.initLinearAnimations([animatables[i]], playing
vendor: 6,332 bytes, lines 5188-5346
5188);
5189                }
5190            }
5191        }
5192    };
5193    /**
5194     * Play the named animations/state machines
5195     * @param animatables the names of the animations/machines to play; plays all if empty
5196     * @returns a list of the playing items
5197     */
5198    Animator.prototype.play = function (animatables) {
5199        return this.add(animatables, true);
5200    };
5201    /**
5202     * Advance state machines if they are paused after initialization
5203     */
5204    Animator.prototype.advanceIfPaused = function () {
5205        this.stateMachines.forEach(function (sm) {
5206            if (!sm.playing) {
5207                sm.advanceAndApply(0);
5208            }
5209        });
5210    };
5211    /**
5212     * Pauses named animations and state machines, or everything if nothing is
5213     * specified
5214     * @param animatables names of the animations and state machines to pause
5215     * @returns a list of names of the animations and state machines paused
5216     */
5217    Animator.prototype.pause = function (animatables) {
5218        return this.add(animatables, false);
5219    };
5220    /**
5221     * Set time of named animations
5222     * @param animations names of the animations to scrub
5223     * @param value time scrub value, a floating point number to which the playhead is jumped
5224     * @returns a list of names of the animations that were scrubbed
5225     */
5226    Animator.prototype.scrub = function (animatables, value) {
5227        var forScrubbing = this.animations.filter(function (a) {
5228            return animatables.includes(a.name);
5229        });
5230        forScrubbing.forEach(function (a) { return (a.scrubTo = value); });
5231        return forScrubbing.map(function (a) { return a.name; });
5232    };
5233    Object.defineProperty(Animator.prototype, "playing", {
5234        /**
5235         * Returns a list of names of all animations and state machines currently
5236         * playing
5237         */
5238        get: function () {
5239            return this.animations
5240                .filter(function (a) { return a.playing; })
5241                .map(function (a) { return a.name; })
5242                .concat(this.stateMachines.filter(function (m) { return m.playing; }).map(function (m) { return m.name; }));
5243        },
5244        enumerable: false,
5245        configurable: true
5246    });
5247    Object.defineProperty(Animator.prototype, "paused", {
5248        /**
5249         * Returns a list of names of all animations and state machines currently
5250         * paused
5251         */
5252        get: function () {
5253            return this.animations
5254                .filter(function (a) { return !a.playing; })
5255                .map(function (a) { return a.name; })
5256                .concat(this.stateMachines.filter(function (m) { return !m.playing; }).map(function (m) { return m.name; }));
5257        },
5258        enumerable: false,
5259        configurable: true
5260    });
5261    /**
5262     * Stops and removes all named animations and state machines
5263     * @param animatables animations and state machines to remove
5264     * @returns a list of names of removed items
5265     */
5266    Animator.prototype.stop = function (animatables) {
5267        var _this = this;
5268        animatables = mapToStringArray(animatables);
5269        // If nothing's specified, wipe them out, all of them
5270        var removedNames = [];
5271        // Stop everything
5272        if (animatables.length === 0) {
5273            removedNames = this.animations
5274                .map(function (a) { return a.name; })
5275                .concat(this.stateMachines.map(function (m) { return m.name; }));
5276            // Clean up before emptying the arrays
5277            this.animations.forEach(function (a) { return a.cleanup(); });
5278            this.stateMachines.forEach(function (m) { return m.cleanup(); });
5279            // Empty out the arrays
5280            this.animations.splice(0, this.animations.length);
5281            this.stateMachines.splice(0, this.stateMachines.length);
5282        }
5283        else {
5284            // Remove only the named animations/state machines
5285            var animationsToRemove = this.animations.filter(function (a) {
5286                return animatables.includes(a.name);
5287            });
5288            animationsToRemove.forEach(function (a) {
5289                a.cleanup();
5290                _this.animations.splice(_this.animations.indexOf(a), 1);
5291            });
5292            var machinesToRemove = this.stateMachines.filter(function (m) {
5293                return animatables.includes(m.name);
5294            });
5295            machinesToRemove.forEach(function (m) {
5296                m.cleanup();
5297                _this.stateMachines.splice(_this.stateMachines.indexOf(m), 1);
5298            });
5299            removedNames = animationsToRemove
5300                .map(function (a) { return a.name; })
5301                .concat(machinesToRemove.map(function (m) { return m.name; }));
5302        }
5303        this.eventManager.fire({
5304            type: EventType.Stop,
5305            data: removedNames,
5306        });
5307        // Return the list of animations removed
5308        return removedNames;
5309    };
5310    Object.defineProperty(Animator.prototype, "isPlaying", {
5311        /**
5312         * Returns true if at least one animation is active
5313         */
5314        get: function () {
5315            return (this.animations.reduce(function (acc, curr) { return acc || curr.playing; }, false) ||
5316                this.stateMachines.reduce(function (acc, curr) { return acc || curr.playing; }, false));
5317        },
5318        enumerable: false,
5319        configurable: true
5320    });
5321    Object.defineProperty(Animator.prototype, "isPaused", {
5322        /**
5323         * Returns true if all animations are paused and there's at least one animation
5324         */
5325        get: function () {
5326            return (!this.isPlaying &&
5327                (this.animations.length > 0 || this.stateMachines.length > 0));
5328        },
5329        enumerable: false,
5330        configurable: true
5331    });
5332    Object.defineProperty(Animator.prototype, "isStopped", {
5333        /**
5334         * Returns true if there are no playing or paused animations/state machines
5335         */
5336        get: function () {
5337            return this.animations.length === 0 && this.stateMachines.length === 0;
5338        },
5339        enumerable: false,
5340        configurable: true
5341    });
5342    /**
5343     * If there are no animations or state machines, add the first one found
5344     * @returns the name of the animation or state machine instanced
5345     */
5346    Animator.prototype.atLeastOne = function (playing, fireEvent
vendor: 3,519 bytes, lines 5346-5437
5346) {
5347        if (fireEvent === void 0) { fireEvent = true; }
5348        var instancedName;
5349        if (this.animations.length === 0 && this.stateMachines.length === 0) {
5350            if (this.artboard.animationCount() > 0) {
5351                // Add the first animation
5352                this.add([(instancedName = this.artboard.animationByIndex(0).name)], playing, fireEvent);
5353            }
5354            else if (this.artboard.stateMachineCount() > 0) {
5355                // Add the first state machine
5356                this.add([(instancedName = this.artboard.stateMachineByIndex(0).name)], playing, fireEvent);
5357            }
5358        }
5359        return instancedName;
5360    };
5361    /**
5362     * Checks if any animations have looped and if so, fire the appropriate event
5363     */
5364    Animator.prototype.handleLooping = function () {
5365        for (var _i = 0, _a = this.animations.filter(function (a) { return a.playing; }); _i < _a.length; _i++) {
5366            var animation = _a[_i];
5367            // Emit if the animation looped
5368            if (animation.loopValue === 0 && animation.loopCount) {
5369                animation.loopCount = 0;
5370                // This is a one-shot; if it has ended, delete the instance
5371                this.stop(animation.name);
5372            }
5373            else if (animation.loopValue === 1 && animation.loopCount) {
5374                this.eventManager.fire({
5375                    type: EventType.Loop,
5376                    data: { animation: animation.name, type: LoopType.Loop },
5377                });
5378                animation.loopCount = 0;
5379            }
5380            // Wasm indicates a loop at each time the animation
5381            // changes direction, so a full loop/lap occurs every
5382            // two loop counts
5383            else if (animation.loopValue === 2 && animation.loopCount > 1) {
5384                this.eventManager.fire({
5385                    type: EventType.Loop,
5386                    data: { animation: animation.name, type: LoopType.PingPong },
5387                });
5388                animation.loopCount = 0;
5389            }
5390        }
5391    };
5392    /**
5393     * Checks if states have changed in state machines and fires a statechange
5394     * event
5395     */
5396    Animator.prototype.handleStateChanges = function () {
5397        var statesChanged = [];
5398        for (var _i = 0, _a = this.stateMachines.filter(function (sm) { return sm.playing; }); _i < _a.length; _i++) {
5399            var stateMachine = _a[_i];
5400            statesChanged.push.apply(statesChanged, stateMachine.statesChanged);
5401        }
5402        if (statesChanged.length > 0) {
5403            this.eventManager.fire({
5404                type: EventType.StateChange,
5405                data: statesChanged,
5406            });
5407        }
5408    };
5409    Animator.prototype.handleAdvancing = function (time) {
5410        this.eventManager.fire({
5411            type: EventType.Advance,
5412            data: time,
5413        });
5414    };
5415    return Animator;
5416}());
5417// #endregion
5418// #region events
5419/**
5420 * Supported event types triggered in Rive
5421 */
5422var EventType;
5423(function (EventType) {
5424    EventType["Load"] = "load";
5425    EventType["LoadError"] = "loaderror";
5426    EventType["Play"] = "play";
5427    EventType["Pause"] = "pause";
5428    EventType["Stop"] = "stop";
5429    EventType["Loop"] = "loop";
5430    EventType["Draw"] = "draw";
5431    EventType["Advance"] = "advance";
5432    EventType["StateChange"] = "statechange";
5433    EventType["RiveEvent"] = "riveevent";
5434    EventType["AudioStatusChange"] = "audiostatuschange";
5435})(EventType || (EventType = {}));
5436/**
5437 * Looping types: one-shot, loop, and ping-pong
vendor: 12,221 bytes, lines 5437-5747
5437
5438 */
5439var LoopType;
5440(function (LoopType) {
5441    LoopType["OneShot"] = "oneshot";
5442    LoopType["Loop"] = "loop";
5443    LoopType["PingPong"] = "pingpong";
5444})(LoopType || (LoopType = {}));
5445// Manages Rive events and listeners
5446var EventManager = /** @class */ (function () {
5447    function EventManager(listeners) {
5448        if (listeners === void 0) { listeners = []; }
5449        this.listeners = listeners;
5450    }
5451    // Gets listeners of specified type
5452    EventManager.prototype.getListeners = function (type) {
5453        return this.listeners.filter(function (e) { return e.type === type; });
5454    };
5455    // Adds a listener
5456    EventManager.prototype.add = function (listener) {
5457        if (!this.listeners.includes(listener)) {
5458            this.listeners.push(listener);
5459        }
5460    };
5461    /**
5462     * Removes a listener
5463     * @param listener the listener with the callback to be removed
5464     */
5465    EventManager.prototype.remove = function (listener) {
5466        // We can't simply look for the listener as it'll be a different instance to
5467        // one originally subscribed. Find all the listeners of the right type and
5468        // then check their callbacks which should match.
5469        for (var i = 0; i < this.listeners.length; i++) {
5470            var currentListener = this.listeners[i];
5471            if (currentListener.type === listener.type) {
5472                if (currentListener.callback === listener.callback) {
5473                    this.listeners.splice(i, 1);
5474                    break;
5475                }
5476            }
5477        }
5478    };
5479    /**
5480     * Clears all listeners of specified type, or every listener if no type is
5481     * specified
5482     * @param type the type of listeners to clear, or all listeners if not
5483     * specified
5484     */
5485    EventManager.prototype.removeAll = function (type) {
5486        var _this = this;
5487        if (!type) {
5488            this.listeners.splice(0, this.listeners.length);
5489        }
5490        else {
5491            this.listeners
5492                .filter(function (l) { return l.type === type; })
5493                .forEach(function (l) { return _this.remove(l); });
5494        }
5495    };
5496    // Fires an event
5497    EventManager.prototype.fire = function (event) {
5498        var eventListeners = this.getListeners(event.type);
5499        eventListeners.forEach(function (listener) { return listener.callback(event); });
5500    };
5501    return EventManager;
5502}());
5503// Manages a queue of tasks
5504var TaskQueueManager = /** @class */ (function () {
5505    function TaskQueueManager(eventManager) {
5506        this.eventManager = eventManager;
5507        this.queue = [];
5508    }
5509    // Adds a task top the queue
5510    TaskQueueManager.prototype.add = function (task) {
5511        this.queue.push(task);
5512    };
5513    // Processes all tasks in the queue
5514    TaskQueueManager.prototype.process = function () {
5515        while (this.queue.length > 0) {
5516            var task = this.queue.shift();
5517            if (task === null || task === void 0 ? void 0 : task.action) {
5518                task.action();
5519            }
5520            if (task === null || task === void 0 ? void 0 : task.event) {
5521                this.eventManager.fire(task.event);
5522            }
5523        }
5524    };
5525    return TaskQueueManager;
5526}());
5527// #endregion
5528// #region Audio
5529var SystemAudioStatus;
5530(function (SystemAudioStatus) {
5531    SystemAudioStatus[SystemAudioStatus["AVAILABLE"] = 0] = "AVAILABLE";
5532    SystemAudioStatus[SystemAudioStatus["UNAVAILABLE"] = 1] = "UNAVAILABLE";
5533})(SystemAudioStatus || (SystemAudioStatus = {}));
5534// Class to handle audio context availability and status changes
5535var AudioManager = /** @class */ (function (_super) {
5536    __extends(AudioManager, _super);
5537    function AudioManager() {
5538        var _this = _super !== null && _super.apply(this, arguments) || this;
5539        _this._started = false;
5540        _this._enabled = false;
5541        _this._status = SystemAudioStatus.UNAVAILABLE;
5542        return _this;
5543    }
5544    AudioManager.prototype.delay = function (time) {
5545        return __awaiter(this, void 0, void 0, function () {
5546            return __generator(this, function (_a) {
5547                return [2 /*return*/, new Promise(function (resolve) { return setTimeout(resolve, time); })];
5548            });
5549        });
5550    };
5551    AudioManager.prototype.timeout = function () {
5552        return __awaiter(this, void 0, void 0, function () {
5553            return __generator(this, function (_a) {
5554                return [2 /*return*/, new Promise(function (_, reject) { return setTimeout(reject, 50); })];
5555            });
5556        });
5557    };
5558    // Alerts animations on status changes and removes the listeners to avoid alerting twice.
5559    AudioManager.prototype.reportToListeners = function () {
5560        this.fire({ type: EventType.AudioStatusChange });
5561        this.removeAll();
5562    };
5563    /**
5564     * The audio context has been resolved.
5565     * Alert any listeners that we can now play audio.
5566     * Rive will now play audio at the configured volume.
5567     */
5568    AudioManager.prototype.enableAudio = function () {
5569        return __awaiter(this, void 0, void 0, function () {
5570            return __generator(this, function (_a) {
5571                if (!this._enabled) {
5572                    this._enabled = true;
5573                    this._status = SystemAudioStatus.AVAILABLE;
5574                    this.reportToListeners();
5575                }
5576                return [2 /*return*/];
5577            });
5578        });
5579    };
5580    /**
5581     * Check if we are able to play audio.
5582     *
5583     * We currently check the audio context, when resume() returns before a timeout we know that the
5584     * audio context is running and we can enable audio.
5585     */
5586    AudioManager.prototype.testAudio = function () {
5587        return __awaiter(this, void 0, void 0, function () {
5588            var _a;
5589            return __generator(this, function (_b) {
5590                switch (_b.label) {
5591                    case 0:
5592                        if (!(this._status === SystemAudioStatus.UNAVAILABLE &&
5593                            this._audioContext !== null)) return [3 /*break*/, 4];
5594                        _b.label = 1;
5595                    case 1:
5596                        _b.trys.push([1, 3, , 4]);
5597                        return [4 /*yield*/, Promise.race([this._audioContext.resume(), this.timeout()])];
5598                    case 2:
5599                        _b.sent();
5600                        this.enableAudio();
5601                        return [3 /*break*/, 4];
5602                    case 3:
5603                        _a = _b.sent();
5604                        return [3 /*break*/, 4];
5605                    case 4: return [2 /*return*/];
5606                }
5607            });
5608        });
5609    };
5610    /**
5611     * Establish audio for use with rive.
5612     * We both test if we can use audio intermittently and listen for user interaction.
5613     * The aim is to enable audio playback as soon as the browser allows this.
5614     */
5615    AudioManager.prototype._establishAudio = function () {
5616        return __awaiter(this, void 0, void 0, function () {
5617            return __generator(this, function (_a) {
5618                switch (_a.label) {
5619                    case 0:
5620                        if (!!this._started) return [3 /*break*/, 5];
5621                        this._started = true;
5622                        if (!(typeof window == "undefined")) return [3 /*break*/, 1];
5623                        this.enableAudio();
5624                        return [3 /*break*/, 5];
5625                    case 1:
5626                        this._audioContext = new AudioContext();
5627                        this.listenForUserAction();
5628                        _a.label = 2;
5629                    case 2:
5630                        if (!(this._status === SystemAudioStatus.UNAVAILABLE)) return [3 /*break*/, 5];
5631                        return [4 /*yield*/, this.testAudio()];
5632                    case 3:
5633                        _a.sent();
5634                        return [4 /*yield*/, this.delay(1000)];
5635                    case 4:
5636                        _a.sent();
5637                        return [3 /*break*/, 2];
5638                    case 5: return [2 /*return*/];
5639                }
5640            });
5641        });
5642    };
5643    AudioManager.prototype.listenForUserAction = function () {
5644        var _this = this;
5645        // NOTE: AudioContexts are ready immediately if requested in a ui callback
5646        // we *could* re request one in this listener.
5647        var _clickListener = function () { return __awaiter(_this, void 0, void 0, function () {
5648            return __generator(this, function (_a) {
5649                // note this has "better" results than calling `await this.testAudio()`
5650                // as we force audio to be enabled in the current thread, rather than chancing
5651                // the thread to be passed over for some other async context
5652                this.enableAudio();
5653                return [2 /*return*/];
5654            });
5655        }); };
5656        // NOTE: we should test this on mobile/pads
5657        document.addEventListener("pointerdown", _clickListener, {
5658            once: true,
5659        });
5660    };
5661    /**
5662     * Establish the audio context for rive, this lets rive know that we can play audio.
5663     */
5664    AudioManager.prototype.establishAudio = function () {
5665        return __awaiter(this, void 0, void 0, function () {
5666            return __generator(this, function (_a) {
5667                this._establishAudio();
5668                return [2 /*return*/];
5669            });
5670        });
5671    };
5672    Object.defineProperty(AudioManager.prototype, "systemVolume", {
5673        get: function () {
5674            if (this._status === SystemAudioStatus.UNAVAILABLE) {
5675                // We do an immediate test to avoid depending on the delay of the running test
5676                this.testAudio();
5677                return 0;
5678            }
5679            return 1;
5680        },
5681        enumerable: false,
5682        configurable: true
5683    });
5684    Object.defineProperty(AudioManager.prototype, "status", {
5685        get: function () {
5686            return this._status;
5687        },
5688        enumerable: false,
5689        configurable: true
5690    });
5691    return AudioManager;
5692}(EventManager));
5693var audioManager = new AudioManager();
5694var FakeResizeObserver = /** @class */ (function () {
5695    function FakeResizeObserver() {
5696    }
5697    FakeResizeObserver.prototype.observe = function () { };
5698    FakeResizeObserver.prototype.unobserve = function () { };
5699    FakeResizeObserver.prototype.disconnect = function () { };
5700    return FakeResizeObserver;
5701}());
5702var MyResizeObserver = globalThis.ResizeObserver || FakeResizeObserver;
5703/**
5704 * This class takes care of any observers that will be attached to an animation.
5705 * It should be treated as a singleton because observers are much more performant
5706 * when used for observing multiple elements by a single instance.
5707 */
5708var ObjectObservers = /** @class */ (function () {
5709    function ObjectObservers() {
5710        var _this = this;
5711        this._elementsMap = new Map();
5712        /**
5713         * Resize observers trigger both when the element changes its size and also when the
5714         * element is added or removed from the document.
5715         */
5716        this._onObservedEntry = function (entry) {
5717            var observed = _this._elementsMap.get(entry.target);
5718            if (observed !== null) {
5719                observed.onResize(entry.target.clientWidth == 0 || entry.target.clientHeight == 0);
5720            }
5721            else {
5722                _this._resizeObserver.unobserve(entry.target);
5723            }
5724        };
5725        this._onObserved = function (entries) {
5726            entries.forEach(_this._onObservedEntry);
5727        };
5728        this._resizeObserver = new MyResizeObserver(this._onObserved);
5729    }
5730    // Adds an observable element
5731    ObjectObservers.prototype.add = function (element, onResize) {
5732        var observed = {
5733            onResize: onResize,
5734            element: element,
5735        };
5736        this._elementsMap.set(element, observed);
5737        this._resizeObserver.observe(element);
5738        return observed;
5739    };
5740    // Removes an observable element
5741    ObjectObservers.prototype.remove = function (observed) {
5742        this._resizeObserver.unobserve(observed.element);
5743        this._elementsMap.delete(observed.element);
5744    };
5745    return ObjectObservers;
5746}());
5747var observers = new ObjectObservers();
5748var RiveFile = /** @class */ (function () {
5749    function RiveFile(params) {
5750        // Allow the runtime to automatically load assets hosted in Rive's runtime.
5751        this.enableRiveAssetCDN = true;
5752        // When true, emits performance.mark/measure entries during RiveFile load.
5753        this.enablePerfMarks = false;
5754        this.referenceCount = 0;
5755        this.destroyed = false;
5756        this.selfUnref = false;
5757        this.bindableArtboards = [];
5758        this.src = params.src;
5759        this.buffer = params.buffer;
5760        if (params.assetLoader)
5761            this.assetLoader = params.assetLoader;
5762        this.enableRiveAssetCDN =
5763            typeof params.enableRiveAssetCDN == "boolean"
5764                ? params.enableRiveAssetCDN
5765                : true;
5766        this.enablePerfMarks = !!params.enablePerfMarks;
5767        if (this.enablePerfMarks)
5768            _runtimeLoader__WEBPACK_IMPORTED_MODULE_1__.RuntimeLoader.enablePerfMarks = true;
5769        // New event management system
5770        this.eventManager = new EventManager();
5771        if (params.onLoad)
5772            this.on(EventType.Load, params.onLoad);
5773        if (params.onLoadError)
5774            this.on(EventType.LoadError, params.onLoadError);
5775    }
5776    RiveFile.prototype.releaseFile = function () {
5777        var _a;
5778        if (this.selfUnref) {
5779            (_a = this.file) === null || _a === void 0 ? void 0 : _a.unref();
5780        }
5781        this.file = null;
5782    };
5783    RiveFile.prototype.releaseBindableArtboards = function () {
5784        this.bindableArtboards.forEach(function (bindableArtboard) {
5785            return bindableArtboard.destroy();
5786        });
5787    };
5788    RiveFile.prototype.initData = function () {
5789        return __awaiter(this, void 0, void 0, function () {
5790            var _a, loader, loaderWrapper, _b, fileFinalizer;
5791            return __generator(this, function (_c) {
5792                switch (_c.label) {
5793                    case 0:
5794                        if (!(this.src && !this.buffer)) return [3 /*break*/, 2];
5795                        _a = this;
5796                        return [4 /*yield*/, loadRiveFile(this.src)];
5797                    case 1:
5798                        _a.buffer = _c.sent();
5799                        _c.label = 2;
5800                    case 2:
5801                        if (this.destroyed) {
5802                            return [2 /*return*/];
5803                        }
5804                        if (this.assetLoader) {
5805                            loaderWrapper = new _utils__WEBPACK_IMPORTED_MODULE_2__.CustomFileAssetLoaderWrapper(this.runtime, this.assetLoader);
5806                            loader = loaderWrapper.assetLoader;
5807                        }
5808                        // Load the Rive file
5809                        if (this.enablePerfMarks)
5810                            performance.mark('rive:file-load:start');
5811                        _b = this;
5812                        return [4 /*yield*/, this.runtime.load(new Uint8Array(this.buffer), loader, this.enableRiveAssetCDN)];
5813                    case 3:
5814                        _b.file = _c.sent();
5815                        if (this.enablePerfMarks) {
5816                            performance.mark('rive:file-load:end');
5817                            performance.measure('rive:file-load', 'rive:file-load:start', 'rive:file-load:end');
5818                        }
5819                        fileFinalizer = new _utils__WEBPACK_IMPORTED_MODULE_2__.FileFinalizer(this.file);
5820                        _utils__WEBPACK_IMPORTED_MODULE_2__.finalizationRegistry.register(this, fileFinalizer);
5821                        if (this.destroyed) {
5822                            this.releaseFile();
5823                            return [2 /*return*/];
5824                        }
5825                        if (this.file !== null) {
5826                            this.eventManager.fire({
5827                                type: EventType.Load,
5828                                data: this,
5829                            });
5830                        }
5831                        else {
5832                            this.fireLoadError(RiveFile.fileLoadErrorMessage);
5833                        }
5834                        return [2 /*return*/];
5835                }
5836            });
5837        });
5838    };
5839    RiveFile.prototype.loadRiveFileBytes = function () {
5840        return __awaiter(this, void 0, void 0, function () {
5841            var bufferPromise;
5842            return __generator(this, function (_a) {
5843                if (this.enablePerfMarks)
5844                    performance.mark('rive:fetch-riv:start');
5845                bufferPromise = this.src
5846                    ? loadRiveFile(this.src)
5847                    : Promise.resolve(this.buffer);
vendor: 54,953 bytes, lines 5848-7080
5848                if (this.enablePerfMarks && this.src) {
5849                    bufferPromise.then(function () {
5850                        performance.mark('rive:fetch-riv:end');
5851                        performance.measure('rive:fetch-riv', 'rive:fetch-riv:start', 'rive:fetch-riv:end');
5852                    });
5853                }
5854                return [2 /*return*/, bufferPromise];
5855            });
5856        });
5857    };
5858    RiveFile.prototype.loadRuntime = function () {
5859        return __awaiter(this, void 0, void 0, function () {
5860            var runtimePromise;
5861            return __generator(this, function (_a) {
5862                if (this.enablePerfMarks)
5863                    performance.mark('rive:await-wasm:start');
5864                runtimePromise = _runtimeLoader__WEBPACK_IMPORTED_MODULE_1__.RuntimeLoader.awaitInstance();
5865                if (this.enablePerfMarks) {
5866                    runtimePromise.then(function () {
5867                        performance.mark('rive:await-wasm:end');
5868                        performance.measure('rive:await-wasm', 'rive:await-wasm:start', 'rive:await-wasm:end');
5869                    });
5870                }
5871                return [2 /*return*/, runtimePromise];
5872            });
5873        });
5874    };
5875    RiveFile.prototype.init = function () {
5876        return __awaiter(this, void 0, void 0, function () {
5877            var _a, bufferResolved, runtimeResolved, error_1;
5878            return __generator(this, function (_b) {
5879                switch (_b.label) {
5880                    case 0:
5881                        // If no source file url specified, it's a bust
5882                        if (!this.src && !this.buffer) {
5883                            this.fireLoadError(RiveFile.missingErrorMessage);
5884                            return [2 /*return*/];
5885                        }
5886                        _b.label = 1;
5887                    case 1:
5888                        _b.trys.push([1, 4, , 5]);
5889                        return [4 /*yield*/, Promise.all([this.loadRiveFileBytes(), this.loadRuntime()])];
5890                    case 2:
5891                        _a = _b.sent(), bufferResolved = _a[0], runtimeResolved = _a[1];
5892                        if (this.destroyed) {
5893                            return [2 /*return*/];
5894                        }
5895                        // .riv file buffer and WASM runtime instance
5896                        this.buffer = bufferResolved;
5897                        this.runtime = runtimeResolved;
5898                        if (this.enablePerfMarks)
5899                            performance.mark('rive:init-data:start');
5900                        return [4 /*yield*/, this.initData()];
5901                    case 3:
5902                        _b.sent();
5903                        if (this.enablePerfMarks) {
5904                            performance.mark('rive:init-data:end');
5905                            performance.measure('rive:init-data', 'rive:init-data:start', 'rive:init-data:end');
5906                        }
5907                        return [3 /*break*/, 5];
5908                    case 4:
5909                        error_1 = _b.sent();
5910                        this.fireLoadError(error_1 instanceof Error ? error_1.message : RiveFile.fileLoadErrorMessage);
5911                        return [3 /*break*/, 5];
5912                    case 5: return [2 /*return*/];
5913                }
5914            });
5915        });
5916    };
5917    RiveFile.prototype.fireLoadError = function (message) {
5918        this.eventManager.fire({
5919            type: EventType.LoadError,
5920            data: message,
5921        });
5922        throw new Error(message);
5923    };
5924    /**
5925     * Subscribe to Rive-generated events
5926     * @param type the type of event to subscribe to
5927     * @param callback callback to fire when the event occurs
5928     */
5929    RiveFile.prototype.on = function (type, callback) {
5930        this.eventManager.add({
5931            type: type,
5932            callback: callback,
5933        });
5934    };
5935    /**
5936     * Unsubscribes from a Rive-generated event
5937     * @param type the type of event to unsubscribe from
5938     * @param callback the callback to unsubscribe
5939     */
5940    RiveFile.prototype.off = function (type, callback) {
5941        this.eventManager.remove({
5942            type: type,
5943            callback: callback,
5944        });
5945    };
5946    RiveFile.prototype.cleanup = function () {
5947        this.referenceCount -= 1;
5948        if (this.referenceCount <= 0) {
5949            this.removeAllRiveEventListeners();
5950            this.releaseFile();
5951            this.releaseBindableArtboards();
5952            this.destroyed = true;
5953        }
5954    };
5955    /**
5956     * Unsubscribes all Rive listeners from an event type, or everything if no type is
5957     * given
5958     * @param type the type of event to unsubscribe from, or all types if
5959     * undefined
5960     */
5961    RiveFile.prototype.removeAllRiveEventListeners = function (type) {
5962        this.eventManager.removeAll(type);
5963    };
5964    RiveFile.prototype.getInstance = function () {
5965        if (this.file !== null) {
5966            this.referenceCount += 1;
5967            return this.file;
5968        }
5969    };
5970    RiveFile.prototype.destroyIfUnused = function () {
5971        if (this.referenceCount <= 0) {
5972            this.cleanup();
5973        }
5974    };
5975    RiveFile.prototype.createBindableArtboard = function (nativeBindableArtboard) {
5976        if (nativeBindableArtboard != null) {
5977            var bindableArtboard = new BindableArtboard(nativeBindableArtboard);
5978            (0,_utils__WEBPACK_IMPORTED_MODULE_2__.createFinalization)(bindableArtboard, bindableArtboard.nativeArtboard);
5979            this.bindableArtboards.push(bindableArtboard);
5980            return bindableArtboard;
5981        }
5982        return null;
5983    };
5984    /**
5985     * @deprecated This function is deprecated. For better stability and memory management
5986     * use `getBindableArtboard()` instead.
5987     * @param {string} name - The name of the artboard.
5988     * @returns {Artboard} The artboard to bind to.
5989     */
5990    RiveFile.prototype.getArtboard = function (name) {
5991        var nativeArtboard = this.file.artboardByName(name);
5992        if (nativeArtboard != null) {
5993            return new Artboard(nativeArtboard, this);
5994        }
5995    };
5996    RiveFile.prototype.getBindableArtboard = function (name) {
5997        var nativeArtboard = this.file.bindableArtboardByName(name);
5998        return this.createBindableArtboard(nativeArtboard);
5999    };
6000    RiveFile.prototype.getDefaultBindableArtboard = function () {
6001        var nativeArtboard = this.file.bindableArtboardDefault();
6002        return this.createBindableArtboard(nativeArtboard);
6003    };
6004    RiveFile.prototype.internalBindableArtboardFromArtboard = function (artboard) {
6005        var nativeBindableArtboard = this.file.internalBindableArtboardFromArtboard(artboard);
6006        return this.createBindableArtboard(nativeBindableArtboard);
6007    };
6008    RiveFile.prototype.viewModelByName = function (name) {
6009        var viewModel = this.file.viewModelByName(name);
6010        if (viewModel !== null) {
6011            return new ViewModel(viewModel);
6012        }
6013        return null;
6014    };
6015    // Error message for missing source or buffer
6016    RiveFile.missingErrorMessage = "Rive source file or data buffer required";
6017    // Error message for file load error
6018    RiveFile.fileLoadErrorMessage = "The file failed to load";
6019    return RiveFile;
6020}());
6021
6022var Rive = /** @class */ (function () {
6023    function Rive(params) {
6024        var _this = this;
6025        var _a, _b;
6026        // Tracks if a Rive file is loaded
6027        this.loaded = false;
6028        // Tracks if a Rive file is destroyed
6029        this.destroyed = false;
6030        // Reference of an object that handles any observers for the animation
6031        this._observed = null;
6032        /**
6033         * Tracks if a Rive file is loaded; we need this in addition to loaded as some
6034         * commands (e.g. contents) can be called as soon as the file is loaded.
6035         * However, playback commands need to be queued and run in order once initial
6036         * animations and autoplay has been sorted out. This applies to play, pause,
6037         * and start.
6038         */
6039        this.readyForPlaying = false;
6040        // Runtime artboard
6041        this.artboard = null;
6042        // place to clear up event listeners
6043        this.eventCleanup = null;
6044        this.shouldDisableRiveListeners = false;
6045        this.automaticallyHandleEvents = false;
6046        this.dispatchPointerExit = true;
6047        // Allow all pointers to be passed to the runtime
6048        this.enableMultiTouch = false;
6049        // Allow the runtime to automatically load assets hosted in Rive's runtime.
6050        this.enableRiveAssetCDN = true;
6051        // Keep a local value of the set volume to update it asynchronously
6052        this._volume = 1;
6053        // Keep a local value of the set width to update it asynchronously
6054        this._artboardWidth = undefined;
6055        // Keep a local value of the set height to update it asynchronously
6056        this._artboardHeight = undefined;
6057        // Keep a local value of the device pixel ratio used in rendering and canvas/artboard resizing
6058        this._devicePixelRatioUsed = 1;
6059        // Whether the canvas element's size is 0
6060        this._hasZeroSize = false;
6061        // Whether a draw operation needs to be forced
6062        this._needsRedraw = false;
6063        // Canvas width and height. Values are lazily updated so they might
6064        // not be in sync with current canvas size.
6065        this._currentCanvasWidth = 0;
6066        this._currentCanvasHeight = 0;
6067        // Audio event listener
6068        this._audioEventListener = null;
6069        // draw method bound to the class
6070        this._boundDraw = null;
6071        this._viewModelInstance = null;
6072        this._dataEnums = null;
6073        this.drawOptimization = DrawOptimizationOptions.DrawOnChanged;
6074        // When true, emits performance.mark/measure entries for load and render.
6075        this.enablePerfMarks = false;
6076        // Durations to generate a frame for the last second. Used for performance profiling.
6077        this.durations = [];
6078        this.frameTimes = [];
6079        this.frameCount = 0;
6080        this.isTouchScrollEnabled = false;
6081        this.onCanvasResize = function (hasZeroSize) {
6082            var toggledDisplay = _this._hasZeroSize !== hasZeroSize;
6083            _this._hasZeroSize = hasZeroSize;
6084            if (!hasZeroSize) {
6085                if (toggledDisplay) {
6086                    _this.resizeDrawingSurfaceToCanvas();
6087                }
6088            }
6089            else if (!_this._layout.maxX || !_this._layout.maxY) {
6090                _this.resizeToCanvas();
6091            }
6092        };
6093        /**
6094         * Used be draw to track when a second of active rendering time has passed.
6095         * Used for debugging purposes
6096         */
6097        this.renderSecondTimer = 0;
6098        this._boundDraw = this.draw.bind(this);
6099        this.canvas = params.canvas;
6100        if (params.canvas.constructor === HTMLCanvasElement) {
6101            this._observed = observers.add(this.canvas, this.onCanvasResize);
6102        }
6103        this._currentCanvasWidth = this.canvas.width;
6104        this._currentCanvasHeight = this.canvas.height;
6105        this.src = params.src;
6106        this.buffer = params.buffer;
6107        this.riveFile = params.riveFile;
6108        this.layout = (_a = params.layout) !== null && _a !== void 0 ? _a : new Layout();
6109        this.shouldDisableRiveListeners = !!params.shouldDisableRiveListeners;
6110        this.isTouchScrollEnabled = !!params.isTouchScrollEnabled;
6111        this.automaticallyHandleEvents = !!params.automaticallyHandleEvents;
6112        this.dispatchPointerExit =
6113            params.dispatchPointerExit === false
6114                ? params.dispatchPointerExit
6115                : this.dispatchPointerExit;
6116        this.enableMultiTouch = !!params.enableMultiTouch;
6117        this.drawOptimization = (_b = params.drawingOptions) !== null && _b !== void 0 ? _b : this.drawOptimization;
6118        this.enableRiveAssetCDN =
6119            params.enableRiveAssetCDN === undefined
6120                ? true
6121                : params.enableRiveAssetCDN;
6122        this.enablePerfMarks = !!params.enablePerfMarks;
6123        if (this.enablePerfMarks)
6124            _runtimeLoader__WEBPACK_IMPORTED_MODULE_1__.RuntimeLoader.enablePerfMarks = true;
6125        // New event management system
6126        this.eventManager = new EventManager();
6127        if (params.onLoad)
6128            this.on(EventType.Load, params.onLoad);
6129        if (params.onLoadError)
6130            this.on(EventType.LoadError, params.onLoadError);
6131        if (params.onPlay)
6132            this.on(EventType.Play, params.onPlay);
6133        if (params.onPause)
6134            this.on(EventType.Pause, params.onPause);
6135        if (params.onStop)
6136            this.on(EventType.Stop, params.onStop);
6137        if (params.onLoop)
6138            this.on(EventType.Loop, params.onLoop);
6139        if (params.onStateChange)
6140            this.on(EventType.StateChange, params.onStateChange);
6141        if (params.onAdvance)
6142            this.on(EventType.Advance, params.onAdvance);
6143        /**
6144         * @deprecated Use camelCase'd versions instead.
6145         */
6146        if (params.onload && !params.onLoad)
6147            this.on(EventType.Load, params.onload);
6148        if (params.onloaderror && !params.onLoadError)
6149            this.on(EventType.LoadError, params.onloaderror);
6150        if (params.onplay && !params.onPlay)
6151            this.on(EventType.Play, params.onplay);
6152        if (params.onpause && !params.onPause)
6153            this.on(EventType.Pause, params.onpause);
6154        if (params.onstop && !params.onStop)
6155            this.on(EventType.Stop, params.onstop);
6156        if (params.onloop && !params.onLoop)
6157            this.on(EventType.Loop, params.onloop);
6158        if (params.onstatechange && !params.onStateChange)
6159            this.on(EventType.StateChange, params.onstatechange);
6160        /**
6161         * Asset loading
6162         */
6163        if (params.assetLoader)
6164            this.assetLoader = params.assetLoader;
6165        // Hook up the task queue
6166        this.taskQueue = new TaskQueueManager(this.eventManager);
6167        this.init({
6168            src: this.src,
6169            buffer: this.buffer,
6170            riveFile: this.riveFile,
6171            autoplay: params.autoplay,
6172            autoBind: params.autoBind,
6173            animations: params.animations,
6174            stateMachines: params.stateMachines,
6175            artboard: params.artboard,
6176            useOffscreenRenderer: params.useOffscreenRenderer,
6177        });
6178    }
6179    Object.defineProperty(Rive.prototype, "viewModelCount", {
6180        get: function () {
6181            return this.file.viewModelCount();
6182        },
6183        enumerable: false,
6184        configurable: true
6185    });
6186    // Alternative constructor to build a Rive instance from an interface/object
6187    Rive.new = function (params) {
6188        console.warn("This function is deprecated: please use `new Rive({})` instead");
6189        return new Rive(params);
6190    };
6191    // Event handler for when audio context becomes available
6192    Rive.prototype.onSystemAudioChanged = function () {
6193        this.volume = this._volume;
6194    };
6195    // Initializes the Rive object either from constructor or load()
6196    Rive.prototype.init = function (_a) {
6197        var _this = this;
6198        var src = _a.src, buffer = _a.buffer, riveFile = _a.riveFile, animations = _a.animations, stateMachines = _a.stateMachines, artboard = _a.artboard, _b = _a.autoplay, autoplay = _b === void 0 ? false : _b, _c = _a.useOffscreenRenderer, useOffscreenRenderer = _c === void 0 ? false : _c, _d = _a.autoBind, autoBind = _d === void 0 ? false : _d;
6199        if (this.destroyed) {
6200            return;
6201        }
6202        this.src = src;
6203        this.buffer = buffer;
6204        this.riveFile = riveFile;
6205        // If no source file url specified, it's a bust
6206        if (!this.src && !this.buffer && !this.riveFile) {
6207            throw new RiveError(Rive.missingErrorMessage);
6208        }
6209        // List of animations that should be initialized.
6210        var startingAnimationNames = mapToStringArray(animations);
6211        // List of state machines that should be initialized
6212        var startingStateMachineNames = mapToStringArray(stateMachines);
6213        // Ensure loaded is marked as false if loading new file
6214        this.loaded = false;
6215        this.readyForPlaying = false;
6216        // Ensure the runtime is loaded
6217        _runtimeLoader__WEBPACK_IMPORTED_MODULE_1__.RuntimeLoader.awaitInstance()
6218            .then(function (runtime) {
6219            if (_this.destroyed) {
6220                return;
6221            }
6222            _this.runtime = runtime;
6223            _this.removeRiveListeners();
6224            _this.deleteRiveRenderer();
6225            // Get the canvas where you want to render the animation and create a renderer
6226            if (_this.enablePerfMarks)
6227                performance.mark('rive:make-renderer:start');
6228            _this.renderer = _this.runtime.makeRenderer(_this.canvas, useOffscreenRenderer);
6229            if (_this.enablePerfMarks) {
6230                performance.mark('rive:make-renderer:end');
6231                performance.measure('rive:make-renderer', 'rive:make-renderer:start', 'rive:make-renderer:end');
6232            }
6233            // Initial size adjustment based on devicePixelRatio if no width/height are
6234            // specified explicitly
6235            if (!(_this.canvas.width || _this.canvas.height)) {
6236                _this.resizeDrawingSurfaceToCanvas();
6237            }
6238            // Load Rive data from a source uri or a data buffer
6239            _this.initData(artboard, startingAnimationNames, startingStateMachineNames, autoplay, autoBind)
6240                .then(function (hasInitialized) {
6241                if (hasInitialized) {
6242                    return _this.setupRiveListeners();
6243                }
6244            })
6245                .catch(function (e) {
6246                console.error(e);
6247            });
6248        })
6249            .catch(function (e) {
6250            console.error(e);
6251        });
6252    };
6253    /**
6254     * Setup Rive Listeners on the canvas
6255     * @param riveListenerOptions - Enables TouchEvent events on the canvas. Set to true to allow
6256     * touch scrolling on the canvas element on touch-enabled devices
6257     * i.e. { isTouchScrollEnabled: true }
6258     */
6259    Rive.prototype.setupRiveListeners = function (riveListenerOptions) {
6260        var _this = this;
6261        if (this.eventCleanup) {
6262            this.eventCleanup();
6263        }
6264        if (!this.shouldDisableRiveListeners) {
6265            var activeStateMachines = (this.animator.stateMachines || [])
6266                .filter(function (sm) { return sm.playing && _this.runtime.hasListeners(sm.instance); })
6267                .map(function (sm) { return sm.instance; });
6268            var touchScrollEnabledOption = this.isTouchScrollEnabled;
6269            var dispatchPointerExit = this.dispatchPointerExit;
6270            var enableMultiTouch = this.enableMultiTouch;
6271            if (riveListenerOptions &&
6272                "isTouchScrollEnabled" in riveListenerOptions) {
6273                touchScrollEnabledOption = riveListenerOptions.isTouchScrollEnabled;
6274            }
6275            this.eventCleanup = (0,_utils__WEBPACK_IMPORTED_MODULE_2__.registerTouchInteractions)({
6276                canvas: this.canvas,
6277                artboard: this.artboard,
6278                stateMachines: activeStateMachines,
6279                renderer: this.renderer,
6280                rive: this.runtime,
6281                fit: this._layout.runtimeFit(this.runtime),
6282                alignment: this._layout.runtimeAlignment(this.runtime),
6283                isTouchScrollEnabled: touchScrollEnabledOption,
6284                dispatchPointerExit: dispatchPointerExit,
6285                enableMultiTouch: enableMultiTouch,
6286                layoutScaleFactor: this._layout.layoutScaleFactor,
6287            });
6288        }
6289    };
6290    /**
6291     * Remove Rive Listeners setup on the canvas
6292     */
6293    Rive.prototype.removeRiveListeners = function () {
6294        if (this.eventCleanup) {
6295            this.eventCleanup();
6296            this.eventCleanup = null;
6297        }
6298    };
6299    /**
6300     * If the instance has audio and the system audio is not ready
6301     * we hook the instance to the audio manager
6302     */
6303    Rive.prototype.initializeAudio = function () {
6304        var _this = this;
6305        var _a;
6306        // Initialize audio if needed
6307        if (audioManager.status == SystemAudioStatus.UNAVAILABLE) {
6308            if (this.file.hasAudio ||
6309                (((_a = this.artboard) === null || _a === void 0 ? void 0 : _a.hasAudio) && this._audioEventListener === null)) {
6310                this._audioEventListener = {
6311                    type: EventType.AudioStatusChange,
6312                    callback: function () { return _this.onSystemAudioChanged(); },
6313                };
6314                audioManager.add(this._audioEventListener);
6315                audioManager.establishAudio();
6316            }
6317        }
6318    };
6319    Rive.prototype.initArtboardSize = function () {
6320        if (!this.artboard)
6321            return;
6322        // Use preset values if they are not undefined
6323        this._artboardWidth = this.artboard.width =
6324            this._artboardWidth || this.artboard.width;
6325        this._artboardHeight = this.artboard.height =
6326            this._artboardHeight || this.artboard.height;
6327    };
6328    // Initializes runtime with Rive data and preps for playing.
6329    // Returns true for successful initialization.
6330    Rive.prototype.initData = function (artboardName, animationNames, stateMachineNames, autoplay, autoBind) {
6331        return __awaiter(this, void 0, void 0, function () {
6332            var riveFile, error_2, msg;
6333            var _a;
6334            return __generator(this, function (_b) {
6335                switch (_b.label) {
6336                    case 0:
6337                        _b.trys.push([0, 3, , 4]);
6338                        if (!(this.riveFile == null)) return [3 /*break*/, 2];
6339                        riveFile = new RiveFile({
6340                            src: this.src,
6341                            buffer: this.buffer,
6342                            enableRiveAssetCDN: this.enableRiveAssetCDN,
6343                            assetLoader: this.assetLoader,
6344                            enablePerfMarks: this.enablePerfMarks,
6345                        });
6346                        this.riveFile = riveFile;
6347                        return [4 /*yield*/, riveFile.init()];
6348                    case 1:
6349                        _b.sent();
6350                        if (this.destroyed) {
6351                            // In the very unlikely scenario where the rive file created by this Rive is shared by
6352                            // another rive file, we only want to destroy it if this file is the only owner.
6353                            riveFile.destroyIfUnused();
6354                            return [2 /*return*/, false];
6355                        }
6356                        _b.label = 2;
6357                    case 2:
6358                        this.file = this.riveFile.getInstance();
6359                        // Initialize and draw frame
6360                        this.initArtboard(artboardName, animationNames, stateMachineNames, autoplay, autoBind);
6361                        // Initialize the artboard size
6362                        this.initArtboardSize();
6363                        // Check for audio
6364                        this.initializeAudio();
6365                        // Everything's set up, emit a load event
6366                        this.loaded = true;
6367                        this.eventManager.fire({
6368                            type: EventType.Load,
6369                            data: (_a = this.src) !== null && _a !== void 0 ? _a : "buffer",
6370                        });
6371                        // Only initialize paused state machines after the load event has been fired
6372                        // to allow users to initialize inputs and view models before the first advance
6373                        this.animator.advanceIfPaused();
6374                        // Flag ready for playback commands and clear the task queue; this order
6375                        // is important or it may infinitely recurse
6376                        this.readyForPlaying = true;
6377                        this.taskQueue.process();
6378                        this.drawFrame();
6379                        return [2 /*return*/, true];
6380                    case 3:
6381                        error_2 = _b.sent();
6382                        msg = resolveErrorMessage(error_2);
6383                        console.warn(msg);
6384                        this.eventManager.fire({ type: EventType.LoadError, data: msg });
6385                        return [2 /*return*/, Promise.reject(msg)];
6386                    case 4: return [2 /*return*/];
6387                }
6388            });
6389        });
6390    };
6391    // Initialize for playback
6392    Rive.prototype.initArtboard = function (artboardName, animationNames, stateMachineNames, autoplay, autoBind) {
6393        if (!this.file) {
6394            return;
6395        }
6396        // Fetch the artboard
6397        var rootArtboard = artboardName
6398            ? this.file.artboardByName(artboardName)
6399            : this.file.defaultArtboard();
6400        // Check we have a working artboard
6401        if (!rootArtboard) {
6402            var msg = "Invalid artboard name or no default artboard";
6403            console.warn(msg);
6404            this.eventManager.fire({ type: EventType.LoadError, data: msg });
6405            return;
6406        }
6407        this.artboard = rootArtboard;
6408        rootArtboard.volume = this._volume * audioManager.systemVolume;
6409        // Initialize the animator
6410        this.animator = new Animator(this.runtime, this.artboard, this.eventManager);
6411        // Initialize the animations; as loaded hasn't happened yet, we need to
6412        // suppress firing the play/pause events until the load event has fired. To
6413        // do this we tell the animator to suppress firing events, and add event
6414        // firing to the task queue.
6415        var instanceNames;
6416        if (animationNames.length > 0 || stateMachineNames.length > 0) {
6417            instanceNames = animationNames.concat(stateMachineNames);
6418            this.animator.initLinearAnimations(animationNames, autoplay);
6419            this.animator.initStateMachines(stateMachineNames, autoplay);
6420        }
6421        else {
6422            instanceNames = [this.animator.atLeastOne(autoplay, false)];
6423        }
6424        // Queue up firing the playback events
6425        this.taskQueue.add({
6426            event: {
6427                type: autoplay ? EventType.Play : EventType.Pause,
6428                data: instanceNames,
6429            },
6430        });
6431        if (autoBind) {
6432            var viewModel = this.file.defaultArtboardViewModel(rootArtboard);
6433            if (viewModel !== null) {
6434                var runtimeInstance = viewModel.defaultInstance();
6435                if (runtimeInstance !== null) {
6436                    var viewModelInstance = new ViewModelInstance(runtimeInstance, null);
6437                    (0,_utils__WEBPACK_IMPORTED_MODULE_2__.createFinalization)(viewModelInstance, viewModelInstance.runtimeInstance);
6438                    this.bindViewModelInstance(viewModelInstance);
6439                }
6440            }
6441        }
6442    };
6443    // Draws the current artboard frame
6444    Rive.prototype.drawFrame = function () {
6445        var _a, _b;
6446        if ((_a = document === null || document === void 0 ? void 0 : document.timeline) === null || _a === void 0 ? void 0 : _a.currentTime) {
6447            if (this.loaded && this.artboard && !this.frameRequestId) {
6448                this._boundDraw(document.timeline.currentTime);
6449                (_b = this.runtime) === null || _b === void 0 ? void 0 : _b.resolveAnimationFrame();
6450            }
6451        }
6452        else {
6453            this.scheduleRendering();
6454        }
6455    };
6456    Rive.prototype._canvasSizeChanged = function () {
6457        var changed = false;
6458        if (this.canvas) {
6459            if (this.canvas.width !== this._currentCanvasWidth) {
6460                this._currentCanvasWidth = this.canvas.width;
6461                changed = true;
6462            }
6463            if (this.canvas.height !== this._currentCanvasHeight) {
6464                this._currentCanvasHeight = this.canvas.height;
6465                changed = true;
6466            }
6467        }
6468        return changed;
6469    };
6470    /**
6471     * Draw rendering loop; renders animation frames at the correct time interval.
6472     * @param time the time at which to render a frame
6473     */
6474    Rive.prototype.draw = function (time, onSecond) {
6475        var _a;
6476        // Clear the frameRequestId, as we're now rendering a fresh frame
6477        this.frameRequestId = null;
6478        var before = performance.now();
6479        // On the first pass, make sure lastTime has a valid value
6480        if (!this.lastRenderTime) {
6481            this.lastRenderTime = time;
6482        }
6483        // Handle the onSecond callback
6484        this.renderSecondTimer += time - this.lastRenderTime;
6485        if (this.renderSecondTimer > 5000) {
6486            this.renderSecondTimer = 0;
6487            onSecond === null || onSecond === void 0 ? void 0 : onSecond();
6488        }
6489        // Calculate the elapsed time between frames in seconds
6490        var elapsedTime = (time - this.lastRenderTime) / 1000;
6491        this.lastRenderTime = time;
6492        // - Advance non-paused animations by the elapsed number of seconds
6493        // - Advance any animations that require scrubbing
6494        // - Advance to the first frame even when autoplay is false
6495        var activeAnimations = this.animator.animations
6496            .filter(function (a) { return a.playing || a.needsScrub; })
6497            // The scrubbed animations must be applied first to prevent weird artifacts
6498            // if the playing animations conflict with the scrubbed animating attribuates.
6499            .sort(function (first) { return (first.needsScrub ? -1 : 1); });
6500        for (var _i = 0, activeAnimations_1 = activeAnimations; _i < activeAnimations_1.length; _i++) {
6501            var animation = activeAnimations_1[_i];
6502            animation.advance(elapsedTime);
6503            if (animation.instance.didLoop) {
6504                animation.loopCount += 1;
6505            }
6506            animation.apply(1.0);
6507        }
6508        // - Advance non-paused state machines by the elapsed number of seconds
6509        // - Advance to the first frame even when autoplay is false
6510        var activeStateMachines = this.animator.stateMachines.filter(function (a) { return a.playing; });
6511        // Instrument the first 3 frames so the Performance timeline shows precise
6512        // per-call latency for advance, draw, and flush without polluting the trace.
6513        var _perfFrame = this.enablePerfMarks && this.frameCount < 3 ? this.frameCount : -1;
6514        for (var _b = 0, activeStateMachines_1 = activeStateMachines; _b < activeStateMachines_1.length; _b++) {
6515            var stateMachine = activeStateMachines_1[_b];
6516            // Check for events before the current frame's state machine advance
6517            var numEventsReported = stateMachine.reportedEventCount();
6518            if (numEventsReported) {
6519                for (var i = 0; i < numEventsReported; i++) {
6520                    var event_1 = stateMachine.reportedEventAt(i);
6521                    if (event_1) {
6522                        if (event_1.type === RiveEventType.OpenUrl) {
6523                            this.eventManager.fire({
6524                                type: EventType.RiveEvent,
6525                                data: event_1,
6526                            });
6527                            // Handle the event side effect if explicitly enabled
6528                            if (this.automaticallyHandleEvents) {
6529                                var newAnchorTag = document.createElement("a");
6530                                var _c = event_1, url = _c.url, target = _c.target;
6531                                var sanitizedUrl = (0,_utils__WEBPACK_IMPORTED_MODULE_2__.sanitizeUrl)(url);
6532                                url && newAnchorTag.setAttribute("href", sanitizedUrl);
6533                                target && newAnchorTag.setAttribute("target", target);
6534                                if (sanitizedUrl && sanitizedUrl !== _utils__WEBPACK_IMPORTED_MODULE_2__.BLANK_URL) {
6535                                    newAnchorTag.click();
6536                                }
6537                            }
6538                        }
6539                        else {
6540                            this.eventManager.fire({
6541                                type: EventType.RiveEvent,
6542                                data: event_1,
6543                            });
6544                        }
6545                    }
6546                }
6547            }
6548            if (_perfFrame >= 0)
6549                performance.mark("rive:sm-advance:start:f".concat(_perfFrame));
6550            stateMachine.advanceAndApply(elapsedTime);
6551            if (_perfFrame >= 0) {
6552                performance.mark("rive:sm-advance:end:f".concat(_perfFrame));
6553                performance.measure("rive:sm-advance:f".concat(_perfFrame), "rive:sm-advance:start:f".concat(_perfFrame), "rive:sm-advance:end:f".concat(_perfFrame));
6554            }
6555            // stateMachine.instance.apply(this.artboard);
6556        }
6557        // Once the animations have been applied to the artboard, advance it
6558        // by the elapsed time.
6559        if (this.animator.stateMachines.length == 0) {
6560            this.artboard.advance(elapsedTime);
6561        }
6562        var renderer = this.renderer;
6563        // Do not draw on 0 canvas size
6564        if (!this._hasZeroSize) {
6565            // If there was no dirt on this frame, do not clear and draw
6566            if (this.drawOptimization == DrawOptimizationOptions.AlwaysDraw ||
6567                this.artboard.didChange() ||
6568                this._needsRedraw ||
6569                this._canvasSizeChanged()) {
6570                // Canvas must be wiped to prevent artifacts
6571                renderer.clear();
6572                renderer.save();
6573                // Update the renderer alignment if necessary
6574                if (_perfFrame >= 0)
6575                    performance.mark("rive:align-renderer:start:f".concat(_perfFrame));
6576                this.alignRenderer();
6577                if (_perfFrame >= 0) {
6578                    performance.mark("rive:align-renderer:end:f".concat(_perfFrame));
6579                    performance.measure("rive:align-renderer:f".concat(_perfFrame), "rive:align-renderer:start:f".concat(_perfFrame), "rive:align-renderer:end:f".concat(_perfFrame));
6580                }
6581                if (_perfFrame >= 0)
6582                    performance.mark("rive:artboard-draw:start:f".concat(_perfFrame));
6583                this.artboard.draw(renderer);
6584                if (_perfFrame >= 0) {
6585                    performance.mark("rive:artboard-draw:end:f".concat(_perfFrame));
6586                    performance.measure("rive:artboard-draw:f".concat(_perfFrame), "rive:artboard-draw:start:f".concat(_perfFrame), "rive:artboard-draw:end:f".concat(_perfFrame));
6587                }
6588                renderer.restore();
6589                if (_perfFrame >= 0)
6590                    performance.mark("rive:renderer-flush:start:f".concat(_perfFrame));
6591                renderer.flush();
6592                if (_perfFrame >= 0) {
6593                    performance.mark("rive:renderer-flush:end:f".concat(_perfFrame));
6594                    performance.measure("rive:renderer-flush:f".concat(_perfFrame), "rive:renderer-flush:start:f".concat(_perfFrame), "rive:renderer-flush:end:f".concat(_perfFrame));
6595                }
6596                this._needsRedraw = false;
6597            }
6598        }
6599        // Check for any animations that looped
6600        this.animator.handleLooping();
6601        // Check for any state machines that had a state change
6602        this.animator.handleStateChanges();
6603        // Report advanced time
6604        this.animator.handleAdvancing(elapsedTime);
6605        // Add duration to create frame to durations array
6606        this.frameCount++;
6607        var after = performance.now();
6608        this.frameTimes.push(after);
6609        this.durations.push(after - before);
6610        while (this.frameTimes[0] <= after - 1000) {
6611            this.frameTimes.shift();
6612            this.durations.shift();
6613        }
6614        (_a = this._viewModelInstance) === null || _a === void 0 ? void 0 : _a.handleCallbacks();
6615        // Calling requestAnimationFrame will rerun draw() at the correct rate:
6616        // https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Basic_animations
6617        if (this.animator.isPlaying) {
6618            // Request a new rendering frame
6619            this.scheduleRendering();
6620        }
6621        else if (this.animator.isPaused) {
6622            // Reset the end time so on playback it starts at the correct frame
6623            this.lastRenderTime = 0;
6624        }
6625        else if (this.animator.isStopped) {
6626            // Reset animation instances, artboard and time
6627            // TODO: implement this properly when we have instancing
6628            // this.initArtboard();
6629            // this.drawFrame();
6630            this.lastRenderTime = 0;
6631        }
6632    };
6633    /**
6634     * Align the renderer
6635     */
6636    Rive.prototype.alignRenderer = function () {
6637        var _a = this, renderer = _a.renderer, runtime = _a.runtime, _layout = _a._layout, artboard = _a.artboard;
6638        // Align things up safe in the knowledge we can restore if changed
6639        renderer.align(_layout.runtimeFit(runtime), _layout.runtimeAlignment(runtime), {
6640            minX: _layout.minX,
6641            minY: _layout.minY,
6642            maxX: _layout.maxX,
6643            maxY: _layout.maxY,
6644        }, artboard.bounds, this._devicePixelRatioUsed * _layout.layoutScaleFactor);
6645    };
6646    Object.defineProperty(Rive.prototype, "fps", {
6647        get: function () {
6648            return this.durations.length;
6649        },
6650        enumerable: false,
6651        configurable: true
6652    });
6653    Object.defineProperty(Rive.prototype, "frameTime", {
6654        get: function () {
6655            if (this.durations.length === 0) {
6656                return 0;
6657            }
6658            return (this.durations.reduce(function (a, b) { return a + b; }, 0) / this.durations.length).toFixed(4);
6659        },
6660        enumerable: false,
6661        configurable: true
6662    });
6663    /**
6664     * Cleans up all Wasm-generated objects that need to be manually destroyed:
6665     * artboard instances, animation instances, state machine instances,
6666     * renderer instance, file and runtime.
6667     *
6668     * Once this is called, you will need to initialise a new instance of the
6669     * Rive class
6670     */
6671    Rive.prototype.cleanup = function () {
6672        var _a, _b;
6673        this.destroyed = true;
6674        // Stop the renderer if it hasn't already been stopped.
6675        this.stopRendering();
6676        // Clean up any artboard, animation or state machine instances.
6677        this.cleanupInstances();
6678        // Remove from observer
6679        if (this._observed !== null) {
6680            observers.remove(this._observed);
6681        }
6682        this.removeRiveListeners();
6683        if (this.file) {
6684            (_a = this.riveFile) === null || _a === void 0 ? void 0 : _a.cleanup();
6685            this.file = null;
6686        }
6687        this.riveFile = null;
6688        this.deleteRiveRenderer();
6689        if (this._audioEventListener !== null) {
6690            audioManager.remove(this._audioEventListener);
6691            this._audioEventListener = null;
6692        }
6693        (_b = this._viewModelInstance) === null || _b === void 0 ? void 0 : _b.cleanup();
6694        this._viewModelInstance = null;
6695        this._dataEnums = null;
6696    };
6697    /**
6698     * Cleans up the Renderer object. Only call this API if you no longer
6699     * need to render Rive content in your session.
6700     */
6701    Rive.prototype.deleteRiveRenderer = function () {
6702        var _a;
6703        (_a = this.renderer) === null || _a === void 0 ? void 0 : _a.delete();
6704        this.renderer = null;
6705    };
6706    /**
6707     * Cleans up any Wasm-generated objects that need to be manually destroyed:
6708     * artboard instances, animation instances, state machine instances.
6709     *
6710     * Once this is called, things will need to be reinitialized or bad things
6711     * might happen.
6712     */
6713    Rive.prototype.cleanupInstances = function () {
6714        if (this.eventCleanup !== null) {
6715            this.eventCleanup();
6716        }
6717        // Delete all animation and state machine instances
6718        this.stop();
6719        if (this.artboard) {
6720            this.artboard.delete();
6721            this.artboard = null;
6722        }
6723    };
6724    /**
6725     * Tries to query the setup Artboard for a text run node with the given name.
6726     *
6727     * @param textRunName - Name of the text run node associated with a text object
6728     * @returns - TextValueRun node or undefined if the text run cannot be queried
6729     */
6730    Rive.prototype.retrieveTextRun = function (textRunName) {
6731        var _a;
6732        if (!textRunName) {
6733            console.warn("No text run name provided");
6734            return;
6735        }
6736        if (!this.artboard) {
6737            console.warn("Tried to access text run, but the Artboard is null");
6738            return;
6739        }
6740        var textRun = this.artboard.textRun(textRunName);
6741        if (!textRun) {
6742            console.warn("Could not access a text run with name '".concat(textRunName, "' in the '").concat((_a = this.artboard) === null || _a === void 0 ? void 0 : _a.name, "' Artboard. Note that you must rename a text run node in the Rive editor to make it queryable at runtime."));
6743            return;
6744        }
6745        return textRun;
6746    };
6747    /**
6748     * Returns a string from a given text run node name, or undefined if the text run
6749     * cannot be queried.
6750     *
6751     * @param textRunName - Name of the text run node associated with a text object
6752     * @returns - String value of the text run node or undefined
6753     */
6754    Rive.prototype.getTextRunValue = function (textRunName) {
6755        var textRun = this.retrieveTextRun(textRunName);
6756        return textRun ? textRun.text : undefined;
6757    };
6758    /**
6759     * Sets a text value for a given text run node name if possible
6760     *
6761     * @param textRunName - Name of the text run node associated with a text object
6762     * @param textRunValue - String value to set on the text run node
6763     */
6764    Rive.prototype.setTextRunValue = function (textRunName, textRunValue) {
6765        var textRun = this.retrieveTextRun(textRunName);
6766        if (textRun) {
6767            textRun.text = textRunValue;
6768        }
6769    };
6770    // Plays specified animations; if none specified, it unpauses everything.
6771    Rive.prototype.play = function (animationNames, autoplay) {
6772        var _this = this;
6773        animationNames = mapToStringArray(animationNames);
6774        // If the file's not loaded, queue up the play
6775        if (!this.readyForPlaying) {
6776            this.taskQueue.add({
6777                action: function () { return _this.play(animationNames, autoplay); },
6778            });
6779            return;
6780        }
6781        this.animator.play(animationNames);
6782        if (this.eventCleanup) {
6783            this.eventCleanup();
6784        }
6785        this.setupRiveListeners();
6786        this.startRendering();
6787    };
6788    // Pauses specified animations; if none specified, pauses all.
6789    Rive.prototype.pause = function (animationNames) {
6790        var _this = this;
6791        animationNames = mapToStringArray(animationNames);
6792        // If the file's not loaded, early out, nothing to pause
6793        if (!this.readyForPlaying) {
6794            this.taskQueue.add({
6795                action: function () { return _this.pause(animationNames); },
6796            });
6797            return;
6798        }
6799        if (this.eventCleanup) {
6800            this.eventCleanup();
6801        }
6802        this.animator.pause(animationNames);
6803    };
6804    Rive.prototype.scrub = function (animationNames, value) {
6805        var _this = this;
6806        animationNames = mapToStringArray(animationNames);
6807        // If the file's not loaded, early out, nothing to pause
6808        if (!this.readyForPlaying) {
6809            this.taskQueue.add({
6810                action: function () { return _this.scrub(animationNames, value); },
6811            });
6812            return;
6813        }
6814        // Scrub the animation time; we draw a single frame here so that if
6815        // nothing's currently playing, the scrubbed animation is still rendered/
6816        this.animator.scrub(animationNames, value || 0);
6817        this.drawFrame();
6818    };
6819    // Stops specified animations; if none specifies, stops them all.
6820    Rive.prototype.stop = function (animationNames) {
6821        var _this = this;
6822        animationNames = mapToStringArray(animationNames);
6823        // If the file's not loaded, early out, nothing to pause
6824        if (!this.readyForPlaying) {
6825            this.taskQueue.add({
6826                action: function () { return _this.stop(animationNames); },
6827            });
6828            return;
6829        }
6830        // If there is no artboard, this.animator will be undefined
6831        if (this.animator) {
6832            this.animator.stop(animationNames);
6833        }
6834        if (this.eventCleanup) {
6835            this.eventCleanup();
6836        }
6837    };
6838    /**
6839     * Resets the animation
6840     * @param artboard the name of the artboard, or default if none given
6841     * @param animations the names of animations for playback
6842     * @param stateMachines the names of state machines for playback
6843     * @param autoplay whether to autoplay when reset, defaults to false
6844     *
6845     */
6846    Rive.prototype.reset = function (params) {
6847        var _a, _b;
6848        // Get the current artboard, animations, state machines, and playback states
6849        var artBoardName = params === null || params === void 0 ? void 0 : params.artboard;
6850        var animationNames = mapToStringArray(params === null || params === void 0 ? void 0 : params.animations);
6851        var stateMachineNames = mapToStringArray(params === null || params === void 0 ? void 0 : params.stateMachines);
6852        var autoplay = (_a = params === null || params === void 0 ? void 0 : params.autoplay) !== null && _a !== void 0 ? _a : false;
6853        var autoBind = (_b = params === null || params === void 0 ? void 0 : params.autoBind) !== null && _b !== void 0 ? _b : false;
6854        // Stop everything and clean up
6855        this.cleanupInstances();
6856        // Reinitialize an artboard instance with the state
6857        this.initArtboard(artBoardName, animationNames, stateMachineNames, autoplay, autoBind);
6858        this.taskQueue.process();
6859    };
6860    // Loads a new Rive file, keeping listeners in place
6861    Rive.prototype.load = function (params) {
6862        this.file = null;
6863        // Stop all animations
6864        this.stop();
6865        // Reinitialize
6866        this.init(params);
6867    };
6868    Object.defineProperty(Rive.prototype, "layout", {
6869        /**
6870         * Returns the current layout. Note that layout should be treated as
6871         * immutable. If you want to change the layout, create a new one use the
6872         * layout setter
6873         */
6874        get: function () {
6875            return this._layout;
6876        },
6877        // Sets a new layout
6878        set: function (layout) {
6879            this._layout = layout;
6880            // If the maxX or maxY are 0, then set them to the canvas width and height
6881            if (!layout.maxX || !layout.maxY) {
6882                this.resizeToCanvas();
6883            }
6884            if (this.loaded && !this.animator.isPlaying) {
6885                this.drawFrame();
6886            }
6887        },
6888        enumerable: false,
6889        configurable: true
6890    });
6891    /**
6892     * Sets the layout bounds to the current canvas size; this is typically called
6893     * when the canvas is resized
6894     */
6895    Rive.prototype.resizeToCanvas = function () {
6896        this._layout = this.layout.copyWith({
6897            minX: 0,
6898            minY: 0,
6899            maxX: this.canvas.width,
6900            maxY: this.canvas.height,
6901        });
6902    };
6903    /**
6904     * Accounts for devicePixelRatio as a multiplier to render the size of the canvas drawing surface.
6905     * Uses the size of the backing canvas to set new width/height attributes. Need to re-render
6906     * and resize the layout to match the new drawing surface afterwards.
6907     * Useful function for consumers to include in a window resize listener.
6908     *
6909     * This method will set the {@link devicePixelRatioUsed} property.
6910     *
6911     * Optionally, you can provide a {@link customDevicePixelRatio} to provide a
6912     * custom value.
6913     */
6914    Rive.prototype.resizeDrawingSurfaceToCanvas = function (customDevicePixelRatio) {
6915        if (this.canvas instanceof HTMLCanvasElement && !!window) {
6916            var _a = this.canvas.getBoundingClientRect(), width = _a.width, height = _a.height;
6917            var dpr = customDevicePixelRatio || window.devicePixelRatio || 1;
6918            this.devicePixelRatioUsed = dpr;
6919            this.canvas.width = dpr * width;
6920            this.canvas.height = dpr * height;
6921            this._needsRedraw = true;
6922            this.resizeToCanvas();
6923            this.drawFrame();
6924            if (this.layout.fit === Fit.Layout) {
6925                var scaleFactor = this._layout.layoutScaleFactor;
6926                this.artboard.width = width / scaleFactor;
6927                this.artboard.height = height / scaleFactor;
6928            }
6929        }
6930    };
6931    Object.defineProperty(Rive.prototype, "source", {
6932        // Returns the animation source, which may be undefined
6933        get: function () {
6934            return this.src;
6935        },
6936        enumerable: false,
6937        configurable: true
6938    });
6939    Object.defineProperty(Rive.prototype, "activeArtboard", {
6940        /**
6941         * Returns the name of the active artboard
6942         */
6943        get: function () {
6944            return this.artboard ? this.artboard.name : "";
6945        },
6946        enumerable: false,
6947        configurable: true
6948    });
6949    Object.defineProperty(Rive.prototype, "animationNames", {
6950        // Returns a list of animation names on the chosen artboard
6951        get: function () {
6952            // If the file's not loaded, we got nothing to return
6953            if (!this.loaded || !this.artboard) {
6954                return [];
6955            }
6956            var animationNames = [];
6957            for (var i = 0; i < this.artboard.animationCount(); i++) {
6958                animationNames.push(this.artboard.animationByIndex(i).name);
6959            }
6960            return animationNames;
6961        },
6962        enumerable: false,
6963        configurable: true
6964    });
6965    Object.defineProperty(Rive.prototype, "stateMachineNames", {
6966        /**
6967         * Returns a list of state machine names from the current artboard
6968         */
6969        get: function () {
6970            // If the file's not loaded, we got nothing to return
6971            if (!this.loaded || !this.artboard) {
6972                return [];
6973            }
6974            var stateMachineNames = [];
6975            for (var i = 0; i < this.artboard.stateMachineCount(); i++) {
6976                stateMachineNames.push(this.artboard.stateMachineByIndex(i).name);
6977            }
6978            return stateMachineNames;
6979        },
6980        enumerable: false,
6981        configurable: true
6982    });
6983    /**
6984     * Returns the inputs for the specified instanced state machine, or an empty
6985     * list if the name is invalid or the state machine is not instanced
6986     * @param name the state machine name
6987     * @returns the inputs for the named state machine
6988     */
6989    Rive.prototype.stateMachineInputs = function (name) {
6990        // If the file's not loaded, early out, nothing to pause
6991        if (!this.loaded) {
6992            return;
6993        }
6994        var stateMachine = this.animator.stateMachines.find(function (m) { return m.name === name; });
6995        return stateMachine === null || stateMachine === void 0 ? void 0 : stateMachine.inputs;
6996    };
6997    // Returns the input with the provided name at the given path
6998    Rive.prototype.retrieveInputAtPath = function (name, path) {
6999        if (!name) {
7000            console.warn("No input name provided for path '".concat(path, "'"));
7001            return;
7002        }
7003        if (!this.artboard) {
7004            console.warn("Tried to access input: '".concat(name, "', at path: '").concat(path, "', but the Artboard is null"));
7005            return;
7006        }
7007        var input = this.artboard.inputByPath(name, path);
7008        if (!input) {
7009            console.warn("Could not access an input with name: '".concat(name, "', at path:'").concat(path, "'"));
7010            return;
7011        }
7012        return input;
7013    };
7014    /**
7015     * Set the boolean input with the provided name at the given path with value
7016     * @param input the state machine input name
7017     * @param value the value to set the input to
7018     * @param path the path the input is located at an artboard level
7019     */
7020    Rive.prototype.setBooleanStateAtPath = function (inputName, value, path) {
7021        var input = this.retrieveInputAtPath(inputName, path);
7022        if (!input)
7023            return;
7024        if (input.type === StateMachineInputType.Boolean) {
7025            input.asBool().value = value;
7026        }
7027        else {
7028            console.warn("Input with name: '".concat(inputName, "', at path:'").concat(path, "' is not a boolean"));
7029        }
7030    };
7031    /**
7032     * Set the number input with the provided name at the given path with value
7033     * @param input the state machine input name
7034     * @param value the value to set the input to
7035     * @param path the path the input is located at an artboard level
7036     */
7037    Rive.prototype.setNumberStateAtPath = function (inputName, value, path) {
7038        var input = this.retrieveInputAtPath(inputName, path);
7039        if (!input)
7040            return;
7041        if (input.type === StateMachineInputType.Number) {
7042            input.asNumber().value = value;
7043        }
7044        else {
7045            console.warn("Input with name: '".concat(inputName, "', at path:'").concat(path, "' is not a number"));
7046        }
7047    };
7048    /**
7049     * Fire the trigger with the provided name at the given path
7050     * @param input the state machine input name
7051     * @param path the path the input is located at an artboard level
7052     */
7053    Rive.prototype.fireStateAtPath = function (inputName, path) {
7054        var input = this.retrieveInputAtPath(inputName, path);
7055        if (!input)
7056            return;
7057        if (input.type === StateMachineInputType.Trigger) {
7058            input.asTrigger().fire();
7059        }
7060        else {
7061            console.warn("Input with name: '".concat(inputName, "', at path:'").concat(path, "' is not a trigger"));
7062        }
7063    };
7064    // Returns the TextValueRun object for the provided name at the given path
7065    Rive.prototype.retrieveTextAtPath = function (name, path) {
7066        if (!name) {
7067            console.warn("No text name provided for path '".concat(path, "'"));
7068            return;
7069        }
7070        if (!path) {
7071            console.warn("No path provided for text '".concat(name, "'"));
7072            return;
7073        }
7074        if (!this.artboard) {
7075            console.warn("Tried to access text: '".concat(name, "', at path: '").concat(path, "', but the Artboard is null"));
7076            return;
7077        }
7078        var text = this.artboard.textByPath(name, path);
7079        if (!text) {
7080            console.warn("Could not access text with name: '".concat(name, "', at path:'").
7080concat(path, "'"));
7081            return;
7082        }
7083        return text;
7084    };
7085    /**
7086     * Retrieves the text value for a specified text run at a given path
7087     * @param textName The name of the text run
7088     * @param path The path to the text run within the artboard
7089     * @returns The text value of the text run, or undefined if not found
7090     *
7091     * @example
7092     * // Get the text value for a text run named "title" at one nested artboard deep
7093     * const titleText = riveInstance.getTextRunValueAtPath("title", "artboard1");
7094     *
7095     * @example
7096     * // Get the text value for a text run named "subtitle" within a nested group two artboards deep
7097     * const subtitleText = riveInstance.getTextRunValueAtPath("subtitle", "group/nestedGroup");
7098     *
7099     * @remarks
7100     * If the text run cannot be found at the specified path, a warning will be logged to the console.
7101     */
7102    Rive.prototype.getTextRunValueAtPath = function (textName, path) {
7103        var run = this.retrieveTextAtPath(textName, path);
7104        if (!run) {
7105            console.warn("Could not get text with name: '".concat(textName, "', at path:'").concat(path, "'"));
7106            return;
7107        }
7108        return run.text;
7109    };
7110    /**
7111     * Sets the text value for a specified text run at a given path
7112     * @param textName The name of the text run
7113     * @param value The new text value to set
7114     * @param path The path to the text run within the artboard
7115     * @returns void
7116     *
7117     * @example
7118     * // Set the text value for a text run named "title" at one nested artboard deep
7119     * riveInstance.setTextRunValueAtPath("title", "New Title", "artboard1");
7120     *
7121     * @example
7122     * // Set the text value for a text run named "subtitle" within a nested group t
vendor: 20,845 bytes, lines 7122-7684
7122wo artboards deep
7123     * riveInstance.setTextRunValueAtPath("subtitle", "New Subtitle", "group/nestedGroup");
7124     *
7125     * @remarks
7126     * If the text run cannot be found at the specified path, a warning will be logged to the console.
7127     */
7128    Rive.prototype.setTextRunValueAtPath = function (textName, value, path) {
7129        var run = this.retrieveTextAtPath(textName, path);
7130        if (!run) {
7131            console.warn("Could not set text with name: '".concat(textName, "', at path:'").concat(path, "'"));
7132            return;
7133        }
7134        run.text = value;
7135    };
7136    Object.defineProperty(Rive.prototype, "playingStateMachineNames", {
7137        // Returns a list of playing machine names
7138        get: function () {
7139            // If the file's not loaded, we got nothing to return
7140            if (!this.loaded) {
7141                return [];
7142            }
7143            return this.animator.stateMachines
7144                .filter(function (m) { return m.playing; })
7145                .map(function (m) { return m.name; });
7146        },
7147        enumerable: false,
7148        configurable: true
7149    });
7150    Object.defineProperty(Rive.prototype, "playingAnimationNames", {
7151        // Returns a list of playing animation names
7152        get: function () {
7153            // If the file's not loaded, we got nothing to return
7154            if (!this.loaded) {
7155                return [];
7156            }
7157            return this.animator.animations.filter(function (a) { return a.playing; }).map(function (a) { return a.name; });
7158        },
7159        enumerable: false,
7160        configurable: true
7161    });
7162    Object.defineProperty(Rive.prototype, "pausedAnimationNames", {
7163        // Returns a list of paused animation names
7164        get: function () {
7165            // If the file's not loaded, we got nothing to return
7166            if (!this.loaded) {
7167                return [];
7168            }
7169            return this.animator.animations
7170                .filter(function (a) { return !a.playing; })
7171                .map(function (a) { return a.name; });
7172        },
7173        enumerable: false,
7174        configurable: true
7175    });
7176    Object.defineProperty(Rive.prototype, "pausedStateMachineNames", {
7177        /**
7178         *  Returns a list of paused machine names
7179         * @returns a list of state machine names that are paused
7180         */
7181        get: function () {
7182            // If the file's not loaded, we got nothing to return
7183            if (!this.loaded) {
7184                return [];
7185            }
7186            return this.animator.stateMachines
7187                .filter(function (m) { return !m.playing; })
7188                .map(function (m) { return m.name; });
7189        },
7190        enumerable: false,
7191        configurable: true
7192    });
7193    Object.defineProperty(Rive.prototype, "isPlaying", {
7194        /**
7195         * @returns true if any animation is playing
7196         */
7197        get: function () {
7198            return this.animator.isPlaying;
7199        },
7200        enumerable: false,
7201        configurable: true
7202    });
7203    Object.defineProperty(Rive.prototype, "isPaused", {
7204        /**
7205         * @returns true if all instanced animations are paused
7206         */
7207        get: function () {
7208            return this.animator.isPaused;
7209        },
7210        enumerable: false,
7211        configurable: true
7212    });
7213    Object.defineProperty(Rive.prototype, "isStopped", {
7214        /**
7215         * @returns true if no animations are playing or paused
7216         */
7217        get: function () {
7218            var _a, _b;
7219            return (_b = (_a = this.animator) === null || _a === void 0 ? void 0 : _a.isStopped) !== null && _b !== void 0 ? _b : true;
7220        },
7221        enumerable: false,
7222        configurable: true
7223    });
7224    Object.defineProperty(Rive.prototype, "bounds", {
7225        /**
7226         * @returns the bounds of the current artboard, or undefined if the artboard
7227         * isn't loaded yet.
7228         */
7229        get: function () {
7230            return this.artboard ? this.artboard.bounds : undefined;
7231        },
7232        enumerable: false,
7233        configurable: true
7234    });
7235    /**
7236     * Subscribe to Rive-generated events
7237     * @param type the type of event to subscribe to
7238     * @param callback callback to fire when the event occurs
7239     */
7240    Rive.prototype.on = function (type, callback) {
7241        this.eventManager.add({
7242            type: type,
7243            callback: callback,
7244        });
7245    };
7246    /**
7247     * Unsubscribes from a Rive-generated event
7248     * @param type the type of event to unsubscribe from
7249     * @param callback the callback to unsubscribe
7250     */
7251    Rive.prototype.off = function (type, callback) {
7252        this.eventManager.remove({
7253            type: type,
7254            callback: callback,
7255        });
7256    };
7257    /**
7258     * Unsubscribes from a Rive-generated event
7259     * @deprecated
7260     * @param callback the callback to unsubscribe from
7261     */
7262    Rive.prototype.unsubscribe = function (type, callback) {
7263        console.warn("This function is deprecated: please use `off()` instead.");
7264        this.off(type, callback);
7265    };
7266    /**
7267     * Unsubscribes all Rive listeners from an event type, or everything if no type is
7268     * given
7269     * @param type the type of event to unsubscribe from, or all types if
7270     * undefined
7271     */
7272    Rive.prototype.removeAllRiveEventListeners = function (type) {
7273        this.eventManager.removeAll(type);
7274    };
7275    /**
7276     * Unsubscribes all listeners from an event type, or everything if no type is
7277     * given
7278     * @deprecated
7279     * @param type the type of event to unsubscribe from, or all types if
7280     * undefined
7281     */
7282    Rive.prototype.unsubscribeAll = function (type) {
7283        console.warn("This function is deprecated: please use `removeAllRiveEventListeners()` instead.");
7284        this.removeAllRiveEventListeners(type);
7285    };
7286    /**
7287     * Stops the rendering loop; this is different from pausing in that it doesn't
7288     * change the state of any animation. It stops rendering from occurring. This
7289     * is designed for situations such as when Rive isn't visible.
7290     *
7291     * The only way to start rendering again is to call `startRendering`.
7292     * Animations that are marked as playing will start from the position that
7293     * they would have been at if rendering had not been stopped.
7294     */
7295    Rive.prototype.stopRendering = function () {
7296        if (this.loaded && this.frameRequestId) {
7297            if (this.runtime.cancelAnimationFrame) {
7298                this.runtime.cancelAnimationFrame(this.frameRequestId);
7299            }
7300            else {
7301                cancelAnimationFrame(this.frameRequestId);
7302            }
7303            this.frameRequestId = null;
7304        }
7305    };
7306    /**
7307     * Starts the rendering loop if it has been previously stopped. If the
7308     * renderer is already active, then this will have zero effect.
7309     */
7310    Rive.prototype.startRendering = function () {
7311        this.drawFrame();
7312    };
7313    Rive.prototype.scheduleRendering = function () {
7314        if (this.loaded && this.artboard && !this.frameRequestId) {
7315            if (this.runtime.requestAnimationFrame) {
7316                this.frameRequestId = this.runtime.requestAnimationFrame(this._boundDraw);
7317            }
7318            else {
7319                this.frameRequestId = requestAnimationFrame(this._boundDraw);
7320            }
7321        }
7322    };
7323    /**
7324     * Enables frames-per-second (FPS) reporting for the runtime
7325     * If no callback is provided, Rive will append a fixed-position div at the top-right corner of
7326     * the page with the FPS reading
7327     * @param fpsCallback - Callback from the runtime during the RAF loop that supplies the FPS value
7328     */
7329    Rive.prototype.enableFPSCounter = function (fpsCallback) {
7330        this.runtime.enableFPSCounter(fpsCallback);
7331    };
7332    /**
7333     * Disables frames-per-second (FPS) reporting for the runtime
7334     */
7335    Rive.prototype.disableFPSCounter = function () {
7336        this.runtime.disableFPSCounter();
7337    };
7338    Object.defineProperty(Rive.prototype, "contents", {
7339        /**
7340         * Returns the contents of a Rive file: the artboards, animations, and state machines
7341         */
7342        get: function () {
7343            if (!this.loaded) {
7344                return undefined;
7345            }
7346            var riveContents = {
7347                artboards: [],
7348            };
7349            for (var i = 0; i < this.file.artboardCount(); i++) {
7350                var artboard = this.file.artboardByIndex(i);
7351                var artboardContents = {
7352                    name: artboard.name,
7353                    animations: [],
7354                    stateMachines: [],
7355                };
7356                for (var j = 0; j < artboard.animationCount(); j++) {
7357                    var animation = artboard.animationByIndex(j);
7358                    artboardContents.animations.push(animation.name);
7359                }
7360                for (var k = 0; k < artboard.stateMachineCount(); k++) {
7361                    var stateMachine = artboard.stateMachineByIndex(k);
7362                    var name_1 = stateMachine.name;
7363                    var instance = new this.runtime.StateMachineInstance(stateMachine, artboard);
7364                    var inputContents = [];
7365                    for (var l = 0; l < instance.inputCount(); l++) {
7366                        var input = instance.input(l);
7367                        inputContents.push({ name: input.name, type: input.type });
7368                    }
7369                    artboardContents.stateMachines.push({
7370                        name: name_1,
7371                        inputs: inputContents,
7372                    });
7373                }
7374                riveContents.artboards.push(artboardContents);
7375            }
7376            return riveContents;
7377        },
7378        enumerable: false,
7379        configurable: true
7380    });
7381    Object.defineProperty(Rive.prototype, "volume", {
7382        /**
7383         * Getter / Setter for the volume of the artboard
7384         */
7385        get: function () {
7386            if (this.artboard && this.artboard.volume !== this._volume) {
7387                this._volume = this.artboard.volume;
7388            }
7389            return this._volume;
7390        },
7391        set: function (value) {
7392            this._volume = value;
7393            if (this.artboard) {
7394                this.artboard.volume = value * audioManager.systemVolume;
7395            }
7396        },
7397        enumerable: false,
7398        configurable: true
7399    });
7400    Object.defineProperty(Rive.prototype, "artboardWidth", {
7401        /**
7402         * The width of the artboard.
7403         *
7404         * This will return 0 if the artboard is not loaded yet and a custom
7405         * width has not been set.
7406         *
7407         * Do not set this value manually when using {@link resizeDrawingSurfaceToCanvas}
7408         * with a {@link Layout.fit} of {@link Fit.Layout}, as the artboard width is
7409         * automatically set.
7410         */
7411        get: function () {
7412            var _a;
7413            if (this.artboard) {
7414                return this.artboard.width;
7415            }
7416            return (_a = this._artboardWidth) !== null && _a !== void 0 ? _a : 0;
7417        },
7418        set: function (value) {
7419            this._artboardWidth = value;
7420            if (this.artboard) {
7421                this.artboard.width = value;
7422            }
7423        },
7424        enumerable: false,
7425        configurable: true
7426    });
7427    Object.defineProperty(Rive.prototype, "artboardHeight", {
7428        /**
7429         * The height of the artboard.
7430         *
7431         * This will return 0 if the artboard is not loaded yet and a custom
7432         * height has not been set.
7433         *
7434         * Do not set this value manually when using {@link resizeDrawingSurfaceToCanvas}
7435         * with a {@link Layout.fit} of {@link Fit.Layout}, as the artboard height is
7436         * automatically set.
7437         */
7438        get: function () {
7439            var _a;
7440            if (this.artboard) {
7441                return this.artboard.height;
7442            }
7443            return (_a = this._artboardHeight) !== null && _a !== void 0 ? _a : 0;
7444        },
7445        set: function (value) {
7446            this._artboardHeight = value;
7447            if (this.artboard) {
7448                this.artboard.height = value;
7449            }
7450        },
7451        enumerable: false,
7452        configurable: true
7453    });
7454    /**
7455     * Reset the artboard size to its original values.
7456     */
7457    Rive.prototype.resetArtboardSize = function () {
7458        if (this.artboard) {
7459            this.artboard.resetArtboardSize();
7460            this._artboardWidth = this.artboard.width;
7461            this._artboardHeight = this.artboard.height;
7462        }
7463        else {
7464            // If the artboard isn't loaded, we need to reset the custom width and height
7465            this._artboardWidth = undefined;
7466            this._artboardHeight = undefined;
7467        }
7468    };
7469    Object.defineProperty(Rive.prototype, "devicePixelRatioUsed", {
7470        /**
7471         * The device pixel ratio used in rendering and canvas/artboard resizing.
7472         *
7473         * This value will be overidden by the device pixel ratio used in
7474         * {@link resizeDrawingSurfaceToCanvas}. If you use that method, do not set this value.
7475         */
7476        get: function () {
7477            return this._devicePixelRatioUsed;
7478        },
7479        set: function (value) {
7480            this._devicePixelRatioUsed = value;
7481        },
7482        enumerable: false,
7483        configurable: true
7484    });
7485    /**
7486     * Initialize the data context with the view model instance.
7487     */
7488    Rive.prototype.bindViewModelInstance = function (viewModelInstance) {
7489        var _a;
7490        if (this.artboard && !this.destroyed) {
7491            if (viewModelInstance && viewModelInstance.runtimeInstance) {
7492                viewModelInstance.internalIncrementReferenceCount();
7493                (_a = this._viewModelInstance) === null || _a === void 0 ? void 0 : _a.cleanup();
7494                this._viewModelInstance = viewModelInstance;
7495                if (this.animator.stateMachines.length > 0) {
7496                    this.animator.stateMachines.forEach(function (stateMachine) {
7497                        return stateMachine.bindViewModelInstance(viewModelInstance);
7498                    });
7499                }
7500                else {
7501                    this.artboard.bindViewModelInstance(viewModelInstance.runtimeInstance);
7502                }
7503            }
7504        }
7505    };
7506    Object.defineProperty(Rive.prototype, "viewModelInstance", {
7507        get: function () {
7508            return this._viewModelInstance;
7509        },
7510        enumerable: false,
7511        configurable: true
7512    });
7513    Rive.prototype.viewModelByIndex = function (index) {
7514        var viewModel = this.file.viewModelByIndex(index);
7515        if (viewModel !== null) {
7516            return new ViewModel(viewModel);
7517        }
7518        return null;
7519    };
7520    Rive.prototype.viewModelByName = function (name) {
7521        var _a;
7522        return (_a = this.riveFile) === null || _a === void 0 ? void 0 : _a.viewModelByName(name);
7523    };
7524    Rive.prototype.enums = function () {
7525        if (this._dataEnums === null) {
7526            var dataEnums = this.file.enums();
7527            this._dataEnums = dataEnums.map(function (dataEnum) {
7528                return new DataEnum(dataEnum);
7529            });
7530        }
7531        return this._dataEnums;
7532    };
7533    Rive.prototype.defaultViewModel = function () {
7534        if (this.artboard) {
7535            var viewModel = this.file.defaultArtboardViewModel(this.artboard);
7536            if (viewModel) {
7537                return new ViewModel(viewModel);
7538            }
7539        }
7540        return null;
7541    };
7542    /**
7543     * @deprecated This function is deprecated. For better stability and memory management
7544     * use `getBindableArtboard()` instead.
7545     * @param {string} name - The name of the artboard.
7546     * @returns {Artboard} The artboard to bind to.
7547     */
7548    Rive.prototype.getArtboard = function (name) {
7549        var _a, _b;
7550        return (_b = (_a = this.riveFile) === null || _a === void 0 ? void 0 : _a.getArtboard(name)) !== null && _b !== void 0 ? _b : null;
7551    };
7552    Rive.prototype.getBindableArtboard = function (name) {
7553        var _a, _b;
7554        return (_b = (_a = this.riveFile) === null || _a === void 0 ? void 0 : _a.getBindableArtboard(name)) !== null && _b !== void 0 ? _b : null;
7555    };
7556    Rive.prototype.getDefaultBindableArtboard = function () {
7557        var _a, _b;
7558        return (_b = (_a = this.riveFile) === null || _a === void 0 ? void 0 : _a.getDefaultBindableArtboard()) !== null && _b !== void 0 ? _b : null;
7559    };
7560    // Error message for missing source or buffer
7561    Rive.missingErrorMessage = "Rive source file or data buffer required";
7562    // Error message for removed rive file
7563    Rive.cleanupErrorMessage = "Attempt to use file after calling cleanup.";
7564    return Rive;
7565}());
7566
7567var DataType;
7568(function (DataType) {
7569    DataType["none"] = "none";
7570    DataType["string"] = "string";
7571    DataType["number"] = "number";
7572    DataType["boolean"] = "boolean";
7573    DataType["color"] = "color";
7574    DataType["list"] = "list";
7575    DataType["enumType"] = "enumType";
7576    DataType["trigger"] = "trigger";
7577    DataType["viewModel"] = "viewModel";
7578    DataType["integer"] = "integer";
7579    DataType["listIndex"] = "listIndex";
7580    DataType["image"] = "image";
7581    DataType["artboard"] = "artboard";
7582})(DataType || (DataType = {}));
7583var ViewModel = /** @class */ (function () {
7584    function ViewModel(viewModel) {
7585        this._viewModel = viewModel;
7586    }
7587    Object.defineProperty(ViewModel.prototype, "instanceCount", {
7588        get: function () {
7589            return this._viewModel.instanceCount;
7590        },
7591        enumerable: false,
7592        configurable: true
7593    });
7594    Object.defineProperty(ViewModel.prototype, "name", {
7595        get: function () {
7596            return this._viewModel.name;
7597        },
7598        enumerable: false,
7599        configurable: true
7600    });
7601    ViewModel.prototype.instanceByIndex = function (index) {
7602        var instance = this._viewModel.instanceByIndex(index);
7603        if (instance !== null) {
7604            var viewModelInstance = new ViewModelInstance(instance, null);
7605            (0,_utils__WEBPACK_IMPORTED_MODULE_2__.createFinalization)(viewModelInstance, instance);
7606            return viewModelInstance;
7607        }
7608        return null;
7609    };
7610    ViewModel.prototype.instanceByName = function (name) {
7611        var instance = this._viewModel.instanceByName(name);
7612        if (instance !== null) {
7613            var viewModelInstance = new ViewModelInstance(instance, null);
7614            (0,_utils__WEBPACK_IMPORTED_MODULE_2__.createFinalization)(viewModelInstance, instance);
7615            return viewModelInstance;
7616        }
7617        return null;
7618    };
7619    ViewModel.prototype.defaultInstance = function () {
7620        var runtimeInstance = this._viewModel.defaultInstance();
7621        if (runtimeInstance !== null) {
7622            var viewModelInstance = new ViewModelInstance(runtimeInstance, null);
7623            (0,_utils__WEBPACK_IMPORTED_MODULE_2__.createFinalization)(viewModelInstance, runtimeInstance);
7624            return viewModelInstance;
7625        }
7626        return null;
7627    };
7628    ViewModel.prototype.instance = function () {
7629        var runtimeInstance = this._viewModel.instance();
7630        if (runtimeInstance !== null) {
7631            var viewModelInstance = new ViewModelInstance(runtimeInstance, null);
7632            (0,_utils__WEBPACK_IMPORTED_MODULE_2__.createFinalization)(viewModelInstance, runtimeInstance);
7633            return viewModelInstance;
7634        }
7635        return null;
7636    };
7637    Object.defineProperty(ViewModel.prototype, "properties", {
7638        get: function () {
7639            return this._viewModel.getProperties();
7640        },
7641        enumerable: false,
7642        configurable: true
7643    });
7644    Object.defineProperty(ViewModel.prototype, "instanceNames", {
7645        get: function () {
7646            return this._viewModel.getInstanceNames();
7647        },
7648        enumerable: false,
7649        configurable: true
7650    });
7651    return ViewModel;
7652}());
7653
7654var DataEnum = /** @class */ (function () {
7655    function DataEnum(dataEnum) {
7656        this._dataEnum = dataEnum;
7657    }
7658    Object.defineProperty(DataEnum.prototype, "name", {
7659        get: function () {
7660            return this._dataEnum.name;
7661        },
7662        enumerable: false,
7663        configurable: true
7664    });
7665    Object.defineProperty(DataEnum.prototype, "values", {
7666        get: function () {
7667            return this._dataEnum.values;
7668        },
7669        enumerable: false,
7670        configurable: true
7671    });
7672    return DataEnum;
7673}());
7674
7675var PropertyType;
7676(function (PropertyType) {
7677    PropertyType["Number"] = "number";
7678    PropertyType["String"] = "string";
7679    PropertyType["Boolean"] = "boolean";
7680    PropertyType["Color"] = "color";
7681    PropertyType["Trigger"] = "trigger";
7682    PropertyType["Enum"] = "enum";
7683    PropertyType["List"] = "list";
7684    PropertyType["Image"] = "image
vendor: 5,425 bytes, lines 7684-7820
7684";
7685    PropertyType["Artboard"] = "artboard";
7686})(PropertyType || (PropertyType = {}));
7687var ViewModelInstance = /** @class */ (function () {
7688    function ViewModelInstance(runtimeInstance, parent) {
7689        this._parents = [];
7690        this._children = [];
7691        this._viewModelInstances = new Map();
7692        this._propertiesWithCallbacks = [];
7693        this._referenceCount = 0;
7694        this.selfUnref = false;
7695        this._runtimeInstance = runtimeInstance;
7696        if (parent !== null) {
7697            this._parents.push(parent);
7698        }
7699    }
7700    Object.defineProperty(ViewModelInstance.prototype, "runtimeInstance", {
7701        get: function () {
7702            return this._runtimeInstance;
7703        },
7704        enumerable: false,
7705        configurable: true
7706    });
7707    Object.defineProperty(ViewModelInstance.prototype, "nativeInstance", {
7708        get: function () {
7709            return this._runtimeInstance;
7710        },
7711        enumerable: false,
7712        configurable: true
7713    });
7714    ViewModelInstance.prototype.handleCallbacks = function () {
7715        if (this._propertiesWithCallbacks.length !== 0) {
7716            this._propertiesWithCallbacks.forEach(function (property) {
7717                property.handleCallbacks();
7718            });
7719            this._propertiesWithCallbacks.forEach(function (property) {
7720                property.clearChanges();
7721            });
7722        }
7723        this._children.forEach(function (child) { return child.handleCallbacks(); });
7724    };
7725    ViewModelInstance.prototype.addParent = function (parent) {
7726        if (!this._parents.includes(parent)) {
7727            this._parents.push(parent);
7728            if (this._propertiesWithCallbacks.length > 0 ||
7729                this._children.length > 0) {
7730                parent.addToViewModelCallbacks(this);
7731            }
7732        }
7733    };
7734    ViewModelInstance.prototype.removeParent = function (parent) {
7735        var index = this._parents.indexOf(parent);
7736        if (index !== -1) {
7737            var parent_1 = this._parents[index];
7738            parent_1.removeFromViewModelCallbacks(this);
7739            this._parents.splice(index, 1);
7740        }
7741    };
7742    /*
7743     * method for internal use, it shouldn't be called externally
7744     */
7745    ViewModelInstance.prototype.addToPropertyCallbacks = function (property) {
7746        var _this = this;
7747        if (!this._propertiesWithCallbacks.includes(property)) {
7748            this._propertiesWithCallbacks.push(property);
7749            if (this._propertiesWithCallbacks.length > 0) {
7750                this._parents.forEach(function (parent) {
7751                    parent.addToViewModelCallbacks(_this);
7752                });
7753            }
7754        }
7755    };
7756    /*
7757     * method for internal use, it shouldn't be called externally
7758     */
7759    ViewModelInstance.prototype.removeFromPropertyCallbacks = function (property) {
7760        var _this = this;
7761        if (this._propertiesWithCallbacks.includes(property)) {
7762            this._propertiesWithCallbacks = this._propertiesWithCallbacks.filter(function (prop) { return prop !== property; });
7763            if (this._children.length === 0 &&
7764                this._propertiesWithCallbacks.length === 0) {
7765                this._parents.forEach(function (parent) {
7766                    parent.removeFromViewModelCallbacks(_this);
7767                });
7768            }
7769        }
7770    };
7771    /*
7772     * method for internal use, it shouldn't be called externally
7773     */
7774    ViewModelInstance.prototype.addToViewModelCallbacks = function (instance) {
7775        var _this = this;
7776        if (!this._children.includes(instance)) {
7777            this._children.push(instance);
7778            this._parents.forEach(function (parent) {
7779                parent.addToViewModelCallbacks(_this);
7780            });
7781        }
7782    };
7783    /*
7784     * method for internal use, it shouldn't be called externally
7785     */
7786    ViewModelInstance.prototype.removeFromViewModelCallbacks = function (instance) {
7787        var _this = this;
7788        if (this._children.includes(instance)) {
7789            this._children = this._children.filter(function (child) { return child !== instance; });
7790            if (this._children.length === 0 &&
7791                this._propertiesWithCallbacks.length === 0) {
7792                this._parents.forEach(function (parent) {
7793                    parent.removeFromViewModelCallbacks(_this);
7794                });
7795            }
7796        }
7797    };
7798    ViewModelInstance.prototype.clearCallbacks = function () {
7799        this._propertiesWithCallbacks.forEach(function (property) {
7800            property.clearCallbacks();
7801        });
7802    };
7803    ViewModelInstance.prototype.propertyFromPath = function (path, type) {
7804        var pathSegments = path.split("/");
7805        return this.propertyFromPathSegments(pathSegments, 0, type);
7806    };
7807    ViewModelInstance.prototype.viewModelFromPathSegments = function (pathSegments, index) {
7808        var viewModelInstance = this.internalViewModelInstance(pathSegments[index]);
7809        if (viewModelInstance !== null) {
7810            if (index == pathSegments.length - 1) {
7811                return viewModelInstance;
7812            }
7813            else {
7814                return viewModelInstance.viewModelFromPathSegments(pathSegments, index++);
7815            }
7816        }
7817        return null;
7818    };
7819    ViewModelInstance.prototype.propertyFromPathSegments = function (pathSegments, index, type) {
7820        var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t
vendor: 7,610 bytes, lines 7820-7973
7820;
7821        if (index < pathSegments.length - 1) {
7822            var viewModelInstance = this.internalViewModelInstance(pathSegments[index]);
7823            if (viewModelInstance !== null) {
7824                return viewModelInstance.propertyFromPathSegments(pathSegments, index + 1, type);
7825            }
7826            else {
7827                return null;
7828            }
7829        }
7830        var instance = null;
7831        switch (type) {
7832            case PropertyType.Number:
7833                instance = (_b = (_a = this._runtimeInstance) === null || _a === void 0 ? void 0 : _a.number(pathSegments[index])) !== null && _b !== void 0 ? _b : null;
7834                if (instance !== null) {
7835                    return new ViewModelInstanceNumber(instance, this);
7836                }
7837                break;
7838            case PropertyType.String:
7839                instance = (_d = (_c = this._runtimeInstance) === null || _c === void 0 ? void 0 : _c.string(pathSegments[index])) !== null && _d !== void 0 ? _d : null;
7840                if (instance !== null) {
7841                    return new ViewModelInstanceString(instance, this);
7842                }
7843                break;
7844            case PropertyType.Boolean:
7845                instance = (_f = (_e = this._runtimeInstance) === null || _e === void 0 ? void 0 : _e.boolean(pathSegments[index])) !== null && _f !== void 0 ? _f : null;
7846                if (instance !== null) {
7847                    return new ViewModelInstanceBoolean(instance, this);
7848                }
7849                break;
7850            case PropertyType.Color:
7851                instance = (_h = (_g = this._runtimeInstance) === null || _g === void 0 ? void 0 : _g.color(pathSegments[index])) !== null && _h !== void 0 ? _h : null;
7852                if (instance !== null) {
7853                    return new ViewModelInstanceColor(instance, this);
7854                }
7855                break;
7856            case PropertyType.Trigger:
7857                instance = (_k = (_j = this._runtimeInstance) === null || _j === void 0 ? void 0 : _j.trigger(pathSegments[index])) !== null && _k !== void 0 ? _k : null;
7858                if (instance !== null) {
7859                    return new ViewModelInstanceTrigger(instance, this);
7860                }
7861                break;
7862            case PropertyType.Enum:
7863                instance = (_m = (_l = this._runtimeInstance) === null || _l === void 0 ? void 0 : _l.enum(pathSegments[index])) !== null && _m !== void 0 ? _m : null;
7864                if (instance !== null) {
7865                    return new ViewModelInstanceEnum(instance, this);
7866                }
7867                break;
7868            case PropertyType.List:
7869                instance = (_p = (_o = this._runtimeInstance) === null || _o === void 0 ? void 0 : _o.list(pathSegments[index])) !== null && _p !== void 0 ? _p : null;
7870                if (instance !== null) {
7871                    return new ViewModelInstanceList(instance, this);
7872                }
7873                break;
7874            case PropertyType.Image:
7875                instance = (_r = (_q = this._runtimeInstance) === null || _q === void 0 ? void 0 : _q.image(pathSegments[index])) !== null && _r !== void 0 ? _r : null;
7876                if (instance !== null) {
7877                    return new ViewModelInstanceAssetImage(instance, this);
7878                }
7879                break;
7880            case PropertyType.Artboard:
7881                instance = (_t = (_s = this._runtimeInstance) === null || _s === void 0 ? void 0 : _s.artboard(pathSegments[index])) !== null && _t !== void 0 ? _t : null;
7882                if (instance !== null) {
7883                    return new ViewModelInstanceArtboard(instance, this);
7884                }
7885                break;
7886        }
7887        return null;
7888    };
7889    ViewModelInstance.prototype.internalViewModelInstance = function (name) {
7890        var _a;
7891        if (this._viewModelInstances.has(name)) {
7892            return this._viewModelInstances.get(name);
7893        }
7894        var viewModelRuntimeInstance = (_a = this._runtimeInstance) === null || _a === void 0 ? void 0 : _a.viewModel(name);
7895        if (viewModelRuntimeInstance !== null) {
7896            var viewModelInstance = new ViewModelInstance(viewModelRuntimeInstance, this);
7897            (0,_utils__WEBPACK_IMPORTED_MODULE_2__.createFinalization)(viewModelInstance, viewModelRuntimeInstance);
7898            viewModelInstance.internalIncrementReferenceCount();
7899            this._viewModelInstances.set(name, viewModelInstance);
7900            return viewModelInstance;
7901        }
7902        return null;
7903    };
7904    /**
7905     * method to access a property instance of type number belonging
7906     * to the view model instance or to a nested view model instance
7907     * @param path - path to the number property
7908     */
7909    ViewModelInstance.prototype.number = function (path) {
7910        var viewmodelInstanceValue = this.propertyFromPath(path, PropertyType.Number);
7911        return viewmodelInstanceValue;
7912    };
7913    /**
7914     * method to access a property instance of type string belonging
7915     * to the view model instance or to a nested view model instance
7916     * @param path - path to the string property
7917     */
7918    ViewModelInstance.prototype.string = function (path) {
7919        var viewmodelInstanceValue = this.propertyFromPath(path, PropertyType.String);
7920        return viewmodelInstanceValue;
7921    };
7922    /**
7923     * method to access a property instance of type boolean belonging
7924     * to the view model instance or to a nested view model instance
7925     * @param path - path to the boolean property
7926     */
7927    ViewModelInstance.prototype.boolean = function (path) {
7928        var viewmodelInstanceValue = this.propertyFromPath(path, PropertyType.Boolean);
7929        return viewmodelInstanceValue;
7930    };
7931    /**
7932     * method to access a property instance of type color belonging
7933     * to the view model instance or to a nested view model instance
7934     * @param path - path to the ttrigger property
7935     */
7936    ViewModelInstance.prototype.color = function (path) {
7937        var viewmodelInstanceValue = this.propertyFromPath(path, PropertyType.Color);
7938        return viewmodelInstanceValue;
7939    };
7940    /**
7941     * method to access a property instance of type trigger belonging
7942     * to the view model instance or to a nested view model instance
7943     * @param path - path to the trigger property
7944     */
7945    ViewModelInstance.prototype.trigger = function (path) {
7946        var viewmodelInstanceValue = this.propertyFromPath(path, PropertyType.Trigger);
7947        return viewmodelInstanceValue;
7948    };
7949    /**
7950     * method to access a property instance of type enum belonging
7951     * to the view model instance or to a nested view model instance
7952     * @param path - path to the enum property
7953     */
7954    ViewModelInstance.prototype.enum = function (path) {
7955        var viewmodelInstanceValue = this.propertyFromPath(path, PropertyType.Enum);
7956        return viewmodelInstanceValue;
7957    };
7958    /**
7959     * method to access a property instance of type list belonging
7960     * to the view model instance or to a nested view model instance
7961     * @param path - path to the list property
7962     */
7963    ViewModelInstance.prototype.list = function (path) {
7964        var viewmodelInstanceValue = this.propertyFromPath(path, PropertyType.List);
7965        return viewmodelInstanceValue;
7966    };
7967    /**
7968     * method to access a view model property instance belonging
7969     * to the view model instance or to a nested view model instance
7970     * @param path - path to the image property
7971     */
7972    ViewModelInstance.prototype.image = function (path) {
7973        var viewmodelInstanceValue = this.propertyFromPath(path, PropertyType.Image
vendor: 13,653 bytes, lines 7973-8314
7973);
7974        return viewmodelInstanceValue;
7975    };
7976    /**
7977     * method to access an artboard property instance belonging
7978     * to the view model instance or to a nested view model instance
7979     * @param path - path to the image property
7980     */
7981    ViewModelInstance.prototype.artboard = function (path) {
7982        var viewmodelInstanceValue = this.propertyFromPath(path, PropertyType.Artboard);
7983        return viewmodelInstanceValue;
7984    };
7985    /**
7986     * method to access a view model property instance belonging
7987     * to the view model instance or to a nested view model instance
7988     * @param path - path to the view model property
7989     */
7990    ViewModelInstance.prototype.viewModel = function (path) {
7991        var pathSegments = path.split("/");
7992        var parentViewModelInstance = pathSegments.length > 1
7993            ? this.viewModelFromPathSegments(pathSegments.slice(0, pathSegments.length - 1), 0)
7994            : this;
7995        if (parentViewModelInstance != null) {
7996            return parentViewModelInstance.internalViewModelInstance(pathSegments[pathSegments.length - 1]);
7997        }
7998        return null;
7999    };
8000    ViewModelInstance.prototype.internalReplaceViewModel = function (name, value) {
8001        var _a;
8002        if (value.runtimeInstance !== null) {
8003            var result = ((_a = this._runtimeInstance) === null || _a === void 0 ? void 0 : _a.replaceViewModel(name, value.runtimeInstance)) ||
8004                false;
8005            if (result) {
8006                value.internalIncrementReferenceCount();
8007                var oldInstance_1 = this.internalViewModelInstance(name);
8008                if (oldInstance_1 !== null) {
8009                    oldInstance_1.removeParent(this);
8010                    if (this._children.includes(oldInstance_1)) {
8011                        this._children = this._children.filter(function (child) { return child !== oldInstance_1; });
8012                    }
8013                    oldInstance_1.cleanup();
8014                }
8015                this._viewModelInstances.set(name, value);
8016                value.addParent(this);
8017            }
8018            return result;
8019        }
8020        return false;
8021    };
8022    /**
8023     * method to replace a view model property with another view model value
8024     * @param path - path to the view model property
8025     * @param value - view model that will replace the original
8026     */
8027    ViewModelInstance.prototype.replaceViewModel = function (path, value) {
8028        var _a;
8029        var pathSegments = path.split("/");
8030        var viewModelInstance = pathSegments.length > 1
8031            ? this.viewModelFromPathSegments(pathSegments.slice(0, pathSegments.length - 1), 0)
8032            : this;
8033        return ((_a = viewModelInstance === null || viewModelInstance === void 0 ? void 0 : viewModelInstance.internalReplaceViewModel(pathSegments[pathSegments.length - 1], value)) !== null && _a !== void 0 ? _a : false);
8034    };
8035    /*
8036     * method to add one to the reference counter of the instance.
8037     * Use if the file owning the reference is destroyed but the instance needs to stay around
8038     */
8039    ViewModelInstance.prototype.incrementReferenceCount = function () {
8040        var _a;
8041        this._referenceCount++;
8042        (_a = this._runtimeInstance) === null || _a === void 0 ? void 0 : _a.incrementReferenceCount();
8043    };
8044    /*
8045     * method to subtract one to the reference counter of the instance.
8046     * Use if incrementReferenceCount has been called
8047     */
8048    ViewModelInstance.prototype.decrementReferenceCount = function () {
8049        var _a;
8050        this._referenceCount--;
8051        (_a = this._runtimeInstance) === null || _a === void 0 ? void 0 : _a.decrementReferenceCount();
8052    };
8053    Object.defineProperty(ViewModelInstance.prototype, "properties", {
8054        get: function () {
8055            var _a;
8056            return (((_a = this._runtimeInstance) === null || _a === void 0 ? void 0 : _a.getProperties().map(function (prop) { return (__assign({}, prop)); })) || []);
8057        },
8058        enumerable: false,
8059        configurable: true
8060    });
8061    Object.defineProperty(ViewModelInstance.prototype, "viewModelName", {
8062        /**
8063         * Get the name of the ViewModel definition this instance was created from.
8064         */
8065        get: function () {
8066            var _a, _b;
8067            return (_b = (_a = this._runtimeInstance) === null || _a === void 0 ? void 0 : _a.getViewModelName()) !== null && _b !== void 0 ? _b : "";
8068        },
8069        enumerable: false,
8070        configurable: true
8071    });
8072    ViewModelInstance.prototype.internalIncrementReferenceCount = function () {
8073        this._referenceCount++;
8074    };
8075    ViewModelInstance.prototype.cleanup = function () {
8076        var _this = this;
8077        var _a;
8078        this._referenceCount--;
8079        if (this._referenceCount <= 0) {
8080            if (this.selfUnref) {
8081                (_a = this._runtimeInstance) === null || _a === void 0 ? void 0 : _a.unref();
8082            }
8083            this._runtimeInstance = null;
8084            this.clearCallbacks();
8085            this._propertiesWithCallbacks = [];
8086            this._viewModelInstances.forEach(function (value) {
8087                value.cleanup();
8088            });
8089            this._viewModelInstances.clear();
8090            var children = __spreadArray([], this._children, true);
8091            this._children.length = 0;
8092            var parents = __spreadArray([], this._parents, true);
8093            this._parents.length = 0;
8094            children.forEach(function (child) {
8095                child.removeParent(_this);
8096            });
8097            parents.forEach(function (parent) {
8098                parent.removeFromViewModelCallbacks(_this);
8099            });
8100        }
8101    };
8102    return ViewModelInstance;
8103}());
8104
8105var ViewModelInstanceValue = /** @class */ (function () {
8106    function ViewModelInstanceValue(instance, parent) {
8107        this.callbacks = [];
8108        this._viewModelInstanceValue = instance;
8109        this._parentViewModel = parent;
8110    }
8111    ViewModelInstanceValue.prototype.on = function (callback) {
8112        // Since we don't clean the changed flag for properties that don't have listeners,
8113        // we clean it the first time we add a listener to it
8114        if (this.callbacks.length === 0) {
8115            this._viewModelInstanceValue.clearChanges();
8116        }
8117        if (!this.callbacks.includes(callback)) {
8118            this.callbacks.push(callback);
8119            this._parentViewModel.addToPropertyCallbacks(this);
8120        }
8121    };
8122    ViewModelInstanceValue.prototype.off = function (callback) {
8123        if (!callback) {
8124            this.callbacks.length = 0;
8125        }
8126        else {
8127            this.callbacks = this.callbacks.filter(function (cb) { return cb !== callback; });
8128        }
8129        if (this.callbacks.length === 0) {
8130            this._parentViewModel.removeFromPropertyCallbacks(this);
8131        }
8132    };
8133    ViewModelInstanceValue.prototype.internalHandleCallback = function (callback) { };
8134    ViewModelInstanceValue.prototype.handleCallbacks = function () {
8135        var _this = this;
8136        if (this._viewModelInstanceValue.hasChanged) {
8137            this.callbacks.forEach(function (callback) {
8138                _this.internalHandleCallback(callback);
8139            });
8140        }
8141    };
8142    ViewModelInstanceValue.prototype.clearChanges = function () {
8143        this._viewModelInstanceValue.clearChanges();
8144    };
8145    ViewModelInstanceValue.prototype.clearCallbacks = function () {
8146        this.callbacks.length = 0;
8147    };
8148    Object.defineProperty(ViewModelInstanceValue.prototype, "name", {
8149        get: function () {
8150            return this._viewModelInstanceValue.name;
8151        },
8152        enumerable: false,
8153        configurable: true
8154    });
8155    return ViewModelInstanceValue;
8156}());
8157
8158var ViewModelInstanceString = /** @class */ (function (_super) {
8159    __extends(ViewModelInstanceString, _super);
8160    function ViewModelInstanceString(instance, parent) {
8161        return _super.call(this, instance, parent) || this;
8162    }
8163    Object.defineProperty(ViewModelInstanceString.prototype, "value", {
8164        get: function () {
8165            return this._viewModelInstanceValue.value;
8166        },
8167        set: function (val) {
8168            this._viewModelInstanceValue.value = val;
8169        },
8170        enumerable: false,
8171        configurable: true
8172    });
8173    ViewModelInstanceString.prototype.internalHandleCallback = function (callback) {
8174        callback(this.value);
8175    };
8176    return ViewModelInstanceString;
8177}(ViewModelInstanceValue));
8178
8179var ViewModelInstanceNumber = /** @class */ (function (_super) {
8180    __extends(ViewModelInstanceNumber, _super);
8181    function ViewModelInstanceNumber(instance, parent) {
8182        return _super.call(this, instance, parent) || this;
8183    }
8184    Object.defineProperty(ViewModelInstanceNumber.prototype, "value", {
8185        get: function () {
8186            return this._viewModelInstanceValue.value;
8187        },
8188        set: function (val) {
8189            this._viewModelInstanceValue.value = val;
8190        },
8191        enumerable: false,
8192        configurable: true
8193    });
8194    ViewModelInstanceNumber.prototype.internalHandleCallback = function (callback) {
8195        callback(this.value);
8196    };
8197    return ViewModelInstanceNumber;
8198}(ViewModelInstanceValue));
8199
8200var ViewModelInstanceBoolean = /** @class */ (function (_super) {
8201    __extends(ViewModelInstanceBoolean, _super);
8202    function ViewModelInstanceBoolean(instance, parent) {
8203        return _super.call(this, instance, parent) || this;
8204    }
8205    Object.defineProperty(ViewModelInstanceBoolean.prototype, "value", {
8206        get: function () {
8207            return this._viewModelInstanceValue.value;
8208        },
8209        set: function (val) {
8210            this._viewModelInstanceValue.value = val;
8211        },
8212        enumerable: false,
8213        configurable: true
8214    });
8215    ViewModelInstanceBoolean.prototype.internalHandleCallback = function (callback) {
8216        callback(this.value);
8217    };
8218    return ViewModelInstanceBoolean;
8219}(ViewModelInstanceValue));
8220
8221var ViewModelInstanceTrigger = /** @class */ (function (_super) {
8222    __extends(ViewModelInstanceTrigger, _super);
8223    function ViewModelInstanceTrigger(instance, parent) {
8224        return _super.call(this, instance, parent) || this;
8225    }
8226    ViewModelInstanceTrigger.prototype.trigger = function () {
8227        return this._viewModelInstanceValue.trigger();
8228    };
8229    ViewModelInstanceTrigger.prototype.internalHandleCallback = function (callback) {
8230        callback();
8231    };
8232    return ViewModelInstanceTrigger;
8233}(ViewModelInstanceValue));
8234
8235var ViewModelInstanceEnum = /** @class */ (function (_super) {
8236    __extends(ViewModelInstanceEnum, _super);
8237    function ViewModelInstanceEnum(instance, parent) {
8238        return _super.call(this, instance, parent) || this;
8239    }
8240    Object.defineProperty(ViewModelInstanceEnum.prototype, "value", {
8241        get: function () {
8242            return this._viewModelInstanceValue.value;
8243        },
8244        set: function (val) {
8245            this._viewModelInstanceValue.value = val;
8246        },
8247        enumerable: false,
8248        configurable: true
8249    });
8250    Object.defineProperty(ViewModelInstanceEnum.prototype, "valueIndex", {
8251        get: function () {
8252            return this._viewModelInstanceValue
8253                .valueIndex;
8254        },
8255        set: function (val) {
8256            this._viewModelInstanceValue.valueIndex = val;
8257        },
8258        enumerable: false,
8259        configurable: true
8260    });
8261    Object.defineProperty(ViewModelInstanceEnum.prototype, "values", {
8262        get: function () {
8263            return this._viewModelInstanceValue.values;
8264        },
8265        enumerable: false,
8266        configurable: true
8267    });
8268    ViewModelInstanceEnum.prototype.internalHandleCallback = function (callback) {
8269        callback(this.value);
8270    };
8271    return ViewModelInstanceEnum;
8272}(ViewModelInstanceValue));
8273
8274var ViewModelInstanceList = /** @class */ (function (_super) {
8275    __extends(ViewModelInstanceList, _super);
8276    function ViewModelInstanceList(instance, parent) {
8277        return _super.call(this, instance, parent) || this;
8278    }
8279    Object.defineProperty(ViewModelInstanceList.prototype, "length", {
8280        get: function () {
8281            return this._viewModelInstanceValue.size;
8282        },
8283        enumerable: false,
8284        configurable: true
8285    });
8286    ViewModelInstanceList.prototype.addInstance = function (instance) {
8287        if (instance.runtimeInstance != null) {
8288            this._viewModelInstanceValue.addInstance(instance.runtimeInstance);
8289            instance.addParent(this._parentViewModel);
8290        }
8291    };
8292    ViewModelInstanceList.prototype.addInstanceAt = function (instance, index) {
8293        if (instance.runtimeInstance != null) {
8294            if (this._viewModelInstanceValue.addInstanceAt(instance.runtimeInstance, index)) {
8295                instance.addParent(this._parentViewModel);
8296                return true;
8297            }
8298        }
8299        return false;
8300    };
8301    ViewModelInstanceList.prototype.removeInstance = function (instance) {
8302        if (instance.runtimeInstance != null) {
8303            this._viewModelInstanceValue.removeInstance(instance.runtimeInstance);
8304            instance.removeParent(this._parentViewModel);
8305        }
8306    };
8307    ViewModelInstanceList.prototype.removeInstanceAt = function (index) {
8308        this._viewModelInstanceValue.removeInstanceAt(index);
8309    };
8310    ViewModelInstanceList.prototype.instanceAt = function (index) {
8311        var runtimeInstance = this._viewModelInstanceValue.instanceAt(index);
8312        if (runtimeInstance != null) {
8313            var viewModelInstance = new ViewModelInstance(runtimeInstance, this._parentViewModel);
8314            (0,_utils__WEBPACK_IMPORTED_MODULE_
vendor: 8,621 bytes, lines 8314-8538
83142__.createFinalization)(viewModelInstance, runtimeInstance);
8315            return viewModelInstance;
8316        }
8317        return null;
8318    };
8319    ViewModelInstanceList.prototype.swap = function (a, b) {
8320        this._viewModelInstanceValue.swap(a, b);
8321    };
8322    ViewModelInstanceList.prototype.internalHandleCallback = function (callback) {
8323        callback();
8324    };
8325    return ViewModelInstanceList;
8326}(ViewModelInstanceValue));
8327
8328var ViewModelInstanceColor = /** @class */ (function (_super) {
8329    __extends(ViewModelInstanceColor, _super);
8330    function ViewModelInstanceColor(instance, parent) {
8331        return _super.call(this, instance, parent) || this;
8332    }
8333    Object.defineProperty(ViewModelInstanceColor.prototype, "value", {
8334        get: function () {
8335            return this._viewModelInstanceValue.value;
8336        },
8337        set: function (val) {
8338            this._viewModelInstanceValue.value = val;
8339        },
8340        enumerable: false,
8341        configurable: true
8342    });
8343    ViewModelInstanceColor.prototype.rgb = function (r, g, b) {
8344        this._viewModelInstanceValue.rgb(r, g, b);
8345    };
8346    ViewModelInstanceColor.prototype.rgba = function (r, g, b, a) {
8347        this._viewModelInstanceValue.argb(a, r, g, b);
8348    };
8349    ViewModelInstanceColor.prototype.argb = function (a, r, g, b) {
8350        this._viewModelInstanceValue.argb(a, r, g, b);
8351    };
8352    // Value 0 to 255
8353    ViewModelInstanceColor.prototype.alpha = function (a) {
8354        this._viewModelInstanceValue.alpha(a);
8355    };
8356    // Value 0 to 1
8357    ViewModelInstanceColor.prototype.opacity = function (o) {
8358        this._viewModelInstanceValue.alpha(Math.round(Math.max(0, Math.min(1, o)) * 255));
8359    };
8360    ViewModelInstanceColor.prototype.internalHandleCallback = function (callback) {
8361        callback(this.value);
8362    };
8363    return ViewModelInstanceColor;
8364}(ViewModelInstanceValue));
8365
8366var ViewModelInstanceAssetImage = /** @class */ (function (_super) {
8367    __extends(ViewModelInstanceAssetImage, _super);
8368    function ViewModelInstanceAssetImage(instance, root) {
8369        return _super.call(this, instance, root) || this;
8370    }
8371    Object.defineProperty(ViewModelInstanceAssetImage.prototype, "value", {
8372        set: function (image) {
8373            var _a;
8374            this._viewModelInstanceValue.value((_a = image === null || image === void 0 ? void 0 : image.nativeImage) !== null && _a !== void 0 ? _a : null);
8375        },
8376        enumerable: false,
8377        configurable: true
8378    });
8379    ViewModelInstanceAssetImage.prototype.internalHandleCallback = function (callback) {
8380        callback();
8381    };
8382    return ViewModelInstanceAssetImage;
8383}(ViewModelInstanceValue));
8384
8385var ViewModelInstanceArtboard = /** @class */ (function (_super) {
8386    __extends(ViewModelInstanceArtboard, _super);
8387    function ViewModelInstanceArtboard(instance, root) {
8388        return _super.call(this, instance, root) || this;
8389    }
8390    Object.defineProperty(ViewModelInstanceArtboard.prototype, "value", {
8391        set: function (artboard) {
8392            var _a, _b;
8393            var bindableArtboard;
8394            if (artboard.isBindableArtboard) {
8395                bindableArtboard = artboard;
8396            }
8397            else {
8398                bindableArtboard = artboard.file.internalBindableArtboardFromArtboard(artboard.nativeArtboard);
8399            }
8400            this._viewModelInstanceValue.value((_a = bindableArtboard === null || bindableArtboard === void 0 ? void 0 : bindableArtboard.nativeArtboard) !== null && _a !== void 0 ? _a : null);
8401            if (bindableArtboard === null || bindableArtboard === void 0 ? void 0 : bindableArtboard.nativeViewModel) {
8402                this._viewModelInstanceValue.viewModelInstance((_b = bindableArtboard === null || bindableArtboard === void 0 ? void 0 : bindableArtboard.nativeViewModel) !== null && _b !== void 0 ? _b : null);
8403            }
8404        },
8405        enumerable: false,
8406        configurable: true
8407    });
8408    ViewModelInstanceArtboard.prototype.internalHandleCallback = function (callback) {
8409        callback();
8410    };
8411    return ViewModelInstanceArtboard;
8412}(ViewModelInstanceValue));
8413
8414// Loads Rive data from a URI via fetch.
8415var loadRiveFile = function (src) { return __awaiter(void 0, void 0, void 0, function () {
8416    var req, res, buffer;
8417    return __generator(this, function (_a) {
8418        switch (_a.label) {
8419            case 0:
8420                req = new Request(src);
8421                return [4 /*yield*/, fetch(req)];
8422            case 1:
8423                res = _a.sent();
8424                return [4 /*yield*/, res.arrayBuffer()];
8425            case 2:
8426                buffer = _a.sent();
8427                return [2 /*return*/, buffer];
8428        }
8429    });
8430}); };
8431// #endregion
8432// #region utility functions
8433/*
8434 * Utility function to ensure an object is a string array
8435 */
8436var mapToStringArray = function (obj) {
8437    if (typeof obj === "string") {
8438        return [obj];
8439    }
8440    else if (obj instanceof Array) {
8441        return obj;
8442    }
8443    // If obj is undefined, return empty array
8444    return [];
8445};
8446// #endregion
8447// #region testing utilities
8448// Exports to only be used for tests
8449var Testing = {
8450    EventManager: EventManager,
8451    TaskQueueManager: TaskQueueManager,
8452};
8453// #endregion
8454// #region asset loaders
8455/**
8456 * Decodes bytes into an audio asset.
8457 *
8458 * Be sure to call `.unref()` on the audio once it is no longer needed. This
8459 * allows the engine to clean it up when it is not used by any more animations.
8460 */
8461var decodeAudio = function (bytes) { return __awaiter(void 0, void 0, void 0, function () {
8462    var decodedPromise, audio, audioWrapper;
8463    return __generator(this, function (_a) {
8464        switch (_a.label) {
8465            case 0:
8466                decodedPromise = new Promise(function (resolve) {
8467                    return _runtimeLoader__WEBPACK_IMPORTED_MODULE_1__.RuntimeLoader.getInstance(function (rive) {
8468                        rive.decodeAudio(bytes, resolve);
8469                    });
8470                });
8471                return [4 /*yield*/, decodedPromise];
8472            case 1:
8473                audio = _a.sent();
8474                audioWrapper = new _utils__WEBPACK_IMPORTED_MODULE_2__.AudioWrapper(audio);
8475                _utils__WEBPACK_IMPORTED_MODULE_2__.finalizationRegistry.register(audioWrapper, audio);
8476                return [2 /*return*/, audioWrapper];
8477        }
8478    });
8479}); };
8480/**
8481 * Decodes bytes into an image.
8482 *
8483 * Be sure to call `.unref()` on the image once it is no longer needed. This
8484 * allows the engine to clean it up when it is not used by any more animations.
8485 */
8486var decodeImage = function (bytes) { return __awaiter(void 0, void 0, void 0, function () {
8487    var decodedPromise, image, imageWrapper;
8488    return __generator(this, function (_a) {
8489        switch (_a.label) {
8490            case 0:
8491                decodedPromise = new Promise(function (resolve) {
8492                    return _runtimeLoader__WEBPACK_IMPORTED_MODULE_1__.RuntimeLoader.getInstance(function (rive) {
8493                        rive.decodeImage(bytes, resolve);
8494                    });
8495                });
8496                return [4 /*yield*/, decodedPromise];
8497            case 1:
8498                image = _a.sent();
8499                imageWrapper = new _utils__WEBPACK_IMPORTED_MODULE_2__.ImageWrapper(image);
8500                _utils__WEBPACK_IMPORTED_MODULE_2__.finalizationRegistry.register(imageWrapper, image);
8501                return [2 /*return*/, imageWrapper];
8502        }
8503    });
8504}); };
8505/**
8506 * Decodes bytes into a font.
8507 *
8508 * Be sure to call `.unref()` on the font once it is no longer needed. This
8509 * allows the engine to clean it up when it is not used by any more animations.
8510 */
8511var decodeFont = function (bytes) { return __awaiter(void 0, void 0, void 0, function () {
8512    var decodedPromise, font, fontWrapper;
8513    return __generator(this, function (_a) {
8514        switch (_a.label) {
8515            case 0:
8516                decodedPromise = new Promise(function (resolve) {
8517                    return _runtimeLoader__WEBPACK_IMPORTED_MODULE_1__.RuntimeLoader.getInstance(function (rive) {
8518                        rive.decodeFont(bytes, resolve);
8519                    });
8520                });
8521                return [4 /*yield*/, decodedPromise];
8522            case 1:
8523                font = _a.sent();
8524                fontWrapper = new _utils__WEBPACK_IMPORTED_MODULE_2__.FontWrapper(font);
8525                _utils__WEBPACK_IMPORTED_MODULE_2__.finalizationRegistry.register(fontWrapper, font);
8526                return [2 /*return*/, fontWrapper];
8527        }
8528    });
8529}); };
8530// #endregion
8531
8532})();
8533
8534/******/ 	return __webpack_exports__;
8535/******/ })()
8536;
8537});
8538//# sourceMappingURL=rive.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.