@mattebox/player 0.14.0 → 0.15.0

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 (279) hide show
  1. package/dist/cdn/mattebox-player.min.js +3 -3
  2. package/dist/controls/chapters.js +1 -1
  3. package/dist/controls/chapters.js.map +1 -1
  4. package/dist/controls/cues.js.map +1 -1
  5. package/dist/controls/native-tracks.js +1 -1
  6. package/dist/controls/native-tracks.js.map +1 -1
  7. package/dist/element-entry.d.ts +1 -0
  8. package/dist/element-entry.d.ts.map +1 -1
  9. package/dist/element-entry.js.map +1 -1
  10. package/dist/element.d.ts +49 -3
  11. package/dist/element.d.ts.map +1 -1
  12. package/dist/element.js +196 -36
  13. package/dist/element.js.map +1 -1
  14. package/dist/elements/airplay-button.js +1 -1
  15. package/dist/elements/airplay-button.js.map +1 -1
  16. package/dist/elements/audio-menu.d.ts.map +1 -1
  17. package/dist/elements/audio-menu.js +4 -3
  18. package/dist/elements/audio-menu.js.map +1 -1
  19. package/dist/elements/casting.d.ts +12 -0
  20. package/dist/elements/casting.d.ts.map +1 -0
  21. package/dist/elements/casting.js +58 -0
  22. package/dist/elements/casting.js.map +1 -0
  23. package/dist/elements/chapters-menu.js +5 -5
  24. package/dist/elements/chapters-menu.js.map +1 -1
  25. package/dist/elements/component.d.ts +13 -0
  26. package/dist/elements/component.d.ts.map +1 -1
  27. package/dist/elements/component.js +21 -3
  28. package/dist/elements/component.js.map +1 -1
  29. package/dist/elements/control-bar.d.ts.map +1 -1
  30. package/dist/elements/control-bar.js +7 -6
  31. package/dist/elements/control-bar.js.map +1 -1
  32. package/dist/elements/current-time.js +2 -2
  33. package/dist/elements/current-time.js.map +1 -1
  34. package/dist/elements/drm-badge.js +1 -1
  35. package/dist/elements/drm-badge.js.map +1 -1
  36. package/dist/elements/duration.js +3 -3
  37. package/dist/elements/duration.js.map +1 -1
  38. package/dist/elements/error-screen.js +1 -1
  39. package/dist/elements/error-screen.js.map +1 -1
  40. package/dist/elements/fullscreen-button.d.ts.map +1 -1
  41. package/dist/elements/fullscreen-button.js +3 -2
  42. package/dist/elements/fullscreen-button.js.map +1 -1
  43. package/dist/elements/live-button.js +2 -2
  44. package/dist/elements/live-button.js.map +1 -1
  45. package/dist/elements/marker-button.js +3 -3
  46. package/dist/elements/marker-button.js.map +1 -1
  47. package/dist/elements/menu-element.js +3 -3
  48. package/dist/elements/menu-element.js.map +1 -1
  49. package/dist/elements/mute-button.js +3 -3
  50. package/dist/elements/mute-button.js.map +1 -1
  51. package/dist/elements/pip-button.d.ts.map +1 -1
  52. package/dist/elements/pip-button.js +6 -2
  53. package/dist/elements/pip-button.js.map +1 -1
  54. package/dist/elements/play-button.js +3 -3
  55. package/dist/elements/play-button.js.map +1 -1
  56. package/dist/elements/quality-menu.d.ts.map +1 -1
  57. package/dist/elements/quality-menu.js +5 -4
  58. package/dist/elements/quality-menu.js.map +1 -1
  59. package/dist/elements/remaining-time.js +2 -2
  60. package/dist/elements/remaining-time.js.map +1 -1
  61. package/dist/elements/scan-button.d.ts.map +1 -1
  62. package/dist/elements/scan-button.js +4 -3
  63. package/dist/elements/scan-button.js.map +1 -1
  64. package/dist/elements/seek-bar.d.ts.map +1 -1
  65. package/dist/elements/seek-bar.js +20 -16
  66. package/dist/elements/seek-bar.js.map +1 -1
  67. package/dist/elements/shared.js +3 -3
  68. package/dist/elements/shared.js.map +1 -1
  69. package/dist/elements/skip-button.js +2 -2
  70. package/dist/elements/skip-button.js.map +1 -1
  71. package/dist/elements/spacer.js.map +1 -1
  72. package/dist/elements/speed-menu.d.ts.map +1 -1
  73. package/dist/elements/speed-menu.js +4 -3
  74. package/dist/elements/speed-menu.js.map +1 -1
  75. package/dist/elements/spinner.js +1 -1
  76. package/dist/elements/spinner.js.map +1 -1
  77. package/dist/elements/start-button.js +3 -3
  78. package/dist/elements/start-button.js.map +1 -1
  79. package/dist/elements/subtitles-menu.d.ts.map +1 -1
  80. package/dist/elements/subtitles-menu.js +5 -4
  81. package/dist/elements/subtitles-menu.js.map +1 -1
  82. package/dist/elements/time-element.js +1 -1
  83. package/dist/elements/time-element.js.map +1 -1
  84. package/dist/elements/title.js +1 -1
  85. package/dist/elements/title.js.map +1 -1
  86. package/dist/elements/video-menu.d.ts.map +1 -1
  87. package/dist/elements/video-menu.js +5 -4
  88. package/dist/elements/video-menu.js.map +1 -1
  89. package/dist/elements/volume-slider.js +4 -4
  90. package/dist/elements/volume-slider.js.map +1 -1
  91. package/dist/elements/volume.js.map +1 -1
  92. package/dist/entries/airplay-button.js +1 -1
  93. package/dist/entries/audio-menu.js +1 -1
  94. package/dist/entries/casting.d.ts +5 -0
  95. package/dist/entries/casting.d.ts.map +1 -0
  96. package/dist/entries/casting.js +8 -0
  97. package/dist/entries/casting.js.map +1 -0
  98. package/dist/entries/chapters-menu.js +1 -1
  99. package/dist/entries/control-bar.js +1 -1
  100. package/dist/entries/current-time.js +1 -1
  101. package/dist/entries/drm-badge.js +1 -1
  102. package/dist/entries/duration.js +1 -1
  103. package/dist/entries/error-screen.js +1 -1
  104. package/dist/entries/fullscreen-button.js +1 -1
  105. package/dist/entries/live-button.js +1 -1
  106. package/dist/entries/marker-button.js +1 -1
  107. package/dist/entries/mute-button.js +1 -1
  108. package/dist/entries/pip-button.js +1 -1
  109. package/dist/entries/play-button.js +1 -1
  110. package/dist/entries/quality-menu.js +1 -1
  111. package/dist/entries/remaining-time.js +1 -1
  112. package/dist/entries/scan-button.js +1 -1
  113. package/dist/entries/seek-bar.js +1 -1
  114. package/dist/entries/skip-button.js +1 -1
  115. package/dist/entries/spacer.js +1 -1
  116. package/dist/entries/speed-menu.js +1 -1
  117. package/dist/entries/spinner.js +1 -1
  118. package/dist/entries/start-button.js +1 -1
  119. package/dist/entries/subtitles-menu.js +1 -1
  120. package/dist/entries/title.js +1 -1
  121. package/dist/entries/video-menu.js +1 -1
  122. package/dist/entries/volume-slider.js +1 -1
  123. package/dist/entries/volume.js +1 -1
  124. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.155.0 → _@oxc-project_runtime@0.158.0}/helpers/esm/asyncToGenerator.js +1 -1
  125. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.155.0 → _@oxc-project_runtime@0.158.0}/helpers/esm/defineProperty.js +1 -1
  126. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.155.0 → _@oxc-project_runtime@0.158.0}/helpers/esm/objectSpread2.js +1 -1
  127. package/dist/es2015/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/toPrimitive.js +13 -0
  128. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.155.0 → _@oxc-project_runtime@0.158.0}/helpers/esm/toPropertyKey.js +1 -1
  129. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.155.0 → _@oxc-project_runtime@0.158.0}/helpers/esm/typeof.js +1 -1
  130. package/dist/es2015/controls/chapters.js +2 -2
  131. package/dist/es2015/controls/menu.js +1 -1
  132. package/dist/es2015/controls/native-tracks.js +1 -1
  133. package/dist/es2015/element.js +213 -44
  134. package/dist/es2015/elements/airplay-button.js +1 -1
  135. package/dist/es2015/elements/audio-menu.js +4 -3
  136. package/dist/es2015/elements/casting.js +57 -0
  137. package/dist/es2015/elements/chapters-menu.js +5 -5
  138. package/dist/es2015/elements/component.js +26 -7
  139. package/dist/es2015/elements/control-bar.js +7 -6
  140. package/dist/es2015/elements/current-time.js +2 -2
  141. package/dist/es2015/elements/drm-badge.js +1 -1
  142. package/dist/es2015/elements/duration.js +3 -3
  143. package/dist/es2015/elements/error-screen.js +1 -1
  144. package/dist/es2015/elements/fullscreen-button.js +3 -2
  145. package/dist/es2015/elements/live-button.js +2 -2
  146. package/dist/es2015/elements/marker-button.js +3 -3
  147. package/dist/es2015/elements/menu-element.js +4 -4
  148. package/dist/es2015/elements/mute-button.js +3 -3
  149. package/dist/es2015/elements/pip-button.js +6 -2
  150. package/dist/es2015/elements/play-button.js +3 -3
  151. package/dist/es2015/elements/quality-menu.js +5 -4
  152. package/dist/es2015/elements/remaining-time.js +2 -2
  153. package/dist/es2015/elements/scan-button.js +4 -3
  154. package/dist/es2015/elements/seek-bar.js +20 -16
  155. package/dist/es2015/elements/shared.js +3 -3
  156. package/dist/es2015/elements/skip-button.js +2 -2
  157. package/dist/es2015/elements/speed-menu.js +4 -3
  158. package/dist/es2015/elements/spinner.js +1 -1
  159. package/dist/es2015/elements/start-button.js +3 -3
  160. package/dist/es2015/elements/subtitles-menu.js +5 -4
  161. package/dist/es2015/elements/time-element.js +1 -1
  162. package/dist/es2015/elements/title.js +1 -1
  163. package/dist/es2015/elements/video-menu.js +5 -4
  164. package/dist/es2015/elements/volume-slider.js +4 -4
  165. package/dist/es2015/entries/airplay-button.js +1 -1
  166. package/dist/es2015/entries/audio-menu.js +1 -1
  167. package/dist/es2015/entries/casting.js +6 -0
  168. package/dist/es2015/entries/chapters-menu.js +1 -1
  169. package/dist/es2015/entries/control-bar.js +1 -1
  170. package/dist/es2015/entries/current-time.js +1 -1
  171. package/dist/es2015/entries/drm-badge.js +1 -1
  172. package/dist/es2015/entries/duration.js +1 -1
  173. package/dist/es2015/entries/error-screen.js +1 -1
  174. package/dist/es2015/entries/fullscreen-button.js +1 -1
  175. package/dist/es2015/entries/live-button.js +1 -1
  176. package/dist/es2015/entries/marker-button.js +1 -1
  177. package/dist/es2015/entries/mute-button.js +1 -1
  178. package/dist/es2015/entries/pip-button.js +1 -1
  179. package/dist/es2015/entries/play-button.js +1 -1
  180. package/dist/es2015/entries/quality-menu.js +1 -1
  181. package/dist/es2015/entries/remaining-time.js +1 -1
  182. package/dist/es2015/entries/scan-button.js +1 -1
  183. package/dist/es2015/entries/seek-bar.js +1 -1
  184. package/dist/es2015/entries/skip-button.js +1 -1
  185. package/dist/es2015/entries/spacer.js +1 -1
  186. package/dist/es2015/entries/speed-menu.js +1 -1
  187. package/dist/es2015/entries/spinner.js +1 -1
  188. package/dist/es2015/entries/start-button.js +1 -1
  189. package/dist/es2015/entries/subtitles-menu.js +1 -1
  190. package/dist/es2015/entries/title.js +1 -1
  191. package/dist/es2015/entries/video-menu.js +1 -1
  192. package/dist/es2015/entries/volume-slider.js +1 -1
  193. package/dist/es2015/entries/volume.js +1 -1
  194. package/dist/es2015/host.js +9 -1
  195. package/dist/es2015/index.js +5 -3
  196. package/dist/es2015/locales/ar.js +2 -1
  197. package/dist/es2015/locales/ca.js +2 -1
  198. package/dist/es2015/locales/de.js +2 -1
  199. package/dist/es2015/locales/es.js +2 -1
  200. package/dist/es2015/locales/fr.js +2 -1
  201. package/dist/es2015/locales/hi.js +2 -1
  202. package/dist/es2015/locales/it.js +2 -1
  203. package/dist/es2015/locales/ja.js +2 -1
  204. package/dist/es2015/locales/ko.js +2 -1
  205. package/dist/es2015/locales/pt.js +2 -1
  206. package/dist/es2015/locales/zh.js +2 -1
  207. package/dist/es2015/locales.js +1 -1
  208. package/dist/es2015/media.js +136 -0
  209. package/dist/es2015/presets.js +1 -1
  210. package/dist/es2015/style.js +1 -1
  211. package/dist/es2015/tags.js +2 -1
  212. package/dist/es2015/video-sources.js +1 -1
  213. package/dist/host.d.ts +19 -1
  214. package/dist/host.d.ts.map +1 -1
  215. package/dist/host.js +9 -1
  216. package/dist/host.js.map +1 -1
  217. package/dist/index.d.ts +4 -0
  218. package/dist/index.d.ts.map +1 -1
  219. package/dist/index.js +5 -3
  220. package/dist/locales/ar.d.ts +1 -0
  221. package/dist/locales/ar.d.ts.map +1 -1
  222. package/dist/locales/ar.js +2 -1
  223. package/dist/locales/ar.js.map +1 -1
  224. package/dist/locales/ca.d.ts +1 -0
  225. package/dist/locales/ca.d.ts.map +1 -1
  226. package/dist/locales/ca.js +2 -1
  227. package/dist/locales/ca.js.map +1 -1
  228. package/dist/locales/de.d.ts +1 -0
  229. package/dist/locales/de.d.ts.map +1 -1
  230. package/dist/locales/de.js +2 -1
  231. package/dist/locales/de.js.map +1 -1
  232. package/dist/locales/es.d.ts +1 -0
  233. package/dist/locales/es.d.ts.map +1 -1
  234. package/dist/locales/es.js +2 -1
  235. package/dist/locales/es.js.map +1 -1
  236. package/dist/locales/fr.d.ts +1 -0
  237. package/dist/locales/fr.d.ts.map +1 -1
  238. package/dist/locales/fr.js +2 -1
  239. package/dist/locales/fr.js.map +1 -1
  240. package/dist/locales/hi.d.ts +1 -0
  241. package/dist/locales/hi.d.ts.map +1 -1
  242. package/dist/locales/hi.js +2 -1
  243. package/dist/locales/hi.js.map +1 -1
  244. package/dist/locales/it.d.ts +1 -0
  245. package/dist/locales/it.d.ts.map +1 -1
  246. package/dist/locales/it.js +2 -1
  247. package/dist/locales/it.js.map +1 -1
  248. package/dist/locales/ja.d.ts +1 -0
  249. package/dist/locales/ja.d.ts.map +1 -1
  250. package/dist/locales/ja.js +2 -1
  251. package/dist/locales/ja.js.map +1 -1
  252. package/dist/locales/ko.d.ts +1 -0
  253. package/dist/locales/ko.d.ts.map +1 -1
  254. package/dist/locales/ko.js +2 -1
  255. package/dist/locales/ko.js.map +1 -1
  256. package/dist/locales/pt.d.ts +1 -0
  257. package/dist/locales/pt.d.ts.map +1 -1
  258. package/dist/locales/pt.js +2 -1
  259. package/dist/locales/pt.js.map +1 -1
  260. package/dist/locales/zh.d.ts +1 -0
  261. package/dist/locales/zh.d.ts.map +1 -1
  262. package/dist/locales/zh.js +2 -1
  263. package/dist/locales/zh.js.map +1 -1
  264. package/dist/media.d.ts +22 -0
  265. package/dist/media.d.ts.map +1 -0
  266. package/dist/media.js +136 -0
  267. package/dist/media.js.map +1 -0
  268. package/dist/messages.d.ts +2 -0
  269. package/dist/messages.d.ts.map +1 -1
  270. package/dist/remote.d.ts +80 -0
  271. package/dist/remote.d.ts.map +1 -0
  272. package/dist/style.js +1 -1
  273. package/dist/style.js.map +1 -1
  274. package/dist/tags.d.ts +1 -0
  275. package/dist/tags.d.ts.map +1 -1
  276. package/dist/tags.js +2 -1
  277. package/dist/tags.js.map +1 -1
  278. package/package.json +2 -2
  279. package/dist/es2015/_virtual/_@oxc-project_runtime@0.155.0/helpers/esm/toPrimitive.js +0 -13
@@ -1,12 +1,12 @@
1
+ import { chapterAt, chapters, followChapters } from "../controls/chapters.js";
2
+ import { EMPTY, at, clip, fraction, spans } from "../controls/ranges.js";
3
+ import { bufferGoal, live, optional, span, wall } from "../controls/session.js";
4
+ import { slider } from "../controls/slider.js";
5
+ import { format } from "../controls/time.js";
1
6
  import { el } from "../dom.js";
2
7
  import { fill } from "../labels.js";
3
8
  import { Component } from "./component.js";
4
9
  import { SLIDER_STYLE, number, seekRow, style } from "./shared.js";
5
- import { EMPTY, at, clip, fraction, spans } from "../controls/ranges.js";
6
- import { format } from "../controls/time.js";
7
- import { bufferGoal, live, optional, span, wall } from "../controls/session.js";
8
- import { chapterAt, chapters, followChapters } from "../controls/chapters.js";
9
- import { slider } from "../controls/slider.js";
10
10
  // src/elements/seek-bar.ts
