@instructure/studio-player 1.1.15 → 1.2.1

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.
Files changed (82) hide show
  1. package/dist/{ar-DWuLBmz_.js → ar-Z9acuZzl.js} +59 -57
  2. package/dist/{ca-Qqae8qG8.js → ca-DlR1wIBB.js} +53 -51
  3. package/dist/chromecast-fcYiHsj5.js +4 -0
  4. package/dist/{cy-BpEFkqco.js → cy-Bfp7KxBK.js} +56 -54
  5. package/dist/{da-wed3aJ7h.js → da-qrZgDst-.js} +48 -46
  6. package/dist/{da-x-k12-COGvNdvr.js → da-x-k12-By8rNInq.js} +46 -44
  7. package/dist/{de-nKvELG0o.js → de-knn0V76L.js} +52 -50
  8. package/dist/dev-D3SS6qhA.js +1000 -0
  9. package/dist/{en_AU-MbaPa8_v.js → en-AU-x-unimelb-ByeXpRSQ.js} +54 -52
  10. package/dist/en-AyGO5HzS.js +133 -0
  11. package/dist/{en-GB-x-ukhe-B4JozeRC.js → en-GB-x-ukhe-xHRAKkin.js} +56 -54
  12. package/dist/{en-AU-x-unimelb-CkNBO1qD.js → en_AU-DyOGFAXY.js} +48 -46
  13. package/dist/{en_CY-Bic0boap.js → en_CY-BOdUgRsC.js} +52 -50
  14. package/dist/{en_GB-Bic0boap.js → en_GB-BgDkmLv4.js} +50 -48
  15. package/dist/errors-Bfk1GqFn.js +70 -0
  16. package/dist/{es-BcgDzQZG.js → es-CBqAZZdR.js} +54 -52
  17. package/dist/{es_ES-Dpu1hibc.js → es_ES-DLfG4pu4.js} +60 -58
  18. package/dist/{fi-BEWl8re7.js → fi-Dq0xAMjn.js} +55 -53
  19. package/dist/{fr-DiQce0QU.js → fr-CvtcW3Dj.js} +58 -56
  20. package/dist/fr_CA-ZpBdXMbh.js +133 -0
  21. package/dist/ga-83Dv-X5Z.js +133 -0
  22. package/dist/{hi-DFgKd5Rh.js → hi-xRyetvo6.js} +59 -57
  23. package/dist/ht-DA2-RKUH.js +133 -0
  24. package/dist/id-CEs1cZOo.js +133 -0
  25. package/dist/index-Bc3X9mWo.css +1 -0
  26. package/dist/{is-CTl9VBTw.js → is-BbinArrV.js} +56 -54
  27. package/dist/{it-DS73ictn.js → it-HslrRsSS.js} +58 -56
  28. package/dist/ja-D89KNqN9.js +133 -0
  29. package/dist/mi-aU_9ve5X.js +133 -0
  30. package/dist/{ms-C_fuUCcA.js → ms-bWAzRpaY.js} +52 -50
  31. package/dist/nb-M_VkURkp.js +133 -0
  32. package/dist/{nb-CrJr2akb.js → nb-x-k12-B-_bQnAo.js} +54 -52
  33. package/dist/{nl-CrynP9Ac.js → nl-DHdAiTnV.js} +56 -54
  34. package/dist/pl-1Qw2eZF3.js +133 -0
  35. package/dist/{pt-GnFuQolP.js → pt-Ck4sSJ6k.js} +52 -50
  36. package/dist/{pt_BR-Bw-U8Fma.js → pt_BR-Cx97cXwr.js} +56 -54
  37. package/dist/ru-C-htuaP4.js +133 -0
  38. package/dist/sl-CQCpGyzi.js +133 -0
  39. package/dist/srt-parser-HIGL5vQl.js +27 -0
  40. package/dist/ssa-parser-DsrjQpwb.js +209 -0
  41. package/dist/studio-player.es.js +4703 -4719
  42. package/dist/sv-e5AFl9Ar.js +133 -0
  43. package/dist/sv-x-k12-pMVzTct2.js +133 -0
  44. package/dist/{th-DY_qsUyE.js → th-D_TJAjfw.js} +63 -61
  45. package/dist/{vi-CZWY3NLh.js → vi-Cm6S7qCi.js} +53 -51
  46. package/dist/vidstack-CjqtyAQk.js +9772 -0
  47. package/dist/vidstack-audio-CkMeA4-b.js +32 -0
  48. package/dist/vidstack-dash-CMEjAqOU.js +95 -0
  49. package/dist/vidstack-google-cast-BMQWFfhs.js +313 -0
  50. package/dist/vidstack-hls-D1a98pZ4.js +95 -0
  51. package/dist/vidstack-html-CPvoK3qB.js +73 -0
  52. package/dist/vidstack-video-C_npz5Cj.js +39 -0
  53. package/dist/vidstack-vimeo-j7LNW6Re.js +426 -0
  54. package/dist/vidstack-youtube-C_ammZWO.js +264 -0
  55. package/dist/zh-DaDuLWt4.js +133 -0
  56. package/dist/zh-Hans-Bh10_Au7.js +133 -0
  57. package/dist/zh-Hant-DvNKec8H.js +133 -0
  58. package/dist/{zh-Hant-DuAgeN0L.js → zh_HK-CwSDZpFm.js} +59 -57
  59. package/package.json +4 -4
  60. package/dist/en-Da2QqQzB.js +0 -131
  61. package/dist/errors-DCJKAXTz.js +0 -70
  62. package/dist/fr_CA-zzDHXzBI.js +0 -131
  63. package/dist/ga-BnfTovup.js +0 -125
  64. package/dist/ht-DmkZypkC.js +0 -131
  65. package/dist/id-D12ot73_.js +0 -131
  66. package/dist/index-DhrDIAdb.css +0 -1
  67. package/dist/ja-B0B-sKEG.js +0 -131
  68. package/dist/mi-BX_XpUQT.js +0 -131
  69. package/dist/nb-x-k12-LqbRKYNM.js +0 -131
  70. package/dist/patches.d.ts +0 -1
  71. package/dist/pl-CBE8GSTo.js +0 -131
  72. package/dist/prod-DTLJXtPo.js +0 -994
  73. package/dist/ru-Din5Ed0v.js +0 -131
  74. package/dist/sl-DOsudmDY.js +0 -131
  75. package/dist/srt-parser-CWqahKwO.js +0 -27
  76. package/dist/ssa-parser-BqjjKy4M.js +0 -209
  77. package/dist/sv-CxnJbrMd.js +0 -131
  78. package/dist/sv-x-k12-C3MKrKJe.js +0 -131
  79. package/dist/vidstack-CpEp8jXV.js +0 -32955
  80. package/dist/zh-Cb-utrSO.js +0 -131
  81. package/dist/zh-Hans-C6EE8GVu.js +0 -131
  82. package/dist/zh_HK-BaabEC8v.js +0 -131
