@hyperframes/player 0.8.58 → 0.8.60
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/chunk-QJ3QTT32.js +2 -0
- package/dist/chunk-QJ3QTT32.js.map +1 -0
- package/dist/hyperframes-player.cjs +3 -3
- package/dist/hyperframes-player.cjs.map +1 -1
- package/dist/hyperframes-player.global.js +3 -3
- package/dist/hyperframes-player.global.js.map +1 -1
- package/dist/hyperframes-player.js +3 -3
- package/dist/hyperframes-player.js.map +1 -1
- package/dist/slideshow/hyperframes-slideshow.js +21 -21
- package/dist/slideshow/hyperframes-slideshow.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function
|
|
1
|
+
import"./chunk-QJ3QTT32.js";function ut(n){return n.hasRuntime||n.runtimeInjected?!1:!!(n.hasNestedCompositions||n.hasTimelines&&n.attempts>=5)}function H(n){return typeof n=="object"&&n!==null}function lt(n){return H(n)&&typeof n.getDuration=="function"}function dt(n){return H(n)&&typeof n.duration=="function"&&typeof n.time=="function"&&typeof n.seek=="function"&&typeof n.play=="function"&&typeof n.pause=="function"}var L="https://cdn.jsdelivr.net/npm/@hyperframes/core@0.8.60/dist/hyperframe.runtime.iife.js";function V(n){if(n===null)return null;let e=Number.parseInt(n,10);return Number.isFinite(e)&&e>0?e:null}function mn(n){let e=n?.querySelector("[data-composition-id][data-width][data-height]")??n?.querySelector("[data-width][data-height]");if(!e)return null;let t=V(e.getAttribute("data-width")),i=V(e.getAttribute("data-height"));return t!==null&&i!==null?{width:t,height:i}:null}var te=class{constructor(e,t){this._iframe=e;this._callbacks=t}_iframe;_callbacks;_interval=null;_runtimeInjected=!1;get runtimeInjected(){return this._runtimeInjected}start(){this.stop(),this._runtimeInjected=!1;let e=0;this._interval=setInterval(()=>{e++;try{let t=this._iframe.contentWindow;if(!t)return;let i=!!(t.__hf||t.__player),r=!!(t.__timelines&&Object.keys(t.__timelines).length>0),o=!!this._iframe.contentDocument?.querySelector("[data-composition-src]");if(ut({hasRuntime:i,hasTimelines:r,hasNestedCompositions:o,runtimeInjected:this._runtimeInjected,attempts:e})){this._injectRuntime();return}if(this._runtimeInjected&&!i)return;let a=this._resolvePlaybackDurationAdapter(t);if(a&&a.getDuration()>0){this.stop();let s=mn(this._iframe.contentDocument);this._callbacks.onReady({duration:a.getDuration(),adapter:a,compositionSize:s});return}}catch{}e>=40&&(this.stop(),this._callbacks.onError("Composition timeline not found after 8s"))},200)}stop(){this._interval!==null&&(clearInterval(this._interval),this._interval=null)}resolveDirectTimelineAdapter(){try{let e=this._iframe.contentWindow;return e?this._resolveDirectTimelineAdapterFromWindow(e):null}catch{return null}}resolveDirectTimelineAdapterFromWindow(e){return this._resolveDirectTimelineAdapterFromWindow(e)}hasRuntimeBridge(e){return Reflect.get(e,"__hf")!==void 0||H(Reflect.get(e,"__player"))}_injectRuntime(){this._runtimeInjected=!0;try{let e=this._iframe.contentDocument;if(!e)return;let t=e.createElement("script");t.src=L,(e.head||e.documentElement).appendChild(t),this._callbacks.onRuntimeInjected?.()}catch{}}_resolveDirectTimelineAdapterFromWindow(e){if(this.hasRuntimeBridge(e))return null;let t=Reflect.get(e,"__timelines");if(!H(t))return null;let i=Object.keys(t);if(i.length===0)return null;let r=this._iframe.contentDocument?.querySelector("[data-composition-id]")?.getAttribute("data-composition-id"),o=r&&r in t?r:i[i.length-1],a=t[o];return dt(a)?a:null}_resolvePlaybackDurationAdapter(e){let t=Reflect.get(e,"__player");if(lt(t))return{kind:"runtime",getDuration:()=>t.getDuration()};let i=this._resolveDirectTimelineAdapterFromWindow(e);return i?{kind:"direct-timeline",timeline:i,getDuration:()=>i.duration()}:null}};var ct=`
|
|
2
2
|
:host {
|
|
3
3
|
display: block;
|
|
4
4
|
position: relative;
|
|
@@ -460,6 +460,6 @@ function Re(r){return r.hasRuntime||r.runtimeInjected?!1:!!(r.hasNestedCompositi
|
|
|
460
460
|
background: var(--hfp-accent, #fff);
|
|
461
461
|
pointer-events: none;
|
|
462
462
|
}
|
|
463
|
-
`,Me='<svg width="24" height="24" viewBox="46 21 54 56" fill="currentColor"><path d="M87.5129 57.5141L56.9696 73.5433C52.8371 75.7098 48.7046 73.2553 49.6688 69.2104L58.9483 30.1391C59.9125 26.0942 65.2097 23.6397 68.3154 25.8062L91.2447 41.8354C96.4668 45.4796 94.4631 53.8699 87.5129 57.5141Z"/></svg>',Le='<svg width="24" height="24" viewBox="0 0 18 18" fill="currentColor"><rect x="3" y="2" width="4" height="14"/><rect x="11" y="2" width="4" height="14"/></svg>',J='<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>',K='<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>',De='<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>';var Ie=[.25,.5,1,1.5,2,4];function G(r){return Number.isInteger(r)?`${r}x`:`${r}x`}function ee(r){if(!Number.isFinite(r)||r<0)return"0:00";let e=Math.floor(r),t=Math.floor(e/60),i=e%60;return`${t}:${i.toString().padStart(2,"0")}`}function Pe(r,e,t={}){let i=t.speedPresets??Ie,n=document.createElement("div");n.className="hfp-controls",n.addEventListener("click",d=>{d.stopPropagation()});let o=document.createElement("button");o.className="hfp-play-btn",o.type="button",o.innerHTML=`<span class="hfp-ico hfp-ico-play">${Me}</span><span class="hfp-ico hfp-ico-pause">${Le}</span>`,o.setAttribute("aria-label","Play");let s=document.createElement("div");s.className="hfp-scrubber";let a=document.createElement("div");a.className="hfp-progress",a.style.width="0%",s.appendChild(a);let u=document.createElement("span");u.className="hfp-time",u.textContent="0:00 / 0:00";let c=document.createElement("div");c.className="hfp-speed-wrap";let p=document.createElement("button");p.className="hfp-speed-btn",p.type="button",p.textContent="1x",p.setAttribute("aria-label","Playback speed");let g=document.createElement("div");g.className="hfp-speed-menu",g.setAttribute("role","menu");for(let d of i){let l=document.createElement("button");l.className="hfp-speed-option",l.type="button",l.setAttribute("role","menuitem"),l.dataset.speed=String(d),l.textContent=G(d),d===1&&l.classList.add("hfp-active"),g.appendChild(l)}c.appendChild(g),c.appendChild(p);let y=document.createElement("div");y.className="hfp-volume-wrap";let f=document.createElement("button");f.className="hfp-mute-btn",f.type="button",f.innerHTML=J,f.setAttribute("aria-label","Mute");let S=document.createElement("div");S.className="hfp-volume-slider-wrap";let m=document.createElement("div");m.className="hfp-volume-slider",m.setAttribute("role","slider"),m.setAttribute("aria-label","Volume"),m.setAttribute("aria-valuemin","0"),m.setAttribute("aria-valuemax","100"),m.setAttribute("aria-valuenow","100"),m.tabIndex=0;let E=document.createElement("div");E.className="hfp-volume-fill",E.style.width="100%",m.appendChild(E),S.appendChild(m),y.appendChild(S),y.appendChild(f),t.audioLocked&&(y.style.display="none"),n.appendChild(o),n.appendChild(s),n.appendChild(u),n.appendChild(y),n.appendChild(c),r.appendChild(n);let U=!1,R=!1,T=1,I=null,V=i.indexOf(1);V===-1&&(V=0);let W=(d,l)=>d?De:l===0?K:l<.5?K:J;o.addEventListener("click",d=>{d.stopPropagation(),U?e.onPause():e.onPlay()}),f.addEventListener("click",d=>{d.stopPropagation(),e.onMuteToggle()});let C=!1,j=d=>{let l=m.getBoundingClientRect(),_=Math.max(0,Math.min(1,(d-l.left)/l.width));T=_,E.style.width=`${_*100}%`,m.setAttribute("aria-valuenow",String(Math.round(_*100))),R&&_>0&&e.onMuteToggle(),f.innerHTML=W(R,_),e.onVolumeChange(_)};m.addEventListener("mousedown",d=>{d.stopPropagation(),C=!0,j(d.clientX)});let pe=d=>{C&&j(d.clientX)},he=()=>{C=!1};document.addEventListener("mousemove",pe),document.addEventListener("mouseup",he),m.addEventListener("touchstart",d=>{C=!0;let l=d.touches[0];l&&j(l.clientX)},{passive:!0});let me=d=>{if(C){let l=d.touches[0];l&&j(l.clientX)}},fe=()=>{C=!1};document.addEventListener("touchmove",me,{passive:!0}),document.addEventListener("touchend",fe);let _e=.05;m.addEventListener("keydown",d=>{let l=T;if(d.key==="ArrowRight"||d.key==="ArrowUp")l=Math.min(1,T+_e);else if(d.key==="ArrowLeft"||d.key==="ArrowDown")l=Math.max(0,T-_e);else return;d.preventDefault(),d.stopPropagation(),T=l,E.style.width=`${l*100}%`,m.setAttribute("aria-valuenow",String(Math.round(l*100))),R&&l>0&&e.onMuteToggle(),f.innerHTML=W(R,l),e.onVolumeChange(l)});let ve=d=>{for(let l of g.querySelectorAll(".hfp-speed-option"))l.classList.toggle("hfp-active",l.dataset.speed===String(d))};p.addEventListener("click",d=>{d.stopPropagation();let l=g.classList.toggle("hfp-open");p.setAttribute("aria-expanded",String(l))}),g.addEventListener("click",d=>{d.stopPropagation();let l=d.target.closest(".hfp-speed-option");if(!l)return;let _=parseFloat(l.dataset.speed);V=i.indexOf(_),p.textContent=G(_),ve(_),g.classList.remove("hfp-open"),p.setAttribute("aria-expanded","false"),e.onSpeedChange(_)});let ge=()=>{g.classList.remove("hfp-open"),p.setAttribute("aria-expanded","false")};document.addEventListener("click",ge);let $=d=>{let l=s.getBoundingClientRect(),_=Math.max(0,Math.min(1,(d-l.left)/l.width));e.onSeek(_)},A=!1;s.addEventListener("mousedown",d=>{d.stopPropagation(),A=!0,e.onScrubStart?.(),$(d.clientX)});let be=d=>{A&&$(d.clientX)},ye=()=>{A&&(A=!1,e.onScrubEnd?.())};document.addEventListener("mousemove",be),document.addEventListener("mouseup",ye),s.addEventListener("touchstart",d=>{A=!0,e.onScrubStart?.();let l=d.touches[0];l&&$(l.clientX)},{passive:!0});let Ee=d=>{if(A){let l=d.touches[0];l&&$(l.clientX)}},Se=()=>{A&&(A=!1,e.onScrubEnd?.())};document.addEventListener("touchmove",Ee,{passive:!0}),document.addEventListener("touchend",Se);let Ae=()=>{I&&clearTimeout(I),I=setTimeout(()=>{U&&n.classList.add("hfp-hidden")},3e3)},z=r instanceof ShadowRoot?r.host:r,Te=()=>{n.classList.remove("hfp-hidden"),Ae()},we=()=>{U&&n.classList.add("hfp-hidden")};return z.addEventListener("mousemove",Te),z.addEventListener("mouseleave",we),{updateTime(d,l){let _=l>0?Math.min(d,l):d,nt=l>0?_/l*100:0;a.style.width=`${nt}%`,u.textContent=`${ee(_)} / ${ee(l)}`},updatePlaying(d){U=d,o.classList.toggle("hfp-playing",d),o.setAttribute("aria-label",d?"Pause":"Play"),d?Ae():n.classList.remove("hfp-hidden")},updateSpeed(d){let l=i.indexOf(d);l!==-1&&(V=l),p.textContent=G(d),ve(d)},updateMuted(d){R=d,f.innerHTML=W(d,T),f.setAttribute("aria-label",d?"Unmute":"Mute")},updateVolume(d){T=d,E.style.width=`${d*100}%`,m.setAttribute("aria-valuenow",String(Math.round(d*100))),f.innerHTML=W(R,d)},setVolumeControlsHidden(d){y.style.display=d?"none":""},show(){n.style.display=""},hide(){n.style.display="none"},destroy(){document.removeEventListener("mousemove",be),document.removeEventListener("mouseup",ye),document.removeEventListener("touchmove",Ee),document.removeEventListener("touchend",Se),document.removeEventListener("mousemove",pe),document.removeEventListener("mouseup",he),document.removeEventListener("touchmove",me),document.removeEventListener("touchend",fe),document.removeEventListener("click",ge),z.removeEventListener("mousemove",Te),z.removeEventListener("mouseleave",we),I&&clearTimeout(I),n.remove()}}}function Oe(r,e,t,i,n,o=!1){let s=i?i.split(",").map(Number).filter(c=>!isNaN(c)&&c>0):void 0,a={...s?{speedPresets:s}:{},audioLocked:o},u=Pe(r,n,a);return u.updateMuted(e),u.updateVolume(t),u}function te(r,e,t){return e?(t||(t=document.createElement("img"),t.className="hfp-poster",r.appendChild(t)),t.src=e,t):(t?.remove(),null)}function Ne(r){return r.composedPath().some(e=>e instanceof HTMLElement&&e.classList.contains("hfp-controls"))}var q=null;function Fe(r,e){if(typeof CSSStyleSheet<"u")try{q||(q=new CSSStyleSheet,q.replaceSync(e)),r.adoptedStyleSheets=[q];return}catch{}let t=document.createElement("style");t.textContent=e,r.appendChild(t)}function He(){let r=document.createElement("div");r.className="hfp-container";let e=document.createElement("iframe");return e.className="hfp-iframe",e.sandbox.add("allow-scripts","allow-same-origin"),e.allow="autoplay; fullscreen",e.referrerPolicy="no-referrer",e.title="HyperFrames Composition",r.appendChild(e),{container:r,iframe:e}}function Ue(r,e,t,i){let n=r.offsetWidth,o=r.offsetHeight;if(n===0||o===0)return!1;let s=Math.min(n/t,o/i);return e.style.width=`${t}px`,e.style.height=`${i}px`,e.style.transform=`translate(-50%, -50%) scale(${s})`,!0}var Y=class{constructor(e){this._callbacks=e}_callbacks;_raf=null;_lastUpdateMs=0;start(e,t,i,n){this.stop();let o=()=>{if(n()){this._raf=null;return}let s;try{s=e.time()}catch{this._raf=null;return}let a=i();a>0&&(s=Math.min(s,a));let u=a>0&&s>=a,c=performance.now();if((c-this._lastUpdateMs>100||u)&&(this._lastUpdateMs=c,this._callbacks.onTimeUpdate(s,a)),u){if(this._callbacks.getLoop()){this._callbacks.restart();return}try{e.pause()}catch{}this._callbacks.onPaused(),this._raf=null;return}this._raf=requestAnimationFrame(o)};this._raf=requestAnimationFrame(o)}stop(){this._raf!==null&&(cancelAnimationFrame(this._raf),this._raf=null)}get isRunning(){return this._raf!==null}};function Ve(r){let e=Array.from(r.querySelectorAll("[data-composition-id]"));if(e.length===0)return r.body?[r.body]:[];let t=[];for(let i of e)at(i)||t.push(i);return st(r),t}function st(r){let e=r.body;if(!e||typeof console>"u"||typeof console.warn!="function")return;let t=e.querySelectorAll("audio[data-start], video[data-start]");if(t.length===0)return;let i=[];for(let n of t)n.closest("[data-composition-id]")||i.push(n);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 at(r){let e=r.parentElement;for(;e;){if(e.hasAttribute("data-composition-id"))return!0;e=e.parentElement}return!1}function N(r){let e=r.ownerDocument?.defaultView;return e&&r instanceof e.Element?!0:r instanceof Element}function b(r){if(!N(r)||r.tagName!=="AUDIO"&&r.tagName!=="VIDEO")return!1;let e=r.ownerDocument?.defaultView;return e&&r instanceof e.HTMLMediaElement?!0:r instanceof HTMLMediaElement}function re(r){let e=Array.from(r.querySelectorAll("video, audio")).filter(b).filter(n=>n.readyState<3),t=Array.from(r.querySelectorAll("img")).filter(n=>!n.complete),i=r.fonts?.status==="loading";return{pendingMedia:e,pendingImages:t,fontsLoading:i}}function dt(r,{pendingMedia:e,pendingImages:t,fontsLoading:i},n){let o=e.map(u=>new Promise(c=>{if(u.error){c();return}let p=()=>{u.removeEventListener("canplay",p),u.removeEventListener("error",p),n.removeEventListener("abort",p),c()};u.addEventListener("canplay",p),u.addEventListener("error",p),n.addEventListener("abort",p,{once:!0})})),s=t.map(u=>u.decode?u.decode().catch(()=>{}):Promise.resolve()),a=i&&r.fonts?r.fonts.ready.then(()=>{}):Promise.resolve();return Promise.all([...o,...s,a]).then(()=>{})}function lt(r,e){let t=re(r);return t.pendingMedia.length===0&&t.pendingImages.length===0&&!t.fontsLoading?null:dt(r,t,e)}var ut=50;function ct(r,e){let t=r.defaultView;return!t||t.__renderReady||!t.__hf?null:new Promise(i=>{let n,o=()=>{n!==void 0&&clearTimeout(n),e.removeEventListener("abort",o),i()};if(e.aborted){o();return}e.addEventListener("abort",o,{once:!0});let s=()=>{if(t.__renderReady){o();return}n=setTimeout(s,ut)};s()})}var pt=50,ht=2,mt=1500;function ie(r,e){return new Promise(t=>{if(e.aborted){t(-1);return}let i=0,n=()=>{r.cancelAnimationFrame?.(i),t(-1)};e.addEventListener("abort",n,{once:!0}),i=r.requestAnimationFrame(o=>{e.removeEventListener("abort",n),t(o)})})}function ft(r,e){let t=r.defaultView;return t?(async()=>{let i=await ie(t,e);if(e.aborted)return;let n=await ie(t,e),o=0;for(;!e.aborted&&o<ht;){if(n-i>=mt)return;let s=await ie(t,e);if(e.aborted)return;o=s-n<pt?o+1:0,n=s}})():null}var _t=8e3;function We(r,e,t={}){let i=t.inputs??[lt,ct,ft],n=new AbortController,o=i.map(c=>c(r,n.signal)).filter(c=>c!==null);if(o.length===0){e({timedOut:!1});return}let s=t.timeoutMs??_t,a,u=new Promise(c=>{a=setTimeout(()=>c("timed-out"),s)});Promise.race([Promise.all(o).then(()=>"done"),u]).then(c=>{clearTimeout(a),n.abort(),e({timedOut:c==="timed-out"})})}var je=(r,e,t)=>r>=e&&r<t;var h=Object.freeze({start:"data-start",duration:"data-duration",trackIndex:"data-track-index",derivedEnd:"data-end",legacyTrack:"data-layer"}),hi=Object.freeze([h.start,h.duration,h.trackIndex]),mi=Object.freeze([h.derivedEnd]),fi=Object.freeze([h.derivedEnd,h.legacyTrack]);function x(r){if(r==null||r.trim()==="")return null;let e=Number(r);return Number.isFinite(e)?e:null}var Be=/^[A-Za-z0-9_.:-]+$/;function Ge(r,e){let t=r.charCodeAt(e);return t>=48&&t<=57}function $e(r,e){let t=e;for(;t>=0&&Ge(r,t);)t--;return t}function vt(r,e){let t=e;for(;t>=0&&(r[t]??"").trim()==="";)t--;return t}function gt(r){let e=r.length-1;if(!Ge(r,e))return null;let t=$e(r,e);return r[t]==="."&&(t=$e(r,t-1)),t+1}function bt(r){let e=gt(r);if(e==null)return null;let t=vt(r,e-1),i=r[t];if(i!=="+"&&i!=="-")return null;let n=r.slice(0,t).trim();if(!Be.test(n))return null;let o=Number(r.slice(e));return Number.isFinite(o)?{refId:n,operator:i,magnitude:o}:null}function yt(r){let e=(r??"").trim();if(!e)return null;let t=x(e);if(t!=null)return{kind:"absolute",value:t};if(Be.test(e))return{kind:"reference",refId:e,offset:0};let i=bt(e);return i?{kind:"reference",refId:i.refId,offset:i.operator==="-"?-i.magnitude:i.magnitude}:null}function v(r,e,t,i){r.push({code:e,attribute:t,value:i})}function Et(r,e,t,i){if(e==null||e.trim()==="")return t.defaultStart===void 0?0:t.defaultStart;if(!r)return v(i,"invalid-start",h.start,e),null;if(r.kind==="absolute")return Math.max(0,r.value);let n=t.resolveReferenceEnd?.(r.refId);return n==null||!Number.isFinite(n)?(v(i,"unresolved-start-reference",h.start,e),null):Math.max(0,n+r.offset)}var St=1e-9;function At(r,e){return Math.abs(r-e)<=St}function Tt(r,e,t){let i=x(r);if(i==null){v(t,"deprecated-end",h.derivedEnd,r),v(t,"invalid-end",h.derivedEnd,r);return}if(e==null){v(t,"deprecated-end",h.derivedEnd,r);return}At(i,e)||(v(t,"deprecated-end",h.derivedEnd,r),v(t,"conflicting-end",h.derivedEnd,r))}function wt(r,e,t){let i=x(r);return i==null||i<0?(v(t,"invalid-duration",h.duration,r),{duration:null,end:null,durationSource:"invalid"}):{duration:i,end:e==null?null:e+i,durationSource:"duration"}}function Rt(r,e,t){v(t,"deprecated-end",h.derivedEnd,r);let i=x(r);return i==null?(v(t,"invalid-end",h.derivedEnd,r),{duration:null,end:null,durationSource:"invalid"}):e==null?{duration:null,end:i,durationSource:"legacy-end"}:i<e?(v(t,"end-before-start",h.derivedEnd,r),{duration:null,end:null,durationSource:"invalid"}):{duration:i-e,end:i,durationSource:"legacy-end"}}function Ct(r,e,t){let i=r.getAttribute(h.duration),n=r.getAttribute(h.derivedEnd);if(i==null)return n==null?{duration:null,end:null,durationSource:"missing"}:Rt(n,e,t);let o=wt(i,e,t);return n!=null&&Tt(n,o.end,t),o}function ze(r,e,t,i){let n=x(r);return n==null||!Number.isInteger(n)?(v(i,"invalid-track-index",e,r),{trackIndex:0,trackSource:"invalid"}):{trackIndex:n,trackSource:t}}function kt(r,e){let t=r.getAttribute(h.trackIndex),i=r.getAttribute(h.legacyTrack);if(t==null&&i==null)return{trackIndex:0,trackSource:"default"};if(t==null&&i!=null)return v(e,"deprecated-layer",h.legacyTrack,i),ze(i,h.legacyTrack,"legacy-layer",e);let n=ze(t??"",h.trackIndex,"track-index",e);if(i==null)return n;v(e,"deprecated-layer",h.legacyTrack,i);let o=x(i);return o!=null&&o!==n.trackIndex&&v(e,"conflicting-layer",h.legacyTrack,i),n}function ne(r,e={}){let t=[],i=r.getAttribute(h.start),n=yt(i),o=Et(n,i,e,t),s=Ct(r,o,t),a=kt(r,t);return{startExpression:n,start:o,...s,...a,diagnostics:t}}var xt=.05,Mt=2,X=class{_entries=[];_mediaObserver;_playbackErrorPosted=!1;_audioOwner="runtime";_urlAudioEntry=null;_urlAudioSrc=null;_dispatchEvent;_getMuted;_getVolume;_getPlaybackRate;_getCurrentTime;_isPaused;constructor(e){this._dispatchEvent=e.dispatchEvent,this._getMuted=e.getMuted,this._getVolume=e.getVolume,this._getPlaybackRate=e.getPlaybackRate,this._getCurrentTime=e.getCurrentTime,this._isPaused=e.isPaused}get audioOwner(){return this._audioOwner}get entries(){return this._entries}resetForIframeLoad(){this._playbackErrorPosted=!1;let e=this._audioOwner==="parent";this._audioOwner="runtime",this.pauseAll(),this.teardownObserver(),e&&this._dispatchEvent(new CustomEvent("audioownershipchange",{detail:{owner:"runtime",reason:"iframe-reload"}}))}destroy(){this.teardownObserver();for(let e of this._entries)e.el.pause(),e.el.src="";this._entries=[],this._urlAudioEntry=null,this._urlAudioSrc=null,this._audioOwner="runtime",this._playbackErrorPosted=!1}updateMuted(e){for(let t of this._entries)t.el.muted=e}updateVolume(e){for(let t of this._entries)t.el.volume=e}updatePlaybackRate(e){for(let t of this._entries)t.el.playbackRate=e}_playEntry(e){e.el.src&&e.el.play().catch(t=>this._reportPlaybackError(t))}_playEntryIfActive(e){this._refreshEntryBounds(e),this._inWindow(e,this._getCurrentTime())&&this._playEntry(e)}_refreshEntryBounds(e){if(!e.source?.isConnected)return;let t=ne(e.source);e.start=t.start??0,e.duration=t.duration!=null&&t.duration>0?t.duration:Number.POSITIVE_INFINITY}_inWindow(e,t){return je(t,e.start,e.start+e.duration)}_gateEntryPlayback(e,t){return this._inWindow(e,t)?(this._audioOwner==="parent"&&!this._isPaused()&&e.el.paused&&this._playEntry(e),!0):(e.el.paused||e.el.pause(),e.driftSamples=0,!1)}playAll(){for(let e of this._entries)this._playEntryIfActive(e)}pauseAll(){for(let e of this._entries)e.el.pause()}stopAdoptedMedia(){for(let e of this._entries)e.source&&e.el.pause()}seekAll(e){for(let t of this._entries)this._refreshEntryBounds(t),this._inWindow(t,e)&&(t.el.currentTime=e-t.start)}scrubAll(e){for(let t of this._entries)this._refreshEntryBounds(t),this._inWindow(t,e)?(t.el.currentTime=e-t.start,this._playEntry(t)):t.el.paused||t.el.pause()}mirrorTime(e,t){let i=t?.force===!0;for(let n of this._entries){if(this._refreshEntryBounds(n),!this._gateEntryPlayback(n,e))continue;let o=e-n.start;Math.abs(n.el.currentTime-o)>xt?(n.driftSamples+=1,(i||n.driftSamples>=Mt)&&(n.el.currentTime=o,n.driftSamples=0)):n.driftSamples=0}}promoteToParentProxy(e,t){if(this._audioOwner==="parent")return;if(this._audioOwner="parent",e)for(let n of e.querySelectorAll("video, audio"))b(n)&&(n.muted=!0);let i=this._getCurrentTime();t?t(i,{force:!0}):this.mirrorTime(i,{force:!0}),this._isPaused()||this.playAll(),this._dispatchEvent(new CustomEvent("audioownershipchange",{detail:{owner:"parent",reason:"autoplay-blocked"}}))}setupFromIframe(e){let t=e.querySelectorAll("audio[data-start], video[data-start]");for(let i of t)b(i)&&this._adoptIframeMedia(i);this._observeDynamicMedia(e)}setupFromUrl(e){if(this._urlAudioSrc===e&&this._urlAudioEntry)return;this.teardownUrlAudio();let t=this._createEntry(e,"audio",0,1/0);this._urlAudioEntry=t,this._urlAudioSrc=t?e:null,t&&this._audioOwner==="parent"&&!this._isPaused()&&(this.mirrorTime(this._getCurrentTime(),{force:!0}),this.playAll())}teardownUrlAudio(){let e=this._urlAudioEntry;if(this._urlAudioEntry=null,this._urlAudioSrc=null,!e)return;e.el.pause(),e.el.src="";let t=this._entries.indexOf(e);t!==-1&&this._entries.splice(t,1)}teardownObserver(){this._mediaObserver?.disconnect(),this._mediaObserver=void 0}_reportPlaybackError(e){this._playbackErrorPosted||(this._playbackErrorPosted=!0,this._dispatchEvent(new CustomEvent("playbackerror",{detail:{source:"parent-proxy",error:e}})))}_createEntry(e,t,i,n,o){if(this._entries.some(c=>c.el.src===e))return null;let s=t==="video"?document.createElement("video"):new Audio;s.preload="auto",s.src=e,s.load(),s.muted=this._getMuted(),s.volume=this._getVolume();let a=this._getPlaybackRate();a!==1&&(s.playbackRate=a);let u={el:s,start:i,duration:n,driftSamples:0,source:o};return this._entries.push(u),u}_resolveIframeMediaSrc(e){let t=e.getAttribute("src")||e.querySelector("source")?.getAttribute("src");return t?new URL(t,e.ownerDocument.baseURI).href:null}_adoptIframeMedia(e){if(e.preload==="metadata"||e.preload==="none")return;let t=this._resolveIframeMediaSrc(e);if(!t)return;let i=ne(e),n=i.start??0,o=i.duration??Number.POSITIVE_INFINITY,s=e.tagName==="VIDEO"?"video":"audio",a=this._createEntry(t,s,n,o,e);a&&this._audioOwner==="parent"&&(this.mirrorTime(this._getCurrentTime(),{force:!0}),this._isPaused()||this._playEntryIfActive(a))}_detachIframeMedia(e){let t=this._resolveIframeMediaSrc(e);if(!t)return;let i=this._entries.findIndex(o=>o.el.src===t);if(i===-1)return;let n=this._entries[i];n.el.pause(),n.el.src="",this._entries.splice(i,1)}_observeDynamicMedia(e){if(this.teardownObserver(),typeof MutationObserver>"u"||!e.body)return;let t=new MutationObserver(o=>{for(let s of o){if(s.type==="attributes"&&s.attributeName==="preload"){let a=s.target;b(a)&&a.matches("audio[data-start], video[data-start]")&&a.preload==="auto"&&this._adoptIframeMedia(a);continue}for(let a of s.addedNodes){if(!N(a))continue;let u=[];b(a)&&a.matches("audio[data-start], video[data-start]")&&u.push(a);let c=a.querySelectorAll("audio[data-start], video[data-start]");for(let p of c)b(p)&&u.push(p);for(let p of u)this._adoptIframeMedia(p)}for(let a of s.removedNodes){if(!N(a))continue;let u=[];b(a)&&a.matches("audio[data-start], video[data-start]")&&u.push(a);let c=a.querySelectorAll("audio[data-start], video[data-start]");for(let p of c)b(p)&&u.push(p);for(let p of u)this._detachIframeMedia(p)}}}),i={childList:!0,subtree:!0,attributes:!0,attributeFilter:["preload"]},n=Ve(e);for(let o of n)t.observe(o,i);this._mediaObserver=t}};function qe(r,e,t,i){let n=(r.frame??0)/e,o=t.duration>0?Math.min(n,t.duration):n,s=!t.paused,a=!r.isPlaying,u=t.duration>0&&o>=t.duration&&(s||r.isPlaying);if(u&&i.getLoop())return i.media.audioOwner==="parent"&&i.media.pauseAll(),i.seek(0),i.play(),{...t,currentTime:o,paused:!1};let c={...t,currentTime:o,paused:a};i.media.audioOwner==="parent"&&(s&&a?i.media.pauseAll():!s&&!a&&i.media.playAll(),i.media.mirrorTime(o));let p=performance.now(),g=a!==t.paused;return(p-t.lastUpdateMs>100||g)&&(c.lastUpdateMs=p,i.updateControlsTime(o,t.duration),i.updateControlsPlaying(!a),i.dispatchEvent(new CustomEvent("timeupdate",{detail:{currentTime:o}}))),u&&(i.media.audioOwner==="parent"&&i.media.pauseAll(),c.paused=!0,i.updateControlsPlaying(!1),i.dispatchEvent(new Event("ended"))),c}var Lt=["seconds-time","rational-fps","seek-keep-playing","composition-manifest-v1","runtime-data"];function Dt(r,e){let t=Math.abs(r),i=Math.abs(e);for(;i!==0;){let n=t%i;t=i,i=n}return t||1}function It(r){let e=Number.isFinite(r)&&r>0?r:30,t=Number.isInteger(e)?1:1e6,i=Math.round(e*t),n=Dt(i,t);return{numerator:i/n,denominator:t/n}}function Pt(r){if(typeof r!="object"||r===null)return null;let e=r;return!Number.isFinite(e.numerator)||!Number.isFinite(e.denominator)||(e.numerator??0)<=0||(e.denominator??0)<=0?null:Number(e.numerator)/Number(e.denominator)}function Ye(r){return{protocolVersion:1,capabilities:Lt,fps:It(r)}}function Ot(r){return Array.isArray(r)&&r.every(e=>typeof e=="string")}function Xe(r,e=30){if(typeof r!="object"||r===null)return{status:"legacy",fps:e};let t=r;if(t.protocolVersion===void 0)return{status:"legacy",fps:e};if(t.protocolVersion!==1)return{status:"unsupported",code:"unsupported_protocol_version",receivedVersion:t.protocolVersion};let i=Pt(t.fps);return i===null||!Ot(t.capabilities)?{status:"unsupported",code:"invalid_protocol_metadata",receivedVersion:t.protocolVersion}:{status:"supported",fps:i,metadata:t}}function Nt(r){return Array.isArray(r)?r.filter(e=>typeof e=="object"&&e!==null&&typeof e.id=="string"&&typeof e.start=="number"&&typeof e.duration=="number"):[]}function Ze(r,e,t){if(r.source!==e)return;let i=r.data;if(!i||i.source!=="hf-preview")return;let n=Xe(i);if(n.status==="unsupported"){t.dispatchEvent(new CustomEvent("runtimeprotocolerror",{detail:{code:n.code,receivedVersion:n.receivedVersion}}));return}if(t.setRuntimeFps?.(n.fps),i.type==="shader-transition-state"){let o=i.state&&typeof i.state=="object"?i.state:{};t.shaderLoader.update(o,t.getShaderLoadingMode()),t.dispatchEvent(new CustomEvent("shadertransitionstate",{detail:{compositionId:i.compositionId,state:o}}));return}if(i.type==="ready"){t.onRuntimeReady();return}if(i.type==="assets-ready"){t.onRuntimeAssetsReady?.(i.timedOut===!0);return}if(i.type==="runtime-data-error"){t.onRuntimeDataError?.(i.channel,i.requestId,i.message);return}if(i.type==="runtime-data-applied"){t.onRuntimeDataApplied?.(i.channel,i.requestId);return}if(i.type==="state"){t.setPlaybackState(qe({frame:i.frame??0,isPlaying:!!i.isPlaying},n.fps,t.getPlaybackState(),t));return}if(i.type==="media-autoplay-blocked"){if(t.shouldPromoteMediaAutoplayFallback?.()===!1)return;let o=null;try{o=t.getIframeDoc()}catch{}t.media.promoteToParentProxy(o,(s,a)=>t.media.mirrorTime(s,a)),t.sendControl("set-media-output-muted",{muted:!0});return}if(i.type==="timeline"&&i.durationInFrames>0){let o=Number(i.durationSeconds),s=Number(i.durationInFrames),a=Number.isFinite(o)&&o>0?o:s/n.fps;if(Number.isFinite(a)&&a>0){let u=t.getPlaybackState();t.setPlaybackState({...u,duration:a}),t.updateControlsTime(u.currentTime,a),t.onRuntimeTimelineReady(a,typeof i.assetsReady=="boolean"?i.assetsReady:void 0)}Number.isFinite(i.compositionWidth)&&i.compositionWidth>0&&Number.isFinite(i.compositionHeight)&&i.compositionHeight>0&&t.setCompositionSize(i.compositionWidth,i.compositionHeight),t.setScenes(Nt(i.scenes));return}i.type==="stage-size"&&Number.isFinite(i.width)&&i.width>0&&Number.isFinite(i.height)&&i.height>0&&t.setCompositionSize(i.width,i.height)}function Ft(r,e){return r.includes(e)?!0:/hyperframe\.runtime\.iife\.js|__hyperframes\s*=/.test(r)}var Ht=new Set([">"," "," ",`
|
|
464
|
-
`,"\r","\f"]);function oe(r,e){let t=r.toLowerCase(),i=`<${e}`,n=0;for(;n<t.length;){let o=t.indexOf(i,n);if(o<0)return null;let s=t[o+i.length];if(Ht.has(s)){let a=t.indexOf(">",o+i.length);return a<0?null:{index:o,end:a+1}}n=o+i.length}return null}function Qe(r,e){if(!r||Ft(r,e))return r;let t=`<script src="${e}"></script>`,i=oe(r,"head");if(i)return r.slice(0,i.end)+t+r.slice(i.end);let n=oe(r,"body");if(n)return r.slice(0,n.index)+t+r.slice(n.index);let o=oe(r,"html");return o?r.slice(0,o.end)+t+r.slice(o.end):t+r}var w="shader-capture-scale",M="shader-loading",Z="runtime-src",Je="__hf_shader_capture_scale",Ke="__hf_shader_loading",L=["Preparing scene transitions","Sampling outgoing scene motion","Sampling incoming scene motion","Caching transition frames","Finalizing transition preview"];function se(r){if(r===null)return null;let e=Number(r);return!Number.isFinite(e)||e<=0?null:String(Math.min(1,Math.max(.25,e)))}function Ut(r){if(r===null||r.trim()==="")return"composition";let e=r.trim().toLowerCase();return e==="none"||e==="false"||e==="0"||e==="off"?"none":e==="player"||e==="true"||e==="1"||e==="on"?"player":"composition"}function et(r,e){return r.filter(t=>t!==""&&t.split("=")[0]!==e)}function Vt(r,e,t){let i=r.indexOf("#"),n=i>=0?r.slice(0,i):r,o=i>=0?r.slice(i):"",s=n.indexOf("?"),a=s>=0?n.slice(0,s):n,u=s>=0?n.slice(s+1):"",c=et(u.split("&"),Je);c=et(c,Ke),e!==null&&c.push(`${Je}=${encodeURIComponent(e)}`),t!=="composition"&&c.push(`${Ke}=${encodeURIComponent(t)}`);let p=c.join("&");return`${a}${p?`?${p}`:""}${o}`}function Wt(r,e,t){if(e===null&&t==="composition")return r;let i=[];e!==null&&i.push(`window.__HF_SHADER_CAPTURE_SCALE=${JSON.stringify(e)};`),t!=="composition"&&i.push(`window.__HF_SHADER_LOADING=${JSON.stringify(t)};`);let n=`<script data-hyperframes-player-shader-options>${i.join("")}</script>`;return/<head\b[^>]*>/i.test(r)?r.replace(/<head\b[^>]*>/i,o=>`${o}${n}`):/<html\b[^>]*>/i.test(r)?r.replace(/<html\b[^>]*>/i,o=>`${o}${n}`):`${n}${r}`}function D(r){return Ut(r.getAttribute(M))}function tt(r){return Number(se(r.getAttribute(w))??"1")}function F(r,e){return Vt(e,se(r.getAttribute(w)),D(r))}function H(r,e){return Qe(Wt(e,se(r.getAttribute(w)),D(r)),jt(r))}function jt(r){let e=r.getAttribute(Z)?.trim();if(!e)return k;try{let t=new URL(e,document.baseURI),i=t.protocol==="http:"||t.protocol==="https:",n=t.hostname==="127.0.0.1"||t.hostname==="localhost"||t.hostname==="[::1]";return i&&(n||t.origin===location.origin)?t.href:k}catch{return k}}function it(){let 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;let e=f=>{f.preventDefault(),f.stopPropagation()};for(let f of["selectstart","dragstart","pointerdown","mousedown","click","dblclick","contextmenu","touchstart"])r.addEventListener(f,e,{capture:!0});let t=document.createElement("div");t.className="hfp-shader-loader-panel",t.draggable=!1;let 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="M10.1851 57.8021L33.1145 73.8313C36.2202 75.9978 41.5173 73.5433 42.4816 69.4984L51.7611 30.4271C52.7253 26.3822 48.5802 23.9277 44.4602 26.0942L13.917 42.1235C6.96677 45.7676 4.97564 54.1579 10.1851 57.8021Z" fill="url(#hfp-shader-loader-grad-left)"/>','<path d="M87.5129 57.5141L56.9696 73.5433C52.8371 75.7098 48.7046 73.2553 49.6688 69.2104L58.9483 30.1391C59.9125 26.0942 65.2097 23.6397 68.3154 25.8062L91.2447 41.8354C96.4668 45.4796 94.4631 53.8699 87.5129 57.5141Z" fill="url(#hfp-shader-loader-grad-right)"/>',"<defs>",'<linearGradient id="hfp-shader-loader-grad-left" x1="48.5676" y1="25" x2="44.7804" y2="71.9384" gradientUnits="userSpaceOnUse">','<stop stop-color="#06E3FA"/>','<stop offset="1" stop-color="#4FDB5E"/>',"</linearGradient>",'<linearGradient id="hfp-shader-loader-grad-right" x1="54.8282" y1="73.8392" x2="72.0989" y2="32.8932" gradientUnits="userSpaceOnUse">','<stop stop-color="#06E3FA"/>','<stop offset="1" stop-color="#4FDB5E"/>',"</linearGradient>","</defs>","</svg>"].join("");let n=document.createElement("div");n.className="hfp-shader-loader-title";let o=document.createElement("span");o.className="hfp-shader-loader-title-text",o.textContent=L[0]||"Preparing scene transitions",n.appendChild(o);let s=document.createElement("div");s.className="hfp-shader-loader-detail",s.textContent="Rendering animated scene samples for shader transitions.";let a=document.createElement("div");a.className="hfp-shader-loader-track",a.setAttribute("aria-hidden","true");let u=document.createElement("div");u.className="hfp-shader-loader-fill",a.appendChild(u);let c=document.createElement("div");c.className="hfp-shader-loader-progress";let p=f=>{let S=document.createElement("div");S.className="hfp-shader-loader-row";let m=document.createElement("span");m.className="hfp-shader-loader-label",m.textContent=f;let E=document.createElement("span");return E.className="hfp-shader-loader-value",S.appendChild(m),S.appendChild(E),c.appendChild(S),{row:S,label:m,value:E}},g=p("transition"),y=p("transition frame");return t.appendChild(i),t.appendChild(n),t.appendChild(s),t.appendChild(a),t.appendChild(c),r.appendChild(t),{root:r,fill:u,title:o,detail:s,transitionValue:g.value,frameLabel:y.label,frameValue:y.value,frameRow:y.row}}var $t=420,Q=class{_el;_hideTimeout=null;_hiddenCallbacks=[];constructor(e){this._el=e}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(e){let t=this._el.root.classList;t.contains("hfp-visible")||t.contains("hfp-hiding")?this._hiddenCallbacks.push(e):e()}_flushHidden(){let e=this._hiddenCallbacks;this._hiddenCallbacks=[];for(let t of e)t()}reset(){this._hideTimeout&&(clearTimeout(this._hideTimeout),this._hideTimeout=null),this._el.root.classList.remove("hfp-visible","hfp-hiding"),this._flushHidden(),this._el.fill.style.transform="scaleX(0)",this._el.transitionValue.textContent="",this._el.frameValue.textContent="",this._el.frameRow.style.visibility="hidden"}update(e,t){if(t!=="player"){this.reset();return}if(e.ready||!e.loading){this.hide();return}this._el.root.setAttribute("aria-label","Preparing scene transitions");let i=typeof e.progress=="number"&&Number.isFinite(e.progress)?e.progress:0,n=typeof e.total=="number"&&Number.isFinite(e.total)?e.total:0,o=n>0?Math.min(1,Math.max(0,i/n)):0,s=Math.min(L.length-1,Math.floor(o*L.length));this._el.title.textContent=L[s]||"Preparing scene transitions",this._el.detail.textContent=e.phase==="cached"?"Loading cached transition frames before playback.":e.phase==="finalizing"?"Uploading transition textures for smooth playback.":"Rendering animated scene samples for shader transitions.",this._el.fill.style.transform=`scaleX(${o})`,this._el.transitionValue.textContent=e.currentTransition!==void 0&&e.transitionTotal!==void 0?`${e.currentTransition}/${e.transitionTotal}`:n>0?`${i}/${n}`:"";let a=e.transitionFrame!==void 0&&e.transitionFrames!==void 0?`${e.transitionFrame}/${e.transitionFrames}`:"";this._el.frameLabel.textContent=e.phase==="cached"?"cached transition frames":e.phase==="finalizing"?"finalizing transition frames":"rendering transition frames",this._el.frameValue.textContent=a,this._el.frameRow.style.visibility=a?"visible":"hidden",this._el.root.setAttribute("aria-valuenow",String(Math.round(o*100))),this.show()}showAssetsLoading(){this.reset(),this._el.title.textContent="Loading assets",this._el.detail.textContent="Waiting for images, video and fonts to finish loading.",this._el.root.setAttribute("aria-label","Loading assets"),this.show()}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()},$t)}};var zt=.1,Bt=5,ae="sandbox-origin",rt=1e4,de=8e3,le="assets-loading",Gt=150;function ue(r){return!Number.isFinite(r)||r<=0?1:Math.max(zt,Math.min(Bt,r))}var ce=class extends HTMLElement{static get observedAttributes(){return["src","srcdoc","width","height","controls","muted","audio-locked","volume","poster","playback-rate","audio-src",ae,Z,w,M]}shadow;container;iframe;posterEl=null;controlsApi=null;resizeObserver;shaderLoader;probe;_ready=!1;_assetsReady=!1;_painted=!1;_pendingPlay=!1;_assetsGeneration=0;_assetsLoadingShowTimer=null;_currentTime=0;_duration=0;_paused=!0;_scrubbing=!1;_lastUpdateMs=0;_volume=1;_compositionWidth=1920;_compositionHeight=1080;_rescaleWarned=!1;_directTimelineAdapter=null;_directTimelineClock;_parentTickRaf=null;_media;_scenes=[];_runtimeFps=30;_runtimeBridgeReady=!1;_runtimeAssetsReadyGeneration=-1;_runtimeData=new Map;_runtimeDataRequestId=0;_pendingRuntimeData=new Map;constructor(){super(),this.shadow=this.attachShadow({mode:"open"}),Fe(this.shadow,xe),{container:this.container,iframe:this.iframe}=He(),this.shadow.appendChild(this.container);let e=it();this.shadow.appendChild(e.root),this.shaderLoader=new Q(e),this._media=new X({dispatchEvent:t=>this.dispatchEvent(t),getMuted:()=>this.muted,getVolume:()=>this._volume,getPlaybackRate:()=>this.playbackRate,getCurrentTime:()=>this._currentTime,isPaused:()=>this._paused}),this._directTimelineClock=new Y({onTimeUpdate:(t,i)=>{this._currentTime=t,this.controlsApi?.updateTime(t,i),this.dispatchEvent(new CustomEvent("timeupdate",{detail:{currentTime:t}}))},getLoop:()=>this.loop,restart:()=>{this.seek(0),this.play()},onPaused:()=>{this._media.audioOwner==="parent"&&this._media.pauseAll(),this._paused=!0,this.controlsApi?.updatePlaying(!1),this.dispatchEvent(new Event("ended"))},onEnded:()=>this.loop}),this.probe=new B(this.iframe,{onReady:t=>this._onProbeReady(t),onError:t=>this.dispatchEvent(new CustomEvent("error",{detail:{message:t}}))}),this.addEventListener("click",t=>{Ne(t)||(this._paused?this.play():this.pause())}),this.resizeObserver=new ResizeObserver(()=>this._rescale()),this._onMessage=this._onMessage.bind(this),this._onIframeLoad=this._onIframeLoad.bind(this)}connectedCallback(){this._applySandboxOriginPolicy(),this.resizeObserver.observe(this),window.addEventListener("message",this._onMessage),this.iframe.addEventListener("load",this._onIframeLoad),this.hasAttribute("controls")&&this._setupControls(),this.hasAttribute("poster")&&(this.posterEl=te(this.shadow,this.getAttribute("poster"),this.posterEl)),this.hasAttribute("audio-src")&&this._media.setupFromUrl(this.getAttribute("audio-src")),this.hasAttribute("srcdoc")&&(this.iframe.srcdoc=H(this,this.getAttribute("srcdoc"))),this.hasAttribute("src")&&(this.iframe.src=F(this,this.getAttribute("src"))),!this.hasAttribute("audio-locked")&&this._isLockedHostEnvironment()&&this._applyAudioLock(!0)}disconnectedCallback(){this._sendControl("pause"),this._stopIframeMedia(),this.resizeObserver.disconnect(),window.removeEventListener("message",this._onMessage),this.iframe.removeEventListener("load",this._onIframeLoad),this.probe.stop(),this._directTimelineClock.stop(),this._stopParentTickClock(),this._directTimelineAdapter=null,this.shaderLoader.destroy(),this._media.destroy(),this.controlsApi?.destroy(),this.controlsApi=null,this._paused=!0,this._ready=!1,this._invalidateAssetsWait(),this._runtimeBridgeReady=!1,this._rejectAllRuntimeDataDeliveries("Player disconnected before runtime data was applied")}attributeChangedCallback(e,t,i){switch(e){case"src":if(!this.isConnected)break;i&&(this._ready=!1,this._invalidateAssetsWait(),this._runtimeBridgeReady=!1,this._rejectAllRuntimeDataDeliveries("Composition navigated before runtime data was applied"),this.iframe.src=F(this,i));break;case"srcdoc":if(!this.isConnected)break;this._ready=!1,this._invalidateAssetsWait(),this._runtimeBridgeReady=!1,this._rejectAllRuntimeDataDeliveries("Composition navigated before runtime data was applied"),i!==null?this.iframe.srcdoc=H(this,i):this.iframe.removeAttribute("srcdoc");break;case ae:this._applySandboxOriginPolicy(this.isConnected&&t!==i);break;case"width":this._compositionWidth=O(i)??1920,this._rescale();break;case"height":this._compositionHeight=O(i)??1080,this._rescale();break;case"controls":i!==null?this._setupControls():(this.controlsApi?.destroy(),this.controlsApi=null);break;case"poster":this.posterEl=te(this.shadow,i,this.posterEl);break;case"playback-rate":{let n=ue(parseFloat(i||"1"));this._media.updatePlaybackRate(n),this._sendControl("set-playback-rate",{playbackRate:n}),this._directTimelineAdapter?.timeScale?.(n),this.controlsApi?.updateSpeed(n),this.dispatchEvent(new Event("ratechange"));break}case"muted":this._handleMutedChange(i);break;case"audio-locked":this._applyAudioLock(i!==null);break;case"volume":{let n=Math.max(0,Math.min(1,parseFloat(i||"1")));this._volume=n,this._media.updateVolume(n),this._sendControl("set-volume",{volume:n}),this.controlsApi?.updateVolume(n),this.dispatchEvent(new Event("volumechange"));break}case"audio-src":i?this._media.setupFromUrl(i):this._media.teardownUrlAudio();break;case w:case M:case Z:if(!this.isConnected)break;this._reloadShaderOptions();break}}_applySandboxOriginPolicy(e=!1){this.hasAttribute(ae)?this.iframe.sandbox.remove("allow-same-origin"):this.iframe.sandbox.add("allow-same-origin"),e&&this._reloadForSandboxOriginPolicy()}_reloadForSandboxOriginPolicy(){this._ready=!1,this._invalidateAssetsWait(),this._runtimeBridgeReady=!1,this._rejectAllRuntimeDataDeliveries("Sandbox policy changed before runtime data was applied");let e=this.getAttribute("srcdoc");if(e!==null){this.iframe.srcdoc=H(this,e);return}let t=this.getAttribute("src");this.iframe.src=t===null?"about:blank":F(this,t)}get iframeElement(){return this.iframe}get scenes(){return this._scenes}play(){if(this._ready&&!this._assetsReady){this._pendingPlay=!0;return}this._pendingPlay=!1,this.posterEl?.remove(),this.posterEl=null,this._duration>0&&this._currentTime>=this._duration&&this.seek(0),this._paused=!1;let e=this._tryDirectTimelinePlay(),t=!1;e||(this._sendControl("play"),this._ready&&!this._directTimelineAdapter?this._startParentTickClock():this._ready||(this._pendingPlay=!0,t=!0)),this._media.audioOwner==="parent"&&this._media.playAll(),this.controlsApi?.updatePlaying(!0),t||this.dispatchEvent(new Event("play")),e&&this._directTimelineAdapter&&this._directTimelineClock.start(this._directTimelineAdapter,()=>this._currentTime,()=>this._duration,()=>this._paused)}pause(){this._pendingPlay=!1,this._tryDirectTimelinePause()||this._sendControl("pause"),this._directTimelineClock.stop(),this._stopParentTickClock(),this._media.audioOwner==="parent"&&this._media.pauseAll(),this._paused=!0,this.controlsApi?.updatePlaying(!1),this.dispatchEvent(new Event("pause"))}stopMedia(){this._sendControl("stop-media"),this._stopIframeMedia(),this._media.stopAdoptedMedia()}seek(e){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,this.controlsApi?.updatePlaying(!1),this.controlsApi?.updateTime(this._currentTime,this._duration)}setColorGrading(e,t){this._sendControl("set-color-grading",{target:e,grading:t})}clearColorGrading(e){this._sendControl("set-color-grading",{target:e,grading:null})}setColorGradingCompare(e,t){this._sendControl("set-color-grading-compare",{target:e,compare:t})}clearColorGradingCompare(e){this._sendControl("set-color-grading-compare",{target:e,compare:{enabled:!1}})}setRuntimeData(e,t){if(!/^[a-z][a-z0-9-]{0,63}$/.test(e))throw new Error(`Invalid HyperFrames runtime-data channel: ${e}`);if(typeof structuredClone!="function")throw new Error("HyperFrames runtime data requires structuredClone support; refusing an unverified payload");let i=structuredClone(t);this._runtimeData.set(e,i),this._deliverRuntimeData(e,i)}clearRuntimeData(e){if(!/^[a-z][a-z0-9-]{0,63}$/.test(e))throw new Error(`Invalid HyperFrames runtime-data channel: ${e}`);this._runtimeData.delete(e),this._deliverRuntimeDataClear(e)}get currentTime(){return this._currentTime}set currentTime(e){this.seek(e)}get duration(){return this._duration}get paused(){return this._paused}get ready(){return this._ready}get assetsReady(){return this._assetsReady}get painted(){return this._painted}get playbackRate(){return ue(parseFloat(this.getAttribute("playback-rate")||"1"))}set playbackRate(e){this.setAttribute("playback-rate",String(ue(e)))}get shaderCaptureScale(){return tt(this)}set shaderCaptureScale(e){this.setAttribute(w,String(e))}get shaderLoading(){return D(this)}set shaderLoading(e){e==="composition"?this.removeAttribute(M):this.setAttribute(M,e)}get muted(){return this.hasAttribute("muted")}set muted(e){e?this.setAttribute("muted",""):this.removeAttribute("muted")}get audioLocked(){return this.hasAttribute("audio-locked")}set audioLocked(e){e?this.setAttribute("audio-locked",""):this.removeAttribute("audio-locked")}_isLockedHostEnvironment(){if(typeof navigator>"u")return!1;let 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){if(e===null&&this._isAudioLocked()){this.setAttribute("muted","");return}this._media.updateMuted(e!==null),this._setIframeMediaMuted(e!==null),this._sendControl("set-muted",{muted:e!==null}),this.controlsApi?.updateMuted(e!==null),this.dispatchEvent(new Event("volumechange"))}_applyAudioLock(e){e&&(this.muted=!0),this.controlsApi?.setVolumeControlsHidden(e)}get volume(){return this._volume}set volume(e){this.setAttribute("volume",String(Math.max(0,Math.min(1,e))))}get loop(){return this.hasAttribute("loop")}set loop(e){e?this.setAttribute("loop",""):this.removeAttribute("loop")}_sendControl(e,t={}){try{let i=this.iframe.contentWindow;return i?(i.postMessage({...t,source:"hf-parent",type:"control",action:e,...Ye(this._runtimeFps)},"*"),!0):((e==="set-runtime-data"||e==="clear-runtime-data")&&this._rejectRuntimeDataDelivery(t.channel,t.requestId,"Composition iframe is unavailable"),!1)}catch(i){return(e==="set-runtime-data"||e==="clear-runtime-data")&&this._rejectRuntimeDataDelivery(t.channel,t.requestId,i instanceof Error?i.message:String(i)),!1}}_deliverRuntimeData(e,t){if(!this.isConnected||!this._runtimeBridgeReady)return;let i=this._beginRuntimeDataDelivery(e);this._trySetRuntimeDataDirect(e,t,i)||this._sendControl("set-runtime-data",{channel:e,payload:t,requestId:i})}_deliverRuntimeDataClear(e){if(!this.isConnected||!this._runtimeBridgeReady)return;let t=this._beginRuntimeDataDelivery(e);this._tryClearRuntimeDataDirect(e,t)||this._sendControl("clear-runtime-data",{channel:e,requestId:t})}_trySetRuntimeDataDirect(e,t,i){try{let n=this.iframe.contentWindow?.__hyperframes;return typeof n?.setRuntimeData!="function"?!1:(n.setRuntimeData(e,t,i),!0)}catch{return!1}}_tryClearRuntimeDataDirect(e,t){try{let i=this.iframe.contentWindow?.__hyperframes;return typeof i?.clearRuntimeData!="function"?!1:(i.clearRuntimeData(e,t),!0)}catch{return!1}}_replayRuntimeData(){for(let[e,t]of this._runtimeData)this._deliverRuntimeData(e,t)}_beginRuntimeDataDelivery(e){let t=this._pendingRuntimeData.get(e);t&&window.clearTimeout(t.timeoutId),this._runtimeDataRequestId+=1;let i=this._runtimeDataRequestId,n=window.setTimeout(()=>{this._rejectRuntimeDataDelivery(e,i,`Runtime data delivery timed out after ${rt}ms`)},rt);return this._pendingRuntimeData.set(e,{requestId:i,timeoutId:n}),i}_resolveRuntimeDataDelivery(e,t){let i=this._takeRuntimeDataDelivery(e,t);i&&this.dispatchEvent(new CustomEvent("runtimedataapplied",{detail:{channel:e,requestId:i.requestId}}))}_rejectRuntimeDataDelivery(e,t,i){let n=this._takeRuntimeDataDelivery(e,t);n&&this.dispatchEvent(new CustomEvent("runtimedataerror",{detail:{channel:e,requestId:n.requestId,message:typeof i=="string"?i:String(i)}}))}_takeRuntimeDataDelivery(e,t){if(typeof e!="string"||typeof t!="number"||!Number.isSafeInteger(t))return null;let i=this._pendingRuntimeData.get(e);return!i||i.requestId!==t?null:(window.clearTimeout(i.timeoutId),this._pendingRuntimeData.delete(e),i)}_rejectAllRuntimeDataDeliveries(e){for(let[t,i]of[...this._pendingRuntimeData])this._rejectRuntimeDataDelivery(t,i.requestId,e)}_getSameOriginIframeDocument(){try{return this.iframe.contentDocument}catch{return null}}_setIframeMediaMuted(e){let t=this._getSameOriginIframeDocument();if(t)for(let i of t.querySelectorAll("video, audio"))b(i)&&(i.muted=e||i.defaultMuted)}_stopIframeMedia(){let e=this._getSameOriginIframeDocument();if(e)for(let t of e.querySelectorAll("video, audio"))b(t)&&t.pause()}_replayBridgeState(){this._sendControl("set-muted",{muted:this.muted}),this._sendControl("set-volume",{volume:this._volume}),this._sendControl("set-playback-rate",{playbackRate:this.playbackRate}),this._sendControl("set-native-media-sync-disabled",{disabled:this._isSlideshowPlayer()}),this._sendControl("set-web-audio-media-disabled",{disabled:this._isSlideshowPlayer()})}_reloadShaderOptions(){if(this._ready=!1,this._invalidateAssetsWait(),this._runtimeBridgeReady=!1,this._rejectAllRuntimeDataDeliveries("Shader options changed before runtime data was applied"),D(this)!=="player"&&this.shaderLoader.reset(),this.hasAttribute("srcdoc")){this.iframe.srcdoc=H(this,this.getAttribute("srcdoc")||"");return}this.hasAttribute("src")&&(this.iframe.src=F(this,this.getAttribute("src")||""))}_trySyncSeek(e){try{let i=this.iframe.contentWindow?.__player;return typeof i?.seek!="function"?!1:(i.seek.call(i,e),!0)}catch{return!1}}_withDirectTimeline(e){let t=this.probe.resolveDirectTimelineAdapter(),i=t||this._directTimelineAdapter;if(!i)return!1;try{if(e(i),t&&t!==this._directTimelineAdapter){let n=t.duration();Number.isFinite(n)&&n>0&&(this._duration=n,this.controlsApi?.updateTime(this._currentTime,n))}return this._directTimelineAdapter=i,!0}catch{return!1}}_tryDirectTimelineSeek(e){return this._withDirectTimeline(t=>{t.seek(e,!1),t.pause()})}_tryDirectTimelinePlay(){return this._withDirectTimeline(e=>{e.play()})}_tryDirectTimelinePause(){return this._withDirectTimeline(e=>{e.pause()})}_startParentTickClock(){this._stopParentTickClock();let 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){Ze(e,this.iframe.contentWindow,{getPlaybackState:()=>({currentTime:this._currentTime,duration:this._duration,paused:this._paused,lastUpdateMs:this._lastUpdateMs}),setPlaybackState:({currentTime:t,duration:i,paused:n,lastUpdateMs:o})=>{this._currentTime=t,this._duration=i,this._paused=n,this._lastUpdateMs=o},getShaderLoadingMode:()=>D(this),shaderLoader:this.shaderLoader,setCompositionSize:(t,i)=>{this._compositionWidth=t,this._compositionHeight=i,this._rescale()},sendControl:(t,i)=>this._sendControl(t,i),getIframeDoc:()=>this.iframe.contentDocument,onRuntimeReady:()=>{this._runtimeBridgeReady=!0,this._replayBridgeState(),this._replayRuntimeData()},onRuntimeAssetsReady:()=>{this._runtimeAssetsReadyGeneration===this._assetsGeneration&&this._settleAssetsReady(this._assetsGeneration)},onRuntimeDataApplied:(t,i)=>this._resolveRuntimeDataDelivery(t,i),onRuntimeDataError:(t,i,n)=>this._rejectRuntimeDataDelivery(t,i,n),onRuntimeTimelineReady:(t,i)=>this._onRuntimeTimelineReady(t,i),setRuntimeFps:t=>{this._runtimeFps=t},shouldPromoteMediaAutoplayFallback:()=>!this._isSlideshowPlayer(),setScenes:t=>{this._scenes=t,this.dispatchEvent(new CustomEvent("scenes",{detail:{scenes:t}}))},updateControlsTime:(t,i)=>this.controlsApi?.updateTime(t,i),updateControlsPlaying:t=>this.controlsApi?.updatePlaying(t),dispatchEvent:t=>this.dispatchEvent(t),seek:t=>this.seek(t),play:()=>this.play(),getLoop:()=>this.loop,media:this._media})}_onRuntimeTimelineReady(e,t){if(this._ready)return;this.probe.stop(),this._duration=e,this._directTimelineAdapter=null,this._ready=!0,this.controlsApi?.updateTime(this._currentTime,e),this.dispatchEvent(new CustomEvent("ready",{detail:{duration:e}})),this._rescale();let i=this._getSameOriginIframeDocument();i&&this._media.setupFromIframe(i),this._replayBridgeState(),this._setIframeMediaMuted(this.muted),this._waitForAssetsReady(i,t),(this.hasAttribute("autoplay")||this._pendingPlay)&&this.play()}_onProbeReady({duration:e,adapter:t,compositionSize:i}){this._duration=e,this._directTimelineAdapter=t.kind==="direct-timeline"?t.timeline:null,this._ready=!0,this.controlsApi?.updateTime(0,e),this.dispatchEvent(new CustomEvent("ready",{detail:{duration:e}})),i&&(this._compositionWidth=i.width,this._compositionHeight=i.height,this._rescale());let n=this._getSameOriginIframeDocument();n&&this._media.setupFromIframe(n),this._setIframeMediaMuted(this.muted),this._waitForAssetsReady(n),(this.hasAttribute("autoplay")||this._pendingPlay)&&this.play()}_waitForAssetsReady(e,t){this._clearAssetsLoadingShowTimer(),this._assetsReady=!1,this._painted=!1;let i=++this._assetsGeneration;if(!e){t===!1?(this._runtimeAssetsReadyGeneration=i,this._startAssetsLoadingOverlayTimer(i),setTimeout(()=>this._settleAssetsReady(i),de)):this._settleAssetsReady(i);return}We(e,({timedOut:n})=>{i===this._assetsGeneration&&(n&&this._warnStuckAssets(e),this._settleAssetsReady(i))},{timeoutMs:de}),this._assetsReady||this._startAssetsLoadingOverlayTimer(i)}_startAssetsLoadingOverlayTimer(e){this._assetsLoadingShowTimer=setTimeout(()=>{this._assetsLoadingShowTimer=null,!(e!==this._assetsGeneration||this._assetsReady)&&(this.setAttribute(le,""),this.shaderLoader.showAssetsLoading())},Gt)}_warnStuckAssets(e){let{pendingMedia:t,pendingImages:i,fontsLoading:n}=re(e),o=e.defaultView;console.warn(`[hyperframes-player] assets-loading timed out after ${de}ms \u2014 playing anyway`,{stuckMedia:t.map(s=>s.currentSrc||s.getAttribute("src")||`<${s.tagName.toLowerCase()}>`),stuckImages:i.map(s=>s.currentSrc||s.getAttribute("src")||"<img>"),fontsLoading:n,computeReady:o?.__renderReady===!0,documentHidden:e.hidden===!0})}_settleAssetsReady(e){e!==this._assetsGeneration||this._assetsReady||(this._clearAssetsLoadingShowTimer(),this._assetsReady=!0,this.removeAttribute(le),this.shaderLoader.hide(),this.dispatchEvent(new Event("assetsready")),this.shaderLoader.whenHidden(()=>{e===this._assetsGeneration&&(this._painted=!0,this.dispatchEvent(new Event("painted")))}),this._pendingPlay&&this.play())}_invalidateAssetsWait(){this._clearAssetsLoadingShowTimer(),this._assetsReady=!1,this._painted=!1,this._pendingPlay=!1,this._assetsGeneration++,this.removeAttribute(le),this.shaderLoader.hide()}_clearAssetsLoadingShowTimer(){this._assetsLoadingShowTimer!==null&&(clearTimeout(this._assetsLoadingShowTimer),this._assetsLoadingShowTimer=null)}_rescale(){!Ue(this,this.iframe,this._compositionWidth,this._compositionHeight)&&this._ready&&!this._rescaleWarned&&(this._rescaleWarned=!0,console.warn("[hyperframes-player] rescale no-op after ready \u2014 zero-size player element",{src:this.getAttribute("src"),offsetWidth:this.offsetWidth,offsetHeight:this.offsetHeight,compositionWidth:this._compositionWidth,compositionHeight:this._compositionHeight}))}_onIframeLoad(){this._ready&&this._getSameOriginIframeDocument()===null||(this._ready=!1,this._directTimelineAdapter=null,this._directTimelineClock.stop(),this._stopParentTickClock(),this._invalidateAssetsWait(),this.shaderLoader.reset(),this._media.resetForIframeLoad(),this.probe.start())}_setupControls(){this.controlsApi||(this.controlsApi=Oe(this.shadow,this.muted,this._volume,this.getAttribute("speed-presets"),{onPlay:()=>this.play(),onPause:()=>this.pause(),onSeek:e=>this.seek(e*this._duration),onScrubStart:()=>{this._scrubbing=!0},onScrubEnd:()=>{this._scrubbing=!1,this.seek(this._currentTime)},onSpeedChange:e=>{this.playbackRate=e},onMuteToggle:()=>{this.muted=!this.muted},onVolumeChange:e=>{this.volume=e}},this._isAudioLocked()))}get _audioOwner(){return this._media.audioOwner}get _parentMedia(){return this._media.entries}_mirrorParentMediaTime(e,t){this._media.mirrorTime(e,t)}_promoteToParentProxy(){let e=null;try{e=this.iframe.contentDocument}catch{}this._media.promoteToParentProxy(e,(t,i)=>this._mirrorParentMediaTime(t,i)),this._sendControl("set-media-output-muted",{muted:!0})}_observeDynamicMedia(e){this._media.setupFromIframe(e)}};customElements.get("hyperframes-player")||customElements.define("hyperframes-player",ce);export{ce as HyperframesPlayer,Ie as SPEED_PRESETS,G as formatSpeed,ee as formatTime};
|
|
463
|
+
`,mt='<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>',pt='<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>',ve='<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>',Ae='<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>',ft='<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>';var ht=[.25,.5,1,1.5,2,4];function ne(n){return Number.isInteger(n)?`${n}x`:`${n}x`}function Ee(n){if(!Number.isFinite(n)||n<0)return"0:00";let e=Math.floor(n),t=Math.floor(e/60),i=e%60;return`${t}:${i.toString().padStart(2,"0")}`}function bt(n,e,t={}){let i=t.speedPresets??ht,r=document.createElement("div");r.className="hfp-controls",r.addEventListener("click",l=>{l.stopPropagation()});let o=document.createElement("button");o.className="hfp-play-btn",o.type="button",o.innerHTML=`<span class="hfp-ico hfp-ico-play">${mt}</span><span class="hfp-ico hfp-ico-pause">${pt}</span>`,o.setAttribute("aria-label","Play");let a=document.createElement("div");a.className="hfp-scrubber";let s=document.createElement("div");s.className="hfp-progress",s.style.width="0%",a.appendChild(s);let u=document.createElement("span");u.className="hfp-time",u.textContent="0:00 / 0:00";let d=document.createElement("div");d.className="hfp-speed-wrap";let c=document.createElement("button");c.className="hfp-speed-btn",c.type="button",c.textContent="1x",c.setAttribute("aria-label","Playback speed");let g=document.createElement("div");g.className="hfp-speed-menu",g.setAttribute("role","menu");for(let l of i){let p=document.createElement("button");p.className="hfp-speed-option",p.type="button",p.setAttribute("role","menuitem"),p.dataset.speed=String(l),p.textContent=ne(l),l===1&&p.classList.add("hfp-active"),g.appendChild(p)}d.appendChild(g),d.appendChild(c);let m=document.createElement("div");m.className="hfp-volume-wrap";let f=document.createElement("button");f.className="hfp-mute-btn",f.type="button",f.innerHTML=ve,f.setAttribute("aria-label","Mute");let h=document.createElement("div");h.className="hfp-volume-slider-wrap";let b=document.createElement("div");b.className="hfp-volume-slider",b.setAttribute("role","slider"),b.setAttribute("aria-label","Volume"),b.setAttribute("aria-valuemin","0"),b.setAttribute("aria-valuemax","100"),b.setAttribute("aria-valuenow","100"),b.tabIndex=0;let y=document.createElement("div");y.className="hfp-volume-fill",y.style.width="100%",b.appendChild(y),h.appendChild(b),m.appendChild(h),m.appendChild(f),t.audioLocked&&(m.style.display="none"),r.appendChild(o),r.appendChild(a),r.appendChild(u),r.appendChild(m),r.appendChild(d),n.appendChild(r);let S=!1,v=!1,w=1,A=null,R=i.indexOf(1);R===-1&&(R=0);let J=(l,p)=>l?ft:p===0?Ae:p<.5?Ae:ve;o.addEventListener("click",l=>{l.stopPropagation(),S?e.onPause():e.onPlay()}),f.addEventListener("click",l=>{l.stopPropagation(),e.onMuteToggle()});let N=!1,Z=l=>{let p=b.getBoundingClientRect(),E=Math.max(0,Math.min(1,(l-p.left)/p.width));w=E,y.style.width=`${E*100}%`,b.setAttribute("aria-valuenow",String(Math.round(E*100))),v&&E>0&&e.onMuteToggle(),f.innerHTML=J(v,E),e.onVolumeChange(E)};b.addEventListener("mousedown",l=>{l.stopPropagation(),N=!0,Z(l.clientX)});let Ye=l=>{N&&Z(l.clientX)},Xe=()=>{N=!1};document.addEventListener("mousemove",Ye),document.addEventListener("mouseup",Xe),b.addEventListener("touchstart",l=>{N=!0;let p=l.touches[0];p&&Z(p.clientX)},{passive:!0});let Ke=l=>{if(N){let p=l.touches[0];p&&Z(p.clientX)}},Je=()=>{N=!1};document.addEventListener("touchmove",Ke,{passive:!0}),document.addEventListener("touchend",Je);let Ze=.05;b.addEventListener("keydown",l=>{let p=w;if(l.key==="ArrowRight"||l.key==="ArrowUp")p=Math.min(1,w+Ze);else if(l.key==="ArrowLeft"||l.key==="ArrowDown")p=Math.max(0,w-Ze);else return;l.preventDefault(),l.stopPropagation(),w=p,y.style.width=`${p*100}%`,b.setAttribute("aria-valuenow",String(Math.round(p*100))),v&&p>0&&e.onMuteToggle(),f.innerHTML=J(v,p),e.onVolumeChange(p)});let Qe=l=>{for(let p of g.querySelectorAll(".hfp-speed-option"))p.classList.toggle("hfp-active",p.dataset.speed===String(l))};c.addEventListener("click",l=>{l.stopPropagation();let p=g.classList.toggle("hfp-open");c.setAttribute("aria-expanded",String(p))}),g.addEventListener("click",l=>{l.stopPropagation();let p=l.target.closest(".hfp-speed-option");if(!p)return;let E=parseFloat(p.dataset.speed);R=i.indexOf(E),c.textContent=ne(E),Qe(E),g.classList.remove("hfp-open"),c.setAttribute("aria-expanded","false"),e.onSpeedChange(E)});let et=()=>{g.classList.remove("hfp-open"),c.setAttribute("aria-expanded","false")};document.addEventListener("click",et);let Q=l=>{let p=a.getBoundingClientRect(),E=Math.max(0,Math.min(1,(l-p.left)/p.width));e.onSeek(E)},I=!1;a.addEventListener("mousedown",l=>{l.stopPropagation(),I=!0,e.onScrubStart?.(),Q(l.clientX)});let tt=l=>{I&&Q(l.clientX)},nt=()=>{I&&(I=!1,e.onScrubEnd?.())};document.addEventListener("mousemove",tt),document.addEventListener("mouseup",nt),a.addEventListener("touchstart",l=>{I=!0,e.onScrubStart?.();let p=l.touches[0];p&&Q(p.clientX)},{passive:!0});let it=l=>{if(I){let p=l.touches[0];p&&Q(p.clientX)}},rt=()=>{I&&(I=!1,e.onScrubEnd?.())};document.addEventListener("touchmove",it,{passive:!0}),document.addEventListener("touchend",rt);let ot=()=>{A&&clearTimeout(A),A=setTimeout(()=>{S&&r.classList.add("hfp-hidden")},3e3)},ee=n instanceof ShadowRoot?n.host:n,at=()=>{r.classList.remove("hfp-hidden"),ot()},st=()=>{S&&r.classList.add("hfp-hidden")};return ee.addEventListener("mousemove",at),ee.addEventListener("mouseleave",st),{updateTime(l,p){let E=p>0?Math.min(l,p):l,cn=p>0?E/p*100:0;s.style.width=`${cn}%`,u.textContent=`${Ee(E)} / ${Ee(p)}`},updatePlaying(l){S=l,o.classList.toggle("hfp-playing",l),o.setAttribute("aria-label",l?"Pause":"Play"),l?ot():r.classList.remove("hfp-hidden")},updateSpeed(l){let p=i.indexOf(l);p!==-1&&(R=p),c.textContent=ne(l),Qe(l)},updateMuted(l){v=l,f.innerHTML=J(l,w),f.setAttribute("aria-label",l?"Unmute":"Mute")},updateVolume(l){w=l,y.style.width=`${l*100}%`,b.setAttribute("aria-valuenow",String(Math.round(l*100))),f.innerHTML=J(v,l)},setVolumeControlsHidden(l){m.style.display=l?"none":""},show(){r.style.display=""},hide(){r.style.display="none"},destroy(){document.removeEventListener("mousemove",tt),document.removeEventListener("mouseup",nt),document.removeEventListener("touchmove",it),document.removeEventListener("touchend",rt),document.removeEventListener("mousemove",Ye),document.removeEventListener("mouseup",Xe),document.removeEventListener("touchmove",Ke),document.removeEventListener("touchend",Je),document.removeEventListener("click",et),ee.removeEventListener("mousemove",at),ee.removeEventListener("mouseleave",st),A&&clearTimeout(A),r.remove()}}}function gt(n,e,t,i,r,o=!1){let a=i?i.split(",").map(Number).filter(d=>!isNaN(d)&&d>0):void 0,s={...a?{speedPresets:a}:{},audioLocked:o},u=bt(n,r,s);return u.updateMuted(e),u.updateVolume(t),u}function Se(n,e,t){return e?(t||(t=document.createElement("img"),t.className="hfp-poster",n.appendChild(t)),t.src=e,t):(t?.remove(),null)}function _t(n){return n.composedPath().some(e=>e instanceof HTMLElement&&e.classList.contains("hfp-controls"))}var ie=null;function yt(n,e){if(typeof CSSStyleSheet<"u")try{ie||(ie=new CSSStyleSheet,ie.replaceSync(e)),n.adoptedStyleSheets=[ie];return}catch{}let t=document.createElement("style");t.textContent=e,n.appendChild(t)}function vt(){let n=document.createElement("div");n.className="hfp-container";let e=document.createElement("iframe");return e.className="hfp-iframe",e.sandbox.add("allow-scripts","allow-same-origin"),e.allow="autoplay; fullscreen",e.referrerPolicy="no-referrer",e.title="HyperFrames Composition",n.appendChild(e),{container:n,iframe:e}}function At(n,e,t,i){let r=n.offsetWidth,o=n.offsetHeight;if(r===0||o===0)return!1;let a=Math.min(r/t,o/i);return e.style.width=`${t}px`,e.style.height=`${i}px`,e.style.transform=`translate(-50%, -50%) scale(${a})`,!0}var re=class{constructor(e){this._callbacks=e}_callbacks;_raf=null;_lastUpdateMs=0;start(e,t,i,r){this.stop();let o=()=>{if(r()){this._raf=null;return}let a;try{a=e.time()}catch{this._raf=null;return}let s=i();s>0&&(a=Math.min(a,s));let u=s>0&&a>=s,d=performance.now();if((d-this._lastUpdateMs>100||u)&&(this._lastUpdateMs=d,this._callbacks.onTimeUpdate(a,s)),u){if(this._callbacks.getLoop()){this._callbacks.restart();return}try{e.pause()}catch{}this._callbacks.onPaused(),this._raf=null;return}this._raf=requestAnimationFrame(o)};this._raf=requestAnimationFrame(o)}stop(){this._raf!==null&&(cancelAnimationFrame(this._raf),this._raf=null)}get isRunning(){return this._raf!==null}};function Et(n){let e=Array.from(n.querySelectorAll("[data-composition-id]"));if(e.length===0)return n.body?[n.body]:[];let t=[];for(let i of e)fn(i)||t.push(i);return pn(n),t}function pn(n){let e=n.body;if(!e||typeof console>"u"||typeof console.warn!="function")return;let t=e.querySelectorAll("audio[data-start], video[data-start]");if(t.length===0)return;let i=[];for(let r of t)r.closest("[data-composition-id]")||i.push(r);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 fn(n){let e=n.parentElement;for(;e;){if(e.hasAttribute("data-composition-id"))return!0;e=e.parentElement}return!1}function St(){return globalThis}function oe(n,e){if(typeof window>"u")return;let t=St(),i=t.__hf?.onSwallowed;if(i)try{i({label:n,error:e})}catch(r){}(t.__hfDebug||t.__HYPERFRAMES_DEBUG)&&console.debug(`[hyperframes] ${n} swallowed:`,e)}var Tt="data-hf-authored-duration",xt="data-hf-authored-end";function G(n){if(n==null||typeof n=="string"&&n.trim()==="")return null;let e=typeof n=="number"?n:Number(n);return Number.isFinite(e)?e:null}function ae(n){let e=G(n.start);if(e==null)return null;let t=Math.max(0,e),i=G(n.duration),r=G(n.authoredDuration),o=i!=null&&i>0?i:r!=null&&r>0?r:null;if(o!=null)return{start:t,duration:o,end:t+o};let a=G(n.end),s=G(n.authoredEnd),u=a!=null&&a>t?a:s!=null&&s>t?s:null;return{start:t,duration:u==null?null:u-t,end:u}}var P=Object.freeze({start:"data-start",duration:"data-duration",trackIndex:"data-track-index",derivedEnd:"data-end",legacyTrack:"data-layer"}),sr=Object.freeze([P.start,P.duration,P.trackIndex]),ur=Object.freeze([P.derivedEnd]),lr=Object.freeze([P.derivedEnd,P.legacyTrack]);function Te(n){if(n==null||n.trim()==="")return null;let e=Number(n);return Number.isFinite(e)?e:null}var wt=n=>{let e=Te(n);return e!==null&&e>=0?e:null};function Rt(n){return wt(n("data-playback-start"))??wt(n("data-media-start"))??0}var B=.1,W=10;function xe(n){return Number.isFinite(n)&&n>0?Math.max(B,Math.min(W,n)):1}function kt(n,e=1){let t=Number.parseFloat(n("data-playback-rate")??"");return xe(Number.isFinite(t)&&t>0?t:e)}function Mt(n){let e=Te(n("data-duration"));return e!==null&&e>0?e:null}function It(n,e){let t=Mt(n);if(t!==null)return t;let i=Te(n("data-end"));return i!==null?i-e:null}var hn=3;function we(n,e,t){return Number.isFinite(n)?Math.max(0,n-e)/xe(t):null}function Ct(n){let{tag:e,authoredDurationSeconds:t,sourceDurationSeconds:i,mediaStartSeconds:r,playbackRate:o}=n;if(t!==null&&t>0)return{seconds:t,source:"authored"};if(e==="img")return{seconds:hn,source:"default"};if(i===null)return{seconds:null,source:"pending",reason:"source duration not yet probed"};let a=we(i,r,o);return a===null?{seconds:null,source:"pending",reason:"source reported a non-finite duration"}:{seconds:a,source:"media"}}var Nt="data-fx-chain",cr=Nt.slice(5);var $=(n="frequency",e="Frequency",t=1e3,i=20,r=2e4)=>({kind:"number",key:n,label:e,unit:"Hz",min:i,max:r,step:1,default:t,scale:"log",automatable:!0}),Re=(n=.707,e="Bandwidth \u2014 higher is narrower.")=>({kind:"number",key:"q",label:"Q",unit:"",min:.1,max:20,step:.01,default:n,scale:"log",automatable:!0,hint:e}),se=(n=-40,e=40,t=0)=>({kind:"number",key:"gain",label:"Gain",unit:"dB",min:n,max:e,step:.1,default:t,automatable:!0}),Dt={kind:"enum",key:"poles",label:"Slope",options:[{value:"1",label:"6 dB/oct"},{value:"2",label:"12 dB/oct"}],default:"2",hint:"Two poles is the usual biquad; one pole is gentler."},Lt=[{id:"gain",label:"Gain",group:"dynamics",description:"Raise or lower the whole signal. Automate it to duck under something else.",params:[se(-60,12,0)],web:"gain-node"},{id:"peaking",label:"Peaking EQ",group:"filter",description:"Boost or cut a band, leaving everything either side alone.",params:[$("frequency","Frequency",1e3),se(-40,40,0),Re(1)],web:"biquad-peaking"},{id:"lowshelf",label:"Low Shelf",group:"filter",description:"Lift or drop everything below the corner frequency.",params:[$("frequency","Frequency",200,20,2e3),se(-40,40,0)],web:"biquad-lowshelf"},{id:"highshelf",label:"High Shelf",group:"filter",description:"Lift or drop everything above the corner frequency.",params:[$("frequency","Frequency",4e3,500,2e4),se(-40,40,0)],web:"biquad-highshelf"},{id:"highpass",label:"High-pass",group:"filter",description:"Remove low frequencies \u2014 the usual fix for rumble on a voice.",params:[$("frequency","Cutoff",300,20,2e4),Re(.707),Dt],web:"biquad-highpass"},{id:"lowpass",label:"Low-pass",group:"filter",description:"Remove high frequencies \u2014 darkens or muffles a track.",params:[$("frequency","Cutoff",8e3,100,2e4),Re(.707),Dt],web:"biquad-lowpass"},{id:"compressor",label:"Compressor",group:"dynamics",description:"Pull loud parts down so the quiet ones can come up.",params:[{kind:"number",key:"threshold",label:"Threshold",unit:"dB",min:-60,max:0,step:.5,default:-24,hint:"Level above which the compressor starts working."},{kind:"number",key:"ratio",label:"Ratio",unit:":1",min:1,max:20,step:.1,default:4},{kind:"number",key:"attack",label:"Attack",unit:"ms",min:.01,max:2e3,step:.1,default:20,scale:"log"},{kind:"number",key:"release",label:"Release",unit:"ms",min:.01,max:9e3,step:1,default:250,scale:"log"},{kind:"number",key:"knee",label:"Knee",unit:"",min:1,max:8,step:.01,default:2.83,hint:"1 is a hard corner; higher eases into it."},{kind:"number",key:"makeup",label:"Makeup",unit:"dB",min:0,max:36,step:.1,default:0},{kind:"number",key:"mix",label:"Mix",unit:"",min:0,max:1,step:.01,default:1,hint:"Below 1 blends the dry signal back in."}],web:"worklet-compressor"},{id:"limiter",label:"Limiter",group:"dynamics",description:"Hard ceiling \u2014 nothing gets past the limit.",params:[{kind:"number",key:"limit",label:"Ceiling",unit:"dB",min:-24,max:0,step:.1,default:-1},{kind:"number",key:"attack",label:"Attack",unit:"ms",min:.1,max:80,step:.1,default:5},{kind:"number",key:"release",label:"Release",unit:"ms",min:1,max:8e3,step:1,default:50,scale:"log"},{kind:"number",key:"level_out",label:"Output",unit:"dB",min:-24,max:24,step:.1,default:0}],web:"worklet-limiter"},{id:"gate",label:"Noise Gate",group:"dynamics",description:"Silence the track when it drops below the threshold.",params:[{kind:"number",key:"threshold",label:"Threshold",unit:"dB",min:-80,max:0,step:.5,default:-35},{kind:"number",key:"range",label:"Range",unit:"dB",min:-80,max:0,step:.5,default:-24,hint:"How far down the gate pulls when closed."},{kind:"number",key:"ratio",label:"Ratio",unit:":1",min:1,max:20,step:.1,default:10},{kind:"number",key:"attack",label:"Attack",unit:"ms",min:.01,max:9e3,step:.1,default:1,scale:"log"},{kind:"number",key:"release",label:"Release",unit:"ms",min:.01,max:9e3,step:1,default:100,scale:"log"},{kind:"number",key:"knee",label:"Knee",unit:"",min:1,max:8,step:.01,default:2.83}],web:"worklet-gate"},{id:"saturate",label:"Saturation",group:"nonlinear",description:"Soft-clip the waveform for warmth or outright distortion.",params:[{kind:"enum",key:"type",label:"Curve",options:[{value:"tanh",label:"Tanh"},{value:"atan",label:"Arctan"},{value:"cubic",label:"Cubic"},{value:"exp",label:"Exponential"},{value:"alg",label:"Algebraic"},{value:"quintic",label:"Quintic"},{value:"sin",label:"Sine"},{value:"erf",label:"Error function"},{value:"hard",label:"Hard clip"}],default:"tanh"},{kind:"number",key:"threshold",label:"Threshold",unit:"dB",min:-40,max:0,step:.1,default:-6},{kind:"number",key:"output",automatable:!0,label:"Output",unit:"dB",min:-24,max:24,step:.1,default:0},{kind:"number",key:"oversample",label:"Oversample",unit:"x",min:1,max:8,step:1,default:4,hint:"Higher costs more but keeps aliasing down."}],web:"waveshaper"},{id:"bitcrush",label:"Bitcrush",group:"nonlinear",description:"Drop bit depth and sample rate for a lo-fi, digital sound.",params:[{kind:"number",key:"bits",label:"Bit depth",unit:"bit",min:1,max:32,step:.1,default:8},{kind:"number",key:"samples",label:"Sample hold",unit:"x",min:1,max:250,step:1,default:1,hint:"Repeats each sample N times \u2014 a crude downsample."},{kind:"number",key:"mix",label:"Mix",unit:"",min:0,max:1,step:.01,default:1}],web:"worklet-bitcrush"},{id:"pitchshift",label:"Pitch shift",group:"time",description:"Shifts pitch up or down without changing playback speed. Adds ~50 ms of latency.",params:[{kind:"number",key:"semitones",label:"Semitones",unit:"st",min:-12,max:12,step:1,default:0},{kind:"number",key:"mix",label:"Mix",unit:"",min:0,max:1,step:.01,default:1}],web:"worklet-pitchshift"},{id:"delay",label:"Delay",group:"time",description:"Repeating echoes behind the dry signal.",params:[{kind:"number",key:"time",automatable:!0,label:"Time",unit:"ms",min:1,max:5e3,step:1,default:250,scale:"log"},{kind:"number",key:"feedback",automatable:!0,label:"Feedback",unit:"",min:.01,max:.95,step:.01,default:.35},{kind:"number",key:"mix",automatable:!0,label:"Mix",unit:"",min:0,max:1,step:.01,default:.4}],web:"delay-feedback"},{id:"chorus",label:"Chorus",group:"time",description:"Detuned copies of the signal for width and thickness.",params:[{kind:"number",key:"delay",automatable:!0,label:"Delay",unit:"ms",min:1,max:100,step:.1,default:7},{kind:"number",key:"depth",automatable:!0,label:"Depth",unit:"ms",min:0,max:10,step:.01,default:2},{kind:"number",key:"speed",automatable:!0,label:"Rate",unit:"Hz",min:.01,max:10,step:.01,default:1},{kind:"number",key:"mix",automatable:!0,label:"Mix",unit:"",min:0,max:1,step:.01,default:.5}],web:"chorus-lfo"},{id:"phaser",label:"Phaser",group:"time",description:"Sweeping notches moving through the spectrum.",params:[{kind:"number",key:"in_gain",automatable:!0,label:"Input",unit:"",min:0,max:1,step:.01,default:.4},{kind:"number",key:"out_gain",automatable:!0,label:"Output",unit:"",min:0,max:2,step:.01,default:.74},{kind:"number",key:"delay",label:"Delay",unit:"ms",min:.1,max:5,step:.1,default:3},{kind:"number",key:"decay",label:"Decay",unit:"",min:0,max:.99,step:.01,default:.4},{kind:"number",key:"speed",automatable:!0,label:"Rate",unit:"Hz",min:.1,max:2,step:.01,default:.5},{kind:"enum",key:"type",label:"Waveform",options:[{value:"0",label:"Triangular"},{value:"1",label:"Sinusoidal"}],default:"0"}],web:"allpass-phaser"},{id:"reverb",label:"Reverb",group:"time",description:"Room tail. Both ends convolve the same generated impulse, so preview matches render.",params:[{kind:"number",key:"size",label:"Room size",unit:"",min:.05,max:1,step:.01,default:.7},{kind:"number",key:"damping",label:"Damping",unit:"",min:0,max:1,step:.01,default:.5,hint:"Higher rolls the top off the tail faster."},{kind:"number",key:"wet",automatable:!0,label:"Wet",unit:"",min:0,max:1,step:.01,default:.35},{kind:"number",key:"dry",automatable:!0,label:"Dry",unit:"",min:0,max:1,step:.01,default:.7}],web:"convolver"}],mr=new Map(Lt.map(n=>[n.id,n]));var pr=Lt.map(n=>n.id);function bn(n){return 10**(n/20)}var Pt=bn(12);var Me="data-automation",Er=Me.slice(5),ke=1,gn=512,k=class extends Error{constructor(e){super(e),this.name="AudioAutomationError"}},ue="volume",le="rate";function Ft(n){if(n===ue)return{kind:"volume"};if(n===le)return{kind:"rate"};let e=n.split(".");if(e.length===3&&e[0]==="fx"&&e[1]===_n){let r=e[2];return r?{kind:"preset",presetId:r}:null}if(e.length!==3||e[0]!=="fx")return null;let[,t,i]=e;return!t||!i?null:{kind:"fx",nodeId:t,param:i}}var _n="preset";var yn={min:0,max:Pt,step:.01,unit:"",label:"Volume",scale:"linear",default:1},vn={min:B,max:W,step:.05,unit:"x",label:"Speed",scale:"log",default:1};function q(n){if(typeof n=="number")return Number.isFinite(n)?n:null;if(typeof n=="string"&&n.trim()!==""){let e=Number(n);return Number.isFinite(e)?e:null}return null}function An(n){let e=q(n);return e===null||e===0?0:Math.min(1,Math.max(-1,e))}function Ot(n,e){let t=q(n),i=q(e);if(t===null||i===null)return null;let r=s=>Math.min(.999,Math.max(.001,s)),o=r(t),a=r(i);return Math.abs(o-a)<1e-6?null:{x:o,y:a}}function En(n){let e=An(n?.curve),t=Ot(n?.viaX,n?.viaY);return{...e?{curve:e}:{},...t?{viaX:t.x,viaY:t.y}:{}}}function Sn(n,e){let t=q(n?.t),i=q(n?.v);if(t===null||i===null)return null;let r=e?Math.min(e.max,Math.max(e.min,i)):i;return{t:Math.max(0,t),v:r,...En(n)}}function Tn(n,e){let t=n.map(r=>Sn(r,e)).filter(r=>r!==null).sort((r,o)=>r.t-o.t),i=[];for(let r of t)i.length>0&&i[i.length-1].t===r.t?i[i.length-1]=r:i.push(r);return i.slice(0,gn)}function xn(n){let e=[];for(let t of n.lanes){if(!Ft(t.target))continue;let i=t.target===ue?yn:t.target===le?vn:null,r=Tn(t.points??[],i);r.length>0&&e.push({target:t.target,points:r})}return{version:ke,lanes:e}}function Ut(n){let e;try{e=JSON.parse(n)}catch(r){throw new k(`Automation is not valid JSON: ${r.message}`)}if(typeof e!="object"||e===null)throw new k("Automation must be a JSON object.");let t=e;if(t.version!==ke)throw new k(`Unsupported automation version: ${String(t.version)}`);if(!Array.isArray(t.lanes))throw new k("Automation is missing a `lanes` array.");let i=t.lanes.map((r,o)=>{if(typeof r!="object"||r===null)throw new k(`Lane ${o} is not an object.`);let a=r;if(typeof a.target!="string"||!Ft(a.target))throw new k(`Lane ${o} has an unreadable target: ${String(a.target)}`);if(!Array.isArray(a.points))throw new k(`Lane ${o} is missing a \`points\` array.`);return{target:a.target,points:a.points}});return xn({version:ke,lanes:i})}function wn(n,e){return e?Math.pow(n,Math.pow(2,2*e)):n}function Rn(n,e){let t=n-.5,i=e-.5,r=.999,o=1e6,a=t>0?t/(r-n):t<0?-t/(n-(1-r)):0,s=i>0?i/(r-e):i<0?-i/(e-(1-r)):0,u=Math.min(o,Math.max(1,a,s));return{cx:n+t/u,cy:e+i/u,w:u}}function kn(n,e,t){let{cx:i,cy:r,w:o}=Rn(e,t),a=2-2*o,s=n*a-1+2*o*i,u=-n*a-2*o*i,d=Mn(s,u,n),c=1-d,g=c*c+2*o*d*c+d*d;return g>0?(2*o*r*d*c+d*d)/g:n}function Mn(n,e,t){if(Math.abs(n)<1e-12)return Math.abs(e)<1e-12?t:-t/e;let i=Math.sqrt(Math.max(0,e*e-4*n*t)),r=(-e+i)/(2*n),o=(-e-i)/(2*n),a=s=>s>=-1e-9&&s<=1+1e-9;return a(r)?Math.min(1,Math.max(0,r)):a(o)?Math.min(1,Math.max(0,o)):t}function In(n,e){let t=Ot(e.viaX,e.viaY);return t?kn(Math.min(1,Math.max(0,n)),t.x,t.y):wn(n,e.curve)}function Cn(n,e,t,i){return i==="log"&&n>0&&e>0?Math.exp(Math.log(n)+(Math.log(e)-Math.log(n))*t):n+(e-n)*t}function de(n,e,t="linear"){let i=n.points;if(i.length===0)return 0;let r=i[0];if(e<=r.t)return r.v;let o=i[i.length-1];if(e>=o.t)return o.v;let a=0,s=i.length-1;for(;s-a>1;){let g=a+s>>1;i[g].t<=e?a=g:s=g}let u=i[a],d=i[s],c=d.t-u.t;return c<=0?d.v:Cn(u.v,d.v,In((e-u.t)/c,u),t)}var ce=new Map,Dn=64;function Ht(n,e=ue){let t=`${e}\0${n}`,i=ce.get(t);if(i!==void 0)return i;let r=null;try{r=Ut(n).lanes.find(o=>o.target===e)??null}catch{r=null}return ce.size>Dn&&ce.clear(),ce.set(t,r),r}var Vt=48,Gt=new WeakMap;function Nn(n){let e=n.points,t=e[0].v,i=e[e.length-1].v,r=[0],o=[0],a=u=>{let d=r[r.length-1];if(u<=d)return;let c=de(n,d,"log");r.push(u),o.push(o[o.length-1]+(c+de(n,u,"log"))/2*(u-d))},s=Math.max(0,e[0].t);a(s);for(let u=1;u<e.length;u+=1){let d=e[u-1].t,c=e[u].t;if(!(c<=0))for(let g=1;g<=Vt;g+=1)a(Math.max(d,0)+(c-d)*g/Vt)}return{ts:Float64Array.from(r),ss:Float64Array.from(o),firstRate:t,lastRate:i}}function Ln(n){let e=Gt.get(n);return e||(e=Nn(n),Gt.set(n,e)),e}function Pn(n){return typeof n!="number"&&n.points.length>0}function Fn(n,e,t){let i=0,r=n.length-1;for(;r-i>1;){let o=i+r>>1;n[o]<=t?i=o:r=o}return e[i]+(e[r]-e[i])*(t-n[i])/(n[r]-n[i])}function Ie(n,e){if(typeof n=="number")return e/n;if(!Pn(n))return e;let{ts:t,ss:i,firstRate:r,lastRate:o}=Ln(n),a=t.length-1;return e<=0?e/r:e>=i[a]?t[a]+(e-i[a])/o:Fn(i,t,e)}function On(n){return n?Ht(n,le):null}function Bt(n,e){return On(n)??e}var Un="http://www.w3.org/1999/xhtml";function Wt(n){return n!=null&&n.nodeType===1}function Hn(n){return Wt(n)&&n.namespaceURI===Un}function Ce(n,e){return Hn(n)&&n.localName===e}function Vn(n){return Ce(n,"video")}function Gn(n){return Ce(n,"audio")}function C(n){return Vn(n)||Gn(n)}function De(n){return Ce(n,"img")}var _=Object.freeze({start:"data-start",duration:"data-duration",trackIndex:"data-track-index",derivedEnd:"data-end",legacyTrack:"data-layer"}),Cr=Object.freeze([_.start,_.duration,_.trackIndex]),Dr=Object.freeze([_.derivedEnd]),Nr=Object.freeze([_.derivedEnd,_.legacyTrack]);function M(n){if(n==null||n.trim()==="")return null;let e=Number(n);return Number.isFinite(e)?e:null}var zt=/^[A-Za-z0-9_.:-]+$/;function jt(n,e){let t=n.charCodeAt(e);return t>=48&&t<=57}function $t(n,e){let t=e;for(;t>=0&&jt(n,t);)t--;return t}function Bn(n,e){let t=e;for(;t>=0&&(n[t]??"").trim()==="";)t--;return t}function Wn(n){let e=n.length-1;if(!jt(n,e))return null;let t=$t(n,e);return n[t]==="."&&(t=$t(n,t-1)),t+1}function $n(n){let e=Wn(n);if(e==null)return null;let t=Bn(n,e-1),i=n[t];if(i!=="+"&&i!=="-")return null;let r=n.slice(0,t).trim();if(!zt.test(r))return null;let o=Number(n.slice(e));return Number.isFinite(o)?{refId:r,operator:i,magnitude:o}:null}function me(n){let e=(n??"").trim();if(!e)return null;let t=M(e);if(t!=null)return{kind:"absolute",value:t};if(zt.test(e))return{kind:"reference",refId:e,offset:0};let i=$n(e);return i?{kind:"reference",refId:i.refId,offset:i.operator==="-"?-i.magnitude:i.magnitude}:null}function T(n,e,t,i){n.push({code:e,attribute:t,value:i})}function qn(n,e,t,i){if(e==null||e.trim()==="")return t.defaultStart===void 0?0:t.defaultStart;if(!n)return T(i,"invalid-start",_.start,e),null;if(n.kind==="absolute")return Math.max(0,n.value);let r=t.resolveReferenceEnd?.(n.refId);return r==null||!Number.isFinite(r)?(T(i,"unresolved-start-reference",_.start,e),null):Math.max(0,r+n.offset)}var zn=1e-9;function jn(n,e){return Math.abs(n-e)<=zn}function Yn(n,e,t){let i=M(n);if(i==null){T(t,"deprecated-end",_.derivedEnd,n),T(t,"invalid-end",_.derivedEnd,n);return}if(e==null){T(t,"deprecated-end",_.derivedEnd,n);return}jn(i,e)||(T(t,"deprecated-end",_.derivedEnd,n),T(t,"conflicting-end",_.derivedEnd,n))}function Xn(n,e,t){let i=M(n);return i==null||i<0?(T(t,"invalid-duration",_.duration,n),{duration:null,end:null,durationSource:"invalid"}):{duration:i,end:e==null?null:e+i,durationSource:"duration"}}function Kn(n,e,t){T(t,"deprecated-end",_.derivedEnd,n);let i=M(n);return i==null?(T(t,"invalid-end",_.derivedEnd,n),{duration:null,end:null,durationSource:"invalid"}):e==null?{duration:null,end:i,durationSource:"legacy-end"}:i<e?(T(t,"end-before-start",_.derivedEnd,n),{duration:null,end:null,durationSource:"invalid"}):{duration:i-e,end:i,durationSource:"legacy-end"}}function Jn(n,e,t){let i=n.getAttribute(_.duration),r=n.getAttribute(_.derivedEnd);if(i==null)return r==null?{duration:null,end:null,durationSource:"missing"}:Kn(r,e,t);let o=Xn(i,e,t);return r!=null&&Yn(r,o.end,t),o}function qt(n,e,t,i){let r=M(n);return r==null||!Number.isInteger(r)?(T(i,"invalid-track-index",e,n),{trackIndex:0,trackSource:"invalid"}):{trackIndex:r,trackSource:t}}function Zn(n,e){let t=n.getAttribute(_.trackIndex),i=n.getAttribute(_.legacyTrack);if(t==null&&i==null)return{trackIndex:0,trackSource:"default"};if(t==null&&i!=null)return T(e,"deprecated-layer",_.legacyTrack,i),qt(i,_.legacyTrack,"legacy-layer",e);let r=qt(t??"",_.trackIndex,"track-index",e);if(i==null)return r;T(e,"deprecated-layer",_.legacyTrack,i);let o=M(i);return o!=null&&o!==r.trackIndex&&T(e,"conflicting-layer",_.legacyTrack,i),r}function Ne(n,e={}){let t=[],i=n.getAttribute(_.start),r=me(i),o=qn(r,i,e,t),a=Jn(n,o,t),s=Zn(n,t);return{startExpression:r,start:o,...a,...s,diagnostics:t}}function z(n){return M(n)}function pe(n){return kt(e=>n.getAttribute(e),C(n)?n.defaultPlaybackRate:1)}function Le(n){return Bt(n.getAttribute("data-automation"),pe(n))}function Yt(n){return Rt(e=>n.getAttribute(e))}function j(n,e){return Qn(e,Yt(n),Le(n))}function fe(n,e=0){return!De(n)||!n.hasAttribute("data-start")&&!n.hasAttribute("data-track-index")?null:Ct({tag:"img",authoredDurationSeconds:It(t=>n.getAttribute(t),e),sourceDurationSeconds:null,mediaStartSeconds:0,playbackRate:1}).seconds}function Qn(n,e,t){return typeof t=="number"?we(n,e,t):Number.isFinite(n)?Ie(t,Math.max(0,n-e)):null}var Xt="data-hf-media-start-basis";function ei(n){return n?.trim().toLowerCase()==="global"?"global":"local"}function ti(n){return ei(n.basis)==="global"?n.authoredStart:n.hostStart+n.authoredStart}function Kt(n){return n.hasAutoStart||n.authoredStart==null||n.hostStart<=0?n.ordinaryStart():ti({authoredStart:n.authoredStart,hostStart:n.hostStart,basis:n.basis})}function he(n){let e=n.timelineRegistry??{},t=n.includeAuthoredTimingAttrs??!1,i=n.documentRef??document,r=new WeakMap,o=new WeakMap,a=new Set,s=m=>{let f=i.getElementById(m);return f||(i.querySelector(`[data-composition-id="${CSS.escape(m)}"]`)??null)},u=m=>{let f=o.get(m);if(f!==void 0)return f;let h=null,b=ae({start:0,duration:m.getAttribute("data-duration"),authoredDuration:t?m.getAttribute("data-hf-authored-duration"):null});if(b?.duration!=null&&b.duration>0&&(h=b.duration),h==null||h<=0){let y=c(m,0),S=ae({start:y,end:m.getAttribute("data-end"),authoredEnd:t?m.getAttribute("data-hf-authored-end"):null});S?.duration!=null&&S.duration>0&&(h=S.duration)}if((h==null||h<=0)&&C(m)&&(h=j(m,m.duration)),(h==null||h<=0)&&(h=fe(m)),h==null||h<=0){let y=m.getAttribute("data-composition-id");if(y){let S=e[y]??null;if(S&&typeof S.duration=="function")try{let v=Number(S.duration());Number.isFinite(v)&&v>0&&(h=v)}catch(v){oe("runtime.startResolver.site1",v)}}}return h!=null&&Number.isFinite(h)&&h>0?(o.set(m,h),h):(o.set(m,null),null)},d=(m,f)=>{if(m.hasAttribute("data-composition-id")){let b=m.parentElement?.closest("[data-composition-id]");return b?c(b,f):0}let h=m.closest("[data-composition-id]");return h?c(h,f):0},c=(m,f)=>{let h=r.get(m);if(h!==void 0)return h??f;if(a.has(m))return f;a.add(m);try{let b=me(m.getAttribute("data-start"));if(!b){if(m.hasAttribute("data-composition-id")){let A=m.parentElement;if(A&&(A.hasAttribute("data-composition-src")||A.hasAttribute("data-composition-id")||A.hasAttribute("data-composition-file"))){let R=c(A,f);return r.set(m,R),R}}return r.set(m,f),f}if(b.kind==="absolute"){let A=Math.max(0,b.value),R=Math.max(0,d(m,f)+A);return r.set(m,R),R}let y=s(b.refId);if(!y)return r.set(m,f),f;let S=c(y,0),v=u(y);if(v==null||v<=0){let A=Math.max(0,S+b.offset);return r.set(m,A),A}let w=Math.max(0,S+v+b.offset);return r.set(m,w),w}finally{a.delete(m)}};return{resolveStartForElement:(m,f=0)=>c(m,Math.max(0,f)),resolveDurationForElement:m=>u(m),resolveMediaStartForElement:m=>{let f=m.closest("[data-composition-id]"),h=f?c(f,0):0;return Kt({authoredStart:z(m.getAttribute("data-start")),hostStart:h,hasAutoStart:m.hasAttribute("data-hf-auto-start"),basis:m.getAttribute(Xt),ordinaryStart:()=>c(m,h)})}}}var be=(n,e,t)=>n>=e&&n<t;var Pe=(n,e,t,i)=>be(n,e,t)||n>=e&&i>0&&t>=i-1e-6;var ii="data-fade-in",ri="data-fade-out",ao=ii.slice(5),so=ri.slice(5),oi=Object.freeze({fadeIn:0,fadeOut:0});var si=["backdrop-filter","clip-path","filter","mask","mask-border-source","mask-image","perspective","rotate","scale","transform","translate","-webkit-mask-image"],Ho=new Set([...si,"contain","isolation","mask-border","mix-blend-mode","opacity"]);function ui(n){return Number.isFinite(n)&&n>0?n:30}function li(n){return Number.isFinite(n)&&n>0?n:0}function Fe(n,e){let t=ui(e),i=li(n),r=i*t,o=Math.round(r);return Math.abs(r-o)<=.001?o/t:i}var di=["seconds-time","rational-fps","seek-keep-playing","composition-manifest-v1","runtime-data"];function ci(n,e){let t=Math.abs(n),i=Math.abs(e);for(;i!==0;){let r=t%i;t=i,i=r}return t||1}function mi(n){let e=Number.isFinite(n)&&n>0?n:30,t=Number.isInteger(e)?1:1e6,i=Math.round(e*t),r=ci(i,t);return{numerator:i/r,denominator:t/r}}function pi(n){if(typeof n!="object"||n===null)return null;let e=n;return!Number.isFinite(e.numerator)||!Number.isFinite(e.denominator)||(e.numerator??0)<=0||(e.denominator??0)<=0?null:Number(e.numerator)/Number(e.denominator)}function Oe(n){return{protocolVersion:1,capabilities:di,fps:mi(n)}}function fi(n){return Array.isArray(n)&&n.every(e=>typeof e=="string")}function Jt(n,e=30){if(typeof n!="object"||n===null)return{status:"legacy",fps:e};let t=n;if(t.protocolVersion===void 0)return{status:"legacy",fps:e};if(t.protocolVersion!==1)return{status:"unsupported",code:"unsupported_protocol_version",receivedVersion:t.protocolVersion};let i=pi(t.fps);return i===null||!fi(t.capabilities)?{status:"unsupported",code:"invalid_protocol_metadata",receivedVersion:t.protocolVersion}:{status:"supported",fps:i,metadata:t}}function Zt(n,e){let t=n.tagName.toLowerCase();if(t==="script"||t==="style"||t==="link"||t==="meta")return!1;let r=t==="video"||t==="audio"?e.resolver.resolveMediaStartForElement(n):e.resolver.resolveStartForElement(n,0),o=e.resolver.resolveDurationForElement(n),a=n.getAttribute("data-composition-id");if(a){let c=e.timelineRegistry[a],g=c&&typeof c.duration=="function"?Number(c.duration()):null;!(n.hasAttribute("data-duration")||n.hasAttribute("data-end")||n.hasAttribute(Tt)||n.hasAttribute(xt))&&(o==null||o<=0)&&g!=null&&Number.isFinite(g)&&g>0&&(o=g)}let s=o!=null&&o>0?r+o:Number.POSITIVE_INFINITY,u=e.exportRenderSeek?Fe(r,e.canonicalFps):r,d=e.exportRenderSeek&&Number.isFinite(s)?Fe(s,e.canonicalFps):s;return Pe(e.currentTime,u,d,e.compositionDuration)}var He="first-frame",hi=3;function Y(n){let e=n.ownerDocument?.defaultView;return e&&n instanceof e.Element?!0:n instanceof Element}function x(n){if(!Y(n)||n.tagName!=="AUDIO"&&n.tagName!=="VIDEO")return!1;let e=n.ownerDocument?.defaultView;return e&&n instanceof e.HTMLMediaElement?!0:n instanceof HTMLMediaElement}function bi(n){return n.hasAttribute("data-start")||n.hasAttribute("data-track-index")}function gi(n,e,t){let i=n;for(;i;){if(bi(i)&&!Zt(i,{currentTime:0,compositionDuration:Number.POSITIVE_INFINITY,canonicalFps:30,exportRenderSeek:!1,timelineRegistry:t,resolver:e}))return!1;i=i.parentElement}return!0}function Qt(n,e,t,i){return e==="all"?!0:gi(n,t,i)}function Ve(n,{scope:e="all"}={}){let t=n.defaultView,i=he({documentRef:n,timelineRegistry:t?.__timelines,includeAuthoredTimingAttrs:!0}),r=Array.from(n.querySelectorAll("video, audio")).filter(x).filter(s=>Qt(s,e,i,t?.__timelines??{})).filter(s=>s.readyState<hi),o=Array.from(n.querySelectorAll("img")).filter(s=>Qt(s,e,i,t?.__timelines??{})).filter(s=>!s.complete),a=n.fonts?.status==="loading";return{pendingMedia:r,pendingImages:o,fontsLoading:a}}function _i(n,{pendingMedia:e,pendingImages:t,fontsLoading:i},r){let o=e.map(u=>new Promise(d=>{if(u.error){d();return}let c=()=>{u.removeEventListener("canplay",c),u.removeEventListener("error",c),r.removeEventListener("abort",c),d()};u.addEventListener("canplay",c),u.addEventListener("error",c),r.addEventListener("abort",c,{once:!0})})),a=t.map(u=>u.decode?u.decode().catch(()=>{}):Promise.resolve()),s=i&&n.fonts?n.fonts.ready.then(()=>{}):Promise.resolve();return Promise.all([...o,...a,s]).then(()=>{})}function yi(n,e,{scope:t="all"}={}){let i=Ve(n,{scope:t});return i.pendingMedia.length===0&&i.pendingImages.length===0&&!i.fontsLoading?null:_i(n,i,e)}var vi=50;function Ai(n,e){let t=n.defaultView;return!t||t.__renderReady||!t.__hf?null:new Promise(i=>{let r,o=()=>{r!==void 0&&clearTimeout(r),e.removeEventListener("abort",o),i()};if(e.aborted){o();return}e.addEventListener("abort",o,{once:!0});let a=()=>{if(t.__renderReady){o();return}r=setTimeout(a,vi)};a()})}var Ei=50,Si=2,Ti=1500;function Ue(n,e){return new Promise(t=>{if(e.aborted){t(-1);return}let i=0,r=()=>{n.cancelAnimationFrame?.(i),t(-1)};e.addEventListener("abort",r,{once:!0}),i=n.requestAnimationFrame(o=>{e.removeEventListener("abort",r),t(o)})})}function xi(n,e){let t=n.defaultView;return t?(async()=>{let i=await Ue(t,e);if(e.aborted)return;let r=await Ue(t,e),o=0;for(;!e.aborted&&o<Si;){if(r-i>=Ti)return;let a=await Ue(t,e);if(e.aborted)return;o=a-r<Ei?o+1:0,r=a}})():null}var wi=8e3;function Ri(n,e,t={}){let i=t.inputs??[(d,c)=>yi(d,c,{scope:t.scope}),Ai,xi],r=new AbortController,o=i.map(d=>d(n,r.signal)).filter(d=>d!==null);if(o.length===0){e({timedOut:!1});return}let a=t.timeoutMs??wi,s,u=new Promise(d=>{s=setTimeout(()=>d("timed-out"),a)});Promise.race([Promise.all(o).then(()=>"done"),u]).then(d=>{clearTimeout(s),r.abort(),e({timedOut:d==="timed-out"})})}function en(n,e,t={}){Ri(n,e,{...t,scope:He})}var ki=.05,Mi=2,ge=class{_entries=[];_mediaObserver;_playbackErrorPosted=!1;_audioOwner="runtime";_urlAudioEntry=null;_urlAudioSrc=null;_dispatchEvent;_getMuted;_getVolume;_getPlaybackRate;_getCurrentTime;_isPaused;constructor(e){this._dispatchEvent=e.dispatchEvent,this._getMuted=e.getMuted,this._getVolume=e.getVolume,this._getPlaybackRate=e.getPlaybackRate,this._getCurrentTime=e.getCurrentTime,this._isPaused=e.isPaused}get audioOwner(){return this._audioOwner}get entries(){return this._entries}resetForIframeLoad(){this._playbackErrorPosted=!1;let e=this._audioOwner==="parent";this._audioOwner="runtime",this.pauseAll(),this.teardownObserver(),e&&this._dispatchEvent(new CustomEvent("audioownershipchange",{detail:{owner:"runtime",reason:"iframe-reload"}}))}destroy(){this.teardownObserver();for(let e of this._entries)e.el.pause(),e.el.src="";this._entries=[],this._urlAudioEntry=null,this._urlAudioSrc=null,this._audioOwner="runtime",this._playbackErrorPosted=!1}updateMuted(e){for(let t of this._entries)t.el.muted=e}updateVolume(e){for(let t of this._entries)t.el.volume=e}updatePlaybackRate(e){for(let t of this._entries)t.el.playbackRate=e}_playEntry(e){e.el.src&&e.el.play().catch(t=>this._reportPlaybackError(t))}_playEntryIfActive(e){this._refreshEntryBounds(e),this._inWindow(e,this._getCurrentTime())&&this._playEntry(e)}_refreshEntryBounds(e){if(!e.source?.isConnected)return;let t=Ne(e.source);e.start=t.start??0,e.duration=t.duration!=null&&t.duration>0?t.duration:Number.POSITIVE_INFINITY}_inWindow(e,t){return be(t,e.start,e.start+e.duration)}_gateEntryPlayback(e,t){return this._inWindow(e,t)?(this._audioOwner==="parent"&&!this._isPaused()&&e.el.paused&&this._playEntry(e),!0):(e.el.paused||e.el.pause(),e.driftSamples=0,!1)}playAll(){for(let e of this._entries)this._playEntryIfActive(e)}pauseAll(){for(let e of this._entries)e.el.pause()}stopAdoptedMedia(){for(let e of this._entries)e.source&&e.el.pause()}seekAll(e){for(let t of this._entries)this._refreshEntryBounds(t),this._inWindow(t,e)&&(t.el.currentTime=e-t.start)}scrubAll(e){for(let t of this._entries)this._refreshEntryBounds(t),this._inWindow(t,e)?(t.el.currentTime=e-t.start,this._playEntry(t)):t.el.paused||t.el.pause()}mirrorTime(e,t){let i=t?.force===!0;for(let r of this._entries){if(this._refreshEntryBounds(r),!this._gateEntryPlayback(r,e))continue;let o=e-r.start;Math.abs(r.el.currentTime-o)>ki?(r.driftSamples+=1,(i||r.driftSamples>=Mi)&&(r.el.currentTime=o,r.driftSamples=0)):r.driftSamples=0}}promoteToParentProxy(e,t){if(this._audioOwner==="parent")return;if(this._audioOwner="parent",e)for(let r of e.querySelectorAll("video, audio"))x(r)&&(r.muted=!0);let i=this._getCurrentTime();t?t(i,{force:!0}):this.mirrorTime(i,{force:!0}),this._isPaused()||this.playAll(),this._dispatchEvent(new CustomEvent("audioownershipchange",{detail:{owner:"parent",reason:"autoplay-blocked"}}))}setupFromIframe(e){let t=e.querySelectorAll("audio[data-start], video[data-start]");for(let i of t)x(i)&&this._adoptIframeMedia(i);this._observeDynamicMedia(e)}setupFromUrl(e){if(this._urlAudioSrc===e&&this._urlAudioEntry)return;this.teardownUrlAudio();let t=this._createEntry(e,"audio",0,1/0);this._urlAudioEntry=t,this._urlAudioSrc=t?e:null,t&&this._audioOwner==="parent"&&!this._isPaused()&&(this.mirrorTime(this._getCurrentTime(),{force:!0}),this.playAll())}teardownUrlAudio(){let e=this._urlAudioEntry;if(this._urlAudioEntry=null,this._urlAudioSrc=null,!e)return;e.el.pause(),e.el.src="";let t=this._entries.indexOf(e);t!==-1&&this._entries.splice(t,1)}teardownObserver(){this._mediaObserver?.disconnect(),this._mediaObserver=void 0}_reportPlaybackError(e){this._playbackErrorPosted||(this._playbackErrorPosted=!0,this._dispatchEvent(new CustomEvent("playbackerror",{detail:{source:"parent-proxy",error:e}})))}_createEntry(e,t,i,r,o){if(this._entries.some(d=>d.el.src===e))return null;let a=t==="video"?document.createElement("video"):new Audio;a.preload="auto",a.src=e,a.load(),a.muted=this._getMuted(),a.volume=this._getVolume();let s=this._getPlaybackRate();s!==1&&(a.playbackRate=s);let u={el:a,start:i,duration:r,driftSamples:0,source:o};return this._entries.push(u),u}_resolveIframeMediaSrc(e){let t=e.getAttribute("src")||e.querySelector("source")?.getAttribute("src");return t?new URL(t,e.ownerDocument.baseURI).href:null}_adoptIframeMedia(e){if(e.preload==="metadata"||e.preload==="none")return;let t=this._resolveIframeMediaSrc(e);if(!t)return;let i=Ne(e),r=i.start??0,o=i.duration??Number.POSITIVE_INFINITY,a=e.tagName==="VIDEO"?"video":"audio",s=this._createEntry(t,a,r,o,e);s&&this._audioOwner==="parent"&&(this.mirrorTime(this._getCurrentTime(),{force:!0}),this._isPaused()||this._playEntryIfActive(s))}_detachIframeMedia(e){let t=this._resolveIframeMediaSrc(e);if(!t)return;let i=this._entries.findIndex(o=>o.el.src===t);if(i===-1)return;let r=this._entries[i];r.el.pause(),r.el.src="",this._entries.splice(i,1)}_observeDynamicMedia(e){if(this.teardownObserver(),typeof MutationObserver>"u"||!e.body)return;let t=new MutationObserver(o=>{for(let a of o){if(a.type==="attributes"&&a.attributeName==="preload"){let s=a.target;x(s)&&s.matches("audio[data-start], video[data-start]")&&s.preload==="auto"&&this._adoptIframeMedia(s);continue}for(let s of a.addedNodes){if(!Y(s))continue;let u=[];x(s)&&s.matches("audio[data-start], video[data-start]")&&u.push(s);let d=s.querySelectorAll("audio[data-start], video[data-start]");for(let c of d)x(c)&&u.push(c);for(let c of u)this._adoptIframeMedia(c)}for(let s of a.removedNodes){if(!Y(s))continue;let u=[];x(s)&&s.matches("audio[data-start], video[data-start]")&&u.push(s);let d=s.querySelectorAll("audio[data-start], video[data-start]");for(let c of d)x(c)&&u.push(c);for(let c of u)this._detachIframeMedia(c)}}}),i={childList:!0,subtree:!0,attributes:!0,attributeFilter:["preload"]},r=Et(e);for(let o of r)t.observe(o,i);this._mediaObserver=t}};function tn(n,e,t,i){let r=(n.frame??0)/e,o=t.duration>0?Math.min(r,t.duration):r,a=!t.paused,s=!n.isPlaying,u=t.duration>0&&o>=t.duration&&(a||n.isPlaying);if(u&&i.getLoop())return i.media.audioOwner==="parent"&&i.media.pauseAll(),i.seek(0),i.play(),{...t,currentTime:o,paused:!1};let d={...t,currentTime:o,paused:s};i.media.audioOwner==="parent"&&(a&&s?i.media.pauseAll():!a&&!s&&i.media.playAll(),i.media.mirrorTime(o));let c=performance.now(),g=s!==t.paused;return(c-t.lastUpdateMs>100||g)&&(d.lastUpdateMs=c,i.updateControlsTime(o,t.duration),i.updateControlsPlaying(!s),i.dispatchEvent(new CustomEvent("timeupdate",{detail:{currentTime:o}}))),u&&(i.media.audioOwner==="parent"&&i.media.pauseAll(),d.paused=!0,i.updateControlsPlaying(!1),i.dispatchEvent(new Event("ended"))),d}function Ii(n){return Array.isArray(n)?n.filter(e=>typeof e=="object"&&e!==null&&typeof e.id=="string"&&typeof e.start=="number"&&typeof e.duration=="number"):[]}function nn(n,e,t){if(n.source!==e)return;let i=n.data;if(!i||i.source!=="hf-preview")return;let r=Jt(i);if(r.status==="unsupported"){t.dispatchEvent(new CustomEvent("runtimeprotocolerror",{detail:{code:r.code,receivedVersion:r.receivedVersion}}));return}if(t.setRuntimeFps?.(r.fps),i.type==="shader-transition-state"){let o=i.state&&typeof i.state=="object"?i.state:{};t.shaderLoader.update(o,t.getShaderLoadingMode()),t.dispatchEvent(new CustomEvent("shadertransitionstate",{detail:{compositionId:i.compositionId,state:o}}));return}if(i.type==="ready"){t.onRuntimeReady();return}if(i.type==="assets-ready"){t.onRuntimeAssetsReady?.(i.timedOut===!0);return}if(i.type==="runtime-data-error"){t.onRuntimeDataError?.(i.channel,i.requestId,i.message);return}if(i.type==="runtime-data-applied"){t.onRuntimeDataApplied?.(i.channel,i.requestId);return}if(i.type==="state"){t.setPlaybackState(tn({frame:i.frame??0,isPlaying:!!i.isPlaying},r.fps,t.getPlaybackState(),t));return}if(i.type==="media-autoplay-blocked"){if(t.shouldPromoteMediaAutoplayFallback?.()===!1)return;let o=null;try{o=t.getIframeDoc()}catch{}t.media.promoteToParentProxy(o,(a,s)=>t.media.mirrorTime(a,s)),t.sendControl("set-media-output-muted",{muted:!0});return}if(i.type==="timeline"&&i.durationInFrames>0){let o=Number(i.durationSeconds),a=Number(i.durationInFrames),s=Number.isFinite(o)&&o>0?o:a/r.fps;if(Number.isFinite(s)&&s>0){let u=t.getPlaybackState();t.setPlaybackState({...u,duration:s}),t.updateControlsTime(u.currentTime,s),t.onRuntimeTimelineReady(s,typeof i.assetsReady=="boolean"?i.assetsReady:void 0)}Number.isFinite(i.compositionWidth)&&i.compositionWidth>0&&Number.isFinite(i.compositionHeight)&&i.compositionHeight>0&&t.setCompositionSize(i.compositionWidth,i.compositionHeight),t.setScenes(Ii(i.scenes));return}i.type==="stage-size"&&Number.isFinite(i.width)&&i.width>0&&Number.isFinite(i.height)&&i.height>0&&t.setCompositionSize(i.width,i.height)}function Ci(n,e){return n.includes(e)?!0:/hyperframe\.runtime\.iife\.js|__hyperframes\s*=/.test(n)}var Di=new Set([">"," "," ",`
|
|
464
|
+
`,"\r","\f"]);function Ge(n,e){let t=n.toLowerCase(),i=`<${e}`,r=0;for(;r<t.length;){let o=t.indexOf(i,r);if(o<0)return null;let a=t[o+i.length];if(Di.has(a)){let s=t.indexOf(">",o+i.length);return s<0?null:{index:o,end:s+1}}r=o+i.length}return null}function rn(n,e){if(!n||Ci(n,e))return n;let t=`<script src="${e}"></script>`,i=Ge(n,"head");if(i)return n.slice(0,i.end)+t+n.slice(i.end);let r=Ge(n,"body");if(r)return n.slice(0,r.index)+t+n.slice(r.index);let o=Ge(n,"html");return o?n.slice(0,o.end)+t+n.slice(o.end):t+n}var D="shader-capture-scale",F="shader-loading",_e="runtime-src",on="__hf_shader_capture_scale",an="__hf_shader_loading",O=["Preparing scene transitions","Sampling outgoing scene motion","Sampling incoming scene motion","Caching transition frames","Finalizing transition preview"];function Be(n){if(n===null)return null;let e=Number(n);return!Number.isFinite(e)||e<=0?null:String(Math.min(1,Math.max(.25,e)))}function Ni(n){if(n===null||n.trim()==="")return"composition";let e=n.trim().toLowerCase();return e==="none"||e==="false"||e==="0"||e==="off"?"none":e==="player"||e==="true"||e==="1"||e==="on"?"player":"composition"}function sn(n,e){return n.filter(t=>t!==""&&t.split("=")[0]!==e)}function Li(n,e,t){let i=n.indexOf("#"),r=i>=0?n.slice(0,i):n,o=i>=0?n.slice(i):"",a=r.indexOf("?"),s=a>=0?r.slice(0,a):r,u=a>=0?r.slice(a+1):"",d=sn(u.split("&"),on);d=sn(d,an),e!==null&&d.push(`${on}=${encodeURIComponent(e)}`),t!=="composition"&&d.push(`${an}=${encodeURIComponent(t)}`);let c=d.join("&");return`${s}${c?`?${c}`:""}${o}`}function Pi(n,e,t){if(e===null&&t==="composition")return n;let i=[];e!==null&&i.push(`window.__HF_SHADER_CAPTURE_SCALE=${JSON.stringify(e)};`),t!=="composition"&&i.push(`window.__HF_SHADER_LOADING=${JSON.stringify(t)};`);let r=`<script data-hyperframes-player-shader-options>${i.join("")}</script>`;return/<head\b[^>]*>/i.test(n)?n.replace(/<head\b[^>]*>/i,o=>`${o}${r}`):/<html\b[^>]*>/i.test(n)?n.replace(/<html\b[^>]*>/i,o=>`${o}${r}`):`${r}${n}`}function U(n){return Ni(n.getAttribute(F))}function un(n){return Number(Be(n.getAttribute(D))??"1")}function X(n,e){return Li(e,Be(n.getAttribute(D)),U(n))}function K(n,e){return rn(Pi(e,Be(n.getAttribute(D)),U(n)),Fi(n))}function Fi(n){let e=n.getAttribute(_e)?.trim();if(!e)return L;try{let t=new URL(e,document.baseURI),i=t.protocol==="http:"||t.protocol==="https:",r=t.hostname==="127.0.0.1"||t.hostname==="localhost"||t.hostname==="[::1]";return i&&(r||t.origin===location.origin)?t.href:L}catch{return L}}function ln(){let n=document.createElement("div");n.className="hfp-shader-loader",n.setAttribute("role","status"),n.setAttribute("aria-live","polite"),n.setAttribute("aria-label","Preparing scene transitions"),n.setAttribute("data-hyperframes-ignore",""),n.draggable=!1;let e=f=>{f.preventDefault(),f.stopPropagation()};for(let f of["selectstart","dragstart","pointerdown","mousedown","click","dblclick","contextmenu","touchstart"])n.addEventListener(f,e,{capture:!0});let t=document.createElement("div");t.className="hfp-shader-loader-panel",t.draggable=!1;let 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="M10.1851 57.8021L33.1145 73.8313C36.2202 75.9978 41.5173 73.5433 42.4816 69.4984L51.7611 30.4271C52.7253 26.3822 48.5802 23.9277 44.4602 26.0942L13.917 42.1235C6.96677 45.7676 4.97564 54.1579 10.1851 57.8021Z" fill="url(#hfp-shader-loader-grad-left)"/>','<path d="M87.5129 57.5141L56.9696 73.5433C52.8371 75.7098 48.7046 73.2553 49.6688 69.2104L58.9483 30.1391C59.9125 26.0942 65.2097 23.6397 68.3154 25.8062L91.2447 41.8354C96.4668 45.4796 94.4631 53.8699 87.5129 57.5141Z" fill="url(#hfp-shader-loader-grad-right)"/>',"<defs>",'<linearGradient id="hfp-shader-loader-grad-left" x1="48.5676" y1="25" x2="44.7804" y2="71.9384" gradientUnits="userSpaceOnUse">','<stop stop-color="#06E3FA"/>','<stop offset="1" stop-color="#4FDB5E"/>',"</linearGradient>",'<linearGradient id="hfp-shader-loader-grad-right" x1="54.8282" y1="73.8392" x2="72.0989" y2="32.8932" gradientUnits="userSpaceOnUse">','<stop stop-color="#06E3FA"/>','<stop offset="1" stop-color="#4FDB5E"/>',"</linearGradient>","</defs>","</svg>"].join("");let r=document.createElement("div");r.className="hfp-shader-loader-title";let o=document.createElement("span");o.className="hfp-shader-loader-title-text",o.textContent=O[0]||"Preparing scene transitions",r.appendChild(o);let a=document.createElement("div");a.className="hfp-shader-loader-detail",a.textContent="Rendering animated scene samples for shader transitions.";let s=document.createElement("div");s.className="hfp-shader-loader-track",s.setAttribute("aria-hidden","true");let u=document.createElement("div");u.className="hfp-shader-loader-fill",s.appendChild(u);let d=document.createElement("div");d.className="hfp-shader-loader-progress";let c=f=>{let h=document.createElement("div");h.className="hfp-shader-loader-row";let b=document.createElement("span");b.className="hfp-shader-loader-label",b.textContent=f;let y=document.createElement("span");return y.className="hfp-shader-loader-value",h.appendChild(b),h.appendChild(y),d.appendChild(h),{row:h,label:b,value:y}},g=c("transition"),m=c("transition frame");return t.appendChild(i),t.appendChild(r),t.appendChild(a),t.appendChild(s),t.appendChild(d),n.appendChild(t),{root:n,fill:u,title:o,detail:a,transitionValue:g.value,frameLabel:m.label,frameValue:m.value,frameRow:m.row}}var Oi=420,ye=class{_el;_hideTimeout=null;_hiddenCallbacks=[];constructor(e){this._el=e}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(e){let t=this._el.root.classList;t.contains("hfp-visible")||t.contains("hfp-hiding")?this._hiddenCallbacks.push(e):e()}_flushHidden(){let e=this._hiddenCallbacks;this._hiddenCallbacks=[];for(let t of e)t()}reset(){this._hideTimeout&&(clearTimeout(this._hideTimeout),this._hideTimeout=null),this._el.root.classList.remove("hfp-visible","hfp-hiding"),this._flushHidden(),this._el.fill.style.transform="scaleX(0)",this._el.transitionValue.textContent="",this._el.frameValue.textContent="",this._el.frameRow.style.visibility="hidden"}update(e,t){if(t!=="player"){this.reset();return}if(e.ready||!e.loading){this.hide();return}this._el.root.setAttribute("aria-label","Preparing scene transitions");let i=typeof e.progress=="number"&&Number.isFinite(e.progress)?e.progress:0,r=typeof e.total=="number"&&Number.isFinite(e.total)?e.total:0,o=r>0?Math.min(1,Math.max(0,i/r)):0,a=Math.min(O.length-1,Math.floor(o*O.length));this._el.title.textContent=O[a]||"Preparing scene transitions",this._el.detail.textContent=e.phase==="cached"?"Loading cached transition frames before playback.":e.phase==="finalizing"?"Uploading transition textures for smooth playback.":"Rendering animated scene samples for shader transitions.",this._el.fill.style.transform=`scaleX(${o})`,this._el.transitionValue.textContent=e.currentTransition!==void 0&&e.transitionTotal!==void 0?`${e.currentTransition}/${e.transitionTotal}`:r>0?`${i}/${r}`:"";let s=e.transitionFrame!==void 0&&e.transitionFrames!==void 0?`${e.transitionFrame}/${e.transitionFrames}`:"";this._el.frameLabel.textContent=e.phase==="cached"?"cached transition frames":e.phase==="finalizing"?"finalizing transition frames":"rendering transition frames",this._el.frameValue.textContent=s,this._el.frameRow.style.visibility=s?"visible":"hidden",this._el.root.setAttribute("aria-valuenow",String(Math.round(o*100))),this.show()}showAssetsLoading(){this.reset(),this._el.title.textContent="Loading assets",this._el.detail.textContent="Waiting for images, video and fonts to finish loading.",this._el.root.setAttribute("aria-label","Loading assets"),this.show()}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()},Oi)}};var Ui=.1,Hi=5,We="sandbox-origin",dn=1e4,$e=8e3,qe="assets-loading",Vi=150;function ze(n){return!Number.isFinite(n)||n<=0?1:Math.max(Ui,Math.min(Hi,n))}var je=class extends HTMLElement{static get observedAttributes(){return["src","srcdoc","width","height","controls","muted","audio-locked","volume","poster","playback-rate","audio-src",We,_e,D,F]}shadow;container;iframe;posterEl=null;controlsApi=null;resizeObserver;shaderLoader;probe;_ready=!1;_assetsReady=!1;_painted=!1;_pendingPlay=!1;_assetsGeneration=0;_assetsLoadingShowTimer=null;_currentTime=0;_duration=0;_paused=!0;_scrubbing=!1;_lastUpdateMs=0;_volume=1;_compositionWidth=1920;_compositionHeight=1080;_rescaleWarned=!1;_directTimelineAdapter=null;_directTimelineClock;_parentTickRaf=null;_media;_scenes=[];_runtimeFps=30;_runtimeBridgeReady=!1;_runtimeAssetsReadyGeneration=-1;_runtimeData=new Map;_runtimeDataRequestId=0;_pendingRuntimeData=new Map;constructor(){super(),this.shadow=this.attachShadow({mode:"open"}),yt(this.shadow,ct),{container:this.container,iframe:this.iframe}=vt(),this.shadow.appendChild(this.container);let e=ln();this.shadow.appendChild(e.root),this.shaderLoader=new ye(e),this._media=new ge({dispatchEvent:t=>this.dispatchEvent(t),getMuted:()=>this.muted,getVolume:()=>this._volume,getPlaybackRate:()=>this.playbackRate,getCurrentTime:()=>this._currentTime,isPaused:()=>this._paused}),this._directTimelineClock=new re({onTimeUpdate:(t,i)=>{this._currentTime=t,this.controlsApi?.updateTime(t,i),this.dispatchEvent(new CustomEvent("timeupdate",{detail:{currentTime:t}}))},getLoop:()=>this.loop,restart:()=>{this.seek(0),this.play()},onPaused:()=>{this._media.audioOwner==="parent"&&this._media.pauseAll(),this._paused=!0,this.controlsApi?.updatePlaying(!1),this.dispatchEvent(new Event("ended"))},onEnded:()=>this.loop}),this.probe=new te(this.iframe,{onReady:t=>this._onProbeReady(t),onError:t=>this.dispatchEvent(new CustomEvent("error",{detail:{message:t}}))}),this.addEventListener("click",t=>{_t(t)||(this._paused?this.play():this.pause())}),this.resizeObserver=new ResizeObserver(()=>this._rescale()),this._onMessage=this._onMessage.bind(this),this._onIframeLoad=this._onIframeLoad.bind(this)}connectedCallback(){this._applySandboxOriginPolicy(),this.resizeObserver.observe(this),window.addEventListener("message",this._onMessage),this.iframe.addEventListener("load",this._onIframeLoad),this.hasAttribute("controls")&&this._setupControls(),this.hasAttribute("poster")&&(this.posterEl=Se(this.shadow,this.getAttribute("poster"),this.posterEl)),this.hasAttribute("audio-src")&&this._media.setupFromUrl(this.getAttribute("audio-src")),this.hasAttribute("srcdoc")&&(this.iframe.srcdoc=K(this,this.getAttribute("srcdoc"))),this.hasAttribute("src")&&(this.iframe.src=X(this,this.getAttribute("src"))),!this.hasAttribute("audio-locked")&&this._isLockedHostEnvironment()&&this._applyAudioLock(!0)}disconnectedCallback(){this._sendControl("pause"),this._stopIframeMedia(),this.resizeObserver.disconnect(),window.removeEventListener("message",this._onMessage),this.iframe.removeEventListener("load",this._onIframeLoad),this.probe.stop(),this._directTimelineClock.stop(),this._stopParentTickClock(),this._directTimelineAdapter=null,this.shaderLoader.destroy(),this._media.destroy(),this.controlsApi?.destroy(),this.controlsApi=null,this._paused=!0,this._ready=!1,this._invalidateAssetsWait(),this._runtimeBridgeReady=!1,this._rejectAllRuntimeDataDeliveries("Player disconnected before runtime data was applied")}attributeChangedCallback(e,t,i){switch(e){case"src":if(!this.isConnected)break;i&&(this._ready=!1,this._invalidateAssetsWait(),this._runtimeBridgeReady=!1,this._rejectAllRuntimeDataDeliveries("Composition navigated before runtime data was applied"),this.iframe.src=X(this,i));break;case"srcdoc":if(!this.isConnected)break;this._ready=!1,this._invalidateAssetsWait(),this._runtimeBridgeReady=!1,this._rejectAllRuntimeDataDeliveries("Composition navigated before runtime data was applied"),i!==null?this.iframe.srcdoc=K(this,i):this.iframe.removeAttribute("srcdoc");break;case We:this._applySandboxOriginPolicy(this.isConnected&&t!==i);break;case"width":this._compositionWidth=V(i)??1920,this._rescale();break;case"height":this._compositionHeight=V(i)??1080,this._rescale();break;case"controls":i!==null?this._setupControls():(this.controlsApi?.destroy(),this.controlsApi=null);break;case"poster":this.posterEl=Se(this.shadow,i,this.posterEl);break;case"playback-rate":{let r=ze(parseFloat(i||"1"));this._media.updatePlaybackRate(r),this._sendControl("set-playback-rate",{playbackRate:r}),this._directTimelineAdapter?.timeScale?.(r),this.controlsApi?.updateSpeed(r),this.dispatchEvent(new Event("ratechange"));break}case"muted":this._handleMutedChange(i);break;case"audio-locked":this._applyAudioLock(i!==null);break;case"volume":{let r=Math.max(0,Math.min(1,parseFloat(i||"1")));this._volume=r,this._media.updateVolume(r),this._sendControl("set-volume",{volume:r}),this.controlsApi?.updateVolume(r),this.dispatchEvent(new Event("volumechange"));break}case"audio-src":i?this._media.setupFromUrl(i):this._media.teardownUrlAudio();break;case D:case F:case _e:if(!this.isConnected)break;this._reloadShaderOptions();break}}_applySandboxOriginPolicy(e=!1){this.hasAttribute(We)?this.iframe.sandbox.remove("allow-same-origin"):this.iframe.sandbox.add("allow-same-origin"),e&&this._reloadForSandboxOriginPolicy()}_reloadForSandboxOriginPolicy(){this._ready=!1,this._invalidateAssetsWait(),this._runtimeBridgeReady=!1,this._rejectAllRuntimeDataDeliveries("Sandbox policy changed before runtime data was applied");let e=this.getAttribute("srcdoc");if(e!==null){this.iframe.srcdoc=K(this,e);return}let t=this.getAttribute("src");this.iframe.src=t===null?"about:blank":X(this,t)}get iframeElement(){return this.iframe}get scenes(){return this._scenes}play(){if(this._ready&&!this._assetsReady){this._pendingPlay=!0;return}this._pendingPlay=!1,this.posterEl?.remove(),this.posterEl=null,this._duration>0&&this._currentTime>=this._duration&&this.seek(0),this._paused=!1;let e=this._tryDirectTimelinePlay(),t=!1;e||(this._sendControl("play"),this._ready&&!this._directTimelineAdapter?this._startParentTickClock():this._ready||(this._pendingPlay=!0,t=!0)),this._media.audioOwner==="parent"&&this._media.playAll(),this.controlsApi?.updatePlaying(!0),t||this.dispatchEvent(new Event("play")),e&&this._directTimelineAdapter&&this._directTimelineClock.start(this._directTimelineAdapter,()=>this._currentTime,()=>this._duration,()=>this._paused)}pause(){this._pendingPlay=!1,this._tryDirectTimelinePause()||this._sendControl("pause"),this._directTimelineClock.stop(),this._stopParentTickClock(),this._media.audioOwner==="parent"&&this._media.pauseAll(),this._paused=!0,this.controlsApi?.updatePlaying(!1),this.dispatchEvent(new Event("pause"))}stopMedia(){this._sendControl("stop-media"),this._stopIframeMedia(),this._media.stopAdoptedMedia()}seek(e){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,this.controlsApi?.updatePlaying(!1),this.controlsApi?.updateTime(this._currentTime,this._duration)}setColorGrading(e,t){this._sendControl("set-color-grading",{target:e,grading:t})}clearColorGrading(e){this._sendControl("set-color-grading",{target:e,grading:null})}setColorGradingCompare(e,t){this._sendControl("set-color-grading-compare",{target:e,compare:t})}clearColorGradingCompare(e){this._sendControl("set-color-grading-compare",{target:e,compare:{enabled:!1}})}setRuntimeData(e,t){if(!/^[a-z][a-z0-9-]{0,63}$/.test(e))throw new Error(`Invalid HyperFrames runtime-data channel: ${e}`);if(typeof structuredClone!="function")throw new Error("HyperFrames runtime data requires structuredClone support; refusing an unverified payload");let i=structuredClone(t);this._runtimeData.set(e,i),this._deliverRuntimeData(e,i)}clearRuntimeData(e){if(!/^[a-z][a-z0-9-]{0,63}$/.test(e))throw new Error(`Invalid HyperFrames runtime-data channel: ${e}`);this._runtimeData.delete(e),this._deliverRuntimeDataClear(e)}get currentTime(){return this._currentTime}set currentTime(e){this.seek(e)}get duration(){return this._duration}get paused(){return this._paused}get ready(){return this._ready}get assetsReady(){return this._assetsReady}get painted(){return this._painted}get playbackRate(){return ze(parseFloat(this.getAttribute("playback-rate")||"1"))}set playbackRate(e){this.setAttribute("playback-rate",String(ze(e)))}get shaderCaptureScale(){return un(this)}set shaderCaptureScale(e){this.setAttribute(D,String(e))}get shaderLoading(){return U(this)}set shaderLoading(e){e==="composition"?this.removeAttribute(F):this.setAttribute(F,e)}get muted(){return this.hasAttribute("muted")}set muted(e){e?this.setAttribute("muted",""):this.removeAttribute("muted")}get audioLocked(){return this.hasAttribute("audio-locked")}set audioLocked(e){e?this.setAttribute("audio-locked",""):this.removeAttribute("audio-locked")}_isLockedHostEnvironment(){if(typeof navigator>"u")return!1;let 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){if(e===null&&this._isAudioLocked()){this.setAttribute("muted","");return}this._media.updateMuted(e!==null),this._setIframeMediaMuted(e!==null),this._sendControl("set-muted",{muted:e!==null}),this.controlsApi?.updateMuted(e!==null),this.dispatchEvent(new Event("volumechange"))}_applyAudioLock(e){e&&(this.muted=!0),this.controlsApi?.setVolumeControlsHidden(e)}get volume(){return this._volume}set volume(e){this.setAttribute("volume",String(Math.max(0,Math.min(1,e))))}get loop(){return this.hasAttribute("loop")}set loop(e){e?this.setAttribute("loop",""):this.removeAttribute("loop")}_sendControl(e,t={}){try{let i=this.iframe.contentWindow;return i?(i.postMessage({...t,source:"hf-parent",type:"control",action:e,...Oe(this._runtimeFps)},"*"),!0):((e==="set-runtime-data"||e==="clear-runtime-data")&&this._rejectRuntimeDataDelivery(t.channel,t.requestId,"Composition iframe is unavailable"),!1)}catch(i){return(e==="set-runtime-data"||e==="clear-runtime-data")&&this._rejectRuntimeDataDelivery(t.channel,t.requestId,i instanceof Error?i.message:String(i)),!1}}_deliverRuntimeData(e,t){if(!this.isConnected||!this._runtimeBridgeReady)return;let i=this._beginRuntimeDataDelivery(e);this._trySetRuntimeDataDirect(e,t,i)||this._sendControl("set-runtime-data",{channel:e,payload:t,requestId:i})}_deliverRuntimeDataClear(e){if(!this.isConnected||!this._runtimeBridgeReady)return;let t=this._beginRuntimeDataDelivery(e);this._tryClearRuntimeDataDirect(e,t)||this._sendControl("clear-runtime-data",{channel:e,requestId:t})}_trySetRuntimeDataDirect(e,t,i){try{let r=this.iframe.contentWindow?.__hyperframes;return typeof r?.setRuntimeData!="function"?!1:(r.setRuntimeData(e,t,i),!0)}catch{return!1}}_tryClearRuntimeDataDirect(e,t){try{let i=this.iframe.contentWindow?.__hyperframes;return typeof i?.clearRuntimeData!="function"?!1:(i.clearRuntimeData(e,t),!0)}catch{return!1}}_replayRuntimeData(){for(let[e,t]of this._runtimeData)this._deliverRuntimeData(e,t)}_beginRuntimeDataDelivery(e){let t=this._pendingRuntimeData.get(e);t&&window.clearTimeout(t.timeoutId),this._runtimeDataRequestId+=1;let i=this._runtimeDataRequestId,r=window.setTimeout(()=>{this._rejectRuntimeDataDelivery(e,i,`Runtime data delivery timed out after ${dn}ms`)},dn);return this._pendingRuntimeData.set(e,{requestId:i,timeoutId:r}),i}_resolveRuntimeDataDelivery(e,t){let i=this._takeRuntimeDataDelivery(e,t);i&&this.dispatchEvent(new CustomEvent("runtimedataapplied",{detail:{channel:e,requestId:i.requestId}}))}_rejectRuntimeDataDelivery(e,t,i){let r=this._takeRuntimeDataDelivery(e,t);r&&this.dispatchEvent(new CustomEvent("runtimedataerror",{detail:{channel:e,requestId:r.requestId,message:typeof i=="string"?i:String(i)}}))}_takeRuntimeDataDelivery(e,t){if(typeof e!="string"||typeof t!="number"||!Number.isSafeInteger(t))return null;let i=this._pendingRuntimeData.get(e);return!i||i.requestId!==t?null:(window.clearTimeout(i.timeoutId),this._pendingRuntimeData.delete(e),i)}_rejectAllRuntimeDataDeliveries(e){for(let[t,i]of[...this._pendingRuntimeData])this._rejectRuntimeDataDelivery(t,i.requestId,e)}_getSameOriginIframeDocument(){try{return this.iframe.contentDocument}catch{return null}}_setIframeMediaMuted(e){let t=this._getSameOriginIframeDocument();if(t)for(let i of t.querySelectorAll("video, audio"))x(i)&&(i.muted=e||i.defaultMuted)}_stopIframeMedia(){let e=this._getSameOriginIframeDocument();if(e)for(let t of e.querySelectorAll("video, audio"))x(t)&&t.pause()}_replayBridgeState(){this._sendControl("set-muted",{muted:this.muted}),this._sendControl("set-volume",{volume:this._volume}),this._sendControl("set-playback-rate",{playbackRate:this.playbackRate}),this._sendControl("set-native-media-sync-disabled",{disabled:this._isSlideshowPlayer()}),this._sendControl("set-web-audio-media-disabled",{disabled:this._isSlideshowPlayer()})}_reloadShaderOptions(){if(this._ready=!1,this._invalidateAssetsWait(),this._runtimeBridgeReady=!1,this._rejectAllRuntimeDataDeliveries("Shader options changed before runtime data was applied"),U(this)!=="player"&&this.shaderLoader.reset(),this.hasAttribute("srcdoc")){this.iframe.srcdoc=K(this,this.getAttribute("srcdoc")||"");return}this.hasAttribute("src")&&(this.iframe.src=X(this,this.getAttribute("src")||""))}_trySyncSeek(e){try{let i=this.iframe.contentWindow?.__player;return typeof i?.seek!="function"?!1:(i.seek.call(i,e),!0)}catch{return!1}}_withDirectTimeline(e){let t=this.probe.resolveDirectTimelineAdapter(),i=t||this._directTimelineAdapter;if(!i)return!1;try{if(e(i),t&&t!==this._directTimelineAdapter){let r=t.duration();Number.isFinite(r)&&r>0&&(this._duration=r,this.controlsApi?.updateTime(this._currentTime,r))}return this._directTimelineAdapter=i,!0}catch{return!1}}_tryDirectTimelineSeek(e){return this._withDirectTimeline(t=>{t.seek(e,!1),t.pause()})}_tryDirectTimelinePlay(){return this._withDirectTimeline(e=>{e.play()})}_tryDirectTimelinePause(){return this._withDirectTimeline(e=>{e.pause()})}_startParentTickClock(){this._stopParentTickClock();let 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){nn(e,this.iframe.contentWindow,{getPlaybackState:()=>({currentTime:this._currentTime,duration:this._duration,paused:this._paused,lastUpdateMs:this._lastUpdateMs}),setPlaybackState:({currentTime:t,duration:i,paused:r,lastUpdateMs:o})=>{this._currentTime=t,this._duration=i,this._paused=r,this._lastUpdateMs=o},getShaderLoadingMode:()=>U(this),shaderLoader:this.shaderLoader,setCompositionSize:(t,i)=>{this._compositionWidth=t,this._compositionHeight=i,this._rescale()},sendControl:(t,i)=>this._sendControl(t,i),getIframeDoc:()=>this.iframe.contentDocument,onRuntimeReady:()=>{this._runtimeBridgeReady=!0,this._replayBridgeState(),this._replayRuntimeData()},onRuntimeAssetsReady:()=>{this._runtimeAssetsReadyGeneration===this._assetsGeneration&&this._settleAssetsReady(this._assetsGeneration)},onRuntimeDataApplied:(t,i)=>this._resolveRuntimeDataDelivery(t,i),onRuntimeDataError:(t,i,r)=>this._rejectRuntimeDataDelivery(t,i,r),onRuntimeTimelineReady:(t,i)=>this._onRuntimeTimelineReady(t,i),setRuntimeFps:t=>{this._runtimeFps=t},shouldPromoteMediaAutoplayFallback:()=>!this._isSlideshowPlayer(),setScenes:t=>{this._scenes=t,this.dispatchEvent(new CustomEvent("scenes",{detail:{scenes:t}}))},updateControlsTime:(t,i)=>this.controlsApi?.updateTime(t,i),updateControlsPlaying:t=>this.controlsApi?.updatePlaying(t),dispatchEvent:t=>this.dispatchEvent(t),seek:t=>this.seek(t),play:()=>this.play(),getLoop:()=>this.loop,media:this._media})}_onRuntimeTimelineReady(e,t){if(this._ready)return;this.probe.stop(),this._duration=e,this._directTimelineAdapter=null,this._ready=!0,this.controlsApi?.updateTime(this._currentTime,e),this.dispatchEvent(new CustomEvent("ready",{detail:{duration:e}})),this._rescale();let i=this._getSameOriginIframeDocument();i&&this._media.setupFromIframe(i),this._replayBridgeState(),this._setIframeMediaMuted(this.muted),this._waitForAssetsReady(i,t),(this.hasAttribute("autoplay")||this._pendingPlay)&&this.play()}_onProbeReady({duration:e,adapter:t,compositionSize:i}){this._duration=e,this._directTimelineAdapter=t.kind==="direct-timeline"?t.timeline:null,this._ready=!0,this.controlsApi?.updateTime(0,e),this.dispatchEvent(new CustomEvent("ready",{detail:{duration:e}})),i&&(this._compositionWidth=i.width,this._compositionHeight=i.height,this._rescale());let r=this._getSameOriginIframeDocument();r&&this._media.setupFromIframe(r),this._setIframeMediaMuted(this.muted),this._waitForAssetsReady(r),(this.hasAttribute("autoplay")||this._pendingPlay)&&this.play()}_waitForAssetsReady(e,t){this._clearAssetsLoadingShowTimer(),this._assetsReady=!1,this._painted=!1;let i=++this._assetsGeneration;if(!e){t===!1?(this._runtimeAssetsReadyGeneration=i,this._startAssetsLoadingOverlayTimer(i),setTimeout(()=>this._settleAssetsReady(i),$e)):this._settleAssetsReady(i);return}en(e,({timedOut:r})=>{i===this._assetsGeneration&&(r&&this._warnStuckAssets(e),this._settleAssetsReady(i))},{timeoutMs:$e}),this._assetsReady||this._startAssetsLoadingOverlayTimer(i)}_startAssetsLoadingOverlayTimer(e){this._assetsLoadingShowTimer=setTimeout(()=>{this._assetsLoadingShowTimer=null,!(e!==this._assetsGeneration||this._assetsReady)&&(this.setAttribute(qe,""),this.shaderLoader.showAssetsLoading())},Vi)}_warnStuckAssets(e){let{pendingMedia:t,pendingImages:i,fontsLoading:r}=Ve(e,{scope:He}),o=e.defaultView;console.warn(`[hyperframes-player] assets-loading timed out after ${$e}ms \u2014 playing anyway`,{stuckMedia:t.map(a=>a.currentSrc||a.getAttribute("src")||`<${a.tagName.toLowerCase()}>`),stuckImages:i.map(a=>a.currentSrc||a.getAttribute("src")||"<img>"),fontsLoading:r,computeReady:o?.__renderReady===!0,documentHidden:e.hidden===!0})}_settleAssetsReady(e){e!==this._assetsGeneration||this._assetsReady||(this._clearAssetsLoadingShowTimer(),this._assetsReady=!0,this.removeAttribute(qe),this.shaderLoader.hide(),this.dispatchEvent(new Event("assetsready")),this.shaderLoader.whenHidden(()=>{e===this._assetsGeneration&&(this._painted=!0,this.dispatchEvent(new Event("painted")))}),this._pendingPlay&&this.play())}_invalidateAssetsWait(){this._clearAssetsLoadingShowTimer(),this._assetsReady=!1,this._painted=!1,this._pendingPlay=!1,this._assetsGeneration++,this.removeAttribute(qe),this.shaderLoader.hide()}_clearAssetsLoadingShowTimer(){this._assetsLoadingShowTimer!==null&&(clearTimeout(this._assetsLoadingShowTimer),this._assetsLoadingShowTimer=null)}_rescale(){!At(this,this.iframe,this._compositionWidth,this._compositionHeight)&&this._ready&&!this._rescaleWarned&&(this._rescaleWarned=!0,console.warn("[hyperframes-player] rescale no-op after ready \u2014 zero-size player element",{src:this.getAttribute("src"),offsetWidth:this.offsetWidth,offsetHeight:this.offsetHeight,compositionWidth:this._compositionWidth,compositionHeight:this._compositionHeight}))}_onIframeLoad(){this._ready&&this._getSameOriginIframeDocument()===null||(this._ready=!1,this._directTimelineAdapter=null,this._directTimelineClock.stop(),this._stopParentTickClock(),this._invalidateAssetsWait(),this.shaderLoader.reset(),this._media.resetForIframeLoad(),this.probe.start())}_setupControls(){this.controlsApi||(this.controlsApi=gt(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=>{this.playbackRate=e},onMuteToggle:()=>{this.muted=!this.muted},onVolumeChange:e=>{this.volume=e}},this._isAudioLocked()))}get _audioOwner(){return this._media.audioOwner}get _parentMedia(){return this._media.entries}_mirrorParentMediaTime(e,t){this._media.mirrorTime(e,t)}_promoteToParentProxy(){let e=null;try{e=this.iframe.contentDocument}catch{}this._media.promoteToParentProxy(e,(t,i)=>this._mirrorParentMediaTime(t,i)),this._sendControl("set-media-output-muted",{muted:!0})}_observeDynamicMedia(e){this._media.setupFromIframe(e)}};customElements.get("hyperframes-player")||customElements.define("hyperframes-player",je);export{je as HyperframesPlayer,ht as SPEED_PRESETS,ne as formatSpeed,Ee as formatTime};
|
|
465
465
|
//# sourceMappingURL=hyperframes-player.js.map
|