@vindral/web-sdk 4.8.2-11-gbcf8b54e → 4.8.2-13-g5ab298c5f

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,9 +1,7 @@
1
- import { t as e } from "./CFqytvUK.js";
2
- import { t } from "./CuYn2z5X.js";
3
- import { t as n } from "./DJNS7hc2.js";
4
- import { t as r } from "./CXMDq12B.js";
5
- import { t as i } from "./2sSTdNyC.js";
6
- //#region ../../libs/wasm-decoders/src/opus/wasm/opus.js
1
+ import { F as e, P as t } from "./hsFRuCkY.js";
2
+ import { n, t as r } from "./DvtbAkGW.js";
3
+ import { l as i } from "./BeCY4GvT.js";
4
+ // ../../libs/wasm-decoders/src/opus/wasm/opus.js
7
5
  var a = (function() {
8
6
  var e = typeof document < "u" && document.currentScript ? document.currentScript.src : void 0;
9
7
  return (function(t) {
@@ -206,21 +204,21 @@ var a = (function() {
206
204
  });
207
205
  })(), o, s = /* @__PURE__ */ function(e) {
208
206
  return e[e.OK = 0] = "OK", e[e["Bad argument"] = -1] = "Bad argument", e[e["Buffer too small"] = -2] = "Buffer too small", e[e["Internal error"] = -3] = "Internal error", e[e["Invalid packet"] = -4] = "Invalid packet", e[e.Unimplemented = -5] = "Unimplemented", e[e["Invalid state"] = -6] = "Invalid state", e[e["Memory allocation fail"] = -7] = "Memory allocation fail", e;
209
- }(s || {}), c = class t {
210
- constructor(n, r, i) {
211
- e(this, "opusModule", void 0), e(this, "decoderInstance", void 0), e(this, "opusBufferPointer", void 0), e(this, "pcmBufferPointer", void 0), e(this, "channels", void 0), e(this, "pcmBufferByteSize", () => t.MAX_SAMPLES * this.channels * Float32Array.BYTES_PER_ELEMENT), e(this, "unload", () => {
207
+ }(s || {}), c = class e {
208
+ constructor(t, r, i) {
209
+ n(this, "opusModule", void 0), n(this, "decoderInstance", void 0), n(this, "opusBufferPointer", void 0), n(this, "pcmBufferPointer", void 0), n(this, "channels", void 0), n(this, "pcmBufferByteSize", () => e.MAX_SAMPLES * this.channels * Float32Array.BYTES_PER_ELEMENT), n(this, "unload", () => {
212
210
  this.opusModule._free(this.opusBufferPointer), this.opusModule._free(this.pcmBufferPointer), this.opusModule._opus_decoder_destroy(this.decoderInstance);
213
- }), e(this, "decode", (e) => {
214
- if (e.byteLength > t.MAX_OPUS_BUFFER) throw Error(`Opus packet too large (${e.byteLength} bytes), max ${t.MAX_OPUS_BUFFER} bytes`);
215
- this.opusModule.HEAPU8.set(e, this.opusBufferPointer);
216
- let n = this.opusModule._opus_decode_float(this.decoderInstance, this.opusBufferPointer, e.byteLength, this.pcmBufferPointer, t.MAX_SAMPLES, 0);
211
+ }), n(this, "decode", (t) => {
212
+ if (t.byteLength > e.MAX_OPUS_BUFFER) throw Error(`Opus packet too large (${t.byteLength} bytes), max ${e.MAX_OPUS_BUFFER} bytes`);
213
+ this.opusModule.HEAPU8.set(t, this.opusBufferPointer);
214
+ let n = this.opusModule._opus_decode_float(this.decoderInstance, this.opusBufferPointer, t.byteLength, this.pcmBufferPointer, e.MAX_SAMPLES, 0);
217
215
  if (n < 0) throw Error(`${s[n]} (${n})`);
218
216
  let r = this.pcmBufferPointer / Float32Array.BYTES_PER_ELEMENT;
219
217
  return this.opusModule.HEAPF32.subarray(r, r + n * this.channels);
220
- }), this.opusModule = n, this.channels = i, this.decoderInstance = this.opusModule._opus_decoder_create(r, i, 0), this.opusBufferPointer = this.opusModule._malloc(t.MAX_OPUS_BUFFER), this.pcmBufferPointer = this.opusModule._malloc(this.pcmBufferByteSize());
218
+ }), this.opusModule = t, this.channels = i, this.decoderInstance = this.opusModule._opus_decoder_create(r, i, 0), this.opusBufferPointer = this.opusModule._malloc(e.MAX_OPUS_BUFFER), this.pcmBufferPointer = this.opusModule._malloc(this.pcmBufferByteSize());
221
219
  }
222
220
  };
223
- o = c, e(c, "MAX_OPUS_BUFFER", 16384), e(c, "MAX_SAMPLES", 6 * 960), e(c, "create", function() {
221
+ o = c, n(c, "MAX_OPUS_BUFFER", 16384), n(c, "MAX_SAMPLES", 5760), n(c, "create", function() {
224
222
  var e = r(function* (e, t) {
225
223
  return new o(yield a(), e, t);
226
224
  });
@@ -228,13 +226,12 @@ o = c, e(c, "MAX_OPUS_BUFFER", 16384), e(c, "MAX_SAMPLES", 6 * 960), e(c, "creat
228
226
  return e.apply(this, arguments);
229
227
  };
230
228
  }());
231
- //#endregion
232
- //#region ../../libs/web-sdk/src/decoders/OpusDecoderContext.ts
229
+ // ../../libs/web-sdk/src/decoders/OpusDecoderContext.ts
233
230
  var l, u = class {
234
231
  constructor(r) {
235
- e(this, "decodedSamples", []), e(this, "decoder", void 0), e(this, "errors", new n(10)), e(this, "unload", () => {
232
+ n(this, "decodedSamples", []), n(this, "decoder", void 0), n(this, "errors", new t(10)), n(this, "unload", () => {
236
233
  this.decoder.unload();
237
- }), e(this, "enqueue", (e) => {
234
+ }), n(this, "enqueue", (e) => {
238
235
  try {
239
236
  let t = performance.now(), n = this.decoder.decode(new Uint8Array(e.data));
240
237
  this.decodedSamples.push(i(i({}, e), {}, {
@@ -251,13 +248,13 @@ var l, u = class {
251
248
  } catch (e) {
252
249
  e instanceof Error && this.errors.push(e);
253
250
  }
254
- }), e(this, "initSegment", t), e(this, "take", () => this.decodedSamples.shift()), this.decoder = r;
251
+ }), n(this, "initSegment", e), n(this, "take", () => this.decodedSamples.shift()), this.decoder = r;
255
252
  }
256
253
  error() {
257
254
  return this.errors.pop();
258
255
  }
259
256
  };
260
- l = u, e(u, "create", function() {
257
+ l = u, n(u, "create", function() {
261
258
  var e = r(function* (e, t) {
262
259
  return new l(yield c.create(e, t));
263
260
  });
@@ -265,5 +262,4 @@ l = u, e(u, "create", function() {
265
262
  return e.apply(this, arguments);
266
263
  };
267
264
  }());
268
- //#endregion
269
265
  export { u as OpusDecoderContext };
@@ -1,19 +1,38 @@
1
- import { t as e } from "./CFqytvUK.js";
2
- import { t } from "./CXMDq12B.js";
3
- import { t as n } from "./2sSTdNyC.js";
4
- //#region ../../libs/utils/src/assert.ts
5
- function r(e, t) {
1
+ import { n as e, t } from "./DvtbAkGW.js";
2
+ // ../../libs/utils/src/assert.ts
3
+ function n(e, t) {
6
4
  if (!e) throw Error(t);
7
5
  }
8
- //#endregion
9
- //#region ../../libs/utils/src/tryJsonParse.ts
10
- var i = (e) => {
6
+ // \0@oxc-project+runtime@0.156.0/helpers/esm/objectSpread2.js
7
+ function r(e, t) {
8
+ var n = Object.keys(e);
9
+ if (Object.getOwnPropertySymbols) {
10
+ var r = Object.getOwnPropertySymbols(e);
11
+ t && (r = r.filter(function(t) {
12
+ return Object.getOwnPropertyDescriptor(e, t).enumerable;
13
+ })), n.push.apply(n, r);
14
+ }
15
+ return n;
16
+ }
17
+ function i(t) {
18
+ for (var n = 1; n < arguments.length; n++) {
19
+ var i = arguments[n] == null ? {} : arguments[n];
20
+ n % 2 ? r(Object(i), !0).forEach(function(n) {
21
+ e(t, n, i[n]);
22
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(i)) : r(Object(i)).forEach(function(e) {
23
+ Object.defineProperty(t, e, Object.getOwnPropertyDescriptor(i, e));
24
+ });
25
+ }
26
+ return t;
27
+ }
28
+ // ../../libs/utils/src/tryJsonParse.ts
29
+ var a = (e) => {
11
30
  try {
12
31
  return JSON.parse(e);
13
32
  } catch (e) {
14
33
  return;
15
34
  }
16
- }, a = (e) => {
35
+ }, o = (e) => {
17
36
  switch (e) {
18
37
  case "h264":
19
38
  case "h265":
@@ -25,7 +44,7 @@ var i = (e) => {
25
44
  default: throw Error("Unknown codec");
26
45
  }
27
46
  };
28
- function o(e) {
47
+ function s(e) {
29
48
  if (e.startsWith("opus")) return "opus";
30
49
  if (e.startsWith("mp4a")) return "aac";
31
50
  if (e.startsWith("avc1")) return "h264";
@@ -33,53 +52,51 @@ function o(e) {
33
52
  if (e.startsWith("av01")) return "av1";
34
53
  if (e.startsWith("webvtt")) return "webvtt";
35
54
  }
36
- //#endregion
37
- //#region ../../libs/data-types/src/ConnectInfo.ts
38
- function s(e) {
55
+ // ../../libs/data-types/src/ConnectInfo.ts
56
+ function c(e) {
39
57
  return !(typeof e.edges[0] == "string" || e.channels[0] && !("catalog" in e.channels[0]));
40
58
  }
41
- function c(e) {
42
- return e.tracks.filter((e) => !!e.codec).filter((e) => o(e.codec || "")).map((e, t) => {
43
- let n = e.codec, i = e.bitrate;
44
- r(n, "codec is required"), r(i !== void 0, "bitrate is required");
45
- let s = o(n);
46
- if (r(s, "codec is required"), a(s) === "audio") {
47
- let r = e.samplerate || 0;
59
+ function l(e) {
60
+ return e.tracks.filter((e) => !!e.codec).filter((e) => s(e.codec || "")).map((e, t) => {
61
+ let r = e.codec, i = e.bitrate;
62
+ n(r, "codec is required"), n(i !== void 0, "bitrate is required");
63
+ let a = s(r);
64
+ if (n(a, "codec is required"), o(a) === "audio") {
65
+ let n = e.samplerate || 0;
48
66
  return {
49
67
  track: e,
50
68
  id: t,
51
- codec: s,
52
- codecString: n,
69
+ codec: a,
70
+ codecString: r,
53
71
  bitRate: i,
54
72
  channels: e.channelConfig === "stereo" ? 2 : 1,
55
- sampleRate: r,
73
+ sampleRate: n,
56
74
  language: e.language
57
75
  };
58
76
  }
59
- return a(s) === "text" ? {
77
+ return o(a) === "text" ? {
60
78
  track: e,
61
79
  id: t,
62
80
  bitRate: 0,
63
- codec: s,
81
+ codec: a,
64
82
  kind: "subtitles",
65
- codecString: n,
83
+ codecString: r,
66
84
  label: e.label,
67
85
  language: e.language
68
- } : (r(e.width, "width is required"), r(e.height, "width is required"), r(e.framerate, "framerate is required"), {
86
+ } : (n(e.width, "width is required"), n(e.height, "width is required"), n(e.framerate, "framerate is required"), {
69
87
  track: e,
70
88
  id: t,
71
- codec: s,
89
+ codec: a,
72
90
  bitRate: i,
73
- codecString: n,
91
+ codecString: r,
74
92
  width: e.width,
75
93
  height: e.height,
76
94
  frameRate: e.framerate
77
95
  });
78
96
  }).sort((e, t) => e.bitRate - t.bitRate);
79
97
  }
80
- //#endregion
81
- //#region ../../libs/api-client/src/auth.ts
82
- var l = (e) => e ? { Authorization: `Bearer ${e}` } : void 0, u = (e, t) => {
98
+ // ../../libs/api-client/src/auth.ts
99
+ var u = (e) => e ? { Authorization: `Bearer ${e}` } : void 0, d = (e, t) => {
83
100
  try {
84
101
  let t = e.ancestorOrigins;
85
102
  if (t && t.length > 0) return Array.from(t).join(",") || void 0;
@@ -87,34 +104,34 @@ var l = (e) => e ? { Authorization: `Bearer ${e}` } : void 0, u = (e, t) => {
87
104
  try {
88
105
  if (t.referrer) return new URL(t.referrer).origin || void 0;
89
106
  } catch (e) {}
90
- }, d = (e) => typeof e == "object" && !!e && "message" in e, f = class extends Error {
107
+ }, f = (e) => typeof e == "object" && !!e && "message" in e, p = class extends Error {
91
108
  constructor({ status: t, url: n, body: r }) {
92
- let a = i(r), o = d(a) ? a.message : `Url ${n.toString()}, Status code: ${t}, Body: ${r}`;
109
+ let i = a(r), o = f(i) ? i.message : `Url ${n.toString()}, Status code: ${t}, Body: ${r}`;
93
110
  super(o), e(this, "status", void 0), e(this, "body", void 0), e(this, "url", void 0), this.status = t, this.body = r, this.url = n, Object.setPrototypeOf(this, new.target.prototype);
94
111
  }
95
- }, p = (e) => typeof e.status == "number", m = () => {
96
- if (!(typeof window > "u" || typeof document > "u")) return u(window.location, document);
97
- }, h = (e) => {
98
- let t = m();
112
+ }, m = (e) => typeof e.status == "number", h = () => {
113
+ if (typeof window < "u" && typeof document < "u") return d(window.location, document);
114
+ }, g = (e) => {
115
+ let t = h();
99
116
  if (!t || e.searchParams.has("parentOrigin")) return e;
100
117
  let n = new URL(e.toString());
101
118
  return n.searchParams.append("parentOrigin", t), n;
102
- }, g = function() {
119
+ }, _ = function() {
103
120
  var e = t(function* (e, t) {
104
- let r = h(e), i = yield fetch(r.toString(), n({ mode: "cors" }, t));
105
- if (!i.ok) throw new f({
106
- status: i.status,
107
- url: r,
108
- body: yield i.text()
121
+ let n = g(e), r = yield fetch(n.toString(), i({ mode: "cors" }, t));
122
+ if (!r.ok) throw new p({
123
+ status: r.status,
124
+ url: n,
125
+ body: yield r.text()
109
126
  });
110
- return i;
127
+ return r;
111
128
  });
112
129
  return function(t, n) {
113
130
  return e.apply(this, arguments);
114
131
  };
115
- }(), _ = function() {
132
+ }(), v = function() {
116
133
  var e = t(function* (e, t) {
117
- return yield (yield g(e, n({}, t))).json();
134
+ return yield (yield _(e, i({}, t))).json();
118
135
  });
119
136
  return function(t, n) {
120
137
  return e.apply(this, arguments);
@@ -122,74 +139,73 @@ var l = (e) => e ? { Authorization: `Bearer ${e}` } : void 0, u = (e, t) => {
122
139
  }();
123
140
  (function() {
124
141
  var e = t(function* (e) {
125
- return g(e);
142
+ return _(e);
126
143
  });
127
144
  return function(t) {
128
145
  return e.apply(this, arguments);
129
146
  };
130
147
  })();
131
- var v = function() {
148
+ var y = function() {
132
149
  var e = t(function* (e, t) {
133
- return g(e, n({ method: "POST" }, t));
150
+ return _(e, i({ method: "POST" }, t));
134
151
  });
135
152
  return function(t, n) {
136
153
  return e.apply(this, arguments);
137
154
  };
138
155
  }();
139
- //#endregion
140
- //#region ../../libs/api-client/src/responses/connect.ts
141
- function y(e) {
156
+ // ../../libs/api-client/src/responses/connect.ts
157
+ function b(e) {
142
158
  var t;
143
159
  return !(typeof e.edges[0] == "string" || e.channels[0] && "catalog" in e.channels[0] && ((t = e.channels[0]) == null ? void 0 : t.catalog) === void 0);
144
160
  }
145
- //#endregion
146
- //#region ../../libs/api-client/src/client.ts
147
- var b = {
161
+ // ../../libs/api-client/src/client.ts
162
+ var x = {
148
163
  lbConnect: (e) => e.channelGroupId ? `connect?channelId=${e.channelId}&channelGroupId=${e.channelGroupId}` : `connect?channelId=${e.channelId}`,
149
164
  thumbnails: (e, t) => t ? e.channelGroupId ? `thumbnail/?channelGroupId=${e.channelGroupId}&auth.token=${t}&auth.type=jwt` : e.channelId ? `thumbnail/?channelId=${e.channelId}&auth.token=${t}&auth.type=jwt` : "thumbnail" : "thumbnail"
150
- }, x = class {
165
+ }, S = class {
151
166
  constructor(t) {
152
167
  e(this, "baseUrl", void 0), e(this, "tokenFactory", void 0), this.baseUrl = new URL("/api/v4/", t.publicEndpoint).toString(), this.tokenFactory = t.tokenFactory;
153
168
  }
154
169
  connect(e) {
155
- var r = this;
170
+ var n = this;
156
171
  return t(function* () {
157
- let { channelId: t, channelGroupId: i } = e, a = {
172
+ let { channelId: t, channelGroupId: r } = e, a = {
158
173
  channelId: t,
159
- channelGroupId: i
160
- }, o = new URL(b.lbConnect(e), r.baseUrl), s = r.getAuthToken(a), l = yield _(o, { headers: r.getHeaders(s) });
161
- if (y(l)) {
162
- let e = l.channels.map((e) => {
163
- let t = r.toChannel(e, a), i = c(e.catalog);
164
- return n(n(n({}, e), t), {}, { renditions: i });
174
+ channelGroupId: r
175
+ }, o = new URL(x.lbConnect(e), n.baseUrl), s = n.getAuthToken(a), c = yield v(o, { headers: n.getHeaders(s) });
176
+ if (b(c)) {
177
+ let e = c.channels.map((e) => {
178
+ let t = n.toChannel(e, a), r = l(e.catalog);
179
+ return i(i(i({}, e), t), {}, { renditions: r });
165
180
  });
166
- return n(n({}, l), {}, { channels: e });
167
- } else {
168
- let e = l.channels.map((e) => {
169
- let t = r.toChannel(e, a);
170
- return n(n({}, e), t);
181
+ return i(i({}, c), {}, { channels: e });
182
+ }
183
+ {
184
+ let e = c.channels.map((e) => {
185
+ let t = n.toChannel(e, a);
186
+ return i(i({}, e), t);
171
187
  });
172
- return n(n({}, l), {}, { channels: e });
188
+ return i(i({}, c), {}, { channels: e });
173
189
  }
174
190
  })();
175
191
  }
176
192
  getChannel(e) {
177
193
  var n = this;
178
194
  return t(function* () {
179
- let t = { channelId: e }, r = new URL(`channel/${e}`, n.baseUrl), i = n.getAuthToken(t), a = yield _(r, { headers: n.getHeaders(i) });
195
+ let t = { channelId: e }, r = new URL(`channel/${e}`, n.baseUrl), i = n.getAuthToken(t), a = yield v(r, { headers: n.getHeaders(i) });
180
196
  return n.toChannel(a, t, i);
181
197
  })();
182
198
  }
183
199
  getChannels(e) {
184
200
  var n = this;
185
201
  return t(function* () {
186
- let t = { channelGroupId: e }, r = new URL(`channels/${e}`, n.baseUrl), i = n.getAuthToken(t), a = yield _(r, { headers: n.getHeaders(i) }), o = Array.isArray(a) ? a : a.channels;
202
+ let t = { channelGroupId: e }, r = new URL(`channels/${e}`, n.baseUrl), i = n.getAuthToken(t), a = yield v(r, { headers: n.getHeaders(i) }), o = Array.isArray(a) ? a : a.channels;
187
203
  return n.toChannels(o, t, i);
188
204
  })();
189
205
  }
190
206
  getHeaders(e) {
191
207
  var t;
192
- return (t = l(e)) == null ? {} : t;
208
+ return (t = u(e)) == null ? {} : t;
193
209
  }
194
210
  getAuthToken(e) {
195
211
  return this.tokenFactory ? this.tokenFactory(e) : void 0;
@@ -198,7 +214,7 @@ var b = {
198
214
  return e.map((e) => this.toChannel(e, t, n));
199
215
  }
200
216
  toChannel(e, t, n) {
201
- let { baseUrl: r, sizes: i } = e.thumbnail, a = r || new URL(b.thumbnails(t, n), this.baseUrl), o = i.map((r) => new URL(`?channelId=${e.channelId}&width=${r.width}&height=${r.height}${S(t, n)}`, a).toString());
217
+ let { baseUrl: r, sizes: i } = e.thumbnail, a = r || new URL(x.thumbnails(t, n), this.baseUrl), o = i.map((r) => new URL(`?channelId=${e.channelId}&width=${r.width}&height=${r.height}${C(t, n)}`, a).toString());
202
218
  return {
203
219
  channelId: e.channelId,
204
220
  name: e.name,
@@ -206,6 +222,5 @@ var b = {
206
222
  thumbnailUrls: o
207
223
  };
208
224
  }
209
- }, S = (e, t) => t ? e.channelGroupId ? `&channelGroupId=${e.channelGroupId}&auth.token=${t}&auth.type=jwt` : `&auth.token=${t}&auth.type=jwt` : "";
210
- //#endregion
211
- export { s as a, i as c, c as i, r as l, p as n, o, v as r, a as s, x as t };
225
+ }, C = (e, t) => t ? e.channelGroupId ? `&channelGroupId=${e.channelGroupId}&auth.token=${t}&auth.type=jwt` : `&auth.token=${t}&auth.type=jwt` : "";
226
+ export { c as a, a as c, l as i, i as l, m as n, s as o, y as r, o as s, S as t, n as u };
package/Bz5OiWeK.js ADDED
@@ -0,0 +1,129 @@
1
+ import { n as e } from "./DvtbAkGW.js";
2
+ // \0@oxc-project+runtime@0.156.0/helpers/esm/checkPrivateRedeclaration.js
3
+ function t(e, t) {
4
+ if (t.has(e)) throw TypeError("Cannot initialize the same private elements twice on an object");
5
+ }
6
+ // \0@oxc-project+runtime@0.156.0/helpers/esm/classPrivateFieldInitSpec.js
7
+ function n(e, n, r) {
8
+ t(e, n), n.set(e, r);
9
+ }
10
+ // \0@oxc-project+runtime@0.156.0/helpers/esm/assertClassBrand.js
11
+ function r(e, t, n) {
12
+ if (typeof e == "function" ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
13
+ throw TypeError("Private element is not present on this object");
14
+ }
15
+ // \0@oxc-project+runtime@0.156.0/helpers/esm/classPrivateFieldSet2.js
16
+ function i(e, t, n) {
17
+ return e.set(r(e, t), n), n;
18
+ }
19
+ // \0@oxc-project+runtime@0.156.0/helpers/esm/classPrivateFieldGet2.js
20
+ function a(e, t) {
21
+ return e.get(r(e, t));
22
+ }
23
+ // ../../libs/utils/src/Emitter.ts
24
+ var o = class {
25
+ constructor() {
26
+ e(this, "listeners", {});
27
+ }
28
+ handleListenerError(e, t) {
29
+ throw e;
30
+ }
31
+ emit(e, t) {
32
+ let n = this.listeners[e];
33
+ if (n) {
34
+ let r = !1;
35
+ for (let e = 0; e < n.length; e++) if (n[e].once) {
36
+ r = !0;
37
+ break;
38
+ }
39
+ r && (this.listeners[e] = n.filter((e) => !e.once));
40
+ let i, a = n.length;
41
+ for (let r = 0; r < a; r++) try {
42
+ let e = n[r].fn(t);
43
+ typeof e == "function" && (i || (i = []), i.push(e));
44
+ } catch (t) {
45
+ this.handleListenerError(t, e);
46
+ }
47
+ if (i) for (let t = 0; t < i.length; t++) try {
48
+ i[t]();
49
+ } catch (t) {
50
+ this.handleListenerError(t, e);
51
+ }
52
+ }
53
+ }
54
+ off(e, t) {
55
+ let n = this.listeners[e];
56
+ n && (this.listeners[e] = n.filter((e) => e.fn !== t));
57
+ }
58
+ on(e, t) {
59
+ this.add(e, t, !1);
60
+ }
61
+ once(e, t) {
62
+ this.add(e, t, !0);
63
+ }
64
+ hasListeners(e) {
65
+ let t = this.listeners[e];
66
+ return t !== void 0 && t.length > 0;
67
+ }
68
+ reset() {
69
+ this.listeners = {};
70
+ }
71
+ add(e, t, n) {
72
+ let r = this.listeners[e], i = {
73
+ fn: t,
74
+ once: n
75
+ };
76
+ r ? r.push(i) : this.listeners[e] = [i];
77
+ }
78
+ }, s = [
79
+ "off",
80
+ "error",
81
+ "warn",
82
+ "info",
83
+ "debug",
84
+ "trace"
85
+ ], c = {
86
+ ERROR: "error",
87
+ WARN: "warn",
88
+ INFO: "info",
89
+ DEBUG: "debug",
90
+ TRACE: "trace",
91
+ OFF: "off"
92
+ }, l = /* @__PURE__ */ new WeakMap(), u = /* @__PURE__ */ new WeakMap(), d = /* @__PURE__ */ new WeakMap(), f = /* @__PURE__ */ new WeakMap(), p = class t {
93
+ constructor({ context: t, logLevel: r, debug: o }) {
94
+ n(this, l, /* @__PURE__ */ new Map()), n(this, u, ""), n(this, d, !1), n(this, f, "off"), e(this, "trace", (...e) => {}), e(this, "debug", (...e) => {}), e(this, "info", (...e) => {}), e(this, "warn", (...e) => {}), e(this, "error", (...e) => {}), e(this, "table", (...e) => {}), e(this, "count", (...e) => {}), i(u, this, t), i(f, this, r), i(d, this, o || !1), this.setLevel(r), this.setDebug(a(d, this));
95
+ }
96
+ setDebug(e) {
97
+ i(d, this, e);
98
+ for (let [t, n] of a(l, this)) n.setDebug(e);
99
+ e ? (this.table = console.table.bind(console), this.count = console.count.bind(console)) : (this.table = () => {}, this.count = () => {});
100
+ }
101
+ getLevel() {
102
+ return a(f, this);
103
+ }
104
+ setLevel(e) {
105
+ i(f, this, e);
106
+ for (let [t, n] of a(l, this)) n.setLevel(e);
107
+ let t = s.indexOf(e);
108
+ for (let [e, n] of s.entries()) n !== "off" && (this[n] = e <= t ? console[n].bind(console, "%c%s %c%s", "font-weight:bold;", n.toUpperCase(), "font-weight:normal;", a(u, this)) : () => {});
109
+ }
110
+ createContext(e) {
111
+ let n = a(l, this).get(e);
112
+ if (!n) {
113
+ let n = new t({
114
+ context: `${e}`,
115
+ logLevel: a(f, this),
116
+ debug: a(d, this)
117
+ });
118
+ return a(l, this).set(e, n), n;
119
+ }
120
+ return n;
121
+ }
122
+ static get() {
123
+ return m._ || (m._ = new t({
124
+ context: "Vindral",
125
+ logLevel: "off"
126
+ })), m._;
127
+ }
128
+ }, m = { _: void 0 };
129
+ export { i as a, t as c, a as i, p as n, r as o, o as r, n as s, c as t };