11
11
  const STYLE_CSS = ":host,[part~=slider]{flex:1}[part~=thumb]{width:1em;height:1em;margin:-.5em 0 0 -.5em;box-shadow:0 1px 3px #0006}[part~=buffered]{position:absolute;top:0;bottom:0;left:0;right:0}[part~=blocked]{pointer-events:none;position:absolute;top:0;bottom:0;left:0;right:0}[part~=blocked-range]{background:var(--mbx-blocked,#000000bf);position:absolute;top:0;bottom:0}[part~=break]{background:var(--mbx-ad,#f5c518);width:.25em;margin-left:-.125em;position:absolute;top:0;bottom:0}[part~=break][part~=span]{margin-left:0}[part~=break][part~=played]{opacity:.4}[part~=buffered-range]{background:#ffffff4d;position:absolute;top:0;bottom:0}[part~=hover]{background:var(--mbx-text);width:.125em;margin-left:-1px;position:absolute;top:0;bottom:0}[part~=edge]{background:var(--mbx-live);width:.125em;margin-left:-1px;position:absolute;top:0;bottom:0}[part~=preview]{background:var(--mbx-surface);border-radius:var(--mbx-radius);font-variant-numeric:tabular-nums;white-space:nowrap;pointer-events:none;flex-direction:column;align-items:center;margin-bottom:.3077em;padding:.1538em;font-size:.8125em;display:flex;position:absolute;bottom:100%;transform:translate(-50%)}[part~=preview]>:not([hidden])~:not([hidden]){margin-top:.125em}[part~=preview-image]{border-radius:2px;position:relative;overflow:hidden}[part~=preview-frame]{border-radius:2px;display:block}[part~=preview-tile]{transform-origin:0 0;background-repeat:no-repeat;position:absolute;top:0;left:0}[part~=preview-time]{padding:0 .3077em}[part~=preview-title]{text-overflow:ellipsis;max-width:18.4615em;padding:0 .3077em;overflow:hidden}[hidden]{display:none}";
12
12
  const STEP = 5;
