@hyperframes/studio 0.4.3 → 0.4.5

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.
@@ -0,0 +1,198 @@
1
+ var S=Object.defineProperty;var R=(u,b,e)=>b in u?S(u,b,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[b]=e;var h=(u,b,e)=>R(u,typeof b!="symbol"?b+"":b,e);var N=`
2
+ :host {
3
+ display: block;
4
+ position: relative;
5
+ overflow: hidden;
6
+ background: #000;
7
+ contain: layout style;
8
+ }
9
+
10
+ .hfp-container {
11
+ position: absolute;
12
+ inset: 0;
13
+ overflow: hidden;
14
+ pointer-events: none;
15
+ }
16
+
17
+
18
+ .hfp-iframe {
19
+ position: absolute;
20
+ top: 50%;
21
+ left: 50%;
22
+ border: none;
23
+ pointer-events: none;
24
+ }
25
+
26
+ .hfp-poster {
27
+ position: absolute;
28
+ inset: 0;
29
+ object-fit: contain;
30
+ z-index: 1;
31
+ pointer-events: none;
32
+ }
33
+
34
+ /* ── Theming via CSS custom properties ──
35
+ *
36
+ * Override from outside the shadow DOM:
37
+ * hyperframes-player {
38
+ * --hfp-controls-bg: linear-gradient(transparent, rgba(0,0,0,0.9));
39
+ * --hfp-accent: #ff6b6b;
40
+ * --hfp-font: "Inter", sans-serif;
41
+ * }
42
+ */
43
+
44
+ .hfp-controls {
45
+ position: absolute;
46
+ bottom: 0;
47
+ left: 0;
48
+ right: 0;
49
+ display: flex;
50
+ align-items: center;
51
+ gap: var(--hfp-controls-gap, 12px);
52
+ padding: var(--hfp-controls-padding, 8px 16px);
53
+ background: var(--hfp-controls-bg, linear-gradient(transparent, rgba(0, 0, 0, 0.7)));
54
+ color: var(--hfp-color, #fff);
55
+ font-family: var(--hfp-font, system-ui, -apple-system, sans-serif);
56
+ font-size: var(--hfp-font-size, 13px);
57
+ z-index: 10;
58
+ pointer-events: auto;
59
+ opacity: 1;
60
+ transition: opacity 0.3s ease;
61
+ user-select: none;
62
+ }
63
+
64
+ .hfp-controls.hfp-hidden {
65
+ opacity: 0;
66
+ pointer-events: none;
67
+ }
68
+
69
+ .hfp-play-btn {
70
+ background: none;
71
+ border: none;
72
+ color: var(--hfp-color, #fff);
73
+ cursor: pointer;
74
+ padding: 8px;
75
+ display: flex;
76
+ align-items: center;
77
+ justify-content: center;
78
+ width: 40px;
79
+ height: 40px;
80
+ flex-shrink: 0;
81
+ z-index: 10;
82
+ }
83
+
84
+ .hfp-play-btn:hover {
85
+ opacity: 0.8;
86
+ }
87
+
88
+ .hfp-play-btn svg,
89
+ .hfp-play-btn svg * {
90
+ pointer-events: none;
91
+ }
92
+
93
+ .hfp-scrubber {
94
+ flex: 1;
95
+ height: var(--hfp-scrubber-height, 4px);
96
+ background: var(--hfp-scrubber-bg, rgba(255, 255, 255, 0.3));
97
+ border-radius: var(--hfp-scrubber-radius, 2px);
98
+ cursor: pointer;
99
+ position: relative;
100
+ }
101
+
102
+ .hfp-scrubber:hover {
103
+ height: var(--hfp-scrubber-height-hover, 6px);
104
+ }
105
+
106
+ .hfp-progress {
107
+ position: absolute;
108
+ top: 0;
109
+ left: 0;
110
+ height: 100%;
111
+ background: var(--hfp-accent, #fff);
112
+ border-radius: var(--hfp-scrubber-radius, 2px);
113
+ pointer-events: none;
114
+ }
115
+
116
+ .hfp-time {
117
+ flex-shrink: 0;
118
+ font-variant-numeric: tabular-nums;
119
+ opacity: 0.9;
120
+ }
121
+
122
+ .hfp-speed-wrap {
123
+ position: relative;
124
+ flex-shrink: 0;
125
+ }
126
+
127
+ .hfp-speed-btn {
128
+ background: var(--hfp-speed-btn-bg, rgba(255, 255, 255, 0.15));
129
+ border: none;
130
+ border-radius: var(--hfp-speed-btn-radius, 4px);
131
+ color: var(--hfp-color, #fff);
132
+ cursor: pointer;
133
+ font-family: var(--hfp-font, system-ui, -apple-system, sans-serif);
134
+ font-size: 12px;
135
+ font-variant-numeric: tabular-nums;
136
+ font-weight: 600;
137
+ padding: 4px 8px;
138
+ min-width: 40px;
139
+ text-align: center;
140
+ transition: background 0.15s ease;
141
+ }
142
+
143
+ .hfp-speed-btn:hover {
144
+ background: var(--hfp-speed-btn-bg-hover, rgba(255, 255, 255, 0.3));
145
+ }
146
+
147
+ .hfp-speed-menu {
148
+ position: absolute;
149
+ bottom: calc(100% + 8px);
150
+ right: 0;
151
+ background: var(--hfp-menu-bg, rgba(20, 20, 20, 0.95));
152
+ backdrop-filter: blur(12px);
153
+ -webkit-backdrop-filter: blur(12px);
154
+ border: 1px solid var(--hfp-menu-border, rgba(255, 255, 255, 0.1));
155
+ border-radius: var(--hfp-menu-radius, 8px);
156
+ padding: 4px;
157
+ display: flex;
158
+ flex-direction: column;
159
+ gap: 2px;
160
+ min-width: 80px;
161
+ opacity: 0;
162
+ visibility: hidden;
163
+ transform: translateY(4px);
164
+ transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
165
+ box-shadow: var(--hfp-menu-shadow, 0 8px 24px rgba(0, 0, 0, 0.4));
166
+ }
167
+
168
+ .hfp-speed-menu.hfp-open {
169
+ opacity: 1;
170
+ visibility: visible;
171
+ transform: translateY(0);
172
+ }
173
+
174
+ .hfp-speed-option {
175
+ background: none;
176
+ border: none;
177
+ border-radius: 4px;
178
+ color: var(--hfp-menu-color, rgba(255, 255, 255, 0.7));
179
+ cursor: pointer;
180
+ font-family: var(--hfp-font, system-ui, -apple-system, sans-serif);
181
+ font-size: 13px;
182
+ font-variant-numeric: tabular-nums;
183
+ padding: 6px 12px;
184
+ text-align: left;
185
+ transition: background 0.1s ease, color 0.1s ease;
186
+ white-space: nowrap;
187
+ }
188
+
189
+ .hfp-speed-option:hover {
190
+ background: var(--hfp-menu-hover-bg, rgba(255, 255, 255, 0.1));
191
+ color: var(--hfp-color, #fff);
192
+ }
193
+
194
+ .hfp-speed-option.hfp-active {
195
+ color: var(--hfp-accent, #fff);
196
+ font-weight: 600;
197
+ }
198
+ `,T='<svg width="24" height="24" viewBox="0 0 18 18" fill="currentColor"><polygon points="4,2 16,9 4,16"/></svg>',D='<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>',H=[.25,.5,1,1.5,2,4];function x(u){return Number.isInteger(u)?`${u}x`:`${u}x`}function O(u){if(!Number.isFinite(u)||u<0)return"0:00";let b=Math.floor(u),e=Math.floor(b/60),t=b%60;return`${e}:${t.toString().padStart(2,"0")}`}function F(u,b,e={}){let t=e.speedPresets??H,i=document.createElement("div");i.className="hfp-controls",i.addEventListener("click",n=>{n.stopPropagation()});let a=document.createElement("button");a.className="hfp-play-btn",a.type="button",a.innerHTML=T,a.setAttribute("aria-label","Play");let r=document.createElement("div");r.className="hfp-scrubber";let o=document.createElement("div");o.className="hfp-progress",o.style.width="0%",r.appendChild(o);let p=document.createElement("span");p.className="hfp-time",p.textContent="0:00 / 0:00";let c=document.createElement("div");c.className="hfp-speed-wrap";let s=document.createElement("button");s.className="hfp-speed-btn",s.type="button",s.textContent="1x",s.setAttribute("aria-label","Playback speed");let l=document.createElement("div");l.className="hfp-speed-menu",l.setAttribute("role","menu");for(let n of t){let d=document.createElement("button");d.className="hfp-speed-option",d.type="button",d.setAttribute("role","menuitem"),d.dataset.speed=String(n),d.textContent=x(n),n===1&&d.classList.add("hfp-active"),l.appendChild(d)}c.appendChild(l),c.appendChild(s),i.appendChild(a),i.appendChild(r),i.appendChild(p),i.appendChild(c),u.appendChild(i);let m=!1,f=null;t.indexOf(1),a.addEventListener("click",n=>{n.stopPropagation(),m?b.onPause():b.onPlay()});let y=n=>{for(let d of l.querySelectorAll(".hfp-speed-option"))d.classList.toggle("hfp-active",d.dataset.speed===String(n))};s.addEventListener("click",n=>{n.stopPropagation();let d=l.classList.toggle("hfp-open");s.setAttribute("aria-expanded",String(d))}),l.addEventListener("click",n=>{n.stopPropagation();let d=n.target.closest(".hfp-speed-option");if(!d)return;let _=parseFloat(d.dataset.speed);t.indexOf(_),s.textContent=x(_),y(_),l.classList.remove("hfp-open"),s.setAttribute("aria-expanded","false"),b.onSpeedChange(_)});let E=()=>{l.classList.remove("hfp-open"),s.setAttribute("aria-expanded","false")};document.addEventListener("click",E);let w=n=>{let d=r.getBoundingClientRect(),_=Math.max(0,Math.min(1,(n-d.left)/d.width));b.onSeek(_)},g=!1;r.addEventListener("mousedown",n=>{n.stopPropagation(),g=!0,w(n.clientX)});let M=n=>{g&&w(n.clientX)},P=()=>{g=!1};document.addEventListener("mousemove",M),document.addEventListener("mouseup",P),r.addEventListener("touchstart",n=>{g=!0;let d=n.touches[0];d&&w(d.clientX)},{passive:!0});let A=n=>{if(g){let d=n.touches[0];d&&w(d.clientX)}},C=()=>{g=!1};document.addEventListener("touchmove",A,{passive:!0}),document.addEventListener("touchend",C);let L=()=>{f&&clearTimeout(f),f=setTimeout(()=>{m&&i.classList.add("hfp-hidden")},3e3)},I=u instanceof ShadowRoot?u.host:u;return I.addEventListener("mousemove",()=>{i.classList.remove("hfp-hidden"),L()}),I.addEventListener("mouseleave",()=>{m&&i.classList.add("hfp-hidden")}),{updateTime(n,d){let _=d>0?n/d*100:0;o.style.width=`${_}%`,p.textContent=`${O(n)} / ${O(d)}`},updatePlaying(n){m=n,a.innerHTML=n?D:T,a.setAttribute("aria-label",n?"Pause":"Play"),n?L():i.classList.remove("hfp-hidden")},updateSpeed(n){t.indexOf(n),s.textContent=x(n),y(n)},show(){i.style.display=""},hide(){i.style.display="none"},destroy(){document.removeEventListener("mousemove",M),document.removeEventListener("mouseup",P),document.removeEventListener("touchmove",A),document.removeEventListener("touchend",C),document.removeEventListener("click",E),f&&clearTimeout(f)}}}var k=30,j="https://cdn.jsdelivr.net/npm/@hyperframes/core/dist/hyperframe.runtime.iife.js",v,z=(v=class extends HTMLElement{constructor(){super();h(this,"shadow");h(this,"container");h(this,"iframe");h(this,"posterEl",null);h(this,"controlsApi",null);h(this,"resizeObserver");h(this,"_ready",!1);h(this,"_duration",0);h(this,"_currentTime",0);h(this,"_paused",!0);h(this,"_compositionWidth",1920);h(this,"_compositionHeight",1080);h(this,"_probeInterval",null);h(this,"_lastUpdateMs",0);h(this,"_parentMedia",[]);h(this,"_audioOwner","runtime");h(this,"_mediaObserver");h(this,"_playbackErrorPosted",!1);h(this,"_runtimeInjected",!1);this.shadow=this.attachShadow({mode:"open"});let e=document.createElement("style");e.textContent=N,this.shadow.appendChild(e),this.container=document.createElement("div"),this.container.className="hfp-container",this.iframe=document.createElement("iframe"),this.iframe.className="hfp-iframe",this.iframe.sandbox.add("allow-scripts","allow-same-origin"),this.iframe.allow="autoplay; fullscreen",this.iframe.referrerPolicy="no-referrer",this.iframe.title="HyperFrames Composition",this.container.appendChild(this.iframe),this.shadow.appendChild(this.container),this.addEventListener("click",t=>{this._isControlsClick(t)||(this._paused?this.play():this.pause())}),this.resizeObserver=new ResizeObserver(()=>this._updateScale()),this._onMessage=this._onMessage.bind(this),this._onIframeLoad=this._onIframeLoad.bind(this)}static get observedAttributes(){return["src","width","height","controls","muted","poster","playback-rate","audio-src"]}connectedCallback(){this.resizeObserver.observe(this),window.addEventListener("message",this._onMessage),this.iframe.addEventListener("load",this._onIframeLoad),this.hasAttribute("controls")&&this._setupControls(),this.hasAttribute("poster")&&this._setupPoster(),this.hasAttribute("audio-src")&&this._setupParentAudioFromUrl(this.getAttribute("audio-src")),this.hasAttribute("src")&&(this.iframe.src=this.getAttribute("src"))}disconnectedCallback(){var e;this.resizeObserver.disconnect(),window.removeEventListener("message",this._onMessage),this.iframe.removeEventListener("load",this._onIframeLoad),this._probeInterval&&clearInterval(this._probeInterval),this._teardownMediaObserver(),(e=this.controlsApi)==null||e.destroy();for(let t of this._parentMedia)t.el.pause(),t.el.src="";this._parentMedia=[]}attributeChangedCallback(e,t,i){var a,r;switch(e){case"src":i&&(this._ready=!1,this.iframe.src=i);break;case"width":this._compositionWidth=parseInt(i||"1920",10),this._updateScale();break;case"height":this._compositionHeight=parseInt(i||"1080",10),this._updateScale();break;case"controls":i!==null?this._setupControls():((a=this.controlsApi)==null||a.destroy(),this.controlsApi=null);break;case"poster":this._setupPoster();break;case"playback-rate":{let o=parseFloat(i||"1");for(let p of this._parentMedia)p.el.playbackRate=o;this._sendControl("set-playback-rate",{playbackRate:o}),(r=this.controlsApi)==null||r.updateSpeed(o),this.dispatchEvent(new Event("ratechange"));break}case"muted":for(let o of this._parentMedia)o.el.muted=i!==null;this._sendControl("set-muted",{muted:i!==null});break;case"audio-src":i&&this._setupParentAudioFromUrl(i);break}}get iframeElement(){return this.iframe}play(){var e;this._hidePoster(),this._sendControl("play"),this._audioOwner==="parent"&&this._playParentMedia(),this._paused=!1,(e=this.controlsApi)==null||e.updatePlaying(!0),this.dispatchEvent(new Event("play"))}pause(){var e;this._sendControl("pause"),this._audioOwner==="parent"&&this._pauseParentMedia(),this._paused=!0,(e=this.controlsApi)==null||e.updatePlaying(!1),this.dispatchEvent(new Event("pause"))}seek(e){var i,a;let t=Math.round(e*k);if(this._sendControl("seek",{frame:t}),this._currentTime=e,this._audioOwner==="parent")for(let r of this._parentMedia){let o=e-r.start;o>=0&&o<r.duration&&(r.el.currentTime=o)}this._paused=!0,(i=this.controlsApi)==null||i.updatePlaying(!1),(a=this.controlsApi)==null||a.updateTime(this._currentTime,this._duration)}get currentTime(){return this._currentTime}set currentTime(e){this.seek(e)}get duration(){return this._duration}get paused(){return this._paused}get ready(){return this._ready}get playbackRate(){return parseFloat(this.getAttribute("playback-rate")||"1")}set playbackRate(e){this.setAttribute("playback-rate",String(e))}get muted(){return this.hasAttribute("muted")}set muted(e){e?this.setAttribute("muted",""):this.removeAttribute("muted")}get loop(){return this.hasAttribute("loop")}set loop(e){e?this.setAttribute("loop",""):this.removeAttribute("loop")}_sendControl(e,t={}){var i;try{(i=this.iframe.contentWindow)==null||i.postMessage({source:"hf-parent",type:"control",action:e,...t},"*")}catch{}}_isControlsClick(e){return e.composedPath().some(t=>t instanceof HTMLElement&&t.classList.contains("hfp-controls"))}_onMessage(e){var i,a,r,o;if(e.source!==this.iframe.contentWindow)return;let t=e.data;if(!(!t||t.source!=="hf-preview")){if(t.type==="state"){this._currentTime=(t.frame??0)/k;let p=!this._paused;this._paused=!t.isPlaying,this._audioOwner==="parent"&&(p&&this._paused?this._pauseParentMedia():!p&&!this._paused&&this._playParentMedia(),this._mirrorParentMediaTime(this._currentTime));let c=performance.now();(c-this._lastUpdateMs>100||this._paused!==p)&&(this._lastUpdateMs=c,(i=this.controlsApi)==null||i.updateTime(this._currentTime,this._duration),(a=this.controlsApi)==null||a.updatePlaying(!this._paused),this.dispatchEvent(new CustomEvent("timeupdate",{detail:{currentTime:this._currentTime}}))),this._currentTime>=this._duration&&!this._paused&&(this._audioOwner==="parent"&&this._pauseParentMedia(),this.loop?(this.seek(0),this.play()):(this._paused=!0,(r=this.controlsApi)==null||r.updatePlaying(!1),this.dispatchEvent(new Event("ended"))))}t.type==="media-autoplay-blocked"&&this._promoteToParentProxy(),t.type==="timeline"&&t.durationInFrames>0&&Number.isFinite(t.durationInFrames)&&(this._duration=t.durationInFrames/k,(o=this.controlsApi)==null||o.updateTime(this._currentTime,this._duration)),t.type==="stage-size"&&t.width>0&&t.height>0&&(this._compositionWidth=t.width,this._compositionHeight=t.height,this._updateScale())}}_onIframeLoad(){let e=0;this._runtimeInjected=!1;let t=this._audioOwner==="parent";this._audioOwner="runtime",this._playbackErrorPosted=!1,this._pauseParentMedia(),this._teardownMediaObserver(),t&&this.dispatchEvent(new CustomEvent("audioownershipchange",{detail:{owner:"runtime",reason:"iframe-reload"}})),this._probeInterval&&clearInterval(this._probeInterval),this._probeInterval=setInterval(()=>{var i,a;e++;try{let r=this.iframe.contentWindow;if(!r)return;let o=!!(r.__hf||r.__player),p=!!(r.__timelines&&Object.keys(r.__timelines).length>0);if(!o&&p&&!this._runtimeInjected&&e>=5){this._injectRuntime();return}if(this._runtimeInjected&&!o)return;let c=(()=>{var s,l;if(r.__player&&typeof r.__player.getDuration=="function")return r.__player;if(r.__timelines){let m=Object.keys(r.__timelines);if(m.length>0){let f=(l=(s=this.iframe.contentDocument)==null?void 0:s.querySelector("[data-composition-id]"))==null?void 0:l.getAttribute("data-composition-id"),y=f&&f in r.__timelines?f:m[m.length-1],E=r.__timelines[y];return{getDuration:()=>E.duration()}}}return null})();if(c&&c.getDuration()>0){clearInterval(this._probeInterval),this._duration=c.getDuration(),this._ready=!0,(i=this.controlsApi)==null||i.updateTime(0,this._duration),this.dispatchEvent(new CustomEvent("ready",{detail:{duration:this._duration}}));let s=(a=this.iframe.contentDocument)==null?void 0:a.querySelector("[data-composition-id]");if(s){let l=parseInt(s.getAttribute("data-width")||"0",10),m=parseInt(s.getAttribute("data-height")||"0",10);l>0&&m>0&&(this._compositionWidth=l,this._compositionHeight=m,this._updateScale())}this._setupParentMedia(),this.hasAttribute("autoplay")&&this.play();return}}catch{}e>=40&&(clearInterval(this._probeInterval),this.dispatchEvent(new CustomEvent("error",{detail:{message:"Composition timeline not found after 8s"}})))},200)}_injectRuntime(){this._runtimeInjected=!0;try{let e=this.iframe.contentDocument;if(!e)return;let t=e.createElement("script");t.src=j,t.onload=()=>{},t.onerror=()=>{},(e.head||e.documentElement).appendChild(t)}catch{}}_updateScale(){let e=this.getBoundingClientRect();if(e.width===0||e.height===0)return;let t=Math.min(e.width/this._compositionWidth,e.height/this._compositionHeight);this.iframe.style.width=`${this._compositionWidth}px`,this.iframe.style.height=`${this._compositionHeight}px`,this.iframe.style.transform=`translate(-50%, -50%) scale(${t})`}_setupControls(){if(this.controlsApi)return;let e={onPlay:()=>this.play(),onPause:()=>this.pause(),onSeek:a=>this.seek(a*this._duration),onSpeedChange:a=>{this.playbackRate=a}},t=this.getAttribute("speed-presets"),i=t?t.split(",").map(Number).filter(a=>!isNaN(a)&&a>0):void 0;this.controlsApi=F(this.shadow,e,{speedPresets:i})}_setupPoster(){var t;let e=this.getAttribute("poster");if(!e){(t=this.posterEl)==null||t.remove(),this.posterEl=null;return}this.posterEl||(this.posterEl=document.createElement("img"),this.posterEl.className="hfp-poster",this.shadow.appendChild(this.posterEl)),this.posterEl.src=e}_playParentMedia(){for(let e of this._parentMedia)e.el.src&&e.el.play().catch(t=>this._reportPlaybackError(t))}_reportPlaybackError(e){this._playbackErrorPosted||(this._playbackErrorPosted=!0,this.dispatchEvent(new CustomEvent("playbackerror",{detail:{source:"parent-proxy",error:e}})))}_pauseParentMedia(){for(let e of this._parentMedia)e.el.pause()}_mirrorParentMediaTime(e){for(let t of this._parentMedia){let i=e-t.start;i<0||i>=t.duration||Math.abs(t.el.currentTime-i)>v.MIRROR_DRIFT_THRESHOLD_SECONDS&&(t.el.currentTime=i)}}_promoteToParentProxy(){this._audioOwner!=="parent"&&(this._audioOwner="parent",this._sendControl("set-media-output-muted",{muted:!0}),this._mirrorParentMediaTime(this._currentTime),this._paused||this._playParentMedia(),this.dispatchEvent(new CustomEvent("audioownershipchange",{detail:{owner:"parent",reason:"autoplay-blocked"}})))}_createParentMedia(e,t,i,a){if(this._parentMedia.some(p=>p.el.src===e))return null;let r=t==="video"?document.createElement("video"):new Audio;r.preload="auto",r.src=e,r.load(),r.muted=this.muted,this.playbackRate!==1&&(r.playbackRate=this.playbackRate);let o={el:r,start:i,duration:a};return this._parentMedia.push(o),o}_setupParentAudioFromUrl(e){this._createParentMedia(e,"audio",0,1/0)}_setupParentMedia(){try{let e=this.iframe.contentDocument;if(!e)return;let t=e.querySelectorAll("audio[data-start], video[data-start]");for(let i of t)this._adoptIframeMedia(i);this._observeDynamicMedia(e)}catch{}}_adoptIframeMedia(e){var c;let t=e.getAttribute("src")||((c=e.querySelector("source"))==null?void 0:c.getAttribute("src"));if(!t)return;let i=new URL(t,e.ownerDocument.baseURI).href,a=parseFloat(e.getAttribute("data-start")||"0"),r=parseFloat(e.getAttribute("data-duration")||"Infinity"),o=e.tagName==="VIDEO"?"video":"audio",p=this._createParentMedia(i,o,a,r);p&&this._audioOwner==="parent"&&(this._mirrorParentMediaTime(this._currentTime),!this._paused&&p.el.src&&p.el.play().catch(s=>this._reportPlaybackError(s)))}_observeDynamicMedia(e){if(this._teardownMediaObserver(),typeof MutationObserver>"u"||!e.body)return;let t=new MutationObserver(i=>{var a,r,o,p;for(let c of i){for(let s of c.addedNodes){if(!(s instanceof Element))continue;let l=[];(a=s.matches)!=null&&a.call(s,"audio[data-start], video[data-start]")&&l.push(s);let m=(r=s.querySelectorAll)==null?void 0:r.call(s,"audio[data-start], video[data-start]");if(m)for(let f of m)l.push(f);for(let f of l)this._adoptIframeMedia(f)}for(let s of c.removedNodes){if(!(s instanceof Element))continue;let l=[];(o=s.matches)!=null&&o.call(s,"audio[data-start], video[data-start]")&&l.push(s);let m=(p=s.querySelectorAll)==null?void 0:p.call(s,"audio[data-start], video[data-start]");if(m)for(let f of m)l.push(f);for(let f of l)this._detachIframeMedia(f)}}});t.observe(e.body,{childList:!0,subtree:!0}),this._mediaObserver=t}_teardownMediaObserver(){var e;(e=this._mediaObserver)==null||e.disconnect(),this._mediaObserver=void 0}_detachIframeMedia(e){var o;let t=e.getAttribute("src")||((o=e.querySelector("source"))==null?void 0:o.getAttribute("src"));if(!t)return;let i=new URL(t,e.ownerDocument.baseURI).href,a=this._parentMedia.findIndex(p=>p.el.src===i);if(a===-1)return;let r=this._parentMedia[a];r.el.pause(),r.el.src="",this._parentMedia.splice(a,1)}_hidePoster(){var e;(e=this.posterEl)==null||e.remove(),this.posterEl=null}},h(v,"MIRROR_DRIFT_THRESHOLD_SECONDS",.05),v);customElements.get("hyperframes-player")||customElements.define("hyperframes-player",z);export{z as HyperframesPlayer,H as SPEED_PRESETS,x as formatSpeed,O as formatTime};