libaribhtml5 0.1.8 → 0.1.10

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.
@@ -39,35 +39,35 @@ function uq(A) {
39
39
  A.__ARIB_HTML5_ROMSOUND__ = !0;
40
40
  const q = A.HTMLMediaElement?.prototype, e = A.Element?.prototype;
41
41
  if (!q || !e) return;
42
- const t = cq(A.navigator), i = (l) => R(l) ?? String(l), r = (l) => l instanceof A.HTMLMediaElement || !!(A.HTMLSourceElement && l instanceof A.HTMLSourceElement), n = "data-arib-romsound", o = e.getAttribute, c = e.setAttribute, V = e.removeAttribute, y = (l) => o.call(l, n), E = (l, d) => {
42
+ const t = cq(A.navigator), i = (c) => R(c) ?? String(c), r = (c) => c instanceof A.HTMLMediaElement || !!(A.HTMLSourceElement && c instanceof A.HTMLSourceElement), a = "data-arib-romsound", n = e.getAttribute, l = e.setAttribute, s = e.removeAttribute, y = (c) => n.call(c, a), E = (c, d) => {
43
43
  const u = String(d), B = R(u);
44
- return B ? c.call(l, n, u) : V.call(l, n), B ?? u;
45
- }, f = (l, d) => !t || !R(d) ? !1 : (E(l, d), V.call(l, "src"), !0);
46
- e.getAttribute = function(l) {
47
- if (l.toLowerCase() === "src" && r(this)) {
44
+ return B ? l.call(c, a, u) : s.call(c, a), B ?? u;
45
+ }, f = (c, d) => !t || !R(d) ? !1 : (E(c, d), s.call(c, "src"), !0);
46
+ e.getAttribute = function(c) {
47
+ if (c.toLowerCase() === "src" && r(this)) {
48
48
  const d = y(this);
49
49
  if (d !== null) return d;
50
50
  }
51
- return o.call(this, l);
52
- }, e.setAttribute = function(l, d) {
53
- if (l.toLowerCase() === "src" && r(this) && f(this, d))
51
+ return n.call(this, c);
52
+ }, e.setAttribute = function(c, d) {
53
+ if (c.toLowerCase() === "src" && r(this) && f(this, d))
54
54
  return;
55
- const u = l.toLowerCase() === "src" && r(this) ? E(this, d) : String(d);
56
- c.call(this, l, String(u));
55
+ const u = c.toLowerCase() === "src" && r(this) ? E(this, d) : String(d);
56
+ l.call(this, c, String(u));
57
57
  };
58
58
  const v = e.setAttributeNS;
59
- e.setAttributeNS = function(l, d, u) {
59
+ e.setAttributeNS = function(c, d, u) {
60
60
  if (d.toLowerCase() === "src" && r(this) && f(this, u))
61
61
  return;
62
62
  const B = d.toLowerCase() === "src" && r(this) ? E(this, u) : String(u);
63
- v.call(this, l, d, String(B));
64
- }, e.removeAttribute = function(l) {
65
- l.toLowerCase() === "src" && r(this) && V.call(this, n), V.call(this, l);
63
+ v.call(this, c, d, String(B));
64
+ }, e.removeAttribute = function(c) {
65
+ c.toLowerCase() === "src" && r(this) && s.call(this, a), s.call(this, c);
66
66
  };
67
- const M = (l) => {
68
- if (!l) return;
69
- const d = Object.getOwnPropertyDescriptor(l, "src");
70
- return !d?.get || !d.set || Object.defineProperty(l, "src", {
67
+ const M = (c) => {
68
+ if (!c) return;
69
+ const d = Object.getOwnPropertyDescriptor(c, "src");
70
+ return !d?.get || !d.set || Object.defineProperty(c, "src", {
71
71
  configurable: !0,
72
72
  enumerable: d.enumerable,
73
73
  get() {
@@ -77,21 +77,21 @@ function uq(A) {
77
77
  r(this) && f(this, u) || d.set.call(this, r(this) ? E(this, u) : i(u));
78
78
  }
79
79
  }), d;
80
- }, s = M(q);
80
+ }, V = M(q);
81
81
  M(A.HTMLSourceElement?.prototype);
82
82
  const p = q.play;
83
83
  q.play = function() {
84
- const l = y(this) ?? o.call(this, "src"), d = R(l);
84
+ const c = y(this) ?? n.call(this, "src"), d = R(c);
85
85
  if (t) {
86
- const u = this.querySelector?.(`source[${n}]`), B = u ? R(y(u)) : null;
86
+ const u = this.querySelector?.(`source[${a}]`), B = u ? R(y(u)) : null;
87
87
  if (d || B) return Promise.resolve();
88
88
  }
89
- return d && s?.set?.call(this, d), p.call(this);
89
+ return d && V?.set?.call(this, d), p.call(this);
90
90
  };
91
- const g = (l, d) => {
92
- if (!l) return;
93
- const u = Object.getOwnPropertyDescriptor(l, d);
94
- !u?.get || !u.set || Object.defineProperty(l, d, {
91
+ const g = (c, d) => {
92
+ if (!c) return;
93
+ const u = Object.getOwnPropertyDescriptor(c, d);
94
+ !u?.get || !u.set || Object.defineProperty(c, d, {
95
95
  configurable: !0,
96
96
  enumerable: u.enumerable,
97
97
  get: u.get,
@@ -101,51 +101,51 @@ function uq(A) {
101
101
  });
102
102
  };
103
103
  g(e, "innerHTML"), g(e, "outerHTML"), g(A.ShadowRoot?.prototype, "innerHTML");
104
- const a = e.insertAdjacentHTML;
105
- e.insertAdjacentHTML = function(l, d) {
106
- a.call(this, l, C(String(d)));
104
+ const o = e.insertAdjacentHTML;
105
+ e.insertAdjacentHTML = function(c, d) {
106
+ o.call(this, c, C(String(d)));
107
107
  };
108
108
  const h = A.Range?.prototype;
109
109
  if (h) {
110
- const l = h.createContextualFragment;
110
+ const c = h.createContextualFragment;
111
111
  h.createContextualFragment = function(d) {
112
- return l.call(this, C(String(d)));
112
+ return c.call(this, C(String(d)));
113
113
  };
114
114
  }
115
115
  const T = A.DOMParser?.prototype;
116
116
  if (T) {
117
- const l = T.parseFromString;
117
+ const c = T.parseFromString;
118
118
  T.parseFromString = function(d, u) {
119
- return l.call(this, C(String(d)), u);
119
+ return c.call(this, C(String(d)), u);
120
120
  };
121
121
  }
122
122
  const k = A.Document?.prototype;
123
123
  if (k) {
124
- const l = k.write, d = k.writeln;
124
+ const c = k.write, d = k.writeln;
125
125
  k.write = function(...u) {
126
- l.apply(this, u.map((B) => C(String(B))));
126
+ c.apply(this, u.map((B) => C(String(B))));
127
127
  }, k.writeln = function(...u) {
128
128
  d.apply(this, u.map((B) => C(String(B))));
129
129
  };
130
130
  }
131
- const w = (l) => {
131
+ const w = (c) => {
132
132
  const d = [];
133
- r(l) && d.push(l), (l instanceof A.Element || l === A.document) && d.push(...l.querySelectorAll(
133
+ r(c) && d.push(c), (c instanceof A.Element || c === A.document) && d.push(...c.querySelectorAll(
134
134
  'audio[src^="romsound://"], video[src^="romsound://"], source[src^="romsound://"], audio[data-arib-romsound], video[data-arib-romsound], source[data-arib-romsound]'
135
135
  ));
136
136
  for (const u of d) {
137
- const X = y(u) ?? o.call(u, "src"), Q = R(X);
137
+ const X = y(u) ?? n.call(u, "src"), Q = R(X);
138
138
  if (Q) {
139
139
  if (t) {
140
- V.call(u, "src"), u instanceof A.HTMLMediaElement && (V.call(u, "autoplay"), u.pause());
140
+ s.call(u, "src"), u instanceof A.HTMLMediaElement && (s.call(u, "autoplay"), u.pause());
141
141
  continue;
142
142
  }
143
- u instanceof A.HTMLMediaElement && s?.set ? s.get?.call(u) !== Q && s.set.call(u, Q) : o.call(u, "src") !== Q && c.call(u, "src", Q);
143
+ u instanceof A.HTMLMediaElement && V?.set ? V.get?.call(u) !== Q && V.set.call(u, Q) : n.call(u, "src") !== Q && l.call(u, "src", Q);
144
144
  }
145
145
  }
146
146
  };
147
- new A.MutationObserver((l) => {
148
- for (const d of l) {
147
+ new A.MutationObserver((c) => {
148
+ for (const d of c) {
149
149
  d.type === "attributes" && w(d.target);
150
150
  for (const u of d.addedNodes) w(u);
151
151
  }
@@ -193,8 +193,8 @@ function fq(A, q) {
193
193
  return e.now();
194
194
  }
195
195
  }, i = function(...r) {
196
- const n = r.length === 0 ? [t()] : r;
197
- return new.target ? Reflect.construct(e, n, new.target) : new e(t()).toString();
196
+ const a = r.length === 0 ? [t()] : r;
197
+ return new.target ? Reflect.construct(e, a, new.target) : new e(t()).toString();
198
198
  };
199
199
  Object.setPrototypeOf(i, e), Object.defineProperty(i, "prototype", {
200
200
  value: e.prototype
@@ -227,15 +227,15 @@ function H(A, q, e = q) {
227
227
  const t = new URL(A, q);
228
228
  if (t.origin !== q.origin || !/^https?:$/.test(t.protocol)) return t;
229
229
  if (!t.pathname.startsWith(q.pathname)) {
230
- const i = t.pathname.replace(/^\/+/, ""), r = e.pathname.startsWith(q.pathname) ? e.pathname.slice(q.pathname.length).replace(/^\/+|\/+$/g, "") : "", n = r && (i === r || i.startsWith(`${r}/`));
231
- t.pathname = `${n ? q.pathname : e.pathname}${i}`;
230
+ const i = t.pathname.replace(/^\/+/, ""), r = e.pathname.startsWith(q.pathname) ? e.pathname.slice(q.pathname.length).replace(/^\/+|\/+$/g, "") : "", a = r && (i === r || i.startsWith(`${r}/`));
231
+ t.pathname = `${a ? q.pathname : e.pathname}${i}`;
232
232
  }
233
233
  return t;
234
234
  }
235
235
  function vq(A, q, e) {
236
236
  const t = e ?? {
237
- async store(s, p) {
238
- const g = await A.fetch(s, {
237
+ async store(V, p) {
238
+ const g = await A.fetch(V, {
239
239
  cache: "reload",
240
240
  credentials: "same-origin",
241
241
  signal: p.signal
@@ -244,64 +244,64 @@ function vq(A, q, e) {
244
244
  await g.arrayBuffer();
245
245
  }
246
246
  }, i = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
247
- let n = !1;
248
- const o = (s) => q(s).href, c = (s, p, g) => A.queueMicrotask(() => p(s, g)), V = (s, p) => {
249
- for (const g of s.paths)
250
- for (const a of i.get(g) ?? []) c(g, a, p);
251
- }, y = (s) => {
247
+ let a = !1;
248
+ const n = (V) => q(V).href, l = (V, p, g) => A.queueMicrotask(() => p(V, g)), s = (V, p) => {
249
+ for (const g of V.paths)
250
+ for (const o of i.get(g) ?? []) l(g, o, p);
251
+ }, y = (V) => {
252
252
  try {
253
- Promise.resolve(t.release?.(s)).catch(() => {
253
+ Promise.resolve(t.release?.(V)).catch(() => {
254
254
  });
255
255
  } catch {
256
256
  }
257
- }, E = (s) => {
258
- s.generation += 1, s.controller?.abort(), s.controller = void 0, r.delete(s.url), y(s.url);
259
- }, f = (s, p) => {
260
- s.controller?.abort();
261
- const g = new A.AbortController(), a = ++s.generation;
262
- s.controller = g, s.state = "loading", Promise.resolve(t.store(s.url, { signal: g.signal })).then(
257
+ }, E = (V) => {
258
+ V.generation += 1, V.controller?.abort(), V.controller = void 0, r.delete(V.url), y(V.url);
259
+ }, f = (V, p) => {
260
+ V.controller?.abort();
261
+ const g = new A.AbortController(), o = ++V.generation;
262
+ V.controller = g, V.state = "loading", Promise.resolve(t.store(V.url, { signal: g.signal })).then(
263
263
  () => {
264
- n || g.signal.aborted || s.generation !== a || (s.controller = void 0, s.state = "stored", V(s, p));
264
+ a || g.signal.aborted || V.generation !== o || (V.controller = void 0, V.state = "stored", s(V, p));
265
265
  },
266
266
  () => {
267
- n || g.signal.aborted || s.generation !== a || (s.controller = void 0, s.state = "failed", V(s, "store_failed"));
267
+ a || g.signal.aborted || V.generation !== o || (V.controller = void 0, V.state = "failed", s(V, "store_failed"));
268
268
  }
269
269
  );
270
- }, v = (s, p) => typeof p != "function" || n ? !1 : (i.has(s) || i.set(s, /* @__PURE__ */ new Set()), i.get(s)?.add(p), r.get(o(s))?.state === "stored" && c(s, p, "store_finished"), !0), M = (s) => {
271
- if (s === void 0) {
270
+ }, v = (V, p) => typeof p != "function" || a ? !1 : (i.has(V) || i.set(V, /* @__PURE__ */ new Set()), i.get(V)?.add(p), r.get(n(V))?.state === "stored" && l(V, p, "store_finished"), !0), M = (V) => {
271
+ if (V === void 0) {
272
272
  for (const g of [...r.values()]) E(g);
273
273
  return !0;
274
274
  }
275
- const p = r.get(o(s));
275
+ const p = r.get(n(V));
276
276
  return p && E(p), !0;
277
277
  };
278
278
  return {
279
279
  addListener: v,
280
- removeListener(s, p) {
281
- return p ? (i.get(s)?.delete(p), i.get(s)?.size === 0 && i.delete(s)) : i.delete(s), !0;
280
+ removeListener(V, p) {
281
+ return p ? (i.get(V)?.delete(p), i.get(V)?.size === 0 && i.delete(V)) : i.delete(V), !0;
282
282
  },
283
- store(s, p) {
284
- if (n) return !1;
285
- const g = o(s);
286
- let a = r.get(g);
287
- return a || (a = {
283
+ store(V, p) {
284
+ if (a) return !1;
285
+ const g = n(V);
286
+ let o = r.get(g);
287
+ return o || (o = {
288
288
  url: g,
289
289
  paths: /* @__PURE__ */ new Set(),
290
290
  state: "failed",
291
291
  generation: 0
292
- }, r.set(g, a)), a.paths.add(s), p && v(s, p), a.state === "stored" || a.state !== "loading" && f(a, "store_finished"), !0;
292
+ }, r.set(g, o)), o.paths.add(V), p && v(V, p), o.state === "stored" || o.state !== "loading" && f(o, "store_finished"), !0;
293
293
  },
294
294
  release: M,
295
- change(s, p) {
296
- const g = r.get(o(s));
297
- g && (p === "deleted" ? (V(g, "deleted"), E(g)) : f(g, "updated"));
295
+ change(V, p) {
296
+ const g = r.get(n(V));
297
+ g && (p === "deleted" ? (s(g, "deleted"), E(g)) : f(g, "updated"));
298
298
  },
299
299
  dispose() {
300
- n || (M(), n = !0, i.clear());
300
+ a || (M(), a = !0, i.clear());
301
301
  }
302
302
  };
303
303
  }
304
- const Mq = "libaribhtml5", bq = "0.1.8", kq = { name: "huggy" }, wq = { modelName: "Huggy ARIB HTML5 Receiver" }, I = {
304
+ const Mq = "libaribhtml5", bq = "0.1.10", kq = { name: "huggy" }, wq = { modelName: "Huggy ARIB HTML5 Receiver" }, I = {
305
305
  name: Mq,
306
306
  version: bq,
307
307
  author: kq,
@@ -432,7 +432,7 @@ function x(A) {
432
432
  throw b("managed_URL must be a string");
433
433
  return { permissionBitmaps: e, managedUrls: t };
434
434
  }
435
- function N(A) {
435
+ function O(A) {
436
436
  const q = A.reduce(
437
437
  (t, i) => t + (i.permissionBitmaps?.length ?? 0),
438
438
  0
@@ -457,7 +457,7 @@ function L(A) {
457
457
  function xq(A, q) {
458
458
  return A.origin === q.origin && A.pathname.startsWith(q.pathname);
459
459
  }
460
- function Nq(A, q, e) {
460
+ function Oq(A, q, e) {
461
461
  let t;
462
462
  try {
463
463
  t = new URL(A, e);
@@ -468,7 +468,7 @@ function Nq(A, q, e) {
468
468
  const i = t.pathname.replace(/\/+$/, "") || "/", r = q.pathname;
469
469
  return i !== "/" && r !== i && !r.startsWith(`${i}/`) ? null : t.origin.length + i.length;
470
470
  }
471
- class Oq {
471
+ class Nq {
472
472
  broadcastBaseUrl;
473
473
  documentUrl;
474
474
  baseAreas;
@@ -479,7 +479,7 @@ class Oq {
479
479
  /** Apply a new MH-AIT descriptor without discarding areas added by the application. */
480
480
  update(q) {
481
481
  const e = q?.map(x);
482
- N([...e ?? [], ...this.addedAreas]), this.baseAreas = e;
482
+ O([...e ?? [], ...this.addedAreas]), this.baseAreas = e;
483
483
  }
484
484
  hasDescriptor() {
485
485
  return this.baseAreas !== void 0 || this.addedAreas.length > 0;
@@ -502,7 +502,7 @@ class Oq {
502
502
  permissionBitmaps: e.permission === null || e.permission.length === 0 ? null : e.permission,
503
503
  managedUrls: e.urls === null || e.urls.length === 0 ? null : e.urls
504
504
  });
505
- N([...this.baseAreas ?? [], ...this.addedAreas, t]), this.addedAreas.push(jq(t));
505
+ O([...this.baseAreas ?? [], ...this.addedAreas, t]), this.addedAreas.push(jq(t));
506
506
  }
507
507
  evaluate(q) {
508
508
  let e;
@@ -517,17 +517,17 @@ class Oq {
517
517
  if (this.baseAreas === void 0 && this.addedAreas.length === 0)
518
518
  return { withinBoundary: !0, permissionBits: S };
519
519
  let i = -1, r = 0;
520
- for (const n of t) {
521
- const o = n.managedUrls;
522
- if (o === null || o.length === 0) {
523
- i < 0 ? (i = 0, r = L(n.permissionBitmaps)) : i === 0 && (r &= L(n.permissionBitmaps));
520
+ for (const a of t) {
521
+ const n = a.managedUrls;
522
+ if (n === null || n.length === 0) {
523
+ i < 0 ? (i = 0, r = L(a.permissionBitmaps)) : i === 0 && (r &= L(a.permissionBitmaps));
524
524
  continue;
525
525
  }
526
- for (const c of o) {
527
- const V = Nq(c, e, this.documentUrl);
528
- if (V === null || V < i) continue;
529
- const y = L(n.permissionBitmaps);
530
- V > i ? (i = V, r = y) : r &= y;
526
+ for (const l of n) {
527
+ const s = Oq(l, e, this.documentUrl);
528
+ if (s === null || s < i) continue;
529
+ const y = L(a.permissionBitmaps);
530
+ s > i ? (i = s, r = y) : r &= y;
531
531
  }
532
532
  }
533
533
  return i < 0 ? { withinBoundary: !1, permissionBits: 0 } : { withinBoundary: !0, permissionBits: r };
@@ -541,48 +541,48 @@ function Zq(A, q) {
541
541
  if (q) return;
542
542
  const e = (r) => {
543
543
  try {
544
- const n = new URL(String(r), A.location.href);
545
- return /^https?:$/.test(n.protocol) && n.origin !== A.location.origin;
544
+ const a = new URL(String(r), A.location.href);
545
+ return /^https?:$/.test(a.protocol) && a.origin !== A.location.origin;
546
546
  } catch {
547
547
  return !1;
548
548
  }
549
549
  }, t = A.XMLHttpRequest?.prototype;
550
550
  if (t) {
551
- const r = /* @__PURE__ */ new WeakSet(), n = t.open, o = t.send;
551
+ const r = /* @__PURE__ */ new WeakSet(), a = t.open, n = t.send;
552
552
  Object.defineProperty(t, "open", {
553
553
  configurable: !0,
554
554
  writable: !0,
555
- value: function(c, V, ...y) {
556
- return e(V) ? r.add(this) : r.delete(this), Reflect.apply(n, this, [c, V, ...y]);
555
+ value: function(l, s, ...y) {
556
+ return e(s) ? r.add(this) : r.delete(this), Reflect.apply(a, this, [l, s, ...y]);
557
557
  }
558
558
  }), Object.defineProperty(t, "send", {
559
559
  configurable: !0,
560
560
  writable: !0,
561
- value: function(c) {
562
- if (!r.has(this)) return o.call(this, c);
561
+ value: function(l) {
562
+ if (!r.has(this)) return n.call(this, l);
563
563
  A.queueMicrotask(() => this.dispatchEvent(new A.ProgressEvent("error")));
564
564
  }
565
565
  });
566
566
  }
567
567
  const i = A.fetch?.bind(A);
568
- if (i && (A.fetch = (r, n) => {
569
- const o = r instanceof A.Request ? r.url : r;
570
- return e(o) ? Promise.reject(new TypeError("External network is offline")) : i(r, n);
568
+ if (i && (A.fetch = (r, a) => {
569
+ const n = r instanceof A.Request ? r.url : r;
570
+ return e(n) ? Promise.reject(new TypeError("External network is offline")) : i(r, a);
571
571
  }), typeof A.navigator.sendBeacon == "function") {
572
572
  const r = A.navigator.sendBeacon.bind(A.navigator);
573
573
  Object.defineProperty(A.navigator, "sendBeacon", {
574
574
  configurable: !0,
575
- value: (n, o) => e(n) ? !1 : r(n, o)
575
+ value: (a, n) => e(a) ? !1 : r(a, n)
576
576
  });
577
577
  }
578
578
  }
579
579
  const Kq = (A, q, e = 1) => Math.abs(A.left - q.left) <= e && Math.abs(A.top - q.top) <= e && Math.abs(A.width - q.width) <= e && Math.abs(A.height - q.height) <= e, zq = (A) => A.hasAttribute("width") || A.hasAttribute("height") || A.style.getPropertyValue("width") !== "" || A.style.getPropertyValue("height") !== "", F = (A) => {
580
580
  const q = A.ownerDocument;
581
581
  let e = A, t = A.getBoundingClientRect(), i = A, r = !zq(A) && (t.width <= 0 || t.height <= 0 || Math.abs(t.width - 300) <= 1 && Math.abs(t.height - 150) <= 1);
582
- for (let n = A.parentElement; n && n !== q.body && n !== q.documentElement; n = n.parentElement) {
583
- const o = n.getBoundingClientRect(), c = n.children.length === 1 && n.firstElementChild === i, V = Kq(o, t);
584
- if (!c || o.width <= 0 || o.height <= 0 || !V && !r) break;
585
- e = n, t = o, i = n, r = !1;
582
+ for (let a = A.parentElement; a && a !== q.body && a !== q.documentElement; a = a.parentElement) {
583
+ const n = a.getBoundingClientRect(), l = a.children.length === 1 && a.firstElementChild === i, s = Kq(n, t);
584
+ if (!l || n.width <= 0 || n.height <= 0 || !s && !r) break;
585
+ e = a, t = n, i = a, r = !1;
586
586
  }
587
587
  return { element: e, rect: t };
588
588
  };
@@ -593,28 +593,28 @@ class Hq {
593
593
  constructor(q) {
594
594
  this.target = q;
595
595
  }
596
- set(q, e) {
597
- if (this.setPlaceholder(q, e), !e) {
596
+ set(q, e, t = !0) {
597
+ if (this.setPlaceholder(q, e), !e || !t) {
598
598
  this.restoreBackgrounds();
599
599
  return;
600
600
  }
601
- const t = /* @__PURE__ */ new Set();
601
+ const i = /* @__PURE__ */ new Set();
602
602
  for (let n = q.parentElement; n && n !== this.target.document.body && n !== this.target.document.documentElement; n = n.parentElement) {
603
- const o = this.target.getComputedStyle(n);
604
- !this.backgrounds.has(n) && this.hasTransparentBackground(o) || t.add(n);
603
+ const l = this.target.getComputedStyle(n);
604
+ !this.backgrounds.has(n) && this.hasTransparentBackground(l) || i.add(n);
605
605
  }
606
- const i = F(q).rect, r = (n) => {
607
- const o = n.getBoundingClientRect(), c = 1;
608
- return o.width > 0 && o.height > 0 && o.left <= i.left + c && o.top <= i.top + c && o.right >= i.right - c && o.bottom >= i.bottom - c;
606
+ const r = F(q).rect, a = (n) => {
607
+ const l = n.getBoundingClientRect(), s = 1;
608
+ return l.width > 0 && l.height > 0 && l.left <= r.left + s && l.top <= r.top + s && l.right >= r.right - s && l.bottom >= r.bottom - s;
609
609
  };
610
610
  for (const n of this.target.document.querySelectorAll("body *")) {
611
611
  if (n === q || n.contains(q) || q.contains(n)) continue;
612
- const o = this.target.getComputedStyle(n);
613
- !this.backgrounds.has(n) && this.hasTransparentBackground(o) || r(n) && t.add(n);
612
+ const l = this.target.getComputedStyle(n);
613
+ !this.backgrounds.has(n) && this.hasTransparentBackground(l) || a(n) && i.add(n);
614
614
  }
615
615
  for (const n of [...this.backgrounds.keys()])
616
- t.has(n) || this.restoreBackground(n);
617
- for (const n of t) {
616
+ i.has(n) || this.restoreBackground(n);
617
+ for (const n of i) {
618
618
  if (this.backgrounds.has(n)) {
619
619
  this.captureApplicationBackgroundChanges(n), this.clearBackground(n);
620
620
  continue;
@@ -669,11 +669,11 @@ class Hq {
669
669
  }
670
670
  placeholderElements(q) {
671
671
  const e = [q], t = F(q), i = t.rect, r = 1;
672
- let n = q;
673
- for (let o = q.parentElement; o && o !== this.target.document.body && o !== this.target.document.documentElement; o = o.parentElement) {
674
- const c = o.getBoundingClientRect();
675
- if (!(o.children.length === 1 && o.firstElementChild === n && (o === t.element || Math.abs(c.left - i.left) <= r && Math.abs(c.top - i.top) <= r && Math.abs(c.width - i.width) <= r && Math.abs(c.height - i.height) <= r))) break;
676
- e.push(o), n = o;
672
+ let a = q;
673
+ for (let n = q.parentElement; n && n !== this.target.document.body && n !== this.target.document.documentElement; n = n.parentElement) {
674
+ const l = n.getBoundingClientRect();
675
+ if (!(n.children.length === 1 && n.firstElementChild === a && (n === t.element || Math.abs(l.left - i.left) <= r && Math.abs(l.top - i.top) <= r && Math.abs(l.width - i.width) <= r && Math.abs(l.height - i.height) <= r))) break;
676
+ e.push(n), a = n;
677
677
  }
678
678
  return e;
679
679
  }
@@ -731,7 +731,7 @@ class Hq {
731
731
  this.restoreBackground(q);
732
732
  }
733
733
  }
734
- const Yq = 'object[type="video/x-arib2-broadcast"], object[data-arib-type="video/x-arib2-broadcast"]', O = [
734
+ const Yq = '[data-arib-object="video/x-arib2-broadcast"], object[type="video/x-arib2-broadcast"]', N = [
735
735
  "animationstart",
736
736
  "animationend",
737
737
  "animationcancel",
@@ -771,7 +771,7 @@ class Xq {
771
771
  startObserving() {
772
772
  if (!(this.observing || this.disposed)) {
773
773
  this.observing = !0, this.mutationObserver = new this.target.MutationObserver(this.schedule), this.observeDocumentMutations(), this.resizeObserver?.observe(this.target.document.documentElement), this.target.addEventListener("resize", this.schedule);
774
- for (const q of O)
774
+ for (const q of N)
775
775
  this.target.document.addEventListener(q, this.schedule, !0);
776
776
  this.target.document.addEventListener("load", this.schedule, !0), queueMicrotask(this.schedule);
777
777
  }
@@ -788,7 +788,7 @@ class Xq {
788
788
  dispose(q, e) {
789
789
  if (!this.disposed) {
790
790
  this.disposed = !0, this.mediaPlaneFrame !== null && this.target.cancelAnimationFrame(this.mediaPlaneFrame), this.mediaPlaneFrame = null, this.mutationObserver?.disconnect(), this.resizeObserver?.disconnect(), this.target.removeEventListener("resize", this.schedule), this.target.document.removeEventListener("load", this.schedule, !0);
791
- for (const t of O)
791
+ for (const t of N)
792
792
  this.target.document.removeEventListener(t, this.schedule, !0);
793
793
  this.applicationCanvasStyle?.remove(), this.applicationCanvasStyle = null, e?.(), this.unmountMediaPlane(q);
794
794
  }
@@ -802,12 +802,12 @@ class Xq {
802
802
  let i = this.target.getComputedStyle(e ?? this.target.document.documentElement).backgroundColor;
803
803
  const r = e?.getBoundingClientRect();
804
804
  if (r && r.width > 0 && r.height > 0)
805
- for (const o of this.target.document.querySelectorAll("body *")) {
806
- const c = this.target.getComputedStyle(o);
807
- if (c.backgroundColor === "rgba(0, 0, 0, 0)" || c.backgroundColor === "transparent") continue;
808
- const V = o.getBoundingClientRect();
809
- if (!(V.width <= 0 || V.height <= 0 || V.left > r.left + 1 || V.top > r.top + 1 || V.right < r.right - 1 || V.bottom < r.bottom - 1)) {
810
- i = c.backgroundColor;
805
+ for (const n of this.target.document.querySelectorAll("body *")) {
806
+ const l = this.target.getComputedStyle(n);
807
+ if (l.backgroundColor === "rgba(0, 0, 0, 0)" || l.backgroundColor === "transparent") continue;
808
+ const s = n.getBoundingClientRect();
809
+ if (!(s.width <= 0 || s.height <= 0 || s.left > r.left + 1 || s.top > r.top + 1 || s.right < r.right - 1 || s.bottom < r.bottom - 1)) {
810
+ i = l.backgroundColor;
811
811
  break;
812
812
  }
813
813
  }
@@ -837,7 +837,14 @@ class Xq {
837
837
  observeDocumentMutations() {
838
838
  !this.observing || this.disposed || this.mutationObserver === null || this.mutationObserver.observe(this.target.document.documentElement, {
839
839
  attributes: !0,
840
- attributeFilter: ["class", "style", "type", "data-arib-type", "name", "value"],
840
+ attributeFilter: [
841
+ "class",
842
+ "style",
843
+ "type",
844
+ "data-arib-object",
845
+ "name",
846
+ "value"
847
+ ],
841
848
  childList: !0,
842
849
  subtree: !0
843
850
  });
@@ -854,11 +861,11 @@ class Xq {
854
861
  q !== this.observedMediaObject && (this.observedMediaObject && this.resizeObserver?.unobserve(this.observedMediaObject), this.observedMediaObject = q, q && this.resizeObserver?.observe(q));
855
862
  }
856
863
  logicalViewport() {
857
- const q = this.target.document.querySelector('meta[name="viewport"]')?.content ?? "", e = (o) => {
858
- const c = Number(q.match(new RegExp(`(?:^|[,;])\\s*${o}\\s*=\\s*(\\d+)`, "i"))?.[1]);
859
- return Number.isSafeInteger(c) && c > 0 ? c : null;
860
- }, t = e("width"), i = e("height"), r = t ?? (i === null ? 3840 : Math.round(i * 16 / 9)), n = i ?? (t === null ? 2160 : Math.round(t * 9 / 16));
861
- return { width: r, height: n };
864
+ const q = this.target.document.querySelector('meta[name="viewport"]')?.content ?? "", e = (n) => {
865
+ const l = Number(q.match(new RegExp(`(?:^|[,;])\\s*${n}\\s*=\\s*(\\d+)`, "i"))?.[1]);
866
+ return Number.isSafeInteger(l) && l > 0 ? l : null;
867
+ }, t = e("width"), i = e("height"), r = t ?? (i === null ? 3840 : Math.round(i * 16 / 9)), a = i ?? (t === null ? 2160 : Math.round(t * 9 / 16));
868
+ return { width: r, height: a };
862
869
  }
863
870
  reportScreenSize() {
864
871
  const q = this.logicalViewport(), e = JSON.stringify(q);
@@ -904,27 +911,28 @@ class Xq {
904
911
  return;
905
912
  }
906
913
  this.observeMediaObject(q), this.installBroadcastObjectApi(q);
907
- const e = F(q), t = e.rect, i = this.target.getComputedStyle(q), r = q.querySelector('param[name="video_src"]')?.value, n = q.querySelector('param[name="audio_src"]')?.value, o = this.logicalViewport(), c = this.externalMediaHole.describeStackingPath(q), V = {
914
+ const e = F(q), t = e.rect, i = this.target.getComputedStyle(q), r = q.querySelector('param[name="video_src"]')?.value, a = q.querySelector('param[name="audio_src"]')?.value, n = this.logicalViewport(), l = this.externalMediaHole.describeStackingPath(q), s = {
908
915
  slotId: this.slotIdFor(q),
909
- visible: i.display !== "none" && i.visibility !== "hidden" && t.width > 0 && t.height > 0 && c.every((E) => E.display !== "none" && E.visibility !== "hidden" && E.opacity > 0),
916
+ visible: i.display !== "none" && i.visibility !== "hidden" && t.width > 0 && t.height > 0 && l.every((E) => E.display !== "none" && E.visibility !== "hidden" && E.opacity > 0),
910
917
  x: t.x,
911
918
  y: t.y,
912
919
  width: t.width,
913
920
  height: t.height,
914
- screenWidth: o.width,
915
- screenHeight: o.height,
921
+ screenWidth: n.width,
922
+ screenHeight: n.height,
916
923
  videoSource: r,
917
- audioSource: n,
924
+ audioSource: a,
918
925
  layer: {
919
926
  documentOrder: Array.from(this.target.document.querySelectorAll("*")).indexOf(q),
920
- stackingPath: c,
927
+ stackingPath: l,
921
928
  externalPlacement: e.element !== q && Number.parseInt(this.target.getComputedStyle(e.element).zIndex, 10) > 0 ? "above-application" : "behind-application"
922
929
  }
923
- }, y = JSON.stringify(V);
924
- q !== this.activeMediaObject ? (this.activeMediaObject && this.unmountMediaPlane("slot-removed"), this.activeMediaObject = q, this.adapter && this.callMediaPlaneAdapter(() => this.adapter?.mountMediaPlane(q, V))) : y !== this.lastMediaPlane && this.adapter && this.callMediaPlaneAdapter(() => this.adapter?.updateMediaPlane(q, V)), this.externalMediaHole.set(
930
+ }, y = JSON.stringify(s);
931
+ q !== this.activeMediaObject ? (this.activeMediaObject && this.unmountMediaPlane("slot-removed"), this.activeMediaObject = q, this.adapter && this.callMediaPlaneAdapter(() => this.adapter?.mountMediaPlane(q, s))) : y !== this.lastMediaPlane && this.adapter && this.callMediaPlaneAdapter(() => this.adapter?.updateMediaPlane(q, s)), this.externalMediaHole.set(
925
932
  q,
926
- (this.adapter?.renderMode ?? "external") === "external"
927
- ), y !== this.lastMediaPlane && (this.lastMediaPlane = y, this.postRuntime("media-plane", V));
933
+ (this.adapter?.renderMode ?? "external") === "external",
934
+ s.layer.externalPlacement !== "above-application"
935
+ ), y !== this.lastMediaPlane && (this.lastMediaPlane = y, this.postRuntime("media-plane", s));
928
936
  }
929
937
  }
930
938
  class _q {
@@ -1015,7 +1023,7 @@ class $q {
1015
1023
  };
1016
1024
  ownerApplication;
1017
1025
  constructor(q) {
1018
- this.target = q.target, this.resolveRuntimeUrl = q.resolveRuntimeUrl, this.allowExternalNetwork = q.allowExternalNetwork, this.postRuntime = q.postRuntime, this.applicationInformation = { ...q.application }, this.boundary = new Oq(
1026
+ this.target = q.target, this.resolveRuntimeUrl = q.resolveRuntimeUrl, this.allowExternalNetwork = q.allowExternalNetwork, this.postRuntime = q.postRuntime, this.applicationInformation = { ...q.application }, this.boundary = new Nq(
1019
1027
  q.broadcastBaseUrl,
1020
1028
  this.target.location.href,
1021
1029
  this.applicationInformation.permissionManagedAreas
@@ -1172,17 +1180,29 @@ function ee(A, q) {
1172
1180
  e ? Object.defineProperty(A, "userAgent", e) : Reflect.deleteProperty(A, "userAgent");
1173
1181
  };
1174
1182
  }
1175
- function te(A, q = {}) {
1183
+ function te(A) {
1184
+ const q = A.document.querySelectorAll(
1185
+ 'object[type="video/x-arib2-broadcast"]'
1186
+ );
1187
+ for (const e of q) {
1188
+ const t = A.document.createElement("video");
1189
+ for (const i of Array.from(e.attributes))
1190
+ i.name.toLowerCase() !== "type" && t.setAttribute(i.name, i.value);
1191
+ for (t.setAttribute("data-arib-object", "video/x-arib2-broadcast"); e.firstChild !== null; ) t.append(e.firstChild);
1192
+ e.replaceWith(t);
1193
+ }
1194
+ }
1195
+ function Ae(A, q = {}) {
1176
1196
  if (!A.__ARIB_HTML5_RUNTIME__) {
1177
1197
  A.__ARIB_HTML5_RUNTIME__ = "installing";
1178
1198
  try {
1179
- Ae(A, q), A.__ARIB_HTML5_RUNTIME__ = !0;
1199
+ ie(A, q), A.__ARIB_HTML5_RUNTIME__ = !0;
1180
1200
  } catch (e) {
1181
1201
  throw delete A.__ARIB_HTML5_RUNTIME__, e;
1182
1202
  }
1183
1203
  }
1184
1204
  }
1185
- function Ae(A, q) {
1205
+ function ie(A, q) {
1186
1206
  const e = q.userAgent === void 0 ? null : ee(A.navigator, q.userAgent);
1187
1207
  fq(A, q.now), uq(A), mq(A);
1188
1208
  const t = z(
@@ -1191,73 +1211,73 @@ function Ae(A, q) {
1191
1211
  );
1192
1212
  if (t.origin !== A.location.origin)
1193
1213
  throw new Error(`Broadcast base URL must be same-origin: ${t.href}`);
1194
- const i = Bq(A.location.href, t), r = (a) => {
1195
- const h = new URL(String(a ?? ""), A.location.href);
1214
+ const i = Bq(A.location.href, t), r = (o) => {
1215
+ const h = new URL(String(o ?? ""), A.location.href);
1196
1216
  return H(h, t, i);
1197
- }, n = A.crypto.randomUUID?.() ?? `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`, o = (a, h = {}) => {
1217
+ }, a = A.crypto.randomUUID?.() ?? `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`, n = (o, h = {}) => {
1198
1218
  A.parent?.postMessage({
1199
1219
  type: "arib-runtime",
1200
- runtimeId: n,
1201
- event: a,
1220
+ runtimeId: a,
1221
+ event: o,
1202
1222
  ...h
1203
1223
  }, "*");
1204
- }, c = new $q({
1224
+ }, l = new $q({
1205
1225
  target: A,
1206
1226
  broadcastBaseUrl: t,
1207
1227
  resolveRuntimeUrl: r,
1208
1228
  allowExternalNetwork: q.allowExternalNetwork ?? !1,
1209
1229
  application: q.application,
1210
- postRuntime: o
1211
- }), V = (a) => {
1212
- c.requirePermission(a);
1230
+ postRuntime: n
1231
+ }), s = (o) => {
1232
+ l.requirePermission(o);
1213
1233
  };
1214
1234
  Zq(A, q.allowExternalNetwork);
1215
- for (const [a, h] of Object.entries(qe)) A[a] = h;
1235
+ for (const [o, h] of Object.entries(qe)) A[o] = h;
1216
1236
  const y = /* @__PURE__ */ new Set(), E = /* @__PURE__ */ new Set(), f = vq(
1217
1237
  A,
1218
- (a) => r(a),
1238
+ (o) => r(o),
1219
1239
  q.resourceStore
1220
1240
  );
1221
1241
  let v = null;
1222
1242
  const M = new _q({
1223
- requirePermission: () => V(m.broadcastMedia),
1224
- postRuntime: o
1243
+ requirePermission: () => s(m.broadcastMedia),
1244
+ postRuntime: n
1225
1245
  });
1226
- let s;
1227
- A.addEventListener("message", (a) => {
1228
- if (!(a.source !== A.parent || a.origin !== A.location.origin) && !(a.data?.type !== "arib-host" || a.data.runtimeId !== n) && !M.handleHostMessage(a.data)) {
1229
- if (a.data.event === "program-info") {
1246
+ let V;
1247
+ A.addEventListener("message", (o) => {
1248
+ if (!(o.source !== A.parent || o.origin !== A.location.origin) && !(o.data?.type !== "arib-host" || o.data.runtimeId !== a) && !M.handleHostMessage(o.data)) {
1249
+ if (o.data.event === "program-info") {
1230
1250
  try {
1231
- v = a.data.value === null ? null : D(a.data.value);
1251
+ v = o.data.value === null ? null : D(o.data.value);
1232
1252
  } catch (h) {
1233
- o("error", { message: `Invalid program information: ${String(h)}` });
1253
+ n("error", { message: `Invalid program information: ${String(h)}` });
1234
1254
  return;
1235
1255
  }
1236
1256
  for (const h of E) queueMicrotask(h);
1237
1257
  return;
1238
1258
  }
1239
- if (a.data.event === "application-information") {
1259
+ if (o.data.event === "application-information") {
1240
1260
  try {
1241
- const h = c.updateApplicationInformation(
1242
- a.data.value ?? {}
1261
+ const h = l.updateApplicationInformation(
1262
+ o.data.value ?? {}
1243
1263
  );
1244
- s.schedule(), h || o("application-boundary-exit", { url: A.location.href });
1264
+ V.schedule(), h || n("application-boundary-exit", { url: A.location.href });
1245
1265
  } catch (h) {
1246
- o("error", { message: `Invalid application information: ${String(h)}` });
1266
+ n("error", { message: `Invalid application information: ${String(h)}` });
1247
1267
  }
1248
1268
  return;
1249
1269
  }
1250
- if (a.data.event === "receiver-input-state") {
1251
- c.setHostInputActive(!!a.data.active);
1270
+ if (o.data.event === "receiver-input-state") {
1271
+ l.setHostInputActive(!!o.data.active);
1252
1272
  return;
1253
1273
  }
1254
- if (a.data.event === "resource-change") {
1255
- const h = a.data.change;
1256
- (h === "updated" || h === "deleted") && f.change(String(a.data.path ?? ""), h);
1274
+ if (o.data.event === "resource-change") {
1275
+ const h = o.data.change;
1276
+ (h === "updated" || h === "deleted") && f.change(String(o.data.path ?? ""), h);
1257
1277
  return;
1258
1278
  }
1259
- if (a.data.event === "stream-event") {
1260
- const h = a.data.value;
1279
+ if (o.data.event === "stream-event") {
1280
+ const h = o.data.value;
1261
1281
  for (const T of [...y])
1262
1282
  Wq(h, T.selector) && T.callback(h);
1263
1283
  }
@@ -1269,35 +1289,35 @@ function Ae(A, q) {
1269
1289
  );
1270
1290
  Qq(A.localStorage, p), P(A.navigator, "receiverDevice", {
1271
1291
  confirmIPNetwork: () => q.allowExternalNetwork ?? !1,
1272
- getSystemInformation: () => (V(m.broadcastResources), { ...p }),
1273
- getDeviceIdentifier: (a, h) => {
1274
- V(m.deviceIdentifier), queueMicrotask(() => {
1275
- Gq(a, q.getDeviceIdentifier).then(
1292
+ getSystemInformation: () => (s(m.broadcastResources), { ...p }),
1293
+ getDeviceIdentifier: (o, h) => {
1294
+ s(m.deviceIdentifier), queueMicrotask(() => {
1295
+ Gq(o, q.getDeviceIdentifier).then(
1276
1296
  h,
1277
1297
  () => h("")
1278
1298
  );
1279
1299
  });
1280
1300
  },
1281
- getCurrentEventInformation: (a) => {
1282
- V(m.currentEventInformation), queueMicrotask(() => a(v ? D(v) : null));
1301
+ getCurrentEventInformation: (o) => {
1302
+ s(m.currentEventInformation), queueMicrotask(() => o(v ? D(v) : null));
1283
1303
  },
1284
1304
  cacheEvent: {
1285
- addCacheEventListener: (a, h) => (V(m.broadcastResources), f.addListener(a, h)),
1286
- storeDataResource: (a, h) => (V(m.broadcastResources), f.store(a, h)),
1287
- releaseDataResource: (a) => (V(m.broadcastResources), f.release(a)),
1288
- removeCacheEventListener: (a, h) => (V(m.broadcastResources), f.removeListener(a, h))
1305
+ addCacheEventListener: (o, h) => (s(m.broadcastResources), f.addListener(o, h)),
1306
+ storeDataResource: (o, h) => (s(m.broadcastResources), f.store(o, h)),
1307
+ releaseDataResource: (o) => (s(m.broadcastResources), f.release(o)),
1308
+ removeCacheEventListener: (o, h) => (s(m.broadcastResources), f.removeListener(o, h))
1289
1309
  },
1290
1310
  streamEvent: {
1291
- addGeneralEventMessageListener: (a, h) => (V(m.broadcastResources), typeof h != "function" ? !1 : (y.add({ selector: a, callback: h }), !0)),
1292
- removeGeneralEventMessageListener: (a, h) => {
1293
- if (V(m.broadcastResources), !a)
1311
+ addGeneralEventMessageListener: (o, h) => (s(m.broadcastResources), typeof h != "function" ? !1 : (y.add({ selector: o, callback: h }), !0)),
1312
+ removeGeneralEventMessageListener: (o, h) => {
1313
+ if (s(m.broadcastResources), !o)
1294
1314
  return y.clear(), !0;
1295
1315
  for (const T of [...y])
1296
- Jq(T.selector, a) && (!h || h === T.callback) && y.delete(T);
1316
+ Jq(T.selector, o) && (!h || h === T.callback) && y.delete(T);
1297
1317
  return !0;
1298
1318
  },
1299
- addEventIDUpdateListener: (a) => (V(m.broadcastResources), typeof a != "function" ? !1 : (E.add(a), !0)),
1300
- removeEventIDUpdateListener: (a) => (V(m.broadcastResources), a ? E.delete(a) : E.clear(), !0)
1319
+ addEventIDUpdateListener: (o) => (s(m.broadcastResources), typeof o != "function" ? !1 : (E.add(o), !0)),
1320
+ removeEventIDUpdateListener: (o) => (s(m.broadcastResources), o ? E.delete(o) : E.clear(), !0)
1301
1321
  }
1302
1322
  }), P(A.navigator, "bmlCompat", {
1303
1323
  browserPseudo: {
@@ -1308,41 +1328,41 @@ function Ae(A, q) {
1308
1328
  // Older broadcaster applications use the synchronous BML API instead
1309
1329
  // of receiverDevice.getDeviceIdentifier(). Keep both paths on the same
1310
1330
  // stable demo ACAS identifier.
1311
- getIRDID: (a) => (V(m.deviceIdentifier), Pq(a)),
1312
- readPersistentArray: (a, h) => {
1313
- V(m.persistentStorage);
1314
- const T = A.localStorage.getItem(`arib:nvram:${a}`);
1331
+ getIRDID: (o) => (s(m.deviceIdentifier), Pq(o)),
1332
+ readPersistentArray: (o, h) => {
1333
+ s(m.persistentStorage);
1334
+ const T = A.localStorage.getItem(`arib:nvram:${o}`);
1315
1335
  if (T) {
1316
1336
  const k = JSON.parse(T);
1317
1337
  return h.split(",").map((w) => k[w] ?? null);
1318
1338
  }
1319
- return Iq(a, h, p);
1339
+ return Iq(o, h, p);
1320
1340
  },
1321
- writePersistentArray: (a, h, T) => {
1322
- V(m.persistentStorage);
1341
+ writePersistentArray: (o, h, T) => {
1342
+ s(m.persistentStorage);
1323
1343
  const k = Object.fromEntries(
1324
1344
  h.split(",").map((w, W) => [w, T[W]])
1325
1345
  );
1326
- return A.localStorage.setItem(`arib:nvram:${a}`, JSON.stringify(k)), T.length;
1346
+ return A.localStorage.setItem(`arib:nvram:${o}`, JSON.stringify(k)), T.length;
1327
1347
  }
1328
1348
  }
1329
- }), s = new Xq({
1349
+ }), V = new Xq({
1330
1350
  target: A,
1331
1351
  adapter: q.mediaPlaneAdapter,
1332
- canUseBroadcastMedia: () => c.permits(
1352
+ canUseBroadcastMedia: () => l.permits(
1333
1353
  m.broadcastMedia
1334
1354
  ),
1335
1355
  installBroadcastObjectApi: M.installBroadcastObjectApi,
1336
- postRuntime: o
1356
+ postRuntime: n
1337
1357
  });
1338
1358
  const g = () => {
1339
- c.startDocument(), s.startDocument();
1359
+ te(A), l.startDocument(), V.startDocument();
1340
1360
  };
1341
- o("installed", { url: A.location.href }), A.document.readyState === "loading" ? A.document.addEventListener("DOMContentLoaded", g, { once: !0 }) : queueMicrotask(g), c.startNavigationCapture(), s.startObserving(), A.addEventListener("pagehide", () => {
1342
- s.dispose("document-unload", () => f.dispose()), c.dispose(), e?.(), o("unloading", { url: A.location.href });
1343
- }), A.addEventListener("error", (a) => {
1344
- o("error", {
1345
- message: a.message
1361
+ n("installed", { url: A.location.href }), A.document.readyState === "loading" ? A.document.addEventListener("DOMContentLoaded", g, { once: !0 }) : queueMicrotask(g), l.startNavigationCapture(), V.startObserving(), A.addEventListener("pagehide", () => {
1362
+ V.dispose("document-unload", () => f.dispose()), l.dispose(), e?.(), n("unloading", { url: A.location.href });
1363
+ }), A.addEventListener("error", (o) => {
1364
+ n("error", {
1365
+ message: o.message
1346
1366
  });
1347
1367
  });
1348
1368
  }
@@ -1386,7 +1406,7 @@ class fe {
1386
1406
  })) : this.media.remove();
1387
1407
  }
1388
1408
  }
1389
- class ie {
1409
+ class re {
1390
1410
  renderMode = "external";
1391
1411
  surface;
1392
1412
  keepVisible;
@@ -1428,35 +1448,35 @@ class ie {
1428
1448
  });
1429
1449
  }
1430
1450
  }
1431
- function re(A, q) {
1451
+ function ne(A, q) {
1432
1452
  const e = A.contentWindow;
1433
1453
  if (!e || !Number.isInteger(q)) return !1;
1434
1454
  try {
1435
1455
  const t = e, i = e.document, r = i.activeElement ?? i.body ?? i.documentElement ?? i;
1436
- for (const n of ["keydown", "keyup"]) {
1437
- const o = new t.KeyboardEvent(n, {
1456
+ for (const a of ["keydown", "keyup"]) {
1457
+ const n = new t.KeyboardEvent(a, {
1438
1458
  bubbles: !0,
1439
1459
  cancelable: !0,
1440
1460
  view: e
1441
1461
  });
1442
- Object.defineProperties(o, {
1462
+ Object.defineProperties(n, {
1443
1463
  keyCode: { value: q },
1444
1464
  which: { value: q }
1445
- }), r.dispatchEvent(o);
1465
+ }), r.dispatchEvent(n);
1446
1466
  }
1447
1467
  return !0;
1448
1468
  } catch {
1449
1469
  return !1;
1450
1470
  }
1451
1471
  }
1452
- function ne(A) {
1472
+ function oe(A) {
1453
1473
  return {
1454
1474
  ...A,
1455
1475
  program: A.program ? D(A.program) : void 0
1456
1476
  };
1457
1477
  }
1458
- async function oe(A, q, e) {
1459
- const t = ne(A);
1478
+ async function ae(A, q, e) {
1479
+ const t = oe(A);
1460
1480
  if (!q)
1461
1481
  return e?.({ request: t, reason: "unsupported" }), !1;
1462
1482
  try {
@@ -1465,7 +1485,7 @@ async function oe(A, q, e) {
1465
1485
  return e?.({ request: t, reason: "error", error: i }), !1;
1466
1486
  }
1467
1487
  }
1468
- class ae {
1488
+ class se {
1469
1489
  state = {
1470
1490
  visible: !0,
1471
1491
  inputActive: !1
@@ -1498,18 +1518,18 @@ class ae {
1498
1518
  return this.delivered.has(e) ? null : (this.delivered.add(e), { ...q, requiresUserAction: !0 });
1499
1519
  }
1500
1520
  }
1501
- function se(A) {
1521
+ function Ve(A) {
1502
1522
  const q = Number(A.width), e = Number(A.height);
1503
1523
  return !Number.isSafeInteger(q) || q <= 0 || !Number.isSafeInteger(e) || e <= 0 ? null : { width: q, height: e };
1504
1524
  }
1505
- function Ve(A) {
1525
+ function le(A) {
1506
1526
  const q = String(A ?? "");
1507
1527
  return q && q !== "rgba(0, 0, 0, 0)" && q !== "transparent" ? q : null;
1508
1528
  }
1509
- function le(A) {
1529
+ function ce(A) {
1510
1530
  return Array.isArray(A) ? [...new Set(A.map(Number).filter((q) => Number.isInteger(q) && q >= 0 && q <= 65535))] : [];
1511
1531
  }
1512
- function ce(A) {
1532
+ function de(A) {
1513
1533
  const q = Number(A.organizationId), e = Number(A.applicationId), t = {
1514
1534
  organizationId: q,
1515
1535
  applicationId: e,
@@ -1527,7 +1547,7 @@ function K(A) {
1527
1547
  externalPlacement: q.externalPlacement === "above-application" ? "above-application" : "behind-application"
1528
1548
  };
1529
1549
  }
1530
- function de(A, q) {
1550
+ function he(A, q) {
1531
1551
  return A.visible ? {
1532
1552
  slotId: String(A.slotId ?? ""),
1533
1553
  visible: !0,
@@ -1552,16 +1572,16 @@ function de(A, q) {
1552
1572
  layer: K(A.layer)
1553
1573
  };
1554
1574
  }
1555
- function he(A) {
1575
+ function ue(A) {
1556
1576
  if (A === null) return null;
1557
1577
  if (!Number.isInteger(A) || A < 0 || A > 16777215)
1558
1578
  throw new RangeError("LCT backgroundColorRgb must be a 24-bit integer or null");
1559
1579
  return `#${A.toString(16).padStart(6, "0")}`;
1560
1580
  }
1561
- function ue(A, q) {
1581
+ function ge(A, q) {
1562
1582
  return A ?? q ?? "#000";
1563
1583
  }
1564
- class ge {
1584
+ class pe {
1565
1585
  iframe;
1566
1586
  viewport;
1567
1587
  resizeObserver;
@@ -1578,7 +1598,7 @@ class ge {
1578
1598
  return { width: this.logicalWidth, height: this.logicalHeight };
1579
1599
  }
1580
1600
  setLctBackgroundColor(q) {
1581
- this.lctBackgroundColor = he(q), this.applyBackgroundColor();
1601
+ this.lctBackgroundColor = ue(q), this.applyBackgroundColor();
1582
1602
  }
1583
1603
  setStageBackgroundColor(q) {
1584
1604
  this.stageBackgroundColor = q, this.applyBackgroundColor();
@@ -1600,13 +1620,13 @@ class ge {
1600
1620
  this.resizeObserver.disconnect();
1601
1621
  }
1602
1622
  applyBackgroundColor() {
1603
- this.viewport.style.backgroundColor = ue(
1623
+ this.viewport.style.backgroundColor = ge(
1604
1624
  this.lctBackgroundColor,
1605
1625
  this.stageBackgroundColor
1606
1626
  );
1607
1627
  }
1608
1628
  }
1609
- class pe {
1629
+ class ye {
1610
1630
  ownerWindow;
1611
1631
  iframe;
1612
1632
  origin;
@@ -1701,7 +1721,7 @@ class Te {
1701
1721
  bmlGreg;
1702
1722
  userAgent;
1703
1723
  onViewerParticipation;
1704
- viewerParticipation = new ae();
1724
+ viewerParticipation = new se();
1705
1725
  canvas;
1706
1726
  runtimeSession;
1707
1727
  captionComponentTags = [];
@@ -1715,7 +1735,7 @@ class Te {
1715
1735
  constructor(q) {
1716
1736
  if (this.iframe = q.iframe, this.viewport = q.viewport, this.videoSurface = q.videoSurface, Z(this.iframe), this.ownerWindow = this.iframe.ownerDocument.defaultView ?? window, this.origin = this.ownerWindow.location.origin, this.onStatus = q.onStatus, this.onLifecycle = q.onLifecycle, this.applicationLoadTimeoutMs = q.applicationLoadTimeoutMs ?? 5e3, !Number.isFinite(this.applicationLoadTimeoutMs) || this.applicationLoadTimeoutMs < 0)
1717
1737
  throw new TypeError("applicationLoadTimeoutMs must be a finite non-negative number");
1718
- this.onUrlChange = q.onUrlChange, this.onMediaPlane = q.onMediaPlane, this.onVideoPlane = q.onVideoPlane, this.mediaPlaneAdapter = q.mediaPlaneAdapter ?? (q.videoSurface ? new ie({
1738
+ this.onUrlChange = q.onUrlChange, this.onMediaPlane = q.onMediaPlane, this.onVideoPlane = q.onVideoPlane, this.mediaPlaneAdapter = q.mediaPlaneAdapter ?? (q.videoSurface ? new re({
1719
1739
  surface: q.videoSurface,
1720
1740
  keepVisible: q.keepVideoVisible
1721
1741
  }) : void 0);
@@ -1736,10 +1756,10 @@ class Te {
1736
1756
  this.ownerWindow.location.href
1737
1757
  ), this.broadcastBaseUrl.origin !== this.origin)
1738
1758
  throw new Error(`Broadcast base URL must be same-origin: ${this.broadcastBaseUrl.href}`);
1739
- this.resourceStore = q.resourceStore, this.onOpenProgramGuide = q.onOpenProgramGuide, this.onCaptionSubscription = q.onCaptionSubscription, this.onReplaceApplication = q.onReplaceApplication, this.onExitManagedState = q.onExitManagedState, this.onLaunchDataBroadcastingBrowser = q.onLaunchDataBroadcastingBrowser, this.onProgramGuideUnavailable = q.onProgramGuideUnavailable, this.systemInformation = q.systemInformation, this.getDeviceIdentifier = q.getDeviceIdentifier, this.bmlGreg = [...q.bmlGreg ?? []], this.userAgent = q.userAgent, this.onViewerParticipation = q.onViewerParticipation, this.ownerWindow.addEventListener("message", this.handleRuntimeMessage), this.iframe.addEventListener("load", this.handleFrameLoad), this.canvas = new ge({
1759
+ this.resourceStore = q.resourceStore, this.onOpenProgramGuide = q.onOpenProgramGuide, this.onCaptionSubscription = q.onCaptionSubscription, this.onReplaceApplication = q.onReplaceApplication, this.onExitManagedState = q.onExitManagedState, this.onLaunchDataBroadcastingBrowser = q.onLaunchDataBroadcastingBrowser, this.onProgramGuideUnavailable = q.onProgramGuideUnavailable, this.systemInformation = q.systemInformation, this.getDeviceIdentifier = q.getDeviceIdentifier, this.bmlGreg = [...q.bmlGreg ?? []], this.userAgent = q.userAgent, this.onViewerParticipation = q.onViewerParticipation, this.ownerWindow.addEventListener("message", this.handleRuntimeMessage), this.iframe.addEventListener("load", this.handleFrameLoad), this.canvas = new pe({
1740
1760
  iframe: this.iframe,
1741
1761
  viewport: this.viewport
1742
- }), this.runtimeSession = new pe({
1762
+ }), this.runtimeSession = new ye({
1743
1763
  ownerWindow: this.ownerWindow,
1744
1764
  iframe: this.iframe,
1745
1765
  origin: this.origin,
@@ -1748,7 +1768,7 @@ class Te {
1748
1768
  });
1749
1769
  }
1750
1770
  installRuntime(q) {
1751
- this.mediaPlaneEnabled = !this.destroyed && !this.applicationExited, te(q, {
1771
+ this.mediaPlaneEnabled = !this.destroyed && !this.applicationExited, Ae(q, {
1752
1772
  allowExternalNetwork: this.allowExternalNetwork,
1753
1773
  broadcastBaseUrl: this.broadcastBaseUrl.href,
1754
1774
  resourceStore: this.resourceStore,
@@ -1803,7 +1823,7 @@ class Te {
1803
1823
  this.assertAlive(), !this.applicationExited && (this.applicationExited = !0, this.viewerParticipation.setPresentation({ visible: !1, inputActive: !1 }), this.runtimeSession.clearPendingStreamEvents(), this.runtimeSession.clearWatchdog(), this.invalidateRuntime("application-exit"), this.iframe.style.display = "none", this.iframe.src = "about:blank", this.onUrlChange?.(""), this.onStatus?.(q), this.onLifecycle?.({ type: "exited" }));
1804
1824
  }
1805
1825
  dispatchKey(q) {
1806
- return this.assertAlive(), this.viewerParticipation.presentation.inputActive ? re(this.iframe, q) ? !0 : (this.onStatus?.("キー入力を送信できません"), !1) : !1;
1826
+ return this.assertAlive(), this.viewerParticipation.presentation.inputActive ? ne(this.iframe, q) ? !0 : (this.onStatus?.("キー入力を送信できません"), !1) : !1;
1807
1827
  }
1808
1828
  /** Transfer or release receiver-key ownership for the broadcast application. */
1809
1829
  setApplicationInputActive(q) {
@@ -1851,7 +1871,7 @@ class Te {
1851
1871
  openProgramGuide(q = {
1852
1872
  destination: "program-guide"
1853
1873
  }) {
1854
- return this.assertAlive(), oe(
1874
+ return this.assertAlive(), ae(
1855
1875
  q,
1856
1876
  this.onOpenProgramGuide,
1857
1877
  this.reportProgramGuideUnavailable
@@ -1964,12 +1984,12 @@ class Te {
1964
1984
  return;
1965
1985
  case "stage-style": {
1966
1986
  this.canvas.setStageBackgroundColor(
1967
- Ve(e.backgroundColor)
1987
+ le(e.backgroundColor)
1968
1988
  );
1969
1989
  return;
1970
1990
  }
1971
1991
  case "screen-size": {
1972
- const t = se(e);
1992
+ const t = Ve(e);
1973
1993
  t && this.canvas.applyScreenSize(t.width, t.height);
1974
1994
  return;
1975
1995
  }
@@ -1978,7 +1998,7 @@ class Te {
1978
1998
  this.applyMediaPlane(e);
1979
1999
  return;
1980
2000
  case "caption-subscription": {
1981
- const t = le(e.componentTags);
2001
+ const t = ce(e.componentTags);
1982
2002
  this.onCaptionSubscription?.({ componentTags: t });
1983
2003
  return;
1984
2004
  }
@@ -1989,7 +2009,7 @@ class Te {
1989
2009
  });
1990
2010
  return;
1991
2011
  case "replace-application": {
1992
- const t = ce(e);
2012
+ const t = de(e);
1993
2013
  if (!t) {
1994
2014
  this.onStatus?.("不正なアプリケーション切替要求を拒否しました");
1995
2015
  return;
@@ -2036,7 +2056,7 @@ class Te {
2036
2056
  }
2037
2057
  };
2038
2058
  applyMediaPlane(q) {
2039
- const e = this.canvas.logicalSize, t = de(q, {
2059
+ const e = this.canvas.logicalSize, t = he(q, {
2040
2060
  screenWidth: e.width,
2041
2061
  screenHeight: e.height
2042
2062
  });
@@ -2065,11 +2085,8 @@ class Te {
2065
2085
  function U(A) {
2066
2086
  return `/${(A || "/data-broadcast/").replace(/^\/+|\/+$/g, "")}/`;
2067
2087
  }
2068
- function ye(A) {
2069
- return A.replace(/<object\b[^>]*>/gi, (q) => /\btype\s*=\s*(?:["']video\/x-arib2-broadcast["']|video\/x-arib2-broadcast)(?:\s|\/?>)/i.test(q) ? q.replace(
2070
- /\s+type\s*=\s*(?:["']video\/x-arib2-broadcast["']|video\/x-arib2-broadcast)/i,
2071
- ' data-arib-type="video/x-arib2-broadcast"'
2072
- ).replace(/\s+data\s*=\s*(["'])(.*?)\1/i, " data-arib-data=$1$2$1") : q);
2088
+ function Be(A) {
2089
+ return A;
2073
2090
  }
2074
2091
  function G(A, q, e) {
2075
2092
  if (A.startsWith(e)) return A;
@@ -2080,27 +2097,27 @@ function Ee(A, q, e) {
2080
2097
  const t = U(q), i = U(e ?? q);
2081
2098
  return A.replace(
2082
2099
  /(\b(?:href|src|action|poster)\s*=\s*)(?:(['"])(\/[^/][^"']*)\2|(\/[^\s>]*))/gi,
2083
- (r, n, o, c, V) => {
2084
- const y = c ?? V;
2100
+ (r, a, n, l, s) => {
2101
+ const y = l ?? s;
2085
2102
  if (!y || y.startsWith(t)) return r;
2086
2103
  const E = G(y, t, i);
2087
- return o ? `${n}${o}${E}${o}` : `${n}${E}`;
2104
+ return n ? `${a}${n}${E}${n}` : `${a}${E}`;
2088
2105
  }
2089
2106
  );
2090
2107
  }
2091
- function Be(A, q = {}) {
2108
+ function ve(A, q = {}) {
2092
2109
  const e = U(q.basePath), t = U(q.scopePath ?? q.basePath);
2093
2110
  return A.replace(
2094
2111
  /url\(\s*(["']?)(\/[^/)][^)]*)\1\s*\)/gi,
2095
- (i, r, n) => n.startsWith(e) ? i : `url(${r}${G(n, e, t)}${r})`
2112
+ (i, r, a) => a.startsWith(e) ? i : `url(${r}${G(a, e, t)}${r})`
2096
2113
  ).replace(
2097
2114
  /(@import\s+)(["'])(\/[^/][^"']*)\2/gi,
2098
- (i, r, n, o) => o.startsWith(e) ? i : `${r}${n}${G(o, e, t)}${n}`
2115
+ (i, r, a, n) => n.startsWith(e) ? i : `${r}${a}${G(n, e, t)}${a}`
2099
2116
  );
2100
2117
  }
2101
- function ve(A, q = {}) {
2118
+ function Me(A, q = {}) {
2102
2119
  const e = Ee(
2103
- C(ye(A)),
2120
+ C(A),
2104
2121
  q.basePath,
2105
2122
  q.scopePath
2106
2123
  );
@@ -2118,7 +2135,7 @@ function me(A) {
2118
2135
  data: q.slice()
2119
2136
  };
2120
2137
  }
2121
- class Me {
2138
+ class be {
2122
2139
  backend;
2123
2140
  onError;
2124
2141
  scheduleTask;
@@ -2200,7 +2217,7 @@ class Me {
2200
2217
  this.completedRevision >= e.revision ? e.resolve() : this.waiters.push(e);
2201
2218
  }
2202
2219
  }
2203
- class be {
2220
+ class ke {
2204
2221
  workerUrl;
2205
2222
  scopeUrl;
2206
2223
  uniqueBasenameFallback;
@@ -2280,13 +2297,13 @@ class be {
2280
2297
  async performRequestWithRegistration(q, e, t = []) {
2281
2298
  const i = q.active ?? q.waiting ?? q.installing;
2282
2299
  if (!i) throw new Error("Broadcast VFS worker is unavailable");
2283
- return new Promise((r, n) => {
2284
- const o = new MessageChannel(), c = window.setTimeout(() => {
2285
- o.port1.close(), n(new Error("Broadcast VFS worker did not respond"));
2300
+ return new Promise((r, a) => {
2301
+ const n = new MessageChannel(), l = window.setTimeout(() => {
2302
+ n.port1.close(), a(new Error("Broadcast VFS worker did not respond"));
2286
2303
  }, 5e3);
2287
- o.port1.onmessage = (V) => {
2288
- window.clearTimeout(c), o.port1.close(), V.data?.ok ? r(V.data) : n(new Error(V.data?.error || "Broadcast VFS worker error"));
2289
- }, i.postMessage(e, [o.port2, ...t]);
2304
+ n.port1.onmessage = (s) => {
2305
+ window.clearTimeout(l), n.port1.close(), s.data?.ok ? r(s.data) : a(new Error(s.data?.error || "Broadcast VFS worker error"));
2306
+ }, i.postMessage(e, [n.port2, ...t]);
2290
2307
  });
2291
2308
  }
2292
2309
  waitForActivation(q) {
@@ -2302,16 +2319,16 @@ class be {
2302
2319
  }
2303
2320
  export {
2304
2321
  m as ARIB_PERMISSION_BITS,
2305
- Oq as AribApplicationBoundaryPolicy,
2322
+ Nq as AribApplicationBoundaryPolicy,
2306
2323
  Te as AribReceiverHost,
2307
- ie as BehindIframeMediaPlaneAdapter,
2308
- Me as BroadcastVfsSession,
2324
+ re as BehindIframeMediaPlaneAdapter,
2325
+ be as BroadcastVfsSession,
2309
2326
  Tq as DEFAULT_BROADCAST_BASE_PATH,
2310
2327
  Y as DEFAULT_RECEIVER_DEVICE_IDENTIFIER,
2311
2328
  fe as DomObjectMediaPlaneAdapter,
2312
2329
  Fq as RECEIVER_IRD_ID_TYPE,
2313
2330
  Rq as RECEIVER_SYSTEM_IDENTITY,
2314
- be as ServiceWorkerBroadcastVfs,
2331
+ ke as ServiceWorkerBroadcastVfs,
2315
2332
  D as cloneProgramInfo,
2316
2333
  Sq as createReceiverSystemInformation,
2317
2334
  C as deferRomSoundMarkup,
@@ -2320,17 +2337,17 @@ export {
2320
2337
  mq as installAribSymbolFont,
2321
2338
  fq as installBroadcastClock,
2322
2339
  uq as installRomSoundProtocol,
2323
- te as installRuntime,
2340
+ Ae as installRuntime,
2324
2341
  z as normalizeBroadcastBaseUrl,
2325
- he as normalizeLctBackgroundColor,
2342
+ ue as normalizeLctBackgroundColor,
2326
2343
  Ee as prefixBroadcastRootAttributes,
2327
- ve as prepareBroadcastHtml,
2328
- Be as prepareBroadcastStylesheet,
2344
+ Me as prepareBroadcastHtml,
2345
+ ve as prepareBroadcastStylesheet,
2329
2346
  Iq as readReceiverInformationArray,
2330
2347
  H as resolveBroadcastUrl,
2331
2348
  Gq as resolveReceiverDeviceIdentifier,
2332
2349
  R as resolveRomSoundUrl,
2333
- ye as rewriteBroadcastObjectMarkup,
2350
+ Be as rewriteBroadcastObjectMarkup,
2334
2351
  Wq as runtimeEventMatchesSelector,
2335
2352
  Qq as synchronizeReceiverCompatibilityStorage
2336
2353
  };