@hyperframes/studio 0.9.58 → 0.9.61
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.
- package/dist/assets/hyperframes-player-Cm0hYGm2.js +573 -0
- package/dist/assets/{index-D7ICtobF.js → index-BGrNWeLK.js} +199 -199
- package/dist/assets/{index-ww7-RmuM.js → index-REqr_dLu.js} +1 -1
- package/dist/assets/{pausedVideoDecoder-Dbe8Cmab.js → pausedVideoDecoder-DqLDSq8J.js} +1 -1
- package/dist/{chunk-5EEM5WO4.js → chunk-3KCEIESB.js} +1 -1
- package/dist/{chunk-G6FJSL7X.js → chunk-JTUKMELR.js} +34 -6
- package/dist/index.d.ts +29 -1
- package/dist/index.html +1 -1
- package/dist/index.js +734 -217
- package/dist/player.js +2 -2
- package/dist/ui.js +1 -1
- package/package.json +8 -8
- package/src/captions/components/CaptionOverlay.sealed.test.ts +273 -0
- package/src/captions/components/CaptionOverlay.tsx +112 -57
- package/src/captions/components/CaptionOverlayUtils.ts +319 -33
- package/src/captions/components/CaptionPropertyPanel.tsx +17 -0
- package/src/components/editor/LayersPanel.opaque.test.ts +2 -2
- package/src/components/editor/previewDrafts.test.ts +2 -2
- package/src/components/editor/previewGestureStartRead.test.ts +2 -2
- package/src/components/editor/previewLayers.test.ts +2 -2
- package/src/components/editor/previewOverlayRects.test.ts +2 -2
- package/src/components/editor/previewPointerTargets.test.ts +2 -2
- package/src/components/editor/previewSelection.test.ts +2 -2
- package/src/components/editor/useColorGradingController.sealed.test.ts +165 -0
- package/src/components/editor/useColorGradingController.ts +20 -1
- package/src/components/editor/useColorGradingPreviews.ts +127 -43
- package/src/components/nle/NLEPreview.test.ts +24 -0
- package/src/components/nle/NLEPreview.tsx +2 -6
- package/src/components/nle/previewStage.ts +11 -1
- package/src/components/panels/VariablesPanel.test.tsx +90 -1
- package/src/components/panels/VariablesPanel.tsx +41 -17
- package/src/components/panels/renderHandoff.test.ts +86 -0
- package/src/components/panels/renderHandoff.ts +28 -0
- package/src/components/ui/Menu.test.tsx +77 -0
- package/src/components/ui/Menu.tsx +47 -4
- package/src/components/ui/Popover.tsx +5 -2
- package/src/elementAnimations.test.ts +13 -0
- package/src/hooks/useCaptionDetection.ts +175 -54
- package/src/hooks/useMusicBeatAnalysis.test.tsx +131 -0
- package/src/hooks/useMusicBeatAnalysis.ts +51 -66
- package/src/hooks/usePersistentEditHistory.test.ts +84 -0
- package/src/hooks/usePersistentEditHistory.ts +36 -3
- package/src/hooks/useRenderClipContent.test.ts +21 -0
- package/src/hooks/useRenderClipContent.ts +3 -1
- package/src/index.ts +2 -0
- package/src/player/hooks/useShadowPreviewReload.ts +7 -0
- package/src/player/hooks/useTimelinePlayer.shadowReload.test.ts +20 -0
- package/src/player/lib/previewElements.test.ts +4 -0
- package/src/player/lib/previewElements.ts +1 -0
- package/src/sealedPreviewExports.test.ts +1 -0
- package/src/utils/gsapUndoRestore.sealed.test.ts +73 -0
- package/src/utils/gsapUndoRestore.ts +66 -0
- package/src/utils/studioPendingEdits.test.ts +20 -0
- package/src/utils/studioPendingEdits.ts +11 -4
- package/src/utils/timelineInspector.test.ts +49 -2
- package/src/utils/timelineInspector.ts +21 -2
- package/dist/assets/hyperframes-player-B78JDyI_.js +0 -565
|
@@ -1,565 +0,0 @@
|
|
|
1
|
-
var je=Object.defineProperty;var Be=(r,t,e)=>t in r?je(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var h=(r,t,e)=>Be(r,typeof t!="symbol"?t+"":t,e);import{S as qe,r as Ge,P as Ye,i as Xe,a as be,b as we,c as Ke,m as Ue,s as Ze,d as A,e as Ae,p as Je,f as Qe,g as et,h as tt,j as it,k as Se,F as Te}from"./index-D7ICtobF.js";function st(r){return r.hasRuntime||r.runtimeInjected?!1:!!(r.hasNestedCompositions||r.hasTimelines&&r.attempts>=5)}function F(r){return typeof r=="object"&&r!==null}function rt(r){return F(r)&&typeof r.getDuration=="function"}function nt(r){return F(r)&&typeof r.duration=="function"&&typeof r.time=="function"&&typeof r.seek=="function"&&typeof r.play=="function"&&typeof r.pause=="function"}function ot(r){if(!/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.test(r))throw new Error(`Invalid HyperFrames runtime version: ${r}`);return`https://cdn.jsdelivr.net/npm/@hyperframes/core@${r}/dist/hyperframe.runtime.iife.js`}const B=typeof __HYPERFRAMES_RUNTIME_CDN_URL__=="string"?__HYPERFRAMES_RUNTIME_CDN_URL__:ot("0.0.0-dev");function Y(r){if(r===null)return null;const t=Number.parseInt(r,10);return Number.isFinite(t)&&t>0?t:null}function at(r){const t=(r==null?void 0:r.querySelector("[data-composition-id][data-width][data-height]"))??(r==null?void 0:r.querySelector("[data-width][data-height]"));if(!t)return null;const e=Y(t.getAttribute("data-width")),i=Y(t.getAttribute("data-height"));return e!==null&&i!==null?{width:e,height:i}:null}function dt(r){return Array.isArray(r)?r.find(t=>typeof t=="string"&&t.trim()!==""&&t!=="[object Event]")??null:null}class ht{constructor(t,e){h(this,"_interval",null);h(this,"_runtimeInjected",!1);h(this,"_runtimeScript",null);h(this,"_failure",null);this._iframe=t,this._callbacks=e}get failed(){return this._failure!==null&&this._failure.document===this._iframe.contentDocument}get runtimeInjected(){return this._runtimeInjected}start(){this.stop(),this._failure=null,this._runtimeInjected=!1;let t=0;this._interval=setInterval(()=>{t++;let e=null;try{e=this._poll(t)}catch(i){i instanceof DOMException&&i.name==="SecurityError"||(e={kind:"error",message:i instanceof Error?i.message:String(i)})}e??(e=this._deadlineOutcome(t)),e&&(this.stop(),e.kind==="error"?(this._failure={document:this._iframe.contentDocument},this._callbacks.onError(e.message)):this._callbacks.onReady(e.result))},200)}_deadlineOutcome(t){var e,i;return t<40||(i=(e=this._callbacks).hostOwnsDeadline)!=null&&i.call(e)?null:{kind:"error",message:"Composition timeline not found after 8s"}}_poll(t){const e=this._iframe.contentWindow;if(!e)return null;const i=dt(Reflect.get(e,qe));if(i!==null)return{kind:"error",message:i};const s=this._iframe.contentDocument,n=Reflect.get(e,"__timelines"),o=this.hasRuntimeBridge(e);if(st({hasRuntime:o,hasTimelines:F(n)&&Object.keys(n).length>0,hasNestedCompositions:!!(s!=null&&s.querySelector("[data-composition-src]")),runtimeInjected:this._runtimeInjected,attempts:t}))return this._injectRuntime(),null;if(this._runtimeInjected&&!o)return null;const a=this._resolveReadyResult(e,s);return a?{kind:"ready",result:a}:null}_resolveReadyResult(t,e){var n;const i=this._resolvePlaybackDurationAdapter(t)??{kind:"document",getDuration:()=>0};let s=i.getDuration();if(!Number.isFinite(s)||s<=0){if(i.kind==="direct-timeline")return null;s=e?((n=Ge(e))==null?void 0:n.durationSeconds)??0:0}return s<=0?null:{duration:s,adapter:{...i,getDuration:()=>s},compositionSize:at(e)}}stop(){this._runtimeScript&&(this._runtimeScript.onerror=null,this._runtimeScript=null),this.failed||(this._failure=null),this._interval!==null&&(clearInterval(this._interval),this._interval=null)}resolveDirectTimelineAdapter(){try{const t=this._iframe.contentWindow;return t?this._resolveDirectTimelineAdapterFromWindow(t):null}catch{return null}}resolveDirectTimelineAdapterFromWindow(t){return this._resolveDirectTimelineAdapterFromWindow(t)}hasRuntimeBridge(t){return F(Reflect.get(t,"__player"))}_injectRuntime(){var t,e,i,s;this._runtimeInjected=!0;try{const n=this._iframe.contentDocument;if(!n)return;const o=n.createElement("script");o.src=((e=(t=this._callbacks).resolveRuntimeUrl)==null?void 0:e.call(t))??B,this._runtimeScript=o,o.onerror=()=>{this._runtimeScript!==o||this._iframe.contentDocument!==n||(this.stop(),this._failure={document:n},this._callbacks.onError("HyperFrames runtime failed to load from "+o.src))},(n.head||n.documentElement).appendChild(o),(s=(i=this._callbacks).onRuntimeInjected)==null||s.call(i)}catch{}}_resolveDirectTimelineAdapterFromWindow(t){var a,c;if(this.hasRuntimeBridge(t))return null;const e=Reflect.get(t,"__timelines");if(!F(e))return null;const i=Object.keys(e);if(i.length===0)return null;const s=(c=(a=this._iframe.contentDocument)==null?void 0:a.querySelector("[data-composition-id]"))==null?void 0:c.getAttribute("data-composition-id"),n=s&&s in e?s:i[i.length-1],o=e[n];return nt(o)?o:null}_resolvePlaybackDurationAdapter(t){const e=Reflect.get(t,"__player");if(rt(e))return{kind:"runtime",getDuration:()=>e.getDuration()};const i=this._resolveDirectTimelineAdapterFromWindow(t);return i?{kind:"direct-timeline",timeline:i,getDuration:()=>i.duration()}:null}}const lt=`
|
|
2
|
-
:host {
|
|
3
|
-
display: block;
|
|
4
|
-
position: relative;
|
|
5
|
-
overflow: hidden;
|
|
6
|
-
background: #000;
|
|
7
|
-
contain: layout style;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/* The only in-flow child: with no height set, the player takes the composition's shape. */
|
|
11
|
-
.hfp-sizer {
|
|
12
|
-
aspect-ratio: 16 / 9;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.hfp-container {
|
|
16
|
-
position: absolute;
|
|
17
|
-
inset: 0;
|
|
18
|
-
overflow: hidden;
|
|
19
|
-
pointer-events: none;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
.hfp-iframe {
|
|
24
|
-
position: absolute;
|
|
25
|
-
top: 50%;
|
|
26
|
-
left: 50%;
|
|
27
|
-
border: none;
|
|
28
|
-
pointer-events: none;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/* Opt-in: an interactive composition (e.g. a live slideshow/app with playable
|
|
32
|
-
media or controls): let pointer events reach the iframe content. */
|
|
33
|
-
:host([interactive]) .hfp-container,
|
|
34
|
-
:host([interactive]) .hfp-iframe {
|
|
35
|
-
pointer-events: auto;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
.hfp-video {
|
|
39
|
-
position: absolute;
|
|
40
|
-
inset: 0;
|
|
41
|
-
width: 100%;
|
|
42
|
-
height: 100%;
|
|
43
|
-
object-fit: contain;
|
|
44
|
-
pointer-events: none;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
.hfp-poster {
|
|
48
|
-
position: absolute;
|
|
49
|
-
inset: 0;
|
|
50
|
-
object-fit: contain;
|
|
51
|
-
z-index: 1;
|
|
52
|
-
pointer-events: none;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
.hfp-shader-loader {
|
|
56
|
-
position: absolute;
|
|
57
|
-
inset: 0;
|
|
58
|
-
z-index: 20;
|
|
59
|
-
display: grid;
|
|
60
|
-
place-items: center;
|
|
61
|
-
visibility: hidden;
|
|
62
|
-
opacity: 0;
|
|
63
|
-
pointer-events: none;
|
|
64
|
-
background: #030504;
|
|
65
|
-
color: #f4f7fb;
|
|
66
|
-
cursor: default;
|
|
67
|
-
user-select: none;
|
|
68
|
-
-webkit-user-select: none;
|
|
69
|
-
transition: opacity 420ms ease-out, visibility 420ms ease-out;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
.hfp-shader-loader.hfp-visible,
|
|
73
|
-
.hfp-shader-loader.hfp-hiding {
|
|
74
|
-
visibility: visible;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
.hfp-shader-loader.hfp-visible {
|
|
78
|
-
opacity: 1;
|
|
79
|
-
pointer-events: auto;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
.hfp-shader-loader.hfp-hiding {
|
|
83
|
-
opacity: 0;
|
|
84
|
-
pointer-events: none;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
.hfp-shader-loader-panel {
|
|
88
|
-
display: grid;
|
|
89
|
-
grid-template-rows: 86px 40px 26px 12px 44px;
|
|
90
|
-
justify-items: center;
|
|
91
|
-
align-items: center;
|
|
92
|
-
gap: 8px;
|
|
93
|
-
width: min(620px, 82%);
|
|
94
|
-
text-align: center;
|
|
95
|
-
font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
.hfp-shader-loader-mark {
|
|
99
|
-
width: 86px;
|
|
100
|
-
height: 86px;
|
|
101
|
-
display: grid;
|
|
102
|
-
place-items: center;
|
|
103
|
-
overflow: visible;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
.hfp-shader-loader-mark svg {
|
|
107
|
-
display: block;
|
|
108
|
-
overflow: visible;
|
|
109
|
-
filter: drop-shadow(0 0 5px rgba(79, 219, 94, 0.16));
|
|
110
|
-
pointer-events: none;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
.hfp-shader-loader-title {
|
|
114
|
-
width: 100%;
|
|
115
|
-
height: 40px;
|
|
116
|
-
overflow: hidden;
|
|
117
|
-
white-space: nowrap;
|
|
118
|
-
text-overflow: ellipsis;
|
|
119
|
-
font-size: 26px;
|
|
120
|
-
line-height: 40px;
|
|
121
|
-
font-weight: 700;
|
|
122
|
-
letter-spacing: 0;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
.hfp-shader-loader-title-text {
|
|
126
|
-
color: transparent;
|
|
127
|
-
background: linear-gradient(
|
|
128
|
-
90deg,
|
|
129
|
-
rgba(244, 247, 251, 0.84) 0%,
|
|
130
|
-
#ffffff 42%,
|
|
131
|
-
#80efe4 52%,
|
|
132
|
-
#ffffff 62%,
|
|
133
|
-
rgba(244, 247, 251, 0.84) 100%
|
|
134
|
-
);
|
|
135
|
-
background-size: 220% 100%;
|
|
136
|
-
-webkit-background-clip: text;
|
|
137
|
-
background-clip: text;
|
|
138
|
-
animation: hfp-shader-loader-sheen 1.9s linear infinite;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
.hfp-shader-loader:not(.hfp-visible):not(.hfp-hiding) .hfp-shader-loader-title-text {
|
|
142
|
-
animation-play-state: paused;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
.hfp-shader-loader-detail {
|
|
146
|
-
width: 100%;
|
|
147
|
-
height: 26px;
|
|
148
|
-
overflow: hidden;
|
|
149
|
-
white-space: nowrap;
|
|
150
|
-
text-overflow: ellipsis;
|
|
151
|
-
color: rgba(244, 247, 251, 0.62);
|
|
152
|
-
font-size: 15px;
|
|
153
|
-
line-height: 26px;
|
|
154
|
-
font-weight: 500;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
.hfp-shader-loader-track {
|
|
158
|
-
width: min(360px, 100%);
|
|
159
|
-
height: 8px;
|
|
160
|
-
overflow: hidden;
|
|
161
|
-
border-radius: 999px;
|
|
162
|
-
background: rgba(255, 255, 255, 0.1);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
.hfp-shader-loader-fill {
|
|
166
|
-
width: 100%;
|
|
167
|
-
height: 100%;
|
|
168
|
-
border-radius: inherit;
|
|
169
|
-
background: linear-gradient(90deg, #06e3fa, #4fdb5e);
|
|
170
|
-
transform: scaleX(0);
|
|
171
|
-
transform-origin: left center;
|
|
172
|
-
transition: transform 160ms ease;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
.hfp-shader-loader-progress {
|
|
176
|
-
width: min(420px, 100%);
|
|
177
|
-
height: 44px;
|
|
178
|
-
display: grid;
|
|
179
|
-
grid-template-rows: repeat(2, 22px);
|
|
180
|
-
color: rgba(244, 247, 251, 0.48);
|
|
181
|
-
font: 600 13px/22px "IBM Plex Mono", "SF Mono", "Fira Code", "Courier New", monospace;
|
|
182
|
-
font-variant-numeric: tabular-nums;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
.hfp-shader-loader-row {
|
|
186
|
-
display: grid;
|
|
187
|
-
grid-template-columns: minmax(0, 1fr) 74px;
|
|
188
|
-
align-items: center;
|
|
189
|
-
column-gap: 20px;
|
|
190
|
-
width: 100%;
|
|
191
|
-
white-space: nowrap;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
.hfp-shader-loader-label {
|
|
195
|
-
min-width: 0;
|
|
196
|
-
overflow: hidden;
|
|
197
|
-
text-align: left;
|
|
198
|
-
text-overflow: ellipsis;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
.hfp-shader-loader-value {
|
|
202
|
-
text-align: right;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
/* Loading assets and Buffering: the frame softly blurred, the mark alone over it with a light
|
|
206
|
-
passing over. filter, transform and opacity only, no backdrop-filter, which drops frames on
|
|
207
|
-
Safari; the frame is still while it waits, so the blur is painted once. */
|
|
208
|
-
.hfp-iframe,
|
|
209
|
-
.hfp-poster {
|
|
210
|
-
transition: filter 400ms ease-out;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
:host([assets-loading]:not([assets-loading-ui="none"])) .hfp-iframe,
|
|
214
|
-
:host([assets-loading]:not([assets-loading-ui="none"])) .hfp-poster,
|
|
215
|
-
:host([buffering]:not([assets-loading-ui="none"])) .hfp-iframe,
|
|
216
|
-
:host([buffering]:not([assets-loading-ui="none"])) .hfp-poster {
|
|
217
|
-
filter: blur(6px) saturate(0.85);
|
|
218
|
-
transition-duration: 180ms;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
.hfp-shader-loader.hfp-assets {
|
|
222
|
-
background: transparent;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
.hfp-shader-loader.hfp-assets .hfp-shader-loader-panel {
|
|
226
|
-
grid-template-rows: auto;
|
|
227
|
-
width: auto;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
.hfp-shader-loader.hfp-assets .hfp-shader-loader-title,
|
|
231
|
-
.hfp-shader-loader.hfp-assets .hfp-shader-loader-detail,
|
|
232
|
-
.hfp-shader-loader.hfp-assets .hfp-shader-loader-track,
|
|
233
|
-
.hfp-shader-loader.hfp-assets .hfp-shader-loader-progress {
|
|
234
|
-
display: none;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
.hfp-shader-loader-mark {
|
|
238
|
-
position: relative;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
.hfp-shader-loader-sheen {
|
|
242
|
-
display: none;
|
|
243
|
-
position: absolute;
|
|
244
|
-
inset: 0;
|
|
245
|
-
overflow: hidden;
|
|
246
|
-
mask-size: contain;
|
|
247
|
-
mask-repeat: no-repeat;
|
|
248
|
-
mask-position: center;
|
|
249
|
-
-webkit-mask-size: contain;
|
|
250
|
-
-webkit-mask-repeat: no-repeat;
|
|
251
|
-
-webkit-mask-position: center;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
.hfp-shader-loader.hfp-assets .hfp-shader-loader-sheen {
|
|
255
|
-
display: block;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
.hfp-shader-loader-sheen::before {
|
|
259
|
-
content: "";
|
|
260
|
-
position: absolute;
|
|
261
|
-
inset: 0 auto 0 -60%;
|
|
262
|
-
width: 60%;
|
|
263
|
-
background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.85), transparent);
|
|
264
|
-
animation: hfp-shader-loader-sweep 1700ms cubic-bezier(0.4, 0, 0.2, 1) infinite;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
.hfp-shader-loader:not(.hfp-visible):not(.hfp-hiding) .hfp-shader-loader-sheen::before {
|
|
268
|
-
animation-play-state: paused;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
@keyframes hfp-shader-loader-sweep {
|
|
272
|
-
0% {
|
|
273
|
-
transform: translateX(0);
|
|
274
|
-
}
|
|
275
|
-
55%,
|
|
276
|
-
100% {
|
|
277
|
-
transform: translateX(280%);
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
@media (prefers-reduced-motion: reduce) {
|
|
282
|
-
.hfp-iframe,
|
|
283
|
-
.hfp-poster {
|
|
284
|
-
transition: none;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
.hfp-shader-loader-sheen::before {
|
|
288
|
-
animation: none;
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
@keyframes hfp-shader-loader-sheen {
|
|
293
|
-
from {
|
|
294
|
-
background-position: 140% 0;
|
|
295
|
-
}
|
|
296
|
-
to {
|
|
297
|
-
background-position: -140% 0;
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
/* ── Theming via CSS custom properties ──
|
|
302
|
-
*
|
|
303
|
-
* Override from outside the shadow DOM:
|
|
304
|
-
* hyperframes-player {
|
|
305
|
-
* --hfp-controls-bg: linear-gradient(transparent, rgba(0,0,0,0.9));
|
|
306
|
-
* --hfp-accent: #ff6b6b;
|
|
307
|
-
* --hfp-font: "Inter", sans-serif;
|
|
308
|
-
* }
|
|
309
|
-
*/
|
|
310
|
-
|
|
311
|
-
.hfp-controls {
|
|
312
|
-
position: absolute;
|
|
313
|
-
bottom: 0;
|
|
314
|
-
left: 0;
|
|
315
|
-
right: 0;
|
|
316
|
-
display: flex;
|
|
317
|
-
align-items: center;
|
|
318
|
-
gap: var(--hfp-controls-gap, 12px);
|
|
319
|
-
padding: var(--hfp-controls-padding, 8px 16px);
|
|
320
|
-
background: var(--hfp-controls-bg, linear-gradient(transparent, rgba(0, 0, 0, 0.7)));
|
|
321
|
-
color: var(--hfp-color, #fff);
|
|
322
|
-
font-family: var(--hfp-font, system-ui, -apple-system, sans-serif);
|
|
323
|
-
font-size: var(--hfp-font-size, 13px);
|
|
324
|
-
z-index: 10;
|
|
325
|
-
pointer-events: auto;
|
|
326
|
-
opacity: 1;
|
|
327
|
-
transition: opacity 0.3s ease;
|
|
328
|
-
user-select: none;
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
.hfp-controls.hfp-hidden {
|
|
332
|
-
opacity: 0;
|
|
333
|
-
pointer-events: none;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
.hfp-play-btn {
|
|
337
|
-
position: relative;
|
|
338
|
-
background: none;
|
|
339
|
-
border: none;
|
|
340
|
-
color: var(--hfp-color, #fff);
|
|
341
|
-
cursor: pointer;
|
|
342
|
-
padding: 8px;
|
|
343
|
-
display: flex;
|
|
344
|
-
align-items: center;
|
|
345
|
-
justify-content: center;
|
|
346
|
-
width: 40px;
|
|
347
|
-
height: 40px;
|
|
348
|
-
flex-shrink: 0;
|
|
349
|
-
z-index: 10;
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
.hfp-play-btn:hover {
|
|
353
|
-
opacity: 0.8;
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
/* Stacked play/pause glyphs that crossfade-morph on toggle (rotate + scale). */
|
|
357
|
-
.hfp-play-btn .hfp-ico {
|
|
358
|
-
position: absolute;
|
|
359
|
-
display: flex;
|
|
360
|
-
align-items: center;
|
|
361
|
-
justify-content: center;
|
|
362
|
-
transition:
|
|
363
|
-
opacity 200ms ease,
|
|
364
|
-
transform 220ms cubic-bezier(0.4, 0, 0.2, 1);
|
|
365
|
-
}
|
|
366
|
-
.hfp-play-btn .hfp-ico-play {
|
|
367
|
-
opacity: 1;
|
|
368
|
-
transform: rotate(0) scale(1);
|
|
369
|
-
}
|
|
370
|
-
.hfp-play-btn .hfp-ico-pause {
|
|
371
|
-
opacity: 0;
|
|
372
|
-
transform: rotate(-90deg) scale(0.4);
|
|
373
|
-
}
|
|
374
|
-
.hfp-play-btn.hfp-playing .hfp-ico-play {
|
|
375
|
-
opacity: 0;
|
|
376
|
-
transform: rotate(90deg) scale(0.4);
|
|
377
|
-
}
|
|
378
|
-
.hfp-play-btn.hfp-playing .hfp-ico-pause {
|
|
379
|
-
opacity: 1;
|
|
380
|
-
transform: rotate(0) scale(1);
|
|
381
|
-
}
|
|
382
|
-
@media (prefers-reduced-motion: reduce) {
|
|
383
|
-
.hfp-play-btn .hfp-ico {
|
|
384
|
-
transition-duration: 0ms;
|
|
385
|
-
transform: none;
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
.hfp-play-btn svg,
|
|
390
|
-
.hfp-play-btn svg * {
|
|
391
|
-
pointer-events: none;
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
.hfp-scrubber {
|
|
395
|
-
flex: 1;
|
|
396
|
-
min-width: 0;
|
|
397
|
-
height: var(--hfp-scrubber-height, 4px);
|
|
398
|
-
background: var(--hfp-scrubber-bg, rgba(255, 255, 255, 0.3));
|
|
399
|
-
border-radius: var(--hfp-scrubber-radius, 2px);
|
|
400
|
-
cursor: pointer;
|
|
401
|
-
position: relative;
|
|
402
|
-
overflow: hidden;
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
.hfp-scrubber:hover {
|
|
406
|
-
height: var(--hfp-scrubber-height-hover, 6px);
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
.hfp-progress {
|
|
410
|
-
position: absolute;
|
|
411
|
-
top: 0;
|
|
412
|
-
left: 0;
|
|
413
|
-
height: 100%;
|
|
414
|
-
background: var(--hfp-accent, #fff);
|
|
415
|
-
pointer-events: none;
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
.hfp-time {
|
|
419
|
-
flex-shrink: 0;
|
|
420
|
-
font-variant-numeric: tabular-nums;
|
|
421
|
-
opacity: 0.9;
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
.hfp-speed-wrap {
|
|
425
|
-
position: relative;
|
|
426
|
-
flex-shrink: 0;
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
.hfp-speed-btn {
|
|
430
|
-
background: var(--hfp-speed-btn-bg, rgba(255, 255, 255, 0.15));
|
|
431
|
-
border: none;
|
|
432
|
-
border-radius: var(--hfp-speed-btn-radius, 4px);
|
|
433
|
-
color: var(--hfp-color, #fff);
|
|
434
|
-
cursor: pointer;
|
|
435
|
-
font-family: var(--hfp-font, system-ui, -apple-system, sans-serif);
|
|
436
|
-
font-size: 12px;
|
|
437
|
-
font-variant-numeric: tabular-nums;
|
|
438
|
-
font-weight: 600;
|
|
439
|
-
padding: 4px 8px;
|
|
440
|
-
min-width: 40px;
|
|
441
|
-
text-align: center;
|
|
442
|
-
transition: background 0.15s ease;
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
.hfp-speed-btn:hover {
|
|
446
|
-
background: var(--hfp-speed-btn-bg-hover, rgba(255, 255, 255, 0.3));
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
.hfp-speed-menu {
|
|
450
|
-
position: absolute;
|
|
451
|
-
bottom: calc(100% + 8px);
|
|
452
|
-
right: 0;
|
|
453
|
-
background: var(--hfp-menu-bg, rgba(20, 20, 20, 0.95));
|
|
454
|
-
backdrop-filter: blur(12px);
|
|
455
|
-
-webkit-backdrop-filter: blur(12px);
|
|
456
|
-
border: 1px solid var(--hfp-menu-border, rgba(255, 255, 255, 0.1));
|
|
457
|
-
border-radius: var(--hfp-menu-radius, 8px);
|
|
458
|
-
padding: 4px;
|
|
459
|
-
display: flex;
|
|
460
|
-
flex-direction: column;
|
|
461
|
-
gap: 2px;
|
|
462
|
-
min-width: 80px;
|
|
463
|
-
opacity: 0;
|
|
464
|
-
visibility: hidden;
|
|
465
|
-
transform: translateY(4px);
|
|
466
|
-
transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
|
|
467
|
-
box-shadow: var(--hfp-menu-shadow, 0 8px 24px rgba(0, 0, 0, 0.4));
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
.hfp-speed-menu.hfp-open {
|
|
471
|
-
opacity: 1;
|
|
472
|
-
visibility: visible;
|
|
473
|
-
transform: translateY(0);
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
.hfp-speed-option {
|
|
477
|
-
background: none;
|
|
478
|
-
border: none;
|
|
479
|
-
border-radius: 4px;
|
|
480
|
-
color: var(--hfp-menu-color, rgba(255, 255, 255, 0.7));
|
|
481
|
-
cursor: pointer;
|
|
482
|
-
font-family: var(--hfp-font, system-ui, -apple-system, sans-serif);
|
|
483
|
-
font-size: 13px;
|
|
484
|
-
font-variant-numeric: tabular-nums;
|
|
485
|
-
padding: 6px 12px;
|
|
486
|
-
text-align: left;
|
|
487
|
-
transition: background 0.1s ease, color 0.1s ease;
|
|
488
|
-
white-space: nowrap;
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
.hfp-speed-option:hover {
|
|
492
|
-
background: var(--hfp-menu-hover-bg, rgba(255, 255, 255, 0.1));
|
|
493
|
-
color: var(--hfp-color, #fff);
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
.hfp-speed-option.hfp-active {
|
|
497
|
-
color: var(--hfp-accent, #fff);
|
|
498
|
-
font-weight: 600;
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
.hfp-volume-wrap {
|
|
502
|
-
position: relative;
|
|
503
|
-
flex-shrink: 0;
|
|
504
|
-
display: flex;
|
|
505
|
-
align-items: center;
|
|
506
|
-
gap: 0;
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
.hfp-mute-btn {
|
|
510
|
-
background: none;
|
|
511
|
-
border: none;
|
|
512
|
-
color: var(--hfp-color, #fff);
|
|
513
|
-
cursor: pointer;
|
|
514
|
-
padding: 4px;
|
|
515
|
-
display: flex;
|
|
516
|
-
align-items: center;
|
|
517
|
-
justify-content: center;
|
|
518
|
-
width: 32px;
|
|
519
|
-
height: 32px;
|
|
520
|
-
flex-shrink: 0;
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
.hfp-mute-btn:hover {
|
|
524
|
-
opacity: 0.8;
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
.hfp-mute-btn svg,
|
|
528
|
-
.hfp-mute-btn svg * {
|
|
529
|
-
pointer-events: none;
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
.hfp-volume-slider-wrap {
|
|
533
|
-
width: 0;
|
|
534
|
-
overflow: hidden;
|
|
535
|
-
transition: width 0.2s ease;
|
|
536
|
-
display: flex;
|
|
537
|
-
align-items: center;
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
.hfp-volume-wrap:hover .hfp-volume-slider-wrap {
|
|
541
|
-
width: 64px;
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
.hfp-volume-slider {
|
|
545
|
-
width: 56px;
|
|
546
|
-
height: var(--hfp-scrubber-height, 4px);
|
|
547
|
-
background: var(--hfp-scrubber-bg, rgba(255, 255, 255, 0.3));
|
|
548
|
-
border-radius: var(--hfp-scrubber-radius, 2px);
|
|
549
|
-
cursor: pointer;
|
|
550
|
-
position: relative;
|
|
551
|
-
overflow: hidden;
|
|
552
|
-
margin-left: 4px;
|
|
553
|
-
margin-right: 4px;
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
.hfp-volume-fill {
|
|
557
|
-
position: absolute;
|
|
558
|
-
top: 0;
|
|
559
|
-
left: 0;
|
|
560
|
-
height: 100%;
|
|
561
|
-
background: var(--hfp-accent, #fff);
|
|
562
|
-
pointer-events: none;
|
|
563
|
-
}
|
|
564
|
-
`,ut='<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>',ct='<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>',Ee='<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>',Re='<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>',pt='<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>',ft=[.25,.5,1,1.5,2,4];function M(r){return Number.isInteger(r)?`${r}x`:`${r}x`}function Ce(r){if(!Number.isFinite(r)||r<0)return"0:00";const t=Math.floor(r),e=Math.floor(t/60),i=t%60;return`${e}:${i.toString().padStart(2,"0")}`}function mt(r,t,e={}){const i=e.speedPresets??ft,s=document.createElement("div");s.className="hfp-controls",s.addEventListener("click",d=>{d.stopPropagation()});const n=document.createElement("button");n.className="hfp-play-btn",n.type="button",n.innerHTML=`<span class="hfp-ico hfp-ico-play">${ut}</span><span class="hfp-ico hfp-ico-pause">${ct}</span>`,n.setAttribute("aria-label","Play");const o=document.createElement("div");o.className="hfp-scrubber";const a=document.createElement("div");a.className="hfp-progress",a.style.width="0%",o.appendChild(a);const c=document.createElement("span");c.className="hfp-time",c.textContent="0:00 / 0:00";const p=document.createElement("div");p.className="hfp-speed-wrap";const l=document.createElement("button");l.className="hfp-speed-btn",l.type="button",l.textContent="1x",l.setAttribute("aria-label","Playback speed: 1x");const g=document.createElement("div");g.className="hfp-speed-menu",g.setAttribute("role","menu");for(const d of i){const u=document.createElement("button");u.className="hfp-speed-option",u.type="button",u.setAttribute("role","menuitem"),u.dataset.speed=String(d),u.textContent=M(d),d===1&&u.classList.add("hfp-active"),g.appendChild(u)}p.appendChild(g),p.appendChild(l);const _=document.createElement("div");_.className="hfp-volume-wrap";const m=document.createElement("button");m.className="hfp-mute-btn",m.type="button",m.innerHTML=Ee,m.setAttribute("aria-label","Mute");const y=document.createElement("div");y.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 b=document.createElement("div");b.className="hfp-volume-fill",b.style.width="100%",f.appendChild(b),y.appendChild(f),_.appendChild(y),_.appendChild(m),e.audioLocked&&(_.style.display="none"),s.appendChild(n),s.appendChild(o),s.appendChild(c),s.appendChild(_),s.appendChild(p),r.appendChild(s);let w=!1,S=!1,R=1,C=null;i.indexOf(1);const U=(d,u)=>d?pt:u===0||u<.5?Re:Ee;n.addEventListener("click",d=>{d.stopPropagation(),w?t.onPause():t.onPlay()}),m.addEventListener("click",d=>{d.stopPropagation(),t.onMuteToggle()});let k=!1;const V=d=>{const u=f.getBoundingClientRect(),v=Math.max(0,Math.min(1,(d-u.left)/u.width));R=v,b.style.width=`${v*100}%`,f.setAttribute("aria-valuenow",String(Math.round(v*100))),S&&v>0&&t.onMuteToggle(),m.innerHTML=U(S,v),t.onVolumeChange(v)};f.addEventListener("mousedown",d=>{d.stopPropagation(),k=!0,V(d.clientX)});const oe=d=>{k&&V(d.clientX)},ae=()=>{k=!1};document.addEventListener("mousemove",oe),document.addEventListener("mouseup",ae),f.addEventListener("touchstart",d=>{k=!0;const u=d.touches[0];u&&V(u.clientX)},{passive:!0});const de=d=>{if(k){const u=d.touches[0];u&&V(u.clientX)}},he=()=>{k=!1};document.addEventListener("touchmove",de,{passive:!0}),document.addEventListener("touchend",he);const le=.05;f.addEventListener("keydown",d=>{let u=R;if(d.key==="ArrowRight"||d.key==="ArrowUp")u=Math.min(1,R+le);else if(d.key==="ArrowLeft"||d.key==="ArrowDown")u=Math.max(0,R-le);else return;d.preventDefault(),d.stopPropagation(),R=u,b.style.width=`${u*100}%`,f.setAttribute("aria-valuenow",String(Math.round(u*100))),S&&u>0&&t.onMuteToggle(),m.innerHTML=U(S,u),t.onVolumeChange(u)});const ue=d=>{for(const u of g.querySelectorAll(".hfp-speed-option"))u.classList.toggle("hfp-active",u.dataset.speed===String(d))};l.addEventListener("click",d=>{d.stopPropagation();const u=g.classList.toggle("hfp-open");l.setAttribute("aria-expanded",String(u))}),g.addEventListener("click",d=>{d.stopPropagation();const u=d.target.closest(".hfp-speed-option");if(!u)return;const v=parseFloat(u.dataset.speed);i.indexOf(v),l.textContent=M(v),l.setAttribute("aria-label",`Playback speed: ${M(v)}`),ue(v),g.classList.remove("hfp-open"),l.setAttribute("aria-expanded","false"),t.onSpeedChange(v)});const ce=()=>{g.classList.remove("hfp-open"),l.setAttribute("aria-expanded","false")};document.addEventListener("click",ce);const H=d=>{const u=o.getBoundingClientRect(),v=Math.max(0,Math.min(1,(d-u.left)/u.width));t.onSeek(v)};let T=!1;o.addEventListener("mousedown",d=>{var u;d.stopPropagation(),T=!0,(u=t.onScrubStart)==null||u.call(t),H(d.clientX)});const pe=d=>{T&&H(d.clientX)},fe=()=>{var d;T&&(T=!1,(d=t.onScrubEnd)==null||d.call(t))};document.addEventListener("mousemove",pe),document.addEventListener("mouseup",fe),o.addEventListener("touchstart",d=>{var v;T=!0,(v=t.onScrubStart)==null||v.call(t);const u=d.touches[0];u&&H(u.clientX)},{passive:!0});const me=d=>{if(T){const u=d.touches[0];u&&H(u.clientX)}},_e=()=>{var d;T&&(T=!1,(d=t.onScrubEnd)==null||d.call(t))};document.addEventListener("touchmove",me,{passive:!0}),document.addEventListener("touchend",_e);const ge=()=>w&&!T&&!k&&!s.querySelector(":focus-visible"),ye=()=>{s.classList.remove("hfp-hidden"),C&&clearTimeout(C),C=setTimeout(()=>{ge()&&s.classList.add("hfp-hidden")},3e3)},E=r instanceof ShadowRoot?r.host:r,P=()=>ye(),ve=()=>{ge()&&s.classList.add("hfp-hidden")};return E.addEventListener("mousemove",P),E.addEventListener("keydown",P),E.addEventListener("focusin",P),E.addEventListener("mouseleave",ve),{updateTime(d,u){const v=u>0?Math.min(d,u):d,$e=u>0?v/u*100:0;a.style.width=`${$e}%`,c.textContent=`${Ce(v)} / ${Ce(u)}`},updatePlaying(d){const u=d!==w;w=d,n.classList.toggle("hfp-playing",d),n.setAttribute("aria-label",d?"Pause":"Play"),d?u&&ye():(C&&clearTimeout(C),s.classList.remove("hfp-hidden"))},updateSpeed(d){i.indexOf(d),l.textContent=M(d),l.setAttribute("aria-label",`Playback speed: ${M(d)}`),ue(d)},updateMuted(d){S=d,m.innerHTML=U(d,R),m.setAttribute("aria-label",d?"Unmute":"Mute")},updateVolume(d){R=d,b.style.width=`${d*100}%`,f.setAttribute("aria-valuenow",String(Math.round(d*100))),m.innerHTML=U(S,d)},setVolumeControlsHidden(d){_.style.display=d?"none":""},show(){s.style.display=""},hide(){s.style.display="none"},destroy(){document.removeEventListener("mousemove",pe),document.removeEventListener("mouseup",fe),document.removeEventListener("touchmove",me),document.removeEventListener("touchend",_e),document.removeEventListener("mousemove",oe),document.removeEventListener("mouseup",ae),document.removeEventListener("touchmove",de),document.removeEventListener("touchend",he),document.removeEventListener("click",ce),E.removeEventListener("mousemove",P),E.removeEventListener("keydown",P),E.removeEventListener("focusin",P),E.removeEventListener("mouseleave",ve),C&&clearTimeout(C),s.remove()}}}function _t(r,t,e,i,s,n=!1){const o=i?i.split(",").map(Number).filter(p=>!isNaN(p)&&p>0):void 0,a={...o?{speedPresets:o}:{},audioLocked:n},c=mt(r,s,a);return c.updateMuted(t),c.updateVolume(e),c}function ke(r,t,e){return t?(e||(e=document.createElement("img"),e.className="hfp-poster",r.appendChild(e)),e.src=t,e):(e==null||e.remove(),null)}function gt(r){return r.composedPath().some(t=>t instanceof HTMLElement&&t.classList.contains("hfp-controls"))}let W=null;function yt(r,t){if(typeof CSSStyleSheet<"u")try{W||(W=new CSSStyleSheet,W.replaceSync(t)),r.adoptedStyleSheets=[W];return}catch{}const e=document.createElement("style");e.textContent=t,r.appendChild(e)}function vt(){const r=document.createElement("div");r.className="hfp-container";const t=document.createElement("iframe");return t.className="hfp-iframe",t.sandbox.add("allow-scripts","allow-same-origin"),t.allow="autoplay; fullscreen",t.referrerPolicy="same-origin",t.title="HyperFrames Composition",t.setAttribute(Ye,""),r.appendChild(t),{container:r,iframe:t}}function bt(r,t,e,i){const s=r.offsetWidth,n=r.offsetHeight;if(s===0||n===0)return!1;const o=Math.min(s/e,n/i);return t.style.width=`${e}px`,t.style.height=`${i}px`,t.style.transform=`translate(-50%, -50%) scale(${o})`,!0}const wt=100,At=.001;function St(r,t,e){if(e.end<=0)return!1;const i=e.shown<e.end&&t>0?t+At:0;return r+i>=e.end}class Tt{constructor(t){h(this,"_raf",null);h(this,"_lastUpdateMs",0);h(this,"_tick",null);this._callbacks=t}start(t,e,i,s,n){this.stop();let o=null,a=0,c=0;const p=()=>{if(s()){this._raf=null;return}let l;try{l=t.time()}catch{this._raf=null;return}const g=i(),_=n();_.end>0&&(l=Math.min(l,_.end));const m=o===null?0:l-o;m!==0&&(c=Math.min(m,a),a=m),o=l;const y=St(l,c,_);y&&(l=_.shown);const f=performance.now();if((f-this._lastUpdateMs>wt||y)&&(this._lastUpdateMs=f,this._callbacks.onTimeUpdate(l,g)),y){if(this._callbacks.getLoop()){this._callbacks.restart();return}try{t.pause(),_.shown<_.end&&t.seek(_.shown,!1)}catch{}this._callbacks.onPaused(),this._raf=null;return}this._raf=requestAnimationFrame(p)};this._tick=p,this._raf=requestAnimationFrame(p)}poll(){this._raf===null||!this._tick||(cancelAnimationFrame(this._raf),this._tick())}stop(){this._raf!==null&&(cancelAnimationFrame(this._raf),this._raf=null)}get isRunning(){return this._raf!==null}}function Et(r){const t=Array.from(r.querySelectorAll("[data-composition-id]"));if(t.length===0)return r.body?[r.body]:[];const e=[];for(const i of t)Ct(i)||e.push(i);return Rt(r),e}function Rt(r){const t=r.body;if(!t||typeof console>"u"||typeof console.warn!="function")return;const e=t.querySelectorAll("audio[data-start], video[data-start]");if(e.length===0)return;const i=[];for(const s of e)s.closest("[data-composition-id]")||i.push(s);i.length!==0&&console.warn(`[hyperframes-player] selectMediaObserverTargets: composition hosts are present, but ${i.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.`,i)}function Ct(r){let t=r.parentElement;for(;t;){if(t.hasAttribute("data-composition-id"))return!0;t=t.parentElement}return!1}const X=.04,kt=.5,Pt=.03,Lt=[[.3,.25],[.1,.1]],Dt=.01,Mt=.1,xt=.1,It=.65,L=new WeakMap,q=new WeakSet;function Ot(r,t,e,i,s=r.tagName==="AUDIO"){var g;const n=Math.abs(t);if(s&&Xe())return L.delete(r),{rate:e,seek:i&&n>It};i&&n<=X&&q.delete(r);const o=!q.has(r)||n>kt;if(s&&i&&n>xt&&o)return L.delete(r),q.add(r),{rate:e,seek:!0};const a=Math.sign(t),c=L.get(r);if(n>X)L.set(r,a);else if(c!==a||n<=Dt)return L.delete(r),{rate:e,seek:!1};const p=((g=Lt.find(([_])=>n>_))==null?void 0:g[1])??Pt,l=s?Math.min(p,Mt):p;return{rate:e*(1+a*l),seek:!1}}function Nt(r){L.delete(r),q.delete(r)}const Ft=.004,Ut=1.5;class Vt{constructor(t){h(this,"_entries",[]);h(this,"_mediaObserver");h(this,"_playbackErrorPosted",!1);h(this,"_audioOwner","runtime");h(this,"_urlAudioEntry",null);h(this,"_urlAudioSrc",null);h(this,"_dispatchEvent");h(this,"_getMuted");h(this,"_getVolume");h(this,"_getPlaybackRate");h(this,"_getCurrentTime");h(this,"_isPaused");this._dispatchEvent=t.dispatchEvent,this._getMuted=t.getMuted,this._getVolume=t.getVolume,this._getPlaybackRate=t.getPlaybackRate,this._getCurrentTime=t.getCurrentTime,this._isPaused=t.isPaused}get audioOwner(){return this._audioOwner}get entries(){return this._entries}resetForIframeLoad(){this._playbackErrorPosted=!1;const t=this._audioOwner==="parent";this._audioOwner="runtime",this.pauseAll();for(const e of this._entries)e!==this._urlAudioEntry&&(e.el.src="");this._entries=this._urlAudioEntry?[this._urlAudioEntry]:[],this._urlAudioSrc&&!this._urlAudioEntry&&(this._urlAudioEntry=this._createEntry(this._urlAudioSrc,"audio",0,1/0)),this.teardownObserver(),t&&this._dispatchEvent(new CustomEvent("audioownershipchange",{detail:{owner:"runtime",reason:"iframe-reload"}}))}destroy(){this.teardownObserver();for(const t of this._entries)t.el.pause(),t.el.src="";this._entries=[],this._urlAudioEntry=null,this._urlAudioSrc=null,this._audioOwner="runtime",this._playbackErrorPosted=!1}updateMuted(t){for(const e of this._entries)e.el.muted=t}updateVolume(t){for(const e of this._entries)e.el.volume=t}updatePlaybackRate(t){for(const e of this._entries)e.el.playbackRate=t}_playEntry(t){t.el.src&&t.el.play().catch(e=>this._reportPlaybackError(e))}_playEntryIfActive(t){this._refreshEntryBounds(t),this._inWindow(t,this._getCurrentTime())&&this._playEntry(t)}_refreshEntryBounds(t){var i;if(!((i=t.source)!=null&&i.isConnected))return;const e=be(t.source);t.start=e.start??0,t.mediaStart=we(t.source).mediaStart,t.duration=e.duration!=null&&e.duration>0?e.duration:Number.POSITIVE_INFINITY}_inWindow(t,e){return Ke(e,t.start,t.start+t.duration)}_preseekUpcoming(t,e){const i=t.start-e;i<=0||i>Ut||!t.el.paused||Math.abs(t.el.currentTime-t.mediaStart)>X&&this._seekTo(t,t.mediaStart)}_seekTo(t,e,i=!1){const s=i?(t.seekLatency??0)*this._getPlaybackRate():0;t.seekIssuedAt=i?performance.now():void 0,t.el.currentTime=Ue(e+s)}_noteSeekLanded(t){if(t.seekIssuedAt===void 0)return;const e=(performance.now()-t.seekIssuedAt)/1e3;t.seekLatency=t.seekLatency===void 0?e:(t.seekLatency+e)/2,t.seekIssuedAt=void 0}_releaseSteering(t){Nt(t.el),t.lastOffset=void 0;const e=this._getPlaybackRate();t.el.playbackRate!==e&&(t.el.playbackRate=e)}_mediaTime(t,e){return e-t.start+t.mediaStart}_gateEntryPlayback(t,e){return this._inWindow(t,e)?(this._audioOwner==="parent"&&!this._isPaused()&&t.el.paused&&this._playEntry(t),!0):(t.el.paused||t.el.pause(),this._releaseSteering(t),!1)}playAll(){for(const t of this._entries)this._playEntryIfActive(t)}primeAll(){if(Ze())for(const t of this._entries)t.el.paused&&(t.el.play().catch(()=>{}),t.el.pause())}pauseAll(){for(const t of this._entries)t.el.pause()}stopAdoptedMedia(){for(const t of this._entries)t.source&&t.el.pause()}seekAll(t){for(const e of this._entries)this._refreshEntryBounds(e),this._inWindow(e,t)&&this._jumpTo(e,this._mediaTime(e,t))}scrubAll(t){for(const e of this._entries)this._refreshEntryBounds(e),this._inWindow(e,t)?(this._jumpTo(e,this._mediaTime(e,t)),this._playEntry(e)):e.el.paused||e.el.pause()}mirrorTime(t,e){const i=(e==null?void 0:e.force)===!0;for(const s of this._entries){this._refreshEntryBounds(s),this._preseekUpcoming(s,t);const n=s.el.paused;if(!this._gateEntryPlayback(s,t))continue;const o=this._mediaTime(s,t),a=o-s.el.currentTime;if(i||n){Math.abs(a)>X&&this._jumpTo(s,o);continue}this._steer(s,o,a)}}_steer(t,e,i){const s=t.lastOffset!==void 0&&Math.abs(i-t.lastOffset)<Ft;t.lastOffset=i;const{rate:n,seek:o}=Ot(t.el,i,this._getPlaybackRate(),s,!0);o?this._jumpTo(t,e,!0):Math.abs(t.el.playbackRate-n)>1e-6&&(t.el.playbackRate=n)}_jumpTo(t,e,i=!1){this._seekTo(t,e,i),this._releaseSteering(t)}promoteToParentProxy(t,e){if(this._audioOwner==="parent")return;if(this._audioOwner="parent",t)for(const s of t.querySelectorAll("video, audio"))A(s)&&(s.muted=!0);for(const s of[...this._entries])this._repointToSource(s);const i=this._getCurrentTime();e?e(i,{force:!0}):this.mirrorTime(i,{force:!0}),this._isPaused()||this.playAll(),this._dispatchEvent(new CustomEvent("audioownershipchange",{detail:{owner:"parent",reason:"autoplay-blocked"}}))}setupFromIframe(t){const e=t.querySelectorAll("audio[data-start], video[data-start]");for(const i of e)A(i)&&this._adoptIframeMedia(i);this._observeDynamicMedia(t)}setupFromUrl(t){if(this._urlAudioSrc===t&&this._urlAudioEntry)return;this.teardownUrlAudio();const e=this._createEntry(t,"audio",0,1/0);this._urlAudioEntry=e,this._urlAudioSrc=t,e&&this._audioOwner==="parent"&&!this._isPaused()&&(this.mirrorTime(this._getCurrentTime(),{force:!0}),this.playAll())}teardownUrlAudio(){const t=this._urlAudioEntry;if(this._urlAudioEntry=null,this._urlAudioSrc=null,!t)return;t.el.pause(),t.el.src="";const e=this._entries.indexOf(t);e!==-1&&this._entries.splice(e,1)}teardownObserver(){var t;(t=this._mediaObserver)==null||t.disconnect(),this._mediaObserver=void 0}_reportPlaybackError(t){this._playbackErrorPosted||(this._playbackErrorPosted=!0,this._dispatchEvent(new CustomEvent("playbackerror",{detail:{source:"parent-proxy",error:t}})))}_createEntry(t,e,i,s,n){if(!n&&this._urlTaken(t))return null;const o=e==="video"?document.createElement("video"):new Audio;o.preload="auto";const a=n==null?void 0:n.getAttribute("crossorigin");a!=null&&o.setAttribute("crossorigin",a),o.src=t,o.load(),o.muted=this._getMuted(),o.volume=this._getVolume();const c=this._getPlaybackRate();c!==1&&(o.playbackRate=c);const p={el:o,start:i,duration:s,mediaStart:n?we(n).mediaStart:0,source:n};return o.addEventListener("seeked",()=>this._noteSeekLanded(p)),this._entries.push(p),p}_resolveIframeMediaSrc(t){var i;const e=t.getAttribute("src")||((i=t.querySelector("source"))==null?void 0:i.getAttribute("src"));return e?new URL(e,t.ownerDocument.baseURI).href:null}_adoptIframeMedia(t){if(t.preload==="metadata"||t.preload==="none"||this._entries.some(c=>c.source===t)||t.tagName==="VIDEO"&&t.hasAttribute("muted"))return;const e=this._resolveIframeMediaSrc(t);if(!e)return;const i=be(t),s=i.start??0,n=i.duration??Number.POSITIVE_INFINITY,o=t.tagName==="VIDEO"?"video":"audio",a=this._createEntry(e,o,s,n,t);a&&this._audioOwner==="parent"&&(this.mirrorTime(this._getCurrentTime(),{force:!0}),this._isPaused()||this._playEntryIfActive(a))}_followIframeMediaSrc(t){const e=this._entries.find(i=>i.source===t);if(!e)return this._adoptIframeMedia(t);this._audioOwner!=="parent"||!this._repointToSource(e)||(this.mirrorTime(this._getCurrentTime(),{force:!0}),this._isPaused()||this._playEntryIfActive(e))}_urlTaken(t){return this._entries.some(e=>e.source&&!e.source.isConnected?!1:(e.source&&this._resolveIframeMediaSrc(e.source)||e.el.src)===t)}_repointToSource(t){const e=t.source?this._resolveIframeMediaSrc(t.source):null;return!e||t.el.src===e?!1:(t.el.src=e,t.el.load(),!0)}_detachIframeMedia(t){const e=this._entries.find(i=>i.source===t);e&&this._removeEntry(e)}_removeEntry(t){t.el.pause(),t.el.src="",this._entries.splice(this._entries.indexOf(t),1)}_observeDynamicMedia(t){if(this.teardownObserver(),typeof MutationObserver>"u"||!t.body)return;const e=new MutationObserver(n=>{for(const o of n){if(o.type==="attributes"&&o.attributeName==="src"){const a=o.target;A(a)&&a.matches("audio[data-start], video[data-start]")&&this._followIframeMediaSrc(a);continue}if(o.type==="attributes"&&o.attributeName==="preload"){const a=o.target;A(a)&&a.matches("audio[data-start], video[data-start]")&&(a.preload==="auto"?this._adoptIframeMedia(a):this._detachIframeMedia(a));continue}for(const a of o.addedNodes){if(!Ae(a))continue;const c=[];A(a)&&a.matches("audio[data-start], video[data-start]")&&c.push(a);const p=a.querySelectorAll("audio[data-start], video[data-start]");for(const l of p)A(l)&&c.push(l);for(const l of c)this._adoptIframeMedia(l)}for(const a of o.removedNodes){if(!Ae(a))continue;const c=[];A(a)&&a.matches("audio[data-start], video[data-start]")&&c.push(a);const p=a.querySelectorAll("audio[data-start], video[data-start]");for(const l of p)A(l)&&c.push(l);for(const l of c)this._detachIframeMedia(l)}}}),i={childList:!0,subtree:!0,attributes:!0,attributeFilter:["preload","src"]},s=Et(t);for(const n of s)e.observe(n,i);this._mediaObserver=e}}function Pe(r,t,e){if(r===null&&t===null)return{range:null,clamped:!1};const i=r??0,s=t!==null&&e>0&&t>e,n=s?e:t,o=n??(e>0?e:1/0);return!(i>=0)||!(o>i)?{range:null,clamped:!0}:{range:{start:i,end:n},clamped:s}}function re(r,t,e){const i=r.end??t;return i<t?Je(r.start,i,e):i}function Le(r,t,e,i){return r<t.start||r>=re(t,e,i)}const Ht=100;function Wt(r,t){return typeof r.currentTime=="number"&&Number.isFinite(r.currentTime)?r.currentTime:(r.frame??0)/t}function Ve(r,t,e){return e<=0?!1:r.ended===!0?!0:r.ended===!1&&!r.isPlaying?!1:t>=e}function zt(r,t,e,i,s,n){const{duration:o}=e;if(!s){const a=Ve(r,t,o);return{start:0,shownAtEnd:o,atEnd:a,stopRuntime:!1,entering:!1}}if(r.ownsRange){const a=i&&r.ended===!0&&!r.isPlaying;return{start:s.start,shownAtEnd:t,atEnd:a,stopRuntime:!1,entering:!1}}return $t(r,t,e,i,s,n)}function $t(r,t,e,i,s,n){const o=s.end??e.duration,a=e.enteringRange===!0&&(t<s.start||t>=o);return{start:s.start,shownAtEnd:re(s,e.duration,n),atEnd:i&&!a&&Ve(r,t,o),stopRuntime:r.isPlaying,entering:a}}function jt(r,t,e,i){var S;const s=Wt(r,t),n=!e.paused,o=n||r.isPlaying,a=(S=i.getPlayRange)==null?void 0:S.call(i),c=zt(r,s,e,o,a,t),{atEnd:p,start:l}=c,g=e.duration>0?Math.min(s,e.duration):s,_=p?c.shownAtEnd:g,m=!r.isPlaying,y=p&&o;if(y&&i.getLoop())return i.media.audioOwner==="parent"&&i.media.pauseAll(),i.seek(l),i.play(),{...e,currentTime:l,paused:!1,enteringRange:!0};const f={...e,currentTime:_,paused:m,enteringRange:c.entering};i.media.audioOwner==="parent"&&(n&&m?i.media.pauseAll():!n&&!m&&i.media.playAll(),i.media.mirrorTime(_));const b=performance.now(),w=m!==e.paused;return(b-e.lastUpdateMs>Ht||w)&&(f.lastUpdateMs=b,i.updateControlsTime(_,e.duration),i.updateControlsPlaying(!m),i.dispatchEvent(new CustomEvent("timeupdate",{detail:{currentTime:_}}))),y&&(c.stopRuntime&&i.seek(_),i.media.audioOwner==="parent"&&i.media.pauseAll(),f.paused=!0,i.updateControlsPlaying(!1),i.dispatchEvent(new Event("ended"))),f}function Bt(r){return Array.isArray(r)?r.filter(t=>typeof t=="object"&&t!==null&&typeof t.id=="string"&&typeof t.start=="number"&&typeof t.duration=="number"):[]}function qt(r,t,e){var o,a,c,p,l,g,_;if(r.source!==t)return;const i=r.data;if(!i||i.source!=="hf-preview")return;const s=Qe(i);if(s.status==="unsupported"){e.dispatchEvent(new CustomEvent("runtimeprotocolerror",{detail:{code:s.code,receivedVersion:s.receivedVersion}}));return}(o=e.setRuntimeFps)==null||o.call(e,s.fps);const n=s.status==="supported"&&s.metadata.capabilities.includes("play-range");if((a=e.setRuntimeOwnsPlayRange)==null||a.call(e,n),i.type==="shader-transition-state"){const m=i.state&&typeof i.state=="object"?i.state:{};e.shaderLoader.update(m,e.getShaderLoadingMode()),e.dispatchEvent(new CustomEvent("shadertransitionstate",{detail:{compositionId:i.compositionId,state:m}}));return}if(i.type==="ready"){e.onRuntimeReady();return}if(i.type==="assets-ready"){(c=e.onRuntimeAssetsReady)==null||c.call(e,i.timedOut===!0);return}if(i.type==="runtime-data-error"){(p=e.onRuntimeDataError)==null||p.call(e,i.channel,i.requestId,i.message);return}if(i.type==="runtime-data-applied"){(l=e.onRuntimeDataApplied)==null||l.call(e,i.channel,i.requestId);return}if(i.type==="state"){e.setPlaybackState(jt({frame:i.frame??0,currentTime:i.currentTime,ended:typeof i.ended=="boolean"?i.ended:void 0,isPlaying:!!i.isPlaying,ownsRange:n},s.fps,e.getPlaybackState(),e)),(g=e.setBuffering)==null||g.call(e,i.buffering===!0);return}if(i.type==="media-autoplay-blocked"){if(((_=e.shouldPromoteMediaAutoplayFallback)==null?void 0:_.call(e))===!1)return;let m=null;try{m=e.getIframeDoc()}catch{}e.media.promoteToParentProxy(m,(y,f)=>e.media.mirrorTime(y,f)),e.sendControl("set-media-output-muted",{muted:!0});return}if(i.type==="timeline"&&i.durationInFrames>0){const m=Number(i.durationSeconds),y=Number(i.durationInFrames),f=Number.isFinite(m)&&m>0?m:y/s.fps;if(Number.isFinite(i.compositionWidth)&&i.compositionWidth>0&&Number.isFinite(i.compositionHeight)&&i.compositionHeight>0&&e.setCompositionSize(i.compositionWidth,i.compositionHeight),Number.isFinite(f)&&f>0){const b=e.getPlaybackState();e.setPlaybackState({...b,duration:f}),e.updateControlsTime(b.currentTime,f),e.onRuntimeTimelineReady(f,typeof i.assetsReady=="boolean"?i.assetsReady:void 0)}e.setScenes(Bt(i.scenes));return}i.type==="stage-size"&&Number.isFinite(i.width)&&i.width>0&&Number.isFinite(i.height)&&i.height>0&&e.setCompositionSize(i.width,i.height)}function Gt(r,t){return r.includes(t)?!0:/hyperframe\.runtime\.iife\.js|__hyperframes\s*=/.test(r)}const Yt=new Set([">"," "," ",`
|
|
565
|
-
`,"\r","\f"]);function Z(r,t){const e=r.toLowerCase(),i=`<${t}`;let s=0;for(;s<e.length;){const n=e.indexOf(i,s);if(n<0)return null;const o=e[n+i.length];if(Yt.has(o)){const a=e.indexOf(">",n+i.length);return a<0?null:{index:n,end:a+1}}s=n+i.length}return null}function Xt(r,t){if(!r||Gt(r,t))return r;const e=`<script src="${t}"><\/script>`,i=Z(r,"head");if(i)return r.slice(0,i.end)+e+r.slice(i.end);const s=Z(r,"body");if(s)return r.slice(0,s.index)+e+r.slice(s.index);const n=Z(r,"html");return n?r.slice(0,n.end)+e+r.slice(n.end):e+r}const D="shader-capture-scale",N="shader-loading",se="runtime-src",De="__hf_shader_capture_scale",Me="__hf_shader_loading",G=["Preparing scene transitions","Sampling outgoing scene motion","Sampling incoming scene motion","Caching transition frames","Finalizing transition preview"];function ne(r){if(r===null)return null;const t=Number(r);return!Number.isFinite(t)||t<=0?null:String(Math.min(1,Math.max(.25,t)))}function Kt(r){if(r===null||r.trim()==="")return"composition";const t=r.trim().toLowerCase();return t==="none"||t==="false"||t==="0"||t==="off"?"none":t==="player"||t==="true"||t==="1"||t==="on"?"player":"composition"}function xe(r,t){return r.filter(e=>e!==""&&e.split("=")[0]!==t)}function Zt(r,t,e){const i=r.indexOf("#"),s=i>=0?r.slice(0,i):r,n=i>=0?r.slice(i):"",o=s.indexOf("?"),a=o>=0?s.slice(0,o):s,c=o>=0?s.slice(o+1):"";let p=xe(c.split("&"),De);p=xe(p,Me),t!==null&&p.push(`${De}=${encodeURIComponent(t)}`),e!=="composition"&&p.push(`${Me}=${encodeURIComponent(e)}`);const l=p.join("&");return`${a}${l?`?${l}`:""}${n}`}function Jt(r,t,e){if(t===null&&e==="composition")return r;const i=[];t!==null&&i.push(`window.__HF_SHADER_CAPTURE_SCALE=${JSON.stringify(t)};`),e!=="composition"&&i.push(`window.__HF_SHADER_LOADING=${JSON.stringify(e)};`);const s=`<script data-hyperframes-player-shader-options>${i.join("")}<\/script>`;return/<head\b[^>]*>/i.test(r)?r.replace(/<head\b[^>]*>/i,n=>`${n}${s}`):/<html\b[^>]*>/i.test(r)?r.replace(/<html\b[^>]*>/i,n=>`${n}${s}`):`${s}${r}`}function K(r){return Kt(r.getAttribute(N))}function Qt(r){return Number(ne(r.getAttribute(D))??"1")}function ei(r,t){return Zt(t,ne(r.getAttribute(D)),K(r))}function z(r,t){return Xt(Jt(t,ne(r.getAttribute(D)),K(r)),He(r))}function He(r){var e;const t=(e=r.getAttribute(se))==null?void 0:e.trim();if(!t)return B;try{const i=new URL(t,document.baseURI),s=i.protocol==="http:"||i.protocol==="https:",n=i.hostname==="127.0.0.1"||i.hostname==="localhost"||i.hostname==="[::1]";return s&&(n||i.origin===location.origin)?i.href:B}catch{return B}}const We="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",ze="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",Ie=`url("data:image/svg+xml,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><path d="${We}"/><path d="${ze}"/></svg>`)}")`;function ti(){const r=document.createElement("div");r.className="hfp-shader-loader",r.setAttribute("role","status"),r.setAttribute("aria-live","polite"),r.setAttribute("aria-label","Preparing scene transitions"),r.setAttribute("data-hyperframes-ignore",""),r.draggable=!1;const t=y=>{y.preventDefault(),y.stopPropagation()};for(const y of["selectstart","dragstart","pointerdown","mousedown","click","dblclick","contextmenu","touchstart"])r.addEventListener(y,t,{capture:!0});const e=document.createElement("div");e.className="hfp-shader-loader-panel",e.draggable=!1;const i=document.createElement("div");i.className="hfp-shader-loader-mark",i.draggable=!1,i.innerHTML=['<svg width="78" height="78" viewBox="0 0 100 100" fill="none" aria-hidden="true" draggable="false">',`<path d="${We}" fill="url(#hfp-shader-loader-grad-left)"/>`,`<path d="${ze}" 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 s=document.createElement("div");s.className="hfp-shader-loader-sheen",s.style.setProperty("mask-image",Ie),s.style.setProperty("-webkit-mask-image",Ie),i.appendChild(s);const n=document.createElement("div");n.className="hfp-shader-loader-title";const o=document.createElement("span");o.className="hfp-shader-loader-title-text",o.textContent=G[0],n.appendChild(o);const a=document.createElement("div");a.className="hfp-shader-loader-detail",a.textContent="Rendering animated scene samples for shader transitions.";const c=document.createElement("div");c.className="hfp-shader-loader-track",c.setAttribute("aria-hidden","true");const p=document.createElement("div");p.className="hfp-shader-loader-fill",c.appendChild(p);const l=document.createElement("div");l.className="hfp-shader-loader-progress";const g=y=>{const f=document.createElement("div");f.className="hfp-shader-loader-row";const b=document.createElement("span");b.className="hfp-shader-loader-label",b.textContent=y;const w=document.createElement("span");return w.className="hfp-shader-loader-value",f.appendChild(b),f.appendChild(w),l.appendChild(f),{row:f,label:b,value:w}},_=g("transition"),m=g("transition frame");return e.appendChild(i),e.appendChild(n),e.appendChild(a),e.appendChild(c),e.appendChild(l),r.appendChild(e),{root:r,fill:p,title:o,detail:a,transitionValue:_.value,transitionRow:_.row,frameLabel:m.label,frameValue:m.value,frameRow:m.row}}const ii=420;function $(r,t,e){t.textContent=e,r.style.visibility=e?"visible":"hidden"}class si{constructor(t){h(this,"_el");h(this,"_hideTimeout",null);h(this,"_hiddenCallbacks",[]);h(this,"_drawingAssets",!1);this._el=t}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())}whenHidden(t){const e=this._el.root.classList;e.contains("hfp-visible")||e.contains("hfp-hiding")?this._hiddenCallbacks.push(t):t()}_flushHidden(){const t=this._hiddenCallbacks;this._hiddenCallbacks=[];for(const e of t)e()}reset(){this._hideTimeout&&(clearTimeout(this._hideTimeout),this._hideTimeout=null),this._el.root.classList.remove("hfp-visible","hfp-hiding"),this._drawingAssets=!1,this._el.root.classList.remove("hfp-assets"),this._flushHidden(),this._el.fill.style.transform="scaleX(0)",$(this._el.transitionRow,this._el.transitionValue,""),$(this._el.frameRow,this._el.frameValue,"")}update(t,e){const i=e==="player"&&t.loading&&!t.ready;if(this._drawingAssets&&!i)return;if(e!=="player"){this.reset();return}if(t.ready||!t.loading){this.hide();return}this._el.root.setAttribute("aria-label","Preparing scene transitions"),this._drawingAssets=!1,this._el.root.classList.remove("hfp-assets");const s=typeof t.progress=="number"&&Number.isFinite(t.progress)?t.progress:0,n=typeof t.total=="number"&&Number.isFinite(t.total)?t.total:0,o=n>0?Math.min(1,Math.max(0,s/n)):0,a=Math.min(G.length-1,Math.floor(o*G.length));this._el.title.textContent=G[a]||"Preparing scene transitions",this._el.detail.textContent=t.phase==="cached"?"Loading cached transition frames before playback.":t.phase==="finalizing"?"Uploading transition textures for smooth playback.":"Rendering animated scene samples for shader transitions.",this._el.fill.style.transform=`scaleX(${o})`;const c=t.currentTransition!==void 0&&t.transitionTotal!==void 0?`${t.currentTransition}/${t.transitionTotal}`:n>0?`${s}/${n}`:"",p=t.transitionFrame!==void 0&&t.transitionFrames!==void 0?`${t.transitionFrame}/${t.transitionFrames}`:"";this._el.frameLabel.textContent=t.phase==="cached"?"cached transition frames":t.phase==="finalizing"?"finalizing transition frames":"rendering transition frames",$(this._el.transitionRow,this._el.transitionValue,c),$(this._el.frameRow,this._el.frameValue,p),this._el.root.setAttribute("aria-valuenow",String(Math.round(o*100))),this.show()}showAssetsLoading(t="Loading assets",e="Waiting for images, video and fonts to finish loading."){this.reset(),this._el.title.textContent=t,this._el.detail.textContent=e,this._el.root.setAttribute("aria-label",t),this._drawingAssets=!0,this._el.root.classList.add("hfp-assets"),this.show()}hideAssetsLoading(){this._drawingAssets&&this.hide()}get hideTimeout(){return this._hideTimeout}destroy(){this._hideTimeout&&(clearTimeout(this._hideTimeout),this._hideTimeout=null),this._hiddenCallbacks=[]}_scheduleCleanup(){this._hideTimeout&&clearTimeout(this._hideTimeout),this._hideTimeout=setTimeout(()=>{this._el.root.classList.remove("hfp-hiding"),this._hideTimeout=null,this._flushHidden()},ii)}}function ri(r){return(r==null?void 0:r.trim().toLowerCase().startsWith("video/"))??!1}function ni(r){const t=document.createElement("video");t.className="hfp-video",t.playsInline=!0,t.preload="metadata";const e=new AbortController,{signal:i}=e;return t.addEventListener("loadedmetadata",()=>r.onMetadata(t),{signal:i}),t.addEventListener("durationchange",()=>r.onDurationChange(t),{signal:i}),t.addEventListener("resize",()=>r.onResize(t),{signal:i}),t.addEventListener("play",()=>r.onPlay(t),{signal:i}),t.addEventListener("pause",()=>r.onPause(t),{signal:i}),t.addEventListener("timeupdate",()=>r.onTimeUpdate(),{signal:i}),t.addEventListener("error",()=>{var n,o;return r.onError(((n=t.error)==null?void 0:n.message)||"Video failed to load",((o=t.error)==null?void 0:o.code)??null)},{signal:i}),{video:t,adapter:{duration:()=>t.duration,time:()=>t.currentTime,seek:n=>{t.currentTime=Ue(n)},play:()=>t.play().catch(n=>{i.aborted||r.onPlayRejected(n)}),pause:()=>t.pause(),timeScale:n=>{t.defaultPlaybackRate=n,t.playbackRate=n}},destroy:()=>{e.abort(),t.pause(),t.removeAttribute("src"),t.load(),t.remove()}}}const oi=.1,ai=5,J="sandbox-origin",Oe=1e4,Q=8e3,ee="assets-loading",x="assets-loading-ui",j="buffering",te="low-power-idle",Ne="disable-click-to-play",I="range-start",O="range-end",Fe=150;function ie(r){return!Number.isFinite(r)||r<=0?1:Math.max(oi,Math.min(ai,r))}class di extends HTMLElement{constructor(){super();h(this,"shadow");h(this,"container");h(this,"sizer",document.createElement("div"));h(this,"iframe");h(this,"posterEl",null);h(this,"controlsApi",null);h(this,"resizeObserver");h(this,"shaderLoader");h(this,"probe");h(this,"_ready",!1);h(this,"_readyDocument",null);h(this,"_connected",!1);h(this,"_assetsReady",!1);h(this,"_painted",!1);h(this,"_pendingPlay",!1);h(this,"_assetsGeneration",0);h(this,"_assetsLoadingShowTimer",null);h(this,"_bufferingShowTimer",null);h(this,"_currentTime",0);h(this,"_duration",0);h(this,"_paused",!0);h(this,"_scrubbing",!1);h(this,"_lastUpdateMs",0);h(this,"_volume",1);h(this,"_compositionWidth",1920);h(this,"_compositionHeight",1080);h(this,"_rescaleWarned",!1);h(this,"_directTimelineAdapter",null);h(this,"_directTimelineClock");h(this,"_parentTickRaf",null);h(this,"_media");h(this,"_scenes",[]);h(this,"_runtimeFps",30);h(this,"_runtimeBridgeReady",!1);h(this,"_runtimeAssetsReadyGeneration",-1);h(this,"_runtimeData",new Map);h(this,"_runtimeDataRequestId",0);h(this,"_pendingRuntimeData",new Map);h(this,"_afterUpdate",null);h(this,"_videoSource",null);h(this,"_runtimeOwnsPlayRange",!1);h(this,"_enteringRange",!1);h(this,"_rangeClampReported","");this.shadow=this.attachShadow({mode:"open"}),yt(this.shadow,lt),{container:this.container,iframe:this.iframe}=vt(),this.sizer.className="hfp-sizer",this.shadow.appendChild(this.sizer),this.shadow.appendChild(this.container);const e=ti();this.shadow.appendChild(e.root),this.shaderLoader=new si(e),this._media=new Vt({dispatchEvent:i=>this._emit(i),getMuted:()=>this.muted,getVolume:()=>this._volume,getPlaybackRate:()=>this.playbackRate,getCurrentTime:()=>this._currentTime,isPaused:()=>this._paused}),this._directTimelineClock=new Tt({onTimeUpdate:(i,s)=>{var n;this._currentTime=i,(n=this.controlsApi)==null||n.updateTime(i,s),this._emit(new CustomEvent("timeupdate",{detail:{currentTime:i}}))},getLoop:()=>this.loop,restart:()=>{var i;this.seek(((i=this._playRange())==null?void 0:i.start)??0),this.play()},onPaused:()=>{var i;this._media.audioOwner==="parent"&&this._media.pauseAll(),this._paused=!0,(i=this.controlsApi)==null||i.updatePlaying(!1),this._emit(new Event("ended"))},onEnded:()=>this.loop}),this.probe=new ht(this.iframe,{resolveRuntimeUrl:()=>He(this),hostOwnsDeadline:()=>this.hasAttribute("no-load-timeout"),onReady:i=>this._onProbeReady(i),onError:i=>this._emit(new CustomEvent("error",{detail:{message:i}}))}),this.addEventListener("click",i=>{this.disableClickToPlay||gt(i)||(this._paused?this.play():this.pause())}),this.resizeObserver=new ResizeObserver(()=>this._rescale()),this._onMessage=this._onMessage.bind(this),this._onIframeLoad=this._onIframeLoad.bind(this),this.iframe.addEventListener("load",this._onIframeLoad)}static get observedAttributes(){return["src","srcdoc","width","height","controls","muted","audio-locked","volume","poster","playback-rate","audio-src","type",J,se,D,N,x,te,I,O]}connectedCallback(){this._connected=!0,this._applySandboxOriginPolicy(),this.resizeObserver.observe(this),window.addEventListener("message",this._onMessage),this.hasAttribute("controls")&&this._setupControls(),this.hasAttribute("poster")&&(this.posterEl=ke(this.shadow,this.getAttribute("poster"),this.posterEl)),this.hasAttribute("audio-src")&&this._media.setupFromUrl(this.getAttribute("audio-src")),this.hasAttribute("srcdoc")&&(this.iframe.srcdoc=z(this,this.getAttribute("srcdoc"))),this.hasAttribute("src")&&this._loadSrc(this.getAttribute("src")),!this.hasAttribute("audio-locked")&&this._isLockedHostEnvironment()&&this._applyAudioLock(!0)}disconnectedCallback(){var e;this._connected=!1,this._teardownVideo(),this._sendControl("pause"),this._stopIframeMedia(),this.resizeObserver.disconnect(),window.removeEventListener("message",this._onMessage),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._pendingPlay=!1,this._abandonComposition("Player disconnected before runtime data was applied")}attributeChangedCallback(e,i,s){var n,o,a,c,p;switch(e){case"src":if(!this.isConnected)break;(s||this._videoSource)&&this._navigateSrc(s??"");break;case"type":{const l=this.getAttribute("src");if(!this.isConnected||l===null||!!this._videoSource===this._wantsVideo())break;this._navigateSrc(l);break}case"srcdoc":if(!this.isConnected)break;if(this._pendingPlay=!1,this._abandonComposition("Composition navigated before runtime data was applied"),s!==null)this._pauseForVideoSwitch(),this._teardownVideo(),this.iframe.srcdoc=z(this,s);else{this.iframe.removeAttribute("srcdoc");const l=this.getAttribute("src");l!==null&&this._wantsVideo()&&this._navigateSrc(l)}break;case J:this._applySandboxOriginPolicy(this.isConnected&&i!==s);break;case"width":this._setCompositionSize(Y(s)??1920,this._compositionHeight);break;case"height":this._setCompositionSize(this._compositionWidth,Y(s)??1080);break;case"controls":s!==null?this._setupControls():((n=this.controlsApi)==null||n.destroy(),this.controlsApi=null);break;case"poster":this.posterEl=ke(this.shadow,s,this.posterEl);break;case"playback-rate":{const l=ie(parseFloat(s||"1"));this._media.updatePlaybackRate(l),this._sendControl("set-playback-rate",{playbackRate:l}),(a=(o=this._directTimelineAdapter)==null?void 0:o.timeScale)==null||a.call(o,l),(c=this.controlsApi)==null||c.updateSpeed(l),this._emit(new Event("ratechange"));break}case"muted":this._handleMutedChange(s);break;case"audio-locked":this._applyAudioLock(s!==null);break;case"volume":{const l=Math.max(0,Math.min(1,parseFloat(s||"1")));this._volume=l,this._syncVideoAudio(),this._media.updateVolume(l),this._sendControl("set-volume",{volume:l}),(p=this.controlsApi)==null||p.updateVolume(l),this._emit(new Event("volumechange"));break}case"audio-src":s?this._media.setupFromUrl(s):this._media.teardownUrlAudio();break;case x:s==="none"&&this.shaderLoader.hideAssetsLoading();break;case te:this._sendControl("set-idle-heartbeat",{slow:s!==null});break;case I:case O:this._applyPlayRange(!0);break;case D:case N:case se:if(!this.isConnected)break;this._reloadShaderOptions();break}}_applySandboxOriginPolicy(e=!1){this.hasAttribute(J)?this.iframe.sandbox.remove("allow-same-origin"):this.iframe.sandbox.add("allow-same-origin"),e&&this._reloadForSandboxOriginPolicy()}_reloadForSandboxOriginPolicy(){if(this._videoSource)return;this._abandonComposition("Sandbox policy changed before runtime data was applied");const e=this.getAttribute("srcdoc");if(e!==null){this.iframe.srcdoc=z(this,e);return}const i=this.getAttribute("src");i===null?this.iframe.src="about:blank":this._loadSrc(i)}get iframeElement(){return this.iframe}get scenes(){return this._scenes}play(){this._play(!0)}_play(e){var o,a;if(this._ready&&!this._assetsReady){this._pendingPlay=!0;return}this._pendingPlay=!1,(o=this.posterEl)==null||o.remove(),this.posterEl=null;const i=this._ready?this._playRange():null;i?Le(this._currentTime,i,this._duration,this._runtimeFps)&&(this.seek(i.start),this._enteringRange=!0):this._duration>0&&this._currentTime>=this._duration&&this.seek(0),this._paused=!1;const s=this._tryDirectTimelinePlay();let n=!1;this._sendDisplayScale(),s||(this._sendControl("play"),this._ready&&!this._directTimelineAdapter?this._startParentTickClock():this._ready||(this._pendingPlay=!0,n=!0)),this._media.audioOwner==="parent"?this._media.playAll():this._media.primeAll(),(a=this.controlsApi)==null||a.updatePlaying(!0),!n&&e&&this._emit(new Event("play")),s&&this._directTimelineAdapter&&this._directTimelineClock.start(this._directTimelineAdapter,()=>this._currentTime,()=>this._duration,()=>this._paused,()=>this._clockStop())}pause(){var e;this._pendingPlay=!1,this._tryDirectTimelinePause()?this._showPausedVideoTime():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._emit(new Event("pause"))}stopMedia(){this._sendControl("stop-media"),this._stopIframeMedia(),this._media.stopAdoptedMedia()}seek(e){var i,s;this._pendingPlay=!1,!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,(i=this.controlsApi)==null||i.updatePlaying(!1),(s=this.controlsApi)==null||s.updateTime(this._currentTime,this._duration)}setColorGrading(e,i){this._sendControl("set-color-grading",{target:e,grading:i})}clearColorGrading(e){this._sendControl("set-color-grading",{target:e,grading:null})}setColorGradingCompare(e,i){this._sendControl("set-color-grading-compare",{target:e,compare:i})}clearColorGradingCompare(e){this._sendControl("set-color-grading-compare",{target:e,compare:{enabled:!1}})}setRuntimeData(e,i){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 s=structuredClone(i);this._runtimeData.set(e,s),this._deliverRuntimeData(e,s)}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 compositionWidth(){return this._compositionWidth}get compositionHeight(){return this._compositionHeight}get paused(){return this._paused}get ready(){return this._ready}get assetsReady(){return this._assetsReady}get painted(){return this._painted}get playbackRate(){return ie(parseFloat(this.getAttribute("playback-rate")||"1"))}set playbackRate(e){this.setAttribute("playback-rate",String(ie(e)))}get shaderCaptureScale(){return Qt(this)}set shaderCaptureScale(e){this.setAttribute(D,String(e))}get shaderLoading(){return K(this)}set shaderLoading(e){e==="composition"?this.removeAttribute(N):this.setAttribute(N,e)}get assetsLoadingUi(){return this.getAttribute(x)==="none"?"none":"player"}set assetsLoadingUi(e){e==="none"?this.setAttribute(x,"none"):this.removeAttribute(x)}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 i;if(e===null&&this._isAudioLocked()){this.setAttribute("muted","");return}this._media.updateMuted(e!==null),this._syncVideoAudio(),this._setIframeMediaMuted(e!==null),this._sendControl("set-muted",{muted:e!==null}),(i=this.controlsApi)==null||i.updateMuted(e!==null),this._emit(new Event("volumechange"))}_applyAudioLock(e){var i;e&&(this.muted=!0),(i=this.controlsApi)==null||i.setVolumeControlsHidden(e)}get volume(){return this._volume}set volume(e){this.setAttribute("volume",String(Math.max(0,Math.min(1,e))))}get disableClickToPlay(){return this.hasAttribute(Ne)}set disableClickToPlay(e){this.toggleAttribute(Ne,e)}get loop(){return this.hasAttribute("loop")}set loop(e){e?this.setAttribute("loop",""):this.removeAttribute("loop")}get rangeStart(){return this._readSeconds(I)}set rangeStart(e){this._writeSeconds(I,e)}get rangeEnd(){return this._readSeconds(O)}set rangeEnd(e){this._writeSeconds(O,e)}_readSeconds(e){const i=this.getAttribute(e);return i===null?null:Number(i)}_writeSeconds(e,i){i==null?this.removeAttribute(e):this.setAttribute(e,String(i))}_hasPlayRange(){return this.hasAttribute(I)||this.hasAttribute(O)}_playRange(){return Pe(this.rangeStart,this.rangeEnd,this._duration).range}_sendPlayRange(e){const i=(e==null?void 0:e.end)??null;this._sendControl("set-play-range",{startSeconds:(e==null?void 0:e.start)??null,endSeconds:i})}_applyPlayRange(e){const{range:i,clamped:s}=Pe(this.rangeStart,this.rangeEnd,this._duration);this._sendPlayRange(i),this._ready&&(this._reportRangeClamp(i,s),i&&e&&!this._pendingPlay&&this._moveIntoPlayRange(i))}_reportRangeClamp(e,i){const s=i?`${this.rangeStart},${this.rangeEnd},${this._duration}`:"";if(s===this._rangeClampReported||(this._rangeClampReported=s,!i))return;const n={rangeStart:(e==null?void 0:e.start)??null,rangeEnd:(e==null?void 0:e.end)??null};this._emit(new CustomEvent("rangeclamped",{detail:{...n,duration:this._duration}}))}_moveIntoPlayRange(e){Le(this._currentTime,e,this._duration,this._runtimeFps)&&(this._paused?this.seek(e.start):this._jumpWhilePlaying(e.start))}_jumpWhilePlaying(e){this._directTimelineAdapter?(this._directTimelineAdapter.seek(e,!1),this._currentTime=e):this._runtimeOwnsPlayRange||(this.seek(e),this._enteringRange=!0,this._play(!1))}_clockStop(){const e=this._playRange(),i=(e==null?void 0:e.end)??this._duration;if(!e)return{end:i,shown:i};const s=re(e,this._duration,this._runtimeFps);return{end:i,shown:s<i?(s+i)/2:s}}_sendControl(e,i={}){try{const s=this.iframe.contentWindow;return s?(s.postMessage({...i,source:"hf-parent",type:"control",action:e,...et(this._runtimeFps)},"*"),!0):((e==="set-runtime-data"||e==="clear-runtime-data")&&this._rejectRuntimeDataDelivery(i.channel,i.requestId,"Composition iframe is unavailable"),!1)}catch(s){return(e==="set-runtime-data"||e==="clear-runtime-data")&&this._rejectRuntimeDataDelivery(i.channel,i.requestId,s instanceof Error?s.message:String(s)),!1}}_deliverRuntimeData(e,i){if(!this.isConnected||!this._runtimeBridgeReady)return;const s=this._beginRuntimeDataDelivery(e);this._trySetRuntimeDataDirect(e,i,s)||this._sendControl("set-runtime-data",{channel:e,payload:i,requestId:s})}_deliverRuntimeDataClear(e){if(!this.isConnected||!this._runtimeBridgeReady)return;const i=this._beginRuntimeDataDelivery(e);this._tryClearRuntimeDataDirect(e,i)||this._sendControl("clear-runtime-data",{channel:e,requestId:i})}_trySetRuntimeDataDirect(e,i,s){var n;try{const o=(n=this.iframe.contentWindow)==null?void 0:n.__hyperframes;return typeof(o==null?void 0:o.setRuntimeData)!="function"?!1:(o.setRuntimeData(e,i,s),!0)}catch{return!1}}_tryClearRuntimeDataDirect(e,i){var s;try{const n=(s=this.iframe.contentWindow)==null?void 0:s.__hyperframes;return typeof(n==null?void 0:n.clearRuntimeData)!="function"?!1:(n.clearRuntimeData(e,i),!0)}catch{return!1}}_replayRuntimeData(){for(const[e,i]of this._runtimeData)this._deliverRuntimeData(e,i)}_beginRuntimeDataDelivery(e){const i=this._pendingRuntimeData.get(e);i&&window.clearTimeout(i.timeoutId),this._runtimeDataRequestId+=1;const s=this._runtimeDataRequestId,n=window.setTimeout(()=>{this._rejectRuntimeDataDelivery(e,s,`Runtime data delivery timed out after ${Oe}ms`)},Oe);return this._pendingRuntimeData.set(e,{requestId:s,timeoutId:n}),s}_resolveRuntimeDataDelivery(e,i){const s=this._takeRuntimeDataDelivery(e,i);s&&this._emit(new CustomEvent("runtimedataapplied",{detail:{channel:e,requestId:s.requestId}}))}_rejectRuntimeDataDelivery(e,i,s){const n=this._takeRuntimeDataDelivery(e,i);n&&this._emit(new CustomEvent("runtimedataerror",{detail:{channel:e,requestId:n.requestId,message:typeof s=="string"?s:String(s)}}))}_takeRuntimeDataDelivery(e,i){if(typeof e!="string"||typeof i!="number"||!Number.isSafeInteger(i))return null;const s=this._pendingRuntimeData.get(e);return!s||s.requestId!==i?null:(window.clearTimeout(s.timeoutId),this._pendingRuntimeData.delete(e),s)}_rejectAllRuntimeDataDeliveries(e){for(const[i,s]of[...this._pendingRuntimeData])this._rejectRuntimeDataDelivery(i,s.requestId,e)}_getSameOriginIframeDocument(){try{return this.iframe.contentDocument}catch{return null}}_setIframeMediaMuted(e){const i=this._getSameOriginIframeDocument();if(i)for(const s of i.querySelectorAll("video, audio"))A(s)&&(s.muted=e||s.defaultMuted)}_stopIframeMedia(){const e=this._getSameOriginIframeDocument();if(e)for(const i of e.querySelectorAll("video, audio"))A(i)&&i.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()}),this._sendControl("set-idle-heartbeat",{slow:this.hasAttribute(te)}),this._sendDisplayScale()}_sendDisplayScale(){const e=tt(this.iframe);e&&this._sendControl("set-display-scale",{scale:e})}_reloadShaderOptions(){if(!this._videoSource){if(this._abandonComposition("Shader options changed before runtime data was applied"),this.hasAttribute("srcdoc")){this.iframe.srcdoc=z(this,this.getAttribute("srcdoc")||"");return}this.hasAttribute("src")&&this._loadSrc(this.getAttribute("src")||"")}}_navigateSrc(e){this._pendingPlay=!1,this._pauseForVideoSwitch(),this._abandonComposition("Composition navigated before runtime data was applied"),this._loadSrc(e)}_wantsVideo(){return ri(this.getAttribute("type"))&&!this.hasAttribute("srcdoc")}_pauseForVideoSwitch(){var e;!this._videoSource&&!this._wantsVideo()||(this._paused=!0,(e=this.controlsApi)==null||e.updatePlaying(!1))}_loadSrc(e){if(this._wantsVideo()){this._loadVideo(e);return}this._teardownVideo(),this.iframe.src=ei(this,e)}_loadVideo(e){var n,o;this._videoSource||(this._videoSource=ni({onMetadata:a=>this._applyThenEmit(()=>this._onVideoReady(a)),onDurationChange:a=>this._applyTimelineDuration(a.duration),onResize:a=>this._applyVideoSize(a),onPlay:a=>{!a.paused&&this._paused&&this.play()},onPause:a=>{a.paused&&!a.ended&&!this._paused&&this.pause()},onTimeUpdate:()=>{document.hidden&&this._playRange()&&this._directTimelineClock.poll()},onError:(a,c)=>{this._paused||this.pause(),this._emit(new CustomEvent("error",{detail:{message:a,code:c}}))},onPlayRejected:a=>this._onVideoPlayRejected(a)}),this.container.appendChild(this._videoSource.video),this.iframe.hidden=!0,this.iframe.src="about:blank"),this.probe.stop();const{video:i,adapter:s}=this._videoSource;this._directTimelineAdapter=s,this._currentTime=0,this._duration=0,(n=this.controlsApi)==null||n.updateTime(0,0),this._syncVideoAudio(),(o=s.timeScale)==null||o.call(s,this.playbackRate),e?i.src=e:(i.removeAttribute("src"),i.load())}_teardownVideo(){this._videoSource&&(this._videoSource.destroy(),this._videoSource=null,this.iframe.hidden=!1)}_syncVideoAudio(){this._videoSource&&(this._videoSource.video.muted=this.muted,this._videoSource.video.volume=this._volume)}_onVideoReady(e){this._applyTimelineDuration(e.duration),this._applyVideoSize(e),this._ready=!0,this._dispatchReady(),this._waitForAssetsReady(null),this._afterEvents(()=>{this.hasAttribute("autoplay")&&this._paused&&this.play()})}_applyTimelineDuration(e){var i;!Number.isFinite(e)||e<=0||(this._setDuration(e),(i=this.controlsApi)==null||i.updateTime(this._currentTime,e))}_applyVideoSize(e){e.videoWidth>0&&e.videoHeight>0&&this._setCompositionSize(e.videoWidth,e.videoHeight)}_onVideoPlayRejected(e){e instanceof DOMException&&e.name==="NotAllowedError"&&(this._paused||this.pause(),this._emit(new CustomEvent("playbackerror",{detail:{source:"video",error:e}})))}_trySyncSeek(e){if(this._videoSource)return!1;try{const i=this.iframe.contentWindow,s=i==null?void 0:i.__player;return typeof(s==null?void 0:s.seek)!="function"?!1:(s.seek.call(s,e),!0)}catch{return!1}}_withDirectTimeline(e){const i=this._videoSource?null:this.probe.resolveDirectTimelineAdapter(),s=i||this._directTimelineAdapter;if(!s)return!1;try{return e(s),i&&i!==this._directTimelineAdapter&&this._applyTimelineDuration(i.duration()),this._directTimelineAdapter=s,!0}catch{return!1}}_tryDirectTimelineSeek(e){return this._withDirectTimeline(i=>{i.seek(e,!1),i.pause()})}_tryDirectTimelinePlay(){return this._withDirectTimeline(e=>void e.play())}_tryDirectTimelinePause(){return this._withDirectTimeline(e=>void e.pause())}_showPausedVideoTime(){var e;this._videoSource&&(this._currentTime=this._videoSource.video.currentTime,(e=this.controlsApi)==null||e.updateTime(this._currentTime,this._duration),this._emit(new CustomEvent("timeupdate",{detail:{currentTime:this._currentTime}})))}_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){this._videoSource||this.probe.failed||this._applyThenEmit(()=>this._handleRuntimeMessage(e))}_handleRuntimeMessage(e){qt(e,this.iframe.contentWindow,{getPlaybackState:()=>({currentTime:this._currentTime,duration:this._duration,paused:this._paused,lastUpdateMs:this._lastUpdateMs,enteringRange:this._enteringRange}),setPlaybackState:({currentTime:i,duration:s,paused:n,lastUpdateMs:o,enteringRange:a})=>{this._enteringRange=a===!0,this._currentTime=i,this._setDuration(s),this._paused=n,this._lastUpdateMs=o},getShaderLoadingMode:()=>K(this),shaderLoader:this.shaderLoader,setCompositionSize:(i,s)=>this._setCompositionSize(i,s),sendControl:(i,s)=>this._sendControl(i,s),getIframeDoc:()=>this.iframe.contentDocument,onRuntimeReady:()=>{this._runtimeBridgeReady=!0,this._replayBridgeState(),this._hasPlayRange()&&this._sendPlayRange(this._playRange()),this._replayRuntimeData()},onRuntimeAssetsReady:()=>{this._runtimeAssetsReadyGeneration===this._assetsGeneration&&this._settleAssetsReady(this._assetsGeneration)},onRuntimeDataApplied:(i,s)=>this._resolveRuntimeDataDelivery(i,s),onRuntimeDataError:(i,s,n)=>this._rejectRuntimeDataDelivery(i,s,n),onRuntimeTimelineReady:(i,s)=>this._onRuntimeTimelineReady(i,s),setBuffering:i=>this._setBuffering(i),setRuntimeFps:i=>{this._runtimeFps=i},setRuntimeOwnsPlayRange:i=>{this._runtimeOwnsPlayRange=i},shouldPromoteMediaAutoplayFallback:()=>!this._isSlideshowPlayer(),setScenes:i=>{this._scenes=i,this._emit(new CustomEvent("scenes",{detail:{scenes:i}}))},updateControlsTime:(i,s)=>{var n;return(n=this.controlsApi)==null?void 0:n.updateTime(i,s)},updateControlsPlaying:i=>{var s;return(s=this.controlsApi)==null?void 0:s.updatePlaying(i)},dispatchEvent:i=>this._emit(i),seek:i=>this.seek(i),play:()=>this.play(),getLoop:()=>this.loop,getPlayRange:()=>this._playRange(),media:this._media})}_onRuntimeTimelineReady(e,i){var n;if(this._ready)return;this.probe.stop(),this._setDuration(e),this._directTimelineAdapter=null,this._ready=!0,(n=this.controlsApi)==null||n.updateTime(this._currentTime,e),this._dispatchReady();const s=this._getSameOriginIframeDocument();s&&this._media.setupFromIframe(s),this._replayBridgeState(),this._setIframeMediaMuted(this.muted),this._waitForAssetsReady(s,i),this._playWhenWanted()}_onProbeReady(e){this._applyThenEmit(()=>this._applyProbeResult(e))}_applyProbeResult({duration:e,adapter:i,compositionSize:s}){var o;this._setDuration(e),this._directTimelineAdapter=i.kind==="direct-timeline"?i.timeline:null,s&&this._setCompositionSize(s.width,s.height),this._ready=!0,(o=this.controlsApi)==null||o.updateTime(0,e),this._dispatchReady();const n=this._getSameOriginIframeDocument();n&&this._media.setupFromIframe(n),this._setIframeMediaMuted(this.muted),this._waitForAssetsReady(n),this._playWhenWanted()}_waitForAssetsReady(e,i){this._clearAssetsLoadingShowTimer(),this._assetsReady=!1,this._painted=!1;const s=++this._assetsGeneration;if(!e){i===!1?(this._runtimeAssetsReadyGeneration=s,this._startAssetsLoadingOverlayTimer(s),setTimeout(()=>this._settleAssetsReady(s),Q)):this._settleAssetsReady(s);return}it(e,({timedOut:n})=>{s===this._assetsGeneration&&(n&&this._warnStuckAssets(e),this._settleAssetsReady(s))},{timeoutMs:Q}),this._assetsReady||this._startAssetsLoadingOverlayTimer(s)}_startAssetsLoadingOverlayTimer(e){this._assetsLoadingShowTimer=setTimeout(()=>{this._assetsLoadingShowTimer=null,!(e!==this._assetsGeneration||this._assetsReady)&&(this.setAttribute(ee,""),this.assetsLoadingUi!=="none"&&this.shaderLoader.showAssetsLoading())},Fe)}_setBuffering(e){if(e){if(this._bufferingShowTimer!==null||this.hasAttribute(j))return;this._bufferingShowTimer=setTimeout(()=>{this._bufferingShowTimer=null,this.setAttribute(j,""),this.assetsLoadingUi!=="none"&&this.shaderLoader.showAssetsLoading("Buffering","")},Fe);return}this._bufferingShowTimer!==null&&clearTimeout(this._bufferingShowTimer),this._bufferingShowTimer=null,this.hasAttribute(j)&&(this.removeAttribute(j),this.shaderLoader.hideAssetsLoading())}_hasPendingFirstFrameAssets(e){const{pendingMedia:i,pendingImages:s,fontsLoading:n}=Se(e,{scope:Te});return i.length>0||s.length>0||n}_warnStuckAssets(e){const{pendingMedia:i,pendingImages:s,fontsLoading:n}=Se(e,{scope:Te}),o=e.defaultView;console.warn(`[hyperframes-player] assets-loading timed out after ${Q}ms, playing anyway`,{stuckMedia:i.map(a=>a.currentSrc||a.getAttribute("src")||`<${a.tagName.toLowerCase()}>`),stuckImages:s.map(a=>a.currentSrc||a.getAttribute("src")||"<img>"),fontsLoading:n,computeReady:(o==null?void 0:o.__renderReady)===!0,documentHidden:e.hidden===!0})}_settleAssetsReady(e){e!==this._assetsGeneration||this._assetsReady||(this._clearAssetsLoadingShowTimer(),this._assetsReady=!0,this.removeAttribute(ee),this.shaderLoader.hideAssetsLoading(),this._emit(new Event("assetsready")),this.shaderLoader.whenHidden(()=>{e===this._assetsGeneration&&(this._painted=!0,this._emit(new Event("painted")))}),this._afterEvents(()=>{this._pendingPlay&&this.play()}))}_abandonComposition(e){this.probe.stop(),this._ready=!1,this._readyDocument=null,this._invalidateAssetsWait(),this._releaseDocument(),this._runtimeBridgeReady=!1,this._rejectAllRuntimeDataDeliveries(e)}_releaseDocument(){this._runtimeOwnsPlayRange=!1,this._enteringRange=!1,this._directTimelineAdapter=null,this._directTimelineClock.stop(),this._stopParentTickClock(),this._setBuffering(!1),this.shaderLoader.reset(),this._media.resetForIframeLoad()}_invalidateAssetsWait(){this._clearAssetsLoadingShowTimer(),this._assetsReady=!1,this._painted=!1,this._assetsGeneration++,this.removeAttribute(ee),this.shaderLoader.hide()}_clearAssetsLoadingShowTimer(){this._assetsLoadingShowTimer!==null&&(clearTimeout(this._assetsLoadingShowTimer),this._assetsLoadingShowTimer=null)}_dispatchReady(){this._readyDocument=this._getSameOriginIframeDocument();const e={duration:this._duration,compositionWidth:this._compositionWidth,compositionHeight:this._compositionHeight};this._emit(new CustomEvent("ready",{detail:e})),this._rescale(),this._rangeClampReported="",this._hasPlayRange()&&this._applyPlayRange(!0)}_setDuration(e){e!==this._duration&&(this._duration=e,this._ready&&(this._emit(new CustomEvent("durationchange",{detail:{duration:e}})),this._hasPlayRange()&&this._applyPlayRange(!1)))}_setCompositionSize(e,i){const s=e!==this._compositionWidth||i!==this._compositionHeight;if(this._compositionWidth=e,this._compositionHeight=i,this.sizer.style.aspectRatio=`${e} / ${i}`,this._rescale(),!s)return;const n={compositionWidth:e,compositionHeight:i};this._emit(new CustomEvent("resize",{detail:n}))}_applyThenEmit(e){if(this._afterUpdate){e();return}const i=[];this._afterUpdate=i;const s=[],n=o=>{try{o()}catch(a){s.push(a)}};n(e);for(const o of i)n(o);if(this._afterUpdate=null,s.length>0)throw s[0]}_afterEvents(e){this._afterUpdate?this._afterUpdate.push(e):e()}_playWhenWanted(){this._afterEvents(()=>{(this.hasAttribute("autoplay")||this._pendingPlay)&&this.play()})}_emit(e){this._afterEvents(()=>this.dispatchEvent(e))}_rescale(){const e=bt(this,this.iframe,this._compositionWidth,this._compositionHeight);e&&this._sendDisplayScale(),!e&&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(){if(!this._connected||this._videoSource)return;const e=this._getSameOriginIframeDocument();if(this._ready&&e===this._readyDocument){e&&this._hasPendingFirstFrameAssets(e)&&this._waitForAssetsReady(e);return}this._ready=!1,this._invalidateAssetsWait(),this._releaseDocument(),this.probe.start()}_setupControls(){this.controlsApi||(this.controlsApi=_t(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()),this.controlsApi.updateTime(this._currentTime,this._duration),this.controlsApi.updatePlaying(!this._paused),this.controlsApi.updateSpeed(this.playbackRate))}get _audioOwner(){return this._media.audioOwner}get _parentMedia(){return this._media.entries}_mirrorParentMediaTime(e,i){this._media.mirrorTime(e,i)}_promoteToParentProxy(){let e=null;try{e=this.iframe.contentDocument}catch{}this._media.promoteToParentProxy(e,(i,s)=>this._mirrorParentMediaTime(i,s)),this._sendControl("set-media-output-muted",{muted:!0})}_observeDynamicMedia(e){this._media.setupFromIframe(e)}}customElements.get("hyperframes-player")||customElements.define("hyperframes-player",di);export{di as HyperframesPlayer,ft as SPEED_PRESETS,M as formatSpeed,Ce as formatTime};
|