@hyperframes/studio 0.8.20 → 0.8.21

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 (37) hide show
  1. package/dist/assets/hyperframes-player-CIXNA_bj.js +460 -0
  2. package/dist/assets/{index-BL1zYTW0.js → index-44gfDvkh.js} +1 -1
  3. package/dist/assets/{index-Cehosfnu.js → index-9VfE7bZe.js} +1 -1
  4. package/dist/assets/{index-CBSKXKAr.js → index-CgGY8dAv.js} +164 -164
  5. package/dist/index.d.ts +28 -0
  6. package/dist/index.html +1 -1
  7. package/dist/index.js +1170 -227
  8. package/dist/index.js.map +1 -1
  9. package/package.json +7 -7
  10. package/src/App.tsx +2 -0
  11. package/src/contexts/StudioContext.tsx +10 -0
  12. package/src/hooks/useStudioContextValue.ts +9 -0
  13. package/src/player/hooks/timelineSyncHydration.test.ts +96 -0
  14. package/src/player/hooks/timelineSyncHydration.ts +47 -1
  15. package/src/player/hooks/useExpandedTimelineElements.test.ts +43 -0
  16. package/src/player/hooks/useExpandedTimelineElements.ts +52 -29
  17. package/src/player/hooks/useTimelineSyncCallbacks.ts +4 -0
  18. package/src/player/store/playerStore.ts +17 -2
  19. package/src/player/store/timelineElement.ts +21 -0
  20. package/src/webmcp/StudioAgentTools.tsx +105 -10
  21. package/src/webmcp/toolResult.ts +1 -1
  22. package/src/webmcp/tools/animationTools.test.ts +244 -0
  23. package/src/webmcp/tools/animationTools.ts +276 -0
  24. package/src/webmcp/tools/contentTools.test.ts +275 -0
  25. package/src/webmcp/tools/contentTools.ts +217 -0
  26. package/src/webmcp/tools/frameTools.test.ts +136 -0
  27. package/src/webmcp/tools/frameTools.ts +133 -0
  28. package/src/webmcp/tools/inspectTools.test.ts +197 -0
  29. package/src/webmcp/tools/inspectTools.ts +208 -0
  30. package/src/webmcp/tools/selectionTools.test.ts +164 -0
  31. package/src/webmcp/tools/selectionTools.ts +154 -0
  32. package/src/webmcp/tools/transformTools.test.ts +179 -0
  33. package/src/webmcp/tools/transformTools.ts +205 -0
  34. package/src/webmcp/useStudioAgentTools.test.tsx +71 -22
  35. package/src/webmcp/useStudioAgentTools.ts +195 -1
  36. package/src/webmcp/webmcpTestUtils.ts +91 -0
  37. package/dist/assets/hyperframes-player-BEKxuimO.js +0 -459
