@sdxc/ui 2026.11.11 → 2026.11.14

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 (191) hide show
  1. package/README.md +89 -44
  2. package/dist/app/app-shell-toggle.d.ts +2 -0
  3. package/dist/app/app-shell-toggle.js +5 -2
  4. package/dist/app/app-shell.d.ts +25 -1
  5. package/dist/app/app-shell.js +73 -38
  6. package/dist/app/auto-refresh.d.ts +2 -0
  7. package/dist/app/auto-refresh.js +3 -3
  8. package/dist/app/behaviors/refresh-schedule.d.ts +8 -3
  9. package/dist/app/behaviors/refresh-schedule.js +4 -3
  10. package/dist/app/board.d.ts +123 -0
  11. package/dist/app/board.js +224 -0
  12. package/dist/app/chart.d.ts +2 -2
  13. package/dist/app/chart.js +7 -3
  14. package/dist/app/check-runs.d.ts +116 -0
  15. package/dist/app/check-runs.js +201 -0
  16. package/dist/app/code-view.d.ts +172 -0
  17. package/dist/app/code-view.js +414 -0
  18. package/dist/app/command-palette.d.ts +38 -3
  19. package/dist/app/command-palette.js +53 -5
  20. package/dist/app/contribution-graph.d.ts +106 -0
  21. package/dist/app/contribution-graph.js +289 -0
  22. package/dist/app/detail-sheet.d.ts +7 -0
  23. package/dist/app/detail-sheet.js +7 -7
  24. package/dist/app/diff.d.ts +200 -0
  25. package/dist/app/diff.js +702 -0
  26. package/dist/app/filter-bar.d.ts +20 -0
  27. package/dist/app/filter-bar.js +35 -15
  28. package/dist/app/filter-menu.d.ts +144 -0
  29. package/dist/app/filter-menu.js +480 -0
  30. package/dist/app/gantt.d.ts +108 -0
  31. package/dist/app/gantt.js +420 -0
  32. package/dist/app/index.d.ts +19 -0
  33. package/dist/app/index.js +19 -0
  34. package/dist/app/log-viewer.d.ts +120 -0
  35. package/dist/app/log-viewer.js +384 -0
  36. package/dist/app/merge-box.d.ts +97 -0
  37. package/dist/app/merge-box.js +227 -0
  38. package/dist/app/mixins/app-shell-controls.d.ts +4 -1
  39. package/dist/app/mixins/app-shell-controls.js +64 -4
  40. package/dist/app/mixins/auto-refresh.d.ts +5 -2
  41. package/dist/app/mixins/auto-refresh.js +9 -3
  42. package/dist/app/mixins/close-popover-on-submit.d.ts +16 -0
  43. package/dist/app/mixins/close-popover-on-submit.js +32 -0
  44. package/dist/app/mixins/code-view-selection.d.ts +60 -0
  45. package/dist/app/mixins/code-view-selection.js +276 -0
  46. package/dist/app/mixins/command-palette.d.ts +15 -4
  47. package/dist/app/mixins/command-palette.js +94 -6
  48. package/dist/app/mixins/contribution-graph-keys.d.ts +19 -0
  49. package/dist/app/mixins/contribution-graph-keys.js +155 -0
  50. package/dist/app/mixins/diff-interactions.d.ts +72 -0
  51. package/dist/app/mixins/diff-interactions.js +269 -0
  52. package/dist/app/mixins/filter-menu-keys.d.ts +41 -0
  53. package/dist/app/mixins/filter-menu-keys.js +91 -0
  54. package/dist/app/mixins/gantt-today.d.ts +17 -0
  55. package/dist/app/mixins/gantt-today.js +50 -0
  56. package/dist/app/mixins/log-viewer.d.ts +29 -0
  57. package/dist/app/mixins/log-viewer.js +333 -0
  58. package/dist/app/mixins/optimistic-toggle-sync.d.ts +5 -0
  59. package/dist/app/mixins/optimistic-toggle-sync.js +25 -1
  60. package/dist/app/mixins/save-bar-sync.d.ts +7 -1
  61. package/dist/app/mixins/save-bar-sync.js +23 -4
  62. package/dist/app/mixins/save-status-sync.js +23 -1
  63. package/dist/app/mixins/split-view.js +1 -1
  64. package/dist/app/mixins/submit-on-close.d.ts +17 -0
  65. package/dist/app/mixins/submit-on-close.js +52 -0
  66. package/dist/app/mixins/tree-filter.d.ts +44 -0
  67. package/dist/app/mixins/tree-filter.js +111 -0
  68. package/dist/app/mixins/tree-navigation.d.ts +50 -0
  69. package/dist/app/mixins/tree-navigation.js +216 -0
  70. package/dist/app/optimistic-toggle.d.ts +8 -0
  71. package/dist/app/optimistic-toggle.js +3 -2
  72. package/dist/app/page-header.d.ts +18 -3
  73. package/dist/app/page-header.js +105 -50
  74. package/dist/app/review-thread.d.ts +115 -0
  75. package/dist/app/review-thread.js +116 -0
  76. package/dist/app/save-bar.d.ts +5 -0
  77. package/dist/app/save-bar.js +1 -1
  78. package/dist/app/settings-layout.d.ts +5 -0
  79. package/dist/app/settings-layout.js +5 -5
  80. package/dist/app/skeleton.d.ts +9 -0
  81. package/dist/app/skeleton.js +28 -0
  82. package/dist/app/split-view.d.ts +4 -0
  83. package/dist/app/split-view.js +3 -3
  84. package/dist/app/styles/code-tokens.d.ts +24 -0
  85. package/dist/app/styles/code-tokens.js +47 -0
  86. package/dist/app/tab-bar.d.ts +59 -0
  87. package/dist/app/tab-bar.js +111 -0
  88. package/dist/app/tree.d.ts +111 -14
  89. package/dist/app/tree.js +202 -15
  90. package/dist/app/utils/ansi.d.ts +55 -0
  91. package/dist/app/utils/ansi.js +157 -0
  92. package/dist/app/utils/diff-rows.d.ts +82 -0
  93. package/dist/app/utils/diff-rows.js +209 -0
  94. package/dist/app/utils/fuzzy-path.d.ts +58 -0
  95. package/dist/app/utils/fuzzy-path.js +202 -0
  96. package/dist/app/utils/line-range.d.ts +48 -0
  97. package/dist/app/utils/line-range.js +61 -0
  98. package/dist/app/utils/log-lines.d.ts +107 -0
  99. package/dist/app/utils/log-lines.js +170 -0
  100. package/dist/app/utils/tree-filter.d.ts +19 -0
  101. package/dist/app/utils/tree-filter.js +26 -0
  102. package/dist/app/view-options.d.ts +2 -0
  103. package/dist/app/view-options.js +2 -2
  104. package/dist/chat/activity.d.ts +72 -0
  105. package/dist/chat/activity.js +184 -0
  106. package/dist/chat/composer-submit.d.ts +38 -0
  107. package/dist/chat/composer-submit.js +44 -0
  108. package/dist/chat/composer.d.ts +47 -0
  109. package/dist/chat/composer.js +100 -0
  110. package/dist/chat/index.d.ts +6 -0
  111. package/dist/chat/index.js +6 -0
  112. package/dist/chat/mixins/composer-send.d.ts +32 -0
  113. package/dist/chat/mixins/composer-send.js +121 -0
  114. package/dist/chat/mixins/reveal-stream.d.ts +68 -0
  115. package/dist/chat/mixins/reveal-stream.js +184 -0
  116. package/dist/chat/mixins/stream-target.d.ts +18 -0
  117. package/dist/chat/mixins/stream-target.js +38 -0
  118. package/dist/components/button.js +7 -1
  119. package/dist/components/character-count.d.ts +44 -0
  120. package/dist/components/character-count.js +68 -0
  121. package/dist/components/index.d.ts +2 -0
  122. package/dist/components/index.js +2 -0
  123. package/dist/components/label-chip.d.ts +42 -0
  124. package/dist/components/label-chip.js +86 -0
  125. package/dist/components/property-list.d.ts +9 -2
  126. package/dist/components/property-list.js +11 -6
  127. package/dist/components/textarea.js +6 -1
  128. package/dist/components/timeline.d.ts +62 -5
  129. package/dist/components/timeline.js +124 -5
  130. package/dist/docs/code-block.js +8 -31
  131. package/dist/docs/file-tree.js +3 -48
  132. package/dist/landing/case-study.d.ts +79 -0
  133. package/dist/landing/case-study.js +162 -0
  134. package/dist/landing/contributor-wall.d.ts +72 -0
  135. package/dist/landing/contributor-wall.js +129 -0
  136. package/dist/landing/countdown.d.ts +88 -0
  137. package/dist/landing/countdown.js +91 -0
  138. package/dist/landing/episode-player.d.ts +87 -0
  139. package/dist/landing/episode-player.js +113 -0
  140. package/dist/landing/faq-band.d.ts +3 -2
  141. package/dist/landing/faq-band.js +4 -3
  142. package/dist/landing/index.d.ts +7 -0
  143. package/dist/landing/index.js +7 -0
  144. package/dist/landing/landing-header.js +15 -4
  145. package/dist/landing/mixins/countdown-tick.d.ts +29 -0
  146. package/dist/landing/mixins/countdown-tick.js +65 -0
  147. package/dist/landing/mixins/usage-estimate-live.d.ts +32 -0
  148. package/dist/landing/mixins/usage-estimate-live.js +120 -0
  149. package/dist/landing/phone-frame.d.ts +2 -1
  150. package/dist/landing/price-list.d.ts +68 -0
  151. package/dist/landing/price-list.js +125 -0
  152. package/dist/landing/scroll-scene.d.ts +59 -0
  153. package/dist/landing/scroll-scene.js +70 -0
  154. package/dist/landing/sponsor-wall.d.ts +30 -6
  155. package/dist/landing/sponsor-wall.js +70 -14
  156. package/dist/landing/typed-terminal.d.ts +24 -6
  157. package/dist/landing/typed-terminal.js +22 -14
  158. package/dist/landing/usage-estimate.d.ts +127 -0
  159. package/dist/landing/usage-estimate.js +164 -0
  160. package/dist/landing/utils/countdown.d.ts +33 -0
  161. package/dist/landing/utils/countdown.js +42 -0
  162. package/dist/landing/utils/pause-toggle.d.ts +2 -1
  163. package/dist/mixins/character-count.d.ts +62 -0
  164. package/dist/mixins/character-count.js +139 -0
  165. package/dist/mixins/index.d.ts +6 -2
  166. package/dist/mixins/index.js +6 -2
  167. package/dist/mixins/invoker-fields.d.ts +18 -0
  168. package/dist/mixins/invoker-fields.js +60 -0
  169. package/dist/mixins/media-sync.d.ts +58 -0
  170. package/dist/mixins/media-sync.js +102 -0
  171. package/dist/mixins/menu-keys.d.ts +11 -0
  172. package/dist/mixins/menu-keys.js +79 -70
  173. package/dist/mixins/sortable.d.ts +96 -0
  174. package/dist/mixins/sortable.js +433 -0
  175. package/dist/utils/code-lines.d.ts +26 -0
  176. package/dist/utils/code-lines.js +29 -0
  177. package/dist/utils/file-icon.d.ts +31 -0
  178. package/dist/utils/file-icon.js +60 -0
  179. package/dist/utils/index.d.ts +2 -0
  180. package/dist/utils/index.js +2 -0
  181. package/dist/utils/write-cookie.d.ts +15 -15
  182. package/dist/utils/write-cookie.js +10 -16
  183. package/dist/video/index.d.ts +11 -0
  184. package/dist/video/index.js +11 -0
  185. package/dist/video/mixins/video-player-sync.d.ts +27 -0
  186. package/dist/video/mixins/video-player-sync.js +413 -0
  187. package/dist/video/utils/timeline.d.ts +55 -0
  188. package/dist/video/utils/timeline.js +90 -0
  189. package/dist/video/video-player.d.ts +261 -0
  190. package/dist/video/video-player.js +927 -0
  191. package/package.json +6 -3
