@opentok/client 2.35.0-alpha.11 → 2.35.0-alpha.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,11 @@
1
1
  /**
2
- * @license OpenTok.js 2.35.0 5ce4f88f4
2
+ * @license OpenTok.js 2.35.0 834cd53dc
3
3
  *
4
4
  * Copyright (c) 2010-2026 TokBox, Inc.
5
5
  * Subject to the applicable Software Development Kit (SDK) License Agreement:
6
6
  * https://www.vonage.com/legal/communications-apis/terms-of-use/
7
7
  *
8
- * Date: Mon, 04 May 2026 08:04:04 GMT
8
+ * Date: Tue, 05 May 2026 09:50:10 GMT
9
9
  */
10
10
 
11
11
  (function webpackUniversalModuleDefinition(root, factory) {
@@ -10228,7 +10228,7 @@ function staticConfigFactory(_temp) {
10228
10228
  _ref$axios = _ref.axios,
10229
10229
  axios = _ref$axios === void 0 ? _axios.default : _ref$axios,
10230
10230
  _ref$properties = _ref.properties,
10231
- properties = _ref$properties === void 0 ? {"version":"v2.35.0","buildHash":"5ce4f88f4","minimumVersion":{"firefox":52,"chrome":49},"debug":false,"websiteURL":"http://www.tokbox.com","configURL":"https://config.opentok.com","ipWhitelistConfigURL":"","cdnURL":"","loggingURL":"https://hlg.tokbox.com/prod","apiURL":"https://anvil.opentok.com","vonageApiURL":""} : _ref$properties;
10231
+ properties = _ref$properties === void 0 ? {"version":"v2.35.0","buildHash":"834cd53dc","minimumVersion":{"firefox":52,"chrome":49},"debug":false,"websiteURL":"http://www.tokbox.com","configURL":"https://config.opentok.com","ipWhitelistConfigURL":"","cdnURL":"","loggingURL":"https://hlg.tokbox.com/prod","apiURL":"https://anvil.opentok.com","vonageApiURL":""} : _ref$properties;
10232
10232
  /** @type builtInConfig */
10233
10233
  const builtInConfig = (0, _cloneDeep.default)(properties);
10234
10234
  /**
@@ -21818,7 +21818,7 @@ function PublisherFactory(_ref) {
21818
21818
  }
21819
21819
  _context7.prev = 6;
21820
21820
  _context7.next = 9;
21821
- return _this.applyVideoFilter(properties.videoFilter);
21821
+ return _this.applyVideoFilter(properties.videoFilter, true);
21822
21822
  case 9:
21823
21823
  _context7.next = 14;
21824
21824
  break;
@@ -23620,7 +23620,7 @@ function PublisherFactory(_ref) {
23620
23620
  }
23621
23621
  originalVideoTrack = mediaProcessor.getOriginalVideoTrack();
23622
23622
  _context26.next = 54;
23623
- return mediaProcessor.setVideoFilter(currentVideoFilter);
23623
+ return mediaProcessor.setVideoFilter(currentVideoFilter, true);
23624
23624
  case 54:
23625
23625
  _context26.next = 56;
23626
23626
  return mediaProcessor.setMediaStream(webRTCStream);
@@ -26139,37 +26139,40 @@ function PublisherFactory(_ref) {
26139
26139
  * If there is an error, the promise is rejected and no new video filter is set.
26140
26140
  */
26141
26141
  this.applyVideoFilter = /*#__PURE__*/function () {
26142
- var _ref59 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee52(videoFilter) {
26142
+ var _ref59 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee52(videoFilter, avoidOriginalTrackLeak) {
26143
26143
  var sanitizedVideoFilter, isSupported, message, _webRTCStream$getVide2, originalVideoTrack, filteredVideoTrack;
26144
26144
  return _regenerator.default.wrap(function _callee52$(_context52) {
26145
26145
  while (1) switch (_context52.prev = _context52.next) {
26146
26146
  case 0:
26147
+ if (avoidOriginalTrackLeak === void 0) {
26148
+ avoidOriginalTrackLeak = false;
26149
+ }
26147
26150
  sanitizedVideoFilter = (0, _sanitizeVideoFilter.default)(videoFilter);
26148
26151
  logAnalyticsEvent('applyVideoFilter', 'Attempt', {
26149
26152
  videoFilter: sanitizedVideoFilter
26150
26153
  });
26151
- _context52.prev = 2;
26154
+ _context52.prev = 3;
26152
26155
  if (!_videoMediaProcessorConnector) {
26153
- _context52.next = 5;
26156
+ _context52.next = 6;
26154
26157
  break;
26155
26158
  }
26156
26159
  throw otError(Errors.NOT_SUPPORTED, new Error('Cannot apply video filter when videoMediaProcessorConnector is set.'));
26157
- case 5:
26160
+ case 6:
26158
26161
  isSupported = MediaProcessor.isSupported('video');
26159
26162
  if (isSupported) {
26160
- _context52.next = 8;
26163
+ _context52.next = 9;
26161
26164
  break;
26162
26165
  }
26163
26166
  throw otError(Errors.NOT_SUPPORTED, new Error('Browser does not support video filters (Insertable Streams and Worker APIs are required)'));
26164
- case 8:
26167
+ case 9:
26165
26168
  if (mediaProcessor.isValidVideoFilter(videoFilter)) {
26166
- _context52.next = 10;
26169
+ _context52.next = 11;
26167
26170
  break;
26168
26171
  }
26169
26172
  throw otError(Errors.INVALID_PARAMETER, new Error('Video filter has invalid configuration'));
26170
- case 10:
26173
+ case 11:
26171
26174
  if (webRTCStream) {
26172
- _context52.next = 15;
26175
+ _context52.next = 16;
26173
26176
  break;
26174
26177
  }
26175
26178
  message = 'Ignoring. No mediaStream';
@@ -26178,16 +26181,16 @@ function PublisherFactory(_ref) {
26178
26181
  });
26179
26182
  logging.warn(message);
26180
26183
  return _context52.abrupt("return");
26181
- case 15:
26184
+ case 16:
26182
26185
  if (!isScreenSharing) {
26183
- _context52.next = 17;
26186
+ _context52.next = 18;
26184
26187
  break;
26185
26188
  }
26186
26189
  throw otError(Errors.INVALID_PARAMETER, new Error('Video filters can not be applied to screen share'));
26187
- case 17:
26190
+ case 18:
26188
26191
  enableMediaProcessorLogging();
26189
26192
  if (properties.publishVideo) {
26190
- _context52.next = 22;
26193
+ _context52.next = 23;
26191
26194
  break;
26192
26195
  }
26193
26196
  currentVideoFilter = videoFilter;
@@ -26195,35 +26198,35 @@ function PublisherFactory(_ref) {
26195
26198
  videoFilter: sanitizedVideoFilter
26196
26199
  });
26197
26200
  return _context52.abrupt("return");
26198
- case 22:
26201
+ case 23:
26199
26202
  if (!mediaProcessor.getVideoFilter()) {
26200
- _context52.next = 37;
26203
+ _context52.next = 38;
26201
26204
  break;
26202
26205
  }
26203
26206
  if (!mediaProcessor.canUpdateVideoFilter(videoFilter.type)) {
26204
- _context52.next = 35;
26207
+ _context52.next = 36;
26205
26208
  break;
26206
26209
  }
26207
- _context52.prev = 24;
26208
- _context52.next = 27;
26210
+ _context52.prev = 25;
26211
+ _context52.next = 28;
26209
26212
  return mediaProcessor.updateVideoFilter(videoFilter);
26210
- case 27:
26213
+ case 28:
26211
26214
  currentVideoFilter = videoFilter;
26212
26215
  logAnalyticsEvent('applyVideoFilter', 'Success', {
26213
26216
  videoFilter: sanitizedVideoFilter
26214
26217
  });
26215
26218
  return _context52.abrupt("return");
26216
- case 32:
26217
- _context52.prev = 32;
26218
- _context52.t0 = _context52["catch"](24);
26219
+ case 33:
26220
+ _context52.prev = 33;
26221
+ _context52.t0 = _context52["catch"](25);
26219
26222
  logging.warn(`Error updating video filter: ${_context52.t0}`);
26220
- case 35:
26221
- _context52.next = 37;
26223
+ case 36:
26224
+ _context52.next = 38;
26222
26225
  return _this.clearVideoFilter();
26223
- case 37:
26226
+ case 38:
26224
26227
  _webRTCStream$getVide2 = webRTCStream.getVideoTracks(), originalVideoTrack = _webRTCStream$getVide2[0];
26225
26228
  if (originalVideoTrack) {
26226
- _context52.next = 43;
26229
+ _context52.next = 44;
26227
26230
  break;
26228
26231
  }
26229
26232
  message = 'Ignoring. No video';
@@ -26232,43 +26235,43 @@ function PublisherFactory(_ref) {
26232
26235
  });
26233
26236
  logging.warn(message);
26234
26237
  return _context52.abrupt("return");
26235
- case 43:
26236
- _context52.next = 45;
26237
- return mediaProcessor.setVideoFilter(videoFilter);
26238
- case 45:
26239
- _context52.next = 47;
26238
+ case 44:
26239
+ _context52.next = 46;
26240
+ return mediaProcessor.setVideoFilter(videoFilter, avoidOriginalTrackLeak);
26241
+ case 46:
26242
+ _context52.next = 48;
26240
26243
  return mediaProcessor.setMediaStream(webRTCStream);
26241
- case 47:
26244
+ case 48:
26242
26245
  filteredVideoTrack = _context52.sent;
26243
26246
  if (!filteredVideoTrack) {
26244
- _context52.next = 51;
26247
+ _context52.next = 52;
26245
26248
  break;
26246
26249
  }
26247
- _context52.next = 51;
26250
+ _context52.next = 52;
26248
26251
  return replaceTrackAndUpdate(originalVideoTrack, filteredVideoTrack);
26249
- case 51:
26250
- _context52.next = 58;
26252
+ case 52:
26253
+ _context52.next = 59;
26251
26254
  break;
26252
- case 53:
26253
- _context52.prev = 53;
26254
- _context52.t1 = _context52["catch"](2);
26255
+ case 54:
26256
+ _context52.prev = 54;
26257
+ _context52.t1 = _context52["catch"](3);
26255
26258
  logging.error(`Error applying video filter: ${_context52.t1}`);
26256
26259
  logAnalyticsEvent('applyVideoFilter', 'Failure', {
26257
26260
  message: _context52.t1.message
26258
26261
  });
26259
26262
  throw _context52.t1;
26260
- case 58:
26263
+ case 59:
26261
26264
  currentVideoFilter = videoFilter;
26262
26265
  logAnalyticsEvent('applyVideoFilter', 'Success', {
26263
26266
  videoFilter: sanitizedVideoFilter
26264
26267
  });
26265
- case 60:
26268
+ case 61:
26266
26269
  case "end":
26267
26270
  return _context52.stop();
26268
26271
  }
26269
- }, _callee52, null, [[2, 53], [24, 32]]);
26272
+ }, _callee52, null, [[3, 54], [25, 33]]);
26270
26273
  }));
26271
- return function (_x40) {
26274
+ return function (_x40, _x41) {
26272
26275
  return _ref59.apply(this, arguments);
26273
26276
  };
26274
26277
  }();
@@ -26472,7 +26475,7 @@ function PublisherFactory(_ref) {
26472
26475
  }
26473
26476
  }, _callee53, null, [[20, 34]]);
26474
26477
  }));
26475
- return function (_x41) {
26478
+ return function (_x42) {
26476
26479
  return _ref60.apply(this, arguments);
26477
26480
  };
26478
26481
  }();
@@ -26748,7 +26751,7 @@ function PublisherFactory(_ref) {
26748
26751
  }
26749
26752
  }, _callee55, null, [[28, 36]]);
26750
26753
  }));
26751
- return function (_x42) {
26754
+ return function (_x43) {
26752
26755
  return _ref62.apply(this, arguments);
26753
26756
  };
26754
26757
  }();
@@ -26842,7 +26845,7 @@ function PublisherFactory(_ref) {
26842
26845
  }
26843
26846
  }, _callee56, null, [[1, 7]]);
26844
26847
  }));
26845
- return function (_x43) {
26848
+ return function (_x44) {
26846
26849
  return _ref63.apply(this, arguments);
26847
26850
  };
26848
26851
  }();
@@ -26916,7 +26919,7 @@ function PublisherFactory(_ref) {
26916
26919
  }
26917
26920
  }, _callee57, null, [[21, 29]]);
26918
26921
  }));
26919
- return function _setAudioMediaProcessorConnector(_x44) {
26922
+ return function _setAudioMediaProcessorConnector(_x45) {
26920
26923
  return _ref64.apply(this, arguments);
26921
26924
  };
26922
26925
  }();
@@ -27065,7 +27068,7 @@ function PublisherFactory(_ref) {
27065
27068
  }
27066
27069
  }, _callee59);
27067
27070
  }));
27068
- return function applySetMaxBitrateToPeerConnection(_x45) {
27071
+ return function applySetMaxBitrateToPeerConnection(_x46) {
27069
27072
  return _ref66.apply(this, arguments);
27070
27073
  };
27071
27074
  }();
@@ -27142,7 +27145,7 @@ function PublisherFactory(_ref) {
27142
27145
  }
27143
27146
  }, _callee60, null, [[0, 6]]);
27144
27147
  }));
27145
- return function applyMaxBitrate(_x47) {
27148
+ return function applyMaxBitrate(_x48) {
27146
27149
  return _ref68.apply(this, arguments);
27147
27150
  };
27148
27151
  }();
@@ -27168,7 +27171,7 @@ function PublisherFactory(_ref) {
27168
27171
  }
27169
27172
  }, _callee61);
27170
27173
  }));
27171
- return function setMaxVideoBitrateToPublisher(_x46) {
27174
+ return function setMaxVideoBitrateToPublisher(_x47) {
27172
27175
  return _ref67.apply(this, arguments);
27173
27176
  };
27174
27177
  }();
@@ -27294,7 +27297,7 @@ function PublisherFactory(_ref) {
27294
27297
  }
27295
27298
  }, _callee62, null, [[19, 27]]);
27296
27299
  }));
27297
- return function (_x48) {
27300
+ return function (_x49) {
27298
27301
  return _ref69.apply(this, arguments);
27299
27302
  };
27300
27303
  }();
@@ -27371,7 +27374,7 @@ function PublisherFactory(_ref) {
27371
27374
  }
27372
27375
  }, _callee63, null, [[10, 18]]);
27373
27376
  }));
27374
- return function (_x49) {
27377
+ return function (_x50) {
27375
27378
  return _ref70.apply(this, arguments);
27376
27379
  };
27377
27380
  }();
@@ -27432,7 +27435,7 @@ function PublisherFactory(_ref) {
27432
27435
  }
27433
27436
  }, _callee64);
27434
27437
  }));
27435
- return function (_x50) {
27438
+ return function (_x51) {
27436
27439
  return _ref71.apply(this, arguments);
27437
27440
  };
27438
27441
  }();
@@ -27491,7 +27494,7 @@ function PublisherFactory(_ref) {
27491
27494
  }
27492
27495
  }, _callee65);
27493
27496
  }));
27494
- return function (_x51) {
27497
+ return function (_x52) {
27495
27498
  return _ref72.apply(this, arguments);
27496
27499
  };
27497
27500
  }();
@@ -27877,7 +27880,7 @@ var _interopRequireDefault = __webpack_require__(0);
27877
27880
  exports.__esModule = true;
27878
27881
  exports.WebglSelfieSegmentationType = exports.WarningType = exports.VonageMediaProcessor = exports.RenderingType = exports.PipelineInfoData = exports.ErrorFunction = exports.BlurRadius = exports.BackgroundTransformerType = exports.BackgroundTransformer = void 0;
27879
27882
  exports.createVonageMediaProcessor = Dd;
27880
- exports.getSupportedBrowserFeatures = Xs;
27883
+ exports.getSupportedBrowserFeatures = Ks;
27881
27884
  exports.isSupported = Bd;
27882
27885
  var _regenerator = _interopRequireDefault(__webpack_require__(5));
27883
27886
  var _wrapNativeSuper2 = _interopRequireDefault(__webpack_require__(86));
@@ -27909,11 +27912,11 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
27909
27912
  function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
27910
27913
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
27911
27914
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
27912
- function is() {
27913
- return _is.apply(this, arguments);
27915
+ function os() {
27916
+ return _os.apply(this, arguments);
27914
27917
  }
27915
- function _is() {
27916
- _is = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee104() {
27918
+ function _os() {
27919
+ _os = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee104() {
27917
27920
  return _regenerator.default.wrap(function _callee104$(_context104) {
27918
27921
  while (1) switch (_context104.prev = _context104.next) {
27919
27922
  case 0:
@@ -27922,20 +27925,20 @@ function _is() {
27922
27925
  return _regenerator.default.wrap(function _callee103$(_context103) {
27923
27926
  while (1) switch (_context103.prev = _context103.next) {
27924
27927
  case 0:
27925
- _context103.t0 = !ss();
27928
+ _context103.t0 = !as();
27926
27929
  if (!_context103.t0) {
27927
27930
  _context103.next = 8;
27928
27931
  break;
27929
27932
  }
27930
27933
  _context103.next = 4;
27931
- return si();
27934
+ return ai();
27932
27935
  case 4:
27933
27936
  _context103.t1 = _context103.sent;
27934
27937
  if (_context103.t1) {
27935
27938
  _context103.next = 7;
27936
27939
  break;
27937
27940
  }
27938
- _context103.t1 = oi();
27941
+ _context103.t1 = si();
27939
27942
  case 7:
27940
27943
  _context103.t0 = _context103.t1;
27941
27944
  case 8:
@@ -27964,20 +27967,20 @@ function _is() {
27964
27967
  }
27965
27968
  }, _callee104);
27966
27969
  }));
27967
- return _is.apply(this, arguments);
27970
+ return _os.apply(this, arguments);
27968
27971
  }
27969
- function oi() {
27970
- return self.MediaStreamTrackProcessor !== void 0 && self.MediaStreamTrackGenerator !== void 0 || os();
27972
+ function si() {
27973
+ return self.MediaStreamTrackProcessor !== void 0 && self.MediaStreamTrackGenerator !== void 0 || ss();
27971
27974
  }
27972
- function os() {
27975
+ function ss() {
27973
27976
  return [self.ReadableStream, self.WritableStream, self.MediaStream, self.OffscreenCanvas, self.VideoFrame, self.AudioContext, self.AudioWorkletNode].filter(r => r === void 0).length === 0;
27974
27977
  }
27975
- function ss() {
27978
+ function as() {
27976
27979
  var _r$split$find;
27977
27980
  const r = navigator.userAgent.toLowerCase();
27978
27981
  return navigator.vendor && navigator.vendor.toLowerCase().indexOf("apple") > -1 && !(r.indexOf("applewebkit") > -1 && r.indexOf("version") === -1) ? parseInt(((_r$split$find = r.split(" ").find(e => e.includes("version/"))) != null ? _r$split$find : "/0").split("/")[1]) < 26 : !1;
27979
27982
  }
27980
- function si() {
27983
+ function ai() {
27981
27984
  return new Promise(r => {
27982
27985
  function e() {
27983
27986
  self.postMessage(typeof MediaStreamTrackProcessor < "u" && typeof VideoTrackGenerator < "u");
@@ -27992,29 +27995,29 @@ function si() {
27992
27995
  const ee = /* @__PURE__ */new WeakMap(),
27993
27996
  me = /* @__PURE__ */new WeakMap(),
27994
27997
  q = /* @__PURE__ */new WeakMap(),
27995
- Rt = /* @__PURE__ */Symbol("anyProducer"),
27998
+ kt = /* @__PURE__ */Symbol("anyProducer"),
27996
27999
  Tn = Promise.resolve(),
27997
- kt = /* @__PURE__ */Symbol("listenerAdded"),
28000
+ Rt = /* @__PURE__ */Symbol("listenerAdded"),
27998
28001
  Pt = /* @__PURE__ */Symbol("listenerRemoved");
27999
28002
  let Ft = !1,
28000
28003
  mr = !1;
28001
28004
  const Ct = r => typeof r == "string" || typeof r == "symbol" || typeof r == "number";
28002
- function Ae(r) {
28005
+ function Te(r) {
28003
28006
  if (!Ct(r)) throw new TypeError("`eventName` must be a string, symbol, or number");
28004
28007
  }
28005
28008
  function ft(r) {
28006
28009
  if (typeof r != "function") throw new TypeError("listener must be a function");
28007
28010
  }
28008
- function Te(r, e) {
28011
+ function Se(r, e) {
28009
28012
  const t = me.get(r);
28010
28013
  if (t.has(e)) return t.get(e);
28011
28014
  }
28012
28015
  function je(r, e) {
28013
- const t = Ct(e) ? e : Rt,
28016
+ const t = Ct(e) ? e : kt,
28014
28017
  n = q.get(r);
28015
28018
  if (n.has(t)) return n.get(t);
28016
28019
  }
28017
- function as(r, e, t) {
28020
+ function cs(r, e, t) {
28018
28021
  const n = q.get(r);
28019
28022
  if (n.has(e)) {
28020
28023
  for (var _iterator = _createForOfIteratorHelperLoose(n.get(e)), _step; !(_step = _iterator()).done;) {
@@ -28022,9 +28025,9 @@ function as(r, e, t) {
28022
28025
  i.enqueue(t);
28023
28026
  }
28024
28027
  }
28025
- if (n.has(Rt)) {
28028
+ if (n.has(kt)) {
28026
28029
  const i = Promise.all([e, t]);
28027
- for (var _iterator2 = _createForOfIteratorHelperLoose(n.get(Rt)), _step2; !(_step2 = _iterator2()).done;) {
28030
+ for (var _iterator2 = _createForOfIteratorHelperLoose(n.get(kt)), _step2; !(_step2 = _iterator2()).done;) {
28028
28031
  const o = _step2.value;
28029
28032
  o.enqueue(i);
28030
28033
  }
@@ -28156,17 +28159,17 @@ function Sn(r, e) {
28156
28159
  };
28157
28160
  }
28158
28161
  function In(r) {
28159
- if (r === void 0) return Rn;
28162
+ if (r === void 0) return kn;
28160
28163
  if (!Array.isArray(r)) throw new TypeError("`methodNames` must be an array of strings");
28161
28164
  for (var _iterator5 = _createForOfIteratorHelperLoose(r), _step5; !(_step5 = _iterator5()).done;) {
28162
28165
  const e = _step5.value;
28163
- if (!Rn.includes(e)) throw typeof e != "string" ? new TypeError("`methodNames` element must be a string") : new Error(`${e} is not Emittery method`);
28166
+ if (!kn.includes(e)) throw typeof e != "string" ? new TypeError("`methodNames` element must be a string") : new Error(`${e} is not Emittery method`);
28164
28167
  }
28165
28168
  return r;
28166
28169
  }
28167
- const Me = r => r === kt || r === Pt;
28170
+ const Be = r => r === Rt || r === Pt;
28168
28171
  function dt(r, e, t) {
28169
- if (Me(e)) try {
28172
+ if (Be(e)) try {
28170
28173
  Ft = !0, r.emit(e, t);
28171
28174
  } finally {
28172
28175
  Ft = !1;
@@ -28208,7 +28211,7 @@ let J = /*#__PURE__*/function () {
28208
28211
  if (e === void 0) {
28209
28212
  e = {};
28210
28213
  }
28211
- 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 = e.debug) != null ? _e$debug : {}, this.debug.enabled === void 0 && (this.debug.enabled = !1), this.debug.logger || (this.debug.logger = (t, n, i, o) => {
28214
+ ee.set(this, /* @__PURE__ */new Set()), me.set(this, /* @__PURE__ */new Map()), q.set(this, /* @__PURE__ */new Map()), q.get(this).set(kt, /* @__PURE__ */new Set()), this.debug = (_e$debug = e.debug) != null ? _e$debug : {}, this.debug.enabled === void 0 && (this.debug.enabled = !1), this.debug.logger || (this.debug.logger = (t, n, i, o) => {
28212
28215
  try {
28213
28216
  o = JSON.stringify(o);
28214
28217
  } catch (_unused) {
@@ -28231,9 +28234,9 @@ let J = /*#__PURE__*/function () {
28231
28234
  ft(t), e = Array.isArray(e) ? e : [e];
28232
28235
  for (var _iterator8 = _createForOfIteratorHelperLoose(e), _step8; !(_step8 = _iterator8()).done;) {
28233
28236
  const o = _step8.value;
28234
- Ae(o);
28235
- let s = Te(this, o);
28236
- 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, {
28237
+ Te(o);
28238
+ let s = Se(this, o);
28239
+ s || (s = /* @__PURE__ */new Set(), me.get(this).set(o, s)), s.add(t), this.logIfDebugEnabled("subscribe", o, void 0), Be(o) || dt(this, Rt, {
28237
28240
  eventName: o,
28238
28241
  listener: t
28239
28242
  });
@@ -28249,9 +28252,9 @@ let J = /*#__PURE__*/function () {
28249
28252
  ft(t), e = Array.isArray(e) ? e : [e];
28250
28253
  for (var _iterator9 = _createForOfIteratorHelperLoose(e), _step9; !(_step9 = _iterator9()).done;) {
28251
28254
  const n = _step9.value;
28252
- Ae(n);
28253
- const i = Te(this, n);
28254
- i && (i.delete(t), i.size === 0 && me.get(this).delete(n)), this.logIfDebugEnabled("unsubscribe", n, void 0), Me(n) || dt(this, Pt, {
28255
+ Te(n);
28256
+ const i = Se(this, n);
28257
+ i && (i.delete(t), i.size === 0 && me.get(this).delete(n)), this.logIfDebugEnabled("unsubscribe", n, void 0), Be(n) || dt(this, Pt, {
28255
28258
  eventName: n,
28256
28259
  listener: t
28257
28260
  });
@@ -28271,25 +28274,25 @@ let J = /*#__PURE__*/function () {
28271
28274
  e = Array.isArray(e) ? e : [e];
28272
28275
  for (var _iterator10 = _createForOfIteratorHelperLoose(e), _step10; !(_step10 = _iterator10()).done;) {
28273
28276
  const t = _step10.value;
28274
- Ae(t);
28277
+ Te(t);
28275
28278
  }
28276
28279
  return Sn(this, e);
28277
28280
  };
28278
28281
  _proto.emit = /*#__PURE__*/function () {
28279
28282
  var _emit = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(e, t) {
28280
- var _Te;
28283
+ var _Se;
28281
28284
  var n, i, o, s;
28282
28285
  return _regenerator.default.wrap(function _callee5$(_context5) {
28283
28286
  while (1) switch (_context5.prev = _context5.next) {
28284
28287
  case 0:
28285
- if (!(Ae(e), Me(e) && !Ft)) {
28288
+ if (!(Te(e), Be(e) && !Ft)) {
28286
28289
  _context5.next = 2;
28287
28290
  break;
28288
28291
  }
28289
28292
  throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");
28290
28293
  case 2:
28291
- this.logIfDebugEnabled("emit", e, t), as(this, e, t);
28292
- n = (_Te = Te(this, e)) != null ? _Te : /* @__PURE__ */new Set(), i = ee.get(this), o = [...n], s = Me(e) ? [] : [...i];
28294
+ this.logIfDebugEnabled("emit", e, t), cs(this, e, t);
28295
+ n = (_Se = Se(this, e)) != null ? _Se : /* @__PURE__ */new Set(), i = ee.get(this), o = [...n], s = Be(e) ? [] : [...i];
28293
28296
  _context5.next = 6;
28294
28297
  return Tn;
28295
28298
  case 6:
@@ -28346,19 +28349,19 @@ let J = /*#__PURE__*/function () {
28346
28349
  }();
28347
28350
  _proto.emitSerial = /*#__PURE__*/function () {
28348
28351
  var _emitSerial = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(e, t) {
28349
- var _Te2;
28352
+ var _Se2;
28350
28353
  var n, i, o, s, _i2, _o2, a, _i3, _s2;
28351
28354
  return _regenerator.default.wrap(function _callee6$(_context6) {
28352
28355
  while (1) switch (_context6.prev = _context6.next) {
28353
28356
  case 0:
28354
- if (!(Ae(e), Me(e) && !Ft)) {
28357
+ if (!(Te(e), Be(e) && !Ft)) {
28355
28358
  _context6.next = 2;
28356
28359
  break;
28357
28360
  }
28358
28361
  throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");
28359
28362
  case 2:
28360
28363
  this.logIfDebugEnabled("emitSerial", e, t);
28361
- n = (_Te2 = Te(this, e)) != null ? _Te2 : /* @__PURE__ */new Set(), i = ee.get(this), o = [...n], s = [...i];
28364
+ n = (_Se2 = Se(this, e)) != null ? _Se2 : /* @__PURE__ */new Set(), i = ee.get(this), o = [...n], s = [...i];
28362
28365
  _context6.next = 6;
28363
28366
  return Tn;
28364
28367
  case 6:
@@ -28413,7 +28416,7 @@ let J = /*#__PURE__*/function () {
28413
28416
  _proto.onAny = function onAny(e, _temp2) {
28414
28417
  let _ref5 = _temp2 === void 0 ? {} : _temp2,
28415
28418
  t = _ref5.signal;
28416
- ft(e), this.logIfDebugEnabled("subscribeAny", void 0, void 0), ee.get(this).add(e), dt(this, kt, {
28419
+ ft(e), this.logIfDebugEnabled("subscribeAny", void 0, void 0), ee.get(this).add(e), dt(this, Rt, {
28417
28420
  listener: e
28418
28421
  });
28419
28422
  const n = () => {
@@ -28436,7 +28439,7 @@ let J = /*#__PURE__*/function () {
28436
28439
  for (var _iterator11 = _createForOfIteratorHelperLoose(e), _step11; !(_step11 = _iterator11()).done;) {
28437
28440
  const t = _step11.value;
28438
28441
  if (this.logIfDebugEnabled("clear", t, void 0), Ct(t)) {
28439
- const n = Te(this, t);
28442
+ const n = Se(this, t);
28440
28443
  n && n.clear();
28441
28444
  const i = je(this, t);
28442
28445
  if (i) {
@@ -28473,11 +28476,11 @@ let J = /*#__PURE__*/function () {
28473
28476
  for (var _iterator16 = _createForOfIteratorHelperLoose(e), _step16; !(_step16 = _iterator16()).done;) {
28474
28477
  const n = _step16.value;
28475
28478
  if (Ct(n)) {
28476
- var _Te$size, _Te3, _je$size, _je, _je$size2, _je2;
28477
- t += ee.get(this).size + ((_Te$size = (_Te3 = Te(this, n)) == null ? void 0 : _Te3.size) != null ? _Te$size : 0) + ((_je$size = (_je = je(this, n)) == null ? void 0 : _je.size) != null ? _je$size : 0) + ((_je$size2 = (_je2 = je(this)) == null ? void 0 : _je2.size) != null ? _je$size2 : 0);
28479
+ var _Se$size, _Se3, _je$size, _je, _je$size2, _je2;
28480
+ t += ee.get(this).size + ((_Se$size = (_Se3 = Se(this, n)) == null ? void 0 : _Se3.size) != null ? _Se$size : 0) + ((_je$size = (_je = je(this, n)) == null ? void 0 : _je.size) != null ? _je$size : 0) + ((_je$size2 = (_je2 = je(this)) == null ? void 0 : _je2.size) != null ? _je$size2 : 0);
28478
28481
  continue;
28479
28482
  }
28480
- n !== void 0 && Ae(n), t += ee.get(this).size;
28483
+ n !== void 0 && Te(n), t += ee.get(this).size;
28481
28484
  for (var _iterator17 = _createForOfIteratorHelperLoose(me.get(this).values()), _step17; !(_step17 = _iterator17()).done;) {
28482
28485
  const i = _step17.value;
28483
28486
  t += i.size;
@@ -28518,9 +28521,9 @@ let J = /*#__PURE__*/function () {
28518
28521
  }]);
28519
28522
  return J;
28520
28523
  }();
28521
- const Rn = Object.getOwnPropertyNames(J.prototype).filter(r => r !== "constructor");
28524
+ const kn = Object.getOwnPropertyNames(J.prototype).filter(r => r !== "constructor");
28522
28525
  Object.defineProperty(J, "listenerAdded", {
28523
- value: kt,
28526
+ value: Rt,
28524
28527
  writable: !1,
28525
28528
  enumerable: !0,
28526
28529
  configurable: !1
@@ -28531,40 +28534,40 @@ Object.defineProperty(J, "listenerRemoved", {
28531
28534
  enumerable: !0,
28532
28535
  configurable: !1
28533
28536
  });
28534
- var cs = Object.defineProperty,
28535
- us = (r, e, t) => e in r ? cs(r, e, {
28537
+ var us = Object.defineProperty,
28538
+ ls = (r, e, t) => e in r ? us(r, e, {
28536
28539
  enumerable: !0,
28537
28540
  configurable: !0,
28538
28541
  writable: !0,
28539
28542
  value: t
28540
28543
  }) : r[e] = t,
28541
- ls = (r, e, t) => (us(r, e + "", t), t);
28542
- const fs = "hlg.tokbox.com/prod/logging/vcp_webrtc",
28543
- ds = "https://",
28544
- hs = 1e4;
28544
+ fs = (r, e, t) => (ls(r, e + "", t), t);
28545
+ const ds = "hlg.tokbox.com/prod/logging/vcp_webrtc",
28546
+ hs = "https://",
28547
+ ms = 1e4;
28545
28548
  let ht;
28546
- const ms = new Uint8Array(16);
28547
- function ps() {
28549
+ const ps = new Uint8Array(16);
28550
+ function gs() {
28548
28551
  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");
28549
- return ht(ms);
28552
+ return ht(ps);
28550
28553
  }
28551
28554
  const F = [];
28552
28555
  for (let r = 0; r < 256; ++r) F.push((r + 256).toString(16).slice(1));
28553
- function gs(r, e) {
28556
+ function ys(r, e) {
28554
28557
  if (e === void 0) {
28555
28558
  e = 0;
28556
28559
  }
28557
28560
  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();
28558
28561
  }
28559
- const ys = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto),
28560
- kn = {
28561
- randomUUID: ys
28562
+ const bs = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto),
28563
+ Rn = {
28564
+ randomUUID: bs
28562
28565
  };
28563
- function bs(r, e, t) {
28564
- if (kn.randomUUID && !r) return kn.randomUUID();
28566
+ function ws(r, e, t) {
28567
+ if (Rn.randomUUID && !r) return Rn.randomUUID();
28565
28568
  r = r || {};
28566
- const n = r.random || (r.rng || ps)();
28567
- return n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128, gs(n);
28569
+ const n = r.random || (r.rng || gs)();
28570
+ return n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128, ys(n);
28568
28571
  }
28569
28572
  function Ur(r, e) {
28570
28573
  _globalThis.vonage || (_globalThis.vonage = {}), _globalThis.vonage.workerizer || (_globalThis.vonage.workerizer = {});
@@ -28572,19 +28575,19 @@ function Ur(r, e) {
28572
28575
  return t[r] || (t[r] = e), t[r];
28573
28576
  }
28574
28577
  const ie = Ur("globals", {});
28575
- var ye = /* @__PURE__ */(r => (r.INIT = "INIT", r.FORWARD = "FORWARD", r.TERMINATE = "TERMINATE", r.GLOBALS_SYNC = "GLOBALS_SYNC", r))(ye || {});
28576
- function ai(r) {
28578
+ var be = /* @__PURE__ */(r => (r.INIT = "INIT", r.FORWARD = "FORWARD", r.TERMINATE = "TERMINATE", r.GLOBALS_SYNC = "GLOBALS_SYNC", r))(be || {});
28579
+ function ci(r) {
28577
28580
  return [ImageBitmap, ReadableStream, WritableStream].some(e => r instanceof e);
28578
28581
  }
28579
- let ws = 0;
28580
- function xs(r, e, t, n, i) {
28581
- const o = ws++;
28582
+ let xs = 0;
28583
+ function vs(r, e, t, n, i) {
28584
+ const o = xs++;
28582
28585
  return r.postMessage({
28583
28586
  id: o,
28584
28587
  type: e,
28585
28588
  functionName: t,
28586
28589
  args: n
28587
- }, n.filter(s => ai(s))), new Promise(s => {
28590
+ }, n.filter(s => ci(s))), new Promise(s => {
28588
28591
  i == null ? void 0 : i.set(o, s);
28589
28592
  });
28590
28593
  }
@@ -28596,27 +28599,27 @@ function Ze(r, e) {
28596
28599
  id: t,
28597
28600
  type: n,
28598
28601
  result: e
28599
- }, i.filter(o => ai(o)));
28602
+ }, i.filter(o => ci(o)));
28600
28603
  }
28601
28604
  const Pn = Ur("workerized", {});
28602
- function ci() {
28605
+ function ui() {
28603
28606
  return typeof WorkerGlobalScope < "u" && self instanceof WorkerGlobalScope;
28604
28607
  }
28605
- function vs() {
28606
- return _vs.apply(this, arguments);
28608
+ function _s() {
28609
+ return _s3.apply(this, arguments);
28607
28610
  }
28608
- function _vs() {
28609
- _vs = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee105() {
28611
+ function _s3() {
28612
+ _s3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee105() {
28610
28613
  var r, e, _Pn$e$workerContext, t, n;
28611
28614
  return _regenerator.default.wrap(function _callee105$(_context105) {
28612
28615
  while (1) switch (_context105.prev = _context105.next) {
28613
28616
  case 0:
28614
- if (!ci()) {
28617
+ if (!ui()) {
28615
28618
  _context105.next = 4;
28616
28619
  break;
28617
28620
  }
28618
28621
  Ze({
28619
- type: ye.GLOBALS_SYNC
28622
+ type: be.GLOBALS_SYNC
28620
28623
  }, ie);
28621
28624
  _context105.next = 8;
28622
28625
  break;
@@ -28624,7 +28627,7 @@ function _vs() {
28624
28627
  r = [];
28625
28628
  for (e in Pn) {
28626
28629
  _Pn$e$workerContext = Pn[e].workerContext, t = _Pn$e$workerContext.worker, n = _Pn$e$workerContext.resolvers;
28627
- t && r.push(xs(t, ye.GLOBALS_SYNC, "", [ie], n));
28630
+ t && r.push(vs(t, be.GLOBALS_SYNC, "", [ie], n));
28628
28631
  }
28629
28632
  _context105.next = 8;
28630
28633
  return Promise.all(r);
@@ -28634,17 +28637,17 @@ function _vs() {
28634
28637
  }
28635
28638
  }, _callee105);
28636
28639
  }));
28637
- return _vs.apply(this, arguments);
28640
+ return _s3.apply(this, arguments);
28638
28641
  }
28639
28642
  function Ot(r, e) {
28640
28643
  if (Array.isArray(e)) e.splice(0, e.length);else if (typeof e == "object") for (const t in e) delete e[t];
28641
28644
  for (const t in r) 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];
28642
28645
  }
28643
- function _s(_x7, _x8) {
28644
- return _s3.apply(this, arguments);
28646
+ function Es(_x7, _x8) {
28647
+ return _Es.apply(this, arguments);
28645
28648
  }
28646
- function _s3() {
28647
- _s3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee106(r, e) {
28649
+ function _Es() {
28650
+ _Es = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee106(r, e) {
28648
28651
  var t, n;
28649
28652
  return _regenerator.default.wrap(function _callee106$(_context106) {
28650
28653
  while (1) switch (_context106.prev = _context106.next) {
@@ -28681,23 +28684,23 @@ function _s3() {
28681
28684
  }
28682
28685
  }, _callee106);
28683
28686
  }));
28684
- return _s3.apply(this, arguments);
28687
+ return _Es.apply(this, arguments);
28685
28688
  }
28686
- const Es = Ur("registeredWorkers", {});
28687
- function As(r, e) {
28689
+ const As = Ur("registeredWorkers", {});
28690
+ function Ts(r, e) {
28688
28691
  if (!r.args) throw "Missing className while initializing worker";
28689
28692
  const _r$args = r.args,
28690
28693
  t = _r$args[0],
28691
28694
  n = _r$args[1],
28692
- i = Es[t];
28695
+ i = As[t];
28693
28696
  if (i) e.instance = new i(r.args.slice(1));else throw `unknown worker class ${t}`;
28694
28697
  Ot(n, ie), Ze(r, typeof e.instance !== void 0);
28695
28698
  }
28696
- function Ts(_x9, _x10) {
28697
- return _Ts.apply(this, arguments);
28699
+ function Ss(_x9, _x10) {
28700
+ return _Ss.apply(this, arguments);
28698
28701
  }
28699
- function _Ts() {
28700
- _Ts = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee107(r, e) {
28702
+ function _Ss() {
28703
+ _Ss = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee107(r, e) {
28701
28704
  var t, n;
28702
28705
  return _regenerator.default.wrap(function _callee107$(_context107) {
28703
28706
  while (1) switch (_context107.prev = _context107.next) {
@@ -28726,13 +28729,13 @@ function _Ts() {
28726
28729
  }
28727
28730
  }, _callee107);
28728
28731
  }));
28729
- return _Ts.apply(this, arguments);
28732
+ return _Ss.apply(this, arguments);
28730
28733
  }
28731
- function Ss(r) {
28734
+ function Is(r) {
28732
28735
  if (!r.args) throw "Missing globals while syncing";
28733
28736
  Ot(r.args[0], ie), Ze(r, {});
28734
28737
  }
28735
- function Is() {
28738
+ function ks() {
28736
28739
  const r = {};
28737
28740
  onmessage = /*#__PURE__*/function () {
28738
28741
  var _ref7 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(e) {
@@ -28742,19 +28745,19 @@ function Is() {
28742
28745
  case 0:
28743
28746
  t = e.data;
28744
28747
  _context7.t0 = t.type;
28745
- _context7.next = _context7.t0 === ye.INIT ? 4 : _context7.t0 === ye.FORWARD ? 6 : _context7.t0 === ye.TERMINATE ? 8 : _context7.t0 === ye.GLOBALS_SYNC ? 10 : 12;
28748
+ _context7.next = _context7.t0 === be.INIT ? 4 : _context7.t0 === be.FORWARD ? 6 : _context7.t0 === be.TERMINATE ? 8 : _context7.t0 === be.GLOBALS_SYNC ? 10 : 12;
28746
28749
  break;
28747
28750
  case 4:
28748
- As(t, r);
28751
+ Ts(t, r);
28749
28752
  return _context7.abrupt("break", 12);
28750
28753
  case 6:
28751
- _s(t, r);
28754
+ Es(t, r);
28752
28755
  return _context7.abrupt("break", 12);
28753
28756
  case 8:
28754
- Ts(t, r);
28757
+ Ss(t, r);
28755
28758
  return _context7.abrupt("break", 12);
28756
28759
  case 10:
28757
- Ss(t);
28760
+ Is(t);
28758
28761
  return _context7.abrupt("break", 12);
28759
28762
  case 12:
28760
28763
  case "end":
@@ -28767,7 +28770,7 @@ function Is() {
28767
28770
  };
28768
28771
  }();
28769
28772
  }
28770
- ci() && Is();
28773
+ ui() && ks();
28771
28774
  function Rs(r, e) {
28772
28775
  return ie[r] || (ie[r] = e), [() => ie[r], /*#__PURE__*/function () {
28773
28776
  var _ref8 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8(t) {
@@ -28776,7 +28779,7 @@ function Rs(r, e) {
28776
28779
  case 0:
28777
28780
  ie[r] = t;
28778
28781
  _context8.next = 3;
28779
- return vs();
28782
+ return _s();
28780
28783
  case 3:
28781
28784
  case "end":
28782
28785
  return _context8.stop();
@@ -28788,21 +28791,21 @@ function Rs(r, e) {
28788
28791
  };
28789
28792
  }()];
28790
28793
  }
28791
- function ks(r, e) {
28794
+ function Ps(r, e) {
28792
28795
  return Rs(r, e);
28793
28796
  }
28794
- const _ks = ks("metadata"),
28795
- Ps = _ks[0],
28796
- Fs = _ks[1];
28797
- function Cs(r) {
28798
- Fs(r);
28797
+ const _Ps = Ps("metadata"),
28798
+ Fs = _Ps[0],
28799
+ Cs = _Ps[1];
28800
+ function Os(r) {
28801
+ Cs(r);
28799
28802
  }
28800
28803
  function Tt() {
28801
- return Ps();
28804
+ return Fs();
28802
28805
  }
28803
28806
  let Lr = /*#__PURE__*/function () {
28804
28807
  function Lr(e, t) {
28805
- ls(this, "uuid"), this.config = e, this.uuid = t != null ? t : bs();
28808
+ fs(this, "uuid"), this.config = e, this.uuid = t != null ? t : ws();
28806
28809
  }
28807
28810
  var _proto2 = Lr.prototype;
28808
28811
  _proto2.send = /*#__PURE__*/function () {
@@ -28818,7 +28821,7 @@ let Lr = /*#__PURE__*/function () {
28818
28821
  }
28819
28822
  return _context9.abrupt("return", "metadata missing");
28820
28823
  case 3:
28821
- a = new AbortController(), c = setTimeout(() => a.abort(), hs);
28824
+ a = new AbortController(), c = setTimeout(() => a.abort(), ms);
28822
28825
  _context9.next = 6;
28823
28826
  return ((i = (n = this.config) == null ? void 0 : n.fetch) != null ? i : fetch)(this.getUrl(), {
28824
28827
  method: "POST",
@@ -28842,8 +28845,8 @@ let Lr = /*#__PURE__*/function () {
28842
28845
  }();
28843
28846
  _proto2.getUrl = function getUrl() {
28844
28847
  var e;
28845
- let t = (e = Tt().proxyUrl) != null ? e : ds;
28846
- return t += (t.at(-1) === "/" ? "" : "/") + fs, t;
28848
+ let t = (e = Tt().proxyUrl) != null ? e : hs;
28849
+ return t += (t.at(-1) === "/" ? "" : "/") + ds, t;
28847
28850
  };
28848
28851
  _proto2.getHeaders = function getHeaders() {
28849
28852
  return {
@@ -28876,12 +28879,12 @@ _r.updates = {
28876
28879
  readable_null: "Readable is null",
28877
28880
  writable_null: "Writable is null"
28878
28881
  };
28879
- let be = _r;
28880
- function Os(r) {
28882
+ let we = _r;
28883
+ function Ms(r) {
28881
28884
  return typeof r == "object" && r !== null && "message" in r && typeof r.message == "string";
28882
28885
  }
28883
- function Ms(r) {
28884
- if (Os(r)) return r;
28886
+ function Bs(r) {
28887
+ if (Ms(r)) return r;
28885
28888
  try {
28886
28889
  return new Error(JSON.stringify(r));
28887
28890
  } catch (_unused2) {
@@ -28889,13 +28892,13 @@ function Ms(r) {
28889
28892
  }
28890
28893
  }
28891
28894
  function pr(r) {
28892
- return Ms(r).message;
28895
+ return Bs(r).message;
28893
28896
  }
28894
- let Bs = /*#__PURE__*/function () {
28895
- function Bs(e, t) {
28897
+ let Ds = /*#__PURE__*/function () {
28898
+ function Ds(e, t) {
28896
28899
  this.config = e, this.frameTransformedCount = 0, this.frameFromSourceCount = 0, this.startAt = 0, this.reporter = new Lr(e, t);
28897
28900
  }
28898
- var _proto3 = Bs.prototype;
28901
+ var _proto3 = Ds.prototype;
28899
28902
  _proto3.onFrameFromSource = /*#__PURE__*/function () {
28900
28903
  var _onFrameFromSource = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10() {
28901
28904
  return _regenerator.default.wrap(function _callee10$(_context10) {
@@ -28944,7 +28947,7 @@ let Bs = /*#__PURE__*/function () {
28944
28947
  }
28945
28948
  return onFrameTransformed;
28946
28949
  }();
28947
- (0, _createClass2.default)(Bs, [{
28950
+ (0, _createClass2.default)(Ds, [{
28948
28951
  key: "fps",
28949
28952
  get: function get() {
28950
28953
  const e = this.startAt,
@@ -28953,22 +28956,22 @@ let Bs = /*#__PURE__*/function () {
28953
28956
  return t / n;
28954
28957
  }
28955
28958
  }]);
28956
- return Bs;
28959
+ return Ds;
28957
28960
  }();
28958
- var Ds = /* @__PURE__ */(r => (r.FPS_DROP = "fps_drop", r))(Ds || {}),
28959
- Us = /* @__PURE__ */(r => (r.start = "start", r.transform = "transform", r.flush = "flush", r))(Us || {}),
28961
+ var Us = /* @__PURE__ */(r => (r.FPS_DROP = "fps_drop", r))(Us || {}),
28962
+ Ls = /* @__PURE__ */(r => (r.start = "start", r.transform = "transform", r.flush = "flush", r))(Ls || {}),
28960
28963
  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 || {});
28961
28964
  exports.PipelineInfoData = Er;
28962
- exports.ErrorFunction = Us;
28963
- exports.WarningType = Ds;
28964
- const Ls = 500,
28965
- zs = 0.8;
28966
- let Ns = /*#__PURE__*/function (_J) {
28967
- (0, _inheritsLoose2.default)(Ns, _J);
28968
- function Ns(e, t) {
28965
+ exports.ErrorFunction = Ls;
28966
+ exports.WarningType = Us;
28967
+ const zs = 500,
28968
+ Ns = 0.8;
28969
+ let $s = /*#__PURE__*/function (_J) {
28970
+ (0, _inheritsLoose2.default)($s, _J);
28971
+ function $s(e, t) {
28969
28972
  var _this2;
28970
- _this2 = _J.call(this) || this, _this2.reporter_ = new Lr(), _this2.reporterQos_ = new Bs({
28971
- loggingIntervalFrameCount: Ls,
28973
+ _this2 = _J.call(this) || this, _this2.reporter_ = new Lr(), _this2.reporterQos_ = new Ds({
28974
+ loggingIntervalFrameCount: zs,
28972
28975
  report: {
28973
28976
  version: St
28974
28977
  }
@@ -28977,7 +28980,7 @@ let Ns = /*#__PURE__*/function (_J) {
28977
28980
  });
28978
28981
  return _this2;
28979
28982
  }
28980
- var _proto4 = Ns.prototype;
28983
+ var _proto4 = $s.prototype;
28981
28984
  _proto4.setTrackExpectedRate = function setTrackExpectedRate(e) {
28982
28985
  this.trackExpectedRate_ = e;
28983
28986
  };
@@ -29001,7 +29004,7 @@ let Ns = /*#__PURE__*/function (_J) {
29001
29004
  _context12.prev = 6;
29002
29005
  _context12.t0 = _context12["catch"](1);
29003
29006
  this.report({
29004
- message: be.errors.transformer_start,
29007
+ message: we.errors.transformer_start,
29005
29008
  variation: "Error",
29006
29009
  error: pr(_context12.t0)
29007
29010
  });
@@ -29056,7 +29059,7 @@ let Ns = /*#__PURE__*/function (_J) {
29056
29059
  _context13.prev = 11;
29057
29060
  _context13.t0 = _context13["catch"](5);
29058
29061
  this.report({
29059
- message: be.errors.transformer_transform,
29062
+ message: we.errors.transformer_transform,
29060
29063
  variation: "Error",
29061
29064
  error: pr(_context13.t0)
29062
29065
  });
@@ -29071,7 +29074,7 @@ let Ns = /*#__PURE__*/function (_J) {
29071
29074
 
29072
29075
  this.emit("error", i);
29073
29076
  case 16:
29074
- if (this.trackExpectedRate_ != -1 && this.trackExpectedRate_ * zs > this.reporterQos_.fps) {
29077
+ if (this.trackExpectedRate_ != -1 && this.trackExpectedRate_ * Ns > this.reporterQos_.fps) {
29075
29078
  n = {
29076
29079
  eventMetaData: {
29077
29080
  transformerIndex: this.index_
@@ -29116,7 +29119,7 @@ let Ns = /*#__PURE__*/function (_J) {
29116
29119
  _context14.prev = 7;
29117
29120
  _context14.t0 = _context14["catch"](2);
29118
29121
  this.report({
29119
- message: be.errors.transformer_flush,
29122
+ message: we.errors.transformer_flush,
29120
29123
  variation: "Error",
29121
29124
  error: pr(_context14.t0)
29122
29125
  });
@@ -29167,15 +29170,15 @@ let Ns = /*#__PURE__*/function (_J) {
29167
29170
  videoHeight: this.videoHeight_
29168
29171
  }, e);
29169
29172
  };
29170
- return Ns;
29173
+ return $s;
29171
29174
  }(J);
29172
- let $s = /*#__PURE__*/function (_J2) {
29173
- (0, _inheritsLoose2.default)($s, _J2);
29174
- function $s(e) {
29175
+ let Ws = /*#__PURE__*/function (_J2) {
29176
+ (0, _inheritsLoose2.default)(Ws, _J2);
29177
+ function Ws(e) {
29175
29178
  var _this3;
29176
29179
  _this3 = _J2.call(this) || this, _this3.transformers_ = [], _this3.trackExpectedRate_ = -1;
29177
29180
  for (let t = 0; t < e.length; t++) {
29178
- let n = new Ns(e[t], t);
29181
+ let n = new $s(e[t], t);
29179
29182
  n.on("error", i => {
29180
29183
  _this3.emit("error", i);
29181
29184
  }), n.on("warn", i => {
@@ -29184,7 +29187,7 @@ let $s = /*#__PURE__*/function (_J2) {
29184
29187
  }
29185
29188
  return _this3;
29186
29189
  }
29187
- var _proto5 = $s.prototype;
29190
+ var _proto5 = Ws.prototype;
29188
29191
  _proto5.setTrackExpectedRate = function setTrackExpectedRate(e) {
29189
29192
  this.trackExpectedRate_ = e;
29190
29193
  for (var _iterator20 = _createForOfIteratorHelperLoose(this.transformers_), _step20; !(_step20 = _iterator20()).done;) {
@@ -29302,11 +29305,11 @@ let $s = /*#__PURE__*/function (_J2) {
29302
29305
  }
29303
29306
  return destroy;
29304
29307
  }();
29305
- return $s;
29308
+ return Ws;
29306
29309
  }(J);
29307
- let ui = /*#__PURE__*/function (_J3) {
29308
- (0, _inheritsLoose2.default)(ui, _J3);
29309
- function ui() {
29310
+ let li = /*#__PURE__*/function (_J3) {
29311
+ (0, _inheritsLoose2.default)(li, _J3);
29312
+ function li() {
29310
29313
  var _this5;
29311
29314
  _this5 = _J3.call(this) || this, _this5.reporter_ = new Lr(), _this5.trackExpectedRate_ = -1, _this5.report({
29312
29315
  variation: "Create"
@@ -29325,7 +29328,7 @@ let ui = /*#__PURE__*/function (_J3) {
29325
29328
  * ***This is an optional method.***
29326
29329
  * @param trackExpectedRate - number holds the predicted track rate.
29327
29330
  */
29328
- var _proto6 = ui.prototype;
29331
+ var _proto6 = li.prototype;
29329
29332
  _proto6.setTrackExpectedRate = function setTrackExpectedRate(e) {
29330
29333
  this.trackExpectedRate_ = e, this.pipeline_ && this.pipeline_.setTrackExpectedRate(this.trackExpectedRate_);
29331
29334
  };
@@ -29384,7 +29387,7 @@ let ui = /*#__PURE__*/function (_J3) {
29384
29387
  break;
29385
29388
  }
29386
29389
  _this6.report({
29387
- message: be.errors.transformer_none,
29390
+ message: we.errors.transformer_none,
29388
29391
  variation: "Error"
29389
29392
  }), t("[MediaProcessor] Need to set transformers.");
29390
29393
  return _context20.abrupt("return");
@@ -29395,7 +29398,7 @@ let ui = /*#__PURE__*/function (_J3) {
29395
29398
  }
29396
29399
  _this6.report({
29397
29400
  variation: "Error",
29398
- message: be.errors.readable_null
29401
+ message: we.errors.readable_null
29399
29402
  }), t("[MediaProcessor] Readable is null.");
29400
29403
  return _context20.abrupt("return");
29401
29404
  case 6:
@@ -29405,12 +29408,12 @@ let ui = /*#__PURE__*/function (_J3) {
29405
29408
  }
29406
29409
  _this6.report({
29407
29410
  variation: "Error",
29408
- message: be.errors.writable_null
29411
+ message: we.errors.writable_null
29409
29412
  }), t("[MediaProcessor] Writable is null.");
29410
29413
  return _context20.abrupt("return");
29411
29414
  case 9:
29412
29415
  n = !1;
29413
- _this6.pipeline_ && (n = !0, _this6.pipeline_.clearListeners(), _this6.pipeline_.destroy()), _this6.pipeline_ = new $s(_this6.transformers_), _this6.pipeline_.on("warn", i => {
29416
+ _this6.pipeline_ && (n = !0, _this6.pipeline_.clearListeners(), _this6.pipeline_.destroy()), _this6.pipeline_ = new Ws(_this6.transformers_), _this6.pipeline_.on("warn", i => {
29414
29417
  _this6.emit("warn", i);
29415
29418
  }), _this6.pipeline_.on("error", i => {
29416
29419
  _this6.emit("error", i);
@@ -29443,7 +29446,7 @@ let ui = /*#__PURE__*/function (_J3) {
29443
29446
  _proto6.setTransformers = function setTransformers(e) {
29444
29447
  return this.report({
29445
29448
  variation: "Update",
29446
- message: be.updates.transformer_new
29449
+ message: we.updates.transformer_new
29447
29450
  }), this.transformers_ = e, this.readable_ && this.writable_ ? this.transformInternal() : Promise.resolve();
29448
29451
  }
29449
29452
  /**
@@ -29480,9 +29483,9 @@ let ui = /*#__PURE__*/function (_J3) {
29480
29483
  _proto6.isTrack = function isTrack(e) {
29481
29484
  return "kind" in e;
29482
29485
  };
29483
- return ui;
29486
+ return li;
29484
29487
  }(J);
29485
- let Ws = function Ws(_ref14) {
29488
+ let Gs = function Gs(_ref14) {
29486
29489
  let e = _ref14.kind;
29487
29490
  if (e == "video") {
29488
29491
  const t = document.createElement("canvas"),
@@ -29552,10 +29555,10 @@ let Ws = function Ws(_ref14) {
29552
29555
  }), i;
29553
29556
  }
29554
29557
  };
29555
- function Gs() {
29556
- return self.MediaStreamTrackGenerator ? self.MediaStreamTrackGenerator : Ws;
29558
+ function Vs() {
29559
+ return self.MediaStreamTrackGenerator ? self.MediaStreamTrackGenerator : Gs;
29557
29560
  }
29558
- let Vs = function Vs(e) {
29561
+ let Hs = function Hs(e) {
29559
29562
  var _e$track;
29560
29563
  const t = (_e$track = e.track) != null ? _e$track : e;
29561
29564
  t.kind == "video" ? this.readable = new ReadableStream({
@@ -29735,24 +29738,24 @@ let Vs = function Vs(e) {
29735
29738
  }
29736
29739
  }));
29737
29740
  };
29738
- function Hs() {
29739
- return self.MediaStreamTrackProcessor ? self.MediaStreamTrackProcessor : Vs;
29741
+ function js() {
29742
+ return self.MediaStreamTrackProcessor ? self.MediaStreamTrackProcessor : Hs;
29740
29743
  }
29741
- let js = /*#__PURE__*/function () {
29742
- function js() {
29744
+ let Ys = /*#__PURE__*/function () {
29745
+ function Ys() {
29743
29746
  this.processor_ = null, this.generator_ = null;
29744
29747
  }
29745
- var _proto9 = js.prototype;
29748
+ var _proto9 = Ys.prototype;
29746
29749
  _proto9.init = function init(e) {
29747
29750
  return new Promise((t, n) => {
29748
29751
  try {
29749
- const i = Hs();
29752
+ const i = js();
29750
29753
  this.processor_ = new i(e);
29751
29754
  } catch (i) {
29752
29755
  console.log(`[InsertableStreamHelper] MediaStreamTrackProcessor failed: ${i}`), n(i);
29753
29756
  }
29754
29757
  try {
29755
- const i = Gs();
29758
+ const i = Vs();
29756
29759
  e.kind === "audio" ? this.generator_ = new i({
29757
29760
  kind: "audio"
29758
29761
  }) : e.kind === "video" ? this.generator_ = new i({
@@ -29773,15 +29776,15 @@ let js = /*#__PURE__*/function () {
29773
29776
  _proto9.getProccesorTrack = function getProccesorTrack() {
29774
29777
  return this.generator_;
29775
29778
  };
29776
- return js;
29779
+ return Ys;
29777
29780
  }();
29778
- let Ys = /*#__PURE__*/function () {
29781
+ let Qs = /*#__PURE__*/function () {
29779
29782
  /**
29780
29783
  * - When running insertable streams on the main `MediaProcessorInterface` should be instance of `MediaProcessor` class.
29781
29784
  * - 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)
29782
29785
  * @param vonageMediaProcessor - MediaProcessorInterface.
29783
29786
  */
29784
- function Ys(e) {
29787
+ function Qs(e) {
29785
29788
  this.mediaProcessor_ = e;
29786
29789
  }
29787
29790
  /**
@@ -29791,7 +29794,7 @@ let Ys = /*#__PURE__*/function () {
29791
29794
  *
29792
29795
  * @returns New track to be used.
29793
29796
  */
29794
- var _proto10 = Ys.prototype;
29797
+ var _proto10 = Qs.prototype;
29795
29798
  _proto10.setTrack =
29796
29799
  /*#__PURE__*/
29797
29800
  function () {
@@ -29800,13 +29803,13 @@ let Ys = /*#__PURE__*/function () {
29800
29803
  return _regenerator.default.wrap(function _callee27$(_context27) {
29801
29804
  while (1) switch (_context27.prev = _context27.next) {
29802
29805
  case 0:
29803
- _context27.t0 = !(this.mediaProcessor_ instanceof ui);
29806
+ _context27.t0 = !(this.mediaProcessor_ instanceof li);
29804
29807
  if (!_context27.t0) {
29805
29808
  _context27.next = 5;
29806
29809
  break;
29807
29810
  }
29808
29811
  _context27.next = 4;
29809
- return si();
29812
+ return ai();
29810
29813
  case 4:
29811
29814
  _context27.t0 = _context27.sent;
29812
29815
  case 5:
@@ -29825,11 +29828,11 @@ let Ys = /*#__PURE__*/function () {
29825
29828
  case 10:
29826
29829
  return _context27.abrupt("return", _context27.sent);
29827
29830
  case 11:
29828
- if (!oi()) {
29831
+ if (!si()) {
29829
29832
  _context27.next = 18;
29830
29833
  break;
29831
29834
  }
29832
- t = new js();
29835
+ t = new Ys();
29833
29836
  _context27.next = 15;
29834
29837
  return t.init(e);
29835
29838
  case 15:
@@ -29863,17 +29866,17 @@ let Ys = /*#__PURE__*/function () {
29863
29866
  }) : t("no processor");
29864
29867
  });
29865
29868
  };
29866
- return Ys;
29869
+ return Qs;
29867
29870
  }();
29868
29871
  var It = /* @__PURE__ */(r => (r.Low = "Low", r.High = "High", r))(It || {}),
29869
- Qs = /* @__PURE__ */(r => (r.BackgroundBlur = "BackgroundBlur", r.VirtualBackground = "VirtualBackground", r.VideoBackground = "VideoBackground", r.SilhouetteBlur = "SilhouetteBlur", r))(Qs || {}),
29872
+ qs = /* @__PURE__ */(r => (r.BackgroundBlur = "BackgroundBlur", r.VirtualBackground = "VirtualBackground", r.VideoBackground = "VideoBackground", r.SilhouetteBlur = "SilhouetteBlur", r))(qs || {}),
29870
29873
  Ar = /* @__PURE__ */(r => (r.FAST = "FAST", r.PRECISE = "PRECISE", r))(Ar || {}),
29871
29874
  Mt = /* @__PURE__ */(r => (r.CANVAS = "CANVAS", r.WEBGL = "WEBGL", r))(Mt || {});
29872
29875
  exports.RenderingType = Mt;
29873
29876
  exports.WebglSelfieSegmentationType = Ar;
29874
- exports.BackgroundTransformerType = Qs;
29877
+ exports.BackgroundTransformerType = qs;
29875
29878
  exports.BlurRadius = It;
29876
- const qs = /*#__PURE__*/function () {
29879
+ const Xs = /*#__PURE__*/function () {
29877
29880
  var _ref18 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee28() {
29878
29881
  return _regenerator.default.wrap(function _callee28$(_context28) {
29879
29882
  while (1) switch (_context28.prev = _context28.next) {
@@ -29885,7 +29888,7 @@ const qs = /*#__PURE__*/function () {
29885
29888
  }
29886
29889
  }, _callee28);
29887
29890
  }));
29888
- return function qs() {
29891
+ return function Xs() {
29889
29892
  return _ref18.apply(this, arguments);
29890
29893
  };
29891
29894
  }();
@@ -29894,18 +29897,18 @@ function Bd() {
29894
29897
  }
29895
29898
  function _Bd() {
29896
29899
  _Bd = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee108() {
29897
- var _yield$Xs, r, e, t, n;
29900
+ var _yield$Ks, r, e, t, n;
29898
29901
  return _regenerator.default.wrap(function _callee108$(_context108) {
29899
29902
  while (1) switch (_context108.prev = _context108.next) {
29900
29903
  case 0:
29901
29904
  _context108.next = 2;
29902
- return Xs();
29905
+ return Ks();
29903
29906
  case 2:
29904
- _yield$Xs = _context108.sent;
29905
- r = _yield$Xs.wasm;
29906
- e = _yield$Xs.insertableStreams;
29907
- t = _yield$Xs.simd;
29908
- n = _yield$Xs.webgl;
29907
+ _yield$Ks = _context108.sent;
29908
+ r = _yield$Ks.wasm;
29909
+ e = _yield$Ks.insertableStreams;
29910
+ t = _yield$Ks.simd;
29911
+ n = _yield$Ks.webgl;
29909
29912
  if (r.supported) {
29910
29913
  _context108.next = 9;
29911
29914
  break;
@@ -29937,11 +29940,11 @@ function _Bd() {
29937
29940
  }));
29938
29941
  return _Bd.apply(this, arguments);
29939
29942
  }
29940
- function Xs() {
29941
- return _Xs.apply(this, arguments);
29943
+ function Ks() {
29944
+ return _Ks.apply(this, arguments);
29942
29945
  }
29943
- function _Xs() {
29944
- _Xs = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee109() {
29946
+ function _Ks() {
29947
+ _Ks = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee109() {
29945
29948
  var r;
29946
29949
  return _regenerator.default.wrap(function _callee109$(_context109) {
29947
29950
  while (1) switch (_context109.prev = _context109.next) {
@@ -29951,7 +29954,7 @@ function _Xs() {
29951
29954
  message: "Your browser does not support WebAssembly features."
29952
29955
  };
29953
29956
  _context109.next = 3;
29954
- return qs();
29957
+ return Xs();
29955
29958
  case 3:
29956
29959
  _context109.t1 = _context109.sent;
29957
29960
  _context109.t2 = {
@@ -29966,8 +29969,8 @@ function _Xs() {
29966
29969
  supported: !0
29967
29970
  // This is a legacy check from the previous segmentation engine. now we just return true always
29968
29971
  };
29969
- _context109.t5 = Ks();
29970
- _context109.t6 = li();
29972
+ _context109.t5 = Js();
29973
+ _context109.t6 = fi();
29971
29974
  r = {
29972
29975
  wasm: _context109.t0,
29973
29976
  simd: _context109.t2,
@@ -29978,7 +29981,7 @@ function _Xs() {
29978
29981
  };
29979
29982
  _context109.prev = 10;
29980
29983
  _context109.next = 13;
29981
- return is();
29984
+ return os();
29982
29985
  case 13:
29983
29986
  _context109.next = 18;
29984
29987
  break;
@@ -29994,9 +29997,9 @@ function _Xs() {
29994
29997
  }
29995
29998
  }, _callee109, null, [[10, 15]]);
29996
29999
  }));
29997
- return _Xs.apply(this, arguments);
30000
+ return _Ks.apply(this, arguments);
29998
30001
  }
29999
- function Ks() {
30002
+ function Js() {
30000
30003
  if (!OffscreenCanvas) return {
30001
30004
  supported: !1,
30002
30005
  message: "Your browser does not support offscreen canvas"
@@ -30013,7 +30016,7 @@ function Ks() {
30013
30016
  supported: !0
30014
30017
  };
30015
30018
  }
30016
- function li() {
30019
+ function fi() {
30017
30020
  const e = new OffscreenCanvas(0, 0).getContext("webgl2", {
30018
30021
  failIfMajorPerformanceCaveat: !0
30019
30022
  });
@@ -30038,13 +30041,13 @@ const te = /* @__PURE__ */new WeakMap(),
30038
30041
  let Lt = !1,
30039
30042
  gr = !1;
30040
30043
  const zt = r => typeof r == "string" || typeof r == "symbol" || typeof r == "number";
30041
- function Se(r) {
30044
+ function Ie(r) {
30042
30045
  if (!zt(r)) throw new TypeError("`eventName` must be a string, symbol, or number");
30043
30046
  }
30044
30047
  function mt(r) {
30045
30048
  if (typeof r != "function") throw new TypeError("listener must be a function");
30046
30049
  }
30047
- function Ie(r, e) {
30050
+ function ke(r, e) {
30048
30051
  const t = pe.get(r);
30049
30052
  if (t.has(e)) return t.get(e);
30050
30053
  }
@@ -30053,7 +30056,7 @@ function Ye(r, e) {
30053
30056
  n = X.get(r);
30054
30057
  if (n.has(t)) return n.get(t);
30055
30058
  }
30056
- function Js(r, e, t) {
30059
+ function Cn(r, e, t) {
30057
30060
  const n = X.get(r);
30058
30061
  if (n.has(e)) {
30059
30062
  for (var _iterator23 = _createForOfIteratorHelperLoose(n.get(e)), _step23; !(_step23 = _iterator23()).done;) {
@@ -30069,7 +30072,7 @@ function Js(r, e, t) {
30069
30072
  }
30070
30073
  }
30071
30074
  }
30072
- function Cn(r, e) {
30075
+ function On(r, e) {
30073
30076
  e = Array.isArray(e) ? e : [e];
30074
30077
  let t = !1,
30075
30078
  n = () => {},
@@ -30194,18 +30197,18 @@ function Cn(r, e) {
30194
30197
  }
30195
30198
  };
30196
30199
  }
30197
- function On(r) {
30198
- if (r === void 0) return Mn;
30200
+ function Mn(r) {
30201
+ if (r === void 0) return Bn;
30199
30202
  if (!Array.isArray(r)) throw new TypeError("`methodNames` must be an array of strings");
30200
30203
  for (var _iterator27 = _createForOfIteratorHelperLoose(r), _step27; !(_step27 = _iterator27()).done;) {
30201
30204
  const e = _step27.value;
30202
- if (!Mn.includes(e)) throw typeof e != "string" ? new TypeError("`methodNames` element must be a string") : new Error(`${e} is not Emittery method`);
30205
+ if (!Bn.includes(e)) throw typeof e != "string" ? new TypeError("`methodNames` element must be a string") : new Error(`${e} is not Emittery method`);
30203
30206
  }
30204
30207
  return r;
30205
30208
  }
30206
- const Be = r => r === Dt || r === Ut;
30209
+ const ge = r => r === Dt || r === Ut;
30207
30210
  function pt(r, e, t) {
30208
- if (Be(e)) try {
30211
+ if (ge(e)) try {
30209
30212
  Lt = !0, r.emit(e, t);
30210
30213
  } finally {
30211
30214
  Lt = !1;
@@ -30213,7 +30216,7 @@ function pt(r, e, t) {
30213
30216
  }
30214
30217
  let et = /*#__PURE__*/function () {
30215
30218
  Tr.mixin = function mixin(e, t) {
30216
- return t = On(t), n => {
30219
+ return t = Mn(t), n => {
30217
30220
  if (typeof n != "function") throw new TypeError("`target` must be function");
30218
30221
  for (var _iterator28 = _createForOfIteratorHelperLoose(t), _step28; !(_step28 = _iterator28()).done;) {
30219
30222
  const s = _step28.value;
@@ -30270,9 +30273,9 @@ let et = /*#__PURE__*/function () {
30270
30273
  mt(t), e = Array.isArray(e) ? e : [e];
30271
30274
  for (var _iterator30 = _createForOfIteratorHelperLoose(e), _step30; !(_step30 = _iterator30()).done;) {
30272
30275
  const o = _step30.value;
30273
- Se(o);
30274
- let s = Ie(this, o);
30275
- s || (s = /* @__PURE__ */new Set(), pe.get(this).set(o, s)), s.add(t), this.logIfDebugEnabled("subscribe", o, void 0), Be(o) || pt(this, Dt, {
30276
+ Ie(o);
30277
+ let s = ke(this, o);
30278
+ s || (s = /* @__PURE__ */new Set(), pe.get(this).set(o, s)), s.add(t), this.logIfDebugEnabled("subscribe", o, void 0), ge(o) || pt(this, Dt, {
30276
30279
  eventName: o,
30277
30280
  listener: t
30278
30281
  });
@@ -30288,9 +30291,9 @@ let et = /*#__PURE__*/function () {
30288
30291
  mt(t), e = Array.isArray(e) ? e : [e];
30289
30292
  for (var _iterator31 = _createForOfIteratorHelperLoose(e), _step31; !(_step31 = _iterator31()).done;) {
30290
30293
  const n = _step31.value;
30291
- Se(n);
30292
- const i = Ie(this, n);
30293
- i && (i.delete(t), i.size === 0 && pe.get(this).delete(n)), this.logIfDebugEnabled("unsubscribe", n, void 0), Be(n) || pt(this, Ut, {
30294
+ Ie(n);
30295
+ const i = ke(this, n);
30296
+ i && (i.delete(t), i.size === 0 && pe.get(this).delete(n)), this.logIfDebugEnabled("unsubscribe", n, void 0), ge(n) || pt(this, Ut, {
30294
30297
  eventName: n,
30295
30298
  listener: t
30296
30299
  });
@@ -30310,25 +30313,25 @@ let et = /*#__PURE__*/function () {
30310
30313
  e = Array.isArray(e) ? e : [e];
30311
30314
  for (var _iterator32 = _createForOfIteratorHelperLoose(e), _step32; !(_step32 = _iterator32()).done;) {
30312
30315
  const t = _step32.value;
30313
- Se(t);
30316
+ Ie(t);
30314
30317
  }
30315
- return Cn(this, e);
30318
+ return On(this, e);
30316
30319
  };
30317
30320
  _proto11.emit = /*#__PURE__*/function () {
30318
30321
  var _emit2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee33(e, t) {
30319
- var _Ie;
30322
+ var _ke;
30320
30323
  var n, i, o, s;
30321
30324
  return _regenerator.default.wrap(function _callee33$(_context33) {
30322
30325
  while (1) switch (_context33.prev = _context33.next) {
30323
30326
  case 0:
30324
- if (!(Se(e), Be(e) && !Lt)) {
30327
+ if (!(Ie(e), ge(e) && !Lt)) {
30325
30328
  _context33.next = 2;
30326
30329
  break;
30327
30330
  }
30328
30331
  throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");
30329
30332
  case 2:
30330
- this.logIfDebugEnabled("emit", e, t), Js(this, e, t);
30331
- n = (_Ie = Ie(this, e)) != null ? _Ie : /* @__PURE__ */new Set(), i = te.get(this), o = [...n], s = Be(e) ? [] : [...i];
30333
+ this.logIfDebugEnabled("emit", e, t), Cn(this, e, t);
30334
+ n = (_ke = ke(this, e)) != null ? _ke : /* @__PURE__ */new Set(), i = te.get(this), o = [...n], s = ge(e) ? [] : [...i];
30332
30335
  _context33.next = 6;
30333
30336
  return Fn;
30334
30337
  case 6:
@@ -30385,19 +30388,19 @@ let et = /*#__PURE__*/function () {
30385
30388
  }();
30386
30389
  _proto11.emitSerial = /*#__PURE__*/function () {
30387
30390
  var _emitSerial2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee34(e, t) {
30388
- var _Ie2;
30391
+ var _ke2;
30389
30392
  var n, i, o, s, _i5, _o3, a, _i6, _s5;
30390
30393
  return _regenerator.default.wrap(function _callee34$(_context34) {
30391
30394
  while (1) switch (_context34.prev = _context34.next) {
30392
30395
  case 0:
30393
- if (!(Se(e), Be(e) && !Lt)) {
30396
+ if (!(Ie(e), ge(e) && !Lt)) {
30394
30397
  _context34.next = 2;
30395
30398
  break;
30396
30399
  }
30397
30400
  throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");
30398
30401
  case 2:
30399
- this.logIfDebugEnabled("emitSerial", e, t);
30400
- n = (_Ie2 = Ie(this, e)) != null ? _Ie2 : /* @__PURE__ */new Set(), i = te.get(this), o = [...n], s = [...i];
30402
+ this.logIfDebugEnabled("emitSerial", e, t), Cn(this, e, t);
30403
+ n = (_ke2 = ke(this, e)) != null ? _ke2 : /* @__PURE__ */new Set(), i = te.get(this), o = [...n], s = ge(e) ? [] : [...i];
30401
30404
  _context34.next = 6;
30402
30405
  return Fn;
30403
30406
  case 6:
@@ -30463,7 +30466,7 @@ let et = /*#__PURE__*/function () {
30463
30466
  }), t != null && t.aborted && n(), n;
30464
30467
  };
30465
30468
  _proto11.anyEvent = function anyEvent() {
30466
- return Cn(this);
30469
+ return On(this);
30467
30470
  };
30468
30471
  _proto11.offAny = function offAny(e) {
30469
30472
  mt(e), this.logIfDebugEnabled("unsubscribeAny", void 0, void 0), pt(this, Ut, {
@@ -30475,7 +30478,7 @@ let et = /*#__PURE__*/function () {
30475
30478
  for (var _iterator33 = _createForOfIteratorHelperLoose(e), _step33; !(_step33 = _iterator33()).done;) {
30476
30479
  const t = _step33.value;
30477
30480
  if (this.logIfDebugEnabled("clear", t, void 0), zt(t)) {
30478
- const n = Ie(this, t);
30481
+ const n = ke(this, t);
30479
30482
  n && n.clear();
30480
30483
  const i = Ye(this, t);
30481
30484
  if (i) {
@@ -30512,11 +30515,11 @@ let et = /*#__PURE__*/function () {
30512
30515
  for (var _iterator38 = _createForOfIteratorHelperLoose(e), _step38; !(_step38 = _iterator38()).done;) {
30513
30516
  const n = _step38.value;
30514
30517
  if (zt(n)) {
30515
- var _Ie$size, _Ie3, _Ye$size, _Ye, _Ye$size2, _Ye2;
30516
- t += te.get(this).size + ((_Ie$size = (_Ie3 = Ie(this, n)) == null ? void 0 : _Ie3.size) != null ? _Ie$size : 0) + ((_Ye$size = (_Ye = Ye(this, n)) == null ? void 0 : _Ye.size) != null ? _Ye$size : 0) + ((_Ye$size2 = (_Ye2 = Ye(this)) == null ? void 0 : _Ye2.size) != null ? _Ye$size2 : 0);
30518
+ var _ke$size, _ke3, _Ye$size, _Ye, _Ye$size2, _Ye2;
30519
+ t += te.get(this).size + ((_ke$size = (_ke3 = ke(this, n)) == null ? void 0 : _ke3.size) != null ? _ke$size : 0) + ((_Ye$size = (_Ye = Ye(this, n)) == null ? void 0 : _Ye.size) != null ? _Ye$size : 0) + ((_Ye$size2 = (_Ye2 = Ye(this)) == null ? void 0 : _Ye2.size) != null ? _Ye$size2 : 0);
30517
30520
  continue;
30518
30521
  }
30519
- n !== void 0 && Se(n), t += te.get(this).size;
30522
+ n !== void 0 && Ie(n), t += te.get(this).size;
30520
30523
  for (var _iterator39 = _createForOfIteratorHelperLoose(pe.get(this).values()), _step39; !(_step39 = _iterator39()).done;) {
30521
30524
  const i = _step39.value;
30522
30525
  t += i.size;
@@ -30530,7 +30533,7 @@ let et = /*#__PURE__*/function () {
30530
30533
  };
30531
30534
  _proto11.bindMethods = function bindMethods(e, t) {
30532
30535
  if (typeof e != "object" || e === null) throw new TypeError("`target` must be an object");
30533
- t = On(t);
30536
+ t = Mn(t);
30534
30537
  for (var _iterator41 = _createForOfIteratorHelperLoose(t), _step41; !(_step41 = _iterator41()).done;) {
30535
30538
  const n = _step41.value;
30536
30539
  if (e[n] !== void 0) throw new Error(`The property \`${n}\` already exists on \`target\``);
@@ -30557,7 +30560,7 @@ let et = /*#__PURE__*/function () {
30557
30560
  }]);
30558
30561
  return Tr;
30559
30562
  }();
30560
- const Mn = Object.getOwnPropertyNames(et.prototype).filter(r => r !== "constructor");
30563
+ const Bn = Object.getOwnPropertyNames(et.prototype).filter(r => r !== "constructor");
30561
30564
  Object.defineProperty(et, "listenerAdded", {
30562
30565
  value: Dt,
30563
30566
  writable: !1,
@@ -30577,7 +30580,7 @@ function zr(r, e) {
30577
30580
  }
30578
30581
  const Le = zr("globals", {});
30579
30582
  var z = /* @__PURE__ */(r => (r.INIT = "INIT", r.FORWARD = "FORWARD", r.TERMINATE = "TERMINATE", r.GLOBALS_SYNC = "GLOBALS_SYNC", r.EVENT = "EVENT", r))(z || {});
30580
- function fi(r) {
30583
+ function di(r) {
30581
30584
  return [ImageBitmap, ReadableStream, WritableStream].some(t => r instanceof t);
30582
30585
  }
30583
30586
  let Zs = 0;
@@ -30588,7 +30591,7 @@ function Nt(r, e, t, n, i) {
30588
30591
  type: e,
30589
30592
  functionName: t,
30590
30593
  args: n
30591
- }, n.filter(a => fi(a))), new Promise(a => {
30594
+ }, n.filter(a => di(a))), new Promise(a => {
30592
30595
  i == null ? void 0 : i.set(o, a);
30593
30596
  });
30594
30597
  }
@@ -30600,7 +30603,7 @@ function ze(r, e) {
30600
30603
  id: t,
30601
30604
  type: n,
30602
30605
  result: e
30603
- }, i.filter(o => fi(o)));
30606
+ }, i.filter(o => di(o)));
30604
30607
  }
30605
30608
  const $t = zr("workerized", {});
30606
30609
  function Nr() {
@@ -30719,10 +30722,10 @@ function _ta() {
30719
30722
  return _ta.apply(this, arguments);
30720
30723
  }
30721
30724
  const re = /* @__PURE__ */new WeakMap(),
30722
- ge = /* @__PURE__ */new WeakMap(),
30725
+ ye = /* @__PURE__ */new WeakMap(),
30723
30726
  K = /* @__PURE__ */new WeakMap(),
30724
30727
  Wt = /* @__PURE__ */Symbol("anyProducer"),
30725
- Bn = Promise.resolve(),
30728
+ Dn = Promise.resolve(),
30726
30729
  Gt = /* @__PURE__ */Symbol("listenerAdded"),
30727
30730
  Vt = /* @__PURE__ */Symbol("listenerRemoved");
30728
30731
  let Ht = !1,
@@ -30733,8 +30736,8 @@ function Re(r) {
30733
30736
  function gt(r) {
30734
30737
  if (typeof r != "function") throw new TypeError("listener must be a function");
30735
30738
  }
30736
- function ke(r, e) {
30737
- const t = ge.get(r);
30739
+ function Pe(r, e) {
30740
+ const t = ye.get(r);
30738
30741
  if (t.has(e)) return t.get(e);
30739
30742
  }
30740
30743
  function Qe(r, e) {
@@ -30758,7 +30761,7 @@ function ra(r, e, t) {
30758
30761
  }
30759
30762
  }
30760
30763
  }
30761
- function Dn(r, e) {
30764
+ function Un(r, e) {
30762
30765
  e = Array.isArray(e) ? e : [e];
30763
30766
  let t = !1,
30764
30767
  n = () => {},
@@ -30883,12 +30886,12 @@ function Dn(r, e) {
30883
30886
  }
30884
30887
  };
30885
30888
  }
30886
- function Un(r) {
30887
- if (r === void 0) return Ln;
30889
+ function Ln(r) {
30890
+ if (r === void 0) return zn;
30888
30891
  if (!Array.isArray(r)) throw new TypeError("`methodNames` must be an array of strings");
30889
30892
  for (var _iterator46 = _createForOfIteratorHelperLoose(r), _step46; !(_step46 = _iterator46()).done;) {
30890
30893
  const e = _step46.value;
30891
- if (!Ln.includes(e)) throw typeof e != "string" ? new TypeError("`methodNames` element must be a string") : new Error(`${e} is not Emittery method`);
30894
+ if (!zn.includes(e)) throw typeof e != "string" ? new TypeError("`methodNames` element must be a string") : new Error(`${e} is not Emittery method`);
30892
30895
  }
30893
30896
  return r;
30894
30897
  }
@@ -30900,9 +30903,9 @@ function yt(r, e, t) {
30900
30903
  Ht = !1;
30901
30904
  }
30902
30905
  }
30903
- let ve = /*#__PURE__*/function () {
30904
- ve.mixin = function mixin(e, t) {
30905
- return t = Un(t), n => {
30906
+ let _e = /*#__PURE__*/function () {
30907
+ _e.mixin = function mixin(e, t) {
30908
+ return t = Ln(t), n => {
30906
30909
  if (typeof n != "function") throw new TypeError("`target` must be function");
30907
30910
  for (var _iterator47 = _createForOfIteratorHelperLoose(t), _step47; !(_step47 = _iterator47()).done;) {
30908
30911
  const s = _step47.value;
@@ -30911,7 +30914,7 @@ let ve = /*#__PURE__*/function () {
30911
30914
  function i() {
30912
30915
  return Object.defineProperty(this, e, {
30913
30916
  enumerable: !1,
30914
- value: new ve()
30917
+ value: new _e()
30915
30918
  }), this[e];
30916
30919
  }
30917
30920
  Object.defineProperty(n.prototype, e, {
@@ -30931,12 +30934,12 @@ let ve = /*#__PURE__*/function () {
30931
30934
  return n;
30932
30935
  };
30933
30936
  };
30934
- function ve(e) {
30937
+ function _e(e) {
30935
30938
  if (e === void 0) {
30936
30939
  e = {};
30937
30940
  }
30938
30941
  var t;
30939
- re.set(this, /* @__PURE__ */new Set()), ge.set(this, /* @__PURE__ */new Map()), K.set(this, /* @__PURE__ */new Map()), K.get(this).set(Wt, /* @__PURE__ */new Set()), this.debug = (t = e.debug) != null ? t : {}, this.debug.enabled === void 0 && (this.debug.enabled = !1), this.debug.logger || (this.debug.logger = (n, i, o, s) => {
30942
+ re.set(this, /* @__PURE__ */new Set()), ye.set(this, /* @__PURE__ */new Map()), K.set(this, /* @__PURE__ */new Map()), K.get(this).set(Wt, /* @__PURE__ */new Set()), this.debug = (t = e.debug) != null ? t : {}, this.debug.enabled === void 0 && (this.debug.enabled = !1), this.debug.logger || (this.debug.logger = (n, i, o, s) => {
30940
30943
  try {
30941
30944
  s = JSON.stringify(s);
30942
30945
  } catch (_unused11) {
@@ -30949,17 +30952,17 @@ let ve = /*#__PURE__*/function () {
30949
30952
  data: ${s}`);
30950
30953
  });
30951
30954
  }
30952
- var _proto12 = ve.prototype;
30955
+ var _proto12 = _e.prototype;
30953
30956
  _proto12.logIfDebugEnabled = function logIfDebugEnabled(e, t, n) {
30954
- (ve.isDebugEnabled || this.debug.enabled) && this.debug.logger(e, this.debug.name, t, n);
30957
+ (_e.isDebugEnabled || this.debug.enabled) && this.debug.logger(e, this.debug.name, t, n);
30955
30958
  };
30956
30959
  _proto12.on = function on(e, t) {
30957
30960
  gt(t), e = Array.isArray(e) ? e : [e];
30958
30961
  for (var _iterator49 = _createForOfIteratorHelperLoose(e), _step49; !(_step49 = _iterator49()).done;) {
30959
30962
  const n = _step49.value;
30960
30963
  Re(n);
30961
- let i = ke(this, n);
30962
- 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, {
30964
+ let i = Pe(this, n);
30965
+ i || (i = /* @__PURE__ */new Set(), ye.get(this).set(n, i)), i.add(t), this.logIfDebugEnabled("subscribe", n, void 0), De(n) || yt(this, Gt, {
30963
30966
  eventName: n,
30964
30967
  listener: t
30965
30968
  });
@@ -30971,8 +30974,8 @@ let ve = /*#__PURE__*/function () {
30971
30974
  for (var _iterator50 = _createForOfIteratorHelperLoose(e), _step50; !(_step50 = _iterator50()).done;) {
30972
30975
  const n = _step50.value;
30973
30976
  Re(n);
30974
- const i = ke(this, n);
30975
- i && (i.delete(t), i.size === 0 && ge.get(this).delete(n)), this.logIfDebugEnabled("unsubscribe", n, void 0), De(n) || yt(this, Vt, {
30977
+ const i = Pe(this, n);
30978
+ i && (i.delete(t), i.size === 0 && ye.get(this).delete(n)), this.logIfDebugEnabled("unsubscribe", n, void 0), De(n) || yt(this, Vt, {
30976
30979
  eventName: n,
30977
30980
  listener: t
30978
30981
  });
@@ -30993,7 +30996,7 @@ let ve = /*#__PURE__*/function () {
30993
30996
  const t = _step51.value;
30994
30997
  Re(t);
30995
30998
  }
30996
- return Dn(this, e);
30999
+ return Un(this, e);
30997
31000
  };
30998
31001
  _proto12.emit = /*#__PURE__*/function () {
30999
31002
  var _emit3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee39(e, t) {
@@ -31008,9 +31011,9 @@ let ve = /*#__PURE__*/function () {
31008
31011
  throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");
31009
31012
  case 2:
31010
31013
  this.logIfDebugEnabled("emit", e, t), ra(this, e, t);
31011
- i = (n = ke(this, e)) != null ? n : /* @__PURE__ */new Set(), o = re.get(this), s = [...i], a = De(e) ? [] : [...o];
31014
+ i = (n = Pe(this, e)) != null ? n : /* @__PURE__ */new Set(), o = re.get(this), s = [...i], a = De(e) ? [] : [...o];
31012
31015
  _context39.next = 6;
31013
- return Bn;
31016
+ return Dn;
31014
31017
  case 6:
31015
31018
  _context39.next = 8;
31016
31019
  return Promise.all([...s.map( /*#__PURE__*/function () {
@@ -31076,9 +31079,9 @@ let ve = /*#__PURE__*/function () {
31076
31079
  throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");
31077
31080
  case 2:
31078
31081
  this.logIfDebugEnabled("emitSerial", e, t);
31079
- i = (n = ke(this, e)) != null ? n : /* @__PURE__ */new Set(), o = re.get(this), s = [...i], a = [...o];
31082
+ i = (n = Pe(this, e)) != null ? n : /* @__PURE__ */new Set(), o = re.get(this), s = [...i], a = [...o];
31080
31083
  _context40.next = 6;
31081
- return Bn;
31084
+ return Dn;
31082
31085
  case 6:
31083
31086
  _i7 = 0, _s6 = s;
31084
31087
  case 7:
@@ -31134,7 +31137,7 @@ let ve = /*#__PURE__*/function () {
31134
31137
  }), this.offAny.bind(this, e);
31135
31138
  };
31136
31139
  _proto12.anyEvent = function anyEvent() {
31137
- return Dn(this);
31140
+ return Un(this);
31138
31141
  };
31139
31142
  _proto12.offAny = function offAny(e) {
31140
31143
  gt(e), this.logIfDebugEnabled("unsubscribeAny", void 0, void 0), yt(this, Vt, {
@@ -31146,7 +31149,7 @@ let ve = /*#__PURE__*/function () {
31146
31149
  for (var _iterator52 = _createForOfIteratorHelperLoose(e), _step52; !(_step52 = _iterator52()).done;) {
31147
31150
  const t = _step52.value;
31148
31151
  if (this.logIfDebugEnabled("clear", t, void 0), typeof t == "string" || typeof t == "symbol" || typeof t == "number") {
31149
- const n = ke(this, t);
31152
+ const n = Pe(this, t);
31150
31153
  n && n.clear();
31151
31154
  const i = Qe(this, t);
31152
31155
  if (i) {
@@ -31158,11 +31161,11 @@ let ve = /*#__PURE__*/function () {
31158
31161
  }
31159
31162
  } else {
31160
31163
  re.get(this).clear();
31161
- for (var _iterator54 = _createForOfIteratorHelperLoose(ge.get(this).entries()), _step54; !(_step54 = _iterator54()).done;) {
31164
+ for (var _iterator54 = _createForOfIteratorHelperLoose(ye.get(this).entries()), _step54; !(_step54 = _iterator54()).done;) {
31162
31165
  const _step54$value = _step54.value,
31163
31166
  n = _step54$value[0],
31164
31167
  i = _step54$value[1];
31165
- i.clear(), ge.get(this).delete(n);
31168
+ i.clear(), ye.get(this).delete(n);
31166
31169
  }
31167
31170
  for (var _iterator55 = _createForOfIteratorHelperLoose(K.get(this).entries()), _step55; !(_step55 = _iterator55()).done;) {
31168
31171
  const _step55$value = _step55.value,
@@ -31184,11 +31187,11 @@ let ve = /*#__PURE__*/function () {
31184
31187
  for (var _iterator57 = _createForOfIteratorHelperLoose(e), _step57; !(_step57 = _iterator57()).done;) {
31185
31188
  const u = _step57.value;
31186
31189
  if (typeof u == "string") {
31187
- 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);
31190
+ c += re.get(this).size + ((n = (t = Pe(this, u)) == null ? void 0 : t.size) != null ? n : 0) + ((o = (i = Qe(this, u)) == null ? void 0 : i.size) != null ? o : 0) + ((a = (s = Qe(this)) == null ? void 0 : s.size) != null ? a : 0);
31188
31191
  continue;
31189
31192
  }
31190
31193
  typeof u < "u" && Re(u), c += re.get(this).size;
31191
- for (var _iterator58 = _createForOfIteratorHelperLoose(ge.get(this).values()), _step58; !(_step58 = _iterator58()).done;) {
31194
+ for (var _iterator58 = _createForOfIteratorHelperLoose(ye.get(this).values()), _step58; !(_step58 = _iterator58()).done;) {
31192
31195
  const f = _step58.value;
31193
31196
  c += f.size;
31194
31197
  }
@@ -31201,7 +31204,7 @@ let ve = /*#__PURE__*/function () {
31201
31204
  };
31202
31205
  _proto12.bindMethods = function bindMethods(e, t) {
31203
31206
  if (typeof e != "object" || e === null) throw new TypeError("`target` must be an object");
31204
- t = Un(t);
31207
+ t = Ln(t);
31205
31208
  for (var _iterator60 = _createForOfIteratorHelperLoose(t), _step60; !(_step60 = _iterator60()).done;) {
31206
31209
  const n = _step60.value;
31207
31210
  if (e[n] !== void 0) throw new Error(`The property \`${n}\` already exists on \`target\``);
@@ -31211,7 +31214,7 @@ let ve = /*#__PURE__*/function () {
31211
31214
  });
31212
31215
  }
31213
31216
  };
31214
- (0, _createClass2.default)(ve, null, [{
31217
+ (0, _createClass2.default)(_e, null, [{
31215
31218
  key: "isDebugEnabled",
31216
31219
  get: function get() {
31217
31220
  var e, t;
@@ -31226,16 +31229,16 @@ let ve = /*#__PURE__*/function () {
31226
31229
  yr = e;
31227
31230
  }
31228
31231
  }]);
31229
- return ve;
31232
+ return _e;
31230
31233
  }();
31231
- const Ln = Object.getOwnPropertyNames(ve.prototype).filter(r => r !== "constructor");
31232
- Object.defineProperty(ve, "listenerAdded", {
31234
+ const zn = Object.getOwnPropertyNames(_e.prototype).filter(r => r !== "constructor");
31235
+ Object.defineProperty(_e, "listenerAdded", {
31233
31236
  value: Gt,
31234
31237
  writable: !1,
31235
31238
  enumerable: !0,
31236
31239
  configurable: !1
31237
31240
  });
31238
- Object.defineProperty(ve, "listenerRemoved", {
31241
+ Object.defineProperty(_e, "listenerRemoved", {
31239
31242
  value: Vt,
31240
31243
  writable: !1,
31241
31244
  enumerable: !0,
@@ -31257,7 +31260,7 @@ function _sa() {
31257
31260
  return _regenerator.default.wrap(function _callee114$(_context114) {
31258
31261
  while (1) switch (_context114.prev = _context114.next) {
31259
31262
  case 0:
31260
- i = ia(r) ? new ve() : {}, o = oa++;
31263
+ i = ia(r) ? new _e() : {}, o = oa++;
31261
31264
  return _context114.abrupt("return", (Object.getOwnPropertyNames(r.prototype).forEach(s => {
31262
31265
  i[s] = function () {
31263
31266
  for (var _len2 = arguments.length, a = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
@@ -31373,16 +31376,16 @@ function _ca() {
31373
31376
  }));
31374
31377
  return _ca.apply(this, arguments);
31375
31378
  }
31376
- const di = zr("registeredWorkers", {});
31379
+ const hi = zr("registeredWorkers", {});
31377
31380
  function ua(r, e) {
31378
- e.workerId = r, Nr() && (di[e.workerId] = e);
31381
+ e.workerId = r, Nr() && (hi[e.workerId] = e);
31379
31382
  }
31380
31383
  function la(r, e) {
31381
31384
  if (!r.args) throw "Missing className while initializing worker";
31382
31385
  const _r$args2 = r.args,
31383
31386
  t = _r$args2[0],
31384
31387
  n = _r$args2[1],
31385
- i = di[t];
31388
+ i = hi[t];
31386
31389
  if (i) e.instance = new i(r.args.slice(1));else throw `unknown worker class ${t}`;
31387
31390
  qe(n, Le), na(e.instance) && e.instance.onAny((o, s) => {
31388
31391
  ze({
@@ -31468,9 +31471,9 @@ function ha() {
31468
31471
  }();
31469
31472
  }
31470
31473
  Nr() && ha();
31471
- let zn = /*#__PURE__*/function () {
31472
- function zn() {}
31473
- zn.createVideoReadable = /*#__PURE__*/function () {
31474
+ let Nn = /*#__PURE__*/function () {
31475
+ function Nn() {}
31476
+ Nn.createVideoReadable = /*#__PURE__*/function () {
31474
31477
  var _createVideoReadable = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee42(e) {
31475
31478
  return _regenerator.default.wrap(function _callee42$(_context42) {
31476
31479
  while (1) switch (_context42.prev = _context42.next) {
@@ -31510,7 +31513,7 @@ let zn = /*#__PURE__*/function () {
31510
31513
  }
31511
31514
  return createVideoReadable;
31512
31515
  }();
31513
- zn.createImageCanvas = /*#__PURE__*/function () {
31516
+ Nn.createImageCanvas = /*#__PURE__*/function () {
31514
31517
  var _createImageCanvas = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee43(e) {
31515
31518
  var n;
31516
31519
  return _regenerator.default.wrap(function _callee43$(_context43) {
@@ -31538,7 +31541,7 @@ let zn = /*#__PURE__*/function () {
31538
31541
  }
31539
31542
  return createImageCanvas;
31540
31543
  }();
31541
- return zn;
31544
+ return Nn;
31542
31545
  }();
31543
31546
  var ma = Object.defineProperty,
31544
31547
  pa = (r, e, t) => e in r ? ma(r, e, {
@@ -31566,11 +31569,11 @@ function _a(r, e) {
31566
31569
  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();
31567
31570
  }
31568
31571
  const Ea = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto),
31569
- Nn = {
31572
+ $n = {
31570
31573
  randomUUID: Ea
31571
31574
  };
31572
31575
  function Aa(r, e, t) {
31573
- if (Nn.randomUUID && !e && !r) return Nn.randomUUID();
31576
+ if ($n.randomUUID && !e && !r) return $n.randomUUID();
31574
31577
  r = r || {};
31575
31578
  const n = r.random || (r.rng || va)();
31576
31579
  return n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128, _a(n);
@@ -31581,8 +31584,8 @@ function $r(r, e) {
31581
31584
  return t[r] || (t[r] = e), t[r];
31582
31585
  }
31583
31586
  const oe = $r("globals", {});
31584
- var we = /* @__PURE__ */(r => (r.INIT = "INIT", r.FORWARD = "FORWARD", r.TERMINATE = "TERMINATE", r.GLOBALS_SYNC = "GLOBALS_SYNC", r))(we || {});
31585
- function hi(r) {
31587
+ var xe = /* @__PURE__ */(r => (r.INIT = "INIT", r.FORWARD = "FORWARD", r.TERMINATE = "TERMINATE", r.GLOBALS_SYNC = "GLOBALS_SYNC", r))(xe || {});
31588
+ function mi(r) {
31586
31589
  return [ImageBitmap, ReadableStream, WritableStream].some(e => r instanceof e);
31587
31590
  }
31588
31591
  let Ta = 0;
@@ -31593,7 +31596,7 @@ function Sa(r, e, t, n, i) {
31593
31596
  type: e,
31594
31597
  functionName: t,
31595
31598
  args: n
31596
- }, n.filter(s => hi(s))), new Promise(s => {
31599
+ }, n.filter(s => mi(s))), new Promise(s => {
31597
31600
  i == null ? void 0 : i.set(o, s);
31598
31601
  });
31599
31602
  }
@@ -31605,10 +31608,10 @@ function tt(r, e) {
31605
31608
  id: t,
31606
31609
  type: n,
31607
31610
  result: e
31608
- }, i.filter(o => hi(o)));
31611
+ }, i.filter(o => mi(o)));
31609
31612
  }
31610
- const $n = $r("workerized", {});
31611
- function mi() {
31613
+ const Wn = $r("workerized", {});
31614
+ function pi() {
31612
31615
  return typeof WorkerGlobalScope < "u" && self instanceof WorkerGlobalScope;
31613
31616
  }
31614
31617
  function Ia() {
@@ -31616,24 +31619,24 @@ function Ia() {
31616
31619
  }
31617
31620
  function _Ia() {
31618
31621
  _Ia = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee118() {
31619
- var r, e, _$n$e$workerContext, t, n;
31622
+ var r, e, _Wn$e$workerContext, t, n;
31620
31623
  return _regenerator.default.wrap(function _callee118$(_context118) {
31621
31624
  while (1) switch (_context118.prev = _context118.next) {
31622
31625
  case 0:
31623
- if (!mi()) {
31626
+ if (!pi()) {
31624
31627
  _context118.next = 4;
31625
31628
  break;
31626
31629
  }
31627
31630
  tt({
31628
- type: we.GLOBALS_SYNC
31631
+ type: xe.GLOBALS_SYNC
31629
31632
  }, oe);
31630
31633
  _context118.next = 8;
31631
31634
  break;
31632
31635
  case 4:
31633
31636
  r = [];
31634
- for (e in $n) {
31635
- _$n$e$workerContext = $n[e].workerContext, t = _$n$e$workerContext.worker, n = _$n$e$workerContext.resolvers;
31636
- t && r.push(Sa(t, we.GLOBALS_SYNC, "", [oe], n));
31637
+ for (e in Wn) {
31638
+ _Wn$e$workerContext = Wn[e].workerContext, t = _Wn$e$workerContext.worker, n = _Wn$e$workerContext.resolvers;
31639
+ t && r.push(Sa(t, xe.GLOBALS_SYNC, "", [oe], n));
31637
31640
  }
31638
31641
  _context118.next = 8;
31639
31642
  return Promise.all(r);
@@ -31649,11 +31652,11 @@ function jt(r, e) {
31649
31652
  if (Array.isArray(e)) e.splice(0, e.length);else if (typeof e == "object") for (const t in e) delete e[t];
31650
31653
  for (const t in r) 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];
31651
31654
  }
31652
- function Ra(_x57, _x58) {
31653
- return _Ra.apply(this, arguments);
31655
+ function ka(_x57, _x58) {
31656
+ return _ka.apply(this, arguments);
31654
31657
  }
31655
- function _Ra() {
31656
- _Ra = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee119(r, e) {
31658
+ function _ka() {
31659
+ _ka = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee119(r, e) {
31657
31660
  var t, n;
31658
31661
  return _regenerator.default.wrap(function _callee119$(_context119) {
31659
31662
  while (1) switch (_context119.prev = _context119.next) {
@@ -31690,15 +31693,15 @@ function _Ra() {
31690
31693
  }
31691
31694
  }, _callee119);
31692
31695
  }));
31693
- return _Ra.apply(this, arguments);
31696
+ return _ka.apply(this, arguments);
31694
31697
  }
31695
- const ka = $r("registeredWorkers", {});
31698
+ const Ra = $r("registeredWorkers", {});
31696
31699
  function Pa(r, e) {
31697
31700
  if (!r.args) throw "Missing className while initializing worker";
31698
31701
  const _r$args3 = r.args,
31699
31702
  t = _r$args3[0],
31700
31703
  n = _r$args3[1],
31701
- i = ka[t];
31704
+ i = Ra[t];
31702
31705
  if (i) e.instance = new i(r.args.slice(1));else throw `unknown worker class ${t}`;
31703
31706
  jt(n, oe), tt(r, typeof e.instance !== void 0);
31704
31707
  }
@@ -31751,13 +31754,13 @@ function Oa() {
31751
31754
  case 0:
31752
31755
  t = e.data;
31753
31756
  _context44.t0 = t.type;
31754
- _context44.next = _context44.t0 === we.INIT ? 4 : _context44.t0 === we.FORWARD ? 6 : _context44.t0 === we.TERMINATE ? 8 : _context44.t0 === we.GLOBALS_SYNC ? 10 : 12;
31757
+ _context44.next = _context44.t0 === xe.INIT ? 4 : _context44.t0 === xe.FORWARD ? 6 : _context44.t0 === xe.TERMINATE ? 8 : _context44.t0 === xe.GLOBALS_SYNC ? 10 : 12;
31755
31758
  break;
31756
31759
  case 4:
31757
31760
  Pa(t, r);
31758
31761
  return _context44.abrupt("break", 12);
31759
31762
  case 6:
31760
- Ra(t, r);
31763
+ ka(t, r);
31761
31764
  return _context44.abrupt("break", 12);
31762
31765
  case 8:
31763
31766
  Fa(t, r);
@@ -31776,7 +31779,7 @@ function Oa() {
31776
31779
  };
31777
31780
  }();
31778
31781
  }
31779
- mi() && Oa();
31782
+ pi() && Oa();
31780
31783
  function Ma(r, e) {
31781
31784
  return oe[r] || (oe[r] = e), [() => oe[r], /*#__PURE__*/function () {
31782
31785
  var _ref29 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee45(t) {
@@ -31868,7 +31871,7 @@ let Ua = /*#__PURE__*/function () {
31868
31871
  };
31869
31872
  return Ua;
31870
31873
  }();
31871
- const La = "7.0.1";
31874
+ const La = "7.0.2";
31872
31875
  let Wr = /*#__PURE__*/function () {
31873
31876
  function Wr() {
31874
31877
  const e = new OffscreenCanvas(0, 0),
@@ -32047,9 +32050,9 @@ const Gr = 5120,
32047
32050
  Qa = 35902,
32048
32051
  qa = 36269,
32049
32052
  Xa = 34042,
32050
- pi = {};
32053
+ gi = {};
32051
32054
  {
32052
- const r = pi;
32055
+ const r = gi;
32053
32056
  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;
32054
32057
  }
32055
32058
  function qr(r) {
@@ -32062,7 +32065,7 @@ function qr(r) {
32062
32065
  if (r instanceof Float32Array) return Qr;
32063
32066
  throw new Error("unsupported typed array type");
32064
32067
  }
32065
- function gi(r) {
32068
+ function yi(r) {
32066
32069
  if (r === Int8Array) return Gr;
32067
32070
  if (r === Uint8Array || r === Uint8ClampedArray) return Xe;
32068
32071
  if (r === Int16Array) return Vr;
@@ -32072,8 +32075,8 @@ function gi(r) {
32072
32075
  if (r === Float32Array) return Qr;
32073
32076
  throw new Error("unsupported typed array type");
32074
32077
  }
32075
- function yi(r) {
32076
- const e = pi[r];
32078
+ function bi(r) {
32079
+ const e = gi[r];
32077
32080
  if (!e) throw new Error("unknown gl type");
32078
32081
  return e;
32079
32082
  }
@@ -32082,14 +32085,14 @@ const Yt = typeof SharedArrayBuffer < "u" ? function (e) {
32082
32085
  } : function (e) {
32083
32086
  return e && e.buffer && e.buffer instanceof ArrayBuffer;
32084
32087
  };
32085
- function bi() {
32088
+ function wi() {
32086
32089
  console.error(...arguments);
32087
32090
  }
32088
- const Wn = /* @__PURE__ */new Map();
32091
+ const Gn = /* @__PURE__ */new Map();
32089
32092
  function Zt(r, e) {
32090
32093
  if (!r || typeof r != "object") return !1;
32091
- let t = Wn.get(e);
32092
- t || (t = /* @__PURE__ */new WeakMap(), Wn.set(e, t));
32094
+ let t = Gn.get(e);
32095
+ t || (t = /* @__PURE__ */new WeakMap(), Gn.set(e, t));
32093
32096
  let n = t.get(r);
32094
32097
  if (n === void 0) {
32095
32098
  const i = Object.prototype.toString.call(r);
@@ -32109,8 +32112,8 @@ function Xr(r, e) {
32109
32112
  function Za(r, e) {
32110
32113
  return typeof WebGLSampler < "u" && Zt(e, "WebGLSampler");
32111
32114
  }
32112
- const wi = 35044,
32113
- xe = 34962,
32115
+ const xi = 35044,
32116
+ ve = 34962,
32114
32117
  ec = 34963,
32115
32118
  tc = 34660,
32116
32119
  rc = 5120,
@@ -32119,20 +32122,20 @@ const wi = 35044,
32119
32122
  oc = 5123,
32120
32123
  sc = 5124,
32121
32124
  ac = 5125,
32122
- xi = 5126,
32123
- vi = {
32125
+ vi = 5126,
32126
+ _i = {
32124
32127
  attribPrefix: ""
32125
32128
  };
32126
32129
  function cc(r, e, t, n, i) {
32127
- r.bindBuffer(e, t), r.bufferData(e, n, i || wi);
32130
+ r.bindBuffer(e, t), r.bufferData(e, n, i || xi);
32128
32131
  }
32129
- function _i(r, e, t, n) {
32132
+ function Ei(r, e, t, n) {
32130
32133
  if (Ka(r, e)) return e;
32131
- t = t || xe;
32134
+ t = t || ve;
32132
32135
  const i = r.createBuffer();
32133
32136
  return cc(r, t, i, e, n), i;
32134
32137
  }
32135
- function Ei(r) {
32138
+ function Ai(r) {
32136
32139
  return r === "indices";
32137
32140
  }
32138
32141
  function uc(r) {
@@ -32151,20 +32154,20 @@ function hc(r, e) {
32151
32154
  function mc(r, e, t) {
32152
32155
  return r.numComponents || r.size || hc(e, t || lc(r).length);
32153
32156
  }
32154
- function Ai(r, e) {
32157
+ function Ti(r, e) {
32155
32158
  if (Yt(r)) return r;
32156
32159
  if (Yt(r.data)) return r.data;
32157
32160
  Array.isArray(r) && (r = {
32158
32161
  data: r
32159
32162
  });
32160
32163
  let t = r.type ? Kr(r.type) : void 0;
32161
- return t || (Ei(e) ? t = Uint16Array : t = Float32Array), new t(r.data);
32164
+ return t || (Ai(e) ? t = Uint16Array : t = Float32Array), new t(r.data);
32162
32165
  }
32163
32166
  function pc(r) {
32164
- return typeof r == "number" ? r : r ? gi(r) : xi;
32167
+ return typeof r == "number" ? r : r ? yi(r) : vi;
32165
32168
  }
32166
32169
  function Kr(r) {
32167
- return typeof r == "number" ? yi(r) : r || Float32Array;
32170
+ return typeof r == "number" ? bi(r) : r || Float32Array;
32168
32171
  }
32169
32172
  function gc(r, e) {
32170
32173
  return {
@@ -32180,18 +32183,18 @@ function yc(r, e) {
32180
32183
  n = Kr(e.type),
32181
32184
  i = t * n.BYTES_PER_ELEMENT,
32182
32185
  o = r.createBuffer();
32183
- return r.bindBuffer(xe, o), r.bufferData(xe, i, e.drawType || wi), {
32186
+ return r.bindBuffer(ve, o), r.bufferData(ve, i, e.drawType || xi), {
32184
32187
  buffer: o,
32185
32188
  numValues: t,
32186
- type: gi(n),
32189
+ type: yi(n),
32187
32190
  arrayType: n
32188
32191
  };
32189
32192
  }
32190
32193
  function bc(r, e, t) {
32191
- const n = Ai(e, t);
32194
+ const n = Ti(e, t);
32192
32195
  return {
32193
32196
  arrayType: n.constructor,
32194
- buffer: _i(r, n, void 0, e.drawType),
32197
+ buffer: Ei(r, n, void 0, e.drawType),
32195
32198
  type: qr(n),
32196
32199
  numValues: 0
32197
32200
  };
@@ -32199,9 +32202,9 @@ function bc(r, e, t) {
32199
32202
  function wc(r, e) {
32200
32203
  const t = {};
32201
32204
  return Object.keys(e).forEach(function (n) {
32202
- if (!Ei(n)) {
32205
+ if (!Ai(n)) {
32203
32206
  const i = e[n],
32204
- o = i.attrib || i.name || i.attribName || vi.attribPrefix + n;
32207
+ o = i.attrib || i.name || i.attribName || _i.attribPrefix + n;
32205
32208
  if (i.value) {
32206
32209
  if (!Array.isArray(i.value) && !Yt(i.value)) throw new Error("array.value is not array or typedarray");
32207
32210
  t[o] = {
@@ -32229,21 +32232,21 @@ function wc(r, e) {
32229
32232
  };
32230
32233
  }
32231
32234
  }
32232
- }), r.bindBuffer(xe, null), t;
32235
+ }), r.bindBuffer(ve, null), t;
32233
32236
  }
32234
32237
  function xc(r, e) {
32235
- return e === rc || e === nc ? 1 : e === ic || e === oc ? 2 : e === sc || e === ac || e === xi ? 4 : 0;
32238
+ return e === rc || e === nc ? 1 : e === ic || e === oc ? 2 : e === sc || e === ac || e === vi ? 4 : 0;
32236
32239
  }
32237
32240
  const wr = ["position", "positions", "a_position"];
32238
32241
  function vc(r, e) {
32239
32242
  let t, n;
32240
- for (n = 0; n < wr.length && (t = wr[n], !(t in e || (t = vi.attribPrefix + t, t in e))); ++n);
32243
+ for (n = 0; n < wr.length && (t = wr[n], !(t in e || (t = _i.attribPrefix + t, t in e))); ++n);
32241
32244
  n === wr.length && (t = Object.keys(e)[0]);
32242
32245
  const i = e[t];
32243
32246
  if (!i.buffer) return 1;
32244
- r.bindBuffer(xe, i.buffer);
32245
- const o = r.getBufferParameter(xe, tc);
32246
- r.bindBuffer(xe, null);
32247
+ r.bindBuffer(ve, i.buffer);
32248
+ const o = r.getBufferParameter(ve, tc);
32249
+ r.bindBuffer(ve, null);
32247
32250
  const s = xc(r, i.type),
32248
32251
  a = o / s,
32249
32252
  c = i.numComponents || i.size,
@@ -32257,15 +32260,15 @@ function _c(r, e, t) {
32257
32260
  i.attribs = Object.assign({}, t ? t.attribs : {}, n);
32258
32261
  const o = e.indices;
32259
32262
  if (o) {
32260
- const s = Ai(o, "indices");
32261
- i.indices = _i(r, s, ec), i.numElements = s.length, i.elementType = qr(s);
32263
+ const s = Ti(o, "indices");
32264
+ i.indices = Ei(r, s, ec), i.numElements = s.length, i.elementType = qr(s);
32262
32265
  } else i.numElements || (i.numElements = vc(r, i.attribs));
32263
32266
  return i;
32264
32267
  }
32265
32268
  function rt(r) {
32266
32269
  return !!r.texStorage2D;
32267
32270
  }
32268
- const Ti = /* @__PURE__ */function () {
32271
+ const Si = /* @__PURE__ */function () {
32269
32272
  const r = {},
32270
32273
  e = {};
32271
32274
  function t(n) {
@@ -32288,37 +32291,37 @@ const Ti = /* @__PURE__ */function () {
32288
32291
  crossOrigin: void 0
32289
32292
  },
32290
32293
  Ke = Yt,
32291
- Si = /* @__PURE__ */function () {
32294
+ Ii = /* @__PURE__ */function () {
32292
32295
  let r;
32293
32296
  return function () {
32294
32297
  return r = r || (typeof document < "u" && document.createElement ? document.createElement("canvas").getContext("2d") : null), r;
32295
32298
  };
32296
32299
  }(),
32297
- Gn = 6406,
32300
+ Vn = 6406,
32298
32301
  j = 6407,
32299
32302
  T = 6408,
32300
- Vn = 6409,
32301
- Hn = 6410,
32303
+ Hn = 6409,
32304
+ jn = 6410,
32302
32305
  Ve = 6402,
32303
- jn = 34041,
32306
+ Yn = 34041,
32304
32307
  Qt = 33071,
32305
32308
  Ec = 9728,
32306
32309
  Ac = 9729,
32307
32310
  ce = 3553,
32308
32311
  se = 34067,
32309
- _e = 32879,
32310
- Ee = 35866,
32312
+ Ee = 32879,
32313
+ Ae = 35866,
32311
32314
  Jr = 34069,
32312
32315
  Tc = 34070,
32313
32316
  Sc = 34071,
32314
32317
  Ic = 34072,
32315
- Rc = 34073,
32316
- kc = 34074,
32318
+ kc = 34073,
32319
+ Rc = 34074,
32317
32320
  Sr = 10241,
32318
32321
  Ir = 10240,
32319
32322
  qt = 10242,
32320
32323
  Xt = 10243,
32321
- Yn = 32882,
32324
+ Qn = 32882,
32322
32325
  Pc = 33082,
32323
32326
  Fc = 33083,
32324
32327
  Cc = 33084,
@@ -32326,11 +32329,11 @@ const Ti = /* @__PURE__ */function () {
32326
32329
  Mc = 34892,
32327
32330
  Bc = 34893,
32328
32331
  Zr = 3317,
32329
- Ii = 3314,
32332
+ ki = 3314,
32330
32333
  Ri = 32878,
32331
- ki = 3316,
32332
- Pi = 3315,
32333
- Fi = 32877,
32334
+ Pi = 3316,
32335
+ Fi = 3315,
32336
+ Ci = 32877,
32334
32337
  Dc = 37443,
32335
32338
  Uc = 37441,
32336
32339
  Lc = 37440,
@@ -32377,8 +32380,8 @@ const Ti = /* @__PURE__ */function () {
32377
32380
  Tu = 34842,
32378
32381
  Su = 34836,
32379
32382
  Iu = 36220,
32380
- Ru = 36238,
32381
- ku = 36975,
32383
+ ku = 36238,
32384
+ Ru = 36975,
32382
32385
  Pu = 36214,
32383
32386
  Fu = 36232,
32384
32387
  Cu = 36226,
@@ -32391,13 +32394,13 @@ const Ti = /* @__PURE__ */function () {
32391
32394
  ne = 5120,
32392
32395
  A = 5121,
32393
32396
  wt = 5122,
32394
- Pe = 5123,
32397
+ Fe = 5123,
32395
32398
  xt = 5124,
32396
32399
  de = 5125,
32397
32400
  M = 5126,
32398
- Qn = 32819,
32399
- qn = 32820,
32400
- Xn = 33635,
32401
+ qn = 32819,
32402
+ Xn = 32820,
32403
+ Kn = 33635,
32401
32404
  G = 5131,
32402
32405
  He = 36193,
32403
32406
  xr = 33640,
@@ -32406,29 +32409,29 @@ const Ti = /* @__PURE__ */function () {
32406
32409
  $u = 36269,
32407
32410
  Wu = 34042,
32408
32411
  vt = 33319,
32409
- Fe = 33320,
32412
+ Ce = 33320,
32410
32413
  _t = 6403,
32411
- Ce = 36244,
32412
- Oe = 36248,
32414
+ Oe = 36244,
32415
+ Me = 36248,
32413
32416
  he = 36249;
32414
32417
  let vr;
32415
32418
  function er(r) {
32416
32419
  if (!vr) {
32417
32420
  const e = {};
32418
- e[Gn] = {
32419
- textureFormat: Gn,
32421
+ e[Vn] = {
32422
+ textureFormat: Vn,
32420
32423
  colorRenderable: !0,
32421
32424
  textureFilterable: !0,
32422
32425
  bytesPerElement: [1, 2, 2, 4],
32423
32426
  type: [A, G, He, M]
32424
- }, e[Vn] = {
32425
- textureFormat: Vn,
32427
+ }, e[Hn] = {
32428
+ textureFormat: Hn,
32426
32429
  colorRenderable: !0,
32427
32430
  textureFilterable: !0,
32428
32431
  bytesPerElement: [1, 2, 2, 4],
32429
32432
  type: [A, G, He, M]
32430
- }, e[Hn] = {
32431
- textureFormat: Hn,
32433
+ }, e[jn] = {
32434
+ textureFormat: jn,
32432
32435
  colorRenderable: !0,
32433
32436
  textureFilterable: !0,
32434
32437
  bytesPerElement: [2, 4, 4, 8],
@@ -32438,19 +32441,19 @@ function er(r) {
32438
32441
  colorRenderable: !0,
32439
32442
  textureFilterable: !0,
32440
32443
  bytesPerElement: [3, 6, 6, 12, 2],
32441
- type: [A, G, He, M, Xn]
32444
+ type: [A, G, He, M, Kn]
32442
32445
  }, e[T] = {
32443
32446
  textureFormat: T,
32444
32447
  colorRenderable: !0,
32445
32448
  textureFilterable: !0,
32446
32449
  bytesPerElement: [4, 8, 8, 16, 2, 2],
32447
- type: [A, G, He, M, Qn, qn]
32450
+ type: [A, G, He, M, qn, Xn]
32448
32451
  }, e[Ve] = {
32449
32452
  textureFormat: Ve,
32450
32453
  colorRenderable: !0,
32451
32454
  textureFilterable: !1,
32452
32455
  bytesPerElement: [2, 4],
32453
- type: [de, Pe]
32456
+ type: [de, Fe]
32454
32457
  }, e[zc] = {
32455
32458
  textureFormat: _t,
32456
32459
  colorRenderable: !0,
@@ -32476,37 +32479,37 @@ function er(r) {
32476
32479
  bytesPerElement: [4],
32477
32480
  type: [M]
32478
32481
  }, e[Gc] = {
32479
- textureFormat: Ce,
32482
+ textureFormat: Oe,
32480
32483
  colorRenderable: !0,
32481
32484
  textureFilterable: !1,
32482
32485
  bytesPerElement: [1],
32483
32486
  type: [A]
32484
32487
  }, e[Vc] = {
32485
- textureFormat: Ce,
32488
+ textureFormat: Oe,
32486
32489
  colorRenderable: !0,
32487
32490
  textureFilterable: !1,
32488
32491
  bytesPerElement: [1],
32489
32492
  type: [ne]
32490
32493
  }, e[tu] = {
32491
- textureFormat: Ce,
32494
+ textureFormat: Oe,
32492
32495
  colorRenderable: !0,
32493
32496
  textureFilterable: !1,
32494
32497
  bytesPerElement: [2],
32495
- type: [Pe]
32498
+ type: [Fe]
32496
32499
  }, e[ru] = {
32497
- textureFormat: Ce,
32500
+ textureFormat: Oe,
32498
32501
  colorRenderable: !0,
32499
32502
  textureFilterable: !1,
32500
32503
  bytesPerElement: [2],
32501
32504
  type: [wt]
32502
32505
  }, e[nu] = {
32503
- textureFormat: Ce,
32506
+ textureFormat: Oe,
32504
32507
  colorRenderable: !0,
32505
32508
  textureFilterable: !1,
32506
32509
  bytesPerElement: [4],
32507
32510
  type: [de]
32508
32511
  }, e[iu] = {
32509
- textureFormat: Ce,
32512
+ textureFormat: Oe,
32510
32513
  colorRenderable: !0,
32511
32514
  textureFilterable: !1,
32512
32515
  bytesPerElement: [4],
@@ -32536,37 +32539,37 @@ function er(r) {
32536
32539
  bytesPerElement: [8],
32537
32540
  type: [M]
32538
32541
  }, e[Zc] = {
32539
- textureFormat: Fe,
32542
+ textureFormat: Ce,
32540
32543
  colorRenderable: !0,
32541
32544
  textureFilterable: !1,
32542
32545
  bytesPerElement: [2],
32543
32546
  type: [A]
32544
32547
  }, e[eu] = {
32545
- textureFormat: Fe,
32548
+ textureFormat: Ce,
32546
32549
  colorRenderable: !0,
32547
32550
  textureFilterable: !1,
32548
32551
  bytesPerElement: [2],
32549
32552
  type: [ne]
32550
32553
  }, e[Hc] = {
32551
- textureFormat: Fe,
32554
+ textureFormat: Ce,
32552
32555
  colorRenderable: !0,
32553
32556
  textureFilterable: !1,
32554
32557
  bytesPerElement: [4],
32555
- type: [Pe]
32558
+ type: [Fe]
32556
32559
  }, e[jc] = {
32557
- textureFormat: Fe,
32560
+ textureFormat: Ce,
32558
32561
  colorRenderable: !0,
32559
32562
  textureFilterable: !1,
32560
32563
  bytesPerElement: [4],
32561
32564
  type: [wt]
32562
32565
  }, e[Yc] = {
32563
- textureFormat: Fe,
32566
+ textureFormat: Ce,
32564
32567
  colorRenderable: !0,
32565
32568
  textureFilterable: !1,
32566
32569
  bytesPerElement: [8],
32567
32570
  type: [de]
32568
32571
  }, e[Qc] = {
32569
- textureFormat: Fe,
32572
+ textureFormat: Ce,
32570
32573
  colorRenderable: !0,
32571
32574
  textureFilterable: !1,
32572
32575
  bytesPerElement: [8],
@@ -32588,7 +32591,7 @@ function er(r) {
32588
32591
  colorRenderable: !0,
32589
32592
  textureFilterable: !0,
32590
32593
  bytesPerElement: [3, 2],
32591
- type: [A, Xn]
32594
+ type: [A, Kn]
32592
32595
  }, e[cu] = {
32593
32596
  textureFormat: j,
32594
32597
  colorRenderable: !1,
@@ -32620,37 +32623,37 @@ function er(r) {
32620
32623
  bytesPerElement: [12],
32621
32624
  type: [M]
32622
32625
  }, e[hu] = {
32623
- textureFormat: Oe,
32626
+ textureFormat: Me,
32624
32627
  colorRenderable: !1,
32625
32628
  textureFilterable: !1,
32626
32629
  bytesPerElement: [3],
32627
32630
  type: [A]
32628
32631
  }, e[mu] = {
32629
- textureFormat: Oe,
32632
+ textureFormat: Me,
32630
32633
  colorRenderable: !1,
32631
32634
  textureFilterable: !1,
32632
32635
  bytesPerElement: [3],
32633
32636
  type: [ne]
32634
32637
  }, e[pu] = {
32635
- textureFormat: Oe,
32638
+ textureFormat: Me,
32636
32639
  colorRenderable: !1,
32637
32640
  textureFilterable: !1,
32638
32641
  bytesPerElement: [6],
32639
- type: [Pe]
32642
+ type: [Fe]
32640
32643
  }, e[gu] = {
32641
- textureFormat: Oe,
32644
+ textureFormat: Me,
32642
32645
  colorRenderable: !1,
32643
32646
  textureFilterable: !1,
32644
32647
  bytesPerElement: [6],
32645
32648
  type: [wt]
32646
32649
  }, e[yu] = {
32647
- textureFormat: Oe,
32650
+ textureFormat: Me,
32648
32651
  colorRenderable: !1,
32649
32652
  textureFilterable: !1,
32650
32653
  bytesPerElement: [12],
32651
32654
  type: [de]
32652
32655
  }, e[bu] = {
32653
- textureFormat: Oe,
32656
+ textureFormat: Me,
32654
32657
  colorRenderable: !1,
32655
32658
  textureFilterable: !1,
32656
32659
  bytesPerElement: [12],
@@ -32678,13 +32681,13 @@ function er(r) {
32678
32681
  colorRenderable: !0,
32679
32682
  textureFilterable: !0,
32680
32683
  bytesPerElement: [4, 2, 4],
32681
- type: [A, qn, xr]
32684
+ type: [A, Xn, xr]
32682
32685
  }, e[Eu] = {
32683
32686
  textureFormat: T,
32684
32687
  colorRenderable: !0,
32685
32688
  textureFilterable: !0,
32686
32689
  bytesPerElement: [4, 2],
32687
- type: [A, Qn]
32690
+ type: [A, qn]
32688
32691
  }, e[Au] = {
32689
32692
  textureFormat: T,
32690
32693
  colorRenderable: !0,
@@ -32709,13 +32712,13 @@ function er(r) {
32709
32712
  textureFilterable: !1,
32710
32713
  bytesPerElement: [4],
32711
32714
  type: [A]
32712
- }, e[Ru] = {
32715
+ }, e[ku] = {
32713
32716
  textureFormat: he,
32714
32717
  colorRenderable: !0,
32715
32718
  textureFilterable: !1,
32716
32719
  bytesPerElement: [4],
32717
32720
  type: [ne]
32718
- }, e[ku] = {
32721
+ }, e[Ru] = {
32719
32722
  textureFormat: he,
32720
32723
  colorRenderable: !0,
32721
32724
  textureFilterable: !1,
@@ -32726,7 +32729,7 @@ function er(r) {
32726
32729
  colorRenderable: !0,
32727
32730
  textureFilterable: !1,
32728
32731
  bytesPerElement: [8],
32729
- type: [Pe]
32732
+ type: [Fe]
32730
32733
  }, e[Fu] = {
32731
32734
  textureFormat: he,
32732
32735
  colorRenderable: !0,
@@ -32750,7 +32753,7 @@ function er(r) {
32750
32753
  colorRenderable: !0,
32751
32754
  textureFilterable: !1,
32752
32755
  bytesPerElement: [2, 4],
32753
- type: [Pe, de]
32756
+ type: [Fe, de]
32754
32757
  }, e[Bu] = {
32755
32758
  textureFormat: Ve,
32756
32759
  colorRenderable: !0,
@@ -32764,13 +32767,13 @@ function er(r) {
32764
32767
  bytesPerElement: [4],
32765
32768
  type: [M]
32766
32769
  }, e[Lu] = {
32767
- textureFormat: jn,
32770
+ textureFormat: Yn,
32768
32771
  colorRenderable: !0,
32769
32772
  textureFilterable: !1,
32770
32773
  bytesPerElement: [4],
32771
32774
  type: [Wu]
32772
32775
  }, e[Uu] = {
32773
- textureFormat: jn,
32776
+ textureFormat: Yn,
32774
32777
  colorRenderable: !0,
32775
32778
  textureFilterable: !1,
32776
32779
  bytesPerElement: [4],
@@ -32800,11 +32803,11 @@ function nt(r) {
32800
32803
  type: e.type[0]
32801
32804
  };
32802
32805
  }
32803
- function Kn(r) {
32806
+ function Jn(r) {
32804
32807
  return (r & r - 1) === 0;
32805
32808
  }
32806
32809
  function Vu(r, e, t, n) {
32807
- if (!rt(r)) return Kn(e) && Kn(t);
32810
+ if (!rt(r)) return Jn(e) && Jn(t);
32808
32811
  const i = er(n);
32809
32812
  if (!i) throw "unknown internal format";
32810
32813
  return i.colorRenderable && i.textureFilterable;
@@ -32833,20 +32836,20 @@ function Et(r, e, t, n, i) {
32833
32836
  function Ne(r, e) {
32834
32837
  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);
32835
32838
  }
32836
- function Ci(r) {
32837
- 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));
32839
+ function Oi(r) {
32840
+ r.pixelStorei(Zr, 4), rt(r) && (r.pixelStorei(ki, 0), r.pixelStorei(Ri, 0), r.pixelStorei(Pi, 0), r.pixelStorei(Fi, 0), r.pixelStorei(Ci, 0));
32838
32841
  }
32839
32842
  function Yu(r, e, t, n) {
32840
- 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);
32843
+ n.minMag && (t.call(r, e, Sr, n.minMag), t.call(r, e, Ir, n.minMag)), n.min && t.call(r, e, Sr, n.min), n.mag && t.call(r, e, Ir, n.mag), n.wrap && (t.call(r, e, qt, n.wrap), t.call(r, e, Xt, n.wrap), (e === Ee || Za(r, e)) && t.call(r, e, Qn, n.wrap)), n.wrapR && t.call(r, e, Qn, n.wrapR), n.wrapS && t.call(r, e, qt, n.wrapS), n.wrapT && t.call(r, e, Xt, n.wrapT), n.minLod !== void 0 && t.call(r, e, Pc, n.minLod), n.maxLod !== void 0 && t.call(r, e, Fc, n.maxLod), n.baseLevel !== void 0 && t.call(r, e, Cc, n.baseLevel), n.maxLevel !== void 0 && t.call(r, e, Oc, n.maxLevel), n.compareFunc !== void 0 && t.call(r, e, Bc, n.compareFunc), n.compareMode !== void 0 && t.call(r, e, Mc, n.compareMode);
32841
32844
  }
32842
- function Oi(r, e, t) {
32845
+ function Mi(r, e, t) {
32843
32846
  const n = t.target || ce;
32844
32847
  r.bindTexture(n, e), Yu(r, n, r.texParameteri, t);
32845
32848
  }
32846
32849
  function Qu(r) {
32847
32850
  return r = r || ae.textureColor, Ke(r) ? r : new Uint8Array([r[0] * 255, r[1] * 255, r[2] * 255, r[3] * 255]);
32848
32851
  }
32849
- function Rr(r, e, t, n, i, o) {
32852
+ function kr(r, e, t, n, i, o) {
32850
32853
  t = t || ae.textureOptions, o = o || T;
32851
32854
  const s = t.target || ce;
32852
32855
  if (n = n || t.width, i = i || t.height, r.bindTexture(s, e), Vu(r, n, i, o)) r.generateMipmap(s);else {
@@ -32857,11 +32860,11 @@ function Rr(r, e, t, n, i, o) {
32857
32860
  function Je(r) {
32858
32861
  return r.auto === !0 || r.auto === void 0 && r.level === void 0;
32859
32862
  }
32860
- function kr(r, e) {
32861
- return e = e || {}, e.cubeFaceOrder || [Jr, Tc, Sc, Ic, Rc, kc];
32863
+ function Rr(r, e) {
32864
+ return e = e || {}, e.cubeFaceOrder || [Jr, Tc, Sc, Ic, kc, Rc];
32862
32865
  }
32863
32866
  function Pr(r, e) {
32864
- const n = kr(r, e).map(function (i, o) {
32867
+ const n = Rr(r, e).map(function (i, o) {
32865
32868
  return {
32866
32869
  face: i,
32867
32870
  ndx: o
@@ -32871,7 +32874,7 @@ function Pr(r, e) {
32871
32874
  return i.face - o.face;
32872
32875
  }), n;
32873
32876
  }
32874
- function Mi(r, e, t, n) {
32877
+ function Bi(r, e, t, n) {
32875
32878
  n = n || ae.textureOptions;
32876
32879
  const i = n.target || ce,
32877
32880
  o = n.level || 0;
@@ -32886,37 +32889,37 @@ function Mi(r, e, t, n) {
32886
32889
  b = t.height;
32887
32890
  let d, g;
32888
32891
  if (p / 6 === b) d = b, g = [0, 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0];else if (b / 6 === p) d = p, g = [0, 0, 0, 1, 0, 2, 0, 3, 0, 4, 0, 5];else if (p / 3 === b / 2) d = p / 3, g = [0, 0, 1, 0, 2, 0, 0, 1, 1, 1, 2, 1];else if (p / 2 === b / 3) d = p / 2, g = [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);
32889
- const x = Si();
32892
+ const x = Ii();
32890
32893
  x ? (x.canvas.width = d, x.canvas.height = d, s = d, a = d, Pr(r, n).forEach(function (v) {
32891
- const R = g[v.ndx * 2 + 0] * d,
32892
- k = g[v.ndx * 2 + 1] * d;
32893
- x.drawImage(t, R, k, d, d, 0, 0, d, d), r.texImage2D(v.face, o, c, f, m, x.canvas);
32894
+ const k = g[v.ndx * 2 + 0] * d,
32895
+ R = g[v.ndx * 2 + 1] * d;
32896
+ x.drawImage(t, k, R, d, d, 0, 0, d, d), r.texImage2D(v.face, o, c, f, m, x.canvas);
32894
32897
  }), x.canvas.width = 1, x.canvas.height = 1) : typeof createImageBitmap < "u" && (s = d, a = d, Pr(r, n).forEach(function (v) {
32895
- const R = g[v.ndx * 2 + 0] * d,
32896
- k = g[v.ndx * 2 + 1] * d;
32897
- r.texImage2D(v.face, o, c, d, d, 0, f, m, null), createImageBitmap(t, R, k, d, d, {
32898
+ const k = g[v.ndx * 2 + 0] * d,
32899
+ R = g[v.ndx * 2 + 1] * d;
32900
+ r.texImage2D(v.face, o, c, d, d, 0, f, m, null), createImageBitmap(t, k, R, d, d, {
32898
32901
  premultiplyAlpha: "none",
32899
32902
  colorSpaceConversion: "none"
32900
32903
  }).then(function (L) {
32901
- 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);
32904
+ Ne(r, n), r.bindTexture(i, e), r.texImage2D(v.face, o, c, f, m, L), Je(n) && kr(r, e, n, s, a, c);
32902
32905
  });
32903
32906
  }));
32904
- } else if (i === _e || i === Ee) {
32907
+ } else if (i === Ee || i === Ae) {
32905
32908
  const p = Math.min(t.width, t.height),
32906
32909
  b = Math.max(t.width, t.height),
32907
32910
  d = b / p;
32908
32911
  if (d % 1 !== 0) throw "can not compute 3D dimensions of element";
32909
32912
  const g = t.width === b ? 1 : 0,
32910
32913
  x = t.height === b ? 1 : 0;
32911
- 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);
32914
+ r.pixelStorei(Zr, 1), r.pixelStorei(ki, t.width), r.pixelStorei(Ri, 0), r.pixelStorei(Ci, 0), r.texImage3D(i, o, c, p, p, p, 0, f, m, null);
32912
32915
  for (let v = 0; v < d; ++v) {
32913
- const R = v * p * g,
32914
- k = v * p * x;
32915
- r.pixelStorei(ki, R), r.pixelStorei(Pi, k), r.texSubImage3D(i, o, 0, 0, v, p, p, 1, f, m, t);
32916
+ const k = v * p * g,
32917
+ R = v * p * x;
32918
+ r.pixelStorei(Pi, k), r.pixelStorei(Fi, R), r.texSubImage3D(i, o, 0, 0, v, p, p, 1, f, m, t);
32916
32919
  }
32917
- Ci(r);
32920
+ Oi(r);
32918
32921
  } else r.texImage2D(i, o, c, f, m, t);
32919
- Je(n) && Rr(r, e, n, s, a, c), Oi(r, e, n);
32922
+ Je(n) && kr(r, e, n, s, a, c), Mi(r, e, n);
32920
32923
  }
32921
32924
  function it() {}
32922
32925
  function qu(r) {
@@ -32941,7 +32944,7 @@ function Ku(r, e, t) {
32941
32944
  },
32942
32945
  o = function o() {
32943
32946
  const c = "couldn't load image: " + r;
32944
- bi(c), t(c, n), i();
32947
+ wi(c), t(c, n), i();
32945
32948
  },
32946
32949
  s = function s() {
32947
32950
  t(null, n), i();
@@ -32969,11 +32972,11 @@ function Ku(r, e, t) {
32969
32972
  }
32970
32973
  return n;
32971
32974
  }
32972
- function Bi(r) {
32975
+ function Di(r) {
32973
32976
  return typeof ImageBitmap < "u" && r instanceof ImageBitmap || typeof ImageData < "u" && r instanceof ImageData || typeof HTMLElement < "u" && r instanceof HTMLElement;
32974
32977
  }
32975
32978
  function en(r, e, t) {
32976
- return Bi(r) ? (setTimeout(function () {
32979
+ return Di(r) ? (setTimeout(function () {
32977
32980
  t(null, r);
32978
32981
  }), r) : Ku(r, e, t);
32979
32982
  }
@@ -32982,11 +32985,11 @@ function tn(r, e, t) {
32982
32985
  const n = t.target || ce;
32983
32986
  if (r.bindTexture(n, e), t.color === !1) return;
32984
32987
  const i = Qu(t.color);
32985
- if (n === se) for (let o = 0; o < 6; ++o) r.texImage2D(Jr + o, 0, T, 1, 1, 0, T, A, i);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);
32988
+ if (n === se) for (let o = 0; o < 6; ++o) r.texImage2D(Jr + o, 0, T, 1, 1, 0, T, A, i);else n === Ee || n === Ae ? r.texImage3D(n, 0, T, 1, 1, 1, 0, T, A, i) : r.texImage2D(n, 0, T, 1, 1, 0, T, A, i);
32986
32989
  }
32987
32990
  function Ju(r, e, t, n) {
32988
32991
  return n = n || it, t = t || ae.textureOptions, tn(r, e, t), t = Object.assign({}, t), en(t.src, t.crossOrigin, function (o, s) {
32989
- o ? n(o, e, s) : (Mi(r, e, s, t), n(null, e, s));
32992
+ o ? n(o, e, s) : (Bi(r, e, s, t), n(null, e, s));
32990
32993
  });
32991
32994
  }
32992
32995
  function Zu(r, e, t, n) {
@@ -33003,13 +33006,13 @@ function Zu(r, e, t, n) {
33003
33006
  tn(r, e, t), t = Object.assign({}, t);
33004
33007
  let m = 6;
33005
33008
  const p = [],
33006
- b = kr(r, t);
33009
+ b = Rr(r, t);
33007
33010
  let d;
33008
33011
  function g(x) {
33009
- return function (v, R) {
33010
- --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) {
33011
- r.texImage2D(k, o, s, c, u, R);
33012
- }) : r.texImage2D(x, o, s, c, u, R), Je(t) && r.generateMipmap(f)), m === 0 && n(p.length ? p : void 0, e, d);
33012
+ return function (v, k) {
33013
+ --m, v ? p.push(v) : k.width !== k.height ? p.push("cubemap face img is not a square: " + k.src) : (Ne(r, t), r.bindTexture(f, e), m === 5 ? Rr().forEach(function (R) {
33014
+ r.texImage2D(R, o, s, c, u, k);
33015
+ }) : r.texImage2D(x, o, s, c, u, k), Je(t) && r.generateMipmap(f)), m === 0 && n(p.length ? p : void 0, e, d);
33013
33016
  };
33014
33017
  }
33015
33018
  d = i.map(function (x, v) {
@@ -33023,8 +33026,8 @@ function el(r, e, t, n) {
33023
33026
  s = nt(o),
33024
33027
  a = t.format || s.format,
33025
33028
  c = t.type || A,
33026
- u = t.target || Ee;
33027
- if (u !== _e && u !== Ee) throw "target must be TEXTURE_3D or TEXTURE_2D_ARRAY";
33029
+ u = t.target || Ae;
33030
+ if (u !== Ee && u !== Ae) throw "target must be TEXTURE_3D or TEXTURE_2D_ARRAY";
33028
33031
  tn(r, e, t), t = Object.assign({}, t);
33029
33032
  let f = i.length;
33030
33033
  const m = [];
@@ -33034,7 +33037,7 @@ function el(r, e, t, n) {
33034
33037
  g = t.height;
33035
33038
  const x = i.length;
33036
33039
  let v = !0;
33037
- function R(k) {
33040
+ function k(R) {
33038
33041
  return function (L, Y) {
33039
33042
  if (--f, L) m.push(L);else {
33040
33043
  if (Ne(r, t), r.bindTexture(u, e), v) {
@@ -33043,15 +33046,15 @@ function el(r, e, t, n) {
33043
33046
  } else {
33044
33047
  let Q = Y,
33045
33048
  N;
33046
- (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);
33049
+ (Y.width !== d || Y.height !== g) && (N = Ii(), Q = N.canvas, N.canvas.width = d, N.canvas.height = g, N.drawImage(Y, 0, 0, d, g)), r.texSubImage3D(u, b, 0, 0, R, d, g, 1, a, c, Q), N && Q === N.canvas && (N.canvas.width = 0, N.canvas.height = 0);
33047
33050
  }
33048
33051
  Je(t) && r.generateMipmap(u);
33049
33052
  }
33050
33053
  f === 0 && n(m.length ? m : void 0, e, p);
33051
33054
  };
33052
33055
  }
33053
- p = i.map(function (k, L) {
33054
- return en(k, t.crossOrigin, R(L));
33056
+ p = i.map(function (R, L) {
33057
+ return en(R, t.crossOrigin, k(L));
33055
33058
  });
33056
33059
  }
33057
33060
  function tl(r, e, t, n) {
@@ -33067,29 +33070,29 @@ function tl(r, e, t, n) {
33067
33070
  m = n.format || f.format,
33068
33071
  p = n.type || ju(r, t, f.type);
33069
33072
  if (Ke(t)) t instanceof Uint8ClampedArray && (t = new Uint8Array(t.buffer));else {
33070
- const x = yi(p);
33073
+ const x = bi(p);
33071
33074
  t = new x(t);
33072
33075
  }
33073
33076
  const b = Gu(u, p),
33074
33077
  d = t.byteLength / b;
33075
- if (d % 1) throw "length wrong size for format: " + Ti(r, m);
33078
+ if (d % 1) throw "length wrong size for format: " + Si(r, m);
33076
33079
  let g;
33077
- if (i === _e || i === Ee) {
33080
+ if (i === Ee || i === Ae) {
33078
33081
  if (!o && !s && !a) {
33079
33082
  const x = Math.cbrt(d);
33080
33083
  if (x % 1 !== 0) throw "can't guess cube size of array of numElements: " + d;
33081
33084
  o = x, s = x, a = x;
33082
33085
  } 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);
33083
33086
  } else g = Et(r, i, o, s, d), o = g.width, s = g.height;
33084
- if (Ci(r), r.pixelStorei(Zr, n.unpackAlignment || 1), Ne(r, n), i === se) {
33087
+ if (Oi(r), r.pixelStorei(Zr, n.unpackAlignment || 1), Ne(r, n), i === se) {
33085
33088
  const x = b / t.BYTES_PER_ELEMENT,
33086
33089
  v = d / 6 * x;
33087
- Pr(r, n).forEach(R => {
33088
- const k = v * R.ndx,
33089
- L = t.subarray(k, k + v);
33090
- r.texImage2D(R.face, c, u, o, s, 0, m, p, L);
33090
+ Pr(r, n).forEach(k => {
33091
+ const R = v * k.ndx,
33092
+ L = t.subarray(R, R + v);
33093
+ r.texImage2D(k.face, c, u, o, s, 0, m, p, L);
33091
33094
  });
33092
- } 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);
33095
+ } else i === Ee || i === Ae ? r.texImage3D(i, c, u, o, s, a, 0, m, p, t) : r.texImage2D(i, c, u, o, s, 0, m, p, t);
33093
33096
  return {
33094
33097
  width: o,
33095
33098
  height: s,
@@ -33105,9 +33108,9 @@ function rl(r, e, t) {
33105
33108
  s = nt(o),
33106
33109
  a = t.format || s.format,
33107
33110
  c = t.type || s.type;
33108
- if (Ne(r, t), n === se) for (let u = 0; u < 6; ++u) r.texImage2D(Jr + u, i, o, t.width, t.height, 0, a, c, null);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);
33111
+ if (Ne(r, t), n === se) for (let u = 0; u < 6; ++u) r.texImage2D(Jr + u, i, o, t.width, t.height, 0, a, c, null);else n === Ee || n === Ae ? r.texImage3D(n, i, o, t.width, t.height, t.depth, 0, a, c, null) : r.texImage2D(n, i, o, t.width, t.height, 0, a, c, null);
33109
33112
  }
33110
- function Di(r, e, t) {
33113
+ function Ui(r, e, t) {
33111
33114
  t = t || it, e = e || ae.textureOptions;
33112
33115
  const n = r.createTexture(),
33113
33116
  i = e.target || ce;
@@ -33120,12 +33123,12 @@ function Di(r, e, t) {
33120
33123
  if (typeof c == "function" && (c = c(r, e)), typeof c == "string") Ju(r, n, e, t);else if (Ke(c) || Array.isArray(c) && (typeof c[0] == "number" || Array.isArray(c[0]) || Ke(c[0]))) {
33121
33124
  const u = tl(r, n, c, e);
33122
33125
  o = u.width, s = u.height;
33123
- } 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);
33126
+ } else Array.isArray(c) && (typeof c[0] == "string" || Di(c[0])) ? i === se ? Zu(r, n, e, t) : el(r, n, e, t) : (Bi(r, n, c, e), o = c.width, s = c.height);
33124
33127
  } else rl(r, n, e);
33125
- return Je(e) && Rr(r, n, e, o, s, a), Oi(r, n, e), n;
33128
+ return Je(e) && kr(r, n, e, o, s, a), Mi(r, n, e), n;
33126
33129
  }
33127
- const rn = bi;
33128
- function Ui(r) {
33130
+ const rn = wi;
33131
+ function Li(r) {
33129
33132
  return typeof document < "u" && document.getElementById ? document.getElementById(r) : null;
33130
33133
  }
33131
33134
  const Kt = 33984,
@@ -33136,7 +33139,7 @@ const Kt = 33984,
33136
33139
  sl = 35632,
33137
33140
  al = 35633,
33138
33141
  cl = 35981,
33139
- Li = 35718,
33142
+ zi = 35718,
33140
33143
  ul = 35721,
33141
33144
  ll = 35971,
33142
33145
  fl = 35382,
@@ -33145,20 +33148,20 @@ const Kt = 33984,
33145
33148
  ml = 35392,
33146
33149
  pl = 35395,
33147
33150
  rr = 5126,
33148
- zi = 35664,
33149
- Ni = 35665,
33150
- $i = 35666,
33151
+ Ni = 35664,
33152
+ $i = 35665,
33153
+ Wi = 35666,
33151
33154
  nn = 5124,
33152
- Wi = 35667,
33153
- Gi = 35668,
33154
- Vi = 35669,
33155
- Hi = 35670,
33156
- ji = 35671,
33157
- Yi = 35672,
33158
- Qi = 35673,
33159
- qi = 35674,
33160
- Xi = 35675,
33161
- Ki = 35676,
33155
+ Gi = 35667,
33156
+ Vi = 35668,
33157
+ Hi = 35669,
33158
+ ji = 35670,
33159
+ Yi = 35671,
33160
+ Qi = 35672,
33161
+ qi = 35673,
33162
+ Xi = 35674,
33163
+ Ki = 35675,
33164
+ Ji = 35676,
33162
33165
  gl = 35678,
33163
33166
  yl = 35680,
33164
33167
  bl = 35679,
@@ -33171,12 +33174,12 @@ const Kt = 33984,
33171
33174
  Tl = 35690,
33172
33175
  Sl = 36289,
33173
33176
  Il = 36292,
33174
- Rl = 36293,
33177
+ kl = 36293,
33175
33178
  on = 5125,
33176
- Ji = 36294,
33177
- Zi = 36295,
33178
- eo = 36296,
33179
- kl = 36298,
33179
+ Zi = 36294,
33180
+ eo = 36295,
33181
+ to = 36296,
33182
+ Rl = 36298,
33180
33183
  Pl = 36299,
33181
33184
  Fl = 36300,
33182
33185
  Cl = 36303,
@@ -33189,7 +33192,7 @@ const Kt = 33984,
33189
33192
  sn = 32879,
33190
33193
  or = 35866,
33191
33194
  w = {};
33192
- function to(r, e) {
33195
+ function ro(r, e) {
33193
33196
  return w[e].bindPoint;
33194
33197
  }
33195
33198
  function Ul(r, e) {
@@ -33217,27 +33220,27 @@ function $l(r, e) {
33217
33220
  r.uniform4fv(e, t);
33218
33221
  };
33219
33222
  }
33220
- function ro(r, e) {
33223
+ function no(r, e) {
33221
33224
  return function (t) {
33222
33225
  r.uniform1i(e, t);
33223
33226
  };
33224
33227
  }
33225
- function no(r, e) {
33228
+ function io(r, e) {
33226
33229
  return function (t) {
33227
33230
  r.uniform1iv(e, t);
33228
33231
  };
33229
33232
  }
33230
- function io(r, e) {
33233
+ function oo(r, e) {
33231
33234
  return function (t) {
33232
33235
  r.uniform2iv(e, t);
33233
33236
  };
33234
33237
  }
33235
- function oo(r, e) {
33238
+ function so(r, e) {
33236
33239
  return function (t) {
33237
33240
  r.uniform3iv(e, t);
33238
33241
  };
33239
33242
  }
33240
- function so(r, e) {
33243
+ function ao(r, e) {
33241
33244
  return function (t) {
33242
33245
  r.uniform4iv(e, t);
33243
33246
  };
@@ -33313,7 +33316,7 @@ function tf(r, e) {
33313
33316
  };
33314
33317
  }
33315
33318
  function D(r, e, t, n) {
33316
- const i = to(r, e);
33319
+ const i = ro(r, e);
33317
33320
  return rt(r) ? function (o) {
33318
33321
  let s, a;
33319
33322
  !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);
@@ -33322,7 +33325,7 @@ function D(r, e, t, n) {
33322
33325
  };
33323
33326
  }
33324
33327
  function U(r, e, t, n, i) {
33325
- const o = to(r, e),
33328
+ const o = ro(r, e),
33326
33329
  s = new Int32Array(i);
33327
33330
  for (let a = 0; a < i; ++a) s[a] = t + a;
33328
33331
  return rt(r) ? function (a) {
@@ -33343,19 +33346,19 @@ w[rr] = {
33343
33346
  setter: Ul,
33344
33347
  arraySetter: Ll
33345
33348
  };
33346
- w[zi] = {
33349
+ w[Ni] = {
33347
33350
  Type: Float32Array,
33348
33351
  size: 8,
33349
33352
  setter: zl,
33350
33353
  cols: 2
33351
33354
  };
33352
- w[Ni] = {
33355
+ w[$i] = {
33353
33356
  Type: Float32Array,
33354
33357
  size: 12,
33355
33358
  setter: Nl,
33356
33359
  cols: 3
33357
33360
  };
33358
- w[$i] = {
33361
+ w[Wi] = {
33359
33362
  Type: Float32Array,
33360
33363
  size: 16,
33361
33364
  setter: $l,
@@ -33364,25 +33367,25 @@ w[$i] = {
33364
33367
  w[nn] = {
33365
33368
  Type: Int32Array,
33366
33369
  size: 4,
33367
- setter: ro,
33368
- arraySetter: no
33370
+ setter: no,
33371
+ arraySetter: io
33369
33372
  };
33370
- w[Wi] = {
33373
+ w[Gi] = {
33371
33374
  Type: Int32Array,
33372
33375
  size: 8,
33373
- setter: io,
33376
+ setter: oo,
33374
33377
  cols: 2
33375
33378
  };
33376
- w[Gi] = {
33379
+ w[Vi] = {
33377
33380
  Type: Int32Array,
33378
33381
  size: 12,
33379
- setter: oo,
33382
+ setter: so,
33380
33383
  cols: 3
33381
33384
  };
33382
- w[Vi] = {
33385
+ w[Hi] = {
33383
33386
  Type: Int32Array,
33384
33387
  size: 16,
33385
- setter: so,
33388
+ setter: ao,
33386
33389
  cols: 4
33387
33390
  };
33388
33391
  w[on] = {
@@ -33391,63 +33394,63 @@ w[on] = {
33391
33394
  setter: Wl,
33392
33395
  arraySetter: Gl
33393
33396
  };
33394
- w[Ji] = {
33397
+ w[Zi] = {
33395
33398
  Type: Uint32Array,
33396
33399
  size: 8,
33397
33400
  setter: Vl,
33398
33401
  cols: 2
33399
33402
  };
33400
- w[Zi] = {
33403
+ w[eo] = {
33401
33404
  Type: Uint32Array,
33402
33405
  size: 12,
33403
33406
  setter: Hl,
33404
33407
  cols: 3
33405
33408
  };
33406
- w[eo] = {
33409
+ w[to] = {
33407
33410
  Type: Uint32Array,
33408
33411
  size: 16,
33409
33412
  setter: jl,
33410
33413
  cols: 4
33411
33414
  };
33412
- w[Hi] = {
33415
+ w[ji] = {
33413
33416
  Type: Uint32Array,
33414
33417
  size: 4,
33415
- setter: ro,
33416
- arraySetter: no
33418
+ setter: no,
33419
+ arraySetter: io
33417
33420
  };
33418
- w[ji] = {
33421
+ w[Yi] = {
33419
33422
  Type: Uint32Array,
33420
33423
  size: 8,
33421
- setter: io,
33424
+ setter: oo,
33422
33425
  cols: 2
33423
33426
  };
33424
- w[Yi] = {
33427
+ w[Qi] = {
33425
33428
  Type: Uint32Array,
33426
33429
  size: 12,
33427
- setter: oo,
33430
+ setter: so,
33428
33431
  cols: 3
33429
33432
  };
33430
- w[Qi] = {
33433
+ w[qi] = {
33431
33434
  Type: Uint32Array,
33432
33435
  size: 16,
33433
- setter: so,
33436
+ setter: ao,
33434
33437
  cols: 4
33435
33438
  };
33436
- w[qi] = {
33439
+ w[Xi] = {
33437
33440
  Type: Float32Array,
33438
33441
  size: 32,
33439
33442
  setter: Yl,
33440
33443
  rows: 2,
33441
33444
  cols: 2
33442
33445
  };
33443
- w[Xi] = {
33446
+ w[Ki] = {
33444
33447
  Type: Float32Array,
33445
33448
  size: 48,
33446
33449
  setter: Ql,
33447
33450
  rows: 3,
33448
33451
  cols: 3
33449
33452
  };
33450
- w[Ki] = {
33453
+ w[Ji] = {
33451
33454
  Type: Float32Array,
33452
33455
  size: 64,
33453
33456
  setter: ql,
@@ -33538,14 +33541,14 @@ w[Il] = {
33538
33541
  arraySetter: U,
33539
33542
  bindPoint: or
33540
33543
  };
33541
- w[Rl] = {
33544
+ w[kl] = {
33542
33545
  Type: null,
33543
33546
  size: 0,
33544
33547
  setter: D,
33545
33548
  arraySetter: U,
33546
33549
  bindPoint: ir
33547
33550
  };
33548
- w[kl] = {
33551
+ w[Rl] = {
33549
33552
  Type: null,
33550
33553
  size: 0,
33551
33554
  setter: D,
@@ -33655,15 +33658,15 @@ I[rr] = {
33655
33658
  size: 4,
33656
33659
  setter: sr
33657
33660
  };
33658
- I[zi] = {
33661
+ I[Ni] = {
33659
33662
  size: 8,
33660
33663
  setter: sr
33661
33664
  };
33662
- I[Ni] = {
33665
+ I[$i] = {
33663
33666
  size: 12,
33664
33667
  setter: sr
33665
33668
  };
33666
- I[$i] = {
33669
+ I[Wi] = {
33667
33670
  size: 16,
33668
33671
  setter: sr
33669
33672
  };
@@ -33671,15 +33674,15 @@ I[nn] = {
33671
33674
  size: 4,
33672
33675
  setter: ue
33673
33676
  };
33674
- I[Wi] = {
33677
+ I[Gi] = {
33675
33678
  size: 8,
33676
33679
  setter: ue
33677
33680
  };
33678
- I[Gi] = {
33681
+ I[Vi] = {
33679
33682
  size: 12,
33680
33683
  setter: ue
33681
33684
  };
33682
- I[Vi] = {
33685
+ I[Hi] = {
33683
33686
  size: 16,
33684
33687
  setter: ue
33685
33688
  };
@@ -33687,45 +33690,45 @@ I[on] = {
33687
33690
  size: 4,
33688
33691
  setter: ar
33689
33692
  };
33690
- I[Ji] = {
33693
+ I[Zi] = {
33691
33694
  size: 8,
33692
33695
  setter: ar
33693
33696
  };
33694
- I[Zi] = {
33697
+ I[eo] = {
33695
33698
  size: 12,
33696
33699
  setter: ar
33697
33700
  };
33698
- I[eo] = {
33701
+ I[to] = {
33699
33702
  size: 16,
33700
33703
  setter: ar
33701
33704
  };
33702
- I[Hi] = {
33705
+ I[ji] = {
33703
33706
  size: 4,
33704
33707
  setter: ue
33705
33708
  };
33706
- I[ji] = {
33709
+ I[Yi] = {
33707
33710
  size: 8,
33708
33711
  setter: ue
33709
33712
  };
33710
- I[Yi] = {
33713
+ I[Qi] = {
33711
33714
  size: 12,
33712
33715
  setter: ue
33713
33716
  };
33714
- I[Qi] = {
33717
+ I[qi] = {
33715
33718
  size: 16,
33716
33719
  setter: ue
33717
33720
  };
33718
- I[qi] = {
33721
+ I[Xi] = {
33719
33722
  size: 4,
33720
33723
  setter: an,
33721
33724
  count: 2
33722
33725
  };
33723
- I[Xi] = {
33726
+ I[Ki] = {
33724
33727
  size: 9,
33725
33728
  setter: an,
33726
33729
  count: 3
33727
33730
  };
33728
- I[Ki] = {
33731
+ I[Ji] = {
33729
33732
  size: 16,
33730
33733
  setter: an,
33731
33734
  count: 4
@@ -33755,10 +33758,10 @@ function nf(r, e, t) {
33755
33758
  }).join(`
33756
33759
  `);
33757
33760
  }
33758
- const Jn = /^[ \t]*\n/;
33759
- function ao(r) {
33761
+ const Zn = /^[ \t]*\n/;
33762
+ function co(r) {
33760
33763
  let e = 0;
33761
- return Jn.test(r) && (e = 1, r = r.replace(Jn, "")), {
33764
+ return Zn.test(r) && (e = 1, r = r.replace(Zn, "")), {
33762
33765
  lineOffset: e,
33763
33766
  shaderSource: r
33764
33767
  };
@@ -33773,11 +33776,11 @@ ${r.errors.join(`
33773
33776
  function sf(r, e, t, n) {
33774
33777
  if (n = n || rn, !r.getShaderParameter(t, il)) {
33775
33778
  const o = r.getShaderInfoLog(t),
33776
- _ao = ao(r.getShaderSource(t)),
33777
- s = _ao.lineOffset,
33778
- a = _ao.shaderSource,
33779
+ _co = co(r.getShaderSource(t)),
33780
+ s = _co.lineOffset,
33781
+ a = _co.shaderSource,
33779
33782
  c = `${nf(a, o, s)}
33780
- Error compiling ${Ti(r, e)}: ${o}`;
33783
+ Error compiling ${Si(r, e)}: ${o}`;
33781
33784
  return n(c), c;
33782
33785
  }
33783
33786
  return "";
@@ -33838,10 +33841,10 @@ function ff(r, e, t) {
33838
33841
  for (let a = 0; a < e.length; ++a) {
33839
33842
  let c = e[a];
33840
33843
  if (typeof c == "string") {
33841
- const u = Ui(c),
33844
+ const u = Li(c),
33842
33845
  f = u ? u.text : c;
33843
33846
  let m = r[af[a]];
33844
- 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);
33847
+ u && u.type && (m = cf(r, u.type) || m), c = r.createShader(m), r.shaderSource(c, co(f).shaderSource), r.compileShader(c), r.attachShader(n, c);
33845
33848
  }
33846
33849
  }
33847
33850
  Object.entries(i).forEach(_ref30 => {
@@ -33914,7 +33917,7 @@ ${s.filter(a => a).join(`
33914
33917
  function pf(r, e, t, n, i) {
33915
33918
  return df(r, e, t, n, i);
33916
33919
  }
33917
- function co(r) {
33920
+ function uo(r) {
33918
33921
  const e = r.name;
33919
33922
  return e.startsWith("gl_") || e.startsWith("webgl_");
33920
33923
  }
@@ -33938,7 +33941,7 @@ function bf(r, e, t, n) {
33938
33941
  b = t[u] || (p ? [] : {});
33939
33942
  t[u] = b, t = b, n[s] = n[s] || /* @__PURE__ */function (d) {
33940
33943
  return function (g) {
33941
- uo(d, g);
33944
+ lo(d, g);
33942
33945
  };
33943
33946
  }(b), s += m;
33944
33947
  }
@@ -33960,10 +33963,10 @@ function wf(r, e) {
33960
33963
  }
33961
33964
  const i = {},
33962
33965
  o = {},
33963
- s = r.getProgramParameter(e, Li);
33966
+ s = r.getProgramParameter(e, zi);
33964
33967
  for (let a = 0; a < s; ++a) {
33965
33968
  const c = r.getActiveUniform(e, a);
33966
- if (co(c)) continue;
33969
+ if (uo(c)) continue;
33967
33970
  let u = c.name;
33968
33971
  u.endsWith("[0]") && (u = u.substr(0, u.length - 3));
33969
33972
  const f = r.getUniformLocation(e, c.name);
@@ -33988,7 +33991,7 @@ function xf(r, e) {
33988
33991
  return t;
33989
33992
  }
33990
33993
  function vf(r, e) {
33991
- const t = r.getProgramParameter(e, Li),
33994
+ const t = r.getProgramParameter(e, zi),
33992
33995
  n = [],
33993
33996
  i = [];
33994
33997
  for (let a = 0; a < t; ++a) {
@@ -34023,20 +34026,20 @@ function vf(r, e) {
34023
34026
  uniformData: n
34024
34027
  };
34025
34028
  }
34026
- function uo(r, e) {
34029
+ function lo(r, e) {
34027
34030
  for (const t in e) {
34028
34031
  const n = r[t];
34029
- typeof n == "function" ? n(e[t]) : uo(r[t], e[t]);
34032
+ typeof n == "function" ? n(e[t]) : lo(r[t], e[t]);
34030
34033
  }
34031
34034
  }
34032
- function lo(r) {
34035
+ function fo(r) {
34033
34036
  const t = r.uniformSetters || r,
34034
34037
  n = arguments.length <= 1 ? 0 : arguments.length - 1;
34035
34038
  for (let i = 0; i < n; ++i) {
34036
34039
  const o = i + 1 < 1 || arguments.length <= i + 1 ? undefined : arguments[i + 1];
34037
34040
  if (Array.isArray(o)) {
34038
34041
  const s = o.length;
34039
- for (let a = 0; a < s; ++a) lo(t, o[a]);
34042
+ for (let a = 0; a < s; ++a) fo(t, o[a]);
34040
34043
  } else for (const s in o) {
34041
34044
  const a = t[s];
34042
34045
  a && a(o[s]);
@@ -34048,7 +34051,7 @@ function _f(r, e) {
34048
34051
  n = r.getProgramParameter(e, ul);
34049
34052
  for (let i = 0; i < n; ++i) {
34050
34053
  const o = r.getActiveAttrib(e, i);
34051
- if (co(o)) continue;
34054
+ if (uo(o)) continue;
34052
34055
  const s = r.getAttribLocation(e, o.name),
34053
34056
  a = I[o.type],
34054
34057
  c = a.setter(r, s, a);
@@ -34065,7 +34068,7 @@ function Ef(r, e) {
34065
34068
  function Af(r, e, t) {
34066
34069
  t.vertexArrayObject ? r.bindVertexArray(t.vertexArrayObject) : (Ef(e.attribSetters || e, t.attribs), t.indices && r.bindBuffer(nl, t.indices));
34067
34070
  }
34068
- function Zn(r, e) {
34071
+ function ei(r, e) {
34069
34072
  const t = wf(r, e),
34070
34073
  n = _f(r, e),
34071
34074
  i = {
@@ -34081,7 +34084,7 @@ function Sf(r, e, t, n, i) {
34081
34084
  s = [];
34082
34085
  if (e = e.map(function (u) {
34083
34086
  if (!Tf.test(u)) {
34084
- const f = Ui(u);
34087
+ const f = Li(u);
34085
34088
  if (f) u = f.text;else {
34086
34089
  const m = `no element with id: ${u}`;
34087
34090
  o.errorCallback(m), s.push(m);
@@ -34091,23 +34094,23 @@ function Sf(r, e, t, n, i) {
34091
34094
  }), s.length) return of(o, "");
34092
34095
  const a = o.callback;
34093
34096
  a && (o.callback = (u, f) => {
34094
- a(u, u ? void 0 : Zn(r, f));
34097
+ a(u, u ? void 0 : ei(r, f));
34095
34098
  });
34096
34099
  const c = pf(r, e, o);
34097
- return c ? Zn(r, c) : null;
34100
+ return c ? ei(r, c) : null;
34098
34101
  }
34099
34102
  const If = 4,
34100
- ei = 5123;
34101
- function Rf(r, e, t, n, i, o) {
34103
+ ti = 5123;
34104
+ function kf(r, e, t, n, i, o) {
34102
34105
  t = t === void 0 ? If : t;
34103
34106
  const s = e.indices,
34104
34107
  a = e.elementType,
34105
34108
  c = n === void 0 ? e.numElements : n;
34106
- 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);
34109
+ i = i === void 0 ? 0 : i, a || s ? o !== void 0 ? r.drawElementsInstanced(t, c, a === void 0 ? ti : e.elementType, i, o) : r.drawElements(t, c, a === void 0 ? ti : e.elementType, i) : o !== void 0 ? r.drawArraysInstanced(t, i, c, o) : r.drawArrays(t, i, c);
34107
34110
  }
34108
- const fo = 36160,
34111
+ const ho = 36160,
34109
34112
  At = 36161,
34110
- kf = 3553,
34113
+ Rf = 3553,
34111
34114
  Pf = 5121,
34112
34115
  Ff = 6402,
34113
34116
  Cf = 6408,
@@ -34118,13 +34121,13 @@ const fo = 36160,
34118
34121
  Uf = 32854,
34119
34122
  Lf = 32855,
34120
34123
  zf = 36194,
34121
- ho = 33189,
34122
- mo = 6401,
34123
- po = 36168,
34124
+ mo = 33189,
34125
+ po = 6401,
34126
+ go = 36168,
34124
34127
  un = 34041,
34125
34128
  Fr = 36064,
34126
34129
  cr = 36096,
34127
- go = 36128,
34130
+ yo = 36128,
34128
34131
  ln = 33306,
34129
34132
  Cr = 33071,
34130
34133
  Or = 9729,
@@ -34138,10 +34141,10 @@ const fo = 36160,
34138
34141
  }],
34139
34142
  V = {};
34140
34143
  V[un] = ln;
34141
- V[mo] = go;
34142
- V[po] = go;
34144
+ V[po] = yo;
34145
+ V[go] = yo;
34143
34146
  V[Ff] = cr;
34144
- V[ho] = cr;
34147
+ V[mo] = cr;
34145
34148
  V[Of] = cr;
34146
34149
  V[Mf] = cr;
34147
34150
  V[Bf] = ln;
@@ -34154,9 +34157,9 @@ le[Uf] = !0;
34154
34157
  le[Lf] = !0;
34155
34158
  le[zf] = !0;
34156
34159
  le[un] = !0;
34157
- le[ho] = !0;
34158
34160
  le[mo] = !0;
34159
34161
  le[po] = !0;
34162
+ le[go] = !0;
34160
34163
  function Wf(r) {
34161
34164
  return le[r];
34162
34165
  }
@@ -34164,8 +34167,8 @@ const Gf = 32;
34164
34167
  function Vf(r) {
34165
34168
  return r >= Fr && r < Fr + Gf;
34166
34169
  }
34167
- function ti(r, e, t, n) {
34168
- const i = fo,
34170
+ function ri(r, e, t, n) {
34171
+ const i = ho,
34169
34172
  o = r.createFramebuffer();
34170
34173
  r.bindFramebuffer(i, o), t = t || r.drawingBufferWidth, n = n || r.drawingBufferHeight, e = e || Nf;
34171
34174
  const s = [],
@@ -34182,17 +34185,17 @@ function ti(r, e, t, n) {
34182
34185
  let b = c.attachmentPoint || $f(p, c.internalFormat);
34183
34186
  if (b || (b = Fr + u), Vf(b) && s.push(b), !f) if (m !== void 0 || Wf(p)) f = r.createRenderbuffer(), r.bindRenderbuffer(At, f), m > 1 ? r.renderbufferStorageMultisample(At, m, p, t, n) : r.renderbufferStorage(At, p, t, n);else {
34184
34187
  const d = Object.assign({}, c);
34185
- 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);
34188
+ d.width = t, d.height = n, d.auto === void 0 && (d.auto = !1, d.min = d.min || d.minMag || Or, d.mag = d.mag || d.minMag || Or, d.wrapS = d.wrapS || d.wrap || Cr, d.wrapT = d.wrapT || d.wrap || Cr), f = Ui(r, d);
34186
34189
  }
34187
- if (Ja(r, f)) r.framebufferRenderbuffer(i, b, At, f);else if (Xr(r, f)) c.layer !== void 0 ? r.framebufferTextureLayer(i, b, f, c.level || 0, c.layer) : r.framebufferTexture2D(i, b, c.target || kf, f, c.level || 0);else throw new Error("unknown attachment type");
34190
+ if (Ja(r, f)) r.framebufferRenderbuffer(i, b, At, f);else if (Xr(r, f)) c.layer !== void 0 ? r.framebufferTextureLayer(i, b, f, c.level || 0, c.layer) : r.framebufferTexture2D(i, b, c.target || Rf, f, c.level || 0);else throw new Error("unknown attachment type");
34188
34191
  a.attachments.push(f);
34189
34192
  }), r.drawBuffers && r.drawBuffers(s), a;
34190
34193
  }
34191
34194
  function Hf(r, e, t) {
34192
- 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));
34195
+ t = t || ho, e ? (r.bindFramebuffer(t, e.framebuffer), r.viewport(0, 0, e.width, e.height)) : (r.bindFramebuffer(t, null), r.viewport(0, 0, r.drawingBufferWidth, r.drawingBufferHeight));
34193
34196
  }
34194
34197
  function B(r, e) {
34195
- return () => e instanceof WebGLTexture ? e : Di(r, {
34198
+ return () => e instanceof WebGLTexture ? e : Ui(r, {
34196
34199
  src: e,
34197
34200
  wrap: r.CLAMP_TO_EDGE
34198
34201
  });
@@ -34206,7 +34209,7 @@ let ot = /*#__PURE__*/function () {
34206
34209
  i = e.height;
34207
34210
  this.context = t, this.options = e;
34208
34211
  const o = this.buildDefines();
34209
- this.programInfo = Sf(this.context, [o + this.getVertexShader(), o + this.getFragmentShader()]), this.bufferInfo = _c(this.context, this.getBuffers()), this.fbi = ti(this.context, [{
34212
+ this.programInfo = Sf(this.context, [o + this.getVertexShader(), o + this.getFragmentShader()]), this.bufferInfo = _c(this.context, this.getBuffers()), this.fbi = ri(this.context, [{
34210
34213
  format: this.context.RGBA,
34211
34214
  type: this.context.UNSIGNED_BYTE,
34212
34215
  min: this.context.LINEAR,
@@ -34215,7 +34218,7 @@ let ot = /*#__PURE__*/function () {
34215
34218
  }
34216
34219
  var _proto18 = ot.prototype;
34217
34220
  _proto18.resizeOutput = function resizeOutput(e, t) {
34218
- this.fbi = ti(this.context, [{
34221
+ this.fbi = ri(this.context, [{
34219
34222
  format: this.context.RGBA,
34220
34223
  type: this.context.UNSIGNED_BYTE,
34221
34224
  min: this.context.LINEAR,
@@ -34271,10 +34274,10 @@ let ot = /*#__PURE__*/function () {
34271
34274
  (_this$profiler5 = this.profiler) == null ? void 0 : _this$profiler5.popContext(`[${this.id}] UNIFORMS`);
34272
34275
  const t = Date.now();
34273
34276
  let n = 0;
34274
- 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), Af(this.context, this.programInfo, this.bufferInfo), lo(this.programInfo, Object.assign({
34277
+ 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), Af(this.context, this.programInfo, this.bufferInfo), fo(this.programInfo, Object.assign({
34275
34278
  delta: n,
34276
34279
  canvas: [this.context.canvas.width, this.context.canvas.height]
34277
- }, e)), Hf(this.context, this.options.disableFramebuffer ? null : this.fbi), Rf(this.context, this.bufferInfo), (_this$profiler6 = this.profiler) == null ? void 0 : _this$profiler6.popContext(`[${this.id}] PROG : ${this.constructor.name}`);
34280
+ }, e)), Hf(this.context, this.options.disableFramebuffer ? null : this.fbi), kf(this.context, this.bufferInfo), (_this$profiler6 = this.profiler) == null ? void 0 : _this$profiler6.popContext(`[${this.id}] PROG : ${this.constructor.name}`);
34278
34281
  };
34279
34282
  _proto18.setProfiler = function setProfiler(e) {
34280
34283
  this.profiler = e;
@@ -34393,9 +34396,9 @@ let hn = /*#__PURE__*/function (_dn) {
34393
34396
  }
34394
34397
  return hn;
34395
34398
  }(dn);
34396
- let yo = /*#__PURE__*/function (_hn) {
34397
- (0, _inheritsLoose2.default)(yo, _hn);
34398
- function yo(e) {
34399
+ let bo = /*#__PURE__*/function (_hn) {
34400
+ (0, _inheritsLoose2.default)(bo, _hn);
34401
+ function bo(e) {
34399
34402
  var _this19;
34400
34403
  _this19 = _hn.call(this) || this, _this19.context = e, _this19.preciseMaskEnabled = !0;
34401
34404
  const t = {
@@ -34416,11 +34419,11 @@ let yo = /*#__PURE__*/function (_hn) {
34416
34419
  });
34417
34420
  return _this19;
34418
34421
  }
34419
- var _proto21 = yo.prototype;
34422
+ var _proto21 = bo.prototype;
34420
34423
  _proto21.setData = function setData(e, t) {
34421
34424
  this.inputImage = e, this.inputMask = t;
34422
34425
  };
34423
- return yo;
34426
+ return bo;
34424
34427
  }(hn);
34425
34428
  const Qf = `precision mediump float;
34426
34429
 
@@ -34484,11 +34487,11 @@ let Kf = /*#__PURE__*/function (_dn2) {
34484
34487
  };
34485
34488
  return Kf;
34486
34489
  }(dn);
34487
- function bo(_x75) {
34488
- return _bo.apply(this, arguments);
34490
+ function wo(_x75) {
34491
+ return _wo.apply(this, arguments);
34489
34492
  }
34490
- function _bo() {
34491
- _bo = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee122(r) {
34493
+ function _wo() {
34494
+ _wo = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee122(r) {
34492
34495
  return _regenerator.default.wrap(function _callee122$(_context122) {
34493
34496
  while (1) switch (_context122.prev = _context122.next) {
34494
34497
  case 0:
@@ -34503,7 +34506,7 @@ function _bo() {
34503
34506
  }
34504
34507
  }, _callee122);
34505
34508
  }));
34506
- return _bo.apply(this, arguments);
34509
+ return _wo.apply(this, arguments);
34507
34510
  }
34508
34511
  const Jf = `precision mediump float;
34509
34512
 
@@ -34527,12 +34530,12 @@ void main() {
34527
34530
  }
34528
34531
  `;
34529
34532
  var mn = /* @__PURE__ */(r => (r[r.LINEAR = 0] = "LINEAR", r[r.GAUSSIAN = 1] = "GAUSSIAN", r))(mn || {});
34530
- let wo = /*#__PURE__*/function (_ot3) {
34531
- (0, _inheritsLoose2.default)(wo, _ot3);
34532
- function wo() {
34533
+ let xo = /*#__PURE__*/function (_ot3) {
34534
+ (0, _inheritsLoose2.default)(xo, _ot3);
34535
+ function xo() {
34533
34536
  return _ot3.apply(this, arguments) || this;
34534
34537
  }
34535
- var _proto24 = wo.prototype;
34538
+ var _proto24 = xo.prototype;
34536
34539
  _proto24.getDefines = function getDefines() {
34537
34540
  var _this$options$radius;
34538
34541
  return {
@@ -34571,7 +34574,7 @@ let wo = /*#__PURE__*/function (_ot3) {
34571
34574
  return result / factorSum;
34572
34575
  }`;
34573
34576
  };
34574
- return wo;
34577
+ return xo;
34575
34578
  }(ot);
34576
34579
  const ed = `#version 300 es
34577
34580
  // https://github.com/Volcomix/virtual-background/blob/main/src/pipelines/webgl2/jointBilateralFilterStage.ts
@@ -34652,7 +34655,7 @@ let nd = /*#__PURE__*/function (_dn3) {
34652
34655
  height: n,
34653
34656
  width: t
34654
34657
  },
34655
- o = new wo(Object.assign({}, i, {
34658
+ o = new xo(Object.assign({}, i, {
34656
34659
  radius: 1,
34657
34660
  type: mn.GAUSSIAN
34658
34661
  }));
@@ -34696,7 +34699,7 @@ let nd = /*#__PURE__*/function (_dn3) {
34696
34699
  };
34697
34700
  return nd;
34698
34701
  }(dn);
34699
- var xo = /* @__PURE__ */(r => (r.PUSH = "PUSH", r.POP = "POP", r))(xo || {});
34702
+ var vo = /* @__PURE__ */(r => (r.PUSH = "PUSH", r.POP = "POP", r))(vo || {});
34700
34703
  let id = /*#__PURE__*/function () {
34701
34704
  function id(e) {
34702
34705
  this.queries = [], this.context = e, this.extension = e.getExtension("EXT_disjoint_timer_query_webgl2");
@@ -34798,7 +34801,7 @@ let id = /*#__PURE__*/function () {
34798
34801
  return _context55.abrupt("return", e);
34799
34802
  case 4:
34800
34803
  _context55.next = 6;
34801
- return bo(200);
34804
+ return wo(200);
34802
34805
  case 6:
34803
34806
  ++t;
34804
34807
  _context55.next = 1;
@@ -34841,7 +34844,7 @@ let ur = /*#__PURE__*/function () {
34841
34844
  this.profiler = t;
34842
34845
  t.start();
34843
34846
  _context56.next = 5;
34844
- return bo(e);
34847
+ return wo(e);
34845
34848
  case 5:
34846
34849
  this.profiler = void 0;
34847
34850
  t.stop();
@@ -34907,18 +34910,18 @@ let ur = /*#__PURE__*/function () {
34907
34910
  };
34908
34911
  return ur;
34909
34912
  }();
34910
- let vo = /*#__PURE__*/function (_ur) {
34911
- (0, _inheritsLoose2.default)(vo, _ur);
34912
- function vo() {
34913
+ let _o = /*#__PURE__*/function (_ur) {
34914
+ (0, _inheritsLoose2.default)(_o, _ur);
34915
+ function _o() {
34913
34916
  var _this22;
34914
- _this22 = _ur.call(this) || this, _this22.pipeline = new yo(_this22.context);
34917
+ _this22 = _ur.call(this) || this, _this22.pipeline = new bo(_this22.context);
34915
34918
  const e = new OffscreenCanvas(0, 0),
34916
34919
  t = e.getContext("webgl2");
34917
34920
  if (!t) throw "Fail to retrieve webgl context";
34918
34921
  _this22.backgroundImageResizerCanvas = e, _this22.backgroundImageResizerContext = t, _this22.backgroundImageResizer = new Kf(_this22.backgroundImageResizerContext, 0, 0);
34919
34922
  return _this22;
34920
34923
  }
34921
- var _proto29 = vo.prototype;
34924
+ var _proto29 = _o.prototype;
34922
34925
  _proto29.setBackgroundImage = function setBackgroundImage(e) {
34923
34926
  this.backgroundImage = e, this.updateBackgroundImage();
34924
34927
  };
@@ -34936,12 +34939,12 @@ let vo = /*#__PURE__*/function (_ur) {
34936
34939
  const e = (_this$backgroundImage = this.backgroundImageResizerContext) == null ? void 0 : _this$backgroundImage.getExtension("WEBGL_lose_context");
34937
34940
  e && e.loseContext(), _ur.prototype.destroy.call(this);
34938
34941
  };
34939
- return vo;
34942
+ return _o;
34940
34943
  }(ur);
34941
- let od = /*#__PURE__*/function (_vo) {
34942
- (0, _inheritsLoose2.default)(od, _vo);
34944
+ let od = /*#__PURE__*/function (_o4) {
34945
+ (0, _inheritsLoose2.default)(od, _o4);
34943
34946
  function od() {
34944
- return _vo.apply(this, arguments) || this;
34947
+ return _o4.apply(this, arguments) || this;
34945
34948
  }
34946
34949
  var _proto30 = od.prototype;
34947
34950
  _proto30.setBackgroundVideo = function setBackgroundVideo(e) {
@@ -34955,7 +34958,7 @@ let od = /*#__PURE__*/function (_vo) {
34955
34958
  _context58.next = 2;
34956
34959
  return this.readNextVideoFrame();
34957
34960
  case 2:
34958
- return _context58.abrupt("return", _vo.prototype.render.call(this, e, t));
34961
+ return _context58.abrupt("return", _o4.prototype.render.call(this, e, t));
34959
34962
  case 3:
34960
34963
  case "end":
34961
34964
  return _context58.stop();
@@ -34999,10 +35002,10 @@ let od = /*#__PURE__*/function (_vo) {
34999
35002
  return readNextVideoFrame;
35000
35003
  }();
35001
35004
  return od;
35002
- }(vo);
35003
- let ri = /*#__PURE__*/function () {
35004
- function ri() {}
35005
- var _proto31 = ri.prototype;
35005
+ }(_o);
35006
+ let ni = /*#__PURE__*/function () {
35007
+ function ni() {}
35008
+ var _proto31 = ni.prototype;
35006
35009
  _proto31.blurBackground = function blurBackground(e) {
35007
35010
  return new za(e);
35008
35011
  };
@@ -35015,7 +35018,7 @@ let ri = /*#__PURE__*/function () {
35015
35018
  _proto31.videoBackground = function videoBackground() {
35016
35019
  return new od();
35017
35020
  };
35018
- return ri;
35021
+ return ni;
35019
35022
  }();
35020
35023
  const sd = `precision mediump float;
35021
35024
 
@@ -35159,7 +35162,7 @@ let md = /*#__PURE__*/function (_hn3) {
35159
35162
  height: e.canvas.height,
35160
35163
  width: e.canvas.width
35161
35164
  },
35162
- i = new wo(Object.assign({}, n, {
35165
+ i = new xo(Object.assign({}, n, {
35163
35166
  radius: t,
35164
35167
  type: mn.GAUSSIAN
35165
35168
  })),
@@ -35196,11 +35199,11 @@ let pd = /*#__PURE__*/function (_ur3) {
35196
35199
  }
35197
35200
  return pd;
35198
35201
  }(ur);
35199
- let gd = /*#__PURE__*/function (_yo) {
35200
- (0, _inheritsLoose2.default)(gd, _yo);
35202
+ let gd = /*#__PURE__*/function (_bo) {
35203
+ (0, _inheritsLoose2.default)(gd, _bo);
35201
35204
  function gd() {
35202
35205
  var _this27;
35203
- _this27 = _yo.apply(this, arguments) || this, _this27.preciseMaskEnabled = !0;
35206
+ _this27 = _bo.apply(this, arguments) || this, _this27.preciseMaskEnabled = !0;
35204
35207
  return _this27;
35205
35208
  }
35206
35209
  var _proto35 = gd.prototype;
@@ -35218,7 +35221,7 @@ let gd = /*#__PURE__*/function (_yo) {
35218
35221
  return this.readNextVideoFrame();
35219
35222
  case 4:
35220
35223
  _context60.next = 6;
35221
- return _yo.prototype.run.call(this);
35224
+ return _bo.prototype.run.call(this);
35222
35225
  case 6:
35223
35226
  case "end":
35224
35227
  return _context60.stop();
@@ -35269,7 +35272,7 @@ let gd = /*#__PURE__*/function (_yo) {
35269
35272
  }
35270
35273
  }]);
35271
35274
  return gd;
35272
- }(yo);
35275
+ }(bo);
35273
35276
  let yd = /*#__PURE__*/function (_ur4) {
35274
35277
  (0, _inheritsLoose2.default)(yd, _ur4);
35275
35278
  function yd() {
@@ -35283,9 +35286,9 @@ let yd = /*#__PURE__*/function (_ur4) {
35283
35286
  };
35284
35287
  return yd;
35285
35288
  }(ur);
35286
- let ni = /*#__PURE__*/function () {
35287
- function ni() {}
35288
- var _proto37 = ni.prototype;
35289
+ let ii = /*#__PURE__*/function () {
35290
+ function ii() {}
35291
+ var _proto37 = ii.prototype;
35289
35292
  _proto37.blurBackground = function blurBackground(e) {
35290
35293
  return new hd(e);
35291
35294
  };
@@ -35293,25 +35296,25 @@ let ni = /*#__PURE__*/function () {
35293
35296
  return new pd(e);
35294
35297
  };
35295
35298
  _proto37.imageBackground = function imageBackground() {
35296
- return new vo();
35299
+ return new _o();
35297
35300
  };
35298
35301
  _proto37.videoBackground = function videoBackground() {
35299
35302
  return new yd();
35300
35303
  };
35301
- return ni;
35304
+ return ii;
35302
35305
  }();
35303
35306
  let bd = /*#__PURE__*/function () {
35304
35307
  function bd(e) {
35305
35308
  switch (e) {
35306
35309
  case Mt.CANVAS:
35307
- this.factory = new ri();
35310
+ this.factory = new ni();
35308
35311
  break;
35309
35312
  case Mt.WEBGL:
35310
- this.factory = new ni();
35313
+ this.factory = new ii();
35311
35314
  break;
35312
35315
  default:
35313
- const t = li();
35314
- this.factory = t.supported ? new ni() : new ri();
35316
+ const t = fi();
35317
+ this.factory = t.supported ? new ii() : new ni();
35315
35318
  }
35316
35319
  }
35317
35320
  var _proto38 = bd.prototype;
@@ -35484,10 +35487,10 @@ var xd = function () {
35484
35487
  t.wasmBinary && (g = t.wasmBinary), t.noExitRuntime, typeof WebAssembly != "object" && Z("no native wasm support detected");
35485
35488
  var x,
35486
35489
  v = !1,
35487
- R = typeof TextDecoder < "u" ? new TextDecoder("utf8") : void 0;
35488
- function k(l, h, y) {
35490
+ k = typeof TextDecoder < "u" ? new TextDecoder("utf8") : void 0;
35491
+ function R(l, h, y) {
35489
35492
  for (var _ = h + y, S = h; l[S] && !(S >= _);) ++S;
35490
- if (S - h > 16 && l.subarray && R) return R.decode(l.subarray(h, S));
35493
+ if (S - h > 16 && l.subarray && k) return k.decode(l.subarray(h, S));
35491
35494
  for (var P = ""; h < S;) {
35492
35495
  var E = l[h++];
35493
35496
  if (!(E & 128)) {
@@ -35508,7 +35511,7 @@ var xd = function () {
35508
35511
  return P;
35509
35512
  }
35510
35513
  function L(l, h) {
35511
- return l ? k($e, l, h) : "";
35514
+ return l ? R($e, l, h) : "";
35512
35515
  }
35513
35516
  function Y(l, h, y) {
35514
35517
  for (var _ = 0; _ < l.length; ++_) st[h++ >> 0] = l.charCodeAt(_);
@@ -35526,21 +35529,21 @@ var xd = function () {
35526
35529
  bn = [],
35527
35530
  wn = [],
35528
35531
  xn = [];
35529
- function Eo() {
35530
- if (t.preRun) for (typeof t.preRun == "function" && (t.preRun = [t.preRun]); t.preRun.length;) So(t.preRun.shift());
35532
+ function Ao() {
35533
+ if (t.preRun) for (typeof t.preRun == "function" && (t.preRun = [t.preRun]); t.preRun.length;) Io(t.preRun.shift());
35531
35534
  fr(bn);
35532
35535
  }
35533
- function Ao() {
35536
+ function To() {
35534
35537
  fr(wn);
35535
35538
  }
35536
- function To() {
35539
+ function So() {
35537
35540
  if (t.postRun) for (typeof t.postRun == "function" && (t.postRun = [t.postRun]); t.postRun.length;) Ro(t.postRun.shift());
35538
35541
  fr(xn);
35539
35542
  }
35540
- function So(l) {
35543
+ function Io(l) {
35541
35544
  bn.unshift(l);
35542
35545
  }
35543
- function Io(l) {
35546
+ function ko(l) {
35544
35547
  wn.unshift(l);
35545
35548
  }
35546
35549
  function Ro(l) {
@@ -35548,10 +35551,10 @@ var xd = function () {
35548
35551
  }
35549
35552
  var fe = 0,
35550
35553
  We = null;
35551
- function ko(l) {
35554
+ function Po(l) {
35552
35555
  fe++, t.monitorRunDependencies && t.monitorRunDependencies(fe);
35553
35556
  }
35554
- function Po(l) {
35557
+ function Fo(l) {
35555
35558
  if (fe--, t.monitorRunDependencies && t.monitorRunDependencies(fe), fe == 0 && We) {
35556
35559
  var h = We;
35557
35560
  We = null, h();
@@ -35563,9 +35566,9 @@ var xd = function () {
35563
35566
  var h = new WebAssembly.RuntimeError(l);
35564
35567
  throw i(h), h;
35565
35568
  }
35566
- var Fo = "data:application/octet-stream;base64,";
35569
+ var Co = "data:application/octet-stream;base64,";
35567
35570
  function vn(l) {
35568
- return l.startsWith(Fo);
35571
+ return l.startsWith(Co);
35569
35572
  }
35570
35573
  var W;
35571
35574
  W = "tflite-simd.wasm", vn(W) || (W = m(W));
@@ -35577,7 +35580,7 @@ var xd = function () {
35577
35580
  Z(h);
35578
35581
  }
35579
35582
  }
35580
- function Co() {
35583
+ function Oo() {
35581
35584
  return !g && u && typeof fetch == "function" ? fetch(W, {
35582
35585
  credentials: "same-origin"
35583
35586
  }).then(function (l) {
@@ -35589,20 +35592,20 @@ var xd = function () {
35589
35592
  return _n(W);
35590
35593
  });
35591
35594
  }
35592
- function Oo() {
35595
+ function Mo() {
35593
35596
  var l = {
35594
- a: es
35597
+ a: ts
35595
35598
  };
35596
35599
  function h(E, O) {
35597
35600
  var H = E.exports;
35598
- t.asm = H, x = t.asm.q, yn(x.buffer), lr = t.asm.E, Io(t.asm.r), Po();
35601
+ t.asm = H, x = t.asm.q, yn(x.buffer), lr = t.asm.E, ko(t.asm.r), Fo();
35599
35602
  }
35600
- ko();
35603
+ Po();
35601
35604
  function y(E) {
35602
35605
  h(E.instance);
35603
35606
  }
35604
35607
  function _(E) {
35605
- return Co().then(function (O) {
35608
+ return Oo().then(function (O) {
35606
35609
  return WebAssembly.instantiate(O, l);
35607
35610
  }).then(function (O) {
35608
35611
  return O;
@@ -35639,43 +35642,43 @@ var xd = function () {
35639
35642
  typeof y == "number" ? h.arg === void 0 ? lr.get(y)() : lr.get(y)(h.arg) : y(h.arg === void 0 ? null : h.arg);
35640
35643
  }
35641
35644
  }
35642
- function Mo(l, h, y, _) {
35645
+ function Bo(l, h, y, _) {
35643
35646
  Z("Assertion failed: " + L(l) + ", at: " + [h ? L(h) : "unknown filename", y, _ ? L(_) : "unknown function"]);
35644
35647
  }
35645
- function Bo(l, h) {
35648
+ function Do(l, h) {
35646
35649
  Z("To use dlopen, you need to use Emscripten's linking support, see https://github.com/emscripten-core/emscripten/wiki/Linking");
35647
35650
  }
35648
- function Do(l, h) {
35651
+ function Uo(l, h) {
35649
35652
  Z("To use dlopen, you need to use Emscripten's linking support, see https://github.com/emscripten-core/emscripten/wiki/Linking");
35650
35653
  }
35651
- function Uo() {
35654
+ function Lo() {
35652
35655
  Z("");
35653
35656
  }
35654
35657
  var at;
35655
35658
  at = function at() {
35656
35659
  return performance.now();
35657
35660
  };
35658
- var Lo = !0;
35659
- function zo(l) {
35661
+ var zo = !0;
35662
+ function No(l) {
35660
35663
  return $[En() >> 2] = l, l;
35661
35664
  }
35662
- function No(l, h) {
35665
+ function $o(l, h) {
35663
35666
  var y;
35664
- if (l === 0) y = Date.now();else if ((l === 1 || l === 4) && Lo) y = at();else return zo(28), -1;
35667
+ if (l === 0) y = Date.now();else if ((l === 1 || l === 4) && zo) y = at();else return No(28), -1;
35665
35668
  return $[h >> 2] = y / 1e3 | 0, $[h + 4 >> 2] = y % 1e3 * 1e3 * 1e3 | 0, 0;
35666
35669
  }
35667
- function $o() {
35670
+ function Wo() {
35668
35671
  return 2147483648;
35669
35672
  }
35670
- function Wo(l, h, y) {
35673
+ function Go(l, h, y) {
35671
35674
  $e.copyWithin(l, h, h + y);
35672
35675
  }
35673
- function Go(l) {
35676
+ function Vo(l) {
35674
35677
  try {
35675
35678
  return x.grow(l - N.byteLength + 65535 >>> 16), yn(x.buffer), 1;
35676
35679
  } catch (_unused3) {}
35677
35680
  }
35678
- function Vo(l) {
35681
+ function Ho(l) {
35679
35682
  var h = $e.length;
35680
35683
  l = l >>> 0;
35681
35684
  var y = 2147483648;
@@ -35684,16 +35687,16 @@ var xd = function () {
35684
35687
  var S = h * (1 + 0.2 / _);
35685
35688
  S = Math.min(S, l + 100663296);
35686
35689
  var P = Math.min(y, Q(Math.max(l, S), 65536)),
35687
- E = Go(P);
35690
+ E = Vo(P);
35688
35691
  if (E) return !0;
35689
35692
  }
35690
35693
  return !1;
35691
35694
  }
35692
- function Ho(l) {
35695
+ function jo(l) {
35693
35696
  for (var h = at(); at() - h < l;);
35694
35697
  }
35695
35698
  var dr = {};
35696
- function jo() {
35699
+ function Yo() {
35697
35700
  return a || "./this.program";
35698
35701
  }
35699
35702
  function Ge() {
@@ -35706,7 +35709,7 @@ var xd = function () {
35706
35709
  PWD: "/",
35707
35710
  HOME: "/home/web_user",
35708
35711
  LANG: l,
35709
- _: jo()
35712
+ _: Yo()
35710
35713
  };
35711
35714
  for (var y in dr) dr[y] === void 0 ? delete h[y] : h[y] = dr[y];
35712
35715
  var _ = [];
@@ -35720,7 +35723,7 @@ var xd = function () {
35720
35723
  buffers: [null, [], []],
35721
35724
  printChar: function printChar(l, h) {
35722
35725
  var y = ct.buffers[l];
35723
- h === 0 || h === 10 ? ((l === 1 ? b : d)(k(y, 0)), y.length = 0) : y.push(h);
35726
+ h === 0 || h === 10 ? ((l === 1 ? b : d)(R(y, 0)), y.length = 0) : y.push(h);
35724
35727
  },
35725
35728
  varargs: void 0,
35726
35729
  get: function get() {
@@ -35736,14 +35739,14 @@ var xd = function () {
35736
35739
  return l;
35737
35740
  }
35738
35741
  };
35739
- function Yo(l, h) {
35742
+ function Qo(l, h) {
35740
35743
  var y = 0;
35741
35744
  return Ge().forEach(function (_, S) {
35742
35745
  var P = h + y;
35743
35746
  $[l + S * 4 >> 2] = P, Y(_, P), y += _.length + 1;
35744
35747
  }), 0;
35745
35748
  }
35746
- function Qo(l, h) {
35749
+ function qo(l, h) {
35747
35750
  var y = Ge();
35748
35751
  $[l >> 2] = y.length;
35749
35752
  var _ = 0;
@@ -35751,21 +35754,21 @@ var xd = function () {
35751
35754
  _ += S.length + 1;
35752
35755
  }), $[h >> 2] = _, 0;
35753
35756
  }
35754
- function qo(l) {
35755
- rs(l);
35756
- }
35757
35757
  function Xo(l) {
35758
+ ns(l);
35759
+ }
35760
+ function Ko(l) {
35758
35761
  return 0;
35759
35762
  }
35760
- function Ko(l, h, y, _, S) {}
35761
- function Jo(l, h, y, _) {
35763
+ function Jo(l, h, y, _, S) {}
35764
+ function Zo(l, h, y, _) {
35762
35765
  for (var S = 0, P = 0; P < y; P++) {
35763
35766
  for (var E = $[h + P * 8 >> 2], O = $[h + (P * 8 + 4) >> 2], H = 0; H < O; H++) ct.printChar(l, $e[E + H]);
35764
35767
  S += O;
35765
35768
  }
35766
35769
  return $[_ >> 2] = S, 0;
35767
35770
  }
35768
- function Zo() {
35771
+ function es() {
35769
35772
  if (typeof crypto == "object" && typeof crypto.getRandomValues == "function") {
35770
35773
  var l = new Uint8Array(1);
35771
35774
  return function () {
@@ -35776,29 +35779,29 @@ var xd = function () {
35776
35779
  };
35777
35780
  }
35778
35781
  function ut(l, h) {
35779
- ut.randomDevice || (ut.randomDevice = Zo());
35782
+ ut.randomDevice || (ut.randomDevice = es());
35780
35783
  for (var y = 0; y < h; y++) st[l + y >> 0] = ut.randomDevice();
35781
35784
  return 0;
35782
35785
  }
35783
- var es = {
35784
- a: Mo,
35785
- e: Bo,
35786
- d: Do,
35787
- b: Uo,
35788
- n: No,
35789
- h: $o,
35790
- l: Wo,
35791
- m: Vo,
35792
- p: Ho,
35793
- f: Yo,
35794
- g: Qo,
35795
- j: qo,
35796
- i: Xo,
35797
- k: Ko,
35798
- c: Jo,
35786
+ var ts = {
35787
+ a: Bo,
35788
+ e: Do,
35789
+ d: Uo,
35790
+ b: Lo,
35791
+ n: $o,
35792
+ h: Wo,
35793
+ l: Go,
35794
+ m: Ho,
35795
+ p: jo,
35796
+ f: Qo,
35797
+ g: qo,
35798
+ j: Xo,
35799
+ i: Ko,
35800
+ k: Jo,
35801
+ c: Zo,
35799
35802
  o: ut
35800
35803
  };
35801
- Oo(), t.___wasm_call_ctors = function () {
35804
+ Mo(), t.___wasm_call_ctors = function () {
35802
35805
  return (t.___wasm_call_ctors = t.asm.r).apply(null, arguments);
35803
35806
  }, t._getModelBufferMemoryOffset = function () {
35804
35807
  return (t._getModelBufferMemoryOffset = t.asm.s).apply(null, arguments);
@@ -35829,16 +35832,16 @@ var xd = function () {
35829
35832
  return (En = t.___errno_location = t.asm.F).apply(null, arguments);
35830
35833
  },
35831
35834
  lt;
35832
- function ts(l) {
35835
+ function rs(l) {
35833
35836
  this.name = "ExitStatus", this.message = "Program terminated with exit(" + l + ")", this.status = l;
35834
35837
  }
35835
35838
  We = function l() {
35836
35839
  lt || hr(), lt || (We = l);
35837
35840
  };
35838
35841
  function hr(l) {
35839
- if (fe > 0 || (Eo(), fe > 0)) return;
35842
+ if (fe > 0 || (Ao(), fe > 0)) return;
35840
35843
  function h() {
35841
- lt || (lt = !0, t.calledRun = !0, !v && (Ao(), n(t), t.onRuntimeInitialized && t.onRuntimeInitialized(), To()));
35844
+ lt || (lt = !0, t.calledRun = !0, !v && (To(), n(t), t.onRuntimeInitialized && t.onRuntimeInitialized(), So()));
35842
35845
  }
35843
35846
  t.setStatus ? (t.setStatus("Running..."), setTimeout(function () {
35844
35847
  setTimeout(function () {
@@ -35847,11 +35850,11 @@ var xd = function () {
35847
35850
  }, 1)) : h();
35848
35851
  }
35849
35852
  t.run = hr;
35850
- function rs(l, h) {
35851
- ns(l);
35853
+ function ns(l, h) {
35854
+ is(l);
35852
35855
  }
35853
- function ns(l) {
35854
- c(l, new ts(l));
35856
+ function is(l) {
35857
+ c(l, new rs(l));
35855
35858
  }
35856
35859
  if (t.preInit) for (typeof t.preInit == "function" && (t.preInit = [t.preInit]); t.preInit.length > 0;) t.preInit.pop()();
35857
35860
  return hr(), e.ready;
@@ -35993,13 +35996,13 @@ function _Ad() {
35993
35996
  const Td = 0.1,
35994
35997
  Sd = 0.7,
35995
35998
  Id = "https://d3opqjmqzxf057.cloudfront.net/ml/vonage_selfie_segmenter/float16/v1/vonage_selfie_segmenter.tflite";
35996
- let Rd = /*#__PURE__*/function () {
35997
- function Rd() {
35999
+ let kd = /*#__PURE__*/function () {
36000
+ function kd() {
35998
36001
  this.canvas = new OffscreenCanvas(0, 0), this.context = this.canvas.getContext("2d", {
35999
36002
  willReadFrequently: !0
36000
36003
  }), this.width = 0, this.height = 0, this.gpuDelegate = !0;
36001
36004
  }
36002
- var _proto40 = Rd.prototype;
36005
+ var _proto40 = kd.prototype;
36003
36006
  _proto40.createImageSegmenter = /*#__PURE__*/function () {
36004
36007
  var _createImageSegmenter = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee66() {
36005
36008
  return _regenerator.default.wrap(function _callee66$(_context66) {
@@ -36170,15 +36173,15 @@ let Rd = /*#__PURE__*/function () {
36170
36173
  f = 1 - Math.min(1, u * (5.68842 + u * (i + u * (o + u * (s + u * a)))));
36171
36174
  return t + (e - t) * (f * 0.9);
36172
36175
  };
36173
- return Rd;
36176
+ return kd;
36174
36177
  }();
36175
- let kd = /*#__PURE__*/function () {
36176
- function kd() {
36178
+ let Rd = /*#__PURE__*/function () {
36179
+ function Rd() {
36177
36180
  this.canvas = new OffscreenCanvas(0, 0), this.context = this.canvas.getContext("2d", {
36178
36181
  willReadFrequently: !0
36179
36182
  }), this.pixelCount = 0, this.inputOffset = 0, this.outputOffset = 0;
36180
36183
  }
36181
- var _proto41 = kd.prototype;
36184
+ var _proto41 = Rd.prototype;
36182
36185
  _proto41.init = /*#__PURE__*/function () {
36183
36186
  var _init2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee70(e, t, n) {
36184
36187
  return _regenerator.default.wrap(function _callee70$(_context70) {
@@ -36259,11 +36262,11 @@ let kd = /*#__PURE__*/function () {
36259
36262
  var _this$infos$selectedT, _this$infos, _this$infos$selectedT2;
36260
36263
  return (_this$infos$selectedT = (_this$infos = this.infos) == null ? void 0 : (_this$infos$selectedT2 = _this$infos.selectedTFLite) == null ? void 0 : _this$infos$selectedT2._isGPUEnabled()) != null ? _this$infos$selectedT : !1;
36261
36264
  };
36262
- return kd;
36265
+ return Rd;
36263
36266
  }();
36264
36267
  let Pd = /*#__PURE__*/function () {
36265
36268
  function Pd() {
36266
- this.reporter = new Ua(), this.isEnabled = !0;
36269
+ this.reporter = new Ua(), this.isEnabled = !0, this.avoidOriginalTrackLeak = !1;
36267
36270
  }
36268
36271
  var _proto42 = Pd.prototype;
36269
36272
  _proto42.init = /*#__PURE__*/function () {
@@ -36272,7 +36275,7 @@ let Pd = /*#__PURE__*/function () {
36272
36275
  return _regenerator.default.wrap(function _callee73$(_context73) {
36273
36276
  while (1) switch (_context73.prev = _context73.next) {
36274
36277
  case 0:
36275
- ((_t$segmentationOption = t.segmentationOptions) == null ? void 0 : _t$segmentationOption.lightWeightEngine) === !0 ? this.selfieSegmentation = new kd() : this.selfieSegmentation = new Rd(), (_this$selfieSegmentat = this.selfieSegmentation) != null && _this$selfieSegmentat.init(t.modelAssetUriPath, t.mediapipeBaseAssetsUri, (_t$segmentationOption2 = t.segmentationOptions) == null ? void 0 : _t$segmentationOption2.gpuSupport), this.backgroundFilter = new wd(), this.report({
36278
+ ((_t$segmentationOption = t.segmentationOptions) == null ? void 0 : _t$segmentationOption.lightWeightEngine) === !0 ? this.selfieSegmentation = new Rd() : this.selfieSegmentation = new kd(), (_this$selfieSegmentat = this.selfieSegmentation) != null && _this$selfieSegmentat.init(t.modelAssetUriPath, t.mediapipeBaseAssetsUri, (_t$segmentationOption2 = t.segmentationOptions) == null ? void 0 : _t$segmentationOption2.gpuSupport), this.avoidOriginalTrackLeak = t.avoidOriginalTrackLeak, this.backgroundFilter = new wd(), this.report({
36276
36279
  variation: "Create"
36277
36280
  });
36278
36281
  case 1:
@@ -36318,11 +36321,12 @@ let Pd = /*#__PURE__*/function () {
36318
36321
  case 13:
36319
36322
  n = _context74.sent;
36320
36323
  case 14:
36324
+ !n && this.avoidOriginalTrackLeak && (n = new OffscreenCanvas(o.width, o.height));
36321
36325
  n ? (e.close(), t.enqueue(new VideoFrame(n, {
36322
36326
  timestamp: i,
36323
36327
  alpha: "discard"
36324
36328
  }))) : t.enqueue(e);
36325
- case 15:
36329
+ case 16:
36326
36330
  case "end":
36327
36331
  return _context74.stop();
36328
36332
  }
@@ -36418,7 +36422,7 @@ let Pd = /*#__PURE__*/function () {
36418
36422
  exports.BackgroundTransformer = Pd;
36419
36423
  const pn = /*#__PURE__*/function () {
36420
36424
  function pn() {
36421
- this.backgroundTransformer = new Pd(), this.mediaProcessor = new ui(), this.rate = 30, this.eventsQueue = [], this.frameTransformLatencyMs = [];
36425
+ this.backgroundTransformer = new Pd(), this.mediaProcessor = new li(), this.rate = 30, this.eventsQueue = [], this.frameTransformLatencyMs = [];
36422
36426
  }
36423
36427
  var _proto43 = pn.prototype;
36424
36428
  _proto43.init = /*#__PURE__*/function () {
@@ -36581,7 +36585,7 @@ const pn = /*#__PURE__*/function () {
36581
36585
  return terminate;
36582
36586
  }();
36583
36587
  _proto43.setVonageMetadata = function setVonageMetadata(e) {
36584
- Cs(e);
36588
+ Os(e);
36585
36589
  };
36586
36590
  _proto43.profile = /*#__PURE__*/function () {
36587
36591
  var _profile3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee85(e) {
@@ -36609,14 +36613,14 @@ const pn = /*#__PURE__*/function () {
36609
36613
  }();
36610
36614
  ua("ProcessorWorker", pn);
36611
36615
  let Mr = pn;
36612
- const _o = '(function(){"use strict";function Vt(r,e){globalThis.vonage||(globalThis.vonage={}),globalThis.vonage.workerizer||(globalThis.vonage.workerizer={});let t=globalThis.vonage.workerizer;return t[r]||(t[r]=e),t[r]}const Vr=Vt("globals",{});var xe=(r=>(r.INIT="INIT",r.FORWARD="FORWARD",r.TERMINATE="TERMINATE",r.GLOBALS_SYNC="GLOBALS_SYNC",r.EVENT="EVENT",r))(xe||{});function zi(r){return[ImageBitmap,ReadableStream,WritableStream].some(t=>r instanceof t)}function Be(r,e){const{id:t,type:n}=r,i=Array.isArray(e)?e:[e];postMessage({id:t,type:n,result:e},i.filter(s=>zi(s)))}Vt("workerized",{});function Hr(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function qe(r,e){if(Array.isArray(e))e.splice(0,e.length);else if(typeof e=="object")for(const t in e)delete e[t];for(const t in r)Array.isArray(r[t])?(e[t]=[],qe(r[t],e[t])):typeof r[t]=="object"?(e[t]={},qe(r[t],e[t])):e[t]=r[t]}const K=new WeakMap,ce=new WeakMap,j=new WeakMap,Ke=Symbol("anyProducer"),jr=Promise.resolve(),Je=Symbol("listenerAdded"),Ze=Symbol("listenerRemoved");let et=!1,Ht=!1;function _e(r){if(typeof r!="string"&&typeof r!="symbol"&&typeof r!="number")throw new TypeError("`eventName` must be a string, symbol, or number")}function tt(r){if(typeof r!="function")throw new TypeError("listener must be a function")}function Ee(r,e){const t=ce.get(r);if(t.has(e))return t.get(e)}function De(r,e){const t=typeof e=="string"||typeof e=="symbol"||typeof e=="number"?e:Ke,n=j.get(r);if(n.has(t))return n.get(t)}function Gi(r,e,t){const n=j.get(r);if(n.has(e))for(const i of n.get(e))i.enqueue(t);if(n.has(Ke)){const i=Promise.all([e,t]);for(const s of n.get(Ke))s.enqueue(i)}}function Xr(r,e){e=Array.isArray(e)?e:[e];let t=!1,n=()=>{},i=[];const s={enqueue(o){i.push(o),n()},finish(){t=!0,n()}};for(const o of e){let a=De(r,o);a||(a=new Set,j.get(r).set(o,a)),a.add(s)}return{async next(){return i?i.length===0?t?(i=void 0,this.next()):(await new Promise(o=>{n=o}),this.next()):{done:!1,value:await i.shift()}:{done:!0}},async return(o){i=void 0;for(const a of e){const c=De(r,a);c&&(c.delete(s),c.size===0&&j.get(r).delete(a))}return n(),arguments.length>0?{done:!0,value:await o}:{done:!0}},[Symbol.asyncIterator](){return this}}}function Yr(r){if(r===void 0)return Qr;if(!Array.isArray(r))throw new TypeError("`methodNames` must be an array of strings");for(const e of r)if(!Qr.includes(e))throw typeof e!="string"?new TypeError("`methodNames` element must be a string"):new Error(`${e} is not Emittery method`);return r}const we=r=>r===Je||r===Ze;function rt(r,e,t){if(we(e))try{et=!0,r.emit(e,t)}finally{et=!1}}class ve{static mixin(e,t){return t=Yr(t),n=>{if(typeof n!="function")throw new TypeError("`target` must be function");for(const o of t)if(n.prototype[o]!==void 0)throw new Error(`The property \\`${o}\\` already exists on \\`target\\``);function i(){return Object.defineProperty(this,e,{enumerable:!1,value:new ve}),this[e]}Object.defineProperty(n.prototype,e,{enumerable:!1,get:i});const s=o=>function(...a){return this[e][o](...a)};for(const o of t)Object.defineProperty(n.prototype,o,{enumerable:!1,value:s(o)});return n}}static get isDebugEnabled(){var e,t;if(typeof((e=globalThis.process)==null?void 0:e.env)!="object")return Ht;const{env:n}=(t=globalThis.process)!=null?t:{env:{}};return n.DEBUG==="emittery"||n.DEBUG==="*"||Ht}static set isDebugEnabled(e){Ht=e}constructor(e={}){var t;K.set(this,new Set),ce.set(this,new Map),j.set(this,new Map),j.get(this).set(Ke,new Set),this.debug=(t=e.debug)!=null?t:{},this.debug.enabled===void 0&&(this.debug.enabled=!1),this.debug.logger||(this.debug.logger=(n,i,s,o)=>{try{o=JSON.stringify(o)}catch{o=`Object with the following keys failed to stringify: ${Object.keys(o).join(",")}`}(typeof s=="symbol"||typeof s=="number")&&(s=s.toString());const a=new Date,c=`${a.getHours()}:${a.getMinutes()}:${a.getSeconds()}.${a.getMilliseconds()}`;console.log(`[${c}][emittery:${n}][${i}] Event Name: ${s}\n data: ${o}`)})}logIfDebugEnabled(e,t,n){(ve.isDebugEnabled||this.debug.enabled)&&this.debug.logger(e,this.debug.name,t,n)}on(e,t){tt(t),e=Array.isArray(e)?e:[e];for(const n of e){_e(n);let i=Ee(this,n);i||(i=new Set,ce.get(this).set(n,i)),i.add(t),this.logIfDebugEnabled("subscribe",n,void 0),we(n)||rt(this,Je,{eventName:n,listener:t})}return this.off.bind(this,e,t)}off(e,t){tt(t),e=Array.isArray(e)?e:[e];for(const n of e){_e(n);const i=Ee(this,n);i&&(i.delete(t),i.size===0&&ce.get(this).delete(n)),this.logIfDebugEnabled("unsubscribe",n,void 0),we(n)||rt(this,Ze,{eventName:n,listener:t})}}once(e){let t;const n=new Promise(i=>{t=this.on(e,s=>{t(),i(s)})});return n.off=t,n}events(e){e=Array.isArray(e)?e:[e];for(const t of e)_e(t);return Xr(this,e)}async emit(e,t){var n;if(_e(e),we(e)&&!et)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");this.logIfDebugEnabled("emit",e,t),Gi(this,e,t);const i=(n=Ee(this,e))!=null?n:new Set,s=K.get(this),o=[...i],a=we(e)?[]:[...s];await jr,await Promise.all([...o.map(async c=>{if(i.has(c))return c(t)}),...a.map(async c=>{if(s.has(c))return c(e,t)})])}async emitSerial(e,t){var n;if(_e(e),we(e)&&!et)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");this.logIfDebugEnabled("emitSerial",e,t);const i=(n=Ee(this,e))!=null?n:new Set,s=K.get(this),o=[...i],a=[...s];await jr;for(const c of o)i.has(c)&&await c(t);for(const c of a)s.has(c)&&await c(e,t)}onAny(e){return tt(e),this.logIfDebugEnabled("subscribeAny",void 0,void 0),K.get(this).add(e),rt(this,Je,{listener:e}),this.offAny.bind(this,e)}anyEvent(){return Xr(this)}offAny(e){tt(e),this.logIfDebugEnabled("unsubscribeAny",void 0,void 0),rt(this,Ze,{listener:e}),K.get(this).delete(e)}clearListeners(e){e=Array.isArray(e)?e:[e];for(const t of e)if(this.logIfDebugEnabled("clear",t,void 0),typeof t=="string"||typeof t=="symbol"||typeof t=="number"){const n=Ee(this,t);n&&n.clear();const i=De(this,t);if(i){for(const s of i)s.finish();i.clear()}}else{K.get(this).clear();for(const[n,i]of ce.get(this).entries())i.clear(),ce.get(this).delete(n);for(const[n,i]of j.get(this).entries()){for(const s of i)s.finish();i.clear(),j.get(this).delete(n)}}}listenerCount(e){var t,n,i,s,o,a;e=Array.isArray(e)?e:[e];let c=0;for(const u of e){if(typeof u=="string"){c+=K.get(this).size+((n=(t=Ee(this,u))==null?void 0:t.size)!=null?n:0)+((s=(i=De(this,u))==null?void 0:i.size)!=null?s:0)+((a=(o=De(this))==null?void 0:o.size)!=null?a:0);continue}typeof u<"u"&&_e(u),c+=K.get(this).size;for(const d of ce.get(this).values())c+=d.size;for(const d of j.get(this).values())c+=d.size}return c}bindMethods(e,t){if(typeof e!="object"||e===null)throw new TypeError("`target` must be an object");t=Yr(t);for(const n of t){if(e[n]!==void 0)throw new Error(`The property \\`${n}\\` already exists on \\`target\\``);Object.defineProperty(e,n,{enumerable:!1,value:this[n].bind(this)})}}}const Qr=Object.getOwnPropertyNames(ve.prototype).filter(r=>r!=="constructor");Object.defineProperty(ve,"listenerAdded",{value:Je,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(ve,"listenerRemoved",{value:Ze,writable:!1,enumerable:!0,configurable:!1});function $i(r){return r.onAny&&r.emit}async function Wi(r,e){const{functionName:t,args:n}=r;if(!e.instance)throw"instance not initialized";if(!t)throw"missing function name to call";if(!e.instance[t])throw`undefined function [${t}] in class ${e.instance.constructor.workerId}`;Be(r,await e.instance[t](...n??[]))}const qr=Vt("registeredWorkers",{});function Vi(r,e){e.workerId=r,Hr()&&(qr[e.workerId]=e)}function Hi(r,e){if(!r.args)throw"Missing className while initializing worker";const[t,n]=r.args,i=qr[t];if(i)e.instance=new i(r.args.slice(1));else throw`unknown worker class ${t}`;qe(n,Vr),$i(e.instance)&&e.instance.onAny((s,o)=>{Be({type:xe.EVENT},{name:s,data:o})}),Be(r,typeof e.instance!==void 0)}async function ji(r,e){const{args:t}=r;if(!e.instance)throw"instance not initialized";let n;e.instance.terminate&&(n=await e.instance.terminate(...t??[])),Be(r,n)}function Xi(r){if(!r.args)throw"Missing globals while syncing";qe(r.args[0],Vr),Be(r,{})}function Yi(){const r={};onmessage=async e=>{const t=e.data;switch(t.type){case xe.INIT:Hi(t,r);break;case xe.FORWARD:Wi(t,r);break;case xe.TERMINATE:ji(t,r);break;case xe.GLOBALS_SYNC:Xi(t);break}}}Hr()&&Yi();const J=new WeakMap,ue=new WeakMap,X=new WeakMap,nt=Symbol("anyProducer"),Kr=Promise.resolve(),it=Symbol("listenerAdded"),st=Symbol("listenerRemoved");let ot=!1,jt=!1;const at=r=>typeof r=="string"||typeof r=="symbol"||typeof r=="number";function Te(r){if(!at(r))throw new TypeError("`eventName` must be a string, symbol, or number")}function ct(r){if(typeof r!="function")throw new TypeError("listener must be a function")}function Ae(r,e){const t=ue.get(r);if(t.has(e))return t.get(e)}function Me(r,e){const t=at(e)?e:nt,n=X.get(r);if(n.has(t))return n.get(t)}function Qi(r,e,t){const n=X.get(r);if(n.has(e))for(const i of n.get(e))i.enqueue(t);if(n.has(nt)){const i=Promise.all([e,t]);for(const s of n.get(nt))s.enqueue(i)}}function Jr(r,e){e=Array.isArray(e)?e:[e];let t=!1,n=()=>{},i=[];const s={enqueue(o){i.push(o),n()},finish(){t=!0,n()}};for(const o of e){let a=Me(r,o);a||(a=new Set,X.get(r).set(o,a)),a.add(s)}return{async next(){return i?i.length===0?t?(i=void 0,this.next()):(await new Promise(o=>{n=o}),this.next()):{done:!1,value:await i.shift()}:{done:!0}},async return(o){i=void 0;for(const a of e){const c=Me(r,a);c&&(c.delete(s),c.size===0&&X.get(r).delete(a))}return n(),arguments.length>0?{done:!0,value:await o}:{done:!0}},[Symbol.asyncIterator](){return this}}}function Zr(r){if(r===void 0)return en;if(!Array.isArray(r))throw new TypeError("`methodNames` must be an array of strings");for(const e of r)if(!en.includes(e))throw typeof e!="string"?new TypeError("`methodNames` element must be a string"):new Error(`${e} is not Emittery method`);return r}const Ie=r=>r===it||r===st;function ut(r,e,t){if(Ie(e))try{ot=!0,r.emit(e,t)}finally{ot=!1}}class Y{static mixin(e,t){return t=Zr(t),n=>{if(typeof n!="function")throw new TypeError("`target` must be function");for(const o of t)if(n.prototype[o]!==void 0)throw new Error(`The property \\`${o}\\` already exists on \\`target\\``);function i(){return Object.defineProperty(this,e,{enumerable:!1,value:new Y}),this[e]}Object.defineProperty(n.prototype,e,{enumerable:!1,get:i});const s=o=>function(...a){return this[e][o](...a)};for(const o of t)Object.defineProperty(n.prototype,o,{enumerable:!1,value:s(o)});return n}}static get isDebugEnabled(){if(typeof globalThis.process?.env!="object")return jt;const{env:e}=globalThis.process??{env:{}};return e.DEBUG==="emittery"||e.DEBUG==="*"||jt}static set isDebugEnabled(e){jt=e}constructor(e={}){J.set(this,new Set),ue.set(this,new Map),X.set(this,new Map),X.get(this).set(nt,new Set),this.debug=e.debug??{},this.debug.enabled===void 0&&(this.debug.enabled=!1),this.debug.logger||(this.debug.logger=(t,n,i,s)=>{try{s=JSON.stringify(s)}catch{s=`Object with the following keys failed to stringify: ${Object.keys(s).join(",")}`}(typeof i=="symbol"||typeof i=="number")&&(i=i.toString());const o=new Date,a=`${o.getHours()}:${o.getMinutes()}:${o.getSeconds()}.${o.getMilliseconds()}`;console.log(`[${a}][emittery:${t}][${n}] Event Name: ${i}\n data: ${s}`)})}logIfDebugEnabled(e,t,n){(Y.isDebugEnabled||this.debug.enabled)&&this.debug.logger(e,this.debug.name,t,n)}on(e,t,{signal:n}={}){ct(t),e=Array.isArray(e)?e:[e];for(const s of e){Te(s);let o=Ae(this,s);o||(o=new Set,ue.get(this).set(s,o)),o.add(t),this.logIfDebugEnabled("subscribe",s,void 0),Ie(s)||ut(this,it,{eventName:s,listener:t})}const i=()=>{this.off(e,t),n?.removeEventListener("abort",i)};return n?.addEventListener("abort",i,{once:!0}),n?.aborted&&i(),i}off(e,t){ct(t),e=Array.isArray(e)?e:[e];for(const n of e){Te(n);const i=Ae(this,n);i&&(i.delete(t),i.size===0&&ue.get(this).delete(n)),this.logIfDebugEnabled("unsubscribe",n,void 0),Ie(n)||ut(this,st,{eventName:n,listener:t})}}once(e,t){if(t!==void 0&&typeof t!="function")throw new TypeError("predicate must be a function");let n;const i=new Promise(s=>{n=this.on(e,o=>{t&&!t(o)||(n(),s(o))})});return i.off=n,i}events(e){e=Array.isArray(e)?e:[e];for(const t of e)Te(t);return Jr(this,e)}async emit(e,t){if(Te(e),Ie(e)&&!ot)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");this.logIfDebugEnabled("emit",e,t),Qi(this,e,t);const n=Ae(this,e)??new Set,i=J.get(this),s=[...n],o=Ie(e)?[]:[...i];await Kr,await Promise.all([...s.map(async a=>{if(n.has(a))return a(t)}),...o.map(async a=>{if(i.has(a))return a(e,t)})])}async emitSerial(e,t){if(Te(e),Ie(e)&&!ot)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");this.logIfDebugEnabled("emitSerial",e,t);const n=Ae(this,e)??new Set,i=J.get(this),s=[...n],o=[...i];await Kr;for(const a of s)n.has(a)&&await a(t);for(const a of o)i.has(a)&&await a(e,t)}onAny(e,{signal:t}={}){ct(e),this.logIfDebugEnabled("subscribeAny",void 0,void 0),J.get(this).add(e),ut(this,it,{listener:e});const n=()=>{this.offAny(e),t?.removeEventListener("abort",n)};return t?.addEventListener("abort",n,{once:!0}),t?.aborted&&n(),n}anyEvent(){return Jr(this)}offAny(e){ct(e),this.logIfDebugEnabled("unsubscribeAny",void 0,void 0),ut(this,st,{listener:e}),J.get(this).delete(e)}clearListeners(e){e=Array.isArray(e)?e:[e];for(const t of e)if(this.logIfDebugEnabled("clear",t,void 0),at(t)){const n=Ae(this,t);n&&n.clear();const i=Me(this,t);if(i){for(const s of i)s.finish();i.clear()}}else{J.get(this).clear();for(const[n,i]of ue.get(this).entries())i.clear(),ue.get(this).delete(n);for(const[n,i]of X.get(this).entries()){for(const s of i)s.finish();i.clear(),X.get(this).delete(n)}}}listenerCount(e){e=Array.isArray(e)?e:[e];let t=0;for(const n of e){if(at(n)){t+=J.get(this).size+(Ae(this,n)?.size??0)+(Me(this,n)?.size??0)+(Me(this)?.size??0);continue}n!==void 0&&Te(n),t+=J.get(this).size;for(const i of ue.get(this).values())t+=i.size;for(const i of X.get(this).values())t+=i.size}return t}bindMethods(e,t){if(typeof e!="object"||e===null)throw new TypeError("`target` must be an object");t=Zr(t);for(const n of t){if(e[n]!==void 0)throw new Error(`The property \\`${n}\\` already exists on \\`target\\``);Object.defineProperty(e,n,{enumerable:!1,value:this[n].bind(this)})}}}const en=Object.getOwnPropertyNames(Y.prototype).filter(r=>r!=="constructor");Object.defineProperty(Y,"listenerAdded",{value:it,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(Y,"listenerRemoved",{value:st,writable:!1,enumerable:!0,configurable:!1});var qi=Object.defineProperty,Ki=(r,e,t)=>e in r?qi(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ji=(r,e,t)=>(Ki(r,e+"",t),t);const Zi="hlg.tokbox.com/prod/logging/vcp_webrtc",es="https://",ts=1e4;let ft;const rs=new Uint8Array(16);function ns(){if(!ft&&(ft=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!ft))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ft(rs)}const F=[];for(let r=0;r<256;++r)F.push((r+256).toString(16).slice(1));function is(r,e=0){return(F[r[e+0]]+F[r[e+1]]+F[r[e+2]]+F[r[e+3]]+"-"+F[r[e+4]]+F[r[e+5]]+"-"+F[r[e+6]]+F[r[e+7]]+"-"+F[r[e+8]]+F[r[e+9]]+"-"+F[r[e+10]]+F[r[e+11]]+F[r[e+12]]+F[r[e+13]]+F[r[e+14]]+F[r[e+15]]).toLowerCase()}const ss=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),tn={randomUUID:ss};function os(r,e,t){if(tn.randomUUID&&!r)return tn.randomUUID();r=r||{};const n=r.random||(r.rng||ns)();return n[6]=n[6]&15|64,n[8]=n[8]&63|128,is(n)}function Xt(r,e){globalThis.vonage||(globalThis.vonage={}),globalThis.vonage.workerizer||(globalThis.vonage.workerizer={});let t=globalThis.vonage.workerizer;return t[r]||(t[r]=e),t[r]}const Z=Xt("globals",{});var fe=(r=>(r.INIT="INIT",r.FORWARD="FORWARD",r.TERMINATE="TERMINATE",r.GLOBALS_SYNC="GLOBALS_SYNC",r))(fe||{});function rn(r){return[ImageBitmap,ReadableStream,WritableStream].some(e=>r instanceof e)}let as=0;function cs(r,e,t,n,i){const s=as++;return r.postMessage({id:s,type:e,functionName:t,args:n},n.filter(o=>rn(o))),new Promise(o=>{i?.set(s,o)})}function Oe(r,e){const{id:t,type:n}=r,i=Array.isArray(e)?e:[e];postMessage({id:t,type:n,result:e},i.filter(s=>rn(s)))}const nn=Xt("workerized",{});function sn(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}async function us(){if(sn())Oe({type:fe.GLOBALS_SYNC},Z);else{const r=[];for(const e in nn){const{worker:t,resolvers:n}=nn[e].workerContext;t&&r.push(cs(t,fe.GLOBALS_SYNC,"",[Z],n))}await Promise.all(r)}}function lt(r,e){if(Array.isArray(e))e.splice(0,e.length);else if(typeof e=="object")for(const t in e)delete e[t];for(const t in r)Array.isArray(r[t])?(e[t]=[],lt(r[t],e[t])):typeof r[t]=="object"?(e[t]={},lt(r[t],e[t])):e[t]=r[t]}async function fs(r,e){const{functionName:t,args:n}=r;if(!e.instance)throw"instance not initialized";if(!t)throw"missing function name to call";if(!e.instance[t])throw`undefined function [${t}] in class ${e.instance.constructor.workerId}`;Oe(r,await e.instance[t](...n??[]))}const ls=Xt("registeredWorkers",{});function ds(r,e){if(!r.args)throw"Missing className while initializing worker";const[t,n]=r.args,i=ls[t];if(i)e.instance=new i(r.args.slice(1));else throw`unknown worker class ${t}`;lt(n,Z),Oe(r,typeof e.instance!==void 0)}async function hs(r,e){const{args:t}=r;if(!e.instance)throw"instance not initialized";let n;e.instance.terminate&&(n=await e.instance.terminate(...t??[])),Oe(r,n)}function ms(r){if(!r.args)throw"Missing globals while syncing";lt(r.args[0],Z),Oe(r,{})}function ps(){const r={};onmessage=async e=>{const t=e.data;switch(t.type){case fe.INIT:ds(t,r);break;case fe.FORWARD:fs(t,r);break;case fe.TERMINATE:hs(t,r);break;case fe.GLOBALS_SYNC:ms(t);break}}}sn()&&ps();function gs(r,e){return Z[r]||(Z[r]=e),[()=>Z[r],async t=>{Z[r]=t,await us()}]}function ys(r,e){return gs(r,e)}const[bs,xs]=ys("metadata");function _s(r){xs(r)}function Yt(){return bs()}let Qt=class{constructor(e,t){Ji(this,"uuid"),this.config=e,this.uuid=t??os()}async send(e){var t,n,i;const{appId:s,sourceType:o}=(t=Yt())!=null?t:{};if(!s||!o)return"metadata missing";const a=new AbortController,c=setTimeout(()=>a.abort(),ts);return await((i=(n=this.config)==null?void 0:n.fetch)!=null?i:fetch)(this.getUrl(),{method:"POST",headers:this.getHeaders(),body:JSON.stringify(this.buildReport(e)),signal:a.signal}),clearTimeout(c),"success"}getUrl(){var e;let t=(e=Yt().proxyUrl)!=null?e:es;return t+=(t.at(-1)==="/"?"":"/")+Zi,t}getHeaders(){return{"Content-Type":"application/json"}}buildReport(e){const t=Yt();return{guid:this.uuid,...e,applicationId:t.appId,timestamp:Date.now(),proxyUrl:t.proxyUrl,source:t.sourceType}}};const dt="3.0.2",qt=class{};qt.updates={transformer_new:"New transformer",transformer_null:"Null transformer"},qt.errors={transformer_none:"No transformers provided",transformer_start:"Cannot start transformer",transformer_transform:"Cannot transform frame",transformer_flush:"Cannot flush transformer",readable_null:"Readable is null",writable_null:"Writable is null"};let le=qt;function Es(r){return typeof r=="object"&&r!==null&&"message"in r&&typeof r.message=="string"}function ws(r){if(Es(r))return r;try{return new Error(JSON.stringify(r))}catch{return new Error(String(r))}}function Kt(r){return ws(r).message}class vs{constructor(e,t){this.config=e,this.frameTransformedCount=0,this.frameFromSourceCount=0,this.startAt=0,this.reporter=new Qt(e,t)}async onFrameFromSource(){this.frameFromSourceCount++}get fps(){const{startAt:e,frameFromSourceCount:t}=this,n=(Date.now()-e)/1e3;return t/n}async onFrameTransformed(e={},t=!1){this.startAt===0&&(this.startAt=Date.now()),this.frameTransformedCount++;const{startAt:n,frameTransformedCount:i,frameFromSourceCount:s}=this,o=Date.now(),a=(o-n)/1e3,c=i/a,u=s/a;return t||this.frameTransformedCount>=this.config.loggingIntervalFrameCount?(this.frameFromSourceCount=0,this.frameTransformedCount=0,this.startAt=o,this.reporter.config=this.config,this.reporter.send({...this.config.report,variation:"QoS",fps:u,transformedFps:c,framesTransformed:i,...e})):"success"}}var Jt=(r=>(r.pipeline_ended="pipeline_ended",r.pipeline_ended_with_error="pipeline_ended_with_error",r.pipeline_started="pipeline_started",r.pipeline_started_with_error="pipeline_started_with_error",r.pipeline_restarted="pipeline_restarted",r.pipeline_restarted_with_error="pipeline_restarted_with_error",r))(Jt||{});const Ts=500,As=.8;class Is extends Y{constructor(e,t){super(),this.reporter_=new Qt,this.reporterQos_=new vs({loggingIntervalFrameCount:Ts,report:{version:dt}}),this.index_=t,this.transformer_=e,this.shouldStop_=!1,this.isFlashed_=!1,this.mediaTransformerQosReportStartTimestamp_=0,this.videoHeight_=0,this.videoWidth_=0,this.trackExpectedRate_=-1,this.transformerType_="Custom","getTransformerType"in e&&(this.transformerType_=e.getTransformerType()),this.report({variation:"Create"})}setTrackExpectedRate(e){this.trackExpectedRate_=e}async start(e){if(this.controller_=e,this.transformer_&&typeof this.transformer_.start=="function")try{await this.transformer_.start(e)}catch(t){this.report({message:le.errors.transformer_start,variation:"Error",error:Kt(t)});const n={eventMetaData:{transformerIndex:this.index_},error:t,function:"start"};this.emit("error",n)}}async transform(e,t){if(this.mediaTransformerQosReportStartTimestamp_===0&&(this.mediaTransformerQosReportStartTimestamp_=Date.now()),e instanceof VideoFrame&&(this.videoHeight_=e?.displayHeight??0,this.videoWidth_=e?.displayWidth??0),this.reporterQos_.onFrameFromSource(),this.transformer_)if(this.shouldStop_)console.warn("[Pipeline] flush from transform"),e.close(),this.flush(t),t.terminate();else{try{await this.transformer_.transform?.(e,t),this.reportQos()}catch(n){this.report({message:le.errors.transformer_transform,variation:"Error",error:Kt(n)});const i={eventMetaData:{transformerIndex:this.index_},error:n,function:"transform"};this.emit("error",i)}if(this.trackExpectedRate_!=-1&&this.trackExpectedRate_*As>this.reporterQos_.fps){const n={eventMetaData:{transformerIndex:this.index_},warningType:"fps_drop",dropInfo:{requested:this.trackExpectedRate_,current:this.reporterQos_.fps}};this.emit("warn",n)}}}async flush(e){if(this.transformer_&&typeof this.transformer_.flush=="function"&&!this.isFlashed_){this.isFlashed_=!0;try{await this.transformer_.flush(e)}catch(t){this.report({message:le.errors.transformer_flush,variation:"Error",error:Kt(t)});const n={eventMetaData:{transformerIndex:this.index_},error:t,function:"flush"};this.emit("error",n)}}this.reportQos(!0),this.report({variation:"Delete"})}stop(){console.log("[Pipeline] Stop stream."),this.controller_&&(this.flush(this.controller_),this.controller_.terminate()),this.shouldStop_=!0}report(e){this.reporter_.send({version:dt,action:"MediaTransformer",transformerType:this.transformerType_,...e})}reportQos(e=!1){this.reporterQos_.config={...this.reporterQos_.config},this.reporterQos_.onFrameTransformed({version:dt,action:"MediaTransformer",transformerType:this.transformerType_,videoWidth:this.videoWidth_,videoHeight:this.videoHeight_},e)}}class Ss extends Y{constructor(e){super(),this.transformers_=[],this.trackExpectedRate_=-1;for(let t=0;t<e.length;t++){let n=new Is(e[t],t);n.on("error",i=>{this.emit("error",i)}),n.on("warn",i=>{this.emit("warn",i)}),this.transformers_.push(n)}}setTrackExpectedRate(e){this.trackExpectedRate_=e;for(let t of this.transformers_)t.setTrackExpectedRate(this.trackExpectedRate_)}async start(e,t){if(!this.transformers_||this.transformers_.length===0){console.log("[Pipeline] No transformers.");return}try{let n=e;for(let i of this.transformers_)e=e.pipeThrough(new TransformStream(i));e.pipeTo(t).then(async()=>{console.log("[Pipeline] Setup."),await t.abort(),await n.cancel(),this.emit("pipelineInfo","pipeline_ended")}).catch(async i=>{e.cancel().then(()=>{console.log("[Pipeline] Shutting down streams after abort.")}).catch(s=>{console.error("[Pipeline] Error from stream transform:",s)}),await t.abort(i),await n.cancel(i),this.emit("pipelineInfo","pipeline_ended_with_error")})}catch{this.emit("pipelineInfo","pipeline_started_with_error"),this.destroy();return}this.emit("pipelineInfo","pipeline_started"),console.log("[Pipeline] Pipeline started.")}async destroy(){console.log("[Pipeline] Destroying Pipeline.");for(let e of this.transformers_)e.stop()}}class Rs extends Y{constructor(){super(),this.reporter_=new Qt,this.trackExpectedRate_=-1,this.report({variation:"Create"})}setTrackExpectedRate(e){this.trackExpectedRate_=e,this.pipeline_&&this.pipeline_.setTrackExpectedRate(this.trackExpectedRate_)}async transform(e,t){if(this.isTrack(e)){if(e.kind==="video"){const n=new MediaStreamTrackProcessor({track:e}),i=new VideoTrackGenerator;return this.readable_=n.readable,this.writable_=i.writable,await this.transformInternal(),i.track}throw Error("Cannot process audio tracks inside a web worker when passing a track to transform")}else return this.readable_=e,this.writable_=t,this.transformInternal()}transformInternal(){return new Promise(async(e,t)=>{if(!this.transformers_||this.transformers_.length===0){this.report({message:le.errors.transformer_none,variation:"Error"}),t("[MediaProcessor] Need to set transformers.");return}if(!this.readable_){this.report({variation:"Error",message:le.errors.readable_null}),t("[MediaProcessor] Readable is null.");return}if(!this.writable_){this.report({variation:"Error",message:le.errors.writable_null}),t("[MediaProcessor] Writable is null.");return}let n=!1;this.pipeline_&&(n=!0,this.pipeline_.clearListeners(),this.pipeline_.destroy()),this.pipeline_=new Ss(this.transformers_),this.pipeline_.on("warn",i=>{this.emit("warn",i)}),this.pipeline_.on("error",i=>{this.emit("error",i)}),this.pipeline_.on("pipelineInfo",i=>{n&&(i==="pipeline_started"?i=Jt.pipeline_restarted:i==="pipeline_started_with_error"&&(i=Jt.pipeline_restarted_with_error)),this.emit("pipelineInfo",i)}),this.trackExpectedRate_!=-1&&this.pipeline_.setTrackExpectedRate(this.trackExpectedRate_),this.pipeline_.start(this.readable_,this.writable_).then(()=>{e()}).catch(i=>{t(i)})})}setTransformers(e){return this.report({variation:"Update",message:le.updates.transformer_new}),this.transformers_=e,this.readable_&&this.writable_?this.transformInternal():Promise.resolve()}destroy(){return new Promise(async e=>{this.pipeline_&&this.pipeline_.destroy(),this.report({variation:"Delete"}),e()})}report(e){this.reporter_.send({version:dt,action:"MediaProcessor",...e})}isTrack(e){return"kind"in e}}var Fs=Object.defineProperty,Ps=(r,e,t)=>e in r?Fs(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ks=(r,e,t)=>(Ps(r,e+"",t),t);const Cs="hlg.tokbox.com/prod/logging/vcp_webrtc",Bs="https://",Ds=1e4;let ht;const Ms=new Uint8Array(16);function Os(){if(!ht&&(ht=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!ht))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ht(Ms)}const P=[];for(let r=0;r<256;++r)P.push((r+256).toString(16).slice(1));function Us(r,e=0){return(P[r[e+0]]+P[r[e+1]]+P[r[e+2]]+P[r[e+3]]+"-"+P[r[e+4]]+P[r[e+5]]+"-"+P[r[e+6]]+P[r[e+7]]+"-"+P[r[e+8]]+P[r[e+9]]+"-"+P[r[e+10]]+P[r[e+11]]+P[r[e+12]]+P[r[e+13]]+P[r[e+14]]+P[r[e+15]]).toLowerCase()}const Ns=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),on={randomUUID:Ns};function Ls(r,e,t){if(on.randomUUID&&!e&&!r)return on.randomUUID();r=r||{};const n=r.random||(r.rng||Os)();return n[6]=n[6]&15|64,n[8]=n[8]&63|128,Us(n)}function Zt(r,e){globalThis.vonage||(globalThis.vonage={}),globalThis.vonage.workerizer||(globalThis.vonage.workerizer={});let t=globalThis.vonage.workerizer;return t[r]||(t[r]=e),t[r]}const ee=Zt("globals",{});var de=(r=>(r.INIT="INIT",r.FORWARD="FORWARD",r.TERMINATE="TERMINATE",r.GLOBALS_SYNC="GLOBALS_SYNC",r))(de||{});function an(r){return[ImageBitmap,ReadableStream,WritableStream].some(e=>r instanceof e)}let zs=0;function Gs(r,e,t,n,i){const s=zs++;return r.postMessage({id:s,type:e,functionName:t,args:n},n.filter(o=>an(o))),new Promise(o=>{i?.set(s,o)})}function Ue(r,e){const{id:t,type:n}=r,i=Array.isArray(e)?e:[e];postMessage({id:t,type:n,result:e},i.filter(s=>an(s)))}const cn=Zt("workerized",{});function un(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}async function $s(){if(un())Ue({type:de.GLOBALS_SYNC},ee);else{const r=[];for(const e in cn){const{worker:t,resolvers:n}=cn[e].workerContext;t&&r.push(Gs(t,de.GLOBALS_SYNC,"",[ee],n))}await Promise.all(r)}}function mt(r,e){if(Array.isArray(e))e.splice(0,e.length);else if(typeof e=="object")for(const t in e)delete e[t];for(const t in r)Array.isArray(r[t])?(e[t]=[],mt(r[t],e[t])):typeof r[t]=="object"?(e[t]={},mt(r[t],e[t])):e[t]=r[t]}async function Ws(r,e){const{functionName:t,args:n}=r;if(!e.instance)throw"instance not initialized";if(!t)throw"missing function name to call";if(!e.instance[t])throw`undefined function [${t}] in class ${e.instance.constructor.workerId}`;Ue(r,await e.instance[t](...n??[]))}const Vs=Zt("registeredWorkers",{});function Hs(r,e){if(!r.args)throw"Missing className while initializing worker";const[t,n]=r.args,i=Vs[t];if(i)e.instance=new i(r.args.slice(1));else throw`unknown worker class ${t}`;mt(n,ee),Ue(r,typeof e.instance!==void 0)}async function js(r,e){const{args:t}=r;if(!e.instance)throw"instance not initialized";let n;e.instance.terminate&&(n=await e.instance.terminate(...t??[])),Ue(r,n)}function Xs(r){if(!r.args)throw"Missing globals while syncing";mt(r.args[0],ee),Ue(r,{})}function Ys(){const r={};onmessage=async e=>{const t=e.data;switch(t.type){case de.INIT:Hs(t,r);break;case de.FORWARD:Ws(t,r);break;case de.TERMINATE:js(t,r);break;case de.GLOBALS_SYNC:Xs(t);break}}}un()&&Ys();function Qs(r,e){return ee[r]||(ee[r]=e),[()=>ee[r],async t=>{ee[r]=t,await $s()}]}function qs(r,e){return Qs(r,e)}const[Ks]=qs("metadata");function er(){return Ks()}class Js{constructor(e){ks(this,"uuid",Ls()),this.config=e}async send(e){var t,n,i;const{appId:s,sourceType:o}=(t=er())!=null?t:{};if(!s||!o)return"metadata missing";const a=new AbortController,c=setTimeout(()=>a.abort(),Ds);return await((i=(n=this.config)==null?void 0:n.fetch)!=null?i:fetch)(this.getUrl(),{method:"POST",headers:this.getHeaders(),body:JSON.stringify(this.buildReport(e)),signal:a.signal}),clearTimeout(c),"success"}getUrl(){var e;let t=(e=er().proxyUrl)!=null?e:Bs;return t+=(t.at(-1)==="/"?"":"/")+Cs,t}getHeaders(){return{"Content-Type":"application/json"}}buildReport(e){const t=er();return{guid:this.uuid,...e,applicationId:t.appId,timestamp:Date.now(),proxyUrl:t.proxyUrl,source:t.sourceType}}}const Zs="7.0.1";var pt=(r=>(r.Low="Low",r.High="High",r))(pt||{}),tr=(r=>(r.FAST="FAST",r.PRECISE="PRECISE",r))(tr||{}),gt=(r=>(r.CANVAS="CANVAS",r.WEBGL="WEBGL",r))(gt||{});function eo(){const e=new OffscreenCanvas(0,0).getContext("webgl2",{failIfMajorPerformanceCaveat:!0});if(e){const t=e?.getExtension("WEBGL_lose_context");t&&t.loseContext()}else return{supported:!1,message:"Your hardware does not perform good enough to run the library efficiently"};return{supported:!0}}class rr{constructor(){const e=new OffscreenCanvas(0,0),t=e.getContext("2d",{willReadFrequently:!0});if(!t)throw"Fail to retrieve 2d context";this.canvas=e,this.context=t}enablePostProcessing(){}disablePostProcessing(){}async profileWebgl(e){return[]}async render(e,t){return this.canvas}resizeCanvas(e){const{width:t,height:n}=e;this.canvas.width=t,this.canvas.height=n}renderSilhouette(e,t,n="none"){const{width:i,height:s}=e;this.context.save(),this.context.drawImage(t,0,0,t.width,t.height,0,0,i,s),this.context.filter="blur(5px)",this.context.globalCompositeOperation="source-in",this.context.drawImage(t,0,0,t.width,t.height,0,0,i,s),this.context.globalCompositeOperation="source-in",this.context.filter=n,this.context.drawImage(e,0,0,i,s,0,0,this.canvas.width,this.canvas.height),this.context.restore()}destroy(){}}class to extends rr{constructor(e){super(),this.radius=e}async render(e,t){super.resizeCanvas(e);const n=await createImageBitmap(t);return this.renderSilhouette(e,n),this.context.save(),this.context.filter=`blur(${this.radius}px)`,this.context.globalCompositeOperation="destination-over",this.context.drawImage(e,0,0,e.width,e.height),this.context.restore(),super.render(e,t)}}class ro extends rr{constructor(e){super(),this.radius=e}async render(e,t){super.resizeCanvas(e);const n=await createImageBitmap(t);return this.renderSilhouette(e,n,`blur(${this.radius}px)`),this.context.save(),this.context.filter="none",this.context.globalCompositeOperation="destination-over",this.context.drawImage(e,0,0,e.width,e.height),this.context.restore(),super.render(e,t)}}class no extends rr{setBackgroundImage(e){this.backgroundImage=e}async render(e,t){super.resizeCanvas(e);const n=await createImageBitmap(t);return this.renderSilhouette(e,n),this.backgroundImage&&(this.context.save(),this.context.filter="none",this.context.globalCompositeOperation="destination-over",this.context.drawImage(this.backgroundImage,0,0,this.backgroundImage.width,this.backgroundImage.height,0,0,e.width,e.height),this.context.restore()),super.render(e,t)}}const nr=5120,Ne=5121,ir=5122,sr=5123,or=5124,ar=5125,cr=5126,io=32819,so=32820,oo=33635,ao=5131,co=33640,uo=35899,fo=35902,lo=36269,ho=34042,fn={};{const r=fn;r[nr]=Int8Array,r[Ne]=Uint8Array,r[ir]=Int16Array,r[sr]=Uint16Array,r[or]=Int32Array,r[ar]=Uint32Array,r[cr]=Float32Array,r[io]=Uint16Array,r[so]=Uint16Array,r[oo]=Uint16Array,r[ao]=Uint16Array,r[co]=Uint32Array,r[uo]=Uint32Array,r[fo]=Uint32Array,r[lo]=Uint32Array,r[ho]=Uint32Array}function ur(r){if(r instanceof Int8Array)return nr;if(r instanceof Uint8Array||r instanceof Uint8ClampedArray)return Ne;if(r instanceof Int16Array)return ir;if(r instanceof Uint16Array)return sr;if(r instanceof Int32Array)return or;if(r instanceof Uint32Array)return ar;if(r instanceof Float32Array)return cr;throw new Error("unsupported typed array type")}function ln(r){if(r===Int8Array)return nr;if(r===Uint8Array||r===Uint8ClampedArray)return Ne;if(r===Int16Array)return ir;if(r===Uint16Array)return sr;if(r===Int32Array)return or;if(r===Uint32Array)return ar;if(r===Float32Array)return cr;throw new Error("unsupported typed array type")}function dn(r){const e=fn[r];if(!e)throw new Error("unknown gl type");return e}const yt=typeof SharedArrayBuffer<"u"?function(e){return e&&e.buffer&&(e.buffer instanceof ArrayBuffer||e.buffer instanceof SharedArrayBuffer)}:function(e){return e&&e.buffer&&e.buffer instanceof ArrayBuffer};function hn(...r){console.error(...r)}const mn=new Map;function bt(r,e){if(!r||typeof r!="object")return!1;let t=mn.get(e);t||(t=new WeakMap,mn.set(e,t));let n=t.get(r);if(n===void 0){const i=Object.prototype.toString.call(r);n=i.substring(8,i.length-1)===e,t.set(r,n)}return n}function mo(r,e){return typeof WebGLBuffer<"u"&&bt(e,"WebGLBuffer")}function po(r,e){return typeof WebGLRenderbuffer<"u"&&bt(e,"WebGLRenderbuffer")}function fr(r,e){return typeof WebGLTexture<"u"&&bt(e,"WebGLTexture")}function go(r,e){return typeof WebGLSampler<"u"&&bt(e,"WebGLSampler")}const pn=35044,he=34962,yo=34963,bo=34660,xo=5120,_o=5121,Eo=5122,wo=5123,vo=5124,To=5125,gn=5126,yn={attribPrefix:""};function Ao(r,e,t,n,i){r.bindBuffer(e,t),r.bufferData(e,n,i||pn)}function bn(r,e,t,n){if(mo(r,e))return e;t=t||he;const i=r.createBuffer();return Ao(r,t,i,e,n),i}function xn(r){return r==="indices"}function Io(r){return r===Int8Array||r===Uint8Array}function So(r){return r.length?r:r.data}const Ro=/coord|texture/i,Fo=/color|colour/i;function Po(r,e){let t;if(Ro.test(r)?t=2:Fo.test(r)?t=4:t=3,e%t>0)throw new Error(`Can not guess numComponents for attribute \'${r}\'. Tried ${t} but ${e} values is not evenly divisible by ${t}. You should specify it.`);return t}function ko(r,e,t){return r.numComponents||r.size||Po(e,t||So(r).length)}function _n(r,e){if(yt(r))return r;if(yt(r.data))return r.data;Array.isArray(r)&&(r={data:r});let t=r.type?lr(r.type):void 0;return t||(xn(e)?t=Uint16Array:t=Float32Array),new t(r.data)}function Co(r){return typeof r=="number"?r:r?ln(r):gn}function lr(r){return typeof r=="number"?dn(r):r||Float32Array}function Bo(r,e){return{buffer:e.buffer,numValues:24,type:Co(e.type),arrayType:lr(e.type)}}function Do(r,e){const t=e.data||e,n=lr(e.type),i=t*n.BYTES_PER_ELEMENT,s=r.createBuffer();return r.bindBuffer(he,s),r.bufferData(he,i,e.drawType||pn),{buffer:s,numValues:t,type:ln(n),arrayType:n}}function Mo(r,e,t){const n=_n(e,t);return{arrayType:n.constructor,buffer:bn(r,n,void 0,e.drawType),type:ur(n),numValues:0}}function Oo(r,e){const t={};return Object.keys(e).forEach(function(n){if(!xn(n)){const i=e[n],s=i.attrib||i.name||i.attribName||yn.attribPrefix+n;if(i.value){if(!Array.isArray(i.value)&&!yt(i.value))throw new Error("array.value is not array or typedarray");t[s]={value:i.value}}else{let o;i.buffer&&i.buffer instanceof WebGLBuffer?o=Bo:typeof i=="number"||typeof i.data=="number"?o=Do:o=Mo;const{buffer:a,type:c,numValues:u,arrayType:d}=o(r,i,n),m=i.normalize!==void 0?i.normalize:Io(d),p=ko(i,n,u);t[s]={buffer:a,numComponents:p,type:c,normalize:m,stride:i.stride||0,offset:i.offset||0,divisor:i.divisor===void 0?void 0:i.divisor,drawType:i.drawType}}}}),r.bindBuffer(he,null),t}function Uo(r,e){return e===xo||e===_o?1:e===Eo||e===wo?2:e===vo||e===To||e===gn?4:0}const dr=["position","positions","a_position"];function No(r,e){let t,n;for(n=0;n<dr.length&&(t=dr[n],!(t in e||(t=yn.attribPrefix+t,t in e)));++n);n===dr.length&&(t=Object.keys(e)[0]);const i=e[t];if(!i.buffer)return 1;r.bindBuffer(he,i.buffer);const s=r.getBufferParameter(he,bo);r.bindBuffer(he,null);const o=Uo(r,i.type),a=s/o,c=i.numComponents||i.size,u=a/c;if(u%1!==0)throw new Error(`numComponents ${c} not correct for length ${length}`);return u}function Lo(r,e,t){const n=Oo(r,e),i=Object.assign({},t||{});i.attribs=Object.assign({},t?t.attribs:{},n);const s=e.indices;if(s){const o=_n(s,"indices");i.indices=bn(r,o,yo),i.numElements=o.length,i.elementType=ur(o)}else i.numElements||(i.numElements=No(r,i.attribs));return i}function Le(r){return!!r.texStorage2D}const En=(function(){const r={},e={};function t(n){const i=n.constructor.name;if(!r[i]){for(const s in n)if(typeof n[s]=="number"){const o=e[n[s]];e[n[s]]=o?`${o} | ${s}`:s}r[i]=!0}}return function(i,s){return t(i),e[s]||(typeof s=="number"?`0x${s.toString(16)}`:s)}})(),te={textureColor:new Uint8Array([128,192,255,255]),textureOptions:{},crossOrigin:void 0},ze=yt,wn=(function(){let r;return function(){return r=r||(typeof document<"u"&&document.createElement?document.createElement("canvas").getContext("2d"):null),r}})(),vn=6406,V=6407,A=6408,Tn=6409,An=6410,Ge=6402,In=34041,xt=33071,zo=9728,Go=9729,re=3553,ne=34067,me=32879,pe=35866,hr=34069,$o=34070,Wo=34071,Vo=34072,Ho=34073,jo=34074,mr=10241,pr=10240,_t=10242,Et=10243,Sn=32882,Xo=33082,Yo=33083,Qo=33084,qo=33085,Ko=34892,Jo=34893,gr=3317,Rn=3314,Fn=32878,Pn=3316,kn=3315,Cn=32877,Zo=37443,ea=37441,ta=37440,ra=33321,na=36756,ia=33325,sa=33326,oa=33330,aa=33329,ca=33338,ua=33337,fa=33340,la=33339,da=33323,ha=36757,ma=33327,pa=33328,ga=33336,ya=33335,ba=33332,xa=33331,_a=33334,Ea=33333,wa=32849,va=35905,Ta=36194,Aa=36758,Ia=35898,Sa=35901,Ra=34843,Fa=34837,Pa=36221,ka=36239,Ca=36215,Ba=36233,Da=36209,Ma=36227,Oa=32856,Ua=35907,Na=36759,La=32855,za=32854,Ga=32857,$a=34842,Wa=34836,Va=36220,Ha=36238,ja=36975,Xa=36214,Ya=36232,Qa=36226,qa=36208,Ka=33189,Ja=33190,Za=36012,ec=36013,tc=35056,ie=5120,T=5121,wt=5122,Se=5123,vt=5124,ge=5125,B=5126,Bn=32819,Dn=32820,Mn=33635,z=5131,$e=36193,yr=33640,rc=35899,nc=35902,ic=36269,sc=34042,Tt=33319,Re=33320,At=6403,Fe=36244,Pe=36248,ye=36249;let br;function It(r){if(!br){const e={};e[vn]={textureFormat:vn,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1,2,2,4],type:[T,z,$e,B]},e[Tn]={textureFormat:Tn,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1,2,2,4],type:[T,z,$e,B]},e[An]={textureFormat:An,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[2,4,4,8],type:[T,z,$e,B]},e[V]={textureFormat:V,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3,6,6,12,2],type:[T,z,$e,B,Mn]},e[A]={textureFormat:A,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,8,8,16,2,2],type:[T,z,$e,B,Bn,Dn]},e[Ge]={textureFormat:Ge,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2,4],type:[ge,Se]},e[ra]={textureFormat:At,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1],type:[T]},e[na]={textureFormat:At,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[1],type:[ie]},e[ia]={textureFormat:At,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[4,2],type:[B,z]},e[sa]={textureFormat:At,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[4],type:[B]},e[oa]={textureFormat:Fe,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[1],type:[T]},e[aa]={textureFormat:Fe,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[1],type:[ie]},e[ba]={textureFormat:Fe,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[Se]},e[xa]={textureFormat:Fe,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[wt]},e[_a]={textureFormat:Fe,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[ge]},e[Ea]={textureFormat:Fe,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[vt]},e[da]={textureFormat:Tt,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[2],type:[T]},e[ha]={textureFormat:Tt,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[2],type:[ie]},e[ma]={textureFormat:Tt,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[8,4],type:[B,z]},e[pa]={textureFormat:Tt,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[8],type:[B]},e[ga]={textureFormat:Re,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[T]},e[ya]={textureFormat:Re,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[ie]},e[ca]={textureFormat:Re,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[Se]},e[ua]={textureFormat:Re,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[wt]},e[fa]={textureFormat:Re,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[ge]},e[la]={textureFormat:Re,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[vt]},e[wa]={textureFormat:V,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3],type:[T]},e[va]={textureFormat:V,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[3],type:[T]},e[Ta]={textureFormat:V,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3,2],type:[T,Mn]},e[Aa]={textureFormat:V,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[3],type:[ie]},e[Ia]={textureFormat:V,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6,4],type:[B,z,rc]},e[Sa]={textureFormat:V,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6,4],type:[B,z,nc]},e[Ra]={textureFormat:V,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6],type:[B,z]},e[Fa]={textureFormat:V,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[B]},e[Pa]={textureFormat:Pe,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[3],type:[T]},e[ka]={textureFormat:Pe,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[3],type:[ie]},e[Ca]={textureFormat:Pe,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[6],type:[Se]},e[Ba]={textureFormat:Pe,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[6],type:[wt]},e[Da]={textureFormat:Pe,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[ge]},e[Ma]={textureFormat:Pe,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[vt]},e[Oa]={textureFormat:A,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[T]},e[Ua]={textureFormat:A,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[T]},e[Na]={textureFormat:A,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[4],type:[ie]},e[La]={textureFormat:A,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,2,4],type:[T,Dn,yr]},e[za]={textureFormat:A,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,2],type:[T,Bn]},e[Ga]={textureFormat:A,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[yr]},e[$a]={textureFormat:A,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[16,8],type:[B,z]},e[Wa]={textureFormat:A,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[16],type:[B]},e[Va]={textureFormat:ye,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[T]},e[Ha]={textureFormat:ye,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[ie]},e[ja]={textureFormat:ye,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[yr]},e[Xa]={textureFormat:ye,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[Se]},e[Ya]={textureFormat:ye,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[wt]},e[Qa]={textureFormat:ye,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[16],type:[vt]},e[qa]={textureFormat:ye,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[16],type:[ge]},e[Ka]={textureFormat:Ge,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2,4],type:[Se,ge]},e[Ja]={textureFormat:Ge,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[ge]},e[Za]={textureFormat:Ge,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[B]},e[tc]={textureFormat:In,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[sc]},e[ec]={textureFormat:In,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[ic]},Object.keys(e).forEach(function(t){const n=e[t];n.bytesPerElementMap={},n.bytesPerElement.forEach(function(i,s){const o=n.type[s];n.bytesPerElementMap[o]=i})}),br=e}return br[r]}function oc(r,e){const t=It(r);if(!t)throw"unknown internal format";const n=t.bytesPerElementMap[e];if(n===void 0)throw"unknown internal format";return n}function We(r){const e=It(r);if(!e)throw"unknown internal format";return{format:e.textureFormat,type:e.type[0]}}function On(r){return(r&r-1)===0}function ac(r,e,t,n){if(!Le(r))return On(e)&&On(t);const i=It(n);if(!i)throw"unknown internal format";return i.colorRenderable&&i.textureFilterable}function cc(r){const e=It(r);if(!e)throw"unknown internal format";return e.textureFilterable}function uc(r,e,t){return ze(e)?ur(e):t||T}function St(r,e,t,n,i){if(i%1!==0)throw"can\'t guess dimensions";if(!t&&!n){const s=Math.sqrt(i/(e===ne?6:1));s%1===0?(t=s,n=s):(t=i,n=1)}else if(n){if(!t&&(t=i/n,t%1))throw"can\'t guess dimensions"}else if(n=i/t,n%1)throw"can\'t guess dimensions";return{width:t,height:n}}function ke(r,e){e.colorspaceConversion!==void 0&&r.pixelStorei(Zo,e.colorspaceConversion),e.premultiplyAlpha!==void 0&&r.pixelStorei(ea,e.premultiplyAlpha),e.flipY!==void 0&&r.pixelStorei(ta,e.flipY)}function Un(r){r.pixelStorei(gr,4),Le(r)&&(r.pixelStorei(Rn,0),r.pixelStorei(Fn,0),r.pixelStorei(Pn,0),r.pixelStorei(kn,0),r.pixelStorei(Cn,0))}function fc(r,e,t,n){n.minMag&&(t.call(r,e,mr,n.minMag),t.call(r,e,pr,n.minMag)),n.min&&t.call(r,e,mr,n.min),n.mag&&t.call(r,e,pr,n.mag),n.wrap&&(t.call(r,e,_t,n.wrap),t.call(r,e,Et,n.wrap),(e===me||go(r,e))&&t.call(r,e,Sn,n.wrap)),n.wrapR&&t.call(r,e,Sn,n.wrapR),n.wrapS&&t.call(r,e,_t,n.wrapS),n.wrapT&&t.call(r,e,Et,n.wrapT),n.minLod!==void 0&&t.call(r,e,Xo,n.minLod),n.maxLod!==void 0&&t.call(r,e,Yo,n.maxLod),n.baseLevel!==void 0&&t.call(r,e,Qo,n.baseLevel),n.maxLevel!==void 0&&t.call(r,e,qo,n.maxLevel),n.compareFunc!==void 0&&t.call(r,e,Jo,n.compareFunc),n.compareMode!==void 0&&t.call(r,e,Ko,n.compareMode)}function Nn(r,e,t){const n=t.target||re;r.bindTexture(n,e),fc(r,n,r.texParameteri,t)}function lc(r){return r=r||te.textureColor,ze(r)?r:new Uint8Array([r[0]*255,r[1]*255,r[2]*255,r[3]*255])}function xr(r,e,t,n,i,s){t=t||te.textureOptions,s=s||A;const o=t.target||re;if(n=n||t.width,i=i||t.height,r.bindTexture(o,e),ac(r,n,i,s))r.generateMipmap(o);else{const a=cc(s)?Go:zo;r.texParameteri(o,mr,a),r.texParameteri(o,pr,a),r.texParameteri(o,_t,xt),r.texParameteri(o,Et,xt)}}function Ve(r){return r.auto===!0||r.auto===void 0&&r.level===void 0}function _r(r,e){return e=e||{},e.cubeFaceOrder||[hr,$o,Wo,Vo,Ho,jo]}function Er(r,e){const n=_r(r,e).map(function(i,s){return{face:i,ndx:s}});return n.sort(function(i,s){return i.face-s.face}),n}function Ln(r,e,t,n){n=n||te.textureOptions;const i=n.target||re,s=n.level||0;let o=t.width,a=t.height;const c=n.internalFormat||n.format||A,u=We(c),d=n.format||u.format,m=n.type||u.type;if(ke(r,n),r.bindTexture(i,e),i===ne){const p=t.width,y=t.height;let l,b;if(p/6===y)l=y,b=[0,0,1,0,2,0,3,0,4,0,5,0];else if(y/6===p)l=p,b=[0,0,0,1,0,2,0,3,0,4,0,5];else if(p/3===y/2)l=p/3,b=[0,0,1,0,2,0,0,1,1,1,2,1];else if(p/2===y/3)l=p/2,b=[0,0,1,0,0,1,1,1,0,2,1,2];else throw"can\'t figure out cube map from element: "+(t.src?t.src:t.nodeName);const _=wn();_?(_.canvas.width=l,_.canvas.height=l,o=l,a=l,Er(r,n).forEach(function(E){const R=b[E.ndx*2+0]*l,k=b[E.ndx*2+1]*l;_.drawImage(t,R,k,l,l,0,0,l,l),r.texImage2D(E.face,s,c,d,m,_.canvas)}),_.canvas.width=1,_.canvas.height=1):typeof createImageBitmap<"u"&&(o=l,a=l,Er(r,n).forEach(function(E){const R=b[E.ndx*2+0]*l,k=b[E.ndx*2+1]*l;r.texImage2D(E.face,s,c,l,l,0,d,m,null),createImageBitmap(t,R,k,l,l,{premultiplyAlpha:"none",colorSpaceConversion:"none"}).then(function(N){ke(r,n),r.bindTexture(i,e),r.texImage2D(E.face,s,c,d,m,N),Ve(n)&&xr(r,e,n,o,a,c)})}))}else if(i===me||i===pe){const p=Math.min(t.width,t.height),y=Math.max(t.width,t.height),l=y/p;if(l%1!==0)throw"can not compute 3D dimensions of element";const b=t.width===y?1:0,_=t.height===y?1:0;r.pixelStorei(gr,1),r.pixelStorei(Rn,t.width),r.pixelStorei(Fn,0),r.pixelStorei(Cn,0),r.texImage3D(i,s,c,p,p,p,0,d,m,null);for(let E=0;E<l;++E){const R=E*p*b,k=E*p*_;r.pixelStorei(Pn,R),r.pixelStorei(kn,k),r.texSubImage3D(i,s,0,0,E,p,p,1,d,m,t)}Un(r)}else r.texImage2D(i,s,c,d,m,t);Ve(n)&&xr(r,e,n,o,a,c),Nn(r,e,n)}function He(){}function dc(r){if(typeof document<"u"){const e=document.createElement("a");return e.href=r,e.hostname===location.hostname&&e.port===location.port&&e.protocol===location.protocol}else{const e=new URL(location.href).origin;return new URL(r,location.href).origin===e}}function hc(r,e){return e===void 0&&!dc(r)?"anonymous":e}function mc(r,e,t){t=t||He;let n;if(e=e!==void 0?e:te.crossOrigin,e=hc(r,e),typeof Image<"u"){n=new Image,e!==void 0&&(n.crossOrigin=e);const i=function(){n.removeEventListener("error",s),n.removeEventListener("load",o),n=null},s=function(){const c="couldn\'t load image: "+r;hn(c),t(c,n),i()},o=function(){t(null,n),i()};return n.addEventListener("error",s),n.addEventListener("load",o),n.src=r,n}else if(typeof ImageBitmap<"u"){let i,s;const o=function(){t(i,s)},a={};e&&(a.mode="cors"),fetch(r,a).then(function(c){if(!c.ok)throw c;return c.blob()}).then(function(c){return createImageBitmap(c,{premultiplyAlpha:"none",colorSpaceConversion:"none"})}).then(function(c){s=c,setTimeout(o)}).catch(function(c){i=c,setTimeout(o)}),n=null}return n}function zn(r){return typeof ImageBitmap<"u"&&r instanceof ImageBitmap||typeof ImageData<"u"&&r instanceof ImageData||typeof HTMLElement<"u"&&r instanceof HTMLElement}function wr(r,e,t){return zn(r)?(setTimeout(function(){t(null,r)}),r):mc(r,e,t)}function vr(r,e,t){t=t||te.textureOptions;const n=t.target||re;if(r.bindTexture(n,e),t.color===!1)return;const i=lc(t.color);if(n===ne)for(let s=0;s<6;++s)r.texImage2D(hr+s,0,A,1,1,0,A,T,i);else n===me||n===pe?r.texImage3D(n,0,A,1,1,1,0,A,T,i):r.texImage2D(n,0,A,1,1,0,A,T,i)}function pc(r,e,t,n){return n=n||He,t=t||te.textureOptions,vr(r,e,t),t=Object.assign({},t),wr(t.src,t.crossOrigin,function(s,o){s?n(s,e,o):(Ln(r,e,o,t),n(null,e,o))})}function gc(r,e,t,n){n=n||He;const i=t.src;if(i.length!==6)throw"there must be 6 urls for a cubemap";const s=t.level||0,o=t.internalFormat||t.format||A,a=We(o),c=t.format||a.format,u=t.type||T,d=t.target||re;if(d!==ne)throw"target must be TEXTURE_CUBE_MAP";vr(r,e,t),t=Object.assign({},t);let m=6;const p=[],y=_r(r,t);let l;function b(_){return function(E,R){--m,E?p.push(E):R.width!==R.height?p.push("cubemap face img is not a square: "+R.src):(ke(r,t),r.bindTexture(d,e),m===5?_r().forEach(function(k){r.texImage2D(k,s,o,c,u,R)}):r.texImage2D(_,s,o,c,u,R),Ve(t)&&r.generateMipmap(d)),m===0&&n(p.length?p:void 0,e,l)}}l=i.map(function(_,E){return wr(_,t.crossOrigin,b(y[E]))})}function yc(r,e,t,n){n=n||He;const i=t.src,s=t.internalFormat||t.format||A,o=We(s),a=t.format||o.format,c=t.type||T,u=t.target||pe;if(u!==me&&u!==pe)throw"target must be TEXTURE_3D or TEXTURE_2D_ARRAY";vr(r,e,t),t=Object.assign({},t);let d=i.length;const m=[];let p;const y=t.level||0;let l=t.width,b=t.height;const _=i.length;let E=!0;function R(k){return function(N,Q){if(--d,N)m.push(N);else{if(ke(r,t),r.bindTexture(u,e),E){E=!1,l=t.width||Q.width,b=t.height||Q.height,r.texImage3D(u,y,s,l,b,_,0,a,c,null);for(let q=0;q<_;++q)r.texSubImage3D(u,y,0,0,q,l,b,1,a,c,Q)}else{let q=Q,L;(Q.width!==l||Q.height!==b)&&(L=wn(),q=L.canvas,L.canvas.width=l,L.canvas.height=b,L.drawImage(Q,0,0,l,b)),r.texSubImage3D(u,y,0,0,k,l,b,1,a,c,q),L&&q===L.canvas&&(L.canvas.width=0,L.canvas.height=0)}Ve(t)&&r.generateMipmap(u)}d===0&&n(m.length?m:void 0,e,p)}}p=i.map(function(k,N){return wr(k,t.crossOrigin,R(N))})}function bc(r,e,t,n){n=n||te.textureOptions;const i=n.target||re;r.bindTexture(i,e);let s=n.width,o=n.height,a=n.depth;const c=n.level||0,u=n.internalFormat||n.format||A,d=We(u),m=n.format||d.format,p=n.type||uc(r,t,d.type);if(ze(t))t instanceof Uint8ClampedArray&&(t=new Uint8Array(t.buffer));else{const _=dn(p);t=new _(t)}const y=oc(u,p),l=t.byteLength/y;if(l%1)throw"length wrong size for format: "+En(r,m);let b;if(i===me||i===pe)if(!s&&!o&&!a){const _=Math.cbrt(l);if(_%1!==0)throw"can\'t guess cube size of array of numElements: "+l;s=_,o=_,a=_}else s&&(!o||!a)?(b=St(r,i,o,a,l/s),o=b.width,a=b.height):o&&(!s||!a)?(b=St(r,i,s,a,l/o),s=b.width,a=b.height):(b=St(r,i,s,o,l/a),s=b.width,o=b.height);else b=St(r,i,s,o,l),s=b.width,o=b.height;if(Un(r),r.pixelStorei(gr,n.unpackAlignment||1),ke(r,n),i===ne){const _=y/t.BYTES_PER_ELEMENT,E=l/6*_;Er(r,n).forEach(R=>{const k=E*R.ndx,N=t.subarray(k,k+E);r.texImage2D(R.face,c,u,s,o,0,m,p,N)})}else i===me||i===pe?r.texImage3D(i,c,u,s,o,a,0,m,p,t):r.texImage2D(i,c,u,s,o,0,m,p,t);return{width:s,height:o,depth:a,type:p}}function xc(r,e,t){const n=t.target||re;r.bindTexture(n,e);const i=t.level||0,s=t.internalFormat||t.format||A,o=We(s),a=t.format||o.format,c=t.type||o.type;if(ke(r,t),n===ne)for(let u=0;u<6;++u)r.texImage2D(hr+u,i,s,t.width,t.height,0,a,c,null);else n===me||n===pe?r.texImage3D(n,i,s,t.width,t.height,t.depth,0,a,c,null):r.texImage2D(n,i,s,t.width,t.height,0,a,c,null)}function Gn(r,e,t){t=t||He,e=e||te.textureOptions;const n=r.createTexture(),i=e.target||re;let s=e.width||1,o=e.height||1;const a=e.internalFormat||A;r.bindTexture(i,n),i===ne&&(r.texParameteri(i,_t,xt),r.texParameteri(i,Et,xt));let c=e.src;if(c)if(typeof c=="function"&&(c=c(r,e)),typeof c=="string")pc(r,n,e,t);else if(ze(c)||Array.isArray(c)&&(typeof c[0]=="number"||Array.isArray(c[0])||ze(c[0]))){const u=bc(r,n,c,e);s=u.width,o=u.height}else Array.isArray(c)&&(typeof c[0]=="string"||zn(c[0]))?i===ne?gc(r,n,e,t):yc(r,n,e,t):(Ln(r,n,c,e),s=c.width,o=c.height);else xc(r,n,e);return Ve(e)&&xr(r,n,e,s,o,a),Nn(r,n,e),n}const Tr=hn;function $n(r){return typeof document<"u"&&document.getElementById?document.getElementById(r):null}const Rt=33984,Ft=34962,_c=34963,Ec=35713,wc=35714,vc=35632,Tc=35633,Ac=35981,Wn=35718,Ic=35721,Sc=35971,Rc=35382,Fc=35396,Pc=35398,kc=35392,Cc=35395,Pt=5126,Vn=35664,Hn=35665,jn=35666,Ar=5124,Xn=35667,Yn=35668,Qn=35669,qn=35670,Kn=35671,Jn=35672,Zn=35673,ei=35674,ti=35675,ri=35676,Bc=35678,Dc=35680,Mc=35679,Oc=35682,Uc=35685,Nc=35686,Lc=35687,zc=35688,Gc=35689,$c=35690,Wc=36289,Vc=36292,Hc=36293,Ir=5125,ni=36294,ii=36295,si=36296,jc=36298,Xc=36299,Yc=36300,Qc=36303,qc=36306,Kc=36307,Jc=36308,Zc=36311,kt=3553,Ct=34067,Sr=32879,Bt=35866,x={};function oi(r,e){return x[e].bindPoint}function eu(r,e){return function(t){r.uniform1f(e,t)}}function tu(r,e){return function(t){r.uniform1fv(e,t)}}function ru(r,e){return function(t){r.uniform2fv(e,t)}}function nu(r,e){return function(t){r.uniform3fv(e,t)}}function iu(r,e){return function(t){r.uniform4fv(e,t)}}function ai(r,e){return function(t){r.uniform1i(e,t)}}function ci(r,e){return function(t){r.uniform1iv(e,t)}}function ui(r,e){return function(t){r.uniform2iv(e,t)}}function fi(r,e){return function(t){r.uniform3iv(e,t)}}function li(r,e){return function(t){r.uniform4iv(e,t)}}function su(r,e){return function(t){r.uniform1ui(e,t)}}function ou(r,e){return function(t){r.uniform1uiv(e,t)}}function au(r,e){return function(t){r.uniform2uiv(e,t)}}function cu(r,e){return function(t){r.uniform3uiv(e,t)}}function uu(r,e){return function(t){r.uniform4uiv(e,t)}}function fu(r,e){return function(t){r.uniformMatrix2fv(e,!1,t)}}function lu(r,e){return function(t){r.uniformMatrix3fv(e,!1,t)}}function du(r,e){return function(t){r.uniformMatrix4fv(e,!1,t)}}function hu(r,e){return function(t){r.uniformMatrix2x3fv(e,!1,t)}}function mu(r,e){return function(t){r.uniformMatrix3x2fv(e,!1,t)}}function pu(r,e){return function(t){r.uniformMatrix2x4fv(e,!1,t)}}function gu(r,e){return function(t){r.uniformMatrix4x2fv(e,!1,t)}}function yu(r,e){return function(t){r.uniformMatrix3x4fv(e,!1,t)}}function bu(r,e){return function(t){r.uniformMatrix4x3fv(e,!1,t)}}function O(r,e,t,n){const i=oi(r,e);return Le(r)?function(s){let o,a;!s||fr(r,s)?(o=s,a=null):(o=s.texture,a=s.sampler),r.uniform1i(n,t),r.activeTexture(Rt+t),r.bindTexture(i,o),r.bindSampler(t,a)}:function(s){r.uniform1i(n,t),r.activeTexture(Rt+t),r.bindTexture(i,s)}}function U(r,e,t,n,i){const s=oi(r,e),o=new Int32Array(i);for(let a=0;a<i;++a)o[a]=t+a;return Le(r)?function(a){r.uniform1iv(n,o),a.forEach(function(c,u){r.activeTexture(Rt+o[u]);let d,m;!c||fr(r,c)?(d=c,m=null):(d=c.texture,m=c.sampler),r.bindSampler(t,m),r.bindTexture(s,d)})}:function(a){r.uniform1iv(n,o),a.forEach(function(c,u){r.activeTexture(Rt+o[u]),r.bindTexture(s,c)})}}x[Pt]={Type:Float32Array,size:4,setter:eu,arraySetter:tu},x[Vn]={Type:Float32Array,size:8,setter:ru,cols:2},x[Hn]={Type:Float32Array,size:12,setter:nu,cols:3},x[jn]={Type:Float32Array,size:16,setter:iu,cols:4},x[Ar]={Type:Int32Array,size:4,setter:ai,arraySetter:ci},x[Xn]={Type:Int32Array,size:8,setter:ui,cols:2},x[Yn]={Type:Int32Array,size:12,setter:fi,cols:3},x[Qn]={Type:Int32Array,size:16,setter:li,cols:4},x[Ir]={Type:Uint32Array,size:4,setter:su,arraySetter:ou},x[ni]={Type:Uint32Array,size:8,setter:au,cols:2},x[ii]={Type:Uint32Array,size:12,setter:cu,cols:3},x[si]={Type:Uint32Array,size:16,setter:uu,cols:4},x[qn]={Type:Uint32Array,size:4,setter:ai,arraySetter:ci},x[Kn]={Type:Uint32Array,size:8,setter:ui,cols:2},x[Jn]={Type:Uint32Array,size:12,setter:fi,cols:3},x[Zn]={Type:Uint32Array,size:16,setter:li,cols:4},x[ei]={Type:Float32Array,size:32,setter:fu,rows:2,cols:2},x[ti]={Type:Float32Array,size:48,setter:lu,rows:3,cols:3},x[ri]={Type:Float32Array,size:64,setter:du,rows:4,cols:4},x[Uc]={Type:Float32Array,size:32,setter:hu,rows:2,cols:3},x[Nc]={Type:Float32Array,size:32,setter:pu,rows:2,cols:4},x[Lc]={Type:Float32Array,size:48,setter:mu,rows:3,cols:2},x[zc]={Type:Float32Array,size:48,setter:yu,rows:3,cols:4},x[Gc]={Type:Float32Array,size:64,setter:gu,rows:4,cols:2},x[$c]={Type:Float32Array,size:64,setter:bu,rows:4,cols:3},x[Bc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:kt},x[Dc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Ct},x[Mc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Sr},x[Oc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:kt},x[Wc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Bt},x[Vc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Bt},x[Hc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Ct},x[jc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:kt},x[Xc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Sr},x[Yc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Ct},x[Qc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Bt},x[qc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:kt},x[Kc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Sr},x[Jc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Ct},x[Zc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Bt};function Dt(r,e){return function(t){if(t.value)switch(r.disableVertexAttribArray(e),t.value.length){case 4:r.vertexAttrib4fv(e,t.value);break;case 3:r.vertexAttrib3fv(e,t.value);break;case 2:r.vertexAttrib2fv(e,t.value);break;case 1:r.vertexAttrib1fv(e,t.value);break;default:throw new Error("the length of a float constant value must be between 1 and 4!")}else r.bindBuffer(Ft,t.buffer),r.enableVertexAttribArray(e),r.vertexAttribPointer(e,t.numComponents||t.size,t.type||Pt,t.normalize||!1,t.stride||0,t.offset||0),r.vertexAttribDivisor&&r.vertexAttribDivisor(e,t.divisor||0)}}function se(r,e){return function(t){if(t.value)if(r.disableVertexAttribArray(e),t.value.length===4)r.vertexAttrib4iv(e,t.value);else throw new Error("The length of an integer constant value must be 4!");else r.bindBuffer(Ft,t.buffer),r.enableVertexAttribArray(e),r.vertexAttribIPointer(e,t.numComponents||t.size,t.type||Ar,t.stride||0,t.offset||0),r.vertexAttribDivisor&&r.vertexAttribDivisor(e,t.divisor||0)}}function Mt(r,e){return function(t){if(t.value)if(r.disableVertexAttribArray(e),t.value.length===4)r.vertexAttrib4uiv(e,t.value);else throw new Error("The length of an unsigned integer constant value must be 4!");else r.bindBuffer(Ft,t.buffer),r.enableVertexAttribArray(e),r.vertexAttribIPointer(e,t.numComponents||t.size,t.type||Ir,t.stride||0,t.offset||0),r.vertexAttribDivisor&&r.vertexAttribDivisor(e,t.divisor||0)}}function Rr(r,e,t){const n=t.size,i=t.count;return function(s){r.bindBuffer(Ft,s.buffer);const o=s.size||s.numComponents||n,a=o/i,c=s.type||Pt,d=x[c].size*o,m=s.normalize||!1,p=s.offset||0,y=d/i;for(let l=0;l<i;++l)r.enableVertexAttribArray(e+l),r.vertexAttribPointer(e+l,a,c,m,d,p+y*l),r.vertexAttribDivisor&&r.vertexAttribDivisor(e+l,s.divisor||0)}}const I={};I[Pt]={size:4,setter:Dt},I[Vn]={size:8,setter:Dt},I[Hn]={size:12,setter:Dt},I[jn]={size:16,setter:Dt},I[Ar]={size:4,setter:se},I[Xn]={size:8,setter:se},I[Yn]={size:12,setter:se},I[Qn]={size:16,setter:se},I[Ir]={size:4,setter:Mt},I[ni]={size:8,setter:Mt},I[ii]={size:12,setter:Mt},I[si]={size:16,setter:Mt},I[qn]={size:4,setter:se},I[Kn]={size:8,setter:se},I[Jn]={size:12,setter:se},I[Zn]={size:16,setter:se},I[ei]={size:4,setter:Rr,count:2},I[ti]={size:9,setter:Rr,count:3},I[ri]={size:16,setter:Rr,count:4};const xu=/ERROR:\\s*\\d+:(\\d+)/gi;function _u(r,e="",t=0){const n=[...e.matchAll(xu)],i=new Map(n.map((s,o)=>{const a=parseInt(s[1]),c=n[o+1],u=c?c.index:e.length,d=e.substring(s.index,u);return[a-1,d]}));return r.split(`\n`).map((s,o)=>{const a=i.get(o);return`${o+1+t}: ${s}${a?`\n\n^^^ ${a}`:""}`}).join(`\n`)}const di=/^[ \\t]*\\n/;function hi(r){let e=0;return di.test(r)&&(e=1,r=r.replace(di,"")),{lineOffset:e,shaderSource:r}}function Eu(r,e){return r.errorCallback(e),r.callback&&setTimeout(()=>{r.callback(`${e}\n${r.errors.join(`\n`)}`)}),null}function wu(r,e,t,n){if(n=n||Tr,!r.getShaderParameter(t,Ec)){const s=r.getShaderInfoLog(t),{lineOffset:o,shaderSource:a}=hi(r.getShaderSource(t)),c=`${_u(a,s,o)}\nError compiling ${En(r,e)}: ${s}`;return n(c),c}return""}function Fr(r,e,t){let n,i,s;if(typeof e=="function"&&(t=e,e=void 0),typeof r=="function")t=r,r=void 0;else if(r&&!Array.isArray(r)){const u=r;t=u.errorCallback,r=u.attribLocations,n=u.transformFeedbackVaryings,i=u.transformFeedbackMode,s=u.callback}const o=t||Tr,a=[],c={errorCallback(u,...d){a.push(u),o(u,...d)},transformFeedbackVaryings:n,transformFeedbackMode:i,callback:s,errors:a};{let u={};Array.isArray(r)?r.forEach(function(d,m){u[d]=e?e[m]:m}):u=r||{},c.attribLocations=u}return c}const vu=["VERTEX_SHADER","FRAGMENT_SHADER"];function Tu(r,e){if(e.indexOf("frag")>=0)return vc;if(e.indexOf("vert")>=0)return Tc}function Au(r,e,t){const n=r.getAttachedShaders(e);for(const i of n)t.has(i)&&r.deleteShader(i);r.deleteProgram(e)}const Iu=(r=0)=>new Promise(e=>setTimeout(e,r));function Su(r,e,t){const n=r.createProgram(),{attribLocations:i,transformFeedbackVaryings:s,transformFeedbackMode:o}=Fr(t);for(let a=0;a<e.length;++a){let c=e[a];if(typeof c=="string"){const u=$n(c),d=u?u.text:c;let m=r[vu[a]];u&&u.type&&(m=Tu(r,u.type)||m),c=r.createShader(m),r.shaderSource(c,hi(d).shaderSource),r.compileShader(c),r.attachShader(n,c)}}Object.entries(i).forEach(([a,c])=>r.bindAttribLocation(n,c,a));{let a=s;a&&(a.attribs&&(a=a.attribs),Array.isArray(a)||(a=Object.keys(a)),r.transformFeedbackVaryings(n,a,o||Ac))}return r.linkProgram(n),n}function Ru(r,e,t,n,i){const s=Fr(t,n,i),o=new Set(e),a=Su(r,e,s);function c(u,d){const m=Pu(u,d,s.errorCallback);return m&&Au(u,d,o),m}if(s.callback){Fu(r,a).then(()=>{const u=c(r,a);s.callback(u,u?void 0:a)});return}return c(r,a)?void 0:a}async function Fu(r,e){const t=r.getExtension("KHR_parallel_shader_compile"),n=t?(s,o)=>s.getProgramParameter(o,t.COMPLETION_STATUS_KHR):()=>!0;let i=0;do await Iu(i),i=1e3/60;while(!n(r,e))}function Pu(r,e,t){if(t=t||Tr,!r.getProgramParameter(e,wc)){const i=r.getProgramInfoLog(e);t(`Error in program linking: ${i}`);const o=r.getAttachedShaders(e).map(a=>wu(r,r.getShaderParameter(a,r.SHADER_TYPE),a,t));return`${i}\n${o.filter(a=>a).join(`\n`)}`}}function ku(r,e,t,n,i){return Ru(r,e,t,n,i)}function mi(r){const e=r.name;return e.startsWith("gl_")||e.startsWith("webgl_")}const Cu=/(\\.|\\[|]|\\w+)/g,Bu=r=>r>="0"&&r<="9";function Du(r,e,t,n){const i=r.split(Cu).filter(a=>a!=="");let s=0,o="";for(;;){const a=i[s++];o+=a;const c=Bu(a[0]),u=c?parseInt(a):a;if(c&&(o+=i[s++]),s===i.length){t[u]=e;break}else{const m=i[s++],p=m==="[",y=t[u]||(p?[]:{});t[u]=y,t=y,n[o]=n[o]||(function(l){return function(b){pi(l,b)}})(y),o+=m}}}function Mu(r,e){let t=0;function n(a,c,u){const d=c.name.endsWith("[0]"),m=c.type,p=x[m];if(!p)throw new Error(`unknown type: 0x${m.toString(16)}`);let y;if(p.bindPoint){const l=t;t+=c.size,d?y=p.arraySetter(r,m,l,u,c.size):y=p.setter(r,m,l,u,c.size)}else p.arraySetter&&d?y=p.arraySetter(r,u):y=p.setter(r,u);return y.location=u,y}const i={},s={},o=r.getProgramParameter(e,Wn);for(let a=0;a<o;++a){const c=r.getActiveUniform(e,a);if(mi(c))continue;let u=c.name;u.endsWith("[0]")&&(u=u.substr(0,u.length-3));const d=r.getUniformLocation(e,c.name);if(d){const m=n(e,c,d);i[u]=m,Du(u,m,s,i)}}return i}function Ou(r,e){const t={},n=r.getProgramParameter(e,Sc);for(let i=0;i<n;++i){const s=r.getTransformFeedbackVarying(e,i);t[s.name]={index:i,type:s.type,size:s.size}}return t}function Uu(r,e){const t=r.getProgramParameter(e,Wn),n=[],i=[];for(let a=0;a<t;++a){i.push(a),n.push({});const c=r.getActiveUniform(e,a);n[a].name=c.name}[["UNIFORM_TYPE","type"],["UNIFORM_SIZE","size"],["UNIFORM_BLOCK_INDEX","blockNdx"],["UNIFORM_OFFSET","offset"]].forEach(function(a){const c=a[0],u=a[1];r.getActiveUniforms(e,i,r[c]).forEach(function(d,m){n[m][u]=d})});const s={},o=r.getProgramParameter(e,Rc);for(let a=0;a<o;++a){const c=r.getActiveUniformBlockName(e,a),u={index:r.getUniformBlockIndex(e,c),usedByVertexShader:r.getActiveUniformBlockParameter(e,a,Fc),usedByFragmentShader:r.getActiveUniformBlockParameter(e,a,Pc),size:r.getActiveUniformBlockParameter(e,a,kc),uniformIndices:r.getActiveUniformBlockParameter(e,a,Cc)};u.used=u.usedByVertexShader||u.usedByFragmentShader,s[c]=u}return{blockSpecs:s,uniformData:n}}function pi(r,e){for(const t in e){const n=r[t];typeof n=="function"?n(e[t]):pi(r[t],e[t])}}function gi(r,...e){const t=r.uniformSetters||r,n=e.length;for(let i=0;i<n;++i){const s=e[i];if(Array.isArray(s)){const o=s.length;for(let a=0;a<o;++a)gi(t,s[a])}else for(const o in s){const a=t[o];a&&a(s[o])}}}function Nu(r,e){const t={},n=r.getProgramParameter(e,Ic);for(let i=0;i<n;++i){const s=r.getActiveAttrib(e,i);if(mi(s))continue;const o=r.getAttribLocation(e,s.name),a=I[s.type],c=a.setter(r,o,a);c.location=o,t[s.name]=c}return t}function Lu(r,e){for(const t in e){const n=r[t];n&&n(e[t])}}function zu(r,e,t){t.vertexArrayObject?r.bindVertexArray(t.vertexArrayObject):(Lu(e.attribSetters||e,t.attribs),t.indices&&r.bindBuffer(_c,t.indices))}function yi(r,e){const t=Mu(r,e),n=Nu(r,e),i={program:e,uniformSetters:t,attribSetters:n};return Le(r)&&(i.uniformBlockSpec=Uu(r,e),i.transformFeedbackInfo=Ou(r,e)),i}const Gu=/\\s|{|}|;/;function $u(r,e,t,n,i){const s=Fr(t,n,i),o=[];if(e=e.map(function(u){if(!Gu.test(u)){const d=$n(u);if(d)u=d.text;else{const m=`no element with id: ${u}`;s.errorCallback(m),o.push(m)}}return u}),o.length)return Eu(s,"");const a=s.callback;a&&(s.callback=(u,d)=>{a(u,u?void 0:yi(r,d))});const c=ku(r,e,s);return c?yi(r,c):null}const Wu=4,bi=5123;function Vu(r,e,t,n,i,s){t=t===void 0?Wu:t;const o=e.indices,a=e.elementType,c=n===void 0?e.numElements:n;i=i===void 0?0:i,a||o?s!==void 0?r.drawElementsInstanced(t,c,a===void 0?bi:e.elementType,i,s):r.drawElements(t,c,a===void 0?bi:e.elementType,i):s!==void 0?r.drawArraysInstanced(t,i,c,s):r.drawArrays(t,i,c)}const xi=36160,Ot=36161,Hu=3553,ju=5121,Xu=6402,Yu=6408,Qu=33190,qu=36012,Ku=35056,Ju=36013,Zu=32854,ef=32855,tf=36194,_i=33189,Ei=6401,wi=36168,Pr=34041,kr=36064,Ut=36096,vi=36128,Cr=33306,Br=33071,Dr=9729,rf=[{format:Yu,type:ju,min:Dr,wrap:Br},{format:Pr}],G={};G[Pr]=Cr,G[Ei]=vi,G[wi]=vi,G[Xu]=Ut,G[_i]=Ut,G[Qu]=Ut,G[qu]=Ut,G[Ku]=Cr,G[Ju]=Cr;function nf(r,e){return G[r]||G[e]}const oe={};oe[Zu]=!0,oe[ef]=!0,oe[tf]=!0,oe[Pr]=!0,oe[_i]=!0,oe[Ei]=!0,oe[wi]=!0;function sf(r){return oe[r]}const of=32;function af(r){return r>=kr&&r<kr+of}function Ti(r,e,t,n){const i=xi,s=r.createFramebuffer();r.bindFramebuffer(i,s),t=t||r.drawingBufferWidth,n=n||r.drawingBufferHeight,e=e||rf;const o=[],a={framebuffer:s,attachments:[],width:t,height:n};return e.forEach(function(c,u){let d=c.attachment;const m=c.samples,p=c.format;let y=c.attachmentPoint||nf(p,c.internalFormat);if(y||(y=kr+u),af(y)&&o.push(y),!d)if(m!==void 0||sf(p))d=r.createRenderbuffer(),r.bindRenderbuffer(Ot,d),m>1?r.renderbufferStorageMultisample(Ot,m,p,t,n):r.renderbufferStorage(Ot,p,t,n);else{const l=Object.assign({},c);l.width=t,l.height=n,l.auto===void 0&&(l.auto=!1,l.min=l.min||l.minMag||Dr,l.mag=l.mag||l.minMag||Dr,l.wrapS=l.wrapS||l.wrap||Br,l.wrapT=l.wrapT||l.wrap||Br),d=Gn(r,l)}if(po(r,d))r.framebufferRenderbuffer(i,y,Ot,d);else if(fr(r,d))c.layer!==void 0?r.framebufferTextureLayer(i,y,d,c.level||0,c.layer):r.framebufferTexture2D(i,y,c.target||Hu,d,c.level||0);else throw new Error("unknown attachment type");a.attachments.push(d)}),r.drawBuffers&&r.drawBuffers(o),a}function cf(r,e,t){t=t||xi,e?(r.bindFramebuffer(t,e.framebuffer),r.viewport(0,0,e.width,e.height)):(r.bindFramebuffer(t,null),r.viewport(0,0,r.drawingBufferWidth,r.drawingBufferHeight))}function D(r,e){return()=>e instanceof WebGLTexture?e:Gn(r,{src:e,wrap:r.CLAMP_TO_EDGE})}const Ce=2;class je{constructor(e){this.id="_";const{context:t,width:n,height:i}=e;this.context=t,this.options=e;const s=this.buildDefines();this.programInfo=$u(this.context,[s+this.getVertexShader(),s+this.getFragmentShader()]),this.bufferInfo=Lo(this.context,this.getBuffers()),this.fbi=Ti(this.context,[{format:this.context.RGBA,type:this.context.UNSIGNED_BYTE,min:this.context.LINEAR,wrap:this.context.CLAMP_TO_EDGE}],n,i),this.output=this.fbi.attachments[0]}resizeOutput(e,t){this.fbi=Ti(this.context,[{format:this.context.RGBA,type:this.context.UNSIGNED_BYTE,min:this.context.LINEAR,wrap:this.context.CLAMP_TO_EDGE}],e,t),this.options.width=e,this.options.height=t,this.output=this.fbi.attachments[0]}getDefines(){return{}}getBuffers(){return{position:{numComponents:2,data:[-1,-1,-1,1,1,-1,1,1,-1,1,1,-1]},texture_coord:{numComponents:2,data:[0,0,0,1,1,0,1,1,0,1,1,0]}}}buildDefines(){let e="";const t=this.getDefines();for(let n in t)e+=`#define ${n} ${t[n].toFixed(1)}\n`;return e}run(e){this.profiler?.pushContext(`[${this.id}] PROG : ${this.constructor.name}`),this.profiler?.pushContext(`[${this.id}] UNIFORMS`);for(const i in e)typeof e[i]=="function"&&(this.profiler?.pushContext(`[${this.id}] UNI : ${i}`),e[i]=e[i](),this.profiler?.popContext(`[${this.id}] UNI : ${i}`));this.profiler?.popContext(`[${this.id}] UNIFORMS`);const t=Date.now();let n=0;this.lastRun&&(n=(t-this.lastRun)/1e3),this.lastRun=t,this.context.viewport(0,0,this.context.canvas.width,this.context.canvas.height),this.context.useProgram(this.programInfo.program),zu(this.context,this.programInfo,this.bufferInfo),gi(this.programInfo,{delta:n,canvas:[this.context.canvas.width,this.context.canvas.height],...e}),cf(this.context,this.options.disableFramebuffer?null:this.fbi),Vu(this.context,this.bufferInfo),this.profiler?.popContext(`[${this.id}] PROG : ${this.constructor.name}`)}setProfiler(e){this.profiler=e}}var uf=`precision mediump float;\n\nvarying vec2 _texture_coord;\n\nuniform sampler2D background;\nuniform sampler2D foreground;\nuniform sampler2D threshold;\n\nvoid main() {\n vec4 backgroundColor = texture2D(background, _texture_coord);\n vec4 foregroundColor = texture2D(foreground, _texture_coord);\n vec4 tresholdColor = texture2D(threshold, _texture_coord);\n gl_FragColor = foregroundColor * tresholdColor.a +\n backgroundColor * (1. - tresholdColor.a);\n}\n`,ff=`varying vec2 _texture_coord;\n\nattribute vec2 position;\nattribute vec2 texture_coord;\n\nvoid main() {\n gl_Position = vec4(position, 0., 1.);\n _texture_coord = texture_coord;\n _texture_coord.y = 1. - texture_coord.y;\n}\n`;class Mr extends je{getFragmentShader(){return uf}getVertexShader(){return ff}}class Or{constructor(){this.steps=[]}addStep(e){this.steps.push(e)}async run(){for(const e of this.steps)e.program.run(e.getUniforms())}resizeOutput(e,t){this.profiler?.pushContext(`PIP [${this.constructor.name}]`);for(const n of this.steps)n.preventResize||n.program.resizeOutput(e,t);this.profiler?.popContext(`PIP [${this.constructor.name}]`)}setProfiler(e){this.profiler=e;for(const t of this.steps)t.program.setProfiler(e)}setId(e){for(const t of this.steps)t.program.id=e}}class Ur extends Or{constructor(){super(...arguments),this.preciseMaskEnabled=!1}}class Ai extends Ur{constructor(e){super(),this.context=e,this.preciseMaskEnabled=!0;const t={context:e,height:e.canvas.height,width:e.canvas.width},n=new Mr({...t,disableFramebuffer:!0});this.addStep({program:n,getUniforms:()=>({background:D(e,this.inputBackgroundImage),foreground:D(e,this.inputImage),threshold:D(e,this.inputMask)})})}setData(e,t){this.inputImage=e,this.inputMask=t}}var lf=`precision mediump float;\n\nvarying vec2 _texture_coord;\nuniform sampler2D texture;\n\nvoid main() { gl_FragColor = texture2D(texture, _texture_coord); }\n`,df=`varying vec2 _texture_coord;\n\nattribute vec2 position;\nattribute vec2 texture_coord;\nuniform bool invert_y;\n\nvoid main() {\n gl_Position = vec4(position, 0., 1.);\n _texture_coord = texture_coord;\n if (invert_y) {\n _texture_coord.y = 1. - texture_coord.y;\n }\n}\n`;class hf extends je{getFragmentShader(){return lf}getVertexShader(){return df}}class mf extends Or{constructor(e,t,n){super(),this.context=e;const i={context:e,height:n,width:t};this.addStep({program:new hf({...i,disableFramebuffer:!0}),getUniforms:()=>({texture:D(e,this.inputImage),invert_y:!0})})}setData(e){this.inputImage=e}}async function Ii(r){return new Promise(e=>{setTimeout(()=>{e()},r)})}var pf=`precision mediump float;\n\nvarying vec2 _texture_coord;\n\nuniform vec2 canvas;\nuniform sampler2D texture;\n\nvec4 loop();\n\nvoid main() { gl_FragColor = loop(); }\n`,gf=`varying vec2 _texture_coord;\n\nattribute vec2 position;\nattribute vec2 texture_coord;\n\nvoid main() {\n gl_Position = vec4(position, 0., 1.);\n _texture_coord = texture_coord;\n}\n`,Nr=(r=>(r[r.LINEAR=0]="LINEAR",r[r.GAUSSIAN=1]="GAUSSIAN",r))(Nr||{});class Si extends je{getDefines(){return{RADIUS:this.options.radius??1}}getFragmentShader(){return pf+this.createLoopFunction()}getVertexShader(){return gf}createLoopFunction(){let e=this.options.radius??1;return`\n\n vec4 loop() { \n vec4 result = vec4(0,0,0,0);\n float factorSum = 0.;\n\n vec2 normalizedRadius = vec2(-${e}.) / canvas;\n vec2 normalizedIncrement = vec2(1.) / canvas;\n vec2 diff = normalizedRadius;\n\n for(int y=-${e}; y<${e+1}; ++y) {\n for(int x=-${e}; x<${e+1}; ++x) {\n float factor = 1.;\n result += factor * texture2D(texture, _texture_coord + diff);\n factorSum += factor;\n diff.x += normalizedIncrement.x;\n }\n diff.y += normalizedIncrement.y;\n diff.x = normalizedRadius.x;\n }\n return result / factorSum;\n }`}}var yf=`#version 300 es\n// https://github.com/Volcomix/virtual-background/blob/main/src/pipelines/webgl2/jointBilateralFilterStage.ts\n\nprecision highp float;\nuniform sampler2D input_frame;\nuniform sampler2D segmentation_mask;\nuniform sampler2D threshold;\nuniform vec2 texel_size;\nuniform float step;\nuniform float radius;\nuniform float offset;\nuniform float sigma_texel;\nuniform float sigma_color;\n\nin vec2 _texture_coord;\nout vec4 outColor;\n\nfloat gaussian(float x, float sigma) {\n float coeff = -0.5 / (sigma * sigma * 4.0 + 1.0e-6);\n return exp((x * x) * coeff);\n}\n\nvoid main() {\n vec2 centerCoord = _texture_coord;\n vec3 centerColor = texture(input_frame, centerCoord).rgb;\n float newVal = 0.0;\n float spaceWeight = 0.0;\n float colorWeight = 0.0;\n float totalWeight = 0.0;\n // Subsample kernel space.\n for (float i = -radius + offset; i <= radius; i += step) {\n for (float j = -radius + offset; j <= radius; j += step) {\n vec2 shift = vec2(j, i) * texel_size;\n vec2 coord = vec2(centerCoord + shift);\n vec3 frameColor = texture(input_frame, coord).rgb;\n float threshold = texture(threshold, coord).a;\n float outVal = texture(segmentation_mask, coord).a;\n\n spaceWeight = gaussian(distance(centerCoord, coord), sigma_texel);\n colorWeight = gaussian(distance(centerColor, frameColor), sigma_color);\n totalWeight += spaceWeight * colorWeight;\n newVal += spaceWeight * colorWeight * outVal * threshold;\n }\n }\n newVal /= totalWeight;\n outColor = vec4(vec3(0.), newVal);\n}`,bf=`#version 300 es\nin vec2 position;\nin vec2 texture_coord;\nout vec2 _texture_coord;\nvoid main() {\n gl_Position = vec4(position, 0.0, 1.0);\n _texture_coord = texture_coord;\n}`;class xf extends je{getFragmentShader(){return yf}getVertexShader(){return bf}}class _f extends Or{constructor(e,t,n){super(),this.context=e;const i={context:e,height:n,width:t},s=new Si({...i,radius:1,type:Nr.GAUSSIAN});this.jointBilateral=new xf(i),this.addStep({program:s,getUniforms:()=>({inputs:D(e,this.inputMask)})}),this.addStep({program:this.jointBilateral,getUniforms:()=>{const a=this.inputImage?.width??1,c=this.inputImage?.height??1;this.inputMask?.width,this.inputMask?.height;const u=3,d=Math.max(1,Math.sqrt(u)*.66),m=1/a,p=1/c;return{input_frame:D(e,this.inputImage),segmentation_mask:D(e,this.inputMask),texel_size:[m,p],step:d,radius:u,offset:d>1?d*.5:0,sigma_texel:Math.max(m,p)*u,sigma_color:u}}}),this.output=this.jointBilateral.output}setData(e,t){this.previousInputImage=this.inputImage?this.inputImage:e,this.previousInputMask=this.inputMask?this.inputMask:t,this.inputImage=e,this.inputMask=t}resizeOutput(e,t){super.resizeOutput(e,t),this.output=this.jointBilateral.output}}class Ef{constructor(e){this.queries=[],this.context=e,this.extension=e.getExtension("EXT_disjoint_timer_query_webgl2")}start(){}stop(){this.activeQuery&&this.context.endQuery(this.extension.TIME_ELAPSED_EXT)}pushContext(e){this.createQuery("PUSH",e)}popContext(e){this.createQuery("POP",e)}createQuery(e,t){this.activeQuery&&this.context.endQuery(this.extension.TIME_ELAPSED_EXT),this.activeQuery=this.context.createQuery(),this.context.beginQuery(this.extension.TIME_ELAPSED_EXT,this.activeQuery),this.queries.push({name:t,action:e,query:this.activeQuery})}async getResolvedQueries(){const e=(await Promise.all([...this.queries].map(t=>this.resolveQuery(t)))).filter(t=>t);for(let t=1;t<e.length;++t)e[t].timestamp+=e[t-1].duration+e[t-1].timestamp;return e}async resolveQuery(e){if(!await this.awaitQueryAvailable(e)){console.log("Unawaitable query",e);return}if(this.context.getParameter(this.extension.GPU_DISJOINT_EXT)){console.log("Disjointed query",e);return}return{...e,duration:this.context.getQueryParameter(e.query,this.context.QUERY_RESULT),timestamp:0}}async awaitQueryAvailable(e){for(let t=0;t<10;++t){if(this.context.getQueryParameter(e.query,this.context.QUERY_RESULT_AVAILABLE))return e;await Ii(200)}}}class Nt{constructor(){this.previousImageWidth=0,this.previousImageHeight=0,this.previousMaskWidth=Ce,this.previousMaskHeight=Ce,this.postProcessingEnabled=!0;const e=new OffscreenCanvas(0,0),t=e.getContext("webgl2");if(!t)throw"Fail to retrieve webgl2 context";this.canvas=e,this.context=t,this.improveMask=new _f(this.context,Ce,Ce)}enablePostProcessing(){this.postProcessingEnabled=!0}disablePostProcessing(){this.postProcessingEnabled=!1}async profileWebgl(e){const t=new Ef(this.context);return this.profiler=t,t.start(),await Ii(e),this.profiler=void 0,t.stop(),t.getResolvedQueries()}async render(e,t){if(!this.pipeline)throw"missing pipeline";(this.previousImageHeight!==e.height||this.previousImageWidth!==e.width)&&this.resizeOutput(e.width,e.height),(this.previousMaskHeight!==t.height||this.previousMaskWidth!==t.width)&&(this.improveMask.resizeOutput(t.width,t.height),this.previousMaskWidth=t.width,this.previousMaskHeight=t.height);const n="renderer";this.profiler?.pushContext(n),this.improveMask.setProfiler(this.profiler),this.pipeline.setProfiler(this.profiler);const i=await createImageBitmap(t);let s=i;return this.postProcessingEnabled&&(this.improveMask.setData(e,i),this.improveMask.run(),s=this.improveMask.output),this.pipeline.setData(e,s),await this.pipeline.run(),this.profiler?.popContext(n),this.canvas}resizeOutput(e,t){this.canvas.width=e,this.canvas.height=t,this.pipeline?.resizeOutput(e,t),this.previousImageWidth=e,this.previousImageHeight=t}destroy(){const e=this.context?.getExtension("WEBGL_lose_context");e&&e.loseContext()}}class Ri extends Nt{constructor(){super(),this.pipeline=new Ai(this.context);const e=new OffscreenCanvas(0,0),t=e.getContext("webgl2");if(!t)throw"Fail to retrieve webgl context";this.backgroundImageResizerCanvas=e,this.backgroundImageResizerContext=t,this.backgroundImageResizer=new mf(this.backgroundImageResizerContext,0,0)}setBackgroundImage(e){this.backgroundImage=e,this.updateBackgroundImage()}updateBackgroundImage(){const{width:e,height:t}=this.canvas;this.backgroundImageResizer.resizeOutput(e,t),this.backgroundImageResizer.setData(this.backgroundImage),this.backgroundImageResizer.run(),this.pipeline.inputBackgroundImage=this.backgroundImageResizerCanvas}resizeOutput(e,t){super.resizeOutput(e,t),this.backgroundImageResizerCanvas.width=e,this.backgroundImageResizerCanvas.height=t,this.backgroundImageResizer.resizeOutput(e,t),this.updateBackgroundImage()}destroy(){const e=this.backgroundImageResizerContext?.getExtension("WEBGL_lose_context");e&&e.loseContext(),super.destroy()}}class wf extends Ri{setBackgroundVideo(e){this.frameReader=e}async render(e,t){return await this.readNextVideoFrame(),super.render(e,t)}async readNextVideoFrame(){const e=await this.frameReader?.read();if(e?.value){const t=await createImageBitmap(e.value);this.setBackgroundImage(t),e.value.close()}}}class Fi{blurBackground(e){return new to(e)}blurSilhouette(e){return new ro(e)}imageBackground(){return new no}videoBackground(){return new wf}}var vf=`precision mediump float;\n\nvarying vec2 _texture_coord;\n\nuniform vec2 canvas;\nuniform sampler2D texture;\nuniform sampler2D mask;\n\nvec4 loop();\n\nvoid main() { gl_FragColor = loop(); }\n`,Tf=`varying vec2 _texture_coord;\n\nattribute vec2 position;\nattribute vec2 texture_coord;\n\nvoid main() {\n gl_Position = vec4(position, 0., 1.);\n _texture_coord = texture_coord;\n}\n`;class Af extends je{getDefines(){return{RADIUS:this.options.radius??1}}getFragmentShader(){return vf+this.createLoopFunction()}getVertexShader(){return Tf}createLoopFunction(){let e=this.options.radius??1;return`\n\n vec4 loop() { \n vec4 result = vec4(0,0,0,0);\n float factorSum = 0.;\n\n vec2 normalizedRadius = vec2(-${e}.) / canvas;\n vec2 normalizedIncrement = vec2(1.) / canvas;\n vec2 diff = normalizedRadius;\n float maxLength = length(normalizedRadius);\n\n for(int y=-${e}; y<${e+1}; ++y) {\n for(int x=-${e}; x<${e+1}; ++x) {\n float factor = (1.- texture2D(mask, _texture_coord + diff).a) * (maxLength - length(diff)) / maxLength;\n result += factor * texture2D(texture, _texture_coord + diff);\n factorSum += factor;\n diff.x += normalizedIncrement.x;\n }\n diff.y += normalizedIncrement.y;\n diff.x = normalizedRadius.x;\n }\n return result / factorSum;\n }`}}const If=10,Sf=2,Rf=8;class Ff extends Ur{constructor(e,t){super(),this.context=e,this.radius=t;const n={context:e,height:e.canvas.height,width:e.canvas.width};this.blur=new Af({...n,radius:t,...this.getBlurTextureSize(e.canvas.width,e.canvas.height)});const i=new Mr({...n,disableFramebuffer:!0});this.addStep({program:this.blur,preventResize:!0,getUniforms:()=>({texture:D(e,this.inputImage),mask:D(e,this.inputMask)})}),this.addStep({program:i,getUniforms:()=>({background:D(e,this.blur.output),foreground:D(e,this.inputImage),threshold:D(e,this.inputMask)})})}getBlurTextureSize(e,t){const n=this.radius>If?Rf:Sf;return{width:Math.max(Ce,e/n),height:Math.max(Ce,t/n)}}setData(e,t){this.inputImage=e,this.inputMask=t}resizeOutput(e,t){super.resizeOutput(e,t);const n=this.getBlurTextureSize(e,t);this.blur.resizeOutput(n.width,n.height)}}class Pf extends Nt{constructor(e){super(),this.pipeline=new Ff(this.context,e),this.disablePostProcessing()}}class kf extends Ur{constructor(e,t){super(),this.context=e;const n={context:e,height:e.canvas.height,width:e.canvas.width},i=new Si({...n,radius:t,type:Nr.GAUSSIAN}),s=new Mr({...n,disableFramebuffer:!0});this.addStep({program:i,getUniforms:()=>({texture:D(e,this.inputImage)})}),this.addStep({program:s,getUniforms:()=>({background:D(e,this.inputImage),foreground:D(e,i.output),threshold:D(e,this.inputMask)})})}setData(e,t){this.inputImage=e,this.inputMask=t}}class Cf extends Nt{constructor(e){super(),this.pipeline=new kf(this.context,e),this.disablePostProcessing()}}class Bf extends Ai{constructor(){super(...arguments),this.preciseMaskEnabled=!0}set reader(e){this.frameReader=e}async run(){this.frameReader&&(await this.readNextVideoFrame(),await super.run())}async readNextVideoFrame(){const e=await this.frameReader?.read();e?.value&&(this.inputBackgroundImage=await createImageBitmap(e.value),e.value.close())}}class Df extends Nt{constructor(){super(),this.pipeline=new Bf(this.context)}setBackgroundVideo(e){this.pipeline.reader=e}}class Pi{blurBackground(e){return new Pf(e)}blurSilhouette(e){return new Cf(e)}imageBackground(){return new Ri}videoBackground(){return new Df}}class Mf{constructor(e){switch(e){case gt.CANVAS:this.factory=new Fi;break;case gt.WEBGL:this.factory=new Pi;break;default:const t=eo();this.factory=t.supported?new Pi:new Fi}}blurBackground(e){return this.getFactory().blurBackground(e)}blurSilhouette(e){return this.getFactory().blurSilhouette(e)}imageBackground(){return this.getFactory().imageBackground()}videoBackground(){return this.getFactory().videoBackground()}getFactory(){if(!this.factory)throw"Factory is not initialized";return this.factory}}class Of{setBackgroundOptions(e){this.renderer&&this.renderer.destroy();const t=new Mf(e.renderingOptions?.type);switch(e.transformerType){case"BackgroundBlur":this.renderer=t.blurBackground(this.getBlurSize(e.radius));break;case"SilhouetteBlur":this.renderer=t.blurSilhouette(this.getBlurSize(e.radius));break;case"VideoBackground":const n=t.videoBackground();this.backgroundVideo&&n.setBackgroundVideo(this.backgroundVideo),this.renderer=n;break;case"VirtualBackground":const i=t.imageBackground();this.backgroundImage&&i.setBackgroundImage(this.backgroundImage),this.renderer=i;break;default:throw`Unknown rendering type [${e.transformerType}]`}e.renderingOptions?.type===gt.WEBGL&&(e.renderingOptions.selfieSegmentationType===tr.PRECISE?this.renderer.enablePostProcessing():e.renderingOptions.selfieSegmentationType===tr.FAST&&this.renderer.disablePostProcessing())}setVideoBGReadable(e){this.backgroundVideo=e.getReader();const t=this.renderer;t?.setBackgroundVideo&&t.setBackgroundVideo(this.backgroundVideo)}async setVirtualBGImage(e){const t=this.renderer;t?.setBackgroundImage&&t.setBackgroundImage(e),this.backgroundImage=e}async process(e,t){if(this.renderer)return this.renderer.render(e,t)}async resizeForeground(e,t){}getBlurSize(e=pt.Low){switch(e){case pt.Low:return 5;case pt.High:return 12}return e}async profile(e){return this.renderer?.profileWebgl(e)??[]}}var Uf=(function(){var r=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return(function(e){e=e||{};var t=typeof e<"u"?e:{},n,i;t.ready=new Promise(function(f,h){n=f,i=h});var s={},o;for(o in t)t.hasOwnProperty(o)&&(s[o]=t[o]);var a="./this.program",c=function(f,h){throw h},u=!0,d="";function m(f){return t.locateFile?t.locateFile(f,d):d+f}var p;typeof document<"u"&&document.currentScript&&(d=document.currentScript.src),r&&(d=r),d.indexOf("blob:")!==0?d=d.substr(0,d.replace(/[?#].*/,"").lastIndexOf("/")+1):d="";var y=t.print||console.log.bind(console),l=t.printErr||console.warn.bind(console);for(o in s)s.hasOwnProperty(o)&&(t[o]=s[o]);s=null,t.arguments&&t.arguments,t.thisProgram&&(a=t.thisProgram),t.quit&&(c=t.quit);var b;t.wasmBinary&&(b=t.wasmBinary),t.noExitRuntime,typeof WebAssembly!="object"&&ae("no native wasm support detected");var _,E=!1,R=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function k(f,h,g){for(var w=h+g,S=h;f[S]&&!(S>=w);)++S;if(S-h>16&&f.subarray&&R)return R.decode(f.subarray(h,S));for(var C="";h<S;){var v=f[h++];if(!(v&128)){C+=String.fromCharCode(v);continue}var M=f[h++]&63;if((v&224)==192){C+=String.fromCharCode((v&31)<<6|M);continue}var H=f[h++]&63;if((v&240)==224?v=(v&15)<<12|M<<6|H:v=(v&7)<<18|M<<12|H<<6|f[h++]&63,v<65536)C+=String.fromCharCode(v);else{var Li=v-65536;C+=String.fromCharCode(55296|Li>>10,56320|Li&1023)}}return C}function N(f,h){return f?k(Xe,f,h):""}function Q(f,h,g){for(var w=0;w<f.length;++w)Lt[h++>>0]=f.charCodeAt(w);Lt[h>>0]=0}function q(f,h){return f%h>0&&(f+=h-f%h),f}var L,Lt,Xe,$;function Ci(f){L=f,t.HEAP8=Lt=new Int8Array(f),t.HEAP16=new Int16Array(f),t.HEAP32=$=new Int32Array(f),t.HEAPU8=Xe=new Uint8Array(f),t.HEAPU16=new Uint16Array(f),t.HEAPU32=new Uint32Array(f),t.HEAPF32=new Float32Array(f),t.HEAPF64=new Float64Array(f)}t.INITIAL_MEMORY;var zr,Bi=[],Di=[],Mi=[];function Yf(){if(t.preRun)for(typeof t.preRun=="function"&&(t.preRun=[t.preRun]);t.preRun.length;)Kf(t.preRun.shift());Gr(Bi)}function Qf(){Gr(Di)}function qf(){if(t.postRun)for(typeof t.postRun=="function"&&(t.postRun=[t.postRun]);t.postRun.length;)Zf(t.postRun.shift());Gr(Mi)}function Kf(f){Bi.unshift(f)}function Jf(f){Di.unshift(f)}function Zf(f){Mi.unshift(f)}var be=0,Ye=null;function el(f){be++,t.monitorRunDependencies&&t.monitorRunDependencies(be)}function tl(f){if(be--,t.monitorRunDependencies&&t.monitorRunDependencies(be),be==0&&Ye){var h=Ye;Ye=null,h()}}t.preloadedImages={},t.preloadedAudios={};function ae(f){t.onAbort&&t.onAbort(f),f="Aborted("+f+")",l(f),E=!0,f+=". Build with -s ASSERTIONS=1 for more info.";var h=new WebAssembly.RuntimeError(f);throw i(h),h}var rl="data:application/octet-stream;base64,";function Oi(f){return f.startsWith(rl)}var W;W="tflite-simd.wasm",Oi(W)||(W=m(W));function Ui(f){try{if(f==W&&b)return new Uint8Array(b);if(!p)throw"both async and sync fetching of the wasm failed"}catch(h){ae(h)}}function nl(){return!b&&u&&typeof fetch=="function"?fetch(W,{credentials:"same-origin"}).then(function(f){if(!f.ok)throw"failed to load wasm binary file at \'"+W+"\'";return f.arrayBuffer()}).catch(function(){return Ui(W)}):Promise.resolve().then(function(){return Ui(W)})}function il(){var f={a:Al};function h(v,M){var H=v.exports;t.asm=H,_=t.asm.q,Ci(_.buffer),zr=t.asm.E,Jf(t.asm.r),tl()}el();function g(v){h(v.instance)}function w(v){return nl().then(function(M){return WebAssembly.instantiate(M,f)}).then(function(M){return M}).then(v,function(M){l("failed to asynchronously prepare wasm: "+M),ae(M)})}function S(){return!b&&typeof WebAssembly.instantiateStreaming=="function"&&!Oi(W)&&typeof fetch=="function"?fetch(W,{credentials:"same-origin"}).then(function(v){var M=WebAssembly.instantiateStreaming(v,f);return M.then(g,function(H){return l("wasm streaming compile failed: "+H),l("falling back to ArrayBuffer instantiation"),w(g)})}):w(g)}if(t.instantiateWasm)try{var C=t.instantiateWasm(f,h);return C}catch(v){return l("Module.instantiateWasm callback failed with error: "+v),!1}return S().catch(i),{}}function Gr(f){for(;f.length>0;){var h=f.shift();if(typeof h=="function"){h(t);continue}var g=h.func;typeof g=="number"?h.arg===void 0?zr.get(g)():zr.get(g)(h.arg):g(h.arg===void 0?null:h.arg)}}function sl(f,h,g,w){ae("Assertion failed: "+N(f)+", at: "+[h?N(h):"unknown filename",g,w?N(w):"unknown function"])}function ol(f,h){ae("To use dlopen, you need to use Emscripten\'s linking support, see https://github.com/emscripten-core/emscripten/wiki/Linking")}function al(f,h){ae("To use dlopen, you need to use Emscripten\'s linking support, see https://github.com/emscripten-core/emscripten/wiki/Linking")}function cl(){ae("")}var zt;zt=function(){return performance.now()};var ul=!0;function fl(f){return $[Ni()>>2]=f,f}function ll(f,h){var g;if(f===0)g=Date.now();else if((f===1||f===4)&&ul)g=zt();else return fl(28),-1;return $[h>>2]=g/1e3|0,$[h+4>>2]=g%1e3*1e3*1e3|0,0}function dl(){return 2147483648}function hl(f,h,g){Xe.copyWithin(f,h,h+g)}function ml(f){try{return _.grow(f-L.byteLength+65535>>>16),Ci(_.buffer),1}catch{}}function pl(f){var h=Xe.length;f=f>>>0;var g=2147483648;if(f>g)return!1;for(var w=1;w<=4;w*=2){var S=h*(1+.2/w);S=Math.min(S,f+100663296);var C=Math.min(g,q(Math.max(f,S),65536)),v=ml(C);if(v)return!0}return!1}function gl(f){for(var h=zt();zt()-h<f;);}var $r={};function yl(){return a||"./this.program"}function Qe(){if(!Qe.strings){var f=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",h={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:f,_:yl()};for(var g in $r)$r[g]===void 0?delete h[g]:h[g]=$r[g];var w=[];for(var g in h)w.push(g+"="+h[g]);Qe.strings=w}return Qe.strings}var Gt={mappings:{},buffers:[null,[],[]],printChar:function(f,h){var g=Gt.buffers[f];h===0||h===10?((f===1?y:l)(k(g,0)),g.length=0):g.push(h)},varargs:void 0,get:function(){Gt.varargs+=4;var f=$[Gt.varargs-4>>2];return f},getStr:function(f){var h=N(f);return h},get64:function(f,h){return f}};function bl(f,h){var g=0;return Qe().forEach(function(w,S){var C=h+g;$[f+S*4>>2]=C,Q(w,C),g+=w.length+1}),0}function xl(f,h){var g=Qe();$[f>>2]=g.length;var w=0;return g.forEach(function(S){w+=S.length+1}),$[h>>2]=w,0}function _l(f){Sl(f)}function El(f){return 0}function wl(f,h,g,w,S){}function vl(f,h,g,w){for(var S=0,C=0;C<g;C++){for(var v=$[h+C*8>>2],M=$[h+(C*8+4)>>2],H=0;H<M;H++)Gt.printChar(f,Xe[v+H]);S+=M}return $[w>>2]=S,0}function Tl(){if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function"){var f=new Uint8Array(1);return function(){return crypto.getRandomValues(f),f[0]}}else return function(){ae("randomDevice")}}function $t(f,h){$t.randomDevice||($t.randomDevice=Tl());for(var g=0;g<h;g++)Lt[f+g>>0]=$t.randomDevice();return 0}var Al={a:sl,e:ol,d:al,b:cl,n:ll,h:dl,l:hl,m:pl,p:gl,f:bl,g:xl,j:_l,i:El,k:wl,c:vl,o:$t};il(),t.___wasm_call_ctors=function(){return(t.___wasm_call_ctors=t.asm.r).apply(null,arguments)},t._getModelBufferMemoryOffset=function(){return(t._getModelBufferMemoryOffset=t.asm.s).apply(null,arguments)},t._getInputMemoryOffset=function(){return(t._getInputMemoryOffset=t.asm.t).apply(null,arguments)},t._getInputHeight=function(){return(t._getInputHeight=t.asm.u).apply(null,arguments)},t._getInputWidth=function(){return(t._getInputWidth=t.asm.v).apply(null,arguments)},t._getInputChannelCount=function(){return(t._getInputChannelCount=t.asm.w).apply(null,arguments)},t._getOutputMemoryOffset=function(){return(t._getOutputMemoryOffset=t.asm.x).apply(null,arguments)},t._getOutputHeight=function(){return(t._getOutputHeight=t.asm.y).apply(null,arguments)},t._getOutputWidth=function(){return(t._getOutputWidth=t.asm.z).apply(null,arguments)},t._getOutputChannelCount=function(){return(t._getOutputChannelCount=t.asm.A).apply(null,arguments)},t._loadModel=function(){return(t._loadModel=t.asm.B).apply(null,arguments)},t._runInference=function(){return(t._runInference=t.asm.C).apply(null,arguments)},t._isGPUEnabled=function(){return(t._isGPUEnabled=t.asm.D).apply(null,arguments)};var Ni=t.___errno_location=function(){return(Ni=t.___errno_location=t.asm.F).apply(null,arguments)},Wt;function Il(f){this.name="ExitStatus",this.message="Program terminated with exit("+f+")",this.status=f}Ye=function f(){Wt||Wr(),Wt||(Ye=f)};function Wr(f){if(be>0||(Yf(),be>0))return;function h(){Wt||(Wt=!0,t.calledRun=!0,!E&&(Qf(),n(t),t.onRuntimeInitialized&&t.onRuntimeInitialized(),qf()))}t.setStatus?(t.setStatus("Running..."),setTimeout(function(){setTimeout(function(){t.setStatus("")},1),h()},1)):h()}t.run=Wr;function Sl(f,h){Rl(f)}function Rl(f){c(f,new Il(f))}if(t.preInit)for(typeof t.preInit=="function"&&(t.preInit=[t.preInit]);t.preInit.length>0;)t.preInit.pop()();return Wr(),e.ready})})();class Nf{constructor(){this.isSIMDSupported=!1,this.isThreadsSupported=!1,this.inputWidth=0,this.inputHeight=0,this.inputChannelCount=0,this.inputMemoryOffset=0,this.outputWidth=0,this.outputHeight=0,this.outputChannelCount=0,this.outputMemoryOffset=0}}const Lf="https://d3opqjmqzxf057.cloudfront.net/vonage-tensorflow-wasm/tflite-simd-wasm/1.1.3/",zf="https://d3opqjmqzxf057.cloudfront.net/ml/selfie_segmentation/4.0.0/selfie_segmentation_landscape.tflite";async function Gf(r=Lf,e=zf){let t=new Nf;var n=new Promise(function(i,s){async function o(){return Uf({locateFile:function(u){return r+u}})}async function a(c){return new Promise(async(u,d)=>{const m=c;if(typeof m>"u")return d("TFLite backend unavailable: wasmSimd");let p=e;console.log("TFLite modelUrl: "+p);try{const l=await(await fetch(p)).arrayBuffer();console.log("Model buffer size:",l.byteLength);const b=m._getModelBufferMemoryOffset();console.log("Model buffer memory offset:",b),console.log("Loading model buffer..."),m.HEAPU8.set(new Uint8Array(l),b);const _=m._loadModel(l.byteLength);if(console.log("Load model result:",_),_!==0){d("Cannot load model");return}t.inputWidth=m._getInputWidth(),t.inputHeight=m._getInputHeight(),t.inputChannelCount=m._getInputChannelCount(),t.inputMemoryOffset=m._getInputMemoryOffset(),console.log("Input memory offset:",t.inputMemoryOffset),console.log("Input height:",t.inputHeight),console.log("Input width:",t.inputWidth),console.log("Input channels:",t.inputChannelCount),t.outputMemoryOffset=m._getOutputMemoryOffset(),t.outputWidth=m._getOutputWidth(),t.outputHeight=m._getOutputHeight(),t.outputChannelCount=m._getOutputChannelCount(),console.log("Output memory offset:",t.outputMemoryOffset),console.log("Output height:",t.outputHeight),console.log("Output width:",t.outputWidth),console.log("Output channels:",t.outputChannelCount),t.selectedTFLite=m}catch(y){d(y);return}u()})}o().then(c=>{if(c===null)throw console.error("loadTFLite null"),"loadTFLite null";a(c).then(u=>{i(t)}).catch(u=>{console.error("loadTFLiteModel error"),s("loadTFLiteModel error")})}).catch(c=>{console.error("loadTFLite error:",c),s("loadTFLite error:"+c)})});return n}const $f=.1,Wf=.7,Vf="https://d3opqjmqzxf057.cloudfront.net/ml/vonage_selfie_segmenter/float16/v1/vonage_selfie_segmenter.tflite";class Hf{constructor(){this.canvas=new OffscreenCanvas(0,0),this.context=this.canvas.getContext("2d",{willReadFrequently:!0}),this.width=0,this.height=0,this.gpuDelegate=!0}async createImageSegmenter(){if(!this.ImageSegmenter||!this.wasmFileset){console.warn("Mediapipe objects not loaded");return}this.imageSegmenter=await this.ImageSegmenter.createFromOptions(this.wasmFileset,{baseOptions:{modelAssetPath:this.modelAssetUriPath,delegate:this.gpuDelegate?"GPU":"CPU"},runningMode:"VIDEO",outputCategoryMask:!0,outputConfidenceMasks:!0})}async loadMediapipeAssets(e,t){this.modelAssetUriPath=e||Vf;const n=t?`${t}/task-vision.js`:"https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.20/+esm",i=t?`${t}/wasm`:"https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.20/wasm",{FilesetResolver:s,ImageSegmenter:o}=await import(n);this.ImageSegmenter=o,this.wasmFileset=await s.forVisionTasks(i)}async init(e,t,n){n===!1&&(this.gpuDelegate=!1),await this.loadMediapipeAssets(e,t),globalThis.document={},await this.createImageSegmenter()}async process(e){if(!this.imageSegmenter){console.warn("ImageSegmenter instance not available");return}(this.width!==e.width||this.height!==e.height)&&(this.canvas.width=this.width=e.width,this.canvas.height=this.height=e.height,this.mask&&(this.mask=new ImageData(this.width,this.height))),this.mask||(this.mask=new ImageData(this.width,this.height)),this.context.drawImage(e,0,0,e.width,e.height);const t=Date.now();let n;try{this.imageSegmenter?.segmentForVideo(this.context.getImageData(0,0,e.width,e.height),t,o=>{n=o.confidenceMasks?.[0]?.getAsFloat32Array()})}catch{await this.createImageSegmenter();return}if(!n)return;if(!this.previousConfidenceMask){this.previousConfidenceMask=n.slice();return}const i=n.map((o,a)=>{const c=this.previousConfidenceMask?.[a];return c!==void 0?this.blend(c,o):o}),s=[255,0,0];for(let o=0;o<i?.length;o++){const a=1-i[o];a>$f?(a<Wf?(this.mask.data[o*4]=s[0]*a,this.mask.data[o*4+3]=255*a):(this.mask.data[o*4]=s[0],this.mask.data[o*4+3]=255),this.mask.data[o*4+1]=s[1],this.mask.data[o*4+2]=s[2]):this.mask.data[o*4]=this.mask.data[o*4+1]=this.mask.data[o*4+2]=this.mask.data[o*4+3]=0}return this.previousConfidenceMask=i.slice(),this.mask}isGpuSupported(){return!0}blend(e,t){const i=-.748699,s=-57.8051,o=291.309,a=-624.717,c=t-.5,u=c*c,d=1-Math.min(1,u*(5.68842+u*(i+u*(s+u*(o+u*a)))));return t+(e-t)*(d*.9)}}class jf{constructor(){this.canvas=new OffscreenCanvas(0,0),this.context=this.canvas.getContext("2d",{willReadFrequently:!0}),this.pixelCount=0,this.inputOffset=0,this.outputOffset=0}async init(e,t,n){await this.initWasm(t,e),this.infos&&(this.canvas.width=this.infos.inputWidth,this.canvas.height=this.infos.inputHeight,this.pixelCount=this.infos.inputWidth*this.infos.inputHeight,this.mask=new ImageData(this.infos.inputWidth,this.infos.inputHeight),this.inputOffset=this.infos.inputMemoryOffset/4,this.outputOffset=this.infos.outputMemoryOffset/4)}async initWasm(e,t){this.infos=await Gf(e,t)}async process(e){if(!this.mask||!this.infos)return;const t=this.infos.inputWidth,n=this.infos.inputHeight;this.context.drawImage(e,0,0,e.width,e.height,0,0,t,n);const i=this.context.getImageData(0,0,t,n),s=this.infos.selectedTFLite.HEAPF32;for(let o=0;o<this.pixelCount;o++){const a=this.inputOffset+o*3;s[a]=i.data[o*4]/255,s[a+1]=i.data[o*4+1]/255,s[a+2]=i.data[o*4+2]/255}this.infos.selectedTFLite._runInference();for(let o=0;o<this.pixelCount;o++){const a=this.infos.selectedTFLite.HEAPF32[this.outputOffset+o];this.mask.data[o*4]=this.mask.data[o*4+3]=255*a}return this.mask}isGpuSupported(){return this.infos?.selectedTFLite?._isGPUEnabled()??!1}}class Xf{constructor(){this.reporter=new Js,this.isEnabled=!0}async init(e,t){t.segmentationOptions?.lightWeightEngine===!0?this.selfieSegmentation=new jf:this.selfieSegmentation=new Hf,this.selfieSegmentation?.init(t.modelAssetUriPath,t.mediapipeBaseAssetsUri,t.segmentationOptions?.gpuSupport),this.backgroundFilter=new Of,this.report({variation:"Create"})}async transform(e,t){if(!this.isEnabled)return t.enqueue(e);let n;const i=e.timestamp??0,s=await createImageBitmap(e),o=await this.selfieSegmentation?.process(s);o&&(n=await this.backgroundFilter?.process(s,o)),n?(e.close(),t.enqueue(new VideoFrame(n,{timestamp:i,alpha:"discard"}))):t.enqueue(e)}async setBackgroundOptions(e){this.backgroundOptions=e,this.backgroundFilter?.setBackgroundOptions(e),this.report({variation:"Update"})}setVideoBGReadable(e){this.backgroundFilter?.setVideoBGReadable(e)}async setVirtualBGImage(e){await this.backgroundFilter?.setVirtualBGImage(e)}async profile(e){return this.backgroundFilter?.profile(e)??[]}getTransformerType(){return this.backgroundOptions?.transformerType??"Undefined"}enable(){this.isEnabled=!0}disable(){this.isEnabled=!1}report(e){this.reporter.send({version:Zs,action:"MlTransformers",transformerType:this.backgroundOptions?.transformerType,config:JSON.stringify(this.backgroundOptions),...e})}}const Lr=class Lr{constructor(){this.backgroundTransformer=new Xf,this.mediaProcessor=new Rs,this.rate=30,this.eventsQueue=[],this.frameTransformLatencyMs=[]}async init(e,t){this.frameTransformLatencyMs=[],await this.backgroundTransformer.init(e,t),await this.mediaProcessor.setTransformers([this.backgroundTransformer]),this.mediaProcessor.setTrackExpectedRate(this.rate),this.mediaProcessor.onAny((n,i)=>{this.resolveOnMediaProcessor?(this.resolveOnMediaProcessor({name:n,data:i}),this.resolveOnMediaProcessor=void 0):this.eventsQueue.push({name:n,data:i})})}enable(){this.backgroundTransformer.enable()}disable(){this.backgroundTransformer.disable()}async onMediaProcessorEvent(){return await new Promise(e=>{this.eventsQueue.length>0?e(this.eventsQueue.shift()):this.resolveOnMediaProcessor=e})}async setTrackExpectedRate(e){this.rate=e,this.mediaProcessor.setTrackExpectedRate(e)}async transform(e,t){let n=this.mediaProcessor.transform(e,t),i=performance.now();return this.frameTransformLatencyMs.push(performance.now()-i),n}async setBackgroundOptions(e){await this.backgroundTransformer?.setBackgroundOptions(e)}setVideoBGReadable(e){this.backgroundTransformer.setVideoBGReadable(e)}async setVirtualBGImage(e){await this.backgroundTransformer.setVirtualBGImage(e)}async terminate(){await this.mediaProcessor.destroy();const t=this.frameTransformLatencyMs.reduce((n,i)=>n+i,0)/this.frameTransformLatencyMs.length||0;console.log(`Transform latency average is: ${t} ms`)}setVonageMetadata(e){_s(e)}async profile(e){return JSON.stringify(await this.backgroundTransformer.profile(e))}};Vi("ProcessorWorker",Lr);let ki=Lr})();\n//# sourceMappingURL=processor-worker-B9-xvwqE.js.map\n',
36613
- ii = typeof self < "u" && self.Blob && new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);", _o], {
36616
+ const Eo = '(function(){"use strict";function Vt(r,e){globalThis.vonage||(globalThis.vonage={}),globalThis.vonage.workerizer||(globalThis.vonage.workerizer={});let t=globalThis.vonage.workerizer;return t[r]||(t[r]=e),t[r]}const Vr=Vt("globals",{});var xe=(r=>(r.INIT="INIT",r.FORWARD="FORWARD",r.TERMINATE="TERMINATE",r.GLOBALS_SYNC="GLOBALS_SYNC",r.EVENT="EVENT",r))(xe||{});function zi(r){return[ImageBitmap,ReadableStream,WritableStream].some(t=>r instanceof t)}function Be(r,e){const{id:t,type:n}=r,i=Array.isArray(e)?e:[e];postMessage({id:t,type:n,result:e},i.filter(s=>zi(s)))}Vt("workerized",{});function Hr(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function qe(r,e){if(Array.isArray(e))e.splice(0,e.length);else if(typeof e=="object")for(const t in e)delete e[t];for(const t in r)Array.isArray(r[t])?(e[t]=[],qe(r[t],e[t])):typeof r[t]=="object"?(e[t]={},qe(r[t],e[t])):e[t]=r[t]}const K=new WeakMap,ce=new WeakMap,j=new WeakMap,Ke=Symbol("anyProducer"),jr=Promise.resolve(),Je=Symbol("listenerAdded"),Ze=Symbol("listenerRemoved");let et=!1,Ht=!1;function _e(r){if(typeof r!="string"&&typeof r!="symbol"&&typeof r!="number")throw new TypeError("`eventName` must be a string, symbol, or number")}function tt(r){if(typeof r!="function")throw new TypeError("listener must be a function")}function Ee(r,e){const t=ce.get(r);if(t.has(e))return t.get(e)}function De(r,e){const t=typeof e=="string"||typeof e=="symbol"||typeof e=="number"?e:Ke,n=j.get(r);if(n.has(t))return n.get(t)}function Gi(r,e,t){const n=j.get(r);if(n.has(e))for(const i of n.get(e))i.enqueue(t);if(n.has(Ke)){const i=Promise.all([e,t]);for(const s of n.get(Ke))s.enqueue(i)}}function Xr(r,e){e=Array.isArray(e)?e:[e];let t=!1,n=()=>{},i=[];const s={enqueue(o){i.push(o),n()},finish(){t=!0,n()}};for(const o of e){let a=De(r,o);a||(a=new Set,j.get(r).set(o,a)),a.add(s)}return{async next(){return i?i.length===0?t?(i=void 0,this.next()):(await new Promise(o=>{n=o}),this.next()):{done:!1,value:await i.shift()}:{done:!0}},async return(o){i=void 0;for(const a of e){const c=De(r,a);c&&(c.delete(s),c.size===0&&j.get(r).delete(a))}return n(),arguments.length>0?{done:!0,value:await o}:{done:!0}},[Symbol.asyncIterator](){return this}}}function Yr(r){if(r===void 0)return Qr;if(!Array.isArray(r))throw new TypeError("`methodNames` must be an array of strings");for(const e of r)if(!Qr.includes(e))throw typeof e!="string"?new TypeError("`methodNames` element must be a string"):new Error(`${e} is not Emittery method`);return r}const we=r=>r===Je||r===Ze;function rt(r,e,t){if(we(e))try{et=!0,r.emit(e,t)}finally{et=!1}}class ve{static mixin(e,t){return t=Yr(t),n=>{if(typeof n!="function")throw new TypeError("`target` must be function");for(const o of t)if(n.prototype[o]!==void 0)throw new Error(`The property \\`${o}\\` already exists on \\`target\\``);function i(){return Object.defineProperty(this,e,{enumerable:!1,value:new ve}),this[e]}Object.defineProperty(n.prototype,e,{enumerable:!1,get:i});const s=o=>function(...a){return this[e][o](...a)};for(const o of t)Object.defineProperty(n.prototype,o,{enumerable:!1,value:s(o)});return n}}static get isDebugEnabled(){var e,t;if(typeof((e=globalThis.process)==null?void 0:e.env)!="object")return Ht;const{env:n}=(t=globalThis.process)!=null?t:{env:{}};return n.DEBUG==="emittery"||n.DEBUG==="*"||Ht}static set isDebugEnabled(e){Ht=e}constructor(e={}){var t;K.set(this,new Set),ce.set(this,new Map),j.set(this,new Map),j.get(this).set(Ke,new Set),this.debug=(t=e.debug)!=null?t:{},this.debug.enabled===void 0&&(this.debug.enabled=!1),this.debug.logger||(this.debug.logger=(n,i,s,o)=>{try{o=JSON.stringify(o)}catch{o=`Object with the following keys failed to stringify: ${Object.keys(o).join(",")}`}(typeof s=="symbol"||typeof s=="number")&&(s=s.toString());const a=new Date,c=`${a.getHours()}:${a.getMinutes()}:${a.getSeconds()}.${a.getMilliseconds()}`;console.log(`[${c}][emittery:${n}][${i}] Event Name: ${s}\n data: ${o}`)})}logIfDebugEnabled(e,t,n){(ve.isDebugEnabled||this.debug.enabled)&&this.debug.logger(e,this.debug.name,t,n)}on(e,t){tt(t),e=Array.isArray(e)?e:[e];for(const n of e){_e(n);let i=Ee(this,n);i||(i=new Set,ce.get(this).set(n,i)),i.add(t),this.logIfDebugEnabled("subscribe",n,void 0),we(n)||rt(this,Je,{eventName:n,listener:t})}return this.off.bind(this,e,t)}off(e,t){tt(t),e=Array.isArray(e)?e:[e];for(const n of e){_e(n);const i=Ee(this,n);i&&(i.delete(t),i.size===0&&ce.get(this).delete(n)),this.logIfDebugEnabled("unsubscribe",n,void 0),we(n)||rt(this,Ze,{eventName:n,listener:t})}}once(e){let t;const n=new Promise(i=>{t=this.on(e,s=>{t(),i(s)})});return n.off=t,n}events(e){e=Array.isArray(e)?e:[e];for(const t of e)_e(t);return Xr(this,e)}async emit(e,t){var n;if(_e(e),we(e)&&!et)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");this.logIfDebugEnabled("emit",e,t),Gi(this,e,t);const i=(n=Ee(this,e))!=null?n:new Set,s=K.get(this),o=[...i],a=we(e)?[]:[...s];await jr,await Promise.all([...o.map(async c=>{if(i.has(c))return c(t)}),...a.map(async c=>{if(s.has(c))return c(e,t)})])}async emitSerial(e,t){var n;if(_e(e),we(e)&&!et)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");this.logIfDebugEnabled("emitSerial",e,t);const i=(n=Ee(this,e))!=null?n:new Set,s=K.get(this),o=[...i],a=[...s];await jr;for(const c of o)i.has(c)&&await c(t);for(const c of a)s.has(c)&&await c(e,t)}onAny(e){return tt(e),this.logIfDebugEnabled("subscribeAny",void 0,void 0),K.get(this).add(e),rt(this,Je,{listener:e}),this.offAny.bind(this,e)}anyEvent(){return Xr(this)}offAny(e){tt(e),this.logIfDebugEnabled("unsubscribeAny",void 0,void 0),rt(this,Ze,{listener:e}),K.get(this).delete(e)}clearListeners(e){e=Array.isArray(e)?e:[e];for(const t of e)if(this.logIfDebugEnabled("clear",t,void 0),typeof t=="string"||typeof t=="symbol"||typeof t=="number"){const n=Ee(this,t);n&&n.clear();const i=De(this,t);if(i){for(const s of i)s.finish();i.clear()}}else{K.get(this).clear();for(const[n,i]of ce.get(this).entries())i.clear(),ce.get(this).delete(n);for(const[n,i]of j.get(this).entries()){for(const s of i)s.finish();i.clear(),j.get(this).delete(n)}}}listenerCount(e){var t,n,i,s,o,a;e=Array.isArray(e)?e:[e];let c=0;for(const u of e){if(typeof u=="string"){c+=K.get(this).size+((n=(t=Ee(this,u))==null?void 0:t.size)!=null?n:0)+((s=(i=De(this,u))==null?void 0:i.size)!=null?s:0)+((a=(o=De(this))==null?void 0:o.size)!=null?a:0);continue}typeof u<"u"&&_e(u),c+=K.get(this).size;for(const d of ce.get(this).values())c+=d.size;for(const d of j.get(this).values())c+=d.size}return c}bindMethods(e,t){if(typeof e!="object"||e===null)throw new TypeError("`target` must be an object");t=Yr(t);for(const n of t){if(e[n]!==void 0)throw new Error(`The property \\`${n}\\` already exists on \\`target\\``);Object.defineProperty(e,n,{enumerable:!1,value:this[n].bind(this)})}}}const Qr=Object.getOwnPropertyNames(ve.prototype).filter(r=>r!=="constructor");Object.defineProperty(ve,"listenerAdded",{value:Je,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(ve,"listenerRemoved",{value:Ze,writable:!1,enumerable:!0,configurable:!1});function $i(r){return r.onAny&&r.emit}async function Wi(r,e){const{functionName:t,args:n}=r;if(!e.instance)throw"instance not initialized";if(!t)throw"missing function name to call";if(!e.instance[t])throw`undefined function [${t}] in class ${e.instance.constructor.workerId}`;Be(r,await e.instance[t](...n??[]))}const qr=Vt("registeredWorkers",{});function Vi(r,e){e.workerId=r,Hr()&&(qr[e.workerId]=e)}function Hi(r,e){if(!r.args)throw"Missing className while initializing worker";const[t,n]=r.args,i=qr[t];if(i)e.instance=new i(r.args.slice(1));else throw`unknown worker class ${t}`;qe(n,Vr),$i(e.instance)&&e.instance.onAny((s,o)=>{Be({type:xe.EVENT},{name:s,data:o})}),Be(r,typeof e.instance!==void 0)}async function ji(r,e){const{args:t}=r;if(!e.instance)throw"instance not initialized";let n;e.instance.terminate&&(n=await e.instance.terminate(...t??[])),Be(r,n)}function Xi(r){if(!r.args)throw"Missing globals while syncing";qe(r.args[0],Vr),Be(r,{})}function Yi(){const r={};onmessage=async e=>{const t=e.data;switch(t.type){case xe.INIT:Hi(t,r);break;case xe.FORWARD:Wi(t,r);break;case xe.TERMINATE:ji(t,r);break;case xe.GLOBALS_SYNC:Xi(t);break}}}Hr()&&Yi();const J=new WeakMap,ue=new WeakMap,X=new WeakMap,nt=Symbol("anyProducer"),Kr=Promise.resolve(),it=Symbol("listenerAdded"),st=Symbol("listenerRemoved");let ot=!1,jt=!1;const at=r=>typeof r=="string"||typeof r=="symbol"||typeof r=="number";function Te(r){if(!at(r))throw new TypeError("`eventName` must be a string, symbol, or number")}function ct(r){if(typeof r!="function")throw new TypeError("listener must be a function")}function Ae(r,e){const t=ue.get(r);if(t.has(e))return t.get(e)}function Me(r,e){const t=at(e)?e:nt,n=X.get(r);if(n.has(t))return n.get(t)}function Qi(r,e,t){const n=X.get(r);if(n.has(e))for(const i of n.get(e))i.enqueue(t);if(n.has(nt)){const i=Promise.all([e,t]);for(const s of n.get(nt))s.enqueue(i)}}function Jr(r,e){e=Array.isArray(e)?e:[e];let t=!1,n=()=>{},i=[];const s={enqueue(o){i.push(o),n()},finish(){t=!0,n()}};for(const o of e){let a=Me(r,o);a||(a=new Set,X.get(r).set(o,a)),a.add(s)}return{async next(){return i?i.length===0?t?(i=void 0,this.next()):(await new Promise(o=>{n=o}),this.next()):{done:!1,value:await i.shift()}:{done:!0}},async return(o){i=void 0;for(const a of e){const c=Me(r,a);c&&(c.delete(s),c.size===0&&X.get(r).delete(a))}return n(),arguments.length>0?{done:!0,value:await o}:{done:!0}},[Symbol.asyncIterator](){return this}}}function Zr(r){if(r===void 0)return en;if(!Array.isArray(r))throw new TypeError("`methodNames` must be an array of strings");for(const e of r)if(!en.includes(e))throw typeof e!="string"?new TypeError("`methodNames` element must be a string"):new Error(`${e} is not Emittery method`);return r}const Ie=r=>r===it||r===st;function ut(r,e,t){if(Ie(e))try{ot=!0,r.emit(e,t)}finally{ot=!1}}class Y{static mixin(e,t){return t=Zr(t),n=>{if(typeof n!="function")throw new TypeError("`target` must be function");for(const o of t)if(n.prototype[o]!==void 0)throw new Error(`The property \\`${o}\\` already exists on \\`target\\``);function i(){return Object.defineProperty(this,e,{enumerable:!1,value:new Y}),this[e]}Object.defineProperty(n.prototype,e,{enumerable:!1,get:i});const s=o=>function(...a){return this[e][o](...a)};for(const o of t)Object.defineProperty(n.prototype,o,{enumerable:!1,value:s(o)});return n}}static get isDebugEnabled(){if(typeof globalThis.process?.env!="object")return jt;const{env:e}=globalThis.process??{env:{}};return e.DEBUG==="emittery"||e.DEBUG==="*"||jt}static set isDebugEnabled(e){jt=e}constructor(e={}){J.set(this,new Set),ue.set(this,new Map),X.set(this,new Map),X.get(this).set(nt,new Set),this.debug=e.debug??{},this.debug.enabled===void 0&&(this.debug.enabled=!1),this.debug.logger||(this.debug.logger=(t,n,i,s)=>{try{s=JSON.stringify(s)}catch{s=`Object with the following keys failed to stringify: ${Object.keys(s).join(",")}`}(typeof i=="symbol"||typeof i=="number")&&(i=i.toString());const o=new Date,a=`${o.getHours()}:${o.getMinutes()}:${o.getSeconds()}.${o.getMilliseconds()}`;console.log(`[${a}][emittery:${t}][${n}] Event Name: ${i}\n data: ${s}`)})}logIfDebugEnabled(e,t,n){(Y.isDebugEnabled||this.debug.enabled)&&this.debug.logger(e,this.debug.name,t,n)}on(e,t,{signal:n}={}){ct(t),e=Array.isArray(e)?e:[e];for(const s of e){Te(s);let o=Ae(this,s);o||(o=new Set,ue.get(this).set(s,o)),o.add(t),this.logIfDebugEnabled("subscribe",s,void 0),Ie(s)||ut(this,it,{eventName:s,listener:t})}const i=()=>{this.off(e,t),n?.removeEventListener("abort",i)};return n?.addEventListener("abort",i,{once:!0}),n?.aborted&&i(),i}off(e,t){ct(t),e=Array.isArray(e)?e:[e];for(const n of e){Te(n);const i=Ae(this,n);i&&(i.delete(t),i.size===0&&ue.get(this).delete(n)),this.logIfDebugEnabled("unsubscribe",n,void 0),Ie(n)||ut(this,st,{eventName:n,listener:t})}}once(e,t){if(t!==void 0&&typeof t!="function")throw new TypeError("predicate must be a function");let n;const i=new Promise(s=>{n=this.on(e,o=>{t&&!t(o)||(n(),s(o))})});return i.off=n,i}events(e){e=Array.isArray(e)?e:[e];for(const t of e)Te(t);return Jr(this,e)}async emit(e,t){if(Te(e),Ie(e)&&!ot)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");this.logIfDebugEnabled("emit",e,t),Qi(this,e,t);const n=Ae(this,e)??new Set,i=J.get(this),s=[...n],o=Ie(e)?[]:[...i];await Kr,await Promise.all([...s.map(async a=>{if(n.has(a))return a(t)}),...o.map(async a=>{if(i.has(a))return a(e,t)})])}async emitSerial(e,t){if(Te(e),Ie(e)&&!ot)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");this.logIfDebugEnabled("emitSerial",e,t);const n=Ae(this,e)??new Set,i=J.get(this),s=[...n],o=[...i];await Kr;for(const a of s)n.has(a)&&await a(t);for(const a of o)i.has(a)&&await a(e,t)}onAny(e,{signal:t}={}){ct(e),this.logIfDebugEnabled("subscribeAny",void 0,void 0),J.get(this).add(e),ut(this,it,{listener:e});const n=()=>{this.offAny(e),t?.removeEventListener("abort",n)};return t?.addEventListener("abort",n,{once:!0}),t?.aborted&&n(),n}anyEvent(){return Jr(this)}offAny(e){ct(e),this.logIfDebugEnabled("unsubscribeAny",void 0,void 0),ut(this,st,{listener:e}),J.get(this).delete(e)}clearListeners(e){e=Array.isArray(e)?e:[e];for(const t of e)if(this.logIfDebugEnabled("clear",t,void 0),at(t)){const n=Ae(this,t);n&&n.clear();const i=Me(this,t);if(i){for(const s of i)s.finish();i.clear()}}else{J.get(this).clear();for(const[n,i]of ue.get(this).entries())i.clear(),ue.get(this).delete(n);for(const[n,i]of X.get(this).entries()){for(const s of i)s.finish();i.clear(),X.get(this).delete(n)}}}listenerCount(e){e=Array.isArray(e)?e:[e];let t=0;for(const n of e){if(at(n)){t+=J.get(this).size+(Ae(this,n)?.size??0)+(Me(this,n)?.size??0)+(Me(this)?.size??0);continue}n!==void 0&&Te(n),t+=J.get(this).size;for(const i of ue.get(this).values())t+=i.size;for(const i of X.get(this).values())t+=i.size}return t}bindMethods(e,t){if(typeof e!="object"||e===null)throw new TypeError("`target` must be an object");t=Zr(t);for(const n of t){if(e[n]!==void 0)throw new Error(`The property \\`${n}\\` already exists on \\`target\\``);Object.defineProperty(e,n,{enumerable:!1,value:this[n].bind(this)})}}}const en=Object.getOwnPropertyNames(Y.prototype).filter(r=>r!=="constructor");Object.defineProperty(Y,"listenerAdded",{value:it,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(Y,"listenerRemoved",{value:st,writable:!1,enumerable:!0,configurable:!1});var qi=Object.defineProperty,Ki=(r,e,t)=>e in r?qi(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ji=(r,e,t)=>(Ki(r,e+"",t),t);const Zi="hlg.tokbox.com/prod/logging/vcp_webrtc",es="https://",ts=1e4;let ft;const rs=new Uint8Array(16);function ns(){if(!ft&&(ft=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!ft))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ft(rs)}const F=[];for(let r=0;r<256;++r)F.push((r+256).toString(16).slice(1));function is(r,e=0){return(F[r[e+0]]+F[r[e+1]]+F[r[e+2]]+F[r[e+3]]+"-"+F[r[e+4]]+F[r[e+5]]+"-"+F[r[e+6]]+F[r[e+7]]+"-"+F[r[e+8]]+F[r[e+9]]+"-"+F[r[e+10]]+F[r[e+11]]+F[r[e+12]]+F[r[e+13]]+F[r[e+14]]+F[r[e+15]]).toLowerCase()}const ss=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),tn={randomUUID:ss};function os(r,e,t){if(tn.randomUUID&&!r)return tn.randomUUID();r=r||{};const n=r.random||(r.rng||ns)();return n[6]=n[6]&15|64,n[8]=n[8]&63|128,is(n)}function Xt(r,e){globalThis.vonage||(globalThis.vonage={}),globalThis.vonage.workerizer||(globalThis.vonage.workerizer={});let t=globalThis.vonage.workerizer;return t[r]||(t[r]=e),t[r]}const Z=Xt("globals",{});var fe=(r=>(r.INIT="INIT",r.FORWARD="FORWARD",r.TERMINATE="TERMINATE",r.GLOBALS_SYNC="GLOBALS_SYNC",r))(fe||{});function rn(r){return[ImageBitmap,ReadableStream,WritableStream].some(e=>r instanceof e)}let as=0;function cs(r,e,t,n,i){const s=as++;return r.postMessage({id:s,type:e,functionName:t,args:n},n.filter(o=>rn(o))),new Promise(o=>{i?.set(s,o)})}function Oe(r,e){const{id:t,type:n}=r,i=Array.isArray(e)?e:[e];postMessage({id:t,type:n,result:e},i.filter(s=>rn(s)))}const nn=Xt("workerized",{});function sn(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}async function us(){if(sn())Oe({type:fe.GLOBALS_SYNC},Z);else{const r=[];for(const e in nn){const{worker:t,resolvers:n}=nn[e].workerContext;t&&r.push(cs(t,fe.GLOBALS_SYNC,"",[Z],n))}await Promise.all(r)}}function lt(r,e){if(Array.isArray(e))e.splice(0,e.length);else if(typeof e=="object")for(const t in e)delete e[t];for(const t in r)Array.isArray(r[t])?(e[t]=[],lt(r[t],e[t])):typeof r[t]=="object"?(e[t]={},lt(r[t],e[t])):e[t]=r[t]}async function fs(r,e){const{functionName:t,args:n}=r;if(!e.instance)throw"instance not initialized";if(!t)throw"missing function name to call";if(!e.instance[t])throw`undefined function [${t}] in class ${e.instance.constructor.workerId}`;Oe(r,await e.instance[t](...n??[]))}const ls=Xt("registeredWorkers",{});function ds(r,e){if(!r.args)throw"Missing className while initializing worker";const[t,n]=r.args,i=ls[t];if(i)e.instance=new i(r.args.slice(1));else throw`unknown worker class ${t}`;lt(n,Z),Oe(r,typeof e.instance!==void 0)}async function hs(r,e){const{args:t}=r;if(!e.instance)throw"instance not initialized";let n;e.instance.terminate&&(n=await e.instance.terminate(...t??[])),Oe(r,n)}function ms(r){if(!r.args)throw"Missing globals while syncing";lt(r.args[0],Z),Oe(r,{})}function ps(){const r={};onmessage=async e=>{const t=e.data;switch(t.type){case fe.INIT:ds(t,r);break;case fe.FORWARD:fs(t,r);break;case fe.TERMINATE:hs(t,r);break;case fe.GLOBALS_SYNC:ms(t);break}}}sn()&&ps();function gs(r,e){return Z[r]||(Z[r]=e),[()=>Z[r],async t=>{Z[r]=t,await us()}]}function ys(r,e){return gs(r,e)}const[bs,xs]=ys("metadata");function _s(r){xs(r)}function Yt(){return bs()}let Qt=class{constructor(e,t){Ji(this,"uuid"),this.config=e,this.uuid=t??os()}async send(e){var t,n,i;const{appId:s,sourceType:o}=(t=Yt())!=null?t:{};if(!s||!o)return"metadata missing";const a=new AbortController,c=setTimeout(()=>a.abort(),ts);return await((i=(n=this.config)==null?void 0:n.fetch)!=null?i:fetch)(this.getUrl(),{method:"POST",headers:this.getHeaders(),body:JSON.stringify(this.buildReport(e)),signal:a.signal}),clearTimeout(c),"success"}getUrl(){var e;let t=(e=Yt().proxyUrl)!=null?e:es;return t+=(t.at(-1)==="/"?"":"/")+Zi,t}getHeaders(){return{"Content-Type":"application/json"}}buildReport(e){const t=Yt();return{guid:this.uuid,...e,applicationId:t.appId,timestamp:Date.now(),proxyUrl:t.proxyUrl,source:t.sourceType}}};const dt="3.0.2",qt=class{};qt.updates={transformer_new:"New transformer",transformer_null:"Null transformer"},qt.errors={transformer_none:"No transformers provided",transformer_start:"Cannot start transformer",transformer_transform:"Cannot transform frame",transformer_flush:"Cannot flush transformer",readable_null:"Readable is null",writable_null:"Writable is null"};let le=qt;function Es(r){return typeof r=="object"&&r!==null&&"message"in r&&typeof r.message=="string"}function ws(r){if(Es(r))return r;try{return new Error(JSON.stringify(r))}catch{return new Error(String(r))}}function Kt(r){return ws(r).message}class vs{constructor(e,t){this.config=e,this.frameTransformedCount=0,this.frameFromSourceCount=0,this.startAt=0,this.reporter=new Qt(e,t)}async onFrameFromSource(){this.frameFromSourceCount++}get fps(){const{startAt:e,frameFromSourceCount:t}=this,n=(Date.now()-e)/1e3;return t/n}async onFrameTransformed(e={},t=!1){this.startAt===0&&(this.startAt=Date.now()),this.frameTransformedCount++;const{startAt:n,frameTransformedCount:i,frameFromSourceCount:s}=this,o=Date.now(),a=(o-n)/1e3,c=i/a,u=s/a;return t||this.frameTransformedCount>=this.config.loggingIntervalFrameCount?(this.frameFromSourceCount=0,this.frameTransformedCount=0,this.startAt=o,this.reporter.config=this.config,this.reporter.send({...this.config.report,variation:"QoS",fps:u,transformedFps:c,framesTransformed:i,...e})):"success"}}var Jt=(r=>(r.pipeline_ended="pipeline_ended",r.pipeline_ended_with_error="pipeline_ended_with_error",r.pipeline_started="pipeline_started",r.pipeline_started_with_error="pipeline_started_with_error",r.pipeline_restarted="pipeline_restarted",r.pipeline_restarted_with_error="pipeline_restarted_with_error",r))(Jt||{});const Ts=500,As=.8;class Is extends Y{constructor(e,t){super(),this.reporter_=new Qt,this.reporterQos_=new vs({loggingIntervalFrameCount:Ts,report:{version:dt}}),this.index_=t,this.transformer_=e,this.shouldStop_=!1,this.isFlashed_=!1,this.mediaTransformerQosReportStartTimestamp_=0,this.videoHeight_=0,this.videoWidth_=0,this.trackExpectedRate_=-1,this.transformerType_="Custom","getTransformerType"in e&&(this.transformerType_=e.getTransformerType()),this.report({variation:"Create"})}setTrackExpectedRate(e){this.trackExpectedRate_=e}async start(e){if(this.controller_=e,this.transformer_&&typeof this.transformer_.start=="function")try{await this.transformer_.start(e)}catch(t){this.report({message:le.errors.transformer_start,variation:"Error",error:Kt(t)});const n={eventMetaData:{transformerIndex:this.index_},error:t,function:"start"};this.emit("error",n)}}async transform(e,t){if(this.mediaTransformerQosReportStartTimestamp_===0&&(this.mediaTransformerQosReportStartTimestamp_=Date.now()),e instanceof VideoFrame&&(this.videoHeight_=e?.displayHeight??0,this.videoWidth_=e?.displayWidth??0),this.reporterQos_.onFrameFromSource(),this.transformer_)if(this.shouldStop_)console.warn("[Pipeline] flush from transform"),e.close(),this.flush(t),t.terminate();else{try{await this.transformer_.transform?.(e,t),this.reportQos()}catch(n){this.report({message:le.errors.transformer_transform,variation:"Error",error:Kt(n)});const i={eventMetaData:{transformerIndex:this.index_},error:n,function:"transform"};this.emit("error",i)}if(this.trackExpectedRate_!=-1&&this.trackExpectedRate_*As>this.reporterQos_.fps){const n={eventMetaData:{transformerIndex:this.index_},warningType:"fps_drop",dropInfo:{requested:this.trackExpectedRate_,current:this.reporterQos_.fps}};this.emit("warn",n)}}}async flush(e){if(this.transformer_&&typeof this.transformer_.flush=="function"&&!this.isFlashed_){this.isFlashed_=!0;try{await this.transformer_.flush(e)}catch(t){this.report({message:le.errors.transformer_flush,variation:"Error",error:Kt(t)});const n={eventMetaData:{transformerIndex:this.index_},error:t,function:"flush"};this.emit("error",n)}}this.reportQos(!0),this.report({variation:"Delete"})}stop(){console.log("[Pipeline] Stop stream."),this.controller_&&(this.flush(this.controller_),this.controller_.terminate()),this.shouldStop_=!0}report(e){this.reporter_.send({version:dt,action:"MediaTransformer",transformerType:this.transformerType_,...e})}reportQos(e=!1){this.reporterQos_.config={...this.reporterQos_.config},this.reporterQos_.onFrameTransformed({version:dt,action:"MediaTransformer",transformerType:this.transformerType_,videoWidth:this.videoWidth_,videoHeight:this.videoHeight_},e)}}class Ss extends Y{constructor(e){super(),this.transformers_=[],this.trackExpectedRate_=-1;for(let t=0;t<e.length;t++){let n=new Is(e[t],t);n.on("error",i=>{this.emit("error",i)}),n.on("warn",i=>{this.emit("warn",i)}),this.transformers_.push(n)}}setTrackExpectedRate(e){this.trackExpectedRate_=e;for(let t of this.transformers_)t.setTrackExpectedRate(this.trackExpectedRate_)}async start(e,t){if(!this.transformers_||this.transformers_.length===0){console.log("[Pipeline] No transformers.");return}try{let n=e;for(let i of this.transformers_)e=e.pipeThrough(new TransformStream(i));e.pipeTo(t).then(async()=>{console.log("[Pipeline] Setup."),await t.abort(),await n.cancel(),this.emit("pipelineInfo","pipeline_ended")}).catch(async i=>{e.cancel().then(()=>{console.log("[Pipeline] Shutting down streams after abort.")}).catch(s=>{console.error("[Pipeline] Error from stream transform:",s)}),await t.abort(i),await n.cancel(i),this.emit("pipelineInfo","pipeline_ended_with_error")})}catch{this.emit("pipelineInfo","pipeline_started_with_error"),this.destroy();return}this.emit("pipelineInfo","pipeline_started"),console.log("[Pipeline] Pipeline started.")}async destroy(){console.log("[Pipeline] Destroying Pipeline.");for(let e of this.transformers_)e.stop()}}class Rs extends Y{constructor(){super(),this.reporter_=new Qt,this.trackExpectedRate_=-1,this.report({variation:"Create"})}setTrackExpectedRate(e){this.trackExpectedRate_=e,this.pipeline_&&this.pipeline_.setTrackExpectedRate(this.trackExpectedRate_)}async transform(e,t){if(this.isTrack(e)){if(e.kind==="video"){const n=new MediaStreamTrackProcessor({track:e}),i=new VideoTrackGenerator;return this.readable_=n.readable,this.writable_=i.writable,await this.transformInternal(),i.track}throw Error("Cannot process audio tracks inside a web worker when passing a track to transform")}else return this.readable_=e,this.writable_=t,this.transformInternal()}transformInternal(){return new Promise(async(e,t)=>{if(!this.transformers_||this.transformers_.length===0){this.report({message:le.errors.transformer_none,variation:"Error"}),t("[MediaProcessor] Need to set transformers.");return}if(!this.readable_){this.report({variation:"Error",message:le.errors.readable_null}),t("[MediaProcessor] Readable is null.");return}if(!this.writable_){this.report({variation:"Error",message:le.errors.writable_null}),t("[MediaProcessor] Writable is null.");return}let n=!1;this.pipeline_&&(n=!0,this.pipeline_.clearListeners(),this.pipeline_.destroy()),this.pipeline_=new Ss(this.transformers_),this.pipeline_.on("warn",i=>{this.emit("warn",i)}),this.pipeline_.on("error",i=>{this.emit("error",i)}),this.pipeline_.on("pipelineInfo",i=>{n&&(i==="pipeline_started"?i=Jt.pipeline_restarted:i==="pipeline_started_with_error"&&(i=Jt.pipeline_restarted_with_error)),this.emit("pipelineInfo",i)}),this.trackExpectedRate_!=-1&&this.pipeline_.setTrackExpectedRate(this.trackExpectedRate_),this.pipeline_.start(this.readable_,this.writable_).then(()=>{e()}).catch(i=>{t(i)})})}setTransformers(e){return this.report({variation:"Update",message:le.updates.transformer_new}),this.transformers_=e,this.readable_&&this.writable_?this.transformInternal():Promise.resolve()}destroy(){return new Promise(async e=>{this.pipeline_&&this.pipeline_.destroy(),this.report({variation:"Delete"}),e()})}report(e){this.reporter_.send({version:dt,action:"MediaProcessor",...e})}isTrack(e){return"kind"in e}}var Fs=Object.defineProperty,Ps=(r,e,t)=>e in r?Fs(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ks=(r,e,t)=>(Ps(r,e+"",t),t);const Cs="hlg.tokbox.com/prod/logging/vcp_webrtc",Bs="https://",Ds=1e4;let ht;const Ms=new Uint8Array(16);function Os(){if(!ht&&(ht=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!ht))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ht(Ms)}const P=[];for(let r=0;r<256;++r)P.push((r+256).toString(16).slice(1));function Us(r,e=0){return(P[r[e+0]]+P[r[e+1]]+P[r[e+2]]+P[r[e+3]]+"-"+P[r[e+4]]+P[r[e+5]]+"-"+P[r[e+6]]+P[r[e+7]]+"-"+P[r[e+8]]+P[r[e+9]]+"-"+P[r[e+10]]+P[r[e+11]]+P[r[e+12]]+P[r[e+13]]+P[r[e+14]]+P[r[e+15]]).toLowerCase()}const Ns=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),on={randomUUID:Ns};function Ls(r,e,t){if(on.randomUUID&&!e&&!r)return on.randomUUID();r=r||{};const n=r.random||(r.rng||Os)();return n[6]=n[6]&15|64,n[8]=n[8]&63|128,Us(n)}function Zt(r,e){globalThis.vonage||(globalThis.vonage={}),globalThis.vonage.workerizer||(globalThis.vonage.workerizer={});let t=globalThis.vonage.workerizer;return t[r]||(t[r]=e),t[r]}const ee=Zt("globals",{});var de=(r=>(r.INIT="INIT",r.FORWARD="FORWARD",r.TERMINATE="TERMINATE",r.GLOBALS_SYNC="GLOBALS_SYNC",r))(de||{});function an(r){return[ImageBitmap,ReadableStream,WritableStream].some(e=>r instanceof e)}let zs=0;function Gs(r,e,t,n,i){const s=zs++;return r.postMessage({id:s,type:e,functionName:t,args:n},n.filter(o=>an(o))),new Promise(o=>{i?.set(s,o)})}function Ue(r,e){const{id:t,type:n}=r,i=Array.isArray(e)?e:[e];postMessage({id:t,type:n,result:e},i.filter(s=>an(s)))}const cn=Zt("workerized",{});function un(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}async function $s(){if(un())Ue({type:de.GLOBALS_SYNC},ee);else{const r=[];for(const e in cn){const{worker:t,resolvers:n}=cn[e].workerContext;t&&r.push(Gs(t,de.GLOBALS_SYNC,"",[ee],n))}await Promise.all(r)}}function mt(r,e){if(Array.isArray(e))e.splice(0,e.length);else if(typeof e=="object")for(const t in e)delete e[t];for(const t in r)Array.isArray(r[t])?(e[t]=[],mt(r[t],e[t])):typeof r[t]=="object"?(e[t]={},mt(r[t],e[t])):e[t]=r[t]}async function Ws(r,e){const{functionName:t,args:n}=r;if(!e.instance)throw"instance not initialized";if(!t)throw"missing function name to call";if(!e.instance[t])throw`undefined function [${t}] in class ${e.instance.constructor.workerId}`;Ue(r,await e.instance[t](...n??[]))}const Vs=Zt("registeredWorkers",{});function Hs(r,e){if(!r.args)throw"Missing className while initializing worker";const[t,n]=r.args,i=Vs[t];if(i)e.instance=new i(r.args.slice(1));else throw`unknown worker class ${t}`;mt(n,ee),Ue(r,typeof e.instance!==void 0)}async function js(r,e){const{args:t}=r;if(!e.instance)throw"instance not initialized";let n;e.instance.terminate&&(n=await e.instance.terminate(...t??[])),Ue(r,n)}function Xs(r){if(!r.args)throw"Missing globals while syncing";mt(r.args[0],ee),Ue(r,{})}function Ys(){const r={};onmessage=async e=>{const t=e.data;switch(t.type){case de.INIT:Hs(t,r);break;case de.FORWARD:Ws(t,r);break;case de.TERMINATE:js(t,r);break;case de.GLOBALS_SYNC:Xs(t);break}}}un()&&Ys();function Qs(r,e){return ee[r]||(ee[r]=e),[()=>ee[r],async t=>{ee[r]=t,await $s()}]}function qs(r,e){return Qs(r,e)}const[Ks]=qs("metadata");function er(){return Ks()}class Js{constructor(e){ks(this,"uuid",Ls()),this.config=e}async send(e){var t,n,i;const{appId:s,sourceType:o}=(t=er())!=null?t:{};if(!s||!o)return"metadata missing";const a=new AbortController,c=setTimeout(()=>a.abort(),Ds);return await((i=(n=this.config)==null?void 0:n.fetch)!=null?i:fetch)(this.getUrl(),{method:"POST",headers:this.getHeaders(),body:JSON.stringify(this.buildReport(e)),signal:a.signal}),clearTimeout(c),"success"}getUrl(){var e;let t=(e=er().proxyUrl)!=null?e:Bs;return t+=(t.at(-1)==="/"?"":"/")+Cs,t}getHeaders(){return{"Content-Type":"application/json"}}buildReport(e){const t=er();return{guid:this.uuid,...e,applicationId:t.appId,timestamp:Date.now(),proxyUrl:t.proxyUrl,source:t.sourceType}}}const Zs="7.0.2";var pt=(r=>(r.Low="Low",r.High="High",r))(pt||{}),tr=(r=>(r.FAST="FAST",r.PRECISE="PRECISE",r))(tr||{}),gt=(r=>(r.CANVAS="CANVAS",r.WEBGL="WEBGL",r))(gt||{});function eo(){const e=new OffscreenCanvas(0,0).getContext("webgl2",{failIfMajorPerformanceCaveat:!0});if(e){const t=e?.getExtension("WEBGL_lose_context");t&&t.loseContext()}else return{supported:!1,message:"Your hardware does not perform good enough to run the library efficiently"};return{supported:!0}}class rr{constructor(){const e=new OffscreenCanvas(0,0),t=e.getContext("2d",{willReadFrequently:!0});if(!t)throw"Fail to retrieve 2d context";this.canvas=e,this.context=t}enablePostProcessing(){}disablePostProcessing(){}async profileWebgl(e){return[]}async render(e,t){return this.canvas}resizeCanvas(e){const{width:t,height:n}=e;this.canvas.width=t,this.canvas.height=n}renderSilhouette(e,t,n="none"){const{width:i,height:s}=e;this.context.save(),this.context.drawImage(t,0,0,t.width,t.height,0,0,i,s),this.context.filter="blur(5px)",this.context.globalCompositeOperation="source-in",this.context.drawImage(t,0,0,t.width,t.height,0,0,i,s),this.context.globalCompositeOperation="source-in",this.context.filter=n,this.context.drawImage(e,0,0,i,s,0,0,this.canvas.width,this.canvas.height),this.context.restore()}destroy(){}}class to extends rr{constructor(e){super(),this.radius=e}async render(e,t){super.resizeCanvas(e);const n=await createImageBitmap(t);return this.renderSilhouette(e,n),this.context.save(),this.context.filter=`blur(${this.radius}px)`,this.context.globalCompositeOperation="destination-over",this.context.drawImage(e,0,0,e.width,e.height),this.context.restore(),super.render(e,t)}}class ro extends rr{constructor(e){super(),this.radius=e}async render(e,t){super.resizeCanvas(e);const n=await createImageBitmap(t);return this.renderSilhouette(e,n,`blur(${this.radius}px)`),this.context.save(),this.context.filter="none",this.context.globalCompositeOperation="destination-over",this.context.drawImage(e,0,0,e.width,e.height),this.context.restore(),super.render(e,t)}}class no extends rr{setBackgroundImage(e){this.backgroundImage=e}async render(e,t){super.resizeCanvas(e);const n=await createImageBitmap(t);return this.renderSilhouette(e,n),this.backgroundImage&&(this.context.save(),this.context.filter="none",this.context.globalCompositeOperation="destination-over",this.context.drawImage(this.backgroundImage,0,0,this.backgroundImage.width,this.backgroundImage.height,0,0,e.width,e.height),this.context.restore()),super.render(e,t)}}const nr=5120,Ne=5121,ir=5122,sr=5123,or=5124,ar=5125,cr=5126,io=32819,so=32820,oo=33635,ao=5131,co=33640,uo=35899,fo=35902,lo=36269,ho=34042,fn={};{const r=fn;r[nr]=Int8Array,r[Ne]=Uint8Array,r[ir]=Int16Array,r[sr]=Uint16Array,r[or]=Int32Array,r[ar]=Uint32Array,r[cr]=Float32Array,r[io]=Uint16Array,r[so]=Uint16Array,r[oo]=Uint16Array,r[ao]=Uint16Array,r[co]=Uint32Array,r[uo]=Uint32Array,r[fo]=Uint32Array,r[lo]=Uint32Array,r[ho]=Uint32Array}function ur(r){if(r instanceof Int8Array)return nr;if(r instanceof Uint8Array||r instanceof Uint8ClampedArray)return Ne;if(r instanceof Int16Array)return ir;if(r instanceof Uint16Array)return sr;if(r instanceof Int32Array)return or;if(r instanceof Uint32Array)return ar;if(r instanceof Float32Array)return cr;throw new Error("unsupported typed array type")}function ln(r){if(r===Int8Array)return nr;if(r===Uint8Array||r===Uint8ClampedArray)return Ne;if(r===Int16Array)return ir;if(r===Uint16Array)return sr;if(r===Int32Array)return or;if(r===Uint32Array)return ar;if(r===Float32Array)return cr;throw new Error("unsupported typed array type")}function dn(r){const e=fn[r];if(!e)throw new Error("unknown gl type");return e}const yt=typeof SharedArrayBuffer<"u"?function(e){return e&&e.buffer&&(e.buffer instanceof ArrayBuffer||e.buffer instanceof SharedArrayBuffer)}:function(e){return e&&e.buffer&&e.buffer instanceof ArrayBuffer};function hn(...r){console.error(...r)}const mn=new Map;function bt(r,e){if(!r||typeof r!="object")return!1;let t=mn.get(e);t||(t=new WeakMap,mn.set(e,t));let n=t.get(r);if(n===void 0){const i=Object.prototype.toString.call(r);n=i.substring(8,i.length-1)===e,t.set(r,n)}return n}function mo(r,e){return typeof WebGLBuffer<"u"&&bt(e,"WebGLBuffer")}function po(r,e){return typeof WebGLRenderbuffer<"u"&&bt(e,"WebGLRenderbuffer")}function fr(r,e){return typeof WebGLTexture<"u"&&bt(e,"WebGLTexture")}function go(r,e){return typeof WebGLSampler<"u"&&bt(e,"WebGLSampler")}const pn=35044,he=34962,yo=34963,bo=34660,xo=5120,_o=5121,Eo=5122,wo=5123,vo=5124,To=5125,gn=5126,yn={attribPrefix:""};function Ao(r,e,t,n,i){r.bindBuffer(e,t),r.bufferData(e,n,i||pn)}function bn(r,e,t,n){if(mo(r,e))return e;t=t||he;const i=r.createBuffer();return Ao(r,t,i,e,n),i}function xn(r){return r==="indices"}function Io(r){return r===Int8Array||r===Uint8Array}function So(r){return r.length?r:r.data}const Ro=/coord|texture/i,Fo=/color|colour/i;function Po(r,e){let t;if(Ro.test(r)?t=2:Fo.test(r)?t=4:t=3,e%t>0)throw new Error(`Can not guess numComponents for attribute \'${r}\'. Tried ${t} but ${e} values is not evenly divisible by ${t}. You should specify it.`);return t}function ko(r,e,t){return r.numComponents||r.size||Po(e,t||So(r).length)}function _n(r,e){if(yt(r))return r;if(yt(r.data))return r.data;Array.isArray(r)&&(r={data:r});let t=r.type?lr(r.type):void 0;return t||(xn(e)?t=Uint16Array:t=Float32Array),new t(r.data)}function Co(r){return typeof r=="number"?r:r?ln(r):gn}function lr(r){return typeof r=="number"?dn(r):r||Float32Array}function Bo(r,e){return{buffer:e.buffer,numValues:24,type:Co(e.type),arrayType:lr(e.type)}}function Do(r,e){const t=e.data||e,n=lr(e.type),i=t*n.BYTES_PER_ELEMENT,s=r.createBuffer();return r.bindBuffer(he,s),r.bufferData(he,i,e.drawType||pn),{buffer:s,numValues:t,type:ln(n),arrayType:n}}function Mo(r,e,t){const n=_n(e,t);return{arrayType:n.constructor,buffer:bn(r,n,void 0,e.drawType),type:ur(n),numValues:0}}function Oo(r,e){const t={};return Object.keys(e).forEach(function(n){if(!xn(n)){const i=e[n],s=i.attrib||i.name||i.attribName||yn.attribPrefix+n;if(i.value){if(!Array.isArray(i.value)&&!yt(i.value))throw new Error("array.value is not array or typedarray");t[s]={value:i.value}}else{let o;i.buffer&&i.buffer instanceof WebGLBuffer?o=Bo:typeof i=="number"||typeof i.data=="number"?o=Do:o=Mo;const{buffer:a,type:c,numValues:u,arrayType:d}=o(r,i,n),m=i.normalize!==void 0?i.normalize:Io(d),p=ko(i,n,u);t[s]={buffer:a,numComponents:p,type:c,normalize:m,stride:i.stride||0,offset:i.offset||0,divisor:i.divisor===void 0?void 0:i.divisor,drawType:i.drawType}}}}),r.bindBuffer(he,null),t}function Uo(r,e){return e===xo||e===_o?1:e===Eo||e===wo?2:e===vo||e===To||e===gn?4:0}const dr=["position","positions","a_position"];function No(r,e){let t,n;for(n=0;n<dr.length&&(t=dr[n],!(t in e||(t=yn.attribPrefix+t,t in e)));++n);n===dr.length&&(t=Object.keys(e)[0]);const i=e[t];if(!i.buffer)return 1;r.bindBuffer(he,i.buffer);const s=r.getBufferParameter(he,bo);r.bindBuffer(he,null);const o=Uo(r,i.type),a=s/o,c=i.numComponents||i.size,u=a/c;if(u%1!==0)throw new Error(`numComponents ${c} not correct for length ${length}`);return u}function Lo(r,e,t){const n=Oo(r,e),i=Object.assign({},t||{});i.attribs=Object.assign({},t?t.attribs:{},n);const s=e.indices;if(s){const o=_n(s,"indices");i.indices=bn(r,o,yo),i.numElements=o.length,i.elementType=ur(o)}else i.numElements||(i.numElements=No(r,i.attribs));return i}function Le(r){return!!r.texStorage2D}const En=(function(){const r={},e={};function t(n){const i=n.constructor.name;if(!r[i]){for(const s in n)if(typeof n[s]=="number"){const o=e[n[s]];e[n[s]]=o?`${o} | ${s}`:s}r[i]=!0}}return function(i,s){return t(i),e[s]||(typeof s=="number"?`0x${s.toString(16)}`:s)}})(),te={textureColor:new Uint8Array([128,192,255,255]),textureOptions:{},crossOrigin:void 0},ze=yt,wn=(function(){let r;return function(){return r=r||(typeof document<"u"&&document.createElement?document.createElement("canvas").getContext("2d"):null),r}})(),vn=6406,V=6407,A=6408,Tn=6409,An=6410,Ge=6402,In=34041,xt=33071,zo=9728,Go=9729,re=3553,ne=34067,me=32879,pe=35866,hr=34069,$o=34070,Wo=34071,Vo=34072,Ho=34073,jo=34074,mr=10241,pr=10240,_t=10242,Et=10243,Sn=32882,Xo=33082,Yo=33083,Qo=33084,qo=33085,Ko=34892,Jo=34893,gr=3317,Rn=3314,Fn=32878,Pn=3316,kn=3315,Cn=32877,Zo=37443,ea=37441,ta=37440,ra=33321,na=36756,ia=33325,sa=33326,oa=33330,aa=33329,ca=33338,ua=33337,fa=33340,la=33339,da=33323,ha=36757,ma=33327,pa=33328,ga=33336,ya=33335,ba=33332,xa=33331,_a=33334,Ea=33333,wa=32849,va=35905,Ta=36194,Aa=36758,Ia=35898,Sa=35901,Ra=34843,Fa=34837,Pa=36221,ka=36239,Ca=36215,Ba=36233,Da=36209,Ma=36227,Oa=32856,Ua=35907,Na=36759,La=32855,za=32854,Ga=32857,$a=34842,Wa=34836,Va=36220,Ha=36238,ja=36975,Xa=36214,Ya=36232,Qa=36226,qa=36208,Ka=33189,Ja=33190,Za=36012,ec=36013,tc=35056,ie=5120,T=5121,wt=5122,Se=5123,vt=5124,ge=5125,B=5126,Bn=32819,Dn=32820,Mn=33635,z=5131,$e=36193,yr=33640,rc=35899,nc=35902,ic=36269,sc=34042,Tt=33319,Re=33320,At=6403,Fe=36244,Pe=36248,ye=36249;let br;function It(r){if(!br){const e={};e[vn]={textureFormat:vn,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1,2,2,4],type:[T,z,$e,B]},e[Tn]={textureFormat:Tn,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1,2,2,4],type:[T,z,$e,B]},e[An]={textureFormat:An,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[2,4,4,8],type:[T,z,$e,B]},e[V]={textureFormat:V,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3,6,6,12,2],type:[T,z,$e,B,Mn]},e[A]={textureFormat:A,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,8,8,16,2,2],type:[T,z,$e,B,Bn,Dn]},e[Ge]={textureFormat:Ge,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2,4],type:[ge,Se]},e[ra]={textureFormat:At,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1],type:[T]},e[na]={textureFormat:At,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[1],type:[ie]},e[ia]={textureFormat:At,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[4,2],type:[B,z]},e[sa]={textureFormat:At,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[4],type:[B]},e[oa]={textureFormat:Fe,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[1],type:[T]},e[aa]={textureFormat:Fe,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[1],type:[ie]},e[ba]={textureFormat:Fe,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[Se]},e[xa]={textureFormat:Fe,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[wt]},e[_a]={textureFormat:Fe,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[ge]},e[Ea]={textureFormat:Fe,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[vt]},e[da]={textureFormat:Tt,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[2],type:[T]},e[ha]={textureFormat:Tt,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[2],type:[ie]},e[ma]={textureFormat:Tt,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[8,4],type:[B,z]},e[pa]={textureFormat:Tt,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[8],type:[B]},e[ga]={textureFormat:Re,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[T]},e[ya]={textureFormat:Re,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[ie]},e[ca]={textureFormat:Re,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[Se]},e[ua]={textureFormat:Re,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[wt]},e[fa]={textureFormat:Re,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[ge]},e[la]={textureFormat:Re,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[vt]},e[wa]={textureFormat:V,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3],type:[T]},e[va]={textureFormat:V,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[3],type:[T]},e[Ta]={textureFormat:V,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3,2],type:[T,Mn]},e[Aa]={textureFormat:V,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[3],type:[ie]},e[Ia]={textureFormat:V,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6,4],type:[B,z,rc]},e[Sa]={textureFormat:V,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6,4],type:[B,z,nc]},e[Ra]={textureFormat:V,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6],type:[B,z]},e[Fa]={textureFormat:V,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[B]},e[Pa]={textureFormat:Pe,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[3],type:[T]},e[ka]={textureFormat:Pe,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[3],type:[ie]},e[Ca]={textureFormat:Pe,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[6],type:[Se]},e[Ba]={textureFormat:Pe,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[6],type:[wt]},e[Da]={textureFormat:Pe,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[ge]},e[Ma]={textureFormat:Pe,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[vt]},e[Oa]={textureFormat:A,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[T]},e[Ua]={textureFormat:A,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[T]},e[Na]={textureFormat:A,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[4],type:[ie]},e[La]={textureFormat:A,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,2,4],type:[T,Dn,yr]},e[za]={textureFormat:A,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,2],type:[T,Bn]},e[Ga]={textureFormat:A,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[yr]},e[$a]={textureFormat:A,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[16,8],type:[B,z]},e[Wa]={textureFormat:A,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[16],type:[B]},e[Va]={textureFormat:ye,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[T]},e[Ha]={textureFormat:ye,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[ie]},e[ja]={textureFormat:ye,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[yr]},e[Xa]={textureFormat:ye,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[Se]},e[Ya]={textureFormat:ye,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[wt]},e[Qa]={textureFormat:ye,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[16],type:[vt]},e[qa]={textureFormat:ye,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[16],type:[ge]},e[Ka]={textureFormat:Ge,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2,4],type:[Se,ge]},e[Ja]={textureFormat:Ge,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[ge]},e[Za]={textureFormat:Ge,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[B]},e[tc]={textureFormat:In,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[sc]},e[ec]={textureFormat:In,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[ic]},Object.keys(e).forEach(function(t){const n=e[t];n.bytesPerElementMap={},n.bytesPerElement.forEach(function(i,s){const o=n.type[s];n.bytesPerElementMap[o]=i})}),br=e}return br[r]}function oc(r,e){const t=It(r);if(!t)throw"unknown internal format";const n=t.bytesPerElementMap[e];if(n===void 0)throw"unknown internal format";return n}function We(r){const e=It(r);if(!e)throw"unknown internal format";return{format:e.textureFormat,type:e.type[0]}}function On(r){return(r&r-1)===0}function ac(r,e,t,n){if(!Le(r))return On(e)&&On(t);const i=It(n);if(!i)throw"unknown internal format";return i.colorRenderable&&i.textureFilterable}function cc(r){const e=It(r);if(!e)throw"unknown internal format";return e.textureFilterable}function uc(r,e,t){return ze(e)?ur(e):t||T}function St(r,e,t,n,i){if(i%1!==0)throw"can\'t guess dimensions";if(!t&&!n){const s=Math.sqrt(i/(e===ne?6:1));s%1===0?(t=s,n=s):(t=i,n=1)}else if(n){if(!t&&(t=i/n,t%1))throw"can\'t guess dimensions"}else if(n=i/t,n%1)throw"can\'t guess dimensions";return{width:t,height:n}}function ke(r,e){e.colorspaceConversion!==void 0&&r.pixelStorei(Zo,e.colorspaceConversion),e.premultiplyAlpha!==void 0&&r.pixelStorei(ea,e.premultiplyAlpha),e.flipY!==void 0&&r.pixelStorei(ta,e.flipY)}function Un(r){r.pixelStorei(gr,4),Le(r)&&(r.pixelStorei(Rn,0),r.pixelStorei(Fn,0),r.pixelStorei(Pn,0),r.pixelStorei(kn,0),r.pixelStorei(Cn,0))}function fc(r,e,t,n){n.minMag&&(t.call(r,e,mr,n.minMag),t.call(r,e,pr,n.minMag)),n.min&&t.call(r,e,mr,n.min),n.mag&&t.call(r,e,pr,n.mag),n.wrap&&(t.call(r,e,_t,n.wrap),t.call(r,e,Et,n.wrap),(e===me||go(r,e))&&t.call(r,e,Sn,n.wrap)),n.wrapR&&t.call(r,e,Sn,n.wrapR),n.wrapS&&t.call(r,e,_t,n.wrapS),n.wrapT&&t.call(r,e,Et,n.wrapT),n.minLod!==void 0&&t.call(r,e,Xo,n.minLod),n.maxLod!==void 0&&t.call(r,e,Yo,n.maxLod),n.baseLevel!==void 0&&t.call(r,e,Qo,n.baseLevel),n.maxLevel!==void 0&&t.call(r,e,qo,n.maxLevel),n.compareFunc!==void 0&&t.call(r,e,Jo,n.compareFunc),n.compareMode!==void 0&&t.call(r,e,Ko,n.compareMode)}function Nn(r,e,t){const n=t.target||re;r.bindTexture(n,e),fc(r,n,r.texParameteri,t)}function lc(r){return r=r||te.textureColor,ze(r)?r:new Uint8Array([r[0]*255,r[1]*255,r[2]*255,r[3]*255])}function xr(r,e,t,n,i,s){t=t||te.textureOptions,s=s||A;const o=t.target||re;if(n=n||t.width,i=i||t.height,r.bindTexture(o,e),ac(r,n,i,s))r.generateMipmap(o);else{const a=cc(s)?Go:zo;r.texParameteri(o,mr,a),r.texParameteri(o,pr,a),r.texParameteri(o,_t,xt),r.texParameteri(o,Et,xt)}}function Ve(r){return r.auto===!0||r.auto===void 0&&r.level===void 0}function _r(r,e){return e=e||{},e.cubeFaceOrder||[hr,$o,Wo,Vo,Ho,jo]}function Er(r,e){const n=_r(r,e).map(function(i,s){return{face:i,ndx:s}});return n.sort(function(i,s){return i.face-s.face}),n}function Ln(r,e,t,n){n=n||te.textureOptions;const i=n.target||re,s=n.level||0;let o=t.width,a=t.height;const c=n.internalFormat||n.format||A,u=We(c),d=n.format||u.format,m=n.type||u.type;if(ke(r,n),r.bindTexture(i,e),i===ne){const p=t.width,y=t.height;let l,b;if(p/6===y)l=y,b=[0,0,1,0,2,0,3,0,4,0,5,0];else if(y/6===p)l=p,b=[0,0,0,1,0,2,0,3,0,4,0,5];else if(p/3===y/2)l=p/3,b=[0,0,1,0,2,0,0,1,1,1,2,1];else if(p/2===y/3)l=p/2,b=[0,0,1,0,0,1,1,1,0,2,1,2];else throw"can\'t figure out cube map from element: "+(t.src?t.src:t.nodeName);const _=wn();_?(_.canvas.width=l,_.canvas.height=l,o=l,a=l,Er(r,n).forEach(function(E){const R=b[E.ndx*2+0]*l,k=b[E.ndx*2+1]*l;_.drawImage(t,R,k,l,l,0,0,l,l),r.texImage2D(E.face,s,c,d,m,_.canvas)}),_.canvas.width=1,_.canvas.height=1):typeof createImageBitmap<"u"&&(o=l,a=l,Er(r,n).forEach(function(E){const R=b[E.ndx*2+0]*l,k=b[E.ndx*2+1]*l;r.texImage2D(E.face,s,c,l,l,0,d,m,null),createImageBitmap(t,R,k,l,l,{premultiplyAlpha:"none",colorSpaceConversion:"none"}).then(function(N){ke(r,n),r.bindTexture(i,e),r.texImage2D(E.face,s,c,d,m,N),Ve(n)&&xr(r,e,n,o,a,c)})}))}else if(i===me||i===pe){const p=Math.min(t.width,t.height),y=Math.max(t.width,t.height),l=y/p;if(l%1!==0)throw"can not compute 3D dimensions of element";const b=t.width===y?1:0,_=t.height===y?1:0;r.pixelStorei(gr,1),r.pixelStorei(Rn,t.width),r.pixelStorei(Fn,0),r.pixelStorei(Cn,0),r.texImage3D(i,s,c,p,p,p,0,d,m,null);for(let E=0;E<l;++E){const R=E*p*b,k=E*p*_;r.pixelStorei(Pn,R),r.pixelStorei(kn,k),r.texSubImage3D(i,s,0,0,E,p,p,1,d,m,t)}Un(r)}else r.texImage2D(i,s,c,d,m,t);Ve(n)&&xr(r,e,n,o,a,c),Nn(r,e,n)}function He(){}function dc(r){if(typeof document<"u"){const e=document.createElement("a");return e.href=r,e.hostname===location.hostname&&e.port===location.port&&e.protocol===location.protocol}else{const e=new URL(location.href).origin;return new URL(r,location.href).origin===e}}function hc(r,e){return e===void 0&&!dc(r)?"anonymous":e}function mc(r,e,t){t=t||He;let n;if(e=e!==void 0?e:te.crossOrigin,e=hc(r,e),typeof Image<"u"){n=new Image,e!==void 0&&(n.crossOrigin=e);const i=function(){n.removeEventListener("error",s),n.removeEventListener("load",o),n=null},s=function(){const c="couldn\'t load image: "+r;hn(c),t(c,n),i()},o=function(){t(null,n),i()};return n.addEventListener("error",s),n.addEventListener("load",o),n.src=r,n}else if(typeof ImageBitmap<"u"){let i,s;const o=function(){t(i,s)},a={};e&&(a.mode="cors"),fetch(r,a).then(function(c){if(!c.ok)throw c;return c.blob()}).then(function(c){return createImageBitmap(c,{premultiplyAlpha:"none",colorSpaceConversion:"none"})}).then(function(c){s=c,setTimeout(o)}).catch(function(c){i=c,setTimeout(o)}),n=null}return n}function zn(r){return typeof ImageBitmap<"u"&&r instanceof ImageBitmap||typeof ImageData<"u"&&r instanceof ImageData||typeof HTMLElement<"u"&&r instanceof HTMLElement}function wr(r,e,t){return zn(r)?(setTimeout(function(){t(null,r)}),r):mc(r,e,t)}function vr(r,e,t){t=t||te.textureOptions;const n=t.target||re;if(r.bindTexture(n,e),t.color===!1)return;const i=lc(t.color);if(n===ne)for(let s=0;s<6;++s)r.texImage2D(hr+s,0,A,1,1,0,A,T,i);else n===me||n===pe?r.texImage3D(n,0,A,1,1,1,0,A,T,i):r.texImage2D(n,0,A,1,1,0,A,T,i)}function pc(r,e,t,n){return n=n||He,t=t||te.textureOptions,vr(r,e,t),t=Object.assign({},t),wr(t.src,t.crossOrigin,function(s,o){s?n(s,e,o):(Ln(r,e,o,t),n(null,e,o))})}function gc(r,e,t,n){n=n||He;const i=t.src;if(i.length!==6)throw"there must be 6 urls for a cubemap";const s=t.level||0,o=t.internalFormat||t.format||A,a=We(o),c=t.format||a.format,u=t.type||T,d=t.target||re;if(d!==ne)throw"target must be TEXTURE_CUBE_MAP";vr(r,e,t),t=Object.assign({},t);let m=6;const p=[],y=_r(r,t);let l;function b(_){return function(E,R){--m,E?p.push(E):R.width!==R.height?p.push("cubemap face img is not a square: "+R.src):(ke(r,t),r.bindTexture(d,e),m===5?_r().forEach(function(k){r.texImage2D(k,s,o,c,u,R)}):r.texImage2D(_,s,o,c,u,R),Ve(t)&&r.generateMipmap(d)),m===0&&n(p.length?p:void 0,e,l)}}l=i.map(function(_,E){return wr(_,t.crossOrigin,b(y[E]))})}function yc(r,e,t,n){n=n||He;const i=t.src,s=t.internalFormat||t.format||A,o=We(s),a=t.format||o.format,c=t.type||T,u=t.target||pe;if(u!==me&&u!==pe)throw"target must be TEXTURE_3D or TEXTURE_2D_ARRAY";vr(r,e,t),t=Object.assign({},t);let d=i.length;const m=[];let p;const y=t.level||0;let l=t.width,b=t.height;const _=i.length;let E=!0;function R(k){return function(N,Q){if(--d,N)m.push(N);else{if(ke(r,t),r.bindTexture(u,e),E){E=!1,l=t.width||Q.width,b=t.height||Q.height,r.texImage3D(u,y,s,l,b,_,0,a,c,null);for(let q=0;q<_;++q)r.texSubImage3D(u,y,0,0,q,l,b,1,a,c,Q)}else{let q=Q,L;(Q.width!==l||Q.height!==b)&&(L=wn(),q=L.canvas,L.canvas.width=l,L.canvas.height=b,L.drawImage(Q,0,0,l,b)),r.texSubImage3D(u,y,0,0,k,l,b,1,a,c,q),L&&q===L.canvas&&(L.canvas.width=0,L.canvas.height=0)}Ve(t)&&r.generateMipmap(u)}d===0&&n(m.length?m:void 0,e,p)}}p=i.map(function(k,N){return wr(k,t.crossOrigin,R(N))})}function bc(r,e,t,n){n=n||te.textureOptions;const i=n.target||re;r.bindTexture(i,e);let s=n.width,o=n.height,a=n.depth;const c=n.level||0,u=n.internalFormat||n.format||A,d=We(u),m=n.format||d.format,p=n.type||uc(r,t,d.type);if(ze(t))t instanceof Uint8ClampedArray&&(t=new Uint8Array(t.buffer));else{const _=dn(p);t=new _(t)}const y=oc(u,p),l=t.byteLength/y;if(l%1)throw"length wrong size for format: "+En(r,m);let b;if(i===me||i===pe)if(!s&&!o&&!a){const _=Math.cbrt(l);if(_%1!==0)throw"can\'t guess cube size of array of numElements: "+l;s=_,o=_,a=_}else s&&(!o||!a)?(b=St(r,i,o,a,l/s),o=b.width,a=b.height):o&&(!s||!a)?(b=St(r,i,s,a,l/o),s=b.width,a=b.height):(b=St(r,i,s,o,l/a),s=b.width,o=b.height);else b=St(r,i,s,o,l),s=b.width,o=b.height;if(Un(r),r.pixelStorei(gr,n.unpackAlignment||1),ke(r,n),i===ne){const _=y/t.BYTES_PER_ELEMENT,E=l/6*_;Er(r,n).forEach(R=>{const k=E*R.ndx,N=t.subarray(k,k+E);r.texImage2D(R.face,c,u,s,o,0,m,p,N)})}else i===me||i===pe?r.texImage3D(i,c,u,s,o,a,0,m,p,t):r.texImage2D(i,c,u,s,o,0,m,p,t);return{width:s,height:o,depth:a,type:p}}function xc(r,e,t){const n=t.target||re;r.bindTexture(n,e);const i=t.level||0,s=t.internalFormat||t.format||A,o=We(s),a=t.format||o.format,c=t.type||o.type;if(ke(r,t),n===ne)for(let u=0;u<6;++u)r.texImage2D(hr+u,i,s,t.width,t.height,0,a,c,null);else n===me||n===pe?r.texImage3D(n,i,s,t.width,t.height,t.depth,0,a,c,null):r.texImage2D(n,i,s,t.width,t.height,0,a,c,null)}function Gn(r,e,t){t=t||He,e=e||te.textureOptions;const n=r.createTexture(),i=e.target||re;let s=e.width||1,o=e.height||1;const a=e.internalFormat||A;r.bindTexture(i,n),i===ne&&(r.texParameteri(i,_t,xt),r.texParameteri(i,Et,xt));let c=e.src;if(c)if(typeof c=="function"&&(c=c(r,e)),typeof c=="string")pc(r,n,e,t);else if(ze(c)||Array.isArray(c)&&(typeof c[0]=="number"||Array.isArray(c[0])||ze(c[0]))){const u=bc(r,n,c,e);s=u.width,o=u.height}else Array.isArray(c)&&(typeof c[0]=="string"||zn(c[0]))?i===ne?gc(r,n,e,t):yc(r,n,e,t):(Ln(r,n,c,e),s=c.width,o=c.height);else xc(r,n,e);return Ve(e)&&xr(r,n,e,s,o,a),Nn(r,n,e),n}const Tr=hn;function $n(r){return typeof document<"u"&&document.getElementById?document.getElementById(r):null}const Rt=33984,Ft=34962,_c=34963,Ec=35713,wc=35714,vc=35632,Tc=35633,Ac=35981,Wn=35718,Ic=35721,Sc=35971,Rc=35382,Fc=35396,Pc=35398,kc=35392,Cc=35395,Pt=5126,Vn=35664,Hn=35665,jn=35666,Ar=5124,Xn=35667,Yn=35668,Qn=35669,qn=35670,Kn=35671,Jn=35672,Zn=35673,ei=35674,ti=35675,ri=35676,Bc=35678,Dc=35680,Mc=35679,Oc=35682,Uc=35685,Nc=35686,Lc=35687,zc=35688,Gc=35689,$c=35690,Wc=36289,Vc=36292,Hc=36293,Ir=5125,ni=36294,ii=36295,si=36296,jc=36298,Xc=36299,Yc=36300,Qc=36303,qc=36306,Kc=36307,Jc=36308,Zc=36311,kt=3553,Ct=34067,Sr=32879,Bt=35866,x={};function oi(r,e){return x[e].bindPoint}function eu(r,e){return function(t){r.uniform1f(e,t)}}function tu(r,e){return function(t){r.uniform1fv(e,t)}}function ru(r,e){return function(t){r.uniform2fv(e,t)}}function nu(r,e){return function(t){r.uniform3fv(e,t)}}function iu(r,e){return function(t){r.uniform4fv(e,t)}}function ai(r,e){return function(t){r.uniform1i(e,t)}}function ci(r,e){return function(t){r.uniform1iv(e,t)}}function ui(r,e){return function(t){r.uniform2iv(e,t)}}function fi(r,e){return function(t){r.uniform3iv(e,t)}}function li(r,e){return function(t){r.uniform4iv(e,t)}}function su(r,e){return function(t){r.uniform1ui(e,t)}}function ou(r,e){return function(t){r.uniform1uiv(e,t)}}function au(r,e){return function(t){r.uniform2uiv(e,t)}}function cu(r,e){return function(t){r.uniform3uiv(e,t)}}function uu(r,e){return function(t){r.uniform4uiv(e,t)}}function fu(r,e){return function(t){r.uniformMatrix2fv(e,!1,t)}}function lu(r,e){return function(t){r.uniformMatrix3fv(e,!1,t)}}function du(r,e){return function(t){r.uniformMatrix4fv(e,!1,t)}}function hu(r,e){return function(t){r.uniformMatrix2x3fv(e,!1,t)}}function mu(r,e){return function(t){r.uniformMatrix3x2fv(e,!1,t)}}function pu(r,e){return function(t){r.uniformMatrix2x4fv(e,!1,t)}}function gu(r,e){return function(t){r.uniformMatrix4x2fv(e,!1,t)}}function yu(r,e){return function(t){r.uniformMatrix3x4fv(e,!1,t)}}function bu(r,e){return function(t){r.uniformMatrix4x3fv(e,!1,t)}}function O(r,e,t,n){const i=oi(r,e);return Le(r)?function(s){let o,a;!s||fr(r,s)?(o=s,a=null):(o=s.texture,a=s.sampler),r.uniform1i(n,t),r.activeTexture(Rt+t),r.bindTexture(i,o),r.bindSampler(t,a)}:function(s){r.uniform1i(n,t),r.activeTexture(Rt+t),r.bindTexture(i,s)}}function U(r,e,t,n,i){const s=oi(r,e),o=new Int32Array(i);for(let a=0;a<i;++a)o[a]=t+a;return Le(r)?function(a){r.uniform1iv(n,o),a.forEach(function(c,u){r.activeTexture(Rt+o[u]);let d,m;!c||fr(r,c)?(d=c,m=null):(d=c.texture,m=c.sampler),r.bindSampler(t,m),r.bindTexture(s,d)})}:function(a){r.uniform1iv(n,o),a.forEach(function(c,u){r.activeTexture(Rt+o[u]),r.bindTexture(s,c)})}}x[Pt]={Type:Float32Array,size:4,setter:eu,arraySetter:tu},x[Vn]={Type:Float32Array,size:8,setter:ru,cols:2},x[Hn]={Type:Float32Array,size:12,setter:nu,cols:3},x[jn]={Type:Float32Array,size:16,setter:iu,cols:4},x[Ar]={Type:Int32Array,size:4,setter:ai,arraySetter:ci},x[Xn]={Type:Int32Array,size:8,setter:ui,cols:2},x[Yn]={Type:Int32Array,size:12,setter:fi,cols:3},x[Qn]={Type:Int32Array,size:16,setter:li,cols:4},x[Ir]={Type:Uint32Array,size:4,setter:su,arraySetter:ou},x[ni]={Type:Uint32Array,size:8,setter:au,cols:2},x[ii]={Type:Uint32Array,size:12,setter:cu,cols:3},x[si]={Type:Uint32Array,size:16,setter:uu,cols:4},x[qn]={Type:Uint32Array,size:4,setter:ai,arraySetter:ci},x[Kn]={Type:Uint32Array,size:8,setter:ui,cols:2},x[Jn]={Type:Uint32Array,size:12,setter:fi,cols:3},x[Zn]={Type:Uint32Array,size:16,setter:li,cols:4},x[ei]={Type:Float32Array,size:32,setter:fu,rows:2,cols:2},x[ti]={Type:Float32Array,size:48,setter:lu,rows:3,cols:3},x[ri]={Type:Float32Array,size:64,setter:du,rows:4,cols:4},x[Uc]={Type:Float32Array,size:32,setter:hu,rows:2,cols:3},x[Nc]={Type:Float32Array,size:32,setter:pu,rows:2,cols:4},x[Lc]={Type:Float32Array,size:48,setter:mu,rows:3,cols:2},x[zc]={Type:Float32Array,size:48,setter:yu,rows:3,cols:4},x[Gc]={Type:Float32Array,size:64,setter:gu,rows:4,cols:2},x[$c]={Type:Float32Array,size:64,setter:bu,rows:4,cols:3},x[Bc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:kt},x[Dc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Ct},x[Mc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Sr},x[Oc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:kt},x[Wc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Bt},x[Vc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Bt},x[Hc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Ct},x[jc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:kt},x[Xc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Sr},x[Yc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Ct},x[Qc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Bt},x[qc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:kt},x[Kc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Sr},x[Jc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Ct},x[Zc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Bt};function Dt(r,e){return function(t){if(t.value)switch(r.disableVertexAttribArray(e),t.value.length){case 4:r.vertexAttrib4fv(e,t.value);break;case 3:r.vertexAttrib3fv(e,t.value);break;case 2:r.vertexAttrib2fv(e,t.value);break;case 1:r.vertexAttrib1fv(e,t.value);break;default:throw new Error("the length of a float constant value must be between 1 and 4!")}else r.bindBuffer(Ft,t.buffer),r.enableVertexAttribArray(e),r.vertexAttribPointer(e,t.numComponents||t.size,t.type||Pt,t.normalize||!1,t.stride||0,t.offset||0),r.vertexAttribDivisor&&r.vertexAttribDivisor(e,t.divisor||0)}}function se(r,e){return function(t){if(t.value)if(r.disableVertexAttribArray(e),t.value.length===4)r.vertexAttrib4iv(e,t.value);else throw new Error("The length of an integer constant value must be 4!");else r.bindBuffer(Ft,t.buffer),r.enableVertexAttribArray(e),r.vertexAttribIPointer(e,t.numComponents||t.size,t.type||Ar,t.stride||0,t.offset||0),r.vertexAttribDivisor&&r.vertexAttribDivisor(e,t.divisor||0)}}function Mt(r,e){return function(t){if(t.value)if(r.disableVertexAttribArray(e),t.value.length===4)r.vertexAttrib4uiv(e,t.value);else throw new Error("The length of an unsigned integer constant value must be 4!");else r.bindBuffer(Ft,t.buffer),r.enableVertexAttribArray(e),r.vertexAttribIPointer(e,t.numComponents||t.size,t.type||Ir,t.stride||0,t.offset||0),r.vertexAttribDivisor&&r.vertexAttribDivisor(e,t.divisor||0)}}function Rr(r,e,t){const n=t.size,i=t.count;return function(s){r.bindBuffer(Ft,s.buffer);const o=s.size||s.numComponents||n,a=o/i,c=s.type||Pt,d=x[c].size*o,m=s.normalize||!1,p=s.offset||0,y=d/i;for(let l=0;l<i;++l)r.enableVertexAttribArray(e+l),r.vertexAttribPointer(e+l,a,c,m,d,p+y*l),r.vertexAttribDivisor&&r.vertexAttribDivisor(e+l,s.divisor||0)}}const I={};I[Pt]={size:4,setter:Dt},I[Vn]={size:8,setter:Dt},I[Hn]={size:12,setter:Dt},I[jn]={size:16,setter:Dt},I[Ar]={size:4,setter:se},I[Xn]={size:8,setter:se},I[Yn]={size:12,setter:se},I[Qn]={size:16,setter:se},I[Ir]={size:4,setter:Mt},I[ni]={size:8,setter:Mt},I[ii]={size:12,setter:Mt},I[si]={size:16,setter:Mt},I[qn]={size:4,setter:se},I[Kn]={size:8,setter:se},I[Jn]={size:12,setter:se},I[Zn]={size:16,setter:se},I[ei]={size:4,setter:Rr,count:2},I[ti]={size:9,setter:Rr,count:3},I[ri]={size:16,setter:Rr,count:4};const xu=/ERROR:\\s*\\d+:(\\d+)/gi;function _u(r,e="",t=0){const n=[...e.matchAll(xu)],i=new Map(n.map((s,o)=>{const a=parseInt(s[1]),c=n[o+1],u=c?c.index:e.length,d=e.substring(s.index,u);return[a-1,d]}));return r.split(`\n`).map((s,o)=>{const a=i.get(o);return`${o+1+t}: ${s}${a?`\n\n^^^ ${a}`:""}`}).join(`\n`)}const di=/^[ \\t]*\\n/;function hi(r){let e=0;return di.test(r)&&(e=1,r=r.replace(di,"")),{lineOffset:e,shaderSource:r}}function Eu(r,e){return r.errorCallback(e),r.callback&&setTimeout(()=>{r.callback(`${e}\n${r.errors.join(`\n`)}`)}),null}function wu(r,e,t,n){if(n=n||Tr,!r.getShaderParameter(t,Ec)){const s=r.getShaderInfoLog(t),{lineOffset:o,shaderSource:a}=hi(r.getShaderSource(t)),c=`${_u(a,s,o)}\nError compiling ${En(r,e)}: ${s}`;return n(c),c}return""}function Fr(r,e,t){let n,i,s;if(typeof e=="function"&&(t=e,e=void 0),typeof r=="function")t=r,r=void 0;else if(r&&!Array.isArray(r)){const u=r;t=u.errorCallback,r=u.attribLocations,n=u.transformFeedbackVaryings,i=u.transformFeedbackMode,s=u.callback}const o=t||Tr,a=[],c={errorCallback(u,...d){a.push(u),o(u,...d)},transformFeedbackVaryings:n,transformFeedbackMode:i,callback:s,errors:a};{let u={};Array.isArray(r)?r.forEach(function(d,m){u[d]=e?e[m]:m}):u=r||{},c.attribLocations=u}return c}const vu=["VERTEX_SHADER","FRAGMENT_SHADER"];function Tu(r,e){if(e.indexOf("frag")>=0)return vc;if(e.indexOf("vert")>=0)return Tc}function Au(r,e,t){const n=r.getAttachedShaders(e);for(const i of n)t.has(i)&&r.deleteShader(i);r.deleteProgram(e)}const Iu=(r=0)=>new Promise(e=>setTimeout(e,r));function Su(r,e,t){const n=r.createProgram(),{attribLocations:i,transformFeedbackVaryings:s,transformFeedbackMode:o}=Fr(t);for(let a=0;a<e.length;++a){let c=e[a];if(typeof c=="string"){const u=$n(c),d=u?u.text:c;let m=r[vu[a]];u&&u.type&&(m=Tu(r,u.type)||m),c=r.createShader(m),r.shaderSource(c,hi(d).shaderSource),r.compileShader(c),r.attachShader(n,c)}}Object.entries(i).forEach(([a,c])=>r.bindAttribLocation(n,c,a));{let a=s;a&&(a.attribs&&(a=a.attribs),Array.isArray(a)||(a=Object.keys(a)),r.transformFeedbackVaryings(n,a,o||Ac))}return r.linkProgram(n),n}function Ru(r,e,t,n,i){const s=Fr(t,n,i),o=new Set(e),a=Su(r,e,s);function c(u,d){const m=Pu(u,d,s.errorCallback);return m&&Au(u,d,o),m}if(s.callback){Fu(r,a).then(()=>{const u=c(r,a);s.callback(u,u?void 0:a)});return}return c(r,a)?void 0:a}async function Fu(r,e){const t=r.getExtension("KHR_parallel_shader_compile"),n=t?(s,o)=>s.getProgramParameter(o,t.COMPLETION_STATUS_KHR):()=>!0;let i=0;do await Iu(i),i=1e3/60;while(!n(r,e))}function Pu(r,e,t){if(t=t||Tr,!r.getProgramParameter(e,wc)){const i=r.getProgramInfoLog(e);t(`Error in program linking: ${i}`);const o=r.getAttachedShaders(e).map(a=>wu(r,r.getShaderParameter(a,r.SHADER_TYPE),a,t));return`${i}\n${o.filter(a=>a).join(`\n`)}`}}function ku(r,e,t,n,i){return Ru(r,e,t,n,i)}function mi(r){const e=r.name;return e.startsWith("gl_")||e.startsWith("webgl_")}const Cu=/(\\.|\\[|]|\\w+)/g,Bu=r=>r>="0"&&r<="9";function Du(r,e,t,n){const i=r.split(Cu).filter(a=>a!=="");let s=0,o="";for(;;){const a=i[s++];o+=a;const c=Bu(a[0]),u=c?parseInt(a):a;if(c&&(o+=i[s++]),s===i.length){t[u]=e;break}else{const m=i[s++],p=m==="[",y=t[u]||(p?[]:{});t[u]=y,t=y,n[o]=n[o]||(function(l){return function(b){pi(l,b)}})(y),o+=m}}}function Mu(r,e){let t=0;function n(a,c,u){const d=c.name.endsWith("[0]"),m=c.type,p=x[m];if(!p)throw new Error(`unknown type: 0x${m.toString(16)}`);let y;if(p.bindPoint){const l=t;t+=c.size,d?y=p.arraySetter(r,m,l,u,c.size):y=p.setter(r,m,l,u,c.size)}else p.arraySetter&&d?y=p.arraySetter(r,u):y=p.setter(r,u);return y.location=u,y}const i={},s={},o=r.getProgramParameter(e,Wn);for(let a=0;a<o;++a){const c=r.getActiveUniform(e,a);if(mi(c))continue;let u=c.name;u.endsWith("[0]")&&(u=u.substr(0,u.length-3));const d=r.getUniformLocation(e,c.name);if(d){const m=n(e,c,d);i[u]=m,Du(u,m,s,i)}}return i}function Ou(r,e){const t={},n=r.getProgramParameter(e,Sc);for(let i=0;i<n;++i){const s=r.getTransformFeedbackVarying(e,i);t[s.name]={index:i,type:s.type,size:s.size}}return t}function Uu(r,e){const t=r.getProgramParameter(e,Wn),n=[],i=[];for(let a=0;a<t;++a){i.push(a),n.push({});const c=r.getActiveUniform(e,a);n[a].name=c.name}[["UNIFORM_TYPE","type"],["UNIFORM_SIZE","size"],["UNIFORM_BLOCK_INDEX","blockNdx"],["UNIFORM_OFFSET","offset"]].forEach(function(a){const c=a[0],u=a[1];r.getActiveUniforms(e,i,r[c]).forEach(function(d,m){n[m][u]=d})});const s={},o=r.getProgramParameter(e,Rc);for(let a=0;a<o;++a){const c=r.getActiveUniformBlockName(e,a),u={index:r.getUniformBlockIndex(e,c),usedByVertexShader:r.getActiveUniformBlockParameter(e,a,Fc),usedByFragmentShader:r.getActiveUniformBlockParameter(e,a,Pc),size:r.getActiveUniformBlockParameter(e,a,kc),uniformIndices:r.getActiveUniformBlockParameter(e,a,Cc)};u.used=u.usedByVertexShader||u.usedByFragmentShader,s[c]=u}return{blockSpecs:s,uniformData:n}}function pi(r,e){for(const t in e){const n=r[t];typeof n=="function"?n(e[t]):pi(r[t],e[t])}}function gi(r,...e){const t=r.uniformSetters||r,n=e.length;for(let i=0;i<n;++i){const s=e[i];if(Array.isArray(s)){const o=s.length;for(let a=0;a<o;++a)gi(t,s[a])}else for(const o in s){const a=t[o];a&&a(s[o])}}}function Nu(r,e){const t={},n=r.getProgramParameter(e,Ic);for(let i=0;i<n;++i){const s=r.getActiveAttrib(e,i);if(mi(s))continue;const o=r.getAttribLocation(e,s.name),a=I[s.type],c=a.setter(r,o,a);c.location=o,t[s.name]=c}return t}function Lu(r,e){for(const t in e){const n=r[t];n&&n(e[t])}}function zu(r,e,t){t.vertexArrayObject?r.bindVertexArray(t.vertexArrayObject):(Lu(e.attribSetters||e,t.attribs),t.indices&&r.bindBuffer(_c,t.indices))}function yi(r,e){const t=Mu(r,e),n=Nu(r,e),i={program:e,uniformSetters:t,attribSetters:n};return Le(r)&&(i.uniformBlockSpec=Uu(r,e),i.transformFeedbackInfo=Ou(r,e)),i}const Gu=/\\s|{|}|;/;function $u(r,e,t,n,i){const s=Fr(t,n,i),o=[];if(e=e.map(function(u){if(!Gu.test(u)){const d=$n(u);if(d)u=d.text;else{const m=`no element with id: ${u}`;s.errorCallback(m),o.push(m)}}return u}),o.length)return Eu(s,"");const a=s.callback;a&&(s.callback=(u,d)=>{a(u,u?void 0:yi(r,d))});const c=ku(r,e,s);return c?yi(r,c):null}const Wu=4,bi=5123;function Vu(r,e,t,n,i,s){t=t===void 0?Wu:t;const o=e.indices,a=e.elementType,c=n===void 0?e.numElements:n;i=i===void 0?0:i,a||o?s!==void 0?r.drawElementsInstanced(t,c,a===void 0?bi:e.elementType,i,s):r.drawElements(t,c,a===void 0?bi:e.elementType,i):s!==void 0?r.drawArraysInstanced(t,i,c,s):r.drawArrays(t,i,c)}const xi=36160,Ot=36161,Hu=3553,ju=5121,Xu=6402,Yu=6408,Qu=33190,qu=36012,Ku=35056,Ju=36013,Zu=32854,ef=32855,tf=36194,_i=33189,Ei=6401,wi=36168,Pr=34041,kr=36064,Ut=36096,vi=36128,Cr=33306,Br=33071,Dr=9729,rf=[{format:Yu,type:ju,min:Dr,wrap:Br},{format:Pr}],G={};G[Pr]=Cr,G[Ei]=vi,G[wi]=vi,G[Xu]=Ut,G[_i]=Ut,G[Qu]=Ut,G[qu]=Ut,G[Ku]=Cr,G[Ju]=Cr;function nf(r,e){return G[r]||G[e]}const oe={};oe[Zu]=!0,oe[ef]=!0,oe[tf]=!0,oe[Pr]=!0,oe[_i]=!0,oe[Ei]=!0,oe[wi]=!0;function sf(r){return oe[r]}const of=32;function af(r){return r>=kr&&r<kr+of}function Ti(r,e,t,n){const i=xi,s=r.createFramebuffer();r.bindFramebuffer(i,s),t=t||r.drawingBufferWidth,n=n||r.drawingBufferHeight,e=e||rf;const o=[],a={framebuffer:s,attachments:[],width:t,height:n};return e.forEach(function(c,u){let d=c.attachment;const m=c.samples,p=c.format;let y=c.attachmentPoint||nf(p,c.internalFormat);if(y||(y=kr+u),af(y)&&o.push(y),!d)if(m!==void 0||sf(p))d=r.createRenderbuffer(),r.bindRenderbuffer(Ot,d),m>1?r.renderbufferStorageMultisample(Ot,m,p,t,n):r.renderbufferStorage(Ot,p,t,n);else{const l=Object.assign({},c);l.width=t,l.height=n,l.auto===void 0&&(l.auto=!1,l.min=l.min||l.minMag||Dr,l.mag=l.mag||l.minMag||Dr,l.wrapS=l.wrapS||l.wrap||Br,l.wrapT=l.wrapT||l.wrap||Br),d=Gn(r,l)}if(po(r,d))r.framebufferRenderbuffer(i,y,Ot,d);else if(fr(r,d))c.layer!==void 0?r.framebufferTextureLayer(i,y,d,c.level||0,c.layer):r.framebufferTexture2D(i,y,c.target||Hu,d,c.level||0);else throw new Error("unknown attachment type");a.attachments.push(d)}),r.drawBuffers&&r.drawBuffers(o),a}function cf(r,e,t){t=t||xi,e?(r.bindFramebuffer(t,e.framebuffer),r.viewport(0,0,e.width,e.height)):(r.bindFramebuffer(t,null),r.viewport(0,0,r.drawingBufferWidth,r.drawingBufferHeight))}function D(r,e){return()=>e instanceof WebGLTexture?e:Gn(r,{src:e,wrap:r.CLAMP_TO_EDGE})}const Ce=2;class je{constructor(e){this.id="_";const{context:t,width:n,height:i}=e;this.context=t,this.options=e;const s=this.buildDefines();this.programInfo=$u(this.context,[s+this.getVertexShader(),s+this.getFragmentShader()]),this.bufferInfo=Lo(this.context,this.getBuffers()),this.fbi=Ti(this.context,[{format:this.context.RGBA,type:this.context.UNSIGNED_BYTE,min:this.context.LINEAR,wrap:this.context.CLAMP_TO_EDGE}],n,i),this.output=this.fbi.attachments[0]}resizeOutput(e,t){this.fbi=Ti(this.context,[{format:this.context.RGBA,type:this.context.UNSIGNED_BYTE,min:this.context.LINEAR,wrap:this.context.CLAMP_TO_EDGE}],e,t),this.options.width=e,this.options.height=t,this.output=this.fbi.attachments[0]}getDefines(){return{}}getBuffers(){return{position:{numComponents:2,data:[-1,-1,-1,1,1,-1,1,1,-1,1,1,-1]},texture_coord:{numComponents:2,data:[0,0,0,1,1,0,1,1,0,1,1,0]}}}buildDefines(){let e="";const t=this.getDefines();for(let n in t)e+=`#define ${n} ${t[n].toFixed(1)}\n`;return e}run(e){this.profiler?.pushContext(`[${this.id}] PROG : ${this.constructor.name}`),this.profiler?.pushContext(`[${this.id}] UNIFORMS`);for(const i in e)typeof e[i]=="function"&&(this.profiler?.pushContext(`[${this.id}] UNI : ${i}`),e[i]=e[i](),this.profiler?.popContext(`[${this.id}] UNI : ${i}`));this.profiler?.popContext(`[${this.id}] UNIFORMS`);const t=Date.now();let n=0;this.lastRun&&(n=(t-this.lastRun)/1e3),this.lastRun=t,this.context.viewport(0,0,this.context.canvas.width,this.context.canvas.height),this.context.useProgram(this.programInfo.program),zu(this.context,this.programInfo,this.bufferInfo),gi(this.programInfo,{delta:n,canvas:[this.context.canvas.width,this.context.canvas.height],...e}),cf(this.context,this.options.disableFramebuffer?null:this.fbi),Vu(this.context,this.bufferInfo),this.profiler?.popContext(`[${this.id}] PROG : ${this.constructor.name}`)}setProfiler(e){this.profiler=e}}var uf=`precision mediump float;\n\nvarying vec2 _texture_coord;\n\nuniform sampler2D background;\nuniform sampler2D foreground;\nuniform sampler2D threshold;\n\nvoid main() {\n vec4 backgroundColor = texture2D(background, _texture_coord);\n vec4 foregroundColor = texture2D(foreground, _texture_coord);\n vec4 tresholdColor = texture2D(threshold, _texture_coord);\n gl_FragColor = foregroundColor * tresholdColor.a +\n backgroundColor * (1. - tresholdColor.a);\n}\n`,ff=`varying vec2 _texture_coord;\n\nattribute vec2 position;\nattribute vec2 texture_coord;\n\nvoid main() {\n gl_Position = vec4(position, 0., 1.);\n _texture_coord = texture_coord;\n _texture_coord.y = 1. - texture_coord.y;\n}\n`;class Mr extends je{getFragmentShader(){return uf}getVertexShader(){return ff}}class Or{constructor(){this.steps=[]}addStep(e){this.steps.push(e)}async run(){for(const e of this.steps)e.program.run(e.getUniforms())}resizeOutput(e,t){this.profiler?.pushContext(`PIP [${this.constructor.name}]`);for(const n of this.steps)n.preventResize||n.program.resizeOutput(e,t);this.profiler?.popContext(`PIP [${this.constructor.name}]`)}setProfiler(e){this.profiler=e;for(const t of this.steps)t.program.setProfiler(e)}setId(e){for(const t of this.steps)t.program.id=e}}class Ur extends Or{constructor(){super(...arguments),this.preciseMaskEnabled=!1}}class Ai extends Ur{constructor(e){super(),this.context=e,this.preciseMaskEnabled=!0;const t={context:e,height:e.canvas.height,width:e.canvas.width},n=new Mr({...t,disableFramebuffer:!0});this.addStep({program:n,getUniforms:()=>({background:D(e,this.inputBackgroundImage),foreground:D(e,this.inputImage),threshold:D(e,this.inputMask)})})}setData(e,t){this.inputImage=e,this.inputMask=t}}var lf=`precision mediump float;\n\nvarying vec2 _texture_coord;\nuniform sampler2D texture;\n\nvoid main() { gl_FragColor = texture2D(texture, _texture_coord); }\n`,df=`varying vec2 _texture_coord;\n\nattribute vec2 position;\nattribute vec2 texture_coord;\nuniform bool invert_y;\n\nvoid main() {\n gl_Position = vec4(position, 0., 1.);\n _texture_coord = texture_coord;\n if (invert_y) {\n _texture_coord.y = 1. - texture_coord.y;\n }\n}\n`;class hf extends je{getFragmentShader(){return lf}getVertexShader(){return df}}class mf extends Or{constructor(e,t,n){super(),this.context=e;const i={context:e,height:n,width:t};this.addStep({program:new hf({...i,disableFramebuffer:!0}),getUniforms:()=>({texture:D(e,this.inputImage),invert_y:!0})})}setData(e){this.inputImage=e}}async function Ii(r){return new Promise(e=>{setTimeout(()=>{e()},r)})}var pf=`precision mediump float;\n\nvarying vec2 _texture_coord;\n\nuniform vec2 canvas;\nuniform sampler2D texture;\n\nvec4 loop();\n\nvoid main() { gl_FragColor = loop(); }\n`,gf=`varying vec2 _texture_coord;\n\nattribute vec2 position;\nattribute vec2 texture_coord;\n\nvoid main() {\n gl_Position = vec4(position, 0., 1.);\n _texture_coord = texture_coord;\n}\n`,Nr=(r=>(r[r.LINEAR=0]="LINEAR",r[r.GAUSSIAN=1]="GAUSSIAN",r))(Nr||{});class Si extends je{getDefines(){return{RADIUS:this.options.radius??1}}getFragmentShader(){return pf+this.createLoopFunction()}getVertexShader(){return gf}createLoopFunction(){let e=this.options.radius??1;return`\n\n vec4 loop() { \n vec4 result = vec4(0,0,0,0);\n float factorSum = 0.;\n\n vec2 normalizedRadius = vec2(-${e}.) / canvas;\n vec2 normalizedIncrement = vec2(1.) / canvas;\n vec2 diff = normalizedRadius;\n\n for(int y=-${e}; y<${e+1}; ++y) {\n for(int x=-${e}; x<${e+1}; ++x) {\n float factor = 1.;\n result += factor * texture2D(texture, _texture_coord + diff);\n factorSum += factor;\n diff.x += normalizedIncrement.x;\n }\n diff.y += normalizedIncrement.y;\n diff.x = normalizedRadius.x;\n }\n return result / factorSum;\n }`}}var yf=`#version 300 es\n// https://github.com/Volcomix/virtual-background/blob/main/src/pipelines/webgl2/jointBilateralFilterStage.ts\n\nprecision highp float;\nuniform sampler2D input_frame;\nuniform sampler2D segmentation_mask;\nuniform sampler2D threshold;\nuniform vec2 texel_size;\nuniform float step;\nuniform float radius;\nuniform float offset;\nuniform float sigma_texel;\nuniform float sigma_color;\n\nin vec2 _texture_coord;\nout vec4 outColor;\n\nfloat gaussian(float x, float sigma) {\n float coeff = -0.5 / (sigma * sigma * 4.0 + 1.0e-6);\n return exp((x * x) * coeff);\n}\n\nvoid main() {\n vec2 centerCoord = _texture_coord;\n vec3 centerColor = texture(input_frame, centerCoord).rgb;\n float newVal = 0.0;\n float spaceWeight = 0.0;\n float colorWeight = 0.0;\n float totalWeight = 0.0;\n // Subsample kernel space.\n for (float i = -radius + offset; i <= radius; i += step) {\n for (float j = -radius + offset; j <= radius; j += step) {\n vec2 shift = vec2(j, i) * texel_size;\n vec2 coord = vec2(centerCoord + shift);\n vec3 frameColor = texture(input_frame, coord).rgb;\n float threshold = texture(threshold, coord).a;\n float outVal = texture(segmentation_mask, coord).a;\n\n spaceWeight = gaussian(distance(centerCoord, coord), sigma_texel);\n colorWeight = gaussian(distance(centerColor, frameColor), sigma_color);\n totalWeight += spaceWeight * colorWeight;\n newVal += spaceWeight * colorWeight * outVal * threshold;\n }\n }\n newVal /= totalWeight;\n outColor = vec4(vec3(0.), newVal);\n}`,bf=`#version 300 es\nin vec2 position;\nin vec2 texture_coord;\nout vec2 _texture_coord;\nvoid main() {\n gl_Position = vec4(position, 0.0, 1.0);\n _texture_coord = texture_coord;\n}`;class xf extends je{getFragmentShader(){return yf}getVertexShader(){return bf}}class _f extends Or{constructor(e,t,n){super(),this.context=e;const i={context:e,height:n,width:t},s=new Si({...i,radius:1,type:Nr.GAUSSIAN});this.jointBilateral=new xf(i),this.addStep({program:s,getUniforms:()=>({inputs:D(e,this.inputMask)})}),this.addStep({program:this.jointBilateral,getUniforms:()=>{const a=this.inputImage?.width??1,c=this.inputImage?.height??1;this.inputMask?.width,this.inputMask?.height;const u=3,d=Math.max(1,Math.sqrt(u)*.66),m=1/a,p=1/c;return{input_frame:D(e,this.inputImage),segmentation_mask:D(e,this.inputMask),texel_size:[m,p],step:d,radius:u,offset:d>1?d*.5:0,sigma_texel:Math.max(m,p)*u,sigma_color:u}}}),this.output=this.jointBilateral.output}setData(e,t){this.previousInputImage=this.inputImage?this.inputImage:e,this.previousInputMask=this.inputMask?this.inputMask:t,this.inputImage=e,this.inputMask=t}resizeOutput(e,t){super.resizeOutput(e,t),this.output=this.jointBilateral.output}}class Ef{constructor(e){this.queries=[],this.context=e,this.extension=e.getExtension("EXT_disjoint_timer_query_webgl2")}start(){}stop(){this.activeQuery&&this.context.endQuery(this.extension.TIME_ELAPSED_EXT)}pushContext(e){this.createQuery("PUSH",e)}popContext(e){this.createQuery("POP",e)}createQuery(e,t){this.activeQuery&&this.context.endQuery(this.extension.TIME_ELAPSED_EXT),this.activeQuery=this.context.createQuery(),this.context.beginQuery(this.extension.TIME_ELAPSED_EXT,this.activeQuery),this.queries.push({name:t,action:e,query:this.activeQuery})}async getResolvedQueries(){const e=(await Promise.all([...this.queries].map(t=>this.resolveQuery(t)))).filter(t=>t);for(let t=1;t<e.length;++t)e[t].timestamp+=e[t-1].duration+e[t-1].timestamp;return e}async resolveQuery(e){if(!await this.awaitQueryAvailable(e)){console.log("Unawaitable query",e);return}if(this.context.getParameter(this.extension.GPU_DISJOINT_EXT)){console.log("Disjointed query",e);return}return{...e,duration:this.context.getQueryParameter(e.query,this.context.QUERY_RESULT),timestamp:0}}async awaitQueryAvailable(e){for(let t=0;t<10;++t){if(this.context.getQueryParameter(e.query,this.context.QUERY_RESULT_AVAILABLE))return e;await Ii(200)}}}class Nt{constructor(){this.previousImageWidth=0,this.previousImageHeight=0,this.previousMaskWidth=Ce,this.previousMaskHeight=Ce,this.postProcessingEnabled=!0;const e=new OffscreenCanvas(0,0),t=e.getContext("webgl2");if(!t)throw"Fail to retrieve webgl2 context";this.canvas=e,this.context=t,this.improveMask=new _f(this.context,Ce,Ce)}enablePostProcessing(){this.postProcessingEnabled=!0}disablePostProcessing(){this.postProcessingEnabled=!1}async profileWebgl(e){const t=new Ef(this.context);return this.profiler=t,t.start(),await Ii(e),this.profiler=void 0,t.stop(),t.getResolvedQueries()}async render(e,t){if(!this.pipeline)throw"missing pipeline";(this.previousImageHeight!==e.height||this.previousImageWidth!==e.width)&&this.resizeOutput(e.width,e.height),(this.previousMaskHeight!==t.height||this.previousMaskWidth!==t.width)&&(this.improveMask.resizeOutput(t.width,t.height),this.previousMaskWidth=t.width,this.previousMaskHeight=t.height);const n="renderer";this.profiler?.pushContext(n),this.improveMask.setProfiler(this.profiler),this.pipeline.setProfiler(this.profiler);const i=await createImageBitmap(t);let s=i;return this.postProcessingEnabled&&(this.improveMask.setData(e,i),this.improveMask.run(),s=this.improveMask.output),this.pipeline.setData(e,s),await this.pipeline.run(),this.profiler?.popContext(n),this.canvas}resizeOutput(e,t){this.canvas.width=e,this.canvas.height=t,this.pipeline?.resizeOutput(e,t),this.previousImageWidth=e,this.previousImageHeight=t}destroy(){const e=this.context?.getExtension("WEBGL_lose_context");e&&e.loseContext()}}class Ri extends Nt{constructor(){super(),this.pipeline=new Ai(this.context);const e=new OffscreenCanvas(0,0),t=e.getContext("webgl2");if(!t)throw"Fail to retrieve webgl context";this.backgroundImageResizerCanvas=e,this.backgroundImageResizerContext=t,this.backgroundImageResizer=new mf(this.backgroundImageResizerContext,0,0)}setBackgroundImage(e){this.backgroundImage=e,this.updateBackgroundImage()}updateBackgroundImage(){const{width:e,height:t}=this.canvas;this.backgroundImageResizer.resizeOutput(e,t),this.backgroundImageResizer.setData(this.backgroundImage),this.backgroundImageResizer.run(),this.pipeline.inputBackgroundImage=this.backgroundImageResizerCanvas}resizeOutput(e,t){super.resizeOutput(e,t),this.backgroundImageResizerCanvas.width=e,this.backgroundImageResizerCanvas.height=t,this.backgroundImageResizer.resizeOutput(e,t),this.updateBackgroundImage()}destroy(){const e=this.backgroundImageResizerContext?.getExtension("WEBGL_lose_context");e&&e.loseContext(),super.destroy()}}class wf extends Ri{setBackgroundVideo(e){this.frameReader=e}async render(e,t){return await this.readNextVideoFrame(),super.render(e,t)}async readNextVideoFrame(){const e=await this.frameReader?.read();if(e?.value){const t=await createImageBitmap(e.value);this.setBackgroundImage(t),e.value.close()}}}class Fi{blurBackground(e){return new to(e)}blurSilhouette(e){return new ro(e)}imageBackground(){return new no}videoBackground(){return new wf}}var vf=`precision mediump float;\n\nvarying vec2 _texture_coord;\n\nuniform vec2 canvas;\nuniform sampler2D texture;\nuniform sampler2D mask;\n\nvec4 loop();\n\nvoid main() { gl_FragColor = loop(); }\n`,Tf=`varying vec2 _texture_coord;\n\nattribute vec2 position;\nattribute vec2 texture_coord;\n\nvoid main() {\n gl_Position = vec4(position, 0., 1.);\n _texture_coord = texture_coord;\n}\n`;class Af extends je{getDefines(){return{RADIUS:this.options.radius??1}}getFragmentShader(){return vf+this.createLoopFunction()}getVertexShader(){return Tf}createLoopFunction(){let e=this.options.radius??1;return`\n\n vec4 loop() { \n vec4 result = vec4(0,0,0,0);\n float factorSum = 0.;\n\n vec2 normalizedRadius = vec2(-${e}.) / canvas;\n vec2 normalizedIncrement = vec2(1.) / canvas;\n vec2 diff = normalizedRadius;\n float maxLength = length(normalizedRadius);\n\n for(int y=-${e}; y<${e+1}; ++y) {\n for(int x=-${e}; x<${e+1}; ++x) {\n float factor = (1.- texture2D(mask, _texture_coord + diff).a) * (maxLength - length(diff)) / maxLength;\n result += factor * texture2D(texture, _texture_coord + diff);\n factorSum += factor;\n diff.x += normalizedIncrement.x;\n }\n diff.y += normalizedIncrement.y;\n diff.x = normalizedRadius.x;\n }\n return result / factorSum;\n }`}}const If=10,Sf=2,Rf=8;class Ff extends Ur{constructor(e,t){super(),this.context=e,this.radius=t;const n={context:e,height:e.canvas.height,width:e.canvas.width};this.blur=new Af({...n,radius:t,...this.getBlurTextureSize(e.canvas.width,e.canvas.height)});const i=new Mr({...n,disableFramebuffer:!0});this.addStep({program:this.blur,preventResize:!0,getUniforms:()=>({texture:D(e,this.inputImage),mask:D(e,this.inputMask)})}),this.addStep({program:i,getUniforms:()=>({background:D(e,this.blur.output),foreground:D(e,this.inputImage),threshold:D(e,this.inputMask)})})}getBlurTextureSize(e,t){const n=this.radius>If?Rf:Sf;return{width:Math.max(Ce,e/n),height:Math.max(Ce,t/n)}}setData(e,t){this.inputImage=e,this.inputMask=t}resizeOutput(e,t){super.resizeOutput(e,t);const n=this.getBlurTextureSize(e,t);this.blur.resizeOutput(n.width,n.height)}}class Pf extends Nt{constructor(e){super(),this.pipeline=new Ff(this.context,e),this.disablePostProcessing()}}class kf extends Ur{constructor(e,t){super(),this.context=e;const n={context:e,height:e.canvas.height,width:e.canvas.width},i=new Si({...n,radius:t,type:Nr.GAUSSIAN}),s=new Mr({...n,disableFramebuffer:!0});this.addStep({program:i,getUniforms:()=>({texture:D(e,this.inputImage)})}),this.addStep({program:s,getUniforms:()=>({background:D(e,this.inputImage),foreground:D(e,i.output),threshold:D(e,this.inputMask)})})}setData(e,t){this.inputImage=e,this.inputMask=t}}class Cf extends Nt{constructor(e){super(),this.pipeline=new kf(this.context,e),this.disablePostProcessing()}}class Bf extends Ai{constructor(){super(...arguments),this.preciseMaskEnabled=!0}set reader(e){this.frameReader=e}async run(){this.frameReader&&(await this.readNextVideoFrame(),await super.run())}async readNextVideoFrame(){const e=await this.frameReader?.read();e?.value&&(this.inputBackgroundImage=await createImageBitmap(e.value),e.value.close())}}class Df extends Nt{constructor(){super(),this.pipeline=new Bf(this.context)}setBackgroundVideo(e){this.pipeline.reader=e}}class Pi{blurBackground(e){return new Pf(e)}blurSilhouette(e){return new Cf(e)}imageBackground(){return new Ri}videoBackground(){return new Df}}class Mf{constructor(e){switch(e){case gt.CANVAS:this.factory=new Fi;break;case gt.WEBGL:this.factory=new Pi;break;default:const t=eo();this.factory=t.supported?new Pi:new Fi}}blurBackground(e){return this.getFactory().blurBackground(e)}blurSilhouette(e){return this.getFactory().blurSilhouette(e)}imageBackground(){return this.getFactory().imageBackground()}videoBackground(){return this.getFactory().videoBackground()}getFactory(){if(!this.factory)throw"Factory is not initialized";return this.factory}}class Of{setBackgroundOptions(e){this.renderer&&this.renderer.destroy();const t=new Mf(e.renderingOptions?.type);switch(e.transformerType){case"BackgroundBlur":this.renderer=t.blurBackground(this.getBlurSize(e.radius));break;case"SilhouetteBlur":this.renderer=t.blurSilhouette(this.getBlurSize(e.radius));break;case"VideoBackground":const n=t.videoBackground();this.backgroundVideo&&n.setBackgroundVideo(this.backgroundVideo),this.renderer=n;break;case"VirtualBackground":const i=t.imageBackground();this.backgroundImage&&i.setBackgroundImage(this.backgroundImage),this.renderer=i;break;default:throw`Unknown rendering type [${e.transformerType}]`}e.renderingOptions?.type===gt.WEBGL&&(e.renderingOptions.selfieSegmentationType===tr.PRECISE?this.renderer.enablePostProcessing():e.renderingOptions.selfieSegmentationType===tr.FAST&&this.renderer.disablePostProcessing())}setVideoBGReadable(e){this.backgroundVideo=e.getReader();const t=this.renderer;t?.setBackgroundVideo&&t.setBackgroundVideo(this.backgroundVideo)}async setVirtualBGImage(e){const t=this.renderer;t?.setBackgroundImage&&t.setBackgroundImage(e),this.backgroundImage=e}async process(e,t){if(this.renderer)return this.renderer.render(e,t)}async resizeForeground(e,t){}getBlurSize(e=pt.Low){switch(e){case pt.Low:return 5;case pt.High:return 12}return e}async profile(e){return this.renderer?.profileWebgl(e)??[]}}var Uf=(function(){var r=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return(function(e){e=e||{};var t=typeof e<"u"?e:{},n,i;t.ready=new Promise(function(f,h){n=f,i=h});var s={},o;for(o in t)t.hasOwnProperty(o)&&(s[o]=t[o]);var a="./this.program",c=function(f,h){throw h},u=!0,d="";function m(f){return t.locateFile?t.locateFile(f,d):d+f}var p;typeof document<"u"&&document.currentScript&&(d=document.currentScript.src),r&&(d=r),d.indexOf("blob:")!==0?d=d.substr(0,d.replace(/[?#].*/,"").lastIndexOf("/")+1):d="";var y=t.print||console.log.bind(console),l=t.printErr||console.warn.bind(console);for(o in s)s.hasOwnProperty(o)&&(t[o]=s[o]);s=null,t.arguments&&t.arguments,t.thisProgram&&(a=t.thisProgram),t.quit&&(c=t.quit);var b;t.wasmBinary&&(b=t.wasmBinary),t.noExitRuntime,typeof WebAssembly!="object"&&ae("no native wasm support detected");var _,E=!1,R=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function k(f,h,g){for(var w=h+g,S=h;f[S]&&!(S>=w);)++S;if(S-h>16&&f.subarray&&R)return R.decode(f.subarray(h,S));for(var C="";h<S;){var v=f[h++];if(!(v&128)){C+=String.fromCharCode(v);continue}var M=f[h++]&63;if((v&224)==192){C+=String.fromCharCode((v&31)<<6|M);continue}var H=f[h++]&63;if((v&240)==224?v=(v&15)<<12|M<<6|H:v=(v&7)<<18|M<<12|H<<6|f[h++]&63,v<65536)C+=String.fromCharCode(v);else{var Li=v-65536;C+=String.fromCharCode(55296|Li>>10,56320|Li&1023)}}return C}function N(f,h){return f?k(Xe,f,h):""}function Q(f,h,g){for(var w=0;w<f.length;++w)Lt[h++>>0]=f.charCodeAt(w);Lt[h>>0]=0}function q(f,h){return f%h>0&&(f+=h-f%h),f}var L,Lt,Xe,$;function Ci(f){L=f,t.HEAP8=Lt=new Int8Array(f),t.HEAP16=new Int16Array(f),t.HEAP32=$=new Int32Array(f),t.HEAPU8=Xe=new Uint8Array(f),t.HEAPU16=new Uint16Array(f),t.HEAPU32=new Uint32Array(f),t.HEAPF32=new Float32Array(f),t.HEAPF64=new Float64Array(f)}t.INITIAL_MEMORY;var zr,Bi=[],Di=[],Mi=[];function Yf(){if(t.preRun)for(typeof t.preRun=="function"&&(t.preRun=[t.preRun]);t.preRun.length;)Kf(t.preRun.shift());Gr(Bi)}function Qf(){Gr(Di)}function qf(){if(t.postRun)for(typeof t.postRun=="function"&&(t.postRun=[t.postRun]);t.postRun.length;)Zf(t.postRun.shift());Gr(Mi)}function Kf(f){Bi.unshift(f)}function Jf(f){Di.unshift(f)}function Zf(f){Mi.unshift(f)}var be=0,Ye=null;function el(f){be++,t.monitorRunDependencies&&t.monitorRunDependencies(be)}function tl(f){if(be--,t.monitorRunDependencies&&t.monitorRunDependencies(be),be==0&&Ye){var h=Ye;Ye=null,h()}}t.preloadedImages={},t.preloadedAudios={};function ae(f){t.onAbort&&t.onAbort(f),f="Aborted("+f+")",l(f),E=!0,f+=". Build with -s ASSERTIONS=1 for more info.";var h=new WebAssembly.RuntimeError(f);throw i(h),h}var rl="data:application/octet-stream;base64,";function Oi(f){return f.startsWith(rl)}var W;W="tflite-simd.wasm",Oi(W)||(W=m(W));function Ui(f){try{if(f==W&&b)return new Uint8Array(b);if(!p)throw"both async and sync fetching of the wasm failed"}catch(h){ae(h)}}function nl(){return!b&&u&&typeof fetch=="function"?fetch(W,{credentials:"same-origin"}).then(function(f){if(!f.ok)throw"failed to load wasm binary file at \'"+W+"\'";return f.arrayBuffer()}).catch(function(){return Ui(W)}):Promise.resolve().then(function(){return Ui(W)})}function il(){var f={a:Al};function h(v,M){var H=v.exports;t.asm=H,_=t.asm.q,Ci(_.buffer),zr=t.asm.E,Jf(t.asm.r),tl()}el();function g(v){h(v.instance)}function w(v){return nl().then(function(M){return WebAssembly.instantiate(M,f)}).then(function(M){return M}).then(v,function(M){l("failed to asynchronously prepare wasm: "+M),ae(M)})}function S(){return!b&&typeof WebAssembly.instantiateStreaming=="function"&&!Oi(W)&&typeof fetch=="function"?fetch(W,{credentials:"same-origin"}).then(function(v){var M=WebAssembly.instantiateStreaming(v,f);return M.then(g,function(H){return l("wasm streaming compile failed: "+H),l("falling back to ArrayBuffer instantiation"),w(g)})}):w(g)}if(t.instantiateWasm)try{var C=t.instantiateWasm(f,h);return C}catch(v){return l("Module.instantiateWasm callback failed with error: "+v),!1}return S().catch(i),{}}function Gr(f){for(;f.length>0;){var h=f.shift();if(typeof h=="function"){h(t);continue}var g=h.func;typeof g=="number"?h.arg===void 0?zr.get(g)():zr.get(g)(h.arg):g(h.arg===void 0?null:h.arg)}}function sl(f,h,g,w){ae("Assertion failed: "+N(f)+", at: "+[h?N(h):"unknown filename",g,w?N(w):"unknown function"])}function ol(f,h){ae("To use dlopen, you need to use Emscripten\'s linking support, see https://github.com/emscripten-core/emscripten/wiki/Linking")}function al(f,h){ae("To use dlopen, you need to use Emscripten\'s linking support, see https://github.com/emscripten-core/emscripten/wiki/Linking")}function cl(){ae("")}var zt;zt=function(){return performance.now()};var ul=!0;function fl(f){return $[Ni()>>2]=f,f}function ll(f,h){var g;if(f===0)g=Date.now();else if((f===1||f===4)&&ul)g=zt();else return fl(28),-1;return $[h>>2]=g/1e3|0,$[h+4>>2]=g%1e3*1e3*1e3|0,0}function dl(){return 2147483648}function hl(f,h,g){Xe.copyWithin(f,h,h+g)}function ml(f){try{return _.grow(f-L.byteLength+65535>>>16),Ci(_.buffer),1}catch{}}function pl(f){var h=Xe.length;f=f>>>0;var g=2147483648;if(f>g)return!1;for(var w=1;w<=4;w*=2){var S=h*(1+.2/w);S=Math.min(S,f+100663296);var C=Math.min(g,q(Math.max(f,S),65536)),v=ml(C);if(v)return!0}return!1}function gl(f){for(var h=zt();zt()-h<f;);}var $r={};function yl(){return a||"./this.program"}function Qe(){if(!Qe.strings){var f=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",h={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:f,_:yl()};for(var g in $r)$r[g]===void 0?delete h[g]:h[g]=$r[g];var w=[];for(var g in h)w.push(g+"="+h[g]);Qe.strings=w}return Qe.strings}var Gt={mappings:{},buffers:[null,[],[]],printChar:function(f,h){var g=Gt.buffers[f];h===0||h===10?((f===1?y:l)(k(g,0)),g.length=0):g.push(h)},varargs:void 0,get:function(){Gt.varargs+=4;var f=$[Gt.varargs-4>>2];return f},getStr:function(f){var h=N(f);return h},get64:function(f,h){return f}};function bl(f,h){var g=0;return Qe().forEach(function(w,S){var C=h+g;$[f+S*4>>2]=C,Q(w,C),g+=w.length+1}),0}function xl(f,h){var g=Qe();$[f>>2]=g.length;var w=0;return g.forEach(function(S){w+=S.length+1}),$[h>>2]=w,0}function _l(f){Sl(f)}function El(f){return 0}function wl(f,h,g,w,S){}function vl(f,h,g,w){for(var S=0,C=0;C<g;C++){for(var v=$[h+C*8>>2],M=$[h+(C*8+4)>>2],H=0;H<M;H++)Gt.printChar(f,Xe[v+H]);S+=M}return $[w>>2]=S,0}function Tl(){if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function"){var f=new Uint8Array(1);return function(){return crypto.getRandomValues(f),f[0]}}else return function(){ae("randomDevice")}}function $t(f,h){$t.randomDevice||($t.randomDevice=Tl());for(var g=0;g<h;g++)Lt[f+g>>0]=$t.randomDevice();return 0}var Al={a:sl,e:ol,d:al,b:cl,n:ll,h:dl,l:hl,m:pl,p:gl,f:bl,g:xl,j:_l,i:El,k:wl,c:vl,o:$t};il(),t.___wasm_call_ctors=function(){return(t.___wasm_call_ctors=t.asm.r).apply(null,arguments)},t._getModelBufferMemoryOffset=function(){return(t._getModelBufferMemoryOffset=t.asm.s).apply(null,arguments)},t._getInputMemoryOffset=function(){return(t._getInputMemoryOffset=t.asm.t).apply(null,arguments)},t._getInputHeight=function(){return(t._getInputHeight=t.asm.u).apply(null,arguments)},t._getInputWidth=function(){return(t._getInputWidth=t.asm.v).apply(null,arguments)},t._getInputChannelCount=function(){return(t._getInputChannelCount=t.asm.w).apply(null,arguments)},t._getOutputMemoryOffset=function(){return(t._getOutputMemoryOffset=t.asm.x).apply(null,arguments)},t._getOutputHeight=function(){return(t._getOutputHeight=t.asm.y).apply(null,arguments)},t._getOutputWidth=function(){return(t._getOutputWidth=t.asm.z).apply(null,arguments)},t._getOutputChannelCount=function(){return(t._getOutputChannelCount=t.asm.A).apply(null,arguments)},t._loadModel=function(){return(t._loadModel=t.asm.B).apply(null,arguments)},t._runInference=function(){return(t._runInference=t.asm.C).apply(null,arguments)},t._isGPUEnabled=function(){return(t._isGPUEnabled=t.asm.D).apply(null,arguments)};var Ni=t.___errno_location=function(){return(Ni=t.___errno_location=t.asm.F).apply(null,arguments)},Wt;function Il(f){this.name="ExitStatus",this.message="Program terminated with exit("+f+")",this.status=f}Ye=function f(){Wt||Wr(),Wt||(Ye=f)};function Wr(f){if(be>0||(Yf(),be>0))return;function h(){Wt||(Wt=!0,t.calledRun=!0,!E&&(Qf(),n(t),t.onRuntimeInitialized&&t.onRuntimeInitialized(),qf()))}t.setStatus?(t.setStatus("Running..."),setTimeout(function(){setTimeout(function(){t.setStatus("")},1),h()},1)):h()}t.run=Wr;function Sl(f,h){Rl(f)}function Rl(f){c(f,new Il(f))}if(t.preInit)for(typeof t.preInit=="function"&&(t.preInit=[t.preInit]);t.preInit.length>0;)t.preInit.pop()();return Wr(),e.ready})})();class Nf{constructor(){this.isSIMDSupported=!1,this.isThreadsSupported=!1,this.inputWidth=0,this.inputHeight=0,this.inputChannelCount=0,this.inputMemoryOffset=0,this.outputWidth=0,this.outputHeight=0,this.outputChannelCount=0,this.outputMemoryOffset=0}}const Lf="https://d3opqjmqzxf057.cloudfront.net/vonage-tensorflow-wasm/tflite-simd-wasm/1.1.3/",zf="https://d3opqjmqzxf057.cloudfront.net/ml/selfie_segmentation/4.0.0/selfie_segmentation_landscape.tflite";async function Gf(r=Lf,e=zf){let t=new Nf;var n=new Promise(function(i,s){async function o(){return Uf({locateFile:function(u){return r+u}})}async function a(c){return new Promise(async(u,d)=>{const m=c;if(typeof m>"u")return d("TFLite backend unavailable: wasmSimd");let p=e;console.log("TFLite modelUrl: "+p);try{const l=await(await fetch(p)).arrayBuffer();console.log("Model buffer size:",l.byteLength);const b=m._getModelBufferMemoryOffset();console.log("Model buffer memory offset:",b),console.log("Loading model buffer..."),m.HEAPU8.set(new Uint8Array(l),b);const _=m._loadModel(l.byteLength);if(console.log("Load model result:",_),_!==0){d("Cannot load model");return}t.inputWidth=m._getInputWidth(),t.inputHeight=m._getInputHeight(),t.inputChannelCount=m._getInputChannelCount(),t.inputMemoryOffset=m._getInputMemoryOffset(),console.log("Input memory offset:",t.inputMemoryOffset),console.log("Input height:",t.inputHeight),console.log("Input width:",t.inputWidth),console.log("Input channels:",t.inputChannelCount),t.outputMemoryOffset=m._getOutputMemoryOffset(),t.outputWidth=m._getOutputWidth(),t.outputHeight=m._getOutputHeight(),t.outputChannelCount=m._getOutputChannelCount(),console.log("Output memory offset:",t.outputMemoryOffset),console.log("Output height:",t.outputHeight),console.log("Output width:",t.outputWidth),console.log("Output channels:",t.outputChannelCount),t.selectedTFLite=m}catch(y){d(y);return}u()})}o().then(c=>{if(c===null)throw console.error("loadTFLite null"),"loadTFLite null";a(c).then(u=>{i(t)}).catch(u=>{console.error("loadTFLiteModel error"),s("loadTFLiteModel error")})}).catch(c=>{console.error("loadTFLite error:",c),s("loadTFLite error:"+c)})});return n}const $f=.1,Wf=.7,Vf="https://d3opqjmqzxf057.cloudfront.net/ml/vonage_selfie_segmenter/float16/v1/vonage_selfie_segmenter.tflite";class Hf{constructor(){this.canvas=new OffscreenCanvas(0,0),this.context=this.canvas.getContext("2d",{willReadFrequently:!0}),this.width=0,this.height=0,this.gpuDelegate=!0}async createImageSegmenter(){if(!this.ImageSegmenter||!this.wasmFileset){console.warn("Mediapipe objects not loaded");return}this.imageSegmenter=await this.ImageSegmenter.createFromOptions(this.wasmFileset,{baseOptions:{modelAssetPath:this.modelAssetUriPath,delegate:this.gpuDelegate?"GPU":"CPU"},runningMode:"VIDEO",outputCategoryMask:!0,outputConfidenceMasks:!0})}async loadMediapipeAssets(e,t){this.modelAssetUriPath=e||Vf;const n=t?`${t}/task-vision.js`:"https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.20/+esm",i=t?`${t}/wasm`:"https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.20/wasm",{FilesetResolver:s,ImageSegmenter:o}=await import(n);this.ImageSegmenter=o,this.wasmFileset=await s.forVisionTasks(i)}async init(e,t,n){n===!1&&(this.gpuDelegate=!1),await this.loadMediapipeAssets(e,t),globalThis.document={},await this.createImageSegmenter()}async process(e){if(!this.imageSegmenter){console.warn("ImageSegmenter instance not available");return}(this.width!==e.width||this.height!==e.height)&&(this.canvas.width=this.width=e.width,this.canvas.height=this.height=e.height,this.mask&&(this.mask=new ImageData(this.width,this.height))),this.mask||(this.mask=new ImageData(this.width,this.height)),this.context.drawImage(e,0,0,e.width,e.height);const t=Date.now();let n;try{this.imageSegmenter?.segmentForVideo(this.context.getImageData(0,0,e.width,e.height),t,o=>{n=o.confidenceMasks?.[0]?.getAsFloat32Array()})}catch{await this.createImageSegmenter();return}if(!n)return;if(!this.previousConfidenceMask){this.previousConfidenceMask=n.slice();return}const i=n.map((o,a)=>{const c=this.previousConfidenceMask?.[a];return c!==void 0?this.blend(c,o):o}),s=[255,0,0];for(let o=0;o<i?.length;o++){const a=1-i[o];a>$f?(a<Wf?(this.mask.data[o*4]=s[0]*a,this.mask.data[o*4+3]=255*a):(this.mask.data[o*4]=s[0],this.mask.data[o*4+3]=255),this.mask.data[o*4+1]=s[1],this.mask.data[o*4+2]=s[2]):this.mask.data[o*4]=this.mask.data[o*4+1]=this.mask.data[o*4+2]=this.mask.data[o*4+3]=0}return this.previousConfidenceMask=i.slice(),this.mask}isGpuSupported(){return!0}blend(e,t){const i=-.748699,s=-57.8051,o=291.309,a=-624.717,c=t-.5,u=c*c,d=1-Math.min(1,u*(5.68842+u*(i+u*(s+u*(o+u*a)))));return t+(e-t)*(d*.9)}}class jf{constructor(){this.canvas=new OffscreenCanvas(0,0),this.context=this.canvas.getContext("2d",{willReadFrequently:!0}),this.pixelCount=0,this.inputOffset=0,this.outputOffset=0}async init(e,t,n){await this.initWasm(t,e),this.infos&&(this.canvas.width=this.infos.inputWidth,this.canvas.height=this.infos.inputHeight,this.pixelCount=this.infos.inputWidth*this.infos.inputHeight,this.mask=new ImageData(this.infos.inputWidth,this.infos.inputHeight),this.inputOffset=this.infos.inputMemoryOffset/4,this.outputOffset=this.infos.outputMemoryOffset/4)}async initWasm(e,t){this.infos=await Gf(e,t)}async process(e){if(!this.mask||!this.infos)return;const t=this.infos.inputWidth,n=this.infos.inputHeight;this.context.drawImage(e,0,0,e.width,e.height,0,0,t,n);const i=this.context.getImageData(0,0,t,n),s=this.infos.selectedTFLite.HEAPF32;for(let o=0;o<this.pixelCount;o++){const a=this.inputOffset+o*3;s[a]=i.data[o*4]/255,s[a+1]=i.data[o*4+1]/255,s[a+2]=i.data[o*4+2]/255}this.infos.selectedTFLite._runInference();for(let o=0;o<this.pixelCount;o++){const a=this.infos.selectedTFLite.HEAPF32[this.outputOffset+o];this.mask.data[o*4]=this.mask.data[o*4+3]=255*a}return this.mask}isGpuSupported(){return this.infos?.selectedTFLite?._isGPUEnabled()??!1}}class Xf{constructor(){this.reporter=new Js,this.isEnabled=!0,this.avoidOriginalTrackLeak=!1}async init(e,t){t.segmentationOptions?.lightWeightEngine===!0?this.selfieSegmentation=new jf:this.selfieSegmentation=new Hf,this.selfieSegmentation?.init(t.modelAssetUriPath,t.mediapipeBaseAssetsUri,t.segmentationOptions?.gpuSupport),this.avoidOriginalTrackLeak=t.avoidOriginalTrackLeak,this.backgroundFilter=new Of,this.report({variation:"Create"})}async transform(e,t){if(!this.isEnabled)return t.enqueue(e);let n;const i=e.timestamp??0,s=await createImageBitmap(e),o=await this.selfieSegmentation?.process(s);o&&(n=await this.backgroundFilter?.process(s,o)),!n&&this.avoidOriginalTrackLeak&&(n=new OffscreenCanvas(s.width,s.height)),n?(e.close(),t.enqueue(new VideoFrame(n,{timestamp:i,alpha:"discard"}))):t.enqueue(e)}async setBackgroundOptions(e){this.backgroundOptions=e,this.backgroundFilter?.setBackgroundOptions(e),this.report({variation:"Update"})}setVideoBGReadable(e){this.backgroundFilter?.setVideoBGReadable(e)}async setVirtualBGImage(e){await this.backgroundFilter?.setVirtualBGImage(e)}async profile(e){return this.backgroundFilter?.profile(e)??[]}getTransformerType(){return this.backgroundOptions?.transformerType??"Undefined"}enable(){this.isEnabled=!0}disable(){this.isEnabled=!1}report(e){this.reporter.send({version:Zs,action:"MlTransformers",transformerType:this.backgroundOptions?.transformerType,config:JSON.stringify(this.backgroundOptions),...e})}}const Lr=class Lr{constructor(){this.backgroundTransformer=new Xf,this.mediaProcessor=new Rs,this.rate=30,this.eventsQueue=[],this.frameTransformLatencyMs=[]}async init(e,t){this.frameTransformLatencyMs=[],await this.backgroundTransformer.init(e,t),await this.mediaProcessor.setTransformers([this.backgroundTransformer]),this.mediaProcessor.setTrackExpectedRate(this.rate),this.mediaProcessor.onAny((n,i)=>{this.resolveOnMediaProcessor?(this.resolveOnMediaProcessor({name:n,data:i}),this.resolveOnMediaProcessor=void 0):this.eventsQueue.push({name:n,data:i})})}enable(){this.backgroundTransformer.enable()}disable(){this.backgroundTransformer.disable()}async onMediaProcessorEvent(){return await new Promise(e=>{this.eventsQueue.length>0?e(this.eventsQueue.shift()):this.resolveOnMediaProcessor=e})}async setTrackExpectedRate(e){this.rate=e,this.mediaProcessor.setTrackExpectedRate(e)}async transform(e,t){let n=this.mediaProcessor.transform(e,t),i=performance.now();return this.frameTransformLatencyMs.push(performance.now()-i),n}async setBackgroundOptions(e){await this.backgroundTransformer?.setBackgroundOptions(e)}setVideoBGReadable(e){this.backgroundTransformer.setVideoBGReadable(e)}async setVirtualBGImage(e){await this.backgroundTransformer.setVirtualBGImage(e)}async terminate(){await this.mediaProcessor.destroy();const t=this.frameTransformLatencyMs.reduce((n,i)=>n+i,0)/this.frameTransformLatencyMs.length||0;console.log(`Transform latency average is: ${t} ms`)}setVonageMetadata(e){_s(e)}async profile(e){return JSON.stringify(await this.backgroundTransformer.profile(e))}};Vi("ProcessorWorker",Lr);let ki=Lr})();\n//# sourceMappingURL=processor-worker-Ds3NmK37.js.map\n',
36617
+ oi = typeof self < "u" && self.Blob && new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);", Eo], {
36614
36618
  type: "text/javascript;charset=utf-8"
36615
36619
  });
36616
36620
  function Fd(r) {
36617
36621
  let e;
36618
36622
  try {
36619
- if (e = ii && (self.URL || self.webkitURL).createObjectURL(ii), !e) throw "";
36623
+ if (e = oi && (self.URL || self.webkitURL).createObjectURL(oi), !e) throw "";
36620
36624
  const t = new Worker(e, {
36621
36625
  name: r == null ? void 0 : r.name
36622
36626
  });
@@ -36624,7 +36628,7 @@ function Fd(r) {
36624
36628
  (self.URL || self.webkitURL).revokeObjectURL(e);
36625
36629
  }), t;
36626
36630
  } catch (_unused13) {
36627
- return new Worker("data:text/javascript;charset=utf-8," + encodeURIComponent(_o), {
36631
+ return new Worker("data:text/javascript;charset=utf-8," + encodeURIComponent(Eo), {
36628
36632
  name: r == null ? void 0 : r.name
36629
36633
  });
36630
36634
  }
@@ -36911,7 +36915,7 @@ const Jt = /*#__PURE__*/function (_et) {
36911
36915
  case 10:
36912
36916
  _context95.t2 = _this$worker9;
36913
36917
  _context95.next = 13;
36914
- return zn.createVideoReadable(e.backgroundAssetUri);
36918
+ return Nn.createVideoReadable(e.backgroundAssetUri);
36915
36919
  case 13:
36916
36920
  _context95.t3 = _context95.sent;
36917
36921
  _context95.t1 = _context95.t2.setVideoBGReadable.call(_context95.t2, _context95.t3);
@@ -36931,7 +36935,7 @@ const Jt = /*#__PURE__*/function (_et) {
36931
36935
  case 22:
36932
36936
  _context95.t5 = _this$worker10;
36933
36937
  _context95.next = 25;
36934
- return zn.createImageCanvas(e.backgroundAssetUri);
36938
+ return Nn.createImageCanvas(e.backgroundAssetUri);
36935
36939
  case 25:
36936
36940
  _context95.t6 = _context95.sent;
36937
36941
  _context95.t4 = _context95.t5.setVirtualBGImage.call(_context95.t5, _context95.t6);
@@ -37004,7 +37008,7 @@ let Cd = /*#__PURE__*/function () {
37004
37008
  t[c.name] === void 0 && (t[c.name] = e.length, e.push({
37005
37009
  name: c.name
37006
37010
  })), a.push({
37007
- type: c.action == xo.PUSH ? "O" : "C",
37011
+ type: c.action == vo.PUSH ? "O" : "C",
37008
37012
  frame: t[c.name],
37009
37013
  at: c.timestamp
37010
37014
  }), i = Math.max(i, c.timestamp + c.duration);
@@ -37037,7 +37041,7 @@ const gn = /*#__PURE__*/function (_et2) {
37037
37041
  */
37038
37042
  function gn(e) {
37039
37043
  var _this30;
37040
- _this30 = _et2.call(this) || this, _this30.worker = new Br(e), _this30.connector = new Ys(_this30.worker), _this30.worker.onAny((t, n) => _this30.emit(t, n));
37044
+ _this30 = _et2.call(this) || this, _this30.worker = new Br(e), _this30.connector = new Qs(_this30.worker), _this30.worker.onAny((t, n) => _this30.emit(t, n));
37041
37045
  return _this30;
37042
37046
  }
37043
37047
  /**
@@ -91338,65 +91342,70 @@ function MediaProcessor(deps) {
91338
91342
  };
91339
91343
  }();
91340
91344
  this.setVideoFilter = /*#__PURE__*/function () {
91341
- var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(newVideoFilter) {
91345
+ var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(newVideoFilter, avoidOriginalTrackLeak) {
91342
91346
  var type, configurator, fullConfig, hasFilterAlready;
91343
91347
  return _regenerator.default.wrap(function _callee2$(_context2) {
91344
91348
  while (1) switch (_context2.prev = _context2.next) {
91345
91349
  case 0:
91350
+ if (avoidOriginalTrackLeak === void 0) {
91351
+ avoidOriginalTrackLeak = false;
91352
+ }
91346
91353
  type = newVideoFilter.type;
91347
91354
  configurator = MediaTransform.getConfigurator(type);
91348
91355
  if (configurator) {
91349
- _context2.next = 5;
91356
+ _context2.next = 6;
91350
91357
  break;
91351
91358
  }
91352
91359
  logging.warn(`Ignoring: filter "${type}" isn't supported`);
91353
91360
  return _context2.abrupt("return");
91354
- case 5:
91361
+ case 6:
91355
91362
  // The config passed in may be a simplified configuration missing URLs for static
91356
91363
  // assets, for example. We need the "full configuration".
91357
91364
  fullConfig = configurator.getConfig(Object.assign({
91358
91365
  proxyUrl: getProxyUrl()
91359
- }, newVideoFilter));
91366
+ }, newVideoFilter, {
91367
+ avoidOriginalTrackLeak
91368
+ }));
91360
91369
  if (fullConfig) {
91361
- _context2.next = 9;
91370
+ _context2.next = 10;
91362
91371
  break;
91363
91372
  }
91364
91373
  logging.warn(`Ignoring: couldn't configure filter ${type}`);
91365
91374
  return _context2.abrupt("return");
91366
- case 9:
91375
+ case 10:
91367
91376
  hasFilterAlready = !!_this.getVideoFilter();
91368
91377
  if (!hasFilterAlready) {
91369
- _context2.next = 20;
91378
+ _context2.next = 21;
91370
91379
  break;
91371
91380
  }
91372
- _context2.prev = 11;
91373
- _context2.next = 14;
91381
+ _context2.prev = 12;
91382
+ _context2.next = 15;
91374
91383
  return _this.destroy();
91375
- case 14:
91376
- _context2.next = 20;
91384
+ case 15:
91385
+ _context2.next = 21;
91377
91386
  break;
91378
- case 16:
91379
- _context2.prev = 16;
91380
- _context2.t0 = _context2["catch"](11);
91387
+ case 17:
91388
+ _context2.prev = 17;
91389
+ _context2.t0 = _context2["catch"](12);
91381
91390
  logging.warn(`Ignoring, couldn't remove previous filter: ${_context2.t0}`);
91382
91391
  return _context2.abrupt("return");
91383
- case 20:
91384
- _context2.next = 22;
91392
+ case 21:
91393
+ _context2.next = 23;
91385
91394
  return ML.createProcessor(fullConfig);
91386
- case 22:
91395
+ case 23:
91387
91396
  processor = _context2.sent;
91388
- _context2.next = 25;
91397
+ _context2.next = 26;
91389
91398
  return processor.getConnector();
91390
- case 25:
91399
+ case 26:
91391
91400
  connector = _context2.sent;
91392
91401
  videoFilter = newVideoFilter;
91393
- case 27:
91402
+ case 28:
91394
91403
  case "end":
91395
91404
  return _context2.stop();
91396
91405
  }
91397
- }, _callee2, null, [[11, 16]]);
91406
+ }, _callee2, null, [[12, 17]]);
91398
91407
  }));
91399
- return function (_x2) {
91408
+ return function (_x2, _x3) {
91400
91409
  return _ref2.apply(this, arguments);
91401
91410
  };
91402
91411
  }();
@@ -91439,7 +91448,7 @@ function MediaProcessor(deps) {
91439
91448
  }
91440
91449
  }, _callee3, null, [[5, 12]]);
91441
91450
  }));
91442
- return function (_x3) {
91451
+ return function (_x4) {
91443
91452
  return _ref3.apply(this, arguments);
91444
91453
  };
91445
91454
  }();
@@ -91470,7 +91479,7 @@ function MediaProcessor(deps) {
91470
91479
  }
91471
91480
  }, _callee4, null, [[1, 8]]);
91472
91481
  }));
91473
- return function (_x4) {
91482
+ return function (_x5) {
91474
91483
  return _ref4.apply(this, arguments);
91475
91484
  };
91476
91485
  }();