@vonage/ml-transformers 7.0.1 → 7.0.2-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,14 +1,14 @@
1
- async function is() {
1
+ async function os() {
2
2
  return new Promise(async (r, e) => {
3
- !ss() && (await si() || oi()) ? r() : e(
3
+ !as() && (await ai() || si()) ? r() : e(
4
4
  "Your browser does not support the MediaStreamTrack API for Insertable Streams of Media."
5
5
  );
6
6
  });
7
7
  }
8
- function oi() {
9
- return self.MediaStreamTrackProcessor !== void 0 && self.MediaStreamTrackGenerator !== void 0 || os();
8
+ function si() {
9
+ return self.MediaStreamTrackProcessor !== void 0 && self.MediaStreamTrackGenerator !== void 0 || ss();
10
10
  }
11
- function os() {
11
+ function ss() {
12
12
  return [
13
13
  self.ReadableStream,
14
14
  self.WritableStream,
@@ -19,11 +19,11 @@ function os() {
19
19
  self.AudioWorkletNode
20
20
  ].filter((r) => r === void 0).length === 0;
21
21
  }
22
- function ss() {
22
+ function as() {
23
23
  const r = navigator.userAgent.toLowerCase();
24
24
  return navigator.vendor && navigator.vendor.toLowerCase().indexOf("apple") > -1 && !(r.indexOf("applewebkit") > -1 && r.indexOf("version") === -1) ? parseInt((r.split(" ").find((e) => e.includes("version/")) ?? "/0").split("/")[1]) < 26 : !1;
25
25
  }
26
- function si() {
26
+ function ai() {
27
27
  return new Promise((r) => {
28
28
  function e() {
29
29
  self.postMessage(
@@ -34,10 +34,10 @@ function si() {
34
34
  t.onmessage = ({ data: n }) => r(n);
35
35
  });
36
36
  }
37
- const ee = /* @__PURE__ */ new WeakMap(), me = /* @__PURE__ */ new WeakMap(), q = /* @__PURE__ */ new WeakMap(), Rt = /* @__PURE__ */ Symbol("anyProducer"), Tn = Promise.resolve(), kt = /* @__PURE__ */ Symbol("listenerAdded"), Pt = /* @__PURE__ */ Symbol("listenerRemoved");
37
+ const ee = /* @__PURE__ */ new WeakMap(), me = /* @__PURE__ */ new WeakMap(), q = /* @__PURE__ */ new WeakMap(), kt = /* @__PURE__ */ Symbol("anyProducer"), Tn = Promise.resolve(), Rt = /* @__PURE__ */ Symbol("listenerAdded"), Pt = /* @__PURE__ */ Symbol("listenerRemoved");
38
38
  let Ft = !1, mr = !1;
39
39
  const Ct = (r) => typeof r == "string" || typeof r == "symbol" || typeof r == "number";
40
- function Ae(r) {
40
+ function Te(r) {
41
41
  if (!Ct(r))
42
42
  throw new TypeError("`eventName` must be a string, symbol, or number");
43
43
  }
@@ -45,24 +45,24 @@ function ft(r) {
45
45
  if (typeof r != "function")
46
46
  throw new TypeError("listener must be a function");
47
47
  }
48
- function Te(r, e) {
48
+ function Se(r, e) {
49
49
  const t = me.get(r);
50
50
  if (t.has(e))
51
51
  return t.get(e);
52
52
  }
53
53
  function je(r, e) {
54
- const t = Ct(e) ? e : Rt, n = q.get(r);
54
+ const t = Ct(e) ? e : kt, n = q.get(r);
55
55
  if (n.has(t))
56
56
  return n.get(t);
57
57
  }
58
- function as(r, e, t) {
58
+ function cs(r, e, t) {
59
59
  const n = q.get(r);
60
60
  if (n.has(e))
61
61
  for (const i of n.get(e))
62
62
  i.enqueue(t);
63
- if (n.has(Rt)) {
63
+ if (n.has(kt)) {
64
64
  const i = Promise.all([e, t]);
65
- for (const o of n.get(Rt))
65
+ for (const o of n.get(kt))
66
66
  o.enqueue(i);
67
67
  }
68
68
  }
@@ -106,17 +106,17 @@ function Sn(r, e) {
106
106
  }
107
107
  function In(r) {
108
108
  if (r === void 0)
109
- return Rn;
109
+ return kn;
110
110
  if (!Array.isArray(r))
111
111
  throw new TypeError("`methodNames` must be an array of strings");
112
112
  for (const e of r)
113
- if (!Rn.includes(e))
113
+ if (!kn.includes(e))
114
114
  throw typeof e != "string" ? new TypeError("`methodNames` element must be a string") : new Error(`${e} is not Emittery method`);
115
115
  return r;
116
116
  }
117
- const Me = (r) => r === kt || r === Pt;
117
+ const Be = (r) => r === Rt || r === Pt;
118
118
  function dt(r, e, t) {
119
- if (Me(e))
119
+ if (Be(e))
120
120
  try {
121
121
  Ft = !0, r.emit(e, t);
122
122
  } finally {
@@ -162,7 +162,7 @@ class J {
162
162
  mr = e;
163
163
  }
164
164
  constructor(e = {}) {
165
- ee.set(this, /* @__PURE__ */ new Set()), me.set(this, /* @__PURE__ */ new Map()), q.set(this, /* @__PURE__ */ new Map()), q.get(this).set(Rt, /* @__PURE__ */ new Set()), this.debug = e.debug ?? {}, this.debug.enabled === void 0 && (this.debug.enabled = !1), this.debug.logger || (this.debug.logger = (t, n, i, o) => {
165
+ ee.set(this, /* @__PURE__ */ new Set()), me.set(this, /* @__PURE__ */ new Map()), q.set(this, /* @__PURE__ */ new Map()), q.get(this).set(kt, /* @__PURE__ */ new Set()), this.debug = e.debug ?? {}, this.debug.enabled === void 0 && (this.debug.enabled = !1), this.debug.logger || (this.debug.logger = (t, n, i, o) => {
166
166
  try {
167
167
  o = JSON.stringify(o);
168
168
  } catch {
@@ -180,9 +180,9 @@ class J {
180
180
  on(e, t, { signal: n } = {}) {
181
181
  ft(t), e = Array.isArray(e) ? e : [e];
182
182
  for (const o of e) {
183
- Ae(o);
184
- let s = Te(this, o);
185
- s || (s = /* @__PURE__ */ new Set(), me.get(this).set(o, s)), s.add(t), this.logIfDebugEnabled("subscribe", o, void 0), Me(o) || dt(this, kt, { eventName: o, listener: t });
183
+ Te(o);
184
+ let s = Se(this, o);
185
+ s || (s = /* @__PURE__ */ new Set(), me.get(this).set(o, s)), s.add(t), this.logIfDebugEnabled("subscribe", o, void 0), Be(o) || dt(this, Rt, { eventName: o, listener: t });
186
186
  }
187
187
  const i = () => {
188
188
  this.off(e, t), n?.removeEventListener("abort", i);
@@ -192,9 +192,9 @@ class J {
192
192
  off(e, t) {
193
193
  ft(t), e = Array.isArray(e) ? e : [e];
194
194
  for (const n of e) {
195
- Ae(n);
196
- const i = Te(this, n);
197
- i && (i.delete(t), i.size === 0 && me.get(this).delete(n)), this.logIfDebugEnabled("unsubscribe", n, void 0), Me(n) || dt(this, Pt, { eventName: n, listener: t });
195
+ Te(n);
196
+ const i = Se(this, n);
197
+ i && (i.delete(t), i.size === 0 && me.get(this).delete(n)), this.logIfDebugEnabled("unsubscribe", n, void 0), Be(n) || dt(this, Pt, { eventName: n, listener: t });
198
198
  }
199
199
  }
200
200
  once(e, t) {
@@ -211,14 +211,14 @@ class J {
211
211
  events(e) {
212
212
  e = Array.isArray(e) ? e : [e];
213
213
  for (const t of e)
214
- Ae(t);
214
+ Te(t);
215
215
  return Sn(this, e);
216
216
  }
217
217
  async emit(e, t) {
218
- if (Ae(e), Me(e) && !Ft)
218
+ if (Te(e), Be(e) && !Ft)
219
219
  throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");
220
- this.logIfDebugEnabled("emit", e, t), as(this, e, t);
221
- const n = Te(this, e) ?? /* @__PURE__ */ new Set(), i = ee.get(this), o = [...n], s = Me(e) ? [] : [...i];
220
+ this.logIfDebugEnabled("emit", e, t), cs(this, e, t);
221
+ const n = Se(this, e) ?? /* @__PURE__ */ new Set(), i = ee.get(this), o = [...n], s = Be(e) ? [] : [...i];
222
222
  await Tn, await Promise.all([
223
223
  ...o.map(async (a) => {
224
224
  if (n.has(a))
@@ -231,10 +231,10 @@ class J {
231
231
  ]);
232
232
  }
233
233
  async emitSerial(e, t) {
234
- if (Ae(e), Me(e) && !Ft)
234
+ if (Te(e), Be(e) && !Ft)
235
235
  throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");
236
236
  this.logIfDebugEnabled("emitSerial", e, t);
237
- const n = Te(this, e) ?? /* @__PURE__ */ new Set(), i = ee.get(this), o = [...n], s = [...i];
237
+ const n = Se(this, e) ?? /* @__PURE__ */ new Set(), i = ee.get(this), o = [...n], s = [...i];
238
238
  await Tn;
239
239
  for (const a of o)
240
240
  n.has(a) && await a(t);
@@ -242,7 +242,7 @@ class J {
242
242
  i.has(a) && await a(e, t);
243
243
  }
244
244
  onAny(e, { signal: t } = {}) {
245
- ft(e), this.logIfDebugEnabled("subscribeAny", void 0, void 0), ee.get(this).add(e), dt(this, kt, { listener: e });
245
+ ft(e), this.logIfDebugEnabled("subscribeAny", void 0, void 0), ee.get(this).add(e), dt(this, Rt, { listener: e });
246
246
  const n = () => {
247
247
  this.offAny(e), t?.removeEventListener("abort", n);
248
248
  };
@@ -258,7 +258,7 @@ class J {
258
258
  e = Array.isArray(e) ? e : [e];
259
259
  for (const t of e)
260
260
  if (this.logIfDebugEnabled("clear", t, void 0), Ct(t)) {
261
- const n = Te(this, t);
261
+ const n = Se(this, t);
262
262
  n && n.clear();
263
263
  const i = je(this, t);
264
264
  if (i) {
@@ -282,10 +282,10 @@ class J {
282
282
  let t = 0;
283
283
  for (const n of e) {
284
284
  if (Ct(n)) {
285
- t += ee.get(this).size + (Te(this, n)?.size ?? 0) + (je(this, n)?.size ?? 0) + (je(this)?.size ?? 0);
285
+ t += ee.get(this).size + (Se(this, n)?.size ?? 0) + (je(this, n)?.size ?? 0) + (je(this)?.size ?? 0);
286
286
  continue;
287
287
  }
288
- n !== void 0 && Ae(n), t += ee.get(this).size;
288
+ n !== void 0 && Te(n), t += ee.get(this).size;
289
289
  for (const i of me.get(this).values())
290
290
  t += i.size;
291
291
  for (const i of q.get(this).values())
@@ -307,9 +307,9 @@ class J {
307
307
  }
308
308
  }
309
309
  }
310
- const Rn = Object.getOwnPropertyNames(J.prototype).filter((r) => r !== "constructor");
310
+ const kn = Object.getOwnPropertyNames(J.prototype).filter((r) => r !== "constructor");
311
311
  Object.defineProperty(J, "listenerAdded", {
312
- value: kt,
312
+ value: Rt,
313
313
  writable: !1,
314
314
  enumerable: !0,
315
315
  configurable: !1
@@ -320,30 +320,30 @@ Object.defineProperty(J, "listenerRemoved", {
320
320
  enumerable: !0,
321
321
  configurable: !1
322
322
  });
323
- var cs = Object.defineProperty, us = (r, e, t) => e in r ? cs(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, ls = (r, e, t) => (us(r, e + "", t), t);
324
- const fs = "hlg.tokbox.com/prod/logging/vcp_webrtc", ds = "https://", hs = 1e4;
323
+ var us = Object.defineProperty, ls = (r, e, t) => e in r ? us(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, fs = (r, e, t) => (ls(r, e + "", t), t);
324
+ const ds = "hlg.tokbox.com/prod/logging/vcp_webrtc", hs = "https://", ms = 1e4;
325
325
  let ht;
326
- const ms = new Uint8Array(16);
327
- function ps() {
326
+ const ps = new Uint8Array(16);
327
+ function gs() {
328
328
  if (!ht && (ht = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !ht))
329
329
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
330
- return ht(ms);
330
+ return ht(ps);
331
331
  }
332
332
  const F = [];
333
333
  for (let r = 0; r < 256; ++r)
334
334
  F.push((r + 256).toString(16).slice(1));
335
- function gs(r, e = 0) {
335
+ function ys(r, e = 0) {
336
336
  return (F[r[e + 0]] + F[r[e + 1]] + F[r[e + 2]] + F[r[e + 3]] + "-" + F[r[e + 4]] + F[r[e + 5]] + "-" + F[r[e + 6]] + F[r[e + 7]] + "-" + F[r[e + 8]] + F[r[e + 9]] + "-" + F[r[e + 10]] + F[r[e + 11]] + F[r[e + 12]] + F[r[e + 13]] + F[r[e + 14]] + F[r[e + 15]]).toLowerCase();
337
337
  }
338
- const ys = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), kn = {
339
- randomUUID: ys
338
+ const bs = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Rn = {
339
+ randomUUID: bs
340
340
  };
341
- function bs(r, e, t) {
342
- if (kn.randomUUID && !r)
343
- return kn.randomUUID();
341
+ function ws(r, e, t) {
342
+ if (Rn.randomUUID && !r)
343
+ return Rn.randomUUID();
344
344
  r = r || {};
345
- const n = r.random || (r.rng || ps)();
346
- return n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128, gs(n);
345
+ const n = r.random || (r.rng || gs)();
346
+ return n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128, ys(n);
347
347
  }
348
348
  function Ur(r, e) {
349
349
  globalThis.vonage || (globalThis.vonage = {}), globalThis.vonage.workerizer || (globalThis.vonage.workerizer = {});
@@ -354,13 +354,13 @@ const ie = Ur(
354
354
  "globals",
355
355
  {}
356
356
  );
357
- var ye = /* @__PURE__ */ ((r) => (r.INIT = "INIT", r.FORWARD = "FORWARD", r.TERMINATE = "TERMINATE", r.GLOBALS_SYNC = "GLOBALS_SYNC", r))(ye || {});
358
- function ai(r) {
357
+ var be = /* @__PURE__ */ ((r) => (r.INIT = "INIT", r.FORWARD = "FORWARD", r.TERMINATE = "TERMINATE", r.GLOBALS_SYNC = "GLOBALS_SYNC", r))(be || {});
358
+ function ci(r) {
359
359
  return [ImageBitmap, ReadableStream, WritableStream].some((e) => r instanceof e);
360
360
  }
361
- let ws = 0;
362
- function xs(r, e, t, n, i) {
363
- const o = ws++;
361
+ let xs = 0;
362
+ function vs(r, e, t, n, i) {
363
+ const o = xs++;
364
364
  return r.postMessage(
365
365
  {
366
366
  id: o,
@@ -368,7 +368,7 @@ function xs(r, e, t, n, i) {
368
368
  functionName: t,
369
369
  args: n
370
370
  },
371
- n.filter((s) => ai(s))
371
+ n.filter((s) => ci(s))
372
372
  ), new Promise((s) => {
373
373
  i?.set(o, s);
374
374
  });
@@ -381,24 +381,24 @@ function Ze(r, e) {
381
381
  type: n,
382
382
  result: e
383
383
  },
384
- i.filter((o) => ai(o))
384
+ i.filter((o) => ci(o))
385
385
  );
386
386
  }
387
387
  const Pn = Ur("workerized", {});
388
- function ci() {
388
+ function ui() {
389
389
  return typeof WorkerGlobalScope < "u" && self instanceof WorkerGlobalScope;
390
390
  }
391
- async function vs() {
392
- if (ci())
393
- Ze({ type: ye.GLOBALS_SYNC }, ie);
391
+ async function _s() {
392
+ if (ui())
393
+ Ze({ type: be.GLOBALS_SYNC }, ie);
394
394
  else {
395
395
  const r = [];
396
396
  for (const e in Pn) {
397
397
  const { worker: t, resolvers: n } = Pn[e].workerContext;
398
398
  t && r.push(
399
- xs(
399
+ vs(
400
400
  t,
401
- ye.GLOBALS_SYNC,
401
+ be.GLOBALS_SYNC,
402
402
  "",
403
403
  [ie],
404
404
  n
@@ -417,7 +417,7 @@ function Ot(r, e) {
417
417
  for (const t in r)
418
418
  Array.isArray(r[t]) ? (e[t] = [], Ot(r[t], e[t])) : typeof r[t] == "object" ? (e[t] = {}, Ot(r[t], e[t])) : e[t] = r[t];
419
419
  }
420
- async function _s(r, e) {
420
+ async function Es(r, e) {
421
421
  const { functionName: t, args: n } = r;
422
422
  if (!e.instance)
423
423
  throw "instance not initialized";
@@ -427,78 +427,78 @@ async function _s(r, e) {
427
427
  throw `undefined function [${t}] in class ${e.instance.constructor.workerId}`;
428
428
  Ze(r, await e.instance[t](...n ?? []));
429
429
  }
430
- const Es = Ur("registeredWorkers", {});
431
- function As(r, e) {
430
+ const As = Ur("registeredWorkers", {});
431
+ function Ts(r, e) {
432
432
  if (!r.args)
433
433
  throw "Missing className while initializing worker";
434
- const [t, n] = r.args, i = Es[t];
434
+ const [t, n] = r.args, i = As[t];
435
435
  if (i)
436
436
  e.instance = new i(r.args.slice(1));
437
437
  else
438
438
  throw `unknown worker class ${t}`;
439
439
  Ot(n, ie), Ze(r, typeof e.instance !== void 0);
440
440
  }
441
- async function Ts(r, e) {
441
+ async function Ss(r, e) {
442
442
  const { args: t } = r;
443
443
  if (!e.instance)
444
444
  throw "instance not initialized";
445
445
  let n;
446
446
  e.instance.terminate && (n = await e.instance.terminate(...t ?? [])), Ze(r, n);
447
447
  }
448
- function Ss(r) {
448
+ function Is(r) {
449
449
  if (!r.args)
450
450
  throw "Missing globals while syncing";
451
451
  Ot(r.args[0], ie), Ze(r, {});
452
452
  }
453
- function Is() {
453
+ function ks() {
454
454
  const r = {};
455
455
  onmessage = async (e) => {
456
456
  const t = e.data;
457
457
  switch (t.type) {
458
- case ye.INIT:
459
- As(t, r);
458
+ case be.INIT:
459
+ Ts(t, r);
460
460
  break;
461
- case ye.FORWARD:
462
- _s(t, r);
461
+ case be.FORWARD:
462
+ Es(t, r);
463
463
  break;
464
- case ye.TERMINATE:
465
- Ts(t, r);
464
+ case be.TERMINATE:
465
+ Ss(t, r);
466
466
  break;
467
- case ye.GLOBALS_SYNC:
468
- Ss(t);
467
+ case be.GLOBALS_SYNC:
468
+ Is(t);
469
469
  break;
470
470
  }
471
471
  };
472
472
  }
473
- ci() && Is();
473
+ ui() && ks();
474
474
  function Rs(r, e) {
475
475
  return ie[r] || (ie[r] = e), [
476
476
  () => ie[r],
477
477
  async (t) => {
478
- ie[r] = t, await vs();
478
+ ie[r] = t, await _s();
479
479
  }
480
480
  ];
481
481
  }
482
- function ks(r, e) {
482
+ function Ps(r, e) {
483
483
  return Rs(r, e);
484
484
  }
485
- const [Ps, Fs] = ks("metadata");
486
- function Cs(r) {
487
- Fs(r);
485
+ const [Fs, Cs] = Ps("metadata");
486
+ function Os(r) {
487
+ Cs(r);
488
488
  }
489
489
  function Tt() {
490
- return Ps();
490
+ return Fs();
491
491
  }
492
492
  let Lr = class {
493
493
  constructor(e, t) {
494
- ls(this, "uuid"), this.config = e, this.uuid = t ?? bs();
494
+ fs(this, "uuid"), this.config = e, this.uuid = t ?? ws();
495
495
  }
496
496
  async send(e) {
497
497
  var t, n, i;
498
498
  const { appId: o, sourceType: s } = (t = Tt()) != null ? t : {};
499
499
  if (!o || !s)
500
500
  return "metadata missing";
501
- const a = new AbortController(), c = setTimeout(() => a.abort(), hs);
501
+ const a = new AbortController(), c = setTimeout(() => a.abort(), ms);
502
502
  return await ((i = (n = this.config) == null ? void 0 : n.fetch) != null ? i : fetch)(this.getUrl(), {
503
503
  method: "POST",
504
504
  headers: this.getHeaders(),
@@ -508,8 +508,8 @@ let Lr = class {
508
508
  }
509
509
  getUrl() {
510
510
  var e;
511
- let t = (e = Tt().proxyUrl) != null ? e : ds;
512
- return t += (t.at(-1) === "/" ? "" : "/") + fs, t;
511
+ let t = (e = Tt().proxyUrl) != null ? e : hs;
512
+ return t += (t.at(-1) === "/" ? "" : "/") + ds, t;
513
513
  }
514
514
  getHeaders() {
515
515
  return {
@@ -541,12 +541,12 @@ _r.updates = {
541
541
  readable_null: "Readable is null",
542
542
  writable_null: "Writable is null"
543
543
  };
544
- let be = _r;
545
- function Os(r) {
544
+ let we = _r;
545
+ function Ms(r) {
546
546
  return typeof r == "object" && r !== null && "message" in r && typeof r.message == "string";
547
547
  }
548
- function Ms(r) {
549
- if (Os(r)) return r;
548
+ function Bs(r) {
549
+ if (Ms(r)) return r;
550
550
  try {
551
551
  return new Error(JSON.stringify(r));
552
552
  } catch {
@@ -554,9 +554,9 @@ function Ms(r) {
554
554
  }
555
555
  }
556
556
  function pr(r) {
557
- return Ms(r).message;
557
+ return Bs(r).message;
558
558
  }
559
- class Bs {
559
+ class Ds {
560
560
  constructor(e, t) {
561
561
  this.config = e, this.frameTransformedCount = 0, this.frameFromSourceCount = 0, this.startAt = 0, this.reporter = new Lr(e, t);
562
562
  }
@@ -580,12 +580,12 @@ class Bs {
580
580
  })) : "success";
581
581
  }
582
582
  }
583
- var Ds = /* @__PURE__ */ ((r) => (r.FPS_DROP = "fps_drop", r))(Ds || {}), Us = /* @__PURE__ */ ((r) => (r.start = "start", r.transform = "transform", r.flush = "flush", r))(Us || {}), Er = /* @__PURE__ */ ((r) => (r.pipeline_ended = "pipeline_ended", r.pipeline_ended_with_error = "pipeline_ended_with_error", r.pipeline_started = "pipeline_started", r.pipeline_started_with_error = "pipeline_started_with_error", r.pipeline_restarted = "pipeline_restarted", r.pipeline_restarted_with_error = "pipeline_restarted_with_error", r))(Er || {});
584
- const Ls = 500, zs = 0.8;
585
- class Ns extends J {
583
+ var Us = /* @__PURE__ */ ((r) => (r.FPS_DROP = "fps_drop", r))(Us || {}), Ls = /* @__PURE__ */ ((r) => (r.start = "start", r.transform = "transform", r.flush = "flush", r))(Ls || {}), Er = /* @__PURE__ */ ((r) => (r.pipeline_ended = "pipeline_ended", r.pipeline_ended_with_error = "pipeline_ended_with_error", r.pipeline_started = "pipeline_started", r.pipeline_started_with_error = "pipeline_started_with_error", r.pipeline_restarted = "pipeline_restarted", r.pipeline_restarted_with_error = "pipeline_restarted_with_error", r))(Er || {});
584
+ const zs = 500, Ns = 0.8;
585
+ class $s extends J {
586
586
  constructor(e, t) {
587
- super(), this.reporter_ = new Lr(), this.reporterQos_ = new Bs({
588
- loggingIntervalFrameCount: Ls,
587
+ super(), this.reporter_ = new Lr(), this.reporterQos_ = new Ds({
588
+ loggingIntervalFrameCount: zs,
589
589
  report: {
590
590
  version: St
591
591
  }
@@ -602,7 +602,7 @@ class Ns extends J {
602
602
  await this.transformer_.start(e);
603
603
  } catch (t) {
604
604
  this.report({
605
- message: be.errors.transformer_start,
605
+ message: we.errors.transformer_start,
606
606
  variation: "Error",
607
607
  error: pr(t)
608
608
  });
@@ -624,7 +624,7 @@ class Ns extends J {
624
624
  await this.transformer_.transform?.(e, t), this.reportQos();
625
625
  } catch (n) {
626
626
  this.report({
627
- message: be.errors.transformer_transform,
627
+ message: we.errors.transformer_transform,
628
628
  variation: "Error",
629
629
  error: pr(n)
630
630
  });
@@ -636,7 +636,7 @@ class Ns extends J {
636
636
  };
637
637
  this.emit("error", i);
638
638
  }
639
- if (this.trackExpectedRate_ != -1 && this.trackExpectedRate_ * zs > this.reporterQos_.fps) {
639
+ if (this.trackExpectedRate_ != -1 && this.trackExpectedRate_ * Ns > this.reporterQos_.fps) {
640
640
  const n = {
641
641
  eventMetaData: {
642
642
  transformerIndex: this.index_
@@ -658,7 +658,7 @@ class Ns extends J {
658
658
  await this.transformer_.flush(e);
659
659
  } catch (t) {
660
660
  this.report({
661
- message: be.errors.transformer_flush,
661
+ message: we.errors.transformer_flush,
662
662
  variation: "Error",
663
663
  error: pr(t)
664
664
  });
@@ -701,11 +701,11 @@ class Ns extends J {
701
701
  );
702
702
  }
703
703
  }
704
- class $s extends J {
704
+ class Ws extends J {
705
705
  constructor(e) {
706
706
  super(), this.transformers_ = [], this.trackExpectedRate_ = -1;
707
707
  for (let t = 0; t < e.length; t++) {
708
- let n = new Ns(e[t], t);
708
+ let n = new $s(e[t], t);
709
709
  n.on("error", (i) => {
710
710
  this.emit("error", i);
711
711
  }), n.on("warn", (i) => {
@@ -771,7 +771,7 @@ class $s extends J {
771
771
  e.stop();
772
772
  }
773
773
  }
774
- class ui extends J {
774
+ class li extends J {
775
775
  constructor() {
776
776
  super(), this.reporter_ = new Lr(), this.trackExpectedRate_ = -1, this.report({
777
777
  variation: "Create"
@@ -809,7 +809,7 @@ class ui extends J {
809
809
  return new Promise(async (e, t) => {
810
810
  if (!this.transformers_ || this.transformers_.length === 0) {
811
811
  this.report({
812
- message: be.errors.transformer_none,
812
+ message: we.errors.transformer_none,
813
813
  variation: "Error"
814
814
  }), t("[MediaProcessor] Need to set transformers.");
815
815
  return;
@@ -817,19 +817,19 @@ class ui extends J {
817
817
  if (!this.readable_) {
818
818
  this.report({
819
819
  variation: "Error",
820
- message: be.errors.readable_null
820
+ message: we.errors.readable_null
821
821
  }), t("[MediaProcessor] Readable is null.");
822
822
  return;
823
823
  }
824
824
  if (!this.writable_) {
825
825
  this.report({
826
826
  variation: "Error",
827
- message: be.errors.writable_null
827
+ message: we.errors.writable_null
828
828
  }), t("[MediaProcessor] Writable is null.");
829
829
  return;
830
830
  }
831
831
  let n = !1;
832
- this.pipeline_ && (n = !0, this.pipeline_.clearListeners(), this.pipeline_.destroy()), this.pipeline_ = new $s(this.transformers_), this.pipeline_.on("warn", (i) => {
832
+ this.pipeline_ && (n = !0, this.pipeline_.clearListeners(), this.pipeline_.destroy()), this.pipeline_ = new Ws(this.transformers_), this.pipeline_.on("warn", (i) => {
833
833
  this.emit("warn", i);
834
834
  }), this.pipeline_.on("error", (i) => {
835
835
  this.emit("error", i);
@@ -853,7 +853,7 @@ class ui extends J {
853
853
  setTransformers(e) {
854
854
  return this.report({
855
855
  variation: "Update",
856
- message: be.updates.transformer_new
856
+ message: we.updates.transformer_new
857
857
  }), this.transformers_ = e, this.readable_ && this.writable_ ? this.transformInternal() : Promise.resolve();
858
858
  }
859
859
  /**
@@ -876,7 +876,7 @@ class ui extends J {
876
876
  return "kind" in e;
877
877
  }
878
878
  }
879
- class Ws {
879
+ class Gs {
880
880
  constructor({ kind: e }) {
881
881
  if (e == "video") {
882
882
  const t = document.createElement("canvas"), n = t.getContext("2d", {
@@ -921,10 +921,10 @@ class Ws {
921
921
  }
922
922
  }
923
923
  }
924
- function Gs() {
925
- return self.MediaStreamTrackGenerator ? self.MediaStreamTrackGenerator : Ws;
924
+ function Vs() {
925
+ return self.MediaStreamTrackGenerator ? self.MediaStreamTrackGenerator : Gs;
926
926
  }
927
- class Vs {
927
+ class Hs {
928
928
  constructor(e) {
929
929
  const t = e.track ?? e;
930
930
  t.kind == "video" ? this.readable = new ReadableStream({
@@ -1041,17 +1041,17 @@ class Vs {
1041
1041
  }));
1042
1042
  }
1043
1043
  }
1044
- function Hs() {
1045
- return self.MediaStreamTrackProcessor ? self.MediaStreamTrackProcessor : Vs;
1044
+ function js() {
1045
+ return self.MediaStreamTrackProcessor ? self.MediaStreamTrackProcessor : Hs;
1046
1046
  }
1047
- class js {
1047
+ class Ys {
1048
1048
  constructor() {
1049
1049
  this.processor_ = null, this.generator_ = null;
1050
1050
  }
1051
1051
  init(e) {
1052
1052
  return new Promise((t, n) => {
1053
1053
  try {
1054
- const i = Hs();
1054
+ const i = js();
1055
1055
  this.processor_ = new i(e);
1056
1056
  } catch (i) {
1057
1057
  console.log(
@@ -1059,7 +1059,7 @@ class js {
1059
1059
  ), n(i);
1060
1060
  }
1061
1061
  try {
1062
- const i = Gs();
1062
+ const i = Vs();
1063
1063
  e.kind === "audio" ? this.generator_ = new i({
1064
1064
  kind: "audio"
1065
1065
  }) : e.kind === "video" ? this.generator_ = new i({
@@ -1083,7 +1083,7 @@ class js {
1083
1083
  return this.generator_;
1084
1084
  }
1085
1085
  }
1086
- class Ys {
1086
+ class Qs {
1087
1087
  /**
1088
1088
  * - When running insertable streams on the main `MediaProcessorInterface` should be instance of `MediaProcessor` class.
1089
1089
  * - When running insertable streams on WebWorker `MediaProcessorInterface` should be instance of bridge calss created by the user. Example can be found [here](/docs/intro.md#using-the-transformer-on-webworker)
@@ -1100,13 +1100,13 @@ class Ys {
1100
1100
  * @returns New track to be used.
1101
1101
  */
1102
1102
  async setTrack(e) {
1103
- if (!(this.mediaProcessor_ instanceof ui) && await si()) {
1103
+ if (!(this.mediaProcessor_ instanceof li) && await ai()) {
1104
1104
  if (e.kind === "audio")
1105
1105
  throw Error("Cannot process audio tracks inside a web worker when passing a track to transform");
1106
1106
  return await this.mediaProcessor_.transform(e);
1107
1107
  }
1108
- if (oi()) {
1109
- const t = new js();
1108
+ if (si()) {
1109
+ const t = new Ys();
1110
1110
  return await t.init(e), await this.mediaProcessor_.transform(
1111
1111
  t.getReadable(),
1112
1112
  t.getWriteable()
@@ -1127,10 +1127,10 @@ class Ys {
1127
1127
  });
1128
1128
  }
1129
1129
  }
1130
- var It = /* @__PURE__ */ ((r) => (r.Low = "Low", r.High = "High", r))(It || {}), Qs = /* @__PURE__ */ ((r) => (r.BackgroundBlur = "BackgroundBlur", r.VirtualBackground = "VirtualBackground", r.VideoBackground = "VideoBackground", r.SilhouetteBlur = "SilhouetteBlur", r))(Qs || {}), Ar = /* @__PURE__ */ ((r) => (r.FAST = "FAST", r.PRECISE = "PRECISE", r))(Ar || {}), Mt = /* @__PURE__ */ ((r) => (r.CANVAS = "CANVAS", r.WEBGL = "WEBGL", r))(Mt || {});
1131
- const qs = async () => WebAssembly.validate(new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 5, 1, 96, 0, 1, 123, 3, 2, 1, 0, 10, 10, 1, 8, 0, 65, 0, 253, 15, 253, 98, 11]));
1130
+ var It = /* @__PURE__ */ ((r) => (r.Low = "Low", r.High = "High", r))(It || {}), qs = /* @__PURE__ */ ((r) => (r.BackgroundBlur = "BackgroundBlur", r.VirtualBackground = "VirtualBackground", r.VideoBackground = "VideoBackground", r.SilhouetteBlur = "SilhouetteBlur", r))(qs || {}), Ar = /* @__PURE__ */ ((r) => (r.FAST = "FAST", r.PRECISE = "PRECISE", r))(Ar || {}), Mt = /* @__PURE__ */ ((r) => (r.CANVAS = "CANVAS", r.WEBGL = "WEBGL", r))(Mt || {});
1131
+ const Xs = async () => WebAssembly.validate(new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 5, 1, 96, 0, 1, 123, 3, 2, 1, 0, 10, 10, 1, 8, 0, 65, 0, 253, 15, 253, 98, 11]));
1132
1132
  async function Bd() {
1133
- const { wasm: r, insertableStreams: e, simd: t, webgl: n } = await Xs();
1133
+ const { wasm: r, insertableStreams: e, simd: t, webgl: n } = await Ks();
1134
1134
  if (!r.supported)
1135
1135
  throw r.message;
1136
1136
  if (!e.supported)
@@ -1140,14 +1140,14 @@ async function Bd() {
1140
1140
  if (!n.supported)
1141
1141
  throw n.message;
1142
1142
  }
1143
- async function Xs() {
1143
+ async function Ks() {
1144
1144
  const r = {
1145
1145
  wasm: {
1146
1146
  supported: typeof WebAssembly == "object" && typeof WebAssembly.instantiate == "function",
1147
1147
  message: "Your browser does not support WebAssembly features."
1148
1148
  },
1149
1149
  simd: {
1150
- supported: await qs(),
1150
+ supported: await Xs(),
1151
1151
  message: "Your browser does not support simd features."
1152
1152
  },
1153
1153
  insertableStreams: { supported: !0 },
@@ -1156,17 +1156,17 @@ async function Xs() {
1156
1156
  supported: !0
1157
1157
  // This is a legacy check from the previous segmentation engine. now we just return true always
1158
1158
  },
1159
- webgl: Ks(),
1160
- performance: li()
1159
+ webgl: Js(),
1160
+ performance: fi()
1161
1161
  };
1162
1162
  try {
1163
- await is();
1163
+ await os();
1164
1164
  } catch (e) {
1165
1165
  r.insertableStreams.supported = !1, r.insertableStreams.message = e;
1166
1166
  }
1167
1167
  return r;
1168
1168
  }
1169
- function Ks() {
1169
+ function Js() {
1170
1170
  if (!OffscreenCanvas)
1171
1171
  return {
1172
1172
  supported: !1,
@@ -1183,7 +1183,7 @@ function Ks() {
1183
1183
  };
1184
1184
  return { supported: !0 };
1185
1185
  }
1186
- function li() {
1186
+ function fi() {
1187
1187
  const e = new OffscreenCanvas(0, 0).getContext("webgl2", {
1188
1188
  failIfMajorPerformanceCaveat: !0
1189
1189
  });
@@ -1200,7 +1200,7 @@ function li() {
1200
1200
  const te = /* @__PURE__ */ new WeakMap(), pe = /* @__PURE__ */ new WeakMap(), X = /* @__PURE__ */ new WeakMap(), Bt = /* @__PURE__ */ Symbol("anyProducer"), Fn = Promise.resolve(), Dt = /* @__PURE__ */ Symbol("listenerAdded"), Ut = /* @__PURE__ */ Symbol("listenerRemoved");
1201
1201
  let Lt = !1, gr = !1;
1202
1202
  const zt = (r) => typeof r == "string" || typeof r == "symbol" || typeof r == "number";
1203
- function Se(r) {
1203
+ function Ie(r) {
1204
1204
  if (!zt(r))
1205
1205
  throw new TypeError("`eventName` must be a string, symbol, or number");
1206
1206
  }
@@ -1208,7 +1208,7 @@ function mt(r) {
1208
1208
  if (typeof r != "function")
1209
1209
  throw new TypeError("listener must be a function");
1210
1210
  }
1211
- function Ie(r, e) {
1211
+ function ke(r, e) {
1212
1212
  const t = pe.get(r);
1213
1213
  if (t.has(e))
1214
1214
  return t.get(e);
@@ -1218,7 +1218,7 @@ function Ye(r, e) {
1218
1218
  if (n.has(t))
1219
1219
  return n.get(t);
1220
1220
  }
1221
- function Js(r, e, t) {
1221
+ function Cn(r, e, t) {
1222
1222
  const n = X.get(r);
1223
1223
  if (n.has(e))
1224
1224
  for (const i of n.get(e))
@@ -1229,7 +1229,7 @@ function Js(r, e, t) {
1229
1229
  o.enqueue(i);
1230
1230
  }
1231
1231
  }
1232
- function Cn(r, e) {
1232
+ function On(r, e) {
1233
1233
  e = Array.isArray(e) ? e : [e];
1234
1234
  let t = !1, n = () => {
1235
1235
  }, i = [];
@@ -1267,19 +1267,19 @@ function Cn(r, e) {
1267
1267
  }
1268
1268
  };
1269
1269
  }
1270
- function On(r) {
1270
+ function Mn(r) {
1271
1271
  if (r === void 0)
1272
- return Mn;
1272
+ return Bn;
1273
1273
  if (!Array.isArray(r))
1274
1274
  throw new TypeError("`methodNames` must be an array of strings");
1275
1275
  for (const e of r)
1276
- if (!Mn.includes(e))
1276
+ if (!Bn.includes(e))
1277
1277
  throw typeof e != "string" ? new TypeError("`methodNames` element must be a string") : new Error(`${e} is not Emittery method`);
1278
1278
  return r;
1279
1279
  }
1280
- const Be = (r) => r === Dt || r === Ut;
1280
+ const ge = (r) => r === Dt || r === Ut;
1281
1281
  function pt(r, e, t) {
1282
- if (Be(e))
1282
+ if (ge(e))
1283
1283
  try {
1284
1284
  Lt = !0, r.emit(e, t);
1285
1285
  } finally {
@@ -1288,7 +1288,7 @@ function pt(r, e, t) {
1288
1288
  }
1289
1289
  let et = class Tr {
1290
1290
  static mixin(e, t) {
1291
- return t = On(t), (n) => {
1291
+ return t = Mn(t), (n) => {
1292
1292
  if (typeof n != "function")
1293
1293
  throw new TypeError("`target` must be function");
1294
1294
  for (const s of t)
@@ -1343,9 +1343,9 @@ let et = class Tr {
1343
1343
  on(e, t, { signal: n } = {}) {
1344
1344
  mt(t), e = Array.isArray(e) ? e : [e];
1345
1345
  for (const o of e) {
1346
- Se(o);
1347
- let s = Ie(this, o);
1348
- s || (s = /* @__PURE__ */ new Set(), pe.get(this).set(o, s)), s.add(t), this.logIfDebugEnabled("subscribe", o, void 0), Be(o) || pt(this, Dt, { eventName: o, listener: t });
1346
+ Ie(o);
1347
+ let s = ke(this, o);
1348
+ s || (s = /* @__PURE__ */ new Set(), pe.get(this).set(o, s)), s.add(t), this.logIfDebugEnabled("subscribe", o, void 0), ge(o) || pt(this, Dt, { eventName: o, listener: t });
1349
1349
  }
1350
1350
  const i = () => {
1351
1351
  this.off(e, t), n?.removeEventListener("abort", i);
@@ -1355,9 +1355,9 @@ let et = class Tr {
1355
1355
  off(e, t) {
1356
1356
  mt(t), e = Array.isArray(e) ? e : [e];
1357
1357
  for (const n of e) {
1358
- Se(n);
1359
- const i = Ie(this, n);
1360
- i && (i.delete(t), i.size === 0 && pe.get(this).delete(n)), this.logIfDebugEnabled("unsubscribe", n, void 0), Be(n) || pt(this, Ut, { eventName: n, listener: t });
1358
+ Ie(n);
1359
+ const i = ke(this, n);
1360
+ i && (i.delete(t), i.size === 0 && pe.get(this).delete(n)), this.logIfDebugEnabled("unsubscribe", n, void 0), ge(n) || pt(this, Ut, { eventName: n, listener: t });
1361
1361
  }
1362
1362
  }
1363
1363
  once(e, t) {
@@ -1374,14 +1374,14 @@ let et = class Tr {
1374
1374
  events(e) {
1375
1375
  e = Array.isArray(e) ? e : [e];
1376
1376
  for (const t of e)
1377
- Se(t);
1378
- return Cn(this, e);
1377
+ Ie(t);
1378
+ return On(this, e);
1379
1379
  }
1380
1380
  async emit(e, t) {
1381
- if (Se(e), Be(e) && !Lt)
1381
+ if (Ie(e), ge(e) && !Lt)
1382
1382
  throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");
1383
- this.logIfDebugEnabled("emit", e, t), Js(this, e, t);
1384
- const n = Ie(this, e) ?? /* @__PURE__ */ new Set(), i = te.get(this), o = [...n], s = Be(e) ? [] : [...i];
1383
+ this.logIfDebugEnabled("emit", e, t), Cn(this, e, t);
1384
+ const n = ke(this, e) ?? /* @__PURE__ */ new Set(), i = te.get(this), o = [...n], s = ge(e) ? [] : [...i];
1385
1385
  await Fn, await Promise.all([
1386
1386
  ...o.map(async (a) => {
1387
1387
  if (n.has(a))
@@ -1394,10 +1394,10 @@ let et = class Tr {
1394
1394
  ]);
1395
1395
  }
1396
1396
  async emitSerial(e, t) {
1397
- if (Se(e), Be(e) && !Lt)
1397
+ if (Ie(e), ge(e) && !Lt)
1398
1398
  throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");
1399
- this.logIfDebugEnabled("emitSerial", e, t);
1400
- const n = Ie(this, e) ?? /* @__PURE__ */ new Set(), i = te.get(this), o = [...n], s = [...i];
1399
+ this.logIfDebugEnabled("emitSerial", e, t), Cn(this, e, t);
1400
+ const n = ke(this, e) ?? /* @__PURE__ */ new Set(), i = te.get(this), o = [...n], s = ge(e) ? [] : [...i];
1401
1401
  await Fn;
1402
1402
  for (const a of o)
1403
1403
  n.has(a) && await a(t);
@@ -1412,7 +1412,7 @@ let et = class Tr {
1412
1412
  return t?.addEventListener("abort", n, { once: !0 }), t?.aborted && n(), n;
1413
1413
  }
1414
1414
  anyEvent() {
1415
- return Cn(this);
1415
+ return On(this);
1416
1416
  }
1417
1417
  offAny(e) {
1418
1418
  mt(e), this.logIfDebugEnabled("unsubscribeAny", void 0, void 0), pt(this, Ut, { listener: e }), te.get(this).delete(e);
@@ -1421,7 +1421,7 @@ let et = class Tr {
1421
1421
  e = Array.isArray(e) ? e : [e];
1422
1422
  for (const t of e)
1423
1423
  if (this.logIfDebugEnabled("clear", t, void 0), zt(t)) {
1424
- const n = Ie(this, t);
1424
+ const n = ke(this, t);
1425
1425
  n && n.clear();
1426
1426
  const i = Ye(this, t);
1427
1427
  if (i) {
@@ -1445,10 +1445,10 @@ let et = class Tr {
1445
1445
  let t = 0;
1446
1446
  for (const n of e) {
1447
1447
  if (zt(n)) {
1448
- t += te.get(this).size + (Ie(this, n)?.size ?? 0) + (Ye(this, n)?.size ?? 0) + (Ye(this)?.size ?? 0);
1448
+ t += te.get(this).size + (ke(this, n)?.size ?? 0) + (Ye(this, n)?.size ?? 0) + (Ye(this)?.size ?? 0);
1449
1449
  continue;
1450
1450
  }
1451
- n !== void 0 && Se(n), t += te.get(this).size;
1451
+ n !== void 0 && Ie(n), t += te.get(this).size;
1452
1452
  for (const i of pe.get(this).values())
1453
1453
  t += i.size;
1454
1454
  for (const i of X.get(this).values())
@@ -1459,7 +1459,7 @@ let et = class Tr {
1459
1459
  bindMethods(e, t) {
1460
1460
  if (typeof e != "object" || e === null)
1461
1461
  throw new TypeError("`target` must be an object");
1462
- t = On(t);
1462
+ t = Mn(t);
1463
1463
  for (const n of t) {
1464
1464
  if (e[n] !== void 0)
1465
1465
  throw new Error(`The property \`${n}\` already exists on \`target\``);
@@ -1470,7 +1470,7 @@ let et = class Tr {
1470
1470
  }
1471
1471
  }
1472
1472
  };
1473
- const Mn = Object.getOwnPropertyNames(et.prototype).filter((r) => r !== "constructor");
1473
+ const Bn = Object.getOwnPropertyNames(et.prototype).filter((r) => r !== "constructor");
1474
1474
  Object.defineProperty(et, "listenerAdded", {
1475
1475
  value: Dt,
1476
1476
  writable: !1,
@@ -1493,7 +1493,7 @@ const Le = zr(
1493
1493
  {}
1494
1494
  );
1495
1495
  var z = /* @__PURE__ */ ((r) => (r.INIT = "INIT", r.FORWARD = "FORWARD", r.TERMINATE = "TERMINATE", r.GLOBALS_SYNC = "GLOBALS_SYNC", r.EVENT = "EVENT", r))(z || {});
1496
- function fi(r) {
1496
+ function di(r) {
1497
1497
  return [ImageBitmap, ReadableStream, WritableStream].some((t) => r instanceof t);
1498
1498
  }
1499
1499
  let Zs = 0;
@@ -1506,7 +1506,7 @@ function Nt(r, e, t, n, i) {
1506
1506
  functionName: t,
1507
1507
  args: n
1508
1508
  },
1509
- n.filter((a) => fi(a))
1509
+ n.filter((a) => di(a))
1510
1510
  ), new Promise((a) => {
1511
1511
  i?.set(o, a);
1512
1512
  });
@@ -1519,7 +1519,7 @@ function ze(r, e) {
1519
1519
  type: n,
1520
1520
  result: e
1521
1521
  },
1522
- i.filter((o) => fi(o))
1522
+ i.filter((o) => di(o))
1523
1523
  );
1524
1524
  }
1525
1525
  const $t = zr("workerized", {});
@@ -1585,7 +1585,7 @@ async function ta(r, e, t, n) {
1585
1585
  throw "Failed to instantiate workerized class";
1586
1586
  return i;
1587
1587
  }
1588
- const re = /* @__PURE__ */ new WeakMap(), ge = /* @__PURE__ */ new WeakMap(), K = /* @__PURE__ */ new WeakMap(), Wt = /* @__PURE__ */ Symbol("anyProducer"), Bn = Promise.resolve(), Gt = /* @__PURE__ */ Symbol("listenerAdded"), Vt = /* @__PURE__ */ Symbol("listenerRemoved");
1588
+ const re = /* @__PURE__ */ new WeakMap(), ye = /* @__PURE__ */ new WeakMap(), K = /* @__PURE__ */ new WeakMap(), Wt = /* @__PURE__ */ Symbol("anyProducer"), Dn = Promise.resolve(), Gt = /* @__PURE__ */ Symbol("listenerAdded"), Vt = /* @__PURE__ */ Symbol("listenerRemoved");
1589
1589
  let Ht = !1, yr = !1;
1590
1590
  function Re(r) {
1591
1591
  if (typeof r != "string" && typeof r != "symbol" && typeof r != "number")
@@ -1595,8 +1595,8 @@ function gt(r) {
1595
1595
  if (typeof r != "function")
1596
1596
  throw new TypeError("listener must be a function");
1597
1597
  }
1598
- function ke(r, e) {
1599
- const t = ge.get(r);
1598
+ function Pe(r, e) {
1599
+ const t = ye.get(r);
1600
1600
  if (t.has(e))
1601
1601
  return t.get(e);
1602
1602
  }
@@ -1616,7 +1616,7 @@ function ra(r, e, t) {
1616
1616
  o.enqueue(i);
1617
1617
  }
1618
1618
  }
1619
- function Dn(r, e) {
1619
+ function Un(r, e) {
1620
1620
  e = Array.isArray(e) ? e : [e];
1621
1621
  let t = !1, n = () => {
1622
1622
  }, i = [];
@@ -1654,13 +1654,13 @@ function Dn(r, e) {
1654
1654
  }
1655
1655
  };
1656
1656
  }
1657
- function Un(r) {
1657
+ function Ln(r) {
1658
1658
  if (r === void 0)
1659
- return Ln;
1659
+ return zn;
1660
1660
  if (!Array.isArray(r))
1661
1661
  throw new TypeError("`methodNames` must be an array of strings");
1662
1662
  for (const e of r)
1663
- if (!Ln.includes(e))
1663
+ if (!zn.includes(e))
1664
1664
  throw typeof e != "string" ? new TypeError("`methodNames` element must be a string") : new Error(`${e} is not Emittery method`);
1665
1665
  return r;
1666
1666
  }
@@ -1673,9 +1673,9 @@ function yt(r, e, t) {
1673
1673
  Ht = !1;
1674
1674
  }
1675
1675
  }
1676
- class ve {
1676
+ class _e {
1677
1677
  static mixin(e, t) {
1678
- return t = Un(t), (n) => {
1678
+ return t = Ln(t), (n) => {
1679
1679
  if (typeof n != "function")
1680
1680
  throw new TypeError("`target` must be function");
1681
1681
  for (const s of t)
@@ -1684,7 +1684,7 @@ class ve {
1684
1684
  function i() {
1685
1685
  return Object.defineProperty(this, e, {
1686
1686
  enumerable: !1,
1687
- value: new ve()
1687
+ value: new _e()
1688
1688
  }), this[e];
1689
1689
  }
1690
1690
  Object.defineProperty(n.prototype, e, {
@@ -1714,7 +1714,7 @@ class ve {
1714
1714
  }
1715
1715
  constructor(e = {}) {
1716
1716
  var t;
1717
- re.set(this, /* @__PURE__ */ new Set()), ge.set(this, /* @__PURE__ */ new Map()), K.set(this, /* @__PURE__ */ new Map()), K.get(this).set(Wt, /* @__PURE__ */ new Set()), this.debug = (t = e.debug) != null ? t : {}, this.debug.enabled === void 0 && (this.debug.enabled = !1), this.debug.logger || (this.debug.logger = (n, i, o, s) => {
1717
+ re.set(this, /* @__PURE__ */ new Set()), ye.set(this, /* @__PURE__ */ new Map()), K.set(this, /* @__PURE__ */ new Map()), K.get(this).set(Wt, /* @__PURE__ */ new Set()), this.debug = (t = e.debug) != null ? t : {}, this.debug.enabled === void 0 && (this.debug.enabled = !1), this.debug.logger || (this.debug.logger = (n, i, o, s) => {
1718
1718
  try {
1719
1719
  s = JSON.stringify(s);
1720
1720
  } catch {
@@ -1727,14 +1727,14 @@ class ve {
1727
1727
  });
1728
1728
  }
1729
1729
  logIfDebugEnabled(e, t, n) {
1730
- (ve.isDebugEnabled || this.debug.enabled) && this.debug.logger(e, this.debug.name, t, n);
1730
+ (_e.isDebugEnabled || this.debug.enabled) && this.debug.logger(e, this.debug.name, t, n);
1731
1731
  }
1732
1732
  on(e, t) {
1733
1733
  gt(t), e = Array.isArray(e) ? e : [e];
1734
1734
  for (const n of e) {
1735
1735
  Re(n);
1736
- let i = ke(this, n);
1737
- i || (i = /* @__PURE__ */ new Set(), ge.get(this).set(n, i)), i.add(t), this.logIfDebugEnabled("subscribe", n, void 0), De(n) || yt(this, Gt, { eventName: n, listener: t });
1736
+ let i = Pe(this, n);
1737
+ i || (i = /* @__PURE__ */ new Set(), ye.get(this).set(n, i)), i.add(t), this.logIfDebugEnabled("subscribe", n, void 0), De(n) || yt(this, Gt, { eventName: n, listener: t });
1738
1738
  }
1739
1739
  return this.off.bind(this, e, t);
1740
1740
  }
@@ -1742,8 +1742,8 @@ class ve {
1742
1742
  gt(t), e = Array.isArray(e) ? e : [e];
1743
1743
  for (const n of e) {
1744
1744
  Re(n);
1745
- const i = ke(this, n);
1746
- i && (i.delete(t), i.size === 0 && ge.get(this).delete(n)), this.logIfDebugEnabled("unsubscribe", n, void 0), De(n) || yt(this, Vt, { eventName: n, listener: t });
1745
+ const i = Pe(this, n);
1746
+ i && (i.delete(t), i.size === 0 && ye.get(this).delete(n)), this.logIfDebugEnabled("unsubscribe", n, void 0), De(n) || yt(this, Vt, { eventName: n, listener: t });
1747
1747
  }
1748
1748
  }
1749
1749
  once(e) {
@@ -1759,15 +1759,15 @@ class ve {
1759
1759
  e = Array.isArray(e) ? e : [e];
1760
1760
  for (const t of e)
1761
1761
  Re(t);
1762
- return Dn(this, e);
1762
+ return Un(this, e);
1763
1763
  }
1764
1764
  async emit(e, t) {
1765
1765
  var n;
1766
1766
  if (Re(e), De(e) && !Ht)
1767
1767
  throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");
1768
1768
  this.logIfDebugEnabled("emit", e, t), ra(this, e, t);
1769
- const i = (n = ke(this, e)) != null ? n : /* @__PURE__ */ new Set(), o = re.get(this), s = [...i], a = De(e) ? [] : [...o];
1770
- await Bn, await Promise.all([
1769
+ const i = (n = Pe(this, e)) != null ? n : /* @__PURE__ */ new Set(), o = re.get(this), s = [...i], a = De(e) ? [] : [...o];
1770
+ await Dn, await Promise.all([
1771
1771
  ...s.map(async (c) => {
1772
1772
  if (i.has(c))
1773
1773
  return c(t);
@@ -1783,8 +1783,8 @@ class ve {
1783
1783
  if (Re(e), De(e) && !Ht)
1784
1784
  throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");
1785
1785
  this.logIfDebugEnabled("emitSerial", e, t);
1786
- const i = (n = ke(this, e)) != null ? n : /* @__PURE__ */ new Set(), o = re.get(this), s = [...i], a = [...o];
1787
- await Bn;
1786
+ const i = (n = Pe(this, e)) != null ? n : /* @__PURE__ */ new Set(), o = re.get(this), s = [...i], a = [...o];
1787
+ await Dn;
1788
1788
  for (const c of s)
1789
1789
  i.has(c) && await c(t);
1790
1790
  for (const c of a)
@@ -1794,7 +1794,7 @@ class ve {
1794
1794
  return gt(e), this.logIfDebugEnabled("subscribeAny", void 0, void 0), re.get(this).add(e), yt(this, Gt, { listener: e }), this.offAny.bind(this, e);
1795
1795
  }
1796
1796
  anyEvent() {
1797
- return Dn(this);
1797
+ return Un(this);
1798
1798
  }
1799
1799
  offAny(e) {
1800
1800
  gt(e), this.logIfDebugEnabled("unsubscribeAny", void 0, void 0), yt(this, Vt, { listener: e }), re.get(this).delete(e);
@@ -1803,7 +1803,7 @@ class ve {
1803
1803
  e = Array.isArray(e) ? e : [e];
1804
1804
  for (const t of e)
1805
1805
  if (this.logIfDebugEnabled("clear", t, void 0), typeof t == "string" || typeof t == "symbol" || typeof t == "number") {
1806
- const n = ke(this, t);
1806
+ const n = Pe(this, t);
1807
1807
  n && n.clear();
1808
1808
  const i = Qe(this, t);
1809
1809
  if (i) {
@@ -1813,8 +1813,8 @@ class ve {
1813
1813
  }
1814
1814
  } else {
1815
1815
  re.get(this).clear();
1816
- for (const [n, i] of ge.get(this).entries())
1817
- i.clear(), ge.get(this).delete(n);
1816
+ for (const [n, i] of ye.get(this).entries())
1817
+ i.clear(), ye.get(this).delete(n);
1818
1818
  for (const [n, i] of K.get(this).entries()) {
1819
1819
  for (const o of i)
1820
1820
  o.finish();
@@ -1828,11 +1828,11 @@ class ve {
1828
1828
  let c = 0;
1829
1829
  for (const u of e) {
1830
1830
  if (typeof u == "string") {
1831
- c += re.get(this).size + ((n = (t = ke(this, u)) == null ? void 0 : t.size) != null ? n : 0) + ((o = (i = Qe(this, u)) == null ? void 0 : i.size) != null ? o : 0) + ((a = (s = Qe(this)) == null ? void 0 : s.size) != null ? a : 0);
1831
+ c += re.get(this).size + ((n = (t = Pe(this, u)) == null ? void 0 : t.size) != null ? n : 0) + ((o = (i = Qe(this, u)) == null ? void 0 : i.size) != null ? o : 0) + ((a = (s = Qe(this)) == null ? void 0 : s.size) != null ? a : 0);
1832
1832
  continue;
1833
1833
  }
1834
1834
  typeof u < "u" && Re(u), c += re.get(this).size;
1835
- for (const f of ge.get(this).values())
1835
+ for (const f of ye.get(this).values())
1836
1836
  c += f.size;
1837
1837
  for (const f of K.get(this).values())
1838
1838
  c += f.size;
@@ -1842,7 +1842,7 @@ class ve {
1842
1842
  bindMethods(e, t) {
1843
1843
  if (typeof e != "object" || e === null)
1844
1844
  throw new TypeError("`target` must be an object");
1845
- t = Un(t);
1845
+ t = Ln(t);
1846
1846
  for (const n of t) {
1847
1847
  if (e[n] !== void 0)
1848
1848
  throw new Error(`The property \`${n}\` already exists on \`target\``);
@@ -1853,14 +1853,14 @@ class ve {
1853
1853
  }
1854
1854
  }
1855
1855
  }
1856
- const Ln = Object.getOwnPropertyNames(ve.prototype).filter((r) => r !== "constructor");
1857
- Object.defineProperty(ve, "listenerAdded", {
1856
+ const zn = Object.getOwnPropertyNames(_e.prototype).filter((r) => r !== "constructor");
1857
+ Object.defineProperty(_e, "listenerAdded", {
1858
1858
  value: Gt,
1859
1859
  writable: !1,
1860
1860
  enumerable: !0,
1861
1861
  configurable: !1
1862
1862
  });
1863
- Object.defineProperty(ve, "listenerRemoved", {
1863
+ Object.defineProperty(_e, "listenerRemoved", {
1864
1864
  value: Vt,
1865
1865
  writable: !1,
1866
1866
  enumerable: !0,
@@ -1874,7 +1874,7 @@ function ia(r) {
1874
1874
  }
1875
1875
  let oa = 0;
1876
1876
  async function sa(r, e, t) {
1877
- const i = ia(r) ? new ve() : {}, o = oa++;
1877
+ const i = ia(r) ? new _e() : {}, o = oa++;
1878
1878
  return Object.getOwnPropertyNames(r.prototype).forEach(
1879
1879
  (s) => {
1880
1880
  i[s] = (...a) => Nt(e, z.FORWARD, s, a, t);
@@ -1921,14 +1921,14 @@ async function ca(r, e) {
1921
1921
  throw `undefined function [${t}] in class ${e.instance.constructor.workerId}`;
1922
1922
  ze(r, await e.instance[t](...n ?? []));
1923
1923
  }
1924
- const di = zr("registeredWorkers", {});
1924
+ const hi = zr("registeredWorkers", {});
1925
1925
  function ua(r, e) {
1926
- e.workerId = r, Nr() && (di[e.workerId] = e);
1926
+ e.workerId = r, Nr() && (hi[e.workerId] = e);
1927
1927
  }
1928
1928
  function la(r, e) {
1929
1929
  if (!r.args)
1930
1930
  throw "Missing className while initializing worker";
1931
- const [t, n] = r.args, i = di[t];
1931
+ const [t, n] = r.args, i = hi[t];
1932
1932
  if (i)
1933
1933
  e.instance = new i(r.args.slice(1));
1934
1934
  else
@@ -1975,7 +1975,7 @@ function ha() {
1975
1975
  };
1976
1976
  }
1977
1977
  Nr() && ha();
1978
- class zn {
1978
+ class Nn {
1979
1979
  static async createVideoReadable(e) {
1980
1980
  return new Promise((t, n) => {
1981
1981
  const i = document.createElement("video");
@@ -2024,12 +2024,12 @@ for (let r = 0; r < 256; ++r)
2024
2024
  function _a(r, e = 0) {
2025
2025
  return (C[r[e + 0]] + C[r[e + 1]] + C[r[e + 2]] + C[r[e + 3]] + "-" + C[r[e + 4]] + C[r[e + 5]] + "-" + C[r[e + 6]] + C[r[e + 7]] + "-" + C[r[e + 8]] + C[r[e + 9]] + "-" + C[r[e + 10]] + C[r[e + 11]] + C[r[e + 12]] + C[r[e + 13]] + C[r[e + 14]] + C[r[e + 15]]).toLowerCase();
2026
2026
  }
2027
- const Ea = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Nn = {
2027
+ const Ea = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), $n = {
2028
2028
  randomUUID: Ea
2029
2029
  };
2030
2030
  function Aa(r, e, t) {
2031
- if (Nn.randomUUID && !e && !r)
2032
- return Nn.randomUUID();
2031
+ if ($n.randomUUID && !e && !r)
2032
+ return $n.randomUUID();
2033
2033
  r = r || {};
2034
2034
  const n = r.random || (r.rng || va)();
2035
2035
  return n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128, _a(n);
@@ -2043,8 +2043,8 @@ const oe = $r(
2043
2043
  "globals",
2044
2044
  {}
2045
2045
  );
2046
- var we = /* @__PURE__ */ ((r) => (r.INIT = "INIT", r.FORWARD = "FORWARD", r.TERMINATE = "TERMINATE", r.GLOBALS_SYNC = "GLOBALS_SYNC", r))(we || {});
2047
- function hi(r) {
2046
+ var xe = /* @__PURE__ */ ((r) => (r.INIT = "INIT", r.FORWARD = "FORWARD", r.TERMINATE = "TERMINATE", r.GLOBALS_SYNC = "GLOBALS_SYNC", r))(xe || {});
2047
+ function mi(r) {
2048
2048
  return [ImageBitmap, ReadableStream, WritableStream].some((e) => r instanceof e);
2049
2049
  }
2050
2050
  let Ta = 0;
@@ -2057,7 +2057,7 @@ function Sa(r, e, t, n, i) {
2057
2057
  functionName: t,
2058
2058
  args: n
2059
2059
  },
2060
- n.filter((s) => hi(s))
2060
+ n.filter((s) => mi(s))
2061
2061
  ), new Promise((s) => {
2062
2062
  i?.set(o, s);
2063
2063
  });
@@ -2070,24 +2070,24 @@ function tt(r, e) {
2070
2070
  type: n,
2071
2071
  result: e
2072
2072
  },
2073
- i.filter((o) => hi(o))
2073
+ i.filter((o) => mi(o))
2074
2074
  );
2075
2075
  }
2076
- const $n = $r("workerized", {});
2077
- function mi() {
2076
+ const Wn = $r("workerized", {});
2077
+ function pi() {
2078
2078
  return typeof WorkerGlobalScope < "u" && self instanceof WorkerGlobalScope;
2079
2079
  }
2080
2080
  async function Ia() {
2081
- if (mi())
2082
- tt({ type: we.GLOBALS_SYNC }, oe);
2081
+ if (pi())
2082
+ tt({ type: xe.GLOBALS_SYNC }, oe);
2083
2083
  else {
2084
2084
  const r = [];
2085
- for (const e in $n) {
2086
- const { worker: t, resolvers: n } = $n[e].workerContext;
2085
+ for (const e in Wn) {
2086
+ const { worker: t, resolvers: n } = Wn[e].workerContext;
2087
2087
  t && r.push(
2088
2088
  Sa(
2089
2089
  t,
2090
- we.GLOBALS_SYNC,
2090
+ xe.GLOBALS_SYNC,
2091
2091
  "",
2092
2092
  [oe],
2093
2093
  n
@@ -2106,7 +2106,7 @@ function jt(r, e) {
2106
2106
  for (const t in r)
2107
2107
  Array.isArray(r[t]) ? (e[t] = [], jt(r[t], e[t])) : typeof r[t] == "object" ? (e[t] = {}, jt(r[t], e[t])) : e[t] = r[t];
2108
2108
  }
2109
- async function Ra(r, e) {
2109
+ async function ka(r, e) {
2110
2110
  const { functionName: t, args: n } = r;
2111
2111
  if (!e.instance)
2112
2112
  throw "instance not initialized";
@@ -2116,11 +2116,11 @@ async function Ra(r, e) {
2116
2116
  throw `undefined function [${t}] in class ${e.instance.constructor.workerId}`;
2117
2117
  tt(r, await e.instance[t](...n ?? []));
2118
2118
  }
2119
- const ka = $r("registeredWorkers", {});
2119
+ const Ra = $r("registeredWorkers", {});
2120
2120
  function Pa(r, e) {
2121
2121
  if (!r.args)
2122
2122
  throw "Missing className while initializing worker";
2123
- const [t, n] = r.args, i = ka[t];
2123
+ const [t, n] = r.args, i = Ra[t];
2124
2124
  if (i)
2125
2125
  e.instance = new i(r.args.slice(1));
2126
2126
  else
@@ -2144,22 +2144,22 @@ function Oa() {
2144
2144
  onmessage = async (e) => {
2145
2145
  const t = e.data;
2146
2146
  switch (t.type) {
2147
- case we.INIT:
2147
+ case xe.INIT:
2148
2148
  Pa(t, r);
2149
2149
  break;
2150
- case we.FORWARD:
2151
- Ra(t, r);
2150
+ case xe.FORWARD:
2151
+ ka(t, r);
2152
2152
  break;
2153
- case we.TERMINATE:
2153
+ case xe.TERMINATE:
2154
2154
  Fa(t, r);
2155
2155
  break;
2156
- case we.GLOBALS_SYNC:
2156
+ case xe.GLOBALS_SYNC:
2157
2157
  Ca(t);
2158
2158
  break;
2159
2159
  }
2160
2160
  };
2161
2161
  }
2162
- mi() && Oa();
2162
+ pi() && Oa();
2163
2163
  function Ma(r, e) {
2164
2164
  return oe[r] || (oe[r] = e), [
2165
2165
  () => oe[r],
@@ -2214,7 +2214,7 @@ class Ua {
2214
2214
  };
2215
2215
  }
2216
2216
  }
2217
- const La = "7.0.1";
2217
+ const La = "7.0.2-alpha.2";
2218
2218
  class Wr {
2219
2219
  constructor() {
2220
2220
  const e = new OffscreenCanvas(0, 0), t = e.getContext("2d", { willReadFrequently: !0 });
@@ -2313,9 +2313,9 @@ class $a extends Wr {
2313
2313
  ), this.context.restore()), super.render(e, t);
2314
2314
  }
2315
2315
  }
2316
- const Gr = 5120, Xe = 5121, Vr = 5122, Hr = 5123, jr = 5124, Yr = 5125, Qr = 5126, Wa = 32819, Ga = 32820, Va = 33635, Ha = 5131, ja = 33640, Ya = 35899, Qa = 35902, qa = 36269, Xa = 34042, pi = {};
2316
+ const Gr = 5120, Xe = 5121, Vr = 5122, Hr = 5123, jr = 5124, Yr = 5125, Qr = 5126, Wa = 32819, Ga = 32820, Va = 33635, Ha = 5131, ja = 33640, Ya = 35899, Qa = 35902, qa = 36269, Xa = 34042, gi = {};
2317
2317
  {
2318
- const r = pi;
2318
+ const r = gi;
2319
2319
  r[Gr] = Int8Array, r[Xe] = Uint8Array, r[Vr] = Int16Array, r[Hr] = Uint16Array, r[jr] = Int32Array, r[Yr] = Uint32Array, r[Qr] = Float32Array, r[Wa] = Uint16Array, r[Ga] = Uint16Array, r[Va] = Uint16Array, r[Ha] = Uint16Array, r[ja] = Uint32Array, r[Ya] = Uint32Array, r[Qa] = Uint32Array, r[qa] = Uint32Array, r[Xa] = Uint32Array;
2320
2320
  }
2321
2321
  function qr(r) {
@@ -2335,7 +2335,7 @@ function qr(r) {
2335
2335
  return Qr;
2336
2336
  throw new Error("unsupported typed array type");
2337
2337
  }
2338
- function gi(r) {
2338
+ function yi(r) {
2339
2339
  if (r === Int8Array)
2340
2340
  return Gr;
2341
2341
  if (r === Uint8Array || r === Uint8ClampedArray)
@@ -2352,8 +2352,8 @@ function gi(r) {
2352
2352
  return Qr;
2353
2353
  throw new Error("unsupported typed array type");
2354
2354
  }
2355
- function yi(r) {
2356
- const e = pi[r];
2355
+ function bi(r) {
2356
+ const e = gi[r];
2357
2357
  if (!e)
2358
2358
  throw new Error("unknown gl type");
2359
2359
  return e;
@@ -2363,15 +2363,15 @@ const Yt = typeof SharedArrayBuffer < "u" ? function(e) {
2363
2363
  } : function(e) {
2364
2364
  return e && e.buffer && e.buffer instanceof ArrayBuffer;
2365
2365
  };
2366
- function bi(...r) {
2366
+ function wi(...r) {
2367
2367
  console.error(...r);
2368
2368
  }
2369
- const Wn = /* @__PURE__ */ new Map();
2369
+ const Gn = /* @__PURE__ */ new Map();
2370
2370
  function Zt(r, e) {
2371
2371
  if (!r || typeof r != "object")
2372
2372
  return !1;
2373
- let t = Wn.get(e);
2374
- t || (t = /* @__PURE__ */ new WeakMap(), Wn.set(e, t));
2373
+ let t = Gn.get(e);
2374
+ t || (t = /* @__PURE__ */ new WeakMap(), Gn.set(e, t));
2375
2375
  let n = t.get(r);
2376
2376
  if (n === void 0) {
2377
2377
  const i = Object.prototype.toString.call(r);
@@ -2391,20 +2391,20 @@ function Xr(r, e) {
2391
2391
  function Za(r, e) {
2392
2392
  return typeof WebGLSampler < "u" && Zt(e, "WebGLSampler");
2393
2393
  }
2394
- const wi = 35044, xe = 34962, ec = 34963, tc = 34660, rc = 5120, nc = 5121, ic = 5122, oc = 5123, sc = 5124, ac = 5125, xi = 5126, vi = {
2394
+ const xi = 35044, ve = 34962, ec = 34963, tc = 34660, rc = 5120, nc = 5121, ic = 5122, oc = 5123, sc = 5124, ac = 5125, vi = 5126, _i = {
2395
2395
  attribPrefix: ""
2396
2396
  };
2397
2397
  function cc(r, e, t, n, i) {
2398
- r.bindBuffer(e, t), r.bufferData(e, n, i || wi);
2398
+ r.bindBuffer(e, t), r.bufferData(e, n, i || xi);
2399
2399
  }
2400
- function _i(r, e, t, n) {
2400
+ function Ei(r, e, t, n) {
2401
2401
  if (Ka(r, e))
2402
2402
  return e;
2403
- t = t || xe;
2403
+ t = t || ve;
2404
2404
  const i = r.createBuffer();
2405
2405
  return cc(r, t, i, e, n), i;
2406
2406
  }
2407
- function Ei(r) {
2407
+ function Ai(r) {
2408
2408
  return r === "indices";
2409
2409
  }
2410
2410
  function uc(r) {
@@ -2423,7 +2423,7 @@ function hc(r, e) {
2423
2423
  function mc(r, e, t) {
2424
2424
  return r.numComponents || r.size || hc(e, t || lc(r).length);
2425
2425
  }
2426
- function Ai(r, e) {
2426
+ function Ti(r, e) {
2427
2427
  if (Yt(r))
2428
2428
  return r;
2429
2429
  if (Yt(r.data))
@@ -2432,13 +2432,13 @@ function Ai(r, e) {
2432
2432
  data: r
2433
2433
  });
2434
2434
  let t = r.type ? Kr(r.type) : void 0;
2435
- return t || (Ei(e) ? t = Uint16Array : t = Float32Array), new t(r.data);
2435
+ return t || (Ai(e) ? t = Uint16Array : t = Float32Array), new t(r.data);
2436
2436
  }
2437
2437
  function pc(r) {
2438
- return typeof r == "number" ? r : r ? gi(r) : xi;
2438
+ return typeof r == "number" ? r : r ? yi(r) : vi;
2439
2439
  }
2440
2440
  function Kr(r) {
2441
- return typeof r == "number" ? yi(r) : r || Float32Array;
2441
+ return typeof r == "number" ? bi(r) : r || Float32Array;
2442
2442
  }
2443
2443
  function gc(r, e) {
2444
2444
  return {
@@ -2451,18 +2451,18 @@ function gc(r, e) {
2451
2451
  }
2452
2452
  function yc(r, e) {
2453
2453
  const t = e.data || e, n = Kr(e.type), i = t * n.BYTES_PER_ELEMENT, o = r.createBuffer();
2454
- return r.bindBuffer(xe, o), r.bufferData(xe, i, e.drawType || wi), {
2454
+ return r.bindBuffer(ve, o), r.bufferData(ve, i, e.drawType || xi), {
2455
2455
  buffer: o,
2456
2456
  numValues: t,
2457
- type: gi(n),
2457
+ type: yi(n),
2458
2458
  arrayType: n
2459
2459
  };
2460
2460
  }
2461
2461
  function bc(r, e, t) {
2462
- const n = Ai(e, t);
2462
+ const n = Ti(e, t);
2463
2463
  return {
2464
2464
  arrayType: n.constructor,
2465
- buffer: _i(r, n, void 0, e.drawType),
2465
+ buffer: Ei(r, n, void 0, e.drawType),
2466
2466
  type: qr(n),
2467
2467
  numValues: 0
2468
2468
  };
@@ -2470,8 +2470,8 @@ function bc(r, e, t) {
2470
2470
  function wc(r, e) {
2471
2471
  const t = {};
2472
2472
  return Object.keys(e).forEach(function(n) {
2473
- if (!Ei(n)) {
2474
- const i = e[n], o = i.attrib || i.name || i.attribName || vi.attribPrefix + n;
2473
+ if (!Ai(n)) {
2474
+ const i = e[n], o = i.attrib || i.name || i.attribName || _i.attribPrefix + n;
2475
2475
  if (i.value) {
2476
2476
  if (!Array.isArray(i.value) && !Yt(i.value))
2477
2477
  throw new Error("array.value is not array or typedarray");
@@ -2494,23 +2494,23 @@ function wc(r, e) {
2494
2494
  };
2495
2495
  }
2496
2496
  }
2497
- }), r.bindBuffer(xe, null), t;
2497
+ }), r.bindBuffer(ve, null), t;
2498
2498
  }
2499
2499
  function xc(r, e) {
2500
- return e === rc || e === nc ? 1 : e === ic || e === oc ? 2 : e === sc || e === ac || e === xi ? 4 : 0;
2500
+ return e === rc || e === nc ? 1 : e === ic || e === oc ? 2 : e === sc || e === ac || e === vi ? 4 : 0;
2501
2501
  }
2502
2502
  const wr = ["position", "positions", "a_position"];
2503
2503
  function vc(r, e) {
2504
2504
  let t, n;
2505
- for (n = 0; n < wr.length && (t = wr[n], !(t in e || (t = vi.attribPrefix + t, t in e))); ++n)
2505
+ for (n = 0; n < wr.length && (t = wr[n], !(t in e || (t = _i.attribPrefix + t, t in e))); ++n)
2506
2506
  ;
2507
2507
  n === wr.length && (t = Object.keys(e)[0]);
2508
2508
  const i = e[t];
2509
2509
  if (!i.buffer)
2510
2510
  return 1;
2511
- r.bindBuffer(xe, i.buffer);
2512
- const o = r.getBufferParameter(xe, tc);
2513
- r.bindBuffer(xe, null);
2511
+ r.bindBuffer(ve, i.buffer);
2512
+ const o = r.getBufferParameter(ve, tc);
2513
+ r.bindBuffer(ve, null);
2514
2514
  const s = xc(r, i.type), a = o / s, c = i.numComponents || i.size, u = a / c;
2515
2515
  if (u % 1 !== 0)
2516
2516
  throw new Error(`numComponents ${c} not correct for length ${length}`);
@@ -2521,15 +2521,15 @@ function _c(r, e, t) {
2521
2521
  i.attribs = Object.assign({}, t ? t.attribs : {}, n);
2522
2522
  const o = e.indices;
2523
2523
  if (o) {
2524
- const s = Ai(o, "indices");
2525
- i.indices = _i(r, s, ec), i.numElements = s.length, i.elementType = qr(s);
2524
+ const s = Ti(o, "indices");
2525
+ i.indices = Ei(r, s, ec), i.numElements = s.length, i.elementType = qr(s);
2526
2526
  } else i.numElements || (i.numElements = vc(r, i.attribs));
2527
2527
  return i;
2528
2528
  }
2529
2529
  function rt(r) {
2530
2530
  return !!r.texStorage2D;
2531
2531
  }
2532
- const Ti = /* @__PURE__ */ (function() {
2532
+ const Si = /* @__PURE__ */ (function() {
2533
2533
  const r = {}, e = {};
2534
2534
  function t(n) {
2535
2535
  const i = n.constructor.name;
@@ -2549,17 +2549,17 @@ const Ti = /* @__PURE__ */ (function() {
2549
2549
  textureColor: new Uint8Array([128, 192, 255, 255]),
2550
2550
  textureOptions: {},
2551
2551
  crossOrigin: void 0
2552
- }, Ke = Yt, Si = /* @__PURE__ */ (function() {
2552
+ }, Ke = Yt, Ii = /* @__PURE__ */ (function() {
2553
2553
  let r;
2554
2554
  return function() {
2555
2555
  return r = r || (typeof document < "u" && document.createElement ? document.createElement("canvas").getContext("2d") : null), r;
2556
2556
  };
2557
- })(), Gn = 6406, j = 6407, T = 6408, Vn = 6409, Hn = 6410, Ve = 6402, jn = 34041, Qt = 33071, Ec = 9728, Ac = 9729, ce = 3553, se = 34067, _e = 32879, Ee = 35866, Jr = 34069, Tc = 34070, Sc = 34071, Ic = 34072, Rc = 34073, kc = 34074, Sr = 10241, Ir = 10240, qt = 10242, Xt = 10243, Yn = 32882, Pc = 33082, Fc = 33083, Cc = 33084, Oc = 33085, Mc = 34892, Bc = 34893, Zr = 3317, Ii = 3314, Ri = 32878, ki = 3316, Pi = 3315, Fi = 32877, Dc = 37443, Uc = 37441, Lc = 37440, zc = 33321, Nc = 36756, $c = 33325, Wc = 33326, Gc = 33330, Vc = 33329, Hc = 33338, jc = 33337, Yc = 33340, Qc = 33339, qc = 33323, Xc = 36757, Kc = 33327, Jc = 33328, Zc = 33336, eu = 33335, tu = 33332, ru = 33331, nu = 33334, iu = 33333, ou = 32849, su = 35905, au = 36194, cu = 36758, uu = 35898, lu = 35901, fu = 34843, du = 34837, hu = 36221, mu = 36239, pu = 36215, gu = 36233, yu = 36209, bu = 36227, wu = 32856, xu = 35907, vu = 36759, _u = 32855, Eu = 32854, Au = 32857, Tu = 34842, Su = 34836, Iu = 36220, Ru = 36238, ku = 36975, Pu = 36214, Fu = 36232, Cu = 36226, Ou = 36208, Mu = 33189, Bu = 33190, Du = 36012, Uu = 36013, Lu = 35056, ne = 5120, A = 5121, wt = 5122, Pe = 5123, xt = 5124, de = 5125, M = 5126, Qn = 32819, qn = 32820, Xn = 33635, G = 5131, He = 36193, xr = 33640, zu = 35899, Nu = 35902, $u = 36269, Wu = 34042, vt = 33319, Fe = 33320, _t = 6403, Ce = 36244, Oe = 36248, he = 36249;
2557
+ })(), Vn = 6406, j = 6407, T = 6408, Hn = 6409, jn = 6410, Ve = 6402, Yn = 34041, Qt = 33071, Ec = 9728, Ac = 9729, ce = 3553, se = 34067, Ee = 32879, Ae = 35866, Jr = 34069, Tc = 34070, Sc = 34071, Ic = 34072, kc = 34073, Rc = 34074, Sr = 10241, Ir = 10240, qt = 10242, Xt = 10243, Qn = 32882, Pc = 33082, Fc = 33083, Cc = 33084, Oc = 33085, Mc = 34892, Bc = 34893, Zr = 3317, ki = 3314, Ri = 32878, Pi = 3316, Fi = 3315, Ci = 32877, Dc = 37443, Uc = 37441, Lc = 37440, zc = 33321, Nc = 36756, $c = 33325, Wc = 33326, Gc = 33330, Vc = 33329, Hc = 33338, jc = 33337, Yc = 33340, Qc = 33339, qc = 33323, Xc = 36757, Kc = 33327, Jc = 33328, Zc = 33336, eu = 33335, tu = 33332, ru = 33331, nu = 33334, iu = 33333, ou = 32849, su = 35905, au = 36194, cu = 36758, uu = 35898, lu = 35901, fu = 34843, du = 34837, hu = 36221, mu = 36239, pu = 36215, gu = 36233, yu = 36209, bu = 36227, wu = 32856, xu = 35907, vu = 36759, _u = 32855, Eu = 32854, Au = 32857, Tu = 34842, Su = 34836, Iu = 36220, ku = 36238, Ru = 36975, Pu = 36214, Fu = 36232, Cu = 36226, Ou = 36208, Mu = 33189, Bu = 33190, Du = 36012, Uu = 36013, Lu = 35056, ne = 5120, A = 5121, wt = 5122, Fe = 5123, xt = 5124, de = 5125, M = 5126, qn = 32819, Xn = 32820, Kn = 33635, G = 5131, He = 36193, xr = 33640, zu = 35899, Nu = 35902, $u = 36269, Wu = 34042, vt = 33319, Ce = 33320, _t = 6403, Oe = 36244, Me = 36248, he = 36249;
2558
2558
  let vr;
2559
2559
  function er(r) {
2560
2560
  if (!vr) {
2561
2561
  const e = {};
2562
- e[Gn] = { textureFormat: Gn, colorRenderable: !0, textureFilterable: !0, bytesPerElement: [1, 2, 2, 4], type: [A, G, He, M] }, e[Vn] = { textureFormat: Vn, colorRenderable: !0, textureFilterable: !0, bytesPerElement: [1, 2, 2, 4], type: [A, G, He, M] }, e[Hn] = { textureFormat: Hn, colorRenderable: !0, textureFilterable: !0, bytesPerElement: [2, 4, 4, 8], type: [A, G, He, M] }, e[j] = { textureFormat: j, colorRenderable: !0, textureFilterable: !0, bytesPerElement: [3, 6, 6, 12, 2], type: [A, G, He, M, Xn] }, e[T] = { textureFormat: T, colorRenderable: !0, textureFilterable: !0, bytesPerElement: [4, 8, 8, 16, 2, 2], type: [A, G, He, M, Qn, qn] }, e[Ve] = { textureFormat: Ve, colorRenderable: !0, textureFilterable: !1, bytesPerElement: [2, 4], type: [de, Pe] }, e[zc] = { textureFormat: _t, colorRenderable: !0, textureFilterable: !0, bytesPerElement: [1], type: [A] }, e[Nc] = { textureFormat: _t, colorRenderable: !1, textureFilterable: !0, bytesPerElement: [1], type: [ne] }, e[$c] = { textureFormat: _t, colorRenderable: !1, textureFilterable: !0, bytesPerElement: [4, 2], type: [M, G] }, e[Wc] = { textureFormat: _t, colorRenderable: !1, textureFilterable: !1, bytesPerElement: [4], type: [M] }, e[Gc] = { textureFormat: Ce, colorRenderable: !0, textureFilterable: !1, bytesPerElement: [1], type: [A] }, e[Vc] = { textureFormat: Ce, colorRenderable: !0, textureFilterable: !1, bytesPerElement: [1], type: [ne] }, e[tu] = { textureFormat: Ce, colorRenderable: !0, textureFilterable: !1, bytesPerElement: [2], type: [Pe] }, e[ru] = { textureFormat: Ce, colorRenderable: !0, textureFilterable: !1, bytesPerElement: [2], type: [wt] }, e[nu] = { textureFormat: Ce, colorRenderable: !0, textureFilterable: !1, bytesPerElement: [4], type: [de] }, e[iu] = { textureFormat: Ce, colorRenderable: !0, textureFilterable: !1, bytesPerElement: [4], type: [xt] }, e[qc] = { textureFormat: vt, colorRenderable: !0, textureFilterable: !0, bytesPerElement: [2], type: [A] }, e[Xc] = { textureFormat: vt, colorRenderable: !1, textureFilterable: !0, bytesPerElement: [2], type: [ne] }, e[Kc] = { textureFormat: vt, colorRenderable: !1, textureFilterable: !0, bytesPerElement: [8, 4], type: [M, G] }, e[Jc] = { textureFormat: vt, colorRenderable: !1, textureFilterable: !1, bytesPerElement: [8], type: [M] }, e[Zc] = { textureFormat: Fe, colorRenderable: !0, textureFilterable: !1, bytesPerElement: [2], type: [A] }, e[eu] = { textureFormat: Fe, colorRenderable: !0, textureFilterable: !1, bytesPerElement: [2], type: [ne] }, e[Hc] = { textureFormat: Fe, colorRenderable: !0, textureFilterable: !1, bytesPerElement: [4], type: [Pe] }, e[jc] = { textureFormat: Fe, colorRenderable: !0, textureFilterable: !1, bytesPerElement: [4], type: [wt] }, e[Yc] = { textureFormat: Fe, colorRenderable: !0, textureFilterable: !1, bytesPerElement: [8], type: [de] }, e[Qc] = { textureFormat: Fe, colorRenderable: !0, textureFilterable: !1, bytesPerElement: [8], type: [xt] }, e[ou] = { textureFormat: j, colorRenderable: !0, textureFilterable: !0, bytesPerElement: [3], type: [A] }, e[su] = { textureFormat: j, colorRenderable: !1, textureFilterable: !0, bytesPerElement: [3], type: [A] }, e[au] = { textureFormat: j, colorRenderable: !0, textureFilterable: !0, bytesPerElement: [3, 2], type: [A, Xn] }, e[cu] = { textureFormat: j, colorRenderable: !1, textureFilterable: !0, bytesPerElement: [3], type: [ne] }, e[uu] = { textureFormat: j, colorRenderable: !1, textureFilterable: !0, bytesPerElement: [12, 6, 4], type: [M, G, zu] }, e[lu] = { textureFormat: j, colorRenderable: !1, textureFilterable: !0, bytesPerElement: [12, 6, 4], type: [M, G, Nu] }, e[fu] = { textureFormat: j, colorRenderable: !1, textureFilterable: !0, bytesPerElement: [12, 6], type: [M, G] }, e[du] = { textureFormat: j, colorRenderable: !1, textureFilterable: !1, bytesPerElement: [12], type: [M] }, e[hu] = { textureFormat: Oe, colorRenderable: !1, textureFilterable: !1, bytesPerElement: [3], type: [A] }, e[mu] = { textureFormat: Oe, colorRenderable: !1, textureFilterable: !1, bytesPerElement: [3], type: [ne] }, e[pu] = { textureFormat: Oe, colorRenderable: !1, textureFilterable: !1, bytesPerElement: [6], type: [Pe] }, e[gu] = { textureFormat: Oe, colorRenderable: !1, textureFilterable: !1, bytesPerElement: [6], type: [wt] }, e[yu] = { textureFormat: Oe, colorRenderable: !1, textureFilterable: !1, bytesPerElement: [12], type: [de] }, e[bu] = { textureFormat: Oe, colorRenderable: !1, textureFilterable: !1, bytesPerElement: [12], type: [xt] }, e[wu] = { textureFormat: T, colorRenderable: !0, textureFilterable: !0, bytesPerElement: [4], type: [A] }, e[xu] = { textureFormat: T, colorRenderable: !0, textureFilterable: !0, bytesPerElement: [4], type: [A] }, e[vu] = { textureFormat: T, colorRenderable: !1, textureFilterable: !0, bytesPerElement: [4], type: [ne] }, e[_u] = { textureFormat: T, colorRenderable: !0, textureFilterable: !0, bytesPerElement: [4, 2, 4], type: [A, qn, xr] }, e[Eu] = { textureFormat: T, colorRenderable: !0, textureFilterable: !0, bytesPerElement: [4, 2], type: [A, Qn] }, e[Au] = { textureFormat: T, colorRenderable: !0, textureFilterable: !0, bytesPerElement: [4], type: [xr] }, e[Tu] = { textureFormat: T, colorRenderable: !1, textureFilterable: !0, bytesPerElement: [16, 8], type: [M, G] }, e[Su] = { textureFormat: T, colorRenderable: !1, textureFilterable: !1, bytesPerElement: [16], type: [M] }, e[Iu] = { textureFormat: he, colorRenderable: !0, textureFilterable: !1, bytesPerElement: [4], type: [A] }, e[Ru] = { textureFormat: he, colorRenderable: !0, textureFilterable: !1, bytesPerElement: [4], type: [ne] }, e[ku] = { textureFormat: he, colorRenderable: !0, textureFilterable: !1, bytesPerElement: [4], type: [xr] }, e[Pu] = { textureFormat: he, colorRenderable: !0, textureFilterable: !1, bytesPerElement: [8], type: [Pe] }, e[Fu] = { textureFormat: he, colorRenderable: !0, textureFilterable: !1, bytesPerElement: [8], type: [wt] }, e[Cu] = { textureFormat: he, colorRenderable: !0, textureFilterable: !1, bytesPerElement: [16], type: [xt] }, e[Ou] = { textureFormat: he, colorRenderable: !0, textureFilterable: !1, bytesPerElement: [16], type: [de] }, e[Mu] = { textureFormat: Ve, colorRenderable: !0, textureFilterable: !1, bytesPerElement: [2, 4], type: [Pe, de] }, e[Bu] = { textureFormat: Ve, colorRenderable: !0, textureFilterable: !1, bytesPerElement: [4], type: [de] }, e[Du] = { textureFormat: Ve, colorRenderable: !0, textureFilterable: !1, bytesPerElement: [4], type: [M] }, e[Lu] = { textureFormat: jn, colorRenderable: !0, textureFilterable: !1, bytesPerElement: [4], type: [Wu] }, e[Uu] = { textureFormat: jn, colorRenderable: !0, textureFilterable: !1, bytesPerElement: [4], type: [$u] }, Object.keys(e).forEach(function(t) {
2562
+ e[Vn] = { textureFormat: Vn, colorRenderable: !0, textureFilterable: !0, bytesPerElement: [1, 2, 2, 4], type: [A, G, He, M] }, e[Hn] = { textureFormat: Hn, colorRenderable: !0, textureFilterable: !0, bytesPerElement: [1, 2, 2, 4], type: [A, G, He, M] }, e[jn] = { textureFormat: jn, colorRenderable: !0, textureFilterable: !0, bytesPerElement: [2, 4, 4, 8], type: [A, G, He, M] }, e[j] = { textureFormat: j, colorRenderable: !0, textureFilterable: !0, bytesPerElement: [3, 6, 6, 12, 2], type: [A, G, He, M, Kn] }, e[T] = { textureFormat: T, colorRenderable: !0, textureFilterable: !0, bytesPerElement: [4, 8, 8, 16, 2, 2], type: [A, G, He, M, qn, Xn] }, e[Ve] = { textureFormat: Ve, colorRenderable: !0, textureFilterable: !1, bytesPerElement: [2, 4], type: [de, Fe] }, e[zc] = { textureFormat: _t, colorRenderable: !0, textureFilterable: !0, bytesPerElement: [1], type: [A] }, e[Nc] = { textureFormat: _t, colorRenderable: !1, textureFilterable: !0, bytesPerElement: [1], type: [ne] }, e[$c] = { textureFormat: _t, colorRenderable: !1, textureFilterable: !0, bytesPerElement: [4, 2], type: [M, G] }, e[Wc] = { textureFormat: _t, colorRenderable: !1, textureFilterable: !1, bytesPerElement: [4], type: [M] }, e[Gc] = { textureFormat: Oe, colorRenderable: !0, textureFilterable: !1, bytesPerElement: [1], type: [A] }, e[Vc] = { textureFormat: Oe, colorRenderable: !0, textureFilterable: !1, bytesPerElement: [1], type: [ne] }, e[tu] = { textureFormat: Oe, colorRenderable: !0, textureFilterable: !1, bytesPerElement: [2], type: [Fe] }, e[ru] = { textureFormat: Oe, colorRenderable: !0, textureFilterable: !1, bytesPerElement: [2], type: [wt] }, e[nu] = { textureFormat: Oe, colorRenderable: !0, textureFilterable: !1, bytesPerElement: [4], type: [de] }, e[iu] = { textureFormat: Oe, colorRenderable: !0, textureFilterable: !1, bytesPerElement: [4], type: [xt] }, e[qc] = { textureFormat: vt, colorRenderable: !0, textureFilterable: !0, bytesPerElement: [2], type: [A] }, e[Xc] = { textureFormat: vt, colorRenderable: !1, textureFilterable: !0, bytesPerElement: [2], type: [ne] }, e[Kc] = { textureFormat: vt, colorRenderable: !1, textureFilterable: !0, bytesPerElement: [8, 4], type: [M, G] }, e[Jc] = { textureFormat: vt, colorRenderable: !1, textureFilterable: !1, bytesPerElement: [8], type: [M] }, e[Zc] = { textureFormat: Ce, colorRenderable: !0, textureFilterable: !1, bytesPerElement: [2], type: [A] }, e[eu] = { textureFormat: Ce, colorRenderable: !0, textureFilterable: !1, bytesPerElement: [2], type: [ne] }, e[Hc] = { textureFormat: Ce, colorRenderable: !0, textureFilterable: !1, bytesPerElement: [4], type: [Fe] }, e[jc] = { textureFormat: Ce, colorRenderable: !0, textureFilterable: !1, bytesPerElement: [4], type: [wt] }, e[Yc] = { textureFormat: Ce, colorRenderable: !0, textureFilterable: !1, bytesPerElement: [8], type: [de] }, e[Qc] = { textureFormat: Ce, colorRenderable: !0, textureFilterable: !1, bytesPerElement: [8], type: [xt] }, e[ou] = { textureFormat: j, colorRenderable: !0, textureFilterable: !0, bytesPerElement: [3], type: [A] }, e[su] = { textureFormat: j, colorRenderable: !1, textureFilterable: !0, bytesPerElement: [3], type: [A] }, e[au] = { textureFormat: j, colorRenderable: !0, textureFilterable: !0, bytesPerElement: [3, 2], type: [A, Kn] }, e[cu] = { textureFormat: j, colorRenderable: !1, textureFilterable: !0, bytesPerElement: [3], type: [ne] }, e[uu] = { textureFormat: j, colorRenderable: !1, textureFilterable: !0, bytesPerElement: [12, 6, 4], type: [M, G, zu] }, e[lu] = { textureFormat: j, colorRenderable: !1, textureFilterable: !0, bytesPerElement: [12, 6, 4], type: [M, G, Nu] }, e[fu] = { textureFormat: j, colorRenderable: !1, textureFilterable: !0, bytesPerElement: [12, 6], type: [M, G] }, e[du] = { textureFormat: j, colorRenderable: !1, textureFilterable: !1, bytesPerElement: [12], type: [M] }, e[hu] = { textureFormat: Me, colorRenderable: !1, textureFilterable: !1, bytesPerElement: [3], type: [A] }, e[mu] = { textureFormat: Me, colorRenderable: !1, textureFilterable: !1, bytesPerElement: [3], type: [ne] }, e[pu] = { textureFormat: Me, colorRenderable: !1, textureFilterable: !1, bytesPerElement: [6], type: [Fe] }, e[gu] = { textureFormat: Me, colorRenderable: !1, textureFilterable: !1, bytesPerElement: [6], type: [wt] }, e[yu] = { textureFormat: Me, colorRenderable: !1, textureFilterable: !1, bytesPerElement: [12], type: [de] }, e[bu] = { textureFormat: Me, colorRenderable: !1, textureFilterable: !1, bytesPerElement: [12], type: [xt] }, e[wu] = { textureFormat: T, colorRenderable: !0, textureFilterable: !0, bytesPerElement: [4], type: [A] }, e[xu] = { textureFormat: T, colorRenderable: !0, textureFilterable: !0, bytesPerElement: [4], type: [A] }, e[vu] = { textureFormat: T, colorRenderable: !1, textureFilterable: !0, bytesPerElement: [4], type: [ne] }, e[_u] = { textureFormat: T, colorRenderable: !0, textureFilterable: !0, bytesPerElement: [4, 2, 4], type: [A, Xn, xr] }, e[Eu] = { textureFormat: T, colorRenderable: !0, textureFilterable: !0, bytesPerElement: [4, 2], type: [A, qn] }, e[Au] = { textureFormat: T, colorRenderable: !0, textureFilterable: !0, bytesPerElement: [4], type: [xr] }, e[Tu] = { textureFormat: T, colorRenderable: !1, textureFilterable: !0, bytesPerElement: [16, 8], type: [M, G] }, e[Su] = { textureFormat: T, colorRenderable: !1, textureFilterable: !1, bytesPerElement: [16], type: [M] }, e[Iu] = { textureFormat: he, colorRenderable: !0, textureFilterable: !1, bytesPerElement: [4], type: [A] }, e[ku] = { textureFormat: he, colorRenderable: !0, textureFilterable: !1, bytesPerElement: [4], type: [ne] }, e[Ru] = { textureFormat: he, colorRenderable: !0, textureFilterable: !1, bytesPerElement: [4], type: [xr] }, e[Pu] = { textureFormat: he, colorRenderable: !0, textureFilterable: !1, bytesPerElement: [8], type: [Fe] }, e[Fu] = { textureFormat: he, colorRenderable: !0, textureFilterable: !1, bytesPerElement: [8], type: [wt] }, e[Cu] = { textureFormat: he, colorRenderable: !0, textureFilterable: !1, bytesPerElement: [16], type: [xt] }, e[Ou] = { textureFormat: he, colorRenderable: !0, textureFilterable: !1, bytesPerElement: [16], type: [de] }, e[Mu] = { textureFormat: Ve, colorRenderable: !0, textureFilterable: !1, bytesPerElement: [2, 4], type: [Fe, de] }, e[Bu] = { textureFormat: Ve, colorRenderable: !0, textureFilterable: !1, bytesPerElement: [4], type: [de] }, e[Du] = { textureFormat: Ve, colorRenderable: !0, textureFilterable: !1, bytesPerElement: [4], type: [M] }, e[Lu] = { textureFormat: Yn, colorRenderable: !0, textureFilterable: !1, bytesPerElement: [4], type: [Wu] }, e[Uu] = { textureFormat: Yn, colorRenderable: !0, textureFilterable: !1, bytesPerElement: [4], type: [$u] }, Object.keys(e).forEach(function(t) {
2563
2563
  const n = e[t];
2564
2564
  n.bytesPerElementMap = {}, n.bytesPerElement.forEach(function(i, o) {
2565
2565
  const s = n.type[o];
@@ -2587,12 +2587,12 @@ function nt(r) {
2587
2587
  type: e.type[0]
2588
2588
  };
2589
2589
  }
2590
- function Kn(r) {
2590
+ function Jn(r) {
2591
2591
  return (r & r - 1) === 0;
2592
2592
  }
2593
2593
  function Vu(r, e, t, n) {
2594
2594
  if (!rt(r))
2595
- return Kn(e) && Kn(t);
2595
+ return Jn(e) && Jn(t);
2596
2596
  const i = er(n);
2597
2597
  if (!i)
2598
2598
  throw "unknown internal format";
@@ -2626,20 +2626,20 @@ function Et(r, e, t, n, i) {
2626
2626
  function Ne(r, e) {
2627
2627
  e.colorspaceConversion !== void 0 && r.pixelStorei(Dc, e.colorspaceConversion), e.premultiplyAlpha !== void 0 && r.pixelStorei(Uc, e.premultiplyAlpha), e.flipY !== void 0 && r.pixelStorei(Lc, e.flipY);
2628
2628
  }
2629
- function Ci(r) {
2630
- r.pixelStorei(Zr, 4), rt(r) && (r.pixelStorei(Ii, 0), r.pixelStorei(Ri, 0), r.pixelStorei(ki, 0), r.pixelStorei(Pi, 0), r.pixelStorei(Fi, 0));
2629
+ function Oi(r) {
2630
+ r.pixelStorei(Zr, 4), rt(r) && (r.pixelStorei(ki, 0), r.pixelStorei(Ri, 0), r.pixelStorei(Pi, 0), r.pixelStorei(Fi, 0), r.pixelStorei(Ci, 0));
2631
2631
  }
2632
2632
  function Yu(r, e, t, n) {
2633
- n.minMag && (t.call(r, e, Sr, n.minMag), t.call(r, e, Ir, n.minMag)), n.min && t.call(r, e, Sr, n.min), n.mag && t.call(r, e, Ir, n.mag), n.wrap && (t.call(r, e, qt, n.wrap), t.call(r, e, Xt, n.wrap), (e === _e || Za(r, e)) && t.call(r, e, Yn, n.wrap)), n.wrapR && t.call(r, e, Yn, n.wrapR), n.wrapS && t.call(r, e, qt, n.wrapS), n.wrapT && t.call(r, e, Xt, n.wrapT), n.minLod !== void 0 && t.call(r, e, Pc, n.minLod), n.maxLod !== void 0 && t.call(r, e, Fc, n.maxLod), n.baseLevel !== void 0 && t.call(r, e, Cc, n.baseLevel), n.maxLevel !== void 0 && t.call(r, e, Oc, n.maxLevel), n.compareFunc !== void 0 && t.call(r, e, Bc, n.compareFunc), n.compareMode !== void 0 && t.call(r, e, Mc, n.compareMode);
2633
+ n.minMag && (t.call(r, e, Sr, n.minMag), t.call(r, e, Ir, n.minMag)), n.min && t.call(r, e, Sr, n.min), n.mag && t.call(r, e, Ir, n.mag), n.wrap && (t.call(r, e, qt, n.wrap), t.call(r, e, Xt, n.wrap), (e === Ee || Za(r, e)) && t.call(r, e, Qn, n.wrap)), n.wrapR && t.call(r, e, Qn, n.wrapR), n.wrapS && t.call(r, e, qt, n.wrapS), n.wrapT && t.call(r, e, Xt, n.wrapT), n.minLod !== void 0 && t.call(r, e, Pc, n.minLod), n.maxLod !== void 0 && t.call(r, e, Fc, n.maxLod), n.baseLevel !== void 0 && t.call(r, e, Cc, n.baseLevel), n.maxLevel !== void 0 && t.call(r, e, Oc, n.maxLevel), n.compareFunc !== void 0 && t.call(r, e, Bc, n.compareFunc), n.compareMode !== void 0 && t.call(r, e, Mc, n.compareMode);
2634
2634
  }
2635
- function Oi(r, e, t) {
2635
+ function Mi(r, e, t) {
2636
2636
  const n = t.target || ce;
2637
2637
  r.bindTexture(n, e), Yu(r, n, r.texParameteri, t);
2638
2638
  }
2639
2639
  function Qu(r) {
2640
2640
  return r = r || ae.textureColor, Ke(r) ? r : new Uint8Array([r[0] * 255, r[1] * 255, r[2] * 255, r[3] * 255]);
2641
2641
  }
2642
- function Rr(r, e, t, n, i, o) {
2642
+ function kr(r, e, t, n, i, o) {
2643
2643
  t = t || ae.textureOptions, o = o || T;
2644
2644
  const s = t.target || ce;
2645
2645
  if (n = n || t.width, i = i || t.height, r.bindTexture(s, e), Vu(r, n, i, o))
@@ -2652,25 +2652,25 @@ function Rr(r, e, t, n, i, o) {
2652
2652
  function Je(r) {
2653
2653
  return r.auto === !0 || r.auto === void 0 && r.level === void 0;
2654
2654
  }
2655
- function kr(r, e) {
2655
+ function Rr(r, e) {
2656
2656
  return e = e || {}, e.cubeFaceOrder || [
2657
2657
  Jr,
2658
2658
  Tc,
2659
2659
  Sc,
2660
2660
  Ic,
2661
- Rc,
2662
- kc
2661
+ kc,
2662
+ Rc
2663
2663
  ];
2664
2664
  }
2665
2665
  function Pr(r, e) {
2666
- const n = kr(r, e).map(function(i, o) {
2666
+ const n = Rr(r, e).map(function(i, o) {
2667
2667
  return { face: i, ndx: o };
2668
2668
  });
2669
2669
  return n.sort(function(i, o) {
2670
2670
  return i.face - o.face;
2671
2671
  }), n;
2672
2672
  }
2673
- function Mi(r, e, t, n) {
2673
+ function Bi(r, e, t, n) {
2674
2674
  n = n || ae.textureOptions;
2675
2675
  const i = n.target || ce, o = n.level || 0;
2676
2676
  let s = t.width, a = t.height;
@@ -2688,33 +2688,33 @@ function Mi(r, e, t, n) {
2688
2688
  d = p / 2, g = [0, 0, 1, 0, 0, 1, 1, 1, 0, 2, 1, 2];
2689
2689
  else
2690
2690
  throw "can't figure out cube map from element: " + (t.src ? t.src : t.nodeName);
2691
- const x = Si();
2691
+ const x = Ii();
2692
2692
  x ? (x.canvas.width = d, x.canvas.height = d, s = d, a = d, Pr(r, n).forEach(function(v) {
2693
- const R = g[v.ndx * 2 + 0] * d, k = g[v.ndx * 2 + 1] * d;
2694
- x.drawImage(t, R, k, d, d, 0, 0, d, d), r.texImage2D(v.face, o, c, f, m, x.canvas);
2693
+ const k = g[v.ndx * 2 + 0] * d, R = g[v.ndx * 2 + 1] * d;
2694
+ x.drawImage(t, k, R, d, d, 0, 0, d, d), r.texImage2D(v.face, o, c, f, m, x.canvas);
2695
2695
  }), x.canvas.width = 1, x.canvas.height = 1) : typeof createImageBitmap < "u" && (s = d, a = d, Pr(r, n).forEach(function(v) {
2696
- const R = g[v.ndx * 2 + 0] * d, k = g[v.ndx * 2 + 1] * d;
2697
- r.texImage2D(v.face, o, c, d, d, 0, f, m, null), createImageBitmap(t, R, k, d, d, {
2696
+ const k = g[v.ndx * 2 + 0] * d, R = g[v.ndx * 2 + 1] * d;
2697
+ r.texImage2D(v.face, o, c, d, d, 0, f, m, null), createImageBitmap(t, k, R, d, d, {
2698
2698
  premultiplyAlpha: "none",
2699
2699
  colorSpaceConversion: "none"
2700
2700
  }).then(function(L) {
2701
- Ne(r, n), r.bindTexture(i, e), r.texImage2D(v.face, o, c, f, m, L), Je(n) && Rr(r, e, n, s, a, c);
2701
+ Ne(r, n), r.bindTexture(i, e), r.texImage2D(v.face, o, c, f, m, L), Je(n) && kr(r, e, n, s, a, c);
2702
2702
  });
2703
2703
  }));
2704
- } else if (i === _e || i === Ee) {
2704
+ } else if (i === Ee || i === Ae) {
2705
2705
  const p = Math.min(t.width, t.height), b = Math.max(t.width, t.height), d = b / p;
2706
2706
  if (d % 1 !== 0)
2707
2707
  throw "can not compute 3D dimensions of element";
2708
2708
  const g = t.width === b ? 1 : 0, x = t.height === b ? 1 : 0;
2709
- r.pixelStorei(Zr, 1), r.pixelStorei(Ii, t.width), r.pixelStorei(Ri, 0), r.pixelStorei(Fi, 0), r.texImage3D(i, o, c, p, p, p, 0, f, m, null);
2709
+ r.pixelStorei(Zr, 1), r.pixelStorei(ki, t.width), r.pixelStorei(Ri, 0), r.pixelStorei(Ci, 0), r.texImage3D(i, o, c, p, p, p, 0, f, m, null);
2710
2710
  for (let v = 0; v < d; ++v) {
2711
- const R = v * p * g, k = v * p * x;
2712
- r.pixelStorei(ki, R), r.pixelStorei(Pi, k), r.texSubImage3D(i, o, 0, 0, v, p, p, 1, f, m, t);
2711
+ const k = v * p * g, R = v * p * x;
2712
+ r.pixelStorei(Pi, k), r.pixelStorei(Fi, R), r.texSubImage3D(i, o, 0, 0, v, p, p, 1, f, m, t);
2713
2713
  }
2714
- Ci(r);
2714
+ Oi(r);
2715
2715
  } else
2716
2716
  r.texImage2D(i, o, c, f, m, t);
2717
- Je(n) && Rr(r, e, n, s, a, c), Oi(r, e, n);
2717
+ Je(n) && kr(r, e, n, s, a, c), Mi(r, e, n);
2718
2718
  }
2719
2719
  function it() {
2720
2720
  }
@@ -2739,7 +2739,7 @@ function Ku(r, e, t) {
2739
2739
  n.removeEventListener("error", o), n.removeEventListener("load", s), n = null;
2740
2740
  }, o = function() {
2741
2741
  const c = "couldn't load image: " + r;
2742
- bi(c), t(c, n), i();
2742
+ wi(c), t(c, n), i();
2743
2743
  }, s = function() {
2744
2744
  t(null, n), i();
2745
2745
  };
@@ -2766,11 +2766,11 @@ function Ku(r, e, t) {
2766
2766
  }
2767
2767
  return n;
2768
2768
  }
2769
- function Bi(r) {
2769
+ function Di(r) {
2770
2770
  return typeof ImageBitmap < "u" && r instanceof ImageBitmap || typeof ImageData < "u" && r instanceof ImageData || typeof HTMLElement < "u" && r instanceof HTMLElement;
2771
2771
  }
2772
2772
  function en(r, e, t) {
2773
- return Bi(r) ? (setTimeout(function() {
2773
+ return Di(r) ? (setTimeout(function() {
2774
2774
  t(null, r);
2775
2775
  }), r) : Ku(r, e, t);
2776
2776
  }
@@ -2783,11 +2783,11 @@ function tn(r, e, t) {
2783
2783
  if (n === se)
2784
2784
  for (let o = 0; o < 6; ++o)
2785
2785
  r.texImage2D(Jr + o, 0, T, 1, 1, 0, T, A, i);
2786
- else n === _e || n === Ee ? r.texImage3D(n, 0, T, 1, 1, 1, 0, T, A, i) : r.texImage2D(n, 0, T, 1, 1, 0, T, A, i);
2786
+ else n === Ee || n === Ae ? r.texImage3D(n, 0, T, 1, 1, 1, 0, T, A, i) : r.texImage2D(n, 0, T, 1, 1, 0, T, A, i);
2787
2787
  }
2788
2788
  function Ju(r, e, t, n) {
2789
2789
  return n = n || it, t = t || ae.textureOptions, tn(r, e, t), t = Object.assign({}, t), en(t.src, t.crossOrigin, function(o, s) {
2790
- o ? n(o, e, s) : (Mi(r, e, s, t), n(null, e, s));
2790
+ o ? n(o, e, s) : (Bi(r, e, s, t), n(null, e, s));
2791
2791
  });
2792
2792
  }
2793
2793
  function Zu(r, e, t, n) {
@@ -2800,13 +2800,13 @@ function Zu(r, e, t, n) {
2800
2800
  throw "target must be TEXTURE_CUBE_MAP";
2801
2801
  tn(r, e, t), t = Object.assign({}, t);
2802
2802
  let m = 6;
2803
- const p = [], b = kr(r, t);
2803
+ const p = [], b = Rr(r, t);
2804
2804
  let d;
2805
2805
  function g(x) {
2806
- return function(v, R) {
2807
- --m, v ? p.push(v) : R.width !== R.height ? p.push("cubemap face img is not a square: " + R.src) : (Ne(r, t), r.bindTexture(f, e), m === 5 ? kr().forEach(function(k) {
2808
- r.texImage2D(k, o, s, c, u, R);
2809
- }) : r.texImage2D(x, o, s, c, u, R), Je(t) && r.generateMipmap(f)), m === 0 && n(p.length ? p : void 0, e, d);
2806
+ return function(v, k) {
2807
+ --m, v ? p.push(v) : k.width !== k.height ? p.push("cubemap face img is not a square: " + k.src) : (Ne(r, t), r.bindTexture(f, e), m === 5 ? Rr().forEach(function(R) {
2808
+ r.texImage2D(R, o, s, c, u, k);
2809
+ }) : r.texImage2D(x, o, s, c, u, k), Je(t) && r.generateMipmap(f)), m === 0 && n(p.length ? p : void 0, e, d);
2810
2810
  };
2811
2811
  }
2812
2812
  d = i.map(function(x, v) {
@@ -2815,8 +2815,8 @@ function Zu(r, e, t, n) {
2815
2815
  }
2816
2816
  function el(r, e, t, n) {
2817
2817
  n = n || it;
2818
- const i = t.src, o = t.internalFormat || t.format || T, s = nt(o), a = t.format || s.format, c = t.type || A, u = t.target || Ee;
2819
- if (u !== _e && u !== Ee)
2818
+ const i = t.src, o = t.internalFormat || t.format || T, s = nt(o), a = t.format || s.format, c = t.type || A, u = t.target || Ae;
2819
+ if (u !== Ee && u !== Ae)
2820
2820
  throw "target must be TEXTURE_3D or TEXTURE_2D_ARRAY";
2821
2821
  tn(r, e, t), t = Object.assign({}, t);
2822
2822
  let f = i.length;
@@ -2826,7 +2826,7 @@ function el(r, e, t, n) {
2826
2826
  let d = t.width, g = t.height;
2827
2827
  const x = i.length;
2828
2828
  let v = !0;
2829
- function R(k) {
2829
+ function k(R) {
2830
2830
  return function(L, Y) {
2831
2831
  if (--f, L)
2832
2832
  m.push(L);
@@ -2837,15 +2837,15 @@ function el(r, e, t, n) {
2837
2837
  r.texSubImage3D(u, b, 0, 0, Q, d, g, 1, a, c, Y);
2838
2838
  } else {
2839
2839
  let Q = Y, N;
2840
- (Y.width !== d || Y.height !== g) && (N = Si(), Q = N.canvas, N.canvas.width = d, N.canvas.height = g, N.drawImage(Y, 0, 0, d, g)), r.texSubImage3D(u, b, 0, 0, k, d, g, 1, a, c, Q), N && Q === N.canvas && (N.canvas.width = 0, N.canvas.height = 0);
2840
+ (Y.width !== d || Y.height !== g) && (N = Ii(), Q = N.canvas, N.canvas.width = d, N.canvas.height = g, N.drawImage(Y, 0, 0, d, g)), r.texSubImage3D(u, b, 0, 0, R, d, g, 1, a, c, Q), N && Q === N.canvas && (N.canvas.width = 0, N.canvas.height = 0);
2841
2841
  }
2842
2842
  Je(t) && r.generateMipmap(u);
2843
2843
  }
2844
2844
  f === 0 && n(m.length ? m : void 0, e, p);
2845
2845
  };
2846
2846
  }
2847
- p = i.map(function(k, L) {
2848
- return en(k, t.crossOrigin, R(L));
2847
+ p = i.map(function(R, L) {
2848
+ return en(R, t.crossOrigin, k(L));
2849
2849
  });
2850
2850
  }
2851
2851
  function tl(r, e, t, n) {
@@ -2857,14 +2857,14 @@ function tl(r, e, t, n) {
2857
2857
  if (Ke(t))
2858
2858
  t instanceof Uint8ClampedArray && (t = new Uint8Array(t.buffer));
2859
2859
  else {
2860
- const x = yi(p);
2860
+ const x = bi(p);
2861
2861
  t = new x(t);
2862
2862
  }
2863
2863
  const b = Gu(u, p), d = t.byteLength / b;
2864
2864
  if (d % 1)
2865
- throw "length wrong size for format: " + Ti(r, m);
2865
+ throw "length wrong size for format: " + Si(r, m);
2866
2866
  let g;
2867
- if (i === _e || i === Ee)
2867
+ if (i === Ee || i === Ae)
2868
2868
  if (!o && !s && !a) {
2869
2869
  const x = Math.cbrt(d);
2870
2870
  if (x % 1 !== 0)
@@ -2873,13 +2873,13 @@ function tl(r, e, t, n) {
2873
2873
  } else o && (!s || !a) ? (g = Et(r, i, s, a, d / o), s = g.width, a = g.height) : s && (!o || !a) ? (g = Et(r, i, o, a, d / s), o = g.width, a = g.height) : (g = Et(r, i, o, s, d / a), o = g.width, s = g.height);
2874
2874
  else
2875
2875
  g = Et(r, i, o, s, d), o = g.width, s = g.height;
2876
- if (Ci(r), r.pixelStorei(Zr, n.unpackAlignment || 1), Ne(r, n), i === se) {
2876
+ if (Oi(r), r.pixelStorei(Zr, n.unpackAlignment || 1), Ne(r, n), i === se) {
2877
2877
  const x = b / t.BYTES_PER_ELEMENT, v = d / 6 * x;
2878
- Pr(r, n).forEach((R) => {
2879
- const k = v * R.ndx, L = t.subarray(k, k + v);
2880
- r.texImage2D(R.face, c, u, o, s, 0, m, p, L);
2878
+ Pr(r, n).forEach((k) => {
2879
+ const R = v * k.ndx, L = t.subarray(R, R + v);
2880
+ r.texImage2D(k.face, c, u, o, s, 0, m, p, L);
2881
2881
  });
2882
- } else i === _e || i === Ee ? r.texImage3D(i, c, u, o, s, a, 0, m, p, t) : r.texImage2D(i, c, u, o, s, 0, m, p, t);
2882
+ } else i === Ee || i === Ae ? r.texImage3D(i, c, u, o, s, a, 0, m, p, t) : r.texImage2D(i, c, u, o, s, 0, m, p, t);
2883
2883
  return {
2884
2884
  width: o,
2885
2885
  height: s,
@@ -2894,9 +2894,9 @@ function rl(r, e, t) {
2894
2894
  if (Ne(r, t), n === se)
2895
2895
  for (let u = 0; u < 6; ++u)
2896
2896
  r.texImage2D(Jr + u, i, o, t.width, t.height, 0, a, c, null);
2897
- else n === _e || n === Ee ? r.texImage3D(n, i, o, t.width, t.height, t.depth, 0, a, c, null) : r.texImage2D(n, i, o, t.width, t.height, 0, a, c, null);
2897
+ else n === Ee || n === Ae ? r.texImage3D(n, i, o, t.width, t.height, t.depth, 0, a, c, null) : r.texImage2D(n, i, o, t.width, t.height, 0, a, c, null);
2898
2898
  }
2899
- function Di(r, e, t) {
2899
+ function Ui(r, e, t) {
2900
2900
  t = t || it, e = e || ae.textureOptions;
2901
2901
  const n = r.createTexture(), i = e.target || ce;
2902
2902
  let o = e.width || 1, s = e.height || 1;
@@ -2909,17 +2909,17 @@ function Di(r, e, t) {
2909
2909
  else if (Ke(c) || Array.isArray(c) && (typeof c[0] == "number" || Array.isArray(c[0]) || Ke(c[0]))) {
2910
2910
  const u = tl(r, n, c, e);
2911
2911
  o = u.width, s = u.height;
2912
- } else Array.isArray(c) && (typeof c[0] == "string" || Bi(c[0])) ? i === se ? Zu(r, n, e, t) : el(r, n, e, t) : (Mi(r, n, c, e), o = c.width, s = c.height);
2912
+ } else Array.isArray(c) && (typeof c[0] == "string" || Di(c[0])) ? i === se ? Zu(r, n, e, t) : el(r, n, e, t) : (Bi(r, n, c, e), o = c.width, s = c.height);
2913
2913
  else
2914
2914
  rl(r, n, e);
2915
- return Je(e) && Rr(r, n, e, o, s, a), Oi(r, n, e), n;
2915
+ return Je(e) && kr(r, n, e, o, s, a), Mi(r, n, e), n;
2916
2916
  }
2917
- const rn = bi;
2918
- function Ui(r) {
2917
+ const rn = wi;
2918
+ function Li(r) {
2919
2919
  return typeof document < "u" && document.getElementById ? document.getElementById(r) : null;
2920
2920
  }
2921
- const Kt = 33984, tr = 34962, nl = 34963, il = 35713, ol = 35714, sl = 35632, al = 35633, cl = 35981, Li = 35718, ul = 35721, ll = 35971, fl = 35382, dl = 35396, hl = 35398, ml = 35392, pl = 35395, rr = 5126, zi = 35664, Ni = 35665, $i = 35666, nn = 5124, Wi = 35667, Gi = 35668, Vi = 35669, Hi = 35670, ji = 35671, Yi = 35672, Qi = 35673, qi = 35674, Xi = 35675, Ki = 35676, gl = 35678, yl = 35680, bl = 35679, wl = 35682, xl = 35685, vl = 35686, _l = 35687, El = 35688, Al = 35689, Tl = 35690, Sl = 36289, Il = 36292, Rl = 36293, on = 5125, Ji = 36294, Zi = 36295, eo = 36296, kl = 36298, Pl = 36299, Fl = 36300, Cl = 36303, Ol = 36306, Ml = 36307, Bl = 36308, Dl = 36311, nr = 3553, ir = 34067, sn = 32879, or = 35866, w = {};
2922
- function to(r, e) {
2921
+ const Kt = 33984, tr = 34962, nl = 34963, il = 35713, ol = 35714, sl = 35632, al = 35633, cl = 35981, zi = 35718, ul = 35721, ll = 35971, fl = 35382, dl = 35396, hl = 35398, ml = 35392, pl = 35395, rr = 5126, Ni = 35664, $i = 35665, Wi = 35666, nn = 5124, Gi = 35667, Vi = 35668, Hi = 35669, ji = 35670, Yi = 35671, Qi = 35672, qi = 35673, Xi = 35674, Ki = 35675, Ji = 35676, gl = 35678, yl = 35680, bl = 35679, wl = 35682, xl = 35685, vl = 35686, _l = 35687, El = 35688, Al = 35689, Tl = 35690, Sl = 36289, Il = 36292, kl = 36293, on = 5125, Zi = 36294, eo = 36295, to = 36296, Rl = 36298, Pl = 36299, Fl = 36300, Cl = 36303, Ol = 36306, Ml = 36307, Bl = 36308, Dl = 36311, nr = 3553, ir = 34067, sn = 32879, or = 35866, w = {};
2922
+ function ro(r, e) {
2923
2923
  return w[e].bindPoint;
2924
2924
  }
2925
2925
  function Ul(r, e) {
@@ -2947,27 +2947,27 @@ function $l(r, e) {
2947
2947
  r.uniform4fv(e, t);
2948
2948
  };
2949
2949
  }
2950
- function ro(r, e) {
2950
+ function no(r, e) {
2951
2951
  return function(t) {
2952
2952
  r.uniform1i(e, t);
2953
2953
  };
2954
2954
  }
2955
- function no(r, e) {
2955
+ function io(r, e) {
2956
2956
  return function(t) {
2957
2957
  r.uniform1iv(e, t);
2958
2958
  };
2959
2959
  }
2960
- function io(r, e) {
2960
+ function oo(r, e) {
2961
2961
  return function(t) {
2962
2962
  r.uniform2iv(e, t);
2963
2963
  };
2964
2964
  }
2965
- function oo(r, e) {
2965
+ function so(r, e) {
2966
2966
  return function(t) {
2967
2967
  r.uniform3iv(e, t);
2968
2968
  };
2969
2969
  }
2970
- function so(r, e) {
2970
+ function ao(r, e) {
2971
2971
  return function(t) {
2972
2972
  r.uniform4iv(e, t);
2973
2973
  };
@@ -3043,7 +3043,7 @@ function tf(r, e) {
3043
3043
  };
3044
3044
  }
3045
3045
  function D(r, e, t, n) {
3046
- const i = to(r, e);
3046
+ const i = ro(r, e);
3047
3047
  return rt(r) ? function(o) {
3048
3048
  let s, a;
3049
3049
  !o || Xr(r, o) ? (s = o, a = null) : (s = o.texture, a = o.sampler), r.uniform1i(n, t), r.activeTexture(Kt + t), r.bindTexture(i, s), r.bindSampler(t, a);
@@ -3052,7 +3052,7 @@ function D(r, e, t, n) {
3052
3052
  };
3053
3053
  }
3054
3054
  function U(r, e, t, n, i) {
3055
- const o = to(r, e), s = new Int32Array(i);
3055
+ const o = ro(r, e), s = new Int32Array(i);
3056
3056
  for (let a = 0; a < i; ++a)
3057
3057
  s[a] = t + a;
3058
3058
  return rt(r) ? function(a) {
@@ -3068,24 +3068,24 @@ function U(r, e, t, n, i) {
3068
3068
  };
3069
3069
  }
3070
3070
  w[rr] = { Type: Float32Array, size: 4, setter: Ul, arraySetter: Ll };
3071
- w[zi] = { Type: Float32Array, size: 8, setter: zl, cols: 2 };
3072
- w[Ni] = { Type: Float32Array, size: 12, setter: Nl, cols: 3 };
3073
- w[$i] = { Type: Float32Array, size: 16, setter: $l, cols: 4 };
3074
- w[nn] = { Type: Int32Array, size: 4, setter: ro, arraySetter: no };
3075
- w[Wi] = { Type: Int32Array, size: 8, setter: io, cols: 2 };
3076
- w[Gi] = { Type: Int32Array, size: 12, setter: oo, cols: 3 };
3077
- w[Vi] = { Type: Int32Array, size: 16, setter: so, cols: 4 };
3071
+ w[Ni] = { Type: Float32Array, size: 8, setter: zl, cols: 2 };
3072
+ w[$i] = { Type: Float32Array, size: 12, setter: Nl, cols: 3 };
3073
+ w[Wi] = { Type: Float32Array, size: 16, setter: $l, cols: 4 };
3074
+ w[nn] = { Type: Int32Array, size: 4, setter: no, arraySetter: io };
3075
+ w[Gi] = { Type: Int32Array, size: 8, setter: oo, cols: 2 };
3076
+ w[Vi] = { Type: Int32Array, size: 12, setter: so, cols: 3 };
3077
+ w[Hi] = { Type: Int32Array, size: 16, setter: ao, cols: 4 };
3078
3078
  w[on] = { Type: Uint32Array, size: 4, setter: Wl, arraySetter: Gl };
3079
- w[Ji] = { Type: Uint32Array, size: 8, setter: Vl, cols: 2 };
3080
- w[Zi] = { Type: Uint32Array, size: 12, setter: Hl, cols: 3 };
3081
- w[eo] = { Type: Uint32Array, size: 16, setter: jl, cols: 4 };
3082
- w[Hi] = { Type: Uint32Array, size: 4, setter: ro, arraySetter: no };
3083
- w[ji] = { Type: Uint32Array, size: 8, setter: io, cols: 2 };
3084
- w[Yi] = { Type: Uint32Array, size: 12, setter: oo, cols: 3 };
3085
- w[Qi] = { Type: Uint32Array, size: 16, setter: so, cols: 4 };
3086
- w[qi] = { Type: Float32Array, size: 32, setter: Yl, rows: 2, cols: 2 };
3087
- w[Xi] = { Type: Float32Array, size: 48, setter: Ql, rows: 3, cols: 3 };
3088
- w[Ki] = { Type: Float32Array, size: 64, setter: ql, rows: 4, cols: 4 };
3079
+ w[Zi] = { Type: Uint32Array, size: 8, setter: Vl, cols: 2 };
3080
+ w[eo] = { Type: Uint32Array, size: 12, setter: Hl, cols: 3 };
3081
+ w[to] = { Type: Uint32Array, size: 16, setter: jl, cols: 4 };
3082
+ w[ji] = { Type: Uint32Array, size: 4, setter: no, arraySetter: io };
3083
+ w[Yi] = { Type: Uint32Array, size: 8, setter: oo, cols: 2 };
3084
+ w[Qi] = { Type: Uint32Array, size: 12, setter: so, cols: 3 };
3085
+ w[qi] = { Type: Uint32Array, size: 16, setter: ao, cols: 4 };
3086
+ w[Xi] = { Type: Float32Array, size: 32, setter: Yl, rows: 2, cols: 2 };
3087
+ w[Ki] = { Type: Float32Array, size: 48, setter: Ql, rows: 3, cols: 3 };
3088
+ w[Ji] = { Type: Float32Array, size: 64, setter: ql, rows: 4, cols: 4 };
3089
3089
  w[xl] = { Type: Float32Array, size: 32, setter: Xl, rows: 2, cols: 3 };
3090
3090
  w[vl] = { Type: Float32Array, size: 32, setter: Jl, rows: 2, cols: 4 };
3091
3091
  w[_l] = { Type: Float32Array, size: 48, setter: Kl, rows: 3, cols: 2 };
@@ -3098,8 +3098,8 @@ w[bl] = { Type: null, size: 0, setter: D, arraySetter: U, bindPoint: sn };
3098
3098
  w[wl] = { Type: null, size: 0, setter: D, arraySetter: U, bindPoint: nr };
3099
3099
  w[Sl] = { Type: null, size: 0, setter: D, arraySetter: U, bindPoint: or };
3100
3100
  w[Il] = { Type: null, size: 0, setter: D, arraySetter: U, bindPoint: or };
3101
- w[Rl] = { Type: null, size: 0, setter: D, arraySetter: U, bindPoint: ir };
3102
- w[kl] = { Type: null, size: 0, setter: D, arraySetter: U, bindPoint: nr };
3101
+ w[kl] = { Type: null, size: 0, setter: D, arraySetter: U, bindPoint: ir };
3102
+ w[Rl] = { Type: null, size: 0, setter: D, arraySetter: U, bindPoint: nr };
3103
3103
  w[Pl] = { Type: null, size: 0, setter: D, arraySetter: U, bindPoint: sn };
3104
3104
  w[Fl] = { Type: null, size: 0, setter: D, arraySetter: U, bindPoint: ir };
3105
3105
  w[Cl] = { Type: null, size: 0, setter: D, arraySetter: U, bindPoint: or };
@@ -3189,24 +3189,24 @@ function an(r, e, t) {
3189
3189
  }
3190
3190
  const I = {};
3191
3191
  I[rr] = { size: 4, setter: sr };
3192
- I[zi] = { size: 8, setter: sr };
3193
- I[Ni] = { size: 12, setter: sr };
3194
- I[$i] = { size: 16, setter: sr };
3192
+ I[Ni] = { size: 8, setter: sr };
3193
+ I[$i] = { size: 12, setter: sr };
3194
+ I[Wi] = { size: 16, setter: sr };
3195
3195
  I[nn] = { size: 4, setter: ue };
3196
- I[Wi] = { size: 8, setter: ue };
3197
- I[Gi] = { size: 12, setter: ue };
3198
- I[Vi] = { size: 16, setter: ue };
3196
+ I[Gi] = { size: 8, setter: ue };
3197
+ I[Vi] = { size: 12, setter: ue };
3198
+ I[Hi] = { size: 16, setter: ue };
3199
3199
  I[on] = { size: 4, setter: ar };
3200
- I[Ji] = { size: 8, setter: ar };
3201
- I[Zi] = { size: 12, setter: ar };
3202
- I[eo] = { size: 16, setter: ar };
3203
- I[Hi] = { size: 4, setter: ue };
3204
- I[ji] = { size: 8, setter: ue };
3205
- I[Yi] = { size: 12, setter: ue };
3206
- I[Qi] = { size: 16, setter: ue };
3207
- I[qi] = { size: 4, setter: an, count: 2 };
3208
- I[Xi] = { size: 9, setter: an, count: 3 };
3209
- I[Ki] = { size: 16, setter: an, count: 4 };
3200
+ I[Zi] = { size: 8, setter: ar };
3201
+ I[eo] = { size: 12, setter: ar };
3202
+ I[to] = { size: 16, setter: ar };
3203
+ I[ji] = { size: 4, setter: ue };
3204
+ I[Yi] = { size: 8, setter: ue };
3205
+ I[Qi] = { size: 12, setter: ue };
3206
+ I[qi] = { size: 16, setter: ue };
3207
+ I[Xi] = { size: 4, setter: an, count: 2 };
3208
+ I[Ki] = { size: 9, setter: an, count: 3 };
3209
+ I[Ji] = { size: 16, setter: an, count: 4 };
3210
3210
  const rf = /ERROR:\s*\d+:(\d+)/gi;
3211
3211
  function nf(r, e = "", t = 0) {
3212
3212
  const n = [...e.matchAll(rf)], i = new Map(n.map((o, s) => {
@@ -3222,10 +3222,10 @@ function nf(r, e = "", t = 0) {
3222
3222
  }).join(`
3223
3223
  `);
3224
3224
  }
3225
- const Jn = /^[ \t]*\n/;
3226
- function ao(r) {
3225
+ const Zn = /^[ \t]*\n/;
3226
+ function co(r) {
3227
3227
  let e = 0;
3228
- return Jn.test(r) && (e = 1, r = r.replace(Jn, "")), { lineOffset: e, shaderSource: r };
3228
+ return Zn.test(r) && (e = 1, r = r.replace(Zn, "")), { lineOffset: e, shaderSource: r };
3229
3229
  }
3230
3230
  function of(r, e) {
3231
3231
  return r.errorCallback(e), r.callback && setTimeout(() => {
@@ -3236,8 +3236,8 @@ ${r.errors.join(`
3236
3236
  }
3237
3237
  function sf(r, e, t, n) {
3238
3238
  if (n = n || rn, !r.getShaderParameter(t, il)) {
3239
- const o = r.getShaderInfoLog(t), { lineOffset: s, shaderSource: a } = ao(r.getShaderSource(t)), c = `${nf(a, o, s)}
3240
- Error compiling ${Ti(r, e)}: ${o}`;
3239
+ const o = r.getShaderInfoLog(t), { lineOffset: s, shaderSource: a } = co(r.getShaderSource(t)), c = `${nf(a, o, s)}
3240
+ Error compiling ${Si(r, e)}: ${o}`;
3241
3241
  return n(c), c;
3242
3242
  }
3243
3243
  return "";
@@ -3293,9 +3293,9 @@ function ff(r, e, t) {
3293
3293
  for (let a = 0; a < e.length; ++a) {
3294
3294
  let c = e[a];
3295
3295
  if (typeof c == "string") {
3296
- const u = Ui(c), f = u ? u.text : c;
3296
+ const u = Li(c), f = u ? u.text : c;
3297
3297
  let m = r[af[a]];
3298
- u && u.type && (m = cf(r, u.type) || m), c = r.createShader(m), r.shaderSource(c, ao(f).shaderSource), r.compileShader(c), r.attachShader(n, c);
3298
+ u && u.type && (m = cf(r, u.type) || m), c = r.createShader(m), r.shaderSource(c, co(f).shaderSource), r.compileShader(c), r.attachShader(n, c);
3299
3299
  }
3300
3300
  }
3301
3301
  Object.entries(i).forEach(([a, c]) => r.bindAttribLocation(n, c, a));
@@ -3340,7 +3340,7 @@ ${s.filter((a) => a).join(`
3340
3340
  function pf(r, e, t, n, i) {
3341
3341
  return df(r, e, t, n, i);
3342
3342
  }
3343
- function co(r) {
3343
+ function uo(r) {
3344
3344
  const e = r.name;
3345
3345
  return e.startsWith("gl_") || e.startsWith("webgl_");
3346
3346
  }
@@ -3359,7 +3359,7 @@ function bf(r, e, t, n) {
3359
3359
  const m = i[o++], p = m === "[", b = t[u] || (p ? [] : {});
3360
3360
  t[u] = b, t = b, n[s] = n[s] || /* @__PURE__ */ (function(d) {
3361
3361
  return function(g) {
3362
- uo(d, g);
3362
+ lo(d, g);
3363
3363
  };
3364
3364
  })(b), s += m;
3365
3365
  }
@@ -3379,10 +3379,10 @@ function wf(r, e) {
3379
3379
  p.arraySetter && f ? b = p.arraySetter(r, u) : b = p.setter(r, u);
3380
3380
  return b.location = u, b;
3381
3381
  }
3382
- const i = {}, o = {}, s = r.getProgramParameter(e, Li);
3382
+ const i = {}, o = {}, s = r.getProgramParameter(e, zi);
3383
3383
  for (let a = 0; a < s; ++a) {
3384
3384
  const c = r.getActiveUniform(e, a);
3385
- if (co(c))
3385
+ if (uo(c))
3386
3386
  continue;
3387
3387
  let u = c.name;
3388
3388
  u.endsWith("[0]") && (u = u.substr(0, u.length - 3));
@@ -3407,7 +3407,7 @@ function xf(r, e) {
3407
3407
  return t;
3408
3408
  }
3409
3409
  function vf(r, e) {
3410
- const t = r.getProgramParameter(e, Li), n = [], i = [];
3410
+ const t = r.getProgramParameter(e, zi), n = [], i = [];
3411
3411
  for (let a = 0; a < t; ++a) {
3412
3412
  i.push(a), n.push({});
3413
3413
  const c = r.getActiveUniform(e, a);
@@ -3441,20 +3441,20 @@ function vf(r, e) {
3441
3441
  uniformData: n
3442
3442
  };
3443
3443
  }
3444
- function uo(r, e) {
3444
+ function lo(r, e) {
3445
3445
  for (const t in e) {
3446
3446
  const n = r[t];
3447
- typeof n == "function" ? n(e[t]) : uo(r[t], e[t]);
3447
+ typeof n == "function" ? n(e[t]) : lo(r[t], e[t]);
3448
3448
  }
3449
3449
  }
3450
- function lo(r, ...e) {
3450
+ function fo(r, ...e) {
3451
3451
  const t = r.uniformSetters || r, n = e.length;
3452
3452
  for (let i = 0; i < n; ++i) {
3453
3453
  const o = e[i];
3454
3454
  if (Array.isArray(o)) {
3455
3455
  const s = o.length;
3456
3456
  for (let a = 0; a < s; ++a)
3457
- lo(t, o[a]);
3457
+ fo(t, o[a]);
3458
3458
  } else
3459
3459
  for (const s in o) {
3460
3460
  const a = t[s];
@@ -3466,7 +3466,7 @@ function _f(r, e) {
3466
3466
  const t = {}, n = r.getProgramParameter(e, ul);
3467
3467
  for (let i = 0; i < n; ++i) {
3468
3468
  const o = r.getActiveAttrib(e, i);
3469
- if (co(o))
3469
+ if (uo(o))
3470
3470
  continue;
3471
3471
  const s = r.getAttribLocation(e, o.name), a = I[o.type], c = a.setter(r, s, a);
3472
3472
  c.location = s, t[o.name] = c;
@@ -3482,7 +3482,7 @@ function Ef(r, e) {
3482
3482
  function Af(r, e, t) {
3483
3483
  t.vertexArrayObject ? r.bindVertexArray(t.vertexArrayObject) : (Ef(e.attribSetters || e, t.attribs), t.indices && r.bindBuffer(nl, t.indices));
3484
3484
  }
3485
- function Zn(r, e) {
3485
+ function ei(r, e) {
3486
3486
  const t = wf(r, e), n = _f(r, e), i = {
3487
3487
  program: e,
3488
3488
  uniformSetters: t,
@@ -3495,7 +3495,7 @@ function Sf(r, e, t, n, i) {
3495
3495
  const o = cn(t, n, i), s = [];
3496
3496
  if (e = e.map(function(u) {
3497
3497
  if (!Tf.test(u)) {
3498
- const f = Ui(u);
3498
+ const f = Li(u);
3499
3499
  if (f)
3500
3500
  u = f.text;
3501
3501
  else {
@@ -3508,26 +3508,26 @@ function Sf(r, e, t, n, i) {
3508
3508
  return of(o, "");
3509
3509
  const a = o.callback;
3510
3510
  a && (o.callback = (u, f) => {
3511
- a(u, u ? void 0 : Zn(r, f));
3511
+ a(u, u ? void 0 : ei(r, f));
3512
3512
  });
3513
3513
  const c = pf(r, e, o);
3514
- return c ? Zn(r, c) : null;
3514
+ return c ? ei(r, c) : null;
3515
3515
  }
3516
- const If = 4, ei = 5123;
3517
- function Rf(r, e, t, n, i, o) {
3516
+ const If = 4, ti = 5123;
3517
+ function kf(r, e, t, n, i, o) {
3518
3518
  t = t === void 0 ? If : t;
3519
3519
  const s = e.indices, a = e.elementType, c = n === void 0 ? e.numElements : n;
3520
- i = i === void 0 ? 0 : i, a || s ? o !== void 0 ? r.drawElementsInstanced(t, c, a === void 0 ? ei : e.elementType, i, o) : r.drawElements(t, c, a === void 0 ? ei : e.elementType, i) : o !== void 0 ? r.drawArraysInstanced(t, i, c, o) : r.drawArrays(t, i, c);
3520
+ i = i === void 0 ? 0 : i, a || s ? o !== void 0 ? r.drawElementsInstanced(t, c, a === void 0 ? ti : e.elementType, i, o) : r.drawElements(t, c, a === void 0 ? ti : e.elementType, i) : o !== void 0 ? r.drawArraysInstanced(t, i, c, o) : r.drawArrays(t, i, c);
3521
3521
  }
3522
- const fo = 36160, At = 36161, kf = 3553, Pf = 5121, Ff = 6402, Cf = 6408, Of = 33190, Mf = 36012, Bf = 35056, Df = 36013, Uf = 32854, Lf = 32855, zf = 36194, ho = 33189, mo = 6401, po = 36168, un = 34041, Fr = 36064, cr = 36096, go = 36128, ln = 33306, Cr = 33071, Or = 9729, Nf = [
3522
+ const ho = 36160, At = 36161, Rf = 3553, Pf = 5121, Ff = 6402, Cf = 6408, Of = 33190, Mf = 36012, Bf = 35056, Df = 36013, Uf = 32854, Lf = 32855, zf = 36194, mo = 33189, po = 6401, go = 36168, un = 34041, Fr = 36064, cr = 36096, yo = 36128, ln = 33306, Cr = 33071, Or = 9729, Nf = [
3523
3523
  { format: Cf, type: Pf, min: Or, wrap: Cr },
3524
3524
  { format: un }
3525
3525
  ], V = {};
3526
3526
  V[un] = ln;
3527
- V[mo] = go;
3528
- V[po] = go;
3527
+ V[po] = yo;
3528
+ V[go] = yo;
3529
3529
  V[Ff] = cr;
3530
- V[ho] = cr;
3530
+ V[mo] = cr;
3531
3531
  V[Of] = cr;
3532
3532
  V[Mf] = cr;
3533
3533
  V[Bf] = ln;
@@ -3540,9 +3540,9 @@ le[Uf] = !0;
3540
3540
  le[Lf] = !0;
3541
3541
  le[zf] = !0;
3542
3542
  le[un] = !0;
3543
- le[ho] = !0;
3544
3543
  le[mo] = !0;
3545
3544
  le[po] = !0;
3545
+ le[go] = !0;
3546
3546
  function Wf(r) {
3547
3547
  return le[r];
3548
3548
  }
@@ -3550,8 +3550,8 @@ const Gf = 32;
3550
3550
  function Vf(r) {
3551
3551
  return r >= Fr && r < Fr + Gf;
3552
3552
  }
3553
- function ti(r, e, t, n) {
3554
- const i = fo, o = r.createFramebuffer();
3553
+ function ri(r, e, t, n) {
3554
+ const i = ho, o = r.createFramebuffer();
3555
3555
  r.bindFramebuffer(i, o), t = t || r.drawingBufferWidth, n = n || r.drawingBufferHeight, e = e || Nf;
3556
3556
  const s = [], a = {
3557
3557
  framebuffer: o,
@@ -3568,7 +3568,7 @@ function ti(r, e, t, n) {
3568
3568
  f = r.createRenderbuffer(), r.bindRenderbuffer(At, f), m > 1 ? r.renderbufferStorageMultisample(At, m, p, t, n) : r.renderbufferStorage(At, p, t, n);
3569
3569
  else {
3570
3570
  const d = Object.assign({}, c);
3571
- d.width = t, d.height = n, d.auto === void 0 && (d.auto = !1, d.min = d.min || d.minMag || Or, d.mag = d.mag || d.minMag || Or, d.wrapS = d.wrapS || d.wrap || Cr, d.wrapT = d.wrapT || d.wrap || Cr), f = Di(r, d);
3571
+ d.width = t, d.height = n, d.auto === void 0 && (d.auto = !1, d.min = d.min || d.minMag || Or, d.mag = d.mag || d.minMag || Or, d.wrapS = d.wrapS || d.wrap || Cr, d.wrapT = d.wrapT || d.wrap || Cr), f = Ui(r, d);
3572
3572
  }
3573
3573
  if (Ja(r, f))
3574
3574
  r.framebufferRenderbuffer(i, b, At, f);
@@ -3582,7 +3582,7 @@ function ti(r, e, t, n) {
3582
3582
  ) : r.framebufferTexture2D(
3583
3583
  i,
3584
3584
  b,
3585
- c.target || kf,
3585
+ c.target || Rf,
3586
3586
  f,
3587
3587
  c.level || 0
3588
3588
  );
@@ -3592,10 +3592,10 @@ function ti(r, e, t, n) {
3592
3592
  }), r.drawBuffers && r.drawBuffers(s), a;
3593
3593
  }
3594
3594
  function Hf(r, e, t) {
3595
- t = t || fo, e ? (r.bindFramebuffer(t, e.framebuffer), r.viewport(0, 0, e.width, e.height)) : (r.bindFramebuffer(t, null), r.viewport(0, 0, r.drawingBufferWidth, r.drawingBufferHeight));
3595
+ t = t || ho, e ? (r.bindFramebuffer(t, e.framebuffer), r.viewport(0, 0, e.width, e.height)) : (r.bindFramebuffer(t, null), r.viewport(0, 0, r.drawingBufferWidth, r.drawingBufferHeight));
3596
3596
  }
3597
3597
  function B(r, e) {
3598
- return () => e instanceof WebGLTexture ? e : Di(r, {
3598
+ return () => e instanceof WebGLTexture ? e : Ui(r, {
3599
3599
  src: e,
3600
3600
  wrap: r.CLAMP_TO_EDGE
3601
3601
  });
@@ -3613,7 +3613,7 @@ class ot {
3613
3613
  ]), this.bufferInfo = _c(
3614
3614
  this.context,
3615
3615
  this.getBuffers()
3616
- ), this.fbi = ti(
3616
+ ), this.fbi = ri(
3617
3617
  this.context,
3618
3618
  [
3619
3619
  {
@@ -3628,7 +3628,7 @@ class ot {
3628
3628
  ), this.output = this.fbi.attachments[0];
3629
3629
  }
3630
3630
  resizeOutput(e, t) {
3631
- this.fbi = ti(
3631
+ this.fbi = ri(
3632
3632
  this.context,
3633
3633
  [
3634
3634
  {
@@ -3700,14 +3700,14 @@ class ot {
3700
3700
  this.context,
3701
3701
  this.programInfo,
3702
3702
  this.bufferInfo
3703
- ), lo(this.programInfo, {
3703
+ ), fo(this.programInfo, {
3704
3704
  delta: n,
3705
3705
  canvas: [this.context.canvas.width, this.context.canvas.height],
3706
3706
  ...e
3707
3707
  }), Hf(
3708
3708
  this.context,
3709
3709
  this.options.disableFramebuffer ? null : this.fbi
3710
- ), Rf(this.context, this.bufferInfo), this.profiler?.popContext(
3710
+ ), kf(this.context, this.bufferInfo), this.profiler?.popContext(
3711
3711
  `[${this.id}] PROG : ${this.constructor.name}`
3712
3712
  );
3713
3713
  }
@@ -3788,7 +3788,7 @@ class hn extends dn {
3788
3788
  super(...arguments), this.preciseMaskEnabled = !1;
3789
3789
  }
3790
3790
  }
3791
- class yo extends hn {
3791
+ class bo extends hn {
3792
3792
  constructor(e) {
3793
3793
  super(), this.context = e, this.preciseMaskEnabled = !0;
3794
3794
  const t = {
@@ -3860,7 +3860,7 @@ class Kf extends dn {
3860
3860
  this.inputImage = e;
3861
3861
  }
3862
3862
  }
3863
- async function bo(r) {
3863
+ async function wo(r) {
3864
3864
  return new Promise((e) => {
3865
3865
  setTimeout(() => {
3866
3866
  e();
@@ -3888,7 +3888,7 @@ void main() {
3888
3888
  }
3889
3889
  `;
3890
3890
  var mn = /* @__PURE__ */ ((r) => (r[r.LINEAR = 0] = "LINEAR", r[r.GAUSSIAN = 1] = "GAUSSIAN", r))(mn || {});
3891
- class wo extends ot {
3891
+ class xo extends ot {
3892
3892
  getDefines() {
3893
3893
  return { RADIUS: this.options.radius ?? 1 };
3894
3894
  }
@@ -3993,7 +3993,7 @@ class nd extends dn {
3993
3993
  context: e,
3994
3994
  height: n,
3995
3995
  width: t
3996
- }, o = new wo({
3996
+ }, o = new xo({
3997
3997
  ...i,
3998
3998
  radius: 1,
3999
3999
  type: mn.GAUSSIAN
@@ -4033,7 +4033,7 @@ class nd extends dn {
4033
4033
  super.resizeOutput(e, t), this.output = this.jointBilateral.output;
4034
4034
  }
4035
4035
  }
4036
- var xo = /* @__PURE__ */ ((r) => (r.PUSH = "PUSH", r.POP = "POP", r))(xo || {});
4036
+ var vo = /* @__PURE__ */ ((r) => (r.PUSH = "PUSH", r.POP = "POP", r))(vo || {});
4037
4037
  class id {
4038
4038
  constructor(e) {
4039
4039
  this.queries = [], this.context = e, this.extension = e.getExtension(
@@ -4096,7 +4096,7 @@ class id {
4096
4096
  this.context.QUERY_RESULT_AVAILABLE
4097
4097
  ))
4098
4098
  return e;
4099
- await bo(200);
4099
+ await wo(200);
4100
4100
  }
4101
4101
  }
4102
4102
  }
@@ -4120,7 +4120,7 @@ class ur {
4120
4120
  }
4121
4121
  async profileWebgl(e) {
4122
4122
  const t = new id(this.context);
4123
- return this.profiler = t, t.start(), await bo(e), this.profiler = void 0, t.stop(), t.getResolvedQueries();
4123
+ return this.profiler = t, t.start(), await wo(e), this.profiler = void 0, t.stop(), t.getResolvedQueries();
4124
4124
  }
4125
4125
  async render(e, t) {
4126
4126
  if (!this.pipeline)
@@ -4140,9 +4140,9 @@ class ur {
4140
4140
  e && e.loseContext();
4141
4141
  }
4142
4142
  }
4143
- class vo extends ur {
4143
+ class _o extends ur {
4144
4144
  constructor() {
4145
- super(), this.pipeline = new yo(this.context);
4145
+ super(), this.pipeline = new bo(this.context);
4146
4146
  const e = new OffscreenCanvas(0, 0), t = e.getContext("webgl2");
4147
4147
  if (!t)
4148
4148
  throw "Fail to retrieve webgl context";
@@ -4167,7 +4167,7 @@ class vo extends ur {
4167
4167
  e && e.loseContext(), super.destroy();
4168
4168
  }
4169
4169
  }
4170
- class od extends vo {
4170
+ class od extends _o {
4171
4171
  setBackgroundVideo(e) {
4172
4172
  this.frameReader = e;
4173
4173
  }
@@ -4182,7 +4182,7 @@ class od extends vo {
4182
4182
  }
4183
4183
  }
4184
4184
  }
4185
- class ri {
4185
+ class ni {
4186
4186
  blurBackground(e) {
4187
4187
  return new za(e);
4188
4188
  }
@@ -4316,7 +4316,7 @@ class md extends hn {
4316
4316
  context: e,
4317
4317
  height: e.canvas.height,
4318
4318
  width: e.canvas.width
4319
- }, i = new wo({
4319
+ }, i = new xo({
4320
4320
  ...n,
4321
4321
  radius: t,
4322
4322
  type: mn.GAUSSIAN
@@ -4344,7 +4344,7 @@ class pd extends ur {
4344
4344
  super(), this.pipeline = new md(this.context, e), this.disablePostProcessing();
4345
4345
  }
4346
4346
  }
4347
- class gd extends yo {
4347
+ class gd extends bo {
4348
4348
  constructor() {
4349
4349
  super(...arguments), this.preciseMaskEnabled = !0;
4350
4350
  }
@@ -4367,7 +4367,7 @@ class yd extends ur {
4367
4367
  this.pipeline.reader = e;
4368
4368
  }
4369
4369
  }
4370
- class ni {
4370
+ class ii {
4371
4371
  blurBackground(e) {
4372
4372
  return new hd(e);
4373
4373
  }
@@ -4375,7 +4375,7 @@ class ni {
4375
4375
  return new pd(e);
4376
4376
  }
4377
4377
  imageBackground() {
4378
- return new vo();
4378
+ return new _o();
4379
4379
  }
4380
4380
  videoBackground() {
4381
4381
  return new yd();
@@ -4385,14 +4385,14 @@ class bd {
4385
4385
  constructor(e) {
4386
4386
  switch (e) {
4387
4387
  case Mt.CANVAS:
4388
- this.factory = new ri();
4388
+ this.factory = new ni();
4389
4389
  break;
4390
4390
  case Mt.WEBGL:
4391
- this.factory = new ni();
4391
+ this.factory = new ii();
4392
4392
  break;
4393
4393
  default:
4394
- const t = li();
4395
- this.factory = t.supported ? new ni() : new ri();
4394
+ const t = fi();
4395
+ this.factory = t.supported ? new ii() : new ni();
4396
4396
  }
4397
4397
  }
4398
4398
  blurBackground(e) {
@@ -4494,11 +4494,11 @@ var xd = (function() {
4494
4494
  o = null, t.arguments && t.arguments, t.thisProgram && (a = t.thisProgram), t.quit && (c = t.quit);
4495
4495
  var g;
4496
4496
  t.wasmBinary && (g = t.wasmBinary), t.noExitRuntime, typeof WebAssembly != "object" && Z("no native wasm support detected");
4497
- var x, v = !1, R = typeof TextDecoder < "u" ? new TextDecoder("utf8") : void 0;
4498
- function k(l, h, y) {
4497
+ var x, v = !1, k = typeof TextDecoder < "u" ? new TextDecoder("utf8") : void 0;
4498
+ function R(l, h, y) {
4499
4499
  for (var _ = h + y, S = h; l[S] && !(S >= _); ) ++S;
4500
- if (S - h > 16 && l.subarray && R)
4501
- return R.decode(l.subarray(h, S));
4500
+ if (S - h > 16 && l.subarray && k)
4501
+ return k.decode(l.subarray(h, S));
4502
4502
  for (var P = ""; h < S; ) {
4503
4503
  var E = l[h++];
4504
4504
  if (!(E & 128)) {
@@ -4521,7 +4521,7 @@ var xd = (function() {
4521
4521
  return P;
4522
4522
  }
4523
4523
  function L(l, h) {
4524
- return l ? k($e, l, h) : "";
4524
+ return l ? R($e, l, h) : "";
4525
4525
  }
4526
4526
  function Y(l, h, y) {
4527
4527
  for (var _ = 0; _ < l.length; ++_)
@@ -4537,35 +4537,35 @@ var xd = (function() {
4537
4537
  }
4538
4538
  t.INITIAL_MEMORY;
4539
4539
  var lr, bn = [], wn = [], xn = [];
4540
- function Eo() {
4540
+ function Ao() {
4541
4541
  if (t.preRun)
4542
4542
  for (typeof t.preRun == "function" && (t.preRun = [t.preRun]); t.preRun.length; )
4543
- So(t.preRun.shift());
4543
+ Io(t.preRun.shift());
4544
4544
  fr(bn);
4545
4545
  }
4546
- function Ao() {
4546
+ function To() {
4547
4547
  fr(wn);
4548
4548
  }
4549
- function To() {
4549
+ function So() {
4550
4550
  if (t.postRun)
4551
4551
  for (typeof t.postRun == "function" && (t.postRun = [t.postRun]); t.postRun.length; )
4552
4552
  Ro(t.postRun.shift());
4553
4553
  fr(xn);
4554
4554
  }
4555
- function So(l) {
4555
+ function Io(l) {
4556
4556
  bn.unshift(l);
4557
4557
  }
4558
- function Io(l) {
4558
+ function ko(l) {
4559
4559
  wn.unshift(l);
4560
4560
  }
4561
4561
  function Ro(l) {
4562
4562
  xn.unshift(l);
4563
4563
  }
4564
4564
  var fe = 0, We = null;
4565
- function ko(l) {
4565
+ function Po(l) {
4566
4566
  fe++, t.monitorRunDependencies && t.monitorRunDependencies(fe);
4567
4567
  }
4568
- function Po(l) {
4568
+ function Fo(l) {
4569
4569
  if (fe--, t.monitorRunDependencies && t.monitorRunDependencies(fe), fe == 0 && We) {
4570
4570
  var h = We;
4571
4571
  We = null, h();
@@ -4577,9 +4577,9 @@ var xd = (function() {
4577
4577
  var h = new WebAssembly.RuntimeError(l);
4578
4578
  throw i(h), h;
4579
4579
  }
4580
- var Fo = "data:application/octet-stream;base64,";
4580
+ var Co = "data:application/octet-stream;base64,";
4581
4581
  function vn(l) {
4582
- return l.startsWith(Fo);
4582
+ return l.startsWith(Co);
4583
4583
  }
4584
4584
  var W;
4585
4585
  W = "tflite-simd.wasm", vn(W) || (W = m(W));
@@ -4592,7 +4592,7 @@ var xd = (function() {
4592
4592
  Z(h);
4593
4593
  }
4594
4594
  }
4595
- function Co() {
4595
+ function Oo() {
4596
4596
  return !g && u && typeof fetch == "function" ? fetch(W, { credentials: "same-origin" }).then(function(l) {
4597
4597
  if (!l.ok)
4598
4598
  throw "failed to load wasm binary file at '" + W + "'";
@@ -4603,18 +4603,18 @@ var xd = (function() {
4603
4603
  return _n(W);
4604
4604
  });
4605
4605
  }
4606
- function Oo() {
4607
- var l = { a: es };
4606
+ function Mo() {
4607
+ var l = { a: ts };
4608
4608
  function h(E, O) {
4609
4609
  var H = E.exports;
4610
- t.asm = H, x = t.asm.q, yn(x.buffer), lr = t.asm.E, Io(t.asm.r), Po();
4610
+ t.asm = H, x = t.asm.q, yn(x.buffer), lr = t.asm.E, ko(t.asm.r), Fo();
4611
4611
  }
4612
- ko();
4612
+ Po();
4613
4613
  function y(E) {
4614
4614
  h(E.instance);
4615
4615
  }
4616
4616
  function _(E) {
4617
- return Co().then(function(O) {
4617
+ return Oo().then(function(O) {
4618
4618
  return WebAssembly.instantiate(O, l);
4619
4619
  }).then(function(O) {
4620
4620
  return O;
@@ -4650,49 +4650,49 @@ var xd = (function() {
4650
4650
  typeof y == "number" ? h.arg === void 0 ? lr.get(y)() : lr.get(y)(h.arg) : y(h.arg === void 0 ? null : h.arg);
4651
4651
  }
4652
4652
  }
4653
- function Mo(l, h, y, _) {
4653
+ function Bo(l, h, y, _) {
4654
4654
  Z("Assertion failed: " + L(l) + ", at: " + [h ? L(h) : "unknown filename", y, _ ? L(_) : "unknown function"]);
4655
4655
  }
4656
- function Bo(l, h) {
4656
+ function Do(l, h) {
4657
4657
  Z("To use dlopen, you need to use Emscripten's linking support, see https://github.com/emscripten-core/emscripten/wiki/Linking");
4658
4658
  }
4659
- function Do(l, h) {
4659
+ function Uo(l, h) {
4660
4660
  Z("To use dlopen, you need to use Emscripten's linking support, see https://github.com/emscripten-core/emscripten/wiki/Linking");
4661
4661
  }
4662
- function Uo() {
4662
+ function Lo() {
4663
4663
  Z("");
4664
4664
  }
4665
4665
  var at;
4666
4666
  at = function() {
4667
4667
  return performance.now();
4668
4668
  };
4669
- var Lo = !0;
4670
- function zo(l) {
4669
+ var zo = !0;
4670
+ function No(l) {
4671
4671
  return $[En() >> 2] = l, l;
4672
4672
  }
4673
- function No(l, h) {
4673
+ function $o(l, h) {
4674
4674
  var y;
4675
4675
  if (l === 0)
4676
4676
  y = Date.now();
4677
- else if ((l === 1 || l === 4) && Lo)
4677
+ else if ((l === 1 || l === 4) && zo)
4678
4678
  y = at();
4679
4679
  else
4680
- return zo(28), -1;
4680
+ return No(28), -1;
4681
4681
  return $[h >> 2] = y / 1e3 | 0, $[h + 4 >> 2] = y % 1e3 * 1e3 * 1e3 | 0, 0;
4682
4682
  }
4683
- function $o() {
4683
+ function Wo() {
4684
4684
  return 2147483648;
4685
4685
  }
4686
- function Wo(l, h, y) {
4686
+ function Go(l, h, y) {
4687
4687
  $e.copyWithin(l, h, h + y);
4688
4688
  }
4689
- function Go(l) {
4689
+ function Vo(l) {
4690
4690
  try {
4691
4691
  return x.grow(l - N.byteLength + 65535 >>> 16), yn(x.buffer), 1;
4692
4692
  } catch {
4693
4693
  }
4694
4694
  }
4695
- function Vo(l) {
4695
+ function Ho(l) {
4696
4696
  var h = $e.length;
4697
4697
  l = l >>> 0;
4698
4698
  var y = 2147483648;
@@ -4701,23 +4701,23 @@ var xd = (function() {
4701
4701
  for (var _ = 1; _ <= 4; _ *= 2) {
4702
4702
  var S = h * (1 + 0.2 / _);
4703
4703
  S = Math.min(S, l + 100663296);
4704
- var P = Math.min(y, Q(Math.max(l, S), 65536)), E = Go(P);
4704
+ var P = Math.min(y, Q(Math.max(l, S), 65536)), E = Vo(P);
4705
4705
  if (E)
4706
4706
  return !0;
4707
4707
  }
4708
4708
  return !1;
4709
4709
  }
4710
- function Ho(l) {
4710
+ function jo(l) {
4711
4711
  for (var h = at(); at() - h < l; )
4712
4712
  ;
4713
4713
  }
4714
4714
  var dr = {};
4715
- function jo() {
4715
+ function Yo() {
4716
4716
  return a || "./this.program";
4717
4717
  }
4718
4718
  function Ge() {
4719
4719
  if (!Ge.strings) {
4720
- var l = (typeof navigator == "object" && navigator.languages && navigator.languages[0] || "C").replace("-", "_") + ".UTF-8", h = { USER: "web_user", LOGNAME: "web_user", PATH: "/", PWD: "/", HOME: "/home/web_user", LANG: l, _: jo() };
4720
+ var l = (typeof navigator == "object" && navigator.languages && navigator.languages[0] || "C").replace("-", "_") + ".UTF-8", h = { USER: "web_user", LOGNAME: "web_user", PATH: "/", PWD: "/", HOME: "/home/web_user", LANG: l, _: Yo() };
4721
4721
  for (var y in dr)
4722
4722
  dr[y] === void 0 ? delete h[y] : h[y] = dr[y];
4723
4723
  var _ = [];
@@ -4729,7 +4729,7 @@ var xd = (function() {
4729
4729
  }
4730
4730
  var ct = { mappings: {}, buffers: [null, [], []], printChar: function(l, h) {
4731
4731
  var y = ct.buffers[l];
4732
- h === 0 || h === 10 ? ((l === 1 ? b : d)(k(y, 0)), y.length = 0) : y.push(h);
4732
+ h === 0 || h === 10 ? ((l === 1 ? b : d)(R(y, 0)), y.length = 0) : y.push(h);
4733
4733
  }, varargs: void 0, get: function() {
4734
4734
  ct.varargs += 4;
4735
4735
  var l = $[ct.varargs - 4 >> 2];
@@ -4740,14 +4740,14 @@ var xd = (function() {
4740
4740
  }, get64: function(l, h) {
4741
4741
  return l;
4742
4742
  } };
4743
- function Yo(l, h) {
4743
+ function Qo(l, h) {
4744
4744
  var y = 0;
4745
4745
  return Ge().forEach(function(_, S) {
4746
4746
  var P = h + y;
4747
4747
  $[l + S * 4 >> 2] = P, Y(_, P), y += _.length + 1;
4748
4748
  }), 0;
4749
4749
  }
4750
- function Qo(l, h) {
4750
+ function qo(l, h) {
4751
4751
  var y = Ge();
4752
4752
  $[l >> 2] = y.length;
4753
4753
  var _ = 0;
@@ -4755,15 +4755,15 @@ var xd = (function() {
4755
4755
  _ += S.length + 1;
4756
4756
  }), $[h >> 2] = _, 0;
4757
4757
  }
4758
- function qo(l) {
4759
- rs(l);
4760
- }
4761
4758
  function Xo(l) {
4759
+ ns(l);
4760
+ }
4761
+ function Ko(l) {
4762
4762
  return 0;
4763
4763
  }
4764
- function Ko(l, h, y, _, S) {
4764
+ function Jo(l, h, y, _, S) {
4765
4765
  }
4766
- function Jo(l, h, y, _) {
4766
+ function Zo(l, h, y, _) {
4767
4767
  for (var S = 0, P = 0; P < y; P++) {
4768
4768
  for (var E = $[h + P * 8 >> 2], O = $[h + (P * 8 + 4) >> 2], H = 0; H < O; H++)
4769
4769
  ct.printChar(l, $e[E + H]);
@@ -4771,7 +4771,7 @@ var xd = (function() {
4771
4771
  }
4772
4772
  return $[_ >> 2] = S, 0;
4773
4773
  }
4774
- function Zo() {
4774
+ function es() {
4775
4775
  if (typeof crypto == "object" && typeof crypto.getRandomValues == "function") {
4776
4776
  var l = new Uint8Array(1);
4777
4777
  return function() {
@@ -4782,13 +4782,13 @@ var xd = (function() {
4782
4782
  };
4783
4783
  }
4784
4784
  function ut(l, h) {
4785
- ut.randomDevice || (ut.randomDevice = Zo());
4785
+ ut.randomDevice || (ut.randomDevice = es());
4786
4786
  for (var y = 0; y < h; y++)
4787
4787
  st[l + y >> 0] = ut.randomDevice();
4788
4788
  return 0;
4789
4789
  }
4790
- var es = { a: Mo, e: Bo, d: Do, b: Uo, n: No, h: $o, l: Wo, m: Vo, p: Ho, f: Yo, g: Qo, j: qo, i: Xo, k: Ko, c: Jo, o: ut };
4791
- Oo(), t.___wasm_call_ctors = function() {
4790
+ var ts = { a: Bo, e: Do, d: Uo, b: Lo, n: $o, h: Wo, l: Go, m: Ho, p: jo, f: Qo, g: qo, j: Xo, i: Ko, k: Jo, c: Zo, o: ut };
4791
+ Mo(), t.___wasm_call_ctors = function() {
4792
4792
  return (t.___wasm_call_ctors = t.asm.r).apply(null, arguments);
4793
4793
  }, t._getModelBufferMemoryOffset = function() {
4794
4794
  return (t._getModelBufferMemoryOffset = t.asm.s).apply(null, arguments);
@@ -4818,17 +4818,17 @@ var xd = (function() {
4818
4818
  var En = t.___errno_location = function() {
4819
4819
  return (En = t.___errno_location = t.asm.F).apply(null, arguments);
4820
4820
  }, lt;
4821
- function ts(l) {
4821
+ function rs(l) {
4822
4822
  this.name = "ExitStatus", this.message = "Program terminated with exit(" + l + ")", this.status = l;
4823
4823
  }
4824
4824
  We = function l() {
4825
4825
  lt || hr(), lt || (We = l);
4826
4826
  };
4827
4827
  function hr(l) {
4828
- if (fe > 0 || (Eo(), fe > 0))
4828
+ if (fe > 0 || (Ao(), fe > 0))
4829
4829
  return;
4830
4830
  function h() {
4831
- lt || (lt = !0, t.calledRun = !0, !v && (Ao(), n(t), t.onRuntimeInitialized && t.onRuntimeInitialized(), To()));
4831
+ lt || (lt = !0, t.calledRun = !0, !v && (To(), n(t), t.onRuntimeInitialized && t.onRuntimeInitialized(), So()));
4832
4832
  }
4833
4833
  t.setStatus ? (t.setStatus("Running..."), setTimeout(function() {
4834
4834
  setTimeout(function() {
@@ -4837,11 +4837,11 @@ var xd = (function() {
4837
4837
  }, 1)) : h();
4838
4838
  }
4839
4839
  t.run = hr;
4840
- function rs(l, h) {
4841
- ns(l);
4840
+ function ns(l, h) {
4841
+ is(l);
4842
4842
  }
4843
- function ns(l) {
4844
- c(l, new ts(l));
4843
+ function is(l) {
4844
+ c(l, new rs(l));
4845
4845
  }
4846
4846
  if (t.preInit)
4847
4847
  for (typeof t.preInit == "function" && (t.preInit = [t.preInit]); t.preInit.length > 0; )
@@ -4925,7 +4925,7 @@ async function Ad(r = _d, e = Ed) {
4925
4925
  return n;
4926
4926
  }
4927
4927
  const Td = 0.1, Sd = 0.7, Id = "https://d3opqjmqzxf057.cloudfront.net/ml/vonage_selfie_segmenter/float16/v1/vonage_selfie_segmenter.tflite";
4928
- class Rd {
4928
+ class kd {
4929
4929
  constructor() {
4930
4930
  this.canvas = new OffscreenCanvas(0, 0), this.context = this.canvas.getContext(
4931
4931
  "2d",
@@ -5014,7 +5014,7 @@ class Rd {
5014
5014
  return t + (e - t) * (f * 0.9);
5015
5015
  }
5016
5016
  }
5017
- class kd {
5017
+ class Rd {
5018
5018
  constructor() {
5019
5019
  this.canvas = new OffscreenCanvas(0, 0), this.context = this.canvas.getContext(
5020
5020
  "2d",
@@ -5068,14 +5068,14 @@ class kd {
5068
5068
  }
5069
5069
  class Pd {
5070
5070
  constructor() {
5071
- this.reporter = new Ua(), this.isEnabled = !0;
5071
+ this.reporter = new Ua(), this.isEnabled = !0, this.avoidOriginalTrackLeak = !1;
5072
5072
  }
5073
5073
  async init(e, t) {
5074
- t.segmentationOptions?.lightWeightEngine === !0 ? this.selfieSegmentation = new kd() : this.selfieSegmentation = new Rd(), this.selfieSegmentation?.init(
5074
+ t.segmentationOptions?.lightWeightEngine === !0 ? this.selfieSegmentation = new Rd() : this.selfieSegmentation = new kd(), this.selfieSegmentation?.init(
5075
5075
  t.modelAssetUriPath,
5076
5076
  t.mediapipeBaseAssetsUri,
5077
5077
  t.segmentationOptions?.gpuSupport
5078
- ), this.backgroundFilter = new wd(), this.report({
5078
+ ), this.avoidOriginalTrackLeak = t.avoidOriginalTrackLeak, this.backgroundFilter = new wd(), this.report({
5079
5079
  variation: "Create"
5080
5080
  });
5081
5081
  }
@@ -5084,7 +5084,7 @@ class Pd {
5084
5084
  return t.enqueue(e);
5085
5085
  let n;
5086
5086
  const i = e.timestamp ?? 0, o = await createImageBitmap(e), s = await this.selfieSegmentation?.process(o);
5087
- s && (n = await this.backgroundFilter?.process(o, s)), n ? (e.close(), t.enqueue(
5087
+ s && (n = await this.backgroundFilter?.process(o, s)), !n && this.avoidOriginalTrackLeak && (n = new OffscreenCanvas(o.width, o.height)), n ? (e.close(), t.enqueue(
5088
5088
  new VideoFrame(n, {
5089
5089
  timestamp: i,
5090
5090
  alpha: "discard"
@@ -5126,7 +5126,7 @@ class Pd {
5126
5126
  }
5127
5127
  const pn = class pn {
5128
5128
  constructor() {
5129
- this.backgroundTransformer = new Pd(), this.mediaProcessor = new ui(), this.rate = 30, this.eventsQueue = [], this.frameTransformLatencyMs = [];
5129
+ this.backgroundTransformer = new Pd(), this.mediaProcessor = new li(), this.rate = 30, this.eventsQueue = [], this.frameTransformLatencyMs = [];
5130
5130
  }
5131
5131
  async init(e, t) {
5132
5132
  this.frameTransformLatencyMs = [], await this.backgroundTransformer.init(e, t), await this.mediaProcessor.setTransformers([this.backgroundTransformer]), this.mediaProcessor.setTrackExpectedRate(this.rate), this.mediaProcessor.onAny((n, i) => {
@@ -5166,7 +5166,7 @@ const pn = class pn {
5166
5166
  console.log(`Transform latency average is: ${t} ms`);
5167
5167
  }
5168
5168
  setVonageMetadata(e) {
5169
- Cs(e);
5169
+ Os(e);
5170
5170
  }
5171
5171
  async profile(e) {
5172
5172
  return JSON.stringify(
@@ -5176,11 +5176,11 @@ const pn = class pn {
5176
5176
  };
5177
5177
  ua("ProcessorWorker", pn);
5178
5178
  let Mr = pn;
5179
- const _o = '(function(){"use strict";function Vt(r,e){globalThis.vonage||(globalThis.vonage={}),globalThis.vonage.workerizer||(globalThis.vonage.workerizer={});let t=globalThis.vonage.workerizer;return t[r]||(t[r]=e),t[r]}const Vr=Vt("globals",{});var xe=(r=>(r.INIT="INIT",r.FORWARD="FORWARD",r.TERMINATE="TERMINATE",r.GLOBALS_SYNC="GLOBALS_SYNC",r.EVENT="EVENT",r))(xe||{});function zi(r){return[ImageBitmap,ReadableStream,WritableStream].some(t=>r instanceof t)}function Be(r,e){const{id:t,type:n}=r,i=Array.isArray(e)?e:[e];postMessage({id:t,type:n,result:e},i.filter(s=>zi(s)))}Vt("workerized",{});function Hr(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function qe(r,e){if(Array.isArray(e))e.splice(0,e.length);else if(typeof e=="object")for(const t in e)delete e[t];for(const t in r)Array.isArray(r[t])?(e[t]=[],qe(r[t],e[t])):typeof r[t]=="object"?(e[t]={},qe(r[t],e[t])):e[t]=r[t]}const K=new WeakMap,ce=new WeakMap,j=new WeakMap,Ke=Symbol("anyProducer"),jr=Promise.resolve(),Je=Symbol("listenerAdded"),Ze=Symbol("listenerRemoved");let et=!1,Ht=!1;function _e(r){if(typeof r!="string"&&typeof r!="symbol"&&typeof r!="number")throw new TypeError("`eventName` must be a string, symbol, or number")}function tt(r){if(typeof r!="function")throw new TypeError("listener must be a function")}function Ee(r,e){const t=ce.get(r);if(t.has(e))return t.get(e)}function De(r,e){const t=typeof e=="string"||typeof e=="symbol"||typeof e=="number"?e:Ke,n=j.get(r);if(n.has(t))return n.get(t)}function Gi(r,e,t){const n=j.get(r);if(n.has(e))for(const i of n.get(e))i.enqueue(t);if(n.has(Ke)){const i=Promise.all([e,t]);for(const s of n.get(Ke))s.enqueue(i)}}function Xr(r,e){e=Array.isArray(e)?e:[e];let t=!1,n=()=>{},i=[];const s={enqueue(o){i.push(o),n()},finish(){t=!0,n()}};for(const o of e){let a=De(r,o);a||(a=new Set,j.get(r).set(o,a)),a.add(s)}return{async next(){return i?i.length===0?t?(i=void 0,this.next()):(await new Promise(o=>{n=o}),this.next()):{done:!1,value:await i.shift()}:{done:!0}},async return(o){i=void 0;for(const a of e){const c=De(r,a);c&&(c.delete(s),c.size===0&&j.get(r).delete(a))}return n(),arguments.length>0?{done:!0,value:await o}:{done:!0}},[Symbol.asyncIterator](){return this}}}function Yr(r){if(r===void 0)return Qr;if(!Array.isArray(r))throw new TypeError("`methodNames` must be an array of strings");for(const e of r)if(!Qr.includes(e))throw typeof e!="string"?new TypeError("`methodNames` element must be a string"):new Error(`${e} is not Emittery method`);return r}const we=r=>r===Je||r===Ze;function rt(r,e,t){if(we(e))try{et=!0,r.emit(e,t)}finally{et=!1}}class ve{static mixin(e,t){return t=Yr(t),n=>{if(typeof n!="function")throw new TypeError("`target` must be function");for(const o of t)if(n.prototype[o]!==void 0)throw new Error(`The property \\`${o}\\` already exists on \\`target\\``);function i(){return Object.defineProperty(this,e,{enumerable:!1,value:new ve}),this[e]}Object.defineProperty(n.prototype,e,{enumerable:!1,get:i});const s=o=>function(...a){return this[e][o](...a)};for(const o of t)Object.defineProperty(n.prototype,o,{enumerable:!1,value:s(o)});return n}}static get isDebugEnabled(){var e,t;if(typeof((e=globalThis.process)==null?void 0:e.env)!="object")return Ht;const{env:n}=(t=globalThis.process)!=null?t:{env:{}};return n.DEBUG==="emittery"||n.DEBUG==="*"||Ht}static set isDebugEnabled(e){Ht=e}constructor(e={}){var t;K.set(this,new Set),ce.set(this,new Map),j.set(this,new Map),j.get(this).set(Ke,new Set),this.debug=(t=e.debug)!=null?t:{},this.debug.enabled===void 0&&(this.debug.enabled=!1),this.debug.logger||(this.debug.logger=(n,i,s,o)=>{try{o=JSON.stringify(o)}catch{o=`Object with the following keys failed to stringify: ${Object.keys(o).join(",")}`}(typeof s=="symbol"||typeof s=="number")&&(s=s.toString());const a=new Date,c=`${a.getHours()}:${a.getMinutes()}:${a.getSeconds()}.${a.getMilliseconds()}`;console.log(`[${c}][emittery:${n}][${i}] Event Name: ${s}\n data: ${o}`)})}logIfDebugEnabled(e,t,n){(ve.isDebugEnabled||this.debug.enabled)&&this.debug.logger(e,this.debug.name,t,n)}on(e,t){tt(t),e=Array.isArray(e)?e:[e];for(const n of e){_e(n);let i=Ee(this,n);i||(i=new Set,ce.get(this).set(n,i)),i.add(t),this.logIfDebugEnabled("subscribe",n,void 0),we(n)||rt(this,Je,{eventName:n,listener:t})}return this.off.bind(this,e,t)}off(e,t){tt(t),e=Array.isArray(e)?e:[e];for(const n of e){_e(n);const i=Ee(this,n);i&&(i.delete(t),i.size===0&&ce.get(this).delete(n)),this.logIfDebugEnabled("unsubscribe",n,void 0),we(n)||rt(this,Ze,{eventName:n,listener:t})}}once(e){let t;const n=new Promise(i=>{t=this.on(e,s=>{t(),i(s)})});return n.off=t,n}events(e){e=Array.isArray(e)?e:[e];for(const t of e)_e(t);return Xr(this,e)}async emit(e,t){var n;if(_e(e),we(e)&&!et)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");this.logIfDebugEnabled("emit",e,t),Gi(this,e,t);const i=(n=Ee(this,e))!=null?n:new Set,s=K.get(this),o=[...i],a=we(e)?[]:[...s];await jr,await Promise.all([...o.map(async c=>{if(i.has(c))return c(t)}),...a.map(async c=>{if(s.has(c))return c(e,t)})])}async emitSerial(e,t){var n;if(_e(e),we(e)&&!et)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");this.logIfDebugEnabled("emitSerial",e,t);const i=(n=Ee(this,e))!=null?n:new Set,s=K.get(this),o=[...i],a=[...s];await jr;for(const c of o)i.has(c)&&await c(t);for(const c of a)s.has(c)&&await c(e,t)}onAny(e){return tt(e),this.logIfDebugEnabled("subscribeAny",void 0,void 0),K.get(this).add(e),rt(this,Je,{listener:e}),this.offAny.bind(this,e)}anyEvent(){return Xr(this)}offAny(e){tt(e),this.logIfDebugEnabled("unsubscribeAny",void 0,void 0),rt(this,Ze,{listener:e}),K.get(this).delete(e)}clearListeners(e){e=Array.isArray(e)?e:[e];for(const t of e)if(this.logIfDebugEnabled("clear",t,void 0),typeof t=="string"||typeof t=="symbol"||typeof t=="number"){const n=Ee(this,t);n&&n.clear();const i=De(this,t);if(i){for(const s of i)s.finish();i.clear()}}else{K.get(this).clear();for(const[n,i]of ce.get(this).entries())i.clear(),ce.get(this).delete(n);for(const[n,i]of j.get(this).entries()){for(const s of i)s.finish();i.clear(),j.get(this).delete(n)}}}listenerCount(e){var t,n,i,s,o,a;e=Array.isArray(e)?e:[e];let c=0;for(const u of e){if(typeof u=="string"){c+=K.get(this).size+((n=(t=Ee(this,u))==null?void 0:t.size)!=null?n:0)+((s=(i=De(this,u))==null?void 0:i.size)!=null?s:0)+((a=(o=De(this))==null?void 0:o.size)!=null?a:0);continue}typeof u<"u"&&_e(u),c+=K.get(this).size;for(const d of ce.get(this).values())c+=d.size;for(const d of j.get(this).values())c+=d.size}return c}bindMethods(e,t){if(typeof e!="object"||e===null)throw new TypeError("`target` must be an object");t=Yr(t);for(const n of t){if(e[n]!==void 0)throw new Error(`The property \\`${n}\\` already exists on \\`target\\``);Object.defineProperty(e,n,{enumerable:!1,value:this[n].bind(this)})}}}const Qr=Object.getOwnPropertyNames(ve.prototype).filter(r=>r!=="constructor");Object.defineProperty(ve,"listenerAdded",{value:Je,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(ve,"listenerRemoved",{value:Ze,writable:!1,enumerable:!0,configurable:!1});function $i(r){return r.onAny&&r.emit}async function Wi(r,e){const{functionName:t,args:n}=r;if(!e.instance)throw"instance not initialized";if(!t)throw"missing function name to call";if(!e.instance[t])throw`undefined function [${t}] in class ${e.instance.constructor.workerId}`;Be(r,await e.instance[t](...n??[]))}const qr=Vt("registeredWorkers",{});function Vi(r,e){e.workerId=r,Hr()&&(qr[e.workerId]=e)}function Hi(r,e){if(!r.args)throw"Missing className while initializing worker";const[t,n]=r.args,i=qr[t];if(i)e.instance=new i(r.args.slice(1));else throw`unknown worker class ${t}`;qe(n,Vr),$i(e.instance)&&e.instance.onAny((s,o)=>{Be({type:xe.EVENT},{name:s,data:o})}),Be(r,typeof e.instance!==void 0)}async function ji(r,e){const{args:t}=r;if(!e.instance)throw"instance not initialized";let n;e.instance.terminate&&(n=await e.instance.terminate(...t??[])),Be(r,n)}function Xi(r){if(!r.args)throw"Missing globals while syncing";qe(r.args[0],Vr),Be(r,{})}function Yi(){const r={};onmessage=async e=>{const t=e.data;switch(t.type){case xe.INIT:Hi(t,r);break;case xe.FORWARD:Wi(t,r);break;case xe.TERMINATE:ji(t,r);break;case xe.GLOBALS_SYNC:Xi(t);break}}}Hr()&&Yi();const J=new WeakMap,ue=new WeakMap,X=new WeakMap,nt=Symbol("anyProducer"),Kr=Promise.resolve(),it=Symbol("listenerAdded"),st=Symbol("listenerRemoved");let ot=!1,jt=!1;const at=r=>typeof r=="string"||typeof r=="symbol"||typeof r=="number";function Te(r){if(!at(r))throw new TypeError("`eventName` must be a string, symbol, or number")}function ct(r){if(typeof r!="function")throw new TypeError("listener must be a function")}function Ae(r,e){const t=ue.get(r);if(t.has(e))return t.get(e)}function Me(r,e){const t=at(e)?e:nt,n=X.get(r);if(n.has(t))return n.get(t)}function Qi(r,e,t){const n=X.get(r);if(n.has(e))for(const i of n.get(e))i.enqueue(t);if(n.has(nt)){const i=Promise.all([e,t]);for(const s of n.get(nt))s.enqueue(i)}}function Jr(r,e){e=Array.isArray(e)?e:[e];let t=!1,n=()=>{},i=[];const s={enqueue(o){i.push(o),n()},finish(){t=!0,n()}};for(const o of e){let a=Me(r,o);a||(a=new Set,X.get(r).set(o,a)),a.add(s)}return{async next(){return i?i.length===0?t?(i=void 0,this.next()):(await new Promise(o=>{n=o}),this.next()):{done:!1,value:await i.shift()}:{done:!0}},async return(o){i=void 0;for(const a of e){const c=Me(r,a);c&&(c.delete(s),c.size===0&&X.get(r).delete(a))}return n(),arguments.length>0?{done:!0,value:await o}:{done:!0}},[Symbol.asyncIterator](){return this}}}function Zr(r){if(r===void 0)return en;if(!Array.isArray(r))throw new TypeError("`methodNames` must be an array of strings");for(const e of r)if(!en.includes(e))throw typeof e!="string"?new TypeError("`methodNames` element must be a string"):new Error(`${e} is not Emittery method`);return r}const Ie=r=>r===it||r===st;function ut(r,e,t){if(Ie(e))try{ot=!0,r.emit(e,t)}finally{ot=!1}}class Y{static mixin(e,t){return t=Zr(t),n=>{if(typeof n!="function")throw new TypeError("`target` must be function");for(const o of t)if(n.prototype[o]!==void 0)throw new Error(`The property \\`${o}\\` already exists on \\`target\\``);function i(){return Object.defineProperty(this,e,{enumerable:!1,value:new Y}),this[e]}Object.defineProperty(n.prototype,e,{enumerable:!1,get:i});const s=o=>function(...a){return this[e][o](...a)};for(const o of t)Object.defineProperty(n.prototype,o,{enumerable:!1,value:s(o)});return n}}static get isDebugEnabled(){if(typeof globalThis.process?.env!="object")return jt;const{env:e}=globalThis.process??{env:{}};return e.DEBUG==="emittery"||e.DEBUG==="*"||jt}static set isDebugEnabled(e){jt=e}constructor(e={}){J.set(this,new Set),ue.set(this,new Map),X.set(this,new Map),X.get(this).set(nt,new Set),this.debug=e.debug??{},this.debug.enabled===void 0&&(this.debug.enabled=!1),this.debug.logger||(this.debug.logger=(t,n,i,s)=>{try{s=JSON.stringify(s)}catch{s=`Object with the following keys failed to stringify: ${Object.keys(s).join(",")}`}(typeof i=="symbol"||typeof i=="number")&&(i=i.toString());const o=new Date,a=`${o.getHours()}:${o.getMinutes()}:${o.getSeconds()}.${o.getMilliseconds()}`;console.log(`[${a}][emittery:${t}][${n}] Event Name: ${i}\n data: ${s}`)})}logIfDebugEnabled(e,t,n){(Y.isDebugEnabled||this.debug.enabled)&&this.debug.logger(e,this.debug.name,t,n)}on(e,t,{signal:n}={}){ct(t),e=Array.isArray(e)?e:[e];for(const s of e){Te(s);let o=Ae(this,s);o||(o=new Set,ue.get(this).set(s,o)),o.add(t),this.logIfDebugEnabled("subscribe",s,void 0),Ie(s)||ut(this,it,{eventName:s,listener:t})}const i=()=>{this.off(e,t),n?.removeEventListener("abort",i)};return n?.addEventListener("abort",i,{once:!0}),n?.aborted&&i(),i}off(e,t){ct(t),e=Array.isArray(e)?e:[e];for(const n of e){Te(n);const i=Ae(this,n);i&&(i.delete(t),i.size===0&&ue.get(this).delete(n)),this.logIfDebugEnabled("unsubscribe",n,void 0),Ie(n)||ut(this,st,{eventName:n,listener:t})}}once(e,t){if(t!==void 0&&typeof t!="function")throw new TypeError("predicate must be a function");let n;const i=new Promise(s=>{n=this.on(e,o=>{t&&!t(o)||(n(),s(o))})});return i.off=n,i}events(e){e=Array.isArray(e)?e:[e];for(const t of e)Te(t);return Jr(this,e)}async emit(e,t){if(Te(e),Ie(e)&&!ot)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");this.logIfDebugEnabled("emit",e,t),Qi(this,e,t);const n=Ae(this,e)??new Set,i=J.get(this),s=[...n],o=Ie(e)?[]:[...i];await Kr,await Promise.all([...s.map(async a=>{if(n.has(a))return a(t)}),...o.map(async a=>{if(i.has(a))return a(e,t)})])}async emitSerial(e,t){if(Te(e),Ie(e)&&!ot)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");this.logIfDebugEnabled("emitSerial",e,t);const n=Ae(this,e)??new Set,i=J.get(this),s=[...n],o=[...i];await Kr;for(const a of s)n.has(a)&&await a(t);for(const a of o)i.has(a)&&await a(e,t)}onAny(e,{signal:t}={}){ct(e),this.logIfDebugEnabled("subscribeAny",void 0,void 0),J.get(this).add(e),ut(this,it,{listener:e});const n=()=>{this.offAny(e),t?.removeEventListener("abort",n)};return t?.addEventListener("abort",n,{once:!0}),t?.aborted&&n(),n}anyEvent(){return Jr(this)}offAny(e){ct(e),this.logIfDebugEnabled("unsubscribeAny",void 0,void 0),ut(this,st,{listener:e}),J.get(this).delete(e)}clearListeners(e){e=Array.isArray(e)?e:[e];for(const t of e)if(this.logIfDebugEnabled("clear",t,void 0),at(t)){const n=Ae(this,t);n&&n.clear();const i=Me(this,t);if(i){for(const s of i)s.finish();i.clear()}}else{J.get(this).clear();for(const[n,i]of ue.get(this).entries())i.clear(),ue.get(this).delete(n);for(const[n,i]of X.get(this).entries()){for(const s of i)s.finish();i.clear(),X.get(this).delete(n)}}}listenerCount(e){e=Array.isArray(e)?e:[e];let t=0;for(const n of e){if(at(n)){t+=J.get(this).size+(Ae(this,n)?.size??0)+(Me(this,n)?.size??0)+(Me(this)?.size??0);continue}n!==void 0&&Te(n),t+=J.get(this).size;for(const i of ue.get(this).values())t+=i.size;for(const i of X.get(this).values())t+=i.size}return t}bindMethods(e,t){if(typeof e!="object"||e===null)throw new TypeError("`target` must be an object");t=Zr(t);for(const n of t){if(e[n]!==void 0)throw new Error(`The property \\`${n}\\` already exists on \\`target\\``);Object.defineProperty(e,n,{enumerable:!1,value:this[n].bind(this)})}}}const en=Object.getOwnPropertyNames(Y.prototype).filter(r=>r!=="constructor");Object.defineProperty(Y,"listenerAdded",{value:it,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(Y,"listenerRemoved",{value:st,writable:!1,enumerable:!0,configurable:!1});var qi=Object.defineProperty,Ki=(r,e,t)=>e in r?qi(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ji=(r,e,t)=>(Ki(r,e+"",t),t);const Zi="hlg.tokbox.com/prod/logging/vcp_webrtc",es="https://",ts=1e4;let ft;const rs=new Uint8Array(16);function ns(){if(!ft&&(ft=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!ft))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ft(rs)}const F=[];for(let r=0;r<256;++r)F.push((r+256).toString(16).slice(1));function is(r,e=0){return(F[r[e+0]]+F[r[e+1]]+F[r[e+2]]+F[r[e+3]]+"-"+F[r[e+4]]+F[r[e+5]]+"-"+F[r[e+6]]+F[r[e+7]]+"-"+F[r[e+8]]+F[r[e+9]]+"-"+F[r[e+10]]+F[r[e+11]]+F[r[e+12]]+F[r[e+13]]+F[r[e+14]]+F[r[e+15]]).toLowerCase()}const ss=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),tn={randomUUID:ss};function os(r,e,t){if(tn.randomUUID&&!r)return tn.randomUUID();r=r||{};const n=r.random||(r.rng||ns)();return n[6]=n[6]&15|64,n[8]=n[8]&63|128,is(n)}function Xt(r,e){globalThis.vonage||(globalThis.vonage={}),globalThis.vonage.workerizer||(globalThis.vonage.workerizer={});let t=globalThis.vonage.workerizer;return t[r]||(t[r]=e),t[r]}const Z=Xt("globals",{});var fe=(r=>(r.INIT="INIT",r.FORWARD="FORWARD",r.TERMINATE="TERMINATE",r.GLOBALS_SYNC="GLOBALS_SYNC",r))(fe||{});function rn(r){return[ImageBitmap,ReadableStream,WritableStream].some(e=>r instanceof e)}let as=0;function cs(r,e,t,n,i){const s=as++;return r.postMessage({id:s,type:e,functionName:t,args:n},n.filter(o=>rn(o))),new Promise(o=>{i?.set(s,o)})}function Oe(r,e){const{id:t,type:n}=r,i=Array.isArray(e)?e:[e];postMessage({id:t,type:n,result:e},i.filter(s=>rn(s)))}const nn=Xt("workerized",{});function sn(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}async function us(){if(sn())Oe({type:fe.GLOBALS_SYNC},Z);else{const r=[];for(const e in nn){const{worker:t,resolvers:n}=nn[e].workerContext;t&&r.push(cs(t,fe.GLOBALS_SYNC,"",[Z],n))}await Promise.all(r)}}function lt(r,e){if(Array.isArray(e))e.splice(0,e.length);else if(typeof e=="object")for(const t in e)delete e[t];for(const t in r)Array.isArray(r[t])?(e[t]=[],lt(r[t],e[t])):typeof r[t]=="object"?(e[t]={},lt(r[t],e[t])):e[t]=r[t]}async function fs(r,e){const{functionName:t,args:n}=r;if(!e.instance)throw"instance not initialized";if(!t)throw"missing function name to call";if(!e.instance[t])throw`undefined function [${t}] in class ${e.instance.constructor.workerId}`;Oe(r,await e.instance[t](...n??[]))}const ls=Xt("registeredWorkers",{});function ds(r,e){if(!r.args)throw"Missing className while initializing worker";const[t,n]=r.args,i=ls[t];if(i)e.instance=new i(r.args.slice(1));else throw`unknown worker class ${t}`;lt(n,Z),Oe(r,typeof e.instance!==void 0)}async function hs(r,e){const{args:t}=r;if(!e.instance)throw"instance not initialized";let n;e.instance.terminate&&(n=await e.instance.terminate(...t??[])),Oe(r,n)}function ms(r){if(!r.args)throw"Missing globals while syncing";lt(r.args[0],Z),Oe(r,{})}function ps(){const r={};onmessage=async e=>{const t=e.data;switch(t.type){case fe.INIT:ds(t,r);break;case fe.FORWARD:fs(t,r);break;case fe.TERMINATE:hs(t,r);break;case fe.GLOBALS_SYNC:ms(t);break}}}sn()&&ps();function gs(r,e){return Z[r]||(Z[r]=e),[()=>Z[r],async t=>{Z[r]=t,await us()}]}function ys(r,e){return gs(r,e)}const[bs,xs]=ys("metadata");function _s(r){xs(r)}function Yt(){return bs()}let Qt=class{constructor(e,t){Ji(this,"uuid"),this.config=e,this.uuid=t??os()}async send(e){var t,n,i;const{appId:s,sourceType:o}=(t=Yt())!=null?t:{};if(!s||!o)return"metadata missing";const a=new AbortController,c=setTimeout(()=>a.abort(),ts);return await((i=(n=this.config)==null?void 0:n.fetch)!=null?i:fetch)(this.getUrl(),{method:"POST",headers:this.getHeaders(),body:JSON.stringify(this.buildReport(e)),signal:a.signal}),clearTimeout(c),"success"}getUrl(){var e;let t=(e=Yt().proxyUrl)!=null?e:es;return t+=(t.at(-1)==="/"?"":"/")+Zi,t}getHeaders(){return{"Content-Type":"application/json"}}buildReport(e){const t=Yt();return{guid:this.uuid,...e,applicationId:t.appId,timestamp:Date.now(),proxyUrl:t.proxyUrl,source:t.sourceType}}};const dt="3.0.2",qt=class{};qt.updates={transformer_new:"New transformer",transformer_null:"Null transformer"},qt.errors={transformer_none:"No transformers provided",transformer_start:"Cannot start transformer",transformer_transform:"Cannot transform frame",transformer_flush:"Cannot flush transformer",readable_null:"Readable is null",writable_null:"Writable is null"};let le=qt;function Es(r){return typeof r=="object"&&r!==null&&"message"in r&&typeof r.message=="string"}function ws(r){if(Es(r))return r;try{return new Error(JSON.stringify(r))}catch{return new Error(String(r))}}function Kt(r){return ws(r).message}class vs{constructor(e,t){this.config=e,this.frameTransformedCount=0,this.frameFromSourceCount=0,this.startAt=0,this.reporter=new Qt(e,t)}async onFrameFromSource(){this.frameFromSourceCount++}get fps(){const{startAt:e,frameFromSourceCount:t}=this,n=(Date.now()-e)/1e3;return t/n}async onFrameTransformed(e={},t=!1){this.startAt===0&&(this.startAt=Date.now()),this.frameTransformedCount++;const{startAt:n,frameTransformedCount:i,frameFromSourceCount:s}=this,o=Date.now(),a=(o-n)/1e3,c=i/a,u=s/a;return t||this.frameTransformedCount>=this.config.loggingIntervalFrameCount?(this.frameFromSourceCount=0,this.frameTransformedCount=0,this.startAt=o,this.reporter.config=this.config,this.reporter.send({...this.config.report,variation:"QoS",fps:u,transformedFps:c,framesTransformed:i,...e})):"success"}}var Jt=(r=>(r.pipeline_ended="pipeline_ended",r.pipeline_ended_with_error="pipeline_ended_with_error",r.pipeline_started="pipeline_started",r.pipeline_started_with_error="pipeline_started_with_error",r.pipeline_restarted="pipeline_restarted",r.pipeline_restarted_with_error="pipeline_restarted_with_error",r))(Jt||{});const Ts=500,As=.8;class Is extends Y{constructor(e,t){super(),this.reporter_=new Qt,this.reporterQos_=new vs({loggingIntervalFrameCount:Ts,report:{version:dt}}),this.index_=t,this.transformer_=e,this.shouldStop_=!1,this.isFlashed_=!1,this.mediaTransformerQosReportStartTimestamp_=0,this.videoHeight_=0,this.videoWidth_=0,this.trackExpectedRate_=-1,this.transformerType_="Custom","getTransformerType"in e&&(this.transformerType_=e.getTransformerType()),this.report({variation:"Create"})}setTrackExpectedRate(e){this.trackExpectedRate_=e}async start(e){if(this.controller_=e,this.transformer_&&typeof this.transformer_.start=="function")try{await this.transformer_.start(e)}catch(t){this.report({message:le.errors.transformer_start,variation:"Error",error:Kt(t)});const n={eventMetaData:{transformerIndex:this.index_},error:t,function:"start"};this.emit("error",n)}}async transform(e,t){if(this.mediaTransformerQosReportStartTimestamp_===0&&(this.mediaTransformerQosReportStartTimestamp_=Date.now()),e instanceof VideoFrame&&(this.videoHeight_=e?.displayHeight??0,this.videoWidth_=e?.displayWidth??0),this.reporterQos_.onFrameFromSource(),this.transformer_)if(this.shouldStop_)console.warn("[Pipeline] flush from transform"),e.close(),this.flush(t),t.terminate();else{try{await this.transformer_.transform?.(e,t),this.reportQos()}catch(n){this.report({message:le.errors.transformer_transform,variation:"Error",error:Kt(n)});const i={eventMetaData:{transformerIndex:this.index_},error:n,function:"transform"};this.emit("error",i)}if(this.trackExpectedRate_!=-1&&this.trackExpectedRate_*As>this.reporterQos_.fps){const n={eventMetaData:{transformerIndex:this.index_},warningType:"fps_drop",dropInfo:{requested:this.trackExpectedRate_,current:this.reporterQos_.fps}};this.emit("warn",n)}}}async flush(e){if(this.transformer_&&typeof this.transformer_.flush=="function"&&!this.isFlashed_){this.isFlashed_=!0;try{await this.transformer_.flush(e)}catch(t){this.report({message:le.errors.transformer_flush,variation:"Error",error:Kt(t)});const n={eventMetaData:{transformerIndex:this.index_},error:t,function:"flush"};this.emit("error",n)}}this.reportQos(!0),this.report({variation:"Delete"})}stop(){console.log("[Pipeline] Stop stream."),this.controller_&&(this.flush(this.controller_),this.controller_.terminate()),this.shouldStop_=!0}report(e){this.reporter_.send({version:dt,action:"MediaTransformer",transformerType:this.transformerType_,...e})}reportQos(e=!1){this.reporterQos_.config={...this.reporterQos_.config},this.reporterQos_.onFrameTransformed({version:dt,action:"MediaTransformer",transformerType:this.transformerType_,videoWidth:this.videoWidth_,videoHeight:this.videoHeight_},e)}}class Ss extends Y{constructor(e){super(),this.transformers_=[],this.trackExpectedRate_=-1;for(let t=0;t<e.length;t++){let n=new Is(e[t],t);n.on("error",i=>{this.emit("error",i)}),n.on("warn",i=>{this.emit("warn",i)}),this.transformers_.push(n)}}setTrackExpectedRate(e){this.trackExpectedRate_=e;for(let t of this.transformers_)t.setTrackExpectedRate(this.trackExpectedRate_)}async start(e,t){if(!this.transformers_||this.transformers_.length===0){console.log("[Pipeline] No transformers.");return}try{let n=e;for(let i of this.transformers_)e=e.pipeThrough(new TransformStream(i));e.pipeTo(t).then(async()=>{console.log("[Pipeline] Setup."),await t.abort(),await n.cancel(),this.emit("pipelineInfo","pipeline_ended")}).catch(async i=>{e.cancel().then(()=>{console.log("[Pipeline] Shutting down streams after abort.")}).catch(s=>{console.error("[Pipeline] Error from stream transform:",s)}),await t.abort(i),await n.cancel(i),this.emit("pipelineInfo","pipeline_ended_with_error")})}catch{this.emit("pipelineInfo","pipeline_started_with_error"),this.destroy();return}this.emit("pipelineInfo","pipeline_started"),console.log("[Pipeline] Pipeline started.")}async destroy(){console.log("[Pipeline] Destroying Pipeline.");for(let e of this.transformers_)e.stop()}}class Rs extends Y{constructor(){super(),this.reporter_=new Qt,this.trackExpectedRate_=-1,this.report({variation:"Create"})}setTrackExpectedRate(e){this.trackExpectedRate_=e,this.pipeline_&&this.pipeline_.setTrackExpectedRate(this.trackExpectedRate_)}async transform(e,t){if(this.isTrack(e)){if(e.kind==="video"){const n=new MediaStreamTrackProcessor({track:e}),i=new VideoTrackGenerator;return this.readable_=n.readable,this.writable_=i.writable,await this.transformInternal(),i.track}throw Error("Cannot process audio tracks inside a web worker when passing a track to transform")}else return this.readable_=e,this.writable_=t,this.transformInternal()}transformInternal(){return new Promise(async(e,t)=>{if(!this.transformers_||this.transformers_.length===0){this.report({message:le.errors.transformer_none,variation:"Error"}),t("[MediaProcessor] Need to set transformers.");return}if(!this.readable_){this.report({variation:"Error",message:le.errors.readable_null}),t("[MediaProcessor] Readable is null.");return}if(!this.writable_){this.report({variation:"Error",message:le.errors.writable_null}),t("[MediaProcessor] Writable is null.");return}let n=!1;this.pipeline_&&(n=!0,this.pipeline_.clearListeners(),this.pipeline_.destroy()),this.pipeline_=new Ss(this.transformers_),this.pipeline_.on("warn",i=>{this.emit("warn",i)}),this.pipeline_.on("error",i=>{this.emit("error",i)}),this.pipeline_.on("pipelineInfo",i=>{n&&(i==="pipeline_started"?i=Jt.pipeline_restarted:i==="pipeline_started_with_error"&&(i=Jt.pipeline_restarted_with_error)),this.emit("pipelineInfo",i)}),this.trackExpectedRate_!=-1&&this.pipeline_.setTrackExpectedRate(this.trackExpectedRate_),this.pipeline_.start(this.readable_,this.writable_).then(()=>{e()}).catch(i=>{t(i)})})}setTransformers(e){return this.report({variation:"Update",message:le.updates.transformer_new}),this.transformers_=e,this.readable_&&this.writable_?this.transformInternal():Promise.resolve()}destroy(){return new Promise(async e=>{this.pipeline_&&this.pipeline_.destroy(),this.report({variation:"Delete"}),e()})}report(e){this.reporter_.send({version:dt,action:"MediaProcessor",...e})}isTrack(e){return"kind"in e}}var Fs=Object.defineProperty,Ps=(r,e,t)=>e in r?Fs(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ks=(r,e,t)=>(Ps(r,e+"",t),t);const Cs="hlg.tokbox.com/prod/logging/vcp_webrtc",Bs="https://",Ds=1e4;let ht;const Ms=new Uint8Array(16);function Os(){if(!ht&&(ht=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!ht))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ht(Ms)}const P=[];for(let r=0;r<256;++r)P.push((r+256).toString(16).slice(1));function Us(r,e=0){return(P[r[e+0]]+P[r[e+1]]+P[r[e+2]]+P[r[e+3]]+"-"+P[r[e+4]]+P[r[e+5]]+"-"+P[r[e+6]]+P[r[e+7]]+"-"+P[r[e+8]]+P[r[e+9]]+"-"+P[r[e+10]]+P[r[e+11]]+P[r[e+12]]+P[r[e+13]]+P[r[e+14]]+P[r[e+15]]).toLowerCase()}const Ns=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),on={randomUUID:Ns};function Ls(r,e,t){if(on.randomUUID&&!e&&!r)return on.randomUUID();r=r||{};const n=r.random||(r.rng||Os)();return n[6]=n[6]&15|64,n[8]=n[8]&63|128,Us(n)}function Zt(r,e){globalThis.vonage||(globalThis.vonage={}),globalThis.vonage.workerizer||(globalThis.vonage.workerizer={});let t=globalThis.vonage.workerizer;return t[r]||(t[r]=e),t[r]}const ee=Zt("globals",{});var de=(r=>(r.INIT="INIT",r.FORWARD="FORWARD",r.TERMINATE="TERMINATE",r.GLOBALS_SYNC="GLOBALS_SYNC",r))(de||{});function an(r){return[ImageBitmap,ReadableStream,WritableStream].some(e=>r instanceof e)}let zs=0;function Gs(r,e,t,n,i){const s=zs++;return r.postMessage({id:s,type:e,functionName:t,args:n},n.filter(o=>an(o))),new Promise(o=>{i?.set(s,o)})}function Ue(r,e){const{id:t,type:n}=r,i=Array.isArray(e)?e:[e];postMessage({id:t,type:n,result:e},i.filter(s=>an(s)))}const cn=Zt("workerized",{});function un(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}async function $s(){if(un())Ue({type:de.GLOBALS_SYNC},ee);else{const r=[];for(const e in cn){const{worker:t,resolvers:n}=cn[e].workerContext;t&&r.push(Gs(t,de.GLOBALS_SYNC,"",[ee],n))}await Promise.all(r)}}function mt(r,e){if(Array.isArray(e))e.splice(0,e.length);else if(typeof e=="object")for(const t in e)delete e[t];for(const t in r)Array.isArray(r[t])?(e[t]=[],mt(r[t],e[t])):typeof r[t]=="object"?(e[t]={},mt(r[t],e[t])):e[t]=r[t]}async function Ws(r,e){const{functionName:t,args:n}=r;if(!e.instance)throw"instance not initialized";if(!t)throw"missing function name to call";if(!e.instance[t])throw`undefined function [${t}] in class ${e.instance.constructor.workerId}`;Ue(r,await e.instance[t](...n??[]))}const Vs=Zt("registeredWorkers",{});function Hs(r,e){if(!r.args)throw"Missing className while initializing worker";const[t,n]=r.args,i=Vs[t];if(i)e.instance=new i(r.args.slice(1));else throw`unknown worker class ${t}`;mt(n,ee),Ue(r,typeof e.instance!==void 0)}async function js(r,e){const{args:t}=r;if(!e.instance)throw"instance not initialized";let n;e.instance.terminate&&(n=await e.instance.terminate(...t??[])),Ue(r,n)}function Xs(r){if(!r.args)throw"Missing globals while syncing";mt(r.args[0],ee),Ue(r,{})}function Ys(){const r={};onmessage=async e=>{const t=e.data;switch(t.type){case de.INIT:Hs(t,r);break;case de.FORWARD:Ws(t,r);break;case de.TERMINATE:js(t,r);break;case de.GLOBALS_SYNC:Xs(t);break}}}un()&&Ys();function Qs(r,e){return ee[r]||(ee[r]=e),[()=>ee[r],async t=>{ee[r]=t,await $s()}]}function qs(r,e){return Qs(r,e)}const[Ks]=qs("metadata");function er(){return Ks()}class Js{constructor(e){ks(this,"uuid",Ls()),this.config=e}async send(e){var t,n,i;const{appId:s,sourceType:o}=(t=er())!=null?t:{};if(!s||!o)return"metadata missing";const a=new AbortController,c=setTimeout(()=>a.abort(),Ds);return await((i=(n=this.config)==null?void 0:n.fetch)!=null?i:fetch)(this.getUrl(),{method:"POST",headers:this.getHeaders(),body:JSON.stringify(this.buildReport(e)),signal:a.signal}),clearTimeout(c),"success"}getUrl(){var e;let t=(e=er().proxyUrl)!=null?e:Bs;return t+=(t.at(-1)==="/"?"":"/")+Cs,t}getHeaders(){return{"Content-Type":"application/json"}}buildReport(e){const t=er();return{guid:this.uuid,...e,applicationId:t.appId,timestamp:Date.now(),proxyUrl:t.proxyUrl,source:t.sourceType}}}const Zs="7.0.1";var pt=(r=>(r.Low="Low",r.High="High",r))(pt||{}),tr=(r=>(r.FAST="FAST",r.PRECISE="PRECISE",r))(tr||{}),gt=(r=>(r.CANVAS="CANVAS",r.WEBGL="WEBGL",r))(gt||{});function eo(){const e=new OffscreenCanvas(0,0).getContext("webgl2",{failIfMajorPerformanceCaveat:!0});if(e){const t=e?.getExtension("WEBGL_lose_context");t&&t.loseContext()}else return{supported:!1,message:"Your hardware does not perform good enough to run the library efficiently"};return{supported:!0}}class rr{constructor(){const e=new OffscreenCanvas(0,0),t=e.getContext("2d",{willReadFrequently:!0});if(!t)throw"Fail to retrieve 2d context";this.canvas=e,this.context=t}enablePostProcessing(){}disablePostProcessing(){}async profileWebgl(e){return[]}async render(e,t){return this.canvas}resizeCanvas(e){const{width:t,height:n}=e;this.canvas.width=t,this.canvas.height=n}renderSilhouette(e,t,n="none"){const{width:i,height:s}=e;this.context.save(),this.context.drawImage(t,0,0,t.width,t.height,0,0,i,s),this.context.filter="blur(5px)",this.context.globalCompositeOperation="source-in",this.context.drawImage(t,0,0,t.width,t.height,0,0,i,s),this.context.globalCompositeOperation="source-in",this.context.filter=n,this.context.drawImage(e,0,0,i,s,0,0,this.canvas.width,this.canvas.height),this.context.restore()}destroy(){}}class to extends rr{constructor(e){super(),this.radius=e}async render(e,t){super.resizeCanvas(e);const n=await createImageBitmap(t);return this.renderSilhouette(e,n),this.context.save(),this.context.filter=`blur(${this.radius}px)`,this.context.globalCompositeOperation="destination-over",this.context.drawImage(e,0,0,e.width,e.height),this.context.restore(),super.render(e,t)}}class ro extends rr{constructor(e){super(),this.radius=e}async render(e,t){super.resizeCanvas(e);const n=await createImageBitmap(t);return this.renderSilhouette(e,n,`blur(${this.radius}px)`),this.context.save(),this.context.filter="none",this.context.globalCompositeOperation="destination-over",this.context.drawImage(e,0,0,e.width,e.height),this.context.restore(),super.render(e,t)}}class no extends rr{setBackgroundImage(e){this.backgroundImage=e}async render(e,t){super.resizeCanvas(e);const n=await createImageBitmap(t);return this.renderSilhouette(e,n),this.backgroundImage&&(this.context.save(),this.context.filter="none",this.context.globalCompositeOperation="destination-over",this.context.drawImage(this.backgroundImage,0,0,this.backgroundImage.width,this.backgroundImage.height,0,0,e.width,e.height),this.context.restore()),super.render(e,t)}}const nr=5120,Ne=5121,ir=5122,sr=5123,or=5124,ar=5125,cr=5126,io=32819,so=32820,oo=33635,ao=5131,co=33640,uo=35899,fo=35902,lo=36269,ho=34042,fn={};{const r=fn;r[nr]=Int8Array,r[Ne]=Uint8Array,r[ir]=Int16Array,r[sr]=Uint16Array,r[or]=Int32Array,r[ar]=Uint32Array,r[cr]=Float32Array,r[io]=Uint16Array,r[so]=Uint16Array,r[oo]=Uint16Array,r[ao]=Uint16Array,r[co]=Uint32Array,r[uo]=Uint32Array,r[fo]=Uint32Array,r[lo]=Uint32Array,r[ho]=Uint32Array}function ur(r){if(r instanceof Int8Array)return nr;if(r instanceof Uint8Array||r instanceof Uint8ClampedArray)return Ne;if(r instanceof Int16Array)return ir;if(r instanceof Uint16Array)return sr;if(r instanceof Int32Array)return or;if(r instanceof Uint32Array)return ar;if(r instanceof Float32Array)return cr;throw new Error("unsupported typed array type")}function ln(r){if(r===Int8Array)return nr;if(r===Uint8Array||r===Uint8ClampedArray)return Ne;if(r===Int16Array)return ir;if(r===Uint16Array)return sr;if(r===Int32Array)return or;if(r===Uint32Array)return ar;if(r===Float32Array)return cr;throw new Error("unsupported typed array type")}function dn(r){const e=fn[r];if(!e)throw new Error("unknown gl type");return e}const yt=typeof SharedArrayBuffer<"u"?function(e){return e&&e.buffer&&(e.buffer instanceof ArrayBuffer||e.buffer instanceof SharedArrayBuffer)}:function(e){return e&&e.buffer&&e.buffer instanceof ArrayBuffer};function hn(...r){console.error(...r)}const mn=new Map;function bt(r,e){if(!r||typeof r!="object")return!1;let t=mn.get(e);t||(t=new WeakMap,mn.set(e,t));let n=t.get(r);if(n===void 0){const i=Object.prototype.toString.call(r);n=i.substring(8,i.length-1)===e,t.set(r,n)}return n}function mo(r,e){return typeof WebGLBuffer<"u"&&bt(e,"WebGLBuffer")}function po(r,e){return typeof WebGLRenderbuffer<"u"&&bt(e,"WebGLRenderbuffer")}function fr(r,e){return typeof WebGLTexture<"u"&&bt(e,"WebGLTexture")}function go(r,e){return typeof WebGLSampler<"u"&&bt(e,"WebGLSampler")}const pn=35044,he=34962,yo=34963,bo=34660,xo=5120,_o=5121,Eo=5122,wo=5123,vo=5124,To=5125,gn=5126,yn={attribPrefix:""};function Ao(r,e,t,n,i){r.bindBuffer(e,t),r.bufferData(e,n,i||pn)}function bn(r,e,t,n){if(mo(r,e))return e;t=t||he;const i=r.createBuffer();return Ao(r,t,i,e,n),i}function xn(r){return r==="indices"}function Io(r){return r===Int8Array||r===Uint8Array}function So(r){return r.length?r:r.data}const Ro=/coord|texture/i,Fo=/color|colour/i;function Po(r,e){let t;if(Ro.test(r)?t=2:Fo.test(r)?t=4:t=3,e%t>0)throw new Error(`Can not guess numComponents for attribute \'${r}\'. Tried ${t} but ${e} values is not evenly divisible by ${t}. You should specify it.`);return t}function ko(r,e,t){return r.numComponents||r.size||Po(e,t||So(r).length)}function _n(r,e){if(yt(r))return r;if(yt(r.data))return r.data;Array.isArray(r)&&(r={data:r});let t=r.type?lr(r.type):void 0;return t||(xn(e)?t=Uint16Array:t=Float32Array),new t(r.data)}function Co(r){return typeof r=="number"?r:r?ln(r):gn}function lr(r){return typeof r=="number"?dn(r):r||Float32Array}function Bo(r,e){return{buffer:e.buffer,numValues:24,type:Co(e.type),arrayType:lr(e.type)}}function Do(r,e){const t=e.data||e,n=lr(e.type),i=t*n.BYTES_PER_ELEMENT,s=r.createBuffer();return r.bindBuffer(he,s),r.bufferData(he,i,e.drawType||pn),{buffer:s,numValues:t,type:ln(n),arrayType:n}}function Mo(r,e,t){const n=_n(e,t);return{arrayType:n.constructor,buffer:bn(r,n,void 0,e.drawType),type:ur(n),numValues:0}}function Oo(r,e){const t={};return Object.keys(e).forEach(function(n){if(!xn(n)){const i=e[n],s=i.attrib||i.name||i.attribName||yn.attribPrefix+n;if(i.value){if(!Array.isArray(i.value)&&!yt(i.value))throw new Error("array.value is not array or typedarray");t[s]={value:i.value}}else{let o;i.buffer&&i.buffer instanceof WebGLBuffer?o=Bo:typeof i=="number"||typeof i.data=="number"?o=Do:o=Mo;const{buffer:a,type:c,numValues:u,arrayType:d}=o(r,i,n),m=i.normalize!==void 0?i.normalize:Io(d),p=ko(i,n,u);t[s]={buffer:a,numComponents:p,type:c,normalize:m,stride:i.stride||0,offset:i.offset||0,divisor:i.divisor===void 0?void 0:i.divisor,drawType:i.drawType}}}}),r.bindBuffer(he,null),t}function Uo(r,e){return e===xo||e===_o?1:e===Eo||e===wo?2:e===vo||e===To||e===gn?4:0}const dr=["position","positions","a_position"];function No(r,e){let t,n;for(n=0;n<dr.length&&(t=dr[n],!(t in e||(t=yn.attribPrefix+t,t in e)));++n);n===dr.length&&(t=Object.keys(e)[0]);const i=e[t];if(!i.buffer)return 1;r.bindBuffer(he,i.buffer);const s=r.getBufferParameter(he,bo);r.bindBuffer(he,null);const o=Uo(r,i.type),a=s/o,c=i.numComponents||i.size,u=a/c;if(u%1!==0)throw new Error(`numComponents ${c} not correct for length ${length}`);return u}function Lo(r,e,t){const n=Oo(r,e),i=Object.assign({},t||{});i.attribs=Object.assign({},t?t.attribs:{},n);const s=e.indices;if(s){const o=_n(s,"indices");i.indices=bn(r,o,yo),i.numElements=o.length,i.elementType=ur(o)}else i.numElements||(i.numElements=No(r,i.attribs));return i}function Le(r){return!!r.texStorage2D}const En=(function(){const r={},e={};function t(n){const i=n.constructor.name;if(!r[i]){for(const s in n)if(typeof n[s]=="number"){const o=e[n[s]];e[n[s]]=o?`${o} | ${s}`:s}r[i]=!0}}return function(i,s){return t(i),e[s]||(typeof s=="number"?`0x${s.toString(16)}`:s)}})(),te={textureColor:new Uint8Array([128,192,255,255]),textureOptions:{},crossOrigin:void 0},ze=yt,wn=(function(){let r;return function(){return r=r||(typeof document<"u"&&document.createElement?document.createElement("canvas").getContext("2d"):null),r}})(),vn=6406,V=6407,A=6408,Tn=6409,An=6410,Ge=6402,In=34041,xt=33071,zo=9728,Go=9729,re=3553,ne=34067,me=32879,pe=35866,hr=34069,$o=34070,Wo=34071,Vo=34072,Ho=34073,jo=34074,mr=10241,pr=10240,_t=10242,Et=10243,Sn=32882,Xo=33082,Yo=33083,Qo=33084,qo=33085,Ko=34892,Jo=34893,gr=3317,Rn=3314,Fn=32878,Pn=3316,kn=3315,Cn=32877,Zo=37443,ea=37441,ta=37440,ra=33321,na=36756,ia=33325,sa=33326,oa=33330,aa=33329,ca=33338,ua=33337,fa=33340,la=33339,da=33323,ha=36757,ma=33327,pa=33328,ga=33336,ya=33335,ba=33332,xa=33331,_a=33334,Ea=33333,wa=32849,va=35905,Ta=36194,Aa=36758,Ia=35898,Sa=35901,Ra=34843,Fa=34837,Pa=36221,ka=36239,Ca=36215,Ba=36233,Da=36209,Ma=36227,Oa=32856,Ua=35907,Na=36759,La=32855,za=32854,Ga=32857,$a=34842,Wa=34836,Va=36220,Ha=36238,ja=36975,Xa=36214,Ya=36232,Qa=36226,qa=36208,Ka=33189,Ja=33190,Za=36012,ec=36013,tc=35056,ie=5120,T=5121,wt=5122,Se=5123,vt=5124,ge=5125,B=5126,Bn=32819,Dn=32820,Mn=33635,z=5131,$e=36193,yr=33640,rc=35899,nc=35902,ic=36269,sc=34042,Tt=33319,Re=33320,At=6403,Fe=36244,Pe=36248,ye=36249;let br;function It(r){if(!br){const e={};e[vn]={textureFormat:vn,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1,2,2,4],type:[T,z,$e,B]},e[Tn]={textureFormat:Tn,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1,2,2,4],type:[T,z,$e,B]},e[An]={textureFormat:An,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[2,4,4,8],type:[T,z,$e,B]},e[V]={textureFormat:V,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3,6,6,12,2],type:[T,z,$e,B,Mn]},e[A]={textureFormat:A,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,8,8,16,2,2],type:[T,z,$e,B,Bn,Dn]},e[Ge]={textureFormat:Ge,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2,4],type:[ge,Se]},e[ra]={textureFormat:At,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1],type:[T]},e[na]={textureFormat:At,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[1],type:[ie]},e[ia]={textureFormat:At,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[4,2],type:[B,z]},e[sa]={textureFormat:At,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[4],type:[B]},e[oa]={textureFormat:Fe,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[1],type:[T]},e[aa]={textureFormat:Fe,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[1],type:[ie]},e[ba]={textureFormat:Fe,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[Se]},e[xa]={textureFormat:Fe,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[wt]},e[_a]={textureFormat:Fe,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[ge]},e[Ea]={textureFormat:Fe,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[vt]},e[da]={textureFormat:Tt,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[2],type:[T]},e[ha]={textureFormat:Tt,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[2],type:[ie]},e[ma]={textureFormat:Tt,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[8,4],type:[B,z]},e[pa]={textureFormat:Tt,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[8],type:[B]},e[ga]={textureFormat:Re,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[T]},e[ya]={textureFormat:Re,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[ie]},e[ca]={textureFormat:Re,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[Se]},e[ua]={textureFormat:Re,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[wt]},e[fa]={textureFormat:Re,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[ge]},e[la]={textureFormat:Re,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[vt]},e[wa]={textureFormat:V,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3],type:[T]},e[va]={textureFormat:V,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[3],type:[T]},e[Ta]={textureFormat:V,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3,2],type:[T,Mn]},e[Aa]={textureFormat:V,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[3],type:[ie]},e[Ia]={textureFormat:V,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6,4],type:[B,z,rc]},e[Sa]={textureFormat:V,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6,4],type:[B,z,nc]},e[Ra]={textureFormat:V,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6],type:[B,z]},e[Fa]={textureFormat:V,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[B]},e[Pa]={textureFormat:Pe,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[3],type:[T]},e[ka]={textureFormat:Pe,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[3],type:[ie]},e[Ca]={textureFormat:Pe,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[6],type:[Se]},e[Ba]={textureFormat:Pe,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[6],type:[wt]},e[Da]={textureFormat:Pe,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[ge]},e[Ma]={textureFormat:Pe,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[vt]},e[Oa]={textureFormat:A,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[T]},e[Ua]={textureFormat:A,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[T]},e[Na]={textureFormat:A,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[4],type:[ie]},e[La]={textureFormat:A,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,2,4],type:[T,Dn,yr]},e[za]={textureFormat:A,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,2],type:[T,Bn]},e[Ga]={textureFormat:A,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[yr]},e[$a]={textureFormat:A,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[16,8],type:[B,z]},e[Wa]={textureFormat:A,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[16],type:[B]},e[Va]={textureFormat:ye,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[T]},e[Ha]={textureFormat:ye,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[ie]},e[ja]={textureFormat:ye,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[yr]},e[Xa]={textureFormat:ye,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[Se]},e[Ya]={textureFormat:ye,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[wt]},e[Qa]={textureFormat:ye,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[16],type:[vt]},e[qa]={textureFormat:ye,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[16],type:[ge]},e[Ka]={textureFormat:Ge,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2,4],type:[Se,ge]},e[Ja]={textureFormat:Ge,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[ge]},e[Za]={textureFormat:Ge,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[B]},e[tc]={textureFormat:In,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[sc]},e[ec]={textureFormat:In,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[ic]},Object.keys(e).forEach(function(t){const n=e[t];n.bytesPerElementMap={},n.bytesPerElement.forEach(function(i,s){const o=n.type[s];n.bytesPerElementMap[o]=i})}),br=e}return br[r]}function oc(r,e){const t=It(r);if(!t)throw"unknown internal format";const n=t.bytesPerElementMap[e];if(n===void 0)throw"unknown internal format";return n}function We(r){const e=It(r);if(!e)throw"unknown internal format";return{format:e.textureFormat,type:e.type[0]}}function On(r){return(r&r-1)===0}function ac(r,e,t,n){if(!Le(r))return On(e)&&On(t);const i=It(n);if(!i)throw"unknown internal format";return i.colorRenderable&&i.textureFilterable}function cc(r){const e=It(r);if(!e)throw"unknown internal format";return e.textureFilterable}function uc(r,e,t){return ze(e)?ur(e):t||T}function St(r,e,t,n,i){if(i%1!==0)throw"can\'t guess dimensions";if(!t&&!n){const s=Math.sqrt(i/(e===ne?6:1));s%1===0?(t=s,n=s):(t=i,n=1)}else if(n){if(!t&&(t=i/n,t%1))throw"can\'t guess dimensions"}else if(n=i/t,n%1)throw"can\'t guess dimensions";return{width:t,height:n}}function ke(r,e){e.colorspaceConversion!==void 0&&r.pixelStorei(Zo,e.colorspaceConversion),e.premultiplyAlpha!==void 0&&r.pixelStorei(ea,e.premultiplyAlpha),e.flipY!==void 0&&r.pixelStorei(ta,e.flipY)}function Un(r){r.pixelStorei(gr,4),Le(r)&&(r.pixelStorei(Rn,0),r.pixelStorei(Fn,0),r.pixelStorei(Pn,0),r.pixelStorei(kn,0),r.pixelStorei(Cn,0))}function fc(r,e,t,n){n.minMag&&(t.call(r,e,mr,n.minMag),t.call(r,e,pr,n.minMag)),n.min&&t.call(r,e,mr,n.min),n.mag&&t.call(r,e,pr,n.mag),n.wrap&&(t.call(r,e,_t,n.wrap),t.call(r,e,Et,n.wrap),(e===me||go(r,e))&&t.call(r,e,Sn,n.wrap)),n.wrapR&&t.call(r,e,Sn,n.wrapR),n.wrapS&&t.call(r,e,_t,n.wrapS),n.wrapT&&t.call(r,e,Et,n.wrapT),n.minLod!==void 0&&t.call(r,e,Xo,n.minLod),n.maxLod!==void 0&&t.call(r,e,Yo,n.maxLod),n.baseLevel!==void 0&&t.call(r,e,Qo,n.baseLevel),n.maxLevel!==void 0&&t.call(r,e,qo,n.maxLevel),n.compareFunc!==void 0&&t.call(r,e,Jo,n.compareFunc),n.compareMode!==void 0&&t.call(r,e,Ko,n.compareMode)}function Nn(r,e,t){const n=t.target||re;r.bindTexture(n,e),fc(r,n,r.texParameteri,t)}function lc(r){return r=r||te.textureColor,ze(r)?r:new Uint8Array([r[0]*255,r[1]*255,r[2]*255,r[3]*255])}function xr(r,e,t,n,i,s){t=t||te.textureOptions,s=s||A;const o=t.target||re;if(n=n||t.width,i=i||t.height,r.bindTexture(o,e),ac(r,n,i,s))r.generateMipmap(o);else{const a=cc(s)?Go:zo;r.texParameteri(o,mr,a),r.texParameteri(o,pr,a),r.texParameteri(o,_t,xt),r.texParameteri(o,Et,xt)}}function Ve(r){return r.auto===!0||r.auto===void 0&&r.level===void 0}function _r(r,e){return e=e||{},e.cubeFaceOrder||[hr,$o,Wo,Vo,Ho,jo]}function Er(r,e){const n=_r(r,e).map(function(i,s){return{face:i,ndx:s}});return n.sort(function(i,s){return i.face-s.face}),n}function Ln(r,e,t,n){n=n||te.textureOptions;const i=n.target||re,s=n.level||0;let o=t.width,a=t.height;const c=n.internalFormat||n.format||A,u=We(c),d=n.format||u.format,m=n.type||u.type;if(ke(r,n),r.bindTexture(i,e),i===ne){const p=t.width,y=t.height;let l,b;if(p/6===y)l=y,b=[0,0,1,0,2,0,3,0,4,0,5,0];else if(y/6===p)l=p,b=[0,0,0,1,0,2,0,3,0,4,0,5];else if(p/3===y/2)l=p/3,b=[0,0,1,0,2,0,0,1,1,1,2,1];else if(p/2===y/3)l=p/2,b=[0,0,1,0,0,1,1,1,0,2,1,2];else throw"can\'t figure out cube map from element: "+(t.src?t.src:t.nodeName);const _=wn();_?(_.canvas.width=l,_.canvas.height=l,o=l,a=l,Er(r,n).forEach(function(E){const R=b[E.ndx*2+0]*l,k=b[E.ndx*2+1]*l;_.drawImage(t,R,k,l,l,0,0,l,l),r.texImage2D(E.face,s,c,d,m,_.canvas)}),_.canvas.width=1,_.canvas.height=1):typeof createImageBitmap<"u"&&(o=l,a=l,Er(r,n).forEach(function(E){const R=b[E.ndx*2+0]*l,k=b[E.ndx*2+1]*l;r.texImage2D(E.face,s,c,l,l,0,d,m,null),createImageBitmap(t,R,k,l,l,{premultiplyAlpha:"none",colorSpaceConversion:"none"}).then(function(N){ke(r,n),r.bindTexture(i,e),r.texImage2D(E.face,s,c,d,m,N),Ve(n)&&xr(r,e,n,o,a,c)})}))}else if(i===me||i===pe){const p=Math.min(t.width,t.height),y=Math.max(t.width,t.height),l=y/p;if(l%1!==0)throw"can not compute 3D dimensions of element";const b=t.width===y?1:0,_=t.height===y?1:0;r.pixelStorei(gr,1),r.pixelStorei(Rn,t.width),r.pixelStorei(Fn,0),r.pixelStorei(Cn,0),r.texImage3D(i,s,c,p,p,p,0,d,m,null);for(let E=0;E<l;++E){const R=E*p*b,k=E*p*_;r.pixelStorei(Pn,R),r.pixelStorei(kn,k),r.texSubImage3D(i,s,0,0,E,p,p,1,d,m,t)}Un(r)}else r.texImage2D(i,s,c,d,m,t);Ve(n)&&xr(r,e,n,o,a,c),Nn(r,e,n)}function He(){}function dc(r){if(typeof document<"u"){const e=document.createElement("a");return e.href=r,e.hostname===location.hostname&&e.port===location.port&&e.protocol===location.protocol}else{const e=new URL(location.href).origin;return new URL(r,location.href).origin===e}}function hc(r,e){return e===void 0&&!dc(r)?"anonymous":e}function mc(r,e,t){t=t||He;let n;if(e=e!==void 0?e:te.crossOrigin,e=hc(r,e),typeof Image<"u"){n=new Image,e!==void 0&&(n.crossOrigin=e);const i=function(){n.removeEventListener("error",s),n.removeEventListener("load",o),n=null},s=function(){const c="couldn\'t load image: "+r;hn(c),t(c,n),i()},o=function(){t(null,n),i()};return n.addEventListener("error",s),n.addEventListener("load",o),n.src=r,n}else if(typeof ImageBitmap<"u"){let i,s;const o=function(){t(i,s)},a={};e&&(a.mode="cors"),fetch(r,a).then(function(c){if(!c.ok)throw c;return c.blob()}).then(function(c){return createImageBitmap(c,{premultiplyAlpha:"none",colorSpaceConversion:"none"})}).then(function(c){s=c,setTimeout(o)}).catch(function(c){i=c,setTimeout(o)}),n=null}return n}function zn(r){return typeof ImageBitmap<"u"&&r instanceof ImageBitmap||typeof ImageData<"u"&&r instanceof ImageData||typeof HTMLElement<"u"&&r instanceof HTMLElement}function wr(r,e,t){return zn(r)?(setTimeout(function(){t(null,r)}),r):mc(r,e,t)}function vr(r,e,t){t=t||te.textureOptions;const n=t.target||re;if(r.bindTexture(n,e),t.color===!1)return;const i=lc(t.color);if(n===ne)for(let s=0;s<6;++s)r.texImage2D(hr+s,0,A,1,1,0,A,T,i);else n===me||n===pe?r.texImage3D(n,0,A,1,1,1,0,A,T,i):r.texImage2D(n,0,A,1,1,0,A,T,i)}function pc(r,e,t,n){return n=n||He,t=t||te.textureOptions,vr(r,e,t),t=Object.assign({},t),wr(t.src,t.crossOrigin,function(s,o){s?n(s,e,o):(Ln(r,e,o,t),n(null,e,o))})}function gc(r,e,t,n){n=n||He;const i=t.src;if(i.length!==6)throw"there must be 6 urls for a cubemap";const s=t.level||0,o=t.internalFormat||t.format||A,a=We(o),c=t.format||a.format,u=t.type||T,d=t.target||re;if(d!==ne)throw"target must be TEXTURE_CUBE_MAP";vr(r,e,t),t=Object.assign({},t);let m=6;const p=[],y=_r(r,t);let l;function b(_){return function(E,R){--m,E?p.push(E):R.width!==R.height?p.push("cubemap face img is not a square: "+R.src):(ke(r,t),r.bindTexture(d,e),m===5?_r().forEach(function(k){r.texImage2D(k,s,o,c,u,R)}):r.texImage2D(_,s,o,c,u,R),Ve(t)&&r.generateMipmap(d)),m===0&&n(p.length?p:void 0,e,l)}}l=i.map(function(_,E){return wr(_,t.crossOrigin,b(y[E]))})}function yc(r,e,t,n){n=n||He;const i=t.src,s=t.internalFormat||t.format||A,o=We(s),a=t.format||o.format,c=t.type||T,u=t.target||pe;if(u!==me&&u!==pe)throw"target must be TEXTURE_3D or TEXTURE_2D_ARRAY";vr(r,e,t),t=Object.assign({},t);let d=i.length;const m=[];let p;const y=t.level||0;let l=t.width,b=t.height;const _=i.length;let E=!0;function R(k){return function(N,Q){if(--d,N)m.push(N);else{if(ke(r,t),r.bindTexture(u,e),E){E=!1,l=t.width||Q.width,b=t.height||Q.height,r.texImage3D(u,y,s,l,b,_,0,a,c,null);for(let q=0;q<_;++q)r.texSubImage3D(u,y,0,0,q,l,b,1,a,c,Q)}else{let q=Q,L;(Q.width!==l||Q.height!==b)&&(L=wn(),q=L.canvas,L.canvas.width=l,L.canvas.height=b,L.drawImage(Q,0,0,l,b)),r.texSubImage3D(u,y,0,0,k,l,b,1,a,c,q),L&&q===L.canvas&&(L.canvas.width=0,L.canvas.height=0)}Ve(t)&&r.generateMipmap(u)}d===0&&n(m.length?m:void 0,e,p)}}p=i.map(function(k,N){return wr(k,t.crossOrigin,R(N))})}function bc(r,e,t,n){n=n||te.textureOptions;const i=n.target||re;r.bindTexture(i,e);let s=n.width,o=n.height,a=n.depth;const c=n.level||0,u=n.internalFormat||n.format||A,d=We(u),m=n.format||d.format,p=n.type||uc(r,t,d.type);if(ze(t))t instanceof Uint8ClampedArray&&(t=new Uint8Array(t.buffer));else{const _=dn(p);t=new _(t)}const y=oc(u,p),l=t.byteLength/y;if(l%1)throw"length wrong size for format: "+En(r,m);let b;if(i===me||i===pe)if(!s&&!o&&!a){const _=Math.cbrt(l);if(_%1!==0)throw"can\'t guess cube size of array of numElements: "+l;s=_,o=_,a=_}else s&&(!o||!a)?(b=St(r,i,o,a,l/s),o=b.width,a=b.height):o&&(!s||!a)?(b=St(r,i,s,a,l/o),s=b.width,a=b.height):(b=St(r,i,s,o,l/a),s=b.width,o=b.height);else b=St(r,i,s,o,l),s=b.width,o=b.height;if(Un(r),r.pixelStorei(gr,n.unpackAlignment||1),ke(r,n),i===ne){const _=y/t.BYTES_PER_ELEMENT,E=l/6*_;Er(r,n).forEach(R=>{const k=E*R.ndx,N=t.subarray(k,k+E);r.texImage2D(R.face,c,u,s,o,0,m,p,N)})}else i===me||i===pe?r.texImage3D(i,c,u,s,o,a,0,m,p,t):r.texImage2D(i,c,u,s,o,0,m,p,t);return{width:s,height:o,depth:a,type:p}}function xc(r,e,t){const n=t.target||re;r.bindTexture(n,e);const i=t.level||0,s=t.internalFormat||t.format||A,o=We(s),a=t.format||o.format,c=t.type||o.type;if(ke(r,t),n===ne)for(let u=0;u<6;++u)r.texImage2D(hr+u,i,s,t.width,t.height,0,a,c,null);else n===me||n===pe?r.texImage3D(n,i,s,t.width,t.height,t.depth,0,a,c,null):r.texImage2D(n,i,s,t.width,t.height,0,a,c,null)}function Gn(r,e,t){t=t||He,e=e||te.textureOptions;const n=r.createTexture(),i=e.target||re;let s=e.width||1,o=e.height||1;const a=e.internalFormat||A;r.bindTexture(i,n),i===ne&&(r.texParameteri(i,_t,xt),r.texParameteri(i,Et,xt));let c=e.src;if(c)if(typeof c=="function"&&(c=c(r,e)),typeof c=="string")pc(r,n,e,t);else if(ze(c)||Array.isArray(c)&&(typeof c[0]=="number"||Array.isArray(c[0])||ze(c[0]))){const u=bc(r,n,c,e);s=u.width,o=u.height}else Array.isArray(c)&&(typeof c[0]=="string"||zn(c[0]))?i===ne?gc(r,n,e,t):yc(r,n,e,t):(Ln(r,n,c,e),s=c.width,o=c.height);else xc(r,n,e);return Ve(e)&&xr(r,n,e,s,o,a),Nn(r,n,e),n}const Tr=hn;function $n(r){return typeof document<"u"&&document.getElementById?document.getElementById(r):null}const Rt=33984,Ft=34962,_c=34963,Ec=35713,wc=35714,vc=35632,Tc=35633,Ac=35981,Wn=35718,Ic=35721,Sc=35971,Rc=35382,Fc=35396,Pc=35398,kc=35392,Cc=35395,Pt=5126,Vn=35664,Hn=35665,jn=35666,Ar=5124,Xn=35667,Yn=35668,Qn=35669,qn=35670,Kn=35671,Jn=35672,Zn=35673,ei=35674,ti=35675,ri=35676,Bc=35678,Dc=35680,Mc=35679,Oc=35682,Uc=35685,Nc=35686,Lc=35687,zc=35688,Gc=35689,$c=35690,Wc=36289,Vc=36292,Hc=36293,Ir=5125,ni=36294,ii=36295,si=36296,jc=36298,Xc=36299,Yc=36300,Qc=36303,qc=36306,Kc=36307,Jc=36308,Zc=36311,kt=3553,Ct=34067,Sr=32879,Bt=35866,x={};function oi(r,e){return x[e].bindPoint}function eu(r,e){return function(t){r.uniform1f(e,t)}}function tu(r,e){return function(t){r.uniform1fv(e,t)}}function ru(r,e){return function(t){r.uniform2fv(e,t)}}function nu(r,e){return function(t){r.uniform3fv(e,t)}}function iu(r,e){return function(t){r.uniform4fv(e,t)}}function ai(r,e){return function(t){r.uniform1i(e,t)}}function ci(r,e){return function(t){r.uniform1iv(e,t)}}function ui(r,e){return function(t){r.uniform2iv(e,t)}}function fi(r,e){return function(t){r.uniform3iv(e,t)}}function li(r,e){return function(t){r.uniform4iv(e,t)}}function su(r,e){return function(t){r.uniform1ui(e,t)}}function ou(r,e){return function(t){r.uniform1uiv(e,t)}}function au(r,e){return function(t){r.uniform2uiv(e,t)}}function cu(r,e){return function(t){r.uniform3uiv(e,t)}}function uu(r,e){return function(t){r.uniform4uiv(e,t)}}function fu(r,e){return function(t){r.uniformMatrix2fv(e,!1,t)}}function lu(r,e){return function(t){r.uniformMatrix3fv(e,!1,t)}}function du(r,e){return function(t){r.uniformMatrix4fv(e,!1,t)}}function hu(r,e){return function(t){r.uniformMatrix2x3fv(e,!1,t)}}function mu(r,e){return function(t){r.uniformMatrix3x2fv(e,!1,t)}}function pu(r,e){return function(t){r.uniformMatrix2x4fv(e,!1,t)}}function gu(r,e){return function(t){r.uniformMatrix4x2fv(e,!1,t)}}function yu(r,e){return function(t){r.uniformMatrix3x4fv(e,!1,t)}}function bu(r,e){return function(t){r.uniformMatrix4x3fv(e,!1,t)}}function O(r,e,t,n){const i=oi(r,e);return Le(r)?function(s){let o,a;!s||fr(r,s)?(o=s,a=null):(o=s.texture,a=s.sampler),r.uniform1i(n,t),r.activeTexture(Rt+t),r.bindTexture(i,o),r.bindSampler(t,a)}:function(s){r.uniform1i(n,t),r.activeTexture(Rt+t),r.bindTexture(i,s)}}function U(r,e,t,n,i){const s=oi(r,e),o=new Int32Array(i);for(let a=0;a<i;++a)o[a]=t+a;return Le(r)?function(a){r.uniform1iv(n,o),a.forEach(function(c,u){r.activeTexture(Rt+o[u]);let d,m;!c||fr(r,c)?(d=c,m=null):(d=c.texture,m=c.sampler),r.bindSampler(t,m),r.bindTexture(s,d)})}:function(a){r.uniform1iv(n,o),a.forEach(function(c,u){r.activeTexture(Rt+o[u]),r.bindTexture(s,c)})}}x[Pt]={Type:Float32Array,size:4,setter:eu,arraySetter:tu},x[Vn]={Type:Float32Array,size:8,setter:ru,cols:2},x[Hn]={Type:Float32Array,size:12,setter:nu,cols:3},x[jn]={Type:Float32Array,size:16,setter:iu,cols:4},x[Ar]={Type:Int32Array,size:4,setter:ai,arraySetter:ci},x[Xn]={Type:Int32Array,size:8,setter:ui,cols:2},x[Yn]={Type:Int32Array,size:12,setter:fi,cols:3},x[Qn]={Type:Int32Array,size:16,setter:li,cols:4},x[Ir]={Type:Uint32Array,size:4,setter:su,arraySetter:ou},x[ni]={Type:Uint32Array,size:8,setter:au,cols:2},x[ii]={Type:Uint32Array,size:12,setter:cu,cols:3},x[si]={Type:Uint32Array,size:16,setter:uu,cols:4},x[qn]={Type:Uint32Array,size:4,setter:ai,arraySetter:ci},x[Kn]={Type:Uint32Array,size:8,setter:ui,cols:2},x[Jn]={Type:Uint32Array,size:12,setter:fi,cols:3},x[Zn]={Type:Uint32Array,size:16,setter:li,cols:4},x[ei]={Type:Float32Array,size:32,setter:fu,rows:2,cols:2},x[ti]={Type:Float32Array,size:48,setter:lu,rows:3,cols:3},x[ri]={Type:Float32Array,size:64,setter:du,rows:4,cols:4},x[Uc]={Type:Float32Array,size:32,setter:hu,rows:2,cols:3},x[Nc]={Type:Float32Array,size:32,setter:pu,rows:2,cols:4},x[Lc]={Type:Float32Array,size:48,setter:mu,rows:3,cols:2},x[zc]={Type:Float32Array,size:48,setter:yu,rows:3,cols:4},x[Gc]={Type:Float32Array,size:64,setter:gu,rows:4,cols:2},x[$c]={Type:Float32Array,size:64,setter:bu,rows:4,cols:3},x[Bc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:kt},x[Dc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Ct},x[Mc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Sr},x[Oc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:kt},x[Wc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Bt},x[Vc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Bt},x[Hc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Ct},x[jc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:kt},x[Xc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Sr},x[Yc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Ct},x[Qc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Bt},x[qc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:kt},x[Kc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Sr},x[Jc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Ct},x[Zc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Bt};function Dt(r,e){return function(t){if(t.value)switch(r.disableVertexAttribArray(e),t.value.length){case 4:r.vertexAttrib4fv(e,t.value);break;case 3:r.vertexAttrib3fv(e,t.value);break;case 2:r.vertexAttrib2fv(e,t.value);break;case 1:r.vertexAttrib1fv(e,t.value);break;default:throw new Error("the length of a float constant value must be between 1 and 4!")}else r.bindBuffer(Ft,t.buffer),r.enableVertexAttribArray(e),r.vertexAttribPointer(e,t.numComponents||t.size,t.type||Pt,t.normalize||!1,t.stride||0,t.offset||0),r.vertexAttribDivisor&&r.vertexAttribDivisor(e,t.divisor||0)}}function se(r,e){return function(t){if(t.value)if(r.disableVertexAttribArray(e),t.value.length===4)r.vertexAttrib4iv(e,t.value);else throw new Error("The length of an integer constant value must be 4!");else r.bindBuffer(Ft,t.buffer),r.enableVertexAttribArray(e),r.vertexAttribIPointer(e,t.numComponents||t.size,t.type||Ar,t.stride||0,t.offset||0),r.vertexAttribDivisor&&r.vertexAttribDivisor(e,t.divisor||0)}}function Mt(r,e){return function(t){if(t.value)if(r.disableVertexAttribArray(e),t.value.length===4)r.vertexAttrib4uiv(e,t.value);else throw new Error("The length of an unsigned integer constant value must be 4!");else r.bindBuffer(Ft,t.buffer),r.enableVertexAttribArray(e),r.vertexAttribIPointer(e,t.numComponents||t.size,t.type||Ir,t.stride||0,t.offset||0),r.vertexAttribDivisor&&r.vertexAttribDivisor(e,t.divisor||0)}}function Rr(r,e,t){const n=t.size,i=t.count;return function(s){r.bindBuffer(Ft,s.buffer);const o=s.size||s.numComponents||n,a=o/i,c=s.type||Pt,d=x[c].size*o,m=s.normalize||!1,p=s.offset||0,y=d/i;for(let l=0;l<i;++l)r.enableVertexAttribArray(e+l),r.vertexAttribPointer(e+l,a,c,m,d,p+y*l),r.vertexAttribDivisor&&r.vertexAttribDivisor(e+l,s.divisor||0)}}const I={};I[Pt]={size:4,setter:Dt},I[Vn]={size:8,setter:Dt},I[Hn]={size:12,setter:Dt},I[jn]={size:16,setter:Dt},I[Ar]={size:4,setter:se},I[Xn]={size:8,setter:se},I[Yn]={size:12,setter:se},I[Qn]={size:16,setter:se},I[Ir]={size:4,setter:Mt},I[ni]={size:8,setter:Mt},I[ii]={size:12,setter:Mt},I[si]={size:16,setter:Mt},I[qn]={size:4,setter:se},I[Kn]={size:8,setter:se},I[Jn]={size:12,setter:se},I[Zn]={size:16,setter:se},I[ei]={size:4,setter:Rr,count:2},I[ti]={size:9,setter:Rr,count:3},I[ri]={size:16,setter:Rr,count:4};const xu=/ERROR:\\s*\\d+:(\\d+)/gi;function _u(r,e="",t=0){const n=[...e.matchAll(xu)],i=new Map(n.map((s,o)=>{const a=parseInt(s[1]),c=n[o+1],u=c?c.index:e.length,d=e.substring(s.index,u);return[a-1,d]}));return r.split(`\n`).map((s,o)=>{const a=i.get(o);return`${o+1+t}: ${s}${a?`\n\n^^^ ${a}`:""}`}).join(`\n`)}const di=/^[ \\t]*\\n/;function hi(r){let e=0;return di.test(r)&&(e=1,r=r.replace(di,"")),{lineOffset:e,shaderSource:r}}function Eu(r,e){return r.errorCallback(e),r.callback&&setTimeout(()=>{r.callback(`${e}\n${r.errors.join(`\n`)}`)}),null}function wu(r,e,t,n){if(n=n||Tr,!r.getShaderParameter(t,Ec)){const s=r.getShaderInfoLog(t),{lineOffset:o,shaderSource:a}=hi(r.getShaderSource(t)),c=`${_u(a,s,o)}\nError compiling ${En(r,e)}: ${s}`;return n(c),c}return""}function Fr(r,e,t){let n,i,s;if(typeof e=="function"&&(t=e,e=void 0),typeof r=="function")t=r,r=void 0;else if(r&&!Array.isArray(r)){const u=r;t=u.errorCallback,r=u.attribLocations,n=u.transformFeedbackVaryings,i=u.transformFeedbackMode,s=u.callback}const o=t||Tr,a=[],c={errorCallback(u,...d){a.push(u),o(u,...d)},transformFeedbackVaryings:n,transformFeedbackMode:i,callback:s,errors:a};{let u={};Array.isArray(r)?r.forEach(function(d,m){u[d]=e?e[m]:m}):u=r||{},c.attribLocations=u}return c}const vu=["VERTEX_SHADER","FRAGMENT_SHADER"];function Tu(r,e){if(e.indexOf("frag")>=0)return vc;if(e.indexOf("vert")>=0)return Tc}function Au(r,e,t){const n=r.getAttachedShaders(e);for(const i of n)t.has(i)&&r.deleteShader(i);r.deleteProgram(e)}const Iu=(r=0)=>new Promise(e=>setTimeout(e,r));function Su(r,e,t){const n=r.createProgram(),{attribLocations:i,transformFeedbackVaryings:s,transformFeedbackMode:o}=Fr(t);for(let a=0;a<e.length;++a){let c=e[a];if(typeof c=="string"){const u=$n(c),d=u?u.text:c;let m=r[vu[a]];u&&u.type&&(m=Tu(r,u.type)||m),c=r.createShader(m),r.shaderSource(c,hi(d).shaderSource),r.compileShader(c),r.attachShader(n,c)}}Object.entries(i).forEach(([a,c])=>r.bindAttribLocation(n,c,a));{let a=s;a&&(a.attribs&&(a=a.attribs),Array.isArray(a)||(a=Object.keys(a)),r.transformFeedbackVaryings(n,a,o||Ac))}return r.linkProgram(n),n}function Ru(r,e,t,n,i){const s=Fr(t,n,i),o=new Set(e),a=Su(r,e,s);function c(u,d){const m=Pu(u,d,s.errorCallback);return m&&Au(u,d,o),m}if(s.callback){Fu(r,a).then(()=>{const u=c(r,a);s.callback(u,u?void 0:a)});return}return c(r,a)?void 0:a}async function Fu(r,e){const t=r.getExtension("KHR_parallel_shader_compile"),n=t?(s,o)=>s.getProgramParameter(o,t.COMPLETION_STATUS_KHR):()=>!0;let i=0;do await Iu(i),i=1e3/60;while(!n(r,e))}function Pu(r,e,t){if(t=t||Tr,!r.getProgramParameter(e,wc)){const i=r.getProgramInfoLog(e);t(`Error in program linking: ${i}`);const o=r.getAttachedShaders(e).map(a=>wu(r,r.getShaderParameter(a,r.SHADER_TYPE),a,t));return`${i}\n${o.filter(a=>a).join(`\n`)}`}}function ku(r,e,t,n,i){return Ru(r,e,t,n,i)}function mi(r){const e=r.name;return e.startsWith("gl_")||e.startsWith("webgl_")}const Cu=/(\\.|\\[|]|\\w+)/g,Bu=r=>r>="0"&&r<="9";function Du(r,e,t,n){const i=r.split(Cu).filter(a=>a!=="");let s=0,o="";for(;;){const a=i[s++];o+=a;const c=Bu(a[0]),u=c?parseInt(a):a;if(c&&(o+=i[s++]),s===i.length){t[u]=e;break}else{const m=i[s++],p=m==="[",y=t[u]||(p?[]:{});t[u]=y,t=y,n[o]=n[o]||(function(l){return function(b){pi(l,b)}})(y),o+=m}}}function Mu(r,e){let t=0;function n(a,c,u){const d=c.name.endsWith("[0]"),m=c.type,p=x[m];if(!p)throw new Error(`unknown type: 0x${m.toString(16)}`);let y;if(p.bindPoint){const l=t;t+=c.size,d?y=p.arraySetter(r,m,l,u,c.size):y=p.setter(r,m,l,u,c.size)}else p.arraySetter&&d?y=p.arraySetter(r,u):y=p.setter(r,u);return y.location=u,y}const i={},s={},o=r.getProgramParameter(e,Wn);for(let a=0;a<o;++a){const c=r.getActiveUniform(e,a);if(mi(c))continue;let u=c.name;u.endsWith("[0]")&&(u=u.substr(0,u.length-3));const d=r.getUniformLocation(e,c.name);if(d){const m=n(e,c,d);i[u]=m,Du(u,m,s,i)}}return i}function Ou(r,e){const t={},n=r.getProgramParameter(e,Sc);for(let i=0;i<n;++i){const s=r.getTransformFeedbackVarying(e,i);t[s.name]={index:i,type:s.type,size:s.size}}return t}function Uu(r,e){const t=r.getProgramParameter(e,Wn),n=[],i=[];for(let a=0;a<t;++a){i.push(a),n.push({});const c=r.getActiveUniform(e,a);n[a].name=c.name}[["UNIFORM_TYPE","type"],["UNIFORM_SIZE","size"],["UNIFORM_BLOCK_INDEX","blockNdx"],["UNIFORM_OFFSET","offset"]].forEach(function(a){const c=a[0],u=a[1];r.getActiveUniforms(e,i,r[c]).forEach(function(d,m){n[m][u]=d})});const s={},o=r.getProgramParameter(e,Rc);for(let a=0;a<o;++a){const c=r.getActiveUniformBlockName(e,a),u={index:r.getUniformBlockIndex(e,c),usedByVertexShader:r.getActiveUniformBlockParameter(e,a,Fc),usedByFragmentShader:r.getActiveUniformBlockParameter(e,a,Pc),size:r.getActiveUniformBlockParameter(e,a,kc),uniformIndices:r.getActiveUniformBlockParameter(e,a,Cc)};u.used=u.usedByVertexShader||u.usedByFragmentShader,s[c]=u}return{blockSpecs:s,uniformData:n}}function pi(r,e){for(const t in e){const n=r[t];typeof n=="function"?n(e[t]):pi(r[t],e[t])}}function gi(r,...e){const t=r.uniformSetters||r,n=e.length;for(let i=0;i<n;++i){const s=e[i];if(Array.isArray(s)){const o=s.length;for(let a=0;a<o;++a)gi(t,s[a])}else for(const o in s){const a=t[o];a&&a(s[o])}}}function Nu(r,e){const t={},n=r.getProgramParameter(e,Ic);for(let i=0;i<n;++i){const s=r.getActiveAttrib(e,i);if(mi(s))continue;const o=r.getAttribLocation(e,s.name),a=I[s.type],c=a.setter(r,o,a);c.location=o,t[s.name]=c}return t}function Lu(r,e){for(const t in e){const n=r[t];n&&n(e[t])}}function zu(r,e,t){t.vertexArrayObject?r.bindVertexArray(t.vertexArrayObject):(Lu(e.attribSetters||e,t.attribs),t.indices&&r.bindBuffer(_c,t.indices))}function yi(r,e){const t=Mu(r,e),n=Nu(r,e),i={program:e,uniformSetters:t,attribSetters:n};return Le(r)&&(i.uniformBlockSpec=Uu(r,e),i.transformFeedbackInfo=Ou(r,e)),i}const Gu=/\\s|{|}|;/;function $u(r,e,t,n,i){const s=Fr(t,n,i),o=[];if(e=e.map(function(u){if(!Gu.test(u)){const d=$n(u);if(d)u=d.text;else{const m=`no element with id: ${u}`;s.errorCallback(m),o.push(m)}}return u}),o.length)return Eu(s,"");const a=s.callback;a&&(s.callback=(u,d)=>{a(u,u?void 0:yi(r,d))});const c=ku(r,e,s);return c?yi(r,c):null}const Wu=4,bi=5123;function Vu(r,e,t,n,i,s){t=t===void 0?Wu:t;const o=e.indices,a=e.elementType,c=n===void 0?e.numElements:n;i=i===void 0?0:i,a||o?s!==void 0?r.drawElementsInstanced(t,c,a===void 0?bi:e.elementType,i,s):r.drawElements(t,c,a===void 0?bi:e.elementType,i):s!==void 0?r.drawArraysInstanced(t,i,c,s):r.drawArrays(t,i,c)}const xi=36160,Ot=36161,Hu=3553,ju=5121,Xu=6402,Yu=6408,Qu=33190,qu=36012,Ku=35056,Ju=36013,Zu=32854,ef=32855,tf=36194,_i=33189,Ei=6401,wi=36168,Pr=34041,kr=36064,Ut=36096,vi=36128,Cr=33306,Br=33071,Dr=9729,rf=[{format:Yu,type:ju,min:Dr,wrap:Br},{format:Pr}],G={};G[Pr]=Cr,G[Ei]=vi,G[wi]=vi,G[Xu]=Ut,G[_i]=Ut,G[Qu]=Ut,G[qu]=Ut,G[Ku]=Cr,G[Ju]=Cr;function nf(r,e){return G[r]||G[e]}const oe={};oe[Zu]=!0,oe[ef]=!0,oe[tf]=!0,oe[Pr]=!0,oe[_i]=!0,oe[Ei]=!0,oe[wi]=!0;function sf(r){return oe[r]}const of=32;function af(r){return r>=kr&&r<kr+of}function Ti(r,e,t,n){const i=xi,s=r.createFramebuffer();r.bindFramebuffer(i,s),t=t||r.drawingBufferWidth,n=n||r.drawingBufferHeight,e=e||rf;const o=[],a={framebuffer:s,attachments:[],width:t,height:n};return e.forEach(function(c,u){let d=c.attachment;const m=c.samples,p=c.format;let y=c.attachmentPoint||nf(p,c.internalFormat);if(y||(y=kr+u),af(y)&&o.push(y),!d)if(m!==void 0||sf(p))d=r.createRenderbuffer(),r.bindRenderbuffer(Ot,d),m>1?r.renderbufferStorageMultisample(Ot,m,p,t,n):r.renderbufferStorage(Ot,p,t,n);else{const l=Object.assign({},c);l.width=t,l.height=n,l.auto===void 0&&(l.auto=!1,l.min=l.min||l.minMag||Dr,l.mag=l.mag||l.minMag||Dr,l.wrapS=l.wrapS||l.wrap||Br,l.wrapT=l.wrapT||l.wrap||Br),d=Gn(r,l)}if(po(r,d))r.framebufferRenderbuffer(i,y,Ot,d);else if(fr(r,d))c.layer!==void 0?r.framebufferTextureLayer(i,y,d,c.level||0,c.layer):r.framebufferTexture2D(i,y,c.target||Hu,d,c.level||0);else throw new Error("unknown attachment type");a.attachments.push(d)}),r.drawBuffers&&r.drawBuffers(o),a}function cf(r,e,t){t=t||xi,e?(r.bindFramebuffer(t,e.framebuffer),r.viewport(0,0,e.width,e.height)):(r.bindFramebuffer(t,null),r.viewport(0,0,r.drawingBufferWidth,r.drawingBufferHeight))}function D(r,e){return()=>e instanceof WebGLTexture?e:Gn(r,{src:e,wrap:r.CLAMP_TO_EDGE})}const Ce=2;class je{constructor(e){this.id="_";const{context:t,width:n,height:i}=e;this.context=t,this.options=e;const s=this.buildDefines();this.programInfo=$u(this.context,[s+this.getVertexShader(),s+this.getFragmentShader()]),this.bufferInfo=Lo(this.context,this.getBuffers()),this.fbi=Ti(this.context,[{format:this.context.RGBA,type:this.context.UNSIGNED_BYTE,min:this.context.LINEAR,wrap:this.context.CLAMP_TO_EDGE}],n,i),this.output=this.fbi.attachments[0]}resizeOutput(e,t){this.fbi=Ti(this.context,[{format:this.context.RGBA,type:this.context.UNSIGNED_BYTE,min:this.context.LINEAR,wrap:this.context.CLAMP_TO_EDGE}],e,t),this.options.width=e,this.options.height=t,this.output=this.fbi.attachments[0]}getDefines(){return{}}getBuffers(){return{position:{numComponents:2,data:[-1,-1,-1,1,1,-1,1,1,-1,1,1,-1]},texture_coord:{numComponents:2,data:[0,0,0,1,1,0,1,1,0,1,1,0]}}}buildDefines(){let e="";const t=this.getDefines();for(let n in t)e+=`#define ${n} ${t[n].toFixed(1)}\n`;return e}run(e){this.profiler?.pushContext(`[${this.id}] PROG : ${this.constructor.name}`),this.profiler?.pushContext(`[${this.id}] UNIFORMS`);for(const i in e)typeof e[i]=="function"&&(this.profiler?.pushContext(`[${this.id}] UNI : ${i}`),e[i]=e[i](),this.profiler?.popContext(`[${this.id}] UNI : ${i}`));this.profiler?.popContext(`[${this.id}] UNIFORMS`);const t=Date.now();let n=0;this.lastRun&&(n=(t-this.lastRun)/1e3),this.lastRun=t,this.context.viewport(0,0,this.context.canvas.width,this.context.canvas.height),this.context.useProgram(this.programInfo.program),zu(this.context,this.programInfo,this.bufferInfo),gi(this.programInfo,{delta:n,canvas:[this.context.canvas.width,this.context.canvas.height],...e}),cf(this.context,this.options.disableFramebuffer?null:this.fbi),Vu(this.context,this.bufferInfo),this.profiler?.popContext(`[${this.id}] PROG : ${this.constructor.name}`)}setProfiler(e){this.profiler=e}}var uf=`precision mediump float;\n\nvarying vec2 _texture_coord;\n\nuniform sampler2D background;\nuniform sampler2D foreground;\nuniform sampler2D threshold;\n\nvoid main() {\n vec4 backgroundColor = texture2D(background, _texture_coord);\n vec4 foregroundColor = texture2D(foreground, _texture_coord);\n vec4 tresholdColor = texture2D(threshold, _texture_coord);\n gl_FragColor = foregroundColor * tresholdColor.a +\n backgroundColor * (1. - tresholdColor.a);\n}\n`,ff=`varying vec2 _texture_coord;\n\nattribute vec2 position;\nattribute vec2 texture_coord;\n\nvoid main() {\n gl_Position = vec4(position, 0., 1.);\n _texture_coord = texture_coord;\n _texture_coord.y = 1. - texture_coord.y;\n}\n`;class Mr extends je{getFragmentShader(){return uf}getVertexShader(){return ff}}class Or{constructor(){this.steps=[]}addStep(e){this.steps.push(e)}async run(){for(const e of this.steps)e.program.run(e.getUniforms())}resizeOutput(e,t){this.profiler?.pushContext(`PIP [${this.constructor.name}]`);for(const n of this.steps)n.preventResize||n.program.resizeOutput(e,t);this.profiler?.popContext(`PIP [${this.constructor.name}]`)}setProfiler(e){this.profiler=e;for(const t of this.steps)t.program.setProfiler(e)}setId(e){for(const t of this.steps)t.program.id=e}}class Ur extends Or{constructor(){super(...arguments),this.preciseMaskEnabled=!1}}class Ai extends Ur{constructor(e){super(),this.context=e,this.preciseMaskEnabled=!0;const t={context:e,height:e.canvas.height,width:e.canvas.width},n=new Mr({...t,disableFramebuffer:!0});this.addStep({program:n,getUniforms:()=>({background:D(e,this.inputBackgroundImage),foreground:D(e,this.inputImage),threshold:D(e,this.inputMask)})})}setData(e,t){this.inputImage=e,this.inputMask=t}}var lf=`precision mediump float;\n\nvarying vec2 _texture_coord;\nuniform sampler2D texture;\n\nvoid main() { gl_FragColor = texture2D(texture, _texture_coord); }\n`,df=`varying vec2 _texture_coord;\n\nattribute vec2 position;\nattribute vec2 texture_coord;\nuniform bool invert_y;\n\nvoid main() {\n gl_Position = vec4(position, 0., 1.);\n _texture_coord = texture_coord;\n if (invert_y) {\n _texture_coord.y = 1. - texture_coord.y;\n }\n}\n`;class hf extends je{getFragmentShader(){return lf}getVertexShader(){return df}}class mf extends Or{constructor(e,t,n){super(),this.context=e;const i={context:e,height:n,width:t};this.addStep({program:new hf({...i,disableFramebuffer:!0}),getUniforms:()=>({texture:D(e,this.inputImage),invert_y:!0})})}setData(e){this.inputImage=e}}async function Ii(r){return new Promise(e=>{setTimeout(()=>{e()},r)})}var pf=`precision mediump float;\n\nvarying vec2 _texture_coord;\n\nuniform vec2 canvas;\nuniform sampler2D texture;\n\nvec4 loop();\n\nvoid main() { gl_FragColor = loop(); }\n`,gf=`varying vec2 _texture_coord;\n\nattribute vec2 position;\nattribute vec2 texture_coord;\n\nvoid main() {\n gl_Position = vec4(position, 0., 1.);\n _texture_coord = texture_coord;\n}\n`,Nr=(r=>(r[r.LINEAR=0]="LINEAR",r[r.GAUSSIAN=1]="GAUSSIAN",r))(Nr||{});class Si extends je{getDefines(){return{RADIUS:this.options.radius??1}}getFragmentShader(){return pf+this.createLoopFunction()}getVertexShader(){return gf}createLoopFunction(){let e=this.options.radius??1;return`\n\n vec4 loop() { \n vec4 result = vec4(0,0,0,0);\n float factorSum = 0.;\n\n vec2 normalizedRadius = vec2(-${e}.) / canvas;\n vec2 normalizedIncrement = vec2(1.) / canvas;\n vec2 diff = normalizedRadius;\n\n for(int y=-${e}; y<${e+1}; ++y) {\n for(int x=-${e}; x<${e+1}; ++x) {\n float factor = 1.;\n result += factor * texture2D(texture, _texture_coord + diff);\n factorSum += factor;\n diff.x += normalizedIncrement.x;\n }\n diff.y += normalizedIncrement.y;\n diff.x = normalizedRadius.x;\n }\n return result / factorSum;\n }`}}var yf=`#version 300 es\n// https://github.com/Volcomix/virtual-background/blob/main/src/pipelines/webgl2/jointBilateralFilterStage.ts\n\nprecision highp float;\nuniform sampler2D input_frame;\nuniform sampler2D segmentation_mask;\nuniform sampler2D threshold;\nuniform vec2 texel_size;\nuniform float step;\nuniform float radius;\nuniform float offset;\nuniform float sigma_texel;\nuniform float sigma_color;\n\nin vec2 _texture_coord;\nout vec4 outColor;\n\nfloat gaussian(float x, float sigma) {\n float coeff = -0.5 / (sigma * sigma * 4.0 + 1.0e-6);\n return exp((x * x) * coeff);\n}\n\nvoid main() {\n vec2 centerCoord = _texture_coord;\n vec3 centerColor = texture(input_frame, centerCoord).rgb;\n float newVal = 0.0;\n float spaceWeight = 0.0;\n float colorWeight = 0.0;\n float totalWeight = 0.0;\n // Subsample kernel space.\n for (float i = -radius + offset; i <= radius; i += step) {\n for (float j = -radius + offset; j <= radius; j += step) {\n vec2 shift = vec2(j, i) * texel_size;\n vec2 coord = vec2(centerCoord + shift);\n vec3 frameColor = texture(input_frame, coord).rgb;\n float threshold = texture(threshold, coord).a;\n float outVal = texture(segmentation_mask, coord).a;\n\n spaceWeight = gaussian(distance(centerCoord, coord), sigma_texel);\n colorWeight = gaussian(distance(centerColor, frameColor), sigma_color);\n totalWeight += spaceWeight * colorWeight;\n newVal += spaceWeight * colorWeight * outVal * threshold;\n }\n }\n newVal /= totalWeight;\n outColor = vec4(vec3(0.), newVal);\n}`,bf=`#version 300 es\nin vec2 position;\nin vec2 texture_coord;\nout vec2 _texture_coord;\nvoid main() {\n gl_Position = vec4(position, 0.0, 1.0);\n _texture_coord = texture_coord;\n}`;class xf extends je{getFragmentShader(){return yf}getVertexShader(){return bf}}class _f extends Or{constructor(e,t,n){super(),this.context=e;const i={context:e,height:n,width:t},s=new Si({...i,radius:1,type:Nr.GAUSSIAN});this.jointBilateral=new xf(i),this.addStep({program:s,getUniforms:()=>({inputs:D(e,this.inputMask)})}),this.addStep({program:this.jointBilateral,getUniforms:()=>{const a=this.inputImage?.width??1,c=this.inputImage?.height??1;this.inputMask?.width,this.inputMask?.height;const u=3,d=Math.max(1,Math.sqrt(u)*.66),m=1/a,p=1/c;return{input_frame:D(e,this.inputImage),segmentation_mask:D(e,this.inputMask),texel_size:[m,p],step:d,radius:u,offset:d>1?d*.5:0,sigma_texel:Math.max(m,p)*u,sigma_color:u}}}),this.output=this.jointBilateral.output}setData(e,t){this.previousInputImage=this.inputImage?this.inputImage:e,this.previousInputMask=this.inputMask?this.inputMask:t,this.inputImage=e,this.inputMask=t}resizeOutput(e,t){super.resizeOutput(e,t),this.output=this.jointBilateral.output}}class Ef{constructor(e){this.queries=[],this.context=e,this.extension=e.getExtension("EXT_disjoint_timer_query_webgl2")}start(){}stop(){this.activeQuery&&this.context.endQuery(this.extension.TIME_ELAPSED_EXT)}pushContext(e){this.createQuery("PUSH",e)}popContext(e){this.createQuery("POP",e)}createQuery(e,t){this.activeQuery&&this.context.endQuery(this.extension.TIME_ELAPSED_EXT),this.activeQuery=this.context.createQuery(),this.context.beginQuery(this.extension.TIME_ELAPSED_EXT,this.activeQuery),this.queries.push({name:t,action:e,query:this.activeQuery})}async getResolvedQueries(){const e=(await Promise.all([...this.queries].map(t=>this.resolveQuery(t)))).filter(t=>t);for(let t=1;t<e.length;++t)e[t].timestamp+=e[t-1].duration+e[t-1].timestamp;return e}async resolveQuery(e){if(!await this.awaitQueryAvailable(e)){console.log("Unawaitable query",e);return}if(this.context.getParameter(this.extension.GPU_DISJOINT_EXT)){console.log("Disjointed query",e);return}return{...e,duration:this.context.getQueryParameter(e.query,this.context.QUERY_RESULT),timestamp:0}}async awaitQueryAvailable(e){for(let t=0;t<10;++t){if(this.context.getQueryParameter(e.query,this.context.QUERY_RESULT_AVAILABLE))return e;await Ii(200)}}}class Nt{constructor(){this.previousImageWidth=0,this.previousImageHeight=0,this.previousMaskWidth=Ce,this.previousMaskHeight=Ce,this.postProcessingEnabled=!0;const e=new OffscreenCanvas(0,0),t=e.getContext("webgl2");if(!t)throw"Fail to retrieve webgl2 context";this.canvas=e,this.context=t,this.improveMask=new _f(this.context,Ce,Ce)}enablePostProcessing(){this.postProcessingEnabled=!0}disablePostProcessing(){this.postProcessingEnabled=!1}async profileWebgl(e){const t=new Ef(this.context);return this.profiler=t,t.start(),await Ii(e),this.profiler=void 0,t.stop(),t.getResolvedQueries()}async render(e,t){if(!this.pipeline)throw"missing pipeline";(this.previousImageHeight!==e.height||this.previousImageWidth!==e.width)&&this.resizeOutput(e.width,e.height),(this.previousMaskHeight!==t.height||this.previousMaskWidth!==t.width)&&(this.improveMask.resizeOutput(t.width,t.height),this.previousMaskWidth=t.width,this.previousMaskHeight=t.height);const n="renderer";this.profiler?.pushContext(n),this.improveMask.setProfiler(this.profiler),this.pipeline.setProfiler(this.profiler);const i=await createImageBitmap(t);let s=i;return this.postProcessingEnabled&&(this.improveMask.setData(e,i),this.improveMask.run(),s=this.improveMask.output),this.pipeline.setData(e,s),await this.pipeline.run(),this.profiler?.popContext(n),this.canvas}resizeOutput(e,t){this.canvas.width=e,this.canvas.height=t,this.pipeline?.resizeOutput(e,t),this.previousImageWidth=e,this.previousImageHeight=t}destroy(){const e=this.context?.getExtension("WEBGL_lose_context");e&&e.loseContext()}}class Ri extends Nt{constructor(){super(),this.pipeline=new Ai(this.context);const e=new OffscreenCanvas(0,0),t=e.getContext("webgl2");if(!t)throw"Fail to retrieve webgl context";this.backgroundImageResizerCanvas=e,this.backgroundImageResizerContext=t,this.backgroundImageResizer=new mf(this.backgroundImageResizerContext,0,0)}setBackgroundImage(e){this.backgroundImage=e,this.updateBackgroundImage()}updateBackgroundImage(){const{width:e,height:t}=this.canvas;this.backgroundImageResizer.resizeOutput(e,t),this.backgroundImageResizer.setData(this.backgroundImage),this.backgroundImageResizer.run(),this.pipeline.inputBackgroundImage=this.backgroundImageResizerCanvas}resizeOutput(e,t){super.resizeOutput(e,t),this.backgroundImageResizerCanvas.width=e,this.backgroundImageResizerCanvas.height=t,this.backgroundImageResizer.resizeOutput(e,t),this.updateBackgroundImage()}destroy(){const e=this.backgroundImageResizerContext?.getExtension("WEBGL_lose_context");e&&e.loseContext(),super.destroy()}}class wf extends Ri{setBackgroundVideo(e){this.frameReader=e}async render(e,t){return await this.readNextVideoFrame(),super.render(e,t)}async readNextVideoFrame(){const e=await this.frameReader?.read();if(e?.value){const t=await createImageBitmap(e.value);this.setBackgroundImage(t),e.value.close()}}}class Fi{blurBackground(e){return new to(e)}blurSilhouette(e){return new ro(e)}imageBackground(){return new no}videoBackground(){return new wf}}var vf=`precision mediump float;\n\nvarying vec2 _texture_coord;\n\nuniform vec2 canvas;\nuniform sampler2D texture;\nuniform sampler2D mask;\n\nvec4 loop();\n\nvoid main() { gl_FragColor = loop(); }\n`,Tf=`varying vec2 _texture_coord;\n\nattribute vec2 position;\nattribute vec2 texture_coord;\n\nvoid main() {\n gl_Position = vec4(position, 0., 1.);\n _texture_coord = texture_coord;\n}\n`;class Af extends je{getDefines(){return{RADIUS:this.options.radius??1}}getFragmentShader(){return vf+this.createLoopFunction()}getVertexShader(){return Tf}createLoopFunction(){let e=this.options.radius??1;return`\n\n vec4 loop() { \n vec4 result = vec4(0,0,0,0);\n float factorSum = 0.;\n\n vec2 normalizedRadius = vec2(-${e}.) / canvas;\n vec2 normalizedIncrement = vec2(1.) / canvas;\n vec2 diff = normalizedRadius;\n float maxLength = length(normalizedRadius);\n\n for(int y=-${e}; y<${e+1}; ++y) {\n for(int x=-${e}; x<${e+1}; ++x) {\n float factor = (1.- texture2D(mask, _texture_coord + diff).a) * (maxLength - length(diff)) / maxLength;\n result += factor * texture2D(texture, _texture_coord + diff);\n factorSum += factor;\n diff.x += normalizedIncrement.x;\n }\n diff.y += normalizedIncrement.y;\n diff.x = normalizedRadius.x;\n }\n return result / factorSum;\n }`}}const If=10,Sf=2,Rf=8;class Ff extends Ur{constructor(e,t){super(),this.context=e,this.radius=t;const n={context:e,height:e.canvas.height,width:e.canvas.width};this.blur=new Af({...n,radius:t,...this.getBlurTextureSize(e.canvas.width,e.canvas.height)});const i=new Mr({...n,disableFramebuffer:!0});this.addStep({program:this.blur,preventResize:!0,getUniforms:()=>({texture:D(e,this.inputImage),mask:D(e,this.inputMask)})}),this.addStep({program:i,getUniforms:()=>({background:D(e,this.blur.output),foreground:D(e,this.inputImage),threshold:D(e,this.inputMask)})})}getBlurTextureSize(e,t){const n=this.radius>If?Rf:Sf;return{width:Math.max(Ce,e/n),height:Math.max(Ce,t/n)}}setData(e,t){this.inputImage=e,this.inputMask=t}resizeOutput(e,t){super.resizeOutput(e,t);const n=this.getBlurTextureSize(e,t);this.blur.resizeOutput(n.width,n.height)}}class Pf extends Nt{constructor(e){super(),this.pipeline=new Ff(this.context,e),this.disablePostProcessing()}}class kf extends Ur{constructor(e,t){super(),this.context=e;const n={context:e,height:e.canvas.height,width:e.canvas.width},i=new Si({...n,radius:t,type:Nr.GAUSSIAN}),s=new Mr({...n,disableFramebuffer:!0});this.addStep({program:i,getUniforms:()=>({texture:D(e,this.inputImage)})}),this.addStep({program:s,getUniforms:()=>({background:D(e,this.inputImage),foreground:D(e,i.output),threshold:D(e,this.inputMask)})})}setData(e,t){this.inputImage=e,this.inputMask=t}}class Cf extends Nt{constructor(e){super(),this.pipeline=new kf(this.context,e),this.disablePostProcessing()}}class Bf extends Ai{constructor(){super(...arguments),this.preciseMaskEnabled=!0}set reader(e){this.frameReader=e}async run(){this.frameReader&&(await this.readNextVideoFrame(),await super.run())}async readNextVideoFrame(){const e=await this.frameReader?.read();e?.value&&(this.inputBackgroundImage=await createImageBitmap(e.value),e.value.close())}}class Df extends Nt{constructor(){super(),this.pipeline=new Bf(this.context)}setBackgroundVideo(e){this.pipeline.reader=e}}class Pi{blurBackground(e){return new Pf(e)}blurSilhouette(e){return new Cf(e)}imageBackground(){return new Ri}videoBackground(){return new Df}}class Mf{constructor(e){switch(e){case gt.CANVAS:this.factory=new Fi;break;case gt.WEBGL:this.factory=new Pi;break;default:const t=eo();this.factory=t.supported?new Pi:new Fi}}blurBackground(e){return this.getFactory().blurBackground(e)}blurSilhouette(e){return this.getFactory().blurSilhouette(e)}imageBackground(){return this.getFactory().imageBackground()}videoBackground(){return this.getFactory().videoBackground()}getFactory(){if(!this.factory)throw"Factory is not initialized";return this.factory}}class Of{setBackgroundOptions(e){this.renderer&&this.renderer.destroy();const t=new Mf(e.renderingOptions?.type);switch(e.transformerType){case"BackgroundBlur":this.renderer=t.blurBackground(this.getBlurSize(e.radius));break;case"SilhouetteBlur":this.renderer=t.blurSilhouette(this.getBlurSize(e.radius));break;case"VideoBackground":const n=t.videoBackground();this.backgroundVideo&&n.setBackgroundVideo(this.backgroundVideo),this.renderer=n;break;case"VirtualBackground":const i=t.imageBackground();this.backgroundImage&&i.setBackgroundImage(this.backgroundImage),this.renderer=i;break;default:throw`Unknown rendering type [${e.transformerType}]`}e.renderingOptions?.type===gt.WEBGL&&(e.renderingOptions.selfieSegmentationType===tr.PRECISE?this.renderer.enablePostProcessing():e.renderingOptions.selfieSegmentationType===tr.FAST&&this.renderer.disablePostProcessing())}setVideoBGReadable(e){this.backgroundVideo=e.getReader();const t=this.renderer;t?.setBackgroundVideo&&t.setBackgroundVideo(this.backgroundVideo)}async setVirtualBGImage(e){const t=this.renderer;t?.setBackgroundImage&&t.setBackgroundImage(e),this.backgroundImage=e}async process(e,t){if(this.renderer)return this.renderer.render(e,t)}async resizeForeground(e,t){}getBlurSize(e=pt.Low){switch(e){case pt.Low:return 5;case pt.High:return 12}return e}async profile(e){return this.renderer?.profileWebgl(e)??[]}}var Uf=(function(){var r=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return(function(e){e=e||{};var t=typeof e<"u"?e:{},n,i;t.ready=new Promise(function(f,h){n=f,i=h});var s={},o;for(o in t)t.hasOwnProperty(o)&&(s[o]=t[o]);var a="./this.program",c=function(f,h){throw h},u=!0,d="";function m(f){return t.locateFile?t.locateFile(f,d):d+f}var p;typeof document<"u"&&document.currentScript&&(d=document.currentScript.src),r&&(d=r),d.indexOf("blob:")!==0?d=d.substr(0,d.replace(/[?#].*/,"").lastIndexOf("/")+1):d="";var y=t.print||console.log.bind(console),l=t.printErr||console.warn.bind(console);for(o in s)s.hasOwnProperty(o)&&(t[o]=s[o]);s=null,t.arguments&&t.arguments,t.thisProgram&&(a=t.thisProgram),t.quit&&(c=t.quit);var b;t.wasmBinary&&(b=t.wasmBinary),t.noExitRuntime,typeof WebAssembly!="object"&&ae("no native wasm support detected");var _,E=!1,R=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function k(f,h,g){for(var w=h+g,S=h;f[S]&&!(S>=w);)++S;if(S-h>16&&f.subarray&&R)return R.decode(f.subarray(h,S));for(var C="";h<S;){var v=f[h++];if(!(v&128)){C+=String.fromCharCode(v);continue}var M=f[h++]&63;if((v&224)==192){C+=String.fromCharCode((v&31)<<6|M);continue}var H=f[h++]&63;if((v&240)==224?v=(v&15)<<12|M<<6|H:v=(v&7)<<18|M<<12|H<<6|f[h++]&63,v<65536)C+=String.fromCharCode(v);else{var Li=v-65536;C+=String.fromCharCode(55296|Li>>10,56320|Li&1023)}}return C}function N(f,h){return f?k(Xe,f,h):""}function Q(f,h,g){for(var w=0;w<f.length;++w)Lt[h++>>0]=f.charCodeAt(w);Lt[h>>0]=0}function q(f,h){return f%h>0&&(f+=h-f%h),f}var L,Lt,Xe,$;function Ci(f){L=f,t.HEAP8=Lt=new Int8Array(f),t.HEAP16=new Int16Array(f),t.HEAP32=$=new Int32Array(f),t.HEAPU8=Xe=new Uint8Array(f),t.HEAPU16=new Uint16Array(f),t.HEAPU32=new Uint32Array(f),t.HEAPF32=new Float32Array(f),t.HEAPF64=new Float64Array(f)}t.INITIAL_MEMORY;var zr,Bi=[],Di=[],Mi=[];function Yf(){if(t.preRun)for(typeof t.preRun=="function"&&(t.preRun=[t.preRun]);t.preRun.length;)Kf(t.preRun.shift());Gr(Bi)}function Qf(){Gr(Di)}function qf(){if(t.postRun)for(typeof t.postRun=="function"&&(t.postRun=[t.postRun]);t.postRun.length;)Zf(t.postRun.shift());Gr(Mi)}function Kf(f){Bi.unshift(f)}function Jf(f){Di.unshift(f)}function Zf(f){Mi.unshift(f)}var be=0,Ye=null;function el(f){be++,t.monitorRunDependencies&&t.monitorRunDependencies(be)}function tl(f){if(be--,t.monitorRunDependencies&&t.monitorRunDependencies(be),be==0&&Ye){var h=Ye;Ye=null,h()}}t.preloadedImages={},t.preloadedAudios={};function ae(f){t.onAbort&&t.onAbort(f),f="Aborted("+f+")",l(f),E=!0,f+=". Build with -s ASSERTIONS=1 for more info.";var h=new WebAssembly.RuntimeError(f);throw i(h),h}var rl="data:application/octet-stream;base64,";function Oi(f){return f.startsWith(rl)}var W;W="tflite-simd.wasm",Oi(W)||(W=m(W));function Ui(f){try{if(f==W&&b)return new Uint8Array(b);if(!p)throw"both async and sync fetching of the wasm failed"}catch(h){ae(h)}}function nl(){return!b&&u&&typeof fetch=="function"?fetch(W,{credentials:"same-origin"}).then(function(f){if(!f.ok)throw"failed to load wasm binary file at \'"+W+"\'";return f.arrayBuffer()}).catch(function(){return Ui(W)}):Promise.resolve().then(function(){return Ui(W)})}function il(){var f={a:Al};function h(v,M){var H=v.exports;t.asm=H,_=t.asm.q,Ci(_.buffer),zr=t.asm.E,Jf(t.asm.r),tl()}el();function g(v){h(v.instance)}function w(v){return nl().then(function(M){return WebAssembly.instantiate(M,f)}).then(function(M){return M}).then(v,function(M){l("failed to asynchronously prepare wasm: "+M),ae(M)})}function S(){return!b&&typeof WebAssembly.instantiateStreaming=="function"&&!Oi(W)&&typeof fetch=="function"?fetch(W,{credentials:"same-origin"}).then(function(v){var M=WebAssembly.instantiateStreaming(v,f);return M.then(g,function(H){return l("wasm streaming compile failed: "+H),l("falling back to ArrayBuffer instantiation"),w(g)})}):w(g)}if(t.instantiateWasm)try{var C=t.instantiateWasm(f,h);return C}catch(v){return l("Module.instantiateWasm callback failed with error: "+v),!1}return S().catch(i),{}}function Gr(f){for(;f.length>0;){var h=f.shift();if(typeof h=="function"){h(t);continue}var g=h.func;typeof g=="number"?h.arg===void 0?zr.get(g)():zr.get(g)(h.arg):g(h.arg===void 0?null:h.arg)}}function sl(f,h,g,w){ae("Assertion failed: "+N(f)+", at: "+[h?N(h):"unknown filename",g,w?N(w):"unknown function"])}function ol(f,h){ae("To use dlopen, you need to use Emscripten\'s linking support, see https://github.com/emscripten-core/emscripten/wiki/Linking")}function al(f,h){ae("To use dlopen, you need to use Emscripten\'s linking support, see https://github.com/emscripten-core/emscripten/wiki/Linking")}function cl(){ae("")}var zt;zt=function(){return performance.now()};var ul=!0;function fl(f){return $[Ni()>>2]=f,f}function ll(f,h){var g;if(f===0)g=Date.now();else if((f===1||f===4)&&ul)g=zt();else return fl(28),-1;return $[h>>2]=g/1e3|0,$[h+4>>2]=g%1e3*1e3*1e3|0,0}function dl(){return 2147483648}function hl(f,h,g){Xe.copyWithin(f,h,h+g)}function ml(f){try{return _.grow(f-L.byteLength+65535>>>16),Ci(_.buffer),1}catch{}}function pl(f){var h=Xe.length;f=f>>>0;var g=2147483648;if(f>g)return!1;for(var w=1;w<=4;w*=2){var S=h*(1+.2/w);S=Math.min(S,f+100663296);var C=Math.min(g,q(Math.max(f,S),65536)),v=ml(C);if(v)return!0}return!1}function gl(f){for(var h=zt();zt()-h<f;);}var $r={};function yl(){return a||"./this.program"}function Qe(){if(!Qe.strings){var f=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",h={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:f,_:yl()};for(var g in $r)$r[g]===void 0?delete h[g]:h[g]=$r[g];var w=[];for(var g in h)w.push(g+"="+h[g]);Qe.strings=w}return Qe.strings}var Gt={mappings:{},buffers:[null,[],[]],printChar:function(f,h){var g=Gt.buffers[f];h===0||h===10?((f===1?y:l)(k(g,0)),g.length=0):g.push(h)},varargs:void 0,get:function(){Gt.varargs+=4;var f=$[Gt.varargs-4>>2];return f},getStr:function(f){var h=N(f);return h},get64:function(f,h){return f}};function bl(f,h){var g=0;return Qe().forEach(function(w,S){var C=h+g;$[f+S*4>>2]=C,Q(w,C),g+=w.length+1}),0}function xl(f,h){var g=Qe();$[f>>2]=g.length;var w=0;return g.forEach(function(S){w+=S.length+1}),$[h>>2]=w,0}function _l(f){Sl(f)}function El(f){return 0}function wl(f,h,g,w,S){}function vl(f,h,g,w){for(var S=0,C=0;C<g;C++){for(var v=$[h+C*8>>2],M=$[h+(C*8+4)>>2],H=0;H<M;H++)Gt.printChar(f,Xe[v+H]);S+=M}return $[w>>2]=S,0}function Tl(){if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function"){var f=new Uint8Array(1);return function(){return crypto.getRandomValues(f),f[0]}}else return function(){ae("randomDevice")}}function $t(f,h){$t.randomDevice||($t.randomDevice=Tl());for(var g=0;g<h;g++)Lt[f+g>>0]=$t.randomDevice();return 0}var Al={a:sl,e:ol,d:al,b:cl,n:ll,h:dl,l:hl,m:pl,p:gl,f:bl,g:xl,j:_l,i:El,k:wl,c:vl,o:$t};il(),t.___wasm_call_ctors=function(){return(t.___wasm_call_ctors=t.asm.r).apply(null,arguments)},t._getModelBufferMemoryOffset=function(){return(t._getModelBufferMemoryOffset=t.asm.s).apply(null,arguments)},t._getInputMemoryOffset=function(){return(t._getInputMemoryOffset=t.asm.t).apply(null,arguments)},t._getInputHeight=function(){return(t._getInputHeight=t.asm.u).apply(null,arguments)},t._getInputWidth=function(){return(t._getInputWidth=t.asm.v).apply(null,arguments)},t._getInputChannelCount=function(){return(t._getInputChannelCount=t.asm.w).apply(null,arguments)},t._getOutputMemoryOffset=function(){return(t._getOutputMemoryOffset=t.asm.x).apply(null,arguments)},t._getOutputHeight=function(){return(t._getOutputHeight=t.asm.y).apply(null,arguments)},t._getOutputWidth=function(){return(t._getOutputWidth=t.asm.z).apply(null,arguments)},t._getOutputChannelCount=function(){return(t._getOutputChannelCount=t.asm.A).apply(null,arguments)},t._loadModel=function(){return(t._loadModel=t.asm.B).apply(null,arguments)},t._runInference=function(){return(t._runInference=t.asm.C).apply(null,arguments)},t._isGPUEnabled=function(){return(t._isGPUEnabled=t.asm.D).apply(null,arguments)};var Ni=t.___errno_location=function(){return(Ni=t.___errno_location=t.asm.F).apply(null,arguments)},Wt;function Il(f){this.name="ExitStatus",this.message="Program terminated with exit("+f+")",this.status=f}Ye=function f(){Wt||Wr(),Wt||(Ye=f)};function Wr(f){if(be>0||(Yf(),be>0))return;function h(){Wt||(Wt=!0,t.calledRun=!0,!E&&(Qf(),n(t),t.onRuntimeInitialized&&t.onRuntimeInitialized(),qf()))}t.setStatus?(t.setStatus("Running..."),setTimeout(function(){setTimeout(function(){t.setStatus("")},1),h()},1)):h()}t.run=Wr;function Sl(f,h){Rl(f)}function Rl(f){c(f,new Il(f))}if(t.preInit)for(typeof t.preInit=="function"&&(t.preInit=[t.preInit]);t.preInit.length>0;)t.preInit.pop()();return Wr(),e.ready})})();class Nf{constructor(){this.isSIMDSupported=!1,this.isThreadsSupported=!1,this.inputWidth=0,this.inputHeight=0,this.inputChannelCount=0,this.inputMemoryOffset=0,this.outputWidth=0,this.outputHeight=0,this.outputChannelCount=0,this.outputMemoryOffset=0}}const Lf="https://d3opqjmqzxf057.cloudfront.net/vonage-tensorflow-wasm/tflite-simd-wasm/1.1.3/",zf="https://d3opqjmqzxf057.cloudfront.net/ml/selfie_segmentation/4.0.0/selfie_segmentation_landscape.tflite";async function Gf(r=Lf,e=zf){let t=new Nf;var n=new Promise(function(i,s){async function o(){return Uf({locateFile:function(u){return r+u}})}async function a(c){return new Promise(async(u,d)=>{const m=c;if(typeof m>"u")return d("TFLite backend unavailable: wasmSimd");let p=e;console.log("TFLite modelUrl: "+p);try{const l=await(await fetch(p)).arrayBuffer();console.log("Model buffer size:",l.byteLength);const b=m._getModelBufferMemoryOffset();console.log("Model buffer memory offset:",b),console.log("Loading model buffer..."),m.HEAPU8.set(new Uint8Array(l),b);const _=m._loadModel(l.byteLength);if(console.log("Load model result:",_),_!==0){d("Cannot load model");return}t.inputWidth=m._getInputWidth(),t.inputHeight=m._getInputHeight(),t.inputChannelCount=m._getInputChannelCount(),t.inputMemoryOffset=m._getInputMemoryOffset(),console.log("Input memory offset:",t.inputMemoryOffset),console.log("Input height:",t.inputHeight),console.log("Input width:",t.inputWidth),console.log("Input channels:",t.inputChannelCount),t.outputMemoryOffset=m._getOutputMemoryOffset(),t.outputWidth=m._getOutputWidth(),t.outputHeight=m._getOutputHeight(),t.outputChannelCount=m._getOutputChannelCount(),console.log("Output memory offset:",t.outputMemoryOffset),console.log("Output height:",t.outputHeight),console.log("Output width:",t.outputWidth),console.log("Output channels:",t.outputChannelCount),t.selectedTFLite=m}catch(y){d(y);return}u()})}o().then(c=>{if(c===null)throw console.error("loadTFLite null"),"loadTFLite null";a(c).then(u=>{i(t)}).catch(u=>{console.error("loadTFLiteModel error"),s("loadTFLiteModel error")})}).catch(c=>{console.error("loadTFLite error:",c),s("loadTFLite error:"+c)})});return n}const $f=.1,Wf=.7,Vf="https://d3opqjmqzxf057.cloudfront.net/ml/vonage_selfie_segmenter/float16/v1/vonage_selfie_segmenter.tflite";class Hf{constructor(){this.canvas=new OffscreenCanvas(0,0),this.context=this.canvas.getContext("2d",{willReadFrequently:!0}),this.width=0,this.height=0,this.gpuDelegate=!0}async createImageSegmenter(){if(!this.ImageSegmenter||!this.wasmFileset){console.warn("Mediapipe objects not loaded");return}this.imageSegmenter=await this.ImageSegmenter.createFromOptions(this.wasmFileset,{baseOptions:{modelAssetPath:this.modelAssetUriPath,delegate:this.gpuDelegate?"GPU":"CPU"},runningMode:"VIDEO",outputCategoryMask:!0,outputConfidenceMasks:!0})}async loadMediapipeAssets(e,t){this.modelAssetUriPath=e||Vf;const n=t?`${t}/task-vision.js`:"https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.20/+esm",i=t?`${t}/wasm`:"https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.20/wasm",{FilesetResolver:s,ImageSegmenter:o}=await import(n);this.ImageSegmenter=o,this.wasmFileset=await s.forVisionTasks(i)}async init(e,t,n){n===!1&&(this.gpuDelegate=!1),await this.loadMediapipeAssets(e,t),globalThis.document={},await this.createImageSegmenter()}async process(e){if(!this.imageSegmenter){console.warn("ImageSegmenter instance not available");return}(this.width!==e.width||this.height!==e.height)&&(this.canvas.width=this.width=e.width,this.canvas.height=this.height=e.height,this.mask&&(this.mask=new ImageData(this.width,this.height))),this.mask||(this.mask=new ImageData(this.width,this.height)),this.context.drawImage(e,0,0,e.width,e.height);const t=Date.now();let n;try{this.imageSegmenter?.segmentForVideo(this.context.getImageData(0,0,e.width,e.height),t,o=>{n=o.confidenceMasks?.[0]?.getAsFloat32Array()})}catch{await this.createImageSegmenter();return}if(!n)return;if(!this.previousConfidenceMask){this.previousConfidenceMask=n.slice();return}const i=n.map((o,a)=>{const c=this.previousConfidenceMask?.[a];return c!==void 0?this.blend(c,o):o}),s=[255,0,0];for(let o=0;o<i?.length;o++){const a=1-i[o];a>$f?(a<Wf?(this.mask.data[o*4]=s[0]*a,this.mask.data[o*4+3]=255*a):(this.mask.data[o*4]=s[0],this.mask.data[o*4+3]=255),this.mask.data[o*4+1]=s[1],this.mask.data[o*4+2]=s[2]):this.mask.data[o*4]=this.mask.data[o*4+1]=this.mask.data[o*4+2]=this.mask.data[o*4+3]=0}return this.previousConfidenceMask=i.slice(),this.mask}isGpuSupported(){return!0}blend(e,t){const i=-.748699,s=-57.8051,o=291.309,a=-624.717,c=t-.5,u=c*c,d=1-Math.min(1,u*(5.68842+u*(i+u*(s+u*(o+u*a)))));return t+(e-t)*(d*.9)}}class jf{constructor(){this.canvas=new OffscreenCanvas(0,0),this.context=this.canvas.getContext("2d",{willReadFrequently:!0}),this.pixelCount=0,this.inputOffset=0,this.outputOffset=0}async init(e,t,n){await this.initWasm(t,e),this.infos&&(this.canvas.width=this.infos.inputWidth,this.canvas.height=this.infos.inputHeight,this.pixelCount=this.infos.inputWidth*this.infos.inputHeight,this.mask=new ImageData(this.infos.inputWidth,this.infos.inputHeight),this.inputOffset=this.infos.inputMemoryOffset/4,this.outputOffset=this.infos.outputMemoryOffset/4)}async initWasm(e,t){this.infos=await Gf(e,t)}async process(e){if(!this.mask||!this.infos)return;const t=this.infos.inputWidth,n=this.infos.inputHeight;this.context.drawImage(e,0,0,e.width,e.height,0,0,t,n);const i=this.context.getImageData(0,0,t,n),s=this.infos.selectedTFLite.HEAPF32;for(let o=0;o<this.pixelCount;o++){const a=this.inputOffset+o*3;s[a]=i.data[o*4]/255,s[a+1]=i.data[o*4+1]/255,s[a+2]=i.data[o*4+2]/255}this.infos.selectedTFLite._runInference();for(let o=0;o<this.pixelCount;o++){const a=this.infos.selectedTFLite.HEAPF32[this.outputOffset+o];this.mask.data[o*4]=this.mask.data[o*4+3]=255*a}return this.mask}isGpuSupported(){return this.infos?.selectedTFLite?._isGPUEnabled()??!1}}class Xf{constructor(){this.reporter=new Js,this.isEnabled=!0}async init(e,t){t.segmentationOptions?.lightWeightEngine===!0?this.selfieSegmentation=new jf:this.selfieSegmentation=new Hf,this.selfieSegmentation?.init(t.modelAssetUriPath,t.mediapipeBaseAssetsUri,t.segmentationOptions?.gpuSupport),this.backgroundFilter=new Of,this.report({variation:"Create"})}async transform(e,t){if(!this.isEnabled)return t.enqueue(e);let n;const i=e.timestamp??0,s=await createImageBitmap(e),o=await this.selfieSegmentation?.process(s);o&&(n=await this.backgroundFilter?.process(s,o)),n?(e.close(),t.enqueue(new VideoFrame(n,{timestamp:i,alpha:"discard"}))):t.enqueue(e)}async setBackgroundOptions(e){this.backgroundOptions=e,this.backgroundFilter?.setBackgroundOptions(e),this.report({variation:"Update"})}setVideoBGReadable(e){this.backgroundFilter?.setVideoBGReadable(e)}async setVirtualBGImage(e){await this.backgroundFilter?.setVirtualBGImage(e)}async profile(e){return this.backgroundFilter?.profile(e)??[]}getTransformerType(){return this.backgroundOptions?.transformerType??"Undefined"}enable(){this.isEnabled=!0}disable(){this.isEnabled=!1}report(e){this.reporter.send({version:Zs,action:"MlTransformers",transformerType:this.backgroundOptions?.transformerType,config:JSON.stringify(this.backgroundOptions),...e})}}const Lr=class Lr{constructor(){this.backgroundTransformer=new Xf,this.mediaProcessor=new Rs,this.rate=30,this.eventsQueue=[],this.frameTransformLatencyMs=[]}async init(e,t){this.frameTransformLatencyMs=[],await this.backgroundTransformer.init(e,t),await this.mediaProcessor.setTransformers([this.backgroundTransformer]),this.mediaProcessor.setTrackExpectedRate(this.rate),this.mediaProcessor.onAny((n,i)=>{this.resolveOnMediaProcessor?(this.resolveOnMediaProcessor({name:n,data:i}),this.resolveOnMediaProcessor=void 0):this.eventsQueue.push({name:n,data:i})})}enable(){this.backgroundTransformer.enable()}disable(){this.backgroundTransformer.disable()}async onMediaProcessorEvent(){return await new Promise(e=>{this.eventsQueue.length>0?e(this.eventsQueue.shift()):this.resolveOnMediaProcessor=e})}async setTrackExpectedRate(e){this.rate=e,this.mediaProcessor.setTrackExpectedRate(e)}async transform(e,t){let n=this.mediaProcessor.transform(e,t),i=performance.now();return this.frameTransformLatencyMs.push(performance.now()-i),n}async setBackgroundOptions(e){await this.backgroundTransformer?.setBackgroundOptions(e)}setVideoBGReadable(e){this.backgroundTransformer.setVideoBGReadable(e)}async setVirtualBGImage(e){await this.backgroundTransformer.setVirtualBGImage(e)}async terminate(){await this.mediaProcessor.destroy();const t=this.frameTransformLatencyMs.reduce((n,i)=>n+i,0)/this.frameTransformLatencyMs.length||0;console.log(`Transform latency average is: ${t} ms`)}setVonageMetadata(e){_s(e)}async profile(e){return JSON.stringify(await this.backgroundTransformer.profile(e))}};Vi("ProcessorWorker",Lr);let ki=Lr})();\n//# sourceMappingURL=processor-worker-B9-xvwqE.js.map\n', ii = typeof self < "u" && self.Blob && new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);", _o], { type: "text/javascript;charset=utf-8" });
5179
+ const Eo = '(function(){"use strict";function Vt(r,e){globalThis.vonage||(globalThis.vonage={}),globalThis.vonage.workerizer||(globalThis.vonage.workerizer={});let t=globalThis.vonage.workerizer;return t[r]||(t[r]=e),t[r]}const Vr=Vt("globals",{});var xe=(r=>(r.INIT="INIT",r.FORWARD="FORWARD",r.TERMINATE="TERMINATE",r.GLOBALS_SYNC="GLOBALS_SYNC",r.EVENT="EVENT",r))(xe||{});function zi(r){return[ImageBitmap,ReadableStream,WritableStream].some(t=>r instanceof t)}function Be(r,e){const{id:t,type:n}=r,i=Array.isArray(e)?e:[e];postMessage({id:t,type:n,result:e},i.filter(s=>zi(s)))}Vt("workerized",{});function Hr(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function qe(r,e){if(Array.isArray(e))e.splice(0,e.length);else if(typeof e=="object")for(const t in e)delete e[t];for(const t in r)Array.isArray(r[t])?(e[t]=[],qe(r[t],e[t])):typeof r[t]=="object"?(e[t]={},qe(r[t],e[t])):e[t]=r[t]}const K=new WeakMap,ce=new WeakMap,j=new WeakMap,Ke=Symbol("anyProducer"),jr=Promise.resolve(),Je=Symbol("listenerAdded"),Ze=Symbol("listenerRemoved");let et=!1,Ht=!1;function _e(r){if(typeof r!="string"&&typeof r!="symbol"&&typeof r!="number")throw new TypeError("`eventName` must be a string, symbol, or number")}function tt(r){if(typeof r!="function")throw new TypeError("listener must be a function")}function Ee(r,e){const t=ce.get(r);if(t.has(e))return t.get(e)}function De(r,e){const t=typeof e=="string"||typeof e=="symbol"||typeof e=="number"?e:Ke,n=j.get(r);if(n.has(t))return n.get(t)}function Gi(r,e,t){const n=j.get(r);if(n.has(e))for(const i of n.get(e))i.enqueue(t);if(n.has(Ke)){const i=Promise.all([e,t]);for(const s of n.get(Ke))s.enqueue(i)}}function Xr(r,e){e=Array.isArray(e)?e:[e];let t=!1,n=()=>{},i=[];const s={enqueue(o){i.push(o),n()},finish(){t=!0,n()}};for(const o of e){let a=De(r,o);a||(a=new Set,j.get(r).set(o,a)),a.add(s)}return{async next(){return i?i.length===0?t?(i=void 0,this.next()):(await new Promise(o=>{n=o}),this.next()):{done:!1,value:await i.shift()}:{done:!0}},async return(o){i=void 0;for(const a of e){const c=De(r,a);c&&(c.delete(s),c.size===0&&j.get(r).delete(a))}return n(),arguments.length>0?{done:!0,value:await o}:{done:!0}},[Symbol.asyncIterator](){return this}}}function Yr(r){if(r===void 0)return Qr;if(!Array.isArray(r))throw new TypeError("`methodNames` must be an array of strings");for(const e of r)if(!Qr.includes(e))throw typeof e!="string"?new TypeError("`methodNames` element must be a string"):new Error(`${e} is not Emittery method`);return r}const we=r=>r===Je||r===Ze;function rt(r,e,t){if(we(e))try{et=!0,r.emit(e,t)}finally{et=!1}}class ve{static mixin(e,t){return t=Yr(t),n=>{if(typeof n!="function")throw new TypeError("`target` must be function");for(const o of t)if(n.prototype[o]!==void 0)throw new Error(`The property \\`${o}\\` already exists on \\`target\\``);function i(){return Object.defineProperty(this,e,{enumerable:!1,value:new ve}),this[e]}Object.defineProperty(n.prototype,e,{enumerable:!1,get:i});const s=o=>function(...a){return this[e][o](...a)};for(const o of t)Object.defineProperty(n.prototype,o,{enumerable:!1,value:s(o)});return n}}static get isDebugEnabled(){var e,t;if(typeof((e=globalThis.process)==null?void 0:e.env)!="object")return Ht;const{env:n}=(t=globalThis.process)!=null?t:{env:{}};return n.DEBUG==="emittery"||n.DEBUG==="*"||Ht}static set isDebugEnabled(e){Ht=e}constructor(e={}){var t;K.set(this,new Set),ce.set(this,new Map),j.set(this,new Map),j.get(this).set(Ke,new Set),this.debug=(t=e.debug)!=null?t:{},this.debug.enabled===void 0&&(this.debug.enabled=!1),this.debug.logger||(this.debug.logger=(n,i,s,o)=>{try{o=JSON.stringify(o)}catch{o=`Object with the following keys failed to stringify: ${Object.keys(o).join(",")}`}(typeof s=="symbol"||typeof s=="number")&&(s=s.toString());const a=new Date,c=`${a.getHours()}:${a.getMinutes()}:${a.getSeconds()}.${a.getMilliseconds()}`;console.log(`[${c}][emittery:${n}][${i}] Event Name: ${s}\n data: ${o}`)})}logIfDebugEnabled(e,t,n){(ve.isDebugEnabled||this.debug.enabled)&&this.debug.logger(e,this.debug.name,t,n)}on(e,t){tt(t),e=Array.isArray(e)?e:[e];for(const n of e){_e(n);let i=Ee(this,n);i||(i=new Set,ce.get(this).set(n,i)),i.add(t),this.logIfDebugEnabled("subscribe",n,void 0),we(n)||rt(this,Je,{eventName:n,listener:t})}return this.off.bind(this,e,t)}off(e,t){tt(t),e=Array.isArray(e)?e:[e];for(const n of e){_e(n);const i=Ee(this,n);i&&(i.delete(t),i.size===0&&ce.get(this).delete(n)),this.logIfDebugEnabled("unsubscribe",n,void 0),we(n)||rt(this,Ze,{eventName:n,listener:t})}}once(e){let t;const n=new Promise(i=>{t=this.on(e,s=>{t(),i(s)})});return n.off=t,n}events(e){e=Array.isArray(e)?e:[e];for(const t of e)_e(t);return Xr(this,e)}async emit(e,t){var n;if(_e(e),we(e)&&!et)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");this.logIfDebugEnabled("emit",e,t),Gi(this,e,t);const i=(n=Ee(this,e))!=null?n:new Set,s=K.get(this),o=[...i],a=we(e)?[]:[...s];await jr,await Promise.all([...o.map(async c=>{if(i.has(c))return c(t)}),...a.map(async c=>{if(s.has(c))return c(e,t)})])}async emitSerial(e,t){var n;if(_e(e),we(e)&&!et)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");this.logIfDebugEnabled("emitSerial",e,t);const i=(n=Ee(this,e))!=null?n:new Set,s=K.get(this),o=[...i],a=[...s];await jr;for(const c of o)i.has(c)&&await c(t);for(const c of a)s.has(c)&&await c(e,t)}onAny(e){return tt(e),this.logIfDebugEnabled("subscribeAny",void 0,void 0),K.get(this).add(e),rt(this,Je,{listener:e}),this.offAny.bind(this,e)}anyEvent(){return Xr(this)}offAny(e){tt(e),this.logIfDebugEnabled("unsubscribeAny",void 0,void 0),rt(this,Ze,{listener:e}),K.get(this).delete(e)}clearListeners(e){e=Array.isArray(e)?e:[e];for(const t of e)if(this.logIfDebugEnabled("clear",t,void 0),typeof t=="string"||typeof t=="symbol"||typeof t=="number"){const n=Ee(this,t);n&&n.clear();const i=De(this,t);if(i){for(const s of i)s.finish();i.clear()}}else{K.get(this).clear();for(const[n,i]of ce.get(this).entries())i.clear(),ce.get(this).delete(n);for(const[n,i]of j.get(this).entries()){for(const s of i)s.finish();i.clear(),j.get(this).delete(n)}}}listenerCount(e){var t,n,i,s,o,a;e=Array.isArray(e)?e:[e];let c=0;for(const u of e){if(typeof u=="string"){c+=K.get(this).size+((n=(t=Ee(this,u))==null?void 0:t.size)!=null?n:0)+((s=(i=De(this,u))==null?void 0:i.size)!=null?s:0)+((a=(o=De(this))==null?void 0:o.size)!=null?a:0);continue}typeof u<"u"&&_e(u),c+=K.get(this).size;for(const d of ce.get(this).values())c+=d.size;for(const d of j.get(this).values())c+=d.size}return c}bindMethods(e,t){if(typeof e!="object"||e===null)throw new TypeError("`target` must be an object");t=Yr(t);for(const n of t){if(e[n]!==void 0)throw new Error(`The property \\`${n}\\` already exists on \\`target\\``);Object.defineProperty(e,n,{enumerable:!1,value:this[n].bind(this)})}}}const Qr=Object.getOwnPropertyNames(ve.prototype).filter(r=>r!=="constructor");Object.defineProperty(ve,"listenerAdded",{value:Je,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(ve,"listenerRemoved",{value:Ze,writable:!1,enumerable:!0,configurable:!1});function $i(r){return r.onAny&&r.emit}async function Wi(r,e){const{functionName:t,args:n}=r;if(!e.instance)throw"instance not initialized";if(!t)throw"missing function name to call";if(!e.instance[t])throw`undefined function [${t}] in class ${e.instance.constructor.workerId}`;Be(r,await e.instance[t](...n??[]))}const qr=Vt("registeredWorkers",{});function Vi(r,e){e.workerId=r,Hr()&&(qr[e.workerId]=e)}function Hi(r,e){if(!r.args)throw"Missing className while initializing worker";const[t,n]=r.args,i=qr[t];if(i)e.instance=new i(r.args.slice(1));else throw`unknown worker class ${t}`;qe(n,Vr),$i(e.instance)&&e.instance.onAny((s,o)=>{Be({type:xe.EVENT},{name:s,data:o})}),Be(r,typeof e.instance!==void 0)}async function ji(r,e){const{args:t}=r;if(!e.instance)throw"instance not initialized";let n;e.instance.terminate&&(n=await e.instance.terminate(...t??[])),Be(r,n)}function Xi(r){if(!r.args)throw"Missing globals while syncing";qe(r.args[0],Vr),Be(r,{})}function Yi(){const r={};onmessage=async e=>{const t=e.data;switch(t.type){case xe.INIT:Hi(t,r);break;case xe.FORWARD:Wi(t,r);break;case xe.TERMINATE:ji(t,r);break;case xe.GLOBALS_SYNC:Xi(t);break}}}Hr()&&Yi();const J=new WeakMap,ue=new WeakMap,X=new WeakMap,nt=Symbol("anyProducer"),Kr=Promise.resolve(),it=Symbol("listenerAdded"),st=Symbol("listenerRemoved");let ot=!1,jt=!1;const at=r=>typeof r=="string"||typeof r=="symbol"||typeof r=="number";function Te(r){if(!at(r))throw new TypeError("`eventName` must be a string, symbol, or number")}function ct(r){if(typeof r!="function")throw new TypeError("listener must be a function")}function Ae(r,e){const t=ue.get(r);if(t.has(e))return t.get(e)}function Me(r,e){const t=at(e)?e:nt,n=X.get(r);if(n.has(t))return n.get(t)}function Qi(r,e,t){const n=X.get(r);if(n.has(e))for(const i of n.get(e))i.enqueue(t);if(n.has(nt)){const i=Promise.all([e,t]);for(const s of n.get(nt))s.enqueue(i)}}function Jr(r,e){e=Array.isArray(e)?e:[e];let t=!1,n=()=>{},i=[];const s={enqueue(o){i.push(o),n()},finish(){t=!0,n()}};for(const o of e){let a=Me(r,o);a||(a=new Set,X.get(r).set(o,a)),a.add(s)}return{async next(){return i?i.length===0?t?(i=void 0,this.next()):(await new Promise(o=>{n=o}),this.next()):{done:!1,value:await i.shift()}:{done:!0}},async return(o){i=void 0;for(const a of e){const c=Me(r,a);c&&(c.delete(s),c.size===0&&X.get(r).delete(a))}return n(),arguments.length>0?{done:!0,value:await o}:{done:!0}},[Symbol.asyncIterator](){return this}}}function Zr(r){if(r===void 0)return en;if(!Array.isArray(r))throw new TypeError("`methodNames` must be an array of strings");for(const e of r)if(!en.includes(e))throw typeof e!="string"?new TypeError("`methodNames` element must be a string"):new Error(`${e} is not Emittery method`);return r}const Ie=r=>r===it||r===st;function ut(r,e,t){if(Ie(e))try{ot=!0,r.emit(e,t)}finally{ot=!1}}class Y{static mixin(e,t){return t=Zr(t),n=>{if(typeof n!="function")throw new TypeError("`target` must be function");for(const o of t)if(n.prototype[o]!==void 0)throw new Error(`The property \\`${o}\\` already exists on \\`target\\``);function i(){return Object.defineProperty(this,e,{enumerable:!1,value:new Y}),this[e]}Object.defineProperty(n.prototype,e,{enumerable:!1,get:i});const s=o=>function(...a){return this[e][o](...a)};for(const o of t)Object.defineProperty(n.prototype,o,{enumerable:!1,value:s(o)});return n}}static get isDebugEnabled(){if(typeof globalThis.process?.env!="object")return jt;const{env:e}=globalThis.process??{env:{}};return e.DEBUG==="emittery"||e.DEBUG==="*"||jt}static set isDebugEnabled(e){jt=e}constructor(e={}){J.set(this,new Set),ue.set(this,new Map),X.set(this,new Map),X.get(this).set(nt,new Set),this.debug=e.debug??{},this.debug.enabled===void 0&&(this.debug.enabled=!1),this.debug.logger||(this.debug.logger=(t,n,i,s)=>{try{s=JSON.stringify(s)}catch{s=`Object with the following keys failed to stringify: ${Object.keys(s).join(",")}`}(typeof i=="symbol"||typeof i=="number")&&(i=i.toString());const o=new Date,a=`${o.getHours()}:${o.getMinutes()}:${o.getSeconds()}.${o.getMilliseconds()}`;console.log(`[${a}][emittery:${t}][${n}] Event Name: ${i}\n data: ${s}`)})}logIfDebugEnabled(e,t,n){(Y.isDebugEnabled||this.debug.enabled)&&this.debug.logger(e,this.debug.name,t,n)}on(e,t,{signal:n}={}){ct(t),e=Array.isArray(e)?e:[e];for(const s of e){Te(s);let o=Ae(this,s);o||(o=new Set,ue.get(this).set(s,o)),o.add(t),this.logIfDebugEnabled("subscribe",s,void 0),Ie(s)||ut(this,it,{eventName:s,listener:t})}const i=()=>{this.off(e,t),n?.removeEventListener("abort",i)};return n?.addEventListener("abort",i,{once:!0}),n?.aborted&&i(),i}off(e,t){ct(t),e=Array.isArray(e)?e:[e];for(const n of e){Te(n);const i=Ae(this,n);i&&(i.delete(t),i.size===0&&ue.get(this).delete(n)),this.logIfDebugEnabled("unsubscribe",n,void 0),Ie(n)||ut(this,st,{eventName:n,listener:t})}}once(e,t){if(t!==void 0&&typeof t!="function")throw new TypeError("predicate must be a function");let n;const i=new Promise(s=>{n=this.on(e,o=>{t&&!t(o)||(n(),s(o))})});return i.off=n,i}events(e){e=Array.isArray(e)?e:[e];for(const t of e)Te(t);return Jr(this,e)}async emit(e,t){if(Te(e),Ie(e)&&!ot)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");this.logIfDebugEnabled("emit",e,t),Qi(this,e,t);const n=Ae(this,e)??new Set,i=J.get(this),s=[...n],o=Ie(e)?[]:[...i];await Kr,await Promise.all([...s.map(async a=>{if(n.has(a))return a(t)}),...o.map(async a=>{if(i.has(a))return a(e,t)})])}async emitSerial(e,t){if(Te(e),Ie(e)&&!ot)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");this.logIfDebugEnabled("emitSerial",e,t);const n=Ae(this,e)??new Set,i=J.get(this),s=[...n],o=[...i];await Kr;for(const a of s)n.has(a)&&await a(t);for(const a of o)i.has(a)&&await a(e,t)}onAny(e,{signal:t}={}){ct(e),this.logIfDebugEnabled("subscribeAny",void 0,void 0),J.get(this).add(e),ut(this,it,{listener:e});const n=()=>{this.offAny(e),t?.removeEventListener("abort",n)};return t?.addEventListener("abort",n,{once:!0}),t?.aborted&&n(),n}anyEvent(){return Jr(this)}offAny(e){ct(e),this.logIfDebugEnabled("unsubscribeAny",void 0,void 0),ut(this,st,{listener:e}),J.get(this).delete(e)}clearListeners(e){e=Array.isArray(e)?e:[e];for(const t of e)if(this.logIfDebugEnabled("clear",t,void 0),at(t)){const n=Ae(this,t);n&&n.clear();const i=Me(this,t);if(i){for(const s of i)s.finish();i.clear()}}else{J.get(this).clear();for(const[n,i]of ue.get(this).entries())i.clear(),ue.get(this).delete(n);for(const[n,i]of X.get(this).entries()){for(const s of i)s.finish();i.clear(),X.get(this).delete(n)}}}listenerCount(e){e=Array.isArray(e)?e:[e];let t=0;for(const n of e){if(at(n)){t+=J.get(this).size+(Ae(this,n)?.size??0)+(Me(this,n)?.size??0)+(Me(this)?.size??0);continue}n!==void 0&&Te(n),t+=J.get(this).size;for(const i of ue.get(this).values())t+=i.size;for(const i of X.get(this).values())t+=i.size}return t}bindMethods(e,t){if(typeof e!="object"||e===null)throw new TypeError("`target` must be an object");t=Zr(t);for(const n of t){if(e[n]!==void 0)throw new Error(`The property \\`${n}\\` already exists on \\`target\\``);Object.defineProperty(e,n,{enumerable:!1,value:this[n].bind(this)})}}}const en=Object.getOwnPropertyNames(Y.prototype).filter(r=>r!=="constructor");Object.defineProperty(Y,"listenerAdded",{value:it,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(Y,"listenerRemoved",{value:st,writable:!1,enumerable:!0,configurable:!1});var qi=Object.defineProperty,Ki=(r,e,t)=>e in r?qi(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ji=(r,e,t)=>(Ki(r,e+"",t),t);const Zi="hlg.tokbox.com/prod/logging/vcp_webrtc",es="https://",ts=1e4;let ft;const rs=new Uint8Array(16);function ns(){if(!ft&&(ft=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!ft))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ft(rs)}const F=[];for(let r=0;r<256;++r)F.push((r+256).toString(16).slice(1));function is(r,e=0){return(F[r[e+0]]+F[r[e+1]]+F[r[e+2]]+F[r[e+3]]+"-"+F[r[e+4]]+F[r[e+5]]+"-"+F[r[e+6]]+F[r[e+7]]+"-"+F[r[e+8]]+F[r[e+9]]+"-"+F[r[e+10]]+F[r[e+11]]+F[r[e+12]]+F[r[e+13]]+F[r[e+14]]+F[r[e+15]]).toLowerCase()}const ss=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),tn={randomUUID:ss};function os(r,e,t){if(tn.randomUUID&&!r)return tn.randomUUID();r=r||{};const n=r.random||(r.rng||ns)();return n[6]=n[6]&15|64,n[8]=n[8]&63|128,is(n)}function Xt(r,e){globalThis.vonage||(globalThis.vonage={}),globalThis.vonage.workerizer||(globalThis.vonage.workerizer={});let t=globalThis.vonage.workerizer;return t[r]||(t[r]=e),t[r]}const Z=Xt("globals",{});var fe=(r=>(r.INIT="INIT",r.FORWARD="FORWARD",r.TERMINATE="TERMINATE",r.GLOBALS_SYNC="GLOBALS_SYNC",r))(fe||{});function rn(r){return[ImageBitmap,ReadableStream,WritableStream].some(e=>r instanceof e)}let as=0;function cs(r,e,t,n,i){const s=as++;return r.postMessage({id:s,type:e,functionName:t,args:n},n.filter(o=>rn(o))),new Promise(o=>{i?.set(s,o)})}function Oe(r,e){const{id:t,type:n}=r,i=Array.isArray(e)?e:[e];postMessage({id:t,type:n,result:e},i.filter(s=>rn(s)))}const nn=Xt("workerized",{});function sn(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}async function us(){if(sn())Oe({type:fe.GLOBALS_SYNC},Z);else{const r=[];for(const e in nn){const{worker:t,resolvers:n}=nn[e].workerContext;t&&r.push(cs(t,fe.GLOBALS_SYNC,"",[Z],n))}await Promise.all(r)}}function lt(r,e){if(Array.isArray(e))e.splice(0,e.length);else if(typeof e=="object")for(const t in e)delete e[t];for(const t in r)Array.isArray(r[t])?(e[t]=[],lt(r[t],e[t])):typeof r[t]=="object"?(e[t]={},lt(r[t],e[t])):e[t]=r[t]}async function fs(r,e){const{functionName:t,args:n}=r;if(!e.instance)throw"instance not initialized";if(!t)throw"missing function name to call";if(!e.instance[t])throw`undefined function [${t}] in class ${e.instance.constructor.workerId}`;Oe(r,await e.instance[t](...n??[]))}const ls=Xt("registeredWorkers",{});function ds(r,e){if(!r.args)throw"Missing className while initializing worker";const[t,n]=r.args,i=ls[t];if(i)e.instance=new i(r.args.slice(1));else throw`unknown worker class ${t}`;lt(n,Z),Oe(r,typeof e.instance!==void 0)}async function hs(r,e){const{args:t}=r;if(!e.instance)throw"instance not initialized";let n;e.instance.terminate&&(n=await e.instance.terminate(...t??[])),Oe(r,n)}function ms(r){if(!r.args)throw"Missing globals while syncing";lt(r.args[0],Z),Oe(r,{})}function ps(){const r={};onmessage=async e=>{const t=e.data;switch(t.type){case fe.INIT:ds(t,r);break;case fe.FORWARD:fs(t,r);break;case fe.TERMINATE:hs(t,r);break;case fe.GLOBALS_SYNC:ms(t);break}}}sn()&&ps();function gs(r,e){return Z[r]||(Z[r]=e),[()=>Z[r],async t=>{Z[r]=t,await us()}]}function ys(r,e){return gs(r,e)}const[bs,xs]=ys("metadata");function _s(r){xs(r)}function Yt(){return bs()}let Qt=class{constructor(e,t){Ji(this,"uuid"),this.config=e,this.uuid=t??os()}async send(e){var t,n,i;const{appId:s,sourceType:o}=(t=Yt())!=null?t:{};if(!s||!o)return"metadata missing";const a=new AbortController,c=setTimeout(()=>a.abort(),ts);return await((i=(n=this.config)==null?void 0:n.fetch)!=null?i:fetch)(this.getUrl(),{method:"POST",headers:this.getHeaders(),body:JSON.stringify(this.buildReport(e)),signal:a.signal}),clearTimeout(c),"success"}getUrl(){var e;let t=(e=Yt().proxyUrl)!=null?e:es;return t+=(t.at(-1)==="/"?"":"/")+Zi,t}getHeaders(){return{"Content-Type":"application/json"}}buildReport(e){const t=Yt();return{guid:this.uuid,...e,applicationId:t.appId,timestamp:Date.now(),proxyUrl:t.proxyUrl,source:t.sourceType}}};const dt="3.0.2",qt=class{};qt.updates={transformer_new:"New transformer",transformer_null:"Null transformer"},qt.errors={transformer_none:"No transformers provided",transformer_start:"Cannot start transformer",transformer_transform:"Cannot transform frame",transformer_flush:"Cannot flush transformer",readable_null:"Readable is null",writable_null:"Writable is null"};let le=qt;function Es(r){return typeof r=="object"&&r!==null&&"message"in r&&typeof r.message=="string"}function ws(r){if(Es(r))return r;try{return new Error(JSON.stringify(r))}catch{return new Error(String(r))}}function Kt(r){return ws(r).message}class vs{constructor(e,t){this.config=e,this.frameTransformedCount=0,this.frameFromSourceCount=0,this.startAt=0,this.reporter=new Qt(e,t)}async onFrameFromSource(){this.frameFromSourceCount++}get fps(){const{startAt:e,frameFromSourceCount:t}=this,n=(Date.now()-e)/1e3;return t/n}async onFrameTransformed(e={},t=!1){this.startAt===0&&(this.startAt=Date.now()),this.frameTransformedCount++;const{startAt:n,frameTransformedCount:i,frameFromSourceCount:s}=this,o=Date.now(),a=(o-n)/1e3,c=i/a,u=s/a;return t||this.frameTransformedCount>=this.config.loggingIntervalFrameCount?(this.frameFromSourceCount=0,this.frameTransformedCount=0,this.startAt=o,this.reporter.config=this.config,this.reporter.send({...this.config.report,variation:"QoS",fps:u,transformedFps:c,framesTransformed:i,...e})):"success"}}var Jt=(r=>(r.pipeline_ended="pipeline_ended",r.pipeline_ended_with_error="pipeline_ended_with_error",r.pipeline_started="pipeline_started",r.pipeline_started_with_error="pipeline_started_with_error",r.pipeline_restarted="pipeline_restarted",r.pipeline_restarted_with_error="pipeline_restarted_with_error",r))(Jt||{});const Ts=500,As=.8;class Is extends Y{constructor(e,t){super(),this.reporter_=new Qt,this.reporterQos_=new vs({loggingIntervalFrameCount:Ts,report:{version:dt}}),this.index_=t,this.transformer_=e,this.shouldStop_=!1,this.isFlashed_=!1,this.mediaTransformerQosReportStartTimestamp_=0,this.videoHeight_=0,this.videoWidth_=0,this.trackExpectedRate_=-1,this.transformerType_="Custom","getTransformerType"in e&&(this.transformerType_=e.getTransformerType()),this.report({variation:"Create"})}setTrackExpectedRate(e){this.trackExpectedRate_=e}async start(e){if(this.controller_=e,this.transformer_&&typeof this.transformer_.start=="function")try{await this.transformer_.start(e)}catch(t){this.report({message:le.errors.transformer_start,variation:"Error",error:Kt(t)});const n={eventMetaData:{transformerIndex:this.index_},error:t,function:"start"};this.emit("error",n)}}async transform(e,t){if(this.mediaTransformerQosReportStartTimestamp_===0&&(this.mediaTransformerQosReportStartTimestamp_=Date.now()),e instanceof VideoFrame&&(this.videoHeight_=e?.displayHeight??0,this.videoWidth_=e?.displayWidth??0),this.reporterQos_.onFrameFromSource(),this.transformer_)if(this.shouldStop_)console.warn("[Pipeline] flush from transform"),e.close(),this.flush(t),t.terminate();else{try{await this.transformer_.transform?.(e,t),this.reportQos()}catch(n){this.report({message:le.errors.transformer_transform,variation:"Error",error:Kt(n)});const i={eventMetaData:{transformerIndex:this.index_},error:n,function:"transform"};this.emit("error",i)}if(this.trackExpectedRate_!=-1&&this.trackExpectedRate_*As>this.reporterQos_.fps){const n={eventMetaData:{transformerIndex:this.index_},warningType:"fps_drop",dropInfo:{requested:this.trackExpectedRate_,current:this.reporterQos_.fps}};this.emit("warn",n)}}}async flush(e){if(this.transformer_&&typeof this.transformer_.flush=="function"&&!this.isFlashed_){this.isFlashed_=!0;try{await this.transformer_.flush(e)}catch(t){this.report({message:le.errors.transformer_flush,variation:"Error",error:Kt(t)});const n={eventMetaData:{transformerIndex:this.index_},error:t,function:"flush"};this.emit("error",n)}}this.reportQos(!0),this.report({variation:"Delete"})}stop(){console.log("[Pipeline] Stop stream."),this.controller_&&(this.flush(this.controller_),this.controller_.terminate()),this.shouldStop_=!0}report(e){this.reporter_.send({version:dt,action:"MediaTransformer",transformerType:this.transformerType_,...e})}reportQos(e=!1){this.reporterQos_.config={...this.reporterQos_.config},this.reporterQos_.onFrameTransformed({version:dt,action:"MediaTransformer",transformerType:this.transformerType_,videoWidth:this.videoWidth_,videoHeight:this.videoHeight_},e)}}class Ss extends Y{constructor(e){super(),this.transformers_=[],this.trackExpectedRate_=-1;for(let t=0;t<e.length;t++){let n=new Is(e[t],t);n.on("error",i=>{this.emit("error",i)}),n.on("warn",i=>{this.emit("warn",i)}),this.transformers_.push(n)}}setTrackExpectedRate(e){this.trackExpectedRate_=e;for(let t of this.transformers_)t.setTrackExpectedRate(this.trackExpectedRate_)}async start(e,t){if(!this.transformers_||this.transformers_.length===0){console.log("[Pipeline] No transformers.");return}try{let n=e;for(let i of this.transformers_)e=e.pipeThrough(new TransformStream(i));e.pipeTo(t).then(async()=>{console.log("[Pipeline] Setup."),await t.abort(),await n.cancel(),this.emit("pipelineInfo","pipeline_ended")}).catch(async i=>{e.cancel().then(()=>{console.log("[Pipeline] Shutting down streams after abort.")}).catch(s=>{console.error("[Pipeline] Error from stream transform:",s)}),await t.abort(i),await n.cancel(i),this.emit("pipelineInfo","pipeline_ended_with_error")})}catch{this.emit("pipelineInfo","pipeline_started_with_error"),this.destroy();return}this.emit("pipelineInfo","pipeline_started"),console.log("[Pipeline] Pipeline started.")}async destroy(){console.log("[Pipeline] Destroying Pipeline.");for(let e of this.transformers_)e.stop()}}class Rs extends Y{constructor(){super(),this.reporter_=new Qt,this.trackExpectedRate_=-1,this.report({variation:"Create"})}setTrackExpectedRate(e){this.trackExpectedRate_=e,this.pipeline_&&this.pipeline_.setTrackExpectedRate(this.trackExpectedRate_)}async transform(e,t){if(this.isTrack(e)){if(e.kind==="video"){const n=new MediaStreamTrackProcessor({track:e}),i=new VideoTrackGenerator;return this.readable_=n.readable,this.writable_=i.writable,await this.transformInternal(),i.track}throw Error("Cannot process audio tracks inside a web worker when passing a track to transform")}else return this.readable_=e,this.writable_=t,this.transformInternal()}transformInternal(){return new Promise(async(e,t)=>{if(!this.transformers_||this.transformers_.length===0){this.report({message:le.errors.transformer_none,variation:"Error"}),t("[MediaProcessor] Need to set transformers.");return}if(!this.readable_){this.report({variation:"Error",message:le.errors.readable_null}),t("[MediaProcessor] Readable is null.");return}if(!this.writable_){this.report({variation:"Error",message:le.errors.writable_null}),t("[MediaProcessor] Writable is null.");return}let n=!1;this.pipeline_&&(n=!0,this.pipeline_.clearListeners(),this.pipeline_.destroy()),this.pipeline_=new Ss(this.transformers_),this.pipeline_.on("warn",i=>{this.emit("warn",i)}),this.pipeline_.on("error",i=>{this.emit("error",i)}),this.pipeline_.on("pipelineInfo",i=>{n&&(i==="pipeline_started"?i=Jt.pipeline_restarted:i==="pipeline_started_with_error"&&(i=Jt.pipeline_restarted_with_error)),this.emit("pipelineInfo",i)}),this.trackExpectedRate_!=-1&&this.pipeline_.setTrackExpectedRate(this.trackExpectedRate_),this.pipeline_.start(this.readable_,this.writable_).then(()=>{e()}).catch(i=>{t(i)})})}setTransformers(e){return this.report({variation:"Update",message:le.updates.transformer_new}),this.transformers_=e,this.readable_&&this.writable_?this.transformInternal():Promise.resolve()}destroy(){return new Promise(async e=>{this.pipeline_&&this.pipeline_.destroy(),this.report({variation:"Delete"}),e()})}report(e){this.reporter_.send({version:dt,action:"MediaProcessor",...e})}isTrack(e){return"kind"in e}}var Fs=Object.defineProperty,Ps=(r,e,t)=>e in r?Fs(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ks=(r,e,t)=>(Ps(r,e+"",t),t);const Cs="hlg.tokbox.com/prod/logging/vcp_webrtc",Bs="https://",Ds=1e4;let ht;const Ms=new Uint8Array(16);function Os(){if(!ht&&(ht=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!ht))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ht(Ms)}const P=[];for(let r=0;r<256;++r)P.push((r+256).toString(16).slice(1));function Us(r,e=0){return(P[r[e+0]]+P[r[e+1]]+P[r[e+2]]+P[r[e+3]]+"-"+P[r[e+4]]+P[r[e+5]]+"-"+P[r[e+6]]+P[r[e+7]]+"-"+P[r[e+8]]+P[r[e+9]]+"-"+P[r[e+10]]+P[r[e+11]]+P[r[e+12]]+P[r[e+13]]+P[r[e+14]]+P[r[e+15]]).toLowerCase()}const Ns=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),on={randomUUID:Ns};function Ls(r,e,t){if(on.randomUUID&&!e&&!r)return on.randomUUID();r=r||{};const n=r.random||(r.rng||Os)();return n[6]=n[6]&15|64,n[8]=n[8]&63|128,Us(n)}function Zt(r,e){globalThis.vonage||(globalThis.vonage={}),globalThis.vonage.workerizer||(globalThis.vonage.workerizer={});let t=globalThis.vonage.workerizer;return t[r]||(t[r]=e),t[r]}const ee=Zt("globals",{});var de=(r=>(r.INIT="INIT",r.FORWARD="FORWARD",r.TERMINATE="TERMINATE",r.GLOBALS_SYNC="GLOBALS_SYNC",r))(de||{});function an(r){return[ImageBitmap,ReadableStream,WritableStream].some(e=>r instanceof e)}let zs=0;function Gs(r,e,t,n,i){const s=zs++;return r.postMessage({id:s,type:e,functionName:t,args:n},n.filter(o=>an(o))),new Promise(o=>{i?.set(s,o)})}function Ue(r,e){const{id:t,type:n}=r,i=Array.isArray(e)?e:[e];postMessage({id:t,type:n,result:e},i.filter(s=>an(s)))}const cn=Zt("workerized",{});function un(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}async function $s(){if(un())Ue({type:de.GLOBALS_SYNC},ee);else{const r=[];for(const e in cn){const{worker:t,resolvers:n}=cn[e].workerContext;t&&r.push(Gs(t,de.GLOBALS_SYNC,"",[ee],n))}await Promise.all(r)}}function mt(r,e){if(Array.isArray(e))e.splice(0,e.length);else if(typeof e=="object")for(const t in e)delete e[t];for(const t in r)Array.isArray(r[t])?(e[t]=[],mt(r[t],e[t])):typeof r[t]=="object"?(e[t]={},mt(r[t],e[t])):e[t]=r[t]}async function Ws(r,e){const{functionName:t,args:n}=r;if(!e.instance)throw"instance not initialized";if(!t)throw"missing function name to call";if(!e.instance[t])throw`undefined function [${t}] in class ${e.instance.constructor.workerId}`;Ue(r,await e.instance[t](...n??[]))}const Vs=Zt("registeredWorkers",{});function Hs(r,e){if(!r.args)throw"Missing className while initializing worker";const[t,n]=r.args,i=Vs[t];if(i)e.instance=new i(r.args.slice(1));else throw`unknown worker class ${t}`;mt(n,ee),Ue(r,typeof e.instance!==void 0)}async function js(r,e){const{args:t}=r;if(!e.instance)throw"instance not initialized";let n;e.instance.terminate&&(n=await e.instance.terminate(...t??[])),Ue(r,n)}function Xs(r){if(!r.args)throw"Missing globals while syncing";mt(r.args[0],ee),Ue(r,{})}function Ys(){const r={};onmessage=async e=>{const t=e.data;switch(t.type){case de.INIT:Hs(t,r);break;case de.FORWARD:Ws(t,r);break;case de.TERMINATE:js(t,r);break;case de.GLOBALS_SYNC:Xs(t);break}}}un()&&Ys();function Qs(r,e){return ee[r]||(ee[r]=e),[()=>ee[r],async t=>{ee[r]=t,await $s()}]}function qs(r,e){return Qs(r,e)}const[Ks]=qs("metadata");function er(){return Ks()}class Js{constructor(e){ks(this,"uuid",Ls()),this.config=e}async send(e){var t,n,i;const{appId:s,sourceType:o}=(t=er())!=null?t:{};if(!s||!o)return"metadata missing";const a=new AbortController,c=setTimeout(()=>a.abort(),Ds);return await((i=(n=this.config)==null?void 0:n.fetch)!=null?i:fetch)(this.getUrl(),{method:"POST",headers:this.getHeaders(),body:JSON.stringify(this.buildReport(e)),signal:a.signal}),clearTimeout(c),"success"}getUrl(){var e;let t=(e=er().proxyUrl)!=null?e:Bs;return t+=(t.at(-1)==="/"?"":"/")+Cs,t}getHeaders(){return{"Content-Type":"application/json"}}buildReport(e){const t=er();return{guid:this.uuid,...e,applicationId:t.appId,timestamp:Date.now(),proxyUrl:t.proxyUrl,source:t.sourceType}}}const Zs="7.0.2-alpha.2";var pt=(r=>(r.Low="Low",r.High="High",r))(pt||{}),tr=(r=>(r.FAST="FAST",r.PRECISE="PRECISE",r))(tr||{}),gt=(r=>(r.CANVAS="CANVAS",r.WEBGL="WEBGL",r))(gt||{});function eo(){const e=new OffscreenCanvas(0,0).getContext("webgl2",{failIfMajorPerformanceCaveat:!0});if(e){const t=e?.getExtension("WEBGL_lose_context");t&&t.loseContext()}else return{supported:!1,message:"Your hardware does not perform good enough to run the library efficiently"};return{supported:!0}}class rr{constructor(){const e=new OffscreenCanvas(0,0),t=e.getContext("2d",{willReadFrequently:!0});if(!t)throw"Fail to retrieve 2d context";this.canvas=e,this.context=t}enablePostProcessing(){}disablePostProcessing(){}async profileWebgl(e){return[]}async render(e,t){return this.canvas}resizeCanvas(e){const{width:t,height:n}=e;this.canvas.width=t,this.canvas.height=n}renderSilhouette(e,t,n="none"){const{width:i,height:s}=e;this.context.save(),this.context.drawImage(t,0,0,t.width,t.height,0,0,i,s),this.context.filter="blur(5px)",this.context.globalCompositeOperation="source-in",this.context.drawImage(t,0,0,t.width,t.height,0,0,i,s),this.context.globalCompositeOperation="source-in",this.context.filter=n,this.context.drawImage(e,0,0,i,s,0,0,this.canvas.width,this.canvas.height),this.context.restore()}destroy(){}}class to extends rr{constructor(e){super(),this.radius=e}async render(e,t){super.resizeCanvas(e);const n=await createImageBitmap(t);return this.renderSilhouette(e,n),this.context.save(),this.context.filter=`blur(${this.radius}px)`,this.context.globalCompositeOperation="destination-over",this.context.drawImage(e,0,0,e.width,e.height),this.context.restore(),super.render(e,t)}}class ro extends rr{constructor(e){super(),this.radius=e}async render(e,t){super.resizeCanvas(e);const n=await createImageBitmap(t);return this.renderSilhouette(e,n,`blur(${this.radius}px)`),this.context.save(),this.context.filter="none",this.context.globalCompositeOperation="destination-over",this.context.drawImage(e,0,0,e.width,e.height),this.context.restore(),super.render(e,t)}}class no extends rr{setBackgroundImage(e){this.backgroundImage=e}async render(e,t){super.resizeCanvas(e);const n=await createImageBitmap(t);return this.renderSilhouette(e,n),this.backgroundImage&&(this.context.save(),this.context.filter="none",this.context.globalCompositeOperation="destination-over",this.context.drawImage(this.backgroundImage,0,0,this.backgroundImage.width,this.backgroundImage.height,0,0,e.width,e.height),this.context.restore()),super.render(e,t)}}const nr=5120,Ne=5121,ir=5122,sr=5123,or=5124,ar=5125,cr=5126,io=32819,so=32820,oo=33635,ao=5131,co=33640,uo=35899,fo=35902,lo=36269,ho=34042,fn={};{const r=fn;r[nr]=Int8Array,r[Ne]=Uint8Array,r[ir]=Int16Array,r[sr]=Uint16Array,r[or]=Int32Array,r[ar]=Uint32Array,r[cr]=Float32Array,r[io]=Uint16Array,r[so]=Uint16Array,r[oo]=Uint16Array,r[ao]=Uint16Array,r[co]=Uint32Array,r[uo]=Uint32Array,r[fo]=Uint32Array,r[lo]=Uint32Array,r[ho]=Uint32Array}function ur(r){if(r instanceof Int8Array)return nr;if(r instanceof Uint8Array||r instanceof Uint8ClampedArray)return Ne;if(r instanceof Int16Array)return ir;if(r instanceof Uint16Array)return sr;if(r instanceof Int32Array)return or;if(r instanceof Uint32Array)return ar;if(r instanceof Float32Array)return cr;throw new Error("unsupported typed array type")}function ln(r){if(r===Int8Array)return nr;if(r===Uint8Array||r===Uint8ClampedArray)return Ne;if(r===Int16Array)return ir;if(r===Uint16Array)return sr;if(r===Int32Array)return or;if(r===Uint32Array)return ar;if(r===Float32Array)return cr;throw new Error("unsupported typed array type")}function dn(r){const e=fn[r];if(!e)throw new Error("unknown gl type");return e}const yt=typeof SharedArrayBuffer<"u"?function(e){return e&&e.buffer&&(e.buffer instanceof ArrayBuffer||e.buffer instanceof SharedArrayBuffer)}:function(e){return e&&e.buffer&&e.buffer instanceof ArrayBuffer};function hn(...r){console.error(...r)}const mn=new Map;function bt(r,e){if(!r||typeof r!="object")return!1;let t=mn.get(e);t||(t=new WeakMap,mn.set(e,t));let n=t.get(r);if(n===void 0){const i=Object.prototype.toString.call(r);n=i.substring(8,i.length-1)===e,t.set(r,n)}return n}function mo(r,e){return typeof WebGLBuffer<"u"&&bt(e,"WebGLBuffer")}function po(r,e){return typeof WebGLRenderbuffer<"u"&&bt(e,"WebGLRenderbuffer")}function fr(r,e){return typeof WebGLTexture<"u"&&bt(e,"WebGLTexture")}function go(r,e){return typeof WebGLSampler<"u"&&bt(e,"WebGLSampler")}const pn=35044,he=34962,yo=34963,bo=34660,xo=5120,_o=5121,Eo=5122,wo=5123,vo=5124,To=5125,gn=5126,yn={attribPrefix:""};function Ao(r,e,t,n,i){r.bindBuffer(e,t),r.bufferData(e,n,i||pn)}function bn(r,e,t,n){if(mo(r,e))return e;t=t||he;const i=r.createBuffer();return Ao(r,t,i,e,n),i}function xn(r){return r==="indices"}function Io(r){return r===Int8Array||r===Uint8Array}function So(r){return r.length?r:r.data}const Ro=/coord|texture/i,Fo=/color|colour/i;function Po(r,e){let t;if(Ro.test(r)?t=2:Fo.test(r)?t=4:t=3,e%t>0)throw new Error(`Can not guess numComponents for attribute \'${r}\'. Tried ${t} but ${e} values is not evenly divisible by ${t}. You should specify it.`);return t}function ko(r,e,t){return r.numComponents||r.size||Po(e,t||So(r).length)}function _n(r,e){if(yt(r))return r;if(yt(r.data))return r.data;Array.isArray(r)&&(r={data:r});let t=r.type?lr(r.type):void 0;return t||(xn(e)?t=Uint16Array:t=Float32Array),new t(r.data)}function Co(r){return typeof r=="number"?r:r?ln(r):gn}function lr(r){return typeof r=="number"?dn(r):r||Float32Array}function Bo(r,e){return{buffer:e.buffer,numValues:24,type:Co(e.type),arrayType:lr(e.type)}}function Do(r,e){const t=e.data||e,n=lr(e.type),i=t*n.BYTES_PER_ELEMENT,s=r.createBuffer();return r.bindBuffer(he,s),r.bufferData(he,i,e.drawType||pn),{buffer:s,numValues:t,type:ln(n),arrayType:n}}function Mo(r,e,t){const n=_n(e,t);return{arrayType:n.constructor,buffer:bn(r,n,void 0,e.drawType),type:ur(n),numValues:0}}function Oo(r,e){const t={};return Object.keys(e).forEach(function(n){if(!xn(n)){const i=e[n],s=i.attrib||i.name||i.attribName||yn.attribPrefix+n;if(i.value){if(!Array.isArray(i.value)&&!yt(i.value))throw new Error("array.value is not array or typedarray");t[s]={value:i.value}}else{let o;i.buffer&&i.buffer instanceof WebGLBuffer?o=Bo:typeof i=="number"||typeof i.data=="number"?o=Do:o=Mo;const{buffer:a,type:c,numValues:u,arrayType:d}=o(r,i,n),m=i.normalize!==void 0?i.normalize:Io(d),p=ko(i,n,u);t[s]={buffer:a,numComponents:p,type:c,normalize:m,stride:i.stride||0,offset:i.offset||0,divisor:i.divisor===void 0?void 0:i.divisor,drawType:i.drawType}}}}),r.bindBuffer(he,null),t}function Uo(r,e){return e===xo||e===_o?1:e===Eo||e===wo?2:e===vo||e===To||e===gn?4:0}const dr=["position","positions","a_position"];function No(r,e){let t,n;for(n=0;n<dr.length&&(t=dr[n],!(t in e||(t=yn.attribPrefix+t,t in e)));++n);n===dr.length&&(t=Object.keys(e)[0]);const i=e[t];if(!i.buffer)return 1;r.bindBuffer(he,i.buffer);const s=r.getBufferParameter(he,bo);r.bindBuffer(he,null);const o=Uo(r,i.type),a=s/o,c=i.numComponents||i.size,u=a/c;if(u%1!==0)throw new Error(`numComponents ${c} not correct for length ${length}`);return u}function Lo(r,e,t){const n=Oo(r,e),i=Object.assign({},t||{});i.attribs=Object.assign({},t?t.attribs:{},n);const s=e.indices;if(s){const o=_n(s,"indices");i.indices=bn(r,o,yo),i.numElements=o.length,i.elementType=ur(o)}else i.numElements||(i.numElements=No(r,i.attribs));return i}function Le(r){return!!r.texStorage2D}const En=(function(){const r={},e={};function t(n){const i=n.constructor.name;if(!r[i]){for(const s in n)if(typeof n[s]=="number"){const o=e[n[s]];e[n[s]]=o?`${o} | ${s}`:s}r[i]=!0}}return function(i,s){return t(i),e[s]||(typeof s=="number"?`0x${s.toString(16)}`:s)}})(),te={textureColor:new Uint8Array([128,192,255,255]),textureOptions:{},crossOrigin:void 0},ze=yt,wn=(function(){let r;return function(){return r=r||(typeof document<"u"&&document.createElement?document.createElement("canvas").getContext("2d"):null),r}})(),vn=6406,V=6407,A=6408,Tn=6409,An=6410,Ge=6402,In=34041,xt=33071,zo=9728,Go=9729,re=3553,ne=34067,me=32879,pe=35866,hr=34069,$o=34070,Wo=34071,Vo=34072,Ho=34073,jo=34074,mr=10241,pr=10240,_t=10242,Et=10243,Sn=32882,Xo=33082,Yo=33083,Qo=33084,qo=33085,Ko=34892,Jo=34893,gr=3317,Rn=3314,Fn=32878,Pn=3316,kn=3315,Cn=32877,Zo=37443,ea=37441,ta=37440,ra=33321,na=36756,ia=33325,sa=33326,oa=33330,aa=33329,ca=33338,ua=33337,fa=33340,la=33339,da=33323,ha=36757,ma=33327,pa=33328,ga=33336,ya=33335,ba=33332,xa=33331,_a=33334,Ea=33333,wa=32849,va=35905,Ta=36194,Aa=36758,Ia=35898,Sa=35901,Ra=34843,Fa=34837,Pa=36221,ka=36239,Ca=36215,Ba=36233,Da=36209,Ma=36227,Oa=32856,Ua=35907,Na=36759,La=32855,za=32854,Ga=32857,$a=34842,Wa=34836,Va=36220,Ha=36238,ja=36975,Xa=36214,Ya=36232,Qa=36226,qa=36208,Ka=33189,Ja=33190,Za=36012,ec=36013,tc=35056,ie=5120,T=5121,wt=5122,Se=5123,vt=5124,ge=5125,B=5126,Bn=32819,Dn=32820,Mn=33635,z=5131,$e=36193,yr=33640,rc=35899,nc=35902,ic=36269,sc=34042,Tt=33319,Re=33320,At=6403,Fe=36244,Pe=36248,ye=36249;let br;function It(r){if(!br){const e={};e[vn]={textureFormat:vn,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1,2,2,4],type:[T,z,$e,B]},e[Tn]={textureFormat:Tn,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1,2,2,4],type:[T,z,$e,B]},e[An]={textureFormat:An,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[2,4,4,8],type:[T,z,$e,B]},e[V]={textureFormat:V,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3,6,6,12,2],type:[T,z,$e,B,Mn]},e[A]={textureFormat:A,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,8,8,16,2,2],type:[T,z,$e,B,Bn,Dn]},e[Ge]={textureFormat:Ge,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2,4],type:[ge,Se]},e[ra]={textureFormat:At,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1],type:[T]},e[na]={textureFormat:At,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[1],type:[ie]},e[ia]={textureFormat:At,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[4,2],type:[B,z]},e[sa]={textureFormat:At,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[4],type:[B]},e[oa]={textureFormat:Fe,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[1],type:[T]},e[aa]={textureFormat:Fe,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[1],type:[ie]},e[ba]={textureFormat:Fe,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[Se]},e[xa]={textureFormat:Fe,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[wt]},e[_a]={textureFormat:Fe,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[ge]},e[Ea]={textureFormat:Fe,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[vt]},e[da]={textureFormat:Tt,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[2],type:[T]},e[ha]={textureFormat:Tt,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[2],type:[ie]},e[ma]={textureFormat:Tt,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[8,4],type:[B,z]},e[pa]={textureFormat:Tt,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[8],type:[B]},e[ga]={textureFormat:Re,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[T]},e[ya]={textureFormat:Re,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[ie]},e[ca]={textureFormat:Re,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[Se]},e[ua]={textureFormat:Re,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[wt]},e[fa]={textureFormat:Re,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[ge]},e[la]={textureFormat:Re,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[vt]},e[wa]={textureFormat:V,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3],type:[T]},e[va]={textureFormat:V,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[3],type:[T]},e[Ta]={textureFormat:V,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3,2],type:[T,Mn]},e[Aa]={textureFormat:V,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[3],type:[ie]},e[Ia]={textureFormat:V,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6,4],type:[B,z,rc]},e[Sa]={textureFormat:V,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6,4],type:[B,z,nc]},e[Ra]={textureFormat:V,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6],type:[B,z]},e[Fa]={textureFormat:V,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[B]},e[Pa]={textureFormat:Pe,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[3],type:[T]},e[ka]={textureFormat:Pe,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[3],type:[ie]},e[Ca]={textureFormat:Pe,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[6],type:[Se]},e[Ba]={textureFormat:Pe,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[6],type:[wt]},e[Da]={textureFormat:Pe,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[ge]},e[Ma]={textureFormat:Pe,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[vt]},e[Oa]={textureFormat:A,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[T]},e[Ua]={textureFormat:A,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[T]},e[Na]={textureFormat:A,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[4],type:[ie]},e[La]={textureFormat:A,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,2,4],type:[T,Dn,yr]},e[za]={textureFormat:A,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,2],type:[T,Bn]},e[Ga]={textureFormat:A,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[yr]},e[$a]={textureFormat:A,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[16,8],type:[B,z]},e[Wa]={textureFormat:A,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[16],type:[B]},e[Va]={textureFormat:ye,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[T]},e[Ha]={textureFormat:ye,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[ie]},e[ja]={textureFormat:ye,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[yr]},e[Xa]={textureFormat:ye,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[Se]},e[Ya]={textureFormat:ye,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[wt]},e[Qa]={textureFormat:ye,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[16],type:[vt]},e[qa]={textureFormat:ye,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[16],type:[ge]},e[Ka]={textureFormat:Ge,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2,4],type:[Se,ge]},e[Ja]={textureFormat:Ge,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[ge]},e[Za]={textureFormat:Ge,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[B]},e[tc]={textureFormat:In,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[sc]},e[ec]={textureFormat:In,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[ic]},Object.keys(e).forEach(function(t){const n=e[t];n.bytesPerElementMap={},n.bytesPerElement.forEach(function(i,s){const o=n.type[s];n.bytesPerElementMap[o]=i})}),br=e}return br[r]}function oc(r,e){const t=It(r);if(!t)throw"unknown internal format";const n=t.bytesPerElementMap[e];if(n===void 0)throw"unknown internal format";return n}function We(r){const e=It(r);if(!e)throw"unknown internal format";return{format:e.textureFormat,type:e.type[0]}}function On(r){return(r&r-1)===0}function ac(r,e,t,n){if(!Le(r))return On(e)&&On(t);const i=It(n);if(!i)throw"unknown internal format";return i.colorRenderable&&i.textureFilterable}function cc(r){const e=It(r);if(!e)throw"unknown internal format";return e.textureFilterable}function uc(r,e,t){return ze(e)?ur(e):t||T}function St(r,e,t,n,i){if(i%1!==0)throw"can\'t guess dimensions";if(!t&&!n){const s=Math.sqrt(i/(e===ne?6:1));s%1===0?(t=s,n=s):(t=i,n=1)}else if(n){if(!t&&(t=i/n,t%1))throw"can\'t guess dimensions"}else if(n=i/t,n%1)throw"can\'t guess dimensions";return{width:t,height:n}}function ke(r,e){e.colorspaceConversion!==void 0&&r.pixelStorei(Zo,e.colorspaceConversion),e.premultiplyAlpha!==void 0&&r.pixelStorei(ea,e.premultiplyAlpha),e.flipY!==void 0&&r.pixelStorei(ta,e.flipY)}function Un(r){r.pixelStorei(gr,4),Le(r)&&(r.pixelStorei(Rn,0),r.pixelStorei(Fn,0),r.pixelStorei(Pn,0),r.pixelStorei(kn,0),r.pixelStorei(Cn,0))}function fc(r,e,t,n){n.minMag&&(t.call(r,e,mr,n.minMag),t.call(r,e,pr,n.minMag)),n.min&&t.call(r,e,mr,n.min),n.mag&&t.call(r,e,pr,n.mag),n.wrap&&(t.call(r,e,_t,n.wrap),t.call(r,e,Et,n.wrap),(e===me||go(r,e))&&t.call(r,e,Sn,n.wrap)),n.wrapR&&t.call(r,e,Sn,n.wrapR),n.wrapS&&t.call(r,e,_t,n.wrapS),n.wrapT&&t.call(r,e,Et,n.wrapT),n.minLod!==void 0&&t.call(r,e,Xo,n.minLod),n.maxLod!==void 0&&t.call(r,e,Yo,n.maxLod),n.baseLevel!==void 0&&t.call(r,e,Qo,n.baseLevel),n.maxLevel!==void 0&&t.call(r,e,qo,n.maxLevel),n.compareFunc!==void 0&&t.call(r,e,Jo,n.compareFunc),n.compareMode!==void 0&&t.call(r,e,Ko,n.compareMode)}function Nn(r,e,t){const n=t.target||re;r.bindTexture(n,e),fc(r,n,r.texParameteri,t)}function lc(r){return r=r||te.textureColor,ze(r)?r:new Uint8Array([r[0]*255,r[1]*255,r[2]*255,r[3]*255])}function xr(r,e,t,n,i,s){t=t||te.textureOptions,s=s||A;const o=t.target||re;if(n=n||t.width,i=i||t.height,r.bindTexture(o,e),ac(r,n,i,s))r.generateMipmap(o);else{const a=cc(s)?Go:zo;r.texParameteri(o,mr,a),r.texParameteri(o,pr,a),r.texParameteri(o,_t,xt),r.texParameteri(o,Et,xt)}}function Ve(r){return r.auto===!0||r.auto===void 0&&r.level===void 0}function _r(r,e){return e=e||{},e.cubeFaceOrder||[hr,$o,Wo,Vo,Ho,jo]}function Er(r,e){const n=_r(r,e).map(function(i,s){return{face:i,ndx:s}});return n.sort(function(i,s){return i.face-s.face}),n}function Ln(r,e,t,n){n=n||te.textureOptions;const i=n.target||re,s=n.level||0;let o=t.width,a=t.height;const c=n.internalFormat||n.format||A,u=We(c),d=n.format||u.format,m=n.type||u.type;if(ke(r,n),r.bindTexture(i,e),i===ne){const p=t.width,y=t.height;let l,b;if(p/6===y)l=y,b=[0,0,1,0,2,0,3,0,4,0,5,0];else if(y/6===p)l=p,b=[0,0,0,1,0,2,0,3,0,4,0,5];else if(p/3===y/2)l=p/3,b=[0,0,1,0,2,0,0,1,1,1,2,1];else if(p/2===y/3)l=p/2,b=[0,0,1,0,0,1,1,1,0,2,1,2];else throw"can\'t figure out cube map from element: "+(t.src?t.src:t.nodeName);const _=wn();_?(_.canvas.width=l,_.canvas.height=l,o=l,a=l,Er(r,n).forEach(function(E){const R=b[E.ndx*2+0]*l,k=b[E.ndx*2+1]*l;_.drawImage(t,R,k,l,l,0,0,l,l),r.texImage2D(E.face,s,c,d,m,_.canvas)}),_.canvas.width=1,_.canvas.height=1):typeof createImageBitmap<"u"&&(o=l,a=l,Er(r,n).forEach(function(E){const R=b[E.ndx*2+0]*l,k=b[E.ndx*2+1]*l;r.texImage2D(E.face,s,c,l,l,0,d,m,null),createImageBitmap(t,R,k,l,l,{premultiplyAlpha:"none",colorSpaceConversion:"none"}).then(function(N){ke(r,n),r.bindTexture(i,e),r.texImage2D(E.face,s,c,d,m,N),Ve(n)&&xr(r,e,n,o,a,c)})}))}else if(i===me||i===pe){const p=Math.min(t.width,t.height),y=Math.max(t.width,t.height),l=y/p;if(l%1!==0)throw"can not compute 3D dimensions of element";const b=t.width===y?1:0,_=t.height===y?1:0;r.pixelStorei(gr,1),r.pixelStorei(Rn,t.width),r.pixelStorei(Fn,0),r.pixelStorei(Cn,0),r.texImage3D(i,s,c,p,p,p,0,d,m,null);for(let E=0;E<l;++E){const R=E*p*b,k=E*p*_;r.pixelStorei(Pn,R),r.pixelStorei(kn,k),r.texSubImage3D(i,s,0,0,E,p,p,1,d,m,t)}Un(r)}else r.texImage2D(i,s,c,d,m,t);Ve(n)&&xr(r,e,n,o,a,c),Nn(r,e,n)}function He(){}function dc(r){if(typeof document<"u"){const e=document.createElement("a");return e.href=r,e.hostname===location.hostname&&e.port===location.port&&e.protocol===location.protocol}else{const e=new URL(location.href).origin;return new URL(r,location.href).origin===e}}function hc(r,e){return e===void 0&&!dc(r)?"anonymous":e}function mc(r,e,t){t=t||He;let n;if(e=e!==void 0?e:te.crossOrigin,e=hc(r,e),typeof Image<"u"){n=new Image,e!==void 0&&(n.crossOrigin=e);const i=function(){n.removeEventListener("error",s),n.removeEventListener("load",o),n=null},s=function(){const c="couldn\'t load image: "+r;hn(c),t(c,n),i()},o=function(){t(null,n),i()};return n.addEventListener("error",s),n.addEventListener("load",o),n.src=r,n}else if(typeof ImageBitmap<"u"){let i,s;const o=function(){t(i,s)},a={};e&&(a.mode="cors"),fetch(r,a).then(function(c){if(!c.ok)throw c;return c.blob()}).then(function(c){return createImageBitmap(c,{premultiplyAlpha:"none",colorSpaceConversion:"none"})}).then(function(c){s=c,setTimeout(o)}).catch(function(c){i=c,setTimeout(o)}),n=null}return n}function zn(r){return typeof ImageBitmap<"u"&&r instanceof ImageBitmap||typeof ImageData<"u"&&r instanceof ImageData||typeof HTMLElement<"u"&&r instanceof HTMLElement}function wr(r,e,t){return zn(r)?(setTimeout(function(){t(null,r)}),r):mc(r,e,t)}function vr(r,e,t){t=t||te.textureOptions;const n=t.target||re;if(r.bindTexture(n,e),t.color===!1)return;const i=lc(t.color);if(n===ne)for(let s=0;s<6;++s)r.texImage2D(hr+s,0,A,1,1,0,A,T,i);else n===me||n===pe?r.texImage3D(n,0,A,1,1,1,0,A,T,i):r.texImage2D(n,0,A,1,1,0,A,T,i)}function pc(r,e,t,n){return n=n||He,t=t||te.textureOptions,vr(r,e,t),t=Object.assign({},t),wr(t.src,t.crossOrigin,function(s,o){s?n(s,e,o):(Ln(r,e,o,t),n(null,e,o))})}function gc(r,e,t,n){n=n||He;const i=t.src;if(i.length!==6)throw"there must be 6 urls for a cubemap";const s=t.level||0,o=t.internalFormat||t.format||A,a=We(o),c=t.format||a.format,u=t.type||T,d=t.target||re;if(d!==ne)throw"target must be TEXTURE_CUBE_MAP";vr(r,e,t),t=Object.assign({},t);let m=6;const p=[],y=_r(r,t);let l;function b(_){return function(E,R){--m,E?p.push(E):R.width!==R.height?p.push("cubemap face img is not a square: "+R.src):(ke(r,t),r.bindTexture(d,e),m===5?_r().forEach(function(k){r.texImage2D(k,s,o,c,u,R)}):r.texImage2D(_,s,o,c,u,R),Ve(t)&&r.generateMipmap(d)),m===0&&n(p.length?p:void 0,e,l)}}l=i.map(function(_,E){return wr(_,t.crossOrigin,b(y[E]))})}function yc(r,e,t,n){n=n||He;const i=t.src,s=t.internalFormat||t.format||A,o=We(s),a=t.format||o.format,c=t.type||T,u=t.target||pe;if(u!==me&&u!==pe)throw"target must be TEXTURE_3D or TEXTURE_2D_ARRAY";vr(r,e,t),t=Object.assign({},t);let d=i.length;const m=[];let p;const y=t.level||0;let l=t.width,b=t.height;const _=i.length;let E=!0;function R(k){return function(N,Q){if(--d,N)m.push(N);else{if(ke(r,t),r.bindTexture(u,e),E){E=!1,l=t.width||Q.width,b=t.height||Q.height,r.texImage3D(u,y,s,l,b,_,0,a,c,null);for(let q=0;q<_;++q)r.texSubImage3D(u,y,0,0,q,l,b,1,a,c,Q)}else{let q=Q,L;(Q.width!==l||Q.height!==b)&&(L=wn(),q=L.canvas,L.canvas.width=l,L.canvas.height=b,L.drawImage(Q,0,0,l,b)),r.texSubImage3D(u,y,0,0,k,l,b,1,a,c,q),L&&q===L.canvas&&(L.canvas.width=0,L.canvas.height=0)}Ve(t)&&r.generateMipmap(u)}d===0&&n(m.length?m:void 0,e,p)}}p=i.map(function(k,N){return wr(k,t.crossOrigin,R(N))})}function bc(r,e,t,n){n=n||te.textureOptions;const i=n.target||re;r.bindTexture(i,e);let s=n.width,o=n.height,a=n.depth;const c=n.level||0,u=n.internalFormat||n.format||A,d=We(u),m=n.format||d.format,p=n.type||uc(r,t,d.type);if(ze(t))t instanceof Uint8ClampedArray&&(t=new Uint8Array(t.buffer));else{const _=dn(p);t=new _(t)}const y=oc(u,p),l=t.byteLength/y;if(l%1)throw"length wrong size for format: "+En(r,m);let b;if(i===me||i===pe)if(!s&&!o&&!a){const _=Math.cbrt(l);if(_%1!==0)throw"can\'t guess cube size of array of numElements: "+l;s=_,o=_,a=_}else s&&(!o||!a)?(b=St(r,i,o,a,l/s),o=b.width,a=b.height):o&&(!s||!a)?(b=St(r,i,s,a,l/o),s=b.width,a=b.height):(b=St(r,i,s,o,l/a),s=b.width,o=b.height);else b=St(r,i,s,o,l),s=b.width,o=b.height;if(Un(r),r.pixelStorei(gr,n.unpackAlignment||1),ke(r,n),i===ne){const _=y/t.BYTES_PER_ELEMENT,E=l/6*_;Er(r,n).forEach(R=>{const k=E*R.ndx,N=t.subarray(k,k+E);r.texImage2D(R.face,c,u,s,o,0,m,p,N)})}else i===me||i===pe?r.texImage3D(i,c,u,s,o,a,0,m,p,t):r.texImage2D(i,c,u,s,o,0,m,p,t);return{width:s,height:o,depth:a,type:p}}function xc(r,e,t){const n=t.target||re;r.bindTexture(n,e);const i=t.level||0,s=t.internalFormat||t.format||A,o=We(s),a=t.format||o.format,c=t.type||o.type;if(ke(r,t),n===ne)for(let u=0;u<6;++u)r.texImage2D(hr+u,i,s,t.width,t.height,0,a,c,null);else n===me||n===pe?r.texImage3D(n,i,s,t.width,t.height,t.depth,0,a,c,null):r.texImage2D(n,i,s,t.width,t.height,0,a,c,null)}function Gn(r,e,t){t=t||He,e=e||te.textureOptions;const n=r.createTexture(),i=e.target||re;let s=e.width||1,o=e.height||1;const a=e.internalFormat||A;r.bindTexture(i,n),i===ne&&(r.texParameteri(i,_t,xt),r.texParameteri(i,Et,xt));let c=e.src;if(c)if(typeof c=="function"&&(c=c(r,e)),typeof c=="string")pc(r,n,e,t);else if(ze(c)||Array.isArray(c)&&(typeof c[0]=="number"||Array.isArray(c[0])||ze(c[0]))){const u=bc(r,n,c,e);s=u.width,o=u.height}else Array.isArray(c)&&(typeof c[0]=="string"||zn(c[0]))?i===ne?gc(r,n,e,t):yc(r,n,e,t):(Ln(r,n,c,e),s=c.width,o=c.height);else xc(r,n,e);return Ve(e)&&xr(r,n,e,s,o,a),Nn(r,n,e),n}const Tr=hn;function $n(r){return typeof document<"u"&&document.getElementById?document.getElementById(r):null}const Rt=33984,Ft=34962,_c=34963,Ec=35713,wc=35714,vc=35632,Tc=35633,Ac=35981,Wn=35718,Ic=35721,Sc=35971,Rc=35382,Fc=35396,Pc=35398,kc=35392,Cc=35395,Pt=5126,Vn=35664,Hn=35665,jn=35666,Ar=5124,Xn=35667,Yn=35668,Qn=35669,qn=35670,Kn=35671,Jn=35672,Zn=35673,ei=35674,ti=35675,ri=35676,Bc=35678,Dc=35680,Mc=35679,Oc=35682,Uc=35685,Nc=35686,Lc=35687,zc=35688,Gc=35689,$c=35690,Wc=36289,Vc=36292,Hc=36293,Ir=5125,ni=36294,ii=36295,si=36296,jc=36298,Xc=36299,Yc=36300,Qc=36303,qc=36306,Kc=36307,Jc=36308,Zc=36311,kt=3553,Ct=34067,Sr=32879,Bt=35866,x={};function oi(r,e){return x[e].bindPoint}function eu(r,e){return function(t){r.uniform1f(e,t)}}function tu(r,e){return function(t){r.uniform1fv(e,t)}}function ru(r,e){return function(t){r.uniform2fv(e,t)}}function nu(r,e){return function(t){r.uniform3fv(e,t)}}function iu(r,e){return function(t){r.uniform4fv(e,t)}}function ai(r,e){return function(t){r.uniform1i(e,t)}}function ci(r,e){return function(t){r.uniform1iv(e,t)}}function ui(r,e){return function(t){r.uniform2iv(e,t)}}function fi(r,e){return function(t){r.uniform3iv(e,t)}}function li(r,e){return function(t){r.uniform4iv(e,t)}}function su(r,e){return function(t){r.uniform1ui(e,t)}}function ou(r,e){return function(t){r.uniform1uiv(e,t)}}function au(r,e){return function(t){r.uniform2uiv(e,t)}}function cu(r,e){return function(t){r.uniform3uiv(e,t)}}function uu(r,e){return function(t){r.uniform4uiv(e,t)}}function fu(r,e){return function(t){r.uniformMatrix2fv(e,!1,t)}}function lu(r,e){return function(t){r.uniformMatrix3fv(e,!1,t)}}function du(r,e){return function(t){r.uniformMatrix4fv(e,!1,t)}}function hu(r,e){return function(t){r.uniformMatrix2x3fv(e,!1,t)}}function mu(r,e){return function(t){r.uniformMatrix3x2fv(e,!1,t)}}function pu(r,e){return function(t){r.uniformMatrix2x4fv(e,!1,t)}}function gu(r,e){return function(t){r.uniformMatrix4x2fv(e,!1,t)}}function yu(r,e){return function(t){r.uniformMatrix3x4fv(e,!1,t)}}function bu(r,e){return function(t){r.uniformMatrix4x3fv(e,!1,t)}}function O(r,e,t,n){const i=oi(r,e);return Le(r)?function(s){let o,a;!s||fr(r,s)?(o=s,a=null):(o=s.texture,a=s.sampler),r.uniform1i(n,t),r.activeTexture(Rt+t),r.bindTexture(i,o),r.bindSampler(t,a)}:function(s){r.uniform1i(n,t),r.activeTexture(Rt+t),r.bindTexture(i,s)}}function U(r,e,t,n,i){const s=oi(r,e),o=new Int32Array(i);for(let a=0;a<i;++a)o[a]=t+a;return Le(r)?function(a){r.uniform1iv(n,o),a.forEach(function(c,u){r.activeTexture(Rt+o[u]);let d,m;!c||fr(r,c)?(d=c,m=null):(d=c.texture,m=c.sampler),r.bindSampler(t,m),r.bindTexture(s,d)})}:function(a){r.uniform1iv(n,o),a.forEach(function(c,u){r.activeTexture(Rt+o[u]),r.bindTexture(s,c)})}}x[Pt]={Type:Float32Array,size:4,setter:eu,arraySetter:tu},x[Vn]={Type:Float32Array,size:8,setter:ru,cols:2},x[Hn]={Type:Float32Array,size:12,setter:nu,cols:3},x[jn]={Type:Float32Array,size:16,setter:iu,cols:4},x[Ar]={Type:Int32Array,size:4,setter:ai,arraySetter:ci},x[Xn]={Type:Int32Array,size:8,setter:ui,cols:2},x[Yn]={Type:Int32Array,size:12,setter:fi,cols:3},x[Qn]={Type:Int32Array,size:16,setter:li,cols:4},x[Ir]={Type:Uint32Array,size:4,setter:su,arraySetter:ou},x[ni]={Type:Uint32Array,size:8,setter:au,cols:2},x[ii]={Type:Uint32Array,size:12,setter:cu,cols:3},x[si]={Type:Uint32Array,size:16,setter:uu,cols:4},x[qn]={Type:Uint32Array,size:4,setter:ai,arraySetter:ci},x[Kn]={Type:Uint32Array,size:8,setter:ui,cols:2},x[Jn]={Type:Uint32Array,size:12,setter:fi,cols:3},x[Zn]={Type:Uint32Array,size:16,setter:li,cols:4},x[ei]={Type:Float32Array,size:32,setter:fu,rows:2,cols:2},x[ti]={Type:Float32Array,size:48,setter:lu,rows:3,cols:3},x[ri]={Type:Float32Array,size:64,setter:du,rows:4,cols:4},x[Uc]={Type:Float32Array,size:32,setter:hu,rows:2,cols:3},x[Nc]={Type:Float32Array,size:32,setter:pu,rows:2,cols:4},x[Lc]={Type:Float32Array,size:48,setter:mu,rows:3,cols:2},x[zc]={Type:Float32Array,size:48,setter:yu,rows:3,cols:4},x[Gc]={Type:Float32Array,size:64,setter:gu,rows:4,cols:2},x[$c]={Type:Float32Array,size:64,setter:bu,rows:4,cols:3},x[Bc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:kt},x[Dc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Ct},x[Mc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Sr},x[Oc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:kt},x[Wc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Bt},x[Vc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Bt},x[Hc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Ct},x[jc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:kt},x[Xc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Sr},x[Yc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Ct},x[Qc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Bt},x[qc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:kt},x[Kc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Sr},x[Jc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Ct},x[Zc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Bt};function Dt(r,e){return function(t){if(t.value)switch(r.disableVertexAttribArray(e),t.value.length){case 4:r.vertexAttrib4fv(e,t.value);break;case 3:r.vertexAttrib3fv(e,t.value);break;case 2:r.vertexAttrib2fv(e,t.value);break;case 1:r.vertexAttrib1fv(e,t.value);break;default:throw new Error("the length of a float constant value must be between 1 and 4!")}else r.bindBuffer(Ft,t.buffer),r.enableVertexAttribArray(e),r.vertexAttribPointer(e,t.numComponents||t.size,t.type||Pt,t.normalize||!1,t.stride||0,t.offset||0),r.vertexAttribDivisor&&r.vertexAttribDivisor(e,t.divisor||0)}}function se(r,e){return function(t){if(t.value)if(r.disableVertexAttribArray(e),t.value.length===4)r.vertexAttrib4iv(e,t.value);else throw new Error("The length of an integer constant value must be 4!");else r.bindBuffer(Ft,t.buffer),r.enableVertexAttribArray(e),r.vertexAttribIPointer(e,t.numComponents||t.size,t.type||Ar,t.stride||0,t.offset||0),r.vertexAttribDivisor&&r.vertexAttribDivisor(e,t.divisor||0)}}function Mt(r,e){return function(t){if(t.value)if(r.disableVertexAttribArray(e),t.value.length===4)r.vertexAttrib4uiv(e,t.value);else throw new Error("The length of an unsigned integer constant value must be 4!");else r.bindBuffer(Ft,t.buffer),r.enableVertexAttribArray(e),r.vertexAttribIPointer(e,t.numComponents||t.size,t.type||Ir,t.stride||0,t.offset||0),r.vertexAttribDivisor&&r.vertexAttribDivisor(e,t.divisor||0)}}function Rr(r,e,t){const n=t.size,i=t.count;return function(s){r.bindBuffer(Ft,s.buffer);const o=s.size||s.numComponents||n,a=o/i,c=s.type||Pt,d=x[c].size*o,m=s.normalize||!1,p=s.offset||0,y=d/i;for(let l=0;l<i;++l)r.enableVertexAttribArray(e+l),r.vertexAttribPointer(e+l,a,c,m,d,p+y*l),r.vertexAttribDivisor&&r.vertexAttribDivisor(e+l,s.divisor||0)}}const I={};I[Pt]={size:4,setter:Dt},I[Vn]={size:8,setter:Dt},I[Hn]={size:12,setter:Dt},I[jn]={size:16,setter:Dt},I[Ar]={size:4,setter:se},I[Xn]={size:8,setter:se},I[Yn]={size:12,setter:se},I[Qn]={size:16,setter:se},I[Ir]={size:4,setter:Mt},I[ni]={size:8,setter:Mt},I[ii]={size:12,setter:Mt},I[si]={size:16,setter:Mt},I[qn]={size:4,setter:se},I[Kn]={size:8,setter:se},I[Jn]={size:12,setter:se},I[Zn]={size:16,setter:se},I[ei]={size:4,setter:Rr,count:2},I[ti]={size:9,setter:Rr,count:3},I[ri]={size:16,setter:Rr,count:4};const xu=/ERROR:\\s*\\d+:(\\d+)/gi;function _u(r,e="",t=0){const n=[...e.matchAll(xu)],i=new Map(n.map((s,o)=>{const a=parseInt(s[1]),c=n[o+1],u=c?c.index:e.length,d=e.substring(s.index,u);return[a-1,d]}));return r.split(`\n`).map((s,o)=>{const a=i.get(o);return`${o+1+t}: ${s}${a?`\n\n^^^ ${a}`:""}`}).join(`\n`)}const di=/^[ \\t]*\\n/;function hi(r){let e=0;return di.test(r)&&(e=1,r=r.replace(di,"")),{lineOffset:e,shaderSource:r}}function Eu(r,e){return r.errorCallback(e),r.callback&&setTimeout(()=>{r.callback(`${e}\n${r.errors.join(`\n`)}`)}),null}function wu(r,e,t,n){if(n=n||Tr,!r.getShaderParameter(t,Ec)){const s=r.getShaderInfoLog(t),{lineOffset:o,shaderSource:a}=hi(r.getShaderSource(t)),c=`${_u(a,s,o)}\nError compiling ${En(r,e)}: ${s}`;return n(c),c}return""}function Fr(r,e,t){let n,i,s;if(typeof e=="function"&&(t=e,e=void 0),typeof r=="function")t=r,r=void 0;else if(r&&!Array.isArray(r)){const u=r;t=u.errorCallback,r=u.attribLocations,n=u.transformFeedbackVaryings,i=u.transformFeedbackMode,s=u.callback}const o=t||Tr,a=[],c={errorCallback(u,...d){a.push(u),o(u,...d)},transformFeedbackVaryings:n,transformFeedbackMode:i,callback:s,errors:a};{let u={};Array.isArray(r)?r.forEach(function(d,m){u[d]=e?e[m]:m}):u=r||{},c.attribLocations=u}return c}const vu=["VERTEX_SHADER","FRAGMENT_SHADER"];function Tu(r,e){if(e.indexOf("frag")>=0)return vc;if(e.indexOf("vert")>=0)return Tc}function Au(r,e,t){const n=r.getAttachedShaders(e);for(const i of n)t.has(i)&&r.deleteShader(i);r.deleteProgram(e)}const Iu=(r=0)=>new Promise(e=>setTimeout(e,r));function Su(r,e,t){const n=r.createProgram(),{attribLocations:i,transformFeedbackVaryings:s,transformFeedbackMode:o}=Fr(t);for(let a=0;a<e.length;++a){let c=e[a];if(typeof c=="string"){const u=$n(c),d=u?u.text:c;let m=r[vu[a]];u&&u.type&&(m=Tu(r,u.type)||m),c=r.createShader(m),r.shaderSource(c,hi(d).shaderSource),r.compileShader(c),r.attachShader(n,c)}}Object.entries(i).forEach(([a,c])=>r.bindAttribLocation(n,c,a));{let a=s;a&&(a.attribs&&(a=a.attribs),Array.isArray(a)||(a=Object.keys(a)),r.transformFeedbackVaryings(n,a,o||Ac))}return r.linkProgram(n),n}function Ru(r,e,t,n,i){const s=Fr(t,n,i),o=new Set(e),a=Su(r,e,s);function c(u,d){const m=Pu(u,d,s.errorCallback);return m&&Au(u,d,o),m}if(s.callback){Fu(r,a).then(()=>{const u=c(r,a);s.callback(u,u?void 0:a)});return}return c(r,a)?void 0:a}async function Fu(r,e){const t=r.getExtension("KHR_parallel_shader_compile"),n=t?(s,o)=>s.getProgramParameter(o,t.COMPLETION_STATUS_KHR):()=>!0;let i=0;do await Iu(i),i=1e3/60;while(!n(r,e))}function Pu(r,e,t){if(t=t||Tr,!r.getProgramParameter(e,wc)){const i=r.getProgramInfoLog(e);t(`Error in program linking: ${i}`);const o=r.getAttachedShaders(e).map(a=>wu(r,r.getShaderParameter(a,r.SHADER_TYPE),a,t));return`${i}\n${o.filter(a=>a).join(`\n`)}`}}function ku(r,e,t,n,i){return Ru(r,e,t,n,i)}function mi(r){const e=r.name;return e.startsWith("gl_")||e.startsWith("webgl_")}const Cu=/(\\.|\\[|]|\\w+)/g,Bu=r=>r>="0"&&r<="9";function Du(r,e,t,n){const i=r.split(Cu).filter(a=>a!=="");let s=0,o="";for(;;){const a=i[s++];o+=a;const c=Bu(a[0]),u=c?parseInt(a):a;if(c&&(o+=i[s++]),s===i.length){t[u]=e;break}else{const m=i[s++],p=m==="[",y=t[u]||(p?[]:{});t[u]=y,t=y,n[o]=n[o]||(function(l){return function(b){pi(l,b)}})(y),o+=m}}}function Mu(r,e){let t=0;function n(a,c,u){const d=c.name.endsWith("[0]"),m=c.type,p=x[m];if(!p)throw new Error(`unknown type: 0x${m.toString(16)}`);let y;if(p.bindPoint){const l=t;t+=c.size,d?y=p.arraySetter(r,m,l,u,c.size):y=p.setter(r,m,l,u,c.size)}else p.arraySetter&&d?y=p.arraySetter(r,u):y=p.setter(r,u);return y.location=u,y}const i={},s={},o=r.getProgramParameter(e,Wn);for(let a=0;a<o;++a){const c=r.getActiveUniform(e,a);if(mi(c))continue;let u=c.name;u.endsWith("[0]")&&(u=u.substr(0,u.length-3));const d=r.getUniformLocation(e,c.name);if(d){const m=n(e,c,d);i[u]=m,Du(u,m,s,i)}}return i}function Ou(r,e){const t={},n=r.getProgramParameter(e,Sc);for(let i=0;i<n;++i){const s=r.getTransformFeedbackVarying(e,i);t[s.name]={index:i,type:s.type,size:s.size}}return t}function Uu(r,e){const t=r.getProgramParameter(e,Wn),n=[],i=[];for(let a=0;a<t;++a){i.push(a),n.push({});const c=r.getActiveUniform(e,a);n[a].name=c.name}[["UNIFORM_TYPE","type"],["UNIFORM_SIZE","size"],["UNIFORM_BLOCK_INDEX","blockNdx"],["UNIFORM_OFFSET","offset"]].forEach(function(a){const c=a[0],u=a[1];r.getActiveUniforms(e,i,r[c]).forEach(function(d,m){n[m][u]=d})});const s={},o=r.getProgramParameter(e,Rc);for(let a=0;a<o;++a){const c=r.getActiveUniformBlockName(e,a),u={index:r.getUniformBlockIndex(e,c),usedByVertexShader:r.getActiveUniformBlockParameter(e,a,Fc),usedByFragmentShader:r.getActiveUniformBlockParameter(e,a,Pc),size:r.getActiveUniformBlockParameter(e,a,kc),uniformIndices:r.getActiveUniformBlockParameter(e,a,Cc)};u.used=u.usedByVertexShader||u.usedByFragmentShader,s[c]=u}return{blockSpecs:s,uniformData:n}}function pi(r,e){for(const t in e){const n=r[t];typeof n=="function"?n(e[t]):pi(r[t],e[t])}}function gi(r,...e){const t=r.uniformSetters||r,n=e.length;for(let i=0;i<n;++i){const s=e[i];if(Array.isArray(s)){const o=s.length;for(let a=0;a<o;++a)gi(t,s[a])}else for(const o in s){const a=t[o];a&&a(s[o])}}}function Nu(r,e){const t={},n=r.getProgramParameter(e,Ic);for(let i=0;i<n;++i){const s=r.getActiveAttrib(e,i);if(mi(s))continue;const o=r.getAttribLocation(e,s.name),a=I[s.type],c=a.setter(r,o,a);c.location=o,t[s.name]=c}return t}function Lu(r,e){for(const t in e){const n=r[t];n&&n(e[t])}}function zu(r,e,t){t.vertexArrayObject?r.bindVertexArray(t.vertexArrayObject):(Lu(e.attribSetters||e,t.attribs),t.indices&&r.bindBuffer(_c,t.indices))}function yi(r,e){const t=Mu(r,e),n=Nu(r,e),i={program:e,uniformSetters:t,attribSetters:n};return Le(r)&&(i.uniformBlockSpec=Uu(r,e),i.transformFeedbackInfo=Ou(r,e)),i}const Gu=/\\s|{|}|;/;function $u(r,e,t,n,i){const s=Fr(t,n,i),o=[];if(e=e.map(function(u){if(!Gu.test(u)){const d=$n(u);if(d)u=d.text;else{const m=`no element with id: ${u}`;s.errorCallback(m),o.push(m)}}return u}),o.length)return Eu(s,"");const a=s.callback;a&&(s.callback=(u,d)=>{a(u,u?void 0:yi(r,d))});const c=ku(r,e,s);return c?yi(r,c):null}const Wu=4,bi=5123;function Vu(r,e,t,n,i,s){t=t===void 0?Wu:t;const o=e.indices,a=e.elementType,c=n===void 0?e.numElements:n;i=i===void 0?0:i,a||o?s!==void 0?r.drawElementsInstanced(t,c,a===void 0?bi:e.elementType,i,s):r.drawElements(t,c,a===void 0?bi:e.elementType,i):s!==void 0?r.drawArraysInstanced(t,i,c,s):r.drawArrays(t,i,c)}const xi=36160,Ot=36161,Hu=3553,ju=5121,Xu=6402,Yu=6408,Qu=33190,qu=36012,Ku=35056,Ju=36013,Zu=32854,ef=32855,tf=36194,_i=33189,Ei=6401,wi=36168,Pr=34041,kr=36064,Ut=36096,vi=36128,Cr=33306,Br=33071,Dr=9729,rf=[{format:Yu,type:ju,min:Dr,wrap:Br},{format:Pr}],G={};G[Pr]=Cr,G[Ei]=vi,G[wi]=vi,G[Xu]=Ut,G[_i]=Ut,G[Qu]=Ut,G[qu]=Ut,G[Ku]=Cr,G[Ju]=Cr;function nf(r,e){return G[r]||G[e]}const oe={};oe[Zu]=!0,oe[ef]=!0,oe[tf]=!0,oe[Pr]=!0,oe[_i]=!0,oe[Ei]=!0,oe[wi]=!0;function sf(r){return oe[r]}const of=32;function af(r){return r>=kr&&r<kr+of}function Ti(r,e,t,n){const i=xi,s=r.createFramebuffer();r.bindFramebuffer(i,s),t=t||r.drawingBufferWidth,n=n||r.drawingBufferHeight,e=e||rf;const o=[],a={framebuffer:s,attachments:[],width:t,height:n};return e.forEach(function(c,u){let d=c.attachment;const m=c.samples,p=c.format;let y=c.attachmentPoint||nf(p,c.internalFormat);if(y||(y=kr+u),af(y)&&o.push(y),!d)if(m!==void 0||sf(p))d=r.createRenderbuffer(),r.bindRenderbuffer(Ot,d),m>1?r.renderbufferStorageMultisample(Ot,m,p,t,n):r.renderbufferStorage(Ot,p,t,n);else{const l=Object.assign({},c);l.width=t,l.height=n,l.auto===void 0&&(l.auto=!1,l.min=l.min||l.minMag||Dr,l.mag=l.mag||l.minMag||Dr,l.wrapS=l.wrapS||l.wrap||Br,l.wrapT=l.wrapT||l.wrap||Br),d=Gn(r,l)}if(po(r,d))r.framebufferRenderbuffer(i,y,Ot,d);else if(fr(r,d))c.layer!==void 0?r.framebufferTextureLayer(i,y,d,c.level||0,c.layer):r.framebufferTexture2D(i,y,c.target||Hu,d,c.level||0);else throw new Error("unknown attachment type");a.attachments.push(d)}),r.drawBuffers&&r.drawBuffers(o),a}function cf(r,e,t){t=t||xi,e?(r.bindFramebuffer(t,e.framebuffer),r.viewport(0,0,e.width,e.height)):(r.bindFramebuffer(t,null),r.viewport(0,0,r.drawingBufferWidth,r.drawingBufferHeight))}function D(r,e){return()=>e instanceof WebGLTexture?e:Gn(r,{src:e,wrap:r.CLAMP_TO_EDGE})}const Ce=2;class je{constructor(e){this.id="_";const{context:t,width:n,height:i}=e;this.context=t,this.options=e;const s=this.buildDefines();this.programInfo=$u(this.context,[s+this.getVertexShader(),s+this.getFragmentShader()]),this.bufferInfo=Lo(this.context,this.getBuffers()),this.fbi=Ti(this.context,[{format:this.context.RGBA,type:this.context.UNSIGNED_BYTE,min:this.context.LINEAR,wrap:this.context.CLAMP_TO_EDGE}],n,i),this.output=this.fbi.attachments[0]}resizeOutput(e,t){this.fbi=Ti(this.context,[{format:this.context.RGBA,type:this.context.UNSIGNED_BYTE,min:this.context.LINEAR,wrap:this.context.CLAMP_TO_EDGE}],e,t),this.options.width=e,this.options.height=t,this.output=this.fbi.attachments[0]}getDefines(){return{}}getBuffers(){return{position:{numComponents:2,data:[-1,-1,-1,1,1,-1,1,1,-1,1,1,-1]},texture_coord:{numComponents:2,data:[0,0,0,1,1,0,1,1,0,1,1,0]}}}buildDefines(){let e="";const t=this.getDefines();for(let n in t)e+=`#define ${n} ${t[n].toFixed(1)}\n`;return e}run(e){this.profiler?.pushContext(`[${this.id}] PROG : ${this.constructor.name}`),this.profiler?.pushContext(`[${this.id}] UNIFORMS`);for(const i in e)typeof e[i]=="function"&&(this.profiler?.pushContext(`[${this.id}] UNI : ${i}`),e[i]=e[i](),this.profiler?.popContext(`[${this.id}] UNI : ${i}`));this.profiler?.popContext(`[${this.id}] UNIFORMS`);const t=Date.now();let n=0;this.lastRun&&(n=(t-this.lastRun)/1e3),this.lastRun=t,this.context.viewport(0,0,this.context.canvas.width,this.context.canvas.height),this.context.useProgram(this.programInfo.program),zu(this.context,this.programInfo,this.bufferInfo),gi(this.programInfo,{delta:n,canvas:[this.context.canvas.width,this.context.canvas.height],...e}),cf(this.context,this.options.disableFramebuffer?null:this.fbi),Vu(this.context,this.bufferInfo),this.profiler?.popContext(`[${this.id}] PROG : ${this.constructor.name}`)}setProfiler(e){this.profiler=e}}var uf=`precision mediump float;\n\nvarying vec2 _texture_coord;\n\nuniform sampler2D background;\nuniform sampler2D foreground;\nuniform sampler2D threshold;\n\nvoid main() {\n vec4 backgroundColor = texture2D(background, _texture_coord);\n vec4 foregroundColor = texture2D(foreground, _texture_coord);\n vec4 tresholdColor = texture2D(threshold, _texture_coord);\n gl_FragColor = foregroundColor * tresholdColor.a +\n backgroundColor * (1. - tresholdColor.a);\n}\n`,ff=`varying vec2 _texture_coord;\n\nattribute vec2 position;\nattribute vec2 texture_coord;\n\nvoid main() {\n gl_Position = vec4(position, 0., 1.);\n _texture_coord = texture_coord;\n _texture_coord.y = 1. - texture_coord.y;\n}\n`;class Mr extends je{getFragmentShader(){return uf}getVertexShader(){return ff}}class Or{constructor(){this.steps=[]}addStep(e){this.steps.push(e)}async run(){for(const e of this.steps)e.program.run(e.getUniforms())}resizeOutput(e,t){this.profiler?.pushContext(`PIP [${this.constructor.name}]`);for(const n of this.steps)n.preventResize||n.program.resizeOutput(e,t);this.profiler?.popContext(`PIP [${this.constructor.name}]`)}setProfiler(e){this.profiler=e;for(const t of this.steps)t.program.setProfiler(e)}setId(e){for(const t of this.steps)t.program.id=e}}class Ur extends Or{constructor(){super(...arguments),this.preciseMaskEnabled=!1}}class Ai extends Ur{constructor(e){super(),this.context=e,this.preciseMaskEnabled=!0;const t={context:e,height:e.canvas.height,width:e.canvas.width},n=new Mr({...t,disableFramebuffer:!0});this.addStep({program:n,getUniforms:()=>({background:D(e,this.inputBackgroundImage),foreground:D(e,this.inputImage),threshold:D(e,this.inputMask)})})}setData(e,t){this.inputImage=e,this.inputMask=t}}var lf=`precision mediump float;\n\nvarying vec2 _texture_coord;\nuniform sampler2D texture;\n\nvoid main() { gl_FragColor = texture2D(texture, _texture_coord); }\n`,df=`varying vec2 _texture_coord;\n\nattribute vec2 position;\nattribute vec2 texture_coord;\nuniform bool invert_y;\n\nvoid main() {\n gl_Position = vec4(position, 0., 1.);\n _texture_coord = texture_coord;\n if (invert_y) {\n _texture_coord.y = 1. - texture_coord.y;\n }\n}\n`;class hf extends je{getFragmentShader(){return lf}getVertexShader(){return df}}class mf extends Or{constructor(e,t,n){super(),this.context=e;const i={context:e,height:n,width:t};this.addStep({program:new hf({...i,disableFramebuffer:!0}),getUniforms:()=>({texture:D(e,this.inputImage),invert_y:!0})})}setData(e){this.inputImage=e}}async function Ii(r){return new Promise(e=>{setTimeout(()=>{e()},r)})}var pf=`precision mediump float;\n\nvarying vec2 _texture_coord;\n\nuniform vec2 canvas;\nuniform sampler2D texture;\n\nvec4 loop();\n\nvoid main() { gl_FragColor = loop(); }\n`,gf=`varying vec2 _texture_coord;\n\nattribute vec2 position;\nattribute vec2 texture_coord;\n\nvoid main() {\n gl_Position = vec4(position, 0., 1.);\n _texture_coord = texture_coord;\n}\n`,Nr=(r=>(r[r.LINEAR=0]="LINEAR",r[r.GAUSSIAN=1]="GAUSSIAN",r))(Nr||{});class Si extends je{getDefines(){return{RADIUS:this.options.radius??1}}getFragmentShader(){return pf+this.createLoopFunction()}getVertexShader(){return gf}createLoopFunction(){let e=this.options.radius??1;return`\n\n vec4 loop() { \n vec4 result = vec4(0,0,0,0);\n float factorSum = 0.;\n\n vec2 normalizedRadius = vec2(-${e}.) / canvas;\n vec2 normalizedIncrement = vec2(1.) / canvas;\n vec2 diff = normalizedRadius;\n\n for(int y=-${e}; y<${e+1}; ++y) {\n for(int x=-${e}; x<${e+1}; ++x) {\n float factor = 1.;\n result += factor * texture2D(texture, _texture_coord + diff);\n factorSum += factor;\n diff.x += normalizedIncrement.x;\n }\n diff.y += normalizedIncrement.y;\n diff.x = normalizedRadius.x;\n }\n return result / factorSum;\n }`}}var yf=`#version 300 es\n// https://github.com/Volcomix/virtual-background/blob/main/src/pipelines/webgl2/jointBilateralFilterStage.ts\n\nprecision highp float;\nuniform sampler2D input_frame;\nuniform sampler2D segmentation_mask;\nuniform sampler2D threshold;\nuniform vec2 texel_size;\nuniform float step;\nuniform float radius;\nuniform float offset;\nuniform float sigma_texel;\nuniform float sigma_color;\n\nin vec2 _texture_coord;\nout vec4 outColor;\n\nfloat gaussian(float x, float sigma) {\n float coeff = -0.5 / (sigma * sigma * 4.0 + 1.0e-6);\n return exp((x * x) * coeff);\n}\n\nvoid main() {\n vec2 centerCoord = _texture_coord;\n vec3 centerColor = texture(input_frame, centerCoord).rgb;\n float newVal = 0.0;\n float spaceWeight = 0.0;\n float colorWeight = 0.0;\n float totalWeight = 0.0;\n // Subsample kernel space.\n for (float i = -radius + offset; i <= radius; i += step) {\n for (float j = -radius + offset; j <= radius; j += step) {\n vec2 shift = vec2(j, i) * texel_size;\n vec2 coord = vec2(centerCoord + shift);\n vec3 frameColor = texture(input_frame, coord).rgb;\n float threshold = texture(threshold, coord).a;\n float outVal = texture(segmentation_mask, coord).a;\n\n spaceWeight = gaussian(distance(centerCoord, coord), sigma_texel);\n colorWeight = gaussian(distance(centerColor, frameColor), sigma_color);\n totalWeight += spaceWeight * colorWeight;\n newVal += spaceWeight * colorWeight * outVal * threshold;\n }\n }\n newVal /= totalWeight;\n outColor = vec4(vec3(0.), newVal);\n}`,bf=`#version 300 es\nin vec2 position;\nin vec2 texture_coord;\nout vec2 _texture_coord;\nvoid main() {\n gl_Position = vec4(position, 0.0, 1.0);\n _texture_coord = texture_coord;\n}`;class xf extends je{getFragmentShader(){return yf}getVertexShader(){return bf}}class _f extends Or{constructor(e,t,n){super(),this.context=e;const i={context:e,height:n,width:t},s=new Si({...i,radius:1,type:Nr.GAUSSIAN});this.jointBilateral=new xf(i),this.addStep({program:s,getUniforms:()=>({inputs:D(e,this.inputMask)})}),this.addStep({program:this.jointBilateral,getUniforms:()=>{const a=this.inputImage?.width??1,c=this.inputImage?.height??1;this.inputMask?.width,this.inputMask?.height;const u=3,d=Math.max(1,Math.sqrt(u)*.66),m=1/a,p=1/c;return{input_frame:D(e,this.inputImage),segmentation_mask:D(e,this.inputMask),texel_size:[m,p],step:d,radius:u,offset:d>1?d*.5:0,sigma_texel:Math.max(m,p)*u,sigma_color:u}}}),this.output=this.jointBilateral.output}setData(e,t){this.previousInputImage=this.inputImage?this.inputImage:e,this.previousInputMask=this.inputMask?this.inputMask:t,this.inputImage=e,this.inputMask=t}resizeOutput(e,t){super.resizeOutput(e,t),this.output=this.jointBilateral.output}}class Ef{constructor(e){this.queries=[],this.context=e,this.extension=e.getExtension("EXT_disjoint_timer_query_webgl2")}start(){}stop(){this.activeQuery&&this.context.endQuery(this.extension.TIME_ELAPSED_EXT)}pushContext(e){this.createQuery("PUSH",e)}popContext(e){this.createQuery("POP",e)}createQuery(e,t){this.activeQuery&&this.context.endQuery(this.extension.TIME_ELAPSED_EXT),this.activeQuery=this.context.createQuery(),this.context.beginQuery(this.extension.TIME_ELAPSED_EXT,this.activeQuery),this.queries.push({name:t,action:e,query:this.activeQuery})}async getResolvedQueries(){const e=(await Promise.all([...this.queries].map(t=>this.resolveQuery(t)))).filter(t=>t);for(let t=1;t<e.length;++t)e[t].timestamp+=e[t-1].duration+e[t-1].timestamp;return e}async resolveQuery(e){if(!await this.awaitQueryAvailable(e)){console.log("Unawaitable query",e);return}if(this.context.getParameter(this.extension.GPU_DISJOINT_EXT)){console.log("Disjointed query",e);return}return{...e,duration:this.context.getQueryParameter(e.query,this.context.QUERY_RESULT),timestamp:0}}async awaitQueryAvailable(e){for(let t=0;t<10;++t){if(this.context.getQueryParameter(e.query,this.context.QUERY_RESULT_AVAILABLE))return e;await Ii(200)}}}class Nt{constructor(){this.previousImageWidth=0,this.previousImageHeight=0,this.previousMaskWidth=Ce,this.previousMaskHeight=Ce,this.postProcessingEnabled=!0;const e=new OffscreenCanvas(0,0),t=e.getContext("webgl2");if(!t)throw"Fail to retrieve webgl2 context";this.canvas=e,this.context=t,this.improveMask=new _f(this.context,Ce,Ce)}enablePostProcessing(){this.postProcessingEnabled=!0}disablePostProcessing(){this.postProcessingEnabled=!1}async profileWebgl(e){const t=new Ef(this.context);return this.profiler=t,t.start(),await Ii(e),this.profiler=void 0,t.stop(),t.getResolvedQueries()}async render(e,t){if(!this.pipeline)throw"missing pipeline";(this.previousImageHeight!==e.height||this.previousImageWidth!==e.width)&&this.resizeOutput(e.width,e.height),(this.previousMaskHeight!==t.height||this.previousMaskWidth!==t.width)&&(this.improveMask.resizeOutput(t.width,t.height),this.previousMaskWidth=t.width,this.previousMaskHeight=t.height);const n="renderer";this.profiler?.pushContext(n),this.improveMask.setProfiler(this.profiler),this.pipeline.setProfiler(this.profiler);const i=await createImageBitmap(t);let s=i;return this.postProcessingEnabled&&(this.improveMask.setData(e,i),this.improveMask.run(),s=this.improveMask.output),this.pipeline.setData(e,s),await this.pipeline.run(),this.profiler?.popContext(n),this.canvas}resizeOutput(e,t){this.canvas.width=e,this.canvas.height=t,this.pipeline?.resizeOutput(e,t),this.previousImageWidth=e,this.previousImageHeight=t}destroy(){const e=this.context?.getExtension("WEBGL_lose_context");e&&e.loseContext()}}class Ri extends Nt{constructor(){super(),this.pipeline=new Ai(this.context);const e=new OffscreenCanvas(0,0),t=e.getContext("webgl2");if(!t)throw"Fail to retrieve webgl context";this.backgroundImageResizerCanvas=e,this.backgroundImageResizerContext=t,this.backgroundImageResizer=new mf(this.backgroundImageResizerContext,0,0)}setBackgroundImage(e){this.backgroundImage=e,this.updateBackgroundImage()}updateBackgroundImage(){const{width:e,height:t}=this.canvas;this.backgroundImageResizer.resizeOutput(e,t),this.backgroundImageResizer.setData(this.backgroundImage),this.backgroundImageResizer.run(),this.pipeline.inputBackgroundImage=this.backgroundImageResizerCanvas}resizeOutput(e,t){super.resizeOutput(e,t),this.backgroundImageResizerCanvas.width=e,this.backgroundImageResizerCanvas.height=t,this.backgroundImageResizer.resizeOutput(e,t),this.updateBackgroundImage()}destroy(){const e=this.backgroundImageResizerContext?.getExtension("WEBGL_lose_context");e&&e.loseContext(),super.destroy()}}class wf extends Ri{setBackgroundVideo(e){this.frameReader=e}async render(e,t){return await this.readNextVideoFrame(),super.render(e,t)}async readNextVideoFrame(){const e=await this.frameReader?.read();if(e?.value){const t=await createImageBitmap(e.value);this.setBackgroundImage(t),e.value.close()}}}class Fi{blurBackground(e){return new to(e)}blurSilhouette(e){return new ro(e)}imageBackground(){return new no}videoBackground(){return new wf}}var vf=`precision mediump float;\n\nvarying vec2 _texture_coord;\n\nuniform vec2 canvas;\nuniform sampler2D texture;\nuniform sampler2D mask;\n\nvec4 loop();\n\nvoid main() { gl_FragColor = loop(); }\n`,Tf=`varying vec2 _texture_coord;\n\nattribute vec2 position;\nattribute vec2 texture_coord;\n\nvoid main() {\n gl_Position = vec4(position, 0., 1.);\n _texture_coord = texture_coord;\n}\n`;class Af extends je{getDefines(){return{RADIUS:this.options.radius??1}}getFragmentShader(){return vf+this.createLoopFunction()}getVertexShader(){return Tf}createLoopFunction(){let e=this.options.radius??1;return`\n\n vec4 loop() { \n vec4 result = vec4(0,0,0,0);\n float factorSum = 0.;\n\n vec2 normalizedRadius = vec2(-${e}.) / canvas;\n vec2 normalizedIncrement = vec2(1.) / canvas;\n vec2 diff = normalizedRadius;\n float maxLength = length(normalizedRadius);\n\n for(int y=-${e}; y<${e+1}; ++y) {\n for(int x=-${e}; x<${e+1}; ++x) {\n float factor = (1.- texture2D(mask, _texture_coord + diff).a) * (maxLength - length(diff)) / maxLength;\n result += factor * texture2D(texture, _texture_coord + diff);\n factorSum += factor;\n diff.x += normalizedIncrement.x;\n }\n diff.y += normalizedIncrement.y;\n diff.x = normalizedRadius.x;\n }\n return result / factorSum;\n }`}}const If=10,Sf=2,Rf=8;class Ff extends Ur{constructor(e,t){super(),this.context=e,this.radius=t;const n={context:e,height:e.canvas.height,width:e.canvas.width};this.blur=new Af({...n,radius:t,...this.getBlurTextureSize(e.canvas.width,e.canvas.height)});const i=new Mr({...n,disableFramebuffer:!0});this.addStep({program:this.blur,preventResize:!0,getUniforms:()=>({texture:D(e,this.inputImage),mask:D(e,this.inputMask)})}),this.addStep({program:i,getUniforms:()=>({background:D(e,this.blur.output),foreground:D(e,this.inputImage),threshold:D(e,this.inputMask)})})}getBlurTextureSize(e,t){const n=this.radius>If?Rf:Sf;return{width:Math.max(Ce,e/n),height:Math.max(Ce,t/n)}}setData(e,t){this.inputImage=e,this.inputMask=t}resizeOutput(e,t){super.resizeOutput(e,t);const n=this.getBlurTextureSize(e,t);this.blur.resizeOutput(n.width,n.height)}}class Pf extends Nt{constructor(e){super(),this.pipeline=new Ff(this.context,e),this.disablePostProcessing()}}class kf extends Ur{constructor(e,t){super(),this.context=e;const n={context:e,height:e.canvas.height,width:e.canvas.width},i=new Si({...n,radius:t,type:Nr.GAUSSIAN}),s=new Mr({...n,disableFramebuffer:!0});this.addStep({program:i,getUniforms:()=>({texture:D(e,this.inputImage)})}),this.addStep({program:s,getUniforms:()=>({background:D(e,this.inputImage),foreground:D(e,i.output),threshold:D(e,this.inputMask)})})}setData(e,t){this.inputImage=e,this.inputMask=t}}class Cf extends Nt{constructor(e){super(),this.pipeline=new kf(this.context,e),this.disablePostProcessing()}}class Bf extends Ai{constructor(){super(...arguments),this.preciseMaskEnabled=!0}set reader(e){this.frameReader=e}async run(){this.frameReader&&(await this.readNextVideoFrame(),await super.run())}async readNextVideoFrame(){const e=await this.frameReader?.read();e?.value&&(this.inputBackgroundImage=await createImageBitmap(e.value),e.value.close())}}class Df extends Nt{constructor(){super(),this.pipeline=new Bf(this.context)}setBackgroundVideo(e){this.pipeline.reader=e}}class Pi{blurBackground(e){return new Pf(e)}blurSilhouette(e){return new Cf(e)}imageBackground(){return new Ri}videoBackground(){return new Df}}class Mf{constructor(e){switch(e){case gt.CANVAS:this.factory=new Fi;break;case gt.WEBGL:this.factory=new Pi;break;default:const t=eo();this.factory=t.supported?new Pi:new Fi}}blurBackground(e){return this.getFactory().blurBackground(e)}blurSilhouette(e){return this.getFactory().blurSilhouette(e)}imageBackground(){return this.getFactory().imageBackground()}videoBackground(){return this.getFactory().videoBackground()}getFactory(){if(!this.factory)throw"Factory is not initialized";return this.factory}}class Of{setBackgroundOptions(e){this.renderer&&this.renderer.destroy();const t=new Mf(e.renderingOptions?.type);switch(e.transformerType){case"BackgroundBlur":this.renderer=t.blurBackground(this.getBlurSize(e.radius));break;case"SilhouetteBlur":this.renderer=t.blurSilhouette(this.getBlurSize(e.radius));break;case"VideoBackground":const n=t.videoBackground();this.backgroundVideo&&n.setBackgroundVideo(this.backgroundVideo),this.renderer=n;break;case"VirtualBackground":const i=t.imageBackground();this.backgroundImage&&i.setBackgroundImage(this.backgroundImage),this.renderer=i;break;default:throw`Unknown rendering type [${e.transformerType}]`}e.renderingOptions?.type===gt.WEBGL&&(e.renderingOptions.selfieSegmentationType===tr.PRECISE?this.renderer.enablePostProcessing():e.renderingOptions.selfieSegmentationType===tr.FAST&&this.renderer.disablePostProcessing())}setVideoBGReadable(e){this.backgroundVideo=e.getReader();const t=this.renderer;t?.setBackgroundVideo&&t.setBackgroundVideo(this.backgroundVideo)}async setVirtualBGImage(e){const t=this.renderer;t?.setBackgroundImage&&t.setBackgroundImage(e),this.backgroundImage=e}async process(e,t){if(this.renderer)return this.renderer.render(e,t)}async resizeForeground(e,t){}getBlurSize(e=pt.Low){switch(e){case pt.Low:return 5;case pt.High:return 12}return e}async profile(e){return this.renderer?.profileWebgl(e)??[]}}var Uf=(function(){var r=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return(function(e){e=e||{};var t=typeof e<"u"?e:{},n,i;t.ready=new Promise(function(f,h){n=f,i=h});var s={},o;for(o in t)t.hasOwnProperty(o)&&(s[o]=t[o]);var a="./this.program",c=function(f,h){throw h},u=!0,d="";function m(f){return t.locateFile?t.locateFile(f,d):d+f}var p;typeof document<"u"&&document.currentScript&&(d=document.currentScript.src),r&&(d=r),d.indexOf("blob:")!==0?d=d.substr(0,d.replace(/[?#].*/,"").lastIndexOf("/")+1):d="";var y=t.print||console.log.bind(console),l=t.printErr||console.warn.bind(console);for(o in s)s.hasOwnProperty(o)&&(t[o]=s[o]);s=null,t.arguments&&t.arguments,t.thisProgram&&(a=t.thisProgram),t.quit&&(c=t.quit);var b;t.wasmBinary&&(b=t.wasmBinary),t.noExitRuntime,typeof WebAssembly!="object"&&ae("no native wasm support detected");var _,E=!1,R=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function k(f,h,g){for(var w=h+g,S=h;f[S]&&!(S>=w);)++S;if(S-h>16&&f.subarray&&R)return R.decode(f.subarray(h,S));for(var C="";h<S;){var v=f[h++];if(!(v&128)){C+=String.fromCharCode(v);continue}var M=f[h++]&63;if((v&224)==192){C+=String.fromCharCode((v&31)<<6|M);continue}var H=f[h++]&63;if((v&240)==224?v=(v&15)<<12|M<<6|H:v=(v&7)<<18|M<<12|H<<6|f[h++]&63,v<65536)C+=String.fromCharCode(v);else{var Li=v-65536;C+=String.fromCharCode(55296|Li>>10,56320|Li&1023)}}return C}function N(f,h){return f?k(Xe,f,h):""}function Q(f,h,g){for(var w=0;w<f.length;++w)Lt[h++>>0]=f.charCodeAt(w);Lt[h>>0]=0}function q(f,h){return f%h>0&&(f+=h-f%h),f}var L,Lt,Xe,$;function Ci(f){L=f,t.HEAP8=Lt=new Int8Array(f),t.HEAP16=new Int16Array(f),t.HEAP32=$=new Int32Array(f),t.HEAPU8=Xe=new Uint8Array(f),t.HEAPU16=new Uint16Array(f),t.HEAPU32=new Uint32Array(f),t.HEAPF32=new Float32Array(f),t.HEAPF64=new Float64Array(f)}t.INITIAL_MEMORY;var zr,Bi=[],Di=[],Mi=[];function Yf(){if(t.preRun)for(typeof t.preRun=="function"&&(t.preRun=[t.preRun]);t.preRun.length;)Kf(t.preRun.shift());Gr(Bi)}function Qf(){Gr(Di)}function qf(){if(t.postRun)for(typeof t.postRun=="function"&&(t.postRun=[t.postRun]);t.postRun.length;)Zf(t.postRun.shift());Gr(Mi)}function Kf(f){Bi.unshift(f)}function Jf(f){Di.unshift(f)}function Zf(f){Mi.unshift(f)}var be=0,Ye=null;function el(f){be++,t.monitorRunDependencies&&t.monitorRunDependencies(be)}function tl(f){if(be--,t.monitorRunDependencies&&t.monitorRunDependencies(be),be==0&&Ye){var h=Ye;Ye=null,h()}}t.preloadedImages={},t.preloadedAudios={};function ae(f){t.onAbort&&t.onAbort(f),f="Aborted("+f+")",l(f),E=!0,f+=". Build with -s ASSERTIONS=1 for more info.";var h=new WebAssembly.RuntimeError(f);throw i(h),h}var rl="data:application/octet-stream;base64,";function Oi(f){return f.startsWith(rl)}var W;W="tflite-simd.wasm",Oi(W)||(W=m(W));function Ui(f){try{if(f==W&&b)return new Uint8Array(b);if(!p)throw"both async and sync fetching of the wasm failed"}catch(h){ae(h)}}function nl(){return!b&&u&&typeof fetch=="function"?fetch(W,{credentials:"same-origin"}).then(function(f){if(!f.ok)throw"failed to load wasm binary file at \'"+W+"\'";return f.arrayBuffer()}).catch(function(){return Ui(W)}):Promise.resolve().then(function(){return Ui(W)})}function il(){var f={a:Al};function h(v,M){var H=v.exports;t.asm=H,_=t.asm.q,Ci(_.buffer),zr=t.asm.E,Jf(t.asm.r),tl()}el();function g(v){h(v.instance)}function w(v){return nl().then(function(M){return WebAssembly.instantiate(M,f)}).then(function(M){return M}).then(v,function(M){l("failed to asynchronously prepare wasm: "+M),ae(M)})}function S(){return!b&&typeof WebAssembly.instantiateStreaming=="function"&&!Oi(W)&&typeof fetch=="function"?fetch(W,{credentials:"same-origin"}).then(function(v){var M=WebAssembly.instantiateStreaming(v,f);return M.then(g,function(H){return l("wasm streaming compile failed: "+H),l("falling back to ArrayBuffer instantiation"),w(g)})}):w(g)}if(t.instantiateWasm)try{var C=t.instantiateWasm(f,h);return C}catch(v){return l("Module.instantiateWasm callback failed with error: "+v),!1}return S().catch(i),{}}function Gr(f){for(;f.length>0;){var h=f.shift();if(typeof h=="function"){h(t);continue}var g=h.func;typeof g=="number"?h.arg===void 0?zr.get(g)():zr.get(g)(h.arg):g(h.arg===void 0?null:h.arg)}}function sl(f,h,g,w){ae("Assertion failed: "+N(f)+", at: "+[h?N(h):"unknown filename",g,w?N(w):"unknown function"])}function ol(f,h){ae("To use dlopen, you need to use Emscripten\'s linking support, see https://github.com/emscripten-core/emscripten/wiki/Linking")}function al(f,h){ae("To use dlopen, you need to use Emscripten\'s linking support, see https://github.com/emscripten-core/emscripten/wiki/Linking")}function cl(){ae("")}var zt;zt=function(){return performance.now()};var ul=!0;function fl(f){return $[Ni()>>2]=f,f}function ll(f,h){var g;if(f===0)g=Date.now();else if((f===1||f===4)&&ul)g=zt();else return fl(28),-1;return $[h>>2]=g/1e3|0,$[h+4>>2]=g%1e3*1e3*1e3|0,0}function dl(){return 2147483648}function hl(f,h,g){Xe.copyWithin(f,h,h+g)}function ml(f){try{return _.grow(f-L.byteLength+65535>>>16),Ci(_.buffer),1}catch{}}function pl(f){var h=Xe.length;f=f>>>0;var g=2147483648;if(f>g)return!1;for(var w=1;w<=4;w*=2){var S=h*(1+.2/w);S=Math.min(S,f+100663296);var C=Math.min(g,q(Math.max(f,S),65536)),v=ml(C);if(v)return!0}return!1}function gl(f){for(var h=zt();zt()-h<f;);}var $r={};function yl(){return a||"./this.program"}function Qe(){if(!Qe.strings){var f=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",h={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:f,_:yl()};for(var g in $r)$r[g]===void 0?delete h[g]:h[g]=$r[g];var w=[];for(var g in h)w.push(g+"="+h[g]);Qe.strings=w}return Qe.strings}var Gt={mappings:{},buffers:[null,[],[]],printChar:function(f,h){var g=Gt.buffers[f];h===0||h===10?((f===1?y:l)(k(g,0)),g.length=0):g.push(h)},varargs:void 0,get:function(){Gt.varargs+=4;var f=$[Gt.varargs-4>>2];return f},getStr:function(f){var h=N(f);return h},get64:function(f,h){return f}};function bl(f,h){var g=0;return Qe().forEach(function(w,S){var C=h+g;$[f+S*4>>2]=C,Q(w,C),g+=w.length+1}),0}function xl(f,h){var g=Qe();$[f>>2]=g.length;var w=0;return g.forEach(function(S){w+=S.length+1}),$[h>>2]=w,0}function _l(f){Sl(f)}function El(f){return 0}function wl(f,h,g,w,S){}function vl(f,h,g,w){for(var S=0,C=0;C<g;C++){for(var v=$[h+C*8>>2],M=$[h+(C*8+4)>>2],H=0;H<M;H++)Gt.printChar(f,Xe[v+H]);S+=M}return $[w>>2]=S,0}function Tl(){if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function"){var f=new Uint8Array(1);return function(){return crypto.getRandomValues(f),f[0]}}else return function(){ae("randomDevice")}}function $t(f,h){$t.randomDevice||($t.randomDevice=Tl());for(var g=0;g<h;g++)Lt[f+g>>0]=$t.randomDevice();return 0}var Al={a:sl,e:ol,d:al,b:cl,n:ll,h:dl,l:hl,m:pl,p:gl,f:bl,g:xl,j:_l,i:El,k:wl,c:vl,o:$t};il(),t.___wasm_call_ctors=function(){return(t.___wasm_call_ctors=t.asm.r).apply(null,arguments)},t._getModelBufferMemoryOffset=function(){return(t._getModelBufferMemoryOffset=t.asm.s).apply(null,arguments)},t._getInputMemoryOffset=function(){return(t._getInputMemoryOffset=t.asm.t).apply(null,arguments)},t._getInputHeight=function(){return(t._getInputHeight=t.asm.u).apply(null,arguments)},t._getInputWidth=function(){return(t._getInputWidth=t.asm.v).apply(null,arguments)},t._getInputChannelCount=function(){return(t._getInputChannelCount=t.asm.w).apply(null,arguments)},t._getOutputMemoryOffset=function(){return(t._getOutputMemoryOffset=t.asm.x).apply(null,arguments)},t._getOutputHeight=function(){return(t._getOutputHeight=t.asm.y).apply(null,arguments)},t._getOutputWidth=function(){return(t._getOutputWidth=t.asm.z).apply(null,arguments)},t._getOutputChannelCount=function(){return(t._getOutputChannelCount=t.asm.A).apply(null,arguments)},t._loadModel=function(){return(t._loadModel=t.asm.B).apply(null,arguments)},t._runInference=function(){return(t._runInference=t.asm.C).apply(null,arguments)},t._isGPUEnabled=function(){return(t._isGPUEnabled=t.asm.D).apply(null,arguments)};var Ni=t.___errno_location=function(){return(Ni=t.___errno_location=t.asm.F).apply(null,arguments)},Wt;function Il(f){this.name="ExitStatus",this.message="Program terminated with exit("+f+")",this.status=f}Ye=function f(){Wt||Wr(),Wt||(Ye=f)};function Wr(f){if(be>0||(Yf(),be>0))return;function h(){Wt||(Wt=!0,t.calledRun=!0,!E&&(Qf(),n(t),t.onRuntimeInitialized&&t.onRuntimeInitialized(),qf()))}t.setStatus?(t.setStatus("Running..."),setTimeout(function(){setTimeout(function(){t.setStatus("")},1),h()},1)):h()}t.run=Wr;function Sl(f,h){Rl(f)}function Rl(f){c(f,new Il(f))}if(t.preInit)for(typeof t.preInit=="function"&&(t.preInit=[t.preInit]);t.preInit.length>0;)t.preInit.pop()();return Wr(),e.ready})})();class Nf{constructor(){this.isSIMDSupported=!1,this.isThreadsSupported=!1,this.inputWidth=0,this.inputHeight=0,this.inputChannelCount=0,this.inputMemoryOffset=0,this.outputWidth=0,this.outputHeight=0,this.outputChannelCount=0,this.outputMemoryOffset=0}}const Lf="https://d3opqjmqzxf057.cloudfront.net/vonage-tensorflow-wasm/tflite-simd-wasm/1.1.3/",zf="https://d3opqjmqzxf057.cloudfront.net/ml/selfie_segmentation/4.0.0/selfie_segmentation_landscape.tflite";async function Gf(r=Lf,e=zf){let t=new Nf;var n=new Promise(function(i,s){async function o(){return Uf({locateFile:function(u){return r+u}})}async function a(c){return new Promise(async(u,d)=>{const m=c;if(typeof m>"u")return d("TFLite backend unavailable: wasmSimd");let p=e;console.log("TFLite modelUrl: "+p);try{const l=await(await fetch(p)).arrayBuffer();console.log("Model buffer size:",l.byteLength);const b=m._getModelBufferMemoryOffset();console.log("Model buffer memory offset:",b),console.log("Loading model buffer..."),m.HEAPU8.set(new Uint8Array(l),b);const _=m._loadModel(l.byteLength);if(console.log("Load model result:",_),_!==0){d("Cannot load model");return}t.inputWidth=m._getInputWidth(),t.inputHeight=m._getInputHeight(),t.inputChannelCount=m._getInputChannelCount(),t.inputMemoryOffset=m._getInputMemoryOffset(),console.log("Input memory offset:",t.inputMemoryOffset),console.log("Input height:",t.inputHeight),console.log("Input width:",t.inputWidth),console.log("Input channels:",t.inputChannelCount),t.outputMemoryOffset=m._getOutputMemoryOffset(),t.outputWidth=m._getOutputWidth(),t.outputHeight=m._getOutputHeight(),t.outputChannelCount=m._getOutputChannelCount(),console.log("Output memory offset:",t.outputMemoryOffset),console.log("Output height:",t.outputHeight),console.log("Output width:",t.outputWidth),console.log("Output channels:",t.outputChannelCount),t.selectedTFLite=m}catch(y){d(y);return}u()})}o().then(c=>{if(c===null)throw console.error("loadTFLite null"),"loadTFLite null";a(c).then(u=>{i(t)}).catch(u=>{console.error("loadTFLiteModel error"),s("loadTFLiteModel error")})}).catch(c=>{console.error("loadTFLite error:",c),s("loadTFLite error:"+c)})});return n}const $f=.1,Wf=.7,Vf="https://d3opqjmqzxf057.cloudfront.net/ml/vonage_selfie_segmenter/float16/v1/vonage_selfie_segmenter.tflite";class Hf{constructor(){this.canvas=new OffscreenCanvas(0,0),this.context=this.canvas.getContext("2d",{willReadFrequently:!0}),this.width=0,this.height=0,this.gpuDelegate=!0}async createImageSegmenter(){if(!this.ImageSegmenter||!this.wasmFileset){console.warn("Mediapipe objects not loaded");return}this.imageSegmenter=await this.ImageSegmenter.createFromOptions(this.wasmFileset,{baseOptions:{modelAssetPath:this.modelAssetUriPath,delegate:this.gpuDelegate?"GPU":"CPU"},runningMode:"VIDEO",outputCategoryMask:!0,outputConfidenceMasks:!0})}async loadMediapipeAssets(e,t){this.modelAssetUriPath=e||Vf;const n=t?`${t}/task-vision.js`:"https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.20/+esm",i=t?`${t}/wasm`:"https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.20/wasm",{FilesetResolver:s,ImageSegmenter:o}=await import(n);this.ImageSegmenter=o,this.wasmFileset=await s.forVisionTasks(i)}async init(e,t,n){n===!1&&(this.gpuDelegate=!1),await this.loadMediapipeAssets(e,t),globalThis.document={},await this.createImageSegmenter()}async process(e){if(!this.imageSegmenter){console.warn("ImageSegmenter instance not available");return}(this.width!==e.width||this.height!==e.height)&&(this.canvas.width=this.width=e.width,this.canvas.height=this.height=e.height,this.mask&&(this.mask=new ImageData(this.width,this.height))),this.mask||(this.mask=new ImageData(this.width,this.height)),this.context.drawImage(e,0,0,e.width,e.height);const t=Date.now();let n;try{this.imageSegmenter?.segmentForVideo(this.context.getImageData(0,0,e.width,e.height),t,o=>{n=o.confidenceMasks?.[0]?.getAsFloat32Array()})}catch{await this.createImageSegmenter();return}if(!n)return;if(!this.previousConfidenceMask){this.previousConfidenceMask=n.slice();return}const i=n.map((o,a)=>{const c=this.previousConfidenceMask?.[a];return c!==void 0?this.blend(c,o):o}),s=[255,0,0];for(let o=0;o<i?.length;o++){const a=1-i[o];a>$f?(a<Wf?(this.mask.data[o*4]=s[0]*a,this.mask.data[o*4+3]=255*a):(this.mask.data[o*4]=s[0],this.mask.data[o*4+3]=255),this.mask.data[o*4+1]=s[1],this.mask.data[o*4+2]=s[2]):this.mask.data[o*4]=this.mask.data[o*4+1]=this.mask.data[o*4+2]=this.mask.data[o*4+3]=0}return this.previousConfidenceMask=i.slice(),this.mask}isGpuSupported(){return!0}blend(e,t){const i=-.748699,s=-57.8051,o=291.309,a=-624.717,c=t-.5,u=c*c,d=1-Math.min(1,u*(5.68842+u*(i+u*(s+u*(o+u*a)))));return t+(e-t)*(d*.9)}}class jf{constructor(){this.canvas=new OffscreenCanvas(0,0),this.context=this.canvas.getContext("2d",{willReadFrequently:!0}),this.pixelCount=0,this.inputOffset=0,this.outputOffset=0}async init(e,t,n){await this.initWasm(t,e),this.infos&&(this.canvas.width=this.infos.inputWidth,this.canvas.height=this.infos.inputHeight,this.pixelCount=this.infos.inputWidth*this.infos.inputHeight,this.mask=new ImageData(this.infos.inputWidth,this.infos.inputHeight),this.inputOffset=this.infos.inputMemoryOffset/4,this.outputOffset=this.infos.outputMemoryOffset/4)}async initWasm(e,t){this.infos=await Gf(e,t)}async process(e){if(!this.mask||!this.infos)return;const t=this.infos.inputWidth,n=this.infos.inputHeight;this.context.drawImage(e,0,0,e.width,e.height,0,0,t,n);const i=this.context.getImageData(0,0,t,n),s=this.infos.selectedTFLite.HEAPF32;for(let o=0;o<this.pixelCount;o++){const a=this.inputOffset+o*3;s[a]=i.data[o*4]/255,s[a+1]=i.data[o*4+1]/255,s[a+2]=i.data[o*4+2]/255}this.infos.selectedTFLite._runInference();for(let o=0;o<this.pixelCount;o++){const a=this.infos.selectedTFLite.HEAPF32[this.outputOffset+o];this.mask.data[o*4]=this.mask.data[o*4+3]=255*a}return this.mask}isGpuSupported(){return this.infos?.selectedTFLite?._isGPUEnabled()??!1}}class Xf{constructor(){this.reporter=new Js,this.isEnabled=!0,this.avoidOriginalTrackLeak=!1}async init(e,t){t.segmentationOptions?.lightWeightEngine===!0?this.selfieSegmentation=new jf:this.selfieSegmentation=new Hf,this.selfieSegmentation?.init(t.modelAssetUriPath,t.mediapipeBaseAssetsUri,t.segmentationOptions?.gpuSupport),this.avoidOriginalTrackLeak=t.avoidOriginalTrackLeak,this.backgroundFilter=new Of,this.report({variation:"Create"})}async transform(e,t){if(!this.isEnabled)return t.enqueue(e);let n;const i=e.timestamp??0,s=await createImageBitmap(e),o=await this.selfieSegmentation?.process(s);o&&(n=await this.backgroundFilter?.process(s,o)),!n&&this.avoidOriginalTrackLeak&&(n=new OffscreenCanvas(s.width,s.height)),n?(e.close(),t.enqueue(new VideoFrame(n,{timestamp:i,alpha:"discard"}))):t.enqueue(e)}async setBackgroundOptions(e){this.backgroundOptions=e,this.backgroundFilter?.setBackgroundOptions(e),this.report({variation:"Update"})}setVideoBGReadable(e){this.backgroundFilter?.setVideoBGReadable(e)}async setVirtualBGImage(e){await this.backgroundFilter?.setVirtualBGImage(e)}async profile(e){return this.backgroundFilter?.profile(e)??[]}getTransformerType(){return this.backgroundOptions?.transformerType??"Undefined"}enable(){this.isEnabled=!0}disable(){this.isEnabled=!1}report(e){this.reporter.send({version:Zs,action:"MlTransformers",transformerType:this.backgroundOptions?.transformerType,config:JSON.stringify(this.backgroundOptions),...e})}}const Lr=class Lr{constructor(){this.backgroundTransformer=new Xf,this.mediaProcessor=new Rs,this.rate=30,this.eventsQueue=[],this.frameTransformLatencyMs=[]}async init(e,t){this.frameTransformLatencyMs=[],await this.backgroundTransformer.init(e,t),await this.mediaProcessor.setTransformers([this.backgroundTransformer]),this.mediaProcessor.setTrackExpectedRate(this.rate),this.mediaProcessor.onAny((n,i)=>{this.resolveOnMediaProcessor?(this.resolveOnMediaProcessor({name:n,data:i}),this.resolveOnMediaProcessor=void 0):this.eventsQueue.push({name:n,data:i})})}enable(){this.backgroundTransformer.enable()}disable(){this.backgroundTransformer.disable()}async onMediaProcessorEvent(){return await new Promise(e=>{this.eventsQueue.length>0?e(this.eventsQueue.shift()):this.resolveOnMediaProcessor=e})}async setTrackExpectedRate(e){this.rate=e,this.mediaProcessor.setTrackExpectedRate(e)}async transform(e,t){let n=this.mediaProcessor.transform(e,t),i=performance.now();return this.frameTransformLatencyMs.push(performance.now()-i),n}async setBackgroundOptions(e){await this.backgroundTransformer?.setBackgroundOptions(e)}setVideoBGReadable(e){this.backgroundTransformer.setVideoBGReadable(e)}async setVirtualBGImage(e){await this.backgroundTransformer.setVirtualBGImage(e)}async terminate(){await this.mediaProcessor.destroy();const t=this.frameTransformLatencyMs.reduce((n,i)=>n+i,0)/this.frameTransformLatencyMs.length||0;console.log(`Transform latency average is: ${t} ms`)}setVonageMetadata(e){_s(e)}async profile(e){return JSON.stringify(await this.backgroundTransformer.profile(e))}};Vi("ProcessorWorker",Lr);let ki=Lr})();\n//# sourceMappingURL=processor-worker-DMoxEyvv.js.map\n', oi = typeof self < "u" && self.Blob && new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);", Eo], { type: "text/javascript;charset=utf-8" });
5180
5180
  function Fd(r) {
5181
5181
  let e;
5182
5182
  try {
5183
- if (e = ii && (self.URL || self.webkitURL).createObjectURL(ii), !e) throw "";
5183
+ if (e = oi && (self.URL || self.webkitURL).createObjectURL(oi), !e) throw "";
5184
5184
  const t = new Worker(e, {
5185
5185
  name: r?.name
5186
5186
  });
@@ -5189,7 +5189,7 @@ function Fd(r) {
5189
5189
  }), t;
5190
5190
  } catch {
5191
5191
  return new Worker(
5192
- "data:text/javascript;charset=utf-8," + encodeURIComponent(_o),
5192
+ "data:text/javascript;charset=utf-8," + encodeURIComponent(Eo),
5193
5193
  {
5194
5194
  name: r?.name
5195
5195
  }
@@ -5253,14 +5253,14 @@ const Jt = class Jt extends et {
5253
5253
  switch (t) {
5254
5254
  case "VideoBackground":
5255
5255
  await this.worker?.setVideoBGReadable(
5256
- await zn.createVideoReadable(
5256
+ await Nn.createVideoReadable(
5257
5257
  e.backgroundAssetUri
5258
5258
  )
5259
5259
  );
5260
5260
  break;
5261
5261
  case "VirtualBackground":
5262
5262
  await this.worker?.setVirtualBGImage(
5263
- await zn.createImageCanvas(
5263
+ await Nn.createImageCanvas(
5264
5264
  e.backgroundAssetUri
5265
5265
  )
5266
5266
  );
@@ -5293,7 +5293,7 @@ class Cd {
5293
5293
  t[c.name] === void 0 && (t[c.name] = e.length, e.push({
5294
5294
  name: c.name
5295
5295
  })), a.push({
5296
- type: c.action == xo.PUSH ? "O" : "C",
5296
+ type: c.action == vo.PUSH ? "O" : "C",
5297
5297
  frame: t[c.name],
5298
5298
  at: c.timestamp
5299
5299
  }), i = Math.max(i, c.timestamp + c.duration);
@@ -5322,7 +5322,7 @@ const gn = class gn extends et {
5322
5322
  * @internal
5323
5323
  */
5324
5324
  constructor(e) {
5325
- super(), this.worker = new Br(e), this.connector = new Ys(this.worker), this.worker.onAny(
5325
+ super(), this.worker = new Br(e), this.connector = new Qs(this.worker), this.worker.onAny(
5326
5326
  (t, n) => this.emit(t, n)
5327
5327
  );
5328
5328
  }
@@ -5396,16 +5396,16 @@ async function Dd(r) {
5396
5396
  }
5397
5397
  export {
5398
5398
  Pd as BackgroundTransformer,
5399
- Qs as BackgroundTransformerType,
5399
+ qs as BackgroundTransformerType,
5400
5400
  It as BlurRadius,
5401
- Us as ErrorFunction,
5401
+ Ls as ErrorFunction,
5402
5402
  Er as PipelineInfoData,
5403
5403
  Mt as RenderingType,
5404
5404
  Dr as VonageMediaProcessor,
5405
- Ds as WarningType,
5405
+ Us as WarningType,
5406
5406
  Ar as WebglSelfieSegmentationType,
5407
5407
  Dd as createVonageMediaProcessor,
5408
- Xs as getSupportedBrowserFeatures,
5408
+ Ks as getSupportedBrowserFeatures,
5409
5409
  Bd as isSupported
5410
5410
  };
5411
5411
  //# sourceMappingURL=ml-transformers.es.js.map