@@ -0,0 +1,927 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "remix/component/jsx-runtime";
2
+ import { visuallyHidden } from "@sdxc/u/a11y";
3
+ import { combine, mergeMix, raw } from "@sdxc/u/general";
4
+ import { container, hidden } from "@sdxc/u/layout";
5
+ import { at, motionSafe } from "@sdxc/u/responsive";
6
+ import { focusVisible, hover, when } from "@sdxc/u/state";
7
+ import { clientEntry } from "remix/component";
8
+ import { Popover } from "../components/popover.js";
9
+ import { videoPlayerSync } from "./mixins/video-player-sync.js";
10
+ import { formatVideoTime, isoDuration, playedShare, playingIndex, webVttUrl, } from "./utils/timeline.js";
11
+ /** Container the player's two columns query. */
12
+ const CONTAINER = "ui-video-player";
13
+ /** Outer radius of the player; the screen and rows nest smaller radii inside it. */
14
+ const RADIUS = "var(--ui-video-player-radius, var(--ui-landing-radius-frame, 0.75rem))";
15
+ /** Ink of the bar and the settings menu, which sit on the picture in any page scheme. */
16
+ const ON_VIDEO = "var(--ui-video-player-on-video, oklch(0.97 0 0))";
17
+ /** Muted ink on the picture, for values and the time's length. */
18
+ const ON_VIDEO_MUTED = "var(--ui-video-player-on-video-muted, oklch(0.8 0 0))";
19
+ /** Wash behind a hovered control or row on the picture. */
20
+ const ON_VIDEO_WASH = "var(--ui-video-player-on-video-wash, rgb(255 255 255 / 0.14))";
21
+ /** Fill of the progress slider and an on switch. */
22
+ const ON_VIDEO_ACCENT = "var(--ui-video-player-progress-color, oklch(0.63 0.22 27))";
23
+ /**
24
+ * The player's inks for each tone. `theater` keeps its night whatever scheme the page is in,
25
+ * so a dark screening room can sit inside a bright page.
26
+ */
27
+ const TONES = {
28
+ plain: {
29
+ "--ui-video-player-bg": "var(--ui-surface-raised, Canvas)",
30
+ "--ui-video-player-emphasis": "var(--ui-neutral-fg-emphasis)",
31
+ "--ui-video-player-body": "var(--ui-neutral-fg)",
32
+ "--ui-video-player-muted": "var(--ui-neutral-fg-muted)",
33
+ "--ui-video-player-accent": "var(--ui-brand-fg)",
34
+ "--ui-video-player-line": "var(--ui-landing-hairline, color-mix(in oklch, CanvasText 10%, transparent))",
35
+ "--ui-video-player-wash": "color-mix(in oklch, CanvasText 5%, transparent)",
36
+ "--ui-video-player-shadow": "0 0 0 1px var(--ui-video-player-line)",
37
+ },
38
+ theater: {
39
+ "--ui-video-player-bg": "color-mix(in oklch, var(--ui-color-neutral-950, oklch(0.165 0.006 270)) 94%, var(--ui-color-brand-900, oklch(0.245 0.05 270)))",
40
+ "--ui-video-player-emphasis": "var(--ui-color-neutral-50, oklch(0.985 0.002 270))",
41
+ "--ui-video-player-body": "var(--ui-color-neutral-300, oklch(0.81 0.006 270))",
42
+ "--ui-video-player-muted": "var(--ui-color-neutral-400, oklch(0.71 0.008 270))",
43
+ "--ui-video-player-accent": "var(--ui-color-brand-300, oklch(0.81 0.08 270))",
44
+ "--ui-video-player-line": "color-mix(in oklch, white 12%, transparent)",
45
+ "--ui-video-player-wash": "color-mix(in oklch, white 7%, transparent)",
46
+ "--ui-video-player-shadow": "0 0 0 1px var(--ui-video-player-line), 0 30px 60px -20px rgb(0 0 0 / 0.45)",
47
+ },
48
+ };
49
+ /** Surface of the settings menu over the picture. */
50
+ const MENU_BG = "var(--ui-video-player-menu-bg, rgb(28 28 30 / 0.96))";
51
+ /** Colour scheme of a player that names none. */
52
+ const DEFAULT_TONE = "plain";
53
+ /** Language of the generated tracks when the screen names none. */
54
+ const DEFAULT_LANGUAGE = "en";
55
+ /** Playback rates {@link VideoPlayer.SpeedMenu} offers unless given its own. */
56
+ const DEFAULT_RATES = [0.25, 0.5, 0.75, 1, 1.25, 1.5, 1.75, 2];
57
+ /** Whether a rendered node is an element of the given component or tag. */
58
+ function isElementOf(node, type) {
59
+ return (typeof node === "object" &&
60
+ node !== null &&
61
+ "$rmx" in node &&
62
+ "type" in node &&
63
+ node.type === type);
64
+ }
65
+ /** The children of a node as a flat list, through arrays. */
66
+ function flatten(node) {
67
+ return Array.isArray(node) ? node.flatMap((child) => flatten(child)) : [node];
68
+ }
69
+ /**
70
+ * Every element of `type` in a tree of children, in document order, searched depth first
71
+ * through the children of every element on the way.
72
+ */
73
+ function findAll(node, type) {
74
+ let found = [];
75
+ for (let child of flatten(node)) {
76
+ if (isElementOf(child, type))
77
+ found.push(child);
78
+ else if (typeof child === "object" && child !== null && "props" in child) {
79
+ found.push(...findAll(child.props.children, type));
80
+ }
81
+ }
82
+ return found;
83
+ }
84
+ /** A prop read as a string, or `undefined` when it is anything else. */
85
+ function text(value) {
86
+ return typeof value === "string" ? value : undefined;
87
+ }
88
+ /**
89
+ * The captions tracks a video will hold: the page's own `<track>` elements of kind
90
+ * captions or subtitles, then the one written from the transcript.
91
+ */
92
+ function captionsOf(children, transcript) {
93
+ let screen = findAll(children, VideoPlayer.Screen)[0];
94
+ let own = findAll(screen?.props.children, "track")
95
+ .filter((track) => track.props.kind === "captions" || track.props.kind === "subtitles")
96
+ .map((track) => ({
97
+ label: text(track.props.label) ?? "",
98
+ language: text(track.props.srcLang) ?? text(track.props.srclang),
99
+ }));
100
+ if (transcript.length === 0)
101
+ return own;
102
+ return [
103
+ ...own,
104
+ {
105
+ label: text(screen?.props.captionsLabel) ?? "",
106
+ language: text(screen?.props.language) ?? DEFAULT_LANGUAGE,
107
+ },
108
+ ];
109
+ }
110
+ /**
111
+ * A `<figure>` sharing one timeline with its parts; with no script its native controls play and
112
+ * time links open the file there. Map {@link VideoPlayerSync} (`@sdxc/ui/video/video-player`) for
113
+ * the bar. Theming: `--ui-video-player-` radius, progress-color, menu-bg, on-video, transcript-height.
114
+ *
115
+ * @param handle Runtime handle carrying the host `<figure>`'s props.
116
+ * @returns The render function producing the player.
117
+ * @example
118
+ * <VideoPlayer duration={703} chapters={chapters}>
119
+ * <VideoPlayer.Screen label="Centering 3 kg" captionsLabel="English" chaptersLabel="Chapters"><VideoPlayer.Source src="/07.mp4" type="video/mp4" /></VideoPlayer.Screen>
120
+ * <VideoPlayer.Side><VideoPlayer.Chapters label="Chapters" /></VideoPlayer.Side>
121
+ * </VideoPlayer>
122
+ * @example
123
+ * <VideoPlayer duration={703} chapters={chapters} transcript={lines} tone="theater">
124
+ * <VideoPlayer.Screen label="Centering 3 kg" captionsLabel="English" chaptersLabel="Chapters">
125
+ * <VideoPlayer.Source src="/07.mp4" type="video/mp4" label="1080p" badge="HD" />
126
+ * <VideoPlayer.Controls label="Video controls"><VideoPlayer.Progress label="Seek" /><VideoPlayer.Play label="Play" pauseLabel="Pause" /><VideoPlayer.Time /></VideoPlayer.Controls>
127
+ * </VideoPlayer.Screen>
128
+ * <VideoPlayer.Side><VideoPlayer.Transcript label="Transcript" /></VideoPlayer.Side>
129
+ * </VideoPlayer>
130
+ */
131
+ export function VideoPlayer(handle) {
132
+ return () => {
133
+ let { chapters = [], children, current, duration, mix, tone = DEFAULT_TONE, transcript = [], ...rest } = handle.props;
134
+ let sources = findAll(children, VideoPlayer.Source).map((source) => ({
135
+ src: text(source.props.src) ?? "",
136
+ label: text(source.props.label),
137
+ badge: text(source.props.badge),
138
+ }));
139
+ handle.context.set({
140
+ duration,
141
+ chapters,
142
+ transcript,
143
+ current,
144
+ href: sources[0]?.src,
145
+ sources,
146
+ captions: captionsOf(children, transcript),
147
+ });
148
+ let parts = flatten(children);
149
+ let side = parts.filter((part) => isElementOf(part, VideoPlayer.Side));
150
+ let main = parts.filter((part) => !isElementOf(part, VideoPlayer.Side));
151
+ return (_jsxs("figure", { ...rest, "data-slot": "video-player", "data-tone": tone, mix: mergeMix([
152
+ container(CONTAINER),
153
+ raw({
154
+ ...TONES[tone],
155
+ margin: "0",
156
+ padding: "clamp(0.75rem, 2.5cqi, 1.5rem)",
157
+ boxSizing: "border-box",
158
+ inlineSize: "100%",
159
+ colorScheme: tone === "theater" ? "dark" : "inherit",
160
+ color: "var(--ui-video-player-body)",
161
+ backgroundColor: "var(--ui-video-player-bg)",
162
+ borderRadius: RADIUS,
163
+ boxShadow: "var(--ui-video-player-shadow)",
164
+ textAlign: "start",
165
+ }),
166
+ ], mix), children: [_jsxs("div", { "data-slot": "video-player-layout", mix: [
167
+ combine([
168
+ raw({ display: "grid", gridTemplateColumns: "minmax(0, 1fr)", gap: "1.25rem" }),
169
+ side.length > 0
170
+ ? at("lg", CONTAINER, raw({
171
+ gridTemplateColumns: "minmax(0, 1.8fr) minmax(16rem, 1fr)",
172
+ alignItems: "start",
173
+ }))
174
+ : [],
175
+ when("[data-theater] > &", raw({ gridTemplateColumns: "minmax(0, 1fr)" })),
176
+ ]),
177
+ ], children: [_jsx("div", { "data-slot": "video-player-main", mix: [raw({ display: "grid", gap: "0.875rem", minInlineSize: "0" })], children: main }), side] }), _jsx(VideoPlayerSync, {})] }));
178
+ };
179
+ }
180
+ /** Reads the timeline a part's {@link VideoPlayer} shares. */
181
+ function timeline(handle) {
182
+ let context = handle.context.get(VideoPlayer);
183
+ return context ?? { duration: 0, chapters: [], transcript: [], sources: [], captions: [] };
184
+ }
185
+ /** The address a time link opens without script: the first source at that second. */
186
+ function timeHref(context, start) {
187
+ return `${context.href ?? ""}#t=${Math.floor(start)}`;
188
+ }
189
+ /**
190
+ * The 16:9 screen: a native `<video controls>` holding its sources and the chapters and
191
+ * captions tracks written from the timeline, over a {@link VideoPlayer.Frame} when given,
192
+ * under a {@link VideoPlayer.Controls} bar that takes over from the native controls.
193
+ *
194
+ * @param handle Runtime handle carrying the screen's props.
195
+ * @returns The render function producing the screen.
196
+ * @example
197
+ * <VideoPlayer.Screen label="Centering 3 kg" poster="/07.jpg" captionsLabel="English" chaptersLabel="Chapters"><VideoPlayer.Source src="/07.mp4" type="video/mp4" /></VideoPlayer.Screen>
198
+ */
199
+ VideoPlayer.Screen = function VideoPlayerScreen(handle) {
200
+ return () => {
201
+ let { captionsLabel, chaptersLabel, children, label, language = DEFAULT_LANGUAGE, mix, poster, ...rest } = handle.props;
202
+ let { chapters, duration, transcript } = timeline(handle);
203
+ let nodes = flatten(children);
204
+ let frames = nodes.filter((node) => isElementOf(node, VideoPlayer.Frame));
205
+ let bars = nodes.filter((node) => isElementOf(node, VideoPlayer.Controls));
206
+ let sources = nodes.filter((node) => !isElementOf(node, VideoPlayer.Frame) && !isElementOf(node, VideoPlayer.Controls));
207
+ return (_jsxs("div", { ...rest, "data-slot": "video-player-screen", mix: mergeMix([
208
+ raw({
209
+ position: "relative",
210
+ aspectRatio: "16 / 9",
211
+ overflow: "clip",
212
+ borderRadius: `max(0px, calc(${RADIUS} - 0.375rem))`,
213
+ backgroundColor: "black",
214
+ }),
215
+ when("& > video, & > [data-slot='video-player-frame']", raw({ position: "absolute", inset: "0", inlineSize: "100%", blockSize: "100%" })),
216
+ when("&:fullscreen", raw({
217
+ aspectRatio: "auto",
218
+ borderRadius: "0",
219
+ inlineSize: "100%",
220
+ blockSize: "100%",
221
+ })),
222
+ ], mix), children: [frames, _jsxs("video", { "data-slot": "video-player-video", controls: true, preload: "metadata", playsInline: true, poster: poster, "aria-label": label, mix: [raw({ objectFit: "contain", backgroundColor: "transparent" })], children: [sources, chapters.length > 0 ? (_jsx("track", { kind: "chapters", srcLang: language, label: chaptersLabel, src: webVttUrl(chapters.map((chapter) => ({ start: chapter.start, text: chapter.title })), duration) })) : null, _jsx("track", { kind: "captions", srcLang: language, label: captionsLabel, src: webVttUrl(transcript, duration), "data-empty": transcript.length === 0 ? "" : undefined })] }), bars] }));
223
+ };
224
+ };
225
+ /**
226
+ * One file the video may play, in preference order, exactly as a `<source>` inside
227
+ * `<video>`; the first one also gives every time link its address. A `label` lists it in
228
+ * the quality menu and a `badge` marks it there and on the gear; a source with neither is a
229
+ * format fallback, such as an MP4 after a WebM.
230
+ *
231
+ * @param handle Runtime handle carrying the `<source>`'s props.
232
+ * @returns The render function producing the source.
233
+ * @example <VideoPlayer.Source src="/07-2160.mp4" type="video/mp4" label="2160p" badge="4K" />
234
+ */
235
+ VideoPlayer.Source = function VideoPlayerSource(handle) {
236
+ return () => {
237
+ let { badge, label, ...rest } = handle.props;
238
+ return _jsx("source", { ...rest, "data-label": label, "data-badge": badge });
239
+ };
240
+ };
241
+ /**
242
+ * A drawn still under the video: it shows before playback and through any transparent
243
+ * part of the picture while it plays. Decorative, so hidden from assistive technology.
244
+ *
245
+ * @param handle Runtime handle carrying the frame's props.
246
+ * @returns The render function producing the frame.
247
+ * @example <VideoPlayer.Frame><WheelFrame /></VideoPlayer.Frame>
248
+ */
249
+ VideoPlayer.Frame = function VideoPlayerFrame(handle) {
250
+ return () => {
251
+ let { mix, ...rest } = handle.props;
252
+ return (_jsx("div", { ...rest, "data-slot": "video-player-frame", "aria-hidden": "true", mix: mergeMix([when("& > svg", raw({ display: "block", inlineSize: "100%", blockSize: "100%" }))], mix) }));
253
+ };
254
+ };
255
+ /**
256
+ * The chapters as one bar of segments as long as each chapter, filled to the current
257
+ * moment, so the video's shape shows before it plays. It repeats the chapter list, so it is
258
+ * hidden from assistive technology.
259
+ *
260
+ * @param handle Runtime handle carrying the bar's props.
261
+ * @returns The render function producing the bar.
262
+ */
263
+ VideoPlayer.Scrubber = function VideoPlayerScrubber(handle) {
264
+ return () => {
265
+ let { mix, ...rest } = handle.props;
266
+ let { chapters, current, duration } = timeline(handle);
267
+ return (_jsx("div", { ...rest, "data-slot": "video-player-scrubber", "aria-hidden": "true", mix: mergeMix([raw({ display: "flex", gap: "3px", blockSize: "0.375rem" })], mix), children: chapters.map((chapter, index) => {
268
+ let end = chapters[index + 1]?.start ?? duration;
269
+ return (_jsx("span", { "data-slot": "video-player-segment", "data-start": chapter.start, "data-end": end, style: {
270
+ "--ui-video-player-played": `${playedShare(chapter.start, end, current) * 100}%`,
271
+ }, mix: [segment(end - chapter.start)] }, chapter.start));
272
+ }) }));
273
+ };
274
+ };
275
+ /**
276
+ * The video's title line: the title at the start, small print at the end, wrapping
277
+ * under each other on a narrow screen.
278
+ *
279
+ * @param handle Runtime handle carrying the `<figcaption>`'s props.
280
+ * @returns The render function producing the caption.
281
+ * @example <VideoPlayer.Caption meta="Lesson 7 · 11:43">Centering 3 kg</VideoPlayer.Caption>
282
+ */
283
+ VideoPlayer.Caption = function VideoPlayerCaption(handle) {
284
+ return () => {
285
+ let { children, meta, mix, ...rest } = handle.props;
286
+ return (_jsxs("figcaption", { ...rest, "data-slot": "video-player-caption", mix: mergeMix([
287
+ raw({
288
+ display: "flex",
289
+ flexWrap: "wrap",
290
+ alignItems: "baseline",
291
+ justifyContent: "space-between",
292
+ columnGap: "1rem",
293
+ rowGap: "0.25rem",
294
+ }),
295
+ ], mix), children: [_jsx("span", { "data-slot": "video-player-title", mix: [
296
+ raw({
297
+ color: "var(--ui-video-player-emphasis)",
298
+ fontSize: "var(--ui-text-lg, 1.125rem)",
299
+ lineHeight: "1.5rem",
300
+ fontWeight: "600",
301
+ textWrap: "balance",
302
+ }),
303
+ ], children: children }), meta ? _jsx("span", { mix: [monoSmall()], children: meta }) : null] }));
304
+ };
305
+ };
306
+ /**
307
+ * The second column: chapters, transcript and anything the page adds, such as a card for
308
+ * the next video, stacked in order.
309
+ *
310
+ * @param handle Runtime handle carrying the column's props.
311
+ * @returns The render function producing the column.
312
+ */
313
+ VideoPlayer.Side = function VideoPlayerSide(handle) {
314
+ return () => {
315
+ let { mix, ...rest } = handle.props;
316
+ return (_jsx("div", { ...rest, "data-slot": "video-player-side", mix: mergeMix([raw({ display: "grid", gap: "1.25rem", minInlineSize: "0" })], mix) }));
317
+ };
318
+ };
319
+ /**
320
+ * The chapters as links to their moments, each with its still when given; the chapter
321
+ * playing carries `aria-current`.
322
+ *
323
+ * @param handle Runtime handle carrying the list's props.
324
+ * @returns The render function producing the chapter list.
325
+ * @example <VideoPlayer.Chapters label="Chapitres" />
326
+ */
327
+ VideoPlayer.Chapters = function VideoPlayerChapters(handle) {
328
+ return () => {
329
+ let { label, mix, ...rest } = handle.props;
330
+ let context = timeline(handle);
331
+ let playing = playingIndex(context.chapters.map((chapter) => chapter.start), context.current);
332
+ return (_jsxs("nav", { ...rest, "aria-label": label, mix: mergeMix([raw({ display: "grid", gap: "0.5rem" })], mix), children: [_jsx("p", { "aria-hidden": "true", mix: [sideLabel()], children: label }), _jsx("ol", { "data-slot": "video-player-chapters", mix: [plainList(), raw({ gap: "0.125rem" })], children: context.chapters.map((chapter, index) => (_jsx("li", { children: _jsxs("a", { href: timeHref(context, chapter.start), "data-start": chapter.start, "aria-current": index === playing ? "true" : undefined, mix: [chapterLink()], children: [chapter.thumbnail ? (_jsx("span", { "data-slot": "video-player-thumbnail", "aria-hidden": "true", children: chapter.thumbnail })) : null, _jsx("span", { mix: [raw({ minInlineSize: "0", textWrap: "pretty" })], children: chapter.title }), _jsx("time", { dateTime: isoDuration(chapter.start), mix: [monoSmall()], children: formatVideoTime(chapter.start) })] }) }, chapter.start))) })] }));
333
+ };
334
+ };
335
+ /**
336
+ * The transcript in a scroll region, each line behind a link to its moment; the line
337
+ * playing carries `aria-current` and the island keeps it in view.
338
+ *
339
+ * @param handle Runtime handle carrying the transcript's props.
340
+ * @returns The render function producing the transcript.
341
+ * @example <VideoPlayer.Transcript label="Transcription" />
342
+ */
343
+ VideoPlayer.Transcript = function VideoPlayerTranscript(handle) {
344
+ return () => {
345
+ let { label, mix, ...rest } = handle.props;
346
+ let context = timeline(handle);
347
+ let playing = playingIndex(context.transcript.map((cue) => cue.start), context.current);
348
+ return (_jsxs("div", { ...rest, mix: mergeMix([raw({ display: "grid", gap: "0.5rem" })], mix), children: [_jsx("p", { "aria-hidden": "true", mix: [sideLabel()], children: label }), _jsx("div", { "data-slot": "video-player-transcript", role: "region", "aria-label": label, mix: [
349
+ raw({
350
+ position: "relative",
351
+ maxBlockSize: "var(--ui-video-player-transcript-height, 11rem)",
352
+ overflowY: "auto",
353
+ overscrollBehavior: "contain",
354
+ paddingInlineEnd: "0.5rem",
355
+ borderRadius: "0.25rem",
356
+ }),
357
+ ], children: _jsx("ol", { mix: [plainList(), raw({ gap: "0.5rem" })], children: context.transcript.map((cue, index) => (_jsxs("li", { "data-slot": "video-player-cue", "data-cue": cue.start, "aria-current": index === playing ? "true" : undefined, mix: [cueRow()], children: [_jsx("a", { href: timeHref(context, cue.start), "data-start": cue.start, mix: [timeLink()], children: _jsx("time", { dateTime: isoDuration(cue.start), children: formatVideoTime(cue.start) }) }), _jsx("span", { children: cue.text })] }, cue.start))) }) })] }));
358
+ };
359
+ };
360
+ /**
361
+ * The custom control bar along the bottom of the screen, rendered `hidden` until the island
362
+ * swaps it for the native controls. A {@link VideoPlayer.Progress} spans its top line and a
363
+ * {@link VideoPlayer.Time} pushes what follows it to the inline end.
364
+ *
365
+ * @param handle Runtime handle carrying the bar's props.
366
+ * @returns The render function producing the bar.
367
+ * @example
368
+ * <VideoPlayer.Controls label="Video controls">
369
+ * <VideoPlayer.Progress label="Seek" /><VideoPlayer.Play label="Play" pauseLabel="Pause" /><VideoPlayer.Time /><VideoPlayer.Fullscreen label="Full screen" />
370
+ * </VideoPlayer.Controls>
371
+ */
372
+ VideoPlayer.Controls = function VideoPlayerControls(handle) {
373
+ return () => {
374
+ let { label, mix, ...rest } = handle.props;
375
+ return (_jsx("div", { ...rest, hidden: true, role: "group", "aria-label": label, "data-slot": "video-player-controls", mix: mergeMix([
376
+ raw({
377
+ position: "absolute",
378
+ insetInline: "0",
379
+ insetBlockEnd: "0",
380
+ zIndex: "1",
381
+ flexWrap: "wrap",
382
+ alignItems: "center",
383
+ columnGap: "0.125rem",
384
+ padding: "2rem 0.5rem 0.25rem",
385
+ colorScheme: "dark",
386
+ color: ON_VIDEO,
387
+ backgroundImage: "linear-gradient(to top, rgb(0 0 0 / 0.72), transparent)",
388
+ }),
389
+ when("&:not([hidden])", raw({ display: "flex" })),
390
+ ], mix) }));
391
+ };
392
+ };
393
+ /**
394
+ * The seek slider: a native range over the video's length, so arrow keys, Home and End
395
+ * seek and assistive technology reads the time. It spans the bar's first line.
396
+ *
397
+ * @param handle Runtime handle carrying the `<input>`'s props.
398
+ * @returns The render function producing the slider.
399
+ * @example <VideoPlayer.Progress label="Buscar" />
400
+ */
401
+ VideoPlayer.Progress = function VideoPlayerProgress(handle) {
402
+ return () => {
403
+ let { label, mix, ...rest } = handle.props;
404
+ let { current = 0, duration } = timeline(handle);
405
+ return (_jsx("input", { ...rest, type: "range", min: "0", max: String(duration), step: "any", value: String(current), "aria-label": label, "aria-valuetext": `${formatVideoTime(current)} / ${formatVideoTime(duration)}`, "data-slot": "video-player-progress", mix: mergeMix([
406
+ raw({
407
+ order: "-1",
408
+ flexBasis: "100%",
409
+ inlineSize: "100%",
410
+ blockSize: "1.25rem",
411
+ margin: "0",
412
+ accentColor: ON_VIDEO_ACCENT,
413
+ cursor: "pointer",
414
+ }),
415
+ onVideoFocus(),
416
+ ], mix) }));
417
+ };
418
+ };
419
+ /**
420
+ * Plays and pauses; its accessible name says what a press does next.
421
+ *
422
+ * @param handle Runtime handle carrying the button's props.
423
+ * @returns The render function producing the button.
424
+ * @example <VideoPlayer.Play label="Reproducir" pauseLabel="Pausar" />
425
+ */
426
+ VideoPlayer.Play = function VideoPlayerPlay(handle) {
427
+ return () => {
428
+ let { label, mix, pauseLabel, ...rest } = handle.props;
429
+ return (_jsxs("button", { ...rest, type: "button", "aria-label": label, "data-label-play": label, "data-label-pause": pauseLabel, "data-video-action": "play", mix: mergeMix([
430
+ barButton(),
431
+ when("& > [data-icon='pause']", raw({ display: "none" })),
432
+ when("[data-playing] & > [data-icon='play']", raw({ display: "none" })),
433
+ when("[data-playing] & > [data-icon='pause']", raw({ display: "block" })),
434
+ ], mix), children: [_jsx(VideoIcon, { name: "play" }), _jsx(VideoIcon, { name: "pause" })] }));
435
+ };
436
+ };
437
+ /**
438
+ * The time played and the video's length, `1:12 / 11:43`. It takes the free space after
439
+ * it, so the controls that follow sit at the bar's inline end.
440
+ *
441
+ * @param handle Runtime handle carrying the `<span>`'s props.
442
+ * @returns The render function producing the reading.
443
+ */
444
+ VideoPlayer.Time = function VideoPlayerTime(handle) {
445
+ return () => {
446
+ let { mix, ...rest } = handle.props;
447
+ let { current = 0, duration } = timeline(handle);
448
+ return (_jsxs("span", { ...rest, "data-slot": "video-player-time", mix: mergeMix([
449
+ raw({
450
+ marginInline: "0.375rem auto",
451
+ fontFamily: "var(--ui-font-mono, ui-monospace, monospace)",
452
+ fontSize: "0.8125rem",
453
+ fontVariantNumeric: "tabular-nums",
454
+ whiteSpace: "nowrap",
455
+ }),
456
+ ], mix), children: [_jsx("span", { "data-slot": "video-player-elapsed", children: formatVideoTime(current) }), _jsx("span", { "aria-hidden": "true", mix: [raw({ color: ON_VIDEO_MUTED })], children: " / " }), _jsx("span", { "data-slot": "video-player-length", mix: [raw({ color: ON_VIDEO_MUTED })], children: formatVideoTime(duration) })] }));
457
+ };
458
+ };
459
+ /**
460
+ * Turns captions on and off: on shows the track last chosen in the captions menu, the
461
+ * first one at the start. `aria-pressed` says whether captions show.
462
+ *
463
+ * @param handle Runtime handle carrying the button's props.
464
+ * @returns The render function producing the button.
465
+ */
466
+ VideoPlayer.CaptionsToggle = function VideoPlayerCaptionsToggle(handle) {
467
+ return () => {
468
+ let { label, mix, ...rest } = handle.props;
469
+ return (_jsx("button", { ...rest, type: "button", "aria-label": label, "aria-pressed": "false", "data-video-action": "captions", mix: mergeMix([
470
+ barButton(),
471
+ when("&[aria-pressed='true']::after", raw({
472
+ content: "''",
473
+ position: "absolute",
474
+ insetInline: "0.625rem",
475
+ insetBlockEnd: "0.375rem",
476
+ blockSize: "2px",
477
+ borderRadius: "1px",
478
+ backgroundColor: ON_VIDEO_ACCENT,
479
+ })),
480
+ ], mix), children: _jsx(VideoIcon, { name: "captions" }) }));
481
+ };
482
+ };
483
+ /**
484
+ * The settings gear and its menu: a Popover API surface the gear opens through
485
+ * `commandfor`, holding toggles and submenus in order. A submenu replaces the top level in
486
+ * place with a back row; the arrow keys walk the rows, → opens a submenu and ← leaves it.
487
+ *
488
+ * @param handle Runtime handle carrying the gear's props.
489
+ * @returns The render function producing the gear and its menu.
490
+ * @example
491
+ * <VideoPlayer.Settings label="Settings">
492
+ * <VideoPlayer.SettingsToggle name="ambient" label="Ambient mode" />
493
+ * <VideoPlayer.SpeedMenu label="Playback speed" normalLabel="Normal" backLabel="Back" />
494
+ * </VideoPlayer.Settings>
495
+ */
496
+ VideoPlayer.Settings = function VideoPlayerSettings(handle) {
497
+ return () => {
498
+ let { badge, children, id = `${handle.id}-menu`, label, mix, ...rest } = handle.props;
499
+ let follows = badge === undefined;
500
+ let mark = follows ? timeline(handle).sources[0]?.badge : badge || undefined;
501
+ return (_jsxs(_Fragment, { children: [_jsxs("button", { ...rest, type: "button", "aria-label": label, "aria-haspopup": "menu", commandfor: id, command: "toggle-popover", mix: mergeMix([barButton()], mix), children: [_jsx(VideoIcon, { name: "settings" }), _jsx("span", { "data-slot": "video-player-badge", "data-follows-quality": follows ? "" : undefined, hidden: mark === undefined, "aria-hidden": "true", mix: [gearBadge()], children: mark })] }), _jsx(Popover, { id: id, placement: "top-end", "data-slot": "video-player-settings", mix: [menuSurface()], children: _jsx("div", { role: "menu", "aria-label": label, "data-slot": "video-player-menu", children: children }) })] }));
502
+ };
503
+ };
504
+ /**
505
+ * A page-defined switch row: a real checkbox the page reads by `name` and follows with an
506
+ * ordinary `change` listener, such as ambient mode or a voice boost.
507
+ *
508
+ * @param handle Runtime handle carrying the `<input>`'s props.
509
+ * @returns The render function producing the row.
510
+ * @example <VideoPlayer.SettingsToggle name="voice-boost" label="Voice boost" checked />
511
+ */
512
+ VideoPlayer.SettingsToggle = function VideoPlayerSettingsToggle(handle) {
513
+ return () => {
514
+ let { label, mix, ...rest } = handle.props;
515
+ return (_jsxs("label", { "data-slot": "video-player-row", mix: [menuRow()], children: [_jsx("span", { mix: [raw({ flex: "1" })], children: label }), _jsx("input", { ...rest, type: "checkbox", role: "menuitemcheckbox", "aria-checked": rest.checked ? "true" : "false", "data-video-item": "", mix: mergeMix([switchControl()], mix) })] }));
516
+ };
517
+ };
518
+ /**
519
+ * A page-defined submenu: a row naming the current choice that opens a panel of
520
+ * {@link VideoPlayer.SettingsOption} radios under one `name`, such as a sleep timer. Picking
521
+ * one fires `change` and returns to the top level.
522
+ *
523
+ * @param handle Runtime handle carrying the panel's props.
524
+ * @returns The render function producing the row and its panel.
525
+ * @example
526
+ * <VideoPlayer.SettingsMenu name="sleep" label="Sleep timer" backLabel="Back">
527
+ * <VideoPlayer.SettingsOption value="off" checked>Off</VideoPlayer.SettingsOption>
528
+ * <VideoPlayer.SettingsOption value="30">30 minutes</VideoPlayer.SettingsOption>
529
+ * </VideoPlayer.SettingsMenu>
530
+ */
531
+ VideoPlayer.SettingsMenu = function VideoPlayerSettingsMenu(handle) {
532
+ return () => {
533
+ let { backLabel, children, label, mix, name, ...rest } = handle.props;
534
+ handle.context.set({ name });
535
+ let panelId = `${handle.id}-panel`;
536
+ let chosen = findAll(children, VideoPlayer.SettingsOption).find((option) => option.props.checked === true);
537
+ return (_jsxs("div", { role: "none", "data-slot": "video-player-submenu", children: [_jsxs("button", { type: "button", role: "menuitem", "aria-haspopup": "menu", "aria-expanded": "false", "aria-controls": panelId, "data-video-item": "", "data-video-action": "open", "data-slot": "video-player-row", mix: [menuRow()], children: [_jsx("span", { mix: [raw({ flex: "1" })], children: label }), _jsx("span", { "data-slot": "video-player-row-value", mix: [raw({ color: ON_VIDEO_MUTED })], children: chosen?.props.children }), _jsx(VideoIcon, { name: "next" })] }), _jsxs("div", { ...rest, id: panelId, role: "menu", hidden: true, "data-slot": "video-player-submenu-panel", mix: mergeMix([when("&:not([hidden])", raw({ display: "grid" }))], mix), children: [_jsxs("button", { type: "button", role: "menuitem", "data-video-item": "", "data-video-action": "back", mix: [
538
+ menuRow(),
539
+ raw({
540
+ fontWeight: "600",
541
+ borderBlockEnd: "1px solid rgb(255 255 255 / 0.16)",
542
+ marginBlockEnd: "0.25rem",
543
+ }),
544
+ ], children: [_jsx(VideoIcon, { name: "back" }), _jsx("span", { mix: [visuallyHidden()], children: `${backLabel}: ` }), _jsx("span", { children: label })] }), children] })] }));
545
+ };
546
+ };
547
+ /**
548
+ * One choice of a {@link VideoPlayer.SettingsMenu}: a real radio under the menu's name,
549
+ * marked with a check when chosen.
550
+ *
551
+ * @param handle Runtime handle carrying the `<input>`'s props.
552
+ * @returns The render function producing the option row.
553
+ * @example <VideoPlayer.SettingsOption value="30">30 minutes</VideoPlayer.SettingsOption>
554
+ */
555
+ VideoPlayer.SettingsOption = function VideoPlayerSettingsOption(handle) {
556
+ return () => {
557
+ let { badge, children, mix, ...rest } = handle.props;
558
+ let menu = handle.context.get(VideoPlayer.SettingsMenu);
559
+ return (_jsxs("label", { "data-slot": "video-player-option", mix: [menuRow()], children: [_jsx("input", { ...rest, type: "radio", role: "menuitemradio", "aria-checked": rest.checked ? "true" : "false", name: menu?.name, "data-video-item": "", mix: mergeMix([checkMark()], mix) }), _jsx("span", { "data-slot": "video-player-option-label", children: children }), badge ? _jsx("span", { mix: [optionBadge()], children: badge }) : null] }));
560
+ };
561
+ };
562
+ /**
563
+ * The captions submenu: Off, then every captions and subtitles track the video holds. It
564
+ * stays in step with {@link VideoPlayer.CaptionsToggle}.
565
+ *
566
+ * @param handle Runtime handle carrying the panel's props.
567
+ * @returns The render function producing the submenu.
568
+ */
569
+ VideoPlayer.CaptionsMenu = function VideoPlayerCaptionsMenu(handle) {
570
+ return () => {
571
+ let { label, offLabel, ...rest } = handle.props;
572
+ let { captions } = timeline(handle);
573
+ return (_jsxs(VideoPlayer.SettingsMenu, { ...rest, name: `${handle.id}-captions`, label: label, "data-video-setting": "captions", children: [_jsx(VideoPlayer.SettingsOption, { value: "-1", checked: true, children: offLabel }), captions.map((track, index) => (_jsx(VideoPlayer.SettingsOption, { value: String(index), children: track.label }, `${track.label}-${index}`)))] }));
574
+ };
575
+ };
576
+ /**
577
+ * The playback speed submenu; a choice sets the video's `playbackRate` and survives a
578
+ * quality change.
579
+ *
580
+ * @param handle Runtime handle carrying the panel's props.
581
+ * @returns The render function producing the submenu.
582
+ * @example <VideoPlayer.SpeedMenu label="Playback speed" normalLabel="Normal" backLabel="Back" rates={[1, 1.5, 2]} />
583
+ */
584
+ VideoPlayer.SpeedMenu = function VideoPlayerSpeedMenu(handle) {
585
+ return () => {
586
+ let { label, normalLabel, rates = DEFAULT_RATES, ...rest } = handle.props;
587
+ return (_jsx(VideoPlayer.SettingsMenu, { ...rest, name: `${handle.id}-rate`, label: label, "data-video-setting": "rate", children: rates.map((rate) => (_jsx(VideoPlayer.SettingsOption, { value: String(rate), checked: rate === 1, children: rate === 1 ? normalLabel : String(rate) }, rate))) }));
588
+ };
589
+ };
590
+ /**
591
+ * The quality submenu: one row per labelled {@link VideoPlayer.Source}, by its `label` and
592
+ * `badge`; an unlabelled source is a format fallback and stays off the menu. A choice swaps
593
+ * the file and resumes from the same moment, and the gear's badge follows.
594
+ *
595
+ * @param handle Runtime handle carrying the panel's props.
596
+ * @returns The render function producing the submenu.
597
+ */
598
+ VideoPlayer.QualityMenu = function VideoPlayerQualityMenu(handle) {
599
+ return () => {
600
+ let { label, ...rest } = handle.props;
601
+ let { sources } = timeline(handle);
602
+ return (_jsx(VideoPlayer.SettingsMenu, { ...rest, name: `${handle.id}-quality`, label: label, "data-video-setting": "quality", children: sources.map((source, index) => source.label === undefined ? null : (_jsx(VideoPlayer.SettingsOption, { value: String(index), checked: index === 0, badge: source.badge, children: source.label }, source.src))) }));
603
+ };
604
+ };
605
+ /**
606
+ * Theater mode: sets `data-theater` on the player, which drops the side column under the
607
+ * screen so the video takes the full width. It shows from the `lg` container width, where
608
+ * the side column sits beside the screen; `aria-pressed` says whether it is on.
609
+ *
610
+ * @param handle Runtime handle carrying the button's props.
611
+ * @returns The render function producing the button.
612
+ */
613
+ VideoPlayer.Theater = function VideoPlayerTheater(handle) {
614
+ return () => {
615
+ let { label, mix, ...rest } = handle.props;
616
+ return (_jsx("button", { ...rest, type: "button", "aria-label": label, "aria-pressed": "false", "data-video-action": "theater", mix: mergeMix([
617
+ barButtonShape(),
618
+ raw({ display: "none" }),
619
+ at("lg", CONTAINER, raw({ display: "inline-grid" })),
620
+ ], mix), children: _jsx(VideoIcon, { name: "theater" }) }));
621
+ };
622
+ };
623
+ /**
624
+ * Full screen for the screen with its bar, so the controls stay. It hides itself where
625
+ * the browser offers no full screen.
626
+ *
627
+ * @param handle Runtime handle carrying the button's props.
628
+ * @returns The render function producing the button.
629
+ */
630
+ VideoPlayer.Fullscreen = function VideoPlayerFullscreen(handle) {
631
+ return () => {
632
+ let { label, mix, ...rest } = handle.props;
633
+ return (_jsxs("button", { ...rest, type: "button", "aria-label": label, "aria-pressed": "false", "data-video-action": "fullscreen", mix: mergeMix([
634
+ barButton(),
635
+ when("& > [data-icon='exit-fullscreen']", raw({ display: "none" })),
636
+ when("&[aria-pressed='true'] > [data-icon='fullscreen']", raw({ display: "none" })),
637
+ when("&[aria-pressed='true'] > [data-icon='exit-fullscreen']", raw({ display: "block" })),
638
+ ], mix), children: [_jsx(VideoIcon, { name: "fullscreen" }), _jsx(VideoIcon, { name: "exit-fullscreen" })] }));
639
+ };
640
+ };
641
+ /** A 24px glyph in the current colour, decorative because its button carries the name. */
642
+ function VideoIcon(handle) {
643
+ return () => {
644
+ let { name } = handle.props;
645
+ let stroke = {
646
+ fill: "none",
647
+ stroke: "currentColor",
648
+ "stroke-width": "2",
649
+ "stroke-linecap": "round",
650
+ "stroke-linejoin": "round",
651
+ };
652
+ return (_jsxs("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", "data-icon": name, mix: [raw({ inlineSize: "1.5rem", blockSize: "1.5rem", flexShrink: "0" })], children: [name === "play" ? _jsx("path", { d: "M8 5.5v13l11-6.5z", fill: "currentColor" }) : null, name === "pause" ? (_jsx("path", { d: "M7 5h3.5v14H7zM13.5 5H17v14h-3.5z", fill: "currentColor" })) : null, name === "captions" ? (_jsxs(_Fragment, { children: [_jsx("rect", { x: "3", y: "5", width: "18", height: "14", rx: "2.5", ...stroke }), _jsx("path", { d: "M10.5 10a2 2 0 1 0 0 4M16.5 10a2 2 0 1 0 0 4", ...stroke })] })) : null, name === "settings" ? (_jsxs(_Fragment, { children: [_jsx("circle", { cx: "12", cy: "12", r: "8", ...stroke, "stroke-width": "3", "stroke-dasharray": "3 3.283", "stroke-linecap": "butt" }), _jsx("circle", { cx: "12", cy: "12", r: "5.5", ...stroke, "stroke-width": "3" })] })) : null, name === "theater" ? (_jsx("rect", { x: "2.5", y: "6.5", width: "19", height: "11", rx: "1.5", ...stroke })) : null, name === "fullscreen" ? (_jsx("path", { d: "M4 9V4h5M15 4h5v5M20 15v5h-5M9 20H4v-5", ...stroke })) : null, name === "exit-fullscreen" ? (_jsx("path", { d: "M9 4v5H4M20 9h-5V4M15 20v-5h5M4 15h5v5", ...stroke })) : null, name === "next" ? _jsx("path", { d: "M9 6l6 6-6 6", ...stroke }) : null, name === "back" ? _jsx("path", { d: "M15 6l-6 6 6 6", ...stroke }) : null] }));
653
+ };
654
+ }
655
+ /** One scrubber segment, as wide as its chapter is long, filled up to the played share. */
656
+ function segment(length) {
657
+ return raw({
658
+ flexGrow: String(Math.max(0, length)),
659
+ flexBasis: "0",
660
+ borderRadius: "9999px",
661
+ backgroundImage: "linear-gradient(to right, var(--ui-video-player-accent) var(--ui-video-player-played, 0%), var(--ui-video-player-line) var(--ui-video-player-played, 0%))",
662
+ });
663
+ }
664
+ /** Mono, tabular, muted small print for times and meta. */
665
+ function monoSmall() {
666
+ return raw({
667
+ fontFamily: "var(--ui-font-mono, ui-monospace, monospace)",
668
+ fontSize: "0.75rem",
669
+ lineHeight: "1.25rem",
670
+ fontVariantNumeric: "tabular-nums",
671
+ color: "var(--ui-video-player-muted)",
672
+ whiteSpace: "nowrap",
673
+ });
674
+ }
675
+ /** The small uppercase label over the side column's lists. */
676
+ function sideLabel() {
677
+ return raw({
678
+ margin: "0",
679
+ fontSize: "0.6875rem",
680
+ lineHeight: "1rem",
681
+ fontWeight: "600",
682
+ letterSpacing: "0.08em",
683
+ textTransform: "uppercase",
684
+ color: "var(--ui-video-player-muted)",
685
+ });
686
+ }
687
+ /** An unstyled, stacked list. */
688
+ function plainList() {
689
+ return raw({ listStyle: "none", margin: "0", padding: "0", display: "grid" });
690
+ }
691
+ /** The ring every link in the player shows under keyboard focus. */
692
+ function focusRing() {
693
+ return focusVisible(raw({ outline: "2px solid var(--ui-video-player-accent)", outlineOffset: "2px" }));
694
+ }
695
+ /** The ring a control on the picture shows under keyboard focus, light on any frame. */
696
+ function onVideoFocus() {
697
+ return focusVisible(raw({ outline: `2px solid ${ON_VIDEO}`, outlineOffset: "-2px" }));
698
+ }
699
+ /**
700
+ * A chapter link: optional still, title and start time on one 44px row, the playing
701
+ * chapter washed and its still ringed in the accent. Hover changes colour only.
702
+ */
703
+ function chapterLink() {
704
+ return combine([
705
+ raw({
706
+ display: "grid",
707
+ gridTemplateColumns: "minmax(0, 1fr) auto",
708
+ alignItems: "center",
709
+ columnGap: "0.75rem",
710
+ minBlockSize: "2.75rem",
711
+ boxSizing: "border-box",
712
+ padding: "0.375rem 0.5rem",
713
+ borderRadius: "0.5rem",
714
+ fontSize: "var(--ui-text-sm, 0.875rem)",
715
+ lineHeight: "1.25rem",
716
+ color: "inherit",
717
+ textDecoration: "none",
718
+ }),
719
+ when("&:has([data-slot='video-player-thumbnail'])", raw({ gridTemplateColumns: "auto minmax(0, 1fr) auto", paddingInlineStart: "0.375rem" })),
720
+ when("& > [data-slot='video-player-thumbnail']", raw({
721
+ display: "block",
722
+ inlineSize: "3.5rem",
723
+ aspectRatio: "16 / 9",
724
+ overflow: "clip",
725
+ borderRadius: "0.25rem",
726
+ boxShadow: "0 0 0 1px var(--ui-video-player-line)",
727
+ })),
728
+ when("& > [data-slot='video-player-thumbnail'] > *", raw({ display: "block", inlineSize: "100%", blockSize: "100%" })),
729
+ hover(raw({ color: "var(--ui-video-player-emphasis)" })),
730
+ when("&[aria-current]", raw({
731
+ backgroundColor: "var(--ui-video-player-wash)",
732
+ color: "var(--ui-video-player-emphasis)",
733
+ })),
734
+ when("&[aria-current] > [data-slot='video-player-thumbnail']", raw({ boxShadow: "0 0 0 2px var(--ui-video-player-accent)" })),
735
+ focusRing(),
736
+ ]);
737
+ }
738
+ /** A transcript line: its time link in a fixed track, the words beside it, the current lit. */
739
+ function cueRow() {
740
+ return combine([
741
+ raw({
742
+ display: "grid",
743
+ gridTemplateColumns: "2.75rem minmax(0, 1fr)",
744
+ columnGap: "0.5rem",
745
+ fontSize: "var(--ui-text-sm, 0.875rem)",
746
+ lineHeight: "1.375rem",
747
+ textWrap: "pretty",
748
+ }),
749
+ when("&[aria-current]", raw({ color: "var(--ui-video-player-emphasis)" })),
750
+ when("&[aria-current] > a", raw({ color: "var(--ui-video-player-accent)" })),
751
+ ]);
752
+ }
753
+ /** A transcript time: muted tabular figures that brighten on hover. */
754
+ function timeLink() {
755
+ return combine([
756
+ monoSmall(),
757
+ raw({ textDecoration: "none", borderRadius: "0.25rem", lineHeight: "1.375rem" }),
758
+ hover(raw({ color: "var(--ui-video-player-emphasis)" })),
759
+ focusRing(),
760
+ ]);
761
+ }
762
+ /** A 40px square icon button on the picture; a `hidden` one stays hidden. */
763
+ function barButton() {
764
+ return combine([barButtonShape(), when("&:not([hidden])", raw({ display: "inline-grid" }))]);
765
+ }
766
+ /** The look of a bar button, leaving when it shows to the caller. */
767
+ function barButtonShape() {
768
+ return combine([
769
+ raw({
770
+ position: "relative",
771
+ placeItems: "center",
772
+ inlineSize: "2.5rem",
773
+ blockSize: "2.5rem",
774
+ padding: "0",
775
+ border: "0",
776
+ borderRadius: "0.5rem",
777
+ backgroundColor: "transparent",
778
+ color: "inherit",
779
+ cursor: "pointer",
780
+ }),
781
+ when("& > svg", raw({ gridArea: "1 / 1" })),
782
+ hover(raw({ backgroundColor: ON_VIDEO_WASH })),
783
+ onVideoFocus(),
784
+ ]);
785
+ }
786
+ /** The quality mark pinned to the gear's corner. */
787
+ function gearBadge() {
788
+ return combine([
789
+ raw({
790
+ position: "absolute",
791
+ insetBlockStart: "0.25rem",
792
+ insetInlineEnd: "0",
793
+ padding: "0 0.1875rem",
794
+ borderRadius: "0.1875rem",
795
+ backgroundColor: ON_VIDEO_ACCENT,
796
+ color: "white",
797
+ fontSize: "0.5625rem",
798
+ lineHeight: "0.875rem",
799
+ fontWeight: "700",
800
+ letterSpacing: "0.02em",
801
+ }),
802
+ when("&[hidden]", hidden()),
803
+ ]);
804
+ }
805
+ /**
806
+ * The menu's dark surface over the picture, scrolling when the screen is short. Where it
807
+ * fits beside the gear on neither side, it centres on the gear across the viewport.
808
+ */
809
+ function menuSurface() {
810
+ return raw({
811
+ positionTryFallbacks: "flip-block, top span-all, bottom span-all",
812
+ colorScheme: "dark",
813
+ color: ON_VIDEO,
814
+ backgroundColor: MENU_BG,
815
+ border: "0",
816
+ borderRadius: "0.75rem",
817
+ padding: "0.5rem 0",
818
+ boxSizing: "border-box",
819
+ inlineSize: "min(17rem, calc(100vw - 1rem))",
820
+ maxBlockSize: "min(22rem, calc(100dvh - 5rem))",
821
+ overflowY: "auto",
822
+ fontSize: "var(--ui-text-sm, 0.875rem)",
823
+ lineHeight: "1.25rem",
824
+ });
825
+ }
826
+ /** A 44px menu row; rows of the top level step aside while a submenu shows. */
827
+ function menuRow() {
828
+ return combine([
829
+ raw({
830
+ display: "flex",
831
+ alignItems: "center",
832
+ gap: "0.75rem",
833
+ boxSizing: "border-box",
834
+ inlineSize: "100%",
835
+ minBlockSize: "2.75rem",
836
+ margin: "0",
837
+ padding: "0 1rem",
838
+ border: "0",
839
+ backgroundColor: "transparent",
840
+ color: "inherit",
841
+ font: "inherit",
842
+ textAlign: "start",
843
+ cursor: "pointer",
844
+ }),
845
+ hover(raw({ backgroundColor: ON_VIDEO_WASH })),
846
+ when("&:has(:focus-visible), &:focus-visible", raw({ backgroundColor: ON_VIDEO_WASH })),
847
+ focusVisible(raw({ outline: "none" })),
848
+ when("[data-submenu] &[data-slot='video-player-row']", raw({ display: "none" })),
849
+ ]);
850
+ }
851
+ /** A checkbox drawn as a switch, its knob sliding to the end when on. */
852
+ function switchControl() {
853
+ return combine([
854
+ raw({
855
+ appearance: "none",
856
+ position: "relative",
857
+ flexShrink: "0",
858
+ inlineSize: "2.25rem",
859
+ blockSize: "1.25rem",
860
+ margin: "0",
861
+ borderRadius: "9999px",
862
+ backgroundColor: "rgb(255 255 255 / 0.3)",
863
+ cursor: "pointer",
864
+ }),
865
+ motionSafe(raw({ transition: "background-color 150ms" })),
866
+ when("&::before", raw({
867
+ content: "''",
868
+ position: "absolute",
869
+ insetBlockStart: "0.125rem",
870
+ insetInlineStart: "0.125rem",
871
+ inlineSize: "1rem",
872
+ blockSize: "1rem",
873
+ borderRadius: "9999px",
874
+ backgroundColor: "white",
875
+ })),
876
+ when("&::before", motionSafe(raw({ transition: "translate 150ms" }))),
877
+ when("&:checked", raw({ backgroundColor: ON_VIDEO_ACCENT })),
878
+ when("&:checked::before", raw({ translate: "1rem 0" })),
879
+ when("&:checked:dir(rtl)::before", raw({ translate: "-1rem 0" })),
880
+ focusVisible(raw({ outline: "none" })),
881
+ ]);
882
+ }
883
+ /** A radio drawn as the check mark beside the chosen option, and as blank space otherwise. */
884
+ function checkMark() {
885
+ return combine([
886
+ raw({
887
+ appearance: "none",
888
+ display: "grid",
889
+ placeContent: "center",
890
+ flexShrink: "0",
891
+ inlineSize: "1.25rem",
892
+ blockSize: "1.25rem",
893
+ margin: "0",
894
+ cursor: "pointer",
895
+ }),
896
+ when("&:checked::before", raw({
897
+ content: "''",
898
+ inlineSize: "0.375rem",
899
+ blockSize: "0.75rem",
900
+ marginBlockStart: "-0.125rem",
901
+ border: "solid currentColor",
902
+ borderWidth: "0 2px 2px 0",
903
+ rotate: "45deg",
904
+ })),
905
+ focusVisible(raw({ outline: "none" })),
906
+ ]);
907
+ }
908
+ /** The small mark after an option's label, such as `4K`. */
909
+ function optionBadge() {
910
+ return raw({
911
+ marginInlineStart: "-0.375rem",
912
+ fontSize: "0.625rem",
913
+ lineHeight: "1rem",
914
+ fontWeight: "700",
915
+ color: ON_VIDEO_ACCENT,
916
+ verticalAlign: "super",
917
+ });
918
+ }
919
+ /**
920
+ * The island inside every {@link VideoPlayer}: a hidden marker that seeks from time links,
921
+ * marks what plays, and swaps the native controls for a {@link VideoPlayer.Controls} bar.
922
+ * It sits after the screen's `<video>` so its insert handler can find that element. It loads
923
+ * from `@sdxc/ui/video/video-player`, which the browser entry maps to an import.
924
+ */
925
+ export const VideoPlayerSync = clientEntry("@sdxc/ui/video/video-player#VideoPlayerSync", function VideoPlayerSync() {
926
+ return () => _jsx("span", { mix: [hidden(), videoPlayerSync()] });
927
+ });