@@ -0,0 +1,1000 @@
1
+ var te = Object.defineProperty;
2
+ var ie = (i, e, t) => e in i ? te(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
+ var c = (i, e, t) => ie(i, typeof e != "symbol" ? e + "" : e, t);
4
+ const H = {
5
+ LoadFail: 0,
6
+ BadSignature: 1,
7
+ BadTimestamp: 2,
8
+ BadSettingValue: 3,
9
+ BadFormat: 4,
10
+ UnknownSetting: 5
11
+ };
12
+ class V extends Error {
13
+ constructor(t) {
14
+ super(t.reason);
15
+ c(this, "code");
16
+ c(this, "line");
17
+ this.code = t.code, this.line = t.line;
18
+ }
19
+ }
20
+ const G = /\r?\n|\r/gm;
21
+ class re {
22
+ constructor(e) {
23
+ c(this, "writable");
24
+ c(this, "readable");
25
+ const t = new se(e);
26
+ this.writable = new WritableStream({
27
+ write(r) {
28
+ t.transform(r);
29
+ },
30
+ close() {
31
+ t.close();
32
+ }
33
+ }), this.readable = new ReadableStream({
34
+ start(r) {
35
+ t.onLine = (n) => r.enqueue(n), t.onClose = () => r.close();
36
+ }
37
+ });
38
+ }
39
+ }
40
+ class se {
41
+ constructor(e) {
42
+ c(this, "_buffer", "");
43
+ c(this, "_decoder");
44
+ c(this, "onLine");
45
+ c(this, "onClose");
46
+ this._decoder = new TextDecoder(e);
47
+ }
48
+ transform(e) {
49
+ this._buffer += this._decoder.decode(e, { stream: !0 });
50
+ const t = this._buffer.split(G);
51
+ this._buffer = t.pop() || "";
52
+ for (let r = 0; r < t.length; r++)
53
+ this.onLine(t[r].trim());
54
+ }
55
+ close() {
56
+ this._buffer && this.onLine(this._buffer.trim()), this._buffer = "", this.onClose();
57
+ }
58
+ }
59
+ async function ne(i, e) {
60
+ const t = new ReadableStream({
61
+ start(r) {
62
+ const n = i.split(G);
63
+ for (const s of n)
64
+ r.enqueue(s);
65
+ r.close();
66
+ }
67
+ });
68
+ return C(t, e);
69
+ }
70
+ async function C(i, e) {
71
+ const t = (e == null ? void 0 : e.type) ?? "vtt";
72
+ let r;
73
+ if (typeof t == "string")
74
+ switch (t) {
75
+ case "srt":
76
+ r = (await import("./srt-parser-HIGL5vQl.js")).default;
77
+ break;
78
+ case "ssa":
79
+ case "ass":
80
+ r = (await import("./ssa-parser-DsrjQpwb.js")).default;
81
+ break;
82
+ default:
83
+ r = (await Promise.resolve().then(function() {
84
+ return Se;
85
+ })).default;
86
+ }
87
+ else
88
+ r = t;
89
+ let n;
90
+ const s = i.getReader(), o = r(), a = (e == null ? void 0 : e.errors) !== !1 || !!(e != null && e.strict) || !!(e != null && e.errors);
91
+ await o.init({
92
+ strict: !1,
93
+ ...e,
94
+ errors: a,
95
+ type: t,
96
+ cancel() {
97
+ s.cancel(), n = o.done(!0);
98
+ }
99
+ });
100
+ let l = 1;
101
+ for (; ; ) {
102
+ const { value: h, done: f } = await s.read();
103
+ if (f) {
104
+ o.parse("", l), n = o.done(!1);
105
+ break;
106
+ }
107
+ o.parse(h, l), l++;
108
+ }
109
+ return n;
110
+ }
111
+ async function ae(i, e) {
112
+ var o, a, l;
113
+ const t = await i;
114
+ if (!t.ok || !t.body) {
115
+ let h;
116
+ return h = new V({
117
+ code: H.LoadFail,
118
+ reason: t.ok ? `response body is missing (status: ${t.status})` : `response is not ok (status: ${t.status})`,
119
+ line: -1
120
+ }), (o = e == null ? void 0 : e.onError) == null || o.call(e, h), {
121
+ metadata: {},
122
+ cues: [],
123
+ regions: [],
124
+ errors: [h]
125
+ };
126
+ }
127
+ const r = t.headers.get("content-type") || "", n = (a = r.match(/text\/(.*?)(?:;|$)/)) == null ? void 0 : a[1], s = (l = r.match(/charset=(.*?)(?:;|$)/)) == null ? void 0 : l[1];
128
+ return W(t.body, { type: n, encoding: s, ...e });
129
+ }
130
+ async function W(i, { encoding: e = "utf-8", ...t } = {}) {
131
+ const r = i.pipeThrough(new re(e));
132
+ return C(r, t);
133
+ }
134
+ class X extends EventTarget {
135
+ constructor(t, r, n) {
136
+ super();
137
+ /**
138
+ * A string that identifies the cue.
139
+ *
140
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/TextTrackCue/id}
141
+ */
142
+ c(this, "id", "");
143
+ /**
144
+ * A `double` that represents the video time that the cue will start being displayed, in seconds.
145
+ *
146
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/TextTrackCue/startTime}
147
+ */
148
+ c(this, "startTime");
149
+ /**
150
+ * A `double` that represents the video time that the cue will stop being displayed, in seconds.
151
+ *
152
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/TextTrackCue/endTime}
153
+ */
154
+ c(this, "endTime");
155
+ /**
156
+ * Returns a string with the contents of the cue.
157
+ *
158
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/VTTCue/text}
159
+ */
160
+ c(this, "text");
161
+ /**
162
+ * A `boolean` for whether the video will pause when this cue stops being displayed.
163
+ *
164
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/TextTrackCue/pauseOnExit}
165
+ */
166
+ c(this, "pauseOnExit", !1);
167
+ this.startTime = t, this.endTime = r, this.text = n;
168
+ }
169
+ addEventListener(t, r, n) {
170
+ super.addEventListener(t, r, n);
171
+ }
172
+ removeEventListener(t, r, n) {
173
+ super.removeEventListener(t, r, n);
174
+ }
175
+ }
176
+ const N = typeof document > "u", oe = N ? X : window.VTTCue;
177
+ class F extends oe {
178
+ constructor() {
179
+ super(...arguments);
180
+ /**
181
+ * A `VTTRegion` object describing the video's sub-region that the cue will be drawn onto,
182
+ * or `null` if none is assigned.
183
+ *
184
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/VTTCue/region}
185
+ */
186
+ c(this, "region", null);
187
+ /**
188
+ * The cue writing direction.
189
+ *
190
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/VTTCue/vertical}
191
+ */
192
+ c(this, "vertical", "");
193
+ /**
194
+ * Returns `true` if the `VTTCue.line` attribute is an integer number of lines or a percentage
195
+ * of the video size.
196
+ *
197
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/VTTCue/snapToLines}
198
+ */
199
+ c(this, "snapToLines", !0);
200
+ /**
201
+ * Returns the line positioning of the cue. This can be the string `'auto'` or a number whose
202
+ * interpretation depends on the value of `VTTCue.snapToLines`.
203
+ *
204
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/VTTCue/line}
205
+ */
206
+ c(this, "line", "auto");
207
+ /**
208
+ * Returns an enum representing the alignment of the `VTTCue.line`.
209
+ *
210
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/VTTCue/lineAlign}
211
+ */
212
+ c(this, "lineAlign", "start");
213
+ /**
214
+ * Returns the indentation of the cue within the line. This can be the string `'auto'` or a
215
+ * number representing the percentage of the `VTTCue.region`, or the video size if `VTTCue`.region`
216
+ * is `null`.
217
+ *
218
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/VTTCue/position}
219
+ */
220
+ c(this, "position", "auto");
221
+ /**
222
+ * Returns an enum representing the alignment of the cue. This is used to determine what
223
+ * the `VTTCue.position` is anchored to. The default is `'auto'`.
224
+ *
225
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/VTTCue/positionAlign}
226
+ */
227
+ c(this, "positionAlign", "auto");
228
+ /**
229
+ * Returns a double representing the size of the cue, as a percentage of the video size.
230
+ *
231
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/VTTCue/size}
232
+ */
233
+ c(this, "size", 100);
234
+ /**
235
+ * Returns an enum representing the alignment of all the lines of text within the cue box.
236
+ *
237
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/VTTCue/align}
238
+ */
239
+ c(this, "align", "center");
240
+ /**
241
+ * Additional styles associated with the cue.
242
+ */
243
+ c(this, "style");
244
+ }
245
+ }
246
+ class j {
247
+ constructor() {
248
+ /**
249
+ * A string that identifies the region.
250
+ */
251
+ c(this, "id", "");
252
+ /**
253
+ * A `double` representing the width of the region, as a percentage of the video.
254
+ */
255
+ c(this, "width", 100);
256
+ /**
257
+ * A `double` representing the height of the region, in number of lines.
258
+ */
259
+ c(this, "lines", 3);
260
+ /**
261
+ * A `double` representing the region anchor X offset, as a percentage of the region.
262
+ */
263
+ c(this, "regionAnchorX", 0);
264
+ /**
265
+ * A `double` representing the region anchor Y offset, as a percentage of the region.
266
+ */
267
+ c(this, "regionAnchorY", 100);
268
+ /**
269
+ * A `double` representing the viewport anchor X offset, as a percentage of the video.
270
+ */
271
+ c(this, "viewportAnchorX", 0);
272
+ /**
273
+ * A `double` representing the viewport anchor Y offset, as a percentage of the video.
274
+ */
275
+ c(this, "viewportAnchorY", 100);
276
+ /**
277
+ * An enum representing how adding new cues will move existing cues.
278
+ */
279
+ c(this, "scroll", "");
280
+ }
281
+ }
282
+ const P = ",", le = "%";
283
+ function ce(i) {
284
+ const e = parseInt(i, 10);
285
+ return Number.isNaN(e) ? null : e;
286
+ }
287
+ function w(i) {
288
+ const e = parseInt(i.replace(le, ""), 10);
289
+ return !Number.isNaN(e) && e >= 0 && e <= 100 ? e : null;
290
+ }
291
+ function M(i) {
292
+ if (!i.includes(P))
293
+ return null;
294
+ const [e, t] = i.split(P).map(w);
295
+ return e !== null && t !== null ? [e, t] : null;
296
+ }
297
+ function he(i) {
298
+ const e = parseFloat(i);
299
+ return Number.isNaN(e) ? null : e;
300
+ }
301
+ const ue = "WEBVTT", z = ",", fe = "%", T = /[:=]/, de = /^[\s\t]*(region|vertical|line|position|size|align)[:=]/, _e = "NOTE", ge = "REGION", me = /^REGION:?[\s\t]+/, v = /[\s\t]+/, pe = "-->", Te = /[\s\t]*-->[\s\t]+/, be = /start|center|end|left|right/, ve = /start|center|end/, we = /line-(?:left|right)|center|auto/, ye = /^(?:(\d{1,2}):)?(\d{2}):(\d{2})(?:\.(\d{1,3}))?$/;
302
+ var Y = /* @__PURE__ */ ((i) => (i[i.None = 0] = "None", i[i.Header = 1] = "Header", i[i.Cue = 2] = "Cue", i[i.Region = 3] = "Region", i[i.Note = 4] = "Note", i))(Y || {});
303
+ class q {
304
+ constructor() {
305
+ c(this, "_init");
306
+ c(this, "_block", 0);
307
+ c(this, "_metadata", {});
308
+ c(this, "_regions", {});
309
+ c(this, "_cues", []);
310
+ c(this, "_cue", null);
311
+ c(this, "_region", null);
312
+ c(this, "_errors", []);
313
+ c(this, "_errorBuilder");
314
+ c(this, "_prevLine", "");
315
+ }
316
+ async init(e) {
317
+ this._init = e, e.strict && (this._block = 1), e.errors && (this._errorBuilder = (await import("./errors-Bfk1GqFn.js")).ParseErrorBuilder);
318
+ }
319
+ parse(e, t) {
320
+ var r, n, s, o, a, l;
321
+ if (e === "")
322
+ this._cue ? (this._cues.push(this._cue), (n = (r = this._init).onCue) == null || n.call(r, this._cue), this._cue = null) : this._region ? (this._regions[this._region.id] = this._region, (o = (s = this._init).onRegion) == null || o.call(s, this._region), this._region = null) : this._block === 1 && (this._parseHeader(e, t), (l = (a = this._init).onHeaderMetadata) == null || l.call(a, this._metadata)), this._block = 0;
323
+ else if (this._block)
324
+ switch (this._block) {
325
+ case 1:
326
+ this._parseHeader(e, t);
327
+ break;
328
+ case 2:
329
+ if (this._cue) {
330
+ const h = this._cue.text.length > 0;
331
+ !h && de.test(e) ? this._parseCueSettings(e.split(v), t) : this._cue.text += (h ? `
332
+ ` : "") + e;
333
+ }
334
+ break;
335
+ case 3:
336
+ this._parseRegionSettings(e.split(v), t);
337
+ break;
338
+ }
339
+ else if (e.startsWith(_e))
340
+ this._block = 4;
341
+ else if (e.startsWith(ge))
342
+ this._block = 3, this._region = new j(), this._parseRegionSettings(e.replace(me, "").split(v), t);
343
+ else if (e.includes(pe)) {
344
+ const h = this._parseTimestamp(e, t);
345
+ h && (this._cue = new F(h[0], h[1], ""), this._cue.id = this._prevLine, this._parseCueSettings(h[2], t)), this._block = 2;
346
+ } else t === 1 && this._parseHeader(e, t);
347
+ this._prevLine = e;
348
+ }
349
+ done() {
350
+ return {
351
+ metadata: this._metadata,
352
+ cues: this._cues,
353
+ regions: Object.values(this._regions),
354
+ errors: this._errors
355
+ };
356
+ }
357
+ _parseHeader(e, t) {
358
+ var r;
359
+ if (t > 1) {
360
+ if (T.test(e)) {
361
+ const [n, s] = e.split(T);
362
+ n && (this._metadata[n] = (s || "").replace(v, ""));
363
+ }
364
+ } else e.startsWith(ue) ? this._block = 1 : this._handleError((r = this._errorBuilder) == null ? void 0 : r._badVTTHeader());
365
+ }
366
+ _parseTimestamp(e, t) {
367
+ var h, f, u;
368
+ const [r, n = ""] = e.split(Te), [s, ...o] = n.split(v), a = E(r), l = E(s);
369
+ if (a !== null && l !== null && l > a)
370
+ return [a, l, o];
371
+ a === null && this._handleError((h = this._errorBuilder) == null ? void 0 : h._badStartTimestamp(r, t)), l === null && this._handleError((f = this._errorBuilder) == null ? void 0 : f._badEndTimestamp(s, t)), a != null && l !== null && l > a && this._handleError((u = this._errorBuilder) == null ? void 0 : u._badRangeTimestamp(a, l, t));
372
+ }
373
+ /**
374
+ * @see {@link https://www.w3.org/TR/webvtt1/#region-settings-parsing}
375
+ */
376
+ _parseRegionSettings(e, t) {
377
+ var n, s;
378
+ let r;
379
+ for (let o = 0; o < e.length; o++)
380
+ if (T.test(e[o])) {
381
+ r = !1;
382
+ const [a, l] = e[o].split(T);
383
+ switch (a) {
384
+ case "id":
385
+ this._region.id = l;
386
+ break;
387
+ case "width":
388
+ const h = w(l);
389
+ h !== null ? this._region.width = h : r = !0;
390
+ break;
391
+ case "lines":
392
+ const f = ce(l);
393
+ f !== null ? this._region.lines = f : r = !0;
394
+ break;
395
+ case "regionanchor":
396
+ const u = M(l);
397
+ u !== null ? (this._region.regionAnchorX = u[0], this._region.regionAnchorY = u[1]) : r = !0;
398
+ break;
399
+ case "viewportanchor":
400
+ const d = M(l);
401
+ d !== null ? (this._region.viewportAnchorX = d[0], this._region.viewportAnchorY = d[1]) : r = !0;
402
+ break;
403
+ case "scroll":
404
+ l === "up" ? this._region.scroll = "up" : r = !0;
405
+ break;
406
+ default:
407
+ this._handleError((n = this._errorBuilder) == null ? void 0 : n._unknownRegionSetting(a, l, t));
408
+ }
409
+ r && this._handleError((s = this._errorBuilder) == null ? void 0 : s._badRegionSetting(a, l, t));
410
+ }
411
+ }
412
+ /**
413
+ * @see {@link https://www.w3.org/TR/webvtt1/#cue-timings-and-settings-parsing}
414
+ */
415
+ _parseCueSettings(e, t) {
416
+ var n, s;
417
+ let r;
418
+ for (let o = 0; o < e.length; o++)
419
+ if (r = !1, T.test(e[o])) {
420
+ const [a, l] = e[o].split(T);
421
+ switch (a) {
422
+ case "region":
423
+ const h = this._regions[l];
424
+ h && (this._cue.region = h);
425
+ break;
426
+ case "vertical":
427
+ l === "lr" || l === "rl" ? (this._cue.vertical = l, this._cue.region = null) : r = !0;
428
+ break;
429
+ case "line":
430
+ const [f, u] = l.split(z);
431
+ if (f.includes(fe)) {
432
+ const b = w(f);
433
+ b !== null ? (this._cue.line = b, this._cue.snapToLines = !1) : r = !0;
434
+ } else {
435
+ const b = he(f);
436
+ b !== null ? this._cue.line = b : r = !0;
437
+ }
438
+ ve.test(u) ? this._cue.lineAlign = u : u && (r = !0), this._cue.line !== "auto" && (this._cue.region = null);
439
+ break;
440
+ case "position":
441
+ const [d, g] = l.split(z), B = w(d);
442
+ B !== null ? this._cue.position = B : r = !0, g && we.test(g) ? this._cue.positionAlign = g : g && (r = !0);
443
+ break;
444
+ case "size":
445
+ const A = w(l);
446
+ A !== null ? (this._cue.size = A, A < 100 && (this._cue.region = null)) : r = !0;
447
+ break;
448
+ case "align":
449
+ be.test(l) ? this._cue.align = l : r = !0;
450
+ break;
451
+ default:
452
+ this._handleError((n = this._errorBuilder) == null ? void 0 : n._unknownCueSetting(a, l, t));
453
+ }
454
+ r && this._handleError((s = this._errorBuilder) == null ? void 0 : s._badCueSetting(a, l, t));
455
+ }
456
+ }
457
+ _handleError(e) {
458
+ var t, r;
459
+ if (e) {
460
+ if (this._errors.push(e), this._init.strict)
461
+ throw this._init.cancel(), e;
462
+ (r = (t = this._init).onError) == null || r.call(t, e);
463
+ }
464
+ }
465
+ }
466
+ function E(i) {
467
+ const e = i.match(ye);
468
+ if (!e)
469
+ return null;
470
+ const t = e[1] ? parseInt(e[1], 10) : 0, r = parseInt(e[2], 10), n = parseInt(e[3], 10), s = e[4] ? parseInt(e[4].padEnd(3, "0"), 10) : 0, o = t * 3600 + r * 60 + n + s / 1e3;
471
+ return t < 0 || r < 0 || n < 0 || s < 0 || r > 59 || n > 59 ? null : o;
472
+ }
473
+ function Ee() {
474
+ return new q();
475
+ }
476
+ var Se = /* @__PURE__ */ Object.freeze({
477
+ __proto__: null,
478
+ VTTBlock: Y,
479
+ VTTParser: q,
480
+ default: Ee,
481
+ parseVTTTimestamp: E
482
+ });
483
+ const Re = /[0-9]/, Ae = /[\s\t]+/, D = {
484
+ c: "span",
485
+ i: "i",
486
+ b: "b",
487
+ u: "u",
488
+ ruby: "ruby",
489
+ rt: "rt",
490
+ v: "span",
491
+ lang: "span",
492
+ timestamp: "span"
493
+ }, ke = {
494
+ "&amp;": "&",
495
+ "&lt;": "<",
496
+ "&gt;": ">",
497
+ "&quot;": '"',
498
+ "&#39;": "'",
499
+ "&nbsp;": " ",
500
+ "&lrm;": "‎",
501
+ "&rlm;": "‏"
502
+ }, Ce = /&(?:amp|lt|gt|quot|#(0+)?39|nbsp|lrm|rlm);/g, Ne = /* @__PURE__ */ new Set([
503
+ "white",
504
+ "lime",
505
+ "cyan",
506
+ "red",
507
+ "yellow",
508
+ "magenta",
509
+ "blue",
510
+ "black"
511
+ ]), Ie = /* @__PURE__ */ new Set(Object.keys(D));
512
+ function K(i) {
513
+ var h, f;
514
+ let e = "", t = 1, r = [], n = [], s;
515
+ for (let u = 0; u < i.text.length; u++) {
516
+ const d = i.text[u];
517
+ switch (t) {
518
+ case 1:
519
+ d === "<" ? (l(), t = 2) : e += d;
520
+ break;
521
+ case 2:
522
+ switch (d) {
523
+ case `
524
+ `:
525
+ case " ":
526
+ case " ":
527
+ o(), t = 4;
528
+ break;
529
+ case ".":
530
+ o(), t = 3;
531
+ break;
532
+ case "/":
533
+ t = 5;
534
+ break;
535
+ case ">":
536
+ o(), t = 1;
537
+ break;
538
+ default:
539
+ !e && Re.test(d) && (t = 6), e += d;
540
+ break;
541
+ }
542
+ break;
543
+ case 3:
544
+ switch (d) {
545
+ case " ":
546
+ case " ":
547
+ case `
548
+ `:
549
+ a(), s && ((h = s.class) == null || h.trim()), t = 4;
550
+ break;
551
+ case ".":
552
+ a();
553
+ break;
554
+ case ">":
555
+ a(), s && ((f = s.class) == null || f.trim()), t = 1;
556
+ break;
557
+ default:
558
+ e += d;
559
+ }
560
+ break;
561
+ case 4:
562
+ d === ">" ? (e = e.replace(Ae, " "), (s == null ? void 0 : s.type) === "v" ? s.voice = k(e) : (s == null ? void 0 : s.type) === "lang" && (s.lang = k(e)), e = "", t = 1) : e += d;
563
+ break;
564
+ case 5:
565
+ d === ">" && (e = "", s = n.pop(), t = 1);
566
+ break;
567
+ case 6:
568
+ if (d === ">") {
569
+ const g = E(e);
570
+ g !== null && g >= i.startTime && g <= i.endTime && (e = "timestamp", o(), s.time = g), e = "", t = 1;
571
+ } else
572
+ e += d;
573
+ break;
574
+ }
575
+ }
576
+ function o() {
577
+ if (Ie.has(e)) {
578
+ const u = s;
579
+ s = Oe(e), u ? (n[n.length - 1] !== u && n.push(u), u.children.push(s)) : r.push(s);
580
+ }
581
+ e = "", t = 1;
582
+ }
583
+ function a() {
584
+ if (s && e) {
585
+ const u = e.replace("bg_", "");
586
+ Ne.has(u) ? s[e.startsWith("bg_") ? "bgColor" : "color"] = u : s.class = s.class ? s.class + " " + e : e;
587
+ }
588
+ e = "";
589
+ }
590
+ function l() {
591
+ if (!e)
592
+ return;
593
+ const u = { type: "text", data: k(e) };
594
+ s ? s.children.push(u) : r.push(u), e = "";
595
+ }
596
+ return t === 1 && l(), r;
597
+ }
598
+ function Oe(i) {
599
+ return {
600
+ tagName: D[i],
601
+ type: i,
602
+ children: []
603
+ };
604
+ }
605
+ function k(i) {
606
+ return i.replace(Ce, (e) => ke[e] || "'");
607
+ }
608
+ function _(i, e, t) {
609
+ i.style.setProperty(`--${e}`, t + "");
610
+ }
611
+ function m(i, e, t = !0) {
612
+ i.setAttribute(`data-${e}`, t === !0 ? "" : t + "");
613
+ }
614
+ function S(i, e) {
615
+ i.setAttribute("data-part", e);
616
+ }
617
+ function Le(i) {
618
+ return parseFloat(getComputedStyle(i).lineHeight) || 0;
619
+ }
620
+ function xe(i) {
621
+ if (N)
622
+ throw Error(
623
+ "[media-captions] called `createVTTCueTemplate` on the server - use `renderVTTCueString`"
624
+ );
625
+ const e = document.createElement("template");
626
+ return e.innerHTML = I(i), { cue: i, content: e.content };
627
+ }
628
+ function I(i, e = 0) {
629
+ return O(K(i), e);
630
+ }
631
+ function O(i, e = 0) {
632
+ let t, r = "";
633
+ for (const n of i)
634
+ if (n.type === "text")
635
+ r += n.data;
636
+ else {
637
+ const s = n.type === "timestamp";
638
+ t = {}, t.class = n.class, t.title = n.type === "v" && n.voice, t.lang = n.type === "lang" && n.lang, t["data-part"] = n.type === "v" && "voice", s && (t["data-part"] = "timed", t["data-time"] = n.time, t["data-future"] = n.time > e, t["data-past"] = n.time < e), t.style = `${n.color ? `color: ${n.color};` : ""}${n.bgColor ? `background-color: ${n.bgColor};` : ""}`;
639
+ const o = Object.entries(t).filter((a) => a[1]).map((a) => `${a[0]}="${a[1] === !0 ? "" : a[1]}"`).join(" ");
640
+ r += `<${n.tagName}${o ? " " + o : ""}>${O(
641
+ n.children
642
+ )}</${n.tagName}>`;
643
+ }
644
+ return r;
645
+ }
646
+ function J(i, e) {
647
+ if (!N)
648
+ for (const t of i.querySelectorAll('[data-part="timed"]')) {
649
+ const r = Number(t.getAttribute("data-time"));
650
+ Number.isNaN(r) || (r > e ? m(t, "future") : t.removeAttribute("data-future"), r < e ? m(t, "past") : t.removeAttribute("data-past"));
651
+ }
652
+ }
653
+ function Be(i, e) {
654
+ let t = null, r;
655
+ function n() {
656
+ s(), i(...r), r = void 0;
657
+ }
658
+ function s() {
659
+ clearTimeout(t), t = null;
660
+ }
661
+ function o() {
662
+ r = [].slice.call(arguments), s(), t = setTimeout(n, e);
663
+ }
664
+ return o;
665
+ }
666
+ const p = Symbol("STARTING_BOX");
667
+ function L(i) {
668
+ return i instanceof HTMLElement ? {
669
+ top: i.offsetTop,
670
+ width: i.clientWidth,
671
+ height: i.clientHeight,
672
+ left: i.offsetLeft,
673
+ right: i.offsetLeft + i.clientWidth,
674
+ bottom: i.offsetTop + i.clientHeight
675
+ } : { ...i };
676
+ }
677
+ function R(i, e, t) {
678
+ switch (e) {
679
+ case "+x":
680
+ i.left += t, i.right += t;
681
+ break;
682
+ case "-x":
683
+ i.left -= t, i.right -= t;
684
+ break;
685
+ case "+y":
686
+ i.top += t, i.bottom += t;
687
+ break;
688
+ case "-y":
689
+ i.top -= t, i.bottom -= t;
690
+ break;
691
+ }
692
+ }
693
+ function Pe(i, e) {
694
+ return i.left <= e.right && i.right >= e.left && i.top <= e.bottom && i.bottom >= e.top;
695
+ }
696
+ function Me(i, e) {
697
+ for (let t = 0; t < e.length; t++)
698
+ if (Pe(i, e[t]))
699
+ return e[t];
700
+ return null;
701
+ }
702
+ function $(i, e) {
703
+ return e.top >= 0 && e.bottom <= i.height && e.left >= 0 && e.right <= i.width;
704
+ }
705
+ function ze(i, e, t) {
706
+ switch (t) {
707
+ case "+x":
708
+ return e.left < 0;
709
+ case "-x":
710
+ return e.right > i.width;
711
+ case "+y":
712
+ return e.top < 0;
713
+ case "-y":
714
+ return e.bottom > i.height;
715
+ }
716
+ }
717
+ function $e(i, e) {
718
+ const t = Math.max(0, Math.min(i.width, e.right) - Math.max(0, e.left)), r = Math.max(0, Math.min(i.height, e.bottom) - Math.max(0, e.top));
719
+ return t * r / (i.height * i.width);
720
+ }
721
+ function x(i, e) {
722
+ return {
723
+ top: e.top / i.height,
724
+ left: e.left / i.width,
725
+ right: (i.width - e.right) / i.width,
726
+ bottom: (i.height - e.bottom) / i.height
727
+ };
728
+ }
729
+ function Q(i, e) {
730
+ return e.top = e.top * i.height, e.left = e.left * i.width, e.right = i.width - e.right * i.width, e.bottom = i.height - e.bottom * i.height, e;
731
+ }
732
+ const Z = ["top", "left", "right", "bottom"];
733
+ function U(i, e, t, r) {
734
+ const n = x(e, t);
735
+ for (const s of Z)
736
+ _(i, `${r}-${s}`, n[s] * 100 + "%");
737
+ }
738
+ function ee(i, e, t, r) {
739
+ let n = 1, s, o = { ...e };
740
+ for (let a = 0; a < r.length; a++) {
741
+ for (; ze(i, e, r[a]) || $(i, e) && Me(e, t); )
742
+ R(e, r[a], 1);
743
+ if ($(i, e))
744
+ return e;
745
+ const l = $e(i, e);
746
+ n > l && (s = { ...e }, n = l), e = { ...o };
747
+ }
748
+ return s || o;
749
+ }
750
+ const y = Symbol("POSITION_OVERRIDE");
751
+ function He(i, e, t, r) {
752
+ let n = t.firstElementChild, s = We(e), o, a = [];
753
+ if (t[p] || (t[p] = Ve(i, t)), o = Q(i, { ...t[p] }), t[y])
754
+ a = [t[y] === "top" ? "+y" : "-y", "+x", "-x"];
755
+ else if (e.snapToLines) {
756
+ let l;
757
+ switch (e.vertical) {
758
+ case "":
759
+ a = ["+y", "-y"], l = "height";
760
+ break;
761
+ case "rl":
762
+ a = ["+x", "-x"], l = "width";
763
+ break;
764
+ case "lr":
765
+ a = ["-x", "+x"], l = "width";
766
+ break;
767
+ }
768
+ let h = Le(n), f = h * Math.round(s), u = i[l] + h, d = a[0];
769
+ Math.abs(f) > u && (f = f < 0 ? -1 : 1, f *= Math.ceil(u / h) * h), s < 0 && (f += e.vertical === "" ? i.height : i.width, a = a.reverse()), R(o, d, f);
770
+ } else {
771
+ const l = e.vertical === "", h = l ? "+y" : "+x", f = l ? o.height : o.width;
772
+ R(
773
+ o,
774
+ h,
775
+ (l ? i.height : i.width) * s / 100
776
+ ), R(
777
+ o,
778
+ h,
779
+ e.lineAlign === "center" ? f / 2 : e.lineAlign === "end" ? f : 0
780
+ ), a = l ? ["-y", "+y", "-x", "+x"] : ["-x", "+x", "-y", "+y"];
781
+ }
782
+ return o = ee(i, o, r, a), U(t, i, o, "cue"), o;
783
+ }
784
+ function Ve(i, e) {
785
+ const t = L(e), r = Ge(e);
786
+ if (e[y] = !1, r.top && (t.top = r.top, t.bottom = r.top + t.height, e[y] = "top"), r.bottom) {
787
+ const n = i.height - r.bottom;
788
+ t.top = n - t.height, t.bottom = n, e[y] = "bottom";
789
+ }
790
+ return r.left && (t.left = r.left), r.right && (t.right = i.width - r.right), x(i, t);
791
+ }
792
+ function Ge(i) {
793
+ const e = {};
794
+ for (const t of Z)
795
+ e[t] = parseFloat(i.style.getPropertyValue(`--cue-${t}`));
796
+ return e;
797
+ }
798
+ function We(i) {
799
+ return i.line === "auto" ? i.snapToLines ? -1 : 100 : i.line;
800
+ }
801
+ function Xe(i) {
802
+ if (i.position === "auto")
803
+ switch (i.align) {
804
+ case "start":
805
+ case "left":
806
+ return 0;
807
+ case "right":
808
+ case "end":
809
+ return 100;
810
+ default:
811
+ return 50;
812
+ }
813
+ return i.position;
814
+ }
815
+ function Fe(i, e) {
816
+ if (i.positionAlign === "auto")
817
+ switch (i.align) {
818
+ case "start":
819
+ return e === "ltr" ? "line-left" : "line-right";
820
+ case "end":
821
+ return e === "ltr" ? "line-right" : "line-left";
822
+ case "center":
823
+ return "center";
824
+ default:
825
+ return `line-${i.align}`;
826
+ }
827
+ return i.positionAlign;
828
+ }
829
+ const je = ["-y", "+y", "-x", "+x"];
830
+ function Ye(i, e, t, r) {
831
+ let n = Array.from(t.querySelectorAll('[data-part="cue-display"]')), s = 0, o = Math.max(0, n.length - e.lines);
832
+ for (let l = n.length - 1; l >= o; l--)
833
+ s += n[l].offsetHeight;
834
+ _(t, "region-height", s + "px"), t[p] || (t[p] = x(i, L(t)));
835
+ let a = { ...t[p] };
836
+ return a = Q(i, a), a.width = t.clientWidth, a.height = s, a.right = a.left + a.width, a.bottom = a.top + s, a = ee(i, a, r, je), U(t, i, a, "region"), a;
837
+ }
838
+ class qe {
839
+ constructor(e, t) {
840
+ c(this, "overlay");
841
+ c(this, "_overlayBox");
842
+ c(this, "_currentTime", 0);
843
+ c(this, "_dir", "ltr");
844
+ c(this, "_activeCues", []);
845
+ c(this, "_isResizing", !1);
846
+ c(this, "_resizeObserver");
847
+ c(this, "_regions", /* @__PURE__ */ new Map());
848
+ c(this, "_cues", /* @__PURE__ */ new Map());
849
+ c(this, "_resize", Be(() => {
850
+ this._isResizing = !1, this._updateOverlay();
851
+ for (const e of this._regions.values())
852
+ e[p] = null;
853
+ for (const e of this._cues.values())
854
+ e && (e[p] = null);
855
+ this._render(!0);
856
+ }, 50));
857
+ this.overlay = e, this.dir = (t == null ? void 0 : t.dir) ?? "ltr", e.setAttribute("translate", "yes"), e.setAttribute("aria-live", "off"), e.setAttribute("aria-atomic", "true"), S(e, "captions"), this._updateOverlay(), this._resizeObserver = new ResizeObserver(this._resizing.bind(this)), this._resizeObserver.observe(e);
858
+ }
859
+ /* Text direction. */
860
+ get dir() {
861
+ return this._dir;
862
+ }
863
+ set dir(e) {
864
+ this._dir = e, m(this.overlay, "dir", e);
865
+ }
866
+ get currentTime() {
867
+ return this._currentTime;
868
+ }
869
+ set currentTime(e) {
870
+ this._currentTime = e, this.update();
871
+ }
872
+ changeTrack({ regions: e, cues: t }) {
873
+ this.reset(), this._buildRegions(e);
874
+ for (const r of t)
875
+ this._cues.set(r, null);
876
+ this.update();
877
+ }
878
+ addCue(e) {
879
+ this._cues.set(e, null), this.update();
880
+ }
881
+ removeCue(e) {
882
+ this._cues.delete(e), this.update();
883
+ }
884
+ update(e = !1) {
885
+ this._render(e);
886
+ }
887
+ reset() {
888
+ this._cues.clear(), this._regions.clear(), this._activeCues = [], this.overlay.textContent = "";
889
+ }
890
+ destroy() {
891
+ this.reset(), this._resizeObserver.disconnect();
892
+ }
893
+ _resizing() {
894
+ this._isResizing = !0, this._resize();
895
+ }
896
+ _updateOverlay() {
897
+ this._overlayBox = L(this.overlay), _(this.overlay, "overlay-width", this._overlayBox.width + "px"), _(this.overlay, "overlay-height", this._overlayBox.height + "px");
898
+ }
899
+ _render(e = !1) {
900
+ if (!this._cues.size || this._isResizing)
901
+ return;
902
+ let t, r = [...this._cues.keys()].filter((s) => this._currentTime >= s.startTime && this._currentTime <= s.endTime).sort(
903
+ (s, o) => s.startTime !== o.startTime ? s.startTime - o.startTime : s.endTime - o.endTime
904
+ ), n = r.map((s) => s.region);
905
+ for (let s = 0; s < this._activeCues.length; s++) {
906
+ if (t = this._activeCues[s], r[s] === t)
907
+ continue;
908
+ if (t.region && !n.includes(t.region)) {
909
+ const a = this._regions.get(t.region.id);
910
+ a && (a.removeAttribute("data-active"), e = !0);
911
+ }
912
+ const o = this._cues.get(t);
913
+ o && (o.remove(), e = !0);
914
+ }
915
+ for (let s = 0; s < r.length; s++) {
916
+ t = r[s];
917
+ let o = this._cues.get(t);
918
+ o || this._cues.set(t, o = this._createCueElement(t));
919
+ const a = this._hasRegion(t) && this._regions.get(t.region.id);
920
+ a && !a.hasAttribute("data-active") && (requestAnimationFrame(() => m(a, "active")), e = !0), o.isConnected || ((a || this.overlay).append(o), e = !0);
921
+ }
922
+ if (e) {
923
+ const s = [], o = /* @__PURE__ */ new Set();
924
+ for (let a = r.length - 1; a >= 0; a--) {
925
+ if (t = r[a], o.has(t.region || t))
926
+ continue;
927
+ const l = this._hasRegion(t), h = l ? this._regions.get(t.region.id) : this._cues.get(t);
928
+ l ? s.push(Ye(this._overlayBox, t.region, h, s)) : s.push(He(this._overlayBox, t, h, s)), o.add(l ? t.region : t);
929
+ }
930
+ }
931
+ J(this.overlay, this._currentTime), this._activeCues = r;
932
+ }
933
+ _buildRegions(e) {
934
+ if (e)
935
+ for (const t of e) {
936
+ const r = this._createRegionElement(t);
937
+ this._regions.set(t.id, r), this.overlay.append(r);
938
+ }
939
+ }
940
+ _createRegionElement(e) {
941
+ const t = document.createElement("div");
942
+ return S(t, "region"), m(t, "id", e.id), m(t, "scroll", e.scroll), _(t, "region-width", e.width + "%"), _(t, "region-anchor-x", e.regionAnchorX), _(t, "region-anchor-y", e.regionAnchorY), _(t, "region-viewport-anchor-x", e.viewportAnchorX), _(t, "region-viewport-anchor-y", e.viewportAnchorY), _(t, "region-lines", e.lines), t;
943
+ }
944
+ _createCueElement(e) {
945
+ var o;
946
+ const t = document.createElement("div"), r = Xe(e), n = Fe(e, this._dir);
947
+ if (S(t, "cue-display"), e.vertical !== "" && m(t, "vertical"), _(t, "cue-text-align", e.align), e.style)
948
+ for (const a of Object.keys(e.style))
949
+ t.style.setProperty(a, e.style[a]);
950
+ if (this._hasRegion(e))
951
+ _(
952
+ t,
953
+ "cue-offset",
954
+ `${r - (n === "line-right" ? 100 : n === "center" ? 50 : 0)}%`
955
+ );
956
+ else if (_(
957
+ t,
958
+ "cue-writing-mode",
959
+ e.vertical === "" ? "horizontal-tb" : e.vertical === "lr" ? "vertical-lr" : "vertical-rl"
960
+ ), !((o = e.style) != null && o["--cue-width"])) {
961
+ let a = r;
962
+ n === "line-left" ? a = 100 - r : n === "center" && r <= 50 ? a = r * 2 : n === "center" && r > 50 && (a = (100 - r) * 2);
963
+ const l = e.size < a ? e.size : a;
964
+ e.vertical === "" ? _(t, "cue-width", l + "%") : _(t, "cue-height", l + "%");
965
+ }
966
+ const s = document.createElement("div");
967
+ return S(s, "cue"), e.id && m(s, "id", e.id), s.innerHTML = I(e), t.append(s), t;
968
+ }
969
+ _hasRegion(e) {
970
+ return e.region && e.size === 100 && e.vertical === "" && e.line === "auto";
971
+ }
972
+ }
973
+ const Ke = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
974
+ __proto__: null,
975
+ CaptionsRenderer: qe,
976
+ ParseError: V,
977
+ ParseErrorCode: H,
978
+ TextCue: X,
979
+ VTTCue: F,
980
+ VTTRegion: j,
981
+ createVTTCueTemplate: xe,
982
+ parseByteStream: W,
983
+ parseResponse: ae,
984
+ parseText: ne,
985
+ parseTextStream: C,
986
+ parseVTTTimestamp: E,
987
+ renderVTTCueString: I,
988
+ renderVTTTokensString: O,
989
+ tokenizeVTTCue: K,
990
+ updateTimedVTTCueNodes: J
991
+ }, Symbol.toStringTag, { value: "Module" }));
992
+ export {
993
+ V as P,
994
+ q as V,
995
+ Y as a,
996
+ F as b,
997
+ H as c,
998
+ Ke as d,
999
+ E as p
1000
+ };