@@ -0,0 +1,460 @@
1
+ var ve=Object.defineProperty;var be=(n,i,e)=>i in n?ve(n,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[i]=e;var u=(n,i,e)=>be(n,typeof i!="symbol"?i+"":i,e);import{r as le,i as we,a as Ae}from"./index-CgGY8dAv.js";function Ee(n){return n.hasRuntime||n.runtimeInjected?!1:!!(n.hasNestedCompositions||n.hasTimelines&&n.attempts>=5)}function V(n){return typeof n=="object"&&n!==null}function Ce(n){return V(n)&&typeof n.getDuration=="function"}function Te(n){return V(n)&&typeof n.duration=="function"&&typeof n.time=="function"&&typeof n.seek=="function"&&typeof n.play=="function"&&typeof n.pause=="function"}function Se(n){if(!/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.test(n))throw new Error(`Invalid HyperFrames runtime version: ${n}`);return`https://cdn.jsdelivr.net/npm/@hyperframes/core@${n}/dist/hyperframe.runtime.iife.js`}const H=typeof __HYPERFRAMES_RUNTIME_CDN_URL__=="string"?__HYPERFRAMES_RUNTIME_CDN_URL__:Se("0.0.0-dev");function $(n){if(n===null)return null;const i=Number.parseInt(n,10);return Number.isFinite(i)&&i>0?i:null}function Re(n){const i=(n==null?void 0:n.querySelector("[data-composition-id][data-width][data-height]"))??(n==null?void 0:n.querySelector("[data-width][data-height]"));if(!i)return null;const e=$(i.getAttribute("data-width")),t=$(i.getAttribute("data-height"));return e!==null&&t!==null?{width:e,height:t}:null}class xe{constructor(i,e){u(this,"_interval",null);u(this,"_runtimeInjected",!1);this._iframe=i,this._callbacks=e}get runtimeInjected(){return this._runtimeInjected}start(){this.stop(),this._runtimeInjected=!1;let i=0;this._interval=setInterval(()=>{var e;i++;try{const t=this._iframe.contentWindow;if(!t)return;const r=!!(t.__hf||t.__player),s=!!(t.__timelines&&Object.keys(t.__timelines).length>0),o=!!((e=this._iframe.contentDocument)!=null&&e.querySelector("[data-composition-src]"));if(Ee({hasRuntime:r,hasTimelines:s,hasNestedCompositions:o,runtimeInjected:this._runtimeInjected,attempts:i})){this._injectRuntime();return}if(this._runtimeInjected&&!r)return;const d=this._resolvePlaybackDurationAdapter(t);if(d&&d.getDuration()>0){this.stop();const p=Re(this._iframe.contentDocument);this._callbacks.onReady({duration:d.getDuration(),adapter:d,compositionSize:p});return}}catch{}i>=40&&(this.stop(),this._callbacks.onError("Composition timeline not found after 8s"))},200)}stop(){this._interval!==null&&(clearInterval(this._interval),this._interval=null)}resolveDirectTimelineAdapter(){try{const i=this._iframe.contentWindow;return i?this._resolveDirectTimelineAdapterFromWindow(i):null}catch{return null}}resolveDirectTimelineAdapterFromWindow(i){return this._resolveDirectTimelineAdapterFromWindow(i)}hasRuntimeBridge(i){return Reflect.get(i,"__hf")!==void 0||V(Reflect.get(i,"__player"))}_injectRuntime(){var i,e;this._runtimeInjected=!0;try{const t=this._iframe.contentDocument;if(!t)return;const r=t.createElement("script");r.src=H,(t.head||t.documentElement).appendChild(r),(e=(i=this._callbacks).onRuntimeInjected)==null||e.call(i)}catch{}}_resolveDirectTimelineAdapterFromWindow(i){var d,p;if(this.hasRuntimeBridge(i))return null;const e=Reflect.get(i,"__timelines");if(!V(e))return null;const t=Object.keys(e);if(t.length===0)return null;const r=(p=(d=this._iframe.contentDocument)==null?void 0:d.querySelector("[data-composition-id]"))==null?void 0:p.getAttribute("data-composition-id"),s=r&&r in e?r:t[t.length-1],o=e[s];return Te(o)?o:null}_resolvePlaybackDurationAdapter(i){const e=Reflect.get(i,"__player");if(Ce(e))return{kind:"runtime",getDuration:()=>e.getDuration()};const t=this._resolveDirectTimelineAdapterFromWindow(i);return t?{kind:"direct-timeline",timeline:t,getDuration:()=>t.duration()}:null}}const Me=`
2
+ :host {
3
+ display: block;
4
+ position: relative;
5
+ overflow: hidden;
6
+ background: #000;
7
+ contain: layout style;
8
+ }
9
+
10
+ .hfp-container {
11
+ position: absolute;
12
+ inset: 0;
13
+ overflow: hidden;
14
+ pointer-events: none;
15
+ }
16
+
17
+
18
+ .hfp-iframe {
19
+ position: absolute;
20
+ top: 50%;
21
+ left: 50%;
22
+ border: none;
23
+ pointer-events: none;
24
+ }
25
+
26
+ /* Opt-in: an interactive composition (e.g. a live slideshow/app with playable
27
+ media or controls) — let pointer events reach the iframe content. */
28
+ :host([interactive]) .hfp-container,
29
+ :host([interactive]) .hfp-iframe {
30
+ pointer-events: auto;
31
+ }
32
+
33
+ .hfp-poster {
34
+ position: absolute;
35
+ inset: 0;
36
+ object-fit: contain;
37
+ z-index: 1;
38
+ pointer-events: none;
39
+ }
40
+
41
+ .hfp-shader-loader {
42
+ position: absolute;
43
+ inset: 0;
44
+ z-index: 20;
45
+ display: grid;
46
+ place-items: center;
47
+ visibility: hidden;
48
+ opacity: 0;
49
+ pointer-events: none;
50
+ background: #030504;
51
+ color: #f4f7fb;
52
+ cursor: default;
53
+ user-select: none;
54
+ -webkit-user-select: none;
55
+ transition: opacity 420ms ease-out, visibility 420ms ease-out;
56
+ }
57
+
58
+ .hfp-shader-loader.hfp-visible,
59
+ .hfp-shader-loader.hfp-hiding {
60
+ visibility: visible;
61
+ }
62
+
63
+ .hfp-shader-loader.hfp-visible {
64
+ opacity: 1;
65
+ pointer-events: auto;
66
+ }
67
+
68
+ .hfp-shader-loader.hfp-hiding {
69
+ opacity: 0;
70
+ pointer-events: none;
71
+ }
72
+
73
+ .hfp-shader-loader-panel {
74
+ display: grid;
75
+ grid-template-rows: 86px 40px 26px 12px 44px;
76
+ justify-items: center;
77
+ align-items: center;
78
+ gap: 8px;
79
+ width: min(620px, 82%);
80
+ text-align: center;
81
+ font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
82
+ }
83
+
84
+ .hfp-shader-loader-mark {
85
+ width: 86px;
86
+ height: 86px;
87
+ display: grid;
88
+ place-items: center;
89
+ overflow: visible;
90
+ }
91
+
92
+ .hfp-shader-loader-mark svg {
93
+ display: block;
94
+ overflow: visible;
95
+ filter: drop-shadow(0 0 5px rgba(79, 219, 94, 0.16));
96
+ pointer-events: none;
97
+ }
98
+
99
+ .hfp-shader-loader-title {
100
+ width: 100%;
101
+ height: 40px;
102
+ overflow: hidden;
103
+ white-space: nowrap;
104
+ text-overflow: ellipsis;
105
+ font-size: 26px;
106
+ line-height: 40px;
107
+ font-weight: 700;
108
+ letter-spacing: 0;
109
+ }
110
+
111
+ .hfp-shader-loader-title-text {
112
+ color: transparent;
113
+ background: linear-gradient(
114
+ 90deg,
115
+ rgba(244, 247, 251, 0.84) 0%,
116
+ #ffffff 42%,
117
+ #80efe4 52%,
118
+ #ffffff 62%,
119
+ rgba(244, 247, 251, 0.84) 100%
120
+ );
121
+ background-size: 220% 100%;
122
+ -webkit-background-clip: text;
123
+ background-clip: text;
124
+ animation: hfp-shader-loader-sheen 1.9s linear infinite;
125
+ }
126
+
127
+ .hfp-shader-loader-detail {
128
+ width: 100%;
129
+ height: 26px;
130
+ overflow: hidden;
131
+ white-space: nowrap;
132
+ text-overflow: ellipsis;
133
+ color: rgba(244, 247, 251, 0.62);
134
+ font-size: 15px;
135
+ line-height: 26px;
136
+ font-weight: 500;
137
+ }
138
+
139
+ .hfp-shader-loader-track {
140
+ width: min(360px, 100%);
141
+ height: 8px;
142
+ overflow: hidden;
143
+ border-radius: 999px;
144
+ background: rgba(255, 255, 255, 0.1);
145
+ }
146
+
147
+ .hfp-shader-loader-fill {
148
+ width: 100%;
149
+ height: 100%;
150
+ border-radius: inherit;
151
+ background: linear-gradient(90deg, #06e3fa, #4fdb5e);
152
+ transform: scaleX(0);
153
+ transform-origin: left center;
154
+ transition: transform 160ms ease;
155
+ }
156
+
157
+ .hfp-shader-loader-progress {
158
+ width: min(420px, 100%);
159
+ height: 44px;
160
+ display: grid;
161
+ grid-template-rows: repeat(2, 22px);
162
+ color: rgba(244, 247, 251, 0.48);
163
+ font: 600 13px/22px "IBM Plex Mono", "SF Mono", "Fira Code", "Courier New", monospace;
164
+ font-variant-numeric: tabular-nums;
165
+ }
166
+
167
+ .hfp-shader-loader-row {
168
+ display: grid;
169
+ grid-template-columns: minmax(0, 1fr) 74px;
170
+ align-items: center;
171
+ column-gap: 20px;
172
+ width: 100%;
173
+ white-space: nowrap;
174
+ }
175
+
176
+ .hfp-shader-loader-label {
177
+ min-width: 0;
178
+ overflow: hidden;
179
+ text-align: left;
180
+ text-overflow: ellipsis;
181
+ }
182
+
183
+ .hfp-shader-loader-value {
184
+ text-align: right;
185
+ }
186
+
187
+ @keyframes hfp-shader-loader-sheen {
188
+ from {
189
+ background-position: 140% 0;
190
+ }
191
+ to {
192
+ background-position: -140% 0;
193
+ }
194
+ }
195
+
196
+ /* ── Theming via CSS custom properties ──
197
+ *
198
+ * Override from outside the shadow DOM:
199
+ * hyperframes-player {
200
+ * --hfp-controls-bg: linear-gradient(transparent, rgba(0,0,0,0.9));
201
+ * --hfp-accent: #ff6b6b;
202
+ * --hfp-font: "Inter", sans-serif;
203
+ * }
204
+ */
205
+
206
+ .hfp-controls {
207
+ position: absolute;
208
+ bottom: 0;
209
+ left: 0;
210
+ right: 0;
211
+ display: flex;
212
+ align-items: center;
213
+ gap: var(--hfp-controls-gap, 12px);
214
+ padding: var(--hfp-controls-padding, 8px 16px);
215
+ background: var(--hfp-controls-bg, linear-gradient(transparent, rgba(0, 0, 0, 0.7)));
216
+ color: var(--hfp-color, #fff);
217
+ font-family: var(--hfp-font, system-ui, -apple-system, sans-serif);
218
+ font-size: var(--hfp-font-size, 13px);
219
+ z-index: 10;
220
+ pointer-events: auto;
221
+ opacity: 1;
222
+ transition: opacity 0.3s ease;
223
+ user-select: none;
224
+ }
225
+
226
+ .hfp-controls.hfp-hidden {
227
+ opacity: 0;
228
+ pointer-events: none;
229
+ }
230
+
231
+ .hfp-play-btn {
232
+ position: relative;
233
+ background: none;
234
+ border: none;
235
+ color: var(--hfp-color, #fff);
236
+ cursor: pointer;
237
+ padding: 8px;
238
+ display: flex;
239
+ align-items: center;
240
+ justify-content: center;
241
+ width: 40px;
242
+ height: 40px;
243
+ flex-shrink: 0;
244
+ z-index: 10;
245
+ }
246
+
247
+ .hfp-play-btn:hover {
248
+ opacity: 0.8;
249
+ }
250
+
251
+ /* Stacked play/pause glyphs that crossfade-morph on toggle (rotate + scale). */
252
+ .hfp-play-btn .hfp-ico {
253
+ position: absolute;
254
+ display: flex;
255
+ align-items: center;
256
+ justify-content: center;
257
+ transition:
258
+ opacity 200ms ease,
259
+ transform 220ms cubic-bezier(0.4, 0, 0.2, 1);
260
+ }
261
+ .hfp-play-btn .hfp-ico-play {
262
+ opacity: 1;
263
+ transform: rotate(0) scale(1);
264
+ }
265
+ .hfp-play-btn .hfp-ico-pause {
266
+ opacity: 0;
267
+ transform: rotate(-90deg) scale(0.4);
268
+ }
269
+ .hfp-play-btn.hfp-playing .hfp-ico-play {
270
+ opacity: 0;
271
+ transform: rotate(90deg) scale(0.4);
272
+ }
273
+ .hfp-play-btn.hfp-playing .hfp-ico-pause {
274
+ opacity: 1;
275
+ transform: rotate(0) scale(1);
276
+ }
277
+ @media (prefers-reduced-motion: reduce) {
278
+ .hfp-play-btn .hfp-ico {
279
+ transition-duration: 0ms;
280
+ transform: none;
281
+ }
282
+ }
283
+
284
+ .hfp-play-btn svg,
285
+ .hfp-play-btn svg * {
286
+ pointer-events: none;
287
+ }
288
+
289
+ .hfp-scrubber {
290
+ flex: 1;
291
+ min-width: 0;
292
+ height: var(--hfp-scrubber-height, 4px);
293
+ background: var(--hfp-scrubber-bg, rgba(255, 255, 255, 0.3));
294
+ border-radius: var(--hfp-scrubber-radius, 2px);
295
+ cursor: pointer;
296
+ position: relative;
297
+ overflow: hidden;
298
+ }
299
+
300
+ .hfp-scrubber:hover {
301
+ height: var(--hfp-scrubber-height-hover, 6px);
302
+ }
303
+
304
+ .hfp-progress {
305
+ position: absolute;
306
+ top: 0;
307
+ left: 0;
308
+ height: 100%;
309
+ background: var(--hfp-accent, #fff);
310
+ pointer-events: none;
311
+ }
312
+
313
+ .hfp-time {
314
+ flex-shrink: 0;
315
+ font-variant-numeric: tabular-nums;
316
+ opacity: 0.9;
317
+ }
318
+
319
+ .hfp-speed-wrap {
320
+ position: relative;
321
+ flex-shrink: 0;
322
+ }
323
+
324
+ .hfp-speed-btn {
325
+ background: var(--hfp-speed-btn-bg, rgba(255, 255, 255, 0.15));
326
+ border: none;
327
+ border-radius: var(--hfp-speed-btn-radius, 4px);
328
+ color: var(--hfp-color, #fff);
329
+ cursor: pointer;
330
+ font-family: var(--hfp-font, system-ui, -apple-system, sans-serif);
331
+ font-size: 12px;
332
+ font-variant-numeric: tabular-nums;
333
+ font-weight: 600;
334
+ padding: 4px 8px;
335
+ min-width: 40px;
336
+ text-align: center;
337
+ transition: background 0.15s ease;
338
+ }
339
+
340
+ .hfp-speed-btn:hover {
341
+ background: var(--hfp-speed-btn-bg-hover, rgba(255, 255, 255, 0.3));
342
+ }
343
+
344
+ .hfp-speed-menu {
345
+ position: absolute;
346
+ bottom: calc(100% + 8px);
347
+ right: 0;
348
+ background: var(--hfp-menu-bg, rgba(20, 20, 20, 0.95));
349
+ backdrop-filter: blur(12px);
350
+ -webkit-backdrop-filter: blur(12px);
351
+ border: 1px solid var(--hfp-menu-border, rgba(255, 255, 255, 0.1));
352
+ border-radius: var(--hfp-menu-radius, 8px);
353
+ padding: 4px;
354
+ display: flex;
355
+ flex-direction: column;
356
+ gap: 2px;
357
+ min-width: 80px;
358
+ opacity: 0;
359
+ visibility: hidden;
360
+ transform: translateY(4px);
361
+ transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
362
+ box-shadow: var(--hfp-menu-shadow, 0 8px 24px rgba(0, 0, 0, 0.4));
363
+ }
364
+
365
+ .hfp-speed-menu.hfp-open {
366
+ opacity: 1;
367
+ visibility: visible;
368
+ transform: translateY(0);
369
+ }
370
+
371
+ .hfp-speed-option {
372
+ background: none;
373
+ border: none;
374
+ border-radius: 4px;
375
+ color: var(--hfp-menu-color, rgba(255, 255, 255, 0.7));
376
+ cursor: pointer;
377
+ font-family: var(--hfp-font, system-ui, -apple-system, sans-serif);
378
+ font-size: 13px;
379
+ font-variant-numeric: tabular-nums;
380
+ padding: 6px 12px;
381
+ text-align: left;
382
+ transition: background 0.1s ease, color 0.1s ease;
383
+ white-space: nowrap;
384
+ }
385
+
386
+ .hfp-speed-option:hover {
387
+ background: var(--hfp-menu-hover-bg, rgba(255, 255, 255, 0.1));
388
+ color: var(--hfp-color, #fff);
389
+ }
390
+
391
+ .hfp-speed-option.hfp-active {
392
+ color: var(--hfp-accent, #fff);
393
+ font-weight: 600;
394
+ }
395
+
396
+ .hfp-volume-wrap {
397
+ position: relative;
398
+ flex-shrink: 0;
399
+ display: flex;
400
+ align-items: center;
401
+ gap: 0;
402
+ }
403
+
404
+ .hfp-mute-btn {
405
+ background: none;
406
+ border: none;
407
+ color: var(--hfp-color, #fff);
408
+ cursor: pointer;
409
+ padding: 4px;
410
+ display: flex;
411
+ align-items: center;
412
+ justify-content: center;
413
+ width: 32px;
414
+ height: 32px;
415
+ flex-shrink: 0;
416
+ }
417
+
418
+ .hfp-mute-btn:hover {
419
+ opacity: 0.8;
420
+ }
421
+
422
+ .hfp-mute-btn svg,
423
+ .hfp-mute-btn svg * {
424
+ pointer-events: none;
425
+ }
426
+
427
+ .hfp-volume-slider-wrap {
428
+ width: 0;
429
+ overflow: hidden;
430
+ transition: width 0.2s ease;
431
+ display: flex;
432
+ align-items: center;
433
+ }
434
+
435
+ .hfp-volume-wrap:hover .hfp-volume-slider-wrap {
436
+ width: 64px;
437
+ }
438
+
439
+ .hfp-volume-slider {
440
+ width: 56px;
441
+ height: var(--hfp-scrubber-height, 4px);
442
+ background: var(--hfp-scrubber-bg, rgba(255, 255, 255, 0.3));
443
+ border-radius: var(--hfp-scrubber-radius, 2px);
444
+ cursor: pointer;
445
+ position: relative;
446
+ overflow: hidden;
447
+ margin-left: 4px;
448
+ margin-right: 4px;
449
+ }
450
+
451
+ .hfp-volume-fill {
452
+ position: absolute;
453
+ top: 0;
454
+ left: 0;
455
+ height: 100%;
456
+ background: var(--hfp-accent, #fff);
457
+ pointer-events: none;
458
+ }
459
+ `,De='<svg width="24" height="24" viewBox="46 21 54 56" fill="currentColor"><path d="M87.5129 57.5141L56.9696 73.5433C52.8371 75.7098 48.7046 73.2553 49.6688 69.2104L58.9483 30.1391C59.9125 26.0942 65.2097 23.6397 68.3154 25.8062L91.2447 41.8354C96.4668 45.4796 94.4631 53.8699 87.5129 57.5141Z"/></svg>',Le='<svg width="24" height="24" viewBox="0 0 18 18" fill="currentColor"><rect x="3" y="2" width="4" height="14"/><rect x="11" y="2" width="4" height="14"/></svg>',ue='<svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M3 9v6h4l5 5V4L7 9H3z"/><path d="M16.5 12c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02z"/><path d="M14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z"/></svg>',he='<svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M3 9v6h4l5 5V4L7 9H3z"/><path d="M16.5 12c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02z"/></svg>',ke='<svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M3 9v6h4l5 5V4L7 9H3z"/><path d="M16.5 12c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02z" opacity="0.3"/><line x1="18" y1="7" x2="14" y2="17" stroke="currentColor" stroke-width="2"/></svg>',Pe=[.25,.5,1,1.5,2,4];function j(n){return Number.isInteger(n)?`${n}x`:`${n}x`}function ce(n){if(!Number.isFinite(n)||n<0)return"0:00";const i=Math.floor(n),e=Math.floor(i/60),t=i%60;return`${e}:${t.toString().padStart(2,"0")}`}function Ie(n,i,e={}){const t=e.speedPresets??Pe,r=document.createElement("div");r.className="hfp-controls",r.addEventListener("click",a=>{a.stopPropagation()});const s=document.createElement("button");s.className="hfp-play-btn",s.type="button",s.innerHTML=`<span class="hfp-ico hfp-ico-play">${De}</span><span class="hfp-ico hfp-ico-pause">${Le}</span>`,s.setAttribute("aria-label","Play");const o=document.createElement("div");o.className="hfp-scrubber";const d=document.createElement("div");d.className="hfp-progress",d.style.width="0%",o.appendChild(d);const p=document.createElement("span");p.className="hfp-time",p.textContent="0:00 / 0:00";const c=document.createElement("div");c.className="hfp-speed-wrap";const h=document.createElement("button");h.className="hfp-speed-btn",h.type="button",h.textContent="1x",h.setAttribute("aria-label","Playback speed");const m=document.createElement("div");m.className="hfp-speed-menu",m.setAttribute("role","menu");for(const a of t){const l=document.createElement("button");l.className="hfp-speed-option",l.type="button",l.setAttribute("role","menuitem"),l.dataset.speed=String(a),l.textContent=j(a),a===1&&l.classList.add("hfp-active"),m.appendChild(l)}c.appendChild(m),c.appendChild(h);const y=document.createElement("div");y.className="hfp-volume-wrap";const g=document.createElement("button");g.className="hfp-mute-btn",g.type="button",g.innerHTML=ue,g.setAttribute("aria-label","Mute");const b=document.createElement("div");b.className="hfp-volume-slider-wrap";const f=document.createElement("div");f.className="hfp-volume-slider",f.setAttribute("role","slider"),f.setAttribute("aria-label","Volume"),f.setAttribute("aria-valuemin","0"),f.setAttribute("aria-valuemax","100"),f.setAttribute("aria-valuenow","100"),f.tabIndex=0;const v=document.createElement("div");v.className="hfp-volume-fill",v.style.width="100%",f.appendChild(v),b.appendChild(f),y.appendChild(b),y.appendChild(g),e.audioLocked&&(y.style.display="none"),r.appendChild(s),r.appendChild(o),r.appendChild(p),r.appendChild(y),r.appendChild(c),n.appendChild(r);let D=!1,C=!1,E=1,R=null;t.indexOf(1);const L=(a,l)=>a?ke:l===0||l<.5?he:ue;s.addEventListener("click",a=>{a.stopPropagation(),D?i.onPause():i.onPlay()}),g.addEventListener("click",a=>{a.stopPropagation(),i.onMuteToggle()});let T=!1;const k=a=>{const l=f.getBoundingClientRect(),_=Math.max(0,Math.min(1,(a-l.left)/l.width));E=_,v.style.width=`${_*100}%`,f.setAttribute("aria-valuenow",String(Math.round(_*100))),C&&_>0&&i.onMuteToggle(),g.innerHTML=L(C,_),i.onVolumeChange(_)};f.addEventListener("mousedown",a=>{a.stopPropagation(),T=!0,k(a.clientX)});const Y=a=>{T&&k(a.clientX)},Z=()=>{T=!1};document.addEventListener("mousemove",Y),document.addEventListener("mouseup",Z),f.addEventListener("touchstart",a=>{T=!0;const l=a.touches[0];l&&k(l.clientX)},{passive:!0});const Q=a=>{if(T){const l=a.touches[0];l&&k(l.clientX)}},J=()=>{T=!1};document.addEventListener("touchmove",Q,{passive:!0}),document.addEventListener("touchend",J);const K=.05;f.addEventListener("keydown",a=>{let l=E;if(a.key==="ArrowRight"||a.key==="ArrowUp")l=Math.min(1,E+K);else if(a.key==="ArrowLeft"||a.key==="ArrowDown")l=Math.max(0,E-K);else return;a.preventDefault(),a.stopPropagation(),E=l,v.style.width=`${l*100}%`,f.setAttribute("aria-valuenow",String(Math.round(l*100))),C&&l>0&&i.onMuteToggle(),g.innerHTML=L(C,l),i.onVolumeChange(l)});const ee=a=>{for(const l of m.querySelectorAll(".hfp-speed-option"))l.classList.toggle("hfp-active",l.dataset.speed===String(a))};h.addEventListener("click",a=>{a.stopPropagation();const l=m.classList.toggle("hfp-open");h.setAttribute("aria-expanded",String(l))}),m.addEventListener("click",a=>{a.stopPropagation();const l=a.target.closest(".hfp-speed-option");if(!l)return;const _=parseFloat(l.dataset.speed);t.indexOf(_),h.textContent=j(_),ee(_),m.classList.remove("hfp-open"),h.setAttribute("aria-expanded","false"),i.onSpeedChange(_)});const te=()=>{m.classList.remove("hfp-open"),h.setAttribute("aria-expanded","false")};document.addEventListener("click",te);const P=a=>{const l=o.getBoundingClientRect(),_=Math.max(0,Math.min(1,(a-l.left)/l.width));i.onSeek(_)};let A=!1;o.addEventListener("mousedown",a=>{var l;a.stopPropagation(),A=!0,(l=i.onScrubStart)==null||l.call(i),P(a.clientX)});const ie=a=>{A&&P(a.clientX)},re=()=>{var a;A&&(A=!1,(a=i.onScrubEnd)==null||a.call(i))};document.addEventListener("mousemove",ie),document.addEventListener("mouseup",re),o.addEventListener("touchstart",a=>{var _;A=!0,(_=i.onScrubStart)==null||_.call(i);const l=a.touches[0];l&&P(l.clientX)},{passive:!0});const ne=a=>{if(A){const l=a.touches[0];l&&P(l.clientX)}},se=()=>{var a;A&&(A=!1,(a=i.onScrubEnd)==null||a.call(i))};document.addEventListener("touchmove",ne,{passive:!0}),document.addEventListener("touchend",se);const oe=()=>{R&&clearTimeout(R),R=setTimeout(()=>{D&&r.classList.add("hfp-hidden")},3e3)},I=n instanceof ShadowRoot?n.host:n,ae=()=>{r.classList.remove("hfp-hidden"),oe()},de=()=>{D&&r.classList.add("hfp-hidden")};return I.addEventListener("mousemove",ae),I.addEventListener("mouseleave",de),{updateTime(a,l){const _=l>0?Math.min(a,l):a,ye=l>0?_/l*100:0;d.style.width=`${ye}%`,p.textContent=`${ce(_)} / ${ce(l)}`},updatePlaying(a){D=a,s.classList.toggle("hfp-playing",a),s.setAttribute("aria-label",a?"Pause":"Play"),a?oe():r.classList.remove("hfp-hidden")},updateSpeed(a){t.indexOf(a),h.textContent=j(a),ee(a)},updateMuted(a){C=a,g.innerHTML=L(a,E),g.setAttribute("aria-label",a?"Unmute":"Mute")},updateVolume(a){E=a,v.style.width=`${a*100}%`,f.setAttribute("aria-valuenow",String(Math.round(a*100))),g.innerHTML=L(C,a)},setVolumeControlsHidden(a){y.style.display=a?"none":""},show(){r.style.display=""},hide(){r.style.display="none"},destroy(){document.removeEventListener("mousemove",ie),document.removeEventListener("mouseup",re),document.removeEventListener("touchmove",ne),document.removeEventListener("touchend",se),document.removeEventListener("mousemove",Y),document.removeEventListener("mouseup",Z),document.removeEventListener("touchmove",Q),document.removeEventListener("touchend",J),document.removeEventListener("click",te),I.removeEventListener("mousemove",ae),I.removeEventListener("mouseleave",de),R&&clearTimeout(R),r.remove()}}}function Oe(n,i,e,t,r,s=!1){const o=t?t.split(",").map(Number).filter(c=>!isNaN(c)&&c>0):void 0,d={...o?{speedPresets:o}:{},audioLocked:s},p=Ie(n,r,d);return p.updateMuted(i),p.updateVolume(e),p}function pe(n,i,e){return i?(e||(e=document.createElement("img"),e.className="hfp-poster",n.appendChild(e)),e.src=i,e):(e==null||e.remove(),null)}function Ne(n){return n.composedPath().some(i=>i instanceof HTMLElement&&i.classList.contains("hfp-controls"))}let O=null;function Fe(n,i){if(typeof CSSStyleSheet<"u")try{O||(O=new CSSStyleSheet,O.replaceSync(i)),n.adoptedStyleSheets=[O];return}catch{}const e=document.createElement("style");e.textContent=i,n.appendChild(e)}function He(){const n=document.createElement("div");n.className="hfp-container";const i=document.createElement("iframe");return i.className="hfp-iframe",i.sandbox.add("allow-scripts","allow-same-origin"),i.allow="autoplay; fullscreen",i.referrerPolicy="no-referrer",i.title="HyperFrames Composition",n.appendChild(i),{container:n,iframe:i}}function Ue(n,i,e,t){const r=n.offsetWidth,s=n.offsetHeight;if(r===0||s===0)return!1;const o=Math.min(r/e,s/t);return i.style.width=`${e}px`,i.style.height=`${t}px`,i.style.transform=`translate(-50%, -50%) scale(${o})`,!0}const Ve=100;class $e{constructor(i){u(this,"_raf",null);u(this,"_lastUpdateMs",0);this._callbacks=i}start(i,e,t,r){this.stop();const s=()=>{if(r()){this._raf=null;return}let o;try{o=i.time()}catch{this._raf=null;return}const d=t();d>0&&(o=Math.min(o,d));const p=d>0&&o>=d,c=performance.now();if((c-this._lastUpdateMs>Ve||p)&&(this._lastUpdateMs=c,this._callbacks.onTimeUpdate(o,d)),p){if(this._callbacks.getLoop()){this._callbacks.restart();return}try{i.pause()}catch{}this._callbacks.onPaused(),this._raf=null;return}this._raf=requestAnimationFrame(s)};this._raf=requestAnimationFrame(s)}stop(){this._raf!==null&&(cancelAnimationFrame(this._raf),this._raf=null)}get isRunning(){return this._raf!==null}}function je(n){const i=Array.from(n.querySelectorAll("[data-composition-id]"));if(i.length===0)return n.body?[n.body]:[];const e=[];for(const t of i)Be(t)||e.push(t);return ze(n),e}function ze(n){const i=n.body;if(!i||typeof console>"u"||typeof console.warn!="function")return;const e=i.querySelectorAll("audio[data-start], video[data-start]");if(e.length===0)return;const t=[];for(const r of e)r.closest("[data-composition-id]")||t.push(r);t.length!==0&&console.warn(`[hyperframes-player] selectMediaObserverTargets: composition hosts are present, but ${t.length} body-level timed media element(s) sit outside every [data-composition-id] subtree and will not be observed. Move them inside a composition host or the parent-frame proxy will never adopt them.`,t)}function Be(n){let i=n.parentElement;for(;i;){if(i.hasAttribute("data-composition-id"))return!0;i=i.parentElement}return!1}function W(n){var e;const i=(e=n.ownerDocument)==null?void 0:e.defaultView;return i&&n instanceof i.Element?!0:n instanceof Element}function w(n){var e;if(!W(n)||n.tagName!=="AUDIO"&&n.tagName!=="VIDEO")return!1;const i=(e=n.ownerDocument)==null?void 0:e.defaultView;return i&&n instanceof i.HTMLMediaElement?!0:n instanceof HTMLMediaElement}const qe=.05,We=2;class Ge{constructor(i){u(this,"_entries",[]);u(this,"_mediaObserver");u(this,"_playbackErrorPosted",!1);u(this,"_audioOwner","runtime");u(this,"_urlAudioEntry",null);u(this,"_urlAudioSrc",null);u(this,"_dispatchEvent");u(this,"_getMuted");u(this,"_getVolume");u(this,"_getPlaybackRate");u(this,"_getCurrentTime");u(this,"_isPaused");this._dispatchEvent=i.dispatchEvent,this._getMuted=i.getMuted,this._getVolume=i.getVolume,this._getPlaybackRate=i.getPlaybackRate,this._getCurrentTime=i.getCurrentTime,this._isPaused=i.isPaused}get audioOwner(){return this._audioOwner}get entries(){return this._entries}resetForIframeLoad(){this._playbackErrorPosted=!1;const i=this._audioOwner==="parent";this._audioOwner="runtime",this.pauseAll(),this.teardownObserver(),i&&this._dispatchEvent(new CustomEvent("audioownershipchange",{detail:{owner:"runtime",reason:"iframe-reload"}}))}destroy(){this.teardownObserver();for(const i of this._entries)i.el.pause(),i.el.src="";this._entries=[],this._urlAudioEntry=null,this._urlAudioSrc=null,this._audioOwner="runtime",this._playbackErrorPosted=!1}updateMuted(i){for(const e of this._entries)e.el.muted=i}updateVolume(i){for(const e of this._entries)e.el.volume=i}updatePlaybackRate(i){for(const e of this._entries)e.el.playbackRate=i}_playEntry(i){i.el.src&&i.el.play().catch(e=>this._reportPlaybackError(e))}_playEntryIfActive(i){this._refreshEntryBounds(i);const e=this._getCurrentTime()-i.start;e<0||e>=i.duration||this._playEntry(i)}_refreshEntryBounds(i){var t;if(!((t=i.source)!=null&&t.isConnected))return;const e=le(i.source);i.start=e.start??0,i.duration=e.duration!=null&&e.duration>0?e.duration:Number.POSITIVE_INFINITY}_gateEntryPlayback(i,e){return e<0||e>=i.duration?(i.el.paused||i.el.pause(),i.driftSamples=0,!1):(this._audioOwner==="parent"&&!this._isPaused()&&i.el.paused&&this._playEntry(i),!0)}playAll(){for(const i of this._entries)this._playEntryIfActive(i)}pauseAll(){for(const i of this._entries)i.el.pause()}stopAdoptedMedia(){for(const i of this._entries)i.source&&i.el.pause()}seekAll(i){for(const e of this._entries){this._refreshEntryBounds(e);const t=i-e.start;t>=0&&t<e.duration&&(e.el.currentTime=t)}}scrubAll(i){for(const e of this._entries){this._refreshEntryBounds(e);const t=i-e.start;t>=0&&t<e.duration?(e.el.currentTime=t,this._playEntry(e)):e.el.paused||e.el.pause()}}mirrorTime(i,e){const t=(e==null?void 0:e.force)===!0;for(const r of this._entries){this._refreshEntryBounds(r);const s=i-r.start;this._gateEntryPlayback(r,s)&&(Math.abs(r.el.currentTime-s)>qe?(r.driftSamples+=1,(t||r.driftSamples>=We)&&(r.el.currentTime=s,r.driftSamples=0)):r.driftSamples=0)}}promoteToParentProxy(i,e){if(this._audioOwner==="parent")return;if(this._audioOwner="parent",i)for(const r of i.querySelectorAll("video, audio"))w(r)&&(r.muted=!0);const t=this._getCurrentTime();e?e(t,{force:!0}):this.mirrorTime(t,{force:!0}),this._isPaused()||this.playAll(),this._dispatchEvent(new CustomEvent("audioownershipchange",{detail:{owner:"parent",reason:"autoplay-blocked"}}))}setupFromIframe(i){const e=i.querySelectorAll("audio[data-start], video[data-start]");for(const t of e)w(t)&&this._adoptIframeMedia(t);this._observeDynamicMedia(i)}setupFromUrl(i){if(this._urlAudioSrc===i&&this._urlAudioEntry)return;this.teardownUrlAudio();const e=this._createEntry(i,"audio",0,1/0);this._urlAudioEntry=e,this._urlAudioSrc=e?i:null,e&&this._audioOwner==="parent"&&!this._isPaused()&&(this.mirrorTime(this._getCurrentTime(),{force:!0}),this.playAll())}teardownUrlAudio(){const i=this._urlAudioEntry;if(this._urlAudioEntry=null,this._urlAudioSrc=null,!i)return;i.el.pause(),i.el.src="";const e=this._entries.indexOf(i);e!==-1&&this._entries.splice(e,1)}teardownObserver(){var i;(i=this._mediaObserver)==null||i.disconnect(),this._mediaObserver=void 0}_reportPlaybackError(i){this._playbackErrorPosted||(this._playbackErrorPosted=!0,this._dispatchEvent(new CustomEvent("playbackerror",{detail:{source:"parent-proxy",error:i}})))}_createEntry(i,e,t,r,s){if(this._entries.some(c=>c.el.src===i))return null;const o=e==="video"?document.createElement("video"):new Audio;o.preload="auto",o.src=i,o.load(),o.muted=this._getMuted(),o.volume=this._getVolume();const d=this._getPlaybackRate();d!==1&&(o.playbackRate=d);const p={el:o,start:t,duration:r,driftSamples:0,source:s};return this._entries.push(p),p}_resolveIframeMediaSrc(i){var t;const e=i.getAttribute("src")||((t=i.querySelector("source"))==null?void 0:t.getAttribute("src"));return e?new URL(e,i.ownerDocument.baseURI).href:null}_adoptIframeMedia(i){if(i.preload==="metadata"||i.preload==="none")return;const e=this._resolveIframeMediaSrc(i);if(!e)return;const t=le(i),r=t.start??0,s=t.duration??Number.POSITIVE_INFINITY,o=i.tagName==="VIDEO"?"video":"audio",d=this._createEntry(e,o,r,s,i);d&&this._audioOwner==="parent"&&(this.mirrorTime(this._getCurrentTime(),{force:!0}),this._isPaused()||this._playEntryIfActive(d))}_detachIframeMedia(i){const e=this._resolveIframeMediaSrc(i);if(!e)return;const t=this._entries.findIndex(s=>s.el.src===e);if(t===-1)return;const r=this._entries[t];r.el.pause(),r.el.src="",this._entries.splice(t,1)}_observeDynamicMedia(i){if(this.teardownObserver(),typeof MutationObserver>"u"||!i.body)return;const e=new MutationObserver(s=>{for(const o of s){if(o.type==="attributes"&&o.attributeName==="preload"){const d=o.target;w(d)&&d.matches("audio[data-start], video[data-start]")&&d.preload==="auto"&&this._adoptIframeMedia(d);continue}for(const d of o.addedNodes){if(!W(d))continue;const p=[];w(d)&&d.matches("audio[data-start], video[data-start]")&&p.push(d);const c=d.querySelectorAll("audio[data-start], video[data-start]");for(const h of c)w(h)&&p.push(h);for(const h of p)this._adoptIframeMedia(h)}for(const d of o.removedNodes){if(!W(d))continue;const p=[];w(d)&&d.matches("audio[data-start], video[data-start]")&&p.push(d);const c=d.querySelectorAll("audio[data-start], video[data-start]");for(const h of c)w(h)&&p.push(h);for(const h of p)this._detachIframeMedia(h)}}}),t={childList:!0,subtree:!0,attributes:!0,attributeFilter:["preload"]},r=je(i);for(const s of r)e.observe(s,t);this._mediaObserver=e}}const Xe=100;function Ye(n,i,e,t){const r=(n.frame??0)/i,s=e.duration>0?Math.min(r,e.duration):r,o=!e.paused,d=!n.isPlaying,p=e.duration>0&&s>=e.duration&&(o||n.isPlaying);if(p&&t.getLoop())return t.media.audioOwner==="parent"&&t.media.pauseAll(),t.seek(0),t.play(),{...e,currentTime:s,paused:!1};const c={...e,currentTime:s,paused:d};t.media.audioOwner==="parent"&&(o&&d?t.media.pauseAll():!o&&!d&&t.media.playAll(),t.media.mirrorTime(s));const h=performance.now(),m=d!==e.paused;return(h-e.lastUpdateMs>Xe||m)&&(c.lastUpdateMs=h,t.updateControlsTime(s,e.duration),t.updateControlsPlaying(!d),t.dispatchEvent(new CustomEvent("timeupdate",{detail:{currentTime:s}}))),p&&(t.media.audioOwner==="parent"&&t.media.pauseAll(),c.paused=!0,t.updateControlsPlaying(!1),t.dispatchEvent(new Event("ended"))),c}function Ze(n){return Array.isArray(n)?n.filter(i=>typeof i=="object"&&i!==null&&typeof i.id=="string"&&typeof i.start=="number"&&typeof i.duration=="number"):[]}function Qe(n,i,e){var s,o,d,p;if(n.source!==i)return;const t=n.data;if(!t||t.source!=="hf-preview")return;const r=we(t);if(r.status==="unsupported"){e.dispatchEvent(new CustomEvent("runtimeprotocolerror",{detail:{code:r.code,receivedVersion:r.receivedVersion}}));return}if((s=e.setRuntimeFps)==null||s.call(e,r.fps),t.type==="shader-transition-state"){const c=t.state&&typeof t.state=="object"?t.state:{};e.shaderLoader.update(c,e.getShaderLoadingMode()),e.dispatchEvent(new CustomEvent("shadertransitionstate",{detail:{compositionId:t.compositionId,state:c}}));return}if(t.type==="ready"){e.onRuntimeReady();return}if(t.type==="runtime-data-error"){(o=e.onRuntimeDataError)==null||o.call(e,t.channel,t.requestId,t.message);return}if(t.type==="runtime-data-applied"){(d=e.onRuntimeDataApplied)==null||d.call(e,t.channel,t.requestId);return}if(t.type==="state"){e.setPlaybackState(Ye({frame:t.frame??0,isPlaying:!!t.isPlaying},r.fps,e.getPlaybackState(),e));return}if(t.type==="media-autoplay-blocked"){if(((p=e.shouldPromoteMediaAutoplayFallback)==null?void 0:p.call(e))===!1)return;let c=null;try{c=e.getIframeDoc()}catch{}e.media.promoteToParentProxy(c,(h,m)=>e.media.mirrorTime(h,m)),e.sendControl("set-media-output-muted",{muted:!0});return}if(t.type==="timeline"&&t.durationInFrames>0){const c=Number(t.durationSeconds),h=Number(t.durationInFrames),m=Number.isFinite(c)&&c>0?c:h/r.fps;if(Number.isFinite(m)&&m>0){const y=e.getPlaybackState();e.setPlaybackState({...y,duration:m}),e.updateControlsTime(y.currentTime,m),e.onRuntimeTimelineReady(m)}Number.isFinite(t.compositionWidth)&&t.compositionWidth>0&&Number.isFinite(t.compositionHeight)&&t.compositionHeight>0&&e.setCompositionSize(t.compositionWidth,t.compositionHeight),e.setScenes(Ze(t.scenes));return}t.type==="stage-size"&&Number.isFinite(t.width)&&t.width>0&&Number.isFinite(t.height)&&t.height>0&&e.setCompositionSize(t.width,t.height)}function Je(n,i){return n.includes(i)?!0:/hyperframe\.runtime\.iife\.js|__hyperframes\s*=/.test(n)}const Ke=new Set([">"," "," ",`
460
+ `,"\r","\f"]);function z(n,i){const e=n.toLowerCase(),t=`<${i}`;let r=0;for(;r<e.length;){const s=e.indexOf(t,r);if(s<0)return null;const o=e[s+t.length];if(Ke.has(o)){const d=e.indexOf(">",s+t.length);return d<0?null:{index:s,end:d+1}}r=s+t.length}return null}function et(n,i){if(!n||Je(n,i))return n;const e=`<script src="${i}"><\/script>`,t=z(n,"head");if(t)return n.slice(0,t.end)+e+n.slice(t.end);const r=z(n,"body");if(r)return n.slice(0,r.index)+e+n.slice(r.index);const s=z(n,"html");return s?n.slice(0,s.end)+e+n.slice(s.end):e+n}const S="shader-capture-scale",x="shader-loading",G="runtime-src",me="__hf_shader_capture_scale",fe="__hf_shader_loading",U=["Preparing scene transitions","Sampling outgoing scene motion","Sampling incoming scene motion","Caching transition frames","Finalizing transition preview"];function X(n){if(n===null)return null;const i=Number(n);return!Number.isFinite(i)||i<=0?null:String(Math.min(1,Math.max(.25,i)))}function tt(n){if(n===null||n.trim()==="")return"composition";const i=n.trim().toLowerCase();return i==="none"||i==="false"||i==="0"||i==="off"?"none":i==="player"||i==="true"||i==="1"||i==="on"?"player":"composition"}function _e(n,i){return n.filter(e=>e!==""&&e.split("=")[0]!==i)}function it(n,i,e){const t=n.indexOf("#"),r=t>=0?n.slice(0,t):n,s=t>=0?n.slice(t):"",o=r.indexOf("?"),d=o>=0?r.slice(0,o):r,p=o>=0?r.slice(o+1):"";let c=_e(p.split("&"),me);c=_e(c,fe),i!==null&&c.push(`${me}=${encodeURIComponent(i)}`),e!=="composition"&&c.push(`${fe}=${encodeURIComponent(e)}`);const h=c.join("&");return`${d}${h?`?${h}`:""}${s}`}function rt(n,i,e){if(i===null&&e==="composition")return n;const t=[];i!==null&&t.push(`window.__HF_SHADER_CAPTURE_SCALE=${JSON.stringify(i)};`),e!=="composition"&&t.push(`window.__HF_SHADER_LOADING=${JSON.stringify(e)};`);const r=`<script data-hyperframes-player-shader-options>${t.join("")}<\/script>`;return/<head\b[^>]*>/i.test(n)?n.replace(/<head\b[^>]*>/i,s=>`${s}${r}`):/<html\b[^>]*>/i.test(n)?n.replace(/<html\b[^>]*>/i,s=>`${s}${r}`):`${r}${n}`}function M(n){return tt(n.getAttribute(x))}function nt(n){return Number(X(n.getAttribute(S))??"1")}function N(n,i){return it(i,X(n.getAttribute(S)),M(n))}function F(n,i){return et(rt(i,X(n.getAttribute(S)),M(n)),st(n))}function st(n){var e;const i=(e=n.getAttribute(G))==null?void 0:e.trim();if(!i)return H;try{const t=new URL(i,document.baseURI),r=t.protocol==="http:"||t.protocol==="https:",s=t.hostname==="127.0.0.1"||t.hostname==="localhost"||t.hostname==="[::1]";return r&&(s||t.origin===location.origin)?t.href:H}catch{return H}}function ot(){const n=document.createElement("div");n.className="hfp-shader-loader",n.setAttribute("role","status"),n.setAttribute("aria-live","polite"),n.setAttribute("aria-label","Preparing scene transitions"),n.setAttribute("data-hyperframes-ignore",""),n.draggable=!1;const i=g=>{g.preventDefault(),g.stopPropagation()};for(const g of["selectstart","dragstart","pointerdown","mousedown","click","dblclick","contextmenu","touchstart"])n.addEventListener(g,i,{capture:!0});const e=document.createElement("div");e.className="hfp-shader-loader-panel",e.draggable=!1;const t=document.createElement("div");t.className="hfp-shader-loader-mark",t.draggable=!1,t.innerHTML=['<svg width="78" height="78" viewBox="0 0 100 100" fill="none" aria-hidden="true" draggable="false">','<path d="M10.1851 57.8021L33.1145 73.8313C36.2202 75.9978 41.5173 73.5433 42.4816 69.4984L51.7611 30.4271C52.7253 26.3822 48.5802 23.9277 44.4602 26.0942L13.917 42.1235C6.96677 45.7676 4.97564 54.1579 10.1851 57.8021Z" fill="url(#hfp-shader-loader-grad-left)"/>','<path d="M87.5129 57.5141L56.9696 73.5433C52.8371 75.7098 48.7046 73.2553 49.6688 69.2104L58.9483 30.1391C59.9125 26.0942 65.2097 23.6397 68.3154 25.8062L91.2447 41.8354C96.4668 45.4796 94.4631 53.8699 87.5129 57.5141Z" fill="url(#hfp-shader-loader-grad-right)"/>',"<defs>",'<linearGradient id="hfp-shader-loader-grad-left" x1="48.5676" y1="25" x2="44.7804" y2="71.9384" gradientUnits="userSpaceOnUse">','<stop stop-color="#06E3FA"/>','<stop offset="1" stop-color="#4FDB5E"/>',"</linearGradient>",'<linearGradient id="hfp-shader-loader-grad-right" x1="54.8282" y1="73.8392" x2="72.0989" y2="32.8932" gradientUnits="userSpaceOnUse">','<stop stop-color="#06E3FA"/>','<stop offset="1" stop-color="#4FDB5E"/>',"</linearGradient>","</defs>","</svg>"].join("");const r=document.createElement("div");r.className="hfp-shader-loader-title";const s=document.createElement("span");s.className="hfp-shader-loader-title-text",s.textContent=U[0],r.appendChild(s);const o=document.createElement("div");o.className="hfp-shader-loader-detail",o.textContent="Rendering animated scene samples for shader transitions.";const d=document.createElement("div");d.className="hfp-shader-loader-track",d.setAttribute("aria-hidden","true");const p=document.createElement("div");p.className="hfp-shader-loader-fill",d.appendChild(p);const c=document.createElement("div");c.className="hfp-shader-loader-progress";const h=g=>{const b=document.createElement("div");b.className="hfp-shader-loader-row";const f=document.createElement("span");f.className="hfp-shader-loader-label",f.textContent=g;const v=document.createElement("span");return v.className="hfp-shader-loader-value",b.appendChild(f),b.appendChild(v),c.appendChild(b),{row:b,label:f,value:v}},m=h("transition"),y=h("transition frame");return e.appendChild(t),e.appendChild(r),e.appendChild(o),e.appendChild(d),e.appendChild(c),n.appendChild(e),{root:n,fill:p,title:s,detail:o,transitionValue:m.value,frameLabel:y.label,frameValue:y.value,frameRow:y.row}}const at=420;class dt{constructor(i){u(this,"_el");u(this,"_hideTimeout",null);this._el=i}show(){this._hideTimeout&&(clearTimeout(this._hideTimeout),this._hideTimeout=null),this._el.root.classList.remove("hfp-hiding"),this._el.root.classList.add("hfp-visible")}hide(){if(this._el.root.classList.contains("hfp-hiding")){this._hideTimeout||this._scheduleCleanup();return}this._el.root.classList.contains("hfp-visible")&&(this._el.root.classList.add("hfp-hiding"),this._el.root.classList.remove("hfp-visible"),this._scheduleCleanup())}reset(){this._hideTimeout&&(clearTimeout(this._hideTimeout),this._hideTimeout=null),this._el.root.classList.remove("hfp-visible","hfp-hiding"),this._el.fill.style.transform="scaleX(0)",this._el.transitionValue.textContent="",this._el.frameValue.textContent="",this._el.frameRow.style.visibility="hidden"}update(i,e){if(e!=="player"){this.reset();return}if(i.ready||!i.loading){this.hide();return}const t=typeof i.progress=="number"&&Number.isFinite(i.progress)?i.progress:0,r=typeof i.total=="number"&&Number.isFinite(i.total)?i.total:0,s=r>0?Math.min(1,Math.max(0,t/r)):0,o=Math.min(U.length-1,Math.floor(s*U.length));this._el.title.textContent=U[o]||"Preparing scene transitions",this._el.detail.textContent=i.phase==="cached"?"Loading cached transition frames before playback.":i.phase==="finalizing"?"Uploading transition textures for smooth playback.":"Rendering animated scene samples for shader transitions.",this._el.fill.style.transform=`scaleX(${s})`,this._el.transitionValue.textContent=i.currentTransition!==void 0&&i.transitionTotal!==void 0?`${i.currentTransition}/${i.transitionTotal}`:r>0?`${t}/${r}`:"";const d=i.transitionFrame!==void 0&&i.transitionFrames!==void 0?`${i.transitionFrame}/${i.transitionFrames}`:"";this._el.frameLabel.textContent=i.phase==="cached"?"cached transition frames":i.phase==="finalizing"?"finalizing transition frames":"rendering transition frames",this._el.frameValue.textContent=d,this._el.frameRow.style.visibility=d?"visible":"hidden",this._el.root.setAttribute("aria-valuenow",String(Math.round(s*100))),this.show()}get hideTimeout(){return this._hideTimeout}destroy(){this._hideTimeout&&(clearTimeout(this._hideTimeout),this._hideTimeout=null)}_scheduleCleanup(){this._hideTimeout&&clearTimeout(this._hideTimeout),this._hideTimeout=setTimeout(()=>{this._el.root.classList.remove("hfp-hiding"),this._hideTimeout=null},at)}}const lt=.1,ut=5,B="sandbox-origin",ge=1e4;function q(n){return!Number.isFinite(n)||n<=0?1:Math.max(lt,Math.min(ut,n))}class ht extends HTMLElement{constructor(){super();u(this,"shadow");u(this,"container");u(this,"iframe");u(this,"posterEl",null);u(this,"controlsApi",null);u(this,"resizeObserver");u(this,"shaderLoader");u(this,"probe");u(this,"_ready",!1);u(this,"_currentTime",0);u(this,"_duration",0);u(this,"_paused",!0);u(this,"_scrubbing",!1);u(this,"_lastUpdateMs",0);u(this,"_volume",1);u(this,"_compositionWidth",1920);u(this,"_compositionHeight",1080);u(this,"_rescaleWarned",!1);u(this,"_directTimelineAdapter",null);u(this,"_directTimelineClock");u(this,"_parentTickRaf",null);u(this,"_media");u(this,"_scenes",[]);u(this,"_runtimeFps",30);u(this,"_runtimeBridgeReady",!1);u(this,"_runtimeData",new Map);u(this,"_runtimeDataRequestId",0);u(this,"_pendingRuntimeData",new Map);this.shadow=this.attachShadow({mode:"open"}),Fe(this.shadow,Me),{container:this.container,iframe:this.iframe}=He(),this.shadow.appendChild(this.container);const e=ot();this.shadow.appendChild(e.root),this.shaderLoader=new dt(e),this._media=new Ge({dispatchEvent:t=>this.dispatchEvent(t),getMuted:()=>this.muted,getVolume:()=>this._volume,getPlaybackRate:()=>this.playbackRate,getCurrentTime:()=>this._currentTime,isPaused:()=>this._paused}),this._directTimelineClock=new $e({onTimeUpdate:(t,r)=>{var s;this._currentTime=t,(s=this.controlsApi)==null||s.updateTime(t,r),this.dispatchEvent(new CustomEvent("timeupdate",{detail:{currentTime:t}}))},getLoop:()=>this.loop,restart:()=>{this.seek(0),this.play()},onPaused:()=>{var t;this._media.audioOwner==="parent"&&this._media.pauseAll(),this._paused=!0,(t=this.controlsApi)==null||t.updatePlaying(!1),this.dispatchEvent(new Event("ended"))},onEnded:()=>this.loop}),this.probe=new xe(this.iframe,{onReady:t=>this._onProbeReady(t),onError:t=>this.dispatchEvent(new CustomEvent("error",{detail:{message:t}}))}),this.addEventListener("click",t=>{Ne(t)||(this._paused?this.play():this.pause())}),this.resizeObserver=new ResizeObserver(()=>this._rescale()),this._onMessage=this._onMessage.bind(this),this._onIframeLoad=this._onIframeLoad.bind(this)}static get observedAttributes(){return["src","srcdoc","width","height","controls","muted","audio-locked","volume","poster","playback-rate","audio-src",B,G,S,x]}connectedCallback(){this._applySandboxOriginPolicy(),this.resizeObserver.observe(this),window.addEventListener("message",this._onMessage),this.iframe.addEventListener("load",this._onIframeLoad),this.hasAttribute("controls")&&this._setupControls(),this.hasAttribute("poster")&&(this.posterEl=pe(this.shadow,this.getAttribute("poster"),this.posterEl)),this.hasAttribute("audio-src")&&this._media.setupFromUrl(this.getAttribute("audio-src")),this.hasAttribute("srcdoc")&&(this.iframe.srcdoc=F(this,this.getAttribute("srcdoc"))),this.hasAttribute("src")&&(this.iframe.src=N(this,this.getAttribute("src"))),!this.hasAttribute("audio-locked")&&this._isLockedHostEnvironment()&&this._applyAudioLock(!0)}disconnectedCallback(){var e;this._sendControl("pause"),this._stopIframeMedia(),this.resizeObserver.disconnect(),window.removeEventListener("message",this._onMessage),this.iframe.removeEventListener("load",this._onIframeLoad),this.probe.stop(),this._directTimelineClock.stop(),this._stopParentTickClock(),this._directTimelineAdapter=null,this.shaderLoader.destroy(),this._media.destroy(),(e=this.controlsApi)==null||e.destroy(),this.controlsApi=null,this._paused=!0,this._ready=!1,this._runtimeBridgeReady=!1,this._rejectAllRuntimeDataDeliveries("Player disconnected before runtime data was applied")}attributeChangedCallback(e,t,r){var s,o,d,p,c;switch(e){case"src":if(!this.isConnected)break;r&&(this._ready=!1,this._runtimeBridgeReady=!1,this._rejectAllRuntimeDataDeliveries("Composition navigated before runtime data was applied"),this.iframe.src=N(this,r));break;case"srcdoc":if(!this.isConnected)break;this._ready=!1,this._runtimeBridgeReady=!1,this._rejectAllRuntimeDataDeliveries("Composition navigated before runtime data was applied"),r!==null?this.iframe.srcdoc=F(this,r):this.iframe.removeAttribute("srcdoc");break;case B:this._applySandboxOriginPolicy(this.isConnected&&t!==r);break;case"width":this._compositionWidth=$(r)??1920,this._rescale();break;case"height":this._compositionHeight=$(r)??1080,this._rescale();break;case"controls":r!==null?this._setupControls():((s=this.controlsApi)==null||s.destroy(),this.controlsApi=null);break;case"poster":this.posterEl=pe(this.shadow,r,this.posterEl);break;case"playback-rate":{const h=q(parseFloat(r||"1"));this._media.updatePlaybackRate(h),this._sendControl("set-playback-rate",{playbackRate:h}),(d=(o=this._directTimelineAdapter)==null?void 0:o.timeScale)==null||d.call(o,h),(p=this.controlsApi)==null||p.updateSpeed(h),this.dispatchEvent(new Event("ratechange"));break}case"muted":this._handleMutedChange(r);break;case"audio-locked":this._applyAudioLock(r!==null);break;case"volume":{const h=Math.max(0,Math.min(1,parseFloat(r||"1")));this._volume=h,this._media.updateVolume(h),this._sendControl("set-volume",{volume:h}),(c=this.controlsApi)==null||c.updateVolume(h),this.dispatchEvent(new Event("volumechange"));break}case"audio-src":r?this._media.setupFromUrl(r):this._media.teardownUrlAudio();break;case S:case x:case G:if(!this.isConnected)break;this._reloadShaderOptions();break}}_applySandboxOriginPolicy(e=!1){this.hasAttribute(B)?this.iframe.sandbox.remove("allow-same-origin"):this.iframe.sandbox.add("allow-same-origin"),e&&this._reloadForSandboxOriginPolicy()}_reloadForSandboxOriginPolicy(){this._ready=!1,this._runtimeBridgeReady=!1,this._rejectAllRuntimeDataDeliveries("Sandbox policy changed before runtime data was applied");const e=this.getAttribute("srcdoc");if(e!==null){this.iframe.srcdoc=F(this,e);return}const t=this.getAttribute("src");this.iframe.src=t===null?"about:blank":N(this,t)}get iframeElement(){return this.iframe}get scenes(){return this._scenes}play(){var t,r;(t=this.posterEl)==null||t.remove(),this.posterEl=null,this._duration>0&&this._currentTime>=this._duration&&this.seek(0),this._paused=!1;const e=this._tryDirectTimelinePlay();e||(this._sendControl("play"),this._ready&&!this._directTimelineAdapter&&this._startParentTickClock()),this._media.audioOwner==="parent"&&this._media.playAll(),(r=this.controlsApi)==null||r.updatePlaying(!0),this.dispatchEvent(new Event("play")),e&&this._directTimelineAdapter&&this._directTimelineClock.start(this._directTimelineAdapter,()=>this._currentTime,()=>this._duration,()=>this._paused)}pause(){var e;this._tryDirectTimelinePause()||this._sendControl("pause"),this._directTimelineClock.stop(),this._stopParentTickClock(),this._media.audioOwner==="parent"&&this._media.pauseAll(),this._paused=!0,(e=this.controlsApi)==null||e.updatePlaying(!1),this.dispatchEvent(new Event("pause"))}stopMedia(){this._sendControl("stop-media"),this._stopIframeMedia(),this._media.stopAdoptedMedia()}seek(e){var t,r;!this._trySyncSeek(e)&&!this._tryDirectTimelineSeek(e)&&this._sendControl("seek",{timeSeconds:e,frame:Math.round(e*this._runtimeFps)}),this._directTimelineClock.stop(),this._stopParentTickClock(),this._currentTime=e,this._media.audioOwner==="parent"&&(this._scrubbing?this._media.scrubAll(e):(this._media.pauseAll(),this._media.seekAll(e))),this._paused=!0,(t=this.controlsApi)==null||t.updatePlaying(!1),(r=this.controlsApi)==null||r.updateTime(this._currentTime,this._duration)}setColorGrading(e,t){this._sendControl("set-color-grading",{target:e,grading:t})}clearColorGrading(e){this._sendControl("set-color-grading",{target:e,grading:null})}setColorGradingCompare(e,t){this._sendControl("set-color-grading-compare",{target:e,compare:t})}clearColorGradingCompare(e){this._sendControl("set-color-grading-compare",{target:e,compare:{enabled:!1}})}setRuntimeData(e,t){if(!/^[a-z][a-z0-9-]{0,63}$/.test(e))throw new Error(`Invalid HyperFrames runtime-data channel: ${e}`);if(typeof structuredClone!="function")throw new Error("HyperFrames runtime data requires structuredClone support; refusing an unverified payload");const r=structuredClone(t);this._runtimeData.set(e,r),this._deliverRuntimeData(e,r)}clearRuntimeData(e){if(!/^[a-z][a-z0-9-]{0,63}$/.test(e))throw new Error(`Invalid HyperFrames runtime-data channel: ${e}`);this._runtimeData.delete(e),this._deliverRuntimeDataClear(e)}get currentTime(){return this._currentTime}set currentTime(e){this.seek(e)}get duration(){return this._duration}get paused(){return this._paused}get ready(){return this._ready}get playbackRate(){return q(parseFloat(this.getAttribute("playback-rate")||"1"))}set playbackRate(e){this.setAttribute("playback-rate",String(q(e)))}get shaderCaptureScale(){return nt(this)}set shaderCaptureScale(e){this.setAttribute(S,String(e))}get shaderLoading(){return M(this)}set shaderLoading(e){e==="composition"?this.removeAttribute(x):this.setAttribute(x,e)}get muted(){return this.hasAttribute("muted")}set muted(e){e?this.setAttribute("muted",""):this.removeAttribute("muted")}get audioLocked(){return this.hasAttribute("audio-locked")}set audioLocked(e){e?this.setAttribute("audio-locked",""):this.removeAttribute("audio-locked")}_isLockedHostEnvironment(){if(typeof navigator>"u")return!1;const e=navigator.userAgent||"";return/\bClaude\/\d/.test(e)&&/\bElectron\b/.test(e)}_isAudioLocked(){return this.hasAttribute("audio-locked")||this._isLockedHostEnvironment()}_isSlideshowPlayer(){return this.closest("hyperframes-slideshow")!==null}_handleMutedChange(e){var t;if(e===null&&this._isAudioLocked()){this.setAttribute("muted","");return}this._media.updateMuted(e!==null),this._setIframeMediaMuted(e!==null),this._sendControl("set-muted",{muted:e!==null}),(t=this.controlsApi)==null||t.updateMuted(e!==null),this.dispatchEvent(new Event("volumechange"))}_applyAudioLock(e){var t;e&&(this.muted=!0),(t=this.controlsApi)==null||t.setVolumeControlsHidden(e)}get volume(){return this._volume}set volume(e){this.setAttribute("volume",String(Math.max(0,Math.min(1,e))))}get loop(){return this.hasAttribute("loop")}set loop(e){e?this.setAttribute("loop",""):this.removeAttribute("loop")}_sendControl(e,t={}){try{const r=this.iframe.contentWindow;return r?(r.postMessage({...t,source:"hf-parent",type:"control",action:e,...Ae(this._runtimeFps)},"*"),!0):((e==="set-runtime-data"||e==="clear-runtime-data")&&this._rejectRuntimeDataDelivery(t.channel,t.requestId,"Composition iframe is unavailable"),!1)}catch(r){return(e==="set-runtime-data"||e==="clear-runtime-data")&&this._rejectRuntimeDataDelivery(t.channel,t.requestId,r instanceof Error?r.message:String(r)),!1}}_deliverRuntimeData(e,t){if(!this.isConnected||!this._runtimeBridgeReady)return;const r=this._beginRuntimeDataDelivery(e);this._trySetRuntimeDataDirect(e,t,r)||this._sendControl("set-runtime-data",{channel:e,payload:t,requestId:r})}_deliverRuntimeDataClear(e){if(!this.isConnected||!this._runtimeBridgeReady)return;const t=this._beginRuntimeDataDelivery(e);this._tryClearRuntimeDataDirect(e,t)||this._sendControl("clear-runtime-data",{channel:e,requestId:t})}_trySetRuntimeDataDirect(e,t,r){var s;try{const o=(s=this.iframe.contentWindow)==null?void 0:s.__hyperframes;return typeof(o==null?void 0:o.setRuntimeData)!="function"?!1:(o.setRuntimeData(e,t,r),!0)}catch{return!1}}_tryClearRuntimeDataDirect(e,t){var r;try{const s=(r=this.iframe.contentWindow)==null?void 0:r.__hyperframes;return typeof(s==null?void 0:s.clearRuntimeData)!="function"?!1:(s.clearRuntimeData(e,t),!0)}catch{return!1}}_replayRuntimeData(){for(const[e,t]of this._runtimeData)this._deliverRuntimeData(e,t)}_beginRuntimeDataDelivery(e){const t=this._pendingRuntimeData.get(e);t&&window.clearTimeout(t.timeoutId),this._runtimeDataRequestId+=1;const r=this._runtimeDataRequestId,s=window.setTimeout(()=>{this._rejectRuntimeDataDelivery(e,r,`Runtime data delivery timed out after ${ge}ms`)},ge);return this._pendingRuntimeData.set(e,{requestId:r,timeoutId:s}),r}_resolveRuntimeDataDelivery(e,t){const r=this._takeRuntimeDataDelivery(e,t);r&&this.dispatchEvent(new CustomEvent("runtimedataapplied",{detail:{channel:e,requestId:r.requestId}}))}_rejectRuntimeDataDelivery(e,t,r){const s=this._takeRuntimeDataDelivery(e,t);s&&this.dispatchEvent(new CustomEvent("runtimedataerror",{detail:{channel:e,requestId:s.requestId,message:typeof r=="string"?r:String(r)}}))}_takeRuntimeDataDelivery(e,t){if(typeof e!="string"||typeof t!="number"||!Number.isSafeInteger(t))return null;const r=this._pendingRuntimeData.get(e);return!r||r.requestId!==t?null:(window.clearTimeout(r.timeoutId),this._pendingRuntimeData.delete(e),r)}_rejectAllRuntimeDataDeliveries(e){for(const[t,r]of[...this._pendingRuntimeData])this._rejectRuntimeDataDelivery(t,r.requestId,e)}_getSameOriginIframeDocument(){try{return this.iframe.contentDocument}catch{return null}}_setIframeMediaMuted(e){const t=this._getSameOriginIframeDocument();if(t)for(const r of t.querySelectorAll("video, audio"))w(r)&&(r.muted=e||r.defaultMuted)}_stopIframeMedia(){const e=this._getSameOriginIframeDocument();if(e)for(const t of e.querySelectorAll("video, audio"))w(t)&&t.pause()}_replayBridgeState(){this._sendControl("set-muted",{muted:this.muted}),this._sendControl("set-volume",{volume:this._volume}),this._sendControl("set-playback-rate",{playbackRate:this.playbackRate}),this._sendControl("set-native-media-sync-disabled",{disabled:this._isSlideshowPlayer()}),this._sendControl("set-web-audio-media-disabled",{disabled:this._isSlideshowPlayer()})}_reloadShaderOptions(){if(this._ready=!1,this._runtimeBridgeReady=!1,this._rejectAllRuntimeDataDeliveries("Shader options changed before runtime data was applied"),M(this)!=="player"&&this.shaderLoader.reset(),this.hasAttribute("srcdoc")){this.iframe.srcdoc=F(this,this.getAttribute("srcdoc")||"");return}this.hasAttribute("src")&&(this.iframe.src=N(this,this.getAttribute("src")||""))}_trySyncSeek(e){try{const t=this.iframe.contentWindow,r=t==null?void 0:t.__player;return typeof(r==null?void 0:r.seek)!="function"?!1:(r.seek.call(r,e),!0)}catch{return!1}}_withDirectTimeline(e){var s;const t=this.probe.resolveDirectTimelineAdapter(),r=t||this._directTimelineAdapter;if(!r)return!1;try{if(e(r),t&&t!==this._directTimelineAdapter){const o=t.duration();Number.isFinite(o)&&o>0&&(this._duration=o,(s=this.controlsApi)==null||s.updateTime(this._currentTime,o))}return this._directTimelineAdapter=r,!0}catch{return!1}}_tryDirectTimelineSeek(e){return this._withDirectTimeline(t=>{t.seek(e,!1),t.pause()})}_tryDirectTimelinePlay(){return this._withDirectTimeline(e=>void e.play())}_tryDirectTimelinePause(){return this._withDirectTimeline(e=>void e.pause())}_startParentTickClock(){this._stopParentTickClock();const e=()=>{if(this._paused){this._parentTickRaf=null;return}this._sendControl("tick"),this._parentTickRaf=requestAnimationFrame(e)};this._parentTickRaf=requestAnimationFrame(e)}_stopParentTickClock(){this._parentTickRaf!==null&&(cancelAnimationFrame(this._parentTickRaf),this._parentTickRaf=null)}_onMessage(e){Qe(e,this.iframe.contentWindow,{getPlaybackState:()=>({currentTime:this._currentTime,duration:this._duration,paused:this._paused,lastUpdateMs:this._lastUpdateMs}),setPlaybackState:({currentTime:t,duration:r,paused:s,lastUpdateMs:o})=>{this._currentTime=t,this._duration=r,this._paused=s,this._lastUpdateMs=o},getShaderLoadingMode:()=>M(this),shaderLoader:this.shaderLoader,setCompositionSize:(t,r)=>{this._compositionWidth=t,this._compositionHeight=r,this._rescale()},sendControl:(t,r)=>this._sendControl(t,r),getIframeDoc:()=>this.iframe.contentDocument,onRuntimeReady:()=>{this._runtimeBridgeReady=!0,this._replayBridgeState(),this._replayRuntimeData()},onRuntimeDataApplied:(t,r)=>this._resolveRuntimeDataDelivery(t,r),onRuntimeDataError:(t,r,s)=>this._rejectRuntimeDataDelivery(t,r,s),onRuntimeTimelineReady:t=>this._onRuntimeTimelineReady(t),setRuntimeFps:t=>{this._runtimeFps=t},shouldPromoteMediaAutoplayFallback:()=>!this._isSlideshowPlayer(),setScenes:t=>{this._scenes=t,this.dispatchEvent(new CustomEvent("scenes",{detail:{scenes:t}}))},updateControlsTime:(t,r)=>{var s;return(s=this.controlsApi)==null?void 0:s.updateTime(t,r)},updateControlsPlaying:t=>{var r;return(r=this.controlsApi)==null?void 0:r.updatePlaying(t)},dispatchEvent:t=>this.dispatchEvent(t),seek:t=>this.seek(t),play:()=>this.play(),getLoop:()=>this.loop,media:this._media})}_onRuntimeTimelineReady(e){var r;if(this._ready)return;this.probe.stop(),this._duration=e,this._directTimelineAdapter=null,this._ready=!0,(r=this.controlsApi)==null||r.updateTime(this._currentTime,e),this.dispatchEvent(new CustomEvent("ready",{detail:{duration:e}})),this._rescale();const t=this._getSameOriginIframeDocument();t&&this._media.setupFromIframe(t),this._replayBridgeState(),this._setIframeMediaMuted(this.muted),this.hasAttribute("autoplay")&&this.play()}_onProbeReady({duration:e,adapter:t,compositionSize:r}){var s;this._duration=e,this._directTimelineAdapter=t.kind==="direct-timeline"?t.timeline:null,this._ready=!0,(s=this.controlsApi)==null||s.updateTime(0,e),this.dispatchEvent(new CustomEvent("ready",{detail:{duration:e}})),r&&(this._compositionWidth=r.width,this._compositionHeight=r.height,this._rescale());try{const o=this.iframe.contentDocument;o&&this._media.setupFromIframe(o)}catch{}this._setIframeMediaMuted(this.muted),this.hasAttribute("autoplay")&&this.play()}_rescale(){!Ue(this,this.iframe,this._compositionWidth,this._compositionHeight)&&this._ready&&!this._rescaleWarned&&(this._rescaleWarned=!0,console.warn("[hyperframes-player] rescale no-op after ready — zero-size player element",{src:this.getAttribute("src"),offsetWidth:this.offsetWidth,offsetHeight:this.offsetHeight,compositionWidth:this._compositionWidth,compositionHeight:this._compositionHeight}))}_onIframeLoad(){this._ready=!1,this._directTimelineAdapter=null,this._directTimelineClock.stop(),this._stopParentTickClock(),this.shaderLoader.reset(),this._media.resetForIframeLoad(),this.probe.start()}_setupControls(){this.controlsApi||(this.controlsApi=Oe(this.shadow,this.muted,this._volume,this.getAttribute("speed-presets"),{onPlay:()=>this.play(),onPause:()=>this.pause(),onSeek:e=>this.seek(e*this._duration),onScrubStart:()=>{this._scrubbing=!0},onScrubEnd:()=>{this._scrubbing=!1,this.seek(this._currentTime)},onSpeedChange:e=>void(this.playbackRate=e),onMuteToggle:()=>void(this.muted=!this.muted),onVolumeChange:e=>void(this.volume=e)},this._isAudioLocked()))}get _audioOwner(){return this._media.audioOwner}get _parentMedia(){return this._media.entries}_mirrorParentMediaTime(e,t){this._media.mirrorTime(e,t)}_promoteToParentProxy(){let e=null;try{e=this.iframe.contentDocument}catch{}this._media.promoteToParentProxy(e,(t,r)=>this._mirrorParentMediaTime(t,r)),this._sendControl("set-media-output-muted",{muted:!0})}_observeDynamicMedia(e){this._media.setupFromIframe(e)}}customElements.get("hyperframes-player")||customElements.define("hyperframes-player",ht);export{ht as HyperframesPlayer,Pe as SPEED_PRESETS,j as formatSpeed,ce as formatTime};
@@ -1,4 +1,4 @@
1
- import{n as Qi}from"./index-CBSKXKAr.js";/*!
1
+ import{n as Qi}from"./index-CgGY8dAv.js";/*!
2
2
  * Copyright (c) 2026-present, Vanilagy and contributors
3
3
  *
4
4
  * This Source Code Form is subject to the terms of the Mozilla Public
@@ -1 +1 @@
1
- import{g as P}from"./index-CBSKXKAr.js";function j(c,d){for(var s=0;s<d.length;s++){const a=d[s];if(typeof a!="string"&&!Array.isArray(a)){for(const i in a)if(i!=="default"&&!(i in c)){const l=Object.getOwnPropertyDescriptor(a,i);l&&Object.defineProperty(c,i,l.get?l:{enumerable:!0,get:()=>a[i]})}}}return Object.freeze(Object.defineProperty(c,Symbol.toStringTag,{value:"Module"}))}var v={},w;function k(){if(w)return v;w=1,Object.defineProperty(v,"__esModule",{value:!0}),v.default=d;var c=window.OfflineAudioContext||window.webkitOfflineAudioContext;function d(e){var r=a(e);return r.start(0),[i,y,O(e.sampleRate),s].reduce(function(t,o){return o(t)},r.buffer.getChannelData(0))}function s(e){return e.sort(function(r,t){return t.count-r.count}).splice(0,5)[0].tempo}function a(e){var r=e.length,t=e.numberOfChannels,o=e.sampleRate,n=new c(t,r,o),u=n.createBufferSource();u.buffer=e;var f=n.createBiquadFilter();return f.type="lowpass",u.connect(f),f.connect(n.destination),u}function i(e){for(var r=[],t=.9,o=.3,n=15;r.length<n&&t>=o;)r=l(e,t),t-=.05;if(r.length<n)throw new Error("Could not find enough samples for a reliable detection.");return r}function l(e,r){for(var t=[],o=0,n=e.length;o<n;o+=1)e[o]>r&&(t.push(o),o+=1e4);return t}function y(e){var r=[];return e.forEach(function(t,o){for(var n=function(x){var g=e[o+x]-t,_=r.some(function(h){if(h.interval===g)return h.count+=1});_||r.push({interval:g,count:1})},u=0;u<10;u+=1)n(u)}),r}function O(e){return function(r){var t=[];return r.forEach(function(o){if(o.interval!==0){for(var n=60/(o.interval/e);n<90;)n*=2;for(;n>180;)n/=2;n=Math.round(n);var u=t.some(function(f){if(f.tempo===n)return f.count+=o.count});u||t.push({tempo:n,count:o.count})}}),t}}return v}var p,b;function q(){return b||(b=1,p=k().default),p}var m=q();const A=P(m),D=j({__proto__:null,default:A},[m]);export{D as i};
1
+ import{g as P}from"./index-CgGY8dAv.js";function j(c,d){for(var s=0;s<d.length;s++){const a=d[s];if(typeof a!="string"&&!Array.isArray(a)){for(const i in a)if(i!=="default"&&!(i in c)){const l=Object.getOwnPropertyDescriptor(a,i);l&&Object.defineProperty(c,i,l.get?l:{enumerable:!0,get:()=>a[i]})}}}return Object.freeze(Object.defineProperty(c,Symbol.toStringTag,{value:"Module"}))}var v={},w;function k(){if(w)return v;w=1,Object.defineProperty(v,"__esModule",{value:!0}),v.default=d;var c=window.OfflineAudioContext||window.webkitOfflineAudioContext;function d(e){var r=a(e);return r.start(0),[i,y,O(e.sampleRate),s].reduce(function(t,o){return o(t)},r.buffer.getChannelData(0))}function s(e){return e.sort(function(r,t){return t.count-r.count}).splice(0,5)[0].tempo}function a(e){var r=e.length,t=e.numberOfChannels,o=e.sampleRate,n=new c(t,r,o),u=n.createBufferSource();u.buffer=e;var f=n.createBiquadFilter();return f.type="lowpass",u.connect(f),f.connect(n.destination),u}function i(e){for(var r=[],t=.9,o=.3,n=15;r.length<n&&t>=o;)r=l(e,t),t-=.05;if(r.length<n)throw new Error("Could not find enough samples for a reliable detection.");return r}function l(e,r){for(var t=[],o=0,n=e.length;o<n;o+=1)e[o]>r&&(t.push(o),o+=1e4);return t}function y(e){var r=[];return e.forEach(function(t,o){for(var n=function(x){var g=e[o+x]-t,_=r.some(function(h){if(h.interval===g)return h.count+=1});_||r.push({interval:g,count:1})},u=0;u<10;u+=1)n(u)}),r}function O(e){return function(r){var t=[];return r.forEach(function(o){if(o.interval!==0){for(var n=60/(o.interval/e);n<90;)n*=2;for(;n>180;)n/=2;n=Math.round(n);var u=t.some(function(f){if(f.tempo===n)return f.count+=o.count});u||t.push({tempo:n,count:o.count})}}),t}}return v}var p,b;function q(){return b||(b=1,p=k().default),p}var m=q();const A=P(m),D=j({__proto__:null,default:A},[m]);export{D as i};