PageSourceSearch

https://onciencias.org/_next/static/chunks/2o_4v23clz8zn.js

js onciencias.org collected 2026-10-02 17:50:12 UTC 916,580 bytes, 38 lines download raw bytes

1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,44077,e=>{"use strict";let t,i;var s,r,a,n,l,o,d,h,u,c,f,p,m,g,y,v,b,E,S,T=e.i(43476),x=e.i(71645);let k={success:{main:"#2e7d32",dark:"#1b5e20",contrastText:"#fff"},warning:{main:"#ed6c02",dark:"#c75e00",contrastText:"#fff"},error:{main:"#d32f2f",dark:"#c62828",contrastText:"#fff"},info:{main:"#0288d1",dark:"#01579b",contrastText:"#fff"}},w=(e,t)=>{let i,s,[r,a,n]=[parseInt((s=3===(i=e.replace("#","")).length?i.split("").map(e=>e+e).join(""):i).slice(0,2),16),parseInt(s.slice(2,4),16),parseInt(s.slice(4,6),16)];return`rgba(${r}, ${a}, ${n}, ${t})`},A=({label:e})=>(0,T.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",background:"linear-gradient(135deg, rgba(2, 136, 209, 0.12), rgba(2, 136, 209, 0.04))",color:"#0288d1"},children:[(0,T.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",style:{width:40,height:40,marginBottom:6},children:[(0,T.jsx)("path",{fillRule:"evenodd",d:"M5.625 1.5c-1.036 0-1.875.84-1.875 1.875v17.25c0 1.035.84 1.875 1.875 1.875h12.75c1.035 0 1.875-.84 1.875-1.875V12.75A3.75 3.75 0 0016.5 9h-1.875a1.875 1.875 0 01-1.875-1.875V5.25A3.75 3.75 0 009 1.5H5.625zM7.5 15a.75.75 0 01.75-.75h7.5a.75.75 0 010 1.5h-7.5A.75.75 0 017.5 15zm.75 2.25a.75.75 0 000 1.5H12a.75.75 0 000-1.5H8.25z",clipRule:"evenodd"}),(0,T.jsx)("path",{d:"M12.971 1.816A5.23 5.23 0 0114.25 5.25v1.875c0 .207.168.375.375.375H16.5a5.23 5.23 0 013.434 1.279 9.768 9.768 0 00-6.963-6.963z"})]}),(0,T.jsx)("div",{style:{fontSize:11,fontWeight:700,letterSpacing:"0.08em",textTransform:"uppercase"},children:e})]}),R=({label:e,href:t,fileName:i,variant:s,color:r})=>{let[a,n]=(0,x.useState)(!1),[l,o]=(0,x.useState)(!1),d=k[r],h="transparent",u="transparent",c=d.main;"contained"===s?(c=d.contrastText,h=l||a?d.dark:d.main):("outlined"===s&&(u=a||l?d.main:w(d.main,.5)),h=l?w(d.main,.12):a?w(d.main,.04):"transparent");let f={display:"inline-flex",alignItems:"center",gap:4,fontSize:12,fontWeight:500,letterSpacing:"0.02857em",textTransform:"uppercase",color:c,padding:"contained"===s?"4px 10px":"3px 9px",borderRadius:4,minHeight:26,justifyContent:"center",textDecoration:"none",cursor:"pointer",background:h,border:`1px solid ${u}`,boxShadow:"contained"===s?a?"0px 2px 4px -1px rgba(0,0,0,0.2), 0px 4px 5px 0px rgba(0,0,0,0.14), 0px 1px 10px 0px rgba(0,0,0,0.12)":"0px 3px 1px -2px rgba(0,0,0,0.2), 0px 2px 2px 0px rgba(0,0,0,0.14), 0px 1px 5px 0px rgba(0,0,0,0.12)":"none",transition:"background-color 250ms cubic-bezier(0.4, 0, 0.2, 1), border-color 250ms cubic-bezier(0.4, 0, 0.2, 1), box-shadow 250ms cubic-bezier(0.4, 0, 0.2, 1)",userSelect:"none",fontFamily:"inherit",lineHeight:1.5};return(0,T.jsxs)("a",{href:t,download:i,target:"_blank",rel:"noopener noreferrer",style:f,onMouseEnter:()=>n(!0),onMouseLeave:()=>{n(!1),o(!1)},onMouseDown:()=>o(!0),onMouseUp:()=>o(!1),children:[(0,T.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",style:{width:14,height:14,flexShrink:0},children:[(0,T.jsx)("path",{d:"M10.75 2.75a.75.75 0 00-1.5 0v8.614L6.295 8.235a.75.75 0 10-1.09 1.03l4.25 4.5a.75.75 0 001.09 0l4.25-4.5a.75.75 0 00-1.09-1.03l-2.955 3.129V2.75z"}),(0,T.jsx)("path",{d:"M3.5 12.75a.75.75 0 00-1.5 0v2.5A2.75 2.75 0 004.75 18h10.5A2.75 2.75 0 0018 15.25v-2.5a.75.75 0 00-1.5 0v2.5c0 .69-.56 1.25-1.25 1.25H4.75c-.69 0-1.25-.56-1.25-1.25v-2.5z"})]}),(0,T.jsx)("span",{children:e})]})},L=({file:e,override:t,orientation:i="horizontal",showCategoryTag:s=!0,categoryTagText:r,showTypeBadge:a=!0,showFileSize:n=!0,showDate:l=!0})=>{let o,d,[h,u]=(0,x.useState)(!1),c=(0,x.useRef)(null),f=(0,x.useRef)(null),[p,m]=(0,x.useState)(null),[g,y]=(0,x.useState)(130),v=t?.orientation??i,b=t?.showCategoryTag??s,E=t?.showTypeBadge??a,S=t?.showFileSize??n,k=t?.showDate??l,w=t?.title||e.name,L=t?.description??e.description,C=t?.thumbnailUrl,I=t?.actionLabel!=="",P=t?.actionLabel||"Baixar material",D=t?.actionVariant??"contained",M=t?.actionColor??"info",_=(o=e.filetype,d=e.name,"application/pdf"===o?"PDF":o.startsWith("image/")?"IMG":o.includes("word")||o.includes("document")?"DOCX":o.includes("spreadsheet")||o.includes("excel")?"XLSX":o.includes("presentation")||o.includes("powerpoint")?"PPTX":(d.split(".").pop()?.toUpperCase()??"").slice(0,5)),$=(e=>{if(!e)return"";let t=new Date(e.replace(" ","T"));return isNaN(t.getTime())?e:t.toLocaleDateString("pt-BR",{day:"2-digit",month:"short",year:"numeric"})})(e.date),O=t?.categoryTagText||r||"Material do curso",N="vertical"===v;(0,x.useLayoutEffect)(()=>
1{if(N||!p||!f.current)return;let e=f.current.offsetHeight;if(e<=0)return;let t=Math.max(110,Math.min(170,Math.round(e*p)));y(e=>2>Math.abs(e-t)?e:t)},[p,N,w,L,I,b,E,S,k]);let F=I?{}:{href:e.s3Url,download:e.name,target:"_blank",rel:"noopener noreferrer"},B=E||S&&!!e.fileSizeLabel||k&&!!$,U=C?(0,T.jsx)("div",{style:{flexShrink:0,width:N?"100%":g,alignSelf:N?void 0:"stretch",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",background:"transparent",borderBottom:N?"1px solid var(--dp-border, #e5e7eb)":"none"},children:(0,T.jsx)("img",{src:C,alt:w,loading:"lazy",onLoad:e=>{let t=e.currentTarget;t.naturalWidth>0&&t.naturalHeight>0&&m(t.naturalWidth/t.naturalHeight)},style:{width:"100%",height:N?"auto":"100%",objectFit:N?"contain":"cover",display:"block"}},C)}):(0,T.jsx)("div",{style:{flexShrink:0,width:N?"100%":140,aspectRatio:"3 / 4",background:"var(--dp-surface-2, #f8fafc)",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",borderRight:N?"none":"1px solid var(--dp-border, #e5e7eb)",borderBottom:N?"1px solid var(--dp-border, #e5e7eb)":"none"},children:(0,T.jsx)(A,{label:_})}),j=(0,T.jsxs)("div",{ref:f,style:{flex:1,minWidth:0,display:"flex",flexDirection:"column"},children:[(0,T.jsxs)("div",{style:{flex:1,padding:"14px 16px",paddingBottom:I?6:14,display:"flex",flexDirection:"column",gap:6},children:[(0,T.jsx)("div",{style:{fontSize:15,fontWeight:600,color:"var(--dp-text, rgba(0, 0, 0, 0.87))",lineHeight:1.35,wordBreak:"break-word",display:"-webkit-box",WebkitLineClamp:1,WebkitBoxOrient:"vertical",overflow:"hidden",textOverflow:"ellipsis"},children:w}),L?(0,T.jsx)("div",{style:{fontSize:13,color:"var(--dp-text-2, rgba(0, 0, 0, 0.6))",lineHeight:1.45,display:"-webkit-box",WebkitLineClamp:1,WebkitBoxOrient:"vertical",overflow:"hidden",textOverflow:"ellipsis"},children:L}):null,B||b?(0,T.jsxs)("div",{style:{marginTop:"auto",paddingTop:4,display:"flex",alignItems:"center",gap:8,fontSize:12,color:"var(--dp-text-2, rgba(0, 0, 0, 0.55))",flexWrap:"wrap"},children:[b?(0,T.jsx)("span",{style:{display:"inline-flex",alignItems:"center",padding:"2px 8px",borderRadius:4,background:"var(--dp-info-bg, #e3f2fd)",color:"#0288d1",fontSize:10.5,fontWeight:700,letterSpacing:"0.06em",textTransform:"uppercase"},children:O}):null,E?(0,T.jsx)("span",{style:{display:"inline-flex",alignItems:"center",padding:"2px 8px",borderRadius:4,background:"var(--dp-info-bg, #eff6ff)",color:"#0288d1",fontSize:11,fontWeight:600,letterSpacing:"0.04em"},children:_}):null,S&&e.fileSizeLabel?(0,T.jsx)("span",{children:e.fileSizeLabel}):null,k&&$?(0,T.jsxs)(T.Fragment,{children:[E||S&&e.fileSizeLabel?(0,T.jsx)("span",{style:{color:"var(--dp-text-2, rgba(0,0,0,0.25))"},children:"·"}):null,(0,T.jsx)("span",{children:$})]}):null]}):null]}),I?(0,T.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",padding:"6px 14px 10px",gap:8},children:(0,T.jsx)(R,{label:P,href:e.s3Url,fileName:e.name,variant:D,color:M})}):null]});return(0,T.jsxs)(I?"div":"a",{...F,ref:c,onMouseEnter:()=>u(!0),onMouseLeave:()=>u(!1),style:{display:"flex",flexDirection:N?"column":"row",alignItems:N?"stretch":"flex-start",background:"var(--dp-surface, #fff)",borderRadius:8,border:"1px solid var(--dp-border, #e5e7eb)",boxShadow:h?"0px 4px 12px -2px rgba(0,0,0,0.1), 0px 2px 6px -1px rgba(0,0,0,0.06)":"0px 1px 2px 0px rgba(0,0,0,0.04)",overflow:"hidden",transition:"box-shadow 250ms cubic-bezier(0.4, 0, 0.2, 1), border-color 250ms cubic-bezier(0.4, 0, 0.2, 1)",borderColor:h?"var(--dp-border, #cbd5e1)":"var(--dp-border, #e5e7eb)",minWidth:N?void 0:280,maxWidth:N?280:480,textDecoration:"none",color:"inherit",cursor:I?"default":"pointer"},children:[U,j]})},C=e=>{let{node:t}=e,i=t?.files,s=t?.overrides??{},r=t?.colsMobile??1,a=t?.colsDesktop??1,n=t?.orientation??"horizontal",l=t?.showCategoryTag??!0,o=t?.categoryTagText,d=t?.showTypeBadge??!0,h=t?.showFileSize??!0,u=t?.showDate??!0;return i&&0!==i.length?(0,T.jsx)("div",{className:`grid gap-3 grid-cols-${r} md:grid-cols-${a}`,style:{width:"100%",margin:"16px 0",display:"grid",gap:12,alignItems:"start"},children:i.map(e=>(0,T.jsx)(L,{file:e,override:s[e.file_id],orientation:n,showCategoryTag:l,categoryTagText:o,showTypeBadge:d,showFileSize:h,showDate:u},e.file_id))}):null},I=e=>{let{htmlLeft:t,htmlRight:i,sizeLeft:s,sizeRight:r}=e,a=[];return a.push('<div class="grid grid-cols-12 gap-4">
1'),a.push(`<div class="text-justify col-span-${s.mobileSize} md:col-span-${s.desktopSize}">`),a.push(`${t}`),a.push(" </div>"),a.push(`<div class="text-justify col-span-${r.mobileSize} md:col-span-${r.desktopSize}">`),a.push(`${i}`),a.push(" </div>"),a.push(" </div>"),a.join("")},P=e=>{let{fileUrl:t,link:i,maxHeight:s,maxWidth:r,openNewTab:a,reference:n,tooltip:l,disableShowOnWeb:o,headerText:d}=e,h=e.maxHeightDesktop?`${e.maxHeightDesktop}px`:"auto",u="left"===e.position?"text-left":"right"===e.position?"text-right":"text-center";return"u">typeof o&&o?null:(0,T.jsx)("div",{style:{position:"relative",width:"100%"},children:(0,T.jsxs)("div",{style:{cursor:"inherit",width:"100%"},children:[d?(0,T.jsx)("p",{children:d}):null,(0,T.jsx)("div",{style:{position:"relative",overflow:"hidden",pointerEvents:"none"},children:(0,T.jsx)("div",{style:{height:"100%",width:"100%"},className:` ${u}`,children:(0,T.jsx)("img",{className:"object-scale-down",style:{objectPosition:"center 50%",width:"100%",objectFit:"contain",maxHeight:h},src:t,alt:n},t)})}),(0,T.jsx)("div",{className:`italic ${u}`,children:n})]})})},D=e=>{let{sizeLeft:t,sizeRight:i,imageLeft:s,imageRight:r}=e;return""===e.imageLeft.fileUrl&&""===e.imageRight.fileUrl||"u">typeof e.imageLeft.disableShowOnWeb&&!0==e.imageLeft.disableShowOnWeb&&"u">typeof e.imageRight.disableShowOnWeb&&!0==e.imageRight.disableShowOnWeb?null:(0,T.jsxs)("div",{className:"grid grid-cols-12 gap-4",children:[(0,T.jsx)("div",{className:`col-span-${t.mobileSize} md:col-span-${t.desktopSize}`,children:(0,T.jsx)(P,{...s})}),(0,T.jsx)("div",{className:`col-span-${i.mobileSize} md:col-span-${i.desktopSize}`,children:(0,T.jsx)(P,{...r})})]})},M={display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0,0,0,0.5)",borderRadius:5,color:"white",border:"none",cursor:"pointer"},_=e=>{let{node:t,macros:i}=e,s=t?.scratch?.text,r=(0,x.useRef)(null),[a,n]=(0,x.useState)(!1);(0,x.useEffect)(()=>{let e=()=>{document.fullscreenElement===r?.current?n(!0):n(!1)};return document.addEventListener("fullscreenchange",e),document.addEventListener("webkitfullscreenchange",e),document.addEventListener("mozfullscreenchange",e),document.addEventListener("MSFullscreenChange",e),()=>{document.removeEventListener("fullscreenchange",e),document.removeEventListener("webkitfullscreenchange",e),document.removeEventListener("mozfullscreenchange",e),document.removeEventListener("MSFullscreenChange",e)}},[]);let l=async()=>{try{!a&&r&&r?.current?r?.current?.requestFullscreen&&await r?.current?.requestFullscreen():document?.exitFullscreen?document?.exitFullscreen():document?.webkitExitFullscreen?document?.webkitExitFullscreen():document?.mozCancelFullScreen?document?.mozCancelFullScreen():document?.msExitFullscreen&&document?.msExitFullscreen()}catch{}};return s&&""!==s?(0,T.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},ref:r,children:[(0,T.jsxs)("button",{id:"btn-fullscreen",style:M,onClick:l,children:[(0,T.jsx)("span",{children:a?"Desativar Modo Tela Cheia":"Ativar Modo Tela Cheia"}),(0,T.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"size-6",width:30,height:30,children:(0,T.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 3.75v4.5m0-4.5h4.5m-4.5 0L9 9M3.75 20.25v-4.5m0 4.5h4.5m-4.5 0L9 15M2
10.25 3.75h-4.5m4.5 0v4.5m0-4.5L15 9m5.25 11.25h-4.5m4.5 0v-4.5m0 4.5L15 15"})})]}),(0,T.jsx)("div",{style:{height:"100vh"},children:(0,T.jsx)("iframe",{title:"My application widget",src:s,width:"100%",height:"100%"})})]}):(0,T.jsx)(T.Fragment,{})},$=e=>{let{sizeLeft:t,sizeRight:i,img:s,imgPos:r,html:a}=e;return(0,T.jsxs)("div",{className:"grid grid-cols-12 gap-4",children:[(0,T.jsx)("div",{className:`order-${+("left"!=r)} col-span-${t.mobileSize} md:col-span-${t.desktopSize}`,children:(0,T.jsx)(P,{...s})}),(0,T.jsx)("div",{className:`${+("left"==r)} col-span-${i.mobileSize} md:col-span-${i.desktopSize}`,children:(0,T.jsx)("div",{style:{textAlign:"justify"},dangerouslySetInnerHTML:{__html:a}})})]})};function O(e){return e.includes("?")&&(e=e.split("?")[0]),e.includes("/")&&(e=e.split("/")[0]),e.includes("&")&&(e=e.split("&")[0]),e}let N=e=>{let{playbackId:t,autoPlay:i,description:s}=e,r=`https://player.mux.com/${t}${i?"?autoplay=1":""}`;return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)("div",{style:{position:"relative",width:"100%",aspectRatio:"16 / 9"},children:(0,T.jsx)("iframe",{title:t,src:r,style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",border:0},allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})}),s?(0,T.jsx)("div",{dangerouslySetInnerHTML:{__html:s}}):null]})},F=e=>{let{videoId:t,autoPlay:i,description:s}=e,r=`https://www.youtube.com/embed/${t}${i?"?autoplay=1":""}`,a=(0,x.useRef)(null),[n,l]=(0,x.useState)(a.current?.5625*a.current.offsetWidth:495),o=(0,x.useCallback)(()=>{let e=window.innerWidth>990?1:window.innerWidth>522?1.2:window.innerWidth>400?1.45:1.85;return l(Math.floor((a.current?.5625*a.current.offsetWidth:495)*e))},[]);return(0,x.useEffect)(()=>{window.addEventListener("resize",o);let e=window.innerWidth>990?1:window.innerWidth>522?1.2:window.innerWidth>400?1.45:1.85;return l(Math.floor((a.current?.5625*a.current.offsetWidth:495)*e)),function(){window.removeEventListener("resize",o)}},[n,o]),(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)("iframe",{ref:a,title:t,width:"100%",height:`${n}px`,src:r,frameBorder:"0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0}),s?(0,T.jsx)("div",{dangerouslySetInnerHTML:{__html:s}}):null]})},B=e=>{let{node:t,macros:i}=e,s=t?.video,r=t?.currentContext;if(!s||s.blockedsContext&&r&&s.blockedsContext.includes(r))return null;if("mux"===s.type||!s.url&&s.playbackId)return s.playbackId?(0,T.jsx)(N,{playbackId:s.playbackId,description:s?.description}):(0,T.jsx)("p",{children:"Vídeo não encontrado"});if(!s.url)return null;let{id:a,service:n}=function(e){if("string"!=typeof e)throw TypeError("get-video-id expects a string");let t=function(e){if("string"!=typeof e)throw TypeError(`extractGoogleRedirectionUrl expected a string, got ${typeof e}`);let t=e.trim();if(/\/\/google|www\.google/.test(t))try{let t=new URL(e),i=new URLSearchParams(t.search).get("url");if(i)return decodeURIComponent(i)}catch{}return t}(function(e){if("string"!=typeof e)throw TypeError(`sanitizeUrl expected a string, got ${typeof e}`);let t=e;return/<iframe/gi.test(t)&&(t=function(e){if("string"!=typeof e)throw TypeError("getSrc expected a string");let t=/src="(.*?)"/gm.exec(e);if(t&&t.length>=2)return t[1]}(t)||""),t=(t=t.trim()).replace("/www.","/")}(e)),i={id:void 0,service:void 0};return/youtube|youtu\.be|y2u\.be|i.ytimg\./.test(t)?i={id:function(e){let t=e;t=(t=(t=t.replace("-nocookie","")).replace(/#t=.*$/,"")).replace(/^https?:\/\//,"");let i=/youtube:\/\/|youtu\.be\/|y2u\.be\//g;if(i.test(t))return O(t.split(i)[1]);let s=/\/shorts\//g;if(s.test(t))return O(t.split(s)[1]);let r=/v=|vi=/g;if(r.test(t))return O(t.split(r)[1].split("&")[0]);let a=/\/v\/|\/vi\/|\/watch\//g;if(a.test(t))return O(t.split(a)[1]);let n=/\/an_webp\//g;if(n.test(t))return O(t.split(n)[1]);let l=/\/e\//g;if(l.test(t))return O(t.split(l)[1]);let o=/\/embed\//g;if(o.test(t))return O(t.split(o)[1]);if(/\/user\/([a-zA-Z\d]*)$/g.test(t))return;if(/\/user\/(?!.*videos)/g.test(t))return O(t.split("/").pop());let d=/\/attribution_link\?.*v%3D([^%&]*)(%26|&|$)/;if(d.test(t))return O(t.match(d)[1]);let h=/\/live\//g;if(h.test(t))return O(t.split(h)[1])}(t),service:"youtube"}:/vimeo/.test(t)?i={id:function(e){let t,i,s=e;s.includes("#")&&([s]=s.split("#")),s.includes("?")&&!s.includes("clip_id=")&&([s]=s.split("?"));let r=/https?:\/\/vimeo\.com\/event\/(\d+)$/.exec(s);if(r&&r[1])return r[1];let a=/https?:\/\/vimeo\.com\/(\d+)/.exec(s);return a&&a[1]?a[1]:(RegExp("https?://player.vimeo.com/video/[0-9]+$|https?://vimeo.com/channels|groups|album","gim").test(s)?(i=s.split("/"))&&i.length>0&&(t=i.pop()):/clip_id=/gim.test(s)&&(i=s.split("clip_id="))&&i.length>0&&([t]=i[1].split("&")),t)}(t),service:"vimeo"}:/vine/.test(t)?i={id:function(e){let t=/https:\/\/vine\.co\/v\/([a-zA-Z\d]*)\/?/.exec(e);if(t&&t.length>1)return t[1]}(t),service:"vine"}:/videopress/.test(t)?i={id:function(e){let t;if(e.includes("embed"))return t=/embed\/(\w{8})/,e.match(t)[1];t=/\/v\/(\w{8})/;let i=e.match(t);if(i&&i.length>0)return i[1]}(t),service:"videopress"}:/microsoftstream/.test(t)?i={id:function(e){let t=(e.includes("embed")?/https:\/\/web\.microsoftstream\.com\/embed\/video\/([a-zA-Z\d-]*)\/?/:/https:\/\/web\.microsoftstream\.com\/video\/([a-zA-Z\d-]*)\/?/).exec(e);if(t&&t.length>1)return t[1]}(t),service:"microsoftstream"}:/tiktok\.com/.test(t)?i={id:function(e){let t=/tiktok\.com(.*)\/video\/(\d+)/gm.exec(e);if(t&&t.length>2)return t[2]}(t),service:"tiktok"}:/(dailymotion\.com|dai\.ly)/.test(t)?i={id:function(e){let t=/dailymotion\.com(.*)(video)\/([a-zA-Z\d]+)/gm.exec(e);if(t)return t[3];let i=/dai\.ly\/([a-zA-Z\d]+)/gm.exec(e);if(i&&i.length>1)return i[1];let s=/dailymotion\.com(.*)video=([a-zA-Z\d]+)/gm.exec(e);if(s&&s.length>2)return s[2]}(t),service:"dailymotion"}:/loom\.com/.test(t)&&(i={id:function(e){let t=/^https?:\/\/(?:www\.)?loom\.com\/(?:share|embed)\/([\da-zA-Z]+)\/?/.exec(e);if(t&&t.length>1)return t[1]}(t),service:"loom"}),i}(s?.url);return a?(0,T.jsx)(F,{videoId:a,description:s?.description}):(0,T.jsx)("p",{children:"Vídeo não encontrado"})};function U(e,t,i,s,r,a,n,l){return{id:e,label:t,description:i,icon:s,columnCount:r,widths:a,mobileMode:n,columnHints:l}}let j=[U("2-cols-50-50","2 Colunas (50/50)","Duas colunas com larguras iguais","M3 3h8v18H3V3zm10 0h8v18h-8V3z",2,{mobile:[100],desktop:[50,50]},"stack",["empty","empty"]),U("2-cols-30-70","2 Colunas (30/70)","Duas colunas: sidebar estreita à esquerda","M3 3h6v18H3V3zm8 0h10v18H11V3z",2,{mobile:[100],desktop:[30,70]},"stack",["empty","empty"]),U("2-cols-70-30","2 Colunas (70/30)","Duas colunas: conteúdo largo à esquerda","M3 3h10v18H3V3zm12 0h6v18h-6V3z",2,{mobile:[100],desktop:[70,30]},"stack",["empty","empty"]),U("2-cols-images","2 Imagens lado a lado","Duas colunas com uma imagem em cada","M3 3h8v18H3V3zm10 0h8v8h-8V3zm0 10h8v8h-8v-8z",2,{mobile:[100],desktop:[50,50]},"stack",["image","image"]),U("image-text","Imagem + Texto","Imagem à esquerda, texto à direita","M3 3h8v18H3V3zm10 1h8v2h-8V4zm0 4h6v2h-6V8zm0 4h8v2h-8v-2z",2,{mobile:[100],desktop:[40,60]},"stack",["image","text"]),U("text-image","Texto + Imagem","Texto à esquerda, imagem à direita","M3 1h8v2H3V1zm0 4h6v2H3V5zm0 4h8v2H3V9zm10-6h8v18h-8V3z",2,{mobile:[100],desktop:[60,40]},"stack",["text","image"]),U("3-cols","3 Colunas","Três colunas com larguras iguais","M3 3h5v18H3V3zm7 0h4v18h-4V3zm6 0h5v18h-5V3z",3,{mobile:[100],desktop:[33.33,33.34,33.33]},"stack",["empty","empty","empty"]),U("hero","Hero (imagem + texto)","Imagem larga no topo com texto abaixo","M3 3h18v10H3V3zm0 12h18v6H3v-6z",1,{mobile:[100],desktop:[100]},"stack",["image"])];j.map(e=>[e.id,e]);let V=(0,x.createContext)({}),G=e=>{let t="string"==typeof e?.backgroundColor||"string"==typeof e?.background;return e&&"string"==typeof e.color&&!t?{...e,color:(e=>{let t=(e=>{let t=e.trim().toLowerCase();if("black"===t)return[0,0,0];if("white"===t)return[255,255,255];let i=t.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/);if(i){let e=i[1];return 3===e.length&&(e=e.split("").map(e=>e+e).join("")),[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}let s=t.match(/^rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)/);return s?[+s[1],+s[2],+s[3]]:null})(e);if(!t)return e;let[i,s,r]=t;return(Math.max(i,s,r)-Math.min(i,s,r))/255<.16&&(.2126*i+.7152*s+.0722*r)/255<.45?`var(--dp-text, ${e})`:e})(e.color)}:e};function q(e){return e.split(";").map(e=>
1e.trim()).filter(Boolean).reduce((e,t)=>{let[i,s]=t.split(":").map(e=>e.trim());return i&&s&&(e[i.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())]=s),e},{})}let H=e=>!!(e&&"object"==typeof e),K=e=>e?Array.isArray(e)?e:H(e)&&"type"in e?[e]:H(e)?Object.values(e).filter(Boolean):[]:[],W=(e,t,i)=>{if(!e?.type)return null;let s=i[e.type];if(s)return(0,T.jsx)(s,{node:e,macros:t,renderNode:(e,s)=>W(e,s??t,i)});let r=K(e.children);return r.length?(0,T.jsx)(T.Fragment,{children:r.map((e,s)=>(0,T.jsx)(T.Fragment,{children:W(e,t,i)},s))}):null},z={width:800,devicePixelRatio:1,fontFamily:"Arial",fontSize:18,lineHeight:1.5,padding:24,backgroundColor:"#ffffff"},Y={text:"#1f2933",mutedText:"#52606d",border:"#d9e2ec",selectedBorder:"#2563eb",selectedBackground:"#eff6ff",alternativeBackground:"#ffffff",imageBackground:"#f5f7fa",focusRing:"#0b3d91"},Q={text:"#f0f4f8",mutedText:"#b0bcc7",border:"#495a6b",selectedBorder:"#7dabf8",selectedBackground:"#1c2a3a",alternativeBackground:"#121a24",imageBackground:"#1a2430",focusRing:"#a9c9ff"},X={enabled:!0,webColumns:2,mobileColumns:1,breakpoint:768,gap:12},J=e=>Array.isArray(e)?`[${e.map(e=>J(e)).join(",")}]`:e&&"object"==typeof e&&!Array.isArray(e)?`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${J(e[t])}`).join(",")}}`:JSON.stringify(e)??"undefined",Z=e=>{let t=J(e),i=0x811c9dc5;for(let e=0;e<t.length;e+=1)i^=t.charCodeAt(e),i=Math.imul(i,0x1000193);return(i>>>0).toString(16).padStart(8,"0")},ee=e=>Number.parseInt(Z({questionId:e.questionId,studentId:e.studentId,sessionId:e.sessionId,textVariantSeed:e.textVariantSeed??null,variantId:e.variantId}).slice(0,8),16),et=e=>!!(e&&"object"==typeof e&&!Array.isArray(e)),ei=e=>{let t=e.children;return t?Array.isArray(t)?t:Object.values(t).filter(Boolean):[]},es=e=>"string"==typeof e.text?e.text:"linebreak"===e.type?`
2`:ei(e).map(es).join(""),er=(e,t)=>String(e.key??e.__key??`lexical_${t}`),ea={angle:-25,enabled:!1,opacity:.08,repeat:!0,visibleText:""},en=e=>{let t=[];if(0===e.length)return{alternatives:e,warnings:t};let i=e.filter(e=>"number"==typeof e.displayPosition);if(0===i.length)return{alternatives:e,warnings:t};if(i.length!==e.length)return t.push({code:"alternative_display_position_partial",message:"Apenas parte das alternativas declarou displayPosition; a ordem do array foi mantida.",metadata:{declared:i.length,total:e.length}}),{alternatives:e,warnings:t};if(new Set(i.map(e=>e.displayPosition)).size!==e.length)return t.push({code:"alternative_display_position_duplicated",message:"displayPosition duplicado entre alternativas; a ordem do array foi mantida."}),{alternatives:e,warnings:t};let s=[...e].sort((e,t)=>(e.displayPosition??0)-(t.displayPosition??0)),r=e.map(e=>e.label);return{alternatives:s.map((e,t)=>{let i=r[t];return void 0===i||i===e.label?e:{...e,label:i}}),warnings:t}},el=e=>{let t={...X,...e.grid};if(!1===t.enabled)return{columns:1,gap:0,isMobile:!1};let i=e.width<=t.breakpoint;return{columns:Math.max(1,Math.floor(i?t.mobileColumns:t.webColumns)),gap:Math.max(0,t.gap),isMobile:i}},eo=(...e)=>{for(let t of e)if("number"==typeof t&&Number.isFinite(t)&&t>0)return t},ed=(e,t,i)=>{let s=[],r="";for(let a of t){let t=`${r}${a}`;r&&e.measureText(t).width>i?(s.push(r),r=a):r=t}return r?[...s,r]:s},eh=e=>e.renderConfig.width-2*e.renderConfig.padding,eu=e=>e.text?e.text:"table"===e.type&&e.rows?e.rows.map(e=>e.cells.map(e=>e.blocks.map(eu).join(" ").trim()).join(" | ")).join(`
3`):"",ec=(e,t)=>{let i=e?.[t];return"number"==typeof i&&Number.isFinite(i)?i:void 0},ef=(e,t,i,s,r,a)=>{var n;let l,o,d,h=eu(i),u=(n=t.payload,l=n.renderConfig.fontSize,o="heading"===i.type?Math.round(l*(1.35-.04*Math.min(i.level??2,6))):l,`${"heading"===i.type?"700":"400"} ${o}px ${n.renderConfig.fontFamily}`),c=(d=t.payload).renderConfig.fontSize*d.renderConfig.lineHeight;for(let i of(t.context.font=u,h.split(`
4`).flatMap(e=>(e=>{let t=e.text.replace(/\s+/g," ").trim();if(!t)return[];let i=[],s=t.split(" "),r="";for(let t of s)for(let s of e.context.measureText(t).width>e.maxWidth?ed(e.context,t,e.maxWidth):[t]){let t=r?`${r} ${s}`:s;r&&e.context.measureText(t).width>e.maxWidth?(i.push(r),r=s):r=t}return r?[...i,r]:i})({context:t.context,maxWidth:a,text:e}))))e.lines.push({color:e.colors.text,font:u,text:i,x:r,y:s.y}),s.y+=c;s.y+="heading"===i.type?14:12},ep=(e,t,i,s,r,a)=>{if("image"===i.type)return void((e,t,i,s,r,a)=>{let n=t.payload,l=i.image,o=el({grid:n.renderConfig.alternativeGrid,width:n.renderConfig.width});l?.headerText&&ef(e,t,{id:`${i.id}_header`,text:l.headerText,type:"paragraph"},s,r,a);let d=l?(e=>{let{availableWidth:t,image:i,isMobile:s}=e;if(s?!!i.disableShowMobile:!!i.disableShowOnWeb)return{height:0,isHidden:!0,width:0,x:0};let r=eo(s?i.maxWidthMobile:i.maxWidthDesktop,i.maxWidth),a=eo(s?i.maxHeightMobile:i.maxHeightDesktop,i.maxHeight),n=eo(e.intrinsicRatio)??1.7
4777777777777777,l=Math.min(t,r??t),o=l/n;void 0!==a&&o>a&&(l=Math.min(l,(o=a)*n));let d=i.alignment??i.position??"center",h=Math.max(0,t-l);return{height:Math.max(1,Math.round(o)),isHidden:!1,width:Math.max(1,Math.round(l)),x:Math.round("right"===d?h:"left"===d?0:h/2)}})({availableWidth:a,image:l,intrinsicRatio:ec(i.metadata,"ratio"),isMobile:o.isMobile}):{height:ec(i.metadata,"height")??160,isHidden:!1,width:Math.min(ec(i.metadata,"width")??a,a),x:0};if(d.isHidden)return e.warnings.push({blockId:i.id,code:"image_hidden_for_target",message:"Imagem oculta neste contexto de render por configuração do bloco."});let h=r+d.x,{height:u,width:c}=d,f=l?.fileUrl??i.src;e.images.push({alt:i.alt,height:u,src:f,width:c,x:h,y:s.y}),e.rects.push({backgroundColor:e.colors.imageBackground,borderColor:e.colors.border,height:u,width:c,x:h,y:s.y}),(l?.isOpenLightboxOnClick||l?.link)&&e.hitAreas.push({alternativeId:i.id,height:u,id:`image_${i.id}`,width:c,x:h,y:s.y}),f||e.warnings.push({blockId:i.id,code:"image_without_src",message:"Bloco de imagem sem src foi renderizado como placeholder."}),s.y+=u+12,l?.reference&&ef(e,t,{id:`${i.id}_caption`,text:l.reference,type:"paragraph"},s,r,a),n.renderConfig.height&&s.y>n.renderConfig.height&&e.warnings.push({blockId:i.id,code:"content_exceeds_config_height",message:"O conteúdo ultrapassou a altura configurada para o canvas."})})(e,t,i,s,r,a);if("spacer"===i.type){s.y+=ec(i.metadata,"height")??12;return}ef(e,t,i,s,r,a)},em=(e,t,i,s)=>{let r={colors:s,height:0,hitAreas:[],images:[],lines:[],rects:[],warnings:[],width:i},a={y:14},n=i-28;return t.label&&ef(r,e,{id:`${t.id}_label`,text:`${t.label}.`,type:"paragraph"},a,14,n),t.blocks.forEach(t=>{ep(r,e,t,a,14,n)}),{alternative:t,height:a.y+14,layout:r}},eg=(e,t,i,s,r,a,n)=>{var l;let o,d,h=(o=i.alternative,d=t.selectedAlternativeId,!!o.isSelected||void 0!==d&&(d===o.id||d===o.answerValue));t.focusedAlternativeId===i.alternative.id&&e.rects.push({borderColor:e.colors.focusRing,borderWidth:3,height:n+6,width:a+6,x:s-3,y:r-3}),e.rects.push({backgroundColor:h?e.colors.selectedBackground:e.colors.alternativeBackground,borderColor:h?e.colors.selectedBorder:e.colors.border,height:n,width:a,x:s,y:r}),l=i.layout,e.lines.push(...l.lines.map(e=>({...e,x:e.x+s,y:e.y+r}))),e.images.push(...l.images.map(e=>({...e,x:e.x+s,y:e.y+r}))),e.rects.push(...l.rects.map(e=>({...e,x:e.x+s,y:e.y+r}))),e.warnings.push(...l.warnings),e.hitAreas.push({alternativeId:i.alternative.id,height:n,id:`hit_${i.alternative.id}`,width:a,x:s,y:r})},ey=/^#([0-9a-f]{3})$/i,ev=/^#([0-9a-f]{6})$/i,eb=e=>{let t=ey.exec(e);if(t){let[e,i,s]=t[1].split("");return[Number.parseInt(`${e}${e}`,16),Number.parseInt(`${i}${i}`,16),Number.parseInt(`${s}${s}`,16)]}let i=ev.exec(e);if(!i)return null;let s=Number.parseInt(i[1],16);return[s>>16&255,s>>8&255,255&s]},eE=e=>{let[t,i,s]=e.map(e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4});return .2126*t+.7152*i+.0722*s},eS=(e,t)=>{let i=eb(e),s=eb(t);return i&&s?(Math.max(eE(i),eE(s))+.05)/(Math.min(eE(i),eE(s))+.05):null},eT=e=>{let t=[];for(let i of e)if("formula"===i.type&&t.push(i),i.rows)for(let e of i.rows)for(let i of e.cells)t.push(...eT(i.blocks));return t},ex=(e,t)=>e.map(e=>{if(e.rows)return{...e,rows:e.rows.map(e=>({...e,cells:e.cells.map(e=>({...e,blocks:ex(e.blocks,t)}))}))};if("formula"!==e.type)return e;let i=t.get(e.id);return i?{...e,image:{alignment:"center",fileUrl:i.dataUri,maxHeight:i.height,maxWidth:i.width},metadata:{...e.metadata,ratio:i.width/i.height},src:i.dataUri,type:"image"}:e}),ek=async e=>{let{payload:t,renderer:i}=e,s=[],r=[...eT(t.blocks),...t.alternatives.flatMap(e=>eT(e.blocks))];if(0===r.length)return{payload:t,warnings:s};if(!i)return s.push({code:"formula_renderer_missing",message:"Há fórmulas no payload e nenhum renderer foi informado; o LaTeX será desenhado como texto.",metadata:{count:r.length}}),{payload:t,warnings:s};let a=t.renderConfig.width-2*t.renderConfig.padding,n=new Map;for(let{block:e,result:l}of(await Promise.all(r.map(async e=>{let s,r=e.text??"",n=e.metadata?.inline===!0;try{s=await i.render({fontSize:t.renderConfig.fontSize,inline:n,latex:r,maxWidth:a})}catch{s=void 0}return{block:e,result:s}})))){if(l){n.set(e.id,l);continue}s.push({blockId:e.id,code:"formula_render_failed",message:"A fórmula não pôde ser rasterizada; o LaTeX foi mantido como texto."})}return 0===n.size?{payload:t,warnings:s}:{payload:{...t,alternatives:t.alternatives.map(e=>({...e,blocks:ex(e.blocks,n)})),blocks:ex(t.blocks,n)},warnings:s}},ew=/^#([0-9a-f]{6})$/i,eA=/(\d+(?:\.\d+)?)px/,eR=(e,t,i)=>{let s=(e^Math.imul(t+1,0x165667b1)^Math.imul(i+1,0x27d4eb2f))>>>0;return(((s=Math.imul(s^s>>>13,0x4bf19f61)>>>0)^s>>>16)>>>0)/0x100000000},eL=(e,t,i,s)=>2*eR(e+0x9e3779b9*s,t,i)-1,eC=(e,t)=>{let i=ew.exec(e);if(!i||t<=0)return e;let s=Number.parseInt(i[1],16);return`#${[s>>16&255,s>>8&255,255&s].map(e=>Math.min(255,Math.max(0,Math.round(e+t)))).map(e=>e.toString(16).padStart(2,"0")).join("")}`},eI=new Map,eP=(e,t,i)=>{let s=`${t}\0${i}`,r=eI.get(s);if(void 0!==r)return r;let a=e.measureText(i).width;return eI.set(s,a),a},eD=new Map,eM=async e=>{let t=[...new Set(e.images.map(e=>e.src).filter(e=>!!e))];if(0===t.length||typeof Image>"u")return new Map;let i=await Promise.all(t.map(e=>(e=>{let t=eD.get(e);if(t)return t;let i=new Promise(t=>{let i=new Image;i.crossOrigin="anonymous",i.onload=()=>t(i),i.onerror=()=>t(null),i.src=e});return eD.set(e,i),i})(e)));return new Map(t.map((e,t)=>[e,i[t]]))},e_=async e=>{let t,{context:i,layout:s,payload:r}=e,a=await eM(s);i.clearRect(0,0,s.width,s.height),i.fillStyle=r.renderConfig.backgroundColor??"#ffffff",i.fillRect(0,0,s.width,s.height),s.rects.forEac
4h(e=>{e.backgroundColor&&(i.fillStyle=e.backgroundColor,i.fillRect(e.x,e.y,e.width,e.height)),e.borderColor&&(i.strokeStyle=e.borderColor,i.lineWidth=e.borderWidth??1,i.strokeRect(e.x,e.y,e.width,e.height))});let n=((e,t,i)=>{let s=[];for(let r of t.images){let a=r.src?i.get(r.src):void 0;if(a){e.drawImage(a,r.x,r.y,r.width,r.height);continue}e.fillStyle=t.colors.mutedText,e.font="400 14px Arial",e.textBaseline="middle",e.fillText("Imagem",r.x+16,r.y+r.height/2),r.src&&s.push({code:"image_load_failed",message:"A imagem não pôde ser carregada no canvas.",metadata:{src:r.src}})}return s})(i,s,a);if(i.textBaseline="top",(t=r.protection)&&[t.glyphVariationIntensity,t.glyphOffsetXIntensity,t.glyphOffsetYIntensity,t.glyphRotationIntensity,t.glyphColorIntensity,t.microDistortionIntensity].some(e=>(e??0)>0)?s.lines.forEach((e,s)=>{var a,n;let l;i.fillStyle=e.color,i.font=e.font,(e=>{let{context:t,fontSize:i,layoutSeed:s,line:r,lineIndex:a,protection:n}=e,l=n.glyphVariationIntensity??0,o=n.microDistortionIntensity??0,d=s+(n.frameSeed??0)*0x9e3779b1,h=(n.glyphOffsetXIntensity??l)*i*.5,u=(n.glyphOffsetYIntensity??l)*i*.5,c=(n.glyphRotationIntensity??l)*(25*Math.PI)/180,f=90*(n.glyphColorIntensity??l),p=o*i,m=Math.max(24,4*i),g=eR(d,a,0)*Math.PI*2,y=r.x;for(let e=0;e<r.text.length;e+=1){let s=r.text[e],n=eP(t,r.font,s);if(" "===s){y+=n;continue}let l=eL(d,a,e,1)*h,o=eL(d,a,e,2)*u,v=eL(d,a,e,3)*c,b=0===p?0:Math.sin(y/m*Math.PI*2+g)*p;if(f>0&&(t.fillStyle=eC(r.color,eL(d,a,e,4)*f)),0===v)t.fillText(s,y+l,r.y+o+b);else{let e=y+n/2,a=r.y+i/2;t.save(),t.translate(e,a),t.rotate(v),t.translate(-e,-a),t.fillText(s,y+l,r.y+o+b),t.restore()}y+=n}})({context:i,fontSize:(a=e.font,n=r.renderConfig.fontSize,(l=eA.exec(a))?Number.parseFloat(l[1]):n),layoutSeed:r.forensic.layoutSeed,line:e,lineIndex:s,protection:t})}):s.lines.forEach(e=>{i.fillStyle=e.color,i.font=e.font,i.fillText(e.text,e.x,e.y)}),((e,t,i)=>{let s=i.watermark;if(!s.enabled||!s.visibleText)return;let r=i.forensic.layoutSeed,a=r%260,n=r%150,l=s.angle*Math.PI/180;e.save(),e.globalAlpha=Math.min(1,Math.max(0,s.opacity)),e.fillStyle=t.colors.mutedText,e.font=`600 ${Math.max(14,i.renderConfig.fontSize)}px ${i.renderConfig.fontFamily}`,e.textBaseline="middle";let o=(t,i)=>{e.save(),e.translate(t,i),e.rotate(l),e.fillText(s.visibleText,0,0),e.restore()};if(!s.repeat){o(t.width/2,t.height/2),e.restore();return}for(let e=-150;e<t.height+150;e+=150)for(let i=-260;i<t.width+260;i+=260)o(i+a,e+n);e.restore()})(i,s,r),(r.protection?.spatialNoiseOpacity??0)>0){let e=Math.max(1,r.renderConfig.devicePixelRatio||1);(e=>{let{context:t,height:i,imageRects:s,layoutSeed:r,protection:a,width:n}=e;if((a.spatialNoiseOpacity??0)<=0||n<=0||i<=0)return;let l=t.getImageData(0,0,n,i);(e=>{let{data:t,height:i,imageRects:s,layoutSeed:r,protection:a,width:n}=e,l=a.spatialNoiseOpacity??0;if(l<=0||n<=0||i<=0)return;let o=Math.max(1,Math.round(a.spatialNoiseScale??2)),d=900*l,h=e=>.2126*t[e]+.7152*t[e+1]+.0722*t[e+2],u=(e,t)=>!!s?.length&&s.some(i=>e>=i.x&&e<i.x+i.width&&t>=i.y&&t<i.y+i.height),c=(e,t)=>{let s=Math.max(0,t-2),r=Math.min(i-1,t+2),a=Math.max(0,e-2),l=Math.min(n-1,e+2),o=255,d=0;for(let e=s;e<=r;e+=1)for(let t=a;t<=l;t+=1){let i=h((e*n+t)*4);if(i<o&&(o=i),i>d&&(d=i),d-o>=60)return!0}return!1},f=Math.trunc(r)+(a.frameSeed??0)*0x9e3779b1>>>0,p=()=>{let e=f=f+0x6d2b79f5>>>0;return e=Math.imul(e^e>>>15,1|e),(((e^=e+Math.imul(e^e>>>7,61|e))^e>>>14)>>>0)/0x100000000};for(let e=0;e<i;e+=o)for(let s=0;s<n;s+=o){if(u(s,e))continue;let r=h((e*n+s)*4);if(r<=40||r>=235||!c(s,e))continue;let a=(2*p()-1)*d;for(let r=e;r<Math.min(e+o,i);r+=1)for(let e=s;e<Math.min(s+o,n);e+=1){if(u(e,r))continue;let i=(r*n+e)*4,s=h(i);s<=40||s>=235||(t[i]=Math.min(255,Math.max(0,t[i]+a)),t[i+1]=Math.min(255,Math.max(0,t[i+1]+a)),t[i+2]=Math.min(255,Math.max(0,t[i+2]+a)))}}})({data:l.data,height:i,imageRects:s,layoutSeed:r,protection:a,width:n}),t.putImageData(l,0,0)})({context:i,height:Math.ceil(s.height*e),imageRects:s.images.map(t=>({height:Math.ceil(t.height*e),width:Math.ceil(t.width*e),x:Math.floor(t.x*e),y:Math.floor(t.y*e)})),layoutSeed:r.forensic.layoutSeed,protection:r.protection,width:Math.ceil(s.width*e)})}return n},e$=()=>"u">typeof performance?performance.now():Date.now(),eO=async e=>{var t,i,s,r;let a,n,l,o,d,h,u,c=e$(),f=await ek({payload:e.payload,renderer:e.formulaRenderer}),p=(t=f.payload,a={...z,...t.renderConfig,alternativeGrid:{...X,...t.renderConfig.alternativeGrid},devicePixelRatio:Math.max(1,t.renderConfig.devicePixelRatio??1),fontSize:Math.max(10,t.renderConfig.fontSize??18),lineHeight:Math.max(1,t.renderConfig.lineHeight??1.5),padding:Math.max(0,t.renderConfig.padding??0),width:Math.max(1,t.renderConfig.width??800)},n=Number.isFinite(t.forensic.layoutSeed)?t.forensic.layoutSeed:ee({questionId:t.questionId,sessionId:t.sessionId,studentId:t.studentId,textVariantSeed:t.forensic.textVariantSeed,variantId:t.variantId}),{payload:l={...t,alternatives:t.alternatives??[],blocks:t.blocks??[],forensic:{...t.forensic,layoutSeed:n},renderConfig:a,watermark:{...t.watermark,angle:Number.isFinite(t.watermark.angle)?t.watermark.angle:-25,opacity:Math.min(1,Math.max(0,t.watermark.opacity??.08))}},warnings:(o=[],l.questionId||o.push({code:"missing_question_id",message:"Payload sem questionId recebeu renderização com assinatura fraca."}),l.studentId&&l.sessionId||o.push({code:"missing_forensic_identity",message:"Payload sem studentId ou sessionId reduz a rastreabilidade."}),l.blocks.length||o.push({code:"empty_question_blocks",message:"Payload sem blocos de enunciado."}),l.watermark?.enabled?l.watermark.visibleText||o.push({code:"watermark_without_text",message:"Marca d'água habilitada sem visibleText: nada será desenhado e não haverá vestígio forense."}):o.push({code:"watermark_disabled",message:"Marca d'água desligada: o render não terá nenhum vestígio forense de origem."}),o)}),m=p.payload,g=(e=>{let{payload:t}=e,i=eh(t),s=t.renderConfig.padding,r=(e=>{let t=e.backgroundColor??"#ffffff",i=[],s=eS(Y.text,t),r=eS(Q.text,t),a=((e,t)=>{if(!t)return e;let i={...e};for(let e of Object.keys(t)){let s=t[e];"string"==typeof s&&s&&(i[e]=s)}return i})({...null!==s&&null!==r&&r>s?Q:Y},e.colors);for(let e of[{background:t,foreground:a.text,surface:"statement"}
4,{background:a.alternativeBackground,foreground:a.text,surface:"alternative"},{background:a.selectedBackground,foreground:a.text,surface:"alternative_selected"}]){let t=eS(e.foreground,e.background);null!==t&&t<4.5&&i.push({code:"low_contrast_text",message:`Contraste de ${t.toFixed(2)}:1 em ${e.surface} n\xe3o atinge o m\xednimo 4.5:1 da WCAG 2.1 AA.`,metadata:{background:e.background,foreground:e.foreground,ratio:Number(t.toFixed(2)),surface:e.surface}})}return{colors:a,warnings:i}})({backgroundColor:t.renderConfig.backgroundColor,colors:t.renderConfig.colors}),a={colors:r.colors,height:t.renderConfig.height??0,hitAreas:[],images:[],lines:[],rects:[],warnings:[...r.warnings],width:t.renderConfig.width},n={y:s};return t.blocks.forEach(t=>{ep(a,e,t,n,s,i)}),((e,t,i)=>{let{columns:s,gap:r}=el({grid:t.payload.renderConfig.alternativeGrid,width:t.payload.renderConfig.width}),a=(eh(t.payload)-r*(s-1))/s,n=en(t.payload.alternatives),l=n.alternatives,o=Math.ceil(l.length/s);e.warnings.push(...n.warnings);for(let n=0;n<o;n+=1){let o=l.slice(n*s,n*s+s).map(i=>em(t,i,a,e.colors)),d=Math.max(...o.map(e=>e.height));o.forEach((s,n)=>{let l=t.payload.renderConfig.padding+n*(a+r);eg(e,t,s,l,i.y,a,d)}),i.y+=d+12}})(a,e,n),a.height=t.renderConfig.height??Math.ceil(n.y+s),a})({context:e.target.context,focusedAlternativeId:e.focusedAlternativeId,payload:m,selectedAlternativeId:e.selectedAlternativeId}),y=(d=Z({alternatives:(i={alternatives:m.alternatives,layoutSeed:m.forensic.layoutSeed,questionId:m.questionId,sessionId:m.sessionId,studentId:m.studentId,textVariantSeed:m.forensic.textVariantSeed,variantId:m.variantId,watermark:m.watermark}).alternatives.map(e=>({blocks:e.blocks,id:e.id,label:e.label})),layoutSeed:i.layoutSeed,questionId:i.questionId,sessionId:i.sessionId,studentId:i.studentId,textVariantSeed:i.textVariantSeed??null,variantId:i.variantId,watermark:i.watermark}),`secure-exam-v1:${d}`);s=e.target.canvas,r=g.height,h=Math.max(1,m.renderConfig.devicePixelRatio||1),s.width=Math.ceil((u=m.renderConfig.width)*h),s.height=Math.ceil(r*h),s.style.width=`${u}px`,s.style.height=`${r}px`,e.target.context.setTransform(m.renderConfig.devicePixelRatio,0,0,m.renderConfig.devicePixelRatio,0,0);let v=await e_({context:e.target.context,layout:g,payload:m}),b=[...f.warnings,...p.warnings,...g.warnings,...v];return{alternativeHitAreas:g.hitAreas,blockCount:m.blocks.length,forensicSignature:m.signature||m.forensic.signature||y,height:g.height,layout:g,questionId:m.questionId,renderDurationMs:e$()-c,variantId:m.variantId,warnings:b,width:g.width}},eN=e=>({cause:e,code:"secure_exam_render_failed",message:e instanceof Error?e.message:"Falha desconhecida ao renderizar o canvas seguro."}),eF=e=>{let t=Number.parseFloat(e);return Number.isFinite(t)?t:0},eB=e=>{let t=e.getBoundingClientRect(),i=typeof window>"u"?void 0:window.getComputedStyle(e);if(!i)return t.width;let s=eF(i.paddingLeft)+eF(i.paddingRight)+eF(i.borderLeftWidth)+eF(i.borderRightWidth);return Math.max(0,t.width-s)},eU=async e=>{let t,i=Math.max(1,e.renderConfig.devicePixelRatio||1),s=await (!(t=(e=>{var t;let i;if(e.dataUrl||e.uri)return{shouldRevoke:!1,url:e.dataUrl??e.uri??""};if(!e.bytes||typeof URL>"u"||typeof Blob>"u")return;let s=new Blob([(new Uint8Array(i=new ArrayBuffer((t=e.bytes).byteLength)).set(t),i)],{type:e.mimeType??"image/png"});return{shouldRevoke:!0,url:URL.createObjectURL(s)}})(e.bitmap))||typeof Image>"u"?Promise.resolve(void 0):new Promise(e=>{let i=new Image,s=()=>{t.shouldRevoke&&URL.revokeObjectURL(t.url)};i.onload=()=>{s(),e(i)},i.onerror=()=>{s(),e(void 0)},i.src=t.url}));e.canvas.width=Math.ceil(e.bitmap.width*i),e.canvas.height=Math.ceil(e.bitmap.height*i),e.canvas.style.width=`${e.bitmap.width}px`,e.canvas.style.height=`${e.bitmap.height}px`,e.context.setTransform(i,0,0,i,0,0),e.context.clearRect(0,0,e.bitmap.width,e.bitmap.height),s&&e.context.drawImage(s,0,0,e.bitmap.width,e.bitmap.height)},ej=()=>"u">typeof performance&&"function"==typeof performance.now?performance.now():Date.now(),eV=async e=>{let t=ej(),i=await e.wasmRenderer.renderToBitmap(e.payload,{...e.wasmOptions,engine:"wasm",selectedAlternativeId:e.selectedAlternativeId});return await eU({bitmap:i,canvas:e.canvas,context:e.context,renderConfig:e.payload.renderConfig}),{alternativeHitAreas:i.alternativeHitAreas??[],blockCount:e.payload.blocks.length,forensicSignature:i.forensicSignature,height:i.height,questionId:e.payload.questionId,renderDurationMs:i.renderDurationMs??ej()-t,variantId:e.payload.variantId,warnings:i.warnings??[],width:i.width}},eG={dispose:()=>{}},eq={type:"none"},eH=["ArrowDown","ArrowRight"],eK=["ArrowLeft","ArrowUp"],eW=[" ","Enter","Spacebar"],ez=e=>{let{accessibility:t,payload:i,selectedAlternativeId:s}=e,[r,a]=(0,x.useState)(-1),n=(0,x.useRef)(-1),l=(0,x.useMemo)(()=>en(i.alternatives).alternatives,[i.alternatives]),o=r>=0?l[r]:void 0,d=(e=>{let{focusedAlternativeId:t,formulaRenderer:i,onAlternativePress:s,onRenderComplete:r,onRenderError:a,onRendererFallback:n,payload:l,selectedAlternativeId:o,responsive:d,wasmOptions:h,wasmRenderer:u}=e,c=d?.enabled,f=d?.maxWidth,p=d?.minWidth,m=d?.mode,g=(0,x.useMemo)(()=>({enabled:c,maxWidth:f,minWidth:p,mode:m}),[c,f,p,m]),y=(0,x.useRef)(null),v=(0,x.useRef)([]),b=(0,x.useRef)({logicalWidth:0}),E=(0,x.useRef)(l),S=(0,x.useRef)(0),T=(0,x.useRef)(!0),[k,w]=(0,x.useState)([]),[A,R]=(0,x.useState)(),[L,C]=(0,x.useState)();(0,x.useEffect)(()=>{E.current=l}),(0,x.useEffect)(()=>(T.current=!0,()=>{T.current=!1}),[]);let I=(0,x.useCallback)(async()=>{let e=y.current;if(!e)return;let s=S.current+1;S.current=s;let d=()=>!T.current||S.current!==s,c=((e,t,i)=>{if(i?.enabled===!1)return e;let s=t.parentElement,r=s?eB(s):void 0,a=e.renderConfig.width,n=i?.mode??"shrink",l=r&&r>0?"container"===n?Math.floor(r):Math.min(a,Math.floor(r)):a,o=i?.maxWidth??("container"===n?1/0:a),d=Math.max(i?.minWidth??1,Math.min(o,l));return{...e,renderConfig:{...e.renderConfig,devicePixelRatio:e.renderConfig.devicePixelRatio||("u">typeof window?window.devicePixelRatio:1),width:d}}})(l,e,g),f=e.getContext("2d");if(!f){let e={code:"canvas_context_unavailable",message:"CanvasRenderingContext2D indisponível."};d()||(C(e),a?.(e));return}let p=e=>{v.current=e.alternativeHitAreas,b.current={logicalWidth:e.width},w(e.alternativeHitAreas),R(e),C(void 0),r?.(e)},m=async()=>{let s=((e,t,i)=>{let s=e.getContext("2d");if(!s)return;let r=Math.max(1,t.devicePixelRatio||1),a=t.width;return e.width=Math.ceil(a*r),e.height=Math.ceil(i*r),e.style.width=`${a}px`,e.style.height=`${i}px`,s.setTransform(r,0,0,r,0,0),{canvas:e,context:s}})(e,c.renderConfig,c.renderConfig.height??1);if(!s){let e={code:"canvas_context_unavailable",message:"CanvasRenderingContext2D indisponível."};d()||(C(e),a?.(e));return}let r=null,n=null;try{r=await eO({focusedAlternativeId:t,formulaRenderer:i,payload:c,selectedAlternativeId:o,target:s})}catch(e){n=e}if(d())return;if(r)return void p(r);let l=eN(n);C(l),a?.(l)};if(u){let t=null,i=null;try{t=await eV({canvas:e,context:f,payload:c,selectedAlternativeId:o,wasmOptions:h,wasmRenderer:u})}catch(e){i=e}if(d())return;if(t)return void p(t);
4n?.({error:eN(i),from:"wasm",to:"canvas2d"})}await m()},[t,i,r,a,n,l,g,o,h,u]);(0,x.useEffect)(()=>{I()},[I]),(0,x.useEffect)(()=>{let e=y.current?.parentElement;if(!e||typeof ResizeObserver>"u")return;let t=0,i=eB(e),s=new ResizeObserver(e=>{let s=e[0]?.contentRect.width??i;1>Math.abs(s-i)||(i=s,t&&cancelAnimationFrame(t),t=requestAnimationFrame(()=>{t=0,I()}))});return s.observe(e),()=>{t&&cancelAnimationFrame(t),s.disconnect()}},[I]);let P=(0,x.useCallback)(e=>{let t,i,r,a=y.current;if(!a)return;let n=(e=>{let{clientX:t,clientY:i,logicalWidth:s,rect:r}=e,a=r.width>0&&s>0?s/r.width:1;return{x:(t-r.left)*a,y:(i-r.top)*a}})({clientX:e.clientX,clientY:e.clientY,logicalWidth:b.current.logicalWidth,rect:a.getBoundingClientRect()}),l=(t=v.current,i=n.x,r=n.y,t.find(e=>i>=e.x&&i<=e.x+e.width&&r>=e.y&&r<=e.y+e.height));if(!l)return;let o=E.current.alternatives.find(e=>e.id===l.alternativeId);s?.(o?o.answerValue??o.id:l.alternativeId)},[s]);return{canvasRef:y,handlePointerPress:P,hitAreas:k,renderError:L,renderResult:A}})({focusedAlternativeId:o?.id,formulaRenderer:e.formulaRenderer,onAlternativePress:e.onAlternativePress,onRenderComplete:e.onRenderComplete,onRenderError:e.onRenderError,onRendererFallback:e.onRendererFallback,payload:i,responsive:e.responsive,selectedAlternativeId:s,wasmOptions:e.wasmOptions,wasmRenderer:e.wasmRenderer});(e=>{let{flags:t,questionId:i,targetRef:s,telemetry:r}=e,a=!!t?.disableContextMenu,n=!!t?.disableCopy,l=!!t?.disablePrint,o=!!t?.disableTextSelection;(0,x.useEffect)(()=>{let e=s.current;if(!e)return;let t=(e=>{let{flags:t,questionId:i,target:s,telemetry:r}=e,a=[],n=(e,t,i)=>{e&&(e.addEventListener(t,i),a.push(()=>e.removeEventListener(t,i)))};if(t.disableCopy){let e=e=>{e.preventDefault(),r?.emit({questionId:i,type:"copy_attempt"})};n(s,"copy",e),n(s,"cut",e)}return t.disableTextSelection&&n(s,"selectstart",e=>{e.preventDefault()}),t.disableContextMenu&&n(s,"contextmenu",e=>{e.preventDefault(),r?.emit({questionId:i,type:"context_menu_attempt"})}),t.disablePrint&&n(s.ownerDocument?.defaultView,"beforeprint",()=>{r?.emit({questionId:i,type:"print_attempt"})}),0===a.length?eG:{dispose:()=>{for(let e of a)e();a.length=0}}})({flags:{disableContextMenu:a,disableCopy:n,disablePrint:l,disableTextSelection:o},questionId:i,target:e,telemetry:r});return()=>t.dispose()},[a,n,l,o,i,s,r])}
4)({flags:e.protections,questionId:i.questionId,targetRef:d.canvasRef,telemetry:e.telemetry}),(0,x.useEffect)(()=>{n.current=r}),(0,x.useEffect)(()=>{a(-1)},[i]);let h=(0,x.useCallback)(t=>{let i=(e=>{let{focusedIndex:t,key:i,optionCount:s}=e;if(s<=0)return eq;let r=t>=0&&t<s?t:-1;return eH.includes(i)?{index:r<0?0:(r+1)%s,type:"focus"}:eK.includes(i)?{index:r<0?s-1:(r-1+s)%s,type:"focus"}:"Home"===i?{index:0,type:"focus"}:"End"===i?{index:s-1,type:"focus"}:eW.includes(i)?r<0?eq:{index:r,type:"select"}:eq})({focusedIndex:n.current,key:t.key,optionCount:l.length});if("none"===i.type)return;if(t.preventDefault(),"focus"===i.type)return void a(i.index);let s=l[i.index];s&&e.onAlternativePress?.(s.answerValue??s.id)},[l,e.onAlternativePress]),u=!!t?.enabled,c=l.length>0;return(0,T.jsx)("canvas",{ref:d.canvasRef,"aria-hidden":!u&&!c||void 0,"aria-label":eY({focusedLabel:o?.label,isAccessible:u,isInteractive:c,label:t?.label,optionCount:l.length}),onBlur:()=>a(-1),onFocus:()=>a(e=>e<0?0:e),onKeyDown:h,onPointerUp:d.handlePointerPress,role:c?"group":u?"img":void 0,style:{display:"block",maxWidth:"100%",outlineOffset:2,touchAction:"manipulation",userSelect:"none"},tabIndex:c?0:void 0})},eY=e=>{let t=e.label??"Conteúdo seguro de prova";if(!e.isInteractive)return e.isAccessible?t:void 0;let i=[`${t}, ${e.optionCount} alternativas`,"use as setas para navegar e Enter ou Espaço para selecionar"];return e.focusedLabel&&i.push(`alternativa ${e.focusedLabel} em foco`),i.join(". ")},eQ={sky:{label:"Info",helper:"Atualizações e dicas",palette:{text:"#0f172a",accent:"#0284c7",border:"#0ea5e91f",background:"#e0f2fe",spotlight:"#38bdf8"}},emerald:{label:"Sucesso",helper:"Confirmações positivas",palette:{text:"#0f172a",accent:"#059669",border:"#10b9811f",background:"#d1fae5",spotlight:"#34d399"}},amber:{label:"Atenção",helper:"Alertas preventivos",palette:{text:"#0f172a",accent:"#f59e0b",border:"#f59e0b1f",background:"#fef3c7",spotlight:"#fbbf24"}},rose:{label:"Crítico",helper:"Problemas que exigem ação",palette:{text:"#0f172a",accent:"#e11d48",border:"#f43f5e26",background:"#ffe4e6",spotlight:"#fb7185"}}},eX=({title:e,description:t,variant:i})=>{let s=eQ[i]??eQ.sky;return(0,T.jsxs)("div",{className:"relative flex gap-3 items-start py-3.5 px-4 rounded-[14px] border shadow-[0_10px_40px_rgba(15,23,42,0.08)]",style:{borderColor:s.palette.border,background:`linear-gradient(120deg, rgba(255,255,255,0.95), rgba(255,255,255,0.9)), ${s.palette.background}`,color:s.palette.text},"data-alert-variant":i,children:[(0,T.jsx)("span",{className:"absolute inset-0 rounded-[14px] opacity-35 pointer-events-none",style:{background:`radial-gradient(circle at 10% 0%, ${s.palette.spotlight} 0, transparent 40%)`},"aria-hidden":!0}),(0,T.jsx)("span",{className:"inline-flex items-center justify-center w-10 h-10 rounded-xl bg-white z-[1] shrink-0 shadow-[0_8px_20px_rgba(15,23,42,0.12)]",style:{borderColor:s.palette.border,borderWidth:1},"aria-hidden":!0,children:(0,T.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:s.palette.accent,strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,T.jsx)("circle",{cx:"12",cy:"12",r:"9",opacity:"0.18",fill:s.palette.accent}),(0,T.jsx)("path",{d:"M12 7.5v6"}),(0,T.jsx)("circle",{cx:"12",cy:"16.5",r:"1.1",fill:s.palette.accent})]})}),(0,T.jsxs)("div",{className:"flex flex-col gap-1 z-[1]",children:[(0,T.jsx)("div",{className:"font-bold text-[15px] tracking-[0.01em]",children:e||s.label}),t?(0,T.jsx)("p",{className:"m-0 text-sm leading-relaxed text-slate-700",children:t}):null]})]})},eJ=({card:e,variant:t})=>(0,T.jsxs)("div",{className:`calendar-card calendar-card--${t}`,children:[(0,T.jsx)("h3",{className:"calendar-card__title",children:e.title}),e.description1&&(0,T.jsx)("h4",{className:"calendar-card__description",children:e.description1}),e.description2&&(0,T.jsx)("h4",{className:"calendar-card__description",children:e.description2})]}),eZ=({mainTitle:e,cards:t,colsMobile:i,colsDesktop:s})=>(0,T.jsxs)("div",{className:"calendar-container",children:[e&&(0,T.jsx)("h1",{className:"calendar-title",children:e}),(0,T.jsx)("div",{className:"calendar-grid",style:{gridTemplateColumns:`repeat(${i}, 1fr)`},"data-cols-mobile":i,"data-cols-desktop":s,children:t.map((e,t)=>(0,T.jsx)(eJ,{card:e,variant:t%2==0?"outline":"filled"},t))})]}),e0=({imageDataUri:e,width:t,height:i,name:s,inline:r,chemistryId:a,onDoubleClick:n})=>(0,T.jsxs)(r?"span":"div",{className:r?"lexical-chemistry lexical-chemistry--inline":"lexical-chemistry","data-chemistry-id":a,onDoubleClick:n,style:{display:r?"inline-block":"block",textAlign:r?void 0:"center"},children:[e?(0,T.jsx)("img",{src:e,alt:s||"Estrutura química",width:t,height:i,style:{maxWidth:"100%",height:"auto",verticalAlign:r?"middle":void 0}}):(0,T.jsx)("span",{style:{fontStyle:"italic",color:"var(--dp-text-2, #888)"},children:"[molécula sem preview]"}),!r&&s?(0,T.jsx)("div",{style:{fontSize:"0.9em",color:"var(--dp-text-2, #555)",marginTop:4,textAlign:"center"},children:s}):null]}),e1=({language:e,code:t})=>(0,T.jsx)(T.Fragment,{}),e2=({node:e,isOpen:t,onToggle:i,macros:s,renderNode:r})=>{let a=K(e.children);return(0,T.jsxs)("button",{onClick:i,className:" cursor-pointer w-full flex items-center justify-between px-4   font-semibold transition-colors",children:[(0,T.jsx)("div",{className:"flex-1 text-left",children:a.map((e,t)=>(0,T.jsx)(x.Fragment,{children:r?.(e,s)},t))}),(0,T.jsx)("svg",{className:"w-5 h-5 transform transition-transform ",style:{transform:t?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.3s ease"},width:20,height:20,fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24",children:(0,T.jsx)("path",{d:"M9 5l7 7-7 7"})})]})},e5={pdf:"pdf",doc:"word",docx:"word",ppt:"pptx",pptx:"pptx",jpg:"image",jpeg:"image",png:"image",gif:"image",webp:"image",svg:"image",bmp:"image"},e3=e=>{try{return e5[new URL(e,"https://x").pathname.split(".").pop()?.toLowerCase()??""]??"generic"}catch{return"generic"}},e4={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"
4currentColor",width:"20",height:"20"},e8={pdf:{icon:()=>(0,T.jsxs)("svg",{...e4,className:"shrink-0 text-red-500",children:[(0,T.jsx)("path",{d:"M5.625 1.5c-1.036 0-1.875.84-1.875 1.875v17.25c0 1.035.84 1.875 1.875 1.875h12.75c1.035 0 1.875-.84 1.875-1.875V12.75A3.75 3.75 0 0016.5 9h-1.875a1.875 1.875 0 01-1.875-1.875V5.25A3.75 3.75 0 009 1.5H5.625z"}),(0,T.jsx)("path",{d:"M12.971 1.816A5.23 5.23 0 0114.25 5.25v1.875c0 .207.168.375.375.375H16.5a5.23 5.23 0 013.434 1.279 9.768 9.768 0 00-6.963-6.963z"})]}),linkClass:"text-red-600 hover:text-red-700"},word:{icon:()=>(0,T.jsxs)("svg",{...e4,className:"shrink-0 text-blue-500",children:[(0,T.jsx)("path",{d:"M5.625 1.5c-1.036 0-1.875.84-1.875 1.875v17.25c0 1.035.84 1.875 1.875 1.875h12.75c1.035 0 1.875-.84 1.875-1.875V12.75A3.75 3.75 0 0016.5 9h-1.875a1.875 1.875 0 01-1.875-1.875V5.25A3.75 3.75 0 009 1.5H5.625z"}),(0,T.jsx)("path",{d:"M12.971 1.816A5.23 5.23 0 0114.25 5.25v1.875c0 .207.168.375.375.375H16.5a5.23 5.23 0 013.434 1.279 9.768 9.768 0 00-6.963-6.963z"}),(0,T.jsx)("text",{x:"7.5",y:"18",fontSize:"7",fontWeight:"bold",fill:"white",children:"W"})]}),linkClass:"text-blue-600 hover:text-blue-700"},pptx:{icon:()=>(0,T.jsxs)("svg",{...e4,className:"shrink-0 text-orange-500",children:[(0,T.jsx)("path",{d:"M5.625 1.5c-1.036 0-1.875.84-1.875 1.875v17.25c0 1.035.84 1.875 1.875 1.875h12.75c1.035 0 1.875-.84 1.875-1.875V12.75A3.75 3.75 0 0016.5 9h-1.875a1.875 1.875 0 01-1.875-1.875V5.25A3.75 3.75 0 009 1.5H5.625z"}),(0,T.jsx)("path",{d:"M12.971 1.816A5.23 5.23 0 0114.25 5.25v1.875c0 .207.168.375.375.375H16.5a5.23 5.23 0 013.434 1.279 9.768 9.768 0 00-6.963-6.963z"}),(0,T.jsx)("text",{x:"7.5",y:"18",fontSize:"7",fontWeight:"bold",fill:"white",children:"P"})]}),linkClass:"text-orange-600 hover:text-orange-700"},image:{icon:()=>(0,T.jsxs)("svg",{...e4,className:"shrink-0 text-purple-500",children:[(0,T.jsx)("path",{fillRule:"evenodd",d:"M1.5 6a2.25 2.25 0 012.25-2.25h16.5A2.25 2.25 0 0122.5 6v12a2.25 2.25 0 01-2.25 2.25H3.75A2.25 2.25 0 011.5 18V6zm2.25-.75a.75.75 0 00-.75.75v12c0 .414.336.75.75.75h16.5a.75.75 0 00.75-.75V6a.75.75 0 00-.75-.75H3.75z",clipRule:"evenodd"}),(0,T.jsx)("path",{fillRule:"evenodd",d:"M16.5 7.5a1.5 1.5 0 100 3 1.5 1.5 0 000-3z",clipRule:"evenodd"}),(0,T.jsx)("path",{d:"M1.875 18.75l4.688-4.688a1.125 1.125 0 011.59 0l3.372 3.375 2.25-2.25a1.125 1.125 0 011.59 0l5.01 5.01a.75.75 0 01-.53 1.28H3.75a.75.75 0 01-.75-.75v-.727l-1.125-1.25z"})]}),linkClass:"text-purple-600 hover:text-purple-700"},generic:{icon:()=>(0,T.jsxs)("svg",{...e4,className:"shrink-0 text-gray-500",children:[(0,T.jsx)("path",{d:"M5.625 1.5c-1.036 0-1.875.84-1.875 1.875v17.25c0 1.035.84 1.875 1.875 1.875h12.75c1.035 0 1.875-.84 1.875-1.875V12.75A3.75 3.75 0 0016.5 9h-1.875a1.875 1.875 0 01-1.875-1.875V5.25A3.75 3.75 0 009 1.5H5.625z"}),(0,T.jsx)("path",{d:"M12.971 1.816A5.23 5.23 0 0114.25 5.25v1.875c0 .207.168.375.375.375H16.5a5.23 5.23 0 013.434 1.279 9.768 9.768 0 00-6.963-6.963z"})]}),linkClass:"text-gray-600 hover:text-gray-700"}},e6=e=>e<=0?"":e<1024?`${e} B`:e<1048576?`${Math.round(e/1024)} KB`:e<0x40000000?`${(e/1048576).toFixed(1)} MB`:`${(e/0x40000000).toFixed(1)} GB`,e7=({item:e,showFileSize:t})=>{let i,{icon:s,linkClass:r}=e8[e3(e.url)],a=(i=[],t&&e.fileSize&&i.push(e6(e.fileSize)),e.pageCount&&i.push(`${e.pageCount} pag.`),e.width&&e.height&&i.push(`${e.width}\xd7${e.height}`),i.join(" · "));return(0,T.jsxs)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-3 rounded-lg border border-gray-200 dark:border-white/10 bg-white dark:bg-[#1e1e2e] px-5 py-3.5 shadow-sm no-underline transition-shadow hover:shadow-md ${r}`,children:[(0,T.jsx)(s,{}),(0,T.jsx)("span",{className:"text-base font-medium text-gray-900 dark:text-[#e5e7eb]",children:e.title}),a&&(0,T.jsxs)("span",{className:"ml-1 text-xs font-normal text-gray-400",children:["(",a,")"]})]})},e9=({items:e,showFileSize:t})=>(0,T.jsx)("div",{className:"my-4 flex w-full flex-col gap-2",children:e.map((e,i)=>(0,T.jsx)(e7,{item:e,showFileSize:t??!1},i))});var te=e.i(70703);(0,te.default)(()=>e.A(63687).then(e=>e.LexicalEquationView),{ssr:!1});let tt=(0,te.default)(()=>e.A(63687).then(e=>e.LexicalEquation),{ssr:!1}),ti="carousel",ts="controller",tr="portal",ta="toolbar",tn="captions",tl="loading",to="error",td="complete",th=e=>`active-slide-${e}`;th(tl),th("playing"),th(to),th(td);let tu="flex_center",tc="no_scroll_padding",tf="slide",tp="prev",tm="next",tg
4="swipe",ty="close",tv="onPointerDown",tb="onPointerMove",tE="onPointerUp",tS="onPointerLeave",tT="onPointerCancel",tx="onKeyDown",tk="onWheel",tw="icon",tA="contain",tR="cover";var tL=e.i(74080);let tC="yarl__";function tI(...e){return e.filter(Boolean).join(" ")}function tP(e){return`${tC}${e}`}function tD(e){return`--${tC}${e}`}function tM(e,t){return`${e}${t?`_${t}`:""}`}function t_(e){return t=>tM(e,t)}function t$(e,t){var i;return null!=(i=null==e?void 0:e[t])?i:t}function tO(...e){return()=>{e.forEach(e=>{e()})}}function tN(e,t,i){return()=>{let s=x.useContext(i);if(!s)throw Error(`${e} must be used within a ${t}.Provider`);return s}}function tF(){return"u">typeof window}function tB(e){return void 0===e.type||"image"===e.type}function tU(e){return"string"==typeof e?Number.parseInt(e,10):e}function tj(e){if("number"==typeof e)return{pixel:e};if("string"==typeof e){let t=tU(e);return e.endsWith("%")?{percent:t}:{pixel:t}}return{pixel:0}}function tV(e,t){return t>0?(e%t+t)%t:0}function tG(e,t){return e[tV(t,e.length)]}function tq(e,t){return e.length>0?tG(e,t):void 0}let tH=Number(x.version.split(".")[0])>=19,tK={open:!1,close:()=>{},index:0,slides:[],render:{},plugins:[],toolbar:{buttons:[ty]},labels:{},animation:{fade:250,swipe:500,easing:{fade:"ease",swipe:"ease-out",navigation:"ease-in-out"}},carousel:{finite:!1,preload:2,padding:"16px",spacing:"30%",imageFit:tA,imageProps:{}},controller:{ref:null,focus:!0,aria:!1,touchAction:"none",closeOnPullUp:!1,closeOnPullDown:!1,closeOnBackdropClick:!1,closeOnEscape:!0,preventDefaultWheelX:!0,preventDefaultWheelY:!1,disableSwipeNavigation:!1},portal:{},noScroll:{disabled:!1},on:{},styles:{},className:""};function tW(e,t){return{name:e,component:t}}function tz(e,t){return{module:e,children:t}}function tY(e,t,i){return e.flatMap(e=>{var s;return null!=(s=function e(t,i,s){return t.module.name===i?s(t):t.children?[tz(t.module,t.children.flatMap(t=>{var r;return null!=(r=e(t,i,s))?r:[]}))]:[t]}(e,t,i))?s:[]})}let tQ=x.createContext(null),tX=tN("useA11yContext","A11yContext",tQ);function tJ({children:e}){let[t,i]=x.useState(!1),[s,r]=x.useState(!1),a=x.useMemo(()=>({focusWithin:t,trackFocusWithin:(e,t)=>{let s=s=>r=>{var a;r.currentTarget.contains(r.relatedTarget)||i(s),null==(a=s?e:t)||a(r)};return{onFocus:s(!0),onBlur:s(!1)}},autoPlaying:s,setAutoPlaying:r}),[t,s]);return x.createElement(tQ.Provider,{value:a},e)}let tZ=x.createContext(null),t0=tN("useDocument","DocumentContext",tZ);function t1({nodeRef:e,children:t}){let i=x.useMemo(()=>{let t=t=>{var i;return(null==(i=t||e.current)?void 0:i.ownerDocument)||document};return{getOwnerDocument:t,getOwnerWindow:e=>{var i;return(null==(i=t(e))?void 0:i.defaultView)||window}}},[e]);return x.createElement(tZ.Provider,{value:i},t)}let t2=x.createContext(null),t5=tN("useEvents","EventsContext",t2);function t3({children:e}){let[t]=x.useState({});x.useEffect(()=>()=>{Object.keys(t).forEach(e=>delete t[e])},[t]);let i=x.useMemo(()=>{let e=(e,i)=>{var s;null==(s=t[e])||s.splice(0,t[e].length,...t[e].filter(e=>e!==i))};return{publish:(...[e,i])=>{var s;null==(s=t[e])||s.forEach(e=>e(i))},subscribe:(i,s)=>(t[i]||(t[i]=[]),t[i].push(s),()=>e(i,s)),unsubscribe:e}},[t]);return x.createElement(t2.Provider,{value:i},e)}let t4=x.createContext(null),t8=tN("useLightboxProps","LightboxPropsContext",t4);function t6({children:e,...t}){return x.createElement(t4.Provider,{value:t},e)}let t7=x.createContext(null),t9=tN("useLightboxState","LightboxStateContext",t7),ie=x.createContext(null),it=tN("useLightboxDispatch","LightboxDispatchContext",ie);function ii(e,t){switch(t.type){case"swipe":{let{slides:i}=e,s=(null==t?void 0:t.increment)||0,r=e.globalIndex+s,a=tV(r,i.length),n=tq(i,a);return{slides:i,currentIndex:a,globalIndex:r,currentSlide:n,animation:s||void 0!==t.duration?{increment:s,duration:t.duration,easing:t.easing}:void 0}}case"update":if(t.slides!==e.slides||t.index!==e.currentIndex)return{slides:t.slides,currentIndex:t.index,globalIndex:t.index,currentSlide:tq(t.slides,t.index)};return e;default:throw Error("Unknown action type")}}function is({slides:e,index:t,children:i}){let[s,r]=x.useReducer(ii,{slides:e,currentIndex:t,globalIndex:t,currentSlide:tq(e,t)}),[a,n]=x.useState(e),[l,o]=x.useState(t);(e!==a||t!==l)&&(n(e),o(t),r({type:"update",slides:e,index:t}));let d=x.useMemo(()=>({...s,state:s,dispatch:r}),[s,r]);return x.createElement(ie.Provider,{value:r},x.createElement(t7.Provider,{value:d},i))}
4let ir=x.createContext(null),ia=tN("useRTLContext","RTLContext",ir);function il({isRTL:e,children:t}){let i=x.useMemo(()=>({isRTL:e}),[e]);return x.createElement(ir.Provider,{value:i},t)}let io=x.createContext(null),id=tN("useTimeouts","TimeoutsContext",io);function ih({children:e}){let[t]=x.useState([]);x.useEffect(()=>()=>{t.forEach(e=>window.clearTimeout(e)),t.splice(0,t.length)},[t]);let i=x.useMemo(()=>{let e=e=>{t.splice(0,t.length,...t.filter(t=>t!==e))};return{setTimeout:(i,s)=>{let r=window.setTimeout(()=>{e(r),i()},s);return t.push(r),r},clearTimeout:t=>{void 0!==t&&(e(t),window.clearTimeout(t))}}},[t]);return x.createElement(io.Provider,{value:i},e)}let iu=x.forwardRef(function({label:e,className:t,icon:i,renderIcon:s,onClick:r,style:a,...n},l){let{styles:o,labels:d}=t8(),h=t$(d,e);return x.createElement("button",{ref:l,type:"button",title:h,"aria-label":h,className:tI(tP("button"),t),onClick:r,style:{...a,...o.button},...n},s?s():x.createElement(i,{className:tP(tw),style:o.icon}))});function ic(e,t){let i=e=>x.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"24",height:"24","aria-hidden":"true",focusable:"false",...e},t);return i.displayName=e,i}function ip(e,t){return ic(e,x.createElement("g",{fill:"currentColor"},x.createElement("path",{d:"M0 0h24v24H0z",fill:"none"}),t))}let im=ip("Close",x.createElement("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"})),ig=ip("Previous",x.createElement("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"})),iy=ip("Next",x.createElement("path",{d:"M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"})),iv=ip("Loading",x.createElement(x.Fragment,null,Array.from({length:8}).map((e,t,i)=>x.createElement("line",{key:t,x1:"12",y1:"6.5",x2:"12",y2:"1.8",strokeLinecap:"round",strokeWidth:"2.6",stroke:"currentColor",strokeOpacity:1/i.length*(t+1),transform:`rotate(${360/i.length*t}, 12, 12)`})))),ib=ip("Error",x.createElement("path",{d:"M21.9,21.9l-8.49-8.49l0,0L3.59,3.59l0,0L2.1,2.1L0.69,3.51L3,5.83V19c0,1.1,0.9,2,2,2h13.17l2.31,2.31L21.9,21.9z M5,18 l3.5-4.5l2.5,3.01L12.17,15l3,3H5z M21,18.17L5.83,3H19c1.1,0,2,0.9,2,2V18.17z"})),iE=tF()?x.useLayoutEffect:x.useEffect;function iS(){let[e,t]=x.useState(!1);return x.useEffect(()=>{var e,i;let s=null==(e=window.matchMedia)?void 0:e.call(window,"(prefers-reduced-motion: reduce)");t(null==s?void 0:s.matches);let r=e=>t(e.matches);return null==(i=null==s?void 0:s.addEventListener)||i.call(s,"change",r),()=>{var e;return null==(e=null==s?void 0:s.removeEventListener)?void 0:e.call(s,"change",r)}},[]),e}function iT(e,t){let i=x.useRef(void 0),s=x.useRef(void 0),r=iS();return iE(()=>{var a,n,l;if(e.current&&void 0!==i.current&&!r){let{keyframes:r,duration:o,easing:d,onfinish:h}=t(i.current,e.current.getBoundingClientRect(),function(e){let t=0,i=0,s=0,r=window.getComputedStyle(e).transform.match(/matrix.*\((.+)\)/);if(r){let e=r[1].split(",").map(tU);6===e.length?(t=e[4],i=e[5]):16===e.length&&(t=e[12],i=e[13],s=e[14])}return{x:t,y:i,z:s}}(e.current))||{};if(r&&o){null==(a=s.current)||a.cancel(),s.current=void 0;try{s.current=null==(l=(n=e.current).animate)?void 0:l.call(n,r,{duration:o,easing:d})}catch(e){console.error(e)}s.current&&(s.current.onfinish=()=>{s.current=void 0,null==h||h()})}}i.current=void 0}),{prepareAnimation:e=>{i.current=e},isAnimationPlaying:()=>{var e;return(null==(e=s.current)?void 0:e.playState)==="running"}}}function ix(){let e=x.useRef(null),t=x.useRef(void 0),[i,s]=x.useState();return{setContainerRef:x.useCallback(i=>{e.current=i,t.current&&(t.current.disconnect(),t.current=void 0);let r=()=>{if(i){let e=window.getComputedStyle(i);s({width:Math.round(i.clientWidth-(parseFloat(e.paddingLeft)||0)-(parseFloat(e.paddingRight)||0)),height:Math.round(i.clientHeight-(parseFloat(e.paddingTop)||0)-(parseFloat(e.paddingBottom)||0))})}else s(void 0)};r(),i&&"u">typeof ResizeObserver&&(t.current=new ResizeObserver(r),t.current.observe(i))},[]),containerRef:e,containerRect:i}}function ik(){let e=x.useRef(void 0),{setTimeout:t,clearTimeout:i}=id();return x.useCallback((s,r)=>{i(e.current),e.current=t(s,r>0?r:0)},[t,i])}function iw(e){let t=x.useRef(e);return iE(()=>{t.current=e}),x.useCallback((...e)=>{var i;return null==(i=t.current)?void 0:i.call(t,...e)},[])}function iA(e,t){"function"==typeof e?e(t):e&&(e.current=t)}function iR(e,t){return x.useMemo(()=>null==e&&null==t?null:i=>{iA(e,i),iA(t,i)},[e,t])}function iL(){return ia().isRTL}function iC(e,t){let i=x.useRef(0),s=ik(),r=iw((...t)=>{i.current=Date.now(),e(t)});return x.useCallback((...e)=>
4{s(()=>{r(e)},t-(Date.now()-i.current))},[t,r,s])}let iI=t_("slide"),iP=t_("slide_image");function iD({slide:e,offset:t,render:i,rect:s,imageFit:r,imageProps:a,onClick:n,onLoad:l,onError:o,style:d}){var h,u,c,f,p,m,g,y;let[v,b]=x.useState(tl),{publish:E}=t5(),{setTimeout:S}=id(),T=x.useRef(null);x.useEffect(()=>{0===t&&E(th(v))},[t,v,E]);let k=iw(e=>{("decode"in e?e.decode():Promise.resolve()).catch(()=>{}).then(()=>{e.parentNode&&(b(td),S(()=>{null==l||l(e)},0))})}),w=x.useCallback(e=>{T.current=e,(null==e?void 0:e.complete)&&k(e)},[k]),A=x.useCallback(e=>{k(e.currentTarget)},[k]),R=iw(()=>{b(to),null==o||o()}),L=e.imageFit===tR||e.imageFit!==tA&&r===tR,C=(e,t)=>Number.isFinite(e)?e:t,I=C(Math.max(...(null!=(u=null==(h=e.srcSet)?void 0:h.map(e=>e.width))?u:[]).concat(e.width?[e.width]:[]).filter(Boolean)),(null==(c=T.current)?void 0:c.naturalWidth)||0),P=C(Math.max(...(null!=(p=null==(f=e.srcSet)?void 0:f.map(e=>e.height))?p:[]).concat(e.height?[e.height]:[]).filter(Boolean)),(null==(m=T.current)?void 0:m.naturalHeight)||0),D=I&&P?{maxWidth:`min(${I}px, 100%)`,maxHeight:`min(${P}px, 100%)`}:{maxWidth:"100%",maxHeight:"100%"},M=null==(g=e.srcSet)?void 0:g.slice().sort((e,t)=>e.width-t.width).map(e=>`${e.src}
4 ${e.width}w`).join(", "),_=M&&s&&tF()?`${Math.round(Math.min(s&&!L&&e.width&&e.height?s.height/e.height*e.width:Number.MAX_VALUE,s.width))}px`:void 0,{style:$,className:O,...N}=("function"==typeof a?a(e):a)||{};return x.createElement(x.Fragment,null,x.createElement("img",{ref:w,onLoad:A,onError:R,onClick:n,draggable:!1,className:tI(tP(iP()),L&&tP(iP("cover")),v!==td&&tP(iP("loading")),O),style:{...D,...d,...$},...N,alt:null!=(y=e.alt)?y:"",sizes:_,srcSet:M,src:e.src}),v!==td&&x.createElement("div",{className:tP(iI("placeholder"))},v===tl&&((null==i?void 0:i.iconLoading)?i.iconLoading():x.createElement(iv,{className:tI(tP(tw),tP(iI(tl)))})),v===to&&((null==i?void 0:i.iconError)?i.iconError():x.createElement(ib,{className:tI(tP(tw),tP(iI(to)))}))))}let iM=x.forwardRef(function({className:e,children:t,onFocus:i,onBlur:s,...r},a){let n=x.useRef(null),[l,o]=x.useState(!1),{trackFocusWithin:d}=tX(),h=iw(()=>{if(n.current){let e="rtl"===window.getComputedStyle(n.current).direction;e!==l&&o(e)}});return x.useEffect(h),x.createElement(t1,{nodeRef:n},x.createElement(il,{isRTL:l},x.createElement("div",{ref:iR(a,n),className:tI(tP("root"),e),...d(i,s),...r},t)))});(o=v||(v={}))[o.NONE=0]="NONE",o[o.SWIPE=1]="SWIPE",o[o.PULL=2]="PULL",o[o.ANIMATION=3]="ANIMATION",(d=b||(b={}))[d.NONE=0]="NONE",d[d.SWIPE=1]="SWIPE",d[d.PULL=2]="PULL";let i_=t_("container"),i$=x.createContext(null),iO=tN("useController","ControllerContext",i$),iN=tW(ts,function({children:e,...t}){var i;let{carousel:s,animation:r,controller:a,on:n,styles:l,render:o}=t,{closeOnPullUp:d,closeOnPullDown:h,preventDefaultWheelX:u,preventDefaultWheelY:c}=a,[f,p]=x.useState(),m=t9(),g=it(),[y,E]=x.useState(v.NONE),S=x.useRef(0),T=x.useRef(0),k=x.useRef(1),{registerSensors:w,subscribeSensors:A}=function(){let[e]=x.useState({}),t=x.useCallback((t,i)=>{var s;null==(s=e[t])||s.forEach(e=>{i.isPropagationStopped()||e(i)})},[e]);return{registerSensors:x.useMemo(()=>({onPointerDown:e=>t(tv,e),onPointerMove:e=>t(tb,e),onPointerUp:e=>t(tE,e),onPointerLeave:e=>t(tS,e),onPointerCancel:e=>t(tT,e),onKeyDown:e=>t(tx,e),onKeyUp:e=>t("onKeyUp",e),onWheel:e=>t(tk,e)}),[t]),subscribeSensors:x.useCallback((t,i)=>(e[t]||(e[t]=[]),e[t].unshift(i),()=>{let s=e[t];s&&s.splice(0,s.length,...s.filter(e=>e!==i))}),[e])}}(),{subscribe:R,publish:L}=t5(),C=ik(),I=ik(),P=ik(),{containerRef:D,setContainerRef:M,containerRect:_}=ix(),$=iR(function({preventDefaultWheelX:e,preventDefaultWheelY:t}){let i=x.useRef(null),s=iw(i=>{let s=Math.abs(i.deltaX)>Math.abs(i.deltaY);(s&&e||!s&&t||i.ctrlKey)&&i.preventDefault()});return x.useCallback(e=>{var t;e?e.addEventListener("wheel",s,{passive:!1}):null==(t=i.current)||t.removeEventListener("wheel",s),i.current=e},[s])}({preventDefaultWheelX:u,preventDefaultWheelY:c}),M),O=x.useRef(null),N=iR(O,void 0),{getOwnerDocument:F}=t0(),B=iL(),U=e=>(B?-1:1)*("number"==typeof e?e:1),j=iw(()=>{var e;return null==(e=D.current)?void 0:e.focus()}),V=iw(()=>t),G=iw(()=>m),q=x.useCallback(e=>L(tp,e),[L]),H=x.useCallback(e=>L(tm,e),[L]),K=x.useCallback(()=>L(ty),[L]),W=e=>!(s.finite&&(U(e)>0&&0===m.currentIndex||0>U(e)&&m.currentIndex===m.slides.length-1)),z=e=>{var t;S.current=e,null==(t=D.current)||t.style.setProperty(tD("swipe_offset"),`${Math.round(e)}px`)},Y=e=>{var t,i;T.current=e,k.current=Math.min(Math.max(function(e,t=0){let i=10**t;return Math.round((e+Number.EPSILON)*i)/i}(1-(h&&e>0?e:d&&e<0?-e:0)/60*.5,2),.5),1),null==(t=D.current)||t.style.setProperty(tD("pull_offset"),`${Math.round(e)}px`),null==(i=D.current)||i.style.setProperty(tD("pull_opacity"),`${k.current}`)},{prepareAnimation:Q}=iT(O,(e,t,i)=>{if(O.current&&_)return{keyframes:[{transform:`translate(0, ${e.rect.y-t.y+i.y}px)`,opacity:e.opacity},{transform:"translate(0, 0)",opacity:1}],duration:e.duration,easing:r.easing.fade}}),X=(e,t)=>{if(d||h){Y(e);let i=0;O.current&&(i=r.fade*(t?2:1),Q({rect:O.current.getBoundingClientRect(),opacity:k.current,duration:i})),P(()=>{Y(0),E(v.NONE)},i),E(v.ANIMATION),t||K()}},{prepareAnimation:J,isAnimationPlaying:Z}=iT(O,(e,t,i)=>{var r;if(O.current&&_&&(null==(r=m.animation)?void 0:r.duration)){let r=tj(s.spacing),a=(r.percent?r.percent*_.width/100:r.pixel)||0;return{keyframes:[{transform:`translate(${U(m.globalIndex-e.index)*(_.width+a)+e.rect.x-t.x+i.x}
4px, 0)`},{transform:"translate(0, 0)"}],duration:m.animation.duration,easing:m.animation.easing}}}),ee=iw(e=>{var t,i;let s=e.offset||0,a=s?r.swipe:null!=(t=r.navigation)?t:r.swipe,n=s||Z()?r.easing.swipe:r.easing.navigation,{direction:l}=e,o=null!=(i=e.count)?i:1,d=v.ANIMATION,h=a*o;if(!l){let t=null==_?void 0:_.width,i=e.duration||0,r=t?a/t*Math.abs(s):a;0!==o?(i<r?h=h/r*Math.max(i,r/5):t&&(h=a/t*(t-Math.abs(s))),l=U(s)>0?tp:tm):h=a/2}let u=0;l===tp?W(U(1))?u=-o:(d=v.NONE,h=a):l===tm&&(W(U(-1))?u=o:(d=v.NONE,h=a)),I(()=>{z(0),E(v.NONE)},h=Math.round(h)),O.current&&J({rect:O.current.getBoundingClientRect(),index:m.globalIndex}),E(d),L(tg,{type:"swipe",increment:u,duration:h,easing:n})});x.useEffect(()=>{var e,t;(null==(e=m.animation)?void 0:e.increment)&&(null==(t=m.animation)?void 0:t.duration)&&C(()=>g({type:"swipe",increment:0}),m.animation.duration)},[m.animation,g,C]);let et=[A,W,(null==_?void 0:_.width)||0,r.swipe,()=>E(v.SWIPE),e=>z(e),(e,t)=>ee({offset:e,duration:t,count:1}),e=>ee({offset:e,count:0})],ei=[()=>{h&&E(v.PULL)},e=>Y(e),e=>X(e),e=>X(e,!0)];!function({disableSwipeNavigation:e,closeOnBackdropClick:t},i,s,r,a,n,l,o,d,h,u,c,f,p,m,g){let y=x.useRef(0),v=x.useRef([]),E=x.useRef(void 0),S=x.useRef(0),T=x.useRef(b.NONE),k=x.useCallback(e=>{E.current===e.pointerId&&(E.current=void 0,T.current=b.NONE);let t=v.current;t.splice(0,t.length,...t.filter(t=>t.pointerId!==e.pointerId))},[]),w=x.useCallback(e=>{k(e),e.persist(),v.current.push(e)},[k]),A=x.useCallback(e=>v.current.find(({pointerId:t})=>e.pointerId===t),[]),R=iw(e=>{w(e)}),L=(e,t)=>u&&e>t||h&&e<-t,C=iw(e=>{let i=A(e);if(i)if(E.current===e.pointerId){let e=Date.now()-S.current,t=y.current;T.current===b.SWIPE?Math.abs(t)>.3*r||Math.abs(t)>5&&e<a?o(t,e):d(t):T.current===b.PULL&&(L(t,60)?p(t,e):m(t)),y.current=0,T.current=b.NONE}else{let{target:s}=e;t&&s instanceof HTMLElement&&s===i.target&&(s.classList.contains(tP(tf))||s.classList.contains(tP("slide_wrapper")))&&g()}k(e)}),I=iw(t=>{let i=A(t);if(i){let r=E.current===t.pointerId;if(0===t.buttons)return void(r&&0!==y.current?C(t):k(i));let a=t.clientX-i.clientX,o=t.clientY-i.clientY;if(void 0===E.current){let i=e=>{w(t),E.current=t.pointerId,S.current=Date.now(),T.current=e};Math.abs(a)>Math.abs(o)&&Math.abs(a)>30&&s(a)?e||(i(b.SWIPE),n()):Math.abs(o)>Math.abs(a)&&L(o,30)&&(i(b.PULL),c())}else r&&(T.current===b.SWIPE?(y.current=a,l(a)):T.current===b.PULL&&(y.current=o,f(o)))}});x.useEffect(()=>tO(i(tv,R),i(tb,I),i(tE,C),i(tS,C),i(tT,C)),[i,R,I,C,void 0])}(a,...et,d,h,...ei,K),function(e,t,i,s,r,a,n,l,o){let d=x.useRef(0),h=x.useRef(0),u=x.useRef(void 0),c=x.useRef(void 0),f=x.useRef(0),p=x.useRef(void 0),m=x.useRef(0),{setTimeout:g,clearTimeout:y}=id(),b=x.useCallback(()=>{u.current&&(y(u.current),u.current=void 0)},[y]),E=x.useCallback(()=>{c.current&&(y(c.current),c.current=void 0)},[y]),S=iw(()=>{e!==v.SWIPE&&(d.current=0,m.current=0,b(),E())});x.useEffect(S,[e,S]);let T=iw(e=>{c.current=void 0,d.current===e&&o(d.current)}),k=iw(t=>{if(t.ctrlKey||Math.abs(t.deltaY)>Math.abs(t.deltaX))return;let o=e=>{f.current=e,y(p.current),p.current=e>0?g(()=>{f.current=0,p.current=void 0},300):void 0};if(e===v.NONE){if(Math.abs(t.deltaX)<=1.2*Math.abs(f.current))return void o(t.deltaX);if(!i(-t.deltaX))return;if(h.current+=t.deltaX,b(),Math.abs(h.current)>30)h.current=0,o(0),m.current=Date.now(),a();else{let e=h.current;u.current=g(()=>{u.current=void 0,e===h.current&&(h.current=0)},r)}}else if(e===v.SWIPE){let e=d.current-t.deltaX;if(d.current=e=Math.min(Math.abs(e),s)*Math.sign(e),n(e),E(),Math.abs(e)>.2*s){o(t.deltaX),l(e,Date.now()-m.current);return}c.current=g(()=>T(e),2*r)}else o(t.deltaX)});x.useEffect(()=>t(tk,k),[t,k])}(y,...et);let es=iw(()=>{a.focus&&F().querySelector(`.${tP(tr)} .${tP(i_())}`)&&j()});x.useEffect(es,[es]);let er=iw(()=>{var e;null==(e=n.view)||e.call(n,{index:m.currentIndex})});x.useEffect(er,[m.globalIndex,er]),x.useEffect(()=>tO(R(tp,e=>ee({direction:tp,...e})),R(tm,e=>ee({direction:tm,...e})),R(tg,e=>g(e))),[R,ee,g]);let ea=x.useMemo(()=>{let e,t;return{prev:q,next:H,close:K,focus:j,slideRect:_?(t=void 0!==(e=tj(s.padding)).percent?_.width/100*e.percent:e.pixel,{width:Math.max(_.width-2*t,0),height:Math.max(_.height-2*t,0)}):{width:0,height:0},containerRect:_||{width:0,height:0},subscribeSensors:A,containerRef:D,setCarouselRef:N,toolbarWidth:f,setToolbarWidth:p}},[q,H,K,j,A,_,D,N,f,p,s.padding]);return x.useImperativeHandle(a.ref,()=>({prev:q,next:H,close:K,focus:j,getLightboxProps:V,getLightboxState:G}),[q,H,K,j,V,G]),x.createElement("div",{ref:$,className:tI(tP(i_()),tP(tu)),style:{...y===v.SWIPE?{[tD("swipe_offset")]:`${Math.round(S.current)}px`}:null,...y===v.PULL?{[tD("pull_offset")]:`${Math.round(T.current)}px`,[tD("pull_opacity")]:`${k.current}`}:null,..."none"!==a.touchAction?{[tD("controller_touch_action")]:a.touchAction}:null,...l.container},tabIndex:-1,...w},_&&x.createElement(i$.Provider,{value:ea},e,null==(i=o.controls)?void 0:i.call(o)))});function iF({slide:e,offset:t}){var i,s,r,a,n;let l,o=x.useRef(null),{currentIndex:d,slides:h}=t9(),{slideRect:u,focus:c}=iO(),{render:f,carousel:{imageFit:p,imageProps:m},on:{click:g},styles:{slide:y},labels:v}=t8(),{getOwnerDocument:b}=t0(),E=0!==t;return x.useEffect(()=>{var e;E&&(null==(e=o.current)?void 0:e.contains(b().activeElement))&&c()},[E,c,b]),x.createElement("div",{ref:o,className:tI(tP(tM(tf,void 0)),!E&&tP(tM(tf,"current")),tP(tu)),...{inert:tH?E:E?"":void 0},style:y,role:"group","aria-roledescription":t$(v,"Slide"),"aria-label":(i=d+t,t$(v,"{index} of {total}").replace(/\{index}/g,`${tV(i,h.length)+1}`).replace(/\{total}/g,`${h.length}`))},(!(l=null==(s=f.slide)?void 0:s.call(f,{slide:e,offset:t,rect:u}))&&tB(e)&&(l=x.createElement(iD,{slide:e,offset:t,render:f,rect:u,imageFit:p,imageProps:m,onClick:E?void 0:()=>null==g?void 0:g({index:d})})),l?x.createElement(x.Fragment,null,null==(r=f.slideHeader)?void 0:r.call(f,{slide:e}),(null!=(a=f.slideContainer)?a:({children:e})=>e)({slide:e,children:l}),null==(n=f.slideFooter)?void 0:n.call(f,{slide:e})):null))}function iB(){let e=t8().styles.slide;return x.createElement("div",{className:tP(tf),style:e})}let iU=tW(ti,function({carousel:e,labels:t}){let{slides:i,currentIndex:s,globalIndex:r}=t9(),{setCarouselRef:a}=iO(),{autoPlaying:n,focusWithin:l}=tX(),o=tj(e.spacing),d=tj(e.padding),h=function(e,t,i=0){return Math.min(e.preload,Math.max(e.finite?t.length-1:Math.floor(t.length/2),i))}(e,i,1),u=[];
4if(i.length>0)for(let t=s-h;t<=s+h;t+=1){let a=tG(i,t),n=r-s+t,l=e.finite&&(t<0||t>i.length-1);u.push(l?{key:n}:{key:[`${n}`,tB(a)?a.src:void 0].filter(Boolean).join("|"),offset:t-s,slide:a})}return x.createElement("div",{ref:a,className:tI(tP(tM(ti,void 0)),u.length>0&&tP(tM(ti,"with_slides"))),style:{[`${tD(tM(ti,"slides_count"))}`]:u.length,[`${tD(tM(ti,"spacing_px"))}`]:o.pixel||0,[`${tD(tM(ti,"spacing_percent"))}`]:o.percent||0,[`${tD(tM(ti,"padding_px"))}`]:d.pixel||0,[`${tD(tM(ti,"padding_percent"))}`]:d.percent||0},role:"region","aria-live":n&&!l?"off":"polite","aria-roledescription":t$(t,"Carousel"),"aria-label":t$(t,"Photo gallery")},u.map(({key:e,slide:t,offset:i})=>t?x.createElement(iF,{key:e,slide:t,offset:i}):x.createElement(iB,{key:e})))});function ij(){let{carousel:e}=t8(),{slides:t,currentIndex:i}=t9();return{prevDisabled:0===t.length||e.finite&&0===i,nextDisabled:0===t.length||e.finite&&i===t.length-1}}function iV({label:e,icon:t,renderIcon:i,action:s,onClick:r,disabled:a,style:n}){return x.createElement(iu,{label:e,icon:t,renderIcon:i,className:tP(`navigation_${s}`),disabled:a,onClick:r,style:n,...function(e,t=!1){let i=x.useRef(!1);return iE(()=>{t&&i.current&&(i.current=!1,e())},[t,e]),{onFocus:x.useCallback(()=>{i.current=!0},[]),onBlur:x.useCallback(()=>{i.current=!1},[])}}(iO().focus,a)})}let iG=tW("navigation",function({render:{buttonPrev:e,buttonNext:t,iconPrev:i,iconNext:s},styles:r}){let{prev:a,next:n,subscribeSensors:l}=iO(),{prevDisabled:o,nextDisabled:d}=ij();return!function(e){var t;let i=iL(),{publish:s}=t5(),{animation:r,controller:a}=t8(),{prevDisabled:n,nextDisabled:l}=ij(),o=(null!=(t=r.navigation)?t:r.swipe)/2,d=iC(()=>s(tp),o),h=iC(()=>s(tm),o),u=iw(e=>{switch(e.key){case"Escape":if(!a.closeOnEscape)return;s(ty);break;case"ArrowLeft":(i?l:n)||(i?h:d)();break;case"ArrowRight":(i?n:l)||(i?d:h)();break;default:return}e.stopPropagation()});x.useEffect(()=>e(tx,u),[e,u])}(l),x.createElement(x.Fragment,null,e?e():x.createElement(iV,{label:"Previous",action:tp,icon:ig,renderIcon:i,style:r.navigationPrev,disabled:o,onClick:a}),t?t():x.createElement(iV,{label:"Next",action:tm,icon:iy,renderIcon:s,style:r.navigationNext,disabled:d,onClick:n}))}),iq=tP("no_scroll"),iH=tP(tc);function iK(e,t,i){let s=window.getComputedStyle(e),r=i?"padding-left":"padding-right",a=i?s.paddingLeft:s.paddingRight,n=e.style.getPropertyValue(r);return e.style.setProperty(r,`${(tU(a)||0)+t}px`),()=>{n?e.style.setProperty(r,n):e.style.removeProperty(r)}}let iW=tW("no-scroll",function({noScroll:{disabled:e},children:t}){let i=iL(),{getOwnerDocument:s,getOwnerWindow:r}=t0();return x.useEffect(()=>{if(e)return()=>{};let t=[],a=r(),{body:n,documentElement:l}=s(),o=Math.round(a.innerWidth-l.clientWidth);if(o>0){t.push(iK(n,o,i));let e=n.getElementsByTagName("*");for(let s=0;s<e.length;s+=1){let r=e[s];"style"in r&&"fixed"===a.getComputedStyle(r).getPropertyValue("position")&&!r.classList.contains(iH)&&t.push(iK(r,o,i))}}return n.classList.add(iq),()=>{n.classList.remove(iq),t.forEach(e=>e())}},[i,e,s,r]),x.createElement(x.Fragment,null,t)});function iz(e,t,i){let s=e.getAttribute(t);return e.setAttribute(t,i),()=>{s?e.setAttribute(t,s):e.removeAttribute(t)}}let iY=tW(tr,function({portal:{root:e,container:{className:t,style:i,...s}={}},animation:r,styles:a,className:n,on:l,close:o,labels:d,children:h}){let[u,c]=x.useState(!1),[f,p]=x.useState(!1),m=x.useRef([]),g=x.useRef(null),{setTimeout:y}=id(),{subscribe:v}=t5(),b=iS()?0:r.fade;x.useEffect(()=>(c(!0),()=>{c(!1),p(!1)}),[]);let E=iw(()=>{m.current.forEach(e=>e()),m.current=[]}),S=iw(()=>{var e;p(!1),E(),null==(e=l.exiting)||e.call(l),y(()=>{var e;null==(e=l.exited)||e.call(l),o()},b)});x.useEffect(()=>v(ty,S),[v,S]);let T=iw(e=>{var t,i,s;e.scrollTop,p(!0),null==(t=l.entering)||t.call(l);let r=null!=(s=null==(i=e.parentNode)?void 0:i.children)?s:[];for(let t=0;t<r.length;t+=1){let i=r[t];-1===["TEMPLATE","SCRIPT","STYLE"].indexOf(i.tagName)&&i!==e&&(m.current.push(iz(i,"inert","")),m.current.push(iz(i,"aria-hidden","true")))}m.current.push(()=>{var e,t;null==(t=null==(e=g.current)?void 0:e.focus)||t.call(e)}),y(()=>{var e;null==(e=l.entered)||e.call(l)},b)}),k=x.useCallback(e=>{e?T(e):E()},[T,E]);return u?(0,tL.createPortal)(x.createElement(iM,{ref:k,className:tI(n,t,tP(tM(tr,void 0)),tP(tc),f&&tP(tM(tr,"open"))),"aria-modal":!0,role:"dialog","aria-label":t$(d,"Lightbox"),style:{...r.fade!==tK.animation.fade?{[tD("fade_animation_duration")]:`${b}ms`}:null,...r.easing.fade!==tK.animation.easing.fade?{[tD("fade_animation_timing_function")]:r.easing.fade}:null,...a.root,...i},onFocus:e=>{g.current||(g.current=e.relatedTarget)},...s},h),("function"==typeof e?e():e)||document.body):null}),iQ=tW("root",function({children:e}){return x.createElement(x.Fragment,null,e)}),iX=tW(ta,function({toolbar:{buttons:e},render:{buttonClose:t,iconClose:i},styles:s}){let{close:r,setToolbarWidth:a}=iO(),{setContainerRef:n,containerRect:l}=ix();return iE(()=>{a(null==l?void 0:l.width)},[a,null==l?void 0:l.width]),x.createElement("div",{ref:n,style:s.toolbar,className:tP(tM(ta,void 0))},null==e?void 0:e.map(e=>e===ty?t?t():x.createElement(iu,{key:ty,label:"Close",icon:im,renderIcon:i,onClick:r}):e))});function iJ({carousel:e,animation:t,render:i,toolbar:s,controller:r,
4noScroll:a,on:n,plugins:l,slides:o,index:d,...h}){let{animation:u,carousel:c,render:f,toolbar:p,controller:m,noScroll:g,on:y,slides:v,index:b,plugins:E,...S}=tK,{config:T,augmentation:k}=function(e,t=[],i=[]){let s=e,r=e=>{let t=[...s];for(;t.length>0;){let i=t.pop();if((null==i?void 0:i.module.name)===e)return!0;(null==i?void 0:i.children)&&t.push(...i.children)}return!1},a=(e,t)=>{if(""===e){s=[tz(t,s)];return}s=tY(s,e,e=>[tz(t,[e])])},n=(e,t)=>{s=tY(s,e,e=>[tz(e.module,[tz(t,e.children)])])},l=(e,t,i)=>{s=tY(s,e,e=>{var s;return[tz(e.module,[...i?[tz(t)]:[],...null!=(s=e.children)?s:[],...i?[]:[tz(t)]])]})},o=(e,t,i)=>{s=tY(s,e,e=>[...i?[tz(t)]:[],e,...i?[]:[tz(t)]])},d=e=>{n(ts,e)},h=(e,t)=>{s=tY(s,e,e=>[tz(t,e.children)])},u=e=>{s=tY(s,e,e=>e.children)},c=e=>{i.push(e)};return t.forEach(e=>{e({contains:r,addParent:a,append:n,addChild:l,addSibling:o,addModule:d,replace:h,remove:u,augment:c})}),{config:s,augmentation:e=>i.reduce((e,t)=>t(e),e)}}([tz(iY,[tz(iW,[tz(iN,[tz(iU),tz(iX),tz(iG)])])])],l||E),w=k({animation:function(e,t={}){let{easing:i,...s}=e,{easing:r,...a}=t;return{easing:{...i,...r},...s,...a}}(u,t),carousel:{...c,...e},render:{...f,...i},toolbar:{...p,...s},controller:{...m,...r},noScroll:{...g,...a},on:{...y,...n},...S,...h});return w.open?x.createElement(t6,{...w},x.createElement(is,{slides:o||v,index:tU(d||b)},x.createElement(ih,null,x.createElement(t3,null,x.createElement(tJ,null,function e(t,i){var s;return x.createElement(t.module.component,{key:t.module.name,...i},null==(s=t.children)?void 0:s.map(t=>e(t,i)))}(tz(iQ,T),w)))))):null}let iZ=e=>tP(`slide_${e}`),i0={descriptionTextAlign:"start",descriptionMaxLines:3,showToggle:!1,hidden:!1},i1=e=>({...i0,...e}),i2=x.createContext(null),i5=tN("useCaptions","CaptionsContext",i2);function i3({captions:e,children:t}){let{ref:i,hidden:s}=i1(e),[r,a]=x.useState(!s),n=x.useMemo(()=>({visible:r,show:()=>a(!0),hide:()=>a(!1)}),[r]);return x.useImperativeHandle(i,()=>n,[n]),x.createElement(i2.Provider,{value:n},t)}function i4({title:e}){let{toolbarWidth:t}=iO(),{styles:i}=t8(),{visible:s}=i5();return s?x.createElement("div",{role:"heading","aria-level":2,style:i.captionsTitleContainer,className:tI(iZ("captions_container"),iZ("title_container"))},x.createElement("div",{className:iZ("title"),style:{...t?{[tD("toolbar_width")]:`${t}px`}:null,...i.captionsTitle}},e)):null}function i8({description:e}){let{descriptionTextAlign:t,descriptionMaxLines:i}=function(){let{captions:e}=t8();return i1(e)}(),{styles:s,labels:r}=t8(),{visible:a}=i5();return a?x.createElement("div",{style:s.captionsDescriptionContainer,className:tI(iZ("captions_container"),iZ("description_container"))},x.createElement("div",{className:iZ("description"),style:{...t!==i0.descriptionTextAlign||i!==i0.descriptionMaxLines?{[tD("slide_description_text_align")]:t,[tD("slide_description_max_lines")]:i}:null,...s.captionsDescription},role:"paragraph","aria-roledescription":t$(r,"Caption")},"string"==typeof e?e.split("\n").flatMap((e,t)=>[...t>0?[x.createElement("br",{key:t})]:[],e]):e)):null}let i6=()=>x.createElement(x.Fragment,null,x.createElement("path",{strokeWidth:2,stroke:"currentColor",strokeLinejoin:"round",fill:"none",d:"M3 5l18 0l0 14l-18 0l0-14z"}),x.createElement("path",{d:"M7 15h3c.55 0 1-.45 1-1v-1H9.5v.5h-2v-3h2v.5H11v-1c0-.55-.45-1-1-1H7c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1zm7 0h3c.55 0 1-.45 1-1v-1h-1.5v.5h-2v-3h2v.5H18v-1c0-.55-.45-1-1-1h-3c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1z"})),i7=ip("CaptionsVisible",i6()),i9=(h=i6(),ic("CaptionsVisible",x.createElement(x.Fragment,null,x.createElement("defs",null,x.createElement("mask",{id:"strike"},x.createElement("path",{d:"M0 0h24v24H0z",fill:"white"}),x.createElement("path",{d:"M0 0L24 24",stroke:"black",strokeWidth:4}))),x.createElement("path",{d:"M0.70707 2.121320L21.878680 23.292883",stroke:"currentColor",strokeWidth:2}),x.createElement("g",{fill:"currentColor",mask:"url(#strike)"},x.createElement("path",{d:"M0 0h24v24H0z",fill:"none"}),h))));function se(){let{visible:e,show:t,hide:i}=i5(),{render:s}=t8();return s.buttonCaptions?x.createElement(x.Fragment,null,s.buttonCaptions({visible:e,show:t,hide:i})):x.createElement(iu,{label:e?"Hide captions":"Show captions",icon:e?i7:i9,renderIcon:e?s.iconCaptionsVisible:s.iconCaptions
4Hidden,onClick:e?i:t})}function st({augment:e,addModule:t}){e(({captions:e,render:{slideFooter:t,...i},toolbar:s,...r})=>{let a=i1(e);return{render:{slideFooter:({slide:e})=>x.createElement(x.Fragment,null,null==t?void 0:t({slide:e}),e.title&&x.createElement(i4,{title:e.title}),e.description&&x.createElement(i8,{description:e.description})),...i},toolbar:function(e,t,i){if(!i)return e;let{buttons:s,...r}=e,a=s.findIndex(e=>e===t),n=x.isValidElement(i)?x.cloneElement(i,{key:t},null):i;if(a>=0){let e=[...s];return e.splice(a,1,n),{buttons:e,...r}}return{buttons:[n,...s],...r}}(s,tn,a.showToggle?x.createElement(se,null):null),captions:a,...r}}),t(tW(tn,i3))}let si={download:"Download",lightbox:"Visualizar",link:"Abrir link",none:""},ss={success:{bg:"var(--dp-success-bg, #f0fdf4)",color:"#16a34a"},warning:{bg:"var(--dp-amber-bg, #fffbeb)",color:"#d97706"},error:{bg:"var(--dp-danger-bg, #fef2f2)",color:"#dc2626"},info:{bg:"var(--dp-info-bg, #eff6ff)",color:"#2563eb"}},sr={thumbPosition:"left",thumbLayout:"top",showTypeBadge:!1,showFileSize:!1,showDownloadAction:!0,captionPosition:"below"},sa="3 / 4",sn=(e,t)=>t?{...e,...t}:e,sl=(e,t)=>{let i=document.createElement("a");i.href=e,i.download=t||"arquivo",i.target="_blank",i.rel="noopener noreferrer",document.body.appendChild(i),i.click(),document.body.removeChild(i)},so=({text:e})=>(0,T.jsx)("div",{style:{marginTop:4,fontSize:13,color:"var(--dp-text-2, #6b7280)",lineHeight:1.4,display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical",overflow:"hidden",textOverflow:"ellipsis"},children:e}),sd={success:{main:"#2e7d32",dark:"#1b5e20",contrastText:"#fff"},warning:{main:"#ed6c02",dark:"#c75e00",contrastText:"#fff"},error:{main:"#d32f2f",dark:"#c62828",contrastText:"#fff"},info:{main:"#0288d1",dark:"#01579b",contrastText:"#fff"}},sh=(e,t)=>{let i,s,[r,a,n]=[parseInt((s=3===(i=e.replace("#","")).length?i.split("").map(e=>e+e).join(""):i).slice(0,2),16),parseInt(s.slice(2,4),16),parseInt(s.slice(4,6),16)];return`rgba(${r}, ${a}, ${n}, ${t})`},su=({label:e,href:t,target:i,rel:s,onClick:r,variant:a="outlined",color:n="info"})=>{let[l,o]=(0,x.useState)(!1),[d,h]=(0,x.useState)(!1),u=sd[n],c="transparent",f="transparent",p=u.main;"contained"===a?(p=u.contrastText,c=d||l?u.dark:u.main):("outlined"===a&&(f=l||d?u.main:sh(u.main,.5)),c=d?sh(u.main,.12):l?sh(u.main,.04):"transparent");let m={display:"inline-flex",alignItems:"center",gap:6,fontSize:13,fontWeight:500,letterSpacing:"0.02857em",textTransform:"uppercase",color:p,padding:"contained"===a?"4px 10px":"3px 9px",borderRadius:4,minWidth:64,minHeight:30,justifyContent:"center",textDecoration:"none",cursor:"pointer",background:c,border:`1px solid ${f}`,boxShadow:"contained"===a?l?"0px 2px 4px -1px rgba(0,0,0,0.2), 0px 4px 5px 0px rgba(0,0,0,0.14), 0px 1px 10px 0px rgba(0,0,0,0.12)":"0px 3px 1px -2px rgba(0,0,0,0.2), 0px 2px 2px 0px rgba(0,0,0,0.14), 0px 1px 5px 0px rgba(0,0,0,0.12)":"none",transition:"background-color 250ms cubic-bezier(0.4, 0, 0.2, 1), border-color 250ms cubic-bezier(0.4, 0, 0.2, 1), box-shadow 250ms cubic-bezier(0.4, 0, 0.2, 1)",userSelect:"none",fontFamily:"inherit",lineHeight:1.75},g=()=>o(!0),y=()=>{o(!1),h(!1)},v=()=>h(!0),b=()=>h(!1),E=(0,T.jsx)("span",{children:e});return t?(0,T.jsx)("a",{href:t,target:i,rel:s,style:m,onMouseEnter:g,onMouseLeave:y,onMouseDown:v,onMouseUp:b,children:E}):(0,T.jsx)("div",{role:"button",tabIndex:0,onClick:r,onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&r?.()},style:m,onMouseEnter:g,onMouseLeave:y,onMouseDown:v,onMouseUp:b,children:E})},sc=({item:e,globalStyle:t,onLightboxClick:i})=>{var s;let r,a=sn(t,e.style),{src:n,title:l,thumbnailUrl:o,fileName:d,mimeType:h,fileSize:u,description:c,caption:f,clickAction:p,link:m,openNewTab:g}=e,y=(e=>{if(!e)return"";if("application/pdf"===e)return"PDF";if(e.startsWith("image/"))return e.split("/")[1]?.toUpperCase()??"IMG";let t=e.split("/")[1];return t?t.includes("word")||t.includes("document")?"DOCX":t.includes("spreadsheet")||t.includes("excel")?"XLSX":t.includes("presentation")||t.includes("powerpoint")?"PPTX":t.toUpperCase().slice(0,5):""})(h),v=u?e6(u):"",b=a.showDownloadAction&&(a.actionLabel||si[p])||"",E=a.showTypeBadge?a.badgeText||y:"",S=h?.startsWith("image/"),k=o||(S?n:void 0),w="none"!==a.thumbPosition,A=a.thumbLayout||"side-contain",R=w&&"top"===A,L=!R&&"left"===a.thumbPosition,C="none"!==a.captionPosition&&!!f,I="lightbox"===p&&!!(o||S)&&!!i,[P,D]=(0,x.useState)(null),M=R||"side-cover"===A?"cover":"contain",_=w?(0,T.jsx)("div",{onClick:I?i:void 0,style:{flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:k?"contain"===M?"var(--dp-surface-2, #f5f5f5)":"transparent":"var(--dp-surface-2, #f5f5f5)",backgroundSize:"cover",backgroundPosition:"center",overflow:"hidden",borderRadius:R?"4px 4px 0 0":L?"4px 0 0 4px":"0 4px 4px 0",cursor:
4I?"pointer":void 0,...R?{width:"100%",aspectRatio:P??sa}:{width:"side-contain"===A?120:"30%",minWidth:96,maxWidth:200,aspectRatio:sa,alignSelf:"flex-start"}},children:k?(0,T.jsx)("img",{src:k,alt:d||"Thumbnail",loading:"lazy",onLoad:R?e=>{let t=e.currentTarget;t.naturalWidth>0&&t.naturalHeight>0&&D(`${t.naturalWidth} / ${t.naturalHeight}`)}:void 0,style:{width:"100%",height:"100%",objectFit:M,display:"block"}},k):(0,T.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",minHeight:80,fontSize:24,fontWeight:700,color:"var(--dp-text-2, rgba(0, 0, 0, 0.38))",textTransform:"uppercase"},children:y||"?"})}):null,$=!!(b&&n),O=!!E||a.showFileSize&&!!v,N=(0,T.jsxs)("div",{style:{flex:1,padding:"16px",paddingBottom:$?4:20,minWidth:0,display:"flex",flexDirection:"column",gap:8},children:[(0,T.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:8},children:[(0,T.jsx)("div",{style:{fontSize:15,fontWeight:500,color:"var(--dp-text, rgba(0, 0, 0, 0.87))",lineHeight:1.334,letterSpacing:"0em",wordBreak:"break-word",flex:1,minWidth:0},children:l||d||"Arquivo"}),O?(0,T.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,flexShrink:0},children:[E?(0,T.jsx)("span",{style:(s=a.badgeColor,r={display:"inline-flex",alignItems:"center",borderRadius:9999,padding:"2px 8px",fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.03em"},s&&ss[s]?{...r,backgroundColor:ss[s].bg,color:ss[s].color}:h?.startsWith("image/")?{...r,backgroundColor:"var(--dp-info-bg, #eff6ff)",color:"#2563eb"}:"application/pdf"===h?{...r,backgroundColor:"var(--dp-danger-bg, #fef2f2)",color:"#dc2626"}:{...r,backgroundColor:"var(--dp-surface-2, #f3f4f6)",color:"var(--dp-text-2, #6b7280)"}),children:E}):null,a.showFileSize&&v?(0,T.jsx)("span",{style:{fontSize:12,color:"var(--dp-text-2, rgba(0, 0, 0, 0.6))",whiteSpace:"nowrap"},children:v}):null]}):null]}),c?(0,T.jsx)(so,{text:c}):null]}),F=$?(0,T.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",padding:"12px 16px 16px",gap:8},children:"link"===p&&(m||n)?(0,T.jsx)(su,{label:b,href:m||n,target:g?"_blank":void 0,rel:g?"noopener noreferrer":void 0,variant:a.actionVariant,color:a.actionColor}):(0,T.jsx)(su,{label:b,onClick:()=>sl(n,d),variant:a.actionVariant,color:a.actionColor})}):null,B=f?(0,T.jsx)("div",{style:{fontSize:13,color:"var(--dp-text-2, rgba(0, 0, 0, 0.6))",padding:"4px 2px",lineHeight:1.4},children:f}):null,U=(0,T.jsxs)("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column"},children:[N,F]}),j=!$&&n&&"none"!==p,V=j&&"download"===p?()=>sl(n,d):j&&"lightbox"===p&&i?i:void 0,G={borderRadius:4,backgroundColor:"var(--dp-surface, #fff)",boxShadow:"0px 2px 1px -1px rgba(0,0,0,0.2), 0px 1px 1px 0px rgba(0,0,0,0.14), 0px 1px 3px 0px rgba(0,0,0,0.12)",overflow:"hidden",transition:"box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1)",...j?{cursor:"pointer",textDecoration:"none",color:"inherit"}:{}},q=j?{role:"button",tabIndex:0,onClick:V,onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&V?.()}}:{},H=j&&"link"===p&&(m||n),K=R?{display:"flex",flexDirection:"column",...G}:{display:"flex",flexDirection:"row",alignItems:"flex-start",...G},W=R?(0,T.jsxs)(T.Fragment,{children:[_,N,F]}):(0,T.jsxs)(T.Fragment,{children:[L?_:null,U,L?null:_]}),z=H?(0,T.jsx)("a",{href:m||n,target:g?"_blank":void 0,rel:g?"noopener noreferrer":void 0,style:K,children:W}):(0,T.jsx)("div",{...q,style:K,children:W});return(0,T.jsxs)("div",{style:{display:"flex",flexDirection:"column",width:R?"100%":void 0,maxWidth:R?320:void 0,justifySelf:R?"start":void 0},children:[C&&"above"===a.captionPosition?B:null,z,C&&"below"===a.captionPosition?B:null]})},sf=({items:e,colsMobile:t=1,colsDesktop:i=2,cardStyle:s})=>{let r={...sr,...s},[a,n]=(0,x.useState)(-1),l=[];e.forEach((e,t)=>{let i=sn(r,e.style),s=!!(e.thumbnailUrl||e.mimeType?.startsWith("image/"));if("lightbox"===e.clickAction&&s){let s=i.lightbox||{},r={src:e.thumbnailUrl||e.src,downloadSrc:e.src,fileName:e.fileName,itemIndex:t};!s.hideTitle&&(e.title||e.fileName)&&(r.title=e.title||e.fileName),!s.hideDescription&&e.description&&(r.description=e.description),l.push(r)}});let o=l.length<=1;return(0,T.jsxs)("div",{style:{width:"100%",margin:"16px 0"},children:[(0,T.jsx)("div",{className:`grid gap-4 grid-cols-${t} md:grid-cols-${i}`,style:{display:"grid",gap:16,alignItems:"start"},children:e.map((e,t)=>{let i=l.findIndex(e=>e.itemIndex===t);return(0,T.jsx)(sc,{item:e,globalStyle:r,onLightboxClick:i>=0?()=>n(i):void 0},`${e.src}-${t}`)})}),l.length>0&&(0,T.jsx)(iJ,{open:a>=0,close:()=>n(-1),index:a>=0?a:0,slides:l,plugins:[st],carousel:{finite:!0},render:o?{buttonPrev:()=>null,buttonNext:()=>null}:void 0,toolbar:{buttons:[(0,T.jsx)("button",{type:"button","aria-label":"Download",onClick:()=>{let e=l[a>=0?a:0];e&&sl(e.downloadSrc,e.fileName||"arquivo")},className:"yarl__button",style:{background:"none",border:"none",color:"#fff",cursor:"pointer",padding:8,opacity:1},children:(0,T.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",style:{width:24,height:24},children:[(0,T.jsx)("path",{d:"M10.75 2.75a.75.75 0 00-1.5 0v8.614L6.295 8.235a.75.75 0 10-1.09 1.03l4.25 4.5a.75.75 0 001.09 0l4.25-4.5a.75.75 0 00-1.09-1.03l-2.955 3.129V2.75z"}),(0,T.jsx)("path",{d:"M3.5 12.75a.75.75 0 00-1.5 0v2.5A2.75 2.75 0 004.75 18h10.5A2.75 2.75 0 0018 15.25v-2.5a.75.75 0 00-1.5 0v2.5c0 .69-.56 1.25-1.25 1.25H4.75c-.69 0-1.25-.56-1.25-1.25v-2.5z"})]})},"download"),"close"]}})]})},sp={original:null,small:320,medium:640,large:960,custom:null},sm=({src:e,alt:t,onClose:i})=>(0,T.jsxs)("div",{onClick:i,style:{position:"fixed",inset:0,zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0, 0, 0, 0.85)",cursor:"zoom-out"},children:[(0,T.jsx)("button",{onClick:i,style:{position:"absolute",top:16,right:16,zIndex:1e4,background:"rgba(255,255,255,0.15)",border:"none",borderRadius:"50%",width:40,height:40,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",color:"#fff",fontSize:20,fontWeight:"bold",backdropFilter:"blur(4px)"},"aria-label":"Fechar",children:"✕"}),(0,T.jsx)("img",{src:e,alt:t,onClick:e=>e.stopPropagation(),style:{maxWidth:"90vw",maxHeight:"90vh",objectFit:"contain",borderRadius:4,cursor:"default"}})]}),sg=(e,t)=>
4{let i=document.createElement("a");i.href=e,i.download=t||"arquivo",i.target="_blank",i.rel="noopener noreferrer",document.body.appendChild(i),i.click(),document.body.removeChild(i)},sy=({node:e})=>{let[t,i]=(0,x.useState)(!1),[s,r]=(0,x.useState)(!1),{src:a,thumbnailUrl:n,alt:l="",fileName:o,mimeType:d,fileSize:h,pageCount:u,sizePreset:c="original",customMaxWidth:f,customMaxHeight:p,clickAction:m="lightbox",link:g,openNewTab:y=!0,caption:v,captionPosition:b="below",description:E,showDownloadIcon:S=!0,showFileTypeIcon:k=!0,showFileSize:w=!0,hoverOverlayText:A,alignment:R="center"}=e,L=d?d?.startsWith("image/")??!1:["jpg","jpeg","png","gif","webp","svg","bmp","avif"].includes(a.split(".").pop()?.toLowerCase()??""),C="custom"===c?f?`${f}px`:void 0:sp[c]?`${sp[c]}px`:void 0,I="custom"===c&&p?`${p}px`:void 0,P=(0,x.useCallback)(()=>{"lightbox"===m&&L?i(!0):"download"===m&&sg(a,o)},[m,a,o,L]),D=n||a;if(!D)return(0,T.jsx)(T.Fragment,{});let M=v?(0,T.jsx)("figcaption",{style:{..."above"===b?{marginBottom:8}:{marginTop:8},fontSize:13,color:"var(--dp-text-2, #6B7280)",textAlign:R},children:v}):null,_=A?(0,T.jsx)("div",{style:{position:"absolute",inset:0,backgroundColor:"rgba(0, 0, 0, 0.55)",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:4,opacity:+!!s,transition:"opacity 0.2s ease",pointerEvents:"none"},children:(0,T.jsx)("span",{style:{color:"#fff",fontSize:15,fontWeight:500,textAlign:"center",padding:12},children:A})}):null;if(L){let e=(0,T.jsx)("img",{src:D,alt:l,loading:"lazy",style:{display:"block",maxWidth:C||"100%",maxHeight:I,width:"auto",height:"auto",borderRadius:4}},D),s="lightbox"===m||"download"===m,n=(0,T.jsxs)("div",{style:{position:"relative",display:"inline-block"},onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),children:[e,_]});return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)("figure",{style:{display:"flex",flexDirection:"column",alignItems:"left"===R?"flex-start":"right"===R?"flex-end":"center",margin:"16px 0"},children:["above"===b&&M,"link"===m&&g?(0,T.jsx)("a",{href:g,target:y?"_blank":"_self",rel:"noopener noreferrer",children:n}):s?(0,T.jsx)("span",{onClick:P,onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&P()},role:"button",tabIndex:0,style:{cursor:"lightbox"===m?"zoom-in":"pointer"},children:n}):n,"below"===b&&M]}),t&&(0,T.jsx)(sm,{src:a,alt:l,onClose:()=>i(!1)})]})}let $=e3(a),O=e8[$].icon,N=(0,T.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:16,padding:16,backgroundColor:"var(--dp-surface, #f9fafb)",borderRadius:8,border:"1px solid var(--dp-border, #e5e7eb)",maxWidth:500,width:"100%",cursor:"none"!==m?"pointer":"default",position:"relative",overflow:"hidden"},onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),children:[n?(0,T.jsx)("img",{src:n,alt:o||"Thumbnail",style:{width:64,height:64,objectFit:"cover",borderRadius:6,flexShrink:0}},n):!1!==k?(0,T.jsx)("div",{style:{width:48,height:48,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:(0,T.jsx)(O,{})}):null,(0,T.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,T.jsx)("div",{style:{fontSize:14,fontWeight:500,color:"var(--dp-text, #111827)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:o||a.split("/").pop()||"Arquivo"}),(0,T.jsx)("div",{style:{fontSize:12,color:"var(--dp-text-2, #6b7280)",marginTop:2},children:[d?.split("/")[1]?.toUpperCase()||$.toUpperCase(),!1!==w&&h?e6(h):null,u?`${u} p\xe1gina${u>1?"s":""}`:null].filter(Boolean).join(" · ")}),E&&(0,T.jsx)("div",{style:{fontSize:12,color:"var(--dp-text-2, #6b7280)",marginTop:4,lineHeight:1.4},children:E})]}),!1!==S&&("download"===m||"lightbox"===m)&&(0,T.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",style:{width:20,height:20,flexShrink:0,color:"var(--dp-text-2, #6b7280)"},children:[(0,T.jsx)("path",{d:"M10.75 2.75a.75.75 0 00-1.5 0v8.614L6.295 8.235a.75.75 0 10-1.09 1.03l4.25 4.5a.75.75 0 001.09 0l4.25-4.5a.75.75 0 00-1.09-1.03l-2.955 3.129V2.75z"}),(0,T.jsx)("path",{d:"M3.5 12.75a.75.75 0 00-1.5 0v2.5A2.75 2.75 0 004.75 18h10.5A2.75 2.75 0 0018 15.25v-2.5a.75.75 0 00-1.5 0v2.5c0 .69-.56 1.25-1.25 1.25H4.75c-.69 0-1.25-.56-1.25-1.25v-2.5z"})]}),_]});return(0,T.jsxs)("figure",{style:{display:"flex",flexDirection:"column",alignItems:"left"===R?"flex-start":"right"===R?"flex-end":"center",margin:"16px 0"},children:["above"===b&&M,"link"===m&&g?(0,T.jsx)("a",{href:g,target:y?"_blank":"_self",rel:"noopener noreferrer",style:{textDecoration:"none"},children:N}):"download"===m?(0,T.jsx)("span",{onClick:()=>sg(a,o),onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&sg(a,o)},role:"button",tabIndex:0,style:{cursor:"pointer"},children:N}):N,"below"===b&&M]})},sv=({node:e})=>Array.isArray(e.items)&&e.items.length>0?(0,T.jsx)(sf,{items:e.items,colsMobile:e.colsMobile,colsDesktop:e.colsDesktop,cardStyle:e.cardStyle}):(0,T.jsx)(sy,{node:e}),sb={border:"1px dashed var(--dp-border, #cfd3da)",minHeight:"140px",display:"flex",alignItems:"center",justifyContent:"center",background:"var(--dp-surface, #fafbfc)",borderRadius:8,overflow:"hidden",transition:"background 0.15s ease, border-color 0.15s ease"},sE={borderColor:"var(--dp-border, #8a93a3)",background:"var(--dp-surface-2, #f2f4f7)"},sS={background:"var(--dp-surface, #ffffff)",borderStyle:"solid",borderColor:"var(--dp-border, #e0e5ec)"},sT={border:"1px solid var(--dp-border, #e0e5ec)",minHeight:"140px",display:"flex",alignItems:"center",justifyContent:"center",background:"var(--dp-surface, #fafbfc)",borderRadius:8,overflow:"hidden"},sx={width:"100%",height:"100%",objectFit:"contain"},sk={color:"var(--dp-text-2, #6b7280)",cursor:"pointer",fontSize:14,textAlign:"center",padding:12},sw=({card:e,downloadLabel:t})=>{let{icon:i,linkClass:s}=e8[e3(e.url)];return(0,T.jsxs)("div",{className:"relative rounded-lg border border-gray-200 dark:border-white/10 bg-white dark:bg-[#1e1e2e] p-5 shadow-sm",children:[e.badge&&(0,T.jsx)("span",{className:"absolute -top-2 right-3 rounded-full bg-emerald-500 px-2.5 py-0.5 text-xs font-bold text-white",children:e.badge}),(0,T.jsx)("p",{className:"m-0 text-sm font-bold uppercase tracking-wide text-indigo-600 dark:text-indigo-300",children:e.header}),(0,T.jsx)("p",{className:"mt-1 mb-0 text-base font-semibold text-gray-900 dark:text-[#e5e7eb]",children:e.title}),(0,T.jsx)("p",{className:"mt-2 mb-0 text-sm text-gray-600 dark:text-[#9aa4b2]",children:e.description}),e.url&&(0,T.jsxs)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:`mt-3 inline-flex items-center gap-2 text-sm font-medium no-underline ${s}`,children:[(0,T.jsx)(i,{}),t]})]})},sA=({cards:e,colsMobile:t,colsDesktop:i,downloadLabel:s})=>(0,T.jsx)("div",{className:"w-full my-4",children:(0,T.jsx)("div",{className:`grid gap-4 grid-cols-${t} md:grid-cols-${i}`,children:e.map((e,t)=>(0,T.jsx)(sw,{card:e,downloadLabel:s??"Download"},t))})});function sR(){let e="(min-width: 768px)",t=(0,x.useCallback)(()=>typeof window>"u"||window.matchMedia(e).matches?"desktop":"mobile",[e]),[i,s]=(0,x.useState)(t);return(0,x.useEffect)(()=>
4{if(typeof window>"u")return;let t=window.matchMedia(e),i=()=>s(t.matches?"desktop":"mobile");return t.addEventListener("change",i),()=>t.removeEventListener("change",i)},[e]),i}let sL=e=>e&&e>0?e:void 0,sC=e=>{let{fileUrl:t,fileUrlDark:i,link:s,reference:r,maxHeight:a,maxWidth:n,maxWidthMobile:l,maxHeightMobile:o,maxWidthDesktop:d,maxHeightDesktop:h,openNewTab:u,headerText:c,alignment:f="center",isOpenLightboxOnClick:p,wordImageLayout:m,wordImageWrap:g,wordAnchor:y}=e,[v,b]=(0,x.useState)(!1),E=sR();if(!t&&!i)return null;let S="mobile"===E,k=S?sL(l)??sL(n):sL(d)??sL(n),w=S?sL(o)??sL(a):sL(h)??sL(a),A="anchor"===m,R=y?.offsetX??0,L=y?.offsetY??0,C=A&&"none"!==g&&"top-and-bottom"!==g&&("left"===f||"right"===f),I={display:"block",maxWidth:k?`min(${k}px, 100%)`:"100%",maxHeight:w?`${w}px`:void 0,width:"auto",height:"auto",cursor:p?"pointer":void 0},P={display:"flex",flexDirection:"column",alignItems:"left"===f?"flex-start":"right"===f?"flex-end":"center",textAlign:f,position:A?"relative":void 0,transform:A?`translate(${R}px, ${L}px)`:void 0,zIndex:A?y?.behindDoc?0:y?.zIndex:void 0,float:C?f:void 0,clear:A&&"top-and-bottom"===g?"both":void 0,pointerEvents:y?.behindDoc?"none":void 0,margin:C&&"left"===f?"0 16px 12px 0":C&&"right"===f?"0 0 12px 16px":void 0},D=()=>{p&&b(!0)},{display:M,..._}=I,$=(e,t)=>(0,T.jsx)("img",{src:e,alt:r||"",className:t,style:t?_:I,onClick:p?D:void 0},e),O=t&&i?(0,T.jsxs)(T.Fragment,{children:[$(t,"dp-img dp-img-light"),$(i,"dp-img dp-img-dark")]}):i?$(i,"dp-img dp-img-dark"):$(t),N=i&&((()=>{if(typeof document>"u")return!1;let e=document.documentElement;return!!e.classList.contains("dark")||(e.getAttribute("data-mui-color-scheme")??e.getAttribute("data-theme"))==="dark"})()||!t)?i:t;return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)("figure",{style:P,children:[c&&(0,T.jsx)("figcaption",{style:{marginBottom:8,fontSize:18,fontWeight:600},children:c}),s&&!p?(0,T.jsx)("a",{href:s,target:u?"_blank":"_self",children:O}):O,r&&(0,T.jsx)("figcaption",{style:{marginTop:12,fontSize:13,color:"var(--dp-text-2, #6B7280)"},children:r})]}),p&&(0,T.jsx)(iJ,{open:v,close:()=>b(!1),slides:[{src:N}],plugins:[],carousel:{finite:!0},render:{buttonPrev:()=>null,buttonNext:()=>null},toolbar:{buttons:[...s?[(0,T.jsx)(()=>(0,T.jsx)("button",{onClick:()=>window.open(s,u?"_blank":"_self"),"aria-label":"Abrir link",style:{position:"fixed",top:16,left:16,zIndex:10001,background:"rgba(255,255,255,0.15)",border:"none",borderRadius:"50%",width:40,height:40,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",color:"#fff",backdropFilter:"blur(4px)"},children:(0,T.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",style:{width:20,height:20},children:[(0,T.jsx)("path",{fillRule:"evenodd",d:"M4.25 5.5a.75.75 0 00-.75.75v8.5c0 .414.336.75.75.75h8.5a.75.75 0 00.75-.75v-4a.75.75 0 011.5 0v4A2.25 2.25 0 0112.75 17h-8.5A2.25 2.25 0 012 14.75v-8.5A2.25 2.25 0 014.25 4h5a.75.75 0 010 1.5h-5z",clipRule:"evenodd"}),(0,T.jsx)("path",{fillRule:"evenodd",d:"M6.194 12.753a.75.75 0 001.06.053L16.5 4.44v2.81a.75.75 0 001.5 0v-4.5a.75.75 0 00-.75-.75h-4.5a.75.75 0 000 1.5h2.553l-9.056 8.194a.75.75 0 00-.053 1.06z",clipRule:"evenodd"})]})}),{},"link-redirect")]:[],"close"]}})]})};function sI(e,t=2){if(0===e.length)return[100];let i=e.map(e=>Math.max(0,e)),s=i.reduce((e,t)=>e+t,0);if(0===s){let e=parseFloat((100/i.length).toFixed(t)),s=Array.from({length:i.length},()=>e),r=100-s.reduce((e,t)=>e+t,0);return s[s.length-1]=parseFloat((s[s.length-1]+r).toFixed(t)),s}let r=100/s,a=i.map(e=>parseFloat((e*r).toFixed(t))),n=parseFloat((100-a.reduce((e,t)=>e+t,0)).toFixed(t));return 0!==n&&(a[a.length-1]=parseFloat((a[a.length-1]+n).toFixed(t))),a}function sP(e,t,i="stack"){let s=[...e.desktop];if(s.length<t){let e=100-s.reduce((e,t)=>e+t,0),i=t-s.length,r=e/i;for(let e=0;e<i;e++)s.push(r)}else s.length>t&&(s=s.slice(0,t));return s=sI(s),{mobile:"stack"===i?[100]:e.mobile.length===t?sI(e.mobile):[...s],desktop:s}}let sD={position:"relative",width:"100%",margin:"16px 0"},sM={...sD,outline:"2px dashed transparent",borderRadius:8,transition:"outline-color 0.15s ease"},s_={outlineColor:"var(--dp-border, #e2e8f0)"},s$={outlineColor:"#3b82f6"},sO={minWidth:0,maxWidth:"100%",overflow:"hidden",position:"relative"},sN={...sO,borderRadius:6,border:"1px dashed transparent",padding:8,transition:"border-color 0.15s ease, background-color 0.15s ease"},sF={borderColor:"var(--dp-border, #cbd5e1)",backgroundColor:"var(--dp-surface-2, rgba(241, 245, 249, 0.5))"},sB={borderColor:"#3b82f6",backgroundColor:"rgba(59, 130, 246, 0.05)"},sU={position:"absolute",top:0,bottom:0,width:12,cursor:"col-resize",zIndex:10,display:"flex",alignItems:"center",justifyContent:"center",transform:"translateX(-50%)"},sj={width:4,height:32,borderRadius:2,backgroundColor:"var(--dp-border, #cbd5e1)",transition:"background-color 0.15s ease, height 0.15s ease"},sV={backgroundColor:"#3b82f6",height:48},sG={position:"absolute",top:0,bottom:0,width:3,backgroundColor:"#3b82f6",borderRadius:2,zIndex:20,pointerEvents:"none",opacity:0,transition:"opacity 0.15s ease"},sq={opacity:1}
4,sH={position:"absolute",top:-40,left:"50%",transform:"translateX(-50%)",display:"flex",alignItems:"center",gap:4,padding:"4px 8px",backgroundColor:"var(--dp-surface, white)",borderRadius:8,boxShadow:"0 4px 16px rgba(15, 23, 42, 0.12)",border:"1px solid var(--dp-border, #e2e8f0)",zIndex:50,whiteSpace:"nowrap"},sK={display:"inline-flex",alignItems:"center",justifyContent:"center",width:28,height:28,borderRadius:6,border:"none",backgroundColor:"transparent",cursor:"pointer",color:"var(--dp-text-2, #475569)",transition:"background-color 0.15s ease, color 0.15s ease"},sW={backgroundColor:"var(--dp-surface-2, #f1f5f9)",color:"var(--dp-text, #0f172a)"},sz={width:1,height:20,backgroundColor:"var(--dp-border, #e2e8f0)",margin:"0 2px"},sY={position:"relative",borderRadius:4,transition:"outline-color 0.15s ease",outline:"1px dashed transparent"},sQ={outlineColor:"var(--dp-border, #cbd5e1)"},sX={position:"absolute",top:2,right:2,display:"flex",alignItems:"center",gap:2,padding:2,backgroundColor:"var(--dp-surface, white)",borderRadius:6,boxShadow:"0 2px 8px rgba(15, 23, 42, 0.10)",border:"1px solid var(--dp-border, #e2e8f0)",zIndex:30,opacity:0,transition:"opacity 0.15s ease",pointerEvents:"auto"},sJ={opacity:1},sZ={display:"inline-flex",alignItems:"center",justifyContent:"center",width:24,height:24,borderRadius:4,border:"none",backgroundColor:"transparent",cursor:"pointer",color:"var(--dp-text-2, #64748b)",transition:"background-color 0.15s ease, color 0.15s ease"},s0={backgroundColor:"var(--dp-surface-2, #f1f5f9)",color:"var(--dp-text, #0f172a)"},s1={opacity:.3,cursor:"not-allowed"},s2=({position:e,visible:t})=>(0,T.jsx)("div",{style:{...sG,..."before"===e?{left:-2}:"after"===e?{right:-2}:{left:0,right:0,top:"auto",bottom:0,width:"100%",height:3},...t?sq:{}},"aria-hidden":"true","data-drop-indicator":e}),s5=({blockIndex:e,totalBlocks:t,onMoveUp:i,onMoveDown:s,onEdit:r})=>(0,T.jsxs)("div",{style:sX,role:"toolbar","aria-label":`Controles do bloco ${e+1}`,children:[(0,T.jsx)(s3,{icon:s4,label:"Mover para cima",onClick:i,disabled:0===e}),(0,T.jsx)(s3,{icon:s8,label:"Mover para baixo",onClick:s,disabled:e===t-1}),(0,T.jsx)(s3,{icon:s6,label:"Editar bloco",onClick:r})]}),s3=({icon:e,label:t,onClick:i,disabled:s})=>{let[r,a]=(0,x.useState)(!1);return(0,T.jsx)("button",{type:"button",style:{...sZ,...r&&!s?s0:{},...s?s1:{}},title:t,"aria-label":t,disabled:s,onClick:e=>{e.stopPropagation(),i?.()},onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),children:(0,T.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,T.jsx)("path",{d:e})})})},s4="M18 15l-6-6-6 6",s8="M6 9l6 6 6-6",s6="M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z",s7=e=>e.replace(/-([a-z])/g,(e,t)=>t.toUpperCase()),s9=e=>{if(!e)return{};let t={};for(let[i,s]of Object.entries(e))t[i.startsWith("--")?i:s7(i)]=s;return t},re=({node:e,macros:t,renderNode:i,index:s,totalColumns:r,editable:a=!1,isDropTarget:n=!1,onDragOver:l,onDragLeave:o,onDrop:d,onMoveBlock:h,onEditBlock:u})=>{let[c,f]=(0,x.useState)(!1),p=K(e.children),m=a?sN:sO,g=s9(e.style),y=a?{...m,...g,...c?sF:{},...n?sB:{}}:{...m,...g};return(0,T.jsxs)("div",{style:y,"data-layout-column":!0,"data-column-index":s,role:a?"group":void 0,"aria-label":a?`Coluna ${s+1} de ${r}`:void 0,onMouseEnter:a?()=>f(!0):void 0,onMouseLeave:a?()=>f(!1):void 0,onDragOver:a?l:void 0,onDragLeave:a?o:void 0,onDrop:a?d:void 0,children:[a&&0===s&&(0,T.jsx)(s2,{position:"before",visible:n}),p.length>0?p.map((e,s)=>a?(0,T.jsx)(rt,{blockIndex:s,totalBlocks:p.length,onMoveUp:s>0?()=>h?.(s,"up"):void 0,onMoveDown:s<p.length-1?()=>h?.(s,"down"):void 0,onEdit:()=>u?.(s),children:i?.(e,t)},s):(0,T.jsx)("div",{children:i?.(e,t)},s)):a?(0,T.jsx)("div",{className:"flex items-center justify-center min-h-[80px] text-sm text-slate-400 select-none",children:"Arraste um bloco ou clique para adicionar conteúdo"}):null,a&&s===r-1&&(0,T.jsx)(s2,{position:"after",visible:n})]})},rt=({blockIndex:e,totalBlocks:t,onMoveUp:i,onMoveDown:s,onEdit:r,children:a})=>{let[n,l]=(0,x.useState)(!1);return(0,T.jsxs)("div",{style:{...sY,...n?sQ:{}},onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),"data-block-index":e,children:[n&&(0,T.jsx)("div",{style:sJ,children:(0,T.jsx)(s5,{blockIndex:e,totalBlocks:t,onMoveUp:i,onMoveDown:s,onEdit:r})}),a]})},ri=({template:e,onSelect:t})=>{let[i,s]=(0,x.useState)(!1);return(0,T.jsxs)("button",{type:"button",className:"flex items-center gap-3 w-full px-3 py-2.5 rounded-lg text-left transition-colors",style:{backgroundColor:i?"var(--dp-surface-2, #f1f5f9)":"transparent",border:"none",cursor:"pointer"},onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),onClick:()=>t(e.id),"aria-label":`Inserir layout: ${e.label}`,children:[(0,T.jsx)("span",{className:"shrink-0 flex items-center justify-center w-10 h-10 rounded-lg",style:{backgroundColor:i?"var(--dp-border, #e2e8f0)":"var(--dp-surface-2, #f1f5f9)",transition:"background-color 0.15s ease"},"aria-hidden":"true",children:(0,T.jsx)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"var(--dp-text-2, #475569)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,T.jsx)("path",{d:e.icon})})}),(0,T.jsxs)("span",{className:"flex flex-col min-w-0",children:[(0,T.jsx)("span",{className:"text-sm font-medium text-slate-800 dark:text-[#e5e7eb] truncate",children:e.label}),(0,T.jsx)("span",{className:"text-xs text-slate-500 dark:text-[#9aa4b2] truncate",children:e.description})]})]})},rs=({onInsertTemplate:e,onAddColumn:t,onRemoveColumn:i,onDelete:s,columnCount:r=1})=>{let[a,n]=(0,x.useState)(!1),l=(0,x.useRef)(null),o=(0,x.useRef)(null);(0,x.useEffect)(()=>
4{if(!a)return;let e=e=>{l.current&&!l.current.contains(e.target)&&o.current&&!o.current.contains(e.target)&&n(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[a]),(0,x.useEffect)(()=>{if(!a)return;let e=e=>{"Escape"===e.key&&n(!1)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[a]);let d=(0,x.useCallback)(t=>{e?.(t),n(!1)},[e]);return(0,T.jsxs)("div",{style:sH,role:"toolbar","aria-label":"Layout editor toolbar",children:[(0,T.jsx)(rr,{ref:o,icon:ra,label:"Escolher layout",onClick:()=>n(e=>!e),isActive:a}),(0,T.jsx)("div",{style:sz,"aria-hidden":"true"}),(0,T.jsx)(rr,{icon:rn,label:"Adicionar coluna",onClick:()=>t?.()}),(0,T.jsx)(rr,{icon:rl,label:"Remover coluna",onClick:()=>i?.(),disabled:r<=1}),(0,T.jsx)("div",{style:sz,"aria-hidden":"true"}),(0,T.jsx)(rr,{icon:ro,label:"Remover layout",onClick:()=>s?.(),danger:!0}),a&&(0,T.jsxs)("div",{ref:l,className:"absolute top-full left-0 mt-2 w-72 max-h-80 overflow-y-auto rounded-xl border border-slate-200 dark:border-white/10 bg-white dark:bg-[#1e1e2e] p-2 shadow-xl",role:"listbox","aria-label":"Templates de layout",style:{zIndex:60},children:[(0,T.jsx)("p",{className:"px-3 pt-1 pb-2 text-xs font-semibold text-slate-400 uppercase tracking-wider",children:"Templates"}),j.map(e=>(0,T.jsx)(ri,{template:e,onSelect:d},e.id))]})]})},rr=(0,x.forwardRef)(({icon:e,label:t,onClick:i,isActive:s,disabled:r,danger:a},n)=>{let[l,o]=(0,x.useState)(!1),d=a?l?"#e11d48":"#f43f5e":s?"var(--dp-text, #0f172a)":void 0;return(0,T.jsx)("button",{ref:n,type:"button",style:{...sK,...l||s?sW:{},...d?{color:d}:{},...r?{opacity:.4,cursor:"not-allowed"}:{}},title:t,"aria-label":t,disabled:r,onClick:i,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),children:(0,T.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,T.jsx)("path",{d:e})})})});rr.displayName="ToolbarButton";let ra="M3 3h7v7H3V3zm11 0h7v7h-7V3zm-11 11h7v7H3v-7zm11 0h7v7h-7v-7z",rn="M12 5v14m-7-7h14",rl="M5 12h14",ro="M3 6h18M8 6V4a2 2 0 012-2h4a2 2 0 012 2v2m3 0v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6h14",rd="application/x-layout-block",rh=({node:e,macros:t,renderNode:i,editable:s=!1,callbacks:r})=>{let a=sR(),[n,l]=(0,x.useState)(!1),[o,d]=(0,x.useState)(!1),h=(0,x.useMemo)(()=>K(e.children).filter(e=>"layout-column"===e.type||"layout-col-item"===e.type),[e.children]),u=h.length||e.columnCount||1,c=(0,x.useMemo)(()=>{if(!e.widths){let t=100/u;return sP({mobile:[100],desktop:Array.from({length:u},()=>t)},u,e.mobileMode??"stack")}return sP(e.widths,u,e.mobileMode??"stack")},[e.widths,u,e.mobileMode]),f="mobile"===a?c.mobile:c.desktop,{liveWidths:p,isResizing:m,resizingIndex:g,startResize:y}=function({widths:e,breakpoint:t,onResizeEnd:i}){let[s,r]=(0,x.useState)(e),[a,n]=(0,x.useState)(!1),[l,o]=(0,x.useState)(null),d=(0,x.useRef)(null),h=(0,x.useRef)(0),u=(0,x.useRef)([]);return!a&&e!==u.current&&(e.some((e,t)=>e!==s[t])||e.length!==s.length)&&r(e),{liveWidths:s,isResizing:a,resizingIndex:l,startResize:(0,x.useCallback)((s,a)=>{a.preventDefault(),a.stopPropagation();let l=a.currentTarget.closest("[data-layout-container]");if(!l)return;d.current=l,h.current=a.clientX,u.current=[...e],n(!0),o(s);let c=l.getBoundingClientRect().width,f=e=>{let t=(e.clientX-h.current)/c*100;r(function(e,t,i){if(e.length<2)return[100];if(t<0||t>=e.length)return[...e];let s=Math.max(10,Math.min(90,i)),r=[...e],a=t<e.length-1?t+1:t-1,n=s-r[t],l=r[a]-n;return l<10?[...e]:(r[t]=s,r[a]=l,sI(r))}(u.current,s,u.current[s]+t))},p=()=>{document.removeEventListener("pointermove",f),document.removeEventListener("pointerup",p),n(!1),o(null),r(e=>(i?.(s,t,e[s]),e))};document.addEventListener("pointermove",f),document.addEventListener("pointerup",p)},[e,t,i])}}({widths:f,breakpoint:a,onResizeEnd:r?.onResizeColumn}),{activeDropColumn:v,handleDragStart:b,getColumnDropHandlers:E}=function({columnCount:e,onDropBlock:t}){let[i,s]=(0,x.useState)(null),r=(0,x.useRef)(null),a=(0,x.useRef)(new Map);return{activeDropColumn:i,handleDragStart:(0,x.useCallback)((e,t,i)=>{let s={nodeKey:e,sourceColumnIndex:t};if(r.current=s,i.dataTransfer.setData(rd,JSON.stringify(s)),i.dataTransfer.effectAllowed="move",i.currentTarget instanceof HTMLElement){let e=i.currentTarget.cloneNode(!0);e.style.opacity="0.5",e.style.position="absolute",e.style.top="-9999px",document.body.appendChild(e),i.dataTransfer.setDragImage(e,0,0),requestAnimationFrame(()=>e.remove())}},[]),getColumnDropHandlers:(0,x.useCallback)(e=>({onDragOver:t=>{if(!t.dataTransfer.types.includes(rd))return;t.preventDefault(),t.dataTransfer.dropEffect="move";let i=(a.current.get(e)??0)+1;a.current.set(e,i),s(e)},onDragLeave:t=>{let i=(a.current.get(e)??1)-1;a.current.set(e,i),i<=0&&(a.current.delete(e),s(t=>t===e?null:t))},onDrop:i=>{i.preventDefault(),a.current.clear(),s(null);let n=i.dataTransfer.getData(rd);if(n){try{let s=JSON.parse(n),r=i.currentTarget,a=r.getBoundingClientRect(),l=i.clientY-a.top,o=r.querySelectorAll(":scope > [data-block-key]"),d=o.length;for(let e=0;e<o.length;
4e++){let t=o[e].getBoundingClientRect(),i=t.top-a.top+t.height/2;if(l<i){d=e;break}}t?.(s.nodeKey,e,d)}catch{}r.current=null}}}),[t])}}({columnCount:u,onDropBlock:r?.onDropBlock}),S=(0,x.useMemo)(()=>{let t=m?p:f;return"mobile"===a&&"stack"===e.mobileMode?"1fr":t.map(e=>`${e}fr`).join(" ")},[m,p,f,a,e.mobileMode]);if(0===h.length)return null;let k=S||e.templateColumns||"1fr",w=e.templateColumnsMobile||("keep"===e.mobileMode?k:"1fr"),A={...s?sM:sD,...s&&n?s_:{},...s&&o?s$:{},...s9(e.style),display:"grid",gridTemplateColumns:k,"--grid-template-columns-mobile":w,gap:"1rem",..."mobile"===a&&"scroll"===e.mobileMode?{overflowX:"auto"}:{}};return(0,T.jsxs)("section",{style:A,"data-layout-container":!0,"data-layout-type":"layout-container","data-template-id":e.templateId,"data-column-count":u,"data-mobile-mode":e.mobileMode??"stack",role:s?"group":void 0,"aria-label":s?`Layout com ${u} colunas`:void 0,onMouseEnter:s?()=>l(!0):void 0,onMouseLeave:s?()=>l(!1):void 0,onClick:s?e=>{e.stopPropagation(),d(!0)}:void 0,className:"layout-container",children:[s&&o&&(0,T.jsx)(rs,{onInsertTemplate:r?.onChangeTemplate,onAddColumn:r?.onAddColumn,onRemoveColumn:h.length>1?()=>r?.onRemoveColumn?.(h.length-1):void 0,onDelete:r?.onDeleteContainer,columnCount:u}),h.map((n,l)=>{let o=m?p:f,d="mobile"===a&&"stack"===e.mobileMode?100:o[l]??100/u,c=s?E(l):void 0;return(0,T.jsxs)("div",{style:{position:"relative"},children:[(0,T.jsx)(re,{node:n,macros:t,renderNode:i,width:d,index:l,totalColumns:u,editable:s,isDropTarget:v===l,onDragOver:c?.onDragOver,onDragLeave:c?.onDragLeave,onDrop:c?.onDrop,onMoveBlock:r?.onMoveBlock?(e,t)=>r.onMoveBlock(l,e,t):void 0,onEditBlock:r?.onEditBlock?e=>r.onEditBlock(l,e):void 0}),s&&l<h.length-1&&(0,T.jsx)("div",{style:{...sU,right:-6},role:"separator","aria-orientation":"vertical","aria-label":`Redimensionar entre coluna ${l+1} e ${l+2}`,tabIndex:0,onPointerDown:e=>y(l,e),onKeyDown:e=>{if("ArrowLeft"===e.key||"ArrowRight"===e.key){e.preventDefault();let t="ArrowLeft"===e.key?-1:1;r?.onResizeColumn?.(l,a,f[l]+t)}},children:(0,T.jsx)("div",{style:{...sj,...g===l?sV:{}}})})]},l)})]})},ru=e=>{let{node:t,macros:i,renderNode:s}=e,r=K(t.children);if(!t||"layout-cols"!==t.type||0===r.length)return null;let{totalColsPerLineMobile:a,totalColsPerLineDesktop:n,tagSafeListContainer:l}=t,o=1===a?"grid-cols-1":`grid-cols-${a}`,d=1===n?"md:grid-cols-1":`md:grid-cols-${n}`;return(0,T.jsx)("section",{className:`grid ${l||"gap-4"} ${o} ${d}`,children:r.map((e,t)=>{let r=e.tagSafeListRow||"",a=K(e.children);return(0,T.jsx)("div",{className:r,style:{minWidth:0,maxWidth:"100%",overflow:"hidden"},children:a.map((e,t)=>(0,T.jsx)("div",{children:s?.(e,i)},t))},t)})})},rc=["http:","https:","mailto:","sms:","tel:"],rf=e=>{let{node:t,macros:i,renderNode:s}=e,r=(e=>{if(!e||"#"===e)return"#";if(e.startsWith("/")||e.startsWith("#"))return e;let t=e.toLowerCase();return rc.some(e=>t.startsWith(e))?e:`https://${e}`})(t.fields?.url?.url||t.url||"#"),a=t.fields?.target||t.target,n=t.fields?.rel||t.rel,l=r.startsWith("http"),o="string"==typeof t.textStyle?q(t.textStyle):{},d=K(t.children);return(0,T.jsx)("a",{href:r,style:{...o,display:"inline-block",maxWidth:"100%",overflowWrap:"break-word",wordBreak:"break-word",whiteSpace:"normal"},className:"no-underline hover:opacity-80 transition-opacity",target:a||(l?"_blank":void 0),rel:n||(l?"noopener noreferrer":void 0),children:d.map((e,t)=>(0,T.jsx)(x.Fragment,{children:s?.(e,i)},t))})},rp={"upper-roman":"list-[upper-roman]","lower-roman":"list-[lower-roman]","upper-alpha":"list-[upper-alpha]","lower-alpha":"list-[lower-alpha]"},rm=e=>{let{node:t,macros:i,renderNode:s}=e,r="number"===t.listType?"ol":"ul",a="number"===t.listType?"list-decimal":"list-disc",n="number"===t.listType&&"string"==typeof t.listStyle?rp[t.listStyle]??a:a,l="number"===t.listType&&"string"==typeof t.listStyle?{listStyleType:t.listStyle}:null,o="string"==typeof t.textStyle?q(t.textStyle):{},d=K(t.children);return(0,T.jsx)(r,{style:{...o,...l??{},marginTop:0,marginBottom:0},className:`lexical-list pl-5 md:pl-6 ${n} ${t.horizontal?"lexical-list--horizontal":"space-y-2"} ${t.showBoldMarkers?"lexical-list--bold-markers":""}`,children:d.map((e,t)=>(0,T.jsx)(x.Fragment,{children:s?.(e,i)},t))})},rg=({item:e})=>(0,T.jsx)("div",{style:{overflow:"hidden",borderRadius:6},children:(0,T.jsx)("img",{src:e.s3Url,alt:e.fileName,loading:"lazy",style:{width:"100%",height:"auto",display:"block",objectFit:"cover",aspectRatio:`${e.finalWidth} / ${e.finalHeight}`}},e.s3Url)}),ry=({items:e})=>(0,T.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:8,width:"100%",margin:"16px 0"},children:e.map(e=>(0,T.jsx)(rg,{item:e},e.id))}),rv={backgroundColor:"#ffffff",color:"#111111",paddingY:12,gap:16,maxWidth:"1200px",sticky:!1,bordered:!0}
4,rb={start:{items:[]},center:{items:[]},end:{items:[]}},rE=new Map;function rS({dataKey:e,fetcher:t,children:i}){let s=(0,x.use)(function(e,t){let i;if(typeof window>"u")return t();let s=rE.get(e);if(s)return s;let r=("u">typeof document?document.querySelector(`script[data-ssr-key="${e.replace(/["\\]/g,"\\$&")}"]`):null)?.textContent;if(null!=r&&""!==r)try{i=Promise.resolve(JSON.parse(r))}catch{i=t()}else i=t();return rE.set(e,i),i}(e,t));return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)("script",{type:"application/json","data-ssr-key":e,dangerouslySetInnerHTML:{__html:JSON.stringify(s??null).replace(/</g,"\\u003c")}}),i(s)]})}let rT=({item:e})=>{let t=Array.isArray(e.children)&&e.children.length>0,i=(0,T.jsx)("a",{className:"docplus-menu__link",href:e.path||"#",target:e.isExternal?"_blank":void 0,rel:e.isExternal?"noopener noreferrer":void 0,children:e.name});return t?(0,T.jsxs)("li",{className:"docplus-menu__item docplus-menu__item--has-sub",children:[i,(0,T.jsx)("ul",{className:"docplus-menu__submenu",children:e.children?.map(e=>(0,T.jsx)(rT,{item:e},e.st_menu_id))})]}):(0,T.jsx)("li",{className:"docplus-menu__item",children:i})},rx=({items:e})=>(0,T.jsx)("ul",{className:"docplus-menu__list",children:e.map(e=>(0,T.jsx)(rT,{item:e},e.st_menu_id))}),rk=({element:e,itemsBySite:t})=>{if("logo"===e.type){if(!e.src)return null;let t=(0,T.jsx)("img",{className:"docplus-menu__logo-img",src:e.src,alt:e.alt||"",style:{height:e.height||40}});return e.href?(0,T.jsx)("a",{className:"docplus-menu__logo",href:e.href,children:t}):(0,T.jsx)("span",{className:"docplus-menu__logo",children:t})}return"menu-items"===e.type?(0,T.jsx)(rx,{items:t[e.siteId]||[]}):null},rw=["start","center","end"],rA=({layout:e,container:t,itemsBySite:i})=>{let s={backgroundColor:t.backgroundColor,color:t.color,"--docplus-menu-pad":`${t.paddingY}px`,"--docplus-menu-gap":`${t.gap}px`,"--docplus-menu-maxw":t.maxWidth},r=["docplus-menu",t.sticky&&"docplus-menu--sticky",t.bordered&&"docplus-menu--bordered"].filter(Boolean).join(" ");return(0,T.jsx)("nav",{className:r,style:s,children:(0,T.jsx)("div",{className:"docplus-menu__inner",children:rw.map(t=>(0,T.jsx)("div",{className:`docplus-menu__region docplus-menu__region--${t}`,children:e[t].items.map(e=>(0,T.jsx)(rk,{element:e,itemsBySite:i},e.id))},t))})})};var rR=e.i(94412);let rL=({popup:e})=>{if("youtube"===e.type){let t=(e=>{if(!e)return"";let t=e.match(/(?:youtube\.com\/(?:watch\?v=|embed\/|v\/)|youtu\.be\/)([\w-]{11})/);return t?t[1]:/^[\w-]{11}$/.test(e)?e:""})(e.args?.link||e.link||e.value),i=new URLSearchParams;return e.args?.autoplay&&i.set("autoplay","1"),e.args?.loop&&t&&(i.set("loop","1"),i.set("playlist",t)),e.args?.showControls===!1&&i.set("controls","0"),(0,T.jsx)("iframe",{className:"docplus-popup__yt",src:`https://www.youtube.com/embed/${t}?${i.toString()}`,title:"popup",allow:"autoplay; encrypted-media; fullscreen",allowFullScreen:!0})}let t=e.args?.redirectUrl||e.link,i=e.args?.linkOpenNewTab??e.linkOpenNewTab,s=(0,T.jsx)("img",{className:"docplus-popup__img",src:e.value,alt:""});return t?(0,T.jsx)("a",{href:t,target:i?"_blank":void 0,rel:i?"noopener noreferrer":void 0,children:s}):s},rC=({popup:e,dismissable:t,onClose:i})=>((0,x.useEffect)(()=>{if(!t)return;let e=e=>{"Escape"===e.key&&i()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[t,i]),(0,T.jsx)("div",{className:"docplus-popup__backdrop",role:"dialog","aria-modal":"true",onClick:t?i:void 0,children:(0,T.jsxs)("div",{className:"docplus-popup__box",onClick:e=>e.stopPropagation(),children:[t&&(0,T.jsx)("button",{type:"button",className:"docplus-popup__close",onClick:i,"aria-label":"Fechar",children:"×"}),(0,T.jsx)(rL,{popup:e})]})})),rI=0,rP="daily",rD=!0,rM=e=>{if(!e)return null;let t=Date.parse(e.replace(" ","T"));return Number.isNaN(t)?null:t},r_=(e,t)=>`docplus_popup_${e}_${t}`,r$=()=>new Date().toISOString().slice(0,10),rO=({popup:e,config:t})=>{let[i,s]=(0,x.useState)(!1);return(0,x.useEffect)(()=>{if(!e||!((e,t)=>{if(typeof window>"u")return!1;try{let i=e.st_popup_id;return"once"===t.frequency?null==window.localStorage.getItem(r_(i,"seen")):"daily"!==t.frequency||window.localStorage.getItem(r_(i,"day"))!==r$()}catch{return!0}})(e,t))return;let i=setTimeout(()=>{s(!0),((e,t)=>{if(!(typeof window>"u"))try{let i=e.st_popup_id;"once"===t.frequency&&window.localStorage.setItem(r_(i,"seen"),"1"),"daily"===t.frequency&&window.localStorage.setItem(r_(i,"day"),r$())}catch{}})(e,t)},Math.max(0,t.delayMs));return()=>clearTimeout(i)},[e,t]),e&&i&&!(typeof document>"u")?(0,tL.createPortal)((0,T.jsx)(rC,{popup:e,dismissable:t.dismissable,onClose:()=>s(!1)}),document.body):null},rN=({siteId:e,popupId:t,config:i})=>(0,T.jsx)(rS,{dataKey:`popup-${e}-${t}`,fetcher:()=>fetch(`${rR.ApiUrl}Sites/popup/getAllBySite/${e}`,{method:"POST",headers:{accept:"application/json"},next:{tags:[`popup-${e}`]}}).then(e=>e.json()).then(e=>{let i=e?.success&&Array.isArray(e.data)?e.data:[];if(t>0)return i.find(e=>e.st_popup_id===t)??null;let s=Date.now();return i.find(e=>((e,t)=>{if(!1===e.status||!1===e.isPublished)return!1;let i=rM(e.date_start),s=rM(e.date_end);return!(null!==i&&t<i||null!==s&&t>s)})(e,s))??null}).catch(()=>null),children:e=>(0,T.jsx)(rO,{popup:e,config:i})}),rF={left:"flex-start",center:"center",right:"flex-end"},rB=()=>
4(0,T.jsx)("div",{"aria-hidden":!0,className:"h-full w-full animate-pulse rounded-md bg-neutral-200/70 dark:bg-white/5"}),rU=(0,te.default)(()=>e.A(16686).then(e=>e.RdkitMolecule),{ssr:!1,loading:()=>(0,T.jsx)(rB,{})}),rj=({smiles:e,name:t,inline:i=!1,monochrome:s=!1,width:r,height:a,rotation:n=0,flipHorizontal:l=!1,flipVertical:o=!1,alignment:d="center",onDoubleClick:h})=>{let u=r??(i?120:250),c=a??(i?90:200),f=90===n||270===n,p=f?c:u,m=f?u:c,g=`rotate(${n}deg) scaleX(${l?-1:1}) scaleY(${o?-1:1})`,y=i?void 0:{display:"flex",justifyContent:rF[d]};return(0,T.jsx)("div",{className:`rdkit-molecule ${i?"rdkit-molecule--inline":""}`,onDoubleClick:h,role:"img","aria-label":t||e,style:{display:i?"inline-block":"block",...y},children:(0,T.jsxs)("div",{style:{display:"inline-block"},children:[(0,T.jsx)("div",{style:{width:p,height:m,display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden"},children:(0,T.jsx)("div",{style:{width:u,height:c,transform:g,transformOrigin:"center center"},children:(0,T.jsx)(rU,{smiles:e,width:u,height:c,monochrome:s})})}),t&&!i?(0,T.jsx)("span",{className:"rdkit-molecule__name",style:{display:"block",textAlign:"center"},children:t}):null]})})},rV=({config:e})=>{let t={"--docplus-ss-desktop":e.aspectRatioDesktop,"--docplus-ss-mobile":e.aspectRatioMobile};return(0,T.jsx)("div",{className:"docplus-slideshow__skeleton",style:t,"aria-hidden":"true"})};var rG=e.i(70960);let rq=({slides:e,config:t})=>(0,T.jsx)("div",{className:"docplus-slideshow docplus-slideshow--static",children:e.map((e,i)=>(0,T.jsx)("div",{className:"docplus-slideshow__item",children:(0,T.jsx)(rG.SlideImage,{slide:e,aspectRatioDesktop:t.aspectRatioDesktop,aspectRatioMobile:t.aspectRatioMobile,eager:0===i})},e.id))}),rH="slide",rK=500,rW=!0,rz=!0,rY=5e3,rQ=!0,rX=!0,rJ=!0,rZ="bullets",r0=!1,r1=!1,r2=!1,r5=!0,r3=!1,r4=1,r8=0,r6="1920 / 500",r7="1 / 1",r9=e=>{if(!e)return null;let t=Date.parse(e.replace(" ","T"));return Number.isNaN(t)?null:t},ae=e=>({id:String(e.id),imgLarge:e.imgLarge||e.img||e.imgMobile,imgMobile:e.imgMobile||e.imgLarge||e.img,url:e.url??"",isTargetBlank:!!e.isTargetBlank,alt:e.text??""}),at=(0,x.lazy)(()=>e.A(88888)),ai=({slides:e,config:t})=>{let[i,s]=(0,x.useState)(!1);if((0,x.useEffect)(()=>{s(!0)},[]),!e.length)return null;let r=(0,T.jsx)(rq,{slides:e,config:t});return i?(0,T.jsx)(x.Suspense,{fallback:r,children:(0,T.jsx)(at,{slides:e,config:t})}):r},as=({siteId:e,slideIds:t,config:i})=>{let s=`slideshow-${e}-${t.length?t.join("."):"auto"}`;return(0,T.jsx)(rS,{dataKey:s,fetcher:()=>((e,t=[])=>fetch(`${rR.ApiUrl}Sites/slideshow/getAll/${e}`,{method:"POST",headers:{accept:"application/json"},next:{tags:[`slider-${e}`]}}).then(e=>e.json()).then(e=>{let i,s=e?.success&&Array.isArray(e.data)?e.data:[];if(t.length){let e=new Map(s.map(e=>[e.id,e]));return t.map(t=>e.get(t)).filter(e=>!!e).map(ae)}return(i=Date.now(),s.filter(e=>{let t=r9(e.date_hour_start),s=r9(e.date_hour_end);return!(null!==t&&i<t||null!==s&&i>s)})).map(ae)}).catch(()=>[]))(e,t),children:e=>(0,T.jsx)(ai,{slides:e,config:i})})},ar=["left","right","center","justify"],aa=(e,t,i,s,r=!1,a=!1)=>{let n,l;if("paragraph"!==e.type)return i?.(e,t);let o="string"==typeof e.textStyle?q(e.textStyle):{};return(0,T.jsx)("p",{style:{margin:a?0:r?"2px 0 0":"6px 0 0",lineHeight:r?1.45:1.55,textAlign:(n=e.format,"string"==typeof n&&ar.includes(n)?n:s),...o},children:(l=K(e.children)).length?l.map((e,s)=>(0,T.jsx)(x.Fragment,{children:i?.(e,t)},s)):(0,T.jsx)("br",{})})},an={1:"bold",2:"italic",4:"strikethrough",8:"underline",16:"code",32:"subscript",64:"superscript",128:"highlight",256:"lowercase",512:"uppercase",1024:"capitalize"},al={bold:{tag:"strong",className:"docplus-text-bold"},italic:{tag:"em",className:"docplus-text-italic"},strikethrough:{tag:"del",className:"docplus-text-strikethrough"},underline:{tag:"u",className:"docplus-text-underline"},code:{tag:"code",className:"docplus-text-code"},subscript:{tag:"sub",className:"docplus-text-subscript"},superscript:{tag:"sup",className:"docplus-text-superscript"}},ao=({tweetID:e,loadingComponent:t,onLoad:i,onError:s})=>{let r=(0,x.useRef)(null),a=(0,x.useRef)(""),[n,l]=(0,x.useState)(!1),o=(0,x.useCallback)(async()=>{try{if("u">typeof window){let t=window.twttr;t?.widgets?.createTweet&&r.current&&await t.widgets.createTweet(e,r.current)}l(!1),i?.()}catch(e){s?.(String(e))}},[s,i,e]);return(0,x.useEffect)(()=>
4{if(!e||e===a.current)return;if(a.current=e,l(!0),"u">typeof window&&window.twttr?.widgets)return void o();let t=document.createElement("script");t.src="https://platform.twitter.com/widgets.js",t.async=!0,t.onload=o,s&&(t.onerror=()=>s("Falha ao carregar o widgets.js do X/Twitter")),document.body?.appendChild(t)},[o,s,e]),(0,T.jsxs)("div",{className:"docplus-tweet",children:[n?t:null,(0,T.jsx)("div",{style:{display:"inline-block",width:"550px"},ref:r})]})},ad={small:"clamp(280px, 40%, 960px)",medium:"clamp(280px, 65%, 960px)",large:"clamp(280px, 85%, 960px)",full:"100%"};e.i(92537);var ah=e.i(85653),au=ah,ac=e.i(3476);let af=Math.min,ap=Math.max,am=Math.round,ag=Math.floor,ay=e=>({x:e,y:e}),av={left:"right",right:"left",bottom:"top",top:"bottom"};function ab(e,t){return"function"==typeof e?e(t):e}function aE(e){return e.split("-")[0]}function aS(e){return e.split("-")[1]}function aT(e){return"x"===e?"y":"x"}function ax(e){return"y"===e?"height":"width"}function ak(e){let t=e[0];return"t"===t||"b"===t?"y":"x"}function aw(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}let aA=["left","right"],aR=["right","left"],aL=["top","bottom"],aC=["bottom","top"];function aI(e){let t=aE(e);return av[t]+e.slice(t.length)}function aP(e){let{x:t,y:i,width:s,height:r}=e;return{width:s,height:r,top:i,left:t,right:t+s,bottom:i+r,x:t,y:i}}function aD(e,t,i){let s,{reference:r,floating:a}=e,n=ak(t),l=aT(ak(t)),o=ax(l),d=aE(t),h="y"===n,u=r.x+r.width/2-a.width/2,c=r.y+r.height/2-a.height/2,f=r[o]/2-a[o]/2;switch(d){case"top":s={x:u,y:r.y-a.height};break;case"bottom":s={x:u,y:r.y+r.height};break;case"right":s={x:r.x+r.width,y:c};break;case"left":s={x:r.x-a.width,y:c};break;default:s={x:r.x,y:r.y}}switch(aS(t)){case"start":s[l]-=f*(i&&h?-1:1);break;case"end":s[l]+=f*(i&&h?-1:1)}return s}async function aM(e,t){var i,s;void 0===t&&(t={});let{x:r,y:a,platform:n,rects:l,elements:o,strategy:d}=e,{boundary:h="clippingAncestors",rootBoundary:u="viewport",elementContext:c="floating",altBoundary:f=!1,padding:p=0}=ab(t,e),m="number"!=typeof(s=p)?{top:0,right:0,bottom:0,left:0,...s}:{top:s,right:s,bottom:s,left:s},g=o[f?"floating"===c?"reference":"floating":c],y=aP(await n.getClippingRect({element:null==(i=await (null==n.isElement?void 0:n.isElement(g)))||i?g:g.contextElement||await (null==n.getDocumentElement?void 0:n.getDocumentElement(o.floating)),boundary:h,rootBoundary:u,strategy:d})),v="floating"===c?{x:r,y:a,width:l.floating.width,height:l.floating.height}:l.reference,b=await (null==n.getOffsetParent?void 0:n.getOffsetParent(o.floating)),E=await (null==n.isElement?void 0:n.isElement(b))&&await (null==n.getScale?void 0:n.getScale(b))||{x:1,y:1},S=aP(n.convertOffsetParentRelativeRectToViewportRelativeRect?await n.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:v,offsetParent:b,strategy:d}):v);return{top:(y.top-S.top+m.top)/E.y,bottom:(S.bottom-y.bottom+m.bottom)/E.y,left:(y.left-S.left+m.left)/E.x,right:(S.right-y.right+m.right)/E.x}}let a_=async(e,t,i)=>{let{placement:s="bottom",strategy:r="absolute",middleware:a=[],platform:n}=i,l=n.detectOverflow?n:{...n,detectOverflow:aM},o=await (null==n.isRTL?void 0:n.isRTL(t)),d=await n.getElementRects({reference:e,floating:t,strategy:r}),{x:h,y:u}=aD(d,s,o),c=s,f=0,p={};for(let i=0;i<a.length;i++){let m=a[i];if(!m)continue;let{name:g,fn:y}=m,{x:v,y:b,data:E,reset:S}=await y({x:h,y:u,initialPlacement:s,placement:c,strategy:r,middlewareData:p,rects:d,platform:l,elements:{reference:e,floating:t}});h=null!=v?v:h,u=null!=b?b:u,p[g]={...p[g],...E},S&&f<50&&(f++,"object"==typeof S&&(S.placement&&(c=S.placement),S.rects&&(d=!0===S.rects?await n.getElementRects({reference:e,floating:t,strategy:r}):S.rects),{x:h,y:u}=aD(d,c,o)),i=-1)}return{x:h,y:u,placement:c,strategy:r,middlewareData:p}};function a$(){return"u">typeof window}function aO(e){return aB(e)?(e.nodeName||"").toLowerCase():"#document"}function aN(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}function aF(e){var t;return null==(t=(aB(e)?e.ownerDocument:e.document)||window.document)?void 0:t.documentElement}function aB(e){return!!a$()&&(e instanceof Node||e instanceof aN(e).Node)}function aU(e){return!!a$()&&(e instanceof Element||e instanceof aN(e).Element)}function aj(e){return!!a$()&&(e instanceof HTMLElement||e instanceof aN(e).HTMLElement)}function aV(e){return!(!a$()||"u"<typeof ShadowRoot)&&(e instanceof ShadowRoot||e instanceof aN(e).ShadowRoot)}function aG(e){let{overflow:t,overflowX:i,overflowY:s,display:r}=aX(e);return/auto|scroll|overlay|hidden|clip/.test(t+s+i)&&"inline"!==r&&"contents"!==r}function aq(e){try{if(e.matches(":popover-open"))return!0}catch(e){}try{return e.matches(":modal")}catch(e){return!1}}let aH=/transform|translate|scale|rotate|perspective|filter/,aK=/paint|layout|strict|content/,aW=e=>!!e&&"none"!==e;function az(e){let t=aU(e)?aX(e):e;return aW(t.transform)||aW(t.translate)||aW(t.scale)||aW(t.rotate)||aW(t.perspective)||!aY()&&(aW(t.backdropFilter)||aW(t.filter))||aH.test(t.willChange||"")||aK.test(t.contain||"")}function aY(){return null==t&&(t="u">typeof CSS&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),t}function aQ(e){return/^(html|body|#document)$/.test(aO(e))}function aX(e){return aN(e).getComputedStyle(e)}function aJ(e){return aU(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function aZ(e){if("html"===aO(e))return e;let t=e.assignedSlot||e.parentNode||aV(e)&&e.host||aF(e);return aV(t)?t.host:t}function a0(e,t,i){var s;void 0===t&&(t=[]),void 0===i&&(i=!0);let r=function e(t){let i=aZ(t);return aQ(i)?t.ownerDocument?t.ownerDocument.body:t.body:aj(i)&&aG(i)?i:e(i)}(e),a=r===(null==(s=e.ownerDocument)?void 0:s.body),n=aN(r);if(!a)return t.concat(r,a0(r,[],i));{let e=a1(n);
4return t.concat(n,n.visualViewport||[],aG(r)?r:[],e&&i?a0(e):[])}}function a1(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function a2(e){let t=aX(e),i=parseFloat(t.width)||0,s=parseFloat(t.height)||0,r=aj(e),a=r?e.offsetWidth:i,n=r?e.offsetHeight:s,l=am(i)!==a||am(s)!==n;return l&&(i=a,s=n),{width:i,height:s,$:l}}function a5(e){return aU(e)?e:e.contextElement}function a3(e){let t=a5(e);if(!aj(t))return ay(1);let i=t.getBoundingClientRect(),{width:s,height:r,$:a}=a2(t),n=(a?am(i.width):i.width)/s,l=(a?am(i.height):i.height)/r;return n&&Number.isFinite(n)||(n=1),l&&Number.isFinite(l)||(l=1),{x:n,y:l}}let a4=ay(0);function a8(e){let t=aN(e);return aY()&&t.visualViewport?{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}:a4}function a6(e,t,i,s){var r;void 0===t&&(t=!1),void 0===i&&(i=!1);let a=e.getBoundingClientRect(),n=a5(e),l=ay(1);t&&(s?aU(s)&&(l=a3(s)):l=a3(e));let o=(void 0===(r=i)&&(r=!1),s&&(!r||s===aN(n))&&r)?a8(n):ay(0),d=(a.left+o.x)/l.x,h=(a.top+o.y)/l.y,u=a.width/l.x,c=a.height/l.y;if(n){let e=aN(n),t=s&&aU(s)?aN(s):s,i=e,r=a1(i);for(;r&&s&&t!==i;){let e=a3(r),t=r.getBoundingClientRect(),s=aX(r),a=t.left+(r.clientLeft+parseFloat(s.paddingLeft))*e.x,n=t.top+(r.clientTop+parseFloat(s.paddingTop))*e.y;d*=e.x,h*=e.y,u*=e.x,c*=e.y,d+=a,h+=n,r=a1(i=aN(r))}}return aP({width:u,height:c,x:d,y:h})}function a7(e,t){let i=aJ(e).scrollLeft;return t?t.left+i:a6(aF(e)).left+i}function a9(e,t){let i=e.getBoundingClientRect();return{x:i.left+t.scrollLeft-a7(e,i),y:i.top+t.scrollTop}}function ne(e,t,i){var s;let r;if("viewport"===t)r=function(e,t){let i=aN(e),s=aF(e),r=i.visualViewport,a=s.clientWidth,n=s.clientHeight,l=0,o=0;if(r){a=r.width,n=r.height;let e=aY();(!e||e&&"fixed"===t)&&(l=r.offsetLeft,o=r.offsetTop)}let d=a7(s);if(d<=0){let e=s.ownerDocument,t=e.body,i=getComputedStyle(t),r="CSS1Compat"===e.compatMode&&parseFloat(i.marginLeft)+parseFloat(i.marginRight)||0,n=Math.abs(s.clientWidth-t.clientWidth-r);n<=25&&(a-=n)}else d<=25&&(a+=d);return{width:a,height:n,x:l,y:o}}(e,i);else if("document"===t){let t,i,a,n,l,o,d;s=aF(e),t=aF(s),i=aJ(s),a=s.ownerDocument.body,n=ap(t.scrollWidth,t.clientWidth,a.scrollWidth,a.clientWidth),l=ap(t.scrollHeight,t.clientHeight,a.scrollHeight,a.clientHeight),o=-i.scrollLeft+a7(s),d=-i.scrollTop,"rtl"===aX(a).direction&&(o+=ap(t.clientWidth,a.clientWidth)-n),r={width:n,height:l,x:o,y:d}}else if(aU(t)){let e,s,a,n,l,o;s=(e=a6(t,!0,"fixed"===i)).top+t.clientTop,a=e.left+t.clientLeft,n=aj(t)?a3(t):ay(1),l=t.clientWidth*n.x,o=t.clientHeight*n.y,r={width:l,height:o,x:a*n.x,y:s*n.y}}else{let i=a8(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return aP(r)}function nt(e){return"static"===aX(e).position}function ni(e,t){if(!aj(e)||"fixed"===aX(e).position)return null;if(t)return t(e);let i=e.offsetParent;return aF(e)===i&&(i=i.ownerDocument.body),i}function ns(e,t){var i;let s=aN(e);if(aq(e))return s;if(!aj(e)){let t=aZ(e);for(;t&&!aQ(t);){if(aU(t)&&!nt(t))return t;t=aZ(t)}return s}let r=ni(e,t);for(;r&&(i=r,/^(table|td|th)$/.test(aO(i)))&&nt(r);)r=ni(r,t);return r&&aQ(r)&&nt(r)&&!az(r)?s:r||function(e){let t=aZ(e);for(;aj(t)&&!aQ(t);){if(az(t))return t;if(aq(t))break;t=aZ(t)}return null}(e)||s}let nr=async function(e){let t=this.getOffsetParent||ns,i=this.getDimensions,s=await i(e.floating);return{reference:function(e,t,i){let s=aj(t),r=aF(t),a="fixed"===i,n=a6(e,!0,a,t),l={scrollLeft:0,scrollTop:0},o=ay(0);if(s||!s&&!a)if(("body"!==aO(t)||aG(r))&&(l=aJ(t)),s){let e=a6(t,!0,a,t);o.x=e.x+t.clientLeft,o.y=e.y+t.clientTop}else r&&(o.x=a7(r));a&&!s&&r&&(o.x=a7(r));let d=!r||s||a?ay(0):a9(r,l);return{x:n.left+l.scrollLeft-o.x-d.x,y:n.top+l.scrollTop-o.y-d.y,width:n.width,height:n.height}}(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}},na={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:t,rect:i,offsetParent:s,strategy:r}=e,a="fixed"===r,n=aF(s),l=!!t&&aq(t.floating);if(s===n||l&&a)return i;let o={scrollLeft:0,scrollTop:0},d=ay(1),h=ay(0),u=aj(s);if((u||!u&&!a)&&(("body"!==aO(s)||aG(n))&&(o=aJ(s)),u)){let e=a6(s);d=a3(s),h.x=e.x+s.clientLeft,h.y=e.y+s.clientTop}let c=!n||u||a?ay(0):a9(n,o);return{width:i.width*d.x,height:i.height*d.y,x:i.x*d.x-o.scrollLeft*d.x+h.x+c.x,y:i.y*d.y-o.scrollTop*d.y+h.y+c.y}},getDocumentElement:aF,getClippingRect:function(e){let{element:t,boundary:i,rootBoundary:s,strategy:r}=e,a=[..."clippingAncestors"===i?aq(t)?[]:function(e,t){let i=t.get(e);if(i)return i;let s=a0(e,[],!1).filter(e=>aU(e)&&"body"!==aO(e)),r=null,a="fixed"===aX(e).position,n=a?aZ(e):e;for(;aU(n)&&!aQ(n);){let t=aX(n),i=az(n);i||"fixed"!==t.position||(r=null),(a?i||r:!(!i&&"static"===t.position&&r&&("absolute"===r.position||"fixed"===r.position)||aG(n)&&!i&&function e(t,i){let s=aZ(t);
4return!(s===i||!aU(s)||aQ(s))&&("fixed"===aX(s).position||e(s,i))}(e,n)))?r=t:s=s.filter(e=>e!==n),n=aZ(n)}return t.set(e,s),s}(t,this._c):[].concat(i),s],n=ne(t,a[0],r),l=n.top,o=n.right,d=n.bottom,h=n.left;for(let e=1;e<a.length;e++){let i=ne(t,a[e],r);l=ap(i.top,l),o=af(i.right,o),d=af(i.bottom,d),h=ap(i.left,h)}return{width:o-h,height:d-l,x:h,y:l}},getOffsetParent:ns,getElementRects:nr,getClientRects:function(e){return Array.from(e.getClientRects())},getDimensions:function(e){let{width:t,height:i}=a2(e);return{width:t,height:i}},getScale:a3,isElement:aU,isRTL:function(e){return"rtl"===aX(e).direction}};function nn(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function nl(e){return!(0,au.isString)(e)&&"width"in e&&"height"in e&&(0,au.isNumber)(e.width)&&(0,au.isNumber)(e.height)}let no=new au.State({artist:"",artwork:null,audioTrack:null,audioTracks:[],autoPlay:!1,autoPlayError:null,audioGain:null,buffered:new ac.TimeRange,canLoad:!1,canLoadPoster:!1,canFullscreen:!1,canOrientScreen:(0,ac.canOrientScreen)(),canPictureInPicture:!1,canPlay:!1,clipStartTime:0,clipEndTime:0,controls:!1,get iOSControl
4s(){return ac.IS_IPHONE&&"video"===this.mediaType&&(!this.playsInline||!au.fscreen.fullscreenEnabled&&this.fullscreen)},get nativeControls(){return this.controls||this.iOSControls},controlsVisible:!1,get controlsHidden(){return!this.controlsVisible},crossOrigin:null,ended:!1,error:null,fullscreen:!1,get loop(){return this.providedLoop||this.userPrefersLoop},logLevel:"silent",mediaType:"unknown",muted:!1,paused:!0,played:new ac.TimeRange,playing:!1,playsInline:!1,pictureInPicture:!1,preload:"metadata",playbackRate:1,qualities:[],quality:null,autoQuality:!1,canSetQuality:!0,canSetPlaybackRate:!0,canSetVolume:!1,canSetAudioGain:!1,seekable:new ac.TimeRange,seeking:!1,source:{src:"",type:""},sources:[],started:!1,textTracks:[],textTrack:null,get hasCaptions(){return this.textTracks.filter(ac.isTrackCaptionKind).length>0},volume:1,waiting:!1,realCurrentTime:0,get currentTime(){return this.ended?this.duration:this.clipStartTime>0?Math.max(0,Math.min(this.realCurrentTime-this.clipStartTime,this.duration)):this.realCurrentTime},providedDuration:-1,intrinsicDuration:0,get duration(){return this.seekableWindow},get title(){return this.providedTitle||this.inferredTitle},get poster(){return this.providedPoster||this.inferredPoster},get viewType(){return"unknown"!==this.providedViewType?this.providedViewType:this.inferredViewType},get streamType(){return"unknown"!==this.providedStreamType?this.providedStreamType:this.inferredStreamType},get currentSrc(){return this.source},get bufferedStart(){return Math.max((0,ac.getTimeRangesStart)(this.buffered)??0,this.clipStartTime)},get bufferedEnd(){let e=(0,ac.getTimeRangesEnd)(this.buffered)??0;return Math.min(this.seekableEnd,Math.max(0,e-this.clipStartTime))},get bufferedWindow(){return Math.max(0,this.bufferedEnd-this.bufferedStart)}
4,get seekableStart(){if(this.isLiveDVR&&this.liveDVRWindow>0)return Math.max(0,this.seekableEnd-this.liveDVRWindow);return Math.max((0,ac.getTimeRangesStart)(this.seekable)??0,this.clipStartTime)},get seekableEnd(){if(this.providedDuration>0)return this.providedDuration;let e=this.liveSyncPosition>0?this.liveSyncPosition:this.canPlay?(0,ac.getTimeRangesEnd)(this.seekable)??1/0:0;return this.clipEndTime>0?Math.min(this.clipEndTime,e):e},get seekableWindow(){let e=this.seekableEnd-this.seekableStart;return isNaN(e)?1/0:Math.max(0,e)},canAirPlay:!1,canGoogleCast:!1,remotePlaybackState:"disconnected",remotePlaybackType:"none",remotePlaybackLoader:null,remotePlaybackInfo:null,get isAirPlayConnected(){return"airplay"===this.remotePlaybackType&&"connected"===this.remotePlaybackState},get isGoogleCastConnected(){return"google-cast"===this.remotePlaybackType&&"connected"===this.remotePlaybackState},pointer:"fine",orientation:"landscape",width:0,height:0,mediaWidth:0,mediaHeight:0,lastKeyboardAction:null,userBehindLiveEdge:!1,liveEdgeTolerance:10,minLiveDVRWindow:60,get canSeek(){return/unknown|on-demand|:dvr/.test(this.streamType)&&Number.isFinite(this.duration)&&(!this.isLiveDVR||this.duration>=this.liveDVRWindow)},get live(){return this.streamType.includes("live")||!Number.isFinite(this.duration)},get liveEdgeStart(){return this.live&&Number.isFinite(this.seekableEnd)?Math.max(0,this.seekableEnd-this.liveEdgeTolerance):0},get liveEdge(){return this.live&&(!this.canSeek||!this.userBehindLiveEdge&&this.currentTime>=this.liveEdgeStart)},get liveEdgeWindow(){return this.live&&Number.isFinite(this.seekableEnd)?this.seekableEnd-this.liveEdgeStart:0},get isLiveDVR(){return/:dvr/.test(this.streamType)},get liveDVRWindow(){return Math.max(this.inferredLiveDVRWindow,this.minLiveDVRWindow)},autoPlaying:!1,providedTitle:"",inferredTitle:"",providedLoop:!1,userPrefersLoop:!1,providedPoster:"",inferredPoster:"",inferredViewType:"unknown",providedViewType:"unknown",providedStreamType:"unknown",inferredStreamType:"unknown",liveSyncPosition:null,inferredLiveDVRWindow:0,savedState:null}),nd=new Set(["autoPlayError","autoPlaying","buffered","canPlay","error","paused","played","playing","seekable","seeking","waiting"]),nh=new Set([...nd,"ended","inferredPoster","inferredStreamType","inferredTitle","intrinsicDuration","inferredLiveDVRWindow","liveSyncPosition","realCurrentTime","savedState","started","userBehindLiveEdge"]);function nu(e,t=!1){let i=t?nd:nh;no.reset(e,e=>i.has(e)),(0,au.tick)()}function nc(e,t){let i=e+t.clipStartTime(),s=i<=t.seekableStart(),r=i>=t.seekableEnd();return s?t.seekableStart():r?t.seekableEnd():t.isLiveDVR()&&t.liveDVRWindow()>0&&i<t.seekableEnd()-t.liveDVRWindow()?t.bufferedStart():Math.min(Math.max(t.seekableStart()+.1,i),t.seekableEnd()-.1)}let nf=(0,au.createContext)();function np(){return(0,au.useContext)(nf)}Symbol(0);var nm=class{#e=null;#t=null;#i=-1;#s;constructor(e){this.#s=e}setTarget(e){this.#e=e}getPlayer(e){return this.#t||(e??this.#e)?.dispatchEvent(new au.DOMEvent("find-media-player",{detail:e=>void(this.#t=e),bubbles:!0,composed:!0})),this.#t}setPlayer(e){this.#t=e}startLoading(e){this.#r("media-start-loading",e)}startLoadingPoster(e){this.#r("media-poster-start-loading",e)}requestAirPlay(e){this.#r("media-airplay-request",e)}requestGoogleCast(e){this.#r("media-google-cast-request",e)}play(e){this.#r("media-play-request",e)}pause(e){this.#r("media-pause-request",e)}mute(e){this.#r("media-mute-request",e)}unmute(e){this.#r("media-unmute-request",e)}enterFullscreen(e,t){this.#r("media-enter-fullscreen-request",t,e)}exitFullscreen(e,t){this.#r("media-exit-fullscreen-request",t,e)}lockScreenOrientation(e,t){this.#r("media-orientation-lock-request",t,e)}unlockScreenOrientation(e){this.#r("media-orientation-unlock-request",e)}enterPictureInPicture(e){this.#r("media-enter-pip-request",e)}exitPictureInPicture(e){this.#r("media-exit-pip-request",e)}seeking(e,t){this.#r("media-seeking-request",t,e)}seek(e,t){this.#r("media-seek-request",t,e)}seekToLiveEdge(e){this.#r("media-live-edge-request",e)}changeDuration(e,t){this.#r("media-duration-change-request",t,e)}changeClipStart(e,t){this.#r("media-clip-start-change-request",t,e)}changeClipEnd(e,t){this.#r("media-clip-end-change-request",t,e)}changeVolume(e,t){this.#r("media-volume-change-request",t,Math.max(0,Math.min(1,e)))}changeAudioTrack(e,t){this.#r("media-audio-track-change-request",t,e)}changeQuality(e,t){this.#r("media-quality-change-request",t,e)}requestAutoQuality(e){this.changeQuality(-1,e)}changeTextTrackMode(e,t,i){this.#r("media-text-track-change-request",i,{index:e,mode:t})}changePlaybackRate(e,t){this.#r("media-rate-change-request",t,e)}changeAudioGain(e,t){this.#r("media-audio-gain-change-request",t,e)}
4resumeControls(e){this.#r("media-resume-controls-request",e)}pauseControls(e){this.#r("media-pause-controls-request",e)}togglePaused(e){let t=this.getPlayer(e?.target);t&&(t.state.paused?this.play(e):this.pause(e))}toggleControls(e){let t=this.getPlayer(e?.target);t&&(t.controls.showing?t.controls.hide(0,e):t.controls.show(0,e))}toggleMuted(e){let t=this.getPlayer(e?.target);t&&(t.state.muted?this.unmute(e):this.mute(e))}toggleFullscreen(e,t){let i=this.getPlayer(t?.target);i&&(i.state.fullscreen?this.exitFullscreen(e,t):this.enterFullscreen(e,t))}togglePictureInPicture(e){let t=this.getPlayer(e?.target);t&&(t.state.pictureInPicture?this.exitPictureInPicture(e):this.enterPictureInPicture(e))}showCaptions(e){let t=this.getPlayer(e?.target);if(!t)return;let i=t.state.textTracks,s=this.#i;i[s]&&(0,ac.isTrackCaptionKind)(i[s])||(s=-1),-1===s&&(s=i.findIndex(e=>(0,ac.isTrackCaptionKind)(e)&&e.default)),-1===s&&(s=i.findIndex(e=>(0,ac.isTrackCaptionKind)(e))),s>=0&&this.changeTextTrackMode(s,"showing",e),this.#i=-1}disableCaptions(e){let t=this.getPlayer(e?.target);if(!t)return;let i=t.state.textTracks,s=t.state.textTrack;if(s){let t=i.indexOf(s);this.changeTextTrackMode(t,"disabled",e),this.#i=t}}toggleCaptions(e){let t=this.getPlayer(e?.target);t&&(t.state.textTrack?this.disableCaptions():this.showCaptions())}userPrefersLoopChange(e,t){this.#r("media-user-loop-change-request",t,e)}#r(e,t,i){let s=new au.DOMEvent(e,{bubbles:!0,composed:!0,cancelable:!0,detail:i,trigger:t}),r=t?.target||null;r&&r instanceof au.Component&&(r=r.el),r=!r||r===document||r===window||r===document.body||this.#t?.el&&r instanceof Node&&!this.#t.el.contains(r)?this.#e??this.getPlayer()?.el:r??this.#e,this.#t&&("media-play-request"!==e||this.#t.state.canLoad)?this.#t.canPlayQueue.enqueue(e,()=>r?.dispatchEvent(s)):r?.dispatchEvent(s)}#a(e){}},ng=class{playerId="vds-player";mediaId=null;#n={volume:null,muted:null,audioGain:null,time:null,lang:null,captions:null,rate:null,quality:null};async getVolume(){return this.#n.volume}async setVolume(e){this.#n.volume=e,this.save()}async getMuted(){return this.#n.muted}async setMuted(e){this.#n.muted=e,this.save()}async getTime(){return this.#n.time}async setTime(e,t){let i=e<0;this.#n.time=i?null:e,i||t?this.saveTime():this.saveTimeThrottled()}async getLang(){return this.#n.lang}async setLang(e){this.#n.lang=e,this.save()}async getCaptions(){return this.#n.captions}async setCaptions(e){this.#n.captions=e,this.save()}async getPlaybackRate(){return this.#n.rate}async setPlaybackRate(e){this.#n.rate=e,this.save()}async getAudioGain(){return this.#n.audioGain}async setAudioGain(e){this.#n.audioGain=e,this.save()}async getVideoQuality(){return this.#n.quality}async setVideoQuality(e){this.#n.quality=e,this.save()}onChange(e,t,i="vds-player"){let s=i?localStorage.getItem(i):null,r=t?localStorage.getItem(t):null;this.playerId=i,this.mediaId=t,this.#n={volume:null,muted:null,audioGain:null,lang:null,captions:null,rate:null,quality:null,...s?JSON.parse(s):{},time:r?+r:null}}save(){if(ac.IS_SERVER||!this.playerId)return;let e=JSON.stringify({...this.#n,time:void 0});localStorage.setItem(this.playerId,e)}saveTimeThrottled=(0,au.functionThrottle)(this.saveTime.bind(this),1e3);saveTime(){if(ac.IS_SERVER||!this.mediaId)return;let e=(this.#n.time??0).toString();localStorage.setItem(this.mediaId,e)}},ny=class extends au.EventsTarget{items=[];[ac.ListSymbol.readonly]=!1;get length(){return this.items.length}get readonly(){return this[ac.ListSymbol.readonly]}indexOf(e){return this.items.indexOf(e)}getById(e){return""===e?null:this.items.find(t=>t.id===e)??null}toArray(){return[...this.items]}[Symbol.iterator](){return this.items.values()}[ac.ListSymbol.add](e,t){let i=this.items.length;""+i in this||Object.defineProperty(this,i,{get(){return this.items[i]}}),this.items.includes(e)||(this.items.push(e),this.dispatchEvent(new au.DOMEvent("add",{detail:e,trigger:t})))}[ac.ListSymbol.remove](e,t){let i=this.items.indexOf(e);i>=0&&(this[ac.ListSymbol.onRemove]?.(e,t),this.items.splice(i,1),this.dispatchEvent(new au.DOMEvent("remove",{detail:e,trigger:t})))}[ac.ListSymbol.reset](e){for(let t of[...this.items])this[ac.ListSymbol.remove](t,e);this.items=[],this[ac.ListSymbol.setReadonly](!1,e),this[ac.ListSymbol.onReset]?.()}[ac.ListSymbol.setReadonly](e,t){this[ac.ListSymbol.readonly]!==e&&(this[ac.ListSymbol.readonly]=e,this.dispatchEvent(new au.DOMEvent("readonly-change",{detail:e,trigger:t})))}};let nv=Symbol(0);var nb=class extends ny{get selected(){return this.items.find(e=>e.selected)??null}get selectedIndex(){return this.items.findIndex(e=>e.selected)}[ac.ListSymbol.onRemove](e,t){this[ac.ListSymbol.select](e,!1,t)}[ac.ListSymbol.add](e,t){e[nv]=!1,Object.defineProperty(e,"selected",{get(){return this[nv]},set:t=>
4{this.readonly||(this[ac.ListSymbol.onUserSelect]?.(),this[ac.ListSymbol.select](e,t))}}),super[ac.ListSymbol.add](e,t)}[ac.ListSymbol.select](e,t,i){if(t===e?.[nv])return;let s=this.selected;e&&(e[nv]=t),(t?s!==e:s===e)&&(s&&(s[nv]=!1),this.dispatchEvent(new au.DOMEvent("change",{detail:{prev:s,current:this.selected},trigger:i})))}},nE=class extends nb{};function nS(e,t){let i=t.composedPath()[0];return(0,au.isDOMNode)(i)&&e.contains(i)}let nT=new Set;function nx(e,t,i){e.hasAttribute(t)||e.setAttribute(t,i)}function nk(e,t){if(!(e.hasAttribute("aria-label")||e.hasAttribute("data-no-label"))){if(!(0,au.isFunction)(t))return void(0,au.setAttribute)(e,"aria-label",t);ac.IS_SERVER?i():(0,au.effect)(i)}function i(){(0,au.setAttribute)(e,"aria-label",t())}}function nw(e){let t=getComputedStyle(e);return"none"!==t.display&&parseInt(t.opacity)>0}function nA(e,t){var i;return i=()=>t(!!e&&("checkVisibility"in e?e.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0}):nw(e))),nT.add(i),()=>nT.delete(i)}function nR(e,t,i){for(;t;)if(t===e)return!0;else if(i?.(t))break;else t=t.parentElement;return!1}function nL(e,t){return new au.EventsController(e).add("pointerup",e=>{0!==e.button||e.defaultPrevented||t(e)}).add("keydown",e=>{(0,au.isKeyboardClick)(e)&&t(e)})}function nC(e){return(0,au.isTouchEvent)(e)&&(e.touches.length>1||e.changedTouches.length>1)}function nI(e){if(ac.IS_SERVER)return e();let t=(0,au.getScope)(),i=window.requestAnimationFrame(()=>{(0,au.scoped)(e,t),i=-1});return()=>void window.cancelAnimationFrame(i)}function nP(e,t,i,{offsetVarName:s,xOffset:r,yOffset:a,...n}){if(!e)return;let l=i.replace(" ","-").replace("-center","");if((0,au.setStyle)(e,"visibility",t?null:"hidden"),!t)return;let o=i.includes("top");return function(e,t,i,s){let r;void 0===s&&(s={});let{ancestorScroll:a=!0,ancestorResize:n=!0,elementResize:l="function"==typeof ResizeObserver,layoutShift:o="function"==typeof IntersectionObserver,animationFrame:d=!1}=s,h=a5(e),u=a||n?[...h?a0(h):[],...t?a0(t):[]]:[];u.forEach(e=>{a&&e.addEventListener("scroll",i,{passive:!0}),n&&e.addEventListener("resize",i)});let c=h&&o?function(e,t){let i,s=null,r=aF(e);function a(){var e;clearTimeout(i),null==(e=s)||e.disconnect(),s=null}return!function n(l,o){void 0===l&&(l=!1),void 0===o&&(o=1),a();let d=e.getBoundingClientRect(),{left:h,top:u,width:c,height:f}=d;if(l||t(),!c||!f)return;let p={rootMargin:-ag(u)+"px "+-ag(r.clientWidth-(h+c))+"px "+-ag(r.clientHeight-(u+f))+"px "+-ag(h)+"px",threshold:ap(0,af(1,o))||1},m=!0;function g(t){let s=t[0].intersectionRatio;if(s!==o){if(!m)return n();s?n(!1,s):i=setTimeout(()=>{n(!1,1e-7)},1e3)}1!==s||nn(d,e.getBoundingClientRect())||n(),m=!1}try{s=new IntersectionObserver(g,{...p,root:r.ownerDocument})}catch(e){s=new IntersectionObserver(g,p)}s.observe(e)}(!0),a}(h,i):null,f=-1,p=null;l&&(p=new ResizeObserver(e=>{let[s]=e;s&&s.target===h&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;null==(e=p)||e.observe(t)})),i()}),h&&!d&&p.observe(h),t&&p.observe(t));let m=d?a6(e):null;return d&&function t(){let s=a6(e);m&&!nn(m,s)&&i(),m=s,r=requestAnimationFrame(t)}(),i(),()=>{var e;u.forEach(e=>{a&&e.removeEventListener("scroll",i),n&&e.removeEventListener("resize",i)}),null==c||c(),null==(e=p)||e.disconnect(),p=null,d&&cancelAnimationFrame(r)}}(t,e,()=>{var d,h,u;let c,f,p;(u={placement:l,middleware:[...n.middleware??[],{name:"flip",options:d={fallbackAxisSideDirection:"start",crossAxis:!1},async fn(e){var t,i,s,r,a,n,l,o;let h,u,c,{placement:f,middlewareData:p,rects:m,initialPlacement:g,platform:y,elements:v}=e,{mainAxis:b=!0,crossAxis:E=!0,fallbackPlacements:S,fallbackStrategy:T="bestFit",fallbackAxisSideDirection:x="none",flipAlignment:k=!0,...w}=ab(d,e);if(null!=(t=p.arrow)&&t.alignmentOffset)return{};let A=aE(f),R=ak(g),L=aE(g)===g,C=await (null==y.isRTL?void 0:y.isRTL(v.floating)),I=S||(L||!k?[aI(g)]:(h=aI(g),[aw(g),h,aw(h)])),P="none"!==x;!S&&P&&I.push(...(u=aS(g),c=function(e,t,i){switch(e){case"top":case"bottom":if(i)return t?aR:aA;return t?aA:aR;case"left":case"right":return t?aL:aC;default:return[]}}(aE(g),"start"===x,C),u&&(c=c.map(e=>e+"-"+u),k&&(c=c.concat(c.map(aw)))),c));let D=[g,...I],M=await y.detectOverflow(e,w),_=[],$=(null==(i=p.flip)?void 0:i.overflows)||[];if(b&&_.push(M[A]),E){let e,t,i,s,r=(n=f,l=m,void 0===(o=C)&&(o=!1),e=aS(n),i=ax(t=aT(ak(n))),s="x"===t?e===(o?"end":"start")?"right":"left":"start"===e?"bottom":"top",l.reference[i]>l.floating[i]&&(s=aI(s)),[s,aI(s)]);_.push(M[r[0]],M[r[1]])}if($=[...$,{placement:f,overflows:_}],!_.every(e=>e<=0)){let e=((null==(s=p.flip)?void 0:s.index)||0)+1,t=D[e];if(t&&("alignment"!==E||R===ak(t)||$.every(e=>ak(e.placement)!==R||e.overflows[0]>0)))return{data:{index:e,overflows:$},reset:{placement:t}};let i=null==(r=$.filter(e=>e.overflows[0]<=0).sort((e,t)=>
4e.overflows[1]-t.overflows[1])[0])?void 0:r.placement;if(!i)switch(T){case"bestFit":{let e=null==(a=$.filter(e=>{if(P){let t=ak(e.placement);return t===R||"y"===t}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0])?void 0:a[0];e&&(i=e);break}case"initialPlacement":i=g}if(f!==i)return{reset:{placement:i}}}return{}}},(void 0===h&&(h={}),{name:"shift",options:h,async fn(e){let{x:t,y:i,placement:s,platform:r}=e,{mainAxis:a=!0,crossAxis:n=!1,limiter:l={fn:e=>{let{x:t,y:i}=e;return{x:t,y:i}}},...o}=ab(h,e),d={x:t,y:i},u=await r.detectOverflow(e,o),c=ak(aE(s)),f=aT(c),p=d[f],m=d[c];if(a){let e="y"===f?"top":"left",t="y"===f?"bottom":"right",i=p+u[e],s=p-u[t];p=ap(i,af(p,s))}if(n){let e="y"===c?"top":"left",t="y"===c?"bottom":"right",i=m+u[e],s=m-u[t];m=ap(i,af(m,s))}let g=l.fn({...e,[f]:p,[c]:m});return{...g,data:{x:g.x-t,y:g.y-i,enabled:{[f]:a,[c]:n}}}}})],...n},c=new Map,p={...(f={platform:na,...u}).platform,_c:c},a_(t,e,{...f,platform:p})).then(({x:t,y:n,middlewareData:l})=>{let d,h,u=!!l.flip?.index;o=i.includes(u?"bottom":"top"),e.setAttribute("data-placement",u?i.startsWith("top")?i.replace("top","bottom"):i.replace("bottom","top"):i),Object.assign(e.style,{top:`calc(${n+"px"} + ${(d=a?a+"px":`var(--${s}-y-offset, 0px)`,o?`calc(-1 * ${d})`:d)})`,left:`calc(${t+"px"} + ${(h=r?r+"px":`var(--${s}-x-offset, 0px)`,i.includes("left")?`calc(-1 * ${h})`:h)})`})})})}function nD(e){return e instanceof HTMLElement}ac.IS_SERVER||function e(){for(let e of nT)try{e()}catch(e){}window.requestAnimationFrame(e)}();var nM=class{priority=0;#l=!0;#o=null;#d=null;#h=new Set;canRender(e,t){return!!t}attach(e){this.#o=e,e&&(e.textTracks.onchange=this.#u.bind(this))}addTrack(e){this.#h.add(e),this.#c(e)}removeTrack(e){e[ac.TextTrackSymbol.native]?.remove?.(),e[ac.TextTrackSymbol.native]=null,this.#h.delete(e)}changeTrack(e){let t=e?.[ac.TextTrackSymbol.native];t&&"showing"!==t.track.mode&&(t.track.mode="showing"),this.#d=e}setDisplay(e){this.#l=e,this.#u()}detach(){for(let e of(this.#o&&(this.#o.textTracks.onchange=null),this.#h))this.removeTrack(e);this.#h.clear(),this.#o=null,this.#d=null}#c(e){if(!this.#o)return;let t=e[ac.TextTrackSymbol.native]??=this.#f(e);nD(t)&&(this.#o.append(t),t.track.mode=t.default?"showing":"disabled")}#f(e){let t=document.createElement("track"),i=e.default||"showing"===e.mode,s=e.src&&"vtt"===e.type;return t.id=e.id,t.src=s?e.src:"",t.label=e.label,t.kind=e.kind,t.default=i,e.language&&(t.srclang=e.language),i&&!s&&this.#p(e,t.track),t}#p(e,t){if(!(e.src&&"vtt"===e.type||t.cues?.length))for(let i of e.cues)t.addCue(i)}#u(e){for(let t of this.#h){let i=t[ac.TextTrackSymbol.native];if(!i)continue;if(!this.#l){i.track.mode=i.managed?"hidden":"disabled";continue}let s="showing"===i.track.mode;s&&this.#p(t,i.track),t.setMode(s?"showing":"disabled",e)}}},n_=class{#o=null;#m;#g=[];#y;#v=!1;#b=null;#E=null;constructor(e){this.#y=e;const t=e.textTracks;this.#m=t,(0,au.effect)(this.#S.bind(this)),(0,au.onDispose)(this.#T.bind(this)),new au.EventsController(t).add("add",this.#x.bind(this)).add("remove",this.#k.bind(this)).add("mode-change",this.#w.bind(this))}#S(){let{nativeControls:e}=this.#y.$state;this.#v=e(),this.#w()}add(e){this.#g.push(e),(0,au.untrack)(this.#w.bind(this))}remove(e){e.detach(),this.#g.splice(this.#g.indexOf(e),1),(0,au.untrack)(this.#w.bind(this))}attachVideo(e){requestAnimationFrame(()=>{if(this.#o=e,e)for(let t of(this.#b=new nM,this.#b.attach(e),this.#m))this.#A(t);this.#w()})}#A(e){(0,ac.isTrackCaptionKind)(e)&&this.#b?.addTrack(e)}#R(e){(0,ac.isTrackCaptionKind)(e)&&this.#b?.removeTrack(e)}#x(e){this.#A(e.detail)}#k(e){this.#R(e.detail)}#w(){let e=this.#m.selected;if(this.#o&&(this.#v||e?.[ac.TextTrackSymbol.nativeHLS])){this.#E?.changeTrack(null),this.#b?.setDisplay(!0),this.#b?.changeTrack(e);return}if(this.#b?.setDisplay(!1),this.#b?.changeTrack(null),!e)return void this.#E?.changeTrack(null);let t=this.#g.sort((e,t)=>e.priority-t.priority).find(t=>t.canRender(e,this.#o));this.#E!==t&&(this.#E?.detach(),t?.attach(this.#o),this.#E=t??null),t?.changeTrack(e)}
4#T(){this.#b?.detach(),this.#b=null,this.#E?.detach(),this.#E=null}},n$=class extends ny{#L=!1;#C={};#I=null;#P=null;[ac.TextTrackSymbol.crossOrigin];constructor(){super()}get selected(){return this.items.find(e=>"showing"===e.mode&&(0,ac.isTrackCaptionKind)(e))??null}get selectedIndex(){let e=this.selected;return e?this.indexOf(e):-1}get preferredLang(){return this.#P}set preferredLang(e){this.#P=e,this.#D(e)}add(e,t){let i=e instanceof ac.TextTrack?e:new ac.TextTrack(e),s="captions"===e.kind||"subtitles"===e.kind?"captions":e.kind;return this.#C[s]&&e.default&&delete e.default,i.addEventListener("mode-change",this.#M),this[ac.ListSymbol.add](i,t),i[ac.TextTrackSymbol.crossOrigin]=this[ac.TextTrackSymbol.crossOrigin],this.#L&&i[ac.TextTrackSymbol.canLoad](),e.default&&(this.#C[s]=i),this.#_(),this}remove(e,t){if(this.#$=e,this.items.includes(e))return e===this.#C[e.kind]&&delete this.#C[e.kind],e.mode="disabled",e[ac.TextTrackSymbol.onModeChange]=null,e.removeEventListener("mode-change",this.#M),this[ac.ListSymbol.remove](e,t),this.#$=null,this}clear(e){for(let t of[...this.items])this.remove(t,e);return this}getByKind(e){let t=Array.isArray(e)?e:[e];return this.items.filter(e=>t.includes(e.kind))}[ac.TextTrackSymbol.canLoad](){if(!this.#L){for(let e of this.items)e[ac.TextTrackSymbol.canLoad]();this.#L=!0,this.#_()}}#_=(0,au.functionDebounce)(async()=>{if(!this.#L)return;!this.#P&&this.#I&&(this.#P=await this.#I.getLang());let e=await this.#I?.getCaptions();for(let t of[["captions","subtitles"],"chapters","descriptions","metadata"]){let i=this.getByKind(t);if(i.find(e=>"showing"===e.mode))continue;let s=this.#P?i.find(e=>e.language===this.#P):null,r=(0,au.isArray)(t)?this.#C[t.find(e=>this.#C[e])||""]:this.#C[t],a=s??r,n=a&&(0,ac.isTrackCaptionKind)(a);a&&(!n||!1!==e)&&(a.mode="showing",n&&this.#O(a))}},300);#$=null;#M=this.#N.bind(this);#N(e){let t=e.detail;if(this.#I&&(0,ac.isTrackCaptionKind)(t)&&t!==this.#$&&this.#O(t),"showing"===t.mode){let e=(0,ac.isTrackCaptionKind)(t)?["captions","subtitles"]:[t.kind];for(let i of this.items)"showing"===i.mode&&i!=t&&e.includes(i.kind)&&(i.mode="disabled")}this.dispatchEvent(new au.DOMEvent("mode-change",{detail:e.detail,trigger:e}))}#O(e){"disabled"!==e.mode&&this.#D(e.language),this.#I?.setCaptions?.("showing"===e.mode)}#D(e){this.#I?.setLang?.(this.#P=e)}setStorage(e){this.#I=e}},nO=class extends nb{#F=!1;switch="current";get auto(){return this.#F||this.readonly}[ac.QualitySymbol.enableAuto];[ac.ListSymbol.onUserSelect](){this[ac.QualitySymbol.setAuto](!1)}[ac.ListSymbol.onReset](e){this[ac.QualitySymbol.enableAuto]=void 0,this[ac.QualitySymbol.setAuto](!1,e)}autoSelect(e){this.readonly||this.#F||!this[ac.QualitySymbol.enableAuto]||(this[ac.QualitySymbol.enableAuto]?.(e),this[ac.QualitySymbol.setAuto](!0,e))}getBySrc(e){return this.items.find(t=>t.src===e)}[ac.QualitySymbol.setAuto](e,t){this.#F!==e&&(this.#F=e,this.dispatchEvent(new au.DOMEvent("auto-change",{detail:e,trigger:t})))}};function nN(e,t){return[...e].sort(t?nB:nF)}function nF(e,t){return e.height===t.height?(e.bitrate??0)-(t.bitrate??0):e.height-t.height}function nB(e,t){return t.height===e.height?(t.bitrate??0)-(e.bitrate??0):t.height-e.height}var nU=class extends au.ViewController{};let nj=new Set(["Shift","Alt","Meta","Ctrl"]),nV='input, textarea, select, [contenteditable], [role^="menuitem"], [role="timer"]';var nG=class extends nU{#y;constructor(e){super(),this.#y=e}onConnect(){(0,au.effect)(this.#B.bind(this))}#B(){let{keyDisabled:e,keyTarget:t}=this.$props;if(e())return;let i="player"===t()?this.el:document,s=(0,au.signal)(!1);i===this.el?new au.EventsController(this.el).add("focusin",()=>s.set(!0)).add("focusout",e=>{this.el.contains(e.target)||s.set(!1)}):((0,au.peek)(s)||s.set(document.querySelector("[data-media-player]")===this.el),(0,au.listenEvent)(document,"focusin",e=>{let t=e.composedPath().find(e=>e instanceof Element&&"media-player"===e.localName);void 0!==t&&s.set(this.el===t)})),(0,au.effect)(()=>{s()&&new au.EventsController(i).add("keyup",this.#U.bind(this)).add("keydown",this.#j.bind(this)).add("keydown",this.#V.bind(this),{capture:!0})})}#U(e){let t=document.activeElement;
4if(!e.key||!this.$state.canSeek()||t?.matches(nV))return;let{method:i,value:s}=this.#G(e);if(!(0,au.isString)(s)&&!(0,au.isArray)(s)){s?.onKeyUp?.({event:e,player:this.#y.player,remote:this.#y.remote}),s?.callback?.(e,this.#y.remote);return}i?.startsWith("seek")&&(e.preventDefault(),e.stopPropagation(),this.#q?(this.#H(e,"seekForward"===i),this.#q=null):(this.#y.remote.seek(this.#K,e),this.#K=void 0)),i?.startsWith("volume")&&this.el.querySelector("[data-media-volume-slider]")?.dispatchEvent(new KeyboardEvent("keyup",{key:"volumeUp"===i?"Up":"Down",shiftKey:e.shiftKey,trigger:e}))}#j(e){if(!e.key||nj.has(e.key))return;let t=document.activeElement;if(t?.matches(nV)||(0,au.isKeyboardClick)(e)&&t?.matches('button, [role="button"]'))return;let{method:i,value:s}=this.#G(e),r=!e.metaKey&&/^[0-9]$/.test(e.key);if(!(0,au.isString)(s)&&!(0,au.isArray)(s)&&!r){s?.onKeyDown?.({event:e,player:this.#y.player,remote:this.#y.remote}),s?.callback?.(e,this.#y.remote);return}if(!i&&r&&!function(e){for(let t of nj)if(e[t.toLowerCase()+"Key"])return!0;return!1}(e)){e.preventDefault(),e.stopPropagation(),this.#y.remote.seek(this.$state.duration()/10*Number(e.key),e);return}if(i){switch(e.preventDefault(),e.stopPropagation(),i){case"seekForward":case"seekBackward":this.#W(e,i,"seekForward"===i);break;case"volumeUp":case"volumeDown":let t=this.el.querySelector("[data-media-volume-slider]");if(t)t.dispatchEvent(new KeyboardEvent("keydown",{key:"volumeUp"===i?"Up":"Down",shiftKey:e.shiftKey,trigger:e}));else{let t=e.shiftKey?.1:.05;this.#y.remote.changeVolume(this.$state.volume()+("volumeUp"===i?+t:-t),e)}break;case"toggleFullscreen":this.#y.remote.toggleFullscreen("prefer-media",e);break;case"speedUp":case"slowDown":let s=this.$state.playbackRate();this.#y.remote.changePlaybackRate(Math.max(.25,Math.min(2,s+("speedUp"===i?.25:-.25))),e);break;default:this.#y.remote[i]?.(e)}this.$state.lastKeyboardAction.set({action:i,event:e})}}#V(e){var t,i;i=t=e.target,(!ac.IS_SERVER&&i instanceof HTMLAudioElement||!ac.IS_SERVER&&t instanceof HTMLVideoElement)&&this.#G(e).method&&e.preventDefault()}#G(e){let t={...this.$props.keyShortcuts(),...this.#y.ariaKeys},i=Object.keys(t).find(i=>{let s=t[i],r=(0,au.isArray)(s)?s.join(" "):(0,au.isString)(s)?s:s?.keys;return((0,au.isArray)(r)?r:r?.split(" "))?.map(e=>e.replace(/Shift\+(\d)/g,(e,t)=>nq[t-1]).replace(/Control/g,"Ctrl").split("+"))?.some(t=>{let i=new Set(t.filter(e=>nj.has(e)));for(let t of("<>".includes(e.key)&&i.add("Shift"),nj)){let s=t.toLowerCase()+"Key";if(!i.has(t)&&e[s])return!1}return t.every(t=>nj.has(t)?e[t.toLowerCase()+"Key"]:e.key===t.replace("Space"," "))})});return{method:i,value:i?t[i]:null}}#K;#z(e,t){let i=e.shiftKey?10:5;return this.#K=Math.max(0,Math.min((this.#K??this.$state.currentTime())+("seekForward"===t?+i:-i),this.$state.duration()))}#q=null;#H(e,t){this.#q?.dispatchEvent(new KeyboardEvent(e.type,{key:t?"Right":"Left",shiftKey:e.shiftKey,trigger:e}))}#W(e,t,i){this.$state.canSeek()&&(this.#q||(this.#q=this.el.querySelector("[data-media-time-slider]")),this.#q?this.#H(e,i):this.#y.remote.seeking(this.#z(e,t),e))}};let nq=["!","@","#","$","%","^","&","*","(",")"];var nH=class extends au.ViewController{#Y;constructor(e){super(),this.#Y=e}onAttach(e){let{$props:t,ariaKeys:i}=np(),s=e.getAttribute("aria-keyshortcuts");if(s){i[this.#Y]=s,ac.IS_SERVER||(0,au.onDispose)(()=>{delete i[this.#Y]});return}let r=t.keyShortcuts()[this.#Y];if(r){let t=(0,au.isArray)(r)?r.join(" "):(0,au.isString)(r)?r:r?.keys;e.setAttribute("aria-keyshortcuts",(0,au.isArray)(t)?t.join(" "):t)}}},nK=class extends nU{#Q=-2;#X=!1;#J=(0,au.signal)(!1);#Z=(0,au.signal)(!1);#ee=null;#et=(0,au.signal)(!0);defaultDelay=2e3;get canIdle(){return this.#et()}set canIdle(e){this.#et.set(e)}get hideOnMouseLeave(){let{hideControlsOnMouseLeave:e}=this.$props;return this.#J()||e()}set hideOnMouseLeave(e){this.#J.set(e)}get showing(){return this.$state.controlsVisible()}show(e=0,t){this.#ei(),this.#X||this.#es(!0,e,t)}hide(e=this.defaultDelay,t){this.#ei(),this.#X||this.#es(!1,e,t)}pause(e){this.#X=!0,this.#ei(),this.#es(!0,0,e)}resume(e){this.#X=!1,this.$state.paused()||this.#es(!1,this.defaultDelay,e)}onConnect(){(0,au.effect)(this.#er.bind(this))}#er(){let{viewType:e}=this.$state;if(!this.el||!this.#et())return;
4if("audio"===e())return void this.show();(0,au.effect)(this.#ea.bind(this)),(0,au.effect)(this.#en.bind(this));let t=this.#el.bind(this),i=this.#eo.bind(this),s=this.#ed.bind(this);new au.EventsController(this.el).add("can-play",e=>this.show(0,e)).add("play",t).add("pause",i).add("end",s).add("auto-play-fail",i)}#ea(){if(!this.el)return;let{started:e,pointer:t,paused:i}=this.$state;if(!e()||"fine"!==t())return;let s=new au.EventsController(this.el),r=this.hideOnMouseLeave;r&&this.#Z()||(0,au.effect)(()=>{i()||s.add("pointermove",this.#eh.bind(this))}),r&&s.add("mouseenter",this.#eu.bind(this)).add("mouseleave",this.#ec.bind(this))}#en(){let{paused:e,started:t,autoPlayError:i}=this.$state;if(e()||i()&&!t())return;let s=this.#eh.bind(this);(0,au.effect)(()=>{if(!this.el)return;let e="coarse"===this.$state.pointer(),t=new au.EventsController(this.el);for(let i of[e?"touchend":"pointerup","keydown"])t.add(i,s,{passive:!1})})}#el(e){e.triggers.hasType("ended")||(this.show(0,e),this.hide(void 0,e))}#eo(e){this.show(0,e)}#ed(e){let{loop:t}=this.$state;t()&&this.hide(0,e)}#eu(e){this.#Z.set(!1),this.show(0,e),this.hide(void 0,e)}#ec(e){this.#Z.set(!0),this.hide(0,e)}#ei(){window.clearTimeout(this.#Q),this.#Q=-1}#eh(e){e.MEDIA_GESTURE||this.#X||nC(e)||((0,au.isKeyboardEvent)(e)&&("Escape"===e.key?(this.el?.focus(),this.#ee=null):this.#ee&&(e.preventDefault(),requestAnimationFrame(()=>{this.#ee?.focus(),this.#ee=null}))),this.show(0,e),this.hide(this.defaultDelay,e))}#es(e,t,i){0===t?this.#u(e,i):this.#Q=window.setTimeout(()=>{this.scope&&this.#u(e&&!this.#X,i)},t)}#u(e,t){this.$state.controlsVisible()!==e&&(this.$state.controlsVisible.set(e),!e&&document.activeElement&&this.el?.contains(document.activeElement)&&(this.#ee=document.activeElement,requestAnimationFrame(()=>{this.el?.focus({preventScroll:!0})}
4)),this.dispatch("controls-change",{detail:e,trigger:t}))}};let nW=au.fscreen.fullscreenEnabled;var nz=class extends au.ViewController{#ef=!1;#ep=!1;get active(){return this.#ep}get supported(){return nW}onConnect(){new au.EventsController(au.fscreen).add("fullscreenchange",this.#u.bind(this)).add("fullscreenerror",this.#em.bind(this)),(0,au.onDispose)(this.#eg.bind(this))}#eg(){nW&&this.exit().catch(au.noop)}#u(e){let t=nY(this.el);t!==this.#ep&&(t||(this.#ef=!1),this.#ep=t,this.dispatch("fullscreen-change",{detail:t,trigger:e}))}#em(e){this.#ef&&(this.dispatch("fullscreen-error",{detail:null,trigger:e}),this.#ef=!1)}async enter(){try{if(this.#ef=!0,!this.el||nY(this.el))return;return nQ(),au.fscreen.requestFullscreen(this.el)}catch(e){throw this.#ef=!1,e}}async exit(){if(this.el&&nY(this.el))return nQ(),au.fscreen.exitFullscreen()}};function nY(e){if(au.fscreen.fullscreenElement===e)return!0;try{return e.matches(au.fscreen.fullscreenPseudoClass)}catch(e){return!1}}function nQ(){if(!nW)throw Error("[vidstack] no fullscreen API")}var nX=class e extends au.ViewController{#ey=(0,au.signal)(this.#ev());#eb=(0,au.signal)(!1);#eE;get type(){return this.#ey()}get locked(){return this.#eb()}get portrait(){return this.#ey().startsWith("portrait")}get landscape(){return this.#ey().startsWith("landscape")}static supported=(0,ac.canOrientScreen)();get supported(){return e.supported}onConnect(){if(this.supported)(0,au.listenEvent)(screen.orientation,"change",this.#eS.bind(this));else{let e=window.matchMedia("(orientation: landscape)");e.onchange=this.#eS.bind(this),(0,au.onDispose)(()=>e.onchange=null)}(0,au.onDispose)(this.#eg.bind(this))}async #eg(){this.supported&&this.#eb()&&await this.unlock()}#eS(e){this.#ey.set(this.#ev()),this.dispatch("orientation-change",{detail:{orientation:(0,au.peek)(this.#ey),lock:this.#eE},trigger:e})}async lock(e){(0,au.peek)(this.#eb)||this.#eE===e||(this.#eT(),await screen.orientation.lock(e),this.#eb.set(!0),this.#eE=e)}async unlock(){(0,au.peek)(this.#eb)&&(this.#eT(),this.#eE=void 0,await screen.orientation.unlock(),this.#eb.set(!1))}#eT(){if(!this.supported)throw Error("[vidstack] no orientation API")}#ev(){return ac.IS_SERVER?"portrait-primary":this.supported?window.screen.orientation.type:window.innerWidth>=window.innerHeight?"landscape-primary":"portrait-primary"}},nJ=class{name="audio";target;canPlay(e){return!!(0,ac.isAudioSrc)(e)&&(ac.IS_SERVER||!(0,au.isString)(e.src)||"?"===e.type||(0,ac.canPlayAudioType)(this.target,e.type))}mediaType(){return"audio"}async load(t){if(ac.IS_SERVER)throw Error("[vidstack] can not load audio provider server-side");return new(await e.A(62606)).AudioProvider(this.target,t)}},nZ=class{name="video";target;canPlay(e){return!!(0,ac.isVideoSrc)(e)&&(ac.IS_SERVER||!(0,au.isString)(e.src)||"?"===e.type||(0,ac.canPlayVideoType)(this.target,e.type))}mediaType(){return"video"}async load(t){if(ac.IS_SERVER)throw Error("[vidstack] can not load video provider server-side");return new(await e.A(95383).then(e=>e.provider_exports$1)).VideoProvider(this.target,t)}},n0=class t extends nZ{static supported=(0,ac.isHLSSupported)();name="hls";canPlay(e){return t.supported&&(0,ac.isHLSSrc)(e)}async load(t){if(ac.IS_SERVER)throw Error("[vidstack] can not load hls provider server-side");return new(await e.A(33886)).HLSProvider(this.target,t)}},n1=class t extends nZ{static supported=(0,ac.isDASHSupported)();name="dash";canPlay(e){return t.supported&&(0,ac.isDASHSrc)(e)}async load(t){if(ac.IS_SERVER)throw Error("[vidstack] can not load dash provider server-side");return new(await e.A(95383).then(e=>e.provider_exports)).DASHProvider(this.target,t)}},n2=class{name="vimeo";target;preconnect(){for(let e of["https://i.vimeocdn.com","https://f.vimeocdn.com","https://fresnel.vimeocdn.com"])(0,ac.preconnect)(e)}canPlay(e){return(0,au.isString)(e.src)&&"video/vimeo"===e.type}mediaType(){return"video"}async load(t){if(ac.IS_SERVER)throw Error("[vidstack] can not load vimeo provider server-side");return new(await e.A(77602)).VimeoProvider(this.target,t)}async loadPoster(t,i,s){let{resolveVimeoVideoId:r,getVimeoVideoInfo:a}=await e.A(87726);if(!(0,au.isString)(t.src))return null;let{videoId:n,hash:l}=r(t.src);return n?a(n,s,l).then(e=>e?e.poster:null):null}},n5=class{name="youtube";target;
4preconnect(){for(let e of["https://www.google.com","https://i.ytimg.com","https://googleads.g.doubleclick.net","https://static.doubleclick.net"])(0,ac.preconnect)(e)}canPlay(e){return(0,au.isString)(e.src)&&"video/youtube"===e.type}mediaType(){return"video"}async load(t){if(ac.IS_SERVER)throw Error("[vidstack] can not load youtube provider server-side");return new(await e.A(3548)).YouTubeProvider(this.target,t)}async loadPoster(t,i,s){let{findYouTubePoster:r,resolveYouTubeVideoId:a}=await e.A(58517),n=(0,au.isString)(t.src)&&a(t.src);return n?r(n,s):null}};function n3(e,t){let i=String(e),s=i.length;return s<t?`${"0".repeat(t-s)}${e}`:i}function n4(e){return{hours:Math.trunc(e/3600),minutes:Math.trunc(e%3600/60),seconds:Math.trunc(e%60),fraction:Number((e-Math.trunc(e)).toPrecision(3))}}function n8(e,{padHrs:t=null,padMins:i=null,showHrs:s=!1,showMs:r=!1}={}){let{hours:a,minutes:n,seconds:l,fraction:o}=n4(e),d=t?n3(a,2):a,h=`${i||(0,au.isNull)(i)&&e>=3600?n3(n,2):n}:${n3(l,2)}${r&&o>0?`.${String(o).replace(/^0?\./,"")}`:""}`;return a>0||s?`${d}:${h}`:h}function n6(e){let t=[],{hours:i,minutes:s,seconds:r}=n4(e);return i>0&&t.push(`${i} hour`),s>0&&t.push(`${s} min`),(r>0||0===t.length)&&t.push(`${r} sec`),t.join(" ")}let n7=Symbol(0),n9=["autoPlay","canAirPlay","canFullscreen","canGoogleCast","canLoad","canLoadPoster","canPictureInPicture","canPlay","canSeek","ended","fullscreen","isAirPlayConnected","isGoogleCastConnected","live","liveEdge","loop","mediaType","muted","paused","pictureInPicture","playing","playsInline","remotePlaybackState","remotePlaybackType","seeking","started","streamType","viewType","waiting"],le={artist:"",artwork:null,ariaLabel:"",autoplay:!1,autoPlay:!1,clipStartTime:0,clipEndTime:0,controls:!1,currentTime:0,crossorigin:null,crossOrigin:null,duration:-1,fullscreenOrientation:"landscape",googleCast:{},load:"visible",posterLoad:"visible",logLevel:"silent",loop:!1,muted:!1,paused:!0,playsinline:!1,playsInline:!1,playbackRate:1,poster:"",preload:"metadata",preferNativeHLS:!1,src:"",title:"",controlsDelay:2e3,hideControlsOnMouseLeave:!1,viewType:"unknown",streamType:"unknown",volume:1,liveEdgeTolerance:10,minLiveDVRWindow:60,keyDisabled:!1,keyTarget:"player",keyShortcuts:{togglePaused:"k Space",toggleMuted:"m",toggleFullscreen:"f",togglePictureInPicture:"i",toggleCaptions:"c",seekBackward:"j J ArrowLeft",seekForward:"l L ArrowRight",volumeUp:"ArrowUp",volumeDown:"ArrowDown",speedUp:">",slowDown:"<"},storage:null};var lt=class extends nU{#ey;#ex;constructor(e,t){super(),this.#ey=e,this.#ex=t}async onAttach(e){if(ac.IS_SERVER)return;let t=this.$props[this.#ey]();if("eager"===t)requestAnimationFrame(this.#ex);else if("idle"===t)(0,au.waitIdlePeriod)(this.#ex);else if("visible"===t){let t,i=new IntersectionObserver(e=>{this.scope&&e[0].isIntersecting&&(t?.(),t=void 0,this.#ex())});i.observe(e),t=(0,au.onDispose)(()=>i.disconnect())}}},li=class{#ek;#y;constructor(e,t){this.#ek=e,this.#y=t}notify(e,...t){ac.IS_SERVER||this.#ek(new au.DOMEvent(e,{detail:t?.[0],trigger:t?.[1]}))}async ready(e,t){if(!ac.IS_SERVER)return(0,au.untrack)(async()=>{let{logger:i}=this.#y,{autoPlay:s,canPlay:r,started:a,duration:n,seekable:l,buffered:o,remotePlaybackInfo:d,playsInline:h,savedState:u,source:c}=this.#y.$state;if(r())return;let f={duration:e?.duration??n(),seekable:e?.seekable??l(),buffered:e?.buffered??o(),provider:this.#y.$provider()};this.notify("can-play",f,t),(0,au.tick)();let p=this.#y.$provider(),{storage:m,qualities:g}=this.#y,{muted:y,volume:v,clipStartTime:b,playbackRate:E}=this.#y.$props;await m?.onLoad?.(c());let S=u()?.currentTime,T=u()?.paused,x=await m?.getTime(),k=S??x??b(),w=!1===T||!0!==T&&!a()&&s();if(p){p.setVolume(await m?.getVolume()??v()),p.setMuted(y()||!!await m?.getMuted());let e=await m?.getAudioGain()??1;e>1&&p.audioGain?.setGain?.(e),p.setPlaybackRate?.(await m?.getPlaybackRate()??E()),p.setPlaysInline?.(h()),k>0&&p.setCurrentTime(k)}let A=await m?.getVideoQuality();if(A&&g.length){let e=null,t=1/0;for(let i of g){let s=Math.abs(A.width-i.width)+Math.abs(A.height-i.height)+(A.bitrate?Math.abs(A.bitrate-(i.bitrate??0)):0);s<t&&(e=i,t=s)}e&&(e.selected=!0)}r()&&w?await this.#ew(t):x&&x>0&&this.notify("started",void 0,t),d.set(null)})}async #ew(e){let{player:t,$state:{autoPlaying:i,muted:s}}=this.#y;i.set(!0);let r=new au.DOMEvent("auto-play-attempt",{trigger:e});try{await t.play(r)}catch(e){}}},ls=class{#eA=new Map;enqueue(e,t){this.#eA.set(e,t)}serve(e){let t=this.peek(e);return this.#eA.delete(e),t}peek(e){return this.#eA.get(e)}delete(e){this.#eA.delete(e)}clear(){this.#eA.clear()}},lr=class{#eR=!1;#eL=(0,au.deferredPromise)();#eA=new Map;get size(){return this.#eA.size}get isServing(){return this.#eR}async waitForFlush(){this.#eR||await this.#eL.promise}enqueue(e,t){this.#eR?t():(this.#eA.delete(e),this.#eA.set(e,t))}serve(e){this.#eA.get(e)?.(),this.#eA.delete(e)}start(){this.#eC(),this.#eR=!0,this.#eA.size>0&&this.#eC()}stop(){this.#eR=!1}reset(){this.stop(),this.#eA.clear(),this.#eI()}#eC(){for(let e of this.#eA.keys())this.serve(e);this.#eI()}#eI(){this.#eL.resolve(),this.#eL=(0,au.deferredPromise)()}};function la(e){return()=>e()?"true":"false"}var ln=class extends nU{#eP;#eD;#y;controls;#eM;#e_;#e$;#eO=new lr;constructor(e,t,i){super(),this.#eP=e,this.#eD=t,this.#y=i,this.#e$=i.$provider,this.controls=new nK,this.#eM=new nz,this.#e_=new nX}onAttach(){this.listen("fullscreen-change",this.#eN.bind(this))}onConnect(e){let t=Object.getOwnPropertyNames(Object.getPrototypeOf(this)),i=new au.EventsController(e),s=this.#eF.bind(this);for(let e of t)e.startsWith("media-")&&i.add(e,s);this.#eB(),(0,au.effect)(this.#eU.bind(this)),(0,au.effect)(this.#ej.bind(this)),(0,au.effect)(this.#eV.bind(this)),(0,au.effect)(this.#eG.bind(this)),(0,au.effect)(this.#eq.bind(this)),(0,au.effect)(this.#eH.bind(this)),(0,au.effect)(this.#eK.bind(this))}onDestroy(){try{let e=this.createEvent("destroy"),{pictureInPicture:t,fullscreen:i}=this.$state;i()&&this.exitFullscreen("prefer-media",e),t()&&this.exitPictureInPicture(e)}catch(e){}this.#eO.reset()}#eB(){let{load:e}=this.$props,{canLoad:t}=this.$state;if("play"!==e()||t())return;let i=this.listen("media-play-request",e=>{this.#eW(e),i()})}#eU(){let e=this.#e$(),t=this.$state.canPlay();return e&&t&&this.#eO.start(),()=>{this.#eO.stop()}}#eF(e){e.stopPropagation(),e.defaultPrevented||this[e.type]&&((0,au.peek)(this.#e$)?this[e.type](e):this.#eO.enqueue(e.type,()=>{(0,au.peek)(this.#e$)&&this[e.type](e)}))}async play(e){if(ac.IS_SERVER)return;let{canPlay:t,paused:i,autoPlaying:s}=this.$state;if(this.#eW(e)||!(0,au.peek)(i))return;e&&this.#eD.queue.enqueue("media-play-request",e);let r=(0,au.peek)(s);try{let e=(0,au.peek)(this.#e$);return ll(e,(0,au.peek)(t)),function(e){if(!("u"<typeof window)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches&&e)throw Error("[vidstack] autoplay blocked")}(r),await e.play()}catch(i){let t=this.createEvent("play-fail",{detail:(0,ac.coerceToError)(i),trigger:e});throw t.autoPlay=r,this.#eP.handle(t),i}}#eW(e){let{load:t}=this.$props,{canLoad:i}=this.$state;if("play"===t()&&!i()){let t=this.createEvent("media-start-loading",{trigger:e});return this.dispatchEvent(t),this.#eO.enqueue("media-play-request",async()=>{try{await this.play(t)}catch(e){}}),!0}return!1}async pause(e){if(ac.IS_SERVER)return;let{canPlay:t,paused:i}=this.$state;if(!(0,au.peek)(i)){e&&this.#eD.queue.enqueue("media-pause-request",e);try{let e=(0,au.peek)(this.#e$);return ll(e,(0,au.peek)(t)),await e.pause()}catch(e){throw this.#eD.queue.delete("media-pause-request"),e}}}setAudioGain(e,t){let{audioGain:i,canSetAudioGain:s}=this.$state;if(i()===e)return;let r=this.#e$();if(!r?.audioGain||!s())throw Error("[vidstack] audio gain api not available");t&&this.#eD.queue.enqueue("media-audio-gain-change-request",t),r.audioGain.setGain(e)}seekToLiveEdge(e){if(ac.IS_SERVER)return;
4let{canPlay:t,live:i,liveEdge:s,canSeek:r,liveSyncPosition:a,seekableEnd:n,userBehindLiveEdge:l}=this.$state;if(l.set(!1),(0,au.peek)(()=>!i()||r()&&s()))return;let o=(0,au.peek)(this.#e$);ll(o,(0,au.peek)(t));let d=n()-2,h=Math.min(d,a()??d);Number.isFinite(h)&&(e&&this.#eD.queue.enqueue("media-seek-request",e),o.setCurrentTime(h))}#ez=!1;async enterFullscreen(e="prefer-media",t){if(ac.IS_SERVER)return;let i=this.#eY(e);if(lo(e,i),!i.active)return(0,au.peek)(this.$state.pictureInPicture)&&(this.#ez=!0,await this.exitPictureInPicture(t)),t&&this.#eD.queue.enqueue("media-enter-fullscreen-request",t),i.enter()}async exitFullscreen(e="prefer-media",t){if(ac.IS_SERVER)return;let i=this.#eY(e);if(lo(e,i),i.active){t&&this.#eD.queue.enqueue("media-exit-fullscreen-request",t);try{let e=await i.exit();return this.#ez&&(0,au.peek)(this.$state.canPictureInPicture)&&await this.enterPictureInPicture(),e}finally{this.#ez=!1}}}#eY(e){let t=(0,au.peek)(this.#e$);return"prefer-media"===e&&this.#eM.supported||"media"===e?this.#eM:t?.fullscreen}async enterPictureInPicture(e){if(!ac.IS_SERVER&&(this.#eQ(),!this.$state.pictureInPicture()))return e&&this.#eD.queue.enqueue("media-enter-pip-request",e),await this.#e$().pictureInPicture.enter()}async exitPictureInPicture(e){if(!ac.IS_SERVER&&(this.#eQ(),this.$state.pictureInPicture())){e&&this.#eD.queue.enqueue("media-exit-pip-request",e);try{if(document?.pictureInPictureElement&&document.exitPictureInPicture)return void await document.exitPictureInPicture();let e=this.#e$();if(e?.pictureInPicture)return void await e.pictureInPicture.exit();for(let e of document?.querySelectorAll?.("video")||[]){if(e===document.pictureInPictureElement&&document.exitPictureInPicture)return void await document.exitPictureInPicture();if("picture-in-picture"===e.webkitPresentationMode)return void e.webkitSetPresentationMode("inline")}}catch(e){}}}#eQ(){if(!this.$state.canPictureInPicture())throw Error("[vidstack] no pip support")}#ej(){this.controls.defaultDelay=this.$props.controlsDelay()}#eV(){let{canSetAudioGain:e}=this.$state,t=!!this.#e$()?.audioGain?.supported;e.set(t)}#eG(){let{canAirPlay:e}=this.$state,t=!!this.#e$()?.airPlay?.supported;e.set(t)}#eq(){let{canGoogleCast:e,source:t}=this.$state,i=ac.IS_CHROME&&!ac.IS_IOS&&(0,ac.canGoogleCastSrc)(t());e.set(i)}#eH(){let{canFullscreen:e}=this.$state,t=this.#eM.supported||!!this.#e$()?.fullscreen?.supported;e.set(t)}#eK(){let{canPictureInPicture:e}=this.$state,t=!!this.#e$()?.pictureInPicture?.supported;e.set(t)}async "media-airplay-request"(e){try{await this.requestAirPlay(e)}catch(e){}}async requestAirPlay(e){try{let t=this.#e$()?.airPlay;if(!t?.supported)throw Error("No AirPlay adapter.");return e&&this.#eD.queue.enqueue("media-airplay-request",e),await t.prompt()}catch(e){throw this.#eD.queue.delete("media-airplay-request"),e}}async "media-google-cast-request"(e){try{await this.requestGoogleCast(e)}catch(e){}}#eX;async requestGoogleCast(t){try{let{canGoogleCast:i}=this.$state;if(!(0,au.peek)(i)){let e=Error("Cast not available.");throw e.code="CAST_NOT_AVAILABLE",e}if((0,ac.preconnect)("https://www.gstatic.com"),!this.#eX){let t=await e.A(15600);this.#eX=new t.GoogleCastLoader}await this.#eX.prompt(this.#y),t&&this.#eD.queue.enqueue("media-google-cast-request",t);let s="disconnected"!==(0,au.peek)(this.$state.remotePlaybackState);s&&this.$state.savedState.set({paused:(0,au.peek)(this.$state.paused),currentTime:(0,au.peek)(this.$state.currentTime)}),this.$state.remotePlaybackLoader.set(s?this.#eX:null)}catch(e){throw this.#eD.queue.delete("media-google-cast-request"),e}}"media-clip-start-change-request"(e){let{clipStartTime:t}=this.$state;t.set(e.detail)}"media-clip-end-change-request"(e){let{clipEndTime:t}=this.$state;t.set(e.detail),this.dispatch("duration-change",{detail:e.detail,trigger:e})}"media-duration-change-request"(e){let{providedDuration:t,clipEndTime:i}=this.$state;t.set(e.detail),0>=i()&&this.dispatch("duration-change",{detail:e.detail,trigger:e})}"media-audio-track-change-request"(e){let{logger:t,audioTracks:i}=this.#y;if(i.readonly)return;let s=i[e.detail];if(s){let t=e.type;this.#eD.queue.enqueue(t,e),s.selected=!0}}async "media-enter-fullscreen-request"(e){try{await this.enterFullscreen(e.detail,e)}catch(t){this.#eJ(t,e)}}async "media-exit-fullscreen-request"(e){try{await this.exitFullscreen(e.detail,e)}catch(t){this.#eJ(t,e)}}async #eN(e){let t=(0,au.peek)(this.$props.fullscreenOrientation),i=e.detail;if(!(0,au.isUndefined)(t)&&"none"!==t&&this.#e_.supported)if(i){if(this.#e_.locked)return;this.dispatch("media-orientation-lock-request",{detail:t,trigger:e})}else this.#e_.locked&&this.dispatch("media-orientation-unlock-request",{trigger:e})}#eJ(e,t){this.#eP.handle(this.createEvent("fullscreen-error",{detail:(0,ac.coerceToError)(e)}))}async "media-orientation-lock-request"(e){let t=e.type;try{this.#eD.queue.enqueue(t,e),await this.#e_.lock(e.detail)}catch(e){this.#eD.queue.delete(t)}}async "media-orientation-unlock-request"(e){let t=e.type;try{this.#eD.queue.enqueue(t,e),await this.#e_.unlock()}catch(e){this.#eD.queue.delete(t)}}async "media-enter-pip-request"(e){try{await this.enterPictureInPicture(e)}catch(t){this.#eZ(t,e)}}async "media-exit-pip-request"(e){try{await this.exitPictureInPicture(e)}catch(t){this.#eZ(t,e)}}#eZ(e,t){this.#eP.handle(this.createEvent("picture-in-picture-error",{detail:(0,ac.coerceToError)(e)}))}"media-live-edge-request"(e){let{live:t,liveEdge:i,canSeek:s}=this.$state;if(!(!t()||s()&&i()))try{this.seekToLiveEdge(e)}catch(e){this.#eD.queue.delete("media-seek-request")}}async "media-loop-request"(e){try{this.#eD.looping=!0,this.#eD.replaying=!0,await this.play(e)}catch(e){this.#eD.looping=!1}}"media-user-loop-change-request"(e){this.$state.userPrefersLoop.set(e.detail)}
4async "media-pause-request"(e){if(!this.$state.paused())try{await this.pause(e)}catch(e){}}async "media-play-request"(e){if(this.$state.paused())try{await this.play(e)}catch(e){}}"media-rate-change-request"(e){let{playbackRate:t,canSetPlaybackRate:i}=this.$state;if(t()===e.detail||!i())return;let s=this.#e$();s?.setPlaybackRate&&(this.#eD.queue.enqueue("media-rate-change-request",e),s.setPlaybackRate(e.detail))}"media-audio-gain-change-request"(e){try{this.setAudioGain(e.detail,e)}catch(e){}}"media-quality-change-request"(e){let{qualities:t,storage:i,logger:s}=this.#y;if(t.readonly)return;this.#eD.queue.enqueue("media-quality-change-request",e);let r=e.detail;if(r<0)t.autoSelect(e),e.isOriginTrusted&&i?.setVideoQuality?.(null);else{let s=t[r];s&&(s.selected=!0,e.isOriginTrusted&&i?.setVideoQuality?.({id:s.id,width:s.width,height:s.height,bitrate:s.bitrate}))}}"media-pause-controls-request"(e){let t=e.type;this.#eD.queue.enqueue(t,e),this.controls.pause(e)}"media-resume-controls-request"(e){let t=e.type;this.#eD.queue.enqueue(t,e),this.controls.resume(e)}"media-seek-request"(e){let{canSeek:t,ended:i,live:s,seekableEnd:r,userBehindLiveEdge:a}=this.$state,n=e.detail;i()&&(this.#eD.replaying=!0);let l=e.type;this.#eD.seeking=!1,this.#eD.queue.delete(l);let o=nc(n,this.$state);Number.isFinite(o)&&t()&&(this.#eD.queue.enqueue(l,e),this.#e$().setCurrentTime(o),s()&&e.isOriginTrusted&&Math.abs(r()-o)>=2&&a.set(!0))}"media-seeking-request"(e){let t=e.type;this.#eD.queue.enqueue(t,e),this.$state.seeking.set(!0),this.#eD.seeking=!0}"media-start-loading"(e){if(this.$state.canLoad())return;let t=e.type;this.#eD.queue.enqueue(t,e),this.#eP.handle(this.createEvent("can-load"))}"media-poster-start-loading"(e){if(this.$state.canLoadPoster())return;let t=e.type;this.#eD.queue.enqueue(t,e),this.#eP.handle(this.createEvent("can-load-poster"))}"media-text-track-change-request"(e){let{index:t,mode:i}=e.detail,s=this.#y.textTracks[t];if(s){let t=e.type;this.#eD.queue.enqueue(t,e),s.setMode(i,e)}}"media-mute-request"(e){if(this.$state.muted())return;let t=e.type;this.#eD.queue.enqueue(t,e),this.#e$().setMuted(!0)}"media-unmute-request"(e){let{muted:t,volume:i}=this.$state;if(!t())return;let s=e.type;this.#eD.queue.enqueue(s,e),this.#y.$provider().setMuted(!1),0===i()&&(this.#eD.queue.enqueue(s,e),this.#e$().setVolume(.25))}"media-volume-change-request"(e){let{muted:t,volume:i}=this.$state,s=e.detail;if(i()===s)return;let r=e.type;this.#eD.queue.enqueue(r,e),this.#e$().setVolume(s),s>0&&t()&&(this.#eD.queue.enqueue(r,e),this.#e$().setMuted(!1))}#e0(e,t,i){}};function ll(e,t){if(!e||!t)throw Error("[vidstack] media not ready")}function lo(e,t){if(!t?.supported)throw Error("[vidstack] no fullscreen support")}var ld=class{seeking=!1;looping=!1;replaying=!1;queue=new ls};let lh=new Set(["auto-play","auto-play-fail","can-load","sources-change","source-change","load-start","abort","error","loaded-metadata","loaded-data","can-play","play","play-fail","pause","playing","seeking","seeked","waiting"]);var lu=class extends nU{#eD;#y;#e1=new Map;#e2=!1;#e5=[];#e3=[-1,-1];#e4=!1;#e8;constructor(e,t){super(),this.#eD=e,this.#y=t}onAttach(e){e.setAttribute("aria-busy","true"),new au.EventsController(this).add("fullscreen-change",this["fullscreen-change"].bind(this)).add("fullscreen-error",this["fullscreen-error"].bind(this)).add("orientation-change",this["orientation-change"].bind(this))}onConnect(e){(0,au.effect)(this.#e6.bind(this)),this.#e7(),this.#e9(),this.#te(),this.#tt(),(0,au.onDispose)(this.#ti.bind(this))}onDestroy(){let{audioTracks:e,qualities:t,textTracks:i}=this.#y;e[ac.ListSymbol.reset](),t[ac.ListSymbol.reset](),i[ac.ListSymbol.reset](),this.#ts()}handle(e){if(!this.scope)return;let t=e.type;(0,au.untrack)(()=>this[e.type]?.(e)),ac.IS_SERVER||(lh.has(t)&&this.#e1.set(t,e),this.dispatch(e))}#tr=!1;#tt(){this.#tr&&(requestAnimationFrame(()=>{this.scope&&this.#y.remote.play(new au.DOMEvent("dom-connect"))}),this.#tr=!1)}#ti(){this.#tr||(this.#tr=!this.$state.paused(),this.#y.$provider()?.pause())}#ta(){this.#tn(),this.#e2=!1,this.#eD.replaying=!1,this.#eD.looping=!1,this.#e4=!1,this.#e8=void 0,this.#e1.clear()}#tl(e,t){let i=this.#eD.queue.serve(e);
4i&&(t.request=i,t.triggers.add(i))}#e7(){this.#to(),this.#td();let e=this.#y.textTracks;new au.EventsController(e).add("add",this.#to.bind(this)).add("remove",this.#to.bind(this)).add("mode-change",this.#td.bind(this))}#e9(){let e=this.#y.qualities;new au.EventsController(e).add("add",this.#th.bind(this)).add("remove",this.#th.bind(this)).add("change",this.#tu.bind(this)).add("auto-change",this.#tc.bind(this)).add("readonly-change",this.#tf.bind(this))}#te(){let e=this.#y.audioTracks;new au.EventsController(e).add("add",this.#tp.bind(this)).add("remove",this.#tp.bind(this)).add("change",this.#tm.bind(this))}#to(e){let{textTracks:t}=this.$state;t.set(this.#y.textTracks.toArray()),this.dispatch("text-tracks-change",{detail:t(),trigger:e})}#td(e){e&&this.#tl("media-text-track-change-request",e);let t=this.#y.textTracks.selected,{textTrack:i}=this.$state;i()!==t&&(i.set(t),this.dispatch("text-track-change",{detail:t,trigger:e}))}#tp(e){let{audioTracks:t}=this.$state;t.set(this.#y.audioTracks.toArray()),this.dispatch("audio-tracks-change",{detail:t(),trigger:e})}#tm(e){let{audioTrack:t}=this.$state;t.set(this.#y.audioTracks.selected),e&&this.#tl("media-audio-track-change-request",e),this.dispatch("audio-track-change",{detail:t(),trigger:e})}#th(e){let{qualities:t}=this.$state;t.set(this.#y.qualities.toArray()),this.dispatch("qualities-change",{detail:t(),trigger:e})}#tu(e){let{quality:t}=this.$state;t.set(this.#y.qualities.selected),e&&this.#tl("media-quality-change-request",e),this.dispatch("quality-change",{detail:t(),trigger:e})}#tc(){let{qualities:e}=this.#y,t=e.auto;this.$state.autoQuality.set(t),t||this.#ts()}#tg=null;#ty(){this.#ts(),this.#tg=(0,au.effect)(()=>{let{qualities:e}=this.#y,{mediaWidth:t,mediaHeight:i}=this.$state,s=t(),r=i();if(0===s||0===r)return;let a=null,n=1/0;for(let t of e){let e=Math.abs(t.width-s)+Math.abs(t.height-r);e<n&&(n=e,a=t)}a&&e[ac.ListSymbol.select](a,!0,new au.DOMEvent("resize",{detail:{width:s,height:r}}))})}#ts(){this.#tg?.(),this.#tg=null}#tf(){this.$state.canSetQuality.set(!this.#y.qualities.readonly)}#e6(){let{canSetVolume:e,isGoogleCastConnected:t}=this.$state;t()?e.set(!1):(0,ac.canChangeVolume)().then(e.set)}"provider-change"(e){let t=this.#y.$provider(),i=e.detail;t?.type!==i?.type&&(t?.destroy?.(),t?.scope?.dispose(),this.#y.$provider.set(e.detail),t&&null===e.detail&&this.#tv(e))}"provider-loader-change"(e){}"auto-play"(e){this.$state.autoPlayError.set(null)}"auto-play-fail"(e){this.$state.autoPlayError.set(e.detail),this.#ta()}"can-load"(e){this.$state.canLoad.set(!0),this.#e1.set("can-load",e),this.#y.textTracks[ac.TextTrackSymbol.canLoad](),this.#tl("media-start-loading",e)}"can-load-poster"(e){this.$state.canLoadPoster.set(!0),this.#e1.set("can-load-poster",e),this.#tl("media-poster-start-loading",e)}"media-type-change"(e){let t=this.#e1.get("source-change");t&&e.triggers.add(t);let i=this.$state.viewType();this.$state.mediaType.set(e.detail);let s=this.$state.providedViewType(),r="unknown"===s?e.detail:s;i!==r&&(ac.IS_SERVER?this.$state.inferredViewType.set(r):setTimeout(()=>{requestAnimationFrame(()=>{this.scope&&(this.$state.inferredViewType.set(e.detail),this.dispatch("view-type-change",{detail:r,trigger:e}))})},0))}"stream-type-change"(e){let t=this.#e1.get("source-change");t&&e.triggers.add(t);let{streamType:i,inferredStreamType:s}=this.$state;s.set(e.detail),e.detail=i()}"rate-change"(e){let{storage:t}=this.#y,{canPlay:i}=this.$state;this.$state.playbackRate.set(e.detail),this.#tl("media-rate-change-request",e),i()&&t?.setPlaybackRate?.(e.detail)}"remote-playback-change"(e){let{remotePlaybackState:t,remotePlaybackType:i}=this.$state,{type:s,state:r}=e.detail,a="connected"===r;i.set(s),t.set(r);let n="airplay"===s?"media-airplay-request":"media-google-cast-request";if(a)this.#tl(n,e);else{let t=this.#eD.queue.peek(n);t&&(e.request=t,e.triggers.add(t))}}"sources-change"(e){let t=this.$state.sources(),i=e.detail;this.$state.sources.set(i),this.#tb(t,i,e)}#tb(e,t,i){let{qualities:s}=this.#y,r=!1,a=!1;for(let r of e)if(nl(r)&&!t.some(e=>e.src===r.src)){let e=s.getBySrc(r.src);e&&(s[ac.ListSymbol.remove](e,i),a=!0)}for(let e of(a&&!s.length&&(this.$state.savedState.set(null),s[ac.ListSymbol.reset](i)),t)){if(!nl(e)||s.getBySrc(e.src))continue;let t={id:e.id??e.height+"p",bitrate:null,codec:null,...e,selected:!1};s[ac.ListSymbol.add](t,i),r=!0}r&&!s[ac.QualitySymbol.enableAuto]&&(this.#ty(),s[ac.QualitySymbol.enableAuto]=this.#ty.bind(this),s[ac.QualitySymbol.setAuto](!0,i))}"source-change"(e){e.isQualityChange=e.originEvent?.type==="quality-change";let t=e.detail;this.#tv(e,e.isQualityChange),this.#e1.set(e.type,e),this.$state.source.set(t),this.el?.setAttribute("aria-busy","true")}#tv(e,t=!1){let{audioTracks:i,qualities:s}=this.#y;if(!t){this.#e5=[],this.#e3=[-1,-1],i[ac.ListSymbol.reset](e),s[ac.ListSymbol.reset](e),nu(this.$state,t),this.#ta();return}nu(this.$state,t),this.#ta()}abort(e){let t=this.#e1.get("source-change");t&&e.triggers.add(t);let i=this.#e1.get("can-load");i&&!e.triggers.hasType("can-load")&&e.triggers.add(i)}"load-start"(e){let t=this.#e1.get("source-change");t&&e.triggers.add(t)}error(e){this.$state.error.set(e.detail);let t=this.#e1.get("abort");t&&e.triggers.add(t)}"loaded-metadata"(e){let t=this.#e1.get("load-start");t&&e.triggers.add(t)}"loaded-data"(e){let t=this.#e1.get("load-start");t&&e.triggers.add(t)}"can-play"(e){let t=this.#e1.get("loaded-metadata");t&&e.triggers.add(t),this.#tE(e.detail),this.el?.setAttribute("aria-busy","false")}"can-play-through"(e){this.#tE(e.detail);let t=this.#e1.get("can-play");t&&e.triggers.add(t)}#tE(e){let{seekable:t,buffered:i,intrinsicDuration:s,canPlay:r}=this.$state;r.set(!0),i.set(e.buffered),t.set(e.seekable);let a=(0,ac.getTimeRangesEnd)(e.seekable)??1/0;s.set(a)}"duration-change"(e){let{live:t,intrinsicDuration:i,providedDuration:s,clipEndTime:r,ended:a}=this.$state,n=e.detail;if(!t()){let t=Number.isNaN(n)?0:n;i.set(t),a()&&this.#tS(e)}(s()>0||r()>0)&&e.stopImmediatePropagation()}progress(e){let{buffered:t,seekable:i}=this.$state,{buffered:s,seekable:r}=e.detail,a=(0,ac.getTimeRangesEnd)(s),n=s.length!==t().length,l=a!==(0,ac.getTimeRangesEnd)(t()),o=(0,ac.getTimeRangesEnd)(r),d=r.length!==i().length,h=o!==(0,ac.getTimeRangesEnd)(i());(n||l)&&t.set(s),(d||h)&&i.set(r)}play(e){let{paused:t,autoPlayError:i,ended:s,autoPlaying:r,playsInl
4ine:a,pointer:n,muted:l,viewType:o,live:d,userBehindLiveEdge:h}=this.$state;if(this.#tT(),!t())return void e.stopImmediatePropagation();e.autoPlay=r();let u=this.#e1.get("waiting");u&&e.triggers.add(u),this.#tl("media-play-request",e),this.#e1.set("play",e),t.set(!1),i.set(null),e.autoPlay&&(this.handle(this.createEvent("auto-play",{detail:{muted:l()},trigger:e})),r.set(!1)),(s()||this.#eD.replaying)&&(this.#eD.replaying=!1,s.set(!1),this.handle(this.createEvent("replay",{trigger:e}))),a()||"video"!==o()||"coarse"!==n()||this.#y.remote.enterFullscreen("prefer-media",e),d()&&!h()&&this.#y.remote.seekToLiveEdge(e)}#tT(e){if(!(0,au.peek)(this.#y.$provider))return;let{ended:t,seekableStart:i,clipEndTime:s,currentTime:r,realCurrentTime:a,duration:n}=this.$state,l=t()||a()<i()||s()>0&&a()>=s()||.1>Math.abs(r()-n());return l&&this.dispatch("media-seek-request",{detail:i(),trigger:e}),l}"play-fail"(e){let{muted:t,autoPlaying:i}=this.$state,s=this.#e1.get("play");s&&e.triggers.add(s),this.#tl("media-play-request",e);let{paused:r,playing:a}=this.$state;r.set(!0),a.set(!1),this.#ta(),this.#e1.set("play-fail",e),e.autoPlay&&(this.handle(this.createEvent("auto-play-fail",{detail:{muted:t(),error:e.detail},trigger:e})),i.set(!1))}playing(e){let t=this.#e1.get("play"),i=this.#e1.get("seeked");t?e.triggers.add(t):i&&e.triggers.add(i),setTimeout(()=>this.#ta(),0);let{paused:s,playing:r,live:a,liveSyncPosition:n,seekableEnd:l,started:o,currentTime:d,seeking:h,ended:u}=this.$state;if(s.set(!1),r.set(!0),h.set(!1),u.set(!1),this.#eD.looping){this.#eD.looping=!1;return}if(a()&&!o()&&0===d()){let e=n()??l()-2;Number.isFinite(e)&&this.#y.$provider().setCurrentTime(e)}this.started(e)}started(e){let{started:t}=this.$state;t()||(t.set(!0),this.handle(this.createEvent("started",{trigger:e})))}pause(e){this.el?.isConnected||(this.#tr=!0),this.#tl("media-pause-request",e);let t=this.#e1.get("seeked");t&&e.triggers.add(t);let{paused:i,playing:s}=this.$state;i.set(!0),s.set(!1),this.#e2&&setTimeout(()=>{this.handle(this.createEvent("end",{trigger:e})),this.#e2=!1},0),this.#ta()}"time-change"(e){if(this.#eD.looping)return void e.stopImmediatePropagation();let{waiting:t,played:i,clipEndTime:s,realCurrentTime:r,currentTime:a}=this.$state,n=e.detail,l=s();for(let i of(r.set(n),this.#tx(),t.set(!1),this.#y.textTracks))i[ac.TextTrackSymbol.updateActiveCues](n,e);l>0&&n>=l&&(this.#e2=!0,this.dispatch("media-pause-request",{trigger:e})),this.#tk(),this.dispatch("time-update",{detail:{currentTime:a(),played:i()},trigger:e})}#tx(){let{currentTime:e,played:t,paused:i}=this.$state;i()||(this.#e3=(0,ac.updateTimeIntervals)(this.#e5,this.#e3,e()),t.set(new ac.TimeRange(this.#e5)))}#tS(e){let{clipStartTime:t,clipEndTime:i,duration:s}=this.$state;t()>0||i()>0||this.handle(this.createEvent("time-change",{detail:s(),trigger:e}))}#tk(){let{storage:e}=this.#y,{canPlay:t,realCurrentTime:i}=this.$state;t()&&e?.setTime?.(i())}"audio-gain-change"(e){let{storage:t}=this.#y,{canPlay:i,audioGain:s}=this.$state;s.set(e.detail),this.#tl("media-audio-gain-change-request",e),i()&&t?.setAudioGain?.(s())}"volume-change"(e){let{storage:t}=this.#y,{volume:i,muted:s,canPlay:r}=this.$state,a=e.detail;i.set(a.volume),s.set(a.muted||0===a.volume),this.#tl("media-volume-change-request",e),this.#tl(a.muted?"media-mute-request":"media-unmute-request",e),r()&&(t?.setVolume?.(i()),t?.setMuted?.(s()))}seeking=(0,au.functionThrottle)(e=>{let{seeking:t,realCurrentTime:i,paused:s}=this.$state;t.set(!0),i.set(e.detail),this.#tl("media-seeking-request",e),s()&&(this.#e8=e,this.#tw()),this.#e3=[-1,-1]},150,{leading:!0});seeked(e){let{seeking:t,currentTime:i,realCurrentTime:s,paused:r,seekableEnd:a,ended:n,live:l}=this.$state;if(this.#eD.seeking)t.set(!0),e.stopImmediatePropagation();else if(t()){let i=this.#e1.get("waiting");i&&e.triggers.add(i);let a=this.#e1.get("seeking");a&&!e.triggers.has(a)&&e.triggers.add(a),r()&&this.#tn(),t.set(!1),s.set(e.detail),this.#tl("media-seek-request",e);let n=e?.originEvent;!n?.isTrusted||n instanceof MessageEvent||/seek/.test(n.type)||this.started(e)}l()||(Math.floor(i())!==Math.floor(a())?n.set(!1):this.end(e))}waiting(e){this.#e4||this.#eD.seeking||(e.stopImmediatePropagation(),this.#e8=e,this.#t
4w())}#tw=(0,au.functionDebounce)(()=>{if(!this.#e8)return;this.#e4=!0;let{waiting:e,playing:t}=this.$state;e.set(!0),t.set(!1);let i=this.createEvent("waiting",{trigger:this.#e8});this.#e1.set("waiting",i),this.dispatch(i),this.#e8=void 0,this.#e4=!1},300);end(e){let{loop:t,ended:i}=this.$state;if(!(!t()&&i())){if(t())return void setTimeout(()=>{requestAnimationFrame(()=>{this.#tT(e),this.dispatch("media-loop-request",{trigger:e})})},10);setTimeout(()=>this.#tA(e),0)}}#tA(e){let{storage:t}=this.#y,{paused:i,seeking:s,ended:r,duration:a}=this.$state;this.#tS(e),i()||this.dispatch("pause",{trigger:e}),s()&&this.dispatch("seeked",{detail:a(),trigger:e}),r.set(!0),this.#ta(),t?.setTime?.(a(),!0),this.dispatch("ended",{trigger:e})}#tn(){this.#tw.cancel(),this.$state.waiting.set(!1)}"fullscreen-change"(e){let t=e.detail;this.$state.fullscreen.set(t),this.#tl(t?"media-enter-fullscreen-request":"media-exit-fullscreen-request",e)}"fullscreen-error"(e){this.#tl("media-enter-fullscreen-request",e),this.#tl("media-exit-fullscreen-request",e)}"orientation-change"(e){let t=e.detail.lock;this.#tl(t?"media-orientation-lock-request":"media-orientation-unlock-request",e)}"picture-in-picture-change"(e){let t=e.detail;this.$state.pictureInPicture.set(t),this.#tl(t?"media-enter-pip-request":"media-exit-pip-request",e)}"picture-in-picture-error"(e){this.#tl("media-enter-pip-request",e),this.#tl("media-exit-pip-request",e)}"title-change"(e){e.trigger&&(e.stopImmediatePropagation(),this.$state.inferredTitle.set(e.detail))}"poster-change"(e){e.trigger&&(e.stopImmediatePropagation(),this.$state.inferredPoster.set(e.detail))}},lc=class extends nU{onSetup(){if(this.#er(),!ac.IS_SERVER)for(let e of[this.#tR,this.#tL,this.#tC,this.#tI,this.#S,this.#tP,this.#tD,this.#tM,this.#t_,this.#t$,this.#tO,this.#tN,this.#tF,this.#tB,this.#tU])(0,au.effect)(e.bind(this))}#er(){let e={duration:"providedDuration",loop:"providedLoop",poster:"providedPoster",streamType:"providedStreamType",title:"providedTitle",viewType:"providedViewType"},t=new Set(["currentTime","paused","playbackRate","volume"]);for(let i of Object.keys(this.$props))t.has(i)||this.$state[e[i]??i]?.set(this.$props[i]());this.$state.muted.set(this.$props.muted()||0===this.$props.volume())}#tB(){let{viewType:e,streamType:t,title:i,poster:s,loop:r}=this.$props,a=this.$state;a.providedPoster.set(s()),a.providedStreamType.set(t()),a.providedViewType.set(e()),a.providedTitle.set(i()),a.providedLoop.set(r())}#tj(){}#tR(){let{artist:e,artwork:t}=this.$props;this.$state.artist.set(e()),this.$state.artwork.set(t())}#tU(){let{title:e}=this.$state;this.dispatch("title-change",{detail:e()})}#tL(){let e=this.$props.autoPlay()||this.$props.autoplay();this.$state.autoPlay.set(e),this.dispatch("auto-play-change",{detail:e})}#tO(){let e=this.$state.loop();this.dispatch("loop-change",{detail:e})}#S(){let e=this.$props.controls();this.$state.controls.set(e)}#tF(){let{poster:e}=this.$state;this.dispatch("poster-change",{detail:e()})}#tP(){let e=this.$props.crossOrigin()??this.$props.crossorigin();this.$state.crossOrigin.set(!0===e?"":e)}#tD(){let{duration:e}=this.$props;this.dispatch("media-duration-change-request",{detail:e()})}#tN(){let e=this.$props.playsInline()||this.$props.playsinline();this.$state.playsInline.set(e),this.dispatch("plays-inline-change",{detail:e})}#tC(){let{clipStartTime:e}=this.$props;this.dispatch("media-clip-start-change-request",{detail:e()})}#tI(){let{clipEndTime:e}=this.$props;this.dispatch("media-clip-end-change-request",{detail:e()})}#tM(){this.dispatch("live-change",{detail:this.$state.live()})}#t$(){this.$state.liveEdgeTolerance.set(this.$props.liveEdgeTolerance()),this.$state.minLiveDVRWindow.set(this.$props.minLiveDVRWindow())}#t_(){this.dispatch("live-edge-change",{detail:this.$state.liveEdge()})}};let lf=["play","pause","seekforward","seekbackward","seekto"];var lp=class extends nU{onConnect(){(0,au.effect)(this.#tV.bind(this)),(0,au.effect)(this.#tG.bind(this));let e=this.#tq.bind(this);for(let t of lf)navigator.mediaSession.setActionHandler(t,e);(0,au.onDispose)(this.#eg.bind(this))}#eg(){for(let e of lf)navigator.mediaSession.setActionHandler(e,null)}#tV(){let{title:e,artist:t,artwork:i,poster:s}=this.$state;
4navigator.mediaSession.metadata=new MediaMetadata({title:e(),artist:t(),artwork:i()??[{src:s()}]})}#tG(){let{canPlay:e,paused:t}=this.$state;navigator.mediaSession.playbackState=e()?t()?"paused":"playing":"none"}#tq(e){let t=new au.DOMEvent("media-session-action",{detail:e});switch(e.action){case"play":this.dispatch("media-play-request",{trigger:t});break;case"pause":this.dispatch("media-pause-request",{trigger:t});break;case"seekto":case"seekforward":case"seekbackward":this.dispatch("media-seek-request",{detail:(0,au.isNumber)(e.seekTime)?e.seekTime:this.$state.currentTime()+(e.seekOffset??("seekforward"===e.action?10:-10)),trigger:t})}}};let lm=(0,au.signal)(!1);ac.IS_SERVER||((0,au.listenEvent)(document,"pointerdown",()=>{lm.set(!1)}),(0,au.listenEvent)(document,"keydown",e=>{e.metaKey||e.altKey||e.ctrlKey||lm.set(!0)}));var lg=class extends au.ViewController{#tH=(0,au.signal)(!1);onConnect(e){(0,au.effect)(()=>{let t=new au.EventsController(e);if(!lm()){this.#tH.set(!1),ly(e,!1),t.add("pointerenter",this.#tK.bind(this)).add("pointerleave",this.#tW.bind(this));return}let i=document.activeElement===e;this.#tH.set(i),ly(e,i),t.add("focus",this.#tz.bind(this)).add("blur",this.#tY.bind(this))})}focused(){return this.#tH()}#tz(){this.#tH.set(!0),ly(this.el,!0)}#tY(){this.#tH.set(!1),ly(this.el,!1)}#tK(){lv(this.el,!0)}#tW(){lv(this.el,!1)}};function ly(e,t){(0,au.setAttribute)(e,"data-focus",t),(0,au.setAttribute)(e,"data-hocus",t)}function lv(e,t){(0,au.setAttribute)(e,"data-hocus",t),(0,au.setAttribute)(e,"data-hover",t)}var lb=class e extends au.Component{static props=le;static state=no;#y;#eP;#tQ;canPlayQueue=new lr;remoteControl;get #tX(){return this.#y.$provider()}get #tJ(){return this.$props}constructor(){super(),new lc;const e={player:this,qualities:new nO,audioTracks:new nE,storage:null,$provider:(0,au.signal)(null),$providerSetup:(0,au.signal)(!1),$props:this.$props,$state:this.$state};e.remote=this.remoteControl=new nm(void 0),e.remote.setPlayer(this),e.textTracks=new n$,e.textTracks[ac.TextTrackSymbol.crossOrigin]=this.$state.crossOrigin,e.textRenderers=new n_(e),e.ariaKeys={},this.#y=e,(0,au.provideContext)(nf,e),this.orientation=new nX,new lg,new nG(e);const t=new ld;this.#eP=new lu(t,e),this.#tQ=new ln(this.#eP,t,e),e.delegate=new li(this.#eP.handle.bind(this.#eP),e),e.notify=e.delegate.notify.bind(e.delegate),"u">typeof navigator&&"mediaSession"in navigator&&new lp,new lt("load",this.startLoading.bind(this)),new lt("posterLoad",this.startLoadingPoster.bind(this))}onSetup(){this.#tZ(),(0,au.effect)(this.#t0.bind(this)),(0,au.effect)(this.#t1.bind(this)),(0,au.effect)(this.#en.bind(this)),(0,au.effect)(this.#t2.bind(this)),(0,au.effect)(this.#t5.bind(this)),(0,au.effect)(this.#tN.bind(this)),(0,au.effect)(this.#t3.bind(this))}onAttach(e){e.setAttribute("data-media-player",""),nx(e,"tabindex","0"),nx(e,"role","region"),(0,au.effect)(this.#t4.bind(this)),ac.IS_SERVER?this.#tU():(0,au.effect)(this.#tU.bind(this)),ac.IS_SERVER?this.#t8():(0,au.effect)(this.#t8.bind(this)),(0,au.listenEvent)(e,"find-media-player",this.#t6.bind(this))}onConnect(e){ac.IS_IPHONE&&(0,au.setAttribute)(e,"data-iphone","");let t=window.matchMedia("(pointer: coarse)");this.#t7(t),t.onchange=this.#t7.bind(this);let i=new ResizeObserver((0,au.animationFrameThrottle)(this.#t9.bind(this)));i.observe(e),(0,au.effect)(this.#t9.bind(this)),this.dispatch("media-player-connect",{detail:this,bubbles:!0,composed:!0}),(0,au.onDispose)(()=>{i.disconnect(),t.onchange=null})}onDestroy(){this.#y.player=null,this.canPlayQueue.reset()}#ie=!1;#tU(){let e=this.$el,{ariaLabel:t}=this.$props,{title:i,live:s,viewType:r,providedTitle:a}=this.$state,n=s(),l=(0,au.uppercaseFirstChar)(r()),o="Unknown"!==l?`${n?"Live ":""}${l}`:n?"Live":"Media",d=i(),h=t()||`${o} Player`+(d?` - ${d}`:"");(0,au.setAttribute)(this.el,"aria-label",h),!ac.IS_SERVER&&e?.hasAttribute("title")&&(this.#ie=!0,e?.removeAttribute("title"))}#t8(){let e=this.orientation.landscape?"landscape":"portrait";this.$state.orientation.set(e),(0,au.setAttribute)(this.el,"data-orientation",e),this.#t9()}#t0(){this.$state.canPlay()&&this.#tX?this.canPlayQueue.start():this.canPlayQueue.stop()}#tZ(){if(e[n7])return void this.setAttributes(e[n7]);let t={"data-load":function(){return this.$props.load()},"data-captions":function(){let e=this.$state.textTrack();return!!e&&(0,ac.isTrackCaptionKind)(e)}
4,"data-ios-controls":function(){return this.$state.iOSControls()},"data-controls":function(){return this.controls.showing},"data-buffering":function(){let{canLoad:e,canPlay:t,waiting:i}=this.$state;return e()&&(!t()||i())},"data-error":function(){let{error:e}=this.$state;return!!e()},"data-autoplay-error":function(){let{autoPlayError:e}=this.$state;return!!e()}},i={autoPlay:"autoplay",canAirPlay:"can-airplay",canPictureInPicture:"can-pip",pictureInPicture:"pip",playsInline:"playsinline",remotePlaybackState:"remote-state",remotePlaybackType:"remote-type",isAirPlayConnected:"airplay",isGoogleCastConnected:"google-cast"};for(let e of n9)t["data-"+(i[e]??(0,au.camelToKebabCase)(e))]=function(){return this.$state[e]()};delete t.title,e[n7]=t,this.setAttributes(t)}#t6(e){e.detail(this)}#t9(){if(ac.IS_SERVER||!this.el)return;let e=this.el.clientWidth,t=this.el.clientHeight;this.$state.width.set(e),this.$state.height.set(t),(0,au.setStyle)(this.el,"--player-width",e+"px"),(0,au.setStyle)(this.el,"--player-height",t+"px")}#t7(e){if(ac.IS_SERVER)return;let t=e.matches?"coarse":"fine";(0,au.setAttribute)(this.el,"data-pointer",t),this.$state.pointer.set(t),this.#t9()}get provider(){return this.#tX}get controls(){return this.#tQ.controls}set controls(e){this.#tJ.controls.set(e)}orientation;get title(){return(0,au.peek)(this.$state.title)}set title(e){if(this.#ie){this.#ie=!1;return}this.#tJ.title.set(e)}get qualities(){return this.#y.qualities}get audioTracks(){return this.#y.audioTracks}get textTracks(){return this.#y.textTracks}get textRenderers(){return this.#y.textRenderers}get duration(){return this.$state.duration()}set duration(e){this.#tJ.duration.set(e)}get paused(){return(0,au.peek)(this.$state.paused)}set paused(e){this.#it(e)}#en(){this.#it(this.$props.paused())}#it(e){e?this.canPlayQueue.enqueue("paused",()=>this.#tQ.pause()):this.canPlayQueue.enqueue("paused",()=>this.#tQ.play())}get muted(){return(0,au.peek)(this.$state.muted)}set muted(e){this.#ii(e)}#t1(){this.#ii(this.$props.muted())}#ii(e){this.canPlayQueue.enqueue("muted",()=>{(0,au.peek)(()=>{this.#tX&&this.#tX.setMuted(e)})})}get currentTime(){return(0,au.peek)(this.$state.currentTime)}set currentTime(e){this.#is(e)}#t5(){this.#is(this.$props.currentTime())}#is(e){this.canPlayQueue.enqueue("currentTime",()=>{let{currentTime:t}=this.$state;e!==(0,au.peek)(t)&&(0,au.peek)(()=>{if(!this.#tX)return;let t=nc(e,this.$state);Number.isFinite(t)&&this.#tX.setCurrentTime(t)})})}get volume(){return(0,au.peek)(this.$state.volume)}set volume(e){this.#ir(e)}#t2(){this.#ir(this.$props.volume())}#ir(e){let t=(0,ac.clampNumber)(0,e,1);this.canPlayQueue.enqueue("volume",()=>{this.#tX&&this.#tX.setVolume(t)})}get playbackRate(){return(0,au.peek)(this.$state.playbackRate)}set playbackRate(e){this.#ia(e)}#t3(){this.#ia(this.$props.playbackRate())}#ia(e){this.canPlayQueue.enqueue("rate",()=>{this.#tX&&this.#tX.setPlaybackRate?.(e)})}#tN(){this.#il(this.$props.playsInline())}#il(e){this.canPlayQueue.enqueue("playsinline",()=>{this.#tX&&this.#tX.setPlaysInline?.(e)})}#t4(){let e=this.$props.storage(),t=(0,au.isString)(e)?new ng:e;if(t?.onChange){let{source:i}=this.$state,s=(0,au.isString)(e)?e:this.el?.id,r=(0,au.computed)(this.#io.bind(this));(0,au.effect)(()=>t.onChange(i(),r(),s||void 0))}this.#y.storage=t,this.#y.textTracks.setStorage(t),(0,au.onDispose)(()=>{t?.onDestroy?.(),this.#y.storage=null,this.#y.textTracks.setStorage(null)})}#io(){let{clipStartTime:e,clipEndTime:t}=this.$props,{source:i}=this.$state,s=i();return s.src?`${s.src}:${e()}:${t()}`:null}async play(e){return this.#tQ.play(e)}async pause(e){return this.#tQ.pause(e)}async enterFullscreen(e,t){return this.#tQ.enterFullscreen(e,t)}async exitFullscreen(e,t){return this.#tQ.exitFullscreen(e,t)}enterPictureInPicture(e){return this.#tQ.enterPictureInPicture(e)}exitPictureInPicture(e){return this.#tQ.exitPictureInPicture(e)}seekToLiveEdge(e){this.#tQ.seekToLiveEdge(e)}startLoading(e){this.#y.notify("can-load",void 0,e)}startLoadingPoster(e){this.#y.notify("can-load-poster",void 0,e)}requestAirPlay(e){return this.#tQ.requestAirPlay(e)}requestGoogleCast(e){return this.#tQ.requestGoogleCast(e)}setAudioGain(e,t){return this.#tQ.setAudioGain(e,t)}destroy(){super.destroy(),this.#y.remote.setPlayer(null),this.dispatch("destroy")}};let lE=lb.prototype;(0,au.prop)(lE,"canPlayQueue"),(0,au.prop)(lE,"remoteControl"),(0,au.prop)(lE,"provider"),(0,au.prop)(lE,"controls"),(0,au.prop)(lE,"orientation"),(0,au.prop)(lE,"title"),
4(0,au.prop)(lE,"qualities"),(0,au.prop)(lE,"audioTracks"),(0,au.prop)(lE,"textTracks"),(0,au.prop)(lE,"textRenderers"),(0,au.prop)(lE,"duration"),(0,au.prop)(lE,"paused"),(0,au.prop)(lE,"muted"),(0,au.prop)(lE,"currentTime"),(0,au.prop)(lE,"volume"),(0,au.prop)(lE,"playbackRate"),(0,au.method)(lE,"play"),(0,au.method)(lE,"pause"),(0,au.method)(lE,"enterFullscreen"),(0,au.method)(lE,"exitFullscreen"),(0,au.method)(lE,"enterPictureInPicture"),(0,au.method)(lE,"exitPictureInPicture"),(0,au.method)(lE,"seekToLiveEdge"),(0,au.method)(lE,"startLoading"),(0,au.method)(lE,"startLoadingPoster"),(0,au.method)(lE,"requestAirPlay"),(0,au.method)(lE,"requestGoogleCast"),(0,au.method)(lE,"setAudioGain");let lS=new Map;var lT=class{#id=!1;#ih;#iu;#y;#ic;constructor(e,t,i,s=[]){this.#iu=e,this.#y=t,this.#ic=i;const r=new n1,a=new n0,n=new nZ,l=new nJ,o=[new n5,new n2];this.#ih=(0,au.computed)(()=>{let e=t.$state.remotePlaybackLoader(),i=t.$props.preferNativeHLS()?[n,l,r,a,...o,...s]:[a,n,l,r,...o,...s];return e?[e,...i]:i});const{$state:d}=t;for(const e of(d.sources.set(lx(t.$props.src())),d.sources())){const i=this.#ih().find(t=>t.canPlay(e));if(!i)continue;const s=i.mediaType(e);t.$state.source.set(e),t.$state.mediaType.set(s),t.$state.inferredViewType.set(s),this.#ic.set(i),this.#id=!0;break}}connect(){let e=this.#ic();this.#id&&(this.#ip(this.#y.$state.source(),e),this.#im(e),this.#id=!1),(0,au.effect)(this.#ig.bind(this)),(0,au.effect)(this.#iy.bind(this)),(0,au.effect)(this.#iv.bind(this)),(0,au.effect)(this.#ib.bind(this)),(0,au.effect)(this.#iE.bind(this))}#ig(){this.#y.notify("sources-change",[...lx(this.#y.$props.src()),...this.#iu()])}#iy(){let{$state:e}=this.#y,t=e.sources(),i=(0,au.peek)(e.source),s=this.#iS(i,t);if(t[0]?.src&&!s.src&&!s.type){let{crossOrigin:i}=e,s=(0,ac.getRequestCredentials)(i()),r=new AbortController;return Promise.all(t.map(e=>(0,au.isString)(e.src)&&"?"===e.type?fetch(e.src,{method:"HEAD",credentials:s,signal:r.signal}).then(t=>(e.type=t.headers.get("content-type")||"??",lS.set(e.src,e.type),e)).catch(()=>e):e)).then(t=>{if(r.signal.aborted)return;let i=this.#iS((0,au.peek)(e.source),t);(0,au.tick)(),i.src||this.#y.notify("error",{message:"Failed to load resource.",code:4})}),()=>r.abort()}(0,au.tick)()}#iS(e,t){let i={src:"",type:""},s=null,r=new au.DOMEvent("sources-change",{detail:{sources:t}}),a=this.#ih(),{started:n,paused:l,currentTime:o,quality:d,savedState:h}=this.#y.$state;for(let e of t){let t=a.find(t=>t.canPlay(e));if(t){i=e,s=t;break}}if(nl(i)){let e=d(),s=t.find(t=>t.src===e?.src);(0,au.peek)(n)?h.set({paused:(0,au.peek)(l),currentTime:(0,au.peek)(o)}):h.set(null),s&&(i=s,r=new au.DOMEvent("quality-change",{detail:{quality:e}}))}return lw(e,i)||this.#ip(i,s,r),s!==(0,au.peek)(this.#ic)&&this.#im(s,r),i}#ip(e,t,i){this.#y.notify("source-change",e,i),this.#y.notify("media-type-change",t?.mediaType(e)||"unknown",i)}#im(e,t){this.#y.$providerSetup.set(!1),this.#y.notify("provider-change",null,t),e&&(0,au.peek)(()=>e.preconnect?.(this.#y)),this.#ic.set(e),this.#y.notify("provider-loader-change",e,t)}#iv(){let e=this.#y.$provider();if(!(!e||(0,au.peek)(this.#y.$providerSetup))){if(this.#y.$state.canLoad()){(0,au.scoped)(()=>e.setup(),e.scope),this.#y.$providerSetup.set(!0);return}(0,au.peek)(()=>e.preconnect?.())}}#ib(){if(!this.#y.$providerSetup())return;let e=this.#y.$provider(),t=this.#y.$state.source(),i=(0,au.peek)(this.#y.$state.crossOrigin),s=(0,au.peek)(this.#y.$props.preferNativeHLS);if(!lw(e?.currentSrc,t)){if(this.#y.$state.canLoad()){let r=new AbortController;if((0,ac.isHLSSrc)(t))(s||!(0,ac.isHLSSupported)())&&(function e(t,i){return fetch(t,i).then(e=>e.text()).then(s=>{let r,a=(r=s.match(/#EXT-X-STREAM-INF:[^\n]+(\n[^\n]+)*/g))?r[0].split("\n")[1].trim():null;if(a)return e(/^https?:/.test(a)?a:new URL(a,t).href,i);let n=/EXT-X-PLAYLIST-TYPE:\s*VOD/.test(s)?"on-demand":"live";return"live"===n&&function(e){for(let t of e.split("\n"))if(t.startsWith("#EXT-X-TARGETDURATION")){let e=parseFloat(t.split(":")[1]);if(!isNaN(e))return e}return -1}(s)>=10&&(/#EXT-X-DVR-ENABLED:\s*true/.test(s)||s.includes("#EXT-X-DISCONTINUITY"))?"live:dvr":n})})(t.src,{credentials:(0,ac.getRequestCredentials)(i),signal:r.signal}).then(e=>{this.#y.notify("stream-type-change",e)}).catch(au.noop);else if((0,ac.isDASHSrc)(t))fetch(t.src,{credentials:(0,ac.getRequestCredentials)(i),signal:r.signal}).then(e=>e.text()).then(e=>/type="static"/.test(e)?"on-demand":"live").then(e=>{this.#y.notify("stream-type-change",e)}).catch(au.noop);else this.#y.notify("stream-type-change","on-demand");return(0,au.peek)(()=>{let i=(0,au.peek)(this.#y.$state.preload);return e?.loadSource(t,i).catch(e=>{})}),()=>r.abort()}try{(0,au.isString)(t.src)&&(0,ac.preconnect)(new URL(t.src).origin)}catch(e){}}}#iE(){let e=this.#ic(),{providedPoster:t,source:i,canLoadPoster:s}=this.#y.$state;if(!e||!e.loadPoster||!i()||!s()||t())return;let r=new AbortController,a=new au.DOMEvent("source-change",{detail:i});return e.loadPoster(i(),this.#y,r).then(e=>{this.#y.notify("poster-change",e||"",a)}).catch(()=>{this.#y.notify("poster-change","",a)}),()=>{r.abort()}}};function lx(e){return((0,au.isArray)(e)?e:[e]).map(e=>(0,au.isString)(e)?{src:e,type:lk(e)}:{...e,type:lk(e.src,e.type)})}function lk(e,t){if((0,au.isString)(t)&&t.length)return t;if((0,au.isString)(e)&&lS.has(e))return lS.get(e);if(!t&&(0,ac.isHLSSrc)({src:e,type:""}))return"application/x-mpegurl";if(!t&&(0,ac.isDASHSrc)({src:e,type:""}
4))return"application/dash+xml";if(!(0,au.isString)(e)||e.startsWith("blob:"))return"video/object";else if(e.includes("youtube")||e.includes("youtu.be"))return"video/youtube";else if(e.includes("vimeo")&&!e.includes("progressive_redirect")&&!e.includes(".m3u8"))return"video/vimeo";return"?"}function lw(e,t){return e?.src===t?.src&&e?.type===t?.type}var lA=class{#iT;#y;#ix=[];constructor(e,t){this.#iT=e,this.#y=t,(0,au.effect)(this.#ik.bind(this))}#ik(){let e=this.#iT();for(let t of this.#ix)if(!e.some(e=>e.id===t.id)){let e=t.id&&this.#y.textTracks.getById(t.id);e&&this.#y.textTracks.remove(e)}for(let t of e){let e=t.id||ac.TextTrack.createId(t);this.#y.textTracks.getById(e)||(t.id=e,this.#y.textTracks.add(t))}this.#ix=e}},lR=class extends au.Component{static props={loaders:[]};static state=new au.State({loader:null});#y;#iw;#iu=(0,au.signal)([]);#iT=(0,au.signal)([]);#ic=null;#e=null;#iA=!1;onSetup(){this.#y=np(),this.#iw=new lT(this.#iu,this.#y,this.$state.loader,this.$props.loaders())}onAttach(e){e.setAttribute("data-media-provider","")}onConnect(e){this.#iA=!0,this.#iw.connect(),new lA(this.#iT,this.#y);let t=new ResizeObserver((0,au.animationFrameThrottle)(this.#t9.bind(this)));t.observe(e);let i=new MutationObserver(this.#iR.bind(this));i.observe(e,{attributes:!0,childList:!0}),this.#t9(),this.#iR(),this.#e&&this.load(this.#e),(0,au.onDispose)(()=>{this.#iA=!1,t.disconnect(),i.disconnect()})}#iL=-1;load(e){this.#e=e||null,e?.setAttribute("aria-hidden","true"),this.#iA&&(window.cancelAnimationFrame(this.#iL),this.#iL=requestAnimationFrame(()=>this.#iC(e)),(0,au.onDispose)(()=>{window.cancelAnimationFrame(this.#iL)}))}#iC(e){if(!this.scope)return;let t=this.$state.loader(),{$provider:i}=this.#y;this.#ic===t&&t?.target===e&&(0,au.peek)(i)||(this.#iI(),this.#ic=t,t&&(t.target=e||null),t&&e&&t.load(this.#y).then(e=>{this.scope&&(0,au.peek)(this.$state.loader)===t&&this.#y.notify("provider-change",e)}))}onDestroy(){this.#ic=null,this.#iI()}#iI(){this.#y?.notify("provider-change",null)}#t9(){if(!this.el)return;let{player:e,$state:t}=this.#y,i=this.el.offsetWidth,s=this.el.offsetHeight;e&&(t.mediaWidth.set(i),t.mediaHeight.set(s),e.el&&((0,au.setStyle)(e.el,"--media-width",i+"px"),(0,au.setStyle)(e.el,"--media-height",s+"px")))}#iR(){let e=[],t=[];for(let i of this.el.children)if(!i.hasAttribute("data-vds")){if(i instanceof HTMLSourceElement){let t={id:i.id,src:i.src,type:i.type};for(let e of["id","src","width","height","bitrate","codec"]){let s=i.getAttribute(`data-${e}`);(0,au.isString)(s)&&(t[e]=/id|src|codec/.test(e)?s:Number(s))}e.push(t)}else if(i instanceof HTMLTrackElement){let e={src:i.src,kind:i.track.kind,language:i.srclang,label:i.label,default:i.default,type:i.getAttribute("data-type")};t.push({id:i.id||ac.TextTrack.createId(e),...e})}}this.#iu.set(e),this.#iT.set(t),(0,au.tick)()}};let lL=lR.prototype;(0,au.method)(lL,"load");var lC=class extends au.Component{static props={translations:null};static state=new au.State({label:null,busy:!1});#y;#iP=!1;onSetup(){this.#y=np()}onAttach(e){e.style.display="contents"}onConnect(e){e.setAttribute("data-media-announcer",""),nx(e,"role","status"),nx(e,"aria-live","polite");let{busy:t}=this.$state;this.setAttributes({"aria-busy":()=>t()?"true":null}),this.#iP=!0,(0,au.effect)(this.#en.bind(this)),(0,au.effect)(this.#t2.bind(this)),(0,au.effect)(this.#iD.bind(this)),(0,au.effect)(this.#iM.bind(this)),(0,au.effect)(this.#i_.bind(this)),(0,au.effect)(this.#i$.bind(this)),(0,au.effect)(this.#iO.bind(this)),(0,au.tick)(),this.#iP=!1}#en(){let{paused:e}=this.#y.$state;this.#iN(e()?"Pause":"Play")}#iM(){let{fullscreen:e}=this.#y.$state;this.#iN(e()?"Enter Fullscreen":"Exit Fullscreen")}#i_(){let{pictureInPicture:e}=this.#y.$state;this.#iN(e()?"Enter PiP":"Exit PiP")}#iD(){let{textTrack:e}=this.#y.$state;this.#iN(e()?"Closed-Captions On":"Closed-Captions Off")}#t2(){let{muted:e,volume:t,audioGain:i}=this.#y.$state;this.#iN(e()||0===t()?"Mute":`${Math.round(t()*(i()??1)*100)}% ${this.#iF("Volume")}`)}#iB=-1;#iU=-1;#i$(){let{seeking:e,currentTime:t}=this.#y.$state,i=e();this.#iB>0?(window.clearTimeout(this.#iU),this.#iU=window.setTimeout(()=>{if(!this.scope)return;let e=(0,au.peek)(t),i=Math.abs(e-this.#iB);if(i>=1){let t=e>=this.#iB,s=n6(i);this.#iN(`${this.#iF(t?"Seek Forward":"Seek Backward")} ${s}`)}this.#iB=-1,this.#iU=-1},300)):i&&(this.#iB=(0,au.peek)(t))}#iF(e){let{translations:t}=this.$props;return t?.()?.[e||""]??e}#iO(){let{label:e,busy:t}=this.$state,i=this.#iF(e());if(this.#iP)return;t.set(!0);let s=window.setTimeout(()=>void t.set(!1),150);return this.el&&(0,au.setAttribute)(this.el,"aria-label",i),(0,au.isString)(i)&&this.dispatch("change",{detail:i}),()=>window.clearTimeout(s)}#iN(e){let{label:t}=this.$state;t.set(e)}},lI=class extends au.Component{static props={hideDelay:2e3,hideOnMouseLeave:!1};#y;onSetup(){this.#y=np(),(0,au.effect)(this.#ij.bind(this))}onAttach(e){let{pictureInPicture:t,fullscreen:i}=this.#y.$state;(0,au.setStyle)(e,"pointer-events","none"),nx(e,"role","group"),this.setAttributes({"data-visible":this.#iV.bind(this),"data-fullscreen":i,"data-pip":t}),(0,au.effect)(()=>{this.dispatch("change",{detail:this.#iV()})}),(0,au.effect)(this.#iG.bind(this)),(0,au.effect)(()=>{let t=i();for(let i of["top","right","bottom","left"])(0,au.setStyle)(e,`padding-${i}`,t&&`env(safe-area-inset-${i})`)})}#iG(){if(!this.el)return;let{nativeControls:e}=this.#y.$state,t=e();(0,au.setAttribute)(this.el,"aria-hidden",t?"true":null),(0,au.setStyle)(this.el,"display",t?"none":null)}#ij(){let{controls:e}=this.#y.player,{hideDelay:t,hideOnMouseLeave:i}=this.$props;e.defaultDelay=2e3===t()?this.#y.$props.controlsDelay():t(),e.hideOnMouseLeave=i()}#iV(){let{controlsVisible:e}=this.#y.$state;return e()}},lP=class extends au.Component{onAttach(e){e.style.pointerEvents||(0,au.setStyle)(e,"pointer-events","auto")}},lD=class extends au.ViewController{#iq;constructor(e){super(),this.#iq=e,(0,au.effect)(this.#iH.bind(this))}onDestroy(){this.#iK?.(),this.#iK=null}#iH(){let e=this.#iq.trigger();if(!e)return void this.hide();let t=this.show.bind(this),i=this.hide.bind(this);this.#iq.listen(e,t,i)}#iW=-1;#iz=-1;#iK=null;show(e){this.#iY(),window.cancelAnimationFrame(this.#iz),this.#iz=-1,this.#iK?.(),this.#iK=null,this.#iW=window.setTimeout(()=>{this.#iW=-1;let t=this.#iq.content();t&&t.style.removeProperty("display"),(0,au.peek)(()=>this.#iq.onChange(!0,e))},this.#iq.showDelay?.()??0)}hide(e){this.#iY(),(0,au.peek)(()=>this.#iq.onChange(!1,e)),this.#iz=requestAnimationFrame(()=>{this.#iY(),this.#iz=-1;let e=this.#iq.content();if(e){let t=()=>{e.style.display="none",this.#iK=null};if("none"!==getComputedStyle(e).animationName){this.#iK?.();let i=(0,au.listenEvent)(e,"animationend",t,{once:!0});this.#iK=i}else t()}})}#iY(){window.clearTimeout(this.#iW),this.#iW=-1}};let lM=(0,au.createContext)(),l_=0;var l$=class extends au.Component{static props={showDelay:700};#iQ=`media-tooltip-${++l_}`;#iX=(0,au.signal)(null);#iJ=(0,au.signal)(null);#iZ=(0,au.signal)(!1);constructor(){super(),new lg;const{showDelay:e}=this.$props;new lD({trigger:this.#iX,content:this.#iJ,showDelay:e,listen(e,t,i){(0,au.effect)(()=>{lm()&&(0,au.listenEvent)(e,"focus",t),(0,au.listenEvent)(e,"blur",i)}),new au.EventsController(e).add("touchstart",e=>e.preventDefault(),{passive:!1}).add("mouseenter",t).add("mouseleave",i)},onChange:this.#i0.bind(this)})}onAttach(e){e.style.setProperty("display","contents")}onSetup(){(0,au.provideContext)(lM,{trigger:this.#iX,content:this.#iJ,showing:this.#iZ,attachTrigger:this.#i1.bind(this),detachTrigger:this.#i2.bind(this),attachContent:this.#i5.bind(this),detachContent:this.#i3.bind(this)})}#i1(e){this.#iX.set(e);let t=e.getAttribute("data-media-tooltip");t&&this.el?.setAttribute(`data-media-${t}-tooltip`,""),(0,au.setAttribute)(e,"data-describedby",this.#iQ)}#i2(e){e.removeAttribute("data-describedby"),e.removeAttribute("aria-describedby"),this.#iX.set(null)}#i5(e){e.setAttribute("id",this.#iQ),e.style.display="none",nx(e,"role","tooltip"),this.#iJ.set(e)}#i3(e){e.removeAttribute("id"),e.removeAttribute("role"),this.#iJ.set(null)}#i0(e){let t=this.#iX(),i=this.#iJ();for(let s of(t&&(0,au.setAttribute)(t,"aria-describedby",e?this.#iQ:null),[this.el,t,i]))s&&(0,au.setAttribute)(s,"data-visible",e);this.#iZ.set(e)}},lO=class extends au.Component{constructor(){super(),new lg}onConnect(e){(0,au.onDispose)(nI(()=>
4{if(!this.connectScope)return;this.#i4();let e=(0,au.useContext)(lM);(0,au.onDispose)(()=>{let t=this.#i8();t&&e.detachTrigger(t)})}))}#i4(){let e=this.#i8(),t=(0,au.useContext)(lM);e&&t.attachTrigger(e)}#i8(){let e=this.el.firstElementChild;return e?.localName==="button"||e?.getAttribute("role")==="button"?e:this.el}},lN=class extends au.Component{static props={placement:"top center",offset:0,alignOffset:0};constructor(){super(),new lg;const{placement:e}=this.$props;this.setAttributes({"data-placement":e})}onAttach(e){this.#i4(e),Object.assign(e.style,{position:"absolute",top:0,left:0,width:"max-content"})}onConnect(e){this.#i4(e);let t=(0,au.useContext)(lM);(0,au.onDispose)(()=>t.detachContent(e)),(0,au.onDispose)(nI(()=>{this.connectScope&&(0,au.effect)(this.#i6.bind(this))}))}#i4(e){(0,au.useContext)(lM).attachContent(e)}#i6(){let{showing:e}=(0,au.useContext)(lM);if(!e())return;let{placement:t,offset:i,alignOffset:s}=this.$props;return nP(this.el,this.#i7(),t(),{offsetVarName:"media-tooltip",xOffset:s(),yOffset:i()})}#i7(){return(0,au.useContext)(lM).trigger()}},lF=class extends au.ViewController{static props={disabled:!1};#iq;constructor(e){super(),this.#iq=e,new lg,e.keyShortcut&&new nH(e.keyShortcut)}onSetup(){let{disabled:e}=this.$props;this.setAttributes({"data-pressed":this.#iq.isPresssed,"aria-pressed":this.#i9.bind(this),"aria-disabled":()=>e()?"true":null})}onAttach(e){nx(e,"tabindex","0"),nx(e,"role","button"),nx(e,"type","button")}onConnect(e){let t=nL(e,this.#se.bind(this));for(let e of["click","touchstart"])t.add(e,this.#st.bind(this),{passive:!0})}#i9(){return(0,au.ariaBool)(this.#iq.isPresssed())}#si(e){(0,au.isWriteSignal)(this.#iq.isPresssed)&&this.#iq.isPresssed.set(e=>!e)}#se(e){if(this.$props.disabled()||this.el.hasAttribute("data-disabled")){e.preventDefault(),e.stopImmediatePropagation();return}e.preventDefault(),(this.#iq.onPress??this.#si).call(this,e)}#st(e){this.$props.disabled()&&(e.preventDefault(),e.stopImmediatePropagation())}},lB=class extends au.Component{static props={disabled:!1,defaultPressed:!1};#ss=(0,au.signal)(!1);get pressed(){return this.#ss()}constructor(){super(),new lF({isPresssed:this.#ss})}};let lU=lB.prototype;(0,au.prop)(lU,"pressed");var lj=class extends au.Component{static props=lF.props;#y;constructor(){super(),new lF({isPresssed:this.#sr.bind(this),onPress:this.#sa.bind(this)})}onSetup(){this.#y=np();let{canAirPlay:e,isAirPlayConnected:t}=this.#y.$state;this.setAttributes({"data-active":t,"data-supported":e,"data-state":this.#sn.bind(this),"aria-hidden":la(()=>!e())})}onAttach(e){e.setAttribute("data-media-tooltip","airplay"),nk(e,this.#sl.bind(this))}#sa(e){this.#y.remote.requestAirPlay(e)}#sr(){let{remotePlaybackType:e,remotePlaybackState:t}=this.#y.$state;return"airplay"===e()&&"disconnected"!==t()}#sn(){let{remotePlaybackType:e,remotePlaybackState:t}=this.#y.$state;return"airplay"===e()&&t()}#sl(){let{remotePlaybackState:e}=this.#y.$state;return`AirPlay ${e()}`}},lV=class extends au.Component{static props=lF.props;#y;constructor(){super(),new lF({isPresssed:this.#sr.bind(this),onPress:this.#sa.bind(this)})}onSetup(){this.#y=np();let{canGoogleCast:e,isGoogleCastConnected:t}=this.#y.$state;this.setAttributes({"data-active":t,"data-supported":e,"data-state":this.#sn.bind(this),"aria-hidden":la(()=>!e())})}onAttach(e){e.setAttribute("data-media-tooltip","google-cast"),nk(e,this.#sl.bind(this))}#sa(e){this.#y.remote.requestGoogleCast(e)}#sr(){let{remotePlaybackType:e,remotePlaybackState:t}=this.#y.$state;return"google-cast"===e()&&"disconnected"!==t()}#sn(){let{remotePlaybackType:e,remotePlaybackState:t}=this.#y.$state;return"google-cast"===e()&&t()}#sl(){let{remotePlaybackState:e}=this.#y.$state;return`Google Cast ${e()}`}},lG=class extends au.Component{static props=lF.props;#y;constructor(){super(),new lF({isPresssed:this.#sr.bind(this),keyShortcut:"togglePaused",onPress:this.#sa.bind(this)})}onSetup(){this.#y=np();let{paused:e,ended:t}=this.#y.$state;this.setAttributes({"data-paused":e,"data-ended":t})}onAttach(e){e.setAttribute("data-media-tooltip","play"),nk(e,"Play")}#sa(e){let t=this.#y.remote;this.#sr()?t.pause(e):t.play(e)}#sr(){let{paused:e}=this.#y.$state;return!e()}},lq=class extends au.Component{static props=lF.props;#y;constructor(){super(),new lF({isPresssed:this.#sr.bind(this),keyShortcut:"toggleCaptions",onPress:this.#sa.bind(this)})}onSetup(){this.#y=np(),this.setAttributes({"data-active":this.#sr.bind(this),"data-supported":()=>!this.#so(),"aria-hidden":la(this.#so.bind(this))})}onAttach(e){e.setAttribute("data-media-tooltip","caption"),nk(e,"Captions")}#sa(e){this.#y.remote.toggleCaptions(e)}#sr(){let{textTrack:e}=this.#y.$state,t=e();return!!t&&(0,ac.isTrackCaptionKind)(t)}#so(){let{hasCaptions:e}=this.#y.$state;return!e()}},lH=class extends au.Component{static props={...lF.props,target:"prefer-media"};#y;constructor(){super(),new lF({isPresssed:this.#sr.bind(this),keyShortcut:"toggleFullscreen",onPress:this.#sa.bind(this)})}onSetup(){this.#y=np();let{fullscreen:e}=this.#y.$state,t=this.#sd.bind(this);this.setAttributes({"data-active":e,"data-supported":t,"aria-hidden":la(()=>!t())})}onAttach(e){e.setAttribute("data-media-tooltip","fullscreen"),nk(e,"Fullscreen")}#sa(e){let t=this.#y.remote,i=this.$props.target();this.#sr()?t.exitFullscreen(i,e):t.enterFullscreen(i,e)}#sr(){let{fullscreen:e}=this.#y.$state;return e()}#sd(){let{canFullscreen:e}=this.#y.$state;return e()}},lK=class extends au.Component{static props=lF.props;#y;constructor(){super(),new lF({isPresssed:this.#sr.bind(this),keyShortcut:"toggleMuted",onPress:this.#sa.bind(this)})}onSetup(){this.#y=np(),this.setAttributes({"data-muted":this.#sr.bind(this),"data-state":this.#sn.bind(this)})}onAttach(e){e.setAttribute("data-media-mute-button",""),e.setAttribute("data-media-tooltip","mute"),nk(e,"Mute")}#sa(e){let t=this.#y.remote;this.#sr()?t.unmute(e):t.mute(e)}#sr(){let{muted:e,volume:t}=this.#y.$state;return e()||0===t()}#sn(){let{muted:e,volume:t}=this.#y.$state,i=t();return e()||0===i?"muted":i>=.5?"high":i<.5?"low":void 0}},lW=class extends au.Component{static props=lF.props;#y;constructor(){super(),new lF({isPresssed:this.#sr.bind(this),keyShortcut:"togglePictureInPicture",onPress:this.#sa.bind(this)})}onSetup(){this.#y=np();let{pictureInPicture:e}=this.#y.$state,t=this.#sd.bind(this);this.setAttributes({"data-active":e,"data-supported":t,"aria-hidden":la(()=>!t())})}onAttach(e){e.setAttribute("data-media-tooltip","pip"),nk(e,"PiP")}#sa(e){let t=this.#y.remote;this.#sr()?t.exitPictureInPicture(e):t.enterPictureInPicture(e)}#sr(){let{pictureInPicture:e}=this.#y.$state;return e()}#sd(){let{canPictureInPicture:e}=this.#y.$state;return e()}},lz=class extends au.Component{static props={disabled:!1,seconds:30};#y;constructor(){super(),new lg}onSetup(){this.#y=np();let{seeking:e}=this.#y.$state,{seconds:t}=this.$props,i=this.#sd.bind(this);this.setAttributes({seconds:t,"data-seeking":e,"data-supported":i,"aria-hidden":la(()=>!i())})}onAttach(e){nx(e,"tabindex","0"),nx(e,"role","button"),nx(e,"type","button"),e.setAttribute("data-media-tooltip","seek"),nk(e,this.#sl.bind(this))}onConnect(e){nL(e,this.#sa.bind(this))}#sd(){let{canSeek:e}=this.#y.$state;return e()}#sl(){let{seconds:e}=this.$props;return`Seek ${e()>0?"forward":"backward"} ${e()} seconds`}#sa(e){let{seconds:t,disabled:i}=this.$props;if(i())return;let{currentTime:s}=this.#y.$state,r=s()+t();this.#y.remote.seek(r,e)}},lY=class extends au.Component{static props={disabled:!1};#y;constructor(){super(),new lg}onSetup(){this.#y=np();let{disabled:e}=this.$props,{live:t,liveEdge:i}=this.#y.$state,s=()=>!t();this.setAttributes({"data-edge":i,"data-hidden":s,"aria-disabled":la(()=>e()||i()),"aria-hidden":la(s)})}onAttach(e){nx(e,"tabindex","0"),nx(e,"role","button"),nx(e,"type","button"),e.setAttribute("data-media-tooltip","live")}onConnect(e){nL(e,this.#sa.bind(this))}#sa(e){let{disabled:t}=this.$props,{liveEdge:i}=this.#y.$state;t()||i()||this.#y.remote.seekToLiveEdge(e)}};let lQ=new au.State({min:0,max:100,value:0,step:1,pointerValue:0,focused:!1,dragging:!1,pointing:!1,hidden:!1,get active(){return this.dragging||this.focused||this.pointing},get fillRate(){return lX(this.min,this.max,this.value)},get fillPercent(){return 100*this.fillRate},get pointerRate(){return lX(this.min,this.max,this.pointerValue)},get pointerPercent(){return 100*this.pointerRate}});function lX(e,t,i){let s=t-e;return s>0?(i-e)/s:0}var lJ=class extends au.ViewController{#er;#sh;constructor(e){super(),this.#er=e}onConnect(e){this.#sh=new IntersectionObserver(e=>{this.#er.callback?.(e,this.#sh)},this.#er),this.#sh.observe(e),(0,au.onDispose)(this.#eg.bind(this))}#eg(){this.#sh?.disconnect(),this.#sh=void 0}};let lZ=(0,au.createContext)(),l0=(0,au.createContext)(),l1={Left:-1,ArrowLeft:-1,Up:1,ArrowUp:1,Right:1,ArrowRight:1,Down:-1,ArrowDown:-1};var l2=class extends au.ViewController{#iq;#y;#sh;constructor(e,t){super(),this.#iq=e,this.#y=t}onSetup(){(0,au.hasProvidedContext)(l0)&&(this.#sh=(0,au.useContext)(l0)
4)}onConnect(e){(0,au.effect)(this.#su.bind(this,e)),(0,au.effect)(this.#sc.bind(this,e)),this.#iq.swipeGesture&&(0,au.effect)(this.#sf.bind(this))}#sf(){let{pointer:e}=this.#y.$state;if("coarse"!==e()||!this.#iq.swipeGesture()){this.#tX=null,this.#sp();return}(this.#tX=this.#y.player.el?.querySelector("media-provider,[data-media-provider]"),this.#tX)?new au.EventsController(this.#tX).add("touchstart",this.#sm.bind(this),{passive:!0}).add("touchmove",this.#sg.bind(this),{passive:!1}):this.#sp()}#tX=null;#sy=null;#sv=null;#sp(){this.#sy=null,this.#sv=null}#sm(e){this.#sy=e.touches[0]}#sg(e){if((0,au.isNull)(this.#sy)||nC(e))return;let t=e.touches[0],i=t.clientX-this.#sy.clientX,s=t.clientY-this.#sy.clientY,r=this.$state.dragging();!r&&Math.abs(s)>5||!r&&(e.preventDefault(),Math.abs(i)>20&&(this.#sy=t,this.#sv=this.$state.value(),this.#sb(this.#sv,e)))}#su(e){let{hidden:t}=this.$props;(0,au.listenEvent)(e,"focus",this.#tz.bind(this)),t()||this.#iq.isDisabled()||new au.EventsController(e).add("keyup",this.#U.bind(this)).add("keydown",this.#j.bind(this)).add("pointerenter",this.#tK.bind(this)).add("pointermove",this.#sE.bind(this)).add("pointerleave",this.#tW.bind(this)).add("pointerdown",this.#sS.bind(this))}#sc(e){!this.#iq.isDisabled()&&this.$state.dragging()&&new au.EventsController(document).add("pointerup",this.#sT.bind(this),{capture:!0}).add("pointermove",this.#sx.bind(this)).add("touchmove",this.#sk.bind(this),{passive:!1})}#tz(){this.#sw(this.$state.value())}#sA(e,t){let{value:i,min:s,max:r,dragging:a}=this.$state,n=Math.max(s(),Math.min(e,r()));i.set(n);let l=this.createEvent("value-change",{detail:n,trigger:t});if(this.dispatch(l),this.#iq.onValueChange?.(l),a()){let e=this.createEvent("drag-value-change",{detail:n,trigger:t});this.dispatch(e),this.#iq.onDragValueChange?.(e)}}#sw(e,t){let{pointerValue:i,dragging:s}=this.$state;i.set(e),this.dispatch("pointer-value-change",{detail:e,trigger:t}),s()&&this.#sA(e,t)}#sR(e){var t,i,s,r;let a,n=this.el.getBoundingClientRect(),{min:l,max:o}=this.$state;if("vertical"===this.$props.orientation()){let{bottom:t,height:i}=n;a=(t-e.clientY)/i}else if(this.#sy&&(0,au.isNumber)(this.#sv)&&this.#tX){let{width:t}=this.#tX.getBoundingClientRect(),i=(e.clientX-this.#sy.clientX)/t,s=o()-l(),r=s*Math.abs(i);a=(i<0?this.#sv-r:this.#sv+r)/s}else{this.#sy&&(0,au.isNumber)(this.#sv)&&this.#sp();let{left:t,width:i}=n;a=(e.clientX-t)/i}return Math.max(l(),Math.min(o(),this.#iq.roundValue((t=l(),i=o(),s=a,t+(r=this.#iq.getStep())*Math.round((i-t)*(0,ac.clampNumber)(0,s,1)/r)))))}#tK(e){this.$state.pointing.set(!0)}#sE(e){let{dragging:t}=this.$state;t()||this.#sw(this.#sR(e),e)}#tW(e){this.$state.pointing.set(!1)}#sS(e){if(0!==e.button)return;let t=this.#sR(e);this.#sb(t,e),this.#sw(t,e)}#sb(e,t){let{dragging:i}=this.$state;if(i())return;i.set(!0),this.#y.remote.pauseControls(t);let s=this.createEvent("drag-start",{detail:e,trigger:t});this.dispatch(s),this.#iq.onDragStart?.(s),this.#sh?.onDragStart?.()}#sL(e,t){let{dragging:i}=this.$state;if(!i())return;i.set(!1),this.#y.remote.resumeControls(t);let s=this.createEvent("drag-end",{detail:e,trigger:t});this.dispatch(s),this.#iq.onDragEnd?.(s),this.#sp(),this.#sh?.onDragEnd?.()}#sC;#sI=!1;#j(e){if(!Object.keys(l1).includes(e.key))return;let{key:t}=e,i=this.#sP(e);if(!(0,au.isNull)(i)){this.#sw(i,e),this.#sA(i,e);return}let s=this.#sD(e);this.#sI||(this.#sI=t===this.#sC,!this.$state.dragging()&&this.#sI&&this.#sb(s,e)),this.#sw(s,e),this.#sC=t}#U(e){if(!Object.keys(l1).includes(e.key)||!(0,au.isNull)(this.#sP(e)))return;let t=this.#sI?this.$state.pointerValue():this.#sD(e);this.#sA(t,e),this.#sL(t,e),this.#sC="",this.#sI=!1}#sP(e){let t=e.key,{min:i,max:s}=this.$state;return"Home"===t||"PageUp"===t?i():"End"===t||"PageDown"===t?s():!e.metaKey&&/^[0-9]$/.test(t)?(s()-i())/10*Number(t):null}#sD(e){let{key:t,shiftKey:i}=e;e.preventDefault(),e.stopPropagation();let{shiftKeyMultiplier:s}=this.$props,{min:r,max:a,value:n,pointerValue:l}=this.$state,o=this.#iq.getStep(),d=this.#iq.getKeyStep(),h=(i?d*s():d)*Number(l1[t]),u=((this.#sI?l():this.#iq.getValue?.()??n())+h)/o;return Math.max(r(),Math.min(a(),Number((o*u).toFixed(3))))}#sT(e){if(0!==e.button)return;e.preventDefault(),e.stopImmediatePropagation();let t=this.#sR(e);this.#sw(t,e),this.#sL(t,e)}#sk(e){e.preventDefault()}#sx=(0,au.functionThrottle)(e=>{this.#sw(this.#sR(e),e)},20,{leading:!0})};let l5=(0,au.createContext)(()=>({}));var l3=class extends au.ViewController{static props={hidden:!1,disabled:!1,step:1,keyStep:1,orientation:"horizontal",shiftKeyMultiplier:5};#y;#iq;#sM=(0,au.signal)(!0);#s_=(0,au.signal)(!0);constructor(e){super(),this.#iq=e}onSetup(){this.#y=np();let e=new lg;e.attach(this),this.$state.focused=e.focused.bind(e),(0,au.hasProvidedContext)(l5)||(0,au.provideContext)(l5,{default:"value"}),(0,au.provideContext)(lZ,{orientation:this.$props.orientation,disabled:this.#iq.isDisabled,preview:(0,au.signal)(null)}),(0,au.effect)(this.#s$.bind(this)),(0,au.effect)(this.#sO.bind(this)),(0,au.effect)(this.#sN.bind(this)),this.#sF(),new l2(this.#iq,this.#y).attach(this),new lJ({callback:this.#sB.bind(this)}).attach(this)}onAttach(e){nx(e,"role","slider"),nx(e,"tabindex","0"),nx(e,"autocomplete","off"),ac.IS_SERVER?this.#sU():(0,au.effect)(this.#sU.bind(this))}onConnect(e){(0,au.onDispose)(nA(e,this.#sM.set)),(0,au.effect)(this.#sj.bind(this))}#sB(e){this.#s_.set(e[0].isIntersecting)}#sj(){let{hidden:e}=this.$props;this.$state.hidden.set(e()||!this.#sM()||!this.#s_())}#s$(){let{dragging:e,value:t,min:i,max:s}=this.$state;if(!(0,au.peek)(e)){var r,a,n,l;t.set((r=i(),a=s(),n=t(),l=this.#iq.getStep(),(0,ac.clampNumber)(r,(0,ac.round)(n,(0,ac.getNumberOfDecimalPlaces)(l)),a)))}}#sO(){this.$state.step.set(this.#iq.getStep())}#sN(){if(!this.#iq.isDisabled())return;let{dragging:e,pointing:t}=this.$state;e.set(!1),t.set(!1)}#sV(){return(0,au.ariaBool)(this.#iq.isDisabled())}#sF(){let{orientation:e}=this.$props,{dragging:t,active:i,pointing:s}=this.$state;
4this.setAttributes({"data-dragging":t,"data-pointing":s,"data-active":i,"aria-disabled":this.#sV.bind(this),"aria-valuemin":this.#iq.aria.valueMin??this.$state.min,"aria-valuemax":this.#iq.aria.valueMax??this.$state.max,"aria-valuenow":this.#iq.aria.valueNow,"aria-valuetext":this.#iq.aria.valueText,"aria-orientation":e})}#sU(){let{fillPercent:e,pointerPercent:t}=this.$state;this.#sG((0,ac.round)(e(),3),(0,ac.round)(t(),3))}#sG=(0,au.animationFrameThrottle)((e,t)=>{this.el?.style.setProperty("--slider-fill",e+"%"),this.el?.style.setProperty("--slider-pointer",t+"%")})},l4=class extends au.Component{static props={...l3.props,min:0,max:100,value:0};static state=lQ;constructor(){super(),new l3({getStep:this.$props.step,getKeyStep:this.$props.keyStep,roundValue:Math.round,isDisabled:this.$props.disabled,aria:{valueNow:this.#sq.bind(this),valueText:this.#sH.bind(this)}})}onSetup(){(0,au.effect)(this.#s$.bind(this)),(0,au.effect)(this.#sK.bind(this))}#sq(){let{value:e}=this.$state;return Math.round(e())}#sH(){let{value:e,max:t}=this.$state;return(0,ac.round)(e()/t()*100,2)+"%"}#s$(){let{value:e}=this.$props;this.$state.value.set(e())}#sK(){let{min:e,max:t}=this.$props;this.$state.min.set(e()),this.$state.max.set(t())}};let l8=new Map,l6=new Map;var l7=class t{#y;#sW;#sz;$images=(0,au.signal)([]);static create(e,i){return new t(e,i,np())}constructor(e,t,i){this.#sW=e,this.#sz=t,this.#y=i,(0,au.effect)(this.#sY.bind(this))}#sY(){let{canLoad:t}=this.#y.$state;if(!t())return;let i=this.#sW();if(i){if((0,au.isString)(i)&&l8.has(i)){let e=l8.get(i);if(l8.delete(i),l8.set(i,e),l8.size>99){let e=l8.keys().next().value;l8.delete(e)}this.$images.set(l8.get(i))}else if((0,au.isString)(i)){let t=this.#sz(),s=i+"::"+t;if(!l6.has(s)){let r=new Promise(async(s,r)=>{try{let a=await fetch(i,{credentials:(0,ac.getRequestCredentials)(t)});if("application/json"===a.headers.get("content-type")){let e=await a.json();if((0,au.isArray)(e))if(e[0]&&"text"in e[0])s(this.#sQ(e));else{for(let t=0;t<e.length;t++){let i=e[t];(0,ac.assert)((0,au.isObject)(i),!1),(0,ac.assert)("url"in i&&(0,au.isString)(i.url),!1),(0,ac.assert)("startTime"in i&&(0,au.isNumber)(i.startTime),!1)}s(e)}else s(this.#sX(e));return}e.A(4004).then(async({parseResponse:e})=>{try{let{cues:t}=await e(a);s(this.#sQ(t))}catch(e){r(e)}})}catch(e){r(e)}}).then(e=>(l8.set(s,e),e)).catch(e=>{this.#em(i,e)}).finally(()=>{(0,au.isString)(s)&&l6.delete(s)});l6.set(s,r)}l6.get(s)?.then(e=>{this.$images.set(e||[])})}else if((0,au.isArray)(i))try{this.$images.set(this.#sJ(i))}catch(e){this.#em(i,e)}else try{this.$images.set(this.#sX(i))}catch(e){this.#em(i,e)}return()=>{this.$images.set([])}}}#sJ(e){let t=this.#sZ();return e.map((e,i)=>((0,ac.assert)(e.url&&(0,au.isString)(e.url),!1),(0,ac.assert)("startTime"in e&&(0,au.isNumber)(e.startTime),!1),{...e,url:(0,au.isString)(e.url)?this.#s0(e.url,t):e.url}))}#sX(e){(0,ac.assert)((0,au.isString)(e.url),!1),(0,ac.assert)((0,au.isArray)(e.tiles)&&e.tiles?.length,!1);let t=new URL(e.url),i=[],s="tile_width"in e?e.tile_width:e.tileWidth,r="tile_height"in e?e.tile_height:e.tileHeight;for(let a of e.tiles)i.push({url:t,startTime:"start"in a?a.start:a.startTime,width:s,height:r,coords:{x:a.x,y:a.y}});return i}#sQ(e){for(let t=0;t<e.length;t++){let i=e[t];(0,ac.assert)("startTime"in i&&(0,au.isNumber)(i.startTime),!1),(0,ac.assert)("text"in i&&(0,au.isString)(i.text),!1)}let t=[],i=this.#sZ();for(let s of e){let[e,r]=s.text.split("#"),a=this.#s1(r);t.push({url:this.#s0(e,i),startTime:s.startTime,endTime:s.endTime,width:a?.w,height:a?.h,coords:a&&(0,au.isNumber)(a.x)&&(0,au.isNumber)(a.y)?{x:a.x,y:a.y}:void 0})}return t}#sZ(){let e=(0,au.peek)(this.#sW);return(0,au.isString)(e)&&/^https?:/.test(e)?e:location.href}#s0(e,t){return/^https?:/.test(e)?new URL(e):new URL(e,t)}#s1(e){if(!e)return{};let[t,i]=e.split("="),s=i?.split(","),r={};if(!t||!s)return null;for(let e=0;e<t.length;e++){let i=+s[e];isNaN(i)||(r[t[e]]=i)}return r}#em(e,t){}};let l9=new Map;var oe=class extends au.Component{static props={src:null,time:0,crossOrigin:null};static state=new au.State({src:"",img:null,thumbnails:[],activeThumbn
4ail:null,crossOrigin:null,loading:!1,error:null,hidden:!1});media;#ic;#s2=[];onSetup(){this.media=np(),this.#ic=l7.create(this.$props.src,this.$state.crossOrigin),this.#tP(),this.setAttributes({"data-loading":this.#s5.bind(this),"data-error":this.#s3.bind(this),"data-hidden":this.$state.hidden,"aria-hidden":la(this.$state.hidden)})}onConnect(e){(0,au.effect)(this.#s4.bind(this)),(0,au.effect)(this.#sj.bind(this)),(0,au.effect)(this.#tP.bind(this)),(0,au.effect)(this.#s8.bind(this)),(0,au.effect)(this.#s6.bind(this)),(0,au.effect)(this.#s7.bind(this)),(0,au.effect)(this.#s9.bind(this))}#s4(){let e=this.$state.img();e&&new au.EventsController(e).add("load",this.#re.bind(this)).add("error",this.#em.bind(this))}#tP(){let{crossOrigin:e}=this.$props,{crossOrigin:t}=this.$state,{crossOrigin:i}=this.media.$state,s=null!==e()?e():i();t.set(!0===s?"anonymous":s)}#s8(){let{src:e,loading:t,error:i}=this.$state;return e()&&(t.set(!0),i.set(null)),()=>{this.#rt(),t.set(!1),i.set(null)}}#re(){let{loading:e,error:t}=this.$state;this.#s9(),e.set(!1),t.set(null)}#em(e){let{loading:t,error:i}=this.$state;t.set(!1),i.set(e)}#s5(){let{loading:e,hidden:t}=this.$state;return!t()&&e()}#s3(){let{error:e}=this.$state;return!(0,au.isNull)(e())}#sj(){let{hidden:e}=this.$state,{duration:t}=this.media.$state,i=this.#ic.$images();e.set(this.#s3()||!Number.isFinite(t())||0===i.length)}getTime(){return this.$props.time()}#s6(){let e=this.#ic.$images();if(!e.length)return;let t=this.getTime(),{src:i,activeThumbnail:s}=this.$state,r=-1,a=null;for(let i=e.length-1;i>=0;i--){let s=e[i];if(t>=s.startTime&&(!s.endTime||t<s.endTime)){r=i;break}}e[r]&&(a=e[r]),i.set(a?.url.href||""),s.set(a)}#s7(){if(ac.IS_SERVER)return;let e=this.#ic.$images(),t=this.$state.activeThumbnail();if(!t)return;let i=e.indexOf(t);if(i<0)return;let s=t.url.href,r=this.$state.crossOrigin(),a=i+1,n=Math.min(a+2,e.length);for(let t=a;t<n;t++){let i=e[t].url.href;i!==s&&function(e,t){let i=`${e}::${t}`;if(l9.has(i)){let e=l9.get(i);l9.delete(i),l9.set(i,e);return}let s=new Image;if(s.decoding="async",s.crossOrigin=t,s.src=e,l9.set(i,s),l9.size>32){let e=l9.keys().next().value;l9.delete(e)}}(i,r)}}#s9(){if(!this.scope||this.$state.hidden())return;let e=this.el,t=this.$state.img(),i=this.$state.activeThumbnail();if(!t||!i||!e)return;let s=i.width??t.naturalWidth,r=i?.height??t.naturalHeight,{maxWidth:a,maxHeight:n,minWidth:l,minHeight:o,width:d,height:h}=getComputedStyle(this.el);"100%"===l&&(l=parseFloat(d)+""),"100%"===o&&(o=parseFloat(h)+"");let u=Math.max(parseInt(l)/s,parseInt(o)/r),c=Math.min(Math.max(parseInt(l),parseInt(a))/s,Math.max(parseInt(o),parseInt(n))/r),f=!isNaN(c)&&c<1?c:u>1?u:1;this.#ri(e,"--thumbnail-width",`${s*f}px`),this.#ri(e,"--thumbnail-height",`${r*f}px`),this.#ri(e,"--thumbnail-aspect-ratio",String((0,ac.round)(s/r,5))),this.#ri(t,"width",`${t.naturalWidth*f}px`),this.#ri(t,"height",`${t.naturalHeight*f}px`),this.#ri(t,"transform",i.coords?`translate(-${i.coords.x*f}px, -${i.coords.y*f}px)`:""),this.#ri(t,"max-width","none")}#ri(e,t,i){e.style.setProperty(t,i),this.#s2.push(()=>e.style.removeProperty(t))}#rt(){for(let e of this.#s2)e();this.#s2=[]}},ot=class extends oe{#rs;onAttach(e){this.#rs=(0,au.useState)(l4.state)}getTime(){let{duration:e,clipStartTime:t}=this.media.$state;return t()+this.#rs.pointerRate()*e()}},oi=class extends au.Component{static props={src:null,crossOrigin:null};static state=new au.State({video:null,src:null,crossOrigin:null,canPlay:!1,error:null,hidden:!1});#y;#rs;get video(){return this.$state.video()}onSetup(){this.#y=np(),this.#rs=(0,au.useState)(l4.state),this.#tP(),this.setAttributes({"data-loading":this.#s5.bind(this),"data-hidden":this.$state.hidden,"data-error":this.#s3.bind(this),"aria-hidden":la(this.$state.hidden)})}onAttach(e){(0,au.effect)(this.#rr.bind(this)),(0,au.effect)(this.#ra.bind(this)),(0,au.effect)(this.#tP.bind(this)),(0,au.effect)(this.#sj.bind(this)),(0,au.effect)(this.#rn.bind(this)),(0,au.effect)(this.#rl.bind(this))}#rr(){let e=this.$state.video();e&&(e.readyState>=2&&this.#ro(),new au.EventsController(e).add("canplay",this.#ro.bind(this)).add("error",this.#em.bind(this)))}#ra(){let{src:e}
4=this.$state,{canLoad:t}=this.#y.$state;e.set(t()?this.$props.src():null)}#tP(){let{crossOrigin:e}=this.$props,{crossOrigin:t}=this.$state,{crossOrigin:i}=this.#y.$state,s=null!==e()?e():i();t.set(!0===s?"anonymous":s)}#s5(){let{canPlay:e,hidden:t}=this.$state;return!e()&&!t()}#s3(){let{error:e}=this.$state;return!(0,au.isNull)(e)}#sj(){let{src:e,hidden:t}=this.$state,{canLoad:i,duration:s}=this.#y.$state;t.set(i()&&(!e()||this.#s3()||!Number.isFinite(s())))}#rn(){let{src:e,canPlay:t,error:i}=this.$state;e(),t.set(!1),i.set(null)}#ro(e){let{canPlay:t,error:i}=this.$state;t.set(!0),i.set(null),this.dispatch("can-play",{trigger:e})}#em(e){let{canPlay:t,error:i}=this.$state;t.set(!1),i.set(e),this.dispatch("error",{trigger:e})}#rl(){let{video:e,canPlay:t}=this.$state,{duration:i}=this.#y.$state,{pointerRate:s}=this.#rs,r=e();t()&&r&&Number.isFinite(i())&&Number.isFinite(s())&&(r.currentTime=s()*i())}};let os=oi.prototype;(0,au.prop)(os,"video");var or=class extends au.Component{static props={type:"pointer",format:null,showHours:!1,showMs:!1,padHours:null,padMinutes:null,decimalPlaces:2};#rd;#rh;#rs;onSetup(){this.#rs=(0,au.useState)(l4.state),this.#rd=(0,au.useContext)(l5),this.#rh=(0,au.computed)(this.getValueText.bind(this))}getValueText(){let{type:e,format:t,decimalPlaces:i,padHours:s,padMinutes:r,showHours:a,showMs:n}=this.$props,{value:l,pointerValue:o,min:d,max:h}=this.#rs,u=t?.()??this.#rd.default,c="current"===e()?l():o();if("percent"===u){let e=c/(h()-d())*100;return(this.#rd.percent??ac.round)(e,i())+"%"}return"time"===u?(this.#rd.time??n8)(c,{padHrs:s(),padMins:r(),showHrs:a(),showMs:n()}):(this.#rd.value?.(c)??c.toFixed(2))+""}};let oa=or.prototype;(0,au.method)(oa,"getValueText");var on=class extends au.Component{static props={offset:0,noClamp:!1};#rs;onSetup(){this.#rs=(0,au.useContext)(lZ);let{active:e}=(0,au.useState)(l4.state);this.setAttributes({"data-visible":e})}onAttach(e){Object.assign(e.style,{position:"absolute",top:0,left:0,width:"max-content"})}onConnect(e){let{preview:t}=this.#rs;t.set(e),(0,au.onDispose)(()=>t.set(null)),(0,au.effect)(this.#ru.bind(this));let i=new ResizeObserver(this.#ru.bind(this));i.observe(e),(0,au.onDispose)(()=>i.disconnect())}#ru=(0,au.animationFrameThrottle)(()=>{let{disabled:e,orientation:t}=this.#rs;if(e())return;let i=this.el,{offset:s,noClamp:r}=this.$props;i&&function(e,{clamp:t,offset:i,orientation:s}){let r=getComputedStyle(e),a=parseFloat(r.width),n=parseFloat(r.height),l={top:null,right:null,bottom:null,left:null};if(l["horizontal"===s?"bottom":"left"]=`calc(100% + var(--media-slider-preview-offset, ${i}px))`,"horizontal"===s){let e=a/2;t?l.left=`min(max(0px, calc(var(--slider-pointer) - ${e}px)), calc(100% - ${a}px))`:l.left=`calc(var(--slider-pointer) - ${e}px)`}else{let e=n/2;t?l.bottom=`min(max(${e}px, calc(var(--slider-pointer) - ${e}px)), calc(100% - ${n}px))`:l.bottom=`calc(var(--slider-pointer) - ${e}px)`}Object.assign(e.style,l)}(i,{clamp:!r(),offset:s(),orientation:t()})})},ol=class extends au.Component{static props={...l3.props,keyStep:5,shiftKeyMultiplier:2};static state=lQ;#y;onSetup(){this.#y=np();let{audioGain:e}=this.#y.$state;(0,au.provideContext)(l5,{default:"percent",value:t=>(t*(e()??1)).toFixed(2),percent:t=>Math.round(t*(e()??1))}),new l3({getStep:this.$props.step,getKeyStep:this.$props.keyStep,roundValue:Math.round,isDisabled:this.#rc.bind(this),aria:{valueMax:this.#rf.bind(this),valueNow:this.#sq.bind(this),valueText:this.#sH.bind(this)},onDragValueChange:this.#rp.bind(this),onValueChange:this.#rm.bind(this)}).attach(this),(0,au.effect)(this.#t2.bind(this))}onAttach(e){e.setAttribute("data-media-volume-slider",""),nx(e,"aria-label","Volume");let{canSetVolume:t}=this.#y.$state;this.setAttributes({"data-supported":t,"aria-hidden":la(()=>!t())})}#sq(){let{value:e}=this.$state,{audioGain:t}=this.#y.$state;return Math.round(e()*(t()??1))}#sH(){let{value:e,max:t}=this.$state,{audioGain:i}=this.#y.$state;return(0,ac.round)(e()/t()*(i()??1)*100,2)+"%"}#rf(){let{audioGain:e}=this.#y.$state;return this.$state.max()*(e()??1)}#rc(){let{disabled:e}=this.$props,{canSetVolume:t}=this.#y.$state;return e()||!t()}#t2(){let{muted:e,volume:t}=this.#y.$state,i=e()?0:100*t();this.$state.value.set(i),this.dispatch("value-change",{detail:i})}#rg=(0,au.functionThrottle)(this.#ry.bind(this),25);#ry(e){if(!e.trigger)return;let t=(0,ac.round)(e.detail/100,3);this.#y.remote.changeVolume(t,e)}#rm(e){this.#rg(e)}#rp(e){this.#rg(e)}},oo=class extends au.Component{static props={...l3.props,step:25,keyStep:25,shiftKeyMultiplier:2,min:0,max:300};static state=lQ;#y;onSetup(){this.#y=np(),(0,au.provideContext)(l5,{default:"percent",percent:(e,t)=>
4(0,ac.round)(this.$state.value(),t)+"%"}),new l3({getStep:this.$props.step,getKeyStep:this.$props.keyStep,roundValue:Math.round,isDisabled:this.#rc.bind(this),aria:{valueNow:this.#sq.bind(this),valueText:this.#sH.bind(this)},onDragValueChange:this.#rp.bind(this),onValueChange:this.#rm.bind(this)}).attach(this),(0,au.effect)(this.#sK.bind(this)),(0,au.effect)(this.#rv.bind(this))}onAttach(e){e.setAttribute("data-media-audio-gain-slider",""),nx(e,"aria-label","Audio Boost");let{canSetAudioGain:t}=this.#y.$state;this.setAttributes({"data-supported":t,"aria-hidden":la(()=>!t())})}#sq(){let{value:e}=this.$state;return Math.round(e())}#sH(){let{value:e}=this.$state;return e()+"%"}#sK(){let{min:e,max:t}=this.$props;this.$state.min.set(e()),this.$state.max.set(t())}#rv(){let{audioGain:e}=this.#y.$state,t=((e()??1)-1)*100;this.$state.value.set(t),this.dispatch("value-change",{detail:t})}#rc(){let{disabled:e}=this.$props,{canSetAudioGain:t}=this.#y.$state;return e()||!t()}#rb(e){if(!e.trigger)return;let t=(0,ac.round)(1+e.detail/100,2);this.#y.remote.changeAudioGain(t,e)}#rm(e){this.#rb(e)}#rp(e){this.#rb(e)}},od=class extends au.Component{static props={...l3.props,step:.25,keyStep:.25,shiftKeyMultiplier:2,min:0,max:2};static state=lQ;#y;onSetup(){this.#y=np(),new l3({getStep:this.$props.step,getKeyStep:this.$props.keyStep,roundValue:this.#rE,isDisabled:this.#rc.bind(this),aria:{valueNow:this.#sq.bind(this),valueText:this.#sH.bind(this)},onDragValueChange:this.#rp.bind(this),onValueChange:this.#rm.bind(this)}).attach(this),(0,au.effect)(this.#sK.bind(this)),(0,au.effect)(this.#t3.bind(this))}onAttach(e){e.setAttribute("data-media-speed-slider",""),nx(e,"aria-label","Speed");let{canSetPlaybackRate:t}=this.#y.$state;this.setAttributes({"data-supported":t,"aria-hidden":la(()=>!t())})}#sq(){let{value:e}=this.$state;return e()}#sH(){let{value:e}=this.$state;return e()+"x"}#sK(){let{min:e,max:t}=this.$props;this.$state.min.set(e()),this.$state.max.set(t())}#t3(){let{playbackRate:e}=this.#y.$state,t=e();this.$state.value.set(t),this.dispatch("value-change",{detail:t})}#rE(e){return(0,ac.round)(e,2)}#rc(){let{disabled:e}=this.$props,{canSetPlaybackRate:t}=this.#y.$state;return e()||!t()}#rS=(0,au.functionThrottle)(this.#rT.bind(this),25);#rT(e){if(!e.trigger)return;let t=e.detail;this.#y.remote.changePlaybackRate(t,e)}#rm(e){this.#rS(e)}#rp(e){this.#rS(e)}},oh=class extends au.Component{static props={...l3.props,step:1,keyStep:1,shiftKeyMultiplier:1};static state=lQ;#y;#rx=(0,au.computed)(()=>{let{qualities:e}=this.#y.$state;return nN(e())});onSetup(){this.#y=np(),new l3({getStep:this.$props.step,getKeyStep:this.$props.keyStep,roundValue:Math.round,isDisabled:this.#rc.bind(this),aria:{valueNow:this.#sq.bind(this),valueText:this.#sH.bind(this)},onDragValueChange:this.#rp.bind(this),onValueChange:this.#rm.bind(this)}).attach(this),(0,au.effect)(this.#rk.bind(this)),(0,au.effect)(this.#rw.bind(this))}onAttach(e){e.setAttribute("data-media-quality-slider",""),nx(e,"aria-label","Video Quality");let{qualities:t,canSetQuality:i}=this.#y.$state,s=(0,au.computed)(()=>i()&&t().length>0);this.setAttributes({"data-supported":s,"aria-hidden":la(()=>!s())})}#sq(){let{value:e}=this.$state;return e()}#sH(){let{quality:e}=this.#y.$state;if(!e())return"";let{height:t,bitrate:i}=e(),s=i&&i>0?`${(i/1e6).toFixed(2)} Mbps`:null;return t?`${t}p${s?` (${s})`:""}`:"Auto"}#rk(){let e=this.#rx();this.$state.max.set(Math.max(0,e.length-1))}#rw(){let{quality:e}=this.#y.$state,t=Math.max(0,this.#rx().indexOf(e()));this.$state.value.set(t),this.dispatch("value-change",{detail:t})}#rc(){let{disabled:e}=this.$props,{canSetQuality:t,qualities:i}=this.#y.$state;return e()||i().length<=1||!t()}#rA=(0,au.functionThrottle)(this.#tu.bind(this),25);#tu(e){if(!e.trigger)return;let{qualities:t}=this.#y,i=(0,au.peek)(this.#rx)[e.detail];this.#y.remote.changeQuality(t.indexOf(i),e)}#rm(e){this.#rA(e)}#rp(e){this.#rA(e)}},ou=class extends au.Component{static props={...l3.props,step:.1,keyStep:5,shiftKeyMultiplier:2,pauseWhileDragging:!1,noSwipeGesture:!1,seekingRequestThrottle:100};static state=lQ;#y;#rR;#rL=(0,au.signal)(null);constructor(){super();const{noSwipeGesture:e}=this.$props;new l3({swipeGesture:()=>!e(),getValue:this.#rC.bind(this),getStep:this.#rI.bind(this),getKeyStep:this.#rP.bind(this),roundValue:this.#rE,isDisabled:this.#rc.bind(this),aria:{valueNow:this.#sq.bind(this),valueText:this.#sH.bind(this)},onDragStart:this.#rD.bind(this),onDragValueChange:this.#rp.bind(this),onDragEnd:this.#rM.bind(this),onValueChange:this.#rm.bind(this)})}onSetup(){this.#y=np(),(0,au.provideContext)(l5,{default:"time",value:this.#r_.bind(this),time:this.#r$.bind(this)}),this.setAttributes({"data-chapters":this.#rO.bind(this)}),this.setStyles({"--slider-progress":this.#rN.bind(this)}),(0,au.effect)(this.#t5.bind(this)),(0,au.effect)(this.#rF.bind(this))}onAttach(e){e.setAttribute("data-media-time-slider",""),nx(e,"aria-label","Seek")}onConnect(e){(0,au.effect)(this.#rB.bind(this)),(0,ac.watchActiveTextTrack)(this.#y.textTracks,"chapters",this.#rL.set)}#rN(){let{bufferedEnd:e,duration:t}=this.#y.$state;return(0,ac.round)(100*Math.min(e()/Math.max(t(),1),1),3)+"%"}#rO(){let{duration:e}=this.#y.$state;return this.#rL()?.cues.length&&Number.isFinite(e())&&e()>0}#rF(){this.#rR=(0,au.functionThrottle)(this.#W.bind(this),this.$props.seekingRequestThrottle())}#t5(){if(this.$state.hidden())return;let{value:e,dragging:t}=this.$state,i=this.#rC();(0,au.peek)(t)||(e.set(i),this.dispatch("value-change",{detail:i}))}#rB(){let e=this.#y.player.el,{preview:t}=(0,au.useContext)(lZ);e&&t()&&(0,au.setAttribute)(e,"data-preview",this.$state.active())}#W(e,t){this.#y.remote.seeking(e,t)}#rU(e,t,i){this.#rR.cancel();let{live:s}=this.#y.$state;s()&&t>=99?this.#y.remote.seekToLiveEdge(i):this.#y.remote.seek(e,i)}#rj=!1;#rD(e){let{pauseWhileDragging:t}=this.$props;if(t()){let{paused:t}=this.#y.$state;this.#rj=!t(),this.#y.remote.pause(e)}}#rp(e){this.#rR(this.#rV(e.detail),e)}#rM(e){let{seeking:t}=this.#y.$state;(0,au.peek)(t)||this.#W(this.#rV(e.detail),e);let i=e.detail;this.#rU(this.#rV(i),i,e);let{pauseWhileDragging:s}=this.$props;s()&&this.#rj&&(this.#y.remote.play(e),this.#rj=!1)}#rm(e){let{dragging:t}=this.$state;!t()&&e.trigger&&this.#rM(e)}#rC(){let{currentTime:e}=this.#y.$state;return this.#rG(e())}#rI(){let e=this.$props.step()/this.#y.$state.duration()*100;return Number.isFinite(e)?e:1}#rP(){let e=this.$props.keyStep()/this.#y.$state.duration()*100;return Number.isFinite(e)?e:1}#rE(e){return(0,ac.round)(e,3)}#rc(){let{disabled:e}=this.$props,{canSeek:t}=this.#y.$state;return e()||!t()}#sq(){let{value:e}=this.$state;return Math.round(e())}#sH(){let e=this.#rV(this.$state.value()),{duration:t}=this.#y.$state;return Number.isFinite(e)?`${n6(e)} out of ${n6(t())}`:"live"}#rV(e){let{duration:t}=this.#y.$state;return(0,ac.round)(e/100*t(),5)}#rG(e){let{liveEdge:t,duration:i}=this.#y.$state,s=Math.max(0,Math.min(1,t()?1:Math.min(e,i())/i()));return Number.isNaN(s)?0:Number.isFinite(s)?100*s:100}#r_(e){let t=this.#rV(e),{live:i,duration:s}=this.#y.$state;return Number.isFinite(t)?(i()?t-s():t).toFixed(0):"LIVE"}#r$(e,t){let i=this.#rV(e),{live:s,duration:r}=this.#y.$state,a=s()?i-r():i;return Number.isFinite(i)?`${a<0?"-":""}${n8(Math.abs(a),t)}`:"LIVE"}},oc=class extends au.Component{static props={disabled:!1};#y;#rq;#rH;#rK=null;#rW=[];#rz=(0,au.signal)(null);#rY=(0,au.signal)([]);#rQ=(0,au.signal)(-1);#rX=(0,au.signal)(-1);#rJ=0;get cues(){return this.#rY()}get activeCue(){return this.#rY()[this.#rQ()]||null}get activePointerCue(){return this.#rY()[this.#rX()]||null}onSetup(){this.#y=np(),this.#rq=(0,au.useState)(ou.state)}onAttach(e){(0,ac.watchActiveTextTrack)(this.#y.textTracks,"chapters",this.#rZ.bind(this)),(0,au.effect)(this.#r0.bind(this))}onConnect(){(0,au.onDispose)(()=>this.#r1.bind(this))}onDestroy(){this.#rZ(null)}setRefs(e){if(this.#rW=e,this.#rH?.dispose(),1===this.#rW.length){let e=this.#rW[0];e.style.width="100%",e.style.setProperty("--chapter-fill","var(--slider-fill)"),e.style.setProperty("--chapter-progress","var(--slider-progress)")}else this.#rW.length>0&&(0,au.scoped)(()=>this.#r2(),this.#rH=(0,au.createScope)())}#rZ(e){(0,au.peek)(this.#rz)!==e&&(this.#r1(),this.#rz.set(e))}#r1(){this.#rW=[],this.#rY.set([]),this.#rQ.set(-1),this.#rX.set(-1),this.#rJ=0,this.#rH?.dispose()}#r2(){this.#rW.length&&(0,au.effect)(this.#r5.bind(this))}#r5(){let{hidden:e}=this.#rq;e()||((0,au.effect)(this.#r3.bind(this)),(0,au.effect)(this.#r4.bind(this)),(0,au.effect)(this.#r8.bind(this)),(0,au.effect)(this.#r6.bind(this)))}#r3(){let e=this.#rY();if(!e.length)return;let t,{seekableStart:i,seekableEnd:s}=this.#y.$state,r=i(),a=(s()||e[e.length-1].endTime)-r,n=100;for(let i=0;i<e.length;i++)if(t=e[i],this.#rW[i]){let s=i===e.length-1?n:(0,ac.round)((t.endTime-Math.max(r,t.startTime))/a*100,3);this.#rW[i].style.width=s+"%",n-=s}}#r4(){let{liveEdge:e,seekableStart:t,seekableEnd:i}=this.#y.$state,{fillPercent:s,value:r}=this.#rq,a=this.#rY(),n=e(),l=(0,au.peek)(this.#rQ),o=a[l],d=n?this.#rY.length-1:this.#r7(o&&o.startTime/i()*100<=(0,au.peek)(r)?l:0,s());n||!o?this.#r9(0,a.length,100):d>l?this.#r9(l,d,100):d<l&&this.#r9(d+1,l+1,0);let h=n?100:this.#ae(a[d],s(),t(),this.#at(a));this.#ai(this.#rW[d],h),this.#rQ.set(d)}#r8(){let{hidden:e,pointerPercent:t}=this.#rq;if(e())return void this.#rX.set(-1);let i=this.#r7(0,t());this.#rX.set(i)}#r9(e,t,i){for(let s=e;s<t;s++)this.#ai(this.#rW[s],i)}#ai(e,t){e&&(e.style.setProperty("--chapter-fill",t+"%"),(0,au.setAttribute)(e,"data-active",t>0&&t<100),(0,au.setAttribute)(e,"data-ended",100===t))}#r7(e,t){let i=0,s=this.#rY();if(0===t)return 0;if(100===t)return s.length-1;let{seekableStart:r}=this.#y.$state,a=r(),n=this.#at(s);for(let r=e;r<s.length;r++)if((i=this.#ae(s[r],t,a,n))>=0&&i<100)return r;return 0}#r6(){this.#as(this.#ar())}#as=(0,au.animationFrameThrottle)(e=>{let t,i=this.#rY(),{seekableStart:s}=this.#y.$state,r=s(),a=this.#at(i);for(let s=this.#rJ;s<this.#rW.length;s++)if(t=this.#ae(i[s],e,r,a),this.#rW[s]?.style.setProperty("--chapter-progress",t+"%"),t<100){this.#rJ=s;break}});#ar=(0,au.computed)(this.#aa.bind(this));#aa(){let{bufferedEnd:e,duration:t}=this.#y.$state;return 100*(0,ac.round)(Math.min(e()/Math.max(t(),1),1),3)}#at(e){let{seekableEnd:t}=this.#y.$state,i=t();return Number.isFinite(i)?i:e[e.length-1]?.endTime||0}#ae(e,t,i,s){if(!e||0===this.#rY().length)return 0;let r=s-i,a=Math.max(0,e.startTime-i),n=Math.min(s,e.endTime)-i,l=a/r,o=100*l,d=100*Math.min(1,l+(n-a)/r);return Math.max(0,(0,ac.round)(t>=d?100:(t-o)/(d-o)*100,3))}#an(e){let t=[],{seekableStart:i,seekableEnd:s,duration:r}=this.#y.$state,a=i(),n=s(),l=(e=e.filter(e=>e.startTime<=n&&e.endTime>=a))[0];l&&l.startTime>a&&t.push(new window.VTTCue(a,l.startTime,""));for(let i=0;i<e.length-1;i++){let s=e[i],r=e[i+1];if(t.push(s),r){let e=r.startTime-s.endTime;e>0&&t.push(new window.VTTCue(s.endTime,s.endTime+e,""))}}let o=e[e.length-1];if(o){t.push(o);let e=r();e>=0&&e-o.endTime>1&&t.push(new window.VTTCue(o.endTime,r(),""))}return t}#r0(){let{source:e}=this.#y.$state;e(),this.#al()}#al(){if(!this.scope)return;let{disabled:e}=this.$props;if(e()){this.#rY.set([]),this.#rQ.set(0),this.#rJ=0;return}let t=this.#rz();if(t){let e=this.#ao.bind(this);e(),new au.EventsController(t).add("add-cue",e).add("remove-cue",e),(0,au.effect)(this.#ad.bind(this))}return this.#rK=this.#ah(),this.#rK&&(0,au.effect)(this.#au.bind(this)),()=>{this.#rK&&(this.#rK.textContent="",this.#rK=null)}}#ad(){this.#y.$state.duration(),this.#ao()}#ao=(0,au.functionDebounce)(()=>{let e=(0,au.peek)(this.#rz);this.scope&&e&&e.cues.length&&(this.#rY.set(this.#an(e.cues)),this.#rQ.set(0),this.#rJ=0)},150,!0);#au(){let e=this.activePointerCue||this.activeCue;this.#rK&&(this.#rK.textContent=e?.text||"")}#ac(){let e=this.el;
4for(;e&&"slider"!==e.getAttribute("role");)e=e.parentElement;return e}#ah(){let e=this.#ac();return e?e.querySelector('[data-part="chapter-title"]'):null}};let of=oc.prototype;(0,au.prop)(of,"cues"),(0,au.prop)(of,"activeCue"),(0,au.prop)(of,"activePointerCue"),(0,au.method)(of,"setRefs");let op=(0,au.createContext)(),om=["a[href]","[tabindex]","input","select","button"].map(e=>`${e}:not([aria-hidden='true'])`).join(","),og=new Set(["Escape","Tab","ArrowUp","ArrowDown","Home","PageUp","End","PageDown","Enter"," "]);var oy=class{#af=-1;#ap=null;#am=[];#iq;get items(){return this.#am}constructor(e){this.#iq=e}attachMenu(e){(0,au.listenEvent)(e,"focus",this.#tz.bind(this)),this.#ap=e,(0,au.onDispose)(()=>{this.#ap=null})}listen(){this.#ap&&(this.update(),new au.EventsController(this.#ap).add("keyup",this.#U.bind(this)).add("keydown",this.#j.bind(this)),(0,au.onDispose)(()=>{this.#af=-1,this.#am=[]}))}update(){this.#af=0,this.#am=this.#ag()}scroll(e=this.#ay()){let t=this.#am[e];t&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{!function(e,t={}){var i={scrollMode:"if-needed",block:"center",inline:"center",...t};for(let{el:t,top:s,left:r}of(0,au.r)(e,i))t.scroll({top:s,left:r,behavior:i.behavior})}(t,{behavior:"smooth",boundary:e=>!e.hasAttribute("data-root")})})})}focusActive(e=!0){let t=this.#ay();this.#av(t>=0?t:0,e)}#av(e,t=!0){this.#af=e,this.#am[e]?(this.#am[e].focus({preventScroll:!0}),t&&this.scroll(e)):this.#ap?.focus({preventScroll:!0})}#ay(){return this.#am.findIndex(e=>document.activeElement===e||"menuitemradio"===e.getAttribute("role")&&"true"===e.getAttribute("aria-checked"))}#tz(){this.#af>=0||(this.update(),this.focusActive())}#ab(e){let t=e.target;if((0,au.wasEnterKeyPressed)(e)&&t instanceof Element){let e=t.getAttribute("role");return!/a|input|select|button/.test(t.localName)&&!e}return og.has(e.key)}#U(e){this.#ab(e)&&(e.stopPropagation(),e.preventDefault())}#j(e){if(this.#ab(e))switch(e.stopPropagation(),e.preventDefault(),e.key){case"Escape":this.#iq.closeMenu(e);break;case"Tab":this.#av(this.#aE(e.shiftKey?-1:1));break;case"ArrowUp":this.#av(this.#aE(-1));break;case"ArrowDown":this.#av(this.#aE(1));break;case"Home":case"PageUp":this.#av(0);break;case"End":case"PageDown":this.#av(this.#am.length-1)}}#aE(e){let t=this.#af;do t=(t+e+this.#am.length)%this.#am.length;while(this.#am[t]?.offsetParent===null)return t}#ag(){if(!this.#ap)return[];let e=this.#ap.querySelectorAll(om),t=[],i=e=>"menu"===e.getAttribute("role");for(let s of e)nD(s)&&null!==s.offsetParent&&nR(this.#ap,s,i)&&t.push(s);return t}};function ov(e,t,i,s){var r,a=arguments.length,n=a<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,s);else for(var l=e.length-1;l>=0;l--)(r=e[l])&&(n=(a<3?r(n):a>3?r(t,i,n):r(t,i))||n);return a>3&&n&&Object.defineProperty(t,i,n),n}let ob=0;var oE=class extends au.Component{static props={showDelay:0};#y;#aS;#aT;#ax=(0,au.signal)(!1);#ak=(0,au.signal)(!1);#iX=(0,au.signal)(null);#iJ=(0,au.signal)(null);#aw;#aA=new Set;#aR=null;#aL;#aC;#aI=!1;#aP=(0,au.signal)(!1);#aD=new Set;get triggerElement(){return this.#iX()}get contentElement(){return this.#iJ()}get isSubmenu(){return!!this.#aw}constructor(){super();const{showDelay:e}=this.$props;this.#aL=new lD({trigger:this.#iX,content:this.#iJ,showDelay:e,listen:(e,t,i)=>{nL(e,e=>{this.#ax()?i(e):t(e)});let s=this.#aM();s&&nL(s,e=>{e.stopPropagation(),i(e)})},onChange:this.#a_.bind(this)})}onSetup(){this.#y=np();let e=++ob;this.#aS=`media-menu-${e}`,this.#aT=`media-menu-button-${e}`,this.#aC=new oy({closeMenu:this.close.bind(this)}),(0,au.hasProvidedContext)(op)&&(this.#aw=(0,au.useContext)(op)),this.#a$(),this.setAttributes({"data-open":this.#ax,"data-root":!this.isSubmenu,"data-submenu":this.isSubmenu,"data-disabled":this.#rc.bind(this)}),(0,au.provideContext)(op,{button:this.#iX,content:this.#iJ,expanded:this.#ax,hint:(0,au.signal)(""),submenu:!!this.#aw,disable:this.#aO.bind(this),attachMenuButton:this.#aN.bind(this),attachMenuItems:this.#aF.bind(this),attachObserver:this.#aB.bind(this),disableMenuButton:this.#aU.bind(this),addSubmenu:this.#aj.bind(this),onTransitionEvent:e=>{this.#aD.add(e),(0,au.onDispose)(()=>{this.#aD.delete(e)})}})}onAttach(e){e.style.setProperty("display","contents")}onConnect(e){(0,au.effect)(this.#aV.bind(this)),this.isSubmenu&&this.#aw?.addSubmenu(this)}onDestroy(){this.#iX.set(null),this.#iJ.set(null),this.#aR=null,this.#aD.clear()}#a$(){let e=-1,t=(0,au.hasProvidedContext)(l0)?(0,au.useContext)(l0):null;(0,au.provideContext)(l0,{onDragStart:()=>{t?.onDragStart?.(),window.clearTimeout(e),e=-1,this.#aI=!0},onDragEnd:()=>{t?.onDragEnd?.(),e=window.setTimeout(()=>{this.#aI=!1,e=-1},300)}})}#aV(){let e=this.#aG();this.isSubmenu||this.#t9(),this.#aq(e),e&&((0,au.effect)(()=>{let{height:e}=this.#y.$state,t=this.#iJ();t&&(0,au.setStyle)(t,"--player-height",e()+"px")}),this.#aC.listen(),this.listen("pointerup",this.#aH.bind(this)),(0,au.listenEvent)(window,"pointerup",this.#aK.bind(this)))}#aN(e){let t=e.el,i=this.isSubmenu,s=la(this.#rc.bind(this));nx(t,"tabindex",i?"-1":"0"),nx(t,"role",i?"menuitem":"button"),(0,au.setAttribute)(t,"i
4d",this.#aT),(0,au.setAttribute)(t,"aria-haspopup","menu"),(0,au.setAttribute)(t,"aria-expanded","false"),(0,au.setAttribute)(t,"data-root",!this.isSubmenu),(0,au.setAttribute)(t,"data-submenu",this.isSubmenu);let r=()=>{(0,au.setAttribute)(t,"data-open",this.#ax()),(0,au.setAttribute)(t,"aria-disabled",s())};ac.IS_SERVER?r():(0,au.effect)(r),this.#iX.set(t),(0,au.onDispose)(()=>{this.#iX.set(null)})}#aF(e){let t=e.el;t.style.setProperty("display","none"),(0,au.setAttribute)(t,"id",this.#aS),nx(t,"role","menu"),nx(t,"tabindex","-1"),(0,au.setAttribute)(t,"data-root",!this.isSubmenu),(0,au.setAttribute)(t,"data-submenu",this.isSubmenu),this.#iJ.set(t),(0,au.onDispose)(()=>this.#iJ.set(null));let i=()=>(0,au.setAttribute)(t,"data-open",this.#ax());ac.IS_SERVER?i():(0,au.effect)(i),this.#aC.attachMenu(t),this.#aq(!1);let s=this.#aW.bind(this);this.isSubmenu?this.#aw?.onTransitionEvent(s):(e.listen("transitionstart",s),e.listen("transitionend",s),e.listen("animationend",this.#t9),e.listen("vds-menu-resize",this.#t9))}#aB(e){this.#aR=e}#aq(e){let t=(0,au.peek)(this.#iJ);t&&(0,au.setAttribute)(t,"aria-hidden",(0,au.ariaBool)(!e))}#aU(e){this.#aP.set(e)}#az=!1;#a_(e,t){if(this.#az=(0,au.isKeyboardEvent)(t),t?.stopPropagation(),this.#ax()===e)return;if(this.#rc()){e&&this.#aL.hide(t);return}this.el?.dispatchEvent(new Event("vds-menu-resize",{bubbles:!0,composed:!0}));let i=this.#iX(),s=this.#iJ();if(i&&((0,au.setAttribute)(i,"aria-controls",e&&this.#aS),(0,au.setAttribute)(i,"aria-expanded",(0,au.ariaBool)(e))),s&&(0,au.setAttribute)(s,"aria-labelledby",e&&this.#aT),this.#ax.set(e),this.#aY(t),(0,au.tick)(),this.#az)for(let t of(e?s?.focus():i?.focus(),[this.el,s]))t&&t.setAttribute("data-keyboard","");else for(let e of[this.el,s])e&&e.removeAttribute("data-keyboard");if(this.dispatch(e?"open":"close",{trigger:t}),e)this.isSubmenu||this.#y.activeMenu===this||(this.#y.activeMenu?.close(t),this.#y.activeMenu=this),this.#aR?.onOpen?.(t);else{if(this.isSubmenu)for(let e of this.#aA)e.close(t);else this.#y.activeMenu=null;this.#aR?.onClose?.(t)}e&&requestAnimationFrame(this.#aQ.bind(this))}#aQ(){this.#aX||this.#aJ||(this.#aC.update(),requestAnimationFrame(()=>{this.#az?this.#aC.focusActive():this.#aC.scroll()}))}#aG(){return!this.#rc()&&this.#ax()}#rc(){return this.#ak()||this.#aP()}#aO(e){this.#ak.set(e)}#aH(e){let t=this.#iJ();this.#aI||t&&nS(t,e)||e.stopPropagation()}#aK(e){let t=this.#iJ();this.#aI||t&&nS(t,e)||this.close(e)}#aM(){let e=this.el?.querySelector('[data-part="close-target"]');return this.el&&e&&nR(this.el,e,e=>"menu"===e.getAttribute("role"))?e:null}#aY(e){this.isSubmenu||(this.#ax()?this.#y.remote.pauseControls(e):this.#y.remote.resumeControls(e))}#aj(e){this.#aA.add(e),new au.EventsController(e).add("open",this.#aZ).add("close",this.#a0),(0,au.onDispose)(this.#a1)}#a1=this.#a2.bind(this);#a2(e){this.#aA.delete(e)}#aJ=!1;#aZ=this.#a5.bind(this);#a5(e){this.#aJ=!0;let t=this.#iJ();for(let t of(this.isSubmenu&&this.triggerElement?.setAttribute("aria-hidden","true"),this.#aA))if(t!==e.target)for(let e of[t.el,t.triggerElement])e?.setAttribute("aria-hidden","true");if(t){let i=e.target.el;for(let e of t.children)e.contains(i)?e.setAttribute("data-open",""):e!==i&&e.setAttribute("data-hidden","")}}#a0=this.#a3.bind(this);#a3(e){this.#aJ=!1;let t=this.#iJ();for(let e of(this.isSubmenu&&this.triggerElement?.setAttribute("aria-hidden","false"),this.#aA))for(let t of[e.el,e.triggerElement])t?.setAttribute("aria-hidden","false");if(t)for(let e of t.children)e.removeAttribute("data-open"),e.removeAttribute("data-hidden")}#t9=(0,au.animationFrameThrottle)(()=>{let e=(0,au.peek)(this.#iJ);if(!e||ac.IS_SERVER)return;let t=0,i=getComputedStyle(e),s=[...e.children];for(let e of["paddingTop","paddingBottom","borderTopWidth","borderBottomWidth"])t+=parseFloat(i[e])||0;for(let e of s)if(nD(e)&&"contents"===e.style.display)s.push(...e.children);else if(3===e.nodeType)t+=parseFloat(getComputedStyle(e).fontSize);else if(nD(e)){if(!nw(e))continue;let i=getComputedStyle(e);t+=e.offsetHeight+(parseFloat(i.marginTop)||0)+(parseFloat(i.marginBottom)||
40)}(0,au.setStyle)(e,"--menu-height",t+"px")});#aX=!1;#aW(e){let t=this.#iJ();for(let i of(t&&"height"===e.propertyName&&(this.#aX="transitionstart"===e.type,(0,au.setAttribute)(t,"data-transition",this.#aX?"height":null),this.#ax()&&this.#aQ()),this.#aD))i(e)}open(e){(0,au.peek)(this.#ax)||(this.#aL.show(e),(0,au.tick)())}close(e){(0,au.peek)(this.#ax)&&(this.#aL.hide(e),(0,au.tick)())}};ov([au.prop],oE.prototype,"triggerElement",null),ov([au.prop],oE.prototype,"contentElement",null),ov([au.prop],oE.prototype,"isSubmenu",null),ov([au.method],oE.prototype,"open",null),ov([au.method],oE.prototype,"close",null);var oS=class extends au.Component{static props={disabled:!1};#a4;#a8=(0,au.signal)(null);get expanded(){return this.#a4?.expanded()??!1}constructor(){super(),new lg}onSetup(){this.#a4=(0,au.useContext)(op)}onAttach(e){this.#a4.attachMenuButton(this),(0,au.effect)(this.#sN.bind(this)),nx(e,"type","button")}onConnect(e){(0,au.effect)(this.#a6.bind(this)),this.#iR();let t=new MutationObserver(this.#iR.bind(this));t.observe(e,{attributeFilter:["data-part"],childList:!0,subtree:!0}),(0,au.onDispose)(()=>t.disconnect()),nL(e,e=>{this.dispatch("select",{trigger:e})})}#sN(){this.#a4.disableMenuButton(this.$props.disabled())}#a6(){let e=this.#a8();e&&(0,au.effect)(()=>{let t=this.#a4.hint();t&&(e.textContent=t)})}#iR(){let e=this.el?.querySelector('[data-part="hint"]');this.#a8.set(e??null)}};let oT=oS.prototype;(0,au.prop)(oT,"expanded");var ox=class extends oS{};au.Component;let ok=(0,au.createContext)();var ow=class extends au.Component{static props={placement:null,offset:0,alignOffset:0};#a4;constructor(){super(),new lg;const{placement:e}=this.$props;this.setAttributes({"data-placement":e})}onAttach(e){if(this.#a4=(0,au.useContext)(op),this.#a4.attachMenuItems(this),(0,au.hasProvidedContext)(ok)){let t=(0,au.useContext)(ok);t&&((0,au.provideContext)(ok,null),t.attach(e),(0,au.onDispose)(()=>t.attach(null)))}}onConnect(e){(0,au.effect)(this.#i6.bind(this))}#i6(){let{expanded:e}=this.#a4;if(!this.el||!e())return;let t=this.$props.placement();if(!t)return;Object.assign(this.el.style,{position:"absolute",top:0,left:0,width:"max-content"});let{offset:i,alignOffset:s}=this.$props;(0,au.onDispose)(nP(this.el,this.#i8(),t,{offsetVarName:"media-menu",xOffset:s(),yOffset:i()})),(0,au.onDispose)(this.#a7.bind(this))}#a7(){this.el&&(this.el.removeAttribute("style"),this.el.style.display="none")}#i8(){return this.#a4.button()}};let oA=(0,au.createContext)();var oR=class extends au.ViewController{#a9=new Set;#ne=(0,au.signal)("");#nt=null;onValueChange;get values(){return Array.from(this.#a9).map(e=>e.value())}get value(){return this.#ne()}set value(e){this.#u(e)}onSetup(){(0,au.provideContext)(oA,{add:this.#ni.bind(this),remove:this.#ns.bind(this)})}onAttach(e){(0,au.hasProvidedContext)(op)||nx(e,"role","radiogroup"),this.setAttributes({value:this.#ne})}onDestroy(){this.#a9.clear()}#ni(e){this.#a9.has(e)||(this.#a9.add(e),e.onCheck=this.#nr,e.check(e.value()===this.#ne()))}#ns(e){e.onCheck=null,this.#a9.delete(e)}#nr=this.#u.bind(this);#u(e,t){let i=(0,au.peek)(this.#ne);if(!e||e===i)return;let s=this.#na(i),r=this.#na(e);s?.check(!1,t),r?.check(!0,t),this.#ne.set(e),this.onValueChange?.(e,t)}#na(e){for(let t of this.#a9)if(e===(0,au.peek)(t.value))return t;return null}},oL=class extends au.Component{static props={value:""};#nt;get values(){return this.#nt.values}get value(){return this.#nt.value}set value(e){this.#nt.value=e}constructor(){super(),this.#nt=new oR,this.#nt.onValueChange=this.#rm.bind(this)}onSetup(){ac.IS_SERVER?this.#s$():(0,au.effect)(this.#s$.bind(this))}#s$(){this.#nt.value=this.$props.value()}#rm(e,t){let i=this.createEvent("change",{detail:e,trigger:t});this.dispatch(i)}};let oC=oL.prototype;(0,au.prop)(oC,"values"),(0,au.prop)(oC,"value");var oI=class extends au.Component{static props={value:""};#nn=(0,au.signal)(!1);#nt={value:this.$props.value,check:this.#nl.bind(this),onCheck:null};get checked(){return this.#nn()}constructor(){super(),new lg}onSetup(){this.setAttributes({value:this.$props.value,"data-checked":this.#nn,"aria-checked":la(this.#nn)})}onAttach(e){let t=(0,au.hasProvidedContext)(op);nx(e,"tabindex",t?"-1":"0"),nx(e,"role",t?"menuitemradio":"radio"),(0,au.effect)(this.#s$.bind(this))}onConnect(e){this.#no(),nL(e,this.#sa.bind(this)),(0,au.onDispose)(this.#eg.bind(this))}#eg(){(0,au.scoped)(()=>{(0,au.useContext)(oA).remove(this.#nt)},this.connectScope)}#no(){(0,au.useContext)(oA).add(this.#nt)}#s$(){let{value:e}=this.$props,t=e();(0,au.peek)(this.#nn)&&this.#nt.onCheck?.(t)}#sa(e){(0,au.peek)(this.#nn)||(this.#u(!0,e),this.#nd(e),this.#nt.onCheck?.((0,au.peek)(this.$props.value),e))}#nl(e,t){(0,au.peek)(this.#nn)!==e&&this.#u(e,t)}#u(e,t){this.#nn.set(e),this.dispatch("change",{detail:e,trigger:t})}#nd(e){this.dispatch("select",{trigger:e})}};let oP=oI.prototype;(0,au.prop)(oP,"checked");var oD=class extends au.Component{static props={disabled:!1,event:void 0,action:void 0};#y;#tX=null;#nh=null;onSetup(){this.#y=np();let{event:e,action:t}=this.$props;this.setAttributes({event:e,action:t})}onAttach(e){e.setAttribute("data-media-gesture",""),e.style.setProperty("pointer-events","none")}onConnect(e){this.#tX=this.#y.player.el?.querySelector("[data-media-provider]"),(0,au.effect)(this.#nu.bind(this))}#nu(){let e=this.$props.event(),t=this.$props.disabled();this.#tX&&e&&!t&&(/^dbl/.test(e)&&(e=e.split(/^dbl/)[1]),("pointerup"===e||"pointerdown"===e)&&"coarse"===this.#y.$state.pointer()&&("pointerup"===e&&(0,au.listenEvent)(this.#tX,"touchstart",this.#sm.bind(this),{passive:!0}),e="pointerup"===e?"touchend":"touchstart"),(0,au.listenEvent)(this.#tX,e,this.#nc.bind(this),{passive:!1}))}#nf=0;#np=-1;#nc(e){if(!(this.$props.disabled()||(0,au.isPointerEvent)(e)&&(0!==e.button||this.#y.activeMenu)||(0,au.isTouchEvent)(e)&&this.#y.activeMenu||this.#nm(e)||nC(e))&&this.#ng(e)){if(e.MEDIA_GESTURE=!0,e.preventDefault(),(0,au.peek)(this.$props.event)?.startsWith("dbl")){if(1===this.#nf){queueMicrotask(()=>this.#ny(e)),clearTimeout(this.#np),this.#nf=0;return}}else 0===this.#nf&&setTimeout(()=>{1===this.#nf&&this.#ny(e)},250);0===this.#nf&&(this.#np=window.setTimeout(()=>{this.#nf=0},275)),this.#nf++}}#sm(e){if(nC(e)){this.#nh=null;return}let t=e.changedTouches[0]??e.touches[0];this.#nh=t?{x:t.clientX,y:t.clientY}:null}#nm(e){if(!(0,au.isTouchEvent)(e)||"touchend"!==e.type)return!1;let t=e.changedTouches[0]??e.touches[0],i=this.#nh;return this.#nh=null,!!t&&!!i&&(Math.abs(t.clientX-i.x)>10||Math.abs(t.clientY-i.y)>10)}#ny(e){this.el.setAttribute("data-triggered",""),requestAnimationFrame(()=>{this.#nv()&&this.#nb((0,au.peek)(this.$props.action),e),requestAnimationFrame(()=>{this.el.removeAttribute("data-triggered")})})}#ng(e){if(!this.el)return!1;if((0,au.isPointerEvent)(e)||(0,au.isMouseEvent)(e)||(0,au.isTouchEvent)(e)){let t=(0,au.isTouchEvent)(e)?e.changedTouches[0]??e.touches[0]:void 0,i=t?.clientX??e.clientX,s=t?.clientY??e.clientY,r=this.el.getBoundingClientRect(),a=s>=r.top&&s<=r.bottom&&i>=r.left&&i<=r.right;return e.type.includes("leave")?!a:a}return!0}#nv(){return Array.from(this.#y.player.el.querySelectorAll("[data-media-gesture][data-triggered]")).sort((e,t)=>
4getComputedStyle(t).zIndex-getComputedStyle(e).zIndex)[0]===this.el}#nb(e,t){if(!e)return;let i=new au.DOMEvent("will-trigger",{detail:e,cancelable:!0,trigger:t});if(this.dispatchEvent(i),i.defaultPrevented)return;let[s,r]=e.replace(/:([a-z])/,"-$1").split(":");e.includes(":fullscreen")?this.#y.remote.toggleFullscreen("prefer-media",t):e.includes("seek:")?this.#y.remote.seek((0,au.peek)(this.#y.$state.currentTime)+(+r||0),t):this.#y.remote[(0,au.kebabToCamelCase)(s)](t),this.dispatch("trigger",{detail:e,trigger:t})}},oM=class{priority=10;#d=null;#nE;#nS;constructor(e){this.#nE=e}attach(){}canRender(){return!0}detach(){this.#nS?.abort(),this.#nS=void 0,this.#nE.reset(),this.#d=null}changeTrack(e){e&&this.#d!==e&&(this.#nS?.abort(),this.#nS=new au.EventsController(e),e.readyState<2?(this.#nE.reset(),this.#nS.add("load",()=>this.#nT(e),{once:!0})):this.#nT(e),this.#nS.add("add-cue",e=>{this.#nE.addCue(e.detail)}).add("remove-cue",e=>{this.#nE.removeCue(e.detail)}),this.#d=e)}#nT(e){this.#nE.changeTrack({cues:[...e.cues],regions:[...e.regions]})}},o_=class t extends au.Component{static props={textDir:"ltr",exampleText:"Captions look like this."};#y;static lib=(0,au.signal)(null);onSetup(){this.#y=np(),this.setAttributes({"aria-hidden":la(this.#so.bind(this))})}onAttach(e){e.style.setProperty("pointer-events","none")}onConnect(i){t.lib()||e.A(4004).then(e=>t.lib.set(e)),(0,au.effect)(this.#nx.bind(this))}#so(){let{textTrack:e,remotePlaybackState:t,iOSControls:i}=this.#y.$state,s=e();return i()||"connected"===t()||!s||!(0,ac.isTrackCaptionKind)(s)}#nx(){if(!t.lib())return;let{viewType:e}=this.#y.$state;return"audio"===e()?this.#nk():this.#nw()}#nk(){return(0,au.effect)(this.#al.bind(this)),this.#nA(null),()=>{this.el.textContent=""}}#al(){if(this.#so())return;this.#nR();let{textTrack:e}=this.#y.$state;(0,au.listenEvent)(e(),"cue-change",this.#nR.bind(this)),(0,au.effect)(this.#nL.bind(this))}#nR(){this.el.textContent="",this.#nC>=0&&this.#nI();let{realCurrentTime:e,textTrack:i}=this.#y.$state,{renderVTTCueString:s}=t.lib(),r=(0,au.peek)(e);for(let e of(0,au.peek)(i).activeCues){let t=this.#nP(),i=this.#nD();i.innerHTML=s(e,r),t.append(i),this.el.append(i)}}#nL(){let{realCurrentTime:e}=this.#y.$state,{updateTimedVTTCueNodes:i}=t.lib();i(this.el,e())}#nw(){let{CaptionsRenderer:e}=t.lib(),i=new e(this.el),s=new oM(i);return this.#y.textRenderers.add(s),(0,au.effect)(this.#nM.bind(this,i)),(0,au.effect)(this.#n_.bind(this,i)),this.#nA(i),()=>{this.el.textContent="",this.#y.textRenderers.remove(s),i.destroy()}}#nM(e){e.dir=this.$props.textDir()}#n_(e){if(this.#so())return;let{realCurrentTime:t,textTrack:i}=this.#y.$state;e.currentTime=t(),this.#nC>=0&&i()?.activeCues[0]&&this.#nI()}#nA(e){let t=this.#y.player;t&&(0,au.listenEvent)(t,"vds-font-change",this.#n$.bind(this,e))}#n$(e){if(this.#nC>=0)return void this.#nO();let{textTrack:t}=this.#y.$state;t()?.activeCues[0]?e?.update(!0):this.#nN()}#nN(){let e=this.#nP();(0,au.setAttribute)(e,"data-example","");let t=this.#nD();(0,au.setAttribute)(t,"data-example",""),t.textContent=this.$props.exampleText(),e?.append(t),this.el?.append(e),this.el?.setAttribute("data-example",""),this.#nO()}#nC=-1;#nO(){window.clearTimeout(this.#nC),this.#nC=window.setTimeout(this.#nI.bind(this),2500)}#nI(){this.el?.removeAttribute("data-example"),this.el?.querySelector("[data-example]")&&(this.el.textContent=""),this.#nC=-1}#nP(){let e=document.createElement("div");return(0,au.setAttribute)(e,"data-part","cue-display"),e}#nD(){let e=document.createElement("div");return(0,au.setAttribute)(e,"data-part","cue"),e}},o$=class extends au.Component{static props={src:null,alt:null,crossOrigin:null};static state=new au.State({img:null,src:null,alt:null,crossOrigin:null,loading:!0,error:null,hidden:!1});#y;onSetup(){this.#y=np(),this.#ra(),this.#nF(),this.#tP(),this.#sj()}onAttach(e){e.style.setProperty("pointer-events","none"),(0,au.effect)(this.#s4.bind(this)),(0,au.effect)(this.#ra.bind(this)),(0,au.effect)(this.#nF.bind(this)),(0,au.effect)(this.#tP.bind(this)),(0,au.effect)(this.#sj.bind(this));let{started:t}=this.#y.$state;this.setAttributes({"data-visible":()=>!t()&&!this.$state.hidden(),"data-loading":this.#s5.bind(this),"data-error":this.#s3.bind(this),"data-hidden":this.$state.hidden})}onConnect(e){(0,au.effect)(this.#nB.bind(this)),(0,au.effect)(this.#s8.bind(this))}#s3(){let{error:e}=this.$state;return!(0,au.isNull)(e())}#nB(){let{canLoadPoster:e,poster:t}=this.#y.$state;!e()&&t()&&(0,ac.preconnect)(t(),"preconnect")}#sj(){let{src:e}=this.$props,{poster:t,nativeControls:i}=this.#y.$state;this.el&&(0,au.setAttribute)(this.el,"display",i()?"none":null),this.$state.hidden.set(this.#s3()||!(e()||t())||i())}#s5(){let{loading:e,hidden:t}=this.$state;return!t()&&e()}#s4(){let e=this.$state.img();e&&(new au.EventsController(e).add("load",this.#nU.bind(this)).add("error",this.#em.bind(this)),e.complete&&this.#nU())}#nj="";#ra(){let{poster:e}=this.#y.$props,{canLoadPoster:t,providedPoster:i,inferredPoster:s}=this.#y.$state,r=this.$props.src()||"",a=r||e()||s();this.#nj===i()&&i.set(r),this.$state.src.set(t()&&a.length?a:null),this.#nj=r}#nF(){let{src:e}=this.$props,{alt:t}=this.$state,{poster:i}=this.#y.$state;t.set(e()||i()?this.$props.alt():null)}#tP(){let{crossOrigin:e}=this.$props,{crossOrigin:t}=this.$state,{crossOrigin:i,poster:s}=this.#y.$state,r=null!==e()?e():i();t.set(/ytimg\.com|vimeo/.test(s()||"")?null:!0===r?"anonymous":r)}#s8(){let{loading:e,error:t}
4=this.$state,{canLoadPoster:i,poster:s}=this.#y.$state;e.set(i()&&!!s()),t.set(null)}#nU(){let{loading:e,error:t}=this.$state;e.set(!1),t.set(null)}#em(e){let{loading:t,error:i}=this.$state;t.set(!1),i.set(e)}},oO=class extends au.Component{static props={type:"current",showHours:!1,padHours:null,padMinutes:null,remainder:!1,toggle:!1,hidden:!1};static state=new au.State({timeText:"",hidden:!1});#y;#nV=(0,au.signal)(null);#sM=(0,au.signal)(!0);#s_=(0,au.signal)(!0);onSetup(){this.#y=np(),this.#nG();let{type:e}=this.$props;this.setAttributes({"data-type":e,"data-remainder":this.#nq.bind(this)}),new lJ({callback:this.#sB.bind(this)}).attach(this)}onAttach(e){e.hasAttribute("role")||(0,au.effect)(this.#nH.bind(this)),(0,au.effect)(this.#nG.bind(this))}onConnect(e){(0,au.onDispose)(nA(e,this.#sM.set)),(0,au.effect)(this.#sj.bind(this)),(0,au.effect)(this.#nK.bind(this))}#sB(e){this.#s_.set(e[0].isIntersecting)}#sj(){let{hidden:e}=this.$props;this.$state.hidden.set(e()||!this.#sM()||!this.#s_())}#nK(){this.$props.toggle()?this.el&&nL(this.el,this.#nW.bind(this)):this.#nV.set(null)}#nG(){let{hidden:e,timeText:t}=this.$state,{duration:i}=this.#y.$state;if(e())return;let{type:s,padHours:r,padMinutes:a,showHours:n}=this.$props,l=this.#nz(s()),o=i(),d=this.#nq();if(!Number.isFinite(l+o))return void t.set("LIVE");let h=n8(d?Math.max(0,o-l):l,{padHrs:r(),padMins:a(),showHrs:n()});t.set((d?"-":"")+h)}#nH(){if(!this.el)return;let{toggle:e}=this.$props;(0,au.setAttribute)(this.el,"role",e()?"timer":null),(0,au.setAttribute)(this.el,"tabindex",e()?0:null)}#nz(e){let{bufferedEnd:t,duration:i,currentTime:s}=this.#y.$state;switch(e){case"buffered":return t();case"duration":return i();default:return s()}}#nq(){return this.$props.remainder()&&!1!==this.#nV()}#nW(e){(e.preventDefault(),null===this.#nV())?this.#nV.set(!this.$props.remainder()):this.#nV.set(e=>!e)}},oN=class extends lb{},oF=class extends lR{},oB=class extends lB{},oU=class extends l4{},oj=class extends ou{},oV=class extends or{},oG=class extends oi{},oq=class extends oc{},oH=class extends oE{},oK=class extends oS{},oW=class extends oL{},oz=class extends oI{},oY=class extends oe{};let oQ=x.forwardRef((e,t)=>{let{children:i,...s}=e,r=x.Children.toArray(i),a=r.find(oZ);if(a){let e=a.props.children,i=r.map(t=>t!==a?t:x.Children.count(e)>1?x.Children.only(null):x.isValidElement(e)?e.props.children:null);return x.createElement(oX,{...s,ref:t},x.isValidElement(e)?x.cloneElement(e,void 0,i):null)}return x.createElement(oX,{...s,ref:t},i)});oQ.displayName="Slot";let oX=x.forwardRef((e,t)=>{let{children:i,...s}=e;if(x.isValidElement(i)){var r;let e,a,n=(r=i,(a=(e=Object.getOwnPropertyDescriptor(r.props,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?r.ref:(a=(e=Object.getOwnPropertyDescriptor(r,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?r.props.ref:r.props.ref||r.ref),l=function(e,t){let i={...t};
4for(let s in t){let r=e[s],a=t[s];/^on[A-Z]/.test(s)?r&&a?i[s]=(...e)=>{a(...e),r(...e)}:r&&(i[s]=r):"style"===s?i[s]={...r,...a}:"className"===s&&(i[s]=[r,a].filter(Boolean).join(" "))}return{...e,...i}}(s,i.props);return i.type!==x.Fragment&&(l.ref=t?(0,au.composeRefs)(t,n):n),x.cloneElement(i,l)}return x.Children.count(i)>1?x.Children.only(null):null});oX.displayName="SlotClone";let oJ=({children:e})=>x.createElement(x.Fragment,null,e);function oZ(e){return x.isValidElement(e)&&e.type===oJ}let o0=["button","div","span","img","video","audio"].reduce((e,t)=>{let i=x.forwardRef((e,i)=>{let{asChild:s,...r}=e,a=s?oQ:t;return x.createElement(a,{...r,ref:i})});return i.displayName=`Primitive.${t}`,{...e,[t]:i}},{}),o1=oN.state.record,o2=Object.keys(o1).reduce((e,t)=>({...e,[t]:()=>o1[t]}),{});function o5(e,t){let i=(0,au.useStateContext)(no);return(0,au.useSignal)((t?.current?.$state||i||o2)[e])}var o3=ah;let o4=oU.state.record,o8=Object.keys(o4).reduce((e,t)=>({...e,[t]:()=>o4[t]}),{});function o6(e,t){let i=(0,ah.useStateContext)(lQ);return(0,ah.useSignal)((t?.current?.$state||i||o8)[e])}function o7(){return(0,ah.useReactContext)(nf)}let o9=(0,ah.createReactComponent)(class extends lj{},{domEventsRegex:/^onMedia/}),de=x.forwardRef(({children:e,...t},i)=>x.createElement(o9,t,t=>x.createElement(o0.button,{...t,ref:(0,ah.composeRefs)(t.ref,i)},e)));de.displayName="AirPlayButton";let dt=(0,ah.createReactComponent)(class extends lG{},{domEventsRegex:/^onMedia/}),di=x.forwardRef(({children:e,...t},i)=>x.createElement(dt,t,t=>x.createElement(o0.button,{...t,ref:(0,ah.composeRefs)(t.ref,i)},e)));di.displayName="PlayButton";let ds=(0,ah.createReactComponent)(class extends lq{},{domEventsRegex:/^onMedia/}),dr=x.forwardRef(({children:e,...t},i)=>x.createElement(ds,t,t=>x.createElement(o0.button,{...t,ref:(0,ah.composeRefs)(t.ref,i)},e)));dr.displayName="CaptionButton";let da=(0,ah.createReactComponent)(class extends lH{},{domEventsRegex:/^onMedia/}),dn=x.forwardRef(({children:e,...t},i)=>x.createElement(da,t,t=>x.createElement(o0.button,{...t,ref:(0,ah.composeRefs)(t.ref,i)},e)));dn.displayName="FullscreenButton";let dl=(0,ah.createReactComponent)(class extends lK{},{domEventsRegex:/^onMedia/}),dd=x.forwardRef(({children:e,...t},i)=>x.createElement(dl,t,t=>x.createElement(o0.button,{...t,ref:(0,ah.composeRefs)(t.ref,i)},e)));dd.displayName="MuteButton";let dh=(0,ah.createReactComponent)(class extends lW{},{domEventsRegex:/^onMedia/}),du=x.forwardRef(({children:e,...t},i)=>x.createElement(dh,t,t=>x.createElement(o0.button,{...t,ref:(0,ah.composeRefs)(t.ref,i)},e)));du.displayName="PIPButton";let dc=(0,ah.createReactComponent)(class extends lz{},{domEventsRegex:/^onMedia/}),df=x.forwardRef(({children:e,...t},i)=>x.createElement(dc,t,t=>x.createElement(o0.button,{...t,ref:(0,ah.composeRefs)(t.ref,i)},e)));df.displayName="SeekButton";let dp=(0,ah.createReactComponent)(class extends lY{},{domEventsRegex:/^onMedia/}),dm=x.forwardRef(({children:e,...t},i)=>x.createElement(dp,t,t=>x.createElement(o0.button,{...t,ref:(0,ah.composeRefs)(t.ref,i)},e)));dm.displayName="LiveButton";let dg=["onDragStart","onDragEnd","onDragValueChange","onValueChange","onPointerValueChange"],dy=(0,ah.createReactComponent)(oV),dv=(0,ah.createReactComponent)(oU,{events:dg}),db=x.forwardRef(({children:e,...t},i)=>x.createElement(dv,{...t,ref:i},t=>x.createElement(o0.div,t,e)));db.displayName="Slider";let dE=x.forwardRef((e,t)=>x.createElement(o0.div,{...e,ref:t}));dE.displayName="SliderThumb";let dS=x.forwardRef((e,t)=>x.createElement(o0.div,{...e,ref:t}));dS.displayName="SliderTrack";let dT=x.forwardRef((e,t)=>x.createElement(o0.div,{...e,ref:t}));dT.displayName="SliderTrackFill";let dx=(0,ah.createReactComponent)(class extends on{}),dk=x.forwardRef(({children:e,...t},i)=>x.createElement(dx,t,t=>x.createElement(o0.div,{...t,ref:(0,ah.composeRefs)(t.ref,i)},e)));dk.displayName="SliderPreview";let dw=x.forwardRef(({children:e,...t},i)=>x.createElement(dy,t,(t,s)=>{let r=(0,ah.useSignal)(()=>s.getValueText(),s);return x.createElement(o0.div,{...t,ref:i},r,e)}));dw.displayName="SliderValue";let dA=x.forwardRef(({children:e,...t},i)=>{let s=o6("min"),r=o6("max"),a=o6("step");return x.createElement(o0.div,{...t,ref:i},Array.from({length:Math.floor((r-s)/a)+1}).map((t,i)=>e(i)))});dA.displayName="SliderSteps";let dR=(0,ah.createReactComponent)(class extends ol{},{events:dg,domEventsRegex:/^onMedia/}),dL=x.forwardRef(({children:e,...t},i)=>x.createElement(dR,{...t,ref:i},t=>x.createElement(o0.div,t,e)));dL.displayName="VolumeSlider";let dC=(0,ah.createReactComponent)(oY),dI=x.forwardRef(({children:e,...t},i)=>x.createElement(dC,t,t=>x.createElement(o0.div,{...t,ref:(0,ah.composeRefs)(t.ref,i)},e)));
4dI.displayName="Thumbnail";let dP=x.forwardRef(({children:e,...t},i)=>{let{src:s,img:r,crossOrigin:a}=(0,ah.useStateContext)(oY.state),n=(0,ah.useSignal)(s),l=(0,ah.useSignal)(a);return x.createElement(o0.img,{crossOrigin:l,...t,src:n||void 0,ref:(0,ah.composeRefs)(r.set,i)},e)});dP.displayName="ThumbnailImg";let dD=x.createContext({$chapters:(0,ah.signal)(null)});dD.displayName="TimeSliderContext";let dM=(0,ah.createReactComponent)(oj,{events:dg,domEventsRegex:/^onMedia/}),d_=x.forwardRef(({children:e,...t},i)=>{let s=x.useMemo(()=>(0,ah.signal)(null),[]);return x.createElement(dD.Provider,{value:{$chapters:s}},x.createElement(dM,{...t,ref:i},t=>x.createElement(o0.div,t,e)))});d_.displayName="TimeSlider";let d$=(0,ah.createReactComponent)(oq),dO=x.forwardRef(({children:e,...t},i)=>x.createElement(d$,t,(t,s)=>x.createElement(o0.div,{...t,ref:(0,ah.composeRefs)(t.ref,i)},x.createElement(dN,{instance:s},e))));function dN({instance:e,children:t}){let i=(0,ah.useSignal)(()=>e.cues,e),s=x.useRef([]),r=x.useRef(null),{$chapters:a}=x.useContext(dD);return r.current||(r.current=function(e=0,t=0,i=""){return ac.IS_SERVER?{startTime:e,endTime:t,text:i,addEventListener:ah.noop,removeEventListener:ah.noop,dispatchEvent:ah.noop}:new window.VTTCue(e,t,i)}()),x.useEffect(()=>(a.set(e),()=>void a.set(null)),[e]),x.useEffect(()=>{e.setRefs(s.current)},[i]),t(i.length?i:[r.current],e=>{if(!e){s.current.length=0;return}s.current.push(e)})}dO.displayName="SliderChapters",dN.displayName="SliderChapterTracks";let dF=x.forwardRef(({children:e,...t},i)=>{let{$chapters:s}=x.useContext(dD),[r,a]=x.useState();return x.useEffect(()=>(0,ah.effect)(()=>{let e=s();a((e?.activePointerCue||e?.activeCue)?.text||"")}),[]),x.createElement(o0.div,{...t,ref:i},r,e)});dF.displayName="SliderChapterTitle";let dB=x.forwardRef((e,t)=>x.createElement(o0.div,{...e,ref:t}));dB.displayName="SliderProgress";let dU=(0,ah.createReactComponent)(class extends ot{}),dj=x.forwardRef(({children:e,...t},i)=>x.createElement(dU,t,t=>x.createElement(o0.div,{...t,ref:(0,ah.composeRefs)(t.ref,i)},e)));dj.displayName="SliderThumbnail";let dV=(0,ah.createReactComponent)(oG,{events:["onCanPlay","onError"]});x.forwardRef(({children:e,...t},i)=>x.createElement(dV,t,(t,s)=>x.createElement(dG,{...t,instance:s,ref:(0,ah.composeRefs)(t.ref,i)},e))).displayName="SliderVideo";let dG=x.forwardRef(({instance:e,children:t,...i},s)=>{let{canLoad:r}=(0,ah.useStateContext)(no),{src:a,video:n,crossOrigin:l}=e.$state,o=(0,ah.useSignal)(a),d=(0,ah.useSignal)(r),h=(0,ah.useSignal)(l);return x.createElement(o0.video,{style:{maxWidth:"unset"},...i,src:o||void 0,muted:!0,playsInline:!0,preload:d?"auto":"none",crossOrigin:h||void 0,ref:(0,ah.composeRefs)(n.set,s)},t)});dG.displayName="SliderVideoProvider";let dq=(0,ah.createReactComponent)(oW,{events:["onChange"]}),dH=x.forwardRef(({children:e,...t},i)=>x.createElement(dq,{...t,ref:i},t=>x.createElement(o0.div,t,e)));dH.displayName="RadioGroup";let dK=(0,ah.createReactComponent)(oz,{events:["onChange","onSelect"]}),dW=x.forwardRef(({children:e,...t},i)=>x.createElement(dK,t,t=>x.createElement(o0.div,{...t,ref:(0,ah.composeRefs)(t.ref,i)},e)));dW.displayName="RadioItem";let dz=(0,ah.createReactComponent)(oH,{events:["onOpen","onClose"],domEventsRegex:/^onMedia/}),dY=x.forwardRef(({children:e,...t},i)=>x.createElement(dz,{...t,ref:i},(t,i)=>x.createElement(o0.div,{...t,style:{display:i.isSubmenu?void 0:"contents",...t.style}},e)));dY.displayName="Menu";let dQ=(0,ah.createReactComponent)(oK,{events:["onSelect"]}),dX=x.forwardRef(({children:e,...t},i)=>x.createElement(dQ,t,t=>x.createElement(o0.button,{...t,ref:(0,ah.composeRefs)(t.ref,i)},e)));dX.displayName="MenuButton";let dJ=x.forwardRef(({container:e=null,disabled:t=!1,children:i,...s},r)=>{let a=o5("fullscreen"),n=x.useMemo(()=>ac.IS_SERVER?null:((0,ah.isString)(e)?document.querySelector(e):e)??document.body,[e]);return!n||("fullscreen"===t?a:t)?i:(0,tL.createPortal)(x.createElement(o0.div,{...s,style:{display:"contents",...s.style},ref:r},i),n)});dJ.displayName="MenuPortal";let dZ=(0,ah.createReactComponent)(class extends ow{}),d0=x.forwardRef(({children:e,...t},i)=>
4x.createElement(dZ,t,t=>x.createElement(o0.div,{...t,ref:(0,ah.composeRefs)(t.ref,i)},e)));d0.displayName="MenuItems";let d1=(0,ah.createReactComponent)(class extends ox{});x.forwardRef(({children:e,...t},i)=>x.createElement(d1,t,t=>x.createElement(o0.div,{...t,ref:(0,ah.composeRefs)(t.ref,i)},e))).displayName="MenuItem";let d2=(0,ah.createReactComponent)(class extends oD{},{events:["onWillTrigger","onTrigger"]}),d5=x.forwardRef(({children:e,...t},i)=>x.createElement(d2,{...t,ref:i},t=>x.createElement(o0.div,t,e)));d5.displayName="Gesture";let d3=(0,ah.createReactComponent)(class extends oO{}),d4=x.forwardRef(({children:e,...t},i)=>x.createElement(d3,t,(t,s)=>x.createElement(d8,{...t,instance:s,ref:(0,ah.composeRefs)(t.ref,i)},e)));d4.displayName="Time";let d8=x.forwardRef(({instance:e,children:t,...i},s)=>{let{timeText:r}=e.$state,a=(0,ah.useSignal)(r);return x.createElement(o0.div,{...i,ref:s},a,t)});function d6(){return o7()?.player||null}function d7(e){return e.label.toLowerCase()}function d9(e){return e.id+":"+e.kind+"-"+e.label.toLowerCase()}function he(e){return e.height+"_"+e.bitrate}d8.displayName="TimeText";let ht=[.25,.5,.75,1,1.25,1.5,1.75,2],hi=(class extends o3.Component{static props={normalLabel:"Normal",rates:ht};#y;#a4;#nt;get value(){return this.#nt.value}get disabled(){let{rates:e}=this.$props,{canSetPlaybackRate:t}=this.#y.$state;return!t()||0===e().length}constructor(){super(),this.#nt=new oR,this.#nt.onValueChange=this.#rm.bind(this)}onSetup(){this.#y=np(),(0,o3.hasProvidedContext)(op)&&(this.#a4=(0,o3.useContext)(op))}onConnect(e){(0,o3.effect)(this.#s$.bind(this)),(0,o3.effect)(this.#nY.bind(this)),(0,o3.effect)(this.#nQ.bind(this))}getOptions(){let{rates:e,normalLabel:t}=this.$props;return e().map(e=>({label:1===e?t:e+"×",value:e.toString()}))}#s$(){this.#nt.value=this.#rC()}#nY(){let{normalLabel:e}=this.$props,{playbackRate:t}=this.#y.$state,i=t();this.#a4?.hint.set(1===i?e():i+"×")}#nQ(){this.#a4?.disable(this.disabled)}#rC(){let{playbackRate:e}=this.#y.$state;return e().toString()}#rm(e,t){if(this.disabled)return;let i=+e;this.#y.remote.changePlaybackRate(i,t),this.dispatch("change",{detail:i,trigger:t})}}).prototype;(0,o3.prop)(hi,"value"),(0,o3.prop)(hi,"disabled"),(0,o3.method)(hi,"getOptions");let hs=(0,ah.createReactComponent)(class extends lC{},{events:["onChange"]}),hr=x.forwardRef(({style:e,children:t,...i},s)=>x.createElement(hs,i,i=>x.createElement(o0.div,{...i,style:{display:"contents",...e},ref:(0,ah.composeRefs)(i.ref,s)},t)));hr.displayName="MediaAnnouncer";let ha=(0,ah.createReactComponent)(class extends lI{}),hn=x.forwardRef(({children:e,...t},i)=>x.createElement(ha,t,t=>x.createElement(o0.div,{...t,ref:(0,ah.composeRefs)(t.ref,i)},e)));hn.displayName="Controls";let hl=(0,ah.createReactComponent)(class extends lP{}),ho=x.forwardRef(({children:e,...t},i)=>x.createElement(hl,t,t=>x.createElement(o0.div,{...t,ref:(0,ah.composeRefs)(t.ref,i)},e)));ho.displayName="ControlsGroup";let hd=(0,ah.createReactComponent)(class extends l${});function hh({children:e,...t}){return x.createElement(hd,t,e)}hh.displayName="Tooltip";let hu=(0,ah.createReactComponent)(class extends lO{}),hc=x.forwardRef(({children:e,...t},i)=>x.createElement(hu,t,t=>x.createElement(o0.button,{...t,ref:(0,ah.composeRefs)(t.ref,i)},e)));hc.displayName="TooltipTrigger";let hf=(0,ah.createReactComponent)(class extends lN{}),hp=x.forwardRef(({children:e,...t},i)=>x.createElement(hf,t,t=>x.createElement(o0.div,{...t,ref:(0,ah.composeRefs)(t.ref,i)},e)));hp.displayName="TooltipContent";let hm=(0,ah.createReactComponent)(class extends lV{},{domEventsRegex:/^onMedia/}),hg=x.forwardRef(({children:e,...t},i)=>x.createElement(hm,t,t=>x.createElement(o0.button,{...t,ref:(0,ah.composeRefs)(t.ref,i)},e)));hg.displayName="GoogleCastButton";let hy=(0,ah.createReactComponent)(class extends oo{},{events:dg,domEventsRegex:/^onMedia/}),hv=x.forwardRef(({children:e,...t},i)=>x.createElement(hy,{...t,ref:i},t=>x.createElement(o0.div,t,e)));hv.displayName="AudioGainSlider";let hb=(0,ah.createReactComponent)(class extends od{},{events:dg,domEventsRegex:/^onMedia/}),hE=x.forwardRef(({children:e,...t},i)=>x.createElement(hb,{...t,ref:i},t=>x.createElement(o0.div,t,e)));hE.displayName="SpeedSlider";let hS=x.forwardRef(({children:e,...t},i)=>{let s=o5("title");return x.createElement(o0.span,{...t,ref:i},s,e)});function hT(e){let[t,i]=x.useState([]);return x.useEffect(()=>{if(!e)return void i([]);function t(){e&&i(e.activeCues)}return t(),(0,ah.listenEvent)(e,"cue-change",t)},[e]),t}function hx(e){let t=o7(),[i,s]=x.useState(null);return x.useEffect(()=>(0,ac.watchActiveTextTrack)(t.textTracks,e,s),[t.textTracks,e]),i}function hk(){return hT(hx("chapters"))[0]?.text||""}hS.displayName="Title";let hw=x.forwardRef(({defaultText:e="",children:t,...i},s)=>{let r=hk();return x.createElement(o0.span,{...i,ref:s},r||e,t)});hw.displayName="ChapterTitle";let hA=(0,ah.createReactComponent)(class extends o_{}),hR=x.forwardRef(({children:e,...t},i)=>x.createElement(hA,{...t,ref:i},t=>x.createElement(o0.div,t,e)));
4hR.displayName="Captions";let hL=x.forwardRef(({size:e=96,children:t,...i},s)=>x.createElement("svg",{width:e,height:e,fill:"none",viewBox:"0 0 120 120","aria-hidden":"true","data-part":"root",...i,ref:s},t)),hC=x.forwardRef(({width:e=8,children:t,...i},s)=>x.createElement("circle",{cx:"60",cy:"60",r:"54",stroke:"currentColor",strokeWidth:e,"data-part":"track",...i,ref:s},t)),hI=x.forwardRef(({width:e=8,fillPercent:t=50,children:i,...s},r)=>x.createElement("circle",{cx:"60",cy:"60",r:"54",stroke:"currentColor",pathLength:"100",strokeWidth:e,strokeDasharray:100,strokeDashoffset:100-t,"data-part":"track-fill",...s,ref:r},i));function hP(e,t=[]){let i=(0,ah.useReactScope)();return x.useMemo(()=>(0,ah.scoped)(()=>(0,ah.signal)(e),i),[i,...t])}function hD(e,t=[]){let i=(0,ah.useReactScope)();return x.useMemo(()=>(0,ah.scoped)(()=>(0,ah.computed)(e),i),[i,...t])}let hM=x.forwardRef((e,t)=>{let{width:i,height:s,size:r=null,paths:a,...n}=e;return x.createElement("svg",{viewBox:"0 0 32 32",...n,width:i??r,height:s??r,fill:"none","aria-hidden":"true",focusable:"false",xmlns:"http://www.w3.org/2000/svg",ref:t,dangerouslySetInnerHTML:{__html:a}})});hM.displayName="VidstackIcon";let h_=[1,1.25,1.5,1.75,2,2.5,3,4],h$=(class extends ah.Component{static props={normalLabel:"Disabled",gains:h_};#y;#a4;#nt;get value(){return this.#nt.value}get disabled(){let{gains:e}=this.$props,{canSetAudioGain:t}=this.#y.$state;return!t()||0===e().length}constructor(){super(),this.#nt=new oR,this.#nt.onValueChange=this.#rm.bind(this)}onSetup(){this.#y=np(),(0,ah.hasProvidedContext)(op)&&(this.#a4=(0,ah.useContext)(op))}onConnect(e){(0,ah.effect)(this.#s$.bind(this)),(0,ah.effect)(this.#nY.bind(this)),(0,ah.effect)(this.#nQ.bind(this))}getOptions(){let{gains:e,normalLabel:t}=this.$props;return e().map(e=>({label:1===e||null===e?t:String(100*e)+"%",value:e.toString()}))}#s$(){this.#nt.value=this.#rC()}#nY(){let{normalLabel:e}=this.$props,{audioGain:t}=this.#y.$state,i=t();this.#a4?.hint.set(1===i||null==i?e():String(100*i)+"%")}#nQ(){this.#a4?.disable(this.disabled)}#rC(){let{audioGain:e}=this.#y.$state;return e()?.toString()??"1"}#rm(e,t){if(this.disabled)return;let i=+e;this.#y.remote.changeAudioGain(i,t),this.dispatch("change",{detail:i,trigger:t})}}).prototype;(0,ah.prop)(h$,"value"),(0,ah.prop)(h$,"disabled"),(0,ah.method)(h$,"getOptions");let hO=(0,ah.createReactComponent)(oN,{events:["onAbort","onAudioTrackChange","onAudioTracksChange","onAutoPlay","onAutoPlayChange","onAutoPlayFail","onCanLoad","onCanPlay","onCanPlayThrough","onControlsChange","onDestroy","onDurationChange","onEmptied","onEnd","onEnded","onError","onFindMediaPlayer","onFullscreenChange","onFullscreenError","onLiveChange","onLiveEdgeChange","onLoadedData","onLoadedMetadata","onLoadStart","onLoopChange","onOrientationChange","onPause","onPictureInPictureChange","onPictureInPictureError","onPlay","onPlayFail","onPlaying","onPlaysInlineChange","onPosterChange","onProgress","onProviderChange","onProviderLoaderChange","onProviderSetup","onQualitiesChange","onQualityChange","onRateChange","onReplay","onSeeked","onSeeking","onSourceChange","onSourceChange","onStalled","onStarted","onStreamTypeChange","onSuspend","onTextTrackChange","onTextTracksChange","onTimeUpdate","onTitleChange","onVdsLog","onVideoPresentationChange","onVolumeChange","onWaiting"],eventsRegex:/^onHls/,domEventsRegex:/^onMedia/}),hN=x.forwardRef(({aspectRatio:e,children:t,...i},s)=>x.createElement(hO,{...i,src:i.src,ref:s,style:{aspectRatio:e,...i.style}},e=>x.createElement(o0.div,e,t)));hN.displayName="MediaPlayer";let hF=(0,ah.createReactComponent)(oF),hB=x.forwardRef(({loaders:e=[],children:t,iframeProps:i,mediaProps:s,...r},a)=>{let n=x.useMemo(()=>e.map(e=>new e),e);return x.createElement(hF,{...r,loaders:n,ref:a},(e,r)=>x.createElement("div",e,x.createElement(hU,{provider:r,mediaProps:s,iframeProps:i}),t))});function hU({provider:t,mediaProps:i,iframeProps:s}){let{sources:r,crossOrigin:a,poster:n,remotePlaybackInfo:l,nativeControls:o,viewType:d}=(0,ah.useStateContext)(no),{loader:h}=t.$state,{$provider:u,$providerSetup:c}=o7(),f=(0,ah.useSignal)(r),p=(0,ah.useSignal)(o),m=(0,ah.useSignal)(a),g=(0,ah.useSignal)(n),y=(0,ah.useSignal)(h),v=(0,ah.useSignal)(u),b=(0,ah.useSignal)(c),E=(0,ah.useSignal)(l),S=y?.mediaType(),T="audio"===(0,ah.useSignal)(d),k=y?.name==="youtube",w=y?.name==="vimeo",A=y?.name==="remotion",R=y?.name==="google-cast",[L,C]=x.useState(""),[I,P]=x.use
4State(!1),D=x.useCallback(e=>{t.load(e)},[t]);return(x.useEffect(()=>{R&&!L&&e.A(40660).then(e=>e.chromecast_exports).then(e=>{C(e.default)})},[R]),x.useLayoutEffect(()=>{P(!0)},[]),R)?x.createElement("div",{className:"vds-google-cast",ref:D},x.createElement(hM,{paths:L}),E?.deviceName?x.createElement("span",{className:"vds-google-cast-info"},"Google Cast on"," ",x.createElement("span",{className:"vds-google-cast-device-name"},E.deviceName)):null):A?x.createElement("div",{"data-remotion-canvas":!0},x.createElement("div",{"data-remotion-container":!0,ref:D},(0,ac.isRemotionProvider)(v)&&b?x.createElement(v.render):null)):k||w?x.createElement(x.Fragment,null,x.createElement("iframe",{...s,className:(s?.className?`${s.className} `:"")+k?"vds-youtube":"vds-vimeo",suppressHydrationWarning:!0,tabIndex:p?void 0:-1,"aria-hidden":"true","data-no-controls":p?void 0:"",ref:D}),p||T?null:x.createElement("div",{className:"vds-blocker"})):S?x.createElement("audio"===S?"audio":"video",{...i,controls:!!p||null,crossOrigin:"boolean"==typeof m?"":m,poster:"video"===S&&p&&g?g:null,suppressHydrationWarning:!0,children:I?null:f.map(({src:e,type:t})=>(0,ah.isString)(e)?x.createElement("source",{src:e,type:"?"!==t?t:void 0,key:e}):null),ref:D}):null}function hj({lang:e,...t}){var i;let s,r;return i={language:e,...t},s=o7(),r=x.useMemo(()=>new ac.TextTrack(i),Object.values(i)),x.useEffect(()=>(s.textTracks.add(r),()=>void s.textTracks.remove(r)),[r]),null}hB.displayName="MediaProvider",hU.displayName="MediaOutlet",hj.displayName="Track";let hV=(0,ah.createReactComponent)(oB);x.forwardRef(({children:e,...t},i)=>x.createElement(hV,t,t=>x.createElement(o0.button,{...t,ref:(0,ah.composeRefs)(t.ref,i)},e))).displayName="ToggleButton";let hG=(0,ah.createReactComponent)(class extends oh{},{events:dg,domEventsRegex:/^onMedia/});x.forwardRef(({children:e,...t},i)=>x.createElement(hG,{...t,ref:i},t=>x.createElement(o0.div,t,e))).displayName="QualitySlider";let hq=(0,ah.createReactComponent)(class extends o${}),hH=x.forwardRef(({children:e,...t},i)=>x.createElement(hq,{src:t.asChild&&x.isValidElement(e)?e.props.src:void 0,...t},(t,s)=>x.createElement(hK,{...t,instance:s,ref:(0,ah.composeRefs)(t.ref,i)},e)));hH.displayName="Poster";let hK=x.forwardRef(({instance:e,children:t,...i},s)=>{let{src:r,img:a,alt:n,crossOrigin:l,hidden:o}=e.$state,d=(0,ah.useSignal)(r),h=(0,ah.useSignal)(n),u=(0,ah.useSignal)(l),c=(0,ah.useSignal)(o);return x.createElement(o0.img,{...i,src:d||void 0,alt:h||void 0,crossOrigin:u||void 0,ref:(0,ah.composeRefs)(a.set,s),style:{display:c?"none":void 0}},t)});hK.displayName="PosterImg",x.forwardRef(({children:e,...t},i)=>x.createElement(o0.div,{translate:"yes","aria-live":"off","aria-atomic":"true",...t,ref:i},e)).displayName="Caption",x.forwardRef((e,t)=>{let i=o5("textTrack"),[s,r]=x.useState();return x.useEffect(()=>{if(i)return i.addEventListener("cue-change",e),()=>{i.removeEventListener("cue-change",e),r(void 0)};function e(){r(i?.activeCues[0])}},[i]),x.createElement(o0.span,{...e,"data-part":"cue",dangerouslySetInnerHTML:{__html:s?.text||""},ref:t})}).displayName="CaptionText";let hW=(0,ah.signal)(null),hz=(0,ah.signal)(null);function hY(e,t){x.useEffect(()=>{if(!e)return;t();let i=new ResizeObserver((0,ah.animationFrameThrottle)(t));return i.observe(e),()=>i.disconnect()},[e,t])}function hQ(e){let t=d6();x.useEffect(()=>{if(t)return(0,ah.effect)(()=>{let i=t.$el;return i?.setAttribute("data-layout",e),()=>i?.removeAttribute("data-layout")})},[t])}function hX(e){function t(t){return x.createElement(hM,{paths:e,...t})}return t.displayName="DefaultLayoutIcon",t}let hJ={AirPlayButton:{Default:hX(ah.Icon$5)},GoogleCastButton:{Default:hX(ah.Icon$24)},PlayButton:{Play:hX(ah.Icon$62),Pause:hX(ah.Icon$59),Replay:hX(ah.Icon$74)},MuteButton:{Mute:hX(ah.Icon$54),VolumeLow:hX(ah.Icon$105),VolumeHigh:hX(ah.Icon$104)},CaptionButton:{On:hX(ah.Icon$26),Off:hX(ah.Icon$27)},PIPButton:{Enter:hX(ah.Icon$61),Exit:hX(ah.Icon$60)},FullscreenButton:{Enter:hX(ah.Icon$40),Exit:hX(ah.Icon$39)},SeekButton:{Backward:hX(ah.Icon$77),Forward:hX(ah.Icon$81)},DownloadButton:{Default:hX(ah.Icon$31)},Menu:{Accessibility:hX(ah.Icon$0),ArrowLeft:hX(ah.Icon$11),ArrowRight:hX(ah.Icon$22),Audio:hX(ah.Icon$53),Chapters:hX(ah.Icon$16),Captions:hX(ah.Icon$27),Playback:hX(ah.Icon$63),Settings:hX(ah.Icon$88),AudioBoostUp:hX(ah.Icon$104),AudioBoostDown:hX(ah.Icon$105),SpeedUp:hX(ah.Icon$58),SpeedDown:hX(ah.Icon$58),QualityUp:hX(ah.Icon$86),QualityDown:hX(ah.Icon$86),FontSizeUp:hX(ah.Icon$13),FontSizeDown:hX(ah.Icon$8),OpacityUp:hX(ah.Icon$33),OpacityDown:hX(ah.Icon$56),RadioCheck:hX(ah.Icon$19)},KeyboardDisplay:{Play:hX(ah.Icon$62),Pause:hX(ah.Icon$59),Mute:hX(ah.Icon$54),VolumeUp:hX(ah.Icon$104),VolumeDown:hX(ah.Icon$105),EnterFullscreen:hX(ah.Icon$40),E
4xitFullscreen:hX(ah.Icon$39),EnterPiP:hX(ah.Icon$61),ExitPiP:hX(ah.Icon$60),CaptionsOn:hX(ah.Icon$26),CaptionsOff:hX(ah.Icon$27),SeekForward:hX(ah.Icon$35),SeekBackward:hX(ah.Icon$34)}},hZ=x.createContext({});function h0(){return x.useContext(hZ)}function h1(e){var t,i;let{translations:s}=h0();return t=s,i=e,t?.[i]??i}function h2(e){let t=function(){let[e,t]=x.useState("dark");return x.useEffect(()=>{let e=window.matchMedia("(prefers-color-scheme: light)");function i(){t(e.matches?"light":"dark")}return i(),(0,ah.listenEvent)(e,"change",i)},[]),e}();return"default"===e?null:"system"===e?t:e}function h5({type:e,smLayoutWhen:t,renderLayout:i}){let s=x.forwardRef(({children:s,className:r,disableTimeSlider:a=!1,hideQualityBitrate:n=!1,icons:l,colorScheme:o="system",download:d=null,menuContainer:h=null,menuGroup:u="bottom",noAudioGain:c=!1,audioGains:f={min:0,max:300,step:25},noGestures:p=!1,noKeyboardAnimations:m=!1,noModal:g=!1,noScrubGesture:y,playbackRates:v={min:0,max:2,step:.25},seekStep:b=10,showMenuDelay:E,showTooltipDelay:S=700,sliderChaptersMinWidth:T=325,slots:k,smallLayoutWhen:w=t,thumbnails:A=null,translations:R,...L},C)=>{let I=o7(),P=(0,ah.useSignal)(I.$props.load),D=o5("canLoad"),M=o5("viewType"),_=o5("streamType"),$=hD(()=>(0,ah.isBoolean)(w)?w:w(I.player.state),[w]),O=hP(!0),N=hP(!0),F=M===e,B=$(),U=(0,ah.isBoolean)(w),j="play"===P&&!D,V=D||U||j,G=h2(o),q=hP(null);return(0,ah.useSignal)($),x.createElement("div",{...L,className:`vds-${e}-layout`+(G?` ${G}`:"")+(r?` ${r}`:""),"data-match":F?"":null,"data-sm":B?"":null,"data-lg":B?null:"","data-size":B?"sm":"lg","data-no-scrub-gesture":y?"":null,ref:(0,ah.composeRefs)(q.set,C)},V&&F?x.createElement(hZ.Provider,{value:{disableTimeSlider:a,hideQualityBitrate:n,icons:l,colorScheme:o,download:d,isSmallLayout:B,menuContainer:h,menuGroup:u,noAudioGain:c,audioGains:f,layoutEl:q,noGestures:p,noKeyboardAnimations:m,noModal:g,noScrubGesture:y,showMenuDelay:E,showTooltipDelay:S,sliderChaptersMinWidth:T,slots:k,seekStep:b,playbackRates:v,thumbnails:A,translations:R,userPrefersAnnouncements:O,userPrefersKeyboardAnimations:N}},i({streamType:_,isSmallLayout:B,isLoadLayout:j}),s):null)});return s.displayName="DefaultMediaLayout",s}function h3(){return x.useContext(hZ).slots}function h4(){return x.useContext(hZ).slots}function h8(e,t,i){let s=e?.[t],r=(0,ah.uppercaseFirstChar)(t);return x.createElement(x.Fragment,null,e?.[`before${r}`],(0,ah.isUndefined)(s)?i:s,e?.[`after${r}`])}function h6(){let{userPrefersAnnouncements:e,translations:t}=h0();return(0,ah.useSignal)(e)?x.createElement(hr,{translations:t}):null}function h7({content:e,placement:t,children:i}){let{showTooltipDelay:s}=h0();return x.createElement(hh,{showDelay:s},x.createElement(hc,{asChild:!0},i),x.createElement(hp,{className:"vds-tooltip-content",placement:t},e))}function h9({tooltip:e}){let{icons:t}=h0(),i=h1("Play"),s=h1("Pause"),r=o5("paused"),a=o5("ended");return x.createElement(h7,{content:r?i:s,placement:e},x.createElement(di,{className:"vds-play-button vds-button","aria-label":i},a?x.createElement(t.PlayButton.Replay,{className:"vds-icon"}):r?x.createElement(t.PlayButton.Play,{className:"vds-icon"}):x.createElement(t.PlayButton.Pause,{className:"vds-icon"})))}hZ.displayName="DefaultLayoutContext",h6.displayName="DefaultAnnouncer",h7.displayName="DefaultTooltip",h9.displayName="DefaultPlayButton";let ue=x.forwardRef(({tooltip:e},t)=>{let{icons:i}=h0(),s=h1("Mute"),r=h1("Unmute"),a=o5("muted"),n=o5("volume");return x.createElement(h7,{content:a?r:s,placement:e},x.createElement(dd,{className:"vds-mute-button vds-button","aria-label":s,ref:t},a||0==n?x.createElement(i.MuteButton.Mute,{className:"vds-icon"}):n<.5?x.createElement(i.MuteButton.VolumeLow,{className:"vds-icon"}):x.createElement(i.MuteButton.VolumeHigh,{className:"vds-icon"})))});function ut({tooltip:e}){let{icons:t}=h0(),i=h1("Captions"),s=h1("Closed-Captions On"),r=h1("Closed-Captions Off"),a=o5("textTrack"),n=a&&(0,ac.isTrackCaptionKind)(a);return x.createElement(h7,{content:n?s:r,placement:e},x.createElement(dr,{className:"vds-caption-button vds-button","aria-label":i},n?x.createElement(t.CaptionButton.On,{className:"vds-icon"}):x.createElement(t.CaptionButton.Off,{className:"vds-icon"})))}function ui({tooltip:e}){let{icons:t}=h0(),i=h1("PiP"),s=h1("Enter PiP"),r=h1("Exit PiP"),a=o5("pictureInPicture");return x.createElement(h7,{content:a?r:s,placement:e},x.createElement(du,{className:"vds-pip-button vds-button","aria-label":i},a?x.createElement(t.PIPButton.Exit,{className:"vds-icon"}):x.createElement(t.PIPButton.Enter,{className:"vds-icon"})))}function us({tooltip:e}){let{icons:t}=h0(),i=h1("Fullscreen"),s=h1("Enter Fullscreen"),r=h1("Exit Fullscreen"),a=o5("fullscreen");return x.createElement(h7,{content:a?r:s,placement:e},x.createElement(dn,{className:"vds-fullscreen-button vds-button","aria-label":i},a?x.createElement(t.FullscreenButton.Exit,{className:"vds-icon"}):x.createElement(t.FullscreenButton.Enter,{className:"vds-icon"})))}function ur({backward:e,tooltip:t}){let{icons:i,seekStep:s}=h0(),r=h1("Seek Forward"),a=h1("Seek Backward"),n=(e?-1:1)*s,l=n>=0?r:a;return x.createElement(h7,{content:l,placement:t},x.createElement(df,{className:"vds-seek-button vds-button",seconds:n,"aria-label":l},n>=0?x.createElement(i.SeekButton.Forward,{className:"vds-icon"}):x.createElement(i.SeekButton.Backward,{className:"vds-icon"})))}function ua({tooltip:e}){let{icons:t}=h0(),i=h1("AirPlay"),s=o5("remotePlaybackState"),r=`${i} ${h1((0,ah.uppercaseFirstChar)(s))}`,a=("connecting"===s?t.AirPlayButton.Connecting:"connected"===s?t.AirPlayButton.Connected:null)??t.AirPlayButton.Default;return x.createElement(h7,{content:i,placement:e},x.createElement(de,{className:"vds-airplay-button vds-button","aria-label":r},x.createElement(a,{className:"vds-icon"})))}function un({tooltip:e}){let{icons:t}=h0(),i=h1("Google Cast"),s=o5("remotePlaybackState"),r=`${i} ${h1((0,ah.uppercaseFirstChar)(s))}`,a=("connecting"===s?t.GoogleCastButton.Connecting:"connected"===s?t.GoogleCastButton.Connected:null)??t.GoogleCastButton.Default;return x.createElement(h7,{content:i,placement:e},x.createElement(hg,{className:"vds-google-cast-button vds-button","aria-label":r},x.createElement(a,{className:"vds-icon"})))}function ul(){let e=o5("live"),t=h1("Skip To Live"),i=h1("LIVE");return e?x.createElement(dm,{className:"vds-live-button","aria-label":t},x.createElement("span",{className:"vds-live-button-text"},i)):null}function uo(){let{download:e,icons:t}=h0(),i=o5("source"),s=(0,ac.getDownloadFile)({title:o5("title"),src:i,download:e}),r=h1("Download");return(0,ah.isString)(s?.url)?x.createElement(h7,{content:r,placement:"top"},x.createElement("a",{role:"button",className:"vds-download-button vds-button","aria-label":r,href:function(e,t){let i=new URL(e);for(let e of Object.keys(t))i.searchParams.set(e,t[e]+"");return i.toString()}(s.url,{download:s.name}),download:s.name,target:"_blank"},t.DownloadButton?x.createElement(t.DownloadButton.Default,{className:"vds-icon"}):null)):null}
4function ud(){let e=h1("Captions look like this");return x.createElement(hR,{className:"vds-captions",exampleText:e})}function uh(){return x.createElement("div",{className:"vds-controls-spacer"})}function uu(){let{layoutEl:e}=h0(),t=(0,ah.useSignal)(e);return x.useMemo(()=>t?.closest("dialog"),[t])}function uc({tooltip:e,placement:t,portalClass:i=""}){let s,r,a,n,l,{showMenuDelay:o,noModal:d,isSmallLayout:h,icons:u,menuGroup:c,menuContainer:f,colorScheme:p}=h0(),m=h1("Chapters"),g=(s=o7(),a=function(e){let[t,i]=x.useState([]);return x.useEffect(()=>{if(!e)return;function t(){e&&i([...e.cues])}let s=new ah.EventsController(e).add("add-cue",t).add("remove-cue",t);return t(),()=>{i([]),s.abort()}},[e]),t}(r=hx("chapters")),n=(0,ah.useSignal)(s.$state.seekableStart),l=(0,ah.useSignal)(s.$state.seekableEnd),hT(r),x.useMemo(()=>{let e=r?a.filter(e=>e.startTime<=l&&e.endTime>=n).map((e,t)=>{let i=null,a;return{cue:e,label:e.text,value:t.toString(),startTimeText:n8(Math.max(0,e.startTime-n)),durationText:n6(Math.min(l,e.endTime)-Math.max(n,e.startTime)),get selected(){return e===r.activeCues[0]},setProgressVar(t){if(!t||e!==r.activeCues[0]){a?.(),a=void 0,t?.style.setProperty("--progress","0%"),i=null;return}i!==t&&(i=t,a?.(),a=(0,ah.effect)(()=>{let{realCurrentTime:i}=s.$state,r=i(),a=Math.max(n,e.startTime),o=Math.min(l,e.endTime)-a,d=Math.max(0,r-a)/o*100;t.style.setProperty("--progress",d.toFixed(3)+"%")}))},select(t){s.remote.seek(e.startTime-n,t)}}}):[];return Object.defineProperty(e,"selectedValue",{get(){let t=e.findIndex(e=>e.selected);return(t>=0?t:0).toString()}}),e},[a,n,l])),y=!g.length,{thumbnails:v}=h0(),b=o5("currentSrc"),E=o5("viewType"),S=(0,ah.useSignal)(hW),T=h2(p),[k,w]=x.useState(!1),A=uu();if(y)return null;let R=x.createElement(d0,{className:"vds-chapters-menu-items vds-menu-items",placement:t,offset:26*(!h&&"bottom"===c&&"video"===E)},k?x.createElement(dH,{className:"vds-chapters-radio-group vds-radio-group",value:g.selectedValue,"data-thumbnails":v?"":null},g.map(({cue:e,label:t,value:i,startTimeText:s,durationText:r,select:a,setProgressVar:n})=>x.createElement(dW,{className:"vds-chapter-radio vds-radio",value:i,key:i,onSelect:a,ref:n},v?x.createElement(dI,{src:v,className:"vds-thumbnail",time:e.startTime},x.createElement(dP,null)):S&&(0,ac.isRemotionSrc)(b)?x.createElement(S,{className:"vds-thumbnail",frame:e.startTime*b.fps}):null,x.createElement("div",{className:"vds-chapter-radio-content"},x.createElement("span",{className:"vds-chapter-radio-label"},t),x.createElement("span",{className:"vds-chapter-radio-start-time"},s),x.createElement("span",{className:"vds-chapter-radio-duration"},r))))):null);return x.createElement(dY,{className:"vds-chapters-menu vds-menu",showDelay:o,onOpen:function(){(0,tL.flushSync)(()=>{w(!0)})},onClose:function(){w(!1)}},x.createElement(h7,{content:m,placement:e},x.createElement(dX,{className:"vds-menu-button vds-button",disabled:y,"aria-label":m},x.createElement(u.Menu.Chapters,{className:"vds-icon"}))),d||!h?R:x.createElement(dJ,{container:f??A,className:i+(T?` ${T}`:""),disabled:"fullscreen","data-sm":h?"":null,"data-lg":h?null:"","data-size":h?"sm":"lg"},R))}ue.displayName="DefaultMuteButton",ut.displayName="DefaultCaptionButton",ui.displayName="DefaultPIPButton",us.displayName="DefaultFullscreenButton",ur.displayName="DefaultSeekButton",ua.displayName="DefaultAirPlayButton",un.displayName="DefaultGoogleCastButton",ul.displayName="DefaultLiveButton",uo.displayName="DefaultDownloadButton",ud.displayName="DefaultCaptions",uh.displayName="DefaultControlsSpacer",uc.displayName="DefaultChaptersMenu";let uf={type:"color"},up={type:"radio",values:{"Monospaced Serif":"mono-serif","Proportional Serif":"pro-serif","Monospaced Sans-Serif":"mono-sans","Proportional Sans-Serif":"pro-sans",Casual:"casual",Cursive:"cursive","Small Capitals":"capitals"}},um={type:"slider",min:0,max:400,step:25,upIcon:null,downIcon:null},ug={type:"slider",min:0,max:100,step:5,upIcon:null,downIcon:null},uy={type:"radio",values:["None","Drop Shadow","Raised","Depressed","Outline"]},uv={fontFamily:"pro-sans",fontSize:"100%",textColor:"#ffffff",textOpacity:"100%",textShadow:"none",textBg:"#000000",textBgOpacity:"100%",displayBg:"#000000",displayBgOpacity:"0%"},ub=Object.keys(uv).reduce((e,t)=>
4({...e,[t]:(0,ah.signal)(uv[t])}),{});if(!ac.IS_SERVER)for(let e of Object.keys(ub)){let t=localStorage.getItem(`vds-player:${(0,ah.camelToKebabCase)(e)}`);(0,ah.isString)(t)&&ub[e].set(t)}function uE(){for(let e of Object.keys(ub)){let t=uv[e];ub[e].set(t)}}function uS(e){let{style:t}=new Option;return t.color=e,t.color.match(/\((.*?)\)/)[1].replace(/,/g," ")}let uT=!1,ux=new Set;function uk(){if(ac.IS_SERVER)return;let{player:e}=np();ux.add(e),function(e){for(let t of(0,ah.keysOf)(ub))uw(e,t,ub[t]())}(e),(0,ah.onDispose)(()=>ux.delete(e)),uT||((0,ah.scoped)(()=>{for(let e of(0,ah.keysOf)(ub)){let t=ub[e],i=uv[e],s=`vds-player:${(0,ah.camelToKebabCase)(e)}`;(0,ah.effect)(()=>{let r=t(),a=r===i;for(let t of ux)uw(t,e,r);a?localStorage.removeItem(s):localStorage.setItem(s,r)})}},null),uT=!0)}function uw(e,t,i){let s=uv[t],r=`--media-user-${(0,ah.camelToKebabCase)(t)}`,a=i!==s?function(e,t){switch(e){case"fontFamily":var i=t;switch(i){case"mono-serif":return'"Courier New", Courier, "Nimbus Mono L", "Cutive Mono", monospace';case"mono-sans":return'"Deja Vu Sans Mono", "Lucida Console", Monaco, Consolas, "PT Mono", monospace';case"pro-sans":return'Roboto, "Arial Unicode Ms", Arial, Helvetica, Verdana, "PT Sans Caption", sans-serif';case"casual":return'"Comic Sans MS", Impact, Handlee, fantasy';case"cursive":return'"Monotype Corsiva", "URW Chancery L", "Apple Chancery", "Dancing Script", cursive';case"capitals":return'"Arial Unicode Ms", Arial, Helvetica, Verdana, "Marcellus SC", sans-serif + font-variant=small-caps';default:return'"Times New Roman", Times, Georgia, Cambria, "PT Serif Caption", serif'}case"fontSize":case"textOpacity":case"textBgOpacity":case"displayBgOpacity":return(parseInt(t)/100).toString();case"textColor":return`rgb(${uS(t)} / var(--media-user-text-opacity, 1))`;case"textShadow":var s=t;switch(s){case"drop shadow":return"rgb(34, 34, 34) 1.86389px 1.86389px 2.79583px, rgb(34, 34, 34) 1.86389px 1.86389px 3.72778px, rgb(34, 34, 34) 1.86389px 1.86389px 4.65972px";case"raised":return"rgb(34, 34, 34) 1px 1px, rgb(34, 34, 34) 2px 2px";case"depressed":return"rgb(204, 204, 204) 1px 1px, rgb(34, 34, 34) -1px -1px";case"outline":return"rgb(34, 34, 34) 0px 0px 1.86389px, rgb(34, 34, 34) 0px 0px 1.86389px, rgb(34, 34, 34) 0px 0px 1.86389px, rgb(34, 34, 34) 0px 0px 1.86389px, rgb(34, 34, 34) 0px 0px 1.86389px";default:return""}case"textBg":return`rgb(${uS(t)} / var(--media-user-text-bg-opacity, 1))`;case"displayBg":return`rgb(${uS(t)} / var(--media-user-display-bg-opacity, 1))`}}(t,i):null;if("fontFamily"===t){let t="capitals"===i?"small-caps":null;e.el?.style.setProperty("--media-user-font-variant",t)}e.el?.style.setProperty(r,a)}function uA({label:e,value:t,children:i}){let s=x.useId();return e?x.createElement("section",{className:"vds-menu-section",role:"group","aria-labelledby":s},x.createElement("div",{className:"vds-menu-section-title"},x.createElement("header",{id:s},e),t?x.createElement("div",{className:"vds-menu-section-value"},t):null),x.createElement("div",{className:"vds-menu-section-body"},i)):x.createElement("div",{className:"vds-menu-section"},x.createElement("div",{className:"vds-menu-section-body"},i))}function uR({label:e,hint:t="",Icon:i,disabled:s=!1}){let{icons:r}=x.useContext(hZ);return x.createElement(dX,{className:"vds-menu-item",disabled:s},x.createElement(r.Menu.ArrowLeft,{className:"vds-menu-close-icon vds-icon"}),i?x.createElement(i,{className:"vds-menu-item-icon vds-icon"}):null,x.createElement("span",{className:"vds-menu-item-label"},e),x.createElement("span",{className:"vds-menu-item-hint"},t),x.createElement(r.Menu.ArrowRight,{className:"vds-menu-open-icon vds-icon"}))}function uL({label:e,children:t}){return x.createElement("div",{className:"vds-menu-item"},x.createElement("div",{className:"vds-menu-item-label"},e),t)}function uC({value:e,options:t,onChange:i}){let{icons:s}=h0();return x.createElement(dH,{className:"vds-radio-group",value:e,onChange:i},t.map(e=>x.createElement(dW,{className:"vds-radio",value:e.value,key:e.value},x.createElement(s.Menu.RadioCheck,{className:"vds-icon"}),x.createElement("span",{className:"vds-radio-label","data-part":"label"},e.label))))}function uI({label:e,value:t,UpIcon:i,DownIcon:s,children:r,isMin:a,isMax:n}){let l=e||t,o=x.createElement(x.Fragment,null,s?x.createElement(s,{className:"vds-icon down"}):null,r,i?x.createElement(i,{className:"vds-icon up"}):null);return x.createElement("div",{className:`vds-menu-item vds-menu-slider-item${l?" group":""}`,"data-min":a?"":null,"data-max":n?"":null},l?x.createElement(x.Fragment,null,x.createElement("div",{className:"vds-menu-slider-title"},e?x.createElement("div",null,e):null,t?x.createElement("div",null,t):null),x.createElement("div",{className:"vds-menu-slider-body"},o)):o)}function uP(){return x.createElement(x.Fragment,null,x.createElement(dS,{className:"vds-slider-track"}),x.createElement(dT,{className:"vds-slider-track-fill vds-slider-track"}),x.createElement(dE,{className:"vds-slider-thumb"}))}function uD(){return x.createElement(dA,{className:"vds-slider-steps"},e=>x.createElement("div",{className:"vds-slider-step",key:String(e)}))}
4function uM(){let e=h1("Caption Styles"),t=o5("hasCaptions"),i=h1("Font"),s=h1("Text"),r=h1("Text Background"),a=h1("Display Background");return t?x.createElement(dY,{className:"vds-font-menu vds-menu"},x.createElement(uR,{label:e}),x.createElement(d0,{className:"vds-font-style-items vds-menu-items"},x.createElement(uA,{label:i},x.createElement(u_,null),x.createElement(u$,null)),x.createElement(uA,{label:s},x.createElement(uO,null),x.createElement(uF,null),x.createElement(uN,null)),x.createElement(uA,{label:r},x.createElement(uB,null),x.createElement(uU,null)),x.createElement(uA,{label:a},x.createElement(uj,null),x.createElement(uV,null)),x.createElement(uA,null,x.createElement(uH,null)))):null}function u_(){return x.createElement(uG,{label:"Family",type:"fontFamily",option:up})}function u$(){let{icons:e}=h0(),t={...um,upIcon:e.Menu.FontSizeUp,downIcon:e.Menu.FontSizeDown};return x.createElement(uG,{label:"Size",type:"fontSize",option:t})}function uO(){return x.createElement(uG,{label:"Color",type:"textColor",option:uf})}function uN(){let{icons:e}=h0(),t={...ug,upIcon:e.Menu.OpacityUp,downIcon:e.Menu.OpacityDown};return x.createElement(uG,{label:"Opacity",type:"textOpacity",option:t})}function uF(){return x.createElement(uG,{label:"Shadow",type:"textShadow",option:uy})}function uB(){return x.createElement(uG,{label:"Color",type:"textBg",option:uf})}function uU(){let{icons:e}=h0(),t={...ug,upIcon:e.Menu.OpacityUp,downIcon:e.Menu.OpacityDown};return x.createElement(uG,{label:"Opacity",type:"textBgOpacity",option:t})}function uj(){return x.createElement(uG,{label:"Color",type:"displayBg",option:uf})}function uV(){let{icons:e}=h0(),t={...ug,upIcon:e.Menu.OpacityUp,downIcon:e.Menu.OpacityDown};return x.createElement(uG,{label:"Opacity",type:"displayBgOpacity",option:t})}function uG({label:e,option:t,type:i}){let s=d6(),r=ub[i],a=(0,ah.useSignal)(r),n=h1(e),l=x.useCallback(()=>{s?.dispatchEvent(new Event("vds-font-change"))},[s]),o=x.useCallback(e=>{r.set(e),l()},[r,l]);if("color"===t.type)return x.createElement(uL,{label:n},x.createElement("input",{className:"vds-color-picker",type:"color",value:a,onChange:function(e){o(e.target.value)}}));if("slider"===t.type){let{min:e,max:i,step:s,upIcon:r,downIcon:l}=t;function d(e){o(e+"%")}return x.createElement(uI,{label:n,value:a,UpIcon:r,DownIcon:l,isMin:a===e+"%",isMax:a===i+"%"},x.createElement(db,{className:"vds-slider",min:e,max:i,step:s,keyStep:s,value:parseInt(a),"aria-label":n,onValueChange:d,onDragValueChange:d},x.createElement(uP,null),x.createElement(uD,null)))}return"radio"===t.type?x.createElement(uq,{id:(0,ah.camelToKebabCase)(i),label:n,value:a,values:t.values,onChange:o}):null}function uq({id:e,label:t,value:i,values:s,onChange:r}){let a=x.useMemo(()=>(0,ah.isArray)(s)?s.map(e=>({label:e,value:e.toLowerCase()})):Object.keys(s).map(e=>({label:e,value:s[e]})),[s]),{translations:n}=h0(),l=x.useMemo(()=>{var e;return e=a.find(e=>e.value===i)?.label||"",n?.[e]??e},[i,a]);return x.createElement(dY,{className:`vds-${e}-menu vds-menu`},x.createElement(uR,{label:t,hint:l}),x.createElement(d0,{className:"vds-menu-items"},x.createElement(uC,{value:i,options:a,onChange:r})))}function uH(){let e=h1("Reset");return x.createElement("button",{className:"vds-menu-item",role:"menuitem",onClick:uE},x.createElement("span",{className:"vds-menu-item-label"},e))}function uK({label:e,checked:t,storageKey:i,defaultChecked:s=!1,onChange:r}){let[a,n]=x.useState(s),[l,o]=x.useState(!1);function d(e){if(e&&"button"in e&&e?.button===1)return;let t=!a;n(t),i&&localStorage.setItem(i,t?"1":""),r?.(t,e?.nativeEvent),o(!1)}return x.useEffect(()=>{let e=!!((i?localStorage.getItem(i):null)??s);n(e),r?.(e)},[]),x.useEffect(()=>{(0,ah.isBoolean)(t)&&n(t)},[t]),x.createElement("div",{className:"vds-menu-checkbox",role:"menuitemcheckbox",tabIndex:0,"aria-label":e,"aria-checked":a?"true":"false","data-active":l?"":null,onPointerUp:d,onPointerDown:function(e){0===e.button&&o(!0)},onKeyDown:function(e){(0,ah.isKeyboardClick)(e.nativeEvent)&&d()}})}function uW({slots:e}){let t=h1("Accessibility"),{icons:i}=h0();return x.createElement(dY,{className:"vds-accessibility-menu vds-menu"},x.createElement(uR,{label:t,Icon:i.Menu.Accessibility}),x.createElement(d0,{className:"vds-menu-items"},h8(e,"accessibilityMenuItemsStart",null),x.createElement(uA,null,x.createElement(uz,null),x.createElement(uY,null)),x.createElement(uA,null,x.createElement(uM,null)),h8(e,"accessibilityMenuItemsEnd",null)))}function uz(){let{userPrefersAnnouncements:e}=h0(),t=h1("Announcements");return x.createElement(uL,{label:t},x.createElement(uK,{label:t,defaultChecked:!0,storageKey:"vds-player::announcements",onChange:function(t){e.set(t)}}))}
4function uY(){let e=o5("viewType"),{userPrefersKeyboardAnimations:t,noKeyboardAnimations:i}=h0(),s=h1("Keyboard Animations");return"video"!==e||i?null:x.createElement(uL,{label:s},x.createElement(uK,{label:s,defaultChecked:!0,storageKey:"vds-player::keyboard-animations",onChange:function(e){t.set(e)}}))}function uQ({slots:e}){let t=h1("Audio"),i=o5("canSetAudioGain"),s=o5("audioTrack"),r=o5("audioTracks"),{noAudioGain:a,icons:n}=h0(),l=i&&!a;return!l&&r.length<=1?null:x.createElement(dY,{className:"vds-audio-menu vds-menu"},x.createElement(uR,{label:t,hint:s?.label,Icon:n.Menu.Audio}),x.createElement(d0,{className:"vds-menu-items"},h8(e,"audioMenuItemsStart",null),x.createElement(u1,null),l?x.createElement(uX,null):null,h8(e,"audioMenuItemsEnd",null)))}function uX(){let e=o5("audioGain"),t=h1("Boost"),i=Math.round(((e??1)-1)*100)+"%",s=o5("canSetAudioGain"),{noAudioGain:r,icons:a}=h0(),n=uJ(),l=uZ();return!s||r?null:x.createElement(uA,{label:t,value:i},x.createElement(uI,{UpIcon:a.Menu.AudioBoostUp,DownIcon:a.Menu.AudioBoostDown,isMin:((e??1)-1)*100<=n,isMax:((e??1)-1)*100===l},x.createElement(u0,null)))}function uJ(){let{audioGains:e}=h0();return((0,ah.isArray)(e)?e[0]:e?.min)??0}function uZ(){let{audioGains:e}=h0();return((0,ah.isArray)(e)?e[e.length-1]:e?.max)??300}function u0(){let e=h1("Audio Boost"),t=uJ(),i=uZ(),s=function(){let{audioGains:e}=h0();return((0,ah.isArray)(e)?e[1]-e[0]:e?.step)||25}();return x.createElement(hv,{className:"vds-audio-gain-slider vds-slider","aria-label":e,min:t,max:i,step:s,keyStep:s},x.createElement(uP,null),x.createElement(uD,null))}function u1(){let{icons:e}=h0(),t=h1("Track"),i=h1("Default"),s=o5("audioTrack"),r=function(){let e=o7(),{audioTracks:t,audioTrack:i}=e.$state,s=(0,ah.useSignal)(t);return(0,ah.useSignal)(i),x.useMemo(()=>{let r=s.map(s=>({track:s,label:s.label,value:d7(s),get selected(){return i()===s},select(i){let r=t().indexOf(s);r>=0&&e.remote.changeAudioTrack(r,i)}}));return Object.defineProperty(r,"disabled",{get:()=>r.length<=1}),Object.defineProperty(r,"selectedTrack",{get:()=>i()}),Object.defineProperty(r,"selectedValue",{get(){let e=i();return e?d7(e):void 0}}),r},[s])}();return r.disabled?null:x.createElement(dY,{className:"vds-audio-track-menu vds-menu"},x.createElement(uR,{label:t,hint:s?.label??i,disabled:r.disabled,Icon:e.Menu.Audio}),x.createElement(d0,{className:"vds-menu-items"},x.createElement(dH,{className:"vds-audio-radio-group vds-radio-group",value:r.selectedValue},r.map(({label:t,value:i,select:s})=>x.createElement(dW,{className:"vds-audio-radio vds-radio",value:i,onSelect:s,key:i},x.createElement(e.Menu.RadioCheck,{className:"vds-icon"}),x.createElement("span",{className:"vds-radio-label"},t))))))}function u2({slots:e}){let{icons:t}=h0(),i=h1("Captions"),s=h1("Off"),r=function({off:e=!0}={}){let t=o7(),{textTracks:i,textTrack:s}=t.$state,r=(0,ah.useSignal)(i);return(0,ah.useSignal)(s),x.useMemo(()=>{let a=r.filter(ac.isTrackCaptionKind),n=a.map(e=>({track:e,label:e.label,value:d9(e),get selected(){return s()===e},select(s){let r=i().indexOf(e);r>=0&&t.remote.changeTextTrackMode(r,"showing",s)}}));return e&&n.unshift({track:null,label:(0,ah.isString)(e)?e:"Off",value:"off",get selected(){return!s()},select(e){t.remote.toggleCaptions(e)}}),Object.defineProperty(n,"disabled",{get:()=>!a.length}),Object.defineProperty(n,"selectedTrack",{get:()=>s()}),Object.defineProperty(n,"selectedValue",{get(){let e=s();return e?d9(e):"off"}}),n},[r])}({off:s}),a=r.selectedTrack?.label??s;return r.disabled?null:x.createElement(dY,{className:"vds-captions-menu vds-menu"},x.createElement(uR,{label:i,hint:a,disabled:r.disabled,Icon:t.Menu.Captions}),x.createElement(d0,{className:"vds-menu-items"},h8(e,"captionsMenuItemsStart",null),x.createElement(dH,{className:"vds-captions-radio-group vds-radio-group",value:r.selectedValue},r.map(({label:e,value:i,select:s})=>x.createElement(dW,{className:"vds-caption-radio vds-radio",value:i,onSelect:s,key:i},x.createElement(t.Menu.RadioCheck,{className:"vds-icon"}),x.createElement("span",{className:"vds-radio-label"},e)))),h8(e,"captionsMenuItemsEnd",null)))}function u5({slots:e}){let{hideQualityBitrate:t,icons:i}=h0(),s=h1("Quality"),r=h1("Auto"),a=o5("canSetQuality"),n=o5("qualities"),l=function({auto:e
4=!0,sort:t="descending"}={}){let i=o7(),{qualities:s,quality:r,autoQuality:a,canSetQuality:n}=i.$state,l=(0,ah.useSignal)(s);return(0,ah.useSignal)(r),(0,ah.useSignal)(a),(0,ah.useSignal)(n),x.useMemo(()=>{let o=nN(l,"descending"===t).map(e=>({quality:e,label:e.height+"p",value:he(e),bitrateText:e.bitrate&&e.bitrate>0?`${(e.bitrate/1e6).toFixed(2)} Mbps`:null,get selected(){return e===r()},get autoSelected(){return a()},select(t){let r=s().indexOf(e);r>=0&&i.remote.changeQuality(r,t)}}));return e&&o.unshift({quality:null,label:(0,ah.isString)(e)?e:"Auto",value:"auto",bitrateText:null,get selected(){return a()},get autoSelected(){return a()},select(e){i.remote.requestAutoQuality(e)}}),Object.defineProperty(o,"disabled",{get:()=>!n()||l.length<=1}),Object.defineProperty(o,"selectedQuality",{get:()=>r()}),Object.defineProperty(o,"selectedValue",{get(){let e=r();return!a()&&e?he(e):"auto"}}),o},[l,t])}({auto:r});return!a||n.length<=1||l.disabled?null:x.createElement(dY,{className:"vds-quality-menu vds-menu"},x.createElement(uR,{label:s,Icon:i.Menu.QualityUp}),x.createElement(d0,{className:"vds-menu-items"},h8(e,"qualityMenuItemsStart",null),x.createElement(dH,{className:"vds-quality-radio-group vds-radio-group",value:l.selectedValue},l.map(({label:e,value:s,bitrateText:r,select:a})=>x.createElement(dW,{className:"vds-quality-radio vds-radio",value:s,onSelect:a,key:s},x.createElement(i.Menu.RadioCheck,{className:"vds-icon"}),x.createElement("span",{className:"vds-radio-label"},e),!t&&r?x.createElement("span",{className:"vds-radio-hint"},r):null))),h8(e,"qualityMenuItemsEnd",null)))}function u3({slots:e}){let{icons:t}=h0(),i=o5("playbackRate"),s=o5("canSetPlaybackRate"),r=h1("Speed"),a=h1("Normal"),n=function(){let{playbackRates:e}=h0();return((0,ah.isArray)(e)?e[0]:e?.min)??0}(),l=function(){let{playbackRates:e}=h0();return((0,ah.isArray)(e)?e[e.length-1]:e?.max)??2}(),o=function(){let{playbackRates:e}=h0();return((0,ah.isArray)(e)?e[1]-e[0]:e?.step)||.25}(),d=1===i?a:i+"x";return s?x.createElement(dY,{className:"vds-speed-menu vds-menu"},x.createElement(uR,{label:r,hint:d,Icon:t.Menu.SpeedUp}),x.createElement(d0,{className:"vds-menu-items"},h8(e,"speedMenuItemsStart",null),x.createElement(uA,{label:r,value:d},x.createElement(uI,{UpIcon:t.Menu.FontSizeUp,DownIcon:t.Menu.FontSizeDown,isMin:i===n,isMax:i===l},x.createElement(hE,{className:"vds-speed-slider vds-slider","aria-label":r,min:n,max:l,step:o,keyStep:o},x.createElement(uP,null),x.createElement(uD,null)))),h8(e,"speedMenuItemsEnd",null))):null}function u4({tooltip:e,placement:t,portalClass:i="",slots:s}){let r,{showMenuDelay:a,icons:n,isSmallLayout:l,menuContainer:o,menuGroup:d,noModal:h,colorScheme:u}=h0(),c=h1("Settings"),f=o5("viewType"),p=h2(u),[m,g]=x.useState(!1),y=uu();r=(0,ah.useReactScope)(),x.useMemo(()=>(0,ah.scoped)(uk,r),[r]);let v=x.createElement(d0,{className:"vds-settings-menu-items vds-menu-items",placement:t,offset:26*(!l&&"bottom"===d&&"video"===f)},m?x.createElement(x.Fragment,null,h8(s,"settingsMenuItemsStart",null),h8(s,"settingsMenuStartItems",null),x.createElement(u3,{slots:s}),x.createElement(u5,{slots:s}),x.createElement(uW,{slots:s}),x.createElement(uQ,{slots:s}),x.createElement(u2,{slots:s}),h8(s,"settingsMenuEndItems",null),h8(s,"settingsMenuItemsEnd",null)):null);return x.createElement(dY,{className:"vds-settings-menu vds-menu",showDelay:a,onOpen:function(){(0,tL.flushSync)(()=>{g(!0)})},onClose:function(){g(!1)}},x.createElement(h7,{content:c,placement:e},x.createElement(dX,{className:"vds-menu-button vds-button","aria-label":c},x.createElement(n.Menu.Settings,{className:"vds-icon vds-rotate-icon"}))),h||!l?v:x.createElement(dJ,{className:i+(p?` ${p}`:""),container:o??y,disabled:"fullscreen","data-sm":l?"":null,"data-lg":l?null:"","data-size":l?"sm":"lg","data-view-type":f},v))}function u8({tooltip:e,orientation:t,slots:i}){let s,r,a,n=o5("pointer"),l=o5("muted"),o=o5("canSetVolume"),[d,h]=x.useState(null),u=(s=function(e){let[t,i]=x.useState(!1);return x.useEffect(()=>{if(!e)return;let t=new ah.EventsController(e).add("mouseenter",()=>i(!0)).add("mouseleave",()=>i(!1));return()=>t.abort()},[e]),t}(d),r=function(e){let[t,i]=x.useState(!1);return x.useEffect(()=>{if(!e)return;let t=new ah.EventsController(e).add("focusin",()=>i(!0)).add("focusout",()=>i(!1));return()=>t.abort()},[e]),t}(d),(!(a=x.useRef(!1)).current||!!s||!!r)&&(a.current=s,s||r)),c=h8(i,"muteButton",x.createElement(ue,{tooltip:e}));return o?"coarse"!==n||l?x.createElement("div",{className:"vds-volume","data-active":u?"":null,ref:h},c,x.createElement("div",{className:"vds-volume-popup"},h8(i,"volumeSlider",x.createElement(u6,{orientation:t})))):null:c}function u6(e){let t=h1("Volume");return x.createElement(dL,{className:"vds-volume-slider vds-slider","aria-label":t,...e},x.createElement(dS,{className:"vds-slider-track"}),x.createElement(dT,{className:"vds-slider-track-fill vds-slider-track"}),x.createElement(dE,{className:"vds-slider-thumb"}),x.createElement(dk,{className:"vds-slider-preview",noClamp:!0}
4,x.createElement(dw,{className:"vds-slider-value"})))}function u7(){let[e,t]=x.useState(null),[i,s]=x.useState(0),r=o5("currentSrc"),{thumbnails:a,sliderChaptersMinWidth:n,disableTimeSlider:l,seekStep:o,noScrubGesture:d}=h0(),h=h1("Seek"),u=(0,ah.useSignal)(hz),c=x.useCallback(()=>{let t=e?.el;t&&s(t.clientWidth)},[e]);return hY(e?.el,c),x.createElement(d_,{className:"vds-time-slider vds-slider","aria-label":h,disabled:l,noSwipeGesture:d,keyStep:o,ref:t},x.createElement(dO,{className:"vds-slider-chapters",disabled:i<n},(e,t)=>e.map(e=>x.createElement("div",{className:"vds-slider-chapter",key:e.startTime,ref:t},x.createElement(dS,{className:"vds-slider-track"}),x.createElement(dT,{className:"vds-slider-track-fill vds-slider-track"}),x.createElement(dB,{className:"vds-slider-progress vds-slider-track"})))),x.createElement(dE,{className:"vds-slider-thumb"}),x.createElement(dk,{className:"vds-slider-preview"},a?x.createElement(dj,{src:a,className:"vds-slider-thumbnail vds-thumbnail"},x.createElement(dP,null)):u&&(0,ac.isRemotionSrc)(r)?x.createElement(u,{className:"vds-slider-thumbnail vds-thumbnail"}):null,x.createElement(dF,{className:"vds-slider-chapter-title"}),x.createElement(dw,{className:"vds-slider-value"})))}function u9({slots:e}){return o5("duration")?x.createElement("div",{className:"vds-time-group"},h8(e,"currentTime",x.createElement(d4,{className:"vds-time",type:"current"})),h8(e,"timeDivider",x.createElement("div",{className:"vds-time-divider"},"/")),h8(e,"endTime",x.createElement(d4,{className:"vds-time",type:"duration"}))):null}function ce({slots:e}){return o5("live")?h8(e,"liveButton",x.createElement(ul,null)):x.createElement(u9,{slots:e})}function ct({slots:e}){let t=o5("live"),i=o5("duration");return t?h8(e,"liveButton",x.createElement(ul,null)):h8(e,"endTime",i?x.createElement(d4,{className:"vds-time",type:"current",toggle:!0,remainder:!0}):null)}function ci(){let e=h3();return hQ("audio"),x.createElement(x.Fragment,null,x.createElement(h6,null),x.createElement(ud,null),x.createElement(hn,{className:"vds-controls"},x.createElement(ho,{className:"vds-controls-group"},h8(e,"seekBackwardButton",x.createElement(ur,{backward:!0,tooltip:"top start"})),h8(e,"playButton",x.createElement(h9,{tooltip:"top center"})),h8(e,"seekForwardButton",x.createElement(ur,{tooltip:"top center"})),x.createElement(cr,null),h8(e,"timeSlider",x.createElement(u7,null)),x.createElement(ct,{slots:e}),x.createElement(u8,{orientation:"vertical",tooltip:"top",slots:e}),h8(e,"captionButton",x.createElement(ut,{tooltip:"top center"})),h8(e,"downloadButton",x.createElement(uo,null)),x.createElement(cs,{slots:e}))))}function cs({slots:e}){let{isSmallLayout:t,noModal:i}=h0(),s=i?"top end":t?null:"top end";return x.createElement(x.Fragment,null,h8(e,"chaptersMenu",x.createElement(uc,{tooltip:"top",placement:s,portalClass:"vds-audio-layout"})),h8(e,"settingsMenu",x.createElement(u4,{tooltip:"top end",placement:s,portalClass:"vds-audio-layout",slots:e})))}function cr(){let[e,t]=x.useState(null),i=o7(),{translations:s}=h0(),[r,a]=x.useState(!1),n=hD(()=>{let{started:e,currentTime:t}=i.$state;return e()||t()>0}),l=(0,ah.useSignal)(hD(()=>{var e;let{title:t,ended:r}=i.$state;return t()?`${e=r()?"Replay":n()?"Continue":"Play",s?.[e]??e}: ${t()}`:""})),o=hk(),d=(0,ah.useSignal)(n)?o:"",h=function(e){let[t,i]=x.useState(!1);return x.useEffect(()=>{if(!e)return;let t=new ah.EventsController(e).add("transitionstart",()=>i(!0)).add("transitionend",()=>i(!1));return()=>t.abort()},[e]),t}(e);return x.useEffect(()=>{h&&document.activeElement===document.body&&i.player.el?.focus({preventScroll:!0})},[]),hY(e,x.useCallback(()=>{let t=!!e&&!h&&e.clientWidth<e.children[0].clientWidth;e&&(0,ah.toggleClass)(e,"vds-marquee",t),a(t)},[e,h])),l?x.createElement("span",{className:"vds-title",title:l,ref:t},x.createElement(ca,{title:l,chapterTitle:d}),r&&!h?x.createElement(ca,{title:l,chapterTitle:d}):null):x.createElement(uh,null)}function ca({title:e,chapterTitle:t}){let i=h3();return x.createElement("span",{className:"vds-title-text"},h8(i,"title",e),h8(i,"chapterTitle",x.createElement("span",{className:"vds-chapter-title"},t)))}uA.displayName="DefaultMenuSection",uR.displayName="DefaultMenuButton",uL.displayName="DefaultMenuItem",uC.displayName="DefaultMenuRadioGroup",uI.displayName="DefaultMenuSliderItem",uP.displayName="DefaultSliderParts",uD.displayName="DefaultSliderSteps",uM.displayName="DefaultFontMenu",u_.displayName="DefaultFontFamilyMenu",u$.displayName="DefaultFontSizeSlider",uO.displayName="DefaultTextColorInput",uN.displayName="DefaultTextOpacitySlider",uF.displayName="DefaultTextShadowMenu",uB.displayName="DefaultTextBgInput",uU.displayName="DefaultTextBgOpacitySlider",uj.displayName="DefaultDisplayBgInput",uV.displayName="DefaultDisplayBgOpacitySlider",uG.displayName="DefaultFontSetting",uq.displayName="DefaultFontRadioGroup",uH.displayName="DefaultResetMenuItem",uK.displayName="DefaultMenuCheckbox",uW.dis
4playName="DefaultAccessibilityMenu",uz.displayName="DefaultAnnouncementsMenuCheckbox",uY.displayName="DefaultKeyboardAnimationsMenuCheckbox",uQ.displayName="DefaultAudioMenu",uX.displayName="DefaultAudioBoostMenuSection",u0.displayName="DefaultAudioGainSlider",u1.displayName="DefaultAudioTracksMenu",u2.displayName="DefaultCaptionMenu",u5.displayName="DefaultQualityMenu",u3.displayName="DefaultSpeedMenu",u4.displayName="DefaultSettingsMenu",u8.displayName="DefaultVolumePopup",u6.displayName="DefaultVolumeSlider",u7.displayName="DefaultTimeSlider",u9.displayName="DefaultTimeGroup",ce.displayName="DefaultTimeInfo",ct.displayName="DefaultTimeInvert",h5({type:"audio",smLayoutWhen:({width:e})=>e<576,renderLayout:()=>x.createElement(ci,null)}),ci.displayName="AudioLayout",cs.displayName="DefaultAudioMenus",cr.displayName="DefaultAudioTitle",ca.displayName="AudioTitle";let cn=x.forwardRef(({icons:e,...t},i)=>{let[s,r]=x.useState(!1),[a,n]=x.useState(null),[l,o]=x.useState(0),d=o5("lastKeyboardAction");x.useEffect(()=>{o(e=>e+1)},[d]);let h=x.useMemo(()=>{let e=d?.action;return e&&s?(0,ah.camelToKebabCase)(e):null},[s,d]),u=x.useMemo(()=>`vds-kb-action${!s?" hidden":""}${t.className?` ${t.className}`:""}`,[s]),c=(0,ah.useSignal)(hD(cl));return!function(e,t=[]){let i=(0,ah.useReactScope)();x.useEffect(()=>(0,ah.scoped)(()=>(0,ah.effect)(e),i),[i,...t])}(()=>{let t=function(e){let{$state:t}=(0,ah.useContext)(nf);switch(t.lastKeyboardAction()?.action){case"togglePaused":return t.paused()?e.Pause:e.Play;case"toggleMuted":return t.muted()||0===t.volume()?e.Mute:t.volume()>=.5?e.VolumeUp:e.VolumeDown;case"toggleFullscreen":return t.fullscreen()?e.EnterFullscreen:e.ExitFullscreen;case"togglePictureInPicture":return t.pictureInPicture()?e.EnterPiP:e.ExitPiP;case"toggleCaptions":return t.hasCaptions()?t.textTrack()?e.CaptionsOn:e.CaptionsOff:null;case"volumeUp":return e.VolumeUp;case"volumeDown":return e.VolumeDown;case"seekForward":return e.SeekForward;case"seekBackward":return e.SeekBackward;default:return null}}(e);n(()=>t)},[e]),x.useEffect(()=>{r(!!d);let e=setTimeout(()=>r(!1),500);return()=>{r(!1),window.clearTimeout(e)}},[d]),a?x.createElement(o0.div,{...t,className:u,"data-action":h,ref:i},x.createElement("div",{className:"vds-kb-text-wrapper"},x.createElement("div",{className:"vds-kb-text"},c)),x.createElement("div",{className:"vds-kb-bezel",key:l},x.createElement("div",{className:"vds-kb-icon"},x.createElement(a,null)))):null});function cl(){let{$state:e}=(0,ah.useContext)(nf),t=e.lastKeyboardAction()?.action,i=e.audioGain()??1;switch(t){case"toggleMuted":return e.muted()?"0%":co(e.volume(),i);case"volumeUp":case"volumeDown":return co(e.volume(),i);default:return""}}function co(e,t){return`${Math.round(e*t*100)}%`}function cd(){let e=o5("started"),t=o5("title");return hx("chapters")&&(e||!t)?x.createElement(hw,{className:"vds-chapter-title"}):x.createElement(hS,{className:"vds-chapter-title"})}cn.displayName="DefaultKeyboardDisplay",cd.displayName="DefaultTitle";let ch=h5({type:"video",smLayoutWhen:({width:e,height:t})=>e<576||t<380,renderLayout:e=>x.createElement(cc,e)});function cu(e){return x.createElement(ch,e)}function cc({streamType:e,isLoadLayout:t,isSmallLayout:i}){return hQ("video"),t?x.createElement(cb,null):"unknown"===e?x.createElement(cy,null):i?x.createElement(cp,null):x.createElement(cf,null)}function cf(){let{menuGroup:e}=h0(),t=h4(),i={...t,...t?.largeLayout};return x.createElement(x.Fragment,null,x.createElement(h6,null),x.createElement(cg,null),x.createElement(cE,null),h8(i,"bufferingIndicator",x.createElement(cy,null)),h8(i,"captions",x.createElement(ud,null)),x.createElement(hn,{className:"vds-controls"},x.createElement(ho,{className:"vds-controls-group"},h8(i,"topControlsGroupStart",null),x.createElement(uh,null),h8(i,"topControlsGroupCenter",null),x.createElement(uh,null),h8(i,"topControlsGroupEnd",null),"top"===e&&x.createElement(cv,{slots:i})),x.createElement(uh,null),x.createElement(ho,{className:"vds-controls-group"},h8(i,"centerControlsGroupStart",null),x.createElement(uh,null),h8(i,"centerControlsGroupCenter",null),x.createElement(uh,null),h8(i,"centerControlsGroupEnd",null)),x.createElement(uh,null),x.createElement(ho,{
4className:"vds-controls-group"},h8(i,"timeSlider",x.createElement(u7,null))),x.createElement(ho,{className:"vds-controls-group"},h8(i,"playButton",x.createElement(h9,{tooltip:"top start"})),x.createElement(u8,{orientation:"horizontal",tooltip:"top",slots:i}),x.createElement(ce,{slots:i}),h8(i,"chapterTitle",x.createElement(cd,null)),h8(i,"captionButton",x.createElement(ut,{tooltip:"top"})),"bottom"===e&&x.createElement(cv,{slots:i}),h8(i,"airPlayButton",x.createElement(ua,{tooltip:"top"})),h8(i,"googleCastButton",x.createElement(un,{tooltip:"top"})),h8(i,"downloadButton",x.createElement(uo,null)),h8(i,"pipButton",x.createElement(ui,{tooltip:"top"})),h8(i,"fullscreenButton",x.createElement(us,{tooltip:"top end"})))))}function cp(){let e=h4(),t={...e,...e?.smallLayout};return x.createElement(x.Fragment,null,x.createElement(h6,null),x.createElement(cg,null),x.createElement(cE,null),h8(t,"bufferingIndicator",x.createElement(cy,null)),h8(t,"captions",x.createElement(ud,null)),x.createElement(hn,{className:"vds-controls"},x.createElement(ho,{className:"vds-controls-group"},h8(t,"topControlsGroupStart",null),h8(t,"airPlayButton",x.createElement(ua,{tooltip:"top start"})),h8(t,"googleCastButton",x.createElement(un,{tooltip:"top start"})),x.createElement(uh,null),h8(t,"topControlsGroupCenter",null),x.createElement(uh,null),h8(t,"captionButton",x.createElement(ut,{tooltip:"bottom"})),h8(t,"downloadButton",x.createElement(uo,null)),x.createElement(cv,{slots:t}),x.createElement(u8,{orientation:"vertical",tooltip:"bottom end",slots:t}),h8(t,"topControlsGroupEnd",null)),x.createElement(uh,null),x.createElement(ho,{className:"vds-controls-group",style:{pointerEvents:"none"}},h8(t,"centerControlsGroupStart",null),x.createElement(uh,null),h8(t,"centerControlsGroupCenter",null),h8(t,"playButton",x.createElement(h9,{tooltip:"top"})),x.createElement(uh,null),h8(t,"centerControlsGroupEnd",null)),x.createElement(uh,null),x.createElement(ho,{className:"vds-controls-group"},x.createElement(ce,{slots:t}),h8(t,"chapterTitle",x.createElement(cd,null)),h8(t,"fullscreenButton",x.createElement(us,{tooltip:"top end"}))),x.createElement(ho,{className:"vds-controls-group"},h8(t,"timeSlider",x.createElement(u7,null)))),h8(t,"startDuration",x.createElement(cm,null)))}function cm(){return 0===o5("duration")?null:x.createElement("div",{className:"vds-start-duration"},x.createElement(d4,{className:"vds-time",type:"duration"}))}function cg(){let{noGestures:e}=h0();return e?null:x.createElement("div",{className:"vds-gestures"},x.createElement(d5,{className:"vds-gesture",event:"pointerup",action:"toggle:paused"}),x.createElement(d5,{className:"vds-gesture",event:"pointerup",action:"toggle:controls"}),x.createElement(d5,{className:"vds-gesture",event:"dblpointerup",action:"toggle:fullscreen"}),x.createElement(d5,{className:"vds-gesture",event:"dblpointerup",action:"seek:-10"}),x.createElement(d5,{className:"vds-gesture",event:"dblpointerup",action:"seek:10"}))}function cy(){return x.createElement("div",{className:"vds-buffering-indicator"},x.createElement(hL,{className:"vds-buffering-spinner"},x.createElement(hC,{className:"vds-buffering-track"}),x.createElement(hI,{className:"vds-buffering-track-fill"})))}function cv({slots:e}){let{isSmallLayout:t,noModal:i,menuGroup:s}=h0(),r="top"===s||t?"bottom":"top",a=`${r} end`,n=i?`${r} end`:t?null:`${r} end`;return x.createElement(x.Fragment,null,h8(e,"chaptersMenu",x.createElement(uc,{tooltip:a,placement:n,portalClass:"vds-video-layout"})),h8(e,"settingsMenu",x.createElement(u4,{tooltip:a,placement:n,portalClass:"vds-video-layout",slots:e})))}function cb(){let{isSmallLayout:e}=h0(),t=h4(),i={...t,...t?.[e?"smallLayout":"largeLayout"]};return x.createElement("div",{className:"vds-load-container"},h8(i,"bufferingIndicator",x.createElement(cy,null)),h8(i,"loadButton",x.createElement(h9,{tooltip:"top"})))}function cE(){let{noKeyboardAnimations:e,icons:t,userPrefersKeyboardAnimations:i}=h0(),s=(0,ah.useSignal)(i);return!e&&s&&t.KeyboardDisplay?x.createElement(cn,{icons:t.KeyboardDisplay}):null}cu.displayName="DefaultVideoLayout",cc.displayName="VideoLayout",cf.displayName="DefaultVideoLargeLayout",cp.displayName="DefaultVideoSmallLayout",cm.displayName="DefaultVideoStartDuration",cg.displayName="DefaultVideoGestures",cy.displayName="DefaultBuffer
4ingIndicator",cv.displayName="DefaultVideoMenus",cb.displayName="DefaultVideoLoadLayout",cE.displayName="DefaultVideoKeyboardDisplay";let cS=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},cT=Number.isSafeInteger||function(e){return"number"==typeof e&&Math.abs(e)<=cx},cx=Number.MAX_SAFE_INTEGER||0x1fffffffffffff,ck=((u={}).NETWORK_ERROR="networkError",u.MEDIA_ERROR="mediaError",u.KEY_SYSTEM_ERROR="keySystemError",u.MUX_ERROR="muxError",u.OTHER_ERROR="otherError",u),cw=((c={}).KEY_SYSTEM_NO_KEYS="keySystemNoKeys",c.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",c.KEY_SYSTEM_NO_SESSION="keySystemNoSession",c.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",c.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",c.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",c.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",c.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",c.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",c.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",c.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR="keySystemDestroyMediaKeysError",c.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR="keySystemDestroyCloseSessionError",c.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR="keySystemDestroyRemoveSessionError",c.MANIFEST_LOAD_ERROR="manifestLoadError",c.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",c.MANIFEST_PARSING_ERROR="manifestParsingError",c.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",c.LEVEL_EMPTY_ERROR="levelEmptyError",c.LEVEL_LOAD_ERROR="levelLoadError",c.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",c.LEVEL_PARSING_ERROR="levelParsingError",c.LEVEL_SWITCH_ERROR="levelSwitchError",c.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",c.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",c.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",c.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",c.FRAG_LOAD_ERROR="fragLoadError",c.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",c.FRAG_DECRYPT_ERROR="fragDecryptError",c.FRAG_PARSING_ERROR="fragParsingError",c.FRAG_GAP="fragGap",c.REMUX_ALLOC_ERROR="remuxAllocError",c.KEY_LOAD_ERROR="keyLoadError",c.KEY_LOAD_TIMEOUT="keyLoadTimeOut",c.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",c.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",c.BUFFER_APPEND_ERROR="bufferAppendError",c.BUFFER_APPENDING_ERROR="bufferAppendingError",c.BUFFER_STALLED_ERROR="bufferStalledError",c.BUFFER_FULL_ERROR="bufferFullError",c.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",c.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",c.ASSET_LIST_LOAD_ERROR="assetListLoadError",c.ASSET_LIST_LOAD_TIMEOUT="assetListLoadTimeout",c.ASSET_LIST_PARSING_ERROR="assetListParsingError",c.INTERSTITIAL_ASSET_ITEM_ERROR="interstitialAssetItemError",c.INTERNAL_EXCEPTION="internalException",c.INTERNAL_ABORTED="aborted",c.ATTACH_MEDIA_ERROR="attachMediaError",c.UNKNOWN="unknown",c),cA=((f={}
4).MEDIA_ATTACHING="hlsMediaAttaching",f.MEDIA_ATTACHED="hlsMediaAttached",f.MEDIA_DETACHING="hlsMediaDetaching",f.MEDIA_DETACHED="hlsMediaDetached",f.MEDIA_ENDED="hlsMediaEnded",f.STALL_RESOLVED="hlsStallResolved",f.BUFFER_RESET="hlsBufferReset",f.BUFFER_CODECS="hlsBufferCodecs",f.BUFFER_CREATED="hlsBufferCreated",f.BUFFER_APPENDING="hlsBufferAppending",f.BUFFER_APPENDED="hlsBufferAppended",f.BUFFER_EOS="hlsBufferEos",f.BUFFERED_TO_END="hlsBufferedToEnd",f.BUFFER_FLUSHING="hlsBufferFlushing",f.BUFFER_FLUSHED="hlsBufferFlushed",f.MANIFEST_LOADING="hlsManifestLoading",f.MANIFEST_LOADED="hlsManifestLoaded",f.MANIFEST_PARSED="hlsManifestParsed",f.LEVEL_SWITCHING="hlsLevelSwitching",f.LEVEL_SWITCHED="hlsLevelSwitched",f.LEVEL_LOADING="hlsLevelLoading",f.LEVEL_LOADED="hlsLevelLoaded",f.LEVEL_UPDATED="hlsLevelUpdated",f.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",f.LEVELS_UPDATED="hlsLevelsUpdated",f.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",f.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",f.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",f.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",f.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",f.AUDIO_TRACK_UPDATED="hlsAudioTrackUpdated",f.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",f.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",f.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",f.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",f.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",f.SUBTITLE_TRACK_UPDATED="hlsSubtitleTrackUpdated",f.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",f.CUES_PARSED="hlsCuesParsed",f.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",f.INIT_PTS_FOUND="hlsInitPtsFound",f.FRAG_LOADING="hlsFragLoading",f.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",f.FRAG_LOADED="hlsFragLoaded",f.FRAG_DECRYPTED="hlsFragDecrypted",f.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",f.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",f.FRAG_PARSING_METADATA="hlsFragParsingMetadata",f.FRAG_PARSED="hlsFragParsed",f.FRAG_BUFFERED="hlsFragBuffered",f.FRAG_CHANGED="hlsFragChanged",f.FPS_DROP="hlsFpsDrop",f.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",f.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",f.ERROR="hlsError",f.DESTROYING="hlsDestroying",f.KEY_LOADING="hlsKeyLoading",f.KEY_LOADED="hlsKeyLoaded",f.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",f.BACK_BUFFER_REACHED="hlsBackBufferReached",f.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",f.ASSET_LIST_LOADING="hlsAssetListLoading",f.ASSET_LIST_LOADED="hlsAssetListLoaded",f.INTERSTITIALS_UPDATED="hlsInterstitialsUpdated",f.INTERSTITIALS_BUFFERED_TO_BOUNDARY="hlsInterstitialsBufferedToBoundary",f.INTERSTITIAL_ASSET_PLAYER_CREATED="hlsInterstitialAssetPlayerCreated",f.INTERSTITIAL_STARTED="hlsInterstitialStarted",f.INTERSTITIAL_ASSET_STARTED="hlsInterstitialAssetStarted",f.INTERSTITIAL_ASSET_ENDED="hlsInterstitialAssetEnded",f.INTERSTITIAL_ASSET_ERROR="hlsInterstitialAssetError",f.INTERSTITIAL_ENDED="hlsInterstitialEnded",f.INTERSTITIALS_PRIMARY_RESUMED="hlsInterstitialsPrimaryResumed",f.PLAYOUT_LIMIT_REACHED="hlsPlayoutLimitReached",f.EVENT_CUE_ENTER="hlsEventCueEnter",f);var cR="manifest",cL="level",cC="audioTrack",cI="subtitleTrack",cP="main",cD="audio",cM="subtitle";class c_{constructor(e,t=0,i=0){this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=i}sample(e,t){let i=Math.pow(this.alpha_,e);this.estimate_=t*(1-i)+i*this.estimate_,this.totalWeight_+=e}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){let e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}}class c${constructor(e,t,i,s=100){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=i,this.minWeight_=.001,this.minDelayMs_=50,this.slow_
4=new c_(e),this.fast_=new c_(t),this.defaultTTFB_=s,this.ttfb_=new c_(e)}update(e,t){let{slow_:i,fast_:s,ttfb_:r}=this;i.halfLife!==e&&(this.slow_=new c_(e,i.getEstimate(),i.getTotalWeight())),s.halfLife!==t&&(this.fast_=new c_(t,s.getEstimate(),s.getTotalWeight())),r.halfLife!==e&&(this.ttfb_=new c_(e,r.getEstimate(),r.getTotalWeight()))}sample(e,t){let i=(e=Math.max(e,this.minDelayMs_))/1e3,s=8*t/i;this.fast_.sample(i,s),this.slow_.sample(i,s)}sampleTTFB(e){let t=Math.sqrt(2)*Math.exp(-Math.pow(e/1e3,2)/2);this.ttfb_.sample(t,Math.max(e,5))}canEstimate(){return this.fast_.getTotalWeight()>=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}get defaultEstimate(){return this.defaultEstimate_}destroy(){}}function cO(){return(cO=Object.assign.bind()).apply(null,arguments)}function cN(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),i.push.apply(i,s)}return i}function cF(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?cN(Object(i),!0).forEach(function(t){var s,r;s=t,r=i[t],(s=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var s=i.call(e,t);if("object"!=typeof s)return s;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(s))in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):cN(Object(i)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))})}return e}class cB{constructor(e,t){this.trace=void 0,this.debug=void 0,this.log=void 0,this.warn=void 0,this.info=void 0,this.error=void 0;const i=`[${e}]:`;this.trace=cU,this.debug=t.debug.bind(null,i),this.log=t.log.bind(null,i),this.warn=t.warn.bind(null,i),this.info=t.info.bind(null,i),this.error=t.error.bind(null,i)}}let cU=function(){},cj={trace:cU,debug:cU,log:cU,warn:cU,info:cU,error:cU};function cV(){return cO({},cj)}function cG(e,t,i){let s;return t[e]?t[e].bind(t):(s=self.console[e])?s.bind(self.console,`${i?"["+i+"] ":""}[${e}] >`):cU}let cq=cV();function cH(e=!0){if(!("u"<typeof self))return(e||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function cK(e,t){let i=Object.keys(e),s=Object.keys(t),r=i.length,a=s.length;return!r||!a||r===a&&!i.some(e=>-1===s.indexOf(e))}function cW(e,t=!1){let i,s;if("u">typeof TextDecoder){let i=new TextDecoder("utf-8").decode(e);if(t){let e=i.indexOf("\0");return -1!==e?i.substring(0,e):i}return i.replace(/\0/g,"")}let r=e.length,a="",n=0;for(;n<r&&(0!==(i=e[n++])||!t);)if(0!==i&&3!==i)switch(i>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:a+=String.fromCharCode(i);break;case 12:case 13:a+=String.fromCharCode((31&i)<<6|63&(s=e[n++]));break;case 14:a+=String.fromCharCode((15&i)<<12|(63&(s=e[n++]))<<6|63&e[n++])}return a}function cz(e){let t="";for(let i=0;i<e.length;i++){let s=e[i].toString(16);s.length<2&&(s="0"+s),t+=s}return t}function cY(e){return Uint8Array.from(e.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var cQ={exports:{}},cX=E?cQ.exports:(E=1,s=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,r=/^(?=([^\/?#]*))\1([^]*)$/,a=/(?:\/|^)\.(?=\/)/g,n=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,cQ.exports=l={buildAbsoluteURL:function(e,t,i){if(i=i||{},e=e.trim(),!(t=t.trim())){if(!i.alwaysNormalize)return e;var s=l.parseURL(e);if(!s)throw Error("Error trying to parse base URL.");return s.path=l.normalizePath(s.path),l.buildURLFromParts(s)}var a=l.parseURL(t);if(!a)throw Error("Error trying to parse relative URL.");
4if(a.scheme)return i.alwaysNormalize?(a.path=l.normalizePath(a.path),l.buildURLFromParts(a)):t;var n=l.parseURL(e);if(!n)throw Error("Error trying to parse base URL.");if(!n.netLoc&&n.path&&"/"!==n.path[0]){var o=r.exec(n.path);n.netLoc=o[1],n.path=o[2]}n.netLoc&&!n.path&&(n.path="/");var d={scheme:n.scheme,netLoc:a.netLoc,path:null,params:a.params,query:a.query,fragment:a.fragment};if(!a.netLoc&&(d.netLoc=n.netLoc,"/"!==a.path[0]))if(a.path){var h=n.path,u=h.substring(0,h.lastIndexOf("/")+1)+a.path;d.path=l.normalizePath(u)}else d.path=n.path,!a.params&&(d.params=n.params,a.query||(d.query=n.query));return null===d.path&&(d.path=i.alwaysNormalize?l.normalizePath(a.path):a.path),l.buildURLFromParts(d)},parseURL:function(e){var t=s.exec(e);return t?{scheme:t[1]||"",netLoc:t[2]||"",path:t[3]||"",params:t[4]||"",query:t[5]||"",fragment:t[6]||""}:null},normalizePath:function(e){for(e=e.split("").reverse().join("").replace(a,"");e.length!==(e=e.replace(n,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}},cQ.exports);class cJ{constructor(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}}var cZ="audio",c0="video",c1="audiovideo";class c2{constructor(e){this._byteRange=null,this._url=null,this._stats=null,this._streams=null,this.base=void 0,this.relurl=void 0,"string"==typeof e&&(e={url:e}),this.base=e,function(e,t){let i=function e(t,i){let s=Object.getPrototypeOf(t);if(s){let t=Object.getOwnPropertyDescriptor(s,i);return t||e(s,i)}}(e,t);i&&(i.enumerable=!0,Object.defineProperty(e,t,i))}(this,"stats")}setByteRange(e,t){let i,s=e.split("@",2);i=1===s.length?(null==t?void 0:t.byteRangeEndOffset)||0:parseInt(s[1]),this._byteRange=[i,parseInt(s[0])+i]}get baseurl(){return this.base.url}get byteRange(){return null===this._byteRange?[]:this._byteRange}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get elementaryStreams(){return null===this._streams&&(this._streams={[cZ]:null,[c0]:null,[c1]:null}),this._streams}set elementaryStreams(e){this._streams=e}get hasStats(){return null!==this._stats}get hasStreams(){return null!==this._streams}get stats(){return null===this._stats&&(this._stats=new cJ),this._stats}set stats(e){this._stats=e}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=cX.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}clearElementaryStreamInfo(){let{elementaryStreams:e}=this;e[cZ]=null,e[c0]=null,e[c1]=null}}function c5(e){return"initSegment"!==e.sn}class c3 extends c2{constructor(e,t){super(t),this._decryptdata=null,this._programDateTime=null,this._ref=null,this._bitrate=void 0,this.rawProgramDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.playlistOffset=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.urlId=0,this.type=e}get byteLength(){if(this.hasStats){let e=this.stats.total;if(e)return e}if(this.byteRange.length){let e=this.byteRange[0],t=this.byteRange[1];if(cS(e)&&cS(t))return t-e}return null}get bitrate(){return this.byteLength?8*this.byteLength/this.duration:this._bitrate?this._bitrate:null}set bitrate(e){this._bitrate=e}get decryptdata(){var e;let{levelkeys:t}=this;if(!t||t.NONE)return null;if(t.identity)this._decryptdata||(this._decryptdata=t.identity.getDecryptData(this.sn));else if(!(null!=(e=this._decryptdata)&&e.keyId)){let e=Object.keys(t);if(1===e.length){let i=this._decryptdata=t[e[0]]||null;i&&(this._decryptdata=i.getDecryptData(this.sn,t))}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(null===this.programDateTime)return null;let e=cS(this.duration)?this.duration:0;return this.programDateTime+1e3*e}get encrypted(){var e,t;if(null!=(e=this._decryptdata)&&e.encrypted)return!0;
4if(this.levelkeys){let e=Object.keys(this.levelkeys),i=e.length;if(i>1||1===i&&null!=(t=this.levelkeys[e[0]])&&t.encrypted)return!0}return!1}get programDateTime(){return null===this._programDateTime&&this.rawProgramDateTime&&(this.programDateTime=Date.parse(this.rawProgramDateTime)),this._programDateTime}set programDateTime(e){if(!cS(e)){this._programDateTime=this.rawProgramDateTime=null;return}this._programDateTime=e}get ref(){return c5(this)?(this._ref||(this._ref={base:this.base,start:this.start,duration:this.duration,sn:this.sn,programDateTime:this.programDateTime}),this._ref):null}addStart(e){this.setStart(this.start+e)}setStart(e){this.start=e,this._ref&&(this._ref.start=e)}setDuration(e){this.duration=e,this._ref&&(this._ref.duration=e)}setKeyFormat(e){let t=this.levelkeys;if(t){var i;let s=t[e];s&&!(null!=(i=this._decryptdata)&&i.keyId)&&(this._decryptdata=s.getDecryptData(this.sn,t))}}abortRequests(){var e,t;null==(e=this.loader)||e.abort(),null==(t=this.keyLoader)||t.abort()}setElementaryStreamInfo(e,t,i,s,r,a=!1){let{elementaryStreams:n}=this,l=n[e];if(!l){n[e]={startPTS:t,endPTS:i,startDTS:s,endDTS:r,partial:a};return}l.startPTS=Math.min(l.startPTS,t),l.endPTS=Math.max(l.endPTS,i),l.startDTS=Math.min(l.startDTS,s),l.endDTS=Math.max(l.endDTS,r)}}class c4 extends c2{constructor(e,t,i,s,r){super(i),this.fragOffset=0,this.duration=0,this.gap=!1,this.independent=!1,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.duration=e.decimalFloatingPoint("DURATION"),this.gap=e.bool("GAP"),this.independent=e.bool("INDEPENDENT"),this.relurl=e.enumeratedString("URI"),this.fragment=t,this.index=s;const a=e.enumeratedString("BYTERANGE");a&&this.setByteRange(a,r),r&&(this.fragOffset=r.fragOffset+r.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){let{elementaryStreams:e}=this;return!!(e.audio||e.video||e.audiovideo)}}let c8=[].push,c6={video:1,audio:2,id3:3,text:4};function c7(e){return String.fromCharCode.apply(null,e)}function c9(e,t){let i=e[t]<<8|e[t+1];return i<0?65536+i:i}function fe(e,t){let i=fi(e,t);return i<0?0x100000000+i:i}function ft(e,t){let i=fe(e,t);return i*=0x100000000,i+=fe(e,t+4)}function fi(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function fs(e,t){let i=[];if(!t.length)return i;let s=e.byteLength;for(let r=0;r<s;){let a=fe(e,r),n=c7(e.subarray(r+4,r+8)),l=a>1?r+a:s;if(n===t[0])if(1===t.length)i.push(e.subarray(r+8,l));else{let s=fs(e.subarray(r+8,l),t.slice(1));s.length&&c8.apply(i,s)}r=l}return i}function fr(e){let t=[],i=fs(e,["moov","trak"]);for(let e=0;e<i.length;e++){let s=i[e],r=fs(s,["tkhd"])[0];if(r){let e=r[0],i=fe(r,0===e?12:20),a=fs(s,["mdia","mdhd"])[0];if(a){e=a[0];let r=fe(a,0===e?12:20),n=fs(s,["mdia","hdlr"])[0];if(n){let e=c7(n.subarray(8,12)),a={soun:cZ,vide:c0}[e],l=function(e){let t,i=e.subarray(8),s=i.subarray(86),r=c7(i.subarray(4,8)),a=r,n="enca"===r||"encv"===r;if(n){let e=fs(i,[r])[0].subarray("enca"===r?28:78);fs(e,["sinf"]).forEach(e=>{let t=fs(e,["schm"])[0];if(t){let i=c7(t.subarray(4,8));if("cbcs"===i||"cenc"===i){let t=fs(e,["frma"])[0];t&&(a=c7(t))}}})}let l=a;switch(a){case"avc1":case"avc2":case"avc3":case"avc4":{let e=fs(s,["avcC"])[0];e&&e.length>3&&(a+="."+fl(e[1])+fl(e[2])+fl(e[3]),t=fa("avc1"===l?"dva1":"dvav",s));break}case"mp4a":{let e=fs(i,[r])[0],t=fs(e.subarray(28),["esds"])[0];if(t&&t.length>7){let e=4;if(3!==t[e++])break;e=fn(t,e)+2;let i=t[e++];if(128&i&&(e+=2),64&i&&(e+=t[e++]),4!==t[e++])break;e=fn(t,e);let s=t[e++];if(64===s)a+="."+fl(s);else break;if(e+=12,5!==t[e++])break;e=fn(t,e);let r=t[e++],n=(248&r)>>3;31===n&&(n+=1+((7&r)<<3)+((224&t[e])>>5)),a+="."+n}break}case"hvc1":case"hev1":{let e=fs(s,["hvcC"])[0];if(e&&e.length>12){let t=e[1],i=["","A","B","C"][t>>6],s=fe(e,2),r=e[12],n=e.subarray(6,12);a+="."+i+(31&t),a+="."+(function(e){let t=0;for(let i=0;i<32;i++)t|=(e>>i&1)<<31-i;return t>>>0})(s).toString(16).toUpperCase(),a+="."+((32&t)>>5?"H":"L")+r;let l="";for(let e=n.length;e--;){let t=n[e];(t||l)&&(l="."+t.toString(16).toUpperCase()+l)}a+=l}t=fa("hev1"==l?"dvhe":"dvh1",s);break}case"dvh1":case"dvhe":case"dvav":case"dva1":case"dav1":a=fa(a,s)||a;break;case"vp09":{let e=fs(s,["vpcC"])[0];if(e&&e.length>6){let t=e[4],i=e[5],s=e[6]>>4&15;a+="."+fo(t)+"."+fo(i)+"."+fo(s)}break}case"av01":{let e=fs(s,["av1C"])[0];if(e&&e.length>2){let i=e[1]>>>5,r=31&e[1],n=e[2]>>>7?"H":"M",l=(64&e[2])>>6,o=(32&e[2])>>5,d=(16&e[2])>>4,h=(8&e[2])>>3,u=(4&e[2])>>2,c=3&e[2];a+="."+i+"."+fo(r)+n+"."+fo(2===i&&l?o?12:10:l?10:8)+"."+d+"."+h+u+c+"."+fo(1)+"."+fo(1)+"."+fo(1)+".0",t=fa("dav1",s)}}}return{codec:a,encrypted:n,supplemental:t}}(fs(s,["mdia","minf","stbl","stsd"])[0]);a?(t[i]={timescale:r,type:a,stsd:l},t[a]=cF({timescale:r,id:i},l)):t[i]={timescale:r,type:e,stsd:l}}}}}
4return fs(e,["moov","mvex","trex"]).forEach(e=>{let i=t[fe(e,4)];i&&(i.default={duration:fe(e,12),flags:fe(e,20)})}),t}function fa(e,t){let i=fs(t,["dvvC"]),s=i.length?i[0]:fs(t,["dvcC"])[0];if(s){let t=s[2]>>1&127,i=s[2]<<5&32|s[3]>>3&31;return e+"."+fo(t)+"."+fo(i)}}function fn(e,t){let i=t+5;for(;128&e[t++]&&t<i;);return t}function fl(e){return("0"+e.toString(16).toUpperCase()).slice(-2)}function fo(e){return(e<10?"0":"")+e}function fd(e,t){fs(e,["moov","trak"]).forEach(e=>{let i=fs(e,["mdia","minf","stbl","stsd"])[0];if(!i)return;let s=i.subarray(8),r=fs(s,["enca"]),a=r.length>0;a||(r=fs(s,["encv"])),r.forEach(e=>{fs(a?e.subarray(28):e.subarray(78),["sinf"]).forEach(e=>{let i=fh(e);i&&t(i,a)})})})}function fh(e){let t=fs(e,["schm"])[0];if(t){let i=c7(t.subarray(4,8));if("cbcs"===i||"cenc"===i){let t=fs(e,["schi","tenc"])[0];if(t)return t}}}function fu(e,t){let i=new Uint8Array(e.length+t.length);return i.set(e),i.set(t,e.length),i}function fc(e,t){let i=[],s=t.samples,r=t.timescale,a=t.id,n=!1;return fs(s,["moof"]).map(l
4=>{let o=l.byteOffset-8;fs(l,["traf"]).map(l=>{let d=fs(l,["tfdt"]).map(e=>{let t=e[0],i=fe(e,4);return 1===t&&(i*=0x100000000,i+=fe(e,8)),i/r})[0];return void 0!==d&&(e=d),fs(l,["tfhd"]).map(d=>{let h=fe(d,4),u=0xffffff&fe(d,0),c=0,f=0,p=8;h===a&&((1&u)!=0&&(p+=8),(2&u)!=0&&(p+=4),(8&u)!=0&&(c=fe(d,p),p+=4),(16&u)!=0&&(f=fe(d,p),p+=4),(32&u)!=0&&(p+=4),"video"===t.type&&(n=ff(t.codec)),fs(l,["trun"]).map(a=>{let l=a[0],d=0xffffff&fe(a,0),h=0,u=(256&d)!=0,p=0,m=(512&d)!=0,g=0,y=(1024&d)!=0,v=(2048&d)!=0,b=0,E=fe(a,4),S=8;(1&d)!=0&&(h=fe(a,S),S+=4),(4&d)!=0&&(S+=4);let T=h+o;for(let o=0;o<E;o++){if(u?(p=fe(a,S),S+=4):p=c,m?(g=fe(a,S),S+=4):g=f,y&&(S+=4),v&&(b=0===l?fe(a,S):fi(a,S),S+=4),t.type===c0){let t=0;for(;t<g;){let a=fe(s,T);T+=4,function(e,t){if(!e)return 6==(31&t);{let e=t>>1&63;return 39===e||40===e}}(n,s[T])&&fp(s.subarray(T,T+a),n?2:1,e+b/r,i),T+=a,t+=a+4}}e+=p/r}}))})})}),i}function ff(e){if(!e)return!1;let t=e.substring(0,4);return"hvc1"===t||"hev1"===t||"dvh1"===t||"dvhe"===t}function fp(e,t,i,s){let r,a=fm(e);r=0+t;let n=0,l=0,o=0;for(;r<a.length;){n=0;do{if(r>=a.length)break;n+=o=a[r++]}while(255===o)l=0;do{if(r>=a.length)break;l+=o=a[r++]}while(255===o)let e=a.length-r,t=r;if(l<e)r+=l;else if(l>e){cq.error(`Malformed SEI payload. ${l} is too small, only ${e} bytes left to parse.`);break}if(4===n){if(181===a[t++]){let e=c9(a,t);if(t+=2,49===e){let e=fe(a,t);if(t+=4,0x47413934===e){let e=a[t++];if(3===e){let r=a[t++],l=31&r,o=64&r,d=o?2+3*l:0,h=new Uint8Array(d);if(o){h[0]=r;for(let e=1;e<d;e++)h[e]=a[t++]}s.push({type:e,payloadType:n,pts:i,bytes:h})}}}}}else if(5===n&&l>16){let e=[];for(let i=0;i<16;i++){let s=a[t++].toString(16);e.push(1==s.length?"0"+s:s),(3===i||5===i||7===i||9===i)&&e.push("-")}let r=l-16,o=new Uint8Array(r);for(let e=0;e<r;e++)o[e]=a[t++];s.push({payloadType:n,pts:i,uuid:e.join(""),userData:cW(o),userDataBytes:o})}}}function fm(e){let t=e.byteLength,i=[],s=1;for(;s<t-2;)0===e[s]&&0===e[s+1]&&3===e[s+2]?(i.push(s+2),s+=2):s++;if(0===i.length)return e;let r=t-i.length,a=new Uint8Array(r),n=0;for(s=0;s<r;n++,s++)n===i[0]&&(n++,i.shift()),a[s]=e[n];return a}let fg={audio:{a3ds:1,"ac-3":.95,"ac-4":1,alac:.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":.9,enca:1,fLaC:.9,flac:.9,FLAC:.9,g719:1,g726:1,m4ae:1,mha1:1,mha2:1,mhm1:1,mhm2:1,mlpa:1,mp4a:1,"raw ":1,Opus:1,opus:1,samr:1,sawb:1,sawp:1,sevc:1,sqcp:1,ssmv:1,twos:1,ulaw:1},video:{avc1:1,avc2:1,avc3:1,avc4:1,avcp:1,av01:.8,dav1:.8,drac:1,dva1:1,dvav:1,dvh1:.7,dvhe:.7,encv:1,hev1:.75,hvc1:.75,mjp2:1,mp4v:1,mvc1:1,mvc2:1,mvc3:1,mvc4:1,resv:1,rv60:1,s263:1,svc1:1,svc2:1,"vc-1":1,vp08:1,vp09:.9},text:{stpp:1,wvtt:1}};function fy(e,t){let i=fg[t];return!!i&&!!i[e.slice(0,4)]}function fv(e,t,i=!0){return!e.split(",").some(e=>!fb(e,t,i))}function fb(e,t,i=!0){var s;let r=cH(i);return null!=(s=null==r?void 0:r.isTypeSupported(fE(e,t)))&&s}function fE(e,t){return`${t}/mp4;codecs=${e}`}function fS(e){if(e){let t=e.substring(0,4);return fg.video[t]}return 2}function fT(e){let t=/\(Windows.+Firefox\//i.test(navigator.userAgent);return e.split(",").reduce((e,i)=>{let s=t&&ff(i)?9:fg.video[i];return s?(2*s+e)/(e?3:2):(fg.audio[i]+e)/(e?2:1)},0)}let fx={},fk=/flac|opus|mp4a\.40\.34/i;function fw(e,t=!0){return e.replace(fk,e=>(function(e,t=!0){if(fx[e])return fx[e];let i={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"],"mp4a.40.34":["mp3"]}[e];for(let r=0;r<i.length;r++){var s;if(fb(i[r],"audio",t))return fx[e]=i[r],i[r];if("mp3"===i[r]&&null!=(s=cH(t))&&s.isTypeSupported("audio/mpeg"))return""}return e})(e.toLowerCase(),t))}function fA(e,t){if(e&&(e.length>4||-1!==["ac-3","ec-3","alac","fLaC","Opus"].indexOf(e))&&(fR(e,"audio")||fR(e,"video")))return e;if(t){let i=t.split(",");if(i.length>1){if(e){for(let t=i.length;t--;)if(i[t].substring(0,4)===e.substring(0,4))return i[t]}return i[0]}}return t||e}function fR(e,t){return fy(e,t)&&fb(e,t)}function fL(e){let t=cH(e)||{isTypeSupported:()=>!1};return{mpeg:t.isTypeSupported("audio/mpeg"),mp3:t.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:t.isTypeSupported('audio/mp4; codecs="ac-3"')}}function fC(e){return e.replace(/^.+codecs=["']?([^"']+).*$/,"$1")}let fI={supported:!1,smooth:!1,powerEfficient:!1},fP={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]};function fD(e,t){return{supported:!1,configurations:t,decodingInfoResults:[fI],error:e}}function fM(e,t,i,s={}){var r,a,n,l,o,d;let h,u,c,f,p,m,g,y,v=e.videoCodec;if(!v&&!e.audioCodec||!i)return Promise.resolve(fP);let b=[],E=(h=null==(a=(r=e).videoCodec)?void 0:a.split(","),u=f_(r),c=r.width||640,f=r.height||480,p=r.frameRate||30,m=r.videoRange.toLowerCase(),h?h.map(e=>{let t={contentType:fE(function(e){if(e.startsWith("av01.")){let t=e.split("."),i=["0","111","01","01","01","0"];for(let e=t.length;e>4&&e<10;e++)t[e]=i[e-4];return t.join(".")}return e}(e),"video"),width:c,height:f,bitrate:u,framerate:p};return"sdr"!==m&&(t.transferFunction=m),t}):[]),S=E.length,T=(n=e,l=t,o=S>0,g=null==(d=n.audioCodec)?void 0:d.split(","),y=f_(n),g&&n.audioGroups?n.audioGroups.reduce((e,t)=>
4{var i;let s=t?null==(i=l.groups[t])?void 0:i.tracks:null;return s?s.reduce((e,i)=>{if(i.groupId===t){let t=parseFloat(i.channels||"");g.forEach(i=>{let s={contentType:fE(i,"audio"),bitrate:o?function(e,t){if(t<=1)return 1;let i=128e3;return"ec-3"===e?i=768e3:"ac-3"===e&&(i=64e4),Math.min(t/2,i)}(i,y):y};t&&(s.channels=""+t),e.push(s)})}return e},e):e},[]):[]),x=T.length;for(let e=S||+x||1;e--;){let t={type:"media-source"};if(S&&(t.video=E[e%S]),x){t.audio=T[e%x];let i=t.audio.bitrate;t.video&&i&&(t.video.bitrate-=i)}b.push(t)}if(v){let e=navigator.userAgent;if(v.split(",").some(e=>ff(e))&&/\(Windows.+Firefox\//i.test(navigator.userAgent))return Promise.resolve(fD(Error(`Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent string: (${e})`),b))}return Promise.all(b.map(e=>{let t=function(e){let t="",{audio:i,video:s}=e;if(s){let e=fC(s.contentType);t+=`${e}_r${s.height}x${s.width}f${Math.ceil(s.framerate)}${s.transferFunction||"sd"}_${Math.ceil(s.bitrate/1e5)}`}if(i){let e=fC(i.contentType);t+=`${s?"_":""}${e}_c${i.channels}`}return t}(e);return s[t]||(s[t]=i.decodingInfo(e))})).then(e=>({supported:!e.some(e=>!e.supported),configurations:b,decodingInfoResults:e})).catch(e=>({supported:!1,configurations:b,decodingInfoResults:[],error:e}))}function f_(e){return 1e3*Math.ceil(Math.max(.9*e.bitrate,e.averageBitrate)/1e3)||1}let f$=["NONE","TYPE-0","TYPE-1",null],fO=["SDR","PQ","HLG"];function fN(e){let{canSkipUntil:t,canSkipDateRanges:i,age:s}=e;return t&&s<t/2?i?"v2":"YES":""}class fF{constructor(e,t,i){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=i}addDirectives(e){let t=new self.URL(e);return void 0!==this.msn&&t.searchParams.set("_HLS_msn",this.msn.toString()),void 0!==this.part&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href}}class fB{constructor(e){if(this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.supplemental=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=void 0,this._urlId=0,this.url=[e.url],this._attrs=[e.attrs],this.bitrate=e.bitrate,e.details&&(this.details=e.details),this.id=e.id||0,this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.frameRate=e.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=e.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.codecSet=[e.videoCodec,e.audioCodec].filter(e=>!!e).map(e=>e.substring(0,4)).join(","),"supplemental"in e){var t;this.supplemental=e.supplemental;const i=null==(t=e.supplemental)?void 0:t.videoCodec;i&&i!==e.videoCodec&&(this.codecSet+=`,${i.substring(0,4)}`)}this.addGroupId("audio",e.attrs.AUDIO),this.addGroupId("text",e.attrs.SUBTITLES)}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get averageBitrate(){return this._avgBitrate||this.realBitrate||this.bitrate}get attrs(){return this._attrs[0]}get codecs(){return this.attrs.CODECS||""}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get videoRange(){return this.attrs["VIDEO-RANGE"]||"SDR"}get score(){return this.attrs.optionalFloat("SCORE",0)}get uri(){return this.url[0]||""}hasAudioGroup(e){return fU(this._audioGroups,e)}hasSubtitleGroup(e){return fU(this._subtitleGroups,e)}get audioGroups(){return this._audioGroups}get subtitleGroups(){return this._subtitleGroups}addGroupId(e,t){if(t){if("audio"===e){let e=this._audioGroups;e||(e=this._audioGroups=[]),-1===e.indexOf(t)&&e.push(t)}else if("text"===e){let e=this._subtitleGroups;e||(e=this._subtitleGroups=[]),-1===e.indexOf(t)&&e.push(t)}}}get urlId(){return 0}set urlId(e){}get audioGroupIds(){return this.audioGroups?[this.audioGroupId]:void 0}get textGroupIds(){return this.subtitleGroups?[this.textGroupId]:void 0}get audioGroupId(){var e;return null==(e=this.audioGroups)?void 0:e[0]}get textGroupId(){var e;return null==(e=this.subtitleGroups)?void 0:e[0]}addFallback(){}}function fU(e,t){return!!t&&!!e&&-1!==e.indexOf(t)}let fj=(e,t)=>{let i;return JSON.stringify(e,(i=new WeakSet,(e,s)=>{if(t&&(s=t(e,s)),"object"==typeof s&&null!==s){if(i.has(s))return;i.add(s)}return s}))};function fV(e,t){cq.log(`[abr] start candidates with "${e}" ignored because ${t}`)}function fG(e){return e.reduce((e,t)=>
4{let i=e.groups[t.groupId];i||(i=e.groups[t.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),i.tracks.push(t);let s=t.channels||"2";return i.channels[s]=(i.channels[s]||0)+1,i.hasDefault=i.hasDefault||t.default,i.hasAutoSelect=i.hasAutoSelect||t.autoselect,i.hasDefault&&(e.hasDefaultAudio=!0),i.hasAutoSelect&&(e.hasAutoSelectAudio=!0),e},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function fq(e){if(!e)return e;let{lang:t,assocLang:i,characteristics:s,channels:r,audioCodec:a}=e;return{lang:t,assocLang:i,characteristics:s,channels:r,audioCodec:a}}function fH(e,t,i){if("attrs"in e){let i=t.indexOf(e);if(-1!==i)return i}for(let s=0;s<t.length;s++)if(fK(e,t[s],i))return s;return -1}function fK(e,t,i){let{groupId:s,name:r,lang:a,assocLang:n,default:l}=e,o=e.forced;return(void 0===s||t.groupId===s)&&(void 0===r||t.name===r)&&(void 0===a||function(e,t="--"){return e.length===t.length?e===t:e.startsWith(t)||t.startsWith(e)}(a,t.lang))&&(void 0===a||t.assocLang===n)&&(void 0===l||t.default===l)&&(void 0===o||t.forced===o)&&(!("characteristics"in e)||function(e,t=""){let i=e.split(","),s=t.split(",");return i.length===s.length&&!i.some(e=>-1===s.indexOf(e))}(e.characteristics||"",t.characteristics))&&(void 0===i||i(e,t))}function fW(e,t){let{audioCodec:i,channels:s}=e;return(void 0===i||(t.audioCodec||"").substring(0,4)===i.substring(0,4))&&(void 0===s||s===(t.channels||"2"))}function fz(e,t,i){for(let s=t;s>-1;s--)if(i(e[s]))return s;for(let s=t+1;
4s<e.length;s++)if(i(e[s]))return s;return -1}function fY(e,t){var i;return!!e&&e!==(null==(i=t.loadLevelObj)?void 0:i.uri)}let fQ=function(e,t){let i=0,s=e.length-1,r=null,a=null;for(;i<=s;){let n=t(a=e[r=(i+s)/2|0]);if(n>0)i=r+1;else{if(!(n<0))return a;s=r-1}}return null};function fX(e,t,i=0,s=0,r=.005){let a=null;if(e){a=t[1+e.sn-t[0].sn]||null;let s=e.endDTS-i;s>0&&s<15e-7&&(i+=15e-7),a&&e.level!==a.level&&a.end<=e.end&&(a=t[2+e.sn-t[0].sn]||null)}else 0===i&&0===t[0].start&&(a=t[0]);if(a&&((!e||e.level===a.level)&&0===fJ(i,s,a)||function(e,t,i){if(t&&0===t.start&&t.level<e.level&&(t.endPTS||0)>0){let s=t.tagList.reduce((e,t)=>("INF"===t[0]&&(e+=parseFloat(t[1])),e),i);return e.start<=s}return!1}(a,e,Math.min(r,s))))return a;let n=fQ(t,fJ.bind(null,i,s));return n&&(n!==e||!a)?n:a}function fJ(e=0,t=0,i){if(i.start<=e&&i.start+i.duration>e)return 0;let s=Math.min(t,i.duration+(i.deltaPTS?i.deltaPTS:0));return i.start+i.duration-s<=e?1:i.start-s>e&&i.start?-1:0}function fZ(e,t,i){if(e&&e.startCC<=t&&e.endCC>=t){let s,r=e.fragments,{fragmentHint:a}=e;return a&&(r=r.concat(a)),fQ(r,e=>e.cc<t?1:e.cc>t?-1:(s=e,e.end<=i)?1:e.start>i?-1:0),s||null}return null}function f0(e){switch(e.details){case cw.FRAG_LOAD_TIMEOUT:case cw.KEY_LOAD_TIMEOUT:case cw.LEVEL_LOAD_TIMEOUT:case cw.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function f1(e){return e.details.startsWith("key")}function f2(e){return f1(e)&&!!e.frag&&!e.frag.decryptdata}function f5(e,t){let i=f0(t);return e.default[`${i?"timeout":"error"}Retry`]}function f3(e,t){return Math.min(("linear"===e.backoff?1:Math.pow(2,t))*e.retryDelayMs,e.maxRetryDelayMs)}function f4(e){return cF(cF({},e),{errorRetry:null,timeoutRetry:null})}function f8(e,t,i,s){var r;if(!e)return!1;let a=null==s?void 0:s.code,n=t<e.maxNumRetry&&(f6(r=a)||!!r&&(r<400||r>499)||!!i);return e.shouldRetry?e.shouldRetry(e,t,i,s,n):n}function f6(e){return 0===e&&!1===navigator.onLine}function f7(e){let t={action:0,flags:0};return e&&(t.resolved=!0),t}var f9="NOT_LOADED",pe="APPENDING",pt="PARTIAL";class pi{constructor(e){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=e,this._registerListeners()}_registerListeners(){let{hls:e}=this;e&&(e.on(cA.MANIFEST_LOADING,this.onManifestLoading,this),e.on(cA.BUFFER_APPENDED,this.onBufferAppended,this),e.on(cA.FRAG_BUFFERED,this.onFragBuffered,this),e.on(cA.FRAG_LOADED,this.onFragLoaded,this))}_unregisterListeners(){let{hls:e}=this;e&&(e.off(cA.MANIFEST_LOADING,this.onManifestLoading,this),e.off(cA.BUFFER_APPENDED,this.onBufferAppended,this),e.off(cA.FRAG_BUFFERED,this.onFragBuffered,this),e.off(cA.FRAG_LOADED,this.onFragLoaded,this))}destroy(){this._unregisterListeners(),this.hls=this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(e,t){let i=this.activePartLists[t];if(i)for(let t=i.length;t--;){let s=i[t];if(!s)break;if(s.start<=e&&e<=s.end&&s.loaded)return s}return this.getBufferedFrag(e,t)}getBufferedFrag(e,t){return this.getFragAtPos(e,t,!0)}getFragAtPos(e,t,i){let{fragments:s}=this,r=Object.keys(s);for(let a=r.length;a--;){let n=s[r[a]];if((null==n?void 0:n.body.type)===t&&(!i||n.buffered)){let t=n.body;if(t.start<=e&&e<=t.end)return t}}return null}detectEvictedFragments(e,t,i,s,r){this.timeRanges&&(this.timeRanges[e]=t);let a=(null==s?void 0:s.fragment.sn)||-1;Object.keys(this.fragments).forEach(s=>{let n=this.fragments[s];if(!n||a>=n.body.sn)return;if(!n.buffered&&(!n.loaded||r)){n.body.type===i&&this.removeFragment(n.body);return}let l=n.range[e];if(l){if(0===l.time.length)return void this.removeFragment(n.body);l.time.some(e=>{let i=!this.isTimeBuffered(e.startPTS,e.endPTS,t);return i&&this.removeFragment(n.body),i})}})}detectPartialFragments(e){let t=this.timeRanges;if(!t||"initSegment"===e.frag.sn)return;let i=e.frag,s=pr(i),r=this.fragments[s];if(!r||r.buffered&&i.gap)return;let a=!i.relurl;Object.keys(t).forEach(s=>{let n=i.elementaryStreams[s];if(!n)return;
4let l=t[s],o=a||!0===n.partial;r.range[s]=this.getBufferedTimes(i,e.part,o,l)}),r.loaded=null,Object.keys(r.range).length?(this.bufferedEnd(r,i),ps(r)||this.removeParts(i.sn-1,i.type)):this.removeFragment(r.body)}bufferedEnd(e,t){e.buffered=!0,(e.body.endList=t.endList||e.body.endList)&&(this.endListFragments[e.body.type]=e)}removeParts(e,t){let i=this.activePartLists[t];i&&(this.activePartLists[t]=pa(i,t=>t.fragment.sn>=e))}fragBuffered(e,t){let i=pr(e),s=this.fragments[i];!s&&t&&(s=this.fragments[i]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),s&&(s.loaded=null,this.bufferedEnd(s,e))}getBufferedTimes(e,t,i,s){let r={time:[],partial:i},a=e.start,n=e.end,l=e.minEndPTS||n,o=e.maxStartPTS||a;for(let e=0;e<s.length;e++){let t=s.start(e)-this.bufferPadding,i=s.end(e)+this.bufferPadding;if(o>=t&&l<=i){r.time.push({startPTS:Math.max(a,s.start(e)),endPTS:Math.min(n,s.end(e))});break}if(a<i&&n>t){let t=Math.max(a,s.start(e)),i=Math.min(n,s.end(e));i>t&&(r.partial=!0,r.time.push({startPTS:t,endPTS:i}))}else if(n<=t)break}return r}getPartialFragment(e){let t,i,s,r=null,a=0,{bufferPadding:n,fragments:l}=this;return Object.keys(l).forEach(o=>{let d=l[o];d&&ps(d)&&(i=d.body.start-n,s=d.body.end+n,e>=i&&e<=s&&a<=(t=Math.min(e-i,s-e))&&(r=d.body,a=t))}),r}isEndListAppended(e){let t=this.endListFragments[e];return void 0!==t&&(t.buffered||ps(t))}getState(e){let t=pr(e),i=this.fragments[t];if(i)if(!i.buffered)return pe;else if(ps(i))return pt;else return"OK";return f9}isTimeBuffered(e,t,i){let s,r;for(let a=0;a<i.length;a++){if(s=i.start(a)-this.bufferPadding,r=i.end(a)+this.bufferPadding,e>=s&&t<=r)return!0;if(t<=s)break}return!1}onManifestLoading(){this.removeAllFragments()}onFragLoaded(e,t){if("initSegment"===t.frag.sn||t.frag.bitrateTest)return;let i=t.frag,s=t.part?null:t,r=pr(i);this.fragments[r]={body:i,appendedPTS:null,loaded:s,buffered:!1,range:Object.create(null)}}onBufferAppended(e,t){let{frag:i,part:s,timeRanges:r,type:a}=t;if("initSegment"===i.sn)return;let n=i.type;if(s){let e=this.activePartLists[n];e||(this.activePartLists[n]=e=[]),e.push(s)}this.timeRanges=r;let l=r[a];this.detectEvictedFragments(a,l,n,s)}onFragBuffered(e,t){this.detectPartialFragments(t)}hasFragment(e){let t=pr(e);return!!this.fragments[t]}hasFragments(e){let{fragments:t}=this,i=Object.keys(t);if(!e)return i.length>0;for(let s=i.length;s--;){let r=t[i[s]];if((null==r?void 0:r.body.type)===e)return!0}return!1}hasParts(e){var t;return!!(null!=(t=this.activePartLists[e])&&t.length)}removeFragmentsInRange(e,t,i,s,r){(!s||this.hasGaps)&&Object.keys(this.fragments).forEach(a=>{let n=this.fragments[a];if(!n)return;let l=n.body;l.type===i&&(!s||l.gap)&&l.start<t&&l.end>e&&(n.buffered||r)&&this.removeFragment(l)})}removeFragment(e){let t=pr(e);e.clearElementaryStreamInfo();let i=this.activePartLists[e.type];if(i){let t=e.sn;this.activePartLists[e.type]=pa(i,e=>e.fragment.sn!==t)}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}removeAllFragments(){var e;this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1;let t=null==(e=this.hls)||null==(e=e.latestLevelDetails)?void 0:e.partList;t&&t.forEach(e=>e.clearElementaryStreamInfo())}}function ps(e){var t,i,s;return e.buffered&&!!(e.body.gap||null!=(t=e.range.video)&&t.partial||null!=(i=e.range.audio)&&i.partial||null!=(s=e.range.audiovideo)&&s.partial)}function pr(e){return`${e.type}_${e.level}_${e.sn}`}function pa(e,t){return e.filter(e=>{let i=t(e);return i||e.clearElementaryStreamInfo(),i})}class pn{constructor(e,t,i){this.subtle=void 0,this.aesIV=void 0,this.aesMode=void 0,this.subtle=e,this.aesIV=t,this.aesMode=i}decrypt(e,t){switch(this.aesMode){case 0:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e);case 1:return this.subtle.decrypt({name:"AES-CTR",counter:this.aesIV,length:64},t,e);default:throw Error(`[AESCrypto] invalid aes mode ${this.aesMode}`)}}}class pl{constructor(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}uint8ArrayToUint32Array_(e){let t=new DataView(e),i=new Uint32Array(4);for(let e=0;e<4;e++)i[e]=t.getUint32(4*e);return i}initTable(){let e=this.sBox,t=this.invSBox,i=this.subMix,s=i[0],r=i[1],a=i[2],n=i[3],l=this.invSubMix,o=l[0],d=l[1],h=l[2],u=l[3],c=new Uint32Array(256),f=0,p=0,m=0;for(m=0;m<256;m++)m<128?c[m]=m<<1:c[m]=m<<1^283;for(m=0;m<256;m++){let i=p^p<<1^p<<2^p<<3^p<<4;i=i>>>8^255&i^99,e[f]=i,t[i]=f;let l=c[f],m=c[l],g=c[m],y=257*c[i]^0x1010100*i;s[f]=y<<24|y>>>8,r[f]=y<<16|y>>>16,a[f]=y<<8|y>>>24,n[f]=y,y=0x1010101*g^65537*m^257*l^0x1010100*f,o[i]=y<<24|y>>>8,d[i]=y<<16|y>>>16,h[i]=y<<8|y>>>24,u[i]=y,f?(f=l^c[c[c[g^l]]],p^=c[c[p]]):f=p=1}}expandKey(e){let t,i,s,r,a=this.uint8ArrayToUint32Array_(e),n=!0,l=0;for(;l<a.length&&n;)n=a[l]===this.key[l],l++;if(n)return;this.key=a;let o=this.keySize=a.length;if(4!==o&&6!==o&&8!==o)throw Error("Invalid aes key size="+o);let d=this.ksRows=(o+6+1)*4,h=this.keySchedule=new Uint32Array(d),u=this.invKeySchedule=new Uint32Array(d),c=this.sBox,f=this.rcon,p=this.invSubMix,m=p[0],g=p[1],y=p[2],v=p[3];for(t=0;t<d;
4t++){if(t<o){s=h[t]=a[t];continue}r=s,t%o==0?r=(c[(r=r<<8|r>>>24)>>>24]<<24|c[r>>>16&255]<<16|c[r>>>8&255]<<8|c[255&r])^f[t/o|0]<<24:o>6&&t%o==4&&(r=c[r>>>24]<<24|c[r>>>16&255]<<16|c[r>>>8&255]<<8|c[255&r]),h[t]=s=(h[t-o]^r)>>>0}for(i=0;i<d;i++)t=d-i,r=3&i?h[t]:h[t-4],i<4||t<=4?u[i]=r:u[i]=m[c[r>>>24]]^g[c[r>>>16&255]]^y[c[r>>>8&255]]^v[c[255&r]],u[i]=u[i]>>>0}networkToHostOrderSwap(e){return e<<24|(65280&e)<<8|(0xff0000&e)>>8|e>>>24}decrypt(e,t,i){let s,r,a,n,l,o,d,h,u,c,f,p,m,g,y=this.keySize+6,v=this.invKeySchedule,b=this.invSBox,E=this.invSubMix,S=E[0],T=E[1],x=E[2],k=E[3],w=this.uint8ArrayToUint32Array_(i),A=w[0],R=w[1],L=w[2],C=w[3],I=new Int32Array(e),P=new Int32Array(I.length),D=this.networkToHostOrderSwap;for(;t<I.length;){for(g=1,u=D(I[t]),c=D(I[t+1]),f=D(I[t+2]),p=D(I[t+3]),l=u^v[0],o=p^v[1],d=f^v[2],h=c^v[3],m=4;g<y;g++)s=S[l>>>24]^T[o>>16&255]^x[d>>8&255]^k[255&h]^v[m],r=S[o>>>24]^T[d>>16&255]^x[h>>8&255]^k[255&l]^v[m+1],a=S[d>>>24]^T[h>>16&255]^x[l>>8&255]^k[255&o]^v[m+2],n=S[h>>>24]^T[l>>16&255]^x[o>>8&255]^k[255&d]^v[m+3],l=s,o=r,d=a,h=n,m+=4;s=b[l>>>24]<<24^b[o>>16&255]<<16^b[d>>8&255]<<8^b[255&h]^v[m],r=b[o>>>24]<<24^b[d>>16&255]<<16^b[h>>8&255]<<8^b[255&l]^v[m+1],a=b[d>>>24]<<24^b[h>>16&255]<<16^b[l>>8&255]<<8^b[255&o]^v[m+2],n=b[h>>>24]<<24^b[l>>16&255]<<16^b[o>>8&255]<<8^b[255&d]^v[m+3],P[t]=D(s^A),P[t+1]=D(n^R),P[t+2]=D(a^L),P[t+3]=D(r^C),A=u,R=c,L=f,C=p,t+=4}return P.buffer}}class po{constructor(e,t,i){this.subtle=void 0,this.key=void 0,this.aesMode=void 0,this.subtle=e,this.key=t,this.aesMode=i}expandKey(){let e=function(e){switch(e){case 0:return"AES-CBC";case 1:return"AES-CTR";default:throw Error(`[FastAESKey] invalid aes mode ${e}`)}}(this.aesMode);return this.subtle.importKey("raw",this.key,{name:e},!1,["encrypt","decrypt"])}}class pd{constructor(e,{removePKCS7Padding:t=!0}={}){if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.enableSoftwareAES=void 0,this.enableSoftwareAES=e.enableSoftwareAES,this.removePKCS7Padding=t,t)try{const e=self.crypto;e&&(this.subtle=e.subtle||e.webkitSubtle)}catch(e){}this.useSoftware=!this.subtle}destroy(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}isSync(){return this.useSoftware}flush(){let{currentResult:e,remainderData:t}=this;if(!e||t)return this.reset(),null;let i=new Uint8Array(e);if(this.reset(),this.removePKCS7Padding){let e,t;return(t=(e=i.byteLength)&&new DataView(i.buffer).getUint8(e-1))?i.slice(0,e-t):i}return i}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(e,t,i,s){return this.useSoftware?new Promise((r,a)=>{let n=ArrayBuffer.isView(e)?e:new Uint8Array(e);this.softwareDecrypt(n,t,i,s);let l=this.flush();l?r(l.buffer):a(Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,i,s)}softwareDecrypt(e,t,i,s){let{currentIV:r,currentResult:a,remainderData:n}=this;if(0!==s||16!==t.byteLength)return cq.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;this.logOnce("JS AES decrypt"),n&&(e=fu(n,e),this.remainderData=null);let l=this.getValidChunk(e);if(!l.length)return null;r&&(i=r);let o=this.softwareDecrypter;return(o||(o=this.softwareDecrypter=new pl),o.expandKey(t),this.currentResult=o.decrypt(l.buffer,0,i),this.currentIV=l.slice(-16).buffer,a)?a:null}webCryptoDecrypt(e,t,i,s){if(this.key!==t||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(e,t,i,s));this.key=t,this.fastAesKey=new po(this.subtle,t,s)}return this.fastAesKey.expandKey().then(t=>this.subtle?(this.logOnce("WebCrypto AES decrypt"),new pn(this.subtle,new Uint8Array(i),s).decrypt(e.buffer,t)):Promise.reject(Error("web crypto not initialized"))).catch(r=>(cq.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${r.name}: ${r.message}`),this.onWebCryptoError(e,t,i,s)))}
4onWebCryptoError(e,t,i,s){let r=this.enableSoftwareAES;if(r){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,i,s);let r=this.flush();if(r)return r.buffer}throw Error("WebCrypto"+(r?" and softwareDecrypt":"")+": failed to decrypt data")}getValidChunk(e){let t=e,i=e.length-e.length%16;return i!==e.length&&(t=e.slice(0,i),this.remainderData=e.slice(i)),t}logOnce(e){this.logEnabled&&(cq.log(`[decrypter]: ${e}`),this.logEnabled=!1)}}class ph{constructor(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(e,t){let i=e.url;if(!i)return Promise.reject(new pf({type:ck.NETWORK_ERROR,details:cw.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:Error(`Fragment does not have a ${i?"part list":"url"}`),networkDetails:null}));this.abort();let s=this.config,r=s.fLoader,a=s.loader;return new Promise((n,l)=>{if(this.loader&&this.loader.destroy(),e.gap)if(e.tagList.some(e=>"GAP"===e[0]))return void l(pc(e));else e.gap=!1;let o=this.loader=r?new r(s):new a(s),d=pu(e);e.loader=o;let h=f4(s.fragLoadPolicy.default),u={loadPolicy:h,timeout:h.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===e.sn?1/0:131072};e.stats=o.stats;let c={onSuccess:(t,i,s,r)=>{this.resetLoader(e,o);let a=t.data;s.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(a.slice(0,16)),a=a.slice(16)),n({frag:e,part:null,payload:a,networkDetails:r})},onError:(t,s,r,a)=>{this.resetLoader(e,o),l(new pf({type:ck.NETWORK_ERROR,details:cw.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:cF({url:i,data:void 0},t),error:Error(`HTTP Error ${t.code} ${t.text}`),networkDetails:r,stats:a}))},onAbort:(t,i,s)=>{this.resetLoader(e,o),l(new pf({type:ck.NETWORK_ERROR,details:cw.INTERNAL_ABORTED,fatal:!1,frag:e,error:Error("Aborted"),networkDetails:s,stats:t}))},onTimeout:(t,i,s)=>{this.resetLoader(e,o),l(new pf({type:ck.NETWORK_ERROR,details:cw.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:Error(`Timeout after ${u.timeout}ms`),networkDetails:s,stats:t}))}};t&&(c.onProgress=(i,s,r,a)=>t({frag:e,part:null,payload:r,networkDetails:a})),o.load(d,u,c)})}loadPart(e,t,i){this.abort();let s=this.config,r=s.fLoader,a=s.loader;return new Promise((n,l)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap)return void l(pc(e,t));let o=this.loader=r?new r(s):new a(s),d=pu(e,t);e.loader=o;let h=f4(s.fragLoadPolicy.default),u={loadPolicy:h,timeout:h.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:131072};t.stats=o.stats,o.load(d,u,{onSuccess:(s,r,a,l)=>{this.resetLoader(e,o),this.updateStatsFromPart(e,t);let d={frag:e,part:t,payload:s.data,networkDetails:l};i(d),n(d)},onError:(i,s,r,a)=>{this.resetLoader(e,o),l(new pf({type:ck.NETWORK_ERROR,details:cw.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:cF({url:d.url,data:void 0},i),error:Error(`HTTP Error ${i.code} ${i.text}`),networkDetails:r,stats:a}))},onAbort:(i,s,r)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,o),l(new pf({type:ck.NETWORK_ERROR,details:cw.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:Error("Aborted"),networkDetails:r,stats:i}))},onTimeout:(i,s,r)=>{this.resetLoader(e,o),l(new pf({type:ck.NETWORK_ERROR,details:cw.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:Error(`Timeout after ${u.timeout}ms`),networkDetails:r,stats:i}))}})})}updateStatsFromPart(e,t){let i=e.stats,s=t.stats,r=s.total;if(i.loaded+=s.loaded,r){let s=Math.round(e.duration/t.duration),a=Math.min(Math.round(i.loaded/r),s),n=(s-a)*Math.round(i.loaded/a);i.total=i.loaded+n}else i.total=Math.max(i.loaded,i.total);let a=i.loading,n=s.loading;a.start?a.first+=n.first-n.start:(a.start=n.start,a.first=n.first),a.end=n.end}resetLoader(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}}function pu(e,t=null){let i=t||e,s={frag:e,part:t,responseType:"arraybuffer",url:i.url,headers:{},rangeStart:0,rangeEnd:0},r=i.byteRangeStartOffset,a=i.byteRangeEndOffset;if(cS(r)&&cS(a)){var n,l;let t=r,i=a;if("initSegment"===e.sn&&("AES-128"===(l=null==(n=e.decryptdata)?void 0:n.method)||"AES-256"===l)){let e=a-r;e%16&&(i=a+(16-e%16)),0!==r&&(s.resetIV=!0,t=r-16)}s.rangeStart=t,s.rangeEnd=i}return s}function pc(e,t){let i=Error(`GAP ${e.gap?"tag":"attribute"} found`),s={type:ck.MEDIA_ERROR,details:cw.FRAG_GAP,fatal:!1,frag:e,error:i,networkDetails:null};return t&&(s.part=t),(t||e).stats.aborted=!0,new pf(s)}
4class pf extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}}class pp extends cB{constructor(e,t){super(e,t),this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed()}onHandlerDestroying(){this.clearNextTick(),this.clearInterval()}onHandlerDestroyed(){}hasInterval(){return!!this._tickInterval}hasNextTick(){return!!this._tickTimer}setInterval(e){return!this._tickInterval&&(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)}clearInterval(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)}clearNextTick(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)}tick(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}}class pm{constructor(e,t,i,s=0,r=-1,a=!1){this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing=pg(),this.buffering={audio:pg(),video:pg(),audiovideo:pg()},this.level=e,this.sn=t,this.id=i,this.size=s,this.part=r,this.partial=a}}function pg(){return{start:0,executeStart:0,executeEnd:0,end:0}}let py={length:0,start:()=>0,end:()=>0};class pv{static isBuffered(e,t){if(e){let i=pv.getBuffered(e);for(let e=i.length;e--;)if(t>=i.start(e)&&t<=i.end(e))return!0}return!1}static bufferedRanges(e){if(e){let t=pv.getBuffered(e);return pv.timeRangesToArray(t)}return[]}static timeRangesToArray(e){let t=[];for(let i=0;i<e.length;i++)t.push({start:e.start(i),end:e.end(i)});return t}static bufferInfo(e,t,i){if(e){let s=pv.bufferedRanges(e);if(s.length)return pv.bufferedInfo(s,t,i)}return{len:0,start:t,end:t,bufferedIndex:-1}}static bufferedInfo(e,t,i){let s;t=Math.max(0,t),e.length>1&&e.sort((e,t)=>e.start-t.start||t.end-e.end);let r=-1,a=[];if(i)for(let s=0;s<e.length;s++){t>=e[s].start&&t<=e[s].end&&(r=s);let n=a.length;if(n){let t=a[n-1].end;e[s].start-t<i?e[s].end>t&&(a[n-1].end=e[s].end):a.push(e[s])}else a.push(e[s])}else a=e;let n=0,l=t,o=t;for(let e=0;e<a.length;e++){let d=a[e].start,h=a[e].end;if(-1===r&&t>=d&&t<=h&&(r=e),t+i>=d&&t<h)l=d,n=(o=h)-t;else if(t+i<d){s=d;break}}return{len:n,start:l||0,end:o||0,nextStart:s,buffered:e,bufferedIndex:r}}static getBuffered(e){try{return e.buffered||py}catch(e){return cq.log("failed to get media.buffered",e),py}}}let pb=/\{\$([a-zA-Z0-9-_]+)\}/g;function pE(e,t){if(null!==e.variableList||e.hasVariableRefs){let i=e.variableList;return t.replace(pb,t=>{let s=t.substring(2,t.length-1),r=null==i?void 0:i[s];return void 0===r?(e.playlistParsingError||(e.playlistParsingError=Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${s}"`)),t):r})}return t}function pS(e,t,i){let s,r,a=e.variableList;if(a||(e.variableList=a={}),"QUERYPARAM"in t){s=t.QUERYPARAM;try{let e=new self.URL(i).searchParams;if(e.has(s))r=e.get(s);else throw Error(`"${s}" does not match any query parameter in URI: "${i}"`)}catch(t){e.playlistParsingError||(e.playlistParsingError=Error(`EXT-X-DEFINE QUERYPARAM: ${t.message}`))}}else s=t.NAME,r=t.VALUE;s in a?e.playlistParsingError||(e.playlistParsingError=Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${s}"`)):a[s]=r||""}let pT=/^(\d+)x(\d+)$/,px=/(.+?)=(".*?"|.*?)(?:,|$)/g;class pk{constructor(e,t){"string"==typeof e&&(e=pk.parseAttrList(e,t)),cO(this,e)}get clientAttrs(){return Object.keys(this).filter(e=>"X-"===e.substring(0,2))}decimalInteger(e){let t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t}hexadecimalInteger(e){if(this[e]){let t=(this[e]||"0x").slice(2),i=new Uint8Array((t=(1&t.length?"0":"")+t).length/2);for(let e=0;e<t.length/2;e++)i[e]=parseInt(t.slice(2*e,2*e+2),16);return i}return null}hexadecimalIntegerAsNumber(e){let t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t}decimalFloatingPoint(e){return parseFloat(this[e])}optionalFloat(e,t){let i=this[e];return i?parseFloat(i):t}enumeratedString(e){return this[e]}enumeratedStringList(e,t){let i=this[e];return(i?i.split(/[ ,]+/):[]).reduce((e,t)=>
4(e[t.toLowerCase()]=!0,e),t)}bool(e){return"YES"===this[e]}decimalResolution(e){let t=pT.exec(this[e]);if(null!==t)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}static parseAttrList(e,t){let i,s={};for(px.lastIndex=0;null!==(i=px.exec(e));){let r=i[1].trim(),a=i[2],n=0===a.indexOf('"')&&a.lastIndexOf('"')===a.length-1,l=!1;if(n)a=a.slice(1,-1);else switch(r){case"IV":case"SCTE35-CMD":case"SCTE35-IN":case"SCTE35-OUT":l=!0}if(t&&(n||l))a=pE(t,a);else if(!l&&!n)switch(r){case"CLOSED-CAPTIONS":if("NONE"===a)break;case"ALLOWED-CPC":case"CLASS":case"ASSOC-LANGUAGE":case"AUDIO":case"BYTERANGE":case"CHANNELS":case"CHARACTERISTICS":case"CODECS":case"DATA-ID":case"END-DATE":case"GROUP-ID":case"ID":case"IMPORT":case"INSTREAM-ID":case"KEYFORMAT":case"KEYFORMATVERSIONS":case"LANGUAGE":case"NAME":case"PATHWAY-ID":case"QUERYPARAM":case"RECENTLY-REMOVED-DATERANGES":case"SERVER-URI":case"STABLE-RENDITION-ID":case"STABLE-VARIANT-ID":case"START-DATE":case"SUBTITLES":case"SUPPLEMENTAL-CODECS":case"URI":case"VALUE":case"VIDEO":case"X-ASSET-LIST":case"X-ASSET-URI":cq.warn(`${e}: attribute ${r} is missing quotes`)}s[r]=a}return s}}class pw{constructor(e,t,i=0){var s;if(this.attr=void 0,this.tagAnchor=void 0,this.tagOrder=void 0,this._startDate=void 0,this._endDate=void 0,this._dateAtEnd=void 0,this._cue=void 0,this._badValueForSameId=void 0,this.tagAnchor=(null==t?void 0:t.tagAnchor)||null,this.tagOrder=null!=(s=null==t?void 0:t.tagOrder)?s:i,t){const i=t.attr;for(const t in i)if(Object.prototype.hasOwnProperty.call(e,t)&&e[t]!==i[t]){cq.warn(`DATERANGE tag attribute: "${t}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=t;break}e=cO(new pk({}),i,e)}if(this.attr=e,t?(this._startDate=t._startDate,this._cue=t._cue,this._endDate=t._endDate,this._dateAtEnd=t._dateAtEnd):this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){const e=(null==t?void 0:t.endDate)||new Date(this.attr["END-DATE"]);cS(e.getTime())&&(this._endDate=e)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get cue(){let e=this._cue;return void 0===e?this._cue=this.attr.enumeratedStringList(this.attr.CUE?"CUE":"X-CUE",{pre:!1,post:!1,once:!1}):e}get startTime(){let{tagAnchor:e}=this;return null===e||null===e.programDateTime?(cq.warn(`Expected tagAnchor Fragment with PDT set for DateRange "${this.id}": ${e}`),NaN):e.start+(this.startDate.getTime()-e.programDateTime)/1e3}get startDate(){return this._startDate}get endDate(){let e=this._endDate||this._dateAtEnd;if(e)return e;let t=this.duration;return null!==t?this._dateAtEnd=new Date(this._startDate.getTime()+1e3*t):null}get duration(){if("DURATION"in this.attr){let e=this.attr.decimalFloatingPoint("DURATION");if(cS(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isInterstitial(){return"com.apple.hls.interstitial"===this.class}get isValid(){return!!this.id&&!this._badValueForSameId&&cS(this.startDate.getTime())&&(null===this.duration||this.duration>=0)&&(!this.endOnNext||!!this.class)&&(!this.attr.CUE||!this.cue.pre&&!this.cue.post||this.cue.pre!==this.cue.post)&&(!this.isInterstitial||"X-ASSET-URI"in this.attr||"X-ASSET-LIST"in this.attr)}}class pA{constructor(e){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.dateRangeTagCount=0,this.live=!0,this.requestScheduled=-1,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.drift
4StartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.appliedTimelineOffset=void 0,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=e}reloaded(e){if(!e){this.advanced=!0,this.updated=!0;return}let t=this.lastPartSn-e.lastPartSn,i=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!i||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||0===t&&i>0,this.updated||this.advanced?this.misses=Math.floor(.6*e.misses):this.misses=e.misses+1}hasKey(e){return this.encryptedFragments.some(t=>{let i=t.decryptdata;return i||(t.setKeyFormat(e.keyFormat),i=t.decryptdata),!!i&&e.matches(i)})}get hasProgramDateTime(){return!!this.fragments.length&&cS(this.fragments[this.fragments.length-1].programDateTime)}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||10}get drift(){let e=this.driftEndTime-this.driftStartTime;return e>0?1e3*(this.driftEnd-this.driftStart)/e:1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){return this.fragments.length?this.fragments[this.fragments.length-1].end:0}get fragmentStart(){return this.fragments.length?this.fragments[0].start:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].index:-1}get maxPartIndex(){let e=this.partList;if(e){let t=this.lastPartIndex;if(-1!==t){for(let i=e.length;i--;)if(e[i].index>t)return e[i].index;return t}}return 0}get lastPartSn(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}get expired(){if(this.live&&this.age&&this.misses<3){let e=this.partEnd-this.fragmentStart;return this.age>Math.max(e,this.totalduration)+this.levelTargetDuration}return!1}}function pR(e,t){return e.length===t.length&&!e.some((e,i)=>e!==t[i])}function pL(e,t){return!e&&!t||!!e&&!!t&&pR(e,t)}function pC(e){return"AES-128"===e||"AES-256"===e||"AES-256-CTR"===e}function pI(e){switch(e){case"AES-128":case"AES-256":return 0;case"AES-256-CTR":return 1;default:throw Error(`invalid full segment method ${e}`)}}function pP(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0))}function pD(e){return Uint8Array.from(unescape(encodeURIComponent(e)),e=>e.charCodeAt(0))}function pM(e){let t=function(e,t,i){let s=e[t];e[t]=e[i],e[i]=s};t(e,0,3),t(e,1,2),t(e,4,5),t(e,6,7)}function p_(e){let t=e.split(":"),i=null;if("data"===t[0]&&2===t.length){let e=t[1].split(";"),s=e[e.length-1].split(",");if(2===s.length){let t="base64"===s[0],r=s[1];if(t)e.splice(-1,1),i=pP(r);else{let e,t;e=pD(r).subarray(0,16),(t=new Uint8Array(16)).set(e,16-e.length),i=t}}}return i}let p$="u">typeof self?self:void 0;var pO="org.w3.clearkey",pN="com.apple.fps",pF="com.microsoft.playready",pB="com.widevine.alpha",pU="org.w3.clearkey",pj="com.apple.streamingkeydelivery",pV="com.microsoft.playready",pG="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function pq(e){switch(e){case pj:return pN;case pV:return pF;case pG:return pB;case pU:return pO}}function pH(e){switch(e){case pN:return pj;case pF:return pV;case pB:return pG;case pO:return pU}}function pK(e){let{drmSystems:t,widevineLicenseUrl:i}=e,s=t?[pN,pB,pF,pO].filter(e=>!!t[e]):[];return!s[pB]&&i&&s.push(pB),s}let pW=null!=p$&&null!=(p=p$.navigator)&&p.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;function pz(e){let t=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2),i=String.fromCharCode.apply(null,Array.from(t)),s=i.substring(i.indexOf("<"),i.length),r=new DOMParser().parseFromString(s,"text/xml").getElementsByTagName("KID")[0];if(r){let e=r.childNodes[0]?r.childNodes[0].nodeValue:r.getAttribute("VALUE");if(e){let t=pP(e).subarray(0,16);return pM(t),t}}return null}let pY={};class pQ{static clearKeyUriToKeyIdMap(){pY={}}static setKeyIdForUri(e,t){pY[e]=t}static addKeyIdForUri(e){let t=Object.keys(pY).length%Number.MAX_SAFE_INTEGER,i=new Uint8Array(16);return new DataView(i.buffer,12,4).setUint32(0,t),pY[e]=i,i}constructor(e,t,i,s=[1],r=null,a){this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pss
4h=null,this.method=e,this.uri=t,this.keyFormat=i,this.keyFormatVersions=s,this.iv=r,this.encrypted=!!e&&"NONE"!==e,this.isCommonEncryption=this.encrypted&&!pC(e),null!=a&&a.startsWith("0x")&&(this.keyId=new Uint8Array(cY(a)))}matches(e){return e.uri===this.uri&&e.method===this.method&&e.encrypted===this.encrypted&&e.keyFormat===this.keyFormat&&pR(e.keyFormatVersions,this.keyFormatVersions)&&pL(e.iv,this.iv)&&pL(e.keyId,this.keyId)}isSupported(){if(this.method){if(pC(this.method)||"NONE"===this.method)return!0;if("identity"===this.keyFormat)return"SAMPLE-AES"===this.method;switch(this.keyFormat){case pj:case pG:case pV:case pU:return -1!==["SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)}}return!1}getDecryptData(e,t){var i,s;if(!this.encrypted||!this.uri)return null;if(pC(this.method)){let t=this.iv;return t||("number"!=typeof e&&(cq.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0),t=function(e){let t=new Uint8Array(16);for(let i=12;i<16;i++)t[i]=e>>8*(15-i)&255;return t}(e)),new pQ(this.method,this.uri,"identity",this.keyFormatVersions,t)}if(this.keyId){let e=pY[this.uri];if(e&&!pR(this.keyId,e)&&pQ.setKeyIdForUri(this.uri,this.keyId),this.pssh)return this}let r=p_(this.uri);if(r)switch(this.keyFormat){case pG:if(this.pssh=r,!this.keyId){let e=function(e){let t=[];if(e instanceof ArrayBuffer){let i=e.byteLength,s=0;for(;s+32<i;){let i=function(e){let t=e.getUint32(0),i=e.byteOffset,s=e.byteLength;if(s<t)return{offset:i,size:s};if(0x70737368!==e.getUint32(4))return{offset:i,size:t};let r=e.getUint32(8)>>>24;if(0!==r&&1!==r)return{offset:i,size:t};let a=e.buffer,n=cz(new Uint8Array(a,i+12,16)),l=null,o=0;if(0===r)o=28;else{let r=e.getUint32(28);if(!r||s<32+16*r)return{offset:i,size:t};l=[];for(let e=0;e<r;e++)l.push(new Uint8Array(a,i+32+16*e,16));o=32+16*r}if(!o)return{offset:i,size:t};let d=e.getUint32(o);return t-32<d?{offset:i,size:t}:{version:r,systemId:n,kids:l,data:new Uint8Array(a,i+o+4,d),offset:i,size:t}}(new DataView(e,s));t.push(i),s+=i.size}}return t}(r.buffer);if(e.length){let t=e[0];this.keyId=null!=(i=t.kids)&&i.length?t.kids[0]:null}}this.keyId||(this.keyId=pX(t));break;case pV:{let e=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=function(e,t){let i,s;if(16!==e.byteLength)throw RangeError("Invalid system id");i=new Uint8Array,s=new Uint8Array;let r=new Uint8Array(4);return t.byteLength>0&&new DataView(r.buffer).setUint32(0,t.byteLength,!1),function(e,...t){let i=t.length,s=8,r=i;for(;r--;)s+=t[r].byteLength;let a=new Uint8Array(s);for(a[0]=s>>24&255,a[1]=s>>16&255,a[2]=s>>8&255,a[3]=255&s,a.set(e,4),r=0,s=8;r<i;r++)a.set(t[r],s),s+=t[r].byteLength;return a}([112,115,115,104],new Uint8Array([0,0,0,0]),e,s,i,r,t)}(e,r),this.keyId=pz(r);break}default:{let e=r.subarray(0,16);if(16!==e.length){let t=new Uint8Array(16);t.set(e,16-e.length),e=t}this.keyId=e}}if(!this.keyId||16!==this.keyId.byteLength){let e,i;!(e=(i=null==(s=t)?void 0:s[pG])?i.keyId:null)&&((e=pX(t))||(e=pY[this.uri])),e&&(this.keyId=e,pQ.setKeyIdForUri(this.uri,e))}return this}}function pX(e){let t=null==e?void 0:e[pV];if(t){let e=p_(t.uri);if(e)return pz(e)}return null}let pJ=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g,pZ=/#EXT-X-MEDIA:(.*)/g,p0=/^#EXT(?:INF|-X-TARGETDURATION):/m,p1=RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#.*/.source].join("|"),"g"),p2=new RegExp([/#EXT-X-(PROGRAM-DATE-TIME|BYTERANGE|DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP|INDEPENDENT-SEGMENTS)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|"));class p5{static findGroup(e,t){for(let i=0;i<e.length;i++){let s=e[i];if(s.id===t)return s}}static resolve(e,t){return cX.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return p0.test(e)}static parseMasterPlaylist(e,t){var i;let s,r={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:pb.test(e)},a=[];if(pJ.lastIndex=0,!e.startsWith("#EXTM3U"))return r.playlistParsingError=Error("no EXTM3U delimiter"),r;for(;null!=(s=pJ.exec(e));)if(s[1]){let e=new pk(s[1],r),n=pE(r,s[2]),l={attrs:e,bitrate:e.decimalInteger("BANDWIDTH")||e.decimalInteger("AVERAGE-BANDWIDTH"),name:e.NAME,url:p5.resolve(n,t)},o=e.decimalResolution("RESOLUTION");o&&(l.width=o.width,l.height=o.height),p6(e.CODECS,l);let d=e["SUPPLEMENTAL-CODECS"];d&&(l.supplemental={},p6(d,l.supplemental)),null!=(i=l.unknownCodecs)&&i.length||a.push(l),r.levels.push(l)}else if(s[3]){let e=s[3],i=s[4];switch(e){case"SESSION-DATA":{let e=new pk(i,r),t=e["DATA-ID"];t&&(null===r.sessionData&&(r.sessionData={}),r.sessionData[t]=e);break}case"SESSION-KEY":{let e=p4(i,t,r);e.encrypted&&e.isSupported()?(null===r.sessionKeys&&(r.sessionKeys=[]),r.sessionKeys.push(e)):cq.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${i}"`);break}case"DEFINE":{let e=new pk(i,r);pS(r,e,t)}break;case"CONTENT-STEERING":{let e=new pk(i,r);r.contentSteering={uri:p5.resolve(e["SERVER-URI"],t),pathwayId:e["PATHWAY-ID"]||"."};break}case"START":r.startTimeOffset=p8(i)}}let n=a.length>0&&a.length<r.levels.length;return r.levels=n?a:r.levels,0===r.levels.length&&(r.playlistParsingError=Error("no levels found in manifest")),r}static parseMasterPlaylistMedia(e,t,i){let s,r={},a=i.levels,n={AUDIO:a.map(e=>({id:e.attrs.AUDIO,audioCodec:e.audioCodec})),SUBTITLES:a.map(e=>({id:e.attrs.SUBTITLES,textCodec:e.textCodec})),"CLOSED-CAPTIONS":[]},l=0;for(pZ.lastIndex=0;null!==(s=pZ.exec(e));){let e=new pk(s[1],i),a=e.TYPE;if(a){let i=n[a],s=r[a]||[];r[a]=s;let o=e.LANGUAGE,d=e["ASSOC-LANGUAGE"],h=e.CHANNELS,u=e.CHARACTERISTICS,c=e["INSTREAM-ID"],f={attrs:e,bitrate:0,id:l++,groupId:e["GROUP-ID"]||"",name:e.NAME||o||"",type:a,default:e.bool("DEFAULT"),autoselect:e.bool("AUTOSELECT"),forced:e.bool("FORCED"),lang:o,url:e.URI?p5.resolve(e.URI,t):""};if(d&&(f.assocLang=d),h&&(f.channels=h),u&&(f.characteristics=u),c&&(f.instreamId=c),null!=i&&i.length){let e=p5.findGroup(i,f.groupId)||i[0];p7(f,e,"audioCodec"),p7(f,e,"textCodec")}s.push(f)}}return r}static parseLevelPlaylist(e,t,i,s,r,a){var n;let l,o,d,h,u={url:t},c=new pA(t),f=c.fragments,p=[],m=null,g=0,y=0,v=0,b=0,E=0,S=null,T=new c3(s,u),x=-1,k=!1,w=null;if(p1.lastIndex=0,c.m3u8=e,c.hasVariableRefs=pb.test(e),(null==(n=p1.exec(e))?void 0:n[0])!=="#EXTM3U")return c.playlistParsingError=Error("Missing format identifier #EXTM3U"),c;for(;null!==(l=p1.exec(e));){k&&(k=!1,(T=new c3(s,u)).playlistOffset=v,T.setStart(v),T.sn=g,T.cc=b,E&&(T.bitrate=E),T.level=i,m&&(T.initSegment=m,m.rawProgramDateTime&&(T.rawProgramDateTime=m.rawProgramDateTime,m.rawProgramDateTime=null),w&&(T.setByteRange(w),w=null)));let e=l[1];if(e){T.duration=parseFloat(e);let t=(" "+l[2]).slice(1);T.title=t||null,T.tagList.push(t?["INF",e,t]:["INF",e])}else if(l[3]){if(cS(T.duration)){T.playlistOffset=v,T.setStart(v),d&&mt(T,d,c),T.sn=g,T.level=i,T.cc=b,f.push(T);let e=(" "+l[3]).slice(1);T.relurl=pE(c,e),p9(T,S,p),S=T,v+=T.duration,g++,y=0,k=!0}}
4else{if(!(l=l[0].match(p2))){cq.warn("No matches on slow regex match for level playlist!");continue}for(o=1;o<l.length&&void 0===l[o];o++);let e=(" "+l[o]).slice(1),r=(" "+l[o+1]).slice(1),n=l[o+2]?(" "+l[o+2]).slice(1):null;switch(e){case"BYTERANGE":S?T.setByteRange(r,S):T.setByteRange(r);break;case"PROGRAM-DATE-TIME":T.rawProgramDateTime=r,T.tagList.push(["PROGRAM-DATE-TIME",r]),-1===x&&(x=f.length);break;case"PLAYLIST-TYPE":c.type&&mi(c,e,l),c.type=r.toUpperCase();break;case"MEDIA-SEQUENCE":0!==c.startSN?mi(c,e,l):f.length>0&&ms(c,e,l),g=c.startSN=parseInt(r);break;case"SKIP":{c.skippedSegments&&mi(c,e,l);let t=new pk(r,c),i=t.decimalInteger("SKIPPED-SEGMENTS");if(cS(i)){c.skippedSegments+=i;for(let e=i;e--;)f.push(null);g+=i}let s=t.enumeratedString("RECENTLY-REMOVED-DATERANGES");s&&(c.recentlyRemovedDateranges=(c.recentlyRemovedDateranges||[]).concat(s.split("	")));break}case"TARGETDURATION":0!==c.targetduration&&mi(c,e,l),c.targetduration=Math.max(parseInt(r),1);break;case"VERSION":null!==c.version&&mi(c,e,l),c.version=parseInt(r);break;case"INDEPENDENT-SEGMENTS":break;case"ENDLIST":c.live||mi(c,e,l),c.live=!1;break;case"#":(r||n)&&T.tagList.push(n?[r,n]:[r]);break;case"DISCONTINUITY":b++,T.tagList.push(["DIS"]);break;case"GAP":T.gap=!0,T.tagList.push([e]);break;case"BITRATE":T.tagList.push([e,r]),cS(E=1e3*parseInt(r))?T.bitrate=E:E=0;break;case"DATERANGE":{let e=new pk(r,c),t=new pw(e,c.dateRanges[e.ID],c.dateRangeTagCount);c.dateRangeTagCount++,t.isValid||c.skippedSegments?c.dateRanges[t.id]=t:cq.warn(`Ignoring invalid DATERANGE tag: "${r}"`),T.tagList.push(["EXT-X-DATERANGE",r]);break}case"DEFINE":{let e=new pk(r,c);"IMPORT"in e?function(e,t,i){let s=t.IMPORT;if(i&&s in i){let t=e.variableList;t||(e.variableList=t={}),t[s]=i[s]}else e.playlistParsingError||(e.playlistParsingError=Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${s}"`))}(c,e,a):pS(c,e,t)}break;case"DISCONTINUITY-SEQUENCE":0!==c.startCC?mi(c,e,l):f.length>0&&ms(c,e,l),c.startCC=b=parseInt(r);break;case"KEY":{let e=p4(r,t,c);if(e.isSupported()){if("NONE"===e.method){d=void 0;break}d||(d={});let t=d[e.keyFormat];null!=t&&t.matches(e)||(t&&(d=cO({},d)),d[e.keyFormat]=e)}else cq.warn(`[Keys] Ignoring unsupported EXT-X-KEY tag: "${r}"`);break}case"START":c.startTimeOffset=p8(r);break;case"MAP":{let e=new pk(r,c);if(T.duration){let t=new c3(s,u);me(t,e,i,d),m=t,T.initSegment=m,m.rawProgramDateTime&&!T.rawProgramDateTime&&(T.rawProgramDateTime=m.rawProgramDateTime)}else{let t=T.byteRangeEndOffset;if(t){let e=T.byteRangeStartOffset;w=`${t-e}@${e}`}else w=null;me(T,e,i,d),m=T,k=!0}m.cc=b;break}case"SERVER-CONTROL":h&&mi(c,e,l),c.canBlockReload=(h=new pk(r)).bool("CAN-BLOCK-RELOAD"),c.canSkipUntil=h.optionalFloat("CAN-SKIP-UNTIL",0),c.canSkipDateRanges=c.canSkipUntil>0&&h.bool("CAN-SKIP-DATERANGES"),c.partHoldBack=h.optionalFloat("PART-HOLD-BACK",0),c.holdBack=h.optionalFloat("HOLD-BACK",0);break;case"PART-INF":c.partTarget&&mi(c,e,l),c.partTarget=new pk(r).decimalFloatingPoint("PART-TARGET");break;case"PART":{let e=c.partList;e||(e=c.partList=[]);let t=y>0?e[e.length-1]:void 0,i=y++,s=new c4(new pk(r,c),T,u,i,t);e.push(s),T.duration+=s.duration;break}case"PRELOAD-HINT":{let e=new pk(r,c);c.preloadHint=e;break}case"RENDITION-REPORT":{let e=new pk(r,c);c.renditionReports=c.renditionReports||[],c.renditionReports.push(e);break}default:cq.warn(`line parsed but not handled: ${l}`)}}}S&&!S.relurl?(f.pop(),v-=S.duration,c.partList&&(c.fragmentHint=S)):c.partList&&(p9(T,S,p),T.cc=b,c.fragmentHint=T,d&&mt(T,d,c)),c.targetduration||(c.playlistParsingError=Error("Missing Target Duration"));let A=f.length,R=f[0],L=f[A-1];if((v+=c.skippedSegments*c.targetduration)>0&&A&&L){c.averagetargetduration=v/A;let e=L.sn;c.endSN="initSegment"!==e?e:0,c.live||(L.endList=!0),x>0&&(function(e,t){let i=e[t];for(let s=t;s--;){let t=e[s];if(!t)return;t.programDateTime=i.programDateTime-1e3*t.duration,i=t}}(f,x),R&&p.unshift(R))}return c.fragmentHint&&(v+=c.fragmentHint.duration),c.totalduration=v,p.length&&c.dateRangeTagCount&&R&&p3(p,c),c.endCC=b,c}}function p3(e,t){let i=e.length;if(!i)if(!t.hasProgramDateTime)return;else{let s=t.fragments[t.fragments.length-1];e.push(s),i++}
4let s=e[i-1],r=t.live?1/0:t.totalduration,a=Object.keys(t.dateRanges);for(let l=a.length;l--;){let o=t.dateRanges[a[l]],d=o.startDate.getTime();o.tagAnchor=s.ref;for(let s=i;s--;){var n;if((null==(n=e[s])?void 0:n.sn)<t.startSN)break;let i=function(e,t,i,s,r){let a=i[s];if(a){let l=a.programDateTime;if(t>=l||0===s){var n;if(t<=l+1e3*(((null==(n=i[s+1])?void 0:n.start)||r)-a.start)){let r=i[s].sn-e.startSN;if(r<0)return -1;let a=e.fragments;if(a.length>i.length){let n=(i[s+1]||a[a.length-1]).sn-e.startSN;for(let e=n;e>r;e--){let i=a[e].programDateTime;if(t>=i&&t<i+1e3*a[e].duration)return e}}return r}}}return -1}(t,d,e,s,r);if(-1!==i){o.tagAnchor=t.fragments[i].ref;break}}}}function p4(e,t,i){var s,r;let a=new pk(e,i),n=null!=(s=a.METHOD)?s:"",l=a.URI,o=a.hexadecimalInteger("IV"),d=a.KEYFORMATVERSIONS,h=null!=(r=a.KEYFORMAT)?r:"identity";return l&&a.IV&&!o&&cq.error(`Invalid IV: ${a.IV}`),new pQ(n,l?p5.resolve(l,t):"",h,(d||"1").split("/").map(Number).filter(Number.isFinite),o,a.KEYID)}function p8(e){let t=new pk(e).decimalFloatingPoint("TIME-OFFSET");return cS(t)?t:null}function p6(e,t){let i=(e||"").split(/[ ,]+/).filter(e=>e);["video","audio","text"].forEach(e=>{let s=i.filter(t=>fy(t,e));s.length&&(t[`${e}Codec`]=s.map(e=>e.split("/")[0]).join(","),i=i.filter(e=>-1===s.indexOf(e)))}),t.unknownCodecs=i}function p7(e,t,i){let s=t[i];s&&(e[i]=s)}function p9(e,t,i){e.rawProgramDateTime?i.push(e):null!=t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime)}function me(e,t,i,s){e.relurl=t.URI,t.BYTERANGE&&e.setByteRange(t.BYTERANGE),e.level=i,e.sn="initSegment",s&&(e.levelkeys=s),e.initSegment=null}function mt(e,t,i){e.levelkeys=t;let{encryptedFragments:s}=i;(!s.length||s[s.length-1].levelkeys!==t)&&Object.keys(t).some(e=>t[e].isCommonEncryption)&&s.push(e)}function mi(e,t,i){e.playlistParsingError=Error(`#EXT-X-${t} must not appear more than once (${i[0]})`)}function ms(e,t,i){e.playlistParsingError=Error(`#EXT-X-${t} must appear before the first Media Segment (${i[0]})`)}function mr(e,t){let i=t.startPTS;if(cS(i)){let s,r=0;t.sn>e.sn?(r=i-e.start,s=e):(r=e.start-i,s=t),s.duration!==r&&s.setDuration(r)}else t.sn>e.sn?e.cc===t.cc&&e.minEndPTS?t.setStart(e.start+(e.minEndPTS-e.start)):t.setStart(e.start+e.duration):t.setStart(Math.max(e.start-t.duration,0))}function ma(e,t,i,s,r,a,n){let l;s-i<=0&&(n.warn("Fragment should have a positive duration",t),s=i+t.duration,a=r+t.duration);let o=i,d=s,h=t.startPTS,u=t.endPTS;if(cS(h)){let l=Math.abs(h-i);e&&l>e.totalduration?n.warn(`media timestamps and playlist times differ by ${l}s for level ${t.level} ${e.url}`):cS(t.deltaPTS)?t.deltaPTS=Math.max(l,t.deltaPTS):t.deltaPTS=l,o=Math.max(i,h),i=Math.min(i,h),r=void 0!==t.startDTS?Math.min(r,t.startDTS):r,d=Math.min(s,u),s=Math.max(s,u),a=void 0!==t.endDTS?Math.max(a,t.endDTS):a}let c=i-t.start;0!==t.start&&t.setStart(i),t.setDuration(s-t.start),t.startPTS=i,t.maxStartPTS=o,t.startDTS=r,t.endPTS=s,t.minEndPTS=d,t.endDTS=a;let f=t.sn;if(!e||f<e.startSN||f>e.endSN)return 0;let p=f-e.startSN,m=e.fragments;for(m[p]=t,l=p;l>0;l--)mr(m[l],m[l-1]);for(l=p;l<m.length-1;l++)mr(m[l],m[l+1]);return e.fragmentHint&&mr(m[m.length-1],e.fragmentHint),e.PTSKnown=e.alignedSliding=!0,c}function mn(e,t,i,s,r){return Error(`${e} ${r.url}
5Playlist starting @${t.startSN}
6${t.m3u8}
7
8Playlist starting @${i.startSN}
9${i.m3u8}`)}function ml(e,t,i=!0){let s=t.startSN+t.skippedSegments-e.startSN,r=e.fragments,a=s>=0,n=0;if(a&&s<r.length)n=r[s].start;else if(a&&t.startSN===e.endSN+1)n=e.fragmentEnd;else if(a&&i)n=e.fragmentStart+s*t.levelTargetDuration;else{if(t.skippedSegments||0!==t.fragmentStart)return;n=e.fragmentStart}mo(t,n)}function mo(e,t){if(t){let i=e.fragments;for(let s=e.skippedSegments;s<i.length;s++)i[s].addStart(t);e.fragmentHint&&e.fragmentHint.addStart(t)}}function md(e,t=1/0){let i=1e3*e.targetduration;if(e.updated){let s=e.fragments;if(s.length&&4*i>t){let e=1e3*s[s.length-1].duration;e<i&&(i=e)}}else i/=2;return Math.round(i)}function mh(e,t,i){if(!e)return null;let s=e.fragments[t-e.startSN];return s||(s=e.fragmentHint)&&s.sn===t?s:t<e.startSN&&i&&i.sn===t?i:null}function mu(e,t,i){return e?mc(e.partList,t,i):null}function mc(e,t,i){if(e)for(let s=e.length;s--;
9){let r=e[s];if(r.index===i&&r.fragment.sn===t)return r}return null}function mf(e){e.forEach((e,t)=>{var i;null==(i=e.details)||i.fragments.forEach(e=>{e.level=t,e.initSegment&&(e.initSegment.level=t)})})}function mp(e){return e.replace(/\?[^?]*$/,"")}function mm(e,t){for(let s=0,r=e.length;s<r;s++){var i;if((null==(i=e[s])?void 0:i.cc)===t)return e[s]}return null}function mg(e,t){let i=e.start+t;e.startPTS=i,e.setStart(i),e.endPTS=i+e.duration}function my(e,t){let i=t.fragments;for(let t=0,s=i.length;t<s;t++)mg(i[t],e);t.fragmentHint&&mg(t.fragmentHint,e),t.alignedSliding=!0}function mv(e,t){if((!t||!(e.startCC<t.endCC)||!(e.endCC>t.startCC))&&1)return;let i=Math.min(t.endCC,e.endCC),s=mm(t.fragments,i),r=mm(e.fragments,i);s&&r&&(cq.log(`Aligning playlist at start of dicontinuity sequence ${i}`),my(s.start-r.start,e))}function mb(e,t){let i,s;if(!e.hasProgramDateTime||!t.hasProgramDateTime)return;let r=e.fragments,a=t.fragments;if(!r.length||!a.length)return;let n=Math.min(t.endCC,e.endCC);t.startCC<n&&e.startCC<n&&(i=mm(a,n),s=mm(r,n)),i&&s||(s=mm(r,(i=a[Math.floor(a.length/2)]).cc)||r[Math.floor(r.length/2)]);let l=i.programDateTime,o=s.programDateTime;l&&o&&my((o-l)/1e3-(s.start-i.start),e)}function mE(e,t,i){mS(e,t,i),e.addEventListener(t,i)}function mS(e,t,i){e.removeEventListener(t,i)}let mT=function(e){let t="",i=e.length;for(let s=0;s<i;s++)t+=`[${e.start(s).toFixed(3)}-${e.end(s).toFixed(3)}]`;return t},mx="STOPPED",mk="IDLE",mw="KEY_LOADING",mA="FRAG_LOADING",mR="FRAG_LOADING_WAITING_RETRY",mL="WAITING_TRACK",mC="PARSING",mI="PARSED",mP="ENDED",mD="ERROR",mM="WAITING_INIT_PTS",m_="WAITING_LEVEL";class m$ extends pp{constructor(e,t,i,s,r){super(s,e.logger),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=mx,this.playlistType=void 0,this.media=null,this.mediaBuffer=null,this.config=void 0,this.bitrateTest=!1,this.lastCurrentTime=0,this.nextLoadPosition=0,this.startPosition=0,this.startTimeOffset=null,this.retryDate=0,this.levels=null,this.fragmentLoader=void 0,this.keyLoader=void 0,this.levelLastLoaded=null,this.startFragRequested=!1,this.decrypter=void 0,this.initPTS=[],this.buffering=!0,this.loadingParts=!1,this.loopSn=void 0,this.onMediaSeeking=()=>{let{config:e,fragCurrent:t,media:i,mediaBuffer:s,state:r}=this,a=i?i.currentTime:0,n=pv.bufferInfo(s||i,a,e.maxBufferHole),l=!n.len;if(this.log(`Media seeking to ${cS(a)?a.toFixed(3):a}, state: ${r}, ${l?"out of":"in"} buffer`),this.state===mP)this.resetLoadingState();else if(t){let i=e.maxFragLookUpTolerance,s=t.start-i,r=t.start+t.duration+i;if(l||r<n.start||s>n.end){let e=a>r;(a<s||e)&&(e&&t.loader&&(this.log(`Cancelling fragment load for seek (sn: ${t.sn})`),t.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}if(i&&(this.fragmentTracker.removeFragmentsInRange(a,1/0,this.playlistType,!0),a>this.lastCurrentTime&&(this.lastCurrentTime=a),!this.loadingParts)){let e=Math.max(n.end,a),t=this.shouldLoadParts(this.getLevelDetails(),e);t&&(this.log(`LL-Part loading ON after seeking to ${a.toFixed(2)} with buffer @${e.toFixed(2)}`),this.loadingParts=t)}!this.hls.hasEnoughToStart&&(this.log(`Setting ${l?"startPosition":"nextLoadPosition"} to ${a} for seek without enough to start`),this.nextLoadPosition=a,l&&(this.startPosition=a)),l&&this.state===mk&&this.tickImmediate()},this.onMediaEnded=()=>{this.log("setting startPosition to 0 because media ended"),this.startPosition=this.lastCurrentTime=0},this.playlistType=r,this.hls=e,this.fragmentLoader=new ph(e.config),this.keyLoader=i,this.fragmentTracker=t,this.config=e.config,this.decrypter=new pd(e.config)}registerListeners(){let{hls:e}=this;
9e.on(cA.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(cA.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(cA.MANIFEST_LOADING,this.onManifestLoading,this),e.on(cA.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(cA.ERROR,this.onError,this)}unregisterListeners(){let{hls:e}=this;e.off(cA.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(cA.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(cA.MANIFEST_LOADING,this.onManifestLoading,this),e.off(cA.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(cA.ERROR,this.onError,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(e){}stopLoad(){if(this.state===mx)return;this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);let e=this.fragCurrent;null!=e&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=mx}get startPositionValue(){let{nextLoadPosition:e,startPosition:t}=this;return -1===t&&e?e:t}get bufferingEnabled(){return this.buffering}pauseBuffering(){this.buffering=!1}resumeBuffering(){this.buffering=!0}get inFlightFrag(){return{frag:this.fragCurrent,state:this.state}}_streamEnded(e,t){if(t.live||!this.media)return!1;let i=e.end||0,s=this.config.timelineOffset||0;if(i<=s)return!1;let r=e.buffered;this.config.maxBufferHole&&r&&r.length>1&&(e=pv.bufferedInfo(r,e.start,0));let a=e.nextStart;if(a&&a>s&&a<t.edge||this.media.currentTime<e.start)return!1;let n=t.partList;if(null!=n&&n.length){let e=n[n.length-1];return pv.isBuffered(this.media,e.start+e.duration/2)}let l=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(l)}getLevelDetails(){if(this.levels&&null!==this.levelLastLoaded)return this.levelLastLoaded.details}get timelineOffset(){let e=this.config.timelineOffset;if(e){var t;return(null==(t=this.getLevelDetails())?void 0:t.appliedTimelineOffset)||e}return 0}onMediaAttached(e,t){let i=this.media=this.mediaBuffer=t.media;mE(i,"seeking",this.onMediaSeeking),mE(i,"ended",this.onMediaEnded);let s=this.config;this.levels&&s.autoStartLoad&&this.state===mx&&this.startLoad(s.startPosition)}onMediaDetaching(e,t){let i=!!t.transferMedia,s=this.media;if(null!==s){if(s.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),mS(s,"seeking",this.onMediaSeeking),mS(s,"ended",this.onMediaEnded),this.keyLoader&&!i&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loopSn=void 0,i){this.resetLoadingState(),this.resetTransmuxer();return}this.loadingParts=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}}onManifestLoading(){this.initPTS=[],this.levels=this.levelLastLoaded=this.fragCurrent=null,this.lastCurrentTime=this.startPosition=0,this.startFragRequested=!1}onError(e,t){}onManifestLoaded(e,t){this.startTimeOffset=t.startTimeOffset}onHandlerDestroying(){this.stopLoad(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),super.onHandlerDestroying(),this.hls=this.onMediaSeeking=this.onMediaEnded=null}onHandlerDestroyed(){this.state=mx,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,super.onHandlerDestroyed()}loadFragment(e,t,i){this.startFragRequested=!0,this._loadFragForPlayback(e,t,i)}_loadFragForPlayback(e,t,i){let s=e=>{let t=e.frag;if(this.fragContextChanged(t)){this.warn(`${t.type} sn: ${t.sn}${e.part?" part: "+e.part.index:""} of ${this.fragInfo(t,!1,e.part)}) was dropped during download.`),this.fragmentTracker.removeFragment(t);return}t.stats.chunkCount++,this._handleFragmentLoadProgress(e)};this._doFragLoad(e,t,i,s).then(e=>{if(!e)return;let t=this.state,i=e.frag;if(this.fragContextChanged(i)){t!==mA&&(this.fragCurrent||t!==mC)||(this.fragmentTracker.removeFragment(i),this.state=mk);return}"payload"in e&&(this.log(`Loaded ${i.type} sn: ${i.sn} of ${this.playlistLabel()} ${i.level}`),this.hls.trigger(cA.FRAG_LOADED,e)),this._handleFragmentLoadComplete(e)}).catch(t=>{this.state!==mx&&this.state!==mD&&(this.warn(`Frag error: ${(null==t?void 0:t.message)||t}`),this.resetFragmentLoading(e))})}clearTrackerIfNeeded(e){var t;let{fragmentTracker:i}=this;
9if(i.getState(e)===pe){let t=e.type,s=this.getFwdBufferInfo(this.mediaBuffer,t),r=Math.max(e.duration,s?s.len:this.config.maxBufferLength),a=this.backtrackFragment;(1==(a?e.sn-a.sn:0)||this.reduceMaxBufferLength(r,e.duration))&&i.removeFragment(e)}else(null==(t=this.mediaBuffer)?void 0:t.buffered.length)===0?i.removeAllFragments():i.hasParts(e.type)&&(i.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),i.getState(e)===pt&&i.removeFragment(e))}checkLiveUpdate(e){if(e.updated&&!e.live){let t=e.fragments[e.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type})}e.fragments[0]||(e.deltaUpdateFailed=!0)}waitForLive(e){let t=e.details;return(null==t?void 0:t.live)&&"EVENT"!==t.type&&(this.levelLastLoaded!==e||t.expired)}flushMainBuffer(e,t,i=null){e-t&&this.hls.trigger(cA.BUFFER_FLUSHING,{startOffset:e,endOffset:t,type:i})}_loadInitSegment(e,t){this._doFragLoad(e,t).then(e=>{let t=null==e?void 0:e.frag;if(!t||this.fragContextChanged(t)||!this.levels)throw Error("init load aborted");return e}).then(e=>{let{hls:t}=this,{frag:i,payload:s}=e,r=i.decryptdata;if(s&&s.byteLength>0&&null!=r&&r.key&&r.iv&&pC(r.method)){let a=self.performance.now();return this.decrypter.decrypt(new Uint8Array(s),r.key.buffer,r.iv.buffer,pI(r.method)).catch(e=>{throw t.trigger(cA.ERROR,{type:ck.MEDIA_ERROR,details:cw.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:i}),e}).then(s=>{let r=self.performance.now();return t.trigger(cA.FRAG_DECRYPTED,{frag:i,payload:s,stats:{tstart:a,tdecrypt:r}}),e.payload=s,this.completeInitSegmentLoad(e)})}return this.completeInitSegmentLoad(e)}).catch(t=>{this.state!==mx&&this.state!==mD&&(this.warn(t),this.resetFragmentLoading(e))})}completeInitSegmentLoad(e){let{levels:t}=this;if(!t)throw Error("init load aborted, missing levels");let i=e.frag.stats;this.state!==mx&&(this.state=mk),e.frag.data=new Uint8Array(e.payload),i.parsing.start=i.buffering.start=self.performance.now(),i.parsing.end=i.buffering.end=self.performance.now(),this.tick()}unhandledEncryptionError(e,t){var i,s;let r=e.tracks;if(r&&!t.encrypted&&(null!=(i=r.audio)&&i.encrypted||null!=(s=r.video)&&s.encrypted)&&(!this.config.emeEnabled||!this.keyLoader.emeController)){let e=this.media,i=Error(`Encrypted track with no key in ${this.fragInfo(t)} (media ${e?"attached mediaKeys: "+e.mediaKeys:"detached"})`);return this.warn(i.message),!!e&&!e.mediaKeys&&(this.hls.trigger(cA.ERROR,{type:ck.KEY_SYSTEM_ERROR,details:cw.KEY_SYSTEM_NO_KEYS,fatal:!1,error:i,frag:t}),this.resetTransmuxer(),!0)}return!1}fragContextChanged(e){let{fragCurrent:t}=this;return!e||!t||e.sn!==t.sn||e.level!==t.level}fragBufferedComplete(e,t){let i=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log(`Buffered ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,!1,t)} > buffer:${i?mT(pv.getBuffered(i)):"(detached)"})`),c5(e)){var s;if(e.type!==cM){let t=e.elementaryStreams;if(!Object.keys(t).some(e=>!!t[e])){this.state=mk;return}}let t=null==(s=this.levels)?void 0:s[e.level];null!=t&&t.fragmentError&&(this.log(`Resetting level fragment error count of ${t.fragmentError} on frag buffered`),t.fragmentError=0)}this.state=mk}_handleFragmentLoadComplete(e){let{transmuxer:t}=this;if(!t)return;let{frag:i,part:s,partsLoaded:r}=e,a=!r||0===r.length||r.some(e=>!e),n=new pm(i.level,i.sn,i.stats.chunkCount+1,0,s?s.index:-1,!a);t.flush(n)}_handleFragmentLoadProgress(e){}_doFragLoad(e,t,i=null,s){var r,a;let n;this.fragCurrent=e;let l=t.details;if(!this.levels||!l)throw Error(`frag load aborted, missing level${l?"":" detail"}s`);let o=null;if(e.encrypted&&!(null!=(r=e.decryptdata)&&r.key)){if(this.log(`Loading key for ${e.sn} of [${l.startSN}-${l.endSN}], ${this.playlistLabel()} ${e.level}`),this.state=mw,this.fragCurrent=e,o=this.keyLoader.load(e).then(e=>{if(!this.fragContextChanged(e.frag))return this.hls.trigger(cA.KEY_LOADED,e),this.state===mw&&(this.state=mk),e}),this.hls.trigger(cA.KEY_LOADING,{frag:e}),null===this.fragCurrent)return this.log("context changed in KEY_LOADING"),Promise.resolve(null)}else!e.encrypted&&(o=this.keyLoader.loadClear(e,l.encryptedFragments,this.startFragRequested))&&this.log("[eme] blocking frag load until media-keys acquired");let d=this.fragPrevious;if(c5(e)&&(!d||e.sn!==d.sn)){let i=this.shouldLoadParts(t.details,e.end);i!==this.loadingParts&&(this.log(`LL-Part loading ${i?"ON":"OFF"} loading sn ${null==d?void 0:d.sn}->${e.sn}`),this.loadingParts=i)}if(i=Math.max(e.start,i||0),this.loadingParts&&c5(e)){let r=l.partList;if(r&&s){i>l.fragmentEnd&&l.fragmentHint&&(e=l.fragmentHint);let a=this.getNextPart(r,e,i);if(a>-1){let n,d=r[a];return(e=this.fragCurrent=d.fragment,this.log(`Loading ${e.type} sn: ${e.sn} part: ${d.index} (${a}/${r.length-1}) of ${this.fragInfo(e,!1,d)}) cc: ${e.cc} [${l.startSN}-${l.endSN}], target: ${parseFloat(i.toFixed(3))}`),this.nextLoadPosition=d.start+d.duration,this.state=mA,n=o?o.then(i=>!i||this.fragContextChanged(i.frag)?null:this.doFragPartsLoad(e,d,t,s)).catch(e=>this.handleFragLoadError(e)):this.doFragPartsLoad(e,d,t,s).catch(e=>this.handleFragLoadError(e)),this.hls.trigger(cA.FRAG_LOADING,{frag:e,part:d,targetBufferTime:i}),null===this.fragCurrent)?Promise.reject(Error("frag load aborted, context changed in FRAG_LOADING parts")):n}if(!e.url||this.loadedEndOfParts(r,i))return Promise.resolve(null)}}if(c5(e)&&this.loadingParts)this.log(`LL-Part loading OFF after next part miss @${i.toFixed(2)} Check buffer at sn: ${e.sn} loaded parts: ${null==(a=l.partList)?void 0:a.filter(e=>e.loaded).map(e=>`[${e.start}-${e.end}]`)}`),this.loadingParts=!1;else if(!e.url)return Promise.resolve(null);this.log(`Loading ${e.type} sn: ${e.sn} of ${this.fragInfo(e,!1)}) cc: ${e.cc} ${"["+l.startSN+"-"+l.endSN+"]"}, target: ${parseFloat(i.toFixed(3))}`),cS(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=mA;let h=this.config.progressive&&e.type!==cM;return(n=h&&o?o.then(t=>!t||this.fragContextChanged(t.frag)?null:this.fragmentLoader.load(e,s)).catch(e=>this.handleFragLoadError(e)):Promise.all([this.fragmentLoader.load(e,h?s:void 0),o]).then(([e])=>(!h&&s&&s(e),e)).catch(e=>this.handleFragLoadError(e)),this.hls.trigger(cA.FRAG_LOADING,{frag:e,targetBufferTime:i}),null===this.fragCurrent)?Promise.reject(Error("frag load aborted, context changed in FRAG_LOADING")):n}doFragPartsLoad(e,t,i,s){return new Promise((r,a)=>{var n;let l=[],o=null==(n=i.details)?void 0:n.partList,d=t=>{this.fragmentLoader.loadPart(e,t,s).then(s=>{l[t.index]=s;let a=s.part;this.hls.trigger(cA.FRAG_LOADED,s);let n=mu(i.details,e.sn,t.index+1)||mc(o,e.sn,t.index+1);if(!n)return r({frag:e,part:a,partsLoaded:l});d(n)}).catch(a)};d(t)})}handleFragLoadError(e){if("data"in e){let t=e.data;t.frag&&t.details===cw.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):t.frag&&t.type===ck.KEY_SYSTEM_ERROR?(t.frag.abortRequests(),this.resetStartWhenNotLoaded(),this.resetFragmentLoading(t.frag)):this.hls.trigger(cA.ERROR,t)}else this.hls.trigger(cA.ERROR,{type:ck.OTHER_ERROR,details:cw.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){let t=this.getCurrentContext(e);if(!t||this.state!==mC){this.fragCurrent||this.state===mx||this.state===mD||(this.state=mk);return}let{frag:i,part:s,level:r}=t,a=self.performance.now();i.stats.parsing.end=a,s&&(s.stats.parsing.end=a);let n=this.getLevelDetails(),l=n&&i.sn>n.endSN||this.shouldLoadParts(n,i.end);l!==this.loadingParts&&(this.log(`LL-Part loading ${l?"ON":"OFF"} after parsing segment ending @${i.end.toFixed(2)}`),this.loadingParts=l),this.updateLevelTiming(i,s,r,e.partial)}shouldLoadParts(e,t){if(this.config.lowLatencyMode){if(!e)return this.loadingParts;if(e.partList){var i,s;let r=e.partList[0];if(r.fragment.type===cM)return!1;if(t>=r.end+((null==(i=e.fragmentHint)?void 0:i.duration)||0)&&(this.hls.hasEnoughToStart?(null==(s=this.media)?void 0:s.currentTime)||this.lastCurrentTime:this.getLoadPosition())>r.start-r.fragment.duration)return!0}}return!1}getCurrentContext(e){let{levels:t,fragCurrent:i}=this,{level:s,sn:r,part:a}=e;if(!(null!=t&&t[s]))return this.warn(`Levels object was unset while buffering fragment ${r} of ${this.playlistLabel()} ${s}. The current chunk will not be buffered.`),null;let n=t[s],l=n.details,o=a>-1?mu(l,r,a):null,d=o?o.fragment:mh(l,r,i);return d?(i&&i!==d&&(d.stats=i.stats),{frag:d,part:o,level:n}):null}bufferFragmentData(e,t,i,s,r){if(this.state!==mC)return;let{data1:a,data2:n}=e,l=a;if(n&&(l=fu(a,n)),!l.length)return;let o=this.initPTS[t.cc],d=o?-o.baseTime/o.timescale:void 0,h={type:e.type,frag:t,part:i,chunkMeta:s,offset:d,parent:t.type,data:l};if(this.hls.trigger(cA.BUFFER_APPENDING,h),e.dropped&&e.independent&&!i){if(r)return;this.flushBufferGap(t)}}flushBufferGap(e){let t=this.media;if(!t)return;if(!pv.isBuffered(t,t.currentTime))return void this.flushMainBuffer(0,e.start);let i=t.currentTime,s=pv.bufferInfo(t,i,0),r=e.duration,a=Math.min(2*this.config.maxFragLookUpTolerance,.25*r),n=Math.max(Math.min(e.start-a,s.end-a),i+a);e.start-n>a&&this.flushMainBuffer(n,e.start)}getFwdBufferInfo(e,t){var i;let s=this.getLoadPosition();if(!cS(s))return null;let r=this.lastCurrentTime>s||null!=(i=this.media)&&i.paused?0:this.config.maxBufferHole;return this.getFwdBufferInfoAtPos(e,s,t,r)}getFwdBufferInfoAtPos(e,t,i,s){let r=pv.bufferInfo(e,t,s);if(0===r.len&&void 0!==r.nextStart){let a=this.fragmentTracker.getBufferedFrag(t,i);if(a&&(r.nextStart<=a.end||a.gap)){let i=Math.max(Math.min(r.nextStart,a.end)-t,s);return pv.bufferInfo(e,t,i)}}return r}
9getMaxBufferLength(e){let{config:t}=this;return Math.min(e?Math.max(8*t.maxBufferSize/e,t.maxBufferLength):t.maxBufferLength,t.maxMaxBufferLength)}exceedsMaxBuffer(e,t,i){let s=e.nextStart;if(s&&i.start>s){let s=e.buffered;if(s){let r=e.len,a=e.bufferedIndex;for(let e=s.length-1;e>a;e--)s[e].start<i.start&&(r+=s[e].end-s[e].start);return r>=t}}return!1}reduceMaxBufferLength(e,t){let i=this.config,s=Math.max(Math.min(e-t,i.maxBufferLength),t),r=Math.max(e-3*t,i.maxMaxBufferLength/2,s);return r>=s&&(i.maxMaxBufferLength=r,this.warn(`Reduce max buffer length to ${r}s`),!0)}getAppendedFrag(e,t=cP){let i=this.fragmentTracker?this.fragmentTracker.getAppendedFrag(e,t):null;return i&&"fragment"in i?i.fragment:i}getNextFragment(e,t){let i=t.fragments,s=i.length;if(!s)return null;let{config:r}=this,a=t.fragmentStart,n=r.lowLatencyMode&&!!t.partList,l=null;if(t.live){let i=r.initialLiveManifestSize;if(s<i)return this.warn(`Not enough fragments to start playback (have: ${s}, need: ${i})`),null;if(!t.PTSKnown&&!this.startFragRequested&&-1===this.startPosition||e<a){var o;let i,s;n&&!this.loadingParts&&(this.log("LL-Part loading ON for initial live fragment"),this.loadingParts=!0),l=this.getInitialLiveFragment(t);let r=this.config.startPosition,d=this.hls.startPosition,h=this.hls.liveSyncPosition,u=(null==(o=l)?void 0:o.start)||0;-1!==d&&d>=a?(i=d,s=d===r?"config":"next load start"):null!==h?(i=h,s="live edge"):(i=e,s="buffer pos"),i<u&&(i=u,s="live frag start"),i<a&&(i=a,s="playlist start"),(this.startPosition!=i||this.nextLoadPosition!=i)&&(this.log(`Setting startPosition to ${i.toFixed(3)} ${-1===d?"":`(from ${r}) `}based on ${s}. live edge: ${h} live frag start: ${u.toFixed(3)} playlist start: ${a.toFixed(3)} buffer pos: ${e}`),this.startPosition=this.nextLoadPosition=i)}}else e<=a&&(l=i[0]);if(!l){let i=this.loadingParts?t.partEnd:t.fragmentEnd;l=this.getFragmentAtPosition(e,i,t)}let d=this.filterReplacedPrimary(l,t);if(!d&&l){let e=l.sn-t.startSN;d=this.filterReplacedPrimary(i[e+1]||null,t)}return this.mapToInitFragWhenRequired(d)}isLoopLoading(e,t){if(this.nextLoadPosition<=t)return!1;let i=this.fragmentTracker.getState(e);return"OK"===i||i===pt&&!!e.gap}getNextFragmentLoopLoading(e,t,i,s,r){let a=null;if(e.gap&&(a=this.getNextFragment(this.nextLoadPosition,t))&&!a.gap&&i.nextStart){let e=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,i.nextStart,s,0);if(null!==e&&i.len+e.len>=r){let e=a.sn;return this.loopSn!==e&&(this.log(`buffer full after gaps in "${s}" playlist starting at sn: ${e}`),this.loopSn=e),null}}return this.loopSn=void 0,a}get primaryPrefetch(){if(mO(this.config)){var e;if(null==(e=this.hls.interstitialsManager)||null==(e=e.playingItem)?void 0:e.event)return!0}return!1}filterReplacedPrimary(e,t){if(!e)return e;if(mO(this.config)&&e.type!==cM){let i=this.hls.interstitialsManager,s=null==i?void 0:i.bufferingItem;if(s){let i=s.event;if(i){if(i.appendInPlace||Math.abs(e.start-s.start)>1||0===s.start)return null}else if(e.end<=s.start&&(null==t?void 0:t.live)===!1||e.start>s.end&&s.nextEvent&&(s.nextEvent.appendInPlace||e.start-s.end>1))return null}let r=null==i?void 0:i.playerQueue;if(r)for(let t=r.length;t--;){let i=r[t].interstitial;if(i.appendInPlace&&e.start>=i.startTime&&e.end<=i.resumeTime)return null}}return e}mapToInitFragWhenRequired(e){return null==e||!e.initSegment||e.initSegment.data||this.bitrateTest?e:e.initSegment}getNextPart(e,t,i){let s=-1,r=!1,a=!0;for(let n=0,l=e.length;n<l;n++){let l=e[n];if(a=a&&!l.independent,s>-1&&i<l.start)break;let o=l.loaded;o?s=-1:(r||(l.independent||a)&&l.fragment===t)&&(l.fragment!==t&&this.warn(`Need buffer at ${i} but next unloaded part starts at ${l.start}`),s=n),r=o}return s}loadedEndOfParts(e,t){let i;for(let s=e.length;s--&&(i=e[s]).loaded;)if(t>i.start)return!0;return!1}getInitialLiveFragment(e){let t=e.fragments,i=this.fragPrevious,s=null;if(i){if(e.hasProgramDateTime&&(s=function(e,t,i){if(null===t||!Array.isArray(e)||!e.length||!cS(t)||t<(e[0].programDateTime||0)||t>=(e[e.length-1].endProgramDateTime||0))return null;for(let s=0;s<e.length;
9++s){let r=e[s];if(function(e,t,i){let s=1e3*Math.min(t,i.duration+(i.deltaPTS?i.deltaPTS:0));return(i.endProgramDateTime||0)-s>e}(t,i,r))return r}return null}(t,i.endProgramDateTime,this.config.maxFragLookUpTolerance))&&this.log(`Live playlist, switching playlist, load frag with same PDT: ${i.programDateTime}`),!s){let r=i.sn+1;if(r>=e.startSN&&r<=e.endSN){let a=t[r-e.startSN];i.cc===a.cc&&(s=a,this.log(`Live playlist, switching playlist, load frag with next SN: ${s.sn}`))}!s&&(s=fZ(e,i.cc,i.end))&&this.log(`Live playlist, switching playlist, load frag with same CC: ${s.sn}`)}}else{let t=this.hls.liveSyncPosition;null!==t&&(s=this.getFragmentAtPosition(t,this.bitrateTest?e.fragmentEnd:e.edge,e))}return s}getFragmentAtPosition(e,t,i){let s,{config:r}=this,{fragPrevious:a}=this,{fragments:n,endSN:l}=i,{fragmentHint:o}=i,{maxFragLookUpTolerance:d}=r,h=i.partList,u=!!(this.loadingParts&&null!=h&&h.length&&o);if(u&&!this.bitrateTest&&h[h.length-1].fragment.sn===o.sn&&(n=n.concat(o),l=o.sn),e<t){var c;let i=e<this.lastCurrentTime||e>t-d||null!=(c=this.media)&&c.paused||!this.startFragRequested?0:d;s=fX(a,n,e,i)}else s=n[n.length-1];if(s){let e=s.sn-i.startSN,t=this.fragmentTracker.getState(s);if(("OK"===t||t===pt&&s.gap)&&(a=s),a&&s.sn===a.sn&&(!u||h[0].fragment.sn>s.sn||!i.live)&&s.level===a.level){let t=n[e+1];s=s.sn<l&&"OK"!==this.fragmentTracker.getState(t)?t:null}}return s}alignPlaylists(e,t,i){let s=e.fragments.length;if(!s)return this.warn("No fragments in live playlist"),0;let r=e.fragmentStart,a=!t,n=e.alignedSliding&&cS(r);if(a||!n&&!r){i&&(mv(e,i),e.alignedSliding||mb(e,i),e.alignedSliding||e.skippedSegments||ml(i,e,!1));let r=e.fragmentStart;return this.log(`Live playlist sliding: ${r.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${e.startSN} fragments: ${s}`),r}return r}waitForCdnTuneIn(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,3*e.partTarget)}setStartPosition(e,t){let i=this.startPosition;i<t&&(i=-1);let s=this.timelineOffset;if(-1===i){let r=null!==this.startTimeOffset,a=r?this.startTimeOffset:e.startTimeOffset;null!==a&&cS(a)?(i=t+a,a<0&&(i+=e.edge),i=Math.min(Math.max(t,i),t+e.totalduration),this.log(`Setting startPosition to ${i} for start time offset ${a} found in ${r?"multivariant":"media"} playlist`),this.startPosition=i):e.live?(i=this.hls.liveSyncPosition||t,this.log(`Setting startPosition to -1 to start at live edge ${i}`),this.startPosition=-1):(this.log("setting startPosition to 0 by default"),this.startPosition=i=0),this.lastCurrentTime=i+s}this.nextLoadPosition=i+s}getLoadPosition(){var e;let{media:t}=this,i=0;return null!=(e=this.hls)&&e.hasEnoughToStart&&t?i=t.currentTime:this.nextLoadPosition>=0&&(i=this.nextLoadPosition),i}handleFragLoadAborted(e,t){this.transmuxer&&e.type===this.playlistType&&c5(e)&&e.stats.aborted&&(this.log(`Fragment ${e.sn}${t?" part "+t.index:""} of ${this.playlistLabel()} ${e.level} was aborted`),this.resetFragmentLoading(e))}resetFragmentLoading(e){this.fragCurrent&&(this.fragContextChanged(e)||this.state===mR)||(this.state=mk)}onFragmentOrKeyLoadError(e,t){var i,s,r;if(t.chunkMeta&&!t.frag){let e=this.getCurrentContext(t.chunkMeta);e&&(t.frag=e.frag)}let a=t.frag;if(!a||a.type!==e||!this.levels)return;if(this.fragContextChanged(a))return void this.warn(`Frag load error must match current frag to retry ${a.url} > ${null==(s=this.fragCurrent)?void 0:s.url}`);let n=t.details===cw.FRAG_GAP;n&&this.fragmentTracker.fragBuffered(a,!0);let l=t.errorAction;if(!l){this.state=mD;return}let{action:o,flags:d,retryCount:h=0,retryConfig:u}=l,c=!!u,f=c&&5===o,p=c&&!l.resolved&&1===d,m=null==(i=this.hls.latestLevelDetails)?void 0:i.live;if(!f&&p&&c5(a)&&!a.endList&&m&&!f2(t))this.resetFragmentErrors(e),this.treatAsGap(a),l.resolved=!0;else if((f||p)&&h<u.maxNumRetry){let i=f6(null==(r=t.response)?void 0:r.code),s=f3(u,h);if(this.resetStartWhenNotLoaded(),this.retryDate=self.performance.now()+s,this.state=mR,l.resolved=!0,i){this.log("Waiting for connection (offline)"),this.retryDate=1/0,t.reason="offline";return}this.warn(`Fragment ${a.sn} of ${e} ${a.level} errored with ${t.details}, retrying loading ${h+1}/${u.maxNumRetry} in ${s}ms`)}else if(u){if(this.resetFragmentErrors(e),!(h<u.maxNumRetry))return void this.warn(`${t.details} reached or exceeded max retry (${h})`);n||3===o||(l.resolved=!0)}else 2===o?this.state=m_:this.state=mD;this.tickImmediate()}checkRetryDate(){let e=self.performance.now(),t=this.retryDate,i=t===1/0;(!t||e>=t||i&&!f6(0))&&(i&&this.log("Connection restored (online)"),this.resetStartWhenNotLoaded(),this.state=mk)}reduceLengthAndFlushBuffer(e){if(this.state===mC||this.state===mI){let t=e.frag,i=e.parent,s=this.getFwdBufferInfo(this.mediaBuffer,i),r=s&&s.len>.5;r&&this.reduceMaxBufferLength(s.len,(null==t?void 0:t.duration)||10);let a=!r;return a&&this.warn(`Buffer full error while media.currentTime (${this.getLoadPosition()}) is not buffered, flush ${i} buffer`),t&&(this.fragmentTracker.removeFragment(t),this.nextLoadPosition=t.start),this.resetLoadingState(),a}return!1}resetFragmentErrors(e){e===cD&&(this.fragCurrent=null),this.hls.hasEnoughToStart||(this.startFragRequested=!1),this.state!==mx&&(this.state=mk)}afterBufferFlushed(e,t,i){if(!e)return;let s=pv.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,s,i),this.state===mP&&this.resetLoadingState()}
9resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==mx&&(this.state=mk)}resetStartWhenNotLoaded(){if(!this.hls.hasEnoughToStart){this.startFragRequested=!1;let e=this.levelLastLoaded,t=e?e.details:null;null!=t&&t.live?(this.log("resetting startPosition for live start"),this.startPosition=-1,this.setStartPosition(t,t.fragmentStart),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(e){this.log(`Loading context changed while buffering sn ${e.sn} of ${this.playlistLabel()} ${-1===e.level?"<removed>":e.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(),this.resetLoadingState()}removeUnbufferedFrags(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}updateLevelTiming(e,t,i,s){let r=i.details;if(!r)return void this.warn("level.details undefined");if(!Object.keys(e.elementaryStreams).reduce((t,a)=>{let n=e.elementaryStreams[a];if(n){let l=n.endPTS-n.startPTS;if(l<=0)return this.warn(`Could not parse fragment ${e.sn} ${a} duration reliably (${l})`),t||!1;let o=s?0:ma(r,e,n.startPTS,n.endPTS,n.startDTS,n.endDTS,this);return this.hls.trigger(cA.LEVEL_PTS_UPDATED,{details:r,level:i,drift:
9o,type:a,frag:e,start:n.startPTS,end:n.endPTS}),!0}return t},!1)){var a;let t=(null==(a=this.transmuxer)?void 0:a.error)===null;if((0===i.fragmentError||t&&(i.fragmentError<2||e.endList))&&this.treatAsGap(e,i),t){let t=Error(`Found no media in fragment ${e.sn} of ${this.playlistLabel()} ${e.level} resetting transmuxer to fallback to playlist timing`);if(this.warn(t.message),this.hls.trigger(cA.ERROR,{type:ck.MEDIA_ERROR,details:cw.FRAG_PARSING_ERROR,fatal:!1,error:t,frag:e,reason:`Found no media in msn ${e.sn} of ${this.playlistLabel()} "${i.url}"`}),!this.hls)return;this.resetTransmuxer()}}this.state=mI,this.log(`Parsed ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,!1,t)})`),this.hls.trigger(cA.FRAG_PARSED,{frag:e,part:t})}playlistLabel(){return this.playlistType===cP?"level":"track"}fragInfo(e,t=!0,i){var s,r;return`${this.playlistLabel()} ${e.level} (${i?"part":"frag"}:[${(null!=(s=t&&!i?e.startPTS:(i||e).start)?s:NaN).toFixed(3)}-${(null!=(r=t&&!i?e.endPTS:(i||e).end)?r:NaN).toFixed(3)}]${i&&"main"===e.type?"INDEPENDENT="+(i.independent?"YES":"NO"):""}`}treatAsGap(e,t){t&&t.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)}resetTransmuxer(){var e;null==(e=this.transmuxer)||e.reset()}recoverWorkerError(e){"demuxerWorker"===e.event&&(this.fragmentTracker.removeAllFragments(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),this.resetStartWhenNotLoaded(),this.resetLoadingState())}set state(e){let t=this._state;t!==e&&(this._state=e,this.log(`${t}->${e}`))}get state(){return this._state}}function mO(e){return!!e.interstitialsController&&!1!==e.enableInterstitialPlayback}class mN{constructor(){this.chunks=[],this.dataLength=0}push(e){this.chunks.push(e),this.dataLength+=e.length}flush(){let e,{chunks:t,dataLength:i}=this;return t.length?(e=1===t.length?t[0]:function(e,t){let i=new Uint8Array(t),s=0;for(let t=0;t<e.length;t++){let r=e[t];i.set(r,s),s+=r.length}return i}(t,i),this.reset(),e):new Uint8Array(0)}reset(){this.chunks.length=0,this.dataLength=0}}var mF={exports:{}},mB=(S||(S=1,!function(e){var t=Object.prototype.hasOwnProperty,i="~";function s(){}function r(e,t,i){this.fn=e,this.context=t,this.once=i||!1}function a(e,t,s,a,n){if("function"!=typeof s)throw TypeError("The listener must be a function");var l=new r(s,a||e,n),o=i?i+t:t;return e._events[o]?e._events[o].fn?e._events[o]=[e._events[o],l]:e._events[o].push(l):(e._events[o]=l,e._eventsCount++),e}function n(e,t){0==--e._eventsCount?e._events=new s:delete e._events[t]}function l(){this._events=new s,this._eventsCount=0}Object.create&&(s.prototype=Object.create(null),new s().__proto__||(i=!1)),l.prototype.eventNames=function(){var e,s,r=[];if(0===this._eventsCount)return r;for(s in e=this._events)t.call(e,s)&&r.push(i?s.slice(1):s);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(e)):r},l.prototype.listeners=function(e){var t=i?i+e:e,s=this._events[t];if(!s)return[];if(s.fn)return[s.fn];for(var r=0,a=s.length,n=Array(a);r<a;r++)n[r]=s[r].fn;return n},l.prototype.listenerCount=function(e){var t=i?i+e:e,s=this._events[t];return s?s.fn?1:s.length:0},l.prototype.emit=function(e,t,s,r,a,n){var l=i?i+e:e;if(!this._events[l])return!1;var o,d,h=this._events[l],u=arguments.length;if(h.fn){switch(h.once&&this.removeListener(e,h.fn,void 0,!0),u){case 1:return h.fn.call(h.context),!0;case 2:return h.fn.call(h.context,t),!0;case 3:return h.fn.call(h.context,t,s),!0;case 4:return h.fn.call(h.context,t,s,r),!0;case 5:return h.fn.call(h.context,t,s,r,a),!0;case 6:return h.fn.call(h.context,t,s,r,a,n),!0}for(d=1,o=Array(u-1);d<u;d++)o[d-1]=arguments[d];h.fn.apply(h.context,o)}else{var c,f=h.length;for(d=0;d<f;d++)switch(h[d].once&&this.removeListener(e,h[d].fn,void 0,!0),u){case 1:h[d].fn.call(h[d].context);break;case 2:h[d].fn.call(h[d].context,t);break;case 3:h[d].fn.call(h[d].context,t,s);break;case 4:h[d].fn.call(h[d].context,t,s,r);break;default:if(!o)for(c=1,o=Array(u-1);c<u;c++)o[c-1]=arguments[c];h[d].fn.apply(h[d].context,o)}}return!0},l.prototype.on=function(e,t,i){return a(this,e,t,i,!1)},l.prototype.once=function(e,t,i){return a(this,e,t,i,!0)},l.prototype.removeListener=function(e,t,s,r){var a=i?i+e:e;if(!this._events[a])return this;if(!t)return n(this,a),this;var l=this._events[a];if(l.fn)l.fn!==t||r&&!l.once||s&&l.context!==s||n(this,a);else{for(var o=0,d=[],h=l.length;o<h;o++)(l[o].fn!==t||r&&!l[o].once||s&&l[o].context!==s)&&d.push(l[o]);d.length?this._events[a]=1===d.length?d[0]:d:n(this,a)}return this},l.prototype.removeAllListeners=function(e){var t;return e?(t=i?i+e:e,this._events[t]&&n(this,t)):(this._events=new s,this._eventsCount=0),this},l.prototype.off=l.prototype.removeListener,l.prototype.addListener=l.prototype.on,l.prefixed=i,l.EventEmitter=l,e.exports=l}
9(mF)),(m=mF.exports)&&m.__esModule&&Object.prototype.hasOwnProperty.call(m,"default"))?m.default:m;let mU="1.6.16",mj={};function mV(e,t){return t+10<=e.length&&51===e[t]&&68===e[t+1]&&73===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128||!1}function mG(e,t){return t+10<=e.length&&73===e[t]&&68===e[t+1]&&51===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128||!1}function mq(e,t){return(127&e[t])<<21|(127&e[t+1])<<14|(127&e[t+2])<<7|127&e[t+3]}function mH(e,t){let i=t,s=0;for(;mG(e,t);)s+=10,s+=mq(e,t+6),mV(e,t+10)&&(s+=10),t+=s;if(s>0)return e.subarray(i,i+s)}function mK(e,t){return 255===e[t]&&(246&e[t+1])==240}function mW(e,t){return 1&e[t+1]?7:9}function mz(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function mY(e,t){return t+1<e.length&&mK(e,t)}function mQ(e,t,i,s,r){if(!e.samplerate){let a=function(e,t,i,s){let r=t[i+2],a=r>>2&15;if(a>12){let t=Error(`invalid ADTS sampling index:${a}`);e.emit(cA.ERROR,cA.ERROR,{type:ck.MEDIA_ERROR,details:cw.FRAG_PARSING_ERROR,fatal:!0,error:t,reason:t.message});return}let n=(r>>6&3)+1,l=t[i+3]>>6&3|(1&r)<<2,o="mp4a.40."+n,d=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350][a],h=a;(5===n||29===n)&&(h-=3);let u=[n<<3|(14&h)>>1,(1&h)<<7|l<<3];return cq.log(`manifest codec:${s}, parsed codec:${o}, channels:${l}, rate:${d} (ADTS object type:${n} sampling index:${a})`),{config:u,samplerate:d,channelCount:l,codec:o,parsedCodec:o,manifestCodec:s}}(t,i,s,r);a&&cO(e,a)}}function mX(e,t,i,s,r){let a,n=s+r*(9216e4/e.samplerate),l=function(e,t){let i=mW(e,t);if(t+i<=e.length){let s=mz(e,t)-i;if(s>0)return{headerLength:i,frameLength:s}}}(t,i);if(l){let{frameLength:s,headerLength:r}=l,o=r+s,d=Math.max(0,i+o-t.length);d?(a=new Uint8Array(o-r)).set(t.subarray(i+r,t.length),0):a=t.subarray(i+r,i+o);let h={unit:a,pts:n};return d||e.samples.push(h),{sample:h,length:o,missing:d}}let o=t.length-i;return(a=new Uint8Array(o)).set(t.subarray(i,t.length),0),{sample:{unit:a,pts:n},length:o,missing:-1}}function mJ(e,t=0,i=1/0){var s,r,a,n,l,o;let d,h,u,c,f,p;return s=e,r=t,a=i,n=Uint8Array,d=(l=s)instanceof ArrayBuffer?l:l.buffer,h=1,"BYTES_PER_ELEMENT"in n&&(h=n.BYTES_PER_ELEMENT),c=((u=(o=s)&&o.buffer instanceof ArrayBuffer&&void 0!==o.byteLength&&void 0!==o.byteOffset?s.byteOffset:0)+s.byteLength)/h,p=Math.floor(Math.min((f=Math.floor(Math.max(0,Math.min((u+r)/h,c))))+Math.max(a,0),c)),new n(d,f,p-f)}function mZ(e){let t=0,i=[];for(;mG(e,t);){let s=mq(e,t+6);e[t+5]>>6&1&&(t+=10);let r=(t+=10)+s;for(;t+10<r;){let s=function(e){let t=String.fromCharCode(e[0],e[1],e[2],e[3]),i=mq(e,4);return{type:t,size:i,data:e.subarray(10,10+i)}}(e.subarray(t)),r=function(e){if("PRIV"===e.type){if(e.size<2)return;let t=cW(e.data,!0),i=new Uint8Array(e.data.subarray(t.length+1));return{key:e.type,info:t,data:i.buffer}}if("W"===e.type[0]){if("WXXX"===e.type){if(e.size<2)return;let t=1,i=cW(e.data.subarray(t),!0);t+=i.length+1;let s=cW(e.data.subarray(t));return{key:e.type,info:i,data:s}}let t=cW(e.data);return{key:e.type,info:"",data:t}}if("APIC"===e.type)return function(e){let t,i={key:e.type,description:"",data:"",mimeType:null,pictureType:null};if(e.size<2)return;if(3!==e.data[0])return void console.log("Ignore frame with unrecognized character encoding");let s=e.data.subarray(1).indexOf(0);if(-1===s)return;let r=cW(mJ(e.data,1,s)),a=e.data[2+s],n=e.data.subarray(3+s).indexOf(0);if(-1===n)return;let l=cW(mJ(e.data,3+s,n));if("-->"===r)t=cW(mJ(e.data,4+s+n));else{var o;t=(o=e.data.subarray(4+s+n))instanceof ArrayBuffer?o:0==o.byteOffset&&o.byteLength==o.buffer.byteLength?o.buffer:new Uint8Array(o).buffer}return i.mimeType=r,i.pictureType=a,i.description=l,i.data=t,i}(e);if(e.size<2)return;if("TXXX"===e.type){let t=1,i=cW(e.data.subarray(t),!0);t+=i.length+1;let s=cW(e.data.subarray(t));return{key:e.type,info:i,data:s}}let t=cW(e.data.subarray(1));return{key:e.type,info:"",data:t}}(s);r&&i.push(r),t+=s.size+10}mV(e,t)&&(t+=10)}return i}function m0(e){return e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info}function m1(e){let t=mZ(e);for(let e=0;e<t.length;e++){let i=t[e];if(m0(i))return function(e){if(8===e.data.byteLength){let t=new Uint8Array(e.data),i=1&t[3],s=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];return s/=45,i&&(s+=47721858.84),Math.round(s)}}(i)}}let m2=((g={}).audioId3="org.id3",g.dateRange="com.apple.quicktime.HLS",g.emsg="https://aomedia.org/emsg/ID3",g.misbklv="urn:misb:KLV:bin:1910.1",g);function m5(e="",t=9e4){return{type:e,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}class m3{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}resetInitSegment(e,t,i,s){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(e){this.initPTS=e,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(e,t){return!1}appendFrame(e,t,i){}demux(e,t){let i;this.cachedData&&(e=fu(this.cachedData,e),this.cachedData=null);
9let s=mH(e,0),r=s?s.length:0,a=this._audioTrack,n=this._id3Track,l=s?m1(s):void 0,o=e.length;for((null===this.basePTS||0===this.frameIndex&&cS(l))&&(this.basePTS=m4(l,t,this.initPTS),this.lastPTS=this.basePTS),null===this.lastPTS&&(this.lastPTS=this.basePTS),s&&s.length>0&&n.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:s,type:m2.audioId3,duration:1/0});r<o;){if(this.canParse(e,r)){let t=this.appendFrame(a,e,r);t?(this.frameIndex++,this.lastPTS=t.sample.pts,r+=t.length,i=r):r=o}else{var d,h;mG(d=e,h=r)&&mq(d,h+6)+10<=d.length-h?(s=mH(e,r),n.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:s,type:m2.audioId3,duration:1/0}),r+=s.length,i=r):r++}if(r===o&&i!==o){let t=e.slice(i);this.cachedData?this.cachedData=fu(this.cachedData,t):this.cachedData=t}}return{audioTrack:a,videoTrack:m5(),id3Track:n,textTrack:m5()}}demuxSampleAes(e,t,i){return Promise.reject(Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(e){let t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:m5(),id3Track:this._id3Track,textTrack:m5()}}destroy(){this.cachedData=null,this._audioTrack=this._id3Track=void 0}}let m4=(e,t,i)=>cS(e)?90*e:9e4*t+(i?9e4*i.baseTime/i.timescale:0),m8=null,m6=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],m7=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],m9=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],ge=[0,1,1,4];function gt(e,t,i,s,r){if(i+24>t.length)return;let a=gi(t,i);if(a&&i+a.frameLength<=t.length){let n=s+r*(9e4*a.samplesPerFrame/a.sampleRate),l={unit:t.subarray(i,i+a.frameLength),pts:n,dts:n};return e.config=[],e.channelCount=a.channelCount,e.samplerate=a.sampleRate,e.samples.push(l),{sample:l,length:a.frameLength,missing:0}}}function gi(e,t){let i=e[t+1]>>3&3,s=e[t+1]>>1&3,r=e[t+2]>>4&15,a=e[t+2]>>2&3;if(1!==i&&0!==r&&15!==r&&3!==a){let n=e[t+2]>>1&1,l=e[t+3]>>6,o=1e3*m6[14*(3===i?3-s:3===s?3:4)+r-1],d=m7[3*(3===i?0:2===i?1:2)+a],h=m9[i][s],u=ge[s],c=Math.floor(h*o/d+n)*u;if(null===m8){let e=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);m8=e?parseInt(e[1]):0}return m8&&m8<=87&&2===s&&o>=224e3&&0===l&&(e[t+3]=128|e[t+3]),{sampleRate:d,channelCount:3===l?1:2,frameLength:c,samplesPerFrame:8*h*u}}}function gs(e,t){return 255===e[t]&&(224&e[t+1])==224&&(6&e[t+1])!=0}function gr(e,t){return t+1<e.length&&gs(e,t)}function ga(e,t){if(t+1<e.length&&gs(e,t)){let i=gi(e,t),s=4;null!=i&&i.frameLength&&(s=i.frameLength);let r=t+s;return r===e.length||gr(e,r)}return!1}let gn=(e,t)=>{let i=0,s=5;t+=5;let r=new Uint32Array(1),a=new Uint32Array(1),n=new Uint8Array(1);for(;s>0;){n[0]=e[t];let l=Math.min(s,8),o=8-l;a[0]=0xff000000>>>24+o<<o,r[0]=(n[0]&a[0])>>o,i=i?i<<l|r[0]:r[0],t+=1,s-=l}return i};function gl(e,t,i,s,r){if(i+8>t.length||11!==t[i]||119!==t[i+1])return -1;let a=t[i+4]>>6;if(a>=3)return -1;let n=[48e3,44100,32e3][a],l=63&t[i+4],o=2*[64,69,96,64,70,96,80,87,120,80,88,120,96,104,144,96,105,144,112,121,168,112,122,168,128,139,192,128,140,192,160,174,240,160,175,240,192,208,288,192,209,288,224,243,336,224,244,336,256,278,384,256,279,384,320,348,480,320,349,480,384,417,576,384,418,576,448,487,672,448,488,672,512,557,768,512,558,768,640,696,960,640,697,960,768,835,1152,768,836,1152,896,975,1344,896,976,1344,1024,1114,1536,1024,1115,1536,1152,1253,1728,1152,1254,1728,1280,1393,1920,1280,1394,1920][3*l+a];if(i+o>t.length)return -1;let d=t[i+6]>>5,h=0;2===d?h+=2:(1&d&&1!==d&&(h+=2),4&d&&(h+=2));let u=(t[i+6]<<8|t[i+7])>>12-h&1,c=[2,1,2,3,3,4,4,5][d]+u,f=t[i+5]>>3,p=7&t[i+5],m=new Uint8Array([a<<6|f<<1|p>>2,(3&p)<<6|d<<3|u<<2|l>>4,l<<4&224]),g=t.subarray(i,i+o);return e.config=m,e.channelCount=c,e.samplerate=n,e.samples.push({unit:g,pts:s+1536/n*9e4*r}),o}let go=/\/emsg[-/]ID3/i;function gd(e,t){return cS(e.presentationTime)?e.presentationTime/e.timeScale:t+e.presentationTimeDelta/e.timeScale}class gh{constructor(e,t,i){this.keyData=void 0,this.decrypter=void 0,this.keyData=i,this.decrypter=new pd(t,{removePKCS7Padding:!1})}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer,0)}decryptAacSample(e,t,i){let s=e[t].unit;if(s.length<=16)return;let r=s.subarray(16,s.length-s.length%16),a=r.buffer.slice(r.byteOffset,r.byteOffset+r.length);this.decryptBuffer(a).then(r=>{let a=new Uint8Array(r);s.set(a,16),this.decrypter.isSync()||this.decryptAacSamples(e,t+1,i)}).catch(i)}decryptAacSamples(e,t,i){for(;;t++){if(t>=e.length)return void i();if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,i),!this.decrypter.isSync()))return}}getAvcEncryptedData(e){let t=new Int8Array(16*Math.floor((e.length-48)/160)+16),i=0;for(let s=32;s<e.length-16;s+=160,i+=16)t.set(e.subarray(s,s+16),i);return t}getAvcDecryptedUnit(e,t){let i=new Uint8Array(t),s=0;for(let t=32;t<e.length-16;t+=160,s+=16)e.set(i.subarray(s,s+16),t);return e}decryptAvcSample(e,t,i,s,r){let a=fm(r.data),n=this.getAvcEncryptedData(a);this.decryptBuffer(n.buffer).then(n=>{r.data=this.getAvcDecryptedUnit(a,n),this.decrypter.isSync()||this.decryptAvcSamples(e,t,i+1,s)}).catch(s)}decryptAvcSamples(e,t,i,s){if(e instanceof Uint8Array)throw Error("Cannot decrypt samples of type Uint8Array");for(;;t++,i=0){if(t>=e.length)return void s();let r=e[t].units;for(;!(i>=r.length);i++){let a=r[i];if(!(a.data.length<=48)&&(1===a.type||5===a.type)&&(this.decryptAvcSample(e,t,i,s,a),!this.decrypter.isSync()))return}}}}class gu{constructor(){this.VideoSample=null}createVideoSample(e,t,i){return{key:e,frame:!1,pts:t,dts:i,units:[],length:0}}getLastNalUnit(e){var t;let i,s=this.VideoSample;if(s&&0!==s.units.length||(s=e[e.length-1]),null!=(t=s)&&t.units){let e=s.units;i=e[e.length-1]}return i}pushAccessUnit(e,t){if(e.units.length&&e.frame){if(void 0===e.pts){let i=t.samples,s=i.length;if(!s)return void t.dropped++;{let t=i[s-1];e.pts=t.pts,e.dts=t.dts}}t.samples.push(e)}}parseNALu(e,t,i){let s,r,a,n=t.byteLength,l=e.naluState||0,o=l,d=[],h=0,u=-1,c=0;for(-1===l&&(u=0,c=this.getNALuType(t,0),l=0,h=1);h<n;){if(s=t[h++],!l){l=+!s;continue}if(1===l){l=2*!s;continue}
9if(s)if(1===s){if(r=h-l-1,u>=0){let e={data:t.subarray(u,r),type:c};d.push(e)}else{let i=this.getLastNalUnit(e.samples);i&&(o&&h<=4-o&&i.state&&(i.data=i.data.subarray(0,i.data.byteLength-o)),r>0&&(i.data=fu(i.data,t.subarray(0,r)),i.state=0))}h<n?(a=this.getNALuType(t,h),u=h,c=a,l=0):l=-1}else l=0;else l=3}if(u>=0&&l>=0){let e={data:t.subarray(u,n),type:c,state:l};d.push(e)}if(0===d.length){let i=this.getLastNalUnit(e.samples);i&&(i.data=fu(i.data,t))}return e.naluState=l,d}}class gc{constructor(e){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}loadWord(){let e=this.data,t=this.bytesAvailable,i=e.byteLength-t,s=new Uint8Array(4),r=Math.min(4,t);if(0===r)throw Error("no bytes available");s.set(e.subarray(i,i+r)),this.word=new DataView(s.buffer).getUint32(0),this.bitsAvailable=8*r,this.bytesAvailable-=r}skipBits(e){let t;e=Math.min(e,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>e||(e-=this.bitsAvailable,t=e>>3,e-=t<<3,this.bytesAvailable-=t,this.loadWord()),this.word<<=e,this.bitsAvailable-=e}readBits(e){let t=Math.min(this.bitsAvailable,e),i=this.word>>>32-t;if(e>32&&cq.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else if(this.bytesAvailable>0)this.loadWord();else throw Error("no bits available");return(t=e-t)>0&&this.bitsAvailable?i<<t|this.readBits(t):i}skipLZ(){let e;for(e=0;e<this.bitsAvailable;++e)if((this.word&0x80000000>>>e)!=0)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){let e=this.skipLZ();return this.readBits(e+1)-1}readEG(){let e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}readBoolean(){return 1===this.readBits(1)}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}}class gf extends gu{parsePES(e,t,i,s){let r,a=this.parseNALu(e,i.data,s),n=this.VideoSample,l=!1;i.data=null,n&&a.length&&!e.audFound&&(this.pushAccessUnit(n,e),n=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts)),a.forEach(s=>{var a,o,d,h,u;switch(s.type){case 1:{let t=!1;r=!0;let a=s.data;if(l&&a.length>4){let e=this.readSliceType(a);(2===e||4===e||7===e||9===e)&&(t=!0)}t&&null!=(d=n)&&d.frame&&!n.key&&(this.pushAccessUnit(n,e),n=this.VideoSample=null),n||(n=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),n.frame=!0,n.key=t;break}case 5:r=!0,null!=(a=n)&&a.frame&&!n.key&&(this.pushAccessUnit(n,e),n=this.VideoSample=null),n||(n=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),n.key=!0,n.frame=!0;break;case 6:r=!0,fp(s.data,1,i.pts,t.samples);break;case 7:{r=!0,l=!0;let t=s.data,i=this.readSPS(t);if(!e.sps||e.width!==i.width||e.height!==i.height||(null==(h=e.pixelRatio)?void 0:h[0])!==i.pixelRatio[0]||(null==(u=e.pixelRatio)?void 0:u[1])!==i.pixelRatio[1]){e.width=i.width,e.height=i.height,e.pixelRatio=i.pixelRatio,e.sps=[t];let s=t.subarray(1,4),r="avc1.";for(let e=0;e<3;e++){let t=s[e].toString(16);t.length<2&&(t="0"+t),r+=t}e.codec=r}break}case 8:r=!0,e.pps=[s.data];break;case 9:r=!0,e.audFound=!0,null!=(o=n)&&o.frame&&(this.pushAccessUnit(n,e),n=null),n||(n=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts));break;case 12:r=!0;break;default:r=!1}n&&r&&n.units.push(s)}),s&&n&&(this.pushAccessUnit(n,e),this.VideoSample=null)}getNALuType(e,t){return 31&e[t]}readSliceType(e){let t=new gc(e);return t.readUByte(),t.readUEG(),t.readUEG()}skipScalingList(e,t){let i=8,s=8;for(let r=0;r<e;r++)0!==s&&(s=(i+t.readEG()+256)%256),i=0===s?i:s}readSPS(e){let t,i,s,r=new gc(e),a=0,n=0,l=0,o=0,d=r.readUByte.bind(r),h=r.readBits.bind(r),u=r.readUEG.bind(r),c=r.readBoolean.bind(r),f=r.skipBits.bind(r),p=r.skipEG.bind(r),m=r.skipUEG.bind(r),g=this.skipScalingList.bind(this);d();let y=d();if(h(5),f(3),d(),m(),100===y||110===y||122===y||244===y||44===y||83===y||86===y||118===y||128===y){let e=u();if(3===e&&f(1),m(),m(),f(1),c())for(s=0,i=3!==e?8:12;s<i;s++)c()&&g(s<6?16:64,r)}m();let v=u();if(0===v)u();else if(1===v)for(f(1),p(),p(),t=u(),s=0;s<t;s++)p();m(),f(1);let b=u(),E=u(),S=h(1);0===S&&f(1),f(1),c()&&(a=u(),n=u(),l=u(),o=u());let T=[1,1];if(c()&&c())switch(d()){case 1:T=[1,1];break;case 2:T=[12,11];break;case 3:T=[10,11];break;case 4:T=[16,11];break;case 5:T=[40,33];break;case 6:T=[24,11];break;case 7:T=[20,11];break;case 8:T=[32,11];break;case 9:T=[80,33];break;case 10:T=[18,11];break;case 11:T=[15,11];break;case 12:T=[64,33];break;case 13:T=[160,99];break;case 14:T=[4,3];break;case 15:T=[3,2];break;case 16:T=[2,1];break;case 255:T=[d()<<8|d(),d()<<8|d()]}return{width:Math.ceil((b+1)*16-2*a-2*n),height:(2-S)*(E+1)*16-(S?2:4)*(l+o),pixelRatio:T}}}class gp extends gu{constructor(...e){super(...e),this.initVPS=null}parsePES(e,t,i,s){let r,a=this.parseNALu(e,i.data,s),n=this.VideoSample,l=!1;i.data=null,n&&a.length&&!e.audFound&&(this.pushAccessUnit(n,e),n=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts)),a.forEach(s=>{var a,o,d;
9switch(s.type){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:n||(n=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts)),n.frame=!0,r=!0;break;case 16:case 17:case 18:case 21:r=!0,l&&null!=(d=n)&&d.frame&&!n.key&&(this.pushAccessUnit(n,e),n=this.VideoSample=null),n||(n=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),n.key=!0,n.frame=!0;break;case 19:case 20:r=!0,null!=(a=n)&&a.frame&&!n.key&&(this.pushAccessUnit(n,e),n=this.VideoSample=null),n||(n=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),n.key=!0,n.frame=!0;break;case 39:r=!0,fp(s.data,2,i.pts,t.samples);break;case 32:r=!0,e.vps||("object"!=typeof e.params&&(e.params={}),e.params=cO(e.params,this.readVPS(s.data)),this.initVPS=s.data),e.vps=[s.data];break;case 33:if(r=!0,l=!0,void 0===e.vps||e.vps[0]===this.initVPS||void 0===e.sps||this.matchSPS(e.sps[0],s.data)||(this.initVPS=e.vps[0],e.sps=e.pps=void 0),!e.sps){let t=this.readSPS(s.data);for(let i in e.width=t.width,e.height=t.height,e.pixelRatio=t.pixelRatio,e.codec=t.codecString,e.sps=[],"object"!=typeof e.params&&(e.params={}),t.params)e.params[i]=t.params[i]}this.pushParameterSet(e.sps,s.data,e.vps),n||(n=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),n.key=!0;break;case 34:if(r=!0,"object"==typeof e.params){if(!e.pps){e.pps=[];let t=this.readPPS(s.data);for(let i in t)e.params[i]=t[i]}this.pushParameterSet(e.pps,s.data,e.vps)}break;case 35:r=!0,e.audFound=!0,null!=(o=n)&&o.frame&&(this.pushAccessUnit(n,e),n=null),n||(n=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts));break;default:r=!1}n&&r&&n.units.push(s)}),s&&n&&(this.pushAccessUnit(n,e),this.VideoSample=null)}pushParameterSet(e,t,i){(!i||i[0]!==this.initVPS)&&(i||e.length)||e.push(t)}getNALuType(e,t){return(126&e[t])>>>1}ebsp2rbsp(e){let t=new Uint8Array(e.byteLength),i=0;for(let s=0;s<e.byteLength;s++)(!(s>=2)||3!==e[s]||0!==e[s-1]||0!==e[s-2])&&(t[i]=e[s],i++);return new Uint8Array(t.buffer,0,i)}pushAccessUnit(e,t){super.pushAccessUnit(e,t),this.initVPS&&(this.initVPS=null)}readVPS(e){let t=new gc(e);return t.readUByte(),t.readUByte(),t.readBits(4),t.skipBits(2),t.readBits(6),{numTemporalLayers:t.readBits(3)+1,temporalIdNested:t.readBoolean()}}readSPS(e){let t=new gc(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.readBits(4);let i=t.readBits(3);t.readBoolean();let s=t.readBits(2),r=t.readBoolean(),a=t.readBits(5),n=t.readUByte(),l=t.readUByte(),o=t.readUByte(),d=t.readUByte(),h=t.readUByte(),u=t.readUByte(),c=t.readUByte(),f=t.readUByte(),p=t.readUByte(),m=t.readUByte(),g=t.readUByte(),y=[],v=[];for(let e=0;e<i;e++)y.push(t.readBoolean()),v.push(t.readBoolean());if(i>0)for(let e=i;e<8;e++)t.readBits(2);for(let e=0;e<i;e++)y[e]&&(t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte()),v[e]&&t.readUByte();t.readUEG();let b=t.readUEG();3==b&&t.skipBits(1);let E=t.readUEG(),S=t.readUEG(),T=t.readBoolean(),x=0,k=0,w=0,A=0;T&&(x+=t.readUEG(),k+=t.readUEG(),w+=t.readUEG(),A+=t.readUEG());let R=t.readUEG(),L=t.readUEG(),C=t.readUEG(),I=t.readBoolean();for(let e=I?0:i;e<=i;e++)t.skipUEG(),t.skipUEG(),t.skipUEG();if(t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.readBoolean()&&t.readBoolean())for(let e=0;e<4;e++)for(let i=0;i<(3===e?2:6);i++)if(t.readBoolean()){let i=Math.min(64,1<<4+(e<<1));e>1&&t.readEG();for(let e=0;e<i;e++)t.readEG()}else t.readUEG();t.readBoolean(),t.readBoolean(),t.readBoolean()&&(t.readUByte(),t.skipUEG(),t.skipUEG(),t.readBoolean());let P=t.readUEG(),D=0;for(let e=0;e<P;e++){let i=!1;if(0!==e&&(i=t.readBoolean()),i){e===P&&t.readUEG(),t.readBoolean(),t.readUEG();let i=0;for(let e=0;e<=D;e++){let e=t.readBoolean(),s=!1;e||(s=t.readBoolean()),(e||s)&&i++}D=i}else{let e=t.readUEG(),i=t.readUEG();D=e+i;for(let i=0;i<e;i++)t.readUEG(),t.readBoolean();for(let e=0;e<i;e++)t.readUEG(),t.readBoolean()}}if(t.readBoolean()){let e=t.readUEG();for(let i=0;i<e;i++){for(let e=0;e<C+4;e++)t.readBits(1);t.readBits(1)}}let M=0,_=1,$=1,O=!0,N=1,F=0;t.readBoolean(),t.readBoolean();if(t.readBoolean()){if(t.readBoolean()){let e=t.readUByte();e>0&&e<16?(_=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2][e-1],$=[
91,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1][e-1]):255===e&&(_=t.readBits(16),$=t.readBits(16))}if(t.readBoolean()&&t.readBoolean(),t.readBoolean()&&(t.readBits(3),t.readBoolean(),t.readBoolean()&&(t.readUByte(),t.readUByte(),t.readUByte())),t.readBoolean()&&(t.readUEG(),t.readUEG()),t.readBoolean(),t.readBoolean(),t.readBoolean(),t.readBoolean()&&(t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG()),t.readBoolean()&&(N=t.readBits(32),F=t.readBits(32),t.readBoolean()&&t.readUEG(),t.readBoolean())){let e=t.readBoolean(),s=t.readBoolean(),r=!1;(e||s)&&((r=t.readBoolean())&&(t.readUByte(),t.readBits(5),t.readBoolean(),t.readBits(5)),t.readBits(4),t.readBits(4),r&&t.readBits(4),t.readBits(5),t.readBits(5),t.readBits(5));for(let a=0;a<=i;a++){let i=(O=t.readBoolean())||t.readBoolean(),a=!1;i?t.readEG():a=t.readBoolean();let n=a?1:t.readUEG()+1;if(e)for(let e=0;e<n;e++)t.readUEG(),t.readUEG(),r&&(t.readUEG(),t.readUEG()),t.skipBits(1);if(s)for(let e=0;e<n;e++)t.readUEG(),t.readUEG(),r&&(t.readUEG(),t.readUEG()),t.skipBits(1)}}t.readBoolean()&&(t.readBoolean(),t.readBoolean(),t.readBoolean(),M=t.readUEG())}let B=E,U=S;if(T){let e=1,t=1;1===b?e=t=2:2==b&&(e=2),B=E-e*k-e*x,U=S-t*A-t*w}let j=s?["A","B","C"][s]:"",V=n<<24|l<<16|o<<8|d,G=0;for(let e=0;e<32;e++)G=(G|(V>>e&1)<<31-e)>>>0;let q=G.toString(16);return 1===a&&"2"===q&&(q="6"),{codecString:`hvc1.${j}${a}.${q}.${r?"H":"L"}${g}.B0`,params:{general_tier_flag:r,general_profile_idc:a,general_profile_space:s,general_profile_compatibility_flags:[n,l,o,d],general_constraint_indicator_flags:[h,u,c,f,p,m],general_level_idc:g,bit_depth:R+8,bit_depth_luma_minus8:R,bit_depth_chroma_minus8:L,min_spatial_segmentation_idc:M,chroma_format_idc:b,frame_rate:{fixed:O,fps:F/N}},width:B,height:U,pixelRatio:[_,$]}}readPPS(e){let t=new gc(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.skipUEG(),t.skipUEG(),t.skipBits(2),t.skipBits(3),t.skipBits(2),t.skipUEG(),t.skipUEG(),t.skipEG(),t.skipBits(2),t.readBoolean()&&t.skipUEG(),t.skipEG(),t.skipEG(),t.skipBits(4);let i=t.readBoolean(),s=t.readBoolean(),r=1;return s&&i?r=0:s?r=3:i&&(r=2),{parallelismType:r}}matchSPS(e,t){return String.fromCharCode.apply(null,e).substr(3)===String.fromCharCode.apply(null,t).substr(3)}}class gm{constructor(e,t,i,s){this.logger=void 0,this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=e,this.config=t,this.typeSupported=i,this.logger=s,this.videoParser=null}static probe(e,t){let i=gm.syncOffset(e);return i>0&&t.warn(`MPEG2-TS detected but first sync word found @ offset ${i}`),-1!==i}static syncOffset(e){let t=e.length,i=Math.min(940,t-188)+1,s=0;for(;s<i;){let r=!1,a=-1,n=0;for(let l=s;l<t;l+=188)if(71===e[l]&&(t-l==188||71===e[l+188])){if(n++,-1===a&&0!==(a=l)&&(i=Math.min(a+18612,e.length-188)+1),r||(r=0===gg(e,l)),r&&n>1&&(0===a&&n>2||l+188>i))return a}else if(n)return -1;else break;s++}return -1}static createTrack(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:c6[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===e?t:void 0}}resetInitSegment(e,t,i,s){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=gm.createTrack("video"),this._videoTrack.duration=s,this._audioTrack=gm.createTrack("audio",s),this._id3Track=gm.createTrack("id3"),this._txtTrack=gm.createTrack("text"),this._audioTrack.segmentCodec="aac",this.videoParser=null,this.aacOverFlow=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=i}resetTimeStamp(){}resetContiguity(){let{_audioTrack:e,_videoTrack:t,_id3Track:i}=this;e&&(e.pesData=null),t&&(t.pesData=null),i&&(i.pesData=null),this.aacOverFlow=null,this.remainderData=null}demux(e,t,i=!1,s=!1){let r;i||(this.sampleAes=null);let a=this._videoTrack,n=this._audioTrack,l=this._id3Track,o=this._txtTrack,d=a.pid,h=a.pesData,u=n.pid,c=l.pid,f=n.pesData,p=l.pesData,m=null,g=this.pmtParsed,y=this._pmtId,v=e.length;if(this.remainderData&&(v=(e=fu(this.remainderData,e)).length,this.remainderData=null),v<188&&!s)return this.remainderData=e,{audioTrack:n,videoTrack:a,id3Track:l,textTrack:o};let b=Math.max(0,gm.syncOffset(e));(v-=(v-b)%188)<e.byteLength&&!s&&(this.remainderData=new Uint8Array(e.buffer,v,e.buffer.byteLength-v));let E=0;for(let t=b;t<v;t+=188)if(71===e[t]){let s,v=!!(64&e[t+1]),E=gg(e,t);if((48&e[t+3])>>4>1){if((s=t+5+e[t+4])===t+188)continue}
9else s=t+4;switch(E){case d:v&&(h&&(r=gb(h,this.logger))&&(this.readyVideoParser(a.segmentCodec),null!==this.videoParser&&this.videoParser.parsePES(a,o,r,!1)),h={data:[],size:0}),h&&(h.data.push(e.subarray(s,t+188)),h.size+=t+188-s);break;case u:if(v){if(f&&(r=gb(f,this.logger)))switch(n.segmentCodec){case"aac":this.parseAACPES(n,r);break;case"mp3":this.parseMPEGPES(n,r);break;case"ac3":this.parseAC3PES(n,r)}f={data:[],size:0}}f&&(f.data.push(e.subarray(s,t+188)),f.size+=t+188-s);break;case c:v&&(p&&(r=gb(p,this.logger))&&this.parseID3PES(l,r),p={data:[],size:0}),p&&(p.data.push(e.subarray(s,t+188)),p.size+=t+188-s);break;case 0:var S,T;v&&(s+=e[s]+1),y=this._pmtId=(31&(S=e)[(T=s)+10])<<8|S[T+11];break;case y:{v&&(s+=e[s]+1);let r=function(e,t,i,s,r,a){let n={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},l=(15&e[t+1])<<8|e[t+2],o=t+3+l-4,d=(15&e[t+10])<<8|e[t+11];for(t+=12+d;t<o;){let l=gg(e,t),o=(15&e[t+3])<<8|e[t+4];switch(e[t]){case 207:if(!s){gv("ADTS AAC",a);break}case 15:-1===n.audioPid&&(n.audioPid=l);break;case 21:-1===n.id3Pid&&(n.id3Pid=l);break;case 219:if(!s){gv("H.264",a);break}case 27:-1===n.videoPid&&(n.videoPid=l);break;case 3:case 4:i.mpeg||i.mp3?-1===n.audioPid&&(n.audioPid=l,n.segmentAudioCodec="mp3"):a.log("MPEG audio found, not supported in this browser");break;case 193:if(!s){gv("AC-3",a);break}case 129:i.ac3?-1===n.audioPid&&(n.audioPid=l,n.segmentAudioCodec="ac3"):a.log("AC-3 audio found, not supported in this browser");break;case 6:if(-1===n.audioPid&&o>0){let s=t+5,r=o;for(;r>2;){106===e[s]&&(!0!==i.ac3?a.log("AC-3 audio found, not supported in this browser for now"):(n.audioPid=l,n.segmentAudioCodec="ac3"));let t=e[s+1]+2;s+=t,r-=t}}break;case 194:case 135:return gy(r,Error("Unsupported EC-3 in M2TS found"),void 0,a),n;case 36:-1===n.videoPid&&(n.videoPid=l,n.segmentVideoCodec="hevc",a.log("HEVC in M2TS found"))}t+=o+5}return n}(e,s,this.typeSupported,i,this.observer,this.logger);(d=r.videoPid)>0&&(a.pid=d,a.segmentCodec=r.segmentVideoCodec),(u=r.audioPid)>0&&(n.pid=u,n.segmentCodec=r.segmentAudioCodec),(c=r.id3Pid)>0&&(l.pid=c),null===m||g||(this.logger.warn(`MPEG-TS PMT found at ${t} after unknown PID '${m}'. Backtracking to sync byte @${b} to parse all TS packets.`),m=null,t=b-188),g=this.pmtParsed=!0;break}case 17:case 8191:break;default:m=E}}else E++;E>0&&gy(this.observer,Error(`Found ${E} TS packet/s that do not start with 0x47`),void 0,this.logger),a.pesData=h,n.pesData=f,l.pesData=p;let x={audioTrack:n,videoTrack:a,id3Track:l,textTrack:o};return s&&this.extractRemainingSamples(x),x}flush(){let e,{remainderData:t}=this;return(this.remainderData=null,e=t?this.demux(t,-1,!1,!0):{videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(e),this.sampleAes)?this.decrypt(e,this.sampleAes):e}extractRemainingSamples(e){let t,{audioTrack:i,videoTrack:s,id3Track:r,textTrack:a}=e,n=s.pesData,l=i.pesData,o=r.pesData;if(n&&(t=gb(n,this.logger))?(this.readyVideoParser(s.segmentCodec),null!==this.videoParser&&(this.videoParser.parsePES(s,a,t,!0),s.pesData=null)):s.pesData=n,l&&(t=gb(l,this.logger))){switch(i.segmentCodec){case"aac":this.parseAACPES(i,t);break;case"mp3":this.parseMPEGPES(i,t);break;case"ac3":this.parseAC3PES(i,t)}i.pesData=null}else null!=l&&l.size&&this.logger.log("last AAC PES packet truncated,might overlap between fragments"),i.pesData=l;o&&(t=gb(o,this.logger))?(this.parseID3PES(r,t),r.pesData=null):r.pesData=o}demuxSampleAes(e,t,i){let s=this.demux(e,i,!0,!this.config.progressive),r=this.sampleAes=new gh(this.observer,this.config,t);return this.decrypt(s,r)}readyVideoParser(e){null===this.videoParser&&("avc"===e?this.videoParser=new gf:"hevc"===e&&(this.videoParser=new gp))}decrypt(e,t){return new Promise(i=>{let{audioTrack:s,videoTrack:r}=e;s.samples&&"aac"===s.segmentCodec?t.decryptAacSamples(s.samples,0,()=>{r.samples?t.decryptAvcSamples(r.samples,0,0,()=>{i(e)}):i(e)}):r.samples&&t.decryptAvcSamples(r.samples,0,0,()=>{i(e)})})}destroy(){this.observer&&this.observer.removeAllListeners(),this.config=this.logger=this.observer=null,this.aacOverFlow=this.videoParser=this.remainderData=this.sampleAes=null,this._videoTrack=this._audioTrack=this._id3Track=this._txtTrack=void 0}parseAACPES(e,t){let i,s,r,a,n=0,l=this.aacOverFlow,o=t.data;if(l){this.aacOverFlow=null;let t=l.missing,i=l.sample.unit.byteLength;-1===t?o=fu(l.sample.unit,o):(l.sample.unit.set(o.subarray(0,t),i-t),e.samples.push(l.sample),n=l.missing)}for(i=n,s=o.length;i<s-1&&!mY(o,i);i++);if(i!==n){let e,t=i<s-1;if(e=t?`AAC PES did not start with ADTS header,offset:${i}`:"No ADTS header found in AAC PES",gy(this.observer,Error(e),t,this.logger),!t)return}if(mQ(e,this.observer,o,i,this.audioCodec),void 0!==t.pts)r=t.pts;else{if(!l)return void this.logger.warn("[tsdemuxer]: AAC PES unknown PTS");let t=9216e4/e.samplerate;r=l.sample.pts+t}let d=0;for(;i<s;){if(a=mX(e,o,i,r,d),i+=a.length,a.missing){this.aacOverFlow=a;break}for(d++;i<s-1&&!mY(o,i);i++);}}parseMPEGPES(e,t){let i=t.data,s=i.length,r=0,a=0,n=t.pts;if(void 0===n)return void this.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");for(;a<s;)if(gr(i,a)){let t=gt(e,i,a,n,r);if(t)a+=t.length,r++;else break}else a++}parseAC3PES(e,t){{let i,s=t.data,r=t.pts;if(void 0===r)return void this.logger.warn("[tsdemuxer]: AC3 PES unknown PTS");let a=s.length,n=0,l=0;for(;
9l<a&&(i=gl(e,s,l,r,n++))>0;)l+=i}}parseID3PES(e,t){if(void 0===t.pts)return void this.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");let i=cO({},t,{type:this._videoTrack?m2.emsg:m2.audioId3,duration:1/0});e.samples.push(i)}}function gg(e,t){return((31&e[t+1])<<8)+e[t+2]}function gy(e,t,i,s){s.warn(`parsing error: ${t.message}`),e.emit(cA.ERROR,cA.ERROR,{type:ck.MEDIA_ERROR,details:cw.FRAG_PARSING_ERROR,fatal:!1,levelRetry:i,error:t,reason:t.message})}function gv(e,t){t.log(`${e} with AES-128-CBC encryption found in unencrypted stream`)}function gb(e,t){let i,s,r,a,n,l=0,o=e.data;if(!e||0===e.size)return null;for(;o[0].length<19&&o.length>1;)o[0]=fu(o[0],o[1]),o.splice(1,1);if(1===((i=o[0])[0]<<16)+(i[1]<<8)+i[2]){if((s=(i[4]<<8)+i[5])&&s>e.size-6)return null;let d=i[7];192&d&&(a=(14&i[9])*0x20000000+(255&i[10])*4194304+(254&i[11])*16384+(255&i[12])*128+(254&i[13])/2,64&d?a-(n=(14&i[14])*0x20000000+(255&i[15])*4194304+(254&i[16])*16384+(255&i[17])*128+(254&i[18])/2)>54e5&&(t.warn(`${Math.round((a-n)/9e4)}s delta between PTS and DTS, align them`),a=n):n=a);let h=(r=i[8])+9;if(e.size<=h)return null;e.size-=h;let u=new Uint8Array(e.size);for(let e=0,t=o.length;e<t;e++){let t=(i=o[e]).byteLength;if(h)if(h>t){h-=t;continue}else i=i.subarray(h),t-=h,h=0;u.set(i,l),l+=t}return s&&(s-=r+3),{data:u,pts:a,dts:n,len:s}}return null}class gE{static getSilentFrame(e,t){if("mp4a.40.2"===e){if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);else if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);else if(5===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);else if(6===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(1===t)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(3===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}}}class gS{static init(){let e;for(e in gS.types={avc1:[],avcC:[],hvc1:[],hvcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],dac3:[],"ac-3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},gS.types)gS.types.hasOwnProperty(e)&&(gS.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);gS.HDLR_TYPES={video:new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),audio:new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0])};let t=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]);gS.STTS=gS.STSC=gS.STCO=new Uint8Array([0,0,0,0,0,0,0,0]),gS.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),gS.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),gS.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),gS.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);let i=new Uint8Array([105,115,111,109]),s=new Uint8Array([97,118,99,49]),r=new Uint8Array([0,0,0,1]);gS.FTYP=gS.box(gS.types.ftyp,i,r,i,s),gS.DINF=gS.box(gS.types.dinf,gS.box(gS.types.dref,t))}static box(e,...t){let i=8,s=t.length,r=s;for(;s--;)i+=t[s].byteLength;let a=new Uint8Array(i);for(a[0]=i>>24&255,a[1]=i>>16&255,a[2]=i>>8&255,a[3]=255&i,a.set(e,4),s=0,i=8;s<r;s++)a.set(t[s],i),i+=t[s].byteLength;return a}static hdlr(e){return gS.box(gS.types.hdlr,gS.HDLR_TYPES[e])}static mdat(e){return gS.box(gS.types.mdat,e)}static mdhd(e,t){let i=Math.floor((t*=e)/0x100000000),s=Math.floor(t%0x100000000);return gS.box(gS.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,i>>24,i>>16&255,i>>8&255,255&i,s>>24,s>>16&255,s>>8&255,255&s,85,196,0,0]))}static mdia(e){return gS.box(gS.types.mdia,gS.mdhd(e.timescale||0,e.duration||0),gS.hdlr(e.type),gS.minf(e))}static mfhd(e){return gS.box(gS.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e]))}static minf(e){return"audio"===e.type?gS.box(gS.types.minf,gS.box(gS.types.smhd,gS.SMHD),gS.DINF,gS.stbl(e)):gS.box(gS.types.minf,gS.box(gS.types.vmhd,gS.VMHD),gS.DINF,gS.stbl(e))}static moof(e,t,i){return gS.box(gS.types.moof,gS.mfhd(e),gS.traf(i,t))}static moov(e){let t=e.length,i=[];for(;t--;)i[t]=gS.trak(e[t]);return gS.box.apply(null,[gS.types.moov,gS.mvhd(e[0].timescale||0,e[0].duration||0)].concat(i).c
9oncat(gS.mvex(e)))}static mvex(e){let t=e.length,i=[];for(;t--;)i[t]=gS.trex(e[t]);return gS.box.apply(null,[gS.types.mvex,...i])}static mvhd(e,t){let i=Math.floor((t*=e)/0x100000000),s=Math.floor(t%0x100000000),r=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,i>>24,i>>16&255,i>>8&255,255&i,s>>24,s>>16&255,s>>8&255,255&s,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return gS.box(gS.types.mvhd,r)}static sdtp(e){let t,i,s=e.samples||[],r=new Uint8Array(4+s.length);for(t=0;t<s.length;t++)i=s[t].flags,r[t+4]=i.dependsOn<<4|i.isDependedOn<<2|i.hasRedundancy;return gS.box(gS.types.sdtp,r)}static stbl(e){return gS.box(gS.types.stbl,gS.stsd(e),gS.box(gS.types.stts,gS.STTS),gS.box(gS.types.stsc,gS.STSC),gS.box(gS.types.stsz,gS.STSZ),gS.box(gS.types.stco,gS.STCO))}static avc1(e){let t,i,s,r=[],a=[];for(t=0;t<e.sps.length;t++)s=(i=e.sps[t]).byteLength,r.push(s>>>8&255),r.push(255&s),r=r.concat(Array.prototype.slice.call(i));for(t=0;t<e.pps.length;t++)s=(i=e.pps[t]).byteLength,a.push(s>>>8&255),a.push(255&s),a=a.concat(Array.prototype.slice.call(i));let n=gS.box(gS.types.avcC,new Uint8Array([1,r[3],r[4],r[5],255,224|e.sps.length].concat(r).concat([e.pps.length]).concat(a))),l=e.width,o=e.height,d=e.pixelRatio[0],h=e.pixelRatio[1];return gS.box(gS.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,l>>8&255,255&l,o>>8&255,255&o,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),n,gS.box(gS.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),gS.box(gS.types.pasp,new Uint8Array([d>>24,d>>16&255,d>>8&255,255&d,h>>24,h>>16&255,h>>8&255,255&h])))}static esds(e){return new Uint8Array([0,0,0,0,3,25,0,1,0,4,17,64,21,0,0,0,0,0,0,0,0,0,0,0,5,2,...e.config,6,1,2])}static audioStsd(e){let t=e.samplerate||0;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount||0,0,16,0,0,0,0,t>>8&255,255&t,0,0])}static mp4a(e){return gS.box(gS.types.mp4a,gS.audioStsd(e),gS.box(gS.types.esds,gS.esds(e)))}static mp3(e){return gS.box(gS.types[".mp3"],gS.audioStsd(e))}static ac3(e){return gS.box(gS.types["ac-3"],gS.audioStsd(e),gS.box(gS.types.dac3,e.config))}static stsd(e){let{segmentCodec:t}=e;if("audio"===e.type){if("aac"===t)return gS.box(gS.types.stsd,gS.STSD,gS.mp4a(e));if("ac3"===t&&e.config)return gS.box(gS.types.stsd,gS.STSD,gS.ac3(e));if("mp3"===t&&"mp3"===e.codec)return gS.box(gS.types.stsd,gS.STSD,gS.mp3(e))}else if(e.pps&&e.sps){if("avc"===t)return gS.box(gS.types.stsd,gS.STSD,gS.avc1(e));if("hevc"===t&&e.vps)return gS.box(gS.types.stsd,gS.STSD,gS.hvc1(e))}else throw Error("video track missing pps or sps");throw Error(`unsupported ${e.type} segment codec (${t}/${e.codec})`)}static tkhd(e){let t=e.id,i=(e.duration||0)*(e.timescale||0),s=e.width||0,r=e.height||0,a=Math.floor(i/0x100000000),n=Math.floor(i%0x100000000);return gS.box(gS.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,0,0,0,0,a>>24,a>>16&255,a>>8&255,255&a,n>>24,n>>16&255,n>>8&255,255&n,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,s>>8&255,255&s,0,0,r>>8&255,255&r,0,0]))}static traf(e,t){let i=gS.sdtp(e),s=e.id,r=Math.floor(t/0x100000000),a=Math.floor(t%0x100000000);return gS.box(gS.types.traf,gS.box(gS.types.tfhd,new Uint8Array([0,0,0,0,s>>24,s>>16&255,s>>8&255,255&s])),gS.box(gS.types.tfdt,new Uint8Array([1,0,0,0,r>>24,r>>16&255,r>>8&255,255&r,a>>24,a>>16&255,a>>8&255,255&a])),gS.trun(e,i.length+16+20+8+16+8+8),i)}static trak(e){return e.duration=e.duration||0xffffffff,gS.box(gS.types.trak,gS.tkhd(e),gS.mdia(e))}static trex(e){let t=e.id;return gS.box(gS.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(e,t){let i,s,r,a,n,l,o=e.samples||[],d=o.length,h=12+16*d,u=new Uint8Array(h);for(t+=8+h,u.set([+("video"===e.type),0,15,1,d>>>24&255,d>>>16&255,d>>>8&255,255&d,t>>>24&255,t>>>16&255,t>>>8&255,255&t],0),i=0;i<d;i++)r=(s=o[i]).duration,a=s.size,n=s.flags,l=s.cts,u.set([r>>>24&255,r>>>16&255,r>>>8&255,255&r,a>>>24&255,a>>>16&255,a>>>8&255,255&a,n.isLeading<<2|n.dependsOn,n.isDependedOn<<6|n.hasRedundancy<<4|n.paddingValue<<1|n.isNonSync,61440&n.degradPrio,15&n.degradPrio,l>>>24&255,l>>>16&255,l>>>8&255,255&l],12+16*i);return gS.box(gS.types.trun,u)}static initSegment(e){gS.types||gS.init();let t=gS.moov(e);return fu(gS.FTYP,t)}static hvc1(e){let t=e.params,i=[e.vps,e.sps,e.pps],s=new Uint8Array([1,t.general_profile_space<<6|32*!!t.general_tier_flag|t.general_profile_idc,t.general_profile_compatibility_flags[0],t.general_profile_compatibility_flags[1],t.general_profile_compatibility_flags[2],t.general_profile_compatibility_flags[3],t.general_constraint_indicator_flags[0],t.general_constraint_indicator_flags[1],t.general_constraint_indicator_flags[2],t.general_constraint_indicator_flags[3],t.general_constraint_indicator_flags[4],t.general_constraint_indicator_flags[5],t.general_level_idc,240|t.min_spatial_segmentation_idc>>8,255&t.min_spatial_segmentation_idc,252|t.parallelismType,252|t.chroma_format_idc,248|t.bit_depth_luma_minus8,248|t.bit_depth_chroma_minus8,0,parseInt(t.frame_rate.fps),3|t.temporal_id_nested<<2|t.num_temporal_layers<<3|64*!!t.frame_rate.fixed,i.length]),r=s.length;for(let e=0;e<i.length;e+=1){r+=3;for(let t=0;t<i[e].length;t+=1)r+=2+i[e][t].length}let a=new Uint8Array(r);a.set(s,0),r=s.length;let n=i.length-1;for(let e=0;e<i.length;e+=1){a.set(new Uint8Array([32+e|128*(e===n),0,i[e].length]),r),r+=3;for(let t=0;t<i[e].length;t+=1)a.set(new Uint8Array([i[e][t].length>>8,255&i[e][t].length]),r),r+=2,a.set(i[e][t],r),r+=i[e][t].length}let l=gS.box(gS.types.hvcC,a),o=e.width,d=e.height,h=e.pixelRatio[0],u=e.pixelRatio[1];return gS.box(gS.types.hvc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,o>>8&255,255&o,d>>8&255,255&d,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),l,gS.box(gS.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),gS.box(gS.types.pasp,new Uint8Array([h>>24,h>>16&255,h>>8&255,255&h,u>>24,u>>16&255,u>>8&255,255&u])))}}function gT(e,t,i=1,s=!1){let r=e*t*i;return s?Math.round(r):r}function gx(e,t=!1){return gT(e,1e3,11111111111111112e-21,t)}
9function gk(e){let{baseTime:t,timescale:i,trackId:s}=e;return`${t/i} (${t}/${i}) trackId: ${s}`}gS.types=void 0,gS.HDLR_TYPES=void 0,gS.STTS=void 0,gS.STSC=void 0,gS.STCO=void 0,gS.STSZ=void 0,gS.VMHD=void 0,gS.SMHD=void 0,gS.STSD=void 0,gS.FTYP=void 0,gS.DINF=void 0;let gw=null,gA=null;function gR(e,t,i,s){return{duration:t,size:i,cts:s,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:e?2:1,isNonSync:+!e}}}class gL extends cB{constructor(e,t,i,s){if(super("mp4-remuxer",s),this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextVideoTs=null,this.nextAudioTs=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.videoTrackConfig=void 0,this.observer=e,this.config=t,this.typeSupported=i,this.ISGenerated=!1,null===gw){const e=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);gw=e?parseInt(e[1]):0}if(null===gA){const e=navigator.userAgent.match(/Safari\/(\d+)/i);gA=e?parseInt(e[1]):0}}destroy(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null}resetTimeStamp(e){let t=this._initPTS;t&&e&&e.trackId===t.trackId&&e.baseTime===t.baseTime&&e.timescale===t.timescale||this.log(`Reset initPTS: ${t?gk(t):t} > ${e?gk(e):e}`),this._initPTS=this._initDTS=e}resetNextTimestamp(){this.log("reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){this.log("ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0}getVideoStartPts(e){let t=!1,i=e[0].pts,s=e.reduce((e,s)=>{let r=s.pts,a=r-e;return(a<-0x100000000&&(t=!0,a=(r=gC(r,i))-e),a>0)?e:r},i);return t&&this.debug("PTS rollover detected"),s}remux(e,t,i,s,r,a,n,l){let o,d,h,u,c,f,p=r,m=r,g=e.pid>-1,y=t.pid>-1,v=t.samples.length,b=e.samples.length>0,E=n&&v>0||v>1;if((!g||b)&&(!y||E)||this.ISGenerated||n){let i;if(this.ISGenerated){var S,T,x,k;let e=this.videoTrackConfig;(e&&(t.width!==e.width||t.height!==e.height||(null==(S=t.pixelRatio)?void 0:S[0])!==(null==(T=e.pixelRatio)?void 0:T[0])||(null==(x=t.pixelRatio)?void 0:x[1])!==(null==(k=e.pixelRatio)?void 0:k[1]))||!e&&E||null===this.nextAudioTs&&b)&&this.resetInitSegment()}this.ISGenerated||(h=this.generateIS(e,t,r,a));let s=this.isVideoContiguous,n=-1;if(E&&(n=function(e){for(let t=0;t<e.length;t++)if(e[t].key)return t;return -1}(t.samples),!s&&this.config.forceKeyFrameOnDiscontinuity))if(f=!0,n>0){this.warn(`Dropped ${n} out of ${v} video samples due to a missing keyframe`);let e=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(n),t.dropped+=n,m+=(t.samples[0].pts-e)/t.inputTimeScale,i=m}else -1===n&&(this.warn(`No keyframe found out of ${v} video samples`),f=!1);if(this.ISGenerated){if(b&&E){let i=this.getVideoStartPts(t.samples),s=(gC(e.samples[0].pts,i)-i)/t.inputTimeScale;p+=Math.max(0,s),m+=Math.max(0,-s)}if(b){if(e.samplerate||(this.warn("regenerate InitSegment as audio detected"),h=this.generateIS(e,t,r,a)),d=this.remuxAudio(e,p,this.isAudioContiguous,a,y||E||l===cD?m:void 0),E){let i=d?d.endPTS-d.startPTS:0;t.inputTimeScale||(this.warn("regenerate InitSegment as video detected"),h=this.generateIS(e,t,r,a)),o=this.remuxVideo(t,m,s,i)}}else E&&(o=this.remuxVideo(t,m,s,0));o&&(o.firstKeyFrame=n,o.independent=-1!==n,o.firstKeyFramePTS=i)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(i.samples.length&&(c=gI(i,r,this._initPTS,this._initDTS)),s.samples.length&&(u=gP(s,r,this._initPTS))),{audio:d,video:o,initSegment:h,independent:f,text:u,id3:c}}computeInitPts(e,t,i,s){let r=Math.round(i*t),a=gC(e,r);if(a<r+t)for(this.log(`Adjusting PTS for rollover in timeline near ${(r-a)/t} ${s}`);a<r+t;)a+=0x200000000;return a-r}generateIS(e,t,i,s){let r,a,n,l=e.samples,o=t.samples,d=this.typeSupported,h={},u=this._initPTS,c=!u||s,f="audio/mp4",p=-1;if(c&&(r=a=1/0),e.config&&l.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":d.mpeg?(f="audio/mpeg",e.codec=""):d.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3"}h.audio={id:"audio",container:f,codec:e.codec,initSegment:"mp3"===e.segmentCodec&&d.mpeg?new Uint8Array(0):gS.initSegment([e]),metadata:{channelCount:e.channelCount}},c&&(p=e.id,n=e.inputTimeScale,u&&n===u.timescale?c=!1:r=a=this.computeInitPts(l[0].pts,n,i,"audio"))}if(t.sps&&t.pps&&o.length){if(t.timescale=t.inputTimeScale,h.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:gS.initSegment([t]),metadata:{width:t.width,height:t.height}},c)if(p=t.id,n=t.inputTimeScale,u&&n===u.timescale)c=!1;else{let e=this.getVideoStartPts(o),t=gC(o[0].dts,e),s=this.computeInitPts(t,n,i,"video"),l=this.computeInitPts(e,n,i,"video");a=Math.min(a,s),r=Math.min(r,l)}this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(h).length)return this.ISGenerated=!0,c?(u&&this.warn(`Timestamps at playlist time: ${s?"":"~"}${i} ${r/n} != initPTS: ${u.baseTime/u.timescale} (${u.baseTime}/${u.timescale}) trackId: ${u.trackId}`),this.log(`Found initPTS at playlist time: ${i} offset: ${r/n} (${r}/${n}) trackId: ${p}`),this._initPTS={baseTime:r,timescale:n,trackId:p},this._initDTS={baseTime:a,timescale:n,trackId:p}):r=n=void 0,{tracks:h,initPTS:r,timescale:n,trackId:p}}remuxVideo(e,t,i,s){let r,a,n,l=e.inputTimeScale,o=e.samples,d=[],h=o.length,u=this._initPTS,c=u.baseTime*l/u.timescale,f=this.nextVideoTs,p=8,m=this.videoSampleDuration,g=1/0,y=-1/0,v=!1;if(!i||null===f){let e=c+t*l,s=o[0].pts-gC(o[0].dts,o[0].pts);gw&&null!==f&&15e3>Math.abs(e-s-(f+c))?i=!0:f=e-s-c}let b=f+c;for(let e=0;e<h;
9e++){let t=o[e];t.pts=gC(t.pts,b),t.dts=gC(t.dts,b),t.dts<o[e>0?e-1:e].dts&&(v=!0)}v&&o.sort(function(e,t){let i=e.dts-t.dts,s=e.pts-t.pts;return i||s}),r=o[0].dts;let E=(a=o[o.length-1].dts)-r,S=E?Math.round(E/(h-1)):m||e.inputTimeScale/30;if(i){let i=r-b,s=i>S,a=i<-1;if((s||a)&&(s?this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${gx(i,!0)} ms (${i}dts) hole between fragments detected at ${t.toFixed(3)}`):this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${gx(-i,!0)} ms (${i}dts) overlapping between fragments detected at ${t.toFixed(3)}`),!a||b>=o[0].pts||gw)){r=b;let e=o[0].pts-i;if(s)o[0].dts=r,o[0].pts=e;else{let t=!0;for(let s=0;s<o.length&&(!(o[s].dts>e)||!t);s++){let e=o[s].pts;if(o[s].dts-=i,o[s].pts-=i,s<o.length-1){let i=o[s+1].pts;t=i<=o[s].pts==i<=e}}}this.log(`Video: Initial PTS/DTS adjusted: ${gx(e,!0)}/${gx(r,!0)}, delta: ${gx(i,!0)} ms`)}}let T=0,x=0,k=r=Math.max(0,r);for(let e=0;e<h;e++){let t=o[e],i=t.units,s=i.length,r=0;for(let e=0;e<s;e++)r+=i[e].data.length;x+=r,T+=s,t.length=r,t.dts<k?(t.dts=k,k+=S/4|0||1):k=t.dts,g=Math.min(t.pts,g),y=Math.max(t.pts,y)}a=o[h-1].dts;let w=x+4*T+8;try{n=new Uint8Array(w)}catch(e){this.observer.emit(cA.ERROR,cA.ERROR,{type:ck.MUX_ERROR,details:cw.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:w,reason:`fail allocating video mdat ${w}`});return}let A=new DataView(n.buffer);A.setUint32(0,w),n.set(gS.types.mdat,4);let R=!1,L=1/0,C=1/0,I=-1/0,P=-1/0;for(let e=0;e<h;e++){let t,i=o[e],r=i.units,a=0;for(let e=0,t=r.length;e<t;e++){let t=r[e],i=t.data,s=t.data.byteLength;A.setUint32(p,s),p+=4,n.set(i,p),p+=s,a+=4+s}if(e<h-1)m=o[e+1].dts-i.dts,t=o[e+1].pts-i.pts;else{let r=this.config,a=e>0?i.dts-o[e-1].dts:S;if(t=e>0?i.pts-o[e-1].pts:S,r.stretchShortVideoTrack&&null!==this.nextAudioTs){let e=Math.floor(r.maxBufferHole*l),t=(s?g+s*l:this.nextAudioTs+c)-i.pts;t>e?((m=t-a)<0?m=a:R=!0,this.log(`It is approximately ${t/90} ms to the next segment; using duration ${m/90} ms for the last video frame.`)):m=a}else m=a}let u=Math.round(i.pts-i.dts);L=Math.min(L,m),I=Math.max(I,m),C=Math.min(C,t),P=Math.max(P,t),d.push(gR(i.key,m,a,u))}if(d.length){if(gw){if(gw<70){let e=d[0].flags;e.dependsOn=2,e.isNonSync=0}}else if(gA&&P-C<I-L&&S/I<.025&&0===d[0].cts){this.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let e=r;for(let t=0,i=d.length;t<i;t++){let s=e+d[t].duration,r=e+d[t].cts;if(t<i-1){let e=s+d[t+1].cts;d[t].duration=e-r}else d[t].duration=t?d[t-1].duration:S;d[t].cts=0,e=s}}}let D=a+(m=R||!m?S:m);this.nextVideoTs=f=D-c,this.videoSampleDuration=m,this.isVideoContiguous=!0;let M={data1:gS.moof(e.sequenceNumber++,r,cO(e,{samples:d})),data2:n,startPTS:(g-c)/l,endPTS:(y+m-c)/l,startDTS:(r-c)/l,endDTS:f/l,type:"video",hasAudio:!1,hasVideo:!0,nb:d.length,dropped:e.dropped};return e.samples=[],e.dropped=0,M}getSamplesPerFrame(e){switch(e.segmentCodec){case"mp3":return 1152;case"ac3":return 1536;default:return 1024}}remuxAudio(e,t,i,s,r){let a,n=e.inputTimeScale,l=e.samplerate?e.samplerate:n,o=n/l,d=this.getSamplesPerFrame(e),h=d*o,u=this._initPTS,c="mp3"===e.segmentCodec&&this.typeSupported.mpeg,f=[],p=void 0!==r,m=e.samples,g=8*!c,y=this.nextAudioTs||-1,v=u.baseTime*n/u.timescale,b=v+t*n;if(this.isAudioContiguous=i=i||m.length&&y>0&&(s&&9e3>Math.abs(b-(y+v))||Math.abs(gC(m[0].pts,b)-(y+v))<20*h),m.forEach(function(e){e.pts=gC(e.pts,b)}),!i||y<0){let e=m.length;if(e!==(m=m.filter(e=>e.pts>=0)).length&&this.warn(`Removed ${m.length-e} of ${e} samples (initPTS ${v} / ${n})`),!m.length)return;y=0===r?0:s&&!p?Math.max(0,b-v):m[0].pts-v}if("aac"===e.segmentCodec){let t=this.config.maxAudioFramesDrift;for(let i=0,s=y+v;i<m.length;i++){let r=m[i],a=r.pts,l=a-s,o=Math.abs(1e3*l/n);
9if(l<=-t*h&&p)0===i&&(this.warn(`Audio frame @ ${(a/n).toFixed(3)}s overlaps marker by ${Math.round(1e3*l/n)} ms.`),this.nextAudioTs=y=a-v,s=a);else if(l>=t*h&&o<1e4&&p){let t=Math.round(l/h);for(s=a-t*h;s<0&&t&&h;)t--,s+=h;0===i&&(this.nextAudioTs=y=s-v),this.warn(`Injecting ${t} audio frames @ ${((s-v)/n).toFixed(3)}s due to ${Math.round(1e3*l/n)} ms gap.`);for(let a=0;a<t;a++){let t=gE.getSilentFrame(e.parsedCodec||e.manifestCodec||e.codec,e.channelCount);t||(this.log("Unable to get silent frame for given audio codec; duplicating last frame instead."),t=r.unit.subarray()),m.splice(i,0,{unit:t,pts:s}),s+=h,i++}}r.pts=s,s+=h}}let E=null,S=null,T=0,x=m.length;for(;x--;)T+=m[x].unit.byteLength;for(let t=0,s=m.length;t<s;t++){let s=m[t],r=s.unit,n=s.pts;if(null!==S)f[t-1].duration=Math.round((n-S)/o);else{if(i&&"aac"===e.segmentCodec&&(n=y+v),E=n,!(T>0))return;T+=g;try{a=new Uint8Array(T)}catch(e){this.observer.emit(cA.ERROR,cA.ERROR,{type:ck.MUX_ERROR,details:cw.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:T,reason:`fail allocating audio mdat ${T}`});return}c||(new DataView(a.buffer).setUint32(0,T),a.set(gS.types.mdat,4))}a.set(r,g);let l=r.byteLength;g+=l,f.push(gR(!0,d,l,0)),S=n}let k=f.length;if(!k)return;let w=f[f.length-1];y=S-v,this.nextAudioTs=y+o*w.duration;let A=c?new Uint8Array(0):gS.moof(e.sequenceNumber++,E/o,cO({},e,{samples:f}));e.samples=[];let R=(E-v)/n,L=this.nextAudioTs/n,C={data1:A,data2:a,startPTS:R,endPTS:L,startDTS:R,endDTS:L,type:"audio",hasAudio:!0,hasVideo:!1,nb:k};return this.isAudioContiguous=!0,C}}function gC(e,t){let i;if(null===t)return e;for(i=t<e?-0x200000000:0x200000000;Math.abs(e-t)>0x100000000;)e+=i;return e}function gI(e,t,i,s){let r=e.samples.length;if(!r)return;let a=e.inputTimeScale;for(let n=0;n<r;n++){let r=e.samples[n];r.pts=gC(r.pts-i.baseTime*a/i.timescale,t*a)/a,r.dts=gC(r.dts-s.baseTime*a/s.timescale,t*a)/a}let n=e.samples;return e.samples=[],{samples:n}}function gP(e,t,i){let s=e.samples.length;if(!s)return;let r=e.inputTimeScale;for(let a=0;a<s;a++){let s=e.samples[a];s.pts=gC(s.pts-i.baseTime*r/i.timescale,t*r)/r}e.samples.sort((e,t)=>e.pts-t.pts);let a=e.samples;return e.samples=[],{samples:a}}function gD(e,t,i=!1){return(null==e?void 0:e.start)!==void 0?(e.start+(i?e.duration:0))/e.timescale:t}function gM(e,t,i){let s=e.codec;return s&&s.length>4?s:t===cZ?"ec-3"===s||"ac-3"===s||"alac"===s?s:"fLaC"===s||"Opus"===s?fw(s,!1):(i.warn(`Unhandled audio codec "${s}" in mp4 MAP`),s||"mp4a"):(i.warn(`Unhandled video codec "${s}" in mp4 MAP`),s||"avc1")}try{i=self.performance.now.bind(self.performance)}catch(e){i=Date.now}let g_=[{demux:class{constructor(e,t){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=t}resetTimeStamp(){}resetInitSegment(e,t,i,s){let r=this.videoTrack=m5("video",1),a=this.audioTrack=m5("audio",1),n=this.txtTrack=m5("text",1);if(this.id3Track=m5("id3",1),this.timeOffset=0,!(null!=e&&e.byteLength))return;let l=fr(e);if(l.video){let{id:e,timescale:t,codec:i,supplemental:s}=l.video;r.id=e,r.timescale=n.timescale=t,r.codec=i,r.supplemental=s}if(l.audio){let{id:e,timescale:t,codec:i}=l.audio;a.id=e,a.timescale=t,a.codec=i}n.id=c6.text,r.sampleDuration=0,r.duration=a.duration=s}resetContiguity(){this.remainderData=null}static probe(e){let t=e.byteLength;for(let i=0;i<t;){let s=fe(e,i);if(s>8&&109===e[i+4]&&111===e[i+5]&&111===e[i+6]&&102===e[i+7])return!0;i=s>1?i+s:t}return!1}demux(e,t){this.timeOffset=t;let i=e,s=this.videoTrack,r=this.txtTrack;if(this.config.progressive){this.remainderData&&(i=fu(this.remainderData,e));let t=function(e){let t={valid:null,remainder:null},i=fs(e,["moof"]);if(i.length<2)return t.remainder=e,t;let s=i[i.length-1];return t.valid=e.slice(0,s.byteOffset-8),t.remainder=e.slice(s.byteOffset-8),t}(i);this.remainderData=t.remainder,s.samples=t.valid||new Uint8Array}else s.samples=i;let a=this.extractID3Track(s,t);
9return r.samples=fc(t,s),{videoTrack:s,audioTrack:this.audioTrack,id3Track:a,textTrack:this.txtTrack}}flush(){let e=this.timeOffset,t=this.videoTrack,i=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;let s=this.extractID3Track(t,this.timeOffset);return i.samples=fc(e,t),{videoTrack:t,audioTrack:m5(),id3Track:s,textTrack:m5()}}extractID3Track(e,t){let i=this.id3Track;return e.samples.length&&fs(e.samples,["emsg"]).forEach(e=>{let s=function(e){let t=e[0],i="",s="",r=0,a=0,n=0,l=0,o=0,d=0;if(0===t){for(;"\0"!==c7(e.subarray(d,d+1));)i+=c7(e.subarray(d,d+1)),d+=1;for(i+=c7(e.subarray(d,d+1)),d+=1;"\0"!==c7(e.subarray(d,d+1));)s+=c7(e.subarray(d,d+1)),d+=1;s+=c7(e.subarray(d,d+1)),d+=1,r=fe(e,12),a=fe(e,16),l=fe(e,20),o=fe(e,24),d=28}else if(1===t){d+=4,r=fe(e,d);let t=fe(e,d+=4),a=fe(e,d+=4);for(d+=4,cT(n=0x100000000*t+a)||(n=Number.MAX_SAFE_INTEGER,cq.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),l=fe(e,d),d+=4,o=fe(e,d),d+=4;"\0"!==c7(e.subarray(d,d+1));)i+=c7(e.subarray(d,d+1)),d+=1;for(i+=c7(e.subarray(d,d+1)),d+=1;"\0"!==c7(e.subarray(d,d+1));)s+=c7(e.subarray(d,d+1)),d+=1;s+=c7(e.subarray(d,d+1)),d+=1}return{schemeIdUri:i,value:s,timeScale:r,presentationTime:n,presentationTimeDelta:a,eventDuration:l,id:o,payload:e.subarray(d,e.byteLength)}}(e);if(go.test(s.schemeIdUri)){let e=gd(s,t),r=0xffffffff===s.eventDuration?1/0:s.eventDuration/s.timeScale;r<=.001&&(r=1/0);let a=s.payload;i.samples.push({data:a,len:a.byteLength,dts:e,pts:e,type:m2.emsg,duration:r})}else if(this.config.enableEmsgKLVMetadata&&s.schemeIdUri.startsWith("urn:misb:KLV:bin:1910.1")){let e=gd(s,t);i.samples.push({data:s.payload,len:s.payload.byteLength,dts:e,pts:e,type:m2.misbklv,duration:1/0})}}),i}demuxSampleAes(e,t,i){return Promise.reject(Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){this.config=null,this.remainderData=null,this.videoTrack=this.audioTrack=this.id3Track=this.txtTrack=void 0}},remux:class extends cB{constructor(e,t,i,s){super("passthrough-remuxer",s),this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null,this.isVideoContiguous=!1}destroy(){}resetTimeStamp(e){this.lastEndTime=null;let t=this.initPTS;t&&e&&t.baseTime===e.baseTime&&t.timescale===e.timescale||(this.initPTS=e)}resetNextTimestamp(){this.isVideoContiguous=!1,this.lastEndTime=null}resetInitSegment(e,t,i,s){this.audioCodec=t,this.videoCodec=i,this.generateInitSegment(e,s),this.emitInitSegment=!0}generateInitSegment(e,t){let{audioCodec:i,videoCodec:s}=this;if(!(null!=e&&e.byteLength)){this.initTracks=void 0,this.initData=void 0;return}let{audio:r,video:a}=this.initData=fr(e);if(t)!function(e,t){if(!e||!t)return;let i=t.keyId;i&&t.isCommonEncryption&&fd(e,(e,t)=>{let s=e.subarray(8,24);s.some(e=>0!==e)||(cq.log(`[eme] Patching keyId in 'enc${t?"a":"v"}>sinf>>tenc' box: ${cz(s)} -> ${cz(i)}`),e.set(i,8))})}(e,t);else{let e=r||a;null!=e&&e.encrypted&&this.warn(`Init segment with encrypted track with has no key ("${e.codec}")!`)}r&&(i=gM(r,cZ,this)),a&&(s=gM(a,c0,this));let n={};r&&a?n.audiovideo={container:"video/mp4",codec:i+","+s,supplemental:a.supplemental,encrypted:a.encrypted,initSegment:e,id:"main"}:r?n.audio={container:"audio/mp4",codec:i,encrypted:r.encrypted,initSegment:e,id:"audio"}:a?n.video={container:"video/mp4",codec:s,supplemental:a.supplemental,encrypted:a.encrypted,initSegment:e,id:"main"}:this.warn("initSegment does not contain moov or trak boxes."),this.initTracks=n}remux(e,t,i,s,r,a){var n,l;let{initPTS:o,lastEndTime:d}=this,h={audio:void 0,video:void 0,text:s,id3:i,initSegment:void 0};cS(d)||(d=this.lastEndTime=r||0);let u=t.samples;if(!u.length)return h;let c={initPTS:void 0,timescale:void 0,trackId:void 0},f=this.initData;if(null!=(n=f)&&n.length||(this.generateInitSegment(u),f=this.initData),!(null!=(l=f)&&l.length))return this.warn("Failed to generate initSegment."),h;this.emitInitSegment&&(c.tracks=this.initTracks,this.emitInitSegment=!1);let p=function(e,t,i){let s={},r=fs(e,["moof","traf"]);for(let e=0;e<r.length;e++){let a=r[e],n=fs(a,["tfhd"])[0],l=fe(n,4),o=t[l];if(!o)continue;s[l]||(s[l]={start:NaN,duration:0,sampleCount:0,timescale:o.timescale,type:o.type});let d=s[l],h=fs(a,["tfdt"])[0];if(h){let e=h[0],t=fe(h,4);1===e&&(0xffffffff===t?i.warn("[mp4-demuxer]: Ignoring assumed invali
9d signed 64-bit track fragment decode time"):(t*=0x100000000,t+=fe(h,8))),cS(t)&&(!cS(d.start)||t<d.start)&&(d.start=t)}let u=o.default,c=fe(n,0)|(null==u?void 0:u.flags),f=(null==u?void 0:u.duration)||0;8&c&&(f=2&c?fe(n,12):fe(n,8));let p=fs(a,["trun"]),m=d.start||0,g=0,y=f;for(let e=0;e<p.length;e++){let t=p[e],i=fe(t,4),s=d.sampleCount;d.sampleCount+=i;let r=1&t[3],a=4&t[3],n=1&t[2],l=2&t[2],o=4&t[2],h=8&t[2],u=8,c=i;for(r&&(u+=4),a&&i&&(1&t[u+1]||void 0!==d.keyFrameIndex||(d.keyFrameIndex=s),u+=4,n?(y=fe(t,u),u+=4):y=f,l&&(u+=4),h&&(u+=4),m+=y,g+=y,c--);c--;)n?(y=fe(t,u),u+=4):y=f,l&&(u+=4),o&&(1&t[u+1]||void 0!==d.keyFrameIndex||(d.keyFrameIndex=d.sampleCount-(c+1),d.keyFrameStart=m),u+=4),h&&(u+=4),m+=y,g+=y;!g&&f&&(g+=f*i)}d.duration+=g}if(!Object.keys(s).some(e=>s[e].duration)){let t=1/0,i=0,r=fs(e,["sidx"]);for(let e=0;e<r.length;e++){let s=function(e){let t=[],i=e[0],s=8,r=fe(e,8);s+=4;let a=0,n=0;0===i?(a=fe(e,s),n=fe(e,s+4),s+=8):(a=ft(e,s),n=ft(e,s+8),s+=16),s+=2;let l=e.length+n,o=c9(e,s);s+=2;for(let i=0;i<o;i++){let i=s,a=fe(e,i);i+=4;let n=0x7fffffff&a;if(1==(0x80000000&a)>>>31)return cq.warn("SIDX has hierarchical references (not supported)"),null;let o=fe(e,i);i+=4,t.push({referenceSize:n,subsegmentDuration:o,info:{duration:o/r,start:l,end:l+n-1}}),l+=n,i+=4,s=i}return{earliestPresentationTime:a,timescale:r,version:i,referencesCount:o,references:t}}(r[e]);if(null!=s&&s.references){t=Math.min(t,s.earliestPresentationTime/s.timescale);let e=s.references.reduce((e,t)=>e+t.info.duration||0,0);i=Math.max(i,e+s.earliestPresentationTime/s.timescale)}}i&&cS(i)&&Object.keys(s).forEach(e=>{s[e].duration||(s[e].duration=i*s[e].timescale-s[e].start)})}return s}(u,f,this),m=f.audio?p[f.audio.id]:null,g=f.video?p[f.video.id]:null,y=gD(g,1/0),v=gD(m,1/0),b=gD(g,0,!0),E=gD(m,0,!0),S=r,T=0,x=m&&(!g||!o&&v<y||o&&o.trackId===f.audio.id),k=x?m:g;if(k){let e=k.timescale,t=k.start-r*e,i=x?f.audio.id:f.video.id;S=k.start/e,T=x?E-v:b-y,(a||!o)&&(function(e,t,i,s){if(null===e)return!0;let r=Math.max(s,1);return Math.abs(t-e.baseTime/e.timescale-i)>r}(o,S,r,T)||e!==o.timescale)&&(o&&this.warn(`Timestamps at playlist time: ${a?"":"~"}${r} ${t/e} != initPTS: ${o.baseTime/o.timescale} (${o.baseTime}/${o.timescale}) trackId: ${o.trackId}`),this.log(`Found initPTS at playlist time: ${r} offset: ${S-r} (${t}/${e}) trackId: ${i}`),o=null,c.initPTS=t,c.timescale=e,c.trackId=i)}else this.warn(`No audio or video samples found for initPTS at playlist time: ${r}`);o?(c.initPTS=o.baseTime,c.timescale=o.timescale,c.trackId=o.trackId):(c.timescale&&void 0!==c.trackId&&void 0!==c.initPTS||(this.warn("Could not set initPTS"),c.initPTS=S,c.timescale=1,c.trackId=-1),this.initPTS=o={baseTime:c.initPTS,timescale:c.timescale,trackId:c.trackId});let w=S-o.baseTime/o.timescale,A=w+T;T>0?this.lastEndTime=A:(this.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());let R=!!f.audio,L=!!f.video,C="";R&&(C+="audio"),L&&(C+="video");let I={data1:u,startPTS:w,startDTS:w,endPTS:A,endDTS:A,type:C,hasAudio:R,hasVideo:L,nb:1,dropped:0,encrypted:!!f.audio&&f.audio.encrypted||!!f.video&&f.video.encrypted};h.audio=R&&!L?I:void 0,h.video=L?I:void 0;let P=null==g?void 0:g.sampleCount;if(P){let e=g.keyFrameIndex,t=-1!==e;I.nb=P,I.dropped=0===e||this.isVideoContiguous?0:t?e:P,I.independent=t,I.firstKeyFrame=e,t&&g.keyFrameStart&&(I.firstKeyFramePTS=(g.keyFrameStart-o.baseTime)/o.timescale),this.isVideoContiguous||(h.independent=t),this.isVideoContiguous||(this.isVideoContiguous=t),I.dropped&&this.warn(`fmp4 does not start with IDR: firstIDR ${e}/${P} dropped: ${I.dropped} start: ${I.firstKeyFramePTS||"NA"}`)}return h.initSegment=c,h.id3=gI(i,r,o,o),s.samples.length&&(h.text=gP(s,r,o)),h}}},{demux:gm,remux:gL},{demux:class extends m3{constructor(e,t){super(),this.observer=void 0,this.config=void 0,this.observer=e,this.config=t}resetInitSegment(e,t,i,s){super.resetInitSegment(e,t,i,s),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}static probe(e,t){if(!e)return!1;let i=mH(e,0),s=(null==i?void 0:i.length)||0;if(ga(e,s))return!1;for(let i=e.length;s<i;s++)if(function(e,t){if(mY(e,t)){let i=mW(e,t);if(t+i>=e.length)return!1;let s=mz(e,t);if(s<=i)return!1;let r=t+s;return r===e.length||mY(e,r)}return!1}
9(e,s))return t.log("ADTS sync word found !"),!0;return!1}canParse(e,t){return t+5<e.length&&mK(e,t)&&mz(e,t)<=e.length-t}appendFrame(e,t,i){mQ(e,this.observer,t,i,e.manifestCodec);let s=mX(e,t,i,this.basePTS,this.frameIndex);if(s&&0===s.missing)return s}},remux:gL},{demux:class extends m3{resetInitSegment(e,t,i,s){super.resetInitSegment(e,t,i,s),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;let t=mH(e,0),i=(null==t?void 0:t.length)||0;if(t&&11===e[i]&&119===e[i+1]&&void 0!==m1(t)&&16>=gn(e,i))return!1;for(let t=e.length;i<t;i++)if(ga(e,i))return cq.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return gs(e,t)&&4<=e.length-t}appendFrame(e,t,i){if(null!==this.basePTS)return gt(e,t,i,this.basePTS,this.frameIndex)}},remux:gL}];g_.splice(2,0,{demux:class extends m3{constructor(e){super(),this.observer=void 0,this.observer=e}resetInitSegment(e,t,i,s){super.resetInitSegment(e,t,i,s),this._audioTrack={container:"audio/ac-3",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"ac3",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}canParse(e,t){return t+64<e.length}appendFrame(e,t,i){let s=gl(e,t,i,this.basePTS,this.frameIndex);if(-1!==s)return{sample:e.samples[e.samples.length-1],length:s,missing:0}}static probe(e){if(!e)return!1;let t=mH(e,0);if(!t)return!1;let i=t.length;return!!(11===e[i]&&119===e[i+1]&&void 0!==m1(t)&&16>gn(e,i))}},remux:gL});class g${constructor(e,t,i,s,r,a){this.asyncResult=!1,this.logger=void 0,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=e,this.typeSupported=t,this.config=i,this.id=r,this.logger=a}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(e,t,s,r){var a,n;let l,o=s.transmuxing;o.executeStart=i();let d=new Uint8Array(e),{currentTransmuxState:h,transmuxConfig:u}=this;r&&(this.currentTransmuxState=r);let{contiguous:c,discontinuity:f,trackSwitch:p,accurateTimeOffset:m,timeOffset:g,initSegmentChange:y}=r||h,{audioCodec:v,videoCodec:b,defaultInitPts:E,duration:S,initSegmentData:T}=u,x=(a=d,n=t,l=null,a.byteLength>0&&(null==n?void 0:n.key)!=null&&null!==n.iv&&null!=n.method&&(l=n),l);if(x&&pC(x.method)){let e=this.getDecrypter(),t=pI(x.method);if(!e.isSync())return this.asyncResult=!0,this.decryptionPromise=e.webCryptoDecrypt(d,x.key.buffer,x.iv.buffer,t).then(e=>{let t=this.push(e,null,s);return this.decryptionPromise=null,t}),this.decryptionPromise;{let r=e.softwareDecrypt(d,x.key.buffer,x.iv.buffer,t);if(s.part>-1){let t=e.flush();r=t?t.buffer:t}if(!r)return o.executeEnd=i(),gO(s);d=new Uint8Array(r)}}let k=this.needsProbing(f,p);if(k){let e=this.configureTransmuxer(d);if(e)return this.logger.warn(`[transmuxer] ${e.message}`),this.observer.emit(cA.ERROR,cA.ERROR,{type:ck.MEDIA_ERROR,details:cw.FRAG_PARSING_ERROR,fatal:!1,error:e,reason:e.message}),o.executeEnd=i(),gO(s)}(f||p||y||k)&&this.resetInitSegment(T,v,b,S,t),(f||y||k)&&this.resetInitialTimestamp(E),c||this.resetContiguity();let w=this.transmux(d,x,g,m,s);this.asyncResult=gN(w);let A=this.currentTransmuxState;return A.contiguous=!0,A.discontinuity=!1,A.trackSwitch=!1,o.executeEnd=i(),w}flush(e){let t=e.transmuxing;t.executeStart=i();let{decrypter:s,currentTransmuxState:r,decryptionPromise:a}=this;if(a)return this.asyncResult=!0,a.then(()=>this.flush(e));let n=[],{timeOffset:l}=r;if(s){let t=s.flush();t&&n.push(this.push(t.buffer,null,e))}let{demuxer:o,remuxer:d}=this;if(!o||!d){t.executeEnd=i();let s=[gO(e)];return this.asyncResult?Promise.resolve(s):s}let h=o.flush(l);return gN(h)?(this.asyncResult=!0,h.then(t=>(this.flushRemux(n,t,e),n))):(this.flushRemux(n,h,e),this.asyncResult)?Promise.resolve(n):n}flushRemux(e,t,s){let{audioTrack:r,videoTrack:a,id3Track:n,textTrack:l}=t,{accurateTimeOffset:o,timeOffset:d}=this.currentTransmuxState;this.logger.log(`[transmuxer.ts]: Flushed ${this.id} sn: ${s.sn}${s.part>-1?" part: "+s.part:""} of ${this.id===cP?"level":"track"} ${s.level}`);let h=this.remuxer.remux(r,a,n,l,d,o,!0,this.id);e.push({remuxResult:h,chunkMeta:s}),s.transmuxing.executeEnd=i()}resetInitialTimestamp(e){let{demuxer:t,remuxer:i}=this;t&&i&&(t.resetTimeStamp(e),i.resetTimeStamp(e))}resetContiguity(){let{demuxer:e,remuxer:t}=this;e&&t&&(e.resetContiguity(),t.resetNextTimestamp())}resetInitSegment(e,t,i,s,r){let{demuxer:a,remuxer:n}=this;a&&n&&(a.resetInitSegment(e,t,i,s),n.resetInitSegment(e,t,i,r))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(e,t,i,s,r){return t&&"SAMPLE-AES"===t.method?this.transmuxSampleAes(e,t,i,s,r):this.transmuxUnencrypted(e,i,s,r)}transmuxUnencrypted(e,t,i,s){let{audioTrack:r,videoTrack:a,id3Track:n,textTrack:l}=this.demuxer.demux(e,t,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(r,a,n,l,t,i,!1,this.id),chunkMeta:s}}transmuxSampleAes(e,t,i,s,r){return this.demuxer.demuxSampleAes(e,t,i).then(e=>({remuxResult:this.remuxer.remux(e.audioTrack,e.videoTrack,e.id3Track,e.textTrack,i,s,!1,this.id),chunkMeta:r}))}
9configureTransmuxer(e){let t,{config:i,observer:s,typeSupported:r}=this;for(let i=0,s=g_.length;i<s;i++){var a;if(null!=(a=g_[i].demux)&&a.probe(e,this.logger)){t=g_[i];break}}if(!t)return Error("Failed to find demuxer by probing fragment data");let n=this.demuxer,l=this.remuxer,o=t.remux,d=t.demux;l&&l instanceof o||(this.remuxer=new o(s,i,r,this.logger)),n&&n instanceof d||(this.demuxer=new d(s,i,r,this.logger),this.probe=d.probe)}needsProbing(e,t){return!this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e||(e=this.decrypter=new pd(this.config)),e}}let gO=e=>({remuxResult:{},chunkMeta:e});function gN(e){return"then"in e&&e.then instanceof Function}class gF{constructor(e,t,i,s,r){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=e,this.videoCodec=t,this.initSegmentData=i,this.duration=s,this.defaultInitPts=r||null}}class gB{constructor(e,t,i,s,r,a){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=e,this.contiguous=t,this.accurateTimeOffset=i,this.trackSwitch=s,this.timeOffset=r,this.initSegmentChange=a}}let gU=0;class gj{constructor(e,t,i,s){this.error=null,this.hls=void 0,this.id=void 0,this.instanceNo=gU++,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.onWorkerMessage=e=>{let t=e.data,i=this.hls;if(i&&null!=t&&t.event&&t.instanceNo===this.instanceNo)switch(t.event){case"init":{var s;let e=null==(s=this.workerContext)?void 0:s.objectURL;e&&self.URL.revokeObjectURL(e);break}case"transmuxComplete":this.handleTransmuxComplete(t.data);break;case"flush":this.onFlush(t.data);break;case"workerLog":i.logger[t.data.logType]&&i.logger[t.data.logType](t.data.message);break;default:t.data=t.data||{},t.data.frag=this.frag,t.data.part=this.part,t.data.id=this.id,i.trigger(t.event,t.data)}},this.onWorkerError=e=>{if(!this.hls)return;let t=Error(`${e.message}  (${e.filename}:${e.lineno})`);this.hls.config.enableWorker=!1,this.hls.logger.warn(`Error in "${this.id}" Web Worker, fallback to inline`),this.hls.trigger(cA.ERROR,{type:ck.OTHER_ERROR,details:cw.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:t})};const r=e.config;this.hls=e,this.id=t,this.useWorker=!!r.enableWorker,this.onTransmuxComplete=i,this.onFlush=s;const a=(e,t)=>{(t=t||{}).frag=this.frag||void 0,e===cA.ERROR&&(t.parent=this.id,t.part=this.part,this.error=t.error),this.hls.trigger(e,t)};this.observer=new mB,this.observer.on(cA.FRAG_DECRYPTED,a),this.observer.on(cA.ERROR,a);const n=fL(r.preferManagedMediaSource);if(this.useWorker&&"u">typeof Worker){const i=this.hls.logger;if(r.workerPath||"function"==typeof __HLS_WORKER_BUNDLE__){try{r.workerPath?(i.log(`loading Web Worker ${r.workerPath} for "${t}"`),this.workerContext=function(e){let t=mj[e];if(t)return t.clientCount++,t;let i=new self.URL(e,self.location.href).href,s={worker:new self.Worker(i),scriptURL:i,clientCount:1};return mj[e]=s,s}(r.workerPath)):(i.log(`injecting Web Worker for "${t}"`),this.workerContext=function(){let e=mj[mU];if(e)return e.clientCount++,e;let t=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),i=self.URL.createObjectURL(t),s={worker:new self.Worker(i),objectURL:i,clientCount:1};return mj[mU]=s,s}());const{worker:e}=this.workerContext;e.addEventListener("message",this.onWorkerMessage),e.addEventListener("error",this.onWorkerError),e.postMessage({instanceNo:this.instanceNo,cmd:"init",typeSupported:n,id:t,config:fj(r)})}catch(s){i.warn(`Error setting up "${t}" Web Worker, fallback to inline`,s),this.terminateWorker(),this.error=null,this.transmuxer=new g$(this.observer,n,r,"",t,e.logger)}return}}this.transmuxer=new g$(this.observer,n,r,"",t,e.logger)}reset(){if(this.frag=null,this.part=null,this.workerContext){let e=this.instanceNo;this.instanceNo=gU++;let t=this.hls.config,i=fL(t.preferManagedMediaSource);this.workerContext.worker.postMessage({instanceNo:this.instanceNo,cmd:"reset",resetNo:e,typeSupp
9orted:i,id:this.id,config:fj(t)})}}terminateWorker(){if(this.workerContext){let{worker:e}=this.workerContext;this.workerContext=null,e.removeEventListener("message",this.onWorkerMessage),e.removeEventListener("error",this.onWorkerError),function(e){let t=mj[e||mU];if(t&&1==t.clientCount--){let{worker:i,objectURL:s}=t;delete mj[e||mU],s&&self.URL.revokeObjectURL(s),i.terminate()}}(this.hls.config.workerPath)}}destroy(){if(this.workerContext)this.terminateWorker(),this.onWorkerMessage=this.onWorkerError=null;else{let e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}let e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.part=null,this.observer=null,this.hls=null}push(e,t,i,s,r,a,n,l,o,d){var h,u;o.transmuxing.start=self.performance.now();let{instanceNo:c,transmuxer:f}=this,p=a?a.start:r.start,m=r.decryptdata,g=this.frag,y=!(g&&r.cc===g.cc),v=!(g&&o.level===g.level),b=g?o.sn-g.sn:-1,E=this.part?o.part-this.part.index:-1,S=0===b&&o.id>1&&o.id===(null==g?void 0:g.stats.chunkCount),T=!v&&(1===b||0===b&&(1===E||S&&E<=0)),x=self.performance.now();(v||b||0===r.stats.parsing.start)&&(r.stats.parsing.start=x),a&&(E||!T)&&(a.stats.parsing.start=x);let k=!(g&&(null==(h=r.initSegment)?void 0:h.url)===(null==(u=g.initSegment)?void 0:u.url)),w=new gB(y,T,l,v,p,k);if(!T||y||k){this.hls.logger.log(`[transmuxer-interface]: Starting new transmux session for ${r.type} sn: ${o.sn}${o.part>-1?" part: "+o.part:""} ${this.id===cP?"level":"track"}: ${o.level} id: ${o.id}
10        discontinuity: ${y}
11        trackSwitch: ${v}
12        contiguous: ${T}
13        accurateTimeOffset: ${l}
14        timeOffset: ${p}
15        initSegmentChange: ${k}`);let e=new gF(i,s,t,n,d);this.configureTransmuxer(e)}if(this.frag=r,this.part=a,this.workerContext)this.workerContext.worker.postMessage({instanceNo:c,cmd:"demux",data:e,decryptdata:m,chunkMeta:o,state:w},e instanceof ArrayBuffer?[e]:[]);else if(f){let t=f.push(e,m,o,w);gN(t)?t.then(e=>{this.handleTransmuxComplete(e)}).catch(e=>{this.transmuxerError(e,o,"transmuxer-interface push error")}):this.handleTransmuxComplete(t)}}flush(e){e.transmuxing.start=self.performance.now();let{instanceNo:t,transmuxer:i}=this;if(this.workerContext)this.workerContext.worker.postMessage({instanceNo:t,cmd:"flush",chunkMeta:e});else if(i){let t=i.flush(e);gN(t)?t.then(t=>{this.handleFlushResult(t,e)}).catch(t=>{this.transmuxerError(t,e,"transmuxer-interface flush error")}):this.handleFlushResult(t,e)}}transmuxerError(e,t,i){this.hls&&(this.error=e,this.hls.trigger(cA.ERROR,{type:ck.MEDIA_ERROR,details:cw.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,part:this.part||void 0,fatal:!1,error:e,err:e,reason:i}))}handleFlushResult(e,t){e.forEach(e=>{this.handleTransmuxComplete(e)}),this.onFlush(t)}configureTransmuxer(e){let{instanceNo:t,transmuxer:i}=this;this.workerContext?this.workerContext.worker.postMessage({instanceNo:t,cmd:"configure",config:e}):i&&i.configure(e)}handleTransmuxComplete(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}}class gV extends cB{constructor(e,t){super(t,e.logger),this.hls=void 0,this.canLoad=!1,this.timer=-1,this.hls=e}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){-1!==this.timer&&(self.clearTimeout(this.timer),this.timer=-1)}startLoad(){this.canLoad=!0,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(e,t,i){let s=null==t?void 0:t.renditionReports;if(s){let r=-1;for(let i=0;i<s.length;i++){let a,n=s[i];try{a=new self.URL(n.URI,t.url).href}catch(e){this.warn(`Could not construct new URL for Rendition Report: ${e}`),a=n.URI||""}if(a===e){r=i;break}a===e.substring(0,a.length)&&(r=i)}if(-1!==r){let e=s[r],a=parseInt(e["LAST-MSN"])||t.lastPartSn,n=parseInt(e["LAST-PART"])||t.lastPartIndex;if(this.hls.config.lowLatencyMode){let e=Math.min(t.age-t.partTarget,t.targetduration);n>=0&&e>t.partTarget&&(n+=1)}return new fF(a,n>=0?n:void 0,i&&fN(i))}}}loadPlaylist(e){this.clearTimer()}loadingPlaylist(e,t){this.clearTimer()}shouldLoadPlaylist(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}getUrlWithDirectives(e,t){if(t)try{return t.addDirectives(e)}catch(e){this.warn(`Could not construct new URL with HLS Delivery Directives: ${e}`)}return e}playlistLoaded(e,t,i){let{details:s,stats:r}=t,a=self.performance.now(),n=r.loading.first?Math.max(0,a-r.loading.first):0;s.advancedDateTime=Date.now()-n;let l=this.hls.config.timelineOffset;
15if(l!==s.appliedTimelineOffset){let e=Math.max(l||0,0);s.appliedTimelineOffset=e,s.fragments.forEach(t=>{t.setStart(t.playlistOffset+e)})}if(s.live||null!=i&&i.live){let l,d,h,u="levelInfo"in t?t.levelInfo:t.track;if(s.reloaded(i),i&&s.fragments.length>0){!function(e,t,i){let s;if(e===t)return;let r=null,a=e.fragments;for(let e=a.length-1;e>=0;e--){let t=a[e].initSegment;if(t){r=t;break}}e.fragmentHint&&delete e.fragmentHint.endPTS,function(e,t,i){let s=t.skippedSegments,r=Math.max(e.startSN,t.startSN)-t.startSN,a=+!!e.fragmentHint+(s?t.endSN:Math.min(e.endSN,t.endSN))-t.startSN,n=t.startSN-e.startSN,l=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,o=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments;for(let u=r;u<=a;u++){let r=o[n+u],a=l[u];if(s&&!a&&r&&(a=t.fragments[u]=r),r&&a){var d,h;i(r,a,u,l);let s=r.relurl,n=a.relurl;if(s&&(d=s)!==(h=n)&&h&&mp(d)!==mp(h)){t.playlistParsingError=mn(`media sequence mismatch ${a.sn}:`,e,t,r,a);return}if(r.cc!==a.cc){t.playlistParsingError=mn(`discontinuity sequence mismatch (${r.cc}!=${a.cc})`,e,t,r,a);return}}}}(e,t,(e,i,a,n)=>{if((!t.startCC||t.skippedSegments)&&i.cc!==e.cc){let s=e.cc-i.cc;for(let e=a;e<n.length;e++)n[e].cc+=s;t.endCC=n[n.length-1].cc}cS(e.startPTS)&&cS(e.endPTS)&&(i.setStart(i.startPTS=e.startPTS),i.startDTS=e.startDTS,i.maxStartPTS=e.maxStartPTS,i.endPTS=e.endPTS,i.endDTS=e.endDTS,i.minEndPTS=e.minEndPTS,i.setDuration(e.endPTS-e.startPTS),i.duration&&(s=i),t.PTSKnown=t.alignedSliding=!0),e.hasStream
15s&&(i.elementaryStreams=e.elementaryStreams),i.loader=e.loader,e.hasStats&&(i.stats=e.stats),e.initSegment&&(i.initSegment=e.initSegment,r=e.initSegment)});let n=t.fragments,l=t.fragmentHint?n.concat(t.fragmentHint):n;if(r&&l.forEach(e=>{var t;e&&(!e.initSegment||e.initSegment.relurl===(null==(t=r)?void 0:t.relurl))&&(e.initSegment=r)}),t.skippedSegments){if(t.deltaUpdateFailed=n.some(e=>!e),t.deltaUpdateFailed){i.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let e=t.skippedSegments;e--;)n.shift();t.startSN=n[0].sn}else{t.canSkipDateRanges&&(t.dateRanges=function(e,t,i){let{dateRanges:s,recentlyRemovedDateranges:r}=t,a=cO({},e);r&&r.forEach(e=>{delete a[e]});let n=Object.keys(a).length;return n?(Object.keys(s).forEach(e=>{let t=a[e],r=new pw(s[e].attr,t);r.isValid?(a[e]=r,t||(r.tagOrder+=n)):i.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${fj(s[e].attr)}"`)}),a):s}(e.dateRanges,t,i));let s=e.fragments.filter(e=>e.rawProgramDateTime);if(e.hasProgramDateTime&&!t.hasProgramDateTime)for(let e=1;e<l.length;e++)null===l[e].programDateTime&&p9(l[e],l[e-1],s);p3(s,t)}t.endCC=n[n.length-1].cc}if(!t.startCC){var o;let i=mh(e,t.startSN-1);t.startCC=null!=(o=null==i?void 0:i.cc)?o:n[0].cc}(function(e,t,i){if(e&&t){let s=0;for(let r=0,a=e.length;r<=a;r++){let a=e[r],n=t[r+s];a&&n&&a.index===n.index&&a.fragment.sn===n.fragment.sn?i(a,n):s--}}})(e.partList,t.partList,(e,t)=>{t.elementaryStreams=e.elementaryStreams,t.stats=e.stats}),s?ma(t,s,s.startPTS,s.endPTS,s.startDTS,s.endDTS,i):ml(e,t),n.length&&(t.totalduration=t.edge-n[0].start),t.driftStartTime=e.driftStartTime,t.driftStart=e.driftStart;let d=t.advancedDateTime;if(t.advanced&&d){let e=t.edge;t.driftStart||(t.driftStartTime=d,t.driftStart=e),t.driftEndTime=d,t.driftEnd=e}else t.driftEndTime=e.driftEndTime,t.driftEnd=e.driftEnd,t.advancedDateTime=e.advancedDateTime;-1===t.requestScheduled&&(t.requestScheduled=e.requestScheduled)}(i,s,this);let e=s.playlistParsingError;if(e){this.warn(e);let i=this.hls;if(!i.config.ignorePlaylistParsingErrors){var o;let{networkDetails:a}=t;i.trigger(cA.ERROR,{type:ck.NETWORK_ERROR,details:cw.LEVEL_PARSING_ERROR,fatal:!1,url:s.url,error:e,reason:e.message,level:t.level||void 0,parent:null==(o=s.fragments[0])?void 0:o.type,networkDetails:a,stats:r});return}s.playlistParsingError=null}}-1===s.requestScheduled&&(s.requestScheduled=r.loading.start);let c=this.hls.mainForwardBufferInfo,f=c?c.end-c.len:0,p=(s.edge-f)*1e3,m=md(s,p);if(s.requestScheduled+m<a?s.requestScheduled=a:s.requestScheduled+=m,this.log(`live playlist ${e} ${s.advanced?"REFRESHED "+s.lastPartSn+"-"+s.lastPartIndex:s.updated?"UPDATED":"MISSED"}`),!this.canLoad||!s.live)return;if(s.canBlockReload&&s.endSN&&s.advanced){let e=this.hls.config.lowLatencyMode,r=s.lastPartSn,n=s.endSN,o=s.lastPartIndex,c=r===n;-1!==o?c?(d=n+1,h=e?0:o):(d=r,h=e?o+1:s.maxPartIndex):d=n+1;let f=s.age,p=f+s.ageHeader,m=Math.min(p-s.partTarget,1.5*s.targetduration);if(m>0){if(p>3*s.targetduration)this.log(`Playlist last advanced ${f.toFixed(2)}s ago. Omitting segment and part directives.`),d=void 0,h=void 0;else if(null!=i&&i.tuneInGoal&&p-s.partTarget>i.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${i.tuneInGoal} to: ${m} with playlist age: ${s.age}`),m=0;else{let e=Math.floor(m/s.targetduration);d+=e,void 0!==h&&(h+=Math.round(m%s.targetduration/s.partTarget)),this.log(`CDN Tune-in age: ${s.ageHeader}s last advanced ${f.toFixed(2)}s goal: ${m} skip sn ${e} to part ${h}`)}s.tuneInGoal=m}if(l=this.getDeliveryDirectives(s,t.deliveryDirectives,d,h),e||!c){s.requestScheduled=a,this.loadingPlaylist(u,l);return}}else(s.canBlockReload||s.canSkipUntil)&&(l=this.getDeliveryDirectives(s,t.deliveryDirectives,d,h));l&&void 0!==d&&s.canBlockReload&&(s.requestScheduled=r.loading.first+Math.max(m-2*n,m/2)),this.scheduleLoading(u,l,s)}else this.clearTimer()}scheduleLoading(e,t,i){let s=i||e.details;if(!s)return void this.loadingPlaylist(e,t);let r=self.performance.now(),a=s.requestScheduled;if(r>=a)return void this.loadingPlaylist(e,t);let n=a-r;this.log(`reload live playlist ${e.name||e.bitrate+"bps"} in ${Math.round(n)} ms`),this.clearTimer(),this.timer=self.setTimeout(()=>this.loadingPlaylist(e,t),n)}getDeliveryDirectives(e,t,i,s){let r=fN(e);return null!=t&&t.skip&&e.deltaUpdateFailed&&(i=t.msn,s=t.part,r=""),new fF(i,s,r)}checkRetry(e){let t=e.details,i=f0(e),s=e.errorAction,{action:r,retryCount:a=0,retryConfig:n}=s||{},l=!!s&&!!n&&(5===r||!s.resolved&&2===r);if(l){var o;if(a>=n.maxNumRetry)return!1;if(i&&null!=(o=e.context)&&o.deliveryDirectives)this.warn(`Retrying playlist loading ${a+1}/${n.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{let e=f3(n,a);this.clearTimer(),this.timer=self.setTimeout(()=>this.loadPlaylist(),e),this.warn(`Retrying playlist loading ${a+1}/${n.maxNumRetry} after "${t}" in ${e}ms`)}e.levelRetry=!0,s.resolved=!0}return l}}function gG(e,t){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!gq(e[i].attrs,t[i].attrs))return!1;return!0}function gq(e,t,i){let s=e["STABLE-RENDITION-ID"];return s&&!i?s===t["STABLE-RENDITION-ID"]:!(i||["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED","ASSOC-LANGUAGE"]).some(i=>e[i]!==t[i])}function gH(e,t){return t.label.toLowerCase()===e.name.toLowerCase()&&(!t.language||t.language.toLowerCase()===(e.lang||"").toLowerCase())}class gK{constructor(e){this.tracks=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.tracks=e}destroy(){this.tracks=this.queues=null}append(e,t,i){if(null===this.queues||null===this.tracks)return;let s=this.queues[t];s.push(e),1!==s.length||i||this.executeNext(t)}appendBlocker(e){return new Promise(t=>{this.append({label:"async-blocker",execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}},e)})}prependBlocker(e){return new Promise(t=>{this.queues&&this.queues[e].unshift({label:"async-blocker-prepend",execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}})})}removeBlockers(){null!==this.queues&&[this.queues.video,this.queues.audio,this.queues.audiovideo].forEac
15h(e=>{var t;let i=null==(t=e[0])?void 0:t.label;("async-blocker"===i||"async-blocker-prepend"===i)&&(e[0].execute(),e.splice(0,1))})}unblockAudio(e){null===this.queues||this.queues.audio[0]===e&&this.shiftAndExecuteNext("audio")}executeNext(e){if(null===this.queues||null===this.tracks)return;let t=this.queues[e];if(t.length){let s=t[0];try{s.execute()}catch(r){var i;if(s.onError(r),null===this.queues||null===this.tracks)return;let t=null==(i=this.tracks[e])?void 0:i.buffer;null!=t&&t.updating||this.shiftAndExecuteNext(e)}}}shiftAndExecuteNext(e){null!==this.queues&&(this.queues[e].shift(),this.executeNext(e))}current(e){var t;return(null==(t=this.queues)?void 0:t[e][0])||null}toString(){let{queues:e,tracks:t}=this;return null===e||null===t?"<destroyed>":`
16${this.list("video")}
17${this.list("audio")}
18${this.list("audiovideo")}}`}list(e){var t,i;return null!=(t=this.queues)&&t[e]||null!=(i=this.tracks)&&i[e]?`${e}: (${this.listSbInfo(e)}) ${this.listOps(e)}`:""}listSbInfo(e){var t;let i=null==(t=this.tracks)?void 0:t[e],s=null==i?void 0:i.buffer;return s?`SourceBuffer${s.updating?" updating":""}${i.ended?" ended":""}${i.ending?" ending":""}`:"none"}listOps(e){var t;return(null==(t=this.queues)?void 0:t[e].map(e=>e.label).join(", "))||""}}let gW=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,gz="HlsJsTrackRemovedError";class gY extends Error{constructor(e){super(e),this.name=gz}}function gQ(e){let t=e.querySelectorAll("source");[].slice.call(t).forEach(t=>{e.removeChild(t)})}function gX(e){return+("audio"===e)}class gJ{constructor(e){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=e,this.autoLevelCapping=1/0,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}setStreamController(e){this.streamController=e}destroy(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){let{hls:e}=this;e.on(cA.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(cA.MEDIA_ATTA
18CHING,this.onMediaAttaching,this),e.on(cA.MANIFEST_PARSED,this.onManifestParsed,this),e.on(cA.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(cA.BUFFER_CODECS,this.onBufferCodecs,this),e.on(cA.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){let{hls:e}=this;e.off(cA.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(cA.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(cA.MANIFEST_PARSED,this.onManifestParsed,this),e.off(cA.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(cA.BUFFER_CODECS,this.onBufferCodecs,this),e.off(cA.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(e,t){let i=this.hls.levels[t.droppedLevel];this.isLevelAllowed(i)&&this.restrictedLevels.push({bitrate:i.bitrate,height:i.height,width:i.width})}onMediaAttaching(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()}onManifestParsed(e,t){let i=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,i.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onLevelsUpdated(e,t){this.timer&&cS(this.autoLevelCapping)&&this.detectPlayerSize()}onBufferCodecs(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onMediaDetaching(){this.stopCapping(),this.media=null}detectPlayerSize(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0){this.clientRect=null;return}let e=this.hls.levels;if(e.length){let t=this.hls,i=this.getMaxLevel(e.length-1);i!==this.autoLevelCapping&&t.logger.log(`Setting autoLevelCapping to ${i}: ${e[i].height}p@${e[i].bitrate} for media ${this.mediaWidth}x${this.mediaHeight}`),t.autoLevelCapping=i,t.autoLevelEnabled&&t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}}getMaxLevel(e){let t=this.hls.levels;if(!t.length)return -1;let i=t.filter((t,i)=>this.isLevelAllowed(t)&&i<=e);return this.clientRect=null,gJ.getMaxLevelByMediaSize(i,this.mediaWidth,this.mediaHeight)}startCapping(){this.timer||(this.autoLevelCapping=1/0,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())}stopCapping(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=1/0,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)}getDimensions(){if(this.clientRect)return this.clientRect;let e=this.media,t={width:0,height:0};if(e){let i=e.getBoundingClientRect();t.width=i.width,t.height=i.height,t.width||t.height||(t.width=i.right-i.left||e.width||0,t.height=i.bottom-i.top||e.height||0)}return this.clientRect=t,t}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch(e){}return Math.min(e,this.hls.config.maxDevicePixelRatio)}isLevelAllowed(e){return!this.restrictedLevels.some(t=>e.bitrate===t.bitrate&&e.width===t.width&&e.height===t.height)}static getMaxLevelByMediaSize(e,t,i){if(!(null!=e&&e.length))return -1;let s=(e,t)=>!t||e.width!==t.width||e.height!==t.height,r=e.length-1,a=Math.max(t,i);for(let t=0;t<e.length;t+=1){let i=e[t];if((i.width>=a||i.height>=a)&&s(i,e[t+1])){r=t;break}}return r}}class gZ{constructor(e,t){Array.isArray(e)&&(e=e.map(e=>e instanceof gZ?e:new gZ(e))),this.value=e,this.params=t}}function g0(e,t,i){return Error(`failed to serialize "${Array.isArray(e)?JSON.stringify(e):e instanceof Map?"Map{}":e instanceof Set?"Set{}":"object"==typeof e?JSON.stringify(e):String(e)}" as ${t}`,{cause:i})}class g1{constructor(e){this.description=e}}let g2="Bare Item";function g5(e){if(e<-0x38d7ea4c67fff||0x38d7ea4c67fff<e)throw g0(e,"Integer");return e.toString()}let g3=/[\x00-\x1f\x7f]+/;function g4(e){let t=e.description||e.toString().slice(7,-1);if(!1===/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(t))throw g0(t,"Token");return t}function g8(e){switch(typeof e){case"number":if(!cS(e))throw g0(e,g2);if(Number.isInteger(e))return g5(e);let t=function e(t,i){if(t<0)return-e(-t,i);let s=Math.pow(10,i);if(!(Math.abs(t*s%1-.5)<Number.EPSILON))return Math.round(t*s)/s;{let e=Math.floor(t*s);return(e%2==0?e:e+1)/s}}(e,3);if(Math.floor(Math.abs(t)).toString().length>12)throw g0(e,"Decimal");let i=t.toString();return i.includes(".")?i:`${i}.0`;case"string":if(g3.test(e))throw g0(e,"String");return`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`;case"symbol":return g4(e);case"boolean":if("boolean"!=typeof e)throw g0(e,"Boolean");return e?"?1":"?0";case"object":if(e instanceof Date)return`@${g5(e.getTime()/1e3)}`;if(e instanceof Uint8Array){if(!1===ArrayBuffer.isView(e))throw g0(e,"Byte Sequence");return`:${btoa(String.fromCharCode(...e))}:`}if(e instanceof g1)return g4(e);default:throw g0(e,g2)}}function g6(e){if(!1===/^[a-z*][a-z0-9\-_.*]*$/.test(e))throw g0(e,"Key");return e}function g7(e){return null==e?"":Object.entries(e).map(([e,t])=>!0===t?`;${g6(e)}`:`;${g6(e)}=${g8(t)}`).join("")}function g9(e){return e instanceof gZ?`${g8(e.value)}${g7(e.params)}`:g8(e)}function ye(e,t){return function(e,t={whitespace:!0}){if("object"!=typeof e||null==e)throw g0(e,"Dict");let i=e instanceof Map?e.entries():Object.entries(e),s=(null==t?void 0:t.whitespace)?" ":"";return Array.from(i).map(([e,t])=>{t instanceof gZ==!1&&(t=new gZ(t));let i=g6(e);if(!0===t.value)i+=g7(t.params);else if(i+="=",Array.isArray(t.value)){var s;i+=(s=t,`(${s.value.map(g9).join(" ")})${g7(s.params)}`)}
18else i+=g9(t);return i}).join(`,${s}`)}(e,t)}let yt="CMCD-Object",yi="CMCD-Request",ys="CMCD-Session",yr="CMCD-Status",ya={br:yt,ab:yt,d:yt,ot:yt,tb:yt,tpb:yt,lb:yt,tab:yt,lab:yt,url:yt,pb:yi,bl:yi,tbl:yi,dl:yi,ltc:yi,mtp:yi,nor:yi,nrr:yi,rc:yi,sn:yi,sta:yi,su:yi,ttfb:yi,ttfbb:yi,ttlb:yi,cmsdd:yi,cmsds:yi,smrt:yi,df:yi,cs:yi,ts:yi,cid:ys,pr:ys,sf:ys,sid:ys,st:ys,v:ys,msd:ys,bs:yr,bsd:yr,cdn:yr,rtp:yr,bg:yr,pt:yr,ec:yr,e:yr},yn="event",yl=e=>Math.round(e),yo=(e,t)=>Array.isArray(e)?e.map(e=>yo(e,t)):e instanceof gZ&&"string"==typeof e.value?new gZ(yo(e.value,t),e.params):(t.baseUrl&&(e=function(e,t){let i=new URL(e),s=new URL(t);if(i.origin!==s.origin)return e;let r=i.pathname.split("/").slice(1),a=s.pathname.split("/").slice(1,-1);for(;r[0]===a[0];)r.shift(),a.shift();for(;a.length;)a.shift(),r.unshift("..");return r.join("/")+i.search+i.hash}(e,t.baseUrl)),1===t.version?encodeURIComponent(e):e),yd=e=>100*yl(e/100),yh={br:yl,d:yl,bl:yd,dl:yd,mtp:yd,nor:(e,t)=>{let i=e;return t.version>=2&&(e instanceof gZ&&"string"==typeof e.value?i=new gZ([e]):"string"==typeof e&&(i=[e])),yo(i,t)},rtp:yd,tb:yl},yu="request",yc="response",yf=["ab","bg","bl","br","bs","bsd","cdn","cid","cs","df","ec","lab","lb","ltc","msd","mtp","pb","pr","pt","sf","sid","sn","st","sta","tab","tb","tbl","tpb","ts","v"],yp=["e"],ym=/^[a-zA-Z0-9-.]+-[a-zA-Z0-9-.]+$/;function yg(e){return ym.test(e)}let yy=["d","dl","nor","ot","rtp","su"],yv=["cmsdd","cmsds","rc","smrt","ttfb","ttfbb","ttlb","url"],yb=["bl","br","bs","cid","d","dl","mtp","nor","nrr","ot","pr","rtp","sf","sid","st","su","tb","v"];function yE(e){return yb.includes(e)||yg(e)}let yS={[yc]:function(e){return yf.includes(e)||yy.includes(e)||yv.includes(e)||yg(e)},[yn]:function(e){return yf.includes(e)||yp.includes(e)||yg(e)},[yu]:function(e){return yf.includes(e)||yy.includes(e)||yg(e)}};function yT(e,t={}){let i={};if(null==e||"object"!=typeof e)return i;let s=t.version||e.v||1,r=t.reportingMode||yu,a=1===s?yE:yS[r],n=Object.keys(e).filter(a),l=t.filter;"function"==typeof l&&(n=n.filter(l));let o=r===yc||r===yn;o&&!n.includes("ts")&&n.push("ts"),s>1&&!n.includes("v")&&n.push("v");let d=cO({},yh,t.formatters),h={version:s,reportingMode:r,baseUrl:t.baseUrl};return n.sort().forEach(t=>{var r;let a=e[t],n=d[t];if("function"==typeof n&&(a=n(a,h)),"v"===t)if(1===s)return;else a=s;("pr"!=t||1!==a)&&(o&&"ts"===t&&!cS(a)&&(a=Date.now()),("number"==typeof(r=a)?cS(r):null!=r&&""!==r&&!1!==r)&&(["ot","sf","st","e","sta"].includes(t)&&"string"==typeof a&&(a=new g1(a)),i[t]=a))}),i}let yx=/CMCD=[^&#]+/;function yk(e,t,i,s){e&&Object.keys(t).forEach(r=>{let a=e.filter(e=>e.groupId===r).map(e=>{let a=cO({},e);return a.details=void 0,a.attrs=new pk(a.attrs),a.url=a.attrs.URI=yw(e.url,e.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",i),a.groupId=a.attrs["GROUP-ID"]=t[r],a.attrs["PATHWAY-ID"]=s,a});e.push(...a)})}function yw(e,t,i,s){let r,{HOST:a,PARAMS:n,[i]:l}=s;t&&(r=null==l?void 0:l[t])&&(e=r);let o=new self.URL(e);return a&&!r&&(o.host=a),n&&Object.keys(n).sort().forEach(e=>{e&&o.searchParams.set(e,n[e])}),o.href}class yA extends cB{constructor(e){super("eme",e.logger),this.hls=void 0,this.config=void 0,this.media=null,this.mediaResolved=void 0,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.mediaKeys=null,this.setMediaKeysQueue=yA.CDMCleanupPromise?[yA.CDMCleanupPromise]:[],this.bannedKeyIds={},this.onMediaEncrypted=e=>{let{initDataType:t,initData:i}=e,s=`"${e.type}" event: init data type: "${t}"`;if(this.debug(s),null!==i){if(!this.keyFormatPromise){let e=Object.keys(this.keySystemAccessPromises);e.length||(e=pK(this.config));let t=e.map(pH).filter(e=>!!e);this.keyFormatPromise=this.getKeyFormatPromise(t)}this.keyFormatPromise.then(r=>{let a,n=pq(r);if("sinf"!==t||n!==pN)return void this.log(`Ignoring "${e.type}" event with init data type: "${t}" for selected key-system ${n}`);try{let e=c7(new Uint8Array(i)),t=pP(JSON.parse(e).sinf),s=fh(t);if(!s)throw Error("'schm' box missing or not cbcs/cenc with schi > tenc");a=new Uint8Array(s.subarray(8,24))}catch(e){this.warn(`${s} Failed to parse sinf: ${e}`);return}let l=cz(a),{keyIdToKeySessionPromise:o,mediaKeySessions:d}=this,h=o[l];for(let e=0;e<d.length;e++){let s=d[e],r=s.decryptdata;if(!r.keyId)continue;let n=cz(r.keyId);if(pR(a,r.keyId)||-1!==r.uri.replace(/-/g,"").indexOf(l)){if(!(h=o[n]))continue;if(r.pssh)break;delete o[n],r.pssh=new Uint8Array(i),r.keyId=a,(h=o[l]=h.then(()=>this.generateRequestWithPreferredKeySession(s,t,i,"encrypted-event-key-match"))).catch(e=>this.handleError(e));break}}h||this.handleError(Error(`Key ID ${l} not encountered in playlist. Key-system sessions ${d.length}.`))}).catch(e=>this.handleError(e))}},this.onWaitingForKey=e=>{this.log(`"${e.type}" event`)},this.hls=e,this.config=e.config,this.registerListeners()}destroy(){this.onDestroying(),this.onMediaDetached();let e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.config=this.keyIdToKeySessionPromise=null,this.onMediaEncrypted=this.onWaitingForKey=null}
18registerListeners(){this.hls.on(cA.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(cA.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(cA.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(cA.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.on(cA.DESTROYING,this.onDestroying,this)}unregisterListeners(){this.hls.off(cA.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(cA.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(cA.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(cA.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.off(cA.DESTROYING,this.onDestroying,this)}getLicenseServerUrl(e){let{drmSystems:t,widevineLicenseUrl:i}=this.config,s=null==t?void 0:t[e];return s?s.licenseUrl:e===pB&&i?i:void 0}getLicenseServerUrlOrThrow(e){let t=this.getLicenseServerUrl(e);if(void 0===t)throw Error(`no license server URL configured for key-system "${e}"`);return t}getServerCertificateUrl(e){let{drmSystems:t}=this.config,i=null==t?void 0:t[e];if(i)return i.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${e}"]`)}attemptKeySystemAccess(e){let t=this.hls.levels,i=(e,t,i)=>!!e&&i.indexOf(e)===t,s=t.map(e=>e.audioCodec).filter(i),r=t.map(e=>e.videoCodec).filter(i);return s.length+r.length===0&&r.push("avc1.42e01e"),new Promise((t,i)=>{let a=e=>{let n=e.shift();this.getMediaKeysPromise(n,s,r).then(e=>t({keySystem:n,mediaKeys:e})).catch(t=>{e.length?a(e):t instanceof yL?i(t):i(new yL({type:ck.KEY_SYSTEM_ERROR,details:cw.KEY_SYSTEM_NO_ACCESS,error:t,fatal:!0},t.message))})};a(e)})}requestMediaKeySystemAccess(e,t){let{requestMediaKeySystemAccessFunc:i}=this.config;if("function"!=typeof i){let e=`Configured requestMediaKeySystemAccess is not a function ${i}`;return null===pW&&"http:"===self.location.protocol&&(e=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(Error(e))}return i(e,t)}getMediaKeysPromise(e,t,i){var s;let r=function(e,t,i,s){var r,a,n,l;let o;switch(e){case pN:o=["cenc","sinf"];break;case pB:case pF:o=["cenc"];break;case pO:o=["cenc","keyids"];break;default:throw Error(`Unknown key-system: ${e}`)}return r=o,a=t,n=i,[{initDataTypes:r,persistentState:(l=s).persistentState||"optional",distinctiveIdentifier:l.distinctiveIdentifier||"optional",sessionTypes:l.sessionTypes||[l.sessionType||"temporary"],audioCapabilities:a.map(e=>({contentType:`audio/mp4; codecs=${e}`,robustness:l.audioRobustness||"",encryptionScheme:l.audioEncryptionScheme||null})),videoCapabilities:n.map(e=>({contentType:`video/mp4; codecs=${e}`,robustness:l.videoRobustness||"",encryptionScheme:l.videoEncryptionScheme||null}))}]}(e,t,i,this.config.drmSystemOptions||{}),a=this.keySystemAccessPromises[e],n=null==(s=a)?void 0:s.keySystemAccess;if(!n){this.log(`Requesting encrypted media "${e}" key-system access with config: ${fj(r)}`),n=this.requestMediaKeySystemAccess(e,r);let t=a=this.keySystemAccessPromises[e]={keySystemAccess:n};return n.catch(t=>{this.log(`Failed to obtain access to key-system "${e}": ${t}`)}),n.then(i=>{this.log(`Access for key-system "${i.keySystem}" obtained`);let s=this.fetchServerCertificate(e);this.log(`Create media-keys for "${e}"`);let r=t.mediaKeys=i.createMediaKeys().then(i=>(this.log(`Media-keys created for "${e}"`),t.hasMediaKeys=!0,s.then(t=>t?this.setMediaKeysServerCertificate(i,e,t):i)));return r.catch(t=>{this.error(`Failed to create media-keys for "${e}"}: ${t}`)}),r})}return n.then(()=>a.mediaKeys)}createMediaKeySessionContext({decryptdata:e,keySystem:t,mediaKeys:i}){this.log(`Creating key-system session "${t}" keyId: ${cz(e.keyId||[])} keyUri: ${e.uri}`);let s=i.createSession(),r={decryptdata:e,keySystem:t,mediaKeys:i,mediaKeysSession:s,keyStatus:"status-pending"};return this.mediaKeySessions.push(r),r}renewKeySession(e){let t=e.decryptdata;if(t.pssh){let i=this.createMediaKeySessionContext(e),s=yR(t);this.keyIdToKeySessionPromise[s]=this.generateRequestWithPreferredKeySession(i,"cenc",t.pssh.buffer,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)}updateKeySession(e,t){let i=e.mediaKeysSession;return this.log(`Updating key-session "${i.sessionId}" for keyId ${cz(e.decryptdata.keyId||[])}
19      } (data length: ${t.byteLength})`),i.update(t)}getSelectedKeySystemFormats(){return Object.keys(this.keySystemAccessPromises).map(e=>({keySystem:e,hasMediaKeys:this.keySystemAccessPromises[e].hasMediaKeys})).filter(({hasMediaKeys:e})=>!!e).map(({keySystem:e})=>pH(e)).filter(e=>!!e)}getKeySystemAccess(e){return this.getKeySystemSelectionPromise(e).then(({keySystem:e,mediaKeys:t})=>this.attemptSetMediaKeys(e,t))}selectKeySystem(e){return new Promise((t,i)=>{this.getKeySystemSelectionPromise(e).then(({keySystem:e})=>{let s=pH(e);s?t(s):i(Error(`Unable to find format for key-system "${e}"`))}).catch(i)})}selectKeySystemFormat(e){let t=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${e.sn} ${e.type}: ${e.level}) key formats ${t.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(t)),this.keyFormatPromise}getKeyFormatPromise(e){let t=pK(this.config),i=e.map(pq).filter(e=>!!e&&-1!==t.indexOf(e));return this.selectKeySystem(i)}getKeyStatus(e){let{mediaKeySessions:t}=this;for(let r=0;r<t.length;r++){var i,s;let a=(i=e,s=t[r],i.keyId&&s.mediaKeysSession.keyStatuses.has(i.keyId)?s.mediaKeysSession.keyStatuses.get(i.keyId):i.matches(s.decryptdata)?s.keyStatus:void 0);if(a)return a}}loadKey(e){let t=e.keyInfo.decryptdata,i=yR(t),s=this.bannedKeyIds[i];if(s||"internal-error"===this.getKeyStatus(t)){let i=yC(s||"internal-error",t);return this.handleError(i,e.frag),Promise.reject(i)}let r=`(keyId: ${i} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${r}`);let a=this.keyIdToKeySessionPromise[i];if(!a){let s=this.getKeySystemForKeyPromise(t).then(({keySystem:i,mediaKeys:s})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${r}`),this.attemptSetMediaKeys(i,s).then(()=>(this.throwIfDestroyed(),this.createMediaKeySessionContext({keySystem:i,mediaKeys:s,decryptdata:t}))))).then(e=>{let i=t.pssh?t.pssh.buffer:null;return this.generateRequestWithPreferredKeySession(e,"cenc",i,"playlist-key")});return s.catch(t=>this.handleError(t,e.frag)),this.keyIdToKeySessionPromise[i]=s,s}return a.catch(i=>{if(i instanceof yL){let s=cF({},i.data);"internal-error"===this.getKeyStatus(t)&&(s.decryptdata=t);let r=new yL(s,i.message);this.handleError(r,e.frag)}}),a}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw Error("invalid state")}handleError(e,t){if(this.hls)if(e instanceof yL){t&&(e.data.frag=t);let i=e.data.decryptdata;this.error(`${e.message}${i?` (${cz(i.keyId||[])})`:""}`),this.hls.trigger(cA.ERROR,e.data)}else this.error(e.message),this.hls.trigger(cA.ERROR,{type:ck.KEY_SYSTEM_ERROR,details:cw.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0})}
19getKeySystemForKeyPromise(e){let t=yR(e),i=this.keyIdToKeySessionPromise[t];if(!i){let t=pq(e.keyFormat),i=t?[t]:pK(this.config);return this.attemptKeySystemAccess(i)}return i}getKeySystemSelectionPromise(e){if(e.length||(e=pK(this.config)),0===e.length)throw new yL({type:ck.KEY_SYSTEM_ERROR,details:cw.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${fj({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}attemptSetMediaKeys(e,t){if(this.mediaResolved=void 0,this.mediaKeys===t)return Promise.resolve();let i=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);let s=Promise.all(i).then(()=>this.media?this.media.setMediaKeys(t):new Promise((e,i)=>{this.mediaResolved=()=>{if(this.mediaResolved=void 0,!this.media)return i(Error("Attempted to set mediaKeys without media element attached"));this.mediaKeys=t,this.media.setMediaKeys(t).then(e).catch(i)}}));return this.mediaKeys=t,this.setMediaKeysQueue.push(s),s.then(()=>{this.log(`Media-keys set for "${e}"`),i.push(s),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(e=>-1===i.indexOf(e))})}generateRequestWithPreferredKeySession(e,t,i,s){var r;let a=null==(r=this.config.drmSystems)||null==(r=r[e.keySystem])?void 0:r.generateRequest;if(a)try{let s=a.call(this.hls,t,i,e);if(!s)throw Error("Invalid response from configured generateRequest filter");t=s.initDataType,i=s.initData?s.initData:null,e.decryptdata.pssh=i?new Uint8Array(i):null}catch(e){if(this.warn(e.message),this.hls&&this.hls.config.debug)throw e}if(null===i)return this.log(`Skipping key-session request for "${s}" (no initData)`),Promise.resolve(e);let n=yR(e.decryptdata),l=e.decryptdata.uri;this.log(`Generating key-session request for "${s}" keyId: ${n} URI: ${l} (init data type: ${t} length: ${i.byteLength})`);let o=new mB,d=e._onmessage=t=>{let i=e.mediaKeysSession;if(!i)return void o.emit("error",Error("invalid state"));let{messageType:s,message:r}=t;this.log(`"${s}" message event for session "${i.sessionId}" message size: ${r.byteLength}`),"license-request"===s||"license-renewal"===s?this.renewLicense(e,r).catch(e=>
19{o.eventNames().length?o.emit("error",e):this.handleError(e)}):"license-release"===s?e.keySystem===pN&&this.updateKeySession(e,pD("acknowledged")).then(()=>this.removeSession(e)).catch(e=>this.handleError(e)):this.warn(`unhandled media key message type "${s}"`)},h=(e,t)=>{let i;t.keyStatus=e,e.startsWith("usable")?o.emit("resolved"):"internal-error"===e||"output-restricted"===e||"output-downscaled"===e?i=yC(e,t.decryptdata):"expired"===e?i=Error(`key expired (keyId: ${n})`):"released"===e?i=Error("key released"):"status-pending"===e||this.warn(`unhandled key status change "${e}" (keyId: ${n})`),i&&(o.eventNames().length?o.emit("error",i):this.handleError(i))},u=e._onkeystatuseschange=t=>{if(!e.mediaKeysSession)return void o.emit("error",Error("invalid state"));let i=this.getKeyStatuses(e);if(!Object.keys(i).some(e=>"status-pending"!==i[e]))return;if("expired"===i[n]){this.log(`Expired key ${fj(i)} in key-session "${e.mediaKeysSession.sessionId}"`),this.renewKeySession(e);return}let s=i[n];if(s)h(s,e);else{var r;e.keyStatusTimeouts||(e.keyStatusTimeouts={}),(r=e.keyStatusTimeouts)[n]||(r[n]=self.setTimeout(()=>{if(!e.mediaKeysSession||!this.mediaKeys)return;let t=this.getKeyStatus(e.decryptdata);if(t&&"status-pending"!==t)return this.log(`No status for keyId ${n} in key-session "${e.mediaKeysSession.sessionId}". Using session key-status ${t} from other session.`),h(t,e);this.log(`key status for ${n} in key-session "${e.mediaKeysSession.sessionId}" timed out after 1000ms`),h(s="internal-error",e)},1e3)),this.log(`No status for keyId ${n} (${fj(i)}).`)}};mE(e.mediaKeysSession,"message",d),mE(e.mediaKeysSession,"keystatuseschange",u);let c=new Promise((e,t)=>{o.on("error",t),o.on("resolved",e)});return e.mediaKeysSession.generateRequest(t,i).then(()=>{this.log(`Request generated for key-session "${e.mediaKeysSession.sessionId}" keyId: ${n} URI: ${l}`)}).catch(t=>{throw new yL({type:ck.KEY_SYSTEM_ERROR,details:cw.KEY_SYSTEM_NO_SESSION,error:t,decryptdata:e.decryptdata,fatal:!1},`Error generating key-session request: ${t}`)}).then(()=>c).catch(t=>(o.removeAllListeners(),this.removeSession(e).then(()=>{throw t}))).then(()=>(o.removeAllListeners(),e))}getKeyStatuses(e){let t={};return e.mediaKeysSession.keyStatuses.forEach((i,s)=>{if("string"==typeof s&&"object"==typeof i){let e=s;s=i,i=e}let r="buffer"in s?new Uint8Array(s.buffer,s.byteOffset,s.byteLength):new Uint8Array(s);e.keySystem===pF&&16===r.length&&(t[cz(r)]=i,pM(r));let a=cz(r);"internal-error"===i&&(this.bannedKeyIds[a]=i),this.log(`key status change "${i}" for keyStatuses keyId: ${a} key-session "${e.mediaKeysSession.sessionId}"`),t[a]=i}),t}fetchServerCertificate(e){let t=this.config,i=new t.loader(t),s=this.getServerCertificateUrl(e);return s?(this.log(`Fetching server certificate for "${e}"`),new Promise((r,a)=>{let n={responseType:"arraybuffer",url:s},l=t.certLoadPolicy.default,o={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0};i.load(n,o,{onSuccess:(e,t,i,s)=>{r(e.data)},onError:(t,i,r,l)=>{a(new yL({type:ck.KEY_SYSTEM_ERROR,details:cw.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:r,response:cF({url:n.url,data:void 0},t)},`"${e}" certificate request failed (${s}). Status: ${t.code} (${t.text})`))},onTimeout:(t,i,r)=>{a(new yL({type:ck.KEY_SYSTEM_ERROR,details:cw.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:r,response:{url:n.url,data:void 0}},`"${e}" certificate request timed out (${s})`))},onAbort:(e,t,i)=>{a(Error("aborted"))}})})):Promise.resolve()}setMediaKeysServerCertificate(e,t,i){return new Promise((s,r)=>{e.setServerCertificate(i).then(r=>{this.log(`setServerCertificate ${r?"success":"not supported by CDM"} (${i.byteLength}) on "${t}"`),s(e)}).catch(e=>{r(new yL({type:ck.KEY_SYSTEM_ERROR,details:cw.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:e,fatal:!0},e.message))})})}renewLicense(e,t){return this.requestLicense(e,new Uint8Array(t)).then(t=>this.updateKeySession(e,new Uint8Array(t)).catch(t=>{throw new yL({type:ck.KEY_SYSTEM_ERROR,details:cw.KEY_SYSTEM_SESSION_UPDATE_FAILED,decryptdata:e.decryptdata,error:t,fatal:!1},t.message)}))}unpackPlayReadyKeyMessage(e,t){let i=String.fromCharCode.apply(null,new Uint16Array(t.buffer));if(!i.includes("PlayReadyKeyMessage"))return e.setRequestHeader("Content-Type","text/xml; charset=utf-8"),t;let s=new DOMParser().parseFromString(i,"application/xml"),r=s.querySelectorAll("HttpHeader");if(r.length>0){let t;for(let i=0,s=r.length;i<s;i++){var a,n;let s=null==(a=(t=r[i]).querySelector("name"))?void 0:a.textContent,l=null==(n=t.querySelector("value"))?void 0:n.textContent;s&&l&&e.setRequestHeader(s,l)}}let l=s.querySelector("Challenge"),o=null==l?void 0:l.textContent;
19if(!o)throw Error("Cannot find <Challenge> in key message");return pD(atob(o))}setupLicenseXHR(e,t,i,s){let r=this.config.licenseXhrSetup;return r?Promise.resolve().then(()=>{if(!i.decryptdata)throw Error("Key removed");return r.call(this.hls,e,t,i,s)}).catch(a=>{if(!i.decryptdata)throw a;return e.open("POST",t,!0),r.call(this.hls,e,t,i,s)}).then(i=>(e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:i||s})):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:s}))}requestLicense(e,t){let i=this.config.keyLoadPolicy.default;return new Promise((s,r)=>{let a=this.getLicenseServerUrlOrThrow(e.keySystem);this.log(`Sending license request to URL: ${a}`);let n=new XMLHttpRequest;n.responseType="arraybuffer",n.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return r(Error("invalid state"));if(4===n.readyState)if(200===n.status){this._requestLicenseFailureCount=0;let t=n.response;this.log(`License received ${t instanceof ArrayBuffer?t.byteLength:t}`);let i=this.config.licenseResponseCallback;if(i)try{t=i.call(this.hls,n,a,e)}catch(e){this.error(e)}s(t)}else{let l=i.errorRetry,o=l?l.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>o||n.status>=400&&n.status<500)r(new yL({type:ck.KEY_SYSTEM_ERROR,details:cw.KEY_SYSTEM_LICENSE_REQUEST_FAILED,decryptdata:e.decryptdata,fatal:!0,networkDetails:n,response:{url:a,data:void 0,code:n.status,text:n.statusText}},`License Request XHR failed (${a}). Status: ${n.status} (${n.statusText})`));else{let i=o-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${i} attempts left`),this.requestLicense(e,t).then(s,r)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=n,this.setupLicenseXHR(n,a,e,t).then(({xhr:t,licenseChallenge:i})=>{e.keySystem==pF&&(i=this.unpackPlayReadyKeyMessage(t,i)),t.send(i)}).catch(r)})}onDestroying(){this.unregisterListeners(),this._clear()}onMediaAttached(e,t){if(!this.config.emeEnabled)return;let i=t.media;this.media=i,mE(i,"encrypted",this.onMediaEncrypted),mE(i,"waitingforkey",this.onWaitingForKey);let s=this.mediaResolved;s?s():this.mediaKeys=i.mediaKeys}onMediaDetached(){let e=this.media;e&&(mS(e,"encrypted",this.onMediaEncrypted),mS(e,"waitingforkey",this.onWaitingForKey),this.media=null,this.mediaKeys=null)}_clear(){var e;this._requestLicenseFailureCount=0,this.keyIdToKeySessionPromise={},this.bannedKeyIds={};let t=this.mediaResolved;if(t&&t(),!this.mediaKeys&&!this.mediaKeySessions.length)return;let i=this.media,s=this.mediaKeySessions.slice();this.mediaKeySessions=[],this.mediaKeys=null,pQ.clearKeyUriToKeyIdMap();let r=s.length;yA.CDMCleanupPromise=Promise.all(s.map(e=>this.removeSession(e)).concat((null==i||null==(e=i.setMediaKeys(null))?void 0:e.catch(e=>{this.log(`Could not clear media keys: ${e}`),this.hls&&this.hls.trigger(cA.ERROR,{type:ck.OTHER_ERROR,details:cw.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR,fatal:!1,error:Error(`Could not clear media keys: ${e}`)})}))||Promise.resolve())).catch(e=>{this.log(`Could not close sessions and clear media keys: ${e}`),this.hls&&this.hls.trigger(cA.ERROR,{type:ck.OTHER_ERROR,details:cw.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:Error(`Could not close sessions and clear media keys: ${e}`)})}).then(()=>{r&&this.log("finished closing key sessions and clearing media keys")})}onManifestLoading(){this._clear()}onManifestLoaded(e,{sessionKeys:t}){if(t&&this.config.emeEnabled&&!this.keyFormatPromise){let e=t.reduce((e,t)=>(-1===e.indexOf(t.keyFormat)&&e.push(t.keyFormat),e),[]);this.log(`Selecting key-system from session-keys ${e.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(e)}}removeSession(e){let{mediaKeysSession:t,licenseXhr:i,decryptdata:s}=e;if(t){var r;this.log(`Remove licenses and keys and close session "${t.sessionId}" keyId: ${cz((null==s?void 0:s.keyId)||[])}`),e._onmessage&&(t.removeEventListener("message",e._onmessage),e._onmessage=void 0),e._onkeystatuseschange&&(t.removeEventListener("keystatuseschange",e._onkeystatuseschange),e._onkeystatuseschange=void 0),i&&i.readyState!==XMLHttpRequest.DONE&&i.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;let a=this.mediaKeySessions.indexOf(e);a>-1&&this.mediaKeySessions.splice(a,1);let{keyStatusTimeouts:n}=e;
19n&&Object.keys(n).forEach(e=>self.clearTimeout(n[e]));let{drmSystemOptions:l}=this.config;return(l&&("persistent-license"===l.sessionType||null!=(r=l.sessionTypes)&&r.some(e=>"persistent-license"===e))?new Promise((e,i)=>{self.setTimeout(()=>i(Error("MediaKeySession.remove() timeout")),8e3),t.remove().then(e).catch(i)}):Promise.resolve()).catch(e=>{this.log(`Could not remove session: ${e}`),this.hls&&this.hls.trigger(cA.ERROR,{type:ck.OTHER_ERROR,details:cw.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR,fatal:!1,error:Error(`Could not remove session: ${e}`)})}).then(()=>t.close()).catch(e=>{this.log(`Could not close session: ${e}`),this.hls&&this.hls.trigger(cA.ERROR,{type:ck.OTHER_ERROR,details:cw.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:Error(`Could not close session: ${e}`)})})}return Promise.resolve()}}function yR(e){if(!e)throw Error("Could not read keyId of undefined decryptdata");if(null===e.keyId)throw Error("keyId is null");return cz(e.keyId)}yA.CDMCleanupPromise=void 0;class yL extends Error{constructor(e,t){super(t),this.data=void 0,e.error||(e.error=Error(t)),this.data=e,e.err=e.error}}function yC(e,t){let i="output-restricted"===e,s=i?cw.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:cw.KEY_SYSTEM_STATUS_INTERNAL_ERROR;return new yL({type:ck.KEY_SYSTEM_ERROR,details:s,fatal:!1,decryptdata:t},i?"HDCP level output restricted":`key status changed to "${e}"`)}function yI(e,t){let i;try{i=new Event("addtrack")}catch(e){(i=document.createEvent("Event")).initEvent("addtrack",!1,!1)}i.track=e,t.dispatchEvent(i)}function yP(e,t){let i=e.mode;if("disabled"===i&&(e.mode="hidden"),e.cues&&!e.cues.getCueById(t.id))try{if(e.addCue(t),!e.cues.getCueById(t.id))throw Error(`addCue is failed for: ${t}`)}catch(i){cq.debug(`[texttrack-utils]: ${i}`);try{let i=new self.TextTrackCue(t.startTime,t.endTime,t.text);i.id=t.id,e.addCue(i)}catch(e){cq.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${e}`)}}"disabled"===i&&(e.mode=i)}function yD(e,t){let i=e.mode;if("disabled"===i&&(e.mode="hidden"),e.cues)for(let i=e.cues.length;i--;)t&&e.cues[i].removeEventListener("enter",t),e.removeCue(e.cues[i]);"disabled"===i&&(e.mode=i)}function yM(e,t,i,s){let r=e.mode;if("disabled"===r&&(e.mode="hidden"),e.cues&&e.cues.length>0){let r=function(e,t,i){let s=[],r=function(e,t){let i;if(t<=e[0].startTime)return 0;let s=e.length-1;if(t>e[s].endTime)return -1;let r=0,a=s;for(;r<=a;)if(t<e[i=Math.floor((a+r)/2)].startTime)a=i-1;else{if(!(t>e[i].startTime)||!(r<s))return i;r=i+1}return e[r].startTime-t<t-e[a].startTime?r:a}(e,t);if(r>-1)for(let a=r,n=e.length;a<n;a++){let r=e[a];if(r.startTime>=t&&r.endTime<=i)s.push(r);else if(r.startTime>i)break}return s}(e.cues,t,i);for(let t=0;t<r.length;t++)(!s||s(r[t]))&&e.removeCue(r[t])}"disabled"===r&&(e.mode=r)}function y_(e){let t=[];for(let i=0;i<e.length;i++){let s=e[i];("subtitles"===s.kind||"captions"===s.kind)&&s.label&&t.push(e[i])}return t}function y$(e){let t=5381,i=e.length;for(;i;)t=33*t^e.charCodeAt(--i);return(t>>>0).toString()}let yO=((y={})[y.Point=0]="Point",y[y.Range=1]="Range",y);class yN{constructor(e,t){this.base=void 0,this._duration=null,this._timelineStart=null,this.appendInPlaceDisabled=void 0,this.appendInPlaceStarted=void 0,this.dateRange=void 0,this.hasPlayed=!1,this.cumulativeDuration=0,this.resumeOffset=NaN,this.playoutLimit=NaN,this.restrictions={skip:!1,jump:!1},this.snapOptions={out:!1,in:!1},this.assetList=[],this.assetListLoader=void 0,this.assetListResponse=null,this.resumeAnchor=void 0,this.error=void 0,this.resetOnResume=void 0,this.base=t,this.dateRange=e,this.setDateRange(e)}setDateRange(e){this.dateRange=e,this.resumeOffset=e.attr.optionalFloat("X-RESUME-OFFSET",this.resumeOffset),this.playoutLimit=e.attr.optionalFloat("X-PLAYOUT-LIMIT",this.playoutLimit),this.restrictions=e.attr.enumeratedStringList("X-RESTRICT",this.restrictions),this.snapOptions=e.attr.enumeratedStringList("X-SNAP",this.snapOptions)}reset(){var e;this.appendInPlaceStarted=!1,null==(e=this.assetListLoader)||e.destroy(),this.assetListLoader=void 0,this.supplementsPrimary||(this.assetListResponse=null,this.assetList=[],this._duration=null)}isAssetPastPlayoutLimit(e){var t;if(e>0&&e>=this.assetList.length)return!0;let i=this.playoutLimit;return!(e<=0||isNaN(i))&&(0===i||((null==(t=this.assetList[e])?void 0:t.startOffset)||0)>i)}findAssetIndex(e){return this.assetList.indexOf(e)}get identifier(){return this.dateRange.id}get startDate(){return this.dateRange.startDate}get startTime(){let e=this.dateRange.startTime;if(this.snapOptions.out){let t=this.dateRange.tagAnchor;if(t)return yF(e,t)}return e}get startOffset(){return this.cue.pre?0:this.startTime}get startIsAligned(){if(0===this.startTime||this.snapOptions.out)return!0;let e=this.dateRange.tagAnchor;if(e){let t=this.dateRange.startTime,i=yF(t,e);return t-i<.1}return!1}get resumptionOffset(){let e=this.resumeOffset,t=cS(e)?e:this.duration;return this.cumulativeDuration+t}get resumeTime(){let e=this.startOffset+this.resumptionOffset;if(this.snapOptions.in){let t=this.resumeAnchor;if(t)return yF(e,t)}return e}get appendInPlace(){return!!this.appendInPlaceStarted||!this.appendInPlaceDisabled&&!!(!this.cue.once&&!this.cue.pre&&this.startIsAligned&&(isNaN(this.playoutLimit)&&isNaN(this.resumeOffset)||this.resumeOffset&&this.duration&&.025>Math.abs(this.resumeOffset-this.duration)))}set appendInPlace(e){if(this.appendInPlaceStarted){this.resetOnResume=!e;return}this.appendInPlaceDisabled=!e}get timelineStart(){return null!==this._timelineStart?this._timelineStart:this.startTime}set timelineStart(e){this._timelineStart=e}get duration(){let e,t=this.playoutLimit;return e=null!==this._duration?this._duration:this.dateRange.duration?this.dateRange.duration:this.dateRange.plannedDuration||0,!isNaN(t)&&t<e&&(e=t),e}set duration(e){this._duration=e}get cue(){return this.dateRange.cue}get timelineOccupancy(){return"RANGE"===this.dateRange.attr["X-TIMELINE-OCCUPIES"]?yO.Range:yO.Point}get supplementsPrimary(){return"PRIMARY"===this.dateRange.attr["X-TIMELINE-STYLE"]}get contentMayVary(){return"NO"!==this.dateRange.attr["X-CONTENT-MAY-VARY"]}get assetUrl(){return this.dateRange.attr["X-ASSET-URI"]}get assetListUrl(){return this.dateRange.attr["X-ASSET-LIST"]}get baseUrl(){return this.base.url}get assetListLoaded(){return this.assetList.length>0||null!==this.assetListResponse}toString(){var e;return e=this,`["${e.identifier}" ${e.cue.pre?"<pre>":e.cue.post?"<post>":""}${e.timelineStart.toFixed(2)}-${e.resumeTime.toFixed(2)}]`}}function yF(e,t){return e-t.start<t.duration/2&&!(.025>Math.abs(e-(t.start+t.duration)))?t.start:t.start+t.duration}function yB(e,t,i){let s=new self.URL(e,i);return"data:"!==s.protocol&&s.searchParams.set("_HLS_primary_id",t),s}function yU(e,t){for(;null!=(i=e.assetList[++t])&&i.error;)var i;return t}function yj(e){let t=e.timelineStart,i=e.duration||0;return`["${e.identifier}" ${t.toFixed(2)}-${(t+i).toFixed(2)}]`}class yV{constructor(e,t,i,s){this.hls=void 0,this.interstitial=void 0,this.assetItem=void 0,this.tracks=null,this.hasDetail
19s=!1,this.mediaAttached=null,this._currentTime=void 0,this._bufferedEosTime=void 0,this.checkPlayout=()=>{this.reachedPlayout(this.currentTime)&&this.hls&&this.hls.trigger(cA.PLAYOUT_LIMIT_REACHED,{})};const r=this.hls=new e(t);this.interstitial=i,this.assetItem=s;const a=()=>{this.hasDetails=!0};r.once(cA.LEVEL_LOADED,a),r.once(cA.AUDIO_TRACK_LOADED,a),r.once(cA.SUBTITLE_TRACK_LOADED,a),r.on(cA.MEDIA_ATTACHING,(e,{media:t})=>{this.removeMediaListeners(),this.mediaAttached=t,this.interstitial.playoutLimit&&(t.addEventListener("timeupdate",this.checkPlayout),this.appendInPlace&&r.on(cA.BUFFER_APPENDED,()=>{let e=this.bufferedEnd;this.reachedPlayout(e)&&(this._bufferedEosTime=e,r.trigger(cA.BUFFERED_TO_END,void 0))}))})}get appendInPlace(){return this.interstitial.appendInPlace}loadSource(){let e=this.hls;if(e)if(e.url)e.levels.length&&!e.started&&e.startLoad(-1,!0);else{let t=this.assetItem.uri;try{t=yB(t,e.config.primarySessionId||"").href}catch(e){}e.loadSource(t)}}bufferedInPlaceToEnd(e){var t;if(!this.appendInPlace)return!1;if(null!=(t=this.hls)&&t.bufferedToEnd)return!0;if(!e)return!1;let i=Math.min(this._bufferedEosTime||1/0,this.duration),s=this.timelineOffset,r=pv.bufferInfo(e,s,0);return this.getAssetTime(r.end)>=i-.02}reachedPlayout(e){let t=this.interstitial.playoutLimit;return this.startOffset+e>=t}get destroyed(){var e;return!(null!=(e=this.hls)&&e.userConfig)}get assetId(){return this.assetItem.identifier}get interstitialId(){return this.assetItem.parentIdentifier}get media(){var e;return(null==(e=this.hls)?void 0:e.media)||null}get bufferedEnd(){let e=this.media||this.mediaAttached;if(!e)return this._bufferedEosTime?this._bufferedEosTime:this.currentTime;let t=pv.bufferInfo(e,e.currentTime,.001);return this.getAssetTime(t.end)}get currentTime(){let e=this.media||this.mediaAttached;return e?this.getAssetTime(e.currentTime):this._currentTime||0}get duration(){let e=this.assetItem.duration;if(!e)return 0;let t=this.interstitial.playoutLimit;if(t){let i=t-this.startOffset;if(i>0&&i<e)return i}return e}get remaining(){let e=this.duration;return e?Math.max(0,e-this.currentTime):0}get startOffset(){return this.assetItem.startOffset}get timelineOffset(){var e;return(null==(e=this.hls)?void 0:e.config.timelineOffset)||0}set timelineOffset(e){let t=this.timelineOffset;if(e!==t&&Math.abs(e-t)>1/9e4&&this.hls){if(this.hasDetails)throw Error("Cannot set timelineOffset after playlists are loaded");this.hls.config.timelineOffset=e}}getAssetTime(e){return Math.min(Math.max(0,e-this.timelineOffset),this.duration)}removeMediaListeners(){let e=this.mediaAttached;e&&(this._currentTime=e.currentTime,this.bufferSnapShot(),e.removeEventListener("timeupdate",this.checkPlayout))}bufferSnapShot(){if(this.mediaAttached){var e;null!=(e=this.hls)&&e.bufferedToEnd&&(this._bufferedEosTime=this.bufferedEnd)}}destroy(){this.removeMediaListeners(),this.hls&&this.hls.destroy(),this.hls=null,this.tracks=this.mediaAttached=this.checkPlayout=null}attachMedia(e){var t;this.loadSource(),null==(t=this.hls)||t.attachMedia(e)}detachMedia(){var e;this.removeMediaListeners(),this.mediaAttached=null,null==(e=this.hls)||e.detachMedia()}resumeBuffering(){var e;null==(e=this.hls)||e.resumeBuffering()}pauseBuffering(){var e;null==(e=this.hls)||e.pauseBuffering()}transferMedia(){var e;return this.bufferSnapShot(),(null==(e=this.hls)?void 0:e.transferMedia())||null}resetDetails(){let e=this.hls;if(e&&this.hasDetails){e.stopLoad();let t=e=>delete e.details;e.levels.forEach(t),e.allAudioTracks.forEach(t),e.allSubtitleTracks.forEach(t),this.hasDetails=!1}}on(e,t,i){var s;null==(s=this.hls)||s.on(e,t)}once(e,t,i){var s;null==(s=this.hls)||s.once(e,t)}off(e,t,i){var s;null==(s=this.hls)||s.off(e,t)}toString(){var e;return`HlsAssetPlayer: ${yj(this.assetItem)} ${null==(e=this.hls)?void 0:e.sessionId} ${this.appendInPlace?"append-in-place":""}`}}class yG extends cB{constructor(e,t){super("interstitials-sched",t),this.onScheduleUpdate=void 0,this.eventMap={},this.events=null,this.items=null,this.durations={primary:0,playout:0,integrated:0},this.onScheduleUpdate=e}destroy(){this.reset(),this.onScheduleUpdate=null}reset(){this.eventMap={}
19,this.setDurations(0,0,0),this.events&&this.events.forEach(e=>e.reset()),this.events=this.items=null}resetErrorsInRange(e,t){return this.events?this.events.reduce((i,s)=>e<=s.startOffset&&t>s.startOffset?(delete s.error,i+1):i,0):0}get duration(){let e=this.items;return e?e[e.length-1].end:0}get length(){return this.items?this.items.length:0}getEvent(e){return e&&this.eventMap[e]||null}hasEvent(e){return e in this.eventMap}findItemIndex(e,t){if(e.event)return this.findEventIndex(e.event.identifier);let i=-1;e.nextEvent?i=this.findEventIndex(e.nextEvent.identifier)-1:e.previousEvent&&(i=this.findEventIndex(e.previousEvent.identifier)+1);let s=this.items;if(s)for(s[i]||(void 0===t&&(t=e.start),i=this.findItemIndexAtTime(t));i>=0&&null!=(r=s[i])&&r.event;){var r;i--}return i}findItemIndexAtTime(e,t){let i=this.items;if(i)for(let s=0;s<i.length;s++){let r=i[s];if(t&&"primary"!==t&&(r=r[t]),e===r.start||e>r.start&&e<r.end)return s}return -1}findJumpRestrictedIndex(e,t){let i=this.items;if(i)for(let s=e;s<=t&&i[s];s++){let e=i[s].event;if(null!=e&&e.restrictions.jump&&!e.appendInPlace)return s}return -1}findEventIndex(e){let t=this.items;if(t)for(let s=t.length;s--;){var i;if((null==(i=t[s].event)?void 0:i.identifier)===e)return s}return -1}findAssetIndex(e,t){let i=e.assetList,s=i.length;if(s>1)for(let e=0;e<s;e++){let r=i[e];if(!r.error){let i=r.timelineStart;if(t===i||t>i&&(t<i+(r.duration||0)||e===s-1))return e}}return 0}get assetIdAtEnd(){var e;let t=null==(e=this.items)||null==(e=e[this.length-1])?void 0:e.event;if(t){let e=t.assetList,i=e[e.length-1];if(i)return i.identifier}return null}parseInterstitialDateRanges(e,t){let i=e.main.details,{dateRanges:s}=i,r=this.events,a=this.parseDateRanges(s,{url:i.url},t),n=Object.keys(s),l=r?r.filter(e=>!n.includes(e.identifier)):[];a.length&&a.sort((e,t)=>{let i=e.cue.pre,s=e.cue.post,r=t.cue.pre,a=t.cue.post;if(i&&!r)return -1;if(r&&!i||s&&!a)return 1;if(a&&!s)return -1;if(!i&&!r&&!s&&!a){let i=e.startTime,s=t.startTime;if(i!==s)return i-s}return e.dateRange.tagOrder-t.dateRange.tagOrder}),this.events=a,l.forEach(e=>{this.removeEvent(e)}),this.updateSchedule(e,l)}updateSchedule(e,t=[],i=!1){let s=this.events||[];
19if(s.length||t.length||this.length<2){let r=this.items,a=this.parseSchedule(s,e);(i||t.length||(null==r?void 0:r.length)!==a.length||a.some((e,t)=>Math.abs(e.playout.start-r[t].playout.start)>.005||Math.abs(e.playout.end-r[t].playout.end)>.005))&&(this.items=a,this.onScheduleUpdate(t,r))}}parseDateRanges(e,t,i){let s=[],r=Object.keys(e);for(let a=0;a<r.length;a++){let n=r[a],l=e[n];if(l.isInterstitial){let e=this.eventMap[n];e?e.setDateRange(l):(e=new yN(l,t),this.eventMap[n]=e,!1===i&&(e.appendInPlace=i)),s.push(e)}}return s}parseSchedule(e,t){let i=[],s=t.main.details,r=s.live?1/0:s.edge,a=0;if((e=e.filter(e=>!e.error&&!(e.cue.once&&e.hasPlayed))).length){this.resolveOffsets(e,t);let s=0,l=0;if(e.forEach((t,n)=>{let o=t.cue.pre,d=t.cue.post,h=e[n-1]||null,u=t.appendInPlace,c=d?r:t.startOffset,f=t.duration,p=t.timelineOccupancy===yO.Range?f:0,m=t.resumptionOffset,g=(null==h?void 0:h.startTime)===c,y=c+t.cumulativeDuration,v=u?y+f:c+m;if(o||!d&&c<=0){let e=l;l+=p,t.timelineStart=y;let s=a;a+=f,i.push({event:t,start:y,end:v,playout:{start:s,end:a},integrated:{start:e,end:l}})}else{if(!(c<=r))return;if(!g){let r=c-s;if(r>.033){let o=s,d=l;l+=r;let h=a;a+=r;let u={previousEvent:e[n-1]||null,nextEvent:t,start:o,end:o+r,playout:{start:h,end:a},integrated:{start:d,end:l}};i.push(u)}else r>0&&h&&(h.cumulativeDuration+=r,i[i.length-1].end=c)}d&&(v=y),t.timelineStart=y;let o=l;l+=p;let u=a;a+=f,i.push({event:t,start:y,end:v,playout:{start:u,end:a},integrated:{start:o,end:l}})}let b=t.resumeTime;s=d||b>r?r:b}),s<r){var n;let e=s,t=l,o=r-s;l+=o;let d=a;a+=o,i.push({previousEvent:(null==(n=i[i.length-1])?void 0:n.event)||null,nextEvent:null,start:s,end:e+o,playout:{start:d,end:a},integrated:{start:t,end:l}})}this.setDurations(r,a,l)}else i.push({previousEvent:null,nextEvent:null,start:0,end:r,playout:{start:0,end:r},integrated:{start:0,end:r}}),this.setDurations(r,r,r);return i}setDurations(e,t,i){this.durations={primary:e,playout:t,integrated:i}}resolveOffsets(e,t){let i=t.main.details,s=i.live?1/0:i.edge,r=0,a=-1;e.forEach((n,l)=>{let o=n.cue.pre,d=n.cue.post,h=o?0:d?s:n.startTime;this.updateAssetDurations(n),a===h?n.cumulativeDuration=r:(r=0,a=h),!d&&n.snapOptions.in&&(n.resumeAnchor=fX(null,i.fragments,n.startOffset+n.resumptionOffset,0,0)||void 0),n.appendInPlace&&!n.appendInPlaceStarted&&(this.primaryCanResumeInPlaceAt(n,t)||(n.appendInPlace=!1)),!n.appendInPlace&&l+1<e.length&&e[l+1].startTime-e[l].resumeTime<.033&&(e[l+1].appendInPlace=!1,e[l+1].appendInPlace&&this.warn(`Could not change append strategy for abutting event ${n}`));let u=cS(n.resumeOffset)?n.resumeOffset:n.duration;r+=u})}primaryCanResumeInPlaceAt(e,t){let i=e.resumeTime,s=e.startTime+e.resumptionOffset;return Math.abs(i-s)>.025?(this.log(`"${e.identifier}" resumption ${i} not aligned with estimated timeline end ${s}`),!1):!Object.keys(t).some(s=>{let r=t[s].details,a=r.edge;if(i>=a)return this.log(`"${e.identifier}" resumption ${i} past ${s} playlist end ${a}`),!1;let n=fX(null,r.fragments,i);if(!n)return this.log(`"${e.identifier}" resumption ${i} does not align with any fragments in ${s} playlist (${r.fragStart}-${r.fragmentEnd})`),!0;let l=.175*("audio"===s);return!(Math.abs(n.start-i)<.025+l||Math.abs(n.end-i)<.025+l)&&(this.log(`"${e.identifier}" resumption ${i} not aligned with ${s} fragment bounds (${n.start}-${n.end} sn: ${n.sn} cc: ${n.cc})`),!0)})}updateAssetDurations(e){if(!e.assetListLoaded)return;let t=e.timelineStart,i=0,s=!1,r=!1;for(let a=0;a<e.assetList.length;a++){let n=e.assetList[a],l=t+i;n.startOffset=i,n.timelineStart=l,s||(s=null===n.duration),r||(r=!!n.error),i+=n.error?0:n.duration||0}s&&!r?e.duration=Math.max(i,e.duration):e.duration=i}removeEvent(e){e.reset(),delete this.eventMap[e.identifier]}}function yq(e){return`[${e.event?'"'+e.event.identifier+'"':"primary"}: ${e.start.toFixed(2)}-${e.end.toFixed(2)}]`}class yH{constructor(e){this.hls=void 0,this.hls=e}destroy(){this.hls=null}loadAssetList(e,t){let i,s=e.assetListUrl;try{i=yB(s,this.hls.sessionId,e.baseUrl)}catch(i){let t=this.assignAssetListError(e,cw.ASSET_LIST_LOAD_ERROR,i,s);this.hls.trigger(cA.ERROR,t);return}t&&"data:"!==i.protocol&&i.searchParams.set("_HLS_start_offset",""+t);let r=this.hls.config,a=new r.loader(r),n={responseType:"json",url:i.href},l=r.interstitialAssetListLoadPolicy.default,o={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0};return a.load(n,o,{onSuccess:(t,i,s,r)=>{let a=t.data;if(!Array.isArray(null==a?void 0:a.ASSETS)){let t=this.assignAssetListError(e,cw.ASSET_LIST_PARSING_ERROR,Error("Invalid interstitial asset list"),s.url,i,r);this.hls.trigger(cA.ERROR,t);return}e.assetListResponse=a,this.hls.trigger(cA.ASSET_LIST_LOADED,{event:e,assetListResponse:a,networkDetails:r})},onError:(t,i,s,r)=>{let a=this.assignAssetListError(e,cw.ASSET_LIST_LOAD_ERROR,Error(`Error loading X-ASSET-LIST: HTTP status ${t.code} ${t.text} (${i.url})`),i.url,r,s);this.hls.trigger(cA.ERROR,a)},onTimeout:(t,i,s)=>{let r=this.assignAssetListError(e,cw.ASSET_LIST_LOAD_TIMEOUT,Error(`Timeout loading X-ASSET-LIST (${i.url})`),i.url,t,s);this.hls.trigger(cA.ERROR,r)}}),this.hls.trigger(cA.ASSET_LIST_LOADING,{event:e}),a}assignAssetListError(e,t,i,s,r,a){return e.error=i,{type:ck.NETWORK_E
19RROR,details:t,fatal:!1,interstitial:e,url:s,error:i,networkDetails:a,stats:r}}}function yK(e){var t;null==e||null==(t=e.play())||t.catch(()=>{})}function yW(e,t){return`[${e}] Advancing timeline position to ${t}`}class yz{constructor(e){this.buffered=void 0;const t=(t,i,s)=>{if((i>>>=0)>s-1)throw new DOMException(`Failed to execute '${t}' on 'TimeRanges': The index provided (${i}) is greater than the maximum bound (${s})`);return e[i][t]};this.buffered={get length(){return e.length},end:i=>t("end",i,e.length),start:i=>t("start",i,e.length)}}}let yY={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},yQ=e=>String.fromCharCode(yY[e]||e),yX={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},yJ={17:2,18:4,21:6,22:8,23:10,19:13,20:15},yZ={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},y0={25:2,26:4,29:6,30:8,31:10,27:13,28:15},y1=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class y2{constructor(){this.time=null,this.verboseLevel=0}log(e,t){if(this.verboseLevel>=e){let i="function"==typeof t?t():t;cq.log(`${this.time} [${e}] ${i}`)}}}let y5=function(e){let t=[];for(let i=0;i<e.length;i++)t.push(e[i].toString(16));return t};class y3{constructor(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}reset(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}setStyles(e){let t=["foreground","underline","italics","background","flash"];for(let i=0;i<t.length;i++){let s=t[i];e.hasOwnProperty(s)&&(this[s]=e[s])}}isDefault(){return"white"===this.foreground&&!this.underline&&!this.italics&&"black"===this.background&&!this.flash}equals(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash}copy(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash}toString(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}}class y4{constructor(){this.uchar=" ",this.penState=new y3}reset(){this.uchar=" ",this.penState.reset()}setChar(e,t){this.uchar=e,this.penState.copy(t)}setPenState(e){this.penState.copy(e)}equals(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)}copy(e){this.uchar=e.uchar,this.penState.copy(e.penState)}isEmpty(){return" "===this.uchar&&this.penState.isDefault()}}class y8{constructor(e){this.chars=[],this.pos=0,this.currPenState=new y3,this.cueStartTime=null,this.logger=void 0;for(let e=0;e<100;e++)this.chars.push(new y4);this.logger=e}equals(e){for(let t=0;t<100;t++)if(!this.chars[t].equals(e.chars[t]))return!1;return!0}copy(e){for(let t=0;t<100;t++)this.chars[t].copy(e.chars[t])}isEmpty(){let e=!0;for(let t=0;t<100;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e}setCursor(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>100&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=100)}moveCursor(e){let t=this.pos+e;if(e>1)for(let e=this.pos+1;e<t+1;e++)this.chars[e].setPenState(this.currPenState);this.setCursor(t)}backSpace(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}insertChar(e){e>=144&&this.backSpace();let t=yQ(e);this.pos>=100?this.logger.log(0,()=>"Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!"):(this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1))}clearFromPos(e){let t;for(t=e;t<100;t++)this.chars[t].reset()}clear(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}clearToEndOfRow(){this.clearFromPos(this.pos)}getTextString(){let e=[],t=!0;for(let i=0;i<100;i++){let s=this.chars[i].uchar;" "!==s&&(t=!1),e.push(s)}return t?"":e.join("")}setPenStyles(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)}}class y6{constructor(e){this.rows=[],this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(let t=0;t<15;t++)this.rows.push(new y8(e));this.logger=e}reset(){for(let e=0;e<15;e++)this.rows[e].clear();this.currRow=14}equals(e){let t=!0;for(let i=0;i<15;i++)if(!this.rows[i].equals(e.rows[i])){t=!1;break}return t}copy(e){for(let t=0;t<15;t++)this.rows[t].copy(e.rows[t])}isEmpty(){let e=!0;for(let t=0;t<15;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e}backSpace(){this.rows[this.currRow].backSpace()}clearToEndOfRow(){this.rows[this.currRow].clearToEndOfRow()}insertChar(e){this.rows[this.currRow].insertChar(e)}setPen(e){this.rows[this.currRow].setPenStyles(e)}moveCursor(e){this.rows[this.currRow].moveCursor(e)}setCursor(e){this.logger.log(2,"setCursor: "+e),this.rows[this.currRow].setCursor(e)}setPAC(e){this.logger.log(2,()=>"pacData = "+fj(e));let t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(let e=0;e<15;e++)this.rows[e].clear();let e=this.currRow+1-this.nrRollUpRows,i=this.lastOutputScreen;if(i){let s=i.rows[e].cueStartTime,r=this.logger.time;if(null!==s&&null!==r&&s<r)for(let s=0;s<this.nrRollUpRows;s++)this.rows[t-this.nrRollUpRows+s+1].copy(i.rows[e+s])}}this.currRow=t;let i=this.rows[this.currRow];if(null!==e.indent){let t=Math.max(e.indent-1,0);i.setCursor(e.indent),e.color=i.chars[t].penState.foreground}let s={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(s)}setBkgData(e){this.logger.log(2,()=>"bkgData = "+fj(e)),this.backSpace(),this.setPen(e),this.insertChar(32)}setRollUpRows(e){this.nrRollUpRows=e}rollUp(){if(null===this.nrRollUpRows)return void this.logger.log(3,"roll_up but nrRollUpRows not set yet");this.logger.log(1,()=>this.getDisplayText());let e=this.currRow+1-this.nrRollUpRows,t=this.rows.splice(e,1)[0];t.clear(),this.rows.splice(this.currRow,0,t),this.logger.log(2,"Rolling up")}getDisplayText(e){e=e||!1;let t=[],i="",s=-1;for(let i=0;i<15;i++){let r=this.rows[i].getTextString();r&&(s=i+1,e?t.push("Row "+s+": '"+r+"'"):t.push(r.trim()))}return t.length>0&&(i=e?"["+t.join(" | ")+"]":t.join("\n")),i}getTextAndFormat(){return this.rows}}class y7{constructor(e,t,i){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=e,this.outputFilter=t,this.mode=null,this.verbose=0,this.displayedMemory=new y6(i),this.nonDisplayedMemory=new y6(i),this.lastOutputScreen=new y6(i),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=i}reset(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}getHandler(){return this.outputFilter}setHandler(e){this.outputFilter=e}setPAC(e){this.writeScreen.setPAC(e)}setBkgData(e){this.writeScreen.setBkgData(e)}setMode(e){e!==this.mode&&(this.mode=e,this.logger.log(2,()=>"MODE="+e),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)}insertChars(e){for(let t=0;t<e.length;t++)this.writeScreen.insertChar(e[t]);let t=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,()=>t+": "+this.writeScreen.getDisplayText(!0)),("MODE_PAINT-ON"===this.mode||"MODE_ROLL-UP"===this.mode)&&(this.logger.log(1,()=>"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())}ccRCL(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}ccBS(){this.logger.log(2,"BS - BackSpace"),"MODE_TEXT"!==this.mode&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())}ccAOF(){}ccAON(){}ccDER(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}ccRU(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)}ccFON(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}
19ccRDC(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}ccTR(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}ccRTD(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}ccEDM(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}ccCR(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}ccENM(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}ccEOC(){if(this.logger.log(2,"EOC - End Of Caption"),"MODE_POP-ON"===this.mode){let e=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,()=>"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)}ccTO(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)}ccMIDROW(e){let t={flash:!1};(t.underline=e%2==1,t.italics=e>=46,t.italics)?t.foreground="white":t.foreground=["white","green","blue","cyan","red","yellow","magenta"][Math.floor(e/2)-16],this.logger.log(2,"MIDROW: "+fj(t)),this.writeScreen.setPen(t)}outputDataUpdate(e=!1){let t=this.logger.time;null!==t&&this.outputFilter&&(null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t):this.cueStartTime=t,this.lastOutputScreen.copy(this.displayedMemory))}cueSplitAtTime(e){this.outputFilter&&!this.displayedMemory.isEmpty()&&(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e)}}class y9{constructor(e,t,i){this.channels=void 0,this.currentChannel=0,this.cmdHistory={a:null,b:null},this.logger=void 0;const s=this.logger=new y2;this.channels=[null,new y7(e,t,s),new y7(e+1,i,s)]}getHandler(e){return this.channels[e].getHandler()}setHandler(e,t){this.channels[e].setHandler(t)}addData(e,t){this.logger.time=e;for(let e=0;e<t.length;e+=2){var i,s,r,a,n,l,o,d;let h=127&t[e],u=127&t[e+1],c=!1,f=null;if(0===h&&0===u)continue;this.logger.log(3,()=>"["+y5([t[e],t[e+1]])+"] -> ("+y5([h,u])+")");let p=this.cmdHistory;if(h>=16&&h<=31){if(i=h,s=u,(r=p).a===i&&r.b===s){(a=p).a=null,a.b=null,this.logger.log(3,()=>"Repeated command ("+y5([h,u])+") is dropped");continue}n=h,l=u,(o=this.cmdHistory).a=n,o.b=l,(c=this.parseCmd(h,u))||(c=this.parseMidrow(h,u)),c||(c=this.parsePAC(h,u)),c||(c=this.parseBackgroundAttributes(h,u))}else{(d=p).a=null,d.b=null}if(!c&&(f=this.parseChars(h,u))){let e=this.currentChannel;e&&e>0?this.channels[e].insertChars(f):this.logger.log(2,"No channel found yet. TEXT-MODE?")}c||f||this.logger.log(2,()=>"Couldn't parse cleaned data "+y5([h,u])+" orig: "+y5([t[e],t[e+1]]))}}parseCmd(e,t){if(!((20===e||28===e||21===e||29===e)&&t>=32&&t<=47||(23===e||31===e)&&t>=33&&t<=35))return!1;let i=20===e||21===e||23===e?1:2,s=this.channels[i];return 20===e||21===e||28===e||29===e?32===t?s.ccRCL():33===t?s.ccBS():34===t?s.ccAOF():35===t?s.ccAON():36===t?s.ccDER():37===t?s.ccRU(2):38===t?s.ccRU(3):39===t?s.ccRU(4):40===t?s.ccFON():41===t?s.ccRDC():42===t?s.ccTR():43===t?s.ccRTD():44===t?s.ccEDM():45===t?s.ccCR():46===t?s.ccENM():47===t&&s.ccEOC():s.ccTO(t-32),this.currentChannel=i,!0}parseMidrow(e,t){let i=0;if((17===e||25===e)&&t>=32&&t<=47){if((i=17===e?1:2)!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;let s=this.channels[i];return!!s&&(s.ccMIDROW(t),this.logger.log(3,()=>"MIDROW ("+y5([e,t])+")"),!0)}return!1}parsePAC(e,t){let i,s=(e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127,r=(16===e||24===e)&&t>=64&&t<=95;if(!(s||r))return!1;let a=e<=23?1:2;i=t>=64&&t<=95?1===a?yX[e]:yZ[e]:1===a?yJ[e]:y0[e];let n=this.channels[a];return!!n&&(n.setPAC(this.interpretPAC(i,t)),this.currentChannel=a,!0)}interpretPAC(e,t){let i,s={color:null,italics:!1,indent:null,underline:!1,row:e};return s.underline=(1&(i=t>95?t-96:t-64))==1,i<=13?s.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(i/2)]:i<=15?(s.italics=!0,s.color="white"):s.indent=4*Math.floor((i-16)/2),s}parseChars(e,t){let i,s=null,r=null;if(e>=25?(i=2,r=e-8):(i=1,r=e),r>=17&&r<=19){let e;e=17===r?t+80:18===r?t+112:t+144,this.logger.log(2,()=>"Special char '"+yQ(e)+"' in channel "+i),s=[e]}else e>=32&&e<=127&&(s=0===t?[e]:[e,t]);return s&&this.logger.log(3,()=>"Char codes =  "+y5(s).join(",")),s}
19parseBackgroundAttributes(e,t){if(!((16===e||24===e)&&t>=32&&t<=47||(23===e||31===e)&&t>=45&&t<=47))return!1;let i={};return 16===e||24===e?(i.background=y1[Math.floor((t-32)/2)],t%2==1&&(i.background=i.background+"_semi")):45===t?i.background="transparent":(i.foreground="black",47===t&&(i.underline=!0)),this.channels[e<=23?1:2].setBkgData(i),!0}reset(){var e;for(let e=0;e<Object.keys(this.channels).length;e++){let t=this.channels[e];t&&t.reset()}(e=this.cmdHistory).a=null,e.b=null}cueSplitAtTime(e){for(let t=0;t<this.channels.length;t++){let i=this.channels[t];i&&i.cueSplitAtTime(e)}}}var ve=function(){if(null!=p$&&p$.VTTCue)return self.VTTCue;let e=["","lr","rl"],t=["start","middle","end","left","right"];function i(e,t){if("string"!=typeof t||!Array.isArray(e))return!1;let i=t.toLowerCase();return!!~e.indexOf(i)&&i}function s(e){let t=1;for(;t<arguments.length;t++){let i=arguments[t];for(let t in i)e[t]=i[t]}return e}function r(r,a,n){let l={enumerable:!0};this.hasBeenReset=!1;let o="",d=!1,h=r,u=a,c=n,f=null,p="",m=!0,g="auto",y="start",v=50,b="middle",E=50,S="middle";Object.defineProperty(this,"id",s({},l,{get:function(){return o},set:function(e){o=""+e}})),Object.defineProperty(this,"pauseOnExit",s({},l,{get:function(){return d},set:function(e){d=!!e}})),Object.defineProperty(this,"startTime",s({},l,{get:function(){return h},set:function(e){if("number"!=typeof e)throw TypeError("Start time must be set to a number.");h=e,this.hasBeenReset=!0}})),Object.defineProperty(this,"endTime",s({},l,{get:function(){return u},set:function(e){if("number"!=typeof e)throw TypeError("End time must be set to a number.");u=e,this.hasBeenReset=!0}})),Object.defineProperty(this,"text",s({},l,{get:function(){return c},set:function(e){c=""+e,this.hasBeenReset=!0}})),Object.defineProperty(this,"region",s({},l,{get:function(){return f},set:function(e){f=e,this.hasBeenReset=!0}})),Object.defineProperty(this,"vertical",s({},l,{get:function(){return p},set:function(t){let s=i(e,t);if(!1===s)throw SyntaxError("An invalid or illegal string was specified.");p=s,this.hasBeenReset=!0}})),Object.defineProperty(this,"snapToLines",s({},l,{get:function(){return m},set:function(e){m=!!e,this.hasBeenReset=!0}})),Object.defineProperty(this,"line",s({},l,{get:function(){return g},set:function(e){if("number"!=typeof e&&"auto"!==e)throw SyntaxError("An invalid number or illegal string was specified.");g=e,this.hasBeenReset=!0}})),Object.defineProperty(this,"lineAlign",s({},l,{get:function(){return y},set:function(e){let s=i(t,e);if(!s)throw SyntaxError("An invalid or illegal string was specified.");y=s,this.hasBeenReset=!0}})),Object.defineProperty(this,"position",s({},l,{get:function(){return v},set:function(e){if(e<0||e>100)throw Error("Position must be between 0 and 100.");v=e,this.hasBeenReset=!0}})),Object.defineProperty(this,"positionAlign",s({},l,{get:function(){return b},set:function(e){let s=i(t,e);if(!s)throw SyntaxError("An invalid or illegal string was specified.");b=s,this.hasBeenReset=!0}})),Object.defineProperty(this,"size",s({},l,{get:function(){return E},set:function(e){if(e<0||e>100)throw Error("Size must be between 0 and 100.");E=e,this.hasBeenReset=!0}})),Object.defineProperty(this,"align",s({},l,{get:function(){return S},set:function(e){let s=i(t,e);if(!s)throw SyntaxError("An invalid or illegal string was specified.");S=s,this.hasBeenReset=!0}})),this.displayState=void 0}return r.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},r}();class vt{decode(e,t){if(!e)return"";if("string"!=typeof e)throw Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}function vi(e){function t(e,t,i,s){return(0|e)*3600+(0|t)*60+(0|i)+parseFloat(s||0)}let i=e.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return i?parseFloat(i[2])>59?t(i[2],i[3],0,i[4]):t(i[1],i[2],i[3],i[4]):null}class vs{constructor(){this.values=Object.create(null)}set(e,t){this.get(e)||""===t||(this.values[e]=t)}get(e,t,i){return i?this.has(e)?this.values[e]:t[i]:this.has(e)?this.values[e]:t}has(e){return e in this.values}alt(e,t,i){for(let s=0;s<i.length;++s)if(t===i[s]){this.set(e,t);break}}integer(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))}percent(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){let i=parseFloat(t);if(i>=0&&i<=100)return this.set(e,i),!0}return!1}}function vr(e,t,i,s){let r=s?e.split(s):[e];for(let e in r){if("string"!=typeof r[e])continue;let s=r[e].split(i);if(2===s.length)t(s[0],s[1])}}let va=new ve(0,0,""),vn="middle"===va.align?"middle":"center";function vl(e){return e.replace(/<br(?: \/)?>/gi,"\n")}class vo{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new vt,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(e){let t=this;function i(){let e=t.buffer,i=0;for(e=vl(e);i<e.length&&"\r"!==e[i]&&"\n"!==e[i];)++i;let s=e.slice(0,i);return"\r"===e[i]&&++i,"\n"===e[i]&&++i,t.buffer=e.slice(i),s}e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));try{let e="";if("INITIAL"===t.state){if(!/\r\n|\n/.test(t.buffer))return this;let s=(e=i()).match(/^()?WEBVTT([ \t].*)?$/);if(!(null!=s&&s[0]))throw Error("Malformed WebVTT signature.");t.state="HEADER"}let r=!1;for(;t.buffer&&/\r\n|\n/.test(t.buffer);)switch(r?r=!1:e=i(),t.state){case"HEADER":if(/:/.test(e)){var s;s=e,vr(s,function(e,t){},/:/)}else e||(t.state="ID");continue;case"NOTE":e||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(e)){t.state="NOTE";break}if(!e)continue;if(t.cue=new ve(0,0,""),t.state="CUE",-1===e.indexOf("-->")){t.cue.id=e;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{!function(e,t,i){var s;let r,a,n,l=e;function o(){let t=vi(e);if(null===t)throw Error("Malformed timestamp: "+l);return e=e.replace(/^[^\sa-zA-Z-]+/,""),t}function d(){e=e.replace(/^\s+/,"")}if(d(),t.startTime=o(),d(),"-->"!==e.slice(0,3))throw Error("Malformed time stamp (time stamps must be separated by '-->'): "+l);e=e.slice(3),d(),t.endTime=o(),d(),s=e,r=new vs,vr(s,function(e,t){let s;switch(e){case"region":for(let s=i.length-1;s>=0;s--)if(i[s].id===t){r.set(e,i[s].region);break}break;case"vertical":r.alt(e,t,["rl","lr"]);break;case"line":s=t.split(","),r.integer(e,s[0]),r.percent(e,s[0])&&r.set("snapToLines",!1),r.alt(e,s[0],["auto"]),2===s.length&&r.alt("lineAlign",s[1],["start",vn,"end"]);break;case"position":s=t.split(","),r.percent(e,s[0]),2===s.length&&r.alt("positionAlign",s[1],["start",vn,"end","line-left","line-right","auto"]);break;case"size":r.percent(e,t);break;case"align":r.alt(e,t,["start",vn,"end","left","right"])}},/:/,/\s/),t.region=r.get("region",null),t.vertical=r.get("vertical",""),"auto"===(a=r.get("line","auto"))&&-1===va.line&&(a=-1),t.line=a,t.lineAlign=r.get("lineAlign","start"),t.snapToLines=r.get("snapToLines",!0),t.size=r.get("size",100),t.align=r.get("align",vn),"auto"===(n=r.get("position","auto"))&&50===va.position&&(n="start"===t.align||"left"===t.align?0:"end"===t.align||"right"===t.align?100:50),t.position=n}(e,t.cue,t.regionList)}catch(e){t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":{let i=-1!==e.indexOf("-->");if(!e||i&&(r=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(null===t.cue)continue;t.cue.text&&(t.cue.text+="\n"),t.cue.text+=e}continue;case"BADCUE":e||(t.state="ID")}}catch(e){"CUETEXT"===t.state&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state="INITIAL"===t.state?"BADWEBVTT":"BADCUE"}return this}flush(){try{if((this.cue||"HEADER"===this.state)&&(this.buffer+="\n\n",this.parse()),"INITIAL"===this.state||"BADWEBVTT"===this.state)throw Error("Malformed WebVTT signature.")}catch(e){this.onparsingerror&&this.onparsingerror(e)}return this.onflush&&this.onflush(),this}}let vd=/\r\n|\n\r|\n|\r/g,vh=function(e,t,i=0){return e.slice(i,i+t.length)===t},vu=function(e){let t=parseInt(e.slice(-3)),i=parseInt(e.slice(-6,-4)),s=parseInt(e.slice(-9,-7)),r=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;
19if(!cS(t)||!cS(i)||!cS(s)||!cS(r))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*i,t+=6e4*s,t+=36e5*r};function vc(e,t,i){return y$(e.toString())+y$(t.toString())+y$(i)}let vf=function(e,t,i){let s=e[t],r=e[s.prevCC];if(!r||!r.new&&s.new){e.ccOffset=e.presentationOffset=s.start,s.new=!1;return}for(;null!=(a=r)&&a.new;){var a;e.ccOffset+=s.start-r.start,s.new=!1,r=e[(s=r).prevCC]}e.presentationOffset=i},vp="stpp.ttml.im1t",vm=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,vg=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,vy={left:"start",center:"center",right:"end",start:"start",end:"end"};function vv(e,t,i,s){let r=fs(new Uint8Array(e),["mdat"]);if(0===r.length)return void s(Error("Could not parse IMSC1 mdat"));let a=r.map(e=>cW(e)),n=function(e,t=1,i=!1){return gT(e,1,1/t,i)}(t.baseTime,t.timescale);try{a.forEach(e=>i(function(e,t){let i=new DOMParser().parseFromString(e,"text/xml").getElementsByTagName("tt")[0];if(!i)throw Error("Invalid ttml");let s={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},r=Object.keys(s).reduce((e,t)=>(e[t]=i.getAttribute(`ttp:${t}`)||s[t],e),{}),a="preserve"!==i.getAttribute("xml:space"),n=vE(vb(i,"styling","style")),l=vE(vb(i,"layout","region")),o=vb(i,"body","[begin]");return[].map.call(o,e=>{var i,s,o;let d,h,u,c=function e(t,i){return[].slice.call(t.childNodes).reduce((t,s,r)=>{var a;return"br"===s.nodeName&&r?t+"\n":null!=(a=s.childNodes)&&a.length?e(s,i):i?t+s.textContent.trim().replace(/\s+/g," "):t+s.textContent},"")}(e,a);if(!c||!e.hasAttribute("begin"))return null;let f=vx(e.getAttribute("begin"),r),p=vx(e.getAttribute("dur"),r),m=vx(e.getAttribute("end"),r);if(null===f)throw vT(e);if(null===m){if(null===p)throw vT(e);m=f+p}let g=new ve(f-t,m-t,c);g.id=vc(g.startTime,g.endTime,g.text);let y=(i=l[e.getAttribute("region")],s=n[e.getAttribute("style")],o=n,d="http://www.w3.org/ns/ttml#styling",h=null,(u=null!=i&&i.hasAttribute("style")?i.getAttribute("style"):null)&&o.hasOwnProperty(u)&&(h=o[u]),["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"].reduce((e,t)=>{let r=vS(s,d,t)||vS(i,d,t)||vS(h,d,t);return r&&(e[t]=r),e},{})),{textAlign:v}=y;if(v){let e=vy[v];e&&(g.lineAlign=e),g.align=v}return cO(g,y),g}).filter(e=>null!==e)}(e,n)))}catch(e){s(e)}}function vb(e,t,i){let s=e.getElementsByTagName(t)[0];return s?[].slice.call(s.querySelectorAll(i)):[]}function vE(e){return e.reduce((e,t)=>{let i=t.getAttribute("xml:id");return i&&(e[i]=t),e},{})}function vS(e,t,i){return e&&e.hasAttributeNS(t,i)?e.getAttributeNS(t,i):null}function vT(e){return Error(`Could not parse ttml timestamp ${e}`)}function vx(e,t){var i,s;let r,a;if(!e)return null;let n=vi(e);return null===n&&(vm.test(e)?(i=e,s=t,a=(0|(r=vm.exec(i))[4])+(0|r[5])/s.subFrameRate,n=(0|r[1])*3600+(0|r[2])*60+(0|r[3])+a/s.frameRate):vg.test(e)&&(n=function(e,t){let i=vg.exec(e),s=Number(i[1]);switch(i[2]){case"h":return 3600*s;case"m":return 60*s;case"ms":return 1e3*s;case"f":return s/t.frameRate;case"t":return s/t.tickRate}return s}(e,t))),n}class vk{constructor(e,t){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=e,this.trackName=t}dispatchCue(){null!==this.startTime&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}newCue(e,t,i){(null===this.startTime||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=i,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}}function vw(e){return e.characteristics&&/transcribes-spoken-dialog/gi.test(e.characteristics)&&/describes-music-and-sound/gi.test(e.characteristics)?"captions":"subtitles"}function vA(e,t){return!!e&&e.kind===vw(t)&&gH(t,e)}function vR(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}let vL=/\s/,vC={newCue(e,t,i,s){let r,a,n,l,o,d=[],h=self.VTTCue||self.TextTrackCue;for(let c=0;c<s.rows.length;c++)if(r=s.rows[c],n=!0,l=0,o="",!r.isEmpty()){var u;for(let e=0;e<r.chars.length;e++)vL.test(r.chars[e].uchar)&&n?l++:(o+=r.chars[e].uchar,n=!1);r.cueStartTime=t,t===i&&(i+=1e-4),l>=16?l--:l++;let s=vl(o.trim()),f=vc(t,i,s);null!=e&&null!=(u=e.cues)&&u.getCueById(f)||((a=new h(t,i,s)).id=f,a.line=c+1,a.align="left",a.position=10+Math.min(80,10*Math.floor(8*l/32)),d.push(a))}return e&&d.length&&(d.sort((e,t)=>
19"auto"===e.line||"auto"===t.line?0:e.line>8&&t.line>8?t.line-e.line:e.line-t.line),d.forEach(t=>yP(e,t))),d}},vI=/(\d+)-(\d+)\/(\d+)/;class vP{constructor(e){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=null,this.response=null,this.controller=void 0,this.context=null,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=e.fetchSetup||vD,this.controller=new self.AbortController,this.stats=new cJ}destroy(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null}abortInternal(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())}abort(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(e,t,i){var s;let r,a=this.stats;if(a.loading.start)throw Error("Loader can only be used once.");a.loading.start=self.performance.now();let n=(s=e,r={method:"GET",mode:"cors",credentials:"same-origin",signal:this.controller.signal,headers:new self.Headers(cO({},s.headers))},s.rangeEnd&&r.headers.set("Range","bytes="+s.rangeStart+"-"+String(s.rangeEnd-1)),r),l="arraybuffer"===e.responseType,o=l?"byteLength":"length",{maxTimeToFirstByteMs:d,maxLoadTimeMs:h}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=i,this.request=this.fetchSetup(e,n),self.clearTimeout(this.requestTimeout),t.timeout=d&&cS(d)?d:h,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(a,e,this.response))},t.timeout),(gN(this.request)?this.request.then(self.fetch):self.fetch(this.request)).then(i=>{var s;this.response=this.loader=i;let r=Math.max(self.performance.now(),a.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=h,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(a,e,this.response))},h-(r-a.loading.start)),!i.ok){let{status:e,statusText:t}=i;throw new vM(t||"fetch, bad network response",e,i)}a.loading.first=r,a.total=function(e){let t=e.get("Content-Range");if(t){let e=function(e){let t=vI.exec(e);if(t)return parseInt(t[2])-parseInt(t[1])+1}(t);if(cS(e))return e}let i=e.get("Content-Length");if(i)return parseInt(i)}(i.headers)||a.total;let n=null==(s=this.callbacks)?void 0:s.onProgress;return n&&cS(t.highWaterMark)?this.loadProgressively(i,a,e,t.highWaterMark,n):l?i.arrayBuffer():"json"===e.responseType?i.json():i.text()}).then(i=>{var s,r;let n=this.response;if(!n)throw Error("loader destroyed");self.clearTimeout(this.requestTimeout),a.loading.end=Math.max(self.performance.now(),a.loading.first);let l=i[o];l&&(a.loaded=a.total=l);let d={url:n.url,data:i,code:n.status},h=null==(s=this.callbacks)?void 0:s.onProgress;h&&!cS(t.highWaterMark)&&h(a,e,i,n),null==(r=this.callbacks)||r.onSuccess(d,a,e,n)}).catch(t=>{var i;if(self.clearTimeout(this.requestTimeout),a.aborted)return;let s=t&&t.code||0,r=t?t.message:null;null==(i=this.callbacks)||i.onError({code:s,text:r},e,t?t.details:null,a)})}getCacheAge(){let e=null;if(this.response){let t=this.response.headers.get("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.response?this.response.headers.get(e):null}loadProgressively(e,t,i,s=0,r){let a=new mN,n=e.body.getReader(),l=()=>n.read().then(n=>{if(n.done)return a.dataLength&&r(t,i,a.flush().buffer,e),Promise.resolve(new ArrayBuffer(0));let o=n.value,d=o.length;return t.loaded+=d,d<s||a.dataLength?(a.push(o),a.dataLength>=s&&r(t,i,a.flush().buffer,e)):r(t,i,o.buffer,e),l()}).catch(()=>Promise.reject());return l()}}function vD(e,t){return new self.Request(e.url,t)}class vM extends Error{constructor(e,t,i){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=i}}let v_=/^age:\s*[\d.]+\s*$/im;class v${constructor(e){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=null,this.loader=null,this.stats=void 0,this.xhrSetup=e&&e.xhrSetup||null,this.stats=new cJ,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null}abortInternal(){let e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,4!==e.readyState&&(this.stats.aborted=!0,e.abort()))}abort(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}load(e,t,i){if(this.stats.loading.start)throw Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=i,this.loadInternal()}loadInternal(){let{config:e,context:t}=this;if(!e||!t)return;let i=this.loader=new self.XMLHttpRequest,s=this.stats;s.loading.first=0,s.loaded=0,s.aborted=!1;let r=this.xhrSetup;r?Promise.resolve().then(()=>
19{if(this.loader===i&&!this.stats.aborted)return r(i,t.url)}).catch(e=>{if(this.loader===i&&!this.stats.aborted)return i.open("GET",t.url,!0),r(i,t.url)}).then(()=>{this.loader!==i||this.stats.aborted||this.openAndSendXhr(i,t,e)}).catch(e=>{var r;null==(r=this.callbacks)||r.onError({code:i.status,text:e.message},t,i,s)}):this.openAndSendXhr(i,t,e)}openAndSendXhr(e,t,i){e.readyState||e.open("GET",t.url,!0);let s=t.headers,{maxTimeToFirstByteMs:r,maxLoadTimeMs:a}=i.loadPolicy;if(s)for(let t in s)e.setRequestHeader(t,s[t]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),i.timeout=r&&cS(r)?r:a,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),i.timeout),e.send()}readystatechange(){let{context:e,loader:t,stats:i}=this;if(!e||!t)return;let s=t.readyState,r=this.config;if(!i.aborted&&s>=2&&(0===i.loading.first&&(i.loading.first=Math.max(self.performance.now(),i.loading.start),r.timeout!==r.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),r.timeout=r.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.loadPolicy.maxLoadTimeMs-(i.loading.first-i.loading.start)))),4===s)){var a,n,l;self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;let s=t.status,o="text"===t.responseType?t.responseText:null;if(s>=200&&s<300){let r=null!=o?o:t.response;if(null!=r){i.loading.end=Math.max(self.performance.now(),i.loading.first),i.loaded=i.total="arraybuffer"===t.responseType?r.byteLength:r.length,i.bwEstimate=8e3*i.total/(i.loading.end-i.loading.first);let l=null==(a=this.callbacks)?void 0:a.onProgress;l&&l(i,e,r,t);let o={url:t.responseURL,data:r,code:s};null==(n=this.callbacks)||n.onSuccess(o,i,e,t);return}}let d=r.loadPolicy.errorRetry;f8(d,i.retry,!1,{url:e.url,data:void 0,code:s})?this.retry(d):(cq.error(`${s} while loading ${e.url}`),null==(l=this.callbacks)||l.onError({code:s,text:t.statusText},e,t,i))}}loadtimeout(){if(!this.config)return;let e=this.config.loadPolicy.timeoutRetry;if(f8(e,this.stats.retry,!0))this.retry(e);else{var t;cq.warn(`timeout while loading ${null==(t=this.context)?void 0:t.url}`);let e=this.callbacks;e&&(this.abortInternal(),e.onTimeout(this.stats,this.context,this.loader))}}retry(e){let{context:t,stats:i}=this;this.retryDelay=f3(e,i.retry),i.retry++,cq.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${null==t?void 0:t.url}, retrying ${i.retry}/${e.maxNumRetry} in ${this.retryDelay}ms`),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)}loadprogress(e){let t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)}getCacheAge(){let e=null;if(this.loader&&v_.test(this.loader.getAllResponseHeaders())){let t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.loader&&RegExp(`^${e}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}}let vO=cF(cF({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,maxDevicePixelRatio:1/0,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,startOnSegmentBoundary:!1,maxBufferSize:6e7,maxFragLookUpTolerance:.25,maxBufferHole:.1,detectStallWithCurrentTimeMs:1250,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,nudgeOnVideoHole:!0,liveSyncMode:"edge",liveSyncDurationCount:3,liveSyncOnStallIncrease:1,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,ignorePlaylistParsingErrors:!1,loader:v$,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:class extends cB{constructor(e){super("abr",e.logger),this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=-1,this.firstSelection=-1,this._nextAutoLevel=-1,this.nextAutoLevelKey="",this.audioTracksByGroup=null,this.co
19decTiers=null,this.timer=-1,this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.rebufferNotice=-1,this.supportedCache={},this.bwEstimator=void 0,this._abandonRulesCheck=e=>{var t;let i,{fragCurrent:s,partCurrent:r,hls:a}=this,{autoLevelEnabled:n,media:l}=a;if(!s||!l)return;let o=performance.now(),d=r?r.stats:s.stats,h=r?r.duration:s.duration,u=o-d.loading.start,c=a.minAutoLevel,f=s.level,p=this._nextAutoLevel;if(d.aborted||d.loaded&&d.loaded===d.total||f<=c){this.clearTimer(),this._nextAutoLevel=-1;return}if(!n)return;let m=p>-1&&p!==f,g=!!e||m;if(!g&&(l.paused||!l.playbackRate||!l.readyState))return;let y=a.mainForwardBufferInfo;if(!g&&null===y)return;let v=this.bwEstimator.getEstimateTTFB(),b=Math.abs(l.playbackRate);if(u<=Math.max(v,h/(2*b)*1e3))return;let E=y?y.len/b:0,S=d.loading.first?d.loading.first-d.loading.start:-1,T=d.loaded&&S>-1,x=this.getBwEstimate(),k=a.levels,w=k[f],A=Math.max(d.loaded,Math.round(h*(s.bitrate||w.averageBitrate)/8)),R=T?u-S:u;R<1&&T&&(R=Math.min(u,8*d.loaded/x));let L=T?1e3*d.loaded/R:0,C=v/1e3,I=L?(A-d.loaded)/L:8*A/x+C;if(I<=E)return;let P=L?8*L:x,D=(null==(t=(null==e?void 0:e.details)||this.hls.latestLevelDetails)?void 0:t.live)===!0,M=this.hls.config.abrBandWidthUpFactor,_=1/0;for(i=f-1;i>c;i--){let e=k[i].maxBitrate,t=!k[i].details||D;if((_=this.getTimeToLoadFrag(C,P,h*e,t))<Math.min(E,h+C))break}if(_>=I||_>10*h)return;T?this.bwEstimator.sample(u-Math.min(v,S),d.loaded):this.bwEstimator.sampleTTFB(u);let $=k[i].maxBitrate;this.getBwEstimate()*M>$&&this.resetEstimator($);let O=this.findBestLevel($,c,i,0,E,1,1);O>-1&&(i=O),this.warn(`Fragment ${s.sn}${r?" part "+r.index:""} of level ${f} is loading too slowly;
20      Fragment duration: ${s.duration.toFixed(3)}
21      Time to underbuffer: ${E.toFixed(3)} s
22      Estimated load time for current fragment: ${I.toFixed(3)} s
23      Estimated load time for down switch fragment: ${_.toFixed(3)} s
24      TTFB estimate: ${0|S} ms
25      Current BW estimate: ${cS(x)?0|x:"Unknown"} bps
26      New BW estimate: ${0|this.getBwEstimate()} bps
27      Switching to level ${i} @ ${0|$} bps`),a.nextLoadLevel=a.nextAutoLevel=i,this.clearTimer();let N=()=>{if(this.clearTimer(),this.fragCurrent===s&&this.hls.loadLevel===i&&i>0){let e=this.getStarvationDelay();if(this.warn(`Aborting inflight request ${i>0?"and switching down":""}
28      Fragment duration: ${s.duration.toFixed(3)} s
29      Time to underbuffer: ${e.toFixed(3)} s`),s.abortRequests(),this.fragCurrent=this.partCurrent=null,i>c){let t=this.findBestLevel(this.hls.levels[c].bitrate,c,i,0,e,1,1);-1===t&&(t=c),this.hls.nextLoadLevel=this.hls.nextAutoLevel=t,this.resetEstimator(this.hls.levels[t].bitrate)}}};m||I>2*_?N():this.timer=self.setInterval(N,1e3*_),a.trigger(cA.FRAG_LOAD_EMERGENCY_ABORTED,{frag:s,part:r,stats:d})},this.hls=e,this.bwEstimator=this.initEstimator(),this.registerListeners()}resetEstimator(e){e&&(this.log(`setting initial bwe to ${e}`),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()}initEstimator(){let e=this.hls.config;return new c$(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}registerListeners(){let{hls:e}=this;e.on(cA.MANIFEST_LOADING,this.onManifestLoading,this),e.on(cA.FRAG_LOADING,this.onFragLoading,this),e.on(cA.FRAG_LOADED,this.onFragLoaded,this),e.on(cA.FRAG_BUFFERED,this.onFragBuffered,this),e.on(cA.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(cA.LEVEL_LOADED,this.onLevelLoaded,this),e.on(cA.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(cA.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(cA.ERROR,this.onError,this)}unregisterListeners(){let{hls:e}=this;e&&(e.off(cA.MANIFEST_LOADING,this.onManifestLoading,this),e.off(cA.FRAG_LOADING,this.onFragLoading,this),e.off(cA.FRAG_LOADED,this.onFragLoaded,this),e.off(cA.FRAG_BUFFERED,this.onFragBuffered,this),e.off(cA.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(cA.LEVEL_LOADED,this.onLevelLoaded,this),e.off(cA.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(cA.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(cA.ERROR,this.onError,this))}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=this.supportedCache=null,this.fragCurrent=this.partCurrent=null}onManifestLoading(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.supportedCache={},this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()}onLevelsUpdated(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null}onMaxAutoLevelUpdated(){this.firstSelection=-1,this.nextAutoLevelKey=""}onFragLoading(e,t){let i=t.frag;
29if(!this.ignoreFragment(i)){if(!i.bitrateTest){var s;this.fragCurrent=i,this.partCurrent=null!=(s=t.part)?s:null}this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100)}}onLevelSwitching(e,t){this.clearTimer()}onError(e,t){if(!t.fatal)switch(t.details){case cw.BUFFER_ADD_CODEC_ERROR:case cw.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case cw.FRAG_LOAD_TIMEOUT:{let e=t.frag,{fragCurrent:i,partCurrent:s}=this;if(e&&i&&e.sn===i.sn&&e.level===i.level){let t=performance.now(),i=s?s.stats:e.stats,r=t-i.loading.start,a=i.loading.first?i.loading.first-i.loading.start:-1;if(i.loaded&&a>-1){let e=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(r-Math.min(e,a),i.loaded)}else this.bwEstimator.sampleTTFB(r)}}}}getTimeToLoadFrag(e,t,i,s){let r=s?e+this.lastLevelLoadSec:0;return e+i/t+r}onLevelLoaded(e,t){let i=this.hls.config,{loading:s}=t.stats,r=s.end-s.first;cS(r)&&(this.lastLevelLoadSec=r/1e3),t.details.live?this.bwEstimator.update(i.abrEwmaSlowLive,i.abrEwmaFastLive):this.bwEstimator.update(i.abrEwmaSlowVoD,i.abrEwmaFastVoD),this.timer>-1&&this._abandonRulesCheck(t.levelInfo)}onFragLoaded(e,{frag:t,part:i}){let s=i?i.stats:t.stats;if(t.type===cP&&this.bwEstimator.sampleTTFB(s.loading.first-s.loading.start),!this.ignoreFragment(t)){if(this.clearTimer(),t.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){let e=i?i.duration:t.duration,r=this.hls.levels[t.level],a=(r.loaded?r.loaded.bytes:0)+s.loaded,n=(r.loaded?r.loaded.duration:0)+e;r.loaded={bytes:a,duration:n},r.realBitrate=Math.round(8*a/n)}if(t.bitrateTest){let e={stats:s,frag:t,part:i,id:t.type};this.onFragBuffered(cA.FRAG_BUFFERED,e),t.bitrateTest=!1}else this.lastLoadedFragLevel=t.level}}onFragBuffered(e,t){let{frag:i,part:s}=t,r=null!=s&&s.stats.loaded?s.stats:i.stats;if(r.aborted||this.ignoreFragment(i))return;let a=r.parsing.end-r.loading.start-Math.min(r.loading.first-r.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(a,r.loaded),r.bwEstimate=this.getBwEstimate(),i.bitrateTest?this.bitrateTestDelay=a/1e3:this.bitrateTestDelay=0}ignoreFragment(e){return e.type!==cP||"initSegment"===e.sn}clearTimer(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)}get firstAutoLevel(){let{maxAutoLevel:e,minAutoLevel:t}=this.hls,i=this.getBwEstimate(),s=this.hls.config.maxStarvationDelay,r=this.findBestLevel(i,t,e,0,s,1,1);if(r>-1)return r;let a=this.hls.firstLevel,n=Math.min(Math.max(a,t),e);return this.warn(`Could not find best starting auto level. Defaulting to first in playlist ${a} clamped to ${n}`),n}get forcedAutoLevel(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}get nextAutoLevel(){let e=this.forcedAutoLevel,t=this.bwEstimator.canEstimate(),i=this.lastLoadedFragLevel>-1;if(-1!==e&&(!t||!i||this.nextAutoLevelKey===this.getAutoLevelKey()))return e;let s=t&&i?this.getNextABRAutoLevel():this.firstAutoLevel;if(-1!==e){let t=this.hls.levels;if(t.length>Math.max(e,s)&&t[e].loadError<=t[s].loadError)return e}return this._nextAutoLevel=s,this.nextAutoLevelKey=this.getAutoLevelKey(),s}getAutoLevelKey(){return`${this.getBwEstimate()}
29_${this.getStarvationDelay().toFixed(2)}`}getNextABRAutoLevel(){let{fragCurrent:e,partCurrent:t,hls:i}=this;if(i.levels.length<=1)return i.loadLevel;let{maxAutoLevel:s,config:r,minAutoLevel:a}=i,n=t?t.duration:e?e.duration:0,l=this.getBwEstimate(),o=this.getStarvationDelay(),d=r.abrBandWidthFactor,h=r.abrBandWidthUpFactor;if(o){let e=this.findBestLevel(l,a,s,o,0,d,h);if(e>=0)return this.rebufferNotice=-1,e}let u=n?Math.min(n,r.maxStarvationDelay):r.maxStarvationDelay;if(!o){let e=this.bitrateTestDelay;e&&(u=(n?Math.min(n,r.maxLoadingDelay):r.maxLoadingDelay)-e,this.info(`bitrate test took ${Math.round(1e3*e)}ms, set first fragment max fetchDuration to ${Math.round(1e3*u)} ms`),d=h=1)}let c=this.findBestLevel(l,a,s,o,u,d,h);if(this.rebufferNotice!==c&&(this.rebufferNotice=c,this.info(`${o?"rebuffering expected":"buffer is empty"}, optimal quality level ${c}`)),c>-1)return c;let f=i.levels[a],p=i.loadLevelObj;return p&&(null==f?void 0:f.bitrate)<p.bitrate?a:i.loadLevel}getStarvationDelay(){let e=this.hls,t=e.media;if(!t)return 1/0;let i=t&&0!==t.playbackRate?Math.abs(t.playbackRate):1,s=e.mainForwardBufferInfo;return(s?s.len:0)/i}getBwEstimate(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate}findBestLevel(e,t,i,s,r,a,n){var l,o;let d,h=s+r,u=this.lastLoadedFragLevel,c=-1===u?this.hls.firstLevel:u,{fragCurrent:f,partCurrent:p}=this,{levels:m,allAudioTracks:g,loadLevel:y,config:v}=this.hls;if(1===m.length)return 0;let b=m[c],E=!!(null!=(l=this.hls.latestLevelDetails)&&l.live),S=-1===y||-1===u,T="SDR",x=(null==b?void 0:b.frameRate)||0,{audioPreference:k,videoPreference:w}=v,A=this.audioTracksByGroup||(this.audioTracksByGroup=fG(g)),R=-1;if(S){if(-1!==this.firstSelection)return this.firstSelection;let s=function(e,t,i,s,r){let a=Object.keys(e),n=null==s?void 0:s.channels,l=null==s?void 0:s.audioCodec,o=null==r?void 0:r.videoCodec,d=n&&2===parseInt(n),h=!1,u=!1,
29c=1/0,f=1/0,p=1/0,m=1/0,g=0,y=[],{preferHDR:v,allowedVideoRanges:b}=function(e,t){let i=!1,s=[];if(e&&(i="SDR"!==e,s=[e]),t){let e="SDR"!==(s=t.allowedVideoRanges||fO.slice(0)).join("")&&!t.videoCodec;(i=void 0!==t.preferHDR?t.preferHDR:e&&function(){if("function"==typeof matchMedia){let e=matchMedia("(dynamic-range: high)"),t=matchMedia("bad query");if(e.media!==t.media)return!0===e.matches}return!1}())||(s=["SDR"])}return{preferHDR:i,allowedVideoRanges:s}}(t,r);for(let t=a.length;t--;){let i=e[a[t]];h||(h=i.channels[2]>0),c=Math.min(c,i.minHeight),f=Math.min(f,i.minFramerate),p=Math.min(p,i.minBitrate),b.filter(e=>i.videoRanges[e]>0).length>0&&(u=!0)}c=cS(c)?c:0,f=cS(f)?f:0;let E=Math.max(1080,c),S=Math.max(30,f);i=Math.max(p=cS(p)?p:i,i),u||(t=void 0);let T=a.length>1;return{codecSet:a.reduce((t,s)=>{let r=e[s];if(s===t)return t;if(y=u?b.filter(e=>r.videoRanges[e]>0):[],T){if(r.minBitrate>i)return fV(s,`min bitrate of ${r.minBitrate} > current estimate of ${i}`),t;if(!r.hasDefaultAudio)return fV(s,"no renditions with default or auto-select sound found"),t;if(l&&s.indexOf(l.substring(0,4))%5!=0)return fV(s,`audio codec preference "${l}" not found`),t;if(n&&!d){if(!r.channels[n])return fV(s,`no renditions with ${n} channel sound found (channels options: ${Object.keys(r.channels)})`),t}else if((!l||d)&&h&&0===r.channels["2"])return fV(s,"no renditions with stereo sound found"),t;if(r.minHeight>E)return fV(s,`min resolution of ${r.minHeight} > maximum of ${E}`),t;if(r.minFramerate>S)return fV(s,`min framerate of ${r.minFramerate} > maximum of ${S}`),t;if(!y.some(e=>r.videoRanges[e]>0))return fV(s,`no variants with VIDEO-RANGE of ${fj(y)} found`),t;if(o&&s.indexOf(o.substring(0,4))%5!=0)return fV(s,`video codec preference "${o}" not found`),t;if(r.maxScore<g)return fV(s,`max score of ${r.maxScore} < selected max of ${g}`),t}return t&&(fT(s)>=fT(t)||r.fragmentError>e[t].fragmentError)?t:(m=r.minIndex,g=r.maxScore,s)},void 0),videoRanges:y,preferHDR:v,minFramerate:f,minBitrate:p,minIndex:m}}(this.codecTiers||(this.codecTiers=m.slice(t,i+1).reduce((e,t,i)=>{if(!t.codecSet)return e;let s=t.audioGroups,r=e[t.codecSet];r||(e[t.codecSet]=r={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,minIndex:i,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!s,fragmentError:0}),r.minBitrate=Math.min(r.minBitrate,t.bitrate);let a=Math.min(t.height,t.width);return r.minHeight=Math.min(r.minHeight,a),r.minFramerate=Math.min(r.minFramerate,t.frameRate),r.minIndex=Math.min(r.minIndex,i),r.maxScore=Math.max(r.maxScore,t.score),r.fragmentError+=t.fragmentError,r.videoRanges[t.videoRange]=(r.videoRanges[t.videoRange]||0)+1,s&&s.forEach(e=>{if(!e)return;let t=A.groups[e];t&&(r.hasDefaultAudio=r.hasDefaultAudio||A.hasDefaultAudio?t.hasDefault:t.hasAutoSelect||!A.hasDefaultAudio&&!A.hasAutoSelectAudio,Object.keys(t.channels).forEach(e=>{r.channels[e]=(r.channels[e]||0)+t.channels[e]}))}),e},{})),T,e,k,w),{codecSet:r,videoRanges:a,minFramerate:n,minBitrate:l,minIndex:o,preferHDR:h}=s;R=o,d=r,T=h?a[a.length-1]:a[0],x=n,e=Math.max(e,l),this.log(`picked start tier ${fj(s)}`)}else d=null==b?void 0:b.codecSet,T=null==b?void 0:b.videoRange;let L=p?p.duration:f?f.duration:0,C=this.bwEstimator.getEstimateTTFB()/1e3,I=[];for(let l=i;l>=t;l--){let t,f=m[l],g=l>c;if(!f)continue;if(v.useMediaCapabilities&&!f.supportedResult&&!f.supportedPromise){let t=navigator.mediaCapabilities;"function"==typeof(null==t?void 0:t.decodingInfo)&&function(e,t,i,s,r,a){let n=e.videoCodec,l=e.audioCodec?e.audioGroups:null,o=null==a?void 0:a.audioCodec,d=null==a?void 0:a.channels,h=d?parseInt(d):o?1/0:2,u=null;if(null!=l&&l.length)try{u=1===l.length&&l[0]?t.groups[l[0]].channels:l.reduce((e,i)=>{if(i){let s=t.groups[i];if(!s)throw Error(`Audio track group ${i} not found`);Object.keys(s.channels).forEach(t=>{e[t]=(e[t]||0)+s.channels[t]})}return e},{2:0})}catch(e){return!0}return void 0!==n&&(n.split(",").some(e=>ff(e))||e.width>1920&&e.height>1088||e.height>1920&&e.width>1088||e.frameRate>Math.max(s,30)||"SDR"!==e.videoRange&&e.videoRange!==i||e.bitrate>Math.max(r,8e6))||!!u&&cS(h)&&Object.keys(u).some(e=>parseInt(e)>h)}
29(f,A,T,x,e,k)?(f.supportedPromise=fM(f,A,t,this.supportedCache),f.supportedPromise.then(e=>{if(!this.hls)return;f.supportedResult=e;let t=this.hls.levels,i=t.indexOf(f);e.error?this.warn(`MediaCapabilities decodingInfo error: "${e.error}" for level ${i} ${fj(e)}`):e.supported?e.decodingInfoResults.some(e=>!1===e.smooth||!1===e.powerEfficient)&&this.log(`MediaCapabilities decodingInfo for level ${i} not smooth or powerEfficient: ${fj(e)}`):(this.warn(`Unsupported MediaCapabilities decodingInfo result for level ${i} ${fj(e)}`),i>-1&&t.length>1&&(this.log(`Removing unsupported level ${i}`),this.hls.removeLevel(i),-1===this.hls.loadLevel&&(this.hls.nextLoadLevel=0)))}).catch(e=>{this.warn(`Error handling MediaCapabilities decodingInfo: ${e}`)})):f.supportedResult=fP}if((d&&f.codecSet!==d||T&&f.videoRange!==T||g&&x>f.frameRate||!g&&x>0&&x<f.frameRate||null!=(o=f.supportedResult)&&null!=(o=o.decodingInfoResults)&&o.some(e=>!1===e.smooth))&&(!S||l!==R)){I.push(l);continue}let b=f.details,w=(p?null==b?void 0:b.partTarget:null==b?void 0:b.averagetargetduration)||L;t=g?n*e:a*e;let P=L&&s>=2*L&&0===r?f.averageBitrate:f.maxBitrate,D=this.getTimeToLoadFrag(C,t,P*w,void 0===b);if(t>=P&&(l===u||0===f.loadError&&0===f.fragmentError)&&(D<=C||!cS(D)||E&&!this.bitrateTestDelay||D<h)){let e=this.forcedAutoLevel;return l!==y&&(-1===e||e!==y)&&(I.length&&this.trace(`Skipped level(s) ${I.join(",")} of ${i} max with CODECS and VIDEO-RANGE:"${m[I[0]].codecs}" ${m[I[0]].videoRange}; not compatible with "${d}" ${T}`),this.info(`switch candidate:${c}->${l} adjustedbw(${Math.round(t)})-bitrate=${Math.round(t-P)} ttfb:${C.toFixed(1)} avgDuration:${w.toFixed(1)} maxFetchDuration:${h.toFixed(1)} fetchDuration:${D.toFixed(1)} firstSelection:${S} codecSet:${f.codecSet} videoRange:${f.videoRange} hls.loadLevel:${y}`)),S&&(this.firstSelection=l),l}}return -1}set nextAutoLevel(e){let t=this.deriveNextAutoLevel(e);this._nextAutoLevel!==t&&(this.nextAutoLevelKey="",this._nextAutoLevel=t)}deriveNextAutoLevel(e){let{maxAutoLevel:t,minAutoLevel:i}=this.hls;return Math.min(Math.max(e,i),t)}},bufferController:class extends cB{constructor(e,t){super("buffer-controller",e.logger),this.hls=void 0,this.fragmentTracker=void 0,this.details=null,this._objectUrl=null,this.operationQueue=null,this.bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.blockedAudioAppend=null,this.lastVideoAppendEnd=0,this.appendSource=void 0,this.transferData=void 0,this.overrides=void 0,this.appendErrors={audio:0,video:0,audiovideo:0},this.tracks={},this.sourceBuffers=[[null,null],[null,null]],this._onEndStreaming=e=>{var t;this.hls&&(null==(t=this.mediaSource)?void 0:t.readyState)==="open"&&this.hls.pauseBuffering()},this._onStartStreaming=e=>{this.hls&&this.hls.resumeBuffering()},this._onMediaSourceOpen=e=>{let{media:t,mediaSource:i}=this;e&&this.log("Media source opened"),t&&i&&(i.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("emptied",this._onMediaEmptied),this.updateDuration(),this.hls.trigger(cA.MEDIA_ATTA
29CHED,{media:t,mediaSource:i}),null!==this.mediaSource&&this.checkPendingTracks())},this._onMediaSourceClose=()=>{this.log("Media source closed")},this._onMediaSourceEnded=()=>{this.log("Media source ended")},this._onMediaEmptied=()=>{let{mediaSrc:e,_objectUrl:t}=this;e!==t&&this.error(`Media element src was set while attaching MediaSource (${t} > ${e})`)},this.hls=e,this.fragmentTracker=t,this.appendSource=function(e){return"u">typeof self&&e===self.ManagedMediaSource}(cH(e.config.preferManagedMediaSource)),this.initTracks(),this.registerListeners()}hasSourceTypes(){return Object.keys(this.tracks).length>0}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.transferData=this.overrides=void 0,this.operationQueue&&(this.operationQueue.destroy(),this.operationQueue=null),this.hls=this.fragmentTracker=null,this._onMediaSourceOpen=this._onMediaSourceClose=null,this._onMediaSourceEnded=null,this._onStartStreaming=this._onEndStreaming=null}registerListeners(){let{hls:e}=this;
29e.on(cA.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(cA.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(cA.MANIFEST_LOADING,this.onManifestLoading,this),e.on(cA.MANIFEST_PARSED,this.onManifestParsed,this),e.on(cA.BUFFER_RESET,this.onBufferReset,this),e.on(cA.BUFFER_APPENDING,this.onBufferAppending,this),e.on(cA.BUFFER_CODECS,this.onBufferCodecs,this),e.on(cA.BUFFER_EOS,this.onBufferEos,this),e.on(cA.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(cA.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(cA.FRAG_PARSED,this.onFragParsed,this),e.on(cA.FRAG_CHANGED,this.onFragChanged,this),e.on(cA.ERROR,this.onError,this)}unregisterListeners(){let{hls:e}=this;e.off(cA.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(cA.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(cA.MANIFEST_LOADING,this.onManifestLoading,this),e.off(cA.MANIFEST_PARSED,this.onManifestParsed,this),e.off(cA.BUFFER_RESET,this.onBufferReset,this),e.off(cA.BUFFER_APPENDING,this.onBufferAppending,this),e.off(cA.BUFFER_CODECS,this.onBufferCodecs,this),e.off(cA.BUFFER_EOS,this.onBufferEos,this),e.off(cA.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(cA.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(cA.FRAG_PARSED,this.onFragParsed,this),e.off(cA.FRAG_CHANGED,this.onFragChanged,this),e.off(cA.ERROR,this.onError,this)}transferMedia(){let{media:e,mediaSource:t}=this;if(!e)return null;let i={};if(this.operationQueue){let e=this.isUpdating();e||this.operationQueue.removeBlockers();let t=this.isQueued();(e||t)&&this.warn(`Transfering MediaSource with${t?" operations in queue":""}${e?" updating SourceBuffer(s)":""} ${this.operationQueue}`),this.operationQueue.destroy()}let s=this.transferData;return!this.sourceBufferCount&&s&&s.mediaSource===t?cO(i,s.tracks):this.sourceBuffers.forEach(e=>{let[t]=e;t&&(i[t]=cO({},this.tracks[t]),this.removeBuffer(t)),e[0]=e[1]=null}),{media:e,mediaSource:t,tracks:i}}initTracks(){this.sourceBuffers=[[null,null],[null,null]],this.tracks={},this.resetQueue(),this.resetAppendErrors(),this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.lastVideoAppendEnd=0}onManifestLoading(){this.bufferCodecEventsTotal=0,this.details=null}onManifestParsed(e,t){var i;let s=2;(!t.audio||t.video)&&t.altAudio||(s=1),this.bufferCodecEventsTotal=s,this.log(`${s} bufferCodec event(s) expected.`),null!=(i=this.transferData)&&i.mediaSource&&this.sourceBufferCount&&s&&this.bufferCreated()}onMediaAttaching(e,t){let i=this.media=t.media;this.transferData=this.overrides=void 0;let s=cH(this.appendSource);if(s){let e=!!t.mediaSource;(e||t.overrides)&&(this.transferData=t,this.overrides=t.overrides);let n=this.mediaSource=t.mediaSource||new s;if(this.assignMediaSource(n),e)this._objectUrl=i.src,this.attachTransferred();else{let e=this._objectUrl=self.URL.createObjectURL(n);if(this.appendSource)try{var r,a;let t;i.removeAttribute("src");let s=self.ManagedMediaSource;i.disableRemotePlayback=i.disableRemotePlayback||s&&n instanceof s,gQ(i),r=i,a=e,(t=self.document.createElement("source")).type="video/mp4",t.src=a,r.appendChild(t),i.load()}catch(t){i.src=e}else i.src=e}i.addEventListener("emptied",this._onMediaEmptied)}}assignMediaSource(e){var t,i;this.log(`${(null==(t=this.transferData)?void 0:t.mediaSource)===e?"transferred":"created"} media source: ${null==(i=e.constructor)?void 0:i.name}`),e.addEventListener("sourceopen",this._onMediaSourceOpen),e.addEventListener("sourceended",this._onMediaSourceEnded),e.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(e.addEventListener("startstreaming",this._onStartStreaming),e.addEventListener("endstreaming",this._onEndStreaming))}attachTransferred(){let e=this.media,t=this.transferData;if(!t||!e)return;let i=this.tracks,s=t.tracks,r=s?Object.keys(s):null,a=r?r.length:0,n=()=>{Promise.resolve().then(()=>{this.media&&this.mediaSourceOpenOrEnded&&this._onMediaSourceOpen()})};if(s&&r&&a){if(!this.tracksReady){this.hls.config.startFragPrefetch=!0,this.log("attachTransferred: waiting for SourceBuffer track info");return}if(this.log(`attachTransferred: (bufferCodecEventsTotal ${this.bufferCodecEventsTotal})
30required tracks: ${fj(i,(e,t)=>"initSegment"===e?void 0:t)};
31transfer tracks: ${fj(s,(e,t)=>"initSegment"===e?void 0:t)}}`),!cK(s,i)){t.mediaSource=null,t.tracks=void 0;let r=e.currentTime,a=this.details,n=Math.max(r,(null==a?void 0:a.fragments[0].start)||0);return n-r>1?void this.log(`attachTransferred: waiting for playback to reach new tracks start time ${r} -> ${n}`):(this.warn(`attachTransferred: resetting MediaSource for incompatible tracks ("${Object.keys(s)}"->"${Object.keys(i)}") start time: ${n} currentTime: ${r}`),this.onMediaDetaching(cA.MEDIA_DETACHING,{}
31),this.onMediaAttaching(cA.MEDIA_ATTACHING,t),void(e.currentTime=n))}this.transferData=void 0,r.forEach(e=>{let t=s[e];if(t){let i=t.buffer;if(i){let s=this.fragmentTracker,r=t.id;if(s.hasFragments(r)||s.hasParts(r)){let t=pv.getBuffered(i);s.detectEvictedFragments(e,t,r,null,!0)}let a=gX(e),n=[e,i];this.sourceBuffers[a]=n,i.updating&&this.operationQueue&&this.operationQueue.prependBlocker(e),this.trackSourceBuffer(e,t)}}}),n(),this.bufferCreated()}else this.log("attachTransferred: MediaSource w/o SourceBuffers"),n()}get mediaSourceOpenOrEnded(){var e;let t=null==(e=this.mediaSource)?void 0:e.readyState;return"open"===t||"ended"===t}onMediaDetaching(e,t){let i=!!t.transferMedia;this.transferData=this.overrides=void 0;let{media:s,mediaSource:r,_objectUrl:a}=this;if(r){if(this.log(`media source ${i?"transferring":"detaching"}`),i)this.sourceBuffers.forEach(([e])=>{e&&this.removeBuffer(e)}),this.resetQueue();else{if(this.mediaSourceOpenOrEnded){let e="open"===r.readyState;try{let t=r.sourceBuffers;for(let i=t.length;i--;)e&&t[i].abort(),r.removeSourceBuffer(t[i]);e&&r.endOfStream()}catch(e){this.warn(`onMediaDetaching: ${e.message} while calling endOfStream`)}}this.sourceBufferCount&&this.onBufferReset()}r.removeEventListener("sourceopen",this._onMediaSourceOpen),r.removeEventListener("sourceended",this._onMediaSourceEnded),r.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(r.removeEventListener("startstreaming",this._onStartStreaming),r.removeEventListener("endstreaming",this._onEndStreaming)),this.mediaSource=null,this._objectUrl=null}s&&(s.removeEventListener("emptied",this._onMediaEmptied),i||(a&&self.URL.revokeObjectURL(a),this.mediaSrc===a?(s.removeAttribute("src"),this.appendSource&&gQ(s),s.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.media=null),this.hls.trigger(cA.MEDIA_DETACHED,t)}onBufferReset(){this.sourceBuffers.forEach(([e])=>{e&&this.resetBuffer(e)}),this.initTracks()}resetBuffer(e){var t,i;let s=null==(t=this.tracks[e])?void 0:t.buffer;if(this.removeBuffer(e),s)try{null!=(i=this.mediaSource)&&i.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(s)}catch(t){this.warn(`onBufferReset ${e}`,t)}delete this.tracks[e]}removeBuffer(e){this.removeBufferListeners(e),this.sourceBuffers[gX(e)]=[null,null];let t=this.tracks[e];t&&(t.buffer=void 0)}resetQueue(){this.operationQueue&&this.operationQueue.destroy(),this.operationQueue=new gK(this.tracks)}onBufferCodecs(e,t){var i;let s=this.tracks,r=Object.keys(t);this.log(`BUFFER_CODECS: "${r}" (current SB count ${this.sourceBufferCount})`);let a="audiovideo"in t&&(s.audio||s.video)||s.audiovideo&&("audio"in t||"video"in t),n=!a&&this.sourceBufferCount&&this.media&&r.some(e=>!s[e]);a||n?this.warn(`Unsupported transition between "${Object.keys(s)}" and "${r}" SourceBuffers`):(r.forEach(e=>{var i,r;let{id:a,codec:n,levelCodec:l,container:o,metadata:d,supplemental:h}=t[e],u=s[e],c=null==(i=this.transferData)||null==(i=i.tracks)?void 0:i[e],f=null!=c&&c.buffer?c:u,p=(null==f?void 0:f.pendingCodec)||(null==f?void 0:f.codec),m=null==f?void 0:f.levelCodec;u||(u=s[e]={buffer:void 0,listeners:[],codec:n,supplemental:h,container:o,levelCodec:l,metadata:d,id:a});let g=fA(p,m),y=null==g?void 0:g.replace(gW,"$1"),v=fA(n,l),b=null==(r=v)?void 0:r.replace(gW,"$1");v&&g&&y!==b&&("audio"===e.slice(0,5)&&(v=fw(v,this.appendSource)),this.log(`switching codec ${p} to ${v}`),v!==(u.pendingCodec||u.codec)&&(u.pendingCodec=v),u.container=o,this.appendChangeType(e,o,v))}),(this.tracksReady||this.sourceBufferCount)&&(t.tracks=this.sourceBufferTracks),!this.sourceBufferCount&&(!(this.bufferCodecEventsTotal>1)||this.tracks.video||t.video||(null==(i=t.audio)?void 0:i.id)!=="main"||(this.log("Main audio-only"),this.bufferCodecEventsTotal=1),this.mediaSourceOpenOrEnded&&this.checkPendingTracks()))}get sourceBufferTracks(){return Object.keys(this.tracks).reduce((e,t)=>{let i=this.tracks[t];return e[t]={id:i.id,container:i.container,codec:i.codec,levelCodec:i.levelCodec},e},{})}appendChangeType(e,t,i){let s=`${t};codecs=${i}`,r={label:`change-type=${s}`,execute:()=>{let r=this.tracks[e];if(r){let a=r.buffer;null!=a&&a.changeType&&(this.log(`changing ${e} sourceBuffer type to ${s}`),a.changeType(s),r.codec=i,r.container=t)}this.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:t=>{this.warn(`Failed to change ${e} SourceBuffer type`,t)}};this.append(r,e,this.isPending(this.tracks[e]))}blockAudio(e){var t;let i=e.start,s=i+.05*e.duration;if((null==(t=this.fragmentTracker.getAppendedFrag(i,cP))?void 0:t.gap)===!0)return;let r={label:"block-audio",execute:()=>{var e;let t=this.tracks.video;(this.lastVideoAppendEnd>s||null!=t&&t.buffer&&pv.isBuffered(t.buffer,s)||(null==(e=this.fragmentTracker.getAppendedFrag(s,cP))?void 0:e.gap)===!0)&&(this.blockedAudioAppend=null,this.shiftAndExecuteNext("audio"))},onStart:()=>{},onComplete:()=>{},onError:e=>{this.warn("Error executing block-audio operation",e)}};this.blockedAudioAppend={op:r,frag:e},this.append(r,"audio",!0)}unblockAudio(){let{blockedAudioAppend:e,operationQueue:t}=this;e&&t&&(this.blockedAudioAppend=null,t.unblockAudio(e.op))}onBufferAppending(e,t){let{tracks:i}=this,{data:s,type:r,parent:a,frag:n,part:l,chunkMeta:o,offset:d}=t,h=o.buffering[r],{sn:u,cc:c}=n,f=self.performance.now();h.start=f;let p=n.stats.buffering,m=l?l.stats.buffering:null;0===p.start&&(p.start=f),m&&0===m.start&&(m.start=f);let g=i.audio,y=!1;"audio"===r&&(null==g?void 0:g.container)==="audio/mpeg"&&(y=!this.lastMpegAudioChunk||1===o.id||this.lastMpegAudioChunk.sn!==o.sn,this.lastMpegAudioChunk=o);let v=i.video,b=null==v?void 0:v.buffer;if(b&&"initSegment"!==u){let e=l||n,t=this.blockedAudioAppend;if("audio"!==r||"main"===a||this.blockedAudioAppend||v.ending||v.ended){if("video"===r){let i=e.end;if(t){let e=t.frag.start;(i>e||i<this.lastVideoAppendEnd||pv.isBuffered(b,e))&&this.unblockAudio()}this.lastVideoAppendEnd=i}}else{let t=e.start+.05*e.duration,i=b.buffered,s=this.currentOp("video");(i.length||s)&&(s||pv.isBuffered(b,t)||!(this.lastVideoAppendEnd<t))||this.blockAudio(e)}}let E=(l||n).start,S={label:`append-${r}`,execute:()=>{var e;h.executeStart=self.performance.now();let t=null==(e=this.tracks[r])?void 0:e.buffer;t&&(y?this.updateTimestampOffset(t,E,.1,r,u,c):void 0!==d&&cS(d)&&this.updateTimestampOffset(t,d,1e-6,r,u,c)),this.appendExecutor(s,r)},onStart:()=>{},onComplete:()=>{let e=self.performance.now();h.executeEnd=h.end=e,0===p.first&&(p.first=e),m&&0===m.first&&(m.first=e);let t={};
31this.sourceBuffers.forEach(([e,i])=>{e&&(t[e]=pv.getBuffered(i))}),this.appendErrors[r]=0,"audio"===r||"video"===r?this.appendErrors.audiovideo=0:(this.appendErrors.audio=0,this.appendErrors.video=0),this.hls.trigger(cA.BUFFER_APPENDED,{type:r,frag:n,part:l,chunkMeta:o,parent:n.type,timeRanges:t})},onError:e=>{var t;let i={type:ck.MEDIA_ERROR,parent:n.type,details:cw.BUFFER_APPEND_ERROR,sourceBufferName:r,frag:n,part:l,chunkMeta:o,error:e,err:e,fatal:!1},s=null==(t=this.media)?void 0:t.error;if(e.code===DOMException.QUOTA_EXCEEDED_ERR||"QuotaExceededError"==e.name||"quota"in e)i.details=cw.BUFFER_FULL_ERROR;else if(e.code===DOMException.INVALID_STATE_ERR&&this.mediaSourceOpenOrEnded&&!s)i.errorAction=f7(!0);else if(e.name===gz&&0===this.sourceBufferCount)i.errorAction=f7(!0);else{let e=++this.appendErrors[r];this.warn(`Failed ${e}/${this.hls.config.appendErrorMaxRetry} times to append segment in "${r}" sourceBuffer (${s||"no media error"})`),(e>=this.hls.config.appendErrorMaxRetry||s)&&(i.fatal=!0)}this.hls.trigger(cA.ERROR,i)}};this.log(`queuing "${r}" append sn: ${u}${l?" p: "+l.index:""} of ${n.type===cP?"level":"track"} ${n.level} cc: ${c}`),this.append(S,r,this.isPending(this.tracks[r]))}getFlushOp(e,t,i){return this.log(`queuing "${e}" remove ${t}-${i}`),{label:"remove",execute:()=>{this.removeExecutor(e,t,i)},onStart:()=>{},onComplete:()=>{this.hls.trigger(cA.BUFFER_FLUSHED,{type:e})},onError:s=>{this.warn(`Failed to remove ${t}-${i} from "${e}" SourceBuffer`,s)}}}onBufferFlushing(e,t){let{type:i,startOffset:s,endOffset:r}=t;i?this.append(this.getFlushOp(i,s,r),i):this.sourceBuffers.forEach(([e])=>{e&&this.append(this.getFlushOp(e,s,r),e)})}onFragParsed(e,t){let{frag:i,part:s}=t,r=[],a=s?s.elementaryStreams:i.elementaryStreams;a[c1]?r.push("audiovideo"):(a[cZ]&&r.push("audio"),a[c0]&&r.push("video"));let n=()=>{let e=self.performance.now();i.stats.buffering.end=e,s&&(s.stats.buffering.end=e);let t=s?s.stats:i.stats;this.hls.trigger(cA.FRAG_BUFFERED,{frag:i,part:s,stats:t,id:i.type})};0===r.length&&this.warn(`Fragments must have at least one ElementaryStreamType set. type: ${i.type} level: ${i.level} sn: ${i.sn}`),this.blockBuffers(n,r).catch(e=>{this.warn(`Fragment buffered callback ${e}`),this.stepOperationQueue(this.sourceBufferTypes)})}onFragChanged(e,t){this.trimBuffers()}get bufferedToEnd(){return this.sourceBufferCount>0&&!this.sourceBuffers.some(([e])=>{if(e){let t=this.tracks[e];if(t)return!t.ended||t.ending}return!1})}onBufferEos(e,t){var i;this.sourceBuffers.forEach(([e])=>{if(e){let i=this.tracks[e];(!t.type||t.type===e)&&(i.ending=!0,i.ended||(i.ended=!0,this.log(`${e} buffer reached EOS`)))}});let s=(null==(i=this.overrides)?void 0:i.endOfStream)!==!1;this.sourceBufferCount>0&&!this.sourceBuffers.some(([e])=>{var t;return e&&!(null!=(t=this.tracks[e])&&t.ended)})?s?(this.log("Queueing EOS"),this.blockUntilOpen(()=>{this.tracksEnded();let{mediaSource:e}=this;if(!e||"open"!==e.readyState){e&&this.log(`Could not call mediaSource.endOfStream(). mediaSource.readyState: ${e.readyState}`);return}this.log("Calling mediaSource.endOfStream()"),e.endOfStream(),this.hls.trigger(cA.BUFFERED_TO_END,void 0)})):(this.tracksEnded(),this.hls.trigger(cA.BUFFERED_TO_END,void 0)):"video"===t.type&&this.unblockAudio()}tracksEnded(){this.sourceBuffers.forEach(([e])=>{if(null!==e){let t=this.tracks[e];t&&(t.ending=!1)}})}onLevelUpdated(e,{details:t}){t.fragments.length&&(this.details=t,this.updateDuration())}updateDuration(){this.blockUntilOpen(()=>{let e=this.getDurationAndRange();e&&this.updateMediaSource(e)})}onError(e,t){if(t.details===cw.BUFFER_APPEND_ERROR&&t.frag){var i;let e=null==(i=t.errorAction)?void 0:i.nextAutoLevel;cS(e)&&e!==t.frag.level&&this.resetAppendErrors()}}resetAppendErrors(){this.appendErrors={audio:0,video:0,audiovideo:0}}trimBuffers(){let{hls:e,details:t,media:i}=this;if(!i||null===t||!this.sourceBufferCount)return;let s=e.config,r=i.currentTime,a=t.levelTargetDuration,n=t.live&&null!==s.liveBackBufferLength?s.liveBackBufferLength:s.backBufferLength;if(cS(n)&&n>=0){let e=Math.max(n,a),t=Math.floor(r/a)*a-e;this.flushBackBuffer(r,a,t)}let l=s.frontBufferFlushThreshold;if(cS(l)&&l>0){let e=Math.max(Math.max(s.maxBufferLength,l),a),t=Math.floor(r/a)*a+e;this.flushFrontBuffer(r,a,t)}}
31flushBackBuffer(e,t,i){this.sourceBuffers.forEach(([e,t])=>{if(t){let r=pv.getBuffered(t);if(r.length>0&&i>r.start(0)){var s;this.hls.trigger(cA.BACK_BUFFER_REACHED,{bufferEnd:i});let t=this.tracks[e];if(null!=(s=this.details)&&s.live)this.hls.trigger(cA.LIVE_BACK_BUFFER_REACHED,{bufferEnd:i});else if(null!=t&&t.ended)return void this.log(`Cannot flush ${e} back buffer while SourceBuffer is in ended state`);this.hls.trigger(cA.BUFFER_FLUSHING,{startOffset:0,endOffset:i,type:e})}}})}flushFrontBuffer(e,t,i){this.sourceBuffers.forEach(([t,s])=>{if(s){let r=pv.getBuffered(s),a=r.length;if(a<2)return;let n=r.start(a-1),l=r.end(a-1);i>n||e>=n&&e<=l||this.hls.trigger(cA.BUFFER_FLUSHING,{startOffset:n,endOffset:1/0,type:t})}})}getDurationAndRange(){var e;let{details:t,mediaSource:i}=this;if(!t||!this.media||(null==i?void 0:i.readyState)!=="open")return null;let s=t.edge;if(t.live&&this.hls.config.liveDurationInfinity){if(t.fragments.length&&i.setLiveSeekableRange){let e=Math.max(0,t.fragmentStart),i=Math.max(e,s);return{duration:1/0,start:e,end:i}}return{duration:1/0}}let r=null==(e=this.overrides)?void 0:e.duration;if(r)return cS(r)?{duration:r}:null;let a=this.media.duration;return s>(cS(i.duration)?i.duration:0)&&s>a||!cS(a)?{duration:s}:null}updateMediaSource({duration:e,start:t,end:i}){let s=this.mediaSource;this.media&&s&&"open"===s.readyState&&(s.duration!==e&&(cS(e)&&this.log(`Updating MediaSource duration to ${e.toFixed(3)}`),s.duration=e),void 0!==t&&void 0!==i&&(this.log(`MediaSource duration is set to ${s.duration}. Setting seekable range to ${t}-${i}.`),s.setLiveSeekableRange(t,i)))}get tracksReady(){let e=this.pendingTrackCount;return e>0&&(e>=this.bufferCodecEventsTotal||this.isPending(this.tracks.audiovideo))}checkPendingTracks(){let{bufferCodecEventsTotal:e,pendingTrackCount:t,tracks:i}=this;if(this.log(`checkPendingTracks (pending: ${t} codec events expected: ${e}) ${fj(i)}`),this.tracksReady){var s;let e=null==(s=this.transferData)?void 0:s.tracks;e&&Object.keys(e).length?this.attachTransferred():this.createSourceBuffers()}}bufferCreated(){if(this.sourceBufferCount){let e={};this.sourceBuffers.forEach(([t,i])=>{if(t){let s=this.tracks[t];e[t]={buffer:i,container:s.container,codec:s.codec,supplemental:s.supplemental,levelCodec:s.levelCodec,id:s.id,metadata:s.metadata}}}),this.hls.trigger(cA.BUFFER_CREATED,{tracks:e}),this.log(`SourceBuffers created. Running queue: ${this.operationQueue}`),this.sourceBuffers.forEach(([e])=>{this.executeNext(e)})}else{let e=Error("could not create source buffer for media codec(s)");this.hls.trigger(cA.ERROR,{type:ck.MEDIA_ERROR,details:cw.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:e,reason:e.message})}}createSourceBuffers(){let{tracks:e,sourceBuffers:t,mediaSource:i}=this;if(!i)throw Error("createSourceBuffers called when mediaSource was null");for(let r in e){let a=e[r];if(this.isPending(a)){let e=this.getTrackCodec(a,r),n=`${a.container};codecs=${e}`;a.codec=e,this.log(`creating sourceBuffer(${n})${this.currentOp(r)?" Queued":""} ${fj(a)}`);try{let e=i.addSourceBuffer(n),s=gX(r),l=[r,e];t[s]=l,a.buffer=e}catch(e){var s;this.error(`error while trying to add sourceBuffer: ${e.message}`),this.shiftAndExecuteNext(r),null==(s=this.operationQueue)||s.removeBlockers(),delete this.tracks[r],this.hls.trigger(cA.ERROR,{type:ck.MEDIA_ERROR,details:cw.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:e,sourceBufferName:r,mimeType:n,parent:a.id});return}this.trackSourceBuffer(r,a)}}this.bufferCreated()}getTrackCodec(e,t){let i=e.supplemental,s=e.codec;i&&("video"===t||"audiovideo"===t)&&fv(i,"video")&&(s=function(e,t){let i=[];if(e){let t=e.split(",");for(let e=0;e<t.length;e++)fy(t[e],"video")||i.push(t[e])}return t&&i.push(t),i.join(",")}(s,i));let r=fA(s,e.levelCodec);return r?"audio"===t.slice(0,5)?fw(r,this.appendSource):r:""}trackSourceBuffer(e,t){let i=t.buffer;if(!i)return;let s=this.getTrackCodec(t,e);this.tracks[e]={buffer:i,codec:s,container:t.container,levelCodec:t.levelCodec,supplemental:t.supplemental,metadata:t.metadata,id:t.id,listeners:[]},this.removeBufferListeners(e),this.addBufferListener(e,"updatestart",this.onSBUpdateStart),this.addBufferListener(e,"updateend",this.onSBUpdateEnd),this.addBufferListener(e,"error",this.onSBUpdateError),this.appendSource&&this.addBufferListener(e,"bufferedchange",(e,t)=>{let i=t.removedRanges;null!=i&&i.length&&this.hls.trigger(cA.BUFFER_FLUSHED,{type:e})})}get mediaSrc(){var e,t;let i=(null==(e=this.media)||null==(t=e.querySelector)?void 0:t.call(e,"source"))||this.media;return null==i?void 0:i.src}onSBUpdateStart(e){let t=this.currentOp(e);t&&t.onStart()}onSBUpdateEnd(e){var t;if((null==(t=this.mediaSource)?void 0:t.readyState)==="closed")return void this.resetBuffer(e);let i=this.currentOp(e);i&&(i.onComplete(),this.shiftAndExecuteNext(e))}onSBUpdateError(e,t){var i;let s=Error(`${e} SourceBuffer error. MediaSource readyState: ${null==(i=this.mediaSource)?void 0:i.readyState}`);this.error(`${s}`,t),this.hls.trigger(cA.ERROR,{type:ck.MEDIA_ERROR,details:cw.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:s,fatal:!1});let r=this.currentOp(e);r&&r.onError(s)}updateTimestampOffset(e,t,i,s,r,a){Math.abs(t-e.timestampOffset)>=i&&(this.log(`Updating ${s} SourceBuffer timestampOffset to ${t} (sn: ${r} cc: ${a})`),e.timestampOffset=t)}removeExecutor(e,t,i){let{media:s,mediaSource:r}=this,a=this.tracks[e],n=null==a?void 0:a.buffer;if(!s||!r||!n){this.warn(`Attempting to remove from the ${e} SourceBuffer, but it does not exist`),this.shiftAndExecuteNext(e);return}let l=cS(s.duration)?s.duration:1/0,o=cS(r.duration)?r.duration:1/0,d=Math.max(0,t),h=Math.min(i,l,o);h>d&&(!a.ending||a.ended)?(a.ended=!1,this.log(`Removing [${d},${h}] from the ${e} SourceBuffer`),n.remove(d,h)):this.shiftAndExecuteNext(e)}appendExecutor(e,t){let i=this.tracks[t],s=null==i?void 0:i.buffer;if(!s)throw new gY(`Attempting to append to the ${t} SourceBuffer, but it does not exist`);i.ending=!1,i.ended=!1,s.appendBuffer(e)}blockUntilOpen(e){if(this.isUpdating()||this.isQueued())this.blockBuffers(e).catch(e=>{this.warn(`SourceBuffer blocked callback ${e}
31`),this.stepOperationQueue(this.sourceBufferTypes)});else try{e()}catch(e){this.warn(`Callback run without blocking ${this.operationQueue} ${e}`)}}isUpdating(){return this.sourceBuffers.some(([e,t])=>e&&t.updating)}isQueued(){return this.sourceBuffers.some(([e])=>e&&!!this.currentOp(e))}isPending(e){return!!e&&!e.buffer}blockBuffers(e,t=this.sourceBufferTypes){if(!t.length)return this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);let{operationQueue:i}=this,s=t.map(e=>this.appendBlocker(e));return t.length>1&&this.blockedAudioAppend&&this.unblockAudio(),Promise.all(s).then(t=>{i===this.operationQueue&&(e(),this.stepOperationQueue(this.sourceBufferTypes))})}stepOperationQueue(e){e.forEach(e=>{var t;let i=null==(t=this.tracks[e])?void 0:t.buffer;i&&!i.updating&&this.shiftAndExecuteNext(e)})}append(e,t,i){this.operationQueue&&this.operationQueue.append(e,t,i)}appendBlocker(e){if(this.operationQueue)return this.operationQueue.appendBlocker(e)}currentOp(e){return this.operationQueue?this.operationQueue.current(e):null}executeNext(e){e&&this.operationQueue&&this.operationQueue.executeNext(e)}shiftAndExecuteNext(e){this.operationQueue&&this.operationQueue.shiftAndExecuteNext(e)}get pendingTrackCount(){return Object.keys(this.tracks).reduce((e,t)=>e+ +!!this.isPending(this.tracks[t]),0)}get sourceBufferCount(){return this.sourceBuffers.reduce((e,[t])=>e+ +!!t,0)}get sourceBufferTypes(){return this.sourceBuffers.map(([e])=>e).filter(e=>!!e)}addBufferListener(e,t,i){let s=this.tracks[e];if(!s)return;let r=s.buffer;if(!r)return;let a=i.bind(this,e);s.listeners.push({event:t,listener:a}),r.addEventListener(t,a)}removeBufferListeners(e){let t=this.tracks[e];if(!t)return;let i=t.buffer;i&&(t.listeners.forEach(e=>{i.removeEventListener(e.event,e.listener)}),t.listeners.length=0)}},capLevelController:gJ,errorController:class extends cB{constructor(e){super("error-controller",e.logger),this.hls=void 0,this.playlistError=0,this.hls=e,this.registerListeners()}registerListeners(){let e=this.hls;e.on(cA.ERROR,this.onError,this),e.on(cA.MANIFEST_LOADING,this.onManifestLoading,this),e.on(cA.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){let e=this.hls;e&&(e.off(cA.ERROR,this.onError,this),e.off(cA.ERROR,this.onErrorOut,this),e.off(cA.MANIFEST_LOADING,this.onManifestLoading,this),e.off(cA.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null}startLoad(e){}stopLoad(){this.playlistError=0}getVariantLevelIndex(e){return(null==e?void 0:e.type)===cP?e.level:this.getVariantIndex()}getVariantIndex(){var e;let t=this.hls,i=t.currentLevel;return null!=(e=t.loadLevelObj)&&e.details||-1===i?t.loadLevel:i}variantHasKey(e,t){if(e){var i;if(null!=(i=e.details)&&i.hasKey(t))return!0;let s=e.audioGroups;if(s)return this.hls.allAudioTracks.filter(e=>s.indexOf(e.groupId)>=0).some(e=>{var i;return null==(i=e.details)?void 0:i.hasKey(t)})}return!1}onManifestLoading(){this.playlistError=0}onLevelUpdated(){this.playlistError=0}onError(e,t){var i,s,r;if(t.fatal)return;let a=this.hls,n=t.context;switch(t.details){case cw.FRAG_LOAD_ERROR:case cw.FRAG_LOAD_TIMEOUT:case cw.KEY_LOAD_ERROR:case cw.KEY_LOAD_TIMEOUT:t.errorAction=this.getFragRetryOrSwitchAction(t);return;case cw.FRAG_PARSING_ERROR:if(null!=(i=t.frag)&&i.gap){t.errorAction=f7();return}case cw.FRAG_GAP:case cw.FRAG_DECRYPT_ERROR:t.errorAction=this.getFragRetryOrSwitchAction(t),t.errorAction.action=2;return;case cw.LEVEL_EMPTY_ERROR:case cw.LEVEL_PARSING_ERROR:{let e=t.parent===cP?t.level:a.loadLevel;t.details===cw.LEVEL_EMPTY_ERROR&&null!=(s=t.context)&&null!=(s=s.levelDetails)&&s.live?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,e):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,e))}return;case cw.LEVEL_LOAD_ERROR:case cw.LEVEL_LOAD_TIMEOUT:"number"==typeof(null==n?void 0:n.level)&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.level));return;case cw.AUDIO_TRACK_LOAD_ERROR:case cw.AUDIO_TRACK_LOAD_TIMEOUT:case cw.SUBTITLE_LOAD_ERROR:case cw.SUBTITLE_TRACK_LOAD_TIMEOUT:if(n){let e=a.loadLevelObj;e&&(n.type===cC&&e.hasAudioGroup(n.groupId)||n.type===cI&&e.hasSubtitleGroup(n.groupId))&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,a.loadLevel),t.errorAction.action=2,t.errorAction.flags=1)}return;case cw.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:t.errorAction={action:2,flags:2};return;case cw.KEY_SYSTEM_SESSION_UPDATE_FAILED:case cw.KEY_SYSTEM_STATUS_INTERNAL_ERROR:case cw.KEY_SYSTEM_NO_SESSION:t.errorAction={action:2,flags:4};return;
31case cw.BUFFER_ADD_CODEC_ERROR:case cw.REMUX_ALLOC_ERROR:case cw.BUFFER_APPEND_ERROR:t.errorAction||(t.errorAction=this.getLevelSwitchAction(t,null!=(r=t.level)?r:a.loadLevel));return;case cw.INTERNAL_EXCEPTION:case cw.BUFFER_APPENDING_ERROR:case cw.BUFFER_FULL_ERROR:case cw.LEVEL_SWITCH_ERROR:case cw.BUFFER_STALLED_ERROR:case cw.BUFFER_SEEK_OVER_HOLE:case cw.BUFFER_NUDGE_ON_STALL:t.errorAction=f7();return}t.type===ck.KEY_SYSTEM_ERROR&&(t.levelRetry=!1,t.errorAction=f7())}getPlaylistRetryOrSwitchAction(e,t){let i=f5(this.hls.config.playlistLoadPolicy,e),s=this.playlistError++;if(f8(i,s,f0(e),e.response))return{action:5,flags:0,retryConfig:i,retryCount:s};let r=this.getLevelSwitchAction(e,t);return i&&(r.retryConfig=i,r.retryCount=s),r}getFragRetryOrSwitchAction(e){let t=this.hls,i=this.getVariantLevelIndex(e.frag),s=t.levels[i],{fragLoadPolicy:r,keyLoadPolicy:a}=t.config,n=f5(f1(e)?a:r,e),l=t.levels.reduce((e,t)=>e+t.fragmentError,0);if(s&&(e.details!==cw.FRAG_GAP&&s.fragmentError++,!f2(e))&&f8(n,l,f0(e),e.response))return{action:5,flags:0,retryConfig:n,retryCount:l};let o=this.getLevelSwitchAction(e,i);return n&&(o.retryConfig=n,o.retryCount=l),o}getLevelSwitchAction(e,t){let i=this.hls;null==t&&(t=i.loadLevel);let s=this.hls.levels[t];if(s){var r,a,n,l;let t=e.details;s.loadError++,t===cw.BUFFER_APPEND_ERROR&&s.fragmentError++;let o=-1,{levels:d,loadLevel:h,minAutoLevel:u,maxAutoLevel:c}=i;i.autoLevelEnabled||i.config.preserveManualLevelOnError||(i.loadLevel=-1);let f=null==(r=e.frag)?void 0:r.type,p=(f===cD&&t===cw.FRAG_PARSING_ERROR||"audio"===e.sourceBufferName&&(t===cw.BUFFER_ADD_CODEC_ERROR||t===cw.BUFFER_APPEND_ERROR))&&d.some(({audioCodec:e})=>s.audioCodec!==e),m="video"===e.sourceBufferName&&(t===cw.BUFFER_ADD_CODEC_ERROR||t===cw.BUFFER_APPEND_ERROR)&&d.some(({codecSet:e,audioCodec:t})=>s.codecSet!==e&&s.audioCodec===t),{type:g,groupId:y}=null!=(a=e.context)?a:{};for(let i=d.length;i--;){let r=(i+h)%d.length;if(r!==h&&r>=u&&r<=c&&0===d[r].loadError){let i=d[r];if(t===cw.FRAG_GAP&&f===cP&&e.frag){let t=d[r].details;if(t){let i=fX(e.frag,t.fragments,e.frag.start);if(null!=i&&i.gap)continue}}else if(g===cC&&i.hasAudioGroup(y)||g===cI&&i.hasSubtitleGroup(y))continue;else if(f===cD&&null!=(n=s.audioGroups)&&n.some(e=>i.hasAudioGroup(e))||f===cM&&null!=(l=s.subtitleGroups)&&l.some(e=>i.hasSubtitleGroup(e))||p&&s.audioCodec===i.audioCodec||m&&s.codecSet===i.codecSet||!p&&s.codecSet!==i.codecSet)continue;o=r;break}}if(o>-1&&i.loadLevel!==o)return e.levelRetry=!0,this.playlistError=0,{action:2,flags:0,nextAutoLevel:o}}return{action:2,flags:1}}onErrorOut(e,t){var i;switch(null==(i=t.errorAction)?void 0:i.action){case 0:break;case 2:this.sendAlternateToPenaltyBox(t),t.errorAction.resolved||t.details===cw.FRAG_GAP?/MediaSource readyState: ended/.test(t.error.message)&&(this.warn(`MediaSource ended after "${t.sourceBufferName}" sourceBuffer append error. Attempting to recover from media error.`),this.hls.recoverMediaError()):t.fatal=!0}if(t.fatal)return void this.hls.stopLoad()}sendAlternateToPenaltyBox(e){let t=this.hls,i=e.errorAction;if(!i)return;let{flags:s}=i,r=i.nextAutoLevel;switch(s){case 0:this.switchLevel(e,r);break;case 2:{let s=this.getVariantLevelIndex(e.frag),r=t.levels[s],a=null==r?void 0:r.attrs["HDCP-LEVEL"];if(i.hdcpLevel=a,"NONE"===a)this.warn("HDCP policy resticted output with HDCP-LEVEL=NONE");else if(a){t.maxHdcpLevel=f$[f$.indexOf(a)-1],i.resolved=!0,this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`);break}}case 4:{let t=e.decryptdata;if(t){let s=this.hls.levels,r=s.length;for(let i=r;i--;)if(this.variantHasKey(s[i],t)){var a,n;this.log(`Banned key found in level ${i} (${s[i].bitrate}bps) or audio group "${null==(a=s[i].audioGroups)?void 0:a.join(",")}" (${null==(n=e.frag)?void 0:n.type} fragment) ${cz(t.keyId||[])}`),s[i].fragmentError++,s[i].loadError++,this.log(`Removing level ${i} with key error (${e.error})`),this.hls.removeLevel(i)}let l=e.frag;if(this.hls.levels.length<r)i.resolved=!0;else if(l&&l.type!==cP){let e=l.decryptdata;e&&!t.matches(e)&&(i.resolved=!0)}}}}i.resolved||this.switchLevel(e,r)}switchLevel(e,t){if(void 0!==t&&e.errorAction&&(this.warn(`switching to level ${t} after ${e.details}`),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel,e.details===cw.BUFFER_ADD_CODEC_ERROR&&e.mimeType&&"audiovideo"!==e.sourceBufferName)){let t=fC(e.mimeType),i=this.hls.levels;for(let s=i.length;s--;)i[s][`${e.sourceBufferName}Codec`]===t&&(this.log(`Removing level ${s} for ${e.details} ("${t}" not supported)`),this.hls.removeLevel(s))}}},fpsController:class{constructor(e){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=e,this.registerListeners()}setStreamController(e){this.streamController=e}
31registerListeners(){this.hls.on(cA.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.on(cA.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListeners(){this.hls.off(cA.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off(cA.MEDIA_DETACHING,this.onMediaDetaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(e,t){let i=this.hls.config;if(i.capLevelOnFPSDrop){let e=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=e,e&&"function"==typeof e.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),i.fpsDroppedMonitoringPeriod)}}onMediaDetaching(){this.media=null}checkFPS(e,t,i){let s=performance.now();if(t){if(this.lastTime){let e=s-this.lastTime,r=i-this.lastDroppedFrames,a=t-this.lastDecodedFrames,n=1e3*r/e,l=this.hls;if(l.trigger(cA.FPS_DROP,{currentDropped:r,currentDecoded:a,totalDroppedFrames:i}),n>0&&r>l.config.fpsDroppedMonitoringThreshold*a){let e=l.currentLevel;l.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+e),e>0&&(-1===l.autoLevelCapping||l.autoLevelCapping>=e)&&(e-=1,l.trigger(cA.FPS_DROP_LEVEL_CAPPING,{level:e,droppedLevel:l.currentLevel}),l.autoLevelCapping=e,this.streamController.nextLevelSwitch())}}this.lastTime=s,this.lastDroppedFrames=i,this.lastDecodedFrames=t}}checkFPSInterval(){let e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){let t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}},stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:pW,requireKeySystemAccessOnStart:!1,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableEmsgKLVMetadata:!1,enableID3MetadataCues:!0,enableInterstitialPlayback:!0,interstitialAppendInPlace:!0,interstitialLiveLookAhead:10,useMediaCapabilities:!0,preserveManualLevelOnError:!1,certLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null}},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},interstitialAssetListLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:3e4,timeoutRetry:{maxNumRetry:0,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:0,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},{cueHandler:vC,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:class extends m${constructor(e,t,i){super(e,t,i,"subt
31itle-stream-controller",cM),this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this.registerListeners()}onHandlerDestroying(){this.unregisterListeners(),super.onHandlerDestroying(),this.mainDetails=null}registerListeners(){super.registerListeners();let{hls:e}=this;e.on(cA.LEVEL_LOADED,this.onLevelLoaded,this),e.on(cA.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(cA.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(cA.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(cA.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(cA.BUFFER_FLUSHING,this.onBufferFlushing,this)}unregisterListeners(){super.unregisterListeners();let{hls:e}=this;e.off(cA.LEVEL_LOADED,this.onLevelLoaded,this),e.off(cA.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(cA.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(cA.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(cA.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(cA.BUFFER_FLUSHING,this.onBufferFlushing,this)}startLoad(e,t){this.stopLoad(),this.state=mk,this.setInterval(500),this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}onManifestLoading(){super.onManifestLoading(),this.mainDetails=null}onMediaDetaching(e,t){this.tracksBuffered=[],super.onMediaDetaching(e,t)}onLevelLoaded(e,t){this.mainDetails=t.details}onSubtitleFragProcessed(e,t){let i,{frag:s,success:r}=t;if(this.fragContextChanged(s)||(c5(s)&&(this.fragPrevious=s),this.state=mk),!r)return;let a=this.tracksBuffered[this.currentTrackId];if(!a)return;let n=s.start;for(let e=0;e<a.length;e++)if(n>=a[e].start&&n<=a[e].end){i=a[e];break}let l=s.start+s.duration;i?i.end=l:(i={start:n,end:l},a.push(i)),this.fragmentTracker.fragBuffered(s),this.fragBufferedComplete(s,null),this.media&&this.tick()}onBufferFlushing(e,t){let{startOffset:i,endOffset:s}=t;if(0===i&&s!==1/0){let e=s-1;if(e<=0)return;t.endOffsetSubtitles=Math.max(0,e),this.tracksBuffered.forEach(t=>{for(let i=0;i<t.length;){if(t[i].end<=e){t.shift();continue}if(t[i].start<e)t[i].start=e;else break;i++}}),this.fragmentTracker.removeFragmentsInRange(i,e,cM)}}onError(e,t){let i=t.frag;(null==i?void 0:i.type)===cM&&(t.details===cw.FRAG_GAP&&this.fragmentTracker.fragBuffered(i,!0),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==mx&&(this.state=mk))}onSubtitleTracksUpdated(e,{subtitleTracks:t}){if(this.levels&&gG(this.levels,t)){this.levels=t.map(e=>new fB(e));return}this.tracksBuffered=[],this.levels=t.map(e=>{let t=new fB(e);return this.tracksBuffered[t.id]=[],t}),this.fragmentTracker.removeFragmentsInRange(0,1/0,cM),this.fragPrevious=null,this.mediaBuffer=null}onSubtitleTrackSwitch(e,t){var i;if(this.currentTrackId=t.id,!(null!=(i=this.levels)&&i.length)||-1===this.currentTrackId)return void this.clearInterval();let s=this.levels[this.currentTrackId];null!=s&&s.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,s&&this.state!==mx&&this.setInterval(500)}onSubtitleTrackLoaded(e,t){var i,s;let{currentTrackId:r,levels:a}=this,{details:n,id:l}=t;if(!a)return void this.warn(`Subtitle tracks were reset while loading level ${l}`);let o=a[l];if(l>=a.length||!o)return;this.log(`Subtitle track ${l} loaded [${n.startSN},${n.endSN}]${n.lastPartSn?`[part-${n.lastPartSn}-${n.lastPartIndex}]`:""},duration:${n.totalduration}`),this.mediaBuffer=this.mediaBufferTimeRanges;let d=0;if(n.live||null!=(i=o.details)&&i.live){if(n.deltaUpdateFailed)return;let e=this.mainDetails;if(!e){this.startFragRequested=!1;return}let t=e.fragments[0];o.details?0===(d=this.alignPlaylists(n,o.details,null==(s=this.levelLastLoaded)?void 0:s.details))&&t&&mo(n,d=t.start):n.hasProgramDateTime&&e.hasProgramDateTime?(mb(n,e),d=n.fragmentStart):t&&mo(n,d=t.start),e&&!this.startFragRequested&&this.setStartPosition(e,d)}o.details=n,this.levelLastLoaded=o,l===r&&(this.hls.trigger(cA.SUBTITLE_TRACK_UPDATED,{details:n,id:l,groupId:t.groupId}),this.tick(),n.live&&!this.fragCurrent&&this.media&&this.state===mk&&(fX(null,n.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),o.details=void 0)))}_handleFragmentLoadComplete(e){let{frag:t,payload:i}=e,s=t.decryptdata,r=this.hls;if(!this.fragContextChanged(t)&&i&&i.byteLength>0&&null!=s&&s.key&&s.iv&&pC(s.method)){let e=performance.now();
31this.decrypter.decrypt(new Uint8Array(i),s.key.buffer,s.iv.buffer,pI(s.method)).catch(e=>{throw r.trigger(cA.ERROR,{type:ck.MEDIA_ERROR,details:cw.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:t}),e}).then(i=>{let s=performance.now();r.trigger(cA.FRAG_DECRYPTED,{frag:t,payload:i,stats:{tstart:e,tdecrypt:s}})}).catch(e=>{this.warn(`${e.name}: ${e.message}`),this.state=mk})}}doTick(){if(!this.media){this.state=mk;return}if(this.state===mk){let{currentTrackId:e,levels:t}=this,i=null==t?void 0:t[e];if(!i||!t.length||!i.details||this.waitForLive(i))return;let{config:s}=this,r=this.getLoadPosition(),{end:a,len:n}=pv.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],r,s.maxBufferHole),l=i.details;if(n>this.hls.maxBufferLength+l.levelTargetDuration)return;let o=l.fragments,d=o.length,h=l.edge,u=null,c=this.fragPrevious;if(a<h){let e=s.maxFragLookUpTolerance;(u=fX(c,o,Math.max(o[0].start,a),a>h-e?0:e))||!c||!(c.start<o[0].start)||(u=o[0])}else u=o[d-1];if(!(u=this.filterReplacedPrimary(u,i.details)))return;let f=o[u.sn-l.startSN-1];if(f&&f.cc===u.cc&&this.fragmentTracker.getState(f)===f9&&(u=f),this.fragmentTracker.getState(u)===f9){let e=this.mapToInitFragWhenRequired(u);e&&this.loadFragment(e,i,a)}}}loadFragment(e,t,i){c5(e)?super.loadFragment(e,t,i):this._loadInitSegment(e,t)}get mediaBufferTimeRanges(){return new yz(this.tracksBuffered[this.currentTrackId]||[])}},subtitleTrackController:class extends gV{constructor(e){super(e,"subtitle-track-controller"),this.media=null,this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.queuedDefaultTrack=-1,this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.onTextTracksChanged=()=>{if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let e=null,t=y_(this.media.textTracks);for(let i=0;i<t.length;i++)if("hidden"===t[i].mode)e=t[i];else if("showing"===t[i].mode){e=t[i];break}let i=this.findTrackForTextTrack(e);this.subtitleTrack!==i&&this.setSubtitleTrack(i)},this.registerListeners()}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,this.onTextTracksChanged=this.asyncPollTrackChange=null,super.destroy()}get subtitleDisplay(){return this._subtitleDisplay}set subtitleDisplay(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes()}registerListeners(){let{hls:e}=this;
vendor: 1,702 bytes, line 31
31e.on(cA.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(cA.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(cA.MANIFEST_LOADING,this.onManifestLoading,this),e.on(cA.MANIFEST_PARSED,this.onManifestParsed,this),e.on(cA.LEVEL_LOADING,this.onLevelLoading,this),e.on(cA.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(cA.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(cA.ERROR,this.onError,this)}unregisterListeners(){let{hls:e}=this;e.off(cA.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(cA.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(cA.MANIFEST_LOADING,this.onManifestLoading,this),e.off(cA.MANIFEST_PARSED,this.onManifestParsed,this),e.off(cA.LEVEL_LOADING,this.onLevelLoading,this),e.off(cA.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(cA.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(cA.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))}pollTrackChange(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.onTextTracksChanged,e)}onMediaDetaching(e,t){let i=this.media;if(!i)return;let s=!!t.transferMedia;self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||i.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),this.subtitleTrack=-1,this.media=null,s||y_(i.textTracks).forEac
31h(e=>{yD(e)})}onManifestLoading(){this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.subtitleTracks}onSubtitleTrackLoaded(e,t){let{id:i,groupId:s,details:r}=t,a=this.tracksInGroup[i];if(!a||a.groupId!==s)return void this.warn(`Subtitle track with id:${i} and group:${s} not found in active group ${null==a?void 0:a.groupId}`);let n=a.details;a.details=t.details,this.log(`Subtitle track ${i} "${a.name}" lang:${a.lang} group:${s} loaded [${r.startSN}-${r.endSN}]`),i===this.trackId&&this.playlistLoaded(i,t,n)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){let t=this.hls.levels[e];if(!t)return;let i=t.subtitleGroups||null,s=this.groupIds,r=this.currentTrack;if(!i||(null==s?void 0:s.length)!==(null==i?void 0:i.length)||null!=i&&i.some(e=>(null==s?void 0:s.indexOf(e))===-1)){this.groupIds=i,this.trackId=-1,this.currentTrack=null;let e=this.tracks.filter(e=>!i||-1!==i.indexOf(e.groupId));if(e.length)this.selectDefaultTrack&&!e.some(e=>e.default)&&(this.selectDefaultTrack=!1),e.forEach((e,t)=>{e.id=t});else if(!r&&!this.tracksInGroup.length)return;this.tracksInGroup=e;let t=this.hls.config.subtitlePreference;if(!r&&t){this.selectDefaultTrack=!1;let i=fH(t,e);if(i>-1)r=e[i];else{let e=fH(t,this.tracks);r=this.tracks[e]}}let s=this.findTrackId(r);-1===s&&r&&(s=this.findTrackId(null)),this.log(`Updating subtitle tracks, ${e.length} track(s) found in "${null==i?void 0:i.join(",")}" group-id`),this.hls.trigger(cA.SUBTITLE_TRACKS_UPDATED,{subtitleTracks:e}),-1!==s&&-1===this.trackId&&this.setSubtitleTrack(s)}}findTrackId(e){let t=this.tracksInGroup,i=this.selectDefaultTrack;for(let s=0;s<t.length;s++){let r=t[s];if((!i||r.default)&&(i||e)&&(!e||fK(r,e)))return s}if(e){for(let i=0;i<t.length;i++){let s=t[i];if(gq(e.attrs,s.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return i}for(let i=0;i<t.length;i++){let s=t[i];if(gq(e.attrs,s.attrs,["LANGUAGE"]))return i}}return -1}findTrackForTextTrack(e){if(e){let t=this.tracksInGroup;for(let i=0;i<t.length;i++)if(gH(t[i],e))return i}return -1}onError(e,t){!t.fatal&&t.context&&(t.context.type!==cI||t.context.id!==this.trackId||this.groupIds&&-1===this.groupIds.indexOf(t.context.groupId)||this.checkRetry(t))}get allSubtitleTracks(){return this.tracks}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(e){this.selectDefaultTrack=!1,this.setSubtitleTrack(e)}setSubtitleOption(e){if(this.hls.config.subtitlePreference=e,e){if(-1===e.id)return this.setSubtitleTrack(-1),null;let t=this.allSubtitleTracks;if(this.selectDefaultTrack=!1,t.length){let i=this.currentTrack;if(i&&fK(e,i))return i;let s=fH(e,this.tracksInGroup);if(s>-1){let e=this.tracksInGroup[s];return this.setSubtitleTrack(s),e}{if(i)return null;let s=fH(e,t);if(s>-1)return t[s]}}}return null}loadPlaylist(e){super.loadPlaylist(),this.shouldLoadPlaylist(this.currentTrack)&&this.scheduleLoading(this.currentTrack,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);let i=e.id,s=e.groupId,r=this.getUrlWithDirectives(e.url,t),a=e.details,n=null==a?void 0:a.age;this.log(`Loading subtitle ${i} "${e.name}" lang:${e.lang} group:${s}${(null==t?void 0:t.msn)!==void 0?" at sn "+t.msn+" part "+t.part:""}${n&&a.live?" age "+n.toFixed(1)+(a.type?" "+a.type:""):""} ${r}`),this.hls.trigger(cA.SUBTITLE_TRACK_LOADING,{url:r,id:i,groupId:s,deliveryDirectives:t||null,track:e})}toggleTrackModes(){let e,{media:t}=this;if(!t)return;let i=y_(t.textTracks),s=this.currentTrack;if(s&&((e=i.filter(e=>gH(s,e))[0])||this.warn(`Unable to find subtitle TextTrack with name "${s.name}" and language "${s.lang}"`)),[].slice.call(i).forEach(t=>{"disabled"!==t.mode&&t!==e&&(t.mode="disabled")}),e){let t=this.subtitleDisplay?"showing":"hidden";e.mode!==t&&(e.mode=t)}}setSubtitleTrack(e){let t=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(e<-1||e>=t.length||!cS(e))return void this.warn(`Invalid subtitle track id: ${e}`);this.selectDefaultTrack=!1;let i=this.currentTrack,s=t[e]||null;if(this.trackId=e,this.currentTrack=s,this.toggleTrackModes(),!s)return void this.hls.trigger(cA.SUBTITLE_TRACK_SWITCH,{id:e});let r=!!s.details&&!s.details.live;if(e===this.trackId&&s===i&&r)return;this.log(`Switching to subtitle-track ${e}`+(s?` "${s.name}" lang:${s.lang} group:${s.groupId}`:""));let{id:a,groupId:n="",name:l,type:o,url:d}=s;this.hls.trigger(cA.SUBTITLE_TRACK_SWITCH,{id:a,groupId:n,name:l,type:o,url:d});let h=this.switchParams(s.url,null==i?void 0:i.details,s.details);this.loadPlaylist(h)}},timelineController:class{constructor(e){this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=vR(),this.captionsProperties=void 0,this.hls=e,this.config=e.config,this.Cues=e.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}}
31,e.on(cA.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(cA.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(cA.MANIFEST_LOADING,this.onManifestLoading,this),e.on(cA.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(cA.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(cA.FRAG_LOADING,this.onFragLoading,this),e.on(cA.FRAG_LOADED,this.onFragLoaded,this),e.on(cA.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(cA.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(cA.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(cA.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(cA.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){let{hls:e}=this;e.off(cA.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(cA.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(cA.MANIFEST_LOADING,this.onManifestLoading,this),e.off(cA.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(cA.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(cA.FRAG_LOADING,this.onFragLoading,this),e.off(cA.FRAG_LOADED,this.onFragLoaded,this),e.off(cA.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(cA.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(cA.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(cA.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(cA.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.media=null,this.cea608Parser1=this.cea608Parser2=void 0}initCea608Parsers(){let e=new vk(this,"textTrack1"),t=new vk(this,"textTrack2"),i=new vk(this,"textTrack3"),s=new vk(this,"textTrack4");this.cea608Parser1=new y9(1,e,t),this.cea608Parser2=new y9(3,i,s)}addCues(e,t,i,s,r){let a=!1;for(let e=r.length;e--;){var n,l;let s=r[e],o=(n=s[0],l=s[1],Math.min(l,i)-Math.max(n,t));if(o>=0&&(s[0]=Math.min(s[0],t),s[1]=Math.max(s[1],i),a=!0,o/(i-t)>.5))return}if(a||r.push([t,i]),this.config.renderTextTracksNatively){let r=this.captionsTracks[e];this.Cues.newCue(r,t,i,s)}else{let r=this.Cues.newCue(null,t,i,s);this.hls.trigger(cA.CUES_PARSED,{type:"captions",cues:r,track:e})}}onInitPtsFound(e,{frag:t,id:i,initPTS:s,timescale:r,trackId:a}){let{unparsedVttFrags:n}=this;i===cP&&(this.initPTS[t.cc]={baseTime:s,timescale:r,trackId:a}),n.length&&(this.unparsedVttFrags=[],n.forEach(e=>{this.initPTS[e.frag.cc]?this.onFragLoaded(cA.FRAG_LOADED,e):this.hls.trigger(cA.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e.frag,error:Error("Subtitle discontinuity domain does not match main")})}))}getExistingTrack(e,t){let{media:i}=this;if(i)for(let s=0;s<i.textTracks.length;s++){let r=i.textTracks[s];if(vA(r,{name:e,lang:t,characteristics:"transcribes-spoken-dialog,describes-music-and-sound"}))return r}return null}createCaptionsTrack(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}createNativeTrack(e){if(this.captionsTracks[e])return;let{captionsProperties:t,captionsTracks:i,media:s}=this,{label:r,languageCode:a}=t[e],n=this.getExistingTrack(r,a);if(n)i[e]=n,yD(i[e]),yI(i[e],s);else{let t=this.createTextTrack("captions",r,a);t&&(t[e]=!0,i[e]=t)}}createNonNativeTrack(e){if(this.nonNativeCaptionsTracks[e])return;let t=this.captionsProperties[e];if(!t)return;let i={_id:e,label:t.label,kind:"captions",default:!!t.media&&!!t.media.default,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=i,this.hls.trigger(cA.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[i]})}createTextTrack(e,t,i){let s=this.media;if(s)return s.addTextTrack(e,t,i)}onMediaAttaching(e,t){this.media=t.media,t.mediaSource||this._cleanTracks()}onMediaDetaching(e,t){let i=!!t.transferMedia;if(this.media=null,i)return;let{captionsTracks:s}=this;Object.keys(s).forEach(e=>{yD(s[e]),delete s[e]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=vR(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}_cleanTracks(){let{media:e}=this;if(!e)return;let t=e.textTracks;
31if(t)for(let e=0;e<t.length;e++)yD(t[e])}onSubtitleTracksUpdated(e,t){let i=t.subtitleTracks||[],s=i.some(e=>e.textCodec===vp);if(this.config.enableWebVTT||s&&this.config.enableIMSC1){if(gG(this.tracks,i)){this.tracks=i;return}if(this.textTracks=[],this.tracks=i,this.config.renderTextTracksNatively){let e=this.media,t=e?y_(e.textTracks):null;if(this.tracks.forEach((e,i)=>{let s;if(t){let i=null;for(let s=0;s<t.length;s++)if(t[s]&&vA(t[s],e)){i=t[s],t[s]=null;break}i&&(s=i)}if(s)yD(s);else{let t=vw(e);(s=this.createTextTrack(t,e.name,e.lang))&&(s.mode="disabled")}s&&this.textTracks.push(s)}),null!=t&&t.length){let e=t.filter(e=>null!==e).map(e=>e.label);e.length&&this.hls.logger.warn(`Media element contains unused subtitle tracks: ${e.join(", ")}. Replace media element for each source to clear TextTracks and captions menu.`)}}else if(this.tracks.length){let e=this.tracks.map(e=>({label:e.name,kind:e.type.toLowerCase(),default:e.default,subtitleTrack:e}));this.hls.trigger(cA.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:e})}}}onManifestLoaded(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(e=>{let t=/(?:CC|SERVICE)([1-4])/.exec(e.instreamId);if(!t)return;let i=`textTrack${t[1]}`,s=this.captionsProperties[i];s&&(s.label=e.name,e.lang&&(s.languageCode=e.lang),s.media=e)})}closedCaptionsForLevel(e){let t=this.hls.levels[e.level];return null==t?void 0:t.attrs["CLOSED-CAPTIONS"]}onFragLoading(e,t){if(this.enabled&&t.frag.type===cP){var i,s;let{cea608Parser1:e,cea608Parser2:r,lastSn:a}=this,{cc:n,sn:l}=t.frag,o=null!=(i=null==(s=t.part)?void 0:s.index)?i:-1;e&&r&&(l!==a+1||l===a&&o!==this.lastPartIndex+1||n!==this.lastCc)&&(e.reset(),r.reset()),this.lastCc=n,this.lastSn=l,this.lastPartIndex=o}}onFragLoaded(e,t){let{frag:i,payload:s}=t;if(i.type===cM)if(s.byteLength){let e=i.decryptdata,r="stats"in t;if(null==e||!e.encrypted||r){let e=this.tracks[i.level],r=this.vttCCs;r[i.cc]||(r[i.cc]={start:i.start,prevCC:this.prevCC,new:!0},this.prevCC=i.cc),e&&e.textCodec===vp?this._parseIMSC1(i,s):this._parseVTTs(t)}}else this.hls.trigger(cA.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:Error("Empty subtitle payload")})}_parseIMSC1(e,t){let i=this.hls;vv(t,this.initPTS[e.cc],t=>{this._appendCues(t,e.level),i.trigger(cA.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},t=>{i.logger.log(`Failed to parse IMSC1: ${t}`),i.trigger(cA.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:t})})}_parseVTTs(e){var t,i,s,r,a,n,l,o;let d,h,u,c,f,p,m,g,y,{frag:v,payload:b}=e,{initPTS:E,unparsedVttFrags:S}=this,T=E.length-1;if(!E[v.cc]&&-1===T)return void S.push(e);let x=this.hls;i=null!=(t=v.initSegment)&&t.data?fu(v.initSegment.data,new Uint8Array(b)).buffer:b,s=this.initPTS[v.cc],r=this.vttCCs,a=v.cc,n=v.start,l=e=>{this._appendCues(e,v.level),x.trigger(cA.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:v})},o=t=>{let i="Missing initPTS for VTT MPEGTS"===t.message;i?S.push(e):this._fallbackToIMSC1(v,b),x.logger.log(`Failed to parse VTT cue: ${t}`),i&&T>v.cc||x.trigger(cA.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:v,error:t})},h=new vo,u=cW(new Uint8Array(i)).trim().replace(vd,"\n").split("\n"),c=[],f=s?function(e,t=1){return gT(e,9e4,1/t)}(s.baseTime,s.timescale):0,p="00:00.000",m=0,g=0,y=!0,h.oncue=function(e){let t=r[a],i=r.ccOffset,l=(m-f)/9e4;if(null!=t&&t.new&&(void 0!==g?i=r.ccOffset=t.start:vf(r,a,l)),l){if(!s){d=Error("Missing initPTS for VTT MPEGTS");return}i=l-r.presentationOffset}let o=e.endTime-e.startTime,h=gC((e.startTime+i-g)*9e4,9e4*n)/9e4;e.startTime=Math.max(h,0),e.endTime=Math.max(h+o,0);let u=e.text.trim();e.text=decodeURIComponent(encodeURIComponent(u)),e.id||(e.id=vc(e.startTime,e.endTime,u)),e.endTime>0&&c.push(e)},h.onparsingerror=function(e){d=e},h.onflush=function(){d?o(d):l(c)},u.forEach(e=>{if(y)if(vh(e,"X-TIMESTAMP-MAP=")){y=!1,e.slice(16).split(",").forEach(e=>{vh(e,"LOCAL:")?p=e.slice(6):vh(e,"MPEGTS:")&&(m=parseInt(e.slice(7)))});try{g=vu(p)/1e3}catch(e){d=e}return}else""===e&&(y=!1);h.parse(e+"\n")}),h.flush()}_fallbackToIMSC1(e,t){let i=this.tracks[e.level];i.textCodec||vv(t,this.initPTS[e.cc],()=>{i.textCodec=vp,this._parseIMSC1(e,t)},()=>{i.textCodec="wvtt"})}_appendCues(e,t){let i=this.hls;if(this.config.renderTextTracksNatively){let i=this.textTracks[t];if(!i||"disabled"===i.mode)return;
31e.forEach(e=>yP(i,e))}else{let s=this.tracks[t];if(!s)return;let r=s.default?"default":"subtitles"+t;i.trigger(cA.CUES_PARSED,{type:"subtitles",cues:e,track:r})}}onFragDecrypted(e,t){let{frag:i}=t;i.type===cM&&this.onFragLoaded(cA.FRAG_LOADED,t)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(e,t){if(!this.enabled||!this.config.enableCEA708Captions)return;let{frag:i,samples:s}=t;if(i.type!==cP||"NONE"!==this.closedCaptionsForLevel(i))for(let e=0;e<s.length;e++){let t=s[e].bytes;if(t){this.cea608Parser1||this.initCea608Parsers();let i=this.extractCea608Data(t);this.cea608Parser1.addData(s[e].pts,i[0]),this.cea608Parser2.addData(s[e].pts,i[1])}}}onBufferFlushing(e,{startOffset:t,endOffset:i,endOffsetSubtitles:s,type:r}){let{media:a}=this;if(a&&!(a.currentTime<i)){if(!r||"video"===r){let{captionsTracks:e}=this;Object.keys(e).forEach(s=>yM(e[s],t,i))}if(this.config.renderTextTracksNatively&&0===t&&void 0!==s){let{textTracks:e}=this;Object.keys(e).forEach(i=>yM(e[i],t,s))}}}extractCea608Data(e){let t=[[],[]],i=31&e[0],s=2;for(let r=0;r<i;r++){let i=e[s++],r=127&e[s++],a=127&e[s++];if((0!==r||0!==a)&&(4&i)!=0){let e=3&i;(0===e||1===e)&&(t[e].push(r),t[e].push(a))}}return t}},audioStreamController:class extends m${constructor(e,t,i){super(e,t,i,"audio-stream-controller",cD),this.mainAnchor=null,this.mainFragLoading=null,this.audioOnly=!1,this.bufferedTrack=null,this.switchingTrack=null,this.trackId=-1,this.waitingData=null,this.mainDetails=null,this.flushing=!1,this.bufferFlushed=!1,this.cachedTrackLoadedData=null,this.registerListeners()}onHandlerDestroying(){this.unregisterListeners(),super.onHandlerDestroying(),this.resetItem()}resetItem(){this.mainDetails=this.mainAnchor=this.mainFragLoading=this.bufferedTrack=this.switchingTrack=this.waitingData=this.cachedTrackLoadedData=null}registerListeners(){super.registerListeners();let{hls:e}=this;e.on(cA.LEVEL_LOADED,this.onLevelLoaded,this),e.on(cA.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(cA.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(cA.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(cA.BUFFER_RESET,this.onBufferReset,this),e.on(cA.BUFFER_CREATED,this.onBufferCreated,this),e.on(cA.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(cA.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(cA.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(cA.FRAG_LOADING,this.onFragLoading,this),e.on(cA.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){let{hls:e}=this;e&&(super.unregisterListeners(),e.off(cA.LEVEL_LOADED,this.onLevelLoaded,this),e.off(cA.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(cA.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(cA.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(cA.BUFFER_RESET,this.onBufferReset,this),e.off(cA.BUFFER_CREATED,this.onBufferCreated,this),e.off(cA.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(cA.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(cA.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(cA.FRAG_LOADING,this.onFragLoading,this),e.off(cA.FRAG_BUFFERED,this.onFragBuffered,this))}onInitPtsFound(e,{frag:t,id:i,initPTS:s,timescale:r,trackId:a}){if(i===cP){let e=t.cc,i=this.fragCurrent;if(this.initPTS[e]={baseTime:s,timescale:r,trackId:a},this.log(`InitPTS for cc: ${e} found from main: ${s/r} (${s}/${r}) trackId: ${a}`),this.mainAnchor=t,this.state===mM){let i=this.waitingData;(i||this.loadingParts)&&(!i||i.frag.cc===e)||this.syncWithAnchor(t,null==i?void 0:i.frag)}else!this.hls.hasEnoughToStart&&i&&i.cc!==e?(i.abortRequests(),this.syncWithAnchor(t,i)):this.state===mk&&this.tick()}}getLoadPosition(){return!this.startFragRequested&&this.nextLoadPosition>=0?this.nextLoadPosition:super.getLoadPosition()}syncWithAnchor(e,t){var i;let s=(null==(i=this.mainFragLoading)?void 0:i.frag)||null;if(t&&(null==s?void 0:s.cc)===t.cc)return;let r=(s||e).cc,a=fZ(this.getLevelDetails(),r,this.getLoadPosition());a&&(this.log(`Syncing with main frag at ${a.start} cc ${a.cc}`),this.startFragRequested=!1,this.nextLoadPosition=a.start,this.resetLoadingState(),this.state===mk&&this.doTickIdle())}
31startLoad(e,t){if(!this.levels){this.startPosition=e,this.state=mx;return}let i=this.lastCurrentTime;this.stopLoad(),this.setInterval(100),i>0&&-1===e?(this.log(`Override startPosition with lastCurrentTime @${i.toFixed(3)}`),e=i,this.state=mk):this.state=mL,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}doTick(){switch(this.state){case mk:this.doTickIdle();break;case mL:{let{levels:e,trackId:t}=this,i=null==e?void 0:e[t],s=null==i?void 0:i.details;if(s&&!this.waitForLive(i)){if(this.waitForCdnTuneIn(s))break;this.state=mM}break}case mR:this.checkRetryDate();break;case mM:{let e=this.waitingData;if(e){let{frag:t,part:i,cache:s,complete:r}=e,a=this.mainAnchor;if(void 0!==this.initPTS[t.cc]){this.waitingData=null,this.state=mA;let e={frag:t,part:i,payload:s.flush().buffer,networkDetails:null};this._handleFragmentLoadProgress(e),r&&super._handleFragmentLoadComplete(e)}else a&&a.cc!==e.frag.cc&&this.syncWithAnchor(a,e.frag)}else this.state=mk}}this.onTickEnd()}resetLoadingState(){let e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null),super.resetLoadingState()}onTickEnd(){let{media:e}=this;null!=e&&e.readyState&&(this.lastCurrentTime=e.currentTime)}doTickIdle(){var e;let{hls:t,levels:i,media:s,trackId:r}=this,a=t.config;if(!this.buffering||!s&&!this.primaryPrefetch&&(this.startFragRequested||!a.startFragPrefetch)||!(null!=i&&i[r]))return;let n=i[r],l=n.details;if(!l||this.waitForLive(n)||this.waitForCdnTuneIn(l)){this.state=mL,this.startFragRequested=!1;return}let o=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&o&&(this.bufferFlushed=!1,this.afterBufferFlushed(o,cZ,cD));let d=this.getFwdBufferInfo(o,cD);if(null===d)return;if(!this.switchingTrack&&this._streamEnded(d,l)){t.trigger(cA.BUFFER_EOS,{type:"audio"}),this.state=mP;return}let h=d.len,u=t.maxBufferLength,c=l.fragments,f=c[0].start,p=this.getLoadPosition(),m=this.flushing?p:d.end;if(this.switchingTrack&&s&&l.PTSKnown&&p<f&&(d.end>f||d.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),s.currentTime=f+.05),h>=u&&!this.switchingTrack&&m<c[c.length-1].start)return;let g=this.getNextFragment(m,l);if(g&&this.isLoopLoading(g,m)&&(g=this.getNextFragmentLoopLoading(g,l,d,cP,u)),!g){this.bufferFlushed=!0;return}if(this.exceedsMaxBuffer(d,u,g))return;let y=(null==(e=this.mainFragLoading)?void 0:e.frag)||null;if(!this.audioOnly&&this.startFragRequested&&y&&c5(g)&&!g.endList&&(!l.live||!this.loadingParts&&m<this.hls.liveSyncPosition)&&("OK"===this.fragmentTracker.getState(y)&&(this.mainFragLoading=y=null),y&&c5(y))){if(g.start>y.end){let e=this.fragmentTracker.getFragAtPos(m,cP);e&&e.end>y.end&&(y=e,this.mainFragLoading={frag:e,targetBufferTime:null})}if(g.start>y.end)return}this.loadFragment(g,n,m)}onMediaDetaching(e,t){this.bufferFlushed=this.flushing=!1,super.onMediaDetaching(e,t)}onAudioTracksUpdated(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map(e=>new fB(e))}onAudioTrackSwitching(e,t){let i=!!t.url;this.trackId=t.id;let{fragCurrent:s}=this;s&&(s.abortRequests(),this.removeUnbufferedFrags(s.start)),this.resetLoadingState(),i?(this.switchingTrack=t,this.flushAudioIfNeeded(t),this.state!==mx&&(this.setInterval(100),this.state=mk,this.tick())):(this.resetTransmuxer(),this.switchingTrack=null,this.bufferedTrack=t,this.clearInterval())}onManifestLoading(){super.onManifestLoading(),this.bufferFlushed=this.flushing=this.audioOnly=!1,this.resetItem(),this.trackId=-1}onLevelLoaded(e,t){this.mainDetails=t.details;let i=this.cachedTrackLoadedData;i&&(this.cachedTrackLoadedData=null,this.onAudioTrackLoaded(cA.AUDIO_TRACK_LOADED,i))}onAudioTrackLoaded(e,t){var i,s;let{levels:r}=this,{details:a,id:n,groupId:l,track:o}=t;if(!r)return void this.warn(`Audio tracks reset while loading track ${n} "${o.name}" of "${l}"`);let d=this.mainDetails;if(!d||a.endCC>d.endCC||d.expired){this.cachedTrackLoadedData=t,this.state!==mx&&(this.state=mL);return}this.cachedTrackLoadedData=null,this.log(`Audio track ${n} "${o.name}" of "${l}" loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""},duration:${a.totalduration}`);let h=r[n],u=0;if(a.live||null!=(i=h.details)&&i.live){if(this.checkLiveUpdate(a),a.deltaUpdateFailed)return;h.details&&(u=this.alignPlaylists(a,h.details,null==(s=this.levelLastLoaded)?void 0:s.details)),a.alignedSliding||(mv(a,d),a.alignedSliding||mb(a,d),u=a.fragmentStart)}h.details=a,this.levelLastLoaded=h,this.startFragRequested||this.setStartPosition(d,u),this.hls.trigger(cA.AUDIO_TRACK_UPDATED,{details:a,id:n,groupId:t.groupId}),this.state!==mL||this.waitForCdnTuneIn(a)||(this.state=mk),this.tick()}_handleFragmentLoadProgress(e){var t;let i=e.frag,{part:s,payload:r}
31=e,{config:a,trackId:n,levels:l}=this;if(!l)return void this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`);let o=l[n];if(!o)return void this.warn("Audio track is undefined on fragment load progress");let d=o.details;if(!d){this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(i.start);return}let h=a.defaultAudioCodec||o.audioCodec||"mp4a.40.2",u=this.transmuxer;u||(u=this.transmuxer=new gj(this.hls,cD,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));let c=this.initPTS[i.cc],f=null==(t=i.initSegment)?void 0:t.data;if(void 0!==c){let e=s?s.index:-1,t=new pm(i.level,i.sn,i.stats.chunkCount,r.byteLength,e,-1!==e);u.push(r,f,h,"",i,s,d.totalduration,!1,t,c)}else{this.log(`Unknown video PTS for cc ${i.cc}, waiting for video PTS before demuxing audio frag ${i.sn} of [${d.startSN} ,${d.endSN}],track ${n}`);let{cache:e}=this.waitingData=this.waitingData||{frag:i,part:s,cache:new mN,complete:!1};e.push(new Uint8Array(r)),this.state!==mx&&(this.state=mM)}}_handleFragmentLoadComplete(e){if(this.waitingData){this.waitingData.complete=!0;return}super._handleFragmentLoadComplete(e)}onBufferReset(){this.mediaBuffer=null}onBufferCreated(e,t){this.bufferFlushed=this.flushing=!1;let i=t.tracks.audio;i&&(this.mediaBuffer=i.buffer||null)}onFragLoading(e,t){!this.audioOnly&&t.frag.type===cP&&c5(t.frag)&&(this.mainFragLoading=t,this.state===mk&&this.tick())}onFragBuffered(e,t){let{frag:i,part:s}=t;if(i.type!==cD){this.audioOnly||i.type!==cP||i.elementaryStreams.video||i.elementaryStreams.audiovideo||(this.audioOnly=!0,this.mainFragLoading=null);return}if(this.fragContextChanged(i))return void this.warn(`Fragment ${i.sn}${s?" p: "+s.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);if(c5(i)){this.fragPrevious=i;let e=this.switchingTrack;e&&(this.bufferedTrack=e,this.switchingTrack=null,this.hls.trigger(cA.AUDIO_TRACK_SWITCHED,cF({},e)))}this.fragBufferedComplete(i,s),this.media&&this.tick()}onError(e,t){var i;if(t.fatal){this.state=mD;return}switch(t.details){case cw.FRAG_GAP:case cw.FRAG_PARSING_ERROR:case cw.FRAG_DECRYPT_ERROR:case cw.FRAG_LOAD_ERROR:case cw.FRAG_LOAD_TIMEOUT:case cw.KEY_LOAD_ERROR:case cw.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(cD,t);break;case cw.AUDIO_TRACK_LOAD_ERROR:case cw.AUDIO_TRACK_LOAD_TIMEOUT:case cw.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==mL||(null==(i=t.context)?void 0:i.type)!==cC||(this.state=mk);break;case cw.BUFFER_ADD_CODEC_ERROR:case cw.BUFFER_APPEND_ERROR:if("audio"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)||this.resetLoadingState();break;case cw.BUFFER_FULL_ERROR:if("audio"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,1/0,"audio"));break;case cw.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}onBufferFlushing(e,{type:t}){t!==c0&&(this.flushing=!0)}onBufferFlushed(e,{type:t}){if(t!==c0){this.flushing=!1,this.bufferFlushed=!0,this.state===mP&&(this.state=mk);let e=this.mediaBuffer||this.media;e&&(this.afterBufferFlushed(e,t,cD),this.tick())}}_handleTransmuxComplete(e){var t;let i="audio",{hls:s}=this,{remuxResult:r,chunkMeta:a}=e,n=this.getCurrentContext(a);if(!n)return void this.resetWhenMissingContext(a);let{frag:l,part:o,level:d}=n,{details:h}=d,{audio:u,text:c,id3:f,initSegment:p}=r;if(this.fragContextChanged(l)||!h)return void this.fragmentTracker.removeFragment(l);if(this.state=mC,this.switchingTrack&&u&&this.completeAudioSwitch(this.switchingTrack),null!=p&&p.tracks){let e=l.initSegment||l;if(this.unhandledEncryptionError(p,l))return;this._bufferInitSegment(d,p.tracks,e,a),s.trigger(cA.FRAG_PARSING_INIT_SEGMENT,{frag:e,id:i,tracks:p.tracks})}if(u){let{startPTS:e,endPTS:t,startDTS:i,endDTS:s}=u;o&&(o.elementaryStreams[cZ]={startPTS:e,endPTS:t,startDTS:i,endDTS:s}),l.setElementaryStreamInfo(cZ,e,t,i,s),this.bufferFragmentData(u,l,o,a)}if(null!=f&&null!=(t=f.samples)&&t.length){let e=cO({id:i,frag:l,details:h},f);s.trigger(cA.FRAG_PARSING_METADATA,e)}if(c){let e=cO({id:i,frag:l,details:h},c);s.trigger(cA.FRAG_PARSING_USERDATA,e)}}_bufferInitSegment(e,t,i,s){if(this.state!==mC||(t.video&&delete t.video,t.audiovideo&&delete t.audiovideo,!t.audio))return;let r=t.audio;r.id=cD;let a=e.audioCodec;this.log(`Init audio buffer, container:${r.container}, codecs[level/parsed]=[${a}/${r.codec}]`),a&&1===a.split(",").length&&(r.levelCodec=a),this.hls.trigger(cA.BUFFER_CODECS,t);let n=r.initSegment;if(null!=n&&n.byteLength){let e={type:"audio",frag:i,part:null,chunkMeta:s,parent:i.type,data:n};this.hls.trigger(cA.BUFFER_APPENDING,e)}this.tickImmediate()}loadFragment(e,t,i){let s=this.fragmentTracker.getState(e);if(this.switchingTrack||s===f9||s===pt){var r;if(c5(e))if(null!=(r=t.details)&&r.live&&!this.initPTS[e.cc]){this.log(`Waiting for video PTS in continuity counter ${e.cc} of live stream before loading audio fragment ${e.sn} of level ${this.trackId}`),this.state=mM;let i=this.mainDetails;i&&i.fragmentStart!==t.details.fragmentStart&&mb(t.details,i)}else super.loadFragment(e,t,i);else this._loadInitSegment(e,t)}else this.clearTrackerIfNeeded(e)}flushAudioIfNeeded(e){if(this.media&&this.bufferedTrack){let{name:t,lang:i,assocLang:s,characteristics:r,audioCodec:a,channels:n}=this.bufferedTrack;fK({name:t,lang:i,assocLang:s,characteristics:r,audioCodec:a,channels:n},e,fW)||(fY(e.url,this.hls)?(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,1/0,"audio"),this.bufferedTrack=null):this.bufferedTrack=e)}}completeAudioSwitch(e){let{hls:t}=this;this.flushAudioIfNeeded(e),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(cA.AUDIO_TRACK_SWITCHED,cF({},e))}},audioTrackController:class extends gV{constructor(e){super(e,"audio-track-controller"),this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){let{hls:e}=this;e.on(cA.MANIFEST_LOADING,this.onManifestLoading,this),e.on(cA.MANIFEST_PARSED,this.onManifestParsed,this),e.on(cA.LEVEL_LOADING,this.onLevelLoading,this),e.on(cA.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(cA.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(cA.ERROR,this.onError,this)}unregisterListeners(){let{hls:e}=this;e.off(cA.MANIFEST_LOADING,this.onManifestLoading,this),e.off(cA.MANIFEST_PARSED,this.onManifestParsed,this),e.off(cA.LEVEL_LOADING,this.onLevelLoading,this),e.off(cA.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(cA.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(cA.ERROR,this.onError,this)}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy()}onManifestLoading(){this.tracks=[],this.tracksInGroup=[],this.groupIds=null,this.currentTrack=null,this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.audioTracks||[]}onAudioTrackLoaded(e,t){let{id:i,groupId:s,details:r}=t,a=this.tracksInGroup[i];if(!a||a.groupId!==s)return void this.warn(`Audio track with id:${i} and group:${s} not found in active group ${null==a?void 0:a.groupId}`);let n=a.details;a.details=t.details,this.log(`Audio track ${i} "${a.name}" lang:${a.lang} group:${s} loaded [${r.startSN}-${r.endSN}]`),i===this.trackId&&this.playlistLoaded(i,t,n)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){let t=this.hls.levels[e];if(!t)return;let i=t.audioGroups||null,s=this.groupIds,r=this.currentTrack;if(!i||(null==s?void 0:s.length)!==(null==i?void 0:i.length)||null!=i&&i.some(e=>(null==s?void 0:s.indexOf(e))===-1)){this.groupIds=i,this.trackId=-1,this.currentTrack=null;let e=this.tracks.filter(e=>!i||-1!==i.indexOf(e.groupId));if(e.length)this.selectDefaultTrack&&!e.some(e=>e.default)&&(this.selectDefaultTrack=!1),e.forEach((e,t)=>
31{e.id=t});else if(!r&&!this.tracksInGroup.length)return;this.tracksInGroup=e;let t=this.hls.config.audioPreference;if(!r&&t){let i=fH(t,e,fW);if(i>-1)r=e[i];else{let e=fH(t,this.tracks);r=this.tracks[e]}}let s=this.findTrackId(r);-1===s&&r&&(s=this.findTrackId(null)),this.log(`Updating audio tracks, ${e.length} track(s) found in group(s): ${null==i?void 0:i.join(",")}`),this.hls.trigger(cA.AUDIO_TRACKS_UPDATED,{audioTracks:e});let n=this.trackId;if(-1!==s&&-1===n)this.setAudioTrack(s);else if(e.length&&-1===n){var a;let t=Error(`No audio track selected for current audio group-ID(s): ${null==(a=this.groupIds)?void 0:a.join(",")} track count: ${e.length}`);this.warn(t.message),this.hls.trigger(cA.ERROR,{type:ck.MEDIA_ERROR,details:cw.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:t})}}}onError(e,t){!t.fatal&&t.context&&(t.context.type!==cC||t.context.id!==this.trackId||this.groupIds&&-1===this.groupIds.indexOf(t.context.groupId)||this.checkRetry(t))}get allAudioTracks(){return this.tracks}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}setAudioOption(e){let t=this.hls;if(t.config.audioPreference=e,e){let r=this.allAudioTracks;
31if(this.selectDefaultTrack=!1,r.length){let a=this.currentTrack;if(a&&fK(e,a,fW))return a;let n=fH(e,this.tracksInGroup,fW);if(n>-1){let e=this.tracksInGroup[n];return this.setAudioTrack(n),e}if(a){var i,s;let a,n,l,o,d,h,u=t.loadLevel;-1===u&&(u=t.firstAutoLevel);let c=(i=t.levels,a=i[s=u],(n=i.reduce((e,t,i)=>{let s=t.uri;return(e[s]||(e[s]=[])).push(i),e},{})[a.uri]).length>1&&(s=Math.max.apply(Math,n)),l=a.videoRange,o=a.frameRate,d=a.codecSet.substring(0,4),(h=fz(i,s,t=>{if(t.videoRange!==l||t.frameRate!==o||t.codecSet.substring(0,4)!==d)return!1;let i=t.audioGroups;return fH(e,r.filter(e=>!i||-1!==i.indexOf(e.groupId)),fW)>-1}))>-1?h:fz(i,s,t=>{let i=t.audioGroups;return fH(e,r.filter(e=>!i||-1!==i.indexOf(e.groupId)),fW)>-1}));if(-1===c)return null;t.nextLoadLevel=c}if(e.channels||e.audioCodec){let t=fH(e,r);if(t>-1)return r[t]}}}return null}setAudioTrack(e){let t=this.tracksInGroup;if(e<0||e>=t.length)return void this.warn(`Invalid audio track id: ${e}`);this.selectDefaultTrack=!1;let i=this.currentTrack,s=t[e],r=s.details&&!s.details.live;if(e===this.trackId&&s===i&&r||(this.log(`Switching to audio-track ${e} "${s.name}" lang:${s.lang} group:${s.groupId} channels:${s.channels}`),this.trackId=e,this.currentTrack=s,this.hls.trigger(cA.AUDIO_TRACK_SWITCHING,cF({},s)),r))return;let a=this.switchParams(s.url,null==i?void 0:i.details,s.details);this.loadPlaylist(a)}findTrackId(e){let t=this.tracksInGroup;for(let i=0;i<t.length;i++){let s=t[i];if((!this.selectDefaultTrack||s.default)&&(!e||fK(e,s,fW)))return i}if(e){let{name:i,lang:s,assocLang:r,characteristics:a,audioCodec:n,channels:l}=e;for(let e=0;e<t.length;e++)if(fK({name:i,lang:s,assocLang:r,characteristics:a,audioCodec:n,channels:l},t[e],fW))return e;for(let i=0;i<t.length;i++){let s=t[i];if(gq(e.attrs,s.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return i}for(let i=0;i<t.length;i++){let s=t[i];if(gq(e.attrs,s.attrs,["LANGUAGE"]))return i}}return -1}loadPlaylist(e){super.loadPlaylist();let t=this.currentTrack;this.shouldLoadPlaylist(t)&&fY(t.url,this.hls)&&this.scheduleLoading(t,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);let i=e.id,s=e.groupId,r=this.getUrlWithDirectives(e.url,t),a=e.details,n=null==a?void 0:a.age;this.log(`Loading audio-track ${i} "${e.name}" lang:${e.lang} group:${s}${(null==t?void 0:t.msn)!==void 0?" at sn "+t.msn+" part "+t.part:""}${n&&a.live?" age "+n.toFixed(1)+(a.type?" "+a.type:""):""} ${r}`),this.hls.trigger(cA.AUDIO_TRACK_LOADING,{url:r,id:i,groupId:s,deliveryDirectives:t||null,track:e})}},emeController:yA,cmcdController:class{constructor(e){this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.includeKeys=void 0,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=!0),this.buffering=!0},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1},this.applyPlaylistData=e=>{try{this.apply(e,{ot:"m",su:!this.initialized})}catch(e){this.hls.logger.warn("Could not generate manifest CMCD data.",e)}},this.applyFragmentData=e=>{try{let{frag:t,part:i}=e,s=this.hls.levels[t.level],r=this.getObjectType(t),a={d:1e3*(i||t).duration,ot:r};("v"===r||"a"===r||"av"==r)&&(a.br=s.bitrate/1e3,a.tb=this.getTopBandwidth(r)/1e3,a.bl=this.getBufferLength(r));let n=i?this.getNextPart(i):this.getNextFrag(t);null!=n&&n.url&&n.url!==t.url&&(a.nor=n.url),this.apply(e,a)}catch(e){this.hls.logger.warn("Could not generate segment CMCD data.",e)}},this.hls=e;const t=this.config=e.config,{cmcd:i}=t;null!=i&&(t.pLoader=this.createPlaylistLoader(),t.fLoader=this.createFragmentLoader(),this.sid=i.sessionId||e.sessionId,this.cid=i.contentId,this.useHeaders=!0===i.useHeaders,this.includeKeys=i.includeKeys,this.registerListeners())}registerListeners(){let e=this.hls;
31e.on(cA.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(cA.MEDIA_DETACHED,this.onMediaDetached,this),e.on(cA.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){let e=this.hls;e.off(cA.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(cA.MEDIA_DETACHED,this.onMediaDetached,this),e.off(cA.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null,this.onWaiting=this.onPlaying=this.media=null}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}onMediaDetached(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}onBufferCreated(e,t){var i,s;this.audioBuffer=null==(i=t.tracks.audio)?void 0:i.buffer,this.videoBuffer=null==(s=t.tracks.video)?void 0:s.buffer}createData(){var e;return{v:1,sf:"h",sid:this.sid,cid:this.cid,pr:null==(e=this.media)?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){cO(t,this.createData());let i="i"===t.ot||"v"===t.ot||"av"===t.ot;this.starved&&i&&(t.bs=!0,t.su=!0,this.starved=!1),null==t.su&&(t.su=this.buffering);let{includeKeys:s}=this;s&&(t=Object.keys(t).reduce((e,i)=>(s.includes(i)&&(e[i]=t[i]),e),{}));let r={baseUrl:e.url};if(this.useHeaders){var a;e.headers||(e.headers={}),a=e.headers,cO(a,function(e,t={}){let i={};return e?Object.entries(function(e,t){let i={};if(!e)return i;let s=Object.keys(e),r=t?Object.keys(t).reduce((e,i)=>{var s;return null==(s=t[i])||s.forEach(t=>e[t]=i),e},{}):{};return s.reduce((t,i)=>{var s;let a=ya[i]||r[i]||yi;return(null!=(s=t[a])?s:t[a]={})[i]=e[i],t},i)}(yT(e,t),null==t?void 0:t.customHeaderMap)).reduce((e,[t,i])=>{let s=ye(i,{whitespace:!1});return s&&(e[t]=s),e},i):i}(t,r))}else e.url=function(e,t,i){let s=function(e,t={}){if(!e)return"";let i=function(e,t={}){return e?encodeURIComponent(function(e,t={}){return e?ye(yT(e,t),{whitespace:!1}):""}(e,t)):""}(e,t);return`CMCD=${i}`}(t,i);if(!s)return e;if(yx.test(e))return e.replace(yx,s);let r=e.includes("?")?"&":"?";return`${e}${r}${s}`}(e.url,t,r)}getNextFrag(e){var t;let i=null==(t=this.hls.levels[e.level])?void 0:t.details;if(i){let t=e.sn-i.startSN;return i.fragments[t+1]}}getNextPart(e){var t;let{index:i,fragment:s}=e,r=null==(t=this.hls.levels[s.level])||null==(t=t.details)?void 0:t.partList;if(r){let{sn:e}=s;for(let t=r.length-1;t>=0;t--){let s=r[t];if(s.index===i&&s.fragment.sn===e)return r[t+1]}}}getObjectType(e){let{type:t}=e;return"subtitle"===t?"tt":"initSegment"===e.sn?"i":"audio"===t?"a":"main"===t?this.hls.audioTracks.length?"v":"av":void 0}getTopBandwidth(e){let t,i=0,s=this.hls;if("a"===e)t=s.audioTracks;else{let e=s.maxAutoLevel,i=e>-1?e+1:s.levels.length;t=s.levels.slice(0,i)}return t.forEach(e=>{e.bitrate>i&&(i=e.bitrate)}),i>0?i:NaN}getBufferLength(e){let t=this.media,i="a"===e?this.audioBuffer:this.videoBuffer;return i&&t?1e3*pv.bufferInfo(i,t.currentTime,this.config.maxBufferHole).len:NaN}createPlaylistLoader(){let{pLoader:e}=this.config,t=this.applyPlaylistData,i=e||this.config.loader;return class{constructor(e){this.loader=void 0,this.loader=new i(e)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(e,i,s){t(e),this.loader.load(e,i,s)}}}createFragmentLoader(){let{fLoader:e}=this.config,t=this.applyFragmentData,i=e||this.config.loader;return class{constructor(e){this.loader=void 0,this.loader=new i(e)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(e,i,s){t(e),this.loader.load(e,i,s)}}}},contentSteeringController:class extends cB{constructor(e){super("content-steering",e.logger),this.hls=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this._pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=e,this.registerListeners()}registerListeners(){let e=this.hls;e.on(cA.MANIFEST_LOADING,this.onManifestLoading,this),e.on(cA.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(cA.MANIFEST_PARSED,this.onManifestParsed,this),e.on(cA.ERROR,this.onError,this)}unregisterListeners(){let e=this.hls;e&&(e.off(cA.MANIFEST_LOADING,this.onManifestLoading,this),e.off(cA.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(cA.MANIFEST_PARSED,this.onManifestParsed,this),e.off(cA.ERROR,this.onError,this))}pathways(){return(this.levels||[]).reduce((e,t)=>
31(-1===e.indexOf(t.pathwayId)&&e.push(t.pathwayId),e),[])}get pathwayPriority(){return this._pathwayPriority}set pathwayPriority(e){this.updatePathwayPriority(e)}startLoad(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){let e=1e3*this.timeToLoad-(performance.now()-this.updated);if(e>0)return void this.scheduleRefresh(this.uri,e)}this.loadSteeringManifest(this.uri)}}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()}clearTimeout(){-1!==this.reloadTimer&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(e){let t=this.levels;t&&(this.levels=t.filter(t=>t!==e))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(e,t){let{contentSteering:i}=t;null!==i&&(this.pathwayId=i.pathwayId,this.uri=i.uri,this.started&&this.startLoad())}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}onError(e,t){let{errorAction:i}=t;if((null==i?void 0:i.action)===2&&1===i.flags){let e=this.levels,s=this._pathwayPriority,r=this.pathwayId;if(t.context){let{groupId:i,pathwayId:s,type:a}=t.context;i&&e?r=this.getPathwayForGroupId(i,a,r):s&&(r=s)}r in this.penalizedPathways||(this.penalizedPathways[r]=performance.now()),!s&&e&&(s=this.pathways()),s&&s.length>1&&(this.updatePathwayPriority(s),i.resolved=this.pathwayId!==r),t.details!==cw.BUFFER_APPEND_ERROR||t.fatal?i.resolved||this.warn(`Could not resolve ${t.details} ("${t.error.message}") with content-steering for Pathway: ${r} levels: ${e?e.length:e} priorities: ${fj(s)} penalized: ${fj(this.penalizedPathways)}`):i.resolved=!0}}filterParsedLevels(e){this.levels=e;let t=this.getLevelsForPathway(this.pathwayId);if(0===t.length){let i=e[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${i}"`),t=this.getLevelsForPathway(i),this.pathwayId=i}return t.length!==e.length&&this.log(`Found ${t.length}/${e.length} levels in Pathway "${this.pathwayId}"`),t}getLevelsForPathway(e){return null===this.levels?[]:this.levels.filter(t=>e===t.pathwayId)}updatePathwayPriority(e){let t;this._pathwayPriority=e;let i=this.penalizedPathways,s=performance.now();
31Object.keys(i).forEach(e=>{s-i[e]>3e5&&delete i[e]});for(let s=0;s<e.length;s++){let r=e[s];if(r in i)continue;if(r===this.pathwayId)return;let a=this.hls.nextLoadLevel,n=this.hls.levels[a];if((t=this.getLevelsForPathway(r)).length>0){this.log(`Setting Pathway to "${r}"`),this.pathwayId=r,mf(t),this.hls.trigger(cA.LEVELS_UPDATED,{levels:t});let e=this.hls.levels[a];n&&e&&this.levels&&(e.attrs["STABLE-VARIANT-ID"]!==n.attrs["STABLE-VARIANT-ID"]&&e.bitrate!==n.bitrate&&this.log(`Unstable Pathways change from bitrate ${n.bitrate} to ${e.bitrate}`),this.hls.nextLoadLevel=a);break}}}getPathwayForGroupId(e,t,i){let s=this.getLevelsForPathway(i).concat(this.levels||[]);for(let i=0;i<s.length;i++)if(t===cC&&s[i].hasAudioGroup(e)||t===cI&&s[i].hasSubtitleGroup(e))return s[i].pathwayId;return i}clonePathways(e){let t=this.levels;if(!t)return;let i={},s={};e.forEach(e=>{let{ID:r,"BASE-ID":a,"URI-REPLACEMENT":n}=e;if(t.some(e=>e.pathwayId===r))return;let l=this.getLevelsForPathway(a).map(e=>{let t=new pk(e.attrs);t["PATHWAY-ID"]=r;let a=t.AUDIO&&`${t.AUDIO}_clone_${r}`,l=t.SUBTITLES&&`${t.SUBTITLES}_clone_${r}`;a&&(i[t.AUDIO]=a,t.AUDIO=a),l&&(s[t.SUBTITLES]=l,t.SUBTITLES=l);let o=yw(e.uri,t["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",n),d=new fB({attrs:t,audioCodec:e.audioCodec,bitrate:e.bitrate,height:e.height,name:e.name,url:o,videoCodec:e.videoCodec,width:e.width});if(e.audioGroups)for(let t=1;t<e.audioGroups.length;t++)d.addGroupId("audio",`${e.audioGroups[t]}_clone_${r}`);if(e.subtitleGroups)for(let t=1;t<e.subtitleGroups.length;t++)d.addGroupId("text",`${e.subtitleGroups[t]}_clone_${r}`);return d});t.push(...l),yk(this.audioTracks,i,n,r),yk(this.subtitleTracks,s,n,r)})}loadSteeringManifest(e){let t,i=this.hls.config,s=i.loader;this.loader&&this.loader.destroy(),this.loader=new s(i);try{t=new self.URL(e)}catch(t){this.enabled=!1,this.log(`Failed to parse Steering Manifest URI: ${e}`);return}if("data:"!==t.protocol){let e=0|(this.hls.bandwidthEstimate||i.abrEwmaDefaultEstimate);t.searchParams.set("_HLS_pathway",this.pathwayId),t.searchParams.set("_HLS_throughput",""+e)}let r={responseType:"json",url:t.href},a=i.steeringManifestLoadPolicy.default,n=a.errorRetry||a.timeoutRetry||{},l={loadPolicy:a,timeout:a.maxLoadTimeMs,maxRetry:n.maxNumRetry||0,retryDelay:n.retryDelayMs||0,maxRetryDelay:n.maxRetryDelayMs||0};this.log(`Requesting steering manifest: ${t}`),this.loader.load(r,l,{onSuccess:(e,i,s,r)=>{this.log(`Loaded steering manifest: "${t}"`);let a=e.data;if((null==a?void 0:a.VERSION)!==1)return void this.log(`Steering VERSION ${a.VERSION} not supported!`);this.updated=performance.now(),this.timeToLoad=a.TTL;let{"RELOAD-URI":n,"PATHWAY-CLONES":l,"PATHWAY-PRIORITY":o}=a;if(n)try{this.uri=new self.URL(n,t).href}catch(e){this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${n}`);return}this.scheduleRefresh(this.uri||s.url),l&&this.clonePathways(l);let d={steeringManifest:a,url:t.toString()};this.hls.trigger(cA.STEERING_MANIFEST_LOADED,d),o&&this.updatePathwayPriority(o)},onError:(e,t,i,s)=>{if(this.log(`Error loading steering manifest: ${e.code} ${e.text} (${t.url})`),this.stopLoad(),410===e.code){this.enabled=!1,this.log(`Steering manifest ${t.url} no longer available`);return}let r=1e3*this.timeToLoad;if(429===e.code){let e=this.loader;if("function"==typeof(null==e?void 0:e.getResponseHeader)){let t=e.getResponseHeader("Retry-After");t&&(r=1e3*parseFloat(t))}this.log(`Steering manifest ${t.url} rate limited`);return}this.scheduleRefresh(this.uri||t.url,r)},onTimeout:(e,t,i)=>{this.log(`Timeout loading steering manifest (${t.url})`),this.scheduleRefresh(this.uri||t.url)}})}scheduleRefresh(e,t=1e3*this.timeToLoad){this.clearTimeout(),this.reloadTimer=self.setTimeout(()=>{var t;let i=null==(t=this.hls)?void 0:t.media;i&&!i.ended?this.loadSteeringManifest(e):this.scheduleRefresh(e,1e3*this.timeToLoad)},t)}},interstitialsController:class extends cB{constructor(e,t){super("interstitials",e.logger),this.HlsPlayerClass=void 0,this.hls=void 0,this.assetListLoader=void 0,this.mediaSelection=null,this.altSelection=null,this.media=null,this.detachedData=null,this.requiredTracks=null,this.manager=null,this.playerQueue=[],this.bufferedPos=-1,this.timelinePos=-1,this.schedule=void 0,this.playingItem=null,this.bufferingItem=null,this.waitingItem=null,this.endedItem=null,this.playingAsset=null,this.endedAsset=null,this.bufferingAsset=null,this.shouldPlay=!1,this.onPlay=()=>{this.shouldPlay=!0},this.onPause=()=>{this.shouldPlay=!1}
31,this.onSeeking=()=>{var e,t;let i=this.currentTime;if(void 0===i||this.playbackDisabled||!this.schedule)return;let s=i-this.timelinePos;if(Math.abs(s)<1/7056e5)return;let r=s<=-.01;-1!==this.timelinePos||this.effectivePlayingItem||this.checkStart(),this.timelinePos=i,this.bufferedPos=i;let a=this.playingItem;if(!a)return void this.checkBuffer();if(r&&this.schedule.resetErrorsInRange(i,i-s)&&this.updateSchedule(!0),this.checkBuffer(),r&&i<a.start||i>=a.end){let t=this.findItemIndex(a),s=this.schedule.findItemIndexAtTime(i);if(-1===s&&(s=t+(r?-1:1),this.log(`seeked ${r?"back ":""}to position not covered by schedule ${i} (resolving from ${t} to ${s})`)),!this.isInterstitial(a)&&null!=(e=this.media)&&e.paused&&(this.shouldPlay=!1),!r&&s>t){let e=this.schedule.findJumpRestrictedIndex(t+1,s);if(e>t)return void this.setSchedulePosition(e)}this.setSchedulePosition(s);return}let n=this.playingAsset;if(!n){if(this.playingLastItem&&this.isInterstitial(a)){let e=a.event.assetList[0];e&&(this.endedItem=this.playingItem,this.playingItem=null,this.setScheduleToAssetAtTime(i,e))}return}let l=n.timelineStart,o=n.duration||0;(r&&i<l||i>=l+o)&&(null!=(t=a.event)&&t.appendInPlace&&(this.clearAssetPlayers(a.event,a),this.flushFrontBuffer(i)),this.setScheduleToAssetAtTime(i,n))},this.onTimeupdate=()=>{let e=this.currentTime;if(void 0===e||this.playbackDisabled||(-1!==this.timelinePos||this.effectivePlayingItem||this.checkStart(),!(e>this.timelinePos)))return;this.timelinePos=e,e>this.bufferedPos&&this.checkBuffer();let t=this.playingItem;if(!t||this.playingLastItem)return;if(e>=t.end){this.timelinePos=t.end;let e=this.findItemIndex(t);this.setSchedulePosition(e+1)}let i=this.playingAsset;!i||e>=i.timelineStart+(i.duration||0)&&this.setScheduleToAssetAtTime(e,i)},this.onScheduleUpdate=(e,t)=>{let i=this.schedule;if(!i)return;let s=this.playingItem,r=i.events||[],a=i.items||[],n=i.durations,l=e.map(e=>e.identifier),o=!!(r.length||l.length);(o||t)&&this.log(`INTERSTITIALS_UPDATED (${r.length}): ${r}
32Schedule: ${a.map(e=>yq(e))} pos: ${this.timelinePos}`),l.length&&this.log(`Removed events ${l}`);let d=null,h=null;s&&(d=this.updateItem(s,this.timelinePos),this.itemsMatch(s,d)?this.playingItem=d:this.waitingItem=this.endedItem=null),this.waitingItem=this.updateItem(this.waitingItem),this.endedItem=this.updateItem(this.endedItem);let u=this.bufferingItem;if(u&&(h=this.updateItem(u,this.bufferedPos),this.itemsMatch(u,h)?this.bufferingItem=h:u.event&&(this.bufferingItem=this.playingItem,this.clearInterstitial(u.event,null))),e.forEach(e=>{e.assetList.forEach(e=>{this.clearAssetPlayer(e.identifier,null)})}),this.playerQueue.forEach(e=>{if(e.interstitial.appendInPlace){let t=e.assetItem.timelineStart,i=e.timelineOffset-t;if(i)try{e.timelineOffset=t}catch(s){Math.abs(i)>.025&&this.warn(`${s} ("${e.assetId}" ${e.timelineOffset}->${t})`)}}}),o||t){if(this.hls.trigger(cA.INTERSTITIALS_UPDATED,{events:r.slice(0),schedule:a.slice(0),durations:n,removedIds:l}),this.isInterstitial(s)&&l.includes(s.event.identifier)){this.warn(`Interstitial "${s.event.identifier}" removed while playing`),this.primaryFallback(s.event);return}s&&this.trimInPlace(d,s),u&&h!==d&&this.trimInPlace(h,u),this.checkBuffer()}},this.hls=e,this.HlsPlayerClass=t,this.assetListLoader=new yH(e),this.schedule=new yG(this.onScheduleUpdate,e.logger),this.registerListeners()}registerListeners(){let e=this.hls;
32e&&(e.on(cA.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(cA.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(cA.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(cA.MANIFEST_LOADING,this.onManifestLoading,this),e.on(cA.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(cA.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(cA.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.on(cA.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(cA.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.on(cA.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.on(cA.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.on(cA.BUFFER_APPENDED,this.onBufferAppended,this),e.on(cA.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(cA.BUFFERED_TO_END,this.onBufferedToEnd,this),e.on(cA.MEDIA_ENDED,this.onMediaEnded,this),e.on(cA.ERROR,this.onError,this),e.on(cA.DESTROYING,this.onDestroying,this))}unregisterListeners(){let e=this.hls;e&&(e.off(cA.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(cA.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(cA.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(cA.MANIFEST_LOADING,this.onManifestLoading,this),e.off(cA.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(cA.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(cA.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.off(cA.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(cA.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.off(cA.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.off(cA.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.off(cA.BUFFER_CODECS,this.onBufferCodecs,this),e.off(cA.BUFFER_APPENDED,this.onBufferAppended,this),e.off(cA.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(cA.BUFFERED_TO_END,this.onBufferedToEnd,this),e.off(cA.MEDIA_ENDED,this.onMediaEnded,this),e.off(cA.ERROR,this.onError,this),e.off(cA.DESTROYING,this.onDestroying,this))}startLoad(){this.resumeBuffering()}stopLoad(){this.pauseBuffering()}resumeBuffering(){var e;null==(e=this.getBufferingPlayer())||e.resumeBuffering()}pauseBuffering(){var e;null==(e=this.getBufferingPlayer())||e.pauseBuffering()}destroy(){this.unregisterListeners(),this.stopLoad(),this.assetListLoader&&this.assetListLoader.destroy(),this.emptyPlayerQueue(),this.clearScheduleState(),this.schedule&&this.schedule.destroy(),this.media=this.detachedData=this.mediaSelection=this.requiredTracks=this.altSelection=this.schedule=this.manager=null,this.hls=this.HlsPlayerClass=this.log=null,this.assetListLoader=null,this.onPlay=this.onPause=this.onSeeking=this.onTimeupdate=null,this.onScheduleUpdate=null}onDestroying(){let e=this.primaryMedia||this.media;e&&this.removeMediaListeners(e)}removeMediaListeners(e){mS(e,"play",this.onPlay),mS(e,"pause",this.onPause),mS(e,"seeking",this.onSeeking),mS(e,"timeupdate",this.onTimeupdate)}onMediaAttaching(e,t){let i=this.media=t.media;mE(i,"seeking",this.onSeeking),mE(i,"timeupdate",this.onTimeupdate),mE(i,"play",this.onPlay),mE(i,"pause",this.onPause)}onMediaAttached(e,t){let i=this.effectivePlayingItem,s=this.detachedData;if(this.detachedData=null,null===i)this.checkStart();else if(!s){this.clearScheduleState();let e=this.findItemIndex(i);this.setSchedulePosition(e)}}clearScheduleState(){this.log("clear schedule state"),this.playingItem=this.bufferingItem=this.waitingItem=this.endedItem=this.playingAsset=this.endedAsset=this.bufferingAsset=null}onMediaDetaching(e,t){let i=!!t.transferMedia,s=this.media;if(this.media=null,!i&&(s&&this.removeMediaListeners(s),this.detachedData)){let e=this.getBufferingPlayer();e&&(this.log(`Removing schedule state for detachedData and ${e}`),this.playingAsset=this.endedAsset=this.bufferingAsset=this.bufferingItem=this.waitingItem=this.detachedData=null,e.detachMedia()),this.shouldPlay=!1}}get interstitialsManager(){if(!this.hls)return null;if(this.manager)return this.manager;let e=this,t=t=>t?e.getAssetPlayer(t.identifier):t,i=(i,r,a,n,l)=>{if(i){let o=i[r].start,d=i.event;if(d){if("playout"===r||d.timelineOccupancy!==yO.Point){let e=t(a);(null==e?void 0:e.interstitial)===d&&(o+=e.assetItem.startOffset+e[l])}}else o+=("bufferedPos"===n?s():e[n])-i.start;return o}return 0},s=()=>{let t=e.bufferedPos;return t===Number.MAX_VALUE?r("primary"):Math.max(t,0)},r=t=>{var i,s;return null!=(i=e.primaryDetails)&&i.live?e.primaryDetails.edge:(null==(s=e.schedule)?void 0:s.durations[t])||0},a=(s,r)=>{var a,n;let l=e.effectivePlayingItem;if(null!=l&&null!=(a=l.event)&&a.restrictions.skip||!e.schedule)return;e.log(`seek to ${s} "${r}"`);let o=e.effectivePlayingItem,d=e.schedule.findItemIndexAtTime(s,r),h=null==(n=e.schedule.items)?void 0:n[d],u=e.getBuffer
32ingPlayer(),c=null==u?void 0:u.interstitial,f=null==c?void 0:c.appendInPlace,p=o&&e.itemsMatch(o,h);if(o&&(f||p)){let a=t(e.playingAsset),n=(null==a?void 0:a.media)||e.primaryMedia;if(n){let t="primary"===r?n.currentTime:i(o,r,e.playingAsset,"timelinePos","currentTime"),l=s-t,d=(f?t:n.currentTime)+l;if(d>=0&&(!a||f||d<=a.duration)){n.currentTime=d;return}}}if(h){let t=s;if("primary"!==r){let e=s-h[r].start;t=h.start+e}let i=!e.isInterstitial(h);if((!e.isInterstitial(o)||o.event.appendInPlace)&&(i||h.event.appendInPlace)){let i=e.media||(f?null==u?void 0:u.media:null);i&&(i.currentTime=t)}else if(o){let a=e.findItemIndex(o);if(d>a){let t=e.schedule.findJumpRestrictedIndex(a+1,d);if(t>a)return void e.setSchedulePosition(t)}let n=0;if(i)e.timelinePos=t,e.checkBuffer();else{let e=h.event.assetList,t=s-(h[r]||h).start;for(let i=e.length;i--;){let s=e[i];if(s.duration&&t>=s.startOffset&&t<s.startOffset+s.duration){n=i;break}}}e.setSchedulePosition(d,n)}}},n=()=>{let t=e.effectivePlayingItem;if(e.isInterstitial(t))return t;let i=e.bufferingItem||e.waitingItem;return e.isInterstitial(i)?i:null},l={get bufferedEnd(){let t=e.bufferingItem||e.waitingItem,s=e.bufferingItem;if(s&&s===t){var o;return i(s,"playout",e.bufferingAsset,"bufferedPos","bufferedEnd")-s.playout.start||(null==(o=e.bufferingAsset)?void 0:o.startOffset)||0}return 0},get currentTime(){let t=n(),s=e.effectivePlayingItem;if(s&&s===t)return i(s,"playout",e.effectivePlayingAsset,"timelinePos","currentTime")-s.playout.start;return 0},set currentTime(time){let t=n(),i=e.effectivePlayingItem;i&&i===t&&a(time+i.playout.start,"playout")},get duration(){let e=n();if(e)return e.playout.end-e.playout.start;return 0},get assetPlayers(){var d;let t=null==(d=n())?void 0:d.event.assetList;if(t)return t.map(t=>e.getAssetPlayer(t.identifier));return[]},get playingIndex(){var h;let t=null==(h=n())?void 0:h.event;if(t&&e.effectivePlayingAsset)return t.findAssetIndex(e.effectivePlayingAsset);return -1},get scheduleItem(){return n()}};return this.manager={get events(){var u;return(null==(u=e.schedule)||null==(u=u.events)?void 0:u.slice(0))||[]},get schedule(){var c;return(null==(c=e.schedule)||null==(c=c.items)?void 0:c.slice(0))||[]},get interstitialPlayer(){if(n())return l;return null},get playerQueue(){return e.playerQueue.slice(0)},get bufferingAsset(){return e.bufferingAsset},get bufferingItem(){return e.bufferingItem||e.waitingItem},get bufferingIndex(){let t=e.bufferingItem||e.waitingItem;return e.findItemIndex(t)},get playingAsset(){return e.effectivePlayingAsset},get playingItem(){return e.effectivePlayingItem},get playingIndex(){let t=e.effectivePlayingItem;return e.findItemIndex(t)},primary:{get bufferedEnd(){return s()},get currentTime(){let t=e.timelinePos;return t>0?t:0},set currentTime(time){a(time,"primary")},get duration(){return r("primary")},get seekableStart(){var f;return(null==(f=e.primaryDetails)?void 0:f.fragmentStart)||0}},integrated:{get bufferedEnd(){return i(e.bufferingItem||e.waitingItem,"integrated",e.bufferingAsset,"bufferedPos","bufferedEnd")},get currentTime(){return i(e.effectivePlayingItem,"integrated",e.effectivePlayingAsset,"timelinePos","currentTime")},set currentTime(time){a(time,"integrated")},get duration(){return r("integrated")},get seekableStart(){var p;return((t,i)=>{var s,r;if(0!==t&&"primary"!==i&&null!=(s=e.schedule)&&s.length){let s=e.schedule.findItemIndexAtTime(t),a=null==(r=e.schedule.items)?void 0:r[s];if(a)return t+(a[i].start-a.start)}return t})((null==(p=e.primaryDetails)?void 0:p.fragmentStart)||0,"integrated")}},skip:()=>{let t=e.effectivePlayingItem,i=null==t?void 0:t.event;if(i&&!i.restrictions.skip){let s=e.findItemIndex(t);i.appendInPlace?a(t.playout.start+t.event.duration+.001,"playout"):e.advanceAfterAssetEnded(i,s,1/0)}}}}get effectivePlayingItem(){return this.waitingItem||this.playingItem||this.endedItem}get effectivePlayingAsset(){return this.playingAsset||this.endedAsset}get playingLastItem(){var e;let t=this.playingItem,i=null==(e=this.schedule)?void 0:e.items;return!!this.playbackStarted&&!!t&&!!i&&this.findItemIndex(t)===i.length-1}get playbackStarted(){return null!==this.effectivePlayingItem}get currentTime(){var e,t;if(null===this.mediaSelection)return;let i=this.waitingItem||this.playingItem;if(this.isInterstitial(i)&&!i.event.appendInPlace)return;let s=this.media;!s&&null!=(e=this.bufferingItem)&&null!=(e=e.event)&&e.appendInPlace&&(s=this.primaryMedia);let r=null==(t=s)?void 0:t.currentTime;if(void 0!==r&&cS(r))return r}get primaryMedia(){var e;return this.media||(null==(e=this.detachedData)?void 0:e.media)||null}isInterstitial(e){return!!(null!=e&&e.event)}retreiveMediaSource(e,t){let i=this.getAssetPlayer(e);i&&this.transferMediaFromPlayer(i,t)}transferMediaFromPlayer(e,t){let i=e.interstitial.appendInPlace,s=e.media;if(i&&s===this.primaryMedia){if(this.bufferingAsset=null,(!t||this.isInterstitial(t)&&!t.event.appendInPlace)&&t&&s){this.detachedData={media:s};return}let i=e.transferMedia();this.log(`transfer MediaSource from ${e} ${fj(i)}`),this.detachedData=i}else t&&s&&(this.shouldPlay||(this.shouldPlay=!s.paused))}transferMediaTo(e,t){var i,s;let r;if(e.media===t)return;let a=null,n=this.hls,l=e!==n,o=l&&e.interstitial.appendInPlace,d=null==(i=this.detachedData)?void 0:i.mediaSource;if(n.media)o&&(a=n.transferMedia(),this.detachedData=a),r="Primary";
32else if(d){let e=this.getBufferingPlayer();e?(a=e.transferMedia(),r=`${e}`):r="detached MediaSource"}else r="detached media";if(!a){if(d)a=this.detachedData,this.log(`using detachedData: MediaSource ${fj(a)}`);else if(!this.detachedData||n.media===t){let e=this.playerQueue;e.length>1&&e.forEach(e=>{if(l&&e.interstitial.appendInPlace!==o){let t=e.interstitial;this.clearInterstitial(e.interstitial,null),t.appendInPlace=!1,t.appendInPlace&&this.warn(`Could not change append strategy for queued assets ${t}`)}}),this.hls.detachMedia(),this.detachedData={media:t}}}let h=a&&"mediaSource"in a&&(null==(s=a.mediaSource)?void 0:s.readyState)!=="closed",u=h&&a?a:t;this.log(`${h?"transfering MediaSource":"attaching media"} to ${l?e:"Primary"} from ${r} (media.currentTime: ${t.currentTime})`);let c=this.schedule;if(u===a&&c){let t=l&&e.assetId===c.assetIdAtEnd;u.overrides={duration:c.duration,endOfStream:!l||t,cueRemoval:!l}}e.attachMedia(u)}onInterstitialCueEnter(){this.onTimeupdate()}checkStart(){let e=this.schedule,t=null==e?void 0:e.events;if(!t||this.playbackDisabled||!this.media)return;-1===this.bufferedPos&&(this.bufferedPos=0);let i=this.timelinePos,s=this.effectivePlayingItem;if(-1===i){let i=this.hls.startPosition;if(this.timelinePos=i,0===t.length)this.setSchedulePosition(0);else if(t[0].cue.pre){this.log(yW("checkStart (preroll)",i));let s=e.findEventIndex(t[0].identifier);this.setSchedulePosition(s)}else if(i>=0||!this.primaryLive){this.log(yW("checkStart",i));let t=this.timelinePos=i>0?i:0,s=e.findItemIndexAtTime(t);this.setSchedulePosition(s)}else 0===this.hls.liveSyncPosition?this.setSchedulePosition(0):this.log("[checkStart] waiting for live start")}else if(s&&!this.playingItem){this.log(yW("checkStart (playing item)",s.start));let t=e.findItemIndex(s);this.setSchedulePosition(t)}}advanceAssetBuffering(e,t){let i=e.event,s=i.findAssetIndex(t),r=yU(i,s);if(i.isAssetPastPlayoutLimit(r)){if(this.schedule){var a;let t=null==(a=this.schedule.items)?void 0:a[this.findItemIndex(e)+1];t&&this.bufferedToItem(t)}}else this.bufferedToEvent(e,r)}advanceAfterAssetEnded(e,t,i){let s=yU(e,i);if(e.isAssetPastPlayoutLimit(s)){if(this.schedule){let i=this.schedule.items;if(i){let s=t+1;if(s>=i.length)return void this.setSchedulePosition(-1);let r=e.resumeTime;this.timelinePos<r&&(this.log(yW("advanceAfterAssetEnded",r)),this.timelinePos=r,e.appendInPlace&&this.advanceInPlace(r),this.checkBuffer(this.bufferedPos<r)),this.setSchedulePosition(s)}}}else{if(e.appendInPlace){let t=e.assetList[s];t&&this.advanceInPlace(t.timelineStart)}this.setSchedulePosition(t,s)}}setScheduleToAssetAtTime(e,t){let i=this.schedule;if(!i)return;let s=t.parentIdentifier,r=i.getEvent(s);if(r){let t=i.findEventIndex(s),a=i.findAssetIndex(r,e);this.advanceAfterAssetEnded(r,t,a-1)}}setSchedulePosition(e,t){var i,s,r;let a=null==(i=this.schedule)?void 0:i.items;if(!a||this.playbackDisabled)return;let n=e>=0?a[e]:null;this.log(`setSchedulePosition ${e}, ${t} (${n?yq(n):n}) pos: ${this.timelinePos}`);let l=this.waitingItem||this.playingItem,o=this.playingLastItem;if(this.isInterstitial(l)){let i=l.event,d=this.playingAsset,h=null==d?void 0:d.identifier,u=h?this.getAssetPlayer(h):null;if(u&&h&&(!this.eventItemsMatch(l,n)||void 0!==t&&h!==i.assetList[t].identifier)){let t=i.findAssetIndex(d);if(this.log(`INTERSTITIAL_ASSET_ENDED ${t+1}/${i.assetList.length} ${yj(d)}`),this.endedAsset=d,this.playingAsset=null,this.hls.trigger(cA.INTERSTITIAL_ASSET_ENDED,{asset:d,assetListIndex:t,event:i,schedule:a.slice(0),scheduleIndex:e,player:u}),l!==this.playingItem){this.itemsMatch(l,this.playingItem)&&!this.playingAsset&&this.advanceAfterAssetEnded(i,this.findItemIndex(this.playingItem),t);return}this.retreiveMediaSource(h,n),u.media&&!(null!=(s=this.detachedData)&&s.mediaSource)&&u.detachMedia()}if(!this.eventItemsMatch(l,n)&&(this.endedItem=l,this.playingItem=null,this.log(`INTERSTITIAL_ENDED ${i} ${yq(l)}`),i.hasPlayed=!0,this.hls.trigger(cA.INTERSTITIAL_ENDED,{event:i,schedule:a.slice(0),scheduleIndex:e}),i.cue.once)){this.updateSchedule();let e=null==(r=this.schedule)?void 0:r.items;if(n&&e){let i=this.findItemIndex(n);this.advanceSchedule(i,e,t,l,o)}return}}this.advanceSchedule(e,a,t,l,o)}advanceSchedule(e,t,i,s,r){let a=this.schedule;if(!a)return;let n=t[e]||null,l=this.primaryMedia,o=this.playerQueue;if(o.length&&o.forEach(t=>{let i=t.interstitial,s=a.findEventIndex(i.identifier);(s<e||s>e+1)&&this.clearInterstitial(i,n)}),this.isInterstitial(n)){this.timelinePos=Math.min(Math.max(this.timelinePos,n.start),n.end);let r=n.event;if(void 0===i){i=a.findAssetIndex(r,this.timelinePos);let t=yU(r,i-1);if(r.isAssetPastPlayoutLimit(t)||r.appendInPlace&&this.timelinePos===n.end)return void this.advanceAfterAssetEnded(r,e,i);i=t}let o=this.waitingItem;this.assetsBuffered(n,l)||this.setBufferingItem(n);let d=this.preloadAssets(r,i);if(this.eventItemsMatch(n,o||s)||(this.waitingItem=n,this.log(`INTERSTITIAL_STARTED ${yq(n)} ${r.appendInPlace?"append in place":""}`),this.hls.trigger(cA.INTERSTITIAL_STARTED,{event:r,schedule:t.slice(0),scheduleIndex:e})),!r.assetListLoaded)return void this.log(`Waiting for ASSET-LIST to complete loading ${r}`);if(r.assetListLoader&&(r.assetListLoader.destroy(),r.assetListLoader=void 0),!l)return void this.log(`Waiting for attachMedia to start Interstitial ${r}`);this.waitingItem=this.endedItem=null,this.playingItem=n;let h=r.assetList[i];if(!h)return void this.advanceAfterAssetEnded(r,e,i||0);if(d||(d=this.getAssetPlayer(h.identifier)),null===d||d.destroyed){let e=r.assetList.length;this.warn(`asset ${i+1}/${e} player destroyed ${r}`),(d=this.createAssetPlayer(r,h,i)).loadSource()}if(!this.eventItemsMatch(n,this.bufferingItem)&&r.appendInPlace&&this.isAssetBuffered(h))return;this.startAssetPlayer(d,i,t,e,l),this.shouldPlay&&yK(d.media)}else n?(this.resumePrimary(n,e,s),this.shouldPlay&&yK(this.hls.media)):r&&this.isInterstitial(s)&&(this.endedItem=null,this.playingItem=s,s.event.appendInPlace||this.attachPrimary(a.durations.primary,null))}get playbackDisabled(){return!1===this.hls.config.enableInterstitialPlayback}get primaryDetails(){var e;return null==(e=this.mediaSelection)?void 0:e.main.details}get primaryLive(){var e;return!!(null!=(e=this.primaryDetails)&&e.live)}resumePrimary(e,t,i){var s,r;if(this.playingItem=e,this.playingAsset=this.endedAsset=null,this.waitingItem=this.endedItem=null,this.bufferedToItem(e),this.log(`resuming ${yq(e)}`),!(null!=(s=this.detachedData)&&s.mediaSource)){let i=this.timelinePos;(i<e.start||i>=e.end)&&(i=this.getPrimaryResumption(e,t),this.log(yW("resumePrimary",i)),this.timelinePos=i),this.attachPrimary(i,e)}if(!i)return;let a=null==(r=this.schedule)?void 0:r.items;a&&(this.log(`INTERSTITIALS_PRIMARY_RESUMED ${yq(e)}`),this.hls.trigger(cA.INTERSTITIALS_PRIMARY_RESUMED,{schedule:a.slice(0),scheduleIndex:t}),this.checkBuffer())}getPrimaryResumption(e,t){let i=e.start;if(this.primaryLive){let e=this.primaryDetails;if(0===t)return this.hls.startPosition;if(e&&(i<e.fragmentStart||i>e.edge))return this.hls.liveSyncPosition||-1}return i}isAssetBuffered(e){let t=this.getAssetPlayer(e.identifier);return null!=t&&t.hls?t.hls.bufferedToEnd:pv.bufferInfo(this.primaryMedia,this.timelinePos,0).end+1>=e.timelineStart+(e.duration||0)}attachPrimary(e,t,i){t?this.setBufferingItem(t):this.bufferingItem=this.playingItem,this.bufferingAsset=null;let s=this.primaryMedia;if(!s)return;let r=this.hls;r.media?this.checkBuffer():(this.transferMediaTo(r,s),i&&this.startLoadingPrimaryAt(e,i)),i||(this.log(yW("attachPrimary",e)),this.timelinePos=e,this.startLoadingPrimaryAt(e,i))}
32startLoadingPrimaryAt(e,t){var i;let s=this.hls;!s.loadingEnabled||!s.media||Math.abs(((null==(i=s.mainForwardBufferInfo)?void 0:i.start)||s.media.currentTime)-e)>.5?s.startLoad(e,t):s.bufferingEnabled||s.resumeBuffering()}onManifestLoading(){var e;this.stopLoad(),null==(e=this.schedule)||e.reset(),this.emptyPlayerQueue(),this.clearScheduleState(),this.shouldPlay=!1,this.bufferedPos=this.timelinePos=-1,this.mediaSelection=this.altSelection=this.manager=this.requiredTracks=null,this.hls.off(cA.BUFFER_CODECS,this.onBufferCodecs,this),this.hls.on(cA.BUFFER_CODECS,this.onBufferCodecs,this)}onLevelUpdated(e,t){if(-1===t.level||!this.schedule)return;let i=this.hls.levels[t.level];if(!i.details)return;let s=cF(cF({},this.mediaSelection||this.altSelection),{},{main:i});this.mediaSelection=s,this.schedule.parseInterstitialDateRanges(s,this.hls.config.interstitialAppendInPlace),!this.effectivePlayingItem&&this.schedule.items&&this.checkStart()}onAudioTrackUpdated(e,t){let i=this.hls.audioTracks[t.id],s=this.mediaSelection;if(!s){this.altSelection=cF(cF({},this.altSelection),{},{audio:i});return}let r=cF(cF({},s),{},{audio:i});this.mediaSelection=r}onSubtitleTrackUpdated(e,t){let i=this.hls.subtitleTracks[t.id],s=this.mediaSelection;if(!s){this.altSelection=cF(cF({},this.altSelection),{},{subtitles:i});return}let r=cF(cF({},s),{},{subtitles:i});this.mediaSelection=r}onAudioTrackSwitching(e,t){let i=fq(t);this.playerQueue.forEach(({hls:e})=>e&&(e.setAudioOption(t)||e.setAudioOption(i)))}onSubtitleTrackSwitch(e,t){let i=fq(t);this.playerQueue.forEach(({hls:e})=>e&&(e.setSubtitleOption(t)||-1!==t.id&&e.setSubtitleOption(i)))}onBufferCodecs(e,t){let i=t.tracks;i&&(this.requiredTracks=i)}onBufferAppended(e,t){this.checkBuffer()}onBufferFlushed(e,t){let i=this.playingItem;if(i&&!this.itemsMatch(i,this.bufferingItem)&&!this.isInterstitial(i)){let e=this.timelinePos;this.bufferedPos=e,this.checkBuffer()}}onBufferedToEnd(e){if(!this.schedule)return;let t=this.schedule.events;if(this.bufferedPos<Number.MAX_VALUE&&t){for(let e=0;e<t.length;e++){let s=t[e];if(s.cue.post){var i;let e=this.schedule.findEventIndex(s.identifier),t=null==(i=this.schedule.items)?void 0:i[e];this.isInterstitial(t)&&this.eventItemsMatch(t,this.bufferingItem)&&this.bufferedToItem(t,0);break}}this.bufferedPos=Number.MAX_VALUE}}onMediaEnded(e){let t=this.playingItem;if(!this.playingLastItem&&t){let e=this.findItemIndex(t);this.setSchedulePosition(e+1)}else this.shouldPlay=!1}updateItem(e,t){var i;let s=null==(i=this.schedule)?void 0:i.items;return e&&s&&s[this.findItemIndex(e,t)]||null}trimInPlace(e,t){if(this.isInterstitial(e)&&e.event.appendInPlace&&t.end-e.end>.25){e.event.assetList.forEach((t,i)=>{e.event.isAssetPastPlayoutLimit(i)&&this.clearAssetPlayer(t.identifier,null)});let i=e.end+.25,s=pv.bufferInfo(this.primaryMedia,i,0);(s.end>i||(s.nextStart||0)>i)&&(this.log(`trim buffered interstitial ${yq(e)} (was ${yq(t)})`),this.attachPrimary(i,null,!0),this.flushFrontBuffer(i))}}itemsMatch(e,t){return!!t&&(e===t||e.event&&t.event&&this.eventItemsMatch(e,t)||!e.event&&!t.event&&this.findItemIndex(e)===this.findItemIndex(t))}eventItemsMatch(e,t){var i;return!!t&&(e===t||e.event.identifier===(null==(i=t.event)?void 0:i.identifier))}findItemIndex(e,t){return e&&this.schedule?this.schedule.findItemIndex(e,t):-1}updateSchedule(e=!1){var t;let i=this.mediaSelection;i&&(null==(t=this.schedule)||t.updateSchedule(i,[],e))}checkBuffer(e){var t;let i=null==(t=this.schedule)?void 0:t.items;if(!i)return;let s=pv.bufferInfo(this.primaryMedia,this.timelinePos,0);e&&(this.bufferedPos=this.timelinePos),e||(e=s.len<1),this.updateBufferedPos(s.end,i,e)}updateBufferedPos(e,t,i){let s=this.schedule,r=this.bufferingItem;if(this.bufferedPos>e||!s)return;if(1===t.length&&this.itemsMatch(t[0],r)){this.bufferedPos=e;return}let a=this.playingItem,n=this.findItemIndex(a),l=s.findItemIndexAtTime(e);if(this.bufferedPos<e){var o;let i=this.findItemIndex(r),s=Math.min(i+1,t.length-1),a=t[s];if((-1===l&&r&&e>=r.end||null!=(o=a.event)&&o.appendInPlace&&e+.01>=a.start)&&(l=s),this.isInterstitial(r)){let e=r.event;if(s-n>1&&!1===e.appendInPlace||0===e.assetList.length&&e.assetListLoader)return}if(this.bufferedPos=e,l>i&&l>n)this.bufferedToItem(a);else{let t=this.primaryDetails;this.primaryLive&&t&&e>t.edge-t.targetduration&&a.start<t.edge+this.hls.config.interstitialLiveLookAhead&&this.isInterstitial(a)&&this.preloadAssets(a.event,0)}}else i&&a&&!this.itemsMatch(a,r)&&(l===n?this.bufferedToItem(a):l===n+1&&this.bufferedToItem(t[l]))}assetsBuffered(e,t){return 0!==e.event.assetList.length&&!e.event.assetList.some(e=>{let i=this.getAssetPlayer(e.identifier);return!(null!=i&&i.bufferedInPlaceToEnd(t))})}setBufferingItem(e){let t=this.bufferingItem,i=this.schedule;if(!this.itemsMatch(e,t)&&i){let{items:s,events:r}=i;if(!s||!r)return t;
32let a=this.isInterstitial(e),n=this.getBufferingPlayer();this.bufferingItem=e,this.bufferedPos=Math.max(e.start,Math.min(e.end,this.timelinePos));let l=n?n.remaining:t?t.end-this.timelinePos:0;if(this.log(`INTERSTITIALS_BUFFERED_TO_BOUNDARY ${yq(e)}`+(t?` (${l.toFixed(2)} remaining)`:"")),!this.playbackDisabled)if(a){let t=i.findAssetIndex(e.event,this.bufferedPos);e.event.assetList.forEach((e,i)=>{let s=this.getAssetPlayer(e.identifier);s&&(i===t&&s.loadSource(),s.resumeBuffering())})}else this.hls.resumeBuffering(),this.playerQueue.forEach(e=>e.pauseBuffering());this.hls.trigger(cA.INTERSTITIALS_BUFFERED_TO_BOUNDARY,{events:r.slice(0),schedule:s.slice(0),bufferingIndex:this.findItemIndex(e),playingIndex:this.findItemIndex(this.playingItem)})}else this.bufferingItem!==e&&(this.bufferingItem=e);return t}bufferedToItem(e,t=0){let i=this.setBufferingItem(e);if(!this.playbackDisabled){if(this.isInterstitial(e))this.bufferedToEvent(e,t);else if(null!==i){this.bufferingAsset=null;let t=this.detachedData;t&&t.mediaSource?this.attachPrimary(e.start,e,!0):this.preloadPrimary(e)}}}preloadPrimary(e){let t=this.findItemIndex(e),i=this.getPrimaryResumption(e,t);this.startLoadingPrimaryAt(i)}bufferedToEvent(e,t){let i=e.event,s=0===i.assetList.length&&!i.assetListLoader,r=i.cue.once;if(s||!r){let e=this.preloadAssets(i,t);if(null!=e&&e.interstitial.appendInPlace){let t=this.primaryMedia;t&&this.bufferAssetPlayer(e,t)}}}preloadAssets(e,t){let i=e.assetUrl,s=e.assetList.length,r=0===s&&!e.assetListLoader,a=e.cue.once;if(r){let r,a=e.timelineStart;if(e.appendInPlace){var n;let t=this.playingItem;this.isInterstitial(t)||(null==t||null==(n=t.nextEvent)?void 0:n.identifier)!==e.identifier||this.flushFrontBuffer(a+.25)}let l=0;if(!this.playingItem&&this.primaryLive&&-1===(l=this.hls.startPosition)&&(l=this.hls.liveSyncPosition||0),l&&!(e.cue.pre||e.cue.post)){let e=l-a;e>0&&(r=Math.round(1e3*e)/1e3)}if(this.log(`Load interstitial asset ${t+1}/${i?1:s} ${e}${r?` live-start: ${l} start-offset: ${r}`:""}`),i)return this.createAsset(e,0,0,a,e.duration,i);let o=this.assetListLoader.loadAssetList(e,r);o&&(e.assetListLoader=o)}else if(!a&&s){for(let i=t;i<s;i++){let t=e.assetList[i],s=this.getAssetPlayerQueueIndex(t.identifier);(-1===s||this.playerQueue[s].destroyed)&&!t.error&&this.createAssetPlayer(e,t,i)}let i=e.assetList[t];if(i){let e=this.getAssetPlayer(i.identifier);return e&&e.loadSource(),e}}return null}flushFrontBuffer(e){let t=this.requiredTracks;t&&(this.log(`Removing front buffer starting at ${e}`),Object.keys(t).forEach(t=>{this.hls.trigger(cA.BUFFER_FLUSHING,{startOffset:e,endOffset:1/0,type:t})}))}getAssetPlayerQueueIndex(e){let t=this.playerQueue;for(let i=0;i<t.length;i++)if(e===t[i].assetId)return i;return -1}getAssetPlayer(e){let t=this.getAssetPlayerQueueIndex(e);return this.playerQueue[t]||null}getBufferingPlayer(){let{playerQueue:e,primaryMedia:t}=this;if(t){for(let i=0;i<e.length;i++)if(e[i].media===t)return e[i]}return null}createAsset(e,t,i,s,r,a){let n={parentIdentifier:e.identifier,identifier:`${e.identifier}-${t+1}-${y$(a)}`,duration:r,startOffset:i,timelineStart:s,uri:a};return this.createAssetPlayer(e,n,t)}createAssetPlayer(e,t,i){let s=this.hls,r=s.userConfig,a=r.videoPreference,n=s.loadLevelObj||s.levels[s.currentLevel];(a||n)&&(a=cO({},a),n.videoCodec&&(a.videoCodec=n.videoCodec),n.videoRange&&(a.allowedVideoRanges=[n.videoRange]));let l=s.audioTracks[s.audioTrack],o=s.subtitleTracks[s.subtitleTrack],d=0;if(this.primaryLive||e.appendInPlace){let e=this.timelinePos-t.timelineStart;if(e>1){let i=t.duration;i&&e<i&&(d=e)}}let h=t.identifier,u=cF(cF({},r),{},{maxMaxBufferLength:Math.min(180,s.config.maxMaxBufferLength),autoStartLoad:!0,startFragPrefetch:!0,primarySessionId:s.sessionId,assetPlayerId:h,abrEwmaDefaultEstimate:s.bandwidthEstimate,interstitialsController:void 0,startPosition:d,liveDurationInfinity:!1,testBandwidth:!1,videoPreference:a,audioPreference:l||r.audioPreference,subtitlePreference:o||r.subtitlePreference});e.appendInPlace&&(e.appendInPlaceStarted=!0,t.timelineStart&&(u.timelineOffset=t.timelineStart));let c=u.cmcd;null!=c&&c.sessionId&&c.contentId&&(u.cmcd=cO({},c,{contentId:y$(t.uri)})),this.getAssetPlayer(h)&&this.warn(`Duplicate date range identifier ${e} and asset ${h}`);let f=new yV(this.HlsPlayerClass,u,e,t);this.playerQueue.push(f),e.assetList[i]=t;let p=!0,m=s=>{if(s.live){var r;let t=Error(`Interstitials MUST be VOD assets ${e}`),s={fatal:!0,type:ck.OTHER_ERROR,details:cw.INTERSTITIAL_ASSET_ITEM_ER
32ROR,error:t},a=(null==(r=this.schedule)?void 0:r.findEventIndex(e.identifier))||-1;this.handleAssetItemError(s,e,a,i,t.message);return}let a=s.edge-s.fragmentStart,n=t.duration;(p||null===n||a>n)&&(p=!1,this.log(`Interstitial asset "${h}" duration change ${n} > ${a}`),t.duration=a,this.updateSchedule())};f.on(cA.LEVEL_UPDATED,(e,{details:t})=>m(t)),f.on(cA.LEVEL_PTS_UPDATED,(e,{details:t})=>m(t)),f.on(cA.EVENT_CUE_ENTER,()=>this.onInterstitialCueEnter());let g=(e,t)=>{let i=this.getAssetPlayer(h);if(i&&t.tracks){i.off(cA.BUFFER_CODECS,g),i.tracks=t.tracks;let e=this.primaryMedia;this.bufferingAsset===i.assetItem&&e&&!i.media&&this.bufferAssetPlayer(i,e)}};f.on(cA.BUFFER_CODECS,g);let y=()=>{var i;let s=this.getAssetPlayer(h);if(this.log(`buffered to end of asset ${s}`),!s||!this.schedule)return;let r=this.schedule.findEventIndex(e.identifier),a=null==(i=this.schedule.items)?void 0:i[r];this.isInterstitial(a)&&this.advanceAssetBuffering(a,t)};f.on(cA.BUFFERED_TO_END,y);let v=t=>()=>{if(!this.getAssetPlayer(h)||!this.schedule)return;this.shouldPlay=!0;let i=this.schedule.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,i,t)};return f.once(cA.MEDIA_ENDED,v(i)),f.once(cA.PLAYOUT_LIMIT_REACHED,v(1/0)),f.on(cA.ERROR,(t,s)=>{if(!this.schedule)return;let r=this.getAssetPlayer(h);s.details===cw.BUFFER_STALLED_ERROR?null!=r&&r.appendInPlace?this.handleInPlaceStall(e):(this.onTimeupdate(),this.checkBuffer(!0)):this.handleAssetItemError(s,e,this.schedule.findEventIndex(e.identifier),i,`Asset player error ${s.error} ${e}`)}),f.on(cA.DESTROYING,()=>{if(!this.getAssetPlayer(h)||!this.schedule)return;let t=Error(`Asset player destroyed unexpectedly ${h}`),s={fatal:!0,type:ck.OTHER_ERROR,details:cw.INTERSTITIAL_ASSET_ITEM_ERROR,error:t};this.handleAssetItemError(s,e,this.schedule.findEventIndex(e.identifier),i,t.message)}),this.log(`INTERSTITIAL_ASSET_PLAYER_CREATED ${yj(t)}`),this.hls.trigger(cA.INTERSTITIAL_ASSET_PLAYER_CREATED,{asset:t,assetListIndex:i,event:e,player:f}),f}clearInterstitial(e,t){this.clearAssetPlayers(e,t),e.reset()}clearAssetPlayers(e,t){e.assetList.forEach(e=>{this.clearAssetPlayer(e.identifier,t)})}resetAssetPlayer(e){let t=this.getAssetPlayerQueueIndex(e);if(-1!==t){this.log(`reset asset player "${e}" after error`);let i=this.playerQueue[t];this.transferMediaFromPlayer(i,null),i.resetDetails()}}clearAssetPlayer(e,t){let i=this.getAssetPlayerQueueIndex(e);if(-1!==i){let e=this.playerQueue[i];this.log(`clear ${e} toSegment: ${t?yq(t):t}`),this.transferMediaFromPlayer(e,t),this.playerQueue.splice(i,1),e.destroy()}}emptyPlayerQueue(){let e;for(;e=this.playerQueue.pop();)e.destroy();this.playerQueue=[]}startAssetPlayer(e,t,i,s,r){let{interstitial:a,assetItem:n,assetId:l}=e,o=a.assetList.length,d=this.playingAsset;this.endedAsset=null,this.playingAsset=n,d&&d.identifier===l||(d&&(this.clearAssetPlayer(d.identifier,i[s]),delete d.error),this.log(`INTERSTITIAL_ASSET_STARTED ${t+1}/${o} ${yj(n)}`),this.hls.trigger(cA.INTERSTITIAL_ASSET_STARTED,{asset:n,assetListIndex:t,event:a,schedule:i.slice(0),scheduleIndex:s,player:e})),this.bufferAssetPlayer(e,r)}bufferAssetPlayer(e,t){var i,s;if(!this.schedule)return;let{interstitial:r,assetItem:a}=e,n=this.schedule.findEventIndex(r.identifier),l=null==(i=this.schedule.items)?void 0:i[n];if(!l)return;e.loadSource(),this.setBufferingItem(l),this.bufferingAsset=a;let o=this.getBufferingPlayer();if(o===e)return;let d=r.appendInPlace;if(d&&(null==o?void 0:o.interstitial.appendInPlace)===!1)return;let h=(null==o?void 0:o.tracks)||(null==(s=this.detachedData)?void 0:s.tracks)||this.requiredTracks;if(d&&a!==this.playingAsset){if(!e.tracks)return void this.log(`Waiting for track info before buffering ${e}`);if(h&&!cK(h,e.tracks)){let t=Error(`Asset ${yj(a)} SourceBuffer tracks ('${Object.keys(e.tracks)}') are not compatible with primary content tracks ('${Object.keys(h)}')`),i={fatal:!0,type:ck.OTHER_ERROR,details:cw.INTERSTITIAL_ASSET_ITEM_ERROR,error:t},s=r.findAssetIndex(a);this.handleAssetItemError(i,r,n,s,t.message);return}}this.transferMediaTo(e,t)}handleInPlaceStall(e){let t=this.schedule,i=this.primaryMedia;if(!t||!i)return;let s=i.currentTime,r=t.findAssetIndex(e,s),a=e.assetList[r];if(a){let n=this.getAssetPlayer(a.identifier);if(n){let l=n.currentTime||s-a.timelineStart,o=n.duration-l;if(this.warn(`Stalled at ${l} of ${l+o} in ${n} ${e} (media.currentTime: ${s})`),l&&(o/i.playbackRate<.5||n.bufferedInPlaceToEnd(i))&&n.hls){let i=t.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,i,r)}}}}advanceInPlace(e){let t=this.primaryMedia;t&&t.currentTime<e&&(t.currentTime=e)}handleAssetItemError(e,t,i,s,r){if(e.details===cw.BUFFER_STALLED_ERROR)return;let a=t.assetList[s]||null;if(this.warn(`INTERSTITIAL_ASSET_ERROR ${a?yj(a):a} ${e.error}`),!this.schedule)return;let n=(null==a?void 0:a.identifier)||"",l=this.getAssetPlayerQueueIndex(n),o=this.playerQueue[l]||null,d=this.schedule.items,h=cO({},e,{fatal:!1,errorAction:f7(!0),asset:a,assetListIndex:s,event:t,schedule:d,scheduleIndex:i,player:o});if(this.hls.trigger(cA.INTERSTITIAL_ASSET_ERROR,h),!e.fatal)return;let u=this.playingAsset,c=this.bufferingAsset,f=Error(r);
32if(a&&(this.clearAssetPlayer(n,null),a.error=f),t.assetList.some(e=>!e.error))for(let e=s;e<t.assetList.length;e++)this.resetAssetPlayer(t.assetList[e].identifier);else t.error=f;this.updateSchedule(!0),t.error?this.primaryFallback(t):u&&u.identifier===n?this.advanceAfterAssetEnded(t,i,s):c&&c.identifier===n&&this.isInterstitial(this.bufferingItem)&&this.advanceAssetBuffering(this.bufferingItem,c)}primaryFallback(e){let t=e.timelineStart,i=this.effectivePlayingItem,s=this.timelinePos;if(i){this.log(`Fallback to primary from event "${e.identifier}" start: ${t} pos: ${s} playing: ${yq(i)} error: ${e.error}`),-1===s&&(s=this.hls.startPosition);let r=this.updateItem(i,s);this.itemsMatch(i,r)&&this.clearInterstitial(e,null),e.appendInPlace&&(this.attachPrimary(t,null),this.flushFrontBuffer(t))}else if(-1===s)return void this.checkStart();if(!this.schedule)return;let r=this.schedule.findItemIndexAtTime(s);this.setSchedulePosition(r)}onAssetListLoaded(e,t){var i,s,r;let a=t.event,n=a.identifier,l=t.assetListResponse.ASSETS;if(!(null!=(i=this.schedule)&&i.hasEvent(n)))return;let o=a.timelineStart,d=a.duration,h=0;l.forEach((e,t)=>{let i=parseFloat(e.DURATION);this.createAsset(a,t,h,o+h,i,e.URI),h+=i}),a.duration=h,this.log(`Loaded asset-list with duration: ${h} (was: ${d}) ${a}`);let u=this.waitingItem,c=(null==u?void 0:u.event.identifier)===n;this.updateSchedule();let f=null==(s=this.bufferingItem)?void 0:s.event;if(c){let e=this.schedule.findEventIndex(n),t=null==(r=this.schedule.items)?void 0:r[e];if(t){if(!this.playingItem&&this.timelinePos>t.end&&this.schedule.findItemIndexAtTime(this.timelinePos)!==e){a.error=Error(`Interstitial ${l.length?"no longer within playback range":"asset-list is empty"} ${this.timelinePos} ${a}`),this.log(a.error.message),this.updateSchedule(!0),this.primaryFallback(a);return}this.setBufferingItem(t)}this.setSchedulePosition(e)}else if((null==f?void 0:f.identifier)===n){let e=a.assetList[0];if(e){let t=this.getAssetPlayer(e.identifier);if(f.appendInPlace){let e=this.primaryMedia;t&&e&&this.bufferAssetPlayer(t,e)}else t&&t.loadSource()}}}onError(e,t){if(this.schedule)switch(t.details){case cw.ASSET_LIST_PARSING_ERROR:case cw.ASSET_LIST_LOAD_ERROR:case cw.ASSET_LIST_LOAD_TIMEOUT:{let e=t.interstitial;e&&(this.updateSchedule(!0),this.primaryFallback(e));break}case cw.BUFFER_STALLED_ERROR:{let e=this.endedItem||this.waitingItem||this.playingItem;if(this.isInterstitial(e)&&e.event.appendInPlace)return void this.handleInPlaceStall(e.event);this.log(`Primary player stall @${this.timelinePos} bufferedPos: ${this.bufferedPos}`),this.onTimeupdate(),this.checkBuffer(!0)}}}}});class vN extends pp{constructor(e,t){super("gap-controller",e.logger),this.hls=void 0,this.fragmentTracker=void 0,this.media=null,this.mediaSource=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.buffered={},this.lastCurrentTime=0,this.ended=0,this.waiting=0,this.onMediaPlaying=()=>{this.ended=0,this.waiting=0},this.onMediaWaiting=()=>{var e;null!=(e=this.media)&&e.seeking||(this.waiting=self.performance.now(),this.tick())},this.onMediaEnded=()=>{if(this.hls){var e;this.ended=(null==(e=this.media)?void 0:e.currentTime)||1,this.hls.trigger(cA.MEDIA_ENDED,{stalled:!1})}},this.hls=e,this.fragmentTracker=t,this.registerListeners()}registerListeners(){let{hls:e}=this;
32e&&(e.on(cA.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(cA.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(cA.BUFFER_APPENDED,this.onBufferAppended,this))}unregisterListeners(){let{hls:e}=this;e&&(e.off(cA.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(cA.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(cA.BUFFER_APPENDED,this.onBufferAppended,this))}destroy(){super.destroy(),this.unregisterListeners(),this.media=this.hls=this.fragmentTracker=null,this.mediaSource=void 0}onMediaAttached(e,t){this.setInterval(100),this.mediaSource=t.mediaSource;let i=this.media=t.media;mE(i,"playing",this.onMediaPlaying),mE(i,"waiting",this.onMediaWaiting),mE(i,"ended",this.onMediaEnded)}onMediaDetaching(e,t){this.clearInterval();let{media:i}=this;i&&(mS(i,"playing",this.onMediaPlaying),mS(i,"waiting",this.onMediaWaiting),mS(i,"ended",this.onMediaEnded),this.media=null),this.mediaSource=void 0}onBufferAppended(e,t){this.buffered=t.timeRanges}get hasBuffered(){return Object.keys(this.buffered).length>0}tick(){var e;if(!(null!=(e=this.media)&&e.readyState)||!this.hasBuffered)return;let t=this.media.currentTime;this.poll(t,this.lastCurrentTime),this.lastCurrentTime=t}poll(e,t){var i,s,r;let a=null==(i=this.hls)?void 0:i.config;if(!a)return;let n=this.media;if(!n)return;let{seeking:l}=n,o=this.seeking&&!l,d=!this.seeking&&l,h=n.paused&&!l||n.ended||0===n.playbackRate;if(this.seeking=l,e!==t){t&&(this.ended=0),this.moved=!0,!l&&(this.nudgeRetry=0,a.nudgeOnVideoHole&&!h&&e>t&&this.nudgeOnVideoHole(e,t)),0===this.waiting&&this.stallResolved(e);return}if(d||o){o&&this.stallResolved(e);return}if(h){this.nudgeRetry=0,this.stallResolved(e),!this.ended&&n.ended&&this.hls&&(this.ended=e||1,this.hls.trigger(cA.MEDIA_ENDED,{stalled:!1}));return}if(!pv.getBuffered(n).length){this.nudgeRetry=0;return}let u=pv.bufferInfo(n,e,0),c=u.nextStart||0,f=this.fragmentTracker;if(l&&f&&this.hls){let t=vF(this.hls.inFlightFragments,e),i=u.len>2,s=!c||t||c-e>2&&!f.getPartialFragment(e);if(i||s)return;this.moved=!1}let p=null==(s=this.hls)?void 0:s.latestLevelDetails;if(!this.moved&&null!==this.stalled&&f){if(!(u.len>0)&&!c)return;let t=Math.max(c,u.start||0)-e,i=null!=p&&p.live?2*p.targetduration:2,s=vU(e,f);if(t>0&&(t<=i||s)){n.paused||this._trySkipBufferHole(s);return}}let m=a.detectStallWithCurrentTimeMs,g=self.performance.now(),y=this.waiting,v=this.stalled;if(null===v)if(y>0&&g-y<m)v=this.stalled=y;else{this.stalled=g;return}let b=g-v;if(!l&&(b>=m||y)&&this.hls){if((null==(r=this.mediaSource)?void 0:r.readyState)==="ended"&&!(null!=p&&p.live)&&1>Math.abs(e-((null==p?void 0:p.edge)||0))){if(this.ended)return;this.ended=e||1,this.hls.trigger(cA.MEDIA_ENDED,{stalled:!0});return}if(this._reportStall(u),!this.media||!this.hls)return}let E=pv.bufferInfo(n,e,a.maxBufferHole);this._tryFixBufferStall(E,b,e)}stallResolved(e){let t=this.stalled;if(t&&this.hls&&(this.stalled=null,this.stallReported)){let i=self.performance.now()-t;this.log(`playback not stuck anymore @${e}, after ${Math.round(i)}ms`),this.stallReported=!1,this.waiting=0,this.hls.trigger(cA.STALL_RESOLVED,{})}}nudgeOnVideoHole(e,t){var i;let s=this.buffered.video;if(this.hls&&this.media&&this.fragmentTracker&&null!=(i=this.buffered.audio)&&i.length&&s&&s.length>1&&e>s.end(0)){let i=pv.bufferedInfo(pv.timeRangesToArray(this.buffered.audio),e,0);if(i.len>1&&t>=i.start){let i=pv.timeRangesToArray(s),r=pv.bufferedInfo(i,t,0).bufferedIndex;if(r>-1&&r<i.length-1){let t=pv.bufferedInfo(i,e,0).bufferedIndex,s=i[r].end,a=i[r+1].start;if((-1===t||t>r)&&a-s<1&&e-s<2){let i=Error(`nudging playhead to flush pipeline after video hole. currentTime: ${e} hole: ${s} -> ${a} buffered index: ${t}`);this.warn(i.message),this.media.currentTime+=1e-6;let r=vU(e,this.fragmentTracker);r&&"fragment"in r?r=r.fragment:r||(r=void 0);let n=pv.bufferInfo(this.media,e,0);this.hls.trigger(cA.ERROR,{type:ck.MEDIA_ERROR,details:cw.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:i,reason:i.message,frag:r,buffer:n.len,bufferInfo:n})}}}}}_tryFixBufferStall(e,t,i){var s,r;let{fragmentTracker:a,media:n}=this,l=null==(s=this.hls)?void 0:s.config;if(!n||!a||!l)return;let o=null==(r=this.hls)?void 0:r.latestLevelDetails,d=vU(i,a);if((d||null!=o&&o.live&&i<o.fragmentStart)&&(this._trySkipBufferHole(d)||!this.media))return;let h=e.buffered,u=this.adjacentTraversal(e,i);(h&&h.length>1&&e.len>l.maxBufferHole||e.nextStart&&(e.nextStart-i<l.maxBufferHole||u))&&(t>1e3*l.highBufferWatchdogPeriod||this.waiting)&&(this.warn("Trying to nudge playhead over buffer-hole"),this._tryNudgeBuffer(e))}adjacentTraversal(e,t){let i=this.fragmentTracker,s=e.nextStart;if(i&&s){let e=i.getFragAtPos(t,cP),r=i.getFragAtPos(s,cP);if(e&&r)return r.sn-e.sn<2}return!1}_reportStall(e){let{hls:t,media:i,stallReported:s,stalled:r}=this;if(!s&&null!==r&&i&&t){this.stallReported=!0;let s=Error(`Playback stalling at @${i.currentTime} due to low buffer (${fj(e)})`);this.warn(s.message),t.trigger(cA.ERROR,{type:ck.MEDIA_ERROR,details:cw.BUFFER_STALLED_ERROR,fatal:!1,error:s,buffer:e.len,bufferInfo:e,stalled:{start:r}})}}_trySkipBufferHole(e){var t,i;let{fragmentTracker:s,media:r}=this,a=null==(t=this.hls)?void 0:t.config;if(!r||!s||!a)return 0;let n=r.currentTime,l=pv.bufferInfo(r,n,0),o=n<l.start?l.start:l.nextStart;if(o&&this.hls){let t=l.len<=a.maxBufferHole,d=l.len>0&&l.len<1&&r.readyState<3,h=o-n;if(h>0&&(t||d)){if(h>a.maxBufferHole){let t=!1;if(0===n){let e=s.getAppendedFrag(0,cP);e&&o<e.end&&(t=!0)}if(!t&&e){if(!(null!=(i=this.hls.loadLevelObj)&&i.details)||vF(this.hls.inFlightFragments,o))return 0;let t=!1,r=e.end;for(;r<o;){let e=vU(r,s);if(e)r+=e.duration;else{t=!0;break}}if(t)return 0}}let t=Math.max(o+.05,n+.1);if(this.warn(`skipping hole, adjusting currentTime from ${n} to ${t}`),this.moved=!0,r.currentTime=t,!(null!=e&&e.gap)){let i=Error(`fragment loaded with buffer holes, seeking from ${n} to ${t}`),s={type:ck.MEDIA_ERROR,details:cw.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:i,reason:i.message,buffer:l.len,bufferInfo:l};e&&("fragment"in e?s.part=e:s.frag=e),this.hls.trigger(cA.ERROR,s)}return t}}return 0}_tryNudgeBuffer(e){let{hls:t,media:i,nudgeRetry:s}=this,r=null==t?void 0:t.config;if(!i||!r)return 0;let a=i.currentTime;if(this.nudgeRetry++,s<r.nudgeMaxRetry){let n=a+(s+1)*r.nudgeOffset,l=Error(`Nudging 'currentTime' from ${a} to ${n}`);this.warn(l.message),i.currentTime=n,t.trigger(cA.ERROR,{type:ck.MEDIA_ERROR,details:cw.BUFFER_NUDGE_ON_STALL,error:l,fatal:!1,buffer:e.len,bufferInfo:e})}else{let i=Error(`Playhead still not moving while enough data buffered @${a} after ${r.nudgeMaxRetry} nudges`);this.error(i.message),t.trigger(cA.ERROR,{type:ck.MEDIA_ERROR,details:cw.BUFFER_STALLED_ERROR,error:i,fatal:!0,buffer:e.len,bufferInfo:e})}}}function vF(e,t){let i=vB(e.main);if(i&&i.start<=t)return i;let s=vB(e.audio);return s&&s.start<=t?s:null}function vB(e){if(!e)return null;switch(e.state){case mk:case mx:case mP:case mD:return null}return e.frag}function vU(e,t){return t.getAppendedFrag(e,cP)||t.getPartialFragment(e)}function vj(){if("u">typeof self)return self.VTTCue||self.TextTrackCue}function vV(e,t,i,s,r){let a=new e(t,i,"");try{a.value=s,r&&(a.type=r)}catch(n){a=new e(t,i,fj(r?cF({type:r},s):s))}return a}let vG=(()=>{let e=vj();try{e&&new e(0,1/0,"")}catch(e){return Number.MAX_VALUE}return 1/0})();class vq{constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.removeCues=!0,this.assetCue=void 0,this.onEventCueEnter=()=>{this.hls&&this.hls.trigger(cA.EVENT_CUE_ENTER,{})},this.hls=e,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=this.onEventCueEnter=null}_registerListeners(){let{hls:e}=this;
32e&&(e.on(cA.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(cA.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(cA.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(cA.MANIFEST_LOADING,this.onManifestLoading,this),e.on(cA.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(cA.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(cA.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(cA.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}_unregisterListeners(){let{hls:e}=this;e&&(e.off(cA.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(cA.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(cA.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(cA.MANIFEST_LOADING,this.onManifestLoading,this),e.off(cA.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(cA.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(cA.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(cA.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}onMediaAttaching(e,t){var i;this.media=t.media,(null==(i=t.overrides)?void 0:i.cueRemoval)===!1&&(this.removeCues=!1)}onMediaAttached(){var e;let t=null==(e=this.hls)?void 0:e.latestLevelDetails;t&&this.updateDateRangeCues(t)}onMediaDetaching(e,t){this.media=null,t.transferMedia||(this.id3Track&&(this.removeCues&&yD(this.id3Track,this.onEventCueEnter),this.id3Track=null),this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(e){let t=this.getID3Track(e.textTracks);return t.mode="hidden",t}getID3Track(e){if(this.media){for(let t=0;t<e.length;t++){let i=e[t];if("metadata"===i.kind&&"id3"===i.label)return yI(i,this.media),i}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(e,t){if(!this.media||!this.hls)return;let{enableEmsgMetadataCues:i,enableID3MetadataCues:s}=this.hls.config;if(!i&&!s)return;let{samples:r}=t;this.id3Track||(this.id3Track=this.createTrack(this.media));let a=vj();if(a)for(let e=0;e<r.length;e++){let t=r[e].type;if(t===m2.emsg&&!i||!s)continue;let n=mZ(r[e].data),l=r[e].pts,o=l+r[e].duration;o>vG&&(o=vG),o-l<=0&&(o=l+.25);for(let e=0;e<n.length;e++){let i=n[e];if(!m0(i)){this.updateId3CueEnds(l,t);let e=vV(a,l,o,i,t);e&&this.id3Track.addCue(e)}}}}updateId3CueEnds(e,t){var i;let s=null==(i=this.id3Track)?void 0:i.cues;if(s)for(let i=s.length;i--;){let r=s[i];r.type===t&&r.startTime<e&&r.endTime===vG&&(r.endTime=e)}}onBufferFlushing(e,{startOffset:t,endOffset:i,type:s}){let{id3Track:r,hls:a}=this;if(!a)return;let{config:{enableEmsgMetadataCues:n,enableID3MetadataCues:l}}=a;r&&(n||l)&&yM(r,t,i,"audio"===s?e=>e.type===m2.audioId3&&l:"video"===s?e=>e.type===m2.emsg&&n:e=>e.type===m2.audioId3&&l||e.type===m2.emsg&&n)}onLevelUpdated(e,{details:t}){this.updateDateRangeCues(t,!0)}onLevelPtsUpdated(e,t){Math.abs(t.drift)>.01&&this.updateDateRangeCues(t.details)}updateDateRangeCues(e,t){var i,s;if(!this.hls||!this.media)return;let{assetPlayerId:r,timelineOffset:a,enableDateRangeMetadataCues:n,interstitialsController:l}=this.hls.config;if(!n)return;let o=vj();if(r&&a&&!l){let{fragmentStart:t,fragmentEnd:i}=e,s=this.assetCue;s?(s.startTime=t,s.endTime=i):o&&(s=this.assetCue=vV(o,t,i,{assetPlayerId:this.hls.config.assetPlayerId},"hlsjs.interstitial.asset"))&&(s.id=r,this.id3Track||(this.id3Track=this.createTrack(this.media)),this.id3Track.addCue(s),s.addEventListener("enter",this.onEventCueEnter))}if(!e.hasProgramDateTime)return;let{id3Track:d}=this,{dateRanges:h}=e,u=Object.keys(h),c=this.dateRangeCuesAppended;if(d&&t)if(null!=(i=d.cues)&&i.length){let e=Object.keys(c).filter(e=>!u.includes(e));for(let t=e.length;t--;){let i=e[t],r=null==(s=c[i])?void 0:s.cues;delete c[i],r&&Object.keys(r).forEach(e=>{let t=r[e];if(t){t.removeEventListener("enter",this.onEventCueEnter);try{d.removeCue(t)}catch(e){}}})}}else c=this.dateRangeCuesAppended={};let f=e.fragments[e.fragments.length-1];if(0!==u.length&&cS(null==f?void 0:f.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(let e=0;e<u.length;e++){let t=u[e],i=h[t],s=i.startTime,r=c[t],a=(null==r?void 0:r.cues)||{},n=(null==r?void 0:r.durationKnown)||!1,d=vG,{duration:f,endDate:p}=i;if(p&&null!==f)d=s+f,n=!0;else if(i.endOnNext&&!n){let e=u.reduce((e,t)=>
32{if(t!==i.id){let s=h[t];if(s.class===i.class&&s.startDate>i.startDate&&(!e||i.startDate<e.startDate))return s}return e},null);e&&(d=e.startTime,n=!0)}let m=Object.keys(i.attr);for(let e=0;e<m.length;e++){let h=m[e];if("ID"===h||"CLASS"===h||"CUE"===h||"START-DATE"===h||"DURATION"===h||"END-DATE"===h||"END-ON-NEXT"===h)continue;let u=a[h];if(u)n&&!(null!=r&&r.durationKnown)?u.endTime=d:Math.abs(u.startTime-s)>.01&&(u.startTime=s,u.endTime=d);else if(o){let e=i.attr[h];("SCTE35-OUT"===h||"SCTE35-IN"===h||"SCTE35-CMD"===h)&&(e=cY(e));let r=vV(o,s,d,{key:h,data:e},m2.dateRange);r&&(r.id=t,this.id3Track.addCue(r),a[h]=r,l&&("X-ASSET-LIST"===h||"X-ASSET-URL"===h)&&r.addEventListener("enter",this.onEventCueEnter))}}c[t]={cues:a,dateRange:i,durationKnown:n}}}}}class vH{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.currentTime=0,this.stallCount=0,this._latency=null,this._targetLatencyUpdated=!1,this.onTimeupdate=()=>{let{media:e}=this,t=this.levelDetails;if(!e||!t)return;this.currentTime=e.currentTime;let i=this.computeLatency();if(null===i)return;this._latency=i;let{lowLatencyMode:s,maxLiveSyncPlaybackRate:r}=this.config;if(!s||1===r||!t.live)return;let a=this.targetLatency;if(null===a)return;let n=i-a;if(n<Math.min(this.maxLatency,a+t.targetduration)&&n>.05&&this.forwardBufferLength>1){let t=Math.min(Math.min(2,Math.max(1,r)),Math.max(1,Math.round(2/(1+Math.exp(-.75*n-this.edgeStalled))*20)/20));this.changeMediaPlaybackRate(e,t)}else 1!==e.playbackRate&&0!==e.playbackRate&&this.changeMediaPlaybackRate(e,1)},this.hls=e,this.config=e.config,this.registerListeners()}get levelDetails(){var e;return(null==(e=this.hls)?void 0:e.latestLevelDetails)||null}get latency(){return this._latency||0}get maxLatency(){let{config:e}=this;if(void 0!==e.liveMaxLatencyDuration)return e.liveMaxLatencyDuration;let t=this.levelDetails;return t?e.liveMaxLatencyDurationCount*t.targetduration:0}get targetLatency(){let e=this.levelDetails;if(null===e||null===this.hls)return null;let{holdBack:t,partHoldBack:i,targetduration:s}=e,{liveSyncDuration:r,liveSyncDurationCount:a,lowLatencyMode:n}=this.config,l=this.hls.userConfig,o=n&&i||t;return(this._targetLatencyUpdated||l.liveSyncDuration||l.liveSyncDurationCount||0===o)&&(o=void 0!==r?r:a*s),o+Math.min(this.stallCount*this.config.liveSyncOnStallIncrease,s)}set targetLatency(e){this.stallCount=0,this.config.liveSyncDuration=e,this._targetLatencyUpdated=!0}get liveSyncPosition(){let e=this.estimateLiveEdge(),t=this.targetLatency;if(null===e||null===t)return null;let i=this.levelDetails;if(null===i)return null;let s=i.edge,r=e-t-this.edgeStalled;return Math.min(Math.max(s-i.totalduration,r),s-(this.config.lowLatencyMode&&i.partTarget||i.targetduration))}get drift(){let e=this.levelDetails;return null===e?1:e.drift}get edgeStalled(){let e=this.levelDetails;if(null===e)return 0;let t=3*(this.config.lowLatencyMode&&e.partTarget||e.targetduration);return Math.max(e.age-t,0)}get forwardBufferLength(){let{media:e}=this,t=this.levelDetails;if(!e||!t)return 0;let i=e.buffered.length;return(i?e.buffered.end(i-1):t.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.hls=null}registerListeners(){let{hls:e}=this;
32e&&(e.on(cA.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(cA.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(cA.MANIFEST_LOADING,this.onManifestLoading,this),e.on(cA.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(cA.ERROR,this.onError,this))}unregisterListeners(){let{hls:e}=this;e&&(e.off(cA.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(cA.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(cA.MANIFEST_LOADING,this.onManifestLoading,this),e.off(cA.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(cA.ERROR,this.onError,this))}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.onTimeupdate)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.onTimeupdate),this.media=null)}onManifestLoading(){this._latency=null,this.stallCount=0}onLevelUpdated(e,{details:t}){t.advanced&&this.onTimeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.onTimeupdate)}onError(e,t){var i;t.details===cw.BUFFER_STALLED_ERROR&&(this.stallCount++,this.hls&&null!=(i=this.levelDetails)&&i.live&&this.hls.logger.warn("[latency-controller]: Stall detected, adjusting target latency"))}changeMediaPlaybackRate(e,t){var i,s;e.playbackRate!==t&&(null==(i=this.hls)||i.logger.debug(`[latency-controller]: latency=${this.latency.toFixed(3)}, targetLatency=${null==(s=this.targetLatency)?void 0:s.toFixed(3)}, forwardBufferLength=${this.forwardBufferLength.toFixed(3)}: adjusting playback rate from ${e.playbackRate} to ${t}`),e.playbackRate=t)}estimateLiveEdge(){let e=this.levelDetails;return null===e?null:e.edge+e.age}computeLatency(){let e=this.estimateLiveEdge();return null===e?null:e-this.currentTime}}class vK extends gV{constructor(e,t){super(e,"level-controller"),this._levels=[],this._firstLevel=-1,this._maxAutoLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=t,this._registerListeners()}_registerListeners(){let{hls:e}=this;e.on(cA.MANIFEST_LOADING,this.onManifestLoading,this),e.on(cA.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(cA.LEVEL_LOADED,this.onLevelLoaded,this),e.on(cA.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(cA.FRAG_BUFFERED,this.onFragBuffered,this),e.on(cA.ERROR,this.onError,this)}_unregisterListeners(){let{hls:e}=this;e.off(cA.MANIFEST_LOADING,this.onManifestLoading,this),e.off(cA.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(cA.LEVEL_LOADED,this.onLevelLoaded,this),e.off(cA.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(cA.FRAG_BUFFERED,this.onFragBuffered,this),e.off(cA.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}stopLoad(){this._levels.forEach(e=>{e.loadError=0,e.fragmentError=0}),super.stopLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1}onManifestLoading(e,t){this.resetLevels()}onManifestLoaded(e,t){let i=this.hls.config.preferManagedMediaSource,s=[],r={},a={},n=!1,l=!1,o=!1;t.levels.forEach(e=>{let t=e.attrs,{audioCodec:d,videoCodec:h}=e;d&&(e.audioCodec=d=fw(d,i)||void 0),h&&(h=e.videoCodec=function(e){let t=e.split(",");for(let e=0;e<t.length;e++){let i=t[e].split(".");i.length>2&&"avc1"===i[0]&&(t[e]=`avc1.${parseInt(i[1]).toString(16)}${("000"+parseInt(i[2]).toString(16)).slice(-4)}`)}return t.join(",")}(h));let{width:u,height:c,unknownCodecs:f}=e,p=(null==f?void 0:f.length)||0;if(n||(n=!!(u&&c)),l||(l=!!h),o||(o=!!d),p||d&&!this.isAudioSupported(d)||h&&!this.isVideoSupported(h))return void this.log(`Some or all CODECS not supported "${t.CODECS}"`);let{CODECS:m,"FRAME-RATE":g,"HDCP-LEVEL":y,"PATHWAY-ID":v,RESOLUTION:b,"VIDEO-RANGE":E}=t,S=`${v||"."}-`,T=`${S}${e.bitrate}-${b}-${g}-${m}-${E}-${y}`;if(r[T])if(r[T].uri===e.url||e.attrs["PATHWAY-ID"])r[T].addGroupId("audio",t.AUDIO),r[T].addGroupId("text",t.SUBTITLES);else{let t=a[T]+=1;e.attrs["PATHWAY-ID"]=Array(t+1).join(".");let i=this.createLevel(e);r[T]=i,s.push(i)}else{let t=this.createLevel(e);r[T]=t,a[T]=1,s.push(t)}}),this.filterAndSortMediaOptions(s,t,n,l,o)}createLevel(e){let t=new fB(e),i=e.supplemental;if(null!=i&&i.videoCodec&&!this.isVideoSupported(i.videoCodec)){let e=Error(`SUPPLEMENTAL-CODECS not supported "${i.videoCodec}"`);this.log(e.message),t.supportedResult=fD(e,[])}return t}isAudioSupported(e){return fv(e,"audio",this.hls.config.preferManagedMediaSource)}isVideoSupported(e){return fv(e,"video",this.hls.config.preferManagedMediaSource)}filterAndSortMediaOptions(e,t,i,s,r){var a,n;let l=[],o=[],d=e,h=(null==(a=t.stats)?void 0:a.parsing)||{};if((i||s)&&r&&(d=d.filter(({videoCodec:e,videoRange:t,width:i,height:s})=>{var r;return(!!e||!!(i&&s))&&!!(r=t)&&fO.indexOf(r)>-1})),0===d.length){Promise.resolve().then(()=>
32{if(this.hls){let e="no level with compatible codecs found in manifest",i=e;t.levels.length&&(i=`one or more CODECS in variant not supported: ${fj(t.levels.map(e=>e.attrs.CODECS).filter((e,t,i)=>i.indexOf(e)===t))}`,this.warn(i),e+=` (${i})`);let s=Error(e);this.hls.trigger(cA.ERROR,{type:ck.MEDIA_ERROR,details:cw.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:s,reason:i})}}),h.end=performance.now();return}t.audioTracks&&vW(l=t.audioTracks.filter(e=>!e.audioCodec||this.isAudioSupported(e.audioCodec))),t.subtitles&&vW(o=t.subtitles);let u=d.slice(0);d.sort((e,t)=>{if(e.attrs["HDCP-LEVEL"]!==t.attrs["HDCP-LEVEL"])return(e.attrs["HDCP-LEVEL"]||"")>(t.attrs["HDCP-LEVEL"]||"")?1:-1;if(i&&e.height!==t.height)return e.height-t.height;if(e.frameRate!==t.frameRate)return e.frameRate-t.frameRate;if(e.videoRange!==t.videoRange)return fO.indexOf(e.videoRange)-fO.indexOf(t.videoRange);if(e.videoCodec!==t.videoCodec){let i=fS(e.videoCodec),s=fS(t.videoCodec);if(i!==s)return s-i}if(e.uri===t.uri&&e.codecSet!==t.codecSet){let i=fT(e.codecSet),s=fT(t.codecSet);if(i!==s)return s-i}return e.averageBitrate!==t.averageBitrate?e.averageBitrate-t.averageBitrate:0});let c=u[0];if(this.steering&&(d=this.steering.filterParsedLevels(d)).length!==u.length){for(let e=0;e<u.length;e++)if(u[e].pathwayId===d[0].pathwayId){c=u[e];break}}this._levels=d;for(let e=0;e<d.length;e++)if(d[e]===c){this._firstLevel=e;let t=c.bitrate,i=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${d.length} level(s) found, first bitrate: ${t}`),(null==(n=this.hls.userConfig)?void 0:n.abrEwmaDefaultEstimate)===void 0){let e=Math.min(t,this.hls.config.abrEwmaDefaultEstimateMax);e>i&&i===this.hls.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=e)}break}let f=r&&!s,p=this.hls.config,m=!!(p.audioStreamController&&p.audioTrackController),g={levels:d,audioTracks:l,subtitleTracks:o,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:r,video:s,altAudio:m&&!f&&l.some(e=>!!e.url)};h.end=performance.now(),this.hls.trigger(cA.MANIFEST_PARSED,g)}get levels(){return 0===this._levels.length?null:this._levels}get loadLevelObj(){return this.currentLevel}get level(){return this.currentLevelIndex}set level(e){let t=this._levels;if(0===t.length)return;if(e<0||e>=t.length){let i=Error("invalid level idx"),s=e<0;if(this.hls.trigger(cA.ERROR,{type:ck.OTHER_ERROR,details:cw.LEVEL_SWITCH_ERROR,level:e,fatal:s,error:i,reason:i.message}),s)return;e=Math.min(e,t.length-1)}let i=this.currentLevelIndex,s=this.currentLevel,r=s?s.attrs["PATHWAY-ID"]:void 0,a=t[e],n=a.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=a,i===e&&s&&r===n)return;this.log(`Switching to level ${e} (${a.height?a.height+"p ":""}${a.videoRange?a.videoRange+" ":""}${a.codecSet?a.codecSet+" ":""}@${a.bitrate})${n?" with Pathway "+n:""} from level ${i}${r?" with Pathway "+r:""}`);let l={level:e,attrs:a.attrs,details:a.details,bitrate:a.bitrate,averageBitrate:a.averageBitrate,maxBitrate:a.maxBitrate,realBitrate:a.realBitrate,width:a.width,height:a.height,codecSet:a.codecSet,audioCodec:a.audioCodec,videoCodec:a.videoCodec,audioGroups:a.audioGroups,subtitleGroups:a.subtitleGroups,loaded:a.loaded,loadError:a.loadError,fragmentError:a.fragmentError,name:a.name,id:a.id,uri:a.uri,url:a.url,urlId:0,audioGroupIds:a.audioGroupIds,textGroupIds:a.textGroupIds};this.hls.trigger(cA.LEVEL_SWITCHING,l);let o=a.details;if(!o||o.live){let e=this.switchParams(a.uri,null==s?void 0:s.details,o);this.loadPlaylist(e)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(e){this.manualLevelIndex=e,void 0===this._startLevel&&(this._startLevel=e),-1!==e&&(this.level=e)}get firstLevel(){return this._firstLevel}set firstLevel(e){this._firstLevel=e}get startLevel(){if(void 0===this._startLevel){let e=this.hls.config.startLevel;return void 0!==e?e:this.hls.firstAutoLevel}return this._startLevel}set startLevel(e){this._startLevel=e}get pathways(){return this.steering?this.steering.pathways():[]}get pathwayPriority(){return this.steering?this.steering.pathwayPriority:null}set pathwayPriority(e){if(this.steering){let t=this.steering.pathways(),i=e.filter(e=>-1!==t.indexOf(e));if(e.length<1)return void this.warn(`pathwayPriority ${e} should contain at least one pathway from list: ${t}`);this.steering.pathwayPriority=i}}onError(e,t){!t.fatal&&t.context&&t.context.type===cL&&t.context.level===this.level&&this.checkRetry(t)}onFragBuffered(e,{frag:t}){if(void 0!==t&&t.type===cP){let e=t.elementaryStreams;if(!Object.keys(e).some(t=>!!e[t]))return;let i=this._levels[t.level];null!=i&&i.loadError&&(this.log(`Resetting level error count of ${i.loadError} on frag buffered`),i.loadError=0)}}onLevelLoaded(e,t){var i,s;let{level:r,details:a}=t,n=t.levelInfo;if(!n){this.warn(`Invalid level index ${r}`),null!=(s=t.deliveryDirectives)&&s.skip&&(a.deltaUpdateFailed=!0);return}if(n===this.currentLevel||t.withoutMultiVariant){0===n.fragmentError&&(n.loadError=0);let e=n.details;e===t.details&&e.advanced&&(e=void 0),this.playlistLoaded(r,t,e)}else null!=(i=t.deliveryDirectives)&&i.skip&&(a.deltaUpdateFailed=!0)}loadPlaylist(e){super.loadPlaylist(),this.shouldLoadPlaylist(this.currentLevel)&&this.scheduleLo
32ading(this.currentLevel,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);let i=this.getUrlWithDirectives(e.uri,t),s=this.currentLevelIndex,r=e.attrs["PATHWAY-ID"],a=e.details,n=null==a?void 0:a.age;this.log(`Loading level index ${s}${(null==t?void 0:t.msn)!==void 0?" at sn "+t.msn+" part "+t.part:""}${r?" Pathway "+r:""}${n&&a.live?" age "+n.toFixed(1)+(a.type?" "+a.type:""):""} ${i}`),this.hls.trigger(cA.LEVEL_LOADING,{url:i,level:s,levelInfo:e,pathwayId:e.attrs["PATHWAY-ID"],id:0,deliveryDirectives:t||null})}get nextLoadLevel(){return -1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(e){this.level=e,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=e)}removeLevel(e){var t;if(1===this._levels.length)return;let i=this._levels.filter((t,i)=>i!==e||(this.steering&&this.steering.removeLevel(t),t===this.currentLevel&&(this.currentLevel=null,this.currentLevelIndex=-1,t.details&&t.details.fragments.forEach(e=>e.level=-1)),!1));mf(i),this._levels=i,this.currentLevelIndex>-1&&null!=(t=this.currentLevel)&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.manualLevelIndex>-1&&(this.manualLevelIndex=this.currentLevelIndex);let s=i.length-1;this._firstLevel=Math.min(this._firstLevel,s),this._startLevel&&(this._startLevel=Math.min(this._startLevel,s)),this.hls.trigger(cA.LEVELS_UPDATED,{levels:i})}onLevelsUpdated(e,{levels:t}){this._levels=t}checkMaxAutoUpdated(){let{autoLevelCapping:e,maxAutoLevel:t,maxHdcpLevel:i}=this.hls;this._maxAutoLevel!==t&&(this._maxAutoLevel=t,this.hls.trigger(cA.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:e,levels:this.levels,maxAutoLevel:t,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:i}))}}function vW(e){let t={};e.forEach(e=>{let i=e.groupId||"";e.id=t[i]=t[i]||0,t[i]++})}function vz(){return self.SourceBuffer||self.WebKitSourceBuffer}function vY(){if(!cH())return!1;let e=vz();return!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove}class vQ extends m${constructor(e,t,i){super(e,t,i,"stream-controller",cP),this.audioCodecSwap=!1,this.level=-1,this._forceStartLoad=!1,this._hasEnoughToStart=!1,this.altAudio=0,this.audioOnly=!1,this.fragPlaying=null,this.fragLastKbps=0,this.couldBacktrack=!1,this.backtrackFragment=null,this.audioCodecSwitch=!1,this.videoBuffer=null,this.onMediaPlaying=()=>{this.tick()},this.onMediaSeeked=()=>{let e=this.media,t=e?e.currentTime:null;if(null===t||!cS(t)||(this.log(`Media seeked to ${t.toFixed(3)}`),!this.getBufferedFrag(t)))return;let i=this.getFwdBufferInfoAtPos(e,t,cP,0);null===i||0===i.len?this.warn(`Main forward buffer length at ${t} on "seeked" event ${i?i.len:"empty"})`):this.tick()},this.registerListeners()}registerListeners(){super.registerListeners();let{hls:e}=this;e.on(cA.MANIFEST_PARSED,this.onManifestParsed,this),e.on(cA.LEVEL_LOADING,this.onLevelLoading,this),e.on(cA.LEVEL_LOADED,this.onLevelLoaded,this),e.on(cA.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(cA.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(cA.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(cA.BUFFER_CREATED,this.onBufferCreated,this),e.on(cA.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(cA.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(cA.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){super.unregisterListeners();let{hls:e}=this;e.off(cA.MANIFEST_PARSED,this.onManifestParsed,this),e.off(cA.LEVEL_LOADED,this.onLevelLoaded,this),e.off(cA.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(cA.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(cA.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(cA.BUFFER_CREATED,this.onBufferCreated,this),e.off(cA.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(cA.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(cA.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this.onMediaPlaying=this.onMediaSeeked=null,this.unregisterListeners(),super.onHandlerDestroying()}startLoad(e,t){if(this.levels){let{lastCurrentTime:i,hls:s}=this;if(this.stopLoad(),this.setInterval(100),this.level=-1,!this.startFragRequested){let e=s.startLevel;-1===e&&(s.config.testBandwidth&&this.levels.length>1?(e=0,this.bitrateTest=!0):e=s.firstAutoLevel),s.nextLoadLevel=e,this.level=s.loadLevel,this._hasEnoughToStart=!!t}i>0&&-1===e&&!t&&(this.log(`Override startPosition with lastCurrentTime @${i.toFixed(3)}`),e=i),this.state=mk,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}else this._forceStartLoad=!0,this.state=mx}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case m_:{let{levels:e,level:t}=this,i=null==e?void 0:e[t],s=null==i?void 0:i.details;if(!s||s.live&&(this.levelLastLoaded!==i||this.waitForLive(i)))this.hls.nextLoadLevel!==this.level&&(this.state=mk);else{if(this.waitForCdnTuneIn(s))break;this.state=mk}break}case mR:this.checkRetryDate()}this.state===mk&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){var e;super.onTickEnd(),null!=(e=this.media)&&e.readyState&&!1===this.media.seeking&&(this.lastCurrentTime=this.media.currentTime),this.checkFragmentChanged()}doTickIdle(){let{hls:e,levelLastLoaded:t,levels:i,media:s}=this;if(null===t||!s&&!this.primaryPrefetch&&(this.startFragRequested||!e.config.startFragPrefetch)||this.altAudio&&this.audioOnly)return;
32let r=this.buffering?e.nextLoadLevel:e.loadLevel;if(!(null!=i&&i[r]))return;let a=i[r],n=this.getMainFwdBufferInfo();if(null===n)return;let l=this.getLevelDetails();if(l&&this._streamEnded(n,l)){let e={};2===this.altAudio&&(e.type="video"),this.hls.trigger(cA.BUFFER_EOS,e),this.state=mP;return}if(!this.buffering)return;e.loadLevel!==r&&-1===e.manualLevel&&this.log(`Adapting to level ${r} from level ${this.level}`),this.level=e.nextLoadLevel=r;let o=a.details;if(!o||this.state===m_||this.waitForLive(a)){this.level=r,this.state=m_,this.startFragRequested=!1;return}let d=n.len,h=this.getMaxBufferLength(a.maxBitrate);if(d>=h)return;this.backtrackFragment&&this.backtrackFragment.start>n.end&&(this.backtrackFragment=null);let u=this.backtrackFragment?this.backtrackFragment.start:n.end,c=this.getNextFragment(u,o);if(this.couldBacktrack&&!this.fragPrevious&&c&&c5(c)&&"OK"!==this.fragmentTracker.getState(c)){var f;let e=(null!=(f=this.backtrackFragment)?f:c).sn-o.startSN,t=o.fragments[e-1];t&&c.cc===t.cc&&(c=t,this.fragmentTracker.removeFragment(t))}else this.backtrackFragment&&n.len&&(this.backtrackFragment=null);if(c&&this.isLoopLoading(c,u)){if(!c.gap){let e=this.audioOnly&&!this.altAudio?cZ:c0,t=(e===c0?this.videoBuffer:this.mediaBuffer)||this.media;t&&this.afterBufferFlushed(t,e,cP)}c=this.getNextFragmentLoopLoading(c,o,n,cP,h)}!c||this.exceedsMaxBuffer(n,h,c)||(!c.initSegment||c.initSegment.data||this.bitrateTest||(c=c.initSegment),this.loadFragment(c,a,u))}loadFragment(e,t,i){let s=this.fragmentTracker.getState(e);s===f9||s===pt?c5(e)?this.bitrateTest?(this.log(`Fragment ${e.sn} of level ${e.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(e,t)):super.loadFragment(e,t,i):this._loadInitSegment(e,t):this.clearTrackerIfNeeded(e)}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,cP)}followingBufferedFrag(e){return e?this.getBufferedFrag(e.end+.5):null}immediateLevelSwitch(){if(this.abortCurrentFrag(),this.flushMainBuffer(0,1/0),0!==this.altAudio){var e;((null==(e=this.getLevelDetails())?void 0:e.fragmentStart)||0)>this.lastCurrentTime&&super.flushMainBuffer(0,1/0,"audio")}}nextLevelSwitch(){let{levels:e,media:t}=this;if(null!=t&&t.readyState){let i,s=this.getAppendedFrag(t.currentTime);s&&s.start>1&&this.flushMainBuffer(0,s.start-1);let r=this.getLevelDetails();if(null!=r&&r.live){let e=this.getMainFwdBufferInfo();if(!e||e.len<2*r.targetduration)return}if(!t.paused&&e){let t=e[this.hls.nextLoadLevel],s=this.fragLastKbps;i=s&&this.fragCurrent?this.fragCurrent.duration*t.maxBitrate/(1e3*s)+1:0}else i=0;let a=this.getBufferedFrag(t.currentTime+i);if(a){let e=this.followingBufferedFrag(a);if(e){this.abortCurrentFrag();let t=e.maxStartPTS?e.maxStartPTS:e.start,i=e.duration,s=Math.max(a.end,t+Math.min(Math.max(i-this.config.maxFragLookUpTolerance,i*(this.couldBacktrack?.5:.125)),i*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(s,1/0)}}}}abortCurrentFrag(){let e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case mw:case mA:case mR:case mC:case mI:this.state=mk}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(e,t){super.flushMainBuffer(e,t,2===this.altAudio?"video":null)}onMediaAttached(e,t){super.onMediaAttached(e,t);let i=t.media;mE(i,"playing",this.onMediaPlaying),mE(i,"seeked",this.onMediaSeeked)}onMediaDetaching(e,t){let{media:i}=this;i&&(mS(i,"playing",this.onMediaPlaying),mS(i,"seeked",this.onMediaSeeked)),this.videoBuffer=null,this.fragPlaying=null,super.onMediaDetaching(e,t),t.transferMedia||(this._hasEnoughToStart=!1)}onManifestLoading(){super.onManifestLoading(),this.log("Trigger BUFFER_RESET"),this.hls.trigger(cA.BUFFER_RESET,void 0),this.couldBacktrack=!1,this.fragLastKbps=0,this.fragPlaying=this.backtrackFragment=null,this.altAudio=0,this.audioOnly=!1}onManifestParsed(e,t){var i;let s,r=!1,a=!1;for(let e=0;e<t.levels.length;e++){let i=t.levels[e].audioCodec;i&&(r=r||-1!==i.indexOf("mp4a.40.2"),a=a||-1!==i.indexOf("mp4a.40.5"))}this.audioCodecSwitch=r&&a&&"function"!=typeof(null==(s=vz())||null==(i=s.prototype)?void 0:i.changeType),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1}onLevelLoading(e,t){let{levels:i}=this;if(!i||this.state!==mk)return;let s=t.levelInfo;(!s.details||s.details.live&&(this.levelLastLoaded!==s||s.details.expired)||this.waitForCdnTuneIn(s.details))&&(this.state=m_)}onLevelLoaded(e,t){var i,s;let{levels:r,startFragRequested:a}=this,n=t.level,l=t.details,o=l.totalduration;if(!r)return void this.warn(`Levels were reset while loading level ${n}`);this.log(`Level ${n} loaded [${l.startSN},${l.endSN}]${l.lastPartSn?`[part-${l.lastPartSn}-${l.lastPartIndex}]`:""}, cc [${l.startCC}, ${l.endCC}] duration:${o}`);let d=t.levelInfo,h=this.fragCurrent;h&&(this.state===mA||this.state===mR)&&h.level!==t.level&&h.loader&&this.abortCurrentFrag();let u=0;if(l.live||null!=(i=d.details)&&i.live){if(this.checkLiveUpdate(l),l.deltaUpdateFailed)return;u=this.alignPlaylists(l,d.details,null==(s=this.levelLastLoaded)?void 0:s.details)}if(d.details=l,this.levelLastLoaded=d,a||this.setStartPosition(l,u),this.hls.trigger(cA.LEVEL_UPDATED,{details:l,level:n}),this.state===m_){if(this.waitForCdnTuneIn(l))return;this.state=mk}a&&l.live&&this.synchronizeToLiveEdge(l),this.tick()}
32synchronizeToLiveEdge(e){let{config:t,media:i}=this;if(!i)return;let s=this.hls.liveSyncPosition,r=this.getLoadPosition(),a=e.fragmentStart,n=e.edge,l=r>=a-t.maxFragLookUpTolerance&&r<=n;if(null!==s&&i.duration>s&&(r<s||!l)){let a=void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;if((!l&&i.readyState<4||r<n-a)&&(this._hasEnoughToStart||(this.nextLoadPosition=s),i.readyState))if(this.warn(`Playback: ${r.toFixed(3)} is located too far from the end of live sliding playlist: ${n}, reset currentTime to : ${s.toFixed(3)}`),"buffered"===this.config.liveSyncMode){var o;let e=pv.bufferInfo(i,s,0);if(!(null!=(o=e.buffered)&&o.length)||e.start<=r){i.currentTime=s;return}let{nextStart:t}=pv.bufferedInfo(e.buffered,r,0);t&&(i.currentTime=t)}else i.currentTime=s}}_handleFragmentLoadProgress(e){var t;let i=e.frag,{part:s,payload:r}=e,{levels:a}=this;if(!a)return void this.warn(`Levels were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`);let n=a[i.level];if(!n)return void this.warn(`Level ${i.level} not found on progress`);let l=n.details;if(!l){this.warn(`Dropping fragment ${i.sn} of level ${i.level} after level details were reset`),this.fragmentTracker.removeFragment(i);return}let o=n.videoCodec,d=l.PTSKnown||!l.live,h=null==(t=i.initSegment)?void 0:t.data,u=this._getAudioCodec(n),c=this.transmuxer=this.transmuxer||new gj(this.hls,cP,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),f=s?s.index:-1,p=new pm(i.level,i.sn,i.stats.chunkCount,r.byteLength,f,-1!==f),m=this.initPTS[i.cc];c.push(r,h,u,o,i,s,l.totalduration,d,p,m)}onAudioTrackSwitching(e,t){let i=this.hls,s=0!==this.altAudio;if(fY(t.url,i))this.altAudio=1;else{if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;let e=this.fragCurrent;e&&(this.log("Switching to main audio track, cancel main fragment load"),e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();if(s){this.altAudio=0,this.fragmentTracker.removeAllFragments(),i.once(cA.BUFFER_FLUSHED,()=>{this.hls&&this.hls.trigger(cA.AUDIO_TRACK_SWITCHED,t)}),i.trigger(cA.BUFFER_FLUSHING,{startOffset:0,endOffset:1/0,type:null});return}i.trigger(cA.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){let i=fY(t.url,this.hls);if(i){let e=this.videoBuffer;e&&this.mediaBuffer!==e&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=e)}this.altAudio=2*!!i,this.tick()}onBufferCreated(e,t){let i,s,r=t.tracks,a=!1;for(let e in r){let t=r[e];if("main"===t.id){if(s=e,i=t,"video"===e){let t=r[e];t&&(this.videoBuffer=t.buffer)}}else a=!0}a&&i?(this.log(`Alternate track found, use ${s}.buffered to schedule main fragment loading`),this.mediaBuffer=i.buffer):this.mediaBuffer=this.media}onFragBuffered(e,t){let{frag:i,part:s}=t,r=i.type===cP;if(r){if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${s?" p: "+s.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}`),this.state===mI&&(this.state=mk);return}let e=s?s.stats:i.stats;this.fragLastKbps=Math.round(8*e.total/(e.buffering.end-e.loading.first)),c5(i)&&(this.fragPrevious=i),this.fragBufferedComplete(i,s)}let a=this.media;a&&(!this._hasEnoughToStart&&pv.getBuffered(a).length&&(this._hasEnoughToStart=!0,this.seekToStartPos()),r&&this.tick())}get hasEnoughToStart(){return this._hasEnoughToStart}onError(e,t){var i;if(t.fatal){this.state=mD;return}switch(t.details){case cw.FRAG_GAP:case cw.FRAG_PARSING_ERROR:case cw.FRAG_DECRYPT_ERROR:case cw.FRAG_LOAD_ERROR:case cw.FRAG_LOAD_TIMEOUT:case cw.KEY_LOAD_ERROR:case cw.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(cP,t);break;case cw.LEVEL_LOAD_ERROR:case cw.LEVEL_LOAD_TIMEOUT:case cw.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==m_||(null==(i=t.context)?void 0:i.type)!==cL||(this.state=mk);break;case cw.BUFFER_ADD_CODEC_ERROR:case cw.BUFFER_APPEND_ERROR:if("main"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)&&this.resetLoadingState();break;case cw.BUFFER_FULL_ERROR:if("main"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)&&(!this.config.interstitialsController&&this.config.assetPlayerId?this._hasEnoughToStart=!0:this.flushMainBuffer(0,1/0));break;
32case cw.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}onFragLoadEmergencyAborted(){this.state=mk,this._hasEnoughToStart||(this.startFragRequested=!1,this.nextLoadPosition=this.lastCurrentTime),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==cZ||!this.altAudio){let e=(t===c0?this.videoBuffer:this.mediaBuffer)||this.media;e&&(this.afterBufferFlushed(e,t,cP),this.tick())}}onLevelsUpdated(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level,-1===this.level&&this.resetWhenMissingContext(this.fragCurrent)),this.levels=t.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){let{media:e}=this;if(!e)return;let t=e.currentTime,i=this.startPosition;if(i>=0&&t<i){if(e.seeking)return void this.log(`could not seek to ${i}, already seeking at ${t}`);let s=this.timelineOffset;s&&i&&(i+=s);let r=this.getLevelDetails(),a=pv.getBuffered(e),n=a.length?a.start(0):0,l=n-i,o=Math.max(this.config.maxBufferHole,this.config.maxFragLookUpTolerance);(this.config.startOnSegmentBoundary||l>0&&(l<o||this.loadingParts&&l<2*((null==r?void 0:r.partTarget)||0)))&&(this.log(`adjusting start position by ${l} to match buffer start`),i+=l,this.startPosition=i),t<i&&(this.log(`seek to target start position ${i} from current time ${t} buffer start ${n}`),e.currentTime=i)}}_getAudioCodec(e){let t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t=-1!==t.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),t}_loadBitrateTestFrag(e,t){e.bitrateTest=!0,this._doFragLoad(e,t).then(e=>{let{hls:i}=this,s=null==e?void 0:e.frag;if(!s||this.fragContextChanged(s))return;t.fragmentError=0,this.state=mk,this.startFragRequested=!1,this.bitrateTest=!1;let r=s.stats;r.parsing.start=r.parsing.end=r.buffering.start=r.buffering.end=self.performance.now(),i.trigger(cA.FRAG_LOADED,e),s.bitrateTest=!1}).catch(t=>{this.state!==mx&&this.state!==mD&&(this.warn(t),this.resetFragmentLoading(e))})}_handleTransmuxComplete(e){let t=this.playlistType,{hls:i}=this,{remuxResult:s,chunkMeta:r}=e,a=this.getCurrentContext(r);if(!a)return void this.resetWhenMissingContext(r);let{frag:n,part:l,level:o}=a,{video:d,text:h,id3:u,initSegment:c}=s,{details:f}=o,p=this.altAudio?void 0:s.audio;if(this.fragContextChanged(n))return void this.fragmentTracker.removeFragment(n);if(this.state=mC,c){let e=c.tracks;if(e){let s=n.initSegment||n;if(this.unhandledEncryptionError(c,n))return;this._bufferInitSegment(o,e,s,r),i.trigger(cA.FRAG_PARSING_INIT_SEGMENT,{frag:s,id:t,tracks:e})}let s=c.initPTS,a=c.timescale,l=this.initPTS[n.cc];if(cS(s)&&(!l||l.baseTime!==s||l.timescale!==a)){let e=c.trackId;this.initPTS[n.cc]={baseTime:s,timescale:a,trackId:e},i.trigger(cA.INIT_PTS_FOUND,{frag:n,id:t,initPTS:s,timescale:a,trackId:e})}}if(d&&f){p&&"audiovideo"===d.type&&this.logMuxedErr(n);let e=f.fragments[n.sn-1-f.startSN],t=n.sn===f.startSN,i=!e||n.cc>e.cc;if(!1!==s.independent){let{startPTS:e,endPTS:s,startDTS:a,endDTS:o}=d;if(l)l.elementaryStreams[d.type]={startPTS:e,endPTS:s,startDTS:a,endDTS:o};else if(d.firstKeyFrame&&d.independent&&1===r.id&&!i&&(this.couldBacktrack=!0),d.dropped&&d.independent){let r=this.getMainFwdBufferInfo(),a=(r?r.end:this.getLoadPosition())+this.config.maxBufferHole,l=d.firstKeyFramePTS?d.firstKeyFramePTS:e;if(!t&&a<l-this.config.maxBufferHole&&!i)return void this.backtrack(n);i&&(n.gap=!0),n.setElementaryStreamInfo(d.type,n.start,s,n.start,o,!0)}else t&&e-(f.appliedTimelineOffset||0)>2&&(n.gap=!0);n.setElementaryStreamInfo(d.type,e,s,a,o),this.backtrackFragment&&(this.backtrackFragment=n),this.bufferFragmentData(d,n,l,r,t||i)}else{if(!t&&!i)return void this.backtrack(n);n.gap=!0}}if(p){let{startPTS:e,endPTS:t,startDTS:i,endDTS:s}=p;l&&(l.elementaryStreams[cZ]={startPTS:e,endPTS:t,startDTS:i,endDTS:s}),n.setElementaryStreamInfo(cZ,e,t,i,s),this.bufferFragmentData(p,n,l,r)}if(f&&null!=u&&u.samples.length){let e={id:t,frag:n,details:f,samples:u.samples};i.trigger(cA.FRAG_PARSING_METADATA,e)}if(f&&h){let e={id:t,frag:n,details:f,samples:h.samples};i.trigger(cA.FRAG_PARSING_USERDATA,e)}}logMuxedErr(e){this.warn(`${c5(e)?"Media":"Init"} segment with muxed audiovideo where only video expected: ${e.url}`)}_bufferInitSegment(e,t,i,s){if(this.state!==mC)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&(delete t.audio,t.audiovideo&&this.logMuxedErr(i));let{audio:r,video:a,audiovideo:n}=t;if(r){let i=e.audioCodec,s=fA(r.codec,i);"mp4a"===s&&(s="mp4a.40.5");let a=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){s&&(s=-1!==s.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5");let e=r.metadata;e&&"channelCount"in e&&1!==(e.channelCount||1)&&-1===a.indexOf("firefox")&&(s="mp4a.40.5")}s&&-1!==s.indexOf("mp4a.40.5")&&-1!==a.indexOf("android")&&"audio/mpeg"!==r.container&&(s="mp4a.40.2",this.log(`Android: force audio codec to ${s}`)),i&&i!==s&&this.log(`Swapping manifest audio codec "${i}" for "${s}"`),r.levelCodec=s,r.id=cP,this.log(`Init audio buffer, container:${r.container}, codecs[selected/level/parsed]=[${s||""}/${i||""}/${r.codec}]`),delete t.audiovideo}if(a){a.levelCodec=e.videoCodec,a.id=cP;let i=a.codec;if((null==i?void 0:i.length)===4)switch(i){case"hvc1":case"hev1":a.codec="hvc1.1.6.L120.90";break;case"av01":a.codec="av01.0.04M.08";break;case"avc1":a.codec="avc1.42e01e"}this.log(`Init video buffer, container:${a.container}, codecs[level/parsed]=[${e.videoCodec||""}/${i}]${a.codec!==i?" parsed-corrected="+a.codec:""}${a.supplemental?" supplemental="+a.supplemental:""}`),delete t.audiovideo}n&&(this.log(`Init audiovideo buffer, container:${n.container}, codecs[level/parsed]=[${e.codecs}/${n.codec}]`),delete t.video,delete t.audio);let l=Object.keys(t);if(l.length){if(this.hls.trigger(cA.BUFFER_CODECS,t),!this.hls)return;
32l.forEach(e=>{let r=t[e].initSegment;null!=r&&r.byteLength&&this.hls.trigger(cA.BUFFER_APPENDING,{type:e,data:r,frag:i,part:null,chunkMeta:s,parent:i.type})})}this.tickImmediate()}getMainFwdBufferInfo(){let e=this.mediaBuffer&&2===this.altAudio?this.mediaBuffer:this.media;return this.getFwdBufferInfo(e,cP)}get maxBufferLength(){let{levels:e,level:t}=this,i=null==e?void 0:e[t];return i?this.getMaxBufferLength(i.maxBitrate):this.config.maxBufferLength}backtrack(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=mk}checkFragmentChanged(){let e=this.media,t=null;if(e&&e.readyState>1&&!1===e.seeking){let i=e.currentTime;if(pv.isBuffered(e,i)?t=this.getAppendedFrag(i):pv.isBuffered(e,i+.1)&&(t=this.getAppendedFrag(i+.1)),t){this.backtrackFragment=null;let e=this.fragPlaying,i=t.level;(!e||t.sn!==e.sn||e.level!==i)&&(this.fragPlaying=t,this.hls.trigger(cA.FRAG_CHANGED,{frag:t}),e&&e.level===i||this.hls.trigger(cA.LEVEL_SWITCHED,{level:i}))}}}get nextLevel(){let e=this.nextBufferedFrag;return e?e.level:-1}get currentFrag(){var e;if(this.fragPlaying)return this.fragPlaying;let t=(null==(e=this.media)?void 0:e.currentTime)||this.lastCurrentTime;return cS(t)?this.getAppendedFrag(t):null}get currentProgramDateTime(){var e;let t=(null==(e=this.media)?void 0:e.currentTime)||this.lastCurrentTime;if(cS(t)){let e=this.getLevelDetails(),i=this.currentFrag||(e?fX(null,e.fragments,t):null);if(i){let e=i.programDateTime;if(null!==e)return new Date(e+(t-i.start)*1e3)}}return null}get currentLevel(){let e=this.currentFrag;return e?e.level:-1}get nextBufferedFrag(){let e=this.currentFrag;return e?this.followingBufferedFrag(e):null}get forceStartLoad(){return this._forceStartLoad}}class vX extends cB{constructor(e,t){super("key-loader",t),this.config=void 0,this.keyIdToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(let i in this.keyIdToKeyInfo){let s=this.keyIdToKeyInfo[i].loader;if(s){var t;if(e&&e!==(null==(t=s.context)?void 0:t.frag.type))return;s.abort()}}}detach(){for(let e in this.keyIdToKeyInfo){let t=this.keyIdToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyIdToKeyInfo[e]}}destroy(){for(let e in this.detach(),this.keyIdToKeyInfo){let t=this.keyIdToKeyInfo[e].loader;t&&t.destroy()}this.keyIdToKeyInfo={}}createKeyLoadError(e,t=cw.KEY_LOAD_ERROR,i,s,r){return new pf({type:ck.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:r,error:i,networkDetails:s})}loadClear(e,t,i){if(this.emeController&&this.config.emeEnabled&&!this.emeController.getSelectedKeySystemFormats().length){if(t.length)for(let s=0,r=t.length;s<r;s++){let a=t[s];if(e.cc<=a.cc&&(!c5(e)||!c5(a)||e.sn<a.sn)||!i&&s==r-1)return this.emeController.selectKeySystemFormat(a).then(e=>{if(!this.emeController)return;a.setKeyFormat(e);let t=pq(e);if(t)return this.emeController.getKeySystemAccess([t])})}if(this.config.requireKeySystemAccessOnStart){let e=pK(this.config);if(e.length)return this.emeController.getKeySystemAccess(e)}}return null}load(e){return!e.decryptdata&&e.encrypted&&this.emeController&&this.config.emeEnabled?this.emeController.selectKeySystemFormat(e).then(t=>this.loadInternal(e,t)):this.loadInternal(e)}loadInternal(e,t){var i,s;t&&e.setKeyFormat(t);let r=e.decryptdata;if(!r){let i=Error(t?`Expected frag.decryptdata to be defined after setting format ${t}`:`Missing decryption data on fragment in onKeyLoading (emeEnabled with controller: ${this.emeController&&this.config.emeEnabled})`);return Promise.reject(this.createKeyLoadError(e,cw.KEY_LOAD_ERROR,i))}let a=r.uri;if(!a)return Promise.reject(this.createKeyLoadError(e,cw.KEY_LOAD_ERROR,Error(`Invalid key URI: "${a}"`)));let n=vJ(r),l=this.keyIdToKeyInfo[n];if(null!=(i=l)&&i.decryptdata.key)return r.key=l.decryptdata.key,Promise.resolve({frag:e,keyInfo:l});if(this.emeController&&null!=(s=l)&&s.keyLoadPromise)switch(this.emeController.getKeyStatus(l.decryptdata)){case"usable":case"usable-in-future":return l.keyLoadPromise.then(t=>{let{keyInfo:i}=t;return r.key=i.decryptdata.key,{frag:e,keyInfo:i}})}switch(this.log(`${this.keyIdToKeyInfo[n]?"Rel":"L"}
32oading${r.keyId?" keyId: "+cz(r.keyId):""} URI: ${r.uri} from ${e.type} ${e.level}`),l=this.keyIdToKeyInfo[n]={decryptdata:r,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},r.method){case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":if("identity"===r.keyFormat)return this.loadKeyHTTP(l,e);return this.loadKeyEME(l,e);case"AES-128":case"AES-256":case"AES-256-CTR":return this.loadKeyHTTP(l,e);default:return Promise.reject(this.createKeyLoadError(e,cw.KEY_LOAD_ERROR,Error(`Key supplied with unsupported METHOD: "${r.method}"`)))}}loadKeyEME(e,t){let i={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){var s,r;if(!e.decryptdata.keyId&&null!=(s=t.initSegment)&&s.data){let i,s=(r=t.initSegment.data,i=[],fd(r,e=>i.push(e.subarray(8,24))),i);if(s.length){let t=s[0];t.some(e=>0!==e)?(this.log(`Using keyId found in init segment ${cz(t)}`),pQ.setKeyIdForUri(e.decryptdata.uri,t)):(t=pQ.addKeyIdForUri(e.decryptdata.uri),this.log(`Generating keyId to patch media ${cz(t)}`)),e.decryptdata.keyId=t}}return e.decryptdata.keyId||c5(t)?(e.keyLoadPromise=this.emeController.loadKey(i).then(t=>(e.mediaKeySessionContext=t,i))).catch(i=>{throw e.keyLoadPromise=null,"data"in i&&(i.data.frag=t),i}):Promise.resolve(i)}return Promise.resolve(i)}loadKeyHTTP(e,t){let i=this.config,s=new i.loader(i);return t.keyLoader=e.loader=s,e.keyLoadPromise=new Promise((r,a)=>{let n={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},l=i.keyLoadPolicy.default,o={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0};s.load(n,o,{onSuccess:(e,t,i,s)=>{let{frag:n,keyInfo:l}=i,o=vJ(l.decryptdata);if(!n.decryptdata||l!==this.keyIdToKeyInfo[o])return a(this.createKeyLoadError(n,cw.KEY_LOAD_ERROR,Error("after key load, decryptdata unset or changed"),s));l.decryptdata.key=n.decryptdata.key=new Uint8Array(e.data),n.keyLoader=null,l.loader=null,r({frag:n,keyInfo:l})},onError:(e,i,s,r)=>{this.resetLoader(i),a(this.createKeyLoadError(t,cw.KEY_LOAD_ERROR,Error(`HTTP Error ${e.code} loading key ${e.text}`),s,cF({url:n.url,data:void 0},e)))},onTimeout:(e,i,s)=>{this.resetLoader(i),a(this.createKeyLoadError(t,cw.KEY_LOAD_TIMEOUT,Error("key loading timed out"),s))},onAbort:(e,i,s)=>{this.resetLoader(i),a(this.createKeyLoadError(t,cw.INTERNAL_ABORTED,Error("key loading aborted"),s))}})})}resetLoader(e){let{frag:t,keyInfo:i,url:s}=e,r=i.loader;t.keyLoader===r&&(t.keyLoader=null,i.loader=null);let a=vJ(i.decryptdata)||s;delete this.keyIdToKeyInfo[a],r&&r.destroy()}}function vJ(e){if(e.keyFormat!==pj){let t=e.keyId;if(t)return cz(t)}return e.uri}function vZ(e){let{type:t}=e;switch(t){case cC:return cD;case cI:return cM;default:return cP}}function v0(e,t){let i=e.url;return(void 0===i||0===i.indexOf("data:"))&&(i=t.url),i}class v1{constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.onManifestLoaded=this.checkAutostartLoad,this.hls=e,this.registerListeners()}startLoad(e){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){let{hls:e}=this;e.on(cA.MANIFEST_LOADING,this.onManifestLoading,this),e.on(cA.LEVEL_LOADING,this.onLevelLoading,this),e.on(cA.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(cA.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.on(cA.LEVELS_UPDATED,this.onLevelsUpdated,this)}unregisterListeners(){let{hls:e}=this;e.off(cA.MANIFEST_LOADING,this.onManifestLoading,this),e.off(cA.LEVEL_LOADING,this.onLevelLoading,this),e.off(cA.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(cA.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.off(cA.LEVELS_UPDATED,this.onLevelsUpdated,this)}createInternalLoader(e){let t=this.hls.config,i=t.pLoader,s=t.loader,r=new(i||s)(t);return this.loaders[e.type]=r,r}getInternalLoader(e){return this.loaders[e.type]}resetInternalLoader(e){this.loaders[e]&&delete this.loaders[e]}destroyInternalLoaders(){for(let e in this.loaders){let t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(e,t){let{url:i}=t;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:cR,url:i,deliveryDirectives:null,levelOrTrack:null})}onLevelLoading(e,t){let{id:i,level:s,pathwayId:r,url:a,deliveryDirectives:n,levelInfo:l}=t;this.load({id:i,level:s,pathwayId:r,responseType:"text",type:cL,url:a,deliveryDirectives:n,levelOrTrack:l})}onAudioTrackLoading(e,t){let{id:i,groupId:s,url:r,deliveryDirectives:a,track:n}=t;this.load({id:i,groupId:s,level:null,responseType:"text",type:cC,url:r,deliveryDirectives:a,levelOrTrack:n})}onSubtitleTrackLoading(e,t){let{id:i,groupId:s,url:r,deliveryDirectives:a,track:n}=t;this.load({id:i,groupId:s,level:null,responseType:"text",type:cI,url:r,deliveryDirectives:a,levelOrTrack:n})}onLevelsUpdated(e,t){let i=this.loaders[cL];if(i){let e=i.context;e&&!t.levels.some(t=>t===e.levelOrTrack)&&(i.abort(),delete this.loaders[cL])}}load(e){var t;let i,s=this.hls.config,r=this.getInternalLoader(e);if(r){let t=this.hls.logger,i=r.context;if(i&&i.levelOrTrack===e.levelOrTrack&&(i.url===e.url||i.deliveryDirectives&&!e.deliveryDirectives))return void(i.url===e.url?t.log(`[playlist-loader]: ignore ${e.url} ongoing request`):t.log(`[playlist-loader]: ignore ${e.url} in favor of ${i.url}`));t.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),r.abort()}if(i=e.type===cR?s.manifestLoadPolicy.default:cO({},s.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),r=this.createInternalLoader(e),cS(null==(t=e.deliveryDirectives)?void 0:t.part)){let t;if(e.type===cL&&null!==e.level?t=this.hls.levels[e.level].details:e.type===cC&&null!==e.id?t=this.hls.audioTracks[e.id].details:e.type===cI&&null!==e.id&&(t=this.hls.subtitleTracks[e.id].details),t){let e=t.partTarget,s=t.targetduration;if(e&&s){let t=1e3*Math.max(3*e,.8*s);i=cO({},i,{maxTimeToFirstByteMs:Math.min(t,i.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(t,i.maxTimeToFirstByteMs)})}}}let a=i.errorRetry||i.timeoutRetry||{},n={loadPolicy:i,timeout:i.maxLoadTimeMs,maxRetry:a.maxNumRetry||0,retryDelay:a.retryDelayMs||0,maxRetryDelay:a.maxRetryDelayMs||0};r.load(e,n,{onSuccess:(e,t,i,s)=>{let r=this.getInternalLoader(i);this.resetInternalLoader(i.type);let a=e.data;t.parsing.start=performance.now(),p5.isMediaPlaylist(a)||i.type!==cR?this.handleTrackOrLevelPlaylist(e,t,i,s||null,r):this.handleMasterPlaylist(e,t,i,s)},onError:(e,t,i,s)=>{this.handleNetworkError(t,i,!1,e,s)},onTimeout:(e,t,i)=>{this.handleNetworkError(t,i,!0,void 0,e)}})}
32checkAutostartLoad(){if(!this.hls)return;let{config:{autoStartLoad:e,startPosition:t},forceStartLoad:i}=this.hls;(e||i)&&(this.hls.logger.log(`${e?"auto":"force"} startLoad with configured startPosition ${t}`),this.hls.startLoad(t))}handleMasterPlaylist(e,t,i,s){let r=this.hls,a=e.data,n=v0(e,i),l=p5.parseMasterPlaylist(a,n);if(l.playlistParsingError){t.parsing.end=performance.now(),this.handleManifestParsingError(e,i,l.playlistParsingError,s,t);return}let{contentSteering:o,levels:d,sessionData:h,sessionKeys:u,startTimeOffset:c,variableList:f}=l;this.variableList=f,d.forEach(e=>{let{unknownCodecs:t}=e;if(t){let{preferManagedMediaSource:i}=this.hls.config,{audioCodec:s,videoCodec:r}=e;for(let a=t.length;a--;){let n=t[a];fv(n,"audio",i)?(e.audioCodec=s=s?`${s},${n}`:n,fg.audio[s.substring(0,4)]=2,t.splice(a,1)):fv(n,"video",i)&&(e.videoCodec=r=r?`${r},${n}`:n,fg.video[r.substring(0,4)]=2,t.splice(a,1))}}});let{AUDIO:p=[],SUBTITLES:m,"CLOSED-CAPTIONS":g}=p5.parseMasterPlaylistMedia(a,n,l);p.length&&(p.some(e=>!e.url)||!d[0].audioCodec||d[0].attrs.AUDIO||(this.hls.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),p.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new pk({}),bitrate:0,url:""}))),r.trigger(cA.MANIFEST_LOADED,{levels:d,audioTracks:p,subtitles:m,captions:g,contentSteering:o,url:n,stats:t,networkDetails:s,sessionData:h,sessionKeys:u,startTimeOffset:c,variableList:f})}handleTrackOrLevelPlaylist(e,t,i,s,r){let a=this.hls,{id:n,level:l,type:o}=i,d=v0(e,i),h=cS(l)?l:cS(n)?n:0,u=vZ(i),c=p5.parseLevelPlaylist(e.data,d,h,u,0,this.variableList);if(o===cR){let e={attrs:new pk({}),bitrate:0,details:c,name:"",url:d};c.requestScheduled=t.loading.start+md(c,0),a.trigger(cA.MANIFEST_LOADED,{levels:[e],audioTracks:[],url:d,stats:t,networkDetails:s,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),i.levelDetails=c,this.handlePlaylistLoaded(c,e,t,i,s,r)}handleManifestParsingError(e,t,i,s,r){this.hls.trigger(cA.ERROR,{type:ck.NETWORK_ERROR,details:cw.MANIFEST_PARSING_ERROR,fatal:t.type===cR,url:e.url,err:i,error:i,reason:i.message,response:e,context:t,networkDetails:s,stats:r})}handleNetworkError(e,t,i=!1,s,r){let a=`A network ${i?"timeout":"error"+(s?" (status "+s.code+")":"")} occurred while loading ${e.type}`;e.type===cL?a+=`: ${e.level} id: ${e.id}`:(e.type===cC||e.type===cI)&&(a+=` id: ${e.id} group-id: "${e.groupId}"`);let n=Error(a);this.hls.logger.warn(`[playlist-loader]: ${a}`);let l=cw.UNKNOWN,o=!1,d=this.getInternalLoader(e);switch(e.type){case cR:l=i?cw.MANIFEST_LOAD_TIMEOUT:cw.MANIFEST_LOAD_ERROR,o=!0;break;case cL:l=i?cw.LEVEL_LOAD_TIMEOUT:cw.LEVEL_LOAD_ERROR,o=!1;break;case cC:l=i?cw.AUDIO_TRACK_LOAD_TIMEOUT:cw.AUDIO_TRACK_LOAD_ERROR,o=!1;break;case cI:l=i?cw.SUBTITLE_TRACK_LOAD_TIMEOUT:cw.SUBTITLE_LOAD_ERROR,o=!1}d&&this.resetInternalLoader(e.type);let h={type:ck.NETWORK_ERROR,details:l,fatal:o,url:e.url,loader:d,context:e,error:n,networkDetails:t,stats:r};s&&(h.response=cF({url:(null==t?void 0:t.url)||e.url,data:void 0},s)),this.hls.trigger(cA.ERROR,h)}handlePlaylistLoaded(e,t,i,s,r,a){let n=this.hls,{type:l,level:o,levelOrTrack:d,id:h,groupId:u,deliveryDirectives:c}=s,f=v0(t,s),p=vZ(s),m="number"==typeof s.level&&p===cP?o:void 0,g=e.playlistParsingError;if(g){if(this.hls.logger.warn(`${g} ${e.url}`),!n.config.ignorePlaylistParsingErrors)return void n.trigger(cA.ERROR,{type:ck.NETWORK_ERROR,details:cw.LEVEL_PARSING_ERROR,fatal:!1,url:f,error:g,reason:g.message,response:t,context:s,level:m,parent:p,networkDetails:r,stats:i});e.playlistParsingError=null}if(!e.fragments.length){let a=e.playlistParsingError=Error("No Segments found in Playlist");n.trigger(cA.ERROR,{type:ck.NETWORK_ERROR,details:cw.LEVEL_EMPTY_ERROR,fatal:!1,url:f,error:a,reason:a.message,response:t,context:s,level:m,parent:p,networkDetails:r,stats:i});return}switch(e.live&&a&&(a.getCacheAge&&(e.ageHeader=a.getCacheAge()||0),(!a.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),l){case cR:case cL:if(m)if(d){if(d!==n.levels[m]){let e=n.levels.indexOf(d);e>-1&&(m=e)}}else m=0;n.trigger(cA.LEVEL_LOADED,{details:e,levelInfo:d||n.levels[0],level:m||0,id:h||0,stats:i,networkDetails:r,deliveryDirectives:c,withoutMultiVariant:l===cR});break;case cC:n.trigger(cA.AUDIO_TRACK_LOADED,{details:e,track:d,id:h||0,groupId:u||"",stats:i,networkDetails:r,deliveryDirectives:c});break;case cI:n.trigger(cA.SUBTITLE_TRACK_LOADED,{details:e,track:d,id:h||0,groupId:u||"",stats:i,networkDetails:r,deliveryDirectives:c})}}}class v2{static get version(){return mU}static isMSESupported(){return vY()}static isSupported(){if(!vY())return!1;let e=cH();
32return"function"==typeof(null==e?void 0:e.isTypeSupported)&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(t=>e.isTypeSupported(fE(t,"video")))||["mp4a.40.2","fLaC"].some(t=>e.isTypeSupported(fE(t,"audio"))))}static getMediaSource(){return cH()}static get Events(){return cA}static get MetadataSchema(){return m2}static get ErrorTypes(){return ck}static get ErrorDetails(){return cw}static get DefaultConfig(){return v2.defaultConfig?v2.defaultConfig:vO}static set DefaultConfig(e){v2.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.logger=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new mB,this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioStreamController=void 0,this.subtititleStreamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.interstitialsController=void 0,this.gapController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this._url=null,this._sessionId=void 0,this.triggeringException=void 0,this.started=!1;const t=this.logger=function(e,t,i){let s=cV();if("object"==typeof console&&!0===e||"object"==typeof e){let r=["debug","log","info","warn","error"];r.forEach(t=>{s[t]=cG(t,e,i)});try{s.log(`Debug logs enabled for "${t}" in hls.js version 1.6.16`)}catch(e){return cV()}r.forEach(t=>{cq[t]=cG(t,e)})}else cO(cq,s);return s}(e.debug||!1,"Hls instance",e.assetPlayerId),i=this.config=function(e,t,i){if((t.liveSyncDurationCount||t.liveMaxLatencyDurationCount)&&(t.liveSyncDuration||t.liveMaxLatencyDuration))throw Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==t.liveMaxLatencyDurationCount&&(void 0===t.liveSyncDurationCount||t.liveMaxLatencyDurationCount<=t.liveSyncDurationCount))throw Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==t.liveMaxLatencyDuration&&(void 0===t.liveSyncDuration||t.liveMaxLatencyDuration<=t.liveSyncDuration))throw Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');let s=function e(t){return t&&"object"==typeof t?Array.isArray(t)?t.map(e):Object.keys(t).reduce((i,s)=>(i[s]=e(t[s]),i),{}):t}(e),r=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach(e=>{let a=`${"level"===e?"playlist":e}LoadPolicy`,n=void 0===t[a],l=[];r.forEach(i=>{let r=`${e}Loading${i}`,o=t[r];if(void 0!==o&&n){l.push(r);let e=s[a].default;switch(t[a]={default:e},i){case"TimeOut":e.maxLoadTimeMs=o,e.maxTimeToFirstByteMs=o;break;case"MaxRetry":e.errorRetry.maxNumRetry=o,e.timeoutRetry.maxNumRetry=o;break;case"RetryDelay":e.errorRetry.retryDelayMs=o,e.timeoutRetry.retryDelayMs=o;break;case"MaxRetryTimeout":e.errorRetry.maxRetryDelayMs=o,e.timeoutRetry.maxRetryDelayMs=o}}}),l.length&&i.warn(`hls.js config: "${l.join('", "')}" setting(s) are deprecated, use "${a}": ${fj(t[a])}`)}),cF(cF({},s),t)}(v2.DefaultConfig,e,t);this.userConfig=e,i.progressive&&function(e,t){let i=e.loader;i!==vP&&i!==v$?(t.log("[config]: Custom loader detected, cannot enable progressive streaming"),e.progressive=!1):function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(e){}return!1}()&&(e.loader=vP,e.progressive=!0,e.enableSoftwareAES=!0,t.log("[config]: Progressive streaming enabled, using FetchLoader"))}(i,t);const{abrController:s,bufferController:r,capLevelController:a,errorController:n,fpsController:l}=i,o=new n(this),d=this.abrController=new s(this),h=new pi(this),u=i.interstitialsController,c=u?this.interstitialsController=new u(this,v2):null,f=this.bufferController=new r(this,h),p=this.capLevelController=new a(this),m=new l(this),g=new v1(this),y=i.contentSteeringController,v=y?new y(this):null,b=this.levelController=new vK(this,v),E=new vq(this),S=new vX(this.config,this.logger),T=this.streamController=new vQ(this,h,S),x=this.gapController=new vN(this,h);p.setStreamController(T),m.setStreamController(T);const k=[g,b,T];c&&k.splice(1,0,c),v&&k.splice(1,0,v),this.networkControllers=k;const w=[d,f,x,p,m,E,h];this.audioTrackController=this.createController(i.audioTrackController,k);const A=i.audioStreamController;A&&k.push(this.audioStreamController=new A(this,h,S)),this.subtitleTrackController=this.createController(i.subtitleTrackController,k);const R=i.subtitleStreamController;R&&k.push(this.subtititleStreamController=new R(this,h,S)),this.createController(i.timelineController,w),S.emeController=this.emeController=this.createController(i.emeController,w),this.cmcdController=this.createController(i.cmcdController,w),this.latencyController=this.createController(vH,w),this.coreComponents=w,k.push(o);const L=o.onErrorOut;"function"==typeof L&&this.on(cA.ERROR,L,o),this.on(cA.MANIFEST_LOADED,g.onManifestLoaded,g)}createController(e,t){if(e){let i=new e(this);return t&&t.push(i),i}return null}on(e,t,i=this){this._emitter.on(e,t,i)}once(e,t,i=this){this._emitter.once(e,t,i)}removeAllListeners(e){this._emitter.removeAllListeners(e)}off(e,t,i=this,s){this._emitter.off(e,t,i,s)}listeners(e){return this._emitter.listeners(e)}emit(e,t,i){return this._emitter.emit(e,t,i)}
vendor: 1,254 bytes, line 32
32trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(t){if(this.logger.error("An internal error happened while handling event "+e+'. Error message: "'+t.message+'". Here is a stacktrace:',t),!this.triggeringException){this.triggeringException=!0;let i=e===cA.ERROR;this.trigger(cA.ERROR,{type:ck.OTHER_ERROR,details:cw.INTERNAL_EXCEPTION,fatal:i,event:e,error:t}),this.triggeringException=!1}}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){this.logger.log("destroy"),this.trigger(cA.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this._url=null,this.networkControllers.forEach(e=>e.destroy()),this.networkControllers.length=0,this.coreComponents.forEach(e=>e.destroy()),this.coreComponents.length=0;let e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null}attachMedia(e){if(!e||"media"in e&&!e.media){let t=Error(`attachMedia failed: invalid argument (${e})`);this.trigger(cA.ERROR,{type:ck.OTHER_ERROR,details:cw.ATTACH_MEDIA_ERROR,fatal:!0,error:t});return}this.logger.log("attachMedia"),this._media&&(this.logger.warn("media must be detached before attaching"),this.detachMedia());let t="media"in e,i=t?e.media:e,s=t?e:{media:i};
32this._media=i,this.trigger(cA.MEDIA_ATTACHING,s)}detachMedia(){this.logger.log("detachMedia"),this.trigger(cA.MEDIA_DETACHING,{}),this._media=null}transferMedia(){this._media=null;let e=this.bufferController.transferMedia();return this.trigger(cA.MEDIA_DETACHING,{transferMedia:e}),e}loadSource(e){this.stopLoad();let t=this.media,i=this._url,s=this._url=cX.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.logger.log(`loadSource:${s}`),t&&i&&(i!==s||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(cA.MANIFEST_LOADING,{url:e})}get url(){return this._url}get hasEnoughToStart(){return this.streamController.hasEnoughToStart}get startPosition(){return this.streamController.startPositionValue}startLoad(e=-1,t){this.logger.log(`startLoad(${e+(t?", <skip seek to start>":"")})`),this.started=!0,this.resumeBuffering();for(let i=0;i<this.networkControllers.length&&(this.networkControllers[i].startLoad(e,t),this.started&&this.networkControllers);i++);}stopLoad(){this.logger.log("stopLoad"),this.started=!1;for(let e=0;e<this.networkControllers.length&&(this.networkControllers[e].stopLoad(),!this.started&&this.networkControllers);e++);}get loadingEnabled(){return this.started}get bufferingEnabled(){return this.streamController.bufferingEnabled}resumeBuffering(){this.bufferingEnabled||(this.logger.log("resume buffering"),this.networkControllers.forEach(e=>{e.resumeBuffering&&e.resumeBuffering()}))}pauseBuffering(){this.bufferingEnabled&&(this.logger.log("pause buffering"),this.networkControllers.forEach(e=>{e.pauseBuffering&&e.pauseBuffering()}))}get inFlightFragments(){let e={[cP]:this.streamController.inFlightFrag};return this.audioStreamController&&(e[cD]=this.audioStreamController.inFlightFrag),this.subtititleStreamController&&(e[cM]=this.subtititleStreamController.inFlightFrag),e}swapAudioCodec(){this.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){this.logger.log("recoverMediaError");let e=this._media,t=null==e?void 0:e.currentTime;this.detachMedia(),e&&(this.attachMedia(e),t&&this.startLoad(t))}removeLevel(e){this.levelController.removeLevel(e)}get sessionId(){let e=this._sessionId;return e||(e=this._sessionId=function(){try{return crypto.randomUUID()}catch(e){try{let e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}catch(t){let e=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{let i=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"==t?i:3&i|8).toString(16)})}}}()),e}get levels(){return this.levelController.levels||[]}get latestLevelDetails(){return this.streamController.getLevelDetails()||null}get loadLevelObj(){return this.levelController.loadLevelObj}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){this.logger.log(`set currentLevel:${e}`),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){this.logger.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(e){this.logger.log(`set loadLevel:${e}`),this.levelController.manualLevel=e}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(e){this.levelController.nextLoadLevel=e}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(e){this.logger.log(`set firstLevel:${e}`),this.levelController.firstLevel=e}get startLevel(){let e=this.levelController.startLevel;return -1===e&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e}set startLevel(e){this.logger.log(`set startLevel:${e}`),-1!==e&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(e){let t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){let{bwEstimator:e}=this.abrController;return e?e.getEstimate():NaN}set bandwidthEstimate(e){this.abrController.resetEstimator(e)}get abrEwmaDefaultEstimate(){let{bwEstimator:e}=this.abrController;return e?e.defaultEstimate:NaN}get ttfbEstimate(){let{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(this.logger.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){f$.indexOf(e)>-1&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}get autoLevelEnabled(){return -1===this.levelController.manualLevel}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){let{levels:e,config:{minAutoBitrate:t}}=this;if(!e)return 0;let i=e.length;for(let s=0;s<i;s++)if(e[s].maxBitrate>=t)return s;return 0}get maxAutoLevel(){let e,{levels:t,autoLevelCapping:i,maxHdcpLevel:s}=this;if(e=-1===i&&null!=t&&t.length?t.length-1:i,s)for(let i=e;i--;){let e=t[i].attrs["HDCP-LEVEL"];if(e&&e<=s)return i}return e}get firstAutoLevel(){return this.abrController.firstAutoLevel}get nextAutoLevel(){return this.abrController.nextAutoLevel}set nextAutoLevel(e){this.abrController.nextAutoLevel=e}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}get maxBufferLength(){return this.streamController.maxBufferLength}setAudioOption(e){var t;return(null==(t=this.audioTrackController)?void 0:t.setAudioOption(e))||null}
32setSubtitleOption(e){var t;return(null==(t=this.subtitleTrackController)?void 0:t.setSubtitleOption(e))||null}get allAudioTracks(){let e=this.audioTrackController;return e?e.allAudioTracks:[]}get audioTracks(){let e=this.audioTrackController;return e?e.audioTracks:[]}get audioTrack(){let e=this.audioTrackController;return e?e.audioTrack:-1}set audioTrack(e){let t=this.audioTrackController;t&&(t.audioTrack=e)}get allSubtitleTracks(){let e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}get subtitleTracks(){let e=this.subtitleTrackController;return e?e.subtitleTracks:[]}get subtitleTrack(){let e=this.subtitleTrackController;return e?e.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(e){let t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}get subtitleDisplay(){let e=this.subtitleTrackController;return!!e&&e.subtitleDisplay}set subtitleDisplay(e){let t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(e){this.config.lowLatencyMode=e}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}set targetLatency(e){this.latencyController.targetLatency=e}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}get pathways(){return this.levelController.pathways}get pathwayPriority(){return this.levelController.pathwayPriority}set pathwayPriority(e){this.levelController.pathwayPriority=e}get bufferedToEnd(){var e;return!!(null!=(e=this.bufferController)&&e.bufferedToEnd)}get interstitialsManager(){var e;return(null==(e=this.interstitialsController)?void 0:e.interstitialsManager)||null}getMediaDecodingInfo(e,t=this.allAudioTracks){return fM(e,fG(t),navigator.mediaCapabilities)}}v2.defaultConfig=void 0;let v5={Announcements:"Anúncios",Accessibility:"Acessibilidade",AirPlay:"AirPlay",Audio:"Áudio",Auto:"Automático",Boost:"Aumentar",Captions:"Legendas","Caption Styles":"Estilo das legendas","Captions look like this":"As legendas ficam assim",Chapters:"Capítulos","Closed-Captions Off":"Legendas desativadas","Closed-Captions On":"Legendas ativadas",Connected:"Conectado",Continue:"Continuar",Connecting:"Conectando",Default:"Padrão",Disabled:"Desativado",Disconnected:"Desconectado","Display Background":"Fundo da exibição",Download:"Baixar","Enter Fullscreen":"Entrar em tela cheia","Enter PiP":"Ativar PiP","Exit Fullscreen":"Sair da tela cheia","Exit PiP":"Sair do PiP",Font:"Fonte",Family:"Família",Fullscreen:"Tela cheia","Google Cast":"Google Cast","Keyboard Animations":"Animações de teclado",LIVE:"AO VIVO",Loop:"Repetir",Mute:"Silenciar",Normal:"Normal",Off:"Desativado",Pause:"Pausar",Play:"Reproduzir",Playback:"Reprodução",PiP:"PiP",Quality:"Qualidade",Replay:"Reproduzir novamente",Reset:"Redefinir","Seek Backward":"Voltar","Seek Forward":"Avançar",Seek:"Buscar",Settings:"Configurações","Skip To Live":"Ir para o ao vivo",Speed:"Velocidade",Size:"Tamanho",Color:"Cor",Opacity:"Opacidade",Shadow:"Sombra",Text:"Texto","Text Background":"Fundo do texto",Track:"Faixa",Unmute:"Ativar som",Volume:"Volume"},v3=e=>{let t=Math.max(0,e),i=Math.floor(t/3600),s=Math.floor(t%3600/60),r=(t%60).toFixed(3).padStart(6,"0");return`${String(i).padStart(2,"0")}:${String(s).padStart(2,"0")}:${r}`},v4=({width:e})=>e<480,v8=e=>{var t,i;let s,{videoId:r,apiBaseUrl:a,title:n,poster:l,authToken:o,clientId:d,autoplay:h,muted:u,loop:c,controls:f,showCaptions:p,showSettings:m,showSpeedMenu:g,showQualityMenu:y,showAccessibilityMenu:v,showAudioMenu:b,showCaptionsMenu:E,showPip:S,showChapters:k,showFullscreen:w,captionSource:A,chapters:R,embeddedDefaultLang:L,onTimeUpdate:C,onDurationChange:I,onPosterResolved:P,onEmbeddedTracksChange:D,seekRef:M}=e,[_,$]=(0,x.useState)(null),[O,N]=(0,x.useState)("loading"),[F,B]=(0,x.useState)(0),[U,j]=(0,x.useState)("16/9"),[V,G]=(0,x.useState)(null),q=(0,x.useRef)(null),H=()=>{let e;N("loading"),fetch(`${a.replace(/\/$/,"")}/videofy_api/playback`,{method:"POST",headers:(e={"Content-Type":"application/json"},o&&(e.Authorization=`Bearer ${o}`),d&&(e.clientid=d),e),body:JSON.stringify({videoId:Number(r)})}).then(e=>e.json()).then(e=>{if(!e?.success||!e?.data?.playbackUrl)throw Error(e?.error??e?.msg??"Playback indisponível");let t=e.data;$(t),t.posterUrl&&P?.(t.posterUrl),N("ready")}
32).catch(e=>{N("error")})},K=(0,x.useRef)(!1);(0,x.useEffect)(()=>{K.current||(K.current=!0,H())},[]),(0,x.useEffect)(()=>{if(M)return M.current=e=>{let t=q.current;t&&(t.currentTime=e)},()=>{M.current=null}},[]);let W=l||_?.posterUrl||"";if("ready"!==O||!_)return(0,T.jsxs)("div",{style:{position:"relative",width:"100%",aspectRatio:"16 / 9",backgroundColor:"#000",borderRadius:8,overflow:"hidden"},children:[W?(0,T.jsx)("img",{src:W,alt:n??"",style:{width:"100%",height:"100%",objectFit:"cover",opacity:.6}}):null,(0,T.jsx)("div",{style:{position:"absolute",inset:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:12,color:"#bbb",fontSize:14},children:"error"===O?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)("span",{children:"Não foi possível carregar o vídeo."}),(0,T.jsx)("button",{onClick:()=>{B(e=>e+1),H()},style:{padding:"6px 16px",borderRadius:6,border:"1px solid #666",backgroundColor:"transparent",color:"#fff",cursor:"pointer",fontSize:13},children:"Tentar de novo"})]}):(0,T.jsx)("span",{children:"Carregando vídeo…"})})]});let z=_.playbackUrl.includes(".m3u8"),Y=!1!==p&&"auto"!==A,Q=Y&&(_.captionTracks?.length??0)>0,X={googleCastButton:null,airPlayButton:null};!1!==p&&("auto"===A||Q)||(X.captionButton=null,X.captions=null),!1===m&&(X.settingsMenu=null),!1===S&&(X.pipButton=null),!1===k&&(X.chaptersMenu=null,X.chapterTitle=null),!1===w&&(X.fullscreenButton=null);let J=!1!==k&&(R?.length??0)>0,Z=J?(t=R??[],i=_.durationSeconds,s=[...t].sort((e,t)=>e.startTime-t.startTime),`WEBVTT
33
34${s.map((e,t)=>{let r=t<s.length-1?s[t+1].startTime:i&&i>e.startTime?i:e.startTime+600;return`${v3(e.startTime)} --> ${v3(r)}
35${e.title}`}).join(`
36
37`)}
38`):"",ee=[!1===g?"videofy-no-speed":"",!1===y?"videofy-no-quality":"",!1===v?"videofy-no-accessibility":"",!1===b?"videofy-no-audio":"",!1===E?"videofy-no-captions-menu":""].filter(Boolean).join(" ");return(0,T.jsx)("div",{ref:G,className:ee||void 0,style:{width:"100%"},children:(0,T.jsxs)(hN,{ref:q,title:n,src:{src:_.playbackUrl,type:z?"application/x-mpegurl":"video/mp4"},autoPlay:h,muted:u,loop:c,playsInline:!0,storage:"videofy-player",poster:!1===f?W:void 0,load:!1===f?"eager":void 0,style:{width:"100%",backgroundColor:"#000",borderRadius:8},aspectRatio:U,onProviderChange:e=>{e?.$$PROVIDER_TYPE==="HLS"&&(e.library=v2)},onCanPlay:()=>{let e=q.current;if(!e)return;let{mediaWidth:t,mediaHeight:i}=e.state;t>0&&i>0&&j(e=>{let s=`${t}/${i}`;return e===s?e:s});let s=[...e.textTracks].filter(e=>"chapters"!==e.kind&&!e.src).map(e=>({label:e.label||e.language||"Sem nome",language:e.language||""}));if(D?.(s),"auto"===A&&L)for(let t of e.textTracks)"chapters"===t.kind||t.src||(t.mode=t.language===L?"showing":"disabled")},onError:e=>{N("error")},onTimeUpdate:C?e=>C(e.currentTime):void 0,onDurationChange:I?e=>I(e):void 0,children:[(0,T.jsxs)(hB,{children:[W?(0,T.jsx)(hH,{className:"vds-poster",src:W,alt:n??""}):null,Y?(_.captionTracks??[]).map(e=>(0,T.jsx)(hj,{kind:"subtitles",src:e.src,label:e.label,language:e.language},e.language)):null,J?(0,T.jsx)(hj,{kind:"chapters",content:Z,type:"vtt",label:"Capítulos",language:"pt-BR",default:!0},Z):null]}),!1!==f&&(0,T.jsx)(cu,{icons:hJ,translations:v5,slots:X,menuContainer:V,smallLayoutWhen:v4})]},F)})},v6=({payload:e,onClick:t})=>{let{title:i,posterUrl:s}=e,r=ad[e.sizePreset??"full"];return(0,T.jsxs)("div",{onClick:t,style:{borderRadius:8,overflow:"hidden",margin:"16px auto",backgroundColor:"#000",position:"relative",paddingTop:"56.25%",width:r,cursor:t?"pointer":void 0},children:[s?(0,T.jsx)("img",{src:s,alt:i,loading:"lazy",style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",objectFit:"cover"}},s):(0,T.jsx)("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",color:"#888",fontSize:14},children:i||"Videofy"}),(0,T.jsx)("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:64,height:64,borderRadius:"50%",backgroundColor:"rgba(0,0,0,0.6)",display:"flex",alignItems:"center",justifyContent:"center",color:"#fff",fontSize:28},children:"▶"})]})},v7=({payload:e,macros:t})=>{let[i,s]=(0,x.useState)(!1),r=t?.authToken,a=t?.clientId,n=`${rR.ApiUrl}Apisx`,l=ad[e.sizePreset??"full"];
38if(!rR.ApiUrl||!e.videoId)return(0,T.jsx)(v6,{payload:e});let o=(0,T.jsx)(v8,{videoId:e.videoId,apiBaseUrl:n,title:e.title,poster:e.posterUrl,authToken:r,clientId:a,autoplay:"modal"===e.mode||e.autoplay,muted:e.muted,loop:e.loop,controls:e.controls,showCaptions:e.showCaptions,showSettings:e.showSettings,showSpeedMenu:e.showSpeedMenu,showQualityMenu:e.showQualityMenu,showAccessibilityMenu:e.showAccessibilityMenu,showAudioMenu:e.showAudioMenu,showCaptionsMenu:e.showCaptionsMenu,showPip:e.showPip,showChapters:e.showChapters,showFullscreen:e.showFullscreen,captionSource:e.captionSource,chapters:e.chapters,embeddedDefaultLang:e.embeddedDefaultLang});return"modal"===e.mode?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(v6,{payload:e,onClick:()=>s(!0)}),i?(0,T.jsxs)("div",{onClick:()=>s(!1),style:{position:"fixed",inset:0,zIndex:1300,backgroundColor:"rgba(0,0,0,0.85)",display:"flex",alignItems:"center",justifyContent:"center",padding:16},children:[(0,T.jsx)("div",{onClick:e=>e.stopPropagation(),style:{width:"100%",maxWidth:960},children:o}),(0,T.jsx)("button",{onClick:()=>s(!1),"aria-label":"Fechar",style:{position:"absolute",top:16,right:16,width:40,height:40,borderRadius:"50%",border:0,backgroundColor:"rgba(255,255,255,0.15)",color:"#fff",fontSize:20,cursor:"pointer"},children:"✕"})]}):null]}):(0,T.jsx)("div",{style:{width:"100%",containerType:"inline-size"},children:(0,T.jsx)("div",{style:{borderRadius:8,overflow:"hidden",margin:"16px auto",width:l},children:o})})},v9={left:"flex-start",center:"center",right:"flex-end"},be=({videoID:e,format:t})=>{if(!e)return(0,T.jsx)(T.Fragment,{});let i="left"===t||"center"===t||"right"===t?{display:"flex",justifyContent:v9[t]}:void 0;return(0,T.jsx)("div",{className:"docplus-youtube",style:i,children:(0,T.jsx)("div",{className:"docplus-youtube__frame",children:(0,T.jsx)("iframe",{className:"docplus-youtube__iframe",src:`https://www.youtube-nocookie.com/embed/${e}`,title:"YouTube video",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})})},bt={"alerts-item":({node:e})=>{let t=e.variant??"sky",i=e.title??"",s=e.description??"";return(0,T.jsx)(eX,{title:i,description:s,variant:t})},"download-link-node":({node:e})=>{let t=e.items??[],i=e.showFileSize??!1;return(0,T.jsx)(e9,{items:t,showFileSize:i})},"info-cards-node":({node:e})=>{let t=e.cards??[],i=e.colsMobile??1,s=e.colsDesktop??2,r=e.downloadLabel??"Download";return(0,T.jsx)(sA,{cards:t,colsMobile:i,colsDesktop:s,downloadLabel:r})},"calendar-node":({node:e})=>(0,T.jsx)(eZ,{mainTitle:e.mainTitle??"",cards:e.cards??[],colsMobile:e.colsMobile??2,colsDesktop:e.colsDesktop??4}),"photo-album-node":({node:e})=>{let t=e.items??[];return t.length?(0,T.jsx)(ry,{items:t}):(0,T.jsx)(T.Fragment,{})},"article-container":({node:e,macros:t,renderNode:i})=>{let s=K(e.children).filter(e=>"article-container-header"!==e.type);return(0,T.jsxs)("article",{className:"article-container",children:[e.title&&(0,T.jsxs)("div",{className:"article-header",children:[(0,T.jsx)("h1",{className:"article-title",children:e.title}),e.subtitle&&(0,T.jsx)("p",{className:"article-subtitle",children:e.subt
38itle}),e.edition&&(0,T.jsx)("p",{className:"article-edition",children:e.edition})]}),s.map((e,s)=>(0,T.jsx)(x.Fragment,{children:i?.(e,t)},s))]})},"article-section":({node:e,macros:t,renderNode:i})=>{let s=K(e.children);return(0,T.jsx)("h2",{id:e.sectionId,className:"article-section-title",...e.num?{"data-section-num":e.num}:{},children:s.length>0?s.map((e,s)=>(0,T.jsx)(x.Fragment,{children:i?.(e,t)},s)):e.title})},"article-item":({node:e,macros:t,renderNode:i})=>{let s=K(e.children);return(0,T.jsx)("p",{className:"article-item","data-item-num":e.num,children:s.length>0?s.map((e,s)=>(0,T.jsx)(x.Fragment,{children:i?.(e,t)},s)):e.content??""})},"article-subitem":({node:e,macros:t,renderNode:i})=>{let s=K(e.children);return(0,T.jsx)("p",{className:"article-subitem","data-subitem-label":e.label,children:s.length>0?s.map((e,s)=>(0,T.jsx)(x.Fragment,{children:i?.(e,t)},s)):e.content??""})},"article-box":({node:e,macros:t,renderNode:i})=>{let s=K(e.children),r=e.variant??"info";return(0,T.jsxs)("div",{className:`article-box article-box--${r}`,children:[e.boxTitle&&(0,T.jsx)("strong",{children:e.boxTitle}),s.length>0?s.map((e,s)=>(0,T.jsx)(x.Fragment,{children:i?.(e,t)},s)):e.content??""]})},"collapsible-container":({node:e,macros:t,renderNode:i})=>{let[s,r]=(0,x.useState)(e.open??!1),a=K(e.children),n=a.find(e=>"collapsible-title"===e.type),l=a.find(e=>"collapsible-content"===e.type);return(0,T.jsxs)("div",{className:"border border-gray-300 dark:border-white/15 rounded-md mb-4 overflow-hidden",children:[n&&(0,T.jsx)(e2,{node:n,isOpen:s,onToggle:()=>{r(e=>!e)},macros:t,renderNode:i}),s&&l&&(0,T.jsx)("div",{className:"px-4 py-3 bg-white dark:bg-[#1e1e2e] border-t border-gray-200 dark:border-white/10",children:K(l.children).map((e,s)=>(0,T.jsx)(x.Fragment,{children:i?.(e,t)},s))})]})},text:({node:e})=>{let t=e.text||"",i="number"==typeof e.format?e.format:0,s=G("string"==typeof e.style?q(e.style):{}),r=Object.keys(s).length>0,a=!0;for(let[e,n]of Object.entries(an)){if((i&Number(e))==0)continue;let l=al[n];if(!l)continue;let o=l.tag;t=(0,T.jsx)(o,{className:l.className,style:a&&r?s:void 0,children:t},n),a=!1}return a&&r&&(t=(0,T.jsx)("span",{style:s,children:t},"style")),t},paragraph:({node:e,macros:t,renderNode:i})=>{let s=K(e.children),r="string"==typeof e.format&&["left","right","center","justify"].includes(e.format),a=G("string"==typeof e.textStyle?q(e.textStyle):{});return(0,T.jsx)("p",{style:{textAlign:r?e.format:"justify",...a},className:"leading-relaxed  dp-body",children:0===s.length?(0,T.jsx)("br",{}):s.map((e,s)=>(0,T.jsx)(x.Fragment,{children:i?.(e,t)},s))})},heading:e=>{let{node:t,macros:i,renderNode:s}=e,r=String(t.tag??"").toLowerCase(),a=r.startsWith("h")?r:`h${r}`,n=["h1","h2","h3","h4","h5","h6"].includes(a)?a:"h2",l="string"==typeof t.format&&["left","right","center","justify"].includes(t.format),o=G("string"==typeof t.textStyle?q(t.textStyle):{}),d=K(t.children),h=d.map(e=>e.text).join("")?.toLowerCase().replace(/\s+/g,"-");return(0,T.jsx)(n,{style:{textAlign:l?t.format:void 0,...o},id:h,className:`${{h1:"text-[28px] md:text-3xl font-bold  ",h2:"text-[24px] md:text-2xl font-bold  ",h3:"text-[20px] md:text-xl font-bold ",h4:"text-[18px] md:text-lg font-bold ",h5:"text-[16px] md:text-base font-bold   ",h6:"text-[16px] md:text-base font-bold   "}[n]} dp-body`,children:d.map((e,t)=>(0,T.jsx)(x.Fragment,{children:s?.(e,i)},t))})},horizontalrule:e=>{let{node:t}=e;return(0,T.jsxs)("div",{className:"w-full relative flex py-5 items-center",children:[(0,T.jsx)("div",{className:"flex-grow border-t border-gray-400"}),(0,T.jsx)("div",{className:"flex-grow border-t border-gray-400"})]})},list:rm,"styled-list":rm,listitem:e=>{let{node:t,macros:i,renderNode:s}=e,r=G("string"==typeof t.textStyle?q(t.textStyle):{}),a=K(t.children);return(0,T.jsx)("li",{style:{...r,marginTop:0,marginBottom:0},className:"leading-relaxed dp-body",children:a.map((e,t)=>(0,T.jsx)(x.Fragment,{children:s?.(e,i)},t))})},quote:e=>{let{node:t,macros:i,renderNode:s}=e,r="string"==typeof t.textStyle?q(t.textStyle):{},a=K(t.children);return(0,T.jsx)("blockquote",{style:r,className:"border-l-4 border-[#
38E5E7EB] dark:border-white/10 pl-4 md:pl-5 italic dp-body",children:a.map((e,t)=>(0,T.jsx)(x.Fragment,{children:s?.(e,i)},t))})},"inline-image":e=>{let{node:t}=e;if(!t.image)return null;let{fileUrl:i,link:s,reference:r,maxHeight:a,maxWidth:n,maxWidthMobile:l,maxHeightMobile:o,maxWidthDesktop:d,maxHeightDesktop:h,openNewTab:u,headerText:c}=t.image;if(!i)return null;let[f,p]=(0,x.useState)({maxWidth:n||"100%",maxHeight:a||"auto"});return(0,x.useEffect)(()=>{let e=()=>{window.matchMedia("(max-width: 768px)").matches?p({maxWidth:l||n||"100%",maxHeight:o||a||"auto"}):window.matchMedia("(min-width: 1024px)").matches?p({maxWidth:d||n||"100%",maxHeight:h||a||"auto"}):p({maxWidth:n||"100%",maxHeight:a||"auto"})};return e(),window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}},[n,a,l,o,d,h]),(0,T.jsxs)("figure",{className:"my-8 flex flex-col items-center",children:[c&&(0,T.jsx)("figcaption",{className:"mb-2 text-lg font-semibold",children:c}),(0,T.jsx)("div",{className:"relative w-full rounded-lg flex justify-center items-center",style:f,children:s?(0,T.jsx)("a",{href:s,target:u?"_blank":"_self",rel:"noopener noreferrer",children:(0,T.jsx)("img",{src:i,alt:r||"",className:"object-cover w-full h-full rounded-lg",style:f},i)}):(0,T.jsx)("img",{src:i,alt:r||"",className:"object-cover w-full h-full rounded-lg",style:f},i)}),r&&(0,T.jsx)("figcaption",{className:"mt-3 text-center text-sm text-gray-500 dark:text-[#9aa4b2]",children:r})]})},"inline-image2":e=>{let{node:t}=e;return t.image&&(t.image.fileUrl||t.image.fileUrlDark)?(0,T.jsx)(sC,{...t.image}):null},"img-two-cols":e=>{let{node:t}=e,i=t.data,s=t.readOnly??!0,r=t.onSelectImage,{hoveredSide:a,setHoveredSide:n,getCellStyle:l,getImageStyle:o,placeholderStyle:d,containerStyle:h}=function(e){let{data:t,readOnly:i}=e,[s,r]=(0,x.useState)(null);return{hoveredSide:s,setHoveredSide:r,getCellStyle:(e,t)=>i?{...sT,...t?sS:{}}:{...sb,...t?sS:{},...s===e?sE:{}},getImageStyle:e=>{let t={...e.maxHeight&&{"--img-max-height":`${e.maxHeight}px`},...e.maxHeightMobile&&{"--img-max-height-mobile":`${e.maxHeightMobile}px`},...e.maxHeightDesktop&&{"--img-max-height-desktop":`${e.maxHeightDesktop}px`}};return{...sx,...t}},placeholderStyle:sk,containerStyle:{display:"grid",gap:12,margin:"12px 0",width:"100%",gridTemplateColumns:(0,x.useMemo)(()=>{let e=t.sizeLeft.desktopSize,i=t.sizeRight.desktopSize;return`${e}fr ${i}fr`},[t])}}}({...t}),u=e=>{let t=i?.[e],a=!!t?.fileUrl;return(0,T.jsx)("div",{style:l(e,a),onClick:s?void 0:()=>r?.(e,t,a),onMouseEnter:()=>!s&&n(e),onMouseLeave:()=>!s&&n(null),children:a?(0,T.jsx)("img",{className:"lexical-img-two-cols-image",style:o(t),src:t.fileUrl,alt:t.reference??""},t.fileUrl):!s&&(0,T.jsx)("span",{style:d,children:"Clique para adicionar imagem"})})};return(0,T.jsxs)("div",{style:h,children:[u("imageLeft"),u("imageRight")]})},code:e=>{let{node:t}=e,i=t.fields?.code?.language||t.language||"plaintext",s=t.fields?.code?.code||t.code||"";return(0,T.jsx)(e1,{language:i,code:s})},video:B,scratch:_,CourseAttachs:C,"secure-exam-render":e=>{let{node:t}=e,i=(0,x.useMemo)(()=>(e=>{var t;let i,s,r,a=e.payload??e.secureExamPayload;if(a)return a;let n=e.questionId??"",l=e.studentId??"",o=e.sessionId??"",d=e.variantId??"",h=(t=e.lexicalState,i=[],s=(e=>{let t=(e=>{if(e){if("string"==typeof e)try{return JSON.parse(e)}catch{return}return et(e)?e:void 0}})(e);if(!t)return;if(et(t.root))return t;let i=(Array.isArray(t.blocks)?t.blocks:[]).find(e=>et(e)&&"lexical"===e.type&&et(e.data));return et(i)&&et(i.data)?i.data:void 0})(t),(r=et(s?.root)?s.root:void 0)?{blocks:ei(r).flatMap((e,t)=>{var s;let r;return s=String(t),r=es(e).trim(),((e,t,i)=>{if("paragraph"===e.type)return i?[{id:er(e,t),text:i,type:"paragraph"}]:[{id:er(e,t),metadata:{height:12},type:"spacer"}];if("heading"===e.type){let s;return[{id:er(e,t),level:Number.isFinite(s=Number.parseInt(String(e.tag??"h2").replace("h",""),10))?Math.min(6,Math.max(1,s)):2,text:i,type:"heading"}]}if(["inline-image","inline-image2","image-display-node"].includes(e.type)){let i,s,r,a,n;return i=(e=>{let t=et(e.fields)?e.fields:void 0,i=(et(e.image)?e.image:void 0)??(et(t?.image)?t?.image:void 0)??(et(e.value)?e.value:void 0),s="string"==typeof i?.fileUrl&&i.fileUrl||"string"==typeof i?.url&&i.url||"string"==typeof e.src&&e.src||void 0;if(!s)return;let r=e=>"number"==typeof e&&Number.isFinite(e),a=e=>"string"==typeof e,n=e=>"boolean"==typeof e,l=(e,t)=>
38{let s=i?.[e];return t(s)?s:void 0};return{alignment:l("alignment",a),disableShowMobile:l("disableShowMobile",n),disableShowOnWeb:l("disableShowOnWeb",n),fileUrl:s,fileUrlDark:l("fileUrlDark",a),headerText:l("headerText",a),isOpenLightboxOnClick:l("isOpenLightboxOnClick",n),link:l("link",a),maxHeight:l("maxHeight",r),maxHeightDesktop:l("maxHeightDesktop",r),maxHeightMobile:l("maxHeightMobile",r),maxWidth:l("maxWidth",r),maxWidthDesktop:l("maxWidthDesktop",r),maxWidthMobile:l("maxWidthMobile",r),openNewTab:l("openNewTab",n),position:l("position",a),reference:l("reference",a)??("string"==typeof e.altText?e.altText:void 0),tooltip:l("tooltip",a)}})(e),[{alt:i?.reference??("string"==typeof e.altText?e.altText:void 0),id:er(e,t),image:i,src:i?.fileUrl??(s=et(e.image)?e.image:void 0,r=et(e.fields)?e.fields:void 0,a=et(r?.image)?r?.image:void 0,n=et(e.value)?e.value:void 0,"string"==typeof e.src&&e.src||"string"==typeof s?.fileUrl&&s.fileUrl||"string"==typeof s?.url&&s.url||"string"==typeof a?.url&&a.url||"string"==typeof n?.url&&n.url||void 0),type:"image"}]}if("equation"===e.type)return[{id:er(e,t),text:e.equation??i,type:"formula"}];if("table"===e.type)return[{id:er(e,t),rows:ei(e).map((e,i)=>({cells:ei(e).map((e,s)=>({blocks:[{id:`${er(e,`${t}_${i}_${s}`)}_text`,text:es(e).trim(),type:"paragraph"}],colSpan:"number"==typeof e.colSpan?e.colSpan:void 0,id:er(e,`${t}_${i}_${s}`),rowSpan:"number"==typeof e.rowSpan?e.rowSpan:void 0})),id:er(e,`${t}_${i}`)})),type:"table"}];if("text"===e.type||"linebreak"===e.type)return i?[{id:er(e,t),text:i,type:"paragraph"}]:[]})(e,s,r)||(i.push({code:"unsupported_lexical_node",message:"Nó Lexical não suportado foi convertido por fallback seguro.",nodeType:e.type,metadata:{path:s}}),r?[{id:er(e,s),metadata:{unsupportedType:e.type},text:r,type:"paragraph"}]:[])}),warnings:i}:{blocks:[],warnings:[{code:"invalid_lexical_state",message:"Estado Lexical ausente ou inválido."}]}).blocks,u=e.forensic?.layoutSeed??ee({questionId:n,sessionId:o,studentId:l,variantId:d});return{alternatives:e.alternatives??[],blocks:h,forensic:{layoutSeed:u,signature:e.forensic?.signature??"",studentTraceId:e.forensic?.studentTraceId,textVariantSeed:e.forensic?.textVariantSeed},questionId:n,renderConfig:{...z,...e.renderConfig},sessionId:o,studentId:l,variantId:d,watermark:e.watermark??ea}})(t),[t]);return(0,T.jsx)(ez,{accessibility:t.accessibility,payload:i,responsive:t.responsive,selectedAlternativeId:t.selectedAlternativeId,onAlternativePress:e.onAlternativePress,onRenderComplete:e.onRenderComplete,onRenderError:e.onRenderError,onRendererFallback:e.onRendererFallback})},table:e=>{let t,{node:i,macros:s,renderNode:r}=e;if(!i)return null;let a=K(i.children);if(0===a.length)return null;let n=i.colWidths,l=(e=>{if(!e)return;let t=e.split(";").map(e=>e.trim()).find(e=>e.toLowerCase().startsWith("width:"));if(!t)return;let[,i]=t.split(":");return i?.trim()||void 0})(i.style),o=(e=>{if(!e)return;let t=e.split(";").map(e=>e.trim()).find(e=>e.toLowerCase().startsWith("line-height:"));if(!t)return;let[,i]=t.split(":");return i?.trim()||void 0})(i.style),d=(e=>{if(!e)return;let t=e.split(";").map(e=>e.trim()).find(e=>e.toLowerCase().startsWith("font-size:"));if(!t)return;let[,i]=t.split(":");return i?.trim()||void 0})(i.style),h="center"===(t=i.format)||"right"===t?t:"left",u={..."string"==typeof i.style?q(i.style):{},...l?{width:l}:{},...n&&n.length>0?{tableLayout:"fixed"}:{}};return"center"===h?(u.marginLeft="auto",u.marginRight="auto"):"right"===h&&(u.marginLeft="auto"),(0,T.jsx)("div",{className:"table-scroll-wrapper",children:(0,T.jsxs)("table",{className:"lexical-table",style:u,children:[n&&n.length>0&&(0,T.jsx)("colgroup",{children:n.map((e,t)=>(0,T.jsx)("col",{style:{width:`${e}px`}},t))}),(0,T.jsx)("tbody",{children:a.map((e,t)=>{let i=K(e.children),a=e.height;return(0,T.jsx)("tr",{style:a?{height:`${a}px`}:void 0,children:i.map((e,t)=>{let i=K(e.children),a=(e.headerState??0)!==0,n="string"==typeof e.style?q(e.style):{};return(0,T.jsx)(a?"th":"td",{colSpan:e.colSpan,rowSpan:e.rowSpan,className:`lexical-table-cell${a?" lexical-table-cell--header":""}`,style:{...n,textAlign:"rtl"===e.direction?"right":"left",backgroundColor:e.backgroundColor||void 0,...e.backgroundColor&&!n.color?{color:"#111827"}:{},verticalAlign:"middle"===e.verticalAlign?"middle":"bottom"===e.verticalAlign?"bottom":void 0,...o?{lineHeight:o}:{},...d?{fontSize:d}:{}},children:i.length>0?i.map((e,t)=>{let i=K(e.children);return(0,T.jsx)("p",{children:i.map((e,t)=>(0,T.jsx)(x.Fragment,{children:r?.(e,s)},t))},t)}):(0,T.jsx)("span",{className:"lexical-table-cell--empty",children:"[Vazio]"})},t)})},t)})})]})})},equation:e=>(0,T.jsx)(tt,{...e}),chemistry:({node:e})=>(0,T.jsx)(e0,{imageDataUri:e.imageDataUri??"",width:e.width??300,height:e.height??200,name:e.name,inline:e.inline??!1,chemistryId:e.chemistryId}),rdkit:({node:e})=>(0,T.jsx)(rj,{smiles:e.smiles??"",name:e.name,inline:e.inline??!1,monochrome:e.monochrome??!1,width:e.width,height:e.height,printWidth:e.printWidth,printHeight:e.printHeight,rotation:e.rotation??0,flipHorizontal:e.flipHorizontal??!1,flipVertical:e.flipVertical??!1,alignment:e.alignment??"center"}),linebreak:()=>(0,T.jsx)("br",{}),link:rf,autolink:rf,"page-break":()=>(0,T.jsx)("figure",{className:"docplus-page-break"}
38),"double-superscript":({node:e,macros:t,renderNode:i})=>{let s=K(e.children);return(0,T.jsx)("sup",{style:{fontSize:"0.64em",verticalAlign:"super",position:"relative",top:"-0.4em"},children:s.map((e,s)=>(0,T.jsx)(x.Fragment,{children:i?.(e,t)},s))})},"double-subscript":({node:e,macros:t,renderNode:i})=>{let s=K(e.children);return(0,T.jsx)("sub",{style:{fontSize:"0.64em",verticalAlign:"sub",position:"relative",top:"0.4em"},children:s.map((e,s)=>(0,T.jsx)(x.Fragment,{children:i?.(e,t)},s))})},"source-text-block":({macros:e,node:t,renderNode:i})=>{let s,r=K(t.children);return(0,T.jsx)("div",{"data-lexical-source-text-block":"true","data-source-text-max-width":t.maxWidth,"data-source-text-position":t.position,style:{maxWidth:t.maxWidth??"70%",width:"100%",marginBottom:16,marginTop:16,..."left"===(s=t.position)?{marginLeft:0,marginRight:"auto"}:"right"===s?{marginLeft:"auto",marginRight:0}:{marginLeft:"auto",marginRight:"auto"}},children:r.map((t,s)=>(0,T.jsx)(x.Fragment,{children:i?.(t,e)},s))})},"source-text-content":({macros:e,node:t,renderNode:i})=>{let s=K(t.children);return(0,T.jsx)("div",{"data-lexical-source-text-content":"true",children:s.length?s.map((t,s)=>(0,T.jsx)(x.Fragment,{children:aa(t,e,i,"left",!1,0===s)},s)):(0,T.jsx)("p",{style:{lineHeight:1.55,margin:0},children:(0,T.jsx)("br",{})})})},"source-text-reference":({macros:e,node:t,renderNode:i})=>{let s=K(t.children);return(0,T.jsx)("div",{"data-lexical-source-text-reference":"true",style:{color:"var(--dp-text, rgba(31, 41, 55, 0.82))",fontSize:"0.82em",lineHeight:1.45,marginTop:10},children:s.length?s.map((t,s)=>(0,T.jsx)(x.Fragment,{children:aa(t,e,i,"right",!0,0===s)},s)):(0,T.jsx)("p",{style:{margin:0,textAlign:"right"},children:(0,T.jsx)("br",{})})})},"image-display-node":sv,"file-display-and-download-node":sv,"videofy-block":({node:e,macros:t})=>{let i=e.payload;return i?.videoId?(0,T.jsx)(v7,{payload:i,macros:t}):(0,T.jsx)(T.Fragment,{})},"slideshow-block":({node:e})=>{let t={effect:e.effect??rH,speedMs:e.speedMs??rK,loop:e.loop??rW,autoplay:e.autoplay??rz,autoplayDelayMs:e.autoplayDelayMs??rY,pauseOnHover:e.pauseOnHover??rQ,showNavigation:e.showNavigation??rX,showPagination:e.showPagination??rJ,paginationType:e.paginationType??rZ,showScrollbar:e.showScrollbar??r0,keyboard:e.keyboard??r1,mousewheel:e.mousewheel??r2,grabCursor:e.grabCursor??r5,zoom:e.zoom??r3,slidesPerView:e.slidesPerView??r4,spaceBetween:e.spaceBetween??r8,aspectRatioDesktop:e.aspectRatioDesktop??r6,aspectRatioMobile:e.aspectRatioMobile??r7};if("local"===e.source){let i=Array.isArray(e.localSlides)?e.localSlides:[];return i.length?(0,T.jsx)(ai,{slides:i,config:t}):null}let i=Number(e.siteId);if(!i)return null;let s=Array.isArray(e.slideIds)?e.slideIds.map(Number).filter(e=>!Number.isNaN(e)):[];return(0,T.jsx)(x.Suspense,{fallback:(0,T.jsx)(rV,{config:t}),children:(0,T.jsx)(as,{siteId:i,slideIds:s,config:t})})},"popup-block":({node:e})=>{let t=Number(e.siteId);if(!t)return null;let i=Number(e.popupId)||0,s={delayMs:e.delayMs??rI,frequency:e.frequency??rP,dismissable:e.dismissable??rD};return(0,T.jsx)(x.Suspense,{fallback:null,children:(0,T.jsx)(rN,{siteId:t,popupId:i,config:s})})},"menu-block":({node:e})=>{let t,i,s=e.layout??rb,r={...rv,...e.container??{}},a=(t=new Set,(i=e=>{for(let i of e)"menu-items"===i.type&&i.siteId&&t.add(i.siteId)})(s.start.items),i(s.center.items),i(s.end.items),[...t]);return a.length?(0,T.jsx)(x.Suspense,{fallback:(0,T.jsx)(rA,{layout:s,container:r,itemsBySite:{}}),children:(0,T.jsx)(rS,{dataKey:`menu-${a.join(".")}`,fetcher:()=>Promise.all(a.map(e=>fetch(`${rR.ApiUrl}Sites/menu/getMenuItems?site_id=${e}`,{method:"POST",headers:{accept:"application/json"},next:{tags:[`site_menu-${e}`]}}).then(e=>e.json()).then(e=>Array.isArray(e?.data)?e.data:[]).catch(()=>[]).then(t=>[e,t]))).then(e=>Object.fromEntries(e)),children:e=>(0,T.jsx)(rA,{layout:s,container:r,itemsBySite:e})})}):(0,T.jsx)(rA,{layout:s,container:r,itemsBySite:{}})},youtube:({node:e})=>(0,T.jsx)(be,{videoID:e.videoID??"",format:e.format}),tweet:({node:e})=>
38(0,T.jsx)(ao,{tweetID:e.id??"",loadingComponent:"Carregando..."}),"layout-container":({node:e,macros:t,renderNode:i})=>(0,T.jsx)(rh,{node:e,macros:t,renderNode:i,editable:!1}),"layout-cols":e=>(0,T.jsx)(ru,{...e,node:e.node})},bi=e=>{let{data:t,paragraphStyles:i,macros:s,maxLines:r}=e,a=(0,x.useContext)(V),n=(0,x.useMemo)(()=>"string"==typeof i?q(i):{},[i]),l=(0,x.useMemo)(()=>({...bt,...a}),[a]),o=(0,x.useMemo)(()=>t?.root?.children?K(t.root.children):[],[t]);return t?.root?.children?(0,T.jsx)("div",{style:{color:"var(--dp-text, inherit)",...G(n)},className:"flex flex-col md:flex-row gap-8",children:(0,T.jsx)("div",{className:"w-full",style:r&&r>0?{display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:r,overflow:"hidden"}:void 0,children:o.map((e,t)=>(0,T.jsx)(x.Fragment,{children:W(e,s,l)},t))})}):null},bs=e=>{let{data:t,paragraphStyles:i,macros:s,extraComponentMap:r,maxLines:a}=e,n=(0,x.useMemo)(()=>t&&"object"==typeof t&&t.root?t:(e=>{let t=e;for(;"string"==typeof t&&t.length>1&&t.startsWith('"')&&t.endsWith('"');)try{let e=JSON.parse(t);if("string"!=typeof e){t=e;break}t=e}catch{break}if("string"==typeof t)try{t=JSON.parse(t)}catch{return null}if(!t||"object"!=typeof t)return null;let i=t;if(i.root&&"object"==typeof i.root)return i;let s=i.blocks;if(Array.isArray(s))for(let e of s){if(!e||"object"!=typeof e)continue;let t=e.data;if(t&&"object"==typeof t&&t.root)return t}return null})(t),[t]);return n&&n.root?(0,T.jsx)(V.Provider,{value:r??{},children:(0,T.jsx)(bi,{data:n,paragraphStyles:i,macros:s,maxLines:a})}):null},br=new Set(['"',"\\","/","b","f","n","r","t","u"]);e.s(["DocplusRenderWeb",0,e=>{let{jsonStr:t,styles:i,macros:s}=e;if(!t||""===t)return null;let{json:r}=(e=>{let{jsonStr:t}=e;return{json:(0,x.useMemo)(()=>(e=>{try{let t=JSON.parse(e);return"object"==typeof t?t:{blocks:[]}}catch{try{return JSON.parse(e.replace(/\\([\s\S])/g,(e,t)=>br.has(t)?e:`\\\\${t}`))}catch{return{blocks:[]}}}})(t),[t])}})({jsonStr:t}),a=(0,x.useRef)(null),n=(()=>{let{defaultText:e}={defaultText:(e,t="")=>{if("string"==typeof e.text&&!e.text)return"";e.text;let i=t||"",s=e.color?`color:"${e.color}"`:"",r=(e.bgColor,[]);return"string"==typeof e.text?r.push(`<p style="text-align: ${e.alignment??"justify"}; ${s}; ${i}">${e.text.replace("<br>","")}</p>`):"object"==typeof e.text&&r.push(`<p style="text-align: ${e.alignment??"justify"}; ${s}; ${i}">${e.text}</p>`),r.join("")}};return{paragraph:(t,i)=>e(t.data,i),header:e=>`<h${e.data.level} style="text-align: ${e.data.alignment}"><b>${e.data.text}</b></h${e.data.level}>`,trueOrFalse:e=>`<p>( ) ${e.data.text}</p>`,TwoColsText:t=>{if(!t.data)return"";let i=[];return t.data.textColLeft.colSize,t.data.textColRight.colSize,i.push('<div style=" display: flex; flex-wrap: wrap; gap:20px; justify-content: "center"; padding: 0 10px;">'),i.push(e(t.data.textColLeft,"min-width: 240px; max-width: 100%; width: 2px; flex-grow: 1;"),e(t.data.textColRight,"min-width: 240px; max-width: 100%; width: 2px; flex-grow: 1;")),i.push("</div>"),i.join("")},ThreeColsText:t=>{if(!t.data)return"";let i=[];return i.push('<div class="container"> <div class="row">'),i.push(e(t.data.textFirstCol),e(t.data.textSecondCol),e(t.data.textThirdCol)),i.push("</div> </div>"),i.join("")},Topic:e=>{let t=[];return t.push(`<h2 class="topic-item" id="${e.id}">`),t.push(e.data.text),t.push("</h2>"),t.join("")},subtopic:e=>{let t=[];return t.push(`<h4 class="subtopic-item" id="${e.id}">`),t.push(e.data.text),t.push("</h4>"),t.join("")}}})(),l=e=>'<div><ul style="margin:0px;">'+e.data.items.map(e=>`<li>${e.replace("<br>","")}</li>`).join("")+"</ul></div>",o=(()=>{let e,{parseImageText:t,generateImageColumn:i,getRawImage:s}={generateImageColumn:e=e=>{if(void 0===e.url)return"<div></div>";let t=[];return t.push('<div class="col-md">'),t.push(`<img src="${e.url}" style="width: 100%;"/>`),t.push("</div>"),t.join("")},parseImageText:({data:t},i)=>{var s;let r;if(!t||!t.image&&!t.text)return"<div></div>";let a=[];a.push('<div class="container"> <div class="row">');let n=e(t.image),l=(s=t.text,(r=[]).push(""),s&&(r.push('<div class="col-md">
38'),s.texts.forEach(e=>{r.push((e=>{let{isBold:t,isItalic:i,text:s}=e,r=`<p>${s}</p>`;return t&&(r=`<b>${r}</b>`),i&&(r=`<i>${r}</i>`),r})(e))}),r.push("</div>")),r.join(""));return i?a.push(l,n):a.push(n,l),a.push("</div> </div>"),a.join("")},getRawImage:e=>{if(void 0===e.url)return"";let t=[];return t.push(`<img src="${e.url}" style="width: 100%;"/>`),t.join("")}};return{parseImage:e=>`<img src="${e.data.file.url}" class="img-fluid"/>`,image:e=>(e.data.fileUrl,'<img src="'+e.data.fileUrl+'"  class="img-fluid" style="width:100%"/>'),twoColsBothImages:e=>{if(!e.data||!e.data.imageLeft&&!e.data.imageRight)return"<div></div>";let t=[];t.push('<div style=" display: grid;grid-template-columns: 1fr 1fr;  grid-gap: 20px;">');let i=s(e.data.imageLeft),r=s(e.data.imageRight);return t.push(`<div>${i}</div>`),t.push(`<div>${r}</div>`),t.push("</div>"),t.join("")},TwoColsImageLeft:e=>t(e,!1),twoColsImageRight:e=>t(e,!0)}})(),d=i||"text-align: justify";return(0,T.jsx)(V.Provider,{value:e.extraComponentMap??{},children:(0,T.jsx)("div",{ref:a,children:r?.blocks&&r.blocks.length>0?r.blocks.map((t,i)=>{switch(t.type){case"VideosTools":return(0,T.jsx)(B,{node:{video:t.data,type:"video",currentContext:e.currentContext,textStyle:""}},i);case"MuxVideo":return(0,T.jsx)(B,{node:{video:{url:"",description:t.data?.player?.title??"",playbackId:t.data?.player?.playbackId??"",blockedsContext:t.data?.blockedsContext??[],type:"mux"},type:"video",currentContext:e.currentContext,textStyle:""}},i);case"lexical":return(0,T.jsx)(bs,{paragraphStyles:d,data:t.data,macros:s,extraComponentMap:e.extraComponentMap},i);case"ScratchEditor":return(0,T.jsx)(_,{node:{...t.data,textStyle:""}},i);case"TwoColsImgHtml":return(0,T.jsx)($,{...t.data},i);case"CourseAttachs":return(0,T.jsx)(C,{node:{...t.data}},i);case"ImgTwoCols":return(0,T.jsx)(D,{...t.data},i);case"HtmlTwoCols":return(0,T.jsx)(I,{...t.data},i);case"imageS3":return(0,T.jsx)(P,{...t.data},i);case"header":return(0,T.jsx)("div",{dangerouslySetInnerHTML:{__html:n.header(t)}},i);case"ThreeColsText":return(0,T.jsx)("div",{dangerouslySetInnerHTML:{__html:n.ThreeColsText(t)}},i);case"Topic":return(0,T.jsx)("div",{dangerouslySetInnerHTML:{__html:n.Topic(t)}},i);case"TwoColsText":return(0,T.jsx)("div",{dangerouslySetInnerHTML:{__html:n.TwoColsText(t)}},i);case"subtopic":return(0,T.jsx)("div",{dangerouslySetInnerHTML:{__html:n.subtopic(t)}},i);case"list":return(0,T.jsx)("div",{style:{textAlign:"justify"},dangerouslySetInnerHTML:{__html:l(t)}},i);case"paragraph":return(0,T.jsx)("div",{dangerouslySetInnerHTML:{__html:n.paragraph(t,d)}},i);case"TwoColsImageLeft":return(0,T.jsx)("div",{dangerouslySetInnerHTML:{__html:o.TwoColsImageLeft(t)}},i);case"image":return(0,T.jsx)("div",{dangerouslySetInnerHTML:{__html:o.image(t)}},i);case"parseImage":return(0,T.jsx)("div",{dangerouslySetInnerHTML:{__html:o.parseImage(t)}},i);case"twoColsBothImages":return(0,T.jsx)("div",{dangerouslySetInnerHTML:{__html:o.twoColsBothImages(t)}},i);case"twoColsImageRight":return(0,T.jsx)("div",{dangerouslySetInnerHTML:{__html:o.twoColsImageRight(t)}},i);case"dynamicList":return(0,T.jsx)(x.default.Fragment,{},i);default:return(0,T.jsx)(x.default.Fragment,{children:JSON.stringify(t)},i)}}):null})})}],44077)}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.