@@ -187,13 +187,16 @@ var MbxSeekBar = class extends Component {
187
187
  dragStart() {
188
188
  const trick = optional(this.player?.engine ?? null).trick;
189
189
  this.dragged = null;
190
- const before = this.player?.video.paused === false ? "playing" : "paused";
190
+ const before = this.player?.media.paused === false ? "playing" : "paused";
191
191
  this.player?.setAttribute("scrubbing", before);
192
- if (trick?.available === true && this.getAttribute("scrub") !== "false") {
192
+ if (this.remote()) {
193
+ this.resume = false;
194
+ this.drag = "hold";
195
+ } else if (trick?.available === true && this.getAttribute("scrub") !== "false") {
193
196
  trick.scrubStart();
194
197
  this.drag = "scrub";
195
198
  } else {
196
- const video = this.player?.video;
199
+ const video = this.player?.media;
197
200
  this.resume = video !== void 0 && !video.paused;
198
201
  video?.pause();
199
202
  this.drag = "seek";
@@ -223,8 +226,8 @@ var MbxSeekBar = class extends Component {
223
226
  if (value === null) trick?.scrubEnd();
224
227
  else trick?.scrubEnd(value);
225
228
  } else {
226
- if (value !== null && value !== written) player.video.currentTime = value;
227
- if (this.resume) player.video.play().catch(() => void 0);
229
+ if (value !== null && value !== written) player.media.currentTime = value;
230
+ if (this.resume) player.media.play().catch(() => void 0);
228
231
  this.resume = false;
229
232
  }
230
233
  player.removeAttribute("scrubbing");
@@ -270,7 +273,7 @@ var MbxSeekBar = class extends Component {
270
273
  commit() {
271
274
  const target = this.target;
272
275
  this.stopAiming();
273
- const video = this.player?.video;
276
+ const video = this.player?.media;
274
277
  if (target !== null && video !== void 0) video.currentTime = target;
275
278
  }
276
279
  /** Drops the target: the thumb goes back to the playhead. */
@@ -286,7 +289,7 @@ var MbxSeekBar = class extends Component {
286
289
  this.leave();
287
290
  }
288
291
  input(value) {
289
- const video = this.player?.video;
292
+ const video = this.player?.media;
290
293
  if (video === void 0) return;
291
294
  this.bar.set(value, this.say(value));
292
295
  if (!this.bar.dragging()) {
@@ -296,6 +299,7 @@ var MbxSeekBar = class extends Component {
296
299
  return;
297
300
  }
298
301
  this.dragged = value;
302
+ if (this.drag === "hold") return;
299
303
  if (this.drag === "scrub") {
300
304
  optional(this.player?.engine ?? null).trick?.scrubTo(value);
301
305
  return;
@@ -307,7 +311,7 @@ var MbxSeekBar = class extends Component {
307
311
  }
308
312
  flush() {
309
313
  this.frame = 0;
310
- const video = this.player?.video;
314
+ const video = this.player?.media;
311
315
  if (this.pending === null || video === void 0) return;
312
316
  video.currentTime = this.pending;
313
317
  if (this.drag === "seek") this.written = this.pending;
@@ -460,7 +464,7 @@ var MbxSeekBar = class extends Component {
460
464
  const tick = () => {
461
465
  this.render();
462
466
  };
463
- this.listen(player.video, EVENTS, tick);
467
+ this.listen(player.media, EVENTS, tick);
464
468
  this.keep(followChapters(player, tick));
465
469
  this.listen(player, ["markerschange", "breakschange"], tick);
466
470
  this.listen(player, ["sourcechange"], () => {
@@ -472,7 +476,7 @@ var MbxSeekBar = class extends Component {
472
476
  const asked = event;
473
477
  if (!this.previewing() || this.hidden || asked.defaultPrevented) return;
474
478
  asked.preventDefault();
475
- this.aim((this.target ?? player.video.currentTime) + asked.detail.by * this.growth());
479
+ this.aim((this.target ?? player.media.currentTime) + asked.detail.by * this.growth());
476
480
  });
477
481
  this.listen(player, ["keydown"], (event) => {
478
482
  const key = event;
@@ -497,7 +501,7 @@ var MbxSeekBar = class extends Component {
497
501
  render() {
498
502
  const player = this.player;
499
503
  if (player === null) return;
500
- const video = player.video;
504
+ const video = player.media;
501
505
  const engine = player.engine;
502
506
  const api = live(engine);
503
507
  const on = api !== void 0;
@@ -1 +1 @@
1
- {"version":3,"file":"seek-bar.js","names":[],"sources":["../../src/elements/seek-bar.ts"],"sourcesContent":["/**\n * <mbx-seek-bar>: the bar over the slider primitive, with four layers on\n * its track, every one a part: the buffered ranges from `video.buffered`,\n * the played span, the hover position, and for live the edge from\n * `engine.live`. The span it maps is the availability window for live and\n * the duration for VOD; `controls/session.ts` says which.\n *\n * A live stream is seekable only when the window is worth it: at least\n * `live-window` forward buffer goals long, the goal read from the engine.\n * Below that the bar hides. VOD is always seekable. The element sets\n * `live` and `seekable` on the player, which the time and the live button\n * read, and `scrubbing` while a pointer holds the thumb: `playing` or\n * `paused`, the state before the drag, which the play buttons show\n * instead of the drag's own pause.\n *\n * Reads happen on the events the video already fires; the live window has\n * no event of its own and moves with the clock, so `timeupdate` covers it.\n * While a pointer holds the thumb, the played layer follows the pointer.\n * The element carries `dragging` meanwhile. With an I-frame track\n * (`engine.trick.available`), the drag scrubs: the video pauses and shows\n * the I-frame at every position, and the release seeks there. See the\n * engine guide's trick play chapter. `scrub=\"false\"` turns this off.\n * Otherwise the video pauses, `currentTime` is written at most once per\n * frame, so the bar never fights a slow seek, and the release resumes\n * playback if it was playing. Thumbnail tiles never drive a drag: they are\n * previews, not frames of the video.\n *\n * The preview above the pointer carries the time and a picture of that\n * time from the sources `preview` names, in order of preference: `frames`\n * and `tiles`, \"frames tiles\" by default, `none` for no picture. A frame\n * is the decoded I-frame from `engine.trick.frameAt`, when the track\n * decodes in this browser; the last one stays until the next arrives, so\n * the picture never flickers while the engine decodes. A tile comes from\n * `engine.thumbnails`: a rectangle of a sprite, drawn by background\n * position at the sprite's own size. Both scale to `--mbx-preview-width`,\n * so a page sets the size with one token.\n *\n * Chapters divide the track: one gap per chapter boundary, cut through\n * every layer with a mask, so the played and the buffered spans read per\n * chapter, and the preview names the chapter under the pointer. They come\n * from the session, see `controls/chapters.ts`. `chapters` lists what the\n * bar does with them: `divided` and `titles`, both by default, one of\n * them alone, or `none`.\n *\n * `step` is what an arrow key moves the playhead by and `page` what Page\n * Up and Page Down do, in seconds. `key-mode=\"preview\"`, for a TV, makes\n * the keys aim instead of seek: the thumb and the preview show the target,\n * a held key's step grows, and the seek comes on Enter, on leaving the bar,\n * or a second after the last key. Escape or Back drops the target. The\n * control bar's seeking keys, the arrows and fast forward and rewind\n * anywhere in the player, aim the same way: the bar asks through\n * `seekkey`, and the seek bar takes it. The default, `instant`, seeks on\n * every key. The name comes from `label`; what a\n * screen reader hears at a position from `label-of`, \"{current} of\n * {duration}\", and on live from `label-behind`, \"{time} behind live\". It\n * sits in the bar's seek row unless the page says otherwise.\n */\n\nimport type { Thumbnail } from 'mattebox/stages/thumbnails';\nimport type { Chapter } from '../controls/chapters.js';\nimport { chapterAt, chapters, followChapters } from '../controls/chapters.js';\nimport type { Span } from '../controls/ranges.js';\nimport { at, clip, EMPTY, fraction, spans } from '../controls/ranges.js';\nimport { bufferGoal, live, optional, span, wall } from '../controls/session.js';\nimport type { Slider } from '../controls/slider.js';\nimport { slider } from '../controls/slider.js';\nimport { format } from '../controls/time.js';\nimport { el } from '../dom.js';\nimport type { PlayerHost } from '../host.js';\nimport { fill } from '../labels.js';\nimport { Component } from './component.js';\nimport STYLE_CSS from './seek-bar.css?inline';\nimport { number, SLIDER_STYLE, seekRow, style } from './shared.js';\n\n/** What a drag does, chosen when the pointer takes the thumb. */\ntype Drag = 'none' | 'seek' | 'scrub';\n\n/** Where the preview's picture comes from: decoded I-frames, or thumbnail tiles. */\ntype Preview = 'frames' | 'tiles';\n\nconst STEP = 5;\n\n/** Under `key-mode=\"preview\"`, a target seeks this long after the last key. */\nconst KEY_COMMIT_MS = 1000;\n/** Key moves closer together than this are one hold, whose step grows. */\nconst REPEAT_GAP_MS = 400;\n/** A held key's step grows by one step every this many moves... */\nconst MOVES_PER_STEP = 8;\n/** ...up to this many steps a move. */\nconst MAX_STEPS = 12;\n\n/** The keys that cancel a target: Escape, and Back as a remote sends it. */\nconst CANCEL_KEYS = ['Escape', 'GoBack', 'BrowserBack'];\nconst PAGE = 30;\nconst LIVE_WINDOW = 3;\n\n/** What the tile scales down to, in em, when the page sets no `--mbx-preview-width`. */\nconst PREVIEW_WIDTH = 10;\n\n/** The buffer goal assumed for a session that reports none. */\nconst BUFFER_GOAL = 30;\n\n/** The gap cut at a chapter boundary, in pixels. */\nconst GAP = 2;\n\nconst EVENTS = [\n 'timeupdate',\n 'progress',\n 'durationchange',\n 'loadedmetadata',\n 'seeking',\n 'seeked',\n 'emptied',\n];\n\nconst STYLE = SLIDER_STYLE + STYLE_CSS;\n\nfunction percent(part: number): string {\n return `${part * 100}%`;\n}\n\n/**\n * A mask that cuts a gap at each chapter boundary, as stops along the\n * track: opaque up to a boundary, clear for the gap, opaque after.\n */\nfunction gaps(boundaries: readonly number[], span: Span): string {\n if (boundaries.length === 0) return '';\n const stops: string[] = ['#000 0'];\n for (const time of boundaries) {\n const at = percent(fraction(time, span));\n const before = `calc(${at} - ${GAP / 2}px)`;\n const after = `calc(${at} + ${GAP / 2}px)`;\n stops.push(`#000 ${before}`, `transparent ${before}`, `transparent ${after}`, `#000 ${after}`);\n }\n stops.push('#000 100%');\n return `linear-gradient(to right, ${stops.join(', ')})`;\n}\n\nexport class MbxSeekBar extends Component {\n static get observedAttributes(): readonly string[] {\n return [\n 'label',\n 'label-of',\n 'label-behind',\n 'label-blocked',\n 'live-window',\n 'chapters',\n 'scrub',\n 'preview',\n 'key-mode',\n ];\n }\n\n declare private readonly bar: Slider;\n declare private readonly buffered: HTMLElement;\n /** The ranges the page marked blocked, drawn as a broken line: they never play. */\n declare private readonly blocked: HTMLElement;\n /** The ad breaks, as ticks, and as spans where a break replaces a part. */\n declare private readonly breaks: HTMLElement;\n declare private readonly hover: HTMLElement;\n declare private readonly edge: HTMLElement;\n declare private readonly preview: HTMLElement;\n declare private readonly image: HTMLElement;\n declare private readonly tile: HTMLElement;\n declare private readonly time: HTMLElement;\n declare private readonly caption: HTMLElement;\n declare private readonly frameCanvas: HTMLCanvasElement;\n declare private drag: Drag;\n /** The last position of the drag, which a cancelled drag settles at. */\n declare private dragged: number | null;\n /** Whether the video played when a seeking drag began, so the release resumes it. */\n declare private resume: boolean;\n /** Frames asked for, and the newest one on screen, so a late frame never replaces a newer one. */\n declare private asked: number;\n /** Under `key-mode=\"preview\"`: where the keys aim, not yet sought to, or null. */\n declare private target: number | null;\n declare private commitTimer: number;\n /** The moves of the current hold, and when the last one came. */\n declare private moves: number;\n declare private lastMove: number;\n declare private shown: number;\n declare private range: Span;\n /** The chapters as last drawn, so the mask is written only when they change. */\n declare private divided: string;\n declare private list: Chapter[];\n declare private pending: number | null;\n /** The last time a frame wrote during the drag, so the release does not seek there again. */\n declare private written: number | null;\n declare private frame: number;\n\n constructor() {\n super();\n this.range = EMPTY;\n this.pending = null;\n this.written = null;\n this.frame = 0;\n this.divided = '';\n this.list = [];\n this.drag = 'none';\n this.dragged = null;\n this.resume = false;\n this.asked = 0;\n this.shown = 0;\n this.target = null;\n this.commitTimer = 0;\n this.moves = 0;\n this.lastMove = 0;\n const root = this.attachShadow({ mode: 'open' });\n this.bar = slider({\n step: () => this.keyStep(),\n page: () => number(this, 'page', PAGE),\n onInput: (value, key) => {\n if (key && this.previewing()) this.aim(value);\n else this.input(value);\n },\n onDrag: (on) => {\n this.toggleAttribute('dragging', on);\n if (on) this.dragStart();\n else this.dragEnd();\n },\n });\n this.buffered = el('div', 'buffered');\n this.blocked = el('div', 'blocked');\n this.breaks = el('div', 'breaks');\n this.hover = el('div', 'hover');\n this.edge = el('div', 'edge');\n this.hover.hidden = true;\n this.edge.hidden = true;\n // Under the fill, so what is played reads over what is buffered.\n this.bar.track.prepend(this.buffered);\n // Over the fill, inside the track: the chapter gaps cut through it too.\n this.bar.track.append(this.blocked, this.breaks, this.hover, this.edge);\n this.preview = el('div', 'preview');\n this.image = el('div', 'preview-image');\n this.tile = el('div', 'preview-tile');\n this.time = el('span', 'preview-time');\n this.caption = el('span', 'preview-title');\n this.caption.hidden = true;\n this.image.append(this.tile);\n this.image.hidden = true;\n this.frameCanvas = el('canvas', 'preview-frame');\n this.frameCanvas.hidden = true;\n this.preview.append(this.frameCanvas, this.image, this.caption, this.time);\n this.preview.hidden = true;\n this.bar.root.append(this.preview);\n this.bar.root.addEventListener('pointermove', (event) => {\n this.point(event);\n });\n this.bar.root.addEventListener('pointerleave', () => {\n if (this.target === null) this.leave();\n });\n // Focus moving on: the target stands, as if the pause ran out.\n this.bar.root.addEventListener('blur', () => {\n if (this.target !== null) this.commit();\n });\n root.append(style(STYLE), this.bar.root);\n }\n\n override connectedCallback(): void {\n seekRow(this);\n super.connectedCallback();\n }\n\n private isLive(): boolean {\n return live(this.player?.engine ?? null) !== undefined;\n }\n\n /** Whether the chapters do `use`: `divided` the track, or name the preview with their `titles`. */\n private chaptered(use: 'divided' | 'titles'): boolean {\n if (this.list.length === 0) return false;\n const value = this.getAttribute('chapters');\n if (value === null) return true;\n const words = value.split(/\\s+/);\n // A value naming neither, as `on` did, keeps both.\n return (\n words.includes(use) ||\n !words.some((word) => word === 'divided' || word === 'titles' || word === 'none')\n );\n }\n\n /** The gaps at the chapter boundaries, on every layer of the track at once. */\n private paintChapters(): void {\n const boundaries =\n this.chaptered('divided') && this.list.length > 1\n ? this.list.slice(1).map((chapter) => chapter.start)\n : [];\n const mask = gaps(boundaries, this.range);\n const key = `${mask}|${this.range.start}|${this.range.end}`;\n if (key === this.divided) return;\n this.divided = key;\n const track = this.bar.track.style;\n // Both spellings: WebKit before 15.4 knows only the prefixed one.\n track.setProperty('mask-image', mask === '' ? '' : mask);\n track.setProperty('-webkit-mask-image', mask === '' ? '' : mask);\n }\n\n /** What a screen reader hears at a time. */\n private say(time: number): string {\n const engine = this.player?.engine ?? null;\n if (!this.isLive()) {\n const template = this.word('label-of', 'seekOf', '{current} of {duration}');\n return Number.isFinite(this.range.end) && this.range.end > 0\n ? fill(template, { current: format(time), duration: format(this.range.end) })\n : format(time);\n }\n const behind = fill(this.word('label-behind', 'behindLive', '{time} behind live'), {\n time: format(this.range.end - time),\n });\n const clock = wall(engine, time);\n return clock === null ? behind : `${clock}, ${behind}`;\n }\n\n /** What the preview shows at a time. */\n private label(time: number): string {\n if (!this.isLive()) return format(time);\n return wall(this.player?.engine ?? null, time) ?? `-${format(this.range.end - time)}`;\n }\n\n /** Scrubs when the session has an I-frame track and the page allows it; seeks otherwise. */\n private dragStart(): void {\n const trick = optional(this.player?.engine ?? null).trick;\n this.dragged = null;\n // The pause below is the drag's, not the viewer's: the player says so,\n // with the state from before, which the play buttons keep showing.\n const before = this.player?.video.paused === false ? 'playing' : 'paused';\n this.player?.setAttribute('scrubbing', before);\n if (trick?.available === true && this.getAttribute('scrub') !== 'false') {\n trick.scrubStart();\n this.drag = 'scrub';\n } else {\n // Paused for the drag, the way the scrub is: the picture follows the\n // pointer, and playback waits for the release.\n const video = this.player?.video;\n this.resume = video !== undefined && !video.paused;\n video?.pause();\n this.drag = 'seek';\n }\n }\n\n /**\n * The pointer let go. A release writes its own input next, in the same\n * task, and that settles the drag. A cancelled drag writes none, so the\n * drag settles at its last position once the task is over.\n */\n private dragEnd(): void {\n queueMicrotask(() => {\n if (this.drag !== 'none') this.settle(this.dragged);\n });\n }\n\n /** Ends the drag at `value`, or where it stands when there is none. */\n private settle(value: number | null): void {\n const drag = this.drag;\n this.drag = 'none';\n this.dragged = null;\n const written = this.written;\n this.written = null;\n const player = this.player;\n if (player === null) return;\n if (drag === 'scrub') {\n const trick = optional(player.engine).trick;\n if (value === null) trick?.scrubEnd();\n else trick?.scrubEnd(value);\n } else {\n // A click writes on the press and again on the release, at the same\n // time: one seek is enough, and a tracker counts each one.\n if (value !== null && value !== written) player.video.currentTime = value;\n if (this.resume) void player.video.play().catch(() => undefined);\n this.resume = false;\n }\n // After the play, which clears `paused` at once, so the start button\n // never shows between the release and the resume.\n player.removeAttribute('scrubbing');\n }\n\n /** Whether keys aim a target with the preview instead of seeking at once. */\n private previewing(): boolean {\n return this.getAttribute('key-mode') === 'preview';\n }\n\n /** The step for a key on the slider itself. */\n private keyStep(): number {\n const base = number(this, 'step', STEP);\n return this.previewing() ? base * this.growth() : base;\n }\n\n /**\n * How many steps a key moves the target under `key-mode=\"preview\"`. It\n * grows while the viewer holds the key, so a long film takes seconds to\n * cross, not minutes; a pause restarts it.\n */\n private growth(): number {\n const now = performance.now();\n if (now - this.lastMove > REPEAT_GAP_MS) this.moves = 0;\n this.moves += 1;\n this.lastMove = now;\n return Math.min(MAX_STEPS, 1 + Math.floor(this.moves / MOVES_PER_STEP));\n }\n\n /**\n * Aims at `value` without seeking: the thumb and the preview show it, and\n * the seek comes on Enter or once the keys pause. A TV decodes slowly, so\n * a seek per key would stutter where the preview already shows the place.\n */\n private aim(value: number): void {\n const time = Math.min(this.range.end, Math.max(this.range.start, value));\n this.target = time;\n this.bar.set(time, this.say(time));\n const span = this.range.end - this.range.start;\n if (span > 0) this.previewAt((time - this.range.start) / span);\n clearTimeout(this.commitTimer);\n this.commitTimer = window.setTimeout(() => {\n this.commit();\n }, KEY_COMMIT_MS);\n }\n\n /** Seeks to the target, if there is one. */\n private commit(): void {\n const target = this.target;\n this.stopAiming();\n const video = this.player?.video;\n if (target !== null && video !== undefined) video.currentTime = target;\n }\n\n /** Drops the target: the thumb goes back to the playhead. */\n private cancel(): void {\n this.stopAiming();\n this.render();\n }\n\n private stopAiming(): void {\n clearTimeout(this.commitTimer);\n this.commitTimer = 0;\n this.target = null;\n this.moves = 0;\n this.leave();\n }\n\n private input(value: number): void {\n const video = this.player?.video;\n if (video === undefined) return;\n this.bar.set(value, this.say(value));\n if (!this.bar.dragging()) {\n // The release, or a key: written now, and it supersedes whatever a\n // frame queued during the drag was about to write.\n this.pending = null;\n if (this.drag !== 'none') this.settle(value);\n else video.currentTime = value;\n return;\n }\n this.dragged = value;\n if (this.drag === 'scrub') {\n // The engine writes `currentTime` on every move; the browser drops a\n // seek a newer one supersedes, so no throttle is needed here.\n optional(this.player?.engine ?? null).trick?.scrubTo(value);\n return;\n }\n this.pending = value;\n if (this.frame === 0) {\n this.frame = requestAnimationFrame(() => {\n this.flush();\n });\n }\n }\n\n private flush(): void {\n this.frame = 0;\n const video = this.player?.video;\n if (this.pending === null || video === undefined) return;\n video.currentTime = this.pending;\n if (this.drag === 'seek') this.written = this.pending;\n this.pending = null;\n }\n\n /** The width the page asked for through the token, or the default. */\n private previewWidth(): number {\n const set = Number.parseFloat(\n getComputedStyle(this.preview).getPropertyValue('--mbx-preview-width'),\n );\n if (Number.isFinite(set) && set > 0) return set;\n return PREVIEW_WIDTH * (Number.parseFloat(getComputedStyle(this).fontSize) || 16);\n }\n\n /** The preview's picture sources from `preview`, in order of preference: frames then tiles by default. */\n private sources(): Preview[] {\n const value = this.getAttribute('preview');\n if (value === 'none') return [];\n const own = (value ?? '')\n .split(/\\s+/)\n .filter((word): word is Preview => word === 'frames' || word === 'tiles');\n return own.length > 0 ? own : ['frames', 'tiles'];\n }\n\n /** `tile`, or none, drawn at its size and scaled to fit. */\n private paintTile(tile: Thumbnail | null): void {\n this.image.hidden = tile === null;\n if (tile === null) return;\n const scale = this.previewWidth() / tile.width;\n this.image.style.width = `${tile.width * scale}px`;\n this.image.style.height = `${tile.height * scale}px`;\n this.tile.style.width = `${tile.width}px`;\n this.tile.style.height = `${tile.height}px`;\n this.tile.style.backgroundImage = `url(\"${tile.url}\")`;\n this.tile.style.backgroundPosition = `-${tile.x}px -${tile.y}px`;\n this.tile.style.transform = `scale(${scale})`;\n }\n\n /**\n * The picture in the preview, from the sources `preview` names, the first\n * that answers winning. A decoded frame arrives later than a tile, so\n * while frames lead, the tile stands in until one is on screen, and the\n * last frame stays until the next one arrives. A scrub already shows the\n * position in the video, so the preview shows none meanwhile.\n */\n private paintPicture(when: number): void {\n const sources = this.drag === 'scrub' ? [] : this.sources();\n const api = optional(this.player?.engine ?? null);\n const trick = api.trick;\n // `previews` turns false once the engine knows no frame will come, such\n // as for TS I-frames; the tile shows then, without asking again.\n const frames = sources.includes('frames') && trick?.previews === true;\n const tile = sources.includes('tiles') ? (api.thumbnails?.at(when) ?? null) : null;\n if (tile !== null && (sources[0] === 'tiles' || !frames)) {\n // A frame still decoding for an earlier position must not replace it.\n this.asked += 1;\n this.shown = this.asked;\n this.frameCanvas.hidden = true;\n this.paintTile(tile);\n return;\n }\n if (!frames || trick === undefined) {\n this.frameCanvas.hidden = true;\n this.paintTile(null);\n return;\n }\n this.asked += 1;\n const request = this.asked;\n const width = this.previewWidth();\n // Null for a call a newer one replaced, and while the track's segments\n // load. What is on screen stays then.\n void trick.frameAt(when, { width: Math.round(width * devicePixelRatio) }).then(\n (bitmap) => {\n if (bitmap === null || request < this.shown || this.preview.hidden) return;\n this.shown = request;\n // The engine keeps the bitmap in its cache: drawn, never closed here.\n const canvas = this.frameCanvas;\n canvas.width = bitmap.width;\n canvas.height = bitmap.height;\n canvas.style.width = `${width}px`;\n canvas.style.height = `${(bitmap.height / bitmap.width) * width}px`;\n canvas.getContext('2d')?.drawImage(bitmap, 0, 0);\n canvas.hidden = false;\n this.image.hidden = true;\n },\n () => undefined,\n );\n if (this.frameCanvas.hidden) this.paintTile(tile);\n }\n\n /** The ranges the page marked blocked. */\n private blockedRanges(): Span[] {\n return (this.player?.markers.list ?? []).filter((marker) => marker.kind === 'blocked');\n }\n\n /** One child of `layer` per range, each named `part`, placed along the track. */\n private paintRanges(layer: HTMLElement, ranges: readonly Span[], part: string): void {\n const parts = clip(ranges, this.range);\n while (layer.childElementCount > parts.length) layer.lastElementChild?.remove();\n while (layer.childElementCount < parts.length) layer.append(el('div', part));\n let i = 0;\n for (const child of layer.children) {\n const part = parts[i];\n i += 1;\n if (part === undefined) break;\n const node = child as HTMLElement;\n node.style.left = percent(part[0]);\n node.style.width = percent(part[1] - part[0]);\n }\n }\n\n /** The ad breaks inside the bar's range: a tick at each start, a span where one replaces a part. */\n private paintBreaks(): void {\n const { start, end } = this.range;\n const marks = (this.player?.breaks.list ?? []).filter(\n (mark) => mark.start >= start && mark.start <= end,\n );\n while (this.breaks.childElementCount > marks.length) this.breaks.lastElementChild?.remove();\n while (this.breaks.childElementCount < marks.length) this.breaks.append(el('div', 'break'));\n marks.forEach((mark, i) => {\n const node = this.breaks.children[i] as HTMLElement;\n const span = mark.end !== undefined && mark.end > mark.start;\n node.setAttribute(\n 'part',\n `break${span ? ' span' : ''}${mark.played === true ? ' played' : ''}`,\n );\n node.style.left = percent(fraction(mark.start, this.range));\n node.style.width = span\n ? percent(\n fraction(Math.min(mark.end ?? end, end), this.range) - fraction(mark.start, this.range),\n )\n : '';\n });\n }\n\n /** Whether a live window is wide enough to be worth a bar. */\n private worthSeeking(): boolean {\n const goals = number(this, 'live-window', LIVE_WINDOW);\n if (goals === 0) return true;\n const goal = bufferGoal(this.player?.engine ?? null) ?? BUFFER_GOAL;\n return this.range.end - this.range.start >= goals * goal;\n }\n\n /** The hover marker and the preview follow the pointer, clamped to the bar. */\n private point(event: PointerEvent): void {\n const rect = this.bar.rail.getBoundingClientRect();\n if (rect.width === 0 || this.range.end <= this.range.start) return;\n const part = Math.min(1, Math.max(0, (event.clientX - rect.left) / rect.width));\n this.hover.hidden = false;\n this.hover.style.left = percent(part);\n this.previewAt(part);\n }\n\n /** The preview over `part` of the bar: the time, the chapter, and the picture. */\n private previewAt(part: number): void {\n const rect = this.bar.rail.getBoundingClientRect();\n if (rect.width === 0 || this.range.end <= this.range.start) return;\n this.preview.hidden = false;\n const when = at(part, this.range);\n this.time.textContent = this.label(when);\n const chapter = this.chaptered('titles') ? this.list[chapterAt(this.list, when)] : undefined;\n // A blocked range shows no picture: its frames must not play, and a\n // preview would show them.\n const blocked = this.player?.markers.within(when).find((marker) => marker.kind === 'blocked');\n const title = blocked\n ? blocked.label === undefined\n ? this.word('label-blocked', 'blocked', 'Not available')\n : this.pageText(blocked.label)\n : (chapter?.title ?? '');\n this.caption.hidden = title === '';\n this.caption.textContent = title;\n if (blocked) {\n this.image.hidden = true;\n this.frameCanvas.hidden = true;\n } else this.paintPicture(when);\n const whole = this.bar.root.getBoundingClientRect();\n const half = this.preview.offsetWidth / 2;\n const x = rect.left - whole.left + part * rect.width;\n this.preview.style.left = `${Math.min(whole.width - half, Math.max(half, x))}px`;\n }\n\n private leave(): void {\n this.hover.hidden = true;\n this.preview.hidden = true;\n // The next hover starts from the tile, not a frame from elsewhere on the bar.\n this.frameCanvas.hidden = true;\n }\n\n protected override attach(player: PlayerHost): void {\n const tick = (): void => {\n this.render();\n };\n this.listen(player.video, EVENTS, tick);\n this.keep(followChapters(player, tick));\n this.listen(player, ['markerschange', 'breakschange'], tick);\n this.listen(player, ['sourcechange'], () => {\n this.drag = 'none';\n this.stopAiming();\n this.render();\n });\n // Under `key-mode=\"preview\"`, the control bar's seeking keys aim: it\n // asks through `seekkey` before it seeks, and a taken event does not.\n this.listen(player, ['seekkey'], (event: Event) => {\n const asked = event as CustomEvent<{ readonly by: number }>;\n if (!this.previewing() || this.hidden || asked.defaultPrevented) return;\n asked.preventDefault();\n this.aim((this.target ?? player.video.currentTime) + asked.detail.by * this.growth());\n });\n // While a target stands, Enter seeks to it and Escape or Back drops it,\n // wherever focus is: on the bar, or anywhere the seeking keys came from.\n // Bubbling, so a focused control has its say first.\n this.listen(player, ['keydown'], (event: Event) => {\n const key = event as KeyboardEvent;\n if (this.target === null || key.defaultPrevented) return;\n // Enter on a button is that button's.\n if (key.key === 'Enter' && !(key.composedPath()[0] instanceof HTMLButtonElement)) {\n this.commit();\n } else if (CANCEL_KEYS.includes(key.key)) {\n this.cancel();\n } else return;\n key.preventDefault();\n });\n this.render();\n }\n\n protected override detach(player: PlayerHost): void {\n cancelAnimationFrame(this.frame);\n this.frame = 0;\n this.pending = null;\n if (this.drag !== 'none') this.settle(null);\n this.stopAiming();\n player.removeAttribute('live');\n player.removeAttribute('seekable');\n player.removeAttribute('scrubbing');\n }\n\n protected override render(): void {\n const player = this.player;\n if (player === null) return;\n const video = player.video;\n const engine = player.engine;\n const api = live(engine);\n const on = api !== undefined;\n this.range = span(video, engine);\n this.list = chapters(video, engine);\n this.bar.label(this.word('label', 'seek', 'Seek'));\n this.bar.range(this.range.start, this.range.end);\n this.paintRanges(this.buffered, spans(video.buffered), 'buffered-range');\n this.paintRanges(this.blocked, this.blockedRanges(), 'blocked-range');\n this.paintBreaks();\n this.paintChapters();\n this.edge.hidden = !on;\n if (api !== undefined && api.edge !== null) {\n this.edge.style.left = percent(fraction(api.edge, this.range));\n }\n const seekable = !on || this.worthSeeking();\n this.hidden = !seekable;\n player.toggleAttribute('live', on);\n player.toggleAttribute('seekable', seekable);\n if (!this.bar.dragging() && this.target === null) {\n this.bar.set(video.currentTime, this.say(video.currentTime));\n }\n }\n}\n"],"mappings":";;;;;;;;;;AAuEA,MAAA,YAAA;AASA,MAAA,OAAA;;AAGA,MAAA,gBAAA;;AAEA,MAAA,gBAAA;;AAEA,MAAA,iBAAA;;AAEA,MAAA,YAAA;;AAGA,MAAA,cAAA;CAAA;CAAA;CAAA;AAAA;AACA,MAAA,OAAA;AACA,MAAA,cAAA;;AAGA,MAAA,gBAAA;;AAGA,MAAA,cAAA;;AAGA,MAAA,MAAA;AAEA,MAAA,SAAA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACA;AAEA,MAAA,QAAA,eAAA;AAEA,SAAA,QAAA,MAAA;CACA,OAAA,GAAA,OAAA,IAAA;AACA;;;;;AAMA,SAAA,KAAA,YAAA,MAAA;CACA,IAAA,WAAA,WAAA,GAAA,OAAA;CACA,MAAA,QAAA,CAAA,QAAA;CACA,KAAA,MAAA,QAAA,YAAA;EACA,MAAA,KAAA,QAAA,SAAA,MAAA,IAAA,CAAA;EACA,MAAA,SAAA,QAAA,GAAA,KAAA,MAAA,EAAA;EACA,MAAA,QAAA,QAAA,GAAA,KAAA,MAAA,EAAA;EACA,MAAA,KAAA,QAAA,UAAA,eAAA,UAAA,eAAA,SAAA,QAAA,OAAA;CACA;CACA,MAAA,KAAA,WAAA;CACA,OAAA,6BAAA,MAAA,KAAA,IAAA,EAAA;AACA;AAEA,IAAA,aAAA,cAAA,UAAA;CACA,WAAA,qBAAA;EACA,OAAA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GAC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AA,SAAA,MACA,KAAA,KAAA,MAAA,OAAA,QAAA,SAAA,IAAA,MAAA,KAAA,KAAA,CAAA;EAEA,MAAA,WAAA,CAAA,MAAA,KAAA,aAAA;EACA,KAAA,SAAA,CAAA;EACA,OAAA,gBAAA,QAAA,EAAA;EACA,OAAA,gBAAA,YAAA,QAAA;EACA,IAAA,CAAA,KAAA,IAAA,SAAA,KAAA,KAAA,WAAA,MACA,KAAA,IAAA,IAAA,MAAA,aAAA,KAAA,IAAA,MAAA,WAAA,CAAA;CAEA;AACA"}
1
+ {"version":3,"file":"seek-bar.js","names":[],"sources":["../../src/elements/seek-bar.ts"],"sourcesContent":["/**\n * <mbx-seek-bar>: the bar over the slider primitive, with four layers on\n * its track, every one a part: the buffered ranges from `video.buffered`,\n * the played span, the hover position, and for live the edge from\n * `engine.live`. The span it maps is the availability window for live and\n * the duration for VOD; `controls/session.ts` says which.\n *\n * A live stream is seekable only when the window is worth it: at least\n * `live-window` forward buffer goals long, the goal read from the engine.\n * Below that the bar hides. VOD is always seekable. The element sets\n * `live` and `seekable` on the player, which the time and the live button\n * read, and `scrubbing` while a pointer holds the thumb: `playing` or\n * `paused`, the state before the drag, which the play buttons show\n * instead of the drag's own pause.\n *\n * Reads happen on the events the video already fires; the live window has\n * no event of its own and moves with the clock, so `timeupdate` covers it.\n * While a pointer holds the thumb, the played layer follows the pointer.\n * The element carries `dragging` meanwhile. With an I-frame track\n * (`engine.trick.available`), the drag scrubs: the video pauses and shows\n * the I-frame at every position, and the release seeks there. See the\n * engine guide's trick play chapter. `scrub=\"false\"` turns this off.\n * Otherwise the video pauses, `currentTime` is written at most once per\n * frame, so the bar never fights a slow seek, and the release resumes\n * playback if it was playing. Thumbnail tiles never drive a drag: they are\n * previews, not frames of the video.\n *\n * The preview above the pointer carries the time and a picture of that\n * time from the sources `preview` names, in order of preference: `frames`\n * and `tiles`, \"frames tiles\" by default, `none` for no picture. A frame\n * is the decoded I-frame from `engine.trick.frameAt`, when the track\n * decodes in this browser; the last one stays until the next arrives, so\n * the picture never flickers while the engine decodes. A tile comes from\n * `engine.thumbnails`: a rectangle of a sprite, drawn by background\n * position at the sprite's own size. Both scale to `--mbx-preview-width`,\n * so a page sets the size with one token.\n *\n * Chapters divide the track: one gap per chapter boundary, cut through\n * every layer with a mask, so the played and the buffered spans read per\n * chapter, and the preview names the chapter under the pointer. They come\n * from the session, see `controls/chapters.ts`. `chapters` lists what the\n * bar does with them: `divided` and `titles`, both by default, one of\n * them alone, or `none`.\n *\n * `step` is what an arrow key moves the playhead by and `page` what Page\n * Up and Page Down do, in seconds. `key-mode=\"preview\"`, for a TV, makes\n * the keys aim instead of seek: the thumb and the preview show the target,\n * a held key's step grows, and the seek comes on Enter, on leaving the bar,\n * or a second after the last key. Escape or Back drops the target. The\n * control bar's seeking keys, the arrows and fast forward and rewind\n * anywhere in the player, aim the same way: the bar asks through\n * `seekkey`, and the seek bar takes it. The default, `instant`, seeks on\n * every key. The name comes from `label`; what a\n * screen reader hears at a position from `label-of`, \"{current} of\n * {duration}\", and on live from `label-behind`, \"{time} behind live\". It\n * sits in the bar's seek row unless the page says otherwise.\n */\n\nimport type { Thumbnail } from 'mattebox/stages/thumbnails';\nimport type { Chapter } from '../controls/chapters.js';\nimport { chapterAt, chapters, followChapters } from '../controls/chapters.js';\nimport type { Span } from '../controls/ranges.js';\nimport { at, clip, EMPTY, fraction, spans } from '../controls/ranges.js';\nimport { bufferGoal, live, optional, span, wall } from '../controls/session.js';\nimport type { Slider } from '../controls/slider.js';\nimport { slider } from '../controls/slider.js';\nimport { format } from '../controls/time.js';\nimport { el } from '../dom.js';\nimport type { PlayerHost } from '../host.js';\nimport { fill } from '../labels.js';\nimport { Component } from './component.js';\nimport STYLE_CSS from './seek-bar.css?inline';\nimport { number, SLIDER_STYLE, seekRow, style } from './shared.js';\n\n/** What a drag does, chosen when the pointer takes the thumb. */\ntype Drag = 'none' | 'seek' | 'scrub' | 'hold';\n\n/** Where the preview's picture comes from: decoded I-frames, or thumbnail tiles. */\ntype Preview = 'frames' | 'tiles';\n\nconst STEP = 5;\n\n/** Under `key-mode=\"preview\"`, a target seeks this long after the last key. */\nconst KEY_COMMIT_MS = 1000;\n/** Key moves closer together than this are one hold, whose step grows. */\nconst REPEAT_GAP_MS = 400;\n/** A held key's step grows by one step every this many moves... */\nconst MOVES_PER_STEP = 8;\n/** ...up to this many steps a move. */\nconst MAX_STEPS = 12;\n\n/** The keys that cancel a target: Escape, and Back as a remote sends it. */\nconst CANCEL_KEYS = ['Escape', 'GoBack', 'BrowserBack'];\nconst PAGE = 30;\nconst LIVE_WINDOW = 3;\n\n/** What the tile scales down to, in em, when the page sets no `--mbx-preview-width`. */\nconst PREVIEW_WIDTH = 10;\n\n/** The buffer goal assumed for a session that reports none. */\nconst BUFFER_GOAL = 30;\n\n/** The gap cut at a chapter boundary, in pixels. */\nconst GAP = 2;\n\nconst EVENTS = [\n 'timeupdate',\n 'progress',\n 'durationchange',\n 'loadedmetadata',\n 'seeking',\n 'seeked',\n 'emptied',\n];\n\nconst STYLE = SLIDER_STYLE + STYLE_CSS;\n\nfunction percent(part: number): string {\n return `${part * 100}%`;\n}\n\n/**\n * A mask that cuts a gap at each chapter boundary, as stops along the\n * track: opaque up to a boundary, clear for the gap, opaque after.\n */\nfunction gaps(boundaries: readonly number[], span: Span): string {\n if (boundaries.length === 0) return '';\n const stops: string[] = ['#000 0'];\n for (const time of boundaries) {\n const at = percent(fraction(time, span));\n const before = `calc(${at} - ${GAP / 2}px)`;\n const after = `calc(${at} + ${GAP / 2}px)`;\n stops.push(`#000 ${before}`, `transparent ${before}`, `transparent ${after}`, `#000 ${after}`);\n }\n stops.push('#000 100%');\n return `linear-gradient(to right, ${stops.join(', ')})`;\n}\n\nexport class MbxSeekBar extends Component {\n static get observedAttributes(): readonly string[] {\n return [\n 'label',\n 'label-of',\n 'label-behind',\n 'label-blocked',\n 'live-window',\n 'chapters',\n 'scrub',\n 'preview',\n 'key-mode',\n ];\n }\n\n declare private readonly bar: Slider;\n declare private readonly buffered: HTMLElement;\n /** The ranges the page marked blocked, drawn as a broken line: they never play. */\n declare private readonly blocked: HTMLElement;\n /** The ad breaks, as ticks, and as spans where a break replaces a part. */\n declare private readonly breaks: HTMLElement;\n declare private readonly hover: HTMLElement;\n declare private readonly edge: HTMLElement;\n declare private readonly preview: HTMLElement;\n declare private readonly image: HTMLElement;\n declare private readonly tile: HTMLElement;\n declare private readonly time: HTMLElement;\n declare private readonly caption: HTMLElement;\n declare private readonly frameCanvas: HTMLCanvasElement;\n declare private drag: Drag;\n /** The last position of the drag, which a cancelled drag settles at. */\n declare private dragged: number | null;\n /** Whether the video played when a seeking drag began, so the release resumes it. */\n declare private resume: boolean;\n /** Frames asked for, and the newest one on screen, so a late frame never replaces a newer one. */\n declare private asked: number;\n /** Under `key-mode=\"preview\"`: where the keys aim, not yet sought to, or null. */\n declare private target: number | null;\n declare private commitTimer: number;\n /** The moves of the current hold, and when the last one came. */\n declare private moves: number;\n declare private lastMove: number;\n declare private shown: number;\n declare private range: Span;\n /** The chapters as last drawn, so the mask is written only when they change. */\n declare private divided: string;\n declare private list: Chapter[];\n declare private pending: number | null;\n /** The last time a frame wrote during the drag, so the release does not seek there again. */\n declare private written: number | null;\n declare private frame: number;\n\n constructor() {\n super();\n this.range = EMPTY;\n this.pending = null;\n this.written = null;\n this.frame = 0;\n this.divided = '';\n this.list = [];\n this.drag = 'none';\n this.dragged = null;\n this.resume = false;\n this.asked = 0;\n this.shown = 0;\n this.target = null;\n this.commitTimer = 0;\n this.moves = 0;\n this.lastMove = 0;\n const root = this.attachShadow({ mode: 'open' });\n this.bar = slider({\n step: () => this.keyStep(),\n page: () => number(this, 'page', PAGE),\n onInput: (value, key) => {\n if (key && this.previewing()) this.aim(value);\n else this.input(value);\n },\n onDrag: (on) => {\n this.toggleAttribute('dragging', on);\n if (on) this.dragStart();\n else this.dragEnd();\n },\n });\n this.buffered = el('div', 'buffered');\n this.blocked = el('div', 'blocked');\n this.breaks = el('div', 'breaks');\n this.hover = el('div', 'hover');\n this.edge = el('div', 'edge');\n this.hover.hidden = true;\n this.edge.hidden = true;\n // Under the fill, so what is played reads over what is buffered.\n this.bar.track.prepend(this.buffered);\n // Over the fill, inside the track: the chapter gaps cut through it too.\n this.bar.track.append(this.blocked, this.breaks, this.hover, this.edge);\n this.preview = el('div', 'preview');\n this.image = el('div', 'preview-image');\n this.tile = el('div', 'preview-tile');\n this.time = el('span', 'preview-time');\n this.caption = el('span', 'preview-title');\n this.caption.hidden = true;\n this.image.append(this.tile);\n this.image.hidden = true;\n this.frameCanvas = el('canvas', 'preview-frame');\n this.frameCanvas.hidden = true;\n this.preview.append(this.frameCanvas, this.image, this.caption, this.time);\n this.preview.hidden = true;\n this.bar.root.append(this.preview);\n this.bar.root.addEventListener('pointermove', (event) => {\n this.point(event);\n });\n this.bar.root.addEventListener('pointerleave', () => {\n if (this.target === null) this.leave();\n });\n // Focus moving on: the target stands, as if the pause ran out.\n this.bar.root.addEventListener('blur', () => {\n if (this.target !== null) this.commit();\n });\n root.append(style(STYLE), this.bar.root);\n }\n\n override connectedCallback(): void {\n seekRow(this);\n super.connectedCallback();\n }\n\n private isLive(): boolean {\n return live(this.player?.engine ?? null) !== undefined;\n }\n\n /** Whether the chapters do `use`: `divided` the track, or name the preview with their `titles`. */\n private chaptered(use: 'divided' | 'titles'): boolean {\n if (this.list.length === 0) return false;\n const value = this.getAttribute('chapters');\n if (value === null) return true;\n const words = value.split(/\\s+/);\n // A value naming neither, as `on` did, keeps both.\n return (\n words.includes(use) ||\n !words.some((word) => word === 'divided' || word === 'titles' || word === 'none')\n );\n }\n\n /** The gaps at the chapter boundaries, on every layer of the track at once. */\n private paintChapters(): void {\n const boundaries =\n this.chaptered('divided') && this.list.length > 1\n ? this.list.slice(1).map((chapter) => chapter.start)\n : [];\n const mask = gaps(boundaries, this.range);\n const key = `${mask}|${this.range.start}|${this.range.end}`;\n if (key === this.divided) return;\n this.divided = key;\n const track = this.bar.track.style;\n // Both spellings: WebKit before 15.4 knows only the prefixed one.\n track.setProperty('mask-image', mask === '' ? '' : mask);\n track.setProperty('-webkit-mask-image', mask === '' ? '' : mask);\n }\n\n /** What a screen reader hears at a time. */\n private say(time: number): string {\n const engine = this.player?.engine ?? null;\n if (!this.isLive()) {\n const template = this.word('label-of', 'seekOf', '{current} of {duration}');\n return Number.isFinite(this.range.end) && this.range.end > 0\n ? fill(template, { current: format(time), duration: format(this.range.end) })\n : format(time);\n }\n const behind = fill(this.word('label-behind', 'behindLive', '{time} behind live'), {\n time: format(this.range.end - time),\n });\n const clock = wall(engine, time);\n return clock === null ? behind : `${clock}, ${behind}`;\n }\n\n /** What the preview shows at a time. */\n private label(time: number): string {\n if (!this.isLive()) return format(time);\n return wall(this.player?.engine ?? null, time) ?? `-${format(this.range.end - time)}`;\n }\n\n /** Scrubs when the session has an I-frame track and the page allows it; seeks otherwise. */\n private dragStart(): void {\n const trick = optional(this.player?.engine ?? null).trick;\n this.dragged = null;\n // The pause below is the drag's, not the viewer's: the player says so,\n // with the state from before, which the play buttons keep showing.\n const before = this.player?.media.paused === false ? 'playing' : 'paused';\n this.player?.setAttribute('scrubbing', before);\n if (this.remote()) {\n // A device plays: the preview follows the pointer, and the seek goes\n // out once, on the release.\n this.resume = false;\n this.drag = 'hold';\n } else if (trick?.available === true && this.getAttribute('scrub') !== 'false') {\n trick.scrubStart();\n this.drag = 'scrub';\n } else {\n // Paused for the drag, the way the scrub is: the picture follows the\n // pointer, and playback waits for the release.\n const video = this.player?.media;\n this.resume = video !== undefined && !video.paused;\n video?.pause();\n this.drag = 'seek';\n }\n }\n\n /**\n * The pointer let go. A release writes its own input next, in the same\n * task, and that settles the drag. A cancelled drag writes none, so the\n * drag settles at its last position once the task is over.\n */\n private dragEnd(): void {\n queueMicrotask(() => {\n if (this.drag !== 'none') this.settle(this.dragged);\n });\n }\n\n /** Ends the drag at `value`, or where it stands when there is none. */\n private settle(value: number | null): void {\n const drag = this.drag;\n this.drag = 'none';\n this.dragged = null;\n const written = this.written;\n this.written = null;\n const player = this.player;\n if (player === null) return;\n if (drag === 'scrub') {\n const trick = optional(player.engine).trick;\n if (value === null) trick?.scrubEnd();\n else trick?.scrubEnd(value);\n } else {\n // A click writes on the press and again on the release, at the same\n // time: one seek is enough, and a tracker counts each one.\n if (value !== null && value !== written) player.media.currentTime = value;\n if (this.resume) void player.media.play().catch(() => undefined);\n this.resume = false;\n }\n // After the play, which clears `paused` at once, so the start button\n // never shows between the release and the resume.\n player.removeAttribute('scrubbing');\n }\n\n /** Whether keys aim a target with the preview instead of seeking at once. */\n private previewing(): boolean {\n return this.getAttribute('key-mode') === 'preview';\n }\n\n /** The step for a key on the slider itself. */\n private keyStep(): number {\n const base = number(this, 'step', STEP);\n return this.previewing() ? base * this.growth() : base;\n }\n\n /**\n * How many steps a key moves the target under `key-mode=\"preview\"`. It\n * grows while the viewer holds the key, so a long film takes seconds to\n * cross, not minutes; a pause restarts it.\n */\n private growth(): number {\n const now = performance.now();\n if (now - this.lastMove > REPEAT_GAP_MS) this.moves = 0;\n this.moves += 1;\n this.lastMove = now;\n return Math.min(MAX_STEPS, 1 + Math.floor(this.moves / MOVES_PER_STEP));\n }\n\n /**\n * Aims at `value` without seeking: the thumb and the preview show it, and\n * the seek comes on Enter or once the keys pause. A TV decodes slowly, so\n * a seek per key would stutter where the preview already shows the place.\n */\n private aim(value: number): void {\n const time = Math.min(this.range.end, Math.max(this.range.start, value));\n this.target = time;\n this.bar.set(time, this.say(time));\n const span = this.range.end - this.range.start;\n if (span > 0) this.previewAt((time - this.range.start) / span);\n clearTimeout(this.commitTimer);\n this.commitTimer = window.setTimeout(() => {\n this.commit();\n }, KEY_COMMIT_MS);\n }\n\n /** Seeks to the target, if there is one. */\n private commit(): void {\n const target = this.target;\n this.stopAiming();\n const video = this.player?.media;\n if (target !== null && video !== undefined) video.currentTime = target;\n }\n\n /** Drops the target: the thumb goes back to the playhead. */\n private cancel(): void {\n this.stopAiming();\n this.render();\n }\n\n private stopAiming(): void {\n clearTimeout(this.commitTimer);\n this.commitTimer = 0;\n this.target = null;\n this.moves = 0;\n this.leave();\n }\n\n private input(value: number): void {\n const video = this.player?.media;\n if (video === undefined) return;\n this.bar.set(value, this.say(value));\n if (!this.bar.dragging()) {\n // The release, or a key: written now, and it supersedes whatever a\n // frame queued during the drag was about to write.\n this.pending = null;\n if (this.drag !== 'none') this.settle(value);\n else video.currentTime = value;\n return;\n }\n this.dragged = value;\n if (this.drag === 'hold') return;\n if (this.drag === 'scrub') {\n // The engine writes `currentTime` on every move; the browser drops a\n // seek a newer one supersedes, so no throttle is needed here.\n optional(this.player?.engine ?? null).trick?.scrubTo(value);\n return;\n }\n this.pending = value;\n if (this.frame === 0) {\n this.frame = requestAnimationFrame(() => {\n this.flush();\n });\n }\n }\n\n private flush(): void {\n this.frame = 0;\n const video = this.player?.media;\n if (this.pending === null || video === undefined) return;\n video.currentTime = this.pending;\n if (this.drag === 'seek') this.written = this.pending;\n this.pending = null;\n }\n\n /** The width the page asked for through the token, or the default. */\n private previewWidth(): number {\n const set = Number.parseFloat(\n getComputedStyle(this.preview).getPropertyValue('--mbx-preview-width'),\n );\n if (Number.isFinite(set) && set > 0) return set;\n return PREVIEW_WIDTH * (Number.parseFloat(getComputedStyle(this).fontSize) || 16);\n }\n\n /** The preview's picture sources from `preview`, in order of preference: frames then tiles by default. */\n private sources(): Preview[] {\n const value = this.getAttribute('preview');\n if (value === 'none') return [];\n const own = (value ?? '')\n .split(/\\s+/)\n .filter((word): word is Preview => word === 'frames' || word === 'tiles');\n return own.length > 0 ? own : ['frames', 'tiles'];\n }\n\n /** `tile`, or none, drawn at its size and scaled to fit. */\n private paintTile(tile: Thumbnail | null): void {\n this.image.hidden = tile === null;\n if (tile === null) return;\n const scale = this.previewWidth() / tile.width;\n this.image.style.width = `${tile.width * scale}px`;\n this.image.style.height = `${tile.height * scale}px`;\n this.tile.style.width = `${tile.width}px`;\n this.tile.style.height = `${tile.height}px`;\n this.tile.style.backgroundImage = `url(\"${tile.url}\")`;\n this.tile.style.backgroundPosition = `-${tile.x}px -${tile.y}px`;\n this.tile.style.transform = `scale(${scale})`;\n }\n\n /**\n * The picture in the preview, from the sources `preview` names, the first\n * that answers winning. A decoded frame arrives later than a tile, so\n * while frames lead, the tile stands in until one is on screen, and the\n * last frame stays until the next one arrives. A scrub already shows the\n * position in the video, so the preview shows none meanwhile.\n */\n private paintPicture(when: number): void {\n const sources = this.drag === 'scrub' ? [] : this.sources();\n const api = optional(this.player?.engine ?? null);\n const trick = api.trick;\n // `previews` turns false once the engine knows no frame will come, such\n // as for TS I-frames; the tile shows then, without asking again.\n const frames = sources.includes('frames') && trick?.previews === true;\n const tile = sources.includes('tiles') ? (api.thumbnails?.at(when) ?? null) : null;\n if (tile !== null && (sources[0] === 'tiles' || !frames)) {\n // A frame still decoding for an earlier position must not replace it.\n this.asked += 1;\n this.shown = this.asked;\n this.frameCanvas.hidden = true;\n this.paintTile(tile);\n return;\n }\n if (!frames || trick === undefined) {\n this.frameCanvas.hidden = true;\n this.paintTile(null);\n return;\n }\n this.asked += 1;\n const request = this.asked;\n const width = this.previewWidth();\n // Null for a call a newer one replaced, and while the track's segments\n // load. What is on screen stays then.\n void trick.frameAt(when, { width: Math.round(width * devicePixelRatio) }).then(\n (bitmap) => {\n if (bitmap === null || request < this.shown || this.preview.hidden) return;\n this.shown = request;\n // The engine keeps the bitmap in its cache: drawn, never closed here.\n const canvas = this.frameCanvas;\n canvas.width = bitmap.width;\n canvas.height = bitmap.height;\n canvas.style.width = `${width}px`;\n canvas.style.height = `${(bitmap.height / bitmap.width) * width}px`;\n canvas.getContext('2d')?.drawImage(bitmap, 0, 0);\n canvas.hidden = false;\n this.image.hidden = true;\n },\n () => undefined,\n );\n if (this.frameCanvas.hidden) this.paintTile(tile);\n }\n\n /** The ranges the page marked blocked. */\n private blockedRanges(): Span[] {\n return (this.player?.markers.list ?? []).filter((marker) => marker.kind === 'blocked');\n }\n\n /** One child of `layer` per range, each named `part`, placed along the track. */\n private paintRanges(layer: HTMLElement, ranges: readonly Span[], part: string): void {\n const parts = clip(ranges, this.range);\n while (layer.childElementCount > parts.length) layer.lastElementChild?.remove();\n while (layer.childElementCount < parts.length) layer.append(el('div', part));\n let i = 0;\n for (const child of layer.children) {\n const part = parts[i];\n i += 1;\n if (part === undefined) break;\n const node = child as HTMLElement;\n node.style.left = percent(part[0]);\n node.style.width = percent(part[1] - part[0]);\n }\n }\n\n /** The ad breaks inside the bar's range: a tick at each start, a span where one replaces a part. */\n private paintBreaks(): void {\n const { start, end } = this.range;\n const marks = (this.player?.breaks.list ?? []).filter(\n (mark) => mark.start >= start && mark.start <= end,\n );\n while (this.breaks.childElementCount > marks.length) this.breaks.lastElementChild?.remove();\n while (this.breaks.childElementCount < marks.length) this.breaks.append(el('div', 'break'));\n marks.forEach((mark, i) => {\n const node = this.breaks.children[i] as HTMLElement;\n const span = mark.end !== undefined && mark.end > mark.start;\n node.setAttribute(\n 'part',\n `break${span ? ' span' : ''}${mark.played === true ? ' played' : ''}`,\n );\n node.style.left = percent(fraction(mark.start, this.range));\n node.style.width = span\n ? percent(\n fraction(Math.min(mark.end ?? end, end), this.range) - fraction(mark.start, this.range),\n )\n : '';\n });\n }\n\n /** Whether a live window is wide enough to be worth a bar. */\n private worthSeeking(): boolean {\n const goals = number(this, 'live-window', LIVE_WINDOW);\n if (goals === 0) return true;\n const goal = bufferGoal(this.player?.engine ?? null) ?? BUFFER_GOAL;\n return this.range.end - this.range.start >= goals * goal;\n }\n\n /** The hover marker and the preview follow the pointer, clamped to the bar. */\n private point(event: PointerEvent): void {\n const rect = this.bar.rail.getBoundingClientRect();\n if (rect.width === 0 || this.range.end <= this.range.start) return;\n const part = Math.min(1, Math.max(0, (event.clientX - rect.left) / rect.width));\n this.hover.hidden = false;\n this.hover.style.left = percent(part);\n this.previewAt(part);\n }\n\n /** The preview over `part` of the bar: the time, the chapter, and the picture. */\n private previewAt(part: number): void {\n const rect = this.bar.rail.getBoundingClientRect();\n if (rect.width === 0 || this.range.end <= this.range.start) return;\n this.preview.hidden = false;\n const when = at(part, this.range);\n this.time.textContent = this.label(when);\n const chapter = this.chaptered('titles') ? this.list[chapterAt(this.list, when)] : undefined;\n // A blocked range shows no picture: its frames must not play, and a\n // preview would show them.\n const blocked = this.player?.markers.within(when).find((marker) => marker.kind === 'blocked');\n const title = blocked\n ? blocked.label === undefined\n ? this.word('label-blocked', 'blocked', 'Not available')\n : this.pageText(blocked.label)\n : (chapter?.title ?? '');\n this.caption.hidden = title === '';\n this.caption.textContent = title;\n if (blocked) {\n this.image.hidden = true;\n this.frameCanvas.hidden = true;\n } else this.paintPicture(when);\n const whole = this.bar.root.getBoundingClientRect();\n const half = this.preview.offsetWidth / 2;\n const x = rect.left - whole.left + part * rect.width;\n this.preview.style.left = `${Math.min(whole.width - half, Math.max(half, x))}px`;\n }\n\n private leave(): void {\n this.hover.hidden = true;\n this.preview.hidden = true;\n // The next hover starts from the tile, not a frame from elsewhere on the bar.\n this.frameCanvas.hidden = true;\n }\n\n protected override attach(player: PlayerHost): void {\n const tick = (): void => {\n this.render();\n };\n this.listen(player.media, EVENTS, tick);\n this.keep(followChapters(player, tick));\n this.listen(player, ['markerschange', 'breakschange'], tick);\n this.listen(player, ['sourcechange'], () => {\n this.drag = 'none';\n this.stopAiming();\n this.render();\n });\n // Under `key-mode=\"preview\"`, the control bar's seeking keys aim: it\n // asks through `seekkey` before it seeks, and a taken event does not.\n this.listen(player, ['seekkey'], (event: Event) => {\n const asked = event as CustomEvent<{ readonly by: number }>;\n if (!this.previewing() || this.hidden || asked.defaultPrevented) return;\n asked.preventDefault();\n this.aim((this.target ?? player.media.currentTime) + asked.detail.by * this.growth());\n });\n // While a target stands, Enter seeks to it and Escape or Back drops it,\n // wherever focus is: on the bar, or anywhere the seeking keys came from.\n // Bubbling, so a focused control has its say first.\n this.listen(player, ['keydown'], (event: Event) => {\n const key = event as KeyboardEvent;\n if (this.target === null || key.defaultPrevented) return;\n // Enter on a button is that button's.\n if (key.key === 'Enter' && !(key.composedPath()[0] instanceof HTMLButtonElement)) {\n this.commit();\n } else if (CANCEL_KEYS.includes(key.key)) {\n this.cancel();\n } else return;\n key.preventDefault();\n });\n this.render();\n }\n\n protected override detach(player: PlayerHost): void {\n cancelAnimationFrame(this.frame);\n this.frame = 0;\n this.pending = null;\n if (this.drag !== 'none') this.settle(null);\n this.stopAiming();\n player.removeAttribute('live');\n player.removeAttribute('seekable');\n player.removeAttribute('scrubbing');\n }\n\n protected override render(): void {\n const player = this.player;\n if (player === null) return;\n const video = player.media;\n const engine = player.engine;\n const api = live(engine);\n const on = api !== undefined;\n this.range = span(video, engine);\n this.list = chapters(video, engine);\n this.bar.label(this.word('label', 'seek', 'Seek'));\n this.bar.range(this.range.start, this.range.end);\n this.paintRanges(this.buffered, spans(video.buffered), 'buffered-range');\n this.paintRanges(this.blocked, this.blockedRanges(), 'blocked-range');\n this.paintBreaks();\n this.paintChapters();\n this.edge.hidden = !on;\n if (api !== undefined && api.edge !== null) {\n this.edge.style.left = percent(fraction(api.edge, this.range));\n }\n const seekable = !on || this.worthSeeking();\n this.hidden = !seekable;\n player.toggleAttribute('live', on);\n player.toggleAttribute('seekable', seekable);\n if (!this.bar.dragging() && this.target === null) {\n this.bar.set(video.currentTime, this.say(video.currentTime));\n }\n }\n}\n"],"mappings":";;;;;;;;;;AAuEA,MAAA,YAAA;AASA,MAAM,OAAO;;AAGb,MAAM,gBAAgB;;AAEtB,MAAM,gBAAgB;;AAEtB,MAAM,iBAAiB;;AAEvB,MAAM,YAAY;;AAGlB,MAAM,cAAc;CAAC;CAAU;CAAU;AAAa;AACtD,MAAM,OAAO;AACb,MAAM,cAAc;;AAGpB,MAAM,gBAAgB;;AAGtB,MAAM,cAAc;;AAGpB,MAAM,MAAM;AAEZ,MAAM,SAAS;CACb;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAM,QAAQ,eAAe;AAE7B,SAAS,QAAQ,MAAsB;CACrC,OAA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AAU,MAAM,MAAM,QAAQ,GAAG,gBAAgB;EACvE,KAAK,YAAY,KAAK,SAAS,KAAK,cAAc,GAAG,eAAe;EACpE,KAAK,YAAY;EACjB,KAAK,cAAc;EACnB,KAAK,KAAK,SAAS,CAAC;EACpB,IAAI,QAAQ,KAAA,KAAa,IAAI,SAAS,MACpC,KAAK,KAAK,MAAM,OAAO,QAAQ,SAAS,IAAI,MAAM,KAAK,KAAK,CAAC;EAE/D,MAAM,WAAW,CAAC,MAAM,KAAK,aAAa;EAC1C,KAAK,SAAS,CAAC;EACf,OAAO,gBAAgB,QAAQ,EAAE;EACjC,OAAO,gBAAgB,YAAY,QAAQ;EAC3C,IAAI,CAAC,KAAK,IAAI,SAAS,KAAK,KAAK,WAAW,MAC1C,KAAK,IAAI,IAAI,MAAM,aAAa,KAAK,IAAI,MAAM,WAAW,CAAC;CAE/D;AACF"}
@@ -1,5 +1,5 @@
1
1
  // src/elements/shared.ts
2
- const BUTTON_STYLE_CSS = ":host{display:inline-flex}:host([hidden]){display:none}[part~=button]{width:2.5em;height:2.5em;font:inherit;color:inherit;border-radius:var(--mbx-radius);cursor:pointer;opacity:.9;background:0 0;border:0;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex;position:relative}[part~=button][aria-label]:after{content:attr(aria-label);display:var(--mbx-tooltip,block);background:var(--mbx-surface);border-radius:var(--mbx-radius);white-space:nowrap;pointer-events:none;opacity:0;margin-bottom:.4615em;padding:.3077em .6154em;font-size:.8125em;transition:opacity .1s;position:absolute;bottom:100%;left:50%;transform:translate(-50%)}[part~=button][aria-label]:focus:after{opacity:1;transition-delay:.4s}[part~=button][aria-label]:focus:not(:focus-visible):after{opacity:0;transition-delay:0s}@media (hover:hover){[part~=button][aria-label]:hover:after{opacity:1;transition-delay:.4s}}:host(:last-child) [part~=button][aria-label]:after{left:auto;right:0;transform:none}[part~=button]:hover{opacity:1}[part~=button]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=button]:focus:not(:focus-visible){outline:none}[part~=icon],::slotted(*){fill:currentColor;width:1.75em;height:1.75em}slot[hidden]{display:none}";
2
+ const BUTTON_STYLE_CSS = ":host{display:inline-flex}:host([hidden]),:host([away]){display:none}[part~=button]{width:2.5em;height:2.5em;font:inherit;color:inherit;border-radius:var(--mbx-radius);cursor:pointer;opacity:.9;background:0 0;border:0;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex;position:relative}[part~=button][aria-label]:after{content:attr(aria-label);display:var(--mbx-tooltip,block);background:var(--mbx-surface);border-radius:var(--mbx-radius);white-space:nowrap;pointer-events:none;opacity:0;margin-bottom:.4615em;padding:.3077em .6154em;font-size:.8125em;transition:opacity .1s;position:absolute;bottom:100%;left:50%;transform:translate(-50%)}[part~=button][aria-label]:focus:after{opacity:1;transition-delay:.4s}[part~=button][aria-label]:focus:not(:focus-visible):after{opacity:0;transition-delay:0s}@media (hover:hover){[part~=button][aria-label]:hover:after{opacity:1;transition-delay:.4s}}:host(:last-child) [part~=button][aria-label]:after{left:auto;right:0;transform:none}[part~=button]:hover{opacity:1}[part~=button]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=button]:focus:not(:focus-visible){outline:none}[part~=icon],::slotted(*){fill:currentColor;width:1.75em;height:1.75em}slot[hidden]{display:none}";
3
3
  const SLIDER_STYLE_CSS = ":host{display:block}:host([hidden]){display:none}[part~=slider]{border-radius:var(--mbx-radius);cursor:pointer;touch-action:none;height:2.5em;position:relative}[part~=slider]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=slider]:focus:not(:focus-visible){outline:none}[part~=rail]{position:absolute;top:0;bottom:0;left:.5em;right:.5em}[part~=track]{background:#ffffff59;border-radius:2px;height:.25em;position:absolute;top:50%;left:0;right:0;overflow:hidden;transform:translateY(-50%)}[part~=fill]{background:var(--mbx-accent);position:absolute;top:0;bottom:0;left:0}[part~=thumb]{background:var(--mbx-text);pointer-events:none;border-radius:50%;width:.75em;height:.75em;margin:-.375em 0 0 -.375em;position:absolute;top:50%}";
4
4
  const BUTTON_STYLE = BUTTON_STYLE_CSS;
5
5
  /** The style of a slider: the rail, the track with its fill, and the thumb. */
@@ -11,7 +11,7 @@ function number(node, name, fallback) {
11
11
  return Number.isFinite(value) && value >= 0 ? value : fallback;
12
12
  }
13
13
  /** The style of a menu: the button from BUTTON_STYLE, and the popup above it with its items. */
14
- const MENU_STYLE = ":host{display:inline-flex}:host([hidden]){display:none}[part~=button]{width:2.5em;height:2.5em;font:inherit;color:inherit;border-radius:var(--mbx-radius);cursor:pointer;opacity:.9;background:0 0;border:0;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex;position:relative}[part~=button][aria-label]:after{content:attr(aria-label);display:var(--mbx-tooltip,block);background:var(--mbx-surface);border-radius:var(--mbx-radius);white-space:nowrap;pointer-events:none;opacity:0;margin-bottom:.4615em;padding:.3077em .6154em;font-size:.8125em;transition:opacity .1s;position:absolute;bottom:100%;left:50%;transform:translate(-50%)}[part~=button][aria-label]:focus:after{opacity:1;transition-delay:.4s}[part~=button][aria-label]:focus:not(:focus-visible):after{opacity:0;transition-delay:0s}@media (hover:hover){[part~=button][aria-label]:hover:after{opacity:1;transition-delay:.4s}}:host(:last-child) [part~=button][aria-label]:after{left:auto;right:0;transform:none}[part~=button]:hover{opacity:1}[part~=button]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=button]:focus:not(:focus-visible){outline:none}[part~=icon],::slotted(*){fill:currentColor;width:1.75em;height:1.75em}slot[hidden]{display:none}:host{position:relative}[part~=popup]{box-sizing:border-box;overscroll-behavior:contain;border-radius:var(--mbx-radius);background:#1c1c20f2;flex-direction:column;min-width:16em;margin-bottom:.5714em;padding:.4286em;font-size:.875em;display:flex;position:absolute;bottom:100%;right:0;overflow-y:auto;box-shadow:0 4px 16px #00000080}[part~=popup][hidden]{display:none}[part~=section]{flex-direction:column;display:flex}[part~=section]+[part~=section]{border-top:1px solid #ffffff1f;margin-top:.4286em;padding-top:.4286em}[part~=section-label]{letter-spacing:.06em;text-transform:uppercase;color:var(--mbx-muted);padding:.3636em 1.0909em .1818em;font-size:.7857em;font-weight:600}[part~=glyph-item]{padding-left:1em}[part~=glyph-item]>svg{margin-right:.75em}[part~=item]{width:100%;font:inherit;color:inherit;text-align:left;white-space:nowrap;border-radius:var(--mbx-radius);cursor:pointer;background:0 0;border:0;align-items:center;padding:.7857em 1em .7857em 2.2857em;display:flex}[part~=item]:hover{background:#ffffff1f}[part~=item-text]{white-space:normal;-webkit-line-clamp:2;-webkit-box-orient:vertical;min-width:0;max-width:16em;display:-webkit-box;overflow:hidden}[part~=item-image]{object-fit:cover;background:#ffffff14;border-radius:2px;flex:none;width:4.5714em;height:2.5714em;margin-right:.8571em}[part~=item-badge]{border:1px solid;border-radius:2px;flex:none;margin-left:auto;padding:0 .381em;font-size:.75em;font-weight:600;line-height:1.5}[part~=item-glyph]{border:0;padding:0;font-size:1em;display:inline-flex}[part~=item-glyph] svg,[part~=glyph-item]>svg{fill:currentColor;flex:none;width:1.5em;height:1.5em}[part~=badge-text]{clip:rect(0 0 0 0);white-space:nowrap;width:1px;height:1px;position:absolute;overflow:hidden}[part~=item-detail]{color:var(--mbx-muted);font-variant-numeric:tabular-nums;margin-left:auto;padding-left:.8571em}[part~=item-badge]~[part~=item-badge],[part~=item-badge]~[part~=item-detail]{margin-left:.7619em}[part~=item]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=item]:focus:not(:focus-visible){outline:none}[part~=page-item]{padding-right:2em;position:relative}[part~=page-item]:after{content:\"\";opacity:.7;border:1.5px solid;border-width:1.5px 1.5px 0 0;width:.5em;height:.5em;margin-top:-.2857em;position:absolute;top:50%;right:.8571em;transform:rotate(45deg)}[part~=title],[part~=back-item]{letter-spacing:.06em;text-transform:uppercase;color:var(--mbx-muted);font-size:.8125em;font-weight:600}[part~=title]{border-bottom:1px solid #ffffff1f;margin:-.5275em -.5275em .5275em;padding:.9231em 1.4066em}[part~=back-item]{border-bottom:1px solid #ffffff1f;border-radius:0;margin-bottom:.5275em;padding:.9231em 1.2308em .9231em 2.4615em;position:relative}[part~=back-item]:before{content:\"\";opacity:.7;border:0 solid;border-width:1.5px 0 0 1.5px;width:.5em;height:.5em;margin-top:-.2857em;position:absolute;top:50%;left:1em;transform:rotate(-45deg)}[part~=checked]{background:#ffffff14;position:relative}[part~=checked]:before{content:\"\";background:var(--mbx-accent);border-radius:50%;width:.4286em;height:.4286em;margin-top:-.2143em;position:absolute;top:50%;left:1em}:host([layout=compact]) [part~=popup]{z-index:1000;padding-bottom:calc(.4286em + env(safe-area-inset-bottom,0px));box-shadow:none;background:#1c1c20;border-radius:.75em .75em 0 0;margin:0;font-size:1em;right:auto}[part~=backdrop]{z-index:999;background:#00000080;position:absolute}[part~=backdrop][hidden]{display:none}";
14
+ const MENU_STYLE = ":host{display:inline-flex}:host([hidden]),:host([away]){display:none}[part~=button]{width:2.5em;height:2.5em;font:inherit;color:inherit;border-radius:var(--mbx-radius);cursor:pointer;opacity:.9;background:0 0;border:0;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex;position:relative}[part~=button][aria-label]:after{content:attr(aria-label);display:var(--mbx-tooltip,block);background:var(--mbx-surface);border-radius:var(--mbx-radius);white-space:nowrap;pointer-events:none;opacity:0;margin-bottom:.4615em;padding:.3077em .6154em;font-size:.8125em;transition:opacity .1s;position:absolute;bottom:100%;left:50%;transform:translate(-50%)}[part~=button][aria-label]:focus:after{opacity:1;transition-delay:.4s}[part~=button][aria-label]:focus:not(:focus-visible):after{opacity:0;transition-delay:0s}@media (hover:hover){[part~=button][aria-label]:hover:after{opacity:1;transition-delay:.4s}}:host(:last-child) [part~=button][aria-label]:after{left:auto;right:0;transform:none}[part~=button]:hover{opacity:1}[part~=button]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=button]:focus:not(:focus-visible){outline:none}[part~=icon],::slotted(*){fill:currentColor;width:1.75em;height:1.75em}slot[hidden]{display:none}:host{position:relative}[part~=popup]{box-sizing:border-box;overscroll-behavior:contain;border-radius:var(--mbx-radius);background:#1c1c20f2;flex-direction:column;min-width:16em;margin-bottom:.5714em;padding:.4286em;font-size:.875em;display:flex;position:absolute;bottom:100%;right:0;overflow-y:auto;box-shadow:0 4px 16px #00000080}[part~=popup][hidden]{display:none}[part~=section]{flex-direction:column;display:flex}[part~=section]+[part~=section]{border-top:1px solid #ffffff1f;margin-top:.4286em;padding-top:.4286em}[part~=section-label]{letter-spacing:.06em;text-transform:uppercase;color:var(--mbx-muted);padding:.3636em 1.0909em .1818em;font-size:.7857em;font-weight:600}[part~=glyph-item]{padding-left:1em}[part~=glyph-item]>svg{margin-right:.75em}[part~=item]{width:100%;font:inherit;color:inherit;text-align:left;white-space:nowrap;border-radius:var(--mbx-radius);cursor:pointer;background:0 0;border:0;align-items:center;padding:.7857em 1em .7857em 2.2857em;display:flex}[part~=item]:hover{background:#ffffff1f}[part~=item-text]{white-space:normal;-webkit-line-clamp:2;-webkit-box-orient:vertical;min-width:0;max-width:16em;display:-webkit-box;overflow:hidden}[part~=item-image]{object-fit:cover;background:#ffffff14;border-radius:2px;flex:none;width:4.5714em;height:2.5714em;margin-right:.8571em}[part~=item-badge]{border:1px solid;border-radius:2px;flex:none;margin-left:auto;padding:0 .381em;font-size:.75em;font-weight:600;line-height:1.5}[part~=item-glyph]{border:0;padding:0;font-size:1em;display:inline-flex}[part~=item-glyph] svg,[part~=glyph-item]>svg{fill:currentColor;flex:none;width:1.5em;height:1.5em}[part~=badge-text]{clip:rect(0 0 0 0);white-space:nowrap;width:1px;height:1px;position:absolute;overflow:hidden}[part~=item-detail]{color:var(--mbx-muted);font-variant-numeric:tabular-nums;margin-left:auto;padding-left:.8571em}[part~=item-badge]~[part~=item-badge],[part~=item-badge]~[part~=item-detail]{margin-left:.7619em}[part~=item]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=item]:focus:not(:focus-visible){outline:none}[part~=page-item]{padding-right:2em;position:relative}[part~=page-item]:after{content:\"\";opacity:.7;border:1.5px solid;border-width:1.5px 1.5px 0 0;width:.5em;height:.5em;margin-top:-.2857em;position:absolute;top:50%;right:.8571em;transform:rotate(45deg)}[part~=title],[part~=back-item]{letter-spacing:.06em;text-transform:uppercase;color:var(--mbx-muted);font-size:.8125em;font-weight:600}[part~=title]{border-bottom:1px solid #ffffff1f;margin:-.5275em -.5275em .5275em;padding:.9231em 1.4066em}[part~=back-item]{border-bottom:1px solid #ffffff1f;border-radius:0;margin-bottom:.5275em;padding:.9231em 1.2308em .9231em 2.4615em;position:relative}[part~=back-item]:before{content:\"\";opacity:.7;border:0 solid;border-width:1.5px 0 0 1.5px;width:.5em;height:.5em;margin-top:-.2857em;position:absolute;top:50%;left:1em;transform:rotate(-45deg)}[part~=checked]{background:#ffffff14;position:relative}[part~=checked]:before{content:\"\";background:var(--mbx-accent);border-radius:50%;width:.4286em;height:.4286em;margin-top:-.2143em;position:absolute;top:50%;left:1em}:host([layout=compact]) [part~=popup]{z-index:1000;padding-bottom:calc(.4286em + env(safe-area-inset-bottom,0px));box-shadow:none;background:#1c1c20;border-radius:.75em .75em 0 0;margin:0;font-size:1em;right:auto}[part~=backdrop]{z-index:999;background:#00000080;position:absolute}[part~=backdrop][hidden]{display:none}";
15
15
  /** Puts a control in the bar's seek row when it is in a bar, unless the page wrote a `slot` of its own. */
16
16
  function seekRow(node) {
17
17
  if (node.parentElement?.localName === "mbx-control-bar" && !node.hasAttribute("slot")) node.slot = "seek";
@@ -54,7 +54,7 @@ function shownPaused(player, names = HELD) {
54
54
  const held = player.getAttribute(name);
55
55
  if (held !== null) return held === "paused";
56
56
  }
57
- return player.video.paused;
57
+ return player.media.paused;
58
58
  }
59
59
  export { BUTTON_STYLE, HELD, MENU_STYLE, SLIDER_STYLE, iconSlots, number, seekRow, show, shownPaused, style };
60
60
 
@@ -1 +1 @@
1
- {"version":3,"file":"shared.js","names":[],"sources":["../../src/elements/shared.ts"],"sourcesContent":["/**\n * The style every button control shares. Each element carries its own\n * copy in its shadow root, so the rules are short and the tokens come\n * through the `--mbx-*` custom properties the player sets, which inherit\n * through light DOM into every control.\n *\n * Nothing carries `!important`: a page's `::part()` rule must win.\n */\nimport type { PlayerHost } from '../host.js';\nimport BUTTON_STYLE_CSS from './button.css?inline';\nimport MENU_STYLE_CSS from './menu.css?inline';\nimport SLIDER_STYLE_CSS from './slider.css?inline';\nexport const BUTTON_STYLE = BUTTON_STYLE_CSS;\n\n/** The style of a slider: the rail, the track with its fill, and the thumb. */\nexport const SLIDER_STYLE = SLIDER_STYLE_CSS;\n\n/** A non-negative number from an attribute, else the default. */\nexport function number(node: Element, name: string, fallback: number): number {\n const raw = node.getAttribute(name);\n const value = raw === null ? Number.NaN : Number(raw);\n return Number.isFinite(value) && value >= 0 ? value : fallback;\n}\n\n/** The style of a menu: the button from BUTTON_STYLE, and the popup above it with its items. */\nexport const MENU_STYLE = BUTTON_STYLE + MENU_STYLE_CSS;\n\n/** Puts a control in the bar's seek row when it is in a bar, unless the page wrote a `slot` of its own. */\nexport function seekRow(node: HTMLElement): void {\n if (node.parentElement?.localName === 'mbx-control-bar' && !node.hasAttribute('slot')) {\n node.slot = 'seek';\n }\n}\n\n/** A `<style>` with `text`, for a shadow root. */\nexport function style(text: string): HTMLStyleElement {\n const node = document.createElement('style');\n node.textContent = text;\n return node;\n}\n\n/**\n * A named slot per state with the default glyph as its fallback, so a page\n * drops its own SVG into `slot=\"icon-<state>\"` and the button keeps the\n * name. Returns the slots by state; `show` hides all but one.\n */\nexport function iconSlots<S extends string>(\n states: readonly S[],\n fallback: (state: S) => SVGSVGElement,\n): Record<S, HTMLSlotElement> {\n const out = {} as Record<S, HTMLSlotElement>;\n for (const state of states) {\n const slot = document.createElement('slot');\n slot.name = `icon-${state}`;\n slot.append(fallback(state));\n slot.hidden = true;\n out[state] = slot;\n }\n return out;\n}\n\nexport function show<S extends string>(slots: Record<S, HTMLSlotElement>, state: S): void {\n for (const key of Object.keys(slots) as S[]) slots[key].hidden = key !== state;\n}\n\n/**\n * The attributes the player carries while it holds the video in another\n * state than the one shown: `scrubbing` through a drag, `switching` through\n * the load of `switchSource` or a version. Each holds the state from\n * before, `playing` or `paused`.\n */\nexport const HELD = ['scrubbing', 'switching'] as const;\n\n/** Whether the controls show the video as paused: the held state, if one of `names` holds it. */\nexport function shownPaused(player: PlayerHost, names: readonly string[] = HELD): boolean {\n for (const name of names) {\n const held = player.getAttribute(name);\n if (held !== null) return held === 'paused';\n }\n return player.video.paused;\n}\n"],"mappings":";AASA,MAAA,mBAAA;AAEA,MAAA,mBAAA;AACA,MAAA,eAAA;;AAGA,MAAA,eAAA;;AAGA,SAAA,OAAA,MAAA,MAAA,UAAA;CACA,MAAA,MAAA,KAAA,aAAA,IAAA;CACA,MAAA,QAAA,QAAA,OAAA,MAAA,OAAA,GAAA;CACA,OAAA,OAAA,SAAA,KAAA,KAAA,SAAA,IAAA,QAAA;AACA;;AAGA,MAAA,aAAA;;AAGA,SAAA,QAAA,MAAA;CACA,IAAA,KAAA,eAAA,cAAA,qBAAA,CAAA,KAAA,aAAA,MAAA,GACA,KAAA,OAAA;AAEA;;AAGA,SAAA,MAAA,MAAA;CACA,MAAA,OAAA,SAAA,cAAA,OAAA;CACA,KAAA,cAAA;CACA,OAAA;AACA;;;;;;AAOA,SAAA,UACA,QACA,UACA;CACA,MAAA,MAAA,CAAA;CACA,KAAA,MAAA,SAAA,QAAA;EACA,MAAA,OAAA,SAAA,cAAA,MAAA;EACA,KAAA,OAAA,QAAA;EACA,KAAA,OAAA,SAAA,KAAA,CAAA;EACA,KAAA,SAAA;EACA,IAAA,SAAA;CACA;CACA,OAAA;AACA;AAEA,SAAA,KAAA,OAAA,OAAA;CACA,KAAA,MAAA,OAAA,OAAA,KAAA,KAAA,GAAA,MAAA,IAAA,CAAA,SAAA,QAAA;AACA;;;;;;;AAQA,MAAA,OAAA,CAAA,aAAA,WAAA;;AAGA,SAAA,YAAA,QAAA,QAAA,MAAA;CACA,KAAA,MAAA,QAAA,OAAA;EACA,MAAA,OAAA,OAAA,aAAA,IAAA;EACA,IAAA,SAAA,MAAA,OAAA,SAAA;CACA;CACA,OAAA,OAAA,MAAA;AACA"}
1
+ {"version":3,"file":"shared.js","names":[],"sources":["../../src/elements/shared.ts"],"sourcesContent":["/**\n * The style every button control shares. Each element carries its own\n * copy in its shadow root, so the rules are short and the tokens come\n * through the `--mbx-*` custom properties the player sets, which inherit\n * through light DOM into every control.\n *\n * Nothing carries `!important`: a page's `::part()` rule must win.\n */\nimport type { PlayerHost } from '../host.js';\nimport BUTTON_STYLE_CSS from './button.css?inline';\nimport MENU_STYLE_CSS from './menu.css?inline';\nimport SLIDER_STYLE_CSS from './slider.css?inline';\nexport const BUTTON_STYLE = BUTTON_STYLE_CSS;\n\n/** The style of a slider: the rail, the track with its fill, and the thumb. */\nexport const SLIDER_STYLE = SLIDER_STYLE_CSS;\n\n/** A non-negative number from an attribute, else the default. */\nexport function number(node: Element, name: string, fallback: number): number {\n const raw = node.getAttribute(name);\n const value = raw === null ? Number.NaN : Number(raw);\n return Number.isFinite(value) && value >= 0 ? value : fallback;\n}\n\n/** The style of a menu: the button from BUTTON_STYLE, and the popup above it with its items. */\nexport const MENU_STYLE = BUTTON_STYLE + MENU_STYLE_CSS;\n\n/** Puts a control in the bar's seek row when it is in a bar, unless the page wrote a `slot` of its own. */\nexport function seekRow(node: HTMLElement): void {\n if (node.parentElement?.localName === 'mbx-control-bar' && !node.hasAttribute('slot')) {\n node.slot = 'seek';\n }\n}\n\n/** A `<style>` with `text`, for a shadow root. */\nexport function style(text: string): HTMLStyleElement {\n const node = document.createElement('style');\n node.textContent = text;\n return node;\n}\n\n/**\n * A named slot per state with the default glyph as its fallback, so a page\n * drops its own SVG into `slot=\"icon-<state>\"` and the button keeps the\n * name. Returns the slots by state; `show` hides all but one.\n */\nexport function iconSlots<S extends string>(\n states: readonly S[],\n fallback: (state: S) => SVGSVGElement,\n): Record<S, HTMLSlotElement> {\n const out = {} as Record<S, HTMLSlotElement>;\n for (const state of states) {\n const slot = document.createElement('slot');\n slot.name = `icon-${state}`;\n slot.append(fallback(state));\n slot.hidden = true;\n out[state] = slot;\n }\n return out;\n}\n\nexport function show<S extends string>(slots: Record<S, HTMLSlotElement>, state: S): void {\n for (const key of Object.keys(slots) as S[]) slots[key].hidden = key !== state;\n}\n\n/**\n * The attributes the player carries while it holds the video in another\n * state than the one shown: `scrubbing` through a drag, `switching` through\n * the load of `switchSource` or a version. Each holds the state from\n * before, `playing` or `paused`.\n */\nexport const HELD = ['scrubbing', 'switching'] as const;\n\n/** Whether the controls show the video as paused: the held state, if one of `names` holds it. */\nexport function shownPaused(player: PlayerHost, names: readonly string[] = HELD): boolean {\n for (const name of names) {\n const held = player.getAttribute(name);\n if (held !== null) return held === 'paused';\n }\n return player.media.paused;\n}\n"],"mappings":";AASA,MAAA,mBAAA;AAEA,MAAA,mBAAA;AACA,MAAa,eAAe;;AAG5B,MAAa,eAAe;;AAG5B,SAAgB,OAAO,MAAe,MAAc,UAA0B;CAC5E,MAAM,MAAM,KAAK,aAAa,IAAI;CAClC,MAAM,QAAQ,QAAQ,OAAO,MAAa,OAAO,GAAG;CACpD,OAAO,OAAO,SAAS,KAAK,KAAK,SAAS,IAAI,QAAQ;AACxD;;AAGA,MAAa,aAAa;;AAG1B,SAAgB,QAAQ,MAAyB;CAC/C,IAAI,KAAK,eAAe,cAAc,qBAAqB,CAAC,KAAK,aAAa,MAAM,GAClF,KAAK,OAAO;AAEhB;;AAGA,SAAgB,MAAM,MAAgC;CACpD,MAAM,OAAO,SAAS,cAAc,OAAO;CAC3C,KAAK,cAAc;CACnB,OAAO;AACT;;;;;;AAOA,SAAgB,UACd,QACA,UAC4B;CAC5B,MAAM,MAAM,CAAC;CACb,KAAK,MAAM,SAAS,QAAQ;EAC1B,MAAM,OAAO,SAAS,cAAc,MAAM;EAC1C,KAAK,OAAO,QAAQ;EACpB,KAAK,OAAO,SAAS,KAAK,CAAC;EAC3B,KAAK,SAAS;EACd,IAAI,SAAS;CACf;CACA,OAAO;AACT;AAEA,SAAgB,KAAuB,OAAmC,OAAgB;CACxF,KAAK,MAAM,OAAO,OAAO,KAAK,KAAK,GAAU,MAAM,IAAI,CAAC,SAAS,QAAQ;AAC3E;;;;;;;AAQA,MAAa,OAAO,CAAC,aAAa,WAAW;;AAG7C,SAAgB,YAAY,QAAoB,QAA2B,MAAe;CACxF,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,OAAO,OAAO,aAAa,IAAI;EACrC,IAAI,SAAS,MAAM,OAAO,SAAS;CACrC;CACA,OAAO,OAAO,MAAM;AACtB"}
@@ -1,6 +1,6 @@
1
+ import { icon } from "../controls/icons.js";
1
2
  import { setChildren } from "../dom.js";
2
3
  import { fill } from "../labels.js";
3
- import { icon } from "../controls/icons.js";
4
4
  import { Component } from "./component.js";
5
5
  import { BUTTON_STYLE, style } from "./shared.js";
6
6
  // src/elements/skip-button.ts
@@ -35,7 +35,7 @@ var MbxSkipButton = class extends Component {
35
35
  return Number.isFinite(value) ? value : SECONDS;
36
36
  }
37
37
  skip() {
38
- const video = this.player?.video;
38
+ const video = this.player?.media;
39
39
  if (video === void 0) return;
40
40
  const ranges = video.seekable;
41
41
  const end = Number.isFinite(video.duration) ? video.duration : ranges.length > 0 ? ranges.end(ranges.length - 1) : video.currentTime;
@@ -1 +1 @@
1
- {"version":3,"file":"skip-button.js","names":[],"sources":["../../src/elements/skip-button.ts"],"sourcesContent":["/**\n * <mbx-skip-button>: moves the playhead by `seconds`, negative for back,\n * within what the video can reach. The glyph says the amount where the\n * set has one, 5, 10, 15 and 30, and a plain arrow otherwise; `icon` takes a\n * page's own. The name comes from `label`, where `{seconds}` is the\n * amount without its sign: \"Back {seconds} seconds\".\n */\nimport type { IconName } from '../controls/icons.js';\nimport { icon } from '../controls/icons.js';\nimport { setChildren } from '../dom.js';\nimport type { PlayerHost } from '../host.js';\nimport { fill } from '../labels.js';\nimport { Component } from './component.js';\nimport { BUTTON_STYLE, style } from './shared.js';\n\nconst SECONDS = 10;\n\n/** The glyph for a skip amount: the set draws 5, 10, 15 and 30, and a plain arrow says the rest. */\nfunction glyphFor(back: boolean, amount: number): IconName {\n const side = back ? 'seek-backward' : 'seek-forward';\n if (amount === 5 || amount === 10 || amount === 15 || amount === 30) return `${side}-${amount}`;\n return side;\n}\n\nexport class MbxSkipButton extends Component {\n static get observedAttributes(): readonly string[] {\n return ['seconds', 'label'];\n }\n\n declare private readonly button: HTMLButtonElement;\n declare private readonly glyph: HTMLSlotElement;\n\n constructor() {\n super();\n const root = this.attachShadow({ mode: 'open' });\n this.button = document.createElement('button');\n this.button.type = 'button';\n this.button.setAttribute('part', 'button');\n this.glyph = document.createElement('slot');\n this.glyph.name = 'icon';\n this.button.append(this.glyph);\n this.button.addEventListener('click', () => {\n this.skip();\n });\n root.append(style(BUTTON_STYLE), this.button);\n }\n\n /** The amount, signed. A value that is not a number is the default. */\n private seconds(): number {\n const value = Number(this.getAttribute('seconds') ?? SECONDS);\n return Number.isFinite(value) ? value : SECONDS;\n }\n\n private skip(): void {\n const video = this.player?.video;\n if (video === undefined) return;\n const ranges = video.seekable;\n const end = Number.isFinite(video.duration)\n ? video.duration\n : ranges.length > 0\n ? ranges.end(ranges.length - 1)\n : video.currentTime;\n video.currentTime = Math.min(end, Math.max(0, video.currentTime + this.seconds()));\n }\n\n protected override attach(_player: PlayerHost): void {\n this.render();\n }\n\n protected override render(): void {\n const seconds = this.seconds();\n const back = seconds < 0;\n const amount = Math.abs(seconds);\n setChildren(this.glyph, icon(glyphFor(back, amount)));\n const template = back\n ? this.word('label', 'skipBack', 'Back {seconds} seconds')\n : this.word('label', 'skipForward', 'Forward {seconds} seconds');\n this.button.setAttribute('aria-label', fill(template, { seconds: amount }));\n }\n}\n"],"mappings":";;;;;;AAeA,MAAM,UAAU;;AAGhB,SAAS,SAAS,MAAe,QAA0B;CACzD,MAAM,OAAO,OAAO,kBAAkB;CACtC,IAAI,WAAW,KAAK,WAAW,MAAM,WAAW,MAAM,WAAW,IA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BAAwB,IACvD,KAAK,KAAK,SAAS,eAAe,2BAA2B;EACjE,KAAK,OAAO,aAAa,cAAc,KAAK,UAAU,EAAE,SAAS,OAAO,CAAC,CAAC;CAC5E;AACF"}
1
+ {"version":3,"file":"skip-button.js","names":[],"sources":["../../src/elements/skip-button.ts"],"sourcesContent":["/**\n * <mbx-skip-button>: moves the playhead by `seconds`, negative for back,\n * within what the video can reach. The glyph says the amount where the\n * set has one, 5, 10, 15 and 30, and a plain arrow otherwise; `icon` takes a\n * page's own. The name comes from `label`, where `{seconds}` is the\n * amount without its sign: \"Back {seconds} seconds\".\n */\nimport type { IconName } from '../controls/icons.js';\nimport { icon } from '../controls/icons.js';\nimport { setChildren } from '../dom.js';\nimport type { PlayerHost } from '../host.js';\nimport { fill } from '../labels.js';\nimport { Component } from './component.js';\nimport { BUTTON_STYLE, style } from './shared.js';\n\nconst SECONDS = 10;\n\n/** The glyph for a skip amount: the set draws 5, 10, 15 and 30, and a plain arrow says the rest. */\nfunction glyphFor(back: boolean, amount: number): IconName {\n const side = back ? 'seek-backward' : 'seek-forward';\n if (amount === 5 || amount === 10 || amount === 15 || amount === 30) return `${side}-${amount}`;\n return side;\n}\n\nexport class MbxSkipButton extends Component {\n static get observedAttributes(): readonly string[] {\n return ['seconds', 'label'];\n }\n\n declare private readonly button: HTMLButtonElement;\n declare private readonly glyph: HTMLSlotElement;\n\n constructor() {\n super();\n const root = this.attachShadow({ mode: 'open' });\n this.button = document.createElement('button');\n this.button.type = 'button';\n this.button.setAttribute('part', 'button');\n this.glyph = document.createElement('slot');\n this.glyph.name = 'icon';\n this.button.append(this.glyph);\n this.button.addEventListener('click', () => {\n this.skip();\n });\n root.append(style(BUTTON_STYLE), this.button);\n }\n\n /** The amount, signed. A value that is not a number is the default. */\n private seconds(): number {\n const value = Number(this.getAttribute('seconds') ?? SECONDS);\n return Number.isFinite(value) ? value : SECONDS;\n }\n\n private skip(): void {\n const video = this.player?.media;\n if (video === undefined) return;\n const ranges = video.seekable;\n const end = Number.isFinite(video.duration)\n ? video.duration\n : ranges.length > 0\n ? ranges.end(ranges.length - 1)\n : video.currentTime;\n video.currentTime = Math.min(end, Math.max(0, video.currentTime + this.seconds()));\n }\n\n protected override attach(_player: PlayerHost): void {\n this.render();\n }\n\n protected override render(): void {\n const seconds = this.seconds();\n const back = seconds < 0;\n const amount = Math.abs(seconds);\n setChildren(this.glyph, icon(glyphFor(back, amount)));\n const template = back\n ? this.word('label', 'skipBack', 'Back {seconds} seconds')\n : this.word('label', 'skipForward', 'Forward {seconds} seconds');\n this.button.setAttribute('aria-label', fill(template, { seconds: amount }));\n }\n}\n"],"mappings":";;;;;;AAeA,MAAM,UAAU;;AAGhB,SAAS,SAAS,MAAe,QAA0B;CACzD,MAAM,OAAO,OAAO,kBAAkB;CACtC,IAAI,WAAW,KAAK,WAAW,MAAM,WAAW,MAAM,WAAW,IAAI,OAAO,GAAG,KAAK,GAAG;CACvF,OAAO;AACT;AAEA,IAAa,gBAAb,cAAmC,UAAU;CAC3C,WAAW,qBAAwC;EACjD,OAAO,CAAC,WAAW,OAAO;CAC5B;CAKA,cAAc;EACZ,MAAM;EACN,MAAM,OAAO,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;EAC/C,KAAK,SAAS,SAAS,cAAc,QAAQ;EAC7C,KAAK,OAAO,OAAO;EACnB,KAAK,OAAO,aAAa,QAAQ,QAAQ;EACzC,KAAK,QAAQ,SAAS,cAAc,MAAM;EAC1C,KAAK,MAAM,OAAO;EAClB,KAAK,OAAO,OAAO,KAAK,KAAK;EAC7B,KAAK,OAAO,iBAAiB,eAAe;GAC1C,KAAK,KAAK;EACZ,CAAC;EACD,KAAK,OAAO,MAAM,YAAY,GAAG,KAAK,MAAM;CAC9C;;CAGQ,UAAkB;EACxB,MAAM,QAAQ,OAAO,KAAK,aAAa,SAAS,KAAK,OAAO;EAC5D,OAAO,OAAO,SAAS,KAAK,IAAI,QAAQ;CAC1C;CAEQ,OAAa;EACnB,MAAM,QAAQ,KAAK,QAAQ;EAC3B,IAAI,UAAU,KAAA,GAAW;EACzB,MAAM,SAAS,MAAM;EACrB,MAAM,MAAM,OAAO,SAAS,MAAM,QAAQ,IACtC,MAAM,WACN,OAAO,SAAS,IACd,OAAO,IAAI,OAAO,SAAS,CAAC,IAC5B,MAAM;EACZ,MAAM,cAAc,KAAK,IAAI,KAAK,KAAK,IAAI,GAAG,MAAM,cAAc,KAAK,QAAQ,CAAC,CAAC;CACnF;CAEmB,OAAO,SAA2B;EACnD,KAAK,OAAO;CACd;CAEmB,SAAe;EAChC,MAAM,UAAU,KAAK,QAAQ;EAC7B,MAAM,OAAO,UAAU;EACvB,MAAM,SAAS,KAAK,IAAI,OAAO;EAC/B,YAAY,KAAK,OAAO,KAAK,SAAS,MAAM,MAAM,CAAC,CAAC;EACpD,MAAM,WAAW,OACb,KAAK,KAAK,SAAS,YAAY,wBAAwB,IACvD,KAAK,KAAK,SAAS,eAAe,2BAA2B;EACjE,KAAK,OAAO,aAAa,cAAc,KAAK,UAAU,EAAE,SAAS,OAAO,CAAC,CAAC;CAC5E;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"spacer.js","names":[],"sources":["../../src/elements/spacer.ts"],"sourcesContent":["/** <mbx-spacer>: takes the room in a row, so what follows sits at the far end. */\nimport { style } from './shared.js';\nimport STYLE from './spacer.css?inline';\n\nexport class MbxSpacer extends HTMLElement {\n constructor() {\n super();\n this.attachShadow({ mode: 'open' }).append(style(STYLE));\n }\n}\n"],"mappings":";;;AAEA,MAAA,QAAA;AAEA,IAAA,YAAA,cAAA,YAAA;CACA,cAAA;EACA,MAAA;EACA,KAAA,aAAA,EAAA,MAAA,OAAA,CAAA,CAAA,CAAA,OAAA,MAAA,KAAA,CAAA;CACA;AACA"}
1
+ {"version":3,"file":"spacer.js","names":[],"sources":["../../src/elements/spacer.ts"],"sourcesContent":["/** <mbx-spacer>: takes the room in a row, so what follows sits at the far end. */\nimport { style } from './shared.js';\nimport STYLE from './spacer.css?inline';\n\nexport class MbxSpacer extends HTMLElement {\n constructor() {\n super();\n this.attachShadow({ mode: 'open' }).append(style(STYLE));\n }\n}\n"],"mappings":";;;AAEA,MAAA,QAAA;AAEA,IAAa,YAAb,cAA+B,YAAY;CACzC,cAAc;EACZ,MAAM;EACN,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,OAAO,MAAM,KAAK,CAAC;CACzD;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"speed-menu.d.ts","sourceRoot":"","sources":["../../src/elements/speed-menu.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAU,MAAM,mBAAmB,CAAC;AAKxD,qBAAa,YAAa,SAAQ,WAAW;IAC3C,MAAM,KAAK,kBAAkB,IAAI,SAAS,MAAM,EAAE,CAEjD;;cAOkB,IAAI,IAAI,SAAS,CAAC,MAAM,QAAQ,EAAE,MAAM,CAAC;IAI5D,OAAO,CAAC,KAAK;cAUM,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;cAOhC,MAAM,IAAI,IAAI;CAsBlC"}
1
+ {"version":3,"file":"speed-menu.d.ts","sourceRoot":"","sources":["../../src/elements/speed-menu.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAU,MAAM,mBAAmB,CAAC;AAKxD,qBAAa,YAAa,SAAQ,WAAW;IAC3C,MAAM,KAAK,kBAAkB,IAAI,SAAS,MAAM,EAAE,CAEjD;;cASkB,IAAI,IAAI,SAAS,CAAC,MAAM,QAAQ,EAAE,MAAM,CAAC;IAI5D,OAAO,CAAC,KAAK;cAUM,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;cAOhC,MAAM,IAAI,IAAI;CAsBlC"}
@@ -1,5 +1,5 @@
1
- import { show } from "./shared.js";
2
1
  import { MenuElement, single } from "./menu-element.js";
2
+ import { show } from "./shared.js";
3
3
  // src/elements/speed-menu.ts
4
4
  const RATES = [
5
5
  .5,
@@ -20,6 +20,7 @@ var MbxSpeedMenu = class extends MenuElement {
20
20
  }
21
21
  constructor() {
22
22
  super(...single("playback-speed"));
23
+ this.leaves = "remote";
23
24
  show(this.slots, "default");
24
25
  }
25
26
  name() {
@@ -32,14 +33,14 @@ var MbxSpeedMenu = class extends MenuElement {
32
33
  return out.length === 0 ? RATES : out;
33
34
  }
34
35
  attach(player) {
35
- this.listen(player.video, ["ratechange"], () => {
36
+ this.listen(player.media, ["ratechange"], () => {
36
37
  this.render();
37
38
  });
38
39
  this.render();
39
40
  }
40
41
  render() {
41
42
  super.render();
42
- const video = this.player?.video;
43
+ const video = this.player?.media;
43
44
  if (video === void 0) return;
44
45
  const normal = this.word("label-normal", "speedNormal", "Normal");
45
46
  const items = this.rates().map((rate) => [String(rate), rate === 1 ? normal : `${rate}×`]);
@@ -1 +1 @@
1
- {"version":3,"file":"speed-menu.js","names":[],"sources":["../../src/elements/speed-menu.ts"],"sourcesContent":["/**\n * <mbx-speed-menu>: the rate over `video.playbackRate`. Video-only, so it\n * works for every session, native included. The rates come from `rates`,\n * space-separated, and the video's own value is the truth, read on\n * `ratechange` and listed even when it is not one of them. The name comes\n * from `label`, the word for one from `label-normal`.\n */\nimport type { PlayerHost } from '../host.js';\nimport type { Messages } from '../messages.js';\nimport { MenuElement, single } from './menu-element.js';\nimport { show } from './shared.js';\n\nconst RATES = [0.5, 0.75, 1, 1.25, 1.5, 2];\n\nexport class MbxSpeedMenu extends MenuElement {\n static get observedAttributes(): readonly string[] {\n return ['rates', 'label', 'label-normal', 'label-back'];\n }\n\n constructor() {\n super(...single('playback-speed'));\n show(this.slots, 'default');\n }\n\n protected override name(): readonly [keyof Messages, string] {\n return ['speed', 'Playback speed'];\n }\n\n private rates(): number[] {\n const raw = this.getAttribute('rates');\n if (raw === null) return RATES;\n const out = raw\n .split(/\\s+/)\n .map(Number)\n .filter((rate) => Number.isFinite(rate) && rate > 0);\n return out.length === 0 ? RATES : out;\n }\n\n protected override attach(player: PlayerHost): void {\n this.listen(player.video, ['ratechange'], () => {\n this.render();\n });\n this.render();\n }\n\n protected override render(): void {\n super.render();\n const video = this.player?.video;\n if (video === undefined) return;\n const normal = this.word('label-normal', 'speedNormal', 'Normal');\n const items: Array<readonly [string, string]> = this.rates().map((rate) => [\n String(rate),\n rate === 1 ? normal : `${rate}×`,\n ]);\n const current = String(video.playbackRate);\n if (!items.some(([id]) => id === current)) items.push([current, `${current}×`]);\n this.menu.fill([\n {\n name: 'rate',\n items,\n value: current,\n onSelect: (value) => {\n video.playbackRate = Number(value);\n },\n },\n ]);\n }\n}\n"],"mappings":";;;AAYA,MAAM,QAAQ;CAAC;CAAK;CAAM;CAAG;CAAM;CAAK;AAAC;AAEzC,IAAa,eAAb,cAAkC,YAAY;CAC5C,WAAW,qBAAwC;EACjD,OAAO;GAAC;GAAS;GAAS;GAAgB;EAAY;CACxD;CAEA,cAAc;EACZ,MAAM,GAAG,OAAO,gBAAgB,CAAC;EACjC,KAAK,KAAK,OAAO,SAAS;CAC5B;CAEA,OAA6D;EAC3D,OAAO,CAAC,SAAS,gBAAgB;CACnC;CAEA,QAA0B;EACxB,MAAM,MAAM,KAAK,aAAa,OAAO;EACrC,IAAI,QAAQ,MAAM,OAAO;EACzB,MAAM,MAAM,IACT,MAAM,KAAK,CAAC,CACZ,IAAI,MAAM,CAAC,CACX,QAAQ,SAAS,OAAO,SAAS,IAAI,KAAK,OAAO,CAAC;EACrD,OAAO,IAAI,WAAW,IAAI,QAAQ;CACpC;CAEA,OAA0B,QAA0B;EAClD,KAAK,OAAO,OAAO,OAAO,CAAC,YAAY,SAAS;GAC9C,KAAK,OAAO;EACd,CAAC;EACD,KAAK,OAAO;CACd;CAEA,SAAkC;EAChC,MAAM,OAAO;EACb,MAAM,QAAQ,KAAK,QAAQ;EAC3B,IAAI,UAAU,KAAA,GAAW;EACzB,MAAM,SAAS,KAAK,KAAK,gBAAgB,eAAe,QAAQ;EAChE,MAAM,QAA0C,KAAK,MAAM,CAAC,CAAC,KAAK,SAAS,CACzE,OAAO,IAAI,GACX,SAAS,IAAI,SAAS,GAAG,KAAK,EAChC,CAAC;EACD,MAAM,UAAU,OAAO,MAAM,YAAY;EACzC,IAAI,CAAC,MAAM,MAAM,CAAC,QAAQ,OAAO,OAAO,GAAG,MAAM,KAAK,CAAC,SAAS,GAAG,QAAQ,EAAE,CAAC;EAC9E,KAAK,KAAK,KAAK,CACb;GACE,MAAM;GACN;GACA,OAAO;GACP,WAAW,UAAU;IACnB,MAAM,eAAe,OAAO,KAAK;GACnC;EACF,CACF,CAAC;CACH;AACF"}
1
+ {"version":3,"file":"speed-menu.js","names":[],"sources":["../../src/elements/speed-menu.ts"],"sourcesContent":["/**\n * <mbx-speed-menu>: the rate over `video.playbackRate`. Video-only, so it\n * works for every session, native included. The rates come from `rates`,\n * space-separated, and the video's own value is the truth, read on\n * `ratechange` and listed even when it is not one of them. The name comes\n * from `label`, the word for one from `label-normal`.\n */\nimport type { PlayerHost } from '../host.js';\nimport type { Messages } from '../messages.js';\nimport { MenuElement, single } from './menu-element.js';\nimport { show } from './shared.js';\n\nconst RATES = [0.5, 0.75, 1, 1.25, 1.5, 2];\n\nexport class MbxSpeedMenu extends MenuElement {\n static get observedAttributes(): readonly string[] {\n return ['rates', 'label', 'label-normal', 'label-back'];\n }\n\n constructor() {\n super(...single('playback-speed'));\n // It would change the engine of the page, which a device does not play.\n this.leaves = 'remote';\n show(this.slots, 'default');\n }\n\n protected override name(): readonly [keyof Messages, string] {\n return ['speed', 'Playback speed'];\n }\n\n private rates(): number[] {\n const raw = this.getAttribute('rates');\n if (raw === null) return RATES;\n const out = raw\n .split(/\\s+/)\n .map(Number)\n .filter((rate) => Number.isFinite(rate) && rate > 0);\n return out.length === 0 ? RATES : out;\n }\n\n protected override attach(player: PlayerHost): void {\n this.listen(player.media, ['ratechange'], () => {\n this.render();\n });\n this.render();\n }\n\n protected override render(): void {\n super.render();\n const video = this.player?.media;\n if (video === undefined) return;\n const normal = this.word('label-normal', 'speedNormal', 'Normal');\n const items: Array<readonly [string, string]> = this.rates().map((rate) => [\n String(rate),\n rate === 1 ? normal : `${rate}×`,\n ]);\n const current = String(video.playbackRate);\n if (!items.some(([id]) => id === current)) items.push([current, `${current}×`]);\n this.menu.fill([\n {\n name: 'rate',\n items,\n value: current,\n onSelect: (value) => {\n video.playbackRate = Number(value);\n },\n },\n ]);\n }\n}\n"],"mappings":";;;AAYA,MAAM,QAAQ;CAAC;CAAK;CAAM;CAAG;CAAM;CAAK;AAAC;AAEzC,IAAa,eAAb,cAAkC,YAAY;CAC5C,WAAW,qBAAwC;EACjD,OAAO;GAAC;GAAS;GAAS;GAAgB;EAAY;CACxD;CAEA,cAAc;EACZ,MAAM,GAAG,OAAO,gBAAgB,CAAC;EAEjC,KAAK,SAAS;EACd,KAAK,KAAK,OAAO,SAAS;CAC5B;CAEmB,OAA0C;EAC3D,OAAO,CAAC,SAAS,gBAAgB;CACnC;CAEQ,QAAkB;EACxB,MAAM,MAAM,KAAK,aAAa,OAAO;EACrC,IAAI,QAAQ,MAAM,OAAO;EACzB,MAAM,MAAM,IACT,MAAM,KAAK,CAAC,CACZ,IAAI,MAAM,CAAC,CACX,QAAQ,SAAS,OAAO,SAAS,IAAI,KAAK,OAAO,CAAC;EACrD,OAAO,IAAI,WAAW,IAAI,QAAQ;CACpC;CAEmB,OAAO,QAA0B;EAClD,KAAK,OAAO,OAAO,OAAO,CAAC,YAAY,SAAS;GAC9C,KAAK,OAAO;EACd,CAAC;EACD,KAAK,OAAO;CACd;CAEmB,SAAe;EAChC,MAAM,OAAO;EACb,MAAM,QAAQ,KAAK,QAAQ;EAC3B,IAAI,UAAU,KAAA,GAAW;EACzB,MAAM,SAAS,KAAK,KAAK,gBAAgB,eAAe,QAAQ;EAChE,MAAM,QAA0C,KAAK,MAAM,CAAC,CAAC,KAAK,SAAS,CACzE,OAAO,IAAI,GACX,SAAS,IAAI,SAAS,GAAG,KAAK,EAChC,CAAC;EACD,MAAM,UAAU,OAAO,MAAM,YAAY;EACzC,IAAI,CAAC,MAAM,MAAM,CAAC,QAAQ,OAAO,OAAO,GAAG,MAAM,KAAK,CAAC,SAAS,GAAG,QAAQ,EAAE,CAAC;EAC9E,KAAK,KAAK,KAAK,CACb;GACE,MAAM;GACN;GACA,OAAO;GACP,WAAW,UAAU;IACnB,MAAM,eAAe,OAAO,KAAK;GACnC;EACF,CACF,CAAC;CACH;AACF"}
@@ -33,7 +33,7 @@ var MbxSpinner = class extends Component {
33
33
  super.connectedCallback();
34
34
  }
35
35
  attach(player) {
36
- const video = player.video;
36
+ const video = player.media;
37
37
  this.listen(video, EVENTS, () => {
38
38
  this.render();
39
39
  });
@@ -1 +1 @@
1
- {"version":3,"file":"spinner.js","names":[],"sources":["../../src/elements/spinner.ts"],"sourcesContent":["/**\n * <mbx-spinner>: shows while the video plays and waits for data. A wait\n * while paused, such as a seek, leaves the start button in place. A drag on\n * the seek bar and a switch to another source count as the state from\n * before, as they do for the play buttons. It sits in the player beside the\n * video, centred over the picture, so it is over the poster and inside\n * fullscreen. It reads the video's `waiting`, `playing`, `canplay`,\n * `emptied`, `play` and `pause`, and carries `waiting` on itself so its\n * stylesheet shows it. It takes the start button's place: a thin ring\n * turns there, a white head on a faint track, in the same monochrome as the\n * controls. The glyph is the `icon` slot, for a page's own; the name comes\n * from `label`.\n */\nimport type { PlayerHost } from '../host.js';\nimport { Component } from './component.js';\nimport { HELD, shownPaused, style } from './shared.js';\nimport STYLE from './spinner.css?inline';\n\n/** What the video fires as it waits and as it goes on. */\nconst EVENTS = ['waiting', 'playing', 'canplay', 'emptied', 'play', 'pause'];\n\nexport class MbxSpinner extends Component {\n static get observedAttributes(): readonly string[] {\n return ['label'];\n }\n\n declare private readonly ring: HTMLElement;\n declare private readonly slot_: HTMLSlotElement;\n\n constructor() {\n super();\n const root = this.attachShadow({ mode: 'open' });\n this.ring = document.createElement('div');\n this.ring.setAttribute('part', 'ring');\n this.slot_ = document.createElement('slot');\n this.slot_.name = 'icon';\n // A page's own glyph replaces the ring: the slot is watched for it.\n this.slot_.addEventListener('slotchange', () => {\n this.ring.hidden = this.slot_.assignedNodes().length > 0;\n });\n root.append(style(STYLE), this.ring, this.slot_);\n }\n\n /** Named before attaching: a constructor must not add attributes. */\n override connectedCallback(): void {\n if (!this.hasAttribute('role')) this.setAttribute('role', 'status');\n super.connectedCallback();\n }\n\n protected override attach(player: PlayerHost): void {\n const video = player.video;\n this.listen(video, EVENTS, () => {\n this.render();\n });\n this.observe(player, HELD, () => {\n this.render();\n });\n this.render();\n }\n\n protected override detach(): void {\n this.removeAttribute('waiting');\n }\n\n protected override render(): void {\n const player = this.player;\n if (player === null) return;\n this.setAttribute('aria-label', this.word('label', 'loading', 'Loading'));\n // The player reflects the same events, and reads them first: it listens\n // from its constructor, before any control attaches.\n this.toggleAttribute('waiting', player.hasAttribute('waiting') && !shownPaused(player));\n }\n}\n"],"mappings":";;;AAgBA,MAAA,QAAA;;AAGA,MAAA,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AAAA;AAEA,IAAA,aAAA,cAAA,UAAA;CACA,WAAA,qBAAA;EACA,OAAA,CAAA,OAAA;CACA;CAKA,cAAA;EACA,MAAA;EACA,MAAA,OAAA,KAAA,aAAA,EAAA,MAAA,OAAA,CAAA;EACA,KAAA,OAAA,SAAA,cAAA,KAAA;EACA,KAAA,KAAA,aAAA,QAAA,MAAA;EACA,KAAA,QAAA,SAAA,cAAA,MAAA;EACA,KAAA,MAAA,OAAA;EAEA,KAAA,MAAA,iBAAA,oBAAA;GACA,KAAA,KAAA,SAAA,KAAA,MAAA,cAAA,CAAA,CAAA,SAAA;EACA,CAAA;EACA,KAAA,OAAA,MAAA,KAAA,GAAA,KAAA,MAAA,KAAA,KAAA;CACA;;CAGA,oBAAA;EACA,IAAA,CAAA,KAAA,aAAA,MAAA,GAAA,KAAA,aAAA,QAAA,QAAA;EACA,MAAA,kBAAA;CACA;CAEA,OAAA,QAAA;EACA,MAAA,QAAA,OAAA;EACA,KAAA,OAAA,OAAA,cAAA;GACA,KAAA,OAAA;EACA,CAAA;EACA,KAAA,QAAA,QAAA,YAAA;GACA,KAAA,OAAA;EACA,CAAA;EACA,KAAA,OAAA;CACA;CAEA,SAAA;EACA,KAAA,gBAAA,SAAA;CACA;CAEA,SAAA;EACA,MAAA,SAAA,KAAA;EACA,IAAA,WAAA,MAAA;EACA,KAAA,aAAA,cAAA,KAAA,KAAA,SAAA,WAAA,SAAA,CAAA;EAGA,KAAA,gBAAA,WAAA,OAAA,aAAA,SAAA,KAAA,CAAA,YAAA,MAAA,CAAA;CACA;AACA"}
1
+ {"version":3,"file":"spinner.js","names":[],"sources":["../../src/elements/spinner.ts"],"sourcesContent":["/**\n * <mbx-spinner>: shows while the video plays and waits for data. A wait\n * while paused, such as a seek, leaves the start button in place. A drag on\n * the seek bar and a switch to another source count as the state from\n * before, as they do for the play buttons. It sits in the player beside the\n * video, centred over the picture, so it is over the poster and inside\n * fullscreen. It reads the video's `waiting`, `playing`, `canplay`,\n * `emptied`, `play` and `pause`, and carries `waiting` on itself so its\n * stylesheet shows it. It takes the start button's place: a thin ring\n * turns there, a white head on a faint track, in the same monochrome as the\n * controls. The glyph is the `icon` slot, for a page's own; the name comes\n * from `label`.\n */\nimport type { PlayerHost } from '../host.js';\nimport { Component } from './component.js';\nimport { HELD, shownPaused, style } from './shared.js';\nimport STYLE from './spinner.css?inline';\n\n/** What the video fires as it waits and as it goes on. */\nconst EVENTS = ['waiting', 'playing', 'canplay', 'emptied', 'play', 'pause'];\n\nexport class MbxSpinner extends Component {\n static get observedAttributes(): readonly string[] {\n return ['label'];\n }\n\n declare private readonly ring: HTMLElement;\n declare private readonly slot_: HTMLSlotElement;\n\n constructor() {\n super();\n const root = this.attachShadow({ mode: 'open' });\n this.ring = document.createElement('div');\n this.ring.setAttribute('part', 'ring');\n this.slot_ = document.createElement('slot');\n this.slot_.name = 'icon';\n // A page's own glyph replaces the ring: the slot is watched for it.\n this.slot_.addEventListener('slotchange', () => {\n this.ring.hidden = this.slot_.assignedNodes().length > 0;\n });\n root.append(style(STYLE), this.ring, this.slot_);\n }\n\n /** Named before attaching: a constructor must not add attributes. */\n override connectedCallback(): void {\n if (!this.hasAttribute('role')) this.setAttribute('role', 'status');\n super.connectedCallback();\n }\n\n protected override attach(player: PlayerHost): void {\n const video = player.media;\n this.listen(video, EVENTS, () => {\n this.render();\n });\n this.observe(player, HELD, () => {\n this.render();\n });\n this.render();\n }\n\n protected override detach(): void {\n this.removeAttribute('waiting');\n }\n\n protected override render(): void {\n const player = this.player;\n if (player === null) return;\n this.setAttribute('aria-label', this.word('label', 'loading', 'Loading'));\n // The player reflects the same events, and reads them first: it listens\n // from its constructor, before any control attaches.\n this.toggleAttribute('waiting', player.hasAttribute('waiting') && !shownPaused(player));\n }\n}\n"],"mappings":";;;AAgBA,MAAA,QAAA;;AAGA,MAAM,SAAS;CAAC;CAAW;CAAW;CAAW;CAAW;CAAQ;AAAO;AAE3E,IAAa,aAAb,cAAgC,UAAU;CACxC,WAAW,qBAAwC;EACjD,OAAO,CAAC,OAAO;CACjB;CAKA,cAAc;EACZ,MAAM;EACN,MAAM,OAAO,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;EAC/C,KAAK,OAAO,SAAS,cAAc,KAAK;EACxC,KAAK,KAAK,aAAa,QAAQ,MAAM;EACrC,KAAK,QAAQ,SAAS,cAAc,MAAM;EAC1C,KAAK,MAAM,OAAO;EAElB,KAAK,MAAM,iBAAiB,oBAAoB;GAC9C,KAAK,KAAK,SAAS,KAAK,MAAM,cAAc,CAAC,CAAC,SAAS;EACzD,CAAC;EACD,KAAK,OAAO,MAAM,KAAK,GAAG,KAAK,MAAM,KAAK,KAAK;CACjD;;CAGS,oBAA0B;EACjC,IAAI,CAAC,KAAK,aAAa,MAAM,GAAG,KAAK,aAAa,QAAQ,QAAQ;EAClE,MAAM,kBAAkB;CAC1B;CAEmB,OAAO,QAA0B;EAClD,MAAM,QAAQ,OAAO;EACrB,KAAK,OAAO,OAAO,cAAc;GAC/B,KAAK,OAAO;EACd,CAAC;EACD,KAAK,QAAQ,QAAQ,YAAY;GAC/B,KAAK,OAAO;EACd,CAAC;EACD,KAAK,OAAO;CACd;CAEmB,SAAe;EAChC,KAAK,gBAAgB,SAAS;CAChC;CAEmB,SAAe;EAChC,MAAM,SAAS,KAAK;EACpB,IAAI,WAAW,MAAM;EACrB,KAAK,aAAa,cAAc,KAAK,KAAK,SAAS,WAAW,SAAS,CAAC;EAGxE,KAAK,gBAAgB,WAAW,OAAO,aAAa,SAAS,KAAK,CAAC,YAAY,MAAM,CAAC;CACxF;AACF"}
@@ -20,12 +20,12 @@ var MbxStartButton = class extends Component {
20
20
  this.slots = iconSlots(STATES, icon);
21
21
  for (const state of STATES) this.button.append(this.slots[state]);
22
22
  this.button.addEventListener("click", () => {
23
- this.player?.video.play().catch(() => void 0);
23
+ this.player?.media.play().catch(() => void 0);
24
24
  });
25
25
  root.append(style(STYLE), this.button);
26
26
  }
27
27
  attach(player) {
28
- const video = player.video;
28
+ const video = player.media;
29
29
  this.listen(video, [
30
30
  "play",
31
31
  "pause",
@@ -108,7 +108,7 @@ var MbxStartButton = class extends Component {
108
108
  if (cramped !== wasCramped) this.render();
109
109
  }
110
110
  render() {
111
- const video = this.player?.video;
111
+ const video = this.player?.media;
112
112
  if (video === void 0) return;
113
113
  const state = video.ended ? "replay" : "play";
114
114
  show(this.slots, state);