test-bentoweb-ui 1.0.73 → 1.0.75

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.
@@ -0,0 +1,377 @@
1
+ var Lt = Object.defineProperty;
2
+ var W = (d) => {
3
+ throw TypeError(d);
4
+ };
5
+ var vt = (d, t, s) => t in d ? Lt(d, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : d[t] = s;
6
+ var G = (d, t, s) => vt(d, typeof t != "symbol" ? t + "" : t, s), O = (d, t, s) => t.has(d) || W("Cannot " + s);
7
+ var e = (d, t, s) => (O(d, t, "read from private field"), s ? s.call(d) : t.get(d)), T = (d, t, s) => t.has(d) ? W("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(d) : t.set(d, s), l = (d, t, s, i) => (O(d, t, "write to private field"), i ? i.call(d, s) : t.set(d, s), s), r = (d, t, s) => (O(d, t, "access private method"), s);
8
+ import { y as St, K as L, am as Z, x as At, D as tt, d as V, l as et, e as It, an as bt, L as Rt } from "./index-CJNQa9oe.js";
9
+ import { R as wt } from "./vidstack-DqAw8m9J-C-yN2xmu.js";
10
+ import { g as Mt, a as Dt, b as it, h as st, l as Nt, c as Pt } from "./vidstack-D2pY00kU-DWwZEB1N.js";
11
+ var g, _, at;
12
+ class _t {
13
+ constructor(t) {
14
+ T(this, _);
15
+ T(this, g);
16
+ l(this, g, new chrome.cast.media.MediaInfo(t.src, t.type));
17
+ }
18
+ build() {
19
+ return e(this, g);
20
+ }
21
+ setStreamType(t) {
22
+ return t.includes("live") ? e(this, g).streamType = chrome.cast.media.StreamType.LIVE : e(this, g).streamType = chrome.cast.media.StreamType.BUFFERED, this;
23
+ }
24
+ setTracks(t) {
25
+ return e(this, g).tracks = t.map(r(this, _, at)), this;
26
+ }
27
+ setMetadata(t, s) {
28
+ return e(this, g).metadata = new chrome.cast.media.GenericMediaMetadata(), e(this, g).metadata.title = t, e(this, g).metadata.images = [{ url: s }], this;
29
+ }
30
+ }
31
+ g = new WeakMap(), _ = new WeakSet(), at = function(t, s) {
32
+ const i = new chrome.cast.media.Track(s, chrome.cast.media.TrackType.TEXT);
33
+ return i.name = t.label, i.trackContentId = t.src, i.trackContentType = "text/vtt", i.language = t.language, i.subtype = t.kind.toUpperCase(), i;
34
+ };
35
+ var p, k, M, c, $, A, rt, nt, ot, H, P, U;
36
+ class xt {
37
+ constructor(t, s, i) {
38
+ T(this, c);
39
+ T(this, p);
40
+ T(this, k);
41
+ T(this, M);
42
+ l(this, p, t), l(this, k, s), l(this, M, i);
43
+ }
44
+ setup() {
45
+ const t = this.syncRemoteActiveIds.bind(this);
46
+ et(e(this, k).audioTracks, "change", t), et(e(this, k).textTracks, "mode-change", t), It(r(this, c, nt).bind(this));
47
+ }
48
+ getLocalTextTracks() {
49
+ return e(this, k).$state.textTracks().filter((t) => t.src && t.type === "vtt");
50
+ }
51
+ syncRemoteTracks(t) {
52
+ if (!e(this, p).isMediaLoaded) return;
53
+ const s = r(this, c, $).call(this), i = this.getLocalTextTracks(), n = r(this, c, A).call(this, chrome.cast.media.TrackType.AUDIO), m = r(this, c, A).call(this, chrome.cast.media.TrackType.TEXT);
54
+ for (const u of n) {
55
+ if (r(this, c, H).call(this, s, u)) continue;
56
+ const w = {
57
+ id: u.trackId.toString(),
58
+ label: u.name,
59
+ language: u.language,
60
+ kind: u.subtype ?? "main",
61
+ selected: !1
62
+ };
63
+ e(this, k).audioTracks[Rt.add](w, t);
64
+ }
65
+ for (const u of m) {
66
+ if (r(this, c, H).call(this, i, u)) continue;
67
+ const w = {
68
+ id: u.trackId.toString(),
69
+ src: u.trackContentId,
70
+ label: u.name,
71
+ language: u.language,
72
+ kind: u.subtype.toLowerCase()
73
+ };
74
+ e(this, k).textTracks.add(w, t);
75
+ }
76
+ }
77
+ syncRemoteActiveIds(t) {
78
+ if (!e(this, p).isMediaLoaded) return;
79
+ const s = r(this, c, rt).call(this), i = new chrome.cast.media.EditTracksInfoRequest(s);
80
+ r(this, c, ot).call(this, i).catch((n) => {
81
+ });
82
+ }
83
+ }
84
+ p = new WeakMap(), k = new WeakMap(), M = new WeakMap(), c = new WeakSet(), $ = function() {
85
+ return e(this, k).$state.audioTracks();
86
+ }, A = function(t) {
87
+ var i;
88
+ const s = ((i = e(this, p).mediaInfo) == null ? void 0 : i.tracks) ?? [];
89
+ return t ? s.filter((n) => n.type === t) : s;
90
+ }, rt = function() {
91
+ const t = [], s = r(this, c, $).call(this).find((n) => n.selected), i = this.getLocalTextTracks().filter((n) => n.mode === "showing");
92
+ if (s) {
93
+ const n = r(this, c, A).call(this, chrome.cast.media.TrackType.AUDIO), m = r(this, c, P).call(this, n, s);
94
+ m && t.push(m.trackId);
95
+ }
96
+ if (i != null && i.length) {
97
+ const n = r(this, c, A).call(this, chrome.cast.media.TrackType.TEXT);
98
+ if (n.length)
99
+ for (const m of i) {
100
+ const u = r(this, c, P).call(this, n, m);
101
+ u && t.push(u.trackId);
102
+ }
103
+ }
104
+ return t;
105
+ }, nt = function() {
106
+ const t = this.getLocalTextTracks();
107
+ if (!e(this, p).isMediaLoaded) return;
108
+ const s = r(this, c, A).call(this, chrome.cast.media.TrackType.TEXT);
109
+ for (const i of t)
110
+ if (!r(this, c, P).call(this, s, i)) {
111
+ bt(() => {
112
+ var m;
113
+ return (m = e(this, M)) == null ? void 0 : m.call(this);
114
+ });
115
+ break;
116
+ }
117
+ }, ot = function(t) {
118
+ const s = it();
119
+ return new Promise((i, n) => s == null ? void 0 : s.editTracksInfo(t, i, n));
120
+ }, H = function(t, s) {
121
+ return t.find((i) => r(this, c, U).call(this, i, s));
122
+ }, P = function(t, s) {
123
+ return t.find((i) => r(this, c, U).call(this, s, i));
124
+ }, // Note: we can't rely on id matching because they will differ between local/remote. A local
125
+ // track id might not even exist.
126
+ U = function(t, s) {
127
+ return s.name === t.label && s.language === t.language && s.subtype.toLowerCase() === t.kind.toLowerCase();
128
+ };
129
+ var o, h, C, E, D, I, v, S, b, N, f, R, a, ht, ct, F, dt, q, ut, lt, mt, B, X, K, Y, Tt, ft, gt, j, kt, z, yt, J, y, pt, Ct, Q, Et;
130
+ class Ht {
131
+ constructor(t, s) {
132
+ T(this, a);
133
+ G(this, "$$PROVIDER_TYPE", "GOOGLE_CAST");
134
+ G(this, "scope", St());
135
+ T(this, o);
136
+ T(this, h);
137
+ T(this, C);
138
+ T(this, E, null);
139
+ T(this, D, "disconnected");
140
+ T(this, I, 0);
141
+ T(this, v, 0);
142
+ T(this, S, new L(0, 0));
143
+ T(this, b, new wt(r(this, a, lt).bind(this)));
144
+ T(this, N);
145
+ T(this, f, null);
146
+ T(this, R, !1);
147
+ l(this, o, t), l(this, h, s), l(this, C, new xt(t, s, r(this, a, Et).bind(this)));
148
+ }
149
+ get type() {
150
+ return "google-cast";
151
+ }
152
+ get currentSrc() {
153
+ return e(this, E);
154
+ }
155
+ /**
156
+ * The Google Cast remote player.
157
+ *
158
+ * @see {@link https://developers.google.com/cast/docs/reference/web_sender/cast.framework.RemotePlayer}
159
+ */
160
+ get player() {
161
+ return e(this, o);
162
+ }
163
+ /**
164
+ * @see {@link https://developers.google.com/cast/docs/reference/web_sender/cast.framework.CastContext}
165
+ */
166
+ get cast() {
167
+ return Mt();
168
+ }
169
+ /**
170
+ * @see {@link https://developers.google.com/cast/docs/reference/web_sender/cast.framework.CastSession}
171
+ */
172
+ get session() {
173
+ return Dt();
174
+ }
175
+ /**
176
+ * @see {@link https://developers.google.com/cast/docs/reference/web_sender/chrome.cast.media.Media}
177
+ */
178
+ get media() {
179
+ return it();
180
+ }
181
+ /**
182
+ * Whether the current Google Cast session belongs to this provider.
183
+ */
184
+ get hasActiveSession() {
185
+ return st(e(this, E));
186
+ }
187
+ setup() {
188
+ r(this, a, ht).call(this), r(this, a, ct).call(this), e(this, C).setup(), e(this, h).notify("provider-setup", this);
189
+ }
190
+ async play() {
191
+ var t;
192
+ if (!(!e(this, o).isPaused && !e(this, R))) {
193
+ if (e(this, R)) {
194
+ await r(this, a, Q).call(this, !1, 0);
195
+ return;
196
+ }
197
+ (t = e(this, o).controller) == null || t.playOrPause();
198
+ }
199
+ }
200
+ async pause() {
201
+ var t;
202
+ e(this, o).isPaused || (t = e(this, o).controller) == null || t.playOrPause();
203
+ }
204
+ getMediaStatus(t) {
205
+ return new Promise((s, i) => {
206
+ var n;
207
+ (n = this.media) == null || n.getStatus(t, s, i);
208
+ });
209
+ }
210
+ setMuted(t) {
211
+ var i;
212
+ (t && !e(this, o).isMuted || !t && e(this, o).isMuted) && ((i = e(this, o).controller) == null || i.muteOrUnmute());
213
+ }
214
+ setCurrentTime(t) {
215
+ var s;
216
+ e(this, o).currentTime = t, e(this, h).notify("seeking", t), (s = e(this, o).controller) == null || s.seek();
217
+ }
218
+ setVolume(t) {
219
+ var s;
220
+ e(this, o).volumeLevel = t, (s = e(this, o).controller) == null || s.setVolumeLevel();
221
+ }
222
+ async loadSource(t) {
223
+ var n;
224
+ if (((n = e(this, f)) == null ? void 0 : n.src) !== t && l(this, f, null), st(t)) {
225
+ r(this, a, dt).call(this), l(this, E, t);
226
+ return;
227
+ }
228
+ e(this, h).notify("load-start");
229
+ const s = r(this, a, Ct).call(this, t), i = await this.session.loadMedia(s);
230
+ if (i) {
231
+ l(this, E, null), e(this, h).notify("error", Error(Pt(i)));
232
+ return;
233
+ }
234
+ l(this, E, t);
235
+ }
236
+ destroy() {
237
+ r(this, a, F).call(this), r(this, a, q).call(this);
238
+ }
239
+ }
240
+ o = new WeakMap(), h = new WeakMap(), C = new WeakMap(), E = new WeakMap(), D = new WeakMap(), I = new WeakMap(), v = new WeakMap(), S = new WeakMap(), b = new WeakMap(), N = new WeakMap(), f = new WeakMap(), R = new WeakMap(), a = new WeakSet(), ht = function() {
241
+ Nt(
242
+ cast.framework.CastContextEventType.CAST_STATE_CHANGED,
243
+ r(this, a, B).bind(this)
244
+ );
245
+ }, ct = function() {
246
+ const t = cast.framework.RemotePlayerEventType, s = {
247
+ [t.IS_CONNECTED_CHANGED]: r(this, a, B),
248
+ [t.IS_MEDIA_LOADED_CHANGED]: r(this, a, X),
249
+ [t.CAN_CONTROL_VOLUME_CHANGED]: r(this, a, K),
250
+ [t.CAN_SEEK_CHANGED]: r(this, a, Y),
251
+ [t.DURATION_CHANGED]: r(this, a, gt),
252
+ [t.IS_MUTED_CHANGED]: r(this, a, j),
253
+ [t.VOLUME_LEVEL_CHANGED]: r(this, a, j),
254
+ [t.IS_PAUSED_CHANGED]: r(this, a, kt),
255
+ [t.LIVE_SEEKABLE_RANGE_CHANGED]: r(this, a, z),
256
+ [t.PLAYER_STATE_CHANGED]: r(this, a, yt)
257
+ };
258
+ l(this, N, s);
259
+ const i = r(this, a, mt).bind(this);
260
+ for (const n of Z(s))
261
+ e(this, o).controller.addEventListener(n, i);
262
+ At(() => {
263
+ for (const n of Z(s))
264
+ e(this, o).controller.removeEventListener(n, i);
265
+ });
266
+ }, F = function() {
267
+ e(this, f) || (l(this, v, 0), l(this, S, new L(0, 0))), e(this, b).stop(), l(this, I, 0), l(this, f, null);
268
+ }, dt = function() {
269
+ const t = new tt("resume-session", { detail: this.session });
270
+ r(this, a, X).call(this, t);
271
+ const { muted: s, volume: i, savedState: n } = e(this, h).$state, m = n();
272
+ this.setCurrentTime(Math.max(e(this, o).currentTime, (m == null ? void 0 : m.currentTime) ?? 0)), this.setMuted(s()), this.setVolume(i()), (m == null ? void 0 : m.paused) === !1 && this.play();
273
+ }, q = function() {
274
+ this.cast.endCurrentSession(!0);
275
+ const { remotePlaybackLoader: t } = e(this, h).$state;
276
+ t.set(null);
277
+ }, ut = function() {
278
+ const { savedState: t } = e(this, h).$state;
279
+ t.set({
280
+ paused: e(this, o).isPaused,
281
+ currentTime: e(this, o).currentTime
282
+ }), r(this, a, q).call(this);
283
+ }, lt = function() {
284
+ r(this, a, ft).call(this);
285
+ }, mt = function(t) {
286
+ e(this, N)[t.type].call(this, t);
287
+ }, B = function(t) {
288
+ const s = this.cast.getCastState(), i = s === cast.framework.CastState.CONNECTED ? "connected" : s === cast.framework.CastState.CONNECTING ? "connecting" : "disconnected";
289
+ if (e(this, D) === i) return;
290
+ const n = { type: "google-cast", state: i }, m = r(this, a, y).call(this, t);
291
+ l(this, D, i), e(this, h).notify("remote-playback-change", n, m), i === "disconnected" && r(this, a, ut).call(this);
292
+ }, X = function(t) {
293
+ if (!!!e(this, o).isMediaLoaded) return;
294
+ const i = V(e(this, h).$state.source);
295
+ Promise.resolve().then(() => {
296
+ if (i !== V(e(this, h).$state.source) || !e(this, o).isMediaLoaded) return;
297
+ r(this, a, F).call(this);
298
+ const n = e(this, o).duration;
299
+ l(this, S, new L(0, n));
300
+ const m = {
301
+ provider: this,
302
+ duration: n,
303
+ buffered: new L(0, 0),
304
+ seekable: r(this, a, J).call(this)
305
+ }, u = r(this, a, y).call(this, t);
306
+ e(this, h).notify("loaded-metadata", void 0, u), e(this, h).notify("loaded-data", void 0, u), e(this, h).notify("can-play", m, u), r(this, a, K).call(this), r(this, a, Y).call(this, t);
307
+ const { volume: x, muted: w } = e(this, h).$state;
308
+ this.setVolume(x()), this.setMuted(w()), e(this, b).start(), e(this, C).syncRemoteTracks(u), e(this, C).syncRemoteActiveIds(u);
309
+ });
310
+ }, K = function() {
311
+ e(this, h).$state.canSetVolume.set(e(this, o).canControlVolume);
312
+ }, Y = function(t) {
313
+ const s = r(this, a, y).call(this, t);
314
+ e(this, h).notify("stream-type-change", r(this, a, Tt).call(this), s);
315
+ }, Tt = function() {
316
+ var s;
317
+ return ((s = e(this, o).mediaInfo) == null ? void 0 : s.streamType) === chrome.cast.media.StreamType.LIVE ? e(this, o).canSeek ? "live:dvr" : "live" : "on-demand";
318
+ }, ft = function() {
319
+ if (e(this, f)) return;
320
+ const t = e(this, o).currentTime;
321
+ t !== e(this, I) && (e(this, h).notify("time-change", t), t > e(this, v) && (l(this, v, t), r(this, a, z).call(this)), e(this, h).$state.seeking() && e(this, h).notify("seeked", t), l(this, I, t));
322
+ }, gt = function(t) {
323
+ if (!e(this, o).isMediaLoaded || e(this, f)) return;
324
+ const s = e(this, o).duration, i = r(this, a, y).call(this, t);
325
+ l(this, S, new L(0, s)), e(this, h).notify("duration-change", s, i);
326
+ }, j = function(t) {
327
+ if (!e(this, o).isMediaLoaded) return;
328
+ const s = {
329
+ muted: e(this, o).isMuted,
330
+ volume: e(this, o).volumeLevel
331
+ }, i = r(this, a, y).call(this, t);
332
+ e(this, h).notify("volume-change", s, i);
333
+ }, kt = function(t) {
334
+ const s = r(this, a, y).call(this, t);
335
+ e(this, o).isPaused ? e(this, h).notify("pause", void 0, s) : e(this, h).notify("play", void 0, s);
336
+ }, z = function(t) {
337
+ const s = {
338
+ seekable: r(this, a, J).call(this),
339
+ buffered: new L(0, e(this, v))
340
+ }, i = t ? r(this, a, y).call(this, t) : void 0;
341
+ e(this, h).notify("progress", s, i);
342
+ }, yt = function(t) {
343
+ const s = e(this, o).playerState, i = chrome.cast.media.PlayerState;
344
+ if (l(this, R, s === i.IDLE), s === i.PAUSED) return;
345
+ const n = r(this, a, y).call(this, t);
346
+ switch (s) {
347
+ case i.PLAYING:
348
+ e(this, h).notify("playing", void 0, n);
349
+ break;
350
+ case i.BUFFERING:
351
+ e(this, h).notify("waiting", void 0, n);
352
+ break;
353
+ case i.IDLE:
354
+ e(this, b).stop(), e(this, h).notify("pause"), e(this, h).notify("end");
355
+ break;
356
+ }
357
+ }, J = function() {
358
+ return e(this, o).liveSeekableRange ? new L(e(this, o).liveSeekableRange.start, e(this, o).liveSeekableRange.end) : e(this, S);
359
+ }, y = function(t) {
360
+ return t instanceof Event ? t : new tt(t.type, { detail: t });
361
+ }, pt = function(t) {
362
+ const { streamType: s, title: i, poster: n } = e(this, h).$state;
363
+ return new _t(t).setMetadata(i(), n()).setStreamType(s()).setTracks(e(this, C).getLocalTextTracks()).build();
364
+ }, Ct = function(t) {
365
+ var m, u;
366
+ const s = r(this, a, pt).call(this, t), i = new chrome.cast.media.LoadRequest(s), n = e(this, h).$state.savedState();
367
+ return i.autoplay = (((m = e(this, f)) == null ? void 0 : m.paused) ?? (n == null ? void 0 : n.paused)) === !1, i.currentTime = ((u = e(this, f)) == null ? void 0 : u.time) ?? (n == null ? void 0 : n.currentTime) ?? 0, i;
368
+ }, Q = async function(t, s) {
369
+ const i = V(e(this, h).$state.source);
370
+ l(this, f, { src: i, paused: t, time: s }), await this.loadSource(i);
371
+ }, Et = function() {
372
+ r(this, a, Q).call(this, e(this, o).isPaused, e(this, o).currentTime).catch((t) => {
373
+ });
374
+ };
375
+ export {
376
+ Ht as GoogleCastProvider
377
+ };
@@ -0,0 +1,324 @@
1
+ var rt = Object.defineProperty;
2
+ var N = (n) => {
3
+ throw TypeError(n);
4
+ };
5
+ var ot = (n, t, i) => t in n ? rt(n, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : n[t] = i;
6
+ var _ = (n, t, i) => ot(n, typeof t != "symbol" ? t + "" : t, i), R = (n, t, i) => t.has(n) || N("Cannot " + i);
7
+ var e = (n, t, i) => (R(n, t, "read from private field"), i ? i.call(n) : t.get(n)), p = (n, t, i) => t.has(n) ? N("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(n) : t.set(n, i), f = (n, t, i, s) => (R(n, t, "write to private field"), s ? s.call(n, i) : t.set(n, i), i), a = (n, t, i) => (R(n, t, "access private method"), i);
8
+ import { i as ht, b as C, p as at, d as O, Q as V, l as j, e as dt, D as x, T as ut, f as k, L as $, g as ct, h as q, j as lt, k as pt, m as ft, n as vt } from "./index-CJNQa9oe.js";
9
+ import { VideoProvider as yt } from "./vidstack-video-YYohV9Kw.js";
10
+ import { R as gt } from "./vidstack-DqAw8m9J-C-yN2xmu.js";
11
+ const Lt = (n) => vt(n);
12
+ var T, h, o, D, b, r, E, M, U, F, Q, K, W, B, J, X, Y, z, G, Z, tt;
13
+ class St {
14
+ constructor(t, i) {
15
+ p(this, r);
16
+ p(this, T);
17
+ p(this, h);
18
+ p(this, o, null);
19
+ p(this, D, null);
20
+ _(this, "config", {});
21
+ p(this, b, /* @__PURE__ */ new Set());
22
+ f(this, T, t), f(this, h, i);
23
+ }
24
+ get instance() {
25
+ return e(this, o);
26
+ }
27
+ setup(t) {
28
+ const { streamType: i } = e(this, h).$state, s = O(i).includes("live"), c = O(i).includes("ll-");
29
+ f(this, o, new t({
30
+ lowLatencyMode: c,
31
+ backBufferLength: c ? 4 : s ? 8 : void 0,
32
+ renderTextTracksNatively: !1,
33
+ ...this.config
34
+ }));
35
+ const u = a(this, r, F).bind(this);
36
+ for (const l of Object.values(t.Events)) e(this, o).on(l, u);
37
+ e(this, o).on(t.Events.ERROR, a(this, r, Y).bind(this));
38
+ for (const l of e(this, b)) l(e(this, o));
39
+ e(this, h).player.dispatch("hls-instance", {
40
+ detail: e(this, o)
41
+ }), e(this, o).attachMedia(e(this, T)), e(this, o).on(t.Events.AUDIO_TRACK_SWITCHED, a(this, r, W).bind(this)), e(this, o).on(t.Events.LEVEL_SWITCHED, a(this, r, B).bind(this)), e(this, o).on(t.Events.LEVEL_LOADED, a(this, r, X).bind(this)), e(this, o).on(t.Events.LEVEL_UPDATED, a(this, r, J).bind(this)), e(this, o).on(t.Events.NON_NATIVE_TEXT_TRACKS_FOUND, a(this, r, Q).bind(this)), e(this, o).on(t.Events.CUES_PARSED, a(this, r, K).bind(this)), e(this, h).qualities[V.enableAuto] = a(this, r, G).bind(this), j(e(this, h).qualities, "change", a(this, r, Z).bind(this)), j(e(this, h).audioTracks, "change", a(this, r, tt).bind(this)), f(this, D, dt(a(this, r, M).bind(this)));
42
+ }
43
+ onInstance(t) {
44
+ return e(this, b).add(t), () => e(this, b).delete(t);
45
+ }
46
+ loadSource(t) {
47
+ var i;
48
+ C(t.src) && ((i = e(this, o)) == null || i.loadSource(t.src));
49
+ }
50
+ destroy() {
51
+ var t, i;
52
+ (t = e(this, o)) == null || t.destroy(), f(this, o, null), (i = e(this, D)) == null || i.call(this), f(this, D, null);
53
+ }
54
+ }
55
+ T = new WeakMap(), h = new WeakMap(), o = new WeakMap(), D = new WeakMap(), b = new WeakMap(), r = new WeakSet(), E = function(t, i) {
56
+ return new x(Lt(t), { detail: i });
57
+ }, M = function() {
58
+ if (!e(this, h).$state.live()) return;
59
+ const t = new gt(a(this, r, U).bind(this));
60
+ return t.start(), t.stop.bind(t);
61
+ }, U = function() {
62
+ var t;
63
+ e(this, h).$state.liveSyncPosition.set(((t = e(this, o)) == null ? void 0 : t.liveSyncPosition) ?? 1 / 0);
64
+ }, F = function(t, i) {
65
+ var s;
66
+ (s = e(this, h).player) == null || s.dispatch(a(this, r, E).call(this, t, i));
67
+ }, Q = function(t, i) {
68
+ const s = a(this, r, E).call(this, t, i);
69
+ let c = -1;
70
+ for (let u = 0; u < i.tracks.length; u++) {
71
+ const l = i.tracks[u], d = l.subtitleTrack ?? l.closedCaptions, w = new ut({
72
+ id: `hls-${l.kind}-${u}`,
73
+ src: d == null ? void 0 : d.url,
74
+ label: l.label,
75
+ language: d == null ? void 0 : d.lang,
76
+ kind: l.kind,
77
+ default: l.default
78
+ });
79
+ w[k.readyState] = 2, w[k.onModeChange] = () => {
80
+ w.mode === "showing" ? (e(this, o).subtitleTrack = u, c = u) : c === u && (e(this, o).subtitleTrack = -1, c = -1);
81
+ }, e(this, h).textTracks.add(w, s);
82
+ }
83
+ }, K = function(t, i) {
84
+ var l;
85
+ const s = (l = e(this, o)) == null ? void 0 : l.subtitleTrack, c = e(this, h).textTracks.getById(`hls-${i.type}-${s}`);
86
+ if (!c) return;
87
+ const u = a(this, r, E).call(this, t, i);
88
+ for (const d of i.cues)
89
+ d.positionAlign = "auto", c.addCue(d, u);
90
+ }, W = function(t, i) {
91
+ const s = e(this, h).audioTracks[i.id];
92
+ if (s) {
93
+ const c = a(this, r, E).call(this, t, i);
94
+ e(this, h).audioTracks[$.select](s, !0, c);
95
+ }
96
+ }, B = function(t, i) {
97
+ const s = e(this, h).qualities[i.level];
98
+ if (s) {
99
+ const c = a(this, r, E).call(this, t, i);
100
+ e(this, h).qualities[$.select](s, !0, c);
101
+ }
102
+ }, J = function(t, i) {
103
+ i.details.totalduration > 0 && e(this, h).$state.inferredLiveDVRWindow.set(i.details.totalduration);
104
+ }, X = function(t, i) {
105
+ var P;
106
+ if (e(this, h).$state.canPlay()) return;
107
+ const { type: s, live: c, totalduration: u, targetduration: l } = i.details, d = a(this, r, E).call(this, t, i);
108
+ e(this, h).notify(
109
+ "stream-type-change",
110
+ c ? s === "EVENT" && Number.isFinite(u) && l >= 10 ? "live:dvr" : "live" : "on-demand",
111
+ d
112
+ ), e(this, h).notify("duration-change", u, d);
113
+ const w = e(this, o).media;
114
+ e(this, o).currentLevel === -1 && e(this, h).qualities[V.setAuto](!0, d);
115
+ for (const y of e(this, o).audioTracks) {
116
+ const H = {
117
+ id: y.id.toString(),
118
+ label: y.name,
119
+ language: y.lang || "",
120
+ kind: "main"
121
+ };
122
+ e(this, h).audioTracks[$.add](H, d);
123
+ }
124
+ for (const y of e(this, o).levels) {
125
+ const H = {
126
+ id: ((P = y.id) == null ? void 0 : P.toString()) ?? y.height + "p",
127
+ width: y.width,
128
+ height: y.height,
129
+ codec: y.codecSet,
130
+ bitrate: y.bitrate
131
+ };
132
+ e(this, h).qualities[$.add](H, d);
133
+ }
134
+ w.dispatchEvent(new x("canplay", { trigger: d }));
135
+ }, Y = function(t, i) {
136
+ var s;
137
+ if (i.fatal)
138
+ switch (i.type) {
139
+ case "mediaError":
140
+ (s = e(this, o)) == null || s.recoverMediaError();
141
+ break;
142
+ default:
143
+ a(this, r, z).call(this, i.error);
144
+ break;
145
+ }
146
+ }, z = function(t) {
147
+ e(this, h).notify("error", {
148
+ message: t.message,
149
+ code: 1,
150
+ error: t
151
+ });
152
+ }, G = function() {
153
+ e(this, o) && (e(this, o).currentLevel = -1);
154
+ }, Z = function() {
155
+ const { qualities: t } = e(this, h);
156
+ !e(this, o) || t.auto || (e(this, o)[t.switch + "Level"] = t.selectedIndex, ct && (e(this, T).currentTime = e(this, T).currentTime));
157
+ }, tt = function() {
158
+ const { audioTracks: t } = e(this, h);
159
+ e(this, o) && e(this, o).audioTrack !== t.selectedIndex && (e(this, o).audioTrack = t.selectedIndex);
160
+ };
161
+ var m, g, I, L, it, et, st, nt;
162
+ class Et {
163
+ constructor(t, i, s) {
164
+ p(this, L);
165
+ p(this, m);
166
+ p(this, g);
167
+ p(this, I);
168
+ f(this, m, t), f(this, g, i), f(this, I, s), a(this, L, it).call(this);
169
+ }
170
+ }
171
+ m = new WeakMap(), g = new WeakMap(), I = new WeakMap(), L = new WeakSet(), it = async function() {
172
+ const t = {
173
+ onLoadStart: a(this, L, et).bind(this),
174
+ onLoaded: a(this, L, st).bind(this),
175
+ onLoadError: a(this, L, nt).bind(this)
176
+ };
177
+ let i = await mt(e(this, m), t);
178
+ if (q(i) && !C(e(this, m)) && (i = await Tt(e(this, m), t)), !i) return null;
179
+ if (!i.isSupported()) {
180
+ const s = "[vidstack] `hls.js` is not supported in this environment";
181
+ return e(this, g).player.dispatch(new x("hls-unsupported")), e(this, g).notify("error", { message: s, code: 4 }), null;
182
+ }
183
+ return i;
184
+ }, et = function() {
185
+ e(this, g).player.dispatch(new x("hls-lib-load-start"));
186
+ }, st = function(t) {
187
+ e(this, g).player.dispatch(
188
+ new x("hls-lib-loaded", {
189
+ detail: t
190
+ })
191
+ ), e(this, I).call(this, t);
192
+ }, nt = function(t) {
193
+ const i = lt(t);
194
+ e(this, g).player.dispatch(
195
+ new x("hls-lib-load-error", {
196
+ detail: i
197
+ })
198
+ ), e(this, g).notify("error", {
199
+ message: i.message,
200
+ code: 4,
201
+ error: i
202
+ });
203
+ };
204
+ async function Tt(n, t = {}) {
205
+ var i, s, c, u, l;
206
+ if (!q(n)) {
207
+ if ((i = t.onLoadStart) == null || i.call(t), n.prototype && n.prototype !== Function)
208
+ return (s = t.onLoaded) == null || s.call(t, n), n;
209
+ try {
210
+ const d = (c = await n()) == null ? void 0 : c.default;
211
+ if (d && d.isSupported)
212
+ (u = t.onLoaded) == null || u.call(t, d);
213
+ else
214
+ throw Error(
215
+ ""
216
+ );
217
+ return d;
218
+ } catch (d) {
219
+ (l = t.onLoadError) == null || l.call(t, d);
220
+ }
221
+ }
222
+ }
223
+ async function mt(n, t = {}) {
224
+ var i, s, c;
225
+ if (C(n)) {
226
+ (i = t.onLoadStart) == null || i.call(t);
227
+ try {
228
+ if (await pt(n), !ft(window.Hls))
229
+ throw Error(
230
+ ""
231
+ );
232
+ const u = window.Hls;
233
+ return (s = t.onLoaded) == null || s.call(t, u), u;
234
+ } catch (u) {
235
+ (c = t.onLoadError) == null || c.call(t, u);
236
+ }
237
+ }
238
+ }
239
+ const wt = "https://cdn.jsdelivr.net";
240
+ var A, v, S;
241
+ class xt extends yt {
242
+ constructor() {
243
+ super(...arguments);
244
+ _(this, "$$PROVIDER_TYPE", "HLS");
245
+ p(this, A, null);
246
+ p(this, v, new St(this.video, this.ctx));
247
+ p(this, S, `${wt}/npm/hls.js@^1.5.0/dist/hls.min.js`);
248
+ }
249
+ /**
250
+ * The `hls.js` constructor.
251
+ */
252
+ get ctor() {
253
+ return e(this, A);
254
+ }
255
+ /**
256
+ * The current `hls.js` instance.
257
+ */
258
+ get instance() {
259
+ return e(this, v).instance;
260
+ }
261
+ get type() {
262
+ return "hls";
263
+ }
264
+ get canLiveSync() {
265
+ return !0;
266
+ }
267
+ /**
268
+ * The `hls.js` configuration object.
269
+ *
270
+ * @see {@link https://github.com/video-dev/hls.js/blob/master/docs/API.md#fine-tuning}
271
+ */
272
+ get config() {
273
+ return e(this, v).config;
274
+ }
275
+ set config(i) {
276
+ e(this, v).config = i;
277
+ }
278
+ /**
279
+ * The `hls.js` constructor (supports dynamic imports) or a URL of where it can be found.
280
+ *
281
+ * @defaultValue `https://cdn.jsdelivr.net/npm/hls.js@^1.0.0/dist/hls.min.js`
282
+ */
283
+ get library() {
284
+ return e(this, S);
285
+ }
286
+ set library(i) {
287
+ f(this, S, i);
288
+ }
289
+ preconnect() {
290
+ C(e(this, S)) && at(e(this, S));
291
+ }
292
+ setup() {
293
+ super.setup(), new Et(e(this, S), this.ctx, (i) => {
294
+ f(this, A, i), e(this, v).setup(i), this.ctx.notify("provider-setup", this);
295
+ const s = O(this.ctx.$state.source);
296
+ s && this.loadSource(s);
297
+ });
298
+ }
299
+ async loadSource(i, s) {
300
+ if (!C(i.src)) {
301
+ this.removeSource();
302
+ return;
303
+ }
304
+ this.media.preload = s || "", this.appendSource(i, "application/x-mpegurl"), e(this, v).loadSource(i), this.currentSrc = i;
305
+ }
306
+ /**
307
+ * The given callback is invoked when a new `hls.js` instance is created and right before it's
308
+ * attached to media.
309
+ */
310
+ onInstance(i) {
311
+ const s = e(this, v).instance;
312
+ return s && i(s), e(this, v).onInstance(i);
313
+ }
314
+ destroy() {
315
+ e(this, v).destroy();
316
+ }
317
+ }
318
+ A = new WeakMap(), v = new WeakMap(), S = new WeakMap(), /**
319
+ * Whether `hls.js` is supported in this environment.
320
+ */
321
+ _(xt, "supported", ht());
322
+ export {
323
+ xt as HLSProvider
324
+ };