var D=Object.defineProperty;var H=(t,i,e)=>i in t?D(t,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[i]=e;var L=(t,i,e)=>(H(t,typeof i!="symbol"?i+"":i,e),e),I=(t,i,e)=>{if(!i.has(t))throw TypeError("Cannot "+e)};var N=(t,i,e)=>(I(t,i,"read from private field"),e?e.call(t):i.get(t)),A=(t,i,e)=>{if(i.has(t))throw TypeError("Cannot add the same private member more than once");i instanceof WeakSet?i.add(t):i.set(t,e)},$=(t,i,e,r)=>(I(t,i,"write to private field"),r?r.call(t,e):i.set(t,e),e);import{c as F}from"./vendor-react-ece1c85f.js";import{_ as W}from"./vendor-pdf-b2a5d8b1.js";import{M as U,C as P}from"./mixin-01ba42c5.js";import"./vendor-mui-69397583.js";var _;class S extends U(P){constructor(){super(...arguments);A(this,_,void 0)}attributeChangedCallback(e,r,n){e!=="src"&&super.attributeChangedCallback(e,r,n),e==="src"&&r!=n&&this.load()}async _initThumbnails(e){const r=async(d,v)=>{const g=[],m=e.timescale||1,w=e.startNumber||1,M=e.presentationTimeOffset?e.presentationTimeOffset/m:0,h=e.segmentDuration;for(let b=0;b<d;b++){const y=K({thIndex:b,thduration:v,ttiles:d,tduration:h,startNumber:w,pto:M}),R=y+v,f=new Promise((E,a)=>{this.api.provideThumbnail(y,({url:s,width:l,height:p,x:T,y:B})=>{try{const k=new VTTCue(y,R,`${s}#xywh=${T},${B},${l},${p}`);E(k)}catch(k){a(k)}})});g.push(f)}return await Promise.all(g).catch(b=>console.error("Error processing thumbnails",b))},{totalThumbnails:n,thumbnailDuration:o}=j(e),u=await r(n,o);let c=this.nativeEl.querySelector('track[label="thumbnails"]');if(!c){c=q(),this.nativeEl.appendChild(c);const d=z(u);c.src=d,c.dispatchEvent(new Event("change"))}}async load(){if(N(this,_)){this.api.attachSource(this.src);return}$(this,_,!0);const e=await W(()=>import("./dash.all.min-de66727c.js"),[]);this.api=e.MediaPlayer().create(),this.api.initialize(this.nativeEl,this.src,this.autoplay),this.api.on(e.MediaPlayer.events.STREAM_INITIALIZED,()=>{const r=this.api.getRepresentationsByType("video");let n=this.videoTracks.getTrackById("main");n||(n=this.addVideoTrack("main"),n.id="main",n.selected=!0),r.forEach(o=>{const u=o.bandwidth??o.bitrate??(Number.isFinite(o.bitrateInKbit)?o.bitrateInKbit*1e3:void 0),c=n.addRendition(o.id,o.width,o.height,o.mimeType??o.codec,u);c.id=o.id}),this.videoRenditions.addEventListener("change",()=>{const o=this.videoRenditions[this.videoRenditions.selectedIndex];o!=null&&o.id?(this.api.updateSettings({streaming:{abr:{autoSwitchBitrate:{video:!1}}}}),this.api.setRepresentationForTypeById("video",o.id,!0)):this.api.updateSettings({streaming:{abr:{autoSwitchBitrate:{video:!0}}}})}),this.api.isDynamic()||this.api.getRepresentationsByType("image").forEach(async(u,c)=>{c>0||this._initThumbnails(u)})})}}_=new WeakMap,L(S,"shadowRootOptions",{...P.shadowRootOptions}),L(S,"getTemplateHTML",e=>{const{src:r,...n}=e;return P.getTemplateHTML(n)});function j(t){var i,e;const r=t.essentialProperties[0],[n,o]=r.value.split("x").map(Number),u=n*o,c=((e=(i=t.adaptation)==null?void 0:i.period)==null?void 0:e.duration)||null,d=t.segmentDuration,v=t.timescale||1,m=d/v/u;return{totalThumbnails:c!=null?Math.ceil(c/m):Math.ceil(d/m),thumbnailDuration:m}}function K({thIndex:t,tduration:i,thduration:e,ttiles:r,startNumber:n,pto:o}){const u=Math.floor(t/r)+n,c=t%r+1,d=(u-1)*i-o,v=(c-1)*e;return d+v}function q(){const t=document.createElement("track");return t.kind="metadata",t.label="thumbnails",t.srclang="en",t.mode="hidden",t.default=!0,t}function z(t){let i=`WEBVTT

`;for(const n of t)i+=`${r(n.startTime)} --> ${r(n.endTime)}
`,i+=`${n.text}

`;const e=new Blob([i],{type:"text/vtt"});return URL.createObjectURL(e);function r(n){const o=String(Math.floor(n/3600)).padStart(2,"0"),u=String(Math.floor(n%3600/60)).padStart(2,"0"),c=(n%60).toFixed(3).padStart(6,"0");return`${o}:${u}:${c}`}}globalThis.customElements&&!globalThis.customElements.get("dash-video")&&globalThis.customElements.define("dash-video",S);var V=S,Z=new Set(["style","children","ref","key","suppressContentEditableWarning","suppressHydrationWarning","dangerouslySetInnerHTML"]),G={className:"class",htmlFor:"for"};function x(t){return t.toLowerCase()}function C(t){if(typeof t=="boolean")return t?"":void 0;if(typeof t!="function"&&!(typeof t=="object"&&t!==null))return t}function J({react:t,tagName:i,elementClass:e,events:r,displayName:n,defaultProps:o,toAttributeName:u=x,toAttributeValue:c=C}){const d=Number.parseInt(t.version)>=19,v=t.forwardRef((g,m)=>{var w,M;const h=t.useRef(null),b=t.useRef(new Map),y={},R={},f={},E={};for(const[a,s]of Object.entries(g)){if(Z.has(a)){f[a]=s;continue}const l=u(G[a]??a);if(e.prototype&&a in e.prototype&&!(a in(((w=globalThis.HTMLElement)==null?void 0:w.prototype)??{}))&&!((M=e.observedAttributes)!=null&&M.some(T=>T===l))){E[a]=s;continue}if(a.startsWith("on")){y[a]=s;continue}const p=c(s);if(l&&p!=null&&(R[l]=String(p),d||(f[l]=p)),l&&d){const T=C(s);p!==T?f[l]=p:f[l]=s}}if(typeof window<"u"){for(const a in y){const s=y[a],l=a.endsWith("Capture"),p=((r==null?void 0:r[a])??a.slice(2).toLowerCase()).slice(0,l?-7:void 0);t.useLayoutEffect(()=>{const T=h==null?void 0:h.current;if(!(!T||typeof s!="function"))return T.addEventListener(p,s,l),()=>{T.removeEventListener(p,s,l)}},[h==null?void 0:h.current,s])}t.useLayoutEffect(()=>{if(h.current===null)return;const a=new Map;for(const s in E)O(h.current,s,E[s]),b.current.delete(s),a.set(s,E[s]);for(const[s,l]of b.current)O(h.current,s,void 0);b.current=a})}if(typeof window>"u"&&(e!=null&&e.getTemplateHTML)&&(e!=null&&e.shadowRootOptions)){const{mode:a,delegatesFocus:s}=e.shadowRootOptions,l=t.createElement("template",{shadowrootmode:a,shadowrootdelegatesfocus:s,dangerouslySetInnerHTML:{__html:e.getTemplateHTML(R,g)},key:"ce-la-react-ssr-template-shadow-root"});f.children=[l,f.children]}return t.createElement(i,{...o,...f,ref:t.useCallback(a=>{h.current=a,typeof m=="function"?m(a):m!==null&&(m.current=a)},[m])},f.children)});return v.displayName=n??e.name,v}function O(t,i,e){var r;t[i]=e,e==null&&i in(((r=globalThis.HTMLElement)==null?void 0:r.prototype)??{})&&t.removeAttribute(i)}var it=J({react:F,tagName:"dash-video",elementClass:V,toAttributeName(t){return t==="muted"?"":t==="defaultMuted"?"muted":x(t)}});/*! Bundled license information:

ce-la-react/dist/ce-la-react.js:
  (**
   * @license
   * Copyright 2018 Google LLC
   * SPDX-License-Identifier: BSD-3-Clause
   *
   * Modified version of `@lit/react` for vanilla custom elements with support for SSR.
   *)
*/export{it as default};
