@vonage/ml-transformers 7.0.0-alpha.2 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/processor-worker-BCzl4yxZ.js.map +1 -0
- package/dist/ml-transformers.es.js +1041 -1031
- package/dist/ml-transformers.es.js.map +1 -1
- package/dist/ml-transformers.min.js +1 -1
- package/dist/ml-transformers.static.js +1041 -1031
- package/dist/ml-transformers.umd.js +21 -21
- package/dist/ml-transformers.umd.js.map +1 -1
- package/package.json +2 -2
- package/dist/assets/processor-worker-BKH_E7wA.js.map +0 -1
|
@@ -1,148 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
self.MediaStreamTrackProcessor || (self.MediaStreamTrackProcessor = (mr = class {
|
|
3
|
-
constructor(r) {
|
|
4
|
-
const e = r.track ?? r;
|
|
5
|
-
e.kind == "video" ? this.readable = new ReadableStream({
|
|
6
|
-
async start(t) {
|
|
7
|
-
e.addEventListener(
|
|
8
|
-
"ended",
|
|
9
|
-
() => t.close(),
|
|
10
|
-
{ once: !0 }
|
|
11
|
-
), this.video = document.createElement("video"), this.video.srcObject = new MediaStream([e]), await Promise.all([
|
|
12
|
-
this.video.play(),
|
|
13
|
-
new Promise(
|
|
14
|
-
(n) => this.video.onloadedmetadata = n
|
|
15
|
-
)
|
|
16
|
-
]), this.track = e, this.canvas = new OffscreenCanvas(
|
|
17
|
-
this.video.videoWidth,
|
|
18
|
-
this.video.videoHeight
|
|
19
|
-
), this.ctx = this.canvas.getContext("2d", {
|
|
20
|
-
desynchronized: !0
|
|
21
|
-
}), this.t1 = performance.now();
|
|
22
|
-
},
|
|
23
|
-
async pull(t) {
|
|
24
|
-
if (e.readyState == "ended")
|
|
25
|
-
return t.close();
|
|
26
|
-
const n = e.getSettings().frameRate || 30;
|
|
27
|
-
for (; performance.now() - this.t1 < 1e3 / n; )
|
|
28
|
-
if (await new Promise((i) => requestAnimationFrame(i)), e.readyState == "ended")
|
|
29
|
-
return t.close();
|
|
30
|
-
this.canvas.width = this.video.videoWidth, this.canvas.height = this.video.videoHeight, this.t1 = performance.now(), this.ctx.drawImage(this.video, 0, 0), t.enqueue(
|
|
31
|
-
new VideoFrame(this.canvas, {
|
|
32
|
-
timestamp: this.t1
|
|
33
|
-
})
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
}) : e.kind == "audio" && (this.readable = new ReadableStream({
|
|
37
|
-
async start(t) {
|
|
38
|
-
e.addEventListener(
|
|
39
|
-
"ended",
|
|
40
|
-
() => t.close(),
|
|
41
|
-
{ once: !0 }
|
|
42
|
-
), this.ac = new AudioContext(), this.arrays = [];
|
|
43
|
-
function n() {
|
|
44
|
-
registerProcessor(
|
|
45
|
-
"mstp-shim",
|
|
46
|
-
class extends AudioWorkletProcessor {
|
|
47
|
-
process(i) {
|
|
48
|
-
return this.port.postMessage(i), !0;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
await this.ac.audioWorklet.addModule(
|
|
54
|
-
`data:text/javascript,(${n.toString()})()`
|
|
55
|
-
), this.node = new AudioWorkletNode(this.ac, "mstp-shim"), this.ac.createMediaStreamSource(new MediaStream([e])).connect(this.node), this.node.port.addEventListener(
|
|
56
|
-
"message",
|
|
57
|
-
({ data: i }) => i[0][0] && this.arrays.push(i)
|
|
58
|
-
);
|
|
59
|
-
},
|
|
60
|
-
async pull(t) {
|
|
61
|
-
if (e.readyState == "ended")
|
|
62
|
-
return t.close();
|
|
63
|
-
for (; !this.arrays.length; )
|
|
64
|
-
if (await new Promise(
|
|
65
|
-
(o) => this.node.port.onmessage = o
|
|
66
|
-
), e.readyState == "ended")
|
|
67
|
-
return t.close();
|
|
68
|
-
const [n] = this.arrays.shift(), i = new Float32Array(
|
|
69
|
-
n.reduce((o, s) => o + s.length, 0)
|
|
70
|
-
);
|
|
71
|
-
n.reduce(
|
|
72
|
-
(o, s) => (i.set(s, o), o + s.length),
|
|
73
|
-
0
|
|
74
|
-
), t.enqueue(
|
|
75
|
-
new AudioData({
|
|
76
|
-
format: "f32-planar",
|
|
77
|
-
sampleRate: this.ac.sampleRate,
|
|
78
|
-
numberOfFrames: n[0].length,
|
|
79
|
-
numberOfChannels: n.length,
|
|
80
|
-
timestamp: this.ac.currentTime * 1e6 | 0,
|
|
81
|
-
data: i,
|
|
82
|
-
transfer: [i.buffer]
|
|
83
|
-
})
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
}));
|
|
87
|
-
}
|
|
88
|
-
}, mr.__POLYFILLED = !0, mr));
|
|
89
|
-
var pr;
|
|
90
|
-
self.MediaStreamTrackGenerator || (self.MediaStreamTrackGenerator = (pr = class {
|
|
91
|
-
constructor({ kind: r }) {
|
|
92
|
-
if (r == "video") {
|
|
93
|
-
const e = document.createElement("canvas"), t = e.getContext("2d", {
|
|
94
|
-
desynchronized: !0
|
|
95
|
-
}), n = e.captureStream().getVideoTracks()[0];
|
|
96
|
-
return n.writable = new WritableStream({
|
|
97
|
-
write(i) {
|
|
98
|
-
e.width = i.displayWidth, e.height = i.displayHeight, t.drawImage(i, 0, 0, e.width, e.height), i.close();
|
|
99
|
-
}
|
|
100
|
-
}), n;
|
|
101
|
-
} else if (r == "audio") {
|
|
102
|
-
const e = new AudioContext(), t = e.createMediaStreamDestination(), [n] = t.stream.getAudioTracks();
|
|
103
|
-
return n.writable = new WritableStream({
|
|
104
|
-
async start(i) {
|
|
105
|
-
this.arrays = [];
|
|
106
|
-
function o() {
|
|
107
|
-
registerProcessor(
|
|
108
|
-
"mstg-shim",
|
|
109
|
-
class extends AudioWorkletProcessor {
|
|
110
|
-
constructor() {
|
|
111
|
-
super(), this.arrays = [], this.arrayOffset = 0, this.port.onmessage = ({ data: s }) => this.arrays.push(s), this.emptyArray = new Float32Array(0);
|
|
112
|
-
}
|
|
113
|
-
process(s, [[a]]) {
|
|
114
|
-
for (let c = 0; c < a.length; c++)
|
|
115
|
-
(!this.array || this.arrayOffset >= this.array.length) && (this.array = this.arrays.shift() || this.emptyArray, this.arrayOffset = 0), a[c] = this.array[this.arrayOffset++] || 0;
|
|
116
|
-
return !0;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
);
|
|
120
|
-
}
|
|
121
|
-
return await e.audioWorklet.addModule(
|
|
122
|
-
`data:text/javascript,(${o.toString()})()`
|
|
123
|
-
), this.node = new AudioWorkletNode(e, "mstg-shim"), this.node.connect(t), n;
|
|
124
|
-
},
|
|
125
|
-
write(i) {
|
|
126
|
-
const o = new Float32Array(
|
|
127
|
-
i.numberOfFrames * i.numberOfChannels
|
|
128
|
-
);
|
|
129
|
-
i.copyTo(o, { planeIndex: 0 }), this.node.port.postMessage(o, [o.buffer]), i.close();
|
|
130
|
-
}
|
|
131
|
-
}), n;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}, pr.__POLYFILLED = !0, pr));
|
|
135
|
-
async function ss() {
|
|
1
|
+
async function is() {
|
|
136
2
|
return new Promise(async (r, e) => {
|
|
137
|
-
await
|
|
3
|
+
!ss() && (await si() || oi()) ? r() : e(
|
|
138
4
|
"Your browser does not support the MediaStreamTrack API for Insertable Streams of Media."
|
|
139
5
|
);
|
|
140
6
|
});
|
|
141
7
|
}
|
|
142
|
-
function
|
|
143
|
-
return self.MediaStreamTrackProcessor !== void 0 && self.MediaStreamTrackGenerator !== void 0
|
|
8
|
+
function oi() {
|
|
9
|
+
return self.MediaStreamTrackProcessor !== void 0 && self.MediaStreamTrackGenerator !== void 0 || os();
|
|
144
10
|
}
|
|
145
|
-
function
|
|
11
|
+
function os() {
|
|
146
12
|
return [
|
|
147
13
|
self.ReadableStream,
|
|
148
14
|
self.WritableStream,
|
|
@@ -153,7 +19,11 @@ function as() {
|
|
|
153
19
|
self.AudioWorkletNode
|
|
154
20
|
].filter((r) => r === void 0).length === 0;
|
|
155
21
|
}
|
|
156
|
-
function
|
|
22
|
+
function ss() {
|
|
23
|
+
const r = navigator.userAgent.toLowerCase();
|
|
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
|
+
}
|
|
26
|
+
function si() {
|
|
157
27
|
return new Promise((r) => {
|
|
158
28
|
function e() {
|
|
159
29
|
self.postMessage(
|
|
@@ -164,11 +34,11 @@ function ci() {
|
|
|
164
34
|
t.onmessage = ({ data: n }) => r(n);
|
|
165
35
|
});
|
|
166
36
|
}
|
|
167
|
-
const ee = /* @__PURE__ */ new WeakMap(), me = /* @__PURE__ */ new WeakMap(), q = /* @__PURE__ */ new WeakMap(),
|
|
168
|
-
let Ft = !1,
|
|
169
|
-
const
|
|
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");
|
|
38
|
+
let Ft = !1, mr = !1;
|
|
39
|
+
const Ct = (r) => typeof r == "string" || typeof r == "symbol" || typeof r == "number";
|
|
170
40
|
function Ae(r) {
|
|
171
|
-
if (!
|
|
41
|
+
if (!Ct(r))
|
|
172
42
|
throw new TypeError("`eventName` must be a string, symbol, or number");
|
|
173
43
|
}
|
|
174
44
|
function ft(r) {
|
|
@@ -181,22 +51,22 @@ function Te(r, e) {
|
|
|
181
51
|
return t.get(e);
|
|
182
52
|
}
|
|
183
53
|
function je(r, e) {
|
|
184
|
-
const t =
|
|
54
|
+
const t = Ct(e) ? e : Rt, n = q.get(r);
|
|
185
55
|
if (n.has(t))
|
|
186
56
|
return n.get(t);
|
|
187
57
|
}
|
|
188
|
-
function
|
|
58
|
+
function as(r, e, t) {
|
|
189
59
|
const n = q.get(r);
|
|
190
60
|
if (n.has(e))
|
|
191
61
|
for (const i of n.get(e))
|
|
192
62
|
i.enqueue(t);
|
|
193
|
-
if (n.has(
|
|
63
|
+
if (n.has(Rt)) {
|
|
194
64
|
const i = Promise.all([e, t]);
|
|
195
|
-
for (const o of n.get(
|
|
65
|
+
for (const o of n.get(Rt))
|
|
196
66
|
o.enqueue(i);
|
|
197
67
|
}
|
|
198
68
|
}
|
|
199
|
-
function
|
|
69
|
+
function Sn(r, e) {
|
|
200
70
|
e = Array.isArray(e) ? e : [e];
|
|
201
71
|
let t = !1, n = () => {
|
|
202
72
|
}, i = [];
|
|
@@ -234,17 +104,17 @@ function kn(r, e) {
|
|
|
234
104
|
}
|
|
235
105
|
};
|
|
236
106
|
}
|
|
237
|
-
function
|
|
107
|
+
function In(r) {
|
|
238
108
|
if (r === void 0)
|
|
239
|
-
return
|
|
109
|
+
return Rn;
|
|
240
110
|
if (!Array.isArray(r))
|
|
241
111
|
throw new TypeError("`methodNames` must be an array of strings");
|
|
242
112
|
for (const e of r)
|
|
243
|
-
if (!
|
|
113
|
+
if (!Rn.includes(e))
|
|
244
114
|
throw typeof e != "string" ? new TypeError("`methodNames` element must be a string") : new Error(`${e} is not Emittery method`);
|
|
245
115
|
return r;
|
|
246
116
|
}
|
|
247
|
-
const Me = (r) => r ===
|
|
117
|
+
const Me = (r) => r === kt || r === Pt;
|
|
248
118
|
function dt(r, e, t) {
|
|
249
119
|
if (Me(e))
|
|
250
120
|
try {
|
|
@@ -255,7 +125,7 @@ function dt(r, e, t) {
|
|
|
255
125
|
}
|
|
256
126
|
class J {
|
|
257
127
|
static mixin(e, t) {
|
|
258
|
-
return t =
|
|
128
|
+
return t = In(t), (n) => {
|
|
259
129
|
if (typeof n != "function")
|
|
260
130
|
throw new TypeError("`target` must be function");
|
|
261
131
|
for (const s of t)
|
|
@@ -284,15 +154,15 @@ class J {
|
|
|
284
154
|
}
|
|
285
155
|
static get isDebugEnabled() {
|
|
286
156
|
if (typeof globalThis.process?.env != "object")
|
|
287
|
-
return
|
|
157
|
+
return mr;
|
|
288
158
|
const { env: e } = globalThis.process ?? { env: {} };
|
|
289
|
-
return e.DEBUG === "emittery" || e.DEBUG === "*" ||
|
|
159
|
+
return e.DEBUG === "emittery" || e.DEBUG === "*" || mr;
|
|
290
160
|
}
|
|
291
161
|
static set isDebugEnabled(e) {
|
|
292
|
-
|
|
162
|
+
mr = e;
|
|
293
163
|
}
|
|
294
164
|
constructor(e = {}) {
|
|
295
|
-
ee.set(this, /* @__PURE__ */ new Set()), me.set(this, /* @__PURE__ */ new Map()), q.set(this, /* @__PURE__ */ new Map()), q.get(this).set(
|
|
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) => {
|
|
296
166
|
try {
|
|
297
167
|
o = JSON.stringify(o);
|
|
298
168
|
} catch {
|
|
@@ -312,7 +182,7 @@ class J {
|
|
|
312
182
|
for (const o of e) {
|
|
313
183
|
Ae(o);
|
|
314
184
|
let s = Te(this, o);
|
|
315
|
-
s || (s = /* @__PURE__ */ new Set(), me.get(this).set(o, s)), s.add(t), this.logIfDebugEnabled("subscribe", o, void 0), Me(o) || dt(this,
|
|
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 });
|
|
316
186
|
}
|
|
317
187
|
const i = () => {
|
|
318
188
|
this.off(e, t), n?.removeEventListener("abort", i);
|
|
@@ -342,14 +212,14 @@ class J {
|
|
|
342
212
|
e = Array.isArray(e) ? e : [e];
|
|
343
213
|
for (const t of e)
|
|
344
214
|
Ae(t);
|
|
345
|
-
return
|
|
215
|
+
return Sn(this, e);
|
|
346
216
|
}
|
|
347
217
|
async emit(e, t) {
|
|
348
218
|
if (Ae(e), Me(e) && !Ft)
|
|
349
219
|
throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");
|
|
350
|
-
this.logIfDebugEnabled("emit", e, t),
|
|
220
|
+
this.logIfDebugEnabled("emit", e, t), as(this, e, t);
|
|
351
221
|
const n = Te(this, e) ?? /* @__PURE__ */ new Set(), i = ee.get(this), o = [...n], s = Me(e) ? [] : [...i];
|
|
352
|
-
await
|
|
222
|
+
await Tn, await Promise.all([
|
|
353
223
|
...o.map(async (a) => {
|
|
354
224
|
if (n.has(a))
|
|
355
225
|
return a(t);
|
|
@@ -365,21 +235,21 @@ class J {
|
|
|
365
235
|
throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");
|
|
366
236
|
this.logIfDebugEnabled("emitSerial", e, t);
|
|
367
237
|
const n = Te(this, e) ?? /* @__PURE__ */ new Set(), i = ee.get(this), o = [...n], s = [...i];
|
|
368
|
-
await
|
|
238
|
+
await Tn;
|
|
369
239
|
for (const a of o)
|
|
370
240
|
n.has(a) && await a(t);
|
|
371
241
|
for (const a of s)
|
|
372
242
|
i.has(a) && await a(e, t);
|
|
373
243
|
}
|
|
374
244
|
onAny(e, { signal: t } = {}) {
|
|
375
|
-
ft(e), this.logIfDebugEnabled("subscribeAny", void 0, void 0), ee.get(this).add(e), dt(this,
|
|
245
|
+
ft(e), this.logIfDebugEnabled("subscribeAny", void 0, void 0), ee.get(this).add(e), dt(this, kt, { listener: e });
|
|
376
246
|
const n = () => {
|
|
377
247
|
this.offAny(e), t?.removeEventListener("abort", n);
|
|
378
248
|
};
|
|
379
249
|
return t?.addEventListener("abort", n, { once: !0 }), t?.aborted && n(), n;
|
|
380
250
|
}
|
|
381
251
|
anyEvent() {
|
|
382
|
-
return
|
|
252
|
+
return Sn(this);
|
|
383
253
|
}
|
|
384
254
|
offAny(e) {
|
|
385
255
|
ft(e), this.logIfDebugEnabled("unsubscribeAny", void 0, void 0), dt(this, Pt, { listener: e }), ee.get(this).delete(e);
|
|
@@ -387,7 +257,7 @@ class J {
|
|
|
387
257
|
clearListeners(e) {
|
|
388
258
|
e = Array.isArray(e) ? e : [e];
|
|
389
259
|
for (const t of e)
|
|
390
|
-
if (this.logIfDebugEnabled("clear", t, void 0),
|
|
260
|
+
if (this.logIfDebugEnabled("clear", t, void 0), Ct(t)) {
|
|
391
261
|
const n = Te(this, t);
|
|
392
262
|
n && n.clear();
|
|
393
263
|
const i = je(this, t);
|
|
@@ -411,7 +281,7 @@ class J {
|
|
|
411
281
|
e = Array.isArray(e) ? e : [e];
|
|
412
282
|
let t = 0;
|
|
413
283
|
for (const n of e) {
|
|
414
|
-
if (
|
|
284
|
+
if (Ct(n)) {
|
|
415
285
|
t += ee.get(this).size + (Te(this, n)?.size ?? 0) + (je(this, n)?.size ?? 0) + (je(this)?.size ?? 0);
|
|
416
286
|
continue;
|
|
417
287
|
}
|
|
@@ -426,7 +296,7 @@ class J {
|
|
|
426
296
|
bindMethods(e, t) {
|
|
427
297
|
if (typeof e != "object" || e === null)
|
|
428
298
|
throw new TypeError("`target` must be an object");
|
|
429
|
-
t =
|
|
299
|
+
t = In(t);
|
|
430
300
|
for (const n of t) {
|
|
431
301
|
if (e[n] !== void 0)
|
|
432
302
|
throw new Error(`The property \`${n}\` already exists on \`target\``);
|
|
@@ -437,9 +307,9 @@ class J {
|
|
|
437
307
|
}
|
|
438
308
|
}
|
|
439
309
|
}
|
|
440
|
-
const
|
|
310
|
+
const Rn = Object.getOwnPropertyNames(J.prototype).filter((r) => r !== "constructor");
|
|
441
311
|
Object.defineProperty(J, "listenerAdded", {
|
|
442
|
-
value:
|
|
312
|
+
value: kt,
|
|
443
313
|
writable: !1,
|
|
444
314
|
enumerable: !0,
|
|
445
315
|
configurable: !1
|
|
@@ -450,47 +320,47 @@ Object.defineProperty(J, "listenerRemoved", {
|
|
|
450
320
|
enumerable: !0,
|
|
451
321
|
configurable: !1
|
|
452
322
|
});
|
|
453
|
-
var
|
|
454
|
-
const
|
|
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;
|
|
455
325
|
let ht;
|
|
456
|
-
const
|
|
457
|
-
function
|
|
326
|
+
const ms = new Uint8Array(16);
|
|
327
|
+
function ps() {
|
|
458
328
|
if (!ht && (ht = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !ht))
|
|
459
329
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
460
|
-
return ht(
|
|
330
|
+
return ht(ms);
|
|
461
331
|
}
|
|
462
332
|
const F = [];
|
|
463
333
|
for (let r = 0; r < 256; ++r)
|
|
464
334
|
F.push((r + 256).toString(16).slice(1));
|
|
465
|
-
function
|
|
335
|
+
function gs(r, e = 0) {
|
|
466
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();
|
|
467
337
|
}
|
|
468
|
-
const
|
|
469
|
-
randomUUID:
|
|
338
|
+
const ys = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), kn = {
|
|
339
|
+
randomUUID: ys
|
|
470
340
|
};
|
|
471
|
-
function
|
|
472
|
-
if (
|
|
473
|
-
return
|
|
341
|
+
function bs(r, e, t) {
|
|
342
|
+
if (kn.randomUUID && !r)
|
|
343
|
+
return kn.randomUUID();
|
|
474
344
|
r = r || {};
|
|
475
|
-
const n = r.random || (r.rng ||
|
|
476
|
-
return n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128,
|
|
345
|
+
const n = r.random || (r.rng || ps)();
|
|
346
|
+
return n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128, gs(n);
|
|
477
347
|
}
|
|
478
|
-
function
|
|
348
|
+
function Ur(r, e) {
|
|
479
349
|
globalThis.vonage || (globalThis.vonage = {}), globalThis.vonage.workerizer || (globalThis.vonage.workerizer = {});
|
|
480
350
|
let t = globalThis.vonage.workerizer;
|
|
481
351
|
return t[r] || (t[r] = e), t[r];
|
|
482
352
|
}
|
|
483
|
-
const ie =
|
|
353
|
+
const ie = Ur(
|
|
484
354
|
"globals",
|
|
485
355
|
{}
|
|
486
356
|
);
|
|
487
357
|
var ye = /* @__PURE__ */ ((r) => (r.INIT = "INIT", r.FORWARD = "FORWARD", r.TERMINATE = "TERMINATE", r.GLOBALS_SYNC = "GLOBALS_SYNC", r))(ye || {});
|
|
488
|
-
function
|
|
358
|
+
function ai(r) {
|
|
489
359
|
return [ImageBitmap, ReadableStream, WritableStream].some((e) => r instanceof e);
|
|
490
360
|
}
|
|
491
|
-
let
|
|
492
|
-
function
|
|
493
|
-
const o =
|
|
361
|
+
let ws = 0;
|
|
362
|
+
function xs(r, e, t, n, i) {
|
|
363
|
+
const o = ws++;
|
|
494
364
|
return r.postMessage(
|
|
495
365
|
{
|
|
496
366
|
id: o,
|
|
@@ -498,7 +368,7 @@ function vs(r, e, t, n, i) {
|
|
|
498
368
|
functionName: t,
|
|
499
369
|
args: n
|
|
500
370
|
},
|
|
501
|
-
n.filter((s) =>
|
|
371
|
+
n.filter((s) => ai(s))
|
|
502
372
|
), new Promise((s) => {
|
|
503
373
|
i?.set(o, s);
|
|
504
374
|
});
|
|
@@ -511,22 +381,22 @@ function Ze(r, e) {
|
|
|
511
381
|
type: n,
|
|
512
382
|
result: e
|
|
513
383
|
},
|
|
514
|
-
i.filter((o) =>
|
|
384
|
+
i.filter((o) => ai(o))
|
|
515
385
|
);
|
|
516
386
|
}
|
|
517
|
-
const
|
|
518
|
-
function
|
|
387
|
+
const Pn = Ur("workerized", {});
|
|
388
|
+
function ci() {
|
|
519
389
|
return typeof WorkerGlobalScope < "u" && self instanceof WorkerGlobalScope;
|
|
520
390
|
}
|
|
521
|
-
async function
|
|
522
|
-
if (
|
|
391
|
+
async function vs() {
|
|
392
|
+
if (ci())
|
|
523
393
|
Ze({ type: ye.GLOBALS_SYNC }, ie);
|
|
524
394
|
else {
|
|
525
395
|
const r = [];
|
|
526
|
-
for (const e in
|
|
527
|
-
const { worker: t, resolvers: n } =
|
|
396
|
+
for (const e in Pn) {
|
|
397
|
+
const { worker: t, resolvers: n } = Pn[e].workerContext;
|
|
528
398
|
t && r.push(
|
|
529
|
-
|
|
399
|
+
xs(
|
|
530
400
|
t,
|
|
531
401
|
ye.GLOBALS_SYNC,
|
|
532
402
|
"",
|
|
@@ -538,16 +408,16 @@ async function _s() {
|
|
|
538
408
|
await Promise.all(r);
|
|
539
409
|
}
|
|
540
410
|
}
|
|
541
|
-
function
|
|
411
|
+
function Ot(r, e) {
|
|
542
412
|
if (Array.isArray(e))
|
|
543
413
|
e.splice(0, e.length);
|
|
544
414
|
else if (typeof e == "object")
|
|
545
415
|
for (const t in e)
|
|
546
416
|
delete e[t];
|
|
547
417
|
for (const t in r)
|
|
548
|
-
Array.isArray(r[t]) ? (e[t] = [],
|
|
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];
|
|
549
419
|
}
|
|
550
|
-
async function
|
|
420
|
+
async function _s(r, e) {
|
|
551
421
|
const { functionName: t, args: n } = r;
|
|
552
422
|
if (!e.instance)
|
|
553
423
|
throw "instance not initialized";
|
|
@@ -557,78 +427,78 @@ async function Es(r, e) {
|
|
|
557
427
|
throw `undefined function [${t}] in class ${e.instance.constructor.workerId}`;
|
|
558
428
|
Ze(r, await e.instance[t](...n ?? []));
|
|
559
429
|
}
|
|
560
|
-
const
|
|
561
|
-
function
|
|
430
|
+
const Es = Ur("registeredWorkers", {});
|
|
431
|
+
function As(r, e) {
|
|
562
432
|
if (!r.args)
|
|
563
433
|
throw "Missing className while initializing worker";
|
|
564
|
-
const [t, n] = r.args, i =
|
|
434
|
+
const [t, n] = r.args, i = Es[t];
|
|
565
435
|
if (i)
|
|
566
436
|
e.instance = new i(r.args.slice(1));
|
|
567
437
|
else
|
|
568
438
|
throw `unknown worker class ${t}`;
|
|
569
|
-
|
|
439
|
+
Ot(n, ie), Ze(r, typeof e.instance !== void 0);
|
|
570
440
|
}
|
|
571
|
-
async function
|
|
441
|
+
async function Ts(r, e) {
|
|
572
442
|
const { args: t } = r;
|
|
573
443
|
if (!e.instance)
|
|
574
444
|
throw "instance not initialized";
|
|
575
445
|
let n;
|
|
576
446
|
e.instance.terminate && (n = await e.instance.terminate(...t ?? [])), Ze(r, n);
|
|
577
447
|
}
|
|
578
|
-
function
|
|
448
|
+
function Ss(r) {
|
|
579
449
|
if (!r.args)
|
|
580
450
|
throw "Missing globals while syncing";
|
|
581
|
-
|
|
451
|
+
Ot(r.args[0], ie), Ze(r, {});
|
|
582
452
|
}
|
|
583
|
-
function
|
|
453
|
+
function Is() {
|
|
584
454
|
const r = {};
|
|
585
455
|
onmessage = async (e) => {
|
|
586
456
|
const t = e.data;
|
|
587
457
|
switch (t.type) {
|
|
588
458
|
case ye.INIT:
|
|
589
|
-
|
|
459
|
+
As(t, r);
|
|
590
460
|
break;
|
|
591
461
|
case ye.FORWARD:
|
|
592
|
-
|
|
462
|
+
_s(t, r);
|
|
593
463
|
break;
|
|
594
464
|
case ye.TERMINATE:
|
|
595
|
-
|
|
465
|
+
Ts(t, r);
|
|
596
466
|
break;
|
|
597
467
|
case ye.GLOBALS_SYNC:
|
|
598
|
-
|
|
468
|
+
Ss(t);
|
|
599
469
|
break;
|
|
600
470
|
}
|
|
601
471
|
};
|
|
602
472
|
}
|
|
603
|
-
|
|
473
|
+
ci() && Is();
|
|
604
474
|
function Rs(r, e) {
|
|
605
475
|
return ie[r] || (ie[r] = e), [
|
|
606
476
|
() => ie[r],
|
|
607
477
|
async (t) => {
|
|
608
|
-
ie[r] = t, await
|
|
478
|
+
ie[r] = t, await vs();
|
|
609
479
|
}
|
|
610
480
|
];
|
|
611
481
|
}
|
|
612
|
-
function
|
|
482
|
+
function ks(r, e) {
|
|
613
483
|
return Rs(r, e);
|
|
614
484
|
}
|
|
615
|
-
const [
|
|
485
|
+
const [Ps, Fs] = ks("metadata");
|
|
616
486
|
function Cs(r) {
|
|
617
|
-
|
|
487
|
+
Fs(r);
|
|
618
488
|
}
|
|
619
489
|
function Tt() {
|
|
620
|
-
return
|
|
490
|
+
return Ps();
|
|
621
491
|
}
|
|
622
|
-
let
|
|
492
|
+
let Lr = class {
|
|
623
493
|
constructor(e, t) {
|
|
624
|
-
|
|
494
|
+
ls(this, "uuid"), this.config = e, this.uuid = t ?? bs();
|
|
625
495
|
}
|
|
626
496
|
async send(e) {
|
|
627
497
|
var t, n, i;
|
|
628
498
|
const { appId: o, sourceType: s } = (t = Tt()) != null ? t : {};
|
|
629
499
|
if (!o || !s)
|
|
630
500
|
return "metadata missing";
|
|
631
|
-
const a = new AbortController(), c = setTimeout(() => a.abort(),
|
|
501
|
+
const a = new AbortController(), c = setTimeout(() => a.abort(), hs);
|
|
632
502
|
return await ((i = (n = this.config) == null ? void 0 : n.fetch) != null ? i : fetch)(this.getUrl(), {
|
|
633
503
|
method: "POST",
|
|
634
504
|
headers: this.getHeaders(),
|
|
@@ -638,8 +508,8 @@ let Nr = class {
|
|
|
638
508
|
}
|
|
639
509
|
getUrl() {
|
|
640
510
|
var e;
|
|
641
|
-
let t = (e = Tt().proxyUrl) != null ? e :
|
|
642
|
-
return t += (t.at(-1) === "/" ? "" : "/") +
|
|
511
|
+
let t = (e = Tt().proxyUrl) != null ? e : ds;
|
|
512
|
+
return t += (t.at(-1) === "/" ? "" : "/") + fs, t;
|
|
643
513
|
}
|
|
644
514
|
getHeaders() {
|
|
645
515
|
return {
|
|
@@ -658,12 +528,12 @@ let Nr = class {
|
|
|
658
528
|
};
|
|
659
529
|
}
|
|
660
530
|
};
|
|
661
|
-
const St = "3.0.
|
|
531
|
+
const St = "3.0.1", _r = class {
|
|
662
532
|
};
|
|
663
|
-
|
|
533
|
+
_r.updates = {
|
|
664
534
|
transformer_new: "New transformer",
|
|
665
535
|
transformer_null: "Null transformer"
|
|
666
|
-
},
|
|
536
|
+
}, _r.errors = {
|
|
667
537
|
transformer_none: "No transformers provided",
|
|
668
538
|
transformer_start: "Cannot start transformer",
|
|
669
539
|
transformer_transform: "Cannot transform frame",
|
|
@@ -671,24 +541,24 @@ Ar.updates = {
|
|
|
671
541
|
readable_null: "Readable is null",
|
|
672
542
|
writable_null: "Writable is null"
|
|
673
543
|
};
|
|
674
|
-
let be =
|
|
675
|
-
function
|
|
544
|
+
let be = _r;
|
|
545
|
+
function Os(r) {
|
|
676
546
|
return typeof r == "object" && r !== null && "message" in r && typeof r.message == "string";
|
|
677
547
|
}
|
|
678
|
-
function
|
|
679
|
-
if (
|
|
548
|
+
function Ms(r) {
|
|
549
|
+
if (Os(r)) return r;
|
|
680
550
|
try {
|
|
681
551
|
return new Error(JSON.stringify(r));
|
|
682
552
|
} catch {
|
|
683
553
|
return new Error(String(r));
|
|
684
554
|
}
|
|
685
555
|
}
|
|
686
|
-
function
|
|
687
|
-
return
|
|
556
|
+
function pr(r) {
|
|
557
|
+
return Ms(r).message;
|
|
688
558
|
}
|
|
689
|
-
class
|
|
559
|
+
class Bs {
|
|
690
560
|
constructor(e, t) {
|
|
691
|
-
this.config = e, this.frameTransformedCount = 0, this.frameFromSourceCount = 0, this.startAt = 0, this.reporter = new
|
|
561
|
+
this.config = e, this.frameTransformedCount = 0, this.frameFromSourceCount = 0, this.startAt = 0, this.reporter = new Lr(e, t);
|
|
692
562
|
}
|
|
693
563
|
async onFrameFromSource() {
|
|
694
564
|
this.frameFromSourceCount++;
|
|
@@ -710,12 +580,12 @@ class Ds {
|
|
|
710
580
|
})) : "success";
|
|
711
581
|
}
|
|
712
582
|
}
|
|
713
|
-
var
|
|
714
|
-
const
|
|
715
|
-
class
|
|
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 {
|
|
716
586
|
constructor(e, t) {
|
|
717
|
-
super(), this.reporter_ = new
|
|
718
|
-
loggingIntervalFrameCount:
|
|
587
|
+
super(), this.reporter_ = new Lr(), this.reporterQos_ = new Bs({
|
|
588
|
+
loggingIntervalFrameCount: Ls,
|
|
719
589
|
report: {
|
|
720
590
|
version: St
|
|
721
591
|
}
|
|
@@ -734,7 +604,7 @@ class $s extends J {
|
|
|
734
604
|
this.report({
|
|
735
605
|
message: be.errors.transformer_start,
|
|
736
606
|
variation: "Error",
|
|
737
|
-
error:
|
|
607
|
+
error: pr(t)
|
|
738
608
|
});
|
|
739
609
|
const n = {
|
|
740
610
|
eventMetaData: { transformerIndex: this.index_ },
|
|
@@ -756,7 +626,7 @@ class $s extends J {
|
|
|
756
626
|
this.report({
|
|
757
627
|
message: be.errors.transformer_transform,
|
|
758
628
|
variation: "Error",
|
|
759
|
-
error:
|
|
629
|
+
error: pr(n)
|
|
760
630
|
});
|
|
761
631
|
const i = {
|
|
762
632
|
eventMetaData: { transformerIndex: this.index_ },
|
|
@@ -766,7 +636,7 @@ class $s extends J {
|
|
|
766
636
|
};
|
|
767
637
|
this.emit("error", i);
|
|
768
638
|
}
|
|
769
|
-
if (this.trackExpectedRate_ != -1 && this.trackExpectedRate_ *
|
|
639
|
+
if (this.trackExpectedRate_ != -1 && this.trackExpectedRate_ * zs > this.reporterQos_.fps) {
|
|
770
640
|
const n = {
|
|
771
641
|
eventMetaData: {
|
|
772
642
|
transformerIndex: this.index_
|
|
@@ -790,7 +660,7 @@ class $s extends J {
|
|
|
790
660
|
this.report({
|
|
791
661
|
message: be.errors.transformer_flush,
|
|
792
662
|
variation: "Error",
|
|
793
|
-
error:
|
|
663
|
+
error: pr(t)
|
|
794
664
|
});
|
|
795
665
|
const n = {
|
|
796
666
|
eventMetaData: { transformerIndex: this.index_ },
|
|
@@ -831,11 +701,11 @@ class $s extends J {
|
|
|
831
701
|
);
|
|
832
702
|
}
|
|
833
703
|
}
|
|
834
|
-
class
|
|
704
|
+
class $s extends J {
|
|
835
705
|
constructor(e) {
|
|
836
706
|
super(), this.transformers_ = [], this.trackExpectedRate_ = -1;
|
|
837
707
|
for (let t = 0; t < e.length; t++) {
|
|
838
|
-
let n = new
|
|
708
|
+
let n = new Ns(e[t], t);
|
|
839
709
|
n.on("error", (i) => {
|
|
840
710
|
this.emit("error", i);
|
|
841
711
|
}), n.on("warn", (i) => {
|
|
@@ -901,9 +771,9 @@ class Ws extends J {
|
|
|
901
771
|
e.stop();
|
|
902
772
|
}
|
|
903
773
|
}
|
|
904
|
-
class
|
|
774
|
+
class ui extends J {
|
|
905
775
|
constructor() {
|
|
906
|
-
super(), this.reporter_ = new
|
|
776
|
+
super(), this.reporter_ = new Lr(), this.trackExpectedRate_ = -1, this.report({
|
|
907
777
|
variation: "Create"
|
|
908
778
|
});
|
|
909
779
|
}
|
|
@@ -959,12 +829,12 @@ class fi extends J {
|
|
|
959
829
|
return;
|
|
960
830
|
}
|
|
961
831
|
let n = !1;
|
|
962
|
-
this.pipeline_ && (n = !0, this.pipeline_.clearListeners(), this.pipeline_.destroy()), this.pipeline_ = new
|
|
832
|
+
this.pipeline_ && (n = !0, this.pipeline_.clearListeners(), this.pipeline_.destroy()), this.pipeline_ = new $s(this.transformers_), this.pipeline_.on("warn", (i) => {
|
|
963
833
|
this.emit("warn", i);
|
|
964
834
|
}), this.pipeline_.on("error", (i) => {
|
|
965
835
|
this.emit("error", i);
|
|
966
836
|
}), this.pipeline_.on("pipelineInfo", (i) => {
|
|
967
|
-
n && (i === "pipeline_started" ? i =
|
|
837
|
+
n && (i === "pipeline_started" ? i = Er.pipeline_restarted : i === "pipeline_started_with_error" && (i = Er.pipeline_restarted_with_error)), this.emit("pipelineInfo", i);
|
|
968
838
|
}), this.trackExpectedRate_ != -1 && this.pipeline_.setTrackExpectedRate(this.trackExpectedRate_), this.pipeline_.start(this.readable_, this.writable_).then(() => {
|
|
969
839
|
e();
|
|
970
840
|
}).catch((i) => {
|
|
@@ -1006,23 +876,163 @@ class fi extends J {
|
|
|
1006
876
|
return "kind" in e;
|
|
1007
877
|
}
|
|
1008
878
|
}
|
|
1009
|
-
class
|
|
879
|
+
class Ws {
|
|
880
|
+
constructor({ kind: e }) {
|
|
881
|
+
if (e == "video") {
|
|
882
|
+
const t = document.createElement("canvas"), n = t.getContext("2d", {
|
|
883
|
+
desynchronized: !0
|
|
884
|
+
}), i = t.captureStream().getVideoTracks()[0];
|
|
885
|
+
return i.writable = new WritableStream({
|
|
886
|
+
write(o) {
|
|
887
|
+
t.width = o.displayWidth, t.height = o.displayHeight, n.drawImage(o, 0, 0, t.width, t.height), o.close();
|
|
888
|
+
}
|
|
889
|
+
}), i;
|
|
890
|
+
} else if (e == "audio") {
|
|
891
|
+
const t = new AudioContext(), n = t.createMediaStreamDestination(), [i] = n.stream.getAudioTracks();
|
|
892
|
+
return i.writable = new WritableStream({
|
|
893
|
+
async start(o) {
|
|
894
|
+
this.arrays = [];
|
|
895
|
+
function s() {
|
|
896
|
+
registerProcessor(
|
|
897
|
+
"mstg-shim",
|
|
898
|
+
class extends AudioWorkletProcessor {
|
|
899
|
+
constructor() {
|
|
900
|
+
super(), this.arrays = [], this.arrayOffset = 0, this.port.onmessage = ({ data: a }) => this.arrays.push(a), this.emptyArray = new Float32Array(0);
|
|
901
|
+
}
|
|
902
|
+
process(a, [[c]]) {
|
|
903
|
+
for (let u = 0; u < c.length; u++)
|
|
904
|
+
(!this.array || this.arrayOffset >= this.array.length) && (this.array = this.arrays.shift() || this.emptyArray, this.arrayOffset = 0), c[u] = this.array[this.arrayOffset++] || 0;
|
|
905
|
+
return !0;
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
);
|
|
909
|
+
}
|
|
910
|
+
return await t.audioWorklet.addModule(
|
|
911
|
+
`data:text/javascript,(${s.toString()})()`
|
|
912
|
+
), this.node = new AudioWorkletNode(t, "mstg-shim"), this.node.connect(n), i;
|
|
913
|
+
},
|
|
914
|
+
write(o) {
|
|
915
|
+
const s = new Float32Array(
|
|
916
|
+
o.numberOfFrames * o.numberOfChannels
|
|
917
|
+
);
|
|
918
|
+
o.copyTo(s, { planeIndex: 0 }), this.node.port.postMessage(s, [s.buffer]), o.close();
|
|
919
|
+
}
|
|
920
|
+
}), i;
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
function Gs() {
|
|
925
|
+
return self.MediaStreamTrackGenerator ? self.MediaStreamTrackGenerator : Ws;
|
|
926
|
+
}
|
|
927
|
+
class Vs {
|
|
928
|
+
constructor(e) {
|
|
929
|
+
const t = e.track ?? e;
|
|
930
|
+
t.kind == "video" ? this.readable = new ReadableStream({
|
|
931
|
+
async start(n) {
|
|
932
|
+
t.addEventListener(
|
|
933
|
+
"ended",
|
|
934
|
+
() => n.close(),
|
|
935
|
+
{ once: !0 }
|
|
936
|
+
), this.video = document.createElement("video"), this.video.srcObject = new MediaStream([t]), await Promise.all([
|
|
937
|
+
this.video.play(),
|
|
938
|
+
new Promise(
|
|
939
|
+
(i) => this.video.onloadedmetadata = i
|
|
940
|
+
)
|
|
941
|
+
]), this.track = t, this.canvas = new OffscreenCanvas(
|
|
942
|
+
this.video.videoWidth,
|
|
943
|
+
this.video.videoHeight
|
|
944
|
+
), this.ctx = this.canvas.getContext("2d", {
|
|
945
|
+
desynchronized: !0
|
|
946
|
+
}), this.t1 = performance.now();
|
|
947
|
+
},
|
|
948
|
+
async pull(n) {
|
|
949
|
+
if (t.readyState == "ended")
|
|
950
|
+
return n.close();
|
|
951
|
+
const i = t.getSettings().frameRate || 30;
|
|
952
|
+
for (; performance.now() - this.t1 < 1e3 / i; )
|
|
953
|
+
if (await new Promise((o) => requestAnimationFrame(o)), t.readyState == "ended")
|
|
954
|
+
return n.close();
|
|
955
|
+
this.canvas.width = this.video.videoWidth, this.canvas.height = this.video.videoHeight, this.t1 = performance.now(), this.ctx.drawImage(this.video, 0, 0), n.enqueue(
|
|
956
|
+
new VideoFrame(this.canvas, {
|
|
957
|
+
timestamp: this.t1
|
|
958
|
+
})
|
|
959
|
+
);
|
|
960
|
+
}
|
|
961
|
+
}) : t.kind == "audio" && (this.readable = new ReadableStream({
|
|
962
|
+
async start(n) {
|
|
963
|
+
t.addEventListener(
|
|
964
|
+
"ended",
|
|
965
|
+
() => n.close(),
|
|
966
|
+
{ once: !0 }
|
|
967
|
+
), this.ac = new AudioContext(), this.arrays = [];
|
|
968
|
+
function i() {
|
|
969
|
+
registerProcessor(
|
|
970
|
+
"mstp-shim",
|
|
971
|
+
class extends AudioWorkletProcessor {
|
|
972
|
+
process(o) {
|
|
973
|
+
return this.port.postMessage(o), !0;
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
);
|
|
977
|
+
}
|
|
978
|
+
await this.ac.audioWorklet.addModule(
|
|
979
|
+
`data:text/javascript,(${i.toString()})()`
|
|
980
|
+
), this.node = new AudioWorkletNode(this.ac, "mstp-shim"), this.ac.createMediaStreamSource(new MediaStream([t])).connect(this.node), this.node.port.addEventListener(
|
|
981
|
+
"message",
|
|
982
|
+
({ data: o }) => o[0][0] && this.arrays.push(o)
|
|
983
|
+
);
|
|
984
|
+
},
|
|
985
|
+
async pull(n) {
|
|
986
|
+
if (t.readyState == "ended")
|
|
987
|
+
return n.close();
|
|
988
|
+
for (; !this.arrays.length; )
|
|
989
|
+
if (await new Promise(
|
|
990
|
+
(s) => this.node.port.onmessage = s
|
|
991
|
+
), t.readyState == "ended")
|
|
992
|
+
return n.close();
|
|
993
|
+
const [i] = this.arrays.shift(), o = new Float32Array(
|
|
994
|
+
i.reduce((s, a) => s + a.length, 0)
|
|
995
|
+
);
|
|
996
|
+
i.reduce(
|
|
997
|
+
(s, a) => (o.set(a, s), s + a.length),
|
|
998
|
+
0
|
|
999
|
+
), n.enqueue(
|
|
1000
|
+
new AudioData({
|
|
1001
|
+
format: "f32-planar",
|
|
1002
|
+
sampleRate: this.ac.sampleRate,
|
|
1003
|
+
numberOfFrames: i[0].length,
|
|
1004
|
+
numberOfChannels: i.length,
|
|
1005
|
+
timestamp: this.ac.currentTime * 1e6 | 0,
|
|
1006
|
+
data: o,
|
|
1007
|
+
transfer: [o.buffer]
|
|
1008
|
+
})
|
|
1009
|
+
);
|
|
1010
|
+
}
|
|
1011
|
+
}));
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
function Hs() {
|
|
1015
|
+
return self.MediaStreamTrackProcessor ? self.MediaStreamTrackProcessor : Vs;
|
|
1016
|
+
}
|
|
1017
|
+
class js {
|
|
1010
1018
|
constructor() {
|
|
1011
1019
|
this.processor_ = null, this.generator_ = null;
|
|
1012
1020
|
}
|
|
1013
1021
|
init(e) {
|
|
1014
1022
|
return new Promise((t, n) => {
|
|
1015
1023
|
try {
|
|
1016
|
-
|
|
1024
|
+
const i = Hs();
|
|
1025
|
+
this.processor_ = new i(e);
|
|
1017
1026
|
} catch (i) {
|
|
1018
1027
|
console.log(
|
|
1019
1028
|
`[InsertableStreamHelper] MediaStreamTrackProcessor failed: ${i}`
|
|
1020
1029
|
), n(i);
|
|
1021
1030
|
}
|
|
1022
1031
|
try {
|
|
1023
|
-
|
|
1032
|
+
const i = Gs();
|
|
1033
|
+
e.kind === "audio" ? this.generator_ = new i({
|
|
1024
1034
|
kind: "audio"
|
|
1025
|
-
}) : e.kind === "video" ? this.generator_ = new
|
|
1035
|
+
}) : e.kind === "video" ? this.generator_ = new i({
|
|
1026
1036
|
kind: "video"
|
|
1027
1037
|
}) : n("kind not supported");
|
|
1028
1038
|
} catch (i) {
|
|
@@ -1043,7 +1053,7 @@ class Gs {
|
|
|
1043
1053
|
return this.generator_;
|
|
1044
1054
|
}
|
|
1045
1055
|
}
|
|
1046
|
-
class
|
|
1056
|
+
class Ys {
|
|
1047
1057
|
/**
|
|
1048
1058
|
* - When running insertable streams on the main `MediaProcessorInterface` should be instance of `MediaProcessor` class.
|
|
1049
1059
|
* - 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)
|
|
@@ -1060,13 +1070,13 @@ class Vs {
|
|
|
1060
1070
|
* @returns New track to be used.
|
|
1061
1071
|
*/
|
|
1062
1072
|
async setTrack(e) {
|
|
1063
|
-
if (!(this.mediaProcessor_ instanceof
|
|
1073
|
+
if (!(this.mediaProcessor_ instanceof ui) && await si()) {
|
|
1064
1074
|
if (e.kind === "audio")
|
|
1065
1075
|
throw Error("Cannot process audio tracks inside a web worker when passing a track to transform");
|
|
1066
1076
|
return await this.mediaProcessor_.transform(e);
|
|
1067
1077
|
}
|
|
1068
|
-
if (
|
|
1069
|
-
const t = new
|
|
1078
|
+
if (oi()) {
|
|
1079
|
+
const t = new js();
|
|
1070
1080
|
return await t.init(e), await this.mediaProcessor_.transform(
|
|
1071
1081
|
t.getReadable(),
|
|
1072
1082
|
t.getWriteable()
|
|
@@ -1087,10 +1097,10 @@ class Vs {
|
|
|
1087
1097
|
});
|
|
1088
1098
|
}
|
|
1089
1099
|
}
|
|
1090
|
-
var It = /* @__PURE__ */ ((r) => (r.Low = "Low", r.High = "High", r))(It || {}),
|
|
1091
|
-
const
|
|
1092
|
-
async function
|
|
1093
|
-
const { wasm: r, insertableStreams: e, simd: t, webgl: n } = await
|
|
1100
|
+
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 || {});
|
|
1101
|
+
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]));
|
|
1102
|
+
async function Bd() {
|
|
1103
|
+
const { wasm: r, insertableStreams: e, simd: t, webgl: n } = await Xs();
|
|
1094
1104
|
if (!r.supported)
|
|
1095
1105
|
throw r.message;
|
|
1096
1106
|
if (!e.supported)
|
|
@@ -1100,14 +1110,14 @@ async function Od() {
|
|
|
1100
1110
|
if (!n.supported)
|
|
1101
1111
|
throw n.message;
|
|
1102
1112
|
}
|
|
1103
|
-
async function
|
|
1113
|
+
async function Xs() {
|
|
1104
1114
|
const r = {
|
|
1105
1115
|
wasm: {
|
|
1106
1116
|
supported: typeof WebAssembly == "object" && typeof WebAssembly.instantiate == "function",
|
|
1107
1117
|
message: "Your browser does not support WebAssembly features."
|
|
1108
1118
|
},
|
|
1109
1119
|
simd: {
|
|
1110
|
-
supported: await
|
|
1120
|
+
supported: await qs(),
|
|
1111
1121
|
message: "Your browser does not support simd features."
|
|
1112
1122
|
},
|
|
1113
1123
|
insertableStreams: { supported: !0 },
|
|
@@ -1116,17 +1126,17 @@ async function Ys() {
|
|
|
1116
1126
|
supported: !0
|
|
1117
1127
|
// This is a legacy check from the previous segmentation engine. now we just return true always
|
|
1118
1128
|
},
|
|
1119
|
-
webgl:
|
|
1120
|
-
performance:
|
|
1129
|
+
webgl: Ks(),
|
|
1130
|
+
performance: li()
|
|
1121
1131
|
};
|
|
1122
1132
|
try {
|
|
1123
|
-
await
|
|
1133
|
+
await is();
|
|
1124
1134
|
} catch (e) {
|
|
1125
1135
|
r.insertableStreams.supported = !1, r.insertableStreams.message = e;
|
|
1126
1136
|
}
|
|
1127
1137
|
return r;
|
|
1128
1138
|
}
|
|
1129
|
-
function
|
|
1139
|
+
function Ks() {
|
|
1130
1140
|
if (!OffscreenCanvas)
|
|
1131
1141
|
return {
|
|
1132
1142
|
supported: !1,
|
|
@@ -1143,7 +1153,7 @@ function Qs() {
|
|
|
1143
1153
|
};
|
|
1144
1154
|
return { supported: !0 };
|
|
1145
1155
|
}
|
|
1146
|
-
function
|
|
1156
|
+
function li() {
|
|
1147
1157
|
const e = new OffscreenCanvas(0, 0).getContext("webgl2", {
|
|
1148
1158
|
failIfMajorPerformanceCaveat: !0
|
|
1149
1159
|
});
|
|
@@ -1157,8 +1167,8 @@ function di() {
|
|
|
1157
1167
|
};
|
|
1158
1168
|
return { supported: !0 };
|
|
1159
1169
|
}
|
|
1160
|
-
const te = /* @__PURE__ */ new WeakMap(), pe = /* @__PURE__ */ new WeakMap(), X = /* @__PURE__ */ new WeakMap(), Bt = /* @__PURE__ */ Symbol("anyProducer"),
|
|
1161
|
-
let Lt = !1,
|
|
1170
|
+
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");
|
|
1171
|
+
let Lt = !1, gr = !1;
|
|
1162
1172
|
const zt = (r) => typeof r == "string" || typeof r == "symbol" || typeof r == "number";
|
|
1163
1173
|
function Se(r) {
|
|
1164
1174
|
if (!zt(r))
|
|
@@ -1178,7 +1188,7 @@ function Ye(r, e) {
|
|
|
1178
1188
|
if (n.has(t))
|
|
1179
1189
|
return n.get(t);
|
|
1180
1190
|
}
|
|
1181
|
-
function
|
|
1191
|
+
function Js(r, e, t) {
|
|
1182
1192
|
const n = X.get(r);
|
|
1183
1193
|
if (n.has(e))
|
|
1184
1194
|
for (const i of n.get(e))
|
|
@@ -1189,7 +1199,7 @@ function qs(r, e, t) {
|
|
|
1189
1199
|
o.enqueue(i);
|
|
1190
1200
|
}
|
|
1191
1201
|
}
|
|
1192
|
-
function
|
|
1202
|
+
function Cn(r, e) {
|
|
1193
1203
|
e = Array.isArray(e) ? e : [e];
|
|
1194
1204
|
let t = !1, n = () => {
|
|
1195
1205
|
}, i = [];
|
|
@@ -1227,13 +1237,13 @@ function Mn(r, e) {
|
|
|
1227
1237
|
}
|
|
1228
1238
|
};
|
|
1229
1239
|
}
|
|
1230
|
-
function
|
|
1240
|
+
function On(r) {
|
|
1231
1241
|
if (r === void 0)
|
|
1232
|
-
return
|
|
1242
|
+
return Mn;
|
|
1233
1243
|
if (!Array.isArray(r))
|
|
1234
1244
|
throw new TypeError("`methodNames` must be an array of strings");
|
|
1235
1245
|
for (const e of r)
|
|
1236
|
-
if (!
|
|
1246
|
+
if (!Mn.includes(e))
|
|
1237
1247
|
throw typeof e != "string" ? new TypeError("`methodNames` element must be a string") : new Error(`${e} is not Emittery method`);
|
|
1238
1248
|
return r;
|
|
1239
1249
|
}
|
|
@@ -1246,9 +1256,9 @@ function pt(r, e, t) {
|
|
|
1246
1256
|
Lt = !1;
|
|
1247
1257
|
}
|
|
1248
1258
|
}
|
|
1249
|
-
let et = class
|
|
1259
|
+
let et = class Tr {
|
|
1250
1260
|
static mixin(e, t) {
|
|
1251
|
-
return t =
|
|
1261
|
+
return t = On(t), (n) => {
|
|
1252
1262
|
if (typeof n != "function")
|
|
1253
1263
|
throw new TypeError("`target` must be function");
|
|
1254
1264
|
for (const s of t)
|
|
@@ -1257,7 +1267,7 @@ let et = class Ir {
|
|
|
1257
1267
|
function i() {
|
|
1258
1268
|
return Object.defineProperty(this, e, {
|
|
1259
1269
|
enumerable: !1,
|
|
1260
|
-
value: new
|
|
1270
|
+
value: new Tr()
|
|
1261
1271
|
}), this[e];
|
|
1262
1272
|
}
|
|
1263
1273
|
Object.defineProperty(n.prototype, e, {
|
|
@@ -1277,12 +1287,12 @@ let et = class Ir {
|
|
|
1277
1287
|
}
|
|
1278
1288
|
static get isDebugEnabled() {
|
|
1279
1289
|
if (typeof globalThis.process?.env != "object")
|
|
1280
|
-
return
|
|
1290
|
+
return gr;
|
|
1281
1291
|
const { env: e } = globalThis.process ?? { env: {} };
|
|
1282
|
-
return e.DEBUG === "emittery" || e.DEBUG === "*" ||
|
|
1292
|
+
return e.DEBUG === "emittery" || e.DEBUG === "*" || gr;
|
|
1283
1293
|
}
|
|
1284
1294
|
static set isDebugEnabled(e) {
|
|
1285
|
-
|
|
1295
|
+
gr = e;
|
|
1286
1296
|
}
|
|
1287
1297
|
constructor(e = {}) {
|
|
1288
1298
|
te.set(this, /* @__PURE__ */ new Set()), pe.set(this, /* @__PURE__ */ new Map()), X.set(this, /* @__PURE__ */ new Map()), X.get(this).set(Bt, /* @__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) => {
|
|
@@ -1298,7 +1308,7 @@ let et = class Ir {
|
|
|
1298
1308
|
});
|
|
1299
1309
|
}
|
|
1300
1310
|
logIfDebugEnabled(e, t, n) {
|
|
1301
|
-
(
|
|
1311
|
+
(Tr.isDebugEnabled || this.debug.enabled) && this.debug.logger(e, this.debug.name, t, n);
|
|
1302
1312
|
}
|
|
1303
1313
|
on(e, t, { signal: n } = {}) {
|
|
1304
1314
|
mt(t), e = Array.isArray(e) ? e : [e];
|
|
@@ -1335,14 +1345,14 @@ let et = class Ir {
|
|
|
1335
1345
|
e = Array.isArray(e) ? e : [e];
|
|
1336
1346
|
for (const t of e)
|
|
1337
1347
|
Se(t);
|
|
1338
|
-
return
|
|
1348
|
+
return Cn(this, e);
|
|
1339
1349
|
}
|
|
1340
1350
|
async emit(e, t) {
|
|
1341
1351
|
if (Se(e), Be(e) && !Lt)
|
|
1342
1352
|
throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");
|
|
1343
|
-
this.logIfDebugEnabled("emit", e, t),
|
|
1353
|
+
this.logIfDebugEnabled("emit", e, t), Js(this, e, t);
|
|
1344
1354
|
const n = Ie(this, e) ?? /* @__PURE__ */ new Set(), i = te.get(this), o = [...n], s = Be(e) ? [] : [...i];
|
|
1345
|
-
await
|
|
1355
|
+
await Fn, await Promise.all([
|
|
1346
1356
|
...o.map(async (a) => {
|
|
1347
1357
|
if (n.has(a))
|
|
1348
1358
|
return a(t);
|
|
@@ -1358,7 +1368,7 @@ let et = class Ir {
|
|
|
1358
1368
|
throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");
|
|
1359
1369
|
this.logIfDebugEnabled("emitSerial", e, t);
|
|
1360
1370
|
const n = Ie(this, e) ?? /* @__PURE__ */ new Set(), i = te.get(this), o = [...n], s = [...i];
|
|
1361
|
-
await
|
|
1371
|
+
await Fn;
|
|
1362
1372
|
for (const a of o)
|
|
1363
1373
|
n.has(a) && await a(t);
|
|
1364
1374
|
for (const a of s)
|
|
@@ -1372,7 +1382,7 @@ let et = class Ir {
|
|
|
1372
1382
|
return t?.addEventListener("abort", n, { once: !0 }), t?.aborted && n(), n;
|
|
1373
1383
|
}
|
|
1374
1384
|
anyEvent() {
|
|
1375
|
-
return
|
|
1385
|
+
return Cn(this);
|
|
1376
1386
|
}
|
|
1377
1387
|
offAny(e) {
|
|
1378
1388
|
mt(e), this.logIfDebugEnabled("unsubscribeAny", void 0, void 0), pt(this, Ut, { listener: e }), te.get(this).delete(e);
|
|
@@ -1419,7 +1429,7 @@ let et = class Ir {
|
|
|
1419
1429
|
bindMethods(e, t) {
|
|
1420
1430
|
if (typeof e != "object" || e === null)
|
|
1421
1431
|
throw new TypeError("`target` must be an object");
|
|
1422
|
-
t =
|
|
1432
|
+
t = On(t);
|
|
1423
1433
|
for (const n of t) {
|
|
1424
1434
|
if (e[n] !== void 0)
|
|
1425
1435
|
throw new Error(`The property \`${n}\` already exists on \`target\``);
|
|
@@ -1430,7 +1440,7 @@ let et = class Ir {
|
|
|
1430
1440
|
}
|
|
1431
1441
|
}
|
|
1432
1442
|
};
|
|
1433
|
-
const
|
|
1443
|
+
const Mn = Object.getOwnPropertyNames(et.prototype).filter((r) => r !== "constructor");
|
|
1434
1444
|
Object.defineProperty(et, "listenerAdded", {
|
|
1435
1445
|
value: Dt,
|
|
1436
1446
|
writable: !1,
|
|
@@ -1443,22 +1453,22 @@ Object.defineProperty(et, "listenerRemoved", {
|
|
|
1443
1453
|
enumerable: !0,
|
|
1444
1454
|
configurable: !1
|
|
1445
1455
|
});
|
|
1446
|
-
function
|
|
1456
|
+
function zr(r, e) {
|
|
1447
1457
|
globalThis.vonage || (globalThis.vonage = {}), globalThis.vonage.workerizer || (globalThis.vonage.workerizer = {});
|
|
1448
1458
|
let t = globalThis.vonage.workerizer;
|
|
1449
1459
|
return t[r] || (t[r] = e), t[r];
|
|
1450
1460
|
}
|
|
1451
|
-
const Le =
|
|
1461
|
+
const Le = zr(
|
|
1452
1462
|
"globals",
|
|
1453
1463
|
{}
|
|
1454
1464
|
);
|
|
1455
1465
|
var z = /* @__PURE__ */ ((r) => (r.INIT = "INIT", r.FORWARD = "FORWARD", r.TERMINATE = "TERMINATE", r.GLOBALS_SYNC = "GLOBALS_SYNC", r.EVENT = "EVENT", r))(z || {});
|
|
1456
|
-
function
|
|
1466
|
+
function fi(r) {
|
|
1457
1467
|
return [ImageBitmap, ReadableStream, WritableStream].some((t) => r instanceof t);
|
|
1458
1468
|
}
|
|
1459
|
-
let
|
|
1469
|
+
let Zs = 0;
|
|
1460
1470
|
function Nt(r, e, t, n, i) {
|
|
1461
|
-
const o =
|
|
1471
|
+
const o = Zs++;
|
|
1462
1472
|
return r.postMessage(
|
|
1463
1473
|
{
|
|
1464
1474
|
id: o,
|
|
@@ -1466,7 +1476,7 @@ function Nt(r, e, t, n, i) {
|
|
|
1466
1476
|
functionName: t,
|
|
1467
1477
|
args: n
|
|
1468
1478
|
},
|
|
1469
|
-
n.filter((a) =>
|
|
1479
|
+
n.filter((a) => fi(a))
|
|
1470
1480
|
), new Promise((a) => {
|
|
1471
1481
|
i?.set(o, a);
|
|
1472
1482
|
});
|
|
@@ -1479,15 +1489,15 @@ function ze(r, e) {
|
|
|
1479
1489
|
type: n,
|
|
1480
1490
|
result: e
|
|
1481
1491
|
},
|
|
1482
|
-
i.filter((o) =>
|
|
1492
|
+
i.filter((o) => fi(o))
|
|
1483
1493
|
);
|
|
1484
1494
|
}
|
|
1485
|
-
const $t =
|
|
1486
|
-
function
|
|
1495
|
+
const $t = zr("workerized", {});
|
|
1496
|
+
function Nr() {
|
|
1487
1497
|
return typeof WorkerGlobalScope < "u" && self instanceof WorkerGlobalScope;
|
|
1488
1498
|
}
|
|
1489
|
-
async function
|
|
1490
|
-
if (
|
|
1499
|
+
async function ea() {
|
|
1500
|
+
if (Nr())
|
|
1491
1501
|
ze({ type: z.GLOBALS_SYNC }, Le);
|
|
1492
1502
|
else {
|
|
1493
1503
|
const r = [];
|
|
@@ -1515,7 +1525,7 @@ function qe(r, e) {
|
|
|
1515
1525
|
for (const t in r)
|
|
1516
1526
|
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];
|
|
1517
1527
|
}
|
|
1518
|
-
async function
|
|
1528
|
+
async function ta(r, e, t, n) {
|
|
1519
1529
|
const i = new e();
|
|
1520
1530
|
if (i.addEventListener(
|
|
1521
1531
|
"message",
|
|
@@ -1523,7 +1533,7 @@ async function Js(r, e, t, n) {
|
|
|
1523
1533
|
var a, c, u, f, m, p, b;
|
|
1524
1534
|
switch (s.type) {
|
|
1525
1535
|
case z.GLOBALS_SYNC:
|
|
1526
|
-
s.id ? ((c = t.get((a = s.id) != null ? a : -1)) == null || c(s.result), t.delete((u = s.id) != null ? u : -1)) : (qe((f = s.result) != null ? f : {}, Le), await
|
|
1536
|
+
s.id ? ((c = t.get((a = s.id) != null ? a : -1)) == null || c(s.result), t.delete((u = s.id) != null ? u : -1)) : (qe((f = s.result) != null ? f : {}, Le), await ea());
|
|
1527
1537
|
break;
|
|
1528
1538
|
case z.EVENT:
|
|
1529
1539
|
const { result: d } = s, g = d;
|
|
@@ -1545,9 +1555,9 @@ async function Js(r, e, t, n) {
|
|
|
1545
1555
|
throw "Failed to instantiate workerized class";
|
|
1546
1556
|
return i;
|
|
1547
1557
|
}
|
|
1548
|
-
const re = /* @__PURE__ */ new WeakMap(), ge = /* @__PURE__ */ new WeakMap(), K = /* @__PURE__ */ new WeakMap(), Wt = /* @__PURE__ */ Symbol("anyProducer"),
|
|
1549
|
-
let Ht = !1,
|
|
1550
|
-
function
|
|
1558
|
+
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");
|
|
1559
|
+
let Ht = !1, yr = !1;
|
|
1560
|
+
function Re(r) {
|
|
1551
1561
|
if (typeof r != "string" && typeof r != "symbol" && typeof r != "number")
|
|
1552
1562
|
throw new TypeError("`eventName` must be a string, symbol, or number");
|
|
1553
1563
|
}
|
|
@@ -1555,7 +1565,7 @@ function gt(r) {
|
|
|
1555
1565
|
if (typeof r != "function")
|
|
1556
1566
|
throw new TypeError("listener must be a function");
|
|
1557
1567
|
}
|
|
1558
|
-
function
|
|
1568
|
+
function ke(r, e) {
|
|
1559
1569
|
const t = ge.get(r);
|
|
1560
1570
|
if (t.has(e))
|
|
1561
1571
|
return t.get(e);
|
|
@@ -1565,7 +1575,7 @@ function Qe(r, e) {
|
|
|
1565
1575
|
if (n.has(t))
|
|
1566
1576
|
return n.get(t);
|
|
1567
1577
|
}
|
|
1568
|
-
function
|
|
1578
|
+
function ra(r, e, t) {
|
|
1569
1579
|
const n = K.get(r);
|
|
1570
1580
|
if (n.has(e))
|
|
1571
1581
|
for (const i of n.get(e))
|
|
@@ -1576,7 +1586,7 @@ function Zs(r, e, t) {
|
|
|
1576
1586
|
o.enqueue(i);
|
|
1577
1587
|
}
|
|
1578
1588
|
}
|
|
1579
|
-
function
|
|
1589
|
+
function Dn(r, e) {
|
|
1580
1590
|
e = Array.isArray(e) ? e : [e];
|
|
1581
1591
|
let t = !1, n = () => {
|
|
1582
1592
|
}, i = [];
|
|
@@ -1614,13 +1624,13 @@ function Ln(r, e) {
|
|
|
1614
1624
|
}
|
|
1615
1625
|
};
|
|
1616
1626
|
}
|
|
1617
|
-
function
|
|
1627
|
+
function Un(r) {
|
|
1618
1628
|
if (r === void 0)
|
|
1619
|
-
return
|
|
1629
|
+
return Ln;
|
|
1620
1630
|
if (!Array.isArray(r))
|
|
1621
1631
|
throw new TypeError("`methodNames` must be an array of strings");
|
|
1622
1632
|
for (const e of r)
|
|
1623
|
-
if (!
|
|
1633
|
+
if (!Ln.includes(e))
|
|
1624
1634
|
throw typeof e != "string" ? new TypeError("`methodNames` element must be a string") : new Error(`${e} is not Emittery method`);
|
|
1625
1635
|
return r;
|
|
1626
1636
|
}
|
|
@@ -1635,7 +1645,7 @@ function yt(r, e, t) {
|
|
|
1635
1645
|
}
|
|
1636
1646
|
class ve {
|
|
1637
1647
|
static mixin(e, t) {
|
|
1638
|
-
return t =
|
|
1648
|
+
return t = Un(t), (n) => {
|
|
1639
1649
|
if (typeof n != "function")
|
|
1640
1650
|
throw new TypeError("`target` must be function");
|
|
1641
1651
|
for (const s of t)
|
|
@@ -1665,12 +1675,12 @@ class ve {
|
|
|
1665
1675
|
static get isDebugEnabled() {
|
|
1666
1676
|
var e, t;
|
|
1667
1677
|
if (typeof ((e = globalThis.process) == null ? void 0 : e.env) != "object")
|
|
1668
|
-
return
|
|
1678
|
+
return yr;
|
|
1669
1679
|
const { env: n } = (t = globalThis.process) != null ? t : { env: {} };
|
|
1670
|
-
return n.DEBUG === "emittery" || n.DEBUG === "*" ||
|
|
1680
|
+
return n.DEBUG === "emittery" || n.DEBUG === "*" || yr;
|
|
1671
1681
|
}
|
|
1672
1682
|
static set isDebugEnabled(e) {
|
|
1673
|
-
|
|
1683
|
+
yr = e;
|
|
1674
1684
|
}
|
|
1675
1685
|
constructor(e = {}) {
|
|
1676
1686
|
var t;
|
|
@@ -1692,8 +1702,8 @@ class ve {
|
|
|
1692
1702
|
on(e, t) {
|
|
1693
1703
|
gt(t), e = Array.isArray(e) ? e : [e];
|
|
1694
1704
|
for (const n of e) {
|
|
1695
|
-
|
|
1696
|
-
let i =
|
|
1705
|
+
Re(n);
|
|
1706
|
+
let i = ke(this, n);
|
|
1697
1707
|
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 });
|
|
1698
1708
|
}
|
|
1699
1709
|
return this.off.bind(this, e, t);
|
|
@@ -1701,8 +1711,8 @@ class ve {
|
|
|
1701
1711
|
off(e, t) {
|
|
1702
1712
|
gt(t), e = Array.isArray(e) ? e : [e];
|
|
1703
1713
|
for (const n of e) {
|
|
1704
|
-
|
|
1705
|
-
const i =
|
|
1714
|
+
Re(n);
|
|
1715
|
+
const i = ke(this, n);
|
|
1706
1716
|
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 });
|
|
1707
1717
|
}
|
|
1708
1718
|
}
|
|
@@ -1718,16 +1728,16 @@ class ve {
|
|
|
1718
1728
|
events(e) {
|
|
1719
1729
|
e = Array.isArray(e) ? e : [e];
|
|
1720
1730
|
for (const t of e)
|
|
1721
|
-
|
|
1722
|
-
return
|
|
1731
|
+
Re(t);
|
|
1732
|
+
return Dn(this, e);
|
|
1723
1733
|
}
|
|
1724
1734
|
async emit(e, t) {
|
|
1725
1735
|
var n;
|
|
1726
|
-
if (
|
|
1736
|
+
if (Re(e), De(e) && !Ht)
|
|
1727
1737
|
throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");
|
|
1728
|
-
this.logIfDebugEnabled("emit", e, t),
|
|
1729
|
-
const i = (n =
|
|
1730
|
-
await
|
|
1738
|
+
this.logIfDebugEnabled("emit", e, t), ra(this, e, t);
|
|
1739
|
+
const i = (n = ke(this, e)) != null ? n : /* @__PURE__ */ new Set(), o = re.get(this), s = [...i], a = De(e) ? [] : [...o];
|
|
1740
|
+
await Bn, await Promise.all([
|
|
1731
1741
|
...s.map(async (c) => {
|
|
1732
1742
|
if (i.has(c))
|
|
1733
1743
|
return c(t);
|
|
@@ -1740,11 +1750,11 @@ class ve {
|
|
|
1740
1750
|
}
|
|
1741
1751
|
async emitSerial(e, t) {
|
|
1742
1752
|
var n;
|
|
1743
|
-
if (
|
|
1753
|
+
if (Re(e), De(e) && !Ht)
|
|
1744
1754
|
throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");
|
|
1745
1755
|
this.logIfDebugEnabled("emitSerial", e, t);
|
|
1746
|
-
const i = (n =
|
|
1747
|
-
await
|
|
1756
|
+
const i = (n = ke(this, e)) != null ? n : /* @__PURE__ */ new Set(), o = re.get(this), s = [...i], a = [...o];
|
|
1757
|
+
await Bn;
|
|
1748
1758
|
for (const c of s)
|
|
1749
1759
|
i.has(c) && await c(t);
|
|
1750
1760
|
for (const c of a)
|
|
@@ -1754,7 +1764,7 @@ class ve {
|
|
|
1754
1764
|
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);
|
|
1755
1765
|
}
|
|
1756
1766
|
anyEvent() {
|
|
1757
|
-
return
|
|
1767
|
+
return Dn(this);
|
|
1758
1768
|
}
|
|
1759
1769
|
offAny(e) {
|
|
1760
1770
|
gt(e), this.logIfDebugEnabled("unsubscribeAny", void 0, void 0), yt(this, Vt, { listener: e }), re.get(this).delete(e);
|
|
@@ -1763,7 +1773,7 @@ class ve {
|
|
|
1763
1773
|
e = Array.isArray(e) ? e : [e];
|
|
1764
1774
|
for (const t of e)
|
|
1765
1775
|
if (this.logIfDebugEnabled("clear", t, void 0), typeof t == "string" || typeof t == "symbol" || typeof t == "number") {
|
|
1766
|
-
const n =
|
|
1776
|
+
const n = ke(this, t);
|
|
1767
1777
|
n && n.clear();
|
|
1768
1778
|
const i = Qe(this, t);
|
|
1769
1779
|
if (i) {
|
|
@@ -1788,10 +1798,10 @@ class ve {
|
|
|
1788
1798
|
let c = 0;
|
|
1789
1799
|
for (const u of e) {
|
|
1790
1800
|
if (typeof u == "string") {
|
|
1791
|
-
c += re.get(this).size + ((n = (t =
|
|
1801
|
+
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);
|
|
1792
1802
|
continue;
|
|
1793
1803
|
}
|
|
1794
|
-
typeof u < "u" &&
|
|
1804
|
+
typeof u < "u" && Re(u), c += re.get(this).size;
|
|
1795
1805
|
for (const f of ge.get(this).values())
|
|
1796
1806
|
c += f.size;
|
|
1797
1807
|
for (const f of K.get(this).values())
|
|
@@ -1802,7 +1812,7 @@ class ve {
|
|
|
1802
1812
|
bindMethods(e, t) {
|
|
1803
1813
|
if (typeof e != "object" || e === null)
|
|
1804
1814
|
throw new TypeError("`target` must be an object");
|
|
1805
|
-
t =
|
|
1815
|
+
t = Un(t);
|
|
1806
1816
|
for (const n of t) {
|
|
1807
1817
|
if (e[n] !== void 0)
|
|
1808
1818
|
throw new Error(`The property \`${n}\` already exists on \`target\``);
|
|
@@ -1813,7 +1823,7 @@ class ve {
|
|
|
1813
1823
|
}
|
|
1814
1824
|
}
|
|
1815
1825
|
}
|
|
1816
|
-
const
|
|
1826
|
+
const Ln = Object.getOwnPropertyNames(ve.prototype).filter((r) => r !== "constructor");
|
|
1817
1827
|
Object.defineProperty(ve, "listenerAdded", {
|
|
1818
1828
|
value: Gt,
|
|
1819
1829
|
writable: !1,
|
|
@@ -1826,15 +1836,15 @@ Object.defineProperty(ve, "listenerRemoved", {
|
|
|
1826
1836
|
enumerable: !0,
|
|
1827
1837
|
configurable: !1
|
|
1828
1838
|
});
|
|
1829
|
-
function
|
|
1839
|
+
function na(r) {
|
|
1830
1840
|
return r.onAny && r.emit;
|
|
1831
1841
|
}
|
|
1832
|
-
function
|
|
1842
|
+
function ia(r) {
|
|
1833
1843
|
return r.prototype.onAny && r.prototype.emit;
|
|
1834
1844
|
}
|
|
1835
|
-
let
|
|
1836
|
-
async function
|
|
1837
|
-
const i =
|
|
1845
|
+
let oa = 0;
|
|
1846
|
+
async function sa(r, e, t) {
|
|
1847
|
+
const i = ia(r) ? new ve() : {}, o = oa++;
|
|
1838
1848
|
return Object.getOwnPropertyNames(r.prototype).forEach(
|
|
1839
1849
|
(s) => {
|
|
1840
1850
|
i[s] = (...a) => Nt(e, z.FORWARD, s, a, t);
|
|
@@ -1854,10 +1864,10 @@ async function na(r, e, t) {
|
|
|
1854
1864
|
resolvers: t
|
|
1855
1865
|
}, $t[o] = i, i;
|
|
1856
1866
|
}
|
|
1857
|
-
async function
|
|
1867
|
+
async function aa(r, e) {
|
|
1858
1868
|
const t = /* @__PURE__ */ new Map();
|
|
1859
1869
|
let n;
|
|
1860
|
-
const i = await
|
|
1870
|
+
const i = await ta(
|
|
1861
1871
|
r,
|
|
1862
1872
|
e,
|
|
1863
1873
|
t,
|
|
@@ -1865,13 +1875,13 @@ async function ia(r, e) {
|
|
|
1865
1875
|
n?.emit && n?.emit(o, s);
|
|
1866
1876
|
}
|
|
1867
1877
|
);
|
|
1868
|
-
return n = await
|
|
1878
|
+
return n = await sa(
|
|
1869
1879
|
r,
|
|
1870
1880
|
i,
|
|
1871
1881
|
t
|
|
1872
1882
|
), n;
|
|
1873
1883
|
}
|
|
1874
|
-
async function
|
|
1884
|
+
async function ca(r, e) {
|
|
1875
1885
|
const { functionName: t, args: n } = r;
|
|
1876
1886
|
if (!e.instance)
|
|
1877
1887
|
throw "instance not initialized";
|
|
@@ -1881,19 +1891,19 @@ async function oa(r, e) {
|
|
|
1881
1891
|
throw `undefined function [${t}] in class ${e.instance.constructor.workerId}`;
|
|
1882
1892
|
ze(r, await e.instance[t](...n ?? []));
|
|
1883
1893
|
}
|
|
1884
|
-
const
|
|
1885
|
-
function
|
|
1886
|
-
e.workerId = r,
|
|
1894
|
+
const di = zr("registeredWorkers", {});
|
|
1895
|
+
function ua(r, e) {
|
|
1896
|
+
e.workerId = r, Nr() && (di[e.workerId] = e);
|
|
1887
1897
|
}
|
|
1888
|
-
function
|
|
1898
|
+
function la(r, e) {
|
|
1889
1899
|
if (!r.args)
|
|
1890
1900
|
throw "Missing className while initializing worker";
|
|
1891
|
-
const [t, n] = r.args, i =
|
|
1901
|
+
const [t, n] = r.args, i = di[t];
|
|
1892
1902
|
if (i)
|
|
1893
1903
|
e.instance = new i(r.args.slice(1));
|
|
1894
1904
|
else
|
|
1895
1905
|
throw `unknown worker class ${t}`;
|
|
1896
|
-
qe(n, Le),
|
|
1906
|
+
qe(n, Le), na(e.instance) && e.instance.onAny((o, s) => {
|
|
1897
1907
|
ze(
|
|
1898
1908
|
{
|
|
1899
1909
|
type: z.EVENT
|
|
@@ -1902,40 +1912,40 @@ function aa(r, e) {
|
|
|
1902
1912
|
);
|
|
1903
1913
|
}), ze(r, typeof e.instance !== void 0);
|
|
1904
1914
|
}
|
|
1905
|
-
async function
|
|
1915
|
+
async function fa(r, e) {
|
|
1906
1916
|
const { args: t } = r;
|
|
1907
1917
|
if (!e.instance)
|
|
1908
1918
|
throw "instance not initialized";
|
|
1909
1919
|
let n;
|
|
1910
1920
|
e.instance.terminate && (n = await e.instance.terminate(...t ?? [])), ze(r, n);
|
|
1911
1921
|
}
|
|
1912
|
-
function
|
|
1922
|
+
function da(r) {
|
|
1913
1923
|
if (!r.args)
|
|
1914
1924
|
throw "Missing globals while syncing";
|
|
1915
1925
|
qe(r.args[0], Le), ze(r, {});
|
|
1916
1926
|
}
|
|
1917
|
-
function
|
|
1927
|
+
function ha() {
|
|
1918
1928
|
const r = {};
|
|
1919
1929
|
onmessage = async (e) => {
|
|
1920
1930
|
const t = e.data;
|
|
1921
1931
|
switch (t.type) {
|
|
1922
1932
|
case z.INIT:
|
|
1923
|
-
|
|
1933
|
+
la(t, r);
|
|
1924
1934
|
break;
|
|
1925
1935
|
case z.FORWARD:
|
|
1926
|
-
|
|
1936
|
+
ca(t, r);
|
|
1927
1937
|
break;
|
|
1928
1938
|
case z.TERMINATE:
|
|
1929
|
-
|
|
1939
|
+
fa(t, r);
|
|
1930
1940
|
break;
|
|
1931
1941
|
case z.GLOBALS_SYNC:
|
|
1932
|
-
|
|
1942
|
+
da(t);
|
|
1933
1943
|
break;
|
|
1934
1944
|
}
|
|
1935
1945
|
};
|
|
1936
1946
|
}
|
|
1937
|
-
|
|
1938
|
-
class
|
|
1947
|
+
Nr() && ha();
|
|
1948
|
+
class zn {
|
|
1939
1949
|
static async createVideoReadable(e) {
|
|
1940
1950
|
return new Promise((t, n) => {
|
|
1941
1951
|
const i = document.createElement("video");
|
|
@@ -1969,47 +1979,47 @@ class $n {
|
|
|
1969
1979
|
return await createImageBitmap(n);
|
|
1970
1980
|
}
|
|
1971
1981
|
}
|
|
1972
|
-
var
|
|
1973
|
-
const
|
|
1982
|
+
var ma = Object.defineProperty, pa = (r, e, t) => e in r ? ma(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, ga = (r, e, t) => (pa(r, e + "", t), t);
|
|
1983
|
+
const ya = "hlg.tokbox.com/prod/logging/vcp_webrtc", ba = "https://", wa = 1e4;
|
|
1974
1984
|
let bt;
|
|
1975
|
-
const
|
|
1976
|
-
function
|
|
1985
|
+
const xa = new Uint8Array(16);
|
|
1986
|
+
function va() {
|
|
1977
1987
|
if (!bt && (bt = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !bt))
|
|
1978
1988
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
1979
|
-
return bt(
|
|
1989
|
+
return bt(xa);
|
|
1980
1990
|
}
|
|
1981
|
-
const
|
|
1991
|
+
const C = [];
|
|
1982
1992
|
for (let r = 0; r < 256; ++r)
|
|
1983
|
-
|
|
1984
|
-
function
|
|
1985
|
-
return (
|
|
1993
|
+
C.push((r + 256).toString(16).slice(1));
|
|
1994
|
+
function _a(r, e = 0) {
|
|
1995
|
+
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();
|
|
1986
1996
|
}
|
|
1987
|
-
const
|
|
1988
|
-
randomUUID:
|
|
1997
|
+
const Ea = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Nn = {
|
|
1998
|
+
randomUUID: Ea
|
|
1989
1999
|
};
|
|
1990
|
-
function
|
|
1991
|
-
if (
|
|
1992
|
-
return
|
|
2000
|
+
function Aa(r, e, t) {
|
|
2001
|
+
if (Nn.randomUUID && !e && !r)
|
|
2002
|
+
return Nn.randomUUID();
|
|
1993
2003
|
r = r || {};
|
|
1994
|
-
const n = r.random || (r.rng ||
|
|
1995
|
-
return n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128,
|
|
2004
|
+
const n = r.random || (r.rng || va)();
|
|
2005
|
+
return n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128, _a(n);
|
|
1996
2006
|
}
|
|
1997
|
-
function
|
|
2007
|
+
function $r(r, e) {
|
|
1998
2008
|
globalThis.vonage || (globalThis.vonage = {}), globalThis.vonage.workerizer || (globalThis.vonage.workerizer = {});
|
|
1999
2009
|
let t = globalThis.vonage.workerizer;
|
|
2000
2010
|
return t[r] || (t[r] = e), t[r];
|
|
2001
2011
|
}
|
|
2002
|
-
const oe =
|
|
2012
|
+
const oe = $r(
|
|
2003
2013
|
"globals",
|
|
2004
2014
|
{}
|
|
2005
2015
|
);
|
|
2006
2016
|
var we = /* @__PURE__ */ ((r) => (r.INIT = "INIT", r.FORWARD = "FORWARD", r.TERMINATE = "TERMINATE", r.GLOBALS_SYNC = "GLOBALS_SYNC", r))(we || {});
|
|
2007
|
-
function
|
|
2017
|
+
function hi(r) {
|
|
2008
2018
|
return [ImageBitmap, ReadableStream, WritableStream].some((e) => r instanceof e);
|
|
2009
2019
|
}
|
|
2010
|
-
let
|
|
2011
|
-
function
|
|
2012
|
-
const o =
|
|
2020
|
+
let Ta = 0;
|
|
2021
|
+
function Sa(r, e, t, n, i) {
|
|
2022
|
+
const o = Ta++;
|
|
2013
2023
|
return r.postMessage(
|
|
2014
2024
|
{
|
|
2015
2025
|
id: o,
|
|
@@ -2017,7 +2027,7 @@ function Ea(r, e, t, n, i) {
|
|
|
2017
2027
|
functionName: t,
|
|
2018
2028
|
args: n
|
|
2019
2029
|
},
|
|
2020
|
-
n.filter((s) =>
|
|
2030
|
+
n.filter((s) => hi(s))
|
|
2021
2031
|
), new Promise((s) => {
|
|
2022
2032
|
i?.set(o, s);
|
|
2023
2033
|
});
|
|
@@ -2030,22 +2040,22 @@ function tt(r, e) {
|
|
|
2030
2040
|
type: n,
|
|
2031
2041
|
result: e
|
|
2032
2042
|
},
|
|
2033
|
-
i.filter((o) =>
|
|
2043
|
+
i.filter((o) => hi(o))
|
|
2034
2044
|
);
|
|
2035
2045
|
}
|
|
2036
|
-
const
|
|
2037
|
-
function
|
|
2046
|
+
const $n = $r("workerized", {});
|
|
2047
|
+
function mi() {
|
|
2038
2048
|
return typeof WorkerGlobalScope < "u" && self instanceof WorkerGlobalScope;
|
|
2039
2049
|
}
|
|
2040
|
-
async function
|
|
2041
|
-
if (
|
|
2050
|
+
async function Ia() {
|
|
2051
|
+
if (mi())
|
|
2042
2052
|
tt({ type: we.GLOBALS_SYNC }, oe);
|
|
2043
2053
|
else {
|
|
2044
2054
|
const r = [];
|
|
2045
|
-
for (const e in
|
|
2046
|
-
const { worker: t, resolvers: n } =
|
|
2055
|
+
for (const e in $n) {
|
|
2056
|
+
const { worker: t, resolvers: n } = $n[e].workerContext;
|
|
2047
2057
|
t && r.push(
|
|
2048
|
-
|
|
2058
|
+
Sa(
|
|
2049
2059
|
t,
|
|
2050
2060
|
we.GLOBALS_SYNC,
|
|
2051
2061
|
"",
|
|
@@ -2066,7 +2076,7 @@ function jt(r, e) {
|
|
|
2066
2076
|
for (const t in r)
|
|
2067
2077
|
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];
|
|
2068
2078
|
}
|
|
2069
|
-
async function
|
|
2079
|
+
async function Ra(r, e) {
|
|
2070
2080
|
const { functionName: t, args: n } = r;
|
|
2071
2081
|
if (!e.instance)
|
|
2072
2082
|
throw "instance not initialized";
|
|
@@ -2076,75 +2086,75 @@ async function Ta(r, e) {
|
|
|
2076
2086
|
throw `undefined function [${t}] in class ${e.instance.constructor.workerId}`;
|
|
2077
2087
|
tt(r, await e.instance[t](...n ?? []));
|
|
2078
2088
|
}
|
|
2079
|
-
const
|
|
2080
|
-
function
|
|
2089
|
+
const ka = $r("registeredWorkers", {});
|
|
2090
|
+
function Pa(r, e) {
|
|
2081
2091
|
if (!r.args)
|
|
2082
2092
|
throw "Missing className while initializing worker";
|
|
2083
|
-
const [t, n] = r.args, i =
|
|
2093
|
+
const [t, n] = r.args, i = ka[t];
|
|
2084
2094
|
if (i)
|
|
2085
2095
|
e.instance = new i(r.args.slice(1));
|
|
2086
2096
|
else
|
|
2087
2097
|
throw `unknown worker class ${t}`;
|
|
2088
2098
|
jt(n, oe), tt(r, typeof e.instance !== void 0);
|
|
2089
2099
|
}
|
|
2090
|
-
async function
|
|
2100
|
+
async function Fa(r, e) {
|
|
2091
2101
|
const { args: t } = r;
|
|
2092
2102
|
if (!e.instance)
|
|
2093
2103
|
throw "instance not initialized";
|
|
2094
2104
|
let n;
|
|
2095
2105
|
e.instance.terminate && (n = await e.instance.terminate(...t ?? [])), tt(r, n);
|
|
2096
2106
|
}
|
|
2097
|
-
function
|
|
2107
|
+
function Ca(r) {
|
|
2098
2108
|
if (!r.args)
|
|
2099
2109
|
throw "Missing globals while syncing";
|
|
2100
2110
|
jt(r.args[0], oe), tt(r, {});
|
|
2101
2111
|
}
|
|
2102
|
-
function
|
|
2112
|
+
function Oa() {
|
|
2103
2113
|
const r = {};
|
|
2104
2114
|
onmessage = async (e) => {
|
|
2105
2115
|
const t = e.data;
|
|
2106
2116
|
switch (t.type) {
|
|
2107
2117
|
case we.INIT:
|
|
2108
|
-
|
|
2118
|
+
Pa(t, r);
|
|
2109
2119
|
break;
|
|
2110
2120
|
case we.FORWARD:
|
|
2111
|
-
|
|
2121
|
+
Ra(t, r);
|
|
2112
2122
|
break;
|
|
2113
2123
|
case we.TERMINATE:
|
|
2114
|
-
|
|
2124
|
+
Fa(t, r);
|
|
2115
2125
|
break;
|
|
2116
2126
|
case we.GLOBALS_SYNC:
|
|
2117
|
-
|
|
2127
|
+
Ca(t);
|
|
2118
2128
|
break;
|
|
2119
2129
|
}
|
|
2120
2130
|
};
|
|
2121
2131
|
}
|
|
2122
|
-
|
|
2123
|
-
function
|
|
2132
|
+
mi() && Oa();
|
|
2133
|
+
function Ma(r, e) {
|
|
2124
2134
|
return oe[r] || (oe[r] = e), [
|
|
2125
2135
|
() => oe[r],
|
|
2126
2136
|
async (t) => {
|
|
2127
|
-
oe[r] = t, await
|
|
2137
|
+
oe[r] = t, await Ia();
|
|
2128
2138
|
}
|
|
2129
2139
|
];
|
|
2130
2140
|
}
|
|
2131
|
-
function
|
|
2132
|
-
return
|
|
2141
|
+
function Ba(r, e) {
|
|
2142
|
+
return Ma(r, e);
|
|
2133
2143
|
}
|
|
2134
|
-
const [
|
|
2135
|
-
function
|
|
2136
|
-
return
|
|
2144
|
+
const [Da] = Ba("metadata");
|
|
2145
|
+
function br() {
|
|
2146
|
+
return Da();
|
|
2137
2147
|
}
|
|
2138
|
-
class
|
|
2148
|
+
class Ua {
|
|
2139
2149
|
constructor(e) {
|
|
2140
|
-
|
|
2150
|
+
ga(this, "uuid", Aa()), this.config = e;
|
|
2141
2151
|
}
|
|
2142
2152
|
async send(e) {
|
|
2143
2153
|
var t, n, i;
|
|
2144
|
-
const { appId: o, sourceType: s } = (t =
|
|
2154
|
+
const { appId: o, sourceType: s } = (t = br()) != null ? t : {};
|
|
2145
2155
|
if (!o || !s)
|
|
2146
2156
|
return "metadata missing";
|
|
2147
|
-
const a = new AbortController(), c = setTimeout(() => a.abort(),
|
|
2157
|
+
const a = new AbortController(), c = setTimeout(() => a.abort(), wa);
|
|
2148
2158
|
return await ((i = (n = this.config) == null ? void 0 : n.fetch) != null ? i : fetch)(this.getUrl(), {
|
|
2149
2159
|
method: "POST",
|
|
2150
2160
|
headers: this.getHeaders(),
|
|
@@ -2154,8 +2164,8 @@ class Ma {
|
|
|
2154
2164
|
}
|
|
2155
2165
|
getUrl() {
|
|
2156
2166
|
var e;
|
|
2157
|
-
let t = (e =
|
|
2158
|
-
return t += (t.at(-1) === "/" ? "" : "/") +
|
|
2167
|
+
let t = (e = br().proxyUrl) != null ? e : ba;
|
|
2168
|
+
return t += (t.at(-1) === "/" ? "" : "/") + ya, t;
|
|
2159
2169
|
}
|
|
2160
2170
|
getHeaders() {
|
|
2161
2171
|
return {
|
|
@@ -2163,7 +2173,7 @@ class Ma {
|
|
|
2163
2173
|
};
|
|
2164
2174
|
}
|
|
2165
2175
|
buildReport(e) {
|
|
2166
|
-
const t =
|
|
2176
|
+
const t = br();
|
|
2167
2177
|
return {
|
|
2168
2178
|
guid: this.uuid,
|
|
2169
2179
|
...e,
|
|
@@ -2174,8 +2184,8 @@ class Ma {
|
|
|
2174
2184
|
};
|
|
2175
2185
|
}
|
|
2176
2186
|
}
|
|
2177
|
-
const
|
|
2178
|
-
class
|
|
2187
|
+
const La = "7.0.0";
|
|
2188
|
+
class Wr {
|
|
2179
2189
|
constructor() {
|
|
2180
2190
|
const e = new OffscreenCanvas(0, 0), t = e.getContext("2d", { willReadFrequently: !0 });
|
|
2181
2191
|
if (!t)
|
|
@@ -2233,7 +2243,7 @@ class Vr {
|
|
|
2233
2243
|
destroy() {
|
|
2234
2244
|
}
|
|
2235
2245
|
}
|
|
2236
|
-
class
|
|
2246
|
+
class za extends Wr {
|
|
2237
2247
|
constructor(e) {
|
|
2238
2248
|
super(), this.radius = e;
|
|
2239
2249
|
}
|
|
@@ -2243,7 +2253,7 @@ class Da extends Vr {
|
|
|
2243
2253
|
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);
|
|
2244
2254
|
}
|
|
2245
2255
|
}
|
|
2246
|
-
class
|
|
2256
|
+
class Na extends Wr {
|
|
2247
2257
|
constructor(e) {
|
|
2248
2258
|
super(), this.radius = e;
|
|
2249
2259
|
}
|
|
@@ -2253,7 +2263,7 @@ class Ua extends Vr {
|
|
|
2253
2263
|
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);
|
|
2254
2264
|
}
|
|
2255
2265
|
}
|
|
2256
|
-
class
|
|
2266
|
+
class $a extends Wr {
|
|
2257
2267
|
setBackgroundImage(e) {
|
|
2258
2268
|
this.backgroundImage = e;
|
|
2259
2269
|
}
|
|
@@ -2273,47 +2283,47 @@ class La extends Vr {
|
|
|
2273
2283
|
), this.context.restore()), super.render(e, t);
|
|
2274
2284
|
}
|
|
2275
2285
|
}
|
|
2276
|
-
const
|
|
2286
|
+
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 = {};
|
|
2277
2287
|
{
|
|
2278
|
-
const r =
|
|
2279
|
-
r[
|
|
2288
|
+
const r = pi;
|
|
2289
|
+
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;
|
|
2280
2290
|
}
|
|
2281
|
-
function
|
|
2291
|
+
function qr(r) {
|
|
2282
2292
|
if (r instanceof Int8Array)
|
|
2283
|
-
return
|
|
2293
|
+
return Gr;
|
|
2284
2294
|
if (r instanceof Uint8Array || r instanceof Uint8ClampedArray)
|
|
2285
2295
|
return Xe;
|
|
2286
2296
|
if (r instanceof Int16Array)
|
|
2287
|
-
return
|
|
2297
|
+
return Vr;
|
|
2288
2298
|
if (r instanceof Uint16Array)
|
|
2289
|
-
return
|
|
2299
|
+
return Hr;
|
|
2290
2300
|
if (r instanceof Int32Array)
|
|
2291
|
-
return
|
|
2301
|
+
return jr;
|
|
2292
2302
|
if (r instanceof Uint32Array)
|
|
2293
|
-
return
|
|
2303
|
+
return Yr;
|
|
2294
2304
|
if (r instanceof Float32Array)
|
|
2295
|
-
return
|
|
2305
|
+
return Qr;
|
|
2296
2306
|
throw new Error("unsupported typed array type");
|
|
2297
2307
|
}
|
|
2298
|
-
function
|
|
2308
|
+
function gi(r) {
|
|
2299
2309
|
if (r === Int8Array)
|
|
2300
|
-
return
|
|
2310
|
+
return Gr;
|
|
2301
2311
|
if (r === Uint8Array || r === Uint8ClampedArray)
|
|
2302
2312
|
return Xe;
|
|
2303
2313
|
if (r === Int16Array)
|
|
2304
|
-
return
|
|
2314
|
+
return Vr;
|
|
2305
2315
|
if (r === Uint16Array)
|
|
2306
|
-
return
|
|
2316
|
+
return Hr;
|
|
2307
2317
|
if (r === Int32Array)
|
|
2308
|
-
return
|
|
2318
|
+
return jr;
|
|
2309
2319
|
if (r === Uint32Array)
|
|
2310
|
-
return
|
|
2320
|
+
return Yr;
|
|
2311
2321
|
if (r === Float32Array)
|
|
2312
|
-
return
|
|
2322
|
+
return Qr;
|
|
2313
2323
|
throw new Error("unsupported typed array type");
|
|
2314
2324
|
}
|
|
2315
|
-
function
|
|
2316
|
-
const e =
|
|
2325
|
+
function yi(r) {
|
|
2326
|
+
const e = pi[r];
|
|
2317
2327
|
if (!e)
|
|
2318
2328
|
throw new Error("unknown gl type");
|
|
2319
2329
|
return e;
|
|
@@ -2323,15 +2333,15 @@ const Yt = typeof SharedArrayBuffer < "u" ? function(e) {
|
|
|
2323
2333
|
} : function(e) {
|
|
2324
2334
|
return e && e.buffer && e.buffer instanceof ArrayBuffer;
|
|
2325
2335
|
};
|
|
2326
|
-
function
|
|
2336
|
+
function bi(...r) {
|
|
2327
2337
|
console.error(...r);
|
|
2328
2338
|
}
|
|
2329
|
-
const
|
|
2339
|
+
const Wn = /* @__PURE__ */ new Map();
|
|
2330
2340
|
function Zt(r, e) {
|
|
2331
2341
|
if (!r || typeof r != "object")
|
|
2332
2342
|
return !1;
|
|
2333
|
-
let t =
|
|
2334
|
-
t || (t = /* @__PURE__ */ new WeakMap(),
|
|
2343
|
+
let t = Wn.get(e);
|
|
2344
|
+
t || (t = /* @__PURE__ */ new WeakMap(), Wn.set(e, t));
|
|
2335
2345
|
let n = t.get(r);
|
|
2336
2346
|
if (n === void 0) {
|
|
2337
2347
|
const i = Object.prototype.toString.call(r);
|
|
@@ -2339,51 +2349,51 @@ function Zt(r, e) {
|
|
|
2339
2349
|
}
|
|
2340
2350
|
return n;
|
|
2341
2351
|
}
|
|
2342
|
-
function
|
|
2352
|
+
function Ka(r, e) {
|
|
2343
2353
|
return typeof WebGLBuffer < "u" && Zt(e, "WebGLBuffer");
|
|
2344
2354
|
}
|
|
2345
|
-
function
|
|
2355
|
+
function Ja(r, e) {
|
|
2346
2356
|
return typeof WebGLRenderbuffer < "u" && Zt(e, "WebGLRenderbuffer");
|
|
2347
2357
|
}
|
|
2348
|
-
function
|
|
2358
|
+
function Xr(r, e) {
|
|
2349
2359
|
return typeof WebGLTexture < "u" && Zt(e, "WebGLTexture");
|
|
2350
2360
|
}
|
|
2351
|
-
function
|
|
2361
|
+
function Za(r, e) {
|
|
2352
2362
|
return typeof WebGLSampler < "u" && Zt(e, "WebGLSampler");
|
|
2353
2363
|
}
|
|
2354
|
-
const
|
|
2364
|
+
const wi = 35044, xe = 34962, ec = 34963, tc = 34660, rc = 5120, nc = 5121, ic = 5122, oc = 5123, sc = 5124, ac = 5125, xi = 5126, vi = {
|
|
2355
2365
|
attribPrefix: ""
|
|
2356
2366
|
};
|
|
2357
|
-
function
|
|
2358
|
-
r.bindBuffer(e, t), r.bufferData(e, n, i ||
|
|
2367
|
+
function cc(r, e, t, n, i) {
|
|
2368
|
+
r.bindBuffer(e, t), r.bufferData(e, n, i || wi);
|
|
2359
2369
|
}
|
|
2360
|
-
function
|
|
2361
|
-
if (
|
|
2370
|
+
function _i(r, e, t, n) {
|
|
2371
|
+
if (Ka(r, e))
|
|
2362
2372
|
return e;
|
|
2363
2373
|
t = t || xe;
|
|
2364
2374
|
const i = r.createBuffer();
|
|
2365
|
-
return
|
|
2375
|
+
return cc(r, t, i, e, n), i;
|
|
2366
2376
|
}
|
|
2367
|
-
function
|
|
2377
|
+
function Ei(r) {
|
|
2368
2378
|
return r === "indices";
|
|
2369
2379
|
}
|
|
2370
|
-
function
|
|
2380
|
+
function uc(r) {
|
|
2371
2381
|
return r === Int8Array || r === Uint8Array;
|
|
2372
2382
|
}
|
|
2373
|
-
function
|
|
2383
|
+
function lc(r) {
|
|
2374
2384
|
return r.length ? r : r.data;
|
|
2375
2385
|
}
|
|
2376
|
-
const
|
|
2377
|
-
function
|
|
2386
|
+
const fc = /coord|texture/i, dc = /color|colour/i;
|
|
2387
|
+
function hc(r, e) {
|
|
2378
2388
|
let t;
|
|
2379
|
-
if (
|
|
2389
|
+
if (fc.test(r) ? t = 2 : dc.test(r) ? t = 4 : t = 3, e % t > 0)
|
|
2380
2390
|
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.`);
|
|
2381
2391
|
return t;
|
|
2382
2392
|
}
|
|
2383
|
-
function
|
|
2384
|
-
return r.numComponents || r.size ||
|
|
2393
|
+
function mc(r, e, t) {
|
|
2394
|
+
return r.numComponents || r.size || hc(e, t || lc(r).length);
|
|
2385
2395
|
}
|
|
2386
|
-
function
|
|
2396
|
+
function Ai(r, e) {
|
|
2387
2397
|
if (Yt(r))
|
|
2388
2398
|
return r;
|
|
2389
2399
|
if (Yt(r.data))
|
|
@@ -2391,47 +2401,47 @@ function Si(r, e) {
|
|
|
2391
2401
|
Array.isArray(r) && (r = {
|
|
2392
2402
|
data: r
|
|
2393
2403
|
});
|
|
2394
|
-
let t = r.type ?
|
|
2395
|
-
return t || (
|
|
2404
|
+
let t = r.type ? Kr(r.type) : void 0;
|
|
2405
|
+
return t || (Ei(e) ? t = Uint16Array : t = Float32Array), new t(r.data);
|
|
2396
2406
|
}
|
|
2397
|
-
function
|
|
2398
|
-
return typeof r == "number" ? r : r ?
|
|
2407
|
+
function pc(r) {
|
|
2408
|
+
return typeof r == "number" ? r : r ? gi(r) : xi;
|
|
2399
2409
|
}
|
|
2400
|
-
function
|
|
2401
|
-
return typeof r == "number" ?
|
|
2410
|
+
function Kr(r) {
|
|
2411
|
+
return typeof r == "number" ? yi(r) : r || Float32Array;
|
|
2402
2412
|
}
|
|
2403
|
-
function
|
|
2413
|
+
function gc(r, e) {
|
|
2404
2414
|
return {
|
|
2405
2415
|
buffer: e.buffer,
|
|
2406
2416
|
numValues: 24,
|
|
2407
2417
|
// safely divided by 2, 3, 4
|
|
2408
|
-
type:
|
|
2409
|
-
arrayType:
|
|
2418
|
+
type: pc(e.type),
|
|
2419
|
+
arrayType: Kr(e.type)
|
|
2410
2420
|
};
|
|
2411
2421
|
}
|
|
2412
|
-
function
|
|
2413
|
-
const t = e.data || e, n =
|
|
2414
|
-
return r.bindBuffer(xe, o), r.bufferData(xe, i, e.drawType ||
|
|
2422
|
+
function yc(r, e) {
|
|
2423
|
+
const t = e.data || e, n = Kr(e.type), i = t * n.BYTES_PER_ELEMENT, o = r.createBuffer();
|
|
2424
|
+
return r.bindBuffer(xe, o), r.bufferData(xe, i, e.drawType || wi), {
|
|
2415
2425
|
buffer: o,
|
|
2416
2426
|
numValues: t,
|
|
2417
|
-
type:
|
|
2427
|
+
type: gi(n),
|
|
2418
2428
|
arrayType: n
|
|
2419
2429
|
};
|
|
2420
2430
|
}
|
|
2421
|
-
function
|
|
2422
|
-
const n =
|
|
2431
|
+
function bc(r, e, t) {
|
|
2432
|
+
const n = Ai(e, t);
|
|
2423
2433
|
return {
|
|
2424
2434
|
arrayType: n.constructor,
|
|
2425
|
-
buffer:
|
|
2426
|
-
type:
|
|
2435
|
+
buffer: _i(r, n, void 0, e.drawType),
|
|
2436
|
+
type: qr(n),
|
|
2427
2437
|
numValues: 0
|
|
2428
2438
|
};
|
|
2429
2439
|
}
|
|
2430
|
-
function
|
|
2440
|
+
function wc(r, e) {
|
|
2431
2441
|
const t = {};
|
|
2432
2442
|
return Object.keys(e).forEach(function(n) {
|
|
2433
|
-
if (!
|
|
2434
|
-
const i = e[n], o = i.attrib || i.name || i.attribName ||
|
|
2443
|
+
if (!Ei(n)) {
|
|
2444
|
+
const i = e[n], o = i.attrib || i.name || i.attribName || vi.attribPrefix + n;
|
|
2435
2445
|
if (i.value) {
|
|
2436
2446
|
if (!Array.isArray(i.value) && !Yt(i.value))
|
|
2437
2447
|
throw new Error("array.value is not array or typedarray");
|
|
@@ -2440,8 +2450,8 @@ function gc(r, e) {
|
|
|
2440
2450
|
};
|
|
2441
2451
|
} else {
|
|
2442
2452
|
let s;
|
|
2443
|
-
i.buffer && i.buffer instanceof WebGLBuffer ? s =
|
|
2444
|
-
const { buffer: a, type: c, numValues: u, arrayType: f } = s(r, i, n), m = i.normalize !== void 0 ? i.normalize :
|
|
2453
|
+
i.buffer && i.buffer instanceof WebGLBuffer ? s = gc : typeof i == "number" || typeof i.data == "number" ? s = yc : s = bc;
|
|
2454
|
+
const { buffer: a, type: c, numValues: u, arrayType: f } = s(r, i, n), m = i.normalize !== void 0 ? i.normalize : uc(f), p = mc(i, n, u);
|
|
2445
2455
|
t[o] = {
|
|
2446
2456
|
buffer: a,
|
|
2447
2457
|
numComponents: p,
|
|
@@ -2456,40 +2466,40 @@ function gc(r, e) {
|
|
|
2456
2466
|
}
|
|
2457
2467
|
}), r.bindBuffer(xe, null), t;
|
|
2458
2468
|
}
|
|
2459
|
-
function
|
|
2460
|
-
return e ===
|
|
2469
|
+
function xc(r, e) {
|
|
2470
|
+
return e === rc || e === nc ? 1 : e === ic || e === oc ? 2 : e === sc || e === ac || e === xi ? 4 : 0;
|
|
2461
2471
|
}
|
|
2462
|
-
const
|
|
2463
|
-
function
|
|
2472
|
+
const wr = ["position", "positions", "a_position"];
|
|
2473
|
+
function vc(r, e) {
|
|
2464
2474
|
let t, n;
|
|
2465
|
-
for (n = 0; n <
|
|
2475
|
+
for (n = 0; n < wr.length && (t = wr[n], !(t in e || (t = vi.attribPrefix + t, t in e))); ++n)
|
|
2466
2476
|
;
|
|
2467
|
-
n ===
|
|
2477
|
+
n === wr.length && (t = Object.keys(e)[0]);
|
|
2468
2478
|
const i = e[t];
|
|
2469
2479
|
if (!i.buffer)
|
|
2470
2480
|
return 1;
|
|
2471
2481
|
r.bindBuffer(xe, i.buffer);
|
|
2472
|
-
const o = r.getBufferParameter(xe,
|
|
2482
|
+
const o = r.getBufferParameter(xe, tc);
|
|
2473
2483
|
r.bindBuffer(xe, null);
|
|
2474
|
-
const s =
|
|
2484
|
+
const s = xc(r, i.type), a = o / s, c = i.numComponents || i.size, u = a / c;
|
|
2475
2485
|
if (u % 1 !== 0)
|
|
2476
2486
|
throw new Error(`numComponents ${c} not correct for length ${length}`);
|
|
2477
2487
|
return u;
|
|
2478
2488
|
}
|
|
2479
|
-
function
|
|
2480
|
-
const n =
|
|
2489
|
+
function _c(r, e, t) {
|
|
2490
|
+
const n = wc(r, e), i = Object.assign({}, t || {});
|
|
2481
2491
|
i.attribs = Object.assign({}, t ? t.attribs : {}, n);
|
|
2482
2492
|
const o = e.indices;
|
|
2483
2493
|
if (o) {
|
|
2484
|
-
const s =
|
|
2485
|
-
i.indices =
|
|
2486
|
-
} else i.numElements || (i.numElements =
|
|
2494
|
+
const s = Ai(o, "indices");
|
|
2495
|
+
i.indices = _i(r, s, ec), i.numElements = s.length, i.elementType = qr(s);
|
|
2496
|
+
} else i.numElements || (i.numElements = vc(r, i.attribs));
|
|
2487
2497
|
return i;
|
|
2488
2498
|
}
|
|
2489
2499
|
function rt(r) {
|
|
2490
2500
|
return !!r.texStorage2D;
|
|
2491
2501
|
}
|
|
2492
|
-
const
|
|
2502
|
+
const Ti = /* @__PURE__ */ (function() {
|
|
2493
2503
|
const r = {}, e = {};
|
|
2494
2504
|
function t(n) {
|
|
2495
2505
|
const i = n.constructor.name;
|
|
@@ -2509,27 +2519,27 @@ const Ii = /* @__PURE__ */ (function() {
|
|
|
2509
2519
|
textureColor: new Uint8Array([128, 192, 255, 255]),
|
|
2510
2520
|
textureOptions: {},
|
|
2511
2521
|
crossOrigin: void 0
|
|
2512
|
-
}, Ke = Yt,
|
|
2522
|
+
}, Ke = Yt, Si = /* @__PURE__ */ (function() {
|
|
2513
2523
|
let r;
|
|
2514
2524
|
return function() {
|
|
2515
2525
|
return r = r || (typeof document < "u" && document.createElement ? document.createElement("canvas").getContext("2d") : null), r;
|
|
2516
2526
|
};
|
|
2517
|
-
})(),
|
|
2518
|
-
let
|
|
2527
|
+
})(), 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;
|
|
2528
|
+
let vr;
|
|
2519
2529
|
function er(r) {
|
|
2520
|
-
if (!
|
|
2530
|
+
if (!vr) {
|
|
2521
2531
|
const e = {};
|
|
2522
|
-
e[
|
|
2532
|
+
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) {
|
|
2523
2533
|
const n = e[t];
|
|
2524
2534
|
n.bytesPerElementMap = {}, n.bytesPerElement.forEach(function(i, o) {
|
|
2525
2535
|
const s = n.type[o];
|
|
2526
2536
|
n.bytesPerElementMap[s] = i;
|
|
2527
2537
|
});
|
|
2528
|
-
}),
|
|
2538
|
+
}), vr = e;
|
|
2529
2539
|
}
|
|
2530
|
-
return
|
|
2540
|
+
return vr[r];
|
|
2531
2541
|
}
|
|
2532
|
-
function
|
|
2542
|
+
function Gu(r, e) {
|
|
2533
2543
|
const t = er(r);
|
|
2534
2544
|
if (!t)
|
|
2535
2545
|
throw "unknown internal format";
|
|
@@ -2547,25 +2557,25 @@ function nt(r) {
|
|
|
2547
2557
|
type: e.type[0]
|
|
2548
2558
|
};
|
|
2549
2559
|
}
|
|
2550
|
-
function
|
|
2560
|
+
function Kn(r) {
|
|
2551
2561
|
return (r & r - 1) === 0;
|
|
2552
2562
|
}
|
|
2553
|
-
function
|
|
2563
|
+
function Vu(r, e, t, n) {
|
|
2554
2564
|
if (!rt(r))
|
|
2555
|
-
return
|
|
2565
|
+
return Kn(e) && Kn(t);
|
|
2556
2566
|
const i = er(n);
|
|
2557
2567
|
if (!i)
|
|
2558
2568
|
throw "unknown internal format";
|
|
2559
2569
|
return i.colorRenderable && i.textureFilterable;
|
|
2560
2570
|
}
|
|
2561
|
-
function
|
|
2571
|
+
function Hu(r) {
|
|
2562
2572
|
const e = er(r);
|
|
2563
2573
|
if (!e)
|
|
2564
2574
|
throw "unknown internal format";
|
|
2565
2575
|
return e.textureFilterable;
|
|
2566
2576
|
}
|
|
2567
|
-
function
|
|
2568
|
-
return Ke(e) ?
|
|
2577
|
+
function ju(r, e, t) {
|
|
2578
|
+
return Ke(e) ? qr(e) : t || A;
|
|
2569
2579
|
}
|
|
2570
2580
|
function Et(r, e, t, n, i) {
|
|
2571
2581
|
if (i % 1 !== 0)
|
|
@@ -2584,53 +2594,53 @@ function Et(r, e, t, n, i) {
|
|
|
2584
2594
|
};
|
|
2585
2595
|
}
|
|
2586
2596
|
function Ne(r, e) {
|
|
2587
|
-
e.colorspaceConversion !== void 0 && r.pixelStorei(
|
|
2597
|
+
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);
|
|
2588
2598
|
}
|
|
2589
|
-
function
|
|
2590
|
-
r.pixelStorei(
|
|
2599
|
+
function Ci(r) {
|
|
2600
|
+
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));
|
|
2591
2601
|
}
|
|
2592
|
-
function
|
|
2593
|
-
n.minMag && (t.call(r, e,
|
|
2602
|
+
function Yu(r, e, t, n) {
|
|
2603
|
+
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);
|
|
2594
2604
|
}
|
|
2595
|
-
function
|
|
2605
|
+
function Oi(r, e, t) {
|
|
2596
2606
|
const n = t.target || ce;
|
|
2597
|
-
r.bindTexture(n, e),
|
|
2607
|
+
r.bindTexture(n, e), Yu(r, n, r.texParameteri, t);
|
|
2598
2608
|
}
|
|
2599
|
-
function
|
|
2609
|
+
function Qu(r) {
|
|
2600
2610
|
return r = r || ae.textureColor, Ke(r) ? r : new Uint8Array([r[0] * 255, r[1] * 255, r[2] * 255, r[3] * 255]);
|
|
2601
2611
|
}
|
|
2602
|
-
function
|
|
2612
|
+
function Rr(r, e, t, n, i, o) {
|
|
2603
2613
|
t = t || ae.textureOptions, o = o || T;
|
|
2604
2614
|
const s = t.target || ce;
|
|
2605
|
-
if (n = n || t.width, i = i || t.height, r.bindTexture(s, e),
|
|
2615
|
+
if (n = n || t.width, i = i || t.height, r.bindTexture(s, e), Vu(r, n, i, o))
|
|
2606
2616
|
r.generateMipmap(s);
|
|
2607
2617
|
else {
|
|
2608
|
-
const a =
|
|
2609
|
-
r.texParameteri(s,
|
|
2618
|
+
const a = Hu(o) ? Ac : Ec;
|
|
2619
|
+
r.texParameteri(s, Sr, a), r.texParameteri(s, Ir, a), r.texParameteri(s, qt, Qt), r.texParameteri(s, Xt, Qt);
|
|
2610
2620
|
}
|
|
2611
2621
|
}
|
|
2612
2622
|
function Je(r) {
|
|
2613
2623
|
return r.auto === !0 || r.auto === void 0 && r.level === void 0;
|
|
2614
2624
|
}
|
|
2615
|
-
function
|
|
2625
|
+
function kr(r, e) {
|
|
2616
2626
|
return e = e || {}, e.cubeFaceOrder || [
|
|
2617
|
-
|
|
2618
|
-
_c,
|
|
2619
|
-
Ec,
|
|
2620
|
-
Ac,
|
|
2627
|
+
Jr,
|
|
2621
2628
|
Tc,
|
|
2622
|
-
Sc
|
|
2629
|
+
Sc,
|
|
2630
|
+
Ic,
|
|
2631
|
+
Rc,
|
|
2632
|
+
kc
|
|
2623
2633
|
];
|
|
2624
2634
|
}
|
|
2625
|
-
function
|
|
2626
|
-
const n =
|
|
2635
|
+
function Pr(r, e) {
|
|
2636
|
+
const n = kr(r, e).map(function(i, o) {
|
|
2627
2637
|
return { face: i, ndx: o };
|
|
2628
2638
|
});
|
|
2629
2639
|
return n.sort(function(i, o) {
|
|
2630
2640
|
return i.face - o.face;
|
|
2631
2641
|
}), n;
|
|
2632
2642
|
}
|
|
2633
|
-
function
|
|
2643
|
+
function Mi(r, e, t, n) {
|
|
2634
2644
|
n = n || ae.textureOptions;
|
|
2635
2645
|
const i = n.target || ce, o = n.level || 0;
|
|
2636
2646
|
let s = t.width, a = t.height;
|
|
@@ -2648,17 +2658,17 @@ function Di(r, e, t, n) {
|
|
|
2648
2658
|
d = p / 2, g = [0, 0, 1, 0, 0, 1, 1, 1, 0, 2, 1, 2];
|
|
2649
2659
|
else
|
|
2650
2660
|
throw "can't figure out cube map from element: " + (t.src ? t.src : t.nodeName);
|
|
2651
|
-
const x =
|
|
2652
|
-
x ? (x.canvas.width = d, x.canvas.height = d, s = d, a = d,
|
|
2653
|
-
const
|
|
2654
|
-
x.drawImage(t,
|
|
2655
|
-
}), x.canvas.width = 1, x.canvas.height = 1) : typeof createImageBitmap < "u" && (s = d, a = d,
|
|
2656
|
-
const
|
|
2657
|
-
r.texImage2D(v.face, o, c, d, d, 0, f, m, null), createImageBitmap(t,
|
|
2661
|
+
const x = Si();
|
|
2662
|
+
x ? (x.canvas.width = d, x.canvas.height = d, s = d, a = d, Pr(r, n).forEach(function(v) {
|
|
2663
|
+
const R = g[v.ndx * 2 + 0] * d, k = g[v.ndx * 2 + 1] * d;
|
|
2664
|
+
x.drawImage(t, R, k, d, d, 0, 0, d, d), r.texImage2D(v.face, o, c, f, m, x.canvas);
|
|
2665
|
+
}), x.canvas.width = 1, x.canvas.height = 1) : typeof createImageBitmap < "u" && (s = d, a = d, Pr(r, n).forEach(function(v) {
|
|
2666
|
+
const R = g[v.ndx * 2 + 0] * d, k = g[v.ndx * 2 + 1] * d;
|
|
2667
|
+
r.texImage2D(v.face, o, c, d, d, 0, f, m, null), createImageBitmap(t, R, k, d, d, {
|
|
2658
2668
|
premultiplyAlpha: "none",
|
|
2659
2669
|
colorSpaceConversion: "none"
|
|
2660
2670
|
}).then(function(L) {
|
|
2661
|
-
Ne(r, n), r.bindTexture(i, e), r.texImage2D(v.face, o, c, f, m, L), Je(n) &&
|
|
2671
|
+
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);
|
|
2662
2672
|
});
|
|
2663
2673
|
}));
|
|
2664
2674
|
} else if (i === _e || i === Ee) {
|
|
@@ -2666,19 +2676,19 @@ function Di(r, e, t, n) {
|
|
|
2666
2676
|
if (d % 1 !== 0)
|
|
2667
2677
|
throw "can not compute 3D dimensions of element";
|
|
2668
2678
|
const g = t.width === b ? 1 : 0, x = t.height === b ? 1 : 0;
|
|
2669
|
-
r.pixelStorei(
|
|
2679
|
+
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);
|
|
2670
2680
|
for (let v = 0; v < d; ++v) {
|
|
2671
|
-
const
|
|
2672
|
-
r.pixelStorei(
|
|
2681
|
+
const R = v * p * g, k = v * p * x;
|
|
2682
|
+
r.pixelStorei(ki, R), r.pixelStorei(Pi, k), r.texSubImage3D(i, o, 0, 0, v, p, p, 1, f, m, t);
|
|
2673
2683
|
}
|
|
2674
|
-
|
|
2684
|
+
Ci(r);
|
|
2675
2685
|
} else
|
|
2676
2686
|
r.texImage2D(i, o, c, f, m, t);
|
|
2677
|
-
Je(n) &&
|
|
2687
|
+
Je(n) && Rr(r, e, n, s, a, c), Oi(r, e, n);
|
|
2678
2688
|
}
|
|
2679
2689
|
function it() {
|
|
2680
2690
|
}
|
|
2681
|
-
function
|
|
2691
|
+
function qu(r) {
|
|
2682
2692
|
if (typeof document < "u") {
|
|
2683
2693
|
const e = document.createElement("a");
|
|
2684
2694
|
return e.href = r, e.hostname === location.hostname && e.port === location.port && e.protocol === location.protocol;
|
|
@@ -2687,19 +2697,19 @@ function ju(r) {
|
|
|
2687
2697
|
return new URL(r, location.href).origin === e;
|
|
2688
2698
|
}
|
|
2689
2699
|
}
|
|
2690
|
-
function
|
|
2691
|
-
return e === void 0 && !
|
|
2700
|
+
function Xu(r, e) {
|
|
2701
|
+
return e === void 0 && !qu(r) ? "anonymous" : e;
|
|
2692
2702
|
}
|
|
2693
|
-
function
|
|
2703
|
+
function Ku(r, e, t) {
|
|
2694
2704
|
t = t || it;
|
|
2695
2705
|
let n;
|
|
2696
|
-
if (e = e !== void 0 ? e : ae.crossOrigin, e =
|
|
2706
|
+
if (e = e !== void 0 ? e : ae.crossOrigin, e = Xu(r, e), typeof Image < "u") {
|
|
2697
2707
|
n = new Image(), e !== void 0 && (n.crossOrigin = e);
|
|
2698
2708
|
const i = function() {
|
|
2699
2709
|
n.removeEventListener("error", o), n.removeEventListener("load", s), n = null;
|
|
2700
2710
|
}, o = function() {
|
|
2701
2711
|
const c = "couldn't load image: " + r;
|
|
2702
|
-
|
|
2712
|
+
bi(c), t(c, n), i();
|
|
2703
2713
|
}, s = function() {
|
|
2704
2714
|
t(null, n), i();
|
|
2705
2715
|
};
|
|
@@ -2726,31 +2736,31 @@ function Qu(r, e, t) {
|
|
|
2726
2736
|
}
|
|
2727
2737
|
return n;
|
|
2728
2738
|
}
|
|
2729
|
-
function
|
|
2739
|
+
function Bi(r) {
|
|
2730
2740
|
return typeof ImageBitmap < "u" && r instanceof ImageBitmap || typeof ImageData < "u" && r instanceof ImageData || typeof HTMLElement < "u" && r instanceof HTMLElement;
|
|
2731
2741
|
}
|
|
2732
|
-
function
|
|
2733
|
-
return
|
|
2742
|
+
function en(r, e, t) {
|
|
2743
|
+
return Bi(r) ? (setTimeout(function() {
|
|
2734
2744
|
t(null, r);
|
|
2735
|
-
}), r) :
|
|
2745
|
+
}), r) : Ku(r, e, t);
|
|
2736
2746
|
}
|
|
2737
|
-
function
|
|
2747
|
+
function tn(r, e, t) {
|
|
2738
2748
|
t = t || ae.textureOptions;
|
|
2739
2749
|
const n = t.target || ce;
|
|
2740
2750
|
if (r.bindTexture(n, e), t.color === !1)
|
|
2741
2751
|
return;
|
|
2742
|
-
const i =
|
|
2752
|
+
const i = Qu(t.color);
|
|
2743
2753
|
if (n === se)
|
|
2744
2754
|
for (let o = 0; o < 6; ++o)
|
|
2745
|
-
r.texImage2D(
|
|
2755
|
+
r.texImage2D(Jr + o, 0, T, 1, 1, 0, T, A, i);
|
|
2746
2756
|
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);
|
|
2747
2757
|
}
|
|
2748
|
-
function
|
|
2749
|
-
return n = n || it, t = t || ae.textureOptions,
|
|
2750
|
-
o ? n(o, e, s) : (
|
|
2758
|
+
function Ju(r, e, t, n) {
|
|
2759
|
+
return n = n || it, t = t || ae.textureOptions, tn(r, e, t), t = Object.assign({}, t), en(t.src, t.crossOrigin, function(o, s) {
|
|
2760
|
+
o ? n(o, e, s) : (Mi(r, e, s, t), n(null, e, s));
|
|
2751
2761
|
});
|
|
2752
2762
|
}
|
|
2753
|
-
function
|
|
2763
|
+
function Zu(r, e, t, n) {
|
|
2754
2764
|
n = n || it;
|
|
2755
2765
|
const i = t.src;
|
|
2756
2766
|
if (i.length !== 6)
|
|
@@ -2758,27 +2768,27 @@ function Xu(r, e, t, n) {
|
|
|
2758
2768
|
const o = t.level || 0, s = t.internalFormat || t.format || T, a = nt(s), c = t.format || a.format, u = t.type || A, f = t.target || ce;
|
|
2759
2769
|
if (f !== se)
|
|
2760
2770
|
throw "target must be TEXTURE_CUBE_MAP";
|
|
2761
|
-
|
|
2771
|
+
tn(r, e, t), t = Object.assign({}, t);
|
|
2762
2772
|
let m = 6;
|
|
2763
|
-
const p = [], b =
|
|
2773
|
+
const p = [], b = kr(r, t);
|
|
2764
2774
|
let d;
|
|
2765
2775
|
function g(x) {
|
|
2766
|
-
return function(v,
|
|
2767
|
-
--m, v ? p.push(v) :
|
|
2768
|
-
r.texImage2D(
|
|
2769
|
-
}) : r.texImage2D(x, o, s, c, u,
|
|
2776
|
+
return function(v, R) {
|
|
2777
|
+
--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) {
|
|
2778
|
+
r.texImage2D(k, o, s, c, u, R);
|
|
2779
|
+
}) : r.texImage2D(x, o, s, c, u, R), Je(t) && r.generateMipmap(f)), m === 0 && n(p.length ? p : void 0, e, d);
|
|
2770
2780
|
};
|
|
2771
2781
|
}
|
|
2772
2782
|
d = i.map(function(x, v) {
|
|
2773
|
-
return
|
|
2783
|
+
return en(x, t.crossOrigin, g(b[v]));
|
|
2774
2784
|
});
|
|
2775
2785
|
}
|
|
2776
|
-
function
|
|
2786
|
+
function el(r, e, t, n) {
|
|
2777
2787
|
n = n || it;
|
|
2778
2788
|
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;
|
|
2779
2789
|
if (u !== _e && u !== Ee)
|
|
2780
2790
|
throw "target must be TEXTURE_3D or TEXTURE_2D_ARRAY";
|
|
2781
|
-
|
|
2791
|
+
tn(r, e, t), t = Object.assign({}, t);
|
|
2782
2792
|
let f = i.length;
|
|
2783
2793
|
const m = [];
|
|
2784
2794
|
let p;
|
|
@@ -2786,7 +2796,7 @@ function Ku(r, e, t, n) {
|
|
|
2786
2796
|
let d = t.width, g = t.height;
|
|
2787
2797
|
const x = i.length;
|
|
2788
2798
|
let v = !0;
|
|
2789
|
-
function k
|
|
2799
|
+
function R(k) {
|
|
2790
2800
|
return function(L, Y) {
|
|
2791
2801
|
if (--f, L)
|
|
2792
2802
|
m.push(L);
|
|
@@ -2797,32 +2807,32 @@ function Ku(r, e, t, n) {
|
|
|
2797
2807
|
r.texSubImage3D(u, b, 0, 0, Q, d, g, 1, a, c, Y);
|
|
2798
2808
|
} else {
|
|
2799
2809
|
let Q = Y, N;
|
|
2800
|
-
(Y.width !== d || Y.height !== g) && (N =
|
|
2810
|
+
(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);
|
|
2801
2811
|
}
|
|
2802
2812
|
Je(t) && r.generateMipmap(u);
|
|
2803
2813
|
}
|
|
2804
2814
|
f === 0 && n(m.length ? m : void 0, e, p);
|
|
2805
2815
|
};
|
|
2806
2816
|
}
|
|
2807
|
-
p = i.map(function(
|
|
2808
|
-
return
|
|
2817
|
+
p = i.map(function(k, L) {
|
|
2818
|
+
return en(k, t.crossOrigin, R(L));
|
|
2809
2819
|
});
|
|
2810
2820
|
}
|
|
2811
|
-
function
|
|
2821
|
+
function tl(r, e, t, n) {
|
|
2812
2822
|
n = n || ae.textureOptions;
|
|
2813
2823
|
const i = n.target || ce;
|
|
2814
2824
|
r.bindTexture(i, e);
|
|
2815
2825
|
let o = n.width, s = n.height, a = n.depth;
|
|
2816
|
-
const c = n.level || 0, u = n.internalFormat || n.format || T, f = nt(u), m = n.format || f.format, p = n.type ||
|
|
2826
|
+
const c = n.level || 0, u = n.internalFormat || n.format || T, f = nt(u), m = n.format || f.format, p = n.type || ju(r, t, f.type);
|
|
2817
2827
|
if (Ke(t))
|
|
2818
2828
|
t instanceof Uint8ClampedArray && (t = new Uint8Array(t.buffer));
|
|
2819
2829
|
else {
|
|
2820
|
-
const x =
|
|
2830
|
+
const x = yi(p);
|
|
2821
2831
|
t = new x(t);
|
|
2822
2832
|
}
|
|
2823
|
-
const b =
|
|
2833
|
+
const b = Gu(u, p), d = t.byteLength / b;
|
|
2824
2834
|
if (d % 1)
|
|
2825
|
-
throw "length wrong size for format: " +
|
|
2835
|
+
throw "length wrong size for format: " + Ti(r, m);
|
|
2826
2836
|
let g;
|
|
2827
2837
|
if (i === _e || i === Ee)
|
|
2828
2838
|
if (!o && !s && !a) {
|
|
@@ -2833,11 +2843,11 @@ function Ju(r, e, t, n) {
|
|
|
2833
2843
|
} 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);
|
|
2834
2844
|
else
|
|
2835
2845
|
g = Et(r, i, o, s, d), o = g.width, s = g.height;
|
|
2836
|
-
if (
|
|
2846
|
+
if (Ci(r), r.pixelStorei(Zr, n.unpackAlignment || 1), Ne(r, n), i === se) {
|
|
2837
2847
|
const x = b / t.BYTES_PER_ELEMENT, v = d / 6 * x;
|
|
2838
|
-
|
|
2839
|
-
const
|
|
2840
|
-
r.texImage2D(
|
|
2848
|
+
Pr(r, n).forEach((R) => {
|
|
2849
|
+
const k = v * R.ndx, L = t.subarray(k, k + v);
|
|
2850
|
+
r.texImage2D(R.face, c, u, o, s, 0, m, p, L);
|
|
2841
2851
|
});
|
|
2842
2852
|
} 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);
|
|
2843
2853
|
return {
|
|
@@ -2847,16 +2857,16 @@ function Ju(r, e, t, n) {
|
|
|
2847
2857
|
type: p
|
|
2848
2858
|
};
|
|
2849
2859
|
}
|
|
2850
|
-
function
|
|
2860
|
+
function rl(r, e, t) {
|
|
2851
2861
|
const n = t.target || ce;
|
|
2852
2862
|
r.bindTexture(n, e);
|
|
2853
2863
|
const i = t.level || 0, o = t.internalFormat || t.format || T, s = nt(o), a = t.format || s.format, c = t.type || s.type;
|
|
2854
2864
|
if (Ne(r, t), n === se)
|
|
2855
2865
|
for (let u = 0; u < 6; ++u)
|
|
2856
|
-
r.texImage2D(
|
|
2866
|
+
r.texImage2D(Jr + u, i, o, t.width, t.height, 0, a, c, null);
|
|
2857
2867
|
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);
|
|
2858
2868
|
}
|
|
2859
|
-
function
|
|
2869
|
+
function Di(r, e, t) {
|
|
2860
2870
|
t = t || it, e = e || ae.textureOptions;
|
|
2861
2871
|
const n = r.createTexture(), i = e.target || ce;
|
|
2862
2872
|
let o = e.width || 1, s = e.height || 1;
|
|
@@ -2865,161 +2875,161 @@ function Li(r, e, t) {
|
|
|
2865
2875
|
let c = e.src;
|
|
2866
2876
|
if (c)
|
|
2867
2877
|
if (typeof c == "function" && (c = c(r, e)), typeof c == "string")
|
|
2868
|
-
|
|
2878
|
+
Ju(r, n, e, t);
|
|
2869
2879
|
else if (Ke(c) || Array.isArray(c) && (typeof c[0] == "number" || Array.isArray(c[0]) || Ke(c[0]))) {
|
|
2870
|
-
const u =
|
|
2880
|
+
const u = tl(r, n, c, e);
|
|
2871
2881
|
o = u.width, s = u.height;
|
|
2872
|
-
} else Array.isArray(c) && (typeof c[0] == "string" ||
|
|
2882
|
+
} 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);
|
|
2873
2883
|
else
|
|
2874
|
-
|
|
2875
|
-
return Je(e) &&
|
|
2884
|
+
rl(r, n, e);
|
|
2885
|
+
return Je(e) && Rr(r, n, e, o, s, a), Oi(r, n, e), n;
|
|
2876
2886
|
}
|
|
2877
|
-
const
|
|
2878
|
-
function
|
|
2887
|
+
const rn = bi;
|
|
2888
|
+
function Ui(r) {
|
|
2879
2889
|
return typeof document < "u" && document.getElementById ? document.getElementById(r) : null;
|
|
2880
2890
|
}
|
|
2881
|
-
const Kt = 33984, tr = 34962,
|
|
2882
|
-
function
|
|
2891
|
+
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 = {};
|
|
2892
|
+
function to(r, e) {
|
|
2883
2893
|
return w[e].bindPoint;
|
|
2884
2894
|
}
|
|
2885
|
-
function
|
|
2895
|
+
function Ul(r, e) {
|
|
2886
2896
|
return function(t) {
|
|
2887
2897
|
r.uniform1f(e, t);
|
|
2888
2898
|
};
|
|
2889
2899
|
}
|
|
2890
|
-
function
|
|
2900
|
+
function Ll(r, e) {
|
|
2891
2901
|
return function(t) {
|
|
2892
2902
|
r.uniform1fv(e, t);
|
|
2893
2903
|
};
|
|
2894
2904
|
}
|
|
2895
|
-
function
|
|
2905
|
+
function zl(r, e) {
|
|
2896
2906
|
return function(t) {
|
|
2897
2907
|
r.uniform2fv(e, t);
|
|
2898
2908
|
};
|
|
2899
2909
|
}
|
|
2900
|
-
function
|
|
2910
|
+
function Nl(r, e) {
|
|
2901
2911
|
return function(t) {
|
|
2902
2912
|
r.uniform3fv(e, t);
|
|
2903
2913
|
};
|
|
2904
2914
|
}
|
|
2905
|
-
function
|
|
2915
|
+
function $l(r, e) {
|
|
2906
2916
|
return function(t) {
|
|
2907
2917
|
r.uniform4fv(e, t);
|
|
2908
2918
|
};
|
|
2909
2919
|
}
|
|
2910
|
-
function
|
|
2920
|
+
function ro(r, e) {
|
|
2911
2921
|
return function(t) {
|
|
2912
2922
|
r.uniform1i(e, t);
|
|
2913
2923
|
};
|
|
2914
2924
|
}
|
|
2915
|
-
function
|
|
2925
|
+
function no(r, e) {
|
|
2916
2926
|
return function(t) {
|
|
2917
2927
|
r.uniform1iv(e, t);
|
|
2918
2928
|
};
|
|
2919
2929
|
}
|
|
2920
|
-
function
|
|
2930
|
+
function io(r, e) {
|
|
2921
2931
|
return function(t) {
|
|
2922
2932
|
r.uniform2iv(e, t);
|
|
2923
2933
|
};
|
|
2924
2934
|
}
|
|
2925
|
-
function
|
|
2935
|
+
function oo(r, e) {
|
|
2926
2936
|
return function(t) {
|
|
2927
2937
|
r.uniform3iv(e, t);
|
|
2928
2938
|
};
|
|
2929
2939
|
}
|
|
2930
|
-
function
|
|
2940
|
+
function so(r, e) {
|
|
2931
2941
|
return function(t) {
|
|
2932
2942
|
r.uniform4iv(e, t);
|
|
2933
2943
|
};
|
|
2934
2944
|
}
|
|
2935
|
-
function
|
|
2945
|
+
function Wl(r, e) {
|
|
2936
2946
|
return function(t) {
|
|
2937
2947
|
r.uniform1ui(e, t);
|
|
2938
2948
|
};
|
|
2939
2949
|
}
|
|
2940
|
-
function
|
|
2950
|
+
function Gl(r, e) {
|
|
2941
2951
|
return function(t) {
|
|
2942
2952
|
r.uniform1uiv(e, t);
|
|
2943
2953
|
};
|
|
2944
2954
|
}
|
|
2945
|
-
function
|
|
2955
|
+
function Vl(r, e) {
|
|
2946
2956
|
return function(t) {
|
|
2947
2957
|
r.uniform2uiv(e, t);
|
|
2948
2958
|
};
|
|
2949
2959
|
}
|
|
2950
|
-
function
|
|
2960
|
+
function Hl(r, e) {
|
|
2951
2961
|
return function(t) {
|
|
2952
2962
|
r.uniform3uiv(e, t);
|
|
2953
2963
|
};
|
|
2954
2964
|
}
|
|
2955
|
-
function
|
|
2965
|
+
function jl(r, e) {
|
|
2956
2966
|
return function(t) {
|
|
2957
2967
|
r.uniform4uiv(e, t);
|
|
2958
2968
|
};
|
|
2959
2969
|
}
|
|
2960
|
-
function
|
|
2970
|
+
function Yl(r, e) {
|
|
2961
2971
|
return function(t) {
|
|
2962
2972
|
r.uniformMatrix2fv(e, !1, t);
|
|
2963
2973
|
};
|
|
2964
2974
|
}
|
|
2965
|
-
function
|
|
2975
|
+
function Ql(r, e) {
|
|
2966
2976
|
return function(t) {
|
|
2967
2977
|
r.uniformMatrix3fv(e, !1, t);
|
|
2968
2978
|
};
|
|
2969
2979
|
}
|
|
2970
|
-
function
|
|
2980
|
+
function ql(r, e) {
|
|
2971
2981
|
return function(t) {
|
|
2972
2982
|
r.uniformMatrix4fv(e, !1, t);
|
|
2973
2983
|
};
|
|
2974
2984
|
}
|
|
2975
|
-
function
|
|
2985
|
+
function Xl(r, e) {
|
|
2976
2986
|
return function(t) {
|
|
2977
2987
|
r.uniformMatrix2x3fv(e, !1, t);
|
|
2978
2988
|
};
|
|
2979
2989
|
}
|
|
2980
|
-
function
|
|
2990
|
+
function Kl(r, e) {
|
|
2981
2991
|
return function(t) {
|
|
2982
2992
|
r.uniformMatrix3x2fv(e, !1, t);
|
|
2983
2993
|
};
|
|
2984
2994
|
}
|
|
2985
|
-
function
|
|
2995
|
+
function Jl(r, e) {
|
|
2986
2996
|
return function(t) {
|
|
2987
2997
|
r.uniformMatrix2x4fv(e, !1, t);
|
|
2988
2998
|
};
|
|
2989
2999
|
}
|
|
2990
|
-
function
|
|
3000
|
+
function Zl(r, e) {
|
|
2991
3001
|
return function(t) {
|
|
2992
3002
|
r.uniformMatrix4x2fv(e, !1, t);
|
|
2993
3003
|
};
|
|
2994
3004
|
}
|
|
2995
|
-
function
|
|
3005
|
+
function ef(r, e) {
|
|
2996
3006
|
return function(t) {
|
|
2997
3007
|
r.uniformMatrix3x4fv(e, !1, t);
|
|
2998
3008
|
};
|
|
2999
3009
|
}
|
|
3000
|
-
function
|
|
3010
|
+
function tf(r, e) {
|
|
3001
3011
|
return function(t) {
|
|
3002
3012
|
r.uniformMatrix4x3fv(e, !1, t);
|
|
3003
3013
|
};
|
|
3004
3014
|
}
|
|
3005
3015
|
function D(r, e, t, n) {
|
|
3006
|
-
const i =
|
|
3016
|
+
const i = to(r, e);
|
|
3007
3017
|
return rt(r) ? function(o) {
|
|
3008
3018
|
let s, a;
|
|
3009
|
-
!o ||
|
|
3019
|
+
!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);
|
|
3010
3020
|
} : function(o) {
|
|
3011
3021
|
r.uniform1i(n, t), r.activeTexture(Kt + t), r.bindTexture(i, o);
|
|
3012
3022
|
};
|
|
3013
3023
|
}
|
|
3014
3024
|
function U(r, e, t, n, i) {
|
|
3015
|
-
const o =
|
|
3025
|
+
const o = to(r, e), s = new Int32Array(i);
|
|
3016
3026
|
for (let a = 0; a < i; ++a)
|
|
3017
3027
|
s[a] = t + a;
|
|
3018
3028
|
return rt(r) ? function(a) {
|
|
3019
3029
|
r.uniform1iv(n, s), a.forEach(function(c, u) {
|
|
3020
3030
|
r.activeTexture(Kt + s[u]);
|
|
3021
3031
|
let f, m;
|
|
3022
|
-
!c ||
|
|
3032
|
+
!c || Xr(r, c) ? (f = c, m = null) : (f = c.texture, m = c.sampler), r.bindSampler(t, m), r.bindTexture(o, f);
|
|
3023
3033
|
});
|
|
3024
3034
|
} : function(a) {
|
|
3025
3035
|
r.uniform1iv(n, s), a.forEach(function(c, u) {
|
|
@@ -3027,46 +3037,46 @@ function U(r, e, t, n, i) {
|
|
|
3027
3037
|
});
|
|
3028
3038
|
};
|
|
3029
3039
|
}
|
|
3030
|
-
w[rr] = { Type: Float32Array, size: 4, setter:
|
|
3031
|
-
w[
|
|
3032
|
-
w[
|
|
3033
|
-
w[
|
|
3034
|
-
w[
|
|
3035
|
-
w[
|
|
3036
|
-
w[
|
|
3037
|
-
w[
|
|
3038
|
-
w[
|
|
3039
|
-
w[
|
|
3040
|
-
w[
|
|
3041
|
-
w[
|
|
3042
|
-
w[
|
|
3043
|
-
w[
|
|
3044
|
-
w[
|
|
3045
|
-
w[
|
|
3046
|
-
w[
|
|
3047
|
-
w[
|
|
3048
|
-
w[
|
|
3049
|
-
w[
|
|
3050
|
-
w[
|
|
3051
|
-
w[
|
|
3052
|
-
w[
|
|
3053
|
-
w[
|
|
3054
|
-
w[
|
|
3055
|
-
w[hl] = { Type: null, size: 0, setter: D, arraySetter: U, bindPoint: nr };
|
|
3056
|
-
w[ml] = { Type: null, size: 0, setter: D, arraySetter: U, bindPoint: ir };
|
|
3057
|
-
w[pl] = { Type: null, size: 0, setter: D, arraySetter: U, bindPoint: cn };
|
|
3040
|
+
w[rr] = { Type: Float32Array, size: 4, setter: Ul, arraySetter: Ll };
|
|
3041
|
+
w[zi] = { Type: Float32Array, size: 8, setter: zl, cols: 2 };
|
|
3042
|
+
w[Ni] = { Type: Float32Array, size: 12, setter: Nl, cols: 3 };
|
|
3043
|
+
w[$i] = { Type: Float32Array, size: 16, setter: $l, cols: 4 };
|
|
3044
|
+
w[nn] = { Type: Int32Array, size: 4, setter: ro, arraySetter: no };
|
|
3045
|
+
w[Wi] = { Type: Int32Array, size: 8, setter: io, cols: 2 };
|
|
3046
|
+
w[Gi] = { Type: Int32Array, size: 12, setter: oo, cols: 3 };
|
|
3047
|
+
w[Vi] = { Type: Int32Array, size: 16, setter: so, cols: 4 };
|
|
3048
|
+
w[on] = { Type: Uint32Array, size: 4, setter: Wl, arraySetter: Gl };
|
|
3049
|
+
w[Ji] = { Type: Uint32Array, size: 8, setter: Vl, cols: 2 };
|
|
3050
|
+
w[Zi] = { Type: Uint32Array, size: 12, setter: Hl, cols: 3 };
|
|
3051
|
+
w[eo] = { Type: Uint32Array, size: 16, setter: jl, cols: 4 };
|
|
3052
|
+
w[Hi] = { Type: Uint32Array, size: 4, setter: ro, arraySetter: no };
|
|
3053
|
+
w[ji] = { Type: Uint32Array, size: 8, setter: io, cols: 2 };
|
|
3054
|
+
w[Yi] = { Type: Uint32Array, size: 12, setter: oo, cols: 3 };
|
|
3055
|
+
w[Qi] = { Type: Uint32Array, size: 16, setter: so, cols: 4 };
|
|
3056
|
+
w[qi] = { Type: Float32Array, size: 32, setter: Yl, rows: 2, cols: 2 };
|
|
3057
|
+
w[Xi] = { Type: Float32Array, size: 48, setter: Ql, rows: 3, cols: 3 };
|
|
3058
|
+
w[Ki] = { Type: Float32Array, size: 64, setter: ql, rows: 4, cols: 4 };
|
|
3059
|
+
w[xl] = { Type: Float32Array, size: 32, setter: Xl, rows: 2, cols: 3 };
|
|
3060
|
+
w[vl] = { Type: Float32Array, size: 32, setter: Jl, rows: 2, cols: 4 };
|
|
3061
|
+
w[_l] = { Type: Float32Array, size: 48, setter: Kl, rows: 3, cols: 2 };
|
|
3062
|
+
w[El] = { Type: Float32Array, size: 48, setter: ef, rows: 3, cols: 4 };
|
|
3063
|
+
w[Al] = { Type: Float32Array, size: 64, setter: Zl, rows: 4, cols: 2 };
|
|
3064
|
+
w[Tl] = { Type: Float32Array, size: 64, setter: tf, rows: 4, cols: 3 };
|
|
3058
3065
|
w[gl] = { Type: null, size: 0, setter: D, arraySetter: U, bindPoint: nr };
|
|
3059
|
-
w[
|
|
3060
|
-
w[
|
|
3061
|
-
w[
|
|
3062
|
-
w[Sl] = { Type: null, size: 0, setter: D, arraySetter: U, bindPoint:
|
|
3063
|
-
w[Il] = { Type: null, size: 0, setter: D, arraySetter: U, bindPoint:
|
|
3064
|
-
w[
|
|
3065
|
-
w[
|
|
3066
|
-
w[Pl] = { Type: null, size: 0, setter: D, arraySetter: U, bindPoint:
|
|
3067
|
-
w[Fl] = { Type: null, size: 0, setter: D, arraySetter: U, bindPoint:
|
|
3068
|
-
w[Ol] = { Type: null, size: 0, setter: D, arraySetter: U, bindPoint: ir };
|
|
3066
|
+
w[yl] = { Type: null, size: 0, setter: D, arraySetter: U, bindPoint: ir };
|
|
3067
|
+
w[bl] = { Type: null, size: 0, setter: D, arraySetter: U, bindPoint: sn };
|
|
3068
|
+
w[wl] = { Type: null, size: 0, setter: D, arraySetter: U, bindPoint: nr };
|
|
3069
|
+
w[Sl] = { Type: null, size: 0, setter: D, arraySetter: U, bindPoint: or };
|
|
3070
|
+
w[Il] = { Type: null, size: 0, setter: D, arraySetter: U, bindPoint: or };
|
|
3071
|
+
w[Rl] = { Type: null, size: 0, setter: D, arraySetter: U, bindPoint: ir };
|
|
3072
|
+
w[kl] = { Type: null, size: 0, setter: D, arraySetter: U, bindPoint: nr };
|
|
3073
|
+
w[Pl] = { Type: null, size: 0, setter: D, arraySetter: U, bindPoint: sn };
|
|
3074
|
+
w[Fl] = { Type: null, size: 0, setter: D, arraySetter: U, bindPoint: ir };
|
|
3069
3075
|
w[Cl] = { Type: null, size: 0, setter: D, arraySetter: U, bindPoint: or };
|
|
3076
|
+
w[Ol] = { Type: null, size: 0, setter: D, arraySetter: U, bindPoint: nr };
|
|
3077
|
+
w[Ml] = { Type: null, size: 0, setter: D, arraySetter: U, bindPoint: sn };
|
|
3078
|
+
w[Bl] = { Type: null, size: 0, setter: D, arraySetter: U, bindPoint: ir };
|
|
3079
|
+
w[Dl] = { Type: null, size: 0, setter: D, arraySetter: U, bindPoint: or };
|
|
3070
3080
|
function sr(r, e) {
|
|
3071
3081
|
return function(t) {
|
|
3072
3082
|
if (t.value)
|
|
@@ -3108,7 +3118,7 @@ function ue(r, e) {
|
|
|
3108
3118
|
r.bindBuffer(tr, t.buffer), r.enableVertexAttribArray(e), r.vertexAttribIPointer(
|
|
3109
3119
|
e,
|
|
3110
3120
|
t.numComponents || t.size,
|
|
3111
|
-
t.type ||
|
|
3121
|
+
t.type || nn,
|
|
3112
3122
|
t.stride || 0,
|
|
3113
3123
|
t.offset || 0
|
|
3114
3124
|
), r.vertexAttribDivisor && r.vertexAttribDivisor(e, t.divisor || 0);
|
|
@@ -3125,13 +3135,13 @@ function ar(r, e) {
|
|
|
3125
3135
|
r.bindBuffer(tr, t.buffer), r.enableVertexAttribArray(e), r.vertexAttribIPointer(
|
|
3126
3136
|
e,
|
|
3127
3137
|
t.numComponents || t.size,
|
|
3128
|
-
t.type ||
|
|
3138
|
+
t.type || on,
|
|
3129
3139
|
t.stride || 0,
|
|
3130
3140
|
t.offset || 0
|
|
3131
3141
|
), r.vertexAttribDivisor && r.vertexAttribDivisor(e, t.divisor || 0);
|
|
3132
3142
|
};
|
|
3133
3143
|
}
|
|
3134
|
-
function
|
|
3144
|
+
function an(r, e, t) {
|
|
3135
3145
|
const n = t.size, i = t.count;
|
|
3136
3146
|
return function(o) {
|
|
3137
3147
|
r.bindBuffer(tr, o.buffer);
|
|
@@ -3149,27 +3159,27 @@ function un(r, e, t) {
|
|
|
3149
3159
|
}
|
|
3150
3160
|
const I = {};
|
|
3151
3161
|
I[rr] = { size: 4, setter: sr };
|
|
3152
|
-
I[
|
|
3153
|
-
I[
|
|
3154
|
-
I[
|
|
3155
|
-
I[
|
|
3156
|
-
I[
|
|
3157
|
-
I[
|
|
3158
|
-
I[
|
|
3159
|
-
I[
|
|
3160
|
-
I[
|
|
3161
|
-
I[
|
|
3162
|
-
I[
|
|
3163
|
-
I[
|
|
3164
|
-
I[
|
|
3165
|
-
I[
|
|
3166
|
-
I[
|
|
3167
|
-
I[
|
|
3168
|
-
I[
|
|
3169
|
-
I[
|
|
3170
|
-
const
|
|
3171
|
-
function
|
|
3172
|
-
const n = [...e.matchAll(
|
|
3162
|
+
I[zi] = { size: 8, setter: sr };
|
|
3163
|
+
I[Ni] = { size: 12, setter: sr };
|
|
3164
|
+
I[$i] = { size: 16, setter: sr };
|
|
3165
|
+
I[nn] = { size: 4, setter: ue };
|
|
3166
|
+
I[Wi] = { size: 8, setter: ue };
|
|
3167
|
+
I[Gi] = { size: 12, setter: ue };
|
|
3168
|
+
I[Vi] = { size: 16, setter: ue };
|
|
3169
|
+
I[on] = { size: 4, setter: ar };
|
|
3170
|
+
I[Ji] = { size: 8, setter: ar };
|
|
3171
|
+
I[Zi] = { size: 12, setter: ar };
|
|
3172
|
+
I[eo] = { size: 16, setter: ar };
|
|
3173
|
+
I[Hi] = { size: 4, setter: ue };
|
|
3174
|
+
I[ji] = { size: 8, setter: ue };
|
|
3175
|
+
I[Yi] = { size: 12, setter: ue };
|
|
3176
|
+
I[Qi] = { size: 16, setter: ue };
|
|
3177
|
+
I[qi] = { size: 4, setter: an, count: 2 };
|
|
3178
|
+
I[Xi] = { size: 9, setter: an, count: 3 };
|
|
3179
|
+
I[Ki] = { size: 16, setter: an, count: 4 };
|
|
3180
|
+
const rf = /ERROR:\s*\d+:(\d+)/gi;
|
|
3181
|
+
function nf(r, e = "", t = 0) {
|
|
3182
|
+
const n = [...e.matchAll(rf)], i = new Map(n.map((o, s) => {
|
|
3173
3183
|
const a = parseInt(o[1]), c = n[s + 1], u = c ? c.index : e.length, f = e.substring(o.index, u);
|
|
3174
3184
|
return [a - 1, f];
|
|
3175
3185
|
}));
|
|
@@ -3182,27 +3192,27 @@ function ef(r, e = "", t = 0) {
|
|
|
3182
3192
|
}).join(`
|
|
3183
3193
|
`);
|
|
3184
3194
|
}
|
|
3185
|
-
const
|
|
3186
|
-
function
|
|
3195
|
+
const Jn = /^[ \t]*\n/;
|
|
3196
|
+
function ao(r) {
|
|
3187
3197
|
let e = 0;
|
|
3188
|
-
return
|
|
3198
|
+
return Jn.test(r) && (e = 1, r = r.replace(Jn, "")), { lineOffset: e, shaderSource: r };
|
|
3189
3199
|
}
|
|
3190
|
-
function
|
|
3200
|
+
function of(r, e) {
|
|
3191
3201
|
return r.errorCallback(e), r.callback && setTimeout(() => {
|
|
3192
3202
|
r.callback(`${e}
|
|
3193
3203
|
${r.errors.join(`
|
|
3194
3204
|
`)}`);
|
|
3195
3205
|
}), null;
|
|
3196
3206
|
}
|
|
3197
|
-
function
|
|
3198
|
-
if (n = n ||
|
|
3199
|
-
const o = r.getShaderInfoLog(t), { lineOffset: s, shaderSource: a } =
|
|
3200
|
-
Error compiling ${
|
|
3207
|
+
function sf(r, e, t, n) {
|
|
3208
|
+
if (n = n || rn, !r.getShaderParameter(t, il)) {
|
|
3209
|
+
const o = r.getShaderInfoLog(t), { lineOffset: s, shaderSource: a } = ao(r.getShaderSource(t)), c = `${nf(a, o, s)}
|
|
3210
|
+
Error compiling ${Ti(r, e)}: ${o}`;
|
|
3201
3211
|
return n(c), c;
|
|
3202
3212
|
}
|
|
3203
3213
|
return "";
|
|
3204
3214
|
}
|
|
3205
|
-
function
|
|
3215
|
+
function cn(r, e, t) {
|
|
3206
3216
|
let n, i, o;
|
|
3207
3217
|
if (typeof e == "function" && (t = e, e = void 0), typeof r == "function")
|
|
3208
3218
|
t = r, r = void 0;
|
|
@@ -3210,7 +3220,7 @@ function ln(r, e, t) {
|
|
|
3210
3220
|
const u = r;
|
|
3211
3221
|
t = u.errorCallback, r = u.attribLocations, n = u.transformFeedbackVaryings, i = u.transformFeedbackMode, o = u.callback;
|
|
3212
3222
|
}
|
|
3213
|
-
const s = t ||
|
|
3223
|
+
const s = t || rn, a = [], c = {
|
|
3214
3224
|
errorCallback(u, ...f) {
|
|
3215
3225
|
a.push(u), s(u, ...f);
|
|
3216
3226
|
},
|
|
@@ -3227,52 +3237,52 @@ function ln(r, e, t) {
|
|
|
3227
3237
|
}
|
|
3228
3238
|
return c;
|
|
3229
3239
|
}
|
|
3230
|
-
const
|
|
3240
|
+
const af = [
|
|
3231
3241
|
"VERTEX_SHADER",
|
|
3232
3242
|
"FRAGMENT_SHADER"
|
|
3233
3243
|
];
|
|
3234
|
-
function
|
|
3244
|
+
function cf(r, e) {
|
|
3235
3245
|
if (e.indexOf("frag") >= 0)
|
|
3236
|
-
return
|
|
3246
|
+
return sl;
|
|
3237
3247
|
if (e.indexOf("vert") >= 0)
|
|
3238
|
-
return
|
|
3248
|
+
return al;
|
|
3239
3249
|
}
|
|
3240
|
-
function
|
|
3250
|
+
function uf(r, e, t) {
|
|
3241
3251
|
const n = r.getAttachedShaders(e);
|
|
3242
3252
|
for (const i of n)
|
|
3243
3253
|
t.has(i) && r.deleteShader(i);
|
|
3244
3254
|
r.deleteProgram(e);
|
|
3245
3255
|
}
|
|
3246
|
-
const
|
|
3247
|
-
function
|
|
3256
|
+
const lf = (r = 0) => new Promise((e) => setTimeout(e, r));
|
|
3257
|
+
function ff(r, e, t) {
|
|
3248
3258
|
const n = r.createProgram(), {
|
|
3249
3259
|
attribLocations: i,
|
|
3250
3260
|
transformFeedbackVaryings: o,
|
|
3251
3261
|
transformFeedbackMode: s
|
|
3252
|
-
} =
|
|
3262
|
+
} = cn(t);
|
|
3253
3263
|
for (let a = 0; a < e.length; ++a) {
|
|
3254
3264
|
let c = e[a];
|
|
3255
3265
|
if (typeof c == "string") {
|
|
3256
|
-
const u =
|
|
3257
|
-
let m = r[
|
|
3258
|
-
u && u.type && (m =
|
|
3266
|
+
const u = Ui(c), f = u ? u.text : c;
|
|
3267
|
+
let m = r[af[a]];
|
|
3268
|
+
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);
|
|
3259
3269
|
}
|
|
3260
3270
|
}
|
|
3261
3271
|
Object.entries(i).forEach(([a, c]) => r.bindAttribLocation(n, c, a));
|
|
3262
3272
|
{
|
|
3263
3273
|
let a = o;
|
|
3264
|
-
a && (a.attribs && (a = a.attribs), Array.isArray(a) || (a = Object.keys(a)), r.transformFeedbackVaryings(n, a, s ||
|
|
3274
|
+
a && (a.attribs && (a = a.attribs), Array.isArray(a) || (a = Object.keys(a)), r.transformFeedbackVaryings(n, a, s || cl));
|
|
3265
3275
|
}
|
|
3266
3276
|
return r.linkProgram(n), n;
|
|
3267
3277
|
}
|
|
3268
|
-
function
|
|
3269
|
-
const o =
|
|
3278
|
+
function df(r, e, t, n, i) {
|
|
3279
|
+
const o = cn(t, n, i), s = new Set(e), a = ff(r, e, o);
|
|
3270
3280
|
function c(u, f) {
|
|
3271
|
-
const m =
|
|
3272
|
-
return m &&
|
|
3281
|
+
const m = mf(u, f, o.errorCallback);
|
|
3282
|
+
return m && uf(u, f, s), m;
|
|
3273
3283
|
}
|
|
3274
3284
|
if (o.callback) {
|
|
3275
|
-
|
|
3285
|
+
hf(r, a).then(() => {
|
|
3276
3286
|
const u = c(r, a);
|
|
3277
3287
|
o.callback(u, u ? void 0 : a);
|
|
3278
3288
|
});
|
|
@@ -3280,38 +3290,38 @@ function uf(r, e, t, n, i) {
|
|
|
3280
3290
|
}
|
|
3281
3291
|
return c(r, a) ? void 0 : a;
|
|
3282
3292
|
}
|
|
3283
|
-
async function
|
|
3293
|
+
async function hf(r, e) {
|
|
3284
3294
|
const t = r.getExtension("KHR_parallel_shader_compile"), n = t ? (o, s) => o.getProgramParameter(s, t.COMPLETION_STATUS_KHR) : () => !0;
|
|
3285
3295
|
let i = 0;
|
|
3286
3296
|
do
|
|
3287
|
-
await
|
|
3297
|
+
await lf(i), i = 1e3 / 60;
|
|
3288
3298
|
while (!n(r, e));
|
|
3289
3299
|
}
|
|
3290
|
-
function
|
|
3291
|
-
if (t = t ||
|
|
3300
|
+
function mf(r, e, t) {
|
|
3301
|
+
if (t = t || rn, !r.getProgramParameter(e, ol)) {
|
|
3292
3302
|
const i = r.getProgramInfoLog(e);
|
|
3293
3303
|
t(`Error in program linking: ${i}`);
|
|
3294
|
-
const s = r.getAttachedShaders(e).map((a) =>
|
|
3304
|
+
const s = r.getAttachedShaders(e).map((a) => sf(r, r.getShaderParameter(a, r.SHADER_TYPE), a, t));
|
|
3295
3305
|
return `${i}
|
|
3296
3306
|
${s.filter((a) => a).join(`
|
|
3297
3307
|
`)}`;
|
|
3298
3308
|
}
|
|
3299
3309
|
}
|
|
3300
|
-
function
|
|
3301
|
-
return
|
|
3310
|
+
function pf(r, e, t, n, i) {
|
|
3311
|
+
return df(r, e, t, n, i);
|
|
3302
3312
|
}
|
|
3303
|
-
function
|
|
3313
|
+
function co(r) {
|
|
3304
3314
|
const e = r.name;
|
|
3305
3315
|
return e.startsWith("gl_") || e.startsWith("webgl_");
|
|
3306
3316
|
}
|
|
3307
|
-
const
|
|
3308
|
-
function
|
|
3309
|
-
const i = r.split(
|
|
3317
|
+
const gf = /(\.|\[|]|\w+)/g, yf = (r) => r >= "0" && r <= "9";
|
|
3318
|
+
function bf(r, e, t, n) {
|
|
3319
|
+
const i = r.split(gf).filter((a) => a !== "");
|
|
3310
3320
|
let o = 0, s = "";
|
|
3311
3321
|
for (; ; ) {
|
|
3312
3322
|
const a = i[o++];
|
|
3313
3323
|
s += a;
|
|
3314
|
-
const c =
|
|
3324
|
+
const c = yf(a[0]), u = c ? parseInt(a) : a;
|
|
3315
3325
|
if (c && (s += i[o++]), o === i.length) {
|
|
3316
3326
|
t[u] = e;
|
|
3317
3327
|
break;
|
|
@@ -3319,13 +3329,13 @@ function pf(r, e, t, n) {
|
|
|
3319
3329
|
const m = i[o++], p = m === "[", b = t[u] || (p ? [] : {});
|
|
3320
3330
|
t[u] = b, t = b, n[s] = n[s] || /* @__PURE__ */ (function(d) {
|
|
3321
3331
|
return function(g) {
|
|
3322
|
-
|
|
3332
|
+
uo(d, g);
|
|
3323
3333
|
};
|
|
3324
3334
|
})(b), s += m;
|
|
3325
3335
|
}
|
|
3326
3336
|
}
|
|
3327
3337
|
}
|
|
3328
|
-
function
|
|
3338
|
+
function wf(r, e) {
|
|
3329
3339
|
let t = 0;
|
|
3330
3340
|
function n(a, c, u) {
|
|
3331
3341
|
const f = c.name.endsWith("[0]"), m = c.type, p = w[m];
|
|
@@ -3339,23 +3349,23 @@ function gf(r, e) {
|
|
|
3339
3349
|
p.arraySetter && f ? b = p.arraySetter(r, u) : b = p.setter(r, u);
|
|
3340
3350
|
return b.location = u, b;
|
|
3341
3351
|
}
|
|
3342
|
-
const i = {}, o = {}, s = r.getProgramParameter(e,
|
|
3352
|
+
const i = {}, o = {}, s = r.getProgramParameter(e, Li);
|
|
3343
3353
|
for (let a = 0; a < s; ++a) {
|
|
3344
3354
|
const c = r.getActiveUniform(e, a);
|
|
3345
|
-
if (
|
|
3355
|
+
if (co(c))
|
|
3346
3356
|
continue;
|
|
3347
3357
|
let u = c.name;
|
|
3348
3358
|
u.endsWith("[0]") && (u = u.substr(0, u.length - 3));
|
|
3349
3359
|
const f = r.getUniformLocation(e, c.name);
|
|
3350
3360
|
if (f) {
|
|
3351
3361
|
const m = n(e, c, f);
|
|
3352
|
-
i[u] = m,
|
|
3362
|
+
i[u] = m, bf(u, m, o, i);
|
|
3353
3363
|
}
|
|
3354
3364
|
}
|
|
3355
3365
|
return i;
|
|
3356
3366
|
}
|
|
3357
|
-
function
|
|
3358
|
-
const t = {}, n = r.getProgramParameter(e,
|
|
3367
|
+
function xf(r, e) {
|
|
3368
|
+
const t = {}, n = r.getProgramParameter(e, ll);
|
|
3359
3369
|
for (let i = 0; i < n; ++i) {
|
|
3360
3370
|
const o = r.getTransformFeedbackVarying(e, i);
|
|
3361
3371
|
t[o.name] = {
|
|
@@ -3366,8 +3376,8 @@ function yf(r, e) {
|
|
|
3366
3376
|
}
|
|
3367
3377
|
return t;
|
|
3368
3378
|
}
|
|
3369
|
-
function
|
|
3370
|
-
const t = r.getProgramParameter(e,
|
|
3379
|
+
function vf(r, e) {
|
|
3380
|
+
const t = r.getProgramParameter(e, Li), n = [], i = [];
|
|
3371
3381
|
for (let a = 0; a < t; ++a) {
|
|
3372
3382
|
i.push(a), n.push({});
|
|
3373
3383
|
const c = r.getActiveUniform(e, a);
|
|
@@ -3385,14 +3395,14 @@ function bf(r, e) {
|
|
|
3385
3395
|
n[m][u] = f;
|
|
3386
3396
|
});
|
|
3387
3397
|
});
|
|
3388
|
-
const o = {}, s = r.getProgramParameter(e,
|
|
3398
|
+
const o = {}, s = r.getProgramParameter(e, fl);
|
|
3389
3399
|
for (let a = 0; a < s; ++a) {
|
|
3390
3400
|
const c = r.getActiveUniformBlockName(e, a), u = {
|
|
3391
3401
|
index: r.getUniformBlockIndex(e, c),
|
|
3392
|
-
usedByVertexShader: r.getActiveUniformBlockParameter(e, a,
|
|
3393
|
-
usedByFragmentShader: r.getActiveUniformBlockParameter(e, a,
|
|
3394
|
-
size: r.getActiveUniformBlockParameter(e, a,
|
|
3395
|
-
uniformIndices: r.getActiveUniformBlockParameter(e, a,
|
|
3402
|
+
usedByVertexShader: r.getActiveUniformBlockParameter(e, a, dl),
|
|
3403
|
+
usedByFragmentShader: r.getActiveUniformBlockParameter(e, a, hl),
|
|
3404
|
+
size: r.getActiveUniformBlockParameter(e, a, ml),
|
|
3405
|
+
uniformIndices: r.getActiveUniformBlockParameter(e, a, pl)
|
|
3396
3406
|
};
|
|
3397
3407
|
u.used = u.usedByVertexShader || u.usedByFragmentShader, o[c] = u;
|
|
3398
3408
|
}
|
|
@@ -3401,20 +3411,20 @@ function bf(r, e) {
|
|
|
3401
3411
|
uniformData: n
|
|
3402
3412
|
};
|
|
3403
3413
|
}
|
|
3404
|
-
function
|
|
3414
|
+
function uo(r, e) {
|
|
3405
3415
|
for (const t in e) {
|
|
3406
3416
|
const n = r[t];
|
|
3407
|
-
typeof n == "function" ? n(e[t]) :
|
|
3417
|
+
typeof n == "function" ? n(e[t]) : uo(r[t], e[t]);
|
|
3408
3418
|
}
|
|
3409
3419
|
}
|
|
3410
|
-
function
|
|
3420
|
+
function lo(r, ...e) {
|
|
3411
3421
|
const t = r.uniformSetters || r, n = e.length;
|
|
3412
3422
|
for (let i = 0; i < n; ++i) {
|
|
3413
3423
|
const o = e[i];
|
|
3414
3424
|
if (Array.isArray(o)) {
|
|
3415
3425
|
const s = o.length;
|
|
3416
3426
|
for (let a = 0; a < s; ++a)
|
|
3417
|
-
|
|
3427
|
+
lo(t, o[a]);
|
|
3418
3428
|
} else
|
|
3419
3429
|
for (const s in o) {
|
|
3420
3430
|
const a = t[s];
|
|
@@ -3422,40 +3432,40 @@ function ho(r, ...e) {
|
|
|
3422
3432
|
}
|
|
3423
3433
|
}
|
|
3424
3434
|
}
|
|
3425
|
-
function
|
|
3426
|
-
const t = {}, n = r.getProgramParameter(e,
|
|
3435
|
+
function _f(r, e) {
|
|
3436
|
+
const t = {}, n = r.getProgramParameter(e, ul);
|
|
3427
3437
|
for (let i = 0; i < n; ++i) {
|
|
3428
3438
|
const o = r.getActiveAttrib(e, i);
|
|
3429
|
-
if (
|
|
3439
|
+
if (co(o))
|
|
3430
3440
|
continue;
|
|
3431
3441
|
const s = r.getAttribLocation(e, o.name), a = I[o.type], c = a.setter(r, s, a);
|
|
3432
3442
|
c.location = s, t[o.name] = c;
|
|
3433
3443
|
}
|
|
3434
3444
|
return t;
|
|
3435
3445
|
}
|
|
3436
|
-
function
|
|
3446
|
+
function Ef(r, e) {
|
|
3437
3447
|
for (const t in e) {
|
|
3438
3448
|
const n = r[t];
|
|
3439
3449
|
n && n(e[t]);
|
|
3440
3450
|
}
|
|
3441
3451
|
}
|
|
3442
|
-
function
|
|
3443
|
-
t.vertexArrayObject ? r.bindVertexArray(t.vertexArrayObject) : (
|
|
3452
|
+
function Af(r, e, t) {
|
|
3453
|
+
t.vertexArrayObject ? r.bindVertexArray(t.vertexArrayObject) : (Ef(e.attribSetters || e, t.attribs), t.indices && r.bindBuffer(nl, t.indices));
|
|
3444
3454
|
}
|
|
3445
|
-
function
|
|
3446
|
-
const t =
|
|
3455
|
+
function Zn(r, e) {
|
|
3456
|
+
const t = wf(r, e), n = _f(r, e), i = {
|
|
3447
3457
|
program: e,
|
|
3448
3458
|
uniformSetters: t,
|
|
3449
3459
|
attribSetters: n
|
|
3450
3460
|
};
|
|
3451
|
-
return rt(r) && (i.uniformBlockSpec =
|
|
3461
|
+
return rt(r) && (i.uniformBlockSpec = vf(r, e), i.transformFeedbackInfo = xf(r, e)), i;
|
|
3452
3462
|
}
|
|
3453
|
-
const
|
|
3454
|
-
function
|
|
3455
|
-
const o =
|
|
3463
|
+
const Tf = /\s|{|}|;/;
|
|
3464
|
+
function Sf(r, e, t, n, i) {
|
|
3465
|
+
const o = cn(t, n, i), s = [];
|
|
3456
3466
|
if (e = e.map(function(u) {
|
|
3457
|
-
if (!
|
|
3458
|
-
const f =
|
|
3467
|
+
if (!Tf.test(u)) {
|
|
3468
|
+
const f = Ui(u);
|
|
3459
3469
|
if (f)
|
|
3460
3470
|
u = f.text;
|
|
3461
3471
|
else {
|
|
@@ -3465,54 +3475,54 @@ function Ef(r, e, t, n, i) {
|
|
|
3465
3475
|
}
|
|
3466
3476
|
return u;
|
|
3467
3477
|
}), s.length)
|
|
3468
|
-
return
|
|
3478
|
+
return of(o, "");
|
|
3469
3479
|
const a = o.callback;
|
|
3470
3480
|
a && (o.callback = (u, f) => {
|
|
3471
|
-
a(u, u ? void 0 :
|
|
3481
|
+
a(u, u ? void 0 : Zn(r, f));
|
|
3472
3482
|
});
|
|
3473
|
-
const c =
|
|
3474
|
-
return c ?
|
|
3483
|
+
const c = pf(r, e, o);
|
|
3484
|
+
return c ? Zn(r, c) : null;
|
|
3475
3485
|
}
|
|
3476
|
-
const
|
|
3477
|
-
function
|
|
3478
|
-
t = t === void 0 ?
|
|
3486
|
+
const If = 4, ei = 5123;
|
|
3487
|
+
function Rf(r, e, t, n, i, o) {
|
|
3488
|
+
t = t === void 0 ? If : t;
|
|
3479
3489
|
const s = e.indices, a = e.elementType, c = n === void 0 ? e.numElements : n;
|
|
3480
|
-
i = i === void 0 ? 0 : i, a || s ? o !== void 0 ? r.drawElementsInstanced(t, c, a === void 0 ?
|
|
3490
|
+
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);
|
|
3481
3491
|
}
|
|
3482
|
-
const
|
|
3483
|
-
{ format:
|
|
3484
|
-
{ format:
|
|
3492
|
+
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 = [
|
|
3493
|
+
{ format: Cf, type: Pf, min: Or, wrap: Cr },
|
|
3494
|
+
{ format: un }
|
|
3485
3495
|
], V = {};
|
|
3486
|
-
V[
|
|
3487
|
-
V[
|
|
3488
|
-
V[
|
|
3489
|
-
V[kf] = cr;
|
|
3490
|
-
V[po] = cr;
|
|
3491
|
-
V[Pf] = cr;
|
|
3496
|
+
V[un] = ln;
|
|
3497
|
+
V[mo] = go;
|
|
3498
|
+
V[po] = go;
|
|
3492
3499
|
V[Ff] = cr;
|
|
3493
|
-
V[
|
|
3494
|
-
V[
|
|
3495
|
-
|
|
3500
|
+
V[ho] = cr;
|
|
3501
|
+
V[Of] = cr;
|
|
3502
|
+
V[Mf] = cr;
|
|
3503
|
+
V[Bf] = ln;
|
|
3504
|
+
V[Df] = ln;
|
|
3505
|
+
function $f(r, e) {
|
|
3496
3506
|
return V[r] || V[e];
|
|
3497
3507
|
}
|
|
3498
3508
|
const le = {};
|
|
3499
|
-
le[
|
|
3500
|
-
le[
|
|
3501
|
-
le[
|
|
3502
|
-
le[
|
|
3509
|
+
le[Uf] = !0;
|
|
3510
|
+
le[Lf] = !0;
|
|
3511
|
+
le[zf] = !0;
|
|
3512
|
+
le[un] = !0;
|
|
3513
|
+
le[ho] = !0;
|
|
3514
|
+
le[mo] = !0;
|
|
3503
3515
|
le[po] = !0;
|
|
3504
|
-
|
|
3505
|
-
le[yo] = !0;
|
|
3506
|
-
function zf(r) {
|
|
3516
|
+
function Wf(r) {
|
|
3507
3517
|
return le[r];
|
|
3508
3518
|
}
|
|
3509
|
-
const
|
|
3510
|
-
function
|
|
3511
|
-
return r >=
|
|
3519
|
+
const Gf = 32;
|
|
3520
|
+
function Vf(r) {
|
|
3521
|
+
return r >= Fr && r < Fr + Gf;
|
|
3512
3522
|
}
|
|
3513
|
-
function
|
|
3514
|
-
const i =
|
|
3515
|
-
r.bindFramebuffer(i, o), t = t || r.drawingBufferWidth, n = n || r.drawingBufferHeight, e = e ||
|
|
3523
|
+
function ti(r, e, t, n) {
|
|
3524
|
+
const i = fo, o = r.createFramebuffer();
|
|
3525
|
+
r.bindFramebuffer(i, o), t = t || r.drawingBufferWidth, n = n || r.drawingBufferHeight, e = e || Nf;
|
|
3516
3526
|
const s = [], a = {
|
|
3517
3527
|
framebuffer: o,
|
|
3518
3528
|
attachments: [],
|
|
@@ -3522,17 +3532,17 @@ function ni(r, e, t, n) {
|
|
|
3522
3532
|
return e.forEach(function(c, u) {
|
|
3523
3533
|
let f = c.attachment;
|
|
3524
3534
|
const m = c.samples, p = c.format;
|
|
3525
|
-
let b = c.attachmentPoint ||
|
|
3526
|
-
if (b || (b =
|
|
3527
|
-
if (m !== void 0 ||
|
|
3535
|
+
let b = c.attachmentPoint || $f(p, c.internalFormat);
|
|
3536
|
+
if (b || (b = Fr + u), Vf(b) && s.push(b), !f)
|
|
3537
|
+
if (m !== void 0 || Wf(p))
|
|
3528
3538
|
f = r.createRenderbuffer(), r.bindRenderbuffer(At, f), m > 1 ? r.renderbufferStorageMultisample(At, m, p, t, n) : r.renderbufferStorage(At, p, t, n);
|
|
3529
3539
|
else {
|
|
3530
3540
|
const d = Object.assign({}, c);
|
|
3531
|
-
d.width = t, d.height = n, d.auto === void 0 && (d.auto = !1, d.min = d.min || d.minMag ||
|
|
3541
|
+
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);
|
|
3532
3542
|
}
|
|
3533
|
-
if (
|
|
3543
|
+
if (Ja(r, f))
|
|
3534
3544
|
r.framebufferRenderbuffer(i, b, At, f);
|
|
3535
|
-
else if (
|
|
3545
|
+
else if (Xr(r, f))
|
|
3536
3546
|
c.layer !== void 0 ? r.framebufferTextureLayer(
|
|
3537
3547
|
i,
|
|
3538
3548
|
b,
|
|
@@ -3542,7 +3552,7 @@ function ni(r, e, t, n) {
|
|
|
3542
3552
|
) : r.framebufferTexture2D(
|
|
3543
3553
|
i,
|
|
3544
3554
|
b,
|
|
3545
|
-
c.target ||
|
|
3555
|
+
c.target || kf,
|
|
3546
3556
|
f,
|
|
3547
3557
|
c.level || 0
|
|
3548
3558
|
);
|
|
@@ -3551,11 +3561,11 @@ function ni(r, e, t, n) {
|
|
|
3551
3561
|
a.attachments.push(f);
|
|
3552
3562
|
}), r.drawBuffers && r.drawBuffers(s), a;
|
|
3553
3563
|
}
|
|
3554
|
-
function
|
|
3555
|
-
t = t ||
|
|
3564
|
+
function Hf(r, e, t) {
|
|
3565
|
+
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));
|
|
3556
3566
|
}
|
|
3557
3567
|
function B(r, e) {
|
|
3558
|
-
return () => e instanceof WebGLTexture ? e :
|
|
3568
|
+
return () => e instanceof WebGLTexture ? e : Di(r, {
|
|
3559
3569
|
src: e,
|
|
3560
3570
|
wrap: r.CLAMP_TO_EDGE
|
|
3561
3571
|
});
|
|
@@ -3567,13 +3577,13 @@ class ot {
|
|
|
3567
3577
|
const { context: t, width: n, height: i } = e;
|
|
3568
3578
|
this.context = t, this.options = e;
|
|
3569
3579
|
const o = this.buildDefines();
|
|
3570
|
-
this.programInfo =
|
|
3580
|
+
this.programInfo = Sf(this.context, [
|
|
3571
3581
|
o + this.getVertexShader(),
|
|
3572
3582
|
o + this.getFragmentShader()
|
|
3573
|
-
]), this.bufferInfo =
|
|
3583
|
+
]), this.bufferInfo = _c(
|
|
3574
3584
|
this.context,
|
|
3575
3585
|
this.getBuffers()
|
|
3576
|
-
), this.fbi =
|
|
3586
|
+
), this.fbi = ti(
|
|
3577
3587
|
this.context,
|
|
3578
3588
|
[
|
|
3579
3589
|
{
|
|
@@ -3588,7 +3598,7 @@ class ot {
|
|
|
3588
3598
|
), this.output = this.fbi.attachments[0];
|
|
3589
3599
|
}
|
|
3590
3600
|
resizeOutput(e, t) {
|
|
3591
|
-
this.fbi =
|
|
3601
|
+
this.fbi = ti(
|
|
3592
3602
|
this.context,
|
|
3593
3603
|
[
|
|
3594
3604
|
{
|
|
@@ -3656,18 +3666,18 @@ class ot {
|
|
|
3656
3666
|
0,
|
|
3657
3667
|
this.context.canvas.width,
|
|
3658
3668
|
this.context.canvas.height
|
|
3659
|
-
), this.context.useProgram(this.programInfo.program),
|
|
3669
|
+
), this.context.useProgram(this.programInfo.program), Af(
|
|
3660
3670
|
this.context,
|
|
3661
3671
|
this.programInfo,
|
|
3662
3672
|
this.bufferInfo
|
|
3663
|
-
),
|
|
3673
|
+
), lo(this.programInfo, {
|
|
3664
3674
|
delta: n,
|
|
3665
3675
|
canvas: [this.context.canvas.width, this.context.canvas.height],
|
|
3666
3676
|
...e
|
|
3667
|
-
}),
|
|
3677
|
+
}), Hf(
|
|
3668
3678
|
this.context,
|
|
3669
3679
|
this.options.disableFramebuffer ? null : this.fbi
|
|
3670
|
-
),
|
|
3680
|
+
), Rf(this.context, this.bufferInfo), this.profiler?.popContext(
|
|
3671
3681
|
`[${this.id}] PROG : ${this.constructor.name}`
|
|
3672
3682
|
);
|
|
3673
3683
|
}
|
|
@@ -3675,7 +3685,7 @@ class ot {
|
|
|
3675
3685
|
this.profiler = e;
|
|
3676
3686
|
}
|
|
3677
3687
|
}
|
|
3678
|
-
const
|
|
3688
|
+
const jf = `precision mediump float;
|
|
3679
3689
|
|
|
3680
3690
|
varying vec2 _texture_coord;
|
|
3681
3691
|
|
|
@@ -3690,7 +3700,7 @@ void main() {
|
|
|
3690
3700
|
gl_FragColor = foregroundColor * tresholdColor.a +
|
|
3691
3701
|
backgroundColor * (1. - tresholdColor.a);
|
|
3692
3702
|
}
|
|
3693
|
-
`,
|
|
3703
|
+
`, Yf = `varying vec2 _texture_coord;
|
|
3694
3704
|
|
|
3695
3705
|
attribute vec2 position;
|
|
3696
3706
|
attribute vec2 texture_coord;
|
|
@@ -3701,15 +3711,15 @@ void main() {
|
|
|
3701
3711
|
_texture_coord.y = 1. - texture_coord.y;
|
|
3702
3712
|
}
|
|
3703
3713
|
`;
|
|
3704
|
-
class
|
|
3714
|
+
class fn extends ot {
|
|
3705
3715
|
getFragmentShader() {
|
|
3706
|
-
return
|
|
3716
|
+
return jf;
|
|
3707
3717
|
}
|
|
3708
3718
|
getVertexShader() {
|
|
3709
|
-
return
|
|
3719
|
+
return Yf;
|
|
3710
3720
|
}
|
|
3711
3721
|
}
|
|
3712
|
-
class
|
|
3722
|
+
class dn {
|
|
3713
3723
|
constructor() {
|
|
3714
3724
|
this.steps = [];
|
|
3715
3725
|
}
|
|
@@ -3743,19 +3753,19 @@ class mn {
|
|
|
3743
3753
|
t.program.id = e;
|
|
3744
3754
|
}
|
|
3745
3755
|
}
|
|
3746
|
-
class
|
|
3756
|
+
class hn extends dn {
|
|
3747
3757
|
constructor() {
|
|
3748
3758
|
super(...arguments), this.preciseMaskEnabled = !1;
|
|
3749
3759
|
}
|
|
3750
3760
|
}
|
|
3751
|
-
class
|
|
3761
|
+
class yo extends hn {
|
|
3752
3762
|
constructor(e) {
|
|
3753
3763
|
super(), this.context = e, this.preciseMaskEnabled = !0;
|
|
3754
3764
|
const t = {
|
|
3755
3765
|
context: e,
|
|
3756
3766
|
height: e.canvas.height,
|
|
3757
3767
|
width: e.canvas.width
|
|
3758
|
-
}, n = new
|
|
3768
|
+
}, n = new fn({ ...t, disableFramebuffer: !0 });
|
|
3759
3769
|
this.addStep({
|
|
3760
3770
|
program: n,
|
|
3761
3771
|
getUniforms: () => ({
|
|
@@ -3769,13 +3779,13 @@ class wo extends pn {
|
|
|
3769
3779
|
this.inputImage = e, this.inputMask = t;
|
|
3770
3780
|
}
|
|
3771
3781
|
}
|
|
3772
|
-
const
|
|
3782
|
+
const Qf = `precision mediump float;
|
|
3773
3783
|
|
|
3774
3784
|
varying vec2 _texture_coord;
|
|
3775
3785
|
uniform sampler2D texture;
|
|
3776
3786
|
|
|
3777
3787
|
void main() { gl_FragColor = texture2D(texture, _texture_coord); }
|
|
3778
|
-
`,
|
|
3788
|
+
`, qf = `varying vec2 _texture_coord;
|
|
3779
3789
|
|
|
3780
3790
|
attribute vec2 position;
|
|
3781
3791
|
attribute vec2 texture_coord;
|
|
@@ -3789,15 +3799,15 @@ void main() {
|
|
|
3789
3799
|
}
|
|
3790
3800
|
}
|
|
3791
3801
|
`;
|
|
3792
|
-
class
|
|
3802
|
+
class Xf extends ot {
|
|
3793
3803
|
getFragmentShader() {
|
|
3794
|
-
return
|
|
3804
|
+
return Qf;
|
|
3795
3805
|
}
|
|
3796
3806
|
getVertexShader() {
|
|
3797
|
-
return
|
|
3807
|
+
return qf;
|
|
3798
3808
|
}
|
|
3799
3809
|
}
|
|
3800
|
-
class
|
|
3810
|
+
class Kf extends dn {
|
|
3801
3811
|
constructor(e, t, n) {
|
|
3802
3812
|
super(), this.context = e;
|
|
3803
3813
|
const i = {
|
|
@@ -3806,7 +3816,7 @@ class Qf extends mn {
|
|
|
3806
3816
|
width: t
|
|
3807
3817
|
};
|
|
3808
3818
|
this.addStep({
|
|
3809
|
-
program: new
|
|
3819
|
+
program: new Xf({
|
|
3810
3820
|
...i,
|
|
3811
3821
|
disableFramebuffer: !0
|
|
3812
3822
|
}),
|
|
@@ -3820,14 +3830,14 @@ class Qf extends mn {
|
|
|
3820
3830
|
this.inputImage = e;
|
|
3821
3831
|
}
|
|
3822
3832
|
}
|
|
3823
|
-
async function
|
|
3833
|
+
async function bo(r) {
|
|
3824
3834
|
return new Promise((e) => {
|
|
3825
3835
|
setTimeout(() => {
|
|
3826
3836
|
e();
|
|
3827
3837
|
}, r);
|
|
3828
3838
|
});
|
|
3829
3839
|
}
|
|
3830
|
-
const
|
|
3840
|
+
const Jf = `precision mediump float;
|
|
3831
3841
|
|
|
3832
3842
|
varying vec2 _texture_coord;
|
|
3833
3843
|
|
|
@@ -3837,7 +3847,7 @@ uniform sampler2D texture;
|
|
|
3837
3847
|
vec4 loop();
|
|
3838
3848
|
|
|
3839
3849
|
void main() { gl_FragColor = loop(); }
|
|
3840
|
-
`,
|
|
3850
|
+
`, Zf = `varying vec2 _texture_coord;
|
|
3841
3851
|
|
|
3842
3852
|
attribute vec2 position;
|
|
3843
3853
|
attribute vec2 texture_coord;
|
|
@@ -3847,16 +3857,16 @@ void main() {
|
|
|
3847
3857
|
_texture_coord = texture_coord;
|
|
3848
3858
|
}
|
|
3849
3859
|
`;
|
|
3850
|
-
var
|
|
3851
|
-
class
|
|
3860
|
+
var mn = /* @__PURE__ */ ((r) => (r[r.LINEAR = 0] = "LINEAR", r[r.GAUSSIAN = 1] = "GAUSSIAN", r))(mn || {});
|
|
3861
|
+
class wo extends ot {
|
|
3852
3862
|
getDefines() {
|
|
3853
3863
|
return { RADIUS: this.options.radius ?? 1 };
|
|
3854
3864
|
}
|
|
3855
3865
|
getFragmentShader() {
|
|
3856
|
-
return
|
|
3866
|
+
return Jf + this.createLoopFunction();
|
|
3857
3867
|
}
|
|
3858
3868
|
getVertexShader() {
|
|
3859
|
-
return
|
|
3869
|
+
return Zf;
|
|
3860
3870
|
}
|
|
3861
3871
|
createLoopFunction() {
|
|
3862
3872
|
let e = this.options.radius ?? 1;
|
|
@@ -3884,7 +3894,7 @@ class vo extends ot {
|
|
|
3884
3894
|
}`;
|
|
3885
3895
|
}
|
|
3886
3896
|
}
|
|
3887
|
-
const
|
|
3897
|
+
const ed = `#version 300 es
|
|
3888
3898
|
// https://github.com/Volcomix/virtual-background/blob/main/src/pipelines/webgl2/jointBilateralFilterStage.ts
|
|
3889
3899
|
|
|
3890
3900
|
precision highp float;
|
|
@@ -3930,7 +3940,7 @@ void main() {
|
|
|
3930
3940
|
}
|
|
3931
3941
|
newVal /= totalWeight;
|
|
3932
3942
|
outColor = vec4(vec3(0.), newVal);
|
|
3933
|
-
}`,
|
|
3943
|
+
}`, td = `#version 300 es
|
|
3934
3944
|
in vec2 position;
|
|
3935
3945
|
in vec2 texture_coord;
|
|
3936
3946
|
out vec2 _texture_coord;
|
|
@@ -3938,27 +3948,27 @@ void main() {
|
|
|
3938
3948
|
gl_Position = vec4(position, 0.0, 1.0);
|
|
3939
3949
|
_texture_coord = texture_coord;
|
|
3940
3950
|
}`;
|
|
3941
|
-
class
|
|
3951
|
+
class rd extends ot {
|
|
3942
3952
|
getFragmentShader() {
|
|
3943
|
-
return
|
|
3953
|
+
return ed;
|
|
3944
3954
|
}
|
|
3945
3955
|
getVertexShader() {
|
|
3946
|
-
return
|
|
3956
|
+
return td;
|
|
3947
3957
|
}
|
|
3948
3958
|
}
|
|
3949
|
-
class
|
|
3959
|
+
class nd extends dn {
|
|
3950
3960
|
constructor(e, t, n) {
|
|
3951
3961
|
super(), this.context = e;
|
|
3952
3962
|
const i = {
|
|
3953
3963
|
context: e,
|
|
3954
3964
|
height: n,
|
|
3955
3965
|
width: t
|
|
3956
|
-
}, o = new
|
|
3966
|
+
}, o = new wo({
|
|
3957
3967
|
...i,
|
|
3958
3968
|
radius: 1,
|
|
3959
|
-
type:
|
|
3969
|
+
type: mn.GAUSSIAN
|
|
3960
3970
|
});
|
|
3961
|
-
this.jointBilateral = new
|
|
3971
|
+
this.jointBilateral = new rd(i), this.addStep({
|
|
3962
3972
|
program: o,
|
|
3963
3973
|
getUniforms: () => ({
|
|
3964
3974
|
inputs: B(e, this.inputMask)
|
|
@@ -3993,8 +4003,8 @@ class ed extends mn {
|
|
|
3993
4003
|
super.resizeOutput(e, t), this.output = this.jointBilateral.output;
|
|
3994
4004
|
}
|
|
3995
4005
|
}
|
|
3996
|
-
var
|
|
3997
|
-
class
|
|
4006
|
+
var xo = /* @__PURE__ */ ((r) => (r.PUSH = "PUSH", r.POP = "POP", r))(xo || {});
|
|
4007
|
+
class id {
|
|
3998
4008
|
constructor(e) {
|
|
3999
4009
|
this.queries = [], this.context = e, this.extension = e.getExtension(
|
|
4000
4010
|
"EXT_disjoint_timer_query_webgl2"
|
|
@@ -4056,7 +4066,7 @@ class td {
|
|
|
4056
4066
|
this.context.QUERY_RESULT_AVAILABLE
|
|
4057
4067
|
))
|
|
4058
4068
|
return e;
|
|
4059
|
-
await
|
|
4069
|
+
await bo(200);
|
|
4060
4070
|
}
|
|
4061
4071
|
}
|
|
4062
4072
|
}
|
|
@@ -4066,7 +4076,7 @@ class ur {
|
|
|
4066
4076
|
const e = new OffscreenCanvas(0, 0), t = e.getContext("webgl2");
|
|
4067
4077
|
if (!t)
|
|
4068
4078
|
throw "Fail to retrieve webgl2 context";
|
|
4069
|
-
this.canvas = e, this.context = t, this.improveMask = new
|
|
4079
|
+
this.canvas = e, this.context = t, this.improveMask = new nd(
|
|
4070
4080
|
this.context,
|
|
4071
4081
|
Ue,
|
|
4072
4082
|
Ue
|
|
@@ -4079,8 +4089,8 @@ class ur {
|
|
|
4079
4089
|
this.postProcessingEnabled = !1;
|
|
4080
4090
|
}
|
|
4081
4091
|
async profileWebgl(e) {
|
|
4082
|
-
const t = new
|
|
4083
|
-
return this.profiler = t, t.start(), await
|
|
4092
|
+
const t = new id(this.context);
|
|
4093
|
+
return this.profiler = t, t.start(), await bo(e), this.profiler = void 0, t.stop(), t.getResolvedQueries();
|
|
4084
4094
|
}
|
|
4085
4095
|
async render(e, t) {
|
|
4086
4096
|
if (!this.pipeline)
|
|
@@ -4100,13 +4110,13 @@ class ur {
|
|
|
4100
4110
|
e && e.loseContext();
|
|
4101
4111
|
}
|
|
4102
4112
|
}
|
|
4103
|
-
class
|
|
4113
|
+
class vo extends ur {
|
|
4104
4114
|
constructor() {
|
|
4105
|
-
super(), this.pipeline = new
|
|
4115
|
+
super(), this.pipeline = new yo(this.context);
|
|
4106
4116
|
const e = new OffscreenCanvas(0, 0), t = e.getContext("webgl2");
|
|
4107
4117
|
if (!t)
|
|
4108
4118
|
throw "Fail to retrieve webgl context";
|
|
4109
|
-
this.backgroundImageResizerCanvas = e, this.backgroundImageResizerContext = t, this.backgroundImageResizer = new
|
|
4119
|
+
this.backgroundImageResizerCanvas = e, this.backgroundImageResizerContext = t, this.backgroundImageResizer = new Kf(
|
|
4110
4120
|
this.backgroundImageResizerContext,
|
|
4111
4121
|
0,
|
|
4112
4122
|
0
|
|
@@ -4127,7 +4137,7 @@ class Eo extends ur {
|
|
|
4127
4137
|
e && e.loseContext(), super.destroy();
|
|
4128
4138
|
}
|
|
4129
4139
|
}
|
|
4130
|
-
class
|
|
4140
|
+
class od extends vo {
|
|
4131
4141
|
setBackgroundVideo(e) {
|
|
4132
4142
|
this.frameReader = e;
|
|
4133
4143
|
}
|
|
@@ -4142,21 +4152,21 @@ class rd extends Eo {
|
|
|
4142
4152
|
}
|
|
4143
4153
|
}
|
|
4144
4154
|
}
|
|
4145
|
-
class
|
|
4155
|
+
class ri {
|
|
4146
4156
|
blurBackground(e) {
|
|
4147
|
-
return new
|
|
4157
|
+
return new za(e);
|
|
4148
4158
|
}
|
|
4149
4159
|
blurSilhouette(e) {
|
|
4150
|
-
return new
|
|
4160
|
+
return new Na(e);
|
|
4151
4161
|
}
|
|
4152
4162
|
imageBackground() {
|
|
4153
|
-
return new
|
|
4163
|
+
return new $a();
|
|
4154
4164
|
}
|
|
4155
4165
|
videoBackground() {
|
|
4156
|
-
return new
|
|
4166
|
+
return new od();
|
|
4157
4167
|
}
|
|
4158
4168
|
}
|
|
4159
|
-
const
|
|
4169
|
+
const sd = `precision mediump float;
|
|
4160
4170
|
|
|
4161
4171
|
varying vec2 _texture_coord;
|
|
4162
4172
|
|
|
@@ -4167,7 +4177,7 @@ uniform sampler2D mask;
|
|
|
4167
4177
|
vec4 loop();
|
|
4168
4178
|
|
|
4169
4179
|
void main() { gl_FragColor = loop(); }
|
|
4170
|
-
`,
|
|
4180
|
+
`, ad = `varying vec2 _texture_coord;
|
|
4171
4181
|
|
|
4172
4182
|
attribute vec2 position;
|
|
4173
4183
|
attribute vec2 texture_coord;
|
|
@@ -4177,15 +4187,15 @@ void main() {
|
|
|
4177
4187
|
_texture_coord = texture_coord;
|
|
4178
4188
|
}
|
|
4179
4189
|
`;
|
|
4180
|
-
class
|
|
4190
|
+
class cd extends ot {
|
|
4181
4191
|
getDefines() {
|
|
4182
4192
|
return { RADIUS: this.options.radius ?? 1 };
|
|
4183
4193
|
}
|
|
4184
4194
|
getFragmentShader() {
|
|
4185
|
-
return
|
|
4195
|
+
return sd + this.createLoopFunction();
|
|
4186
4196
|
}
|
|
4187
4197
|
getVertexShader() {
|
|
4188
|
-
return
|
|
4198
|
+
return ad;
|
|
4189
4199
|
}
|
|
4190
4200
|
createLoopFunction() {
|
|
4191
4201
|
let e = this.options.radius ?? 1;
|
|
@@ -4214,8 +4224,8 @@ class od extends ot {
|
|
|
4214
4224
|
}`;
|
|
4215
4225
|
}
|
|
4216
4226
|
}
|
|
4217
|
-
const
|
|
4218
|
-
class
|
|
4227
|
+
const ud = 10, ld = 2, fd = 8;
|
|
4228
|
+
class dd extends hn {
|
|
4219
4229
|
constructor(e, t) {
|
|
4220
4230
|
super(), this.context = e, this.radius = t;
|
|
4221
4231
|
const n = {
|
|
@@ -4223,7 +4233,7 @@ class ud extends pn {
|
|
|
4223
4233
|
height: e.canvas.height,
|
|
4224
4234
|
width: e.canvas.width
|
|
4225
4235
|
};
|
|
4226
|
-
this.blur = new
|
|
4236
|
+
this.blur = new cd({
|
|
4227
4237
|
...n,
|
|
4228
4238
|
radius: t,
|
|
4229
4239
|
...this.getBlurTextureSize(
|
|
@@ -4231,7 +4241,7 @@ class ud extends pn {
|
|
|
4231
4241
|
e.canvas.height
|
|
4232
4242
|
)
|
|
4233
4243
|
});
|
|
4234
|
-
const i = new
|
|
4244
|
+
const i = new fn({ ...n, disableFramebuffer: !0 });
|
|
4235
4245
|
this.addStep({
|
|
4236
4246
|
program: this.blur,
|
|
4237
4247
|
preventResize: !0,
|
|
@@ -4249,7 +4259,7 @@ class ud extends pn {
|
|
|
4249
4259
|
});
|
|
4250
4260
|
}
|
|
4251
4261
|
getBlurTextureSize(e, t) {
|
|
4252
|
-
const n = this.radius >
|
|
4262
|
+
const n = this.radius > ud ? fd : ld;
|
|
4253
4263
|
return {
|
|
4254
4264
|
width: Math.max(Ue, e / n),
|
|
4255
4265
|
height: Math.max(Ue, t / n)
|
|
@@ -4264,23 +4274,23 @@ class ud extends pn {
|
|
|
4264
4274
|
this.blur.resizeOutput(n.width, n.height);
|
|
4265
4275
|
}
|
|
4266
4276
|
}
|
|
4267
|
-
class
|
|
4277
|
+
class hd extends ur {
|
|
4268
4278
|
constructor(e) {
|
|
4269
|
-
super(), this.pipeline = new
|
|
4279
|
+
super(), this.pipeline = new dd(this.context, e), this.disablePostProcessing();
|
|
4270
4280
|
}
|
|
4271
4281
|
}
|
|
4272
|
-
class
|
|
4282
|
+
class md extends hn {
|
|
4273
4283
|
constructor(e, t) {
|
|
4274
4284
|
super(), this.context = e;
|
|
4275
4285
|
const n = {
|
|
4276
4286
|
context: e,
|
|
4277
4287
|
height: e.canvas.height,
|
|
4278
4288
|
width: e.canvas.width
|
|
4279
|
-
}, i = new
|
|
4289
|
+
}, i = new wo({
|
|
4280
4290
|
...n,
|
|
4281
4291
|
radius: t,
|
|
4282
|
-
type:
|
|
4283
|
-
}), o = new
|
|
4292
|
+
type: mn.GAUSSIAN
|
|
4293
|
+
}), o = new fn({ ...n, disableFramebuffer: !0 });
|
|
4284
4294
|
this.addStep({
|
|
4285
4295
|
program: i,
|
|
4286
4296
|
getUniforms: () => ({
|
|
@@ -4299,12 +4309,12 @@ class fd extends pn {
|
|
|
4299
4309
|
this.inputImage = e, this.inputMask = t;
|
|
4300
4310
|
}
|
|
4301
4311
|
}
|
|
4302
|
-
class
|
|
4312
|
+
class pd extends ur {
|
|
4303
4313
|
constructor(e) {
|
|
4304
|
-
super(), this.pipeline = new
|
|
4314
|
+
super(), this.pipeline = new md(this.context, e), this.disablePostProcessing();
|
|
4305
4315
|
}
|
|
4306
4316
|
}
|
|
4307
|
-
class
|
|
4317
|
+
class gd extends yo {
|
|
4308
4318
|
constructor() {
|
|
4309
4319
|
super(...arguments), this.preciseMaskEnabled = !0;
|
|
4310
4320
|
}
|
|
@@ -4319,40 +4329,40 @@ class hd extends wo {
|
|
|
4319
4329
|
e?.value && (this.inputBackgroundImage = await createImageBitmap(e.value), e.value.close());
|
|
4320
4330
|
}
|
|
4321
4331
|
}
|
|
4322
|
-
class
|
|
4332
|
+
class yd extends ur {
|
|
4323
4333
|
constructor() {
|
|
4324
|
-
super(), this.pipeline = new
|
|
4334
|
+
super(), this.pipeline = new gd(this.context);
|
|
4325
4335
|
}
|
|
4326
4336
|
setBackgroundVideo(e) {
|
|
4327
4337
|
this.pipeline.reader = e;
|
|
4328
4338
|
}
|
|
4329
4339
|
}
|
|
4330
|
-
class
|
|
4340
|
+
class ni {
|
|
4331
4341
|
blurBackground(e) {
|
|
4332
|
-
return new
|
|
4342
|
+
return new hd(e);
|
|
4333
4343
|
}
|
|
4334
4344
|
blurSilhouette(e) {
|
|
4335
|
-
return new
|
|
4345
|
+
return new pd(e);
|
|
4336
4346
|
}
|
|
4337
4347
|
imageBackground() {
|
|
4338
|
-
return new
|
|
4348
|
+
return new vo();
|
|
4339
4349
|
}
|
|
4340
4350
|
videoBackground() {
|
|
4341
|
-
return new
|
|
4351
|
+
return new yd();
|
|
4342
4352
|
}
|
|
4343
4353
|
}
|
|
4344
|
-
class
|
|
4354
|
+
class bd {
|
|
4345
4355
|
constructor(e) {
|
|
4346
4356
|
switch (e) {
|
|
4347
4357
|
case Mt.CANVAS:
|
|
4348
|
-
this.factory = new
|
|
4358
|
+
this.factory = new ri();
|
|
4349
4359
|
break;
|
|
4350
4360
|
case Mt.WEBGL:
|
|
4351
|
-
this.factory = new
|
|
4361
|
+
this.factory = new ni();
|
|
4352
4362
|
break;
|
|
4353
4363
|
default:
|
|
4354
|
-
const t =
|
|
4355
|
-
this.factory = t.supported ? new
|
|
4364
|
+
const t = li();
|
|
4365
|
+
this.factory = t.supported ? new ni() : new ri();
|
|
4356
4366
|
}
|
|
4357
4367
|
}
|
|
4358
4368
|
blurBackground(e) {
|
|
@@ -4373,10 +4383,10 @@ class pd {
|
|
|
4373
4383
|
return this.factory;
|
|
4374
4384
|
}
|
|
4375
4385
|
}
|
|
4376
|
-
class
|
|
4386
|
+
class wd {
|
|
4377
4387
|
setBackgroundOptions(e) {
|
|
4378
4388
|
this.renderer && this.renderer.destroy();
|
|
4379
|
-
const t = new
|
|
4389
|
+
const t = new bd(e.renderingOptions?.type);
|
|
4380
4390
|
switch (e.transformerType) {
|
|
4381
4391
|
case "BackgroundBlur":
|
|
4382
4392
|
this.renderer = t.blurBackground(
|
|
@@ -4399,7 +4409,7 @@ class gd {
|
|
|
4399
4409
|
default:
|
|
4400
4410
|
throw `Unknown rendering type [${e.transformerType}]`;
|
|
4401
4411
|
}
|
|
4402
|
-
e.renderingOptions?.type === Mt.WEBGL && (e.renderingOptions.selfieSegmentationType ===
|
|
4412
|
+
e.renderingOptions?.type === Mt.WEBGL && (e.renderingOptions.selfieSegmentationType === Ar.PRECISE ? this.renderer.enablePostProcessing() : e.renderingOptions.selfieSegmentationType === Ar.FAST && this.renderer.disablePostProcessing());
|
|
4403
4413
|
}
|
|
4404
4414
|
setVideoBGReadable(e) {
|
|
4405
4415
|
this.backgroundVideo = e.getReader();
|
|
@@ -4429,7 +4439,7 @@ class gd {
|
|
|
4429
4439
|
return this.renderer?.profileWebgl(e) ?? [];
|
|
4430
4440
|
}
|
|
4431
4441
|
}
|
|
4432
|
-
var
|
|
4442
|
+
var xd = (function() {
|
|
4433
4443
|
var r = typeof document < "u" && document.currentScript ? document.currentScript.src : void 0;
|
|
4434
4444
|
return (function(e) {
|
|
4435
4445
|
e = e || {};
|
|
@@ -4454,34 +4464,34 @@ var yd = (function() {
|
|
|
4454
4464
|
o = null, t.arguments && t.arguments, t.thisProgram && (a = t.thisProgram), t.quit && (c = t.quit);
|
|
4455
4465
|
var g;
|
|
4456
4466
|
t.wasmBinary && (g = t.wasmBinary), t.noExitRuntime, typeof WebAssembly != "object" && Z("no native wasm support detected");
|
|
4457
|
-
var x, v = !1,
|
|
4458
|
-
function
|
|
4467
|
+
var x, v = !1, R = typeof TextDecoder < "u" ? new TextDecoder("utf8") : void 0;
|
|
4468
|
+
function k(l, h, y) {
|
|
4459
4469
|
for (var _ = h + y, S = h; l[S] && !(S >= _); ) ++S;
|
|
4460
|
-
if (S - h > 16 && l.subarray &&
|
|
4461
|
-
return
|
|
4470
|
+
if (S - h > 16 && l.subarray && R)
|
|
4471
|
+
return R.decode(l.subarray(h, S));
|
|
4462
4472
|
for (var P = ""; h < S; ) {
|
|
4463
4473
|
var E = l[h++];
|
|
4464
4474
|
if (!(E & 128)) {
|
|
4465
4475
|
P += String.fromCharCode(E);
|
|
4466
4476
|
continue;
|
|
4467
4477
|
}
|
|
4468
|
-
var
|
|
4478
|
+
var O = l[h++] & 63;
|
|
4469
4479
|
if ((E & 224) == 192) {
|
|
4470
|
-
P += String.fromCharCode((E & 31) << 6 |
|
|
4480
|
+
P += String.fromCharCode((E & 31) << 6 | O);
|
|
4471
4481
|
continue;
|
|
4472
4482
|
}
|
|
4473
4483
|
var H = l[h++] & 63;
|
|
4474
|
-
if ((E & 240) == 224 ? E = (E & 15) << 12 |
|
|
4484
|
+
if ((E & 240) == 224 ? E = (E & 15) << 12 | O << 6 | H : E = (E & 7) << 18 | O << 12 | H << 6 | l[h++] & 63, E < 65536)
|
|
4475
4485
|
P += String.fromCharCode(E);
|
|
4476
4486
|
else {
|
|
4477
|
-
var
|
|
4478
|
-
P += String.fromCharCode(55296 |
|
|
4487
|
+
var An = E - 65536;
|
|
4488
|
+
P += String.fromCharCode(55296 | An >> 10, 56320 | An & 1023);
|
|
4479
4489
|
}
|
|
4480
4490
|
}
|
|
4481
4491
|
return P;
|
|
4482
4492
|
}
|
|
4483
4493
|
function L(l, h) {
|
|
4484
|
-
return l ?
|
|
4494
|
+
return l ? k($e, l, h) : "";
|
|
4485
4495
|
}
|
|
4486
4496
|
function Y(l, h, y) {
|
|
4487
4497
|
for (var _ = 0; _ < l.length; ++_)
|
|
@@ -4492,40 +4502,40 @@ var yd = (function() {
|
|
|
4492
4502
|
return l % h > 0 && (l += h - l % h), l;
|
|
4493
4503
|
}
|
|
4494
4504
|
var N, st, $e, $;
|
|
4495
|
-
function
|
|
4505
|
+
function yn(l) {
|
|
4496
4506
|
N = l, t.HEAP8 = st = new Int8Array(l), t.HEAP16 = new Int16Array(l), t.HEAP32 = $ = new Int32Array(l), t.HEAPU8 = $e = new Uint8Array(l), t.HEAPU16 = new Uint16Array(l), t.HEAPU32 = new Uint32Array(l), t.HEAPF32 = new Float32Array(l), t.HEAPF64 = new Float64Array(l);
|
|
4497
4507
|
}
|
|
4498
4508
|
t.INITIAL_MEMORY;
|
|
4499
|
-
var lr,
|
|
4500
|
-
function
|
|
4509
|
+
var lr, bn = [], wn = [], xn = [];
|
|
4510
|
+
function Eo() {
|
|
4501
4511
|
if (t.preRun)
|
|
4502
4512
|
for (typeof t.preRun == "function" && (t.preRun = [t.preRun]); t.preRun.length; )
|
|
4503
|
-
|
|
4504
|
-
fr(
|
|
4513
|
+
So(t.preRun.shift());
|
|
4514
|
+
fr(bn);
|
|
4505
4515
|
}
|
|
4506
|
-
function
|
|
4507
|
-
fr(
|
|
4516
|
+
function Ao() {
|
|
4517
|
+
fr(wn);
|
|
4508
4518
|
}
|
|
4509
|
-
function
|
|
4519
|
+
function To() {
|
|
4510
4520
|
if (t.postRun)
|
|
4511
4521
|
for (typeof t.postRun == "function" && (t.postRun = [t.postRun]); t.postRun.length; )
|
|
4512
|
-
|
|
4513
|
-
fr(
|
|
4522
|
+
Ro(t.postRun.shift());
|
|
4523
|
+
fr(xn);
|
|
4514
4524
|
}
|
|
4515
|
-
function
|
|
4516
|
-
|
|
4525
|
+
function So(l) {
|
|
4526
|
+
bn.unshift(l);
|
|
4517
4527
|
}
|
|
4518
|
-
function
|
|
4519
|
-
|
|
4528
|
+
function Io(l) {
|
|
4529
|
+
wn.unshift(l);
|
|
4520
4530
|
}
|
|
4521
|
-
function
|
|
4522
|
-
|
|
4531
|
+
function Ro(l) {
|
|
4532
|
+
xn.unshift(l);
|
|
4523
4533
|
}
|
|
4524
4534
|
var fe = 0, We = null;
|
|
4525
|
-
function
|
|
4535
|
+
function ko(l) {
|
|
4526
4536
|
fe++, t.monitorRunDependencies && t.monitorRunDependencies(fe);
|
|
4527
4537
|
}
|
|
4528
|
-
function
|
|
4538
|
+
function Po(l) {
|
|
4529
4539
|
if (fe--, t.monitorRunDependencies && t.monitorRunDependencies(fe), fe == 0 && We) {
|
|
4530
4540
|
var h = We;
|
|
4531
4541
|
We = null, h();
|
|
@@ -4537,13 +4547,13 @@ var yd = (function() {
|
|
|
4537
4547
|
var h = new WebAssembly.RuntimeError(l);
|
|
4538
4548
|
throw i(h), h;
|
|
4539
4549
|
}
|
|
4540
|
-
var
|
|
4541
|
-
function
|
|
4542
|
-
return l.startsWith(
|
|
4550
|
+
var Fo = "data:application/octet-stream;base64,";
|
|
4551
|
+
function vn(l) {
|
|
4552
|
+
return l.startsWith(Fo);
|
|
4543
4553
|
}
|
|
4544
4554
|
var W;
|
|
4545
|
-
W = "tflite-simd.wasm",
|
|
4546
|
-
function
|
|
4555
|
+
W = "tflite-simd.wasm", vn(W) || (W = m(W));
|
|
4556
|
+
function _n(l) {
|
|
4547
4557
|
try {
|
|
4548
4558
|
if (l == W && g)
|
|
4549
4559
|
return new Uint8Array(g);
|
|
@@ -4552,40 +4562,40 @@ var yd = (function() {
|
|
|
4552
4562
|
Z(h);
|
|
4553
4563
|
}
|
|
4554
4564
|
}
|
|
4555
|
-
function
|
|
4565
|
+
function Co() {
|
|
4556
4566
|
return !g && u && typeof fetch == "function" ? fetch(W, { credentials: "same-origin" }).then(function(l) {
|
|
4557
4567
|
if (!l.ok)
|
|
4558
4568
|
throw "failed to load wasm binary file at '" + W + "'";
|
|
4559
4569
|
return l.arrayBuffer();
|
|
4560
4570
|
}).catch(function() {
|
|
4561
|
-
return
|
|
4571
|
+
return _n(W);
|
|
4562
4572
|
}) : Promise.resolve().then(function() {
|
|
4563
|
-
return
|
|
4573
|
+
return _n(W);
|
|
4564
4574
|
});
|
|
4565
4575
|
}
|
|
4566
|
-
function
|
|
4567
|
-
var l = { a:
|
|
4568
|
-
function h(E,
|
|
4576
|
+
function Oo() {
|
|
4577
|
+
var l = { a: es };
|
|
4578
|
+
function h(E, O) {
|
|
4569
4579
|
var H = E.exports;
|
|
4570
|
-
t.asm = H, x = t.asm.q,
|
|
4580
|
+
t.asm = H, x = t.asm.q, yn(x.buffer), lr = t.asm.E, Io(t.asm.r), Po();
|
|
4571
4581
|
}
|
|
4572
|
-
|
|
4582
|
+
ko();
|
|
4573
4583
|
function y(E) {
|
|
4574
4584
|
h(E.instance);
|
|
4575
4585
|
}
|
|
4576
4586
|
function _(E) {
|
|
4577
|
-
return
|
|
4578
|
-
return WebAssembly.instantiate(
|
|
4579
|
-
}).then(function(
|
|
4580
|
-
return
|
|
4581
|
-
}).then(E, function(
|
|
4582
|
-
d("failed to asynchronously prepare wasm: " +
|
|
4587
|
+
return Co().then(function(O) {
|
|
4588
|
+
return WebAssembly.instantiate(O, l);
|
|
4589
|
+
}).then(function(O) {
|
|
4590
|
+
return O;
|
|
4591
|
+
}).then(E, function(O) {
|
|
4592
|
+
d("failed to asynchronously prepare wasm: " + O), Z(O);
|
|
4583
4593
|
});
|
|
4584
4594
|
}
|
|
4585
4595
|
function S() {
|
|
4586
|
-
return !g && typeof WebAssembly.instantiateStreaming == "function" && !
|
|
4587
|
-
var
|
|
4588
|
-
return
|
|
4596
|
+
return !g && typeof WebAssembly.instantiateStreaming == "function" && !vn(W) && typeof fetch == "function" ? fetch(W, { credentials: "same-origin" }).then(function(E) {
|
|
4597
|
+
var O = WebAssembly.instantiateStreaming(E, l);
|
|
4598
|
+
return O.then(y, function(H) {
|
|
4589
4599
|
return d("wasm streaming compile failed: " + H), d("falling back to ArrayBuffer instantiation"), _(y);
|
|
4590
4600
|
});
|
|
4591
4601
|
}) : _(y);
|
|
@@ -4610,49 +4620,49 @@ var yd = (function() {
|
|
|
4610
4620
|
typeof y == "number" ? h.arg === void 0 ? lr.get(y)() : lr.get(y)(h.arg) : y(h.arg === void 0 ? null : h.arg);
|
|
4611
4621
|
}
|
|
4612
4622
|
}
|
|
4613
|
-
function
|
|
4623
|
+
function Mo(l, h, y, _) {
|
|
4614
4624
|
Z("Assertion failed: " + L(l) + ", at: " + [h ? L(h) : "unknown filename", y, _ ? L(_) : "unknown function"]);
|
|
4615
4625
|
}
|
|
4616
|
-
function
|
|
4626
|
+
function Bo(l, h) {
|
|
4617
4627
|
Z("To use dlopen, you need to use Emscripten's linking support, see https://github.com/emscripten-core/emscripten/wiki/Linking");
|
|
4618
4628
|
}
|
|
4619
|
-
function
|
|
4629
|
+
function Do(l, h) {
|
|
4620
4630
|
Z("To use dlopen, you need to use Emscripten's linking support, see https://github.com/emscripten-core/emscripten/wiki/Linking");
|
|
4621
4631
|
}
|
|
4622
|
-
function
|
|
4632
|
+
function Uo() {
|
|
4623
4633
|
Z("");
|
|
4624
4634
|
}
|
|
4625
4635
|
var at;
|
|
4626
4636
|
at = function() {
|
|
4627
4637
|
return performance.now();
|
|
4628
4638
|
};
|
|
4629
|
-
var
|
|
4630
|
-
function
|
|
4631
|
-
return $[
|
|
4639
|
+
var Lo = !0;
|
|
4640
|
+
function zo(l) {
|
|
4641
|
+
return $[En() >> 2] = l, l;
|
|
4632
4642
|
}
|
|
4633
|
-
function
|
|
4643
|
+
function No(l, h) {
|
|
4634
4644
|
var y;
|
|
4635
4645
|
if (l === 0)
|
|
4636
4646
|
y = Date.now();
|
|
4637
|
-
else if ((l === 1 || l === 4) &&
|
|
4647
|
+
else if ((l === 1 || l === 4) && Lo)
|
|
4638
4648
|
y = at();
|
|
4639
4649
|
else
|
|
4640
|
-
return
|
|
4650
|
+
return zo(28), -1;
|
|
4641
4651
|
return $[h >> 2] = y / 1e3 | 0, $[h + 4 >> 2] = y % 1e3 * 1e3 * 1e3 | 0, 0;
|
|
4642
4652
|
}
|
|
4643
|
-
function
|
|
4653
|
+
function $o() {
|
|
4644
4654
|
return 2147483648;
|
|
4645
4655
|
}
|
|
4646
|
-
function
|
|
4656
|
+
function Wo(l, h, y) {
|
|
4647
4657
|
$e.copyWithin(l, h, h + y);
|
|
4648
4658
|
}
|
|
4649
|
-
function
|
|
4659
|
+
function Go(l) {
|
|
4650
4660
|
try {
|
|
4651
|
-
return x.grow(l - N.byteLength + 65535 >>> 16),
|
|
4661
|
+
return x.grow(l - N.byteLength + 65535 >>> 16), yn(x.buffer), 1;
|
|
4652
4662
|
} catch {
|
|
4653
4663
|
}
|
|
4654
4664
|
}
|
|
4655
|
-
function
|
|
4665
|
+
function Vo(l) {
|
|
4656
4666
|
var h = $e.length;
|
|
4657
4667
|
l = l >>> 0;
|
|
4658
4668
|
var y = 2147483648;
|
|
@@ -4661,23 +4671,23 @@ var yd = (function() {
|
|
|
4661
4671
|
for (var _ = 1; _ <= 4; _ *= 2) {
|
|
4662
4672
|
var S = h * (1 + 0.2 / _);
|
|
4663
4673
|
S = Math.min(S, l + 100663296);
|
|
4664
|
-
var P = Math.min(y, Q(Math.max(l, S), 65536)), E =
|
|
4674
|
+
var P = Math.min(y, Q(Math.max(l, S), 65536)), E = Go(P);
|
|
4665
4675
|
if (E)
|
|
4666
4676
|
return !0;
|
|
4667
4677
|
}
|
|
4668
4678
|
return !1;
|
|
4669
4679
|
}
|
|
4670
|
-
function
|
|
4680
|
+
function Ho(l) {
|
|
4671
4681
|
for (var h = at(); at() - h < l; )
|
|
4672
4682
|
;
|
|
4673
4683
|
}
|
|
4674
4684
|
var dr = {};
|
|
4675
|
-
function
|
|
4685
|
+
function jo() {
|
|
4676
4686
|
return a || "./this.program";
|
|
4677
4687
|
}
|
|
4678
4688
|
function Ge() {
|
|
4679
4689
|
if (!Ge.strings) {
|
|
4680
|
-
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, _:
|
|
4690
|
+
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() };
|
|
4681
4691
|
for (var y in dr)
|
|
4682
4692
|
dr[y] === void 0 ? delete h[y] : h[y] = dr[y];
|
|
4683
4693
|
var _ = [];
|
|
@@ -4689,7 +4699,7 @@ var yd = (function() {
|
|
|
4689
4699
|
}
|
|
4690
4700
|
var ct = { mappings: {}, buffers: [null, [], []], printChar: function(l, h) {
|
|
4691
4701
|
var y = ct.buffers[l];
|
|
4692
|
-
h === 0 || h === 10 ? ((l === 1 ? b : d)(
|
|
4702
|
+
h === 0 || h === 10 ? ((l === 1 ? b : d)(k(y, 0)), y.length = 0) : y.push(h);
|
|
4693
4703
|
}, varargs: void 0, get: function() {
|
|
4694
4704
|
ct.varargs += 4;
|
|
4695
4705
|
var l = $[ct.varargs - 4 >> 2];
|
|
@@ -4700,14 +4710,14 @@ var yd = (function() {
|
|
|
4700
4710
|
}, get64: function(l, h) {
|
|
4701
4711
|
return l;
|
|
4702
4712
|
} };
|
|
4703
|
-
function
|
|
4713
|
+
function Yo(l, h) {
|
|
4704
4714
|
var y = 0;
|
|
4705
4715
|
return Ge().forEach(function(_, S) {
|
|
4706
4716
|
var P = h + y;
|
|
4707
4717
|
$[l + S * 4 >> 2] = P, Y(_, P), y += _.length + 1;
|
|
4708
4718
|
}), 0;
|
|
4709
4719
|
}
|
|
4710
|
-
function
|
|
4720
|
+
function Qo(l, h) {
|
|
4711
4721
|
var y = Ge();
|
|
4712
4722
|
$[l >> 2] = y.length;
|
|
4713
4723
|
var _ = 0;
|
|
@@ -4715,23 +4725,23 @@ var yd = (function() {
|
|
|
4715
4725
|
_ += S.length + 1;
|
|
4716
4726
|
}), $[h >> 2] = _, 0;
|
|
4717
4727
|
}
|
|
4718
|
-
function
|
|
4719
|
-
|
|
4728
|
+
function qo(l) {
|
|
4729
|
+
rs(l);
|
|
4720
4730
|
}
|
|
4721
|
-
function
|
|
4731
|
+
function Xo(l) {
|
|
4722
4732
|
return 0;
|
|
4723
4733
|
}
|
|
4724
|
-
function
|
|
4734
|
+
function Ko(l, h, y, _, S) {
|
|
4725
4735
|
}
|
|
4726
|
-
function
|
|
4736
|
+
function Jo(l, h, y, _) {
|
|
4727
4737
|
for (var S = 0, P = 0; P < y; P++) {
|
|
4728
|
-
for (var E = $[h + P * 8 >> 2],
|
|
4738
|
+
for (var E = $[h + P * 8 >> 2], O = $[h + (P * 8 + 4) >> 2], H = 0; H < O; H++)
|
|
4729
4739
|
ct.printChar(l, $e[E + H]);
|
|
4730
|
-
S +=
|
|
4740
|
+
S += O;
|
|
4731
4741
|
}
|
|
4732
4742
|
return $[_ >> 2] = S, 0;
|
|
4733
4743
|
}
|
|
4734
|
-
function
|
|
4744
|
+
function Zo() {
|
|
4735
4745
|
if (typeof crypto == "object" && typeof crypto.getRandomValues == "function") {
|
|
4736
4746
|
var l = new Uint8Array(1);
|
|
4737
4747
|
return function() {
|
|
@@ -4742,13 +4752,13 @@ var yd = (function() {
|
|
|
4742
4752
|
};
|
|
4743
4753
|
}
|
|
4744
4754
|
function ut(l, h) {
|
|
4745
|
-
ut.randomDevice || (ut.randomDevice =
|
|
4755
|
+
ut.randomDevice || (ut.randomDevice = Zo());
|
|
4746
4756
|
for (var y = 0; y < h; y++)
|
|
4747
4757
|
st[l + y >> 0] = ut.randomDevice();
|
|
4748
4758
|
return 0;
|
|
4749
4759
|
}
|
|
4750
|
-
var
|
|
4751
|
-
|
|
4760
|
+
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 };
|
|
4761
|
+
Oo(), t.___wasm_call_ctors = function() {
|
|
4752
4762
|
return (t.___wasm_call_ctors = t.asm.r).apply(null, arguments);
|
|
4753
4763
|
}, t._getModelBufferMemoryOffset = function() {
|
|
4754
4764
|
return (t._getModelBufferMemoryOffset = t.asm.s).apply(null, arguments);
|
|
@@ -4775,20 +4785,20 @@ var yd = (function() {
|
|
|
4775
4785
|
}, t._isGPUEnabled = function() {
|
|
4776
4786
|
return (t._isGPUEnabled = t.asm.D).apply(null, arguments);
|
|
4777
4787
|
};
|
|
4778
|
-
var
|
|
4779
|
-
return (
|
|
4788
|
+
var En = t.___errno_location = function() {
|
|
4789
|
+
return (En = t.___errno_location = t.asm.F).apply(null, arguments);
|
|
4780
4790
|
}, lt;
|
|
4781
|
-
function
|
|
4791
|
+
function ts(l) {
|
|
4782
4792
|
this.name = "ExitStatus", this.message = "Program terminated with exit(" + l + ")", this.status = l;
|
|
4783
4793
|
}
|
|
4784
4794
|
We = function l() {
|
|
4785
4795
|
lt || hr(), lt || (We = l);
|
|
4786
4796
|
};
|
|
4787
4797
|
function hr(l) {
|
|
4788
|
-
if (fe > 0 || (
|
|
4798
|
+
if (fe > 0 || (Eo(), fe > 0))
|
|
4789
4799
|
return;
|
|
4790
4800
|
function h() {
|
|
4791
|
-
lt || (lt = !0, t.calledRun = !0, !v && (
|
|
4801
|
+
lt || (lt = !0, t.calledRun = !0, !v && (Ao(), n(t), t.onRuntimeInitialized && t.onRuntimeInitialized(), To()));
|
|
4792
4802
|
}
|
|
4793
4803
|
t.setStatus ? (t.setStatus("Running..."), setTimeout(function() {
|
|
4794
4804
|
setTimeout(function() {
|
|
@@ -4797,11 +4807,11 @@ var yd = (function() {
|
|
|
4797
4807
|
}, 1)) : h();
|
|
4798
4808
|
}
|
|
4799
4809
|
t.run = hr;
|
|
4800
|
-
function
|
|
4801
|
-
|
|
4810
|
+
function rs(l, h) {
|
|
4811
|
+
ns(l);
|
|
4802
4812
|
}
|
|
4803
|
-
function
|
|
4804
|
-
c(l, new
|
|
4813
|
+
function ns(l) {
|
|
4814
|
+
c(l, new ts(l));
|
|
4805
4815
|
}
|
|
4806
4816
|
if (t.preInit)
|
|
4807
4817
|
for (typeof t.preInit == "function" && (t.preInit = [t.preInit]); t.preInit.length > 0; )
|
|
@@ -4809,17 +4819,17 @@ var yd = (function() {
|
|
|
4809
4819
|
return hr(), e.ready;
|
|
4810
4820
|
});
|
|
4811
4821
|
})();
|
|
4812
|
-
class
|
|
4822
|
+
class vd {
|
|
4813
4823
|
constructor() {
|
|
4814
4824
|
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;
|
|
4815
4825
|
}
|
|
4816
4826
|
}
|
|
4817
|
-
const
|
|
4818
|
-
async function
|
|
4819
|
-
let t = new
|
|
4827
|
+
const _d = "https://d3opqjmqzxf057.cloudfront.net/vonage-tensorflow-wasm/tflite-simd-wasm/1.1.3/", Ed = "https://d3opqjmqzxf057.cloudfront.net/ml/selfie_segmentation/4.0.0/selfie_segmentation_landscape.tflite";
|
|
4828
|
+
async function Ad(r = _d, e = Ed) {
|
|
4829
|
+
let t = new vd();
|
|
4820
4830
|
var n = new Promise(function(i, o) {
|
|
4821
4831
|
async function s() {
|
|
4822
|
-
return
|
|
4832
|
+
return xd({
|
|
4823
4833
|
locateFile: function(u) {
|
|
4824
4834
|
return r + u;
|
|
4825
4835
|
}
|
|
@@ -4884,8 +4894,8 @@ async function vd(r = wd, e = xd) {
|
|
|
4884
4894
|
});
|
|
4885
4895
|
return n;
|
|
4886
4896
|
}
|
|
4887
|
-
const
|
|
4888
|
-
class
|
|
4897
|
+
const Td = 0.1, Sd = 0.7, Id = "https://d3opqjmqzxf057.cloudfront.net/ml/vonage_selfie_segmenter/float16/v1/vonage_selfie_segmenter.tflite";
|
|
4898
|
+
class Rd {
|
|
4889
4899
|
constructor() {
|
|
4890
4900
|
this.canvas = new OffscreenCanvas(0, 0), this.context = this.canvas.getContext(
|
|
4891
4901
|
"2d",
|
|
@@ -4911,7 +4921,7 @@ class Td {
|
|
|
4911
4921
|
});
|
|
4912
4922
|
}
|
|
4913
4923
|
async loadMediapipeAssets(e, t) {
|
|
4914
|
-
this.modelAssetUriPath = e ||
|
|
4924
|
+
this.modelAssetUriPath = e || Id;
|
|
4915
4925
|
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: o, ImageSegmenter: s } = await import(
|
|
4916
4926
|
/* @vite-ignore */
|
|
4917
4927
|
n
|
|
@@ -4961,7 +4971,7 @@ class Td {
|
|
|
4961
4971
|
}), o = [255, 0, 0];
|
|
4962
4972
|
for (let s = 0; s < i?.length; s++) {
|
|
4963
4973
|
const a = 1 - i[s];
|
|
4964
|
-
a >
|
|
4974
|
+
a > Td ? (a < Sd ? (this.mask.data[s * 4] = o[0] * a, this.mask.data[s * 4 + 3] = 255 * a) : (this.mask.data[s * 4] = o[0], this.mask.data[s * 4 + 3] = 255), this.mask.data[s * 4 + 1] = o[1], this.mask.data[s * 4 + 2] = o[2]) : this.mask.data[s * 4] = this.mask.data[s * 4 + 1] = this.mask.data[s * 4 + 2] = this.mask.data[s * 4 + 3] = 0;
|
|
4965
4975
|
}
|
|
4966
4976
|
return this.previousConfidenceMask = i.slice(), this.mask;
|
|
4967
4977
|
}
|
|
@@ -4974,7 +4984,7 @@ class Td {
|
|
|
4974
4984
|
return t + (e - t) * (f * 0.9);
|
|
4975
4985
|
}
|
|
4976
4986
|
}
|
|
4977
|
-
class
|
|
4987
|
+
class kd {
|
|
4978
4988
|
constructor() {
|
|
4979
4989
|
this.canvas = new OffscreenCanvas(0, 0), this.context = this.canvas.getContext(
|
|
4980
4990
|
"2d",
|
|
@@ -4990,7 +5000,7 @@ class Sd {
|
|
|
4990
5000
|
), this.inputOffset = this.infos.inputMemoryOffset / 4, this.outputOffset = this.infos.outputMemoryOffset / 4);
|
|
4991
5001
|
}
|
|
4992
5002
|
async initWasm(e, t) {
|
|
4993
|
-
this.infos = await
|
|
5003
|
+
this.infos = await Ad(
|
|
4994
5004
|
e,
|
|
4995
5005
|
t
|
|
4996
5006
|
);
|
|
@@ -5026,16 +5036,16 @@ class Sd {
|
|
|
5026
5036
|
return this.infos?.selectedTFLite?._isGPUEnabled() ?? !1;
|
|
5027
5037
|
}
|
|
5028
5038
|
}
|
|
5029
|
-
class
|
|
5039
|
+
class Pd {
|
|
5030
5040
|
constructor() {
|
|
5031
|
-
this.reporter = new
|
|
5041
|
+
this.reporter = new Ua(), this.isEnabled = !0;
|
|
5032
5042
|
}
|
|
5033
5043
|
async init(e, t) {
|
|
5034
|
-
t.segmentationOptions?.lightWeightEngine === !0 ? this.selfieSegmentation = new
|
|
5044
|
+
t.segmentationOptions?.lightWeightEngine === !0 ? this.selfieSegmentation = new kd() : this.selfieSegmentation = new Rd(), this.selfieSegmentation?.init(
|
|
5035
5045
|
t.modelAssetUriPath,
|
|
5036
5046
|
t.mediapipeBaseAssetsUri,
|
|
5037
5047
|
t.segmentationOptions?.gpuSupport
|
|
5038
|
-
), this.backgroundFilter = new
|
|
5048
|
+
), this.backgroundFilter = new wd(), this.report({
|
|
5039
5049
|
variation: "Create"
|
|
5040
5050
|
});
|
|
5041
5051
|
}
|
|
@@ -5076,7 +5086,7 @@ class Id {
|
|
|
5076
5086
|
}
|
|
5077
5087
|
report(e) {
|
|
5078
5088
|
this.reporter.send({
|
|
5079
|
-
version:
|
|
5089
|
+
version: La,
|
|
5080
5090
|
action: "MlTransformers",
|
|
5081
5091
|
transformerType: this.backgroundOptions?.transformerType,
|
|
5082
5092
|
config: JSON.stringify(this.backgroundOptions),
|
|
@@ -5084,9 +5094,9 @@ class Id {
|
|
|
5084
5094
|
});
|
|
5085
5095
|
}
|
|
5086
5096
|
}
|
|
5087
|
-
const
|
|
5097
|
+
const pn = class pn {
|
|
5088
5098
|
constructor() {
|
|
5089
|
-
this.backgroundTransformer = new
|
|
5099
|
+
this.backgroundTransformer = new Pd(), this.mediaProcessor = new ui(), this.rate = 30, this.eventsQueue = [], this.frameTransformLatencyMs = [];
|
|
5090
5100
|
}
|
|
5091
5101
|
async init(e, t) {
|
|
5092
5102
|
this.frameTransformLatencyMs = [], await this.backgroundTransformer.init(e, t), await this.mediaProcessor.setTransformers([this.backgroundTransformer]), this.mediaProcessor.setTrackExpectedRate(this.rate), this.mediaProcessor.onAny((n, i) => {
|
|
@@ -5134,13 +5144,13 @@ const yn = class yn {
|
|
|
5134
5144
|
);
|
|
5135
5145
|
}
|
|
5136
5146
|
};
|
|
5137
|
-
|
|
5138
|
-
let
|
|
5139
|
-
const Ao = '(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 jr=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 $i(r){return[ImageBitmap,ReadableStream,WritableStream].some(t=>r instanceof t)}function Me(r,e){const{id:t,type:n}=r,i=Array.isArray(e)?e:[e];postMessage({id:t,type:n,result:e},i.filter(s=>$i(s)))}Vt("workerized",{});function Yr(){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"),Xr=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 Be(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 Wi(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 Qr(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=Be(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=Be(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 qr(r){if(r===void 0)return Kr;if(!Array.isArray(r))throw new TypeError("`methodNames` must be an array of strings");for(const e of r)if(!Kr.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=qr(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 Qr(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),Wi(this,e,t);const i=(n=Ee(this,e))!=null?n:new Set,s=K.get(this),o=[...i],a=we(e)?[]:[...s];await Xr,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 Xr;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 Qr(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=Be(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=Be(this,u))==null?void 0:i.size)!=null?s:0)+((a=(o=Be(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=qr(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 Kr=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 Vi(r){return r.onAny&&r.emit}async function Hi(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}`;Me(r,await e.instance[t](...n??[]))}const Jr=Vt("registeredWorkers",{});function ji(r,e){e.workerId=r,Yr()&&(Jr[e.workerId]=e)}function Yi(r,e){if(!r.args)throw"Missing className while initializing worker";const[t,n]=r.args,i=Jr[t];if(i)e.instance=new i(r.args.slice(1));else throw`unknown worker class ${t}`;qe(n,jr),Vi(e.instance)&&e.instance.onAny((s,o)=>{Me({type:xe.EVENT},{name:s,data:o})}),Me(r,typeof e.instance!==void 0)}async function Xi(r,e){const{args:t}=r;if(!e.instance)throw"instance not initialized";let n;e.instance.terminate&&(n=await e.instance.terminate(...t??[])),Me(r,n)}function Qi(r){if(!r.args)throw"Missing globals while syncing";qe(r.args[0],jr),Me(r,{})}function qi(){const r={};onmessage=async e=>{const t=e.data;switch(t.type){case xe.INIT:Yi(t,r);break;case xe.FORWARD:Hi(t,r);break;case xe.TERMINATE:Xi(t,r);break;case xe.GLOBALS_SYNC:Qi(t);break}}}Yr()&&qi();var jt;self.MediaStreamTrackProcessor||(self.MediaStreamTrackProcessor=(jt=class{constructor(r){const e=r.track??r;e.kind=="video"?this.readable=new ReadableStream({async start(t){e.addEventListener("ended",()=>t.close(),{once:!0}),this.video=document.createElement("video"),this.video.srcObject=new MediaStream([e]),await Promise.all([this.video.play(),new Promise(n=>this.video.onloadedmetadata=n)]),this.track=e,this.canvas=new OffscreenCanvas(this.video.videoWidth,this.video.videoHeight),this.ctx=this.canvas.getContext("2d",{desynchronized:!0}),this.t1=performance.now()},async pull(t){if(e.readyState=="ended")return t.close();const n=e.getSettings().frameRate||30;for(;performance.now()-this.t1<1e3/n;)if(await new Promise(i=>requestAnimationFrame(i)),e.readyState=="ended")return t.close();this.canvas.width=this.video.videoWidth,this.canvas.height=this.video.videoHeight,this.t1=performance.now(),this.ctx.drawImage(this.video,0,0),t.enqueue(new VideoFrame(this.canvas,{timestamp:this.t1}))}}):e.kind=="audio"&&(this.readable=new ReadableStream({async start(t){e.addEventListener("ended",()=>t.close(),{once:!0}),this.ac=new AudioContext,this.arrays=[];function n(){registerProcessor("mstp-shim",class extends AudioWorkletProcessor{process(i){return this.port.postMessage(i),!0}})}await this.ac.audioWorklet.addModule(`data:text/javascript,(${n.toString()})()`),this.node=new AudioWorkletNode(this.ac,"mstp-shim"),this.ac.createMediaStreamSource(new MediaStream([e])).connect(this.node),this.node.port.addEventListener("message",({data:i})=>i[0][0]&&this.arrays.push(i))},async pull(t){if(e.readyState=="ended")return t.close();for(;!this.arrays.length;)if(await new Promise(s=>this.node.port.onmessage=s),e.readyState=="ended")return t.close();const[n]=this.arrays.shift(),i=new Float32Array(n.reduce((s,o)=>s+o.length,0));n.reduce((s,o)=>(i.set(o,s),s+o.length),0),t.enqueue(new AudioData({format:"f32-planar",sampleRate:this.ac.sampleRate,numberOfFrames:n[0].length,numberOfChannels:n.length,timestamp:this.ac.currentTime*1e6|0,data:i,transfer:[i.buffer]}))}}))}},jt.__POLYFILLED=!0,jt));var Yt;self.MediaStreamTrackGenerator||(self.MediaStreamTrackGenerator=(Yt=class{constructor({kind:r}){if(r=="video"){const e=document.createElement("canvas"),t=e.getContext("2d",{desynchronized:!0}),n=e.captureStream().getVideoTracks()[0];return n.writable=new WritableStream({write(i){e.width=i.displayWidth,e.height=i.displayHeight,t.drawImage(i,0,0,e.width,e.height),i.close()}}),n}else if(r=="audio"){const e=new AudioContext,t=e.createMediaStreamDestination(),[n]=t.stream.getAudioTracks();return n.writable=new WritableStream({async start(i){this.arrays=[];function s(){registerProcessor("mstg-shim",class extends AudioWorkletProcessor{constructor(){super(),this.arrays=[],this.arrayOffset=0,this.port.onmessage=({data:o})=>this.arrays.push(o),this.emptyArray=new Float32Array(0)}process(o,[[a]]){for(let c=0;c<a.length;c++)(!this.array||this.arrayOffset>=this.array.length)&&(this.array=this.arrays.shift()||this.emptyArray,this.arrayOffset=0),a[c]=this.array[this.arrayOffset++]||0;return!0}})}return await e.audioWorklet.addModule(`data:text/javascript,(${s.toString()})()`),this.node=new AudioWorkletNode(e,"mstg-shim"),this.node.connect(t),n},write(i){const s=new Float32Array(i.numberOfFrames*i.numberOfChannels);i.copyTo(s,{planeIndex:0}),this.node.port.postMessage(s,[s.buffer]),i.close()}}),n}}},Yt.__POLYFILLED=!0,Yt));const J=new WeakMap,ue=new WeakMap,Y=new WeakMap,nt=Symbol("anyProducer"),Zr=Promise.resolve(),it=Symbol("listenerAdded"),st=Symbol("listenerRemoved");let ot=!1,Xt=!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 De(r,e){const t=at(e)?e:nt,n=Y.get(r);if(n.has(t))return n.get(t)}function Ki(r,e,t){const n=Y.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 en(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,Y.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&&Y.get(r).delete(a))}return n(),arguments.length>0?{done:!0,value:await o}:{done:!0}},[Symbol.asyncIterator](){return this}}}function tn(r){if(r===void 0)return rn;if(!Array.isArray(r))throw new TypeError("`methodNames` must be an array of strings");for(const e of r)if(!rn.includes(e))throw typeof e!="string"?new TypeError("`methodNames` element must be a string"):new Error(`${e} is not Emittery method`);return r}const Se=r=>r===it||r===st;function ut(r,e,t){if(Se(e))try{ot=!0,r.emit(e,t)}finally{ot=!1}}class X{static mixin(e,t){return t=tn(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 X}),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 Xt;const{env:e}=globalThis.process??{env:{}};return e.DEBUG==="emittery"||e.DEBUG==="*"||Xt}static set isDebugEnabled(e){Xt=e}constructor(e={}){J.set(this,new Set),ue.set(this,new Map),Y.set(this,new Map),Y.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){(X.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),Se(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),Se(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 en(this,e)}async emit(e,t){if(Te(e),Se(e)&&!ot)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");this.logIfDebugEnabled("emit",e,t),Ki(this,e,t);const n=Ae(this,e)??new Set,i=J.get(this),s=[...n],o=Se(e)?[]:[...i];await Zr,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),Se(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 Zr;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 en(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=De(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 Y.get(this).entries()){for(const s of i)s.finish();i.clear(),Y.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)+(De(this,n)?.size??0)+(De(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 Y.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=tn(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 rn=Object.getOwnPropertyNames(X.prototype).filter(r=>r!=="constructor");Object.defineProperty(X,"listenerAdded",{value:it,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(X,"listenerRemoved",{value:st,writable:!1,enumerable:!0,configurable:!1});var Ji=Object.defineProperty,Zi=(r,e,t)=>e in r?Ji(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,es=(r,e,t)=>(Zi(r,e+"",t),t);const ts="hlg.tokbox.com/prod/logging/vcp_webrtc",rs="https://",ns=1e4;let ft;const is=new Uint8Array(16);function ss(){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(is)}const F=[];for(let r=0;r<256;++r)F.push((r+256).toString(16).slice(1));function os(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 as=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),nn={randomUUID:as};function cs(r,e,t){if(nn.randomUUID&&!r)return nn.randomUUID();r=r||{};const n=r.random||(r.rng||ss)();return n[6]=n[6]&15|64,n[8]=n[8]&63|128,os(n)}function Qt(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=Qt("globals",{});var fe=(r=>(r.INIT="INIT",r.FORWARD="FORWARD",r.TERMINATE="TERMINATE",r.GLOBALS_SYNC="GLOBALS_SYNC",r))(fe||{});function sn(r){return[ImageBitmap,ReadableStream,WritableStream].some(e=>r instanceof e)}let us=0;function fs(r,e,t,n,i){const s=us++;return r.postMessage({id:s,type:e,functionName:t,args:n},n.filter(o=>sn(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=>sn(s)))}const on=Qt("workerized",{});function an(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}async function ls(){if(an())Oe({type:fe.GLOBALS_SYNC},Z);else{const r=[];for(const e in on){const{worker:t,resolvers:n}=on[e].workerContext;t&&r.push(fs(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 ds(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 hs=Qt("registeredWorkers",{});function ms(r,e){if(!r.args)throw"Missing className while initializing worker";const[t,n]=r.args,i=hs[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 ps(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 gs(r){if(!r.args)throw"Missing globals while syncing";lt(r.args[0],Z),Oe(r,{})}function ys(){const r={};onmessage=async e=>{const t=e.data;switch(t.type){case fe.INIT:ms(t,r);break;case fe.FORWARD:ds(t,r);break;case fe.TERMINATE:ps(t,r);break;case fe.GLOBALS_SYNC:gs(t);break}}}an()&&ys();function bs(r,e){return Z[r]||(Z[r]=e),[()=>Z[r],async t=>{Z[r]=t,await ls()}]}function xs(r,e){return bs(r,e)}const[_s,Es]=xs("metadata");function ws(r){Es(r)}function qt(){return _s()}let Kt=class{constructor(e,t){es(this,"uuid"),this.config=e,this.uuid=t??cs()}async send(e){var t,n,i;const{appId:s,sourceType:o}=(t=qt())!=null?t:{};if(!s||!o)return"metadata missing";const a=new AbortController,c=setTimeout(()=>a.abort(),ns);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=qt().proxyUrl)!=null?e:rs;return t+=(t.at(-1)==="/"?"":"/")+ts,t}getHeaders(){return{"Content-Type":"application/json"}}buildReport(e){const t=qt();return{guid:this.uuid,...e,applicationId:t.appId,timestamp:Date.now(),proxyUrl:t.proxyUrl,source:t.sourceType}}};const dt="3.0.0",Jt=class{};Jt.updates={transformer_new:"New transformer",transformer_null:"Null transformer"},Jt.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=Jt;function vs(r){return typeof r=="object"&&r!==null&&"message"in r&&typeof r.message=="string"}function Ts(r){if(vs(r))return r;try{return new Error(JSON.stringify(r))}catch{return new Error(String(r))}}function Zt(r){return Ts(r).message}class As{constructor(e,t){this.config=e,this.frameTransformedCount=0,this.frameFromSourceCount=0,this.startAt=0,this.reporter=new Kt(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 er=(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||{});const Ss=500,Is=.8;class Rs extends X{constructor(e,t){super(),this.reporter_=new Kt,this.reporterQos_=new As({loggingIntervalFrameCount:Ss,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:Zt(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:Zt(n)});const i={eventMetaData:{transformerIndex:this.index_},error:n,function:"transform"};this.emit("error",i)}if(this.trackExpectedRate_!=-1&&this.trackExpectedRate_*Is>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:Zt(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 Fs extends X{constructor(e){super(),this.transformers_=[],this.trackExpectedRate_=-1;for(let t=0;t<e.length;t++){let n=new Rs(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 Ps extends X{constructor(){super(),this.reporter_=new Kt,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 Fs(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=er.pipeline_restarted:i==="pipeline_started_with_error"&&(i=er.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 ks=Object.defineProperty,Cs=(r,e,t)=>e in r?ks(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ms=(r,e,t)=>(Cs(r,e+"",t),t);const Bs="hlg.tokbox.com/prod/logging/vcp_webrtc",Ds="https://",Os=1e4;let ht;const Us=new Uint8Array(16);function Ns(){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(Us)}const P=[];for(let r=0;r<256;++r)P.push((r+256).toString(16).slice(1));function Ls(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 zs=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),cn={randomUUID:zs};function Gs(r,e,t){if(cn.randomUUID&&!e&&!r)return cn.randomUUID();r=r||{};const n=r.random||(r.rng||Ns)();return n[6]=n[6]&15|64,n[8]=n[8]&63|128,Ls(n)}function tr(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=tr("globals",{});var de=(r=>(r.INIT="INIT",r.FORWARD="FORWARD",r.TERMINATE="TERMINATE",r.GLOBALS_SYNC="GLOBALS_SYNC",r))(de||{});function un(r){return[ImageBitmap,ReadableStream,WritableStream].some(e=>r instanceof e)}let $s=0;function Ws(r,e,t,n,i){const s=$s++;return r.postMessage({id:s,type:e,functionName:t,args:n},n.filter(o=>un(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=>un(s)))}const fn=tr("workerized",{});function ln(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}async function Vs(){if(ln())Ue({type:de.GLOBALS_SYNC},ee);else{const r=[];for(const e in fn){const{worker:t,resolvers:n}=fn[e].workerContext;t&&r.push(Ws(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 Hs(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 js=tr("registeredWorkers",{});function Ys(r,e){if(!r.args)throw"Missing className while initializing worker";const[t,n]=r.args,i=js[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 Xs(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 Qs(r){if(!r.args)throw"Missing globals while syncing";mt(r.args[0],ee),Ue(r,{})}function qs(){const r={};onmessage=async e=>{const t=e.data;switch(t.type){case de.INIT:Ys(t,r);break;case de.FORWARD:Hs(t,r);break;case de.TERMINATE:Xs(t,r);break;case de.GLOBALS_SYNC:Qs(t);break}}}ln()&&qs();function Ks(r,e){return ee[r]||(ee[r]=e),[()=>ee[r],async t=>{ee[r]=t,await Vs()}]}function Js(r,e){return Ks(r,e)}const[Zs]=Js("metadata");function rr(){return Zs()}class eo{constructor(e){Ms(this,"uuid",Gs()),this.config=e}async send(e){var t,n,i;const{appId:s,sourceType:o}=(t=rr())!=null?t:{};if(!s||!o)return"metadata missing";const a=new AbortController,c=setTimeout(()=>a.abort(),Os);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=rr().proxyUrl)!=null?e:Ds;return t+=(t.at(-1)==="/"?"":"/")+Bs,t}getHeaders(){return{"Content-Type":"application/json"}}buildReport(e){const t=rr();return{guid:this.uuid,...e,applicationId:t.appId,timestamp:Date.now(),proxyUrl:t.proxyUrl,source:t.sourceType}}}const to="7.0.0-alpha.2";var pt=(r=>(r.Low="Low",r.High="High",r))(pt||{}),nr=(r=>(r.FAST="FAST",r.PRECISE="PRECISE",r))(nr||{}),gt=(r=>(r.CANVAS="CANVAS",r.WEBGL="WEBGL",r))(gt||{});function ro(){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 ir{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 no extends ir{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 io extends ir{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 so extends ir{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 sr=5120,Ne=5121,or=5122,ar=5123,cr=5124,ur=5125,fr=5126,oo=32819,ao=32820,co=33635,uo=5131,fo=33640,lo=35899,ho=35902,mo=36269,po=34042,dn={};{const r=dn;r[sr]=Int8Array,r[Ne]=Uint8Array,r[or]=Int16Array,r[ar]=Uint16Array,r[cr]=Int32Array,r[ur]=Uint32Array,r[fr]=Float32Array,r[oo]=Uint16Array,r[ao]=Uint16Array,r[co]=Uint16Array,r[uo]=Uint16Array,r[fo]=Uint32Array,r[lo]=Uint32Array,r[ho]=Uint32Array,r[mo]=Uint32Array,r[po]=Uint32Array}function lr(r){if(r instanceof Int8Array)return sr;if(r instanceof Uint8Array||r instanceof Uint8ClampedArray)return Ne;if(r instanceof Int16Array)return or;if(r instanceof Uint16Array)return ar;if(r instanceof Int32Array)return cr;if(r instanceof Uint32Array)return ur;if(r instanceof Float32Array)return fr;throw new Error("unsupported typed array type")}function hn(r){if(r===Int8Array)return sr;if(r===Uint8Array||r===Uint8ClampedArray)return Ne;if(r===Int16Array)return or;if(r===Uint16Array)return ar;if(r===Int32Array)return cr;if(r===Uint32Array)return ur;if(r===Float32Array)return fr;throw new Error("unsupported typed array type")}function mn(r){const e=dn[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 pn(...r){console.error(...r)}const gn=new Map;function bt(r,e){if(!r||typeof r!="object")return!1;let t=gn.get(e);t||(t=new WeakMap,gn.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 go(r,e){return typeof WebGLBuffer<"u"&&bt(e,"WebGLBuffer")}function yo(r,e){return typeof WebGLRenderbuffer<"u"&&bt(e,"WebGLRenderbuffer")}function dr(r,e){return typeof WebGLTexture<"u"&&bt(e,"WebGLTexture")}function bo(r,e){return typeof WebGLSampler<"u"&&bt(e,"WebGLSampler")}const yn=35044,he=34962,xo=34963,_o=34660,Eo=5120,wo=5121,vo=5122,To=5123,Ao=5124,So=5125,bn=5126,xn={attribPrefix:""};function Io(r,e,t,n,i){r.bindBuffer(e,t),r.bufferData(e,n,i||yn)}function _n(r,e,t,n){if(go(r,e))return e;t=t||he;const i=r.createBuffer();return Io(r,t,i,e,n),i}function En(r){return r==="indices"}function Ro(r){return r===Int8Array||r===Uint8Array}function Fo(r){return r.length?r:r.data}const Po=/coord|texture/i,ko=/color|colour/i;function Co(r,e){let t;if(Po.test(r)?t=2:ko.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 Mo(r,e,t){return r.numComponents||r.size||Co(e,t||Fo(r).length)}function wn(r,e){if(yt(r))return r;if(yt(r.data))return r.data;Array.isArray(r)&&(r={data:r});let t=r.type?hr(r.type):void 0;return t||(En(e)?t=Uint16Array:t=Float32Array),new t(r.data)}function Bo(r){return typeof r=="number"?r:r?hn(r):bn}function hr(r){return typeof r=="number"?mn(r):r||Float32Array}function Do(r,e){return{buffer:e.buffer,numValues:24,type:Bo(e.type),arrayType:hr(e.type)}}function Oo(r,e){const t=e.data||e,n=hr(e.type),i=t*n.BYTES_PER_ELEMENT,s=r.createBuffer();return r.bindBuffer(he,s),r.bufferData(he,i,e.drawType||yn),{buffer:s,numValues:t,type:hn(n),arrayType:n}}function Uo(r,e,t){const n=wn(e,t);return{arrayType:n.constructor,buffer:_n(r,n,void 0,e.drawType),type:lr(n),numValues:0}}function No(r,e){const t={};return Object.keys(e).forEach(function(n){if(!En(n)){const i=e[n],s=i.attrib||i.name||i.attribName||xn.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=Do:typeof i=="number"||typeof i.data=="number"?o=Oo:o=Uo;const{buffer:a,type:c,numValues:u,arrayType:d}=o(r,i,n),m=i.normalize!==void 0?i.normalize:Ro(d),p=Mo(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 Lo(r,e){return e===Eo||e===wo?1:e===vo||e===To?2:e===Ao||e===So||e===bn?4:0}const mr=["position","positions","a_position"];function zo(r,e){let t,n;for(n=0;n<mr.length&&(t=mr[n],!(t in e||(t=xn.attribPrefix+t,t in e)));++n);n===mr.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,_o);r.bindBuffer(he,null);const o=Lo(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 Go(r,e,t){const n=No(r,e),i=Object.assign({},t||{});i.attribs=Object.assign({},t?t.attribs:{},n);const s=e.indices;if(s){const o=wn(s,"indices");i.indices=_n(r,o,xo),i.numElements=o.length,i.elementType=lr(o)}else i.numElements||(i.numElements=zo(r,i.attribs));return i}function Le(r){return!!r.texStorage2D}const vn=(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,Tn=(function(){let r;return function(){return r=r||(typeof document<"u"&&document.createElement?document.createElement("canvas").getContext("2d"):null),r}})(),An=6406,V=6407,A=6408,Sn=6409,In=6410,Ge=6402,Rn=34041,xt=33071,$o=9728,Wo=9729,re=3553,ne=34067,me=32879,pe=35866,pr=34069,Vo=34070,Ho=34071,jo=34072,Yo=34073,Xo=34074,gr=10241,yr=10240,_t=10242,Et=10243,Fn=32882,Qo=33082,qo=33083,Ko=33084,Jo=33085,Zo=34892,ea=34893,br=3317,Pn=3314,kn=32878,Cn=3316,Mn=3315,Bn=32877,ta=37443,ra=37441,na=37440,ia=33321,sa=36756,oa=33325,aa=33326,ca=33330,ua=33329,fa=33338,la=33337,da=33340,ha=33339,ma=33323,pa=36757,ga=33327,ya=33328,ba=33336,xa=33335,_a=33332,Ea=33331,wa=33334,va=33333,Ta=32849,Aa=35905,Sa=36194,Ia=36758,Ra=35898,Fa=35901,Pa=34843,ka=34837,Ca=36221,Ma=36239,Ba=36215,Da=36233,Oa=36209,Ua=36227,Na=32856,La=35907,za=36759,Ga=32855,$a=32854,Wa=32857,Va=34842,Ha=34836,ja=36220,Ya=36238,Xa=36975,Qa=36214,qa=36232,Ka=36226,Ja=36208,Za=33189,ec=33190,tc=36012,rc=36013,nc=35056,ie=5120,T=5121,wt=5122,Ie=5123,vt=5124,ge=5125,M=5126,Dn=32819,On=32820,Un=33635,z=5131,$e=36193,xr=33640,ic=35899,sc=35902,oc=36269,ac=34042,Tt=33319,Re=33320,At=6403,Fe=36244,Pe=36248,ye=36249;let _r;function St(r){if(!_r){const e={};e[An]={textureFormat:An,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1,2,2,4],type:[T,z,$e,M]},e[Sn]={textureFormat:Sn,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1,2,2,4],type:[T,z,$e,M]},e[In]={textureFormat:In,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[2,4,4,8],type:[T,z,$e,M]},e[V]={textureFormat:V,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3,6,6,12,2],type:[T,z,$e,M,Un]},e[A]={textureFormat:A,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,8,8,16,2,2],type:[T,z,$e,M,Dn,On]},e[Ge]={textureFormat:Ge,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2,4],type:[ge,Ie]},e[ia]={textureFormat:At,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1],type:[T]},e[sa]={textureFormat:At,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[1],type:[ie]},e[oa]={textureFormat:At,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[4,2],type:[M,z]},e[aa]={textureFormat:At,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[4],type:[M]},e[ca]={textureFormat:Fe,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[1],type:[T]},e[ua]={textureFormat:Fe,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[1],type:[ie]},e[_a]={textureFormat:Fe,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[Ie]},e[Ea]={textureFormat:Fe,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[wt]},e[wa]={textureFormat:Fe,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[ge]},e[va]={textureFormat:Fe,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[vt]},e[ma]={textureFormat:Tt,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[2],type:[T]},e[pa]={textureFormat:Tt,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[2],type:[ie]},e[ga]={textureFormat:Tt,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[8,4],type:[M,z]},e[ya]={textureFormat:Tt,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[8],type:[M]},e[ba]={textureFormat:Re,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[T]},e[xa]={textureFormat:Re,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[ie]},e[fa]={textureFormat:Re,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[Ie]},e[la]={textureFormat:Re,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[wt]},e[da]={textureFormat:Re,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[ge]},e[ha]={textureFormat:Re,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[vt]},e[Ta]={textureFormat:V,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3],type:[T]},e[Aa]={textureFormat:V,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[3],type:[T]},e[Sa]={textureFormat:V,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3,2],type:[T,Un]},e[Ia]={textureFormat:V,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[3],type:[ie]},e[Ra]={textureFormat:V,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6,4],type:[M,z,ic]},e[Fa]={textureFormat:V,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6,4],type:[M,z,sc]},e[Pa]={textureFormat:V,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6],type:[M,z]},e[ka]={textureFormat:V,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[M]},e[Ca]={textureFormat:Pe,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[3],type:[T]},e[Ma]={textureFormat:Pe,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[3],type:[ie]},e[Ba]={textureFormat:Pe,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[6],type:[Ie]},e[Da]={textureFormat:Pe,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[6],type:[wt]},e[Oa]={textureFormat:Pe,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[ge]},e[Ua]={textureFormat:Pe,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[vt]},e[Na]={textureFormat:A,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[T]},e[La]={textureFormat:A,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[T]},e[za]={textureFormat:A,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[4],type:[ie]},e[Ga]={textureFormat:A,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,2,4],type:[T,On,xr]},e[$a]={textureFormat:A,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,2],type:[T,Dn]},e[Wa]={textureFormat:A,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[xr]},e[Va]={textureFormat:A,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[16,8],type:[M,z]},e[Ha]={textureFormat:A,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[16],type:[M]},e[ja]={textureFormat:ye,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[T]},e[Ya]={textureFormat:ye,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[ie]},e[Xa]={textureFormat:ye,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[xr]},e[Qa]={textureFormat:ye,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[Ie]},e[qa]={textureFormat:ye,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[wt]},e[Ka]={textureFormat:ye,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[16],type:[vt]},e[Ja]={textureFormat:ye,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[16],type:[ge]},e[Za]={textureFormat:Ge,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2,4],type:[Ie,ge]},e[ec]={textureFormat:Ge,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[ge]},e[tc]={textureFormat:Ge,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[M]},e[nc]={textureFormat:Rn,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[ac]},e[rc]={textureFormat:Rn,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[oc]},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})}),_r=e}return _r[r]}function cc(r,e){const t=St(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=St(r);if(!e)throw"unknown internal format";return{format:e.textureFormat,type:e.type[0]}}function Nn(r){return(r&r-1)===0}function uc(r,e,t,n){if(!Le(r))return Nn(e)&&Nn(t);const i=St(n);if(!i)throw"unknown internal format";return i.colorRenderable&&i.textureFilterable}function fc(r){const e=St(r);if(!e)throw"unknown internal format";return e.textureFilterable}function lc(r,e,t){return ze(e)?lr(e):t||T}function It(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(ta,e.colorspaceConversion),e.premultiplyAlpha!==void 0&&r.pixelStorei(ra,e.premultiplyAlpha),e.flipY!==void 0&&r.pixelStorei(na,e.flipY)}function Ln(r){r.pixelStorei(br,4),Le(r)&&(r.pixelStorei(Pn,0),r.pixelStorei(kn,0),r.pixelStorei(Cn,0),r.pixelStorei(Mn,0),r.pixelStorei(Bn,0))}function dc(r,e,t,n){n.minMag&&(t.call(r,e,gr,n.minMag),t.call(r,e,yr,n.minMag)),n.min&&t.call(r,e,gr,n.min),n.mag&&t.call(r,e,yr,n.mag),n.wrap&&(t.call(r,e,_t,n.wrap),t.call(r,e,Et,n.wrap),(e===me||bo(r,e))&&t.call(r,e,Fn,n.wrap)),n.wrapR&&t.call(r,e,Fn,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,Qo,n.minLod),n.maxLod!==void 0&&t.call(r,e,qo,n.maxLod),n.baseLevel!==void 0&&t.call(r,e,Ko,n.baseLevel),n.maxLevel!==void 0&&t.call(r,e,Jo,n.maxLevel),n.compareFunc!==void 0&&t.call(r,e,ea,n.compareFunc),n.compareMode!==void 0&&t.call(r,e,Zo,n.compareMode)}function zn(r,e,t){const n=t.target||re;r.bindTexture(n,e),dc(r,n,r.texParameteri,t)}function hc(r){return r=r||te.textureColor,ze(r)?r:new Uint8Array([r[0]*255,r[1]*255,r[2]*255,r[3]*255])}function Er(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),uc(r,n,i,s))r.generateMipmap(o);else{const a=fc(s)?Wo:$o;r.texParameteri(o,gr,a),r.texParameteri(o,yr,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 wr(r,e){return e=e||{},e.cubeFaceOrder||[pr,Vo,Ho,jo,Yo,Xo]}function vr(r,e){const n=wr(r,e).map(function(i,s){return{face:i,ndx:s}});return n.sort(function(i,s){return i.face-s.face}),n}function Gn(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 _=Tn();_?(_.canvas.width=l,_.canvas.height=l,o=l,a=l,vr(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,vr(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)&&Er(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(br,1),r.pixelStorei(Pn,t.width),r.pixelStorei(kn,0),r.pixelStorei(Bn,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(Cn,R),r.pixelStorei(Mn,k),r.texSubImage3D(i,s,0,0,E,p,p,1,d,m,t)}Ln(r)}else r.texImage2D(i,s,c,d,m,t);Ve(n)&&Er(r,e,n,o,a,c),zn(r,e,n)}function He(){}function mc(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 pc(r,e){return e===void 0&&!mc(r)?"anonymous":e}function gc(r,e,t){t=t||He;let n;if(e=e!==void 0?e:te.crossOrigin,e=pc(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;pn(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 $n(r){return typeof ImageBitmap<"u"&&r instanceof ImageBitmap||typeof ImageData<"u"&&r instanceof ImageData||typeof HTMLElement<"u"&&r instanceof HTMLElement}function Tr(r,e,t){return $n(r)?(setTimeout(function(){t(null,r)}),r):gc(r,e,t)}function Ar(r,e,t){t=t||te.textureOptions;const n=t.target||re;if(r.bindTexture(n,e),t.color===!1)return;const i=hc(t.color);if(n===ne)for(let s=0;s<6;++s)r.texImage2D(pr+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 yc(r,e,t,n){return n=n||He,t=t||te.textureOptions,Ar(r,e,t),t=Object.assign({},t),Tr(t.src,t.crossOrigin,function(s,o){s?n(s,e,o):(Gn(r,e,o,t),n(null,e,o))})}function bc(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";Ar(r,e,t),t=Object.assign({},t);let m=6;const p=[],y=wr(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?wr().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 Tr(_,t.crossOrigin,b(y[E]))})}function xc(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";Ar(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=Tn(),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 Tr(k,t.crossOrigin,R(N))})}function _c(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||lc(r,t,d.type);if(ze(t))t instanceof Uint8ClampedArray&&(t=new Uint8Array(t.buffer));else{const _=mn(p);t=new _(t)}const y=cc(u,p),l=t.byteLength/y;if(l%1)throw"length wrong size for format: "+vn(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=It(r,i,o,a,l/s),o=b.width,a=b.height):o&&(!s||!a)?(b=It(r,i,s,a,l/o),s=b.width,a=b.height):(b=It(r,i,s,o,l/a),s=b.width,o=b.height);else b=It(r,i,s,o,l),s=b.width,o=b.height;if(Ln(r),r.pixelStorei(br,n.unpackAlignment||1),ke(r,n),i===ne){const _=y/t.BYTES_PER_ELEMENT,E=l/6*_;vr(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 Ec(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(pr+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 Wn(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")yc(r,n,e,t);else if(ze(c)||Array.isArray(c)&&(typeof c[0]=="number"||Array.isArray(c[0])||ze(c[0]))){const u=_c(r,n,c,e);s=u.width,o=u.height}else Array.isArray(c)&&(typeof c[0]=="string"||$n(c[0]))?i===ne?bc(r,n,e,t):xc(r,n,e,t):(Gn(r,n,c,e),s=c.width,o=c.height);else Ec(r,n,e);return Ve(e)&&Er(r,n,e,s,o,a),zn(r,n,e),n}const Sr=pn;function Vn(r){return typeof document<"u"&&document.getElementById?document.getElementById(r):null}const Rt=33984,Ft=34962,wc=34963,vc=35713,Tc=35714,Ac=35632,Sc=35633,Ic=35981,Hn=35718,Rc=35721,Fc=35971,Pc=35382,kc=35396,Cc=35398,Mc=35392,Bc=35395,Pt=5126,jn=35664,Yn=35665,Xn=35666,Ir=5124,Qn=35667,qn=35668,Kn=35669,Jn=35670,Zn=35671,ei=35672,ti=35673,ri=35674,ni=35675,ii=35676,Dc=35678,Oc=35680,Uc=35679,Nc=35682,Lc=35685,zc=35686,Gc=35687,$c=35688,Wc=35689,Vc=35690,Hc=36289,jc=36292,Yc=36293,Rr=5125,si=36294,oi=36295,ai=36296,Xc=36298,Qc=36299,qc=36300,Kc=36303,Jc=36306,Zc=36307,eu=36308,tu=36311,kt=3553,Ct=34067,Fr=32879,Mt=35866,x={};function ci(r,e){return x[e].bindPoint}function ru(r,e){return function(t){r.uniform1f(e,t)}}function nu(r,e){return function(t){r.uniform1fv(e,t)}}function iu(r,e){return function(t){r.uniform2fv(e,t)}}function su(r,e){return function(t){r.uniform3fv(e,t)}}function ou(r,e){return function(t){r.uniform4fv(e,t)}}function ui(r,e){return function(t){r.uniform1i(e,t)}}function fi(r,e){return function(t){r.uniform1iv(e,t)}}function li(r,e){return function(t){r.uniform2iv(e,t)}}function di(r,e){return function(t){r.uniform3iv(e,t)}}function hi(r,e){return function(t){r.uniform4iv(e,t)}}function au(r,e){return function(t){r.uniform1ui(e,t)}}function cu(r,e){return function(t){r.uniform1uiv(e,t)}}function uu(r,e){return function(t){r.uniform2uiv(e,t)}}function fu(r,e){return function(t){r.uniform3uiv(e,t)}}function lu(r,e){return function(t){r.uniform4uiv(e,t)}}function du(r,e){return function(t){r.uniformMatrix2fv(e,!1,t)}}function hu(r,e){return function(t){r.uniformMatrix3fv(e,!1,t)}}function mu(r,e){return function(t){r.uniformMatrix4fv(e,!1,t)}}function pu(r,e){return function(t){r.uniformMatrix2x3fv(e,!1,t)}}function gu(r,e){return function(t){r.uniformMatrix3x2fv(e,!1,t)}}function yu(r,e){return function(t){r.uniformMatrix2x4fv(e,!1,t)}}function bu(r,e){return function(t){r.uniformMatrix4x2fv(e,!1,t)}}function xu(r,e){return function(t){r.uniformMatrix3x4fv(e,!1,t)}}function _u(r,e){return function(t){r.uniformMatrix4x3fv(e,!1,t)}}function O(r,e,t,n){const i=ci(r,e);return Le(r)?function(s){let o,a;!s||dr(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=ci(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||dr(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:ru,arraySetter:nu},x[jn]={Type:Float32Array,size:8,setter:iu,cols:2},x[Yn]={Type:Float32Array,size:12,setter:su,cols:3},x[Xn]={Type:Float32Array,size:16,setter:ou,cols:4},x[Ir]={Type:Int32Array,size:4,setter:ui,arraySetter:fi},x[Qn]={Type:Int32Array,size:8,setter:li,cols:2},x[qn]={Type:Int32Array,size:12,setter:di,cols:3},x[Kn]={Type:Int32Array,size:16,setter:hi,cols:4},x[Rr]={Type:Uint32Array,size:4,setter:au,arraySetter:cu},x[si]={Type:Uint32Array,size:8,setter:uu,cols:2},x[oi]={Type:Uint32Array,size:12,setter:fu,cols:3},x[ai]={Type:Uint32Array,size:16,setter:lu,cols:4},x[Jn]={Type:Uint32Array,size:4,setter:ui,arraySetter:fi},x[Zn]={Type:Uint32Array,size:8,setter:li,cols:2},x[ei]={Type:Uint32Array,size:12,setter:di,cols:3},x[ti]={Type:Uint32Array,size:16,setter:hi,cols:4},x[ri]={Type:Float32Array,size:32,setter:du,rows:2,cols:2},x[ni]={Type:Float32Array,size:48,setter:hu,rows:3,cols:3},x[ii]={Type:Float32Array,size:64,setter:mu,rows:4,cols:4},x[Lc]={Type:Float32Array,size:32,setter:pu,rows:2,cols:3},x[zc]={Type:Float32Array,size:32,setter:yu,rows:2,cols:4},x[Gc]={Type:Float32Array,size:48,setter:gu,rows:3,cols:2},x[$c]={Type:Float32Array,size:48,setter:xu,rows:3,cols:4},x[Wc]={Type:Float32Array,size:64,setter:bu,rows:4,cols:2},x[Vc]={Type:Float32Array,size:64,setter:_u,rows:4,cols:3},x[Dc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:kt},x[Oc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Ct},x[Uc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Fr},x[Nc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:kt},x[Hc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Mt},x[jc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Mt},x[Yc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Ct},x[Xc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:kt},x[Qc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Fr},x[qc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Ct},x[Kc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Mt},x[Jc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:kt},x[Zc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Fr},x[eu]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Ct},x[tu]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Mt};function Bt(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||Ir,t.stride||0,t.offset||0),r.vertexAttribDivisor&&r.vertexAttribDivisor(e,t.divisor||0)}}function Dt(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||Rr,t.stride||0,t.offset||0),r.vertexAttribDivisor&&r.vertexAttribDivisor(e,t.divisor||0)}}function Pr(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 S={};S[Pt]={size:4,setter:Bt},S[jn]={size:8,setter:Bt},S[Yn]={size:12,setter:Bt},S[Xn]={size:16,setter:Bt},S[Ir]={size:4,setter:se},S[Qn]={size:8,setter:se},S[qn]={size:12,setter:se},S[Kn]={size:16,setter:se},S[Rr]={size:4,setter:Dt},S[si]={size:8,setter:Dt},S[oi]={size:12,setter:Dt},S[ai]={size:16,setter:Dt},S[Jn]={size:4,setter:se},S[Zn]={size:8,setter:se},S[ei]={size:12,setter:se},S[ti]={size:16,setter:se},S[ri]={size:4,setter:Pr,count:2},S[ni]={size:9,setter:Pr,count:3},S[ii]={size:16,setter:Pr,count:4};const Eu=/ERROR:\\s*\\d+:(\\d+)/gi;function wu(r,e="",t=0){const n=[...e.matchAll(Eu)],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 mi=/^[ \\t]*\\n/;function pi(r){let e=0;return mi.test(r)&&(e=1,r=r.replace(mi,"")),{lineOffset:e,shaderSource:r}}function vu(r,e){return r.errorCallback(e),r.callback&&setTimeout(()=>{r.callback(`${e}\n${r.errors.join(`\n`)}`)}),null}function Tu(r,e,t,n){if(n=n||Sr,!r.getShaderParameter(t,vc)){const s=r.getShaderInfoLog(t),{lineOffset:o,shaderSource:a}=pi(r.getShaderSource(t)),c=`${wu(a,s,o)}\nError compiling ${vn(r,e)}: ${s}`;return n(c),c}return""}function kr(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||Sr,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 Au=["VERTEX_SHADER","FRAGMENT_SHADER"];function Su(r,e){if(e.indexOf("frag")>=0)return Ac;if(e.indexOf("vert")>=0)return Sc}function Iu(r,e,t){const n=r.getAttachedShaders(e);for(const i of n)t.has(i)&&r.deleteShader(i);r.deleteProgram(e)}const Ru=(r=0)=>new Promise(e=>setTimeout(e,r));function Fu(r,e,t){const n=r.createProgram(),{attribLocations:i,transformFeedbackVaryings:s,transformFeedbackMode:o}=kr(t);for(let a=0;a<e.length;++a){let c=e[a];if(typeof c=="string"){const u=Vn(c),d=u?u.text:c;let m=r[Au[a]];u&&u.type&&(m=Su(r,u.type)||m),c=r.createShader(m),r.shaderSource(c,pi(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||Ic))}return r.linkProgram(n),n}function Pu(r,e,t,n,i){const s=kr(t,n,i),o=new Set(e),a=Fu(r,e,s);function c(u,d){const m=Cu(u,d,s.errorCallback);return m&&Iu(u,d,o),m}if(s.callback){ku(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 ku(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 Ru(i),i=1e3/60;while(!n(r,e))}function Cu(r,e,t){if(t=t||Sr,!r.getProgramParameter(e,Tc)){const i=r.getProgramInfoLog(e);t(`Error in program linking: ${i}`);const o=r.getAttachedShaders(e).map(a=>Tu(r,r.getShaderParameter(a,r.SHADER_TYPE),a,t));return`${i}\n${o.filter(a=>a).join(`\n`)}`}}function Mu(r,e,t,n,i){return Pu(r,e,t,n,i)}function gi(r){const e=r.name;return e.startsWith("gl_")||e.startsWith("webgl_")}const Bu=/(\\.|\\[|]|\\w+)/g,Du=r=>r>="0"&&r<="9";function Ou(r,e,t,n){const i=r.split(Bu).filter(a=>a!=="");let s=0,o="";for(;;){const a=i[s++];o+=a;const c=Du(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){yi(l,b)}})(y),o+=m}}}function Uu(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,Hn);for(let a=0;a<o;++a){const c=r.getActiveUniform(e,a);if(gi(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,Ou(u,m,s,i)}}return i}function Nu(r,e){const t={},n=r.getProgramParameter(e,Fc);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 Lu(r,e){const t=r.getProgramParameter(e,Hn),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,Pc);for(let a=0;a<o;++a){const c=r.getActiveUniformBlockName(e,a),u={index:r.getUniformBlockIndex(e,c),usedByVertexShader:r.getActiveUniformBlockParameter(e,a,kc),usedByFragmentShader:r.getActiveUniformBlockParameter(e,a,Cc),size:r.getActiveUniformBlockParameter(e,a,Mc),uniformIndices:r.getActiveUniformBlockParameter(e,a,Bc)};u.used=u.usedByVertexShader||u.usedByFragmentShader,s[c]=u}return{blockSpecs:s,uniformData:n}}function yi(r,e){for(const t in e){const n=r[t];typeof n=="function"?n(e[t]):yi(r[t],e[t])}}function bi(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)bi(t,s[a])}else for(const o in s){const a=t[o];a&&a(s[o])}}}function zu(r,e){const t={},n=r.getProgramParameter(e,Rc);for(let i=0;i<n;++i){const s=r.getActiveAttrib(e,i);if(gi(s))continue;const o=r.getAttribLocation(e,s.name),a=S[s.type],c=a.setter(r,o,a);c.location=o,t[s.name]=c}return t}function Gu(r,e){for(const t in e){const n=r[t];n&&n(e[t])}}function $u(r,e,t){t.vertexArrayObject?r.bindVertexArray(t.vertexArrayObject):(Gu(e.attribSetters||e,t.attribs),t.indices&&r.bindBuffer(wc,t.indices))}function xi(r,e){const t=Uu(r,e),n=zu(r,e),i={program:e,uniformSetters:t,attribSetters:n};return Le(r)&&(i.uniformBlockSpec=Lu(r,e),i.transformFeedbackInfo=Nu(r,e)),i}const Wu=/\\s|{|}|;/;function Vu(r,e,t,n,i){const s=kr(t,n,i),o=[];if(e=e.map(function(u){if(!Wu.test(u)){const d=Vn(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 vu(s,"");const a=s.callback;a&&(s.callback=(u,d)=>{a(u,u?void 0:xi(r,d))});const c=Mu(r,e,s);return c?xi(r,c):null}const Hu=4,_i=5123;function ju(r,e,t,n,i,s){t=t===void 0?Hu: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?_i:e.elementType,i,s):r.drawElements(t,c,a===void 0?_i:e.elementType,i):s!==void 0?r.drawArraysInstanced(t,i,c,s):r.drawArrays(t,i,c)}const Ei=36160,Ot=36161,Yu=3553,Xu=5121,Qu=6402,qu=6408,Ku=33190,Ju=36012,Zu=35056,ef=36013,tf=32854,rf=32855,nf=36194,wi=33189,vi=6401,Ti=36168,Cr=34041,Mr=36064,Ut=36096,Ai=36128,Br=33306,Dr=33071,Or=9729,sf=[{format:qu,type:Xu,min:Or,wrap:Dr},{format:Cr}],G={};G[Cr]=Br,G[vi]=Ai,G[Ti]=Ai,G[Qu]=Ut,G[wi]=Ut,G[Ku]=Ut,G[Ju]=Ut,G[Zu]=Br,G[ef]=Br;function of(r,e){return G[r]||G[e]}const oe={};oe[tf]=!0,oe[rf]=!0,oe[nf]=!0,oe[Cr]=!0,oe[wi]=!0,oe[vi]=!0,oe[Ti]=!0;function af(r){return oe[r]}const cf=32;function uf(r){return r>=Mr&&r<Mr+cf}function Si(r,e,t,n){const i=Ei,s=r.createFramebuffer();r.bindFramebuffer(i,s),t=t||r.drawingBufferWidth,n=n||r.drawingBufferHeight,e=e||sf;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||of(p,c.internalFormat);if(y||(y=Mr+u),uf(y)&&o.push(y),!d)if(m!==void 0||af(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||Or,l.mag=l.mag||l.minMag||Or,l.wrapS=l.wrapS||l.wrap||Dr,l.wrapT=l.wrapT||l.wrap||Dr),d=Wn(r,l)}if(yo(r,d))r.framebufferRenderbuffer(i,y,Ot,d);else if(dr(r,d))c.layer!==void 0?r.framebufferTextureLayer(i,y,d,c.level||0,c.layer):r.framebufferTexture2D(i,y,c.target||Yu,d,c.level||0);else throw new Error("unknown attachment type");a.attachments.push(d)}),r.drawBuffers&&r.drawBuffers(o),a}function ff(r,e,t){t=t||Ei,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 B(r,e){return()=>e instanceof WebGLTexture?e:Wn(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=Vu(this.context,[s+this.getVertexShader(),s+this.getFragmentShader()]),this.bufferInfo=Go(this.context,this.getBuffers()),this.fbi=Si(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=Si(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),$u(this.context,this.programInfo,this.bufferInfo),bi(this.programInfo,{delta:n,canvas:[this.context.canvas.width,this.context.canvas.height],...e}),ff(this.context,this.options.disableFramebuffer?null:this.fbi),ju(this.context,this.bufferInfo),this.profiler?.popContext(`[${this.id}] PROG : ${this.constructor.name}`)}setProfiler(e){this.profiler=e}}var lf=`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`,df=`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 Ur extends je{getFragmentShader(){return lf}getVertexShader(){return df}}class Nr{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 Lr extends Nr{constructor(){super(...arguments),this.preciseMaskEnabled=!1}}class Ii extends Lr{constructor(e){super(),this.context=e,this.preciseMaskEnabled=!0;const t={context:e,height:e.canvas.height,width:e.canvas.width},n=new Ur({...t,disableFramebuffer:!0});this.addStep({program:n,getUniforms:()=>({background:B(e,this.inputBackgroundImage),foreground:B(e,this.inputImage),threshold:B(e,this.inputMask)})})}setData(e,t){this.inputImage=e,this.inputMask=t}}var hf=`precision mediump float;\n\nvarying vec2 _texture_coord;\nuniform sampler2D texture;\n\nvoid main() { gl_FragColor = texture2D(texture, _texture_coord); }\n`,mf=`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 pf extends je{getFragmentShader(){return hf}getVertexShader(){return mf}}class gf extends Nr{constructor(e,t,n){super(),this.context=e;const i={context:e,height:n,width:t};this.addStep({program:new pf({...i,disableFramebuffer:!0}),getUniforms:()=>({texture:B(e,this.inputImage),invert_y:!0})})}setData(e){this.inputImage=e}}async function Ri(r){return new Promise(e=>{setTimeout(()=>{e()},r)})}var yf=`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`,bf=`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`,zr=(r=>(r[r.LINEAR=0]="LINEAR",r[r.GAUSSIAN=1]="GAUSSIAN",r))(zr||{});class Fi extends je{getDefines(){return{RADIUS:this.options.radius??1}}getFragmentShader(){return yf+this.createLoopFunction()}getVertexShader(){return bf}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 xf=`#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}`,_f=`#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 Ef extends je{getFragmentShader(){return xf}getVertexShader(){return _f}}class wf extends Nr{constructor(e,t,n){super(),this.context=e;const i={context:e,height:n,width:t},s=new Fi({...i,radius:1,type:zr.GAUSSIAN});this.jointBilateral=new Ef(i),this.addStep({program:s,getUniforms:()=>({inputs:B(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:B(e,this.inputImage),segmentation_mask:B(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 vf{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 Ri(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 wf(this.context,Ce,Ce)}enablePostProcessing(){this.postProcessingEnabled=!0}disablePostProcessing(){this.postProcessingEnabled=!1}async profileWebgl(e){const t=new vf(this.context);return this.profiler=t,t.start(),await Ri(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 Pi extends Nt{constructor(){super(),this.pipeline=new Ii(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 gf(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 Tf extends Pi{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 ki{blurBackground(e){return new no(e)}blurSilhouette(e){return new io(e)}imageBackground(){return new so}videoBackground(){return new Tf}}var Af=`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`,Sf=`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 If extends je{getDefines(){return{RADIUS:this.options.radius??1}}getFragmentShader(){return Af+this.createLoopFunction()}getVertexShader(){return Sf}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 Rf=10,Ff=2,Pf=8;class kf extends Lr{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 If({...n,radius:t,...this.getBlurTextureSize(e.canvas.width,e.canvas.height)});const i=new Ur({...n,disableFramebuffer:!0});this.addStep({program:this.blur,preventResize:!0,getUniforms:()=>({texture:B(e,this.inputImage),mask:B(e,this.inputMask)})}),this.addStep({program:i,getUniforms:()=>({background:B(e,this.blur.output),foreground:B(e,this.inputImage),threshold:B(e,this.inputMask)})})}getBlurTextureSize(e,t){const n=this.radius>Rf?Pf:Ff;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 Cf extends Nt{constructor(e){super(),this.pipeline=new kf(this.context,e),this.disablePostProcessing()}}class Mf extends Lr{constructor(e,t){super(),this.context=e;const n={context:e,height:e.canvas.height,width:e.canvas.width},i=new Fi({...n,radius:t,type:zr.GAUSSIAN}),s=new Ur({...n,disableFramebuffer:!0});this.addStep({program:i,getUniforms:()=>({texture:B(e,this.inputImage)})}),this.addStep({program:s,getUniforms:()=>({background:B(e,this.inputImage),foreground:B(e,i.output),threshold:B(e,this.inputMask)})})}setData(e,t){this.inputImage=e,this.inputMask=t}}class Bf extends Nt{constructor(e){super(),this.pipeline=new Mf(this.context,e),this.disablePostProcessing()}}class Df extends Ii{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 Of extends Nt{constructor(){super(),this.pipeline=new Df(this.context)}setBackgroundVideo(e){this.pipeline.reader=e}}class Ci{blurBackground(e){return new Cf(e)}blurSilhouette(e){return new Bf(e)}imageBackground(){return new Pi}videoBackground(){return new Of}}class Uf{constructor(e){switch(e){case gt.CANVAS:this.factory=new ki;break;case gt.WEBGL:this.factory=new Ci;break;default:const t=ro();this.factory=t.supported?new Ci:new ki}}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 Nf{setBackgroundOptions(e){this.renderer&&this.renderer.destroy();const t=new Uf(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===nr.PRECISE?this.renderer.enablePostProcessing():e.renderingOptions.selfieSegmentationType===nr.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 Lf=(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,I=h;f[I]&&!(I>=w);)++I;if(I-h>16&&f.subarray&&R)return R.decode(f.subarray(h,I));for(var C="";h<I;){var v=f[h++];if(!(v&128)){C+=String.fromCharCode(v);continue}var D=f[h++]&63;if((v&224)==192){C+=String.fromCharCode((v&31)<<6|D);continue}var H=f[h++]&63;if((v&240)==224?v=(v&15)<<12|D<<6|H:v=(v&7)<<18|D<<12|H<<6|f[h++]&63,v<65536)C+=String.fromCharCode(v);else{var Gi=v-65536;C+=String.fromCharCode(55296|Gi>>10,56320|Gi&1023)}}return C}function N(f,h){return f?k(Ye,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,Ye,$;function Bi(f){L=f,t.HEAP8=Lt=new Int8Array(f),t.HEAP16=new Int16Array(f),t.HEAP32=$=new Int32Array(f),t.HEAPU8=Ye=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 $r,Di=[],Oi=[],Ui=[];function qf(){if(t.preRun)for(typeof t.preRun=="function"&&(t.preRun=[t.preRun]);t.preRun.length;)Zf(t.preRun.shift());Wr(Di)}function Kf(){Wr(Oi)}function Jf(){if(t.postRun)for(typeof t.postRun=="function"&&(t.postRun=[t.postRun]);t.postRun.length;)tl(t.postRun.shift());Wr(Ui)}function Zf(f){Di.unshift(f)}function el(f){Oi.unshift(f)}function tl(f){Ui.unshift(f)}var be=0,Xe=null;function rl(f){be++,t.monitorRunDependencies&&t.monitorRunDependencies(be)}function nl(f){if(be--,t.monitorRunDependencies&&t.monitorRunDependencies(be),be==0&&Xe){var h=Xe;Xe=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 il="data:application/octet-stream;base64,";function Ni(f){return f.startsWith(il)}var W;W="tflite-simd.wasm",Ni(W)||(W=m(W));function Li(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 sl(){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 Li(W)}):Promise.resolve().then(function(){return Li(W)})}function ol(){var f={a:Il};function h(v,D){var H=v.exports;t.asm=H,_=t.asm.q,Bi(_.buffer),$r=t.asm.E,el(t.asm.r),nl()}rl();function g(v){h(v.instance)}function w(v){return sl().then(function(D){return WebAssembly.instantiate(D,f)}).then(function(D){return D}).then(v,function(D){l("failed to asynchronously prepare wasm: "+D),ae(D)})}function I(){return!b&&typeof WebAssembly.instantiateStreaming=="function"&&!Ni(W)&&typeof fetch=="function"?fetch(W,{credentials:"same-origin"}).then(function(v){var D=WebAssembly.instantiateStreaming(v,f);return D.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 I().catch(i),{}}function Wr(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?$r.get(g)():$r.get(g)(h.arg):g(h.arg===void 0?null:h.arg)}}function al(f,h,g,w){ae("Assertion failed: "+N(f)+", at: "+[h?N(h):"unknown filename",g,w?N(w):"unknown function"])}function cl(f,h){ae("To use dlopen, you need to use Emscripten\'s linking support, see https://github.com/emscripten-core/emscripten/wiki/Linking")}function ul(f,h){ae("To use dlopen, you need to use Emscripten\'s linking support, see https://github.com/emscripten-core/emscripten/wiki/Linking")}function fl(){ae("")}var zt;zt=function(){return performance.now()};var ll=!0;function dl(f){return $[zi()>>2]=f,f}function hl(f,h){var g;if(f===0)g=Date.now();else if((f===1||f===4)&&ll)g=zt();else return dl(28),-1;return $[h>>2]=g/1e3|0,$[h+4>>2]=g%1e3*1e3*1e3|0,0}function ml(){return 2147483648}function pl(f,h,g){Ye.copyWithin(f,h,h+g)}function gl(f){try{return _.grow(f-L.byteLength+65535>>>16),Bi(_.buffer),1}catch{}}function yl(f){var h=Ye.length;f=f>>>0;var g=2147483648;if(f>g)return!1;for(var w=1;w<=4;w*=2){var I=h*(1+.2/w);I=Math.min(I,f+100663296);var C=Math.min(g,q(Math.max(f,I),65536)),v=gl(C);if(v)return!0}return!1}function bl(f){for(var h=zt();zt()-h<f;);}var Vr={};function xl(){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,_:xl()};for(var g in Vr)Vr[g]===void 0?delete h[g]:h[g]=Vr[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 _l(f,h){var g=0;return Qe().forEach(function(w,I){var C=h+g;$[f+I*4>>2]=C,Q(w,C),g+=w.length+1}),0}function El(f,h){var g=Qe();$[f>>2]=g.length;var w=0;return g.forEach(function(I){w+=I.length+1}),$[h>>2]=w,0}function wl(f){Fl(f)}function vl(f){return 0}function Tl(f,h,g,w,I){}function Al(f,h,g,w){for(var I=0,C=0;C<g;C++){for(var v=$[h+C*8>>2],D=$[h+(C*8+4)>>2],H=0;H<D;H++)Gt.printChar(f,Ye[v+H]);I+=D}return $[w>>2]=I,0}function Sl(){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=Sl());for(var g=0;g<h;g++)Lt[f+g>>0]=$t.randomDevice();return 0}var Il={a:al,e:cl,d:ul,b:fl,n:hl,h:ml,l:pl,m:yl,p:bl,f:_l,g:El,j:wl,i:vl,k:Tl,c:Al,o:$t};ol(),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 zi=t.___errno_location=function(){return(zi=t.___errno_location=t.asm.F).apply(null,arguments)},Wt;function Rl(f){this.name="ExitStatus",this.message="Program terminated with exit("+f+")",this.status=f}Xe=function f(){Wt||Hr(),Wt||(Xe=f)};function Hr(f){if(be>0||(qf(),be>0))return;function h(){Wt||(Wt=!0,t.calledRun=!0,!E&&(Kf(),n(t),t.onRuntimeInitialized&&t.onRuntimeInitialized(),Jf()))}t.setStatus?(t.setStatus("Running..."),setTimeout(function(){setTimeout(function(){t.setStatus("")},1),h()},1)):h()}t.run=Hr;function Fl(f,h){Pl(f)}function Pl(f){c(f,new Rl(f))}if(t.preInit)for(typeof t.preInit=="function"&&(t.preInit=[t.preInit]);t.preInit.length>0;)t.preInit.pop()();return Hr(),e.ready})})();class zf{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 Gf="https://d3opqjmqzxf057.cloudfront.net/vonage-tensorflow-wasm/tflite-simd-wasm/1.1.3/",$f="https://d3opqjmqzxf057.cloudfront.net/ml/selfie_segmentation/4.0.0/selfie_segmentation_landscape.tflite";async function Wf(r=Gf,e=$f){let t=new zf;var n=new Promise(function(i,s){async function o(){return Lf({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 Vf=.1,Hf=.7,jf="https://d3opqjmqzxf057.cloudfront.net/ml/vonage_selfie_segmenter/float16/v1/vonage_selfie_segmenter.tflite";class Yf{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||jf;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>Vf?(a<Hf?(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 Xf{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 Wf(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 Qf{constructor(){this.reporter=new eo,this.isEnabled=!0}async init(e,t){t.segmentationOptions?.lightWeightEngine===!0?this.selfieSegmentation=new Xf:this.selfieSegmentation=new Yf,this.selfieSegmentation?.init(t.modelAssetUriPath,t.mediapipeBaseAssetsUri,t.segmentationOptions?.gpuSupport),this.backgroundFilter=new Nf,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:to,action:"MlTransformers",transformerType:this.backgroundOptions?.transformerType,config:JSON.stringify(this.backgroundOptions),...e})}}const Gr=class Gr{constructor(){this.backgroundTransformer=new Qf,this.mediaProcessor=new Ps,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){ws(e)}async profile(e){return JSON.stringify(await this.backgroundTransformer.profile(e))}};ji("ProcessorWorker",Gr);let Mi=Gr})();\n//# sourceMappingURL=processor-worker-BKH_E7wA.js.map\n', si = typeof self < "u" && self.Blob && new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);", Ao], { type: "text/javascript;charset=utf-8" });
|
|
5140
|
-
function
|
|
5147
|
+
ua("ProcessorWorker", pn);
|
|
5148
|
+
let Mr = pn;
|
|
5149
|
+
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.1",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.0";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-BCzl4yxZ.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" });
|
|
5150
|
+
function Fd(r) {
|
|
5141
5151
|
let e;
|
|
5142
5152
|
try {
|
|
5143
|
-
if (e =
|
|
5153
|
+
if (e = ii && (self.URL || self.webkitURL).createObjectURL(ii), !e) throw "";
|
|
5144
5154
|
const t = new Worker(e, {
|
|
5145
5155
|
name: r?.name
|
|
5146
5156
|
});
|
|
@@ -5149,7 +5159,7 @@ function kd(r) {
|
|
|
5149
5159
|
}), t;
|
|
5150
5160
|
} catch {
|
|
5151
5161
|
return new Worker(
|
|
5152
|
-
"data:text/javascript;charset=utf-8," + encodeURIComponent(
|
|
5162
|
+
"data:text/javascript;charset=utf-8," + encodeURIComponent(_o),
|
|
5153
5163
|
{
|
|
5154
5164
|
name: r?.name
|
|
5155
5165
|
}
|
|
@@ -5202,7 +5212,7 @@ const Jt = class Jt extends et {
|
|
|
5202
5212
|
}
|
|
5203
5213
|
}
|
|
5204
5214
|
async startWorker() {
|
|
5205
|
-
!this.config || this.worker || (this.worker = await
|
|
5215
|
+
!this.config || this.worker || (this.worker = await aa(Mr, Fd), this.isEnabled || await this.worker.disable(), await this.worker.init(
|
|
5206
5216
|
`worker_${Jt.initCount++}`,
|
|
5207
5217
|
this.config
|
|
5208
5218
|
), await this.worker.setVonageMetadata(Tt()), this.backgroundOptions ? await this.setBackgroundOptions(this.backgroundOptions) : await this.setBackgroundOptions(this.config), this.listenWorker());
|
|
@@ -5213,14 +5223,14 @@ const Jt = class Jt extends et {
|
|
|
5213
5223
|
switch (t) {
|
|
5214
5224
|
case "VideoBackground":
|
|
5215
5225
|
await this.worker?.setVideoBGReadable(
|
|
5216
|
-
await
|
|
5226
|
+
await zn.createVideoReadable(
|
|
5217
5227
|
e.backgroundAssetUri
|
|
5218
5228
|
)
|
|
5219
5229
|
);
|
|
5220
5230
|
break;
|
|
5221
5231
|
case "VirtualBackground":
|
|
5222
5232
|
await this.worker?.setVirtualBGImage(
|
|
5223
|
-
await
|
|
5233
|
+
await zn.createImageCanvas(
|
|
5224
5234
|
e.backgroundAssetUri
|
|
5225
5235
|
)
|
|
5226
5236
|
);
|
|
@@ -5230,8 +5240,8 @@ const Jt = class Jt extends et {
|
|
|
5230
5240
|
}
|
|
5231
5241
|
};
|
|
5232
5242
|
Jt.initCount = 0;
|
|
5233
|
-
let
|
|
5234
|
-
class
|
|
5243
|
+
let Br = Jt;
|
|
5244
|
+
class Cd {
|
|
5235
5245
|
constructor(e) {
|
|
5236
5246
|
this.queries = e;
|
|
5237
5247
|
}
|
|
@@ -5253,7 +5263,7 @@ class Rd {
|
|
|
5253
5263
|
t[c.name] === void 0 && (t[c.name] = e.length, e.push({
|
|
5254
5264
|
name: c.name
|
|
5255
5265
|
})), a.push({
|
|
5256
|
-
type: c.action ==
|
|
5266
|
+
type: c.action == xo.PUSH ? "O" : "C",
|
|
5257
5267
|
frame: t[c.name],
|
|
5258
5268
|
at: c.timestamp
|
|
5259
5269
|
}), i = Math.max(i, c.timestamp + c.duration);
|
|
@@ -5275,14 +5285,14 @@ class Rd {
|
|
|
5275
5285
|
}, null, 2);
|
|
5276
5286
|
}
|
|
5277
5287
|
}
|
|
5278
|
-
const
|
|
5288
|
+
const gn = class gn extends et {
|
|
5279
5289
|
/**
|
|
5280
5290
|
* Private constructor
|
|
5281
5291
|
* Use {@link create} to instantiate the class
|
|
5282
5292
|
* @internal
|
|
5283
5293
|
*/
|
|
5284
5294
|
constructor(e) {
|
|
5285
|
-
super(), this.worker = new
|
|
5295
|
+
super(), this.worker = new Br(e), this.connector = new Ys(this.worker), this.worker.onAny(
|
|
5286
5296
|
(t, n) => this.emit(t, n)
|
|
5287
5297
|
);
|
|
5288
5298
|
}
|
|
@@ -5337,7 +5347,7 @@ const bn = class bn extends et {
|
|
|
5337
5347
|
const t = await Promise.all(
|
|
5338
5348
|
this.instances.map((n) => n.profile(e))
|
|
5339
5349
|
);
|
|
5340
|
-
return new
|
|
5350
|
+
return new Cd(t);
|
|
5341
5351
|
}
|
|
5342
5352
|
/**
|
|
5343
5353
|
* Asynchronous constructor of VonageMediaProcessor
|
|
@@ -5349,23 +5359,23 @@ const bn = class bn extends et {
|
|
|
5349
5359
|
return this.instances.push(t), t;
|
|
5350
5360
|
}
|
|
5351
5361
|
};
|
|
5352
|
-
|
|
5353
|
-
let
|
|
5354
|
-
async function
|
|
5355
|
-
return await
|
|
5362
|
+
gn.instances = [];
|
|
5363
|
+
let Dr = gn;
|
|
5364
|
+
async function Dd(r) {
|
|
5365
|
+
return await Dr.create(r);
|
|
5356
5366
|
}
|
|
5357
5367
|
export {
|
|
5358
|
-
|
|
5359
|
-
|
|
5368
|
+
Pd as BackgroundTransformer,
|
|
5369
|
+
Qs as BackgroundTransformerType,
|
|
5360
5370
|
It as BlurRadius,
|
|
5361
|
-
|
|
5362
|
-
|
|
5371
|
+
Us as ErrorFunction,
|
|
5372
|
+
Er as PipelineInfoData,
|
|
5363
5373
|
Mt as RenderingType,
|
|
5364
|
-
|
|
5365
|
-
|
|
5366
|
-
|
|
5367
|
-
|
|
5368
|
-
|
|
5369
|
-
|
|
5374
|
+
Dr as VonageMediaProcessor,
|
|
5375
|
+
Ds as WarningType,
|
|
5376
|
+
Ar as WebglSelfieSegmentationType,
|
|
5377
|
+
Dd as createVonageMediaProcessor,
|
|
5378
|
+
Xs as getSupportedBrowserFeatures,
|
|
5379
|
+
Bd as isSupported
|
|
5370
5380
|
};
|
|
5371
5381
|
//# sourceMappingURL=ml-transformers.es.js.map
|