@streamlayer/react 1.21.3 → 1.22.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/app/masters.d.ts +2 -5
- package/lib/app/pause-ad.d.ts +1 -10
- package/lib/app/useStreamLayerApp.d.ts +1 -23
- package/lib/cjs/Question.js +1 -0
- package/lib/cjs/advertisement.js +40 -40
- package/lib/cjs/analytics.js +1 -0
- package/lib/cjs/auth.js +1 -1
- package/lib/cjs/bet-pack.js +1 -1
- package/lib/cjs/gamification-feature.js +1 -1
- package/lib/cjs/hooks-B0Qttldg.js +1 -0
- package/lib/cjs/index-DSi8Qgfs.js +1 -0
- package/lib/cjs/index.js +1 -1
- package/lib/cjs/index10.js +1 -0
- package/lib/cjs/index11.js +4 -0
- package/lib/cjs/index12.js +1 -0
- package/lib/cjs/index13.js +1 -0
- package/lib/cjs/index14.js +1 -0
- package/lib/cjs/index15.js +1 -0
- package/lib/cjs/index16.js +5 -0
- package/lib/cjs/index2.js +1 -5
- package/lib/cjs/index3.js +1 -0
- package/lib/cjs/index4.js +5 -0
- package/lib/cjs/index5.js +1 -0
- package/lib/cjs/index6.js +1 -0
- package/lib/cjs/index7.js +5 -0
- package/lib/cjs/index8.js +1 -0
- package/lib/cjs/index9.js +1 -0
- package/lib/cjs/insight.js +1 -1
- package/lib/cjs/masters.js +1 -1
- package/lib/cjs/masters2.js +6 -6
- package/lib/cjs/notification.js +1 -1
- package/lib/cjs/pause-ad.js +1 -1
- package/lib/cjs/points.js +1 -1
- package/lib/cjs/sl-types.js +15 -0
- package/lib/cjs/storage.js +1 -0
- package/lib/cjs/theme.js +17 -0
- package/lib/cjs/useStreamLayerApp.js +1 -1
- package/lib/cjs/useStreamLayerApp2.js +17 -16
- package/lib/cjs/utils.js +47 -0
- package/lib/cjs/vast-client.min.js +1 -0
- package/lib/classic/app/masters.d.ts +2 -5
- package/lib/classic/app/pause-ad.d.ts +1 -10
- package/lib/classic/app/useStreamLayerApp.d.ts +1 -23
- package/lib/classic/cjs/Question.js +1 -0
- package/lib/classic/cjs/advertisement.js +40 -40
- package/lib/classic/cjs/analytics.js +1 -0
- package/lib/classic/cjs/auth.js +1 -1
- package/lib/classic/cjs/bet-pack.js +4 -4
- package/lib/classic/cjs/gamification-feature.js +1 -1
- package/lib/classic/cjs/hooks-B0Qttldg.js +1 -0
- package/lib/classic/cjs/index-DSi8Qgfs.js +1 -0
- package/lib/classic/cjs/index.js +1 -1
- package/lib/classic/cjs/index10.js +1 -0
- package/lib/classic/cjs/index11.js +1 -0
- package/lib/classic/cjs/index12.js +1 -0
- package/lib/classic/cjs/index13.js +4 -0
- package/lib/classic/cjs/index2.js +5 -0
- package/lib/classic/cjs/index3.js +1 -0
- package/lib/classic/cjs/index4.js +1 -0
- package/lib/classic/cjs/index5.js +1 -0
- package/lib/classic/cjs/index6.js +5 -0
- package/lib/classic/cjs/index7.js +1 -0
- package/lib/classic/cjs/index8.js +1 -0
- package/lib/classic/cjs/index9.js +1 -0
- package/lib/classic/cjs/insight.js +1 -1
- package/lib/classic/cjs/notification.js +1 -1
- package/lib/classic/cjs/notification2.js +1 -0
- package/lib/classic/cjs/pause-ad.js +1 -1
- package/lib/classic/cjs/points.js +1 -1
- package/lib/classic/cjs/sl-types.js +15 -0
- package/lib/classic/cjs/useStreamLayerApp.js +1 -1
- package/lib/classic/cjs/useStreamLayerApp2.js +17 -16
- package/lib/classic/cjs/utils.js +47 -0
- package/lib/classic/cjs/vast-client.min.js +1 -0
- package/lib/classic/es/Question.js +392 -0
- package/lib/classic/es/advertisement.js +10375 -10374
- package/lib/classic/es/analytics.js +28 -0
- package/lib/classic/es/auth.js +4 -4
- package/lib/classic/es/bet-pack.js +55 -51
- package/lib/classic/es/gamification-feature.js +1 -1
- package/lib/classic/es/hooks-B0Qttldg.js +98 -0
- package/lib/classic/es/index-DSi8Qgfs.js +65 -0
- package/lib/classic/es/index.js +14 -15
- package/lib/classic/es/index10.js +87 -0
- package/lib/classic/es/index11.js +2355 -0
- package/lib/classic/es/index12.js +183 -0
- package/lib/classic/es/index13.js +835 -0
- package/lib/classic/es/index2.js +2621 -0
- package/lib/classic/es/index3.js +64 -0
- package/lib/classic/es/index4.js +19 -0
- package/lib/classic/es/index5.js +285 -0
- package/lib/classic/es/{index-l-eyvmpL.js → index6.js} +937 -937
- package/lib/classic/es/index7.js +7 -0
- package/lib/classic/es/index8.js +11 -0
- package/lib/classic/es/index9.js +319 -0
- package/lib/classic/es/insight.js +31 -32
- package/lib/classic/es/notification.js +7 -1006
- package/lib/classic/es/notification2.js +1117 -0
- package/lib/classic/es/pause-ad.js +139 -138
- package/lib/classic/es/points.js +39 -38
- package/lib/classic/es/sl-types.js +258 -0
- package/lib/classic/es/useStreamLayerApp.js +1 -2
- package/lib/classic/es/useStreamLayerApp2.js +4798 -2735
- package/lib/classic/es/utils.js +76 -0
- package/lib/{es/vast-client.min-B0NUra1B.js → classic/es/vast-client.min.js} +338 -338
- package/lib/classic/index.d.ts +5 -13
- package/lib/classic/masters.d.ts +1 -1
- package/lib/dist/cjs/index.js +1 -1
- package/lib/dist/cjs/masters.js +34 -33
- package/lib/dist/es/index.js +2 -2
- package/lib/dist/es/masters.js +10563 -8870
- package/lib/dist/index.d.ts +1332 -0
- package/lib/dist/style.css +1 -1
- package/lib/es/Question.js +136 -0
- package/lib/es/advertisement.js +10375 -10374
- package/lib/es/analytics.js +28 -0
- package/lib/es/auth.js +4 -4
- package/lib/es/bet-pack.js +7 -6
- package/lib/es/gamification-feature.js +1 -1
- package/lib/es/hooks-B0Qttldg.js +98 -0
- package/lib/es/index-DSi8Qgfs.js +65 -0
- package/lib/es/index.js +13 -14
- package/lib/es/index10.js +267 -0
- package/lib/es/index11.js +835 -0
- package/lib/es/index12.js +183 -0
- package/lib/es/index13.js +319 -0
- package/lib/es/index14.js +87 -0
- package/lib/es/index15.js +2355 -0
- package/lib/es/index16.js +1254 -0
- package/lib/es/index2.js +1349 -3364
- package/lib/es/index3.js +64 -0
- package/lib/es/index4.js +3418 -0
- package/lib/es/index5.js +19 -0
- package/lib/es/index6.js +285 -0
- package/lib/es/{index-l-eyvmpL.js → index7.js} +937 -937
- package/lib/es/index8.js +7 -0
- package/lib/es/index9.js +11 -0
- package/lib/es/insight.js +31 -32
- package/lib/es/masters.js +6 -5
- package/lib/es/masters2.js +189 -176
- package/lib/es/notification.js +141 -136
- package/lib/es/pause-ad.js +140 -139
- package/lib/es/points.js +40 -38
- package/lib/es/sl-types.js +277 -0
- package/lib/es/storage.js +113 -0
- package/lib/es/theme.js +47 -0
- package/lib/es/useStreamLayerApp.js +1 -2
- package/lib/es/useStreamLayerApp2.js +4798 -2735
- package/lib/es/utils.js +76 -0
- package/lib/{classic/es/vast-client.min-B0NUra1B.js → es/vast-client.min.js} +338 -338
- package/lib/index.d.ts +5 -13
- package/lib/masters.d.ts +1 -1
- package/lib/style.css +1 -1
- package/package.json +16 -51
- package/lib/app/event.d.ts +0 -6
- package/lib/app/provider.d.ts +0 -49
- package/lib/cjs/index-l-eyvmpL.js +0 -5
- package/lib/cjs/provider.js +0 -84
- package/lib/cjs/vast-client.min-B0NUra1B.js +0 -1
- package/lib/classic/app/event.d.ts +0 -6
- package/lib/classic/app/provider.d.ts +0 -49
- package/lib/classic/cjs/index-l-eyvmpL.js +0 -5
- package/lib/classic/cjs/provider.js +0 -68
- package/lib/classic/cjs/vast-client.min-B0NUra1B.js +0 -1
- package/lib/classic/es/provider.js +0 -7619
- package/lib/dist/cjs/gamification-feature2.js +0 -1
- package/lib/dist/es/gamification-feature2.js +0 -285
- package/lib/es/provider.js +0 -7695
package/lib/cjs/advertisement.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const z=require("react/jsx-runtime"),_e=require("react"),W=require("./provider.js");require("nanostores");require("lodash.throttle");require("react-dom");require("react-countup");const ue=require("./useStreamLayerApp2.js"),Dd=require("./vast-client.min-B0NUra1B.js"),Qf=require("./index-l-eyvmpL.js"),Gn=require("uuid"),Jf=W.styled_default("div")({name:"Container",class:"c5b6wdg",propsAsIs:!1}),Zf="a1rlj479",em="s35f1di",tm="sj4471g",im="b12050d8",nm="b1d5ybek",sm=i=>i==="left"||i==="right"?em:im,rm=i=>i==="left"||i==="right"?tm:nm,am=i=>i==="left"?"avdxyl3":i==="right"?"a1bisd08":i==="top"?"a1u9y2aj":"a1qqaks",bo=({children:i,style:e,className:t,enabled:n=!0,hiding:s,direction:r="left",onAnimationEnd:a})=>z.jsx(Jf,{style:e,className:W.cx_default(t,Zf,am(r),n&&!s&&sm(r),n&&s&&rm(r)),onAnimationEnd:a,children:i}),om=W.styled_default("a")({name:"Link",class:"l1sgte8c",propsAsIs:!1}),lm=W.styled_default("div")({name:"BannerContainer",class:"b7yfc72",propsAsIs:!1}),um=()=>om,dm=W.styled_default(um())({name:"BannerLink",class:"bejjq94",propsAsIs:!0}),Od=({promotion:i,promotionId:e,hiding:t,isEventFired:n,fireEvent:s,direction:r="bottom"})=>{const a=(i==null?void 0:i.adUnit)===ue.AdUnit.STANDART,l=a?i.banner:i.additionalBanner;if(_e.useEffect(()=>{l!=null&&l.imageUrl&&i.type&&e&&(n!=null&&n("banner-showed")||(W.eventBus.emit("advertisement",{action:"bannerShown",payload:{id:e,type:i.type}}),s==null||s("banner-showed")))},[l==null?void 0:l.imageUrl,s,n,i.type,e]),!(l!=null&&l.imageUrl))return null;let c=l==null?void 0:l.url;return c&&c.indexOf("http")!==0&&(c=`https://${c}`),z.jsx(bo,{direction:r,hiding:t,children:z.jsx(lm,{className:"BannerContainer","data-is-ad":a,children:z.jsx(dm,{as:c?"a":"span",className:"BannerLink",href:c,style:{backgroundImage:`url(${l.imageUrl})`,cursor:c?"pointer":"default"},"data-promo-id":e,"data-promo-type":i.type,"data-a":"banner",target:"_blank","data-is-ad":a})})})},hm=({cardId:i,promotion:e,direction:t="bottom"})=>z.jsx(Od,{promotion:e,promotionId:i,direction:t,hiding:!1}),cm=W.styled_default("div")({name:"NotificationContent",class:"n18wsqoo",propsAsIs:!1}),pm=W.styled_default("div")({name:"Body",class:"b1ia90c2",propsAsIs:!1}),gm=W.styled_default("div")({name:"Title",class:"tg2z08v",propsAsIs:!1}),fm=W.styled_default("div")({name:"Text",class:"t59zdk1",propsAsIs:!1}),To=W.styled_default("div")({name:"MediaImgBottom",class:"m1ab9fq",propsAsIs:!1}),mm=()=>To,ym=W.styled_default(mm())({name:"MediaImgMiddle",class:"m9fsr0y",propsAsIs:!0}),iu=W.styled_default("img")({name:"CtaIcon",class:"cvi9y5q",propsAsIs:!1}),_m=W.styled_default("div")({name:"Logo",class:"l5mq0z",propsAsIs:!1}),bm=W.styled_default("div")({name:"Footer",class:"f1mse0ft",propsAsIs:!1}),Tm=W.styled_default("div")({name:"Vector",class:"v1hcloah",propsAsIs:!1}),vm=W.styled_default("div")({name:"NotificationContainer",class:"n3n65jf",propsAsIs:!1}),Md=W.styled_default("button")({name:"TVButton",class:"tkkfuqy",propsAsIs:!1}),Sm=()=>Md,Em=W.styled_default(Sm())({name:"DismissButton",class:"dh9vato",propsAsIs:!0}),wm=()=>Md,Rd=W.styled_default(wm())({name:"OpenButton",class:"oeah8gv",propsAsIs:!0}),km={[ue.NotificationPromotionImagePosition.BOTTOM]:To,[ue.NotificationPromotionImagePosition.MIDDLE]:ym},Cm=({src:i,imagePosition:e})=>{const t=km[e]||To;return z.jsx(t,{children:z.jsx("img",{src:i,alt:""})})},Im=W.O(Em),xm=W.O(Rd),Am=({notification:i,open:e,close:t,webos:n})=>{if(!i||!i.promotion||i.enabled!==ue.NotificationEnabled.NOTIFICATION_ENABLED)return null;const{title:s,body:r,image:a,promotion:l}=i,{sponsorLogo:c,sponsorLogoMode:f,imagePosition:m,ctaButton:b}=l;return z.jsxs(vm,{"data-webos":n,className:"SL_Lower_Third_Notification",onClick:n?void 0:e,children:[z.jsxs(cm,{children:[z.jsx(Cm,{src:a,imagePosition:m}),z.jsxs(pm,{children:[s&&z.jsx(gm,{children:s}),r&&z.jsx(fm,{children:r})]})]}),z.jsxs(bm,{children:[f!==ue.NotificationSponsorLogoMode.NOTIFICATION_SPONSOR_LOGO_NONE&&z.jsxs(z.Fragment,{children:[z.jsx(_m,{children:z.jsx("img",{src:c,alt:s})}),z.jsx(Tm,{})]}),n?z.jsxs(z.Fragment,{children:[z.jsx(Im,{webos:!0,onClick:t,children:"Dismiss"}),z.jsxs(xm,{webos:!0,autoFocus:!0,style:{color:b==null?void 0:b.textColor,backgroundColor:b==null?void 0:b.color},onClick:e,children:[(b==null?void 0:b.ctaIcon)&&(b==null?void 0:b.ctaIconMode)===ue.CtaIconMode.CTA_ICON_TRANSPARENT&&z.jsx(iu,{src:b==null?void 0:b.ctaIcon,alt:"cta-icon"}),(b==null?void 0:b.label)||"Open"]})]}):z.jsxs(Rd,{name:"promo-button",style:{color:b==null?void 0:b.textColor,backgroundColor:b==null?void 0:b.color},children:[(b==null?void 0:b.ctaIcon)&&(b==null?void 0:b.ctaIconMode)===ue.CtaIconMode.CTA_ICON_TRANSPARENT&&z.jsx(iu,{src:b==null?void 0:b.ctaIcon,alt:"cta-icon"}),(b==null?void 0:b.label)||"Open"]})]})]})},Pm=W.styled_default("div")({name:"NotificationContent",class:"n1ku6hz",propsAsIs:!1}),Lm=W.styled_default("div")({name:"NotificationContainer",class:"nbxqmol",propsAsIs:!1}),Dm=W.styled_default("div")({name:"Body",class:"b1gu3eml",propsAsIs:!1}),Om=W.styled_default("div")({name:"Title",class:"t1u17zva",propsAsIs:!1}),Mm=W.styled_default("div")({name:"Text",class:"t10ko1g",propsAsIs:!1}),Lr=W.styled_default("div")({name:"Media",class:"mntc42e",propsAsIs:!1}),Rm=()=>Lr,nu=W.styled_default(Rm())({name:"MediaImgFit",class:"ml060eo",propsAsIs:!0}),Um=()=>Lr,Ud=W.styled_default(Um())({name:"MediaImgCentered",class:"m1vqlvig",propsAsIs:!0}),Nm=()=>Ud,Bm=W.styled_default(Nm())({name:"MediaImgBottom",class:"m1e7tvi5",propsAsIs:!0}),Fm=()=>Lr,jm=W.styled_default(Fm())({name:"MediaImgSolid",class:"mqvntt2",propsAsIs:!0}),$m=()=>Lr,qm=W.styled_default($m())({name:"MediaImgMiddle",class:"m12jtj3u",propsAsIs:!0}),Vm=W.styled_default("img")({name:"CtaIcon",class:"ckq1frv",propsAsIs:!1}),Hm=()=>W.B1,zm=W.styled_default(Hm())({name:"StyledChevronRight",class:"s9mjmz3",propsAsIs:!0}),Wm=W.styled_default("div")({name:"Logo",class:"l1cf50a7",propsAsIs:!1}),Nd=W.styled_default("button")({name:"TVButton",class:"thdqfl0",propsAsIs:!1}),Gm=()=>Nd,Xm=W.styled_default(Gm())({name:"DismissButton",class:"d11pe8bx",propsAsIs:!0}),Km=()=>Nd,Ym=W.styled_default(Km())({name:"OpenButton",class:"oy9k0kp",propsAsIs:!0}),Qm={[ue.NotificationPromotionImagePosition.UNSET]:nu,[ue.NotificationPromotionImagePosition.FIT]:nu,[ue.NotificationPromotionImagePosition.CENTERED]:Ud,[ue.NotificationPromotionImagePosition.BOTTOM]:Bm,[ue.NotificationPromotionImagePosition.SOLID]:jm,[ue.NotificationPromotionImagePosition.MIDDLE]:qm},Jm=({src:i,imagePosition:e})=>{const t=Qm[e];return z.jsx(t,{children:z.jsx("img",{src:i,alt:""})})},Zm=W.O(Xm),ey=W.O(Ym),ty=({notification:i,open:e,promotionId:t,hiding:n,direction:s="left",close:r,webos:a})=>{if(!i||!i.promotion||i.enabled!==ue.NotificationEnabled.NOTIFICATION_ENABLED)return null;if(i.promotion.mode===ue.NotificationPromotionMode.LOWER_THIRD)return z.jsx(Am,{notification:i,open:e,close:r,webos:a});const{title:l,body:c,image:f,promotion:m}=i,{sponsorLogo:b,sponsorLogoMode:C,imagePosition:w,ctaButton:A}=m,v=M=>{M.stopPropagation(),r==null||r()};return z.jsx(bo,{className:"SL_Rich_Notification",direction:s,hiding:n,children:z.jsxs(Lm,{onClick:a?()=>{}:e,children:[C!==ue.NotificationSponsorLogoMode.NOTIFICATION_SPONSOR_LOGO_NONE&&b&&z.jsx(Wm,{children:z.jsx("img",{src:b,alt:l})}),z.jsxs(Pm,{children:[z.jsx(Jm,{src:f,imagePosition:w}),z.jsxs(Dm,{children:[l&&z.jsx(Om,{children:l}),c&&z.jsx(Mm,{children:c})]}),a&&z.jsx(Zm,{webos:!0,onClick:v,children:"Dismiss"}),z.jsxs(ey,{webos:a,autoFocus:a,onClick:a?e:()=>{},name:"promo-button",style:{color:A==null?void 0:A.textColor,backgroundColor:A==null?void 0:A.color},children:[(A==null?void 0:A.ctaIcon)&&(A==null?void 0:A.ctaIconMode)===ue.CtaIconMode.CTA_ICON_TRANSPARENT&&z.jsx(Vm,{src:A==null?void 0:A.ctaIcon,alt:"cta-icon"}),(A==null?void 0:A.label)||"Open"]}),z.jsx(zm,{name:"chevronRight"})]})]})})},iy=W.styled_default("div")({name:"OverlayContainer",class:"okzhq2w",propsAsIs:!1}),Bd=W.styled_default("div")({name:"PromoOverlay",class:"pmgz5i",propsAsIs:!1}),Fd=W.styled_default("div")({name:"Header",class:"hyxi3jt",propsAsIs:!1}),jd=W.styled_default("div")({name:"HeaderContent",class:"h149e3gp",propsAsIs:!1}),$d="h10toh7",su=W.styled_default("img")({name:"SponsorLogo",class:"s1jyea6t",propsAsIs:!1}),ny=W.styled_default("div")({name:"SponsorName",class:"szpfa3h",propsAsIs:!1}),qd=W.styled_default("div")({name:"Media",class:"m1crmu01",propsAsIs:!1}),sy=W.styled_default("img")({name:"PromoImg",class:"p1l37r8s",propsAsIs:!1}),ry="s1nmch9k",ru=W.styled_default("div")({name:"Content",class:"c1er0ljd",propsAsIs:!1}),ay=W.styled_default("div")({name:"Description",class:"dydopmr",propsAsIs:!1}),oy=W.styled_default("div")({name:"Sponsor",class:"s1w6nt04",propsAsIs:!1}),ly=W.styled_default("div")({name:"SponsorText",class:"s1evcmtq",propsAsIs:!1}),Vd=W.styled_default("div")({name:"ADLogo",class:"awodx0x",propsAsIs:!1}),uy=W.styled_default("span")({name:"SponsoredText",class:"s1q3n6oi",propsAsIs:!1}),Hd=W.styled_default("div")({name:"ActionBtnWrap",class:"a8d4xfk",propsAsIs:!1}),zd=W.styled_default("a")({name:"ActionButton",class:"at6oobh",propsAsIs:!1}),dy=W.styled_default("div")({name:"Title",class:"t1gyg7tt",propsAsIs:!1}),hy="h17rwbtk",cy=W.styled_default("div")({name:"Container",class:"c10m2bce",propsAsIs:!1}),au=W.styled_default("div")({name:"Item",class:"ig23yq5",propsAsIs:!1}),py=W.styled_default("div")({name:"Dot",class:"d1f6aqua",propsAsIs:!1}),gy=({time:i,adCount:e,adPosition:t})=>{const n=Math.floor(i/60),s=i-n*60;return n===0&&s===0&&e===t?null:z.jsxs(cy,{children:[e>1&&z.jsxs(z.Fragment,{children:[z.jsxs(au,{children:[t," of ",e]}),z.jsx(py,{})]}),z.jsxs(au,{children:[n,":",s<10?`0${s}`:s]})]})},fy=W.styled_default("a")({name:"WhyThisAdLink",class:"w13o8uld",propsAsIs:!1}),my=({whyThisAd:i})=>{const[e,t]=_e.useState(!1);return!i.iconClickThroughURLTemplate||!i.staticResource?null:z.jsxs(fy,{style:{width:i.width,height:i.height,[i.xPosition]:3,[i.yPosition]:11},href:i.iconClickThroughURLTemplate,target:"_blank",rel:"noreferrer",children:[!e&&z.jsx("img",{alt:"ad choice",src:i.staticResource,onLoad:()=>t(!1),onError:()=>t(!0)}),e&&z.jsx("span",{children:"ad choice"})]})},yy=W.styled_default("div")({name:"VideoControls",class:"v1xzooj9",propsAsIs:!1}),Wd=W.styled_default("button")({name:"ControlBtn",class:"c1bo41vr",propsAsIs:!1}),_y=()=>Wd,by=W.styled_default(_y())({name:"MuteIcon",class:"m13efyu8",propsAsIs:!0}),Ty=()=>Wd,vy=W.styled_default(Ty())({name:"PauseIcon",class:"pladkgh",propsAsIs:!0}),Sy=W.styled_default("div")({name:"Container",class:"cjnga56",propsAsIs:!1}),Ey=W.styled_default("div")({name:"ControlsContainer",class:"c7qs1am",propsAsIs:!1}),ou="m12n261r",lu="m16vcml8",uu="m1078nk6",du=globalThis||void 0||self;class wy{constructor(e){this.id=e.getAttribute("id"),this.allowMultipleAds=e.getAttribute("allowMultipleAds"),this.followRedirects=e.getAttribute("followRedirects"),this.vastAdData=null,this.adTagURI=null,this.customData=null;for(const t in e.childNodes){const n=e.childNodes[t];switch(n.localName){case"AdTagURI":this.adTagURI={templateType:n.getAttribute("templateType"),uri:(n.textContent||n.text||"").trim()};break;case"VASTAdData":for(this.vastAdData=n.firstChild;this.vastAdData&&this.vastAdData.nodeType!==1;)this.vastAdData=this.vastAdData.nextSibling;break;case"CustomAdData":this.customData=n;break}}}}function Gd(i,e){const t=[];for(const n in i.childNodes){const s=i.childNodes[n];(s.nodeName===e||e===`vmap:${s.nodeName}`||s.nodeName===`vmap:${e}`)&&t.push(s)}return t}function ky(i){if(!i||!i.childNodes)return{};const e=i.childNodes,t=[];for(const s in e){const r=e[s];r.nodeName==="#cdata-section"&&t.push(r)}if(t&&t.length>0)try{return JSON.parse(t[0].data)}catch{}let n="";for(const s in e){const r=e[s];switch(r.nodeName){case"#text":n+=r.textContent.trim();break;case"#cdata-section":n+=r.data;break}}return n}function vo(i){const e={attributes:{},children:{},value:{}};e.value=ky(i);const t=i.attributes;if(t)for(const s in t){const r=t[s];r.nodeName&&r.nodeValue!==void 0&&r.nodeValue!==null&&(e.attributes[r.nodeName]=r.nodeValue)}const n=i.childNodes;if(n)for(const s in n){const r=n[s];r.nodeName&&r.nodeName.substring(0,1)!=="#"&&(e.children[r.nodeName]=vo(r))}return e}class Cy{constructor(e){this.timeOffset=e.getAttribute("timeOffset"),this.breakType=e.getAttribute("breakType"),this.breakId=e.getAttribute("breakId"),this.repeatAfter=e.getAttribute("repeatAfter"),this.adSource=null,this.trackingEvents=[],this.extensions=[];for(const t in e.childNodes){const n=e.childNodes[t];switch(n.localName){case"AdSource":this.adSource=new wy(n);break;case"TrackingEvents":for(const s in n.childNodes){const r=n.childNodes[s];r.localName==="Tracking"&&this.trackingEvents.push({event:r.getAttribute("event"),uri:(r.textContent||r.text||"").trim()})}break;case"Extensions":this.extensions=Gd(n,"Extension").map(s=>vo(s));break}}}track(e,t){for(const n in this.trackingEvents){const s=this.trackingEvents[n];if(s.event===e){let{uri:r}=s;s.event==="error"&&(r=r.replace("[ERRORCODE]",t)),this.tracker(r)}}}tracker(e){if(typeof window<"u"&&window!==null){const t=new Image;t.src=e}}}class Iy{constructor(e){if(!e||!e.documentElement||e.documentElement.localName!=="VMAP")throw new Error("Not a VMAP document");this.version=e.documentElement.getAttribute("version"),this.adBreaks=[],this.extensions=[];for(const t in e.documentElement.childNodes){const n=e.documentElement.childNodes[t];switch(n.localName){case"AdBreak":this.adBreaks.push(new Cy(n));break;case"Extensions":this.extensions=Gd(n,"Extension").map(s=>vo(s));break}}}}const xy=(i,e)=>{const t=goog.pal,n=new t.ConsentSettings;n.allowStorage=!1;const s=new t.NonceLoader(n);return async()=>{try{const r=new URL(e),a=new t.NonceRequest;let l=localStorage.getItem("sl-device-id")||Gn.v4(),c=sessionStorage.getItem("sl-ad-session-id");c||(c=Gn.v4(),sessionStorage.setItem("sl-ad-session-id",c)),Gn.validate(l)||(l=Gn.v5(`https://${l}`,Gn.v5.URL)),r.searchParams.get("url")||r.searchParams.set("url","https://streamlayer.io"),r.searchParams.get("description_url")||r.searchParams.set("description_url","https://streamlayer.io"),a.adWillAutoPlay=r.searchParams.get("vpa")==="auto",a.adWillPlayMuted=r.searchParams.get("vpmute")==="1",a.continuousPlayback=!0,a.descriptionUrl=r.searchParams.get("description_url"),a.iconsSupported=!0,a.sessionId=l,a.supportedApiFrameworks="2,7,9",a.videoHeight=i.clientHeight,a.videoWidth=i.clientWidth;const f=await s.loadNonceManager(a);return r.searchParams.get("is_lat")==="[placeholder]"&&r.searchParams.set("is_lat","1"),r.searchParams.get("rdid")==="[placeholder]"&&r.searchParams.set("rdid",l),r.searchParams.get("correlator")==="[placeholder]"&&r.searchParams.set("correlator",c),r.searchParams.set("wta","1"),r.searchParams.set("givn",f.getNonce()),{url:r,manager:f}}catch(r){console.log("AdsManager could not be started",r);return}}},Ay=new Dd.ce,Py=i=>i.creatives.find(e=>e.mediaFiles),Ly=i=>{var e;const t=i==null?void 0:i.mediaFiles;return t!=null&&t.length&&((e=t.find(n=>n.fileURL))==null?void 0:e.fileURL)||""},Xn=W.a({ads:[],autoplay:!0,muted:!1,nonceManager:void 0}),Dy=(i,e)=>{const[t,n]=_e.useState(),s=_e.useRef(Date.now()),r=_e.useRef(Date.now());return _e.useEffect(()=>{if(!e||!(i!=null&&i.current))return;const a=xy(i.current,e),l=Date.now();s.current=l,Xn.set({ads:[],autoplay:!0,muted:!1,nonceManager:void 0}),a().then(c=>{s.current===l&&c&&(n(c.url),Xn.set({ads:[],autoplay:!0,muted:!1,nonceManager:c.manager}))}).catch(c=>{console.error(c)})},[i,e]),_e.useEffect(()=>{const a=async(l,c)=>{let f=[];if(l.searchParams.get("output")==="vmap"){const w=await fetch(l.toString()),A=new DOMParser,v=await w.text(),M=A.parseFromString(v,"text/xml");f=new Iy(M).adBreaks.map(D=>D.adSource.adTagURI.uri)}else f=[l.toString()];const m=await Promise.all(f.map((w,A)=>Ay.get(w).then(v=>{if(r.current===c){const M=v.ads.find(N=>N.creatives.length>0);if(!M)return;const D=Py(M),R=Ly(D);return{creative:D,order:A,mediaFileUrl:R,ad:M,raw:v}}}))),b=l.searchParams.get("vpa")!=="click",C=l.searchParams.get("vpmute")==="1";Xn.set({...Xn.get(),ads:m.filter(w=>!!w),autoplay:b,muted:C})};if(t){const l=Date.now();r.current=l,a(t,l)}return()=>{r.current=0}},[t]),Xn},ar=globalThis||void 0||self;var or=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof du<"u"?du:typeof self<"u"?self:{};function ms(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}function Oy(i){if(i.__esModule)return i;var e=i.default;if(typeof e=="function"){var t=function n(){return this instanceof n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(i).forEach(function(n){var s=Object.getOwnPropertyDescriptor(i,n);Object.defineProperty(t,n,s.get?s:{enumerable:!0,get:function(){return i[n]}})}),t}var Zn;typeof window<"u"?Zn=window:typeof or<"u"?Zn=or:typeof self<"u"?Zn=self:Zn={};var Dr=Zn;const x=ms(Dr),My={},Ry=Object.freeze(Object.defineProperty({__proto__:null,default:My},Symbol.toStringTag,{value:"Module"})),Uy=Oy(Ry);var hu=typeof or<"u"?or:typeof window<"u"?window:{},Ny=Uy,es;typeof document<"u"?es=document:(es=hu["__GLOBAL_DOCUMENT_CACHE@4"],es||(es=hu["__GLOBAL_DOCUMENT_CACHE@4"]=Ny));var Xd=es;const G=ms(Xd);var So={exports:{}},Kd={exports:{}};(function(i){function e(){return i.exports=e=Object.assign?Object.assign.bind():function(t){for(var n=1;n<arguments.length;n++){var s=arguments[n];for(var r in s)({}).hasOwnProperty.call(s,r)&&(t[r]=s[r])}return t},i.exports.__esModule=!0,i.exports.default=i.exports,e.apply(null,arguments)}i.exports=e,i.exports.__esModule=!0,i.exports.default=i.exports})(Kd);var By=Kd.exports,Fy=$y,jy=Object.prototype.toString;function $y(i){if(!i)return!1;var e=jy.call(i);return e==="[object Function]"||typeof i=="function"&&e!=="[object RegExp]"||typeof window<"u"&&(i===window.setTimeout||i===window.alert||i===window.confirm||i===window.prompt)}function qy(i,e){var t=typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(t)return(t=t.call(i)).next.bind(t);if(Array.isArray(i)||(t=Vy(i))||e){t&&(i=t);var n=0;return function(){return n>=i.length?{done:!0}:{done:!1,value:i[n++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
2
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const W=require("react/jsx-runtime"),Jm=require("./index8.js"),Q=require("./sl-types.js"),Zm=require("./analytics.js"),Te=require("react"),qt=require("./index3.js"),re=require("./useStreamLayerApp2.js"),Or=require("./index14.js"),eg=require("./index6.js"),ur=require("./index13.js"),Lc=require("./vast-client.min.js"),Jt=require("./index15.js"),tg=require("./index7.js"),Qs=require("uuid"),Oc=require("./index-DSi8Qgfs.js"),ig=require("./utils.js"),Vt=require("./hooks-B0Qttldg.js");function je(){return je=Object.assign?Object.assign.bind():function(s){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)({}).hasOwnProperty.call(t,i)&&(s[i]=t[i])}return s},je.apply(null,arguments)}const sg=Q.styled_default("div")({name:"Container",class:"c5b6wdg",propsAsIs:!1}),ng="a1rlj479",rg="s35f1di",ag="sj4471g",og="b12050d8",lg="b1d5ybek",ug=s=>s==="left"||s==="right"?rg:og,cg=s=>s==="left"||s==="right"?ag:lg,dg=s=>s==="left"?"avdxyl3":s==="right"?"a1bisd08":s==="top"?"a1u9y2aj":"a1qqaks",xo=({children:s,style:e,className:t,enabled:i=!0,hiding:n,direction:r="left",onAnimationEnd:a})=>W.jsx(sg,{style:e,className:Q.cx_default(t,ng,dg(r),i&&!n&&ug(r),i&&n&&cg(r)),onAnimationEnd:a,children:s}),hg=Q.styled_default("a")({name:"Link",class:"l1sgte8c",propsAsIs:!1}),fg=Q.styled_default("div")({name:"BannerContainer",class:"b7yfc72",propsAsIs:!1}),pg=()=>hg,mg=Q.styled_default(pg())({name:"BannerLink",class:"bejjq94",propsAsIs:!0}),Rc=({promotion:s,promotionId:e,hiding:t,isEventFired:i,fireEvent:n,direction:r="bottom"})=>{const a=(s==null?void 0:s.adUnit)===re.AdUnit.STANDART,l=a?s.banner:s.additionalBanner;if(Te.useEffect(()=>{l!=null&&l.imageUrl&&s.type&&e&&(i!=null&&i("banner-showed")||(qt.eventBus.emit("advertisement",{action:"bannerShown",payload:{id:e,type:s.type}}),n==null||n("banner-showed")))},[l==null?void 0:l.imageUrl,n,i,s.type,e]),!(l!=null&&l.imageUrl))return null;let h=l==null?void 0:l.url;return h&&h.indexOf("http")!==0&&(h=`https://${h}`),W.jsx(xo,{direction:r,hiding:t,children:W.jsx(fg,{className:"BannerContainer","data-is-ad":a,children:W.jsx(mg,{as:h?"a":"span",className:"BannerLink",href:h,style:{backgroundImage:`url(${l.imageUrl})`,cursor:h?"pointer":"default"},"data-promo-id":e,"data-promo-type":s.type,"data-a":"banner",target:"_blank","data-is-ad":a})})})},gg=({cardId:s,promotion:e,direction:t="bottom"})=>W.jsx(Rc,{promotion:e,promotionId:s,direction:t,hiding:!1}),yg=Q.styled_default("div")({name:"NotificationContent",class:"n18wsqoo",propsAsIs:!1}),_g=Q.styled_default("div")({name:"Body",class:"b1ia90c2",propsAsIs:!1}),Tg=Q.styled_default("div")({name:"Title",class:"tg2z08v",propsAsIs:!1}),vg=Q.styled_default("div")({name:"Text",class:"t59zdk1",propsAsIs:!1}),ts=Q.styled_default("div")({name:"MediaImgBottom",class:"m1ab9fq",propsAsIs:!1}),bg=()=>ts,xg=Q.styled_default(bg())({name:"MediaImgMiddle",class:"m9fsr0y",propsAsIs:!0}),su=Q.styled_default("img")({name:"CtaIcon",class:"cvi9y5q",propsAsIs:!1}),Sg=Q.styled_default("div")({name:"Logo",class:"l5mq0z",propsAsIs:!1}),Eg=Q.styled_default("div")({name:"Footer",class:"f1mse0ft",propsAsIs:!1}),Cg=Q.styled_default("div")({name:"Vector",class:"v1hcloah",propsAsIs:!1}),wg=Q.styled_default("div")({name:"NotificationContainer",class:"n3n65jf",propsAsIs:!1}),Mc=Q.styled_default("button")({name:"TVButton",class:"tkkfuqy",propsAsIs:!1}),Ig=()=>Mc,Ag=Q.styled_default(Ig())({name:"DismissButton",class:"dh9vato",propsAsIs:!0}),kg=()=>Mc,Nc=Q.styled_default(kg())({name:"OpenButton",class:"oeah8gv",propsAsIs:!0}),Pg={[re.NotificationPromotionImagePosition.UNSET]:ts,[re.NotificationPromotionImagePosition.FIT]:ts,[re.NotificationPromotionImagePosition.CENTERED]:ts,[re.NotificationPromotionImagePosition.SOLID]:ts,[re.NotificationPromotionImagePosition.BOTTOM]:ts,[re.NotificationPromotionImagePosition.MIDDLE]:xg},Dg=({src:s,imagePosition:e})=>{const t=Pg[e];return W.jsx(t,{children:W.jsx("img",{src:s,alt:""})})},Lg=Or.O(Ag),Og=Or.O(Nc),Rg=({notification:s,open:e,close:t,webos:i})=>{if(!s||!s.promotion||s.enabled!==re.NotificationEnabled.NOTIFICATION_ENABLED)return null;const{title:n,body:r,image:a,promotion:l}=s,{sponsorLogo:h,sponsorLogoMode:f,imagePosition:m,ctaButton:T}=l;return W.jsxs(wg,{"data-webos":i,className:"SL_Lower_Third_Notification",onClick:i?void 0:e,children:[W.jsxs(yg,{children:[W.jsx(Dg,{src:a,imagePosition:m}),W.jsxs(_g,{children:[n&&W.jsx(Tg,{children:n}),r&&W.jsx(vg,{children:r})]})]}),W.jsxs(Eg,{children:[f!==re.NotificationSponsorLogoMode.NOTIFICATION_SPONSOR_LOGO_NONE&&W.jsxs(W.Fragment,{children:[W.jsx(Sg,{children:W.jsx("img",{src:h,alt:n})}),W.jsx(Cg,{})]}),i?W.jsxs(W.Fragment,{children:[W.jsx(Lg,{webos:!0,onClick:t,children:"Dismiss"}),W.jsxs(Og,{webos:!0,autoFocus:!0,style:{color:T==null?void 0:T.textColor,backgroundColor:T==null?void 0:T.color},onClick:e,children:[(T==null?void 0:T.ctaIcon)&&(T==null?void 0:T.ctaIconMode)===re.CtaIconMode.CTA_ICON_TRANSPARENT&&W.jsx(su,{src:T==null?void 0:T.ctaIcon,alt:"cta-icon"}),(T==null?void 0:T.label)||"Open"]})]}):W.jsxs(Nc,{name:"promo-button",style:{color:T==null?void 0:T.textColor,backgroundColor:T==null?void 0:T.color},children:[(T==null?void 0:T.ctaIcon)&&(T==null?void 0:T.ctaIconMode)===re.CtaIconMode.CTA_ICON_TRANSPARENT&&W.jsx(su,{src:T==null?void 0:T.ctaIcon,alt:"cta-icon"}),(T==null?void 0:T.label)||"Open"]})]})]})},Mg=Q.styled_default("div")({name:"NotificationContent",class:"n1ku6hz",propsAsIs:!1}),Ng=Q.styled_default("div")({name:"NotificationContainer",class:"nbxqmol",propsAsIs:!1}),Ug=Q.styled_default("div")({name:"Body",class:"b1gu3eml",propsAsIs:!1}),Bg=Q.styled_default("div")({name:"Title",class:"t1u17zva",propsAsIs:!1}),Fg=Q.styled_default("div")({name:"Text",class:"t10ko1g",propsAsIs:!1}),Rr=Q.styled_default("div")({name:"Media",class:"mntc42e",propsAsIs:!1}),$g=()=>Rr,nu=Q.styled_default($g())({name:"MediaImgFit",class:"ml060eo",propsAsIs:!0}),jg=()=>Rr,Uc=Q.styled_default(jg())({name:"MediaImgCentered",class:"m1vqlvig",propsAsIs:!0}),Vg=()=>Uc,Hg=Q.styled_default(Vg())({name:"MediaImgBottom",class:"m1e7tvi5",propsAsIs:!0}),qg=()=>Rr,zg=Q.styled_default(qg())({name:"MediaImgSolid",class:"mqvntt2",propsAsIs:!0}),Wg=()=>Rr,Gg=Q.styled_default(Wg())({name:"MediaImgMiddle",class:"m12jtj3u",propsAsIs:!0}),Kg=Q.styled_default("img")({name:"CtaIcon",class:"ckq1frv",propsAsIs:!1}),Xg=()=>eg.B1,Yg=Q.styled_default(Xg())({name:"StyledChevronRight",class:"s9mjmz3",propsAsIs:!0}),Qg=Q.styled_default("div")({name:"Logo",class:"l1cf50a7",propsAsIs:!1}),Bc=Q.styled_default("button")({name:"TVButton",class:"thdqfl0",propsAsIs:!1}),Jg=()=>Bc,Zg=Q.styled_default(Jg())({name:"DismissButton",class:"d11pe8bx",propsAsIs:!0}),e0=()=>Bc,t0=Q.styled_default(e0())({name:"OpenButton",class:"oy9k0kp",propsAsIs:!0}),i0={[re.NotificationPromotionImagePosition.UNSET]:nu,[re.NotificationPromotionImagePosition.FIT]:nu,[re.NotificationPromotionImagePosition.CENTERED]:Uc,[re.NotificationPromotionImagePosition.BOTTOM]:Hg,[re.NotificationPromotionImagePosition.SOLID]:zg,[re.NotificationPromotionImagePosition.MIDDLE]:Gg},s0=({src:s,imagePosition:e})=>{const t=i0[e];return W.jsx(t,{children:W.jsx("img",{src:s,alt:""})})},n0=Or.O(Zg),r0=Or.O(t0),a0=({notification:s,open:e,promotionId:t,hiding:i,direction:n="left",close:r,webos:a})=>{if(!s||!s.promotion||s.enabled!==re.NotificationEnabled.NOTIFICATION_ENABLED)return null;if(s.promotion.mode===re.NotificationPromotionMode.LOWER_THIRD)return W.jsx(Rg,{notification:s,open:e,close:r,webos:a});const{title:l,body:h,image:f,promotion:m}=s,{sponsorLogo:T,sponsorLogoMode:E,imagePosition:C,ctaButton:P}=m,v=R=>{R.stopPropagation(),r==null||r()};return W.jsx(xo,{className:"SL_Rich_Notification",direction:n,hiding:i,children:W.jsxs(Ng,{onClick:a?()=>{}:e,children:[E!==re.NotificationSponsorLogoMode.NOTIFICATION_SPONSOR_LOGO_NONE&&T&&W.jsx(Qg,{children:W.jsx("img",{src:T,alt:l})}),W.jsxs(Mg,{children:[W.jsx(s0,{src:f,imagePosition:C}),W.jsxs(Ug,{children:[l&&W.jsx(Bg,{children:l}),h&&W.jsx(Fg,{children:h})]}),a&&W.jsx(n0,{webos:!0,onClick:v,children:"Dismiss"}),W.jsxs(r0,{webos:a,autoFocus:a,onClick:a?e:()=>{},name:"promo-button",style:{color:P==null?void 0:P.textColor,backgroundColor:P==null?void 0:P.color},children:[(P==null?void 0:P.ctaIcon)&&(P==null?void 0:P.ctaIconMode)===re.CtaIconMode.CTA_ICON_TRANSPARENT&&W.jsx(Kg,{src:P==null?void 0:P.ctaIcon,alt:"cta-icon"}),(P==null?void 0:P.label)||"Open"]}),W.jsx(Yg,{name:"chevronRight"})]})]})})},o0=Q.styled_default("div")({name:"OverlayContainer",class:"okzhq2w",propsAsIs:!1}),Fc=Q.styled_default("div")({name:"PromoOverlay",class:"pmgz5i",propsAsIs:!1}),$c=Q.styled_default("div")({name:"Header",class:"hyxi3jt",propsAsIs:!1}),jc=Q.styled_default("div")({name:"HeaderContent",class:"h149e3gp",propsAsIs:!1}),Vc="h10toh7",ru=Q.styled_default("img")({name:"SponsorLogo",class:"s1jyea6t",propsAsIs:!1}),l0=Q.styled_default("div")({name:"SponsorName",class:"szpfa3h",propsAsIs:!1}),Hc=Q.styled_default("div")({name:"Media",class:"m1crmu01",propsAsIs:!1}),u0=Q.styled_default("img")({name:"PromoImg",class:"p1l37r8s",propsAsIs:!1}),c0="s1nmch9k",au=Q.styled_default("div")({name:"Content",class:"c1er0ljd",propsAsIs:!1}),d0=Q.styled_default("div")({name:"Description",class:"dydopmr",propsAsIs:!1}),h0=Q.styled_default("div")({name:"Sponsor",class:"s1w6nt04",propsAsIs:!1}),f0=Q.styled_default("div")({name:"SponsorText",class:"s1evcmtq",propsAsIs:!1}),qc=Q.styled_default("div")({name:"ADLogo",class:"awodx0x",propsAsIs:!1}),p0=Q.styled_default("span")({name:"SponsoredText",class:"s1q3n6oi",propsAsIs:!1}),zc=Q.styled_default("div")({name:"ActionBtnWrap",class:"a8d4xfk",propsAsIs:!1}),Wc=Q.styled_default("a")({name:"ActionButton",class:"at6oobh",propsAsIs:!1}),m0=Q.styled_default("div")({name:"Title",class:"t1gyg7tt",propsAsIs:!1}),g0="h17rwbtk",y0=Q.styled_default("div")({name:"Container",class:"c10m2bce",propsAsIs:!1}),ou=Q.styled_default("div")({name:"Item",class:"ig23yq5",propsAsIs:!1}),_0=Q.styled_default("div")({name:"Dot",class:"d1f6aqua",propsAsIs:!1}),T0=({time:s,adCount:e,adPosition:t})=>{const i=Math.floor(s/60),n=s-i*60;return i===0&&n===0&&e===t?null:W.jsxs(y0,{children:[e>1&&W.jsxs(W.Fragment,{children:[W.jsxs(ou,{children:[t," of ",e]}),W.jsx(_0,{})]}),W.jsxs(ou,{children:[i,":",n<10?`0${n}`:n]})]})},v0=Q.styled_default("a")({name:"WhyThisAdLink",class:"w13o8uld",propsAsIs:!1}),b0=({whyThisAd:s})=>{const[e,t]=Te.useState(!1);return!s.iconClickThroughURLTemplate||!s.staticResource?null:W.jsxs(v0,{style:{width:s.width,height:s.height,[s.xPosition]:3,[s.yPosition]:11},href:s.iconClickThroughURLTemplate,target:"_blank",rel:"noreferrer",children:[!e&&W.jsx("img",{alt:"ad choice",src:s.staticResource,onLoad:()=>t(!1),onError:()=>t(!0)}),e&&W.jsx("span",{children:"ad choice"})]})},x0=Q.styled_default("div")({name:"VideoControls",class:"v1xzooj9",propsAsIs:!1}),Gc=Q.styled_default("button")({name:"ControlBtn",class:"c1bo41vr",propsAsIs:!1}),S0=()=>Gc,E0=Q.styled_default(S0())({name:"MuteIcon",class:"m13efyu8",propsAsIs:!0}),C0=()=>Gc,w0=Q.styled_default(C0())({name:"PauseIcon",class:"pladkgh",propsAsIs:!0}),I0=Q.styled_default("div")({name:"Container",class:"cjnga56",propsAsIs:!1}),A0=Q.styled_default("div")({name:"ControlsContainer",class:"c7qs1am",propsAsIs:!1}),lu="m12n261r",uu="m16vcml8",cu="m1078nk6";var nn;typeof window<"u"?nn=window:typeof Jt.commonjsGlobal<"u"?nn=Jt.commonjsGlobal:typeof self<"u"?nn=self:nn={};var Mr=nn;const k=Jt.getDefaultExportFromCjs(Mr),k0={},P0=Object.freeze(Object.defineProperty({__proto__:null,default:k0},Symbol.toStringTag,{value:"Module"})),D0=Jt.getAugmentedNamespace(P0);var du=typeof Jt.commonjsGlobal<"u"?Jt.commonjsGlobal:typeof window<"u"?window:{},L0=D0,rn;typeof document<"u"?rn=document:(rn=du["__GLOBAL_DOCUMENT_CACHE@4"],rn||(rn=du["__GLOBAL_DOCUMENT_CACHE@4"]=L0));var Kc=rn;const K=Jt.getDefaultExportFromCjs(Kc);var So={exports:{}},Xc={exports:{}};(function(s){function e(){return s.exports=e=Object.assign?Object.assign.bind():function(t){for(var i=1;i<arguments.length;i++){var n=arguments[i];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},s.exports.__esModule=!0,s.exports.default=s.exports,e.apply(null,arguments)}s.exports=e,s.exports.__esModule=!0,s.exports.default=s.exports})(Xc);var O0=Xc.exports,R0=N0,M0=Object.prototype.toString;function N0(s){if(!s)return!1;var e=M0.call(s);return e==="[object Function]"||typeof s=="function"&&e!=="[object RegExp]"||typeof window<"u"&&(s===window.setTimeout||s===window.alert||s===window.confirm||s===window.prompt)}function U0(s,e){var t=typeof Symbol<"u"&&s[Symbol.iterator]||s["@@iterator"];if(t)return(t=t.call(s)).next.bind(t);if(Array.isArray(s)||(t=B0(s))||e){t&&(s=t);var i=0;return function(){return i>=s.length?{done:!0}:{done:!1,value:s[i++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
2
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function B0(s,e){if(s){if(typeof s=="string")return hu(s,e);var t=Object.prototype.toString.call(s).slice(8,-1);if(t==="Object"&&s.constructor&&(t=s.constructor.name),t==="Map"||t==="Set")return Array.from(s);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return hu(s,e)}}function hu(s,e){(e==null||e>s.length)&&(e=s.length);for(var t=0,i=new Array(e);t<e;t++)i[t]=s[t];return i}var F0=function(){function s(){this.typeToInterceptorsMap_=new Map,this.enabled_=!1}var e=s.prototype;return e.getIsEnabled=function(){return this.enabled_},e.enable=function(){this.enabled_=!0},e.disable=function(){this.enabled_=!1},e.reset=function(){this.typeToInterceptorsMap_=new Map,this.enabled_=!1},e.addInterceptor=function(i,n){this.typeToInterceptorsMap_.has(i)||this.typeToInterceptorsMap_.set(i,new Set);var r=this.typeToInterceptorsMap_.get(i);return r.has(n)?!1:(r.add(n),!0)},e.removeInterceptor=function(i,n){var r=this.typeToInterceptorsMap_.get(i);return r&&r.has(n)?(r.delete(n),!0):!1},e.clearInterceptorsByType=function(i){var n=this.typeToInterceptorsMap_.get(i);return n?(this.typeToInterceptorsMap_.delete(i),this.typeToInterceptorsMap_.set(i,new Set),!0):!1},e.clear=function(){return this.typeToInterceptorsMap_.size?(this.typeToInterceptorsMap_=new Map,!0):!1},e.getForType=function(i){return this.typeToInterceptorsMap_.get(i)||new Set},e.execute=function(i,n){for(var r=this.getForType(i),a=U0(r),l;!(l=a()).done;){var h=l.value;try{n=h(n)}catch{}}return n},s}(),$0=F0,j0=function(){function s(){this.maxAttempts_=1,this.delayFactor_=.1,this.fuzzFactor_=.1,this.initialDelay_=1e3,this.enabled_=!1}var e=s.prototype;return e.getIsEnabled=function(){return this.enabled_},e.enable=function(){this.enabled_=!0},e.disable=function(){this.enabled_=!1},e.reset=function(){this.maxAttempts_=1,this.delayFactor_=.1,this.fuzzFactor_=.1,this.initialDelay_=1e3,this.enabled_=!1},e.getMaxAttempts=function(){return this.maxAttempts_},e.setMaxAttempts=function(i){this.maxAttempts_=i},e.getDelayFactor=function(){return this.delayFactor_},e.setDelayFactor=function(i){this.delayFactor_=i},e.getFuzzFactor=function(){return this.fuzzFactor_},e.setFuzzFactor=function(i){this.fuzzFactor_=i},e.getInitialDelay=function(){return this.initialDelay_},e.setInitialDelay=function(i){this.initialDelay_=i},e.createRetry=function(i){var n=i===void 0?{}:i,r=n.maxAttempts,a=n.delayFactor,l=n.fuzzFactor,h=n.initialDelay;return new V0({maxAttempts:r||this.maxAttempts_,delayFactor:a||this.delayFactor_,fuzzFactor:l||this.fuzzFactor_,initialDelay:h||this.initialDelay_})},s}(),V0=function(){function s(t){this.maxAttempts_=t.maxAttempts,this.delayFactor_=t.delayFactor,this.fuzzFactor_=t.fuzzFactor,this.currentDelay_=t.initialDelay,this.currentAttempt_=1}var e=s.prototype;return e.moveToNextAttempt=function(){this.currentAttempt_++;var i=this.currentDelay_*this.delayFactor_;this.currentDelay_=this.currentDelay_+i},e.shouldRetry=function(){return this.currentAttempt_<this.maxAttempts_},e.getCurrentDelay=function(){return this.currentDelay_},e.getCurrentMinPossibleDelay=function(){return(1-this.fuzzFactor_)*this.currentDelay_},e.getCurrentMaxPossibleDelay=function(){return(1+this.fuzzFactor_)*this.currentDelay_},e.getCurrentFuzzedDelay=function(){var i=this.getCurrentMinPossibleDelay(),n=this.getCurrentMaxPossibleDelay();return i+Math.random()*(n-i)},s}(),H0=j0,q0=Mr,z0=function(e,t){return t===void 0&&(t=!1),function(i,n,r){if(i){e(i);return}if(n.statusCode>=400&&n.statusCode<=599){var a=r;if(t)if(q0.TextDecoder){var l=W0(n.headers&&n.headers["content-type"]);try{a=new TextDecoder(l).decode(r)}catch{}}else a=String.fromCharCode.apply(null,new Uint8Array(r));e({cause:a});return}e(null,r)}};function W0(s){return s===void 0&&(s=""),s.toLowerCase().split(";").reduce(function(e,t){var i=t.split("="),n=i[0],r=i[1];return n.trim()==="charset"?r.trim():e},"utf-8")}var G0=z0,Yc=Mr,K0=O0,X0=R0,Qc=$0,Y0=H0;$e.httpHandler=G0;$e.requestInterceptorsStorage=new Qc;$e.responseInterceptorsStorage=new Qc;$e.retryManager=new Y0;/**
|
|
3
3
|
* @license
|
|
4
4
|
* slighly modified parse-headers 2.0.2 <https://github.com/kesla/parse-headers/>
|
|
5
5
|
* Copyright (c) 2014 David Björklund
|
|
6
6
|
* Available under the MIT license
|
|
7
7
|
* <https://github.com/kesla/parse-headers/blob/master/LICENCE>
|
|
8
|
-
*/var
|
|
9
|
-
`).forEach(function(t){var n=t.indexOf(":"),s=t.slice(0,n).trim().toLowerCase(),r=t.slice(n+1).trim();typeof e[s]>"u"?e[s]=r:Array.isArray(e[s])?e[s].push(r):e[s]=[e[s],r]}),e};So.exports=Fe;So.exports.default=Fe;Fe.XMLHttpRequest=Yd.XMLHttpRequest||a_;Fe.XDomainRequest="withCredentials"in new Fe.XMLHttpRequest?Fe.XMLHttpRequest:Yd.XDomainRequest;n_(["get","put","post","patch","head","delete"],function(i){Fe[i==="delete"?"del":i]=function(e,t,n){return t=Jd(e,t,n),t.method=i.toUpperCase(),Eo(t)}});function n_(i,e){for(var t=0;t<i.length;t++)e(i[t])}function s_(i){for(var e in i)if(i.hasOwnProperty(e))return!1;return!0}function Jd(i,e,t){var n=i;return e_(e)?(t=e,typeof i=="string"&&(n={uri:i})):n=Zy({},e,{uri:i}),n.callback=t,n}function Fe(i,e,t){return e=Jd(i,e,t),Eo(e)}function Eo(i){if(typeof i.callback>"u")throw new Error("callback argument missing");if(i.requestType&&Fe.requestInterceptorsStorage.getIsEnabled()){var e={uri:i.uri||i.url,headers:i.headers||{},body:i.body,metadata:i.metadata||{},retry:i.retry,timeout:i.timeout},t=Fe.requestInterceptorsStorage.execute(i.requestType,e);i.uri=t.uri,i.headers=t.headers,i.body=t.body,i.metadata=t.metadata,i.retry=t.retry,i.timeout=t.timeout}var n=!1,s=function(F,P,$){n||(n=!0,i.callback(F,P,$))};function r(){f.readyState===4&&!Fe.responseInterceptorsStorage.getIsEnabled()&&setTimeout(c,0)}function a(){var F=void 0;if(f.response?F=f.response:F=f.responseText||r_(f),D)try{F=JSON.parse(F)}catch{}return F}function l(F){if(clearTimeout(R),clearTimeout(i.retryTimeout),F instanceof Error||(F=new Error(""+(F||"Unknown XMLHttpRequest Error"))),F.statusCode=0,!b&&Fe.retryManager.getIsEnabled()&&i.retry&&i.retry.shouldRetry()){i.retryTimeout=setTimeout(function(){i.retry.moveToNextAttempt(),i.xhr=f,Eo(i)},i.retry.getCurrentFuzzedDelay());return}if(i.requestType&&Fe.responseInterceptorsStorage.getIsEnabled()){var P={headers:N.headers||{},body:N.body,responseUrl:f.responseURL,responseType:f.responseType},$=Fe.responseInterceptorsStorage.execute(i.requestType,P);N.body=$.body,N.headers=$.headers}return s(F,N)}function c(){if(!b){var F;clearTimeout(R),clearTimeout(i.retryTimeout),i.useXDR&&f.status===void 0?F=200:F=f.status===1223?204:f.status;var P=N,$=null;if(F!==0?(P={body:a(),statusCode:F,method:w,headers:{},url:C,rawRequest:f},f.getAllResponseHeaders&&(P.headers=i_(f.getAllResponseHeaders()))):$=new Error("Internal XMLHttpRequest Error"),i.requestType&&Fe.responseInterceptorsStorage.getIsEnabled()){var Y={headers:P.headers||{},body:P.body,responseUrl:f.responseURL,responseType:f.responseType},X=Fe.responseInterceptorsStorage.execute(i.requestType,Y);P.body=X.body,P.headers=X.headers}return s($,P,P.body)}}var f=i.xhr||null;f||(i.cors||i.useXDR?f=new Fe.XDomainRequest:f=new Fe.XMLHttpRequest);var m,b,C=f.url=i.uri||i.url,w=f.method=i.method||"GET",A=i.body||i.data,v=f.headers=i.headers||{},M=!!i.sync,D=!1,R,N={body:void 0,headers:{},statusCode:0,method:w,url:C,rawRequest:f};if("json"in i&&i.json!==!1&&(D=!0,v.accept||v.Accept||(v.Accept="application/json"),w!=="GET"&&w!=="HEAD"&&(v["content-type"]||v["Content-Type"]||(v["Content-Type"]="application/json"),A=JSON.stringify(i.json===!0?A:i.json))),f.onreadystatechange=r,f.onload=c,f.onerror=l,f.onprogress=function(){},f.onabort=function(){b=!0,clearTimeout(i.retryTimeout)},f.ontimeout=l,f.open(w,C,!M,i.username,i.password),M||(f.withCredentials=!!i.withCredentials),!M&&i.timeout>0&&(R=setTimeout(function(){if(!b){b=!0,f.abort("timeout");var F=new Error("XMLHttpRequest timeout");F.code="ETIMEDOUT",l(F)}},i.timeout)),f.setRequestHeader)for(m in v)v.hasOwnProperty(m)&&f.setRequestHeader(m,v[m]);else if(i.headers&&!s_(i.headers))throw new Error("Headers cannot be set on an XDomainRequest object");return"responseType"in i&&(f.responseType=i.responseType),"beforeSend"in i&&typeof i.beforeSend=="function"&&i.beforeSend(f),f.send(A||null),f}function r_(i){try{if(i.responseType==="document")return i.responseXML;var e=i.responseXML&&i.responseXML.documentElement.nodeName==="parsererror";if(i.responseType===""&&!e)return i.responseXML}catch{}return null}function a_(){}var o_=So.exports;const Zd=ms(o_);var eh={exports:{}},pu=Xd,wo=Object.create||function(){function i(){}return function(e){if(arguments.length!==1)throw new Error("Object.create shim only accepts one parameter.");return i.prototype=e,new i}}();function Tt(i,e){this.name="ParsingError",this.code=i.code,this.message=e||i.message}Tt.prototype=wo(Error.prototype);Tt.prototype.constructor=Tt;Tt.Errors={BadSignature:{code:0,message:"Malformed WebVTT signature."},BadTimeStamp:{code:1,message:"Malformed time stamp."}};function ko(i){function e(n,s,r,a){return(n|0)*3600+(s|0)*60+(r|0)+(a|0)/1e3}var t=i.match(/^(\d+):(\d{1,2})(:\d{1,2})?\.(\d{3})/);return t?t[3]?e(t[1],t[2],t[3].replace(":",""),t[4]):t[1]>59?e(t[1],t[2],0,t[4]):e(0,t[1],t[2],t[4]):null}function rs(){this.values=wo(null)}rs.prototype={set:function(i,e){!this.get(i)&&e!==""&&(this.values[i]=e)},get:function(i,e,t){return t?this.has(i)?this.values[i]:e[t]:this.has(i)?this.values[i]:e},has:function(i){return i in this.values},alt:function(i,e,t){for(var n=0;n<t.length;++n)if(e===t[n]){this.set(i,e);break}},integer:function(i,e){/^-?\d+$/.test(e)&&this.set(i,parseInt(e,10))},percent:function(i,e){return e.match(/^([\d]{1,3})(\.[\d]*)?%$/)&&(e=parseFloat(e),e>=0&&e<=100)?(this.set(i,e),!0):!1}};function ts(i,e,t,n){var s=n?i.split(n):[i];for(var r in s)if(typeof s[r]=="string"){var a=s[r].split(t);if(a.length===2){var l=a[0].trim(),c=a[1].trim();e(l,c)}}}function l_(i,e,t){var n=i;function s(){var l=ko(i);if(l===null)throw new Tt(Tt.Errors.BadTimeStamp,"Malformed timestamp: "+n);return i=i.replace(/^[^\sa-zA-Z-]+/,""),l}function r(l,c){var f=new rs;ts(l,function(m,b){switch(m){case"region":for(var C=t.length-1;C>=0;C--)if(t[C].id===b){f.set(m,t[C].region);break}break;case"vertical":f.alt(m,b,["rl","lr"]);break;case"line":var w=b.split(","),A=w[0];f.integer(m,A),f.percent(m,A)&&f.set("snapToLines",!1),f.alt(m,A,["auto"]),w.length===2&&f.alt("lineAlign",w[1],["start","center","end"]);break;case"position":w=b.split(","),f.percent(m,w[0]),w.length===2&&f.alt("positionAlign",w[1],["start","center","end"]);break;case"size":f.percent(m,b);break;case"align":f.alt(m,b,["start","center","end","left","right"]);break}},/:/,/\s/),c.region=f.get("region",null),c.vertical=f.get("vertical","");try{c.line=f.get("line","auto")}catch{}c.lineAlign=f.get("lineAlign","start"),c.snapToLines=f.get("snapToLines",!0),c.size=f.get("size",100);try{c.align=f.get("align","center")}catch{c.align=f.get("align","middle")}try{c.position=f.get("position","auto")}catch{c.position=f.get("position",{start:0,left:0,center:50,middle:50,end:100,right:100},c.align)}c.positionAlign=f.get("positionAlign",{start:"start",left:"start",center:"center",middle:"center",end:"end",right:"end"},c.align)}function a(){i=i.replace(/^\s+/,"")}if(a(),e.startTime=s(),a(),i.substr(0,3)!=="-->")throw new Tt(Tt.Errors.BadTimeStamp,"Malformed time stamp (time stamps must be separated by '-->'): "+n);i=i.substr(3),a(),e.endTime=s(),a(),r(i,e)}var wa=pu.createElement&&pu.createElement("textarea"),u_={c:"span",i:"i",b:"b",u:"u",ruby:"ruby",rt:"rt",v:"span",lang:"span"},gu={white:"rgba(255,255,255,1)",lime:"rgba(0,255,0,1)",cyan:"rgba(0,255,255,1)",red:"rgba(255,0,0,1)",yellow:"rgba(255,255,0,1)",magenta:"rgba(255,0,255,1)",blue:"rgba(0,0,255,1)",black:"rgba(0,0,0,1)"},d_={v:"title",lang:"lang"},fu={rt:"ruby"};function th(i,e){function t(){if(!e)return null;function A(M){return e=e.substr(M.length),M}var v=e.match(/^([^<]*)(<[^>]*>?)?/);return A(v[1]?v[1]:v[2])}function n(A){return wa.innerHTML=A,A=wa.textContent,wa.textContent="",A}function s(A,v){return!fu[v.localName]||fu[v.localName]===A.localName}function r(A,v){var M=u_[A];if(!M)return null;var D=i.document.createElement(M),R=d_[A];return R&&v&&(D[R]=v.trim()),D}for(var a=i.document.createElement("div"),l=a,c,f=[];(c=t())!==null;){if(c[0]==="<"){if(c[1]==="/"){f.length&&f[f.length-1]===c.substr(2).replace(">","")&&(f.pop(),l=l.parentNode);continue}var m=ko(c.substr(1,c.length-2)),b;if(m){b=i.document.createProcessingInstruction("timestamp",m),l.appendChild(b);continue}var C=c.match(/^<([^.\s/0-9>]+)(\.[^\s\\>]+)?([^>\\]+)?(\\?)>?$/);if(!C||(b=r(C[1],C[3]),!b)||!s(l,b))continue;if(C[2]){var w=C[2].split(".");w.forEach(function(A){var v=/^bg_/.test(A),M=v?A.slice(3):A;if(gu.hasOwnProperty(M)){var D=v?"background-color":"color",R=gu[M];b.style[D]=R}}),b.className=w.join(" ")}f.push(C[1]),l.appendChild(b),l=b;continue}l.appendChild(i.document.createTextNode(n(c)))}return a}var mu=[[1470,1470],[1472,1472],[1475,1475],[1478,1478],[1488,1514],[1520,1524],[1544,1544],[1547,1547],[1549,1549],[1563,1563],[1566,1610],[1645,1647],[1649,1749],[1765,1766],[1774,1775],[1786,1805],[1807,1808],[1810,1839],[1869,1957],[1969,1969],[1984,2026],[2036,2037],[2042,2042],[2048,2069],[2074,2074],[2084,2084],[2088,2088],[2096,2110],[2112,2136],[2142,2142],[2208,2208],[2210,2220],[8207,8207],[64285,64285],[64287,64296],[64298,64310],[64312,64316],[64318,64318],[64320,64321],[64323,64324],[64326,64449],[64467,64829],[64848,64911],[64914,64967],[65008,65020],[65136,65140],[65142,65276],[67584,67589],[67592,67592],[67594,67637],[67639,67640],[67644,67644],[67647,67669],[67671,67679],[67840,67867],[67872,67897],[67903,67903],[67968,68023],[68030,68031],[68096,68096],[68112,68115],[68117,68119],[68121,68147],[68160,68167],[68176,68184],[68192,68223],[68352,68405],[68416,68437],[68440,68466],[68472,68479],[68608,68680],[126464,126467],[126469,126495],[126497,126498],[126500,126500],[126503,126503],[126505,126514],[126516,126519],[126521,126521],[126523,126523],[126530,126530],[126535,126535],[126537,126537],[126539,126539],[126541,126543],[126545,126546],[126548,126548],[126551,126551],[126553,126553],[126555,126555],[126557,126557],[126559,126559],[126561,126562],[126564,126564],[126567,126570],[126572,126578],[126580,126583],[126585,126588],[126590,126590],[126592,126601],[126603,126619],[126625,126627],[126629,126633],[126635,126651],[1114109,1114109]];function h_(i){for(var e=0;e<mu.length;e++){var t=mu[e];if(i>=t[0]&&i<=t[1])return!0}return!1}function c_(i){var e=[],t="",n;if(!i||!i.childNodes)return"ltr";function s(l,c){for(var f=c.childNodes.length-1;f>=0;f--)l.push(c.childNodes[f])}function r(l){if(!l||!l.length)return null;var c=l.pop(),f=c.textContent||c.innerText;if(f){var m=f.match(/^.*(\n|\r)/);return m?(l.length=0,m[0]):f}if(c.tagName==="ruby")return r(l);if(c.childNodes)return s(l,c),r(l)}for(s(e,i);t=r(e);)for(var a=0;a<t.length;a++)if(n=t.charCodeAt(a),h_(n))return"rtl";return"ltr"}function p_(i){if(typeof i.line=="number"&&(i.snapToLines||i.line>=0&&i.line<=100))return i.line;if(!i.track||!i.track.textTrackList||!i.track.textTrackList.mediaElement)return-1;for(var e=i.track,t=e.textTrackList,n=0,s=0;s<t.length&&t[s]!==e;s++)t[s].mode==="showing"&&n++;return++n*-1}function Or(){}Or.prototype.applyStyles=function(i,e){e=e||this.div;for(var t in i)i.hasOwnProperty(t)&&(e.style[t]=i[t])};Or.prototype.formatStyle=function(i,e){return i===0?0:i+e};function lr(i,e,t){Or.call(this),this.cue=e,this.cueDiv=th(i,e.text);var n={color:"rgba(255, 255, 255, 1)",backgroundColor:"rgba(0, 0, 0, 0.8)",position:"relative",left:0,right:0,top:0,bottom:0,display:"inline",writingMode:e.vertical===""?"horizontal-tb":e.vertical==="lr"?"vertical-lr":"vertical-rl",unicodeBidi:"plaintext"};this.applyStyles(n,this.cueDiv),this.div=i.document.createElement("div"),n={direction:c_(this.cueDiv),writingMode:e.vertical===""?"horizontal-tb":e.vertical==="lr"?"vertical-lr":"vertical-rl",unicodeBidi:"plaintext",textAlign:e.align==="middle"?"center":e.align,font:t.font,whiteSpace:"pre-line",position:"absolute"},this.applyStyles(n),this.div.appendChild(this.cueDiv);var s=0;switch(e.positionAlign){case"start":case"line-left":s=e.position;break;case"center":s=e.position-e.size/2;break;case"end":case"line-right":s=e.position-e.size;break}e.vertical===""?this.applyStyles({left:this.formatStyle(s,"%"),width:this.formatStyle(e.size,"%")}):this.applyStyles({top:this.formatStyle(s,"%"),height:this.formatStyle(e.size,"%")}),this.move=function(r){this.applyStyles({top:this.formatStyle(r.top,"px"),bottom:this.formatStyle(r.bottom,"px"),left:this.formatStyle(r.left,"px"),right:this.formatStyle(r.right,"px"),height:this.formatStyle(r.height,"px"),width:this.formatStyle(r.width,"px")})}}lr.prototype=wo(Or.prototype);lr.prototype.constructor=lr;function ot(i){var e,t,n,s;if(i.div){t=i.div.offsetHeight,n=i.div.offsetWidth,s=i.div.offsetTop;var r=(r=i.div.childNodes)&&(r=r[0])&&r.getClientRects&&r.getClientRects();i=i.div.getBoundingClientRect(),e=r?Math.max(r[0]&&r[0].height||0,i.height/r.length):0}this.left=i.left,this.right=i.right,this.top=i.top||s,this.height=i.height||t,this.bottom=i.bottom||s+(i.height||t),this.width=i.width||n,this.lineHeight=e!==void 0?e:i.lineHeight}ot.prototype.move=function(i,e){switch(e=e!==void 0?e:this.lineHeight,i){case"+x":this.left+=e,this.right+=e;break;case"-x":this.left-=e,this.right-=e;break;case"+y":this.top+=e,this.bottom+=e;break;case"-y":this.top-=e,this.bottom-=e;break}};ot.prototype.overlaps=function(i){return this.left<i.right&&this.right>i.left&&this.top<i.bottom&&this.bottom>i.top};ot.prototype.overlapsAny=function(i){for(var e=0;e<i.length;e++)if(this.overlaps(i[e]))return!0;return!1};ot.prototype.within=function(i){return this.top>=i.top&&this.bottom<=i.bottom&&this.left>=i.left&&this.right<=i.right};ot.prototype.overlapsOppositeAxis=function(i,e){switch(e){case"+x":return this.left<i.left;case"-x":return this.right>i.right;case"+y":return this.top<i.top;case"-y":return this.bottom>i.bottom}};ot.prototype.intersectPercentage=function(i){var e=Math.max(0,Math.min(this.right,i.right)-Math.max(this.left,i.left)),t=Math.max(0,Math.min(this.bottom,i.bottom)-Math.max(this.top,i.top)),n=e*t;return n/(this.height*this.width)};ot.prototype.toCSSCompatValues=function(i){return{top:this.top-i.top,bottom:i.bottom-this.bottom,left:this.left-i.left,right:i.right-this.right,height:this.height,width:this.width}};ot.getSimpleBoxPosition=function(i){var e=i.div?i.div.offsetHeight:i.tagName?i.offsetHeight:0,t=i.div?i.div.offsetWidth:i.tagName?i.offsetWidth:0,n=i.div?i.div.offsetTop:i.tagName?i.offsetTop:0;i=i.div?i.div.getBoundingClientRect():i.tagName?i.getBoundingClientRect():i;var s={left:i.left,right:i.right,top:i.top||n,height:i.height||e,bottom:i.bottom||n+(i.height||e),width:i.width||t};return s};function g_(i,e,t,n){function s(M,D){for(var R,N=new ot(M),F=1,P=0;P<D.length;P++){for(;M.overlapsOppositeAxis(t,D[P])||M.within(t)&&M.overlapsAny(n);)M.move(D[P]);if(M.within(t))return M;var $=M.intersectPercentage(t);F>$&&(R=new ot(M),F=$),M=new ot(N)}return R||N}var r=new ot(e),a=e.cue,l=p_(a),c=[];if(a.snapToLines){var f;switch(a.vertical){case"":c=["+y","-y"],f="height";break;case"rl":c=["+x","-x"],f="width";break;case"lr":c=["-x","+x"],f="width";break}var m=r.lineHeight,b=m*Math.round(l),C=t[f]+m,w=c[0];Math.abs(b)>C&&(b=b<0?-1:1,b*=Math.ceil(C/m)*m),l<0&&(b+=a.vertical===""?t.height:t.width,c=c.reverse()),r.move(w,b)}else{var A=r.lineHeight/t.height*100;switch(a.lineAlign){case"center":l-=A/2;break;case"end":l-=A;break}switch(a.vertical){case"":e.applyStyles({top:e.formatStyle(l,"%")});break;case"rl":e.applyStyles({left:e.formatStyle(l,"%")});break;case"lr":e.applyStyles({right:e.formatStyle(l,"%")});break}c=["+y","-x","+x","-y"],r=new ot(e)}var v=s(r,c);e.move(v.toCSSCompatValues(t))}function Sn(){}Sn.StringDecoder=function(){return{decode:function(i){if(!i)return"";if(typeof i!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(i))}}};Sn.convertCueToDOMTree=function(i,e){return!i||!e?null:th(i,e)};var f_=.05,m_="sans-serif",y_="1.5%";Sn.processCues=function(i,e,t){if(!i||!e||!t)return null;for(;t.firstChild;)t.removeChild(t.firstChild);var n=i.document.createElement("div");n.style.position="absolute",n.style.left="0",n.style.right="0",n.style.top="0",n.style.bottom="0",n.style.margin=y_,t.appendChild(n);function s(m){for(var b=0;b<m.length;b++)if(m[b].hasBeenReset||!m[b].displayState)return!0;return!1}if(!s(e)){for(var r=0;r<e.length;r++)n.appendChild(e[r].displayState);return}var a=[],l=ot.getSimpleBoxPosition(n),c=Math.round(l.height*f_*100)/100,f={font:c+"px "+m_};(function(){for(var m,b,C=0;C<e.length;C++)b=e[C],m=new lr(i,b,f),n.appendChild(m.div),g_(i,m,l,a),b.displayState=m.div,a.push(ot.getSimpleBoxPosition(m))})()};Sn.Parser=function(i,e,t){t||(t=e,e={}),e||(e={}),this.window=i,this.vttjs=e,this.state="INITIAL",this.buffer="",this.decoder=t||new TextDecoder("utf8"),this.regionList=[]};Sn.Parser.prototype={reportOrThrowError:function(i){if(i instanceof Tt)this.onparsingerror&&this.onparsingerror(i);else throw i},parse:function(i){var e=this;i&&(e.buffer+=e.decoder.decode(i,{stream:!0}));function t(){for(var m=e.buffer,b=0;b<m.length&&m[b]!=="\r"&&m[b]!==`
|
|
10
|
-
`;)++
|
|
11
|
-
`&&++
|
|
8
|
+
*/var Q0=function(e){var t={};return e&&e.trim().split(`
|
|
9
|
+
`).forEach(function(i){var n=i.indexOf(":"),r=i.slice(0,n).trim().toLowerCase(),a=i.slice(n+1).trim();typeof t[r]>"u"?t[r]=a:Array.isArray(t[r])?t[r].push(a):t[r]=[t[r],a]}),t};So.exports=$e;So.exports.default=$e;$e.XMLHttpRequest=Yc.XMLHttpRequest||ty;$e.XDomainRequest="withCredentials"in new $e.XMLHttpRequest?$e.XMLHttpRequest:Yc.XDomainRequest;J0(["get","put","post","patch","head","delete"],function(s){$e[s==="delete"?"del":s]=function(e,t,i){return t=Jc(e,t,i),t.method=s.toUpperCase(),Eo(t)}});function J0(s,e){for(var t=0;t<s.length;t++)e(s[t])}function Z0(s){for(var e in s)if(s.hasOwnProperty(e))return!1;return!0}function Jc(s,e,t){var i=s;return X0(e)?(t=e,typeof s=="string"&&(i={uri:s})):i=K0({},e,{uri:s}),i.callback=t,i}function $e(s,e,t){return e=Jc(s,e,t),Eo(e)}function Eo(s){if(typeof s.callback>"u")throw new Error("callback argument missing");if(s.requestType&&$e.requestInterceptorsStorage.getIsEnabled()){var e={uri:s.uri||s.url,headers:s.headers||{},body:s.body,metadata:s.metadata||{},retry:s.retry,timeout:s.timeout},t=$e.requestInterceptorsStorage.execute(s.requestType,e);s.uri=t.uri,s.headers=t.headers,s.body=t.body,s.metadata=t.metadata,s.retry=t.retry,s.timeout=t.timeout}var i=!1,n=function(D,V,X){i||(i=!0,s.callback(D,V,X))};function r(){f.readyState===4&&!$e.responseInterceptorsStorage.getIsEnabled()&&setTimeout(h,0)}function a(){var F=void 0;if(f.response?F=f.response:F=f.responseText||ey(f),L)try{F=JSON.parse(F)}catch{}return F}function l(F){if(clearTimeout(N),clearTimeout(s.retryTimeout),F instanceof Error||(F=new Error(""+(F||"Unknown XMLHttpRequest Error"))),F.statusCode=0,!T&&$e.retryManager.getIsEnabled()&&s.retry&&s.retry.shouldRetry()){s.retryTimeout=setTimeout(function(){s.retry.moveToNextAttempt(),s.xhr=f,Eo(s)},s.retry.getCurrentFuzzedDelay());return}if(s.requestType&&$e.responseInterceptorsStorage.getIsEnabled()){var D={headers:U.headers||{},body:U.body,responseUrl:f.responseURL,responseType:f.responseType},V=$e.responseInterceptorsStorage.execute(s.requestType,D);U.body=V.body,U.headers=V.headers}return n(F,U)}function h(){if(!T){var F;clearTimeout(N),clearTimeout(s.retryTimeout),s.useXDR&&f.status===void 0?F=200:F=f.status===1223?204:f.status;var D=U,V=null;if(F!==0?(D={body:a(),statusCode:F,method:C,headers:{},url:E,rawRequest:f},f.getAllResponseHeaders&&(D.headers=Q0(f.getAllResponseHeaders()))):V=new Error("Internal XMLHttpRequest Error"),s.requestType&&$e.responseInterceptorsStorage.getIsEnabled()){var X={headers:D.headers||{},body:D.body,responseUrl:f.responseURL,responseType:f.responseType},G=$e.responseInterceptorsStorage.execute(s.requestType,X);D.body=G.body,D.headers=G.headers}return n(V,D,D.body)}}var f=s.xhr||null;f||(s.cors||s.useXDR?f=new $e.XDomainRequest:f=new $e.XMLHttpRequest);var m,T,E=f.url=s.uri||s.url,C=f.method=s.method||"GET",P=s.body||s.data,v=f.headers=s.headers||{},R=!!s.sync,L=!1,N,U={body:void 0,headers:{},statusCode:0,method:C,url:E,rawRequest:f};if("json"in s&&s.json!==!1&&(L=!0,v.accept||v.Accept||(v.Accept="application/json"),C!=="GET"&&C!=="HEAD"&&(v["content-type"]||v["Content-Type"]||(v["Content-Type"]="application/json"),P=JSON.stringify(s.json===!0?P:s.json))),f.onreadystatechange=r,f.onload=h,f.onerror=l,f.onprogress=function(){},f.onabort=function(){T=!0,clearTimeout(s.retryTimeout)},f.ontimeout=l,f.open(C,E,!R,s.username,s.password),R||(f.withCredentials=!!s.withCredentials),!R&&s.timeout>0&&(N=setTimeout(function(){if(!T){T=!0,f.abort("timeout");var F=new Error("XMLHttpRequest timeout");F.code="ETIMEDOUT",l(F)}},s.timeout)),f.setRequestHeader)for(m in v)v.hasOwnProperty(m)&&f.setRequestHeader(m,v[m]);else if(s.headers&&!Z0(s.headers))throw new Error("Headers cannot be set on an XDomainRequest object");return"responseType"in s&&(f.responseType=s.responseType),"beforeSend"in s&&typeof s.beforeSend=="function"&&s.beforeSend(f),f.send(P||null),f}function ey(s){try{if(s.responseType==="document")return s.responseXML;var e=s.responseXML&&s.responseXML.documentElement.nodeName==="parsererror";if(s.responseType===""&&!e)return s.responseXML}catch{}return null}function ty(){}var iy=So.exports;const Zc=Jt.getDefaultExportFromCjs(iy);var ed={exports:{}},fu=Kc,Co=Object.create||function(){function s(){}return function(e){if(arguments.length!==1)throw new Error("Object.create shim only accepts one parameter.");return s.prototype=e,new s}}();function Tt(s,e){this.name="ParsingError",this.code=s.code,this.message=e||s.message}Tt.prototype=Co(Error.prototype);Tt.prototype.constructor=Tt;Tt.Errors={BadSignature:{code:0,message:"Malformed WebVTT signature."},BadTimeStamp:{code:1,message:"Malformed time stamp."}};function wo(s){function e(i,n,r,a){return(i|0)*3600+(n|0)*60+(r|0)+(a|0)/1e3}var t=s.match(/^(\d+):(\d{1,2})(:\d{1,2})?\.(\d{3})/);return t?t[3]?e(t[1],t[2],t[3].replace(":",""),t[4]):t[1]>59?e(t[1],t[2],0,t[4]):e(0,t[1],t[2],t[4]):null}function cn(){this.values=Co(null)}cn.prototype={set:function(s,e){!this.get(s)&&e!==""&&(this.values[s]=e)},get:function(s,e,t){return t?this.has(s)?this.values[s]:e[t]:this.has(s)?this.values[s]:e},has:function(s){return s in this.values},alt:function(s,e,t){for(var i=0;i<t.length;++i)if(e===t[i]){this.set(s,e);break}},integer:function(s,e){/^-?\d+$/.test(e)&&this.set(s,parseInt(e,10))},percent:function(s,e){return e.match(/^([\d]{1,3})(\.[\d]*)?%$/)&&(e=parseFloat(e),e>=0&&e<=100)?(this.set(s,e),!0):!1}};function an(s,e,t,i){var n=i?s.split(i):[s];for(var r in n)if(typeof n[r]=="string"){var a=n[r].split(t);if(a.length===2){var l=a[0].trim(),h=a[1].trim();e(l,h)}}}function sy(s,e,t){var i=s;function n(){var l=wo(s);if(l===null)throw new Tt(Tt.Errors.BadTimeStamp,"Malformed timestamp: "+i);return s=s.replace(/^[^\sa-zA-Z-]+/,""),l}function r(l,h){var f=new cn;an(l,function(m,T){switch(m){case"region":for(var E=t.length-1;E>=0;E--)if(t[E].id===T){f.set(m,t[E].region);break}break;case"vertical":f.alt(m,T,["rl","lr"]);break;case"line":var C=T.split(","),P=C[0];f.integer(m,P),f.percent(m,P)&&f.set("snapToLines",!1),f.alt(m,P,["auto"]),C.length===2&&f.alt("lineAlign",C[1],["start","center","end"]);break;case"position":C=T.split(","),f.percent(m,C[0]),C.length===2&&f.alt("positionAlign",C[1],["start","center","end"]);break;case"size":f.percent(m,T);break;case"align":f.alt(m,T,["start","center","end","left","right"]);break}},/:/,/\s/),h.region=f.get("region",null),h.vertical=f.get("vertical","");try{h.line=f.get("line","auto")}catch{}h.lineAlign=f.get("lineAlign","start"),h.snapToLines=f.get("snapToLines",!0),h.size=f.get("size",100);try{h.align=f.get("align","center")}catch{h.align=f.get("align","middle")}try{h.position=f.get("position","auto")}catch{h.position=f.get("position",{start:0,left:0,center:50,middle:50,end:100,right:100},h.align)}h.positionAlign=f.get("positionAlign",{start:"start",left:"start",center:"center",middle:"center",end:"end",right:"end"},h.align)}function a(){s=s.replace(/^\s+/,"")}if(a(),e.startTime=n(),a(),s.substr(0,3)!=="-->")throw new Tt(Tt.Errors.BadTimeStamp,"Malformed time stamp (time stamps must be separated by '-->'): "+i);s=s.substr(3),a(),e.endTime=n(),a(),r(s,e)}var Ia=fu.createElement&&fu.createElement("textarea"),ny={c:"span",i:"i",b:"b",u:"u",ruby:"ruby",rt:"rt",v:"span",lang:"span"},pu={white:"rgba(255,255,255,1)",lime:"rgba(0,255,0,1)",cyan:"rgba(0,255,255,1)",red:"rgba(255,0,0,1)",yellow:"rgba(255,255,0,1)",magenta:"rgba(255,0,255,1)",blue:"rgba(0,0,255,1)",black:"rgba(0,0,0,1)"},ry={v:"title",lang:"lang"},mu={rt:"ruby"};function td(s,e){function t(){if(!e)return null;function P(R){return e=e.substr(R.length),R}var v=e.match(/^([^<]*)(<[^>]*>?)?/);return P(v[1]?v[1]:v[2])}function i(P){return Ia.innerHTML=P,P=Ia.textContent,Ia.textContent="",P}function n(P,v){return!mu[v.localName]||mu[v.localName]===P.localName}function r(P,v){var R=ny[P];if(!R)return null;var L=s.document.createElement(R),N=ry[P];return N&&v&&(L[N]=v.trim()),L}for(var a=s.document.createElement("div"),l=a,h,f=[];(h=t())!==null;){if(h[0]==="<"){if(h[1]==="/"){f.length&&f[f.length-1]===h.substr(2).replace(">","")&&(f.pop(),l=l.parentNode);continue}var m=wo(h.substr(1,h.length-2)),T;if(m){T=s.document.createProcessingInstruction("timestamp",m),l.appendChild(T);continue}var E=h.match(/^<([^.\s/0-9>]+)(\.[^\s\\>]+)?([^>\\]+)?(\\?)>?$/);if(!E||(T=r(E[1],E[3]),!T)||!n(l,T))continue;if(E[2]){var C=E[2].split(".");C.forEach(function(P){var v=/^bg_/.test(P),R=v?P.slice(3):P;if(pu.hasOwnProperty(R)){var L=v?"background-color":"color",N=pu[R];T.style[L]=N}}),T.className=C.join(" ")}f.push(E[1]),l.appendChild(T),l=T;continue}l.appendChild(s.document.createTextNode(i(h)))}return a}var gu=[[1470,1470],[1472,1472],[1475,1475],[1478,1478],[1488,1514],[1520,1524],[1544,1544],[1547,1547],[1549,1549],[1563,1563],[1566,1610],[1645,1647],[1649,1749],[1765,1766],[1774,1775],[1786,1805],[1807,1808],[1810,1839],[1869,1957],[1969,1969],[1984,2026],[2036,2037],[2042,2042],[2048,2069],[2074,2074],[2084,2084],[2088,2088],[2096,2110],[2112,2136],[2142,2142],[2208,2208],[2210,2220],[8207,8207],[64285,64285],[64287,64296],[64298,64310],[64312,64316],[64318,64318],[64320,64321],[64323,64324],[64326,64449],[64467,64829],[64848,64911],[64914,64967],[65008,65020],[65136,65140],[65142,65276],[67584,67589],[67592,67592],[67594,67637],[67639,67640],[67644,67644],[67647,67669],[67671,67679],[67840,67867],[67872,67897],[67903,67903],[67968,68023],[68030,68031],[68096,68096],[68112,68115],[68117,68119],[68121,68147],[68160,68167],[68176,68184],[68192,68223],[68352,68405],[68416,68437],[68440,68466],[68472,68479],[68608,68680],[126464,126467],[126469,126495],[126497,126498],[126500,126500],[126503,126503],[126505,126514],[126516,126519],[126521,126521],[126523,126523],[126530,126530],[126535,126535],[126537,126537],[126539,126539],[126541,126543],[126545,126546],[126548,126548],[126551,126551],[126553,126553],[126555,126555],[126557,126557],[126559,126559],[126561,126562],[126564,126564],[126567,126570],[126572,126578],[126580,126583],[126585,126588],[126590,126590],[126592,126601],[126603,126619],[126625,126627],[126629,126633],[126635,126651],[1114109,1114109]];function ay(s){for(var e=0;e<gu.length;e++){var t=gu[e];if(s>=t[0]&&s<=t[1])return!0}return!1}function oy(s){var e=[],t="",i;if(!s||!s.childNodes)return"ltr";function n(l,h){for(var f=h.childNodes.length-1;f>=0;f--)l.push(h.childNodes[f])}function r(l){if(!l||!l.length)return null;var h=l.pop(),f=h.textContent||h.innerText;if(f){var m=f.match(/^.*(\n|\r)/);return m?(l.length=0,m[0]):f}if(h.tagName==="ruby")return r(l);if(h.childNodes)return n(l,h),r(l)}for(n(e,s);t=r(e);)for(var a=0;a<t.length;a++)if(i=t.charCodeAt(a),ay(i))return"rtl";return"ltr"}function ly(s){if(typeof s.line=="number"&&(s.snapToLines||s.line>=0&&s.line<=100))return s.line;if(!s.track||!s.track.textTrackList||!s.track.textTrackList.mediaElement)return-1;for(var e=s.track,t=e.textTrackList,i=0,n=0;n<t.length&&t[n]!==e;n++)t[n].mode==="showing"&&i++;return++i*-1}function Nr(){}Nr.prototype.applyStyles=function(s,e){e=e||this.div;for(var t in s)s.hasOwnProperty(t)&&(e.style[t]=s[t])};Nr.prototype.formatStyle=function(s,e){return s===0?0:s+e};function cr(s,e,t){Nr.call(this),this.cue=e,this.cueDiv=td(s,e.text);var i={color:"rgba(255, 255, 255, 1)",backgroundColor:"rgba(0, 0, 0, 0.8)",position:"relative",left:0,right:0,top:0,bottom:0,display:"inline",writingMode:e.vertical===""?"horizontal-tb":e.vertical==="lr"?"vertical-lr":"vertical-rl",unicodeBidi:"plaintext"};this.applyStyles(i,this.cueDiv),this.div=s.document.createElement("div"),i={direction:oy(this.cueDiv),writingMode:e.vertical===""?"horizontal-tb":e.vertical==="lr"?"vertical-lr":"vertical-rl",unicodeBidi:"plaintext",textAlign:e.align==="middle"?"center":e.align,font:t.font,whiteSpace:"pre-line",position:"absolute"},this.applyStyles(i),this.div.appendChild(this.cueDiv);var n=0;switch(e.positionAlign){case"start":case"line-left":n=e.position;break;case"center":n=e.position-e.size/2;break;case"end":case"line-right":n=e.position-e.size;break}e.vertical===""?this.applyStyles({left:this.formatStyle(n,"%"),width:this.formatStyle(e.size,"%")}):this.applyStyles({top:this.formatStyle(n,"%"),height:this.formatStyle(e.size,"%")}),this.move=function(r){this.applyStyles({top:this.formatStyle(r.top,"px"),bottom:this.formatStyle(r.bottom,"px"),left:this.formatStyle(r.left,"px"),right:this.formatStyle(r.right,"px"),height:this.formatStyle(r.height,"px"),width:this.formatStyle(r.width,"px")})}}cr.prototype=Co(Nr.prototype);cr.prototype.constructor=cr;function at(s){var e,t,i,n;if(s.div){t=s.div.offsetHeight,i=s.div.offsetWidth,n=s.div.offsetTop;var r=(r=s.div.childNodes)&&(r=r[0])&&r.getClientRects&&r.getClientRects();s=s.div.getBoundingClientRect(),e=r?Math.max(r[0]&&r[0].height||0,s.height/r.length):0}this.left=s.left,this.right=s.right,this.top=s.top||n,this.height=s.height||t,this.bottom=s.bottom||n+(s.height||t),this.width=s.width||i,this.lineHeight=e!==void 0?e:s.lineHeight}at.prototype.move=function(s,e){switch(e=e!==void 0?e:this.lineHeight,s){case"+x":this.left+=e,this.right+=e;break;case"-x":this.left-=e,this.right-=e;break;case"+y":this.top+=e,this.bottom+=e;break;case"-y":this.top-=e,this.bottom-=e;break}};at.prototype.overlaps=function(s){return this.left<s.right&&this.right>s.left&&this.top<s.bottom&&this.bottom>s.top};at.prototype.overlapsAny=function(s){for(var e=0;e<s.length;e++)if(this.overlaps(s[e]))return!0;return!1};at.prototype.within=function(s){return this.top>=s.top&&this.bottom<=s.bottom&&this.left>=s.left&&this.right<=s.right};at.prototype.overlapsOppositeAxis=function(s,e){switch(e){case"+x":return this.left<s.left;case"-x":return this.right>s.right;case"+y":return this.top<s.top;case"-y":return this.bottom>s.bottom}};at.prototype.intersectPercentage=function(s){var e=Math.max(0,Math.min(this.right,s.right)-Math.max(this.left,s.left)),t=Math.max(0,Math.min(this.bottom,s.bottom)-Math.max(this.top,s.top)),i=e*t;return i/(this.height*this.width)};at.prototype.toCSSCompatValues=function(s){return{top:this.top-s.top,bottom:s.bottom-this.bottom,left:this.left-s.left,right:s.right-this.right,height:this.height,width:this.width}};at.getSimpleBoxPosition=function(s){var e=s.div?s.div.offsetHeight:s.tagName?s.offsetHeight:0,t=s.div?s.div.offsetWidth:s.tagName?s.offsetWidth:0,i=s.div?s.div.offsetTop:s.tagName?s.offsetTop:0;s=s.div?s.div.getBoundingClientRect():s.tagName?s.getBoundingClientRect():s;var n={left:s.left,right:s.right,top:s.top||i,height:s.height||e,bottom:s.bottom||i+(s.height||e),width:s.width||t};return n};function uy(s,e,t,i){function n(R,L){for(var N,U=new at(R),F=1,D=0;D<L.length;D++){for(;R.overlapsOppositeAxis(t,L[D])||R.within(t)&&R.overlapsAny(i);)R.move(L[D]);if(R.within(t))return R;var V=R.intersectPercentage(t);F>V&&(N=new at(R),F=V),R=new at(U)}return N||U}var r=new at(e),a=e.cue,l=ly(a),h=[];if(a.snapToLines){var f;switch(a.vertical){case"":h=["+y","-y"],f="height";break;case"rl":h=["+x","-x"],f="width";break;case"lr":h=["-x","+x"],f="width";break}var m=r.lineHeight,T=m*Math.round(l),E=t[f]+m,C=h[0];Math.abs(T)>E&&(T=T<0?-1:1,T*=Math.ceil(E/m)*m),l<0&&(T+=a.vertical===""?t.height:t.width,h=h.reverse()),r.move(C,T)}else{var P=r.lineHeight/t.height*100;switch(a.lineAlign){case"center":l-=P/2;break;case"end":l-=P;break}switch(a.vertical){case"":e.applyStyles({top:e.formatStyle(l,"%")});break;case"rl":e.applyStyles({left:e.formatStyle(l,"%")});break;case"lr":e.applyStyles({right:e.formatStyle(l,"%")});break}h=["+y","-x","+x","-y"],r=new at(e)}var v=n(r,h);e.move(v.toCSSCompatValues(t))}function Ss(){}Ss.StringDecoder=function(){return{decode:function(s){if(!s)return"";if(typeof s!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(s))}}};Ss.convertCueToDOMTree=function(s,e){return!s||!e?null:td(s,e)};var cy=.05,dy="sans-serif",hy="1.5%";Ss.processCues=function(s,e,t){if(!s||!e||!t)return null;for(;t.firstChild;)t.removeChild(t.firstChild);var i=s.document.createElement("div");i.style.position="absolute",i.style.left="0",i.style.right="0",i.style.top="0",i.style.bottom="0",i.style.margin=hy,t.appendChild(i);function n(m){for(var T=0;T<m.length;T++)if(m[T].hasBeenReset||!m[T].displayState)return!0;return!1}if(!n(e)){for(var r=0;r<e.length;r++)i.appendChild(e[r].displayState);return}var a=[],l=at.getSimpleBoxPosition(i),h=Math.round(l.height*cy*100)/100,f={font:h+"px "+dy};(function(){for(var m,T,E=0;E<e.length;E++)T=e[E],m=new cr(s,T,f),i.appendChild(m.div),uy(s,m,l,a),T.displayState=m.div,a.push(at.getSimpleBoxPosition(m))})()};Ss.Parser=function(s,e,t){t||(t=e,e={}),e||(e={}),this.window=s,this.vttjs=e,this.state="INITIAL",this.buffer="",this.decoder=t||new TextDecoder("utf8"),this.regionList=[]};Ss.Parser.prototype={reportOrThrowError:function(s){if(s instanceof Tt)this.onparsingerror&&this.onparsingerror(s);else throw s},parse:function(s){var e=this;s&&(e.buffer+=e.decoder.decode(s,{stream:!0}));function t(){for(var m=e.buffer,T=0;T<m.length&&m[T]!=="\r"&&m[T]!==`
|
|
10
|
+
`;)++T;var E=m.substr(0,T);return m[T]==="\r"&&++T,m[T]===`
|
|
11
|
+
`&&++T,e.buffer=m.substr(T),E}function i(m){var T=new cn;if(an(m,function(C,P){switch(C){case"id":T.set(C,P);break;case"width":T.percent(C,P);break;case"lines":T.integer(C,P);break;case"regionanchor":case"viewportanchor":var v=P.split(",");if(v.length!==2)break;var R=new cn;if(R.percent("x",v[0]),R.percent("y",v[1]),!R.has("x")||!R.has("y"))break;T.set(C+"X",R.get("x")),T.set(C+"Y",R.get("y"));break;case"scroll":T.alt(C,P,["up"]);break}},/=/,/\s/),T.has("id")){var E=new(e.vttjs.VTTRegion||e.window.VTTRegion);E.width=T.get("width",100),E.lines=T.get("lines",3),E.regionAnchorX=T.get("regionanchorX",0),E.regionAnchorY=T.get("regionanchorY",100),E.viewportAnchorX=T.get("viewportanchorX",0),E.viewportAnchorY=T.get("viewportanchorY",100),E.scroll=T.get("scroll",""),e.onregion&&e.onregion(E),e.regionList.push({id:T.get("id"),region:E})}}function n(m){var T=new cn;an(m,function(E,C){switch(E){case"MPEGT":T.integer(E+"S",C);break;case"LOCA":T.set(E+"L",wo(C));break}},/[^\d]:/,/,/),e.ontimestampmap&&e.ontimestampmap({MPEGTS:T.get("MPEGTS"),LOCAL:T.get("LOCAL")})}function r(m){m.match(/X-TIMESTAMP-MAP/)?an(m,function(T,E){switch(T){case"X-TIMESTAMP-MAP":n(E);break}},/=/):an(m,function(T,E){switch(T){case"Region":i(E);break}},/:/)}try{var a;if(e.state==="INITIAL"){if(!/\r\n|\n/.test(e.buffer))return this;a=t();var l=a.match(/^WEBVTT([ \t].*)?$/);if(!l||!l[0])throw new Tt(Tt.Errors.BadSignature);e.state="HEADER"}for(var h=!1;e.buffer;){if(!/\r\n|\n/.test(e.buffer))return this;switch(h?h=!1:a=t(),e.state){case"HEADER":/:/.test(a)?r(a):a||(e.state="ID");continue;case"NOTE":a||(e.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(a)){e.state="NOTE";break}if(!a)continue;e.cue=new(e.vttjs.VTTCue||e.window.VTTCue)(0,0,"");try{e.cue.align="center"}catch{e.cue.align="middle"}if(e.state="CUE",a.indexOf("-->")===-1){e.cue.id=a;continue}case"CUE":try{sy(a,e.cue,e.regionList)}catch(m){e.reportOrThrowError(m),e.cue=null,e.state="BADCUE";continue}e.state="CUETEXT";continue;case"CUETEXT":var f=a.indexOf("-->")!==-1;if(!a||f&&(h=!0)){e.oncue&&e.oncue(e.cue),e.cue=null,e.state="ID";continue}e.cue.text&&(e.cue.text+=`
|
|
12
12
|
`),e.cue.text+=a.replace(/\u2028/g,`
|
|
13
13
|
`).replace(/u2029/g,`
|
|
14
|
-
`);continue;case"BADCUE":a||(e.state="ID");continue}}}catch(m){e.reportOrThrowError(m),e.state==="CUETEXT"&&e.cue&&e.oncue&&e.oncue(e.cue),e.cue=null,e.state=e.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},flush:function(){var
|
|
14
|
+
`);continue;case"BADCUE":a||(e.state="ID");continue}}}catch(m){e.reportOrThrowError(m),e.state==="CUETEXT"&&e.cue&&e.oncue&&e.oncue(e.cue),e.cue=null,e.state=e.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},flush:function(){var s=this;try{if(s.buffer+=s.decoder.decode(),(s.cue||s.state==="HEADER")&&(s.buffer+=`
|
|
15
15
|
|
|
16
|
-
`,
|
|
16
|
+
`,s.parse()),s.state==="INITIAL")throw new Tt(Tt.Errors.BadSignature)}catch(e){s.reportOrThrowError(e)}return s.onflush&&s.onflush(),this}};var fy=Ss,py="auto",my={"":1,lr:1,rl:1},gy={start:1,center:1,end:1,left:1,right:1,auto:1,"line-left":1,"line-right":1};function yy(s){if(typeof s!="string")return!1;var e=my[s.toLowerCase()];return e?s.toLowerCase():!1}function Aa(s){if(typeof s!="string")return!1;var e=gy[s.toLowerCase()];return e?s.toLowerCase():!1}function id(s,e,t){this.hasBeenReset=!1;var i="",n=!1,r=s,a=e,l=t,h=null,f="",m=!0,T="auto",E="start",C="auto",P="auto",v=100,R="center";Object.defineProperties(this,{id:{enumerable:!0,get:function(){return i},set:function(L){i=""+L}},pauseOnExit:{enumerable:!0,get:function(){return n},set:function(L){n=!!L}},startTime:{enumerable:!0,get:function(){return r},set:function(L){if(typeof L!="number")throw new TypeError("Start time must be set to a number.");r=L,this.hasBeenReset=!0}},endTime:{enumerable:!0,get:function(){return a},set:function(L){if(typeof L!="number")throw new TypeError("End time must be set to a number.");a=L,this.hasBeenReset=!0}},text:{enumerable:!0,get:function(){return l},set:function(L){l=""+L,this.hasBeenReset=!0}},region:{enumerable:!0,get:function(){return h},set:function(L){h=L,this.hasBeenReset=!0}},vertical:{enumerable:!0,get:function(){return f},set:function(L){var N=yy(L);if(N===!1)throw new SyntaxError("Vertical: an invalid or illegal direction string was specified.");f=N,this.hasBeenReset=!0}},snapToLines:{enumerable:!0,get:function(){return m},set:function(L){m=!!L,this.hasBeenReset=!0}},line:{enumerable:!0,get:function(){return T},set:function(L){if(typeof L!="number"&&L!==py)throw new SyntaxError("Line: an invalid number or illegal string was specified.");T=L,this.hasBeenReset=!0}},lineAlign:{enumerable:!0,get:function(){return E},set:function(L){var N=Aa(L);N?(E=N,this.hasBeenReset=!0):console.warn("lineAlign: an invalid or illegal string was specified.")}},position:{enumerable:!0,get:function(){return C},set:function(L){if(L<0||L>100)throw new Error("Position must be between 0 and 100.");C=L,this.hasBeenReset=!0}},positionAlign:{enumerable:!0,get:function(){return P},set:function(L){var N=Aa(L);N?(P=N,this.hasBeenReset=!0):console.warn("positionAlign: an invalid or illegal string was specified.")}},size:{enumerable:!0,get:function(){return v},set:function(L){if(L<0||L>100)throw new Error("Size must be between 0 and 100.");v=L,this.hasBeenReset=!0}},align:{enumerable:!0,get:function(){return R},set:function(L){var N=Aa(L);if(!N)throw new SyntaxError("align: an invalid or illegal alignment string was specified.");R=N,this.hasBeenReset=!0}}}),this.displayState=void 0}id.prototype.getCueAsHTML=function(){return WebVTT.convertCueToDOMTree(window,this.text)};var _y=id,Ty={"":!0,up:!0};function vy(s){if(typeof s!="string")return!1;var e=Ty[s.toLowerCase()];return e?s.toLowerCase():!1}function Js(s){return typeof s=="number"&&s>=0&&s<=100}function by(){var s=100,e=3,t=0,i=100,n=0,r=100,a="";Object.defineProperties(this,{width:{enumerable:!0,get:function(){return s},set:function(l){if(!Js(l))throw new Error("Width must be between 0 and 100.");s=l}},lines:{enumerable:!0,get:function(){return e},set:function(l){if(typeof l!="number")throw new TypeError("Lines must be set to a number.");e=l}},regionAnchorY:{enumerable:!0,get:function(){return i},set:function(l){if(!Js(l))throw new Error("RegionAnchorX must be between 0 and 100.");i=l}},regionAnchorX:{enumerable:!0,get:function(){return t},set:function(l){if(!Js(l))throw new Error("RegionAnchorY must be between 0 and 100.");t=l}},viewportAnchorY:{enumerable:!0,get:function(){return r},set:function(l){if(!Js(l))throw new Error("ViewportAnchorY must be between 0 and 100.");r=l}},viewportAnchorX:{enumerable:!0,get:function(){return n},set:function(l){if(!Js(l))throw new Error("ViewportAnchorX must be between 0 and 100.");n=l}},scroll:{enumerable:!0,get:function(){return a},set:function(l){var h=vy(l);h===!1?console.warn("Scroll: an invalid or illegal string was specified."):a=h}}})}var xy=by,oi=Mr,qi=ed.exports={WebVTT:fy,VTTCue:_y,VTTRegion:xy};oi.vttjs=qi;oi.WebVTT=qi.WebVTT;var Sy=qi.VTTCue,Ey=qi.VTTRegion,Cy=oi.VTTCue,wy=oi.VTTRegion;qi.shim=function(){oi.VTTCue=Sy,oi.VTTRegion=Ey};qi.restore=function(){oi.VTTCue=Cy,oi.VTTRegion=wy};oi.VTTCue||qi.shim();var Iy=ed.exports;const yu=Jt.getDefaultExportFromCjs(Iy);var _u="https://example.com",Ur=function(e,t){if(/^[a-z]+:/i.test(t))return t;/^data:/.test(e)&&(e=k.location&&k.location.href||"");var i=/^\/\//.test(e),n=!k.location&&!/\/\//i.test(e);e=new k.URL(e,k.location||_u);var r=new URL(t,e);return n?r.href.slice(_u.length):i?r.href.slice(r.protocol.length):r.href},Io=function(){function s(){this.listeners={}}var e=s.prototype;return e.on=function(i,n){this.listeners[i]||(this.listeners[i]=[]),this.listeners[i].push(n)},e.off=function(i,n){if(!this.listeners[i])return!1;var r=this.listeners[i].indexOf(n);return this.listeners[i]=this.listeners[i].slice(0),this.listeners[i].splice(r,1),r>-1},e.trigger=function(i){var n=this.listeners[i];if(n)if(arguments.length===2)for(var r=n.length,a=0;a<r;++a)n[a].call(this,arguments[1]);else for(var l=Array.prototype.slice.call(arguments,1),h=n.length,f=0;f<h;++f)n[f].apply(this,l)},e.dispose=function(){this.listeners={}},e.pipe=function(i){this.on("data",function(n){i.push(n)})},s}(),sd={},Br={};Br.byteLength=Py;Br.toByteArray=Ly;Br.fromByteArray=My;var Gt=[],wt=[],Ay=typeof Uint8Array<"u"?Uint8Array:Array,ka="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var Qi=0,ky=ka.length;Qi<ky;++Qi)Gt[Qi]=ka[Qi],wt[ka.charCodeAt(Qi)]=Qi;wt[45]=62;wt[95]=63;function nd(s){var e=s.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=s.indexOf("=");t===-1&&(t=e);var i=t===e?0:4-t%4;return[t,i]}function Py(s){var e=nd(s),t=e[0],i=e[1];return(t+i)*3/4-i}function Dy(s,e,t){return(e+t)*3/4-t}function Ly(s){var e,t=nd(s),i=t[0],n=t[1],r=new Ay(Dy(s,i,n)),a=0,l=n>0?i-4:i,h;for(h=0;h<l;h+=4)e=wt[s.charCodeAt(h)]<<18|wt[s.charCodeAt(h+1)]<<12|wt[s.charCodeAt(h+2)]<<6|wt[s.charCodeAt(h+3)],r[a++]=e>>16&255,r[a++]=e>>8&255,r[a++]=e&255;return n===2&&(e=wt[s.charCodeAt(h)]<<2|wt[s.charCodeAt(h+1)]>>4,r[a++]=e&255),n===1&&(e=wt[s.charCodeAt(h)]<<10|wt[s.charCodeAt(h+1)]<<4|wt[s.charCodeAt(h+2)]>>2,r[a++]=e>>8&255,r[a++]=e&255),r}function Oy(s){return Gt[s>>18&63]+Gt[s>>12&63]+Gt[s>>6&63]+Gt[s&63]}function Ry(s,e,t){for(var i,n=[],r=e;r<t;r+=3)i=(s[r]<<16&16711680)+(s[r+1]<<8&65280)+(s[r+2]&255),n.push(Oy(i));return n.join("")}function My(s){for(var e,t=s.length,i=t%3,n=[],r=16383,a=0,l=t-i;a<l;a+=r)n.push(Ry(s,a,a+r>l?l:a+r));return i===1?(e=s[t-1],n.push(Gt[e>>2]+Gt[e<<4&63]+"==")):i===2&&(e=(s[t-2]<<8)+s[t-1],n.push(Gt[e>>10]+Gt[e>>4&63]+Gt[e<<2&63]+"=")),n.join("")}var Ao={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */Ao.read=function(s,e,t,i,n){var r,a,l=n*8-i-1,h=(1<<l)-1,f=h>>1,m=-7,T=t?n-1:0,E=t?-1:1,C=s[e+T];for(T+=E,r=C&(1<<-m)-1,C>>=-m,m+=l;m>0;r=r*256+s[e+T],T+=E,m-=8);for(a=r&(1<<-m)-1,r>>=-m,m+=i;m>0;a=a*256+s[e+T],T+=E,m-=8);if(r===0)r=1-f;else{if(r===h)return a?NaN:(C?-1:1)*(1/0);a=a+Math.pow(2,i),r=r-f}return(C?-1:1)*a*Math.pow(2,r-i)};Ao.write=function(s,e,t,i,n,r){var a,l,h,f=r*8-n-1,m=(1<<f)-1,T=m>>1,E=n===23?Math.pow(2,-24)-Math.pow(2,-77):0,C=i?0:r-1,P=i?1:-1,v=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(l=isNaN(e)?1:0,a=m):(a=Math.floor(Math.log(e)/Math.LN2),e*(h=Math.pow(2,-a))<1&&(a--,h*=2),a+T>=1?e+=E/h:e+=E*Math.pow(2,1-T),e*h>=2&&(a++,h/=2),a+T>=m?(l=0,a=m):a+T>=1?(l=(e*h-1)*Math.pow(2,n),a=a+T):(l=e*Math.pow(2,T-1)*Math.pow(2,n),a=0));n>=8;s[t+C]=l&255,C+=P,l/=256,n-=8);for(a=a<<n|l,f+=n;f>0;s[t+C]=a&255,C+=P,a/=256,f-=8);s[t+C-P]|=v*128};/*!
|
|
17
17
|
* The buffer module from node.js, for the browser.
|
|
18
18
|
*
|
|
19
19
|
* @author Feross Aboukhadijeh <https://feross.org>
|
|
20
20
|
* @license MIT
|
|
21
|
-
*/(function(i){const e=Rr,t=Io,n=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;i.Buffer=m,i.SlowBuffer=P,i.INSPECT_MAX_BYTES=50;const s=2147483647;i.kMaxLength=s;const{Uint8Array:r,ArrayBuffer:a,SharedArrayBuffer:l}=globalThis;m.TYPED_ARRAY_SUPPORT=c(),!m.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function c(){try{const p=new r(1),_={foo:function(){return 42}};return Object.setPrototypeOf(_,r.prototype),Object.setPrototypeOf(p,_),p.foo()===42}catch{return!1}}Object.defineProperty(m.prototype,"parent",{enumerable:!0,get:function(){if(m.isBuffer(this))return this.buffer}}),Object.defineProperty(m.prototype,"offset",{enumerable:!0,get:function(){if(m.isBuffer(this))return this.byteOffset}});function f(p){if(p>s)throw new RangeError('The value "'+p+'" is invalid for option "size"');const _=new r(p);return Object.setPrototypeOf(_,m.prototype),_}function m(p,_,T){if(typeof p=="number"){if(typeof _=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return A(p)}return b(p,_,T)}m.poolSize=8192;function b(p,_,T){if(typeof p=="string")return v(p,_);if(a.isView(p))return D(p);if(p==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof p);if(ut(p,a)||p&&ut(p.buffer,a)||typeof l<"u"&&(ut(p,l)||p&&ut(p.buffer,l)))return R(p,_,T);if(typeof p=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const L=p.valueOf&&p.valueOf();if(L!=null&&L!==p)return m.from(L,_,T);const U=N(p);if(U)return U;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof p[Symbol.toPrimitive]=="function")return m.from(p[Symbol.toPrimitive]("string"),_,T);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof p)}m.from=function(p,_,T){return b(p,_,T)},Object.setPrototypeOf(m.prototype,r.prototype),Object.setPrototypeOf(m,r);function C(p){if(typeof p!="number")throw new TypeError('"size" argument must be of type number');if(p<0)throw new RangeError('The value "'+p+'" is invalid for option "size"')}function w(p,_,T){return C(p),p<=0?f(p):_!==void 0?typeof T=="string"?f(p).fill(_,T):f(p).fill(_):f(p)}m.alloc=function(p,_,T){return w(p,_,T)};function A(p){return C(p),f(p<0?0:F(p)|0)}m.allocUnsafe=function(p){return A(p)},m.allocUnsafeSlow=function(p){return A(p)};function v(p,_){if((typeof _!="string"||_==="")&&(_="utf8"),!m.isEncoding(_))throw new TypeError("Unknown encoding: "+_);const T=$(p,_)|0;let L=f(T);const U=L.write(p,_);return U!==T&&(L=L.slice(0,U)),L}function M(p){const _=p.length<0?0:F(p.length)|0,T=f(_);for(let L=0;L<_;L+=1)T[L]=p[L]&255;return T}function D(p){if(ut(p,r)){const _=new r(p);return R(_.buffer,_.byteOffset,_.byteLength)}return M(p)}function R(p,_,T){if(_<0||p.byteLength<_)throw new RangeError('"offset" is outside of buffer bounds');if(p.byteLength<_+(T||0))throw new RangeError('"length" is outside of buffer bounds');let L;return _===void 0&&T===void 0?L=new r(p):T===void 0?L=new r(p,_):L=new r(p,_,T),Object.setPrototypeOf(L,m.prototype),L}function N(p){if(m.isBuffer(p)){const _=F(p.length)|0,T=f(_);return T.length===0||p.copy(T,0,0,_),T}if(p.length!==void 0)return typeof p.length!="number"||Ci(p.length)?f(0):M(p);if(p.type==="Buffer"&&Array.isArray(p.data))return M(p.data)}function F(p){if(p>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return p|0}function P(p){return+p!=p&&(p=0),m.alloc(+p)}m.isBuffer=function(p){return p!=null&&p._isBuffer===!0&&p!==m.prototype},m.compare=function(p,_){if(ut(p,r)&&(p=m.from(p,p.offset,p.byteLength)),ut(_,r)&&(_=m.from(_,_.offset,_.byteLength)),!m.isBuffer(p)||!m.isBuffer(_))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(p===_)return 0;let T=p.length,L=_.length;for(let U=0,q=Math.min(T,L);U<q;++U)if(p[U]!==_[U]){T=p[U],L=_[U];break}return T<L?-1:L<T?1:0},m.isEncoding=function(p){switch(String(p).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},m.concat=function(p,_){if(!Array.isArray(p))throw new TypeError('"list" argument must be an Array of Buffers');if(p.length===0)return m.alloc(0);let T;if(_===void 0)for(_=0,T=0;T<p.length;++T)_+=p[T].length;const L=m.allocUnsafe(_);let U=0;for(T=0;T<p.length;++T){let q=p[T];if(ut(q,r))U+q.length>L.length?(m.isBuffer(q)||(q=m.from(q)),q.copy(L,U)):r.prototype.set.call(L,q,U);else if(m.isBuffer(q))q.copy(L,U);else throw new TypeError('"list" argument must be an Array of Buffers');U+=q.length}return L};function $(p,_){if(m.isBuffer(p))return p.length;if(a.isView(p)||ut(p,a))return p.byteLength;if(typeof p!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof p);const T=p.length,L=arguments.length>2&&arguments[2]===!0;if(!L&&T===0)return 0;let U=!1;for(;;)switch(_){case"ascii":case"latin1":case"binary":return T;case"utf8":case"utf-8":return pe(p).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T*2;case"hex":return T>>>1;case"base64":return Es(p).length;default:if(U)return L?-1:pe(p).length;_=(""+_).toLowerCase(),U=!0}}m.byteLength=$;function Y(p,_,T){let L=!1;if((_===void 0||_<0)&&(_=0),_>this.length||((T===void 0||T>this.length)&&(T=this.length),T<=0)||(T>>>=0,_>>>=0,T<=_))return"";for(p||(p="utf8");;)switch(p){case"hex":return mt(this,_,T);case"utf8":case"utf-8":return Ye(this,_,T);case"ascii":return me(this,_,T);case"latin1":case"binary":return ge(this,_,T);case"base64":return Xe(this,_,T);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Et(this,_,T);default:if(L)throw new TypeError("Unknown encoding: "+p);p=(p+"").toLowerCase(),L=!0}}m.prototype._isBuffer=!0;function X(p,_,T){const L=p[_];p[_]=p[T],p[T]=L}m.prototype.swap16=function(){const p=this.length;if(p%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let _=0;_<p;_+=2)X(this,_,_+1);return this},m.prototype.swap32=function(){const p=this.length;if(p%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let _=0;_<p;_+=4)X(this,_,_+3),X(this,_+1,_+2);return this},m.prototype.swap64=function(){const p=this.length;if(p%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let _=0;_<p;_+=8)X(this,_,_+7),X(this,_+1,_+6),X(this,_+2,_+5),X(this,_+3,_+4);return this},m.prototype.toString=function(){const p=this.length;return p===0?"":arguments.length===0?Ye(this,0,p):Y.apply(this,arguments)},m.prototype.toLocaleString=m.prototype.toString,m.prototype.equals=function(p){if(!m.isBuffer(p))throw new TypeError("Argument must be a Buffer");return this===p?!0:m.compare(this,p)===0},m.prototype.inspect=function(){let p="";const _=i.INSPECT_MAX_BYTES;return p=this.toString("hex",0,_).replace(/(.{2})/g,"$1 ").trim(),this.length>_&&(p+=" ... "),"<Buffer "+p+">"},n&&(m.prototype[n]=m.prototype.inspect),m.prototype.compare=function(p,_,T,L,U){if(ut(p,r)&&(p=m.from(p,p.offset,p.byteLength)),!m.isBuffer(p))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof p);if(_===void 0&&(_=0),T===void 0&&(T=p?p.length:0),L===void 0&&(L=0),U===void 0&&(U=this.length),_<0||T>p.length||L<0||U>this.length)throw new RangeError("out of range index");if(L>=U&&_>=T)return 0;if(L>=U)return-1;if(_>=T)return 1;if(_>>>=0,T>>>=0,L>>>=0,U>>>=0,this===p)return 0;let q=U-L,K=T-_;const Se=Math.min(q,K),Ve=this.slice(L,U),ke=p.slice(_,T);for(let Te=0;Te<Se;++Te)if(Ve[Te]!==ke[Te]){q=Ve[Te],K=ke[Te];break}return q<K?-1:K<q?1:0};function re(p,_,T,L,U){if(p.length===0)return-1;if(typeof T=="string"?(L=T,T=0):T>2147483647?T=2147483647:T<-2147483648&&(T=-2147483648),T=+T,Ci(T)&&(T=U?0:p.length-1),T<0&&(T=p.length+T),T>=p.length){if(U)return-1;T=p.length-1}else if(T<0)if(U)T=0;else return-1;if(typeof _=="string"&&(_=m.from(_,L)),m.isBuffer(_))return _.length===0?-1:ce(p,_,T,L,U);if(typeof _=="number")return _=_&255,typeof r.prototype.indexOf=="function"?U?r.prototype.indexOf.call(p,_,T):r.prototype.lastIndexOf.call(p,_,T):ce(p,[_],T,L,U);throw new TypeError("val must be string, number or Buffer")}function ce(p,_,T,L,U){let q=1,K=p.length,Se=_.length;if(L!==void 0&&(L=String(L).toLowerCase(),L==="ucs2"||L==="ucs-2"||L==="utf16le"||L==="utf-16le")){if(p.length<2||_.length<2)return-1;q=2,K/=2,Se/=2,T/=2}function Ve(Te,Ue){return q===1?Te[Ue]:Te.readUInt16BE(Ue*q)}let ke;if(U){let Te=-1;for(ke=T;ke<K;ke++)if(Ve(p,ke)===Ve(_,Te===-1?0:ke-Te)){if(Te===-1&&(Te=ke),ke-Te+1===Se)return Te*q}else Te!==-1&&(ke-=ke-Te),Te=-1}else for(T+Se>K&&(T=K-Se),ke=T;ke>=0;ke--){let Te=!0;for(let Ue=0;Ue<Se;Ue++)if(Ve(p,ke+Ue)!==Ve(_,Ue)){Te=!1;break}if(Te)return ke}return-1}m.prototype.includes=function(p,_,T){return this.indexOf(p,_,T)!==-1},m.prototype.indexOf=function(p,_,T){return re(this,p,_,T,!0)},m.prototype.lastIndexOf=function(p,_,T){return re(this,p,_,T,!1)};function be(p,_,T,L){T=Number(T)||0;const U=p.length-T;L?(L=Number(L),L>U&&(L=U)):L=U;const q=_.length;L>q/2&&(L=q/2);let K;for(K=0;K<L;++K){const Se=parseInt(_.substr(K*2,2),16);if(Ci(Se))return K;p[T+K]=Se}return K}function he(p,_,T,L){return di(pe(_,p.length-T),p,T,L)}function Z(p,_,T,L){return di(ia(_),p,T,L)}function de(p,_,T,L){return di(Es(_),p,T,L)}function ee(p,_,T,L){return di(Ln(_,p.length-T),p,T,L)}m.prototype.write=function(p,_,T,L){if(_===void 0)L="utf8",T=this.length,_=0;else if(T===void 0&&typeof _=="string")L=_,T=this.length,_=0;else if(isFinite(_))_=_>>>0,isFinite(T)?(T=T>>>0,L===void 0&&(L="utf8")):(L=T,T=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const U=this.length-_;if((T===void 0||T>U)&&(T=U),p.length>0&&(T<0||_<0)||_>this.length)throw new RangeError("Attempt to write outside buffer bounds");L||(L="utf8");let q=!1;for(;;)switch(L){case"hex":return be(this,p,_,T);case"utf8":case"utf-8":return he(this,p,_,T);case"ascii":case"latin1":case"binary":return Z(this,p,_,T);case"base64":return de(this,p,_,T);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ee(this,p,_,T);default:if(q)throw new TypeError("Unknown encoding: "+L);L=(""+L).toLowerCase(),q=!0}},m.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Xe(p,_,T){return _===0&&T===p.length?e.fromByteArray(p):e.fromByteArray(p.slice(_,T))}function Ye(p,_,T){T=Math.min(p.length,T);const L=[];let U=_;for(;U<T;){const q=p[U];let K=null,Se=q>239?4:q>223?3:q>191?2:1;if(U+Se<=T){let Ve,ke,Te,Ue;switch(Se){case 1:q<128&&(K=q);break;case 2:Ve=p[U+1],(Ve&192)===128&&(Ue=(q&31)<<6|Ve&63,Ue>127&&(K=Ue));break;case 3:Ve=p[U+1],ke=p[U+2],(Ve&192)===128&&(ke&192)===128&&(Ue=(q&15)<<12|(Ve&63)<<6|ke&63,Ue>2047&&(Ue<55296||Ue>57343)&&(K=Ue));break;case 4:Ve=p[U+1],ke=p[U+2],Te=p[U+3],(Ve&192)===128&&(ke&192)===128&&(Te&192)===128&&(Ue=(q&15)<<18|(Ve&63)<<12|(ke&63)<<6|Te&63,Ue>65535&&Ue<1114112&&(K=Ue))}}K===null?(K=65533,Se=1):K>65535&&(K-=65536,L.push(K>>>10&1023|55296),K=56320|K&1023),L.push(K),U+=Se}return He(L)}const $e=4096;function He(p){const _=p.length;if(_<=$e)return String.fromCharCode.apply(String,p);let T="",L=0;for(;L<_;)T+=String.fromCharCode.apply(String,p.slice(L,L+=$e));return T}function me(p,_,T){let L="";T=Math.min(p.length,T);for(let U=_;U<T;++U)L+=String.fromCharCode(p[U]&127);return L}function ge(p,_,T){let L="";T=Math.min(p.length,T);for(let U=_;U<T;++U)L+=String.fromCharCode(p[U]);return L}function mt(p,_,T){const L=p.length;(!_||_<0)&&(_=0),(!T||T<0||T>L)&&(T=L);let U="";for(let q=_;q<T;++q)U+=zi[p[q]];return U}function Et(p,_,T){const L=p.slice(_,T);let U="";for(let q=0;q<L.length-1;q+=2)U+=String.fromCharCode(L[q]+L[q+1]*256);return U}m.prototype.slice=function(p,_){const T=this.length;p=~~p,_=_===void 0?T:~~_,p<0?(p+=T,p<0&&(p=0)):p>T&&(p=T),_<0?(_+=T,_<0&&(_=0)):_>T&&(_=T),_<p&&(_=p);const L=this.subarray(p,_);return Object.setPrototypeOf(L,m.prototype),L};function we(p,_,T){if(p%1!==0||p<0)throw new RangeError("offset is not uint");if(p+_>T)throw new RangeError("Trying to access beyond buffer length")}m.prototype.readUintLE=m.prototype.readUIntLE=function(p,_,T){p=p>>>0,_=_>>>0,T||we(p,_,this.length);let L=this[p],U=1,q=0;for(;++q<_&&(U*=256);)L+=this[p+q]*U;return L},m.prototype.readUintBE=m.prototype.readUIntBE=function(p,_,T){p=p>>>0,_=_>>>0,T||we(p,_,this.length);let L=this[p+--_],U=1;for(;_>0&&(U*=256);)L+=this[p+--_]*U;return L},m.prototype.readUint8=m.prototype.readUInt8=function(p,_){return p=p>>>0,_||we(p,1,this.length),this[p]},m.prototype.readUint16LE=m.prototype.readUInt16LE=function(p,_){return p=p>>>0,_||we(p,2,this.length),this[p]|this[p+1]<<8},m.prototype.readUint16BE=m.prototype.readUInt16BE=function(p,_){return p=p>>>0,_||we(p,2,this.length),this[p]<<8|this[p+1]},m.prototype.readUint32LE=m.prototype.readUInt32LE=function(p,_){return p=p>>>0,_||we(p,4,this.length),(this[p]|this[p+1]<<8|this[p+2]<<16)+this[p+3]*16777216},m.prototype.readUint32BE=m.prototype.readUInt32BE=function(p,_){return p=p>>>0,_||we(p,4,this.length),this[p]*16777216+(this[p+1]<<16|this[p+2]<<8|this[p+3])},m.prototype.readBigUInt64LE=wt(function(p){p=p>>>0,Ot(p,"offset");const _=this[p],T=this[p+7];(_===void 0||T===void 0)&&ki(p,this.length-8);const L=_+this[++p]*2**8+this[++p]*2**16+this[++p]*2**24,U=this[++p]+this[++p]*2**8+this[++p]*2**16+T*2**24;return BigInt(L)+(BigInt(U)<<BigInt(32))}),m.prototype.readBigUInt64BE=wt(function(p){p=p>>>0,Ot(p,"offset");const _=this[p],T=this[p+7];(_===void 0||T===void 0)&&ki(p,this.length-8);const L=_*2**24+this[++p]*2**16+this[++p]*2**8+this[++p],U=this[++p]*2**24+this[++p]*2**16+this[++p]*2**8+T;return(BigInt(L)<<BigInt(32))+BigInt(U)}),m.prototype.readIntLE=function(p,_,T){p=p>>>0,_=_>>>0,T||we(p,_,this.length);let L=this[p],U=1,q=0;for(;++q<_&&(U*=256);)L+=this[p+q]*U;return U*=128,L>=U&&(L-=Math.pow(2,8*_)),L},m.prototype.readIntBE=function(p,_,T){p=p>>>0,_=_>>>0,T||we(p,_,this.length);let L=_,U=1,q=this[p+--L];for(;L>0&&(U*=256);)q+=this[p+--L]*U;return U*=128,q>=U&&(q-=Math.pow(2,8*_)),q},m.prototype.readInt8=function(p,_){return p=p>>>0,_||we(p,1,this.length),this[p]&128?(255-this[p]+1)*-1:this[p]},m.prototype.readInt16LE=function(p,_){p=p>>>0,_||we(p,2,this.length);const T=this[p]|this[p+1]<<8;return T&32768?T|4294901760:T},m.prototype.readInt16BE=function(p,_){p=p>>>0,_||we(p,2,this.length);const T=this[p+1]|this[p]<<8;return T&32768?T|4294901760:T},m.prototype.readInt32LE=function(p,_){return p=p>>>0,_||we(p,4,this.length),this[p]|this[p+1]<<8|this[p+2]<<16|this[p+3]<<24},m.prototype.readInt32BE=function(p,_){return p=p>>>0,_||we(p,4,this.length),this[p]<<24|this[p+1]<<16|this[p+2]<<8|this[p+3]},m.prototype.readBigInt64LE=wt(function(p){p=p>>>0,Ot(p,"offset");const _=this[p],T=this[p+7];(_===void 0||T===void 0)&&ki(p,this.length-8);const L=this[p+4]+this[p+5]*2**8+this[p+6]*2**16+(T<<24);return(BigInt(L)<<BigInt(32))+BigInt(_+this[++p]*2**8+this[++p]*2**16+this[++p]*2**24)}),m.prototype.readBigInt64BE=wt(function(p){p=p>>>0,Ot(p,"offset");const _=this[p],T=this[p+7];(_===void 0||T===void 0)&&ki(p,this.length-8);const L=(_<<24)+this[++p]*2**16+this[++p]*2**8+this[++p];return(BigInt(L)<<BigInt(32))+BigInt(this[++p]*2**24+this[++p]*2**16+this[++p]*2**8+T)}),m.prototype.readFloatLE=function(p,_){return p=p>>>0,_||we(p,4,this.length),t.read(this,p,!0,23,4)},m.prototype.readFloatBE=function(p,_){return p=p>>>0,_||we(p,4,this.length),t.read(this,p,!1,23,4)},m.prototype.readDoubleLE=function(p,_){return p=p>>>0,_||we(p,8,this.length),t.read(this,p,!0,52,8)},m.prototype.readDoubleBE=function(p,_){return p=p>>>0,_||we(p,8,this.length),t.read(this,p,!1,52,8)};function le(p,_,T,L,U,q){if(!m.isBuffer(p))throw new TypeError('"buffer" argument must be a Buffer instance');if(_>U||_<q)throw new RangeError('"value" argument is out of bounds');if(T+L>p.length)throw new RangeError("Index out of range")}m.prototype.writeUintLE=m.prototype.writeUIntLE=function(p,_,T,L){if(p=+p,_=_>>>0,T=T>>>0,!L){const K=Math.pow(2,8*T)-1;le(this,p,_,T,K,0)}let U=1,q=0;for(this[_]=p&255;++q<T&&(U*=256);)this[_+q]=p/U&255;return _+T},m.prototype.writeUintBE=m.prototype.writeUIntBE=function(p,_,T,L){if(p=+p,_=_>>>0,T=T>>>0,!L){const K=Math.pow(2,8*T)-1;le(this,p,_,T,K,0)}let U=T-1,q=1;for(this[_+U]=p&255;--U>=0&&(q*=256);)this[_+U]=p/q&255;return _+T},m.prototype.writeUint8=m.prototype.writeUInt8=function(p,_,T){return p=+p,_=_>>>0,T||le(this,p,_,1,255,0),this[_]=p&255,_+1},m.prototype.writeUint16LE=m.prototype.writeUInt16LE=function(p,_,T){return p=+p,_=_>>>0,T||le(this,p,_,2,65535,0),this[_]=p&255,this[_+1]=p>>>8,_+2},m.prototype.writeUint16BE=m.prototype.writeUInt16BE=function(p,_,T){return p=+p,_=_>>>0,T||le(this,p,_,2,65535,0),this[_]=p>>>8,this[_+1]=p&255,_+2},m.prototype.writeUint32LE=m.prototype.writeUInt32LE=function(p,_,T){return p=+p,_=_>>>0,T||le(this,p,_,4,4294967295,0),this[_+3]=p>>>24,this[_+2]=p>>>16,this[_+1]=p>>>8,this[_]=p&255,_+4},m.prototype.writeUint32BE=m.prototype.writeUInt32BE=function(p,_,T){return p=+p,_=_>>>0,T||le(this,p,_,4,4294967295,0),this[_]=p>>>24,this[_+1]=p>>>16,this[_+2]=p>>>8,this[_+3]=p&255,_+4};function Re(p,_,T,L,U){Dt(_,L,U,p,T,7);let q=Number(_&BigInt(4294967295));p[T++]=q,q=q>>8,p[T++]=q,q=q>>8,p[T++]=q,q=q>>8,p[T++]=q;let K=Number(_>>BigInt(32)&BigInt(4294967295));return p[T++]=K,K=K>>8,p[T++]=K,K=K>>8,p[T++]=K,K=K>>8,p[T++]=K,T}function Hi(p,_,T,L,U){Dt(_,L,U,p,T,7);let q=Number(_&BigInt(4294967295));p[T+7]=q,q=q>>8,p[T+6]=q,q=q>>8,p[T+5]=q,q=q>>8,p[T+4]=q;let K=Number(_>>BigInt(32)&BigInt(4294967295));return p[T+3]=K,K=K>>8,p[T+2]=K,K=K>>8,p[T+1]=K,K=K>>8,p[T]=K,T+8}m.prototype.writeBigUInt64LE=wt(function(p,_=0){return Re(this,p,_,BigInt(0),BigInt("0xffffffffffffffff"))}),m.prototype.writeBigUInt64BE=wt(function(p,_=0){return Hi(this,p,_,BigInt(0),BigInt("0xffffffffffffffff"))}),m.prototype.writeIntLE=function(p,_,T,L){if(p=+p,_=_>>>0,!L){const Se=Math.pow(2,8*T-1);le(this,p,_,T,Se-1,-Se)}let U=0,q=1,K=0;for(this[_]=p&255;++U<T&&(q*=256);)p<0&&K===0&&this[_+U-1]!==0&&(K=1),this[_+U]=(p/q>>0)-K&255;return _+T},m.prototype.writeIntBE=function(p,_,T,L){if(p=+p,_=_>>>0,!L){const Se=Math.pow(2,8*T-1);le(this,p,_,T,Se-1,-Se)}let U=T-1,q=1,K=0;for(this[_+U]=p&255;--U>=0&&(q*=256);)p<0&&K===0&&this[_+U+1]!==0&&(K=1),this[_+U]=(p/q>>0)-K&255;return _+T},m.prototype.writeInt8=function(p,_,T){return p=+p,_=_>>>0,T||le(this,p,_,1,127,-128),p<0&&(p=255+p+1),this[_]=p&255,_+1},m.prototype.writeInt16LE=function(p,_,T){return p=+p,_=_>>>0,T||le(this,p,_,2,32767,-32768),this[_]=p&255,this[_+1]=p>>>8,_+2},m.prototype.writeInt16BE=function(p,_,T){return p=+p,_=_>>>0,T||le(this,p,_,2,32767,-32768),this[_]=p>>>8,this[_+1]=p&255,_+2},m.prototype.writeInt32LE=function(p,_,T){return p=+p,_=_>>>0,T||le(this,p,_,4,2147483647,-2147483648),this[_]=p&255,this[_+1]=p>>>8,this[_+2]=p>>>16,this[_+3]=p>>>24,_+4},m.prototype.writeInt32BE=function(p,_,T){return p=+p,_=_>>>0,T||le(this,p,_,4,2147483647,-2147483648),p<0&&(p=4294967295+p+1),this[_]=p>>>24,this[_+1]=p>>>16,this[_+2]=p>>>8,this[_+3]=p&255,_+4},m.prototype.writeBigInt64LE=wt(function(p,_=0){return Re(this,p,_,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),m.prototype.writeBigInt64BE=wt(function(p,_=0){return Hi(this,p,_,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function oi(p,_,T,L,U,q){if(T+L>p.length)throw new RangeError("Index out of range");if(T<0)throw new RangeError("Index out of range")}function li(p,_,T,L,U){return _=+_,T=T>>>0,U||oi(p,_,T,4),t.write(p,_,T,L,23,4),T+4}m.prototype.writeFloatLE=function(p,_,T){return li(this,p,_,!0,T)},m.prototype.writeFloatBE=function(p,_,T){return li(this,p,_,!1,T)};function Ei(p,_,T,L,U){return _=+_,T=T>>>0,U||oi(p,_,T,8),t.write(p,_,T,L,52,8),T+8}m.prototype.writeDoubleLE=function(p,_,T){return Ei(this,p,_,!0,T)},m.prototype.writeDoubleBE=function(p,_,T){return Ei(this,p,_,!1,T)},m.prototype.copy=function(p,_,T,L){if(!m.isBuffer(p))throw new TypeError("argument should be a Buffer");if(T||(T=0),!L&&L!==0&&(L=this.length),_>=p.length&&(_=p.length),_||(_=0),L>0&&L<T&&(L=T),L===T||p.length===0||this.length===0)return 0;if(_<0)throw new RangeError("targetStart out of bounds");if(T<0||T>=this.length)throw new RangeError("Index out of range");if(L<0)throw new RangeError("sourceEnd out of bounds");L>this.length&&(L=this.length),p.length-_<L-T&&(L=p.length-_+T);const U=L-T;return this===p&&typeof r.prototype.copyWithin=="function"?this.copyWithin(_,T,L):r.prototype.set.call(p,this.subarray(T,L),_),U},m.prototype.fill=function(p,_,T,L){if(typeof p=="string"){if(typeof _=="string"?(L=_,_=0,T=this.length):typeof T=="string"&&(L=T,T=this.length),L!==void 0&&typeof L!="string")throw new TypeError("encoding must be a string");if(typeof L=="string"&&!m.isEncoding(L))throw new TypeError("Unknown encoding: "+L);if(p.length===1){const q=p.charCodeAt(0);(L==="utf8"&&q<128||L==="latin1")&&(p=q)}}else typeof p=="number"?p=p&255:typeof p=="boolean"&&(p=Number(p));if(_<0||this.length<_||this.length<T)throw new RangeError("Out of range index");if(T<=_)return this;_=_>>>0,T=T===void 0?this.length:T>>>0,p||(p=0);let U;if(typeof p=="number")for(U=_;U<T;++U)this[U]=p;else{const q=m.isBuffer(p)?p:m.from(p,L),K=q.length;if(K===0)throw new TypeError('The value "'+p+'" is invalid for argument "value"');for(U=0;U<T-_;++U)this[U+_]=q[U%K]}return this};const yt={};function ui(p,_,T){yt[p]=class extends T{constructor(){super(),Object.defineProperty(this,"message",{value:_.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${p}]`,this.stack,delete this.name}get code(){return p}set code(L){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:L,writable:!0})}toString(){return`${this.name} [${p}]: ${this.message}`}}}ui("ERR_BUFFER_OUT_OF_BOUNDS",function(p){return p?`${p} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),ui("ERR_INVALID_ARG_TYPE",function(p,_){return`The "${p}" argument must be of type number. Received type ${typeof _}`},TypeError),ui("ERR_OUT_OF_RANGE",function(p,_,T){let L=`The value of "${p}" is out of range.`,U=T;return Number.isInteger(T)&&Math.abs(T)>2**32?U=Ft(String(T)):typeof T=="bigint"&&(U=String(T),(T>BigInt(2)**BigInt(32)||T<-(BigInt(2)**BigInt(32)))&&(U=Ft(U)),U+="n"),L+=` It must be ${_}. Received ${U}`,L},RangeError);function Ft(p){let _="",T=p.length;const L=p[0]==="-"?1:0;for(;T>=L+4;T-=3)_=`_${p.slice(T-3,T)}${_}`;return`${p.slice(0,T)}${_}`}function wi(p,_,T){Ot(_,"offset"),(p[_]===void 0||p[_+T]===void 0)&&ki(_,p.length-(T+1))}function Dt(p,_,T,L,U,q){if(p>T||p<_){const K=typeof _=="bigint"?"n":"";let Se;throw _===0||_===BigInt(0)?Se=`>= 0${K} and < 2${K} ** ${(q+1)*8}${K}`:Se=`>= -(2${K} ** ${(q+1)*8-1}${K}) and < 2 ** ${(q+1)*8-1}${K}`,new yt.ERR_OUT_OF_RANGE("value",Se,p)}wi(L,U,q)}function Ot(p,_){if(typeof p!="number")throw new yt.ERR_INVALID_ARG_TYPE(_,"number",p)}function ki(p,_,T){throw Math.floor(p)!==p?(Ot(p,T),new yt.ERR_OUT_OF_RANGE("offset","an integer",p)):_<0?new yt.ERR_BUFFER_OUT_OF_BOUNDS:new yt.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${_}`,p)}const jt=/[^+/0-9A-Za-z-_]/g;function Pn(p){if(p=p.split("=")[0],p=p.trim().replace(jt,""),p.length<2)return"";for(;p.length%4!==0;)p=p+"=";return p}function pe(p,_){_=_||1/0;let T;const L=p.length;let U=null;const q=[];for(let K=0;K<L;++K){if(T=p.charCodeAt(K),T>55295&&T<57344){if(!U){if(T>56319){(_-=3)>-1&&q.push(239,191,189);continue}else if(K+1===L){(_-=3)>-1&&q.push(239,191,189);continue}U=T;continue}if(T<56320){(_-=3)>-1&&q.push(239,191,189),U=T;continue}T=(U-55296<<10|T-56320)+65536}else U&&(_-=3)>-1&&q.push(239,191,189);if(U=null,T<128){if((_-=1)<0)break;q.push(T)}else if(T<2048){if((_-=2)<0)break;q.push(T>>6|192,T&63|128)}else if(T<65536){if((_-=3)<0)break;q.push(T>>12|224,T>>6&63|128,T&63|128)}else if(T<1114112){if((_-=4)<0)break;q.push(T>>18|240,T>>12&63|128,T>>6&63|128,T&63|128)}else throw new Error("Invalid code point")}return q}function ia(p){const _=[];for(let T=0;T<p.length;++T)_.push(p.charCodeAt(T)&255);return _}function Ln(p,_){let T,L,U;const q=[];for(let K=0;K<p.length&&!((_-=2)<0);++K)T=p.charCodeAt(K),L=T>>8,U=T%256,q.push(U),q.push(L);return q}function Es(p){return e.toByteArray(Pn(p))}function di(p,_,T,L){let U;for(U=0;U<L&&!(U+T>=_.length||U>=p.length);++U)_[U+T]=p[U];return U}function ut(p,_){return p instanceof _||p!=null&&p.constructor!=null&&p.constructor.name!=null&&p.constructor.name===_.name}function Ci(p){return p!==p}const zi=function(){const p="0123456789abcdef",_=new Array(256);for(let T=0;T<16;++T){const L=T*16;for(let U=0;U<16;++U)_[L+U]=p[T]+p[U]}return _}();function wt(p){return typeof BigInt>"u"?ws:p}function ws(){throw new Error("BigInt not supported")}})(nh);const $_=nh.Buffer;var q_=function(i){return x.atob?x.atob(i):$_.from(i,"base64").toString("binary")};function rh(i){for(var e=q_(i),t=new Uint8Array(e.length),n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}/*! @name m3u8-parser @version 7.2.0 @license Apache-2.0 */class V_ extends Co{constructor(){super(),this.buffer=""}push(e){let t;for(this.buffer+=e,t=this.buffer.indexOf(`
|
|
21
|
+
*/(function(s){const e=Br,t=Ao,i=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;s.Buffer=m,s.SlowBuffer=D,s.INSPECT_MAX_BYTES=50;const n=2147483647;s.kMaxLength=n;const{Uint8Array:r,ArrayBuffer:a,SharedArrayBuffer:l}=globalThis;m.TYPED_ARRAY_SUPPORT=h(),!m.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function h(){try{const b=new r(1),g={foo:function(){return 42}};return Object.setPrototypeOf(g,r.prototype),Object.setPrototypeOf(b,g),b.foo()===42}catch{return!1}}Object.defineProperty(m.prototype,"parent",{enumerable:!0,get:function(){if(m.isBuffer(this))return this.buffer}}),Object.defineProperty(m.prototype,"offset",{enumerable:!0,get:function(){if(m.isBuffer(this))return this.byteOffset}});function f(b){if(b>n)throw new RangeError('The value "'+b+'" is invalid for option "size"');const g=new r(b);return Object.setPrototypeOf(g,m.prototype),g}function m(b,g,y){if(typeof b=="number"){if(typeof g=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return P(b)}return T(b,g,y)}m.poolSize=8192;function T(b,g,y){if(typeof b=="string")return v(b,g);if(a.isView(b))return L(b);if(b==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof b);if(lt(b,a)||b&<(b.buffer,a)||typeof l<"u"&&(lt(b,l)||b&<(b.buffer,l)))return N(b,g,y);if(typeof b=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const w=b.valueOf&&b.valueOf();if(w!=null&&w!==b)return m.from(w,g,y);const M=U(b);if(M)return M;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof b[Symbol.toPrimitive]=="function")return m.from(b[Symbol.toPrimitive]("string"),g,y);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof b)}m.from=function(b,g,y){return T(b,g,y)},Object.setPrototypeOf(m.prototype,r.prototype),Object.setPrototypeOf(m,r);function E(b){if(typeof b!="number")throw new TypeError('"size" argument must be of type number');if(b<0)throw new RangeError('The value "'+b+'" is invalid for option "size"')}function C(b,g,y){return E(b),b<=0?f(b):g!==void 0?typeof y=="string"?f(b).fill(g,y):f(b).fill(g):f(b)}m.alloc=function(b,g,y){return C(b,g,y)};function P(b){return E(b),f(b<0?0:F(b)|0)}m.allocUnsafe=function(b){return P(b)},m.allocUnsafeSlow=function(b){return P(b)};function v(b,g){if((typeof g!="string"||g==="")&&(g="utf8"),!m.isEncoding(g))throw new TypeError("Unknown encoding: "+g);const y=V(b,g)|0;let w=f(y);const M=w.write(b,g);return M!==y&&(w=w.slice(0,M)),w}function R(b){const g=b.length<0?0:F(b.length)|0,y=f(g);for(let w=0;w<g;w+=1)y[w]=b[w]&255;return y}function L(b){if(lt(b,r)){const g=new r(b);return N(g.buffer,g.byteOffset,g.byteLength)}return R(b)}function N(b,g,y){if(g<0||b.byteLength<g)throw new RangeError('"offset" is outside of buffer bounds');if(b.byteLength<g+(y||0))throw new RangeError('"length" is outside of buffer bounds');let w;return g===void 0&&y===void 0?w=new r(b):y===void 0?w=new r(b,g):w=new r(b,g,y),Object.setPrototypeOf(w,m.prototype),w}function U(b){if(m.isBuffer(b)){const g=F(b.length)|0,y=f(g);return y.length===0||b.copy(y,0,0,g),y}if(b.length!==void 0)return typeof b.length!="number"||ki(b.length)?f(0):R(b);if(b.type==="Buffer"&&Array.isArray(b.data))return R(b.data)}function F(b){if(b>=n)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+n.toString(16)+" bytes");return b|0}function D(b){return+b!=b&&(b=0),m.alloc(+b)}m.isBuffer=function(g){return g!=null&&g._isBuffer===!0&&g!==m.prototype},m.compare=function(g,y){if(lt(g,r)&&(g=m.from(g,g.offset,g.byteLength)),lt(y,r)&&(y=m.from(y,y.offset,y.byteLength)),!m.isBuffer(g)||!m.isBuffer(y))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(g===y)return 0;let w=g.length,M=y.length;for(let $=0,z=Math.min(w,M);$<z;++$)if(g[$]!==y[$]){w=g[$],M=y[$];break}return w<M?-1:M<w?1:0},m.isEncoding=function(g){switch(String(g).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},m.concat=function(g,y){if(!Array.isArray(g))throw new TypeError('"list" argument must be an Array of Buffers');if(g.length===0)return m.alloc(0);let w;if(y===void 0)for(y=0,w=0;w<g.length;++w)y+=g[w].length;const M=m.allocUnsafe(y);let $=0;for(w=0;w<g.length;++w){let z=g[w];if(lt(z,r))$+z.length>M.length?(m.isBuffer(z)||(z=m.from(z)),z.copy(M,$)):r.prototype.set.call(M,z,$);else if(m.isBuffer(z))z.copy(M,$);else throw new TypeError('"list" argument must be an Array of Buffers');$+=z.length}return M};function V(b,g){if(m.isBuffer(b))return b.length;if(a.isView(b)||lt(b,a))return b.byteLength;if(typeof b!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof b);const y=b.length,w=arguments.length>2&&arguments[2]===!0;if(!w&&y===0)return 0;let M=!1;for(;;)switch(g){case"ascii":case"latin1":case"binary":return y;case"utf8":case"utf-8":return pe(b).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return y*2;case"hex":return y>>>1;case"base64":return In(b).length;default:if(M)return w?-1:pe(b).length;g=(""+g).toLowerCase(),M=!0}}m.byteLength=V;function X(b,g,y){let w=!1;if((g===void 0||g<0)&&(g=0),g>this.length||((y===void 0||y>this.length)&&(y=this.length),y<=0)||(y>>>=0,g>>>=0,y<=g))return"";for(b||(b="utf8");;)switch(b){case"hex":return pt(this,g,y);case"utf8":case"utf-8":return Qe(this,g,y);case"ascii":return be(this,g,y);case"latin1":case"binary":return me(this,g,y);case"base64":return Xe(this,g,y);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return xt(this,g,y);default:if(w)throw new TypeError("Unknown encoding: "+b);b=(b+"").toLowerCase(),w=!0}}m.prototype._isBuffer=!0;function G(b,g,y){const w=b[g];b[g]=b[y],b[y]=w}m.prototype.swap16=function(){const g=this.length;if(g%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let y=0;y<g;y+=2)G(this,y,y+1);return this},m.prototype.swap32=function(){const g=this.length;if(g%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let y=0;y<g;y+=4)G(this,y,y+3),G(this,y+1,y+2);return this},m.prototype.swap64=function(){const g=this.length;if(g%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let y=0;y<g;y+=8)G(this,y,y+7),G(this,y+1,y+6),G(this,y+2,y+5),G(this,y+3,y+4);return this},m.prototype.toString=function(){const g=this.length;return g===0?"":arguments.length===0?Qe(this,0,g):X.apply(this,arguments)},m.prototype.toLocaleString=m.prototype.toString,m.prototype.equals=function(g){if(!m.isBuffer(g))throw new TypeError("Argument must be a Buffer");return this===g?!0:m.compare(this,g)===0},m.prototype.inspect=function(){let g="";const y=s.INSPECT_MAX_BYTES;return g=this.toString("hex",0,y).replace(/(.{2})/g,"$1 ").trim(),this.length>y&&(g+=" ... "),"<Buffer "+g+">"},i&&(m.prototype[i]=m.prototype.inspect),m.prototype.compare=function(g,y,w,M,$){if(lt(g,r)&&(g=m.from(g,g.offset,g.byteLength)),!m.isBuffer(g))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof g);if(y===void 0&&(y=0),w===void 0&&(w=g?g.length:0),M===void 0&&(M=0),$===void 0&&($=this.length),y<0||w>g.length||M<0||$>this.length)throw new RangeError("out of range index");if(M>=$&&y>=w)return 0;if(M>=$)return-1;if(y>=w)return 1;if(y>>>=0,w>>>=0,M>>>=0,$>>>=0,this===g)return 0;let z=$-M,le=w-y;const Pe=Math.min(z,le),Ce=this.slice(M,$),De=g.slice(y,w);for(let ye=0;ye<Pe;++ye)if(Ce[ye]!==De[ye]){z=Ce[ye],le=De[ye];break}return z<le?-1:le<z?1:0};function ae(b,g,y,w,M){if(b.length===0)return-1;if(typeof y=="string"?(w=y,y=0):y>2147483647?y=2147483647:y<-2147483648&&(y=-2147483648),y=+y,ki(y)&&(y=M?0:b.length-1),y<0&&(y=b.length+y),y>=b.length){if(M)return-1;y=b.length-1}else if(y<0)if(M)y=0;else return-1;if(typeof g=="string"&&(g=m.from(g,w)),m.isBuffer(g))return g.length===0?-1:fe(b,g,y,w,M);if(typeof g=="number")return g=g&255,typeof r.prototype.indexOf=="function"?M?r.prototype.indexOf.call(b,g,y):r.prototype.lastIndexOf.call(b,g,y):fe(b,[g],y,w,M);throw new TypeError("val must be string, number or Buffer")}function fe(b,g,y,w,M){let $=1,z=b.length,le=g.length;if(w!==void 0&&(w=String(w).toLowerCase(),w==="ucs2"||w==="ucs-2"||w==="utf16le"||w==="utf-16le")){if(b.length<2||g.length<2)return-1;$=2,z/=2,le/=2,y/=2}function Pe(De,ye){return $===1?De[ye]:De.readUInt16BE(ye*$)}let Ce;if(M){let De=-1;for(Ce=y;Ce<z;Ce++)if(Pe(b,Ce)===Pe(g,De===-1?0:Ce-De)){if(De===-1&&(De=Ce),Ce-De+1===le)return De*$}else De!==-1&&(Ce-=Ce-De),De=-1}else for(y+le>z&&(y=z-le),Ce=y;Ce>=0;Ce--){let De=!0;for(let ye=0;ye<le;ye++)if(Pe(b,Ce+ye)!==Pe(g,ye)){De=!1;break}if(De)return Ce}return-1}m.prototype.includes=function(g,y,w){return this.indexOf(g,y,w)!==-1},m.prototype.indexOf=function(g,y,w){return ae(this,g,y,w,!0)},m.prototype.lastIndexOf=function(g,y,w){return ae(this,g,y,w,!1)};function ve(b,g,y,w){y=Number(y)||0;const M=b.length-y;w?(w=Number(w),w>M&&(w=M)):w=M;const $=g.length;w>$/2&&(w=$/2);let z;for(z=0;z<w;++z){const le=parseInt(g.substr(z*2,2),16);if(ki(le))return z;b[y+z]=le}return z}function he(b,g,y,w){return hi(pe(g,b.length-y),b,y,w)}function Z(b,g,y,w){return hi(ra(g),b,y,w)}function de(b,g,y,w){return hi(In(g),b,y,w)}function ee(b,g,y,w){return hi(Ls(g,b.length-y),b,y,w)}m.prototype.write=function(g,y,w,M){if(y===void 0)M="utf8",w=this.length,y=0;else if(w===void 0&&typeof y=="string")M=y,w=this.length,y=0;else if(isFinite(y))y=y>>>0,isFinite(w)?(w=w>>>0,M===void 0&&(M="utf8")):(M=w,w=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const $=this.length-y;if((w===void 0||w>$)&&(w=$),g.length>0&&(w<0||y<0)||y>this.length)throw new RangeError("Attempt to write outside buffer bounds");M||(M="utf8");let z=!1;for(;;)switch(M){case"hex":return ve(this,g,y,w);case"utf8":case"utf-8":return he(this,g,y,w);case"ascii":case"latin1":case"binary":return Z(this,g,y,w);case"base64":return de(this,g,y,w);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ee(this,g,y,w);default:if(z)throw new TypeError("Unknown encoding: "+M);M=(""+M).toLowerCase(),z=!0}},m.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Xe(b,g,y){return g===0&&y===b.length?e.fromByteArray(b):e.fromByteArray(b.slice(g,y))}function Qe(b,g,y){y=Math.min(b.length,y);const w=[];let M=g;for(;M<y;){const $=b[M];let z=null,le=$>239?4:$>223?3:$>191?2:1;if(M+le<=y){let Pe,Ce,De,ye;switch(le){case 1:$<128&&(z=$);break;case 2:Pe=b[M+1],(Pe&192)===128&&(ye=($&31)<<6|Pe&63,ye>127&&(z=ye));break;case 3:Pe=b[M+1],Ce=b[M+2],(Pe&192)===128&&(Ce&192)===128&&(ye=($&15)<<12|(Pe&63)<<6|Ce&63,ye>2047&&(ye<55296||ye>57343)&&(z=ye));break;case 4:Pe=b[M+1],Ce=b[M+2],De=b[M+3],(Pe&192)===128&&(Ce&192)===128&&(De&192)===128&&(ye=($&15)<<18|(Pe&63)<<12|(Ce&63)<<6|De&63,ye>65535&&ye<1114112&&(z=ye))}}z===null?(z=65533,le=1):z>65535&&(z-=65536,w.push(z>>>10&1023|55296),z=56320|z&1023),w.push(z),M+=le}return qe(w)}const Ve=4096;function qe(b){const g=b.length;if(g<=Ve)return String.fromCharCode.apply(String,b);let y="",w=0;for(;w<g;)y+=String.fromCharCode.apply(String,b.slice(w,w+=Ve));return y}function be(b,g,y){let w="";y=Math.min(b.length,y);for(let M=g;M<y;++M)w+=String.fromCharCode(b[M]&127);return w}function me(b,g,y){let w="";y=Math.min(b.length,y);for(let M=g;M<y;++M)w+=String.fromCharCode(b[M]);return w}function pt(b,g,y){const w=b.length;(!g||g<0)&&(g=0),(!y||y<0||y>w)&&(y=w);let M="";for(let $=g;$<y;++$)M+=Wi[b[$]];return M}function xt(b,g,y){const w=b.slice(g,y);let M="";for(let $=0;$<w.length-1;$+=2)M+=String.fromCharCode(w[$]+w[$+1]*256);return M}m.prototype.slice=function(g,y){const w=this.length;g=~~g,y=y===void 0?w:~~y,g<0?(g+=w,g<0&&(g=0)):g>w&&(g=w),y<0?(y+=w,y<0&&(y=0)):y>w&&(y=w),y<g&&(y=g);const M=this.subarray(g,y);return Object.setPrototypeOf(M,m.prototype),M};function Ee(b,g,y){if(b%1!==0||b<0)throw new RangeError("offset is not uint");if(b+g>y)throw new RangeError("Trying to access beyond buffer length")}m.prototype.readUintLE=m.prototype.readUIntLE=function(g,y,w){g=g>>>0,y=y>>>0,w||Ee(g,y,this.length);let M=this[g],$=1,z=0;for(;++z<y&&($*=256);)M+=this[g+z]*$;return M},m.prototype.readUintBE=m.prototype.readUIntBE=function(g,y,w){g=g>>>0,y=y>>>0,w||Ee(g,y,this.length);let M=this[g+--y],$=1;for(;y>0&&($*=256);)M+=this[g+--y]*$;return M},m.prototype.readUint8=m.prototype.readUInt8=function(g,y){return g=g>>>0,y||Ee(g,1,this.length),this[g]},m.prototype.readUint16LE=m.prototype.readUInt16LE=function(g,y){return g=g>>>0,y||Ee(g,2,this.length),this[g]|this[g+1]<<8},m.prototype.readUint16BE=m.prototype.readUInt16BE=function(g,y){return g=g>>>0,y||Ee(g,2,this.length),this[g]<<8|this[g+1]},m.prototype.readUint32LE=m.prototype.readUInt32LE=function(g,y){return g=g>>>0,y||Ee(g,4,this.length),(this[g]|this[g+1]<<8|this[g+2]<<16)+this[g+3]*16777216},m.prototype.readUint32BE=m.prototype.readUInt32BE=function(g,y){return g=g>>>0,y||Ee(g,4,this.length),this[g]*16777216+(this[g+1]<<16|this[g+2]<<8|this[g+3])},m.prototype.readBigUInt64LE=St(function(g){g=g>>>0,Lt(g,"offset");const y=this[g],w=this[g+7];(y===void 0||w===void 0)&&Ai(g,this.length-8);const M=y+this[++g]*2**8+this[++g]*2**16+this[++g]*2**24,$=this[++g]+this[++g]*2**8+this[++g]*2**16+w*2**24;return BigInt(M)+(BigInt($)<<BigInt(32))}),m.prototype.readBigUInt64BE=St(function(g){g=g>>>0,Lt(g,"offset");const y=this[g],w=this[g+7];(y===void 0||w===void 0)&&Ai(g,this.length-8);const M=y*2**24+this[++g]*2**16+this[++g]*2**8+this[++g],$=this[++g]*2**24+this[++g]*2**16+this[++g]*2**8+w;return(BigInt(M)<<BigInt(32))+BigInt($)}),m.prototype.readIntLE=function(g,y,w){g=g>>>0,y=y>>>0,w||Ee(g,y,this.length);let M=this[g],$=1,z=0;for(;++z<y&&($*=256);)M+=this[g+z]*$;return $*=128,M>=$&&(M-=Math.pow(2,8*y)),M},m.prototype.readIntBE=function(g,y,w){g=g>>>0,y=y>>>0,w||Ee(g,y,this.length);let M=y,$=1,z=this[g+--M];for(;M>0&&($*=256);)z+=this[g+--M]*$;return $*=128,z>=$&&(z-=Math.pow(2,8*y)),z},m.prototype.readInt8=function(g,y){return g=g>>>0,y||Ee(g,1,this.length),this[g]&128?(255-this[g]+1)*-1:this[g]},m.prototype.readInt16LE=function(g,y){g=g>>>0,y||Ee(g,2,this.length);const w=this[g]|this[g+1]<<8;return w&32768?w|4294901760:w},m.prototype.readInt16BE=function(g,y){g=g>>>0,y||Ee(g,2,this.length);const w=this[g+1]|this[g]<<8;return w&32768?w|4294901760:w},m.prototype.readInt32LE=function(g,y){return g=g>>>0,y||Ee(g,4,this.length),this[g]|this[g+1]<<8|this[g+2]<<16|this[g+3]<<24},m.prototype.readInt32BE=function(g,y){return g=g>>>0,y||Ee(g,4,this.length),this[g]<<24|this[g+1]<<16|this[g+2]<<8|this[g+3]},m.prototype.readBigInt64LE=St(function(g){g=g>>>0,Lt(g,"offset");const y=this[g],w=this[g+7];(y===void 0||w===void 0)&&Ai(g,this.length-8);const M=this[g+4]+this[g+5]*2**8+this[g+6]*2**16+(w<<24);return(BigInt(M)<<BigInt(32))+BigInt(y+this[++g]*2**8+this[++g]*2**16+this[++g]*2**24)}),m.prototype.readBigInt64BE=St(function(g){g=g>>>0,Lt(g,"offset");const y=this[g],w=this[g+7];(y===void 0||w===void 0)&&Ai(g,this.length-8);const M=(y<<24)+this[++g]*2**16+this[++g]*2**8+this[++g];return(BigInt(M)<<BigInt(32))+BigInt(this[++g]*2**24+this[++g]*2**16+this[++g]*2**8+w)}),m.prototype.readFloatLE=function(g,y){return g=g>>>0,y||Ee(g,4,this.length),t.read(this,g,!0,23,4)},m.prototype.readFloatBE=function(g,y){return g=g>>>0,y||Ee(g,4,this.length),t.read(this,g,!1,23,4)},m.prototype.readDoubleLE=function(g,y){return g=g>>>0,y||Ee(g,8,this.length),t.read(this,g,!0,52,8)},m.prototype.readDoubleBE=function(g,y){return g=g>>>0,y||Ee(g,8,this.length),t.read(this,g,!1,52,8)};function ce(b,g,y,w,M,$){if(!m.isBuffer(b))throw new TypeError('"buffer" argument must be a Buffer instance');if(g>M||g<$)throw new RangeError('"value" argument is out of bounds');if(y+w>b.length)throw new RangeError("Index out of range")}m.prototype.writeUintLE=m.prototype.writeUIntLE=function(g,y,w,M){if(g=+g,y=y>>>0,w=w>>>0,!M){const le=Math.pow(2,8*w)-1;ce(this,g,y,w,le,0)}let $=1,z=0;for(this[y]=g&255;++z<w&&($*=256);)this[y+z]=g/$&255;return y+w},m.prototype.writeUintBE=m.prototype.writeUIntBE=function(g,y,w,M){if(g=+g,y=y>>>0,w=w>>>0,!M){const le=Math.pow(2,8*w)-1;ce(this,g,y,w,le,0)}let $=w-1,z=1;for(this[y+$]=g&255;--$>=0&&(z*=256);)this[y+$]=g/z&255;return y+w},m.prototype.writeUint8=m.prototype.writeUInt8=function(g,y,w){return g=+g,y=y>>>0,w||ce(this,g,y,1,255,0),this[y]=g&255,y+1},m.prototype.writeUint16LE=m.prototype.writeUInt16LE=function(g,y,w){return g=+g,y=y>>>0,w||ce(this,g,y,2,65535,0),this[y]=g&255,this[y+1]=g>>>8,y+2},m.prototype.writeUint16BE=m.prototype.writeUInt16BE=function(g,y,w){return g=+g,y=y>>>0,w||ce(this,g,y,2,65535,0),this[y]=g>>>8,this[y+1]=g&255,y+2},m.prototype.writeUint32LE=m.prototype.writeUInt32LE=function(g,y,w){return g=+g,y=y>>>0,w||ce(this,g,y,4,4294967295,0),this[y+3]=g>>>24,this[y+2]=g>>>16,this[y+1]=g>>>8,this[y]=g&255,y+4},m.prototype.writeUint32BE=m.prototype.writeUInt32BE=function(g,y,w){return g=+g,y=y>>>0,w||ce(this,g,y,4,4294967295,0),this[y]=g>>>24,this[y+1]=g>>>16,this[y+2]=g>>>8,this[y+3]=g&255,y+4};function Ue(b,g,y,w,M){Dt(g,w,M,b,y,7);let $=Number(g&BigInt(4294967295));b[y++]=$,$=$>>8,b[y++]=$,$=$>>8,b[y++]=$,$=$>>8,b[y++]=$;let z=Number(g>>BigInt(32)&BigInt(4294967295));return b[y++]=z,z=z>>8,b[y++]=z,z=z>>8,b[y++]=z,z=z>>8,b[y++]=z,y}function zi(b,g,y,w,M){Dt(g,w,M,b,y,7);let $=Number(g&BigInt(4294967295));b[y+7]=$,$=$>>8,b[y+6]=$,$=$>>8,b[y+5]=$,$=$>>8,b[y+4]=$;let z=Number(g>>BigInt(32)&BigInt(4294967295));return b[y+3]=z,z=z>>8,b[y+2]=z,z=z>>8,b[y+1]=z,z=z>>8,b[y]=z,y+8}m.prototype.writeBigUInt64LE=St(function(g,y=0){return Ue(this,g,y,BigInt(0),BigInt("0xffffffffffffffff"))}),m.prototype.writeBigUInt64BE=St(function(g,y=0){return zi(this,g,y,BigInt(0),BigInt("0xffffffffffffffff"))}),m.prototype.writeIntLE=function(g,y,w,M){if(g=+g,y=y>>>0,!M){const Pe=Math.pow(2,8*w-1);ce(this,g,y,w,Pe-1,-Pe)}let $=0,z=1,le=0;for(this[y]=g&255;++$<w&&(z*=256);)g<0&&le===0&&this[y+$-1]!==0&&(le=1),this[y+$]=(g/z>>0)-le&255;return y+w},m.prototype.writeIntBE=function(g,y,w,M){if(g=+g,y=y>>>0,!M){const Pe=Math.pow(2,8*w-1);ce(this,g,y,w,Pe-1,-Pe)}let $=w-1,z=1,le=0;for(this[y+$]=g&255;--$>=0&&(z*=256);)g<0&&le===0&&this[y+$+1]!==0&&(le=1),this[y+$]=(g/z>>0)-le&255;return y+w},m.prototype.writeInt8=function(g,y,w){return g=+g,y=y>>>0,w||ce(this,g,y,1,127,-128),g<0&&(g=255+g+1),this[y]=g&255,y+1},m.prototype.writeInt16LE=function(g,y,w){return g=+g,y=y>>>0,w||ce(this,g,y,2,32767,-32768),this[y]=g&255,this[y+1]=g>>>8,y+2},m.prototype.writeInt16BE=function(g,y,w){return g=+g,y=y>>>0,w||ce(this,g,y,2,32767,-32768),this[y]=g>>>8,this[y+1]=g&255,y+2},m.prototype.writeInt32LE=function(g,y,w){return g=+g,y=y>>>0,w||ce(this,g,y,4,2147483647,-2147483648),this[y]=g&255,this[y+1]=g>>>8,this[y+2]=g>>>16,this[y+3]=g>>>24,y+4},m.prototype.writeInt32BE=function(g,y,w){return g=+g,y=y>>>0,w||ce(this,g,y,4,2147483647,-2147483648),g<0&&(g=4294967295+g+1),this[y]=g>>>24,this[y+1]=g>>>16,this[y+2]=g>>>8,this[y+3]=g&255,y+4},m.prototype.writeBigInt64LE=St(function(g,y=0){return Ue(this,g,y,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),m.prototype.writeBigInt64BE=St(function(g,y=0){return zi(this,g,y,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function ui(b,g,y,w,M,$){if(y+w>b.length)throw new RangeError("Index out of range");if(y<0)throw new RangeError("Index out of range")}function ci(b,g,y,w,M){return g=+g,y=y>>>0,M||ui(b,g,y,4),t.write(b,g,y,w,23,4),y+4}m.prototype.writeFloatLE=function(g,y,w){return ci(this,g,y,!0,w)},m.prototype.writeFloatBE=function(g,y,w){return ci(this,g,y,!1,w)};function wi(b,g,y,w,M){return g=+g,y=y>>>0,M||ui(b,g,y,8),t.write(b,g,y,w,52,8),y+8}m.prototype.writeDoubleLE=function(g,y,w){return wi(this,g,y,!0,w)},m.prototype.writeDoubleBE=function(g,y,w){return wi(this,g,y,!1,w)},m.prototype.copy=function(g,y,w,M){if(!m.isBuffer(g))throw new TypeError("argument should be a Buffer");if(w||(w=0),!M&&M!==0&&(M=this.length),y>=g.length&&(y=g.length),y||(y=0),M>0&&M<w&&(M=w),M===w||g.length===0||this.length===0)return 0;if(y<0)throw new RangeError("targetStart out of bounds");if(w<0||w>=this.length)throw new RangeError("Index out of range");if(M<0)throw new RangeError("sourceEnd out of bounds");M>this.length&&(M=this.length),g.length-y<M-w&&(M=g.length-y+w);const $=M-w;return this===g&&typeof r.prototype.copyWithin=="function"?this.copyWithin(y,w,M):r.prototype.set.call(g,this.subarray(w,M),y),$},m.prototype.fill=function(g,y,w,M){if(typeof g=="string"){if(typeof y=="string"?(M=y,y=0,w=this.length):typeof w=="string"&&(M=w,w=this.length),M!==void 0&&typeof M!="string")throw new TypeError("encoding must be a string");if(typeof M=="string"&&!m.isEncoding(M))throw new TypeError("Unknown encoding: "+M);if(g.length===1){const z=g.charCodeAt(0);(M==="utf8"&&z<128||M==="latin1")&&(g=z)}}else typeof g=="number"?g=g&255:typeof g=="boolean"&&(g=Number(g));if(y<0||this.length<y||this.length<w)throw new RangeError("Out of range index");if(w<=y)return this;y=y>>>0,w=w===void 0?this.length:w>>>0,g||(g=0);let $;if(typeof g=="number")for($=y;$<w;++$)this[$]=g;else{const z=m.isBuffer(g)?g:m.from(g,M),le=z.length;if(le===0)throw new TypeError('The value "'+g+'" is invalid for argument "value"');for($=0;$<w-y;++$)this[$+y]=z[$%le]}return this};const mt={};function di(b,g,y){mt[b]=class extends y{constructor(){super(),Object.defineProperty(this,"message",{value:g.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${b}]`,this.stack,delete this.name}get code(){return b}set code(M){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:M,writable:!0})}toString(){return`${this.name} [${b}]: ${this.message}`}}}di("ERR_BUFFER_OUT_OF_BOUNDS",function(b){return b?`${b} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),di("ERR_INVALID_ARG_TYPE",function(b,g){return`The "${b}" argument must be of type number. Received type ${typeof g}`},TypeError),di("ERR_OUT_OF_RANGE",function(b,g,y){let w=`The value of "${b}" is out of range.`,M=y;return Number.isInteger(y)&&Math.abs(y)>2**32?M=Ft(String(y)):typeof y=="bigint"&&(M=String(y),(y>BigInt(2)**BigInt(32)||y<-(BigInt(2)**BigInt(32)))&&(M=Ft(M)),M+="n"),w+=` It must be ${g}. Received ${M}`,w},RangeError);function Ft(b){let g="",y=b.length;const w=b[0]==="-"?1:0;for(;y>=w+4;y-=3)g=`_${b.slice(y-3,y)}${g}`;return`${b.slice(0,y)}${g}`}function Ii(b,g,y){Lt(g,"offset"),(b[g]===void 0||b[g+y]===void 0)&&Ai(g,b.length-(y+1))}function Dt(b,g,y,w,M,$){if(b>y||b<g){const z=typeof g=="bigint"?"n":"";let le;throw g===0||g===BigInt(0)?le=`>= 0${z} and < 2${z} ** ${($+1)*8}${z}`:le=`>= -(2${z} ** ${($+1)*8-1}${z}) and < 2 ** ${($+1)*8-1}${z}`,new mt.ERR_OUT_OF_RANGE("value",le,b)}Ii(w,M,$)}function Lt(b,g){if(typeof b!="number")throw new mt.ERR_INVALID_ARG_TYPE(g,"number",b)}function Ai(b,g,y){throw Math.floor(b)!==b?(Lt(b,y),new mt.ERR_OUT_OF_RANGE("offset","an integer",b)):g<0?new mt.ERR_BUFFER_OUT_OF_BOUNDS:new mt.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${g}`,b)}const $t=/[^+/0-9A-Za-z-_]/g;function Ds(b){if(b=b.split("=")[0],b=b.trim().replace($t,""),b.length<2)return"";for(;b.length%4!==0;)b=b+"=";return b}function pe(b,g){g=g||1/0;let y;const w=b.length;let M=null;const $=[];for(let z=0;z<w;++z){if(y=b.charCodeAt(z),y>55295&&y<57344){if(!M){if(y>56319){(g-=3)>-1&&$.push(239,191,189);continue}else if(z+1===w){(g-=3)>-1&&$.push(239,191,189);continue}M=y;continue}if(y<56320){(g-=3)>-1&&$.push(239,191,189),M=y;continue}y=(M-55296<<10|y-56320)+65536}else M&&(g-=3)>-1&&$.push(239,191,189);if(M=null,y<128){if((g-=1)<0)break;$.push(y)}else if(y<2048){if((g-=2)<0)break;$.push(y>>6|192,y&63|128)}else if(y<65536){if((g-=3)<0)break;$.push(y>>12|224,y>>6&63|128,y&63|128)}else if(y<1114112){if((g-=4)<0)break;$.push(y>>18|240,y>>12&63|128,y>>6&63|128,y&63|128)}else throw new Error("Invalid code point")}return $}function ra(b){const g=[];for(let y=0;y<b.length;++y)g.push(b.charCodeAt(y)&255);return g}function Ls(b,g){let y,w,M;const $=[];for(let z=0;z<b.length&&!((g-=2)<0);++z)y=b.charCodeAt(z),w=y>>8,M=y%256,$.push(M),$.push(w);return $}function In(b){return e.toByteArray(Ds(b))}function hi(b,g,y,w){let M;for(M=0;M<w&&!(M+y>=g.length||M>=b.length);++M)g[M+y]=b[M];return M}function lt(b,g){return b instanceof g||b!=null&&b.constructor!=null&&b.constructor.name!=null&&b.constructor.name===g.name}function ki(b){return b!==b}const Wi=function(){const b="0123456789abcdef",g=new Array(256);for(let y=0;y<16;++y){const w=y*16;for(let M=0;M<16;++M)g[w+M]=b[y]+b[M]}return g}();function St(b){return typeof BigInt>"u"?An:b}function An(){throw new Error("BigInt not supported")}})(sd);const Ny=sd.Buffer;var Uy=function(e){return k.atob?k.atob(e):Ny.from(e,"base64").toString("binary")};function rd(s){for(var e=Uy(s),t=new Uint8Array(e.length),i=0;i<e.length;i++)t[i]=e.charCodeAt(i);return t}/*! @name m3u8-parser @version 7.2.0 @license Apache-2.0 */class By extends Io{constructor(){super(),this.buffer=""}push(e){let t;for(this.buffer+=e,t=this.buffer.indexOf(`
|
|
22
22
|
`);t>-1;t=this.buffer.indexOf(`
|
|
23
|
-
`))this.trigger("data",this.buffer.substring(0,t)),this.buffer=this.buffer.substring(t+1)}}const H_=" ",Ia=function(i){const e=/([0-9.]*)?@?([0-9.]*)?/.exec(i||""),t={};return e[1]&&(t.length=parseInt(e[1],10)),e[2]&&(t.offset=parseInt(e[2],10)),t},z_=function(){const i='(?:[^=]*)=(?:"[^"]*"|[^,]*)';return new RegExp("(?:^|,)("+i+")")},st=function(i){const e={};if(!i)return e;const t=i.split(z_());let n=t.length,s;for(;n--;)t[n]!==""&&(s=/([^=]*)=(.*)/.exec(t[n]).slice(1),s[0]=s[0].replace(/^\s+|\s+$/g,""),s[1]=s[1].replace(/^\s+|\s+$/g,""),s[1]=s[1].replace(/^['"](.*)['"]$/g,"$1"),e[s[0]]=s[1]);return e},bu=i=>{const e=i.split("x"),t={};return e[0]&&(t.width=parseInt(e[0],10)),e[1]&&(t.height=parseInt(e[1],10)),t};class W_ extends Co{constructor(){super(),this.customParsers=[],this.tagMappers=[]}push(e){let t,n;if(e=e.trim(),e.length!==0){if(e[0]!=="#"){this.trigger("data",{type:"uri",uri:e});return}this.tagMappers.reduce((s,r)=>{const a=r(e);return a===e?s:s.concat([a])},[e]).forEach(s=>{for(let r=0;r<this.customParsers.length;r++)if(this.customParsers[r].call(this,s))return;if(s.indexOf("#EXT")!==0){this.trigger("data",{type:"comment",text:s.slice(1)});return}if(s=s.replace("\r",""),t=/^#EXTM3U/.exec(s),t){this.trigger("data",{type:"tag",tagType:"m3u"});return}if(t=/^#EXTINF:([0-9\.]*)?,?(.*)?$/.exec(s),t){n={type:"tag",tagType:"inf"},t[1]&&(n.duration=parseFloat(t[1])),t[2]&&(n.title=t[2]),this.trigger("data",n);return}if(t=/^#EXT-X-TARGETDURATION:([0-9.]*)?/.exec(s),t){n={type:"tag",tagType:"targetduration"},t[1]&&(n.duration=parseInt(t[1],10)),this.trigger("data",n);return}if(t=/^#EXT-X-VERSION:([0-9.]*)?/.exec(s),t){n={type:"tag",tagType:"version"},t[1]&&(n.version=parseInt(t[1],10)),this.trigger("data",n);return}if(t=/^#EXT-X-MEDIA-SEQUENCE:(\-?[0-9.]*)?/.exec(s),t){n={type:"tag",tagType:"media-sequence"},t[1]&&(n.number=parseInt(t[1],10)),this.trigger("data",n);return}if(t=/^#EXT-X-DISCONTINUITY-SEQUENCE:(\-?[0-9.]*)?/.exec(s),t){n={type:"tag",tagType:"discontinuity-sequence"},t[1]&&(n.number=parseInt(t[1],10)),this.trigger("data",n);return}if(t=/^#EXT-X-PLAYLIST-TYPE:(.*)?$/.exec(s),t){n={type:"tag",tagType:"playlist-type"},t[1]&&(n.playlistType=t[1]),this.trigger("data",n);return}if(t=/^#EXT-X-BYTERANGE:(.*)?$/.exec(s),t){n=je(Ia(t[1]),{type:"tag",tagType:"byterange"}),this.trigger("data",n);return}if(t=/^#EXT-X-ALLOW-CACHE:(YES|NO)?/.exec(s),t){n={type:"tag",tagType:"allow-cache"},t[1]&&(n.allowed=!/NO/.test(t[1])),this.trigger("data",n);return}if(t=/^#EXT-X-MAP:(.*)$/.exec(s),t){if(n={type:"tag",tagType:"map"},t[1]){const r=st(t[1]);r.URI&&(n.uri=r.URI),r.BYTERANGE&&(n.byterange=Ia(r.BYTERANGE))}this.trigger("data",n);return}if(t=/^#EXT-X-STREAM-INF:(.*)$/.exec(s),t){n={type:"tag",tagType:"stream-inf"},t[1]&&(n.attributes=st(t[1]),n.attributes.RESOLUTION&&(n.attributes.RESOLUTION=bu(n.attributes.RESOLUTION)),n.attributes.BANDWIDTH&&(n.attributes.BANDWIDTH=parseInt(n.attributes.BANDWIDTH,10)),n.attributes["FRAME-RATE"]&&(n.attributes["FRAME-RATE"]=parseFloat(n.attributes["FRAME-RATE"])),n.attributes["PROGRAM-ID"]&&(n.attributes["PROGRAM-ID"]=parseInt(n.attributes["PROGRAM-ID"],10))),this.trigger("data",n);return}if(t=/^#EXT-X-MEDIA:(.*)$/.exec(s),t){n={type:"tag",tagType:"media"},t[1]&&(n.attributes=st(t[1])),this.trigger("data",n);return}if(t=/^#EXT-X-ENDLIST/.exec(s),t){this.trigger("data",{type:"tag",tagType:"endlist"});return}if(t=/^#EXT-X-DISCONTINUITY/.exec(s),t){this.trigger("data",{type:"tag",tagType:"discontinuity"});return}if(t=/^#EXT-X-PROGRAM-DATE-TIME:(.*)$/.exec(s),t){n={type:"tag",tagType:"program-date-time"},t[1]&&(n.dateTimeString=t[1],n.dateTimeObject=new Date(t[1])),this.trigger("data",n);return}if(t=/^#EXT-X-KEY:(.*)$/.exec(s),t){n={type:"tag",tagType:"key"},t[1]&&(n.attributes=st(t[1]),n.attributes.IV&&(n.attributes.IV.substring(0,2).toLowerCase()==="0x"&&(n.attributes.IV=n.attributes.IV.substring(2)),n.attributes.IV=n.attributes.IV.match(/.{8}/g),n.attributes.IV[0]=parseInt(n.attributes.IV[0],16),n.attributes.IV[1]=parseInt(n.attributes.IV[1],16),n.attributes.IV[2]=parseInt(n.attributes.IV[2],16),n.attributes.IV[3]=parseInt(n.attributes.IV[3],16),n.attributes.IV=new Uint32Array(n.attributes.IV))),this.trigger("data",n);return}if(t=/^#EXT-X-START:(.*)$/.exec(s),t){n={type:"tag",tagType:"start"},t[1]&&(n.attributes=st(t[1]),n.attributes["TIME-OFFSET"]=parseFloat(n.attributes["TIME-OFFSET"]),n.attributes.PRECISE=/YES/.test(n.attributes.PRECISE)),this.trigger("data",n);return}if(t=/^#EXT-X-CUE-OUT-CONT:(.*)?$/.exec(s),t){n={type:"tag",tagType:"cue-out-cont"},t[1]?n.data=t[1]:n.data="",this.trigger("data",n);return}if(t=/^#EXT-X-CUE-OUT:(.*)?$/.exec(s),t){n={type:"tag",tagType:"cue-out"},t[1]?n.data=t[1]:n.data="",this.trigger("data",n);return}if(t=/^#EXT-X-CUE-IN:?(.*)?$/.exec(s),t){n={type:"tag",tagType:"cue-in"},t[1]?n.data=t[1]:n.data="",this.trigger("data",n);return}if(t=/^#EXT-X-SKIP:(.*)$/.exec(s),t&&t[1]){n={type:"tag",tagType:"skip"},n.attributes=st(t[1]),n.attributes.hasOwnProperty("SKIPPED-SEGMENTS")&&(n.attributes["SKIPPED-SEGMENTS"]=parseInt(n.attributes["SKIPPED-SEGMENTS"],10)),n.attributes.hasOwnProperty("RECENTLY-REMOVED-DATERANGES")&&(n.attributes["RECENTLY-REMOVED-DATERANGES"]=n.attributes["RECENTLY-REMOVED-DATERANGES"].split(H_)),this.trigger("data",n);return}if(t=/^#EXT-X-PART:(.*)$/.exec(s),t&&t[1]){n={type:"tag",tagType:"part"},n.attributes=st(t[1]),["DURATION"].forEach(function(r){n.attributes.hasOwnProperty(r)&&(n.attributes[r]=parseFloat(n.attributes[r]))}),["INDEPENDENT","GAP"].forEach(function(r){n.attributes.hasOwnProperty(r)&&(n.attributes[r]=/YES/.test(n.attributes[r]))}),n.attributes.hasOwnProperty("BYTERANGE")&&(n.attributes.byterange=Ia(n.attributes.BYTERANGE)),this.trigger("data",n);return}if(t=/^#EXT-X-SERVER-CONTROL:(.*)$/.exec(s),t&&t[1]){n={type:"tag",tagType:"server-control"},n.attributes=st(t[1]),["CAN-SKIP-UNTIL","PART-HOLD-BACK","HOLD-BACK"].forEach(function(r){n.attributes.hasOwnProperty(r)&&(n.attributes[r]=parseFloat(n.attributes[r]))}),["CAN-SKIP-DATERANGES","CAN-BLOCK-RELOAD"].forEach(function(r){n.attributes.hasOwnProperty(r)&&(n.attributes[r]=/YES/.test(n.attributes[r]))}),this.trigger("data",n);return}if(t=/^#EXT-X-PART-INF:(.*)$/.exec(s),t&&t[1]){n={type:"tag",tagType:"part-inf"},n.attributes=st(t[1]),["PART-TARGET"].forEach(function(r){n.attributes.hasOwnProperty(r)&&(n.attributes[r]=parseFloat(n.attributes[r]))}),this.trigger("data",n);return}if(t=/^#EXT-X-PRELOAD-HINT:(.*)$/.exec(s),t&&t[1]){n={type:"tag",tagType:"preload-hint"},n.attributes=st(t[1]),["BYTERANGE-START","BYTERANGE-LENGTH"].forEach(function(r){if(n.attributes.hasOwnProperty(r)){n.attributes[r]=parseInt(n.attributes[r],10);const a=r==="BYTERANGE-LENGTH"?"length":"offset";n.attributes.byterange=n.attributes.byterange||{},n.attributes.byterange[a]=n.attributes[r],delete n.attributes[r]}}),this.trigger("data",n);return}if(t=/^#EXT-X-RENDITION-REPORT:(.*)$/.exec(s),t&&t[1]){n={type:"tag",tagType:"rendition-report"},n.attributes=st(t[1]),["LAST-MSN","LAST-PART"].forEach(function(r){n.attributes.hasOwnProperty(r)&&(n.attributes[r]=parseInt(n.attributes[r],10))}),this.trigger("data",n);return}if(t=/^#EXT-X-DATERANGE:(.*)$/.exec(s),t&&t[1]){n={type:"tag",tagType:"daterange"},n.attributes=st(t[1]),["ID","CLASS"].forEach(function(a){n.attributes.hasOwnProperty(a)&&(n.attributes[a]=String(n.attributes[a]))}),["START-DATE","END-DATE"].forEach(function(a){n.attributes.hasOwnProperty(a)&&(n.attributes[a]=new Date(n.attributes[a]))}),["DURATION","PLANNED-DURATION"].forEach(function(a){n.attributes.hasOwnProperty(a)&&(n.attributes[a]=parseFloat(n.attributes[a]))}),["END-ON-NEXT"].forEach(function(a){n.attributes.hasOwnProperty(a)&&(n.attributes[a]=/YES/i.test(n.attributes[a]))}),["SCTE35-CMD"," SCTE35-OUT","SCTE35-IN"].forEach(function(a){n.attributes.hasOwnProperty(a)&&(n.attributes[a]=n.attributes[a].toString(16))});const r=/^X-([A-Z]+-)+[A-Z]+$/;for(const a in n.attributes){if(!r.test(a))continue;const l=/[0-9A-Fa-f]{6}/g.test(n.attributes[a]),c=/^\d+(\.\d+)?$/.test(n.attributes[a]);n.attributes[a]=l?n.attributes[a].toString(16):c?parseFloat(n.attributes[a]):String(n.attributes[a])}this.trigger("data",n);return}if(t=/^#EXT-X-INDEPENDENT-SEGMENTS/.exec(s),t){this.trigger("data",{type:"tag",tagType:"independent-segments"});return}if(t=/^#EXT-X-I-FRAMES-ONLY/.exec(s),t){this.trigger("data",{type:"tag",tagType:"i-frames-only"});return}if(t=/^#EXT-X-CONTENT-STEERING:(.*)$/.exec(s),t){n={type:"tag",tagType:"content-steering"},n.attributes=st(t[1]),this.trigger("data",n);return}if(t=/^#EXT-X-I-FRAME-STREAM-INF:(.*)$/.exec(s),t){n={type:"tag",tagType:"i-frame-playlist"},n.attributes=st(t[1]),n.attributes.URI&&(n.uri=n.attributes.URI),n.attributes.BANDWIDTH&&(n.attributes.BANDWIDTH=parseInt(n.attributes.BANDWIDTH,10)),n.attributes.RESOLUTION&&(n.attributes.RESOLUTION=bu(n.attributes.RESOLUTION)),n.attributes["AVERAGE-BANDWIDTH"]&&(n.attributes["AVERAGE-BANDWIDTH"]=parseInt(n.attributes["AVERAGE-BANDWIDTH"],10)),n.attributes["FRAME-RATE"]&&(n.attributes["FRAME-RATE"]=parseFloat(n.attributes["FRAME-RATE"])),this.trigger("data",n);return}if(t=/^#EXT-X-DEFINE:(.*)$/.exec(s),t){n={type:"tag",tagType:"define"},n.attributes=st(t[1]),this.trigger("data",n);return}this.trigger("data",{type:"tag",data:s.slice(4)})})}}addParser({expression:e,customType:t,dataParser:n,segment:s}){typeof n!="function"&&(n=r=>r),this.customParsers.push(r=>{if(e.exec(r))return this.trigger("data",{type:"custom",data:n(r),customType:t,segment:s}),!0})}addTagMapper({expression:e,map:t}){const n=s=>e.test(s)?t(s):s;this.tagMappers.push(n)}}const G_=i=>i.toLowerCase().replace(/-(\w)/g,e=>e[1].toUpperCase()),gi=function(i){const e={};return Object.keys(i).forEach(function(t){e[G_(t)]=i[t]}),e},xa=function(i){const{serverControl:e,targetDuration:t,partTargetDuration:n}=i;if(!e)return;const s="#EXT-X-SERVER-CONTROL",r="holdBack",a="partHoldBack",l=t&&t*3,c=n&&n*2;t&&!e.hasOwnProperty(r)&&(e[r]=l,this.trigger("info",{message:`${s} defaulting HOLD-BACK to targetDuration * 3 (${l}).`})),l&&e[r]<l&&(this.trigger("warn",{message:`${s} clamping HOLD-BACK (${e[r]}) to targetDuration * 3 (${l})`}),e[r]=l),n&&!e.hasOwnProperty(a)&&(e[a]=n*3,this.trigger("info",{message:`${s} defaulting PART-HOLD-BACK to partTargetDuration * 3 (${e[a]}).`})),n&&e[a]<c&&(this.trigger("warn",{message:`${s} clamping PART-HOLD-BACK (${e[a]}) to partTargetDuration * 2 (${c}).`}),e[a]=c)};class X_ extends Co{constructor(e={}){super(),this.lineStream=new V_,this.parseStream=new W_,this.lineStream.pipe(this.parseStream),this.mainDefinitions=e.mainDefinitions||{},this.params=new URL(e.uri,"https://a.com").searchParams,this.lastProgramDateTime=null;const t=this,n=[];let s={},r,a,l=!1;const c=function(){},f={AUDIO:{},VIDEO:{},"CLOSED-CAPTIONS":{},SUBTITLES:{}},m="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";let b=0;this.manifest={allowCache:!0,discontinuityStarts:[],dateRanges:[],iFramePlaylists:[],segments:[]};let C=0,w=0;const A={};this.on("end",()=>{s.uri||!s.parts&&!s.preloadHints||(!s.map&&r&&(s.map=r),!s.key&&a&&(s.key=a),!s.timeline&&typeof b=="number"&&(s.timeline=b),this.manifest.preloadSegment=s)}),this.parseStream.on("data",function(v){let M,D;if(t.manifest.definitions){for(const R in t.manifest.definitions)if(v.uri&&(v.uri=v.uri.replace(`{$${R}}`,t.manifest.definitions[R])),v.attributes)for(const N in v.attributes)typeof v.attributes[N]=="string"&&(v.attributes[N]=v.attributes[N].replace(`{$${R}}`,t.manifest.definitions[R]))}({tag(){({version(){v.version&&(this.manifest.version=v.version)},"allow-cache"(){this.manifest.allowCache=v.allowed,"allowed"in v||(this.trigger("info",{message:"defaulting allowCache to YES"}),this.manifest.allowCache=!0)},byterange(){const R={};"length"in v&&(s.byterange=R,R.length=v.length,"offset"in v||(v.offset=C)),"offset"in v&&(s.byterange=R,R.offset=v.offset),C=R.offset+R.length},endlist(){this.manifest.endList=!0},inf(){"mediaSequence"in this.manifest||(this.manifest.mediaSequence=0,this.trigger("info",{message:"defaulting media sequence to zero"})),"discontinuitySequence"in this.manifest||(this.manifest.discontinuitySequence=0,this.trigger("info",{message:"defaulting discontinuity sequence to zero"})),v.title&&(s.title=v.title),v.duration>0&&(s.duration=v.duration),v.duration===0&&(s.duration=.01,this.trigger("info",{message:"updating zero segment duration to a small value"})),this.manifest.segments=n},key(){if(!v.attributes){this.trigger("warn",{message:"ignoring key declaration without attribute list"});return}if(v.attributes.METHOD==="NONE"){a=null;return}if(!v.attributes.URI){this.trigger("warn",{message:"ignoring key declaration without URI"});return}if(v.attributes.KEYFORMAT==="com.apple.streamingkeydelivery"){this.manifest.contentProtection=this.manifest.contentProtection||{},this.manifest.contentProtection["com.apple.fps.1_0"]={attributes:v.attributes};return}if(v.attributes.KEYFORMAT==="com.microsoft.playready"){this.manifest.contentProtection=this.manifest.contentProtection||{},this.manifest.contentProtection["com.microsoft.playready"]={uri:v.attributes.URI};return}if(v.attributes.KEYFORMAT===m){if(["SAMPLE-AES","SAMPLE-AES-CTR","SAMPLE-AES-CENC"].indexOf(v.attributes.METHOD)===-1){this.trigger("warn",{message:"invalid key method provided for Widevine"});return}if(v.attributes.METHOD==="SAMPLE-AES-CENC"&&this.trigger("warn",{message:"SAMPLE-AES-CENC is deprecated, please use SAMPLE-AES-CTR instead"}),v.attributes.URI.substring(0,23)!=="data:text/plain;base64,"){this.trigger("warn",{message:"invalid key URI provided for Widevine"});return}if(!(v.attributes.KEYID&&v.attributes.KEYID.substring(0,2)==="0x")){this.trigger("warn",{message:"invalid key ID provided for Widevine"});return}this.manifest.contentProtection=this.manifest.contentProtection||{},this.manifest.contentProtection["com.widevine.alpha"]={attributes:{schemeIdUri:v.attributes.KEYFORMAT,keyId:v.attributes.KEYID.substring(2)},pssh:rh(v.attributes.URI.split(",")[1])};return}v.attributes.METHOD||this.trigger("warn",{message:"defaulting key method to AES-128"}),a={method:v.attributes.METHOD||"AES-128",uri:v.attributes.URI},typeof v.attributes.IV<"u"&&(a.iv=v.attributes.IV)},"media-sequence"(){if(!isFinite(v.number)){this.trigger("warn",{message:"ignoring invalid media sequence: "+v.number});return}this.manifest.mediaSequence=v.number},"discontinuity-sequence"(){if(!isFinite(v.number)){this.trigger("warn",{message:"ignoring invalid discontinuity sequence: "+v.number});return}this.manifest.discontinuitySequence=v.number,b=v.number},"playlist-type"(){if(!/VOD|EVENT/.test(v.playlistType)){this.trigger("warn",{message:"ignoring unknown playlist type: "+v.playlist});return}this.manifest.playlistType=v.playlistType},map(){r={},v.uri&&(r.uri=v.uri),v.byterange&&(r.byterange=v.byterange),a&&(r.key=a)},"stream-inf"(){if(this.manifest.playlists=n,this.manifest.mediaGroups=this.manifest.mediaGroups||f,!v.attributes){this.trigger("warn",{message:"ignoring empty stream-inf attributes"});return}s.attributes||(s.attributes={}),je(s.attributes,v.attributes)},media(){if(this.manifest.mediaGroups=this.manifest.mediaGroups||f,!(v.attributes&&v.attributes.TYPE&&v.attributes["GROUP-ID"]&&v.attributes.NAME)){this.trigger("warn",{message:"ignoring incomplete or missing media group"});return}const R=this.manifest.mediaGroups[v.attributes.TYPE];R[v.attributes["GROUP-ID"]]=R[v.attributes["GROUP-ID"]]||{},M=R[v.attributes["GROUP-ID"]],D={default:/yes/i.test(v.attributes.DEFAULT)},D.default?D.autoselect=!0:D.autoselect=/yes/i.test(v.attributes.AUTOSELECT),v.attributes.LANGUAGE&&(D.language=v.attributes.LANGUAGE),v.attributes.URI&&(D.uri=v.attributes.URI),v.attributes["INSTREAM-ID"]&&(D.instreamId=v.attributes["INSTREAM-ID"]),v.attributes.CHARACTERISTICS&&(D.characteristics=v.attributes.CHARACTERISTICS),v.attributes.FORCED&&(D.forced=/yes/i.test(v.attributes.FORCED)),M[v.attributes.NAME]=D},discontinuity(){b+=1,s.discontinuity=!0,this.manifest.discontinuityStarts.push(n.length)},"program-date-time"(){typeof this.manifest.dateTimeString>"u"&&(this.manifest.dateTimeString=v.dateTimeString,this.manifest.dateTimeObject=v.dateTimeObject),s.dateTimeString=v.dateTimeString,s.dateTimeObject=v.dateTimeObject;const{lastProgramDateTime:R}=this;this.lastProgramDateTime=new Date(v.dateTimeString).getTime(),R===null&&this.manifest.segments.reduceRight((N,F)=>(F.programDateTime=N-F.duration*1e3,F.programDateTime),this.lastProgramDateTime)},targetduration(){if(!isFinite(v.duration)||v.duration<0){this.trigger("warn",{message:"ignoring invalid target duration: "+v.duration});return}this.manifest.targetDuration=v.duration,xa.call(this,this.manifest)},start(){if(!v.attributes||isNaN(v.attributes["TIME-OFFSET"])){this.trigger("warn",{message:"ignoring start declaration without appropriate attribute list"});return}this.manifest.start={timeOffset:v.attributes["TIME-OFFSET"],precise:v.attributes.PRECISE}},"cue-out"(){s.cueOut=v.data},"cue-out-cont"(){s.cueOutCont=v.data},"cue-in"(){s.cueIn=v.data},skip(){this.manifest.skip=gi(v.attributes),this.warnOnMissingAttributes_("#EXT-X-SKIP",v.attributes,["SKIPPED-SEGMENTS"])},part(){l=!0;const R=this.manifest.segments.length,N=gi(v.attributes);s.parts=s.parts||[],s.parts.push(N),N.byterange&&(N.byterange.hasOwnProperty("offset")||(N.byterange.offset=w),w=N.byterange.offset+N.byterange.length);const F=s.parts.length-1;this.warnOnMissingAttributes_(`#EXT-X-PART #${F} for segment #${R}`,v.attributes,["URI","DURATION"]),this.manifest.renditionReports&&this.manifest.renditionReports.forEach((P,$)=>{P.hasOwnProperty("lastPart")||this.trigger("warn",{message:`#EXT-X-RENDITION-REPORT #${$} lacks required attribute(s): LAST-PART`})})},"server-control"(){const R=this.manifest.serverControl=gi(v.attributes);R.hasOwnProperty("canBlockReload")||(R.canBlockReload=!1,this.trigger("info",{message:"#EXT-X-SERVER-CONTROL defaulting CAN-BLOCK-RELOAD to false"})),xa.call(this,this.manifest),R.canSkipDateranges&&!R.hasOwnProperty("canSkipUntil")&&this.trigger("warn",{message:"#EXT-X-SERVER-CONTROL lacks required attribute CAN-SKIP-UNTIL which is required when CAN-SKIP-DATERANGES is set"})},"preload-hint"(){const R=this.manifest.segments.length,N=gi(v.attributes),F=N.type&&N.type==="PART";s.preloadHints=s.preloadHints||[],s.preloadHints.push(N),N.byterange&&(N.byterange.hasOwnProperty("offset")||(N.byterange.offset=F?w:0,F&&(w=N.byterange.offset+N.byterange.length)));const P=s.preloadHints.length-1;if(this.warnOnMissingAttributes_(`#EXT-X-PRELOAD-HINT #${P} for segment #${R}`,v.attributes,["TYPE","URI"]),!!N.type)for(let $=0;$<s.preloadHints.length-1;$++){const Y=s.preloadHints[$];Y.type&&Y.type===N.type&&this.trigger("warn",{message:`#EXT-X-PRELOAD-HINT #${P} for segment #${R} has the same TYPE ${N.type} as preload hint #${$}`})}},"rendition-report"(){const R=gi(v.attributes);this.manifest.renditionReports=this.manifest.renditionReports||[],this.manifest.renditionReports.push(R);const N=this.manifest.renditionReports.length-1,F=["LAST-MSN","URI"];l&&F.push("LAST-PART"),this.warnOnMissingAttributes_(`#EXT-X-RENDITION-REPORT #${N}`,v.attributes,F)},"part-inf"(){this.manifest.partInf=gi(v.attributes),this.warnOnMissingAttributes_("#EXT-X-PART-INF",v.attributes,["PART-TARGET"]),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),xa.call(this,this.manifest)},daterange(){this.manifest.dateRanges.push(gi(v.attributes));const R=this.manifest.dateRanges.length-1;this.warnOnMissingAttributes_(`#EXT-X-DATERANGE #${R}`,v.attributes,["ID","START-DATE"]);const N=this.manifest.dateRanges[R];N.endDate&&N.startDate&&new Date(N.endDate)<new Date(N.startDate)&&this.trigger("warn",{message:"EXT-X-DATERANGE END-DATE must be equal to or later than the value of the START-DATE"}),N.duration&&N.duration<0&&this.trigger("warn",{message:"EXT-X-DATERANGE DURATION must not be negative"}),N.plannedDuration&&N.plannedDuration<0&&this.trigger("warn",{message:"EXT-X-DATERANGE PLANNED-DURATION must not be negative"});const F=!!N.endOnNext;if(F&&!N.class&&this.trigger("warn",{message:"EXT-X-DATERANGE with an END-ON-NEXT=YES attribute must have a CLASS attribute"}),F&&(N.duration||N.endDate)&&this.trigger("warn",{message:"EXT-X-DATERANGE with an END-ON-NEXT=YES attribute must not contain DURATION or END-DATE attributes"}),N.duration&&N.endDate){const P=N.startDate.getTime()+N.duration*1e3;this.manifest.dateRanges[R].endDate=new Date(P)}if(!A[N.id])A[N.id]=N;else{for(const $ in A[N.id])if(N[$]&&JSON.stringify(A[N.id][$])!==JSON.stringify(N[$])){this.trigger("warn",{message:"EXT-X-DATERANGE tags with the same ID in a playlist must have the same attributes values"});break}const P=this.manifest.dateRanges.findIndex($=>$.id===N.id);this.manifest.dateRanges[P]=je(this.manifest.dateRanges[P],N),A[N.id]=je(A[N.id],N),this.manifest.dateRanges.pop()}},"independent-segments"(){this.manifest.independentSegments=!0},"i-frames-only"(){this.manifest.iFramesOnly=!0,this.requiredCompatibilityversion(this.manifest.version,4)},"content-steering"(){this.manifest.contentSteering=gi(v.attributes),this.warnOnMissingAttributes_("#EXT-X-CONTENT-STEERING",v.attributes,["SERVER-URI"])},define(){this.manifest.definitions=this.manifest.definitions||{};const R=(N,F)=>{if(N in this.manifest.definitions){this.trigger("error",{message:`EXT-X-DEFINE: Duplicate name ${N}`});return}this.manifest.definitions[N]=F};if("QUERYPARAM"in v.attributes){if("NAME"in v.attributes||"IMPORT"in v.attributes){this.trigger("error",{message:"EXT-X-DEFINE: Invalid attributes"});return}const N=this.params.get(v.attributes.QUERYPARAM);if(!N){this.trigger("error",{message:`EXT-X-DEFINE: No query param ${v.attributes.QUERYPARAM}`});return}R(v.attributes.QUERYPARAM,decodeURIComponent(N));return}if("NAME"in v.attributes){if("IMPORT"in v.attributes){this.trigger("error",{message:"EXT-X-DEFINE: Invalid attributes"});return}if(!("VALUE"in v.attributes)||typeof v.attributes.VALUE!="string"){this.trigger("error",{message:`EXT-X-DEFINE: No value for ${v.attributes.NAME}`});return}R(v.attributes.NAME,v.attributes.VALUE);return}if("IMPORT"in v.attributes){if(!this.mainDefinitions[v.attributes.IMPORT]){this.trigger("error",{message:`EXT-X-DEFINE: No value ${v.attributes.IMPORT} to import, or IMPORT used on main playlist`});return}R(v.attributes.IMPORT,this.mainDefinitions[v.attributes.IMPORT]);return}this.trigger("error",{message:"EXT-X-DEFINE: No attribute"})},"i-frame-playlist"(){this.manifest.iFramePlaylists.push({attributes:v.attributes,uri:v.uri,timeline:b}),this.warnOnMissingAttributes_("#EXT-X-I-FRAME-STREAM-INF",v.attributes,["BANDWIDTH","URI"])}}[v.tagType]||c).call(t)},uri(){s.uri=v.uri,n.push(s),this.manifest.targetDuration&&!("duration"in s)&&(this.trigger("warn",{message:"defaulting segment duration to the target duration"}),s.duration=this.manifest.targetDuration),a&&(s.key=a),s.timeline=b,r&&(s.map=r),w=0,this.lastProgramDateTime!==null&&(s.programDateTime=this.lastProgramDateTime,this.lastProgramDateTime+=s.duration*1e3),s={}},comment(){},custom(){v.segment?(s.custom=s.custom||{},s.custom[v.customType]=v.data):(this.manifest.custom=this.manifest.custom||{},this.manifest.custom[v.customType]=v.data)}})[v.type].call(t)})}requiredCompatibilityversion(e,t){(e<t||!e)&&this.trigger("warn",{message:`manifest must be at least version ${t}`})}warnOnMissingAttributes_(e,t,n){const s=[];n.forEach(function(r){t.hasOwnProperty(r)||s.push(r)}),s.length&&this.trigger("warn",{message:`${e} lacks required attribute(s): ${s.join(", ")}`})}push(e){this.lineStream.push(e)}end(){this.lineStream.push(`
|
|
24
|
-
`),this.manifest.dateRanges.length&&this.lastProgramDateTime===null&&this.trigger("warn",{message:"A playlist with EXT-X-DATERANGE tag must contain atleast one EXT-X-PROGRAM-DATE-TIME tag"}),this.lastProgramDateTime=null,this.trigger("end")}addParser(e){this.parseStream.addParser(e)}addTagMapper(e){this.parseStream.addTagMapper(e)}}var Ni={mp4:/^(av0?1|avc0?[1234]|vp0?9|flac|opus|mp3|mp4a|mp4v|stpp.ttml.im1t)/,webm:/^(vp0?[89]|av0?1|opus|vorbis)/,ogg:/^(vp0?[89]|theora|flac|opus|vorbis)/,video:/^(av0?1|avc0?[1234]|vp0?[89]|hvc1|hev1|theora|mp4v)/,audio:/^(mp4a|flac|vorbis|opus|ac-[34]|ec-3|alac|mp3|speex|aac)/,text:/^(stpp.ttml.im1t)/,muxerVideo:/^(avc0?1)/,muxerAudio:/^(mp4a)/,muxerText:/a^/},K_=["video","audio","text"],Tu=["Video","Audio","Text"],ah=function(i){return i&&i.replace(/avc1\.(\d+)\.(\d+)/i,function(e,t,n){var s=("00"+Number(t).toString(16)).slice(-2),r=("00"+Number(n).toString(16)).slice(-2);return"avc1."+s+"00"+r})},Ht=function(i){i===void 0&&(i="");var e=i.split(","),t=[];return e.forEach(function(n){n=n.trim();var s;K_.forEach(function(r){var a=Ni[r].exec(n.toLowerCase());if(!(!a||a.length<=1)){s=r;var l=n.substring(0,a[1].length),c=n.replace(l,"");t.push({type:l,details:c,mediaType:r})}}),s||t.push({type:n,details:"",mediaType:"unknown"})}),t},Y_=function(i,e){if(!i.mediaGroups.AUDIO||!e)return null;var t=i.mediaGroups.AUDIO[e];if(!t)return null;for(var n in t){var s=t[n];if(s.default&&s.playlists)return Ht(s.playlists[0].attributes.CODECS)}return null},oh=function(i){return i===void 0&&(i=""),Ni.audio.test(i.trim().toLowerCase())},Q_=function(i){return i===void 0&&(i=""),Ni.text.test(i.trim().toLowerCase())},cn=function(i){if(!(!i||typeof i!="string")){var e=i.toLowerCase().split(",").map(function(s){return ah(s.trim())}),t="video";e.length===1&&oh(e[0])?t="audio":e.length===1&&Q_(e[0])&&(t="application");var n="mp4";return e.every(function(s){return Ni.mp4.test(s)})?n="mp4":e.every(function(s){return Ni.webm.test(s)})?n="webm":e.every(function(s){return Ni.ogg.test(s)})&&(n="ogg"),t+"/"+n+';codecs="'+i+'"'}},as=function(i,e){return i===void 0&&(i=""),e===void 0&&(e=!1),x.MediaSource&&x.MediaSource.isTypeSupported&&x.MediaSource.isTypeSupported(cn(i))||e&&x.ManagedMediaSource&&x.ManagedMediaSource.isTypeSupported&&x.ManagedMediaSource.isTypeSupported(cn(i))||!1},Aa=function(i){return i===void 0&&(i=""),i.toLowerCase().split(",").every(function(e){e=e.trim();for(var t=0;t<Tu.length;t++){var n=Tu[t];if(Ni["muxer"+n].test(e))return!0}return!1})},vu="mp4a.40.2",J_="avc1.4d400d",Z_=/^(audio|video|application)\/(x-|vnd\.apple\.)?mpegurl/i,e0=/^application\/dash\+xml/i,lh=function(i){return Z_.test(i)?"hls":e0.test(i)?"dash":i==="application/vnd.videojs.vhs+json"?"vhs-json":null},t0=function(i){return i.toString(2).length},i0=function(i){return Math.ceil(t0(i)/8)},uh=function(i){return ArrayBuffer.isView==="function"?ArrayBuffer.isView(i):i&&i.buffer instanceof ArrayBuffer},n0=function(i){return uh(i)},ie=function(i){return i instanceof Uint8Array?i:(!Array.isArray(i)&&!n0(i)&&!(i instanceof ArrayBuffer)&&(typeof i!="number"||typeof i=="number"&&i!==i?i=0:i=[i]),new Uint8Array(i&&i.buffer||i,i&&i.byteOffset||0,i&&i.byteLength||0))},Ke=x.BigInt||Number,Wa=[Ke("0x1"),Ke("0x100"),Ke("0x10000"),Ke("0x1000000"),Ke("0x100000000"),Ke("0x10000000000"),Ke("0x1000000000000"),Ke("0x100000000000000"),Ke("0x10000000000000000")];(function(){var i=new Uint16Array([65484]),e=new Uint8Array(i.buffer,i.byteOffset,i.byteLength);return e[0]===255?"big":e[0]===204?"little":"unknown"})();var s0=function(i,e){var t=e===void 0?{}:e,n=t.signed,s=n===void 0?!1:n,r=t.le,a=r===void 0?!1:r;i=ie(i);var l=a?"reduce":"reduceRight",c=i[l]?i[l]:Array.prototype[l],f=c.call(i,function(b,C,w){var A=a?w:Math.abs(w+1-i.length);return b+Ke(C)*Wa[A]},Ke(0));if(s){var m=Wa[i.length]/Ke(2)-Ke(1);f=Ke(f),f>m&&(f-=m,f-=m,f-=Ke(2))}return Number(f)},r0=function(i,e){var t={},n=t.le,s=n===void 0?!1:n;(typeof i!="bigint"&&typeof i!="number"||typeof i=="number"&&i!==i)&&(i=0),i=Ke(i);for(var r=i0(i),a=new Uint8Array(new ArrayBuffer(r)),l=0;l<r;l++){var c=s?l:Math.abs(l+1-a.length);a[c]=Number(i/Wa[l]&Ke(255)),i<0&&(a[c]=Math.abs(~a[c]),a[c]-=l===0?1:2)}return a},dh=function(i,e){if(typeof i!="string"&&i&&typeof i.toString=="function"&&(i=i.toString()),typeof i!="string")return new Uint8Array;e||(i=unescape(encodeURIComponent(i)));for(var t=new Uint8Array(i.length),n=0;n<i.length;n++)t[n]=i.charCodeAt(n);return t},a0=function(){for(var i=arguments.length,e=new Array(i),t=0;t<i;t++)e[t]=arguments[t];if(e=e.filter(function(a){return a&&(a.byteLength||a.length)&&typeof a!="string"}),e.length<=1)return ie(e[0]);var n=e.reduce(function(a,l,c){return a+(l.byteLength||l.length)},0),s=new Uint8Array(n),r=0;return e.forEach(function(a){a=ie(a),s.set(a,r),r+=a.byteLength}),s},Le=function(i,e,t){var n=t===void 0?{}:t,s=n.offset,r=s===void 0?0:s,a=n.mask,l=a===void 0?[]:a;i=ie(i),e=ie(e);var c=e.every?e.every:Array.prototype.every;return e.length&&i.length-r>=e.length&&c.call(e,function(f,m){var b=l[m]?l[m]&i[r+m]:i[r+m];return f===b})},o0=function(i,e,t){e.forEach(function(n){for(var s in i.mediaGroups[n])for(var r in i.mediaGroups[n][s]){var a=i.mediaGroups[n][s][r];t(a,n,s,r)}})};/*! @name mpd-parser @version 1.3.1 @license Apache-2.0 */const Su=i=>!!i&&typeof i=="object",Ge=(...i)=>i.reduce((e,t)=>(typeof t!="object"||Object.keys(t).forEach(n=>{Array.isArray(e[n])&&Array.isArray(t[n])?e[n]=e[n].concat(t[n]):Su(e[n])&&Su(t[n])?e[n]=Ge(e[n],t[n]):e[n]=t[n]}),e),{}),hh=i=>Object.keys(i).map(e=>i[e]),l0=(i,e)=>{const t=[];for(let n=i;n<e;n++)t.push(n);return t},pn=i=>i.reduce((e,t)=>e.concat(t),[]),ch=i=>{if(!i.length)return[];const e=[];for(let t=0;t<i.length;t++)e.push(i[t]);return e},u0=(i,e)=>i.reduce((t,n,s)=>(n[e]&&t.push(s),t),[]),d0=(i,e)=>hh(i.reduce((t,n)=>(n.forEach(s=>{t[e(s)]=s}),t),{}));var gn={INVALID_NUMBER_OF_PERIOD:"INVALID_NUMBER_OF_PERIOD",INVALID_NUMBER_OF_CONTENT_STEERING:"INVALID_NUMBER_OF_CONTENT_STEERING",DASH_EMPTY_MANIFEST:"DASH_EMPTY_MANIFEST",DASH_INVALID_XML:"DASH_INVALID_XML",NO_BASE_URL:"NO_BASE_URL",MISSING_SEGMENT_INFORMATION:"MISSING_SEGMENT_INFORMATION",SEGMENT_TIME_UNSPECIFIED:"SEGMENT_TIME_UNSPECIFIED",UNSUPPORTED_UTC_TIMING_SCHEME:"UNSUPPORTED_UTC_TIMING_SCHEME"};const cs=({baseUrl:i="",source:e="",range:t="",indexRange:n=""})=>{const s={uri:e,resolvedUri:Mr(i||"",e)};if(t||n){const r=(t||n).split("-");let a=x.BigInt?x.BigInt(r[0]):parseInt(r[0],10),l=x.BigInt?x.BigInt(r[1]):parseInt(r[1],10);a<Number.MAX_SAFE_INTEGER&&typeof a=="bigint"&&(a=Number(a)),l<Number.MAX_SAFE_INTEGER&&typeof l=="bigint"&&(l=Number(l));let c;typeof l=="bigint"||typeof a=="bigint"?c=x.BigInt(l)-x.BigInt(a)+x.BigInt(1):c=l-a+1,typeof c=="bigint"&&c<Number.MAX_SAFE_INTEGER&&(c=Number(c)),s.byterange={length:c,offset:a}}return s},h0=i=>{let e;return typeof i.offset=="bigint"||typeof i.length=="bigint"?e=x.BigInt(i.offset)+x.BigInt(i.length)-x.BigInt(1):e=i.offset+i.length-1,`${i.offset}-${e}`},Eu=i=>(i&&typeof i!="number"&&(i=parseInt(i,10)),isNaN(i)?null:i),c0={static(i){const{duration:e,timescale:t=1,sourceDuration:n,periodDuration:s}=i,r=Eu(i.endNumber),a=e/t;return typeof r=="number"?{start:0,end:r}:typeof s=="number"?{start:0,end:s/a}:{start:0,end:n/a}},dynamic(i){const{NOW:e,clientOffset:t,availabilityStartTime:n,timescale:s=1,duration:r,periodStart:a=0,minimumUpdatePeriod:l=0,timeShiftBufferDepth:c=1/0}=i,f=Eu(i.endNumber),m=(e+t)/1e3,b=n+a,C=m+l-b,w=Math.ceil(C*s/r),A=Math.floor((m-b-c)*s/r),v=Math.floor((m-b)*s/r);return{start:Math.max(0,A),end:typeof f=="number"?f:Math.min(w,v)}}},p0=i=>e=>{const{duration:t,timescale:n=1,periodStart:s,startNumber:r=1}=i;return{number:r+e,duration:t/n,timeline:s,time:e*t}},xo=i=>{const{type:e,duration:t,timescale:n=1,periodDuration:s,sourceDuration:r}=i,{start:a,end:l}=c0[e](i),c=l0(a,l).map(p0(i));if(e==="static"){const f=c.length-1,m=typeof s=="number"?s:r;c[f].duration=m-t/n*f}return c},ph=i=>{const{baseUrl:e,initialization:t={},sourceDuration:n,indexRange:s="",periodStart:r,presentationTime:a,number:l=0,duration:c}=i;if(!e)throw new Error(gn.NO_BASE_URL);const f=cs({baseUrl:e,source:t.sourceURL,range:t.range}),m=cs({baseUrl:e,source:e,indexRange:s});if(m.map=f,c){const b=xo(i);b.length&&(m.duration=b[0].duration,m.timeline=b[0].timeline)}else n&&(m.duration=n,m.timeline=r);return m.presentationTime=a||r,m.number=l,[m]},Ao=(i,e,t)=>{const n=i.sidx.map?i.sidx.map:null,s=i.sidx.duration,r=i.timeline||0,a=i.sidx.byterange,l=a.offset+a.length,c=e.timescale,f=e.references.filter(M=>M.referenceType!==1),m=[],b=i.endList?"static":"dynamic",C=i.sidx.timeline;let w=C,A=i.mediaSequence||0,v;typeof e.firstOffset=="bigint"?v=x.BigInt(l)+e.firstOffset:v=l+e.firstOffset;for(let M=0;M<f.length;M++){const D=e.references[M],R=D.referencedSize,N=D.subsegmentDuration;let F;typeof v=="bigint"?F=v+x.BigInt(R)-x.BigInt(1):F=v+R-1;const P=`${v}-${F}`,$=ph({baseUrl:t,timescale:c,timeline:r,periodStart:C,presentationTime:w,number:A,duration:N,sourceDuration:s,indexRange:P,type:b})[0];n&&($.map=n),m.push($),typeof v=="bigint"?v+=x.BigInt(R):v+=R,w+=N/c,A++}return i.segments=m,i},g0=["AUDIO","SUBTITLES"],f0=1/60,gh=i=>d0(i,({timeline:e})=>e).sort((e,t)=>e.timeline>t.timeline?1:-1),m0=(i,e)=>{for(let t=0;t<i.length;t++)if(i[t].attributes.NAME===e)return i[t];return null},wu=i=>{let e=[];return o0(i,g0,(t,n,s,r)=>{e=e.concat(t.playlists||[])}),e},ku=({playlist:i,mediaSequence:e})=>{i.mediaSequence=e,i.segments.forEach((t,n)=>{t.number=i.mediaSequence+n})},y0=({oldPlaylists:i,newPlaylists:e,timelineStarts:t})=>{e.forEach(n=>{n.discontinuitySequence=t.findIndex(function({timeline:l}){return l===n.timeline});const s=m0(i,n.attributes.NAME);if(!s||n.sidx)return;const r=n.segments[0],a=s.segments.findIndex(function(l){return Math.abs(l.presentationTime-r.presentationTime)<f0});if(a===-1){ku({playlist:n,mediaSequence:s.mediaSequence+s.segments.length}),n.segments[0].discontinuity=!0,n.discontinuityStarts.unshift(0),(!s.segments.length&&n.timeline>s.timeline||s.segments.length&&n.timeline>s.segments[s.segments.length-1].timeline)&&n.discontinuitySequence--;return}s.segments[a].discontinuity&&!r.discontinuity&&(r.discontinuity=!0,n.discontinuityStarts.unshift(0),n.discontinuitySequence--),ku({playlist:n,mediaSequence:s.segments[a].number})})},_0=({oldManifest:i,newManifest:e})=>{const t=i.playlists.concat(wu(i)),n=e.playlists.concat(wu(e));return e.timelineStarts=gh([i.timelineStarts,e.timelineStarts]),y0({oldPlaylists:t,newPlaylists:n,timelineStarts:e.timelineStarts}),e},Ur=i=>i&&i.uri+"-"+h0(i.byterange),Pa=i=>{const e=i.reduce(function(n,s){return n[s.attributes.baseUrl]||(n[s.attributes.baseUrl]=[]),n[s.attributes.baseUrl].push(s),n},{});let t=[];return Object.values(e).forEach(n=>{const s=hh(n.reduce((r,a)=>{const l=a.attributes.id+(a.attributes.lang||"");return r[l]?(a.segments&&(a.segments[0]&&(a.segments[0].discontinuity=!0),r[l].segments.push(...a.segments)),a.attributes.contentProtection&&(r[l].attributes.contentProtection=a.attributes.contentProtection)):(r[l]=a,r[l].attributes.timelineStarts=[]),r[l].attributes.timelineStarts.push({start:a.attributes.periodStart,timeline:a.attributes.periodStart}),r},{}));t=t.concat(s)}),t.map(n=>(n.discontinuityStarts=u0(n.segments||[],"discontinuity"),n))},Po=(i,e)=>{const t=Ur(i.sidx),n=t&&e[t]&&e[t].sidx;return n&&Ao(i,n,i.sidx.resolvedUri),i},b0=(i,e={})=>{if(!Object.keys(e).length)return i;for(const t in i)i[t]=Po(i[t],e);return i},T0=({attributes:i,segments:e,sidx:t,mediaSequence:n,discontinuitySequence:s,discontinuityStarts:r},a)=>{const l={attributes:{NAME:i.id,BANDWIDTH:i.bandwidth,CODECS:i.codecs,"PROGRAM-ID":1},uri:"",endList:i.type==="static",timeline:i.periodStart,resolvedUri:i.baseUrl||"",targetDuration:i.duration,discontinuitySequence:s,discontinuityStarts:r,timelineStarts:i.timelineStarts,mediaSequence:n,segments:e};return i.contentProtection&&(l.contentProtection=i.contentProtection),i.serviceLocation&&(l.attributes.serviceLocation=i.serviceLocation),t&&(l.sidx=t),a&&(l.attributes.AUDIO="audio",l.attributes.SUBTITLES="subs"),l},v0=({attributes:i,segments:e,mediaSequence:t,discontinuityStarts:n,discontinuitySequence:s})=>{typeof e>"u"&&(e=[{uri:i.baseUrl,timeline:i.periodStart,resolvedUri:i.baseUrl||"",duration:i.sourceDuration,number:0}],i.duration=i.sourceDuration);const r={NAME:i.id,BANDWIDTH:i.bandwidth,"PROGRAM-ID":1};i.codecs&&(r.CODECS=i.codecs);const a={attributes:r,uri:"",endList:i.type==="static",timeline:i.periodStart,resolvedUri:i.baseUrl||"",targetDuration:i.duration,timelineStarts:i.timelineStarts,discontinuityStarts:n,discontinuitySequence:s,mediaSequence:t,segments:e};return i.serviceLocation&&(a.attributes.serviceLocation=i.serviceLocation),a},S0=(i,e={},t=!1)=>{let n;const s=i.reduce((r,a)=>{const l=a.attributes.role&&a.attributes.role.value||"",c=a.attributes.lang||"";let f=a.attributes.label||"main";if(c&&!a.attributes.label){const b=l?` (${l})`:"";f=`${a.attributes.lang}${b}`}r[f]||(r[f]={language:c,autoselect:!0,default:l==="main",playlists:[],uri:""});const m=Po(T0(a,t),e);return r[f].playlists.push(m),typeof n>"u"&&l==="main"&&(n=a,n.default=!0),r},{});if(!n){const r=Object.keys(s)[0];s[r].default=!0}return s},E0=(i,e={})=>i.reduce((t,n)=>{const s=n.attributes.label||n.attributes.lang||"text",r=n.attributes.lang||"und";return t[s]||(t[s]={language:r,default:!1,autoselect:!1,playlists:[],uri:""}),t[s].playlists.push(Po(v0(n),e)),t},{}),w0=i=>i.reduce((e,t)=>(t&&t.forEach(n=>{const{channel:s,language:r}=n;e[r]={autoselect:!1,default:!1,instreamId:s,language:r},n.hasOwnProperty("aspectRatio")&&(e[r].aspectRatio=n.aspectRatio),n.hasOwnProperty("easyReader")&&(e[r].easyReader=n.easyReader),n.hasOwnProperty("3D")&&(e[r]["3D"]=n["3D"])}),e),{}),k0=({attributes:i,segments:e,sidx:t,discontinuityStarts:n})=>{const s={attributes:{NAME:i.id,AUDIO:"audio",SUBTITLES:"subs",RESOLUTION:{width:i.width,height:i.height},CODECS:i.codecs,BANDWIDTH:i.bandwidth,"PROGRAM-ID":1},uri:"",endList:i.type==="static",timeline:i.periodStart,resolvedUri:i.baseUrl||"",targetDuration:i.duration,discontinuityStarts:n,timelineStarts:i.timelineStarts,segments:e};return i.frameRate&&(s.attributes["FRAME-RATE"]=i.frameRate),i.contentProtection&&(s.contentProtection=i.contentProtection),i.serviceLocation&&(s.attributes.serviceLocation=i.serviceLocation),t&&(s.sidx=t),s},C0=({attributes:i})=>i.mimeType==="video/mp4"||i.mimeType==="video/webm"||i.contentType==="video",I0=({attributes:i})=>i.mimeType==="audio/mp4"||i.mimeType==="audio/webm"||i.contentType==="audio",x0=({attributes:i})=>i.mimeType==="text/vtt"||i.contentType==="text",A0=(i,e)=>{i.forEach(t=>{t.mediaSequence=0,t.discontinuitySequence=e.findIndex(function({timeline:n}){return n===t.timeline}),t.segments&&t.segments.forEach((n,s)=>{n.number=s})})},Cu=i=>i?Object.keys(i).reduce((e,t)=>{const n=i[t];return e.concat(n.playlists)},[]):[],P0=({dashPlaylists:i,locations:e,contentSteering:t,sidxMapping:n={},previousManifest:s,eventStream:r})=>{if(!i.length)return{};const{sourceDuration:a,type:l,suggestedPresentationDelay:c,minimumUpdatePeriod:f}=i[0].attributes,m=Pa(i.filter(C0)).map(k0),b=Pa(i.filter(I0)),C=Pa(i.filter(x0)),w=i.map(F=>F.attributes.captionServices).filter(Boolean),A={allowCache:!0,discontinuityStarts:[],segments:[],endList:!0,mediaGroups:{AUDIO:{},VIDEO:{},"CLOSED-CAPTIONS":{},SUBTITLES:{}},uri:"",duration:a,playlists:b0(m,n)};f>=0&&(A.minimumUpdatePeriod=f*1e3),e&&(A.locations=e),t&&(A.contentSteering=t),l==="dynamic"&&(A.suggestedPresentationDelay=c),r&&r.length>0&&(A.eventStream=r);const v=A.playlists.length===0,M=b.length?S0(b,n,v):null,D=C.length?E0(C,n):null,R=m.concat(Cu(M),Cu(D)),N=R.map(({timelineStarts:F})=>F);return A.timelineStarts=gh(N),A0(R,A.timelineStarts),M&&(A.mediaGroups.AUDIO.audio=M),D&&(A.mediaGroups.SUBTITLES.subs=D),w.length&&(A.mediaGroups["CLOSED-CAPTIONS"].cc=w0(w)),s?_0({oldManifest:s,newManifest:A}):A},L0=(i,e,t)=>{const{NOW:n,clientOffset:s,availabilityStartTime:r,timescale:a=1,periodStart:l=0,minimumUpdatePeriod:c=0}=i,f=(n+s)/1e3,m=r+l,b=f+c-m;return Math.ceil((b*a-e)/t)},fh=(i,e)=>{const{type:t,minimumUpdatePeriod:n=0,media:s="",sourceDuration:r,timescale:a=1,startNumber:l=1,periodStart:c}=i,f=[];let m=-1;for(let b=0;b<e.length;b++){const C=e[b],w=C.d,A=C.r||0,v=C.t||0;m<0&&(m=v),v&&v>m&&(m=v);let M;if(A<0){const N=b+1;N===e.length?t==="dynamic"&&n>0&&s.indexOf("$Number$")>0?M=L0(i,m,w):M=(r*a-m)/w:M=(e[N].t-m)/w}else M=A+1;const D=l+f.length+M;let R=l+f.length;for(;R<D;)f.push({number:R,duration:w/a,time:m,timeline:c}),m+=w,R++}return f},D0=/\$([A-z]*)(?:(%0)([0-9]+)d)?\$/g,O0=i=>(e,t,n,s)=>{if(e==="$$")return"$";if(typeof i[t]>"u")return e;const r=""+i[t];return t==="RepresentationID"||(n?s=parseInt(s,10):s=1,r.length>=s)?r:`${new Array(s-r.length+1).join("0")}${r}`},Iu=(i,e)=>i.replace(D0,O0(e)),M0=(i,e)=>!i.duration&&!e?[{number:i.startNumber||1,duration:i.sourceDuration,time:0,timeline:i.periodStart}]:i.duration?xo(i):fh(i,e),R0=(i,e)=>{const t={RepresentationID:i.id,Bandwidth:i.bandwidth||0},{initialization:n={sourceURL:"",range:""}}=i,s=cs({baseUrl:i.baseUrl,source:Iu(n.sourceURL,t),range:n.range});return M0(i,e).map(r=>{t.Number=r.number,t.Time=r.time;const a=Iu(i.media||"",t),l=i.timescale||1,c=i.presentationTimeOffset||0,f=i.periodStart+(r.time-c)/l;return{uri:a,timeline:r.timeline,duration:r.duration,resolvedUri:Mr(i.baseUrl||"",a),map:s,number:r.number,presentationTime:f}})},U0=(i,e)=>{const{baseUrl:t,initialization:n={}}=i,s=cs({baseUrl:t,source:n.sourceURL,range:n.range}),r=cs({baseUrl:t,source:e.media,range:e.mediaRange});return r.map=s,r},N0=(i,e)=>{const{duration:t,segmentUrls:n=[],periodStart:s}=i;if(!t&&!e||t&&e)throw new Error(gn.SEGMENT_TIME_UNSPECIFIED);const r=n.map(l=>U0(i,l));let a;return t&&(a=xo(i)),e&&(a=fh(i,e)),a.map((l,c)=>{if(r[c]){const f=r[c],m=i.timescale||1,b=i.presentationTimeOffset||0;return f.timeline=l.timeline,f.duration=l.duration,f.number=l.number,f.presentationTime=s+(l.time-b)/m,f}}).filter(l=>l)},B0=({attributes:i,segmentInfo:e})=>{let t,n;e.template?(n=R0,t=Ge(i,e.template)):e.base?(n=ph,t=Ge(i,e.base)):e.list&&(n=N0,t=Ge(i,e.list));const s={attributes:i};if(!n)return s;const r=n(t,e.segmentTimeline);if(t.duration){const{duration:a,timescale:l=1}=t;t.duration=a/l}else r.length?t.duration=r.reduce((a,l)=>Math.max(a,Math.ceil(l.duration)),0):t.duration=0;return s.attributes=t,s.segments=r,e.base&&t.indexRange&&(s.sidx=r[0],s.segments=[]),s},F0=i=>i.map(B0),De=(i,e)=>ch(i.childNodes).filter(({tagName:t})=>t===e),ys=i=>i.textContent.trim(),j0=i=>parseFloat(i.split("/").reduce((e,t)=>e/t)),Qi=i=>{const e=/P(?:(\d*)Y)?(?:(\d*)M)?(?:(\d*)D)?(?:T(?:(\d*)H)?(?:(\d*)M)?(?:([\d.]*)S)?)?/.exec(i);if(!e)return 0;const[t,n,s,r,a,l]=e.slice(1);return parseFloat(t||0)*31536e3+parseFloat(n||0)*2592e3+parseFloat(s||0)*86400+parseFloat(r||0)*3600+parseFloat(a||0)*60+parseFloat(l||0)},$0=i=>(/^\d+-\d+-\d+T\d+:\d+:\d+(\.\d+)?$/.test(i)&&(i+="Z"),Date.parse(i)),xu={mediaPresentationDuration(i){return Qi(i)},availabilityStartTime(i){return $0(i)/1e3},minimumUpdatePeriod(i){return Qi(i)},suggestedPresentationDelay(i){return Qi(i)},type(i){return i},timeShiftBufferDepth(i){return Qi(i)},start(i){return Qi(i)},width(i){return parseInt(i,10)},height(i){return parseInt(i,10)},bandwidth(i){return parseInt(i,10)},frameRate(i){return j0(i)},startNumber(i){return parseInt(i,10)},timescale(i){return parseInt(i,10)},presentationTimeOffset(i){return parseInt(i,10)},duration(i){const e=parseInt(i,10);return isNaN(e)?Qi(i):e},d(i){return parseInt(i,10)},t(i){return parseInt(i,10)},r(i){return parseInt(i,10)},presentationTime(i){return parseInt(i,10)},DEFAULT(i){return i}},qe=i=>i&&i.attributes?ch(i.attributes).reduce((e,t)=>{const n=xu[t.name]||xu.DEFAULT;return e[t.name]=n(t.value),e},{}):{},q0={"urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b":"org.w3.clearkey","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":"com.widevine.alpha","urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":"com.microsoft.playready","urn:uuid:f239e769-efa3-4850-9c16-a903c6932efb":"com.adobe.primetime","urn:mpeg:dash:mp4protection:2011":"mp4protection"},Nr=(i,e)=>e.length?pn(i.map(function(t){return e.map(function(n){const s=ys(n),r=Mr(t.baseUrl,s),a=Ge(qe(n),{baseUrl:r});return r!==s&&!a.serviceLocation&&t.serviceLocation&&(a.serviceLocation=t.serviceLocation),a})})):i,Lo=i=>{const e=De(i,"SegmentTemplate")[0],t=De(i,"SegmentList")[0],n=t&&De(t,"SegmentURL").map(b=>Ge({tag:"SegmentURL"},qe(b))),s=De(i,"SegmentBase")[0],r=t||e,a=r&&De(r,"SegmentTimeline")[0],l=t||s||e,c=l&&De(l,"Initialization")[0],f=e&&qe(e);f&&c?f.initialization=c&&qe(c):f&&f.initialization&&(f.initialization={sourceURL:f.initialization});const m={template:f,segmentTimeline:a&&De(a,"S").map(b=>qe(b)),list:t&&Ge(qe(t),{segmentUrls:n,initialization:qe(c)}),base:s&&Ge(qe(s),{initialization:qe(c)})};return Object.keys(m).forEach(b=>{m[b]||delete m[b]}),m},V0=(i,e,t)=>n=>{const s=De(n,"BaseURL"),r=Nr(e,s),a=Ge(i,qe(n)),l=Lo(n);return r.map(c=>({segmentInfo:Ge(t,l),attributes:Ge(a,c)}))},H0=i=>i.reduce((e,t)=>{const n=qe(t);n.schemeIdUri&&(n.schemeIdUri=n.schemeIdUri.toLowerCase());const s=q0[n.schemeIdUri];if(s){e[s]={attributes:n};const r=De(t,"cenc:pssh")[0];if(r){const a=ys(r);e[s].pssh=a&&rh(a)}}return e},{}),z0=i=>{if(i.schemeIdUri==="urn:scte:dash:cc:cea-608:2015")return(typeof i.value!="string"?[]:i.value.split(";")).map(e=>{let t,n;return n=e,/^CC\d=/.test(e)?[t,n]=e.split("="):/^CC\d$/.test(e)&&(t=e),{channel:t,language:n}});if(i.schemeIdUri==="urn:scte:dash:cc:cea-708:2015")return(typeof i.value!="string"?[]:i.value.split(";")).map(e=>{const t={channel:void 0,language:void 0,aspectRatio:1,easyReader:0,"3D":0};if(/=/.test(e)){const[n,s=""]=e.split("=");t.channel=n,t.language=e,s.split(",").forEach(r=>{const[a,l]=r.split(":");a==="lang"?t.language=l:a==="er"?t.easyReader=Number(l):a==="war"?t.aspectRatio=Number(l):a==="3D"&&(t["3D"]=Number(l))})}else t.language=e;return t.channel&&(t.channel="SERVICE"+t.channel),t})},W0=i=>pn(De(i.node,"EventStream").map(e=>{const t=qe(e),n=t.schemeIdUri;return De(e,"Event").map(s=>{const r=qe(s),a=r.presentationTime||0,l=t.timescale||1,c=r.duration||0,f=a/l+i.attributes.start;return{schemeIdUri:n,value:t.value,id:r.id,start:f,end:f+c/l,messageData:ys(s)||r.messageData,contentEncoding:t.contentEncoding,presentationTimeOffset:t.presentationTimeOffset||0}})})),G0=(i,e,t)=>n=>{const s=qe(n),r=Nr(e,De(n,"BaseURL")),a=De(n,"Role")[0],l={role:qe(a)};let c=Ge(i,s,l);const f=De(n,"Accessibility")[0],m=z0(qe(f));m&&(c=Ge(c,{captionServices:m}));const b=De(n,"Label")[0];if(b&&b.childNodes.length){const M=b.childNodes[0].nodeValue.trim();c=Ge(c,{label:M})}const C=H0(De(n,"ContentProtection"));Object.keys(C).length&&(c=Ge(c,{contentProtection:C}));const w=Lo(n),A=De(n,"Representation"),v=Ge(t,w);return pn(A.map(V0(c,r,v)))},X0=(i,e)=>(t,n)=>{const s=Nr(e,De(t.node,"BaseURL")),r=Ge(i,{periodStart:t.attributes.start});typeof t.attributes.duration=="number"&&(r.periodDuration=t.attributes.duration);const a=De(t.node,"AdaptationSet"),l=Lo(t.node);return pn(a.map(G0(r,s,l)))},K0=(i,e)=>{if(i.length>1&&e({type:"warn",message:"The MPD manifest should contain no more than one ContentSteering tag"}),!i.length)return null;const t=Ge({serverURL:ys(i[0])},qe(i[0]));return t.queryBeforeStart=t.queryBeforeStart==="true",t},Y0=({attributes:i,priorPeriodAttributes:e,mpdType:t})=>typeof i.start=="number"?i.start:e&&typeof e.start=="number"&&typeof e.duration=="number"?e.start+e.duration:!e&&t==="static"?0:null,Q0=(i,e={})=>{const{manifestUri:t="",NOW:n=Date.now(),clientOffset:s=0,eventHandler:r=function(){}}=e,a=De(i,"Period");if(!a.length)throw new Error(gn.INVALID_NUMBER_OF_PERIOD);const l=De(i,"Location"),c=qe(i),f=Nr([{baseUrl:t}],De(i,"BaseURL")),m=De(i,"ContentSteering");c.type=c.type||"static",c.sourceDuration=c.mediaPresentationDuration||0,c.NOW=n,c.clientOffset=s,l.length&&(c.locations=l.map(ys));const b=[];return a.forEach((C,w)=>{const A=qe(C),v=b[w-1];A.start=Y0({attributes:A,priorPeriodAttributes:v?v.attributes:null,mpdType:c.type}),b.push({node:C,attributes:A})}),{locations:c.locations,contentSteeringInfo:K0(m,r),representationInfo:pn(b.map(X0(c,f))),eventStream:pn(b.map(W0))}},mh=i=>{if(i==="")throw new Error(gn.DASH_EMPTY_MANIFEST);const e=new Qf.D;let t,n;try{t=e.parseFromString(i,"application/xml"),n=t&&t.documentElement.tagName==="MPD"?t.documentElement:null}catch{}if(!n||n&&n.getElementsByTagName("parsererror").length>0)throw new Error(gn.DASH_INVALID_XML);return n},J0=i=>{const e=De(i,"UTCTiming")[0];if(!e)return null;const t=qe(e);switch(t.schemeIdUri){case"urn:mpeg:dash:utc:http-head:2014":case"urn:mpeg:dash:utc:http-head:2012":t.method="HEAD";break;case"urn:mpeg:dash:utc:http-xsdate:2014":case"urn:mpeg:dash:utc:http-iso:2014":case"urn:mpeg:dash:utc:http-xsdate:2012":case"urn:mpeg:dash:utc:http-iso:2012":t.method="GET";break;case"urn:mpeg:dash:utc:direct:2014":case"urn:mpeg:dash:utc:direct:2012":t.method="DIRECT",t.value=Date.parse(t.value);break;case"urn:mpeg:dash:utc:http-ntp:2014":case"urn:mpeg:dash:utc:ntp:2014":case"urn:mpeg:dash:utc:sntp:2014":default:throw new Error(gn.UNSUPPORTED_UTC_TIMING_SCHEME)}return t},Z0=(i,e={})=>{const t=Q0(mh(i),e),n=F0(t.representationInfo);return P0({dashPlaylists:n,locations:t.locations,contentSteering:t.contentSteeringInfo,sidxMapping:e.sidxMapping,previousManifest:e.previousManifest,eventStream:t.eventStream})},e1=i=>J0(mh(i));var yh=Math.pow(2,32),t1=function(i){var e=new DataView(i.buffer,i.byteOffset,i.byteLength),t;return e.getBigUint64?(t=e.getBigUint64(0),t<Number.MAX_SAFE_INTEGER?Number(t):t):e.getUint32(0)*yh+e.getUint32(4)},i1={getUint64:t1,MAX_UINT32:yh},Au=i1.getUint64,n1=function(i){var e=new DataView(i.buffer,i.byteOffset,i.byteLength),t={version:i[0],flags:new Uint8Array(i.subarray(1,4)),references:[],referenceId:e.getUint32(4),timescale:e.getUint32(8)},n=12;t.version===0?(t.earliestPresentationTime=e.getUint32(n),t.firstOffset=e.getUint32(n+4),n+=8):(t.earliestPresentationTime=Au(i.subarray(n)),t.firstOffset=Au(i.subarray(n+8)),n+=16),n+=2;var s=e.getUint16(n);for(n+=2;s>0;n+=12,s--)t.references.push({referenceType:(i[n]&128)>>>7,referencedSize:e.getUint32(n)&2147483647,subsegmentDuration:e.getUint32(n+4),startsWithSap:!!(i[n+8]&128),sapType:(i[n+8]&112)>>>4,sapDeltaTime:e.getUint32(n+8)&268435455});return t},s1=n1;const r1=ms(s1);var a1=ie([73,68,51]),o1=function(i,e){e===void 0&&(e=0),i=ie(i);var t=i[e+5],n=i[e+6]<<21|i[e+7]<<14|i[e+8]<<7|i[e+9],s=(t&16)>>4;return s?n+20:n+10},is=function i(e,t){return t===void 0&&(t=0),e=ie(e),e.length-t<10||!Le(e,a1,{offset:t})?t:(t+=o1(e,t),i(e,t))},Pu=function(i){return typeof i=="string"?dh(i):i},l1=function(i){return Array.isArray(i)?i.map(function(e){return Pu(e)}):[Pu(i)]},u1=function i(e,t,n){n===void 0&&(n=!1),t=l1(t),e=ie(e);var s=[];if(!t.length)return s;for(var r=0;r<e.length;){var a=(e[r]<<24|e[r+1]<<16|e[r+2]<<8|e[r+3])>>>0,l=e.subarray(r+4,r+8);if(a===0)break;var c=r+a;if(c>e.length){if(n)break;c=e.length}var f=e.subarray(r+8,c);Le(l,t[0])&&(t.length===1?s.push(f):s.push.apply(s,i(f,t.slice(1),n))),r=c}return s},Qs={EBML:ie([26,69,223,163]),DocType:ie([66,130]),Segment:ie([24,83,128,103]),SegmentInfo:ie([21,73,169,102]),Tracks:ie([22,84,174,107]),Track:ie([174]),TrackNumber:ie([215]),DefaultDuration:ie([35,227,131]),TrackEntry:ie([174]),TrackType:ie([131]),FlagDefault:ie([136]),CodecID:ie([134]),CodecPrivate:ie([99,162]),VideoTrack:ie([224]),AudioTrack:ie([225]),Cluster:ie([31,67,182,117]),Timestamp:ie([231]),TimestampScale:ie([42,215,177]),BlockGroup:ie([160]),BlockDuration:ie([155]),Block:ie([161]),SimpleBlock:ie([163])},Ga=[128,64,32,16,8,4,2,1],d1=function(i){for(var e=1,t=0;t<Ga.length&&!(i&Ga[t]);t++)e++;return e},ur=function(i,e,t,n){t===void 0&&(t=!0),n===void 0&&(n=!1);var s=d1(i[e]),r=i.subarray(e,e+s);return t&&(r=Array.prototype.slice.call(i,e,e+s),r[0]^=Ga[s-1]),{length:s,value:s0(r,{signed:n}),bytes:r}},Lu=function i(e){return typeof e=="string"?e.match(/.{1,2}/g).map(function(t){return i(t)}):typeof e=="number"?r0(e):e},h1=function(i){return Array.isArray(i)?i.map(function(e){return Lu(e)}):[Lu(i)]},c1=function i(e,t,n){if(n>=t.length)return t.length;var s=ur(t,n,!1);if(Le(e.bytes,s.bytes))return n;var r=ur(t,n+s.length);return i(e,t,n+r.length+r.value+s.length)},Du=function i(e,t){t=h1(t),e=ie(e);var n=[];if(!t.length)return n;for(var s=0;s<e.length;){var r=ur(e,s,!1),a=ur(e,s+r.length),l=s+r.length+a.length;a.value===127&&(a.value=c1(r,e,l),a.value!==e.length&&(a.value-=l));var c=l+a.value>e.length?e.length:l+a.value,f=e.subarray(l,c);Le(t[0],r.bytes)&&(t.length===1?n.push(f):n=n.concat(i(f,t.slice(1))));var m=r.length+a.length+f.length;s+=m}return n},p1=ie([0,0,0,1]),g1=ie([0,0,1]),f1=ie([0,0,3]),m1=function(i){for(var e=[],t=1;t<i.length-2;)Le(i.subarray(t,t+3),f1)&&(e.push(t+2),t++),t++;if(e.length===0)return i;var n=i.length-e.length,s=new Uint8Array(n),r=0;for(t=0;t<n;r++,t++)r===e[0]&&(r++,e.shift()),s[t]=i[r];return s},_h=function(i,e,t,n){i=ie(i),t=[].concat(t);for(var s=0,r,a=0;s<i.length&&(a<n||r);){var l=void 0;if(Le(i.subarray(s),p1)?l=4:Le(i.subarray(s),g1)&&(l=3),!l){s++;continue}if(a++,r)return m1(i.subarray(r,s));var c=void 0;e==="h264"?c=i[s+l]&31:e==="h265"&&(c=i[s+l]>>1&63),t.indexOf(c)!==-1&&(r=s+l),s+=l+(e==="h264"?1:2)}return i.subarray(0,0)},y1=function(i,e,t){return _h(i,"h264",e,t)},_1=function(i,e,t){return _h(i,"h265",e,t)},rt={webm:ie([119,101,98,109]),matroska:ie([109,97,116,114,111,115,107,97]),flac:ie([102,76,97,67]),ogg:ie([79,103,103,83]),ac3:ie([11,119]),riff:ie([82,73,70,70]),avi:ie([65,86,73]),wav:ie([87,65,86,69]),"3gp":ie([102,116,121,112,51,103]),mp4:ie([102,116,121,112]),fmp4:ie([115,116,121,112]),mov:ie([102,116,121,112,113,116]),moov:ie([109,111,111,118]),moof:ie([109,111,111,102])},fn={aac:function(i){var e=is(i);return Le(i,[255,16],{offset:e,mask:[255,22]})},mp3:function(i){var e=is(i);return Le(i,[255,2],{offset:e,mask:[255,6]})},webm:function(i){var e=Du(i,[Qs.EBML,Qs.DocType])[0];return Le(e,rt.webm)},mkv:function(i){var e=Du(i,[Qs.EBML,Qs.DocType])[0];return Le(e,rt.matroska)},mp4:function(i){if(fn["3gp"](i)||fn.mov(i))return!1;if(Le(i,rt.mp4,{offset:4})||Le(i,rt.fmp4,{offset:4})||Le(i,rt.moof,{offset:4})||Le(i,rt.moov,{offset:4}))return!0},mov:function(i){return Le(i,rt.mov,{offset:4})},"3gp":function(i){return Le(i,rt["3gp"],{offset:4})},ac3:function(i){var e=is(i);return Le(i,rt.ac3,{offset:e})},ts:function(i){if(i.length<189&&i.length>=1)return i[0]===71;for(var e=0;e+188<i.length&&e<188;){if(i[e]===71&&i[e+188]===71)return!0;e+=1}return!1},flac:function(i){var e=is(i);return Le(i,rt.flac,{offset:e})},ogg:function(i){return Le(i,rt.ogg)},avi:function(i){return Le(i,rt.riff)&&Le(i,rt.avi,{offset:8})},wav:function(i){return Le(i,rt.riff)&&Le(i,rt.wav,{offset:8})},h264:function(i){return y1(i,7,3).length},h265:function(i){return _1(i,[32,33],3).length}},Xa=Object.keys(fn).filter(function(i){return i!=="ts"&&i!=="h264"&&i!=="h265"}).concat(["ts","h264","h265"]);Xa.forEach(function(i){var e=fn[i];fn[i]=function(t){return e(ie(t))}});var b1=fn,Do=function(i){i=ie(i);for(var e=0;e<Xa.length;e++){var t=Xa[e];if(b1[t](i))return t}return""},T1=function(i){return u1(i,["moof"]).length>0},Oo=9e4,Mo,Ro,Br,Uo,bh,Th,vh;Mo=function(i){return i*Oo};Ro=function(i,e){return i*e};Br=function(i){return i/Oo};Uo=function(i,e){return i/e};bh=function(i,e){return Mo(Uo(i,e))};Th=function(i,e){return Ro(Br(i),e)};vh=function(i,e,t){return Br(t?i:i-e)};var Ri={ONE_SECOND_IN_TS:Oo,secondsToVideoTs:Mo,secondsToAudioTs:Ro,videoTsToSeconds:Br,audioTsToSeconds:Uo,audioTsToVideoTs:bh,videoTsToAudioTs:Th,metadataTsToSeconds:vh},Ka="8.21.0";const ii={},Ti=function(i,e){return ii[i]=ii[i]||[],e&&(ii[i]=ii[i].concat(e)),ii[i]},v1=function(i,e){Ti(i,e)},Sh=function(i,e){const t=Ti(i).indexOf(e);return t<=-1?!1:(ii[i]=ii[i].slice(),ii[i].splice(t,1),!0)},S1=function(i,e){Ti(i,[].concat(e).map(t=>{const n=(...s)=>(Sh(i,n),t(...s));return n}))},dr={prefixed:!0},nr=[["requestFullscreen","exitFullscreen","fullscreenElement","fullscreenEnabled","fullscreenchange","fullscreenerror","fullscreen"],["webkitRequestFullscreen","webkitExitFullscreen","webkitFullscreenElement","webkitFullscreenEnabled","webkitfullscreenchange","webkitfullscreenerror","-webkit-full-screen"]],Ou=nr[0];let ns;for(let i=0;i<nr.length;i++)if(nr[i][1]in G){ns=nr[i];break}if(ns){for(let i=0;i<ns.length;i++)dr[Ou[i]]=ns[i];dr.prefixed=ns[0]!==Ou[0]}let ct=[];const E1=(i,e,t)=>(n,s,r)=>{const a=e.levels[s],l=new RegExp(`^(${a})$`);let c=i;if(n!=="log"&&r.unshift(n.toUpperCase()+":"),t&&(c=`%c${i}`,r.unshift(t)),r.unshift(c+":"),ct){ct.push([].concat(r));const m=ct.length-1e3;ct.splice(0,m>0?m:0)}if(!x.console)return;let f=x.console[n];!f&&n==="debug"&&(f=x.console.info||x.console.log),!(!f||!a||!l.test(n))&&f[Array.isArray(r)?"apply":"call"](x.console,r)};function Ya(i,e=":",t=""){let n="info",s;function r(...a){s("log",n,a)}return s=E1(i,r,t),r.createLogger=(a,l,c)=>{const f=l!==void 0?l:e,m=c!==void 0?c:t,b=`${i} ${f} ${a}`;return Ya(b,f,m)},r.createNewLogger=(a,l,c)=>Ya(a,l,c),r.levels={all:"debug|log|warn|error",off:"",debug:"debug|log|warn|error",info:"log|warn|error",warn:"warn|error",error:"error",DEFAULT:n},r.level=a=>{if(typeof a=="string"){if(!r.levels.hasOwnProperty(a))throw new Error(`"${a}" in not a valid log level`);n=a}return n},r.history=()=>ct?[].concat(ct):[],r.history.filter=a=>(ct||[]).filter(l=>new RegExp(`.*${a}.*`).test(l[0])),r.history.clear=()=>{ct&&(ct.length=0)},r.history.disable=()=>{ct!==null&&(ct.length=0,ct=null)},r.history.enable=()=>{ct===null&&(ct=[])},r.error=(...a)=>s("error",n,a),r.warn=(...a)=>s("warn",n,a),r.debug=(...a)=>s("debug",n,a),r}const oe=Ya("VIDEOJS"),Eh=oe.createLogger,w1=Object.prototype.toString,wh=function(i){return Qt(i)?Object.keys(i):[]};function sn(i,e){wh(i).forEach(t=>e(i[t],t))}function kh(i,e,t=0){return wh(i).reduce((n,s)=>e(n,i[s],s),t)}function Qt(i){return!!i&&typeof i=="object"}function mn(i){return Qt(i)&&w1.call(i)==="[object Object]"&&i.constructor===Object}function ve(...i){const e={};return i.forEach(t=>{t&&sn(t,(n,s)=>{if(!mn(n)){e[s]=n;return}mn(e[s])||(e[s]={}),e[s]=ve(e[s],n)})}),e}function Ch(i={}){const e=[];for(const t in i)if(i.hasOwnProperty(t)){const n=i[t];e.push(n)}return e}function Fr(i,e,t,n=!0){const s=a=>Object.defineProperty(i,e,{value:a,enumerable:!0,writable:!0}),r={configurable:!0,enumerable:!0,get(){const a=t();return s(a),a}};return n&&(r.set=s),Object.defineProperty(i,e,r)}var k1=Object.freeze({__proto__:null,each:sn,reduce:kh,isObject:Qt,isPlain:mn,merge:ve,values:Ch,defineLazyProperty:Fr});let No=!1,Ih=null,Nt=!1,xh,Ah=!1,rn=!1,an=!1,Jt=!1,Bo=null,jr=null;const C1=!!(x.cast&&x.cast.framework&&x.cast.framework.CastReceiverContext);let Ph=null,hr=!1,$r=!1,cr=!1,qr=!1,pr=!1,gr=!1,fr=!1;const ps=!!(En()&&("ontouchstart"in x||x.navigator.maxTouchPoints||x.DocumentTouch&&x.document instanceof x.DocumentTouch)),fi=x.navigator&&x.navigator.userAgentData;fi&&fi.platform&&fi.brands&&(Nt=fi.platform==="Android",rn=!!fi.brands.find(i=>i.brand==="Microsoft Edge"),an=!!fi.brands.find(i=>i.brand==="Chromium"),Jt=!rn&&an,Bo=jr=(fi.brands.find(i=>i.brand==="Chromium")||{}).version||null,$r=fi.platform==="Windows");if(!an){const i=x.navigator&&x.navigator.userAgent||"";No=/iPod/i.test(i),Ih=function(){const e=i.match(/OS (\d+)_/i);return e&&e[1]?e[1]:null}(),Nt=/Android/i.test(i),xh=function(){const e=i.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(!e)return null;const t=e[1]&&parseFloat(e[1]),n=e[2]&&parseFloat(e[2]);return t&&n?parseFloat(e[1]+"."+e[2]):t||null}(),Ah=/Firefox/i.test(i),rn=/Edg/i.test(i),an=/Chrome/i.test(i)||/CriOS/i.test(i),Jt=!rn&&an,Bo=jr=function(){const e=i.match(/(Chrome|CriOS)\/(\d+)/);return e&&e[2]?parseFloat(e[2]):null}(),Ph=function(){const e=/MSIE\s(\d+)\.\d/.exec(i);let t=e&&parseFloat(e[1]);return!t&&/Trident\/7.0/i.test(i)&&/rv:11.0/.test(i)&&(t=11),t}(),pr=/Tizen/i.test(i),gr=/Web0S/i.test(i),fr=pr||gr,hr=/Safari/i.test(i)&&!Jt&&!Nt&&!rn&&!fr,$r=/Windows/i.test(i),cr=/iPad/i.test(i)||hr&&ps&&!/iPhone/i.test(i),qr=/iPhone/i.test(i)&&!cr}const Je=qr||cr||No,Vr=(hr||Je)&&!Jt;var Lh=Object.freeze({__proto__:null,get IS_IPOD(){return No},get IOS_VERSION(){return Ih},get IS_ANDROID(){return Nt},get ANDROID_VERSION(){return xh},get IS_FIREFOX(){return Ah},get IS_EDGE(){return rn},get IS_CHROMIUM(){return an},get IS_CHROME(){return Jt},get CHROMIUM_VERSION(){return Bo},get CHROME_VERSION(){return jr},IS_CHROMECAST_RECEIVER:C1,get IE_VERSION(){return Ph},get IS_SAFARI(){return hr},get IS_WINDOWS(){return $r},get IS_IPAD(){return cr},get IS_IPHONE(){return qr},get IS_TIZEN(){return pr},get IS_WEBOS(){return gr},get IS_SMART_TV(){return fr},TOUCH_ENABLED:ps,IS_IOS:Je,IS_ANY_SAFARI:Vr});function Mu(i){return typeof i=="string"&&!!i.trim()}function I1(i){if(i.indexOf(" ")>=0)throw new Error("class has illegal whitespace characters")}function En(){return G===x.document}function wn(i){return Qt(i)&&i.nodeType===1}function Dh(){try{return x.parent!==x.self}catch{return!0}}function Oh(i){return function(e,t){if(!Mu(e))return G[i](null);Mu(t)&&(t=G.querySelector(t));const n=wn(t)?t:G;return n[i]&&n[i](e)}}function ne(i="div",e={},t={},n){const s=G.createElement(i);return Object.getOwnPropertyNames(e).forEach(function(r){const a=e[r];r==="textContent"?Si(s,a):(s[r]!==a||r==="tabIndex")&&(s[r]=a)}),Object.getOwnPropertyNames(t).forEach(function(r){s.setAttribute(r,t[r])}),n&&Fo(s,n),s}function Si(i,e){return typeof i.textContent>"u"?i.innerText=e:i.textContent=e,i}function Qa(i,e){e.firstChild?e.insertBefore(i,e.firstChild):e.appendChild(i)}function os(i,e){return I1(e),i.classList.contains(e)}function Bi(i,...e){return i.classList.add(...e.reduce((t,n)=>t.concat(n.split(/\s+/)),[])),i}function Hr(i,...e){return i?(i.classList.remove(...e.reduce((t,n)=>t.concat(n.split(/\s+/)),[])),i):(oe.warn("removeClass was called with an element that doesn't exist"),null)}function Mh(i,e,t){return typeof t=="function"&&(t=t(i,e)),typeof t!="boolean"&&(t=void 0),e.split(/\s+/).forEach(n=>i.classList.toggle(n,t)),i}function Rh(i,e){Object.getOwnPropertyNames(e).forEach(function(t){const n=e[t];n===null||typeof n>"u"||n===!1?i.removeAttribute(t):i.setAttribute(t,n===!0?"":n)})}function _i(i){const e={},t=["autoplay","controls","playsinline","loop","muted","default","defaultMuted"];if(i&&i.attributes&&i.attributes.length>0){const n=i.attributes;for(let s=n.length-1;s>=0;s--){const r=n[s].name;let a=n[s].value;t.includes(r)&&(a=a!==null),e[r]=a}}return e}function Uh(i,e){return i.getAttribute(e)}function yn(i,e,t){i.setAttribute(e,t)}function zr(i,e){i.removeAttribute(e)}function Nh(){G.body.focus(),G.onselectstart=function(){return!1}}function Bh(){G.onselectstart=function(){return!0}}function _n(i){if(i&&i.getBoundingClientRect&&i.parentNode){const e=i.getBoundingClientRect(),t={};return["bottom","height","left","right","top","width"].forEach(n=>{e[n]!==void 0&&(t[n]=e[n])}),t.height||(t.height=parseFloat(bn(i,"height"))),t.width||(t.width=parseFloat(bn(i,"width"))),t}}function gs(i){if(!i||i&&!i.offsetParent)return{left:0,top:0,width:0,height:0};const e=i.offsetWidth,t=i.offsetHeight;let n=0,s=0;for(;i.offsetParent&&i!==G[dr.fullscreenElement];)n+=i.offsetLeft,s+=i.offsetTop,i=i.offsetParent;return{left:n,top:s,width:e,height:t}}function Wr(i,e){const t={x:0,y:0};if(Je){let m=i;for(;m&&m.nodeName.toLowerCase()!=="html";){const b=bn(m,"transform");if(/^matrix/.test(b)){const C=b.slice(7,-1).split(/,\s/).map(Number);t.x+=C[4],t.y+=C[5]}else if(/^matrix3d/.test(b)){const C=b.slice(9,-1).split(/,\s/).map(Number);t.x+=C[12],t.y+=C[13]}if(m.assignedSlot&&m.assignedSlot.parentElement&&x.WebKitCSSMatrix){const C=x.getComputedStyle(m.assignedSlot.parentElement).transform,w=new x.WebKitCSSMatrix(C);t.x+=w.m41,t.y+=w.m42}m=m.parentNode||m.host}}const n={},s=gs(e.target),r=gs(i),a=r.width,l=r.height;let c=e.offsetY-(r.top-s.top),f=e.offsetX-(r.left-s.left);return e.changedTouches&&(f=e.changedTouches[0].pageX-r.left,c=e.changedTouches[0].pageY+r.top,Je&&(f-=t.x,c-=t.y)),n.y=1-Math.max(0,Math.min(1,c/l)),n.x=Math.max(0,Math.min(1,f/a)),n}function Fh(i){return Qt(i)&&i.nodeType===3}function Gr(i){for(;i.firstChild;)i.removeChild(i.firstChild);return i}function jh(i){return typeof i=="function"&&(i=i()),(Array.isArray(i)?i:[i]).map(e=>{if(typeof e=="function"&&(e=e()),wn(e)||Fh(e))return e;if(typeof e=="string"&&/\S/.test(e))return G.createTextNode(e)}).filter(e=>e)}function Fo(i,e){return jh(e).forEach(t=>i.appendChild(t)),i}function $h(i,e){return Fo(Gr(i),e)}function fs(i){return i.button===void 0&&i.buttons===void 0||i.button===0&&i.buttons===void 0||i.type==="mouseup"&&i.button===0&&i.buttons===0||i.type==="mousedown"&&i.button===0&&i.buttons===0?!0:!(i.button!==0||i.buttons!==1)}const vi=Oh("querySelector"),qh=Oh("querySelectorAll");function bn(i,e){if(!i||!e)return"";if(typeof x.getComputedStyle=="function"){let t;try{t=x.getComputedStyle(i)}catch{return""}return t?t.getPropertyValue(e)||t[e]:""}return""}function Vh(i){[...G.styleSheets].forEach(e=>{try{const t=[...e.cssRules].map(s=>s.cssText).join(""),n=G.createElement("style");n.textContent=t,i.document.head.appendChild(n)}catch{const t=G.createElement("link");t.rel="stylesheet",t.type=e.type,t.media=e.media.mediaText,t.href=e.href,i.document.head.appendChild(t)}})}var Hh=Object.freeze({__proto__:null,isReal:En,isEl:wn,isInFrame:Dh,createEl:ne,textContent:Si,prependTo:Qa,hasClass:os,addClass:Bi,removeClass:Hr,toggleClass:Mh,setAttributes:Rh,getAttributes:_i,getAttribute:Uh,setAttribute:yn,removeAttribute:zr,blockTextSelection:Nh,unblockTextSelection:Bh,getBoundingClientRect:_n,findPosition:gs,getPointerPosition:Wr,isTextNode:Fh,emptyEl:Gr,normalizeContent:jh,appendContent:Fo,insertContent:$h,isSingleLeftClick:fs,$:vi,$$:qh,computedStyle:bn,copyStyleSheetsToWindow:Vh});let zh=!1,Ja;const x1=function(){if(Ja.options.autoSetup===!1)return;const i=Array.prototype.slice.call(G.getElementsByTagName("video")),e=Array.prototype.slice.call(G.getElementsByTagName("audio")),t=Array.prototype.slice.call(G.getElementsByTagName("video-js")),n=i.concat(e,t);if(n&&n.length>0)for(let s=0,r=n.length;s<r;s++){const a=n[s];if(a&&a.getAttribute)a.player===void 0&&a.getAttribute("data-setup")!==null&&Ja(a);else{Za(1);break}}else zh||Za(1)};function Za(i,e){En()&&(e&&(Ja=e),x.setTimeout(x1,i))}function eo(){zh=!0,x.removeEventListener("load",eo)}En()&&(G.readyState==="complete"?eo():x.addEventListener("load",eo));const Wh=function(i){const e=G.createElement("style");return e.className=i,e},Gh=function(i,e){i.styleSheet?i.styleSheet.cssText=e:i.textContent=e};var lt=new WeakMap;const A1=3;let P1=A1;function At(){return P1++}function Ru(i,e){if(!lt.has(i))return;const t=lt.get(i);t.handlers[e].length===0&&(delete t.handlers[e],i.removeEventListener?i.removeEventListener(e,t.dispatcher,!1):i.detachEvent&&i.detachEvent("on"+e,t.dispatcher)),Object.getOwnPropertyNames(t.handlers).length<=0&&(delete t.handlers,delete t.dispatcher,delete t.disabled),Object.getOwnPropertyNames(t).length===0&<.delete(i)}function jo(i,e,t,n){t.forEach(function(s){i(e,s,n)})}function Xr(i){if(i.fixed_)return i;function e(){return!0}function t(){return!1}if(!i||!i.isPropagationStopped||!i.isImmediatePropagationStopped){const n=i||x.event;i={};const s=["layerX","layerY","keyLocation","path","webkitMovementX","webkitMovementY","mozPressure","mozInputSource"];for(const r in n)s.includes(r)||r==="returnValue"&&n.preventDefault||(i[r]=n[r]);if(i.target||(i.target=i.srcElement||G),i.relatedTarget||(i.relatedTarget=i.fromElement===i.target?i.toElement:i.fromElement),i.preventDefault=function(){n.preventDefault&&n.preventDefault(),i.returnValue=!1,n.returnValue=!1,i.defaultPrevented=!0},i.defaultPrevented=!1,i.stopPropagation=function(){n.stopPropagation&&n.stopPropagation(),i.cancelBubble=!0,n.cancelBubble=!0,i.isPropagationStopped=e},i.isPropagationStopped=t,i.stopImmediatePropagation=function(){n.stopImmediatePropagation&&n.stopImmediatePropagation(),i.isImmediatePropagationStopped=e,i.stopPropagation()},i.isImmediatePropagationStopped=t,i.clientX!==null&&i.clientX!==void 0){const r=G.documentElement,a=G.body;i.pageX=i.clientX+(r&&r.scrollLeft||a&&a.scrollLeft||0)-(r&&r.clientLeft||a&&a.clientLeft||0),i.pageY=i.clientY+(r&&r.scrollTop||a&&a.scrollTop||0)-(r&&r.clientTop||a&&a.clientTop||0)}i.which=i.charCode||i.keyCode,i.button!==null&&i.button!==void 0&&(i.button=i.button&1?0:i.button&4?1:i.button&2?2:0)}return i.fixed_=!0,i}let Js;const L1=function(){if(typeof Js!="boolean"){Js=!1;try{const i=Object.defineProperty({},"passive",{get(){Js=!0}});x.addEventListener("test",null,i),x.removeEventListener("test",null,i)}catch{}}return Js},D1=["touchstart","touchmove"];function vt(i,e,t){if(Array.isArray(e))return jo(vt,i,e,t);lt.has(i)||lt.set(i,{});const n=lt.get(i);if(n.handlers||(n.handlers={}),n.handlers[e]||(n.handlers[e]=[]),t.guid||(t.guid=At()),n.handlers[e].push(t),n.dispatcher||(n.disabled=!1,n.dispatcher=function(s,r){if(n.disabled)return;s=Xr(s);const a=n.handlers[s.type];if(a){const l=a.slice(0);for(let c=0,f=l.length;c<f&&!s.isImmediatePropagationStopped();c++)try{l[c].call(i,s,r)}catch(m){oe.error(m)}}}),n.handlers[e].length===1)if(i.addEventListener){let s=!1;L1()&&D1.indexOf(e)>-1&&(s={passive:!0}),i.addEventListener(e,n.dispatcher,s)}else i.attachEvent&&i.attachEvent("on"+e,n.dispatcher)}function Ze(i,e,t){if(!lt.has(i))return;const n=lt.get(i);if(!n.handlers)return;if(Array.isArray(e))return jo(Ze,i,e,t);const s=function(a,l){n.handlers[l]=[],Ru(a,l)};if(e===void 0){for(const a in n.handlers)Object.prototype.hasOwnProperty.call(n.handlers||{},a)&&s(i,a);return}const r=n.handlers[e];if(r){if(!t){s(i,e);return}if(t.guid)for(let a=0;a<r.length;a++)r[a].guid===t.guid&&r.splice(a--,1);Ru(i,e)}}function kn(i,e,t){const n=lt.has(i)?lt.get(i):{},s=i.parentNode||i.ownerDocument;if(typeof e=="string"?e={type:e,target:i}:e.target||(e.target=i),e=Xr(e),n.dispatcher&&n.dispatcher.call(i,e,t),s&&!e.isPropagationStopped()&&e.bubbles===!0)kn.call(null,s,e,t);else if(!s&&!e.defaultPrevented&&e.target&&e.target[e.type]){lt.has(e.target)||lt.set(e.target,{});const r=lt.get(e.target);e.target[e.type]&&(r.disabled=!0,typeof e.target[e.type]=="function"&&e.target[e.type](),r.disabled=!1)}return!e.defaultPrevented}function Kr(i,e,t){if(Array.isArray(e))return jo(Kr,i,e,t);const n=function(){Ze(i,e,n),t.apply(this,arguments)};n.guid=t.guid=t.guid||At(),vt(i,e,n)}function $o(i,e,t){const n=function(){Ze(i,e,n),t.apply(this,arguments)};n.guid=t.guid=t.guid||At(),vt(i,e,n)}var O1=Object.freeze({__proto__:null,fixEvent:Xr,on:vt,off:Ze,trigger:kn,one:Kr,any:$o});const Pt=30,Ce=function(i,e,t){e.guid||(e.guid=At());const n=e.bind(i);return n.guid=t?t+"_"+e.guid:e.guid,n},Zt=function(i,e){let t=x.performance.now();return function(...n){const s=x.performance.now();s-t>=e&&(i(...n),t=s)}},Xh=function(i,e,t,n=x){let s;const r=()=>{n.clearTimeout(s),s=null},a=function(){const l=this,c=arguments;let f=function(){s=null,f=null,t||i.apply(l,c)};!s&&t&&i.apply(l,c),n.clearTimeout(s),s=n.setTimeout(f,e)};return a.cancel=r,a};var M1=Object.freeze({__proto__:null,UPDATE_REFRESH_INTERVAL:Pt,bind_:Ce,throttle:Zt,debounce:Xh});let Yn;class St{on(e,t){const n=this.addEventListener;this.addEventListener=()=>{},vt(this,e,t),this.addEventListener=n}off(e,t){Ze(this,e,t)}one(e,t){const n=this.addEventListener;this.addEventListener=()=>{},Kr(this,e,t),this.addEventListener=n}any(e,t){const n=this.addEventListener;this.addEventListener=()=>{},$o(this,e,t),this.addEventListener=n}trigger(e){const t=e.type||e;typeof e=="string"&&(e={type:t}),e=Xr(e),this.allowedEvents_[t]&&this["on"+t]&&this["on"+t](e),kn(this,e)}queueTrigger(e){Yn||(Yn=new Map);const t=e.type||e;let n=Yn.get(this);n||(n=new Map,Yn.set(this,n));const s=n.get(t);n.delete(t),x.clearTimeout(s);const r=x.setTimeout(()=>{n.delete(t),n.size===0&&(n=null,Yn.delete(this)),this.trigger(e)},0);n.set(t,r)}}St.prototype.allowedEvents_={};St.prototype.addEventListener=St.prototype.on;St.prototype.removeEventListener=St.prototype.off;St.prototype.dispatchEvent=St.prototype.trigger;const Yr=i=>typeof i.name=="function"?i.name():typeof i.name=="string"?i.name:i.name_?i.name_:i.constructor&&i.constructor.name?i.constructor.name:typeof i,si=i=>i instanceof St||!!i.eventBusEl_&&["on","one","off","trigger"].every(e=>typeof i[e]=="function"),R1=(i,e)=>{si(i)?e():(i.eventedCallbacks||(i.eventedCallbacks=[]),i.eventedCallbacks.push(e))},to=i=>typeof i=="string"&&/\S/.test(i)||Array.isArray(i)&&!!i.length,mr=(i,e,t)=>{if(!i||!i.nodeName&&!si(i))throw new Error(`Invalid target for ${Yr(e)}#${t}; must be a DOM node or evented object.`)},Kh=(i,e,t)=>{if(!to(i))throw new Error(`Invalid event type for ${Yr(e)}#${t}; must be a non-empty string or array.`)},Yh=(i,e,t)=>{if(typeof i!="function")throw new Error(`Invalid listener for ${Yr(e)}#${t}; must be a function.`)},La=(i,e,t)=>{const n=e.length<3||e[0]===i||e[0]===i.eventBusEl_;let s,r,a;return n?(s=i.eventBusEl_,e.length>=3&&e.shift(),[r,a]=e):(s=e[0],r=e[1],a=e[2]),mr(s,i,t),Kh(r,i,t),Yh(a,i,t),a=Ce(i,a),{isTargetingSelf:n,target:s,type:r,listener:a}},Di=(i,e,t,n)=>{mr(i,i,e),i.nodeName?O1[e](i,t,n):i[e](t,n)},U1={on(...i){const{isTargetingSelf:e,target:t,type:n,listener:s}=La(this,i,"on");if(Di(t,"on",n,s),!e){const r=()=>this.off(t,n,s);r.guid=s.guid;const a=()=>this.off("dispose",r);a.guid=s.guid,Di(this,"on","dispose",r),Di(t,"on","dispose",a)}},one(...i){const{isTargetingSelf:e,target:t,type:n,listener:s}=La(this,i,"one");if(e)Di(t,"one",n,s);else{const r=(...a)=>{this.off(t,n,r),s.apply(null,a)};r.guid=s.guid,Di(t,"one",n,r)}},any(...i){const{isTargetingSelf:e,target:t,type:n,listener:s}=La(this,i,"any");if(e)Di(t,"any",n,s);else{const r=(...a)=>{this.off(t,n,r),s.apply(null,a)};r.guid=s.guid,Di(t,"any",n,r)}},off(i,e,t){if(!i||to(i))Ze(this.eventBusEl_,i,e);else{const n=i,s=e;mr(n,this,"off"),Kh(s,this,"off"),Yh(t,this,"off"),t=Ce(this,t),this.off("dispose",t),n.nodeName?(Ze(n,s,t),Ze(n,"dispose",t)):si(n)&&(n.off(s,t),n.off("dispose",t))}},trigger(i,e){mr(this.eventBusEl_,this,"trigger");const t=i&&typeof i!="string"?i.type:i;if(!to(t))throw new Error(`Invalid event type for ${Yr(this)}#trigger; must be a non-empty string or object with a type key that has a non-empty value.`);return kn(this.eventBusEl_,i,e)}};function qo(i,e={}){const{eventBusKey:t}=e;if(t){if(!i[t].nodeName)throw new Error(`The eventBusKey "${t}" does not refer to an element.`);i.eventBusEl_=i[t]}else i.eventBusEl_=ne("span",{className:"vjs-event-bus"});return Object.assign(i,U1),i.eventedCallbacks&&i.eventedCallbacks.forEach(n=>{n()}),i.on("dispose",()=>{i.off(),[i,i.el_,i.eventBusEl_].forEach(function(n){n&<.has(n)&<.delete(n)}),x.setTimeout(()=>{i.eventBusEl_=null},0)}),i}const N1={state:{},setState(i){typeof i=="function"&&(i=i());let e;return sn(i,(t,n)=>{this.state[n]!==t&&(e=e||{},e[n]={from:this.state[n],to:t}),this.state[n]=t}),e&&si(this)&&this.trigger({changes:e,type:"statechanged"}),e}};function Qh(i,e){return Object.assign(i,N1),i.state=Object.assign({},i.state,e),typeof i.handleStateChanged=="function"&&si(i)&&i.on("statechanged",i.handleStateChanged),i}const ls=function(i){return typeof i!="string"?i:i.replace(/./,e=>e.toLowerCase())},Ne=function(i){return typeof i!="string"?i:i.replace(/./,e=>e.toUpperCase())},Jh=function(i,e){return Ne(i)===Ne(e)};var B1=Object.freeze({__proto__:null,toLowerCase:ls,toTitleCase:Ne,titleCaseEquals:Jh});let H=class ht{constructor(e,t,n){if(!e&&this.play?this.player_=e=this:this.player_=e,this.isDisposed_=!1,this.parentComponent_=null,this.options_=ve({},this.options_),t=this.options_=ve(this.options_,t),this.id_=t.id||t.el&&t.el.id,!this.id_){const s=e&&e.id&&e.id()||"no_player";this.id_=`${s}_component_${At()}`}this.name_=t.name||null,t.el?this.el_=t.el:t.createEl!==!1&&(this.el_=this.createEl()),t.className&&this.el_&&t.className.split(" ").forEach(s=>this.addClass(s)),["on","off","one","any","trigger"].forEach(s=>{this[s]=void 0}),t.evented!==!1&&(qo(this,{eventBusKey:this.el_?"el_":null}),this.handleLanguagechange=this.handleLanguagechange.bind(this),this.on(this.player_,"languagechange",this.handleLanguagechange)),Qh(this,this.constructor.defaultState),this.children_=[],this.childIndex_={},this.childNameIndex_={},this.setTimeoutIds_=new Set,this.setIntervalIds_=new Set,this.rafIds_=new Set,this.namedRafs_=new Map,this.clearingTimersOnDispose_=!1,t.initChildren!==!1&&this.initChildren(),this.ready(n),t.reportTouchActivity!==!1&&this.enableTouchActivity()}dispose(e={}){if(!this.isDisposed_){if(this.readyQueue_&&(this.readyQueue_.length=0),this.trigger({type:"dispose",bubbles:!1}),this.isDisposed_=!0,this.children_)for(let t=this.children_.length-1;t>=0;t--)this.children_[t].dispose&&this.children_[t].dispose();this.children_=null,this.childIndex_=null,this.childNameIndex_=null,this.parentComponent_=null,this.el_&&(this.el_.parentNode&&(e.restoreEl?this.el_.parentNode.replaceChild(e.restoreEl,this.el_):this.el_.parentNode.removeChild(this.el_)),this.el_=null),this.player_=null}}isDisposed(){return!!this.isDisposed_}player(){return this.player_}options(e){return e?(this.options_=ve(this.options_,e),this.options_):this.options_}el(){return this.el_}createEl(e,t,n){return ne(e,t,n)}localize(e,t,n=e){const s=this.player_.language&&this.player_.language(),r=this.player_.languages&&this.player_.languages(),a=r&&r[s],l=s&&s.split("-")[0],c=r&&r[l];let f=n;return a&&a[e]?f=a[e]:c&&c[e]&&(f=c[e]),t&&(f=f.replace(/\{(\d+)\}/g,function(m,b){const C=t[b-1];let w=C;return typeof C>"u"&&(w=m),w})),f}handleLanguagechange(){}contentEl(){return this.contentEl_||this.el_}id(){return this.id_}name(){return this.name_}children(){return this.children_}getChildById(e){return this.childIndex_[e]}getChild(e){if(e)return this.childNameIndex_[e]}getDescendant(...e){e=e.reduce((n,s)=>n.concat(s),[]);let t=this;for(let n=0;n<e.length;n++)if(t=t.getChild(e[n]),!t||!t.getChild)return;return t}setIcon(e,t=this.el()){if(!this.player_.options_.experimentalSvgIcons)return;const n="http://www.w3.org/2000/svg",s=ne("span",{className:"vjs-icon-placeholder vjs-svg-icon"},{"aria-hidden":"true"}),r=G.createElementNS(n,"svg");r.setAttributeNS(null,"viewBox","0 0 512 512");const a=G.createElementNS(n,"use");return r.appendChild(a),a.setAttributeNS(null,"href",`#vjs-icon-${e}`),s.appendChild(r),this.iconIsSet_?t.replaceChild(s,t.querySelector(".vjs-icon-placeholder")):t.appendChild(s),this.iconIsSet_=!0,s}addChild(e,t={},n=this.children_.length){let s,r;if(typeof e=="string"){r=Ne(e);const a=t.componentClass||r;t.name=r;const l=ht.getComponent(a);if(!l)throw new Error(`Component ${a} does not exist`);if(typeof l!="function")return null;s=new l(this.player_||this,t)}else s=e;if(s.parentComponent_&&s.parentComponent_.removeChild(s),this.children_.splice(n,0,s),s.parentComponent_=this,typeof s.id=="function"&&(this.childIndex_[s.id()]=s),r=r||s.name&&Ne(s.name()),r&&(this.childNameIndex_[r]=s,this.childNameIndex_[ls(r)]=s),typeof s.el=="function"&&s.el()){let a=null;this.children_[n+1]&&(this.children_[n+1].el_?a=this.children_[n+1].el_:wn(this.children_[n+1])&&(a=this.children_[n+1])),this.contentEl().insertBefore(s.el(),a)}return s}removeChild(e){if(typeof e=="string"&&(e=this.getChild(e)),!e||!this.children_)return;let t=!1;for(let s=this.children_.length-1;s>=0;s--)if(this.children_[s]===e){t=!0,this.children_.splice(s,1);break}if(!t)return;e.parentComponent_=null,this.childIndex_[e.id()]=null,this.childNameIndex_[Ne(e.name())]=null,this.childNameIndex_[ls(e.name())]=null;const n=e.el();n&&n.parentNode===this.contentEl()&&this.contentEl().removeChild(e.el())}initChildren(){const e=this.options_.children;if(e){const t=this.options_,n=a=>{const l=a.name;let c=a.opts;if(t[l]!==void 0&&(c=t[l]),c===!1)return;c===!0&&(c={}),c.playerOptions=this.options_.playerOptions;const f=this.addChild(l,c);f&&(this[l]=f)};let s;const r=ht.getComponent("Tech");Array.isArray(e)?s=e:s=Object.keys(e),s.concat(Object.keys(this.options_).filter(function(a){return!s.some(function(l){return typeof l=="string"?a===l:a===l.name})})).map(a=>{let l,c;return typeof a=="string"?(l=a,c=e[l]||this.options_[l]||{}):(l=a.name,c=a),{name:l,opts:c}}).filter(a=>{const l=ht.getComponent(a.opts.componentClass||Ne(a.name));return l&&!r.isTech(l)}).forEach(n)}}buildCSSClass(){return""}ready(e,t=!1){if(e){if(!this.isReady_){this.readyQueue_=this.readyQueue_||[],this.readyQueue_.push(e);return}t?e.call(this):this.setTimeout(e,1)}}triggerReady(){this.isReady_=!0,this.setTimeout(function(){const e=this.readyQueue_;this.readyQueue_=[],e&&e.length>0&&e.forEach(function(t){t.call(this)},this),this.trigger("ready")},1)}$(e,t){return vi(e,t||this.contentEl())}$$(e,t){return qh(e,t||this.contentEl())}hasClass(e){return os(this.el_,e)}addClass(...e){Bi(this.el_,...e)}removeClass(...e){Hr(this.el_,...e)}toggleClass(e,t){Mh(this.el_,e,t)}show(){this.removeClass("vjs-hidden")}hide(){this.addClass("vjs-hidden")}lockShowing(){this.addClass("vjs-lock-showing")}unlockShowing(){this.removeClass("vjs-lock-showing")}getAttribute(e){return Uh(this.el_,e)}setAttribute(e,t){yn(this.el_,e,t)}removeAttribute(e){zr(this.el_,e)}width(e,t){return this.dimension("width",e,t)}height(e,t){return this.dimension("height",e,t)}dimensions(e,t){this.width(e,!0),this.height(t)}dimension(e,t,n){if(t!==void 0){(t===null||t!==t)&&(t=0),(""+t).indexOf("%")!==-1||(""+t).indexOf("px")!==-1?this.el_.style[e]=t:t==="auto"?this.el_.style[e]="":this.el_.style[e]=t+"px",n||this.trigger("componentresize");return}if(!this.el_)return 0;const s=this.el_.style[e],r=s.indexOf("px");return parseInt(r!==-1?s.slice(0,r):this.el_["offset"+Ne(e)],10)}currentDimension(e){let t=0;if(e!=="width"&&e!=="height")throw new Error("currentDimension only accepts width or height value");if(t=bn(this.el_,e),t=parseFloat(t),t===0||isNaN(t)){const n=`offset${Ne(e)}`;t=this.el_[n]}return t}currentDimensions(){return{width:this.currentDimension("width"),height:this.currentDimension("height")}}currentWidth(){return this.currentDimension("width")}currentHeight(){return this.currentDimension("height")}getPositions(){const e=this.el_.getBoundingClientRect(),t={x:e.x,y:e.y,width:e.width,height:e.height,top:e.top,right:e.right,bottom:e.bottom,left:e.left},n={x:e.left+e.width/2,y:e.top+e.height/2,width:0,height:0,top:e.top+e.height/2,right:e.left+e.width/2,bottom:e.top+e.height/2,left:e.left+e.width/2};return{boundingClientRect:t,center:n}}focus(){this.el_.focus()}blur(){this.el_.blur()}handleKeyDown(e){this.player_&&(e.key!=="Tab"&&!(this.player_.options_.playerOptions.spatialNavigation&&this.player_.options_.playerOptions.spatialNavigation.enabled)&&e.stopPropagation(),this.player_.handleKeyDown(e))}handleKeyPress(e){this.handleKeyDown(e)}emitTapEvents(){let e=0,t=null;const n=10,s=200;let r;this.on("touchstart",function(l){l.touches.length===1&&(t={pageX:l.touches[0].pageX,pageY:l.touches[0].pageY},e=x.performance.now(),r=!0)}),this.on("touchmove",function(l){if(l.touches.length>1)r=!1;else if(t){const c=l.touches[0].pageX-t.pageX,f=l.touches[0].pageY-t.pageY;Math.sqrt(c*c+f*f)>n&&(r=!1)}});const a=function(){r=!1};this.on("touchleave",a),this.on("touchcancel",a),this.on("touchend",function(l){t=null,r===!0&&x.performance.now()-e<s&&(l.preventDefault(),this.trigger("tap"))})}enableTouchActivity(){if(!this.player()||!this.player().reportUserActivity)return;const e=Ce(this.player(),this.player().reportUserActivity);let t;this.on("touchstart",function(){e(),this.clearInterval(t),t=this.setInterval(e,250)});const n=function(s){e(),this.clearInterval(t)};this.on("touchmove",e),this.on("touchend",n),this.on("touchcancel",n)}setTimeout(e,t){var n;return e=Ce(this,e),this.clearTimersOnDispose_(),n=x.setTimeout(()=>{this.setTimeoutIds_.has(n)&&this.setTimeoutIds_.delete(n),e()},t),this.setTimeoutIds_.add(n),n}clearTimeout(e){return this.setTimeoutIds_.has(e)&&(this.setTimeoutIds_.delete(e),x.clearTimeout(e)),e}setInterval(e,t){e=Ce(this,e),this.clearTimersOnDispose_();const n=x.setInterval(e,t);return this.setIntervalIds_.add(n),n}clearInterval(e){return this.setIntervalIds_.has(e)&&(this.setIntervalIds_.delete(e),x.clearInterval(e)),e}requestAnimationFrame(e){this.clearTimersOnDispose_();var t;return e=Ce(this,e),t=x.requestAnimationFrame(()=>{this.rafIds_.has(t)&&this.rafIds_.delete(t),e()}),this.rafIds_.add(t),t}requestNamedAnimationFrame(e,t){this.namedRafs_.has(e)&&this.cancelNamedAnimationFrame(e),this.clearTimersOnDispose_(),t=Ce(this,t);const n=this.requestAnimationFrame(()=>{t(),this.namedRafs_.has(e)&&this.namedRafs_.delete(e)});return this.namedRafs_.set(e,n),e}cancelNamedAnimationFrame(e){this.namedRafs_.has(e)&&(this.cancelAnimationFrame(this.namedRafs_.get(e)),this.namedRafs_.delete(e))}cancelAnimationFrame(e){return this.rafIds_.has(e)&&(this.rafIds_.delete(e),x.cancelAnimationFrame(e)),e}clearTimersOnDispose_(){this.clearingTimersOnDispose_||(this.clearingTimersOnDispose_=!0,this.one("dispose",()=>{[["namedRafs_","cancelNamedAnimationFrame"],["rafIds_","cancelAnimationFrame"],["setTimeoutIds_","clearTimeout"],["setIntervalIds_","clearInterval"]].forEach(([e,t])=>{this[e].forEach((n,s)=>this[t](s))}),this.clearingTimersOnDispose_=!1}))}getIsDisabled(){return!!this.el_.disabled}getIsExpresslyInert(){return this.el_.inert&&!this.el_.ownerDocument.documentElement.inert}getIsFocusable(e){return(e||this.el_).tabIndex>=0&&!(this.getIsDisabled()||this.getIsExpresslyInert())}getIsAvailableToBeFocused(e){function t(r){const a=x.getComputedStyle(r,null),l=a.getPropertyValue("visibility");return a.getPropertyValue("display")!=="none"&&!["hidden","collapse"].includes(l)}function n(r){return!(!t(r.parentElement)||!t(r)||r.style.opacity==="0"||x.getComputedStyle(r).height==="0px"||x.getComputedStyle(r).width==="0px")}function s(r){if(r.offsetWidth+r.offsetHeight+r.getBoundingClientRect().height+r.getBoundingClientRect().width===0)return!1;const a={x:r.getBoundingClientRect().left+r.offsetWidth/2,y:r.getBoundingClientRect().top+r.offsetHeight/2};if(a.x<0||a.x>(G.documentElement.clientWidth||x.innerWidth)||a.y<0||a.y>(G.documentElement.clientHeight||x.innerHeight))return!1;let l=G.elementFromPoint(a.x,a.y);for(;l;){if(l===r)return!0;if(l.parentNode)l=l.parentNode;else return!1}}return e||(e=this.el()),!!(s(e)&&n(e)&&(!e.parentElement||e.tabIndex>=0))}static registerComponent(e,t){if(typeof e!="string"||!e)throw new Error(`Illegal component name, "${e}"; must be a non-empty string.`);const n=ht.getComponent("Tech"),s=n&&n.isTech(t),r=ht===t||ht.prototype.isPrototypeOf(t.prototype);if(s||!r){let l;throw s?l="techs must be registered using Tech.registerTech()":l="must be a Component subclass",new Error(`Illegal component, "${e}"; ${l}.`)}e=Ne(e),ht.components_||(ht.components_={});const a=ht.getComponent("Player");if(e==="Player"&&a&&a.players){const l=a.players,c=Object.keys(l);if(l&&c.length>0&&c.map(f=>l[f]).every(Boolean))throw new Error("Can not register Player component after player has been created.")}return ht.components_[e]=t,ht.components_[ls(e)]=t,t}static getComponent(e){if(!(!e||!ht.components_))return ht.components_[e]}};H.registerComponent("Component",H);function F1(i,e,t){if(typeof e!="number"||e<0||e>t)throw new Error(`Failed to execute '${i}' on 'TimeRanges': The index provided (${e}) is non-numeric or out of bounds (0-${t}).`)}function Uu(i,e,t,n){return F1(i,n,t.length-1),t[n][e]}function Da(i){let e;return i===void 0||i.length===0?e={length:0,start(){throw new Error("This TimeRanges object is empty")},end(){throw new Error("This TimeRanges object is empty")}}:e={length:i.length,start:Uu.bind(null,"start",0,i),end:Uu.bind(null,"end",1,i)},x.Symbol&&x.Symbol.iterator&&(e[x.Symbol.iterator]=()=>(i||[]).values()),e}function Ut(i,e){return Array.isArray(i)?Da(i):i===void 0||e===void 0?Da():Da([[i,e]])}const Zh=function(i,e){i=i<0?0:i;let t=Math.floor(i%60),n=Math.floor(i/60%60),s=Math.floor(i/3600);const r=Math.floor(e/60%60),a=Math.floor(e/3600);return(isNaN(i)||i===1/0)&&(s=n=t="-"),s=s>0||a>0?s+":":"",n=((s||r>=10)&&n<10?"0"+n:n)+":",t=t<10?"0"+t:t,s+n+t};let Vo=Zh;function ec(i){Vo=i}function tc(){Vo=Zh}function qi(i,e=i){return Vo(i,e)}var j1=Object.freeze({__proto__:null,createTimeRanges:Ut,createTimeRange:Ut,setFormatTime:ec,resetFormatTime:tc,formatTime:qi});function ic(i,e){let t=0,n,s;if(!e)return 0;(!i||!i.length)&&(i=Ut(0,0));for(let r=0;r<i.length;r++)n=i.start(r),s=i.end(r),s>e&&(s=e),t+=s-n;return t/e}function Me(i){if(i instanceof Me)return i;typeof i=="number"?this.code=i:typeof i=="string"?this.message=i:Qt(i)&&(typeof i.code=="number"&&(this.code=i.code),Object.assign(this,i)),this.message||(this.message=Me.defaultMessages[this.code]||"")}Me.prototype.code=0;Me.prototype.message="";Me.prototype.status=null;Me.prototype.metadata=null;Me.errorTypes=["MEDIA_ERR_CUSTOM","MEDIA_ERR_ABORTED","MEDIA_ERR_NETWORK","MEDIA_ERR_DECODE","MEDIA_ERR_SRC_NOT_SUPPORTED","MEDIA_ERR_ENCRYPTED"];Me.defaultMessages={1:"You aborted the media playback",2:"A network error caused the media download to fail part-way.",3:"The media playback was aborted due to a corruption problem or because the media used features your browser did not support.",4:"The media could not be loaded, either because the server or network failed or because the format is not supported.",5:"The media is encrypted and we do not have the keys to decrypt it."};Me.MEDIA_ERR_CUSTOM=0;Me.prototype.MEDIA_ERR_CUSTOM=0;Me.MEDIA_ERR_ABORTED=1;Me.prototype.MEDIA_ERR_ABORTED=1;Me.MEDIA_ERR_NETWORK=2;Me.prototype.MEDIA_ERR_NETWORK=2;Me.MEDIA_ERR_DECODE=3;Me.prototype.MEDIA_ERR_DECODE=3;Me.MEDIA_ERR_SRC_NOT_SUPPORTED=4;Me.prototype.MEDIA_ERR_SRC_NOT_SUPPORTED=4;Me.MEDIA_ERR_ENCRYPTED=5;Me.prototype.MEDIA_ERR_ENCRYPTED=5;function us(i){return i!=null&&typeof i.then=="function"}function Gt(i){us(i)&&i.then(null,e=>{})}const io=function(i){return["kind","label","language","id","inBandMetadataTrackDispatchType","mode","src"].reduce((e,t,n)=>(i[t]&&(e[t]=i[t]),e),{cues:i.cues&&Array.prototype.map.call(i.cues,function(e){return{startTime:e.startTime,endTime:e.endTime,text:e.text,id:e.id}})})},$1=function(i){const e=i.$$("track"),t=Array.prototype.map.call(e,n=>n.track);return Array.prototype.map.call(e,function(n){const s=io(n.track);return n.src&&(s.src=n.src),s}).concat(Array.prototype.filter.call(i.textTracks(),function(n){return t.indexOf(n)===-1}).map(io))},q1=function(i,e){return i.forEach(function(t){const n=e.addRemoteTextTrack(t).track;!t.src&&t.cues&&t.cues.forEach(s=>n.addCue(s))}),e.textTracks()};var Nu={textTracksToJson:$1,jsonToTextTracks:q1,trackToJson_:io};const Oa="vjs-modal-dialog";class Cn extends H{constructor(e,t){super(e,t),this.handleKeyDown_=n=>this.handleKeyDown(n),this.close_=n=>this.close(n),this.opened_=this.hasBeenOpened_=this.hasBeenFilled_=!1,this.closeable(!this.options_.uncloseable),this.content(this.options_.content),this.contentEl_=ne("div",{className:`${Oa}-content`},{role:"document"}),this.descEl_=ne("p",{className:`${Oa}-description vjs-control-text`,id:this.el().getAttribute("aria-describedby")}),Si(this.descEl_,this.description()),this.el_.appendChild(this.descEl_),this.el_.appendChild(this.contentEl_)}createEl(){return super.createEl("div",{className:this.buildCSSClass(),tabIndex:-1},{"aria-describedby":`${this.id()}_description`,"aria-hidden":"true","aria-label":this.label(),role:"dialog","aria-live":"polite"})}dispose(){this.contentEl_=null,this.descEl_=null,this.previouslyActiveEl_=null,super.dispose()}buildCSSClass(){return`${Oa} vjs-hidden ${super.buildCSSClass()}`}label(){return this.localize(this.options_.label||"Modal Window")}description(){let e=this.options_.description||this.localize("This is a modal window.");return this.closeable()&&(e+=" "+this.localize("This modal can be closed by pressing the Escape key or activating the close button.")),e}open(){if(this.opened_){this.options_.fillAlways&&this.fill();return}const e=this.player();this.trigger("beforemodalopen"),this.opened_=!0,(this.options_.fillAlways||!this.hasBeenOpened_&&!this.hasBeenFilled_)&&this.fill(),this.wasPlaying_=!e.paused(),this.options_.pauseOnOpen&&this.wasPlaying_&&e.pause(),this.on("keydown",this.handleKeyDown_),this.hadControls_=e.controls(),e.controls(!1),this.show(),this.conditionalFocus_(),this.el().setAttribute("aria-hidden","false"),this.trigger("modalopen"),this.hasBeenOpened_=!0}opened(e){return typeof e=="boolean"&&this[e?"open":"close"](),this.opened_}close(){if(!this.opened_)return;const e=this.player();this.trigger("beforemodalclose"),this.opened_=!1,this.wasPlaying_&&this.options_.pauseOnOpen&&e.play(),this.off("keydown",this.handleKeyDown_),this.hadControls_&&e.controls(!0),this.hide(),this.el().setAttribute("aria-hidden","true"),this.trigger({type:"modalclose",bubbles:!0}),this.conditionalBlur_(),this.options_.temporary&&this.dispose()}closeable(e){if(typeof e=="boolean"){const t=this.closeable_=!!e;let n=this.getChild("closeButton");if(t&&!n){const s=this.contentEl_;this.contentEl_=this.el_,n=this.addChild("closeButton",{controlText:"Close Modal Dialog"}),this.contentEl_=s,this.on(n,"close",this.close_)}!t&&n&&(this.off(n,"close",this.close_),this.removeChild(n),n.dispose())}return this.closeable_}fill(){this.fillWith(this.content())}fillWith(e){const t=this.contentEl(),n=t.parentNode,s=t.nextSibling;this.trigger("beforemodalfill"),this.hasBeenFilled_=!0,n.removeChild(t),this.empty(),$h(t,e),this.trigger("modalfill"),s?n.insertBefore(t,s):n.appendChild(t);const r=this.getChild("closeButton");r&&n.appendChild(r.el_),this.trigger("aftermodalfill")}empty(){this.trigger("beforemodalempty"),Gr(this.contentEl()),this.trigger("modalempty")}content(e){return typeof e<"u"&&(this.content_=e),this.content_}conditionalFocus_(){const e=G.activeElement,t=this.player_.el_;this.previouslyActiveEl_=null,(t.contains(e)||t===e)&&(this.previouslyActiveEl_=e,this.focus())}conditionalBlur_(){this.previouslyActiveEl_&&(this.previouslyActiveEl_.focus(),this.previouslyActiveEl_=null)}handleKeyDown(e){if(this.trigger({type:"modalKeydown",originalEvent:e,target:this,bubbles:!0}),e.stopPropagation(),e.key==="Escape"&&this.closeable()){e.preventDefault(),this.close();return}if(e.key!=="Tab")return;const t=this.focusableEls_(),n=this.el_.querySelector(":focus");let s;for(let r=0;r<t.length;r++)if(n===t[r]){s=r;break}G.activeElement===this.el_&&(s=0),e.shiftKey&&s===0?(t[t.length-1].focus(),e.preventDefault()):!e.shiftKey&&s===t.length-1&&(t[0].focus(),e.preventDefault())}focusableEls_(){const e=this.el_.querySelectorAll("*");return Array.prototype.filter.call(e,t=>(t instanceof x.HTMLAnchorElement||t instanceof x.HTMLAreaElement)&&t.hasAttribute("href")||(t instanceof x.HTMLInputElement||t instanceof x.HTMLSelectElement||t instanceof x.HTMLTextAreaElement||t instanceof x.HTMLButtonElement)&&!t.hasAttribute("disabled")||t instanceof x.HTMLIFrameElement||t instanceof x.HTMLObjectElement||t instanceof x.HTMLEmbedElement||t.hasAttribute("tabindex")&&t.getAttribute("tabindex")!==-1||t.hasAttribute("contenteditable"))}}Cn.prototype.options_={pauseOnOpen:!0,temporary:!0};H.registerComponent("ModalDialog",Cn);class Tn extends St{constructor(e=[]){super(),this.tracks_=[],Object.defineProperty(this,"length",{get(){return this.tracks_.length}});for(let t=0;t<e.length;t++)this.addTrack(e[t])}addTrack(e){const t=this.tracks_.length;""+t in this||Object.defineProperty(this,t,{get(){return this.tracks_[t]}}),this.tracks_.indexOf(e)===-1&&(this.tracks_.push(e),this.trigger({track:e,type:"addtrack",target:this})),e.labelchange_=()=>{this.trigger({track:e,type:"labelchange",target:this})},si(e)&&e.addEventListener("labelchange",e.labelchange_)}removeTrack(e){let t;for(let n=0,s=this.length;n<s;n++)if(this[n]===e){t=this[n],t.off&&t.off(),this.tracks_.splice(n,1);break}t&&this.trigger({track:t,type:"removetrack",target:this})}getTrackById(e){let t=null;for(let n=0,s=this.length;n<s;n++){const r=this[n];if(r.id===e){t=r;break}}return t}}Tn.prototype.allowedEvents_={change:"change",addtrack:"addtrack",removetrack:"removetrack",labelchange:"labelchange"};for(const i in Tn.prototype.allowedEvents_)Tn.prototype["on"+i]=null;const Ma=function(i,e){for(let t=0;t<i.length;t++)!Object.keys(i[t]).length||e.id===i[t].id||(i[t].enabled=!1)};class V1 extends Tn{constructor(e=[]){for(let t=e.length-1;t>=0;t--)if(e[t].enabled){Ma(e,e[t]);break}super(e),this.changing_=!1}addTrack(e){e.enabled&&Ma(this,e),super.addTrack(e),e.addEventListener&&(e.enabledChange_=()=>{this.changing_||(this.changing_=!0,Ma(this,e),this.changing_=!1,this.trigger("change"))},e.addEventListener("enabledchange",e.enabledChange_))}removeTrack(e){super.removeTrack(e),e.removeEventListener&&e.enabledChange_&&(e.removeEventListener("enabledchange",e.enabledChange_),e.enabledChange_=null)}}const Ra=function(i,e){for(let t=0;t<i.length;t++)!Object.keys(i[t]).length||e.id===i[t].id||(i[t].selected=!1)};class H1 extends Tn{constructor(e=[]){for(let t=e.length-1;t>=0;t--)if(e[t].selected){Ra(e,e[t]);break}super(e),this.changing_=!1,Object.defineProperty(this,"selectedIndex",{get(){for(let t=0;t<this.length;t++)if(this[t].selected)return t;return-1},set(){}})}addTrack(e){e.selected&&Ra(this,e),super.addTrack(e),e.addEventListener&&(e.selectedChange_=()=>{this.changing_||(this.changing_=!0,Ra(this,e),this.changing_=!1,this.trigger("change"))},e.addEventListener("selectedchange",e.selectedChange_))}removeTrack(e){super.removeTrack(e),e.removeEventListener&&e.selectedChange_&&(e.removeEventListener("selectedchange",e.selectedChange_),e.selectedChange_=null)}}class nc extends Tn{addTrack(e){super.addTrack(e),this.queueChange_||(this.queueChange_=()=>this.queueTrigger("change")),this.triggerSelectedlanguagechange||(this.triggerSelectedlanguagechange_=()=>this.trigger("selectedlanguagechange")),e.addEventListener("modechange",this.queueChange_),["metadata","chapters"].indexOf(e.kind)===-1&&e.addEventListener("modechange",this.triggerSelectedlanguagechange_)}removeTrack(e){super.removeTrack(e),e.removeEventListener&&(this.queueChange_&&e.removeEventListener("modechange",this.queueChange_),this.selectedlanguagechange_&&e.removeEventListener("modechange",this.triggerSelectedlanguagechange_))}}class z1{constructor(e=[]){this.trackElements_=[],Object.defineProperty(this,"length",{get(){return this.trackElements_.length}});for(let t=0,n=e.length;t<n;t++)this.addTrackElement_(e[t])}addTrackElement_(e){const t=this.trackElements_.length;""+t in this||Object.defineProperty(this,t,{get(){return this.trackElements_[t]}}),this.trackElements_.indexOf(e)===-1&&this.trackElements_.push(e)}getTrackElementByTrack_(e){let t;for(let n=0,s=this.trackElements_.length;n<s;n++)if(e===this.trackElements_[n].track){t=this.trackElements_[n];break}return t}removeTrackElement_(e){for(let t=0,n=this.trackElements_.length;t<n;t++)if(e===this.trackElements_[t]){this.trackElements_[t].track&&typeof this.trackElements_[t].track.off=="function"&&this.trackElements_[t].track.off(),typeof this.trackElements_[t].off=="function"&&this.trackElements_[t].off(),this.trackElements_.splice(t,1);break}}}class yr{constructor(e){yr.prototype.setCues_.call(this,e),Object.defineProperty(this,"length",{get(){return this.length_}})}setCues_(e){const t=this.length||0;let n=0;const s=e.length;this.cues_=e,this.length_=e.length;const r=function(a){""+a in this||Object.defineProperty(this,""+a,{get(){return this.cues_[a]}})};if(t<s)for(n=t;n<s;n++)r.call(this,n)}getCueById(e){let t=null;for(let n=0,s=this.length;n<s;n++){const r=this[n];if(r.id===e){t=r;break}}return t}}const W1={alternative:"alternative",captions:"captions",main:"main",sign:"sign",subtitles:"subtitles",commentary:"commentary"},G1={alternative:"alternative",descriptions:"descriptions",main:"main","main-desc":"main-desc",translation:"translation",commentary:"commentary"},X1={subtitles:"subtitles",captions:"captions",descriptions:"descriptions",chapters:"chapters",metadata:"metadata"},Bu={disabled:"disabled",hidden:"hidden",showing:"showing"};class Ho extends St{constructor(e={}){super();const t={id:e.id||"vjs_track_"+At(),kind:e.kind||"",language:e.language||""};let n=e.label||"";for(const s in t)Object.defineProperty(this,s,{get(){return t[s]},set(){}});Object.defineProperty(this,"label",{get(){return n},set(s){s!==n&&(n=s,this.trigger("labelchange"))}})}}const zo=function(i){return new URL(i,G.baseURI)},sc=function(i){return new URL(i,G.baseURI).href},Wo=function(i){if(typeof i=="string"){const e=/^(\/?)([\s\S]*?)((?:\.{1,2}|[^\/]+?)(\.([^\.\/\?]+)))(?:[\/]*|[\?].*)$/.exec(i);if(e)return e.pop().toLowerCase()}return""},Qr=function(i,e=x.location){return zo(i).origin!==e.origin};var K1=Object.freeze({__proto__:null,parseUrl:zo,getAbsoluteURL:sc,getFileExtension:Wo,isCrossOrigin:Qr});const Fu=function(i,e){const t=new x.WebVTT.Parser(x,x.vttjs,x.WebVTT.StringDecoder()),n=[];t.oncue=function(s){e.addCue(s)},t.onparsingerror=function(s){n.push(s)},t.onflush=function(){e.trigger({type:"loadeddata",target:e})},t.parse(i),n.length>0&&(x.console&&x.console.groupCollapsed&&x.console.groupCollapsed(`Text Track parsing errors for ${e.src}`),n.forEach(s=>oe.error(s)),x.console&&x.console.groupEnd&&x.console.groupEnd()),t.flush()},ju=function(i,e){const t={uri:i},n=Qr(i);n&&(t.cors=n);const s=e.tech_.crossOrigin()==="use-credentials";s&&(t.withCredentials=s),Zd(t,Ce(this,function(r,a,l){if(r)return oe.error(r,a);e.loaded_=!0,typeof x.WebVTT!="function"?e.tech_&&e.tech_.any(["vttjsloaded","vttjserror"],c=>{if(c.type==="vttjserror"){oe.error(`vttjs failed to load, stopping trying to process ${e.src}`);return}return Fu(l,e)}):Fu(l,e)}))};class _s extends Ho{constructor(e={}){if(!e.tech)throw new Error("A tech was not provided.");const t=ve(e,{kind:X1[e.kind]||"subtitles",language:e.language||e.srclang||""});let n=Bu[t.mode]||"disabled";const s=t.default;(t.kind==="metadata"||t.kind==="chapters")&&(n="hidden"),super(t),this.tech_=t.tech,this.cues_=[],this.activeCues_=[],this.preload_=this.tech_.preloadTextTracks!==!1;const r=new yr(this.cues_),a=new yr(this.activeCues_);let l=!1;this.timeupdateHandler=Ce(this,function(f={}){if(!this.tech_.isDisposed()){if(!this.tech_.isReady_){f.type!=="timeupdate"&&(this.rvf_=this.tech_.requestVideoFrameCallback(this.timeupdateHandler));return}this.activeCues=this.activeCues,l&&(this.trigger("cuechange"),l=!1),f.type!=="timeupdate"&&(this.rvf_=this.tech_.requestVideoFrameCallback(this.timeupdateHandler))}});const c=()=>{this.stopTracking()};this.tech_.one("dispose",c),n!=="disabled"&&this.startTracking(),Object.defineProperties(this,{default:{get(){return s},set(){}},mode:{get(){return n},set(f){Bu[f]&&n!==f&&(n=f,!this.preload_&&n!=="disabled"&&this.cues.length===0&&ju(this.src,this),this.stopTracking(),n!=="disabled"&&this.startTracking(),this.trigger("modechange"))}},cues:{get(){return this.loaded_?r:null},set(){}},activeCues:{get(){if(!this.loaded_)return null;if(this.cues.length===0)return a;const f=this.tech_.currentTime(),m=[];for(let b=0,C=this.cues.length;b<C;b++){const w=this.cues[b];w.startTime<=f&&w.endTime>=f&&m.push(w)}if(l=!1,m.length!==this.activeCues_.length)l=!0;else for(let b=0;b<m.length;b++)this.activeCues_.indexOf(m[b])===-1&&(l=!0);return this.activeCues_=m,a.setCues_(this.activeCues_),a},set(){}}}),t.src?(this.src=t.src,this.preload_||(this.loaded_=!0),(this.preload_||t.kind!=="subtitles"&&t.kind!=="captions")&&ju(this.src,this)):this.loaded_=!0}startTracking(){this.rvf_=this.tech_.requestVideoFrameCallback(this.timeupdateHandler),this.tech_.on("timeupdate",this.timeupdateHandler)}stopTracking(){this.rvf_&&(this.tech_.cancelVideoFrameCallback(this.rvf_),this.rvf_=void 0),this.tech_.off("timeupdate",this.timeupdateHandler)}addCue(e){let t=e;if(!("getCueAsHTML"in t)){t=new x.vttjs.VTTCue(e.startTime,e.endTime,e.text);for(const s in e)s in t||(t[s]=e[s]);t.id=e.id,t.originalCue_=e}const n=this.tech_.textTracks();for(let s=0;s<n.length;s++)n[s]!==this&&n[s].removeCue(t);this.cues_.push(t),this.cues.setCues_(this.cues_)}removeCue(e){let t=this.cues_.length;for(;t--;){const n=this.cues_[t];if(n===e||n.originalCue_&&n.originalCue_===e){this.cues_.splice(t,1),this.cues.setCues_(this.cues_);break}}}}_s.prototype.allowedEvents_={cuechange:"cuechange"};class rc extends Ho{constructor(e={}){const t=ve(e,{kind:G1[e.kind]||""});super(t);let n=!1;Object.defineProperty(this,"enabled",{get(){return n},set(s){typeof s!="boolean"||s===n||(n=s,this.trigger("enabledchange"))}}),t.enabled&&(this.enabled=t.enabled),this.loaded_=!0}}class ac extends Ho{constructor(e={}){const t=ve(e,{kind:W1[e.kind]||""});super(t);let n=!1;Object.defineProperty(this,"selected",{get(){return n},set(s){typeof s!="boolean"||s===n||(n=s,this.trigger("selectedchange"))}}),t.selected&&(this.selected=t.selected)}}class ai extends St{constructor(e={}){super();let t;const n=new _s(e);this.kind=n.kind,this.src=n.src,this.srclang=n.language,this.label=n.label,this.default=n.default,Object.defineProperties(this,{readyState:{get(){return t}},track:{get(){return n}}}),t=ai.NONE,n.addEventListener("loadeddata",()=>{t=ai.LOADED,this.trigger({type:"load",target:this})})}}ai.prototype.allowedEvents_={load:"load"};ai.NONE=0;ai.LOADING=1;ai.LOADED=2;ai.ERROR=3;const xt={audio:{ListClass:V1,TrackClass:rc,capitalName:"Audio"},video:{ListClass:H1,TrackClass:ac,capitalName:"Video"},text:{ListClass:nc,TrackClass:_s,capitalName:"Text"}};Object.keys(xt).forEach(function(i){xt[i].getterName=`${i}Tracks`,xt[i].privateName=`${i}Tracks_`});const vn={remoteText:{ListClass:nc,TrackClass:_s,capitalName:"RemoteText",getterName:"remoteTextTracks",privateName:"remoteTextTracks_"},remoteTextEl:{ListClass:z1,TrackClass:ai,capitalName:"RemoteTextTrackEls",getterName:"remoteTextTrackEls",privateName:"remoteTextTrackEls_"}},at=Object.assign({},xt,vn);vn.names=Object.keys(vn);xt.names=Object.keys(xt);at.names=[].concat(vn.names).concat(xt.names);function Y1(i,e,t,n,s={}){const r=i.textTracks();s.kind=e,t&&(s.label=t),n&&(s.language=n),s.tech=i;const a=new at.text.TrackClass(s);return r.addTrack(a),a}class ae extends H{constructor(e={},t=function(){}){e.reportTouchActivity=!1,super(null,e,t),this.onDurationChange_=n=>this.onDurationChange(n),this.trackProgress_=n=>this.trackProgress(n),this.trackCurrentTime_=n=>this.trackCurrentTime(n),this.stopTrackingCurrentTime_=n=>this.stopTrackingCurrentTime(n),this.disposeSourceHandler_=n=>this.disposeSourceHandler(n),this.queuedHanders_=new Set,this.hasStarted_=!1,this.on("playing",function(){this.hasStarted_=!0}),this.on("loadstart",function(){this.hasStarted_=!1}),at.names.forEach(n=>{const s=at[n];e&&e[s.getterName]&&(this[s.privateName]=e[s.getterName])}),this.featuresProgressEvents||this.manualProgressOn(),this.featuresTimeupdateEvents||this.manualTimeUpdatesOn(),["Text","Audio","Video"].forEach(n=>{e[`native${n}Tracks`]===!1&&(this[`featuresNative${n}Tracks`]=!1)}),e.nativeCaptions===!1||e.nativeTextTracks===!1?this.featuresNativeTextTracks=!1:(e.nativeCaptions===!0||e.nativeTextTracks===!0)&&(this.featuresNativeTextTracks=!0),this.featuresNativeTextTracks||this.emulateTextTracks(),this.preloadTextTracks=e.preloadTextTracks!==!1,this.autoRemoteTextTracks_=new at.text.ListClass,this.initTrackListeners(),e.nativeControlsForTouch||this.emitTapEvents(),this.constructor&&(this.name_=this.constructor.name||"Unknown Tech")}triggerSourceset(e){this.isReady_||this.one("ready",()=>this.setTimeout(()=>this.triggerSourceset(e),1)),this.trigger({src:e,type:"sourceset"})}manualProgressOn(){this.on("durationchange",this.onDurationChange_),this.manualProgress=!0,this.one("ready",this.trackProgress_)}manualProgressOff(){this.manualProgress=!1,this.stopTrackingProgress(),this.off("durationchange",this.onDurationChange_)}trackProgress(e){this.stopTrackingProgress(),this.progressInterval=this.setInterval(Ce(this,function(){const t=this.bufferedPercent();this.bufferedPercent_!==t&&this.trigger("progress"),this.bufferedPercent_=t,t===1&&this.stopTrackingProgress()}),500)}onDurationChange(e){this.duration_=this.duration()}buffered(){return Ut(0,0)}bufferedPercent(){return ic(this.buffered(),this.duration_)}stopTrackingProgress(){this.clearInterval(this.progressInterval)}manualTimeUpdatesOn(){this.manualTimeUpdates=!0,this.on("play",this.trackCurrentTime_),this.on("pause",this.stopTrackingCurrentTime_)}manualTimeUpdatesOff(){this.manualTimeUpdates=!1,this.stopTrackingCurrentTime(),this.off("play",this.trackCurrentTime_),this.off("pause",this.stopTrackingCurrentTime_)}trackCurrentTime(){this.currentTimeInterval&&this.stopTrackingCurrentTime(),this.currentTimeInterval=this.setInterval(function(){this.trigger({type:"timeupdate",target:this,manuallyTriggered:!0})},250)}stopTrackingCurrentTime(){this.clearInterval(this.currentTimeInterval),this.trigger({type:"timeupdate",target:this,manuallyTriggered:!0})}dispose(){this.clearTracks(xt.names),this.manualProgress&&this.manualProgressOff(),this.manualTimeUpdates&&this.manualTimeUpdatesOff(),super.dispose()}clearTracks(e){e=[].concat(e),e.forEach(t=>{const n=this[`${t}Tracks`]()||[];let s=n.length;for(;s--;){const r=n[s];t==="text"&&this.removeRemoteTextTrack(r),n.removeTrack(r)}})}cleanupAutoTextTracks(){const e=this.autoRemoteTextTracks_||[];let t=e.length;for(;t--;){const n=e[t];this.removeRemoteTextTrack(n)}}reset(){}crossOrigin(){}setCrossOrigin(){}error(e){return e!==void 0&&(this.error_=new Me(e),this.trigger("error")),this.error_}played(){return this.hasStarted_?Ut(0,0):Ut()}play(){}setScrubbing(e){}scrubbing(){}setCurrentTime(e){this.manualTimeUpdates&&this.trigger({type:"timeupdate",target:this,manuallyTriggered:!0})}initTrackListeners(){xt.names.forEach(e=>{const t=xt[e],n=()=>{this.trigger(`${e}trackchange`)},s=this[t.getterName]();s.addEventListener("removetrack",n),s.addEventListener("addtrack",n),this.on("dispose",()=>{s.removeEventListener("removetrack",n),s.removeEventListener("addtrack",n)})})}addWebVttScript_(){if(!x.WebVTT)if(G.body.contains(this.el())){if(!this.options_["vtt.js"]&&mn(yu)&&Object.keys(yu).length>0){this.trigger("vttjsloaded");return}const e=G.createElement("script");e.src=this.options_["vtt.js"]||"https://vjs.zencdn.net/vttjs/0.14.1/vtt.min.js",e.onload=()=>{this.trigger("vttjsloaded")},e.onerror=()=>{this.trigger("vttjserror")},this.on("dispose",()=>{e.onload=null,e.onerror=null}),x.WebVTT=!0,this.el().parentNode.appendChild(e)}else this.ready(this.addWebVttScript_)}emulateTextTracks(){const e=this.textTracks(),t=this.remoteTextTracks(),n=l=>e.addTrack(l.track),s=l=>e.removeTrack(l.track);t.on("addtrack",n),t.on("removetrack",s),this.addWebVttScript_();const r=()=>this.trigger("texttrackchange"),a=()=>{r();for(let l=0;l<e.length;l++){const c=e[l];c.removeEventListener("cuechange",r),c.mode==="showing"&&c.addEventListener("cuechange",r)}};a(),e.addEventListener("change",a),e.addEventListener("addtrack",a),e.addEventListener("removetrack",a),this.on("dispose",function(){t.off("addtrack",n),t.off("removetrack",s),e.removeEventListener("change",a),e.removeEventListener("addtrack",a),e.removeEventListener("removetrack",a);for(let l=0;l<e.length;l++)e[l].removeEventListener("cuechange",r)})}addTextTrack(e,t,n){if(!e)throw new Error("TextTrack kind is required but was not provided");return Y1(this,e,t,n)}createRemoteTextTrack(e){const t=ve(e,{tech:this});return new vn.remoteTextEl.TrackClass(t)}addRemoteTextTrack(e={},t){const n=this.createRemoteTextTrack(e);return typeof t!="boolean"&&(t=!1),this.remoteTextTrackEls().addTrackElement_(n),this.remoteTextTracks().addTrack(n.track),t===!1&&this.ready(()=>this.autoRemoteTextTracks_.addTrack(n.track)),n}removeRemoteTextTrack(e){const t=this.remoteTextTrackEls().getTrackElementByTrack_(e);this.remoteTextTrackEls().removeTrackElement_(t),this.remoteTextTracks().removeTrack(e),this.autoRemoteTextTracks_.removeTrack(e)}getVideoPlaybackQuality(){return{}}requestPictureInPicture(){return Promise.reject()}disablePictureInPicture(){return!0}setDisablePictureInPicture(){}requestVideoFrameCallback(e){const t=At();return!this.isReady_||this.paused()?(this.queuedHanders_.add(t),this.one("playing",()=>{this.queuedHanders_.has(t)&&(this.queuedHanders_.delete(t),e())})):this.requestNamedAnimationFrame(t,e),t}cancelVideoFrameCallback(e){this.queuedHanders_.has(e)?this.queuedHanders_.delete(e):this.cancelNamedAnimationFrame(e)}setPoster(){}playsinline(){}setPlaysinline(){}overrideNativeAudioTracks(e){}overrideNativeVideoTracks(e){}canPlayType(e){return""}static canPlayType(e){return""}static canPlaySource(e,t){return ae.canPlayType(e.type)}static isTech(e){return e.prototype instanceof ae||e instanceof ae||e===ae}static registerTech(e,t){if(ae.techs_||(ae.techs_={}),!ae.isTech(t))throw new Error(`Tech ${e} must be a Tech`);if(!ae.canPlayType)throw new Error("Techs must have a static canPlayType method on them");if(!ae.canPlaySource)throw new Error("Techs must have a static canPlaySource method on them");return e=Ne(e),ae.techs_[e]=t,ae.techs_[ls(e)]=t,e!=="Tech"&&ae.defaultTechOrder_.push(e),t}static getTech(e){if(e){if(ae.techs_&&ae.techs_[e])return ae.techs_[e];if(e=Ne(e),x&&x.videojs&&x.videojs[e])return oe.warn(`The ${e} tech was added to the videojs object when it should be registered using videojs.registerTech(name, tech)`),x.videojs[e]}}}at.names.forEach(function(i){const e=at[i];ae.prototype[e.getterName]=function(){return this[e.privateName]=this[e.privateName]||new e.ListClass,this[e.privateName]}});ae.prototype.featuresVolumeControl=!0;ae.prototype.featuresMuteControl=!0;ae.prototype.featuresFullscreenResize=!1;ae.prototype.featuresPlaybackRate=!1;ae.prototype.featuresProgressEvents=!1;ae.prototype.featuresSourceset=!1;ae.prototype.featuresTimeupdateEvents=!1;ae.prototype.featuresNativeTextTracks=!1;ae.prototype.featuresVideoFrameCallback=!1;ae.withSourceHandlers=function(i){i.registerSourceHandler=function(e,t){let n=i.sourceHandlers;n||(n=i.sourceHandlers=[]),t===void 0&&(t=n.length),n.splice(t,0,e)},i.canPlayType=function(e){const t=i.sourceHandlers||[];let n;for(let s=0;s<t.length;s++)if(n=t[s].canPlayType(e),n)return n;return""},i.selectSourceHandler=function(e,t){const n=i.sourceHandlers||[];let s;for(let r=0;r<n.length;r++)if(s=n[r].canHandleSource(e,t),s)return n[r];return null},i.canPlaySource=function(e,t){const n=i.selectSourceHandler(e,t);return n?n.canHandleSource(e,t):""},["seekable","seeking","duration"].forEach(function(e){const t=this[e];typeof t=="function"&&(this[e]=function(){return this.sourceHandler_&&this.sourceHandler_[e]?this.sourceHandler_[e].apply(this.sourceHandler_,arguments):t.apply(this,arguments)})},i.prototype),i.prototype.setSource=function(e){let t=i.selectSourceHandler(e,this.options_);t||(i.nativeSourceHandler?t=i.nativeSourceHandler:oe.error("No source handler found for the current source.")),this.disposeSourceHandler(),this.off("dispose",this.disposeSourceHandler_),t!==i.nativeSourceHandler&&(this.currentSource_=e),this.sourceHandler_=t.handleSource(e,this,this.options_),this.one("dispose",this.disposeSourceHandler_)},i.prototype.disposeSourceHandler=function(){this.currentSource_&&(this.clearTracks(["audio","video"]),this.currentSource_=null),this.cleanupAutoTextTracks(),this.sourceHandler_&&(this.sourceHandler_.dispose&&this.sourceHandler_.dispose(),this.sourceHandler_=null)}};H.registerComponent("Tech",ae);ae.registerTech("Tech",ae);ae.defaultTechOrder_=[];const Fi={},_r={},br={};function Q1(i,e){Fi[i]=Fi[i]||[],Fi[i].push(e)}function J1(i,e,t){i.setTimeout(()=>Oi(e,Fi[e.type],t,i),1)}function Z1(i,e){i.forEach(t=>t.setTech&&t.setTech(e))}function eb(i,e,t){return i.reduceRight(Go(t),e[t]())}function tb(i,e,t,n){return e[t](i.reduce(Go(t),n))}function $u(i,e,t,n=null){const s="call"+Ne(t),r=i.reduce(Go(s),n),a=r===br,l=a?null:e[t](r);return sb(i,t,l,a),l}const ib={buffered:1,currentTime:1,duration:1,muted:1,played:1,paused:1,seekable:1,volume:1,ended:1},nb={setCurrentTime:1,setMuted:1,setVolume:1},qu={play:1,pause:1};function Go(i){return(e,t)=>e===br?br:t[i]?t[i](e):e}function sb(i,e,t,n){for(let s=i.length-1;s>=0;s--){const r=i[s];r[e]&&r[e](n,t)}}function rb(i){_r.hasOwnProperty(i.id())&&delete _r[i.id()]}function ab(i,e){const t=_r[i.id()];let n=null;if(t==null)return n=e(i),_r[i.id()]=[[e,n]],n;for(let s=0;s<t.length;s++){const[r,a]=t[s];r===e&&(n=a)}return n===null&&(n=e(i),t.push([e,n])),n}function Oi(i={},e=[],t,n,s=[],r=!1){const[a,...l]=e;if(typeof a=="string")Oi(i,Fi[a],t,n,s,r);else if(a){const c=ab(n,a);if(!c.setSource)return s.push(c),Oi(i,l,t,n,s,r);c.setSource(Object.assign({},i),function(f,m){if(f)return Oi(i,l,t,n,s,r);s.push(c),Oi(m,i.type===m.type?l:Fi[m.type],t,n,s,r)})}else l.length?Oi(i,l,t,n,s,r):r?t(i,s):Oi(i,Fi["*"],t,n,s,!0)}const ob={opus:"video/ogg",ogv:"video/ogg",mp4:"video/mp4",mov:"video/mp4",m4v:"video/mp4",mkv:"video/x-matroska",m4a:"audio/mp4",mp3:"audio/mpeg",aac:"audio/aac",caf:"audio/x-caf",flac:"audio/flac",oga:"audio/ogg",wav:"audio/wav",m3u8:"application/x-mpegURL",mpd:"application/dash+xml",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",png:"image/png",svg:"image/svg+xml",webp:"image/webp"},Tr=function(i=""){const e=Wo(i);return ob[e.toLowerCase()]||""},lb=(i,e)=>{if(!e)return"";if(i.cache_.source.src===e&&i.cache_.source.type)return i.cache_.source.type;const t=i.cache_.sources.filter(s=>s.src===e);if(t.length)return t[0].type;const n=i.$$("source");for(let s=0;s<n.length;s++){const r=n[s];if(r.type&&r.src&&r.src===e)return r.type}return Tr(e)},oc=function(i){if(Array.isArray(i)){let e=[];i.forEach(function(t){t=oc(t),Array.isArray(t)?e=e.concat(t):Qt(t)&&e.push(t)}),i=e}else typeof i=="string"&&i.trim()?i=[Vu({src:i})]:Qt(i)&&typeof i.src=="string"&&i.src&&i.src.trim()?i=[Vu(i)]:i=[];return i};function Vu(i){if(!i.type){const e=Tr(i.src);e&&(i.type=e)}return i}var ub=`<svg xmlns="http://www.w3.org/2000/svg">
|
|
23
|
+
`))this.trigger("data",this.buffer.substring(0,t)),this.buffer=this.buffer.substring(t+1)}}const Fy=" ",Pa=function(s){const e=/([0-9.]*)?@?([0-9.]*)?/.exec(s||""),t={};return e[1]&&(t.length=parseInt(e[1],10)),e[2]&&(t.offset=parseInt(e[2],10)),t},$y=function(){const t="(?:"+"[^=]*"+")=(?:"+'"[^"]*"|[^,]*'+")";return new RegExp("(?:^|,)("+t+")")},st=function(s){const e={};if(!s)return e;const t=s.split($y());let i=t.length,n;for(;i--;)t[i]!==""&&(n=/([^=]*)=(.*)/.exec(t[i]).slice(1),n[0]=n[0].replace(/^\s+|\s+$/g,""),n[1]=n[1].replace(/^\s+|\s+$/g,""),n[1]=n[1].replace(/^['"](.*)['"]$/g,"$1"),e[n[0]]=n[1]);return e},Tu=s=>{const e=s.split("x"),t={};return e[0]&&(t.width=parseInt(e[0],10)),e[1]&&(t.height=parseInt(e[1],10)),t};class jy extends Io{constructor(){super(),this.customParsers=[],this.tagMappers=[]}push(e){let t,i;if(e=e.trim(),e.length===0)return;if(e[0]!=="#"){this.trigger("data",{type:"uri",uri:e});return}this.tagMappers.reduce((r,a)=>{const l=a(e);return l===e?r:r.concat([l])},[e]).forEach(r=>{for(let a=0;a<this.customParsers.length;a++)if(this.customParsers[a].call(this,r))return;if(r.indexOf("#EXT")!==0){this.trigger("data",{type:"comment",text:r.slice(1)});return}if(r=r.replace("\r",""),t=/^#EXTM3U/.exec(r),t){this.trigger("data",{type:"tag",tagType:"m3u"});return}if(t=/^#EXTINF:([0-9\.]*)?,?(.*)?$/.exec(r),t){i={type:"tag",tagType:"inf"},t[1]&&(i.duration=parseFloat(t[1])),t[2]&&(i.title=t[2]),this.trigger("data",i);return}if(t=/^#EXT-X-TARGETDURATION:([0-9.]*)?/.exec(r),t){i={type:"tag",tagType:"targetduration"},t[1]&&(i.duration=parseInt(t[1],10)),this.trigger("data",i);return}if(t=/^#EXT-X-VERSION:([0-9.]*)?/.exec(r),t){i={type:"tag",tagType:"version"},t[1]&&(i.version=parseInt(t[1],10)),this.trigger("data",i);return}if(t=/^#EXT-X-MEDIA-SEQUENCE:(\-?[0-9.]*)?/.exec(r),t){i={type:"tag",tagType:"media-sequence"},t[1]&&(i.number=parseInt(t[1],10)),this.trigger("data",i);return}if(t=/^#EXT-X-DISCONTINUITY-SEQUENCE:(\-?[0-9.]*)?/.exec(r),t){i={type:"tag",tagType:"discontinuity-sequence"},t[1]&&(i.number=parseInt(t[1],10)),this.trigger("data",i);return}if(t=/^#EXT-X-PLAYLIST-TYPE:(.*)?$/.exec(r),t){i={type:"tag",tagType:"playlist-type"},t[1]&&(i.playlistType=t[1]),this.trigger("data",i);return}if(t=/^#EXT-X-BYTERANGE:(.*)?$/.exec(r),t){i=je(Pa(t[1]),{type:"tag",tagType:"byterange"}),this.trigger("data",i);return}if(t=/^#EXT-X-ALLOW-CACHE:(YES|NO)?/.exec(r),t){i={type:"tag",tagType:"allow-cache"},t[1]&&(i.allowed=!/NO/.test(t[1])),this.trigger("data",i);return}if(t=/^#EXT-X-MAP:(.*)$/.exec(r),t){if(i={type:"tag",tagType:"map"},t[1]){const a=st(t[1]);a.URI&&(i.uri=a.URI),a.BYTERANGE&&(i.byterange=Pa(a.BYTERANGE))}this.trigger("data",i);return}if(t=/^#EXT-X-STREAM-INF:(.*)$/.exec(r),t){i={type:"tag",tagType:"stream-inf"},t[1]&&(i.attributes=st(t[1]),i.attributes.RESOLUTION&&(i.attributes.RESOLUTION=Tu(i.attributes.RESOLUTION)),i.attributes.BANDWIDTH&&(i.attributes.BANDWIDTH=parseInt(i.attributes.BANDWIDTH,10)),i.attributes["FRAME-RATE"]&&(i.attributes["FRAME-RATE"]=parseFloat(i.attributes["FRAME-RATE"])),i.attributes["PROGRAM-ID"]&&(i.attributes["PROGRAM-ID"]=parseInt(i.attributes["PROGRAM-ID"],10))),this.trigger("data",i);return}if(t=/^#EXT-X-MEDIA:(.*)$/.exec(r),t){i={type:"tag",tagType:"media"},t[1]&&(i.attributes=st(t[1])),this.trigger("data",i);return}if(t=/^#EXT-X-ENDLIST/.exec(r),t){this.trigger("data",{type:"tag",tagType:"endlist"});return}if(t=/^#EXT-X-DISCONTINUITY/.exec(r),t){this.trigger("data",{type:"tag",tagType:"discontinuity"});return}if(t=/^#EXT-X-PROGRAM-DATE-TIME:(.*)$/.exec(r),t){i={type:"tag",tagType:"program-date-time"},t[1]&&(i.dateTimeString=t[1],i.dateTimeObject=new Date(t[1])),this.trigger("data",i);return}if(t=/^#EXT-X-KEY:(.*)$/.exec(r),t){i={type:"tag",tagType:"key"},t[1]&&(i.attributes=st(t[1]),i.attributes.IV&&(i.attributes.IV.substring(0,2).toLowerCase()==="0x"&&(i.attributes.IV=i.attributes.IV.substring(2)),i.attributes.IV=i.attributes.IV.match(/.{8}/g),i.attributes.IV[0]=parseInt(i.attributes.IV[0],16),i.attributes.IV[1]=parseInt(i.attributes.IV[1],16),i.attributes.IV[2]=parseInt(i.attributes.IV[2],16),i.attributes.IV[3]=parseInt(i.attributes.IV[3],16),i.attributes.IV=new Uint32Array(i.attributes.IV))),this.trigger("data",i);return}if(t=/^#EXT-X-START:(.*)$/.exec(r),t){i={type:"tag",tagType:"start"},t[1]&&(i.attributes=st(t[1]),i.attributes["TIME-OFFSET"]=parseFloat(i.attributes["TIME-OFFSET"]),i.attributes.PRECISE=/YES/.test(i.attributes.PRECISE)),this.trigger("data",i);return}if(t=/^#EXT-X-CUE-OUT-CONT:(.*)?$/.exec(r),t){i={type:"tag",tagType:"cue-out-cont"},t[1]?i.data=t[1]:i.data="",this.trigger("data",i);return}if(t=/^#EXT-X-CUE-OUT:(.*)?$/.exec(r),t){i={type:"tag",tagType:"cue-out"},t[1]?i.data=t[1]:i.data="",this.trigger("data",i);return}if(t=/^#EXT-X-CUE-IN:?(.*)?$/.exec(r),t){i={type:"tag",tagType:"cue-in"},t[1]?i.data=t[1]:i.data="",this.trigger("data",i);return}if(t=/^#EXT-X-SKIP:(.*)$/.exec(r),t&&t[1]){i={type:"tag",tagType:"skip"},i.attributes=st(t[1]),i.attributes.hasOwnProperty("SKIPPED-SEGMENTS")&&(i.attributes["SKIPPED-SEGMENTS"]=parseInt(i.attributes["SKIPPED-SEGMENTS"],10)),i.attributes.hasOwnProperty("RECENTLY-REMOVED-DATERANGES")&&(i.attributes["RECENTLY-REMOVED-DATERANGES"]=i.attributes["RECENTLY-REMOVED-DATERANGES"].split(Fy)),this.trigger("data",i);return}if(t=/^#EXT-X-PART:(.*)$/.exec(r),t&&t[1]){i={type:"tag",tagType:"part"},i.attributes=st(t[1]),["DURATION"].forEach(function(a){i.attributes.hasOwnProperty(a)&&(i.attributes[a]=parseFloat(i.attributes[a]))}),["INDEPENDENT","GAP"].forEach(function(a){i.attributes.hasOwnProperty(a)&&(i.attributes[a]=/YES/.test(i.attributes[a]))}),i.attributes.hasOwnProperty("BYTERANGE")&&(i.attributes.byterange=Pa(i.attributes.BYTERANGE)),this.trigger("data",i);return}if(t=/^#EXT-X-SERVER-CONTROL:(.*)$/.exec(r),t&&t[1]){i={type:"tag",tagType:"server-control"},i.attributes=st(t[1]),["CAN-SKIP-UNTIL","PART-HOLD-BACK","HOLD-BACK"].forEach(function(a){i.attributes.hasOwnProperty(a)&&(i.attributes[a]=parseFloat(i.attributes[a]))}),["CAN-SKIP-DATERANGES","CAN-BLOCK-RELOAD"].forEach(function(a){i.attributes.hasOwnProperty(a)&&(i.attributes[a]=/YES/.test(i.attributes[a]))}),this.trigger("data",i);return}if(t=/^#EXT-X-PART-INF:(.*)$/.exec(r),t&&t[1]){i={type:"tag",tagType:"part-inf"},i.attributes=st(t[1]),["PART-TARGET"].forEach(function(a){i.attributes.hasOwnProperty(a)&&(i.attributes[a]=parseFloat(i.attributes[a]))}),this.trigger("data",i);return}if(t=/^#EXT-X-PRELOAD-HINT:(.*)$/.exec(r),t&&t[1]){i={type:"tag",tagType:"preload-hint"},i.attributes=st(t[1]),["BYTERANGE-START","BYTERANGE-LENGTH"].forEach(function(a){if(i.attributes.hasOwnProperty(a)){i.attributes[a]=parseInt(i.attributes[a],10);const l=a==="BYTERANGE-LENGTH"?"length":"offset";i.attributes.byterange=i.attributes.byterange||{},i.attributes.byterange[l]=i.attributes[a],delete i.attributes[a]}}),this.trigger("data",i);return}if(t=/^#EXT-X-RENDITION-REPORT:(.*)$/.exec(r),t&&t[1]){i={type:"tag",tagType:"rendition-report"},i.attributes=st(t[1]),["LAST-MSN","LAST-PART"].forEach(function(a){i.attributes.hasOwnProperty(a)&&(i.attributes[a]=parseInt(i.attributes[a],10))}),this.trigger("data",i);return}if(t=/^#EXT-X-DATERANGE:(.*)$/.exec(r),t&&t[1]){i={type:"tag",tagType:"daterange"},i.attributes=st(t[1]),["ID","CLASS"].forEach(function(l){i.attributes.hasOwnProperty(l)&&(i.attributes[l]=String(i.attributes[l]))}),["START-DATE","END-DATE"].forEach(function(l){i.attributes.hasOwnProperty(l)&&(i.attributes[l]=new Date(i.attributes[l]))}),["DURATION","PLANNED-DURATION"].forEach(function(l){i.attributes.hasOwnProperty(l)&&(i.attributes[l]=parseFloat(i.attributes[l]))}),["END-ON-NEXT"].forEach(function(l){i.attributes.hasOwnProperty(l)&&(i.attributes[l]=/YES/i.test(i.attributes[l]))}),["SCTE35-CMD"," SCTE35-OUT","SCTE35-IN"].forEach(function(l){i.attributes.hasOwnProperty(l)&&(i.attributes[l]=i.attributes[l].toString(16))});const a=/^X-([A-Z]+-)+[A-Z]+$/;for(const l in i.attributes){if(!a.test(l))continue;const h=/[0-9A-Fa-f]{6}/g.test(i.attributes[l]),f=/^\d+(\.\d+)?$/.test(i.attributes[l]);i.attributes[l]=h?i.attributes[l].toString(16):f?parseFloat(i.attributes[l]):String(i.attributes[l])}this.trigger("data",i);return}if(t=/^#EXT-X-INDEPENDENT-SEGMENTS/.exec(r),t){this.trigger("data",{type:"tag",tagType:"independent-segments"});return}if(t=/^#EXT-X-I-FRAMES-ONLY/.exec(r),t){this.trigger("data",{type:"tag",tagType:"i-frames-only"});return}if(t=/^#EXT-X-CONTENT-STEERING:(.*)$/.exec(r),t){i={type:"tag",tagType:"content-steering"},i.attributes=st(t[1]),this.trigger("data",i);return}if(t=/^#EXT-X-I-FRAME-STREAM-INF:(.*)$/.exec(r),t){i={type:"tag",tagType:"i-frame-playlist"},i.attributes=st(t[1]),i.attributes.URI&&(i.uri=i.attributes.URI),i.attributes.BANDWIDTH&&(i.attributes.BANDWIDTH=parseInt(i.attributes.BANDWIDTH,10)),i.attributes.RESOLUTION&&(i.attributes.RESOLUTION=Tu(i.attributes.RESOLUTION)),i.attributes["AVERAGE-BANDWIDTH"]&&(i.attributes["AVERAGE-BANDWIDTH"]=parseInt(i.attributes["AVERAGE-BANDWIDTH"],10)),i.attributes["FRAME-RATE"]&&(i.attributes["FRAME-RATE"]=parseFloat(i.attributes["FRAME-RATE"])),this.trigger("data",i);return}if(t=/^#EXT-X-DEFINE:(.*)$/.exec(r),t){i={type:"tag",tagType:"define"},i.attributes=st(t[1]),this.trigger("data",i);return}this.trigger("data",{type:"tag",data:r.slice(4)})})}addParser({expression:e,customType:t,dataParser:i,segment:n}){typeof i!="function"&&(i=r=>r),this.customParsers.push(r=>{if(e.exec(r))return this.trigger("data",{type:"custom",data:i(r),customType:t,segment:n}),!0})}addTagMapper({expression:e,map:t}){const i=n=>e.test(n)?t(n):n;this.tagMappers.push(i)}}const Vy=s=>s.toLowerCase().replace(/-(\w)/g,e=>e[1].toUpperCase()),yi=function(s){const e={};return Object.keys(s).forEach(function(t){e[Vy(t)]=s[t]}),e},Da=function(s){const{serverControl:e,targetDuration:t,partTargetDuration:i}=s;if(!e)return;const n="#EXT-X-SERVER-CONTROL",r="holdBack",a="partHoldBack",l=t&&t*3,h=i&&i*2;t&&!e.hasOwnProperty(r)&&(e[r]=l,this.trigger("info",{message:`${n} defaulting HOLD-BACK to targetDuration * 3 (${l}).`})),l&&e[r]<l&&(this.trigger("warn",{message:`${n} clamping HOLD-BACK (${e[r]}) to targetDuration * 3 (${l})`}),e[r]=l),i&&!e.hasOwnProperty(a)&&(e[a]=i*3,this.trigger("info",{message:`${n} defaulting PART-HOLD-BACK to partTargetDuration * 3 (${e[a]}).`})),i&&e[a]<h&&(this.trigger("warn",{message:`${n} clamping PART-HOLD-BACK (${e[a]}) to partTargetDuration * 2 (${h}).`}),e[a]=h)};class Hy extends Io{constructor(e={}){super(),this.lineStream=new By,this.parseStream=new jy,this.lineStream.pipe(this.parseStream),this.mainDefinitions=e.mainDefinitions||{},this.params=new URL(e.uri,"https://a.com").searchParams,this.lastProgramDateTime=null;const t=this,i=[];let n={},r,a,l=!1;const h=function(){},f={AUDIO:{},VIDEO:{},"CLOSED-CAPTIONS":{},SUBTITLES:{}},m="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";let T=0;this.manifest={allowCache:!0,discontinuityStarts:[],dateRanges:[],iFramePlaylists:[],segments:[]};let E=0,C=0;const P={};this.on("end",()=>{n.uri||!n.parts&&!n.preloadHints||(!n.map&&r&&(n.map=r),!n.key&&a&&(n.key=a),!n.timeline&&typeof T=="number"&&(n.timeline=T),this.manifest.preloadSegment=n)}),this.parseStream.on("data",function(v){let R,L;if(t.manifest.definitions){for(const N in t.manifest.definitions)if(v.uri&&(v.uri=v.uri.replace(`{$${N}}`,t.manifest.definitions[N])),v.attributes)for(const U in v.attributes)typeof v.attributes[U]=="string"&&(v.attributes[U]=v.attributes[U].replace(`{$${N}}`,t.manifest.definitions[N]))}({tag(){({version(){v.version&&(this.manifest.version=v.version)},"allow-cache"(){this.manifest.allowCache=v.allowed,"allowed"in v||(this.trigger("info",{message:"defaulting allowCache to YES"}),this.manifest.allowCache=!0)},byterange(){const N={};"length"in v&&(n.byterange=N,N.length=v.length,"offset"in v||(v.offset=E)),"offset"in v&&(n.byterange=N,N.offset=v.offset),E=N.offset+N.length},endlist(){this.manifest.endList=!0},inf(){"mediaSequence"in this.manifest||(this.manifest.mediaSequence=0,this.trigger("info",{message:"defaulting media sequence to zero"})),"discontinuitySequence"in this.manifest||(this.manifest.discontinuitySequence=0,this.trigger("info",{message:"defaulting discontinuity sequence to zero"})),v.title&&(n.title=v.title),v.duration>0&&(n.duration=v.duration),v.duration===0&&(n.duration=.01,this.trigger("info",{message:"updating zero segment duration to a small value"})),this.manifest.segments=i},key(){if(!v.attributes){this.trigger("warn",{message:"ignoring key declaration without attribute list"});return}if(v.attributes.METHOD==="NONE"){a=null;return}if(!v.attributes.URI){this.trigger("warn",{message:"ignoring key declaration without URI"});return}if(v.attributes.KEYFORMAT==="com.apple.streamingkeydelivery"){this.manifest.contentProtection=this.manifest.contentProtection||{},this.manifest.contentProtection["com.apple.fps.1_0"]={attributes:v.attributes};return}if(v.attributes.KEYFORMAT==="com.microsoft.playready"){this.manifest.contentProtection=this.manifest.contentProtection||{},this.manifest.contentProtection["com.microsoft.playready"]={uri:v.attributes.URI};return}if(v.attributes.KEYFORMAT===m){if(["SAMPLE-AES","SAMPLE-AES-CTR","SAMPLE-AES-CENC"].indexOf(v.attributes.METHOD)===-1){this.trigger("warn",{message:"invalid key method provided for Widevine"});return}if(v.attributes.METHOD==="SAMPLE-AES-CENC"&&this.trigger("warn",{message:"SAMPLE-AES-CENC is deprecated, please use SAMPLE-AES-CTR instead"}),v.attributes.URI.substring(0,23)!=="data:text/plain;base64,"){this.trigger("warn",{message:"invalid key URI provided for Widevine"});return}if(!(v.attributes.KEYID&&v.attributes.KEYID.substring(0,2)==="0x")){this.trigger("warn",{message:"invalid key ID provided for Widevine"});return}this.manifest.contentProtection=this.manifest.contentProtection||{},this.manifest.contentProtection["com.widevine.alpha"]={attributes:{schemeIdUri:v.attributes.KEYFORMAT,keyId:v.attributes.KEYID.substring(2)},pssh:rd(v.attributes.URI.split(",")[1])};return}v.attributes.METHOD||this.trigger("warn",{message:"defaulting key method to AES-128"}),a={method:v.attributes.METHOD||"AES-128",uri:v.attributes.URI},typeof v.attributes.IV<"u"&&(a.iv=v.attributes.IV)},"media-sequence"(){if(!isFinite(v.number)){this.trigger("warn",{message:"ignoring invalid media sequence: "+v.number});return}this.manifest.mediaSequence=v.number},"discontinuity-sequence"(){if(!isFinite(v.number)){this.trigger("warn",{message:"ignoring invalid discontinuity sequence: "+v.number});return}this.manifest.discontinuitySequence=v.number,T=v.number},"playlist-type"(){if(!/VOD|EVENT/.test(v.playlistType)){this.trigger("warn",{message:"ignoring unknown playlist type: "+v.playlist});return}this.manifest.playlistType=v.playlistType},map(){r={},v.uri&&(r.uri=v.uri),v.byterange&&(r.byterange=v.byterange),a&&(r.key=a)},"stream-inf"(){if(this.manifest.playlists=i,this.manifest.mediaGroups=this.manifest.mediaGroups||f,!v.attributes){this.trigger("warn",{message:"ignoring empty stream-inf attributes"});return}n.attributes||(n.attributes={}),je(n.attributes,v.attributes)},media(){if(this.manifest.mediaGroups=this.manifest.mediaGroups||f,!(v.attributes&&v.attributes.TYPE&&v.attributes["GROUP-ID"]&&v.attributes.NAME)){this.trigger("warn",{message:"ignoring incomplete or missing media group"});return}const N=this.manifest.mediaGroups[v.attributes.TYPE];N[v.attributes["GROUP-ID"]]=N[v.attributes["GROUP-ID"]]||{},R=N[v.attributes["GROUP-ID"]],L={default:/yes/i.test(v.attributes.DEFAULT)},L.default?L.autoselect=!0:L.autoselect=/yes/i.test(v.attributes.AUTOSELECT),v.attributes.LANGUAGE&&(L.language=v.attributes.LANGUAGE),v.attributes.URI&&(L.uri=v.attributes.URI),v.attributes["INSTREAM-ID"]&&(L.instreamId=v.attributes["INSTREAM-ID"]),v.attributes.CHARACTERISTICS&&(L.characteristics=v.attributes.CHARACTERISTICS),v.attributes.FORCED&&(L.forced=/yes/i.test(v.attributes.FORCED)),R[v.attributes.NAME]=L},discontinuity(){T+=1,n.discontinuity=!0,this.manifest.discontinuityStarts.push(i.length)},"program-date-time"(){typeof this.manifest.dateTimeString>"u"&&(this.manifest.dateTimeString=v.dateTimeString,this.manifest.dateTimeObject=v.dateTimeObject),n.dateTimeString=v.dateTimeString,n.dateTimeObject=v.dateTimeObject;const{lastProgramDateTime:N}=this;this.lastProgramDateTime=new Date(v.dateTimeString).getTime(),N===null&&this.manifest.segments.reduceRight((U,F)=>(F.programDateTime=U-F.duration*1e3,F.programDateTime),this.lastProgramDateTime)},targetduration(){if(!isFinite(v.duration)||v.duration<0){this.trigger("warn",{message:"ignoring invalid target duration: "+v.duration});return}this.manifest.targetDuration=v.duration,Da.call(this,this.manifest)},start(){if(!v.attributes||isNaN(v.attributes["TIME-OFFSET"])){this.trigger("warn",{message:"ignoring start declaration without appropriate attribute list"});return}this.manifest.start={timeOffset:v.attributes["TIME-OFFSET"],precise:v.attributes.PRECISE}},"cue-out"(){n.cueOut=v.data},"cue-out-cont"(){n.cueOutCont=v.data},"cue-in"(){n.cueIn=v.data},skip(){this.manifest.skip=yi(v.attributes),this.warnOnMissingAttributes_("#EXT-X-SKIP",v.attributes,["SKIPPED-SEGMENTS"])},part(){l=!0;const N=this.manifest.segments.length,U=yi(v.attributes);n.parts=n.parts||[],n.parts.push(U),U.byterange&&(U.byterange.hasOwnProperty("offset")||(U.byterange.offset=C),C=U.byterange.offset+U.byterange.length);const F=n.parts.length-1;this.warnOnMissingAttributes_(`#EXT-X-PART #${F} for segment #${N}`,v.attributes,["URI","DURATION"]),this.manifest.renditionReports&&this.manifest.renditionReports.forEach((D,V)=>{D.hasOwnProperty("lastPart")||this.trigger("warn",{message:`#EXT-X-RENDITION-REPORT #${V} lacks required attribute(s): LAST-PART`})})},"server-control"(){const N=this.manifest.serverControl=yi(v.attributes);N.hasOwnProperty("canBlockReload")||(N.canBlockReload=!1,this.trigger("info",{message:"#EXT-X-SERVER-CONTROL defaulting CAN-BLOCK-RELOAD to false"})),Da.call(this,this.manifest),N.canSkipDateranges&&!N.hasOwnProperty("canSkipUntil")&&this.trigger("warn",{message:"#EXT-X-SERVER-CONTROL lacks required attribute CAN-SKIP-UNTIL which is required when CAN-SKIP-DATERANGES is set"})},"preload-hint"(){const N=this.manifest.segments.length,U=yi(v.attributes),F=U.type&&U.type==="PART";n.preloadHints=n.preloadHints||[],n.preloadHints.push(U),U.byterange&&(U.byterange.hasOwnProperty("offset")||(U.byterange.offset=F?C:0,F&&(C=U.byterange.offset+U.byterange.length)));const D=n.preloadHints.length-1;if(this.warnOnMissingAttributes_(`#EXT-X-PRELOAD-HINT #${D} for segment #${N}`,v.attributes,["TYPE","URI"]),!!U.type)for(let V=0;V<n.preloadHints.length-1;V++){const X=n.preloadHints[V];X.type&&X.type===U.type&&this.trigger("warn",{message:`#EXT-X-PRELOAD-HINT #${D} for segment #${N} has the same TYPE ${U.type} as preload hint #${V}`})}},"rendition-report"(){const N=yi(v.attributes);this.manifest.renditionReports=this.manifest.renditionReports||[],this.manifest.renditionReports.push(N);const U=this.manifest.renditionReports.length-1,F=["LAST-MSN","URI"];l&&F.push("LAST-PART"),this.warnOnMissingAttributes_(`#EXT-X-RENDITION-REPORT #${U}`,v.attributes,F)},"part-inf"(){this.manifest.partInf=yi(v.attributes),this.warnOnMissingAttributes_("#EXT-X-PART-INF",v.attributes,["PART-TARGET"]),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),Da.call(this,this.manifest)},daterange(){this.manifest.dateRanges.push(yi(v.attributes));const N=this.manifest.dateRanges.length-1;this.warnOnMissingAttributes_(`#EXT-X-DATERANGE #${N}`,v.attributes,["ID","START-DATE"]);const U=this.manifest.dateRanges[N];U.endDate&&U.startDate&&new Date(U.endDate)<new Date(U.startDate)&&this.trigger("warn",{message:"EXT-X-DATERANGE END-DATE must be equal to or later than the value of the START-DATE"}),U.duration&&U.duration<0&&this.trigger("warn",{message:"EXT-X-DATERANGE DURATION must not be negative"}),U.plannedDuration&&U.plannedDuration<0&&this.trigger("warn",{message:"EXT-X-DATERANGE PLANNED-DURATION must not be negative"});const F=!!U.endOnNext;if(F&&!U.class&&this.trigger("warn",{message:"EXT-X-DATERANGE with an END-ON-NEXT=YES attribute must have a CLASS attribute"}),F&&(U.duration||U.endDate)&&this.trigger("warn",{message:"EXT-X-DATERANGE with an END-ON-NEXT=YES attribute must not contain DURATION or END-DATE attributes"}),U.duration&&U.endDate){const V=U.startDate.getTime()+U.duration*1e3;this.manifest.dateRanges[N].endDate=new Date(V)}if(!P[U.id])P[U.id]=U;else{for(const V in P[U.id])if(U[V]&&JSON.stringify(P[U.id][V])!==JSON.stringify(U[V])){this.trigger("warn",{message:"EXT-X-DATERANGE tags with the same ID in a playlist must have the same attributes values"});break}const D=this.manifest.dateRanges.findIndex(V=>V.id===U.id);this.manifest.dateRanges[D]=je(this.manifest.dateRanges[D],U),P[U.id]=je(P[U.id],U),this.manifest.dateRanges.pop()}},"independent-segments"(){this.manifest.independentSegments=!0},"i-frames-only"(){this.manifest.iFramesOnly=!0,this.requiredCompatibilityversion(this.manifest.version,4)},"content-steering"(){this.manifest.contentSteering=yi(v.attributes),this.warnOnMissingAttributes_("#EXT-X-CONTENT-STEERING",v.attributes,["SERVER-URI"])},define(){this.manifest.definitions=this.manifest.definitions||{};const N=(U,F)=>{if(U in this.manifest.definitions){this.trigger("error",{message:`EXT-X-DEFINE: Duplicate name ${U}`});return}this.manifest.definitions[U]=F};if("QUERYPARAM"in v.attributes){if("NAME"in v.attributes||"IMPORT"in v.attributes){this.trigger("error",{message:"EXT-X-DEFINE: Invalid attributes"});return}const U=this.params.get(v.attributes.QUERYPARAM);if(!U){this.trigger("error",{message:`EXT-X-DEFINE: No query param ${v.attributes.QUERYPARAM}`});return}N(v.attributes.QUERYPARAM,decodeURIComponent(U));return}if("NAME"in v.attributes){if("IMPORT"in v.attributes){this.trigger("error",{message:"EXT-X-DEFINE: Invalid attributes"});return}if(!("VALUE"in v.attributes)||typeof v.attributes.VALUE!="string"){this.trigger("error",{message:`EXT-X-DEFINE: No value for ${v.attributes.NAME}`});return}N(v.attributes.NAME,v.attributes.VALUE);return}if("IMPORT"in v.attributes){if(!this.mainDefinitions[v.attributes.IMPORT]){this.trigger("error",{message:`EXT-X-DEFINE: No value ${v.attributes.IMPORT} to import, or IMPORT used on main playlist`});return}N(v.attributes.IMPORT,this.mainDefinitions[v.attributes.IMPORT]);return}this.trigger("error",{message:"EXT-X-DEFINE: No attribute"})},"i-frame-playlist"(){this.manifest.iFramePlaylists.push({attributes:v.attributes,uri:v.uri,timeline:T}),this.warnOnMissingAttributes_("#EXT-X-I-FRAME-STREAM-INF",v.attributes,["BANDWIDTH","URI"])}}[v.tagType]||h).call(t)},uri(){n.uri=v.uri,i.push(n),this.manifest.targetDuration&&!("duration"in n)&&(this.trigger("warn",{message:"defaulting segment duration to the target duration"}),n.duration=this.manifest.targetDuration),a&&(n.key=a),n.timeline=T,r&&(n.map=r),C=0,this.lastProgramDateTime!==null&&(n.programDateTime=this.lastProgramDateTime,this.lastProgramDateTime+=n.duration*1e3),n={}},comment(){},custom(){v.segment?(n.custom=n.custom||{},n.custom[v.customType]=v.data):(this.manifest.custom=this.manifest.custom||{},this.manifest.custom[v.customType]=v.data)}})[v.type].call(t)})}requiredCompatibilityversion(e,t){(e<t||!e)&&this.trigger("warn",{message:`manifest must be at least version ${t}`})}warnOnMissingAttributes_(e,t,i){const n=[];i.forEach(function(r){t.hasOwnProperty(r)||n.push(r)}),n.length&&this.trigger("warn",{message:`${e} lacks required attribute(s): ${n.join(", ")}`})}push(e){this.lineStream.push(e)}end(){this.lineStream.push(`
|
|
24
|
+
`),this.manifest.dateRanges.length&&this.lastProgramDateTime===null&&this.trigger("warn",{message:"A playlist with EXT-X-DATERANGE tag must contain atleast one EXT-X-PROGRAM-DATE-TIME tag"}),this.lastProgramDateTime=null,this.trigger("end")}addParser(e){this.parseStream.addParser(e)}addTagMapper(e){this.parseStream.addTagMapper(e)}}var Bi={mp4:/^(av0?1|avc0?[1234]|vp0?9|flac|opus|mp3|mp4a|mp4v|stpp.ttml.im1t)/,webm:/^(vp0?[89]|av0?1|opus|vorbis)/,ogg:/^(vp0?[89]|theora|flac|opus|vorbis)/,video:/^(av0?1|avc0?[1234]|vp0?[89]|hvc1|hev1|theora|mp4v)/,audio:/^(mp4a|flac|vorbis|opus|ac-[34]|ec-3|alac|mp3|speex|aac)/,text:/^(stpp.ttml.im1t)/,muxerVideo:/^(avc0?1)/,muxerAudio:/^(mp4a)/,muxerText:/a^/},qy=["video","audio","text"],vu=["Video","Audio","Text"],ad=function(e){return e&&e.replace(/avc1\.(\d+)\.(\d+)/i,function(t,i,n){var r=("00"+Number(i).toString(16)).slice(-2),a=("00"+Number(n).toString(16)).slice(-2);return"avc1."+r+"00"+a})},zt=function(e){e===void 0&&(e="");var t=e.split(","),i=[];return t.forEach(function(n){n=n.trim();var r;qy.forEach(function(a){var l=Bi[a].exec(n.toLowerCase());if(!(!l||l.length<=1)){r=a;var h=n.substring(0,l[1].length),f=n.replace(h,"");i.push({type:h,details:f,mediaType:a})}}),r||i.push({type:n,details:"",mediaType:"unknown"})}),i},zy=function(e,t){if(!e.mediaGroups.AUDIO||!t)return null;var i=e.mediaGroups.AUDIO[t];if(!i)return null;for(var n in i){var r=i[n];if(r.default&&r.playlists)return zt(r.playlists[0].attributes.CODECS)}return null},od=function(e){return e===void 0&&(e=""),Bi.audio.test(e.trim().toLowerCase())},Wy=function(e){return e===void 0&&(e=""),Bi.text.test(e.trim().toLowerCase())},fs=function(e){if(!(!e||typeof e!="string")){var t=e.toLowerCase().split(",").map(function(r){return ad(r.trim())}),i="video";t.length===1&&od(t[0])?i="audio":t.length===1&&Wy(t[0])&&(i="application");var n="mp4";return t.every(function(r){return Bi.mp4.test(r)})?n="mp4":t.every(function(r){return Bi.webm.test(r)})?n="webm":t.every(function(r){return Bi.ogg.test(r)})&&(n="ogg"),i+"/"+n+';codecs="'+e+'"'}},dn=function(e,t){return e===void 0&&(e=""),t===void 0&&(t=!1),k.MediaSource&&k.MediaSource.isTypeSupported&&k.MediaSource.isTypeSupported(fs(e))||t&&k.ManagedMediaSource&&k.ManagedMediaSource.isTypeSupported&&k.ManagedMediaSource.isTypeSupported(fs(e))||!1},La=function(e){return e===void 0&&(e=""),e.toLowerCase().split(",").every(function(t){t=t.trim();for(var i=0;i<vu.length;i++){var n=vu[i];if(Bi["muxer"+n].test(t))return!0}return!1})},bu="mp4a.40.2",Gy="avc1.4d400d",Ky=/^(audio|video|application)\/(x-|vnd\.apple\.)?mpegurl/i,Xy=/^application\/dash\+xml/i,ld=function(e){return Ky.test(e)?"hls":Xy.test(e)?"dash":e==="application/vnd.videojs.vhs+json"?"vhs-json":null},Yy=function(e){return e.toString(2).length},Qy=function(e){return Math.ceil(Yy(e)/8)},ud=function(e){return ArrayBuffer.isView==="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer},Jy=function(e){return ud(e)},ie=function(e){return e instanceof Uint8Array?e:(!Array.isArray(e)&&!Jy(e)&&!(e instanceof ArrayBuffer)&&(typeof e!="number"||typeof e=="number"&&e!==e?e=0:e=[e]),new Uint8Array(e&&e.buffer||e,e&&e.byteOffset||0,e&&e.byteLength||0))},Ye=k.BigInt||Number,Xa=[Ye("0x1"),Ye("0x100"),Ye("0x10000"),Ye("0x1000000"),Ye("0x100000000"),Ye("0x10000000000"),Ye("0x1000000000000"),Ye("0x100000000000000"),Ye("0x10000000000000000")];(function(){var s=new Uint16Array([65484]),e=new Uint8Array(s.buffer,s.byteOffset,s.byteLength);return e[0]===255?"big":e[0]===204?"little":"unknown"})();var Zy=function(e,t){var i=t===void 0?{}:t,n=i.signed,r=n===void 0?!1:n,a=i.le,l=a===void 0?!1:a;e=ie(e);var h=l?"reduce":"reduceRight",f=e[h]?e[h]:Array.prototype[h],m=f.call(e,function(E,C,P){var v=l?P:Math.abs(P+1-e.length);return E+Ye(C)*Xa[v]},Ye(0));if(r){var T=Xa[e.length]/Ye(2)-Ye(1);m=Ye(m),m>T&&(m-=T,m-=T,m-=Ye(2))}return Number(m)},e_=function(e,t){var i={},n=i.le,r=n===void 0?!1:n;(typeof e!="bigint"&&typeof e!="number"||typeof e=="number"&&e!==e)&&(e=0),e=Ye(e);for(var a=Qy(e),l=new Uint8Array(new ArrayBuffer(a)),h=0;h<a;h++){var f=r?h:Math.abs(h+1-l.length);l[f]=Number(e/Xa[h]&Ye(255)),e<0&&(l[f]=Math.abs(~l[f]),l[f]-=h===0?1:2)}return l},cd=function(e,t){if(typeof e!="string"&&e&&typeof e.toString=="function"&&(e=e.toString()),typeof e!="string")return new Uint8Array;t||(e=unescape(encodeURIComponent(e)));for(var i=new Uint8Array(e.length),n=0;n<e.length;n++)i[n]=e.charCodeAt(n);return i},t_=function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];if(t=t.filter(function(l){return l&&(l.byteLength||l.length)&&typeof l!="string"}),t.length<=1)return ie(t[0]);var n=t.reduce(function(l,h,f){return l+(h.byteLength||h.length)},0),r=new Uint8Array(n),a=0;return t.forEach(function(l){l=ie(l),r.set(l,a),a+=l.byteLength}),r},Oe=function(e,t,i){var n=i===void 0?{}:i,r=n.offset,a=r===void 0?0:r,l=n.mask,h=l===void 0?[]:l;e=ie(e),t=ie(t);var f=t.every?t.every:Array.prototype.every;return t.length&&e.length-a>=t.length&&f.call(t,function(m,T){var E=h[T]?h[T]&e[a+T]:e[a+T];return m===E})},i_=function(e,t,i){t.forEach(function(n){for(var r in e.mediaGroups[n])for(var a in e.mediaGroups[n][r]){var l=e.mediaGroups[n][r][a];i(l,n,r,a)}})};/*! @name mpd-parser @version 1.3.1 @license Apache-2.0 */const xu=s=>!!s&&typeof s=="object",Ge=(...s)=>s.reduce((e,t)=>(typeof t!="object"||Object.keys(t).forEach(i=>{Array.isArray(e[i])&&Array.isArray(t[i])?e[i]=e[i].concat(t[i]):xu(e[i])&&xu(t[i])?e[i]=Ge(e[i],t[i]):e[i]=t[i]}),e),{}),dd=s=>Object.keys(s).map(e=>s[e]),s_=(s,e)=>{const t=[];for(let i=s;i<e;i++)t.push(i);return t},ps=s=>s.reduce((e,t)=>e.concat(t),[]),hd=s=>{if(!s.length)return[];const e=[];for(let t=0;t<s.length;t++)e.push(s[t]);return e},n_=(s,e)=>s.reduce((t,i,n)=>(i[e]&&t.push(n),t),[]),r_=(s,e)=>dd(s.reduce((t,i)=>(i.forEach(n=>{t[e(n)]=n}),t),{}));var ms={INVALID_NUMBER_OF_PERIOD:"INVALID_NUMBER_OF_PERIOD",INVALID_NUMBER_OF_CONTENT_STEERING:"INVALID_NUMBER_OF_CONTENT_STEERING",DASH_EMPTY_MANIFEST:"DASH_EMPTY_MANIFEST",DASH_INVALID_XML:"DASH_INVALID_XML",NO_BASE_URL:"NO_BASE_URL",MISSING_SEGMENT_INFORMATION:"MISSING_SEGMENT_INFORMATION",SEGMENT_TIME_UNSPECIFIED:"SEGMENT_TIME_UNSPECIFIED",UNSUPPORTED_UTC_TIMING_SCHEME:"UNSUPPORTED_UTC_TIMING_SCHEME"};const yn=({baseUrl:s="",source:e="",range:t="",indexRange:i=""})=>{const n={uri:e,resolvedUri:Ur(s||"",e)};if(t||i){const a=(t||i).split("-");let l=k.BigInt?k.BigInt(a[0]):parseInt(a[0],10),h=k.BigInt?k.BigInt(a[1]):parseInt(a[1],10);l<Number.MAX_SAFE_INTEGER&&typeof l=="bigint"&&(l=Number(l)),h<Number.MAX_SAFE_INTEGER&&typeof h=="bigint"&&(h=Number(h));let f;typeof h=="bigint"||typeof l=="bigint"?f=k.BigInt(h)-k.BigInt(l)+k.BigInt(1):f=h-l+1,typeof f=="bigint"&&f<Number.MAX_SAFE_INTEGER&&(f=Number(f)),n.byterange={length:f,offset:l}}return n},a_=s=>{let e;return typeof s.offset=="bigint"||typeof s.length=="bigint"?e=k.BigInt(s.offset)+k.BigInt(s.length)-k.BigInt(1):e=s.offset+s.length-1,`${s.offset}-${e}`},Su=s=>(s&&typeof s!="number"&&(s=parseInt(s,10)),isNaN(s)?null:s),o_={static(s){const{duration:e,timescale:t=1,sourceDuration:i,periodDuration:n}=s,r=Su(s.endNumber),a=e/t;return typeof r=="number"?{start:0,end:r}:typeof n=="number"?{start:0,end:n/a}:{start:0,end:i/a}},dynamic(s){const{NOW:e,clientOffset:t,availabilityStartTime:i,timescale:n=1,duration:r,periodStart:a=0,minimumUpdatePeriod:l=0,timeShiftBufferDepth:h=1/0}=s,f=Su(s.endNumber),m=(e+t)/1e3,T=i+a,C=m+l-T,P=Math.ceil(C*n/r),v=Math.floor((m-T-h)*n/r),R=Math.floor((m-T)*n/r);return{start:Math.max(0,v),end:typeof f=="number"?f:Math.min(P,R)}}},l_=s=>e=>{const{duration:t,timescale:i=1,periodStart:n,startNumber:r=1}=s;return{number:r+e,duration:t/i,timeline:n,time:e*t}},ko=s=>{const{type:e,duration:t,timescale:i=1,periodDuration:n,sourceDuration:r}=s,{start:a,end:l}=o_[e](s),h=s_(a,l).map(l_(s));if(e==="static"){const f=h.length-1,m=typeof n=="number"?n:r;h[f].duration=m-t/i*f}return h},fd=s=>{const{baseUrl:e,initialization:t={},sourceDuration:i,indexRange:n="",periodStart:r,presentationTime:a,number:l=0,duration:h}=s;if(!e)throw new Error(ms.NO_BASE_URL);const f=yn({baseUrl:e,source:t.sourceURL,range:t.range}),m=yn({baseUrl:e,source:e,indexRange:n});if(m.map=f,h){const T=ko(s);T.length&&(m.duration=T[0].duration,m.timeline=T[0].timeline)}else i&&(m.duration=i,m.timeline=r);return m.presentationTime=a||r,m.number=l,[m]},Po=(s,e,t)=>{const i=s.sidx.map?s.sidx.map:null,n=s.sidx.duration,r=s.timeline||0,a=s.sidx.byterange,l=a.offset+a.length,h=e.timescale,f=e.references.filter(R=>R.referenceType!==1),m=[],T=s.endList?"static":"dynamic",E=s.sidx.timeline;let C=E,P=s.mediaSequence||0,v;typeof e.firstOffset=="bigint"?v=k.BigInt(l)+e.firstOffset:v=l+e.firstOffset;for(let R=0;R<f.length;R++){const L=e.references[R],N=L.referencedSize,U=L.subsegmentDuration;let F;typeof v=="bigint"?F=v+k.BigInt(N)-k.BigInt(1):F=v+N-1;const D=`${v}-${F}`,X=fd({baseUrl:t,timescale:h,timeline:r,periodStart:E,presentationTime:C,number:P,duration:U,sourceDuration:n,indexRange:D,type:T})[0];i&&(X.map=i),m.push(X),typeof v=="bigint"?v+=k.BigInt(N):v+=N,C+=U/h,P++}return s.segments=m,s},u_=["AUDIO","SUBTITLES"],c_=1/60,pd=s=>r_(s,({timeline:e})=>e).sort((e,t)=>e.timeline>t.timeline?1:-1),d_=(s,e)=>{for(let t=0;t<s.length;t++)if(s[t].attributes.NAME===e)return s[t];return null},Eu=s=>{let e=[];return i_(s,u_,(t,i,n,r)=>{e=e.concat(t.playlists||[])}),e},Cu=({playlist:s,mediaSequence:e})=>{s.mediaSequence=e,s.segments.forEach((t,i)=>{t.number=s.mediaSequence+i})},h_=({oldPlaylists:s,newPlaylists:e,timelineStarts:t})=>{e.forEach(i=>{i.discontinuitySequence=t.findIndex(function({timeline:h}){return h===i.timeline});const n=d_(s,i.attributes.NAME);if(!n||i.sidx)return;const r=i.segments[0],a=n.segments.findIndex(function(h){return Math.abs(h.presentationTime-r.presentationTime)<c_});if(a===-1){Cu({playlist:i,mediaSequence:n.mediaSequence+n.segments.length}),i.segments[0].discontinuity=!0,i.discontinuityStarts.unshift(0),(!n.segments.length&&i.timeline>n.timeline||n.segments.length&&i.timeline>n.segments[n.segments.length-1].timeline)&&i.discontinuitySequence--;return}n.segments[a].discontinuity&&!r.discontinuity&&(r.discontinuity=!0,i.discontinuityStarts.unshift(0),i.discontinuitySequence--),Cu({playlist:i,mediaSequence:n.segments[a].number})})},f_=({oldManifest:s,newManifest:e})=>{const t=s.playlists.concat(Eu(s)),i=e.playlists.concat(Eu(e));return e.timelineStarts=pd([s.timelineStarts,e.timelineStarts]),h_({oldPlaylists:t,newPlaylists:i,timelineStarts:e.timelineStarts}),e},Fr=s=>s&&s.uri+"-"+a_(s.byterange),Oa=s=>{const e=s.reduce(function(i,n){return i[n.attributes.baseUrl]||(i[n.attributes.baseUrl]=[]),i[n.attributes.baseUrl].push(n),i},{});let t=[];return Object.values(e).forEach(i=>{const n=dd(i.reduce((r,a)=>{const l=a.attributes.id+(a.attributes.lang||"");return r[l]?(a.segments&&(a.segments[0]&&(a.segments[0].discontinuity=!0),r[l].segments.push(...a.segments)),a.attributes.contentProtection&&(r[l].attributes.contentProtection=a.attributes.contentProtection)):(r[l]=a,r[l].attributes.timelineStarts=[]),r[l].attributes.timelineStarts.push({start:a.attributes.periodStart,timeline:a.attributes.periodStart}),r},{}));t=t.concat(n)}),t.map(i=>(i.discontinuityStarts=n_(i.segments||[],"discontinuity"),i))},Do=(s,e)=>{const t=Fr(s.sidx),i=t&&e[t]&&e[t].sidx;return i&&Po(s,i,s.sidx.resolvedUri),s},p_=(s,e={})=>{if(!Object.keys(e).length)return s;for(const t in s)s[t]=Do(s[t],e);return s},m_=({attributes:s,segments:e,sidx:t,mediaSequence:i,discontinuitySequence:n,discontinuityStarts:r},a)=>{const l={attributes:{NAME:s.id,BANDWIDTH:s.bandwidth,CODECS:s.codecs,"PROGRAM-ID":1},uri:"",endList:s.type==="static",timeline:s.periodStart,resolvedUri:s.baseUrl||"",targetDuration:s.duration,discontinuitySequence:n,discontinuityStarts:r,timelineStarts:s.timelineStarts,mediaSequence:i,segments:e};return s.contentProtection&&(l.contentProtection=s.contentProtection),s.serviceLocation&&(l.attributes.serviceLocation=s.serviceLocation),t&&(l.sidx=t),a&&(l.attributes.AUDIO="audio",l.attributes.SUBTITLES="subs"),l},g_=({attributes:s,segments:e,mediaSequence:t,discontinuityStarts:i,discontinuitySequence:n})=>{typeof e>"u"&&(e=[{uri:s.baseUrl,timeline:s.periodStart,resolvedUri:s.baseUrl||"",duration:s.sourceDuration,number:0}],s.duration=s.sourceDuration);const r={NAME:s.id,BANDWIDTH:s.bandwidth,"PROGRAM-ID":1};s.codecs&&(r.CODECS=s.codecs);const a={attributes:r,uri:"",endList:s.type==="static",timeline:s.periodStart,resolvedUri:s.baseUrl||"",targetDuration:s.duration,timelineStarts:s.timelineStarts,discontinuityStarts:i,discontinuitySequence:n,mediaSequence:t,segments:e};return s.serviceLocation&&(a.attributes.serviceLocation=s.serviceLocation),a},y_=(s,e={},t=!1)=>{let i;const n=s.reduce((r,a)=>{const l=a.attributes.role&&a.attributes.role.value||"",h=a.attributes.lang||"";let f=a.attributes.label||"main";if(h&&!a.attributes.label){const T=l?` (${l})`:"";f=`${a.attributes.lang}${T}`}r[f]||(r[f]={language:h,autoselect:!0,default:l==="main",playlists:[],uri:""});const m=Do(m_(a,t),e);return r[f].playlists.push(m),typeof i>"u"&&l==="main"&&(i=a,i.default=!0),r},{});if(!i){const r=Object.keys(n)[0];n[r].default=!0}return n},__=(s,e={})=>s.reduce((t,i)=>{const n=i.attributes.label||i.attributes.lang||"text",r=i.attributes.lang||"und";return t[n]||(t[n]={language:r,default:!1,autoselect:!1,playlists:[],uri:""}),t[n].playlists.push(Do(g_(i),e)),t},{}),T_=s=>s.reduce((e,t)=>(t&&t.forEach(i=>{const{channel:n,language:r}=i;e[r]={autoselect:!1,default:!1,instreamId:n,language:r},i.hasOwnProperty("aspectRatio")&&(e[r].aspectRatio=i.aspectRatio),i.hasOwnProperty("easyReader")&&(e[r].easyReader=i.easyReader),i.hasOwnProperty("3D")&&(e[r]["3D"]=i["3D"])}),e),{}),v_=({attributes:s,segments:e,sidx:t,discontinuityStarts:i})=>{const n={attributes:{NAME:s.id,AUDIO:"audio",SUBTITLES:"subs",RESOLUTION:{width:s.width,height:s.height},CODECS:s.codecs,BANDWIDTH:s.bandwidth,"PROGRAM-ID":1},uri:"",endList:s.type==="static",timeline:s.periodStart,resolvedUri:s.baseUrl||"",targetDuration:s.duration,discontinuityStarts:i,timelineStarts:s.timelineStarts,segments:e};return s.frameRate&&(n.attributes["FRAME-RATE"]=s.frameRate),s.contentProtection&&(n.contentProtection=s.contentProtection),s.serviceLocation&&(n.attributes.serviceLocation=s.serviceLocation),t&&(n.sidx=t),n},b_=({attributes:s})=>s.mimeType==="video/mp4"||s.mimeType==="video/webm"||s.contentType==="video",x_=({attributes:s})=>s.mimeType==="audio/mp4"||s.mimeType==="audio/webm"||s.contentType==="audio",S_=({attributes:s})=>s.mimeType==="text/vtt"||s.contentType==="text",E_=(s,e)=>{s.forEach(t=>{t.mediaSequence=0,t.discontinuitySequence=e.findIndex(function({timeline:i}){return i===t.timeline}),t.segments&&t.segments.forEach((i,n)=>{i.number=n})})},wu=s=>s?Object.keys(s).reduce((e,t)=>{const i=s[t];return e.concat(i.playlists)},[]):[],C_=({dashPlaylists:s,locations:e,contentSteering:t,sidxMapping:i={},previousManifest:n,eventStream:r})=>{if(!s.length)return{};const{sourceDuration:a,type:l,suggestedPresentationDelay:h,minimumUpdatePeriod:f}=s[0].attributes,m=Oa(s.filter(b_)).map(v_),T=Oa(s.filter(x_)),E=Oa(s.filter(S_)),C=s.map(F=>F.attributes.captionServices).filter(Boolean),P={allowCache:!0,discontinuityStarts:[],segments:[],endList:!0,mediaGroups:{AUDIO:{},VIDEO:{},"CLOSED-CAPTIONS":{},SUBTITLES:{}},uri:"",duration:a,playlists:p_(m,i)};f>=0&&(P.minimumUpdatePeriod=f*1e3),e&&(P.locations=e),t&&(P.contentSteering=t),l==="dynamic"&&(P.suggestedPresentationDelay=h),r&&r.length>0&&(P.eventStream=r);const v=P.playlists.length===0,R=T.length?y_(T,i,v):null,L=E.length?__(E,i):null,N=m.concat(wu(R),wu(L)),U=N.map(({timelineStarts:F})=>F);return P.timelineStarts=pd(U),E_(N,P.timelineStarts),R&&(P.mediaGroups.AUDIO.audio=R),L&&(P.mediaGroups.SUBTITLES.subs=L),C.length&&(P.mediaGroups["CLOSED-CAPTIONS"].cc=T_(C)),n?f_({oldManifest:n,newManifest:P}):P},w_=(s,e,t)=>{const{NOW:i,clientOffset:n,availabilityStartTime:r,timescale:a=1,periodStart:l=0,minimumUpdatePeriod:h=0}=s,f=(i+n)/1e3,m=r+l,E=f+h-m;return Math.ceil((E*a-e)/t)},md=(s,e)=>{const{type:t,minimumUpdatePeriod:i=0,media:n="",sourceDuration:r,timescale:a=1,startNumber:l=1,periodStart:h}=s,f=[];let m=-1;for(let T=0;T<e.length;T++){const E=e[T],C=E.d,P=E.r||0,v=E.t||0;m<0&&(m=v),v&&v>m&&(m=v);let R;if(P<0){const U=T+1;U===e.length?t==="dynamic"&&i>0&&n.indexOf("$Number$")>0?R=w_(s,m,C):R=(r*a-m)/C:R=(e[U].t-m)/C}else R=P+1;const L=l+f.length+R;let N=l+f.length;for(;N<L;)f.push({number:N,duration:C/a,time:m,timeline:h}),m+=C,N++}return f},I_=/\$([A-z]*)(?:(%0)([0-9]+)d)?\$/g,A_=s=>(e,t,i,n)=>{if(e==="$$")return"$";if(typeof s[t]>"u")return e;const r=""+s[t];return t==="RepresentationID"||(i?n=parseInt(n,10):n=1,r.length>=n)?r:`${new Array(n-r.length+1).join("0")}${r}`},Iu=(s,e)=>s.replace(I_,A_(e)),k_=(s,e)=>!s.duration&&!e?[{number:s.startNumber||1,duration:s.sourceDuration,time:0,timeline:s.periodStart}]:s.duration?ko(s):md(s,e),P_=(s,e)=>{const t={RepresentationID:s.id,Bandwidth:s.bandwidth||0},{initialization:i={sourceURL:"",range:""}}=s,n=yn({baseUrl:s.baseUrl,source:Iu(i.sourceURL,t),range:i.range});return k_(s,e).map(a=>{t.Number=a.number,t.Time=a.time;const l=Iu(s.media||"",t),h=s.timescale||1,f=s.presentationTimeOffset||0,m=s.periodStart+(a.time-f)/h;return{uri:l,timeline:a.timeline,duration:a.duration,resolvedUri:Ur(s.baseUrl||"",l),map:n,number:a.number,presentationTime:m}})},D_=(s,e)=>{const{baseUrl:t,initialization:i={}}=s,n=yn({baseUrl:t,source:i.sourceURL,range:i.range}),r=yn({baseUrl:t,source:e.media,range:e.mediaRange});return r.map=n,r},L_=(s,e)=>{const{duration:t,segmentUrls:i=[],periodStart:n}=s;if(!t&&!e||t&&e)throw new Error(ms.SEGMENT_TIME_UNSPECIFIED);const r=i.map(h=>D_(s,h));let a;return t&&(a=ko(s)),e&&(a=md(s,e)),a.map((h,f)=>{if(r[f]){const m=r[f],T=s.timescale||1,E=s.presentationTimeOffset||0;return m.timeline=h.timeline,m.duration=h.duration,m.number=h.number,m.presentationTime=n+(h.time-E)/T,m}}).filter(h=>h)},O_=({attributes:s,segmentInfo:e})=>{let t,i;e.template?(i=P_,t=Ge(s,e.template)):e.base?(i=fd,t=Ge(s,e.base)):e.list&&(i=L_,t=Ge(s,e.list));const n={attributes:s};if(!i)return n;const r=i(t,e.segmentTimeline);if(t.duration){const{duration:a,timescale:l=1}=t;t.duration=a/l}else r.length?t.duration=r.reduce((a,l)=>Math.max(a,Math.ceil(l.duration)),0):t.duration=0;return n.attributes=t,n.segments=r,e.base&&t.indexRange&&(n.sidx=r[0],n.segments=[]),n},R_=s=>s.map(O_),Re=(s,e)=>hd(s.childNodes).filter(({tagName:t})=>t===e),bn=s=>s.textContent.trim(),M_=s=>parseFloat(s.split("/").reduce((e,t)=>e/t)),Ji=s=>{const l=/P(?:(\d*)Y)?(?:(\d*)M)?(?:(\d*)D)?(?:T(?:(\d*)H)?(?:(\d*)M)?(?:([\d.]*)S)?)?/.exec(s);if(!l)return 0;const[h,f,m,T,E,C]=l.slice(1);return parseFloat(h||0)*31536e3+parseFloat(f||0)*2592e3+parseFloat(m||0)*86400+parseFloat(T||0)*3600+parseFloat(E||0)*60+parseFloat(C||0)},N_=s=>(/^\d+-\d+-\d+T\d+:\d+:\d+(\.\d+)?$/.test(s)&&(s+="Z"),Date.parse(s)),Au={mediaPresentationDuration(s){return Ji(s)},availabilityStartTime(s){return N_(s)/1e3},minimumUpdatePeriod(s){return Ji(s)},suggestedPresentationDelay(s){return Ji(s)},type(s){return s},timeShiftBufferDepth(s){return Ji(s)},start(s){return Ji(s)},width(s){return parseInt(s,10)},height(s){return parseInt(s,10)},bandwidth(s){return parseInt(s,10)},frameRate(s){return M_(s)},startNumber(s){return parseInt(s,10)},timescale(s){return parseInt(s,10)},presentationTimeOffset(s){return parseInt(s,10)},duration(s){const e=parseInt(s,10);return isNaN(e)?Ji(s):e},d(s){return parseInt(s,10)},t(s){return parseInt(s,10)},r(s){return parseInt(s,10)},presentationTime(s){return parseInt(s,10)},DEFAULT(s){return s}},He=s=>s&&s.attributes?hd(s.attributes).reduce((e,t)=>{const i=Au[t.name]||Au.DEFAULT;return e[t.name]=i(t.value),e},{}):{},U_={"urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b":"org.w3.clearkey","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":"com.widevine.alpha","urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":"com.microsoft.playready","urn:uuid:f239e769-efa3-4850-9c16-a903c6932efb":"com.adobe.primetime","urn:mpeg:dash:mp4protection:2011":"mp4protection"},$r=(s,e)=>e.length?ps(s.map(function(t){return e.map(function(i){const n=bn(i),r=Ur(t.baseUrl,n),a=Ge(He(i),{baseUrl:r});return r!==n&&!a.serviceLocation&&t.serviceLocation&&(a.serviceLocation=t.serviceLocation),a})})):s,Lo=s=>{const e=Re(s,"SegmentTemplate")[0],t=Re(s,"SegmentList")[0],i=t&&Re(t,"SegmentURL").map(T=>Ge({tag:"SegmentURL"},He(T))),n=Re(s,"SegmentBase")[0],r=t||e,a=r&&Re(r,"SegmentTimeline")[0],l=t||n||e,h=l&&Re(l,"Initialization")[0],f=e&&He(e);f&&h?f.initialization=h&&He(h):f&&f.initialization&&(f.initialization={sourceURL:f.initialization});const m={template:f,segmentTimeline:a&&Re(a,"S").map(T=>He(T)),list:t&&Ge(He(t),{segmentUrls:i,initialization:He(h)}),base:n&&Ge(He(n),{initialization:He(h)})};return Object.keys(m).forEach(T=>{m[T]||delete m[T]}),m},B_=(s,e,t)=>i=>{const n=Re(i,"BaseURL"),r=$r(e,n),a=Ge(s,He(i)),l=Lo(i);return r.map(h=>({segmentInfo:Ge(t,l),attributes:Ge(a,h)}))},F_=s=>s.reduce((e,t)=>{const i=He(t);i.schemeIdUri&&(i.schemeIdUri=i.schemeIdUri.toLowerCase());const n=U_[i.schemeIdUri];if(n){e[n]={attributes:i};const r=Re(t,"cenc:pssh")[0];if(r){const a=bn(r);e[n].pssh=a&&rd(a)}}return e},{}),$_=s=>{if(s.schemeIdUri==="urn:scte:dash:cc:cea-608:2015")return(typeof s.value!="string"?[]:s.value.split(";")).map(t=>{let i,n;return n=t,/^CC\d=/.test(t)?[i,n]=t.split("="):/^CC\d$/.test(t)&&(i=t),{channel:i,language:n}});if(s.schemeIdUri==="urn:scte:dash:cc:cea-708:2015")return(typeof s.value!="string"?[]:s.value.split(";")).map(t=>{const i={channel:void 0,language:void 0,aspectRatio:1,easyReader:0,"3D":0};if(/=/.test(t)){const[n,r=""]=t.split("=");i.channel=n,i.language=t,r.split(",").forEach(a=>{const[l,h]=a.split(":");l==="lang"?i.language=h:l==="er"?i.easyReader=Number(h):l==="war"?i.aspectRatio=Number(h):l==="3D"&&(i["3D"]=Number(h))})}else i.language=t;return i.channel&&(i.channel="SERVICE"+i.channel),i})},j_=s=>ps(Re(s.node,"EventStream").map(e=>{const t=He(e),i=t.schemeIdUri;return Re(e,"Event").map(n=>{const r=He(n),a=r.presentationTime||0,l=t.timescale||1,h=r.duration||0,f=a/l+s.attributes.start;return{schemeIdUri:i,value:t.value,id:r.id,start:f,end:f+h/l,messageData:bn(n)||r.messageData,contentEncoding:t.contentEncoding,presentationTimeOffset:t.presentationTimeOffset||0}})})),V_=(s,e,t)=>i=>{const n=He(i),r=$r(e,Re(i,"BaseURL")),a=Re(i,"Role")[0],l={role:He(a)};let h=Ge(s,n,l);const f=Re(i,"Accessibility")[0],m=$_(He(f));m&&(h=Ge(h,{captionServices:m}));const T=Re(i,"Label")[0];if(T&&T.childNodes.length){const R=T.childNodes[0].nodeValue.trim();h=Ge(h,{label:R})}const E=F_(Re(i,"ContentProtection"));Object.keys(E).length&&(h=Ge(h,{contentProtection:E}));const C=Lo(i),P=Re(i,"Representation"),v=Ge(t,C);return ps(P.map(B_(h,r,v)))},H_=(s,e)=>(t,i)=>{const n=$r(e,Re(t.node,"BaseURL")),r=Ge(s,{periodStart:t.attributes.start});typeof t.attributes.duration=="number"&&(r.periodDuration=t.attributes.duration);const a=Re(t.node,"AdaptationSet"),l=Lo(t.node);return ps(a.map(V_(r,n,l)))},q_=(s,e)=>{if(s.length>1&&e({type:"warn",message:"The MPD manifest should contain no more than one ContentSteering tag"}),!s.length)return null;const t=Ge({serverURL:bn(s[0])},He(s[0]));return t.queryBeforeStart=t.queryBeforeStart==="true",t},z_=({attributes:s,priorPeriodAttributes:e,mpdType:t})=>typeof s.start=="number"?s.start:e&&typeof e.start=="number"&&typeof e.duration=="number"?e.start+e.duration:!e&&t==="static"?0:null,W_=(s,e={})=>{const{manifestUri:t="",NOW:i=Date.now(),clientOffset:n=0,eventHandler:r=function(){}}=e,a=Re(s,"Period");if(!a.length)throw new Error(ms.INVALID_NUMBER_OF_PERIOD);const l=Re(s,"Location"),h=He(s),f=$r([{baseUrl:t}],Re(s,"BaseURL")),m=Re(s,"ContentSteering");h.type=h.type||"static",h.sourceDuration=h.mediaPresentationDuration||0,h.NOW=i,h.clientOffset=n,l.length&&(h.locations=l.map(bn));const T=[];return a.forEach((E,C)=>{const P=He(E),v=T[C-1];P.start=z_({attributes:P,priorPeriodAttributes:v?v.attributes:null,mpdType:h.type}),T.push({node:E,attributes:P})}),{locations:h.locations,contentSteeringInfo:q_(m,r),representationInfo:ps(T.map(H_(h,f))),eventStream:ps(T.map(j_))}},gd=s=>{if(s==="")throw new Error(ms.DASH_EMPTY_MANIFEST);const e=new tg.DOMParser;let t,i;try{t=e.parseFromString(s,"application/xml"),i=t&&t.documentElement.tagName==="MPD"?t.documentElement:null}catch{}if(!i||i&&i.getElementsByTagName("parsererror").length>0)throw new Error(ms.DASH_INVALID_XML);return i},G_=s=>{const e=Re(s,"UTCTiming")[0];if(!e)return null;const t=He(e);switch(t.schemeIdUri){case"urn:mpeg:dash:utc:http-head:2014":case"urn:mpeg:dash:utc:http-head:2012":t.method="HEAD";break;case"urn:mpeg:dash:utc:http-xsdate:2014":case"urn:mpeg:dash:utc:http-iso:2014":case"urn:mpeg:dash:utc:http-xsdate:2012":case"urn:mpeg:dash:utc:http-iso:2012":t.method="GET";break;case"urn:mpeg:dash:utc:direct:2014":case"urn:mpeg:dash:utc:direct:2012":t.method="DIRECT",t.value=Date.parse(t.value);break;case"urn:mpeg:dash:utc:http-ntp:2014":case"urn:mpeg:dash:utc:ntp:2014":case"urn:mpeg:dash:utc:sntp:2014":default:throw new Error(ms.UNSUPPORTED_UTC_TIMING_SCHEME)}return t},K_=(s,e={})=>{const t=W_(gd(s),e),i=R_(t.representationInfo);return C_({dashPlaylists:i,locations:t.locations,contentSteering:t.contentSteeringInfo,sidxMapping:e.sidxMapping,previousManifest:e.previousManifest,eventStream:t.eventStream})},X_=s=>G_(gd(s));var yd=Math.pow(2,32),Y_=function(s){var e=new DataView(s.buffer,s.byteOffset,s.byteLength),t;return e.getBigUint64?(t=e.getBigUint64(0),t<Number.MAX_SAFE_INTEGER?Number(t):t):e.getUint32(0)*yd+e.getUint32(4)},Q_={getUint64:Y_,MAX_UINT32:yd},ku=Q_.getUint64,J_=function(s){var e=new DataView(s.buffer,s.byteOffset,s.byteLength),t={version:s[0],flags:new Uint8Array(s.subarray(1,4)),references:[],referenceId:e.getUint32(4),timescale:e.getUint32(8)},i=12;t.version===0?(t.earliestPresentationTime=e.getUint32(i),t.firstOffset=e.getUint32(i+4),i+=8):(t.earliestPresentationTime=ku(s.subarray(i)),t.firstOffset=ku(s.subarray(i+8)),i+=16),i+=2;var n=e.getUint16(i);for(i+=2;n>0;i+=12,n--)t.references.push({referenceType:(s[i]&128)>>>7,referencedSize:e.getUint32(i)&2147483647,subsegmentDuration:e.getUint32(i+4),startsWithSap:!!(s[i+8]&128),sapType:(s[i+8]&112)>>>4,sapDeltaTime:e.getUint32(i+8)&268435455});return t},Z_=J_;const eT=Jt.getDefaultExportFromCjs(Z_);var tT=ie([73,68,51]),iT=function(e,t){t===void 0&&(t=0),e=ie(e);var i=e[t+5],n=e[t+6]<<21|e[t+7]<<14|e[t+8]<<7|e[t+9],r=(i&16)>>4;return r?n+20:n+10},on=function s(e,t){return t===void 0&&(t=0),e=ie(e),e.length-t<10||!Oe(e,tT,{offset:t})?t:(t+=iT(e,t),s(e,t))},Pu=function(e){return typeof e=="string"?cd(e):e},sT=function(e){return Array.isArray(e)?e.map(function(t){return Pu(t)}):[Pu(e)]},nT=function s(e,t,i){i===void 0&&(i=!1),t=sT(t),e=ie(e);var n=[];if(!t.length)return n;for(var r=0;r<e.length;){var a=(e[r]<<24|e[r+1]<<16|e[r+2]<<8|e[r+3])>>>0,l=e.subarray(r+4,r+8);if(a===0)break;var h=r+a;if(h>e.length){if(i)break;h=e.length}var f=e.subarray(r+8,h);Oe(l,t[0])&&(t.length===1?n.push(f):n.push.apply(n,s(f,t.slice(1),i))),r=h}return n},er={EBML:ie([26,69,223,163]),DocType:ie([66,130]),Segment:ie([24,83,128,103]),SegmentInfo:ie([21,73,169,102]),Tracks:ie([22,84,174,107]),Track:ie([174]),TrackNumber:ie([215]),DefaultDuration:ie([35,227,131]),TrackEntry:ie([174]),TrackType:ie([131]),FlagDefault:ie([136]),CodecID:ie([134]),CodecPrivate:ie([99,162]),VideoTrack:ie([224]),AudioTrack:ie([225]),Cluster:ie([31,67,182,117]),Timestamp:ie([231]),TimestampScale:ie([42,215,177]),BlockGroup:ie([160]),BlockDuration:ie([155]),Block:ie([161]),SimpleBlock:ie([163])},Ya=[128,64,32,16,8,4,2,1],rT=function(e){for(var t=1,i=0;i<Ya.length&&!(e&Ya[i]);i++)t++;return t},dr=function(e,t,i,n){i===void 0&&(i=!0),n===void 0&&(n=!1);var r=rT(e[t]),a=e.subarray(t,t+r);return i&&(a=Array.prototype.slice.call(e,t,t+r),a[0]^=Ya[r-1]),{length:r,value:Zy(a,{signed:n}),bytes:a}},Du=function s(e){return typeof e=="string"?e.match(/.{1,2}/g).map(function(t){return s(t)}):typeof e=="number"?e_(e):e},aT=function(e){return Array.isArray(e)?e.map(function(t){return Du(t)}):[Du(e)]},oT=function s(e,t,i){if(i>=t.length)return t.length;var n=dr(t,i,!1);if(Oe(e.bytes,n.bytes))return i;var r=dr(t,i+n.length);return s(e,t,i+r.length+r.value+n.length)},Lu=function s(e,t){t=aT(t),e=ie(e);var i=[];if(!t.length)return i;for(var n=0;n<e.length;){var r=dr(e,n,!1),a=dr(e,n+r.length),l=n+r.length+a.length;a.value===127&&(a.value=oT(r,e,l),a.value!==e.length&&(a.value-=l));var h=l+a.value>e.length?e.length:l+a.value,f=e.subarray(l,h);Oe(t[0],r.bytes)&&(t.length===1?i.push(f):i=i.concat(s(f,t.slice(1))));var m=r.length+a.length+f.length;n+=m}return i},lT=ie([0,0,0,1]),uT=ie([0,0,1]),cT=ie([0,0,3]),dT=function(e){for(var t=[],i=1;i<e.length-2;)Oe(e.subarray(i,i+3),cT)&&(t.push(i+2),i++),i++;if(t.length===0)return e;var n=e.length-t.length,r=new Uint8Array(n),a=0;for(i=0;i<n;a++,i++)a===t[0]&&(a++,t.shift()),r[i]=e[a];return r},_d=function(e,t,i,n){e=ie(e),i=[].concat(i);for(var r=0,a,l=0;r<e.length&&(l<n||a);){var h=void 0;if(Oe(e.subarray(r),lT)?h=4:Oe(e.subarray(r),uT)&&(h=3),!h){r++;continue}if(l++,a)return dT(e.subarray(a,r));var f=void 0;t==="h264"?f=e[r+h]&31:t==="h265"&&(f=e[r+h]>>1&63),i.indexOf(f)!==-1&&(a=r+h),r+=h+(t==="h264"?1:2)}return e.subarray(0,0)},hT=function(e,t,i){return _d(e,"h264",t,i)},fT=function(e,t,i){return _d(e,"h265",t,i)},nt={webm:ie([119,101,98,109]),matroska:ie([109,97,116,114,111,115,107,97]),flac:ie([102,76,97,67]),ogg:ie([79,103,103,83]),ac3:ie([11,119]),riff:ie([82,73,70,70]),avi:ie([65,86,73]),wav:ie([87,65,86,69]),"3gp":ie([102,116,121,112,51,103]),mp4:ie([102,116,121,112]),fmp4:ie([115,116,121,112]),mov:ie([102,116,121,112,113,116]),moov:ie([109,111,111,118]),moof:ie([109,111,111,102])},gs={aac:function(e){var t=on(e);return Oe(e,[255,16],{offset:t,mask:[255,22]})},mp3:function(e){var t=on(e);return Oe(e,[255,2],{offset:t,mask:[255,6]})},webm:function(e){var t=Lu(e,[er.EBML,er.DocType])[0];return Oe(t,nt.webm)},mkv:function(e){var t=Lu(e,[er.EBML,er.DocType])[0];return Oe(t,nt.matroska)},mp4:function(e){if(gs["3gp"](e)||gs.mov(e))return!1;if(Oe(e,nt.mp4,{offset:4})||Oe(e,nt.fmp4,{offset:4})||Oe(e,nt.moof,{offset:4})||Oe(e,nt.moov,{offset:4}))return!0},mov:function(e){return Oe(e,nt.mov,{offset:4})},"3gp":function(e){return Oe(e,nt["3gp"],{offset:4})},ac3:function(e){var t=on(e);return Oe(e,nt.ac3,{offset:t})},ts:function(e){if(e.length<189&&e.length>=1)return e[0]===71;for(var t=0;t+188<e.length&&t<188;){if(e[t]===71&&e[t+188]===71)return!0;t+=1}return!1},flac:function(e){var t=on(e);return Oe(e,nt.flac,{offset:t})},ogg:function(e){return Oe(e,nt.ogg)},avi:function(e){return Oe(e,nt.riff)&&Oe(e,nt.avi,{offset:8})},wav:function(e){return Oe(e,nt.riff)&&Oe(e,nt.wav,{offset:8})},h264:function(e){return hT(e,7,3).length},h265:function(e){return fT(e,[32,33],3).length}},Qa=Object.keys(gs).filter(function(s){return s!=="ts"&&s!=="h264"&&s!=="h265"}).concat(["ts","h264","h265"]);Qa.forEach(function(s){var e=gs[s];gs[s]=function(t){return e(ie(t))}});var pT=gs,Oo=function(e){e=ie(e);for(var t=0;t<Qa.length;t++){var i=Qa[t];if(pT[i](e))return i}return""},mT=function(e){return nT(e,["moof"]).length>0},Ro=9e4,Mo,No,jr,Uo,Td,vd,bd;Mo=function(s){return s*Ro};No=function(s,e){return s*e};jr=function(s){return s/Ro};Uo=function(s,e){return s/e};Td=function(s,e){return Mo(Uo(s,e))};vd=function(s,e){return No(jr(s),e)};bd=function(s,e,t){return jr(t?s:s-e)};var Ni={ONE_SECOND_IN_TS:Ro,secondsToVideoTs:Mo,secondsToAudioTs:No,videoTsToSeconds:jr,audioTsToSeconds:Uo,audioTsToVideoTs:Td,videoTsToAudioTs:vd,metadataTsToSeconds:bd},Ja="8.21.0";const ni={},Si=function(s,e){return ni[s]=ni[s]||[],e&&(ni[s]=ni[s].concat(e)),ni[s]},gT=function(s,e){Si(s,e)},xd=function(s,e){const t=Si(s).indexOf(e);return t<=-1?!1:(ni[s]=ni[s].slice(),ni[s].splice(t,1),!0)},yT=function(s,e){Si(s,[].concat(e).map(t=>{const i=(...n)=>(xd(s,i),t(...n));return i}))},hr={prefixed:!0},ar=[["requestFullscreen","exitFullscreen","fullscreenElement","fullscreenEnabled","fullscreenchange","fullscreenerror","fullscreen"],["webkitRequestFullscreen","webkitExitFullscreen","webkitFullscreenElement","webkitFullscreenEnabled","webkitfullscreenchange","webkitfullscreenerror","-webkit-full-screen"]],Ou=ar[0];let ln;for(let s=0;s<ar.length;s++)if(ar[s][1]in K){ln=ar[s];break}if(ln){for(let s=0;s<ln.length;s++)hr[Ou[s]]=ln[s];hr.prefixed=ln[0]!==Ou[0]}let ct=[];const _T=(s,e,t)=>(i,n,r)=>{const a=e.levels[n],l=new RegExp(`^(${a})$`);let h=s;if(i!=="log"&&r.unshift(i.toUpperCase()+":"),t&&(h=`%c${s}`,r.unshift(t)),r.unshift(h+":"),ct){ct.push([].concat(r));const m=ct.length-1e3;ct.splice(0,m>0?m:0)}if(!k.console)return;let f=k.console[i];!f&&i==="debug"&&(f=k.console.info||k.console.log),!(!f||!a||!l.test(i))&&f[Array.isArray(r)?"apply":"call"](k.console,r)};function Za(s,e=":",t=""){let i="info",n;function r(...a){n("log",i,a)}return n=_T(s,r,t),r.createLogger=(a,l,h)=>{const f=l!==void 0?l:e,m=h!==void 0?h:t,T=`${s} ${f} ${a}`;return Za(T,f,m)},r.createNewLogger=(a,l,h)=>Za(a,l,h),r.levels={all:"debug|log|warn|error",off:"",debug:"debug|log|warn|error",info:"log|warn|error",warn:"warn|error",error:"error",DEFAULT:i},r.level=a=>{if(typeof a=="string"){if(!r.levels.hasOwnProperty(a))throw new Error(`"${a}" in not a valid log level`);i=a}return i},r.history=()=>ct?[].concat(ct):[],r.history.filter=a=>(ct||[]).filter(l=>new RegExp(`.*${a}.*`).test(l[0])),r.history.clear=()=>{ct&&(ct.length=0)},r.history.disable=()=>{ct!==null&&(ct.length=0,ct=null)},r.history.enable=()=>{ct===null&&(ct=[])},r.error=(...a)=>n("error",i,a),r.warn=(...a)=>n("warn",i,a),r.debug=(...a)=>n("debug",i,a),r}const ue=Za("VIDEOJS"),Sd=ue.createLogger,TT=Object.prototype.toString,Ed=function(s){return Zt(s)?Object.keys(s):[]};function rs(s,e){Ed(s).forEach(t=>e(s[t],t))}function Cd(s,e,t=0){return Ed(s).reduce((i,n)=>e(i,s[n],n),t)}function Zt(s){return!!s&&typeof s=="object"}function ys(s){return Zt(s)&&TT.call(s)==="[object Object]"&&s.constructor===Object}function xe(...s){const e={};return s.forEach(t=>{t&&rs(t,(i,n)=>{if(!ys(i)){e[n]=i;return}ys(e[n])||(e[n]={}),e[n]=xe(e[n],i)})}),e}function wd(s={}){const e=[];for(const t in s)if(s.hasOwnProperty(t)){const i=s[t];e.push(i)}return e}function Vr(s,e,t,i=!0){const n=a=>Object.defineProperty(s,e,{value:a,enumerable:!0,writable:!0}),r={configurable:!0,enumerable:!0,get(){const a=t();return n(a),a}};return i&&(r.set=n),Object.defineProperty(s,e,r)}var vT=Object.freeze({__proto__:null,each:rs,reduce:Cd,isObject:Zt,isPlain:ys,merge:xe,values:wd,defineLazyProperty:Vr});let Bo=!1,Id=null,Ut=!1,Ad,kd=!1,as=!1,os=!1,ei=!1,Fo=null,Hr=null;const bT=!!(k.cast&&k.cast.framework&&k.cast.framework.CastReceiverContext);let Pd=null,fr=!1,qr=!1,pr=!1,zr=!1,mr=!1,gr=!1,yr=!1;const _n=!!(Es()&&("ontouchstart"in k||k.navigator.maxTouchPoints||k.DocumentTouch&&k.document instanceof k.DocumentTouch)),_i=k.navigator&&k.navigator.userAgentData;_i&&_i.platform&&_i.brands&&(Ut=_i.platform==="Android",as=!!_i.brands.find(s=>s.brand==="Microsoft Edge"),os=!!_i.brands.find(s=>s.brand==="Chromium"),ei=!as&&os,Fo=Hr=(_i.brands.find(s=>s.brand==="Chromium")||{}).version||null,qr=_i.platform==="Windows");if(!os){const s=k.navigator&&k.navigator.userAgent||"";Bo=/iPod/i.test(s),Id=function(){const e=s.match(/OS (\d+)_/i);return e&&e[1]?e[1]:null}(),Ut=/Android/i.test(s),Ad=function(){const e=s.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(!e)return null;const t=e[1]&&parseFloat(e[1]),i=e[2]&&parseFloat(e[2]);return t&&i?parseFloat(e[1]+"."+e[2]):t||null}(),kd=/Firefox/i.test(s),as=/Edg/i.test(s),os=/Chrome/i.test(s)||/CriOS/i.test(s),ei=!as&&os,Fo=Hr=function(){const e=s.match(/(Chrome|CriOS)\/(\d+)/);return e&&e[2]?parseFloat(e[2]):null}(),Pd=function(){const e=/MSIE\s(\d+)\.\d/.exec(s);let t=e&&parseFloat(e[1]);return!t&&/Trident\/7.0/i.test(s)&&/rv:11.0/.test(s)&&(t=11),t}(),mr=/Tizen/i.test(s),gr=/Web0S/i.test(s),yr=mr||gr,fr=/Safari/i.test(s)&&!ei&&!Ut&&!as&&!yr,qr=/Windows/i.test(s),pr=/iPad/i.test(s)||fr&&_n&&!/iPhone/i.test(s),zr=/iPhone/i.test(s)&&!pr}const Ze=zr||pr||Bo,Wr=(fr||Ze)&&!ei;var Dd=Object.freeze({__proto__:null,get IS_IPOD(){return Bo},get IOS_VERSION(){return Id},get IS_ANDROID(){return Ut},get ANDROID_VERSION(){return Ad},get IS_FIREFOX(){return kd},get IS_EDGE(){return as},get IS_CHROMIUM(){return os},get IS_CHROME(){return ei},get CHROMIUM_VERSION(){return Fo},get CHROME_VERSION(){return Hr},IS_CHROMECAST_RECEIVER:bT,get IE_VERSION(){return Pd},get IS_SAFARI(){return fr},get IS_WINDOWS(){return qr},get IS_IPAD(){return pr},get IS_IPHONE(){return zr},get IS_TIZEN(){return mr},get IS_WEBOS(){return gr},get IS_SMART_TV(){return yr},TOUCH_ENABLED:_n,IS_IOS:Ze,IS_ANY_SAFARI:Wr});function Ru(s){return typeof s=="string"&&!!s.trim()}function xT(s){if(s.indexOf(" ")>=0)throw new Error("class has illegal whitespace characters")}function Es(){return K===k.document}function Cs(s){return Zt(s)&&s.nodeType===1}function Ld(){try{return k.parent!==k.self}catch{return!0}}function Od(s){return function(e,t){if(!Ru(e))return K[s](null);Ru(t)&&(t=K.querySelector(t));const i=Cs(t)?t:K;return i[s]&&i[s](e)}}function se(s="div",e={},t={},i){const n=K.createElement(s);return Object.getOwnPropertyNames(e).forEach(function(r){const a=e[r];r==="textContent"?Ci(n,a):(n[r]!==a||r==="tabIndex")&&(n[r]=a)}),Object.getOwnPropertyNames(t).forEach(function(r){n.setAttribute(r,t[r])}),i&&$o(n,i),n}function Ci(s,e){return typeof s.textContent>"u"?s.innerText=e:s.textContent=e,s}function eo(s,e){e.firstChild?e.insertBefore(s,e.firstChild):e.appendChild(s)}function hn(s,e){return xT(e),s.classList.contains(e)}function Fi(s,...e){return s.classList.add(...e.reduce((t,i)=>t.concat(i.split(/\s+/)),[])),s}function Gr(s,...e){return s?(s.classList.remove(...e.reduce((t,i)=>t.concat(i.split(/\s+/)),[])),s):(ue.warn("removeClass was called with an element that doesn't exist"),null)}function Rd(s,e,t){return typeof t=="function"&&(t=t(s,e)),typeof t!="boolean"&&(t=void 0),e.split(/\s+/).forEach(i=>s.classList.toggle(i,t)),s}function Md(s,e){Object.getOwnPropertyNames(e).forEach(function(t){const i=e[t];i===null||typeof i>"u"||i===!1?s.removeAttribute(t):s.setAttribute(t,i===!0?"":i)})}function bi(s){const e={},t=["autoplay","controls","playsinline","loop","muted","default","defaultMuted"];if(s&&s.attributes&&s.attributes.length>0){const i=s.attributes;for(let n=i.length-1;n>=0;n--){const r=i[n].name;let a=i[n].value;t.includes(r)&&(a=a!==null),e[r]=a}}return e}function Nd(s,e){return s.getAttribute(e)}function _s(s,e,t){s.setAttribute(e,t)}function Kr(s,e){s.removeAttribute(e)}function Ud(){K.body.focus(),K.onselectstart=function(){return!1}}function Bd(){K.onselectstart=function(){return!0}}function Ts(s){if(s&&s.getBoundingClientRect&&s.parentNode){const e=s.getBoundingClientRect(),t={};return["bottom","height","left","right","top","width"].forEach(i=>{e[i]!==void 0&&(t[i]=e[i])}),t.height||(t.height=parseFloat(vs(s,"height"))),t.width||(t.width=parseFloat(vs(s,"width"))),t}}function Tn(s){if(!s||s&&!s.offsetParent)return{left:0,top:0,width:0,height:0};const e=s.offsetWidth,t=s.offsetHeight;let i=0,n=0;for(;s.offsetParent&&s!==K[hr.fullscreenElement];)i+=s.offsetLeft,n+=s.offsetTop,s=s.offsetParent;return{left:i,top:n,width:e,height:t}}function Xr(s,e){const t={x:0,y:0};if(Ze){let m=s;for(;m&&m.nodeName.toLowerCase()!=="html";){const T=vs(m,"transform");if(/^matrix/.test(T)){const E=T.slice(7,-1).split(/,\s/).map(Number);t.x+=E[4],t.y+=E[5]}else if(/^matrix3d/.test(T)){const E=T.slice(9,-1).split(/,\s/).map(Number);t.x+=E[12],t.y+=E[13]}if(m.assignedSlot&&m.assignedSlot.parentElement&&k.WebKitCSSMatrix){const E=k.getComputedStyle(m.assignedSlot.parentElement).transform,C=new k.WebKitCSSMatrix(E);t.x+=C.m41,t.y+=C.m42}m=m.parentNode||m.host}}const i={},n=Tn(e.target),r=Tn(s),a=r.width,l=r.height;let h=e.offsetY-(r.top-n.top),f=e.offsetX-(r.left-n.left);return e.changedTouches&&(f=e.changedTouches[0].pageX-r.left,h=e.changedTouches[0].pageY+r.top,Ze&&(f-=t.x,h-=t.y)),i.y=1-Math.max(0,Math.min(1,h/l)),i.x=Math.max(0,Math.min(1,f/a)),i}function Fd(s){return Zt(s)&&s.nodeType===3}function Yr(s){for(;s.firstChild;)s.removeChild(s.firstChild);return s}function $d(s){return typeof s=="function"&&(s=s()),(Array.isArray(s)?s:[s]).map(e=>{if(typeof e=="function"&&(e=e()),Cs(e)||Fd(e))return e;if(typeof e=="string"&&/\S/.test(e))return K.createTextNode(e)}).filter(e=>e)}function $o(s,e){return $d(e).forEach(t=>s.appendChild(t)),s}function jd(s,e){return $o(Yr(s),e)}function vn(s){return s.button===void 0&&s.buttons===void 0||s.button===0&&s.buttons===void 0||s.type==="mouseup"&&s.button===0&&s.buttons===0||s.type==="mousedown"&&s.button===0&&s.buttons===0?!0:!(s.button!==0||s.buttons!==1)}const Ei=Od("querySelector"),Vd=Od("querySelectorAll");function vs(s,e){if(!s||!e)return"";if(typeof k.getComputedStyle=="function"){let t;try{t=k.getComputedStyle(s)}catch{return""}return t?t.getPropertyValue(e)||t[e]:""}return""}function Hd(s){[...K.styleSheets].forEach(e=>{try{const t=[...e.cssRules].map(n=>n.cssText).join(""),i=K.createElement("style");i.textContent=t,s.document.head.appendChild(i)}catch{const i=K.createElement("link");i.rel="stylesheet",i.type=e.type,i.media=e.media.mediaText,i.href=e.href,s.document.head.appendChild(i)}})}var qd=Object.freeze({__proto__:null,isReal:Es,isEl:Cs,isInFrame:Ld,createEl:se,textContent:Ci,prependTo:eo,hasClass:hn,addClass:Fi,removeClass:Gr,toggleClass:Rd,setAttributes:Md,getAttributes:bi,getAttribute:Nd,setAttribute:_s,removeAttribute:Kr,blockTextSelection:Ud,unblockTextSelection:Bd,getBoundingClientRect:Ts,findPosition:Tn,getPointerPosition:Xr,isTextNode:Fd,emptyEl:Yr,normalizeContent:$d,appendContent:$o,insertContent:jd,isSingleLeftClick:vn,$:Ei,$$:Vd,computedStyle:vs,copyStyleSheetsToWindow:Hd});let zd=!1,to;const ST=function(){if(to.options.autoSetup===!1)return;const s=Array.prototype.slice.call(K.getElementsByTagName("video")),e=Array.prototype.slice.call(K.getElementsByTagName("audio")),t=Array.prototype.slice.call(K.getElementsByTagName("video-js")),i=s.concat(e,t);if(i&&i.length>0)for(let n=0,r=i.length;n<r;n++){const a=i[n];if(a&&a.getAttribute)a.player===void 0&&a.getAttribute("data-setup")!==null&&to(a);else{io(1);break}}else zd||io(1)};function io(s,e){Es()&&(e&&(to=e),k.setTimeout(ST,s))}function so(){zd=!0,k.removeEventListener("load",so)}Es()&&(K.readyState==="complete"?so():k.addEventListener("load",so));const Wd=function(s){const e=K.createElement("style");return e.className=s,e},Gd=function(s,e){s.styleSheet?s.styleSheet.cssText=e:s.textContent=e};var ot=new WeakMap;const ET=3;let CT=ET;function At(){return CT++}function Mu(s,e){if(!ot.has(s))return;const t=ot.get(s);t.handlers[e].length===0&&(delete t.handlers[e],s.removeEventListener?s.removeEventListener(e,t.dispatcher,!1):s.detachEvent&&s.detachEvent("on"+e,t.dispatcher)),Object.getOwnPropertyNames(t.handlers).length<=0&&(delete t.handlers,delete t.dispatcher,delete t.disabled),Object.getOwnPropertyNames(t).length===0&&ot.delete(s)}function jo(s,e,t,i){t.forEach(function(n){s(e,n,i)})}function Qr(s){if(s.fixed_)return s;function e(){return!0}function t(){return!1}if(!s||!s.isPropagationStopped||!s.isImmediatePropagationStopped){const i=s||k.event;s={};const n=["layerX","layerY","keyLocation","path","webkitMovementX","webkitMovementY","mozPressure","mozInputSource"];for(const r in i)n.includes(r)||r==="returnValue"&&i.preventDefault||(s[r]=i[r]);if(s.target||(s.target=s.srcElement||K),s.relatedTarget||(s.relatedTarget=s.fromElement===s.target?s.toElement:s.fromElement),s.preventDefault=function(){i.preventDefault&&i.preventDefault(),s.returnValue=!1,i.returnValue=!1,s.defaultPrevented=!0},s.defaultPrevented=!1,s.stopPropagation=function(){i.stopPropagation&&i.stopPropagation(),s.cancelBubble=!0,i.cancelBubble=!0,s.isPropagationStopped=e},s.isPropagationStopped=t,s.stopImmediatePropagation=function(){i.stopImmediatePropagation&&i.stopImmediatePropagation(),s.isImmediatePropagationStopped=e,s.stopPropagation()},s.isImmediatePropagationStopped=t,s.clientX!==null&&s.clientX!==void 0){const r=K.documentElement,a=K.body;s.pageX=s.clientX+(r&&r.scrollLeft||a&&a.scrollLeft||0)-(r&&r.clientLeft||a&&a.clientLeft||0),s.pageY=s.clientY+(r&&r.scrollTop||a&&a.scrollTop||0)-(r&&r.clientTop||a&&a.clientTop||0)}s.which=s.charCode||s.keyCode,s.button!==null&&s.button!==void 0&&(s.button=s.button&1?0:s.button&4?1:s.button&2?2:0)}return s.fixed_=!0,s}let tr;const wT=function(){if(typeof tr!="boolean"){tr=!1;try{const s=Object.defineProperty({},"passive",{get(){tr=!0}});k.addEventListener("test",null,s),k.removeEventListener("test",null,s)}catch{}}return tr},IT=["touchstart","touchmove"];function vt(s,e,t){if(Array.isArray(e))return jo(vt,s,e,t);ot.has(s)||ot.set(s,{});const i=ot.get(s);if(i.handlers||(i.handlers={}),i.handlers[e]||(i.handlers[e]=[]),t.guid||(t.guid=At()),i.handlers[e].push(t),i.dispatcher||(i.disabled=!1,i.dispatcher=function(n,r){if(i.disabled)return;n=Qr(n);const a=i.handlers[n.type];if(a){const l=a.slice(0);for(let h=0,f=l.length;h<f&&!n.isImmediatePropagationStopped();h++)try{l[h].call(s,n,r)}catch(m){ue.error(m)}}}),i.handlers[e].length===1)if(s.addEventListener){let n=!1;wT()&&IT.indexOf(e)>-1&&(n={passive:!0}),s.addEventListener(e,i.dispatcher,n)}else s.attachEvent&&s.attachEvent("on"+e,i.dispatcher)}function et(s,e,t){if(!ot.has(s))return;const i=ot.get(s);if(!i.handlers)return;if(Array.isArray(e))return jo(et,s,e,t);const n=function(a,l){i.handlers[l]=[],Mu(a,l)};if(e===void 0){for(const a in i.handlers)Object.prototype.hasOwnProperty.call(i.handlers||{},a)&&n(s,a);return}const r=i.handlers[e];if(r){if(!t){n(s,e);return}if(t.guid)for(let a=0;a<r.length;a++)r[a].guid===t.guid&&r.splice(a--,1);Mu(s,e)}}function ws(s,e,t){const i=ot.has(s)?ot.get(s):{},n=s.parentNode||s.ownerDocument;if(typeof e=="string"?e={type:e,target:s}:e.target||(e.target=s),e=Qr(e),i.dispatcher&&i.dispatcher.call(s,e,t),n&&!e.isPropagationStopped()&&e.bubbles===!0)ws.call(null,n,e,t);else if(!n&&!e.defaultPrevented&&e.target&&e.target[e.type]){ot.has(e.target)||ot.set(e.target,{});const r=ot.get(e.target);e.target[e.type]&&(r.disabled=!0,typeof e.target[e.type]=="function"&&e.target[e.type](),r.disabled=!1)}return!e.defaultPrevented}function Jr(s,e,t){if(Array.isArray(e))return jo(Jr,s,e,t);const i=function(){et(s,e,i),t.apply(this,arguments)};i.guid=t.guid=t.guid||At(),vt(s,e,i)}function Vo(s,e,t){const i=function(){et(s,e,i),t.apply(this,arguments)};i.guid=t.guid=t.guid||At(),vt(s,e,i)}var AT=Object.freeze({__proto__:null,fixEvent:Qr,on:vt,off:et,trigger:ws,one:Jr,any:Vo});const kt=30,we=function(s,e,t){e.guid||(e.guid=At());const i=e.bind(s);return i.guid=t?t+"_"+e.guid:e.guid,i},ti=function(s,e){let t=k.performance.now();return function(...n){const r=k.performance.now();r-t>=e&&(s(...n),t=r)}},Kd=function(s,e,t,i=k){let n;const r=()=>{i.clearTimeout(n),n=null},a=function(){const l=this,h=arguments;let f=function(){n=null,f=null,t||s.apply(l,h)};!n&&t&&s.apply(l,h),i.clearTimeout(n),n=i.setTimeout(f,e)};return a.cancel=r,a};var kT=Object.freeze({__proto__:null,UPDATE_REFRESH_INTERVAL:kt,bind_:we,throttle:ti,debounce:Kd});let Zs;class bt{on(e,t){const i=this.addEventListener;this.addEventListener=()=>{},vt(this,e,t),this.addEventListener=i}off(e,t){et(this,e,t)}one(e,t){const i=this.addEventListener;this.addEventListener=()=>{},Jr(this,e,t),this.addEventListener=i}any(e,t){const i=this.addEventListener;this.addEventListener=()=>{},Vo(this,e,t),this.addEventListener=i}trigger(e){const t=e.type||e;typeof e=="string"&&(e={type:t}),e=Qr(e),this.allowedEvents_[t]&&this["on"+t]&&this["on"+t](e),ws(this,e)}queueTrigger(e){Zs||(Zs=new Map);const t=e.type||e;let i=Zs.get(this);i||(i=new Map,Zs.set(this,i));const n=i.get(t);i.delete(t),k.clearTimeout(n);const r=k.setTimeout(()=>{i.delete(t),i.size===0&&(i=null,Zs.delete(this)),this.trigger(e)},0);i.set(t,r)}}bt.prototype.allowedEvents_={};bt.prototype.addEventListener=bt.prototype.on;bt.prototype.removeEventListener=bt.prototype.off;bt.prototype.dispatchEvent=bt.prototype.trigger;const Zr=s=>typeof s.name=="function"?s.name():typeof s.name=="string"?s.name:s.name_?s.name_:s.constructor&&s.constructor.name?s.constructor.name:typeof s,ai=s=>s instanceof bt||!!s.eventBusEl_&&["on","one","off","trigger"].every(e=>typeof s[e]=="function"),PT=(s,e)=>{ai(s)?e():(s.eventedCallbacks||(s.eventedCallbacks=[]),s.eventedCallbacks.push(e))},no=s=>typeof s=="string"&&/\S/.test(s)||Array.isArray(s)&&!!s.length,_r=(s,e,t)=>{if(!s||!s.nodeName&&!ai(s))throw new Error(`Invalid target for ${Zr(e)}#${t}; must be a DOM node or evented object.`)},Xd=(s,e,t)=>{if(!no(s))throw new Error(`Invalid event type for ${Zr(e)}#${t}; must be a non-empty string or array.`)},Yd=(s,e,t)=>{if(typeof s!="function")throw new Error(`Invalid listener for ${Zr(e)}#${t}; must be a function.`)},Ra=(s,e,t)=>{const i=e.length<3||e[0]===s||e[0]===s.eventBusEl_;let n,r,a;return i?(n=s.eventBusEl_,e.length>=3&&e.shift(),[r,a]=e):(n=e[0],r=e[1],a=e[2]),_r(n,s,t),Xd(r,s,t),Yd(a,s,t),a=we(s,a),{isTargetingSelf:i,target:n,type:r,listener:a}},Oi=(s,e,t,i)=>{_r(s,s,e),s.nodeName?AT[e](s,t,i):s[e](t,i)},DT={on(...s){const{isTargetingSelf:e,target:t,type:i,listener:n}=Ra(this,s,"on");if(Oi(t,"on",i,n),!e){const r=()=>this.off(t,i,n);r.guid=n.guid;const a=()=>this.off("dispose",r);a.guid=n.guid,Oi(this,"on","dispose",r),Oi(t,"on","dispose",a)}},one(...s){const{isTargetingSelf:e,target:t,type:i,listener:n}=Ra(this,s,"one");if(e)Oi(t,"one",i,n);else{const r=(...a)=>{this.off(t,i,r),n.apply(null,a)};r.guid=n.guid,Oi(t,"one",i,r)}},any(...s){const{isTargetingSelf:e,target:t,type:i,listener:n}=Ra(this,s,"any");if(e)Oi(t,"any",i,n);else{const r=(...a)=>{this.off(t,i,r),n.apply(null,a)};r.guid=n.guid,Oi(t,"any",i,r)}},off(s,e,t){if(!s||no(s))et(this.eventBusEl_,s,e);else{const i=s,n=e;_r(i,this,"off"),Xd(n,this,"off"),Yd(t,this,"off"),t=we(this,t),this.off("dispose",t),i.nodeName?(et(i,n,t),et(i,"dispose",t)):ai(i)&&(i.off(n,t),i.off("dispose",t))}},trigger(s,e){_r(this.eventBusEl_,this,"trigger");const t=s&&typeof s!="string"?s.type:s;if(!no(t))throw new Error(`Invalid event type for ${Zr(this)}#trigger; must be a non-empty string or object with a type key that has a non-empty value.`);return ws(this.eventBusEl_,s,e)}};function Ho(s,e={}){const{eventBusKey:t}=e;if(t){if(!s[t].nodeName)throw new Error(`The eventBusKey "${t}" does not refer to an element.`);s.eventBusEl_=s[t]}else s.eventBusEl_=se("span",{className:"vjs-event-bus"});return Object.assign(s,DT),s.eventedCallbacks&&s.eventedCallbacks.forEach(i=>{i()}),s.on("dispose",()=>{s.off(),[s,s.el_,s.eventBusEl_].forEach(function(i){i&&ot.has(i)&&ot.delete(i)}),k.setTimeout(()=>{s.eventBusEl_=null},0)}),s}const LT={state:{},setState(s){typeof s=="function"&&(s=s());let e;return rs(s,(t,i)=>{this.state[i]!==t&&(e=e||{},e[i]={from:this.state[i],to:t}),this.state[i]=t}),e&&ai(this)&&this.trigger({changes:e,type:"statechanged"}),e}};function Qd(s,e){return Object.assign(s,LT),s.state=Object.assign({},s.state,e),typeof s.handleStateChanged=="function"&&ai(s)&&s.on("statechanged",s.handleStateChanged),s}const fn=function(s){return typeof s!="string"?s:s.replace(/./,e=>e.toLowerCase())},Be=function(s){return typeof s!="string"?s:s.replace(/./,e=>e.toUpperCase())},Jd=function(s,e){return Be(s)===Be(e)};var OT=Object.freeze({__proto__:null,toLowerCase:fn,toTitleCase:Be,titleCaseEquals:Jd});class H{constructor(e,t,i){if(!e&&this.play?this.player_=e=this:this.player_=e,this.isDisposed_=!1,this.parentComponent_=null,this.options_=xe({},this.options_),t=this.options_=xe(this.options_,t),this.id_=t.id||t.el&&t.el.id,!this.id_){const n=e&&e.id&&e.id()||"no_player";this.id_=`${n}_component_${At()}`}this.name_=t.name||null,t.el?this.el_=t.el:t.createEl!==!1&&(this.el_=this.createEl()),t.className&&this.el_&&t.className.split(" ").forEach(n=>this.addClass(n)),["on","off","one","any","trigger"].forEach(n=>{this[n]=void 0}),t.evented!==!1&&(Ho(this,{eventBusKey:this.el_?"el_":null}),this.handleLanguagechange=this.handleLanguagechange.bind(this),this.on(this.player_,"languagechange",this.handleLanguagechange)),Qd(this,this.constructor.defaultState),this.children_=[],this.childIndex_={},this.childNameIndex_={},this.setTimeoutIds_=new Set,this.setIntervalIds_=new Set,this.rafIds_=new Set,this.namedRafs_=new Map,this.clearingTimersOnDispose_=!1,t.initChildren!==!1&&this.initChildren(),this.ready(i),t.reportTouchActivity!==!1&&this.enableTouchActivity()}dispose(e={}){if(!this.isDisposed_){if(this.readyQueue_&&(this.readyQueue_.length=0),this.trigger({type:"dispose",bubbles:!1}),this.isDisposed_=!0,this.children_)for(let t=this.children_.length-1;t>=0;t--)this.children_[t].dispose&&this.children_[t].dispose();this.children_=null,this.childIndex_=null,this.childNameIndex_=null,this.parentComponent_=null,this.el_&&(this.el_.parentNode&&(e.restoreEl?this.el_.parentNode.replaceChild(e.restoreEl,this.el_):this.el_.parentNode.removeChild(this.el_)),this.el_=null),this.player_=null}}isDisposed(){return!!this.isDisposed_}player(){return this.player_}options(e){return e?(this.options_=xe(this.options_,e),this.options_):this.options_}el(){return this.el_}createEl(e,t,i){return se(e,t,i)}localize(e,t,i=e){const n=this.player_.language&&this.player_.language(),r=this.player_.languages&&this.player_.languages(),a=r&&r[n],l=n&&n.split("-")[0],h=r&&r[l];let f=i;return a&&a[e]?f=a[e]:h&&h[e]&&(f=h[e]),t&&(f=f.replace(/\{(\d+)\}/g,function(m,T){const E=t[T-1];let C=E;return typeof E>"u"&&(C=m),C})),f}handleLanguagechange(){}contentEl(){return this.contentEl_||this.el_}id(){return this.id_}name(){return this.name_}children(){return this.children_}getChildById(e){return this.childIndex_[e]}getChild(e){if(e)return this.childNameIndex_[e]}getDescendant(...e){e=e.reduce((i,n)=>i.concat(n),[]);let t=this;for(let i=0;i<e.length;i++)if(t=t.getChild(e[i]),!t||!t.getChild)return;return t}setIcon(e,t=this.el()){if(!this.player_.options_.experimentalSvgIcons)return;const i="http://www.w3.org/2000/svg",n=se("span",{className:"vjs-icon-placeholder vjs-svg-icon"},{"aria-hidden":"true"}),r=K.createElementNS(i,"svg");r.setAttributeNS(null,"viewBox","0 0 512 512");const a=K.createElementNS(i,"use");return r.appendChild(a),a.setAttributeNS(null,"href",`#vjs-icon-${e}`),n.appendChild(r),this.iconIsSet_?t.replaceChild(n,t.querySelector(".vjs-icon-placeholder")):t.appendChild(n),this.iconIsSet_=!0,n}addChild(e,t={},i=this.children_.length){let n,r;if(typeof e=="string"){r=Be(e);const a=t.componentClass||r;t.name=r;const l=H.getComponent(a);if(!l)throw new Error(`Component ${a} does not exist`);if(typeof l!="function")return null;n=new l(this.player_||this,t)}else n=e;if(n.parentComponent_&&n.parentComponent_.removeChild(n),this.children_.splice(i,0,n),n.parentComponent_=this,typeof n.id=="function"&&(this.childIndex_[n.id()]=n),r=r||n.name&&Be(n.name()),r&&(this.childNameIndex_[r]=n,this.childNameIndex_[fn(r)]=n),typeof n.el=="function"&&n.el()){let a=null;this.children_[i+1]&&(this.children_[i+1].el_?a=this.children_[i+1].el_:Cs(this.children_[i+1])&&(a=this.children_[i+1])),this.contentEl().insertBefore(n.el(),a)}return n}removeChild(e){if(typeof e=="string"&&(e=this.getChild(e)),!e||!this.children_)return;let t=!1;for(let n=this.children_.length-1;n>=0;n--)if(this.children_[n]===e){t=!0,this.children_.splice(n,1);break}if(!t)return;e.parentComponent_=null,this.childIndex_[e.id()]=null,this.childNameIndex_[Be(e.name())]=null,this.childNameIndex_[fn(e.name())]=null;const i=e.el();i&&i.parentNode===this.contentEl()&&this.contentEl().removeChild(e.el())}initChildren(){const e=this.options_.children;if(e){const t=this.options_,i=a=>{const l=a.name;let h=a.opts;if(t[l]!==void 0&&(h=t[l]),h===!1)return;h===!0&&(h={}),h.playerOptions=this.options_.playerOptions;const f=this.addChild(l,h);f&&(this[l]=f)};let n;const r=H.getComponent("Tech");Array.isArray(e)?n=e:n=Object.keys(e),n.concat(Object.keys(this.options_).filter(function(a){return!n.some(function(l){return typeof l=="string"?a===l:a===l.name})})).map(a=>{let l,h;return typeof a=="string"?(l=a,h=e[l]||this.options_[l]||{}):(l=a.name,h=a),{name:l,opts:h}}).filter(a=>{const l=H.getComponent(a.opts.componentClass||Be(a.name));return l&&!r.isTech(l)}).forEach(i)}}buildCSSClass(){return""}ready(e,t=!1){if(e){if(!this.isReady_){this.readyQueue_=this.readyQueue_||[],this.readyQueue_.push(e);return}t?e.call(this):this.setTimeout(e,1)}}triggerReady(){this.isReady_=!0,this.setTimeout(function(){const e=this.readyQueue_;this.readyQueue_=[],e&&e.length>0&&e.forEach(function(t){t.call(this)},this),this.trigger("ready")},1)}$(e,t){return Ei(e,t||this.contentEl())}$$(e,t){return Vd(e,t||this.contentEl())}hasClass(e){return hn(this.el_,e)}addClass(...e){Fi(this.el_,...e)}removeClass(...e){Gr(this.el_,...e)}toggleClass(e,t){Rd(this.el_,e,t)}show(){this.removeClass("vjs-hidden")}hide(){this.addClass("vjs-hidden")}lockShowing(){this.addClass("vjs-lock-showing")}unlockShowing(){this.removeClass("vjs-lock-showing")}getAttribute(e){return Nd(this.el_,e)}setAttribute(e,t){_s(this.el_,e,t)}removeAttribute(e){Kr(this.el_,e)}width(e,t){return this.dimension("width",e,t)}height(e,t){return this.dimension("height",e,t)}dimensions(e,t){this.width(e,!0),this.height(t)}dimension(e,t,i){if(t!==void 0){(t===null||t!==t)&&(t=0),(""+t).indexOf("%")!==-1||(""+t).indexOf("px")!==-1?this.el_.style[e]=t:t==="auto"?this.el_.style[e]="":this.el_.style[e]=t+"px",i||this.trigger("componentresize");return}if(!this.el_)return 0;const n=this.el_.style[e],r=n.indexOf("px");return parseInt(r!==-1?n.slice(0,r):this.el_["offset"+Be(e)],10)}currentDimension(e){let t=0;if(e!=="width"&&e!=="height")throw new Error("currentDimension only accepts width or height value");if(t=vs(this.el_,e),t=parseFloat(t),t===0||isNaN(t)){const i=`offset${Be(e)}`;t=this.el_[i]}return t}currentDimensions(){return{width:this.currentDimension("width"),height:this.currentDimension("height")}}currentWidth(){return this.currentDimension("width")}currentHeight(){return this.currentDimension("height")}getPositions(){const e=this.el_.getBoundingClientRect(),t={x:e.x,y:e.y,width:e.width,height:e.height,top:e.top,right:e.right,bottom:e.bottom,left:e.left},i={x:e.left+e.width/2,y:e.top+e.height/2,width:0,height:0,top:e.top+e.height/2,right:e.left+e.width/2,bottom:e.top+e.height/2,left:e.left+e.width/2};return{boundingClientRect:t,center:i}}focus(){this.el_.focus()}blur(){this.el_.blur()}handleKeyDown(e){this.player_&&(e.key!=="Tab"&&!(this.player_.options_.playerOptions.spatialNavigation&&this.player_.options_.playerOptions.spatialNavigation.enabled)&&e.stopPropagation(),this.player_.handleKeyDown(e))}handleKeyPress(e){this.handleKeyDown(e)}emitTapEvents(){let e=0,t=null;const i=10,n=200;let r;this.on("touchstart",function(l){l.touches.length===1&&(t={pageX:l.touches[0].pageX,pageY:l.touches[0].pageY},e=k.performance.now(),r=!0)}),this.on("touchmove",function(l){if(l.touches.length>1)r=!1;else if(t){const h=l.touches[0].pageX-t.pageX,f=l.touches[0].pageY-t.pageY;Math.sqrt(h*h+f*f)>i&&(r=!1)}});const a=function(){r=!1};this.on("touchleave",a),this.on("touchcancel",a),this.on("touchend",function(l){t=null,r===!0&&k.performance.now()-e<n&&(l.preventDefault(),this.trigger("tap"))})}enableTouchActivity(){if(!this.player()||!this.player().reportUserActivity)return;const e=we(this.player(),this.player().reportUserActivity);let t;this.on("touchstart",function(){e(),this.clearInterval(t),t=this.setInterval(e,250)});const i=function(n){e(),this.clearInterval(t)};this.on("touchmove",e),this.on("touchend",i),this.on("touchcancel",i)}setTimeout(e,t){var i;return e=we(this,e),this.clearTimersOnDispose_(),i=k.setTimeout(()=>{this.setTimeoutIds_.has(i)&&this.setTimeoutIds_.delete(i),e()},t),this.setTimeoutIds_.add(i),i}clearTimeout(e){return this.setTimeoutIds_.has(e)&&(this.setTimeoutIds_.delete(e),k.clearTimeout(e)),e}setInterval(e,t){e=we(this,e),this.clearTimersOnDispose_();const i=k.setInterval(e,t);return this.setIntervalIds_.add(i),i}clearInterval(e){return this.setIntervalIds_.has(e)&&(this.setIntervalIds_.delete(e),k.clearInterval(e)),e}requestAnimationFrame(e){this.clearTimersOnDispose_();var t;return e=we(this,e),t=k.requestAnimationFrame(()=>{this.rafIds_.has(t)&&this.rafIds_.delete(t),e()}),this.rafIds_.add(t),t}requestNamedAnimationFrame(e,t){this.namedRafs_.has(e)&&this.cancelNamedAnimationFrame(e),this.clearTimersOnDispose_(),t=we(this,t);const i=this.requestAnimationFrame(()=>{t(),this.namedRafs_.has(e)&&this.namedRafs_.delete(e)});return this.namedRafs_.set(e,i),e}cancelNamedAnimationFrame(e){this.namedRafs_.has(e)&&(this.cancelAnimationFrame(this.namedRafs_.get(e)),this.namedRafs_.delete(e))}cancelAnimationFrame(e){return this.rafIds_.has(e)&&(this.rafIds_.delete(e),k.cancelAnimationFrame(e)),e}clearTimersOnDispose_(){this.clearingTimersOnDispose_||(this.clearingTimersOnDispose_=!0,this.one("dispose",()=>{[["namedRafs_","cancelNamedAnimationFrame"],["rafIds_","cancelAnimationFrame"],["setTimeoutIds_","clearTimeout"],["setIntervalIds_","clearInterval"]].forEach(([e,t])=>{this[e].forEach((i,n)=>this[t](n))}),this.clearingTimersOnDispose_=!1}))}getIsDisabled(){return!!this.el_.disabled}getIsExpresslyInert(){return this.el_.inert&&!this.el_.ownerDocument.documentElement.inert}getIsFocusable(e){return(e||this.el_).tabIndex>=0&&!(this.getIsDisabled()||this.getIsExpresslyInert())}getIsAvailableToBeFocused(e){function t(r){const a=k.getComputedStyle(r,null),l=a.getPropertyValue("visibility");return a.getPropertyValue("display")!=="none"&&!["hidden","collapse"].includes(l)}function i(r){return!(!t(r.parentElement)||!t(r)||r.style.opacity==="0"||k.getComputedStyle(r).height==="0px"||k.getComputedStyle(r).width==="0px")}function n(r){if(r.offsetWidth+r.offsetHeight+r.getBoundingClientRect().height+r.getBoundingClientRect().width===0)return!1;const a={x:r.getBoundingClientRect().left+r.offsetWidth/2,y:r.getBoundingClientRect().top+r.offsetHeight/2};if(a.x<0||a.x>(K.documentElement.clientWidth||k.innerWidth)||a.y<0||a.y>(K.documentElement.clientHeight||k.innerHeight))return!1;let l=K.elementFromPoint(a.x,a.y);for(;l;){if(l===r)return!0;if(l.parentNode)l=l.parentNode;else return!1}}return e||(e=this.el()),!!(n(e)&&i(e)&&(!e.parentElement||e.tabIndex>=0))}static registerComponent(e,t){if(typeof e!="string"||!e)throw new Error(`Illegal component name, "${e}"; must be a non-empty string.`);const i=H.getComponent("Tech"),n=i&&i.isTech(t),r=H===t||H.prototype.isPrototypeOf(t.prototype);if(n||!r){let l;throw n?l="techs must be registered using Tech.registerTech()":l="must be a Component subclass",new Error(`Illegal component, "${e}"; ${l}.`)}e=Be(e),H.components_||(H.components_={});const a=H.getComponent("Player");if(e==="Player"&&a&&a.players){const l=a.players,h=Object.keys(l);if(l&&h.length>0&&h.map(f=>l[f]).every(Boolean))throw new Error("Can not register Player component after player has been created.")}return H.components_[e]=t,H.components_[fn(e)]=t,t}static getComponent(e){if(!(!e||!H.components_))return H.components_[e]}}H.registerComponent("Component",H);function RT(s,e,t){if(typeof e!="number"||e<0||e>t)throw new Error(`Failed to execute '${s}' on 'TimeRanges': The index provided (${e}) is non-numeric or out of bounds (0-${t}).`)}function Nu(s,e,t,i){return RT(s,i,t.length-1),t[i][e]}function Ma(s){let e;return s===void 0||s.length===0?e={length:0,start(){throw new Error("This TimeRanges object is empty")},end(){throw new Error("This TimeRanges object is empty")}}:e={length:s.length,start:Nu.bind(null,"start",0,s),end:Nu.bind(null,"end",1,s)},k.Symbol&&k.Symbol.iterator&&(e[k.Symbol.iterator]=()=>(s||[]).values()),e}function Nt(s,e){return Array.isArray(s)?Ma(s):s===void 0||e===void 0?Ma():Ma([[s,e]])}const Zd=function(s,e){s=s<0?0:s;let t=Math.floor(s%60),i=Math.floor(s/60%60),n=Math.floor(s/3600);const r=Math.floor(e/60%60),a=Math.floor(e/3600);return(isNaN(s)||s===1/0)&&(n=i=t="-"),n=n>0||a>0?n+":":"",i=((n||r>=10)&&i<10?"0"+i:i)+":",t=t<10?"0"+t:t,n+i+t};let qo=Zd;function eh(s){qo=s}function th(){qo=Zd}function Hi(s,e=s){return qo(s,e)}var MT=Object.freeze({__proto__:null,createTimeRanges:Nt,createTimeRange:Nt,setFormatTime:eh,resetFormatTime:th,formatTime:Hi});function ih(s,e){let t=0,i,n;if(!e)return 0;(!s||!s.length)&&(s=Nt(0,0));for(let r=0;r<s.length;r++)i=s.start(r),n=s.end(r),n>e&&(n=e),t+=n-i;return t/e}function Ne(s){if(s instanceof Ne)return s;typeof s=="number"?this.code=s:typeof s=="string"?this.message=s:Zt(s)&&(typeof s.code=="number"&&(this.code=s.code),Object.assign(this,s)),this.message||(this.message=Ne.defaultMessages[this.code]||"")}Ne.prototype.code=0;Ne.prototype.message="";Ne.prototype.status=null;Ne.prototype.metadata=null;Ne.errorTypes=["MEDIA_ERR_CUSTOM","MEDIA_ERR_ABORTED","MEDIA_ERR_NETWORK","MEDIA_ERR_DECODE","MEDIA_ERR_SRC_NOT_SUPPORTED","MEDIA_ERR_ENCRYPTED"];Ne.defaultMessages={1:"You aborted the media playback",2:"A network error caused the media download to fail part-way.",3:"The media playback was aborted due to a corruption problem or because the media used features your browser did not support.",4:"The media could not be loaded, either because the server or network failed or because the format is not supported.",5:"The media is encrypted and we do not have the keys to decrypt it."};Ne.MEDIA_ERR_CUSTOM=0;Ne.prototype.MEDIA_ERR_CUSTOM=0;Ne.MEDIA_ERR_ABORTED=1;Ne.prototype.MEDIA_ERR_ABORTED=1;Ne.MEDIA_ERR_NETWORK=2;Ne.prototype.MEDIA_ERR_NETWORK=2;Ne.MEDIA_ERR_DECODE=3;Ne.prototype.MEDIA_ERR_DECODE=3;Ne.MEDIA_ERR_SRC_NOT_SUPPORTED=4;Ne.prototype.MEDIA_ERR_SRC_NOT_SUPPORTED=4;Ne.MEDIA_ERR_ENCRYPTED=5;Ne.prototype.MEDIA_ERR_ENCRYPTED=5;function pn(s){return s!=null&&typeof s.then=="function"}function Kt(s){pn(s)&&s.then(null,e=>{})}const ro=function(s){return["kind","label","language","id","inBandMetadataTrackDispatchType","mode","src"].reduce((t,i,n)=>(s[i]&&(t[i]=s[i]),t),{cues:s.cues&&Array.prototype.map.call(s.cues,function(t){return{startTime:t.startTime,endTime:t.endTime,text:t.text,id:t.id}})})},NT=function(s){const e=s.$$("track"),t=Array.prototype.map.call(e,n=>n.track);return Array.prototype.map.call(e,function(n){const r=ro(n.track);return n.src&&(r.src=n.src),r}).concat(Array.prototype.filter.call(s.textTracks(),function(n){return t.indexOf(n)===-1}).map(ro))},UT=function(s,e){return s.forEach(function(t){const i=e.addRemoteTextTrack(t).track;!t.src&&t.cues&&t.cues.forEach(n=>i.addCue(n))}),e.textTracks()};var Uu={textTracksToJson:NT,jsonToTextTracks:UT,trackToJson_:ro};const Na="vjs-modal-dialog";class Is extends H{constructor(e,t){super(e,t),this.handleKeyDown_=i=>this.handleKeyDown(i),this.close_=i=>this.close(i),this.opened_=this.hasBeenOpened_=this.hasBeenFilled_=!1,this.closeable(!this.options_.uncloseable),this.content(this.options_.content),this.contentEl_=se("div",{className:`${Na}-content`},{role:"document"}),this.descEl_=se("p",{className:`${Na}-description vjs-control-text`,id:this.el().getAttribute("aria-describedby")}),Ci(this.descEl_,this.description()),this.el_.appendChild(this.descEl_),this.el_.appendChild(this.contentEl_)}createEl(){return super.createEl("div",{className:this.buildCSSClass(),tabIndex:-1},{"aria-describedby":`${this.id()}_description`,"aria-hidden":"true","aria-label":this.label(),role:"dialog","aria-live":"polite"})}dispose(){this.contentEl_=null,this.descEl_=null,this.previouslyActiveEl_=null,super.dispose()}buildCSSClass(){return`${Na} vjs-hidden ${super.buildCSSClass()}`}label(){return this.localize(this.options_.label||"Modal Window")}description(){let e=this.options_.description||this.localize("This is a modal window.");return this.closeable()&&(e+=" "+this.localize("This modal can be closed by pressing the Escape key or activating the close button.")),e}open(){if(this.opened_){this.options_.fillAlways&&this.fill();return}const e=this.player();this.trigger("beforemodalopen"),this.opened_=!0,(this.options_.fillAlways||!this.hasBeenOpened_&&!this.hasBeenFilled_)&&this.fill(),this.wasPlaying_=!e.paused(),this.options_.pauseOnOpen&&this.wasPlaying_&&e.pause(),this.on("keydown",this.handleKeyDown_),this.hadControls_=e.controls(),e.controls(!1),this.show(),this.conditionalFocus_(),this.el().setAttribute("aria-hidden","false"),this.trigger("modalopen"),this.hasBeenOpened_=!0}opened(e){return typeof e=="boolean"&&this[e?"open":"close"](),this.opened_}close(){if(!this.opened_)return;const e=this.player();this.trigger("beforemodalclose"),this.opened_=!1,this.wasPlaying_&&this.options_.pauseOnOpen&&e.play(),this.off("keydown",this.handleKeyDown_),this.hadControls_&&e.controls(!0),this.hide(),this.el().setAttribute("aria-hidden","true"),this.trigger({type:"modalclose",bubbles:!0}),this.conditionalBlur_(),this.options_.temporary&&this.dispose()}closeable(e){if(typeof e=="boolean"){const t=this.closeable_=!!e;let i=this.getChild("closeButton");if(t&&!i){const n=this.contentEl_;this.contentEl_=this.el_,i=this.addChild("closeButton",{controlText:"Close Modal Dialog"}),this.contentEl_=n,this.on(i,"close",this.close_)}!t&&i&&(this.off(i,"close",this.close_),this.removeChild(i),i.dispose())}return this.closeable_}fill(){this.fillWith(this.content())}fillWith(e){const t=this.contentEl(),i=t.parentNode,n=t.nextSibling;this.trigger("beforemodalfill"),this.hasBeenFilled_=!0,i.removeChild(t),this.empty(),jd(t,e),this.trigger("modalfill"),n?i.insertBefore(t,n):i.appendChild(t);const r=this.getChild("closeButton");r&&i.appendChild(r.el_),this.trigger("aftermodalfill")}empty(){this.trigger("beforemodalempty"),Yr(this.contentEl()),this.trigger("modalempty")}content(e){return typeof e<"u"&&(this.content_=e),this.content_}conditionalFocus_(){const e=K.activeElement,t=this.player_.el_;this.previouslyActiveEl_=null,(t.contains(e)||t===e)&&(this.previouslyActiveEl_=e,this.focus())}conditionalBlur_(){this.previouslyActiveEl_&&(this.previouslyActiveEl_.focus(),this.previouslyActiveEl_=null)}handleKeyDown(e){if(this.trigger({type:"modalKeydown",originalEvent:e,target:this,bubbles:!0}),e.stopPropagation(),e.key==="Escape"&&this.closeable()){e.preventDefault(),this.close();return}if(e.key!=="Tab")return;const t=this.focusableEls_(),i=this.el_.querySelector(":focus");let n;for(let r=0;r<t.length;r++)if(i===t[r]){n=r;break}K.activeElement===this.el_&&(n=0),e.shiftKey&&n===0?(t[t.length-1].focus(),e.preventDefault()):!e.shiftKey&&n===t.length-1&&(t[0].focus(),e.preventDefault())}focusableEls_(){const e=this.el_.querySelectorAll("*");return Array.prototype.filter.call(e,t=>(t instanceof k.HTMLAnchorElement||t instanceof k.HTMLAreaElement)&&t.hasAttribute("href")||(t instanceof k.HTMLInputElement||t instanceof k.HTMLSelectElement||t instanceof k.HTMLTextAreaElement||t instanceof k.HTMLButtonElement)&&!t.hasAttribute("disabled")||t instanceof k.HTMLIFrameElement||t instanceof k.HTMLObjectElement||t instanceof k.HTMLEmbedElement||t.hasAttribute("tabindex")&&t.getAttribute("tabindex")!==-1||t.hasAttribute("contenteditable"))}}Is.prototype.options_={pauseOnOpen:!0,temporary:!0};H.registerComponent("ModalDialog",Is);class bs extends bt{constructor(e=[]){super(),this.tracks_=[],Object.defineProperty(this,"length",{get(){return this.tracks_.length}});for(let t=0;t<e.length;t++)this.addTrack(e[t])}addTrack(e){const t=this.tracks_.length;""+t in this||Object.defineProperty(this,t,{get(){return this.tracks_[t]}}),this.tracks_.indexOf(e)===-1&&(this.tracks_.push(e),this.trigger({track:e,type:"addtrack",target:this})),e.labelchange_=()=>{this.trigger({track:e,type:"labelchange",target:this})},ai(e)&&e.addEventListener("labelchange",e.labelchange_)}removeTrack(e){let t;for(let i=0,n=this.length;i<n;i++)if(this[i]===e){t=this[i],t.off&&t.off(),this.tracks_.splice(i,1);break}t&&this.trigger({track:t,type:"removetrack",target:this})}getTrackById(e){let t=null;for(let i=0,n=this.length;i<n;i++){const r=this[i];if(r.id===e){t=r;break}}return t}}bs.prototype.allowedEvents_={change:"change",addtrack:"addtrack",removetrack:"removetrack",labelchange:"labelchange"};for(const s in bs.prototype.allowedEvents_)bs.prototype["on"+s]=null;const Ua=function(s,e){for(let t=0;t<s.length;t++)!Object.keys(s[t]).length||e.id===s[t].id||(s[t].enabled=!1)};class BT extends bs{constructor(e=[]){for(let t=e.length-1;t>=0;t--)if(e[t].enabled){Ua(e,e[t]);break}super(e),this.changing_=!1}addTrack(e){e.enabled&&Ua(this,e),super.addTrack(e),e.addEventListener&&(e.enabledChange_=()=>{this.changing_||(this.changing_=!0,Ua(this,e),this.changing_=!1,this.trigger("change"))},e.addEventListener("enabledchange",e.enabledChange_))}removeTrack(e){super.removeTrack(e),e.removeEventListener&&e.enabledChange_&&(e.removeEventListener("enabledchange",e.enabledChange_),e.enabledChange_=null)}}const Ba=function(s,e){for(let t=0;t<s.length;t++)!Object.keys(s[t]).length||e.id===s[t].id||(s[t].selected=!1)};class FT extends bs{constructor(e=[]){for(let t=e.length-1;t>=0;t--)if(e[t].selected){Ba(e,e[t]);break}super(e),this.changing_=!1,Object.defineProperty(this,"selectedIndex",{get(){for(let t=0;t<this.length;t++)if(this[t].selected)return t;return-1},set(){}})}addTrack(e){e.selected&&Ba(this,e),super.addTrack(e),e.addEventListener&&(e.selectedChange_=()=>{this.changing_||(this.changing_=!0,Ba(this,e),this.changing_=!1,this.trigger("change"))},e.addEventListener("selectedchange",e.selectedChange_))}removeTrack(e){super.removeTrack(e),e.removeEventListener&&e.selectedChange_&&(e.removeEventListener("selectedchange",e.selectedChange_),e.selectedChange_=null)}}class sh extends bs{addTrack(e){super.addTrack(e),this.queueChange_||(this.queueChange_=()=>this.queueTrigger("change")),this.triggerSelectedlanguagechange||(this.triggerSelectedlanguagechange_=()=>this.trigger("selectedlanguagechange")),e.addEventListener("modechange",this.queueChange_),["metadata","chapters"].indexOf(e.kind)===-1&&e.addEventListener("modechange",this.triggerSelectedlanguagechange_)}removeTrack(e){super.removeTrack(e),e.removeEventListener&&(this.queueChange_&&e.removeEventListener("modechange",this.queueChange_),this.selectedlanguagechange_&&e.removeEventListener("modechange",this.triggerSelectedlanguagechange_))}}class $T{constructor(e=[]){this.trackElements_=[],Object.defineProperty(this,"length",{get(){return this.trackElements_.length}});for(let t=0,i=e.length;t<i;t++)this.addTrackElement_(e[t])}addTrackElement_(e){const t=this.trackElements_.length;""+t in this||Object.defineProperty(this,t,{get(){return this.trackElements_[t]}}),this.trackElements_.indexOf(e)===-1&&this.trackElements_.push(e)}getTrackElementByTrack_(e){let t;for(let i=0,n=this.trackElements_.length;i<n;i++)if(e===this.trackElements_[i].track){t=this.trackElements_[i];break}return t}removeTrackElement_(e){for(let t=0,i=this.trackElements_.length;t<i;t++)if(e===this.trackElements_[t]){this.trackElements_[t].track&&typeof this.trackElements_[t].track.off=="function"&&this.trackElements_[t].track.off(),typeof this.trackElements_[t].off=="function"&&this.trackElements_[t].off(),this.trackElements_.splice(t,1);break}}}class Tr{constructor(e){Tr.prototype.setCues_.call(this,e),Object.defineProperty(this,"length",{get(){return this.length_}})}setCues_(e){const t=this.length||0;let i=0;const n=e.length;this.cues_=e,this.length_=e.length;const r=function(a){""+a in this||Object.defineProperty(this,""+a,{get(){return this.cues_[a]}})};if(t<n)for(i=t;i<n;i++)r.call(this,i)}getCueById(e){let t=null;for(let i=0,n=this.length;i<n;i++){const r=this[i];if(r.id===e){t=r;break}}return t}}const jT={alternative:"alternative",captions:"captions",main:"main",sign:"sign",subtitles:"subtitles",commentary:"commentary"},VT={alternative:"alternative",descriptions:"descriptions",main:"main","main-desc":"main-desc",translation:"translation",commentary:"commentary"},HT={subtitles:"subtitles",captions:"captions",descriptions:"descriptions",chapters:"chapters",metadata:"metadata"},Bu={disabled:"disabled",hidden:"hidden",showing:"showing"};class zo extends bt{constructor(e={}){super();const t={id:e.id||"vjs_track_"+At(),kind:e.kind||"",language:e.language||""};let i=e.label||"";for(const n in t)Object.defineProperty(this,n,{get(){return t[n]},set(){}});Object.defineProperty(this,"label",{get(){return i},set(n){n!==i&&(i=n,this.trigger("labelchange"))}})}}const Wo=function(s){return new URL(s,K.baseURI)},nh=function(s){return new URL(s,K.baseURI).href},Go=function(s){if(typeof s=="string"){const t=/^(\/?)([\s\S]*?)((?:\.{1,2}|[^\/]+?)(\.([^\.\/\?]+)))(?:[\/]*|[\?].*)$/.exec(s);if(t)return t.pop().toLowerCase()}return""},ea=function(s,e=k.location){return Wo(s).origin!==e.origin};var qT=Object.freeze({__proto__:null,parseUrl:Wo,getAbsoluteURL:nh,getFileExtension:Go,isCrossOrigin:ea});const Fu=function(s,e){const t=new k.WebVTT.Parser(k,k.vttjs,k.WebVTT.StringDecoder()),i=[];t.oncue=function(n){e.addCue(n)},t.onparsingerror=function(n){i.push(n)},t.onflush=function(){e.trigger({type:"loadeddata",target:e})},t.parse(s),i.length>0&&(k.console&&k.console.groupCollapsed&&k.console.groupCollapsed(`Text Track parsing errors for ${e.src}`),i.forEach(n=>ue.error(n)),k.console&&k.console.groupEnd&&k.console.groupEnd()),t.flush()},$u=function(s,e){const t={uri:s},i=ea(s);i&&(t.cors=i);const n=e.tech_.crossOrigin()==="use-credentials";n&&(t.withCredentials=n),Zc(t,we(this,function(r,a,l){if(r)return ue.error(r,a);e.loaded_=!0,typeof k.WebVTT!="function"?e.tech_&&e.tech_.any(["vttjsloaded","vttjserror"],h=>{if(h.type==="vttjserror"){ue.error(`vttjs failed to load, stopping trying to process ${e.src}`);return}return Fu(l,e)}):Fu(l,e)}))};class xn extends zo{constructor(e={}){if(!e.tech)throw new Error("A tech was not provided.");const t=xe(e,{kind:HT[e.kind]||"subtitles",language:e.language||e.srclang||""});let i=Bu[t.mode]||"disabled";const n=t.default;(t.kind==="metadata"||t.kind==="chapters")&&(i="hidden"),super(t),this.tech_=t.tech,this.cues_=[],this.activeCues_=[],this.preload_=this.tech_.preloadTextTracks!==!1;const r=new Tr(this.cues_),a=new Tr(this.activeCues_);let l=!1;this.timeupdateHandler=we(this,function(f={}){if(!this.tech_.isDisposed()){if(!this.tech_.isReady_){f.type!=="timeupdate"&&(this.rvf_=this.tech_.requestVideoFrameCallback(this.timeupdateHandler));return}this.activeCues=this.activeCues,l&&(this.trigger("cuechange"),l=!1),f.type!=="timeupdate"&&(this.rvf_=this.tech_.requestVideoFrameCallback(this.timeupdateHandler))}});const h=()=>{this.stopTracking()};this.tech_.one("dispose",h),i!=="disabled"&&this.startTracking(),Object.defineProperties(this,{default:{get(){return n},set(){}},mode:{get(){return i},set(f){Bu[f]&&i!==f&&(i=f,!this.preload_&&i!=="disabled"&&this.cues.length===0&&$u(this.src,this),this.stopTracking(),i!=="disabled"&&this.startTracking(),this.trigger("modechange"))}},cues:{get(){return this.loaded_?r:null},set(){}},activeCues:{get(){if(!this.loaded_)return null;if(this.cues.length===0)return a;const f=this.tech_.currentTime(),m=[];for(let T=0,E=this.cues.length;T<E;T++){const C=this.cues[T];C.startTime<=f&&C.endTime>=f&&m.push(C)}if(l=!1,m.length!==this.activeCues_.length)l=!0;else for(let T=0;T<m.length;T++)this.activeCues_.indexOf(m[T])===-1&&(l=!0);return this.activeCues_=m,a.setCues_(this.activeCues_),a},set(){}}}),t.src?(this.src=t.src,this.preload_||(this.loaded_=!0),(this.preload_||t.kind!=="subtitles"&&t.kind!=="captions")&&$u(this.src,this)):this.loaded_=!0}startTracking(){this.rvf_=this.tech_.requestVideoFrameCallback(this.timeupdateHandler),this.tech_.on("timeupdate",this.timeupdateHandler)}stopTracking(){this.rvf_&&(this.tech_.cancelVideoFrameCallback(this.rvf_),this.rvf_=void 0),this.tech_.off("timeupdate",this.timeupdateHandler)}addCue(e){let t=e;if(!("getCueAsHTML"in t)){t=new k.vttjs.VTTCue(e.startTime,e.endTime,e.text);for(const n in e)n in t||(t[n]=e[n]);t.id=e.id,t.originalCue_=e}const i=this.tech_.textTracks();for(let n=0;n<i.length;n++)i[n]!==this&&i[n].removeCue(t);this.cues_.push(t),this.cues.setCues_(this.cues_)}removeCue(e){let t=this.cues_.length;for(;t--;){const i=this.cues_[t];if(i===e||i.originalCue_&&i.originalCue_===e){this.cues_.splice(t,1),this.cues.setCues_(this.cues_);break}}}}xn.prototype.allowedEvents_={cuechange:"cuechange"};class rh extends zo{constructor(e={}){const t=xe(e,{kind:VT[e.kind]||""});super(t);let i=!1;Object.defineProperty(this,"enabled",{get(){return i},set(n){typeof n!="boolean"||n===i||(i=n,this.trigger("enabledchange"))}}),t.enabled&&(this.enabled=t.enabled),this.loaded_=!0}}class ah extends zo{constructor(e={}){const t=xe(e,{kind:jT[e.kind]||""});super(t);let i=!1;Object.defineProperty(this,"selected",{get(){return i},set(n){typeof n!="boolean"||n===i||(i=n,this.trigger("selectedchange"))}}),t.selected&&(this.selected=t.selected)}}class li extends bt{constructor(e={}){super();let t;const i=new xn(e);this.kind=i.kind,this.src=i.src,this.srclang=i.language,this.label=i.label,this.default=i.default,Object.defineProperties(this,{readyState:{get(){return t}},track:{get(){return i}}}),t=li.NONE,i.addEventListener("loadeddata",()=>{t=li.LOADED,this.trigger({type:"load",target:this})})}}li.prototype.allowedEvents_={load:"load"};li.NONE=0;li.LOADING=1;li.LOADED=2;li.ERROR=3;const It={audio:{ListClass:BT,TrackClass:rh,capitalName:"Audio"},video:{ListClass:FT,TrackClass:ah,capitalName:"Video"},text:{ListClass:sh,TrackClass:xn,capitalName:"Text"}};Object.keys(It).forEach(function(s){It[s].getterName=`${s}Tracks`,It[s].privateName=`${s}Tracks_`});const xs={remoteText:{ListClass:sh,TrackClass:xn,capitalName:"RemoteText",getterName:"remoteTextTracks",privateName:"remoteTextTracks_"},remoteTextEl:{ListClass:$T,TrackClass:li,capitalName:"RemoteTextTrackEls",getterName:"remoteTextTrackEls",privateName:"remoteTextTrackEls_"}},rt=Object.assign({},It,xs);xs.names=Object.keys(xs);It.names=Object.keys(It);rt.names=[].concat(xs.names).concat(It.names);function zT(s,e,t,i,n={}){const r=s.textTracks();n.kind=e,t&&(n.label=t),i&&(n.language=i),n.tech=s;const a=new rt.text.TrackClass(n);return r.addTrack(a),a}class oe extends H{constructor(e={},t=function(){}){e.reportTouchActivity=!1,super(null,e,t),this.onDurationChange_=i=>this.onDurationChange(i),this.trackProgress_=i=>this.trackProgress(i),this.trackCurrentTime_=i=>this.trackCurrentTime(i),this.stopTrackingCurrentTime_=i=>this.stopTrackingCurrentTime(i),this.disposeSourceHandler_=i=>this.disposeSourceHandler(i),this.queuedHanders_=new Set,this.hasStarted_=!1,this.on("playing",function(){this.hasStarted_=!0}),this.on("loadstart",function(){this.hasStarted_=!1}),rt.names.forEach(i=>{const n=rt[i];e&&e[n.getterName]&&(this[n.privateName]=e[n.getterName])}),this.featuresProgressEvents||this.manualProgressOn(),this.featuresTimeupdateEvents||this.manualTimeUpdatesOn(),["Text","Audio","Video"].forEach(i=>{e[`native${i}Tracks`]===!1&&(this[`featuresNative${i}Tracks`]=!1)}),e.nativeCaptions===!1||e.nativeTextTracks===!1?this.featuresNativeTextTracks=!1:(e.nativeCaptions===!0||e.nativeTextTracks===!0)&&(this.featuresNativeTextTracks=!0),this.featuresNativeTextTracks||this.emulateTextTracks(),this.preloadTextTracks=e.preloadTextTracks!==!1,this.autoRemoteTextTracks_=new rt.text.ListClass,this.initTrackListeners(),e.nativeControlsForTouch||this.emitTapEvents(),this.constructor&&(this.name_=this.constructor.name||"Unknown Tech")}triggerSourceset(e){this.isReady_||this.one("ready",()=>this.setTimeout(()=>this.triggerSourceset(e),1)),this.trigger({src:e,type:"sourceset"})}manualProgressOn(){this.on("durationchange",this.onDurationChange_),this.manualProgress=!0,this.one("ready",this.trackProgress_)}manualProgressOff(){this.manualProgress=!1,this.stopTrackingProgress(),this.off("durationchange",this.onDurationChange_)}trackProgress(e){this.stopTrackingProgress(),this.progressInterval=this.setInterval(we(this,function(){const t=this.bufferedPercent();this.bufferedPercent_!==t&&this.trigger("progress"),this.bufferedPercent_=t,t===1&&this.stopTrackingProgress()}),500)}onDurationChange(e){this.duration_=this.duration()}buffered(){return Nt(0,0)}bufferedPercent(){return ih(this.buffered(),this.duration_)}stopTrackingProgress(){this.clearInterval(this.progressInterval)}manualTimeUpdatesOn(){this.manualTimeUpdates=!0,this.on("play",this.trackCurrentTime_),this.on("pause",this.stopTrackingCurrentTime_)}manualTimeUpdatesOff(){this.manualTimeUpdates=!1,this.stopTrackingCurrentTime(),this.off("play",this.trackCurrentTime_),this.off("pause",this.stopTrackingCurrentTime_)}trackCurrentTime(){this.currentTimeInterval&&this.stopTrackingCurrentTime(),this.currentTimeInterval=this.setInterval(function(){this.trigger({type:"timeupdate",target:this,manuallyTriggered:!0})},250)}stopTrackingCurrentTime(){this.clearInterval(this.currentTimeInterval),this.trigger({type:"timeupdate",target:this,manuallyTriggered:!0})}dispose(){this.clearTracks(It.names),this.manualProgress&&this.manualProgressOff(),this.manualTimeUpdates&&this.manualTimeUpdatesOff(),super.dispose()}clearTracks(e){e=[].concat(e),e.forEach(t=>{const i=this[`${t}Tracks`]()||[];let n=i.length;for(;n--;){const r=i[n];t==="text"&&this.removeRemoteTextTrack(r),i.removeTrack(r)}})}cleanupAutoTextTracks(){const e=this.autoRemoteTextTracks_||[];let t=e.length;for(;t--;){const i=e[t];this.removeRemoteTextTrack(i)}}reset(){}crossOrigin(){}setCrossOrigin(){}error(e){return e!==void 0&&(this.error_=new Ne(e),this.trigger("error")),this.error_}played(){return this.hasStarted_?Nt(0,0):Nt()}play(){}setScrubbing(e){}scrubbing(){}setCurrentTime(e){this.manualTimeUpdates&&this.trigger({type:"timeupdate",target:this,manuallyTriggered:!0})}initTrackListeners(){It.names.forEach(e=>{const t=It[e],i=()=>{this.trigger(`${e}trackchange`)},n=this[t.getterName]();n.addEventListener("removetrack",i),n.addEventListener("addtrack",i),this.on("dispose",()=>{n.removeEventListener("removetrack",i),n.removeEventListener("addtrack",i)})})}addWebVttScript_(){if(!k.WebVTT)if(K.body.contains(this.el())){if(!this.options_["vtt.js"]&&ys(yu)&&Object.keys(yu).length>0){this.trigger("vttjsloaded");return}const e=K.createElement("script");e.src=this.options_["vtt.js"]||"https://vjs.zencdn.net/vttjs/0.14.1/vtt.min.js",e.onload=()=>{this.trigger("vttjsloaded")},e.onerror=()=>{this.trigger("vttjserror")},this.on("dispose",()=>{e.onload=null,e.onerror=null}),k.WebVTT=!0,this.el().parentNode.appendChild(e)}else this.ready(this.addWebVttScript_)}emulateTextTracks(){const e=this.textTracks(),t=this.remoteTextTracks(),i=l=>e.addTrack(l.track),n=l=>e.removeTrack(l.track);t.on("addtrack",i),t.on("removetrack",n),this.addWebVttScript_();const r=()=>this.trigger("texttrackchange"),a=()=>{r();for(let l=0;l<e.length;l++){const h=e[l];h.removeEventListener("cuechange",r),h.mode==="showing"&&h.addEventListener("cuechange",r)}};a(),e.addEventListener("change",a),e.addEventListener("addtrack",a),e.addEventListener("removetrack",a),this.on("dispose",function(){t.off("addtrack",i),t.off("removetrack",n),e.removeEventListener("change",a),e.removeEventListener("addtrack",a),e.removeEventListener("removetrack",a);for(let l=0;l<e.length;l++)e[l].removeEventListener("cuechange",r)})}addTextTrack(e,t,i){if(!e)throw new Error("TextTrack kind is required but was not provided");return zT(this,e,t,i)}createRemoteTextTrack(e){const t=xe(e,{tech:this});return new xs.remoteTextEl.TrackClass(t)}addRemoteTextTrack(e={},t){const i=this.createRemoteTextTrack(e);return typeof t!="boolean"&&(t=!1),this.remoteTextTrackEls().addTrackElement_(i),this.remoteTextTracks().addTrack(i.track),t===!1&&this.ready(()=>this.autoRemoteTextTracks_.addTrack(i.track)),i}removeRemoteTextTrack(e){const t=this.remoteTextTrackEls().getTrackElementByTrack_(e);this.remoteTextTrackEls().removeTrackElement_(t),this.remoteTextTracks().removeTrack(e),this.autoRemoteTextTracks_.removeTrack(e)}getVideoPlaybackQuality(){return{}}requestPictureInPicture(){return Promise.reject()}disablePictureInPicture(){return!0}setDisablePictureInPicture(){}requestVideoFrameCallback(e){const t=At();return!this.isReady_||this.paused()?(this.queuedHanders_.add(t),this.one("playing",()=>{this.queuedHanders_.has(t)&&(this.queuedHanders_.delete(t),e())})):this.requestNamedAnimationFrame(t,e),t}cancelVideoFrameCallback(e){this.queuedHanders_.has(e)?this.queuedHanders_.delete(e):this.cancelNamedAnimationFrame(e)}setPoster(){}playsinline(){}setPlaysinline(){}overrideNativeAudioTracks(e){}overrideNativeVideoTracks(e){}canPlayType(e){return""}static canPlayType(e){return""}static canPlaySource(e,t){return oe.canPlayType(e.type)}static isTech(e){return e.prototype instanceof oe||e instanceof oe||e===oe}static registerTech(e,t){if(oe.techs_||(oe.techs_={}),!oe.isTech(t))throw new Error(`Tech ${e} must be a Tech`);if(!oe.canPlayType)throw new Error("Techs must have a static canPlayType method on them");if(!oe.canPlaySource)throw new Error("Techs must have a static canPlaySource method on them");return e=Be(e),oe.techs_[e]=t,oe.techs_[fn(e)]=t,e!=="Tech"&&oe.defaultTechOrder_.push(e),t}static getTech(e){if(e){if(oe.techs_&&oe.techs_[e])return oe.techs_[e];if(e=Be(e),k&&k.videojs&&k.videojs[e])return ue.warn(`The ${e} tech was added to the videojs object when it should be registered using videojs.registerTech(name, tech)`),k.videojs[e]}}}rt.names.forEach(function(s){const e=rt[s];oe.prototype[e.getterName]=function(){return this[e.privateName]=this[e.privateName]||new e.ListClass,this[e.privateName]}});oe.prototype.featuresVolumeControl=!0;oe.prototype.featuresMuteControl=!0;oe.prototype.featuresFullscreenResize=!1;oe.prototype.featuresPlaybackRate=!1;oe.prototype.featuresProgressEvents=!1;oe.prototype.featuresSourceset=!1;oe.prototype.featuresTimeupdateEvents=!1;oe.prototype.featuresNativeTextTracks=!1;oe.prototype.featuresVideoFrameCallback=!1;oe.withSourceHandlers=function(s){s.registerSourceHandler=function(t,i){let n=s.sourceHandlers;n||(n=s.sourceHandlers=[]),i===void 0&&(i=n.length),n.splice(i,0,t)},s.canPlayType=function(t){const i=s.sourceHandlers||[];let n;for(let r=0;r<i.length;r++)if(n=i[r].canPlayType(t),n)return n;return""},s.selectSourceHandler=function(t,i){const n=s.sourceHandlers||[];let r;for(let a=0;a<n.length;a++)if(r=n[a].canHandleSource(t,i),r)return n[a];return null},s.canPlaySource=function(t,i){const n=s.selectSourceHandler(t,i);return n?n.canHandleSource(t,i):""},["seekable","seeking","duration"].forEach(function(t){const i=this[t];typeof i=="function"&&(this[t]=function(){return this.sourceHandler_&&this.sourceHandler_[t]?this.sourceHandler_[t].apply(this.sourceHandler_,arguments):i.apply(this,arguments)})},s.prototype),s.prototype.setSource=function(t){let i=s.selectSourceHandler(t,this.options_);i||(s.nativeSourceHandler?i=s.nativeSourceHandler:ue.error("No source handler found for the current source.")),this.disposeSourceHandler(),this.off("dispose",this.disposeSourceHandler_),i!==s.nativeSourceHandler&&(this.currentSource_=t),this.sourceHandler_=i.handleSource(t,this,this.options_),this.one("dispose",this.disposeSourceHandler_)},s.prototype.disposeSourceHandler=function(){this.currentSource_&&(this.clearTracks(["audio","video"]),this.currentSource_=null),this.cleanupAutoTextTracks(),this.sourceHandler_&&(this.sourceHandler_.dispose&&this.sourceHandler_.dispose(),this.sourceHandler_=null)}};H.registerComponent("Tech",oe);oe.registerTech("Tech",oe);oe.defaultTechOrder_=[];const $i={},vr={},br={};function WT(s,e){$i[s]=$i[s]||[],$i[s].push(e)}function GT(s,e,t){s.setTimeout(()=>Ri(e,$i[e.type],t,s),1)}function KT(s,e){s.forEach(t=>t.setTech&&t.setTech(e))}function XT(s,e,t){return s.reduceRight(Ko(t),e[t]())}function YT(s,e,t,i){return e[t](s.reduce(Ko(t),i))}function ju(s,e,t,i=null){const n="call"+Be(t),r=s.reduce(Ko(n),i),a=r===br,l=a?null:e[t](r);return ZT(s,t,l,a),l}const QT={buffered:1,currentTime:1,duration:1,muted:1,played:1,paused:1,seekable:1,volume:1,ended:1},JT={setCurrentTime:1,setMuted:1,setVolume:1},Vu={play:1,pause:1};function Ko(s){return(e,t)=>e===br?br:t[s]?t[s](e):e}function ZT(s,e,t,i){for(let n=s.length-1;n>=0;n--){const r=s[n];r[e]&&r[e](i,t)}}function ev(s){vr.hasOwnProperty(s.id())&&delete vr[s.id()]}function tv(s,e){const t=vr[s.id()];let i=null;if(t==null)return i=e(s),vr[s.id()]=[[e,i]],i;for(let n=0;n<t.length;n++){const[r,a]=t[n];r===e&&(i=a)}return i===null&&(i=e(s),t.push([e,i])),i}function Ri(s={},e=[],t,i,n=[],r=!1){const[a,...l]=e;if(typeof a=="string")Ri(s,$i[a],t,i,n,r);else if(a){const h=tv(i,a);if(!h.setSource)return n.push(h),Ri(s,l,t,i,n,r);h.setSource(Object.assign({},s),function(f,m){if(f)return Ri(s,l,t,i,n,r);n.push(h),Ri(m,s.type===m.type?l:$i[m.type],t,i,n,r)})}else l.length?Ri(s,l,t,i,n,r):r?t(s,n):Ri(s,$i["*"],t,i,n,!0)}const iv={opus:"video/ogg",ogv:"video/ogg",mp4:"video/mp4",mov:"video/mp4",m4v:"video/mp4",mkv:"video/x-matroska",m4a:"audio/mp4",mp3:"audio/mpeg",aac:"audio/aac",caf:"audio/x-caf",flac:"audio/flac",oga:"audio/ogg",wav:"audio/wav",m3u8:"application/x-mpegURL",mpd:"application/dash+xml",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",png:"image/png",svg:"image/svg+xml",webp:"image/webp"},xr=function(s=""){const e=Go(s);return iv[e.toLowerCase()]||""},sv=(s,e)=>{if(!e)return"";if(s.cache_.source.src===e&&s.cache_.source.type)return s.cache_.source.type;const t=s.cache_.sources.filter(n=>n.src===e);if(t.length)return t[0].type;const i=s.$$("source");for(let n=0;n<i.length;n++){const r=i[n];if(r.type&&r.src&&r.src===e)return r.type}return xr(e)},oh=function(s){if(Array.isArray(s)){let e=[];s.forEach(function(t){t=oh(t),Array.isArray(t)?e=e.concat(t):Zt(t)&&e.push(t)}),s=e}else typeof s=="string"&&s.trim()?s=[Hu({src:s})]:Zt(s)&&typeof s.src=="string"&&s.src&&s.src.trim()?s=[Hu(s)]:s=[];return s};function Hu(s){if(!s.type){const e=xr(s.src);e&&(s.type=e)}return s}var nv=`<svg xmlns="http://www.w3.org/2000/svg">
|
|
25
25
|
<defs>
|
|
26
26
|
<symbol viewBox="0 0 48 48" id="vjs-icon-play">
|
|
27
27
|
<path d="M16 10v28l22-14z"></path>
|
|
@@ -163,19 +163,19 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
163
163
|
<path d="M1664 896q0 209-103 385.5T1281.5 1561 896 1664q-111 0-218-32 59-93 78-164 9-34 54-211 20 39 73 67.5t114 28.5q121 0 216-68.5t147-188.5 52-270q0-114-59.5-214T1180 449t-255-63q-105 0-196 29t-154.5 77-109 110.5-67 129.5T377 866q0 104 40 183t117 111q30 12 38-20 2-7 8-31t8-30q6-23-11-43-51-61-51-151 0-151 104.5-259.5T904 517q151 0 235.5 82t84.5 213q0 170-68.5 289T980 1220q-61 0-98-43.5T859 1072q8-35 26.5-93.5t30-103T927 800q0-50-27-83t-77-33q-62 0-105 57t-43 142q0 73 25 122l-99 418q-17 70-13 177-206-91-333-281T128 896q0-209 103-385.5T510.5 231 896 128t385.5 103T1561 510.5 1664 896z"></path>
|
|
164
164
|
</symbol>
|
|
165
165
|
</defs>
|
|
166
|
-
</svg>`;const Hu=pr?10009:gr?461:8,Ji={codes:{play:415,pause:19,ff:417,rw:412,back:Hu},names:{415:"play",19:"pause",417:"ff",412:"rw",[Hu]:"back"},isEventKey(i,e){return e=e.toLowerCase(),!!(this.names[i.keyCode]&&this.names[i.keyCode]===e)},getEventName(i){if(this.names[i.keyCode])return this.names[i.keyCode];if(this.codes[i.code]){const e=this.codes[i.code];return this.names[e]}return null}},zu=5;class db extends St{constructor(e){super(),this.player_=e,this.focusableComponents=[],this.isListening_=!1,this.isPaused_=!1,this.onKeyDown_=this.onKeyDown_.bind(this),this.lastFocusedComponent_=null}start(){this.isListening_||(this.player_.on("keydown",this.onKeyDown_),this.player_.on("modalKeydown",this.onKeyDown_),this.player_.on("loadedmetadata",()=>{this.focus(this.updateFocusableComponents()[0])}),this.player_.on("modalclose",()=>{this.refocusComponent()}),this.player_.on("focusin",this.handlePlayerFocus_.bind(this)),this.player_.on("focusout",this.handlePlayerBlur_.bind(this)),this.isListening_=!0,this.player_.errorDisplay&&this.player_.errorDisplay.on("aftermodalfill",()=>{this.updateFocusableComponents(),this.focusableComponents.length&&(this.focusableComponents.length>1?this.focusableComponents[1].focus():this.focusableComponents[0].focus())}))}stop(){this.player_.off("keydown",this.onKeyDown_),this.isListening_=!1}onKeyDown_(e){const t=e.originalEvent?e.originalEvent:e;if(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(t.key)){if(this.isPaused_)return;t.preventDefault();const n=t.key.substring(5).toLowerCase();this.move(n)}else if(Ji.isEventKey(t,"play")||Ji.isEventKey(t,"pause")||Ji.isEventKey(t,"ff")||Ji.isEventKey(t,"rw")){t.preventDefault();const n=Ji.getEventName(t);this.performMediaAction_(n)}else Ji.isEventKey(t,"Back")&&e.target&&typeof e.target.closeable=="function"&&e.target.closeable()&&(t.preventDefault(),e.target.close())}performMediaAction_(e){if(this.player_)switch(e){case"play":this.player_.paused()&&this.player_.play();break;case"pause":this.player_.paused()||this.player_.pause();break;case"ff":this.userSeek_(this.player_.currentTime()+zu);break;case"rw":this.userSeek_(this.player_.currentTime()-zu);break}}userSeek_(e){this.player_.liveTracker&&this.player_.liveTracker.isLive()&&this.player_.liveTracker.nextSeekedFromUser(),this.player_.currentTime(e)}pause(){this.isPaused_=!0}resume(){this.isPaused_=!1}handlePlayerBlur_(e){const t=e.relatedTarget;let n=null;const s=this.getCurrentComponent(e.target);t&&(n=!!t.closest(".video-js"),t.classList.contains("vjs-text-track-settings")&&!this.isPaused_&&this.searchForTrackSelect_()),(!e.currentTarget.contains(e.relatedTarget)&&!n||!t)&&(s&&s.name()==="CloseButton"?this.refocusComponent():(this.pause(),s&&s.el()&&(this.lastFocusedComponent_=s)))}handlePlayerFocus_(){this.getCurrentComponent()&&this.getCurrentComponent().getIsFocusable()&&this.resume()}updateFocusableComponents(){const e=this.player_,t=[];function n(s){for(const r of s)r.hasOwnProperty("el_")&&r.getIsFocusable()&&r.getIsAvailableToBeFocused(r.el())&&t.push(r),r.hasOwnProperty("children_")&&r.children_.length>0&&n(r.children_)}return e.children_.forEach(s=>{if(s.hasOwnProperty("el_"))if(s.getIsFocusable&&s.getIsAvailableToBeFocused&&s.getIsFocusable()&&s.getIsAvailableToBeFocused(s.el())){t.push(s);return}else s.hasOwnProperty("children_")&&s.children_.length>0?n(s.children_):s.hasOwnProperty("items")&&s.items.length>0?n(s.items):this.findSuitableDOMChild(s)&&t.push(s);if(s.name_==="ErrorDisplay"&&s.opened_){const r=s.el_.querySelector(".vjs-errors-ok-button-container");r&&r.querySelectorAll("button").forEach((a,l)=>{t.push({name:()=>"ModalButton"+(l+1),el:()=>a,getPositions:()=>{const c=a.getBoundingClientRect(),f={x:c.x,y:c.y,width:c.width,height:c.height,top:c.top,right:c.right,bottom:c.bottom,left:c.left},m={x:c.left+c.width/2,y:c.top+c.height/2,width:0,height:0,top:c.top+c.height/2,right:c.left+c.width/2,bottom:c.top+c.height/2,left:c.left+c.width/2};return{boundingClientRect:f,center:m}},getIsAvailableToBeFocused:()=>!0,getIsFocusable:c=>!0,focus:()=>a.focus()})})}}),this.focusableComponents=t,this.focusableComponents}findSuitableDOMChild(e){function t(n){if(e.getIsFocusable(n)&&e.getIsAvailableToBeFocused(n))return n;for(let s=0;s<n.children.length;s++){const r=n.children[s],a=t(r);if(a)return a}return null}return e.el()?t(e.el()):null}getCurrentComponent(e){this.updateFocusableComponents();const t=e||document.activeElement;if(this.focusableComponents.length){for(const n of this.focusableComponents)if(n.el()===t)return n}}add(e){const t=[...this.focusableComponents];e.hasOwnProperty("el_")&&e.getIsFocusable()&&e.getIsAvailableToBeFocused(e.el())&&t.push(e),this.focusableComponents=t,this.trigger({type:"focusableComponentsChanged",focusableComponents:this.focusableComponents})}remove(e){for(let t=0;t<this.focusableComponents.length;t++)if(this.focusableComponents[t].name()===e.name()){this.focusableComponents.splice(t,1),this.trigger({type:"focusableComponentsChanged",focusableComponents:this.focusableComponents});return}}clear(){this.focusableComponents.length>0&&(this.focusableComponents=[],this.trigger({type:"focusableComponentsChanged",focusableComponents:this.focusableComponents}))}move(e){const t=this.getCurrentComponent();if(!t)return;const n=t.getPositions(),s=this.focusableComponents.filter(a=>a!==t&&this.isInDirection_(n.boundingClientRect,a.getPositions().boundingClientRect,e)),r=this.findBestCandidate_(n.center,s,e);r?this.focus(r):this.trigger({type:"endOfFocusableComponents",direction:e,focusedComponent:t})}findBestCandidate_(e,t,n){let s=1/0,r=null;for(const a of t){const l=a.getPositions().center,c=this.calculateDistance_(e,l,n);c<s&&(s=c,r=a)}return r}isInDirection_(e,t,n){switch(n){case"right":return t.left>=e.right;case"left":return t.right<=e.left;case"down":return t.top>=e.bottom;case"up":return t.bottom<=e.top;default:return!1}}refocusComponent(){if(this.lastFocusedComponent_){this.player_.userActive()||this.player_.userActive(!0),this.updateFocusableComponents();for(let e=0;e<this.focusableComponents.length;e++)if(this.focusableComponents[e].name()===this.lastFocusedComponent_.name()){this.focus(this.focusableComponents[e]);return}}else this.focus(this.updateFocusableComponents()[0])}focus(e){typeof e=="object"&&(e.getIsAvailableToBeFocused(e.el())?e.focus():this.findSuitableDOMChild(e)&&this.findSuitableDOMChild(e).focus())}calculateDistance_(e,t,n){const s=Math.abs(e.x-t.x),r=Math.abs(e.y-t.y);let a;switch(n){case"right":case"left":a=s+r*100;break;case"up":a=r*2+s*.5;break;case"down":a=r*5+s;break;default:a=s+r}return a}searchForTrackSelect_(){const e=this;for(const t of e.updateFocusableComponents())if(t.constructor.name==="TextTrackSelect"){e.focus(t);break}}}class hb extends H{constructor(e,t,n){const s=ve({createEl:!1},t);if(super(e,s,n),!t.playerOptions.sources||t.playerOptions.sources.length===0)for(let r=0,a=t.playerOptions.techOrder;r<a.length;r++){const l=Ne(a[r]);let c=ae.getTech(l);if(l||(c=H.getComponent(l)),c&&c.isSupported()){e.loadTech_(l);break}}else e.src(t.playerOptions.sources)}}H.registerComponent("MediaLoader",hb);class Jr extends H{constructor(e,t){super(e,t),this.options_.controlText&&this.controlText(this.options_.controlText),this.handleMouseOver_=n=>this.handleMouseOver(n),this.handleMouseOut_=n=>this.handleMouseOut(n),this.handleClick_=n=>this.handleClick(n),this.handleKeyDown_=n=>this.handleKeyDown(n),this.emitTapEvents(),this.enable()}createEl(e="div",t={},n={}){t=Object.assign({className:this.buildCSSClass(),tabIndex:0},t),e==="button"&&oe.error(`Creating a ClickableComponent with an HTML element of ${e} is not supported; use a Button instead.`),n=Object.assign({role:"button"},n),this.tabIndex_=t.tabIndex;const s=ne(e,t,n);return this.player_.options_.experimentalSvgIcons||s.appendChild(ne("span",{className:"vjs-icon-placeholder"},{"aria-hidden":!0})),this.createControlTextEl(s),s}dispose(){this.controlTextEl_=null,super.dispose()}createControlTextEl(e){return this.controlTextEl_=ne("span",{className:"vjs-control-text"},{"aria-live":"polite"}),e&&e.appendChild(this.controlTextEl_),this.controlText(this.controlText_,e),this.controlTextEl_}controlText(e,t=this.el()){if(e===void 0)return this.controlText_||"Need Text";const n=this.localize(e);this.controlText_=e,Si(this.controlTextEl_,n),!this.nonIconControl&&!this.player_.options_.noUITitleAttributes&&t.setAttribute("title",n)}buildCSSClass(){return`vjs-control vjs-button ${super.buildCSSClass()}`}enable(){this.enabled_||(this.enabled_=!0,this.removeClass("vjs-disabled"),this.el_.setAttribute("aria-disabled","false"),typeof this.tabIndex_<"u"&&this.el_.setAttribute("tabIndex",this.tabIndex_),this.on(["tap","click"],this.handleClick_),this.on("keydown",this.handleKeyDown_))}disable(){this.enabled_=!1,this.addClass("vjs-disabled"),this.el_.setAttribute("aria-disabled","true"),typeof this.tabIndex_<"u"&&this.el_.removeAttribute("tabIndex"),this.off("mouseover",this.handleMouseOver_),this.off("mouseout",this.handleMouseOut_),this.off(["tap","click"],this.handleClick_),this.off("keydown",this.handleKeyDown_)}handleLanguagechange(){this.controlText(this.controlText_)}handleClick(e){this.options_.clickHandler&&this.options_.clickHandler.call(this,arguments)}handleKeyDown(e){e.key===" "||e.key==="Enter"?(e.preventDefault(),e.stopPropagation(),this.trigger("click")):super.handleKeyDown(e)}}H.registerComponent("ClickableComponent",Jr);class no extends Jr{constructor(e,t){super(e,t),this.update(),this.update_=n=>this.update(n),e.on("posterchange",this.update_)}dispose(){this.player().off("posterchange",this.update_),super.dispose()}createEl(){return ne("div",{className:"vjs-poster"})}crossOrigin(e){if(typeof e>"u")return this.$("img")?this.$("img").crossOrigin:this.player_.tech_&&this.player_.tech_.isReady_?this.player_.crossOrigin():this.player_.options_.crossOrigin||this.player_.options_.crossorigin||null;if(e!==null&&e!=="anonymous"&&e!=="use-credentials"){this.player_.log.warn(`crossOrigin must be null, "anonymous" or "use-credentials", given "${e}"`);return}this.$("img")&&(this.$("img").crossOrigin=e)}update(e){const t=this.player().poster();this.setSrc(t),t?this.show():this.hide()}setSrc(e){if(!e){this.el_.textContent="";return}this.$("img")||this.el_.appendChild(ne("picture",{className:"vjs-poster",tabIndex:-1},{},ne("img",{loading:"lazy",crossOrigin:this.crossOrigin()},{alt:""}))),this.$("img").src=e}handleClick(e){this.player_.controls()&&(this.player_.tech(!0)&&this.player_.tech(!0).focus(),this.player_.paused()?Gt(this.player_.play()):this.player_.pause())}}no.prototype.crossorigin=no.prototype.crossOrigin;H.registerComponent("PosterImage",no);const Ct="#222",Wu="#ccc",cb={monospace:"monospace",sansSerif:"sans-serif",serif:"serif",monospaceSansSerif:'"Andale Mono", "Lucida Console", monospace',monospaceSerif:'"Courier New", monospace',proportionalSansSerif:"sans-serif",proportionalSerif:"serif",casual:'"Comic Sans MS", Impact, fantasy',script:'"Monotype Corsiva", cursive',smallcaps:'"Andale Mono", "Lucida Console", monospace, sans-serif'};function Ua(i,e){let t;if(i.length===4)t=i[1]+i[1]+i[2]+i[2]+i[3]+i[3];else if(i.length===7)t=i.slice(1);else throw new Error("Invalid color code provided, "+i+"; must be formatted as e.g. #f0e or #f604e2.");return"rgba("+parseInt(t.slice(0,2),16)+","+parseInt(t.slice(2,4),16)+","+parseInt(t.slice(4,6),16)+","+e+")"}function Vt(i,e,t){try{i.style[e]=t}catch{return}}function Gu(i){return i?`${i}px`:""}class pb extends H{constructor(e,t,n){super(e,t,n);const s=a=>this.updateDisplay(a),r=a=>{this.updateDisplayOverlay(),this.updateDisplay(a)};e.on("loadstart",a=>this.toggleDisplay(a)),e.on("texttrackchange",s),e.on("loadedmetadata",a=>{this.updateDisplayOverlay(),this.preselectTrack(a)}),e.ready(Ce(this,function(){if(e.tech_&&e.tech_.featuresNativeTextTracks){this.hide();return}e.on("fullscreenchange",r),e.on("playerresize",r);const a=x.screen.orientation||x,l=x.screen.orientation?"change":"orientationchange";a.addEventListener(l,r),e.on("dispose",()=>a.removeEventListener(l,r));const c=this.options_.playerOptions.tracks||[];for(let f=0;f<c.length;f++)this.player_.addRemoteTextTrack(c[f],!0);this.preselectTrack()}))}preselectTrack(){const e={captions:1,subtitles:1},t=this.player_.textTracks(),n=this.player_.cache_.selectedLanguage;let s,r,a;for(let l=0;l<t.length;l++){const c=t[l];n&&n.enabled&&n.language&&n.language===c.language&&c.kind in e?c.kind===n.kind?a=c:a||(a=c):n&&!n.enabled?(a=null,s=null,r=null):c.default&&(c.kind==="descriptions"&&!s?s=c:c.kind in e&&!r&&(r=c))}a?a.mode="showing":r?r.mode="showing":s&&(s.mode="showing")}toggleDisplay(){this.player_.tech_&&this.player_.tech_.featuresNativeTextTracks?this.hide():this.show()}createEl(){return super.createEl("div",{className:"vjs-text-track-display"},{translate:"yes","aria-live":"off","aria-atomic":"true"})}clearDisplay(){typeof x.WebVTT=="function"&&x.WebVTT.processCues(x,[],this.el_)}updateDisplay(){const e=this.player_.textTracks(),t=this.options_.allowMultipleShowingTracks;if(this.clearDisplay(),t){const a=[];for(let l=0;l<e.length;++l){const c=e[l];c.mode==="showing"&&a.push(c)}this.updateForTrack(a);return}let n=null,s=null,r=e.length;for(;r--;){const a=e[r];a.mode==="showing"&&(a.kind==="descriptions"?n=a:s=a)}if(s?(this.getAttribute("aria-live")!=="off"&&this.setAttribute("aria-live","off"),this.updateForTrack(s)):n&&(this.getAttribute("aria-live")!=="assertive"&&this.setAttribute("aria-live","assertive"),this.updateForTrack(n)),!x.CSS.supports("inset","10px")){const a=this.el_,l=a.querySelectorAll(".vjs-text-track-cue"),c=this.player_.controlBar.el_.getBoundingClientRect().height,f=this.player_.el_.getBoundingClientRect().height;a.style="",Vt(a,"position","relative"),Vt(a,"height",f-c+"px"),Vt(a,"top","unset"),fr?Vt(a,"bottom",f+"px"):Vt(a,"bottom","0px"),l.length>0&&l.forEach(m=>{if(m.style.inset){const b=m.style.inset.split(" ");b.length===3&&Object.assign(m.style,{top:b[0],right:b[1],bottom:b[2],left:"unset"})}})}}updateDisplayOverlay(){if(!this.player_.videoHeight()||!x.CSS.supports("inset-inline: 10px"))return;const e=this.player_.currentWidth(),t=this.player_.currentHeight(),n=e/t,s=this.player_.videoWidth()/this.player_.videoHeight();let r=0,a=0;Math.abs(n-s)>.1&&(n>s?r=Math.round((e-t*s)/2):a=Math.round((t-e/s)/2)),Vt(this.el_,"insetInline",Gu(r)),Vt(this.el_,"insetBlock",Gu(a))}updateDisplayState(e){const t=this.player_.textTrackSettings.getValues(),n=e.activeCues;let s=n.length;for(;s--;){const r=n[s];if(!r)continue;const a=r.displayState;if(t.color&&(a.firstChild.style.color=t.color),t.textOpacity&&Vt(a.firstChild,"color",Ua(t.color||"#fff",t.textOpacity)),t.backgroundColor&&(a.firstChild.style.backgroundColor=t.backgroundColor),t.backgroundOpacity&&Vt(a.firstChild,"backgroundColor",Ua(t.backgroundColor||"#000",t.backgroundOpacity)),t.windowColor&&(t.windowOpacity?Vt(a,"backgroundColor",Ua(t.windowColor,t.windowOpacity)):a.style.backgroundColor=t.windowColor),t.edgeStyle&&(t.edgeStyle==="dropshadow"?a.firstChild.style.textShadow=`2px 2px 3px ${Ct}, 2px 2px 4px ${Ct}, 2px 2px 5px ${Ct}`:t.edgeStyle==="raised"?a.firstChild.style.textShadow=`1px 1px ${Ct}, 2px 2px ${Ct}, 3px 3px ${Ct}`:t.edgeStyle==="depressed"?a.firstChild.style.textShadow=`1px 1px ${Wu}, 0 1px ${Wu}, -1px -1px ${Ct}, 0 -1px ${Ct}`:t.edgeStyle==="uniform"&&(a.firstChild.style.textShadow=`0 0 4px ${Ct}, 0 0 4px ${Ct}, 0 0 4px ${Ct}, 0 0 4px ${Ct}`)),t.fontPercent&&t.fontPercent!==1){const l=x.parseFloat(a.style.fontSize);a.style.fontSize=l*t.fontPercent+"px",a.style.height="auto",a.style.top="auto"}t.fontFamily&&t.fontFamily!=="default"&&(t.fontFamily==="small-caps"?a.firstChild.style.fontVariant="small-caps":a.firstChild.style.fontFamily=cb[t.fontFamily])}}updateForTrack(e){if(Array.isArray(e)||(e=[e]),typeof x.WebVTT!="function"||e.every(n=>!n.activeCues))return;const t=[];for(let n=0;n<e.length;++n){const s=e[n];for(let r=0;r<s.activeCues.length;++r)t.push(s.activeCues[r])}x.WebVTT.processCues(x,t,this.el_);for(let n=0;n<e.length;++n){const s=e[n];for(let r=0;r<s.activeCues.length;++r){const a=s.activeCues[r].displayState;Bi(a,"vjs-text-track-cue","vjs-text-track-cue-"+(s.language?s.language:n)),s.language&&yn(a,"lang",s.language)}this.player_.textTrackSettings&&this.updateDisplayState(s)}}}H.registerComponent("TextTrackDisplay",pb);class gb extends H{createEl(){const e=this.player_.isAudio(),t=this.localize(e?"Audio Player":"Video Player"),n=ne("span",{className:"vjs-control-text",textContent:this.localize("{1} is loading.",[t])}),s=super.createEl("div",{className:"vjs-loading-spinner",dir:"ltr"});return s.appendChild(n),s}handleLanguagechange(){this.$(".vjs-control-text").textContent=this.localize("{1} is loading.",[this.player_.isAudio()?"Audio Player":"Video Player"])}}H.registerComponent("LoadingSpinner",gb);class et extends Jr{createEl(e,t={},n={}){e="button",t=Object.assign({className:this.buildCSSClass()},t),n=Object.assign({type:"button"},n);const s=ne(e,t,n);return this.player_.options_.experimentalSvgIcons||s.appendChild(ne("span",{className:"vjs-icon-placeholder"},{"aria-hidden":!0})),this.createControlTextEl(s),s}addChild(e,t={}){const n=this.constructor.name;return oe.warn(`Adding an actionable (user controllable) child to a Button (${n}) is not supported; use a ClickableComponent instead.`),H.prototype.addChild.call(this,e,t)}enable(){super.enable(),this.el_.removeAttribute("disabled")}disable(){super.disable(),this.el_.setAttribute("disabled","disabled")}handleKeyDown(e){if(e.key===" "||e.key==="Enter"){e.stopPropagation();return}super.handleKeyDown(e)}}H.registerComponent("Button",et);class lc extends et{constructor(e,t){super(e,t),this.mouseused_=!1,this.setIcon("play"),this.on("mousedown",n=>this.handleMouseDown(n))}buildCSSClass(){return"vjs-big-play-button"}handleClick(e){const t=this.player_.play();if(this.mouseused_&&"clientX"in e&&"clientY"in e){Gt(t),this.player_.tech(!0)&&this.player_.tech(!0).focus();return}const n=this.player_.getChild("controlBar"),s=n&&n.getChild("playToggle");if(!s){this.player_.tech(!0).focus();return}const r=()=>s.focus();us(t)?t.then(r,()=>{}):this.setTimeout(r,1)}handleKeyDown(e){this.mouseused_=!1,super.handleKeyDown(e)}handleMouseDown(e){this.mouseused_=!0}}lc.prototype.controlText_="Play Video";H.registerComponent("BigPlayButton",lc);class fb extends et{constructor(e,t){super(e,t),this.setIcon("cancel"),this.controlText(t&&t.controlText||this.localize("Close"))}buildCSSClass(){return`vjs-close-button ${super.buildCSSClass()}`}handleClick(e){this.trigger({type:"close",bubbles:!1})}handleKeyDown(e){e.key==="Escape"?(e.preventDefault(),e.stopPropagation(),this.trigger("click")):super.handleKeyDown(e)}}H.registerComponent("CloseButton",fb);class uc extends et{constructor(e,t={}){super(e,t),t.replay=t.replay===void 0||t.replay,this.setIcon("play"),this.on(e,"play",n=>this.handlePlay(n)),this.on(e,"pause",n=>this.handlePause(n)),t.replay&&this.on(e,"ended",n=>this.handleEnded(n))}buildCSSClass(){return`vjs-play-control ${super.buildCSSClass()}`}handleClick(e){this.player_.paused()?Gt(this.player_.play()):this.player_.pause()}handleSeeked(e){this.removeClass("vjs-ended"),this.player_.paused()?this.handlePause(e):this.handlePlay(e)}handlePlay(e){this.removeClass("vjs-ended","vjs-paused"),this.addClass("vjs-playing"),this.setIcon("pause"),this.controlText("Pause")}handlePause(e){this.removeClass("vjs-playing"),this.addClass("vjs-paused"),this.setIcon("play"),this.controlText("Play")}handleEnded(e){this.removeClass("vjs-playing"),this.addClass("vjs-ended"),this.setIcon("replay"),this.controlText("Replay"),this.one(this.player_,"seeked",t=>this.handleSeeked(t))}}uc.prototype.controlText_="Play";H.registerComponent("PlayToggle",uc);class In extends H{constructor(e,t){super(e,t),this.on(e,["timeupdate","ended","seeking"],n=>this.update(n)),this.updateTextNode_()}createEl(){const e=this.buildCSSClass(),t=super.createEl("div",{className:`${e} vjs-time-control vjs-control`}),n=ne("span",{className:"vjs-control-text",textContent:`${this.localize(this.labelText_)} `},{role:"presentation"});return t.appendChild(n),this.contentEl_=ne("span",{className:`${e}-display`},{role:"presentation"}),t.appendChild(this.contentEl_),t}dispose(){this.contentEl_=null,this.textNode_=null,super.dispose()}update(e){!this.player_.options_.enableSmoothSeeking&&e.type==="seeking"||this.updateContent(e)}updateTextNode_(e=0){e=qi(e),this.formattedTime_!==e&&(this.formattedTime_=e,this.requestNamedAnimationFrame("TimeDisplay#updateTextNode_",()=>{if(!this.contentEl_)return;let t=this.textNode_;t&&this.contentEl_.firstChild!==t&&(t=null,oe.warn("TimeDisplay#updateTextnode_: Prevented replacement of text node element since it was no longer a child of this node. Appending a new node instead.")),this.textNode_=G.createTextNode(this.formattedTime_),this.textNode_&&(t?this.contentEl_.replaceChild(this.textNode_,t):this.contentEl_.appendChild(this.textNode_))}))}updateContent(e){}}In.prototype.labelText_="Time";In.prototype.controlText_="Time";H.registerComponent("TimeDisplay",In);class Xo extends In{buildCSSClass(){return"vjs-current-time"}updateContent(e){let t;this.player_.ended()?t=this.player_.duration():t=this.player_.scrubbing()?this.player_.getCache().currentTime:this.player_.currentTime(),this.updateTextNode_(t)}}Xo.prototype.labelText_="Current Time";Xo.prototype.controlText_="Current Time";H.registerComponent("CurrentTimeDisplay",Xo);let Ko=class extends In{constructor(e,t){super(e,t);const n=s=>this.updateContent(s);this.on(e,"durationchange",n),this.on(e,"loadstart",n),this.on(e,"loadedmetadata",n)}buildCSSClass(){return"vjs-duration"}updateContent(e){const t=this.player_.duration();this.updateTextNode_(t)}};Ko.prototype.labelText_="Duration";Ko.prototype.controlText_="Duration";H.registerComponent("DurationDisplay",Ko);class mb extends H{createEl(){const e=super.createEl("div",{className:"vjs-time-control vjs-time-divider"},{"aria-hidden":!0}),t=super.createEl("div"),n=super.createEl("span",{textContent:"/"});return t.appendChild(n),e.appendChild(t),e}}H.registerComponent("TimeDivider",mb);class Yo extends In{constructor(e,t){super(e,t),this.on(e,"durationchange",n=>this.updateContent(n))}buildCSSClass(){return"vjs-remaining-time"}createEl(){const e=super.createEl();return this.options_.displayNegative!==!1&&e.insertBefore(ne("span",{},{"aria-hidden":!0},"-"),this.contentEl_),e}updateContent(e){if(typeof this.player_.duration()!="number")return;let t;this.player_.ended()?t=0:this.player_.remainingTimeDisplay?t=this.player_.remainingTimeDisplay():t=this.player_.remainingTime(),this.updateTextNode_(t)}}Yo.prototype.labelText_="Remaining Time";Yo.prototype.controlText_="Remaining Time";H.registerComponent("RemainingTimeDisplay",Yo);class yb extends H{constructor(e,t){super(e,t),this.updateShowing(),this.on(this.player(),"durationchange",n=>this.updateShowing(n))}createEl(){const e=super.createEl("div",{className:"vjs-live-control vjs-control"});return this.contentEl_=ne("div",{className:"vjs-live-display"},{"aria-live":"off"}),this.contentEl_.appendChild(ne("span",{className:"vjs-control-text",textContent:`${this.localize("Stream Type")} `})),this.contentEl_.appendChild(G.createTextNode(this.localize("LIVE"))),e.appendChild(this.contentEl_),e}dispose(){this.contentEl_=null,super.dispose()}updateShowing(e){this.player().duration()===1/0?this.show():this.hide()}}H.registerComponent("LiveDisplay",yb);class dc extends et{constructor(e,t){super(e,t),this.updateLiveEdgeStatus(),this.player_.liveTracker&&(this.updateLiveEdgeStatusHandler_=n=>this.updateLiveEdgeStatus(n),this.on(this.player_.liveTracker,"liveedgechange",this.updateLiveEdgeStatusHandler_))}createEl(){const e=super.createEl("button",{className:"vjs-seek-to-live-control vjs-control"});return this.setIcon("circle",e),this.textEl_=ne("span",{className:"vjs-seek-to-live-text",textContent:this.localize("LIVE")},{"aria-hidden":"true"}),e.appendChild(this.textEl_),e}updateLiveEdgeStatus(){!this.player_.liveTracker||this.player_.liveTracker.atLiveEdge()?(this.setAttribute("aria-disabled",!0),this.addClass("vjs-at-live-edge"),this.controlText("Seek to live, currently playing live")):(this.setAttribute("aria-disabled",!1),this.removeClass("vjs-at-live-edge"),this.controlText("Seek to live, currently behind live"))}handleClick(){this.player_.liveTracker.seekToLiveEdge()}dispose(){this.player_.liveTracker&&this.off(this.player_.liveTracker,"liveedgechange",this.updateLiveEdgeStatusHandler_),this.textEl_=null,super.dispose()}}dc.prototype.controlText_="Seek to live, currently playing live";H.registerComponent("SeekToLive",dc);function bs(i,e,t){return i=Number(i),Math.min(t,Math.max(e,isNaN(i)?e:i))}var _b=Object.freeze({__proto__:null,clamp:bs});class Qo extends H{constructor(e,t){super(e,t),this.handleMouseDown_=n=>this.handleMouseDown(n),this.handleMouseUp_=n=>this.handleMouseUp(n),this.handleKeyDown_=n=>this.handleKeyDown(n),this.handleClick_=n=>this.handleClick(n),this.handleMouseMove_=n=>this.handleMouseMove(n),this.update_=n=>this.update(n),this.bar=this.getChild(this.options_.barName),this.vertical(!!this.options_.vertical),this.enable()}enabled(){return this.enabled_}enable(){this.enabled()||(this.on("mousedown",this.handleMouseDown_),this.on("touchstart",this.handleMouseDown_),this.on("keydown",this.handleKeyDown_),this.on("click",this.handleClick_),this.on(this.player_,"controlsvisible",this.update),this.playerEvent&&this.on(this.player_,this.playerEvent,this.update),this.removeClass("disabled"),this.setAttribute("tabindex",0),this.enabled_=!0)}disable(){if(!this.enabled())return;const e=this.bar.el_.ownerDocument;this.off("mousedown",this.handleMouseDown_),this.off("touchstart",this.handleMouseDown_),this.off("keydown",this.handleKeyDown_),this.off("click",this.handleClick_),this.off(this.player_,"controlsvisible",this.update_),this.off(e,"mousemove",this.handleMouseMove_),this.off(e,"mouseup",this.handleMouseUp_),this.off(e,"touchmove",this.handleMouseMove_),this.off(e,"touchend",this.handleMouseUp_),this.removeAttribute("tabindex"),this.addClass("disabled"),this.playerEvent&&this.off(this.player_,this.playerEvent,this.update),this.enabled_=!1}createEl(e,t={},n={}){return t.className=t.className+" vjs-slider",t=Object.assign({tabIndex:0},t),n=Object.assign({role:"slider","aria-valuenow":0,"aria-valuemin":0,"aria-valuemax":100},n),super.createEl(e,t,n)}handleMouseDown(e){const t=this.bar.el_.ownerDocument;e.type==="mousedown"&&e.preventDefault(),e.type==="touchstart"&&!Jt&&e.preventDefault(),Nh(),this.addClass("vjs-sliding"),this.trigger("slideractive"),this.on(t,"mousemove",this.handleMouseMove_),this.on(t,"mouseup",this.handleMouseUp_),this.on(t,"touchmove",this.handleMouseMove_),this.on(t,"touchend",this.handleMouseUp_),this.handleMouseMove(e,!0)}handleMouseMove(e){}handleMouseUp(e){const t=this.bar.el_.ownerDocument;Bh(),this.removeClass("vjs-sliding"),this.trigger("sliderinactive"),this.off(t,"mousemove",this.handleMouseMove_),this.off(t,"mouseup",this.handleMouseUp_),this.off(t,"touchmove",this.handleMouseMove_),this.off(t,"touchend",this.handleMouseUp_),this.update()}update(){if(!this.el_||!this.bar)return;const e=this.getProgress();return e===this.progress_||(this.progress_=e,this.requestNamedAnimationFrame("Slider#update",()=>{const t=this.vertical()?"height":"width";this.bar.el().style[t]=(e*100).toFixed(2)+"%"})),e}getProgress(){return Number(bs(this.getPercent(),0,1).toFixed(4))}calculateDistance(e){const t=Wr(this.el_,e);return this.vertical()?t.y:t.x}handleKeyDown(e){const t=this.options_.playerOptions.spatialNavigation,n=t&&t.enabled,s=t&&t.horizontalSeek;n?s&&e.key==="ArrowLeft"||!s&&e.key==="ArrowDown"?(e.preventDefault(),e.stopPropagation(),this.stepBack()):s&&e.key==="ArrowRight"||!s&&e.key==="ArrowUp"?(e.preventDefault(),e.stopPropagation(),this.stepForward()):super.handleKeyDown(e):e.key==="ArrowLeft"||e.key==="ArrowDown"?(e.preventDefault(),e.stopPropagation(),this.stepBack()):e.key==="ArrowUp"||e.key==="ArrowRight"?(e.preventDefault(),e.stopPropagation(),this.stepForward()):super.handleKeyDown(e)}handleClick(e){e.stopPropagation(),e.preventDefault()}vertical(e){if(e===void 0)return this.vertical_||!1;this.vertical_=!!e,this.vertical_?this.addClass("vjs-slider-vertical"):this.addClass("vjs-slider-horizontal")}}H.registerComponent("Slider",Qo);const Na=(i,e)=>bs(i/e*100,0,100).toFixed(2)+"%";class bb extends H{constructor(e,t){super(e,t),this.partEls_=[],this.on(e,"progress",n=>this.update(n))}createEl(){const e=super.createEl("div",{className:"vjs-load-progress"}),t=ne("span",{className:"vjs-control-text"}),n=ne("span",{textContent:this.localize("Loaded")}),s=G.createTextNode(": ");return this.percentageEl_=ne("span",{className:"vjs-control-text-loaded-percentage",textContent:"0%"}),e.appendChild(t),t.appendChild(n),t.appendChild(s),t.appendChild(this.percentageEl_),e}dispose(){this.partEls_=null,this.percentageEl_=null,super.dispose()}update(e){this.requestNamedAnimationFrame("LoadProgressBar#update",()=>{const t=this.player_.liveTracker,n=this.player_.buffered(),s=t&&t.isLive()?t.seekableEnd():this.player_.duration(),r=this.player_.bufferedEnd(),a=this.partEls_,l=Na(r,s);this.percent_!==l&&(this.el_.style.width=l,Si(this.percentageEl_,l),this.percent_=l);for(let c=0;c<n.length;c++){const f=n.start(c),m=n.end(c);let b=a[c];b||(b=this.el_.appendChild(ne()),a[c]=b),!(b.dataset.start===f&&b.dataset.end===m)&&(b.dataset.start=f,b.dataset.end=m,b.style.left=Na(f,r),b.style.width=Na(m-f,r))}for(let c=a.length;c>n.length;c--)this.el_.removeChild(a[c-1]);a.length=n.length})}}H.registerComponent("LoadProgressBar",bb);class Tb extends H{constructor(e,t){super(e,t),this.update=Zt(Ce(this,this.update),Pt)}createEl(){return super.createEl("div",{className:"vjs-time-tooltip"},{"aria-hidden":"true"})}update(e,t,n){const s=gs(this.el_),r=_n(this.player_.el()),a=e.width*t;if(!r||!s)return;let l=e.left-r.left+a,c=e.width-a+(r.right-e.right);c||(c=e.width-a,l=a);let f=s.width/2;l<f?f+=f-l:c<f&&(f=c),f<0?f=0:f>s.width&&(f=s.width),f=Math.round(f),this.el_.style.right=`-${f}px`,this.write(n)}write(e){Si(this.el_,e)}updateTime(e,t,n,s){this.requestNamedAnimationFrame("TimeTooltip#updateTime",()=>{let r;const a=this.player_.duration();if(this.player_.liveTracker&&this.player_.liveTracker.isLive()){const l=this.player_.liveTracker.liveWindow(),c=l-t*l;r=(c<1?"":"-")+qi(c,l)}else r=qi(n,a);this.update(e,t,r),s&&s()})}}H.registerComponent("TimeTooltip",Tb);class Jo extends H{constructor(e,t){super(e,t),this.setIcon("circle"),this.update=Zt(Ce(this,this.update),Pt)}createEl(){return super.createEl("div",{className:"vjs-play-progress vjs-slider-bar"},{"aria-hidden":"true"})}update(e,t){const n=this.getChild("timeTooltip");if(!n)return;const s=this.player_.scrubbing()?this.player_.getCache().currentTime:this.player_.currentTime();n.updateTime(e,t,s)}}Jo.prototype.options_={children:[]};!Je&&!Nt&&Jo.prototype.options_.children.push("timeTooltip");H.registerComponent("PlayProgressBar",Jo);class hc extends H{constructor(e,t){super(e,t),this.update=Zt(Ce(this,this.update),Pt)}createEl(){return super.createEl("div",{className:"vjs-mouse-display"})}update(e,t){const n=t*this.player_.duration();this.getChild("timeTooltip").updateTime(e,t,n,()=>{this.el_.style.left=`${e.width*t}px`})}}hc.prototype.options_={children:["timeTooltip"]};H.registerComponent("MouseTimeDisplay",hc);const Zs=5,Xu=12;class Zr extends Qo{constructor(e,t){t=ve(Zr.prototype.options_,t),t.children=[...t.children];const n=e.options_.disableSeekWhileScrubbingOnMobile&&(Je||Nt);(!Je&&!Nt||n)&&t.children.splice(1,0,"mouseTimeDisplay"),super(e,t),this.shouldDisableSeekWhileScrubbingOnMobile_=n,this.pendingSeekTime_=null,this.setEventHandlers_()}setEventHandlers_(){this.update_=Ce(this,this.update),this.update=Zt(this.update_,Pt),this.on(this.player_,["durationchange","timeupdate"],this.update),this.on(this.player_,["ended"],this.update_),this.player_.liveTracker&&this.on(this.player_.liveTracker,"liveedgechange",this.update),this.updateInterval=null,this.enableIntervalHandler_=e=>this.enableInterval_(e),this.disableIntervalHandler_=e=>this.disableInterval_(e),this.on(this.player_,["playing"],this.enableIntervalHandler_),this.on(this.player_,["ended","pause","waiting"],this.disableIntervalHandler_),"hidden"in G&&"visibilityState"in G&&this.on(G,"visibilitychange",this.toggleVisibility_)}toggleVisibility_(e){G.visibilityState==="hidden"?(this.cancelNamedAnimationFrame("SeekBar#update"),this.cancelNamedAnimationFrame("Slider#update"),this.disableInterval_(e)):(!this.player_.ended()&&!this.player_.paused()&&this.enableInterval_(),this.update())}enableInterval_(){this.updateInterval||(this.updateInterval=this.setInterval(this.update,Pt))}disableInterval_(e){this.player_.liveTracker&&this.player_.liveTracker.isLive()&&e&&e.type!=="ended"||this.updateInterval&&(this.clearInterval(this.updateInterval),this.updateInterval=null)}createEl(){return super.createEl("div",{className:"vjs-progress-holder"},{"aria-label":this.localize("Progress Bar")})}update(e){if(G.visibilityState==="hidden")return;const t=super.update();return this.requestNamedAnimationFrame("SeekBar#update",()=>{const n=this.player_.ended()?this.player_.duration():this.getCurrentTime_(),s=this.player_.liveTracker;let r=this.player_.duration();s&&s.isLive()&&(r=this.player_.liveTracker.liveCurrentTime()),this.percent_!==t&&(this.el_.setAttribute("aria-valuenow",(t*100).toFixed(2)),this.percent_=t),(this.currentTime_!==n||this.duration_!==r)&&(this.el_.setAttribute("aria-valuetext",this.localize("progress bar timing: currentTime={1} duration={2}",[qi(n,r),qi(r,r)],"{1} of {2}")),this.currentTime_=n,this.duration_=r),this.bar&&this.bar.update(_n(this.el()),this.getProgress())}),t}userSeek_(e){this.player_.liveTracker&&this.player_.liveTracker.isLive()&&this.player_.liveTracker.nextSeekedFromUser(),this.player_.currentTime(e)}getCurrentTime_(){return this.player_.scrubbing()?this.player_.getCache().currentTime:this.player_.currentTime()}getPercent(){if(this.pendingSeekTime_)return this.pendingSeekTime_/this.player_.duration();const e=this.getCurrentTime_();let t;const n=this.player_.liveTracker;return n&&n.isLive()?(t=(e-n.seekableStart())/n.liveWindow(),n.atLiveEdge()&&(t=1)):t=e/this.player_.duration(),t}handleMouseDown(e){fs(e)&&(e.stopPropagation(),this.videoWasPlaying=!this.player_.paused(),this.shouldDisableSeekWhileScrubbingOnMobile_||this.player_.pause(),super.handleMouseDown(e))}handleMouseMove(e,t=!1){if(!fs(e)||isNaN(this.player_.duration()))return;!t&&!this.player_.scrubbing()&&this.player_.scrubbing(!0);let n;const s=this.calculateDistance(e),r=this.player_.liveTracker;if(!r||!r.isLive())n=s*this.player_.duration(),n===this.player_.duration()&&(n=n-.1);else{if(s>=.99){r.seekToLiveEdge();return}const a=r.seekableStart(),l=r.liveCurrentTime();if(n=a+s*r.liveWindow(),n>=l&&(n=l),n<=a&&(n=a+.1),n===1/0)return}this.shouldDisableSeekWhileScrubbingOnMobile_?this.pendingSeekTime_=n:this.userSeek_(n),this.player_.options_.enableSmoothSeeking&&this.update()}enable(){super.enable();const e=this.getChild("mouseTimeDisplay");e&&e.show()}disable(){super.disable();const e=this.getChild("mouseTimeDisplay");e&&e.hide()}handleMouseUp(e){super.handleMouseUp(e),e&&e.stopPropagation(),this.player_.scrubbing(!1),this.pendingSeekTime_&&(this.userSeek_(this.pendingSeekTime_),this.pendingSeekTime_=null),this.player_.trigger({type:"timeupdate",target:this,manuallyTriggered:!0}),this.videoWasPlaying?Gt(this.player_.play()):this.update_()}stepForward(){this.userSeek_(this.player_.currentTime()+Zs)}stepBack(){this.userSeek_(this.player_.currentTime()-Zs)}handleAction(e){this.player_.paused()?this.player_.play():this.player_.pause()}handleKeyDown(e){const t=this.player_.liveTracker;if(e.key===" "||e.key==="Enter")e.preventDefault(),e.stopPropagation(),this.handleAction(e);else if(e.key==="Home")e.preventDefault(),e.stopPropagation(),this.userSeek_(0);else if(e.key==="End")e.preventDefault(),e.stopPropagation(),t&&t.isLive()?this.userSeek_(t.liveCurrentTime()):this.userSeek_(this.player_.duration());else if(/^[0-9]$/.test(e.key)){e.preventDefault(),e.stopPropagation();const n=parseInt(e.key,10)*.1;t&&t.isLive()?this.userSeek_(t.seekableStart()+t.liveWindow()*n):this.userSeek_(this.player_.duration()*n)}else e.key==="PageDown"?(e.preventDefault(),e.stopPropagation(),this.userSeek_(this.player_.currentTime()-Zs*Xu)):e.key==="PageUp"?(e.preventDefault(),e.stopPropagation(),this.userSeek_(this.player_.currentTime()+Zs*Xu)):super.handleKeyDown(e)}dispose(){this.disableInterval_(),this.off(this.player_,["durationchange","timeupdate"],this.update),this.off(this.player_,["ended"],this.update_),this.player_.liveTracker&&this.off(this.player_.liveTracker,"liveedgechange",this.update),this.off(this.player_,["playing"],this.enableIntervalHandler_),this.off(this.player_,["ended","pause","waiting"],this.disableIntervalHandler_),"hidden"in G&&"visibilityState"in G&&this.off(G,"visibilitychange",this.toggleVisibility_),super.dispose()}}Zr.prototype.options_={children:["loadProgressBar","playProgressBar"],barName:"playProgressBar"};H.registerComponent("SeekBar",Zr);class cc extends H{constructor(e,t){super(e,t),this.handleMouseMove=Zt(Ce(this,this.handleMouseMove),Pt),this.throttledHandleMouseSeek=Zt(Ce(this,this.handleMouseSeek),Pt),this.handleMouseUpHandler_=n=>this.handleMouseUp(n),this.handleMouseDownHandler_=n=>this.handleMouseDown(n),this.enable()}createEl(){return super.createEl("div",{className:"vjs-progress-control vjs-control"})}handleMouseMove(e){const t=this.getChild("seekBar");if(!t)return;const n=t.getChild("playProgressBar"),s=t.getChild("mouseTimeDisplay");if(!n&&!s)return;const r=t.el(),a=gs(r);let l=Wr(r,e).x;l=bs(l,0,1),s&&s.update(a,l),n&&n.update(a,t.getProgress())}handleMouseSeek(e){const t=this.getChild("seekBar");t&&t.handleMouseMove(e)}enabled(){return this.enabled_}disable(){if(this.children().forEach(e=>e.disable&&e.disable()),!!this.enabled()&&(this.off(["mousedown","touchstart"],this.handleMouseDownHandler_),this.off(this.el_,["mousemove","touchmove"],this.handleMouseMove),this.removeListenersAddedOnMousedownAndTouchstart(),this.addClass("disabled"),this.enabled_=!1,this.player_.scrubbing())){const e=this.getChild("seekBar");this.player_.scrubbing(!1),e.videoWasPlaying&&Gt(this.player_.play())}}enable(){this.children().forEach(e=>e.enable&&e.enable()),!this.enabled()&&(this.on(["mousedown","touchstart"],this.handleMouseDownHandler_),this.on(this.el_,["mousemove","touchmove"],this.handleMouseMove),this.removeClass("disabled"),this.enabled_=!0)}removeListenersAddedOnMousedownAndTouchstart(){const e=this.el_.ownerDocument;this.off(e,"mousemove",this.throttledHandleMouseSeek),this.off(e,"touchmove",this.throttledHandleMouseSeek),this.off(e,"mouseup",this.handleMouseUpHandler_),this.off(e,"touchend",this.handleMouseUpHandler_)}handleMouseDown(e){const t=this.el_.ownerDocument,n=this.getChild("seekBar");n&&n.handleMouseDown(e),this.on(t,"mousemove",this.throttledHandleMouseSeek),this.on(t,"touchmove",this.throttledHandleMouseSeek),this.on(t,"mouseup",this.handleMouseUpHandler_),this.on(t,"touchend",this.handleMouseUpHandler_)}handleMouseUp(e){const t=this.getChild("seekBar");t&&t.handleMouseUp(e),this.removeListenersAddedOnMousedownAndTouchstart()}}cc.prototype.options_={children:["seekBar"]};H.registerComponent("ProgressControl",cc);class pc extends et{constructor(e,t){super(e,t),this.setIcon("picture-in-picture-enter"),this.on(e,["enterpictureinpicture","leavepictureinpicture"],n=>this.handlePictureInPictureChange(n)),this.on(e,["disablepictureinpicturechanged","loadedmetadata"],n=>this.handlePictureInPictureEnabledChange(n)),this.on(e,["loadedmetadata","audioonlymodechange","audiopostermodechange"],()=>this.handlePictureInPictureAudioModeChange()),this.disable()}buildCSSClass(){return`vjs-picture-in-picture-control vjs-hidden ${super.buildCSSClass()}`}handlePictureInPictureAudioModeChange(){if(!(this.player_.currentType().substring(0,5)==="audio"||this.player_.audioPosterMode()||this.player_.audioOnlyMode())){this.show();return}this.player_.isInPictureInPicture()&&this.player_.exitPictureInPicture(),this.hide()}handlePictureInPictureEnabledChange(){G.pictureInPictureEnabled&&this.player_.disablePictureInPicture()===!1||this.player_.options_.enableDocumentPictureInPicture&&"documentPictureInPicture"in x?this.enable():this.disable()}handlePictureInPictureChange(e){this.player_.isInPictureInPicture()?(this.setIcon("picture-in-picture-exit"),this.controlText("Exit Picture-in-Picture")):(this.setIcon("picture-in-picture-enter"),this.controlText("Picture-in-Picture")),this.handlePictureInPictureEnabledChange()}handleClick(e){this.player_.isInPictureInPicture()?this.player_.exitPictureInPicture():this.player_.requestPictureInPicture()}show(){typeof G.exitPictureInPicture=="function"&&super.show()}}pc.prototype.controlText_="Picture-in-Picture";H.registerComponent("PictureInPictureToggle",pc);class gc extends et{constructor(e,t){super(e,t),this.setIcon("fullscreen-enter"),this.on(e,"fullscreenchange",n=>this.handleFullscreenChange(n)),G[e.fsApi_.fullscreenEnabled]===!1&&this.disable()}buildCSSClass(){return`vjs-fullscreen-control ${super.buildCSSClass()}`}handleFullscreenChange(e){this.player_.isFullscreen()?(this.controlText("Exit Fullscreen"),this.setIcon("fullscreen-exit")):(this.controlText("Fullscreen"),this.setIcon("fullscreen-enter"))}handleClick(e){this.player_.isFullscreen()?this.player_.exitFullscreen():this.player_.requestFullscreen()}}gc.prototype.controlText_="Fullscreen";H.registerComponent("FullscreenToggle",gc);const vb=function(i,e){e.tech_&&!e.tech_.featuresVolumeControl&&i.addClass("vjs-hidden"),i.on(e,"loadstart",function(){e.tech_.featuresVolumeControl?i.removeClass("vjs-hidden"):i.addClass("vjs-hidden")})};class Sb extends H{createEl(){const e=super.createEl("div",{className:"vjs-volume-level"});return this.setIcon("circle",e),e.appendChild(super.createEl("span",{className:"vjs-control-text"})),e}}H.registerComponent("VolumeLevel",Sb);class Eb extends H{constructor(e,t){super(e,t),this.update=Zt(Ce(this,this.update),Pt)}createEl(){return super.createEl("div",{className:"vjs-volume-tooltip"},{"aria-hidden":"true"})}update(e,t,n,s){if(!n){const r=_n(this.el_),a=_n(this.player_.el()),l=e.width*t;if(!a||!r)return;const c=e.left-a.left+l,f=e.width-l+(a.right-e.right);let m=r.width/2;c<m?m+=m-c:f<m&&(m=f),m<0?m=0:m>r.width&&(m=r.width),this.el_.style.right=`-${m}px`}this.write(`${s}%`)}write(e){Si(this.el_,e)}updateVolume(e,t,n,s,r){this.requestNamedAnimationFrame("VolumeLevelTooltip#updateVolume",()=>{this.update(e,t,n,s.toFixed(0)),r&&r()})}}H.registerComponent("VolumeLevelTooltip",Eb);class fc extends H{constructor(e,t){super(e,t),this.update=Zt(Ce(this,this.update),Pt)}createEl(){return super.createEl("div",{className:"vjs-mouse-display"})}update(e,t,n){const s=100*t;this.getChild("volumeLevelTooltip").updateVolume(e,t,n,s,()=>{n?this.el_.style.bottom=`${e.height*t}px`:this.el_.style.left=`${e.width*t}px`})}}fc.prototype.options_={children:["volumeLevelTooltip"]};H.registerComponent("MouseVolumeLevelDisplay",fc);class ea extends Qo{constructor(e,t){super(e,t),this.on("slideractive",n=>this.updateLastVolume_(n)),this.on(e,"volumechange",n=>this.updateARIAAttributes(n)),e.ready(()=>this.updateARIAAttributes())}createEl(){return super.createEl("div",{className:"vjs-volume-bar vjs-slider-bar"},{"aria-label":this.localize("Volume Level"),"aria-live":"polite"})}handleMouseDown(e){fs(e)&&super.handleMouseDown(e)}handleMouseMove(e){const t=this.getChild("mouseVolumeLevelDisplay");if(t){const n=this.el(),s=_n(n),r=this.vertical();let a=Wr(n,e);a=r?a.y:a.x,a=bs(a,0,1),t.update(s,a,r)}fs(e)&&(this.checkMuted(),this.player_.volume(this.calculateDistance(e)))}checkMuted(){this.player_.muted()&&this.player_.muted(!1)}getPercent(){return this.player_.muted()?0:this.player_.volume()}stepForward(){this.checkMuted(),this.player_.volume(this.player_.volume()+.1)}stepBack(){this.checkMuted(),this.player_.volume(this.player_.volume()-.1)}updateARIAAttributes(e){const t=this.player_.muted()?0:this.volumeAsPercentage_();this.el_.setAttribute("aria-valuenow",t),this.el_.setAttribute("aria-valuetext",t+"%")}volumeAsPercentage_(){return Math.round(this.player_.volume()*100)}updateLastVolume_(){const e=this.player_.volume();this.one("sliderinactive",()=>{this.player_.volume()===0&&this.player_.lastVolume_(e)})}}ea.prototype.options_={children:["volumeLevel"],barName:"volumeLevel"};!Je&&!Nt&&ea.prototype.options_.children.splice(0,0,"mouseVolumeLevelDisplay");ea.prototype.playerEvent="volumechange";H.registerComponent("VolumeBar",ea);class mc extends H{constructor(e,t={}){t.vertical=t.vertical||!1,(typeof t.volumeBar>"u"||mn(t.volumeBar))&&(t.volumeBar=t.volumeBar||{},t.volumeBar.vertical=t.vertical),super(e,t),vb(this,e),this.throttledHandleMouseMove=Zt(Ce(this,this.handleMouseMove),Pt),this.handleMouseUpHandler_=n=>this.handleMouseUp(n),this.on("mousedown",n=>this.handleMouseDown(n)),this.on("touchstart",n=>this.handleMouseDown(n)),this.on("mousemove",n=>this.handleMouseMove(n)),this.on(this.volumeBar,["focus","slideractive"],()=>{this.volumeBar.addClass("vjs-slider-active"),this.addClass("vjs-slider-active"),this.trigger("slideractive")}),this.on(this.volumeBar,["blur","sliderinactive"],()=>{this.volumeBar.removeClass("vjs-slider-active"),this.removeClass("vjs-slider-active"),this.trigger("sliderinactive")})}createEl(){let e="vjs-volume-horizontal";return this.options_.vertical&&(e="vjs-volume-vertical"),super.createEl("div",{className:`vjs-volume-control vjs-control ${e}`})}handleMouseDown(e){const t=this.el_.ownerDocument;this.on(t,"mousemove",this.throttledHandleMouseMove),this.on(t,"touchmove",this.throttledHandleMouseMove),this.on(t,"mouseup",this.handleMouseUpHandler_),this.on(t,"touchend",this.handleMouseUpHandler_)}handleMouseUp(e){const t=this.el_.ownerDocument;this.off(t,"mousemove",this.throttledHandleMouseMove),this.off(t,"touchmove",this.throttledHandleMouseMove),this.off(t,"mouseup",this.handleMouseUpHandler_),this.off(t,"touchend",this.handleMouseUpHandler_)}handleMouseMove(e){this.volumeBar.handleMouseMove(e)}}mc.prototype.options_={children:["volumeBar"]};H.registerComponent("VolumeControl",mc);const wb=function(i,e){e.tech_&&!e.tech_.featuresMuteControl&&i.addClass("vjs-hidden"),i.on(e,"loadstart",function(){e.tech_.featuresMuteControl?i.removeClass("vjs-hidden"):i.addClass("vjs-hidden")})};class yc extends et{constructor(e,t){super(e,t),wb(this,e),this.on(e,["loadstart","volumechange"],n=>this.update(n))}buildCSSClass(){return`vjs-mute-control ${super.buildCSSClass()}`}handleClick(e){const t=this.player_.volume(),n=this.player_.lastVolume_();if(t===0){const s=n<.1?.1:n;this.player_.volume(s),this.player_.muted(!1)}else this.player_.muted(!this.player_.muted())}update(e){this.updateIcon_(),this.updateControlText_()}updateIcon_(){const e=this.player_.volume();let t=3;this.setIcon("volume-high"),Je&&this.player_.tech_&&this.player_.tech_.el_&&this.player_.muted(this.player_.tech_.el_.muted),e===0||this.player_.muted()?(this.setIcon("volume-mute"),t=0):e<.33?(this.setIcon("volume-low"),t=1):e<.67&&(this.setIcon("volume-medium"),t=2),Hr(this.el_,[0,1,2,3].reduce((n,s)=>n+`${s?" ":""}vjs-vol-${s}`,"")),Bi(this.el_,`vjs-vol-${t}`)}updateControlText_(){const e=this.player_.muted()||this.player_.volume()===0?"Unmute":"Mute";this.controlText()!==e&&this.controlText(e)}}yc.prototype.controlText_="Mute";H.registerComponent("MuteToggle",yc);class _c extends H{constructor(e,t={}){typeof t.inline<"u"?t.inline=t.inline:t.inline=!0,(typeof t.volumeControl>"u"||mn(t.volumeControl))&&(t.volumeControl=t.volumeControl||{},t.volumeControl.vertical=!t.inline),super(e,t),this.handleKeyPressHandler_=n=>this.handleKeyPress(n),this.on(e,["loadstart"],n=>this.volumePanelState_(n)),this.on(this.muteToggle,"keyup",n=>this.handleKeyPress(n)),this.on(this.volumeControl,"keyup",n=>this.handleVolumeControlKeyUp(n)),this.on("keydown",n=>this.handleKeyPress(n)),this.on("mouseover",n=>this.handleMouseOver(n)),this.on("mouseout",n=>this.handleMouseOut(n)),this.on(this.volumeControl,["slideractive"],this.sliderActive_),this.on(this.volumeControl,["sliderinactive"],this.sliderInactive_)}sliderActive_(){this.addClass("vjs-slider-active")}sliderInactive_(){this.removeClass("vjs-slider-active")}volumePanelState_(){this.volumeControl.hasClass("vjs-hidden")&&this.muteToggle.hasClass("vjs-hidden")&&this.addClass("vjs-hidden"),this.volumeControl.hasClass("vjs-hidden")&&!this.muteToggle.hasClass("vjs-hidden")&&this.addClass("vjs-mute-toggle-only")}createEl(){let e="vjs-volume-panel-horizontal";return this.options_.inline||(e="vjs-volume-panel-vertical"),super.createEl("div",{className:`vjs-volume-panel vjs-control ${e}`})}dispose(){this.handleMouseOut(),super.dispose()}handleVolumeControlKeyUp(e){e.key==="Escape"&&this.muteToggle.focus()}handleMouseOver(e){this.addClass("vjs-hover"),vt(G,"keyup",this.handleKeyPressHandler_)}handleMouseOut(e){this.removeClass("vjs-hover"),Ze(G,"keyup",this.handleKeyPressHandler_)}handleKeyPress(e){e.key==="Escape"&&this.handleMouseOut()}}_c.prototype.options_={children:["muteToggle","volumeControl"]};H.registerComponent("VolumePanel",_c);class bc extends et{constructor(e,t){super(e,t),this.validOptions=[5,10,30],this.skipTime=this.getSkipForwardTime(),this.skipTime&&this.validOptions.includes(this.skipTime)?(this.setIcon(`forward-${this.skipTime}`),this.controlText(this.localize("Skip forward {1} seconds",[this.skipTime.toLocaleString(e.language())])),this.show()):this.hide()}getSkipForwardTime(){const e=this.options_.playerOptions;return e.controlBar&&e.controlBar.skipButtons&&e.controlBar.skipButtons.forward}buildCSSClass(){return`vjs-skip-forward-${this.getSkipForwardTime()} ${super.buildCSSClass()}`}handleClick(e){if(isNaN(this.player_.duration()))return;const t=this.player_.currentTime(),n=this.player_.liveTracker,s=n&&n.isLive()?n.seekableEnd():this.player_.duration();let r;t+this.skipTime<=s?r=t+this.skipTime:r=s,this.player_.currentTime(r)}handleLanguagechange(){this.controlText(this.localize("Skip forward {1} seconds",[this.skipTime]))}}bc.prototype.controlText_="Skip Forward";H.registerComponent("SkipForward",bc);class Tc extends et{constructor(e,t){super(e,t),this.validOptions=[5,10,30],this.skipTime=this.getSkipBackwardTime(),this.skipTime&&this.validOptions.includes(this.skipTime)?(this.setIcon(`replay-${this.skipTime}`),this.controlText(this.localize("Skip backward {1} seconds",[this.skipTime.toLocaleString(e.language())])),this.show()):this.hide()}getSkipBackwardTime(){const e=this.options_.playerOptions;return e.controlBar&&e.controlBar.skipButtons&&e.controlBar.skipButtons.backward}buildCSSClass(){return`vjs-skip-backward-${this.getSkipBackwardTime()} ${super.buildCSSClass()}`}handleClick(e){const t=this.player_.currentTime(),n=this.player_.liveTracker,s=n&&n.isLive()&&n.seekableStart();let r;s&&t-this.skipTime<=s?r=s:t>=this.skipTime?r=t-this.skipTime:r=0,this.player_.currentTime(r)}handleLanguagechange(){this.controlText(this.localize("Skip backward {1} seconds",[this.skipTime]))}}Tc.prototype.controlText_="Skip Backward";H.registerComponent("SkipBackward",Tc);class vc extends H{constructor(e,t){super(e,t),t&&(this.menuButton_=t.menuButton),this.focusedChild_=-1,this.on("keydown",n=>this.handleKeyDown(n)),this.boundHandleBlur_=n=>this.handleBlur(n),this.boundHandleTapClick_=n=>this.handleTapClick(n)}addEventListenerForItem(e){e instanceof H&&(this.on(e,"blur",this.boundHandleBlur_),this.on(e,["tap","click"],this.boundHandleTapClick_))}removeEventListenerForItem(e){e instanceof H&&(this.off(e,"blur",this.boundHandleBlur_),this.off(e,["tap","click"],this.boundHandleTapClick_))}removeChild(e){typeof e=="string"&&(e=this.getChild(e)),this.removeEventListenerForItem(e),super.removeChild(e)}addItem(e){const t=this.addChild(e);t&&this.addEventListenerForItem(t)}createEl(){const e=this.options_.contentElType||"ul";this.contentEl_=ne(e,{className:"vjs-menu-content"}),this.contentEl_.setAttribute("role","menu");const t=super.createEl("div",{append:this.contentEl_,className:"vjs-menu"});return t.appendChild(this.contentEl_),vt(t,"click",function(n){n.preventDefault(),n.stopImmediatePropagation()}),t}dispose(){this.contentEl_=null,this.boundHandleBlur_=null,this.boundHandleTapClick_=null,super.dispose()}handleBlur(e){const t=e.relatedTarget||G.activeElement;if(!this.children().some(n=>n.el()===t)){const n=this.menuButton_;n&&n.buttonPressed_&&t!==n.el().firstChild&&n.unpressButton()}}handleTapClick(e){if(this.menuButton_){this.menuButton_.unpressButton();const t=this.children();if(!Array.isArray(t))return;const n=t.filter(s=>s.el()===e.target)[0];if(!n)return;n.name()!=="CaptionSettingsMenuItem"&&this.menuButton_.focus()}}handleKeyDown(e){e.key==="ArrowLeft"||e.key==="ArrowDown"?(e.preventDefault(),e.stopPropagation(),this.stepForward()):(e.key==="ArrowRight"||e.key==="ArrowUp")&&(e.preventDefault(),e.stopPropagation(),this.stepBack())}stepForward(){let e=0;this.focusedChild_!==void 0&&(e=this.focusedChild_+1),this.focus(e)}stepBack(){let e=0;this.focusedChild_!==void 0&&(e=this.focusedChild_-1),this.focus(e)}focus(e=0){const t=this.children().slice();t.length&&t[0].hasClass("vjs-menu-title")&&t.shift(),t.length>0&&(e<0?e=0:e>=t.length&&(e=t.length-1),this.focusedChild_=e,t[e].el_.focus())}}H.registerComponent("Menu",vc);class Zo extends H{constructor(e,t={}){super(e,t),this.menuButton_=new et(e,t),this.menuButton_.controlText(this.controlText_),this.menuButton_.el_.setAttribute("aria-haspopup","true");const n=et.prototype.buildCSSClass();this.menuButton_.el_.className=this.buildCSSClass()+" "+n,this.menuButton_.removeClass("vjs-control"),this.addChild(this.menuButton_),this.update(),this.enabled_=!0;const s=r=>this.handleClick(r);this.handleMenuKeyUp_=r=>this.handleMenuKeyUp(r),this.on(this.menuButton_,"tap",s),this.on(this.menuButton_,"click",s),this.on(this.menuButton_,"keydown",r=>this.handleKeyDown(r)),this.on(this.menuButton_,"mouseenter",()=>{this.addClass("vjs-hover"),this.menu.show(),vt(G,"keyup",this.handleMenuKeyUp_)}),this.on("mouseleave",r=>this.handleMouseLeave(r)),this.on("keydown",r=>this.handleSubmenuKeyDown(r))}update(){const e=this.createMenu();this.menu&&(this.menu.dispose(),this.removeChild(this.menu)),this.menu=e,this.addChild(e),this.buttonPressed_=!1,this.menuButton_.el_.setAttribute("aria-expanded","false"),this.items&&this.items.length<=this.hideThreshold_?(this.hide(),this.menu.contentEl_.removeAttribute("role")):(this.show(),this.menu.contentEl_.setAttribute("role","menu"))}createMenu(){const e=new vc(this.player_,{menuButton:this});if(this.hideThreshold_=0,this.options_.title){const t=ne("li",{className:"vjs-menu-title",textContent:Ne(this.options_.title),tabIndex:-1}),n=new H(this.player_,{el:t});e.addItem(n)}if(this.items=this.createItems(),this.items)for(let t=0;t<this.items.length;t++)e.addItem(this.items[t]);return e}createItems(){}createEl(){return super.createEl("div",{className:this.buildWrapperCSSClass()},{})}setIcon(e){super.setIcon(e,this.menuButton_.el_)}buildWrapperCSSClass(){let e="vjs-menu-button";this.options_.inline===!0?e+="-inline":e+="-popup";const t=et.prototype.buildCSSClass();return`vjs-menu-button ${e} ${t} ${super.buildCSSClass()}`}buildCSSClass(){let e="vjs-menu-button";return this.options_.inline===!0?e+="-inline":e+="-popup",`vjs-menu-button ${e} ${super.buildCSSClass()}`}controlText(e,t=this.menuButton_.el()){return this.menuButton_.controlText(e,t)}dispose(){this.handleMouseLeave(),super.dispose()}handleClick(e){this.buttonPressed_?this.unpressButton():this.pressButton()}handleMouseLeave(e){this.removeClass("vjs-hover"),Ze(G,"keyup",this.handleMenuKeyUp_)}focus(){this.menuButton_.focus()}blur(){this.menuButton_.blur()}handleKeyDown(e){e.key==="Escape"||e.key==="Tab"?(this.buttonPressed_&&this.unpressButton(),!e.key==="Tab"&&(e.preventDefault(),this.menuButton_.focus())):(e.key==="Up"||e.key==="Down"&&!(this.player_.options_.playerOptions.spatialNavigation&&this.player_.options_.playerOptions.spatialNavigation.enabled))&&(this.buttonPressed_||(e.preventDefault(),this.pressButton()))}handleMenuKeyUp(e){(e.key==="Escape"||e.key==="Tab")&&this.removeClass("vjs-hover")}handleSubmenuKeyPress(e){this.handleSubmenuKeyDown(e)}handleSubmenuKeyDown(e){(e.key==="Escape"||e.key==="Tab")&&(this.buttonPressed_&&this.unpressButton(),!e.key==="Tab"&&(e.preventDefault(),this.menuButton_.focus()))}pressButton(){if(this.enabled_){if(this.buttonPressed_=!0,this.menu.show(),this.menu.lockShowing(),this.menuButton_.el_.setAttribute("aria-expanded","true"),Je&&Dh())return;this.menu.focus()}}unpressButton(){this.enabled_&&(this.buttonPressed_=!1,this.menu.unlockShowing(),this.menu.hide(),this.menuButton_.el_.setAttribute("aria-expanded","false"))}disable(){this.unpressButton(),this.enabled_=!1,this.addClass("vjs-disabled"),this.menuButton_.disable()}enable(){this.enabled_=!0,this.removeClass("vjs-disabled"),this.menuButton_.enable()}}H.registerComponent("MenuButton",Zo);class el extends Zo{constructor(e,t){const n=t.tracks;if(super(e,t),this.items.length<=1&&this.hide(),!n)return;const s=Ce(this,this.update);n.addEventListener("removetrack",s),n.addEventListener("addtrack",s),n.addEventListener("labelchange",s),this.player_.on("ready",s),this.player_.on("dispose",function(){n.removeEventListener("removetrack",s),n.removeEventListener("addtrack",s),n.removeEventListener("labelchange",s)})}}H.registerComponent("TrackButton",el);class Ts extends Jr{constructor(e,t){super(e,t),this.selectable=t.selectable,this.isSelected_=t.selected||!1,this.multiSelectable=t.multiSelectable,this.selected(this.isSelected_),this.selectable?this.multiSelectable?this.el_.setAttribute("role","menuitemcheckbox"):this.el_.setAttribute("role","menuitemradio"):this.el_.setAttribute("role","menuitem")}createEl(e,t,n){this.nonIconControl=!0;const s=super.createEl("li",Object.assign({className:"vjs-menu-item",tabIndex:-1},t),n),r=ne("span",{className:"vjs-menu-item-text",textContent:this.localize(this.options_.label)});return this.player_.options_.experimentalSvgIcons?s.appendChild(r):s.replaceChild(r,s.querySelector(".vjs-icon-placeholder")),s}handleKeyDown(e){["Tab","Escape","ArrowUp","ArrowLeft","ArrowRight","ArrowDown"].includes(e.key)||super.handleKeyDown(e)}handleClick(e){this.selected(!0)}selected(e){this.selectable&&(e?(this.addClass("vjs-selected"),this.el_.setAttribute("aria-checked","true"),this.controlText(", selected"),this.isSelected_=!0):(this.removeClass("vjs-selected"),this.el_.setAttribute("aria-checked","false"),this.controlText(""),this.isSelected_=!1))}}H.registerComponent("MenuItem",Ts);class vs extends Ts{constructor(e,t){const n=t.track,s=e.textTracks();t.label=n.label||n.language||"Unknown",t.selected=n.mode==="showing",super(e,t),this.track=n,this.kinds=(t.kinds||[t.kind||this.track.kind]).filter(Boolean);const r=(...l)=>{this.handleTracksChange.apply(this,l)},a=(...l)=>{this.handleSelectedLanguageChange.apply(this,l)};if(e.on(["loadstart","texttrackchange"],r),s.addEventListener("change",r),s.addEventListener("selectedlanguagechange",a),this.on("dispose",function(){e.off(["loadstart","texttrackchange"],r),s.removeEventListener("change",r),s.removeEventListener("selectedlanguagechange",a)}),s.onchange===void 0){let l;this.on(["tap","click"],function(){if(typeof x.Event!="object")try{l=new x.Event("change")}catch{}l||(l=G.createEvent("Event"),l.initEvent("change",!0,!0)),s.dispatchEvent(l)})}this.handleTracksChange()}handleClick(e){const t=this.track,n=this.player_.textTracks();if(super.handleClick(e),!!n)for(let s=0;s<n.length;s++){const r=n[s];this.kinds.indexOf(r.kind)!==-1&&(r===t?r.mode!=="showing"&&(r.mode="showing"):r.mode!=="disabled"&&(r.mode="disabled"))}}handleTracksChange(e){const t=this.track.mode==="showing";t!==this.isSelected_&&this.selected(t)}handleSelectedLanguageChange(e){if(this.track.mode==="showing"){const t=this.player_.cache_.selectedLanguage;if(t&&t.enabled&&t.language===this.track.language&&t.kind!==this.track.kind)return;this.player_.cache_.selectedLanguage={enabled:!0,language:this.track.language,kind:this.track.kind}}}dispose(){this.track=null,super.dispose()}}H.registerComponent("TextTrackMenuItem",vs);class Sc extends vs{constructor(e,t){t.track={player:e,kind:t.kind,kinds:t.kinds,default:!1,mode:"disabled"},t.kinds||(t.kinds=[t.kind]),t.label?t.track.label=t.label:t.track.label=t.kinds.join(" and ")+" off",t.selectable=!0,t.multiSelectable=!1,super(e,t)}handleTracksChange(e){const t=this.player().textTracks();let n=!0;for(let s=0,r=t.length;s<r;s++){const a=t[s];if(this.options_.kinds.indexOf(a.kind)>-1&&a.mode==="showing"){n=!1;break}}n!==this.isSelected_&&this.selected(n)}handleSelectedLanguageChange(e){const t=this.player().textTracks();let n=!0;for(let s=0,r=t.length;s<r;s++){const a=t[s];if(["captions","descriptions","subtitles"].indexOf(a.kind)>-1&&a.mode==="showing"){n=!1;break}}n&&(this.player_.cache_.selectedLanguage={enabled:!1})}handleLanguagechange(){this.$(".vjs-menu-item-text").textContent=this.player_.localize(this.options_.label),super.handleLanguagechange()}}H.registerComponent("OffTextTrackMenuItem",Sc);class xn extends el{constructor(e,t={}){t.tracks=e.textTracks(),super(e,t)}createItems(e=[],t=vs){let n;this.label_&&(n=`${this.label_} off`),e.push(new Sc(this.player_,{kinds:this.kinds_,kind:this.kind_,label:n})),this.hideThreshold_+=1;const s=this.player_.textTracks();Array.isArray(this.kinds_)||(this.kinds_=[this.kind_]);for(let r=0;r<s.length;r++){const a=s[r];if(this.kinds_.indexOf(a.kind)>-1){const l=new t(this.player_,{track:a,kinds:this.kinds_,kind:this.kind_,selectable:!0,multiSelectable:!1});l.addClass(`vjs-${a.kind}-menu-item`),e.push(l)}}return e}}H.registerComponent("TextTrackButton",xn);class Ec extends Ts{constructor(e,t){const n=t.track,s=t.cue,r=e.currentTime();t.selectable=!0,t.multiSelectable=!1,t.label=s.text,t.selected=s.startTime<=r&&r<s.endTime,super(e,t),this.track=n,this.cue=s}handleClick(e){super.handleClick(),this.player_.currentTime(this.cue.startTime)}}H.registerComponent("ChaptersTrackMenuItem",Ec);class tl extends xn{constructor(e,t,n){super(e,t,n),this.setIcon("chapters"),this.selectCurrentItem_=()=>{this.items.forEach(s=>{s.selected(this.track_.activeCues[0]===s.cue)})}}buildCSSClass(){return`vjs-chapters-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-chapters-button ${super.buildWrapperCSSClass()}`}update(e){if(e&&e.track&&e.track.kind!=="chapters")return;const t=this.findChaptersTrack();t!==this.track_?(this.setTrack(t),super.update()):(!this.items||t&&t.cues&&t.cues.length!==this.items.length)&&super.update()}setTrack(e){if(this.track_!==e){if(this.updateHandler_||(this.updateHandler_=this.update.bind(this)),this.track_){const t=this.player_.remoteTextTrackEls().getTrackElementByTrack_(this.track_);t&&t.removeEventListener("load",this.updateHandler_),this.track_.removeEventListener("cuechange",this.selectCurrentItem_),this.track_=null}if(this.track_=e,this.track_){this.track_.mode="hidden";const t=this.player_.remoteTextTrackEls().getTrackElementByTrack_(this.track_);t&&t.addEventListener("load",this.updateHandler_),this.track_.addEventListener("cuechange",this.selectCurrentItem_)}}}findChaptersTrack(){const e=this.player_.textTracks()||[];for(let t=e.length-1;t>=0;t--){const n=e[t];if(n.kind===this.kind_)return n}}getMenuCaption(){return this.track_&&this.track_.label?this.track_.label:this.localize(Ne(this.kind_))}createMenu(){return this.options_.title=this.getMenuCaption(),super.createMenu()}createItems(){const e=[];if(!this.track_)return e;const t=this.track_.cues;if(!t)return e;for(let n=0,s=t.length;n<s;n++){const r=t[n],a=new Ec(this.player_,{track:this.track_,cue:r});e.push(a)}return e}}tl.prototype.kind_="chapters";tl.prototype.controlText_="Chapters";H.registerComponent("ChaptersButton",tl);class il extends xn{constructor(e,t,n){super(e,t,n),this.setIcon("audio-description");const s=e.textTracks(),r=Ce(this,this.handleTracksChange);s.addEventListener("change",r),this.on("dispose",function(){s.removeEventListener("change",r)})}handleTracksChange(e){const t=this.player().textTracks();let n=!1;for(let s=0,r=t.length;s<r;s++){const a=t[s];if(a.kind!==this.kind_&&a.mode==="showing"){n=!0;break}}n?this.disable():this.enable()}buildCSSClass(){return`vjs-descriptions-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-descriptions-button ${super.buildWrapperCSSClass()}`}}il.prototype.kind_="descriptions";il.prototype.controlText_="Descriptions";H.registerComponent("DescriptionsButton",il);class nl extends xn{constructor(e,t,n){super(e,t,n),this.setIcon("subtitles")}buildCSSClass(){return`vjs-subtitles-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-subtitles-button ${super.buildWrapperCSSClass()}`}}nl.prototype.kind_="subtitles";nl.prototype.controlText_="Subtitles";H.registerComponent("SubtitlesButton",nl);class sl extends vs{constructor(e,t){t.track={player:e,kind:t.kind,label:t.kind+" settings",selectable:!1,default:!1,mode:"disabled"},t.selectable=!1,t.name="CaptionSettingsMenuItem",super(e,t),this.addClass("vjs-texttrack-settings"),this.controlText(", opens "+t.kind+" settings dialog")}handleClick(e){this.player().getChild("textTrackSettings").open()}handleLanguagechange(){this.$(".vjs-menu-item-text").textContent=this.player_.localize(this.options_.kind+" settings"),super.handleLanguagechange()}}H.registerComponent("CaptionSettingsMenuItem",sl);class rl extends xn{constructor(e,t,n){super(e,t,n),this.setIcon("captions")}buildCSSClass(){return`vjs-captions-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-captions-button ${super.buildWrapperCSSClass()}`}createItems(){const e=[];return!(this.player().tech_&&this.player().tech_.featuresNativeTextTracks)&&this.player().getChild("textTrackSettings")&&(e.push(new sl(this.player_,{kind:this.kind_})),this.hideThreshold_+=1),super.createItems(e)}}rl.prototype.kind_="captions";rl.prototype.controlText_="Captions";H.registerComponent("CaptionsButton",rl);class wc extends vs{createEl(e,t,n){const s=super.createEl(e,t,n),r=s.querySelector(".vjs-menu-item-text");return this.options_.track.kind==="captions"&&(this.player_.options_.experimentalSvgIcons?this.setIcon("captions",s):r.appendChild(ne("span",{className:"vjs-icon-placeholder"},{"aria-hidden":!0})),r.appendChild(ne("span",{className:"vjs-control-text",textContent:` ${this.localize("Captions")}`}))),s}}H.registerComponent("SubsCapsMenuItem",wc);class al extends xn{constructor(e,t={}){super(e,t),this.label_="subtitles",this.setIcon("subtitles"),["en","en-us","en-ca","fr-ca"].indexOf(this.player_.language_)>-1&&(this.label_="captions",this.setIcon("captions")),this.menuButton_.controlText(Ne(this.label_))}buildCSSClass(){return`vjs-subs-caps-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-subs-caps-button ${super.buildWrapperCSSClass()}`}createItems(){let e=[];return!(this.player().tech_&&this.player().tech_.featuresNativeTextTracks)&&this.player().getChild("textTrackSettings")&&(e.push(new sl(this.player_,{kind:this.label_})),this.hideThreshold_+=1),e=super.createItems(e,wc),e}}al.prototype.kinds_=["captions","subtitles"];al.prototype.controlText_="Subtitles";H.registerComponent("SubsCapsButton",al);class kc extends Ts{constructor(e,t){const n=t.track,s=e.audioTracks();t.label=n.label||n.language||"Unknown",t.selected=n.enabled,super(e,t),this.track=n,this.addClass(`vjs-${n.kind}-menu-item`);const r=(...a)=>{this.handleTracksChange.apply(this,a)};s.addEventListener("change",r),this.on("dispose",()=>{s.removeEventListener("change",r)})}createEl(e,t,n){const s=super.createEl(e,t,n),r=s.querySelector(".vjs-menu-item-text");return["main-desc","descriptions"].indexOf(this.options_.track.kind)>=0&&(r.appendChild(ne("span",{className:"vjs-icon-placeholder"},{"aria-hidden":!0})),r.appendChild(ne("span",{className:"vjs-control-text",textContent:" "+this.localize("Descriptions")}))),s}handleClick(e){if(super.handleClick(e),this.track.enabled=!0,this.player_.tech_.featuresNativeAudioTracks){const t=this.player_.audioTracks();for(let n=0;n<t.length;n++){const s=t[n];s!==this.track&&(s.enabled=s===this.track)}}}handleTracksChange(e){this.selected(this.track.enabled)}}H.registerComponent("AudioTrackMenuItem",kc);class Cc extends el{constructor(e,t={}){t.tracks=e.audioTracks(),super(e,t),this.setIcon("audio")}buildCSSClass(){return`vjs-audio-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-audio-button ${super.buildWrapperCSSClass()}`}createItems(e=[]){this.hideThreshold_=1;const t=this.player_.audioTracks();for(let n=0;n<t.length;n++){const s=t[n];e.push(new kc(this.player_,{track:s,selectable:!0,multiSelectable:!1}))}return e}}Cc.prototype.controlText_="Audio Track";H.registerComponent("AudioTrackButton",Cc);class ol extends Ts{constructor(e,t){const n=t.rate,s=parseFloat(n,10);t.label=n,t.selected=s===e.playbackRate(),t.selectable=!0,t.multiSelectable=!1,super(e,t),this.label=n,this.rate=s,this.on(e,"ratechange",r=>this.update(r))}handleClick(e){super.handleClick(),this.player().playbackRate(this.rate)}update(e){this.selected(this.player().playbackRate()===this.rate)}}ol.prototype.contentElType="button";H.registerComponent("PlaybackRateMenuItem",ol);class Ic extends Zo{constructor(e,t){super(e,t),this.menuButton_.el_.setAttribute("aria-describedby",this.labelElId_),this.updateVisibility(),this.updateLabel(),this.on(e,"loadstart",n=>this.updateVisibility(n)),this.on(e,"ratechange",n=>this.updateLabel(n)),this.on(e,"playbackrateschange",n=>this.handlePlaybackRateschange(n))}createEl(){const e=super.createEl();return this.labelElId_="vjs-playback-rate-value-label-"+this.id_,this.labelEl_=ne("div",{className:"vjs-playback-rate-value",id:this.labelElId_,textContent:"1x"}),e.appendChild(this.labelEl_),e}dispose(){this.labelEl_=null,super.dispose()}buildCSSClass(){return`vjs-playback-rate ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-playback-rate ${super.buildWrapperCSSClass()}`}createItems(){const e=this.playbackRates(),t=[];for(let n=e.length-1;n>=0;n--)t.push(new ol(this.player(),{rate:e[n]+"x"}));return t}handlePlaybackRateschange(e){this.update()}playbackRates(){const e=this.player();return e.playbackRates&&e.playbackRates()||[]}playbackRateSupported(){return this.player().tech_&&this.player().tech_.featuresPlaybackRate&&this.playbackRates()&&this.playbackRates().length>0}updateVisibility(e){this.playbackRateSupported()?this.removeClass("vjs-hidden"):this.addClass("vjs-hidden")}updateLabel(e){this.playbackRateSupported()&&(this.labelEl_.textContent=this.player().playbackRate()+"x")}}Ic.prototype.controlText_="Playback Rate";H.registerComponent("PlaybackRateMenuButton",Ic);class xc extends H{buildCSSClass(){return`vjs-spacer ${super.buildCSSClass()}`}createEl(e="div",t={},n={}){return t.className||(t.className=this.buildCSSClass()),super.createEl(e,t,n)}}H.registerComponent("Spacer",xc);class kb extends xc{buildCSSClass(){return`vjs-custom-control-spacer ${super.buildCSSClass()}`}createEl(){return super.createEl("div",{className:this.buildCSSClass(),textContent:" "})}}H.registerComponent("CustomControlSpacer",kb);class Ac extends H{createEl(){return super.createEl("div",{className:"vjs-control-bar",dir:"ltr"})}}Ac.prototype.options_={children:["playToggle","skipBackward","skipForward","volumePanel","currentTimeDisplay","timeDivider","durationDisplay","progressControl","liveDisplay","seekToLive","remainingTimeDisplay","customControlSpacer","playbackRateMenuButton","chaptersButton","descriptionsButton","subsCapsButton","audioTrackButton","pictureInPictureToggle","fullscreenToggle"]};H.registerComponent("ControlBar",Ac);class Pc extends Cn{constructor(e,t){super(e,t),this.on(e,"error",n=>{this.open(n)})}buildCSSClass(){return`vjs-error-display ${super.buildCSSClass()}`}content(){const e=this.player().error();return e?this.localize(e.message):""}}Pc.prototype.options_=Object.assign({},Cn.prototype.options_,{pauseOnOpen:!1,fillAlways:!0,temporary:!1,uncloseable:!0});H.registerComponent("ErrorDisplay",Pc);class Lc extends H{constructor(e,t={}){super(e,t),this.el_.setAttribute("aria-labelledby",this.selectLabelledbyIds)}createEl(){return this.selectLabelledbyIds=[this.options_.legendId,this.options_.labelId].join(" ").trim(),ne("select",{id:this.options_.id},{},this.options_.SelectOptions.map(e=>{const t=(this.options_.labelId?this.options_.labelId:`vjs-track-option-${At()}`)+"-"+e[1].replace(/\W+/g,""),n=ne("option",{id:t,value:this.localize(e[0]),textContent:this.localize(e[1])});return n.setAttribute("aria-labelledby",`${this.selectLabelledbyIds} ${t}`),n}))}}H.registerComponent("TextTrackSelect",Lc);class ji extends H{constructor(e,t={}){super(e,t);const n=ne("legend",{textContent:this.localize(this.options_.legendText),id:this.options_.legendId});this.el().appendChild(n);const s=this.options_.selects;for(const r of s){const a=this.options_.selectConfigs[r],l=a.className,c=a.id.replace("%s",this.options_.id_);let f=null;const m=`vjs_select_${At()}`;if(this.options_.type==="colors"){f=ne("span",{className:l});const C=ne("label",{id:c,className:"vjs-label",textContent:this.localize(a.label)});C.setAttribute("for",m),f.appendChild(C)}const b=new Lc(e,{SelectOptions:a.options,legendId:this.options_.legendId,id:m,labelId:c});this.addChild(b),this.options_.type==="colors"&&(f.appendChild(b.el()),this.el().appendChild(f))}}createEl(){return ne("fieldset",{className:this.options_.className})}}H.registerComponent("TextTrackFieldset",ji);class Dc extends H{constructor(e,t={}){super(e,t);const n=this.options_.textTrackComponentid,s=new ji(e,{id_:n,legendId:`captions-text-legend-${n}`,legendText:this.localize("Text"),className:"vjs-fg vjs-track-setting",selects:this.options_.fieldSets[0],selectConfigs:this.options_.selectConfigs,type:"colors"});this.addChild(s);const r=new ji(e,{id_:n,legendId:`captions-background-${n}`,legendText:this.localize("Text Background"),className:"vjs-bg vjs-track-setting",selects:this.options_.fieldSets[1],selectConfigs:this.options_.selectConfigs,type:"colors"});this.addChild(r);const a=new ji(e,{id_:n,legendId:`captions-window-${n}`,legendText:this.localize("Caption Area Background"),className:"vjs-window vjs-track-setting",selects:this.options_.fieldSets[2],selectConfigs:this.options_.selectConfigs,type:"colors"});this.addChild(a)}createEl(){return ne("div",{className:"vjs-track-settings-colors"})}}H.registerComponent("TextTrackSettingsColors",Dc);class Oc extends H{constructor(e,t={}){super(e,t);const n=this.options_.textTrackComponentid,s=new ji(e,{id_:n,legendId:`captions-font-size-${n}`,legendText:"Font Size",className:"vjs-font-percent vjs-track-setting",selects:this.options_.fieldSets[0],selectConfigs:this.options_.selectConfigs,type:"font"});this.addChild(s);const r=new ji(e,{id_:n,legendId:`captions-edge-style-${n}`,legendText:this.localize("Text Edge Style"),className:"vjs-edge-style vjs-track-setting",selects:this.options_.fieldSets[1],selectConfigs:this.options_.selectConfigs,type:"font"});this.addChild(r);const a=new ji(e,{id_:n,legendId:`captions-font-family-${n}`,legendText:this.localize("Font Family"),className:"vjs-font-family vjs-track-setting",selects:this.options_.fieldSets[2],selectConfigs:this.options_.selectConfigs,type:"font"});this.addChild(a)}createEl(){return ne("div",{className:"vjs-track-settings-font"})}}H.registerComponent("TextTrackSettingsFont",Oc);class Mc extends H{constructor(e,t={}){super(e,t);const n=this.localize("restore all settings to the default values"),s=new et(e,{controlText:n,className:"vjs-default-button"});s.el().classList.remove("vjs-control","vjs-button"),s.el().textContent=this.localize("Reset"),this.addChild(s);const r=new et(e,{controlText:n,className:"vjs-done-button"});r.el().classList.remove("vjs-control","vjs-button"),r.el().textContent=this.localize("Done"),this.addChild(r)}createEl(){return ne("div",{className:"vjs-track-settings-controls"})}}H.registerComponent("TrackSettingsControls",Mc);const Ba="vjs-text-track-settings",Ku=["#000","Black"],Yu=["#00F","Blue"],Qu=["#0FF","Cyan"],Ju=["#0F0","Green"],Zu=["#F0F","Magenta"],ed=["#F00","Red"],td=["#FFF","White"],id=["#FF0","Yellow"],Fa=["1","Opaque"],ja=["0.5","Semi-Transparent"],nd=["0","Transparent"],bi={backgroundColor:{selector:".vjs-bg-color > select",id:"captions-background-color-%s",label:"Color",options:[Ku,td,ed,Ju,Yu,id,Zu,Qu],className:"vjs-bg-color"},backgroundOpacity:{selector:".vjs-bg-opacity > select",id:"captions-background-opacity-%s",label:"Opacity",options:[Fa,ja,nd],className:"vjs-bg-opacity vjs-opacity"},color:{selector:".vjs-text-color > select",id:"captions-foreground-color-%s",label:"Color",options:[td,Ku,ed,Ju,Yu,id,Zu,Qu],className:"vjs-text-color"},edgeStyle:{selector:".vjs-edge-style > select",id:"",label:"Text Edge Style",options:[["none","None"],["raised","Raised"],["depressed","Depressed"],["uniform","Uniform"],["dropshadow","Drop shadow"]]},fontFamily:{selector:".vjs-font-family > select",id:"",label:"Font Family",options:[["proportionalSansSerif","Proportional Sans-Serif"],["monospaceSansSerif","Monospace Sans-Serif"],["proportionalSerif","Proportional Serif"],["monospaceSerif","Monospace Serif"],["casual","Casual"],["script","Script"],["small-caps","Small Caps"]]},fontPercent:{selector:".vjs-font-percent > select",id:"",label:"Font Size",options:[["0.50","50%"],["0.75","75%"],["1.00","100%"],["1.25","125%"],["1.50","150%"],["1.75","175%"],["2.00","200%"],["3.00","300%"],["4.00","400%"]],default:2,parser:i=>i==="1.00"?null:Number(i)},textOpacity:{selector:".vjs-text-opacity > select",id:"captions-foreground-opacity-%s",label:"Opacity",options:[Fa,ja],className:"vjs-text-opacity vjs-opacity"},windowColor:{selector:".vjs-window-color > select",id:"captions-window-color-%s",label:"Color",className:"vjs-window-color"},windowOpacity:{selector:".vjs-window-opacity > select",id:"captions-window-opacity-%s",label:"Opacity",options:[nd,ja,Fa],className:"vjs-window-opacity vjs-opacity"}};bi.windowColor.options=bi.backgroundColor.options;function Rc(i,e){if(e&&(i=e(i)),i&&i!=="none")return i}function Cb(i,e){const t=i.options[i.options.selectedIndex].value;return Rc(t,e)}function Ib(i,e,t){if(e){for(let n=0;n<i.options.length;n++)if(Rc(i.options[n].value,t)===e){i.selectedIndex=n;break}}}class xb extends Cn{constructor(e,t){t.temporary=!1,super(e,t),this.updateDisplay=this.updateDisplay.bind(this),this.fill(),this.hasBeenOpened_=this.hasBeenFilled_=!0,this.renderModalComponents(e),this.endDialog=ne("p",{className:"vjs-control-text",textContent:this.localize("End of dialog window.")}),this.el().appendChild(this.endDialog),this.setDefaults(),t.persistTextTrackSettings===void 0&&(this.options_.persistTextTrackSettings=this.options_.playerOptions.persistTextTrackSettings),this.bindFunctionsToSelectsAndButtons(),this.options_.persistTextTrackSettings&&this.restoreSettings()}renderModalComponents(e){const t=new Dc(e,{textTrackComponentid:this.id_,selectConfigs:bi,fieldSets:[["color","textOpacity"],["backgroundColor","backgroundOpacity"],["windowColor","windowOpacity"]]});this.addChild(t);const n=new Oc(e,{textTrackComponentid:this.id_,selectConfigs:bi,fieldSets:[["fontPercent"],["edgeStyle"],["fontFamily"]]});this.addChild(n);const s=new Mc(e);this.addChild(s)}bindFunctionsToSelectsAndButtons(){this.on(this.$(".vjs-done-button"),["click","tap"],()=>{this.saveSettings(),this.close()}),this.on(this.$(".vjs-default-button"),["click","tap"],()=>{this.setDefaults(),this.updateDisplay()}),sn(bi,e=>{this.on(this.$(e.selector),"change",this.updateDisplay)})}dispose(){this.endDialog=null,super.dispose()}label(){return this.localize("Caption Settings Dialog")}description(){return this.localize("Beginning of dialog window. Escape will cancel and close the window.")}buildCSSClass(){return super.buildCSSClass()+" vjs-text-track-settings"}getValues(){return kh(bi,(e,t,n)=>{const s=Cb(this.$(t.selector),t.parser);return s!==void 0&&(e[n]=s),e},{})}setValues(e){sn(bi,(t,n)=>{Ib(this.$(t.selector),e[n],t.parser)})}setDefaults(){sn(bi,e=>{const t=e.hasOwnProperty("default")?e.default:0;this.$(e.selector).selectedIndex=t})}restoreSettings(){let e;try{e=JSON.parse(x.localStorage.getItem(Ba))}catch(t){oe.warn(t)}e&&this.setValues(e)}saveSettings(){if(!this.options_.persistTextTrackSettings)return;const e=this.getValues();try{Object.keys(e).length?x.localStorage.setItem(Ba,JSON.stringify(e)):x.localStorage.removeItem(Ba)}catch(t){oe.warn(t)}}updateDisplay(){const e=this.player_.getChild("textTrackDisplay");e&&e.updateDisplay()}handleLanguagechange(){this.fill(),this.renderModalComponents(this.player_),this.bindFunctionsToSelectsAndButtons()}}H.registerComponent("TextTrackSettings",xb);class Ab extends H{constructor(e,t){let n=t.ResizeObserver||x.ResizeObserver;t.ResizeObserver===null&&(n=!1);const s=ve({createEl:!n,reportTouchActivity:!1},t);super(e,s),this.ResizeObserver=t.ResizeObserver||x.ResizeObserver,this.loadListener_=null,this.resizeObserver_=null,this.debouncedHandler_=Xh(()=>{this.resizeHandler()},100,!1,this),n?(this.resizeObserver_=new this.ResizeObserver(this.debouncedHandler_),this.resizeObserver_.observe(e.el())):(this.loadListener_=()=>{if(!this.el_||!this.el_.contentWindow)return;const r=this.debouncedHandler_;let a=this.unloadListener_=function(){Ze(this,"resize",r),Ze(this,"unload",a),a=null};vt(this.el_.contentWindow,"unload",a),vt(this.el_.contentWindow,"resize",r)},this.one("load",this.loadListener_))}createEl(){return super.createEl("iframe",{className:"vjs-resize-manager",tabIndex:-1,title:this.localize("No content")},{"aria-hidden":"true"})}resizeHandler(){!this.player_||!this.player_.trigger||this.player_.trigger("playerresize")}dispose(){this.debouncedHandler_&&this.debouncedHandler_.cancel(),this.resizeObserver_&&(this.player_.el()&&this.resizeObserver_.unobserve(this.player_.el()),this.resizeObserver_.disconnect()),this.loadListener_&&this.off("load",this.loadListener_),this.el_&&this.el_.contentWindow&&this.unloadListener_&&this.unloadListener_.call(this.el_.contentWindow),this.ResizeObserver=null,this.resizeObserver=null,this.debouncedHandler_=null,this.loadListener_=null,super.dispose()}}H.registerComponent("ResizeManager",Ab);const Pb={trackingThreshold:20,liveTolerance:15};class Lb extends H{constructor(e,t){const n=ve(Pb,t,{createEl:!1});super(e,n),this.trackLiveHandler_=()=>this.trackLive_(),this.handlePlay_=s=>this.handlePlay(s),this.handleFirstTimeupdate_=s=>this.handleFirstTimeupdate(s),this.handleSeeked_=s=>this.handleSeeked(s),this.seekToLiveEdge_=s=>this.seekToLiveEdge(s),this.reset_(),this.on(this.player_,"durationchange",s=>this.handleDurationchange(s)),this.on(this.player_,"canplay",()=>this.toggleTracking())}trackLive_(){const e=this.player_.seekable();if(!e||!e.length)return;const t=Number(x.performance.now().toFixed(4)),n=this.lastTime_===-1?0:(t-this.lastTime_)/1e3;this.lastTime_=t,this.pastSeekEnd_=this.pastSeekEnd()+n;const s=this.liveCurrentTime(),r=this.player_.currentTime();let a=this.player_.paused()||this.seekedBehindLive_||Math.abs(s-r)>this.options_.liveTolerance;(!this.timeupdateSeen_||s===1/0)&&(a=!1),a!==this.behindLiveEdge_&&(this.behindLiveEdge_=a,this.trigger("liveedgechange"))}handleDurationchange(){this.toggleTracking()}toggleTracking(){this.player_.duration()===1/0&&this.liveWindow()>=this.options_.trackingThreshold?(this.player_.options_.liveui&&this.player_.addClass("vjs-liveui"),this.startTracking()):(this.player_.removeClass("vjs-liveui"),this.stopTracking())}startTracking(){this.isTracking()||(this.timeupdateSeen_||(this.timeupdateSeen_=this.player_.hasStarted()),this.trackingInterval_=this.setInterval(this.trackLiveHandler_,Pt),this.trackLive_(),this.on(this.player_,["play","pause"],this.trackLiveHandler_),this.timeupdateSeen_?this.on(this.player_,"seeked",this.handleSeeked_):(this.one(this.player_,"play",this.handlePlay_),this.one(this.player_,"timeupdate",this.handleFirstTimeupdate_)))}handleFirstTimeupdate(){this.timeupdateSeen_=!0,this.on(this.player_,"seeked",this.handleSeeked_)}handleSeeked(){const e=Math.abs(this.liveCurrentTime()-this.player_.currentTime());this.seekedBehindLive_=this.nextSeekedFromUser_&&e>2,this.nextSeekedFromUser_=!1,this.trackLive_()}handlePlay(){this.one(this.player_,"timeupdate",this.seekToLiveEdge_)}reset_(){this.lastTime_=-1,this.pastSeekEnd_=0,this.lastSeekEnd_=-1,this.behindLiveEdge_=!0,this.timeupdateSeen_=!1,this.seekedBehindLive_=!1,this.nextSeekedFromUser_=!1,this.clearInterval(this.trackingInterval_),this.trackingInterval_=null,this.off(this.player_,["play","pause"],this.trackLiveHandler_),this.off(this.player_,"seeked",this.handleSeeked_),this.off(this.player_,"play",this.handlePlay_),this.off(this.player_,"timeupdate",this.handleFirstTimeupdate_),this.off(this.player_,"timeupdate",this.seekToLiveEdge_)}nextSeekedFromUser(){this.nextSeekedFromUser_=!0}stopTracking(){this.isTracking()&&(this.reset_(),this.trigger("liveedgechange"))}seekableEnd(){const e=this.player_.seekable(),t=[];let n=e?e.length:0;for(;n--;)t.push(e.end(n));return t.length?t.sort()[t.length-1]:1/0}seekableStart(){const e=this.player_.seekable(),t=[];let n=e?e.length:0;for(;n--;)t.push(e.start(n));return t.length?t.sort()[0]:0}liveWindow(){const e=this.liveCurrentTime();return e===1/0?0:e-this.seekableStart()}isLive(){return this.isTracking()}atLiveEdge(){return!this.behindLiveEdge()}liveCurrentTime(){return this.pastSeekEnd()+this.seekableEnd()}pastSeekEnd(){const e=this.seekableEnd();return this.lastSeekEnd_!==-1&&e!==this.lastSeekEnd_&&(this.pastSeekEnd_=0),this.lastSeekEnd_=e,this.pastSeekEnd_}behindLiveEdge(){return this.behindLiveEdge_}isTracking(){return typeof this.trackingInterval_=="number"}seekToLiveEdge(){this.seekedBehindLive_=!1,!this.atLiveEdge()&&(this.nextSeekedFromUser_=!1,this.player_.currentTime(this.liveCurrentTime()))}dispose(){this.stopTracking(),super.dispose()}}H.registerComponent("LiveTracker",Lb);class Db extends H{constructor(e,t){super(e,t),this.on("statechanged",n=>this.updateDom_()),this.updateDom_()}createEl(){return this.els={title:ne("div",{className:"vjs-title-bar-title",id:`vjs-title-bar-title-${At()}`}),description:ne("div",{className:"vjs-title-bar-description",id:`vjs-title-bar-description-${At()}`})},ne("div",{className:"vjs-title-bar"},{},Ch(this.els))}updateDom_(){const e=this.player_.tech_,t=e&&e.el_,n={title:"aria-labelledby",description:"aria-describedby"};["title","description"].forEach(s=>{const r=this.state[s],a=this.els[s],l=n[s];Gr(a),r&&Si(a,r),t&&(t.removeAttribute(l),r&&t.setAttribute(l,a.id))}),this.state.title||this.state.description?this.show():this.hide()}update(e){this.setState(e)}dispose(){const e=this.player_.tech_,t=e&&e.el_;t&&(t.removeAttribute("aria-labelledby"),t.removeAttribute("aria-describedby")),super.dispose(),this.els=null}}H.registerComponent("TitleBar",Db);const Ob={initialDisplay:4e3,position:[],takeFocus:!1};class Mb extends et{constructor(e,t){t=ve(Ob,t),super(e,t),this.controlText(t.controlText),this.hide(),this.on(this.player_,["useractive","userinactive"],n=>{this.removeClass("force-display")})}buildCSSClass(){return`vjs-transient-button focus-visible ${this.options_.position.map(e=>`vjs-${e}`).join(" ")}`}createEl(){const e=ne("button",{},{type:"button",class:this.buildCSSClass()},ne("span"));return this.controlTextEl_=e.querySelector("span"),e}show(){super.show(),this.addClass("force-display"),this.options_.takeFocus&&this.el().focus({preventScroll:!0}),this.forceDisplayTimeout=this.player_.setTimeout(()=>{this.removeClass("force-display")},this.options_.initialDisplay)}hide(){this.removeClass("force-display"),super.hide()}dispose(){this.player_.clearTimeout(this.forceDisplayTimeout),super.dispose()}}H.registerComponent("TransientButton",Mb);const so=i=>{const e=i.el();if(e.hasAttribute("src"))return i.triggerSourceset(e.src),!0;const t=i.$$("source"),n=[];let s="";if(!t.length)return!1;for(let r=0;r<t.length;r++){const a=t[r].src;a&&n.indexOf(a)===-1&&n.push(a)}return n.length?(n.length===1&&(s=n[0]),i.triggerSourceset(s),!0):!1},Rb=Object.defineProperty({},"innerHTML",{get(){return this.cloneNode(!0).innerHTML},set(i){const e=G.createElement(this.nodeName.toLowerCase());e.innerHTML=i;const t=G.createDocumentFragment();for(;e.childNodes.length;)t.appendChild(e.childNodes[0]);return this.innerText="",x.Element.prototype.appendChild.call(this,t),this.innerHTML}}),Uc=(i,e)=>{let t={};for(let n=0;n<i.length&&(t=Object.getOwnPropertyDescriptor(i[n],e),!(t&&t.set&&t.get));n++);return t.enumerable=!0,t.configurable=!0,t},Ub=i=>Uc([i.el(),x.HTMLMediaElement.prototype,x.Element.prototype,Rb],"innerHTML"),sd=function(i){const e=i.el();if(e.resetSourceWatch_)return;const t={},n=Ub(i),s=r=>(...a)=>{const l=r.apply(e,a);return so(i),l};["append","appendChild","insertAdjacentHTML"].forEach(r=>{e[r]&&(t[r]=e[r],e[r]=s(t[r]))}),Object.defineProperty(e,"innerHTML",ve(n,{set:s(n.set)})),e.resetSourceWatch_=()=>{e.resetSourceWatch_=null,Object.keys(t).forEach(r=>{e[r]=t[r]}),Object.defineProperty(e,"innerHTML",n)},i.one("sourceset",e.resetSourceWatch_)},Nb=Object.defineProperty({},"src",{get(){return this.hasAttribute("src")?sc(x.Element.prototype.getAttribute.call(this,"src")):""},set(i){return x.Element.prototype.setAttribute.call(this,"src",i),i}}),Bb=i=>Uc([i.el(),x.HTMLMediaElement.prototype,Nb],"src"),Fb=function(i){if(!i.featuresSourceset)return;const e=i.el();if(e.resetSourceset_)return;const t=Bb(i),n=e.setAttribute,s=e.load;Object.defineProperty(e,"src",ve(t,{set:r=>{const a=t.set.call(e,r);return i.triggerSourceset(e.src),a}})),e.setAttribute=(r,a)=>{const l=n.call(e,r,a);return/src/i.test(r)&&i.triggerSourceset(e.src),l},e.load=()=>{const r=s.call(e);return so(i)||(i.triggerSourceset(""),sd(i)),r},e.currentSrc?i.triggerSourceset(e.currentSrc):so(i)||sd(i),e.resetSourceset_=()=>{e.resetSourceset_=null,e.load=s,e.setAttribute=n,Object.defineProperty(e,"src",t),e.resetSourceWatch_&&e.resetSourceWatch_()}};class J extends ae{constructor(e,t){super(e,t);const n=e.source;let s=!1;if(this.featuresVideoFrameCallback=this.featuresVideoFrameCallback&&this.el_.tagName==="VIDEO",n&&(this.el_.currentSrc!==n.src||e.tag&&e.tag.initNetworkState_===3)?this.setSource(n):this.handleLateInit_(this.el_),e.enableSourceset&&this.setupSourcesetHandling_(),this.isScrubbing_=!1,this.el_.hasChildNodes()){const r=this.el_.childNodes;let a=r.length;const l=[];for(;a--;){const c=r[a];c.nodeName.toLowerCase()==="track"&&(this.featuresNativeTextTracks?(this.remoteTextTrackEls().addTrackElement_(c),this.remoteTextTracks().addTrack(c.track),this.textTracks().addTrack(c.track),!s&&!this.el_.hasAttribute("crossorigin")&&Qr(c.src)&&(s=!0)):l.push(c))}for(let c=0;c<l.length;c++)this.el_.removeChild(l[c])}this.proxyNativeTracks_(),this.featuresNativeTextTracks&&s&&oe.warn(`Text Tracks are being loaded from another origin but the crossorigin attribute isn't used.
|
|
167
|
-
This may prevent text tracks from loading.`),this.restoreMetadataTracksInIOSNativePlayer_(),(ps||qr)&&e.nativeControlsForTouch===!0&&this.setControls(!0),this.proxyWebkitFullscreen_(),this.triggerReady()}dispose(){this.el_&&this.el_.resetSourceset_&&this.el_.resetSourceset_(),J.disposeMediaElement(this.el_),this.options_=null,super.dispose()}setupSourcesetHandling_(){Fb(this)}restoreMetadataTracksInIOSNativePlayer_(){const e=this.textTracks();let t;const n=()=>{t=[];for(let r=0;r<e.length;r++){const a=e[r];a.kind==="metadata"&&t.push({track:a,storedMode:a.mode})}};n(),e.addEventListener("change",n),this.on("dispose",()=>e.removeEventListener("change",n));const s=()=>{for(let r=0;r<t.length;r++){const a=t[r];a.track.mode==="disabled"&&a.track.mode!==a.storedMode&&(a.track.mode=a.storedMode)}e.removeEventListener("change",s)};this.on("webkitbeginfullscreen",()=>{e.removeEventListener("change",n),e.removeEventListener("change",s),e.addEventListener("change",s)}),this.on("webkitendfullscreen",()=>{e.removeEventListener("change",n),e.addEventListener("change",n),e.removeEventListener("change",s)})}overrideNative_(e,t){if(t!==this[`featuresNative${e}Tracks`])return;const n=e.toLowerCase();this[`${n}TracksListeners_`]&&Object.keys(this[`${n}TracksListeners_`]).forEach(s=>{this.el()[`${n}Tracks`].removeEventListener(s,this[`${n}TracksListeners_`][s])}),this[`featuresNative${e}Tracks`]=!t,this[`${n}TracksListeners_`]=null,this.proxyNativeTracksForType_(n)}overrideNativeAudioTracks(e){this.overrideNative_("Audio",e)}overrideNativeVideoTracks(e){this.overrideNative_("Video",e)}proxyNativeTracksForType_(e){const t=xt[e],n=this.el()[t.getterName],s=this[t.getterName]();if(!this[`featuresNative${t.capitalName}Tracks`]||!n||!n.addEventListener)return;const r={change:l=>{const c={type:"change",target:s,currentTarget:s,srcElement:s};s.trigger(c),e==="text"&&this[vn.remoteText.getterName]().trigger(c)},addtrack(l){s.addTrack(l.track)},removetrack(l){s.removeTrack(l.track)}},a=function(){const l=[];for(let c=0;c<s.length;c++){let f=!1;for(let m=0;m<n.length;m++)if(n[m]===s[c]){f=!0;break}f||l.push(s[c])}for(;l.length;)s.removeTrack(l.shift())};this[t.getterName+"Listeners_"]=r,Object.keys(r).forEach(l=>{const c=r[l];n.addEventListener(l,c),this.on("dispose",f=>n.removeEventListener(l,c))}),this.on("loadstart",a),this.on("dispose",l=>this.off("loadstart",a))}proxyNativeTracks_(){xt.names.forEach(e=>{this.proxyNativeTracksForType_(e)})}createEl(){let e=this.options_.tag;if(!e||!(this.options_.playerElIngest||this.movingMediaElementInDOM)){if(e){const n=e.cloneNode(!0);e.parentNode&&e.parentNode.insertBefore(n,e),J.disposeMediaElement(e),e=n}else{e=G.createElement("video");const n=this.options_.tag&&_i(this.options_.tag),s=ve({},n);(!ps||this.options_.nativeControlsForTouch!==!0)&&delete s.controls,Rh(e,Object.assign(s,{id:this.options_.techId,class:"vjs-tech"}))}e.playerId=this.options_.playerId}typeof this.options_.preload<"u"&&yn(e,"preload",this.options_.preload),this.options_.disablePictureInPicture!==void 0&&(e.disablePictureInPicture=this.options_.disablePictureInPicture);const t=["loop","muted","playsinline","autoplay"];for(let n=0;n<t.length;n++){const s=t[n],r=this.options_[s];typeof r<"u"&&(r?yn(e,s,s):zr(e,s),e[s]=r)}return e}handleLateInit_(e){if(e.networkState===0||e.networkState===3)return;if(e.readyState===0){let n=!1;const s=function(){n=!0};this.on("loadstart",s);const r=function(){n||this.trigger("loadstart")};this.on("loadedmetadata",r),this.ready(function(){this.off("loadstart",s),this.off("loadedmetadata",r),n||this.trigger("loadstart")});return}const t=["loadstart"];t.push("loadedmetadata"),e.readyState>=2&&t.push("loadeddata"),e.readyState>=3&&t.push("canplay"),e.readyState>=4&&t.push("canplaythrough"),this.ready(function(){t.forEach(function(n){this.trigger(n)},this)})}setScrubbing(e){this.isScrubbing_=e}scrubbing(){return this.isScrubbing_}setCurrentTime(e){try{this.isScrubbing_&&this.el_.fastSeek&&Vr?this.el_.fastSeek(e):this.el_.currentTime=e}catch(t){oe(t,"Video is not ready. (Video.js)")}}duration(){if(this.el_.duration===1/0&&Nt&&Jt&&this.el_.currentTime===0){const e=()=>{this.el_.currentTime>0&&(this.el_.duration===1/0&&this.trigger("durationchange"),this.off("timeupdate",e))};return this.on("timeupdate",e),NaN}return this.el_.duration||NaN}width(){return this.el_.offsetWidth}height(){return this.el_.offsetHeight}proxyWebkitFullscreen_(){if(!("webkitDisplayingFullscreen"in this.el_))return;const e=function(){this.trigger("fullscreenchange",{isFullscreen:!1}),this.el_.controls&&!this.options_.nativeControlsForTouch&&this.controls()&&(this.el_.controls=!1)},t=function(){"webkitPresentationMode"in this.el_&&this.el_.webkitPresentationMode!=="picture-in-picture"&&(this.one("webkitendfullscreen",e),this.trigger("fullscreenchange",{isFullscreen:!0,nativeIOSFullscreen:!0}))};this.on("webkitbeginfullscreen",t),this.on("dispose",()=>{this.off("webkitbeginfullscreen",t),this.off("webkitendfullscreen",e)})}supportsFullScreen(){return typeof this.el_.webkitEnterFullScreen=="function"}enterFullScreen(){const e=this.el_;if(e.paused&&e.networkState<=e.HAVE_METADATA)Gt(this.el_.play()),this.setTimeout(function(){e.pause();try{e.webkitEnterFullScreen()}catch(t){this.trigger("fullscreenerror",t)}},0);else try{e.webkitEnterFullScreen()}catch(t){this.trigger("fullscreenerror",t)}}exitFullScreen(){if(!this.el_.webkitDisplayingFullscreen){this.trigger("fullscreenerror",new Error("The video is not fullscreen"));return}this.el_.webkitExitFullScreen()}requestPictureInPicture(){return this.el_.requestPictureInPicture()}requestVideoFrameCallback(e){return this.featuresVideoFrameCallback&&!this.el_.webkitKeys?this.el_.requestVideoFrameCallback(e):super.requestVideoFrameCallback(e)}cancelVideoFrameCallback(e){this.featuresVideoFrameCallback&&!this.el_.webkitKeys?this.el_.cancelVideoFrameCallback(e):super.cancelVideoFrameCallback(e)}src(e){if(e===void 0)return this.el_.src;this.setSrc(e)}addSourceElement(e,t){if(!e)return oe.error("Invalid source URL."),!1;const n={src:e};t&&(n.type=t);const s=ne("source",{},n);return this.el_.appendChild(s),!0}removeSourceElement(e){if(!e)return oe.error("Source URL is required to remove the source element."),!1;const t=this.el_.querySelectorAll("source");for(const n of t)if(n.src===e)return this.el_.removeChild(n),!0;return oe.warn(`No matching source element found with src: ${e}`),!1}reset(){J.resetMediaElement(this.el_)}currentSrc(){return this.currentSource_?this.currentSource_.src:this.el_.currentSrc}setControls(e){this.el_.controls=!!e}addTextTrack(e,t,n){return this.featuresNativeTextTracks?this.el_.addTextTrack(e,t,n):super.addTextTrack(e,t,n)}createRemoteTextTrack(e){if(!this.featuresNativeTextTracks)return super.createRemoteTextTrack(e);const t=G.createElement("track");return e.kind&&(t.kind=e.kind),e.label&&(t.label=e.label),(e.language||e.srclang)&&(t.srclang=e.language||e.srclang),e.default&&(t.default=e.default),e.id&&(t.id=e.id),e.src&&(t.src=e.src),t}addRemoteTextTrack(e,t){const n=super.addRemoteTextTrack(e,t);return this.featuresNativeTextTracks&&this.el().appendChild(n),n}removeRemoteTextTrack(e){if(super.removeRemoteTextTrack(e),this.featuresNativeTextTracks){const t=this.$$("track");let n=t.length;for(;n--;)(e===t[n]||e===t[n].track)&&this.el().removeChild(t[n])}}getVideoPlaybackQuality(){if(typeof this.el().getVideoPlaybackQuality=="function")return this.el().getVideoPlaybackQuality();const e={};return typeof this.el().webkitDroppedFrameCount<"u"&&typeof this.el().webkitDecodedFrameCount<"u"&&(e.droppedVideoFrames=this.el().webkitDroppedFrameCount,e.totalVideoFrames=this.el().webkitDecodedFrameCount),x.performance&&(e.creationTime=x.performance.now()),e}}Fr(J,"TEST_VID",function(){if(!En())return;const i=G.createElement("video"),e=G.createElement("track");return e.kind="captions",e.srclang="en",e.label="English",i.appendChild(e),i});J.isSupported=function(){try{J.TEST_VID.volume=.5}catch{return!1}return!!(J.TEST_VID&&J.TEST_VID.canPlayType)};J.canPlayType=function(i){return J.TEST_VID.canPlayType(i)};J.canPlaySource=function(i,e){return J.canPlayType(i.type)};J.canControlVolume=function(){try{const i=J.TEST_VID.volume;J.TEST_VID.volume=i/2+.1;const e=i!==J.TEST_VID.volume;return e&&Je?(x.setTimeout(()=>{J&&J.prototype&&(J.prototype.featuresVolumeControl=i!==J.TEST_VID.volume)}),!1):e}catch{return!1}};J.canMuteVolume=function(){try{const i=J.TEST_VID.muted;return J.TEST_VID.muted=!i,J.TEST_VID.muted?yn(J.TEST_VID,"muted","muted"):zr(J.TEST_VID,"muted","muted"),i!==J.TEST_VID.muted}catch{return!1}};J.canControlPlaybackRate=function(){if(Nt&&Jt&&jr<58)return!1;try{const i=J.TEST_VID.playbackRate;return J.TEST_VID.playbackRate=i/2+.1,i!==J.TEST_VID.playbackRate}catch{return!1}};J.canOverrideAttributes=function(){try{const i=()=>{};Object.defineProperty(G.createElement("video"),"src",{get:i,set:i}),Object.defineProperty(G.createElement("audio"),"src",{get:i,set:i}),Object.defineProperty(G.createElement("video"),"innerHTML",{get:i,set:i}),Object.defineProperty(G.createElement("audio"),"innerHTML",{get:i,set:i})}catch{return!1}return!0};J.supportsNativeTextTracks=function(){return Vr||Je&&Jt};J.supportsNativeVideoTracks=function(){return!!(J.TEST_VID&&J.TEST_VID.videoTracks)};J.supportsNativeAudioTracks=function(){return!!(J.TEST_VID&&J.TEST_VID.audioTracks)};J.Events=["loadstart","suspend","abort","error","emptied","stalled","loadedmetadata","loadeddata","canplay","canplaythrough","playing","waiting","seeking","seeked","ended","durationchange","timeupdate","progress","play","pause","ratechange","resize","volumechange"];[["featuresMuteControl","canMuteVolume"],["featuresPlaybackRate","canControlPlaybackRate"],["featuresSourceset","canOverrideAttributes"],["featuresNativeTextTracks","supportsNativeTextTracks"],["featuresNativeVideoTracks","supportsNativeVideoTracks"],["featuresNativeAudioTracks","supportsNativeAudioTracks"]].forEach(function([i,e]){Fr(J.prototype,i,()=>J[e](),!0)});J.prototype.featuresVolumeControl=J.canControlVolume();J.prototype.movingMediaElementInDOM=!Je;J.prototype.featuresFullscreenResize=!0;J.prototype.featuresProgressEvents=!0;J.prototype.featuresTimeupdateEvents=!0;J.prototype.featuresVideoFrameCallback=!!(J.TEST_VID&&J.TEST_VID.requestVideoFrameCallback);J.disposeMediaElement=function(i){if(i){for(i.parentNode&&i.parentNode.removeChild(i);i.hasChildNodes();)i.removeChild(i.firstChild);i.removeAttribute("src"),typeof i.load=="function"&&function(){try{i.load()}catch{}}()}};J.resetMediaElement=function(i){if(!i)return;const e=i.querySelectorAll("source");let t=e.length;for(;t--;)i.removeChild(e[t]);i.removeAttribute("src"),typeof i.load=="function"&&function(){try{i.load()}catch{}}()};["muted","defaultMuted","autoplay","controls","loop","playsinline"].forEach(function(i){J.prototype[i]=function(){return this.el_[i]||this.el_.hasAttribute(i)}});["muted","defaultMuted","autoplay","loop","playsinline"].forEach(function(i){J.prototype["set"+Ne(i)]=function(e){this.el_[i]=e,e?this.el_.setAttribute(i,i):this.el_.removeAttribute(i)}});["paused","currentTime","buffered","volume","poster","preload","error","seeking","seekable","ended","playbackRate","defaultPlaybackRate","disablePictureInPicture","played","networkState","readyState","videoWidth","videoHeight","crossOrigin"].forEach(function(i){J.prototype[i]=function(){return this.el_[i]}});["volume","src","poster","preload","playbackRate","defaultPlaybackRate","disablePictureInPicture","crossOrigin"].forEach(function(i){J.prototype["set"+Ne(i)]=function(e){this.el_[i]=e}});["pause","load","play"].forEach(function(i){J.prototype[i]=function(){return this.el_[i]()}});ae.withSourceHandlers(J);J.nativeSourceHandler={};J.nativeSourceHandler.canPlayType=function(i){try{return J.TEST_VID.canPlayType(i)}catch{return""}};J.nativeSourceHandler.canHandleSource=function(i,e){if(i.type)return J.nativeSourceHandler.canPlayType(i.type);if(i.src){const t=Wo(i.src);return J.nativeSourceHandler.canPlayType(`video/${t}`)}return""};J.nativeSourceHandler.handleSource=function(i,e,t){e.setSrc(i.src)};J.nativeSourceHandler.dispose=function(){};J.registerSourceHandler(J.nativeSourceHandler);ae.registerTech("Html5",J);const Nc=["progress","abort","suspend","emptied","stalled","loadedmetadata","loadeddata","timeupdate","resize","volumechange","texttrackchange"],$a={canplay:"CanPlay",canplaythrough:"CanPlayThrough",playing:"Playing",seeked:"Seeked"},ro=["tiny","xsmall","small","medium","large","xlarge","huge"],sr={};ro.forEach(i=>{const e=i.charAt(0)==="x"?`x-${i.substring(1)}`:i;sr[i]=`vjs-layout-${e}`});const jb={tiny:210,xsmall:320,small:425,medium:768,large:1440,xlarge:2560,huge:1/0};class Ae extends H{constructor(e,t,n){if(e.id=e.id||t.id||`vjs_video_${At()}`,t=Object.assign(Ae.getTagSettings(e),t),t.initChildren=!1,t.createEl=!1,t.evented=!1,t.reportTouchActivity=!1,!t.language){const a=e.closest("[lang]");a&&(t.language=a.getAttribute("lang"))}if(super(null,t,n),this.boundDocumentFullscreenChange_=a=>this.documentFullscreenChange_(a),this.boundFullWindowOnEscKey_=a=>this.fullWindowOnEscKey(a),this.boundUpdateStyleEl_=a=>this.updateStyleEl_(a),this.boundApplyInitTime_=a=>this.applyInitTime_(a),this.boundUpdateCurrentBreakpoint_=a=>this.updateCurrentBreakpoint_(a),this.boundHandleTechClick_=a=>this.handleTechClick_(a),this.boundHandleTechDoubleClick_=a=>this.handleTechDoubleClick_(a),this.boundHandleTechTouchStart_=a=>this.handleTechTouchStart_(a),this.boundHandleTechTouchMove_=a=>this.handleTechTouchMove_(a),this.boundHandleTechTouchEnd_=a=>this.handleTechTouchEnd_(a),this.boundHandleTechTap_=a=>this.handleTechTap_(a),this.boundUpdatePlayerHeightOnAudioOnlyMode_=a=>this.updatePlayerHeightOnAudioOnlyMode_(a),this.isFullscreen_=!1,this.log=Eh(this.id_),this.fsApi_=dr,this.isPosterFromTech_=!1,this.queuedCallbacks_=[],this.isReady_=!1,this.hasStarted_=!1,this.userActive_=!1,this.debugEnabled_=!1,this.audioOnlyMode_=!1,this.audioPosterMode_=!1,this.audioOnlyCache_={controlBarHeight:null,playerHeight:null,hiddenChildren:[]},!this.options_||!this.options_.techOrder||!this.options_.techOrder.length)throw new Error("No techOrder specified. Did you overwrite videojs.options instead of just changing the properties you want to override?");if(this.tag=e,this.tagAttributes=e&&_i(e),this.language(this.options_.language),t.languages){const a={};Object.getOwnPropertyNames(t.languages).forEach(function(l){a[l.toLowerCase()]=t.languages[l]}),this.languages_=a}else this.languages_=Ae.prototype.options_.languages;this.resetCache_(),this.poster_=t.poster||"",this.controls_=!!t.controls,e.controls=!1,e.removeAttribute("controls"),this.changingSrc_=!1,this.playCallbacks_=[],this.playTerminatedQueue_=[],e.hasAttribute("autoplay")?this.autoplay(!0):this.autoplay(this.options_.autoplay),t.plugins&&Object.keys(t.plugins).forEach(a=>{if(typeof this[a]!="function")throw new Error(`plugin "${a}" does not exist`)}),this.scrubbing_=!1,this.el_=this.createEl(),qo(this,{eventBusKey:"el_"}),this.fsApi_.requestFullscreen&&(vt(G,this.fsApi_.fullscreenchange,this.boundDocumentFullscreenChange_),this.on(this.fsApi_.fullscreenchange,this.boundDocumentFullscreenChange_)),this.fluid_&&this.on(["playerreset","resize"],this.boundUpdateStyleEl_);const s=ve(this.options_);if(t.plugins&&Object.keys(t.plugins).forEach(a=>{this[a](t.plugins[a])}),t.debug&&this.debug(!0),this.options_.playerOptions=s,this.middleware_=[],this.playbackRates(t.playbackRates),t.experimentalSvgIcons){const a=new x.DOMParser().parseFromString(ub,"image/svg+xml");if(a.querySelector("parsererror"))oe.warn("Failed to load SVG Icons. Falling back to Font Icons."),this.options_.experimentalSvgIcons=null;else{const l=a.documentElement;l.style.display="none",this.el_.appendChild(l),this.addClass("vjs-svg-icons-enabled")}}this.initChildren(),this.isAudio(e.nodeName.toLowerCase()==="audio"),this.controls()?this.addClass("vjs-controls-enabled"):this.addClass("vjs-controls-disabled"),this.el_.setAttribute("role","region"),this.isAudio()?this.el_.setAttribute("aria-label",this.localize("Audio Player")):this.el_.setAttribute("aria-label",this.localize("Video Player")),this.isAudio()&&this.addClass("vjs-audio"),t.spatialNavigation&&t.spatialNavigation.enabled&&(this.spatialNavigation=new db(this),this.addClass("vjs-spatial-navigation-enabled")),ps&&this.addClass("vjs-touch-enabled"),Je||this.addClass("vjs-workinghover"),Ae.players[this.id_]=this;const r=Ka.split(".")[0];this.addClass(`vjs-v${r}`),this.userActive(!0),this.reportUserActivity(),this.one("play",a=>this.listenForUserActivity_(a)),this.on("keydown",a=>this.handleKeyDown(a)),this.on("languagechange",a=>this.handleLanguagechange(a)),this.breakpoints(this.options_.breakpoints),this.responsive(this.options_.responsive),this.on("ready",()=>{this.audioPosterMode(this.options_.audioPosterMode),this.audioOnlyMode(this.options_.audioOnlyMode)})}dispose(){this.trigger("dispose"),this.off("dispose"),Ze(G,this.fsApi_.fullscreenchange,this.boundDocumentFullscreenChange_),Ze(G,"keydown",this.boundFullWindowOnEscKey_),this.styleEl_&&this.styleEl_.parentNode&&(this.styleEl_.parentNode.removeChild(this.styleEl_),this.styleEl_=null),Ae.players[this.id_]=null,this.tag&&this.tag.player&&(this.tag.player=null),this.el_&&this.el_.player&&(this.el_.player=null),this.tech_&&(this.tech_.dispose(),this.isPosterFromTech_=!1,this.poster_=""),this.playerElIngest_&&(this.playerElIngest_=null),this.tag&&(this.tag=null),rb(this),at.names.forEach(e=>{const t=at[e],n=this[t.getterName]();n&&n.off&&n.off()}),super.dispose({restoreEl:this.options_.restoreEl})}createEl(){let e=this.tag,t,n=this.playerElIngest_=e.parentNode&&e.parentNode.hasAttribute&&e.parentNode.hasAttribute("data-vjs-player");const s=this.tag.tagName.toLowerCase()==="video-js";n?t=this.el_=e.parentNode:s||(t=this.el_=super.createEl("div"));const r=_i(e);if(s){for(t=this.el_=e,e=this.tag=G.createElement("video");t.children.length;)e.appendChild(t.firstChild);os(t,"video-js")||Bi(t,"video-js"),t.appendChild(e),n=this.playerElIngest_=t,Object.keys(t).forEach(c=>{try{e[c]=t[c]}catch{}})}e.setAttribute("tabindex","-1"),r.tabindex="-1",Jt&&$r&&(e.setAttribute("role","application"),r.role="application"),e.removeAttribute("width"),e.removeAttribute("height"),"width"in r&&delete r.width,"height"in r&&delete r.height,Object.getOwnPropertyNames(r).forEach(function(c){s&&c==="class"||t.setAttribute(c,r[c]),s&&e.setAttribute(c,r[c])}),e.playerId=e.id,e.id+="_html5_api",e.className="vjs-tech",e.player=t.player=this,this.addClass("vjs-paused");const a=["IS_SMART_TV","IS_TIZEN","IS_WEBOS","IS_ANDROID","IS_IPAD","IS_IPHONE","IS_CHROMECAST_RECEIVER"].filter(c=>Lh[c]).map(c=>"vjs-device-"+c.substring(3).toLowerCase().replace(/\_/g,"-"));if(this.addClass(...a),x.VIDEOJS_NO_DYNAMIC_STYLE!==!0){this.styleEl_=Wh("vjs-styles-dimensions");const c=vi(".vjs-styles-defaults"),f=vi("head");f.insertBefore(this.styleEl_,c?c.nextSibling:f.firstChild)}this.fill_=!1,this.fluid_=!1,this.width(this.options_.width),this.height(this.options_.height),this.fill(this.options_.fill),this.fluid(this.options_.fluid),this.aspectRatio(this.options_.aspectRatio),this.crossOrigin(this.options_.crossOrigin||this.options_.crossorigin);const l=e.getElementsByTagName("a");for(let c=0;c<l.length;c++){const f=l.item(c);Bi(f,"vjs-hidden"),f.setAttribute("hidden","hidden")}return e.initNetworkState_=e.networkState,e.parentNode&&!n&&e.parentNode.insertBefore(t,e),Qa(e,t),this.children_.unshift(e),this.el_.setAttribute("lang",this.language_),this.el_.setAttribute("translate","no"),this.el_=t,t}crossOrigin(e){if(typeof e>"u")return this.techGet_("crossOrigin");if(e!==null&&e!=="anonymous"&&e!=="use-credentials"){oe.warn(`crossOrigin must be null, "anonymous" or "use-credentials", given "${e}"`);return}this.techCall_("setCrossOrigin",e),this.posterImage&&this.posterImage.crossOrigin(e)}width(e){return this.dimension("width",e)}height(e){return this.dimension("height",e)}dimension(e,t){const n=e+"_";if(t===void 0)return this[n]||0;if(t===""||t==="auto"){this[n]=void 0,this.updateStyleEl_();return}const s=parseFloat(t);if(isNaN(s)){oe.error(`Improper value "${t}" supplied for for ${e}`);return}this[n]=s,this.updateStyleEl_()}fluid(e){if(e===void 0)return!!this.fluid_;this.fluid_=!!e,si(this)&&this.off(["playerreset","resize"],this.boundUpdateStyleEl_),e?(this.addClass("vjs-fluid"),this.fill(!1),R1(this,()=>{this.on(["playerreset","resize"],this.boundUpdateStyleEl_)})):this.removeClass("vjs-fluid"),this.updateStyleEl_()}fill(e){if(e===void 0)return!!this.fill_;this.fill_=!!e,e?(this.addClass("vjs-fill"),this.fluid(!1)):this.removeClass("vjs-fill")}aspectRatio(e){if(e===void 0)return this.aspectRatio_;if(!/^\d+\:\d+$/.test(e))throw new Error("Improper value supplied for aspect ratio. The format should be width:height, for example 16:9.");this.aspectRatio_=e,this.fluid(!0),this.updateStyleEl_()}updateStyleEl_(){if(x.VIDEOJS_NO_DYNAMIC_STYLE===!0){const l=typeof this.width_=="number"?this.width_:this.options_.width,c=typeof this.height_=="number"?this.height_:this.options_.height,f=this.tech_&&this.tech_.el();f&&(l>=0&&(f.width=l),c>=0&&(f.height=c));return}let e,t,n,s;this.aspectRatio_!==void 0&&this.aspectRatio_!=="auto"?n=this.aspectRatio_:this.videoWidth()>0?n=this.videoWidth()+":"+this.videoHeight():n="16:9";const r=n.split(":"),a=r[1]/r[0];this.width_!==void 0?e=this.width_:this.height_!==void 0?e=this.height_/a:e=this.videoWidth()||300,this.height_!==void 0?t=this.height_:t=e*a,/^[^a-zA-Z]/.test(this.id())?s="dimensions-"+this.id():s=this.id()+"-dimensions",this.addClass(s),Gh(this.styleEl_,`
|
|
168
|
-
.${
|
|
166
|
+
</svg>`;const qu=mr?10009:gr?461:8,Zi={codes:{play:415,pause:19,ff:417,rw:412,back:qu},names:{415:"play",19:"pause",417:"ff",412:"rw",[qu]:"back"},isEventKey(s,e){return e=e.toLowerCase(),!!(this.names[s.keyCode]&&this.names[s.keyCode]===e)},getEventName(s){if(this.names[s.keyCode])return this.names[s.keyCode];if(this.codes[s.code]){const e=this.codes[s.code];return this.names[e]}return null}},zu=5;class rv extends bt{constructor(e){super(),this.player_=e,this.focusableComponents=[],this.isListening_=!1,this.isPaused_=!1,this.onKeyDown_=this.onKeyDown_.bind(this),this.lastFocusedComponent_=null}start(){this.isListening_||(this.player_.on("keydown",this.onKeyDown_),this.player_.on("modalKeydown",this.onKeyDown_),this.player_.on("loadedmetadata",()=>{this.focus(this.updateFocusableComponents()[0])}),this.player_.on("modalclose",()=>{this.refocusComponent()}),this.player_.on("focusin",this.handlePlayerFocus_.bind(this)),this.player_.on("focusout",this.handlePlayerBlur_.bind(this)),this.isListening_=!0,this.player_.errorDisplay&&this.player_.errorDisplay.on("aftermodalfill",()=>{this.updateFocusableComponents(),this.focusableComponents.length&&(this.focusableComponents.length>1?this.focusableComponents[1].focus():this.focusableComponents[0].focus())}))}stop(){this.player_.off("keydown",this.onKeyDown_),this.isListening_=!1}onKeyDown_(e){const t=e.originalEvent?e.originalEvent:e;if(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(t.key)){if(this.isPaused_)return;t.preventDefault();const i=t.key.substring(5).toLowerCase();this.move(i)}else if(Zi.isEventKey(t,"play")||Zi.isEventKey(t,"pause")||Zi.isEventKey(t,"ff")||Zi.isEventKey(t,"rw")){t.preventDefault();const i=Zi.getEventName(t);this.performMediaAction_(i)}else Zi.isEventKey(t,"Back")&&e.target&&typeof e.target.closeable=="function"&&e.target.closeable()&&(t.preventDefault(),e.target.close())}performMediaAction_(e){if(this.player_)switch(e){case"play":this.player_.paused()&&this.player_.play();break;case"pause":this.player_.paused()||this.player_.pause();break;case"ff":this.userSeek_(this.player_.currentTime()+zu);break;case"rw":this.userSeek_(this.player_.currentTime()-zu);break}}userSeek_(e){this.player_.liveTracker&&this.player_.liveTracker.isLive()&&this.player_.liveTracker.nextSeekedFromUser(),this.player_.currentTime(e)}pause(){this.isPaused_=!0}resume(){this.isPaused_=!1}handlePlayerBlur_(e){const t=e.relatedTarget;let i=null;const n=this.getCurrentComponent(e.target);t&&(i=!!t.closest(".video-js"),t.classList.contains("vjs-text-track-settings")&&!this.isPaused_&&this.searchForTrackSelect_()),(!e.currentTarget.contains(e.relatedTarget)&&!i||!t)&&(n&&n.name()==="CloseButton"?this.refocusComponent():(this.pause(),n&&n.el()&&(this.lastFocusedComponent_=n)))}handlePlayerFocus_(){this.getCurrentComponent()&&this.getCurrentComponent().getIsFocusable()&&this.resume()}updateFocusableComponents(){const e=this.player_,t=[];function i(n){for(const r of n)r.hasOwnProperty("el_")&&r.getIsFocusable()&&r.getIsAvailableToBeFocused(r.el())&&t.push(r),r.hasOwnProperty("children_")&&r.children_.length>0&&i(r.children_)}return e.children_.forEach(n=>{if(n.hasOwnProperty("el_"))if(n.getIsFocusable&&n.getIsAvailableToBeFocused&&n.getIsFocusable()&&n.getIsAvailableToBeFocused(n.el())){t.push(n);return}else n.hasOwnProperty("children_")&&n.children_.length>0?i(n.children_):n.hasOwnProperty("items")&&n.items.length>0?i(n.items):this.findSuitableDOMChild(n)&&t.push(n);if(n.name_==="ErrorDisplay"&&n.opened_){const r=n.el_.querySelector(".vjs-errors-ok-button-container");r&&r.querySelectorAll("button").forEach((l,h)=>{t.push({name:()=>"ModalButton"+(h+1),el:()=>l,getPositions:()=>{const f=l.getBoundingClientRect(),m={x:f.x,y:f.y,width:f.width,height:f.height,top:f.top,right:f.right,bottom:f.bottom,left:f.left},T={x:f.left+f.width/2,y:f.top+f.height/2,width:0,height:0,top:f.top+f.height/2,right:f.left+f.width/2,bottom:f.top+f.height/2,left:f.left+f.width/2};return{boundingClientRect:m,center:T}},getIsAvailableToBeFocused:()=>!0,getIsFocusable:f=>!0,focus:()=>l.focus()})})}}),this.focusableComponents=t,this.focusableComponents}findSuitableDOMChild(e){function t(i){if(e.getIsFocusable(i)&&e.getIsAvailableToBeFocused(i))return i;for(let n=0;n<i.children.length;n++){const r=i.children[n],a=t(r);if(a)return a}return null}return e.el()?t(e.el()):null}getCurrentComponent(e){this.updateFocusableComponents();const t=e||document.activeElement;if(this.focusableComponents.length){for(const i of this.focusableComponents)if(i.el()===t)return i}}add(e){const t=[...this.focusableComponents];e.hasOwnProperty("el_")&&e.getIsFocusable()&&e.getIsAvailableToBeFocused(e.el())&&t.push(e),this.focusableComponents=t,this.trigger({type:"focusableComponentsChanged",focusableComponents:this.focusableComponents})}remove(e){for(let t=0;t<this.focusableComponents.length;t++)if(this.focusableComponents[t].name()===e.name()){this.focusableComponents.splice(t,1),this.trigger({type:"focusableComponentsChanged",focusableComponents:this.focusableComponents});return}}clear(){this.focusableComponents.length>0&&(this.focusableComponents=[],this.trigger({type:"focusableComponentsChanged",focusableComponents:this.focusableComponents}))}move(e){const t=this.getCurrentComponent();if(!t)return;const i=t.getPositions(),n=this.focusableComponents.filter(a=>a!==t&&this.isInDirection_(i.boundingClientRect,a.getPositions().boundingClientRect,e)),r=this.findBestCandidate_(i.center,n,e);r?this.focus(r):this.trigger({type:"endOfFocusableComponents",direction:e,focusedComponent:t})}findBestCandidate_(e,t,i){let n=1/0,r=null;for(const a of t){const l=a.getPositions().center,h=this.calculateDistance_(e,l,i);h<n&&(n=h,r=a)}return r}isInDirection_(e,t,i){switch(i){case"right":return t.left>=e.right;case"left":return t.right<=e.left;case"down":return t.top>=e.bottom;case"up":return t.bottom<=e.top;default:return!1}}refocusComponent(){if(this.lastFocusedComponent_){this.player_.userActive()||this.player_.userActive(!0),this.updateFocusableComponents();for(let e=0;e<this.focusableComponents.length;e++)if(this.focusableComponents[e].name()===this.lastFocusedComponent_.name()){this.focus(this.focusableComponents[e]);return}}else this.focus(this.updateFocusableComponents()[0])}focus(e){typeof e=="object"&&(e.getIsAvailableToBeFocused(e.el())?e.focus():this.findSuitableDOMChild(e)&&this.findSuitableDOMChild(e).focus())}calculateDistance_(e,t,i){const n=Math.abs(e.x-t.x),r=Math.abs(e.y-t.y);let a;switch(i){case"right":case"left":a=n+r*100;break;case"up":a=r*2+n*.5;break;case"down":a=r*5+n;break;default:a=n+r}return a}searchForTrackSelect_(){const e=this;for(const t of e.updateFocusableComponents())if(t.constructor.name==="TextTrackSelect"){e.focus(t);break}}}class av extends H{constructor(e,t,i){const n=xe({createEl:!1},t);if(super(e,n,i),!t.playerOptions.sources||t.playerOptions.sources.length===0)for(let r=0,a=t.playerOptions.techOrder;r<a.length;r++){const l=Be(a[r]);let h=oe.getTech(l);if(l||(h=H.getComponent(l)),h&&h.isSupported()){e.loadTech_(l);break}}else e.src(t.playerOptions.sources)}}H.registerComponent("MediaLoader",av);class ta extends H{constructor(e,t){super(e,t),this.options_.controlText&&this.controlText(this.options_.controlText),this.handleMouseOver_=i=>this.handleMouseOver(i),this.handleMouseOut_=i=>this.handleMouseOut(i),this.handleClick_=i=>this.handleClick(i),this.handleKeyDown_=i=>this.handleKeyDown(i),this.emitTapEvents(),this.enable()}createEl(e="div",t={},i={}){t=Object.assign({className:this.buildCSSClass(),tabIndex:0},t),e==="button"&&ue.error(`Creating a ClickableComponent with an HTML element of ${e} is not supported; use a Button instead.`),i=Object.assign({role:"button"},i),this.tabIndex_=t.tabIndex;const n=se(e,t,i);return this.player_.options_.experimentalSvgIcons||n.appendChild(se("span",{className:"vjs-icon-placeholder"},{"aria-hidden":!0})),this.createControlTextEl(n),n}dispose(){this.controlTextEl_=null,super.dispose()}createControlTextEl(e){return this.controlTextEl_=se("span",{className:"vjs-control-text"},{"aria-live":"polite"}),e&&e.appendChild(this.controlTextEl_),this.controlText(this.controlText_,e),this.controlTextEl_}controlText(e,t=this.el()){if(e===void 0)return this.controlText_||"Need Text";const i=this.localize(e);this.controlText_=e,Ci(this.controlTextEl_,i),!this.nonIconControl&&!this.player_.options_.noUITitleAttributes&&t.setAttribute("title",i)}buildCSSClass(){return`vjs-control vjs-button ${super.buildCSSClass()}`}enable(){this.enabled_||(this.enabled_=!0,this.removeClass("vjs-disabled"),this.el_.setAttribute("aria-disabled","false"),typeof this.tabIndex_<"u"&&this.el_.setAttribute("tabIndex",this.tabIndex_),this.on(["tap","click"],this.handleClick_),this.on("keydown",this.handleKeyDown_))}disable(){this.enabled_=!1,this.addClass("vjs-disabled"),this.el_.setAttribute("aria-disabled","true"),typeof this.tabIndex_<"u"&&this.el_.removeAttribute("tabIndex"),this.off("mouseover",this.handleMouseOver_),this.off("mouseout",this.handleMouseOut_),this.off(["tap","click"],this.handleClick_),this.off("keydown",this.handleKeyDown_)}handleLanguagechange(){this.controlText(this.controlText_)}handleClick(e){this.options_.clickHandler&&this.options_.clickHandler.call(this,arguments)}handleKeyDown(e){e.key===" "||e.key==="Enter"?(e.preventDefault(),e.stopPropagation(),this.trigger("click")):super.handleKeyDown(e)}}H.registerComponent("ClickableComponent",ta);class ao extends ta{constructor(e,t){super(e,t),this.update(),this.update_=i=>this.update(i),e.on("posterchange",this.update_)}dispose(){this.player().off("posterchange",this.update_),super.dispose()}createEl(){return se("div",{className:"vjs-poster"})}crossOrigin(e){if(typeof e>"u")return this.$("img")?this.$("img").crossOrigin:this.player_.tech_&&this.player_.tech_.isReady_?this.player_.crossOrigin():this.player_.options_.crossOrigin||this.player_.options_.crossorigin||null;if(e!==null&&e!=="anonymous"&&e!=="use-credentials"){this.player_.log.warn(`crossOrigin must be null, "anonymous" or "use-credentials", given "${e}"`);return}this.$("img")&&(this.$("img").crossOrigin=e)}update(e){const t=this.player().poster();this.setSrc(t),t?this.show():this.hide()}setSrc(e){if(!e){this.el_.textContent="";return}this.$("img")||this.el_.appendChild(se("picture",{className:"vjs-poster",tabIndex:-1},{},se("img",{loading:"lazy",crossOrigin:this.crossOrigin()},{alt:""}))),this.$("img").src=e}handleClick(e){this.player_.controls()&&(this.player_.tech(!0)&&this.player_.tech(!0).focus(),this.player_.paused()?Kt(this.player_.play()):this.player_.pause())}}ao.prototype.crossorigin=ao.prototype.crossOrigin;H.registerComponent("PosterImage",ao);const Ct="#222",Wu="#ccc",ov={monospace:"monospace",sansSerif:"sans-serif",serif:"serif",monospaceSansSerif:'"Andale Mono", "Lucida Console", monospace',monospaceSerif:'"Courier New", monospace',proportionalSansSerif:"sans-serif",proportionalSerif:"serif",casual:'"Comic Sans MS", Impact, fantasy',script:'"Monotype Corsiva", cursive',smallcaps:'"Andale Mono", "Lucida Console", monospace, sans-serif'};function Fa(s,e){let t;if(s.length===4)t=s[1]+s[1]+s[2]+s[2]+s[3]+s[3];else if(s.length===7)t=s.slice(1);else throw new Error("Invalid color code provided, "+s+"; must be formatted as e.g. #f0e or #f604e2.");return"rgba("+parseInt(t.slice(0,2),16)+","+parseInt(t.slice(2,4),16)+","+parseInt(t.slice(4,6),16)+","+e+")"}function Ht(s,e,t){try{s.style[e]=t}catch{return}}function Gu(s){return s?`${s}px`:""}class lv extends H{constructor(e,t,i){super(e,t,i);const n=a=>this.updateDisplay(a),r=a=>{this.updateDisplayOverlay(),this.updateDisplay(a)};e.on("loadstart",a=>this.toggleDisplay(a)),e.on("texttrackchange",n),e.on("loadedmetadata",a=>{this.updateDisplayOverlay(),this.preselectTrack(a)}),e.ready(we(this,function(){if(e.tech_&&e.tech_.featuresNativeTextTracks){this.hide();return}e.on("fullscreenchange",r),e.on("playerresize",r);const a=k.screen.orientation||k,l=k.screen.orientation?"change":"orientationchange";a.addEventListener(l,r),e.on("dispose",()=>a.removeEventListener(l,r));const h=this.options_.playerOptions.tracks||[];for(let f=0;f<h.length;f++)this.player_.addRemoteTextTrack(h[f],!0);this.preselectTrack()}))}preselectTrack(){const e={captions:1,subtitles:1},t=this.player_.textTracks(),i=this.player_.cache_.selectedLanguage;let n,r,a;for(let l=0;l<t.length;l++){const h=t[l];i&&i.enabled&&i.language&&i.language===h.language&&h.kind in e?h.kind===i.kind?a=h:a||(a=h):i&&!i.enabled?(a=null,n=null,r=null):h.default&&(h.kind==="descriptions"&&!n?n=h:h.kind in e&&!r&&(r=h))}a?a.mode="showing":r?r.mode="showing":n&&(n.mode="showing")}toggleDisplay(){this.player_.tech_&&this.player_.tech_.featuresNativeTextTracks?this.hide():this.show()}createEl(){return super.createEl("div",{className:"vjs-text-track-display"},{translate:"yes","aria-live":"off","aria-atomic":"true"})}clearDisplay(){typeof k.WebVTT=="function"&&k.WebVTT.processCues(k,[],this.el_)}updateDisplay(){const e=this.player_.textTracks(),t=this.options_.allowMultipleShowingTracks;if(this.clearDisplay(),t){const a=[];for(let l=0;l<e.length;++l){const h=e[l];h.mode==="showing"&&a.push(h)}this.updateForTrack(a);return}let i=null,n=null,r=e.length;for(;r--;){const a=e[r];a.mode==="showing"&&(a.kind==="descriptions"?i=a:n=a)}if(n?(this.getAttribute("aria-live")!=="off"&&this.setAttribute("aria-live","off"),this.updateForTrack(n)):i&&(this.getAttribute("aria-live")!=="assertive"&&this.setAttribute("aria-live","assertive"),this.updateForTrack(i)),!k.CSS.supports("inset","10px")){const a=this.el_,l=a.querySelectorAll(".vjs-text-track-cue"),h=this.player_.controlBar.el_.getBoundingClientRect().height,f=this.player_.el_.getBoundingClientRect().height;a.style="",Ht(a,"position","relative"),Ht(a,"height",f-h+"px"),Ht(a,"top","unset"),yr?Ht(a,"bottom",f+"px"):Ht(a,"bottom","0px"),l.length>0&&l.forEach(m=>{if(m.style.inset){const T=m.style.inset.split(" ");T.length===3&&Object.assign(m.style,{top:T[0],right:T[1],bottom:T[2],left:"unset"})}})}}updateDisplayOverlay(){if(!this.player_.videoHeight()||!k.CSS.supports("inset-inline: 10px"))return;const e=this.player_.currentWidth(),t=this.player_.currentHeight(),i=e/t,n=this.player_.videoWidth()/this.player_.videoHeight();let r=0,a=0;Math.abs(i-n)>.1&&(i>n?r=Math.round((e-t*n)/2):a=Math.round((t-e/n)/2)),Ht(this.el_,"insetInline",Gu(r)),Ht(this.el_,"insetBlock",Gu(a))}updateDisplayState(e){const t=this.player_.textTrackSettings.getValues(),i=e.activeCues;let n=i.length;for(;n--;){const r=i[n];if(!r)continue;const a=r.displayState;if(t.color&&(a.firstChild.style.color=t.color),t.textOpacity&&Ht(a.firstChild,"color",Fa(t.color||"#fff",t.textOpacity)),t.backgroundColor&&(a.firstChild.style.backgroundColor=t.backgroundColor),t.backgroundOpacity&&Ht(a.firstChild,"backgroundColor",Fa(t.backgroundColor||"#000",t.backgroundOpacity)),t.windowColor&&(t.windowOpacity?Ht(a,"backgroundColor",Fa(t.windowColor,t.windowOpacity)):a.style.backgroundColor=t.windowColor),t.edgeStyle&&(t.edgeStyle==="dropshadow"?a.firstChild.style.textShadow=`2px 2px 3px ${Ct}, 2px 2px 4px ${Ct}, 2px 2px 5px ${Ct}`:t.edgeStyle==="raised"?a.firstChild.style.textShadow=`1px 1px ${Ct}, 2px 2px ${Ct}, 3px 3px ${Ct}`:t.edgeStyle==="depressed"?a.firstChild.style.textShadow=`1px 1px ${Wu}, 0 1px ${Wu}, -1px -1px ${Ct}, 0 -1px ${Ct}`:t.edgeStyle==="uniform"&&(a.firstChild.style.textShadow=`0 0 4px ${Ct}, 0 0 4px ${Ct}, 0 0 4px ${Ct}, 0 0 4px ${Ct}`)),t.fontPercent&&t.fontPercent!==1){const l=k.parseFloat(a.style.fontSize);a.style.fontSize=l*t.fontPercent+"px",a.style.height="auto",a.style.top="auto"}t.fontFamily&&t.fontFamily!=="default"&&(t.fontFamily==="small-caps"?a.firstChild.style.fontVariant="small-caps":a.firstChild.style.fontFamily=ov[t.fontFamily])}}updateForTrack(e){if(Array.isArray(e)||(e=[e]),typeof k.WebVTT!="function"||e.every(i=>!i.activeCues))return;const t=[];for(let i=0;i<e.length;++i){const n=e[i];for(let r=0;r<n.activeCues.length;++r)t.push(n.activeCues[r])}k.WebVTT.processCues(k,t,this.el_);for(let i=0;i<e.length;++i){const n=e[i];for(let r=0;r<n.activeCues.length;++r){const a=n.activeCues[r].displayState;Fi(a,"vjs-text-track-cue","vjs-text-track-cue-"+(n.language?n.language:i)),n.language&&_s(a,"lang",n.language)}this.player_.textTrackSettings&&this.updateDisplayState(n)}}}H.registerComponent("TextTrackDisplay",lv);class uv extends H{createEl(){const e=this.player_.isAudio(),t=this.localize(e?"Audio Player":"Video Player"),i=se("span",{className:"vjs-control-text",textContent:this.localize("{1} is loading.",[t])}),n=super.createEl("div",{className:"vjs-loading-spinner",dir:"ltr"});return n.appendChild(i),n}handleLanguagechange(){this.$(".vjs-control-text").textContent=this.localize("{1} is loading.",[this.player_.isAudio()?"Audio Player":"Video Player"])}}H.registerComponent("LoadingSpinner",uv);class tt extends ta{createEl(e,t={},i={}){e="button",t=Object.assign({className:this.buildCSSClass()},t),i=Object.assign({type:"button"},i);const n=se(e,t,i);return this.player_.options_.experimentalSvgIcons||n.appendChild(se("span",{className:"vjs-icon-placeholder"},{"aria-hidden":!0})),this.createControlTextEl(n),n}addChild(e,t={}){const i=this.constructor.name;return ue.warn(`Adding an actionable (user controllable) child to a Button (${i}) is not supported; use a ClickableComponent instead.`),H.prototype.addChild.call(this,e,t)}enable(){super.enable(),this.el_.removeAttribute("disabled")}disable(){super.disable(),this.el_.setAttribute("disabled","disabled")}handleKeyDown(e){if(e.key===" "||e.key==="Enter"){e.stopPropagation();return}super.handleKeyDown(e)}}H.registerComponent("Button",tt);class lh extends tt{constructor(e,t){super(e,t),this.mouseused_=!1,this.setIcon("play"),this.on("mousedown",i=>this.handleMouseDown(i))}buildCSSClass(){return"vjs-big-play-button"}handleClick(e){const t=this.player_.play();if(this.mouseused_&&"clientX"in e&&"clientY"in e){Kt(t),this.player_.tech(!0)&&this.player_.tech(!0).focus();return}const i=this.player_.getChild("controlBar"),n=i&&i.getChild("playToggle");if(!n){this.player_.tech(!0).focus();return}const r=()=>n.focus();pn(t)?t.then(r,()=>{}):this.setTimeout(r,1)}handleKeyDown(e){this.mouseused_=!1,super.handleKeyDown(e)}handleMouseDown(e){this.mouseused_=!0}}lh.prototype.controlText_="Play Video";H.registerComponent("BigPlayButton",lh);class cv extends tt{constructor(e,t){super(e,t),this.setIcon("cancel"),this.controlText(t&&t.controlText||this.localize("Close"))}buildCSSClass(){return`vjs-close-button ${super.buildCSSClass()}`}handleClick(e){this.trigger({type:"close",bubbles:!1})}handleKeyDown(e){e.key==="Escape"?(e.preventDefault(),e.stopPropagation(),this.trigger("click")):super.handleKeyDown(e)}}H.registerComponent("CloseButton",cv);class uh extends tt{constructor(e,t={}){super(e,t),t.replay=t.replay===void 0||t.replay,this.setIcon("play"),this.on(e,"play",i=>this.handlePlay(i)),this.on(e,"pause",i=>this.handlePause(i)),t.replay&&this.on(e,"ended",i=>this.handleEnded(i))}buildCSSClass(){return`vjs-play-control ${super.buildCSSClass()}`}handleClick(e){this.player_.paused()?Kt(this.player_.play()):this.player_.pause()}handleSeeked(e){this.removeClass("vjs-ended"),this.player_.paused()?this.handlePause(e):this.handlePlay(e)}handlePlay(e){this.removeClass("vjs-ended","vjs-paused"),this.addClass("vjs-playing"),this.setIcon("pause"),this.controlText("Pause")}handlePause(e){this.removeClass("vjs-playing"),this.addClass("vjs-paused"),this.setIcon("play"),this.controlText("Play")}handleEnded(e){this.removeClass("vjs-playing"),this.addClass("vjs-ended"),this.setIcon("replay"),this.controlText("Replay"),this.one(this.player_,"seeked",t=>this.handleSeeked(t))}}uh.prototype.controlText_="Play";H.registerComponent("PlayToggle",uh);class As extends H{constructor(e,t){super(e,t),this.on(e,["timeupdate","ended","seeking"],i=>this.update(i)),this.updateTextNode_()}createEl(){const e=this.buildCSSClass(),t=super.createEl("div",{className:`${e} vjs-time-control vjs-control`}),i=se("span",{className:"vjs-control-text",textContent:`${this.localize(this.labelText_)} `},{role:"presentation"});return t.appendChild(i),this.contentEl_=se("span",{className:`${e}-display`},{role:"presentation"}),t.appendChild(this.contentEl_),t}dispose(){this.contentEl_=null,this.textNode_=null,super.dispose()}update(e){!this.player_.options_.enableSmoothSeeking&&e.type==="seeking"||this.updateContent(e)}updateTextNode_(e=0){e=Hi(e),this.formattedTime_!==e&&(this.formattedTime_=e,this.requestNamedAnimationFrame("TimeDisplay#updateTextNode_",()=>{if(!this.contentEl_)return;let t=this.textNode_;t&&this.contentEl_.firstChild!==t&&(t=null,ue.warn("TimeDisplay#updateTextnode_: Prevented replacement of text node element since it was no longer a child of this node. Appending a new node instead.")),this.textNode_=K.createTextNode(this.formattedTime_),this.textNode_&&(t?this.contentEl_.replaceChild(this.textNode_,t):this.contentEl_.appendChild(this.textNode_))}))}updateContent(e){}}As.prototype.labelText_="Time";As.prototype.controlText_="Time";H.registerComponent("TimeDisplay",As);class Xo extends As{buildCSSClass(){return"vjs-current-time"}updateContent(e){let t;this.player_.ended()?t=this.player_.duration():t=this.player_.scrubbing()?this.player_.getCache().currentTime:this.player_.currentTime(),this.updateTextNode_(t)}}Xo.prototype.labelText_="Current Time";Xo.prototype.controlText_="Current Time";H.registerComponent("CurrentTimeDisplay",Xo);class Yo extends As{constructor(e,t){super(e,t);const i=n=>this.updateContent(n);this.on(e,"durationchange",i),this.on(e,"loadstart",i),this.on(e,"loadedmetadata",i)}buildCSSClass(){return"vjs-duration"}updateContent(e){const t=this.player_.duration();this.updateTextNode_(t)}}Yo.prototype.labelText_="Duration";Yo.prototype.controlText_="Duration";H.registerComponent("DurationDisplay",Yo);class dv extends H{createEl(){const e=super.createEl("div",{className:"vjs-time-control vjs-time-divider"},{"aria-hidden":!0}),t=super.createEl("div"),i=super.createEl("span",{textContent:"/"});return t.appendChild(i),e.appendChild(t),e}}H.registerComponent("TimeDivider",dv);class Qo extends As{constructor(e,t){super(e,t),this.on(e,"durationchange",i=>this.updateContent(i))}buildCSSClass(){return"vjs-remaining-time"}createEl(){const e=super.createEl();return this.options_.displayNegative!==!1&&e.insertBefore(se("span",{},{"aria-hidden":!0},"-"),this.contentEl_),e}updateContent(e){if(typeof this.player_.duration()!="number")return;let t;this.player_.ended()?t=0:this.player_.remainingTimeDisplay?t=this.player_.remainingTimeDisplay():t=this.player_.remainingTime(),this.updateTextNode_(t)}}Qo.prototype.labelText_="Remaining Time";Qo.prototype.controlText_="Remaining Time";H.registerComponent("RemainingTimeDisplay",Qo);class hv extends H{constructor(e,t){super(e,t),this.updateShowing(),this.on(this.player(),"durationchange",i=>this.updateShowing(i))}createEl(){const e=super.createEl("div",{className:"vjs-live-control vjs-control"});return this.contentEl_=se("div",{className:"vjs-live-display"},{"aria-live":"off"}),this.contentEl_.appendChild(se("span",{className:"vjs-control-text",textContent:`${this.localize("Stream Type")} `})),this.contentEl_.appendChild(K.createTextNode(this.localize("LIVE"))),e.appendChild(this.contentEl_),e}dispose(){this.contentEl_=null,super.dispose()}updateShowing(e){this.player().duration()===1/0?this.show():this.hide()}}H.registerComponent("LiveDisplay",hv);class ch extends tt{constructor(e,t){super(e,t),this.updateLiveEdgeStatus(),this.player_.liveTracker&&(this.updateLiveEdgeStatusHandler_=i=>this.updateLiveEdgeStatus(i),this.on(this.player_.liveTracker,"liveedgechange",this.updateLiveEdgeStatusHandler_))}createEl(){const e=super.createEl("button",{className:"vjs-seek-to-live-control vjs-control"});return this.setIcon("circle",e),this.textEl_=se("span",{className:"vjs-seek-to-live-text",textContent:this.localize("LIVE")},{"aria-hidden":"true"}),e.appendChild(this.textEl_),e}updateLiveEdgeStatus(){!this.player_.liveTracker||this.player_.liveTracker.atLiveEdge()?(this.setAttribute("aria-disabled",!0),this.addClass("vjs-at-live-edge"),this.controlText("Seek to live, currently playing live")):(this.setAttribute("aria-disabled",!1),this.removeClass("vjs-at-live-edge"),this.controlText("Seek to live, currently behind live"))}handleClick(){this.player_.liveTracker.seekToLiveEdge()}dispose(){this.player_.liveTracker&&this.off(this.player_.liveTracker,"liveedgechange",this.updateLiveEdgeStatusHandler_),this.textEl_=null,super.dispose()}}ch.prototype.controlText_="Seek to live, currently playing live";H.registerComponent("SeekToLive",ch);function Sn(s,e,t){return s=Number(s),Math.min(t,Math.max(e,isNaN(s)?e:s))}var fv=Object.freeze({__proto__:null,clamp:Sn});class Jo extends H{constructor(e,t){super(e,t),this.handleMouseDown_=i=>this.handleMouseDown(i),this.handleMouseUp_=i=>this.handleMouseUp(i),this.handleKeyDown_=i=>this.handleKeyDown(i),this.handleClick_=i=>this.handleClick(i),this.handleMouseMove_=i=>this.handleMouseMove(i),this.update_=i=>this.update(i),this.bar=this.getChild(this.options_.barName),this.vertical(!!this.options_.vertical),this.enable()}enabled(){return this.enabled_}enable(){this.enabled()||(this.on("mousedown",this.handleMouseDown_),this.on("touchstart",this.handleMouseDown_),this.on("keydown",this.handleKeyDown_),this.on("click",this.handleClick_),this.on(this.player_,"controlsvisible",this.update),this.playerEvent&&this.on(this.player_,this.playerEvent,this.update),this.removeClass("disabled"),this.setAttribute("tabindex",0),this.enabled_=!0)}disable(){if(!this.enabled())return;const e=this.bar.el_.ownerDocument;this.off("mousedown",this.handleMouseDown_),this.off("touchstart",this.handleMouseDown_),this.off("keydown",this.handleKeyDown_),this.off("click",this.handleClick_),this.off(this.player_,"controlsvisible",this.update_),this.off(e,"mousemove",this.handleMouseMove_),this.off(e,"mouseup",this.handleMouseUp_),this.off(e,"touchmove",this.handleMouseMove_),this.off(e,"touchend",this.handleMouseUp_),this.removeAttribute("tabindex"),this.addClass("disabled"),this.playerEvent&&this.off(this.player_,this.playerEvent,this.update),this.enabled_=!1}createEl(e,t={},i={}){return t.className=t.className+" vjs-slider",t=Object.assign({tabIndex:0},t),i=Object.assign({role:"slider","aria-valuenow":0,"aria-valuemin":0,"aria-valuemax":100},i),super.createEl(e,t,i)}handleMouseDown(e){const t=this.bar.el_.ownerDocument;e.type==="mousedown"&&e.preventDefault(),e.type==="touchstart"&&!ei&&e.preventDefault(),Ud(),this.addClass("vjs-sliding"),this.trigger("slideractive"),this.on(t,"mousemove",this.handleMouseMove_),this.on(t,"mouseup",this.handleMouseUp_),this.on(t,"touchmove",this.handleMouseMove_),this.on(t,"touchend",this.handleMouseUp_),this.handleMouseMove(e,!0)}handleMouseMove(e){}handleMouseUp(e){const t=this.bar.el_.ownerDocument;Bd(),this.removeClass("vjs-sliding"),this.trigger("sliderinactive"),this.off(t,"mousemove",this.handleMouseMove_),this.off(t,"mouseup",this.handleMouseUp_),this.off(t,"touchmove",this.handleMouseMove_),this.off(t,"touchend",this.handleMouseUp_),this.update()}update(){if(!this.el_||!this.bar)return;const e=this.getProgress();return e===this.progress_||(this.progress_=e,this.requestNamedAnimationFrame("Slider#update",()=>{const t=this.vertical()?"height":"width";this.bar.el().style[t]=(e*100).toFixed(2)+"%"})),e}getProgress(){return Number(Sn(this.getPercent(),0,1).toFixed(4))}calculateDistance(e){const t=Xr(this.el_,e);return this.vertical()?t.y:t.x}handleKeyDown(e){const t=this.options_.playerOptions.spatialNavigation,i=t&&t.enabled,n=t&&t.horizontalSeek;i?n&&e.key==="ArrowLeft"||!n&&e.key==="ArrowDown"?(e.preventDefault(),e.stopPropagation(),this.stepBack()):n&&e.key==="ArrowRight"||!n&&e.key==="ArrowUp"?(e.preventDefault(),e.stopPropagation(),this.stepForward()):super.handleKeyDown(e):e.key==="ArrowLeft"||e.key==="ArrowDown"?(e.preventDefault(),e.stopPropagation(),this.stepBack()):e.key==="ArrowUp"||e.key==="ArrowRight"?(e.preventDefault(),e.stopPropagation(),this.stepForward()):super.handleKeyDown(e)}handleClick(e){e.stopPropagation(),e.preventDefault()}vertical(e){if(e===void 0)return this.vertical_||!1;this.vertical_=!!e,this.vertical_?this.addClass("vjs-slider-vertical"):this.addClass("vjs-slider-horizontal")}}H.registerComponent("Slider",Jo);const $a=(s,e)=>Sn(s/e*100,0,100).toFixed(2)+"%";class pv extends H{constructor(e,t){super(e,t),this.partEls_=[],this.on(e,"progress",i=>this.update(i))}createEl(){const e=super.createEl("div",{className:"vjs-load-progress"}),t=se("span",{className:"vjs-control-text"}),i=se("span",{textContent:this.localize("Loaded")}),n=K.createTextNode(": ");return this.percentageEl_=se("span",{className:"vjs-control-text-loaded-percentage",textContent:"0%"}),e.appendChild(t),t.appendChild(i),t.appendChild(n),t.appendChild(this.percentageEl_),e}dispose(){this.partEls_=null,this.percentageEl_=null,super.dispose()}update(e){this.requestNamedAnimationFrame("LoadProgressBar#update",()=>{const t=this.player_.liveTracker,i=this.player_.buffered(),n=t&&t.isLive()?t.seekableEnd():this.player_.duration(),r=this.player_.bufferedEnd(),a=this.partEls_,l=$a(r,n);this.percent_!==l&&(this.el_.style.width=l,Ci(this.percentageEl_,l),this.percent_=l);for(let h=0;h<i.length;h++){const f=i.start(h),m=i.end(h);let T=a[h];T||(T=this.el_.appendChild(se()),a[h]=T),!(T.dataset.start===f&&T.dataset.end===m)&&(T.dataset.start=f,T.dataset.end=m,T.style.left=$a(f,r),T.style.width=$a(m-f,r))}for(let h=a.length;h>i.length;h--)this.el_.removeChild(a[h-1]);a.length=i.length})}}H.registerComponent("LoadProgressBar",pv);class mv extends H{constructor(e,t){super(e,t),this.update=ti(we(this,this.update),kt)}createEl(){return super.createEl("div",{className:"vjs-time-tooltip"},{"aria-hidden":"true"})}update(e,t,i){const n=Tn(this.el_),r=Ts(this.player_.el()),a=e.width*t;if(!r||!n)return;let l=e.left-r.left+a,h=e.width-a+(r.right-e.right);h||(h=e.width-a,l=a);let f=n.width/2;l<f?f+=f-l:h<f&&(f=h),f<0?f=0:f>n.width&&(f=n.width),f=Math.round(f),this.el_.style.right=`-${f}px`,this.write(i)}write(e){Ci(this.el_,e)}updateTime(e,t,i,n){this.requestNamedAnimationFrame("TimeTooltip#updateTime",()=>{let r;const a=this.player_.duration();if(this.player_.liveTracker&&this.player_.liveTracker.isLive()){const l=this.player_.liveTracker.liveWindow(),h=l-t*l;r=(h<1?"":"-")+Hi(h,l)}else r=Hi(i,a);this.update(e,t,r),n&&n()})}}H.registerComponent("TimeTooltip",mv);class Zo extends H{constructor(e,t){super(e,t),this.setIcon("circle"),this.update=ti(we(this,this.update),kt)}createEl(){return super.createEl("div",{className:"vjs-play-progress vjs-slider-bar"},{"aria-hidden":"true"})}update(e,t){const i=this.getChild("timeTooltip");if(!i)return;const n=this.player_.scrubbing()?this.player_.getCache().currentTime:this.player_.currentTime();i.updateTime(e,t,n)}}Zo.prototype.options_={children:[]};!Ze&&!Ut&&Zo.prototype.options_.children.push("timeTooltip");H.registerComponent("PlayProgressBar",Zo);class dh extends H{constructor(e,t){super(e,t),this.update=ti(we(this,this.update),kt)}createEl(){return super.createEl("div",{className:"vjs-mouse-display"})}update(e,t){const i=t*this.player_.duration();this.getChild("timeTooltip").updateTime(e,t,i,()=>{this.el_.style.left=`${e.width*t}px`})}}dh.prototype.options_={children:["timeTooltip"]};H.registerComponent("MouseTimeDisplay",dh);const ir=5,Ku=12;class ia extends Jo{constructor(e,t){t=xe(ia.prototype.options_,t),t.children=[...t.children];const i=e.options_.disableSeekWhileScrubbingOnMobile&&(Ze||Ut);(!Ze&&!Ut||i)&&t.children.splice(1,0,"mouseTimeDisplay"),super(e,t),this.shouldDisableSeekWhileScrubbingOnMobile_=i,this.pendingSeekTime_=null,this.setEventHandlers_()}setEventHandlers_(){this.update_=we(this,this.update),this.update=ti(this.update_,kt),this.on(this.player_,["durationchange","timeupdate"],this.update),this.on(this.player_,["ended"],this.update_),this.player_.liveTracker&&this.on(this.player_.liveTracker,"liveedgechange",this.update),this.updateInterval=null,this.enableIntervalHandler_=e=>this.enableInterval_(e),this.disableIntervalHandler_=e=>this.disableInterval_(e),this.on(this.player_,["playing"],this.enableIntervalHandler_),this.on(this.player_,["ended","pause","waiting"],this.disableIntervalHandler_),"hidden"in K&&"visibilityState"in K&&this.on(K,"visibilitychange",this.toggleVisibility_)}toggleVisibility_(e){K.visibilityState==="hidden"?(this.cancelNamedAnimationFrame("SeekBar#update"),this.cancelNamedAnimationFrame("Slider#update"),this.disableInterval_(e)):(!this.player_.ended()&&!this.player_.paused()&&this.enableInterval_(),this.update())}enableInterval_(){this.updateInterval||(this.updateInterval=this.setInterval(this.update,kt))}disableInterval_(e){this.player_.liveTracker&&this.player_.liveTracker.isLive()&&e&&e.type!=="ended"||this.updateInterval&&(this.clearInterval(this.updateInterval),this.updateInterval=null)}createEl(){return super.createEl("div",{className:"vjs-progress-holder"},{"aria-label":this.localize("Progress Bar")})}update(e){if(K.visibilityState==="hidden")return;const t=super.update();return this.requestNamedAnimationFrame("SeekBar#update",()=>{const i=this.player_.ended()?this.player_.duration():this.getCurrentTime_(),n=this.player_.liveTracker;let r=this.player_.duration();n&&n.isLive()&&(r=this.player_.liveTracker.liveCurrentTime()),this.percent_!==t&&(this.el_.setAttribute("aria-valuenow",(t*100).toFixed(2)),this.percent_=t),(this.currentTime_!==i||this.duration_!==r)&&(this.el_.setAttribute("aria-valuetext",this.localize("progress bar timing: currentTime={1} duration={2}",[Hi(i,r),Hi(r,r)],"{1} of {2}")),this.currentTime_=i,this.duration_=r),this.bar&&this.bar.update(Ts(this.el()),this.getProgress())}),t}userSeek_(e){this.player_.liveTracker&&this.player_.liveTracker.isLive()&&this.player_.liveTracker.nextSeekedFromUser(),this.player_.currentTime(e)}getCurrentTime_(){return this.player_.scrubbing()?this.player_.getCache().currentTime:this.player_.currentTime()}getPercent(){if(this.pendingSeekTime_)return this.pendingSeekTime_/this.player_.duration();const e=this.getCurrentTime_();let t;const i=this.player_.liveTracker;return i&&i.isLive()?(t=(e-i.seekableStart())/i.liveWindow(),i.atLiveEdge()&&(t=1)):t=e/this.player_.duration(),t}handleMouseDown(e){vn(e)&&(e.stopPropagation(),this.videoWasPlaying=!this.player_.paused(),this.shouldDisableSeekWhileScrubbingOnMobile_||this.player_.pause(),super.handleMouseDown(e))}handleMouseMove(e,t=!1){if(!vn(e)||isNaN(this.player_.duration()))return;!t&&!this.player_.scrubbing()&&this.player_.scrubbing(!0);let i;const n=this.calculateDistance(e),r=this.player_.liveTracker;if(!r||!r.isLive())i=n*this.player_.duration(),i===this.player_.duration()&&(i=i-.1);else{if(n>=.99){r.seekToLiveEdge();return}const a=r.seekableStart(),l=r.liveCurrentTime();if(i=a+n*r.liveWindow(),i>=l&&(i=l),i<=a&&(i=a+.1),i===1/0)return}this.shouldDisableSeekWhileScrubbingOnMobile_?this.pendingSeekTime_=i:this.userSeek_(i),this.player_.options_.enableSmoothSeeking&&this.update()}enable(){super.enable();const e=this.getChild("mouseTimeDisplay");e&&e.show()}disable(){super.disable();const e=this.getChild("mouseTimeDisplay");e&&e.hide()}handleMouseUp(e){super.handleMouseUp(e),e&&e.stopPropagation(),this.player_.scrubbing(!1),this.pendingSeekTime_&&(this.userSeek_(this.pendingSeekTime_),this.pendingSeekTime_=null),this.player_.trigger({type:"timeupdate",target:this,manuallyTriggered:!0}),this.videoWasPlaying?Kt(this.player_.play()):this.update_()}stepForward(){this.userSeek_(this.player_.currentTime()+ir)}stepBack(){this.userSeek_(this.player_.currentTime()-ir)}handleAction(e){this.player_.paused()?this.player_.play():this.player_.pause()}handleKeyDown(e){const t=this.player_.liveTracker;if(e.key===" "||e.key==="Enter")e.preventDefault(),e.stopPropagation(),this.handleAction(e);else if(e.key==="Home")e.preventDefault(),e.stopPropagation(),this.userSeek_(0);else if(e.key==="End")e.preventDefault(),e.stopPropagation(),t&&t.isLive()?this.userSeek_(t.liveCurrentTime()):this.userSeek_(this.player_.duration());else if(/^[0-9]$/.test(e.key)){e.preventDefault(),e.stopPropagation();const i=parseInt(e.key,10)*.1;t&&t.isLive()?this.userSeek_(t.seekableStart()+t.liveWindow()*i):this.userSeek_(this.player_.duration()*i)}else e.key==="PageDown"?(e.preventDefault(),e.stopPropagation(),this.userSeek_(this.player_.currentTime()-ir*Ku)):e.key==="PageUp"?(e.preventDefault(),e.stopPropagation(),this.userSeek_(this.player_.currentTime()+ir*Ku)):super.handleKeyDown(e)}dispose(){this.disableInterval_(),this.off(this.player_,["durationchange","timeupdate"],this.update),this.off(this.player_,["ended"],this.update_),this.player_.liveTracker&&this.off(this.player_.liveTracker,"liveedgechange",this.update),this.off(this.player_,["playing"],this.enableIntervalHandler_),this.off(this.player_,["ended","pause","waiting"],this.disableIntervalHandler_),"hidden"in K&&"visibilityState"in K&&this.off(K,"visibilitychange",this.toggleVisibility_),super.dispose()}}ia.prototype.options_={children:["loadProgressBar","playProgressBar"],barName:"playProgressBar"};H.registerComponent("SeekBar",ia);class hh extends H{constructor(e,t){super(e,t),this.handleMouseMove=ti(we(this,this.handleMouseMove),kt),this.throttledHandleMouseSeek=ti(we(this,this.handleMouseSeek),kt),this.handleMouseUpHandler_=i=>this.handleMouseUp(i),this.handleMouseDownHandler_=i=>this.handleMouseDown(i),this.enable()}createEl(){return super.createEl("div",{className:"vjs-progress-control vjs-control"})}handleMouseMove(e){const t=this.getChild("seekBar");if(!t)return;const i=t.getChild("playProgressBar"),n=t.getChild("mouseTimeDisplay");if(!i&&!n)return;const r=t.el(),a=Tn(r);let l=Xr(r,e).x;l=Sn(l,0,1),n&&n.update(a,l),i&&i.update(a,t.getProgress())}handleMouseSeek(e){const t=this.getChild("seekBar");t&&t.handleMouseMove(e)}enabled(){return this.enabled_}disable(){if(this.children().forEach(e=>e.disable&&e.disable()),!!this.enabled()&&(this.off(["mousedown","touchstart"],this.handleMouseDownHandler_),this.off(this.el_,["mousemove","touchmove"],this.handleMouseMove),this.removeListenersAddedOnMousedownAndTouchstart(),this.addClass("disabled"),this.enabled_=!1,this.player_.scrubbing())){const e=this.getChild("seekBar");this.player_.scrubbing(!1),e.videoWasPlaying&&Kt(this.player_.play())}}enable(){this.children().forEach(e=>e.enable&&e.enable()),!this.enabled()&&(this.on(["mousedown","touchstart"],this.handleMouseDownHandler_),this.on(this.el_,["mousemove","touchmove"],this.handleMouseMove),this.removeClass("disabled"),this.enabled_=!0)}removeListenersAddedOnMousedownAndTouchstart(){const e=this.el_.ownerDocument;this.off(e,"mousemove",this.throttledHandleMouseSeek),this.off(e,"touchmove",this.throttledHandleMouseSeek),this.off(e,"mouseup",this.handleMouseUpHandler_),this.off(e,"touchend",this.handleMouseUpHandler_)}handleMouseDown(e){const t=this.el_.ownerDocument,i=this.getChild("seekBar");i&&i.handleMouseDown(e),this.on(t,"mousemove",this.throttledHandleMouseSeek),this.on(t,"touchmove",this.throttledHandleMouseSeek),this.on(t,"mouseup",this.handleMouseUpHandler_),this.on(t,"touchend",this.handleMouseUpHandler_)}handleMouseUp(e){const t=this.getChild("seekBar");t&&t.handleMouseUp(e),this.removeListenersAddedOnMousedownAndTouchstart()}}hh.prototype.options_={children:["seekBar"]};H.registerComponent("ProgressControl",hh);class fh extends tt{constructor(e,t){super(e,t),this.setIcon("picture-in-picture-enter"),this.on(e,["enterpictureinpicture","leavepictureinpicture"],i=>this.handlePictureInPictureChange(i)),this.on(e,["disablepictureinpicturechanged","loadedmetadata"],i=>this.handlePictureInPictureEnabledChange(i)),this.on(e,["loadedmetadata","audioonlymodechange","audiopostermodechange"],()=>this.handlePictureInPictureAudioModeChange()),this.disable()}buildCSSClass(){return`vjs-picture-in-picture-control vjs-hidden ${super.buildCSSClass()}`}handlePictureInPictureAudioModeChange(){if(!(this.player_.currentType().substring(0,5)==="audio"||this.player_.audioPosterMode()||this.player_.audioOnlyMode())){this.show();return}this.player_.isInPictureInPicture()&&this.player_.exitPictureInPicture(),this.hide()}handlePictureInPictureEnabledChange(){K.pictureInPictureEnabled&&this.player_.disablePictureInPicture()===!1||this.player_.options_.enableDocumentPictureInPicture&&"documentPictureInPicture"in k?this.enable():this.disable()}handlePictureInPictureChange(e){this.player_.isInPictureInPicture()?(this.setIcon("picture-in-picture-exit"),this.controlText("Exit Picture-in-Picture")):(this.setIcon("picture-in-picture-enter"),this.controlText("Picture-in-Picture")),this.handlePictureInPictureEnabledChange()}handleClick(e){this.player_.isInPictureInPicture()?this.player_.exitPictureInPicture():this.player_.requestPictureInPicture()}show(){typeof K.exitPictureInPicture=="function"&&super.show()}}fh.prototype.controlText_="Picture-in-Picture";H.registerComponent("PictureInPictureToggle",fh);class ph extends tt{constructor(e,t){super(e,t),this.setIcon("fullscreen-enter"),this.on(e,"fullscreenchange",i=>this.handleFullscreenChange(i)),K[e.fsApi_.fullscreenEnabled]===!1&&this.disable()}buildCSSClass(){return`vjs-fullscreen-control ${super.buildCSSClass()}`}handleFullscreenChange(e){this.player_.isFullscreen()?(this.controlText("Exit Fullscreen"),this.setIcon("fullscreen-exit")):(this.controlText("Fullscreen"),this.setIcon("fullscreen-enter"))}handleClick(e){this.player_.isFullscreen()?this.player_.exitFullscreen():this.player_.requestFullscreen()}}ph.prototype.controlText_="Fullscreen";H.registerComponent("FullscreenToggle",ph);const gv=function(s,e){e.tech_&&!e.tech_.featuresVolumeControl&&s.addClass("vjs-hidden"),s.on(e,"loadstart",function(){e.tech_.featuresVolumeControl?s.removeClass("vjs-hidden"):s.addClass("vjs-hidden")})};class yv extends H{createEl(){const e=super.createEl("div",{className:"vjs-volume-level"});return this.setIcon("circle",e),e.appendChild(super.createEl("span",{className:"vjs-control-text"})),e}}H.registerComponent("VolumeLevel",yv);class _v extends H{constructor(e,t){super(e,t),this.update=ti(we(this,this.update),kt)}createEl(){return super.createEl("div",{className:"vjs-volume-tooltip"},{"aria-hidden":"true"})}update(e,t,i,n){if(!i){const r=Ts(this.el_),a=Ts(this.player_.el()),l=e.width*t;if(!a||!r)return;const h=e.left-a.left+l,f=e.width-l+(a.right-e.right);let m=r.width/2;h<m?m+=m-h:f<m&&(m=f),m<0?m=0:m>r.width&&(m=r.width),this.el_.style.right=`-${m}px`}this.write(`${n}%`)}write(e){Ci(this.el_,e)}updateVolume(e,t,i,n,r){this.requestNamedAnimationFrame("VolumeLevelTooltip#updateVolume",()=>{this.update(e,t,i,n.toFixed(0)),r&&r()})}}H.registerComponent("VolumeLevelTooltip",_v);class mh extends H{constructor(e,t){super(e,t),this.update=ti(we(this,this.update),kt)}createEl(){return super.createEl("div",{className:"vjs-mouse-display"})}update(e,t,i){const n=100*t;this.getChild("volumeLevelTooltip").updateVolume(e,t,i,n,()=>{i?this.el_.style.bottom=`${e.height*t}px`:this.el_.style.left=`${e.width*t}px`})}}mh.prototype.options_={children:["volumeLevelTooltip"]};H.registerComponent("MouseVolumeLevelDisplay",mh);class sa extends Jo{constructor(e,t){super(e,t),this.on("slideractive",i=>this.updateLastVolume_(i)),this.on(e,"volumechange",i=>this.updateARIAAttributes(i)),e.ready(()=>this.updateARIAAttributes())}createEl(){return super.createEl("div",{className:"vjs-volume-bar vjs-slider-bar"},{"aria-label":this.localize("Volume Level"),"aria-live":"polite"})}handleMouseDown(e){vn(e)&&super.handleMouseDown(e)}handleMouseMove(e){const t=this.getChild("mouseVolumeLevelDisplay");if(t){const i=this.el(),n=Ts(i),r=this.vertical();let a=Xr(i,e);a=r?a.y:a.x,a=Sn(a,0,1),t.update(n,a,r)}vn(e)&&(this.checkMuted(),this.player_.volume(this.calculateDistance(e)))}checkMuted(){this.player_.muted()&&this.player_.muted(!1)}getPercent(){return this.player_.muted()?0:this.player_.volume()}stepForward(){this.checkMuted(),this.player_.volume(this.player_.volume()+.1)}stepBack(){this.checkMuted(),this.player_.volume(this.player_.volume()-.1)}updateARIAAttributes(e){const t=this.player_.muted()?0:this.volumeAsPercentage_();this.el_.setAttribute("aria-valuenow",t),this.el_.setAttribute("aria-valuetext",t+"%")}volumeAsPercentage_(){return Math.round(this.player_.volume()*100)}updateLastVolume_(){const e=this.player_.volume();this.one("sliderinactive",()=>{this.player_.volume()===0&&this.player_.lastVolume_(e)})}}sa.prototype.options_={children:["volumeLevel"],barName:"volumeLevel"};!Ze&&!Ut&&sa.prototype.options_.children.splice(0,0,"mouseVolumeLevelDisplay");sa.prototype.playerEvent="volumechange";H.registerComponent("VolumeBar",sa);class gh extends H{constructor(e,t={}){t.vertical=t.vertical||!1,(typeof t.volumeBar>"u"||ys(t.volumeBar))&&(t.volumeBar=t.volumeBar||{},t.volumeBar.vertical=t.vertical),super(e,t),gv(this,e),this.throttledHandleMouseMove=ti(we(this,this.handleMouseMove),kt),this.handleMouseUpHandler_=i=>this.handleMouseUp(i),this.on("mousedown",i=>this.handleMouseDown(i)),this.on("touchstart",i=>this.handleMouseDown(i)),this.on("mousemove",i=>this.handleMouseMove(i)),this.on(this.volumeBar,["focus","slideractive"],()=>{this.volumeBar.addClass("vjs-slider-active"),this.addClass("vjs-slider-active"),this.trigger("slideractive")}),this.on(this.volumeBar,["blur","sliderinactive"],()=>{this.volumeBar.removeClass("vjs-slider-active"),this.removeClass("vjs-slider-active"),this.trigger("sliderinactive")})}createEl(){let e="vjs-volume-horizontal";return this.options_.vertical&&(e="vjs-volume-vertical"),super.createEl("div",{className:`vjs-volume-control vjs-control ${e}`})}handleMouseDown(e){const t=this.el_.ownerDocument;this.on(t,"mousemove",this.throttledHandleMouseMove),this.on(t,"touchmove",this.throttledHandleMouseMove),this.on(t,"mouseup",this.handleMouseUpHandler_),this.on(t,"touchend",this.handleMouseUpHandler_)}handleMouseUp(e){const t=this.el_.ownerDocument;this.off(t,"mousemove",this.throttledHandleMouseMove),this.off(t,"touchmove",this.throttledHandleMouseMove),this.off(t,"mouseup",this.handleMouseUpHandler_),this.off(t,"touchend",this.handleMouseUpHandler_)}handleMouseMove(e){this.volumeBar.handleMouseMove(e)}}gh.prototype.options_={children:["volumeBar"]};H.registerComponent("VolumeControl",gh);const Tv=function(s,e){e.tech_&&!e.tech_.featuresMuteControl&&s.addClass("vjs-hidden"),s.on(e,"loadstart",function(){e.tech_.featuresMuteControl?s.removeClass("vjs-hidden"):s.addClass("vjs-hidden")})};class yh extends tt{constructor(e,t){super(e,t),Tv(this,e),this.on(e,["loadstart","volumechange"],i=>this.update(i))}buildCSSClass(){return`vjs-mute-control ${super.buildCSSClass()}`}handleClick(e){const t=this.player_.volume(),i=this.player_.lastVolume_();if(t===0){const n=i<.1?.1:i;this.player_.volume(n),this.player_.muted(!1)}else this.player_.muted(!this.player_.muted())}update(e){this.updateIcon_(),this.updateControlText_()}updateIcon_(){const e=this.player_.volume();let t=3;this.setIcon("volume-high"),Ze&&this.player_.tech_&&this.player_.tech_.el_&&this.player_.muted(this.player_.tech_.el_.muted),e===0||this.player_.muted()?(this.setIcon("volume-mute"),t=0):e<.33?(this.setIcon("volume-low"),t=1):e<.67&&(this.setIcon("volume-medium"),t=2),Gr(this.el_,[0,1,2,3].reduce((i,n)=>i+`${n?" ":""}vjs-vol-${n}`,"")),Fi(this.el_,`vjs-vol-${t}`)}updateControlText_(){const t=this.player_.muted()||this.player_.volume()===0?"Unmute":"Mute";this.controlText()!==t&&this.controlText(t)}}yh.prototype.controlText_="Mute";H.registerComponent("MuteToggle",yh);class _h extends H{constructor(e,t={}){typeof t.inline<"u"?t.inline=t.inline:t.inline=!0,(typeof t.volumeControl>"u"||ys(t.volumeControl))&&(t.volumeControl=t.volumeControl||{},t.volumeControl.vertical=!t.inline),super(e,t),this.handleKeyPressHandler_=i=>this.handleKeyPress(i),this.on(e,["loadstart"],i=>this.volumePanelState_(i)),this.on(this.muteToggle,"keyup",i=>this.handleKeyPress(i)),this.on(this.volumeControl,"keyup",i=>this.handleVolumeControlKeyUp(i)),this.on("keydown",i=>this.handleKeyPress(i)),this.on("mouseover",i=>this.handleMouseOver(i)),this.on("mouseout",i=>this.handleMouseOut(i)),this.on(this.volumeControl,["slideractive"],this.sliderActive_),this.on(this.volumeControl,["sliderinactive"],this.sliderInactive_)}sliderActive_(){this.addClass("vjs-slider-active")}sliderInactive_(){this.removeClass("vjs-slider-active")}volumePanelState_(){this.volumeControl.hasClass("vjs-hidden")&&this.muteToggle.hasClass("vjs-hidden")&&this.addClass("vjs-hidden"),this.volumeControl.hasClass("vjs-hidden")&&!this.muteToggle.hasClass("vjs-hidden")&&this.addClass("vjs-mute-toggle-only")}createEl(){let e="vjs-volume-panel-horizontal";return this.options_.inline||(e="vjs-volume-panel-vertical"),super.createEl("div",{className:`vjs-volume-panel vjs-control ${e}`})}dispose(){this.handleMouseOut(),super.dispose()}handleVolumeControlKeyUp(e){e.key==="Escape"&&this.muteToggle.focus()}handleMouseOver(e){this.addClass("vjs-hover"),vt(K,"keyup",this.handleKeyPressHandler_)}handleMouseOut(e){this.removeClass("vjs-hover"),et(K,"keyup",this.handleKeyPressHandler_)}handleKeyPress(e){e.key==="Escape"&&this.handleMouseOut()}}_h.prototype.options_={children:["muteToggle","volumeControl"]};H.registerComponent("VolumePanel",_h);class Th extends tt{constructor(e,t){super(e,t),this.validOptions=[5,10,30],this.skipTime=this.getSkipForwardTime(),this.skipTime&&this.validOptions.includes(this.skipTime)?(this.setIcon(`forward-${this.skipTime}`),this.controlText(this.localize("Skip forward {1} seconds",[this.skipTime.toLocaleString(e.language())])),this.show()):this.hide()}getSkipForwardTime(){const e=this.options_.playerOptions;return e.controlBar&&e.controlBar.skipButtons&&e.controlBar.skipButtons.forward}buildCSSClass(){return`vjs-skip-forward-${this.getSkipForwardTime()} ${super.buildCSSClass()}`}handleClick(e){if(isNaN(this.player_.duration()))return;const t=this.player_.currentTime(),i=this.player_.liveTracker,n=i&&i.isLive()?i.seekableEnd():this.player_.duration();let r;t+this.skipTime<=n?r=t+this.skipTime:r=n,this.player_.currentTime(r)}handleLanguagechange(){this.controlText(this.localize("Skip forward {1} seconds",[this.skipTime]))}}Th.prototype.controlText_="Skip Forward";H.registerComponent("SkipForward",Th);class vh extends tt{constructor(e,t){super(e,t),this.validOptions=[5,10,30],this.skipTime=this.getSkipBackwardTime(),this.skipTime&&this.validOptions.includes(this.skipTime)?(this.setIcon(`replay-${this.skipTime}`),this.controlText(this.localize("Skip backward {1} seconds",[this.skipTime.toLocaleString(e.language())])),this.show()):this.hide()}getSkipBackwardTime(){const e=this.options_.playerOptions;return e.controlBar&&e.controlBar.skipButtons&&e.controlBar.skipButtons.backward}buildCSSClass(){return`vjs-skip-backward-${this.getSkipBackwardTime()} ${super.buildCSSClass()}`}handleClick(e){const t=this.player_.currentTime(),i=this.player_.liveTracker,n=i&&i.isLive()&&i.seekableStart();let r;n&&t-this.skipTime<=n?r=n:t>=this.skipTime?r=t-this.skipTime:r=0,this.player_.currentTime(r)}handleLanguagechange(){this.controlText(this.localize("Skip backward {1} seconds",[this.skipTime]))}}vh.prototype.controlText_="Skip Backward";H.registerComponent("SkipBackward",vh);class bh extends H{constructor(e,t){super(e,t),t&&(this.menuButton_=t.menuButton),this.focusedChild_=-1,this.on("keydown",i=>this.handleKeyDown(i)),this.boundHandleBlur_=i=>this.handleBlur(i),this.boundHandleTapClick_=i=>this.handleTapClick(i)}addEventListenerForItem(e){e instanceof H&&(this.on(e,"blur",this.boundHandleBlur_),this.on(e,["tap","click"],this.boundHandleTapClick_))}removeEventListenerForItem(e){e instanceof H&&(this.off(e,"blur",this.boundHandleBlur_),this.off(e,["tap","click"],this.boundHandleTapClick_))}removeChild(e){typeof e=="string"&&(e=this.getChild(e)),this.removeEventListenerForItem(e),super.removeChild(e)}addItem(e){const t=this.addChild(e);t&&this.addEventListenerForItem(t)}createEl(){const e=this.options_.contentElType||"ul";this.contentEl_=se(e,{className:"vjs-menu-content"}),this.contentEl_.setAttribute("role","menu");const t=super.createEl("div",{append:this.contentEl_,className:"vjs-menu"});return t.appendChild(this.contentEl_),vt(t,"click",function(i){i.preventDefault(),i.stopImmediatePropagation()}),t}dispose(){this.contentEl_=null,this.boundHandleBlur_=null,this.boundHandleTapClick_=null,super.dispose()}handleBlur(e){const t=e.relatedTarget||K.activeElement;if(!this.children().some(i=>i.el()===t)){const i=this.menuButton_;i&&i.buttonPressed_&&t!==i.el().firstChild&&i.unpressButton()}}handleTapClick(e){if(this.menuButton_){this.menuButton_.unpressButton();const t=this.children();if(!Array.isArray(t))return;const i=t.filter(n=>n.el()===e.target)[0];if(!i)return;i.name()!=="CaptionSettingsMenuItem"&&this.menuButton_.focus()}}handleKeyDown(e){e.key==="ArrowLeft"||e.key==="ArrowDown"?(e.preventDefault(),e.stopPropagation(),this.stepForward()):(e.key==="ArrowRight"||e.key==="ArrowUp")&&(e.preventDefault(),e.stopPropagation(),this.stepBack())}stepForward(){let e=0;this.focusedChild_!==void 0&&(e=this.focusedChild_+1),this.focus(e)}stepBack(){let e=0;this.focusedChild_!==void 0&&(e=this.focusedChild_-1),this.focus(e)}focus(e=0){const t=this.children().slice();t.length&&t[0].hasClass("vjs-menu-title")&&t.shift(),t.length>0&&(e<0?e=0:e>=t.length&&(e=t.length-1),this.focusedChild_=e,t[e].el_.focus())}}H.registerComponent("Menu",bh);class el extends H{constructor(e,t={}){super(e,t),this.menuButton_=new tt(e,t),this.menuButton_.controlText(this.controlText_),this.menuButton_.el_.setAttribute("aria-haspopup","true");const i=tt.prototype.buildCSSClass();this.menuButton_.el_.className=this.buildCSSClass()+" "+i,this.menuButton_.removeClass("vjs-control"),this.addChild(this.menuButton_),this.update(),this.enabled_=!0;const n=r=>this.handleClick(r);this.handleMenuKeyUp_=r=>this.handleMenuKeyUp(r),this.on(this.menuButton_,"tap",n),this.on(this.menuButton_,"click",n),this.on(this.menuButton_,"keydown",r=>this.handleKeyDown(r)),this.on(this.menuButton_,"mouseenter",()=>{this.addClass("vjs-hover"),this.menu.show(),vt(K,"keyup",this.handleMenuKeyUp_)}),this.on("mouseleave",r=>this.handleMouseLeave(r)),this.on("keydown",r=>this.handleSubmenuKeyDown(r))}update(){const e=this.createMenu();this.menu&&(this.menu.dispose(),this.removeChild(this.menu)),this.menu=e,this.addChild(e),this.buttonPressed_=!1,this.menuButton_.el_.setAttribute("aria-expanded","false"),this.items&&this.items.length<=this.hideThreshold_?(this.hide(),this.menu.contentEl_.removeAttribute("role")):(this.show(),this.menu.contentEl_.setAttribute("role","menu"))}createMenu(){const e=new bh(this.player_,{menuButton:this});if(this.hideThreshold_=0,this.options_.title){const t=se("li",{className:"vjs-menu-title",textContent:Be(this.options_.title),tabIndex:-1}),i=new H(this.player_,{el:t});e.addItem(i)}if(this.items=this.createItems(),this.items)for(let t=0;t<this.items.length;t++)e.addItem(this.items[t]);return e}createItems(){}createEl(){return super.createEl("div",{className:this.buildWrapperCSSClass()},{})}setIcon(e){super.setIcon(e,this.menuButton_.el_)}buildWrapperCSSClass(){let e="vjs-menu-button";this.options_.inline===!0?e+="-inline":e+="-popup";const t=tt.prototype.buildCSSClass();return`vjs-menu-button ${e} ${t} ${super.buildCSSClass()}`}buildCSSClass(){let e="vjs-menu-button";return this.options_.inline===!0?e+="-inline":e+="-popup",`vjs-menu-button ${e} ${super.buildCSSClass()}`}controlText(e,t=this.menuButton_.el()){return this.menuButton_.controlText(e,t)}dispose(){this.handleMouseLeave(),super.dispose()}handleClick(e){this.buttonPressed_?this.unpressButton():this.pressButton()}handleMouseLeave(e){this.removeClass("vjs-hover"),et(K,"keyup",this.handleMenuKeyUp_)}focus(){this.menuButton_.focus()}blur(){this.menuButton_.blur()}handleKeyDown(e){e.key==="Escape"||e.key==="Tab"?(this.buttonPressed_&&this.unpressButton(),!e.key==="Tab"&&(e.preventDefault(),this.menuButton_.focus())):(e.key==="Up"||e.key==="Down"&&!(this.player_.options_.playerOptions.spatialNavigation&&this.player_.options_.playerOptions.spatialNavigation.enabled))&&(this.buttonPressed_||(e.preventDefault(),this.pressButton()))}handleMenuKeyUp(e){(e.key==="Escape"||e.key==="Tab")&&this.removeClass("vjs-hover")}handleSubmenuKeyPress(e){this.handleSubmenuKeyDown(e)}handleSubmenuKeyDown(e){(e.key==="Escape"||e.key==="Tab")&&(this.buttonPressed_&&this.unpressButton(),!e.key==="Tab"&&(e.preventDefault(),this.menuButton_.focus()))}pressButton(){if(this.enabled_){if(this.buttonPressed_=!0,this.menu.show(),this.menu.lockShowing(),this.menuButton_.el_.setAttribute("aria-expanded","true"),Ze&&Ld())return;this.menu.focus()}}unpressButton(){this.enabled_&&(this.buttonPressed_=!1,this.menu.unlockShowing(),this.menu.hide(),this.menuButton_.el_.setAttribute("aria-expanded","false"))}disable(){this.unpressButton(),this.enabled_=!1,this.addClass("vjs-disabled"),this.menuButton_.disable()}enable(){this.enabled_=!0,this.removeClass("vjs-disabled"),this.menuButton_.enable()}}H.registerComponent("MenuButton",el);class tl extends el{constructor(e,t){const i=t.tracks;if(super(e,t),this.items.length<=1&&this.hide(),!i)return;const n=we(this,this.update);i.addEventListener("removetrack",n),i.addEventListener("addtrack",n),i.addEventListener("labelchange",n),this.player_.on("ready",n),this.player_.on("dispose",function(){i.removeEventListener("removetrack",n),i.removeEventListener("addtrack",n),i.removeEventListener("labelchange",n)})}}H.registerComponent("TrackButton",tl);class En extends ta{constructor(e,t){super(e,t),this.selectable=t.selectable,this.isSelected_=t.selected||!1,this.multiSelectable=t.multiSelectable,this.selected(this.isSelected_),this.selectable?this.multiSelectable?this.el_.setAttribute("role","menuitemcheckbox"):this.el_.setAttribute("role","menuitemradio"):this.el_.setAttribute("role","menuitem")}createEl(e,t,i){this.nonIconControl=!0;const n=super.createEl("li",Object.assign({className:"vjs-menu-item",tabIndex:-1},t),i),r=se("span",{className:"vjs-menu-item-text",textContent:this.localize(this.options_.label)});return this.player_.options_.experimentalSvgIcons?n.appendChild(r):n.replaceChild(r,n.querySelector(".vjs-icon-placeholder")),n}handleKeyDown(e){["Tab","Escape","ArrowUp","ArrowLeft","ArrowRight","ArrowDown"].includes(e.key)||super.handleKeyDown(e)}handleClick(e){this.selected(!0)}selected(e){this.selectable&&(e?(this.addClass("vjs-selected"),this.el_.setAttribute("aria-checked","true"),this.controlText(", selected"),this.isSelected_=!0):(this.removeClass("vjs-selected"),this.el_.setAttribute("aria-checked","false"),this.controlText(""),this.isSelected_=!1))}}H.registerComponent("MenuItem",En);class Cn extends En{constructor(e,t){const i=t.track,n=e.textTracks();t.label=i.label||i.language||"Unknown",t.selected=i.mode==="showing",super(e,t),this.track=i,this.kinds=(t.kinds||[t.kind||this.track.kind]).filter(Boolean);const r=(...l)=>{this.handleTracksChange.apply(this,l)},a=(...l)=>{this.handleSelectedLanguageChange.apply(this,l)};if(e.on(["loadstart","texttrackchange"],r),n.addEventListener("change",r),n.addEventListener("selectedlanguagechange",a),this.on("dispose",function(){e.off(["loadstart","texttrackchange"],r),n.removeEventListener("change",r),n.removeEventListener("selectedlanguagechange",a)}),n.onchange===void 0){let l;this.on(["tap","click"],function(){if(typeof k.Event!="object")try{l=new k.Event("change")}catch{}l||(l=K.createEvent("Event"),l.initEvent("change",!0,!0)),n.dispatchEvent(l)})}this.handleTracksChange()}handleClick(e){const t=this.track,i=this.player_.textTracks();if(super.handleClick(e),!!i)for(let n=0;n<i.length;n++){const r=i[n];this.kinds.indexOf(r.kind)!==-1&&(r===t?r.mode!=="showing"&&(r.mode="showing"):r.mode!=="disabled"&&(r.mode="disabled"))}}handleTracksChange(e){const t=this.track.mode==="showing";t!==this.isSelected_&&this.selected(t)}handleSelectedLanguageChange(e){if(this.track.mode==="showing"){const t=this.player_.cache_.selectedLanguage;if(t&&t.enabled&&t.language===this.track.language&&t.kind!==this.track.kind)return;this.player_.cache_.selectedLanguage={enabled:!0,language:this.track.language,kind:this.track.kind}}}dispose(){this.track=null,super.dispose()}}H.registerComponent("TextTrackMenuItem",Cn);class xh extends Cn{constructor(e,t){t.track={player:e,kind:t.kind,kinds:t.kinds,default:!1,mode:"disabled"},t.kinds||(t.kinds=[t.kind]),t.label?t.track.label=t.label:t.track.label=t.kinds.join(" and ")+" off",t.selectable=!0,t.multiSelectable=!1,super(e,t)}handleTracksChange(e){const t=this.player().textTracks();let i=!0;for(let n=0,r=t.length;n<r;n++){const a=t[n];if(this.options_.kinds.indexOf(a.kind)>-1&&a.mode==="showing"){i=!1;break}}i!==this.isSelected_&&this.selected(i)}handleSelectedLanguageChange(e){const t=this.player().textTracks();let i=!0;for(let n=0,r=t.length;n<r;n++){const a=t[n];if(["captions","descriptions","subtitles"].indexOf(a.kind)>-1&&a.mode==="showing"){i=!1;break}}i&&(this.player_.cache_.selectedLanguage={enabled:!1})}handleLanguagechange(){this.$(".vjs-menu-item-text").textContent=this.player_.localize(this.options_.label),super.handleLanguagechange()}}H.registerComponent("OffTextTrackMenuItem",xh);class ks extends tl{constructor(e,t={}){t.tracks=e.textTracks(),super(e,t)}createItems(e=[],t=Cn){let i;this.label_&&(i=`${this.label_} off`),e.push(new xh(this.player_,{kinds:this.kinds_,kind:this.kind_,label:i})),this.hideThreshold_+=1;const n=this.player_.textTracks();Array.isArray(this.kinds_)||(this.kinds_=[this.kind_]);for(let r=0;r<n.length;r++){const a=n[r];if(this.kinds_.indexOf(a.kind)>-1){const l=new t(this.player_,{track:a,kinds:this.kinds_,kind:this.kind_,selectable:!0,multiSelectable:!1});l.addClass(`vjs-${a.kind}-menu-item`),e.push(l)}}return e}}H.registerComponent("TextTrackButton",ks);class Sh extends En{constructor(e,t){const i=t.track,n=t.cue,r=e.currentTime();t.selectable=!0,t.multiSelectable=!1,t.label=n.text,t.selected=n.startTime<=r&&r<n.endTime,super(e,t),this.track=i,this.cue=n}handleClick(e){super.handleClick(),this.player_.currentTime(this.cue.startTime)}}H.registerComponent("ChaptersTrackMenuItem",Sh);class il extends ks{constructor(e,t,i){super(e,t,i),this.setIcon("chapters"),this.selectCurrentItem_=()=>{this.items.forEach(n=>{n.selected(this.track_.activeCues[0]===n.cue)})}}buildCSSClass(){return`vjs-chapters-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-chapters-button ${super.buildWrapperCSSClass()}`}update(e){if(e&&e.track&&e.track.kind!=="chapters")return;const t=this.findChaptersTrack();t!==this.track_?(this.setTrack(t),super.update()):(!this.items||t&&t.cues&&t.cues.length!==this.items.length)&&super.update()}setTrack(e){if(this.track_!==e){if(this.updateHandler_||(this.updateHandler_=this.update.bind(this)),this.track_){const t=this.player_.remoteTextTrackEls().getTrackElementByTrack_(this.track_);t&&t.removeEventListener("load",this.updateHandler_),this.track_.removeEventListener("cuechange",this.selectCurrentItem_),this.track_=null}if(this.track_=e,this.track_){this.track_.mode="hidden";const t=this.player_.remoteTextTrackEls().getTrackElementByTrack_(this.track_);t&&t.addEventListener("load",this.updateHandler_),this.track_.addEventListener("cuechange",this.selectCurrentItem_)}}}findChaptersTrack(){const e=this.player_.textTracks()||[];for(let t=e.length-1;t>=0;t--){const i=e[t];if(i.kind===this.kind_)return i}}getMenuCaption(){return this.track_&&this.track_.label?this.track_.label:this.localize(Be(this.kind_))}createMenu(){return this.options_.title=this.getMenuCaption(),super.createMenu()}createItems(){const e=[];if(!this.track_)return e;const t=this.track_.cues;if(!t)return e;for(let i=0,n=t.length;i<n;i++){const r=t[i],a=new Sh(this.player_,{track:this.track_,cue:r});e.push(a)}return e}}il.prototype.kind_="chapters";il.prototype.controlText_="Chapters";H.registerComponent("ChaptersButton",il);class sl extends ks{constructor(e,t,i){super(e,t,i),this.setIcon("audio-description");const n=e.textTracks(),r=we(this,this.handleTracksChange);n.addEventListener("change",r),this.on("dispose",function(){n.removeEventListener("change",r)})}handleTracksChange(e){const t=this.player().textTracks();let i=!1;for(let n=0,r=t.length;n<r;n++){const a=t[n];if(a.kind!==this.kind_&&a.mode==="showing"){i=!0;break}}i?this.disable():this.enable()}buildCSSClass(){return`vjs-descriptions-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-descriptions-button ${super.buildWrapperCSSClass()}`}}sl.prototype.kind_="descriptions";sl.prototype.controlText_="Descriptions";H.registerComponent("DescriptionsButton",sl);class nl extends ks{constructor(e,t,i){super(e,t,i),this.setIcon("subtitles")}buildCSSClass(){return`vjs-subtitles-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-subtitles-button ${super.buildWrapperCSSClass()}`}}nl.prototype.kind_="subtitles";nl.prototype.controlText_="Subtitles";H.registerComponent("SubtitlesButton",nl);class rl extends Cn{constructor(e,t){t.track={player:e,kind:t.kind,label:t.kind+" settings",selectable:!1,default:!1,mode:"disabled"},t.selectable=!1,t.name="CaptionSettingsMenuItem",super(e,t),this.addClass("vjs-texttrack-settings"),this.controlText(", opens "+t.kind+" settings dialog")}handleClick(e){this.player().getChild("textTrackSettings").open()}handleLanguagechange(){this.$(".vjs-menu-item-text").textContent=this.player_.localize(this.options_.kind+" settings"),super.handleLanguagechange()}}H.registerComponent("CaptionSettingsMenuItem",rl);class al extends ks{constructor(e,t,i){super(e,t,i),this.setIcon("captions")}buildCSSClass(){return`vjs-captions-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-captions-button ${super.buildWrapperCSSClass()}`}createItems(){const e=[];return!(this.player().tech_&&this.player().tech_.featuresNativeTextTracks)&&this.player().getChild("textTrackSettings")&&(e.push(new rl(this.player_,{kind:this.kind_})),this.hideThreshold_+=1),super.createItems(e)}}al.prototype.kind_="captions";al.prototype.controlText_="Captions";H.registerComponent("CaptionsButton",al);class Eh extends Cn{createEl(e,t,i){const n=super.createEl(e,t,i),r=n.querySelector(".vjs-menu-item-text");return this.options_.track.kind==="captions"&&(this.player_.options_.experimentalSvgIcons?this.setIcon("captions",n):r.appendChild(se("span",{className:"vjs-icon-placeholder"},{"aria-hidden":!0})),r.appendChild(se("span",{className:"vjs-control-text",textContent:` ${this.localize("Captions")}`}))),n}}H.registerComponent("SubsCapsMenuItem",Eh);class ol extends ks{constructor(e,t={}){super(e,t),this.label_="subtitles",this.setIcon("subtitles"),["en","en-us","en-ca","fr-ca"].indexOf(this.player_.language_)>-1&&(this.label_="captions",this.setIcon("captions")),this.menuButton_.controlText(Be(this.label_))}buildCSSClass(){return`vjs-subs-caps-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-subs-caps-button ${super.buildWrapperCSSClass()}`}createItems(){let e=[];return!(this.player().tech_&&this.player().tech_.featuresNativeTextTracks)&&this.player().getChild("textTrackSettings")&&(e.push(new rl(this.player_,{kind:this.label_})),this.hideThreshold_+=1),e=super.createItems(e,Eh),e}}ol.prototype.kinds_=["captions","subtitles"];ol.prototype.controlText_="Subtitles";H.registerComponent("SubsCapsButton",ol);class Ch extends En{constructor(e,t){const i=t.track,n=e.audioTracks();t.label=i.label||i.language||"Unknown",t.selected=i.enabled,super(e,t),this.track=i,this.addClass(`vjs-${i.kind}-menu-item`);const r=(...a)=>{this.handleTracksChange.apply(this,a)};n.addEventListener("change",r),this.on("dispose",()=>{n.removeEventListener("change",r)})}createEl(e,t,i){const n=super.createEl(e,t,i),r=n.querySelector(".vjs-menu-item-text");return["main-desc","descriptions"].indexOf(this.options_.track.kind)>=0&&(r.appendChild(se("span",{className:"vjs-icon-placeholder"},{"aria-hidden":!0})),r.appendChild(se("span",{className:"vjs-control-text",textContent:" "+this.localize("Descriptions")}))),n}handleClick(e){if(super.handleClick(e),this.track.enabled=!0,this.player_.tech_.featuresNativeAudioTracks){const t=this.player_.audioTracks();for(let i=0;i<t.length;i++){const n=t[i];n!==this.track&&(n.enabled=n===this.track)}}}handleTracksChange(e){this.selected(this.track.enabled)}}H.registerComponent("AudioTrackMenuItem",Ch);class wh extends tl{constructor(e,t={}){t.tracks=e.audioTracks(),super(e,t),this.setIcon("audio")}buildCSSClass(){return`vjs-audio-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-audio-button ${super.buildWrapperCSSClass()}`}createItems(e=[]){this.hideThreshold_=1;const t=this.player_.audioTracks();for(let i=0;i<t.length;i++){const n=t[i];e.push(new Ch(this.player_,{track:n,selectable:!0,multiSelectable:!1}))}return e}}wh.prototype.controlText_="Audio Track";H.registerComponent("AudioTrackButton",wh);class ll extends En{constructor(e,t){const i=t.rate,n=parseFloat(i,10);t.label=i,t.selected=n===e.playbackRate(),t.selectable=!0,t.multiSelectable=!1,super(e,t),this.label=i,this.rate=n,this.on(e,"ratechange",r=>this.update(r))}handleClick(e){super.handleClick(),this.player().playbackRate(this.rate)}update(e){this.selected(this.player().playbackRate()===this.rate)}}ll.prototype.contentElType="button";H.registerComponent("PlaybackRateMenuItem",ll);class Ih extends el{constructor(e,t){super(e,t),this.menuButton_.el_.setAttribute("aria-describedby",this.labelElId_),this.updateVisibility(),this.updateLabel(),this.on(e,"loadstart",i=>this.updateVisibility(i)),this.on(e,"ratechange",i=>this.updateLabel(i)),this.on(e,"playbackrateschange",i=>this.handlePlaybackRateschange(i))}createEl(){const e=super.createEl();return this.labelElId_="vjs-playback-rate-value-label-"+this.id_,this.labelEl_=se("div",{className:"vjs-playback-rate-value",id:this.labelElId_,textContent:"1x"}),e.appendChild(this.labelEl_),e}dispose(){this.labelEl_=null,super.dispose()}buildCSSClass(){return`vjs-playback-rate ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-playback-rate ${super.buildWrapperCSSClass()}`}createItems(){const e=this.playbackRates(),t=[];for(let i=e.length-1;i>=0;i--)t.push(new ll(this.player(),{rate:e[i]+"x"}));return t}handlePlaybackRateschange(e){this.update()}playbackRates(){const e=this.player();return e.playbackRates&&e.playbackRates()||[]}playbackRateSupported(){return this.player().tech_&&this.player().tech_.featuresPlaybackRate&&this.playbackRates()&&this.playbackRates().length>0}updateVisibility(e){this.playbackRateSupported()?this.removeClass("vjs-hidden"):this.addClass("vjs-hidden")}updateLabel(e){this.playbackRateSupported()&&(this.labelEl_.textContent=this.player().playbackRate()+"x")}}Ih.prototype.controlText_="Playback Rate";H.registerComponent("PlaybackRateMenuButton",Ih);class Ah extends H{buildCSSClass(){return`vjs-spacer ${super.buildCSSClass()}`}createEl(e="div",t={},i={}){return t.className||(t.className=this.buildCSSClass()),super.createEl(e,t,i)}}H.registerComponent("Spacer",Ah);class vv extends Ah{buildCSSClass(){return`vjs-custom-control-spacer ${super.buildCSSClass()}`}createEl(){return super.createEl("div",{className:this.buildCSSClass(),textContent:" "})}}H.registerComponent("CustomControlSpacer",vv);class kh extends H{createEl(){return super.createEl("div",{className:"vjs-control-bar",dir:"ltr"})}}kh.prototype.options_={children:["playToggle","skipBackward","skipForward","volumePanel","currentTimeDisplay","timeDivider","durationDisplay","progressControl","liveDisplay","seekToLive","remainingTimeDisplay","customControlSpacer","playbackRateMenuButton","chaptersButton","descriptionsButton","subsCapsButton","audioTrackButton","pictureInPictureToggle","fullscreenToggle"]};H.registerComponent("ControlBar",kh);class Ph extends Is{constructor(e,t){super(e,t),this.on(e,"error",i=>{this.open(i)})}buildCSSClass(){return`vjs-error-display ${super.buildCSSClass()}`}content(){const e=this.player().error();return e?this.localize(e.message):""}}Ph.prototype.options_=Object.assign({},Is.prototype.options_,{pauseOnOpen:!1,fillAlways:!0,temporary:!1,uncloseable:!0});H.registerComponent("ErrorDisplay",Ph);class Dh extends H{constructor(e,t={}){super(e,t),this.el_.setAttribute("aria-labelledby",this.selectLabelledbyIds)}createEl(){return this.selectLabelledbyIds=[this.options_.legendId,this.options_.labelId].join(" ").trim(),se("select",{id:this.options_.id},{},this.options_.SelectOptions.map(t=>{const i=(this.options_.labelId?this.options_.labelId:`vjs-track-option-${At()}`)+"-"+t[1].replace(/\W+/g,""),n=se("option",{id:i,value:this.localize(t[0]),textContent:this.localize(t[1])});return n.setAttribute("aria-labelledby",`${this.selectLabelledbyIds} ${i}`),n}))}}H.registerComponent("TextTrackSelect",Dh);class ji extends H{constructor(e,t={}){super(e,t);const i=se("legend",{textContent:this.localize(this.options_.legendText),id:this.options_.legendId});this.el().appendChild(i);const n=this.options_.selects;for(const r of n){const a=this.options_.selectConfigs[r],l=a.className,h=a.id.replace("%s",this.options_.id_);let f=null;const m=`vjs_select_${At()}`;if(this.options_.type==="colors"){f=se("span",{className:l});const E=se("label",{id:h,className:"vjs-label",textContent:this.localize(a.label)});E.setAttribute("for",m),f.appendChild(E)}const T=new Dh(e,{SelectOptions:a.options,legendId:this.options_.legendId,id:m,labelId:h});this.addChild(T),this.options_.type==="colors"&&(f.appendChild(T.el()),this.el().appendChild(f))}}createEl(){return se("fieldset",{className:this.options_.className})}}H.registerComponent("TextTrackFieldset",ji);class Lh extends H{constructor(e,t={}){super(e,t);const i=this.options_.textTrackComponentid,n=new ji(e,{id_:i,legendId:`captions-text-legend-${i}`,legendText:this.localize("Text"),className:"vjs-fg vjs-track-setting",selects:this.options_.fieldSets[0],selectConfigs:this.options_.selectConfigs,type:"colors"});this.addChild(n);const r=new ji(e,{id_:i,legendId:`captions-background-${i}`,legendText:this.localize("Text Background"),className:"vjs-bg vjs-track-setting",selects:this.options_.fieldSets[1],selectConfigs:this.options_.selectConfigs,type:"colors"});this.addChild(r);const a=new ji(e,{id_:i,legendId:`captions-window-${i}`,legendText:this.localize("Caption Area Background"),className:"vjs-window vjs-track-setting",selects:this.options_.fieldSets[2],selectConfigs:this.options_.selectConfigs,type:"colors"});this.addChild(a)}createEl(){return se("div",{className:"vjs-track-settings-colors"})}}H.registerComponent("TextTrackSettingsColors",Lh);class Oh extends H{constructor(e,t={}){super(e,t);const i=this.options_.textTrackComponentid,n=new ji(e,{id_:i,legendId:`captions-font-size-${i}`,legendText:"Font Size",className:"vjs-font-percent vjs-track-setting",selects:this.options_.fieldSets[0],selectConfigs:this.options_.selectConfigs,type:"font"});this.addChild(n);const r=new ji(e,{id_:i,legendId:`captions-edge-style-${i}`,legendText:this.localize("Text Edge Style"),className:"vjs-edge-style vjs-track-setting",selects:this.options_.fieldSets[1],selectConfigs:this.options_.selectConfigs,type:"font"});this.addChild(r);const a=new ji(e,{id_:i,legendId:`captions-font-family-${i}`,legendText:this.localize("Font Family"),className:"vjs-font-family vjs-track-setting",selects:this.options_.fieldSets[2],selectConfigs:this.options_.selectConfigs,type:"font"});this.addChild(a)}createEl(){return se("div",{className:"vjs-track-settings-font"})}}H.registerComponent("TextTrackSettingsFont",Oh);class Rh extends H{constructor(e,t={}){super(e,t);const i=this.localize("restore all settings to the default values"),n=new tt(e,{controlText:i,className:"vjs-default-button"});n.el().classList.remove("vjs-control","vjs-button"),n.el().textContent=this.localize("Reset"),this.addChild(n);const r=new tt(e,{controlText:i,className:"vjs-done-button"});r.el().classList.remove("vjs-control","vjs-button"),r.el().textContent=this.localize("Done"),this.addChild(r)}createEl(){return se("div",{className:"vjs-track-settings-controls"})}}H.registerComponent("TrackSettingsControls",Rh);const ja="vjs-text-track-settings",Xu=["#000","Black"],Yu=["#00F","Blue"],Qu=["#0FF","Cyan"],Ju=["#0F0","Green"],Zu=["#F0F","Magenta"],ec=["#F00","Red"],tc=["#FFF","White"],ic=["#FF0","Yellow"],Va=["1","Opaque"],Ha=["0.5","Semi-Transparent"],sc=["0","Transparent"],xi={backgroundColor:{selector:".vjs-bg-color > select",id:"captions-background-color-%s",label:"Color",options:[Xu,tc,ec,Ju,Yu,ic,Zu,Qu],className:"vjs-bg-color"},backgroundOpacity:{selector:".vjs-bg-opacity > select",id:"captions-background-opacity-%s",label:"Opacity",options:[Va,Ha,sc],className:"vjs-bg-opacity vjs-opacity"},color:{selector:".vjs-text-color > select",id:"captions-foreground-color-%s",label:"Color",options:[tc,Xu,ec,Ju,Yu,ic,Zu,Qu],className:"vjs-text-color"},edgeStyle:{selector:".vjs-edge-style > select",id:"",label:"Text Edge Style",options:[["none","None"],["raised","Raised"],["depressed","Depressed"],["uniform","Uniform"],["dropshadow","Drop shadow"]]},fontFamily:{selector:".vjs-font-family > select",id:"",label:"Font Family",options:[["proportionalSansSerif","Proportional Sans-Serif"],["monospaceSansSerif","Monospace Sans-Serif"],["proportionalSerif","Proportional Serif"],["monospaceSerif","Monospace Serif"],["casual","Casual"],["script","Script"],["small-caps","Small Caps"]]},fontPercent:{selector:".vjs-font-percent > select",id:"",label:"Font Size",options:[["0.50","50%"],["0.75","75%"],["1.00","100%"],["1.25","125%"],["1.50","150%"],["1.75","175%"],["2.00","200%"],["3.00","300%"],["4.00","400%"]],default:2,parser:s=>s==="1.00"?null:Number(s)},textOpacity:{selector:".vjs-text-opacity > select",id:"captions-foreground-opacity-%s",label:"Opacity",options:[Va,Ha],className:"vjs-text-opacity vjs-opacity"},windowColor:{selector:".vjs-window-color > select",id:"captions-window-color-%s",label:"Color",className:"vjs-window-color"},windowOpacity:{selector:".vjs-window-opacity > select",id:"captions-window-opacity-%s",label:"Opacity",options:[sc,Ha,Va],className:"vjs-window-opacity vjs-opacity"}};xi.windowColor.options=xi.backgroundColor.options;function Mh(s,e){if(e&&(s=e(s)),s&&s!=="none")return s}function bv(s,e){const t=s.options[s.options.selectedIndex].value;return Mh(t,e)}function xv(s,e,t){if(e){for(let i=0;i<s.options.length;i++)if(Mh(s.options[i].value,t)===e){s.selectedIndex=i;break}}}class Sv extends Is{constructor(e,t){t.temporary=!1,super(e,t),this.updateDisplay=this.updateDisplay.bind(this),this.fill(),this.hasBeenOpened_=this.hasBeenFilled_=!0,this.renderModalComponents(e),this.endDialog=se("p",{className:"vjs-control-text",textContent:this.localize("End of dialog window.")}),this.el().appendChild(this.endDialog),this.setDefaults(),t.persistTextTrackSettings===void 0&&(this.options_.persistTextTrackSettings=this.options_.playerOptions.persistTextTrackSettings),this.bindFunctionsToSelectsAndButtons(),this.options_.persistTextTrackSettings&&this.restoreSettings()}renderModalComponents(e){const t=new Lh(e,{textTrackComponentid:this.id_,selectConfigs:xi,fieldSets:[["color","textOpacity"],["backgroundColor","backgroundOpacity"],["windowColor","windowOpacity"]]});this.addChild(t);const i=new Oh(e,{textTrackComponentid:this.id_,selectConfigs:xi,fieldSets:[["fontPercent"],["edgeStyle"],["fontFamily"]]});this.addChild(i);const n=new Rh(e);this.addChild(n)}bindFunctionsToSelectsAndButtons(){this.on(this.$(".vjs-done-button"),["click","tap"],()=>{this.saveSettings(),this.close()}),this.on(this.$(".vjs-default-button"),["click","tap"],()=>{this.setDefaults(),this.updateDisplay()}),rs(xi,e=>{this.on(this.$(e.selector),"change",this.updateDisplay)})}dispose(){this.endDialog=null,super.dispose()}label(){return this.localize("Caption Settings Dialog")}description(){return this.localize("Beginning of dialog window. Escape will cancel and close the window.")}buildCSSClass(){return super.buildCSSClass()+" vjs-text-track-settings"}getValues(){return Cd(xi,(e,t,i)=>{const n=bv(this.$(t.selector),t.parser);return n!==void 0&&(e[i]=n),e},{})}setValues(e){rs(xi,(t,i)=>{xv(this.$(t.selector),e[i],t.parser)})}setDefaults(){rs(xi,e=>{const t=e.hasOwnProperty("default")?e.default:0;this.$(e.selector).selectedIndex=t})}restoreSettings(){let e;try{e=JSON.parse(k.localStorage.getItem(ja))}catch(t){ue.warn(t)}e&&this.setValues(e)}saveSettings(){if(!this.options_.persistTextTrackSettings)return;const e=this.getValues();try{Object.keys(e).length?k.localStorage.setItem(ja,JSON.stringify(e)):k.localStorage.removeItem(ja)}catch(t){ue.warn(t)}}updateDisplay(){const e=this.player_.getChild("textTrackDisplay");e&&e.updateDisplay()}handleLanguagechange(){this.fill(),this.renderModalComponents(this.player_),this.bindFunctionsToSelectsAndButtons()}}H.registerComponent("TextTrackSettings",Sv);class Ev extends H{constructor(e,t){let i=t.ResizeObserver||k.ResizeObserver;t.ResizeObserver===null&&(i=!1);const n=xe({createEl:!i,reportTouchActivity:!1},t);super(e,n),this.ResizeObserver=t.ResizeObserver||k.ResizeObserver,this.loadListener_=null,this.resizeObserver_=null,this.debouncedHandler_=Kd(()=>{this.resizeHandler()},100,!1,this),i?(this.resizeObserver_=new this.ResizeObserver(this.debouncedHandler_),this.resizeObserver_.observe(e.el())):(this.loadListener_=()=>{if(!this.el_||!this.el_.contentWindow)return;const r=this.debouncedHandler_;let a=this.unloadListener_=function(){et(this,"resize",r),et(this,"unload",a),a=null};vt(this.el_.contentWindow,"unload",a),vt(this.el_.contentWindow,"resize",r)},this.one("load",this.loadListener_))}createEl(){return super.createEl("iframe",{className:"vjs-resize-manager",tabIndex:-1,title:this.localize("No content")},{"aria-hidden":"true"})}resizeHandler(){!this.player_||!this.player_.trigger||this.player_.trigger("playerresize")}dispose(){this.debouncedHandler_&&this.debouncedHandler_.cancel(),this.resizeObserver_&&(this.player_.el()&&this.resizeObserver_.unobserve(this.player_.el()),this.resizeObserver_.disconnect()),this.loadListener_&&this.off("load",this.loadListener_),this.el_&&this.el_.contentWindow&&this.unloadListener_&&this.unloadListener_.call(this.el_.contentWindow),this.ResizeObserver=null,this.resizeObserver=null,this.debouncedHandler_=null,this.loadListener_=null,super.dispose()}}H.registerComponent("ResizeManager",Ev);const Cv={trackingThreshold:20,liveTolerance:15};class wv extends H{constructor(e,t){const i=xe(Cv,t,{createEl:!1});super(e,i),this.trackLiveHandler_=()=>this.trackLive_(),this.handlePlay_=n=>this.handlePlay(n),this.handleFirstTimeupdate_=n=>this.handleFirstTimeupdate(n),this.handleSeeked_=n=>this.handleSeeked(n),this.seekToLiveEdge_=n=>this.seekToLiveEdge(n),this.reset_(),this.on(this.player_,"durationchange",n=>this.handleDurationchange(n)),this.on(this.player_,"canplay",()=>this.toggleTracking())}trackLive_(){const e=this.player_.seekable();if(!e||!e.length)return;const t=Number(k.performance.now().toFixed(4)),i=this.lastTime_===-1?0:(t-this.lastTime_)/1e3;this.lastTime_=t,this.pastSeekEnd_=this.pastSeekEnd()+i;const n=this.liveCurrentTime(),r=this.player_.currentTime();let a=this.player_.paused()||this.seekedBehindLive_||Math.abs(n-r)>this.options_.liveTolerance;(!this.timeupdateSeen_||n===1/0)&&(a=!1),a!==this.behindLiveEdge_&&(this.behindLiveEdge_=a,this.trigger("liveedgechange"))}handleDurationchange(){this.toggleTracking()}toggleTracking(){this.player_.duration()===1/0&&this.liveWindow()>=this.options_.trackingThreshold?(this.player_.options_.liveui&&this.player_.addClass("vjs-liveui"),this.startTracking()):(this.player_.removeClass("vjs-liveui"),this.stopTracking())}startTracking(){this.isTracking()||(this.timeupdateSeen_||(this.timeupdateSeen_=this.player_.hasStarted()),this.trackingInterval_=this.setInterval(this.trackLiveHandler_,kt),this.trackLive_(),this.on(this.player_,["play","pause"],this.trackLiveHandler_),this.timeupdateSeen_?this.on(this.player_,"seeked",this.handleSeeked_):(this.one(this.player_,"play",this.handlePlay_),this.one(this.player_,"timeupdate",this.handleFirstTimeupdate_)))}handleFirstTimeupdate(){this.timeupdateSeen_=!0,this.on(this.player_,"seeked",this.handleSeeked_)}handleSeeked(){const e=Math.abs(this.liveCurrentTime()-this.player_.currentTime());this.seekedBehindLive_=this.nextSeekedFromUser_&&e>2,this.nextSeekedFromUser_=!1,this.trackLive_()}handlePlay(){this.one(this.player_,"timeupdate",this.seekToLiveEdge_)}reset_(){this.lastTime_=-1,this.pastSeekEnd_=0,this.lastSeekEnd_=-1,this.behindLiveEdge_=!0,this.timeupdateSeen_=!1,this.seekedBehindLive_=!1,this.nextSeekedFromUser_=!1,this.clearInterval(this.trackingInterval_),this.trackingInterval_=null,this.off(this.player_,["play","pause"],this.trackLiveHandler_),this.off(this.player_,"seeked",this.handleSeeked_),this.off(this.player_,"play",this.handlePlay_),this.off(this.player_,"timeupdate",this.handleFirstTimeupdate_),this.off(this.player_,"timeupdate",this.seekToLiveEdge_)}nextSeekedFromUser(){this.nextSeekedFromUser_=!0}stopTracking(){this.isTracking()&&(this.reset_(),this.trigger("liveedgechange"))}seekableEnd(){const e=this.player_.seekable(),t=[];let i=e?e.length:0;for(;i--;)t.push(e.end(i));return t.length?t.sort()[t.length-1]:1/0}seekableStart(){const e=this.player_.seekable(),t=[];let i=e?e.length:0;for(;i--;)t.push(e.start(i));return t.length?t.sort()[0]:0}liveWindow(){const e=this.liveCurrentTime();return e===1/0?0:e-this.seekableStart()}isLive(){return this.isTracking()}atLiveEdge(){return!this.behindLiveEdge()}liveCurrentTime(){return this.pastSeekEnd()+this.seekableEnd()}pastSeekEnd(){const e=this.seekableEnd();return this.lastSeekEnd_!==-1&&e!==this.lastSeekEnd_&&(this.pastSeekEnd_=0),this.lastSeekEnd_=e,this.pastSeekEnd_}behindLiveEdge(){return this.behindLiveEdge_}isTracking(){return typeof this.trackingInterval_=="number"}seekToLiveEdge(){this.seekedBehindLive_=!1,!this.atLiveEdge()&&(this.nextSeekedFromUser_=!1,this.player_.currentTime(this.liveCurrentTime()))}dispose(){this.stopTracking(),super.dispose()}}H.registerComponent("LiveTracker",wv);class Iv extends H{constructor(e,t){super(e,t),this.on("statechanged",i=>this.updateDom_()),this.updateDom_()}createEl(){return this.els={title:se("div",{className:"vjs-title-bar-title",id:`vjs-title-bar-title-${At()}`}),description:se("div",{className:"vjs-title-bar-description",id:`vjs-title-bar-description-${At()}`})},se("div",{className:"vjs-title-bar"},{},wd(this.els))}updateDom_(){const e=this.player_.tech_,t=e&&e.el_,i={title:"aria-labelledby",description:"aria-describedby"};["title","description"].forEach(n=>{const r=this.state[n],a=this.els[n],l=i[n];Yr(a),r&&Ci(a,r),t&&(t.removeAttribute(l),r&&t.setAttribute(l,a.id))}),this.state.title||this.state.description?this.show():this.hide()}update(e){this.setState(e)}dispose(){const e=this.player_.tech_,t=e&&e.el_;t&&(t.removeAttribute("aria-labelledby"),t.removeAttribute("aria-describedby")),super.dispose(),this.els=null}}H.registerComponent("TitleBar",Iv);const Av={initialDisplay:4e3,position:[],takeFocus:!1};class kv extends tt{constructor(e,t){t=xe(Av,t),super(e,t),this.controlText(t.controlText),this.hide(),this.on(this.player_,["useractive","userinactive"],i=>{this.removeClass("force-display")})}buildCSSClass(){return`vjs-transient-button focus-visible ${this.options_.position.map(e=>`vjs-${e}`).join(" ")}`}createEl(){const e=se("button",{},{type:"button",class:this.buildCSSClass()},se("span"));return this.controlTextEl_=e.querySelector("span"),e}show(){super.show(),this.addClass("force-display"),this.options_.takeFocus&&this.el().focus({preventScroll:!0}),this.forceDisplayTimeout=this.player_.setTimeout(()=>{this.removeClass("force-display")},this.options_.initialDisplay)}hide(){this.removeClass("force-display"),super.hide()}dispose(){this.player_.clearTimeout(this.forceDisplayTimeout),super.dispose()}}H.registerComponent("TransientButton",kv);const oo=s=>{const e=s.el();if(e.hasAttribute("src"))return s.triggerSourceset(e.src),!0;const t=s.$$("source"),i=[];let n="";if(!t.length)return!1;for(let r=0;r<t.length;r++){const a=t[r].src;a&&i.indexOf(a)===-1&&i.push(a)}return i.length?(i.length===1&&(n=i[0]),s.triggerSourceset(n),!0):!1},Pv=Object.defineProperty({},"innerHTML",{get(){return this.cloneNode(!0).innerHTML},set(s){const e=K.createElement(this.nodeName.toLowerCase());e.innerHTML=s;const t=K.createDocumentFragment();for(;e.childNodes.length;)t.appendChild(e.childNodes[0]);return this.innerText="",k.Element.prototype.appendChild.call(this,t),this.innerHTML}}),Nh=(s,e)=>{let t={};for(let i=0;i<s.length&&(t=Object.getOwnPropertyDescriptor(s[i],e),!(t&&t.set&&t.get));i++);return t.enumerable=!0,t.configurable=!0,t},Dv=s=>Nh([s.el(),k.HTMLMediaElement.prototype,k.Element.prototype,Pv],"innerHTML"),nc=function(s){const e=s.el();if(e.resetSourceWatch_)return;const t={},i=Dv(s),n=r=>(...a)=>{const l=r.apply(e,a);return oo(s),l};["append","appendChild","insertAdjacentHTML"].forEach(r=>{e[r]&&(t[r]=e[r],e[r]=n(t[r]))}),Object.defineProperty(e,"innerHTML",xe(i,{set:n(i.set)})),e.resetSourceWatch_=()=>{e.resetSourceWatch_=null,Object.keys(t).forEach(r=>{e[r]=t[r]}),Object.defineProperty(e,"innerHTML",i)},s.one("sourceset",e.resetSourceWatch_)},Lv=Object.defineProperty({},"src",{get(){return this.hasAttribute("src")?nh(k.Element.prototype.getAttribute.call(this,"src")):""},set(s){return k.Element.prototype.setAttribute.call(this,"src",s),s}}),Ov=s=>Nh([s.el(),k.HTMLMediaElement.prototype,Lv],"src"),Rv=function(s){if(!s.featuresSourceset)return;const e=s.el();if(e.resetSourceset_)return;const t=Ov(s),i=e.setAttribute,n=e.load;Object.defineProperty(e,"src",xe(t,{set:r=>{const a=t.set.call(e,r);return s.triggerSourceset(e.src),a}})),e.setAttribute=(r,a)=>{const l=i.call(e,r,a);return/src/i.test(r)&&s.triggerSourceset(e.src),l},e.load=()=>{const r=n.call(e);return oo(s)||(s.triggerSourceset(""),nc(s)),r},e.currentSrc?s.triggerSourceset(e.currentSrc):oo(s)||nc(s),e.resetSourceset_=()=>{e.resetSourceset_=null,e.load=n,e.setAttribute=i,Object.defineProperty(e,"src",t),e.resetSourceWatch_&&e.resetSourceWatch_()}};class J extends oe{constructor(e,t){super(e,t);const i=e.source;let n=!1;if(this.featuresVideoFrameCallback=this.featuresVideoFrameCallback&&this.el_.tagName==="VIDEO",i&&(this.el_.currentSrc!==i.src||e.tag&&e.tag.initNetworkState_===3)?this.setSource(i):this.handleLateInit_(this.el_),e.enableSourceset&&this.setupSourcesetHandling_(),this.isScrubbing_=!1,this.el_.hasChildNodes()){const r=this.el_.childNodes;let a=r.length;const l=[];for(;a--;){const h=r[a];h.nodeName.toLowerCase()==="track"&&(this.featuresNativeTextTracks?(this.remoteTextTrackEls().addTrackElement_(h),this.remoteTextTracks().addTrack(h.track),this.textTracks().addTrack(h.track),!n&&!this.el_.hasAttribute("crossorigin")&&ea(h.src)&&(n=!0)):l.push(h))}for(let h=0;h<l.length;h++)this.el_.removeChild(l[h])}this.proxyNativeTracks_(),this.featuresNativeTextTracks&&n&&ue.warn(`Text Tracks are being loaded from another origin but the crossorigin attribute isn't used.
|
|
167
|
+
This may prevent text tracks from loading.`),this.restoreMetadataTracksInIOSNativePlayer_(),(_n||zr)&&e.nativeControlsForTouch===!0&&this.setControls(!0),this.proxyWebkitFullscreen_(),this.triggerReady()}dispose(){this.el_&&this.el_.resetSourceset_&&this.el_.resetSourceset_(),J.disposeMediaElement(this.el_),this.options_=null,super.dispose()}setupSourcesetHandling_(){Rv(this)}restoreMetadataTracksInIOSNativePlayer_(){const e=this.textTracks();let t;const i=()=>{t=[];for(let r=0;r<e.length;r++){const a=e[r];a.kind==="metadata"&&t.push({track:a,storedMode:a.mode})}};i(),e.addEventListener("change",i),this.on("dispose",()=>e.removeEventListener("change",i));const n=()=>{for(let r=0;r<t.length;r++){const a=t[r];a.track.mode==="disabled"&&a.track.mode!==a.storedMode&&(a.track.mode=a.storedMode)}e.removeEventListener("change",n)};this.on("webkitbeginfullscreen",()=>{e.removeEventListener("change",i),e.removeEventListener("change",n),e.addEventListener("change",n)}),this.on("webkitendfullscreen",()=>{e.removeEventListener("change",i),e.addEventListener("change",i),e.removeEventListener("change",n)})}overrideNative_(e,t){if(t!==this[`featuresNative${e}Tracks`])return;const i=e.toLowerCase();this[`${i}TracksListeners_`]&&Object.keys(this[`${i}TracksListeners_`]).forEach(n=>{this.el()[`${i}Tracks`].removeEventListener(n,this[`${i}TracksListeners_`][n])}),this[`featuresNative${e}Tracks`]=!t,this[`${i}TracksListeners_`]=null,this.proxyNativeTracksForType_(i)}overrideNativeAudioTracks(e){this.overrideNative_("Audio",e)}overrideNativeVideoTracks(e){this.overrideNative_("Video",e)}proxyNativeTracksForType_(e){const t=It[e],i=this.el()[t.getterName],n=this[t.getterName]();if(!this[`featuresNative${t.capitalName}Tracks`]||!i||!i.addEventListener)return;const r={change:l=>{const h={type:"change",target:n,currentTarget:n,srcElement:n};n.trigger(h),e==="text"&&this[xs.remoteText.getterName]().trigger(h)},addtrack(l){n.addTrack(l.track)},removetrack(l){n.removeTrack(l.track)}},a=function(){const l=[];for(let h=0;h<n.length;h++){let f=!1;for(let m=0;m<i.length;m++)if(i[m]===n[h]){f=!0;break}f||l.push(n[h])}for(;l.length;)n.removeTrack(l.shift())};this[t.getterName+"Listeners_"]=r,Object.keys(r).forEach(l=>{const h=r[l];i.addEventListener(l,h),this.on("dispose",f=>i.removeEventListener(l,h))}),this.on("loadstart",a),this.on("dispose",l=>this.off("loadstart",a))}proxyNativeTracks_(){It.names.forEach(e=>{this.proxyNativeTracksForType_(e)})}createEl(){let e=this.options_.tag;if(!e||!(this.options_.playerElIngest||this.movingMediaElementInDOM)){if(e){const i=e.cloneNode(!0);e.parentNode&&e.parentNode.insertBefore(i,e),J.disposeMediaElement(e),e=i}else{e=K.createElement("video");const i=this.options_.tag&&bi(this.options_.tag),n=xe({},i);(!_n||this.options_.nativeControlsForTouch!==!0)&&delete n.controls,Md(e,Object.assign(n,{id:this.options_.techId,class:"vjs-tech"}))}e.playerId=this.options_.playerId}typeof this.options_.preload<"u"&&_s(e,"preload",this.options_.preload),this.options_.disablePictureInPicture!==void 0&&(e.disablePictureInPicture=this.options_.disablePictureInPicture);const t=["loop","muted","playsinline","autoplay"];for(let i=0;i<t.length;i++){const n=t[i],r=this.options_[n];typeof r<"u"&&(r?_s(e,n,n):Kr(e,n),e[n]=r)}return e}handleLateInit_(e){if(e.networkState===0||e.networkState===3)return;if(e.readyState===0){let i=!1;const n=function(){i=!0};this.on("loadstart",n);const r=function(){i||this.trigger("loadstart")};this.on("loadedmetadata",r),this.ready(function(){this.off("loadstart",n),this.off("loadedmetadata",r),i||this.trigger("loadstart")});return}const t=["loadstart"];t.push("loadedmetadata"),e.readyState>=2&&t.push("loadeddata"),e.readyState>=3&&t.push("canplay"),e.readyState>=4&&t.push("canplaythrough"),this.ready(function(){t.forEach(function(i){this.trigger(i)},this)})}setScrubbing(e){this.isScrubbing_=e}scrubbing(){return this.isScrubbing_}setCurrentTime(e){try{this.isScrubbing_&&this.el_.fastSeek&&Wr?this.el_.fastSeek(e):this.el_.currentTime=e}catch(t){ue(t,"Video is not ready. (Video.js)")}}duration(){if(this.el_.duration===1/0&&Ut&&ei&&this.el_.currentTime===0){const e=()=>{this.el_.currentTime>0&&(this.el_.duration===1/0&&this.trigger("durationchange"),this.off("timeupdate",e))};return this.on("timeupdate",e),NaN}return this.el_.duration||NaN}width(){return this.el_.offsetWidth}height(){return this.el_.offsetHeight}proxyWebkitFullscreen_(){if(!("webkitDisplayingFullscreen"in this.el_))return;const e=function(){this.trigger("fullscreenchange",{isFullscreen:!1}),this.el_.controls&&!this.options_.nativeControlsForTouch&&this.controls()&&(this.el_.controls=!1)},t=function(){"webkitPresentationMode"in this.el_&&this.el_.webkitPresentationMode!=="picture-in-picture"&&(this.one("webkitendfullscreen",e),this.trigger("fullscreenchange",{isFullscreen:!0,nativeIOSFullscreen:!0}))};this.on("webkitbeginfullscreen",t),this.on("dispose",()=>{this.off("webkitbeginfullscreen",t),this.off("webkitendfullscreen",e)})}supportsFullScreen(){return typeof this.el_.webkitEnterFullScreen=="function"}enterFullScreen(){const e=this.el_;if(e.paused&&e.networkState<=e.HAVE_METADATA)Kt(this.el_.play()),this.setTimeout(function(){e.pause();try{e.webkitEnterFullScreen()}catch(t){this.trigger("fullscreenerror",t)}},0);else try{e.webkitEnterFullScreen()}catch(t){this.trigger("fullscreenerror",t)}}exitFullScreen(){if(!this.el_.webkitDisplayingFullscreen){this.trigger("fullscreenerror",new Error("The video is not fullscreen"));return}this.el_.webkitExitFullScreen()}requestPictureInPicture(){return this.el_.requestPictureInPicture()}requestVideoFrameCallback(e){return this.featuresVideoFrameCallback&&!this.el_.webkitKeys?this.el_.requestVideoFrameCallback(e):super.requestVideoFrameCallback(e)}cancelVideoFrameCallback(e){this.featuresVideoFrameCallback&&!this.el_.webkitKeys?this.el_.cancelVideoFrameCallback(e):super.cancelVideoFrameCallback(e)}src(e){if(e===void 0)return this.el_.src;this.setSrc(e)}addSourceElement(e,t){if(!e)return ue.error("Invalid source URL."),!1;const i={src:e};t&&(i.type=t);const n=se("source",{},i);return this.el_.appendChild(n),!0}removeSourceElement(e){if(!e)return ue.error("Source URL is required to remove the source element."),!1;const t=this.el_.querySelectorAll("source");for(const i of t)if(i.src===e)return this.el_.removeChild(i),!0;return ue.warn(`No matching source element found with src: ${e}`),!1}reset(){J.resetMediaElement(this.el_)}currentSrc(){return this.currentSource_?this.currentSource_.src:this.el_.currentSrc}setControls(e){this.el_.controls=!!e}addTextTrack(e,t,i){return this.featuresNativeTextTracks?this.el_.addTextTrack(e,t,i):super.addTextTrack(e,t,i)}createRemoteTextTrack(e){if(!this.featuresNativeTextTracks)return super.createRemoteTextTrack(e);const t=K.createElement("track");return e.kind&&(t.kind=e.kind),e.label&&(t.label=e.label),(e.language||e.srclang)&&(t.srclang=e.language||e.srclang),e.default&&(t.default=e.default),e.id&&(t.id=e.id),e.src&&(t.src=e.src),t}addRemoteTextTrack(e,t){const i=super.addRemoteTextTrack(e,t);return this.featuresNativeTextTracks&&this.el().appendChild(i),i}removeRemoteTextTrack(e){if(super.removeRemoteTextTrack(e),this.featuresNativeTextTracks){const t=this.$$("track");let i=t.length;for(;i--;)(e===t[i]||e===t[i].track)&&this.el().removeChild(t[i])}}getVideoPlaybackQuality(){if(typeof this.el().getVideoPlaybackQuality=="function")return this.el().getVideoPlaybackQuality();const e={};return typeof this.el().webkitDroppedFrameCount<"u"&&typeof this.el().webkitDecodedFrameCount<"u"&&(e.droppedVideoFrames=this.el().webkitDroppedFrameCount,e.totalVideoFrames=this.el().webkitDecodedFrameCount),k.performance&&(e.creationTime=k.performance.now()),e}}Vr(J,"TEST_VID",function(){if(!Es())return;const s=K.createElement("video"),e=K.createElement("track");return e.kind="captions",e.srclang="en",e.label="English",s.appendChild(e),s});J.isSupported=function(){try{J.TEST_VID.volume=.5}catch{return!1}return!!(J.TEST_VID&&J.TEST_VID.canPlayType)};J.canPlayType=function(s){return J.TEST_VID.canPlayType(s)};J.canPlaySource=function(s,e){return J.canPlayType(s.type)};J.canControlVolume=function(){try{const s=J.TEST_VID.volume;J.TEST_VID.volume=s/2+.1;const e=s!==J.TEST_VID.volume;return e&&Ze?(k.setTimeout(()=>{J&&J.prototype&&(J.prototype.featuresVolumeControl=s!==J.TEST_VID.volume)}),!1):e}catch{return!1}};J.canMuteVolume=function(){try{const s=J.TEST_VID.muted;return J.TEST_VID.muted=!s,J.TEST_VID.muted?_s(J.TEST_VID,"muted","muted"):Kr(J.TEST_VID,"muted","muted"),s!==J.TEST_VID.muted}catch{return!1}};J.canControlPlaybackRate=function(){if(Ut&&ei&&Hr<58)return!1;try{const s=J.TEST_VID.playbackRate;return J.TEST_VID.playbackRate=s/2+.1,s!==J.TEST_VID.playbackRate}catch{return!1}};J.canOverrideAttributes=function(){try{const s=()=>{};Object.defineProperty(K.createElement("video"),"src",{get:s,set:s}),Object.defineProperty(K.createElement("audio"),"src",{get:s,set:s}),Object.defineProperty(K.createElement("video"),"innerHTML",{get:s,set:s}),Object.defineProperty(K.createElement("audio"),"innerHTML",{get:s,set:s})}catch{return!1}return!0};J.supportsNativeTextTracks=function(){return Wr||Ze&&ei};J.supportsNativeVideoTracks=function(){return!!(J.TEST_VID&&J.TEST_VID.videoTracks)};J.supportsNativeAudioTracks=function(){return!!(J.TEST_VID&&J.TEST_VID.audioTracks)};J.Events=["loadstart","suspend","abort","error","emptied","stalled","loadedmetadata","loadeddata","canplay","canplaythrough","playing","waiting","seeking","seeked","ended","durationchange","timeupdate","progress","play","pause","ratechange","resize","volumechange"];[["featuresMuteControl","canMuteVolume"],["featuresPlaybackRate","canControlPlaybackRate"],["featuresSourceset","canOverrideAttributes"],["featuresNativeTextTracks","supportsNativeTextTracks"],["featuresNativeVideoTracks","supportsNativeVideoTracks"],["featuresNativeAudioTracks","supportsNativeAudioTracks"]].forEach(function([s,e]){Vr(J.prototype,s,()=>J[e](),!0)});J.prototype.featuresVolumeControl=J.canControlVolume();J.prototype.movingMediaElementInDOM=!Ze;J.prototype.featuresFullscreenResize=!0;J.prototype.featuresProgressEvents=!0;J.prototype.featuresTimeupdateEvents=!0;J.prototype.featuresVideoFrameCallback=!!(J.TEST_VID&&J.TEST_VID.requestVideoFrameCallback);J.disposeMediaElement=function(s){if(s){for(s.parentNode&&s.parentNode.removeChild(s);s.hasChildNodes();)s.removeChild(s.firstChild);s.removeAttribute("src"),typeof s.load=="function"&&function(){try{s.load()}catch{}}()}};J.resetMediaElement=function(s){if(!s)return;const e=s.querySelectorAll("source");let t=e.length;for(;t--;)s.removeChild(e[t]);s.removeAttribute("src"),typeof s.load=="function"&&function(){try{s.load()}catch{}}()};["muted","defaultMuted","autoplay","controls","loop","playsinline"].forEach(function(s){J.prototype[s]=function(){return this.el_[s]||this.el_.hasAttribute(s)}});["muted","defaultMuted","autoplay","loop","playsinline"].forEach(function(s){J.prototype["set"+Be(s)]=function(e){this.el_[s]=e,e?this.el_.setAttribute(s,s):this.el_.removeAttribute(s)}});["paused","currentTime","buffered","volume","poster","preload","error","seeking","seekable","ended","playbackRate","defaultPlaybackRate","disablePictureInPicture","played","networkState","readyState","videoWidth","videoHeight","crossOrigin"].forEach(function(s){J.prototype[s]=function(){return this.el_[s]}});["volume","src","poster","preload","playbackRate","defaultPlaybackRate","disablePictureInPicture","crossOrigin"].forEach(function(s){J.prototype["set"+Be(s)]=function(e){this.el_[s]=e}});["pause","load","play"].forEach(function(s){J.prototype[s]=function(){return this.el_[s]()}});oe.withSourceHandlers(J);J.nativeSourceHandler={};J.nativeSourceHandler.canPlayType=function(s){try{return J.TEST_VID.canPlayType(s)}catch{return""}};J.nativeSourceHandler.canHandleSource=function(s,e){if(s.type)return J.nativeSourceHandler.canPlayType(s.type);if(s.src){const t=Go(s.src);return J.nativeSourceHandler.canPlayType(`video/${t}`)}return""};J.nativeSourceHandler.handleSource=function(s,e,t){e.setSrc(s.src)};J.nativeSourceHandler.dispose=function(){};J.registerSourceHandler(J.nativeSourceHandler);oe.registerTech("Html5",J);const Uh=["progress","abort","suspend","emptied","stalled","loadedmetadata","loadeddata","timeupdate","resize","volumechange","texttrackchange"],qa={canplay:"CanPlay",canplaythrough:"CanPlayThrough",playing:"Playing",seeked:"Seeked"},lo=["tiny","xsmall","small","medium","large","xlarge","huge"],or={};lo.forEach(s=>{const e=s.charAt(0)==="x"?`x-${s.substring(1)}`:s;or[s]=`vjs-layout-${e}`});const Mv={tiny:210,xsmall:320,small:425,medium:768,large:1440,xlarge:2560,huge:1/0};class ke extends H{constructor(e,t,i){if(e.id=e.id||t.id||`vjs_video_${At()}`,t=Object.assign(ke.getTagSettings(e),t),t.initChildren=!1,t.createEl=!1,t.evented=!1,t.reportTouchActivity=!1,!t.language){const a=e.closest("[lang]");a&&(t.language=a.getAttribute("lang"))}if(super(null,t,i),this.boundDocumentFullscreenChange_=a=>this.documentFullscreenChange_(a),this.boundFullWindowOnEscKey_=a=>this.fullWindowOnEscKey(a),this.boundUpdateStyleEl_=a=>this.updateStyleEl_(a),this.boundApplyInitTime_=a=>this.applyInitTime_(a),this.boundUpdateCurrentBreakpoint_=a=>this.updateCurrentBreakpoint_(a),this.boundHandleTechClick_=a=>this.handleTechClick_(a),this.boundHandleTechDoubleClick_=a=>this.handleTechDoubleClick_(a),this.boundHandleTechTouchStart_=a=>this.handleTechTouchStart_(a),this.boundHandleTechTouchMove_=a=>this.handleTechTouchMove_(a),this.boundHandleTechTouchEnd_=a=>this.handleTechTouchEnd_(a),this.boundHandleTechTap_=a=>this.handleTechTap_(a),this.boundUpdatePlayerHeightOnAudioOnlyMode_=a=>this.updatePlayerHeightOnAudioOnlyMode_(a),this.isFullscreen_=!1,this.log=Sd(this.id_),this.fsApi_=hr,this.isPosterFromTech_=!1,this.queuedCallbacks_=[],this.isReady_=!1,this.hasStarted_=!1,this.userActive_=!1,this.debugEnabled_=!1,this.audioOnlyMode_=!1,this.audioPosterMode_=!1,this.audioOnlyCache_={controlBarHeight:null,playerHeight:null,hiddenChildren:[]},!this.options_||!this.options_.techOrder||!this.options_.techOrder.length)throw new Error("No techOrder specified. Did you overwrite videojs.options instead of just changing the properties you want to override?");if(this.tag=e,this.tagAttributes=e&&bi(e),this.language(this.options_.language),t.languages){const a={};Object.getOwnPropertyNames(t.languages).forEach(function(l){a[l.toLowerCase()]=t.languages[l]}),this.languages_=a}else this.languages_=ke.prototype.options_.languages;this.resetCache_(),this.poster_=t.poster||"",this.controls_=!!t.controls,e.controls=!1,e.removeAttribute("controls"),this.changingSrc_=!1,this.playCallbacks_=[],this.playTerminatedQueue_=[],e.hasAttribute("autoplay")?this.autoplay(!0):this.autoplay(this.options_.autoplay),t.plugins&&Object.keys(t.plugins).forEach(a=>{if(typeof this[a]!="function")throw new Error(`plugin "${a}" does not exist`)}),this.scrubbing_=!1,this.el_=this.createEl(),Ho(this,{eventBusKey:"el_"}),this.fsApi_.requestFullscreen&&(vt(K,this.fsApi_.fullscreenchange,this.boundDocumentFullscreenChange_),this.on(this.fsApi_.fullscreenchange,this.boundDocumentFullscreenChange_)),this.fluid_&&this.on(["playerreset","resize"],this.boundUpdateStyleEl_);const n=xe(this.options_);if(t.plugins&&Object.keys(t.plugins).forEach(a=>{this[a](t.plugins[a])}),t.debug&&this.debug(!0),this.options_.playerOptions=n,this.middleware_=[],this.playbackRates(t.playbackRates),t.experimentalSvgIcons){const l=new k.DOMParser().parseFromString(nv,"image/svg+xml");if(l.querySelector("parsererror"))ue.warn("Failed to load SVG Icons. Falling back to Font Icons."),this.options_.experimentalSvgIcons=null;else{const f=l.documentElement;f.style.display="none",this.el_.appendChild(f),this.addClass("vjs-svg-icons-enabled")}}this.initChildren(),this.isAudio(e.nodeName.toLowerCase()==="audio"),this.controls()?this.addClass("vjs-controls-enabled"):this.addClass("vjs-controls-disabled"),this.el_.setAttribute("role","region"),this.isAudio()?this.el_.setAttribute("aria-label",this.localize("Audio Player")):this.el_.setAttribute("aria-label",this.localize("Video Player")),this.isAudio()&&this.addClass("vjs-audio"),t.spatialNavigation&&t.spatialNavigation.enabled&&(this.spatialNavigation=new rv(this),this.addClass("vjs-spatial-navigation-enabled")),_n&&this.addClass("vjs-touch-enabled"),Ze||this.addClass("vjs-workinghover"),ke.players[this.id_]=this;const r=Ja.split(".")[0];this.addClass(`vjs-v${r}`),this.userActive(!0),this.reportUserActivity(),this.one("play",a=>this.listenForUserActivity_(a)),this.on("keydown",a=>this.handleKeyDown(a)),this.on("languagechange",a=>this.handleLanguagechange(a)),this.breakpoints(this.options_.breakpoints),this.responsive(this.options_.responsive),this.on("ready",()=>{this.audioPosterMode(this.options_.audioPosterMode),this.audioOnlyMode(this.options_.audioOnlyMode)})}dispose(){this.trigger("dispose"),this.off("dispose"),et(K,this.fsApi_.fullscreenchange,this.boundDocumentFullscreenChange_),et(K,"keydown",this.boundFullWindowOnEscKey_),this.styleEl_&&this.styleEl_.parentNode&&(this.styleEl_.parentNode.removeChild(this.styleEl_),this.styleEl_=null),ke.players[this.id_]=null,this.tag&&this.tag.player&&(this.tag.player=null),this.el_&&this.el_.player&&(this.el_.player=null),this.tech_&&(this.tech_.dispose(),this.isPosterFromTech_=!1,this.poster_=""),this.playerElIngest_&&(this.playerElIngest_=null),this.tag&&(this.tag=null),ev(this),rt.names.forEach(e=>{const t=rt[e],i=this[t.getterName]();i&&i.off&&i.off()}),super.dispose({restoreEl:this.options_.restoreEl})}createEl(){let e=this.tag,t,i=this.playerElIngest_=e.parentNode&&e.parentNode.hasAttribute&&e.parentNode.hasAttribute("data-vjs-player");const n=this.tag.tagName.toLowerCase()==="video-js";i?t=this.el_=e.parentNode:n||(t=this.el_=super.createEl("div"));const r=bi(e);if(n){for(t=this.el_=e,e=this.tag=K.createElement("video");t.children.length;)e.appendChild(t.firstChild);hn(t,"video-js")||Fi(t,"video-js"),t.appendChild(e),i=this.playerElIngest_=t,Object.keys(t).forEach(h=>{try{e[h]=t[h]}catch{}})}e.setAttribute("tabindex","-1"),r.tabindex="-1",ei&&qr&&(e.setAttribute("role","application"),r.role="application"),e.removeAttribute("width"),e.removeAttribute("height"),"width"in r&&delete r.width,"height"in r&&delete r.height,Object.getOwnPropertyNames(r).forEach(function(h){n&&h==="class"||t.setAttribute(h,r[h]),n&&e.setAttribute(h,r[h])}),e.playerId=e.id,e.id+="_html5_api",e.className="vjs-tech",e.player=t.player=this,this.addClass("vjs-paused");const a=["IS_SMART_TV","IS_TIZEN","IS_WEBOS","IS_ANDROID","IS_IPAD","IS_IPHONE","IS_CHROMECAST_RECEIVER"].filter(h=>Dd[h]).map(h=>"vjs-device-"+h.substring(3).toLowerCase().replace(/\_/g,"-"));if(this.addClass(...a),k.VIDEOJS_NO_DYNAMIC_STYLE!==!0){this.styleEl_=Wd("vjs-styles-dimensions");const h=Ei(".vjs-styles-defaults"),f=Ei("head");f.insertBefore(this.styleEl_,h?h.nextSibling:f.firstChild)}this.fill_=!1,this.fluid_=!1,this.width(this.options_.width),this.height(this.options_.height),this.fill(this.options_.fill),this.fluid(this.options_.fluid),this.aspectRatio(this.options_.aspectRatio),this.crossOrigin(this.options_.crossOrigin||this.options_.crossorigin);const l=e.getElementsByTagName("a");for(let h=0;h<l.length;h++){const f=l.item(h);Fi(f,"vjs-hidden"),f.setAttribute("hidden","hidden")}return e.initNetworkState_=e.networkState,e.parentNode&&!i&&e.parentNode.insertBefore(t,e),eo(e,t),this.children_.unshift(e),this.el_.setAttribute("lang",this.language_),this.el_.setAttribute("translate","no"),this.el_=t,t}crossOrigin(e){if(typeof e>"u")return this.techGet_("crossOrigin");if(e!==null&&e!=="anonymous"&&e!=="use-credentials"){ue.warn(`crossOrigin must be null, "anonymous" or "use-credentials", given "${e}"`);return}this.techCall_("setCrossOrigin",e),this.posterImage&&this.posterImage.crossOrigin(e)}width(e){return this.dimension("width",e)}height(e){return this.dimension("height",e)}dimension(e,t){const i=e+"_";if(t===void 0)return this[i]||0;if(t===""||t==="auto"){this[i]=void 0,this.updateStyleEl_();return}const n=parseFloat(t);if(isNaN(n)){ue.error(`Improper value "${t}" supplied for for ${e}`);return}this[i]=n,this.updateStyleEl_()}fluid(e){if(e===void 0)return!!this.fluid_;this.fluid_=!!e,ai(this)&&this.off(["playerreset","resize"],this.boundUpdateStyleEl_),e?(this.addClass("vjs-fluid"),this.fill(!1),PT(this,()=>{this.on(["playerreset","resize"],this.boundUpdateStyleEl_)})):this.removeClass("vjs-fluid"),this.updateStyleEl_()}fill(e){if(e===void 0)return!!this.fill_;this.fill_=!!e,e?(this.addClass("vjs-fill"),this.fluid(!1)):this.removeClass("vjs-fill")}aspectRatio(e){if(e===void 0)return this.aspectRatio_;if(!/^\d+\:\d+$/.test(e))throw new Error("Improper value supplied for aspect ratio. The format should be width:height, for example 16:9.");this.aspectRatio_=e,this.fluid(!0),this.updateStyleEl_()}updateStyleEl_(){if(k.VIDEOJS_NO_DYNAMIC_STYLE===!0){const l=typeof this.width_=="number"?this.width_:this.options_.width,h=typeof this.height_=="number"?this.height_:this.options_.height,f=this.tech_&&this.tech_.el();f&&(l>=0&&(f.width=l),h>=0&&(f.height=h));return}let e,t,i,n;this.aspectRatio_!==void 0&&this.aspectRatio_!=="auto"?i=this.aspectRatio_:this.videoWidth()>0?i=this.videoWidth()+":"+this.videoHeight():i="16:9";const r=i.split(":"),a=r[1]/r[0];this.width_!==void 0?e=this.width_:this.height_!==void 0?e=this.height_/a:e=this.videoWidth()||300,this.height_!==void 0?t=this.height_:t=e*a,/^[^a-zA-Z]/.test(this.id())?n="dimensions-"+this.id():n=this.id()+"-dimensions",this.addClass(n),Gd(this.styleEl_,`
|
|
168
|
+
.${n} {
|
|
169
169
|
width: ${e}px;
|
|
170
170
|
height: ${t}px;
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
-
.${
|
|
173
|
+
.${n}.vjs-fluid:not(.vjs-audio-only-mode) {
|
|
174
174
|
padding-top: ${a*100}%;
|
|
175
175
|
}
|
|
176
|
-
`)}loadTech_(e,t){this.tech_&&this.unloadTech_();const
|
|
176
|
+
`)}loadTech_(e,t){this.tech_&&this.unloadTech_();const i=Be(e),n=e.charAt(0).toLowerCase()+e.slice(1);i!=="Html5"&&this.tag&&(oe.getTech("Html5").disposeMediaElement(this.tag),this.tag.player=null,this.tag=null),this.techName_=i,this.isReady_=!1;let r=this.autoplay();(typeof this.autoplay()=="string"||this.autoplay()===!0&&this.options_.normalizeAutoplay)&&(r=!1);const a={source:t,autoplay:r,nativeControlsForTouch:this.options_.nativeControlsForTouch,playerId:this.id(),techId:`${this.id()}_${n}_api`,playsinline:this.options_.playsinline,preload:this.options_.preload,loop:this.options_.loop,disablePictureInPicture:this.options_.disablePictureInPicture,muted:this.options_.muted,poster:this.poster(),language:this.language(),playerElIngest:this.playerElIngest_||!1,"vtt.js":this.options_["vtt.js"],canOverridePoster:!!this.options_.techCanOverridePoster,enableSourceset:this.options_.enableSourceset};rt.names.forEach(h=>{const f=rt[h];a[f.getterName]=this[f.privateName]}),Object.assign(a,this.options_[i]),Object.assign(a,this.options_[n]),Object.assign(a,this.options_[e.toLowerCase()]),this.tag&&(a.tag=this.tag),t&&t.src===this.cache_.src&&this.cache_.currentTime>0&&(a.startTime=this.cache_.currentTime);const l=oe.getTech(e);if(!l)throw new Error(`No Tech named '${i}' exists! '${i}' should be registered using videojs.registerTech()'`);this.tech_=new l(a),this.tech_.ready(we(this,this.handleTechReady_),!0),Uu.jsonToTextTracks(this.textTracksJson_||[],this.tech_),Uh.forEach(h=>{this.on(this.tech_,h,f=>this[`handleTech${Be(h)}_`](f))}),Object.keys(qa).forEach(h=>{this.on(this.tech_,h,f=>{if(this.tech_.playbackRate()===0&&this.tech_.seeking()){this.queuedCallbacks_.push({callback:this[`handleTech${qa[h]}_`].bind(this),event:f});return}this[`handleTech${qa[h]}_`](f)})}),this.on(this.tech_,"loadstart",h=>this.handleTechLoadStart_(h)),this.on(this.tech_,"sourceset",h=>this.handleTechSourceset_(h)),this.on(this.tech_,"waiting",h=>this.handleTechWaiting_(h)),this.on(this.tech_,"ended",h=>this.handleTechEnded_(h)),this.on(this.tech_,"seeking",h=>this.handleTechSeeking_(h)),this.on(this.tech_,"play",h=>this.handleTechPlay_(h)),this.on(this.tech_,"pause",h=>this.handleTechPause_(h)),this.on(this.tech_,"durationchange",h=>this.handleTechDurationChange_(h)),this.on(this.tech_,"fullscreenchange",(h,f)=>this.handleTechFullscreenChange_(h,f)),this.on(this.tech_,"fullscreenerror",(h,f)=>this.handleTechFullscreenError_(h,f)),this.on(this.tech_,"enterpictureinpicture",h=>this.handleTechEnterPictureInPicture_(h)),this.on(this.tech_,"leavepictureinpicture",h=>this.handleTechLeavePictureInPicture_(h)),this.on(this.tech_,"error",h=>this.handleTechError_(h)),this.on(this.tech_,"posterchange",h=>this.handleTechPosterChange_(h)),this.on(this.tech_,"textdata",h=>this.handleTechTextData_(h)),this.on(this.tech_,"ratechange",h=>this.handleTechRateChange_(h)),this.on(this.tech_,"loadedmetadata",this.boundUpdateStyleEl_),this.usingNativeControls(this.techGet_("controls")),this.controls()&&!this.usingNativeControls()&&this.addTechControlsListeners_(),this.tech_.el().parentNode!==this.el()&&(i!=="Html5"||!this.tag)&&eo(this.tech_.el(),this.el()),this.tag&&(this.tag.player=null,this.tag=null)}unloadTech_(){rt.names.forEach(e=>{const t=rt[e];this[t.privateName]=this[t.getterName]()}),this.textTracksJson_=Uu.textTracksToJson(this.tech_),this.isReady_=!1,this.tech_.dispose(),this.tech_=!1,this.isPosterFromTech_&&(this.poster_="",this.trigger("posterchange")),this.isPosterFromTech_=!1}tech(e){return e===void 0&&ue.warn(`Using the tech directly can be dangerous. I hope you know what you're doing.
|
|
177
177
|
See https://github.com/videojs/video.js/issues/2617 for more info.
|
|
178
|
-
`),this.tech_}version(){return{"video.js":Ka}}addTechControlsListeners_(){this.removeTechControlsListeners_(),this.on(this.tech_,"click",this.boundHandleTechClick_),this.on(this.tech_,"dblclick",this.boundHandleTechDoubleClick_),this.on(this.tech_,"touchstart",this.boundHandleTechTouchStart_),this.on(this.tech_,"touchmove",this.boundHandleTechTouchMove_),this.on(this.tech_,"touchend",this.boundHandleTechTouchEnd_),this.on(this.tech_,"tap",this.boundHandleTechTap_)}removeTechControlsListeners_(){this.off(this.tech_,"tap",this.boundHandleTechTap_),this.off(this.tech_,"touchstart",this.boundHandleTechTouchStart_),this.off(this.tech_,"touchmove",this.boundHandleTechTouchMove_),this.off(this.tech_,"touchend",this.boundHandleTechTouchEnd_),this.off(this.tech_,"click",this.boundHandleTechClick_),this.off(this.tech_,"dblclick",this.boundHandleTechDoubleClick_)}handleTechReady_(){this.triggerReady(),this.cache_.volume&&this.techCall_("setVolume",this.cache_.volume),this.handleTechPosterChange_(),this.handleTechDurationChange_()}handleTechLoadStart_(){this.removeClass("vjs-ended","vjs-seeking"),this.error(null),this.handleTechDurationChange_(),this.paused()?(this.hasStarted(!1),this.trigger("loadstart")):this.trigger("loadstart"),this.manualAutoplay_(this.autoplay()===!0&&this.options_.normalizeAutoplay?"play":this.autoplay())}manualAutoplay_(e){if(!this.tech_||typeof e!="string")return;const t=()=>{const s=this.muted();this.muted(!0);const r=()=>{this.muted(s)};this.playTerminatedQueue_.push(r);const a=this.play();if(us(a))return a.catch(l=>{throw r(),new Error(`Rejection at manualAutoplay. Restoring muted value. ${l||""}`)})};let n;if(e==="any"&&!this.muted()?(n=this.play(),us(n)&&(n=n.catch(t))):e==="muted"&&!this.muted()?n=t():n=this.play(),!!us(n))return n.then(()=>{this.trigger({type:"autoplay-success",autoplay:e})}).catch(()=>{this.trigger({type:"autoplay-failure",autoplay:e})})}updateSourceCaches_(e=""){let t=e,n="";typeof t!="string"&&(t=e.src,n=e.type),this.cache_.source=this.cache_.source||{},this.cache_.sources=this.cache_.sources||[],t&&!n&&(n=lb(this,t)),this.cache_.source=ve({},e,{src:t,type:n});const s=this.cache_.sources.filter(c=>c.src&&c.src===t),r=[],a=this.$$("source"),l=[];for(let c=0;c<a.length;c++){const f=_i(a[c]);r.push(f),f.src&&f.src===t&&l.push(f.src)}l.length&&!s.length?this.cache_.sources=r:s.length||(this.cache_.sources=[this.cache_.source]),this.cache_.src=t}handleTechSourceset_(e){if(!this.changingSrc_){let t=r=>this.updateSourceCaches_(r);const n=this.currentSource().src,s=e.src;n&&!/^blob:/.test(n)&&/^blob:/.test(s)&&(!this.lastSource_||this.lastSource_.tech!==s&&this.lastSource_.player!==n)&&(t=()=>{}),t(s),e.src||this.tech_.any(["sourceset","loadstart"],r=>{if(r.type==="sourceset")return;const a=this.techGet_("currentSrc");this.lastSource_.tech=a,this.updateSourceCaches_(a)})}this.lastSource_={player:this.currentSource().src,tech:e.src},this.trigger({src:e.src,type:"sourceset"})}hasStarted(e){if(e===void 0)return this.hasStarted_;e!==this.hasStarted_&&(this.hasStarted_=e,this.hasStarted_?this.addClass("vjs-has-started"):this.removeClass("vjs-has-started"))}handleTechPlay_(){this.removeClass("vjs-ended","vjs-paused"),this.addClass("vjs-playing"),this.hasStarted(!0),this.trigger("play")}handleTechRateChange_(){this.tech_.playbackRate()>0&&this.cache_.lastPlaybackRate===0&&(this.queuedCallbacks_.forEach(e=>e.callback(e.event)),this.queuedCallbacks_=[]),this.cache_.lastPlaybackRate=this.tech_.playbackRate(),this.trigger("ratechange")}handleTechWaiting_(){this.addClass("vjs-waiting"),this.trigger("waiting");const e=this.currentTime(),t=()=>{e!==this.currentTime()&&(this.removeClass("vjs-waiting"),this.off("timeupdate",t))};this.on("timeupdate",t)}handleTechCanPlay_(){this.removeClass("vjs-waiting"),this.trigger("canplay")}handleTechCanPlayThrough_(){this.removeClass("vjs-waiting"),this.trigger("canplaythrough")}handleTechPlaying_(){this.removeClass("vjs-waiting"),this.trigger("playing")}handleTechSeeking_(){this.addClass("vjs-seeking"),this.trigger("seeking")}handleTechSeeked_(){this.removeClass("vjs-seeking","vjs-ended"),this.trigger("seeked")}handleTechPause_(){this.removeClass("vjs-playing"),this.addClass("vjs-paused"),this.trigger("pause")}handleTechEnded_(){this.addClass("vjs-ended"),this.removeClass("vjs-waiting"),this.options_.loop?(this.currentTime(0),this.play()):this.paused()||this.pause(),this.trigger("ended")}handleTechDurationChange_(){this.duration(this.techGet_("duration"))}handleTechClick_(e){this.controls_&&(this.options_===void 0||this.options_.userActions===void 0||this.options_.userActions.click===void 0||this.options_.userActions.click!==!1)&&(this.options_!==void 0&&this.options_.userActions!==void 0&&typeof this.options_.userActions.click=="function"?this.options_.userActions.click.call(this,e):this.paused()?Gt(this.play()):this.pause())}handleTechDoubleClick_(e){this.controls_&&(Array.prototype.some.call(this.$$(".vjs-control-bar, .vjs-modal-dialog"),t=>t.contains(e.target))||(this.options_===void 0||this.options_.userActions===void 0||this.options_.userActions.doubleClick===void 0||this.options_.userActions.doubleClick!==!1)&&(this.options_!==void 0&&this.options_.userActions!==void 0&&typeof this.options_.userActions.doubleClick=="function"?this.options_.userActions.doubleClick.call(this,e):this.isInPictureInPicture()&&!G.pictureInPictureElement?this.exitPictureInPicture():this.isFullscreen()?this.exitFullscreen():this.requestFullscreen()))}handleTechTap_(){this.userActive(!this.userActive())}handleTechTouchStart_(){this.userWasActive=this.userActive()}handleTechTouchMove_(){this.userWasActive&&this.reportUserActivity()}handleTechTouchEnd_(e){e.cancelable&&e.preventDefault()}toggleFullscreenClass_(){this.isFullscreen()?this.addClass("vjs-fullscreen"):this.removeClass("vjs-fullscreen")}documentFullscreenChange_(e){const t=e.target.player;if(t&&t!==this)return;const n=this.el();let s=G[this.fsApi_.fullscreenElement]===n;!s&&n.matches&&(s=n.matches(":"+this.fsApi_.fullscreen)),this.isFullscreen(s)}handleTechFullscreenChange_(e,t){t&&(t.nativeIOSFullscreen&&(this.addClass("vjs-ios-native-fs"),this.tech_.one("webkitendfullscreen",()=>{this.removeClass("vjs-ios-native-fs")})),this.isFullscreen(t.isFullscreen))}handleTechFullscreenError_(e,t){this.trigger("fullscreenerror",t)}togglePictureInPictureClass_(){this.isInPictureInPicture()?this.addClass("vjs-picture-in-picture"):this.removeClass("vjs-picture-in-picture")}handleTechEnterPictureInPicture_(e){this.isInPictureInPicture(!0)}handleTechLeavePictureInPicture_(e){this.isInPictureInPicture(!1)}handleTechError_(){const e=this.tech_.error();e&&this.error(e)}handleTechTextData_(){let e=null;arguments.length>1&&(e=arguments[1]),this.trigger("textdata",e)}getCache(){return this.cache_}resetCache_(){this.cache_={currentTime:0,initTime:0,inactivityTimeout:this.options_.inactivityTimeout,duration:NaN,lastVolume:1,lastPlaybackRate:this.defaultPlaybackRate(),media:null,src:"",source:{},sources:[],playbackRates:[],volume:1}}techCall_(e,t){this.ready(function(){if(e in nb)return tb(this.middleware_,this.tech_,e,t);if(e in qu)return $u(this.middleware_,this.tech_,e,t);try{this.tech_&&this.tech_[e](t)}catch(n){throw oe(n),n}},!0)}techGet_(e){if(!(!this.tech_||!this.tech_.isReady_)){if(e in ib)return eb(this.middleware_,this.tech_,e);if(e in qu)return $u(this.middleware_,this.tech_,e);try{return this.tech_[e]()}catch(t){throw this.tech_[e]===void 0?(oe(`Video.js: ${e} method not defined for ${this.techName_} playback technology.`,t),t):t.name==="TypeError"?(oe(`Video.js: ${e} unavailable on ${this.techName_} playback technology element.`,t),this.tech_.isReady_=!1,t):(oe(t),t)}}}play(){return new Promise(e=>{this.play_(e)})}play_(e=Gt){this.playCallbacks_.push(e);const t=!!(!this.changingSrc_&&(this.src()||this.currentSrc())),n=!!(Vr||Je);if(this.waitToPlay_&&(this.off(["ready","loadstart"],this.waitToPlay_),this.waitToPlay_=null),!this.isReady_||!t){this.waitToPlay_=r=>{this.play_()},this.one(["ready","loadstart"],this.waitToPlay_),!t&&n&&this.load();return}const s=this.techGet_("play");n&&this.hasClass("vjs-ended")&&this.resetProgressBar_(),s===null?this.runPlayTerminatedQueue_():this.runPlayCallbacks_(s)}runPlayTerminatedQueue_(){const e=this.playTerminatedQueue_.slice(0);this.playTerminatedQueue_=[],e.forEach(function(t){t()})}runPlayCallbacks_(e){const t=this.playCallbacks_.slice(0);this.playCallbacks_=[],this.playTerminatedQueue_=[],t.forEach(function(n){n(e)})}pause(){this.techCall_("pause")}paused(){return this.techGet_("paused")!==!1}played(){return this.techGet_("played")||Ut(0,0)}scrubbing(e){if(typeof e>"u")return this.scrubbing_;this.scrubbing_=!!e,this.techCall_("setScrubbing",this.scrubbing_),e?this.addClass("vjs-scrubbing"):this.removeClass("vjs-scrubbing")}currentTime(e){if(e===void 0)return this.cache_.currentTime=this.techGet_("currentTime")||0,this.cache_.currentTime;if(e<0&&(e=0),!this.isReady_||this.changingSrc_||!this.tech_||!this.tech_.isReady_){this.cache_.initTime=e,this.off("canplay",this.boundApplyInitTime_),this.one("canplay",this.boundApplyInitTime_);return}this.techCall_("setCurrentTime",e),this.cache_.initTime=0,isFinite(e)&&(this.cache_.currentTime=Number(e))}applyInitTime_(){this.currentTime(this.cache_.initTime)}duration(e){if(e===void 0)return this.cache_.duration!==void 0?this.cache_.duration:NaN;e=parseFloat(e),e<0&&(e=1/0),e!==this.cache_.duration&&(this.cache_.duration=e,e===1/0?this.addClass("vjs-live"):this.removeClass("vjs-live"),isNaN(e)||this.trigger("durationchange"))}remainingTime(){return this.duration()-this.currentTime()}remainingTimeDisplay(){return Math.floor(this.duration())-Math.floor(this.currentTime())}buffered(){let e=this.techGet_("buffered");return(!e||!e.length)&&(e=Ut(0,0)),e}seekable(){let e=this.techGet_("seekable");return(!e||!e.length)&&(e=Ut(0,0)),e}seeking(){return this.techGet_("seeking")}ended(){return this.techGet_("ended")}networkState(){return this.techGet_("networkState")}readyState(){return this.techGet_("readyState")}bufferedPercent(){return ic(this.buffered(),this.duration())}bufferedEnd(){const e=this.buffered(),t=this.duration();let n=e.end(e.length-1);return n>t&&(n=t),n}volume(e){let t;if(e!==void 0){t=Math.max(0,Math.min(1,e)),this.cache_.volume=t,this.techCall_("setVolume",t),t>0&&this.lastVolume_(t);return}return t=parseFloat(this.techGet_("volume")),isNaN(t)?1:t}muted(e){if(e!==void 0){this.techCall_("setMuted",e);return}return this.techGet_("muted")||!1}defaultMuted(e){return e!==void 0&&this.techCall_("setDefaultMuted",e),this.techGet_("defaultMuted")||!1}lastVolume_(e){if(e!==void 0&&e!==0){this.cache_.lastVolume=e;return}return this.cache_.lastVolume}supportsFullScreen(){return this.techGet_("supportsFullScreen")||!1}isFullscreen(e){if(e!==void 0){const t=this.isFullscreen_;this.isFullscreen_=!!e,this.isFullscreen_!==t&&this.fsApi_.prefixed&&this.trigger("fullscreenchange"),this.toggleFullscreenClass_();return}return this.isFullscreen_}requestFullscreen(e){this.isInPictureInPicture()&&this.exitPictureInPicture();const t=this;return new Promise((n,s)=>{function r(){t.off("fullscreenerror",l),t.off("fullscreenchange",a)}function a(){r(),n()}function l(f,m){r(),s(m)}t.one("fullscreenchange",a),t.one("fullscreenerror",l);const c=t.requestFullscreenHelper_(e);c&&(c.then(r,r),c.then(n,s))})}requestFullscreenHelper_(e){let t;if(this.fsApi_.prefixed||(t=this.options_.fullscreen&&this.options_.fullscreen.options||{},e!==void 0&&(t=e)),this.fsApi_.requestFullscreen){const n=this.el_[this.fsApi_.requestFullscreen](t);return n&&n.then(()=>this.isFullscreen(!0),()=>this.isFullscreen(!1)),n}else this.tech_.supportsFullScreen()&&!this.options_.preferFullWindow?this.techCall_("enterFullScreen"):this.enterFullWindow()}exitFullscreen(){const e=this;return new Promise((t,n)=>{function s(){e.off("fullscreenerror",a),e.off("fullscreenchange",r)}function r(){s(),t()}function a(c,f){s(),n(f)}e.one("fullscreenchange",r),e.one("fullscreenerror",a);const l=e.exitFullscreenHelper_();l&&(l.then(s,s),l.then(t,n))})}exitFullscreenHelper_(){if(this.fsApi_.requestFullscreen){const e=G[this.fsApi_.exitFullscreen]();return e&&Gt(e.then(()=>this.isFullscreen(!1))),e}else this.tech_.supportsFullScreen()&&!this.options_.preferFullWindow?this.techCall_("exitFullScreen"):this.exitFullWindow()}enterFullWindow(){this.isFullscreen(!0),this.isFullWindow=!0,this.docOrigOverflow=G.documentElement.style.overflow,vt(G,"keydown",this.boundFullWindowOnEscKey_),G.documentElement.style.overflow="hidden",Bi(G.body,"vjs-full-window"),this.trigger("enterFullWindow")}fullWindowOnEscKey(e){e.key==="Escape"&&this.isFullscreen()===!0&&(this.isFullWindow?this.exitFullWindow():this.exitFullscreen())}exitFullWindow(){this.isFullscreen(!1),this.isFullWindow=!1,Ze(G,"keydown",this.boundFullWindowOnEscKey_),G.documentElement.style.overflow=this.docOrigOverflow,Hr(G.body,"vjs-full-window"),this.trigger("exitFullWindow")}disablePictureInPicture(e){if(e===void 0)return this.techGet_("disablePictureInPicture");this.techCall_("setDisablePictureInPicture",e),this.options_.disablePictureInPicture=e,this.trigger("disablepictureinpicturechanged")}isInPictureInPicture(e){if(e!==void 0){this.isInPictureInPicture_=!!e,this.togglePictureInPictureClass_();return}return!!this.isInPictureInPicture_}requestPictureInPicture(){if(this.options_.enableDocumentPictureInPicture&&x.documentPictureInPicture){const e=G.createElement(this.el().tagName);return e.classList=this.el().classList,e.classList.add("vjs-pip-container"),this.posterImage&&e.appendChild(this.posterImage.el().cloneNode(!0)),this.titleBar&&e.appendChild(this.titleBar.el().cloneNode(!0)),e.appendChild(ne("p",{className:"vjs-pip-text"},{},this.localize("Playing in picture-in-picture"))),x.documentPictureInPicture.requestWindow({width:this.videoWidth(),height:this.videoHeight()}).then(t=>(Vh(t),this.el_.parentNode.insertBefore(e,this.el_),t.document.body.appendChild(this.el_),t.document.body.classList.add("vjs-pip-window"),this.player_.isInPictureInPicture(!0),this.player_.trigger({type:"enterpictureinpicture",pipWindow:t}),t.addEventListener("pagehide",n=>{const s=n.target.querySelector(".video-js");e.parentNode.replaceChild(s,e),this.player_.isInPictureInPicture(!1),this.player_.trigger("leavepictureinpicture")}),t))}return"pictureInPictureEnabled"in G&&this.disablePictureInPicture()===!1?this.techGet_("requestPictureInPicture"):Promise.reject("No PiP mode is available")}exitPictureInPicture(){if(x.documentPictureInPicture&&x.documentPictureInPicture.window)return x.documentPictureInPicture.window.close(),Promise.resolve();if("pictureInPictureEnabled"in G)return G.exitPictureInPicture()}handleKeyDown(e){const{userActions:t}=this.options_;!t||!t.hotkeys||(n=>{const s=n.tagName.toLowerCase();return n.isContentEditable?!0:s==="input"?["button","checkbox","hidden","radio","reset","submit"].indexOf(n.type)===-1:["textarea"].indexOf(s)!==-1})(this.el_.ownerDocument.activeElement)||(typeof t.hotkeys=="function"?t.hotkeys.call(this,e):this.handleHotkeys(e))}handleHotkeys(e){const t=this.options_.userActions?this.options_.userActions.hotkeys:{},{fullscreenKey:n=a=>e.key.toLowerCase()==="f",muteKey:s=a=>e.key.toLowerCase()==="m",playPauseKey:r=a=>e.key.toLowerCase()==="k"||e.key.toLowerCase()===" "}=t;if(n.call(this,e)){e.preventDefault(),e.stopPropagation();const a=H.getComponent("FullscreenToggle");G[this.fsApi_.fullscreenEnabled]!==!1&&a.prototype.handleClick.call(this,e)}else s.call(this,e)?(e.preventDefault(),e.stopPropagation(),H.getComponent("MuteToggle").prototype.handleClick.call(this,e)):r.call(this,e)&&(e.preventDefault(),e.stopPropagation(),H.getComponent("PlayToggle").prototype.handleClick.call(this,e))}canPlayType(e){let t;for(let n=0,s=this.options_.techOrder;n<s.length;n++){const r=s[n];let a=ae.getTech(r);if(a||(a=H.getComponent(r)),!a){oe.error(`The "${r}" tech is undefined. Skipped browser support check for that tech.`);continue}if(a.isSupported()&&(t=a.canPlayType(e),t))return t}return""}selectSource(e){const t=this.options_.techOrder.map(l=>[l,ae.getTech(l)]).filter(([l,c])=>c?c.isSupported():(oe.error(`The "${l}" tech is undefined. Skipped browser support check for that tech.`),!1)),n=function(l,c,f){let m;return l.some(b=>c.some(C=>{if(m=f(b,C),m)return!0})),m};let s;const r=l=>(c,f)=>l(f,c),a=([l,c],f)=>{if(c.canPlaySource(f,this.options_[l.toLowerCase()]))return{source:f,tech:l}};return this.options_.sourceOrder?s=n(e,t,r(a)):s=n(t,e,a),s||!1}handleSrc_(e,t){if(typeof e>"u")return this.cache_.src||"";this.resetRetryOnError_&&this.resetRetryOnError_();const n=oc(e);if(!n.length){this.setTimeout(function(){this.error({code:4,message:this.options_.notSupportedMessage})},0);return}if(this.changingSrc_=!0,t||(this.cache_.sources=n),this.updateSourceCaches_(n[0]),J1(this,n[0],(s,r)=>{if(this.middleware_=r,t||(this.cache_.sources=n),this.updateSourceCaches_(s),this.src_(s)){if(n.length>1)return this.handleSrc_(n.slice(1));this.changingSrc_=!1,this.setTimeout(function(){this.error({code:4,message:this.options_.notSupportedMessage})},0),this.triggerReady();return}Z1(r,this.tech_)}),n.length>1){const s=()=>{this.error(null),this.handleSrc_(n.slice(1),!0)},r=()=>{this.off("error",s)};this.one("error",s),this.one("playing",r),this.resetRetryOnError_=()=>{this.off("error",s),this.off("playing",r)}}}src(e){return this.handleSrc_(e,!1)}src_(e){const t=this.selectSource([e]);return t?Jh(t.tech,this.techName_)?(this.ready(function(){this.tech_.constructor.prototype.hasOwnProperty("setSource")?this.techCall_("setSource",e):this.techCall_("src",e.src),this.changingSrc_=!1},!0),!1):(this.changingSrc_=!0,this.loadTech_(t.tech,t.source),this.tech_.ready(()=>{this.changingSrc_=!1}),!1):!0}addSourceElement(e,t){return this.tech_?this.tech_.addSourceElement(e,t):!1}removeSourceElement(e){return this.tech_?this.tech_.removeSourceElement(e):!1}load(){if(this.tech_&&this.tech_.vhs){this.src(this.currentSource());return}this.techCall_("load")}reset(){if(this.paused())this.doReset_();else{const e=this.play();Gt(e.then(()=>this.doReset_()))}}doReset_(){this.tech_&&this.tech_.clearTracks("text"),this.removeClass("vjs-playing"),this.addClass("vjs-paused"),this.resetCache_(),this.poster(""),this.loadTech_(this.options_.techOrder[0],null),this.techCall_("reset"),this.resetControlBarUI_(),this.error(null),this.titleBar&&this.titleBar.update({title:void 0,description:void 0}),si(this)&&this.trigger("playerreset")}resetControlBarUI_(){this.resetProgressBar_(),this.resetPlaybackRate_(),this.resetVolumeBar_()}resetProgressBar_(){this.currentTime(0);const{currentTimeDisplay:e,durationDisplay:t,progressControl:n,remainingTimeDisplay:s}=this.controlBar||{},{seekBar:r}=n||{};e&&e.updateContent(),t&&t.updateContent(),s&&s.updateContent(),r&&(r.update(),r.loadProgressBar&&r.loadProgressBar.update())}resetPlaybackRate_(){this.playbackRate(this.defaultPlaybackRate()),this.handleTechRateChange_()}resetVolumeBar_(){this.volume(1),this.trigger("volumechange")}currentSources(){const e=this.currentSource(),t=[];return Object.keys(e).length!==0&&t.push(e),this.cache_.sources||t}currentSource(){return this.cache_.source||{}}currentSrc(){return this.currentSource()&&this.currentSource().src||""}currentType(){return this.currentSource()&&this.currentSource().type||""}preload(e){if(e!==void 0){this.techCall_("setPreload",e),this.options_.preload=e;return}return this.techGet_("preload")}autoplay(e){if(e===void 0)return this.options_.autoplay||!1;let t;typeof e=="string"&&/(any|play|muted)/.test(e)||e===!0&&this.options_.normalizeAutoplay?(this.options_.autoplay=e,this.manualAutoplay_(typeof e=="string"?e:"play"),t=!1):e?this.options_.autoplay=!0:this.options_.autoplay=!1,t=typeof t>"u"?this.options_.autoplay:t,this.tech_&&this.techCall_("setAutoplay",t)}playsinline(e){return e!==void 0&&(this.techCall_("setPlaysinline",e),this.options_.playsinline=e),this.techGet_("playsinline")}loop(e){if(e!==void 0){this.techCall_("setLoop",e),this.options_.loop=e;return}return this.techGet_("loop")}poster(e){if(e===void 0)return this.poster_;e||(e=""),e!==this.poster_&&(this.poster_=e,this.techCall_("setPoster",e),this.isPosterFromTech_=!1,this.trigger("posterchange"))}handleTechPosterChange_(){if((!this.poster_||this.options_.techCanOverridePoster)&&this.tech_&&this.tech_.poster){const e=this.tech_.poster()||"";e!==this.poster_&&(this.poster_=e,this.isPosterFromTech_=!0,this.trigger("posterchange"))}}controls(e){if(e===void 0)return!!this.controls_;e=!!e,this.controls_!==e&&(this.controls_=e,this.usingNativeControls()&&this.techCall_("setControls",e),this.controls_?(this.removeClass("vjs-controls-disabled"),this.addClass("vjs-controls-enabled"),this.trigger("controlsenabled"),this.usingNativeControls()||this.addTechControlsListeners_()):(this.removeClass("vjs-controls-enabled"),this.addClass("vjs-controls-disabled"),this.trigger("controlsdisabled"),this.usingNativeControls()||this.removeTechControlsListeners_()))}usingNativeControls(e){if(e===void 0)return!!this.usingNativeControls_;e=!!e,this.usingNativeControls_!==e&&(this.usingNativeControls_=e,this.usingNativeControls_?(this.addClass("vjs-using-native-controls"),this.trigger("usingnativecontrols")):(this.removeClass("vjs-using-native-controls"),this.trigger("usingcustomcontrols")))}error(e){if(e===void 0)return this.error_||null;if(Ti("beforeerror").forEach(t=>{const n=t(this,e);if(!(Qt(n)&&!Array.isArray(n)||typeof n=="string"||typeof n=="number"||n===null)){this.log.error("please return a value that MediaError expects in beforeerror hooks");return}e=n}),this.options_.suppressNotSupportedError&&e&&e.code===4){const t=function(){this.error(e)};this.options_.suppressNotSupportedError=!1,this.any(["click","touchstart"],t),this.one("loadstart",function(){this.off(["click","touchstart"],t)});return}if(e===null){this.error_=null,this.removeClass("vjs-error"),this.errorDisplay&&this.errorDisplay.close();return}this.error_=new Me(e),this.addClass("vjs-error"),oe.error(`(CODE:${this.error_.code} ${Me.errorTypes[this.error_.code]})`,this.error_.message,this.error_),this.trigger("error"),Ti("error").forEach(t=>t(this,this.error_))}reportUserActivity(e){this.userActivity_=!0}userActive(e){if(e===void 0)return this.userActive_;if(e=!!e,e!==this.userActive_){if(this.userActive_=e,this.userActive_){this.userActivity_=!0,this.removeClass("vjs-user-inactive"),this.addClass("vjs-user-active"),this.trigger("useractive");return}this.tech_&&this.tech_.one("mousemove",function(t){t.stopPropagation(),t.preventDefault()}),this.userActivity_=!1,this.removeClass("vjs-user-active"),this.addClass("vjs-user-inactive"),this.trigger("userinactive")}}listenForUserActivity_(){let e,t,n;const s=Ce(this,this.reportUserActivity),r=function(b){(b.screenX!==t||b.screenY!==n)&&(t=b.screenX,n=b.screenY,s())},a=function(){s(),this.clearInterval(e),e=this.setInterval(s,250)},l=function(b){s(),this.clearInterval(e)};this.on("mousedown",a),this.on("mousemove",r),this.on("mouseup",l),this.on("mouseleave",l);const c=this.getChild("controlBar");c&&!Je&&!Nt&&(c.on("mouseenter",function(b){this.player().options_.inactivityTimeout!==0&&(this.player().cache_.inactivityTimeout=this.player().options_.inactivityTimeout),this.player().options_.inactivityTimeout=0}),c.on("mouseleave",function(b){this.player().options_.inactivityTimeout=this.player().cache_.inactivityTimeout})),this.on("keydown",s),this.on("keyup",s);let f;const m=function(){if(!this.userActivity_)return;this.userActivity_=!1,this.userActive(!0),this.clearTimeout(f);const b=this.options_.inactivityTimeout;b<=0||(f=this.setTimeout(function(){this.userActivity_||this.userActive(!1)},b))};this.setInterval(m,250)}playbackRate(e){if(e!==void 0){this.techCall_("setPlaybackRate",e);return}return this.tech_&&this.tech_.featuresPlaybackRate?this.cache_.lastPlaybackRate||this.techGet_("playbackRate"):1}defaultPlaybackRate(e){return e!==void 0?this.techCall_("setDefaultPlaybackRate",e):this.tech_&&this.tech_.featuresPlaybackRate?this.techGet_("defaultPlaybackRate"):1}isAudio(e){if(e!==void 0){this.isAudio_=!!e;return}return!!this.isAudio_}updatePlayerHeightOnAudioOnlyMode_(){const e=this.getChild("ControlBar");!e||this.audioOnlyCache_.controlBarHeight===e.currentHeight()||(this.audioOnlyCache_.controlBarHeight=e.currentHeight(),this.height(this.audioOnlyCache_.controlBarHeight))}enableAudioOnlyUI_(){this.addClass("vjs-audio-only-mode");const e=this.children(),t=this.getChild("ControlBar"),n=t&&t.currentHeight();e.forEach(s=>{s!==t&&s.el_&&!s.hasClass("vjs-hidden")&&(s.hide(),this.audioOnlyCache_.hiddenChildren.push(s))}),this.audioOnlyCache_.playerHeight=this.currentHeight(),this.audioOnlyCache_.controlBarHeight=n,this.on("playerresize",this.boundUpdatePlayerHeightOnAudioOnlyMode_),this.height(n),this.trigger("audioonlymodechange")}disableAudioOnlyUI_(){this.removeClass("vjs-audio-only-mode"),this.off("playerresize",this.boundUpdatePlayerHeightOnAudioOnlyMode_),this.audioOnlyCache_.hiddenChildren.forEach(e=>e.show()),this.height(this.audioOnlyCache_.playerHeight),this.trigger("audioonlymodechange")}audioOnlyMode(e){if(typeof e!="boolean"||e===this.audioOnlyMode_)return this.audioOnlyMode_;if(this.audioOnlyMode_=e,e){const t=[];return this.isInPictureInPicture()&&t.push(this.exitPictureInPicture()),this.isFullscreen()&&t.push(this.exitFullscreen()),this.audioPosterMode()&&t.push(this.audioPosterMode(!1)),Promise.all(t).then(()=>this.enableAudioOnlyUI_())}return Promise.resolve().then(()=>this.disableAudioOnlyUI_())}enablePosterModeUI_(){(this.tech_&&this.tech_).hide(),this.addClass("vjs-audio-poster-mode"),this.trigger("audiopostermodechange")}disablePosterModeUI_(){(this.tech_&&this.tech_).show(),this.removeClass("vjs-audio-poster-mode"),this.trigger("audiopostermodechange")}audioPosterMode(e){return typeof e!="boolean"||e===this.audioPosterMode_?this.audioPosterMode_:(this.audioPosterMode_=e,e?this.audioOnlyMode()?this.audioOnlyMode(!1).then(()=>{this.enablePosterModeUI_()}):Promise.resolve().then(()=>{this.enablePosterModeUI_()}):Promise.resolve().then(()=>{this.disablePosterModeUI_()}))}addTextTrack(e,t,n){if(this.tech_)return this.tech_.addTextTrack(e,t,n)}addRemoteTextTrack(e,t){if(this.tech_)return this.tech_.addRemoteTextTrack(e,t)}removeRemoteTextTrack(e={}){let{track:t}=e;if(t||(t=e),this.tech_)return this.tech_.removeRemoteTextTrack(t)}getVideoPlaybackQuality(){return this.techGet_("getVideoPlaybackQuality")}videoWidth(){return this.tech_&&this.tech_.videoWidth&&this.tech_.videoWidth()||0}videoHeight(){return this.tech_&&this.tech_.videoHeight&&this.tech_.videoHeight()||0}language(e){if(e===void 0)return this.language_;this.language_!==String(e).toLowerCase()&&(this.language_=String(e).toLowerCase(),si(this)&&this.trigger("languagechange"))}languages(){return ve(Ae.prototype.options_.languages,this.languages_)}toJSON(){const e=ve(this.options_),t=e.tracks;e.tracks=[];for(let n=0;n<t.length;n++){let s=t[n];s=ve(s),s.player=void 0,e.tracks[n]=s}return e}createModal(e,t){t=t||{},t.content=e||"";const n=new Cn(this,t);return this.addChild(n),n.on("dispose",()=>{this.removeChild(n)}),n.open(),n}updateCurrentBreakpoint_(){if(!this.responsive())return;const e=this.currentBreakpoint(),t=this.currentWidth();for(let n=0;n<ro.length;n++){const s=ro[n],r=this.breakpoints_[s];if(t<=r){if(e===s)return;e&&this.removeClass(sr[e]),this.addClass(sr[s]),this.breakpoint_=s;break}}}removeCurrentBreakpoint_(){const e=this.currentBreakpointClass();this.breakpoint_="",e&&this.removeClass(e)}breakpoints(e){return e===void 0?Object.assign(this.breakpoints_):(this.breakpoint_="",this.breakpoints_=Object.assign({},jb,e),this.updateCurrentBreakpoint_(),Object.assign(this.breakpoints_))}responsive(e){if(e===void 0)return this.responsive_;e=!!e;const t=this.responsive_;if(e!==t)return this.responsive_=e,e?(this.on("playerresize",this.boundUpdateCurrentBreakpoint_),this.updateCurrentBreakpoint_()):(this.off("playerresize",this.boundUpdateCurrentBreakpoint_),this.removeCurrentBreakpoint_()),e}currentBreakpoint(){return this.breakpoint_}currentBreakpointClass(){return sr[this.breakpoint_]||""}loadMedia(e,t){if(!e||typeof e!="object")return;const n=this.crossOrigin();this.reset(),this.cache_.media=ve(e);const{artist:s,artwork:r,description:a,poster:l,src:c,textTracks:f,title:m}=this.cache_.media;!r&&l&&(this.cache_.media.artwork=[{src:l,type:Tr(l)}]),n&&this.crossOrigin(n),c&&this.src(c),l&&this.poster(l),Array.isArray(f)&&f.forEach(b=>this.addRemoteTextTrack(b,!1)),this.titleBar&&this.titleBar.update({title:m,description:a||s||""}),this.ready(t)}getMedia(){if(!this.cache_.media){const e=this.poster(),t=this.currentSources(),n=Array.prototype.map.call(this.remoteTextTracks(),r=>({kind:r.kind,label:r.label,language:r.language,src:r.src})),s={src:t,textTracks:n};return e&&(s.poster=e,s.artwork=[{src:s.poster,type:Tr(s.poster)}]),s}return ve(this.cache_.media)}static getTagSettings(e){const t={sources:[],tracks:[]},n=_i(e),s=n["data-setup"];if(os(e,"vjs-fill")&&(n.fill=!0),os(e,"vjs-fluid")&&(n.fluid=!0),s!==null)try{Object.assign(n,JSON.parse(s||"{}"))}catch(r){oe.error("data-setup",r)}if(Object.assign(t,n),e.hasChildNodes()){const r=e.childNodes;for(let a=0,l=r.length;a<l;a++){const c=r[a],f=c.nodeName.toLowerCase();f==="source"?t.sources.push(_i(c)):f==="track"&&t.tracks.push(_i(c))}}return t}debug(e){if(e===void 0)return this.debugEnabled_;e?(this.trigger("debugon"),this.previousLogLevel_=this.log.level,this.log.level("debug"),this.debugEnabled_=!0):(this.trigger("debugoff"),this.log.level(this.previousLogLevel_),this.previousLogLevel_=void 0,this.debugEnabled_=!1)}playbackRates(e){if(e===void 0)return this.cache_.playbackRates;Array.isArray(e)&&e.every(t=>typeof t=="number")&&(this.cache_.playbackRates=e,this.trigger("playbackrateschange"))}}at.names.forEach(function(i){const e=at[i];Ae.prototype[e.getterName]=function(){return this.tech_?this.tech_[e.getterName]():(this[e.privateName]=this[e.privateName]||new e.ListClass,this[e.privateName])}});Ae.prototype.crossorigin=Ae.prototype.crossOrigin;Ae.players={};const Qn=x.navigator;Ae.prototype.options_={techOrder:ae.defaultTechOrder_,html5:{},enableSourceset:!0,inactivityTimeout:2e3,playbackRates:[],liveui:!1,children:["mediaLoader","posterImage","titleBar","textTrackDisplay","loadingSpinner","bigPlayButton","liveTracker","controlBar","errorDisplay","textTrackSettings","resizeManager"],language:Qn&&(Qn.languages&&Qn.languages[0]||Qn.userLanguage||Qn.language)||"en",languages:{},notSupportedMessage:"No compatible source was found for this media.",normalizeAutoplay:!1,fullscreen:{options:{navigationUI:"hide"}},breakpoints:{},responsive:!1,audioOnlyMode:!1,audioPosterMode:!1,spatialNavigation:{enabled:!1,horizontalSeek:!1},enableSmoothSeeking:!1,disableSeekWhileScrubbingOnMobile:!1};Nc.forEach(function(i){Ae.prototype[`handleTech${Ne(i)}_`]=function(){return this.trigger(i)}});H.registerComponent("Player",Ae);const vr="plugin",on="activePlugins_",en={},Sr=i=>en.hasOwnProperty(i),rr=i=>Sr(i)?en[i]:void 0,Bc=(i,e)=>{i[on]=i[on]||{},i[on][e]=!0},Er=(i,e,t)=>{const n=(t?"before":"")+"pluginsetup";i.trigger(n,e),i.trigger(n+":"+e.name,e)},$b=function(i,e){const t=function(){Er(this,{name:i,plugin:e,instance:null},!0);const n=e.apply(this,arguments);return Bc(this,i),Er(this,{name:i,plugin:e,instance:n}),n};return Object.keys(e).forEach(function(n){t[n]=e[n]}),t},rd=(i,e)=>(e.prototype.name=i,function(...t){Er(this,{name:i,plugin:e,instance:null},!0);const n=new e(this,...t);return this[i]=()=>n,Er(this,n.getEventHash()),n});class ft{constructor(e){if(this.constructor===ft)throw new Error("Plugin must be sub-classed; not directly instantiated.");this.player=e,this.log||(this.log=this.player.log.createLogger(this.name)),qo(this),delete this.trigger,Qh(this,this.constructor.defaultState),Bc(e,this.name),this.dispose=this.dispose.bind(this),e.on("dispose",this.dispose)}version(){return this.constructor.VERSION}getEventHash(e={}){return e.name=this.name,e.plugin=this.constructor,e.instance=this,e}trigger(e,t={}){return kn(this.eventBusEl_,e,this.getEventHash(t))}handleStateChanged(e){}dispose(){const{name:e,player:t}=this;this.trigger("dispose"),this.off(),t.off("dispose",this.dispose),t[on][e]=!1,this.player=this.state=null,t[e]=rd(e,en[e])}static isBasic(e){const t=typeof e=="string"?rr(e):e;return typeof t=="function"&&!ft.prototype.isPrototypeOf(t.prototype)}static registerPlugin(e,t){if(typeof e!="string")throw new Error(`Illegal plugin name, "${e}", must be a string, was ${typeof e}.`);if(Sr(e))oe.warn(`A plugin named "${e}" already exists. You may want to avoid re-registering plugins!`);else if(Ae.prototype.hasOwnProperty(e))throw new Error(`Illegal plugin name, "${e}", cannot share a name with an existing player method!`);if(typeof t!="function")throw new Error(`Illegal plugin for "${e}", must be a function, was ${typeof t}.`);return en[e]=t,e!==vr&&(ft.isBasic(t)?Ae.prototype[e]=$b(e,t):Ae.prototype[e]=rd(e,t)),t}static deregisterPlugin(e){if(e===vr)throw new Error("Cannot de-register base plugin.");Sr(e)&&(delete en[e],delete Ae.prototype[e])}static getPlugins(e=Object.keys(en)){let t;return e.forEach(n=>{const s=rr(n);s&&(t=t||{},t[n]=s)}),t}static getPluginVersion(e){const t=rr(e);return t&&t.VERSION||""}}ft.getPlugin=rr;ft.BASE_PLUGIN_NAME=vr;ft.registerPlugin(vr,ft);Ae.prototype.usingPlugin=function(i){return!!this[on]&&this[on][i]===!0};Ae.prototype.hasPlugin=function(i){return!!Sr(i)};function qb(i,e){let t=!1;return function(...n){return t||oe.warn(i),t=!0,e.apply(this,n)}}function Bt(i,e,t,n){return qb(`${e} is deprecated and will be removed in ${i}.0; please use ${t} instead.`,n)}var Vb={NetworkBadStatus:"networkbadstatus",NetworkRequestFailed:"networkrequestfailed",NetworkRequestAborted:"networkrequestaborted",NetworkRequestTimeout:"networkrequesttimeout",NetworkBodyParserFailed:"networkbodyparserfailed",StreamingHlsPlaylistParserError:"streaminghlsplaylistparsererror",StreamingDashManifestParserError:"streamingdashmanifestparsererror",StreamingContentSteeringParserError:"streamingcontentsteeringparsererror",StreamingVttParserError:"streamingvttparsererror",StreamingFailedToSelectNextSegment:"streamingfailedtoselectnextsegment",StreamingFailedToDecryptSegment:"streamingfailedtodecryptsegment",StreamingFailedToTransmuxSegment:"streamingfailedtotransmuxsegment",StreamingFailedToAppendSegment:"streamingfailedtoappendsegment",StreamingCodecsChangeError:"streamingcodecschangeerror"};const Fc=i=>i.indexOf("#")===0?i.slice(1):i;function B(i,e,t){let n=B.getPlayer(i);if(n)return e&&oe.warn(`Player "${i}" is already initialised. Options will not be applied.`),t&&n.ready(t),n;const s=typeof i=="string"?vi("#"+Fc(i)):i;if(!wn(s))throw new TypeError("The element or ID supplied is not valid. (videojs)");const r="getRootNode"in s&&s.getRootNode()instanceof x.ShadowRoot?s.getRootNode():s.ownerDocument.body;(!s.ownerDocument.defaultView||!r.contains(s))&&oe.warn("The element supplied is not included in the DOM"),e=e||{},e.restoreEl===!0&&(e.restoreEl=(s.parentNode&&s.parentNode.hasAttribute&&s.parentNode.hasAttribute("data-vjs-player")?s.parentNode:s).cloneNode(!0)),Ti("beforesetup").forEach(l=>{const c=l(s,ve(e));if(!Qt(c)||Array.isArray(c)){oe.error("please return an object in beforesetup hooks");return}e=ve(e,c)});const a=H.getComponent("Player");return n=new a(s,e,t),Ti("setup").forEach(l=>l(n)),n}B.hooks_=ii;B.hooks=Ti;B.hook=v1;B.hookOnce=S1;B.removeHook=Sh;if(x.VIDEOJS_NO_DYNAMIC_STYLE!==!0&&En()){let i=vi(".vjs-styles-defaults");if(!i){i=Wh("vjs-styles-defaults");const e=vi("head");e&&e.insertBefore(i,e.firstChild),Gh(i,`
|
|
178
|
+
`),this.tech_}version(){return{"video.js":Ja}}addTechControlsListeners_(){this.removeTechControlsListeners_(),this.on(this.tech_,"click",this.boundHandleTechClick_),this.on(this.tech_,"dblclick",this.boundHandleTechDoubleClick_),this.on(this.tech_,"touchstart",this.boundHandleTechTouchStart_),this.on(this.tech_,"touchmove",this.boundHandleTechTouchMove_),this.on(this.tech_,"touchend",this.boundHandleTechTouchEnd_),this.on(this.tech_,"tap",this.boundHandleTechTap_)}removeTechControlsListeners_(){this.off(this.tech_,"tap",this.boundHandleTechTap_),this.off(this.tech_,"touchstart",this.boundHandleTechTouchStart_),this.off(this.tech_,"touchmove",this.boundHandleTechTouchMove_),this.off(this.tech_,"touchend",this.boundHandleTechTouchEnd_),this.off(this.tech_,"click",this.boundHandleTechClick_),this.off(this.tech_,"dblclick",this.boundHandleTechDoubleClick_)}handleTechReady_(){this.triggerReady(),this.cache_.volume&&this.techCall_("setVolume",this.cache_.volume),this.handleTechPosterChange_(),this.handleTechDurationChange_()}handleTechLoadStart_(){this.removeClass("vjs-ended","vjs-seeking"),this.error(null),this.handleTechDurationChange_(),this.paused()?(this.hasStarted(!1),this.trigger("loadstart")):this.trigger("loadstart"),this.manualAutoplay_(this.autoplay()===!0&&this.options_.normalizeAutoplay?"play":this.autoplay())}manualAutoplay_(e){if(!this.tech_||typeof e!="string")return;const t=()=>{const n=this.muted();this.muted(!0);const r=()=>{this.muted(n)};this.playTerminatedQueue_.push(r);const a=this.play();if(pn(a))return a.catch(l=>{throw r(),new Error(`Rejection at manualAutoplay. Restoring muted value. ${l||""}`)})};let i;if(e==="any"&&!this.muted()?(i=this.play(),pn(i)&&(i=i.catch(t))):e==="muted"&&!this.muted()?i=t():i=this.play(),!!pn(i))return i.then(()=>{this.trigger({type:"autoplay-success",autoplay:e})}).catch(()=>{this.trigger({type:"autoplay-failure",autoplay:e})})}updateSourceCaches_(e=""){let t=e,i="";typeof t!="string"&&(t=e.src,i=e.type),this.cache_.source=this.cache_.source||{},this.cache_.sources=this.cache_.sources||[],t&&!i&&(i=sv(this,t)),this.cache_.source=xe({},e,{src:t,type:i});const n=this.cache_.sources.filter(h=>h.src&&h.src===t),r=[],a=this.$$("source"),l=[];for(let h=0;h<a.length;h++){const f=bi(a[h]);r.push(f),f.src&&f.src===t&&l.push(f.src)}l.length&&!n.length?this.cache_.sources=r:n.length||(this.cache_.sources=[this.cache_.source]),this.cache_.src=t}handleTechSourceset_(e){if(!this.changingSrc_){let t=r=>this.updateSourceCaches_(r);const i=this.currentSource().src,n=e.src;i&&!/^blob:/.test(i)&&/^blob:/.test(n)&&(!this.lastSource_||this.lastSource_.tech!==n&&this.lastSource_.player!==i)&&(t=()=>{}),t(n),e.src||this.tech_.any(["sourceset","loadstart"],r=>{if(r.type==="sourceset")return;const a=this.techGet_("currentSrc");this.lastSource_.tech=a,this.updateSourceCaches_(a)})}this.lastSource_={player:this.currentSource().src,tech:e.src},this.trigger({src:e.src,type:"sourceset"})}hasStarted(e){if(e===void 0)return this.hasStarted_;e!==this.hasStarted_&&(this.hasStarted_=e,this.hasStarted_?this.addClass("vjs-has-started"):this.removeClass("vjs-has-started"))}handleTechPlay_(){this.removeClass("vjs-ended","vjs-paused"),this.addClass("vjs-playing"),this.hasStarted(!0),this.trigger("play")}handleTechRateChange_(){this.tech_.playbackRate()>0&&this.cache_.lastPlaybackRate===0&&(this.queuedCallbacks_.forEach(e=>e.callback(e.event)),this.queuedCallbacks_=[]),this.cache_.lastPlaybackRate=this.tech_.playbackRate(),this.trigger("ratechange")}handleTechWaiting_(){this.addClass("vjs-waiting"),this.trigger("waiting");const e=this.currentTime(),t=()=>{e!==this.currentTime()&&(this.removeClass("vjs-waiting"),this.off("timeupdate",t))};this.on("timeupdate",t)}handleTechCanPlay_(){this.removeClass("vjs-waiting"),this.trigger("canplay")}handleTechCanPlayThrough_(){this.removeClass("vjs-waiting"),this.trigger("canplaythrough")}handleTechPlaying_(){this.removeClass("vjs-waiting"),this.trigger("playing")}handleTechSeeking_(){this.addClass("vjs-seeking"),this.trigger("seeking")}handleTechSeeked_(){this.removeClass("vjs-seeking","vjs-ended"),this.trigger("seeked")}handleTechPause_(){this.removeClass("vjs-playing"),this.addClass("vjs-paused"),this.trigger("pause")}handleTechEnded_(){this.addClass("vjs-ended"),this.removeClass("vjs-waiting"),this.options_.loop?(this.currentTime(0),this.play()):this.paused()||this.pause(),this.trigger("ended")}handleTechDurationChange_(){this.duration(this.techGet_("duration"))}handleTechClick_(e){this.controls_&&(this.options_===void 0||this.options_.userActions===void 0||this.options_.userActions.click===void 0||this.options_.userActions.click!==!1)&&(this.options_!==void 0&&this.options_.userActions!==void 0&&typeof this.options_.userActions.click=="function"?this.options_.userActions.click.call(this,e):this.paused()?Kt(this.play()):this.pause())}handleTechDoubleClick_(e){if(!this.controls_)return;Array.prototype.some.call(this.$$(".vjs-control-bar, .vjs-modal-dialog"),i=>i.contains(e.target))||(this.options_===void 0||this.options_.userActions===void 0||this.options_.userActions.doubleClick===void 0||this.options_.userActions.doubleClick!==!1)&&(this.options_!==void 0&&this.options_.userActions!==void 0&&typeof this.options_.userActions.doubleClick=="function"?this.options_.userActions.doubleClick.call(this,e):this.isInPictureInPicture()&&!K.pictureInPictureElement?this.exitPictureInPicture():this.isFullscreen()?this.exitFullscreen():this.requestFullscreen())}handleTechTap_(){this.userActive(!this.userActive())}handleTechTouchStart_(){this.userWasActive=this.userActive()}handleTechTouchMove_(){this.userWasActive&&this.reportUserActivity()}handleTechTouchEnd_(e){e.cancelable&&e.preventDefault()}toggleFullscreenClass_(){this.isFullscreen()?this.addClass("vjs-fullscreen"):this.removeClass("vjs-fullscreen")}documentFullscreenChange_(e){const t=e.target.player;if(t&&t!==this)return;const i=this.el();let n=K[this.fsApi_.fullscreenElement]===i;!n&&i.matches&&(n=i.matches(":"+this.fsApi_.fullscreen)),this.isFullscreen(n)}handleTechFullscreenChange_(e,t){t&&(t.nativeIOSFullscreen&&(this.addClass("vjs-ios-native-fs"),this.tech_.one("webkitendfullscreen",()=>{this.removeClass("vjs-ios-native-fs")})),this.isFullscreen(t.isFullscreen))}handleTechFullscreenError_(e,t){this.trigger("fullscreenerror",t)}togglePictureInPictureClass_(){this.isInPictureInPicture()?this.addClass("vjs-picture-in-picture"):this.removeClass("vjs-picture-in-picture")}handleTechEnterPictureInPicture_(e){this.isInPictureInPicture(!0)}handleTechLeavePictureInPicture_(e){this.isInPictureInPicture(!1)}handleTechError_(){const e=this.tech_.error();e&&this.error(e)}handleTechTextData_(){let e=null;arguments.length>1&&(e=arguments[1]),this.trigger("textdata",e)}getCache(){return this.cache_}resetCache_(){this.cache_={currentTime:0,initTime:0,inactivityTimeout:this.options_.inactivityTimeout,duration:NaN,lastVolume:1,lastPlaybackRate:this.defaultPlaybackRate(),media:null,src:"",source:{},sources:[],playbackRates:[],volume:1}}techCall_(e,t){this.ready(function(){if(e in JT)return YT(this.middleware_,this.tech_,e,t);if(e in Vu)return ju(this.middleware_,this.tech_,e,t);try{this.tech_&&this.tech_[e](t)}catch(i){throw ue(i),i}},!0)}techGet_(e){if(!(!this.tech_||!this.tech_.isReady_)){if(e in QT)return XT(this.middleware_,this.tech_,e);if(e in Vu)return ju(this.middleware_,this.tech_,e);try{return this.tech_[e]()}catch(t){throw this.tech_[e]===void 0?(ue(`Video.js: ${e} method not defined for ${this.techName_} playback technology.`,t),t):t.name==="TypeError"?(ue(`Video.js: ${e} unavailable on ${this.techName_} playback technology element.`,t),this.tech_.isReady_=!1,t):(ue(t),t)}}}play(){return new Promise(e=>{this.play_(e)})}play_(e=Kt){this.playCallbacks_.push(e);const t=!!(!this.changingSrc_&&(this.src()||this.currentSrc())),i=!!(Wr||Ze);if(this.waitToPlay_&&(this.off(["ready","loadstart"],this.waitToPlay_),this.waitToPlay_=null),!this.isReady_||!t){this.waitToPlay_=a=>{this.play_()},this.one(["ready","loadstart"],this.waitToPlay_),!t&&i&&this.load();return}const n=this.techGet_("play");i&&this.hasClass("vjs-ended")&&this.resetProgressBar_(),n===null?this.runPlayTerminatedQueue_():this.runPlayCallbacks_(n)}runPlayTerminatedQueue_(){const e=this.playTerminatedQueue_.slice(0);this.playTerminatedQueue_=[],e.forEach(function(t){t()})}runPlayCallbacks_(e){const t=this.playCallbacks_.slice(0);this.playCallbacks_=[],this.playTerminatedQueue_=[],t.forEach(function(i){i(e)})}pause(){this.techCall_("pause")}paused(){return this.techGet_("paused")!==!1}played(){return this.techGet_("played")||Nt(0,0)}scrubbing(e){if(typeof e>"u")return this.scrubbing_;this.scrubbing_=!!e,this.techCall_("setScrubbing",this.scrubbing_),e?this.addClass("vjs-scrubbing"):this.removeClass("vjs-scrubbing")}currentTime(e){if(e===void 0)return this.cache_.currentTime=this.techGet_("currentTime")||0,this.cache_.currentTime;if(e<0&&(e=0),!this.isReady_||this.changingSrc_||!this.tech_||!this.tech_.isReady_){this.cache_.initTime=e,this.off("canplay",this.boundApplyInitTime_),this.one("canplay",this.boundApplyInitTime_);return}this.techCall_("setCurrentTime",e),this.cache_.initTime=0,isFinite(e)&&(this.cache_.currentTime=Number(e))}applyInitTime_(){this.currentTime(this.cache_.initTime)}duration(e){if(e===void 0)return this.cache_.duration!==void 0?this.cache_.duration:NaN;e=parseFloat(e),e<0&&(e=1/0),e!==this.cache_.duration&&(this.cache_.duration=e,e===1/0?this.addClass("vjs-live"):this.removeClass("vjs-live"),isNaN(e)||this.trigger("durationchange"))}remainingTime(){return this.duration()-this.currentTime()}remainingTimeDisplay(){return Math.floor(this.duration())-Math.floor(this.currentTime())}buffered(){let e=this.techGet_("buffered");return(!e||!e.length)&&(e=Nt(0,0)),e}seekable(){let e=this.techGet_("seekable");return(!e||!e.length)&&(e=Nt(0,0)),e}seeking(){return this.techGet_("seeking")}ended(){return this.techGet_("ended")}networkState(){return this.techGet_("networkState")}readyState(){return this.techGet_("readyState")}bufferedPercent(){return ih(this.buffered(),this.duration())}bufferedEnd(){const e=this.buffered(),t=this.duration();let i=e.end(e.length-1);return i>t&&(i=t),i}volume(e){let t;if(e!==void 0){t=Math.max(0,Math.min(1,e)),this.cache_.volume=t,this.techCall_("setVolume",t),t>0&&this.lastVolume_(t);return}return t=parseFloat(this.techGet_("volume")),isNaN(t)?1:t}muted(e){if(e!==void 0){this.techCall_("setMuted",e);return}return this.techGet_("muted")||!1}defaultMuted(e){return e!==void 0&&this.techCall_("setDefaultMuted",e),this.techGet_("defaultMuted")||!1}lastVolume_(e){if(e!==void 0&&e!==0){this.cache_.lastVolume=e;return}return this.cache_.lastVolume}supportsFullScreen(){return this.techGet_("supportsFullScreen")||!1}isFullscreen(e){if(e!==void 0){const t=this.isFullscreen_;this.isFullscreen_=!!e,this.isFullscreen_!==t&&this.fsApi_.prefixed&&this.trigger("fullscreenchange"),this.toggleFullscreenClass_();return}return this.isFullscreen_}requestFullscreen(e){this.isInPictureInPicture()&&this.exitPictureInPicture();const t=this;return new Promise((i,n)=>{function r(){t.off("fullscreenerror",l),t.off("fullscreenchange",a)}function a(){r(),i()}function l(f,m){r(),n(m)}t.one("fullscreenchange",a),t.one("fullscreenerror",l);const h=t.requestFullscreenHelper_(e);h&&(h.then(r,r),h.then(i,n))})}requestFullscreenHelper_(e){let t;if(this.fsApi_.prefixed||(t=this.options_.fullscreen&&this.options_.fullscreen.options||{},e!==void 0&&(t=e)),this.fsApi_.requestFullscreen){const i=this.el_[this.fsApi_.requestFullscreen](t);return i&&i.then(()=>this.isFullscreen(!0),()=>this.isFullscreen(!1)),i}else this.tech_.supportsFullScreen()&&!this.options_.preferFullWindow?this.techCall_("enterFullScreen"):this.enterFullWindow()}exitFullscreen(){const e=this;return new Promise((t,i)=>{function n(){e.off("fullscreenerror",a),e.off("fullscreenchange",r)}function r(){n(),t()}function a(h,f){n(),i(f)}e.one("fullscreenchange",r),e.one("fullscreenerror",a);const l=e.exitFullscreenHelper_();l&&(l.then(n,n),l.then(t,i))})}exitFullscreenHelper_(){if(this.fsApi_.requestFullscreen){const e=K[this.fsApi_.exitFullscreen]();return e&&Kt(e.then(()=>this.isFullscreen(!1))),e}else this.tech_.supportsFullScreen()&&!this.options_.preferFullWindow?this.techCall_("exitFullScreen"):this.exitFullWindow()}enterFullWindow(){this.isFullscreen(!0),this.isFullWindow=!0,this.docOrigOverflow=K.documentElement.style.overflow,vt(K,"keydown",this.boundFullWindowOnEscKey_),K.documentElement.style.overflow="hidden",Fi(K.body,"vjs-full-window"),this.trigger("enterFullWindow")}fullWindowOnEscKey(e){e.key==="Escape"&&this.isFullscreen()===!0&&(this.isFullWindow?this.exitFullWindow():this.exitFullscreen())}exitFullWindow(){this.isFullscreen(!1),this.isFullWindow=!1,et(K,"keydown",this.boundFullWindowOnEscKey_),K.documentElement.style.overflow=this.docOrigOverflow,Gr(K.body,"vjs-full-window"),this.trigger("exitFullWindow")}disablePictureInPicture(e){if(e===void 0)return this.techGet_("disablePictureInPicture");this.techCall_("setDisablePictureInPicture",e),this.options_.disablePictureInPicture=e,this.trigger("disablepictureinpicturechanged")}isInPictureInPicture(e){if(e!==void 0){this.isInPictureInPicture_=!!e,this.togglePictureInPictureClass_();return}return!!this.isInPictureInPicture_}requestPictureInPicture(){if(this.options_.enableDocumentPictureInPicture&&k.documentPictureInPicture){const e=K.createElement(this.el().tagName);return e.classList=this.el().classList,e.classList.add("vjs-pip-container"),this.posterImage&&e.appendChild(this.posterImage.el().cloneNode(!0)),this.titleBar&&e.appendChild(this.titleBar.el().cloneNode(!0)),e.appendChild(se("p",{className:"vjs-pip-text"},{},this.localize("Playing in picture-in-picture"))),k.documentPictureInPicture.requestWindow({width:this.videoWidth(),height:this.videoHeight()}).then(t=>(Hd(t),this.el_.parentNode.insertBefore(e,this.el_),t.document.body.appendChild(this.el_),t.document.body.classList.add("vjs-pip-window"),this.player_.isInPictureInPicture(!0),this.player_.trigger({type:"enterpictureinpicture",pipWindow:t}),t.addEventListener("pagehide",i=>{const n=i.target.querySelector(".video-js");e.parentNode.replaceChild(n,e),this.player_.isInPictureInPicture(!1),this.player_.trigger("leavepictureinpicture")}),t))}return"pictureInPictureEnabled"in K&&this.disablePictureInPicture()===!1?this.techGet_("requestPictureInPicture"):Promise.reject("No PiP mode is available")}exitPictureInPicture(){if(k.documentPictureInPicture&&k.documentPictureInPicture.window)return k.documentPictureInPicture.window.close(),Promise.resolve();if("pictureInPictureEnabled"in K)return K.exitPictureInPicture()}handleKeyDown(e){const{userActions:t}=this.options_;!t||!t.hotkeys||(n=>{const r=n.tagName.toLowerCase();if(n.isContentEditable)return!0;const a=["button","checkbox","hidden","radio","reset","submit"];return r==="input"?a.indexOf(n.type)===-1:["textarea"].indexOf(r)!==-1})(this.el_.ownerDocument.activeElement)||(typeof t.hotkeys=="function"?t.hotkeys.call(this,e):this.handleHotkeys(e))}handleHotkeys(e){const t=this.options_.userActions?this.options_.userActions.hotkeys:{},{fullscreenKey:i=a=>e.key.toLowerCase()==="f",muteKey:n=a=>e.key.toLowerCase()==="m",playPauseKey:r=a=>e.key.toLowerCase()==="k"||e.key.toLowerCase()===" "}=t;if(i.call(this,e)){e.preventDefault(),e.stopPropagation();const a=H.getComponent("FullscreenToggle");K[this.fsApi_.fullscreenEnabled]!==!1&&a.prototype.handleClick.call(this,e)}else n.call(this,e)?(e.preventDefault(),e.stopPropagation(),H.getComponent("MuteToggle").prototype.handleClick.call(this,e)):r.call(this,e)&&(e.preventDefault(),e.stopPropagation(),H.getComponent("PlayToggle").prototype.handleClick.call(this,e))}canPlayType(e){let t;for(let i=0,n=this.options_.techOrder;i<n.length;i++){const r=n[i];let a=oe.getTech(r);if(a||(a=H.getComponent(r)),!a){ue.error(`The "${r}" tech is undefined. Skipped browser support check for that tech.`);continue}if(a.isSupported()&&(t=a.canPlayType(e),t))return t}return""}selectSource(e){const t=this.options_.techOrder.map(l=>[l,oe.getTech(l)]).filter(([l,h])=>h?h.isSupported():(ue.error(`The "${l}" tech is undefined. Skipped browser support check for that tech.`),!1)),i=function(l,h,f){let m;return l.some(T=>h.some(E=>{if(m=f(T,E),m)return!0})),m};let n;const r=l=>(h,f)=>l(f,h),a=([l,h],f)=>{if(h.canPlaySource(f,this.options_[l.toLowerCase()]))return{source:f,tech:l}};return this.options_.sourceOrder?n=i(e,t,r(a)):n=i(t,e,a),n||!1}handleSrc_(e,t){if(typeof e>"u")return this.cache_.src||"";this.resetRetryOnError_&&this.resetRetryOnError_();const i=oh(e);if(!i.length){this.setTimeout(function(){this.error({code:4,message:this.options_.notSupportedMessage})},0);return}if(this.changingSrc_=!0,t||(this.cache_.sources=i),this.updateSourceCaches_(i[0]),GT(this,i[0],(n,r)=>{if(this.middleware_=r,t||(this.cache_.sources=i),this.updateSourceCaches_(n),this.src_(n)){if(i.length>1)return this.handleSrc_(i.slice(1));this.changingSrc_=!1,this.setTimeout(function(){this.error({code:4,message:this.options_.notSupportedMessage})},0),this.triggerReady();return}KT(r,this.tech_)}),i.length>1){const n=()=>{this.error(null),this.handleSrc_(i.slice(1),!0)},r=()=>{this.off("error",n)};this.one("error",n),this.one("playing",r),this.resetRetryOnError_=()=>{this.off("error",n),this.off("playing",r)}}}src(e){return this.handleSrc_(e,!1)}src_(e){const t=this.selectSource([e]);return t?Jd(t.tech,this.techName_)?(this.ready(function(){this.tech_.constructor.prototype.hasOwnProperty("setSource")?this.techCall_("setSource",e):this.techCall_("src",e.src),this.changingSrc_=!1},!0),!1):(this.changingSrc_=!0,this.loadTech_(t.tech,t.source),this.tech_.ready(()=>{this.changingSrc_=!1}),!1):!0}addSourceElement(e,t){return this.tech_?this.tech_.addSourceElement(e,t):!1}removeSourceElement(e){return this.tech_?this.tech_.removeSourceElement(e):!1}load(){if(this.tech_&&this.tech_.vhs){this.src(this.currentSource());return}this.techCall_("load")}reset(){if(this.paused())this.doReset_();else{const e=this.play();Kt(e.then(()=>this.doReset_()))}}doReset_(){this.tech_&&this.tech_.clearTracks("text"),this.removeClass("vjs-playing"),this.addClass("vjs-paused"),this.resetCache_(),this.poster(""),this.loadTech_(this.options_.techOrder[0],null),this.techCall_("reset"),this.resetControlBarUI_(),this.error(null),this.titleBar&&this.titleBar.update({title:void 0,description:void 0}),ai(this)&&this.trigger("playerreset")}resetControlBarUI_(){this.resetProgressBar_(),this.resetPlaybackRate_(),this.resetVolumeBar_()}resetProgressBar_(){this.currentTime(0);const{currentTimeDisplay:e,durationDisplay:t,progressControl:i,remainingTimeDisplay:n}=this.controlBar||{},{seekBar:r}=i||{};e&&e.updateContent(),t&&t.updateContent(),n&&n.updateContent(),r&&(r.update(),r.loadProgressBar&&r.loadProgressBar.update())}resetPlaybackRate_(){this.playbackRate(this.defaultPlaybackRate()),this.handleTechRateChange_()}resetVolumeBar_(){this.volume(1),this.trigger("volumechange")}currentSources(){const e=this.currentSource(),t=[];return Object.keys(e).length!==0&&t.push(e),this.cache_.sources||t}currentSource(){return this.cache_.source||{}}currentSrc(){return this.currentSource()&&this.currentSource().src||""}currentType(){return this.currentSource()&&this.currentSource().type||""}preload(e){if(e!==void 0){this.techCall_("setPreload",e),this.options_.preload=e;return}return this.techGet_("preload")}autoplay(e){if(e===void 0)return this.options_.autoplay||!1;let t;typeof e=="string"&&/(any|play|muted)/.test(e)||e===!0&&this.options_.normalizeAutoplay?(this.options_.autoplay=e,this.manualAutoplay_(typeof e=="string"?e:"play"),t=!1):e?this.options_.autoplay=!0:this.options_.autoplay=!1,t=typeof t>"u"?this.options_.autoplay:t,this.tech_&&this.techCall_("setAutoplay",t)}playsinline(e){return e!==void 0&&(this.techCall_("setPlaysinline",e),this.options_.playsinline=e),this.techGet_("playsinline")}loop(e){if(e!==void 0){this.techCall_("setLoop",e),this.options_.loop=e;return}return this.techGet_("loop")}poster(e){if(e===void 0)return this.poster_;e||(e=""),e!==this.poster_&&(this.poster_=e,this.techCall_("setPoster",e),this.isPosterFromTech_=!1,this.trigger("posterchange"))}handleTechPosterChange_(){if((!this.poster_||this.options_.techCanOverridePoster)&&this.tech_&&this.tech_.poster){const e=this.tech_.poster()||"";e!==this.poster_&&(this.poster_=e,this.isPosterFromTech_=!0,this.trigger("posterchange"))}}controls(e){if(e===void 0)return!!this.controls_;e=!!e,this.controls_!==e&&(this.controls_=e,this.usingNativeControls()&&this.techCall_("setControls",e),this.controls_?(this.removeClass("vjs-controls-disabled"),this.addClass("vjs-controls-enabled"),this.trigger("controlsenabled"),this.usingNativeControls()||this.addTechControlsListeners_()):(this.removeClass("vjs-controls-enabled"),this.addClass("vjs-controls-disabled"),this.trigger("controlsdisabled"),this.usingNativeControls()||this.removeTechControlsListeners_()))}usingNativeControls(e){if(e===void 0)return!!this.usingNativeControls_;e=!!e,this.usingNativeControls_!==e&&(this.usingNativeControls_=e,this.usingNativeControls_?(this.addClass("vjs-using-native-controls"),this.trigger("usingnativecontrols")):(this.removeClass("vjs-using-native-controls"),this.trigger("usingcustomcontrols")))}error(e){if(e===void 0)return this.error_||null;if(Si("beforeerror").forEach(t=>{const i=t(this,e);if(!(Zt(i)&&!Array.isArray(i)||typeof i=="string"||typeof i=="number"||i===null)){this.log.error("please return a value that MediaError expects in beforeerror hooks");return}e=i}),this.options_.suppressNotSupportedError&&e&&e.code===4){const t=function(){this.error(e)};this.options_.suppressNotSupportedError=!1,this.any(["click","touchstart"],t),this.one("loadstart",function(){this.off(["click","touchstart"],t)});return}if(e===null){this.error_=null,this.removeClass("vjs-error"),this.errorDisplay&&this.errorDisplay.close();return}this.error_=new Ne(e),this.addClass("vjs-error"),ue.error(`(CODE:${this.error_.code} ${Ne.errorTypes[this.error_.code]})`,this.error_.message,this.error_),this.trigger("error"),Si("error").forEach(t=>t(this,this.error_))}reportUserActivity(e){this.userActivity_=!0}userActive(e){if(e===void 0)return this.userActive_;if(e=!!e,e!==this.userActive_){if(this.userActive_=e,this.userActive_){this.userActivity_=!0,this.removeClass("vjs-user-inactive"),this.addClass("vjs-user-active"),this.trigger("useractive");return}this.tech_&&this.tech_.one("mousemove",function(t){t.stopPropagation(),t.preventDefault()}),this.userActivity_=!1,this.removeClass("vjs-user-active"),this.addClass("vjs-user-inactive"),this.trigger("userinactive")}}listenForUserActivity_(){let e,t,i;const n=we(this,this.reportUserActivity),r=function(T){(T.screenX!==t||T.screenY!==i)&&(t=T.screenX,i=T.screenY,n())},a=function(){n(),this.clearInterval(e),e=this.setInterval(n,250)},l=function(T){n(),this.clearInterval(e)};this.on("mousedown",a),this.on("mousemove",r),this.on("mouseup",l),this.on("mouseleave",l);const h=this.getChild("controlBar");h&&!Ze&&!Ut&&(h.on("mouseenter",function(T){this.player().options_.inactivityTimeout!==0&&(this.player().cache_.inactivityTimeout=this.player().options_.inactivityTimeout),this.player().options_.inactivityTimeout=0}),h.on("mouseleave",function(T){this.player().options_.inactivityTimeout=this.player().cache_.inactivityTimeout})),this.on("keydown",n),this.on("keyup",n);let f;const m=function(){if(!this.userActivity_)return;this.userActivity_=!1,this.userActive(!0),this.clearTimeout(f);const T=this.options_.inactivityTimeout;T<=0||(f=this.setTimeout(function(){this.userActivity_||this.userActive(!1)},T))};this.setInterval(m,250)}playbackRate(e){if(e!==void 0){this.techCall_("setPlaybackRate",e);return}return this.tech_&&this.tech_.featuresPlaybackRate?this.cache_.lastPlaybackRate||this.techGet_("playbackRate"):1}defaultPlaybackRate(e){return e!==void 0?this.techCall_("setDefaultPlaybackRate",e):this.tech_&&this.tech_.featuresPlaybackRate?this.techGet_("defaultPlaybackRate"):1}isAudio(e){if(e!==void 0){this.isAudio_=!!e;return}return!!this.isAudio_}updatePlayerHeightOnAudioOnlyMode_(){const e=this.getChild("ControlBar");!e||this.audioOnlyCache_.controlBarHeight===e.currentHeight()||(this.audioOnlyCache_.controlBarHeight=e.currentHeight(),this.height(this.audioOnlyCache_.controlBarHeight))}enableAudioOnlyUI_(){this.addClass("vjs-audio-only-mode");const e=this.children(),t=this.getChild("ControlBar"),i=t&&t.currentHeight();e.forEach(n=>{n!==t&&n.el_&&!n.hasClass("vjs-hidden")&&(n.hide(),this.audioOnlyCache_.hiddenChildren.push(n))}),this.audioOnlyCache_.playerHeight=this.currentHeight(),this.audioOnlyCache_.controlBarHeight=i,this.on("playerresize",this.boundUpdatePlayerHeightOnAudioOnlyMode_),this.height(i),this.trigger("audioonlymodechange")}disableAudioOnlyUI_(){this.removeClass("vjs-audio-only-mode"),this.off("playerresize",this.boundUpdatePlayerHeightOnAudioOnlyMode_),this.audioOnlyCache_.hiddenChildren.forEach(e=>e.show()),this.height(this.audioOnlyCache_.playerHeight),this.trigger("audioonlymodechange")}audioOnlyMode(e){if(typeof e!="boolean"||e===this.audioOnlyMode_)return this.audioOnlyMode_;if(this.audioOnlyMode_=e,e){const t=[];return this.isInPictureInPicture()&&t.push(this.exitPictureInPicture()),this.isFullscreen()&&t.push(this.exitFullscreen()),this.audioPosterMode()&&t.push(this.audioPosterMode(!1)),Promise.all(t).then(()=>this.enableAudioOnlyUI_())}return Promise.resolve().then(()=>this.disableAudioOnlyUI_())}enablePosterModeUI_(){(this.tech_&&this.tech_).hide(),this.addClass("vjs-audio-poster-mode"),this.trigger("audiopostermodechange")}disablePosterModeUI_(){(this.tech_&&this.tech_).show(),this.removeClass("vjs-audio-poster-mode"),this.trigger("audiopostermodechange")}audioPosterMode(e){return typeof e!="boolean"||e===this.audioPosterMode_?this.audioPosterMode_:(this.audioPosterMode_=e,e?this.audioOnlyMode()?this.audioOnlyMode(!1).then(()=>{this.enablePosterModeUI_()}):Promise.resolve().then(()=>{this.enablePosterModeUI_()}):Promise.resolve().then(()=>{this.disablePosterModeUI_()}))}addTextTrack(e,t,i){if(this.tech_)return this.tech_.addTextTrack(e,t,i)}addRemoteTextTrack(e,t){if(this.tech_)return this.tech_.addRemoteTextTrack(e,t)}removeRemoteTextTrack(e={}){let{track:t}=e;if(t||(t=e),this.tech_)return this.tech_.removeRemoteTextTrack(t)}getVideoPlaybackQuality(){return this.techGet_("getVideoPlaybackQuality")}videoWidth(){return this.tech_&&this.tech_.videoWidth&&this.tech_.videoWidth()||0}videoHeight(){return this.tech_&&this.tech_.videoHeight&&this.tech_.videoHeight()||0}language(e){if(e===void 0)return this.language_;this.language_!==String(e).toLowerCase()&&(this.language_=String(e).toLowerCase(),ai(this)&&this.trigger("languagechange"))}languages(){return xe(ke.prototype.options_.languages,this.languages_)}toJSON(){const e=xe(this.options_),t=e.tracks;e.tracks=[];for(let i=0;i<t.length;i++){let n=t[i];n=xe(n),n.player=void 0,e.tracks[i]=n}return e}createModal(e,t){t=t||{},t.content=e||"";const i=new Is(this,t);return this.addChild(i),i.on("dispose",()=>{this.removeChild(i)}),i.open(),i}updateCurrentBreakpoint_(){if(!this.responsive())return;const e=this.currentBreakpoint(),t=this.currentWidth();for(let i=0;i<lo.length;i++){const n=lo[i],r=this.breakpoints_[n];if(t<=r){if(e===n)return;e&&this.removeClass(or[e]),this.addClass(or[n]),this.breakpoint_=n;break}}}removeCurrentBreakpoint_(){const e=this.currentBreakpointClass();this.breakpoint_="",e&&this.removeClass(e)}breakpoints(e){return e===void 0?Object.assign(this.breakpoints_):(this.breakpoint_="",this.breakpoints_=Object.assign({},Mv,e),this.updateCurrentBreakpoint_(),Object.assign(this.breakpoints_))}responsive(e){if(e===void 0)return this.responsive_;e=!!e;const t=this.responsive_;if(e!==t)return this.responsive_=e,e?(this.on("playerresize",this.boundUpdateCurrentBreakpoint_),this.updateCurrentBreakpoint_()):(this.off("playerresize",this.boundUpdateCurrentBreakpoint_),this.removeCurrentBreakpoint_()),e}currentBreakpoint(){return this.breakpoint_}currentBreakpointClass(){return or[this.breakpoint_]||""}loadMedia(e,t){if(!e||typeof e!="object")return;const i=this.crossOrigin();this.reset(),this.cache_.media=xe(e);const{artist:n,artwork:r,description:a,poster:l,src:h,textTracks:f,title:m}=this.cache_.media;!r&&l&&(this.cache_.media.artwork=[{src:l,type:xr(l)}]),i&&this.crossOrigin(i),h&&this.src(h),l&&this.poster(l),Array.isArray(f)&&f.forEach(T=>this.addRemoteTextTrack(T,!1)),this.titleBar&&this.titleBar.update({title:m,description:a||n||""}),this.ready(t)}getMedia(){if(!this.cache_.media){const e=this.poster(),t=this.currentSources(),i=Array.prototype.map.call(this.remoteTextTracks(),r=>({kind:r.kind,label:r.label,language:r.language,src:r.src})),n={src:t,textTracks:i};return e&&(n.poster=e,n.artwork=[{src:n.poster,type:xr(n.poster)}]),n}return xe(this.cache_.media)}static getTagSettings(e){const t={sources:[],tracks:[]},i=bi(e),n=i["data-setup"];if(hn(e,"vjs-fill")&&(i.fill=!0),hn(e,"vjs-fluid")&&(i.fluid=!0),n!==null)try{Object.assign(i,JSON.parse(n||"{}"))}catch(r){ue.error("data-setup",r)}if(Object.assign(t,i),e.hasChildNodes()){const r=e.childNodes;for(let a=0,l=r.length;a<l;a++){const h=r[a],f=h.nodeName.toLowerCase();f==="source"?t.sources.push(bi(h)):f==="track"&&t.tracks.push(bi(h))}}return t}debug(e){if(e===void 0)return this.debugEnabled_;e?(this.trigger("debugon"),this.previousLogLevel_=this.log.level,this.log.level("debug"),this.debugEnabled_=!0):(this.trigger("debugoff"),this.log.level(this.previousLogLevel_),this.previousLogLevel_=void 0,this.debugEnabled_=!1)}playbackRates(e){if(e===void 0)return this.cache_.playbackRates;Array.isArray(e)&&e.every(t=>typeof t=="number")&&(this.cache_.playbackRates=e,this.trigger("playbackrateschange"))}}rt.names.forEach(function(s){const e=rt[s];ke.prototype[e.getterName]=function(){return this.tech_?this.tech_[e.getterName]():(this[e.privateName]=this[e.privateName]||new e.ListClass,this[e.privateName])}});ke.prototype.crossorigin=ke.prototype.crossOrigin;ke.players={};const en=k.navigator;ke.prototype.options_={techOrder:oe.defaultTechOrder_,html5:{},enableSourceset:!0,inactivityTimeout:2e3,playbackRates:[],liveui:!1,children:["mediaLoader","posterImage","titleBar","textTrackDisplay","loadingSpinner","bigPlayButton","liveTracker","controlBar","errorDisplay","textTrackSettings","resizeManager"],language:en&&(en.languages&&en.languages[0]||en.userLanguage||en.language)||"en",languages:{},notSupportedMessage:"No compatible source was found for this media.",normalizeAutoplay:!1,fullscreen:{options:{navigationUI:"hide"}},breakpoints:{},responsive:!1,audioOnlyMode:!1,audioPosterMode:!1,spatialNavigation:{enabled:!1,horizontalSeek:!1},enableSmoothSeeking:!1,disableSeekWhileScrubbingOnMobile:!1};Uh.forEach(function(s){ke.prototype[`handleTech${Be(s)}_`]=function(){return this.trigger(s)}});H.registerComponent("Player",ke);const Sr="plugin",ls="activePlugins_",is={},Er=s=>is.hasOwnProperty(s),lr=s=>Er(s)?is[s]:void 0,Bh=(s,e)=>{s[ls]=s[ls]||{},s[ls][e]=!0},Cr=(s,e,t)=>{const i=(t?"before":"")+"pluginsetup";s.trigger(i,e),s.trigger(i+":"+e.name,e)},Nv=function(s,e){const t=function(){Cr(this,{name:s,plugin:e,instance:null},!0);const i=e.apply(this,arguments);return Bh(this,s),Cr(this,{name:s,plugin:e,instance:i}),i};return Object.keys(e).forEach(function(i){t[i]=e[i]}),t},rc=(s,e)=>(e.prototype.name=s,function(...t){Cr(this,{name:s,plugin:e,instance:null},!0);const i=new e(this,...t);return this[s]=()=>i,Cr(this,i.getEventHash()),i});class ft{constructor(e){if(this.constructor===ft)throw new Error("Plugin must be sub-classed; not directly instantiated.");this.player=e,this.log||(this.log=this.player.log.createLogger(this.name)),Ho(this),delete this.trigger,Qd(this,this.constructor.defaultState),Bh(e,this.name),this.dispose=this.dispose.bind(this),e.on("dispose",this.dispose)}version(){return this.constructor.VERSION}getEventHash(e={}){return e.name=this.name,e.plugin=this.constructor,e.instance=this,e}trigger(e,t={}){return ws(this.eventBusEl_,e,this.getEventHash(t))}handleStateChanged(e){}dispose(){const{name:e,player:t}=this;this.trigger("dispose"),this.off(),t.off("dispose",this.dispose),t[ls][e]=!1,this.player=this.state=null,t[e]=rc(e,is[e])}static isBasic(e){const t=typeof e=="string"?lr(e):e;return typeof t=="function"&&!ft.prototype.isPrototypeOf(t.prototype)}static registerPlugin(e,t){if(typeof e!="string")throw new Error(`Illegal plugin name, "${e}", must be a string, was ${typeof e}.`);if(Er(e))ue.warn(`A plugin named "${e}" already exists. You may want to avoid re-registering plugins!`);else if(ke.prototype.hasOwnProperty(e))throw new Error(`Illegal plugin name, "${e}", cannot share a name with an existing player method!`);if(typeof t!="function")throw new Error(`Illegal plugin for "${e}", must be a function, was ${typeof t}.`);return is[e]=t,e!==Sr&&(ft.isBasic(t)?ke.prototype[e]=Nv(e,t):ke.prototype[e]=rc(e,t)),t}static deregisterPlugin(e){if(e===Sr)throw new Error("Cannot de-register base plugin.");Er(e)&&(delete is[e],delete ke.prototype[e])}static getPlugins(e=Object.keys(is)){let t;return e.forEach(i=>{const n=lr(i);n&&(t=t||{},t[i]=n)}),t}static getPluginVersion(e){const t=lr(e);return t&&t.VERSION||""}}ft.getPlugin=lr;ft.BASE_PLUGIN_NAME=Sr;ft.registerPlugin(Sr,ft);ke.prototype.usingPlugin=function(s){return!!this[ls]&&this[ls][s]===!0};ke.prototype.hasPlugin=function(s){return!!Er(s)};function Uv(s,e){let t=!1;return function(...i){return t||ue.warn(s),t=!0,e.apply(this,i)}}function Bt(s,e,t,i){return Uv(`${e} is deprecated and will be removed in ${s}.0; please use ${t} instead.`,i)}var Bv={NetworkBadStatus:"networkbadstatus",NetworkRequestFailed:"networkrequestfailed",NetworkRequestAborted:"networkrequestaborted",NetworkRequestTimeout:"networkrequesttimeout",NetworkBodyParserFailed:"networkbodyparserfailed",StreamingHlsPlaylistParserError:"streaminghlsplaylistparsererror",StreamingDashManifestParserError:"streamingdashmanifestparsererror",StreamingContentSteeringParserError:"streamingcontentsteeringparsererror",StreamingVttParserError:"streamingvttparsererror",StreamingFailedToSelectNextSegment:"streamingfailedtoselectnextsegment",StreamingFailedToDecryptSegment:"streamingfailedtodecryptsegment",StreamingFailedToTransmuxSegment:"streamingfailedtotransmuxsegment",StreamingFailedToAppendSegment:"streamingfailedtoappendsegment",StreamingCodecsChangeError:"streamingcodecschangeerror"};const Fh=s=>s.indexOf("#")===0?s.slice(1):s;function B(s,e,t){let i=B.getPlayer(s);if(i)return e&&ue.warn(`Player "${s}" is already initialised. Options will not be applied.`),t&&i.ready(t),i;const n=typeof s=="string"?Ei("#"+Fh(s)):s;if(!Cs(n))throw new TypeError("The element or ID supplied is not valid. (videojs)");const a=("getRootNode"in n?n.getRootNode()instanceof k.ShadowRoot:!1)?n.getRootNode():n.ownerDocument.body;(!n.ownerDocument.defaultView||!a.contains(n))&&ue.warn("The element supplied is not included in the DOM"),e=e||{},e.restoreEl===!0&&(e.restoreEl=(n.parentNode&&n.parentNode.hasAttribute&&n.parentNode.hasAttribute("data-vjs-player")?n.parentNode:n).cloneNode(!0)),Si("beforesetup").forEach(h=>{const f=h(n,xe(e));if(!Zt(f)||Array.isArray(f)){ue.error("please return an object in beforesetup hooks");return}e=xe(e,f)});const l=H.getComponent("Player");return i=new l(n,e,t),Si("setup").forEach(h=>h(i)),i}B.hooks_=ni;B.hooks=Si;B.hook=gT;B.hookOnce=yT;B.removeHook=xd;if(k.VIDEOJS_NO_DYNAMIC_STYLE!==!0&&Es()){let s=Ei(".vjs-styles-defaults");if(!s){s=Wd("vjs-styles-defaults");const e=Ei("head");e&&e.insertBefore(s,e.firstChild),Gd(s,`
|
|
179
179
|
.video-js {
|
|
180
180
|
width: 300px;
|
|
181
181
|
height: 150px;
|
|
@@ -184,36 +184,36 @@ See https://github.com/videojs/video.js/issues/2617 for more info.
|
|
|
184
184
|
.vjs-fluid:not(.vjs-audio-only-mode) {
|
|
185
185
|
padding-top: 56.25%
|
|
186
186
|
}
|
|
187
|
-
`)}}
|
|
188
|
-
`;for(let t=0;t<
|
|
189
|
-
`}return e}const Xt=1/30,Kt=Xt*3,qc=function(i,e){const t=[];let n;if(i&&i.length)for(n=0;n<i.length;n++)e(i.start(n),i.end(n))&&t.push([i.start(n),i.end(n)]);return tt(t)},tn=function(i,e){return qc(i,function(t,n){return t-Kt<=e&&n+Kt>=e})},er=function(i,e){return qc(i,function(t){return t-Xt>=e})},Gb=function(i){if(i.length<2)return tt();const e=[];for(let t=1;t<i.length;t++){const n=i.end(t-1),s=i.start(t);e.push([n,s])}return tt(e)},Xb=function(i,e){let t=null,n=null,s=0;const r=[],a=[];if(!i||!i.length||!e||!e.length)return tt();let l=i.length;for(;l--;)r.push({time:i.start(l),type:"start"}),r.push({time:i.end(l),type:"end"});for(l=e.length;l--;)r.push({time:e.start(l),type:"start"}),r.push({time:e.end(l),type:"end"});for(r.sort(function(c,f){return c.time-f.time}),l=0;l<r.length;l++)r[l].type==="start"?(s++,s===2&&(t=r[l].time)):r[l].type==="end"&&(s--,s===1&&(n=r[l].time)),t!==null&&n!==null&&(a.push([t,n]),t=null,n=null);return tt(a)},Vc=i=>{const e=[];if(!i||!i.length)return"";for(let t=0;t<i.length;t++)e.push(i.start(t)+" => "+i.end(t));return e.join(", ")},Kb=function(i,e,t=1){return((i.length?i.end(i.length-1):0)-e)/t},Ui=i=>{const e=[];for(let t=0;t<i.length;t++)e.push({start:i.start(t),end:i.end(t)});return e},Yb=function(i,e){if(i===e)return!1;if(!i&&e||!e&&i||i.length!==e.length)return!0;for(let t=0;t<i.length;t++)if(i.start(t)!==e.start(t)||i.end(t)!==e.end(t))return!0;return!1},qa=function(i){if(!(!i||!i.length||!i.end))return i.end(i.length-1)},ll=function(i,e){let t=0;if(!i||!i.length)return t;for(let n=0;n<i.length;n++){const s=i.start(n),r=i.end(n);if(!(e>r)){if(e>s&&e<=r){t+=r-e;continue}t+=r-s}}return t},ul=(i,e)=>{if(!e.preload)return e.duration;let t=0;return(e.parts||[]).forEach(function(n){t+=n.duration}),(e.preloadHints||[]).forEach(function(n){n.type==="PART"&&(t+=i.partTargetDuration)}),t},ao=i=>(i.segments||[]).reduce((e,t,n)=>(t.parts?t.parts.forEach(function(s,r){e.push({duration:s.duration,segmentIndex:n,partIndex:r,part:s,segment:t})}):e.push({duration:t.duration,segmentIndex:n,partIndex:null,segment:t,part:null}),e),[]),Hc=i=>{const e=i.segments&&i.segments.length&&i.segments[i.segments.length-1];return e&&e.parts||[]},zc=({preloadSegment:i})=>{if(!i)return;const{parts:e,preloadHints:t}=i;let n=(t||[]).reduce((s,r)=>s+(r.type==="PART"?1:0),0);return n+=e&&e.length?e.length:0,n},Wc=(i,e)=>{if(e.endList)return 0;if(i&&i.suggestedPresentationDelay)return i.suggestedPresentationDelay;const t=Hc(e).length>0;return t&&e.serverControl&&e.serverControl.partHoldBack?e.serverControl.partHoldBack:t&&e.partTargetDuration?e.partTargetDuration*3:e.serverControl&&e.serverControl.holdBack?e.serverControl.holdBack:e.targetDuration?e.targetDuration*3:0},Qb=function(i,e){let t=0,n=e-i.mediaSequence,s=i.segments[n];if(s){if(typeof s.start<"u")return{result:s.start,precise:!0};if(typeof s.end<"u")return{result:s.end-s.duration,precise:!0}}for(;n--;){if(s=i.segments[n],typeof s.end<"u")return{result:t+s.end,precise:!0};if(t+=ul(i,s),typeof s.start<"u")return{result:t+s.start,precise:!0}}return{result:t,precise:!1}},Jb=function(i,e){let t=0,n,s=e-i.mediaSequence;for(;s<i.segments.length;s++){if(n=i.segments[s],typeof n.start<"u")return{result:n.start-t,precise:!0};if(t+=ul(i,n),typeof n.end<"u")return{result:n.end-t,precise:!0}}return{result:-1,precise:!1}},Gc=function(i,e,t){if(typeof e>"u"&&(e=i.mediaSequence+i.segments.length),e<i.mediaSequence)return 0;const n=Qb(i,e);if(n.precise)return n.result;const s=Jb(i,e);return s.precise?s.result:n.result+t},Xc=function(i,e,t){if(!i)return 0;if(typeof t!="number"&&(t=0),typeof e>"u"){if(i.totalDuration)return i.totalDuration;if(!i.endList)return x.Infinity}return Gc(i,e,t)},ds=function({defaultDuration:i,durationList:e,startIndex:t,endIndex:n}){let s=0;if(t>n&&([t,n]=[n,t]),t<0){for(let r=t;r<Math.min(0,n);r++)s+=i;t=0}for(let r=t;r<n;r++)s+=e[r].duration;return s},Kc=function(i,e,t,n){if(!i||!i.segments)return null;if(i.endList)return Xc(i);if(e===null)return null;e=e||0;let s=Gc(i,i.mediaSequence+i.segments.length,e);return t&&(n=typeof n=="number"?n:Wc(null,i),s-=n),Math.max(0,s)},Zb=function(i,e,t){const n=e||0;let s=Kc(i,e,!0,t);return s===null?tt():(s<n&&(s=n),tt(n,s))},eT=function({playlist:i,currentTime:e,startingSegmentIndex:t,startingPartIndex:n,startTime:s,exactManifestTimings:r}){let a=e-s;const l=ao(i);let c=0;for(let f=0;f<l.length;f++){const m=l[f];if(t===m.segmentIndex&&!(typeof n=="number"&&typeof m.partIndex=="number"&&n!==m.partIndex)){c=f;break}}if(a<0){if(c>0)for(let f=c-1;f>=0;f--){const m=l[f];if(a+=m.duration,r){if(a<0)continue}else if(a+Xt<=0)continue;return{partIndex:m.partIndex,segmentIndex:m.segmentIndex,startTime:s-ds({defaultDuration:i.targetDuration,durationList:l,startIndex:c,endIndex:f})}}return{partIndex:l[0]&&l[0].partIndex||null,segmentIndex:l[0]&&l[0].segmentIndex||0,startTime:e}}if(c<0){for(let f=c;f<0;f++)if(a-=i.targetDuration,a<0)return{partIndex:l[0]&&l[0].partIndex||null,segmentIndex:l[0]&&l[0].segmentIndex||0,startTime:e};c=0}for(let f=c;f<l.length;f++){const m=l[f];a-=m.duration;const b=m.duration>Xt,C=a===0,w=b&&a+Xt>=0;if(!((C||w)&&f!==l.length-1)){if(r){if(a>0)continue}else if(a-Xt>=0)continue;return{partIndex:m.partIndex,segmentIndex:m.segmentIndex,startTime:s+ds({defaultDuration:i.targetDuration,durationList:l,startIndex:c,endIndex:f})}}}return{segmentIndex:l[l.length-1].segmentIndex,partIndex:l[l.length-1].partIndex,startTime:e}},Yc=function(i){return i.excludeUntil&&i.excludeUntil>Date.now()},dl=function(i){return i.excludeUntil&&i.excludeUntil===1/0},ta=function(i){const e=Yc(i);return!i.disabled&&!e},tT=function(i){return i.disabled},iT=function(i){for(let e=0;e<i.segments.length;e++)if(i.segments[e].key)return!0;return!1},Qc=function(i,e){return e.attributes&&e.attributes[i]},nT=function(i,e,t,n=0){return Qc("BANDWIDTH",t)?(i*t.attributes.BANDWIDTH-n*8)/e:NaN},oo=(i,e)=>{if(i.playlists.length===1)return!0;const t=e.attributes.BANDWIDTH||Number.MAX_VALUE;return i.playlists.filter(n=>ta(n)?(n.attributes.BANDWIDTH||0)<t:!1).length===0},hl=(i,e)=>!i&&!e||!i&&e||i&&!e?!1:!!(i===e||i.id&&e.id&&i.id===e.id||i.resolvedUri&&e.resolvedUri&&i.resolvedUri===e.resolvedUri||i.uri&&e.uri&&i.uri===e.uri),ad=function(i,e){const t=i&&i.mediaGroups&&i.mediaGroups.AUDIO||{};let n=!1;for(const s in t){for(const r in t[s])if(n=e(t[s][r]),n)break;if(n)break}return!!n},Ss=i=>{if(!i||!i.playlists||!i.playlists.length)return ad(i,e=>e.playlists&&e.playlists.length||e.uri);for(let e=0;e<i.playlists.length;e++){const t=i.playlists[e],n=t.attributes&&t.attributes.CODECS;if(!(n&&n.split(",").every(s=>oh(s))||ad(i,s=>hl(t,s))))return!1}return!0};var gt={liveEdgeDelay:Wc,duration:Xc,seekable:Zb,getMediaInfoForTime:eT,isEnabled:ta,isDisabled:tT,isExcluded:Yc,isIncompatible:dl,playlistEnd:Kc,isAes:iT,hasAttribute:Qc,estimateSegmentRequestTime:nT,isLowestEnabledRendition:oo,isAudioOnly:Ss,playlistMatch:hl,segmentDurationWithParts:ul};const{log:Jc}=B,ln=(i,e)=>`${i}-${e}`,Zc=(i,e,t)=>`placeholder-uri-${i}-${e}-${t}`,sT=({onwarn:i,oninfo:e,manifestString:t,customTagParsers:n=[],customTagMappers:s=[],llhls:r})=>{const a=new X_;i&&a.on("warn",i),e&&a.on("info",e),n.forEach(f=>a.addParser(f)),s.forEach(f=>a.addTagMapper(f)),a.push(t),a.end();const l=a.manifest;if(r||(["preloadSegment","skip","serverControl","renditionReports","partInf","partTargetDuration"].forEach(function(f){l.hasOwnProperty(f)&&delete l[f]}),l.segments&&l.segments.forEach(function(f){["parts","preloadHints"].forEach(function(m){f.hasOwnProperty(m)&&delete f[m]})})),!l.targetDuration){let f=10;l.segments&&l.segments.length&&(f=l.segments.reduce((m,b)=>Math.max(m,b.duration),0)),i&&i({message:`manifest has no targetDuration defaulting to ${f}`}),l.targetDuration=f}const c=Hc(l);if(c.length&&!l.partTargetDuration){const f=c.reduce((m,b)=>Math.max(m,b.duration),0);i&&(i({message:`manifest has no partTargetDuration defaulting to ${f}`}),Jc.error("LL-HLS manifest has parts but lacks required #EXT-X-PART-INF:PART-TARGET value. See https://datatracker.ietf.org/doc/html/draft-pantos-hls-rfc8216bis-09#section-4.4.3.7. Playback is not guaranteed.")),l.partTargetDuration=f}return l},An=(i,e)=>{i.mediaGroups&&["AUDIO","SUBTITLES"].forEach(t=>{if(i.mediaGroups[t])for(const n in i.mediaGroups[t])for(const s in i.mediaGroups[t][n]){const r=i.mediaGroups[t][n][s];e(r,t,n,s)}})},ep=({playlist:i,uri:e,id:t})=>{i.id=t,i.playlistErrors_=0,e&&(i.uri=e),i.attributes=i.attributes||{}},rT=i=>{let e=i.playlists.length;for(;e--;){const t=i.playlists[e];ep({playlist:t,id:ln(e,t.uri)}),t.resolvedUri=pt(i.uri,t.uri),i.playlists[t.id]=t,i.playlists[t.uri]=t,t.attributes.BANDWIDTH||Jc.warn("Invalid playlist STREAM-INF detected. Missing BANDWIDTH attribute.")}},aT=i=>{An(i,e=>{e.uri&&(e.resolvedUri=pt(i.uri,e.uri))})},oT=(i,e)=>{const t=ln(0,e),n={mediaGroups:{AUDIO:{},VIDEO:{},"CLOSED-CAPTIONS":{},SUBTITLES:{}},uri:x.location.href,resolvedUri:x.location.href,playlists:[{uri:e,id:t,resolvedUri:e,attributes:{}}]};return n.playlists[t]=n.playlists[0],n.playlists[e]=n.playlists[0],n},tp=(i,e,t=Zc)=>{i.uri=e;for(let s=0;s<i.playlists.length;s++)if(!i.playlists[s].uri){const r=`placeholder-uri-${s}`;i.playlists[s].uri=r}const n=Ss(i);An(i,(s,r,a,l)=>{if(!s.playlists||!s.playlists.length){if(n&&r==="AUDIO"&&!s.uri)for(let c=0;c<i.playlists.length;c++){const f=i.playlists[c];if(f.attributes&&f.attributes.AUDIO&&f.attributes.AUDIO===a)return}s.playlists=[je({},s)]}s.playlists.forEach(function(c,f){const m=t(r,a,l,c),b=ln(f,m);c.uri?c.resolvedUri=c.resolvedUri||pt(i.uri,c.uri):(c.uri=f===0?m:b,c.resolvedUri=c.uri),c.id=c.id||b,c.attributes=c.attributes||{},i.playlists[c.id]=c,i.playlists[c.uri]=c})}),rT(i),aT(i)};class od{constructor(){this.offset_=null,this.pendingDateRanges_=new Map,this.processedDateRanges_=new Map}setOffset(e=[]){if(this.offset_!==null||!e.length)return;const[t]=e;t.programDateTime!==void 0&&(this.offset_=t.programDateTime/1e3)}setPendingDateRanges(e=[]){if(!e.length)return;const[t]=e,n=t.startDate.getTime();this.trimProcessedDateRanges_(n),this.pendingDateRanges_=e.reduce((s,r)=>(s.set(r.id,r),s),new Map)}processDateRange(e){this.pendingDateRanges_.delete(e.id),this.processedDateRanges_.set(e.id,e)}getDateRangesToProcess(){if(this.offset_===null)return[];const e={},t=[];this.pendingDateRanges_.forEach((n,s)=>{if(!this.processedDateRanges_.has(s)&&(n.startTime=n.startDate.getTime()/1e3-this.offset_,n.processDateRange=()=>this.processDateRange(n),t.push(n),!!n.class))if(e[n.class]){const r=e[n.class].push(n);n.classListIndex=r-1}else e[n.class]=[n],n.classListIndex=0});for(const n of t){const s=e[n.class]||[];n.endDate?n.endTime=n.endDate.getTime()/1e3-this.offset_:n.endOnNext&&s[n.classListIndex+1]?n.endTime=s[n.classListIndex+1].startTime:n.duration?n.endTime=n.startTime+n.duration:n.plannedDuration?n.endTime=n.startTime+n.plannedDuration:n.endTime=n.startTime}return t}trimProcessedDateRanges_(e){new Map(this.processedDateRanges_).forEach((t,n)=>{t.startDate.getTime()<e&&this.processedDateRanges_.delete(n)})}}const ip=22,$i=({requestType:i,request:e,error:t,parseFailure:n})=>{const s=e.status<200||e.status>299,r=e.status>=400&&e.status<=499,a={uri:e.uri,requestType:i},l=s&&!r||n;if(t&&r)a.error=je({},t),a.errorType=B.Error.NetworkRequestFailed;else if(e.aborted)a.errorType=B.Error.NetworkRequestAborted;else if(e.timedout)a.erroType=B.Error.NetworkRequestTimeout;else if(l){const c=n?B.Error.NetworkBodyParserFailed:B.Error.NetworkBadStatus;a.errorType=c,a.status=e.status,a.headers=e.headers}return a},{EventTarget:lT}=B,uT=(i,e)=>{if(e.endList||!e.serverControl)return i;const t={};if(e.serverControl.canBlockReload){const{preloadSegment:n}=e;let s=e.mediaSequence+e.segments.length;if(n){const r=n.parts||[],a=zc(e)-1;a>-1&&a!==r.length-1&&(t._HLS_part=a),(a>-1||r.length)&&s--}t._HLS_msn=s}if(e.serverControl&&e.serverControl.canSkipUntil&&(t._HLS_skip=e.serverControl.canSkipDateranges?"v2":"YES"),Object.keys(t).length){const n=new x.URL(i);["_HLS_skip","_HLS_msn","_HLS_part"].forEach(function(s){t.hasOwnProperty(s)&&n.searchParams.set(s,t[s])}),i=n.toString()}return i},dT=(i,e)=>{if(!i)return e;const t=fe(i,e);if(i.preloadHints&&!e.preloadHints&&delete t.preloadHints,i.parts&&!e.parts)delete t.parts;else if(i.parts&&e.parts)for(let n=0;n<e.parts.length;n++)i.parts&&i.parts[n]&&(t.parts[n]=fe(i.parts[n],e.parts[n]));return!i.skipped&&e.skipped&&(t.skipped=!1),i.preload&&!e.preload&&(t.preload=!1),t},hT=(i,e,t)=>{const n=i.slice(),s=e.slice();t=t||0;const r=[];let a;for(let l=0;l<s.length;l++){const c=n[l+t],f=s[l];c?(a=c.map||a,r.push(dT(c,f))):(a&&!f.map&&(f.map=a),r.push(f))}return r},np=(i,e)=>{!i.resolvedUri&&i.uri&&(i.resolvedUri=pt(e,i.uri)),i.key&&!i.key.resolvedUri&&(i.key.resolvedUri=pt(e,i.key.uri)),i.map&&!i.map.resolvedUri&&(i.map.resolvedUri=pt(e,i.map.uri)),i.map&&i.map.key&&!i.map.key.resolvedUri&&(i.map.key.resolvedUri=pt(e,i.map.key.uri)),i.parts&&i.parts.length&&i.parts.forEach(t=>{t.resolvedUri||(t.resolvedUri=pt(e,t.uri))}),i.preloadHints&&i.preloadHints.length&&i.preloadHints.forEach(t=>{t.resolvedUri||(t.resolvedUri=pt(e,t.uri))})},sp=function(i){const e=i.segments||[],t=i.preloadSegment;if(t&&t.parts&&t.parts.length){if(t.preloadHints){for(let n=0;n<t.preloadHints.length;n++)if(t.preloadHints[n].type==="MAP")return e}t.duration=i.targetDuration,t.preload=!0,e.push(t)}return e},rp=(i,e)=>i===e||i.segments&&e.segments&&i.segments.length===e.segments.length&&i.endList===e.endList&&i.mediaSequence===e.mediaSequence&&i.preloadSegment===e.preloadSegment,lo=(i,e,t=rp)=>{const n=fe(i,{}),s=n.playlists[e.id];if(!s||t(s,e))return null;e.segments=sp(e);const r=fe(s,e);if(r.preloadSegment&&!e.preloadSegment&&delete r.preloadSegment,s.segments){if(e.skip){e.segments=e.segments||[];for(let a=0;a<e.skip.skippedSegments;a++)e.segments.unshift({skipped:!0})}r.segments=hT(s.segments,e.segments,e.mediaSequence-s.mediaSequence)}r.segments.forEach(a=>{np(a,r.resolvedUri)});for(let a=0;a<n.playlists.length;a++)n.playlists[a].id===e.id&&(n.playlists[a]=r);return n.playlists[e.id]=r,n.playlists[e.uri]=r,An(i,(a,l,c,f)=>{if(a.playlists)for(let m=0;m<a.playlists.length;m++)e.id===a.playlists[m].id&&(a.playlists[m]=r)}),n},uo=(i,e)=>{const t=i.segments||[],n=t[t.length-1],s=n&&n.parts&&n.parts[n.parts.length-1],r=s&&s.duration||n&&n.duration;return e&&r?r*1e3:(i.partTargetDuration||i.targetDuration||10)*500},ld=(i,e,t)=>{if(!i)return;const n=[];return i.forEach(s=>{if(!s.attributes)return;const{BANDWIDTH:r,RESOLUTION:a,CODECS:l}=s.attributes;n.push({id:s.id,bandwidth:r,resolution:a,codecs:l})}),{type:e,isLive:t,renditions:n}};class nn extends lT{constructor(e,t,n={}){if(super(),!e)throw new Error("A non-empty playlist URL or object is required");this.logger_=Lt("PlaylistLoader");const{withCredentials:s=!1}=n;this.src=e,this.vhs_=t,this.withCredentials=s,this.addDateRangesToTextTrack_=n.addDateRangesToTextTrack;const r=t.options_;this.customTagParsers=r&&r.customTagParsers||[],this.customTagMappers=r&&r.customTagMappers||[],this.llhls=r&&r.llhls,this.dateRangesStorage_=new od,this.state="HAVE_NOTHING",this.handleMediaupdatetimeout_=this.handleMediaupdatetimeout_.bind(this),this.on("mediaupdatetimeout",this.handleMediaupdatetimeout_),this.on("loadedplaylist",this.handleLoadedPlaylist_.bind(this))}handleLoadedPlaylist_(){const e=this.media();if(!e)return;this.dateRangesStorage_.setOffset(e.segments),this.dateRangesStorage_.setPendingDateRanges(e.dateRanges);const t=this.dateRangesStorage_.getDateRangesToProcess();!t.length||!this.addDateRangesToTextTrack_||this.addDateRangesToTextTrack_(t)}handleMediaupdatetimeout_(){if(this.state!=="HAVE_METADATA")return;const e=this.media();let t=pt(this.main.uri,e.uri);this.llhls&&(t=uT(t,e)),this.state="HAVE_CURRENT_METADATA",this.request=this.vhs_.xhr({uri:t,withCredentials:this.withCredentials,requestType:"hls-playlist"},(n,s)=>{if(this.request){if(n)return this.playlistRequestError(this.request,this.media(),"HAVE_METADATA");this.haveMetadata({playlistString:this.request.responseText,url:this.media().uri,id:this.media().id})}})}playlistRequestError(e,t,n){const{uri:s,id:r}=t;this.request=null,n&&(this.state=n),this.error={playlist:this.main.playlists[r],status:e.status,message:`HLS playlist request error at URL: ${s}.`,responseText:e.responseText,code:e.status>=500?4:2,metadata:$i({requestType:e.requestType,request:e,error:e.error})},this.trigger("error")}parseManifest_({url:e,manifestString:t}){try{return sT({onwarn:({message:n})=>this.logger_(`m3u8-parser warn for ${e}: ${n}`),oninfo:({message:n})=>this.logger_(`m3u8-parser info for ${e}: ${n}`),manifestString:t,customTagParsers:this.customTagParsers,customTagMappers:this.customTagMappers,llhls:this.llhls})}catch(n){this.error=n,this.error.metadata={errorType:B.Error.StreamingHlsPlaylistParserError,error:n}}}haveMetadata({playlistString:e,playlistObject:t,url:n,id:s}){this.request=null,this.state="HAVE_METADATA";const r={playlistInfo:{type:"media",uri:n}};this.trigger({type:"playlistparsestart",metadata:r});const a=t||this.parseManifest_({url:n,manifestString:e});a.lastRequest=Date.now(),ep({playlist:a,uri:n,id:s});const l=lo(this.main,a);this.targetDuration=a.partTargetDuration||a.targetDuration,this.pendingMedia_=null,l?(this.main=l,this.media_=this.main.playlists[s]):this.trigger("playlistunchanged"),this.updateMediaUpdateTimeout_(uo(this.media(),!!l)),r.parsedPlaylist=ld(this.main.playlists,r.playlistInfo.type,!this.media_.endList),this.trigger({type:"playlistparsecomplete",metadata:r}),this.trigger("loadedplaylist")}dispose(){this.trigger("dispose"),this.stopRequest(),x.clearTimeout(this.mediaUpdateTimeout),x.clearTimeout(this.finalRenditionTimeout),this.dateRangesStorage_=new od,this.off()}stopRequest(){if(this.request){const e=this.request;this.request=null,e.onreadystatechange=null,e.abort()}}media(e,t){if(!e)return this.media_;if(this.state==="HAVE_NOTHING")throw new Error("Cannot switch media playlist from "+this.state);if(typeof e=="string"){if(!this.main.playlists[e])throw new Error("Unknown playlist URI: "+e);e=this.main.playlists[e]}if(x.clearTimeout(this.finalRenditionTimeout),t){const l=(e.partTargetDuration||e.targetDuration)/2*1e3||5e3;this.finalRenditionTimeout=x.setTimeout(this.media.bind(this,e,!1),l);return}const n=this.state,s=!this.media_||e.id!==this.media_.id,r=this.main.playlists[e.id];if(r&&r.endList||e.endList&&e.segments.length){this.request&&(this.request.onreadystatechange=null,this.request.abort(),this.request=null),this.state="HAVE_METADATA",this.media_=e,s&&(this.trigger("mediachanging"),n==="HAVE_MAIN_MANIFEST"?this.trigger("loadedmetadata"):this.trigger("mediachange"));return}if(this.updateMediaUpdateTimeout_(uo(e,!0)),!s)return;if(this.state="SWITCHING_MEDIA",this.request){if(e.resolvedUri===this.request.url)return;this.request.onreadystatechange=null,this.request.abort(),this.request=null}this.media_&&this.trigger("mediachanging"),this.pendingMedia_=e;const a={playlistInfo:{type:"media",uri:e.uri}};this.trigger({type:"playlistrequeststart",metadata:a}),this.request=this.vhs_.xhr({uri:e.resolvedUri,withCredentials:this.withCredentials,requestType:"hls-playlist"},(l,c)=>{if(this.request){if(e.lastRequest=Date.now(),e.resolvedUri=kr(e.resolvedUri,c),l)return this.playlistRequestError(this.request,e,n);this.trigger({type:"playlistrequestcomplete",metadata:a}),this.haveMetadata({playlistString:c.responseText,url:e.uri,id:e.id}),n==="HAVE_MAIN_MANIFEST"?this.trigger("loadedmetadata"):this.trigger("mediachange")}})}pause(){this.mediaUpdateTimeout&&(x.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null),this.stopRequest(),this.state==="HAVE_NOTHING"&&(this.started=!1),this.state==="SWITCHING_MEDIA"?this.media_?this.state="HAVE_METADATA":this.state="HAVE_MAIN_MANIFEST":this.state==="HAVE_CURRENT_METADATA"&&(this.state="HAVE_METADATA")}load(e){this.mediaUpdateTimeout&&(x.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null);const t=this.media();if(e){const n=t?(t.partTargetDuration||t.targetDuration)/2*1e3:5e3;this.mediaUpdateTimeout=x.setTimeout(()=>{this.mediaUpdateTimeout=null,this.load()},n);return}if(!this.started){this.start();return}t&&!t.endList?this.trigger("mediaupdatetimeout"):this.trigger("loadedplaylist")}updateMediaUpdateTimeout_(e){this.mediaUpdateTimeout&&(x.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null),!(!this.media()||this.media().endList)&&(this.mediaUpdateTimeout=x.setTimeout(()=>{this.mediaUpdateTimeout=null,this.trigger("mediaupdatetimeout"),this.updateMediaUpdateTimeout_(e)},e))}start(){if(this.started=!0,typeof this.src=="object"){this.src.uri||(this.src.uri=x.location.href),this.src.resolvedUri=this.src.uri,setTimeout(()=>{this.setupInitialPlaylist(this.src)},0);return}const e={playlistInfo:{type:"multivariant",uri:this.src}};this.trigger({type:"playlistrequeststart",metadata:e}),this.request=this.vhs_.xhr({uri:this.src,withCredentials:this.withCredentials,requestType:"hls-playlist"},(t,n)=>{if(!this.request)return;if(this.request=null,t)return this.error={status:n.status,message:`HLS playlist request error at URL: ${this.src}.`,responseText:n.responseText,code:2,metadata:$i({requestType:n.requestType,request:n,error:t})},this.state==="HAVE_NOTHING"&&(this.started=!1),this.trigger("error");this.trigger({type:"playlistrequestcomplete",metadata:e}),this.src=kr(this.src,n),this.trigger({type:"playlistparsestart",metadata:e});const s=this.parseManifest_({manifestString:n.responseText,url:this.src});e.parsedPlaylist=ld(s.playlists,e.playlistInfo.type,!1),this.trigger({type:"playlistparsecomplete",metadata:e}),this.setupInitialPlaylist(s)})}srcUri(){return typeof this.src=="string"?this.src:this.src.uri}setupInitialPlaylist(e){if(this.state="HAVE_MAIN_MANIFEST",e.playlists){this.main=e,tp(this.main,this.srcUri()),e.playlists.forEach(n=>{n.segments=sp(n),n.segments.forEach(s=>{np(s,n.resolvedUri)})}),this.trigger("loadedplaylist"),this.request||this.media(this.main.playlists[0]);return}const t=this.srcUri()||x.location.href;this.main=oT(e,t),this.haveMetadata({playlistObject:e,url:t,id:this.main.playlists[0].id}),this.trigger("loadedmetadata")}updateOrDeleteClone(e,t){const n=this.main,s=e.ID;let r=n.playlists.length;for(;r--;){const a=n.playlists[r];if(a.attributes["PATHWAY-ID"]===s){const l=a.resolvedUri,c=a.id;if(t){const f=this.createCloneURI_(a.resolvedUri,e),m=ln(s,f),b=this.createCloneAttributes_(s,a.attributes),C=this.createClonePlaylist_(a,m,e,b);n.playlists[r]=C,n.playlists[m]=C,n.playlists[f]=C}else n.playlists.splice(r,1);delete n.playlists[c],delete n.playlists[l]}}this.updateOrDeleteCloneMedia(e,t)}updateOrDeleteCloneMedia(e,t){const n=this.main,s=e.ID;["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(r=>{if(!(!n.mediaGroups[r]||!n.mediaGroups[r][s])){for(const a in n.mediaGroups[r])if(a===s){for(const l in n.mediaGroups[r][a])n.mediaGroups[r][a][l].playlists.forEach((c,f)=>{const m=n.playlists[c.id],b=m.id,C=m.resolvedUri;delete n.playlists[b],delete n.playlists[C]});delete n.mediaGroups[r][a]}}}),t&&this.createClonedMediaGroups_(e)}addClonePathway(e,t={}){const n=this.main,s=n.playlists.length,r=this.createCloneURI_(t.resolvedUri,e),a=ln(e.ID,r),l=this.createCloneAttributes_(e.ID,t.attributes),c=this.createClonePlaylist_(t,a,e,l);n.playlists[s]=c,n.playlists[a]=c,n.playlists[r]=c,this.createClonedMediaGroups_(e)}createClonedMediaGroups_(e){const t=e.ID,n=e["BASE-ID"],s=this.main;["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(r=>{if(!(!s.mediaGroups[r]||s.mediaGroups[r][t]))for(const a in s.mediaGroups[r]){if(a===n)s.mediaGroups[r][t]={};else continue;for(const l in s.mediaGroups[r][a]){const c=s.mediaGroups[r][a][l];s.mediaGroups[r][t][l]=je({},c);const f=s.mediaGroups[r][t][l],m=this.createCloneURI_(c.resolvedUri,e);f.resolvedUri=m,f.uri=m,f.playlists=[],c.playlists.forEach((b,C)=>{const w=s.playlists[b.id],A=Zc(r,t,l),v=ln(t,A);if(w&&!s.playlists[v]){const M=this.createClonePlaylist_(w,v,e),D=M.resolvedUri;s.playlists[v]=M,s.playlists[D]=M}f.playlists[C]=this.createClonePlaylist_(b,v,e)})}}})}createClonePlaylist_(e,t,n,s){const r=this.createCloneURI_(e.resolvedUri,n),a={resolvedUri:r,uri:r,id:t};return e.segments&&(a.segments=[]),s&&(a.attributes=s),fe(e,a)}createCloneURI_(e,t){const n=new URL(e);n.hostname=t["URI-REPLACEMENT"].HOST;const s=t["URI-REPLACEMENT"].PARAMS;for(const r of Object.keys(s))n.searchParams.set(r,s[r]);return n.href}createCloneAttributes_(e,t){const n={"PATHWAY-ID":e};return["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(s=>{t[s]&&(n[s]=e)}),n}getKeyIdSet(e){if(e.contentProtection){const t=new Set;for(const n in e.contentProtection){const s=e.contentProtection[n].attributes.keyId;s&&t.add(s.toLowerCase())}return t}}}const ho=function(i,e,t,n){const s=i.responseType==="arraybuffer"?i.response:i.responseText;!e&&s&&(i.responseTime=Date.now(),i.roundTripTime=i.responseTime-i.requestTime,i.bytesReceived=s.byteLength||s.length,i.bandwidth||(i.bandwidth=Math.floor(i.bytesReceived/i.roundTripTime*8*1e3))),t.headers&&(i.responseHeaders=t.headers),e&&e.code==="ETIMEDOUT"&&(i.timedout=!0),!e&&!i.aborted&&t.statusCode!==200&&t.statusCode!==206&&t.statusCode!==0&&(e=new Error("XHR Failed with a response of: "+(i&&(s||i.responseText)))),n(e,i)},cT=(i,e)=>{if(!i||!i.size)return;let t=e;return i.forEach(n=>{t=n(t)}),t},pT=(i,e,t,n)=>{!i||!i.size||i.forEach(s=>{s(e,t,n)})},ap=function(){const i=function e(t,n){t=fe({timeout:45e3},t);const s=e.beforeRequest||B.Vhs.xhr.beforeRequest,r=e._requestCallbackSet||B.Vhs.xhr._requestCallbackSet||new Set,a=e._responseCallbackSet||B.Vhs.xhr._responseCallbackSet;s&&typeof s=="function"&&(B.log.warn("beforeRequest is deprecated, use onRequest instead."),r.add(s));const l=B.Vhs.xhr.original===!0?B.xhr:B.Vhs.xhr,c=cT(r,t);r.delete(s);const f=l(c||t,function(b,C){return pT(a,f,b,C),ho(f,b,C,n)}),m=f.abort;return f.abort=function(){return f.aborted=!0,m.apply(f,arguments)},f.uri=t.uri,f.requestType=t.requestType,f.requestTime=Date.now(),f};return i.original=!0,i},gT=function(i){let e;const t=i.offset;return typeof i.offset=="bigint"||typeof i.length=="bigint"?e=x.BigInt(i.offset)+x.BigInt(i.length)-x.BigInt(1):e=i.offset+i.length-1,"bytes="+t+"-"+e},co=function(i){const e={};return i.byterange&&(e.Range=gT(i.byterange)),e},fT=function(i,e){return i.start(e)+"-"+i.end(e)},mT=function(i,e){const t=i.toString(16);return"00".substring(0,2-t.length)+t+(e%2?" ":"")},yT=function(i){return i>=32&&i<126?String.fromCharCode(i):"."},op=function(i){const e={};return Object.keys(i).forEach(t=>{const n=i[t];uh(n)?e[t]={bytes:n.buffer,byteOffset:n.byteOffset,byteLength:n.byteLength}:e[t]=n}),e},Cr=function(i){const e=i.byterange||{length:1/0,offset:0};return[e.length,e.offset,i.resolvedUri].join(",")},lp=function(i){return i.resolvedUri},up=i=>{const e=Array.prototype.slice.call(i),t=16;let n="",s,r;for(let a=0;a<e.length/t;a++)s=e.slice(a*t,a*t+t).map(mT).join(""),r=e.slice(a*t,a*t+t).map(yT).join(""),n+=s+" "+r+`
|
|
190
|
-
`;return n},_T=({bytes:i})=>up(i),bT=i=>{let e="",t;for(t=0;t<i.length;t++)e+=fT(i,t)+" ";return e};var TT=Object.freeze({__proto__:null,createTransferableMessage:op,initSegmentId:Cr,segmentKeyId:lp,hexDump:up,tagDump:_T,textRanges:bT});const dp=.25,vT=(i,e)=>{if(!e.dateTimeObject)return null;const t=e.videoTimingInfo.transmuxerPrependedSeconds,n=e.videoTimingInfo.transmuxedPresentationStart+t,s=i-n;return new Date(e.dateTimeObject.getTime()+s*1e3)},ST=i=>i.transmuxedPresentationEnd-i.transmuxedPresentationStart-i.transmuxerPrependedSeconds,ET=(i,e)=>{let t;try{t=new Date(i)}catch{return null}if(!e||!e.segments||e.segments.length===0)return null;let n=e.segments[0];if(t<new Date(n.dateTimeObject))return null;for(let c=0;c<e.segments.length-1;c++){n=e.segments[c];const f=new Date(e.segments[c+1].dateTimeObject);if(t<f)break}const s=e.segments[e.segments.length-1],r=s.dateTimeObject,a=s.videoTimingInfo?ST(s.videoTimingInfo):s.duration+s.duration*dp,l=new Date(r.getTime()+a*1e3);return t>l?null:(t>new Date(r)&&(n=s),{segment:n,estimatedStart:n.videoTimingInfo?n.videoTimingInfo.transmuxedPresentationStart:gt.duration(e,e.mediaSequence+e.segments.indexOf(n)),type:n.videoTimingInfo?"accurate":"estimate"})},wT=(i,e)=>{if(!e||!e.segments||e.segments.length===0)return null;let t=0,n;for(let r=0;r<e.segments.length&&(n=e.segments[r],t=n.videoTimingInfo?n.videoTimingInfo.transmuxedPresentationEnd:t+n.duration,!(i<=t));r++);const s=e.segments[e.segments.length-1];if(s.videoTimingInfo&&s.videoTimingInfo.transmuxedPresentationEnd<i)return null;if(i>t){if(i>t+s.duration*dp)return null;n=s}return{segment:n,estimatedStart:n.videoTimingInfo?n.videoTimingInfo.transmuxedPresentationStart:t-n.duration,type:n.videoTimingInfo?"accurate":"estimate"}},kT=(i,e)=>{let t,n;try{t=new Date(i),n=new Date(e)}catch{}const s=t.getTime();return(n.getTime()-s)/1e3},CT=i=>{if(!i.segments||i.segments.length===0)return!1;for(let e=0;e<i.segments.length;e++)if(!i.segments[e].dateTimeObject)return!1;return!0},IT=({playlist:i,time:e=void 0,callback:t})=>{if(!t)throw new Error("getProgramTime: callback must be provided");if(!i||e===void 0)return t({message:"getProgramTime: playlist and time must be provided"});const n=wT(e,i);if(!n)return t({message:"valid programTime was not found"});if(n.type==="estimate")return t({message:"Accurate programTime could not be determined. Please seek to e.seekTime and try again",seekTime:n.estimatedStart});const s={mediaSeconds:e},r=vT(e,n.segment);return r&&(s.programDateTime=r.toISOString()),t(null,s)},hp=({programTime:i,playlist:e,retryCount:t=2,seekTo:n,pauseAfterSeek:s=!0,tech:r,callback:a})=>{if(!a)throw new Error("seekToProgramTime: callback must be provided");if(typeof i>"u"||!e||!n)return a({message:"seekToProgramTime: programTime, seekTo and playlist must be provided"});if(!e.endList&&!r.hasStarted_)return a({message:"player must be playing a live stream to start buffering"});if(!CT(e))return a({message:"programDateTime tags must be provided in the manifest "+e.resolvedUri});const l=ET(i,e);if(!l)return a({message:`${i} was not found in the stream`});const c=l.segment,f=kT(c.dateTimeObject,i);if(l.type==="estimate"){if(t===0)return a({message:`${i} is not buffered yet. Try again`});n(l.estimatedStart+f),r.one("seeked",()=>{hp({programTime:i,playlist:e,retryCount:t-1,seekTo:n,pauseAfterSeek:s,tech:r,callback:a})});return}const m=c.start+f,b=()=>a(null,r.currentTime());r.one("seeked",b),s&&r.pause(),n(m)},Va=(i,e)=>{if(i.readyState===4)return e()},xT=(i,e,t,n)=>{let s=[],r,a=!1;const l=function(m,b,C,w){return b.abort(),a=!0,t(m,b,C,w)},c=function(m,b){if(a)return;if(m)return m.metadata=$i({requestType:n,request:b,error:m}),l(m,b,"",s);const C=b.responseText.substring(s&&s.byteLength||0,b.responseText.length);if(s=a0(s,dh(C,!0)),r=r||is(s),s.length<10||r&&s.length<r+2)return Va(b,()=>l(m,b,"",s));const w=Do(s);return w==="ts"&&s.length<188?Va(b,()=>l(m,b,"",s)):!w&&s.length<376?Va(b,()=>l(m,b,"",s)):l(null,b,w,s)},f=e({uri:i,beforeSend(m){m.overrideMimeType("text/plain; charset=x-user-defined"),m.addEventListener("progress",function({total:b,loaded:C}){return ho(m,null,{statusCode:m.status},c)})}},function(m,b){return ho(f,m,b,c)});return f},{EventTarget:AT}=B,ud=function(i,e){if(!rp(i,e)||i.sidx&&e.sidx&&(i.sidx.offset!==e.sidx.offset||i.sidx.length!==e.sidx.length)||!i.sidx&&e.sidx||i.sidx&&!e.sidx||i.segments&&!e.segments||!i.segments&&e.segments)return!1;if(!i.segments&&!e.segments)return!0;for(let t=0;t<i.segments.length;t++){const n=i.segments[t],s=e.segments[t];if(n.uri!==s.uri)return!1;if(!n.byterange&&!s.byterange)continue;const r=n.byterange,a=s.byterange;if(r&&!a||!r&&a||r.offset!==a.offset||r.length!==a.length)return!1}return!0},PT=(i,e,t,n)=>{const s=n.attributes.NAME||t;return`placeholder-uri-${i}-${e}-${s}`},LT=({mainXml:i,srcUrl:e,clientOffset:t,sidxMapping:n,previousManifest:s})=>{const r=Z0(i,{manifestUri:e,clientOffset:t,sidxMapping:n,previousManifest:s});return tp(r,e,PT),r},DT=(i,e)=>{An(i,(t,n,s,r)=>{(!e.mediaGroups[n][s]||!(r in e.mediaGroups[n][s]))&&delete i.mediaGroups[n][s][r]})},OT=(i,e,t)=>{let n=!0,s=fe(i,{duration:e.duration,minimumUpdatePeriod:e.minimumUpdatePeriod,timelineStarts:e.timelineStarts});for(let r=0;r<e.playlists.length;r++){const a=e.playlists[r];if(a.sidx){const c=Ur(a.sidx);t&&t[c]&&t[c].sidx&&Ao(a,t[c].sidx,a.sidx.resolvedUri)}const l=lo(s,a,ud);l&&(s=l,n=!1)}return An(e,(r,a,l,c)=>{if(r.playlists&&r.playlists.length){const f=r.playlists[0].id,m=lo(s,r.playlists[0],ud);m&&(s=m,c in s.mediaGroups[a][l]||(s.mediaGroups[a][l][c]=r),s.mediaGroups[a][l][c].playlists[0]=s.playlists[f],n=!1)}}),DT(s,e),e.minimumUpdatePeriod!==i.minimumUpdatePeriod&&(n=!1),n?null:s},MT=(i,e)=>(!i.map&&!e.map||!!(i.map&&e.map&&i.map.byterange.offset===e.map.byterange.offset&&i.map.byterange.length===e.map.byterange.length))&&i.uri===e.uri&&i.byterange.offset===e.byterange.offset&&i.byterange.length===e.byterange.length,dd=(i,e)=>{const t={};for(const n in i){const s=i[n].sidx;if(s){const r=Ur(s);if(!e[r])break;const a=e[r].sidxInfo;MT(a,s)&&(t[r]=e[r])}}return t},RT=(i,e)=>{let t=dd(i.playlists,e);return An(i,(n,s,r,a)=>{if(n.playlists&&n.playlists.length){const l=n.playlists;t=fe(t,dd(l,e))}}),t};class po extends AT{constructor(e,t,n={},s){super(),this.isPaused_=!0,this.mainPlaylistLoader_=s||this,s||(this.isMain_=!0);const{withCredentials:r=!1}=n;if(this.vhs_=t,this.withCredentials=r,this.addMetadataToTextTrack=n.addMetadataToTextTrack,!e)throw new Error("A non-empty playlist URL or object is required");this.on("minimumUpdatePeriod",()=>{this.refreshXml_()}),this.on("mediaupdatetimeout",()=>{this.refreshMedia_(this.media().id)}),this.state="HAVE_NOTHING",this.loadedPlaylists_={},this.logger_=Lt("DashPlaylistLoader"),this.isMain_?(this.mainPlaylistLoader_.srcUrl=e,this.mainPlaylistLoader_.sidxMapping_={}):this.childPlaylist_=e}get isPaused(){return this.isPaused_}requestErrored_(e,t,n){if(!this.request)return!0;if(this.request=null,e)return this.error=typeof e=="object"&&!(e instanceof Error)?e:{status:t.status,message:"DASH request error at URL: "+t.uri,response:t.response,code:2,metadata:e.metadata},n&&(this.state=n),this.trigger("error"),!0}addSidxSegments_(e,t,n){const s=e.sidx&&Ur(e.sidx);if(!e.sidx||!s||this.mainPlaylistLoader_.sidxMapping_[s]){x.clearTimeout(this.mediaRequest_),this.mediaRequest_=x.setTimeout(()=>n(!1),0);return}const r=kr(e.sidx.resolvedUri),a=(c,f)=>{if(this.requestErrored_(c,f,t))return;const m=this.mainPlaylistLoader_.sidxMapping_,{requestType:b}=f;let C;try{C=r1(ie(f.response).subarray(8))}catch(w){w.metadata=$i({requestType:b,request:f,parseFailure:!0}),this.requestErrored_(w,f,t);return}return m[s]={sidxInfo:e.sidx,sidx:C},Ao(e,C,e.sidx.resolvedUri),n(!0)},l="dash-sidx";this.request=xT(r,this.vhs_.xhr,(c,f,m,b)=>{if(c)return a(c,f);if(!m||m!=="mp4"){const A=m||"unknown";return a({status:f.status,message:`Unsupported ${A} container type for sidx segment at URL: ${r}`,response:"",playlist:e,internal:!0,playlistExclusionDuration:1/0,code:2},f)}const{offset:C,length:w}=e.sidx.byterange;if(b.length>=w+C)return a(c,{response:b.subarray(C,C+w),status:f.status,uri:f.uri});this.request=this.vhs_.xhr({uri:r,responseType:"arraybuffer",requestType:"dash-sidx",headers:co({byterange:e.sidx.byterange})},a)},l)}dispose(){this.isPaused_=!0,this.trigger("dispose"),this.stopRequest(),this.loadedPlaylists_={},x.clearTimeout(this.minimumUpdatePeriodTimeout_),x.clearTimeout(this.mediaRequest_),x.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null,this.mediaRequest_=null,this.minimumUpdatePeriodTimeout_=null,this.mainPlaylistLoader_.createMupOnMedia_&&(this.off("loadedmetadata",this.mainPlaylistLoader_.createMupOnMedia_),this.mainPlaylistLoader_.createMupOnMedia_=null),this.off()}hasPendingRequest(){return this.request||this.mediaRequest_}stopRequest(){if(this.request){const e=this.request;this.request=null,e.onreadystatechange=null,e.abort()}}media(e){if(!e)return this.media_;if(this.state==="HAVE_NOTHING")throw new Error("Cannot switch media playlist from "+this.state);const t=this.state;if(typeof e=="string"){if(!this.mainPlaylistLoader_.main.playlists[e])throw new Error("Unknown playlist URI: "+e);e=this.mainPlaylistLoader_.main.playlists[e]}const n=!this.media_||e.id!==this.media_.id;if(n&&this.loadedPlaylists_[e.id]&&this.loadedPlaylists_[e.id].endList){this.state="HAVE_METADATA",this.media_=e,n&&(this.trigger("mediachanging"),this.trigger("mediachange"));return}n&&(this.media_&&this.trigger("mediachanging"),this.addSidxSegments_(e,t,s=>{this.haveMetadata({startingState:t,playlist:e})}))}haveMetadata({startingState:e,playlist:t}){this.state="HAVE_METADATA",this.loadedPlaylists_[t.id]=t,x.clearTimeout(this.mediaRequest_),this.mediaRequest_=null,this.refreshMedia_(t.id),e==="HAVE_MAIN_MANIFEST"?this.trigger("loadedmetadata"):this.trigger("mediachange")}pause(){this.isPaused_=!0,this.mainPlaylistLoader_.createMupOnMedia_&&(this.off("loadedmetadata",this.mainPlaylistLoader_.createMupOnMedia_),this.mainPlaylistLoader_.createMupOnMedia_=null),this.stopRequest(),x.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null,this.isMain_&&(x.clearTimeout(this.mainPlaylistLoader_.minimumUpdatePeriodTimeout_),this.mainPlaylistLoader_.minimumUpdatePeriodTimeout_=null),this.state==="HAVE_NOTHING"&&(this.started=!1)}load(e){this.isPaused_=!1,x.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null;const t=this.media();if(e){const n=t?t.targetDuration/2*1e3:5e3;this.mediaUpdateTimeout=x.setTimeout(()=>this.load(),n);return}if(!this.started){this.start();return}t&&!t.endList?(this.isMain_&&!this.minimumUpdatePeriodTimeout_&&(this.trigger("minimumUpdatePeriod"),this.updateMinimumUpdatePeriodTimeout_()),this.trigger("mediaupdatetimeout")):this.trigger("loadedplaylist")}start(){if(this.started=!0,!this.isMain_){x.clearTimeout(this.mediaRequest_),this.mediaRequest_=x.setTimeout(()=>this.haveMain_(),0);return}this.requestMain_((e,t)=>{this.haveMain_(),!this.hasPendingRequest()&&!this.media_&&this.media(this.mainPlaylistLoader_.main.playlists[0])})}requestMain_(e){const t={manifestInfo:{uri:this.mainPlaylistLoader_.srcUrl}};this.trigger({type:"manifestrequeststart",metadata:t}),this.request=this.vhs_.xhr({uri:this.mainPlaylistLoader_.srcUrl,withCredentials:this.withCredentials,requestType:"dash-manifest"},(n,s)=>{if(n){const{requestType:a}=s;n.metadata=$i({requestType:a,request:s,error:n})}if(this.requestErrored_(n,s)){this.state==="HAVE_NOTHING"&&(this.started=!1);return}this.trigger({type:"manifestrequestcomplete",metadata:t});const r=s.responseText!==this.mainPlaylistLoader_.mainXml_;if(this.mainPlaylistLoader_.mainXml_=s.responseText,s.responseHeaders&&s.responseHeaders.date?this.mainLoaded_=Date.parse(s.responseHeaders.date):this.mainLoaded_=Date.now(),this.mainPlaylistLoader_.srcUrl=kr(this.mainPlaylistLoader_.srcUrl,s),r){this.handleMain_(),this.syncClientServerClock_(()=>e(s,r));return}return e(s,r)})}syncClientServerClock_(e){const t=e1(this.mainPlaylistLoader_.mainXml_);if(t===null)return this.mainPlaylistLoader_.clientOffset_=this.mainLoaded_-Date.now(),e();if(t.method==="DIRECT")return this.mainPlaylistLoader_.clientOffset_=t.value-Date.now(),e();this.request=this.vhs_.xhr({uri:pt(this.mainPlaylistLoader_.srcUrl,t.value),method:t.method,withCredentials:this.withCredentials,requestType:"dash-clock-sync"},(n,s)=>{if(!this.request)return;if(n){const{requestType:a}=s;return this.error.metadata=$i({requestType:a,request:s,error:n}),this.mainPlaylistLoader_.clientOffset_=this.mainLoaded_-Date.now(),e()}let r;t.method==="HEAD"?!s.responseHeaders||!s.responseHeaders.date?r=this.mainLoaded_:r=Date.parse(s.responseHeaders.date):r=Date.parse(s.responseText),this.mainPlaylistLoader_.clientOffset_=r-Date.now(),e()})}haveMain_(){this.state="HAVE_MAIN_MANIFEST",this.isMain_?this.trigger("loadedplaylist"):this.media_||this.media(this.childPlaylist_)}handleMain_(){x.clearTimeout(this.mediaRequest_),this.mediaRequest_=null;const e=this.mainPlaylistLoader_.main,t={manifestInfo:{uri:this.mainPlaylistLoader_.srcUrl}};this.trigger({type:"manifestparsestart",metadata:t});let n;try{n=LT({mainXml:this.mainPlaylistLoader_.mainXml_,srcUrl:this.mainPlaylistLoader_.srcUrl,clientOffset:this.mainPlaylistLoader_.clientOffset_,sidxMapping:this.mainPlaylistLoader_.sidxMapping_,previousManifest:e})}catch(r){this.error=r,this.error.metadata={errorType:B.Error.StreamingDashManifestParserError,error:r},this.trigger("error")}e&&(n=OT(e,n,this.mainPlaylistLoader_.sidxMapping_)),this.mainPlaylistLoader_.main=n||e;const s=this.mainPlaylistLoader_.main.locations&&this.mainPlaylistLoader_.main.locations[0];if(s&&s!==this.mainPlaylistLoader_.srcUrl&&(this.mainPlaylistLoader_.srcUrl=s),(!e||n&&n.minimumUpdatePeriod!==e.minimumUpdatePeriod)&&this.updateMinimumUpdatePeriodTimeout_(),this.addEventStreamToMetadataTrack_(n),n){const{duration:r,endList:a}=n,l=[];n.playlists.forEach(f=>{l.push({id:f.id,bandwidth:f.attributes.BANDWIDTH,resolution:f.attributes.RESOLUTION,codecs:f.attributes.CODECS})});const c={duration:r,isLive:!a,renditions:l};t.parsedManifest=c,this.trigger({type:"manifestparsecomplete",metadata:t})}return!!n}updateMinimumUpdatePeriodTimeout_(){const e=this.mainPlaylistLoader_;e.createMupOnMedia_&&(e.off("loadedmetadata",e.createMupOnMedia_),e.createMupOnMedia_=null),e.minimumUpdatePeriodTimeout_&&(x.clearTimeout(e.minimumUpdatePeriodTimeout_),e.minimumUpdatePeriodTimeout_=null);let t=e.main&&e.main.minimumUpdatePeriod;if(t===0&&(e.media()?t=e.media().targetDuration*1e3:(e.createMupOnMedia_=e.updateMinimumUpdatePeriodTimeout_,e.one("loadedmetadata",e.createMupOnMedia_))),typeof t!="number"||t<=0){t<0&&this.logger_(`found invalid minimumUpdatePeriod of ${t}, not setting a timeout`);return}this.createMUPTimeout_(t)}createMUPTimeout_(e){const t=this.mainPlaylistLoader_;t.minimumUpdatePeriodTimeout_=x.setTimeout(()=>{t.minimumUpdatePeriodTimeout_=null,t.trigger("minimumUpdatePeriod"),t.createMUPTimeout_(e)},e)}refreshXml_(){this.requestMain_((e,t)=>{t&&(this.media_&&(this.media_=this.mainPlaylistLoader_.main.playlists[this.media_.id]),this.mainPlaylistLoader_.sidxMapping_=RT(this.mainPlaylistLoader_.main,this.mainPlaylistLoader_.sidxMapping_),this.addSidxSegments_(this.media(),this.state,n=>{this.refreshMedia_(this.media().id)}))})}refreshMedia_(e){if(!e)throw new Error("refreshMedia_ must take a media id");this.media_&&this.isMain_&&this.handleMain_();const t=this.mainPlaylistLoader_.main.playlists,n=!this.media_||this.media_!==t[e];if(n?this.media_=t[e]:this.trigger("playlistunchanged"),!this.mediaUpdateTimeout){const s=()=>{this.media().endList||(this.mediaUpdateTimeout=x.setTimeout(()=>{this.trigger("mediaupdatetimeout"),s()},uo(this.media(),!!n)))};s()}this.trigger("loadedplaylist")}addEventStreamToMetadataTrack_(e){if(e&&this.mainPlaylistLoader_.main.eventStream){const t=this.mainPlaylistLoader_.main.eventStream.map(n=>({cueTime:n.start,frames:[{data:n.messageData}]}));this.addMetadataToTextTrack("EventStream",t,this.mainPlaylistLoader_.main.duration)}}getKeyIdSet(e){if(e.contentProtection){const t=new Set;for(const n in e.contentProtection){const s=e.contentProtection[n].attributes["cenc:default_KID"];s&&t.add(s.replace(/-/g,"").toLowerCase())}return t}}}var We={GOAL_BUFFER_LENGTH:30,MAX_GOAL_BUFFER_LENGTH:60,BACK_BUFFER_LENGTH:30,GOAL_BUFFER_LENGTH_RATE:1,INITIAL_BANDWIDTH:4194304,BANDWIDTH_VARIANCE:1.2,BUFFER_LOW_WATER_LINE:0,MAX_BUFFER_LOW_WATER_LINE:30,EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE:16,BUFFER_LOW_WATER_LINE_RATE:1,BUFFER_HIGH_WATER_LINE:30};const UT=i=>{const e=new Uint8Array(new ArrayBuffer(i.length));for(let t=0;t<i.length;t++)e[t]=i.charCodeAt(t);return e.buffer},cp=function(i){return i.on=i.addEventListener,i.off=i.removeEventListener,i},NT=function(i){try{return URL.createObjectURL(new Blob([i],{type:"application/javascript"}))}catch{const e=new BlobBuilder;return e.append(i),URL.createObjectURL(e.getBlob())}},pp=function(i){return function(){const e=NT(i),t=cp(new Worker(e));t.objURL=e;const n=t.terminate;return t.on=t.addEventListener,t.off=t.removeEventListener,t.terminate=function(){return URL.revokeObjectURL(e),n.call(this)},t}},gp=function(i){return`var browserWorkerPolyFill = ${cp.toString()};
|
|
187
|
+
`)}}io(1,B);B.VERSION=Ja;B.options=ke.prototype.options_;B.getPlayers=()=>ke.players;B.getPlayer=s=>{const e=ke.players;let t;if(typeof s=="string"){const i=Fh(s),n=e[i];if(n)return n;t=Ei("#"+i)}else t=s;if(Cs(t)){const{player:i,playerId:n}=t;if(i||e[n])return i||e[n]}};B.getAllPlayers=()=>Object.keys(ke.players).map(s=>ke.players[s]).filter(Boolean);B.players=ke.players;B.getComponent=H.getComponent;B.registerComponent=(s,e)=>(oe.isTech(e)&&ue.warn(`The ${s} tech was registered as a component. It should instead be registered using videojs.registerTech(name, tech)`),H.registerComponent.call(H,s,e));B.getTech=oe.getTech;B.registerTech=oe.registerTech;B.use=WT;Object.defineProperty(B,"middleware",{value:{},writeable:!1,enumerable:!0});Object.defineProperty(B.middleware,"TERMINATOR",{value:br,writeable:!1,enumerable:!0});B.browser=Dd;B.obj=vT;B.mergeOptions=Bt(9,"videojs.mergeOptions","videojs.obj.merge",xe);B.defineLazyProperty=Bt(9,"videojs.defineLazyProperty","videojs.obj.defineLazyProperty",Vr);B.bind=Bt(9,"videojs.bind","native Function.prototype.bind",we);B.registerPlugin=ft.registerPlugin;B.deregisterPlugin=ft.deregisterPlugin;B.plugin=(s,e)=>(ue.warn("videojs.plugin() is deprecated; use videojs.registerPlugin() instead"),ft.registerPlugin(s,e));B.getPlugins=ft.getPlugins;B.getPlugin=ft.getPlugin;B.getPluginVersion=ft.getPluginVersion;B.addLanguage=function(s,e){return s=(""+s).toLowerCase(),B.options.languages=xe(B.options.languages,{[s]:e}),B.options.languages[s]};B.log=ue;B.createLogger=Sd;B.time=MT;B.createTimeRange=Bt(9,"videojs.createTimeRange","videojs.time.createTimeRanges",Nt);B.createTimeRanges=Bt(9,"videojs.createTimeRanges","videojs.time.createTimeRanges",Nt);B.formatTime=Bt(9,"videojs.formatTime","videojs.time.formatTime",Hi);B.setFormatTime=Bt(9,"videojs.setFormatTime","videojs.time.setFormatTime",eh);B.resetFormatTime=Bt(9,"videojs.resetFormatTime","videojs.time.resetFormatTime",th);B.parseUrl=Bt(9,"videojs.parseUrl","videojs.url.parseUrl",Wo);B.isCrossOrigin=Bt(9,"videojs.isCrossOrigin","videojs.url.isCrossOrigin",ea);B.EventTarget=bt;B.any=Vo;B.on=vt;B.one=Jr;B.off=et;B.trigger=ws;B.xhr=Zc;B.TextTrack=xn;B.AudioTrack=rh;B.VideoTrack=ah;["isEl","isTextNode","createEl","hasClass","addClass","removeClass","toggleClass","setAttributes","getAttributes","emptyEl","appendContent","insertContent"].forEach(s=>{B[s]=function(){return ue.warn(`videojs.${s}() is deprecated; use videojs.dom.${s}() instead`),qd[s].apply(null,arguments)}});B.computedStyle=Bt(9,"videojs.computedStyle","videojs.dom.computedStyle",vs);B.dom=qd;B.fn=kT;B.num=fv;B.str=OT;B.url=qT;B.Error=Bv;/*! @name videojs-contrib-quality-levels @version 4.1.0 @license Apache-2.0 */class Fv{constructor(e){let t=this;return t.id=e.id,t.label=t.id,t.width=e.width,t.height=e.height,t.bitrate=e.bandwidth,t.frameRate=e.frameRate,t.enabled_=e.enabled,Object.defineProperty(t,"enabled",{get(){return t.enabled_()},set(i){t.enabled_(i)}}),t}}class wr extends B.EventTarget{constructor(){super();let e=this;return e.levels_=[],e.selectedIndex_=-1,Object.defineProperty(e,"selectedIndex",{get(){return e.selectedIndex_}}),Object.defineProperty(e,"length",{get(){return e.levels_.length}}),e[Symbol.iterator]=()=>e.levels_.values(),e}addQualityLevel(e){let t=this.getQualityLevelById(e.id);if(t)return t;const i=this.levels_.length;return t=new Fv(e),""+i in this||Object.defineProperty(this,i,{get(){return this.levels_[i]}}),this.levels_.push(t),this.trigger({qualityLevel:t,type:"addqualitylevel"}),t}removeQualityLevel(e){let t=null;for(let i=0,n=this.length;i<n;i++)if(this[i]===e){t=this.levels_.splice(i,1)[0],this.selectedIndex_===i?this.selectedIndex_=-1:this.selectedIndex_>i&&this.selectedIndex_--;break}return t&&this.trigger({qualityLevel:e,type:"removequalitylevel"}),t}getQualityLevelById(e){for(let t=0,i=this.length;t<i;t++){const n=this[t];if(n.id===e)return n}return null}dispose(){this.selectedIndex_=-1,this.levels_.length=0}}wr.prototype.allowedEvents_={change:"change",addqualitylevel:"addqualitylevel",removequalitylevel:"removequalitylevel"};for(const s in wr.prototype.allowedEvents_)wr.prototype["on"+s]=null;var $h="4.1.0";const $v=function(s,e){const t=s.qualityLevels,i=new wr,n=function(){i.dispose(),s.qualityLevels=t,s.off("dispose",n)};return s.on("dispose",n),s.qualityLevels=()=>i,s.qualityLevels.VERSION=$h,i},jh=function(s){return $v(this,B.obj.merge({},s))};B.registerPlugin("qualityLevels",jh);jh.VERSION=$h;/*! @name @videojs/http-streaming @version 3.16.2 @license Apache-2.0 */const dt=Ur,Ir=(s,e)=>e&&e.responseURL&&s!==e.responseURL?e.responseURL:s,Pt=s=>B.log.debug?B.log.debug.bind(B,"VHS:",`${s} >`):function(){};function ge(...s){const e=B.obj||B;return(e.merge||e.mergeOptions).apply(e,s)}function Ke(...s){const e=B.time||B;return(e.createTimeRanges||e.createTimeRanges).apply(e,s)}function jv(s){if(s.length===0)return"Buffered Ranges are empty";let e=`Buffered Ranges:
|
|
188
|
+
`;for(let t=0;t<s.length;t++){const i=s.start(t),n=s.end(t);e+=`${i} --> ${n}. Duration (${n-i})
|
|
189
|
+
`}return e}const Xt=1/30,Yt=Xt*3,Vh=function(s,e){const t=[];let i;if(s&&s.length)for(i=0;i<s.length;i++)e(s.start(i),s.end(i))&&t.push([s.start(i),s.end(i)]);return Ke(t)},ss=function(s,e){return Vh(s,function(t,i){return t-Yt<=e&&i+Yt>=e})},sr=function(s,e){return Vh(s,function(t){return t-Xt>=e})},Vv=function(s){if(s.length<2)return Ke();const e=[];for(let t=1;t<s.length;t++){const i=s.end(t-1),n=s.start(t);e.push([i,n])}return Ke(e)},Hv=function(s,e){let t=null,i=null,n=0;const r=[],a=[];if(!s||!s.length||!e||!e.length)return Ke();let l=s.length;for(;l--;)r.push({time:s.start(l),type:"start"}),r.push({time:s.end(l),type:"end"});for(l=e.length;l--;)r.push({time:e.start(l),type:"start"}),r.push({time:e.end(l),type:"end"});for(r.sort(function(h,f){return h.time-f.time}),l=0;l<r.length;l++)r[l].type==="start"?(n++,n===2&&(t=r[l].time)):r[l].type==="end"&&(n--,n===1&&(i=r[l].time)),t!==null&&i!==null&&(a.push([t,i]),t=null,i=null);return Ke(a)},Hh=s=>{const e=[];if(!s||!s.length)return"";for(let t=0;t<s.length;t++)e.push(s.start(t)+" => "+s.end(t));return e.join(", ")},qv=function(s,e,t=1){return((s.length?s.end(s.length-1):0)-e)/t},Ui=s=>{const e=[];for(let t=0;t<s.length;t++)e.push({start:s.start(t),end:s.end(t)});return e},zv=function(s,e){if(s===e)return!1;if(!s&&e||!e&&s||s.length!==e.length)return!0;for(let t=0;t<s.length;t++)if(s.start(t)!==e.start(t)||s.end(t)!==e.end(t))return!0;return!1},za=function(s){if(!(!s||!s.length||!s.end))return s.end(s.length-1)},ul=function(s,e){let t=0;if(!s||!s.length)return t;for(let i=0;i<s.length;i++){const n=s.start(i),r=s.end(i);if(!(e>r)){if(e>n&&e<=r){t+=r-e;continue}t+=r-n}}return t},cl=(s,e)=>{if(!e.preload)return e.duration;let t=0;return(e.parts||[]).forEach(function(i){t+=i.duration}),(e.preloadHints||[]).forEach(function(i){i.type==="PART"&&(t+=s.partTargetDuration)}),t},uo=s=>(s.segments||[]).reduce((e,t,i)=>(t.parts?t.parts.forEach(function(n,r){e.push({duration:n.duration,segmentIndex:i,partIndex:r,part:n,segment:t})}):e.push({duration:t.duration,segmentIndex:i,partIndex:null,segment:t,part:null}),e),[]),qh=s=>{const e=s.segments&&s.segments.length&&s.segments[s.segments.length-1];return e&&e.parts||[]},zh=({preloadSegment:s})=>{if(!s)return;const{parts:e,preloadHints:t}=s;let i=(t||[]).reduce((n,r)=>n+(r.type==="PART"?1:0),0);return i+=e&&e.length?e.length:0,i},Wh=(s,e)=>{if(e.endList)return 0;if(s&&s.suggestedPresentationDelay)return s.suggestedPresentationDelay;const t=qh(e).length>0;return t&&e.serverControl&&e.serverControl.partHoldBack?e.serverControl.partHoldBack:t&&e.partTargetDuration?e.partTargetDuration*3:e.serverControl&&e.serverControl.holdBack?e.serverControl.holdBack:e.targetDuration?e.targetDuration*3:0},Wv=function(s,e){let t=0,i=e-s.mediaSequence,n=s.segments[i];if(n){if(typeof n.start<"u")return{result:n.start,precise:!0};if(typeof n.end<"u")return{result:n.end-n.duration,precise:!0}}for(;i--;){if(n=s.segments[i],typeof n.end<"u")return{result:t+n.end,precise:!0};if(t+=cl(s,n),typeof n.start<"u")return{result:t+n.start,precise:!0}}return{result:t,precise:!1}},Gv=function(s,e){let t=0,i,n=e-s.mediaSequence;for(;n<s.segments.length;n++){if(i=s.segments[n],typeof i.start<"u")return{result:i.start-t,precise:!0};if(t+=cl(s,i),typeof i.end<"u")return{result:i.end-t,precise:!0}}return{result:-1,precise:!1}},Gh=function(s,e,t){if(typeof e>"u"&&(e=s.mediaSequence+s.segments.length),e<s.mediaSequence)return 0;const i=Wv(s,e);if(i.precise)return i.result;const n=Gv(s,e);return n.precise?n.result:i.result+t},Kh=function(s,e,t){if(!s)return 0;if(typeof t!="number"&&(t=0),typeof e>"u"){if(s.totalDuration)return s.totalDuration;if(!s.endList)return k.Infinity}return Gh(s,e,t)},mn=function({defaultDuration:s,durationList:e,startIndex:t,endIndex:i}){let n=0;if(t>i&&([t,i]=[i,t]),t<0){for(let r=t;r<Math.min(0,i);r++)n+=s;t=0}for(let r=t;r<i;r++)n+=e[r].duration;return n},Xh=function(s,e,t,i){if(!s||!s.segments)return null;if(s.endList)return Kh(s);if(e===null)return null;e=e||0;let n=Gh(s,s.mediaSequence+s.segments.length,e);return t&&(i=typeof i=="number"?i:Wh(null,s),n-=i),Math.max(0,n)},Kv=function(s,e,t){const n=e||0;let r=Xh(s,e,!0,t);return r===null?Ke():(r<n&&(r=n),Ke(n,r))},Xv=function({playlist:s,currentTime:e,startingSegmentIndex:t,startingPartIndex:i,startTime:n,exactManifestTimings:r}){let a=e-n;const l=uo(s);let h=0;for(let f=0;f<l.length;f++){const m=l[f];if(t===m.segmentIndex&&!(typeof i=="number"&&typeof m.partIndex=="number"&&i!==m.partIndex)){h=f;break}}if(a<0){if(h>0)for(let f=h-1;f>=0;f--){const m=l[f];if(a+=m.duration,r){if(a<0)continue}else if(a+Xt<=0)continue;return{partIndex:m.partIndex,segmentIndex:m.segmentIndex,startTime:n-mn({defaultDuration:s.targetDuration,durationList:l,startIndex:h,endIndex:f})}}return{partIndex:l[0]&&l[0].partIndex||null,segmentIndex:l[0]&&l[0].segmentIndex||0,startTime:e}}if(h<0){for(let f=h;f<0;f++)if(a-=s.targetDuration,a<0)return{partIndex:l[0]&&l[0].partIndex||null,segmentIndex:l[0]&&l[0].segmentIndex||0,startTime:e};h=0}for(let f=h;f<l.length;f++){const m=l[f];a-=m.duration;const T=m.duration>Xt,E=a===0,C=T&&a+Xt>=0;if(!((E||C)&&f!==l.length-1)){if(r){if(a>0)continue}else if(a-Xt>=0)continue;return{partIndex:m.partIndex,segmentIndex:m.segmentIndex,startTime:n+mn({defaultDuration:s.targetDuration,durationList:l,startIndex:h,endIndex:f})}}}return{segmentIndex:l[l.length-1].segmentIndex,partIndex:l[l.length-1].partIndex,startTime:e}},Yh=function(s){return s.excludeUntil&&s.excludeUntil>Date.now()},dl=function(s){return s.excludeUntil&&s.excludeUntil===1/0},na=function(s){const e=Yh(s);return!s.disabled&&!e},Yv=function(s){return s.disabled},Qv=function(s){for(let e=0;e<s.segments.length;e++)if(s.segments[e].key)return!0;return!1},Qh=function(s,e){return e.attributes&&e.attributes[s]},Jv=function(s,e,t,i=0){return Qh("BANDWIDTH",t)?(s*t.attributes.BANDWIDTH-i*8)/e:NaN},co=(s,e)=>{if(s.playlists.length===1)return!0;const t=e.attributes.BANDWIDTH||Number.MAX_VALUE;return s.playlists.filter(i=>na(i)?(i.attributes.BANDWIDTH||0)<t:!1).length===0},hl=(s,e)=>!s&&!e||!s&&e||s&&!e?!1:!!(s===e||s.id&&e.id&&s.id===e.id||s.resolvedUri&&e.resolvedUri&&s.resolvedUri===e.resolvedUri||s.uri&&e.uri&&s.uri===e.uri),ac=function(s,e){const t=s&&s.mediaGroups&&s.mediaGroups.AUDIO||{};let i=!1;for(const n in t){for(const r in t[n])if(i=e(t[n][r]),i)break;if(i)break}return!!i},wn=s=>{if(!s||!s.playlists||!s.playlists.length)return ac(s,t=>t.playlists&&t.playlists.length||t.uri);for(let e=0;e<s.playlists.length;e++){const t=s.playlists[e],i=t.attributes&&t.attributes.CODECS;if(!(i&&i.split(",").every(r=>od(r))||ac(s,r=>hl(t,r))))return!1}return!0};var ht={liveEdgeDelay:Wh,duration:Kh,seekable:Kv,getMediaInfoForTime:Xv,isEnabled:na,isDisabled:Yv,isExcluded:Yh,isIncompatible:dl,playlistEnd:Xh,isAes:Qv,hasAttribute:Qh,estimateSegmentRequestTime:Jv,isLowestEnabledRendition:co,isAudioOnly:wn,playlistMatch:hl,segmentDurationWithParts:cl};const{log:Jh}=B,us=(s,e)=>`${s}-${e}`,Zh=(s,e,t)=>`placeholder-uri-${s}-${e}-${t}`,Zv=({onwarn:s,oninfo:e,manifestString:t,customTagParsers:i=[],customTagMappers:n=[],llhls:r})=>{const a=new Hy;s&&a.on("warn",s),e&&a.on("info",e),i.forEach(f=>a.addParser(f)),n.forEach(f=>a.addTagMapper(f)),a.push(t),a.end();const l=a.manifest;if(r||(["preloadSegment","skip","serverControl","renditionReports","partInf","partTargetDuration"].forEach(function(f){l.hasOwnProperty(f)&&delete l[f]}),l.segments&&l.segments.forEach(function(f){["parts","preloadHints"].forEach(function(m){f.hasOwnProperty(m)&&delete f[m]})})),!l.targetDuration){let f=10;l.segments&&l.segments.length&&(f=l.segments.reduce((m,T)=>Math.max(m,T.duration),0)),s&&s({message:`manifest has no targetDuration defaulting to ${f}`}),l.targetDuration=f}const h=qh(l);if(h.length&&!l.partTargetDuration){const f=h.reduce((m,T)=>Math.max(m,T.duration),0);s&&(s({message:`manifest has no partTargetDuration defaulting to ${f}`}),Jh.error("LL-HLS manifest has parts but lacks required #EXT-X-PART-INF:PART-TARGET value. See https://datatracker.ietf.org/doc/html/draft-pantos-hls-rfc8216bis-09#section-4.4.3.7. Playback is not guaranteed.")),l.partTargetDuration=f}return l},Ps=(s,e)=>{s.mediaGroups&&["AUDIO","SUBTITLES"].forEach(t=>{if(s.mediaGroups[t])for(const i in s.mediaGroups[t])for(const n in s.mediaGroups[t][i]){const r=s.mediaGroups[t][i][n];e(r,t,i,n)}})},ef=({playlist:s,uri:e,id:t})=>{s.id=t,s.playlistErrors_=0,e&&(s.uri=e),s.attributes=s.attributes||{}},eb=s=>{let e=s.playlists.length;for(;e--;){const t=s.playlists[e];ef({playlist:t,id:us(e,t.uri)}),t.resolvedUri=dt(s.uri,t.uri),s.playlists[t.id]=t,s.playlists[t.uri]=t,t.attributes.BANDWIDTH||Jh.warn("Invalid playlist STREAM-INF detected. Missing BANDWIDTH attribute.")}},tb=s=>{Ps(s,e=>{e.uri&&(e.resolvedUri=dt(s.uri,e.uri))})},ib=(s,e)=>{const t=us(0,e),i={mediaGroups:{AUDIO:{},VIDEO:{},"CLOSED-CAPTIONS":{},SUBTITLES:{}},uri:k.location.href,resolvedUri:k.location.href,playlists:[{uri:e,id:t,resolvedUri:e,attributes:{}}]};return i.playlists[t]=i.playlists[0],i.playlists[e]=i.playlists[0],i},tf=(s,e,t=Zh)=>{s.uri=e;for(let n=0;n<s.playlists.length;n++)if(!s.playlists[n].uri){const r=`placeholder-uri-${n}`;s.playlists[n].uri=r}const i=wn(s);Ps(s,(n,r,a,l)=>{if(!n.playlists||!n.playlists.length){if(i&&r==="AUDIO"&&!n.uri)for(let h=0;h<s.playlists.length;h++){const f=s.playlists[h];if(f.attributes&&f.attributes.AUDIO&&f.attributes.AUDIO===a)return}n.playlists=[je({},n)]}n.playlists.forEach(function(h,f){const m=t(r,a,l,h),T=us(f,m);h.uri?h.resolvedUri=h.resolvedUri||dt(s.uri,h.uri):(h.uri=f===0?m:T,h.resolvedUri=h.uri),h.id=h.id||T,h.attributes=h.attributes||{},s.playlists[h.id]=h,s.playlists[h.uri]=h})}),eb(s),tb(s)};class oc{constructor(){this.offset_=null,this.pendingDateRanges_=new Map,this.processedDateRanges_=new Map}setOffset(e=[]){if(this.offset_!==null||!e.length)return;const[t]=e;t.programDateTime!==void 0&&(this.offset_=t.programDateTime/1e3)}setPendingDateRanges(e=[]){if(!e.length)return;const[t]=e,i=t.startDate.getTime();this.trimProcessedDateRanges_(i),this.pendingDateRanges_=e.reduce((n,r)=>(n.set(r.id,r),n),new Map)}processDateRange(e){this.pendingDateRanges_.delete(e.id),this.processedDateRanges_.set(e.id,e)}getDateRangesToProcess(){if(this.offset_===null)return[];const e={},t=[];this.pendingDateRanges_.forEach((i,n)=>{if(!this.processedDateRanges_.has(n)&&(i.startTime=i.startDate.getTime()/1e3-this.offset_,i.processDateRange=()=>this.processDateRange(i),t.push(i),!!i.class))if(e[i.class]){const r=e[i.class].push(i);i.classListIndex=r-1}else e[i.class]=[i],i.classListIndex=0});for(const i of t){const n=e[i.class]||[];i.endDate?i.endTime=i.endDate.getTime()/1e3-this.offset_:i.endOnNext&&n[i.classListIndex+1]?i.endTime=n[i.classListIndex+1].startTime:i.duration?i.endTime=i.startTime+i.duration:i.plannedDuration?i.endTime=i.startTime+i.plannedDuration:i.endTime=i.startTime}return t}trimProcessedDateRanges_(e){new Map(this.processedDateRanges_).forEach((i,n)=>{i.startDate.getTime()<e&&this.processedDateRanges_.delete(n)})}}const sf=22,Vi=({requestType:s,request:e,error:t,parseFailure:i})=>{const n=e.status<200||e.status>299,r=e.status>=400&&e.status<=499,a={uri:e.uri,requestType:s},l=n&&!r||i;if(t&&r)a.error=je({},t),a.errorType=B.Error.NetworkRequestFailed;else if(e.aborted)a.errorType=B.Error.NetworkRequestAborted;else if(e.timedout)a.erroType=B.Error.NetworkRequestTimeout;else if(l){const h=i?B.Error.NetworkBodyParserFailed:B.Error.NetworkBadStatus;a.errorType=h,a.status=e.status,a.headers=e.headers}return a},{EventTarget:sb}=B,nb=(s,e)=>{if(e.endList||!e.serverControl)return s;const t={};if(e.serverControl.canBlockReload){const{preloadSegment:i}=e;let n=e.mediaSequence+e.segments.length;if(i){const r=i.parts||[],a=zh(e)-1;a>-1&&a!==r.length-1&&(t._HLS_part=a),(a>-1||r.length)&&n--}t._HLS_msn=n}if(e.serverControl&&e.serverControl.canSkipUntil&&(t._HLS_skip=e.serverControl.canSkipDateranges?"v2":"YES"),Object.keys(t).length){const i=new k.URL(s);["_HLS_skip","_HLS_msn","_HLS_part"].forEach(function(n){t.hasOwnProperty(n)&&i.searchParams.set(n,t[n])}),s=i.toString()}return s},rb=(s,e)=>{if(!s)return e;const t=ge(s,e);if(s.preloadHints&&!e.preloadHints&&delete t.preloadHints,s.parts&&!e.parts)delete t.parts;else if(s.parts&&e.parts)for(let i=0;i<e.parts.length;i++)s.parts&&s.parts[i]&&(t.parts[i]=ge(s.parts[i],e.parts[i]));return!s.skipped&&e.skipped&&(t.skipped=!1),s.preload&&!e.preload&&(t.preload=!1),t},ab=(s,e,t)=>{const i=s.slice(),n=e.slice();t=t||0;const r=[];let a;for(let l=0;l<n.length;l++){const h=i[l+t],f=n[l];h?(a=h.map||a,r.push(rb(h,f))):(a&&!f.map&&(f.map=a),r.push(f))}return r},nf=(s,e)=>{!s.resolvedUri&&s.uri&&(s.resolvedUri=dt(e,s.uri)),s.key&&!s.key.resolvedUri&&(s.key.resolvedUri=dt(e,s.key.uri)),s.map&&!s.map.resolvedUri&&(s.map.resolvedUri=dt(e,s.map.uri)),s.map&&s.map.key&&!s.map.key.resolvedUri&&(s.map.key.resolvedUri=dt(e,s.map.key.uri)),s.parts&&s.parts.length&&s.parts.forEach(t=>{t.resolvedUri||(t.resolvedUri=dt(e,t.uri))}),s.preloadHints&&s.preloadHints.length&&s.preloadHints.forEach(t=>{t.resolvedUri||(t.resolvedUri=dt(e,t.uri))})},rf=function(s){const e=s.segments||[],t=s.preloadSegment;if(t&&t.parts&&t.parts.length){if(t.preloadHints){for(let i=0;i<t.preloadHints.length;i++)if(t.preloadHints[i].type==="MAP")return e}t.duration=s.targetDuration,t.preload=!0,e.push(t)}return e},af=(s,e)=>s===e||s.segments&&e.segments&&s.segments.length===e.segments.length&&s.endList===e.endList&&s.mediaSequence===e.mediaSequence&&s.preloadSegment===e.preloadSegment,ho=(s,e,t=af)=>{const i=ge(s,{}),n=i.playlists[e.id];if(!n||t(n,e))return null;e.segments=rf(e);const r=ge(n,e);if(r.preloadSegment&&!e.preloadSegment&&delete r.preloadSegment,n.segments){if(e.skip){e.segments=e.segments||[];for(let a=0;a<e.skip.skippedSegments;a++)e.segments.unshift({skipped:!0})}r.segments=ab(n.segments,e.segments,e.mediaSequence-n.mediaSequence)}r.segments.forEach(a=>{nf(a,r.resolvedUri)});for(let a=0;a<i.playlists.length;a++)i.playlists[a].id===e.id&&(i.playlists[a]=r);return i.playlists[e.id]=r,i.playlists[e.uri]=r,Ps(s,(a,l,h,f)=>{if(a.playlists)for(let m=0;m<a.playlists.length;m++)e.id===a.playlists[m].id&&(a.playlists[m]=r)}),i},fo=(s,e)=>{const t=s.segments||[],i=t[t.length-1],n=i&&i.parts&&i.parts[i.parts.length-1],r=n&&n.duration||i&&i.duration;return e&&r?r*1e3:(s.partTargetDuration||s.targetDuration||10)*500},lc=(s,e,t)=>{if(!s)return;const i=[];return s.forEach(n=>{if(!n.attributes)return;const{BANDWIDTH:r,RESOLUTION:a,CODECS:l}=n.attributes;i.push({id:n.id,bandwidth:r,resolution:a,codecs:l})}),{type:e,isLive:t,renditions:i}};class ns extends sb{constructor(e,t,i={}){if(super(),!e)throw new Error("A non-empty playlist URL or object is required");this.logger_=Pt("PlaylistLoader");const{withCredentials:n=!1}=i;this.src=e,this.vhs_=t,this.withCredentials=n,this.addDateRangesToTextTrack_=i.addDateRangesToTextTrack;const r=t.options_;this.customTagParsers=r&&r.customTagParsers||[],this.customTagMappers=r&&r.customTagMappers||[],this.llhls=r&&r.llhls,this.dateRangesStorage_=new oc,this.state="HAVE_NOTHING",this.handleMediaupdatetimeout_=this.handleMediaupdatetimeout_.bind(this),this.on("mediaupdatetimeout",this.handleMediaupdatetimeout_),this.on("loadedplaylist",this.handleLoadedPlaylist_.bind(this))}handleLoadedPlaylist_(){const e=this.media();if(!e)return;this.dateRangesStorage_.setOffset(e.segments),this.dateRangesStorage_.setPendingDateRanges(e.dateRanges);const t=this.dateRangesStorage_.getDateRangesToProcess();!t.length||!this.addDateRangesToTextTrack_||this.addDateRangesToTextTrack_(t)}handleMediaupdatetimeout_(){if(this.state!=="HAVE_METADATA")return;const e=this.media();let t=dt(this.main.uri,e.uri);this.llhls&&(t=nb(t,e)),this.state="HAVE_CURRENT_METADATA",this.request=this.vhs_.xhr({uri:t,withCredentials:this.withCredentials,requestType:"hls-playlist"},(i,n)=>{if(this.request){if(i)return this.playlistRequestError(this.request,this.media(),"HAVE_METADATA");this.haveMetadata({playlistString:this.request.responseText,url:this.media().uri,id:this.media().id})}})}playlistRequestError(e,t,i){const{uri:n,id:r}=t;this.request=null,i&&(this.state=i),this.error={playlist:this.main.playlists[r],status:e.status,message:`HLS playlist request error at URL: ${n}.`,responseText:e.responseText,code:e.status>=500?4:2,metadata:Vi({requestType:e.requestType,request:e,error:e.error})},this.trigger("error")}parseManifest_({url:e,manifestString:t}){try{return Zv({onwarn:({message:i})=>this.logger_(`m3u8-parser warn for ${e}: ${i}`),oninfo:({message:i})=>this.logger_(`m3u8-parser info for ${e}: ${i}`),manifestString:t,customTagParsers:this.customTagParsers,customTagMappers:this.customTagMappers,llhls:this.llhls})}catch(i){this.error=i,this.error.metadata={errorType:B.Error.StreamingHlsPlaylistParserError,error:i}}}haveMetadata({playlistString:e,playlistObject:t,url:i,id:n}){this.request=null,this.state="HAVE_METADATA";const r={playlistInfo:{type:"media",uri:i}};this.trigger({type:"playlistparsestart",metadata:r});const a=t||this.parseManifest_({url:i,manifestString:e});a.lastRequest=Date.now(),ef({playlist:a,uri:i,id:n});const l=ho(this.main,a);this.targetDuration=a.partTargetDuration||a.targetDuration,this.pendingMedia_=null,l?(this.main=l,this.media_=this.main.playlists[n]):this.trigger("playlistunchanged"),this.updateMediaUpdateTimeout_(fo(this.media(),!!l)),r.parsedPlaylist=lc(this.main.playlists,r.playlistInfo.type,!this.media_.endList),this.trigger({type:"playlistparsecomplete",metadata:r}),this.trigger("loadedplaylist")}dispose(){this.trigger("dispose"),this.stopRequest(),k.clearTimeout(this.mediaUpdateTimeout),k.clearTimeout(this.finalRenditionTimeout),this.dateRangesStorage_=new oc,this.off()}stopRequest(){if(this.request){const e=this.request;this.request=null,e.onreadystatechange=null,e.abort()}}media(e,t){if(!e)return this.media_;if(this.state==="HAVE_NOTHING")throw new Error("Cannot switch media playlist from "+this.state);if(typeof e=="string"){if(!this.main.playlists[e])throw new Error("Unknown playlist URI: "+e);e=this.main.playlists[e]}if(k.clearTimeout(this.finalRenditionTimeout),t){const l=(e.partTargetDuration||e.targetDuration)/2*1e3||5e3;this.finalRenditionTimeout=k.setTimeout(this.media.bind(this,e,!1),l);return}const i=this.state,n=!this.media_||e.id!==this.media_.id,r=this.main.playlists[e.id];if(r&&r.endList||e.endList&&e.segments.length){this.request&&(this.request.onreadystatechange=null,this.request.abort(),this.request=null),this.state="HAVE_METADATA",this.media_=e,n&&(this.trigger("mediachanging"),i==="HAVE_MAIN_MANIFEST"?this.trigger("loadedmetadata"):this.trigger("mediachange"));return}if(this.updateMediaUpdateTimeout_(fo(e,!0)),!n)return;if(this.state="SWITCHING_MEDIA",this.request){if(e.resolvedUri===this.request.url)return;this.request.onreadystatechange=null,this.request.abort(),this.request=null}this.media_&&this.trigger("mediachanging"),this.pendingMedia_=e;const a={playlistInfo:{type:"media",uri:e.uri}};this.trigger({type:"playlistrequeststart",metadata:a}),this.request=this.vhs_.xhr({uri:e.resolvedUri,withCredentials:this.withCredentials,requestType:"hls-playlist"},(l,h)=>{if(this.request){if(e.lastRequest=Date.now(),e.resolvedUri=Ir(e.resolvedUri,h),l)return this.playlistRequestError(this.request,e,i);this.trigger({type:"playlistrequestcomplete",metadata:a}),this.haveMetadata({playlistString:h.responseText,url:e.uri,id:e.id}),i==="HAVE_MAIN_MANIFEST"?this.trigger("loadedmetadata"):this.trigger("mediachange")}})}pause(){this.mediaUpdateTimeout&&(k.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null),this.stopRequest(),this.state==="HAVE_NOTHING"&&(this.started=!1),this.state==="SWITCHING_MEDIA"?this.media_?this.state="HAVE_METADATA":this.state="HAVE_MAIN_MANIFEST":this.state==="HAVE_CURRENT_METADATA"&&(this.state="HAVE_METADATA")}load(e){this.mediaUpdateTimeout&&(k.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null);const t=this.media();if(e){const i=t?(t.partTargetDuration||t.targetDuration)/2*1e3:5e3;this.mediaUpdateTimeout=k.setTimeout(()=>{this.mediaUpdateTimeout=null,this.load()},i);return}if(!this.started){this.start();return}t&&!t.endList?this.trigger("mediaupdatetimeout"):this.trigger("loadedplaylist")}updateMediaUpdateTimeout_(e){this.mediaUpdateTimeout&&(k.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null),!(!this.media()||this.media().endList)&&(this.mediaUpdateTimeout=k.setTimeout(()=>{this.mediaUpdateTimeout=null,this.trigger("mediaupdatetimeout"),this.updateMediaUpdateTimeout_(e)},e))}start(){if(this.started=!0,typeof this.src=="object"){this.src.uri||(this.src.uri=k.location.href),this.src.resolvedUri=this.src.uri,setTimeout(()=>{this.setupInitialPlaylist(this.src)},0);return}const e={playlistInfo:{type:"multivariant",uri:this.src}};this.trigger({type:"playlistrequeststart",metadata:e}),this.request=this.vhs_.xhr({uri:this.src,withCredentials:this.withCredentials,requestType:"hls-playlist"},(t,i)=>{if(!this.request)return;if(this.request=null,t)return this.error={status:i.status,message:`HLS playlist request error at URL: ${this.src}.`,responseText:i.responseText,code:2,metadata:Vi({requestType:i.requestType,request:i,error:t})},this.state==="HAVE_NOTHING"&&(this.started=!1),this.trigger("error");this.trigger({type:"playlistrequestcomplete",metadata:e}),this.src=Ir(this.src,i),this.trigger({type:"playlistparsestart",metadata:e});const n=this.parseManifest_({manifestString:i.responseText,url:this.src});e.parsedPlaylist=lc(n.playlists,e.playlistInfo.type,!1),this.trigger({type:"playlistparsecomplete",metadata:e}),this.setupInitialPlaylist(n)})}srcUri(){return typeof this.src=="string"?this.src:this.src.uri}setupInitialPlaylist(e){if(this.state="HAVE_MAIN_MANIFEST",e.playlists){this.main=e,tf(this.main,this.srcUri()),e.playlists.forEach(i=>{i.segments=rf(i),i.segments.forEach(n=>{nf(n,i.resolvedUri)})}),this.trigger("loadedplaylist"),this.request||this.media(this.main.playlists[0]);return}const t=this.srcUri()||k.location.href;this.main=ib(e,t),this.haveMetadata({playlistObject:e,url:t,id:this.main.playlists[0].id}),this.trigger("loadedmetadata")}updateOrDeleteClone(e,t){const i=this.main,n=e.ID;let r=i.playlists.length;for(;r--;){const a=i.playlists[r];if(a.attributes["PATHWAY-ID"]===n){const l=a.resolvedUri,h=a.id;if(t){const f=this.createCloneURI_(a.resolvedUri,e),m=us(n,f),T=this.createCloneAttributes_(n,a.attributes),E=this.createClonePlaylist_(a,m,e,T);i.playlists[r]=E,i.playlists[m]=E,i.playlists[f]=E}else i.playlists.splice(r,1);delete i.playlists[h],delete i.playlists[l]}}this.updateOrDeleteCloneMedia(e,t)}updateOrDeleteCloneMedia(e,t){const i=this.main,n=e.ID;["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(r=>{if(!(!i.mediaGroups[r]||!i.mediaGroups[r][n])){for(const a in i.mediaGroups[r])if(a===n){for(const l in i.mediaGroups[r][a])i.mediaGroups[r][a][l].playlists.forEach((f,m)=>{const T=i.playlists[f.id],E=T.id,C=T.resolvedUri;delete i.playlists[E],delete i.playlists[C]});delete i.mediaGroups[r][a]}}}),t&&this.createClonedMediaGroups_(e)}addClonePathway(e,t={}){const i=this.main,n=i.playlists.length,r=this.createCloneURI_(t.resolvedUri,e),a=us(e.ID,r),l=this.createCloneAttributes_(e.ID,t.attributes),h=this.createClonePlaylist_(t,a,e,l);i.playlists[n]=h,i.playlists[a]=h,i.playlists[r]=h,this.createClonedMediaGroups_(e)}createClonedMediaGroups_(e){const t=e.ID,i=e["BASE-ID"],n=this.main;["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(r=>{if(!(!n.mediaGroups[r]||n.mediaGroups[r][t]))for(const a in n.mediaGroups[r]){if(a===i)n.mediaGroups[r][t]={};else continue;for(const l in n.mediaGroups[r][a]){const h=n.mediaGroups[r][a][l];n.mediaGroups[r][t][l]=je({},h);const f=n.mediaGroups[r][t][l],m=this.createCloneURI_(h.resolvedUri,e);f.resolvedUri=m,f.uri=m,f.playlists=[],h.playlists.forEach((T,E)=>{const C=n.playlists[T.id],P=Zh(r,t,l),v=us(t,P);if(C&&!n.playlists[v]){const R=this.createClonePlaylist_(C,v,e),L=R.resolvedUri;n.playlists[v]=R,n.playlists[L]=R}f.playlists[E]=this.createClonePlaylist_(T,v,e)})}}})}createClonePlaylist_(e,t,i,n){const r=this.createCloneURI_(e.resolvedUri,i),a={resolvedUri:r,uri:r,id:t};return e.segments&&(a.segments=[]),n&&(a.attributes=n),ge(e,a)}createCloneURI_(e,t){const i=new URL(e);i.hostname=t["URI-REPLACEMENT"].HOST;const n=t["URI-REPLACEMENT"].PARAMS;for(const r of Object.keys(n))i.searchParams.set(r,n[r]);return i.href}createCloneAttributes_(e,t){const i={"PATHWAY-ID":e};return["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(n=>{t[n]&&(i[n]=e)}),i}getKeyIdSet(e){if(e.contentProtection){const t=new Set;for(const i in e.contentProtection){const n=e.contentProtection[i].attributes.keyId;n&&t.add(n.toLowerCase())}return t}}}const po=function(s,e,t,i){const n=s.responseType==="arraybuffer"?s.response:s.responseText;!e&&n&&(s.responseTime=Date.now(),s.roundTripTime=s.responseTime-s.requestTime,s.bytesReceived=n.byteLength||n.length,s.bandwidth||(s.bandwidth=Math.floor(s.bytesReceived/s.roundTripTime*8*1e3))),t.headers&&(s.responseHeaders=t.headers),e&&e.code==="ETIMEDOUT"&&(s.timedout=!0),!e&&!s.aborted&&t.statusCode!==200&&t.statusCode!==206&&t.statusCode!==0&&(e=new Error("XHR Failed with a response of: "+(s&&(n||s.responseText)))),i(e,s)},ob=(s,e)=>{if(!s||!s.size)return;let t=e;return s.forEach(i=>{t=i(t)}),t},lb=(s,e,t,i)=>{!s||!s.size||s.forEach(n=>{n(e,t,i)})},of=function(){const s=function e(t,i){t=ge({timeout:45e3},t);const n=e.beforeRequest||B.Vhs.xhr.beforeRequest,r=e._requestCallbackSet||B.Vhs.xhr._requestCallbackSet||new Set,a=e._responseCallbackSet||B.Vhs.xhr._responseCallbackSet;n&&typeof n=="function"&&(B.log.warn("beforeRequest is deprecated, use onRequest instead."),r.add(n));const l=B.Vhs.xhr.original===!0?B.xhr:B.Vhs.xhr,h=ob(r,t);r.delete(n);const f=l(h||t,function(T,E){return lb(a,f,T,E),po(f,T,E,i)}),m=f.abort;return f.abort=function(){return f.aborted=!0,m.apply(f,arguments)},f.uri=t.uri,f.requestType=t.requestType,f.requestTime=Date.now(),f};return s.original=!0,s},ub=function(s){let e;const t=s.offset;return typeof s.offset=="bigint"||typeof s.length=="bigint"?e=k.BigInt(s.offset)+k.BigInt(s.length)-k.BigInt(1):e=s.offset+s.length-1,"bytes="+t+"-"+e},mo=function(s){const e={};return s.byterange&&(e.Range=ub(s.byterange)),e},cb=function(s,e){return s.start(e)+"-"+s.end(e)},db=function(s,e){const t=s.toString(16);return"00".substring(0,2-t.length)+t+(e%2?" ":"")},hb=function(s){return s>=32&&s<126?String.fromCharCode(s):"."},lf=function(s){const e={};return Object.keys(s).forEach(t=>{const i=s[t];ud(i)?e[t]={bytes:i.buffer,byteOffset:i.byteOffset,byteLength:i.byteLength}:e[t]=i}),e},Ar=function(s){const e=s.byterange||{length:1/0,offset:0};return[e.length,e.offset,s.resolvedUri].join(",")},uf=function(s){return s.resolvedUri},cf=s=>{const e=Array.prototype.slice.call(s),t=16;let i="",n,r;for(let a=0;a<e.length/t;a++)n=e.slice(a*t,a*t+t).map(db).join(""),r=e.slice(a*t,a*t+t).map(hb).join(""),i+=n+" "+r+`
|
|
190
|
+
`;return i},fb=({bytes:s})=>cf(s),pb=s=>{let e="",t;for(t=0;t<s.length;t++)e+=cb(s,t)+" ";return e};var mb=Object.freeze({__proto__:null,createTransferableMessage:lf,initSegmentId:Ar,segmentKeyId:uf,hexDump:cf,tagDump:fb,textRanges:pb});const df=.25,gb=(s,e)=>{if(!e.dateTimeObject)return null;const t=e.videoTimingInfo.transmuxerPrependedSeconds,n=e.videoTimingInfo.transmuxedPresentationStart+t,r=s-n;return new Date(e.dateTimeObject.getTime()+r*1e3)},yb=s=>s.transmuxedPresentationEnd-s.transmuxedPresentationStart-s.transmuxerPrependedSeconds,_b=(s,e)=>{let t;try{t=new Date(s)}catch{return null}if(!e||!e.segments||e.segments.length===0)return null;let i=e.segments[0];if(t<new Date(i.dateTimeObject))return null;for(let h=0;h<e.segments.length-1;h++){i=e.segments[h];const f=new Date(e.segments[h+1].dateTimeObject);if(t<f)break}const n=e.segments[e.segments.length-1],r=n.dateTimeObject,a=n.videoTimingInfo?yb(n.videoTimingInfo):n.duration+n.duration*df,l=new Date(r.getTime()+a*1e3);return t>l?null:(t>new Date(r)&&(i=n),{segment:i,estimatedStart:i.videoTimingInfo?i.videoTimingInfo.transmuxedPresentationStart:ht.duration(e,e.mediaSequence+e.segments.indexOf(i)),type:i.videoTimingInfo?"accurate":"estimate"})},Tb=(s,e)=>{if(!e||!e.segments||e.segments.length===0)return null;let t=0,i;for(let r=0;r<e.segments.length&&(i=e.segments[r],t=i.videoTimingInfo?i.videoTimingInfo.transmuxedPresentationEnd:t+i.duration,!(s<=t));r++);const n=e.segments[e.segments.length-1];if(n.videoTimingInfo&&n.videoTimingInfo.transmuxedPresentationEnd<s)return null;if(s>t){if(s>t+n.duration*df)return null;i=n}return{segment:i,estimatedStart:i.videoTimingInfo?i.videoTimingInfo.transmuxedPresentationStart:t-i.duration,type:i.videoTimingInfo?"accurate":"estimate"}},vb=(s,e)=>{let t,i;try{t=new Date(s),i=new Date(e)}catch{}const n=t.getTime();return(i.getTime()-n)/1e3},bb=s=>{if(!s.segments||s.segments.length===0)return!1;for(let e=0;e<s.segments.length;e++)if(!s.segments[e].dateTimeObject)return!1;return!0},xb=({playlist:s,time:e=void 0,callback:t})=>{if(!t)throw new Error("getProgramTime: callback must be provided");if(!s||e===void 0)return t({message:"getProgramTime: playlist and time must be provided"});const i=Tb(e,s);if(!i)return t({message:"valid programTime was not found"});if(i.type==="estimate")return t({message:"Accurate programTime could not be determined. Please seek to e.seekTime and try again",seekTime:i.estimatedStart});const n={mediaSeconds:e},r=gb(e,i.segment);return r&&(n.programDateTime=r.toISOString()),t(null,n)},hf=({programTime:s,playlist:e,retryCount:t=2,seekTo:i,pauseAfterSeek:n=!0,tech:r,callback:a})=>{if(!a)throw new Error("seekToProgramTime: callback must be provided");if(typeof s>"u"||!e||!i)return a({message:"seekToProgramTime: programTime, seekTo and playlist must be provided"});if(!e.endList&&!r.hasStarted_)return a({message:"player must be playing a live stream to start buffering"});if(!bb(e))return a({message:"programDateTime tags must be provided in the manifest "+e.resolvedUri});const l=_b(s,e);if(!l)return a({message:`${s} was not found in the stream`});const h=l.segment,f=vb(h.dateTimeObject,s);if(l.type==="estimate"){if(t===0)return a({message:`${s} is not buffered yet. Try again`});i(l.estimatedStart+f),r.one("seeked",()=>{hf({programTime:s,playlist:e,retryCount:t-1,seekTo:i,pauseAfterSeek:n,tech:r,callback:a})});return}const m=h.start+f,T=()=>a(null,r.currentTime());r.one("seeked",T),n&&r.pause(),i(m)},Wa=(s,e)=>{if(s.readyState===4)return e()},Sb=(s,e,t,i)=>{let n=[],r,a=!1;const l=function(T,E,C,P){return E.abort(),a=!0,t(T,E,C,P)},h=function(T,E){if(a)return;if(T)return T.metadata=Vi({requestType:i,request:E,error:T}),l(T,E,"",n);const C=E.responseText.substring(n&&n.byteLength||0,E.responseText.length);if(n=t_(n,cd(C,!0)),r=r||on(n),n.length<10||r&&n.length<r+2)return Wa(E,()=>l(T,E,"",n));const P=Oo(n);return P==="ts"&&n.length<188?Wa(E,()=>l(T,E,"",n)):!P&&n.length<376?Wa(E,()=>l(T,E,"",n)):l(null,E,P,n)},m=e({uri:s,beforeSend(T){T.overrideMimeType("text/plain; charset=x-user-defined"),T.addEventListener("progress",function({total:E,loaded:C}){return po(T,null,{statusCode:T.status},h)})}},function(T,E){return po(m,T,E,h)});return m},{EventTarget:Eb}=B,uc=function(s,e){if(!af(s,e)||s.sidx&&e.sidx&&(s.sidx.offset!==e.sidx.offset||s.sidx.length!==e.sidx.length))return!1;if(!s.sidx&&e.sidx||s.sidx&&!e.sidx||s.segments&&!e.segments||!s.segments&&e.segments)return!1;if(!s.segments&&!e.segments)return!0;for(let t=0;t<s.segments.length;t++){const i=s.segments[t],n=e.segments[t];if(i.uri!==n.uri)return!1;if(!i.byterange&&!n.byterange)continue;const r=i.byterange,a=n.byterange;if(r&&!a||!r&&a||r.offset!==a.offset||r.length!==a.length)return!1}return!0},Cb=(s,e,t,i)=>{const n=i.attributes.NAME||t;return`placeholder-uri-${s}-${e}-${n}`},wb=({mainXml:s,srcUrl:e,clientOffset:t,sidxMapping:i,previousManifest:n})=>{const r=K_(s,{manifestUri:e,clientOffset:t,sidxMapping:i,previousManifest:n});return tf(r,e,Cb),r},Ib=(s,e)=>{Ps(s,(t,i,n,r)=>{(!e.mediaGroups[i][n]||!(r in e.mediaGroups[i][n]))&&delete s.mediaGroups[i][n][r]})},Ab=(s,e,t)=>{let i=!0,n=ge(s,{duration:e.duration,minimumUpdatePeriod:e.minimumUpdatePeriod,timelineStarts:e.timelineStarts});for(let r=0;r<e.playlists.length;r++){const a=e.playlists[r];if(a.sidx){const h=Fr(a.sidx);t&&t[h]&&t[h].sidx&&Po(a,t[h].sidx,a.sidx.resolvedUri)}const l=ho(n,a,uc);l&&(n=l,i=!1)}return Ps(e,(r,a,l,h)=>{if(r.playlists&&r.playlists.length){const f=r.playlists[0].id,m=ho(n,r.playlists[0],uc);m&&(n=m,h in n.mediaGroups[a][l]||(n.mediaGroups[a][l][h]=r),n.mediaGroups[a][l][h].playlists[0]=n.playlists[f],i=!1)}}),Ib(n,e),e.minimumUpdatePeriod!==s.minimumUpdatePeriod&&(i=!1),i?null:n},kb=(s,e)=>(!s.map&&!e.map||!!(s.map&&e.map&&s.map.byterange.offset===e.map.byterange.offset&&s.map.byterange.length===e.map.byterange.length))&&s.uri===e.uri&&s.byterange.offset===e.byterange.offset&&s.byterange.length===e.byterange.length,cc=(s,e)=>{const t={};for(const i in s){const r=s[i].sidx;if(r){const a=Fr(r);if(!e[a])break;const l=e[a].sidxInfo;kb(l,r)&&(t[a]=e[a])}}return t},Pb=(s,e)=>{let i=cc(s.playlists,e);return Ps(s,(n,r,a,l)=>{if(n.playlists&&n.playlists.length){const h=n.playlists;i=ge(i,cc(h,e))}}),i};class go extends Eb{constructor(e,t,i={},n){super(),this.isPaused_=!0,this.mainPlaylistLoader_=n||this,n||(this.isMain_=!0);const{withCredentials:r=!1}=i;if(this.vhs_=t,this.withCredentials=r,this.addMetadataToTextTrack=i.addMetadataToTextTrack,!e)throw new Error("A non-empty playlist URL or object is required");this.on("minimumUpdatePeriod",()=>{this.refreshXml_()}),this.on("mediaupdatetimeout",()=>{this.refreshMedia_(this.media().id)}),this.state="HAVE_NOTHING",this.loadedPlaylists_={},this.logger_=Pt("DashPlaylistLoader"),this.isMain_?(this.mainPlaylistLoader_.srcUrl=e,this.mainPlaylistLoader_.sidxMapping_={}):this.childPlaylist_=e}get isPaused(){return this.isPaused_}requestErrored_(e,t,i){if(!this.request)return!0;if(this.request=null,e)return this.error=typeof e=="object"&&!(e instanceof Error)?e:{status:t.status,message:"DASH request error at URL: "+t.uri,response:t.response,code:2,metadata:e.metadata},i&&(this.state=i),this.trigger("error"),!0}addSidxSegments_(e,t,i){const n=e.sidx&&Fr(e.sidx);if(!e.sidx||!n||this.mainPlaylistLoader_.sidxMapping_[n]){k.clearTimeout(this.mediaRequest_),this.mediaRequest_=k.setTimeout(()=>i(!1),0);return}const r=Ir(e.sidx.resolvedUri),a=(h,f)=>{if(this.requestErrored_(h,f,t))return;const m=this.mainPlaylistLoader_.sidxMapping_,{requestType:T}=f;let E;try{E=eT(ie(f.response).subarray(8))}catch(C){C.metadata=Vi({requestType:T,request:f,parseFailure:!0}),this.requestErrored_(C,f,t);return}return m[n]={sidxInfo:e.sidx,sidx:E},Po(e,E,e.sidx.resolvedUri),i(!0)},l="dash-sidx";this.request=Sb(r,this.vhs_.xhr,(h,f,m,T)=>{if(h)return a(h,f);if(!m||m!=="mp4"){const P=m||"unknown";return a({status:f.status,message:`Unsupported ${P} container type for sidx segment at URL: ${r}`,response:"",playlist:e,internal:!0,playlistExclusionDuration:1/0,code:2},f)}const{offset:E,length:C}=e.sidx.byterange;if(T.length>=C+E)return a(h,{response:T.subarray(E,E+C),status:f.status,uri:f.uri});this.request=this.vhs_.xhr({uri:r,responseType:"arraybuffer",requestType:"dash-sidx",headers:mo({byterange:e.sidx.byterange})},a)},l)}dispose(){this.isPaused_=!0,this.trigger("dispose"),this.stopRequest(),this.loadedPlaylists_={},k.clearTimeout(this.minimumUpdatePeriodTimeout_),k.clearTimeout(this.mediaRequest_),k.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null,this.mediaRequest_=null,this.minimumUpdatePeriodTimeout_=null,this.mainPlaylistLoader_.createMupOnMedia_&&(this.off("loadedmetadata",this.mainPlaylistLoader_.createMupOnMedia_),this.mainPlaylistLoader_.createMupOnMedia_=null),this.off()}hasPendingRequest(){return this.request||this.mediaRequest_}stopRequest(){if(this.request){const e=this.request;this.request=null,e.onreadystatechange=null,e.abort()}}media(e){if(!e)return this.media_;if(this.state==="HAVE_NOTHING")throw new Error("Cannot switch media playlist from "+this.state);const t=this.state;if(typeof e=="string"){if(!this.mainPlaylistLoader_.main.playlists[e])throw new Error("Unknown playlist URI: "+e);e=this.mainPlaylistLoader_.main.playlists[e]}const i=!this.media_||e.id!==this.media_.id;if(i&&this.loadedPlaylists_[e.id]&&this.loadedPlaylists_[e.id].endList){this.state="HAVE_METADATA",this.media_=e,i&&(this.trigger("mediachanging"),this.trigger("mediachange"));return}i&&(this.media_&&this.trigger("mediachanging"),this.addSidxSegments_(e,t,n=>{this.haveMetadata({startingState:t,playlist:e})}))}haveMetadata({startingState:e,playlist:t}){this.state="HAVE_METADATA",this.loadedPlaylists_[t.id]=t,k.clearTimeout(this.mediaRequest_),this.mediaRequest_=null,this.refreshMedia_(t.id),e==="HAVE_MAIN_MANIFEST"?this.trigger("loadedmetadata"):this.trigger("mediachange")}pause(){this.isPaused_=!0,this.mainPlaylistLoader_.createMupOnMedia_&&(this.off("loadedmetadata",this.mainPlaylistLoader_.createMupOnMedia_),this.mainPlaylistLoader_.createMupOnMedia_=null),this.stopRequest(),k.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null,this.isMain_&&(k.clearTimeout(this.mainPlaylistLoader_.minimumUpdatePeriodTimeout_),this.mainPlaylistLoader_.minimumUpdatePeriodTimeout_=null),this.state==="HAVE_NOTHING"&&(this.started=!1)}load(e){this.isPaused_=!1,k.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null;const t=this.media();if(e){const i=t?t.targetDuration/2*1e3:5e3;this.mediaUpdateTimeout=k.setTimeout(()=>this.load(),i);return}if(!this.started){this.start();return}t&&!t.endList?(this.isMain_&&!this.minimumUpdatePeriodTimeout_&&(this.trigger("minimumUpdatePeriod"),this.updateMinimumUpdatePeriodTimeout_()),this.trigger("mediaupdatetimeout")):this.trigger("loadedplaylist")}start(){if(this.started=!0,!this.isMain_){k.clearTimeout(this.mediaRequest_),this.mediaRequest_=k.setTimeout(()=>this.haveMain_(),0);return}this.requestMain_((e,t)=>{this.haveMain_(),!this.hasPendingRequest()&&!this.media_&&this.media(this.mainPlaylistLoader_.main.playlists[0])})}requestMain_(e){const t={manifestInfo:{uri:this.mainPlaylistLoader_.srcUrl}};this.trigger({type:"manifestrequeststart",metadata:t}),this.request=this.vhs_.xhr({uri:this.mainPlaylistLoader_.srcUrl,withCredentials:this.withCredentials,requestType:"dash-manifest"},(i,n)=>{if(i){const{requestType:a}=n;i.metadata=Vi({requestType:a,request:n,error:i})}if(this.requestErrored_(i,n)){this.state==="HAVE_NOTHING"&&(this.started=!1);return}this.trigger({type:"manifestrequestcomplete",metadata:t});const r=n.responseText!==this.mainPlaylistLoader_.mainXml_;if(this.mainPlaylistLoader_.mainXml_=n.responseText,n.responseHeaders&&n.responseHeaders.date?this.mainLoaded_=Date.parse(n.responseHeaders.date):this.mainLoaded_=Date.now(),this.mainPlaylistLoader_.srcUrl=Ir(this.mainPlaylistLoader_.srcUrl,n),r){this.handleMain_(),this.syncClientServerClock_(()=>e(n,r));return}return e(n,r)})}syncClientServerClock_(e){const t=X_(this.mainPlaylistLoader_.mainXml_);if(t===null)return this.mainPlaylistLoader_.clientOffset_=this.mainLoaded_-Date.now(),e();if(t.method==="DIRECT")return this.mainPlaylistLoader_.clientOffset_=t.value-Date.now(),e();this.request=this.vhs_.xhr({uri:dt(this.mainPlaylistLoader_.srcUrl,t.value),method:t.method,withCredentials:this.withCredentials,requestType:"dash-clock-sync"},(i,n)=>{if(!this.request)return;if(i){const{requestType:a}=n;return this.error.metadata=Vi({requestType:a,request:n,error:i}),this.mainPlaylistLoader_.clientOffset_=this.mainLoaded_-Date.now(),e()}let r;t.method==="HEAD"?!n.responseHeaders||!n.responseHeaders.date?r=this.mainLoaded_:r=Date.parse(n.responseHeaders.date):r=Date.parse(n.responseText),this.mainPlaylistLoader_.clientOffset_=r-Date.now(),e()})}haveMain_(){this.state="HAVE_MAIN_MANIFEST",this.isMain_?this.trigger("loadedplaylist"):this.media_||this.media(this.childPlaylist_)}handleMain_(){k.clearTimeout(this.mediaRequest_),this.mediaRequest_=null;const e=this.mainPlaylistLoader_.main,t={manifestInfo:{uri:this.mainPlaylistLoader_.srcUrl}};this.trigger({type:"manifestparsestart",metadata:t});let i;try{i=wb({mainXml:this.mainPlaylistLoader_.mainXml_,srcUrl:this.mainPlaylistLoader_.srcUrl,clientOffset:this.mainPlaylistLoader_.clientOffset_,sidxMapping:this.mainPlaylistLoader_.sidxMapping_,previousManifest:e})}catch(r){this.error=r,this.error.metadata={errorType:B.Error.StreamingDashManifestParserError,error:r},this.trigger("error")}e&&(i=Ab(e,i,this.mainPlaylistLoader_.sidxMapping_)),this.mainPlaylistLoader_.main=i||e;const n=this.mainPlaylistLoader_.main.locations&&this.mainPlaylistLoader_.main.locations[0];if(n&&n!==this.mainPlaylistLoader_.srcUrl&&(this.mainPlaylistLoader_.srcUrl=n),(!e||i&&i.minimumUpdatePeriod!==e.minimumUpdatePeriod)&&this.updateMinimumUpdatePeriodTimeout_(),this.addEventStreamToMetadataTrack_(i),i){const{duration:r,endList:a}=i,l=[];i.playlists.forEach(f=>{l.push({id:f.id,bandwidth:f.attributes.BANDWIDTH,resolution:f.attributes.RESOLUTION,codecs:f.attributes.CODECS})});const h={duration:r,isLive:!a,renditions:l};t.parsedManifest=h,this.trigger({type:"manifestparsecomplete",metadata:t})}return!!i}updateMinimumUpdatePeriodTimeout_(){const e=this.mainPlaylistLoader_;e.createMupOnMedia_&&(e.off("loadedmetadata",e.createMupOnMedia_),e.createMupOnMedia_=null),e.minimumUpdatePeriodTimeout_&&(k.clearTimeout(e.minimumUpdatePeriodTimeout_),e.minimumUpdatePeriodTimeout_=null);let t=e.main&&e.main.minimumUpdatePeriod;if(t===0&&(e.media()?t=e.media().targetDuration*1e3:(e.createMupOnMedia_=e.updateMinimumUpdatePeriodTimeout_,e.one("loadedmetadata",e.createMupOnMedia_))),typeof t!="number"||t<=0){t<0&&this.logger_(`found invalid minimumUpdatePeriod of ${t}, not setting a timeout`);return}this.createMUPTimeout_(t)}createMUPTimeout_(e){const t=this.mainPlaylistLoader_;t.minimumUpdatePeriodTimeout_=k.setTimeout(()=>{t.minimumUpdatePeriodTimeout_=null,t.trigger("minimumUpdatePeriod"),t.createMUPTimeout_(e)},e)}refreshXml_(){this.requestMain_((e,t)=>{t&&(this.media_&&(this.media_=this.mainPlaylistLoader_.main.playlists[this.media_.id]),this.mainPlaylistLoader_.sidxMapping_=Pb(this.mainPlaylistLoader_.main,this.mainPlaylistLoader_.sidxMapping_),this.addSidxSegments_(this.media(),this.state,i=>{this.refreshMedia_(this.media().id)}))})}refreshMedia_(e){if(!e)throw new Error("refreshMedia_ must take a media id");this.media_&&this.isMain_&&this.handleMain_();const t=this.mainPlaylistLoader_.main.playlists,i=!this.media_||this.media_!==t[e];if(i?this.media_=t[e]:this.trigger("playlistunchanged"),!this.mediaUpdateTimeout){const n=()=>{this.media().endList||(this.mediaUpdateTimeout=k.setTimeout(()=>{this.trigger("mediaupdatetimeout"),n()},fo(this.media(),!!i)))};n()}this.trigger("loadedplaylist")}addEventStreamToMetadataTrack_(e){if(e&&this.mainPlaylistLoader_.main.eventStream){const t=this.mainPlaylistLoader_.main.eventStream.map(i=>({cueTime:i.start,frames:[{data:i.messageData}]}));this.addMetadataToTextTrack("EventStream",t,this.mainPlaylistLoader_.main.duration)}}getKeyIdSet(e){if(e.contentProtection){const t=new Set;for(const i in e.contentProtection){const n=e.contentProtection[i].attributes["cenc:default_KID"];n&&t.add(n.replace(/-/g,"").toLowerCase())}return t}}}var We={GOAL_BUFFER_LENGTH:30,MAX_GOAL_BUFFER_LENGTH:60,BACK_BUFFER_LENGTH:30,GOAL_BUFFER_LENGTH_RATE:1,INITIAL_BANDWIDTH:4194304,BANDWIDTH_VARIANCE:1.2,BUFFER_LOW_WATER_LINE:0,MAX_BUFFER_LOW_WATER_LINE:30,EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE:16,BUFFER_LOW_WATER_LINE_RATE:1,BUFFER_HIGH_WATER_LINE:30};const Db=s=>{const e=new Uint8Array(new ArrayBuffer(s.length));for(let t=0;t<s.length;t++)e[t]=s.charCodeAt(t);return e.buffer},ff=function(s){return s.on=s.addEventListener,s.off=s.removeEventListener,s},Lb=function(s){try{return URL.createObjectURL(new Blob([s],{type:"application/javascript"}))}catch{const t=new BlobBuilder;return t.append(s),URL.createObjectURL(t.getBlob())}},pf=function(s){return function(){const e=Lb(s),t=ff(new Worker(e));t.objURL=e;const i=t.terminate;return t.on=t.addEventListener,t.off=t.removeEventListener,t.terminate=function(){return URL.revokeObjectURL(e),i.call(this)},t}},mf=function(s){return`var browserWorkerPolyFill = ${ff.toString()};
|
|
191
191
|
browserWorkerPolyFill(self);
|
|
192
|
-
`+i},fp=function(i){return i.toString().replace(/^function.+?{/,"").slice(0,-1)},BT=gp(fp(function(){var i=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof ar<"u"?ar:typeof self<"u"?self:{},e=function(){this.init=function(){var o={};this.on=function(u,d){o[u]||(o[u]=[]),o[u]=o[u].concat(d)},this.off=function(u,d){var h;return o[u]?(h=o[u].indexOf(d),o[u]=o[u].slice(),o[u].splice(h,1),h>-1):!1},this.trigger=function(u){var d,h,g,y;if(d=o[u],!!d)if(arguments.length===2)for(g=d.length,h=0;h<g;++h)d[h].call(this,arguments[1]);else{for(y=[],h=arguments.length,h=1;h<arguments.length;++h)y.push(arguments[h]);for(g=d.length,h=0;h<g;++h)d[h].apply(this,y)}},this.dispose=function(){o={}}}};e.prototype.pipe=function(o){return this.on("data",function(u){o.push(u)}),this.on("done",function(u){o.flush(u)}),this.on("partialdone",function(u){o.partialFlush(u)}),this.on("endedtimeline",function(u){o.endTimeline(u)}),this.on("reset",function(u){o.reset(u)}),o},e.prototype.push=function(o){this.trigger("data",o)},e.prototype.flush=function(o){this.trigger("done",o)},e.prototype.partialFlush=function(o){this.trigger("partialdone",o)},e.prototype.endTimeline=function(o){this.trigger("endedtimeline",o)},e.prototype.reset=function(o){this.trigger("reset",o)};var t=e,n=Math.pow(2,32),s=function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),d;return u.getBigUint64?(d=u.getBigUint64(0),d<Number.MAX_SAFE_INTEGER?Number(d):d):u.getUint32(0)*n+u.getUint32(4)},r={getUint64:s,MAX_UINT32:n},a=r.MAX_UINT32,l,c,f,m,b,C,w,A,v,M,D,R,N,F,P,$,Y,X,re,ce,be,he,Z,de,ee,Xe,Ye,$e,He,me,ge,mt,Et,we,le,Re;(function(){var o;if(Z={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],mvex:[],mvhd:[],pasp:[],sdtp:[],smhd:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],styp:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[]},!(typeof Uint8Array>"u")){for(o in Z)Z.hasOwnProperty(o)&&(Z[o]=[o.charCodeAt(0),o.charCodeAt(1),o.charCodeAt(2),o.charCodeAt(3)]);de=new Uint8Array([105,115,111,109]),Xe=new Uint8Array([97,118,99,49]),ee=new Uint8Array([0,0,0,1]),Ye=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]),$e=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]),He={video:Ye,audio:$e},mt=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),ge=new Uint8Array([0,0,0,0,0,0,0,0]),Et=new Uint8Array([0,0,0,0,0,0,0,0]),we=Et,le=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),Re=Et,me=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])}})(),l=function(o){var u=[],d=0,h,g,y;for(h=1;h<arguments.length;h++)u.push(arguments[h]);for(h=u.length;h--;)d+=u[h].byteLength;for(g=new Uint8Array(d+8),y=new DataView(g.buffer,g.byteOffset,g.byteLength),y.setUint32(0,g.byteLength),g.set(o,4),h=0,d=8;h<u.length;h++)g.set(u[h],d),d+=u[h].byteLength;return g},c=function(){return l(Z.dinf,l(Z.dref,mt))},f=function(o){return l(Z.esds,new Uint8Array([0,0,0,0,3,25,0,0,0,4,17,64,21,0,6,0,0,0,218,192,0,0,218,192,5,2,o.audioobjecttype<<3|o.samplingfrequencyindex>>>1,o.samplingfrequencyindex<<7|o.channelcount<<3,6,1,2]))},m=function(){return l(Z.ftyp,de,ee,de,Xe)},$=function(o){return l(Z.hdlr,He[o])},b=function(o){return l(Z.mdat,o)},P=function(o){var u=new Uint8Array([0,0,0,0,0,0,0,2,0,0,0,3,0,1,95,144,o.duration>>>24&255,o.duration>>>16&255,o.duration>>>8&255,o.duration&255,85,196,0,0]);return o.samplerate&&(u[12]=o.samplerate>>>24&255,u[13]=o.samplerate>>>16&255,u[14]=o.samplerate>>>8&255,u[15]=o.samplerate&255),l(Z.mdhd,u)},F=function(o){return l(Z.mdia,P(o),$(o.type),w(o))},C=function(o){return l(Z.mfhd,new Uint8Array([0,0,0,0,(o&4278190080)>>24,(o&16711680)>>16,(o&65280)>>8,o&255]))},w=function(o){return l(Z.minf,o.type==="video"?l(Z.vmhd,me):l(Z.smhd,ge),c(),X(o))},A=function(o,u){for(var d=[],h=u.length;h--;)d[h]=ce(u[h]);return l.apply(null,[Z.moof,C(o)].concat(d))},v=function(o){for(var u=o.length,d=[];u--;)d[u]=R(o[u]);return l.apply(null,[Z.moov,D(4294967295)].concat(d).concat(M(o)))},M=function(o){for(var u=o.length,d=[];u--;)d[u]=be(o[u]);return l.apply(null,[Z.mvex].concat(d))},D=function(o){var u=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,2,0,1,95,144,(o&4278190080)>>24,(o&16711680)>>16,(o&65280)>>8,o&255,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 l(Z.mvhd,u)},Y=function(o){var u=o.samples||[],d=new Uint8Array(4+u.length),h,g;for(g=0;g<u.length;g++)h=u[g].flags,d[g+4]=h.dependsOn<<4|h.isDependedOn<<2|h.hasRedundancy;return l(Z.sdtp,d)},X=function(o){return l(Z.stbl,re(o),l(Z.stts,Re),l(Z.stsc,we),l(Z.stsz,le),l(Z.stco,Et))},function(){var o,u;re=function(d){return l(Z.stsd,new Uint8Array([0,0,0,0,0,0,0,1]),d.type==="video"?o(d):u(d))},o=function(d){var h=d.sps||[],g=d.pps||[],y=[],S=[],E,k;for(E=0;E<h.length;E++)y.push((h[E].byteLength&65280)>>>8),y.push(h[E].byteLength&255),y=y.concat(Array.prototype.slice.call(h[E]));for(E=0;E<g.length;E++)S.push((g[E].byteLength&65280)>>>8),S.push(g[E].byteLength&255),S=S.concat(Array.prototype.slice.call(g[E]));if(k=[Z.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,(d.width&65280)>>8,d.width&255,(d.height&65280)>>8,d.height&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,19,118,105,100,101,111,106,115,45,99,111,110,116,114,105,98,45,104,108,115,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),l(Z.avcC,new Uint8Array([1,d.profileIdc,d.profileCompatibility,d.levelIdc,255].concat([h.length],y,[g.length],S))),l(Z.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192]))],d.sarRatio){var I=d.sarRatio[0],O=d.sarRatio[1];k.push(l(Z.pasp,new Uint8Array([(I&4278190080)>>24,(I&16711680)>>16,(I&65280)>>8,I&255,(O&4278190080)>>24,(O&16711680)>>16,(O&65280)>>8,O&255])))}return l.apply(null,k)},u=function(d){return l(Z.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,(d.channelcount&65280)>>8,d.channelcount&255,(d.samplesize&65280)>>8,d.samplesize&255,0,0,0,0,(d.samplerate&65280)>>8,d.samplerate&255,0,0]),f(d))}}(),N=function(o){var u=new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,(o.id&4278190080)>>24,(o.id&16711680)>>16,(o.id&65280)>>8,o.id&255,0,0,0,0,(o.duration&4278190080)>>24,(o.duration&16711680)>>16,(o.duration&65280)>>8,o.duration&255,0,0,0,0,0,0,0,0,0,0,0,0,1,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,(o.width&65280)>>8,o.width&255,0,0,(o.height&65280)>>8,o.height&255,0,0]);return l(Z.tkhd,u)},ce=function(o){var u,d,h,g,y,S,E;return u=l(Z.tfhd,new Uint8Array([0,0,0,58,(o.id&4278190080)>>24,(o.id&16711680)>>16,(o.id&65280)>>8,o.id&255,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0])),S=Math.floor(o.baseMediaDecodeTime/a),E=Math.floor(o.baseMediaDecodeTime%a),d=l(Z.tfdt,new Uint8Array([1,0,0,0,S>>>24&255,S>>>16&255,S>>>8&255,S&255,E>>>24&255,E>>>16&255,E>>>8&255,E&255])),y=92,o.type==="audio"?(h=he(o,y),l(Z.traf,u,d,h)):(g=Y(o),h=he(o,g.length+y),l(Z.traf,u,d,h,g))},R=function(o){return o.duration=o.duration||4294967295,l(Z.trak,N(o),F(o))},be=function(o){var u=new Uint8Array([0,0,0,0,(o.id&4278190080)>>24,(o.id&16711680)>>16,(o.id&65280)>>8,o.id&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return o.type!=="video"&&(u[u.length-1]=0),l(Z.trex,u)},function(){var o,u,d;d=function(h,g){var y=0,S=0,E=0,k=0;return h.length&&(h[0].duration!==void 0&&(y=1),h[0].size!==void 0&&(S=2),h[0].flags!==void 0&&(E=4),h[0].compositionTimeOffset!==void 0&&(k=8)),[0,0,y|S|E|k,1,(h.length&4278190080)>>>24,(h.length&16711680)>>>16,(h.length&65280)>>>8,h.length&255,(g&4278190080)>>>24,(g&16711680)>>>16,(g&65280)>>>8,g&255]},u=function(h,g){var y,S,E,k,I,O;for(k=h.samples||[],g+=20+16*k.length,E=d(k,g),S=new Uint8Array(E.length+k.length*16),S.set(E),y=E.length,O=0;O<k.length;O++)I=k[O],S[y++]=(I.duration&4278190080)>>>24,S[y++]=(I.duration&16711680)>>>16,S[y++]=(I.duration&65280)>>>8,S[y++]=I.duration&255,S[y++]=(I.size&4278190080)>>>24,S[y++]=(I.size&16711680)>>>16,S[y++]=(I.size&65280)>>>8,S[y++]=I.size&255,S[y++]=I.flags.isLeading<<2|I.flags.dependsOn,S[y++]=I.flags.isDependedOn<<6|I.flags.hasRedundancy<<4|I.flags.paddingValue<<1|I.flags.isNonSyncSample,S[y++]=I.flags.degradationPriority&61440,S[y++]=I.flags.degradationPriority&15,S[y++]=(I.compositionTimeOffset&4278190080)>>>24,S[y++]=(I.compositionTimeOffset&16711680)>>>16,S[y++]=(I.compositionTimeOffset&65280)>>>8,S[y++]=I.compositionTimeOffset&255;return l(Z.trun,S)},o=function(h,g){var y,S,E,k,I,O;for(k=h.samples||[],g+=20+8*k.length,E=d(k,g),y=new Uint8Array(E.length+k.length*8),y.set(E),S=E.length,O=0;O<k.length;O++)I=k[O],y[S++]=(I.duration&4278190080)>>>24,y[S++]=(I.duration&16711680)>>>16,y[S++]=(I.duration&65280)>>>8,y[S++]=I.duration&255,y[S++]=(I.size&4278190080)>>>24,y[S++]=(I.size&16711680)>>>16,y[S++]=(I.size&65280)>>>8,y[S++]=I.size&255;return l(Z.trun,y)},he=function(h,g){return h.type==="audio"?o(h,g):u(h,g)}}();var Hi={ftyp:m,mdat:b,moof:A,moov:v,initSegment:function(o){var u=m(),d=v(o),h;return h=new Uint8Array(u.byteLength+d.byteLength),h.set(u),h.set(d,u.byteLength),h}},oi=function(o){var u,d,h=[],g=[];for(g.byteLength=0,g.nalCount=0,g.duration=0,h.byteLength=0,u=0;u<o.length;u++)d=o[u],d.nalUnitType==="access_unit_delimiter_rbsp"?(h.length&&(h.duration=d.dts-h.dts,g.byteLength+=h.byteLength,g.nalCount+=h.length,g.duration+=h.duration,g.push(h)),h=[d],h.byteLength=d.data.byteLength,h.pts=d.pts,h.dts=d.dts):(d.nalUnitType==="slice_layer_without_partitioning_rbsp_idr"&&(h.keyFrame=!0),h.duration=d.dts-h.dts,h.byteLength+=d.data.byteLength,h.push(d));return g.length&&(!h.duration||h.duration<=0)&&(h.duration=g[g.length-1].duration),g.byteLength+=h.byteLength,g.nalCount+=h.length,g.duration+=h.duration,g.push(h),g},li=function(o){var u,d,h=[],g=[];for(h.byteLength=0,h.nalCount=0,h.duration=0,h.pts=o[0].pts,h.dts=o[0].dts,g.byteLength=0,g.nalCount=0,g.duration=0,g.pts=o[0].pts,g.dts=o[0].dts,u=0;u<o.length;u++)d=o[u],d.keyFrame?(h.length&&(g.push(h),g.byteLength+=h.byteLength,g.nalCount+=h.nalCount,g.duration+=h.duration),h=[d],h.nalCount=d.length,h.byteLength=d.byteLength,h.pts=d.pts,h.dts=d.dts,h.duration=d.duration):(h.duration+=d.duration,h.nalCount+=d.length,h.byteLength+=d.byteLength,h.push(d));return g.length&&h.duration<=0&&(h.duration=g[g.length-1].duration),g.byteLength+=h.byteLength,g.nalCount+=h.nalCount,g.duration+=h.duration,g.push(h),g},Ei=function(o){var u;return!o[0][0].keyFrame&&o.length>1&&(u=o.shift(),o.byteLength-=u.byteLength,o.nalCount-=u.nalCount,o[0][0].dts=u.dts,o[0][0].pts=u.pts,o[0][0].duration+=u.duration),o},yt=function(){return{size:0,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0,degradationPriority:0,isNonSyncSample:1}}},ui=function(o,u){var d=yt();return d.dataOffset=u,d.compositionTimeOffset=o.pts-o.dts,d.duration=o.duration,d.size=4*o.length,d.size+=o.byteLength,o.keyFrame&&(d.flags.dependsOn=2,d.flags.isNonSyncSample=0),d},Ft=function(o,u){var d,h,g,y,S,E=u||0,k=[];for(d=0;d<o.length;d++)for(y=o[d],h=0;h<y.length;h++)S=y[h],g=ui(S,E),E+=g.size,k.push(g);return k},wi=function(o){var u,d,h,g,y,S,E=0,k=o.byteLength,I=o.nalCount,O=k+4*I,j=new Uint8Array(O),Q=new DataView(j.buffer);for(u=0;u<o.length;u++)for(g=o[u],d=0;d<g.length;d++)for(y=g[d],h=0;h<y.length;h++)S=y[h],Q.setUint32(E,S.data.byteLength),E+=4,j.set(S.data,E),E+=S.data.byteLength;return j},Dt=function(o,u){var d,h=u||0,g=[];return d=ui(o,h),g.push(d),g},Ot=function(o){var u,d,h=0,g=o.byteLength,y=o.length,S=g+4*y,E=new Uint8Array(S),k=new DataView(E.buffer);for(u=0;u<o.length;u++)d=o[u],k.setUint32(h,d.data.byteLength),h+=4,E.set(d.data,h),h+=d.data.byteLength;return E},ki={groupNalsIntoFrames:oi,groupFramesIntoGops:li,extendFirstKeyFrame:Ei,generateSampleTable:Ft,concatenateNalData:wi,generateSampleTableForFrame:Dt,concatenateNalDataForFrame:Ot},jt=[33,16,5,32,164,27],Pn=[33,65,108,84,1,2,4,8,168,2,4,8,17,191,252],pe=function(o){for(var u=[];o--;)u.push(0);return u},ia=function(o){return Object.keys(o).reduce(function(u,d){return u[d]=new Uint8Array(o[d].reduce(function(h,g){return h.concat(g)},[])),u},{})},Ln,Es=function(){if(!Ln){var o={96e3:[jt,[227,64],pe(154),[56]],88200:[jt,[231],pe(170),[56]],64e3:[jt,[248,192],pe(240),[56]],48e3:[jt,[255,192],pe(268),[55,148,128],pe(54),[112]],44100:[jt,[255,192],pe(268),[55,163,128],pe(84),[112]],32e3:[jt,[255,192],pe(268),[55,234],pe(226),[112]],24e3:[jt,[255,192],pe(268),[55,255,128],pe(268),[111,112],pe(126),[224]],16e3:[jt,[255,192],pe(268),[55,255,128],pe(268),[111,255],pe(269),[223,108],pe(195),[1,192]],12e3:[Pn,pe(268),[3,127,248],pe(268),[6,255,240],pe(268),[13,255,224],pe(268),[27,253,128],pe(259),[56]],11025:[Pn,pe(268),[3,127,248],pe(268),[6,255,240],pe(268),[13,255,224],pe(268),[27,255,192],pe(268),[55,175,128],pe(108),[112]],8e3:[Pn,pe(268),[3,121,16],pe(47),[7]]};Ln=ia(o)}return Ln},di=9e4,ut,Ci,zi,wt,ws,p,_;ut=function(o){return o*di},Ci=function(o,u){return o*u},zi=function(o){return o/di},wt=function(o,u){return o/u},ws=function(o,u){return ut(wt(o,u))},p=function(o,u){return Ci(zi(o),u)},_=function(o,u,d){return zi(d?o:o-u)};var T={ONE_SECOND_IN_TS:di,secondsToVideoTs:ut,secondsToAudioTs:Ci,videoTsToSeconds:zi,audioTsToSeconds:wt,audioTsToVideoTs:ws,videoTsToAudioTs:p,metadataTsToSeconds:_},L=Es,U=T,q=function(o){var u,d,h=0;for(u=0;u<o.length;u++)d=o[u],h+=d.data.byteLength;return h},K=function(o,u,d,h){var g,y=0,S=0,E=0,k=0,I,O,j;if(u.length&&(g=U.audioTsToVideoTs(o.baseMediaDecodeTime,o.samplerate),y=Math.ceil(U.ONE_SECOND_IN_TS/(o.samplerate/1024)),d&&h&&(S=g-Math.max(d,h),E=Math.floor(S/y),k=E*y),!(E<1||k>U.ONE_SECOND_IN_TS/2))){for(I=L()[o.samplerate],I||(I=u[0].data),O=0;O<E;O++)j=u[0],u.splice(0,0,{data:I,dts:j.dts-y,pts:j.pts-y});return o.baseMediaDecodeTime-=Math.floor(U.videoTsToAudioTs(k,o.samplerate)),k}},Se=function(o,u,d){return u.minSegmentDts>=d?o:(u.minSegmentDts=1/0,o.filter(function(h){return h.dts>=d?(u.minSegmentDts=Math.min(u.minSegmentDts,h.dts),u.minSegmentPts=u.minSegmentDts,!0):!1}))},Ve=function(o){var u,d,h=[];for(u=0;u<o.length;u++)d=o[u],h.push({size:d.data.byteLength,duration:1024});return h},ke=function(o){var u,d,h=0,g=new Uint8Array(q(o));for(u=0;u<o.length;u++)d=o[u],g.set(d.data,h),h+=d.data.byteLength;return g},Te={prefixWithSilence:K,trimAdtsFramesByEarliestDts:Se,generateSampleTable:Ve,concatenateFrameData:ke},Ue=T.ONE_SECOND_IN_TS,zp=function(o,u){typeof u.pts=="number"&&(o.timelineStartInfo.pts===void 0&&(o.timelineStartInfo.pts=u.pts),o.minSegmentPts===void 0?o.minSegmentPts=u.pts:o.minSegmentPts=Math.min(o.minSegmentPts,u.pts),o.maxSegmentPts===void 0?o.maxSegmentPts=u.pts:o.maxSegmentPts=Math.max(o.maxSegmentPts,u.pts)),typeof u.dts=="number"&&(o.timelineStartInfo.dts===void 0&&(o.timelineStartInfo.dts=u.dts),o.minSegmentDts===void 0?o.minSegmentDts=u.dts:o.minSegmentDts=Math.min(o.minSegmentDts,u.dts),o.maxSegmentDts===void 0?o.maxSegmentDts=u.dts:o.maxSegmentDts=Math.max(o.maxSegmentDts,u.dts))},Wp=function(o){delete o.minSegmentDts,delete o.maxSegmentDts,delete o.minSegmentPts,delete o.maxSegmentPts},Gp=function(o,u){var d,h,g=o.minSegmentDts;return u||(g-=o.timelineStartInfo.dts),d=o.timelineStartInfo.baseMediaDecodeTime,d+=g,d=Math.max(0,d),o.type==="audio"&&(h=o.samplerate/Ue,d*=h,d=Math.floor(d)),d},Xp={clearDtsInfo:Wp,calculateTrackBaseMediaDecodeTime:Gp,collectDtsInfo:zp},gl=4,Kp=128,Yp=function(o){for(var u=0,d={payloadType:-1,payloadSize:0},h=0,g=0;u<o.byteLength&&o[u]!==Kp;){for(;o[u]===255;)h+=255,u++;for(h+=o[u++];o[u]===255;)g+=255,u++;if(g+=o[u++],!d.payload&&h===gl){var y=String.fromCharCode(o[u+3],o[u+4],o[u+5],o[u+6]);if(y==="GA94"){d.payloadType=h,d.payloadSize=g,d.payload=o.subarray(u,u+g);break}else d.payload=void 0}u+=g,h=0,g=0}return d},Qp=function(o){return o.payload[0]!==181||(o.payload[1]<<8|o.payload[2])!==49||String.fromCharCode(o.payload[3],o.payload[4],o.payload[5],o.payload[6])!=="GA94"||o.payload[7]!==3?null:o.payload.subarray(8,o.payload.length-1)},Jp=function(o,u){var d=[],h,g,y,S;if(!(u[0]&64))return d;for(g=u[0]&31,h=0;h<g;h++)y=h*3,S={type:u[y+2]&3,pts:o},u[y+2]&4&&(S.ccData=u[y+3]<<8|u[y+4],d.push(S));return d},Zp=function(o){for(var u=o.byteLength,d=[],h=1,g,y;h<u-2;)o[h]===0&&o[h+1]===0&&o[h+2]===3?(d.push(h+2),h+=2):h++;if(d.length===0)return o;g=u-d.length,y=new Uint8Array(g);var S=0;for(h=0;h<g;S++,h++)S===d[0]&&(S++,d.shift()),y[h]=o[S];return y},fl={parseSei:Yp,parseUserData:Qp,parseCaptionPackets:Jp,discardEmulationPreventionBytes:Zp,USER_DATA_REGISTERED_ITU_T_T35:gl},na=t,ks=fl,dt=function(o){o=o||{},dt.prototype.init.call(this),this.parse708captions_=typeof o.parse708captions=="boolean"?o.parse708captions:!0,this.captionPackets_=[],this.ccStreams_=[new Pe(0,0),new Pe(0,1),new Pe(1,0),new Pe(1,1)],this.parse708captions_&&(this.cc708Stream_=new Ee({captionServices:o.captionServices})),this.reset(),this.ccStreams_.forEach(function(u){u.on("data",this.trigger.bind(this,"data")),u.on("partialdone",this.trigger.bind(this,"partialdone")),u.on("done",this.trigger.bind(this,"done"))},this),this.parse708captions_&&(this.cc708Stream_.on("data",this.trigger.bind(this,"data")),this.cc708Stream_.on("partialdone",this.trigger.bind(this,"partialdone")),this.cc708Stream_.on("done",this.trigger.bind(this,"done")))};dt.prototype=new na,dt.prototype.push=function(o){var u,d,h;if(o.nalUnitType==="sei_rbsp"&&(u=ks.parseSei(o.escapedRBSP),!!u.payload&&u.payloadType===ks.USER_DATA_REGISTERED_ITU_T_T35&&(d=ks.parseUserData(u),!!d))){if(o.dts<this.latestDts_){this.ignoreNextEqualDts_=!0;return}else if(o.dts===this.latestDts_&&this.ignoreNextEqualDts_){this.numSameDts_--,this.numSameDts_||(this.ignoreNextEqualDts_=!1);return}h=ks.parseCaptionPackets(o.pts,d),this.captionPackets_=this.captionPackets_.concat(h),this.latestDts_!==o.dts&&(this.numSameDts_=0),this.numSameDts_++,this.latestDts_=o.dts}},dt.prototype.flushCCStreams=function(o){this.ccStreams_.forEach(function(u){return o==="flush"?u.flush():u.partialFlush()},this)},dt.prototype.flushStream=function(o){if(!this.captionPackets_.length){this.flushCCStreams(o);return}this.captionPackets_.forEach(function(u,d){u.presortIndex=d}),this.captionPackets_.sort(function(u,d){return u.pts===d.pts?u.presortIndex-d.presortIndex:u.pts-d.pts}),this.captionPackets_.forEach(function(u){u.type<2?this.dispatchCea608Packet(u):this.dispatchCea708Packet(u)},this),this.captionPackets_.length=0,this.flushCCStreams(o)},dt.prototype.flush=function(){return this.flushStream("flush")},dt.prototype.partialFlush=function(){return this.flushStream("partialFlush")},dt.prototype.reset=function(){this.latestDts_=null,this.ignoreNextEqualDts_=!1,this.numSameDts_=0,this.activeCea608Channel_=[null,null],this.ccStreams_.forEach(function(o){o.reset()})},dt.prototype.dispatchCea608Packet=function(o){this.setsTextOrXDSActive(o)?this.activeCea608Channel_[o.type]=null:this.setsChannel1Active(o)?this.activeCea608Channel_[o.type]=0:this.setsChannel2Active(o)&&(this.activeCea608Channel_[o.type]=1),this.activeCea608Channel_[o.type]!==null&&this.ccStreams_[(o.type<<1)+this.activeCea608Channel_[o.type]].push(o)},dt.prototype.setsChannel1Active=function(o){return(o.ccData&30720)===4096},dt.prototype.setsChannel2Active=function(o){return(o.ccData&30720)===6144},dt.prototype.setsTextOrXDSActive=function(o){return(o.ccData&28928)===256||(o.ccData&30974)===4138||(o.ccData&30974)===6186},dt.prototype.dispatchCea708Packet=function(o){this.parse708captions_&&this.cc708Stream_.push(o)};var eg={127:9834,4128:32,4129:160,4133:8230,4138:352,4140:338,4144:9608,4145:8216,4146:8217,4147:8220,4148:8221,4149:8226,4153:8482,4154:353,4156:339,4157:8480,4159:376,4214:8539,4215:8540,4216:8541,4217:8542,4218:9168,4219:9124,4220:9123,4221:9135,4222:9126,4223:9121,4256:12600},tg=function(o){var u=eg[o]||o;return o&4096&&o===u?"":String.fromCharCode(u)},Cs=function(o){return 32<=o&&o<=127||160<=o&&o<=255},ei=function(o){this.windowNum=o,this.reset()};ei.prototype.reset=function(){this.clearText(),this.pendingNewLine=!1,this.winAttr={},this.penAttr={},this.penLoc={},this.penColor={},this.visible=0,this.rowLock=0,this.columnLock=0,this.priority=0,this.relativePositioning=0,this.anchorVertical=0,this.anchorHorizontal=0,this.anchorPoint=0,this.rowCount=1,this.virtualRowCount=this.rowCount+1,this.columnCount=41,this.windowStyle=0,this.penStyle=0},ei.prototype.getText=function(){return this.rows.join(`
|
|
193
|
-
`)},
|
|
192
|
+
`+s},gf=function(s){return s.toString().replace(/^function.+?{/,"").slice(0,-1)},Ob=mf(gf(function(){var s=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof re.global<"u"?re.global:typeof self<"u"?self:{},e=function(){this.init=function(){var o={};this.on=function(u,c){o[u]||(o[u]=[]),o[u]=o[u].concat(c)},this.off=function(u,c){var d;return o[u]?(d=o[u].indexOf(c),o[u]=o[u].slice(),o[u].splice(d,1),d>-1):!1},this.trigger=function(u){var c,d,p,_;if(c=o[u],!!c)if(arguments.length===2)for(p=c.length,d=0;d<p;++d)c[d].call(this,arguments[1]);else{for(_=[],d=arguments.length,d=1;d<arguments.length;++d)_.push(arguments[d]);for(p=c.length,d=0;d<p;++d)c[d].apply(this,_)}},this.dispose=function(){o={}}}};e.prototype.pipe=function(o){return this.on("data",function(u){o.push(u)}),this.on("done",function(u){o.flush(u)}),this.on("partialdone",function(u){o.partialFlush(u)}),this.on("endedtimeline",function(u){o.endTimeline(u)}),this.on("reset",function(u){o.reset(u)}),o},e.prototype.push=function(o){this.trigger("data",o)},e.prototype.flush=function(o){this.trigger("done",o)},e.prototype.partialFlush=function(o){this.trigger("partialdone",o)},e.prototype.endTimeline=function(o){this.trigger("endedtimeline",o)},e.prototype.reset=function(o){this.trigger("reset",o)};var t=e,i=Math.pow(2,32),n=function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),c;return u.getBigUint64?(c=u.getBigUint64(0),c<Number.MAX_SAFE_INTEGER?Number(c):c):u.getUint32(0)*i+u.getUint32(4)},r={getUint64:n,MAX_UINT32:i},a=r.MAX_UINT32,l,h,f,m,T,E,C,P,v,R,L,N,U,F,D,V,X,G,ae,fe,ve,he,Z,de,ee,Xe,Qe,Ve,qe,be,me,pt,xt,Ee,ce,Ue;(function(){var o;if(Z={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],mvex:[],mvhd:[],pasp:[],sdtp:[],smhd:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],styp:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[]},!(typeof Uint8Array>"u")){for(o in Z)Z.hasOwnProperty(o)&&(Z[o]=[o.charCodeAt(0),o.charCodeAt(1),o.charCodeAt(2),o.charCodeAt(3)]);de=new Uint8Array([105,115,111,109]),Xe=new Uint8Array([97,118,99,49]),ee=new Uint8Array([0,0,0,1]),Qe=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]),Ve=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]),qe={video:Qe,audio:Ve},pt=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),me=new Uint8Array([0,0,0,0,0,0,0,0]),xt=new Uint8Array([0,0,0,0,0,0,0,0]),Ee=xt,ce=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),Ue=xt,be=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])}})(),l=function(o){var u=[],c=0,d,p,_;for(d=1;d<arguments.length;d++)u.push(arguments[d]);for(d=u.length;d--;)c+=u[d].byteLength;for(p=new Uint8Array(c+8),_=new DataView(p.buffer,p.byteOffset,p.byteLength),_.setUint32(0,p.byteLength),p.set(o,4),d=0,c=8;d<u.length;d++)p.set(u[d],c),c+=u[d].byteLength;return p},h=function(){return l(Z.dinf,l(Z.dref,pt))},f=function(o){return l(Z.esds,new Uint8Array([0,0,0,0,3,25,0,0,0,4,17,64,21,0,6,0,0,0,218,192,0,0,218,192,5,2,o.audioobjecttype<<3|o.samplingfrequencyindex>>>1,o.samplingfrequencyindex<<7|o.channelcount<<3,6,1,2]))},m=function(){return l(Z.ftyp,de,ee,de,Xe)},V=function(o){return l(Z.hdlr,qe[o])},T=function(o){return l(Z.mdat,o)},D=function(o){var u=new Uint8Array([0,0,0,0,0,0,0,2,0,0,0,3,0,1,95,144,o.duration>>>24&255,o.duration>>>16&255,o.duration>>>8&255,o.duration&255,85,196,0,0]);return o.samplerate&&(u[12]=o.samplerate>>>24&255,u[13]=o.samplerate>>>16&255,u[14]=o.samplerate>>>8&255,u[15]=o.samplerate&255),l(Z.mdhd,u)},F=function(o){return l(Z.mdia,D(o),V(o.type),C(o))},E=function(o){return l(Z.mfhd,new Uint8Array([0,0,0,0,(o&4278190080)>>24,(o&16711680)>>16,(o&65280)>>8,o&255]))},C=function(o){return l(Z.minf,o.type==="video"?l(Z.vmhd,be):l(Z.smhd,me),h(),G(o))},P=function(o,u){for(var c=[],d=u.length;d--;)c[d]=fe(u[d]);return l.apply(null,[Z.moof,E(o)].concat(c))},v=function(o){for(var u=o.length,c=[];u--;)c[u]=N(o[u]);return l.apply(null,[Z.moov,L(4294967295)].concat(c).concat(R(o)))},R=function(o){for(var u=o.length,c=[];u--;)c[u]=ve(o[u]);return l.apply(null,[Z.mvex].concat(c))},L=function(o){var u=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,2,0,1,95,144,(o&4278190080)>>24,(o&16711680)>>16,(o&65280)>>8,o&255,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 l(Z.mvhd,u)},X=function(o){var u=o.samples||[],c=new Uint8Array(4+u.length),d,p;for(p=0;p<u.length;p++)d=u[p].flags,c[p+4]=d.dependsOn<<4|d.isDependedOn<<2|d.hasRedundancy;return l(Z.sdtp,c)},G=function(o){return l(Z.stbl,ae(o),l(Z.stts,Ue),l(Z.stsc,Ee),l(Z.stsz,ce),l(Z.stco,xt))},function(){var o,u;ae=function(c){return l(Z.stsd,new Uint8Array([0,0,0,0,0,0,0,1]),c.type==="video"?o(c):u(c))},o=function(c){var d=c.sps||[],p=c.pps||[],_=[],x=[],S,I;for(S=0;S<d.length;S++)_.push((d[S].byteLength&65280)>>>8),_.push(d[S].byteLength&255),_=_.concat(Array.prototype.slice.call(d[S]));for(S=0;S<p.length;S++)x.push((p[S].byteLength&65280)>>>8),x.push(p[S].byteLength&255),x=x.concat(Array.prototype.slice.call(p[S]));if(I=[Z.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,(c.width&65280)>>8,c.width&255,(c.height&65280)>>8,c.height&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,19,118,105,100,101,111,106,115,45,99,111,110,116,114,105,98,45,104,108,115,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),l(Z.avcC,new Uint8Array([1,c.profileIdc,c.profileCompatibility,c.levelIdc,255].concat([d.length],_,[p.length],x))),l(Z.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192]))],c.sarRatio){var A=c.sarRatio[0],O=c.sarRatio[1];I.push(l(Z.pasp,new Uint8Array([(A&4278190080)>>24,(A&16711680)>>16,(A&65280)>>8,A&255,(O&4278190080)>>24,(O&16711680)>>16,(O&65280)>>8,O&255])))}return l.apply(null,I)},u=function(c){return l(Z.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,(c.channelcount&65280)>>8,c.channelcount&255,(c.samplesize&65280)>>8,c.samplesize&255,0,0,0,0,(c.samplerate&65280)>>8,c.samplerate&255,0,0]),f(c))}}(),U=function(o){var u=new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,(o.id&4278190080)>>24,(o.id&16711680)>>16,(o.id&65280)>>8,o.id&255,0,0,0,0,(o.duration&4278190080)>>24,(o.duration&16711680)>>16,(o.duration&65280)>>8,o.duration&255,0,0,0,0,0,0,0,0,0,0,0,0,1,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,(o.width&65280)>>8,o.width&255,0,0,(o.height&65280)>>8,o.height&255,0,0]);return l(Z.tkhd,u)},fe=function(o){var u,c,d,p,_,x,S;return u=l(Z.tfhd,new Uint8Array([0,0,0,58,(o.id&4278190080)>>24,(o.id&16711680)>>16,(o.id&65280)>>8,o.id&255,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0])),x=Math.floor(o.baseMediaDecodeTime/a),S=Math.floor(o.baseMediaDecodeTime%a),c=l(Z.tfdt,new Uint8Array([1,0,0,0,x>>>24&255,x>>>16&255,x>>>8&255,x&255,S>>>24&255,S>>>16&255,S>>>8&255,S&255])),_=92,o.type==="audio"?(d=he(o,_),l(Z.traf,u,c,d)):(p=X(o),d=he(o,p.length+_),l(Z.traf,u,c,d,p))},N=function(o){return o.duration=o.duration||4294967295,l(Z.trak,U(o),F(o))},ve=function(o){var u=new Uint8Array([0,0,0,0,(o.id&4278190080)>>24,(o.id&16711680)>>16,(o.id&65280)>>8,o.id&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return o.type!=="video"&&(u[u.length-1]=0),l(Z.trex,u)},function(){var o,u,c;c=function(d,p){var _=0,x=0,S=0,I=0;return d.length&&(d[0].duration!==void 0&&(_=1),d[0].size!==void 0&&(x=2),d[0].flags!==void 0&&(S=4),d[0].compositionTimeOffset!==void 0&&(I=8)),[0,0,_|x|S|I,1,(d.length&4278190080)>>>24,(d.length&16711680)>>>16,(d.length&65280)>>>8,d.length&255,(p&4278190080)>>>24,(p&16711680)>>>16,(p&65280)>>>8,p&255]},u=function(d,p){var _,x,S,I,A,O;for(I=d.samples||[],p+=20+16*I.length,S=c(I,p),x=new Uint8Array(S.length+I.length*16),x.set(S),_=S.length,O=0;O<I.length;O++)A=I[O],x[_++]=(A.duration&4278190080)>>>24,x[_++]=(A.duration&16711680)>>>16,x[_++]=(A.duration&65280)>>>8,x[_++]=A.duration&255,x[_++]=(A.size&4278190080)>>>24,x[_++]=(A.size&16711680)>>>16,x[_++]=(A.size&65280)>>>8,x[_++]=A.size&255,x[_++]=A.flags.isLeading<<2|A.flags.dependsOn,x[_++]=A.flags.isDependedOn<<6|A.flags.hasRedundancy<<4|A.flags.paddingValue<<1|A.flags.isNonSyncSample,x[_++]=A.flags.degradationPriority&61440,x[_++]=A.flags.degradationPriority&15,x[_++]=(A.compositionTimeOffset&4278190080)>>>24,x[_++]=(A.compositionTimeOffset&16711680)>>>16,x[_++]=(A.compositionTimeOffset&65280)>>>8,x[_++]=A.compositionTimeOffset&255;return l(Z.trun,x)},o=function(d,p){var _,x,S,I,A,O;for(I=d.samples||[],p+=20+8*I.length,S=c(I,p),_=new Uint8Array(S.length+I.length*8),_.set(S),x=S.length,O=0;O<I.length;O++)A=I[O],_[x++]=(A.duration&4278190080)>>>24,_[x++]=(A.duration&16711680)>>>16,_[x++]=(A.duration&65280)>>>8,_[x++]=A.duration&255,_[x++]=(A.size&4278190080)>>>24,_[x++]=(A.size&16711680)>>>16,_[x++]=(A.size&65280)>>>8,_[x++]=A.size&255;return l(Z.trun,_)},he=function(d,p){return d.type==="audio"?o(d,p):u(d,p)}}();var zi={ftyp:m,mdat:T,moof:P,moov:v,initSegment:function(o){var u=m(),c=v(o),d;return d=new Uint8Array(u.byteLength+c.byteLength),d.set(u),d.set(c,u.byteLength),d}},ui=function(o){var u,c,d=[],p=[];for(p.byteLength=0,p.nalCount=0,p.duration=0,d.byteLength=0,u=0;u<o.length;u++)c=o[u],c.nalUnitType==="access_unit_delimiter_rbsp"?(d.length&&(d.duration=c.dts-d.dts,p.byteLength+=d.byteLength,p.nalCount+=d.length,p.duration+=d.duration,p.push(d)),d=[c],d.byteLength=c.data.byteLength,d.pts=c.pts,d.dts=c.dts):(c.nalUnitType==="slice_layer_without_partitioning_rbsp_idr"&&(d.keyFrame=!0),d.duration=c.dts-d.dts,d.byteLength+=c.data.byteLength,d.push(c));return p.length&&(!d.duration||d.duration<=0)&&(d.duration=p[p.length-1].duration),p.byteLength+=d.byteLength,p.nalCount+=d.length,p.duration+=d.duration,p.push(d),p},ci=function(o){var u,c,d=[],p=[];for(d.byteLength=0,d.nalCount=0,d.duration=0,d.pts=o[0].pts,d.dts=o[0].dts,p.byteLength=0,p.nalCount=0,p.duration=0,p.pts=o[0].pts,p.dts=o[0].dts,u=0;u<o.length;u++)c=o[u],c.keyFrame?(d.length&&(p.push(d),p.byteLength+=d.byteLength,p.nalCount+=d.nalCount,p.duration+=d.duration),d=[c],d.nalCount=c.length,d.byteLength=c.byteLength,d.pts=c.pts,d.dts=c.dts,d.duration=c.duration):(d.duration+=c.duration,d.nalCount+=c.length,d.byteLength+=c.byteLength,d.push(c));return p.length&&d.duration<=0&&(d.duration=p[p.length-1].duration),p.byteLength+=d.byteLength,p.nalCount+=d.nalCount,p.duration+=d.duration,p.push(d),p},wi=function(o){var u;return!o[0][0].keyFrame&&o.length>1&&(u=o.shift(),o.byteLength-=u.byteLength,o.nalCount-=u.nalCount,o[0][0].dts=u.dts,o[0][0].pts=u.pts,o[0][0].duration+=u.duration),o},mt=function(){return{size:0,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0,degradationPriority:0,isNonSyncSample:1}}},di=function(o,u){var c=mt();return c.dataOffset=u,c.compositionTimeOffset=o.pts-o.dts,c.duration=o.duration,c.size=4*o.length,c.size+=o.byteLength,o.keyFrame&&(c.flags.dependsOn=2,c.flags.isNonSyncSample=0),c},Ft=function(o,u){var c,d,p,_,x,S=u||0,I=[];for(c=0;c<o.length;c++)for(_=o[c],d=0;d<_.length;d++)x=_[d],p=di(x,S),S+=p.size,I.push(p);return I},Ii=function(o){var u,c,d,p,_,x,S=0,I=o.byteLength,A=o.nalCount,O=I+4*A,j=new Uint8Array(O),Y=new DataView(j.buffer);for(u=0;u<o.length;u++)for(p=o[u],c=0;c<p.length;c++)for(_=p[c],d=0;d<_.length;d++)x=_[d],Y.setUint32(S,x.data.byteLength),S+=4,j.set(x.data,S),S+=x.data.byteLength;return j},Dt=function(o,u){var c,d=u||0,p=[];return c=di(o,d),p.push(c),p},Lt=function(o){var u,c,d=0,p=o.byteLength,_=o.length,x=p+4*_,S=new Uint8Array(x),I=new DataView(S.buffer);for(u=0;u<o.length;u++)c=o[u],I.setUint32(d,c.data.byteLength),d+=4,S.set(c.data,d),d+=c.data.byteLength;return S},Ai={groupNalsIntoFrames:ui,groupFramesIntoGops:ci,extendFirstKeyFrame:wi,generateSampleTable:Ft,concatenateNalData:Ii,generateSampleTableForFrame:Dt,concatenateNalDataForFrame:Lt},$t=[33,16,5,32,164,27],Ds=[33,65,108,84,1,2,4,8,168,2,4,8,17,191,252],pe=function(o){for(var u=[];o--;)u.push(0);return u},ra=function(o){return Object.keys(o).reduce(function(u,c){return u[c]=new Uint8Array(o[c].reduce(function(d,p){return d.concat(p)},[])),u},{})},Ls,In=function(){if(!Ls){var o={96e3:[$t,[227,64],pe(154),[56]],88200:[$t,[231],pe(170),[56]],64e3:[$t,[248,192],pe(240),[56]],48e3:[$t,[255,192],pe(268),[55,148,128],pe(54),[112]],44100:[$t,[255,192],pe(268),[55,163,128],pe(84),[112]],32e3:[$t,[255,192],pe(268),[55,234],pe(226),[112]],24e3:[$t,[255,192],pe(268),[55,255,128],pe(268),[111,112],pe(126),[224]],16e3:[$t,[255,192],pe(268),[55,255,128],pe(268),[111,255],pe(269),[223,108],pe(195),[1,192]],12e3:[Ds,pe(268),[3,127,248],pe(268),[6,255,240],pe(268),[13,255,224],pe(268),[27,253,128],pe(259),[56]],11025:[Ds,pe(268),[3,127,248],pe(268),[6,255,240],pe(268),[13,255,224],pe(268),[27,255,192],pe(268),[55,175,128],pe(108),[112]],8e3:[Ds,pe(268),[3,121,16],pe(47),[7]]};Ls=ra(o)}return Ls},hi=9e4,lt,ki,Wi,St,An,b,g;lt=function(o){return o*hi},ki=function(o,u){return o*u},Wi=function(o){return o/hi},St=function(o,u){return o/u},An=function(o,u){return lt(St(o,u))},b=function(o,u){return ki(Wi(o),u)},g=function(o,u,c){return Wi(c?o:o-u)};var y={ONE_SECOND_IN_TS:hi,secondsToVideoTs:lt,secondsToAudioTs:ki,videoTsToSeconds:Wi,audioTsToSeconds:St,audioTsToVideoTs:An,videoTsToAudioTs:b,metadataTsToSeconds:g},w=In,M=y,$=function(o){var u,c,d=0;for(u=0;u<o.length;u++)c=o[u],d+=c.data.byteLength;return d},z=function(o,u,c,d){var p,_=0,x=0,S=0,I=0,A,O,j;if(u.length&&(p=M.audioTsToVideoTs(o.baseMediaDecodeTime,o.samplerate),_=Math.ceil(M.ONE_SECOND_IN_TS/(o.samplerate/1024)),c&&d&&(x=p-Math.max(c,d),S=Math.floor(x/_),I=S*_),!(S<1||I>M.ONE_SECOND_IN_TS/2))){for(A=w()[o.samplerate],A||(A=u[0].data),O=0;O<S;O++)j=u[0],u.splice(0,0,{data:A,dts:j.dts-_,pts:j.pts-_});return o.baseMediaDecodeTime-=Math.floor(M.videoTsToAudioTs(I,o.samplerate)),I}},le=function(o,u,c){return u.minSegmentDts>=c?o:(u.minSegmentDts=1/0,o.filter(function(d){return d.dts>=c?(u.minSegmentDts=Math.min(u.minSegmentDts,d.dts),u.minSegmentPts=u.minSegmentDts,!0):!1}))},Pe=function(o){var u,c,d=[];for(u=0;u<o.length;u++)c=o[u],d.push({size:c.data.byteLength,duration:1024});return d},Ce=function(o){var u,c,d=0,p=new Uint8Array($(o));for(u=0;u<o.length;u++)c=o[u],p.set(c.data,d),d+=c.data.byteLength;return p},De={prefixWithSilence:z,trimAdtsFramesByEarliestDts:le,generateSampleTable:Pe,concatenateFrameData:Ce},ye=y.ONE_SECOND_IN_TS,Gf=function(o,u){typeof u.pts=="number"&&(o.timelineStartInfo.pts===void 0&&(o.timelineStartInfo.pts=u.pts),o.minSegmentPts===void 0?o.minSegmentPts=u.pts:o.minSegmentPts=Math.min(o.minSegmentPts,u.pts),o.maxSegmentPts===void 0?o.maxSegmentPts=u.pts:o.maxSegmentPts=Math.max(o.maxSegmentPts,u.pts)),typeof u.dts=="number"&&(o.timelineStartInfo.dts===void 0&&(o.timelineStartInfo.dts=u.dts),o.minSegmentDts===void 0?o.minSegmentDts=u.dts:o.minSegmentDts=Math.min(o.minSegmentDts,u.dts),o.maxSegmentDts===void 0?o.maxSegmentDts=u.dts:o.maxSegmentDts=Math.max(o.maxSegmentDts,u.dts))},Kf=function(o){delete o.minSegmentDts,delete o.maxSegmentDts,delete o.minSegmentPts,delete o.maxSegmentPts},Xf=function(o,u){var c,d,p=o.minSegmentDts;return u||(p-=o.timelineStartInfo.dts),c=o.timelineStartInfo.baseMediaDecodeTime,c+=p,c=Math.max(0,c),o.type==="audio"&&(d=o.samplerate/ye,c*=d,c=Math.floor(c)),c},Yf={clearDtsInfo:Kf,calculateTrackBaseMediaDecodeTime:Xf,collectDtsInfo:Gf},gl=4,Qf=128,Jf=function(o){for(var u=0,c={payloadType:-1,payloadSize:0},d=0,p=0;u<o.byteLength&&o[u]!==Qf;){for(;o[u]===255;)d+=255,u++;for(d+=o[u++];o[u]===255;)p+=255,u++;if(p+=o[u++],!c.payload&&d===gl){var _=String.fromCharCode(o[u+3],o[u+4],o[u+5],o[u+6]);if(_==="GA94"){c.payloadType=d,c.payloadSize=p,c.payload=o.subarray(u,u+p);break}else c.payload=void 0}u+=p,d=0,p=0}return c},Zf=function(o){return o.payload[0]!==181||(o.payload[1]<<8|o.payload[2])!==49||String.fromCharCode(o.payload[3],o.payload[4],o.payload[5],o.payload[6])!=="GA94"||o.payload[7]!==3?null:o.payload.subarray(8,o.payload.length-1)},ep=function(o,u){var c=[],d,p,_,x;if(!(u[0]&64))return c;for(p=u[0]&31,d=0;d<p;d++)_=d*3,x={type:u[_+2]&3,pts:o},u[_+2]&4&&(x.ccData=u[_+3]<<8|u[_+4],c.push(x));return c},tp=function(o){for(var u=o.byteLength,c=[],d=1,p,_;d<u-2;)o[d]===0&&o[d+1]===0&&o[d+2]===3?(c.push(d+2),d+=2):d++;if(c.length===0)return o;p=u-c.length,_=new Uint8Array(p);var x=0;for(d=0;d<p;x++,d++)x===c[0]&&(x++,c.shift()),_[d]=o[x];return _},yl={parseSei:Jf,parseUserData:Zf,parseCaptionPackets:ep,discardEmulationPreventionBytes:tp,USER_DATA_REGISTERED_ITU_T_T35:gl},aa=t,kn=yl,ut=function(o){o=o||{},ut.prototype.init.call(this),this.parse708captions_=typeof o.parse708captions=="boolean"?o.parse708captions:!0,this.captionPackets_=[],this.ccStreams_=[new Le(0,0),new Le(0,1),new Le(1,0),new Le(1,1)],this.parse708captions_&&(this.cc708Stream_=new Se({captionServices:o.captionServices})),this.reset(),this.ccStreams_.forEach(function(u){u.on("data",this.trigger.bind(this,"data")),u.on("partialdone",this.trigger.bind(this,"partialdone")),u.on("done",this.trigger.bind(this,"done"))},this),this.parse708captions_&&(this.cc708Stream_.on("data",this.trigger.bind(this,"data")),this.cc708Stream_.on("partialdone",this.trigger.bind(this,"partialdone")),this.cc708Stream_.on("done",this.trigger.bind(this,"done")))};ut.prototype=new aa,ut.prototype.push=function(o){var u,c,d;if(o.nalUnitType==="sei_rbsp"&&(u=kn.parseSei(o.escapedRBSP),!!u.payload&&u.payloadType===kn.USER_DATA_REGISTERED_ITU_T_T35&&(c=kn.parseUserData(u),!!c))){if(o.dts<this.latestDts_){this.ignoreNextEqualDts_=!0;return}else if(o.dts===this.latestDts_&&this.ignoreNextEqualDts_){this.numSameDts_--,this.numSameDts_||(this.ignoreNextEqualDts_=!1);return}d=kn.parseCaptionPackets(o.pts,c),this.captionPackets_=this.captionPackets_.concat(d),this.latestDts_!==o.dts&&(this.numSameDts_=0),this.numSameDts_++,this.latestDts_=o.dts}},ut.prototype.flushCCStreams=function(o){this.ccStreams_.forEach(function(u){return o==="flush"?u.flush():u.partialFlush()},this)},ut.prototype.flushStream=function(o){if(!this.captionPackets_.length){this.flushCCStreams(o);return}this.captionPackets_.forEach(function(u,c){u.presortIndex=c}),this.captionPackets_.sort(function(u,c){return u.pts===c.pts?u.presortIndex-c.presortIndex:u.pts-c.pts}),this.captionPackets_.forEach(function(u){u.type<2?this.dispatchCea608Packet(u):this.dispatchCea708Packet(u)},this),this.captionPackets_.length=0,this.flushCCStreams(o)},ut.prototype.flush=function(){return this.flushStream("flush")},ut.prototype.partialFlush=function(){return this.flushStream("partialFlush")},ut.prototype.reset=function(){this.latestDts_=null,this.ignoreNextEqualDts_=!1,this.numSameDts_=0,this.activeCea608Channel_=[null,null],this.ccStreams_.forEach(function(o){o.reset()})},ut.prototype.dispatchCea608Packet=function(o){this.setsTextOrXDSActive(o)?this.activeCea608Channel_[o.type]=null:this.setsChannel1Active(o)?this.activeCea608Channel_[o.type]=0:this.setsChannel2Active(o)&&(this.activeCea608Channel_[o.type]=1),this.activeCea608Channel_[o.type]!==null&&this.ccStreams_[(o.type<<1)+this.activeCea608Channel_[o.type]].push(o)},ut.prototype.setsChannel1Active=function(o){return(o.ccData&30720)===4096},ut.prototype.setsChannel2Active=function(o){return(o.ccData&30720)===6144},ut.prototype.setsTextOrXDSActive=function(o){return(o.ccData&28928)===256||(o.ccData&30974)===4138||(o.ccData&30974)===6186},ut.prototype.dispatchCea708Packet=function(o){this.parse708captions_&&this.cc708Stream_.push(o)};var ip={127:9834,4128:32,4129:160,4133:8230,4138:352,4140:338,4144:9608,4145:8216,4146:8217,4147:8220,4148:8221,4149:8226,4153:8482,4154:353,4156:339,4157:8480,4159:376,4214:8539,4215:8540,4216:8541,4217:8542,4218:9168,4219:9124,4220:9123,4221:9135,4222:9126,4223:9121,4256:12600},sp=function(o){var u=ip[o]||o;return o&4096&&o===u?"":String.fromCharCode(u)},Pn=function(o){return 32<=o&&o<=127||160<=o&&o<=255},ii=function(o){this.windowNum=o,this.reset()};ii.prototype.reset=function(){this.clearText(),this.pendingNewLine=!1,this.winAttr={},this.penAttr={},this.penLoc={},this.penColor={},this.visible=0,this.rowLock=0,this.columnLock=0,this.priority=0,this.relativePositioning=0,this.anchorVertical=0,this.anchorHorizontal=0,this.anchorPoint=0,this.rowCount=1,this.virtualRowCount=this.rowCount+1,this.columnCount=41,this.windowStyle=0,this.penStyle=0},ii.prototype.getText=function(){return this.rows.join(`
|
|
193
|
+
`)},ii.prototype.clearText=function(){this.rows=[""],this.rowIdx=0},ii.prototype.newLine=function(o){for(this.rows.length>=this.virtualRowCount&&typeof this.beforeRowOverflow=="function"&&this.beforeRowOverflow(o),this.rows.length>0&&(this.rows.push(""),this.rowIdx++);this.rows.length>this.virtualRowCount;)this.rows.shift(),this.rowIdx--},ii.prototype.isEmpty=function(){return this.rows.length===0?!0:this.rows.length===1?this.rows[0]==="":!1},ii.prototype.addText=function(o){this.rows[this.rowIdx]+=o},ii.prototype.backspace=function(){if(!this.isEmpty()){var o=this.rows[this.rowIdx];this.rows[this.rowIdx]=o.substr(0,o.length-1)}};var Dn=function(o,u,c){this.serviceNum=o,this.text="",this.currentWindow=new ii(-1),this.windows=[],this.stream=c,typeof u=="string"&&this.createTextDecoder(u)};Dn.prototype.init=function(o,u){this.startPts=o;for(var c=0;c<8;c++)this.windows[c]=new ii(c),typeof u=="function"&&(this.windows[c].beforeRowOverflow=u)},Dn.prototype.setCurrentWindow=function(o){this.currentWindow=this.windows[o]},Dn.prototype.createTextDecoder=function(o){if(typeof TextDecoder>"u")this.stream.trigger("log",{level:"warn",message:"The `encoding` option is unsupported without TextDecoder support"});else try{this.textDecoder_=new TextDecoder(o)}catch(u){this.stream.trigger("log",{level:"warn",message:"TextDecoder could not be created with "+o+" encoding. "+u})}};var Se=function(o){o=o||{},Se.prototype.init.call(this);var u=this,c=o.captionServices||{},d={},p;Object.keys(c).forEach(_=>{p=c[_],/^SERVICE/.test(_)&&(d[_]=p.encoding)}),this.serviceEncodings=d,this.current708Packet=null,this.services={},this.push=function(_){_.type===3?(u.new708Packet(),u.add708Bytes(_)):(u.current708Packet===null&&u.new708Packet(),u.add708Bytes(_))}};Se.prototype=new aa,Se.prototype.new708Packet=function(){this.current708Packet!==null&&this.push708Packet(),this.current708Packet={data:[],ptsVals:[]}},Se.prototype.add708Bytes=function(o){var u=o.ccData,c=u>>>8,d=u&255;this.current708Packet.ptsVals.push(o.pts),this.current708Packet.data.push(c),this.current708Packet.data.push(d)},Se.prototype.push708Packet=function(){var o=this.current708Packet,u=o.data,c=null,d=null,p=0,_=u[p++];for(o.seq=_>>6,o.sizeCode=_&63;p<u.length;p++)_=u[p++],c=_>>5,d=_&31,c===7&&d>0&&(_=u[p++],c=_),this.pushServiceBlock(c,p,d),d>0&&(p+=d-1)},Se.prototype.pushServiceBlock=function(o,u,c){var d,p=u,_=this.current708Packet.data,x=this.services[o];for(x||(x=this.initService(o,p));p<u+c&&p<_.length;p++)d=_[p],Pn(d)?p=this.handleText(p,x):d===24?p=this.multiByteCharacter(p,x):d===16?p=this.extendedCommands(p,x):128<=d&&d<=135?p=this.setCurrentWindow(p,x):152<=d&&d<=159?p=this.defineWindow(p,x):d===136?p=this.clearWindows(p,x):d===140?p=this.deleteWindows(p,x):d===137?p=this.displayWindows(p,x):d===138?p=this.hideWindows(p,x):d===139?p=this.toggleWindows(p,x):d===151?p=this.setWindowAttributes(p,x):d===144?p=this.setPenAttributes(p,x):d===145?p=this.setPenColor(p,x):d===146?p=this.setPenLocation(p,x):d===143?x=this.reset(p,x):d===8?x.currentWindow.backspace():d===12?x.currentWindow.clearText():d===13?x.currentWindow.pendingNewLine=!0:d===14?x.currentWindow.clearText():d===141&&p++},Se.prototype.extendedCommands=function(o,u){var c=this.current708Packet.data,d=c[++o];return Pn(d)&&(o=this.handleText(o,u,{isExtended:!0})),o},Se.prototype.getPts=function(o){return this.current708Packet.ptsVals[Math.floor(o/2)]},Se.prototype.initService=function(o,u){var d="SERVICE"+o,c=this,d,p;return d in this.serviceEncodings&&(p=this.serviceEncodings[d]),this.services[o]=new Dn(o,p,c),this.services[o].init(this.getPts(u),function(_){c.flushDisplayed(_,c.services[o])}),this.services[o]},Se.prototype.handleText=function(o,u,c){var d=c&&c.isExtended,p=c&&c.isMultiByte,_=this.current708Packet.data,x=d?4096:0,S=_[o],I=_[o+1],A=u.currentWindow,O,j;function Y(q){return q.map(te=>("0"+(te&255).toString(16)).slice(-2)).join("")}if(p?(j=[S,I],o++):j=[S],u.textDecoder_&&!d)O=u.textDecoder_.decode(new Uint8Array(j));else if(p){const q=Y(j);O=String.fromCharCode(parseInt(q,16))}else O=sp(x|S);return A.pendingNewLine&&!A.isEmpty()&&A.newLine(this.getPts(o)),A.pendingNewLine=!1,A.addText(O),o},Se.prototype.multiByteCharacter=function(o,u){var c=this.current708Packet.data,d=c[o+1],p=c[o+2];return Pn(d)&&Pn(p)&&(o=this.handleText(++o,u,{isMultiByte:!0})),o},Se.prototype.setCurrentWindow=function(o,u){var c=this.current708Packet.data,d=c[o],p=d&7;return u.setCurrentWindow(p),o},Se.prototype.defineWindow=function(o,u){var c=this.current708Packet.data,d=c[o],p=d&7;u.setCurrentWindow(p);var _=u.currentWindow;return d=c[++o],_.visible=(d&32)>>5,_.rowLock=(d&16)>>4,_.columnLock=(d&8)>>3,_.priority=d&7,d=c[++o],_.relativePositioning=(d&128)>>7,_.anchorVertical=d&127,d=c[++o],_.anchorHorizontal=d,d=c[++o],_.anchorPoint=(d&240)>>4,_.rowCount=d&15,d=c[++o],_.columnCount=d&63,d=c[++o],_.windowStyle=(d&56)>>3,_.penStyle=d&7,_.virtualRowCount=_.rowCount+1,o},Se.prototype.setWindowAttributes=function(o,u){var c=this.current708Packet.data,d=c[o],p=u.currentWindow.winAttr;return d=c[++o],p.fillOpacity=(d&192)>>6,p.fillRed=(d&48)>>4,p.fillGreen=(d&12)>>2,p.fillBlue=d&3,d=c[++o],p.borderType=(d&192)>>6,p.borderRed=(d&48)>>4,p.borderGreen=(d&12)>>2,p.borderBlue=d&3,d=c[++o],p.borderType+=(d&128)>>5,p.wordWrap=(d&64)>>6,p.printDirection=(d&48)>>4,p.scrollDirection=(d&12)>>2,p.justify=d&3,d=c[++o],p.effectSpeed=(d&240)>>4,p.effectDirection=(d&12)>>2,p.displayEffect=d&3,o},Se.prototype.flushDisplayed=function(o,u){for(var c=[],d=0;d<8;d++)u.windows[d].visible&&!u.windows[d].isEmpty()&&c.push(u.windows[d].getText());u.endPts=o,u.text=c.join(`
|
|
194
194
|
|
|
195
|
-
`),this.pushCaption(u),u.startPts=o},Ee.prototype.pushCaption=function(o){o.text!==""&&(this.trigger("data",{startPts:o.startPts,endPts:o.endPts,text:o.text,stream:"cc708_"+o.serviceNum}),o.text="",o.startPts=o.endPts)},Ee.prototype.displayWindows=function(o,u){var d=this.current708Packet.data,h=d[++o],g=this.getPts(o);this.flushDisplayed(g,u);for(var y=0;y<8;y++)h&1<<y&&(u.windows[y].visible=1);return o},Ee.prototype.hideWindows=function(o,u){var d=this.current708Packet.data,h=d[++o],g=this.getPts(o);this.flushDisplayed(g,u);for(var y=0;y<8;y++)h&1<<y&&(u.windows[y].visible=0);return o},Ee.prototype.toggleWindows=function(o,u){var d=this.current708Packet.data,h=d[++o],g=this.getPts(o);this.flushDisplayed(g,u);for(var y=0;y<8;y++)h&1<<y&&(u.windows[y].visible^=1);return o},Ee.prototype.clearWindows=function(o,u){var d=this.current708Packet.data,h=d[++o],g=this.getPts(o);this.flushDisplayed(g,u);for(var y=0;y<8;y++)h&1<<y&&u.windows[y].clearText();return o},Ee.prototype.deleteWindows=function(o,u){var d=this.current708Packet.data,h=d[++o],g=this.getPts(o);this.flushDisplayed(g,u);for(var y=0;y<8;y++)h&1<<y&&u.windows[y].reset();return o},Ee.prototype.setPenAttributes=function(o,u){var d=this.current708Packet.data,h=d[o],g=u.currentWindow.penAttr;return h=d[++o],g.textTag=(h&240)>>4,g.offset=(h&12)>>2,g.penSize=h&3,h=d[++o],g.italics=(h&128)>>7,g.underline=(h&64)>>6,g.edgeType=(h&56)>>3,g.fontStyle=h&7,o},Ee.prototype.setPenColor=function(o,u){var d=this.current708Packet.data,h=d[o],g=u.currentWindow.penColor;return h=d[++o],g.fgOpacity=(h&192)>>6,g.fgRed=(h&48)>>4,g.fgGreen=(h&12)>>2,g.fgBlue=h&3,h=d[++o],g.bgOpacity=(h&192)>>6,g.bgRed=(h&48)>>4,g.bgGreen=(h&12)>>2,g.bgBlue=h&3,h=d[++o],g.edgeRed=(h&48)>>4,g.edgeGreen=(h&12)>>2,g.edgeBlue=h&3,o},Ee.prototype.setPenLocation=function(o,u){var d=this.current708Packet.data,h=d[o],g=u.currentWindow.penLoc;return u.currentWindow.pendingNewLine=!0,h=d[++o],g.row=h&15,h=d[++o],g.column=h&63,o},Ee.prototype.reset=function(o,u){var d=this.getPts(o);return this.flushDisplayed(d,u),this.initService(u.serviceNum,o)};var ig={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,304:174,305:176,306:189,307:191,308:8482,309:162,310:163,311:9834,312:224,313:160,314:232,315:226,316:234,317:238,318:244,319:251,544:193,545:201,546:211,547:218,548:220,549:252,550:8216,551:161,552:42,553:39,554:8212,555:169,556:8480,557:8226,558:8220,559:8221,560:192,561:194,562:199,563:200,564:202,565:203,566:235,567:206,568:207,569:239,570:212,571:217,572:249,573:219,574:171,575:187,800:195,801:227,802:205,803:204,804:236,805:210,806:242,807:213,808:245,809:123,810:125,811:92,812:94,813:95,814:124,815:126,816:196,817:228,818:214,819:246,820:223,821:165,822:164,823:9474,824:197,825:229,826:216,827:248,828:9484,829:9488,830:9492,831:9496},xs=function(o){return o===null?"":(o=ig[o]||o,String.fromCharCode(o))},As=14,ng=[4352,4384,4608,4640,5376,5408,5632,5664,5888,5920,4096,4864,4896,5120,5152],Ii=function(){for(var o=[],u=As+1;u--;)o.push({text:"",indent:0,offset:0});return o},Pe=function(o,u){Pe.prototype.init.call(this),this.field_=o||0,this.dataChannel_=u||0,this.name_="CC"+((this.field_<<1|this.dataChannel_)+1),this.setConstants(),this.reset(),this.push=function(d){var h,g,y,S,E;if(h=d.ccData&32639,h===this.lastControlCode_){this.lastControlCode_=null;return}if((h&61440)===4096?this.lastControlCode_=h:h!==this.PADDING_&&(this.lastControlCode_=null),y=h>>>8,S=h&255,h!==this.PADDING_)if(h===this.RESUME_CAPTION_LOADING_)this.mode_="popOn";else if(h===this.END_OF_CAPTION_)this.mode_="popOn",this.clearFormatting(d.pts),this.flushDisplayed(d.pts),g=this.displayed_,this.displayed_=this.nonDisplayed_,this.nonDisplayed_=g,this.startPts_=d.pts;else if(h===this.ROLL_UP_2_ROWS_)this.rollUpRows_=2,this.setRollUp(d.pts);else if(h===this.ROLL_UP_3_ROWS_)this.rollUpRows_=3,this.setRollUp(d.pts);else if(h===this.ROLL_UP_4_ROWS_)this.rollUpRows_=4,this.setRollUp(d.pts);else if(h===this.CARRIAGE_RETURN_)this.clearFormatting(d.pts),this.flushDisplayed(d.pts),this.shiftRowsUp_(),this.startPts_=d.pts;else if(h===this.BACKSPACE_)this.mode_==="popOn"?this.nonDisplayed_[this.row_].text=this.nonDisplayed_[this.row_].text.slice(0,-1):this.displayed_[this.row_].text=this.displayed_[this.row_].text.slice(0,-1);else if(h===this.ERASE_DISPLAYED_MEMORY_)this.flushDisplayed(d.pts),this.displayed_=Ii();else if(h===this.ERASE_NON_DISPLAYED_MEMORY_)this.nonDisplayed_=Ii();else if(h===this.RESUME_DIRECT_CAPTIONING_)this.mode_!=="paintOn"&&(this.flushDisplayed(d.pts),this.displayed_=Ii()),this.mode_="paintOn",this.startPts_=d.pts;else if(this.isSpecialCharacter(y,S))y=(y&3)<<8,E=xs(y|S),this[this.mode_](d.pts,E),this.column_++;else if(this.isExtCharacter(y,S))this.mode_==="popOn"?this.nonDisplayed_[this.row_].text=this.nonDisplayed_[this.row_].text.slice(0,-1):this.displayed_[this.row_].text=this.displayed_[this.row_].text.slice(0,-1),y=(y&3)<<8,E=xs(y|S),this[this.mode_](d.pts,E),this.column_++;else if(this.isMidRowCode(y,S))this.clearFormatting(d.pts),this[this.mode_](d.pts," "),this.column_++,(S&14)===14&&this.addFormatting(d.pts,["i"]),(S&1)===1&&this.addFormatting(d.pts,["u"]);else if(this.isOffsetControlCode(y,S)){const I=S&3;this.nonDisplayed_[this.row_].offset=I,this.column_+=I}else if(this.isPAC(y,S)){var k=ng.indexOf(h&7968);if(this.mode_==="rollUp"&&(k-this.rollUpRows_+1<0&&(k=this.rollUpRows_-1),this.setRollUp(d.pts,k)),k!==this.row_&&k>=0&&k<=14&&(this.clearFormatting(d.pts),this.row_=k),S&1&&this.formatting_.indexOf("u")===-1&&this.addFormatting(d.pts,["u"]),(h&16)===16){const I=(h&14)>>1;this.column_=I*4,this.nonDisplayed_[this.row_].indent+=I}this.isColorPAC(S)&&(S&14)===14&&this.addFormatting(d.pts,["i"])}else this.isNormalChar(y)&&(S===0&&(S=null),E=xs(y),E+=xs(S),this[this.mode_](d.pts,E),this.column_+=E.length)}};Pe.prototype=new na,Pe.prototype.flushDisplayed=function(o){const u=h=>{this.trigger("log",{level:"warn",message:"Skipping a malformed 608 caption at index "+h+"."})},d=[];this.displayed_.forEach((h,g)=>{if(h&&h.text&&h.text.length){try{h.text=h.text.trim()}catch{u(g)}h.text.length&&d.push({text:h.text,line:g+1,position:10+Math.min(70,h.indent*10)+h.offset*2.5})}else h==null&&u(g)}),d.length&&this.trigger("data",{startPts:this.startPts_,endPts:o,content:d,stream:this.name_})},Pe.prototype.reset=function(){this.mode_="popOn",this.topRow_=0,this.startPts_=0,this.displayed_=Ii(),this.nonDisplayed_=Ii(),this.lastControlCode_=null,this.column_=0,this.row_=As,this.rollUpRows_=2,this.formatting_=[]},Pe.prototype.setConstants=function(){this.dataChannel_===0?(this.BASE_=16,this.EXT_=17,this.CONTROL_=(20|this.field_)<<8,this.OFFSET_=23):this.dataChannel_===1&&(this.BASE_=24,this.EXT_=25,this.CONTROL_=(28|this.field_)<<8,this.OFFSET_=31),this.PADDING_=0,this.RESUME_CAPTION_LOADING_=this.CONTROL_|32,this.END_OF_CAPTION_=this.CONTROL_|47,this.ROLL_UP_2_ROWS_=this.CONTROL_|37,this.ROLL_UP_3_ROWS_=this.CONTROL_|38,this.ROLL_UP_4_ROWS_=this.CONTROL_|39,this.CARRIAGE_RETURN_=this.CONTROL_|45,this.RESUME_DIRECT_CAPTIONING_=this.CONTROL_|41,this.BACKSPACE_=this.CONTROL_|33,this.ERASE_DISPLAYED_MEMORY_=this.CONTROL_|44,this.ERASE_NON_DISPLAYED_MEMORY_=this.CONTROL_|46},Pe.prototype.isSpecialCharacter=function(o,u){return o===this.EXT_&&u>=48&&u<=63},Pe.prototype.isExtCharacter=function(o,u){return(o===this.EXT_+1||o===this.EXT_+2)&&u>=32&&u<=63},Pe.prototype.isMidRowCode=function(o,u){return o===this.EXT_&&u>=32&&u<=47},Pe.prototype.isOffsetControlCode=function(o,u){return o===this.OFFSET_&&u>=33&&u<=35},Pe.prototype.isPAC=function(o,u){return o>=this.BASE_&&o<this.BASE_+8&&u>=64&&u<=127},Pe.prototype.isColorPAC=function(o){return o>=64&&o<=79||o>=96&&o<=127},Pe.prototype.isNormalChar=function(o){return o>=32&&o<=127},Pe.prototype.setRollUp=function(o,u){if(this.mode_!=="rollUp"&&(this.row_=As,this.mode_="rollUp",this.flushDisplayed(o),this.nonDisplayed_=Ii(),this.displayed_=Ii()),u!==void 0&&u!==this.row_)for(var d=0;d<this.rollUpRows_;d++)this.displayed_[u-d]=this.displayed_[this.row_-d],this.displayed_[this.row_-d]={text:"",indent:0,offset:0};u===void 0&&(u=this.row_),this.topRow_=u-this.rollUpRows_+1},Pe.prototype.addFormatting=function(o,u){this.formatting_=this.formatting_.concat(u);var d=u.reduce(function(h,g){return h+"<"+g+">"},"");this[this.mode_](o,d)},Pe.prototype.clearFormatting=function(o){if(this.formatting_.length){var u=this.formatting_.reverse().reduce(function(d,h){return d+"</"+h+">"},"");this.formatting_=[],this[this.mode_](o,u)}},Pe.prototype.popOn=function(o,u){var d=this.nonDisplayed_[this.row_].text;d+=u,this.nonDisplayed_[this.row_].text=d},Pe.prototype.rollUp=function(o,u){var d=this.displayed_[this.row_].text;d+=u,this.displayed_[this.row_].text=d},Pe.prototype.shiftRowsUp_=function(){var o;for(o=0;o<this.topRow_;o++)this.displayed_[o]={text:"",indent:0,offset:0};for(o=this.row_+1;o<As+1;o++)this.displayed_[o]={text:"",indent:0,offset:0};for(o=this.topRow_;o<this.row_;o++)this.displayed_[o]=this.displayed_[o+1];this.displayed_[this.row_]={text:"",indent:0,offset:0}},Pe.prototype.paintOn=function(o,u){var d=this.displayed_[this.row_].text;d+=u,this.displayed_[this.row_].text=d};var ml={CaptionStream:dt,Cea608Stream:Pe,Cea708Stream:Ee},Ps={H264_STREAM_TYPE:27,ADTS_STREAM_TYPE:15,METADATA_STREAM_TYPE:21},sg=t,rg=8589934592,ag=4294967296,yl="shared",sa=function(o,u){var d=1;for(o>u&&(d=-1);Math.abs(u-o)>ag;)o+=d*rg;return o},ra=function(o){var u,d;ra.prototype.init.call(this),this.type_=o||yl,this.push=function(h){if(h.type==="metadata"){this.trigger("data",h);return}this.type_!==yl&&h.type!==this.type_||(d===void 0&&(d=h.dts),h.dts=sa(h.dts,d),h.pts=sa(h.pts,d),u=h.dts,this.trigger("data",h))},this.flush=function(){d=u,this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")},this.discontinuity=function(){d=void 0,u=void 0},this.reset=function(){this.discontinuity(),this.trigger("reset")}};ra.prototype=new sg;var _l={TimestampRolloverStream:ra,handleRollover:sa},og=(o,u,d)=>{if(!o)return-1;for(var h=d;h<o.length;h++)if(o[h]===u)return h;return-1},lg={typedArrayIndexOf:og},Ls=lg.typedArrayIndexOf,Ds={Iso88591:0,Utf16:1,Utf16be:2,Utf8:3},bl=function(o,u,d){var h,g="";for(h=u;h<d;h++)g+="%"+("00"+o[h].toString(16)).slice(-2);return g},Dn=function(o,u,d){return decodeURIComponent(bl(o,u,d))},On=function(o,u,d){return unescape(bl(o,u,d))},Mn=function(o){return o[0]<<21|o[1]<<14|o[2]<<7|o[3]},Rn={APIC:function(o){var u=1,d,h,g="-->";o.data[0]===Ds.Utf8&&(d=Ls(o.data,0,u),!(d<0)&&(o.mimeType=On(o.data,u,d),u=d+1,o.pictureType=o.data[u],u++,h=Ls(o.data,0,u),!(h<0)&&(o.description=Dn(o.data,u,h),u=h+1,o.mimeType===g?o.url=On(o.data,u,o.data.length):o.pictureData=o.data.subarray(u,o.data.length))))},"T*":function(o){o.data[0]===Ds.Utf8&&(o.value=Dn(o.data,1,o.data.length).replace(/\0*$/,""),o.values=o.value.split("\0"))},TXXX:function(o){var u;o.data[0]===Ds.Utf8&&(u=Ls(o.data,0,1),u!==-1&&(o.description=Dn(o.data,1,u),o.value=Dn(o.data,u+1,o.data.length).replace(/\0*$/,""),o.data=o.value))},"W*":function(o){o.url=On(o.data,0,o.data.length).replace(/\0.*$/,"")},WXXX:function(o){var u;o.data[0]===Ds.Utf8&&(u=Ls(o.data,0,1),u!==-1&&(o.description=Dn(o.data,1,u),o.url=On(o.data,u+1,o.data.length).replace(/\0.*$/,"")))},PRIV:function(o){var u;for(u=0;u<o.data.length;u++)if(o.data[u]===0){o.owner=On(o.data,0,u);break}o.privateData=o.data.subarray(u+1),o.data=o.privateData}},ug=function(o){var u,d,h=10,g=0,y=[];if(!(o.length<10||o[0]!==73||o[1]!==68||o[2]!==51)){g=Mn(o.subarray(6,10)),g+=10;var S=o[5]&64;S&&(h+=4,h+=Mn(o.subarray(10,14)),g-=Mn(o.subarray(16,20)));do{if(u=Mn(o.subarray(h+4,h+8)),u<1)break;d=String.fromCharCode(o[h],o[h+1],o[h+2],o[h+3]);var E={id:d,data:o.subarray(h+10,h+u+10)};E.key=E.id,Rn[E.id]?Rn[E.id](E):E.id[0]==="T"?Rn["T*"](E):E.id[0]==="W"&&Rn["W*"](E),y.push(E),h+=10,h+=u}while(h<g);return y}},Tl={parseId3Frames:ug,parseSyncSafeInteger:Mn,frameParsers:Rn},dg=t,hg=Ps,hi=Tl,Os;Os=function(o){var u={descriptor:o&&o.descriptor},d=0,h=[],g=0,y;if(Os.prototype.init.call(this),this.dispatchType=hg.METADATA_STREAM_TYPE.toString(16),u.descriptor)for(y=0;y<u.descriptor.length;y++)this.dispatchType+=("00"+u.descriptor[y].toString(16)).slice(-2);this.push=function(S){var E,k,I,O,j,Q;if(S.type==="timed-metadata"){if(S.dataAlignmentIndicator&&(g=0,h.length=0),h.length===0&&(S.data.length<10||S.data[0]!==73||S.data[1]!==68||S.data[2]!==51)){this.trigger("log",{level:"warn",message:"Skipping unrecognized metadata packet"});return}if(h.push(S),g+=S.data.byteLength,h.length===1&&(d=hi.parseSyncSafeInteger(S.data.subarray(6,10)),d+=10),!(g<d)){for(E={data:new Uint8Array(d),frames:[],pts:h[0].pts,dts:h[0].dts},j=0;j<d;)E.data.set(h[0].data.subarray(0,d-j),j),j+=h[0].data.byteLength,g-=h[0].data.byteLength,h.shift();k=10,E.data[5]&64&&(k+=4,k+=hi.parseSyncSafeInteger(E.data.subarray(10,14)),d-=hi.parseSyncSafeInteger(E.data.subarray(16,20)));do{if(I=hi.parseSyncSafeInteger(E.data.subarray(k+4,k+8)),I<1){this.trigger("log",{level:"warn",message:"Malformed ID3 frame encountered. Skipping remaining metadata parsing."});break}if(Q=String.fromCharCode(E.data[k],E.data[k+1],E.data[k+2],E.data[k+3]),O={id:Q,data:E.data.subarray(k+10,k+I+10)},O.key=O.id,hi.frameParsers[O.id]?hi.frameParsers[O.id](O):O.id[0]==="T"?hi.frameParsers["T*"](O):O.id[0]==="W"&&hi.frameParsers["W*"](O),O.owner==="com.apple.streaming.transportStreamTimestamp"){var V=O.data,te=(V[3]&1)<<30|V[4]<<22|V[5]<<14|V[6]<<6|V[7]>>>2;te*=4,te+=V[7]&3,O.timeStamp=te,E.pts===void 0&&E.dts===void 0&&(E.pts=O.timeStamp,E.dts=O.timeStamp),this.trigger("timestamp",O)}E.frames.push(O),k+=10,k+=I}while(k<d);this.trigger("data",E)}}}},Os.prototype=new dg;var cg=Os,aa=t,oa=ml,Mt=Ps,pg=_l.TimestampRolloverStream,Ms,Un,Rs,Wi=188,la=71;Ms=function(){var o=new Uint8Array(Wi),u=0;Ms.prototype.init.call(this),this.push=function(d){var h=0,g=Wi,y;for(u?(y=new Uint8Array(d.byteLength+u),y.set(o.subarray(0,u)),y.set(d,u),u=0):y=d;g<y.byteLength;){if(y[h]===la&&y[g]===la){this.trigger("data",y.subarray(h,g)),h+=Wi,g+=Wi;continue}h++,g++}h<y.byteLength&&(o.set(y.subarray(h),0),u=y.byteLength-h)},this.flush=function(){u===Wi&&o[0]===la&&(this.trigger("data",o),u=0),this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")},this.reset=function(){u=0,this.trigger("reset")}},Ms.prototype=new aa,Un=function(){var o,u,d,h;Un.prototype.init.call(this),h=this,this.packetsWaitingForPmt=[],this.programMapTable=void 0,o=function(g,y){var S=0;y.payloadUnitStartIndicator&&(S+=g[S]+1),y.type==="pat"?u(g.subarray(S),y):d(g.subarray(S),y)},u=function(g,y){y.section_number=g[7],y.last_section_number=g[8],h.pmtPid=(g[10]&31)<<8|g[11],y.pmtPid=h.pmtPid},d=function(g,y){var S,E,k,I;if(g[5]&1){for(h.programMapTable={video:null,audio:null,"timed-metadata":{}},S=(g[1]&15)<<8|g[2],E=3+S-4,k=(g[10]&15)<<8|g[11],I=12+k;I<E;){var O=g[I],j=(g[I+1]&31)<<8|g[I+2];O===Mt.H264_STREAM_TYPE&&h.programMapTable.video===null?h.programMapTable.video=j:O===Mt.ADTS_STREAM_TYPE&&h.programMapTable.audio===null?h.programMapTable.audio=j:O===Mt.METADATA_STREAM_TYPE&&(h.programMapTable["timed-metadata"][j]=O),I+=((g[I+3]&15)<<8|g[I+4])+5}y.programMapTable=h.programMapTable}},this.push=function(g){var y={},S=4;if(y.payloadUnitStartIndicator=!!(g[1]&64),y.pid=g[1]&31,y.pid<<=8,y.pid|=g[2],(g[3]&48)>>>4>1&&(S+=g[S]+1),y.pid===0)y.type="pat",o(g.subarray(S),y),this.trigger("data",y);else if(y.pid===this.pmtPid)for(y.type="pmt",o(g.subarray(S),y),this.trigger("data",y);this.packetsWaitingForPmt.length;)this.processPes_.apply(this,this.packetsWaitingForPmt.shift());else this.programMapTable===void 0?this.packetsWaitingForPmt.push([g,S,y]):this.processPes_(g,S,y)},this.processPes_=function(g,y,S){S.pid===this.programMapTable.video?S.streamType=Mt.H264_STREAM_TYPE:S.pid===this.programMapTable.audio?S.streamType=Mt.ADTS_STREAM_TYPE:S.streamType=this.programMapTable["timed-metadata"][S.pid],S.type="pes",S.data=g.subarray(y),this.trigger("data",S)}},Un.prototype=new aa,Un.STREAM_TYPES={h264:27,adts:15},Rs=function(){var o=this,u=!1,d={data:[],size:0},h={data:[],size:0},g={data:[],size:0},y,S=function(k,I){var O;const j=k[0]<<16|k[1]<<8|k[2];I.data=new Uint8Array,j===1&&(I.packetLength=6+(k[4]<<8|k[5]),I.dataAlignmentIndicator=(k[6]&4)!==0,O=k[7],O&192&&(I.pts=(k[9]&14)<<27|(k[10]&255)<<20|(k[11]&254)<<12|(k[12]&255)<<5|(k[13]&254)>>>3,I.pts*=4,I.pts+=(k[13]&6)>>>1,I.dts=I.pts,O&64&&(I.dts=(k[14]&14)<<27|(k[15]&255)<<20|(k[16]&254)<<12|(k[17]&255)<<5|(k[18]&254)>>>3,I.dts*=4,I.dts+=(k[18]&6)>>>1)),I.data=k.subarray(9+k[8]))},E=function(k,I,O){var j=new Uint8Array(k.size),Q={type:I},V=0,te=0,se=!1,ze;if(!(!k.data.length||k.size<9)){for(Q.trackId=k.data[0].pid,V=0;V<k.data.length;V++)ze=k.data[V],j.set(ze.data,te),te+=ze.data.byteLength;S(j,Q),se=I==="video"||Q.packetLength<=k.size,(O||se)&&(k.size=0,k.data.length=0),se&&o.trigger("data",Q)}};Rs.prototype.init.call(this),this.push=function(k){({pat:function(){},pes:function(){var I,O;switch(k.streamType){case Mt.H264_STREAM_TYPE:I=d,O="video";break;case Mt.ADTS_STREAM_TYPE:I=h,O="audio";break;case Mt.METADATA_STREAM_TYPE:I=g,O="timed-metadata";break;default:return}k.payloadUnitStartIndicator&&E(I,O,!0),I.data.push(k),I.size+=k.data.byteLength},pmt:function(){var I={type:"metadata",tracks:[]};y=k.programMapTable,y.video!==null&&I.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+y.video,codec:"avc",type:"video"}),y.audio!==null&&I.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+y.audio,codec:"adts",type:"audio"}),u=!0,o.trigger("data",I)}})[k.type]()},this.reset=function(){d.size=0,d.data.length=0,h.size=0,h.data.length=0,this.trigger("reset")},this.flushStreams_=function(){E(d,"video"),E(h,"audio"),E(g,"timed-metadata")},this.flush=function(){if(!u&&y){var k={type:"metadata",tracks:[]};y.video!==null&&k.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+y.video,codec:"avc",type:"video"}),y.audio!==null&&k.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+y.audio,codec:"adts",type:"audio"}),o.trigger("data",k)}u=!1,this.flushStreams_(),this.trigger("done")}},Rs.prototype=new aa;var vl={PAT_PID:0,MP2T_PACKET_LENGTH:Wi,TransportPacketStream:Ms,TransportParseStream:Un,ElementaryStream:Rs,TimestampRolloverStream:pg,CaptionStream:oa.CaptionStream,Cea608Stream:oa.Cea608Stream,Cea708Stream:oa.Cea708Stream,MetadataStream:cg};for(var ua in Mt)Mt.hasOwnProperty(ua)&&(vl[ua]=Mt[ua]);var gg=vl,fg=t,mg=T.ONE_SECOND_IN_TS,Us,Sl=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];Us=function(o){var u,d=0;Us.prototype.init.call(this),this.skipWarn_=function(h,g){this.trigger("log",{level:"warn",message:`adts skiping bytes ${h} to ${g} in frame ${d} outside syncword`})},this.push=function(h){var g=0,y,S,E,k,I;if(o||(d=0),h.type==="audio"){u&&u.length?(E=u,u=new Uint8Array(E.byteLength+h.data.byteLength),u.set(E),u.set(h.data,E.byteLength)):u=h.data;for(var O;g+7<u.length;){if(u[g]!==255||(u[g+1]&246)!==240){typeof O!="number"&&(O=g),g++;continue}if(typeof O=="number"&&(this.skipWarn_(O,g),O=null),S=(~u[g+1]&1)*2,y=(u[g+3]&3)<<11|u[g+4]<<3|(u[g+5]&224)>>5,k=((u[g+6]&3)+1)*1024,I=k*mg/Sl[(u[g+2]&60)>>>2],u.byteLength-g<y)break;this.trigger("data",{pts:h.pts+d*I,dts:h.dts+d*I,sampleCount:k,audioobjecttype:(u[g+2]>>>6&3)+1,channelcount:(u[g+2]&1)<<2|(u[g+3]&192)>>>6,samplerate:Sl[(u[g+2]&60)>>>2],samplingfrequencyindex:(u[g+2]&60)>>>2,samplesize:16,data:u.subarray(g+7+S,g+y)}),d++,g+=y}typeof O=="number"&&(this.skipWarn_(O,g),O=null),u=u.subarray(g)}},this.flush=function(){d=0,this.trigger("done")},this.reset=function(){u=void 0,this.trigger("reset")},this.endTimeline=function(){u=void 0,this.trigger("endedtimeline")}},Us.prototype=new fg;var yg=Us,El;El=function(o){var u=o.byteLength,d=0,h=0;this.length=function(){return 8*u},this.bitsAvailable=function(){return 8*u+h},this.loadWord=function(){var g=o.byteLength-u,y=new Uint8Array(4),S=Math.min(4,u);if(S===0)throw new Error("no bytes available");y.set(o.subarray(g,g+S)),d=new DataView(y.buffer).getUint32(0),h=S*8,u-=S},this.skipBits=function(g){var y;h>g?(d<<=g,h-=g):(g-=h,y=Math.floor(g/8),g-=y*8,u-=y,this.loadWord(),d<<=g,h-=g)},this.readBits=function(g){var y=Math.min(h,g),S=d>>>32-y;return h-=y,h>0?d<<=y:u>0&&this.loadWord(),y=g-y,y>0?S<<y|this.readBits(y):S},this.skipLeadingZeros=function(){var g;for(g=0;g<h;++g)if(d&2147483648>>>g)return d<<=g,h-=g,g;return this.loadWord(),g+this.skipLeadingZeros()},this.skipUnsignedExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros())},this.skipExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros())},this.readUnsignedExpGolomb=function(){var g=this.skipLeadingZeros();return this.readBits(g+1)-1},this.readExpGolomb=function(){var g=this.readUnsignedExpGolomb();return 1&g?1+g>>>1:-1*(g>>>1)},this.readBoolean=function(){return this.readBits(1)===1},this.readUnsignedByte=function(){return this.readBits(8)},this.loadWord()};var _g=El,wl=t,bg=_g,Ns,Nn,kl;Nn=function(){var o=0,u,d;Nn.prototype.init.call(this),this.push=function(h){var g;d?(g=new Uint8Array(d.byteLength+h.data.byteLength),g.set(d),g.set(h.data,d.byteLength),d=g):d=h.data;for(var y=d.byteLength;o<y-3;o++)if(d[o+2]===1){u=o+5;break}for(;u<y;)switch(d[u]){case 0:if(d[u-1]!==0){u+=2;break}else if(d[u-2]!==0){u++;break}o+3!==u-2&&this.trigger("data",d.subarray(o+3,u-2));do u++;while(d[u]!==1&&u<y);o=u-2,u+=3;break;case 1:if(d[u-1]!==0||d[u-2]!==0){u+=3;break}this.trigger("data",d.subarray(o+3,u-2)),o=u-2,u+=3;break;default:u+=3;break}d=d.subarray(o),u-=o,o=0},this.reset=function(){d=null,o=0,this.trigger("reset")},this.flush=function(){d&&d.byteLength>3&&this.trigger("data",d.subarray(o+3)),d=null,o=0,this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")}},Nn.prototype=new wl,kl={100:!0,110:!0,122:!0,244:!0,44:!0,83:!0,86:!0,118:!0,128:!0,138:!0,139:!0,134:!0},Ns=function(){var o=new Nn,u,d,h,g,y,S,E;Ns.prototype.init.call(this),u=this,this.push=function(k){k.type==="video"&&(d=k.trackId,h=k.pts,g=k.dts,o.push(k))},o.on("data",function(k){var I={trackId:d,pts:h,dts:g,data:k,nalUnitTypeCode:k[0]&31};switch(I.nalUnitTypeCode){case 5:I.nalUnitType="slice_layer_without_partitioning_rbsp_idr";break;case 6:I.nalUnitType="sei_rbsp",I.escapedRBSP=y(k.subarray(1));break;case 7:I.nalUnitType="seq_parameter_set_rbsp",I.escapedRBSP=y(k.subarray(1)),I.config=S(I.escapedRBSP);break;case 8:I.nalUnitType="pic_parameter_set_rbsp";break;case 9:I.nalUnitType="access_unit_delimiter_rbsp";break}u.trigger("data",I)}),o.on("done",function(){u.trigger("done")}),o.on("partialdone",function(){u.trigger("partialdone")}),o.on("reset",function(){u.trigger("reset")}),o.on("endedtimeline",function(){u.trigger("endedtimeline")}),this.flush=function(){o.flush()},this.partialFlush=function(){o.partialFlush()},this.reset=function(){o.reset()},this.endTimeline=function(){o.endTimeline()},E=function(k,I){var O=8,j=8,Q,V;for(Q=0;Q<k;Q++)j!==0&&(V=I.readExpGolomb(),j=(O+V+256)%256),O=j===0?O:j},y=function(k){for(var I=k.byteLength,O=[],j=1,Q,V;j<I-2;)k[j]===0&&k[j+1]===0&&k[j+2]===3?(O.push(j+2),j+=2):j++;if(O.length===0)return k;Q=I-O.length,V=new Uint8Array(Q);var te=0;for(j=0;j<Q;te++,j++)te===O[0]&&(te++,O.shift()),V[j]=k[te];return V},S=function(k){var I=0,O=0,j=0,Q=0,V,te,se,ze,nt,qt,zn,Ks,Ys,Pi,Wn,Ie=[1,1],tu,Li;if(V=new bg(k),te=V.readUnsignedByte(),ze=V.readUnsignedByte(),se=V.readUnsignedByte(),V.skipUnsignedExpGolomb(),kl[te]&&(nt=V.readUnsignedExpGolomb(),nt===3&&V.skipBits(1),V.skipUnsignedExpGolomb(),V.skipUnsignedExpGolomb(),V.skipBits(1),V.readBoolean()))for(Wn=nt!==3?8:12,Li=0;Li<Wn;Li++)V.readBoolean()&&(Li<6?E(16,V):E(64,V));if(V.skipUnsignedExpGolomb(),qt=V.readUnsignedExpGolomb(),qt===0)V.readUnsignedExpGolomb();else if(qt===1)for(V.skipBits(1),V.skipExpGolomb(),V.skipExpGolomb(),zn=V.readUnsignedExpGolomb(),Li=0;Li<zn;Li++)V.skipExpGolomb();if(V.skipUnsignedExpGolomb(),V.skipBits(1),Ks=V.readUnsignedExpGolomb(),Ys=V.readUnsignedExpGolomb(),Pi=V.readBits(1),Pi===0&&V.skipBits(1),V.skipBits(1),V.readBoolean()&&(I=V.readUnsignedExpGolomb(),O=V.readUnsignedExpGolomb(),j=V.readUnsignedExpGolomb(),Q=V.readUnsignedExpGolomb()),V.readBoolean()&&V.readBoolean()){switch(tu=V.readUnsignedByte(),tu){case 1:Ie=[1,1];break;case 2:Ie=[12,11];break;case 3:Ie=[10,11];break;case 4:Ie=[16,11];break;case 5:Ie=[40,33];break;case 6:Ie=[24,11];break;case 7:Ie=[20,11];break;case 8:Ie=[32,11];break;case 9:Ie=[80,33];break;case 10:Ie=[18,11];break;case 11:Ie=[15,11];break;case 12:Ie=[64,33];break;case 13:Ie=[160,99];break;case 14:Ie=[4,3];break;case 15:Ie=[3,2];break;case 16:Ie=[2,1];break;case 255:{Ie=[V.readUnsignedByte()<<8|V.readUnsignedByte(),V.readUnsignedByte()<<8|V.readUnsignedByte()];break}}Ie&&Ie[0]/Ie[1]}return{profileIdc:te,levelIdc:se,profileCompatibility:ze,width:(Ks+1)*16-I*2-O*2,height:(2-Pi)*(Ys+1)*16-j*2-Q*2,sarRatio:Ie}}},Ns.prototype=new wl;var Tg={H264Stream:Ns,NalByteStream:Nn},vg=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],Cl=function(o,u){var d=o[u+6]<<21|o[u+7]<<14|o[u+8]<<7|o[u+9],h=o[u+5],g=(h&16)>>4;return d=d>=0?d:0,g?d+20:d+10},Il=function(o,u){return o.length-u<10||o[u]!==73||o[u+1]!==68||o[u+2]!==51?u:(u+=Cl(o,u),Il(o,u))},Sg=function(o){var u=Il(o,0);return o.length>=u+2&&(o[u]&255)===255&&(o[u+1]&240)===240&&(o[u+1]&22)===16},xl=function(o){return o[0]<<21|o[1]<<14|o[2]<<7|o[3]},Eg=function(o,u,d){var h,g="";for(h=u;h<d;h++)g+="%"+("00"+o[h].toString(16)).slice(-2);return g},wg=function(o,u,d){return unescape(Eg(o,u,d))},kg=function(o,u){var d=(o[u+5]&224)>>5,h=o[u+4]<<3,g=o[u+3]&6144;return g|h|d},Cg=function(o,u){return o[u]===73&&o[u+1]===68&&o[u+2]===51?"timed-metadata":o[u]&!0&&(o[u+1]&240)===240?"audio":null},Ig=function(o){for(var u=0;u+5<o.length;){if(o[u]!==255||(o[u+1]&246)!==240){u++;continue}return vg[(o[u+2]&60)>>>2]}return null},xg=function(o){var u,d,h,g;u=10,o[5]&64&&(u+=4,u+=xl(o.subarray(10,14)));do{if(d=xl(o.subarray(u+4,u+8)),d<1)return null;if(g=String.fromCharCode(o[u],o[u+1],o[u+2],o[u+3]),g==="PRIV"){h=o.subarray(u+10,u+d+10);for(var y=0;y<h.byteLength;y++)if(h[y]===0){var S=wg(h,0,y);if(S==="com.apple.streaming.transportStreamTimestamp"){var E=h.subarray(y+1),k=(E[3]&1)<<30|E[4]<<22|E[5]<<14|E[6]<<6|E[7]>>>2;return k*=4,k+=E[7]&3,k}break}}u+=10,u+=d}while(u<o.byteLength);return null},da={isLikelyAacData:Sg,parseId3TagSize:Cl,parseAdtsSize:kg,parseType:Cg,parseSampleRate:Ig,parseAacTimestamp:xg},Ag=t,Al=da,Bs;Bs=function(){var o=new Uint8Array,u=0;Bs.prototype.init.call(this),this.setTimestamp=function(d){u=d},this.push=function(d){var h=0,g=0,y,S,E,k;for(o.length?(k=o.length,o=new Uint8Array(d.byteLength+k),o.set(o.subarray(0,k)),o.set(d,k)):o=d;o.length-g>=3;){if(o[g]===73&&o[g+1]===68&&o[g+2]===51){if(o.length-g<10||(h=Al.parseId3TagSize(o,g),g+h>o.length))break;S={type:"timed-metadata",data:o.subarray(g,g+h)},this.trigger("data",S),g+=h;continue}else if((o[g]&255)===255&&(o[g+1]&240)===240){if(o.length-g<7||(h=Al.parseAdtsSize(o,g),g+h>o.length))break;E={type:"audio",data:o.subarray(g,g+h),pts:u,dts:u},this.trigger("data",E),g+=h;continue}g++}y=o.length-g,y>0?o=o.subarray(g):o=new Uint8Array},this.reset=function(){o=new Uint8Array,this.trigger("reset")},this.endTimeline=function(){o=new Uint8Array,this.trigger("endedtimeline")}},Bs.prototype=new Ag;var Pg=Bs,Lg=["audioobjecttype","channelcount","samplerate","samplingfrequencyindex","samplesize"],Dg=Lg,Og=["width","height","profileIdc","levelIdc","profileCompatibility","sarRatio"],Mg=Og,Fs=t,Bn=Hi,Fn=ki,js=Te,Rt=Xp,ti=gg,$s=T,Pl=yg,Rg=Tg.H264Stream,Ug=Pg,Ng=da.isLikelyAacData,Bg=T.ONE_SECOND_IN_TS,ha=Dg,ca=Mg,jn,Gi,qs,xi,Fg=function(o,u){u.stream=o,this.trigger("log",u)},Ll=function(o,u){for(var d=Object.keys(u),h=0;h<d.length;h++){var g=d[h];g==="headOfPipeline"||!u[g].on||u[g].on("log",Fg.bind(o,g))}},Dl=function(o,u){var d;if(o.length!==u.length)return!1;for(d=0;d<o.length;d++)if(o[d]!==u[d])return!1;return!0},pa=function(o,u,d,h,g,y){var S=d-u,E=h-u,k=g-d;return{start:{dts:o,pts:o+S},end:{dts:o+E,pts:o+k},prependedContentDuration:y,baseMediaDecodeTime:o}};Gi=function(o,u){var d=[],h,g=0,y=0,S=1/0;u=u||{},h=u.firstSequenceNumber||0,Gi.prototype.init.call(this),this.push=function(E){Rt.collectDtsInfo(o,E),o&&ha.forEach(function(k){o[k]=E[k]}),d.push(E)},this.setEarliestDts=function(E){g=E},this.setVideoBaseMediaDecodeTime=function(E){S=E},this.setAudioAppendStart=function(E){y=E},this.flush=function(){var E,k,I,O,j,Q,V;if(d.length===0){this.trigger("done","AudioSegmentStream");return}E=js.trimAdtsFramesByEarliestDts(d,o,g),o.baseMediaDecodeTime=Rt.calculateTrackBaseMediaDecodeTime(o,u.keepOriginalTimestamps),V=js.prefixWithSilence(o,E,y,S),o.samples=js.generateSampleTable(E),I=Bn.mdat(js.concatenateFrameData(E)),d=[],k=Bn.moof(h,[o]),O=new Uint8Array(k.byteLength+I.byteLength),h++,O.set(k),O.set(I,k.byteLength),Rt.clearDtsInfo(o),j=Math.ceil(Bg*1024/o.samplerate),E.length&&(Q=E.length*j,this.trigger("segmentTimingInfo",pa($s.audioTsToVideoTs(o.baseMediaDecodeTime,o.samplerate),E[0].dts,E[0].pts,E[0].dts+Q,E[0].pts+Q,V||0)),this.trigger("timingInfo",{start:E[0].pts,end:E[0].pts+Q})),this.trigger("data",{track:o,boxes:O}),this.trigger("done","AudioSegmentStream")},this.reset=function(){Rt.clearDtsInfo(o),d=[],this.trigger("reset")}},Gi.prototype=new Fs,jn=function(o,u){var d,h=[],g=[],y,S;u=u||{},d=u.firstSequenceNumber||0,jn.prototype.init.call(this),delete o.minPTS,this.gopCache_=[],this.push=function(E){Rt.collectDtsInfo(o,E),E.nalUnitType==="seq_parameter_set_rbsp"&&!y&&(y=E.config,o.sps=[E.data],ca.forEach(function(k){o[k]=y[k]},this)),E.nalUnitType==="pic_parameter_set_rbsp"&&!S&&(S=E.data,o.pps=[E.data]),h.push(E)},this.flush=function(){for(var E,k,I,O,j,Q,V=0,te,se;h.length&&h[0].nalUnitType!=="access_unit_delimiter_rbsp";)h.shift();if(h.length===0){this.resetStream_(),this.trigger("done","VideoSegmentStream");return}if(E=Fn.groupNalsIntoFrames(h),I=Fn.groupFramesIntoGops(E),I[0][0].keyFrame||(k=this.getGopForFusion_(h[0],o),k?(V=k.duration,I.unshift(k),I.byteLength+=k.byteLength,I.nalCount+=k.nalCount,I.pts=k.pts,I.dts=k.dts,I.duration+=k.duration):I=Fn.extendFirstKeyFrame(I)),g.length){var ze;if(u.alignGopsAtEnd?ze=this.alignGopsAtEnd_(I):ze=this.alignGopsAtStart_(I),!ze){this.gopCache_.unshift({gop:I.pop(),pps:o.pps,sps:o.sps}),this.gopCache_.length=Math.min(6,this.gopCache_.length),h=[],this.resetStream_(),this.trigger("done","VideoSegmentStream");return}Rt.clearDtsInfo(o),I=ze}Rt.collectDtsInfo(o,I),o.samples=Fn.generateSampleTable(I),j=Bn.mdat(Fn.concatenateNalData(I)),o.baseMediaDecodeTime=Rt.calculateTrackBaseMediaDecodeTime(o,u.keepOriginalTimestamps),this.trigger("processedGopsInfo",I.map(function(nt){return{pts:nt.pts,dts:nt.dts,byteLength:nt.byteLength}})),te=I[0],se=I[I.length-1],this.trigger("segmentTimingInfo",pa(o.baseMediaDecodeTime,te.dts,te.pts,se.dts+se.duration,se.pts+se.duration,V)),this.trigger("timingInfo",{start:I[0].pts,end:I[I.length-1].pts+I[I.length-1].duration}),this.gopCache_.unshift({gop:I.pop(),pps:o.pps,sps:o.sps}),this.gopCache_.length=Math.min(6,this.gopCache_.length),h=[],this.trigger("baseMediaDecodeTime",o.baseMediaDecodeTime),this.trigger("timelineStartInfo",o.timelineStartInfo),O=Bn.moof(d,[o]),Q=new Uint8Array(O.byteLength+j.byteLength),d++,Q.set(O),Q.set(j,O.byteLength),this.trigger("data",{track:o,boxes:Q}),this.resetStream_(),this.trigger("done","VideoSegmentStream")},this.reset=function(){this.resetStream_(),h=[],this.gopCache_.length=0,g.length=0,this.trigger("reset")},this.resetStream_=function(){Rt.clearDtsInfo(o),y=void 0,S=void 0},this.getGopForFusion_=function(E){var k=45e3,I=1e4,O=1/0,j,Q,V,te,se;for(se=0;se<this.gopCache_.length;se++)te=this.gopCache_[se],V=te.gop,!(!(o.pps&&Dl(o.pps[0],te.pps[0]))||!(o.sps&&Dl(o.sps[0],te.sps[0])))&&(V.dts<o.timelineStartInfo.dts||(j=E.dts-V.dts-V.duration,j>=-I&&j<=k&&(!Q||O>j)&&(Q=te,O=j)));return Q?Q.gop:null},this.alignGopsAtStart_=function(E){var k,I,O,j,Q,V,te,se;for(Q=E.byteLength,V=E.nalCount,te=E.duration,k=I=0;k<g.length&&I<E.length&&(O=g[k],j=E[I],O.pts!==j.pts);){if(j.pts>O.pts){k++;continue}I++,Q-=j.byteLength,V-=j.nalCount,te-=j.duration}return I===0?E:I===E.length?null:(se=E.slice(I),se.byteLength=Q,se.duration=te,se.nalCount=V,se.pts=se[0].pts,se.dts=se[0].dts,se)},this.alignGopsAtEnd_=function(E){var k,I,O,j,Q,V;for(k=g.length-1,I=E.length-1,Q=null,V=!1;k>=0&&I>=0;){if(O=g[k],j=E[I],O.pts===j.pts){V=!0;break}if(O.pts>j.pts){k--;continue}k===g.length-1&&(Q=I),I--}if(!V&&Q===null)return null;var te;if(V?te=I:te=Q,te===0)return E;var se=E.slice(te),ze=se.reduce(function(nt,qt){return nt.byteLength+=qt.byteLength,nt.duration+=qt.duration,nt.nalCount+=qt.nalCount,nt},{byteLength:0,duration:0,nalCount:0});return se.byteLength=ze.byteLength,se.duration=ze.duration,se.nalCount=ze.nalCount,se.pts=se[0].pts,se.dts=se[0].dts,se},this.alignGopsWith=function(E){g=E}},jn.prototype=new Fs,xi=function(o,u){this.numberOfTracks=0,this.metadataStream=u,o=o||{},typeof o.remux<"u"?this.remuxTracks=!!o.remux:this.remuxTracks=!0,typeof o.keepOriginalTimestamps=="boolean"?this.keepOriginalTimestamps=o.keepOriginalTimestamps:this.keepOriginalTimestamps=!1,this.pendingTracks=[],this.videoTrack=null,this.pendingBoxes=[],this.pendingCaptions=[],this.pendingMetadata=[],this.pendingBytes=0,this.emittedTracks=0,xi.prototype.init.call(this),this.push=function(d){if(d.content||d.text)return this.pendingCaptions.push(d);if(d.frames)return this.pendingMetadata.push(d);this.pendingTracks.push(d.track),this.pendingBytes+=d.boxes.byteLength,d.track.type==="video"&&(this.videoTrack=d.track,this.pendingBoxes.push(d.boxes)),d.track.type==="audio"&&(this.audioTrack=d.track,this.pendingBoxes.unshift(d.boxes))}},xi.prototype=new Fs,xi.prototype.flush=function(o){var u=0,d={captions:[],captionStreams:{},metadata:[],info:{}},h,g,y,S=0,E;if(this.pendingTracks.length<this.numberOfTracks){if(o!=="VideoSegmentStream"&&o!=="AudioSegmentStream"||this.remuxTracks)return;if(this.pendingTracks.length===0){this.emittedTracks++,this.emittedTracks>=this.numberOfTracks&&(this.trigger("done"),this.emittedTracks=0);return}}if(this.videoTrack?(S=this.videoTrack.timelineStartInfo.pts,ca.forEach(function(k){d.info[k]=this.videoTrack[k]},this)):this.audioTrack&&(S=this.audioTrack.timelineStartInfo.pts,ha.forEach(function(k){d.info[k]=this.audioTrack[k]},this)),this.videoTrack||this.audioTrack){for(this.pendingTracks.length===1?d.type=this.pendingTracks[0].type:d.type="combined",this.emittedTracks+=this.pendingTracks.length,y=Bn.initSegment(this.pendingTracks),d.initSegment=new Uint8Array(y.byteLength),d.initSegment.set(y),d.data=new Uint8Array(this.pendingBytes),E=0;E<this.pendingBoxes.length;E++)d.data.set(this.pendingBoxes[E],u),u+=this.pendingBoxes[E].byteLength;for(E=0;E<this.pendingCaptions.length;E++)h=this.pendingCaptions[E],h.startTime=$s.metadataTsToSeconds(h.startPts,S,this.keepOriginalTimestamps),h.endTime=$s.metadataTsToSeconds(h.endPts,S,this.keepOriginalTimestamps),d.captionStreams[h.stream]=!0,d.captions.push(h);for(E=0;E<this.pendingMetadata.length;E++)g=this.pendingMetadata[E],g.cueTime=$s.metadataTsToSeconds(g.pts,S,this.keepOriginalTimestamps),d.metadata.push(g);for(d.metadata.dispatchType=this.metadataStream.dispatchType,this.pendingTracks.length=0,this.videoTrack=null,this.pendingBoxes.length=0,this.pendingCaptions.length=0,this.pendingBytes=0,this.pendingMetadata.length=0,this.trigger("data",d),E=0;E<d.captions.length;E++)h=d.captions[E],this.trigger("caption",h);for(E=0;E<d.metadata.length;E++)g=d.metadata[E],this.trigger("id3Frame",g)}this.emittedTracks>=this.numberOfTracks&&(this.trigger("done"),this.emittedTracks=0)},xi.prototype.setRemux=function(o){this.remuxTracks=o},qs=function(o){var u=this,d=!0,h,g;qs.prototype.init.call(this),o=o||{},this.baseMediaDecodeTime=o.baseMediaDecodeTime||0,this.transmuxPipeline_={},this.setupAacPipeline=function(){var y={};this.transmuxPipeline_=y,y.type="aac",y.metadataStream=new ti.MetadataStream,y.aacStream=new Ug,y.audioTimestampRolloverStream=new ti.TimestampRolloverStream("audio"),y.timedMetadataTimestampRolloverStream=new ti.TimestampRolloverStream("timed-metadata"),y.adtsStream=new Pl,y.coalesceStream=new xi(o,y.metadataStream),y.headOfPipeline=y.aacStream,y.aacStream.pipe(y.audioTimestampRolloverStream).pipe(y.adtsStream),y.aacStream.pipe(y.timedMetadataTimestampRolloverStream).pipe(y.metadataStream).pipe(y.coalesceStream),y.metadataStream.on("timestamp",function(S){y.aacStream.setTimestamp(S.timeStamp)}),y.aacStream.on("data",function(S){S.type!=="timed-metadata"&&S.type!=="audio"||y.audioSegmentStream||(g=g||{timelineStartInfo:{baseMediaDecodeTime:u.baseMediaDecodeTime},codec:"adts",type:"audio"},y.coalesceStream.numberOfTracks++,y.audioSegmentStream=new Gi(g,o),y.audioSegmentStream.on("log",u.getLogTrigger_("audioSegmentStream")),y.audioSegmentStream.on("timingInfo",u.trigger.bind(u,"audioTimingInfo")),y.adtsStream.pipe(y.audioSegmentStream).pipe(y.coalesceStream),u.trigger("trackinfo",{hasAudio:!!g,hasVideo:!!h}))}),y.coalesceStream.on("data",this.trigger.bind(this,"data")),y.coalesceStream.on("done",this.trigger.bind(this,"done")),Ll(this,y)},this.setupTsPipeline=function(){var y={};this.transmuxPipeline_=y,y.type="ts",y.metadataStream=new ti.MetadataStream,y.packetStream=new ti.TransportPacketStream,y.parseStream=new ti.TransportParseStream,y.elementaryStream=new ti.ElementaryStream,y.timestampRolloverStream=new ti.TimestampRolloverStream,y.adtsStream=new Pl,y.h264Stream=new Rg,y.captionStream=new ti.CaptionStream(o),y.coalesceStream=new xi(o,y.metadataStream),y.headOfPipeline=y.packetStream,y.packetStream.pipe(y.parseStream).pipe(y.elementaryStream).pipe(y.timestampRolloverStream),y.timestampRolloverStream.pipe(y.h264Stream),y.timestampRolloverStream.pipe(y.adtsStream),y.timestampRolloverStream.pipe(y.metadataStream).pipe(y.coalesceStream),y.h264Stream.pipe(y.captionStream).pipe(y.coalesceStream),y.elementaryStream.on("data",function(S){var E;if(S.type==="metadata"){for(E=S.tracks.length;E--;)!h&&S.tracks[E].type==="video"?(h=S.tracks[E],h.timelineStartInfo.baseMediaDecodeTime=u.baseMediaDecodeTime):!g&&S.tracks[E].type==="audio"&&(g=S.tracks[E],g.timelineStartInfo.baseMediaDecodeTime=u.baseMediaDecodeTime);h&&!y.videoSegmentStream&&(y.coalesceStream.numberOfTracks++,y.videoSegmentStream=new jn(h,o),y.videoSegmentStream.on("log",u.getLogTrigger_("videoSegmentStream")),y.videoSegmentStream.on("timelineStartInfo",function(k){g&&!o.keepOriginalTimestamps&&(g.timelineStartInfo=k,y.audioSegmentStream.setEarliestDts(k.dts-u.baseMediaDecodeTime))}),y.videoSegmentStream.on("processedGopsInfo",u.trigger.bind(u,"gopInfo")),y.videoSegmentStream.on("segmentTimingInfo",u.trigger.bind(u,"videoSegmentTimingInfo")),y.videoSegmentStream.on("baseMediaDecodeTime",function(k){g&&y.audioSegmentStream.setVideoBaseMediaDecodeTime(k)}),y.videoSegmentStream.on("timingInfo",u.trigger.bind(u,"videoTimingInfo")),y.h264Stream.pipe(y.videoSegmentStream).pipe(y.coalesceStream)),g&&!y.audioSegmentStream&&(y.coalesceStream.numberOfTracks++,y.audioSegmentStream=new Gi(g,o),y.audioSegmentStream.on("log",u.getLogTrigger_("audioSegmentStream")),y.audioSegmentStream.on("timingInfo",u.trigger.bind(u,"audioTimingInfo")),y.audioSegmentStream.on("segmentTimingInfo",u.trigger.bind(u,"audioSegmentTimingInfo")),y.adtsStream.pipe(y.audioSegmentStream).pipe(y.coalesceStream)),u.trigger("trackinfo",{hasAudio:!!g,hasVideo:!!h})}}),y.coalesceStream.on("data",this.trigger.bind(this,"data")),y.coalesceStream.on("id3Frame",function(S){S.dispatchType=y.metadataStream.dispatchType,u.trigger("id3Frame",S)}),y.coalesceStream.on("caption",this.trigger.bind(this,"caption")),y.coalesceStream.on("done",this.trigger.bind(this,"done")),Ll(this,y)},this.setBaseMediaDecodeTime=function(y){var S=this.transmuxPipeline_;o.keepOriginalTimestamps||(this.baseMediaDecodeTime=y),g&&(g.timelineStartInfo.dts=void 0,g.timelineStartInfo.pts=void 0,Rt.clearDtsInfo(g),S.audioTimestampRolloverStream&&S.audioTimestampRolloverStream.discontinuity()),h&&(S.videoSegmentStream&&(S.videoSegmentStream.gopCache_=[]),h.timelineStartInfo.dts=void 0,h.timelineStartInfo.pts=void 0,Rt.clearDtsInfo(h),S.captionStream.reset()),S.timestampRolloverStream&&S.timestampRolloverStream.discontinuity()},this.setAudioAppendStart=function(y){g&&this.transmuxPipeline_.audioSegmentStream.setAudioAppendStart(y)},this.setRemux=function(y){var S=this.transmuxPipeline_;o.remux=y,S&&S.coalesceStream&&S.coalesceStream.setRemux(y)},this.alignGopsWith=function(y){h&&this.transmuxPipeline_.videoSegmentStream&&this.transmuxPipeline_.videoSegmentStream.alignGopsWith(y)},this.getLogTrigger_=function(y){var S=this;return function(E){E.stream=y,S.trigger("log",E)}},this.push=function(y){if(d){var S=Ng(y);S&&this.transmuxPipeline_.type!=="aac"?this.setupAacPipeline():!S&&this.transmuxPipeline_.type!=="ts"&&this.setupTsPipeline(),d=!1}this.transmuxPipeline_.headOfPipeline.push(y)},this.flush=function(){d=!0,this.transmuxPipeline_.headOfPipeline.flush()},this.endTimeline=function(){this.transmuxPipeline_.headOfPipeline.endTimeline()},this.reset=function(){this.transmuxPipeline_.headOfPipeline&&this.transmuxPipeline_.headOfPipeline.reset()},this.resetCaptions=function(){this.transmuxPipeline_.captionStream&&this.transmuxPipeline_.captionStream.reset()}},qs.prototype=new Fs;var jg={Transmuxer:qs,VideoSegmentStream:jn,AudioSegmentStream:Gi,AUDIO_PROPERTIES:ha,VIDEO_PROPERTIES:ca,generateSegmentTimingInfo:pa},$g=function(o){return o>>>0},qg=function(o){return("00"+o.toString(16)).slice(-2)},Vs={toUnsigned:$g,toHexString:qg},Vg=function(o){var u="";return u+=String.fromCharCode(o[0]),u+=String.fromCharCode(o[1]),u+=String.fromCharCode(o[2]),u+=String.fromCharCode(o[3]),u},ga=Vg,Hg=Vs.toUnsigned,zg=ga,Ol=function(o,u){var d=[],h,g,y,S,E;if(!u.length)return null;for(h=0;h<o.byteLength;)g=Hg(o[h]<<24|o[h+1]<<16|o[h+2]<<8|o[h+3]),y=zg(o.subarray(h+4,h+8)),S=g>1?h+g:o.byteLength,y===u[0]&&(u.length===1?d.push(o.subarray(h+8,S)):(E=Ol(o.subarray(h+8,S),u.slice(1)),E.length&&(d=d.concat(E)))),h=S;return d},Hs=Ol,Wg=Vs.toUnsigned,Gg=r.getUint64,Xg=function(o){var u={version:o[0],flags:new Uint8Array(o.subarray(1,4))};return u.version===1?u.baseMediaDecodeTime=Gg(o.subarray(4)):u.baseMediaDecodeTime=Wg(o[4]<<24|o[5]<<16|o[6]<<8|o[7]),u},fa=Xg,Kg=function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),d={version:o[0],flags:new Uint8Array(o.subarray(1,4)),trackId:u.getUint32(4)},h=d.flags[2]&1,g=d.flags[2]&2,y=d.flags[2]&8,S=d.flags[2]&16,E=d.flags[2]&32,k=d.flags[0]&65536,I=d.flags[0]&131072,O;return O=8,h&&(O+=4,d.baseDataOffset=u.getUint32(12),O+=4),g&&(d.sampleDescriptionIndex=u.getUint32(O),O+=4),y&&(d.defaultSampleDuration=u.getUint32(O),O+=4),S&&(d.defaultSampleSize=u.getUint32(O),O+=4),E&&(d.defaultSampleFlags=u.getUint32(O)),k&&(d.durationIsEmpty=!0),!h&&I&&(d.baseDataOffsetIsMoof=!0),d},ma=Kg,Ml=r.getUint64,Yg=function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),d={version:o[0],flags:new Uint8Array(o.subarray(1,4)),references:[],referenceId:u.getUint32(4),timescale:u.getUint32(8)},h=12;d.version===0?(d.earliestPresentationTime=u.getUint32(h),d.firstOffset=u.getUint32(h+4),h+=8):(d.earliestPresentationTime=Ml(o.subarray(h)),d.firstOffset=Ml(o.subarray(h+8)),h+=16),h+=2;var g=u.getUint16(h);for(h+=2;g>0;h+=12,g--)d.references.push({referenceType:(o[h]&128)>>>7,referencedSize:u.getUint32(h)&2147483647,subsegmentDuration:u.getUint32(h+4),startsWithSap:!!(o[h+8]&128),sapType:(o[h+8]&112)>>>4,sapDeltaTime:u.getUint32(h+8)&268435455});return d},Qg=Yg,Jg=function(o){return{isLeading:(o[0]&12)>>>2,dependsOn:o[0]&3,isDependedOn:(o[1]&192)>>>6,hasRedundancy:(o[1]&48)>>>4,paddingValue:(o[1]&14)>>>1,isNonSyncSample:o[1]&1,degradationPriority:o[2]<<8|o[3]}},Zg=Jg,Rl=Zg,ef=function(o){var u={version:o[0],flags:new Uint8Array(o.subarray(1,4)),samples:[]},d=new DataView(o.buffer,o.byteOffset,o.byteLength),h=u.flags[2]&1,g=u.flags[2]&4,y=u.flags[1]&1,S=u.flags[1]&2,E=u.flags[1]&4,k=u.flags[1]&8,I=d.getUint32(4),O=8,j;for(h&&(u.dataOffset=d.getInt32(O),O+=4),g&&I&&(j={flags:Rl(o.subarray(O,O+4))},O+=4,y&&(j.duration=d.getUint32(O),O+=4),S&&(j.size=d.getUint32(O),O+=4),k&&(u.version===1?j.compositionTimeOffset=d.getInt32(O):j.compositionTimeOffset=d.getUint32(O),O+=4),u.samples.push(j),I--);I--;)j={},y&&(j.duration=d.getUint32(O),O+=4),S&&(j.size=d.getUint32(O),O+=4),E&&(j.flags=Rl(o.subarray(O,O+4)),O+=4),k&&(u.version===1?j.compositionTimeOffset=d.getInt32(O):j.compositionTimeOffset=d.getUint32(O),O+=4),u.samples.push(j);return u},Ul=ef,tf=r,Nl=tf.getUint64,Qe,ya,kt=function(o){return new Date(o*1e3-20828448e5)},$n=ga,nf=Hs,sf=function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),d=[],h,g;for(h=0;h+4<o.length;h+=g){if(g=u.getUint32(h),h+=4,g<=0){d.push("<span style='color:red;'>MALFORMED DATA</span>");continue}switch(o[h]&31){case 1:d.push("slice_layer_without_partitioning_rbsp");break;case 5:d.push("slice_layer_without_partitioning_rbsp_idr");break;case 6:d.push("sei_rbsp");break;case 7:d.push("seq_parameter_set_rbsp");break;case 8:d.push("pic_parameter_set_rbsp");break;case 9:d.push("access_unit_delimiter_rbsp");break;default:d.push("UNKNOWN NAL - "+o[h]&31);break}}return d},ci={avc1:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength);return{dataReferenceIndex:u.getUint16(6),width:u.getUint16(24),height:u.getUint16(26),horizresolution:u.getUint16(28)+u.getUint16(30)/16,vertresolution:u.getUint16(32)+u.getUint16(34)/16,frameCount:u.getUint16(40),depth:u.getUint16(74),config:Qe(o.subarray(78,o.byteLength))}},avcC:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),d={configurationVersion:o[0],avcProfileIndication:o[1],profileCompatibility:o[2],avcLevelIndication:o[3],lengthSizeMinusOne:o[4]&3,sps:[],pps:[]},h=o[5]&31,g,y,S,E;for(S=6,E=0;E<h;E++)y=u.getUint16(S),S+=2,d.sps.push(new Uint8Array(o.subarray(S,S+y))),S+=y;for(g=o[S],S++,E=0;E<g;E++)y=u.getUint16(S),S+=2,d.pps.push(new Uint8Array(o.subarray(S,S+y))),S+=y;return d},btrt:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength);return{bufferSizeDB:u.getUint32(0),maxBitrate:u.getUint32(4),avgBitrate:u.getUint32(8)}},edts:function(o){return{boxes:Qe(o)}},elst:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),d={version:u.getUint8(0),flags:new Uint8Array(o.subarray(1,4)),edits:[]},h=u.getUint32(4),g;for(g=8;h;h--)d.version===0?(d.edits.push({segmentDuration:u.getUint32(g),mediaTime:u.getInt32(g+4),mediaRate:u.getUint16(g+8)+u.getUint16(g+10)/(256*256)}),g+=12):(d.edits.push({segmentDuration:Nl(o.subarray(g)),mediaTime:Nl(o.subarray(g+8)),mediaRate:u.getUint16(g+16)+u.getUint16(g+18)/(256*256)}),g+=20);return d},esds:function(o){return{version:o[0],flags:new Uint8Array(o.subarray(1,4)),esId:o[6]<<8|o[7],streamPriority:o[8]&31,decoderConfig:{objectProfileIndication:o[11],streamType:o[12]>>>2&63,bufferSize:o[13]<<16|o[14]<<8|o[15],maxBitrate:o[16]<<24|o[17]<<16|o[18]<<8|o[19],avgBitrate:o[20]<<24|o[21]<<16|o[22]<<8|o[23],decoderConfigDescriptor:{tag:o[24],length:o[25],audioObjectType:o[26]>>>3&31,samplingFrequencyIndex:(o[26]&7)<<1|o[27]>>>7&1,channelConfiguration:o[27]>>>3&15}}}},ftyp:function(o){for(var u=new DataView(o.buffer,o.byteOffset,o.byteLength),d={majorBrand:$n(o.subarray(0,4)),minorVersion:u.getUint32(4),compatibleBrands:[]},h=8;h<o.byteLength;)d.compatibleBrands.push($n(o.subarray(h,h+4))),h+=4;return d},dinf:function(o){return{boxes:Qe(o)}},dref:function(o){return{version:o[0],flags:new Uint8Array(o.subarray(1,4)),dataReferences:Qe(o.subarray(8))}},hdlr:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),d={version:u.getUint8(0),flags:new Uint8Array(o.subarray(1,4)),handlerType:$n(o.subarray(8,12)),name:""},h=8;for(h=24;h<o.byteLength;h++){if(o[h]===0){h++;break}d.name+=String.fromCharCode(o[h])}return d.name=decodeURIComponent(escape(d.name)),d},mdat:function(o){return{byteLength:o.byteLength,nals:sf(o)}},mdhd:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),d=4,h,g={version:u.getUint8(0),flags:new Uint8Array(o.subarray(1,4)),language:""};return g.version===1?(d+=4,g.creationTime=kt(u.getUint32(d)),d+=8,g.modificationTime=kt(u.getUint32(d)),d+=4,g.timescale=u.getUint32(d),d+=8,g.duration=u.getUint32(d)):(g.creationTime=kt(u.getUint32(d)),d+=4,g.modificationTime=kt(u.getUint32(d)),d+=4,g.timescale=u.getUint32(d),d+=4,g.duration=u.getUint32(d)),d+=4,h=u.getUint16(d),g.language+=String.fromCharCode((h>>10)+96),g.language+=String.fromCharCode(((h&992)>>5)+96),g.language+=String.fromCharCode((h&31)+96),g},mdia:function(o){return{boxes:Qe(o)}},mfhd:function(o){return{version:o[0],flags:new Uint8Array(o.subarray(1,4)),sequenceNumber:o[4]<<24|o[5]<<16|o[6]<<8|o[7]}},minf:function(o){return{boxes:Qe(o)}},mp4a:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),d={dataReferenceIndex:u.getUint16(6),channelcount:u.getUint16(16),samplesize:u.getUint16(18),samplerate:u.getUint16(24)+u.getUint16(26)/65536};return o.byteLength>28&&(d.streamDescriptor=Qe(o.subarray(28))[0]),d},moof:function(o){return{boxes:Qe(o)}},moov:function(o){return{boxes:Qe(o)}},mvex:function(o){return{boxes:Qe(o)}},mvhd:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),d=4,h={version:u.getUint8(0),flags:new Uint8Array(o.subarray(1,4))};return h.version===1?(d+=4,h.creationTime=kt(u.getUint32(d)),d+=8,h.modificationTime=kt(u.getUint32(d)),d+=4,h.timescale=u.getUint32(d),d+=8,h.duration=u.getUint32(d)):(h.creationTime=kt(u.getUint32(d)),d+=4,h.modificationTime=kt(u.getUint32(d)),d+=4,h.timescale=u.getUint32(d),d+=4,h.duration=u.getUint32(d)),d+=4,h.rate=u.getUint16(d)+u.getUint16(d+2)/16,d+=4,h.volume=u.getUint8(d)+u.getUint8(d+1)/8,d+=2,d+=2,d+=2*4,h.matrix=new Uint32Array(o.subarray(d,d+9*4)),d+=9*4,d+=6*4,h.nextTrackId=u.getUint32(d),h},pdin:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength);return{version:u.getUint8(0),flags:new Uint8Array(o.subarray(1,4)),rate:u.getUint32(4),initialDelay:u.getUint32(8)}},sdtp:function(o){var u={version:o[0],flags:new Uint8Array(o.subarray(1,4)),samples:[]},d;for(d=4;d<o.byteLength;d++)u.samples.push({dependsOn:(o[d]&48)>>4,isDependedOn:(o[d]&12)>>2,hasRedundancy:o[d]&3});return u},sidx:Qg,smhd:function(o){return{version:o[0],flags:new Uint8Array(o.subarray(1,4)),balance:o[4]+o[5]/256}},stbl:function(o){return{boxes:Qe(o)}},ctts:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),d={version:u.getUint8(0),flags:new Uint8Array(o.subarray(1,4)),compositionOffsets:[]},h=u.getUint32(4),g;for(g=8;h;g+=8,h--)d.compositionOffsets.push({sampleCount:u.getUint32(g),sampleOffset:u[d.version===0?"getUint32":"getInt32"](g+4)});return d},stss:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),d={version:u.getUint8(0),flags:new Uint8Array(o.subarray(1,4)),syncSamples:[]},h=u.getUint32(4),g;for(g=8;h;g+=4,h--)d.syncSamples.push(u.getUint32(g));return d},stco:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),d={version:o[0],flags:new Uint8Array(o.subarray(1,4)),chunkOffsets:[]},h=u.getUint32(4),g;for(g=8;h;g+=4,h--)d.chunkOffsets.push(u.getUint32(g));return d},stsc:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),d=u.getUint32(4),h={version:o[0],flags:new Uint8Array(o.subarray(1,4)),sampleToChunks:[]},g;for(g=8;d;g+=12,d--)h.sampleToChunks.push({firstChunk:u.getUint32(g),samplesPerChunk:u.getUint32(g+4),sampleDescriptionIndex:u.getUint32(g+8)});return h},stsd:function(o){return{version:o[0],flags:new Uint8Array(o.subarray(1,4)),sampleDescriptions:Qe(o.subarray(8))}},stsz:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),d={version:o[0],flags:new Uint8Array(o.subarray(1,4)),sampleSize:u.getUint32(4),entries:[]},h;for(h=12;h<o.byteLength;h+=4)d.entries.push(u.getUint32(h));return d},stts:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),d={version:o[0],flags:new Uint8Array(o.subarray(1,4)),timeToSamples:[]},h=u.getUint32(4),g;for(g=8;h;g+=8,h--)d.timeToSamples.push({sampleCount:u.getUint32(g),sampleDelta:u.getUint32(g+4)});return d},styp:function(o){return ci.ftyp(o)},tfdt:fa,tfhd:ma,tkhd:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),d=4,h={version:u.getUint8(0),flags:new Uint8Array(o.subarray(1,4))};return h.version===1?(d+=4,h.creationTime=kt(u.getUint32(d)),d+=8,h.modificationTime=kt(u.getUint32(d)),d+=4,h.trackId=u.getUint32(d),d+=4,d+=8,h.duration=u.getUint32(d)):(h.creationTime=kt(u.getUint32(d)),d+=4,h.modificationTime=kt(u.getUint32(d)),d+=4,h.trackId=u.getUint32(d),d+=4,d+=4,h.duration=u.getUint32(d)),d+=4,d+=2*4,h.layer=u.getUint16(d),d+=2,h.alternateGroup=u.getUint16(d),d+=2,h.volume=u.getUint8(d)+u.getUint8(d+1)/8,d+=2,d+=2,h.matrix=new Uint32Array(o.subarray(d,d+9*4)),d+=9*4,h.width=u.getUint16(d)+u.getUint16(d+2)/65536,d+=4,h.height=u.getUint16(d)+u.getUint16(d+2)/65536,h},traf:function(o){return{boxes:Qe(o)}},trak:function(o){return{boxes:Qe(o)}},trex:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength);return{version:o[0],flags:new Uint8Array(o.subarray(1,4)),trackId:u.getUint32(4),defaultSampleDescriptionIndex:u.getUint32(8),defaultSampleDuration:u.getUint32(12),defaultSampleSize:u.getUint32(16),sampleDependsOn:o[20]&3,sampleIsDependedOn:(o[21]&192)>>6,sampleHasRedundancy:(o[21]&48)>>4,samplePaddingValue:(o[21]&14)>>1,sampleIsDifferenceSample:!!(o[21]&1),sampleDegradationPriority:u.getUint16(22)}},trun:Ul,"url ":function(o){return{version:o[0],flags:new Uint8Array(o.subarray(1,4))}},vmhd:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength);return{version:o[0],flags:new Uint8Array(o.subarray(1,4)),graphicsmode:u.getUint16(4),opcolor:new Uint16Array([u.getUint16(6),u.getUint16(8),u.getUint16(10)])}}};Qe=function(o){for(var u=0,d=[],h,g,y,S,E,k=new ArrayBuffer(o.length),I=new Uint8Array(k),O=0;O<o.length;++O)I[O]=o[O];for(h=new DataView(k);u<o.byteLength;)g=h.getUint32(u),y=$n(o.subarray(u+4,u+8)),S=g>1?u+g:o.byteLength,E=(ci[y]||function(j){return{data:j}})(o.subarray(u+8,S)),E.size=g,E.type=y,d.push(E),u=S;return d},ya=function(o,u){var d;return u=u||0,d=new Array(u*2+1).join(" "),o.map(function(h,g){return d+h.type+`
|
|
196
|
-
`+Object.keys(
|
|
197
|
-
`+
|
|
195
|
+
`),this.pushCaption(u),u.startPts=o},Se.prototype.pushCaption=function(o){o.text!==""&&(this.trigger("data",{startPts:o.startPts,endPts:o.endPts,text:o.text,stream:"cc708_"+o.serviceNum}),o.text="",o.startPts=o.endPts)},Se.prototype.displayWindows=function(o,u){var c=this.current708Packet.data,d=c[++o],p=this.getPts(o);this.flushDisplayed(p,u);for(var _=0;_<8;_++)d&1<<_&&(u.windows[_].visible=1);return o},Se.prototype.hideWindows=function(o,u){var c=this.current708Packet.data,d=c[++o],p=this.getPts(o);this.flushDisplayed(p,u);for(var _=0;_<8;_++)d&1<<_&&(u.windows[_].visible=0);return o},Se.prototype.toggleWindows=function(o,u){var c=this.current708Packet.data,d=c[++o],p=this.getPts(o);this.flushDisplayed(p,u);for(var _=0;_<8;_++)d&1<<_&&(u.windows[_].visible^=1);return o},Se.prototype.clearWindows=function(o,u){var c=this.current708Packet.data,d=c[++o],p=this.getPts(o);this.flushDisplayed(p,u);for(var _=0;_<8;_++)d&1<<_&&u.windows[_].clearText();return o},Se.prototype.deleteWindows=function(o,u){var c=this.current708Packet.data,d=c[++o],p=this.getPts(o);this.flushDisplayed(p,u);for(var _=0;_<8;_++)d&1<<_&&u.windows[_].reset();return o},Se.prototype.setPenAttributes=function(o,u){var c=this.current708Packet.data,d=c[o],p=u.currentWindow.penAttr;return d=c[++o],p.textTag=(d&240)>>4,p.offset=(d&12)>>2,p.penSize=d&3,d=c[++o],p.italics=(d&128)>>7,p.underline=(d&64)>>6,p.edgeType=(d&56)>>3,p.fontStyle=d&7,o},Se.prototype.setPenColor=function(o,u){var c=this.current708Packet.data,d=c[o],p=u.currentWindow.penColor;return d=c[++o],p.fgOpacity=(d&192)>>6,p.fgRed=(d&48)>>4,p.fgGreen=(d&12)>>2,p.fgBlue=d&3,d=c[++o],p.bgOpacity=(d&192)>>6,p.bgRed=(d&48)>>4,p.bgGreen=(d&12)>>2,p.bgBlue=d&3,d=c[++o],p.edgeRed=(d&48)>>4,p.edgeGreen=(d&12)>>2,p.edgeBlue=d&3,o},Se.prototype.setPenLocation=function(o,u){var c=this.current708Packet.data,d=c[o],p=u.currentWindow.penLoc;return u.currentWindow.pendingNewLine=!0,d=c[++o],p.row=d&15,d=c[++o],p.column=d&63,o},Se.prototype.reset=function(o,u){var c=this.getPts(o);return this.flushDisplayed(c,u),this.initService(u.serviceNum,o)};var np={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,304:174,305:176,306:189,307:191,308:8482,309:162,310:163,311:9834,312:224,313:160,314:232,315:226,316:234,317:238,318:244,319:251,544:193,545:201,546:211,547:218,548:220,549:252,550:8216,551:161,552:42,553:39,554:8212,555:169,556:8480,557:8226,558:8220,559:8221,560:192,561:194,562:199,563:200,564:202,565:203,566:235,567:206,568:207,569:239,570:212,571:217,572:249,573:219,574:171,575:187,800:195,801:227,802:205,803:204,804:236,805:210,806:242,807:213,808:245,809:123,810:125,811:92,812:94,813:95,814:124,815:126,816:196,817:228,818:214,819:246,820:223,821:165,822:164,823:9474,824:197,825:229,826:216,827:248,828:9484,829:9488,830:9492,831:9496},Ln=function(o){return o===null?"":(o=np[o]||o,String.fromCharCode(o))},On=14,rp=[4352,4384,4608,4640,5376,5408,5632,5664,5888,5920,4096,4864,4896,5120,5152],Pi=function(){for(var o=[],u=On+1;u--;)o.push({text:"",indent:0,offset:0});return o},Le=function(o,u){Le.prototype.init.call(this),this.field_=o||0,this.dataChannel_=u||0,this.name_="CC"+((this.field_<<1|this.dataChannel_)+1),this.setConstants(),this.reset(),this.push=function(c){var d,p,_,x,S;if(d=c.ccData&32639,d===this.lastControlCode_){this.lastControlCode_=null;return}if((d&61440)===4096?this.lastControlCode_=d:d!==this.PADDING_&&(this.lastControlCode_=null),_=d>>>8,x=d&255,d!==this.PADDING_)if(d===this.RESUME_CAPTION_LOADING_)this.mode_="popOn";else if(d===this.END_OF_CAPTION_)this.mode_="popOn",this.clearFormatting(c.pts),this.flushDisplayed(c.pts),p=this.displayed_,this.displayed_=this.nonDisplayed_,this.nonDisplayed_=p,this.startPts_=c.pts;else if(d===this.ROLL_UP_2_ROWS_)this.rollUpRows_=2,this.setRollUp(c.pts);else if(d===this.ROLL_UP_3_ROWS_)this.rollUpRows_=3,this.setRollUp(c.pts);else if(d===this.ROLL_UP_4_ROWS_)this.rollUpRows_=4,this.setRollUp(c.pts);else if(d===this.CARRIAGE_RETURN_)this.clearFormatting(c.pts),this.flushDisplayed(c.pts),this.shiftRowsUp_(),this.startPts_=c.pts;else if(d===this.BACKSPACE_)this.mode_==="popOn"?this.nonDisplayed_[this.row_].text=this.nonDisplayed_[this.row_].text.slice(0,-1):this.displayed_[this.row_].text=this.displayed_[this.row_].text.slice(0,-1);else if(d===this.ERASE_DISPLAYED_MEMORY_)this.flushDisplayed(c.pts),this.displayed_=Pi();else if(d===this.ERASE_NON_DISPLAYED_MEMORY_)this.nonDisplayed_=Pi();else if(d===this.RESUME_DIRECT_CAPTIONING_)this.mode_!=="paintOn"&&(this.flushDisplayed(c.pts),this.displayed_=Pi()),this.mode_="paintOn",this.startPts_=c.pts;else if(this.isSpecialCharacter(_,x))_=(_&3)<<8,S=Ln(_|x),this[this.mode_](c.pts,S),this.column_++;else if(this.isExtCharacter(_,x))this.mode_==="popOn"?this.nonDisplayed_[this.row_].text=this.nonDisplayed_[this.row_].text.slice(0,-1):this.displayed_[this.row_].text=this.displayed_[this.row_].text.slice(0,-1),_=(_&3)<<8,S=Ln(_|x),this[this.mode_](c.pts,S),this.column_++;else if(this.isMidRowCode(_,x))this.clearFormatting(c.pts),this[this.mode_](c.pts," "),this.column_++,(x&14)===14&&this.addFormatting(c.pts,["i"]),(x&1)===1&&this.addFormatting(c.pts,["u"]);else if(this.isOffsetControlCode(_,x)){const A=x&3;this.nonDisplayed_[this.row_].offset=A,this.column_+=A}else if(this.isPAC(_,x)){var I=rp.indexOf(d&7968);if(this.mode_==="rollUp"&&(I-this.rollUpRows_+1<0&&(I=this.rollUpRows_-1),this.setRollUp(c.pts,I)),I!==this.row_&&I>=0&&I<=14&&(this.clearFormatting(c.pts),this.row_=I),x&1&&this.formatting_.indexOf("u")===-1&&this.addFormatting(c.pts,["u"]),(d&16)===16){const A=(d&14)>>1;this.column_=A*4,this.nonDisplayed_[this.row_].indent+=A}this.isColorPAC(x)&&(x&14)===14&&this.addFormatting(c.pts,["i"])}else this.isNormalChar(_)&&(x===0&&(x=null),S=Ln(_),S+=Ln(x),this[this.mode_](c.pts,S),this.column_+=S.length)}};Le.prototype=new aa,Le.prototype.flushDisplayed=function(o){const u=d=>{this.trigger("log",{level:"warn",message:"Skipping a malformed 608 caption at index "+d+"."})},c=[];this.displayed_.forEach((d,p)=>{if(d&&d.text&&d.text.length){try{d.text=d.text.trim()}catch{u(p)}d.text.length&&c.push({text:d.text,line:p+1,position:10+Math.min(70,d.indent*10)+d.offset*2.5})}else d==null&&u(p)}),c.length&&this.trigger("data",{startPts:this.startPts_,endPts:o,content:c,stream:this.name_})},Le.prototype.reset=function(){this.mode_="popOn",this.topRow_=0,this.startPts_=0,this.displayed_=Pi(),this.nonDisplayed_=Pi(),this.lastControlCode_=null,this.column_=0,this.row_=On,this.rollUpRows_=2,this.formatting_=[]},Le.prototype.setConstants=function(){this.dataChannel_===0?(this.BASE_=16,this.EXT_=17,this.CONTROL_=(20|this.field_)<<8,this.OFFSET_=23):this.dataChannel_===1&&(this.BASE_=24,this.EXT_=25,this.CONTROL_=(28|this.field_)<<8,this.OFFSET_=31),this.PADDING_=0,this.RESUME_CAPTION_LOADING_=this.CONTROL_|32,this.END_OF_CAPTION_=this.CONTROL_|47,this.ROLL_UP_2_ROWS_=this.CONTROL_|37,this.ROLL_UP_3_ROWS_=this.CONTROL_|38,this.ROLL_UP_4_ROWS_=this.CONTROL_|39,this.CARRIAGE_RETURN_=this.CONTROL_|45,this.RESUME_DIRECT_CAPTIONING_=this.CONTROL_|41,this.BACKSPACE_=this.CONTROL_|33,this.ERASE_DISPLAYED_MEMORY_=this.CONTROL_|44,this.ERASE_NON_DISPLAYED_MEMORY_=this.CONTROL_|46},Le.prototype.isSpecialCharacter=function(o,u){return o===this.EXT_&&u>=48&&u<=63},Le.prototype.isExtCharacter=function(o,u){return(o===this.EXT_+1||o===this.EXT_+2)&&u>=32&&u<=63},Le.prototype.isMidRowCode=function(o,u){return o===this.EXT_&&u>=32&&u<=47},Le.prototype.isOffsetControlCode=function(o,u){return o===this.OFFSET_&&u>=33&&u<=35},Le.prototype.isPAC=function(o,u){return o>=this.BASE_&&o<this.BASE_+8&&u>=64&&u<=127},Le.prototype.isColorPAC=function(o){return o>=64&&o<=79||o>=96&&o<=127},Le.prototype.isNormalChar=function(o){return o>=32&&o<=127},Le.prototype.setRollUp=function(o,u){if(this.mode_!=="rollUp"&&(this.row_=On,this.mode_="rollUp",this.flushDisplayed(o),this.nonDisplayed_=Pi(),this.displayed_=Pi()),u!==void 0&&u!==this.row_)for(var c=0;c<this.rollUpRows_;c++)this.displayed_[u-c]=this.displayed_[this.row_-c],this.displayed_[this.row_-c]={text:"",indent:0,offset:0};u===void 0&&(u=this.row_),this.topRow_=u-this.rollUpRows_+1},Le.prototype.addFormatting=function(o,u){this.formatting_=this.formatting_.concat(u);var c=u.reduce(function(d,p){return d+"<"+p+">"},"");this[this.mode_](o,c)},Le.prototype.clearFormatting=function(o){if(this.formatting_.length){var u=this.formatting_.reverse().reduce(function(c,d){return c+"</"+d+">"},"");this.formatting_=[],this[this.mode_](o,u)}},Le.prototype.popOn=function(o,u){var c=this.nonDisplayed_[this.row_].text;c+=u,this.nonDisplayed_[this.row_].text=c},Le.prototype.rollUp=function(o,u){var c=this.displayed_[this.row_].text;c+=u,this.displayed_[this.row_].text=c},Le.prototype.shiftRowsUp_=function(){var o;for(o=0;o<this.topRow_;o++)this.displayed_[o]={text:"",indent:0,offset:0};for(o=this.row_+1;o<On+1;o++)this.displayed_[o]={text:"",indent:0,offset:0};for(o=this.topRow_;o<this.row_;o++)this.displayed_[o]=this.displayed_[o+1];this.displayed_[this.row_]={text:"",indent:0,offset:0}},Le.prototype.paintOn=function(o,u){var c=this.displayed_[this.row_].text;c+=u,this.displayed_[this.row_].text=c};var _l={CaptionStream:ut,Cea608Stream:Le,Cea708Stream:Se},Rn={H264_STREAM_TYPE:27,ADTS_STREAM_TYPE:15,METADATA_STREAM_TYPE:21},ap=t,op=8589934592,lp=4294967296,Tl="shared",oa=function(o,u){var c=1;for(o>u&&(c=-1);Math.abs(u-o)>lp;)o+=c*op;return o},la=function(o){var u,c;la.prototype.init.call(this),this.type_=o||Tl,this.push=function(d){if(d.type==="metadata"){this.trigger("data",d);return}this.type_!==Tl&&d.type!==this.type_||(c===void 0&&(c=d.dts),d.dts=oa(d.dts,c),d.pts=oa(d.pts,c),u=d.dts,this.trigger("data",d))},this.flush=function(){c=u,this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")},this.discontinuity=function(){c=void 0,u=void 0},this.reset=function(){this.discontinuity(),this.trigger("reset")}};la.prototype=new ap;var vl={TimestampRolloverStream:la,handleRollover:oa},up=(o,u,c)=>{if(!o)return-1;for(var d=c;d<o.length;d++)if(o[d]===u)return d;return-1},cp={typedArrayIndexOf:up},Mn=cp.typedArrayIndexOf,Nn={Iso88591:0,Utf16:1,Utf16be:2,Utf8:3},bl=function(o,u,c){var d,p="";for(d=u;d<c;d++)p+="%"+("00"+o[d].toString(16)).slice(-2);return p},Os=function(o,u,c){return decodeURIComponent(bl(o,u,c))},Rs=function(o,u,c){return unescape(bl(o,u,c))},Ms=function(o){return o[0]<<21|o[1]<<14|o[2]<<7|o[3]},Ns={APIC:function(o){var u=1,c,d,p="-->";o.data[0]===Nn.Utf8&&(c=Mn(o.data,0,u),!(c<0)&&(o.mimeType=Rs(o.data,u,c),u=c+1,o.pictureType=o.data[u],u++,d=Mn(o.data,0,u),!(d<0)&&(o.description=Os(o.data,u,d),u=d+1,o.mimeType===p?o.url=Rs(o.data,u,o.data.length):o.pictureData=o.data.subarray(u,o.data.length))))},"T*":function(o){o.data[0]===Nn.Utf8&&(o.value=Os(o.data,1,o.data.length).replace(/\0*$/,""),o.values=o.value.split("\0"))},TXXX:function(o){var u;o.data[0]===Nn.Utf8&&(u=Mn(o.data,0,1),u!==-1&&(o.description=Os(o.data,1,u),o.value=Os(o.data,u+1,o.data.length).replace(/\0*$/,""),o.data=o.value))},"W*":function(o){o.url=Rs(o.data,0,o.data.length).replace(/\0.*$/,"")},WXXX:function(o){var u;o.data[0]===Nn.Utf8&&(u=Mn(o.data,0,1),u!==-1&&(o.description=Os(o.data,1,u),o.url=Rs(o.data,u+1,o.data.length).replace(/\0.*$/,"")))},PRIV:function(o){var u;for(u=0;u<o.data.length;u++)if(o.data[u]===0){o.owner=Rs(o.data,0,u);break}o.privateData=o.data.subarray(u+1),o.data=o.privateData}},dp=function(o){var u,c,d=10,p=0,_=[];if(!(o.length<10||o[0]!==73||o[1]!==68||o[2]!==51)){p=Ms(o.subarray(6,10)),p+=10;var x=o[5]&64;x&&(d+=4,d+=Ms(o.subarray(10,14)),p-=Ms(o.subarray(16,20)));do{if(u=Ms(o.subarray(d+4,d+8)),u<1)break;c=String.fromCharCode(o[d],o[d+1],o[d+2],o[d+3]);var S={id:c,data:o.subarray(d+10,d+u+10)};S.key=S.id,Ns[S.id]?Ns[S.id](S):S.id[0]==="T"?Ns["T*"](S):S.id[0]==="W"&&Ns["W*"](S),_.push(S),d+=10,d+=u}while(d<p);return _}},xl={parseId3Frames:dp,parseSyncSafeInteger:Ms,frameParsers:Ns},hp=t,fp=Rn,fi=xl,Un;Un=function(o){var u={descriptor:o&&o.descriptor},c=0,d=[],p=0,_;if(Un.prototype.init.call(this),this.dispatchType=fp.METADATA_STREAM_TYPE.toString(16),u.descriptor)for(_=0;_<u.descriptor.length;_++)this.dispatchType+=("00"+u.descriptor[_].toString(16)).slice(-2);this.push=function(x){var S,I,A,O,j,Y;if(x.type==="timed-metadata"){if(x.dataAlignmentIndicator&&(p=0,d.length=0),d.length===0&&(x.data.length<10||x.data[0]!==73||x.data[1]!==68||x.data[2]!==51)){this.trigger("log",{level:"warn",message:"Skipping unrecognized metadata packet"});return}if(d.push(x),p+=x.data.byteLength,d.length===1&&(c=fi.parseSyncSafeInteger(x.data.subarray(6,10)),c+=10),!(p<c)){for(S={data:new Uint8Array(c),frames:[],pts:d[0].pts,dts:d[0].dts},j=0;j<c;)S.data.set(d[0].data.subarray(0,c-j),j),j+=d[0].data.byteLength,p-=d[0].data.byteLength,d.shift();I=10,S.data[5]&64&&(I+=4,I+=fi.parseSyncSafeInteger(S.data.subarray(10,14)),c-=fi.parseSyncSafeInteger(S.data.subarray(16,20)));do{if(A=fi.parseSyncSafeInteger(S.data.subarray(I+4,I+8)),A<1){this.trigger("log",{level:"warn",message:"Malformed ID3 frame encountered. Skipping remaining metadata parsing."});break}if(Y=String.fromCharCode(S.data[I],S.data[I+1],S.data[I+2],S.data[I+3]),O={id:Y,data:S.data.subarray(I+10,I+A+10)},O.key=O.id,fi.frameParsers[O.id]?fi.frameParsers[O.id](O):O.id[0]==="T"?fi.frameParsers["T*"](O):O.id[0]==="W"&&fi.frameParsers["W*"](O),O.owner==="com.apple.streaming.transportStreamTimestamp"){var q=O.data,te=(q[3]&1)<<30|q[4]<<22|q[5]<<14|q[6]<<6|q[7]>>>2;te*=4,te+=q[7]&3,O.timeStamp=te,S.pts===void 0&&S.dts===void 0&&(S.pts=O.timeStamp,S.dts=O.timeStamp),this.trigger("timestamp",O)}S.frames.push(O),I+=10,I+=A}while(I<c);this.trigger("data",S)}}}},Un.prototype=new hp;var pp=Un,ua=t,ca=_l,Ot=Rn,mp=vl.TimestampRolloverStream,Bn,Us,Fn,Gi=188,da=71;Bn=function(){var o=new Uint8Array(Gi),u=0;Bn.prototype.init.call(this),this.push=function(c){var d=0,p=Gi,_;for(u?(_=new Uint8Array(c.byteLength+u),_.set(o.subarray(0,u)),_.set(c,u),u=0):_=c;p<_.byteLength;){if(_[d]===da&&_[p]===da){this.trigger("data",_.subarray(d,p)),d+=Gi,p+=Gi;continue}d++,p++}d<_.byteLength&&(o.set(_.subarray(d),0),u=_.byteLength-d)},this.flush=function(){u===Gi&&o[0]===da&&(this.trigger("data",o),u=0),this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")},this.reset=function(){u=0,this.trigger("reset")}},Bn.prototype=new ua,Us=function(){var o,u,c,d;Us.prototype.init.call(this),d=this,this.packetsWaitingForPmt=[],this.programMapTable=void 0,o=function(p,_){var x=0;_.payloadUnitStartIndicator&&(x+=p[x]+1),_.type==="pat"?u(p.subarray(x),_):c(p.subarray(x),_)},u=function(p,_){_.section_number=p[7],_.last_section_number=p[8],d.pmtPid=(p[10]&31)<<8|p[11],_.pmtPid=d.pmtPid},c=function(p,_){var x,S,I,A;if(p[5]&1){for(d.programMapTable={video:null,audio:null,"timed-metadata":{}},x=(p[1]&15)<<8|p[2],S=3+x-4,I=(p[10]&15)<<8|p[11],A=12+I;A<S;){var O=p[A],j=(p[A+1]&31)<<8|p[A+2];O===Ot.H264_STREAM_TYPE&&d.programMapTable.video===null?d.programMapTable.video=j:O===Ot.ADTS_STREAM_TYPE&&d.programMapTable.audio===null?d.programMapTable.audio=j:O===Ot.METADATA_STREAM_TYPE&&(d.programMapTable["timed-metadata"][j]=O),A+=((p[A+3]&15)<<8|p[A+4])+5}_.programMapTable=d.programMapTable}},this.push=function(p){var _={},x=4;if(_.payloadUnitStartIndicator=!!(p[1]&64),_.pid=p[1]&31,_.pid<<=8,_.pid|=p[2],(p[3]&48)>>>4>1&&(x+=p[x]+1),_.pid===0)_.type="pat",o(p.subarray(x),_),this.trigger("data",_);else if(_.pid===this.pmtPid)for(_.type="pmt",o(p.subarray(x),_),this.trigger("data",_);this.packetsWaitingForPmt.length;)this.processPes_.apply(this,this.packetsWaitingForPmt.shift());else this.programMapTable===void 0?this.packetsWaitingForPmt.push([p,x,_]):this.processPes_(p,x,_)},this.processPes_=function(p,_,x){x.pid===this.programMapTable.video?x.streamType=Ot.H264_STREAM_TYPE:x.pid===this.programMapTable.audio?x.streamType=Ot.ADTS_STREAM_TYPE:x.streamType=this.programMapTable["timed-metadata"][x.pid],x.type="pes",x.data=p.subarray(_),this.trigger("data",x)}},Us.prototype=new ua,Us.STREAM_TYPES={h264:27,adts:15},Fn=function(){var o=this,u=!1,c={data:[],size:0},d={data:[],size:0},p={data:[],size:0},_,x=function(I,A){var O;const j=I[0]<<16|I[1]<<8|I[2];A.data=new Uint8Array,j===1&&(A.packetLength=6+(I[4]<<8|I[5]),A.dataAlignmentIndicator=(I[6]&4)!==0,O=I[7],O&192&&(A.pts=(I[9]&14)<<27|(I[10]&255)<<20|(I[11]&254)<<12|(I[12]&255)<<5|(I[13]&254)>>>3,A.pts*=4,A.pts+=(I[13]&6)>>>1,A.dts=A.pts,O&64&&(A.dts=(I[14]&14)<<27|(I[15]&255)<<20|(I[16]&254)<<12|(I[17]&255)<<5|(I[18]&254)>>>3,A.dts*=4,A.dts+=(I[18]&6)>>>1)),A.data=I.subarray(9+I[8]))},S=function(I,A,O){var j=new Uint8Array(I.size),Y={type:A},q=0,te=0,ne=!1,ze;if(!(!I.data.length||I.size<9)){for(Y.trackId=I.data[0].pid,q=0;q<I.data.length;q++)ze=I.data[q],j.set(ze.data,te),te+=ze.data.byteLength;x(j,Y),ne=A==="video"||Y.packetLength<=I.size,(O||ne)&&(I.size=0,I.data.length=0),ne&&o.trigger("data",Y)}};Fn.prototype.init.call(this),this.push=function(I){({pat:function(){},pes:function(){var A,O;switch(I.streamType){case Ot.H264_STREAM_TYPE:A=c,O="video";break;case Ot.ADTS_STREAM_TYPE:A=d,O="audio";break;case Ot.METADATA_STREAM_TYPE:A=p,O="timed-metadata";break;default:return}I.payloadUnitStartIndicator&&S(A,O,!0),A.data.push(I),A.size+=I.data.byteLength},pmt:function(){var A={type:"metadata",tracks:[]};_=I.programMapTable,_.video!==null&&A.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+_.video,codec:"avc",type:"video"}),_.audio!==null&&A.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+_.audio,codec:"adts",type:"audio"}),u=!0,o.trigger("data",A)}})[I.type]()},this.reset=function(){c.size=0,c.data.length=0,d.size=0,d.data.length=0,this.trigger("reset")},this.flushStreams_=function(){S(c,"video"),S(d,"audio"),S(p,"timed-metadata")},this.flush=function(){if(!u&&_){var I={type:"metadata",tracks:[]};_.video!==null&&I.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+_.video,codec:"avc",type:"video"}),_.audio!==null&&I.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+_.audio,codec:"adts",type:"audio"}),o.trigger("data",I)}u=!1,this.flushStreams_(),this.trigger("done")}},Fn.prototype=new ua;var Sl={PAT_PID:0,MP2T_PACKET_LENGTH:Gi,TransportPacketStream:Bn,TransportParseStream:Us,ElementaryStream:Fn,TimestampRolloverStream:mp,CaptionStream:ca.CaptionStream,Cea608Stream:ca.Cea608Stream,Cea708Stream:ca.Cea708Stream,MetadataStream:pp};for(var ha in Ot)Ot.hasOwnProperty(ha)&&(Sl[ha]=Ot[ha]);var gp=Sl,yp=t,_p=y.ONE_SECOND_IN_TS,$n,El=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];$n=function(o){var u,c=0;$n.prototype.init.call(this),this.skipWarn_=function(d,p){this.trigger("log",{level:"warn",message:`adts skiping bytes ${d} to ${p} in frame ${c} outside syncword`})},this.push=function(d){var p=0,_,x,S,I,A;if(o||(c=0),d.type==="audio"){u&&u.length?(S=u,u=new Uint8Array(S.byteLength+d.data.byteLength),u.set(S),u.set(d.data,S.byteLength)):u=d.data;for(var O;p+7<u.length;){if(u[p]!==255||(u[p+1]&246)!==240){typeof O!="number"&&(O=p),p++;continue}if(typeof O=="number"&&(this.skipWarn_(O,p),O=null),x=(~u[p+1]&1)*2,_=(u[p+3]&3)<<11|u[p+4]<<3|(u[p+5]&224)>>5,I=((u[p+6]&3)+1)*1024,A=I*_p/El[(u[p+2]&60)>>>2],u.byteLength-p<_)break;this.trigger("data",{pts:d.pts+c*A,dts:d.dts+c*A,sampleCount:I,audioobjecttype:(u[p+2]>>>6&3)+1,channelcount:(u[p+2]&1)<<2|(u[p+3]&192)>>>6,samplerate:El[(u[p+2]&60)>>>2],samplingfrequencyindex:(u[p+2]&60)>>>2,samplesize:16,data:u.subarray(p+7+x,p+_)}),c++,p+=_}typeof O=="number"&&(this.skipWarn_(O,p),O=null),u=u.subarray(p)}},this.flush=function(){c=0,this.trigger("done")},this.reset=function(){u=void 0,this.trigger("reset")},this.endTimeline=function(){u=void 0,this.trigger("endedtimeline")}},$n.prototype=new yp;var Tp=$n,Cl;Cl=function(o){var u=o.byteLength,c=0,d=0;this.length=function(){return 8*u},this.bitsAvailable=function(){return 8*u+d},this.loadWord=function(){var p=o.byteLength-u,_=new Uint8Array(4),x=Math.min(4,u);if(x===0)throw new Error("no bytes available");_.set(o.subarray(p,p+x)),c=new DataView(_.buffer).getUint32(0),d=x*8,u-=x},this.skipBits=function(p){var _;d>p?(c<<=p,d-=p):(p-=d,_=Math.floor(p/8),p-=_*8,u-=_,this.loadWord(),c<<=p,d-=p)},this.readBits=function(p){var _=Math.min(d,p),x=c>>>32-_;return d-=_,d>0?c<<=_:u>0&&this.loadWord(),_=p-_,_>0?x<<_|this.readBits(_):x},this.skipLeadingZeros=function(){var p;for(p=0;p<d;++p)if(c&2147483648>>>p)return c<<=p,d-=p,p;return this.loadWord(),p+this.skipLeadingZeros()},this.skipUnsignedExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros())},this.skipExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros())},this.readUnsignedExpGolomb=function(){var p=this.skipLeadingZeros();return this.readBits(p+1)-1},this.readExpGolomb=function(){var p=this.readUnsignedExpGolomb();return 1&p?1+p>>>1:-1*(p>>>1)},this.readBoolean=function(){return this.readBits(1)===1},this.readUnsignedByte=function(){return this.readBits(8)},this.loadWord()};var vp=Cl,wl=t,bp=vp,jn,Bs,Il;Bs=function(){var o=0,u,c;Bs.prototype.init.call(this),this.push=function(d){var p;c?(p=new Uint8Array(c.byteLength+d.data.byteLength),p.set(c),p.set(d.data,c.byteLength),c=p):c=d.data;for(var _=c.byteLength;o<_-3;o++)if(c[o+2]===1){u=o+5;break}for(;u<_;)switch(c[u]){case 0:if(c[u-1]!==0){u+=2;break}else if(c[u-2]!==0){u++;break}o+3!==u-2&&this.trigger("data",c.subarray(o+3,u-2));do u++;while(c[u]!==1&&u<_);o=u-2,u+=3;break;case 1:if(c[u-1]!==0||c[u-2]!==0){u+=3;break}this.trigger("data",c.subarray(o+3,u-2)),o=u-2,u+=3;break;default:u+=3;break}c=c.subarray(o),u-=o,o=0},this.reset=function(){c=null,o=0,this.trigger("reset")},this.flush=function(){c&&c.byteLength>3&&this.trigger("data",c.subarray(o+3)),c=null,o=0,this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")}},Bs.prototype=new wl,Il={100:!0,110:!0,122:!0,244:!0,44:!0,83:!0,86:!0,118:!0,128:!0,138:!0,139:!0,134:!0},jn=function(){var o=new Bs,u,c,d,p,_,x,S;jn.prototype.init.call(this),u=this,this.push=function(I){I.type==="video"&&(c=I.trackId,d=I.pts,p=I.dts,o.push(I))},o.on("data",function(I){var A={trackId:c,pts:d,dts:p,data:I,nalUnitTypeCode:I[0]&31};switch(A.nalUnitTypeCode){case 5:A.nalUnitType="slice_layer_without_partitioning_rbsp_idr";break;case 6:A.nalUnitType="sei_rbsp",A.escapedRBSP=_(I.subarray(1));break;case 7:A.nalUnitType="seq_parameter_set_rbsp",A.escapedRBSP=_(I.subarray(1)),A.config=x(A.escapedRBSP);break;case 8:A.nalUnitType="pic_parameter_set_rbsp";break;case 9:A.nalUnitType="access_unit_delimiter_rbsp";break}u.trigger("data",A)}),o.on("done",function(){u.trigger("done")}),o.on("partialdone",function(){u.trigger("partialdone")}),o.on("reset",function(){u.trigger("reset")}),o.on("endedtimeline",function(){u.trigger("endedtimeline")}),this.flush=function(){o.flush()},this.partialFlush=function(){o.partialFlush()},this.reset=function(){o.reset()},this.endTimeline=function(){o.endTimeline()},S=function(I,A){var O=8,j=8,Y,q;for(Y=0;Y<I;Y++)j!==0&&(q=A.readExpGolomb(),j=(O+q+256)%256),O=j===0?O:j},_=function(I){for(var A=I.byteLength,O=[],j=1,Y,q;j<A-2;)I[j]===0&&I[j+1]===0&&I[j+2]===3?(O.push(j+2),j+=2):j++;if(O.length===0)return I;Y=A-O.length,q=new Uint8Array(Y);var te=0;for(j=0;j<Y;te++,j++)te===O[0]&&(te++,O.shift()),q[j]=I[te];return q},x=function(I){var A=0,O=0,j=0,Y=0,q,te,ne,ze,gt,gi,Ws,Gs,Ks,Xs,Zn,Ie=[1,1],Ys,Mt;if(q=new bp(I),te=q.readUnsignedByte(),ze=q.readUnsignedByte(),ne=q.readUnsignedByte(),q.skipUnsignedExpGolomb(),Il[te]&&(gt=q.readUnsignedExpGolomb(),gt===3&&q.skipBits(1),q.skipUnsignedExpGolomb(),q.skipUnsignedExpGolomb(),q.skipBits(1),q.readBoolean()))for(Zn=gt!==3?8:12,Mt=0;Mt<Zn;Mt++)q.readBoolean()&&(Mt<6?S(16,q):S(64,q));if(q.skipUnsignedExpGolomb(),gi=q.readUnsignedExpGolomb(),gi===0)q.readUnsignedExpGolomb();else if(gi===1)for(q.skipBits(1),q.skipExpGolomb(),q.skipExpGolomb(),Ws=q.readUnsignedExpGolomb(),Mt=0;Mt<Ws;Mt++)q.skipExpGolomb();if(q.skipUnsignedExpGolomb(),q.skipBits(1),Gs=q.readUnsignedExpGolomb(),Ks=q.readUnsignedExpGolomb(),Xs=q.readBits(1),Xs===0&&q.skipBits(1),q.skipBits(1),q.readBoolean()&&(A=q.readUnsignedExpGolomb(),O=q.readUnsignedExpGolomb(),j=q.readUnsignedExpGolomb(),Y=q.readUnsignedExpGolomb()),q.readBoolean()&&q.readBoolean()){switch(Ys=q.readUnsignedByte(),Ys){case 1:Ie=[1,1];break;case 2:Ie=[12,11];break;case 3:Ie=[10,11];break;case 4:Ie=[16,11];break;case 5:Ie=[40,33];break;case 6:Ie=[24,11];break;case 7:Ie=[20,11];break;case 8:Ie=[32,11];break;case 9:Ie=[80,33];break;case 10:Ie=[18,11];break;case 11:Ie=[15,11];break;case 12:Ie=[64,33];break;case 13:Ie=[160,99];break;case 14:Ie=[4,3];break;case 15:Ie=[3,2];break;case 16:Ie=[2,1];break;case 255:{Ie=[q.readUnsignedByte()<<8|q.readUnsignedByte(),q.readUnsignedByte()<<8|q.readUnsignedByte()];break}}Ie&&Ie[0]/Ie[1]}return{profileIdc:te,levelIdc:ne,profileCompatibility:ze,width:(Gs+1)*16-A*2-O*2,height:(2-Xs)*(Ks+1)*16-j*2-Y*2,sarRatio:Ie}}},jn.prototype=new wl;var xp={H264Stream:jn,NalByteStream:Bs},Sp=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],Al=function(o,u){var c=o[u+6]<<21|o[u+7]<<14|o[u+8]<<7|o[u+9],d=o[u+5],p=(d&16)>>4;return c=c>=0?c:0,p?c+20:c+10},kl=function(o,u){return o.length-u<10||o[u]!==73||o[u+1]!==68||o[u+2]!==51?u:(u+=Al(o,u),kl(o,u))},Ep=function(o){var u=kl(o,0);return o.length>=u+2&&(o[u]&255)===255&&(o[u+1]&240)===240&&(o[u+1]&22)===16},Pl=function(o){return o[0]<<21|o[1]<<14|o[2]<<7|o[3]},Cp=function(o,u,c){var d,p="";for(d=u;d<c;d++)p+="%"+("00"+o[d].toString(16)).slice(-2);return p},wp=function(o,u,c){return unescape(Cp(o,u,c))},Ip=function(o,u){var c=(o[u+5]&224)>>5,d=o[u+4]<<3,p=o[u+3]&6144;return p|d|c},Ap=function(o,u){return o[u]===73&&o[u+1]===68&&o[u+2]===51?"timed-metadata":o[u]&!0&&(o[u+1]&240)===240?"audio":null},kp=function(o){for(var u=0;u+5<o.length;){if(o[u]!==255||(o[u+1]&246)!==240){u++;continue}return Sp[(o[u+2]&60)>>>2]}return null},Pp=function(o){var u,c,d,p;u=10,o[5]&64&&(u+=4,u+=Pl(o.subarray(10,14)));do{if(c=Pl(o.subarray(u+4,u+8)),c<1)return null;if(p=String.fromCharCode(o[u],o[u+1],o[u+2],o[u+3]),p==="PRIV"){d=o.subarray(u+10,u+c+10);for(var _=0;_<d.byteLength;_++)if(d[_]===0){var x=wp(d,0,_);if(x==="com.apple.streaming.transportStreamTimestamp"){var S=d.subarray(_+1),I=(S[3]&1)<<30|S[4]<<22|S[5]<<14|S[6]<<6|S[7]>>>2;return I*=4,I+=S[7]&3,I}break}}u+=10,u+=c}while(u<o.byteLength);return null},fa={isLikelyAacData:Ep,parseId3TagSize:Al,parseAdtsSize:Ip,parseType:Ap,parseSampleRate:kp,parseAacTimestamp:Pp},Dp=t,Dl=fa,Vn;Vn=function(){var o=new Uint8Array,u=0;Vn.prototype.init.call(this),this.setTimestamp=function(c){u=c},this.push=function(c){var d=0,p=0,_,x,S,I;for(o.length?(I=o.length,o=new Uint8Array(c.byteLength+I),o.set(o.subarray(0,I)),o.set(c,I)):o=c;o.length-p>=3;){if(o[p]===73&&o[p+1]===68&&o[p+2]===51){if(o.length-p<10||(d=Dl.parseId3TagSize(o,p),p+d>o.length))break;x={type:"timed-metadata",data:o.subarray(p,p+d)},this.trigger("data",x),p+=d;continue}else if((o[p]&255)===255&&(o[p+1]&240)===240){if(o.length-p<7||(d=Dl.parseAdtsSize(o,p),p+d>o.length))break;S={type:"audio",data:o.subarray(p,p+d),pts:u,dts:u},this.trigger("data",S),p+=d;continue}p++}_=o.length-p,_>0?o=o.subarray(p):o=new Uint8Array},this.reset=function(){o=new Uint8Array,this.trigger("reset")},this.endTimeline=function(){o=new Uint8Array,this.trigger("endedtimeline")}},Vn.prototype=new Dp;var Lp=Vn,Op=["audioobjecttype","channelcount","samplerate","samplingfrequencyindex","samplesize"],Rp=Op,Mp=["width","height","profileIdc","levelIdc","profileCompatibility","sarRatio"],Np=Mp,Hn=t,Fs=zi,$s=Ai,qn=De,Rt=Yf,si=gp,zn=y,Ll=Tp,Up=xp.H264Stream,Bp=Lp,Fp=fa.isLikelyAacData,$p=y.ONE_SECOND_IN_TS,pa=Rp,ma=Np,js,Ki,Wn,Di,jp=function(o,u){u.stream=o,this.trigger("log",u)},Ol=function(o,u){for(var c=Object.keys(u),d=0;d<c.length;d++){var p=c[d];p==="headOfPipeline"||!u[p].on||u[p].on("log",jp.bind(o,p))}},Rl=function(o,u){var c;if(o.length!==u.length)return!1;for(c=0;c<o.length;c++)if(o[c]!==u[c])return!1;return!0},ga=function(o,u,c,d,p,_){var x=c-u,S=d-u,I=p-c;return{start:{dts:o,pts:o+x},end:{dts:o+S,pts:o+I},prependedContentDuration:_,baseMediaDecodeTime:o}};Ki=function(o,u){var c=[],d,p=0,_=0,x=1/0;u=u||{},d=u.firstSequenceNumber||0,Ki.prototype.init.call(this),this.push=function(S){Rt.collectDtsInfo(o,S),o&&pa.forEach(function(I){o[I]=S[I]}),c.push(S)},this.setEarliestDts=function(S){p=S},this.setVideoBaseMediaDecodeTime=function(S){x=S},this.setAudioAppendStart=function(S){_=S},this.flush=function(){var S,I,A,O,j,Y,q;if(c.length===0){this.trigger("done","AudioSegmentStream");return}S=qn.trimAdtsFramesByEarliestDts(c,o,p),o.baseMediaDecodeTime=Rt.calculateTrackBaseMediaDecodeTime(o,u.keepOriginalTimestamps),q=qn.prefixWithSilence(o,S,_,x),o.samples=qn.generateSampleTable(S),A=Fs.mdat(qn.concatenateFrameData(S)),c=[],I=Fs.moof(d,[o]),O=new Uint8Array(I.byteLength+A.byteLength),d++,O.set(I),O.set(A,I.byteLength),Rt.clearDtsInfo(o),j=Math.ceil($p*1024/o.samplerate),S.length&&(Y=S.length*j,this.trigger("segmentTimingInfo",ga(zn.audioTsToVideoTs(o.baseMediaDecodeTime,o.samplerate),S[0].dts,S[0].pts,S[0].dts+Y,S[0].pts+Y,q||0)),this.trigger("timingInfo",{start:S[0].pts,end:S[0].pts+Y})),this.trigger("data",{track:o,boxes:O}),this.trigger("done","AudioSegmentStream")},this.reset=function(){Rt.clearDtsInfo(o),c=[],this.trigger("reset")}},Ki.prototype=new Hn,js=function(o,u){var c,d=[],p=[],_,x;u=u||{},c=u.firstSequenceNumber||0,js.prototype.init.call(this),delete o.minPTS,this.gopCache_=[],this.push=function(S){Rt.collectDtsInfo(o,S),S.nalUnitType==="seq_parameter_set_rbsp"&&!_&&(_=S.config,o.sps=[S.data],ma.forEach(function(I){o[I]=_[I]},this)),S.nalUnitType==="pic_parameter_set_rbsp"&&!x&&(x=S.data,o.pps=[S.data]),d.push(S)},this.flush=function(){for(var S,I,A,O,j,Y,q=0,te,ne;d.length&&d[0].nalUnitType!=="access_unit_delimiter_rbsp";)d.shift();if(d.length===0){this.resetStream_(),this.trigger("done","VideoSegmentStream");return}if(S=$s.groupNalsIntoFrames(d),A=$s.groupFramesIntoGops(S),A[0][0].keyFrame||(I=this.getGopForFusion_(d[0],o),I?(q=I.duration,A.unshift(I),A.byteLength+=I.byteLength,A.nalCount+=I.nalCount,A.pts=I.pts,A.dts=I.dts,A.duration+=I.duration):A=$s.extendFirstKeyFrame(A)),p.length){var ze;if(u.alignGopsAtEnd?ze=this.alignGopsAtEnd_(A):ze=this.alignGopsAtStart_(A),!ze){this.gopCache_.unshift({gop:A.pop(),pps:o.pps,sps:o.sps}),this.gopCache_.length=Math.min(6,this.gopCache_.length),d=[],this.resetStream_(),this.trigger("done","VideoSegmentStream");return}Rt.clearDtsInfo(o),A=ze}Rt.collectDtsInfo(o,A),o.samples=$s.generateSampleTable(A),j=Fs.mdat($s.concatenateNalData(A)),o.baseMediaDecodeTime=Rt.calculateTrackBaseMediaDecodeTime(o,u.keepOriginalTimestamps),this.trigger("processedGopsInfo",A.map(function(gt){return{pts:gt.pts,dts:gt.dts,byteLength:gt.byteLength}})),te=A[0],ne=A[A.length-1],this.trigger("segmentTimingInfo",ga(o.baseMediaDecodeTime,te.dts,te.pts,ne.dts+ne.duration,ne.pts+ne.duration,q)),this.trigger("timingInfo",{start:A[0].pts,end:A[A.length-1].pts+A[A.length-1].duration}),this.gopCache_.unshift({gop:A.pop(),pps:o.pps,sps:o.sps}),this.gopCache_.length=Math.min(6,this.gopCache_.length),d=[],this.trigger("baseMediaDecodeTime",o.baseMediaDecodeTime),this.trigger("timelineStartInfo",o.timelineStartInfo),O=Fs.moof(c,[o]),Y=new Uint8Array(O.byteLength+j.byteLength),c++,Y.set(O),Y.set(j,O.byteLength),this.trigger("data",{track:o,boxes:Y}),this.resetStream_(),this.trigger("done","VideoSegmentStream")},this.reset=function(){this.resetStream_(),d=[],this.gopCache_.length=0,p.length=0,this.trigger("reset")},this.resetStream_=function(){Rt.clearDtsInfo(o),_=void 0,x=void 0},this.getGopForFusion_=function(S){var I=45e3,A=1e4,O=1/0,j,Y,q,te,ne;for(ne=0;ne<this.gopCache_.length;ne++)te=this.gopCache_[ne],q=te.gop,!(!(o.pps&&Rl(o.pps[0],te.pps[0]))||!(o.sps&&Rl(o.sps[0],te.sps[0])))&&(q.dts<o.timelineStartInfo.dts||(j=S.dts-q.dts-q.duration,j>=-A&&j<=I&&(!Y||O>j)&&(Y=te,O=j)));return Y?Y.gop:null},this.alignGopsAtStart_=function(S){var I,A,O,j,Y,q,te,ne;for(Y=S.byteLength,q=S.nalCount,te=S.duration,I=A=0;I<p.length&&A<S.length&&(O=p[I],j=S[A],O.pts!==j.pts);){if(j.pts>O.pts){I++;continue}A++,Y-=j.byteLength,q-=j.nalCount,te-=j.duration}return A===0?S:A===S.length?null:(ne=S.slice(A),ne.byteLength=Y,ne.duration=te,ne.nalCount=q,ne.pts=ne[0].pts,ne.dts=ne[0].dts,ne)},this.alignGopsAtEnd_=function(S){var I,A,O,j,Y,q;for(I=p.length-1,A=S.length-1,Y=null,q=!1;I>=0&&A>=0;){if(O=p[I],j=S[A],O.pts===j.pts){q=!0;break}if(O.pts>j.pts){I--;continue}I===p.length-1&&(Y=A),A--}if(!q&&Y===null)return null;var te;if(q?te=A:te=Y,te===0)return S;var ne=S.slice(te),ze=ne.reduce(function(gt,gi){return gt.byteLength+=gi.byteLength,gt.duration+=gi.duration,gt.nalCount+=gi.nalCount,gt},{byteLength:0,duration:0,nalCount:0});return ne.byteLength=ze.byteLength,ne.duration=ze.duration,ne.nalCount=ze.nalCount,ne.pts=ne[0].pts,ne.dts=ne[0].dts,ne},this.alignGopsWith=function(S){p=S}},js.prototype=new Hn,Di=function(o,u){this.numberOfTracks=0,this.metadataStream=u,o=o||{},typeof o.remux<"u"?this.remuxTracks=!!o.remux:this.remuxTracks=!0,typeof o.keepOriginalTimestamps=="boolean"?this.keepOriginalTimestamps=o.keepOriginalTimestamps:this.keepOriginalTimestamps=!1,this.pendingTracks=[],this.videoTrack=null,this.pendingBoxes=[],this.pendingCaptions=[],this.pendingMetadata=[],this.pendingBytes=0,this.emittedTracks=0,Di.prototype.init.call(this),this.push=function(c){if(c.content||c.text)return this.pendingCaptions.push(c);if(c.frames)return this.pendingMetadata.push(c);this.pendingTracks.push(c.track),this.pendingBytes+=c.boxes.byteLength,c.track.type==="video"&&(this.videoTrack=c.track,this.pendingBoxes.push(c.boxes)),c.track.type==="audio"&&(this.audioTrack=c.track,this.pendingBoxes.unshift(c.boxes))}},Di.prototype=new Hn,Di.prototype.flush=function(o){var u=0,c={captions:[],captionStreams:{},metadata:[],info:{}},d,p,_,x=0,S;if(this.pendingTracks.length<this.numberOfTracks){if(o!=="VideoSegmentStream"&&o!=="AudioSegmentStream")return;if(this.remuxTracks)return;if(this.pendingTracks.length===0){this.emittedTracks++,this.emittedTracks>=this.numberOfTracks&&(this.trigger("done"),this.emittedTracks=0);return}}if(this.videoTrack?(x=this.videoTrack.timelineStartInfo.pts,ma.forEach(function(I){c.info[I]=this.videoTrack[I]},this)):this.audioTrack&&(x=this.audioTrack.timelineStartInfo.pts,pa.forEach(function(I){c.info[I]=this.audioTrack[I]},this)),this.videoTrack||this.audioTrack){for(this.pendingTracks.length===1?c.type=this.pendingTracks[0].type:c.type="combined",this.emittedTracks+=this.pendingTracks.length,_=Fs.initSegment(this.pendingTracks),c.initSegment=new Uint8Array(_.byteLength),c.initSegment.set(_),c.data=new Uint8Array(this.pendingBytes),S=0;S<this.pendingBoxes.length;S++)c.data.set(this.pendingBoxes[S],u),u+=this.pendingBoxes[S].byteLength;for(S=0;S<this.pendingCaptions.length;S++)d=this.pendingCaptions[S],d.startTime=zn.metadataTsToSeconds(d.startPts,x,this.keepOriginalTimestamps),d.endTime=zn.metadataTsToSeconds(d.endPts,x,this.keepOriginalTimestamps),c.captionStreams[d.stream]=!0,c.captions.push(d);for(S=0;S<this.pendingMetadata.length;S++)p=this.pendingMetadata[S],p.cueTime=zn.metadataTsToSeconds(p.pts,x,this.keepOriginalTimestamps),c.metadata.push(p);for(c.metadata.dispatchType=this.metadataStream.dispatchType,this.pendingTracks.length=0,this.videoTrack=null,this.pendingBoxes.length=0,this.pendingCaptions.length=0,this.pendingBytes=0,this.pendingMetadata.length=0,this.trigger("data",c),S=0;S<c.captions.length;S++)d=c.captions[S],this.trigger("caption",d);for(S=0;S<c.metadata.length;S++)p=c.metadata[S],this.trigger("id3Frame",p)}this.emittedTracks>=this.numberOfTracks&&(this.trigger("done"),this.emittedTracks=0)},Di.prototype.setRemux=function(o){this.remuxTracks=o},Wn=function(o){var u=this,c=!0,d,p;Wn.prototype.init.call(this),o=o||{},this.baseMediaDecodeTime=o.baseMediaDecodeTime||0,this.transmuxPipeline_={},this.setupAacPipeline=function(){var _={};this.transmuxPipeline_=_,_.type="aac",_.metadataStream=new si.MetadataStream,_.aacStream=new Bp,_.audioTimestampRolloverStream=new si.TimestampRolloverStream("audio"),_.timedMetadataTimestampRolloverStream=new si.TimestampRolloverStream("timed-metadata"),_.adtsStream=new Ll,_.coalesceStream=new Di(o,_.metadataStream),_.headOfPipeline=_.aacStream,_.aacStream.pipe(_.audioTimestampRolloverStream).pipe(_.adtsStream),_.aacStream.pipe(_.timedMetadataTimestampRolloverStream).pipe(_.metadataStream).pipe(_.coalesceStream),_.metadataStream.on("timestamp",function(x){_.aacStream.setTimestamp(x.timeStamp)}),_.aacStream.on("data",function(x){x.type!=="timed-metadata"&&x.type!=="audio"||_.audioSegmentStream||(p=p||{timelineStartInfo:{baseMediaDecodeTime:u.baseMediaDecodeTime},codec:"adts",type:"audio"},_.coalesceStream.numberOfTracks++,_.audioSegmentStream=new Ki(p,o),_.audioSegmentStream.on("log",u.getLogTrigger_("audioSegmentStream")),_.audioSegmentStream.on("timingInfo",u.trigger.bind(u,"audioTimingInfo")),_.adtsStream.pipe(_.audioSegmentStream).pipe(_.coalesceStream),u.trigger("trackinfo",{hasAudio:!!p,hasVideo:!!d}))}),_.coalesceStream.on("data",this.trigger.bind(this,"data")),_.coalesceStream.on("done",this.trigger.bind(this,"done")),Ol(this,_)},this.setupTsPipeline=function(){var _={};this.transmuxPipeline_=_,_.type="ts",_.metadataStream=new si.MetadataStream,_.packetStream=new si.TransportPacketStream,_.parseStream=new si.TransportParseStream,_.elementaryStream=new si.ElementaryStream,_.timestampRolloverStream=new si.TimestampRolloverStream,_.adtsStream=new Ll,_.h264Stream=new Up,_.captionStream=new si.CaptionStream(o),_.coalesceStream=new Di(o,_.metadataStream),_.headOfPipeline=_.packetStream,_.packetStream.pipe(_.parseStream).pipe(_.elementaryStream).pipe(_.timestampRolloverStream),_.timestampRolloverStream.pipe(_.h264Stream),_.timestampRolloverStream.pipe(_.adtsStream),_.timestampRolloverStream.pipe(_.metadataStream).pipe(_.coalesceStream),_.h264Stream.pipe(_.captionStream).pipe(_.coalesceStream),_.elementaryStream.on("data",function(x){var S;if(x.type==="metadata"){for(S=x.tracks.length;S--;)!d&&x.tracks[S].type==="video"?(d=x.tracks[S],d.timelineStartInfo.baseMediaDecodeTime=u.baseMediaDecodeTime):!p&&x.tracks[S].type==="audio"&&(p=x.tracks[S],p.timelineStartInfo.baseMediaDecodeTime=u.baseMediaDecodeTime);d&&!_.videoSegmentStream&&(_.coalesceStream.numberOfTracks++,_.videoSegmentStream=new js(d,o),_.videoSegmentStream.on("log",u.getLogTrigger_("videoSegmentStream")),_.videoSegmentStream.on("timelineStartInfo",function(I){p&&!o.keepOriginalTimestamps&&(p.timelineStartInfo=I,_.audioSegmentStream.setEarliestDts(I.dts-u.baseMediaDecodeTime))}),_.videoSegmentStream.on("processedGopsInfo",u.trigger.bind(u,"gopInfo")),_.videoSegmentStream.on("segmentTimingInfo",u.trigger.bind(u,"videoSegmentTimingInfo")),_.videoSegmentStream.on("baseMediaDecodeTime",function(I){p&&_.audioSegmentStream.setVideoBaseMediaDecodeTime(I)}),_.videoSegmentStream.on("timingInfo",u.trigger.bind(u,"videoTimingInfo")),_.h264Stream.pipe(_.videoSegmentStream).pipe(_.coalesceStream)),p&&!_.audioSegmentStream&&(_.coalesceStream.numberOfTracks++,_.audioSegmentStream=new Ki(p,o),_.audioSegmentStream.on("log",u.getLogTrigger_("audioSegmentStream")),_.audioSegmentStream.on("timingInfo",u.trigger.bind(u,"audioTimingInfo")),_.audioSegmentStream.on("segmentTimingInfo",u.trigger.bind(u,"audioSegmentTimingInfo")),_.adtsStream.pipe(_.audioSegmentStream).pipe(_.coalesceStream)),u.trigger("trackinfo",{hasAudio:!!p,hasVideo:!!d})}}),_.coalesceStream.on("data",this.trigger.bind(this,"data")),_.coalesceStream.on("id3Frame",function(x){x.dispatchType=_.metadataStream.dispatchType,u.trigger("id3Frame",x)}),_.coalesceStream.on("caption",this.trigger.bind(this,"caption")),_.coalesceStream.on("done",this.trigger.bind(this,"done")),Ol(this,_)},this.setBaseMediaDecodeTime=function(_){var x=this.transmuxPipeline_;o.keepOriginalTimestamps||(this.baseMediaDecodeTime=_),p&&(p.timelineStartInfo.dts=void 0,p.timelineStartInfo.pts=void 0,Rt.clearDtsInfo(p),x.audioTimestampRolloverStream&&x.audioTimestampRolloverStream.discontinuity()),d&&(x.videoSegmentStream&&(x.videoSegmentStream.gopCache_=[]),d.timelineStartInfo.dts=void 0,d.timelineStartInfo.pts=void 0,Rt.clearDtsInfo(d),x.captionStream.reset()),x.timestampRolloverStream&&x.timestampRolloverStream.discontinuity()},this.setAudioAppendStart=function(_){p&&this.transmuxPipeline_.audioSegmentStream.setAudioAppendStart(_)},this.setRemux=function(_){var x=this.transmuxPipeline_;o.remux=_,x&&x.coalesceStream&&x.coalesceStream.setRemux(_)},this.alignGopsWith=function(_){d&&this.transmuxPipeline_.videoSegmentStream&&this.transmuxPipeline_.videoSegmentStream.alignGopsWith(_)},this.getLogTrigger_=function(_){var x=this;return function(S){S.stream=_,x.trigger("log",S)}},this.push=function(_){if(c){var x=Fp(_);x&&this.transmuxPipeline_.type!=="aac"?this.setupAacPipeline():!x&&this.transmuxPipeline_.type!=="ts"&&this.setupTsPipeline(),c=!1}this.transmuxPipeline_.headOfPipeline.push(_)},this.flush=function(){c=!0,this.transmuxPipeline_.headOfPipeline.flush()},this.endTimeline=function(){this.transmuxPipeline_.headOfPipeline.endTimeline()},this.reset=function(){this.transmuxPipeline_.headOfPipeline&&this.transmuxPipeline_.headOfPipeline.reset()},this.resetCaptions=function(){this.transmuxPipeline_.captionStream&&this.transmuxPipeline_.captionStream.reset()}},Wn.prototype=new Hn;var Vp={Transmuxer:Wn,VideoSegmentStream:js,AudioSegmentStream:Ki,AUDIO_PROPERTIES:pa,VIDEO_PROPERTIES:ma,generateSegmentTimingInfo:ga},Hp=function(o){return o>>>0},qp=function(o){return("00"+o.toString(16)).slice(-2)},Gn={toUnsigned:Hp,toHexString:qp},zp=function(o){var u="";return u+=String.fromCharCode(o[0]),u+=String.fromCharCode(o[1]),u+=String.fromCharCode(o[2]),u+=String.fromCharCode(o[3]),u},ya=zp,Wp=Gn.toUnsigned,Gp=ya,Ml=function(o,u){var c=[],d,p,_,x,S;if(!u.length)return null;for(d=0;d<o.byteLength;)p=Wp(o[d]<<24|o[d+1]<<16|o[d+2]<<8|o[d+3]),_=Gp(o.subarray(d+4,d+8)),x=p>1?d+p:o.byteLength,_===u[0]&&(u.length===1?c.push(o.subarray(d+8,x)):(S=Ml(o.subarray(d+8,x),u.slice(1)),S.length&&(c=c.concat(S)))),d=x;return c},Kn=Ml,Kp=Gn.toUnsigned,Xp=r.getUint64,Yp=function(o){var u={version:o[0],flags:new Uint8Array(o.subarray(1,4))};return u.version===1?u.baseMediaDecodeTime=Xp(o.subarray(4)):u.baseMediaDecodeTime=Kp(o[4]<<24|o[5]<<16|o[6]<<8|o[7]),u},_a=Yp,Qp=function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),c={version:o[0],flags:new Uint8Array(o.subarray(1,4)),trackId:u.getUint32(4)},d=c.flags[2]&1,p=c.flags[2]&2,_=c.flags[2]&8,x=c.flags[2]&16,S=c.flags[2]&32,I=c.flags[0]&65536,A=c.flags[0]&131072,O;return O=8,d&&(O+=4,c.baseDataOffset=u.getUint32(12),O+=4),p&&(c.sampleDescriptionIndex=u.getUint32(O),O+=4),_&&(c.defaultSampleDuration=u.getUint32(O),O+=4),x&&(c.defaultSampleSize=u.getUint32(O),O+=4),S&&(c.defaultSampleFlags=u.getUint32(O)),I&&(c.durationIsEmpty=!0),!d&&A&&(c.baseDataOffsetIsMoof=!0),c},Ta=Qp,Nl=r.getUint64,Jp=function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),c={version:o[0],flags:new Uint8Array(o.subarray(1,4)),references:[],referenceId:u.getUint32(4),timescale:u.getUint32(8)},d=12;c.version===0?(c.earliestPresentationTime=u.getUint32(d),c.firstOffset=u.getUint32(d+4),d+=8):(c.earliestPresentationTime=Nl(o.subarray(d)),c.firstOffset=Nl(o.subarray(d+8)),d+=16),d+=2;var p=u.getUint16(d);for(d+=2;p>0;d+=12,p--)c.references.push({referenceType:(o[d]&128)>>>7,referencedSize:u.getUint32(d)&2147483647,subsegmentDuration:u.getUint32(d+4),startsWithSap:!!(o[d+8]&128),sapType:(o[d+8]&112)>>>4,sapDeltaTime:u.getUint32(d+8)&268435455});return c},Zp=Jp,em=function(o){return{isLeading:(o[0]&12)>>>2,dependsOn:o[0]&3,isDependedOn:(o[1]&192)>>>6,hasRedundancy:(o[1]&48)>>>4,paddingValue:(o[1]&14)>>>1,isNonSyncSample:o[1]&1,degradationPriority:o[2]<<8|o[3]}},tm=em,Ul=tm,im=function(o){var u={version:o[0],flags:new Uint8Array(o.subarray(1,4)),samples:[]},c=new DataView(o.buffer,o.byteOffset,o.byteLength),d=u.flags[2]&1,p=u.flags[2]&4,_=u.flags[1]&1,x=u.flags[1]&2,S=u.flags[1]&4,I=u.flags[1]&8,A=c.getUint32(4),O=8,j;for(d&&(u.dataOffset=c.getInt32(O),O+=4),p&&A&&(j={flags:Ul(o.subarray(O,O+4))},O+=4,_&&(j.duration=c.getUint32(O),O+=4),x&&(j.size=c.getUint32(O),O+=4),I&&(u.version===1?j.compositionTimeOffset=c.getInt32(O):j.compositionTimeOffset=c.getUint32(O),O+=4),u.samples.push(j),A--);A--;)j={},_&&(j.duration=c.getUint32(O),O+=4),x&&(j.size=c.getUint32(O),O+=4),S&&(j.flags=Ul(o.subarray(O,O+4)),O+=4),I&&(u.version===1?j.compositionTimeOffset=c.getInt32(O):j.compositionTimeOffset=c.getUint32(O),O+=4),u.samples.push(j);return u},Bl=im,sm=r,Fl=sm.getUint64,Je,va,Et=function(o){return new Date(o*1e3-20828448e5)},Vs=ya,nm=Kn,rm=function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),c=[],d,p;for(d=0;d+4<o.length;d+=p){if(p=u.getUint32(d),d+=4,p<=0){c.push("<span style='color:red;'>MALFORMED DATA</span>");continue}switch(o[d]&31){case 1:c.push("slice_layer_without_partitioning_rbsp");break;case 5:c.push("slice_layer_without_partitioning_rbsp_idr");break;case 6:c.push("sei_rbsp");break;case 7:c.push("seq_parameter_set_rbsp");break;case 8:c.push("pic_parameter_set_rbsp");break;case 9:c.push("access_unit_delimiter_rbsp");break;default:c.push("UNKNOWN NAL - "+o[d]&31);break}}return c},pi={avc1:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength);return{dataReferenceIndex:u.getUint16(6),width:u.getUint16(24),height:u.getUint16(26),horizresolution:u.getUint16(28)+u.getUint16(30)/16,vertresolution:u.getUint16(32)+u.getUint16(34)/16,frameCount:u.getUint16(40),depth:u.getUint16(74),config:Je(o.subarray(78,o.byteLength))}},avcC:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),c={configurationVersion:o[0],avcProfileIndication:o[1],profileCompatibility:o[2],avcLevelIndication:o[3],lengthSizeMinusOne:o[4]&3,sps:[],pps:[]},d=o[5]&31,p,_,x,S;for(x=6,S=0;S<d;S++)_=u.getUint16(x),x+=2,c.sps.push(new Uint8Array(o.subarray(x,x+_))),x+=_;for(p=o[x],x++,S=0;S<p;S++)_=u.getUint16(x),x+=2,c.pps.push(new Uint8Array(o.subarray(x,x+_))),x+=_;return c},btrt:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength);return{bufferSizeDB:u.getUint32(0),maxBitrate:u.getUint32(4),avgBitrate:u.getUint32(8)}},edts:function(u){return{boxes:Je(u)}},elst:function(u){var c=new DataView(u.buffer,u.byteOffset,u.byteLength),d={version:c.getUint8(0),flags:new Uint8Array(u.subarray(1,4)),edits:[]},p=c.getUint32(4),_;for(_=8;p;p--)d.version===0?(d.edits.push({segmentDuration:c.getUint32(_),mediaTime:c.getInt32(_+4),mediaRate:c.getUint16(_+8)+c.getUint16(_+10)/(256*256)}),_+=12):(d.edits.push({segmentDuration:Fl(u.subarray(_)),mediaTime:Fl(u.subarray(_+8)),mediaRate:c.getUint16(_+16)+c.getUint16(_+18)/(256*256)}),_+=20);return d},esds:function(o){return{version:o[0],flags:new Uint8Array(o.subarray(1,4)),esId:o[6]<<8|o[7],streamPriority:o[8]&31,decoderConfig:{objectProfileIndication:o[11],streamType:o[12]>>>2&63,bufferSize:o[13]<<16|o[14]<<8|o[15],maxBitrate:o[16]<<24|o[17]<<16|o[18]<<8|o[19],avgBitrate:o[20]<<24|o[21]<<16|o[22]<<8|o[23],decoderConfigDescriptor:{tag:o[24],length:o[25],audioObjectType:o[26]>>>3&31,samplingFrequencyIndex:(o[26]&7)<<1|o[27]>>>7&1,channelConfiguration:o[27]>>>3&15}}}},ftyp:function(o){for(var u=new DataView(o.buffer,o.byteOffset,o.byteLength),c={majorBrand:Vs(o.subarray(0,4)),minorVersion:u.getUint32(4),compatibleBrands:[]},d=8;d<o.byteLength;)c.compatibleBrands.push(Vs(o.subarray(d,d+4))),d+=4;return c},dinf:function(o){return{boxes:Je(o)}},dref:function(o){return{version:o[0],flags:new Uint8Array(o.subarray(1,4)),dataReferences:Je(o.subarray(8))}},hdlr:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),c={version:u.getUint8(0),flags:new Uint8Array(o.subarray(1,4)),handlerType:Vs(o.subarray(8,12)),name:""},d=8;for(d=24;d<o.byteLength;d++){if(o[d]===0){d++;break}c.name+=String.fromCharCode(o[d])}return c.name=decodeURIComponent(escape(c.name)),c},mdat:function(o){return{byteLength:o.byteLength,nals:rm(o)}},mdhd:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),c=4,d,p={version:u.getUint8(0),flags:new Uint8Array(o.subarray(1,4)),language:""};return p.version===1?(c+=4,p.creationTime=Et(u.getUint32(c)),c+=8,p.modificationTime=Et(u.getUint32(c)),c+=4,p.timescale=u.getUint32(c),c+=8,p.duration=u.getUint32(c)):(p.creationTime=Et(u.getUint32(c)),c+=4,p.modificationTime=Et(u.getUint32(c)),c+=4,p.timescale=u.getUint32(c),c+=4,p.duration=u.getUint32(c)),c+=4,d=u.getUint16(c),p.language+=String.fromCharCode((d>>10)+96),p.language+=String.fromCharCode(((d&992)>>5)+96),p.language+=String.fromCharCode((d&31)+96),p},mdia:function(o){return{boxes:Je(o)}},mfhd:function(o){return{version:o[0],flags:new Uint8Array(o.subarray(1,4)),sequenceNumber:o[4]<<24|o[5]<<16|o[6]<<8|o[7]}},minf:function(o){return{boxes:Je(o)}},mp4a:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),c={dataReferenceIndex:u.getUint16(6),channelcount:u.getUint16(16),samplesize:u.getUint16(18),samplerate:u.getUint16(24)+u.getUint16(26)/65536};return o.byteLength>28&&(c.streamDescriptor=Je(o.subarray(28))[0]),c},moof:function(o){return{boxes:Je(o)}},moov:function(o){return{boxes:Je(o)}},mvex:function(o){return{boxes:Je(o)}},mvhd:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),c=4,d={version:u.getUint8(0),flags:new Uint8Array(o.subarray(1,4))};return d.version===1?(c+=4,d.creationTime=Et(u.getUint32(c)),c+=8,d.modificationTime=Et(u.getUint32(c)),c+=4,d.timescale=u.getUint32(c),c+=8,d.duration=u.getUint32(c)):(d.creationTime=Et(u.getUint32(c)),c+=4,d.modificationTime=Et(u.getUint32(c)),c+=4,d.timescale=u.getUint32(c),c+=4,d.duration=u.getUint32(c)),c+=4,d.rate=u.getUint16(c)+u.getUint16(c+2)/16,c+=4,d.volume=u.getUint8(c)+u.getUint8(c+1)/8,c+=2,c+=2,c+=2*4,d.matrix=new Uint32Array(o.subarray(c,c+9*4)),c+=9*4,c+=6*4,d.nextTrackId=u.getUint32(c),d},pdin:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength);return{version:u.getUint8(0),flags:new Uint8Array(o.subarray(1,4)),rate:u.getUint32(4),initialDelay:u.getUint32(8)}},sdtp:function(o){var u={version:o[0],flags:new Uint8Array(o.subarray(1,4)),samples:[]},c;for(c=4;c<o.byteLength;c++)u.samples.push({dependsOn:(o[c]&48)>>4,isDependedOn:(o[c]&12)>>2,hasRedundancy:o[c]&3});return u},sidx:Zp,smhd:function(o){return{version:o[0],flags:new Uint8Array(o.subarray(1,4)),balance:o[4]+o[5]/256}},stbl:function(o){return{boxes:Je(o)}},ctts:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),c={version:u.getUint8(0),flags:new Uint8Array(o.subarray(1,4)),compositionOffsets:[]},d=u.getUint32(4),p;for(p=8;d;p+=8,d--)c.compositionOffsets.push({sampleCount:u.getUint32(p),sampleOffset:u[c.version===0?"getUint32":"getInt32"](p+4)});return c},stss:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),c={version:u.getUint8(0),flags:new Uint8Array(o.subarray(1,4)),syncSamples:[]},d=u.getUint32(4),p;for(p=8;d;p+=4,d--)c.syncSamples.push(u.getUint32(p));return c},stco:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),c={version:o[0],flags:new Uint8Array(o.subarray(1,4)),chunkOffsets:[]},d=u.getUint32(4),p;for(p=8;d;p+=4,d--)c.chunkOffsets.push(u.getUint32(p));return c},stsc:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),c=u.getUint32(4),d={version:o[0],flags:new Uint8Array(o.subarray(1,4)),sampleToChunks:[]},p;for(p=8;c;p+=12,c--)d.sampleToChunks.push({firstChunk:u.getUint32(p),samplesPerChunk:u.getUint32(p+4),sampleDescriptionIndex:u.getUint32(p+8)});return d},stsd:function(o){return{version:o[0],flags:new Uint8Array(o.subarray(1,4)),sampleDescriptions:Je(o.subarray(8))}},stsz:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),c={version:o[0],flags:new Uint8Array(o.subarray(1,4)),sampleSize:u.getUint32(4),entries:[]},d;for(d=12;d<o.byteLength;d+=4)c.entries.push(u.getUint32(d));return c},stts:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),c={version:o[0],flags:new Uint8Array(o.subarray(1,4)),timeToSamples:[]},d=u.getUint32(4),p;for(p=8;d;p+=8,d--)c.timeToSamples.push({sampleCount:u.getUint32(p),sampleDelta:u.getUint32(p+4)});return c},styp:function(o){return pi.ftyp(o)},tfdt:_a,tfhd:Ta,tkhd:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),c=4,d={version:u.getUint8(0),flags:new Uint8Array(o.subarray(1,4))};return d.version===1?(c+=4,d.creationTime=Et(u.getUint32(c)),c+=8,d.modificationTime=Et(u.getUint32(c)),c+=4,d.trackId=u.getUint32(c),c+=4,c+=8,d.duration=u.getUint32(c)):(d.creationTime=Et(u.getUint32(c)),c+=4,d.modificationTime=Et(u.getUint32(c)),c+=4,d.trackId=u.getUint32(c),c+=4,c+=4,d.duration=u.getUint32(c)),c+=4,c+=2*4,d.layer=u.getUint16(c),c+=2,d.alternateGroup=u.getUint16(c),c+=2,d.volume=u.getUint8(c)+u.getUint8(c+1)/8,c+=2,c+=2,d.matrix=new Uint32Array(o.subarray(c,c+9*4)),c+=9*4,d.width=u.getUint16(c)+u.getUint16(c+2)/65536,c+=4,d.height=u.getUint16(c)+u.getUint16(c+2)/65536,d},traf:function(o){return{boxes:Je(o)}},trak:function(o){return{boxes:Je(o)}},trex:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength);return{version:o[0],flags:new Uint8Array(o.subarray(1,4)),trackId:u.getUint32(4),defaultSampleDescriptionIndex:u.getUint32(8),defaultSampleDuration:u.getUint32(12),defaultSampleSize:u.getUint32(16),sampleDependsOn:o[20]&3,sampleIsDependedOn:(o[21]&192)>>6,sampleHasRedundancy:(o[21]&48)>>4,samplePaddingValue:(o[21]&14)>>1,sampleIsDifferenceSample:!!(o[21]&1),sampleDegradationPriority:u.getUint16(22)}},trun:Bl,"url ":function(o){return{version:o[0],flags:new Uint8Array(o.subarray(1,4))}},vmhd:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength);return{version:o[0],flags:new Uint8Array(o.subarray(1,4)),graphicsmode:u.getUint16(4),opcolor:new Uint16Array([u.getUint16(6),u.getUint16(8),u.getUint16(10)])}}};Je=function(o){for(var u=0,c=[],d,p,_,x,S,I=new ArrayBuffer(o.length),A=new Uint8Array(I),O=0;O<o.length;++O)A[O]=o[O];for(d=new DataView(I);u<o.byteLength;)p=d.getUint32(u),_=Vs(o.subarray(u+4,u+8)),x=p>1?u+p:o.byteLength,S=(pi[_]||function(j){return{data:j}})(o.subarray(u+8,x)),S.size=p,S.type=_,c.push(S),u=x;return c},va=function(o,u){var c;return u=u||0,c=new Array(u*2+1).join(" "),o.map(function(d,p){return c+d.type+`
|
|
196
|
+
`+Object.keys(d).filter(function(_){return _!=="type"&&_!=="boxes"}).map(function(_){var x=c+" "+_+": ",S=d[_];if(S instanceof Uint8Array||S instanceof Uint32Array){var I=Array.prototype.slice.call(new Uint8Array(S.buffer,S.byteOffset,S.byteLength)).map(function(A){return" "+("00"+A.toString(16)).slice(-2)}).join("").match(/.{1,24}/g);return I?I.length===1?x+"<"+I.join("").slice(1)+">":x+`<
|
|
197
|
+
`+I.map(function(A){return c+" "+A}).join(`
|
|
198
198
|
`)+`
|
|
199
|
-
`+
|
|
200
|
-
`).map(function(
|
|
199
|
+
`+c+" >":x+"<>"}return x+JSON.stringify(S,null,2).split(`
|
|
200
|
+
`).map(function(A,O){return O===0?A:c+" "+A}).join(`
|
|
201
201
|
`)}).join(`
|
|
202
|
-
`)+(
|
|
203
|
-
`+
|
|
204
|
-
`)};var Bl={inspect:Qe,textify:ya,parseType:$n,findBox:nf,parseTraf:ci.traf,parseTfdt:ci.tfdt,parseHdlr:ci.hdlr,parseTfhd:ci.tfhd,parseTrun:ci.trun,parseSidx:ci.sidx},rf=function(o){for(var u=0,d=String.fromCharCode(o[u]),h="";d!=="\0";)h+=d,u++,d=String.fromCharCode(o[u]);return h+=d,h},af={uint8ToCString:rf},zs=af.uint8ToCString,of=r.getUint64,lf=function(o){var u=4,d=o[0],h,g,y,S,E,k,I,O;if(d===0){h=zs(o.subarray(u)),u+=h.length,g=zs(o.subarray(u)),u+=g.length;var j=new DataView(o.buffer);y=j.getUint32(u),u+=4,E=j.getUint32(u),u+=4,k=j.getUint32(u),u+=4,I=j.getUint32(u),u+=4}else if(d===1){var j=new DataView(o.buffer);y=j.getUint32(u),u+=4,S=of(o.subarray(u)),u+=8,k=j.getUint32(u),u+=4,I=j.getUint32(u),u+=4,h=zs(o.subarray(u)),u+=h.length,g=zs(o.subarray(u)),u+=g.length}O=new Uint8Array(o.subarray(u,o.byteLength));var Q={scheme_id_uri:h,value:g,timescale:y||1,presentation_time:S,presentation_time_delta:E,event_duration:k,id:I,message_data:O};return df(d,Q)?Q:void 0},uf=function(o,u,d,h){return o||o===0?o/u:h+d/u},df=function(o,u){var d=u.scheme_id_uri!=="\0",h=o===0&&Fl(u.presentation_time_delta)&&d,g=o===1&&Fl(u.presentation_time)&&d;return!(o>1)&&h||g},Fl=function(o){return o!==void 0||o!==null},hf={parseEmsgBox:lf,scaleTime:uf},qn;typeof window<"u"?qn=window:typeof i<"u"?qn=i:typeof self<"u"?qn=self:qn={};var jl=qn,Ws=Vs.toUnsigned,Vn=Vs.toHexString,Be=Hs,Xi=ga,_a=hf,cf=ma,pf=Ul,gf=fa,ff=r.getUint64,$l,ql,Vl,Hl,zl,ba,Wl,Ta=jl,mf=Tl.parseId3Frames;$l=function(o){var u={},d=Be(o,["moov","trak"]);return d.reduce(function(h,g){var y,S,E,k,I;return y=Be(g,["tkhd"])[0],!y||(S=y[0],E=S===0?12:20,k=Ws(y[E]<<24|y[E+1]<<16|y[E+2]<<8|y[E+3]),I=Be(g,["mdia","mdhd"])[0],!I)?null:(S=I[0],E=S===0?12:20,h[k]=Ws(I[E]<<24|I[E+1]<<16|I[E+2]<<8|I[E+3]),h)},u)},ql=function(o,u){var d;d=Be(u,["moof","traf"]);var h=d.reduce(function(g,y){var S=Be(y,["tfhd"])[0],E=Ws(S[4]<<24|S[5]<<16|S[6]<<8|S[7]),k=o[E]||9e4,I=Be(y,["tfdt"])[0],O=new DataView(I.buffer,I.byteOffset,I.byteLength),j;I[0]===1?j=ff(I.subarray(4,12)):j=O.getUint32(4);let Q;return typeof j=="bigint"?Q=j/Ta.BigInt(k):typeof j=="number"&&!isNaN(j)&&(Q=j/k),Q<Number.MAX_SAFE_INTEGER&&(Q=Number(Q)),Q<g&&(g=Q),g},1/0);return typeof h=="bigint"||isFinite(h)?h:0},Vl=function(o,u){var d=Be(u,["moof","traf"]),h=0,g=0,y;if(d&&d.length){var S=Be(d[0],["tfhd"])[0],E=Be(d[0],["trun"])[0],k=Be(d[0],["tfdt"])[0];if(S){var I=cf(S);y=I.trackId}if(k){var O=gf(k);h=O.baseMediaDecodeTime}if(E){var j=pf(E);j.samples&&j.samples.length&&(g=j.samples[0].compositionTimeOffset||0)}}var Q=o[y]||9e4;typeof h=="bigint"&&(g=Ta.BigInt(g),Q=Ta.BigInt(Q));var V=(h+g)/Q;return typeof V=="bigint"&&V<Number.MAX_SAFE_INTEGER&&(V=Number(V)),V},Hl=function(o){var u=Be(o,["moov","trak"]),d=[];return u.forEach(function(h){var g=Be(h,["mdia","hdlr"]),y=Be(h,["tkhd"]);g.forEach(function(S,E){var k=Xi(S.subarray(8,12)),I=y[E],O,j,Q;k==="vide"&&(O=new DataView(I.buffer,I.byteOffset,I.byteLength),j=O.getUint8(0),Q=j===0?O.getUint32(12):O.getUint32(20),d.push(Q))})}),d},ba=function(o){var u=o[0],d=u===0?12:20;return Ws(o[d]<<24|o[d+1]<<16|o[d+2]<<8|o[d+3])},zl=function(o){var u=Be(o,["moov","trak"]),d=[];return u.forEach(function(h){var g={},y=Be(h,["tkhd"])[0],S,E;y&&(S=new DataView(y.buffer,y.byteOffset,y.byteLength),E=S.getUint8(0),g.id=E===0?S.getUint32(12):S.getUint32(20));var k=Be(h,["mdia","hdlr"])[0];if(k){var I=Xi(k.subarray(8,12));I==="vide"?g.type="video":I==="soun"?g.type="audio":g.type=I}var O=Be(h,["mdia","minf","stbl","stsd"])[0];if(O){var j=O.subarray(8);g.codec=Xi(j.subarray(4,8));var Q=Be(j,[g.codec])[0],V,te;Q&&(/^[asm]vc[1-9]$/i.test(g.codec)?(V=Q.subarray(78),te=Xi(V.subarray(4,8)),te==="avcC"&&V.length>11?(g.codec+=".",g.codec+=Vn(V[9]),g.codec+=Vn(V[10]),g.codec+=Vn(V[11])):g.codec="avc1.4d400d"):/^mp4[a,v]$/i.test(g.codec)?(V=Q.subarray(28),te=Xi(V.subarray(4,8)),te==="esds"&&V.length>20&&V[19]!==0?(g.codec+="."+Vn(V[19]),g.codec+="."+Vn(V[20]>>>2&63).replace(/^0/,"")):g.codec="mp4a.40.2"):g.codec=g.codec.toLowerCase())}var se=Be(h,["mdia","mdhd"])[0];se&&(g.timescale=ba(se)),d.push(g)}),d},Wl=function(o,u=0){var d=Be(o,["emsg"]);return d.map(h=>{var g=_a.parseEmsgBox(new Uint8Array(h)),y=mf(g.message_data);return{cueTime:_a.scaleTime(g.presentation_time,g.timescale,g.presentation_time_delta,u),duration:_a.scaleTime(g.event_duration,g.timescale),frames:y}})};var Hn={findBox:Be,parseType:Xi,timescale:$l,startTime:ql,compositionStartTime:Vl,videoTrackIds:Hl,tracks:zl,getTimescaleFromMediaHeader:ba,getEmsgID3:Wl};const{parseTrun:yf}=Bl,{findBox:Gl}=Hn;var Xl=jl,_f=function(o){var u=Gl(o,["moof","traf"]),d=Gl(o,["mdat"]),h=[];return d.forEach(function(g,y){var S=u[y];h.push({mdat:g,traf:S})}),h},bf=function(o,u,d){var h=u,g=d.defaultSampleDuration||0,y=d.defaultSampleSize||0,S=d.trackId,E=[];return o.forEach(function(k){var I=yf(k),O=I.samples;O.forEach(function(j){j.duration===void 0&&(j.duration=g),j.size===void 0&&(j.size=y),j.trackId=S,j.dts=h,j.compositionTimeOffset===void 0&&(j.compositionTimeOffset=0),typeof h=="bigint"?(j.pts=h+Xl.BigInt(j.compositionTimeOffset),h+=Xl.BigInt(j.duration)):(j.pts=h+j.compositionTimeOffset,h+=j.duration)}),E=E.concat(O)}),E},Kl={getMdatTrafPairs:_f,parseSamples:bf},Tf=fl.discardEmulationPreventionBytes,vf=ml.CaptionStream,va=Hs,Sf=fa,Ef=ma,{getMdatTrafPairs:wf,parseSamples:kf}=Kl,Cf=function(o,u){for(var d=o,h=0;h<u.length;h++){var g=u[h];if(d<g.size)return g;d-=g.size}return null},If=function(o,u,d){var h=new DataView(o.buffer,o.byteOffset,o.byteLength),g={logs:[],seiNals:[]},y,S,E,k;for(S=0;S+4<o.length;S+=E)if(E=h.getUint32(S),S+=4,!(E<=0))switch(o[S]&31){case 6:var I=o.subarray(S+1,S+1+E),O=Cf(S,u);if(y={nalUnitType:"sei_rbsp",size:E,data:I,escapedRBSP:Tf(I),trackId:d},O)y.pts=O.pts,y.dts=O.dts,k=O;else if(k)y.pts=k.pts,y.dts=k.dts;else{g.logs.push({level:"warn",message:"We've encountered a nal unit without data at "+S+" for trackId "+d+". See mux.js#223."});break}g.seiNals.push(y);break}return g},xf=function(o,u){var d={},h=wf(o);return h.forEach(function(g){var y=g.mdat,S=g.traf,E=va(S,["tfhd"]),k=Ef(E[0]),I=k.trackId,O=va(S,["tfdt"]),j=O.length>0?Sf(O[0]).baseMediaDecodeTime:0,Q=va(S,["trun"]),V,te;u===I&&Q.length>0&&(V=kf(Q,j,k),te=If(y,V,I),d[I]||(d[I]={seiNals:[],logs:[]}),d[I].seiNals=d[I].seiNals.concat(te.seiNals),d[I].logs=d[I].logs.concat(te.logs))}),d},Af=function(o,u,d){var h;if(u===null)return null;h=xf(o,u);var g=h[u]||{};return{seiNals:g.seiNals,logs:g.logs,timescale:d}},Pf=function(){var o=!1,u,d,h,g,y,S;this.isInitialized=function(){return o},this.init=function(E){u=new vf,o=!0,S=E?E.isPartial:!1,u.on("data",function(k){k.startTime=k.startPts/g,k.endTime=k.endPts/g,y.captions.push(k),y.captionStreams[k.stream]=!0}),u.on("log",function(k){y.logs.push(k)})},this.isNewInit=function(E,k){return E&&E.length===0||k&&typeof k=="object"&&Object.keys(k).length===0?!1:h!==E[0]||g!==k[h]},this.parse=function(E,k,I){var O;if(this.isInitialized()){if(!k||!I)return null;if(this.isNewInit(k,I))h=k[0],g=I[h];else if(h===null||!g)return d.push(E),null}else return null;for(;d.length>0;){var j=d.shift();this.parse(j,k,I)}return O=Af(E,h,g),O&&O.logs&&(y.logs=y.logs.concat(O.logs)),O===null||!O.seiNals?y.logs.length?{logs:y.logs,captions:[],captionStreams:[]}:null:(this.pushNals(O.seiNals),this.flushStream(),y)},this.pushNals=function(E){if(!this.isInitialized()||!E||E.length===0)return null;E.forEach(function(k){u.push(k)})},this.flushStream=function(){if(!this.isInitialized())return null;S?u.partialFlush():u.flush()},this.clearParsedCaptions=function(){y.captions=[],y.captionStreams={},y.logs=[]},this.resetCaptionStream=function(){if(!this.isInitialized())return null;u.reset()},this.clearAllCaptions=function(){this.clearParsedCaptions(),this.resetCaptionStream()},this.reset=function(){d=[],h=null,g=null,y?this.clearParsedCaptions():y={captions:[],captionStreams:{},logs:[]},this.resetCaptionStream()},this.reset()},Lf=Pf;const{parseTfdt:Df}=Bl,pi=Hs,{getTimescaleFromMediaHeader:Of}=Hn,{parseSamples:Mf,getMdatTrafPairs:Rf}=Kl;var Yl=function(){let o=9e4;this.init=function(u){const d=pi(u,["moov","trak","mdia","mdhd"])[0];d&&(o=Of(d))},this.parseSegment=function(u){const d=[],h=Rf(u);let g=0;return h.forEach(function(y){const S=y.mdat,E=y.traf,k=pi(E,["tfdt"])[0],I=pi(E,["tfhd"])[0],O=pi(E,["trun"]);if(k&&(g=Df(k).baseMediaDecodeTime),O.length&&I){const j=Mf(O,g,I);let Q=0;j.forEach(function(V){const te="utf-8",se=new TextDecoder(te),ze=S.slice(Q,Q+V.size);if(pi(ze,["vtte"])[0]){Q+=V.size;return}pi(ze,["vttc"]).forEach(function(nt){const qt=pi(nt,["payl"])[0],zn=pi(nt,["sttg"])[0],Ks=V.pts/o,Ys=(V.pts+V.duration)/o;let Pi,Wn;if(qt)try{Pi=se.decode(qt)}catch(Ie){console.error(Ie)}if(zn)try{Wn=se.decode(zn)}catch(Ie){console.error(Ie)}V.duration&&Pi&&d.push({cueText:Pi,start:Ks,end:Ys,settings:Wn})}),Q+=V.size})}}),d}},Sa=Ps,Ql=function(o){var u=o[1]&31;return u<<=8,u|=o[2],u},Gs=function(o){return!!(o[1]&64)},Xs=function(o){var u=0;return(o[3]&48)>>>4>1&&(u+=o[4]+1),u},Uf=function(o,u){var d=Ql(o);return d===0?"pat":d===u?"pmt":u?"pes":null},Nf=function(o){var u=Gs(o),d=4+Xs(o);return u&&(d+=o[d]+1),(o[d+10]&31)<<8|o[d+11]},Bf=function(o){var u={},d=Gs(o),h=4+Xs(o);if(d&&(h+=o[h]+1),!!(o[h+5]&1)){var g,y,S;g=(o[h+1]&15)<<8|o[h+2],y=3+g-4,S=(o[h+10]&15)<<8|o[h+11];for(var E=12+S;E<y;){var k=h+E;u[(o[k+1]&31)<<8|o[k+2]]=o[k],E+=((o[k+3]&15)<<8|o[k+4])+5}return u}},Ff=function(o,u){var d=Ql(o),h=u[d];switch(h){case Sa.H264_STREAM_TYPE:return"video";case Sa.ADTS_STREAM_TYPE:return"audio";case Sa.METADATA_STREAM_TYPE:return"timed-metadata";default:return null}},jf=function(o){var u=Gs(o);if(!u)return null;var d=4+Xs(o);if(d>=o.byteLength)return null;var h=null,g;return g=o[d+7],g&192&&(h={},h.pts=(o[d+9]&14)<<27|(o[d+10]&255)<<20|(o[d+11]&254)<<12|(o[d+12]&255)<<5|(o[d+13]&254)>>>3,h.pts*=4,h.pts+=(o[d+13]&6)>>>1,h.dts=h.pts,g&64&&(h.dts=(o[d+14]&14)<<27|(o[d+15]&255)<<20|(o[d+16]&254)<<12|(o[d+17]&255)<<5|(o[d+18]&254)>>>3,h.dts*=4,h.dts+=(o[d+18]&6)>>>1)),h},Ea=function(o){switch(o){case 5:return"slice_layer_without_partitioning_rbsp_idr";case 6:return"sei_rbsp";case 7:return"seq_parameter_set_rbsp";case 8:return"pic_parameter_set_rbsp";case 9:return"access_unit_delimiter_rbsp";default:return null}},$f=function(o){for(var u=4+Xs(o),d=o.subarray(u),h=0,g=0,y=!1,S;g<d.byteLength-3;g++)if(d[g+2]===1){h=g+5;break}for(;h<d.byteLength;)switch(d[h]){case 0:if(d[h-1]!==0){h+=2;break}else if(d[h-2]!==0){h++;break}g+3!==h-2&&(S=Ea(d[g+3]&31),S==="slice_layer_without_partitioning_rbsp_idr"&&(y=!0));do h++;while(d[h]!==1&&h<d.length);g=h-2,h+=3;break;case 1:if(d[h-1]!==0||d[h-2]!==0){h+=3;break}S=Ea(d[g+3]&31),S==="slice_layer_without_partitioning_rbsp_idr"&&(y=!0),g=h-2,h+=3;break;default:h+=3;break}return d=d.subarray(g),h-=g,g=0,d&&d.byteLength>3&&(S=Ea(d[g+3]&31),S==="slice_layer_without_partitioning_rbsp_idr"&&(y=!0)),y},qf={parseType:Uf,parsePat:Nf,parsePmt:Bf,parsePayloadUnitStartIndicator:Gs,parsePesType:Ff,parsePesTime:jf,videoPacketContainsKeyFrame:$f},Jl=Ps,Ki=_l.handleRollover,ye={};ye.ts=qf,ye.aac=da;var Ai=T.ONE_SECOND_IN_TS,it=188,$t=71,Vf=function(o,u){for(var d=0,h=it,g,y;h<o.byteLength;){if(o[d]===$t&&o[h]===$t){switch(g=o.subarray(d,h),y=ye.ts.parseType(g,u.pid),y){case"pat":u.pid=ye.ts.parsePat(g);break;case"pmt":var S=ye.ts.parsePmt(g);u.table=u.table||{},Object.keys(S).forEach(function(E){u.table[E]=S[E]});break}d+=it,h+=it;continue}d++,h++}},Zl=function(o,u,d){for(var h=0,g=it,y,S,E,k,I,O=!1;g<=o.byteLength;){if(o[h]===$t&&(o[g]===$t||g===o.byteLength)){switch(y=o.subarray(h,g),S=ye.ts.parseType(y,u.pid),S){case"pes":E=ye.ts.parsePesType(y,u.table),k=ye.ts.parsePayloadUnitStartIndicator(y),E==="audio"&&k&&(I=ye.ts.parsePesTime(y),I&&(I.type="audio",d.audio.push(I),O=!0));break}if(O)break;h+=it,g+=it;continue}h++,g++}for(g=o.byteLength,h=g-it,O=!1;h>=0;){if(o[h]===$t&&(o[g]===$t||g===o.byteLength)){switch(y=o.subarray(h,g),S=ye.ts.parseType(y,u.pid),S){case"pes":E=ye.ts.parsePesType(y,u.table),k=ye.ts.parsePayloadUnitStartIndicator(y),E==="audio"&&k&&(I=ye.ts.parsePesTime(y),I&&(I.type="audio",d.audio.push(I),O=!0));break}if(O)break;h-=it,g-=it;continue}h--,g--}},Hf=function(o,u,d){for(var h=0,g=it,y,S,E,k,I,O,j,Q,V=!1,te={data:[],size:0};g<o.byteLength;){if(o[h]===$t&&o[g]===$t){switch(y=o.subarray(h,g),S=ye.ts.parseType(y,u.pid),S){case"pes":if(E=ye.ts.parsePesType(y,u.table),k=ye.ts.parsePayloadUnitStartIndicator(y),E==="video"&&(k&&!V&&(I=ye.ts.parsePesTime(y),I&&(I.type="video",d.video.push(I),V=!0)),!d.firstKeyFrame)){if(k&&te.size!==0){for(O=new Uint8Array(te.size),j=0;te.data.length;)Q=te.data.shift(),O.set(Q,j),j+=Q.byteLength;if(ye.ts.videoPacketContainsKeyFrame(O)){var se=ye.ts.parsePesTime(O);se?(d.firstKeyFrame=se,d.firstKeyFrame.type="video"):console.warn("Failed to extract PTS/DTS from PES at first keyframe. This could be an unusual TS segment, or else mux.js did not parse your TS segment correctly. If you know your TS segments do contain PTS/DTS on keyframes please file a bug report! You can try ffprobe to double check for yourself.")}te.size=0}te.data.push(y),te.size+=y.byteLength}break}if(V&&d.firstKeyFrame)break;h+=it,g+=it;continue}h++,g++}for(g=o.byteLength,h=g-it,V=!1;h>=0;){if(o[h]===$t&&o[g]===$t){switch(y=o.subarray(h,g),S=ye.ts.parseType(y,u.pid),S){case"pes":E=ye.ts.parsePesType(y,u.table),k=ye.ts.parsePayloadUnitStartIndicator(y),E==="video"&&k&&(I=ye.ts.parsePesTime(y),I&&(I.type="video",d.video.push(I),V=!0));break}if(V)break;h-=it,g-=it;continue}h--,g--}},zf=function(o,u){if(o.audio&&o.audio.length){var d=u;(typeof d>"u"||isNaN(d))&&(d=o.audio[0].dts),o.audio.forEach(function(y){y.dts=Ki(y.dts,d),y.pts=Ki(y.pts,d),y.dtsTime=y.dts/Ai,y.ptsTime=y.pts/Ai})}if(o.video&&o.video.length){var h=u;if((typeof h>"u"||isNaN(h))&&(h=o.video[0].dts),o.video.forEach(function(y){y.dts=Ki(y.dts,h),y.pts=Ki(y.pts,h),y.dtsTime=y.dts/Ai,y.ptsTime=y.pts/Ai}),o.firstKeyFrame){var g=o.firstKeyFrame;g.dts=Ki(g.dts,h),g.pts=Ki(g.pts,h),g.dtsTime=g.dts/Ai,g.ptsTime=g.pts/Ai}}},Wf=function(o){for(var u=!1,d=0,h=null,g=null,y=0,S=0,E;o.length-S>=3;){var k=ye.aac.parseType(o,S);switch(k){case"timed-metadata":if(o.length-S<10){u=!0;break}if(y=ye.aac.parseId3TagSize(o,S),y>o.length){u=!0;break}g===null&&(E=o.subarray(S,S+y),g=ye.aac.parseAacTimestamp(E)),S+=y;break;case"audio":if(o.length-S<7){u=!0;break}if(y=ye.aac.parseAdtsSize(o,S),y>o.length){u=!0;break}h===null&&(E=o.subarray(S,S+y),h=ye.aac.parseSampleRate(E)),d++,S+=y;break;default:S++;break}if(u)return null}if(h===null||g===null)return null;var I=Ai/h,O={audio:[{type:"audio",dts:g,pts:g},{type:"audio",dts:g+d*1024*I,pts:g+d*1024*I}]};return O},Gf=function(o){var u={pid:null,table:null},d={};Vf(o,u);for(var h in u.table)if(u.table.hasOwnProperty(h)){var g=u.table[h];switch(g){case Jl.H264_STREAM_TYPE:d.video=[],Hf(o,u,d),d.video.length===0&&delete d.video;break;case Jl.ADTS_STREAM_TYPE:d.audio=[],Zl(o,u,d),d.audio.length===0&&delete d.audio;break}}return d},Xf=function(o,u){var d=ye.aac.isLikelyAacData(o),h;return d?h=Wf(o):h=Gf(o),!h||!h.audio&&!h.video?null:(zf(h,u),h)},Kf={inspect:Xf,parseAudioPes_:Zl};const Yf=function(o,u){u.on("data",function(d){const h=d.initSegment;d.initSegment={data:h.buffer,byteOffset:h.byteOffset,byteLength:h.byteLength};const g=d.data;d.data=g.buffer,o.postMessage({action:"data",segment:d,byteOffset:g.byteOffset,byteLength:g.byteLength},[d.data])}),u.on("done",function(d){o.postMessage({action:"done"})}),u.on("gopInfo",function(d){o.postMessage({action:"gopInfo",gopInfo:d})}),u.on("videoSegmentTimingInfo",function(d){const h={start:{decode:T.videoTsToSeconds(d.start.dts),presentation:T.videoTsToSeconds(d.start.pts)},end:{decode:T.videoTsToSeconds(d.end.dts),presentation:T.videoTsToSeconds(d.end.pts)},baseMediaDecodeTime:T.videoTsToSeconds(d.baseMediaDecodeTime)};d.prependedContentDuration&&(h.prependedContentDuration=T.videoTsToSeconds(d.prependedContentDuration)),o.postMessage({action:"videoSegmentTimingInfo",videoSegmentTimingInfo:h})}),u.on("audioSegmentTimingInfo",function(d){const h={start:{decode:T.videoTsToSeconds(d.start.dts),presentation:T.videoTsToSeconds(d.start.pts)},end:{decode:T.videoTsToSeconds(d.end.dts),presentation:T.videoTsToSeconds(d.end.pts)},baseMediaDecodeTime:T.videoTsToSeconds(d.baseMediaDecodeTime)};d.prependedContentDuration&&(h.prependedContentDuration=T.videoTsToSeconds(d.prependedContentDuration)),o.postMessage({action:"audioSegmentTimingInfo",audioSegmentTimingInfo:h})}),u.on("id3Frame",function(d){o.postMessage({action:"id3Frame",id3Frame:d})}),u.on("caption",function(d){o.postMessage({action:"caption",caption:d})}),u.on("trackinfo",function(d){o.postMessage({action:"trackinfo",trackInfo:d})}),u.on("audioTimingInfo",function(d){o.postMessage({action:"audioTimingInfo",audioTimingInfo:{start:T.videoTsToSeconds(d.start),end:T.videoTsToSeconds(d.end)}})}),u.on("videoTimingInfo",function(d){o.postMessage({action:"videoTimingInfo",videoTimingInfo:{start:T.videoTsToSeconds(d.start),end:T.videoTsToSeconds(d.end)}})}),u.on("log",function(d){o.postMessage({action:"log",log:d})})};class eu{constructor(u,d){this.options=d||{},this.self=u,this.init()}init(){this.transmuxer&&this.transmuxer.dispose(),this.transmuxer=new jg.Transmuxer(this.options),Yf(this.self,this.transmuxer)}pushMp4Captions(u){this.captionParser||(this.captionParser=new Lf,this.captionParser.init());const d=new Uint8Array(u.data,u.byteOffset,u.byteLength),h=this.captionParser.parse(d,u.trackIds,u.timescales);this.self.postMessage({action:"mp4Captions",captions:h&&h.captions||[],logs:h&&h.logs||[],data:d.buffer},[d.buffer])}initMp4WebVttParser(u){this.webVttParser||(this.webVttParser=new Yl);const d=new Uint8Array(u.data,u.byteOffset,u.byteLength);this.webVttParser.init(d)}getMp4WebVttText(u){this.webVttParser||(this.webVttParser=new Yl);const d=new Uint8Array(u.data,u.byteOffset,u.byteLength),h=this.webVttParser.parseSegment(d);this.self.postMessage({action:"getMp4WebVttText",mp4VttCues:h||[],data:d.buffer},[d.buffer])}probeMp4StartTime({timescales:u,data:d}){const h=Hn.startTime(u,d);this.self.postMessage({action:"probeMp4StartTime",startTime:h,data:d},[d.buffer])}probeMp4Tracks({data:u}){const d=Hn.tracks(u);this.self.postMessage({action:"probeMp4Tracks",tracks:d,data:u},[u.buffer])}probeEmsgID3({data:u,offset:d}){const h=Hn.getEmsgID3(u,d);this.self.postMessage({action:"probeEmsgID3",id3Frames:h,emsgData:u},[u.buffer])}probeTs({data:u,baseStartTime:d}){const h=typeof d=="number"&&!isNaN(d)?d*T.ONE_SECOND_IN_TS:void 0,g=Kf.inspect(u,h);let y=null;g&&(y={hasVideo:g.video&&g.video.length===2||!1,hasAudio:g.audio&&g.audio.length===2||!1},y.hasVideo&&(y.videoStart=g.video[0].ptsTime),y.hasAudio&&(y.audioStart=g.audio[0].ptsTime)),this.self.postMessage({action:"probeTs",result:y,data:u},[u.buffer])}clearAllMp4Captions(){this.captionParser&&this.captionParser.clearAllCaptions()}clearParsedMp4Captions(){this.captionParser&&this.captionParser.clearParsedCaptions()}push(u){const d=new Uint8Array(u.data,u.byteOffset,u.byteLength);this.transmuxer.push(d)}reset(){this.transmuxer.reset()}setTimestampOffset(u){const d=u.timestampOffset||0;this.transmuxer.setBaseMediaDecodeTime(Math.round(T.secondsToVideoTs(d)))}setAudioAppendStart(u){this.transmuxer.setAudioAppendStart(Math.ceil(T.secondsToVideoTs(u.appendStart)))}setRemux(u){this.transmuxer.setRemux(u.remux)}flush(u){this.transmuxer.flush(),self.postMessage({action:"done",type:"transmuxed"})}endTimeline(){this.transmuxer.endTimeline(),self.postMessage({action:"endedtimeline",type:"transmuxed"})}alignGopsWith(u){this.transmuxer.alignGopsWith(u.gopsToAlignWith.slice())}}self.onmessage=function(o){if(o.data.action==="init"&&o.data.options){this.messageHandlers=new eu(self,o.data.options);return}this.messageHandlers||(this.messageHandlers=new eu(self)),o.data&&o.data.action&&o.data.action!=="init"&&this.messageHandlers[o.data.action]&&this.messageHandlers[o.data.action](o.data)}}));var FT=pp(BT);const jT=(i,e,t)=>{const{type:n,initSegment:s,captions:r,captionStreams:a,metadata:l,videoFrameDtsTime:c,videoFramePtsTime:f}=i.data.segment;e.buffer.push({captions:r,captionStreams:a,metadata:l});const m=i.data.segment.boxes||{data:i.data.segment.data},b={type:n,data:new Uint8Array(m.data,m.data.byteOffset,m.data.byteLength),initSegment:new Uint8Array(s.data,s.byteOffset,s.byteLength)};typeof c<"u"&&(b.videoFrameDtsTime=c),typeof f<"u"&&(b.videoFramePtsTime=f),t(b)},$T=({transmuxedData:i,callback:e})=>{i.buffer=[],e(i)},qT=(i,e)=>{e.gopInfo=i.data.gopInfo},mp=i=>{const{transmuxer:e,bytes:t,audioAppendStart:n,gopsToAlignWith:s,remux:r,onData:a,onTrackInfo:l,onAudioTimingInfo:c,onVideoTimingInfo:f,onVideoSegmentTimingInfo:m,onAudioSegmentTimingInfo:b,onId3:C,onCaptions:w,onDone:A,onEndedTimeline:v,onTransmuxerLog:M,isEndOfTimeline:D,segment:R,triggerSegmentEventFn:N}=i,F={buffer:[]};let P=D;const $=X=>{e.currentTransmux===i&&(X.data.action==="data"&&jT(X,F,a),X.data.action==="trackinfo"&&l(X.data.trackInfo),X.data.action==="gopInfo"&&qT(X,F),X.data.action==="audioTimingInfo"&&c(X.data.audioTimingInfo),X.data.action==="videoTimingInfo"&&f(X.data.videoTimingInfo),X.data.action==="videoSegmentTimingInfo"&&m(X.data.videoSegmentTimingInfo),X.data.action==="audioSegmentTimingInfo"&&b(X.data.audioSegmentTimingInfo),X.data.action==="id3Frame"&&C([X.data.id3Frame],X.data.id3Frame.dispatchType),X.data.action==="caption"&&w(X.data.caption),X.data.action==="endedtimeline"&&(P=!1,v()),X.data.action==="log"&&M(X.data.log),X.data.type==="transmuxed"&&(P||(e.onmessage=null,$T({transmuxedData:F,callback:A}),yp(e))))},Y=()=>{const X={message:"Received an error message from the transmuxer worker",metadata:{errorType:B.Error.StreamingFailedToTransmuxSegment,segmentInfo:Mi({segment:R})}};A(null,X)};if(e.onmessage=$,e.onerror=Y,n&&e.postMessage({action:"setAudioAppendStart",appendStart:n}),Array.isArray(s)&&e.postMessage({action:"alignGopsWith",gopsToAlignWith:s}),typeof r<"u"&&e.postMessage({action:"setRemux",remux:r}),t.byteLength){const X=t instanceof ArrayBuffer?t:t.buffer,re=t instanceof ArrayBuffer?0:t.byteOffset;N({type:"segmenttransmuxingstart",segment:R}),e.postMessage({action:"push",data:X,byteOffset:re,byteLength:t.byteLength},[X])}D&&e.postMessage({action:"endTimeline"}),e.postMessage({action:"flush"})},yp=i=>{i.currentTransmux=null,i.transmuxQueue.length&&(i.currentTransmux=i.transmuxQueue.shift(),typeof i.currentTransmux=="function"?i.currentTransmux():mp(i.currentTransmux))},hd=(i,e)=>{i.postMessage({action:e}),yp(i)},_p=(i,e)=>{if(!e.currentTransmux){e.currentTransmux=i,hd(e,i);return}e.transmuxQueue.push(hd.bind(null,e,i))},VT=i=>{_p("reset",i)},HT=i=>{_p("endTimeline",i)},bp=i=>{if(!i.transmuxer.currentTransmux){i.transmuxer.currentTransmux=i,mp(i);return}i.transmuxer.transmuxQueue.push(i)},zT=i=>{const e=new FT;e.currentTransmux=null,e.transmuxQueue=[];const t=e.terminate;return e.terminate=()=>(e.currentTransmux=null,e.transmuxQueue.length=0,t.call(e)),e.postMessage({action:"init",options:i}),e};var Ha={reset:VT,endTimeline:HT,transmux:bp,createTransmuxer:zT};const un=function(i){const e=i.transmuxer,t=i.endAction||i.action,n=i.callback,s=je({},i,{endAction:null,transmuxer:null,callback:null}),r=a=>{a.data.action===t&&(e.removeEventListener("message",r),a.data.data&&(a.data.data=new Uint8Array(a.data.data,i.byteOffset||0,i.byteLength||a.data.data.byteLength),i.data&&(i.data=a.data.data)),n(a.data))};if(e.addEventListener("message",r),i.data){const a=i.data instanceof ArrayBuffer;s.byteOffset=a?0:i.data.byteOffset,s.byteLength=i.data.byteLength;const l=[a?i.data:i.data.buffer];e.postMessage(s,l)}else e.postMessage(s)},Yt={FAILURE:2,TIMEOUT:-101,ABORTED:-102},Tp="wvtt",go=i=>{i.forEach(e=>{e.abort()})},WT=i=>({bandwidth:i.bandwidth,bytesReceived:i.bytesReceived||0,roundTripTime:i.roundTripTime||0}),GT=i=>{const e=i.target,t={bandwidth:1/0,bytesReceived:0,roundTripTime:Date.now()-e.requestTime||0};return t.bytesReceived=i.loaded,t.bandwidth=Math.floor(t.bytesReceived/t.roundTripTime*8*1e3),t},cl=(i,e)=>{const{requestType:t}=e,n=$i({requestType:t,request:e,error:i});return e.timedout?{status:e.status,message:"HLS request timed-out at URL: "+e.uri,code:Yt.TIMEOUT,xhr:e,metadata:n}:e.aborted?{status:e.status,message:"HLS request aborted at URL: "+e.uri,code:Yt.ABORTED,xhr:e,metadata:n}:i?{status:e.status,message:"HLS request errored at URL: "+e.uri,code:Yt.FAILURE,xhr:e,metadata:n}:e.responseType==="arraybuffer"&&e.response.byteLength===0?{status:e.status,message:"Empty HLS response at URL: "+e.uri,code:Yt.FAILURE,xhr:e,metadata:n}:null},cd=(i,e,t,n)=>(s,r)=>{const a=r.response,l=cl(s,r);if(l)return t(l,i);if(a.byteLength!==16)return t({status:r.status,message:"Invalid HLS key at URL: "+r.uri,code:Yt.FAILURE,xhr:r},i);const c=new DataView(a),f=new Uint32Array([c.getUint32(0),c.getUint32(4),c.getUint32(8),c.getUint32(12)]);for(let b=0;b<e.length;b++)e[b].bytes=f;const m={uri:r.uri};return n({type:"segmentkeyloadcomplete",segment:i,keyInfo:m}),t(null,i)},XT=(i,e)=>{e===Tp&&i.transmuxer.postMessage({action:"initMp4WebVttParser",data:i.map.bytes})},KT=(i,e,t)=>{e===Tp&&un({action:"getMp4WebVttText",data:i.bytes,transmuxer:i.transmuxer,callback:({data:n,mp4VttCues:s})=>{i.bytes=n,t(null,i,{mp4VttCues:s})}})},vp=(i,e)=>{const t=Do(i.map.bytes);if(t!=="mp4"){const n=i.map.resolvedUri||i.map.uri,s=t||"unknown";return e({internal:!0,message:`Found unsupported ${s} container for initialization segment at URL: ${n}`,code:Yt.FAILURE,metadata:{mediaType:s}})}un({action:"probeMp4Tracks",data:i.map.bytes,transmuxer:i.transmuxer,callback:({tracks:n,data:s})=>(i.map.bytes=s,n.forEach(function(r){i.map.tracks=i.map.tracks||{},!i.map.tracks[r.type]&&(i.map.tracks[r.type]=r,typeof r.id=="number"&&r.timescale&&(i.map.timescales=i.map.timescales||{},i.map.timescales[r.id]=r.timescale),r.type==="text"&&XT(i,r.codec))}),e(null))})},YT=({segment:i,finishProcessingFn:e,triggerSegmentEventFn:t})=>(n,s)=>{const r=cl(n,s);if(r)return e(r,i);const a=new Uint8Array(s.response);if(t({type:"segmentloaded",segment:i}),i.map.key)return i.map.encryptedBytes=a,e(null,i);i.map.bytes=a,vp(i,function(l){if(l)return l.xhr=s,l.status=s.status,e(l,i);e(null,i)})},QT=({segment:i,finishProcessingFn:e,responseType:t,triggerSegmentEventFn:n})=>(s,r)=>{const a=cl(s,r);if(a)return e(a,i);n({type:"segmentloaded",segment:i});const l=t==="arraybuffer"||!r.responseText?r.response:UT(r.responseText.substring(i.lastReachedChar||0));return i.stats=WT(r),i.key?i.encryptedBytes=new Uint8Array(l):i.bytes=new Uint8Array(l),e(null,i)},JT=({segment:i,bytes:e,trackInfoFn:t,timingInfoFn:n,videoSegmentTimingInfoFn:s,audioSegmentTimingInfoFn:r,id3Fn:a,captionsFn:l,isEndOfTimeline:c,endedTimelineFn:f,dataFn:m,doneFn:b,onTransmuxerLog:C,triggerSegmentEventFn:w})=>{const A=i.map&&i.map.tracks||{},v=!!(A.audio&&A.video);let M=n.bind(null,i,"audio","start");const D=n.bind(null,i,"audio","end");let R=n.bind(null,i,"video","start");const N=n.bind(null,i,"video","end"),F=()=>bp({bytes:e,transmuxer:i.transmuxer,audioAppendStart:i.audioAppendStart,gopsToAlignWith:i.gopsToAlignWith,remux:v,onData:P=>{P.type=P.type==="combined"?"video":P.type,m(i,P)},onTrackInfo:P=>{t&&(v&&(P.isMuxed=!0),t(i,P))},onAudioTimingInfo:P=>{M&&typeof P.start<"u"&&(M(P.start),M=null),D&&typeof P.end<"u"&&D(P.end)},onVideoTimingInfo:P=>{R&&typeof P.start<"u"&&(R(P.start),R=null),N&&typeof P.end<"u"&&N(P.end)},onVideoSegmentTimingInfo:P=>{const $={pts:{start:P.start.presentation,end:P.end.presentation},dts:{start:P.start.decode,end:P.end.decode}};w({type:"segmenttransmuxingtiminginfoavailable",segment:i,timingInfo:$}),s(P)},onAudioSegmentTimingInfo:P=>{const $={pts:{start:P.start.pts,end:P.end.pts},dts:{start:P.start.dts,end:P.end.dts}};w({type:"segmenttransmuxingtiminginfoavailable",segment:i,timingInfo:$}),r(P)},onId3:(P,$)=>{a(i,P,$)},onCaptions:P=>{l(i,[P])},isEndOfTimeline:c,onEndedTimeline:()=>{f()},onTransmuxerLog:C,onDone:(P,$)=>{b&&(P.type=P.type==="combined"?"video":P.type,w({type:"segmenttransmuxingcomplete",segment:i}),b($,i,P))},segment:i,triggerSegmentEventFn:w});un({action:"probeTs",transmuxer:i.transmuxer,data:e,baseStartTime:i.baseStartTime,callback:P=>{i.bytes=e=P.data;const $=P.result;$&&(t(i,{hasAudio:$.hasAudio,hasVideo:$.hasVideo,isMuxed:v}),t=null),F()}})},Sp=({segment:i,bytes:e,trackInfoFn:t,timingInfoFn:n,videoSegmentTimingInfoFn:s,audioSegmentTimingInfoFn:r,id3Fn:a,captionsFn:l,isEndOfTimeline:c,endedTimelineFn:f,dataFn:m,doneFn:b,onTransmuxerLog:C,triggerSegmentEventFn:w})=>{let A=new Uint8Array(e);if(T1(A)){i.isFmp4=!0;const{tracks:v}=i.map;if(v.text&&(!v.audio||!v.video)){m(i,{data:A,type:"text"}),KT(i,v.text.codec,b);return}const M={isFmp4:!0,hasVideo:!!v.video,hasAudio:!!v.audio};v.audio&&v.audio.codec&&v.audio.codec!=="enca"&&(M.audioCodec=v.audio.codec),v.video&&v.video.codec&&v.video.codec!=="encv"&&(M.videoCodec=v.video.codec),v.video&&v.audio&&(M.isMuxed=!0),t(i,M);const D=(R,N)=>{m(i,{data:A,type:M.hasAudio&&!M.isMuxed?"audio":"video"}),N&&N.length&&a(i,N),R&&R.length&&l(i,R),b(null,i,{})};un({action:"probeMp4StartTime",timescales:i.map.timescales,data:A,transmuxer:i.transmuxer,callback:({data:R,startTime:N})=>{e=R.buffer,i.bytes=A=R,M.hasAudio&&!M.isMuxed&&n(i,"audio","start",N),M.hasVideo&&n(i,"video","start",N),un({action:"probeEmsgID3",data:A,transmuxer:i.transmuxer,offset:N,callback:({emsgData:F,id3Frames:P})=>{if(e=F.buffer,i.bytes=A=F,!v.video||!F.byteLength||!i.transmuxer){D(void 0,P);return}un({action:"pushMp4Captions",endAction:"mp4Captions",transmuxer:i.transmuxer,data:A,timescales:i.map.timescales,trackIds:[v.video.id],callback:$=>{e=$.data.buffer,i.bytes=A=$.data,$.logs.forEach(function(Y){C(fe(Y,{stream:"mp4CaptionParser"}))}),D($.captions,P)}})}})}});return}if(!i.transmuxer){b(null,i,{});return}if(typeof i.container>"u"&&(i.container=Do(A)),i.container!=="ts"&&i.container!=="aac"){t(i,{hasAudio:!1,hasVideo:!1}),b(null,i,{});return}JT({segment:i,bytes:e,trackInfoFn:t,timingInfoFn:n,videoSegmentTimingInfoFn:s,audioSegmentTimingInfoFn:r,id3Fn:a,captionsFn:l,isEndOfTimeline:c,endedTimelineFn:f,dataFn:m,doneFn:b,onTransmuxerLog:C,triggerSegmentEventFn:w})},Ep=function({id:i,key:e,encryptedBytes:t,decryptionWorker:n,segment:s,doneFn:r},a){const l=f=>{if(f.data.source===i){n.removeEventListener("message",l);const m=f.data.decrypted;a(new Uint8Array(m.bytes,m.byteOffset,m.byteLength))}};n.onerror=()=>{const f="An error occurred in the decryption worker",m=Mi({segment:s}),b={message:f,metadata:{error:new Error(f),errorType:B.Error.StreamingFailedToDecryptSegment,segmentInfo:m,keyInfo:{uri:s.key.resolvedUri||s.map.key.resolvedUri}}};r(b,s)},n.addEventListener("message",l);let c;e.bytes.slice?c=e.bytes.slice():c=new Uint32Array(Array.prototype.slice.call(e.bytes)),n.postMessage(op({source:i,encrypted:t,key:c,iv:e.iv}),[t.buffer,c.buffer])},ZT=({decryptionWorker:i,segment:e,trackInfoFn:t,timingInfoFn:n,videoSegmentTimingInfoFn:s,audioSegmentTimingInfoFn:r,id3Fn:a,captionsFn:l,isEndOfTimeline:c,endedTimelineFn:f,dataFn:m,doneFn:b,onTransmuxerLog:C,triggerSegmentEventFn:w})=>{w({type:"segmentdecryptionstart"}),Ep({id:e.requestId,key:e.key,encryptedBytes:e.encryptedBytes,decryptionWorker:i,segment:e,doneFn:b},A=>{e.bytes=A,w({type:"segmentdecryptioncomplete",segment:e}),Sp({segment:e,bytes:e.bytes,trackInfoFn:t,timingInfoFn:n,videoSegmentTimingInfoFn:s,audioSegmentTimingInfoFn:r,id3Fn:a,captionsFn:l,isEndOfTimeline:c,endedTimelineFn:f,dataFn:m,doneFn:b,onTransmuxerLog:C,triggerSegmentEventFn:w})})},ev=({activeXhrs:i,decryptionWorker:e,trackInfoFn:t,timingInfoFn:n,videoSegmentTimingInfoFn:s,audioSegmentTimingInfoFn:r,id3Fn:a,captionsFn:l,isEndOfTimeline:c,endedTimelineFn:f,dataFn:m,doneFn:b,onTransmuxerLog:C,triggerSegmentEventFn:w})=>{let A=0,v=!1;return(M,D)=>{if(!v){if(M)return v=!0,go(i),b(M,D);if(A+=1,A===i.length){const R=function(){if(D.encryptedBytes)return ZT({decryptionWorker:e,segment:D,trackInfoFn:t,timingInfoFn:n,videoSegmentTimingInfoFn:s,audioSegmentTimingInfoFn:r,id3Fn:a,captionsFn:l,isEndOfTimeline:c,endedTimelineFn:f,dataFn:m,doneFn:b,onTransmuxerLog:C,triggerSegmentEventFn:w});Sp({segment:D,bytes:D.bytes,trackInfoFn:t,timingInfoFn:n,videoSegmentTimingInfoFn:s,audioSegmentTimingInfoFn:r,id3Fn:a,captionsFn:l,isEndOfTimeline:c,endedTimelineFn:f,dataFn:m,doneFn:b,onTransmuxerLog:C,triggerSegmentEventFn:w})};if(D.endOfAllRequests=Date.now(),D.map&&D.map.encryptedBytes&&!D.map.bytes)return w({type:"segmentdecryptionstart",segment:D}),Ep({decryptionWorker:e,id:D.requestId+"-init",encryptedBytes:D.map.encryptedBytes,key:D.map.key,segment:D,doneFn:b},N=>{D.map.bytes=N,w({type:"segmentdecryptioncomplete",segment:D}),vp(D,F=>{if(F)return go(i),b(F,D);R()})});R()}}}},tv=({loadendState:i,abortFn:e})=>t=>{t.target.aborted&&e&&!i.calledAbortFn&&(e(),i.calledAbortFn=!0)},iv=({segment:i,progressFn:e,trackInfoFn:t,timingInfoFn:n,videoSegmentTimingInfoFn:s,audioSegmentTimingInfoFn:r,id3Fn:a,captionsFn:l,isEndOfTimeline:c,endedTimelineFn:f,dataFn:m})=>b=>{if(!b.target.aborted)return i.stats=fe(i.stats,GT(b)),!i.stats.firstBytesReceivedAt&&i.stats.bytesReceived&&(i.stats.firstBytesReceivedAt=Date.now()),e(b,i)},nv=({xhr:i,xhrOptions:e,decryptionWorker:t,segment:n,abortFn:s,progressFn:r,trackInfoFn:a,timingInfoFn:l,videoSegmentTimingInfoFn:c,audioSegmentTimingInfoFn:f,id3Fn:m,captionsFn:b,isEndOfTimeline:C,endedTimelineFn:w,dataFn:A,doneFn:v,onTransmuxerLog:M,triggerSegmentEventFn:D})=>{const R=[],N=ev({activeXhrs:R,decryptionWorker:t,trackInfoFn:a,timingInfoFn:l,videoSegmentTimingInfoFn:c,audioSegmentTimingInfoFn:f,id3Fn:m,captionsFn:b,isEndOfTimeline:C,endedTimelineFn:w,dataFn:A,doneFn:v,onTransmuxerLog:M,triggerSegmentEventFn:D});if(n.key&&!n.key.bytes){const X=[n.key];n.map&&!n.map.bytes&&n.map.key&&n.map.key.resolvedUri===n.key.resolvedUri&&X.push(n.map.key);const re=fe(e,{uri:n.key.resolvedUri,responseType:"arraybuffer",requestType:"segment-key"}),ce=cd(n,X,N,D),be={uri:n.key.resolvedUri};D({type:"segmentkeyloadstart",segment:n,keyInfo:be});const he=i(re,ce);R.push(he)}if(n.map&&!n.map.bytes){if(n.map.key&&(!n.key||n.key.resolvedUri!==n.map.key.resolvedUri)){const be=fe(e,{uri:n.map.key.resolvedUri,responseType:"arraybuffer",requestType:"segment-key"}),he=cd(n,[n.map.key],N,D),Z={uri:n.map.key.resolvedUri};D({type:"segmentkeyloadstart",segment:n,keyInfo:Z});const de=i(be,he);R.push(de)}const X=fe(e,{uri:n.map.resolvedUri,responseType:"arraybuffer",headers:co(n.map),requestType:"segment-media-initialization"}),re=YT({segment:n,finishProcessingFn:N,triggerSegmentEventFn:D});D({type:"segmentloadstart",segment:n});const ce=i(X,re);R.push(ce)}const F=fe(e,{uri:n.part&&n.part.resolvedUri||n.resolvedUri,responseType:"arraybuffer",headers:co(n),requestType:"segment"}),P=QT({segment:n,finishProcessingFn:N,responseType:F.responseType,triggerSegmentEventFn:D});D({type:"segmentloadstart",segment:n});const $=i(F,P);$.addEventListener("progress",iv({segment:n,progressFn:r,trackInfoFn:a,timingInfoFn:l,videoSegmentTimingInfoFn:c,audioSegmentTimingInfoFn:f,id3Fn:m,captionsFn:b,isEndOfTimeline:C,endedTimelineFn:w,dataFn:A})),R.push($);const Y={};return R.forEach(X=>{X.addEventListener("loadend",tv({loadendState:Y,abortFn:s}))}),()=>go(R)},sv=Lt("CodecUtils"),rv=function(i){const e=i.attributes||{};if(e.CODECS)return Ht(e.CODECS)},wp=(i,e)=>{const t=e.attributes||{};return i&&i.mediaGroups&&i.mediaGroups.AUDIO&&t.AUDIO&&i.mediaGroups.AUDIO[t.AUDIO]},av=(i,e)=>{if(!wp(i,e))return!0;const t=e.attributes||{},n=i.mediaGroups.AUDIO[t.AUDIO];for(const s in n)if(!n[s].uri&&!n[s].playlists)return!0;return!1},Ir=function(i){const e={};return i.forEach(({mediaType:t,type:n,details:s})=>{e[t]=e[t]||[],e[t].push(ah(`${n}${s}`))}),Object.keys(e).forEach(function(t){if(e[t].length>1){sv(`multiple ${t} codecs found as attributes: ${e[t].join(", ")}. Setting playlist codecs to null so that we wait for mux.js to probe segments for real codecs.`),e[t]=null;return}e[t]=e[t][0]}),e},pd=function(i){let e=0;return i.audio&&e++,i.video&&e++,e},hs=function(i,e){const t=e.attributes||{},n=Ir(rv(e)||[]);if(wp(i,e)&&!n.audio&&!av(i,e)){const s=Ir(Y_(i,t.AUDIO)||[]);s.audio&&(n.audio=s.audio)}return n},tr=Lt("PlaylistSelector"),gd=function(i){if(!i||!i.playlist)return;const e=i.playlist;return JSON.stringify({id:e.id,bandwidth:i.bandwidth,width:i.width,height:i.height,codecs:e.attributes&&e.attributes.CODECS||""})},xr=function(i,e){if(!i)return"";const t=x.getComputedStyle(i);return t?t[e]:""},dn=function(i,e){const t=i.slice();i.sort(function(n,s){const r=e(n,s);return r===0?t.indexOf(n)-t.indexOf(s):r})},pl=function(i,e){let t,n;return i.attributes.BANDWIDTH&&(t=i.attributes.BANDWIDTH),t=t||x.Number.MAX_VALUE,e.attributes.BANDWIDTH&&(n=e.attributes.BANDWIDTH),n=n||x.Number.MAX_VALUE,t-n},ov=function(i,e){let t,n;return i.attributes.RESOLUTION&&i.attributes.RESOLUTION.width&&(t=i.attributes.RESOLUTION.width),t=t||x.Number.MAX_VALUE,e.attributes.RESOLUTION&&e.attributes.RESOLUTION.width&&(n=e.attributes.RESOLUTION.width),n=n||x.Number.MAX_VALUE,t===n&&i.attributes.BANDWIDTH&&e.attributes.BANDWIDTH?i.attributes.BANDWIDTH-e.attributes.BANDWIDTH:t-n};let kp=function(i,e,t,n,s,r){if(!i)return;const a={bandwidth:e,width:t,height:n,limitRenditionByPlayerDimensions:s};let l=i.playlists;gt.isAudioOnly(i)&&(l=r.getAudioTrackPlaylists_(),a.audioOnly=!0);let c=l.map(P=>{let $;const Y=P.attributes&&P.attributes.RESOLUTION&&P.attributes.RESOLUTION.width,X=P.attributes&&P.attributes.RESOLUTION&&P.attributes.RESOLUTION.height;return $=P.attributes&&P.attributes.BANDWIDTH,$=$||x.Number.MAX_VALUE,{bandwidth:$,width:Y,height:X,playlist:P}});dn(c,(P,$)=>P.bandwidth-$.bandwidth),c=c.filter(P=>!gt.isIncompatible(P.playlist));let f=c.filter(P=>gt.isEnabled(P.playlist));f.length||(f=c.filter(P=>!gt.isDisabled(P.playlist)));const m=f.filter(P=>P.bandwidth*We.BANDWIDTH_VARIANCE<e);let b=m[m.length-1];const C=m.filter(P=>P.bandwidth===b.bandwidth)[0];if(s===!1){const P=C||f[0]||c[0];if(P&&P.playlist){let $="sortedPlaylistReps";return C&&($="bandwidthBestRep"),f[0]&&($="enabledPlaylistReps"),tr(`choosing ${gd(P)} using ${$} with options`,a),P.playlist}return tr("could not choose a playlist with options",a),null}const w=m.filter(P=>P.width&&P.height);dn(w,(P,$)=>P.width-$.width);const A=w.filter(P=>P.width===t&&P.height===n);b=A[A.length-1];const v=A.filter(P=>P.bandwidth===b.bandwidth)[0];let M,D,R;v||(M=w.filter(P=>P.width>t||P.height>n),D=M.filter(P=>P.width===M[0].width&&P.height===M[0].height),b=D[D.length-1],R=D.filter(P=>P.bandwidth===b.bandwidth)[0]);let N;if(r.leastPixelDiffSelector){const P=w.map($=>($.pixelDiff=Math.abs($.width-t)+Math.abs($.height-n),$));dn(P,($,Y)=>$.pixelDiff===Y.pixelDiff?Y.bandwidth-$.bandwidth:$.pixelDiff-Y.pixelDiff),N=P[0]}const F=N||R||v||C||f[0]||c[0];if(F&&F.playlist){let P="sortedPlaylistReps";return N?P="leastPixelDiffRep":R?P="resolutionPlusOneRep":v?P="resolutionBestRep":C?P="bandwidthBestRep":f[0]&&(P="enabledPlaylistReps"),tr(`choosing ${gd(F)} using ${P} with options`,a),F.playlist}return tr("could not choose a playlist with options",a),null};const fd=function(){let i=this.useDevicePixelRatio&&x.devicePixelRatio||1;return isNaN(this.customPixelRatio)||(i=this.customPixelRatio),kp(this.playlists.main,this.systemBandwidth,parseInt(xr(this.tech_.el(),"width"),10)*i,parseInt(xr(this.tech_.el(),"height"),10)*i,this.limitRenditionByPlayerDimensions,this.playlistController_)},lv=function(i){let e=-1,t=-1;if(i<0||i>1)throw new Error("Moving average bandwidth decay must be between 0 and 1.");return function(){let n=this.useDevicePixelRatio&&x.devicePixelRatio||1;return isNaN(this.customPixelRatio)||(n=this.customPixelRatio),e<0&&(e=this.systemBandwidth,t=this.systemBandwidth),this.systemBandwidth>0&&this.systemBandwidth!==t&&(e=i*this.systemBandwidth+(1-i)*e,t=this.systemBandwidth),kp(this.playlists.main,e,parseInt(xr(this.tech_.el(),"width"),10)*n,parseInt(xr(this.tech_.el(),"height"),10)*n,this.limitRenditionByPlayerDimensions,this.playlistController_)}},uv=function(i){const{main:e,currentTime:t,bandwidth:n,duration:s,segmentDuration:r,timeUntilRebuffer:a,currentTimeline:l,syncController:c}=i,f=e.playlists.filter(w=>!gt.isIncompatible(w));let m=f.filter(gt.isEnabled);m.length||(m=f.filter(w=>!gt.isDisabled(w)));const b=m.filter(gt.hasAttribute.bind(null,"BANDWIDTH")).map(w=>{const A=c.getSyncPoint(w,s,l,t)?1:2,v=gt.estimateSegmentRequestTime(r,n,w)*A-a;return{playlist:w,rebufferingImpact:v}}),C=b.filter(w=>w.rebufferingImpact<=0);return dn(C,(w,A)=>pl(A.playlist,w.playlist)),C.length?C[0]:(dn(b,(w,A)=>w.rebufferingImpact-A.rebufferingImpact),b[0]||null)},dv=function(){const i=this.playlists.main.playlists.filter(gt.isEnabled);return dn(i,(e,t)=>pl(e,t)),i.filter(e=>!!hs(this.playlists.main,e).video)[0]||null},hv=i=>{let e=0,t;return i.bytes&&(t=new Uint8Array(i.bytes),i.segments.forEach(n=>{t.set(n,e),e+=n.byteLength})),t};function Cp(i){try{return new URL(i).pathname.split("/").slice(-2).join("/")}catch{return""}}const cv=function(i,e,t){if(!i[t]){e.trigger({type:"usage",name:"vhs-608"});let n=t;/^cc708_/.test(t)&&(n="SERVICE"+t.split("_")[1]);const s=e.textTracks().getTrackById(n);if(s)i[t]=s;else{const r=e.options_.vhs&&e.options_.vhs.captionServices||{};let a=t,l=t,c=!1;const f=r[n];f&&(a=f.label,l=f.language,c=f.default),i[t]=e.addRemoteTextTrack({kind:"captions",id:n,default:c,label:a,language:l},!1).track}}},pv=function({inbandTextTracks:i,captionArray:e,timestampOffset:t}){if(!e)return;const n=x.WebKitDataCue||x.VTTCue;e.forEach(s=>{const r=s.stream;s.content?s.content.forEach(a=>{const l=new n(s.startTime+t,s.endTime+t,a.text);l.line=a.line,l.align="left",l.position=a.position,l.positionAlign="line-left",i[r].addCue(l)}):i[r].addCue(new n(s.startTime+t,s.endTime+t,s.text))})},gv=function(i){Object.defineProperties(i.frame,{id:{get(){return B.log.warn("cue.frame.id is deprecated. Use cue.value.key instead."),i.value.key}},value:{get(){return B.log.warn("cue.frame.value is deprecated. Use cue.value.data instead."),i.value.data}},privateData:{get(){return B.log.warn("cue.frame.privateData is deprecated. Use cue.value.data instead."),i.value.data}}})},fv=({inbandTextTracks:i,metadataArray:e,timestampOffset:t,videoDuration:n})=>{if(!e)return;const s=x.WebKitDataCue||x.VTTCue,r=i.metadataTrack_;if(!r||(e.forEach(m=>{const b=m.cueTime+t;typeof b!="number"||x.isNaN(b)||b<0||!(b<1/0)||!m.frames||!m.frames.length||m.frames.forEach(C=>{const w=new s(b,b,C.value||C.url||C.data||"");w.frame=C,w.value=C,gv(w),r.addCue(w)})}),!r.cues||!r.cues.length))return;const a=r.cues,l=[];for(let m=0;m<a.length;m++)a[m]&&l.push(a[m]);const c=l.reduce((m,b)=>{const C=m[b.startTime]||[];return C.push(b),m[b.startTime]=C,m},{}),f=Object.keys(c).sort((m,b)=>Number(m)-Number(b));f.forEach((m,b)=>{const C=c[m],w=isFinite(n)?n:m,A=Number(f[b+1])||w;C.forEach(v=>{v.endTime=A})})},mv={id:"ID",class:"CLASS",startDate:"START-DATE",duration:"DURATION",endDate:"END-DATE",endOnNext:"END-ON-NEXT",plannedDuration:"PLANNED-DURATION",scte35Out:"SCTE35-OUT",scte35In:"SCTE35-IN"},yv=new Set(["id","class","startDate","duration","endDate","endOnNext","startTime","endTime","processDateRange"]),_v=({inbandTextTracks:i,dateRanges:e})=>{const t=i.metadataTrack_;if(!t)return;const n=x.WebKitDataCue||x.VTTCue;e.forEach(s=>{for(const r of Object.keys(s)){if(yv.has(r))continue;const a=new n(s.startTime,s.endTime,"");a.id=s.id,a.type="com.apple.quicktime.HLS",a.value={key:mv[r],data:s[r]},(r==="scte35Out"||r==="scte35In")&&(a.value.data=new Uint8Array(a.value.data.match(/[\da-f]{2}/gi)).buffer),t.addCue(a)}s.processDateRange()})},md=(i,e,t)=>{i.metadataTrack_||(i.metadataTrack_=t.addRemoteTextTrack({kind:"metadata",label:"Timed Metadata"},!1).track,B.browser.IS_ANY_SAFARI||(i.metadataTrack_.inBandMetadataTrackDispatchType=e))},ss=function(i,e,t){let n,s;if(t&&t.cues)for(n=t.cues.length;n--;)s=t.cues[n],s.startTime>=i&&s.endTime<=e&&t.removeCue(s)},bv=function(i){const e=i.cues;if(!e)return;const t={};for(let n=e.length-1;n>=0;n--){const s=e[n],r=`${s.startTime}-${s.endTime}-${s.text}`;t[r]?i.removeCue(s):t[r]=s}},Tv=(i,e,t)=>{if(typeof e>"u"||e===null||!i.length)return[];const n=Math.ceil((e-t+3)*Ri.ONE_SECOND_IN_TS);let s;for(s=0;s<i.length&&!(i[s].pts>n);s++);return i.slice(s)},vv=(i,e,t)=>{if(!e.length)return i;if(t)return e.slice();const n=e[0].pts;let s=0;for(s;s<i.length&&!(i[s].pts>=n);s++);return i.slice(0,s).concat(e)},Sv=(i,e,t,n)=>{const s=Math.ceil((e-n)*Ri.ONE_SECOND_IN_TS),r=Math.ceil((t-n)*Ri.ONE_SECOND_IN_TS),a=i.slice();let l=i.length;for(;l--&&!(i[l].pts<=r););if(l===-1)return a;let c=l+1;for(;c--&&!(i[c].pts<=s););return c=Math.max(c,0),a.splice(c,l-c+1),a},Ev=function(i,e){if(!i&&!e||!i&&e||i&&!e)return!1;if(i===e)return!0;const t=Object.keys(i).sort(),n=Object.keys(e).sort();if(t.length!==n.length)return!1;for(let s=0;s<t.length;s++){const r=t[s];if(r!==n[s]||i[r]!==e[r])return!1}return!0},wv=function(i,e,t){e=e||[];const n=[];let s=0;for(let r=0;r<e.length;r++){const a=e[r];if(i===a.timeline&&(n.push(r),s+=a.duration,s>t))return r}return n.length===0?0:n[n.length-1]},Jn=1,kv=500,yd=i=>typeof i=="number"&&isFinite(i),ir=1/60,Cv=(i,e,t)=>i!=="main"||!e||!t?null:!t.hasAudio&&!t.hasVideo?"Neither audio nor video found in segment.":e.hasVideo&&!t.hasVideo?"Only audio found in segment when we expected video. We can't switch to audio only from a stream that had video. To get rid of this message, please add codec information to the manifest.":!e.hasVideo&&t.hasVideo?"Video found in segment when we expected only audio. We can't switch to a stream with video from an audio only stream. To get rid of this message, please add codec information to the manifest.":null,Iv=(i,e,t)=>{let n=e-We.BACK_BUFFER_LENGTH;i.length&&(n=Math.max(n,i.start(0)));const s=e-t;return Math.min(s,n)},Zi=i=>{const{startOfSegment:e,duration:t,segment:n,part:s,playlist:{mediaSequence:r,id:a,segments:l=[]},mediaIndex:c,partIndex:f,timeline:m}=i,b=l.length-1;let C="mediaIndex/partIndex increment";i.getMediaInfoForTime?C=`getMediaInfoForTime (${i.getMediaInfoForTime})`:i.isSyncRequest&&(C="getSyncSegmentCandidate (isSyncRequest)"),i.independent&&(C+=` with independent ${i.independent}`);const w=typeof f=="number",A=i.segment.uri?"segment":"pre-segment",v=w?zc({preloadSegment:n})-1:0;return`${A} [${r+c}/${r+b}]`+(w?` part [${f}/${v}]`:"")+` segment start/end [${n.start} => ${n.end}]`+(w?` part start/end [${s.start} => ${s.end}]`:"")+` startOfSegment [${e}] duration [${t}] timeline [${m}] selected by [${C}] playlist [${a}]`},_d=i=>`${i}TimingInfo`,xv=({segmentTimeline:i,currentTimeline:e,startOfSegment:t,buffered:n,overrideCheck:s})=>!s&&i===e?null:i<e?t:n.length?n.end(n.length-1):t,fo=({timelineChangeController:i,currentTimeline:e,segmentTimeline:t,loaderType:n,audioDisabled:s})=>{if(e===t)return!1;if(n==="audio"){const r=i.lastTimelineChange({type:"main"});return!r||r.to!==t}if(n==="main"&&s){const r=i.pendingTimelineChange({type:"audio"});return!(r&&r.to===t)}return!1},Av=i=>{if(!i)return!1;const e=i.pendingTimelineChange({type:"audio"}),t=i.pendingTimelineChange({type:"main"}),n=e&&t,s=n&&e.to!==t.to;return!!(n&&e.from!==-1&&t.from!==-1&&s)},Pv=i=>{const e=i.timelineChangeController_.pendingTimelineChange({type:"audio"}),t=i.timelineChangeController_.pendingTimelineChange({type:"main"});return e&&t&&e.to<t.to},mi=i=>{const e=i.pendingSegment_;if(e&&fo({timelineChangeController:i.timelineChangeController_,currentTimeline:i.currentTimeline_,segmentTimeline:e.timeline,loaderType:i.loaderType_,audioDisabled:i.audioDisabled_})&&Av(i.timelineChangeController_)){if(Pv(i)){i.timelineChangeController_.trigger("audioTimelineBehind");return}i.timelineChangeController_.trigger("fixBadTimelineChange")}},Lv=i=>{let e=0;return["video","audio"].forEach(function(t){const n=i[`${t}TimingInfo`];if(!n)return;const{start:s,end:r}=n;let a;typeof s=="bigint"||typeof r=="bigint"?a=x.BigInt(r)-x.BigInt(s):typeof s=="number"&&typeof r=="number"&&(a=r-s),typeof a<"u"&&a>e&&(e=a)}),typeof e=="bigint"&&e<Number.MAX_SAFE_INTEGER&&(e=Number(e)),e},bd=({segmentDuration:i,maxDuration:e})=>i?Math.round(i)>e+Xt:!1,Dv=(i,e)=>{if(e!=="hls")return null;const t=Lv({audioTimingInfo:i.audioTimingInfo,videoTimingInfo:i.videoTimingInfo});if(!t)return null;const n=i.playlist.targetDuration,s=bd({segmentDuration:t,maxDuration:n*2}),r=bd({segmentDuration:t,maxDuration:n}),a=`Segment with index ${i.mediaIndex} from playlist ${i.playlist.id} has a duration of ${t} when the reported duration is ${i.duration} and the target duration is ${n}. For HLS content, a duration in excess of the target duration may result in playback issues. See the HLS specification section on EXT-X-TARGETDURATION for more details: https://tools.ietf.org/html/draft-pantos-http-live-streaming-23#section-4.3.3.1`;return s||r?{severity:s?"warn":"info",message:a}:null},Mi=({type:i,segment:e})=>{if(!e)return;const t=!!(e.key||e.map&&e.map.ke),n=!!(e.map&&!e.map.bytes),s=e.startOfSegment===void 0?e.start:e.startOfSegment;return{type:i||e.type,uri:e.resolvedUri||e.uri,start:s,duration:e.duration,isEncrypted:t,isMediaInitialization:n}};class mo extends B.EventTarget{constructor(e,t={}){if(super(),!e)throw new TypeError("Initialization settings are required");if(typeof e.currentTime!="function")throw new TypeError("No currentTime getter specified");if(!e.mediaSource)throw new TypeError("No MediaSource specified");this.bandwidth=e.bandwidth,this.throughput={rate:0,count:0},this.roundTrip=NaN,this.resetStats_(),this.mediaIndex=null,this.partIndex=null,this.hasPlayed_=e.hasPlayed,this.currentTime_=e.currentTime,this.seekable_=e.seekable,this.seeking_=e.seeking,this.duration_=e.duration,this.mediaSource_=e.mediaSource,this.vhs_=e.vhs,this.loaderType_=e.loaderType,this.currentMediaInfo_=void 0,this.startingMediaInfo_=void 0,this.segmentMetadataTrack_=e.segmentMetadataTrack,this.goalBufferLength_=e.goalBufferLength,this.sourceType_=e.sourceType,this.sourceUpdater_=e.sourceUpdater,this.inbandTextTracks_=e.inbandTextTracks,this.state_="INIT",this.timelineChangeController_=e.timelineChangeController,this.shouldSaveSegmentTimingInfo_=!0,this.parse708captions_=e.parse708captions,this.useDtsForTimestampOffset_=e.useDtsForTimestampOffset,this.captionServices_=e.captionServices,this.exactManifestTimings=e.exactManifestTimings,this.addMetadataToTextTrack=e.addMetadataToTextTrack,this.checkBufferTimeout_=null,this.error_=void 0,this.currentTimeline_=-1,this.shouldForceTimestampOffsetAfterResync_=!1,this.pendingSegment_=null,this.xhrOptions_=null,this.pendingSegments_=[],this.audioDisabled_=!1,this.isPendingTimestampOffset_=!1,this.gopBuffer_=[],this.timeMapping_=0,this.safeAppend_=!1,this.appendInitSegment_={audio:!0,video:!0},this.playlistOfLastInitSegment_={audio:null,video:null},this.callQueue_=[],this.loadQueue_=[],this.metadataQueue_={id3:[],caption:[]},this.waitingOnRemove_=!1,this.quotaExceededErrorRetryTimeout_=null,this.activeInitSegmentId_=null,this.initSegments_={},this.cacheEncryptionKeys_=e.cacheEncryptionKeys,this.keyCache_={},this.decrypter_=e.decrypter,this.syncController_=e.syncController,this.syncPoint_={segmentIndex:0,time:0},this.transmuxer_=this.createTransmuxer_(),this.triggerSyncInfoUpdate_=()=>this.trigger("syncinfoupdate"),this.syncController_.on("syncinfoupdate",this.triggerSyncInfoUpdate_),this.mediaSource_.addEventListener("sourceopen",()=>{this.isEndOfStream_()||(this.ended_=!1)}),this.fetchAtBuffer_=!1,this.logger_=Lt(`SegmentLoader[${this.loaderType_}]`),Object.defineProperty(this,"state",{get(){return this.state_},set(n){n!==this.state_&&(this.logger_(`${this.state_} -> ${n}`),this.state_=n,this.trigger("statechange"))}}),this.sourceUpdater_.on("ready",()=>{this.hasEnoughInfoToAppend_()?this.processCallQueue_():mi(this)}),this.sourceUpdater_.on("codecschange",n=>{this.trigger(je({type:"codecschange"},n))}),this.loaderType_==="main"&&this.timelineChangeController_.on("pendingtimelinechange",()=>{this.hasEnoughInfoToAppend_()?this.processCallQueue_():mi(this)}),this.loaderType_==="audio"&&this.timelineChangeController_.on("timelinechange",n=>{this.trigger(je({type:"timelinechange"},n)),this.hasEnoughInfoToLoad_()?this.processLoadQueue_():mi(this),this.hasEnoughInfoToAppend_()?this.processCallQueue_():mi(this)})}get mediaSequenceSync_(){return this.syncController_.getMediaSequenceSync(this.loaderType_)}createTransmuxer_(){return Ha.createTransmuxer({remux:!1,alignGopsAtEnd:this.safeAppend_,keepOriginalTimestamps:!0,parse708captions:this.parse708captions_,captionServices:this.captionServices_})}resetStats_(){this.mediaBytesTransferred=0,this.mediaRequests=0,this.mediaRequestsAborted=0,this.mediaRequestsTimedout=0,this.mediaRequestsErrored=0,this.mediaTransferDuration=0,this.mediaSecondsLoaded=0,this.mediaAppends=0}dispose(){this.trigger("dispose"),this.state="DISPOSED",this.pause(),this.abort_(),this.transmuxer_&&this.transmuxer_.terminate(),this.resetStats_(),this.checkBufferTimeout_&&x.clearTimeout(this.checkBufferTimeout_),this.syncController_&&this.triggerSyncInfoUpdate_&&this.syncController_.off("syncinfoupdate",this.triggerSyncInfoUpdate_),this.off()}setAudio(e){this.audioDisabled_=!e,e?this.appendInitSegment_.audio=!0:this.sourceUpdater_.removeAudio(0,this.duration_())}abort(){if(this.state!=="WAITING"){this.pendingSegment_&&(this.pendingSegment_=null),this.timelineChangeController_.clearPendingTimelineChange(this.loaderType_);return}this.abort_(),this.state="READY",this.paused()||this.monitorBuffer_()}abort_(){this.pendingSegment_&&this.pendingSegment_.abortRequests&&this.pendingSegment_.abortRequests(),this.pendingSegment_=null,this.callQueue_=[],this.loadQueue_=[],this.metadataQueue_.id3=[],this.metadataQueue_.caption=[],this.timelineChangeController_.clearPendingTimelineChange(this.loaderType_),this.waitingOnRemove_=!1,x.clearTimeout(this.quotaExceededErrorRetryTimeout_),this.quotaExceededErrorRetryTimeout_=null}checkForAbort_(e){return this.state==="APPENDING"&&!this.pendingSegment_?(this.state="READY",!0):!this.pendingSegment_||this.pendingSegment_.requestId!==e}error(e){return typeof e<"u"&&(this.logger_("error occurred:",e),this.error_=e),this.pendingSegment_=null,this.error_}endOfStream(){this.ended_=!0,this.transmuxer_&&Ha.reset(this.transmuxer_),this.gopBuffer_.length=0,this.pause(),this.trigger("ended")}buffered_(){const e=this.getMediaInfo_();if(!this.sourceUpdater_||!e)return tt();if(this.loaderType_==="main"){const{hasAudio:t,hasVideo:n,isMuxed:s}=e;if(n&&t&&!this.audioDisabled_&&!s)return this.sourceUpdater_.buffered();if(n)return this.sourceUpdater_.videoBuffered()}return this.sourceUpdater_.audioBuffered()}initSegmentForMap(e,t=!1){if(!e)return null;const n=Cr(e);let s=this.initSegments_[n];return t&&!s&&e.bytes&&(this.initSegments_[n]=s={resolvedUri:e.resolvedUri,byterange:e.byterange,bytes:e.bytes,tracks:e.tracks,timescales:e.timescales}),s||e}segmentKey(e,t=!1){if(!e)return null;const n=lp(e);let s=this.keyCache_[n];this.cacheEncryptionKeys_&&t&&!s&&e.bytes&&(this.keyCache_[n]=s={resolvedUri:e.resolvedUri,bytes:e.bytes});const r={resolvedUri:(s||e).resolvedUri};return s&&(r.bytes=s.bytes),r}couldBeginLoading_(){return this.playlist_&&!this.paused()}load(){if(this.monitorBuffer_(),!!this.playlist_){if(this.state==="INIT"&&this.couldBeginLoading_())return this.init_();!this.couldBeginLoading_()||this.state!=="READY"&&this.state!=="INIT"||(this.state="READY")}}init_(){return this.state="READY",this.resetEverything(),this.monitorBuffer_()}playlist(e,t={}){if(!e||this.playlist_&&this.playlist_.endList&&e.endList&&this.playlist_.uri===e.uri)return;const n=this.playlist_,s=this.pendingSegment_;this.playlist_=e,this.xhrOptions_=t,this.state==="INIT"&&(e.syncInfo={mediaSequence:e.mediaSequence,time:0},this.loaderType_==="main"&&this.syncController_.setDateTimeMappingForStart(e));let r=null;if(n&&(n.id?r=n.id:n.uri&&(r=n.uri)),this.logger_(`playlist update [${r} => ${e.id||e.uri}]`),this.mediaSequenceSync_&&(this.mediaSequenceSync_.update(e,this.currentTime_()),this.logger_(`Playlist update:
|
|
202
|
+
`)+(d.boxes?`
|
|
203
|
+
`+va(d.boxes,u+1):"")}).join(`
|
|
204
|
+
`)};var $l={inspect:Je,textify:va,parseType:Vs,findBox:nm,parseTraf:pi.traf,parseTfdt:pi.tfdt,parseHdlr:pi.hdlr,parseTfhd:pi.tfhd,parseTrun:pi.trun,parseSidx:pi.sidx},am=function(o){for(var u=0,c=String.fromCharCode(o[u]),d="";c!=="\0";)d+=c,u++,c=String.fromCharCode(o[u]);return d+=c,d},om={uint8ToCString:am},Xn=om.uint8ToCString,lm=r.getUint64,um=function(o){var u=4,c=o[0],d,p,_,x,S,I,A,O;if(c===0){d=Xn(o.subarray(u)),u+=d.length,p=Xn(o.subarray(u)),u+=p.length;var j=new DataView(o.buffer);_=j.getUint32(u),u+=4,S=j.getUint32(u),u+=4,I=j.getUint32(u),u+=4,A=j.getUint32(u),u+=4}else if(c===1){var j=new DataView(o.buffer);_=j.getUint32(u),u+=4,x=lm(o.subarray(u)),u+=8,I=j.getUint32(u),u+=4,A=j.getUint32(u),u+=4,d=Xn(o.subarray(u)),u+=d.length,p=Xn(o.subarray(u)),u+=p.length}O=new Uint8Array(o.subarray(u,o.byteLength));var Y={scheme_id_uri:d,value:p,timescale:_||1,presentation_time:x,presentation_time_delta:S,event_duration:I,id:A,message_data:O};return dm(c,Y)?Y:void 0},cm=function(o,u,c,d){return o||o===0?o/u:d+c/u},dm=function(o,u){var c=u.scheme_id_uri!=="\0",d=o===0&&jl(u.presentation_time_delta)&&c,p=o===1&&jl(u.presentation_time)&&c;return!(o>1)&&d||p},jl=function(o){return o!==void 0||o!==null},hm={parseEmsgBox:um,scaleTime:cm},Hs;typeof window<"u"?Hs=window:typeof s<"u"?Hs=s:typeof self<"u"?Hs=self:Hs={};var Vl=Hs,Yn=Gn.toUnsigned,qs=Gn.toHexString,Fe=Kn,Xi=ya,ba=hm,fm=Ta,pm=Bl,mm=_a,gm=r.getUint64,Hl,ql,zl,Wl,Gl,xa,Kl,Sa=Vl,ym=xl.parseId3Frames;Hl=function(o){var u={},c=Fe(o,["moov","trak"]);return c.reduce(function(d,p){var _,x,S,I,A;return _=Fe(p,["tkhd"])[0],!_||(x=_[0],S=x===0?12:20,I=Yn(_[S]<<24|_[S+1]<<16|_[S+2]<<8|_[S+3]),A=Fe(p,["mdia","mdhd"])[0],!A)?null:(x=A[0],S=x===0?12:20,d[I]=Yn(A[S]<<24|A[S+1]<<16|A[S+2]<<8|A[S+3]),d)},u)},ql=function(o,u){var c;c=Fe(u,["moof","traf"]);var d=c.reduce(function(p,_){var x=Fe(_,["tfhd"])[0],S=Yn(x[4]<<24|x[5]<<16|x[6]<<8|x[7]),I=o[S]||9e4,A=Fe(_,["tfdt"])[0],O=new DataView(A.buffer,A.byteOffset,A.byteLength),j;A[0]===1?j=gm(A.subarray(4,12)):j=O.getUint32(4);let Y;return typeof j=="bigint"?Y=j/Sa.BigInt(I):typeof j=="number"&&!isNaN(j)&&(Y=j/I),Y<Number.MAX_SAFE_INTEGER&&(Y=Number(Y)),Y<p&&(p=Y),p},1/0);return typeof d=="bigint"||isFinite(d)?d:0},zl=function(o,u){var c=Fe(u,["moof","traf"]),d=0,p=0,_;if(c&&c.length){var x=Fe(c[0],["tfhd"])[0],S=Fe(c[0],["trun"])[0],I=Fe(c[0],["tfdt"])[0];if(x){var A=fm(x);_=A.trackId}if(I){var O=mm(I);d=O.baseMediaDecodeTime}if(S){var j=pm(S);j.samples&&j.samples.length&&(p=j.samples[0].compositionTimeOffset||0)}}var Y=o[_]||9e4;typeof d=="bigint"&&(p=Sa.BigInt(p),Y=Sa.BigInt(Y));var q=(d+p)/Y;return typeof q=="bigint"&&q<Number.MAX_SAFE_INTEGER&&(q=Number(q)),q},Wl=function(o){var u=Fe(o,["moov","trak"]),c=[];return u.forEach(function(d){var p=Fe(d,["mdia","hdlr"]),_=Fe(d,["tkhd"]);p.forEach(function(x,S){var I=Xi(x.subarray(8,12)),A=_[S],O,j,Y;I==="vide"&&(O=new DataView(A.buffer,A.byteOffset,A.byteLength),j=O.getUint8(0),Y=j===0?O.getUint32(12):O.getUint32(20),c.push(Y))})}),c},xa=function(o){var u=o[0],c=u===0?12:20;return Yn(o[c]<<24|o[c+1]<<16|o[c+2]<<8|o[c+3])},Gl=function(o){var u=Fe(o,["moov","trak"]),c=[];return u.forEach(function(d){var p={},_=Fe(d,["tkhd"])[0],x,S;_&&(x=new DataView(_.buffer,_.byteOffset,_.byteLength),S=x.getUint8(0),p.id=S===0?x.getUint32(12):x.getUint32(20));var I=Fe(d,["mdia","hdlr"])[0];if(I){var A=Xi(I.subarray(8,12));A==="vide"?p.type="video":A==="soun"?p.type="audio":p.type=A}var O=Fe(d,["mdia","minf","stbl","stsd"])[0];if(O){var j=O.subarray(8);p.codec=Xi(j.subarray(4,8));var Y=Fe(j,[p.codec])[0],q,te;Y&&(/^[asm]vc[1-9]$/i.test(p.codec)?(q=Y.subarray(78),te=Xi(q.subarray(4,8)),te==="avcC"&&q.length>11?(p.codec+=".",p.codec+=qs(q[9]),p.codec+=qs(q[10]),p.codec+=qs(q[11])):p.codec="avc1.4d400d"):/^mp4[a,v]$/i.test(p.codec)?(q=Y.subarray(28),te=Xi(q.subarray(4,8)),te==="esds"&&q.length>20&&q[19]!==0?(p.codec+="."+qs(q[19]),p.codec+="."+qs(q[20]>>>2&63).replace(/^0/,"")):p.codec="mp4a.40.2"):p.codec=p.codec.toLowerCase())}var ne=Fe(d,["mdia","mdhd"])[0];ne&&(p.timescale=xa(ne)),c.push(p)}),c},Kl=function(o,u=0){var c=Fe(o,["emsg"]);return c.map(d=>{var p=ba.parseEmsgBox(new Uint8Array(d)),_=ym(p.message_data);return{cueTime:ba.scaleTime(p.presentation_time,p.timescale,p.presentation_time_delta,u),duration:ba.scaleTime(p.event_duration,p.timescale),frames:_}})};var zs={findBox:Fe,parseType:Xi,timescale:Hl,startTime:ql,compositionStartTime:zl,videoTrackIds:Wl,tracks:Gl,getTimescaleFromMediaHeader:xa,getEmsgID3:Kl};const{parseTrun:_m}=$l,{findBox:Xl}=zs;var Yl=Vl,Tm=function(o){var u=Xl(o,["moof","traf"]),c=Xl(o,["mdat"]),d=[];return c.forEach(function(p,_){var x=u[_];d.push({mdat:p,traf:x})}),d},vm=function(o,u,c){var d=u,p=c.defaultSampleDuration||0,_=c.defaultSampleSize||0,x=c.trackId,S=[];return o.forEach(function(I){var A=_m(I),O=A.samples;O.forEach(function(j){j.duration===void 0&&(j.duration=p),j.size===void 0&&(j.size=_),j.trackId=x,j.dts=d,j.compositionTimeOffset===void 0&&(j.compositionTimeOffset=0),typeof d=="bigint"?(j.pts=d+Yl.BigInt(j.compositionTimeOffset),d+=Yl.BigInt(j.duration)):(j.pts=d+j.compositionTimeOffset,d+=j.duration)}),S=S.concat(O)}),S},Ql={getMdatTrafPairs:Tm,parseSamples:vm},bm=yl.discardEmulationPreventionBytes,xm=_l.CaptionStream,Ea=Kn,Sm=_a,Em=Ta,{getMdatTrafPairs:Cm,parseSamples:wm}=Ql,Im=function(o,u){for(var c=o,d=0;d<u.length;d++){var p=u[d];if(c<p.size)return p;c-=p.size}return null},Am=function(o,u,c){var d=new DataView(o.buffer,o.byteOffset,o.byteLength),p={logs:[],seiNals:[]},_,x,S,I;for(x=0;x+4<o.length;x+=S)if(S=d.getUint32(x),x+=4,!(S<=0))switch(o[x]&31){case 6:var A=o.subarray(x+1,x+1+S),O=Im(x,u);if(_={nalUnitType:"sei_rbsp",size:S,data:A,escapedRBSP:bm(A),trackId:c},O)_.pts=O.pts,_.dts=O.dts,I=O;else if(I)_.pts=I.pts,_.dts=I.dts;else{p.logs.push({level:"warn",message:"We've encountered a nal unit without data at "+x+" for trackId "+c+". See mux.js#223."});break}p.seiNals.push(_);break}return p},km=function(o,u){var c={},d=Cm(o);return d.forEach(function(p){var _=p.mdat,x=p.traf,S=Ea(x,["tfhd"]),I=Em(S[0]),A=I.trackId,O=Ea(x,["tfdt"]),j=O.length>0?Sm(O[0]).baseMediaDecodeTime:0,Y=Ea(x,["trun"]),q,te;u===A&&Y.length>0&&(q=wm(Y,j,I),te=Am(_,q,A),c[A]||(c[A]={seiNals:[],logs:[]}),c[A].seiNals=c[A].seiNals.concat(te.seiNals),c[A].logs=c[A].logs.concat(te.logs))}),c},Pm=function(o,u,c){var d;if(u===null)return null;d=km(o,u);var p=d[u]||{};return{seiNals:p.seiNals,logs:p.logs,timescale:c}},Dm=function(){var o=!1,u,c,d,p,_,x;this.isInitialized=function(){return o},this.init=function(S){u=new xm,o=!0,x=S?S.isPartial:!1,u.on("data",function(I){I.startTime=I.startPts/p,I.endTime=I.endPts/p,_.captions.push(I),_.captionStreams[I.stream]=!0}),u.on("log",function(I){_.logs.push(I)})},this.isNewInit=function(S,I){return S&&S.length===0||I&&typeof I=="object"&&Object.keys(I).length===0?!1:d!==S[0]||p!==I[d]},this.parse=function(S,I,A){var O;if(this.isInitialized()){if(!I||!A)return null;if(this.isNewInit(I,A))d=I[0],p=A[d];else if(d===null||!p)return c.push(S),null}else return null;for(;c.length>0;){var j=c.shift();this.parse(j,I,A)}return O=Pm(S,d,p),O&&O.logs&&(_.logs=_.logs.concat(O.logs)),O===null||!O.seiNals?_.logs.length?{logs:_.logs,captions:[],captionStreams:[]}:null:(this.pushNals(O.seiNals),this.flushStream(),_)},this.pushNals=function(S){if(!this.isInitialized()||!S||S.length===0)return null;S.forEach(function(I){u.push(I)})},this.flushStream=function(){if(!this.isInitialized())return null;x?u.partialFlush():u.flush()},this.clearParsedCaptions=function(){_.captions=[],_.captionStreams={},_.logs=[]},this.resetCaptionStream=function(){if(!this.isInitialized())return null;u.reset()},this.clearAllCaptions=function(){this.clearParsedCaptions(),this.resetCaptionStream()},this.reset=function(){c=[],d=null,p=null,_?this.clearParsedCaptions():_={captions:[],captionStreams:{},logs:[]},this.resetCaptionStream()},this.reset()},Lm=Dm;const{parseTfdt:Om}=$l,mi=Kn,{getTimescaleFromMediaHeader:Rm}=zs,{parseSamples:Mm,getMdatTrafPairs:Nm}=Ql;var Jl=function(){let o=9e4;this.init=function(u){const c=mi(u,["moov","trak","mdia","mdhd"])[0];c&&(o=Rm(c))},this.parseSegment=function(u){const c=[],d=Nm(u);let p=0;return d.forEach(function(_){const x=_.mdat,S=_.traf,I=mi(S,["tfdt"])[0],A=mi(S,["tfhd"])[0],O=mi(S,["trun"]);if(I&&(p=Om(I).baseMediaDecodeTime),O.length&&A){const j=Mm(O,p,A);let Y=0;j.forEach(function(q){const te="utf-8",ne=new TextDecoder(te),ze=x.slice(Y,Y+q.size);if(mi(ze,["vtte"])[0]){Y+=q.size;return}mi(ze,["vttc"]).forEach(function(Ws){const Gs=mi(Ws,["payl"])[0],Ks=mi(Ws,["sttg"])[0],Xs=q.pts/o,Zn=(q.pts+q.duration)/o;let Ie,Ys;if(Gs)try{Ie=ne.decode(Gs)}catch(Mt){console.error(Mt)}if(Ks)try{Ys=ne.decode(Ks)}catch(Mt){console.error(Mt)}q.duration&&Ie&&c.push({cueText:Ie,start:Xs,end:Zn,settings:Ys})}),Y+=q.size})}}),c}},Ca=Rn,Zl=function(o){var u=o[1]&31;return u<<=8,u|=o[2],u},Qn=function(o){return!!(o[1]&64)},Jn=function(o){var u=0;return(o[3]&48)>>>4>1&&(u+=o[4]+1),u},Um=function(o,u){var c=Zl(o);return c===0?"pat":c===u?"pmt":u?"pes":null},Bm=function(o){var u=Qn(o),c=4+Jn(o);return u&&(c+=o[c]+1),(o[c+10]&31)<<8|o[c+11]},Fm=function(o){var u={},c=Qn(o),d=4+Jn(o);if(c&&(d+=o[d]+1),!!(o[d+5]&1)){var p,_,x;p=(o[d+1]&15)<<8|o[d+2],_=3+p-4,x=(o[d+10]&15)<<8|o[d+11];for(var S=12+x;S<_;){var I=d+S;u[(o[I+1]&31)<<8|o[I+2]]=o[I],S+=((o[I+3]&15)<<8|o[I+4])+5}return u}},$m=function(o,u){var c=Zl(o),d=u[c];switch(d){case Ca.H264_STREAM_TYPE:return"video";case Ca.ADTS_STREAM_TYPE:return"audio";case Ca.METADATA_STREAM_TYPE:return"timed-metadata";default:return null}},jm=function(o){var u=Qn(o);if(!u)return null;var c=4+Jn(o);if(c>=o.byteLength)return null;var d=null,p;return p=o[c+7],p&192&&(d={},d.pts=(o[c+9]&14)<<27|(o[c+10]&255)<<20|(o[c+11]&254)<<12|(o[c+12]&255)<<5|(o[c+13]&254)>>>3,d.pts*=4,d.pts+=(o[c+13]&6)>>>1,d.dts=d.pts,p&64&&(d.dts=(o[c+14]&14)<<27|(o[c+15]&255)<<20|(o[c+16]&254)<<12|(o[c+17]&255)<<5|(o[c+18]&254)>>>3,d.dts*=4,d.dts+=(o[c+18]&6)>>>1)),d},wa=function(o){switch(o){case 5:return"slice_layer_without_partitioning_rbsp_idr";case 6:return"sei_rbsp";case 7:return"seq_parameter_set_rbsp";case 8:return"pic_parameter_set_rbsp";case 9:return"access_unit_delimiter_rbsp";default:return null}},Vm=function(o){for(var u=4+Jn(o),c=o.subarray(u),d=0,p=0,_=!1,x;p<c.byteLength-3;p++)if(c[p+2]===1){d=p+5;break}for(;d<c.byteLength;)switch(c[d]){case 0:if(c[d-1]!==0){d+=2;break}else if(c[d-2]!==0){d++;break}p+3!==d-2&&(x=wa(c[p+3]&31),x==="slice_layer_without_partitioning_rbsp_idr"&&(_=!0));do d++;while(c[d]!==1&&d<c.length);p=d-2,d+=3;break;case 1:if(c[d-1]!==0||c[d-2]!==0){d+=3;break}x=wa(c[p+3]&31),x==="slice_layer_without_partitioning_rbsp_idr"&&(_=!0),p=d-2,d+=3;break;default:d+=3;break}return c=c.subarray(p),d-=p,p=0,c&&c.byteLength>3&&(x=wa(c[p+3]&31),x==="slice_layer_without_partitioning_rbsp_idr"&&(_=!0)),_},Hm={parseType:Um,parsePat:Bm,parsePmt:Fm,parsePayloadUnitStartIndicator:Qn,parsePesType:$m,parsePesTime:jm,videoPacketContainsKeyFrame:Vm},eu=Rn,Yi=vl.handleRollover,_e={};_e.ts=Hm,_e.aac=fa;var Li=y.ONE_SECOND_IN_TS,it=188,jt=71,qm=function(o,u){for(var c=0,d=it,p,_;d<o.byteLength;){if(o[c]===jt&&o[d]===jt){switch(p=o.subarray(c,d),_=_e.ts.parseType(p,u.pid),_){case"pat":u.pid=_e.ts.parsePat(p);break;case"pmt":var x=_e.ts.parsePmt(p);u.table=u.table||{},Object.keys(x).forEach(function(S){u.table[S]=x[S]});break}c+=it,d+=it;continue}c++,d++}},tu=function(o,u,c){for(var d=0,p=it,_,x,S,I,A,O=!1;p<=o.byteLength;){if(o[d]===jt&&(o[p]===jt||p===o.byteLength)){switch(_=o.subarray(d,p),x=_e.ts.parseType(_,u.pid),x){case"pes":S=_e.ts.parsePesType(_,u.table),I=_e.ts.parsePayloadUnitStartIndicator(_),S==="audio"&&I&&(A=_e.ts.parsePesTime(_),A&&(A.type="audio",c.audio.push(A),O=!0));break}if(O)break;d+=it,p+=it;continue}d++,p++}for(p=o.byteLength,d=p-it,O=!1;d>=0;){if(o[d]===jt&&(o[p]===jt||p===o.byteLength)){switch(_=o.subarray(d,p),x=_e.ts.parseType(_,u.pid),x){case"pes":S=_e.ts.parsePesType(_,u.table),I=_e.ts.parsePayloadUnitStartIndicator(_),S==="audio"&&I&&(A=_e.ts.parsePesTime(_),A&&(A.type="audio",c.audio.push(A),O=!0));break}if(O)break;d-=it,p-=it;continue}d--,p--}},zm=function(o,u,c){for(var d=0,p=it,_,x,S,I,A,O,j,Y,q=!1,te={data:[],size:0};p<o.byteLength;){if(o[d]===jt&&o[p]===jt){switch(_=o.subarray(d,p),x=_e.ts.parseType(_,u.pid),x){case"pes":if(S=_e.ts.parsePesType(_,u.table),I=_e.ts.parsePayloadUnitStartIndicator(_),S==="video"&&(I&&!q&&(A=_e.ts.parsePesTime(_),A&&(A.type="video",c.video.push(A),q=!0)),!c.firstKeyFrame)){if(I&&te.size!==0){for(O=new Uint8Array(te.size),j=0;te.data.length;)Y=te.data.shift(),O.set(Y,j),j+=Y.byteLength;if(_e.ts.videoPacketContainsKeyFrame(O)){var ne=_e.ts.parsePesTime(O);ne?(c.firstKeyFrame=ne,c.firstKeyFrame.type="video"):console.warn("Failed to extract PTS/DTS from PES at first keyframe. This could be an unusual TS segment, or else mux.js did not parse your TS segment correctly. If you know your TS segments do contain PTS/DTS on keyframes please file a bug report! You can try ffprobe to double check for yourself.")}te.size=0}te.data.push(_),te.size+=_.byteLength}break}if(q&&c.firstKeyFrame)break;d+=it,p+=it;continue}d++,p++}for(p=o.byteLength,d=p-it,q=!1;d>=0;){if(o[d]===jt&&o[p]===jt){switch(_=o.subarray(d,p),x=_e.ts.parseType(_,u.pid),x){case"pes":S=_e.ts.parsePesType(_,u.table),I=_e.ts.parsePayloadUnitStartIndicator(_),S==="video"&&I&&(A=_e.ts.parsePesTime(_),A&&(A.type="video",c.video.push(A),q=!0));break}if(q)break;d-=it,p-=it;continue}d--,p--}},Wm=function(o,u){if(o.audio&&o.audio.length){var c=u;(typeof c>"u"||isNaN(c))&&(c=o.audio[0].dts),o.audio.forEach(function(_){_.dts=Yi(_.dts,c),_.pts=Yi(_.pts,c),_.dtsTime=_.dts/Li,_.ptsTime=_.pts/Li})}if(o.video&&o.video.length){var d=u;if((typeof d>"u"||isNaN(d))&&(d=o.video[0].dts),o.video.forEach(function(_){_.dts=Yi(_.dts,d),_.pts=Yi(_.pts,d),_.dtsTime=_.dts/Li,_.ptsTime=_.pts/Li}),o.firstKeyFrame){var p=o.firstKeyFrame;p.dts=Yi(p.dts,d),p.pts=Yi(p.pts,d),p.dtsTime=p.dts/Li,p.ptsTime=p.pts/Li}}},Gm=function(o){for(var u=!1,c=0,d=null,p=null,_=0,x=0,S;o.length-x>=3;){var I=_e.aac.parseType(o,x);switch(I){case"timed-metadata":if(o.length-x<10){u=!0;break}if(_=_e.aac.parseId3TagSize(o,x),_>o.length){u=!0;break}p===null&&(S=o.subarray(x,x+_),p=_e.aac.parseAacTimestamp(S)),x+=_;break;case"audio":if(o.length-x<7){u=!0;break}if(_=_e.aac.parseAdtsSize(o,x),_>o.length){u=!0;break}d===null&&(S=o.subarray(x,x+_),d=_e.aac.parseSampleRate(S)),c++,x+=_;break;default:x++;break}if(u)return null}if(d===null||p===null)return null;var A=Li/d,O={audio:[{type:"audio",dts:p,pts:p},{type:"audio",dts:p+c*1024*A,pts:p+c*1024*A}]};return O},Km=function(o){var u={pid:null,table:null},c={};qm(o,u);for(var d in u.table)if(u.table.hasOwnProperty(d)){var p=u.table[d];switch(p){case eu.H264_STREAM_TYPE:c.video=[],zm(o,u,c),c.video.length===0&&delete c.video;break;case eu.ADTS_STREAM_TYPE:c.audio=[],tu(o,u,c),c.audio.length===0&&delete c.audio;break}}return c},Xm=function(o,u){var c=_e.aac.isLikelyAacData(o),d;return c?d=Gm(o):d=Km(o),!d||!d.audio&&!d.video?null:(Wm(d,u),d)},Ym={inspect:Xm,parseAudioPes_:tu};const Qm=function(o,u){u.on("data",function(c){const d=c.initSegment;c.initSegment={data:d.buffer,byteOffset:d.byteOffset,byteLength:d.byteLength};const p=c.data;c.data=p.buffer,o.postMessage({action:"data",segment:c,byteOffset:p.byteOffset,byteLength:p.byteLength},[c.data])}),u.on("done",function(c){o.postMessage({action:"done"})}),u.on("gopInfo",function(c){o.postMessage({action:"gopInfo",gopInfo:c})}),u.on("videoSegmentTimingInfo",function(c){const d={start:{decode:y.videoTsToSeconds(c.start.dts),presentation:y.videoTsToSeconds(c.start.pts)},end:{decode:y.videoTsToSeconds(c.end.dts),presentation:y.videoTsToSeconds(c.end.pts)},baseMediaDecodeTime:y.videoTsToSeconds(c.baseMediaDecodeTime)};c.prependedContentDuration&&(d.prependedContentDuration=y.videoTsToSeconds(c.prependedContentDuration)),o.postMessage({action:"videoSegmentTimingInfo",videoSegmentTimingInfo:d})}),u.on("audioSegmentTimingInfo",function(c){const d={start:{decode:y.videoTsToSeconds(c.start.dts),presentation:y.videoTsToSeconds(c.start.pts)},end:{decode:y.videoTsToSeconds(c.end.dts),presentation:y.videoTsToSeconds(c.end.pts)},baseMediaDecodeTime:y.videoTsToSeconds(c.baseMediaDecodeTime)};c.prependedContentDuration&&(d.prependedContentDuration=y.videoTsToSeconds(c.prependedContentDuration)),o.postMessage({action:"audioSegmentTimingInfo",audioSegmentTimingInfo:d})}),u.on("id3Frame",function(c){o.postMessage({action:"id3Frame",id3Frame:c})}),u.on("caption",function(c){o.postMessage({action:"caption",caption:c})}),u.on("trackinfo",function(c){o.postMessage({action:"trackinfo",trackInfo:c})}),u.on("audioTimingInfo",function(c){o.postMessage({action:"audioTimingInfo",audioTimingInfo:{start:y.videoTsToSeconds(c.start),end:y.videoTsToSeconds(c.end)}})}),u.on("videoTimingInfo",function(c){o.postMessage({action:"videoTimingInfo",videoTimingInfo:{start:y.videoTsToSeconds(c.start),end:y.videoTsToSeconds(c.end)}})}),u.on("log",function(c){o.postMessage({action:"log",log:c})})};class iu{constructor(u,c){this.options=c||{},this.self=u,this.init()}init(){this.transmuxer&&this.transmuxer.dispose(),this.transmuxer=new Vp.Transmuxer(this.options),Qm(this.self,this.transmuxer)}pushMp4Captions(u){this.captionParser||(this.captionParser=new Lm,this.captionParser.init());const c=new Uint8Array(u.data,u.byteOffset,u.byteLength),d=this.captionParser.parse(c,u.trackIds,u.timescales);this.self.postMessage({action:"mp4Captions",captions:d&&d.captions||[],logs:d&&d.logs||[],data:c.buffer},[c.buffer])}initMp4WebVttParser(u){this.webVttParser||(this.webVttParser=new Jl);const c=new Uint8Array(u.data,u.byteOffset,u.byteLength);this.webVttParser.init(c)}getMp4WebVttText(u){this.webVttParser||(this.webVttParser=new Jl);const c=new Uint8Array(u.data,u.byteOffset,u.byteLength),d=this.webVttParser.parseSegment(c);this.self.postMessage({action:"getMp4WebVttText",mp4VttCues:d||[],data:c.buffer},[c.buffer])}probeMp4StartTime({timescales:u,data:c}){const d=zs.startTime(u,c);this.self.postMessage({action:"probeMp4StartTime",startTime:d,data:c},[c.buffer])}probeMp4Tracks({data:u}){const c=zs.tracks(u);this.self.postMessage({action:"probeMp4Tracks",tracks:c,data:u},[u.buffer])}probeEmsgID3({data:u,offset:c}){const d=zs.getEmsgID3(u,c);this.self.postMessage({action:"probeEmsgID3",id3Frames:d,emsgData:u},[u.buffer])}probeTs({data:u,baseStartTime:c}){const d=typeof c=="number"&&!isNaN(c)?c*y.ONE_SECOND_IN_TS:void 0,p=Ym.inspect(u,d);let _=null;p&&(_={hasVideo:p.video&&p.video.length===2||!1,hasAudio:p.audio&&p.audio.length===2||!1},_.hasVideo&&(_.videoStart=p.video[0].ptsTime),_.hasAudio&&(_.audioStart=p.audio[0].ptsTime)),this.self.postMessage({action:"probeTs",result:_,data:u},[u.buffer])}clearAllMp4Captions(){this.captionParser&&this.captionParser.clearAllCaptions()}clearParsedMp4Captions(){this.captionParser&&this.captionParser.clearParsedCaptions()}push(u){const c=new Uint8Array(u.data,u.byteOffset,u.byteLength);this.transmuxer.push(c)}reset(){this.transmuxer.reset()}setTimestampOffset(u){const c=u.timestampOffset||0;this.transmuxer.setBaseMediaDecodeTime(Math.round(y.secondsToVideoTs(c)))}setAudioAppendStart(u){this.transmuxer.setAudioAppendStart(Math.ceil(y.secondsToVideoTs(u.appendStart)))}setRemux(u){this.transmuxer.setRemux(u.remux)}flush(u){this.transmuxer.flush(),self.postMessage({action:"done",type:"transmuxed"})}endTimeline(){this.transmuxer.endTimeline(),self.postMessage({action:"endedtimeline",type:"transmuxed"})}alignGopsWith(u){this.transmuxer.alignGopsWith(u.gopsToAlignWith.slice())}}self.onmessage=function(o){if(o.data.action==="init"&&o.data.options){this.messageHandlers=new iu(self,o.data.options);return}this.messageHandlers||(this.messageHandlers=new iu(self)),o.data&&o.data.action&&o.data.action!=="init"&&this.messageHandlers[o.data.action]&&this.messageHandlers[o.data.action](o.data)}}));var Rb=pf(Ob);const Mb=(s,e,t)=>{const{type:i,initSegment:n,captions:r,captionStreams:a,metadata:l,videoFrameDtsTime:h,videoFramePtsTime:f}=s.data.segment;e.buffer.push({captions:r,captionStreams:a,metadata:l});const m=s.data.segment.boxes||{data:s.data.segment.data},T={type:i,data:new Uint8Array(m.data,m.data.byteOffset,m.data.byteLength),initSegment:new Uint8Array(n.data,n.byteOffset,n.byteLength)};typeof h<"u"&&(T.videoFrameDtsTime=h),typeof f<"u"&&(T.videoFramePtsTime=f),t(T)},Nb=({transmuxedData:s,callback:e})=>{s.buffer=[],e(s)},Ub=(s,e)=>{e.gopInfo=s.data.gopInfo},yf=s=>{const{transmuxer:e,bytes:t,audioAppendStart:i,gopsToAlignWith:n,remux:r,onData:a,onTrackInfo:l,onAudioTimingInfo:h,onVideoTimingInfo:f,onVideoSegmentTimingInfo:m,onAudioSegmentTimingInfo:T,onId3:E,onCaptions:C,onDone:P,onEndedTimeline:v,onTransmuxerLog:R,isEndOfTimeline:L,segment:N,triggerSegmentEventFn:U}=s,F={buffer:[]};let D=L;const V=G=>{e.currentTransmux===s&&(G.data.action==="data"&&Mb(G,F,a),G.data.action==="trackinfo"&&l(G.data.trackInfo),G.data.action==="gopInfo"&&Ub(G,F),G.data.action==="audioTimingInfo"&&h(G.data.audioTimingInfo),G.data.action==="videoTimingInfo"&&f(G.data.videoTimingInfo),G.data.action==="videoSegmentTimingInfo"&&m(G.data.videoSegmentTimingInfo),G.data.action==="audioSegmentTimingInfo"&&T(G.data.audioSegmentTimingInfo),G.data.action==="id3Frame"&&E([G.data.id3Frame],G.data.id3Frame.dispatchType),G.data.action==="caption"&&C(G.data.caption),G.data.action==="endedtimeline"&&(D=!1,v()),G.data.action==="log"&&R(G.data.log),G.data.type==="transmuxed"&&(D||(e.onmessage=null,Nb({transmuxedData:F,callback:P}),_f(e))))},X=()=>{const G={message:"Received an error message from the transmuxer worker",metadata:{errorType:B.Error.StreamingFailedToTransmuxSegment,segmentInfo:Mi({segment:N})}};P(null,G)};if(e.onmessage=V,e.onerror=X,i&&e.postMessage({action:"setAudioAppendStart",appendStart:i}),Array.isArray(n)&&e.postMessage({action:"alignGopsWith",gopsToAlignWith:n}),typeof r<"u"&&e.postMessage({action:"setRemux",remux:r}),t.byteLength){const G=t instanceof ArrayBuffer?t:t.buffer,ae=t instanceof ArrayBuffer?0:t.byteOffset;U({type:"segmenttransmuxingstart",segment:N}),e.postMessage({action:"push",data:G,byteOffset:ae,byteLength:t.byteLength},[G])}L&&e.postMessage({action:"endTimeline"}),e.postMessage({action:"flush"})},_f=s=>{s.currentTransmux=null,s.transmuxQueue.length&&(s.currentTransmux=s.transmuxQueue.shift(),typeof s.currentTransmux=="function"?s.currentTransmux():yf(s.currentTransmux))},dc=(s,e)=>{s.postMessage({action:e}),_f(s)},Tf=(s,e)=>{if(!e.currentTransmux){e.currentTransmux=s,dc(e,s);return}e.transmuxQueue.push(dc.bind(null,e,s))},Bb=s=>{Tf("reset",s)},Fb=s=>{Tf("endTimeline",s)},vf=s=>{if(!s.transmuxer.currentTransmux){s.transmuxer.currentTransmux=s,yf(s);return}s.transmuxer.transmuxQueue.push(s)},$b=s=>{const e=new Rb;e.currentTransmux=null,e.transmuxQueue=[];const t=e.terminate;return e.terminate=()=>(e.currentTransmux=null,e.transmuxQueue.length=0,t.call(e)),e.postMessage({action:"init",options:s}),e};var Ga={reset:Bb,endTimeline:Fb,transmux:vf,createTransmuxer:$b};const cs=function(s){const e=s.transmuxer,t=s.endAction||s.action,i=s.callback,n=je({},s,{endAction:null,transmuxer:null,callback:null}),r=a=>{a.data.action===t&&(e.removeEventListener("message",r),a.data.data&&(a.data.data=new Uint8Array(a.data.data,s.byteOffset||0,s.byteLength||a.data.data.byteLength),s.data&&(s.data=a.data.data)),i(a.data))};if(e.addEventListener("message",r),s.data){const a=s.data instanceof ArrayBuffer;n.byteOffset=a?0:s.data.byteOffset,n.byteLength=s.data.byteLength;const l=[a?s.data:s.data.buffer];e.postMessage(n,l)}else e.postMessage(n)},Qt={FAILURE:2,TIMEOUT:-101,ABORTED:-102},bf="wvtt",yo=s=>{s.forEach(e=>{e.abort()})},jb=s=>({bandwidth:s.bandwidth,bytesReceived:s.bytesReceived||0,roundTripTime:s.roundTripTime||0}),Vb=s=>{const e=s.target,i={bandwidth:1/0,bytesReceived:0,roundTripTime:Date.now()-e.requestTime||0};return i.bytesReceived=s.loaded,i.bandwidth=Math.floor(i.bytesReceived/i.roundTripTime*8*1e3),i},fl=(s,e)=>{const{requestType:t}=e,i=Vi({requestType:t,request:e,error:s});return e.timedout?{status:e.status,message:"HLS request timed-out at URL: "+e.uri,code:Qt.TIMEOUT,xhr:e,metadata:i}:e.aborted?{status:e.status,message:"HLS request aborted at URL: "+e.uri,code:Qt.ABORTED,xhr:e,metadata:i}:s?{status:e.status,message:"HLS request errored at URL: "+e.uri,code:Qt.FAILURE,xhr:e,metadata:i}:e.responseType==="arraybuffer"&&e.response.byteLength===0?{status:e.status,message:"Empty HLS response at URL: "+e.uri,code:Qt.FAILURE,xhr:e,metadata:i}:null},hc=(s,e,t,i)=>(n,r)=>{const a=r.response,l=fl(n,r);if(l)return t(l,s);if(a.byteLength!==16)return t({status:r.status,message:"Invalid HLS key at URL: "+r.uri,code:Qt.FAILURE,xhr:r},s);const h=new DataView(a),f=new Uint32Array([h.getUint32(0),h.getUint32(4),h.getUint32(8),h.getUint32(12)]);for(let T=0;T<e.length;T++)e[T].bytes=f;const m={uri:r.uri};return i({type:"segmentkeyloadcomplete",segment:s,keyInfo:m}),t(null,s)},Hb=(s,e)=>{e===bf&&s.transmuxer.postMessage({action:"initMp4WebVttParser",data:s.map.bytes})},qb=(s,e,t)=>{e===bf&&cs({action:"getMp4WebVttText",data:s.bytes,transmuxer:s.transmuxer,callback:({data:i,mp4VttCues:n})=>{s.bytes=i,t(null,s,{mp4VttCues:n})}})},xf=(s,e)=>{const t=Oo(s.map.bytes);if(t!=="mp4"){const i=s.map.resolvedUri||s.map.uri,n=t||"unknown";return e({internal:!0,message:`Found unsupported ${n} container for initialization segment at URL: ${i}`,code:Qt.FAILURE,metadata:{mediaType:n}})}cs({action:"probeMp4Tracks",data:s.map.bytes,transmuxer:s.transmuxer,callback:({tracks:i,data:n})=>(s.map.bytes=n,i.forEach(function(r){s.map.tracks=s.map.tracks||{},!s.map.tracks[r.type]&&(s.map.tracks[r.type]=r,typeof r.id=="number"&&r.timescale&&(s.map.timescales=s.map.timescales||{},s.map.timescales[r.id]=r.timescale),r.type==="text"&&Hb(s,r.codec))}),e(null))})},zb=({segment:s,finishProcessingFn:e,triggerSegmentEventFn:t})=>(i,n)=>{const r=fl(i,n);if(r)return e(r,s);const a=new Uint8Array(n.response);if(t({type:"segmentloaded",segment:s}),s.map.key)return s.map.encryptedBytes=a,e(null,s);s.map.bytes=a,xf(s,function(l){if(l)return l.xhr=n,l.status=n.status,e(l,s);e(null,s)})},Wb=({segment:s,finishProcessingFn:e,responseType:t,triggerSegmentEventFn:i})=>(n,r)=>{const a=fl(n,r);if(a)return e(a,s);i({type:"segmentloaded",segment:s});const l=t==="arraybuffer"||!r.responseText?r.response:Db(r.responseText.substring(s.lastReachedChar||0));return s.stats=jb(r),s.key?s.encryptedBytes=new Uint8Array(l):s.bytes=new Uint8Array(l),e(null,s)},Gb=({segment:s,bytes:e,trackInfoFn:t,timingInfoFn:i,videoSegmentTimingInfoFn:n,audioSegmentTimingInfoFn:r,id3Fn:a,captionsFn:l,isEndOfTimeline:h,endedTimelineFn:f,dataFn:m,doneFn:T,onTransmuxerLog:E,triggerSegmentEventFn:C})=>{const P=s.map&&s.map.tracks||{},v=!!(P.audio&&P.video);let R=i.bind(null,s,"audio","start");const L=i.bind(null,s,"audio","end");let N=i.bind(null,s,"video","start");const U=i.bind(null,s,"video","end"),F=()=>vf({bytes:e,transmuxer:s.transmuxer,audioAppendStart:s.audioAppendStart,gopsToAlignWith:s.gopsToAlignWith,remux:v,onData:D=>{D.type=D.type==="combined"?"video":D.type,m(s,D)},onTrackInfo:D=>{t&&(v&&(D.isMuxed=!0),t(s,D))},onAudioTimingInfo:D=>{R&&typeof D.start<"u"&&(R(D.start),R=null),L&&typeof D.end<"u"&&L(D.end)},onVideoTimingInfo:D=>{N&&typeof D.start<"u"&&(N(D.start),N=null),U&&typeof D.end<"u"&&U(D.end)},onVideoSegmentTimingInfo:D=>{const V={pts:{start:D.start.presentation,end:D.end.presentation},dts:{start:D.start.decode,end:D.end.decode}};C({type:"segmenttransmuxingtiminginfoavailable",segment:s,timingInfo:V}),n(D)},onAudioSegmentTimingInfo:D=>{const V={pts:{start:D.start.pts,end:D.end.pts},dts:{start:D.start.dts,end:D.end.dts}};C({type:"segmenttransmuxingtiminginfoavailable",segment:s,timingInfo:V}),r(D)},onId3:(D,V)=>{a(s,D,V)},onCaptions:D=>{l(s,[D])},isEndOfTimeline:h,onEndedTimeline:()=>{f()},onTransmuxerLog:E,onDone:(D,V)=>{T&&(D.type=D.type==="combined"?"video":D.type,C({type:"segmenttransmuxingcomplete",segment:s}),T(V,s,D))},segment:s,triggerSegmentEventFn:C});cs({action:"probeTs",transmuxer:s.transmuxer,data:e,baseStartTime:s.baseStartTime,callback:D=>{s.bytes=e=D.data;const V=D.result;V&&(t(s,{hasAudio:V.hasAudio,hasVideo:V.hasVideo,isMuxed:v}),t=null),F()}})},Sf=({segment:s,bytes:e,trackInfoFn:t,timingInfoFn:i,videoSegmentTimingInfoFn:n,audioSegmentTimingInfoFn:r,id3Fn:a,captionsFn:l,isEndOfTimeline:h,endedTimelineFn:f,dataFn:m,doneFn:T,onTransmuxerLog:E,triggerSegmentEventFn:C})=>{let P=new Uint8Array(e);if(mT(P)){s.isFmp4=!0;const{tracks:v}=s.map;if(v.text&&(!v.audio||!v.video)){m(s,{data:P,type:"text"}),qb(s,v.text.codec,T);return}const L={isFmp4:!0,hasVideo:!!v.video,hasAudio:!!v.audio};v.audio&&v.audio.codec&&v.audio.codec!=="enca"&&(L.audioCodec=v.audio.codec),v.video&&v.video.codec&&v.video.codec!=="encv"&&(L.videoCodec=v.video.codec),v.video&&v.audio&&(L.isMuxed=!0),t(s,L);const N=(U,F)=>{m(s,{data:P,type:L.hasAudio&&!L.isMuxed?"audio":"video"}),F&&F.length&&a(s,F),U&&U.length&&l(s,U),T(null,s,{})};cs({action:"probeMp4StartTime",timescales:s.map.timescales,data:P,transmuxer:s.transmuxer,callback:({data:U,startTime:F})=>{e=U.buffer,s.bytes=P=U,L.hasAudio&&!L.isMuxed&&i(s,"audio","start",F),L.hasVideo&&i(s,"video","start",F),cs({action:"probeEmsgID3",data:P,transmuxer:s.transmuxer,offset:F,callback:({emsgData:D,id3Frames:V})=>{if(e=D.buffer,s.bytes=P=D,!v.video||!D.byteLength||!s.transmuxer){N(void 0,V);return}cs({action:"pushMp4Captions",endAction:"mp4Captions",transmuxer:s.transmuxer,data:P,timescales:s.map.timescales,trackIds:[v.video.id],callback:X=>{e=X.data.buffer,s.bytes=P=X.data,X.logs.forEach(function(G){E(ge(G,{stream:"mp4CaptionParser"}))}),N(X.captions,V)}})}})}});return}if(!s.transmuxer){T(null,s,{});return}if(typeof s.container>"u"&&(s.container=Oo(P)),s.container!=="ts"&&s.container!=="aac"){t(s,{hasAudio:!1,hasVideo:!1}),T(null,s,{});return}Gb({segment:s,bytes:e,trackInfoFn:t,timingInfoFn:i,videoSegmentTimingInfoFn:n,audioSegmentTimingInfoFn:r,id3Fn:a,captionsFn:l,isEndOfTimeline:h,endedTimelineFn:f,dataFn:m,doneFn:T,onTransmuxerLog:E,triggerSegmentEventFn:C})},Ef=function({id:s,key:e,encryptedBytes:t,decryptionWorker:i,segment:n,doneFn:r},a){const l=f=>{if(f.data.source===s){i.removeEventListener("message",l);const m=f.data.decrypted;a(new Uint8Array(m.bytes,m.byteOffset,m.byteLength))}};i.onerror=()=>{const f="An error occurred in the decryption worker",m=Mi({segment:n}),T={message:f,metadata:{error:new Error(f),errorType:B.Error.StreamingFailedToDecryptSegment,segmentInfo:m,keyInfo:{uri:n.key.resolvedUri||n.map.key.resolvedUri}}};r(T,n)},i.addEventListener("message",l);let h;e.bytes.slice?h=e.bytes.slice():h=new Uint32Array(Array.prototype.slice.call(e.bytes)),i.postMessage(lf({source:s,encrypted:t,key:h,iv:e.iv}),[t.buffer,h.buffer])},Kb=({decryptionWorker:s,segment:e,trackInfoFn:t,timingInfoFn:i,videoSegmentTimingInfoFn:n,audioSegmentTimingInfoFn:r,id3Fn:a,captionsFn:l,isEndOfTimeline:h,endedTimelineFn:f,dataFn:m,doneFn:T,onTransmuxerLog:E,triggerSegmentEventFn:C})=>{C({type:"segmentdecryptionstart"}),Ef({id:e.requestId,key:e.key,encryptedBytes:e.encryptedBytes,decryptionWorker:s,segment:e,doneFn:T},P=>{e.bytes=P,C({type:"segmentdecryptioncomplete",segment:e}),Sf({segment:e,bytes:e.bytes,trackInfoFn:t,timingInfoFn:i,videoSegmentTimingInfoFn:n,audioSegmentTimingInfoFn:r,id3Fn:a,captionsFn:l,isEndOfTimeline:h,endedTimelineFn:f,dataFn:m,doneFn:T,onTransmuxerLog:E,triggerSegmentEventFn:C})})},Xb=({activeXhrs:s,decryptionWorker:e,trackInfoFn:t,timingInfoFn:i,videoSegmentTimingInfoFn:n,audioSegmentTimingInfoFn:r,id3Fn:a,captionsFn:l,isEndOfTimeline:h,endedTimelineFn:f,dataFn:m,doneFn:T,onTransmuxerLog:E,triggerSegmentEventFn:C})=>{let P=0,v=!1;return(R,L)=>{if(!v){if(R)return v=!0,yo(s),T(R,L);if(P+=1,P===s.length){const N=function(){if(L.encryptedBytes)return Kb({decryptionWorker:e,segment:L,trackInfoFn:t,timingInfoFn:i,videoSegmentTimingInfoFn:n,audioSegmentTimingInfoFn:r,id3Fn:a,captionsFn:l,isEndOfTimeline:h,endedTimelineFn:f,dataFn:m,doneFn:T,onTransmuxerLog:E,triggerSegmentEventFn:C});Sf({segment:L,bytes:L.bytes,trackInfoFn:t,timingInfoFn:i,videoSegmentTimingInfoFn:n,audioSegmentTimingInfoFn:r,id3Fn:a,captionsFn:l,isEndOfTimeline:h,endedTimelineFn:f,dataFn:m,doneFn:T,onTransmuxerLog:E,triggerSegmentEventFn:C})};if(L.endOfAllRequests=Date.now(),L.map&&L.map.encryptedBytes&&!L.map.bytes)return C({type:"segmentdecryptionstart",segment:L}),Ef({decryptionWorker:e,id:L.requestId+"-init",encryptedBytes:L.map.encryptedBytes,key:L.map.key,segment:L,doneFn:T},U=>{L.map.bytes=U,C({type:"segmentdecryptioncomplete",segment:L}),xf(L,F=>{if(F)return yo(s),T(F,L);N()})});N()}}}},Yb=({loadendState:s,abortFn:e})=>t=>{t.target.aborted&&e&&!s.calledAbortFn&&(e(),s.calledAbortFn=!0)},Qb=({segment:s,progressFn:e,trackInfoFn:t,timingInfoFn:i,videoSegmentTimingInfoFn:n,audioSegmentTimingInfoFn:r,id3Fn:a,captionsFn:l,isEndOfTimeline:h,endedTimelineFn:f,dataFn:m})=>T=>{if(!T.target.aborted)return s.stats=ge(s.stats,Vb(T)),!s.stats.firstBytesReceivedAt&&s.stats.bytesReceived&&(s.stats.firstBytesReceivedAt=Date.now()),e(T,s)},Jb=({xhr:s,xhrOptions:e,decryptionWorker:t,segment:i,abortFn:n,progressFn:r,trackInfoFn:a,timingInfoFn:l,videoSegmentTimingInfoFn:h,audioSegmentTimingInfoFn:f,id3Fn:m,captionsFn:T,isEndOfTimeline:E,endedTimelineFn:C,dataFn:P,doneFn:v,onTransmuxerLog:R,triggerSegmentEventFn:L})=>{const N=[],U=Xb({activeXhrs:N,decryptionWorker:t,trackInfoFn:a,timingInfoFn:l,videoSegmentTimingInfoFn:h,audioSegmentTimingInfoFn:f,id3Fn:m,captionsFn:T,isEndOfTimeline:E,endedTimelineFn:C,dataFn:P,doneFn:v,onTransmuxerLog:R,triggerSegmentEventFn:L});if(i.key&&!i.key.bytes){const G=[i.key];i.map&&!i.map.bytes&&i.map.key&&i.map.key.resolvedUri===i.key.resolvedUri&&G.push(i.map.key);const ae=ge(e,{uri:i.key.resolvedUri,responseType:"arraybuffer",requestType:"segment-key"}),fe=hc(i,G,U,L),ve={uri:i.key.resolvedUri};L({type:"segmentkeyloadstart",segment:i,keyInfo:ve});const he=s(ae,fe);N.push(he)}if(i.map&&!i.map.bytes){if(i.map.key&&(!i.key||i.key.resolvedUri!==i.map.key.resolvedUri)){const he=ge(e,{uri:i.map.key.resolvedUri,responseType:"arraybuffer",requestType:"segment-key"}),Z=hc(i,[i.map.key],U,L),de={uri:i.map.key.resolvedUri};L({type:"segmentkeyloadstart",segment:i,keyInfo:de});const ee=s(he,Z);N.push(ee)}const ae=ge(e,{uri:i.map.resolvedUri,responseType:"arraybuffer",headers:mo(i.map),requestType:"segment-media-initialization"}),fe=zb({segment:i,finishProcessingFn:U,triggerSegmentEventFn:L});L({type:"segmentloadstart",segment:i});const ve=s(ae,fe);N.push(ve)}const F=ge(e,{uri:i.part&&i.part.resolvedUri||i.resolvedUri,responseType:"arraybuffer",headers:mo(i),requestType:"segment"}),D=Wb({segment:i,finishProcessingFn:U,responseType:F.responseType,triggerSegmentEventFn:L});L({type:"segmentloadstart",segment:i});const V=s(F,D);V.addEventListener("progress",Qb({segment:i,progressFn:r,trackInfoFn:a,timingInfoFn:l,videoSegmentTimingInfoFn:h,audioSegmentTimingInfoFn:f,id3Fn:m,captionsFn:T,isEndOfTimeline:E,endedTimelineFn:C,dataFn:P})),N.push(V);const X={};return N.forEach(G=>{G.addEventListener("loadend",Yb({loadendState:X,abortFn:n}))}),()=>yo(N)},Zb=Pt("CodecUtils"),ex=function(s){const e=s.attributes||{};if(e.CODECS)return zt(e.CODECS)},Cf=(s,e)=>{const t=e.attributes||{};return s&&s.mediaGroups&&s.mediaGroups.AUDIO&&t.AUDIO&&s.mediaGroups.AUDIO[t.AUDIO]},tx=(s,e)=>{if(!Cf(s,e))return!0;const t=e.attributes||{},i=s.mediaGroups.AUDIO[t.AUDIO];for(const n in i)if(!i[n].uri&&!i[n].playlists)return!0;return!1},kr=function(s){const e={};return s.forEach(({mediaType:t,type:i,details:n})=>{e[t]=e[t]||[],e[t].push(ad(`${i}${n}`))}),Object.keys(e).forEach(function(t){if(e[t].length>1){Zb(`multiple ${t} codecs found as attributes: ${e[t].join(", ")}. Setting playlist codecs to null so that we wait for mux.js to probe segments for real codecs.`),e[t]=null;return}e[t]=e[t][0]}),e},fc=function(s){let e=0;return s.audio&&e++,s.video&&e++,e},gn=function(s,e){const t=e.attributes||{},i=kr(ex(e)||[]);if(Cf(s,e)&&!i.audio&&!tx(s,e)){const n=kr(zy(s,t.AUDIO)||[]);n.audio&&(i.audio=n.audio)}return i},nr=Pt("PlaylistSelector"),pc=function(s){if(!s||!s.playlist)return;const e=s.playlist;return JSON.stringify({id:e.id,bandwidth:s.bandwidth,width:s.width,height:s.height,codecs:e.attributes&&e.attributes.CODECS||""})},Pr=function(s,e){if(!s)return"";const t=k.getComputedStyle(s);return t?t[e]:""},ds=function(s,e){const t=s.slice();s.sort(function(i,n){const r=e(i,n);return r===0?t.indexOf(i)-t.indexOf(n):r})},pl=function(s,e){let t,i;return s.attributes.BANDWIDTH&&(t=s.attributes.BANDWIDTH),t=t||k.Number.MAX_VALUE,e.attributes.BANDWIDTH&&(i=e.attributes.BANDWIDTH),i=i||k.Number.MAX_VALUE,t-i},ix=function(s,e){let t,i;return s.attributes.RESOLUTION&&s.attributes.RESOLUTION.width&&(t=s.attributes.RESOLUTION.width),t=t||k.Number.MAX_VALUE,e.attributes.RESOLUTION&&e.attributes.RESOLUTION.width&&(i=e.attributes.RESOLUTION.width),i=i||k.Number.MAX_VALUE,t===i&&s.attributes.BANDWIDTH&&e.attributes.BANDWIDTH?s.attributes.BANDWIDTH-e.attributes.BANDWIDTH:t-i};let wf=function(s,e,t,i,n,r){if(!s)return;const a={bandwidth:e,width:t,height:i,limitRenditionByPlayerDimensions:n};let l=s.playlists;ht.isAudioOnly(s)&&(l=r.getAudioTrackPlaylists_(),a.audioOnly=!0);let h=l.map(D=>{let V;const X=D.attributes&&D.attributes.RESOLUTION&&D.attributes.RESOLUTION.width,G=D.attributes&&D.attributes.RESOLUTION&&D.attributes.RESOLUTION.height;return V=D.attributes&&D.attributes.BANDWIDTH,V=V||k.Number.MAX_VALUE,{bandwidth:V,width:X,height:G,playlist:D}});ds(h,(D,V)=>D.bandwidth-V.bandwidth),h=h.filter(D=>!ht.isIncompatible(D.playlist));let f=h.filter(D=>ht.isEnabled(D.playlist));f.length||(f=h.filter(D=>!ht.isDisabled(D.playlist)));const m=f.filter(D=>D.bandwidth*We.BANDWIDTH_VARIANCE<e);let T=m[m.length-1];const E=m.filter(D=>D.bandwidth===T.bandwidth)[0];if(n===!1){const D=E||f[0]||h[0];if(D&&D.playlist){let V="sortedPlaylistReps";return E&&(V="bandwidthBestRep"),f[0]&&(V="enabledPlaylistReps"),nr(`choosing ${pc(D)} using ${V} with options`,a),D.playlist}return nr("could not choose a playlist with options",a),null}const C=m.filter(D=>D.width&&D.height);ds(C,(D,V)=>D.width-V.width);const P=C.filter(D=>D.width===t&&D.height===i);T=P[P.length-1];const v=P.filter(D=>D.bandwidth===T.bandwidth)[0];let R,L,N;v||(R=C.filter(D=>D.width>t||D.height>i),L=R.filter(D=>D.width===R[0].width&&D.height===R[0].height),T=L[L.length-1],N=L.filter(D=>D.bandwidth===T.bandwidth)[0]);let U;if(r.leastPixelDiffSelector){const D=C.map(V=>(V.pixelDiff=Math.abs(V.width-t)+Math.abs(V.height-i),V));ds(D,(V,X)=>V.pixelDiff===X.pixelDiff?X.bandwidth-V.bandwidth:V.pixelDiff-X.pixelDiff),U=D[0]}const F=U||N||v||E||f[0]||h[0];if(F&&F.playlist){let D="sortedPlaylistReps";return U?D="leastPixelDiffRep":N?D="resolutionPlusOneRep":v?D="resolutionBestRep":E?D="bandwidthBestRep":f[0]&&(D="enabledPlaylistReps"),nr(`choosing ${pc(F)} using ${D} with options`,a),F.playlist}return nr("could not choose a playlist with options",a),null};const mc=function(){let s=this.useDevicePixelRatio&&k.devicePixelRatio||1;return isNaN(this.customPixelRatio)||(s=this.customPixelRatio),wf(this.playlists.main,this.systemBandwidth,parseInt(Pr(this.tech_.el(),"width"),10)*s,parseInt(Pr(this.tech_.el(),"height"),10)*s,this.limitRenditionByPlayerDimensions,this.playlistController_)},sx=function(s){let e=-1,t=-1;if(s<0||s>1)throw new Error("Moving average bandwidth decay must be between 0 and 1.");return function(){let i=this.useDevicePixelRatio&&k.devicePixelRatio||1;return isNaN(this.customPixelRatio)||(i=this.customPixelRatio),e<0&&(e=this.systemBandwidth,t=this.systemBandwidth),this.systemBandwidth>0&&this.systemBandwidth!==t&&(e=s*this.systemBandwidth+(1-s)*e,t=this.systemBandwidth),wf(this.playlists.main,e,parseInt(Pr(this.tech_.el(),"width"),10)*i,parseInt(Pr(this.tech_.el(),"height"),10)*i,this.limitRenditionByPlayerDimensions,this.playlistController_)}},nx=function(s){const{main:e,currentTime:t,bandwidth:i,duration:n,segmentDuration:r,timeUntilRebuffer:a,currentTimeline:l,syncController:h}=s,f=e.playlists.filter(P=>!ht.isIncompatible(P));let m=f.filter(ht.isEnabled);m.length||(m=f.filter(P=>!ht.isDisabled(P)));const E=m.filter(ht.hasAttribute.bind(null,"BANDWIDTH")).map(P=>{const R=h.getSyncPoint(P,n,l,t)?1:2,N=ht.estimateSegmentRequestTime(r,i,P)*R-a;return{playlist:P,rebufferingImpact:N}}),C=E.filter(P=>P.rebufferingImpact<=0);return ds(C,(P,v)=>pl(v.playlist,P.playlist)),C.length?C[0]:(ds(E,(P,v)=>P.rebufferingImpact-v.rebufferingImpact),E[0]||null)},rx=function(){const s=this.playlists.main.playlists.filter(ht.isEnabled);return ds(s,(t,i)=>pl(t,i)),s.filter(t=>!!gn(this.playlists.main,t).video)[0]||null},ax=s=>{let e=0,t;return s.bytes&&(t=new Uint8Array(s.bytes),s.segments.forEach(i=>{t.set(i,e),e+=i.byteLength})),t};function If(s){try{return new URL(s).pathname.split("/").slice(-2).join("/")}catch{return""}}const ox=function(s,e,t){if(!s[t]){e.trigger({type:"usage",name:"vhs-608"});let i=t;/^cc708_/.test(t)&&(i="SERVICE"+t.split("_")[1]);const n=e.textTracks().getTrackById(i);if(n)s[t]=n;else{const r=e.options_.vhs&&e.options_.vhs.captionServices||{};let a=t,l=t,h=!1;const f=r[i];f&&(a=f.label,l=f.language,h=f.default),s[t]=e.addRemoteTextTrack({kind:"captions",id:i,default:h,label:a,language:l},!1).track}}},lx=function({inbandTextTracks:s,captionArray:e,timestampOffset:t}){if(!e)return;const i=k.WebKitDataCue||k.VTTCue;e.forEach(n=>{const r=n.stream;n.content?n.content.forEach(a=>{const l=new i(n.startTime+t,n.endTime+t,a.text);l.line=a.line,l.align="left",l.position=a.position,l.positionAlign="line-left",s[r].addCue(l)}):s[r].addCue(new i(n.startTime+t,n.endTime+t,n.text))})},ux=function(s){Object.defineProperties(s.frame,{id:{get(){return B.log.warn("cue.frame.id is deprecated. Use cue.value.key instead."),s.value.key}},value:{get(){return B.log.warn("cue.frame.value is deprecated. Use cue.value.data instead."),s.value.data}},privateData:{get(){return B.log.warn("cue.frame.privateData is deprecated. Use cue.value.data instead."),s.value.data}}})},cx=({inbandTextTracks:s,metadataArray:e,timestampOffset:t,videoDuration:i})=>{if(!e)return;const n=k.WebKitDataCue||k.VTTCue,r=s.metadataTrack_;if(!r||(e.forEach(m=>{const T=m.cueTime+t;typeof T!="number"||k.isNaN(T)||T<0||!(T<1/0)||!m.frames||!m.frames.length||m.frames.forEach(E=>{const C=new n(T,T,E.value||E.url||E.data||"");C.frame=E,C.value=E,ux(C),r.addCue(C)})}),!r.cues||!r.cues.length))return;const a=r.cues,l=[];for(let m=0;m<a.length;m++)a[m]&&l.push(a[m]);const h=l.reduce((m,T)=>{const E=m[T.startTime]||[];return E.push(T),m[T.startTime]=E,m},{}),f=Object.keys(h).sort((m,T)=>Number(m)-Number(T));f.forEach((m,T)=>{const E=h[m],C=isFinite(i)?i:m,P=Number(f[T+1])||C;E.forEach(v=>{v.endTime=P})})},dx={id:"ID",class:"CLASS",startDate:"START-DATE",duration:"DURATION",endDate:"END-DATE",endOnNext:"END-ON-NEXT",plannedDuration:"PLANNED-DURATION",scte35Out:"SCTE35-OUT",scte35In:"SCTE35-IN"},hx=new Set(["id","class","startDate","duration","endDate","endOnNext","startTime","endTime","processDateRange"]),fx=({inbandTextTracks:s,dateRanges:e})=>{const t=s.metadataTrack_;if(!t)return;const i=k.WebKitDataCue||k.VTTCue;e.forEach(n=>{for(const r of Object.keys(n)){if(hx.has(r))continue;const a=new i(n.startTime,n.endTime,"");a.id=n.id,a.type="com.apple.quicktime.HLS",a.value={key:dx[r],data:n[r]},(r==="scte35Out"||r==="scte35In")&&(a.value.data=new Uint8Array(a.value.data.match(/[\da-f]{2}/gi)).buffer),t.addCue(a)}n.processDateRange()})},gc=(s,e,t)=>{s.metadataTrack_||(s.metadataTrack_=t.addRemoteTextTrack({kind:"metadata",label:"Timed Metadata"},!1).track,B.browser.IS_ANY_SAFARI||(s.metadataTrack_.inBandMetadataTrackDispatchType=e))},un=function(s,e,t){let i,n;if(t&&t.cues)for(i=t.cues.length;i--;)n=t.cues[i],n.startTime>=s&&n.endTime<=e&&t.removeCue(n)},px=function(s){const e=s.cues;if(!e)return;const t={};for(let i=e.length-1;i>=0;i--){const n=e[i],r=`${n.startTime}-${n.endTime}-${n.text}`;t[r]?s.removeCue(n):t[r]=n}},mx=(s,e,t)=>{if(typeof e>"u"||e===null||!s.length)return[];const i=Math.ceil((e-t+3)*Ni.ONE_SECOND_IN_TS);let n;for(n=0;n<s.length&&!(s[n].pts>i);n++);return s.slice(n)},gx=(s,e,t)=>{if(!e.length)return s;if(t)return e.slice();const i=e[0].pts;let n=0;for(n;n<s.length&&!(s[n].pts>=i);n++);return s.slice(0,n).concat(e)},yx=(s,e,t,i)=>{const n=Math.ceil((e-i)*Ni.ONE_SECOND_IN_TS),r=Math.ceil((t-i)*Ni.ONE_SECOND_IN_TS),a=s.slice();let l=s.length;for(;l--&&!(s[l].pts<=r););if(l===-1)return a;let h=l+1;for(;h--&&!(s[h].pts<=n););return h=Math.max(h,0),a.splice(h,l-h+1),a},_x=function(s,e){if(!s&&!e||!s&&e||s&&!e)return!1;if(s===e)return!0;const t=Object.keys(s).sort(),i=Object.keys(e).sort();if(t.length!==i.length)return!1;for(let n=0;n<t.length;n++){const r=t[n];if(r!==i[n]||s[r]!==e[r])return!1}return!0},Tx=function(s,e,t){e=e||[];const i=[];let n=0;for(let r=0;r<e.length;r++){const a=e[r];if(s===a.timeline&&(i.push(r),n+=a.duration,n>t))return r}return i.length===0?0:i[i.length-1]},tn=1,vx=500,yc=s=>typeof s=="number"&&isFinite(s),rr=1/60,bx=(s,e,t)=>s!=="main"||!e||!t?null:!t.hasAudio&&!t.hasVideo?"Neither audio nor video found in segment.":e.hasVideo&&!t.hasVideo?"Only audio found in segment when we expected video. We can't switch to audio only from a stream that had video. To get rid of this message, please add codec information to the manifest.":!e.hasVideo&&t.hasVideo?"Video found in segment when we expected only audio. We can't switch to a stream with video from an audio only stream. To get rid of this message, please add codec information to the manifest.":null,xx=(s,e,t)=>{let i=e-We.BACK_BUFFER_LENGTH;s.length&&(i=Math.max(i,s.start(0)));const n=e-t;return Math.min(n,i)},es=s=>{const{startOfSegment:e,duration:t,segment:i,part:n,playlist:{mediaSequence:r,id:a,segments:l=[]},mediaIndex:h,partIndex:f,timeline:m}=s,T=l.length-1;let E="mediaIndex/partIndex increment";s.getMediaInfoForTime?E=`getMediaInfoForTime (${s.getMediaInfoForTime})`:s.isSyncRequest&&(E="getSyncSegmentCandidate (isSyncRequest)"),s.independent&&(E+=` with independent ${s.independent}`);const C=typeof f=="number",P=s.segment.uri?"segment":"pre-segment",v=C?zh({preloadSegment:i})-1:0;return`${P} [${r+h}/${r+T}]`+(C?` part [${f}/${v}]`:"")+` segment start/end [${i.start} => ${i.end}]`+(C?` part start/end [${n.start} => ${n.end}]`:"")+` startOfSegment [${e}] duration [${t}] timeline [${m}] selected by [${E}] playlist [${a}]`},_c=s=>`${s}TimingInfo`,Sx=({segmentTimeline:s,currentTimeline:e,startOfSegment:t,buffered:i,overrideCheck:n})=>!n&&s===e?null:s<e?t:i.length?i.end(i.length-1):t,_o=({timelineChangeController:s,currentTimeline:e,segmentTimeline:t,loaderType:i,audioDisabled:n})=>{if(e===t)return!1;if(i==="audio"){const r=s.lastTimelineChange({type:"main"});return!r||r.to!==t}if(i==="main"&&n){const r=s.pendingTimelineChange({type:"audio"});return!(r&&r.to===t)}return!1},Ex=s=>{if(!s)return!1;const e=s.pendingTimelineChange({type:"audio"}),t=s.pendingTimelineChange({type:"main"}),i=e&&t,n=i&&e.to!==t.to;return!!(i&&e.from!==-1&&t.from!==-1&&n)},Cx=s=>{const e=s.timelineChangeController_.pendingTimelineChange({type:"audio"}),t=s.timelineChangeController_.pendingTimelineChange({type:"main"});return e&&t&&e.to<t.to},Ti=s=>{const e=s.pendingSegment_;if(!e)return;if(_o({timelineChangeController:s.timelineChangeController_,currentTimeline:s.currentTimeline_,segmentTimeline:e.timeline,loaderType:s.loaderType_,audioDisabled:s.audioDisabled_})&&Ex(s.timelineChangeController_)){if(Cx(s)){s.timelineChangeController_.trigger("audioTimelineBehind");return}s.timelineChangeController_.trigger("fixBadTimelineChange")}},wx=s=>{let e=0;return["video","audio"].forEach(function(t){const i=s[`${t}TimingInfo`];if(!i)return;const{start:n,end:r}=i;let a;typeof n=="bigint"||typeof r=="bigint"?a=k.BigInt(r)-k.BigInt(n):typeof n=="number"&&typeof r=="number"&&(a=r-n),typeof a<"u"&&a>e&&(e=a)}),typeof e=="bigint"&&e<Number.MAX_SAFE_INTEGER&&(e=Number(e)),e},Tc=({segmentDuration:s,maxDuration:e})=>s?Math.round(s)>e+Xt:!1,Ix=(s,e)=>{if(e!=="hls")return null;const t=wx({audioTimingInfo:s.audioTimingInfo,videoTimingInfo:s.videoTimingInfo});if(!t)return null;const i=s.playlist.targetDuration,n=Tc({segmentDuration:t,maxDuration:i*2}),r=Tc({segmentDuration:t,maxDuration:i}),a=`Segment with index ${s.mediaIndex} from playlist ${s.playlist.id} has a duration of ${t} when the reported duration is ${s.duration} and the target duration is ${i}. For HLS content, a duration in excess of the target duration may result in playback issues. See the HLS specification section on EXT-X-TARGETDURATION for more details: https://tools.ietf.org/html/draft-pantos-http-live-streaming-23#section-4.3.3.1`;return n||r?{severity:n?"warn":"info",message:a}:null},Mi=({type:s,segment:e})=>{if(!e)return;const t=!!(e.key||e.map&&e.map.ke),i=!!(e.map&&!e.map.bytes),n=e.startOfSegment===void 0?e.start:e.startOfSegment;return{type:s||e.type,uri:e.resolvedUri||e.uri,start:n,duration:e.duration,isEncrypted:t,isMediaInitialization:i}};class To extends B.EventTarget{constructor(e,t={}){if(super(),!e)throw new TypeError("Initialization settings are required");if(typeof e.currentTime!="function")throw new TypeError("No currentTime getter specified");if(!e.mediaSource)throw new TypeError("No MediaSource specified");this.bandwidth=e.bandwidth,this.throughput={rate:0,count:0},this.roundTrip=NaN,this.resetStats_(),this.mediaIndex=null,this.partIndex=null,this.hasPlayed_=e.hasPlayed,this.currentTime_=e.currentTime,this.seekable_=e.seekable,this.seeking_=e.seeking,this.duration_=e.duration,this.mediaSource_=e.mediaSource,this.vhs_=e.vhs,this.loaderType_=e.loaderType,this.currentMediaInfo_=void 0,this.startingMediaInfo_=void 0,this.segmentMetadataTrack_=e.segmentMetadataTrack,this.goalBufferLength_=e.goalBufferLength,this.sourceType_=e.sourceType,this.sourceUpdater_=e.sourceUpdater,this.inbandTextTracks_=e.inbandTextTracks,this.state_="INIT",this.timelineChangeController_=e.timelineChangeController,this.shouldSaveSegmentTimingInfo_=!0,this.parse708captions_=e.parse708captions,this.useDtsForTimestampOffset_=e.useDtsForTimestampOffset,this.captionServices_=e.captionServices,this.exactManifestTimings=e.exactManifestTimings,this.addMetadataToTextTrack=e.addMetadataToTextTrack,this.checkBufferTimeout_=null,this.error_=void 0,this.currentTimeline_=-1,this.shouldForceTimestampOffsetAfterResync_=!1,this.pendingSegment_=null,this.xhrOptions_=null,this.pendingSegments_=[],this.audioDisabled_=!1,this.isPendingTimestampOffset_=!1,this.gopBuffer_=[],this.timeMapping_=0,this.safeAppend_=!1,this.appendInitSegment_={audio:!0,video:!0},this.playlistOfLastInitSegment_={audio:null,video:null},this.callQueue_=[],this.loadQueue_=[],this.metadataQueue_={id3:[],caption:[]},this.waitingOnRemove_=!1,this.quotaExceededErrorRetryTimeout_=null,this.activeInitSegmentId_=null,this.initSegments_={},this.cacheEncryptionKeys_=e.cacheEncryptionKeys,this.keyCache_={},this.decrypter_=e.decrypter,this.syncController_=e.syncController,this.syncPoint_={segmentIndex:0,time:0},this.transmuxer_=this.createTransmuxer_(),this.triggerSyncInfoUpdate_=()=>this.trigger("syncinfoupdate"),this.syncController_.on("syncinfoupdate",this.triggerSyncInfoUpdate_),this.mediaSource_.addEventListener("sourceopen",()=>{this.isEndOfStream_()||(this.ended_=!1)}),this.fetchAtBuffer_=!1,this.logger_=Pt(`SegmentLoader[${this.loaderType_}]`),Object.defineProperty(this,"state",{get(){return this.state_},set(i){i!==this.state_&&(this.logger_(`${this.state_} -> ${i}`),this.state_=i,this.trigger("statechange"))}}),this.sourceUpdater_.on("ready",()=>{this.hasEnoughInfoToAppend_()?this.processCallQueue_():Ti(this)}),this.sourceUpdater_.on("codecschange",i=>{this.trigger(je({type:"codecschange"},i))}),this.loaderType_==="main"&&this.timelineChangeController_.on("pendingtimelinechange",()=>{this.hasEnoughInfoToAppend_()?this.processCallQueue_():Ti(this)}),this.loaderType_==="audio"&&this.timelineChangeController_.on("timelinechange",i=>{this.trigger(je({type:"timelinechange"},i)),this.hasEnoughInfoToLoad_()?this.processLoadQueue_():Ti(this),this.hasEnoughInfoToAppend_()?this.processCallQueue_():Ti(this)})}get mediaSequenceSync_(){return this.syncController_.getMediaSequenceSync(this.loaderType_)}createTransmuxer_(){return Ga.createTransmuxer({remux:!1,alignGopsAtEnd:this.safeAppend_,keepOriginalTimestamps:!0,parse708captions:this.parse708captions_,captionServices:this.captionServices_})}resetStats_(){this.mediaBytesTransferred=0,this.mediaRequests=0,this.mediaRequestsAborted=0,this.mediaRequestsTimedout=0,this.mediaRequestsErrored=0,this.mediaTransferDuration=0,this.mediaSecondsLoaded=0,this.mediaAppends=0}dispose(){this.trigger("dispose"),this.state="DISPOSED",this.pause(),this.abort_(),this.transmuxer_&&this.transmuxer_.terminate(),this.resetStats_(),this.checkBufferTimeout_&&k.clearTimeout(this.checkBufferTimeout_),this.syncController_&&this.triggerSyncInfoUpdate_&&this.syncController_.off("syncinfoupdate",this.triggerSyncInfoUpdate_),this.off()}setAudio(e){this.audioDisabled_=!e,e?this.appendInitSegment_.audio=!0:this.sourceUpdater_.removeAudio(0,this.duration_())}abort(){if(this.state!=="WAITING"){this.pendingSegment_&&(this.pendingSegment_=null),this.timelineChangeController_.clearPendingTimelineChange(this.loaderType_);return}this.abort_(),this.state="READY",this.paused()||this.monitorBuffer_()}abort_(){this.pendingSegment_&&this.pendingSegment_.abortRequests&&this.pendingSegment_.abortRequests(),this.pendingSegment_=null,this.callQueue_=[],this.loadQueue_=[],this.metadataQueue_.id3=[],this.metadataQueue_.caption=[],this.timelineChangeController_.clearPendingTimelineChange(this.loaderType_),this.waitingOnRemove_=!1,k.clearTimeout(this.quotaExceededErrorRetryTimeout_),this.quotaExceededErrorRetryTimeout_=null}checkForAbort_(e){return this.state==="APPENDING"&&!this.pendingSegment_?(this.state="READY",!0):!this.pendingSegment_||this.pendingSegment_.requestId!==e}error(e){return typeof e<"u"&&(this.logger_("error occurred:",e),this.error_=e),this.pendingSegment_=null,this.error_}endOfStream(){this.ended_=!0,this.transmuxer_&&Ga.reset(this.transmuxer_),this.gopBuffer_.length=0,this.pause(),this.trigger("ended")}buffered_(){const e=this.getMediaInfo_();if(!this.sourceUpdater_||!e)return Ke();if(this.loaderType_==="main"){const{hasAudio:t,hasVideo:i,isMuxed:n}=e;if(i&&t&&!this.audioDisabled_&&!n)return this.sourceUpdater_.buffered();if(i)return this.sourceUpdater_.videoBuffered()}return this.sourceUpdater_.audioBuffered()}initSegmentForMap(e,t=!1){if(!e)return null;const i=Ar(e);let n=this.initSegments_[i];return t&&!n&&e.bytes&&(this.initSegments_[i]=n={resolvedUri:e.resolvedUri,byterange:e.byterange,bytes:e.bytes,tracks:e.tracks,timescales:e.timescales}),n||e}segmentKey(e,t=!1){if(!e)return null;const i=uf(e);let n=this.keyCache_[i];this.cacheEncryptionKeys_&&t&&!n&&e.bytes&&(this.keyCache_[i]=n={resolvedUri:e.resolvedUri,bytes:e.bytes});const r={resolvedUri:(n||e).resolvedUri};return n&&(r.bytes=n.bytes),r}couldBeginLoading_(){return this.playlist_&&!this.paused()}load(){if(this.monitorBuffer_(),!!this.playlist_){if(this.state==="INIT"&&this.couldBeginLoading_())return this.init_();!this.couldBeginLoading_()||this.state!=="READY"&&this.state!=="INIT"||(this.state="READY")}}init_(){return this.state="READY",this.resetEverything(),this.monitorBuffer_()}playlist(e,t={}){if(!e||this.playlist_&&this.playlist_.endList&&e.endList&&this.playlist_.uri===e.uri)return;const i=this.playlist_,n=this.pendingSegment_;this.playlist_=e,this.xhrOptions_=t,this.state==="INIT"&&(e.syncInfo={mediaSequence:e.mediaSequence,time:0},this.loaderType_==="main"&&this.syncController_.setDateTimeMappingForStart(e));let r=null;if(i&&(i.id?r=i.id:i.uri&&(r=i.uri)),this.logger_(`playlist update [${r} => ${e.id||e.uri}]`),this.mediaSequenceSync_&&(this.mediaSequenceSync_.update(e,this.currentTime_()),this.logger_(`Playlist update:
|
|
205
205
|
currentTime: ${this.currentTime_()}
|
|
206
|
-
bufferedEnd: ${
|
|
207
|
-
`,this.mediaSequenceSync_.diagnostics)),this.trigger("syncinfoupdate"),this.state==="INIT"&&this.couldBeginLoading_())return this.init_();if(!
|
|
206
|
+
bufferedEnd: ${za(this.buffered_())}
|
|
207
|
+
`,this.mediaSequenceSync_.diagnostics)),this.trigger("syncinfoupdate"),this.state==="INIT"&&this.couldBeginLoading_())return this.init_();if(!i||i.uri!==e.uri){this.mediaIndex!==null&&(!e.endList&&typeof e.partTargetDuration=="number"?this.resetLoader():this.resyncLoader()),this.currentMediaInfo_=void 0,this.trigger("playlistupdate");return}const a=e.mediaSequence-i.mediaSequence;if(this.logger_(`live window shift [${a}]`),this.mediaIndex!==null)if(this.mediaIndex-=a,this.mediaIndex<0)this.mediaIndex=null,this.partIndex=null;else{const l=this.playlist_.segments[this.mediaIndex];if(this.partIndex&&(!l.parts||!l.parts.length||!l.parts[this.partIndex])){const h=this.mediaIndex;this.logger_(`currently processing part (index ${this.partIndex}) no longer exists.`),this.resetLoader(),this.mediaIndex=h}}n&&(n.mediaIndex-=a,n.mediaIndex<0?(n.mediaIndex=null,n.partIndex=null):(n.mediaIndex>=0&&(n.segment=e.segments[n.mediaIndex]),n.partIndex>=0&&n.segment.parts&&(n.part=n.segment.parts[n.partIndex]))),this.syncController_.saveExpiredSegmentInfo(i,e)}pause(){this.checkBufferTimeout_&&(k.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=null)}paused(){return this.checkBufferTimeout_===null}resetEverything(e){this.ended_=!1,this.activeInitSegmentId_=null,this.appendInitSegment_={audio:!0,video:!0},this.resetLoader(),this.remove(0,1/0,e),this.transmuxer_&&(this.transmuxer_.postMessage({action:"clearAllMp4Captions"}),this.transmuxer_.postMessage({action:"reset"}))}resetLoader(){this.fetchAtBuffer_=!1,this.mediaSequenceSync_&&this.mediaSequenceSync_.resetAppendedStatus(),this.resyncLoader()}resyncLoader(){this.transmuxer_&&Ga.reset(this.transmuxer_),this.mediaIndex=null,this.partIndex=null,this.syncPoint_=null,this.isPendingTimestampOffset_=!1;const e=this.currentMediaInfo_&&this.currentMediaInfo_.isFmp4;this.sourceType_==="hls"&&!e&&(this.shouldForceTimestampOffsetAfterResync_=!0),this.callQueue_=[],this.loadQueue_=[],this.metadataQueue_.id3=[],this.metadataQueue_.caption=[],this.abort(),this.transmuxer_&&this.transmuxer_.postMessage({action:"clearParsedMp4Captions"})}remove(e,t,i=()=>{},n=!1){if(t===1/0&&(t=this.duration_()),t<=e){this.logger_("skipping remove because end ${end} is <= start ${start}");return}if(!this.sourceUpdater_||!this.getMediaInfo_()){this.logger_("skipping remove because no source updater or starting media info");return}let r=1;const a=()=>{r--,r===0&&i()};(n||!this.audioDisabled_)&&(r++,this.sourceUpdater_.removeAudio(e,t,a)),(n||this.loaderType_==="main")&&(this.gopBuffer_=yx(this.gopBuffer_,e,t,this.timeMapping_),r++,this.sourceUpdater_.removeVideo(e,t,a));for(const l in this.inbandTextTracks_)un(e,t,this.inbandTextTracks_[l]);un(e,t,this.segmentMetadataTrack_),a()}monitorBuffer_(){this.checkBufferTimeout_&&k.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=k.setTimeout(this.monitorBufferTick_.bind(this),1)}monitorBufferTick_(){this.state==="READY"&&this.fillBuffer_(),this.checkBufferTimeout_&&k.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=k.setTimeout(this.monitorBufferTick_.bind(this),vx)}fillBuffer_(){if(this.sourceUpdater_.updating())return;const e=this.chooseNextRequest_();if(!e)return;const t={segmentInfo:Mi({type:this.loaderType_,segment:e})};this.trigger({type:"segmentselected",metadata:t}),typeof e.timestampOffset=="number"&&(this.isPendingTimestampOffset_=!1,this.timelineChangeController_.pendingTimelineChange({type:this.loaderType_,from:this.currentTimeline_,to:e.timeline})),this.loadSegment_(e)}isEndOfStream_(e=this.mediaIndex,t=this.playlist_,i=this.partIndex){if(!t||!this.mediaSource_)return!1;const n=typeof e=="number"&&t.segments[e],r=e+1===t.segments.length,a=!n||!n.parts||i+1===n.parts.length;return t.endList&&this.mediaSource_.readyState==="open"&&r&&a}chooseNextRequest_(){const e=this.buffered_(),t=za(e)||0,i=ul(e,this.currentTime_()),n=!this.hasPlayed_()&&i>=1,r=i>=this.goalBufferLength_(),a=this.playlist_.segments;if(!a.length||n||r)return null;this.syncPoint_=this.syncPoint_||this.syncController_.getSyncPoint(this.playlist_,this.duration_(),this.currentTimeline_,this.currentTime_(),this.loaderType_);const l={partIndex:null,mediaIndex:null,startOfSegment:null,playlist:this.playlist_,isSyncRequest:!this.syncPoint_};if(l.isSyncRequest)l.mediaIndex=Tx(this.currentTimeline_,a,t),this.logger_(`choose next request. Can not find sync point. Fallback to media Index: ${l.mediaIndex}`);else if(this.mediaIndex!==null){const E=a[this.mediaIndex],C=typeof this.partIndex=="number"?this.partIndex:-1;l.startOfSegment=E.end?E.end:t,E.parts&&E.parts[C+1]?(l.mediaIndex=this.mediaIndex,l.partIndex=C+1):l.mediaIndex=this.mediaIndex+1}else{let E,C,P;const v=this.fetchAtBuffer_?t:this.currentTime_();if(this.mediaSequenceSync_&&this.logger_(`chooseNextRequest_ request after Quality Switch:
|
|
208
208
|
For TargetTime: ${v}.
|
|
209
209
|
CurrentTime: ${this.currentTime_()}
|
|
210
210
|
BufferedEnd: ${t}
|
|
211
211
|
Fetch At Buffer: ${this.fetchAtBuffer_}
|
|
212
|
-
`,this.mediaSequenceSync_.diagnostics),this.mediaSequenceSync_&&this.mediaSequenceSync_.isReliable){const M=this.getSyncInfoFromMediaSequenceSync_(v);if(!M){const D="No sync info found while using media sequence sync";return this.error({message:D,metadata:{errorType:B.Error.StreamingFailedToSelectNextSegment,error:new Error(D)}}),this.logger_("chooseNextRequest_ - no sync info found using media sequence sync"),null}this.logger_(`chooseNextRequest_ mediaSequence syncInfo (${M.start} --> ${M.end})`),C=M.segmentIndex,w=M.partIndex,A=M.start}else{this.logger_("chooseNextRequest_ - fallback to a regular segment selection algorithm, based on a syncPoint.");const M=gt.getMediaInfoForTime({exactManifestTimings:this.exactManifestTimings,playlist:this.playlist_,currentTime:v,startingPartIndex:this.syncPoint_.partIndex,startingSegmentIndex:this.syncPoint_.segmentIndex,startTime:this.syncPoint_.time});C=M.segmentIndex,w=M.partIndex,A=M.startTime}l.getMediaInfoForTime=this.fetchAtBuffer_?`bufferedEnd ${v}`:`currentTime ${v}`,l.mediaIndex=C,l.startOfSegment=A,l.partIndex=w,this.logger_(`choose next request. Playlist switched and we have a sync point. Media Index: ${l.mediaIndex} `)}const c=a[l.mediaIndex];let f=c&&typeof l.partIndex=="number"&&c.parts&&c.parts[l.partIndex];if(!c||typeof l.partIndex=="number"&&!f)return null;typeof l.partIndex!="number"&&c.parts&&(l.partIndex=0,f=c.parts[0]);const m=this.vhs_.playlists&&this.vhs_.playlists.main&&this.vhs_.playlists.main.independentSegments||this.playlist_.independentSegments;if(!n&&f&&!m&&!f.independent)if(l.partIndex===0){const C=a[l.mediaIndex-1],w=C.parts&&C.parts.length&&C.parts[C.parts.length-1];w&&w.independent&&(l.mediaIndex-=1,l.partIndex=C.parts.length-1,l.independent="previous segment")}else c.parts[l.partIndex-1].independent&&(l.partIndex-=1,l.independent="previous part");const b=this.mediaSource_&&this.mediaSource_.readyState==="ended";return l.mediaIndex>=a.length-1&&b&&!this.seeking_()?null:(this.shouldForceTimestampOffsetAfterResync_&&(this.shouldForceTimestampOffsetAfterResync_=!1,l.forceTimestampOffset=!0,this.logger_("choose next request. Force timestamp offset after loader resync")),this.generateSegmentInfo_(l))}getSyncInfoFromMediaSequenceSync_(e){if(!this.mediaSequenceSync_)return null;const t=Math.max(e,this.mediaSequenceSync_.start);e!==t&&this.logger_(`getSyncInfoFromMediaSequenceSync_. Pulled target time from ${e} to ${t}`);const n=this.mediaSequenceSync_.getSyncInfoForTime(t);if(!n)return null;if(!n.isAppended)return n;const s=this.mediaSequenceSync_.getSyncInfoForTime(n.end);return s?(s.isAppended&&this.logger_("getSyncInfoFromMediaSequenceSync_: We encounter unexpected scenario where next media sequence sync info is also appended!"),s):null}generateSegmentInfo_(e){const{independent:t,playlist:n,mediaIndex:s,startOfSegment:r,isSyncRequest:a,partIndex:l,forceTimestampOffset:c,getMediaInfoForTime:f}=e,m=n.segments[s],b=typeof l=="number"&&m.parts[l],C={requestId:"segment-loader-"+Math.random(),uri:b&&b.resolvedUri||m.resolvedUri,mediaIndex:s,partIndex:b?l:null,isSyncRequest:a,startOfSegment:r,playlist:n,bytes:null,encryptedBytes:null,timestampOffset:null,timeline:m.timeline,duration:b&&b.duration||m.duration,segment:m,part:b,byteLength:0,transmuxer:this.transmuxer_,getMediaInfoForTime:f,independent:t},w=typeof c<"u"?c:this.isPendingTimestampOffset_;C.timestampOffset=this.timestampOffsetForSegment_({segmentTimeline:m.timeline,currentTimeline:this.currentTimeline_,startOfSegment:r,buffered:this.buffered_(),overrideCheck:w});const A=qa(this.sourceUpdater_.audioBuffered());return typeof A=="number"&&(C.audioAppendStart=A-this.sourceUpdater_.audioTimestampOffset()),this.sourceUpdater_.videoBuffered().length&&(C.gopsToAlignWith=Tv(this.gopBuffer_,this.currentTime_()-this.sourceUpdater_.videoTimestampOffset(),this.timeMapping_)),C}timestampOffsetForSegment_(e){return xv(e)}earlyAbortWhenNeeded_(e){if(this.vhs_.tech_.paused()||!this.xhrOptions_.timeout||!this.playlist_.attributes.BANDWIDTH||Date.now()-(e.firstBytesReceivedAt||Date.now())<1e3)return;const t=this.currentTime_(),n=e.bandwidth,s=this.pendingSegment_.duration,r=gt.estimateSegmentRequestTime(s,n,this.playlist_,e.bytesReceived),a=Kb(this.buffered_(),t,this.vhs_.tech_.playbackRate())-1;if(r<=a)return;const l=uv({main:this.vhs_.playlists.main,currentTime:t,bandwidth:n,duration:this.duration_(),segmentDuration:s,timeUntilRebuffer:a,currentTimeline:this.currentTimeline_,syncController:this.syncController_});if(!l)return;const c=r-a-l.rebufferingImpact;let f=.5;a<=Xt&&(f=1),!(!l.playlist||l.playlist.uri===this.playlist_.uri||c<f)&&(this.bandwidth=l.playlist.attributes.BANDWIDTH*We.BANDWIDTH_VARIANCE+1,this.trigger("earlyabort"))}handleAbort_(e){this.logger_(`Aborting ${Zi(e)}`),this.mediaRequestsAborted+=1}handleProgress_(e,t){this.earlyAbortWhenNeeded_(t.stats),!this.checkForAbort_(t.requestId)&&this.trigger("progress")}handleTrackInfo_(e,t){const{hasAudio:n,hasVideo:s}=t,r={segmentInfo:Mi({type:this.loaderType_,segment:e}),trackInfo:{hasAudio:n,hasVideo:s}};this.trigger({type:"segmenttransmuxingtrackinfoavailable",metadata:r}),this.earlyAbortWhenNeeded_(e.stats),!this.checkForAbort_(e.requestId)&&(this.checkForIllegalMediaSwitch(t)||(t=t||{},Ev(this.currentMediaInfo_,t)||(this.appendInitSegment_={audio:!0,video:!0},this.startingMediaInfo_=t,this.currentMediaInfo_=t,this.logger_("trackinfo update",t),this.trigger("trackinfo")),!this.checkForAbort_(e.requestId)&&(this.pendingSegment_.trackInfo=t,this.hasEnoughInfoToAppend_()?this.processCallQueue_():mi(this))))}handleTimingInfo_(e,t,n,s){if(this.earlyAbortWhenNeeded_(e.stats),this.checkForAbort_(e.requestId))return;const r=this.pendingSegment_,a=_d(t);r[a]=r[a]||{},r[a][n]=s,this.logger_(`timinginfo: ${t} - ${n} - ${s}`),this.hasEnoughInfoToAppend_()?this.processCallQueue_():mi(this)}handleCaptions_(e,t){if(this.earlyAbortWhenNeeded_(e.stats),this.checkForAbort_(e.requestId))return;if(t.length===0){this.logger_("SegmentLoader received no captions from a caption event");return}if(!this.pendingSegment_.hasAppendedData_){this.metadataQueue_.caption.push(this.handleCaptions_.bind(this,e,t));return}const n=this.sourceUpdater_.videoTimestampOffset()===null?this.sourceUpdater_.audioTimestampOffset():this.sourceUpdater_.videoTimestampOffset(),s={};t.forEach(r=>{s[r.stream]=s[r.stream]||{startTime:1/0,captions:[],endTime:0};const a=s[r.stream];a.startTime=Math.min(a.startTime,r.startTime+n),a.endTime=Math.max(a.endTime,r.endTime+n),a.captions.push(r)}),Object.keys(s).forEach(r=>{const{startTime:a,endTime:l,captions:c}=s[r],f=this.inbandTextTracks_;this.logger_(`adding cues from ${a} -> ${l} for ${r}`),cv(f,this.vhs_.tech_,r),ss(a,l,f[r]),pv({captionArray:c,inbandTextTracks:f,timestampOffset:n})}),this.transmuxer_&&this.transmuxer_.postMessage({action:"clearParsedMp4Captions"})}handleId3_(e,t,n){if(this.earlyAbortWhenNeeded_(e.stats),!this.checkForAbort_(e.requestId)){if(!this.pendingSegment_.hasAppendedData_){this.metadataQueue_.id3.push(this.handleId3_.bind(this,e,t,n));return}this.addMetadataToTextTrack(n,t,this.duration_())}}processMetadataQueue_(){this.metadataQueue_.id3.forEach(e=>e()),this.metadataQueue_.caption.forEach(e=>e()),this.metadataQueue_.id3=[],this.metadataQueue_.caption=[]}processCallQueue_(){const e=this.callQueue_;this.callQueue_=[],e.forEach(t=>t())}processLoadQueue_(){const e=this.loadQueue_;this.loadQueue_=[],e.forEach(t=>t())}hasEnoughInfoToLoad_(){if(this.loaderType_!=="audio")return!0;const e=this.pendingSegment_;return e?this.getCurrentMediaInfo_()?!fo({timelineChangeController:this.timelineChangeController_,currentTimeline:this.currentTimeline_,segmentTimeline:e.timeline,loaderType:this.loaderType_,audioDisabled:this.audioDisabled_}):!0:!1}getCurrentMediaInfo_(e=this.pendingSegment_){return e&&e.trackInfo||this.currentMediaInfo_}getMediaInfo_(e=this.pendingSegment_){return this.getCurrentMediaInfo_(e)||this.startingMediaInfo_}getPendingSegmentPlaylist(){return this.pendingSegment_?this.pendingSegment_.playlist:null}hasEnoughInfoToAppend_(){if(!this.sourceUpdater_.ready()||this.waitingOnRemove_||this.quotaExceededErrorRetryTimeout_)return!1;const e=this.pendingSegment_,t=this.getCurrentMediaInfo_();if(!e||!t)return!1;const{hasAudio:n,hasVideo:s,isMuxed:r}=t;return!(s&&!e.videoTimingInfo||n&&!this.audioDisabled_&&!r&&!e.audioTimingInfo||fo({timelineChangeController:this.timelineChangeController_,currentTimeline:this.currentTimeline_,segmentTimeline:e.timeline,loaderType:this.loaderType_,audioDisabled:this.audioDisabled_}))}handleData_(e,t){if(this.earlyAbortWhenNeeded_(e.stats),this.checkForAbort_(e.requestId))return;if(this.callQueue_.length||!this.hasEnoughInfoToAppend_()){mi(this),this.callQueue_.push(this.handleData_.bind(this,e,t));return}const n=this.pendingSegment_;if(this.setTimeMapping_(n.timeline),this.updateMediaSecondsLoaded_(n.part||n.segment),this.mediaSource_.readyState!=="closed"){if(e.map&&(e.map=this.initSegmentForMap(e.map,!0),n.segment.map=e.map),e.key&&this.segmentKey(e.key,!0),n.isFmp4=e.isFmp4,n.timingInfo=n.timingInfo||{},n.isFmp4)this.trigger("fmp4"),n.timingInfo.start=n[_d(t.type)].start;else{const s=this.getCurrentMediaInfo_(),r=this.loaderType_==="main"&&s&&s.hasVideo;let a;r&&(a=n.videoTimingInfo.start),n.timingInfo.start=this.trueSegmentStart_({currentStart:n.timingInfo.start,playlist:n.playlist,mediaIndex:n.mediaIndex,currentVideoTimestampOffset:this.sourceUpdater_.videoTimestampOffset(),useVideoTimingInfo:r,firstVideoFrameTimeForData:a,videoTimingInfo:n.videoTimingInfo,audioTimingInfo:n.audioTimingInfo})}if(this.updateAppendInitSegmentStatus(n,t.type),this.updateSourceBufferTimestampOffset_(n),n.isSyncRequest){this.updateTimingInfoEnd_(n),this.syncController_.saveSegmentTimingInfo({segmentInfo:n,shouldSaveTimelineMapping:this.loaderType_==="main"});const s=this.chooseNextRequest_();if(s.mediaIndex!==n.mediaIndex||s.partIndex!==n.partIndex){this.logger_("sync segment was incorrect, not appending");return}this.logger_("sync segment was correct, appending")}n.hasAppendedData_=!0,this.processMetadataQueue_(),this.appendData_(n,t)}}updateAppendInitSegmentStatus(e,t){this.loaderType_==="main"&&typeof e.timestampOffset=="number"&&!e.changedTimestampOffset&&(this.appendInitSegment_={audio:!0,video:!0}),this.playlistOfLastInitSegment_[t]!==e.playlist&&(this.appendInitSegment_[t]=!0)}getInitSegmentAndUpdateState_({type:e,initSegment:t,map:n,playlist:s}){if(n){const r=Cr(n);if(this.activeInitSegmentId_===r)return null;t=this.initSegmentForMap(n,!0).bytes,this.activeInitSegmentId_=r}return t&&this.appendInitSegment_[e]?(this.playlistOfLastInitSegment_[e]=s,this.appendInitSegment_[e]=!1,this.activeInitSegmentId_=null,t):null}handleQuotaExceededError_({segmentInfo:e,type:t,bytes:n},s){const r=this.sourceUpdater_.audioBuffered(),a=this.sourceUpdater_.videoBuffered();r.length>1&&this.logger_("On QUOTA_EXCEEDED_ERR, found gaps in the audio buffer: "+Ui(r).join(", ")),a.length>1&&this.logger_("On QUOTA_EXCEEDED_ERR, found gaps in the video buffer: "+Ui(a).join(", "));const l=r.length?r.start(0):0,c=r.length?r.end(r.length-1):0,f=a.length?a.start(0):0,m=a.length?a.end(a.length-1):0;if(c-l<=Jn&&m-f<=Jn){this.logger_(`On QUOTA_EXCEEDED_ERR, single segment too large to append to buffer, triggering an error. Appended byte length: ${n.byteLength}, audio buffer: ${Ui(r).join(", ")}, video buffer: ${Ui(a).join(", ")}, `),this.error({message:"Quota exceeded error with append of a single segment of content",excludeUntil:1/0}),this.trigger("error");return}this.waitingOnRemove_=!0,this.callQueue_.push(this.appendToSourceBuffer_.bind(this,{segmentInfo:e,type:t,bytes:n}));const b=this.currentTime_()-Jn;this.logger_(`On QUOTA_EXCEEDED_ERR, removing audio/video from 0 to ${b}`),this.remove(0,b,()=>{this.logger_(`On QUOTA_EXCEEDED_ERR, retrying append in ${Jn}s`),this.waitingOnRemove_=!1,this.quotaExceededErrorRetryTimeout_=x.setTimeout(()=>{this.logger_("On QUOTA_EXCEEDED_ERR, re-processing call queue"),this.quotaExceededErrorRetryTimeout_=null,this.processCallQueue_()},Jn*1e3)},!0)}handleAppendError_({segmentInfo:e,type:t,bytes:n},s){if(s){if(s.code===ip){this.handleQuotaExceededError_({segmentInfo:e,type:t,bytes:n});return}this.logger_("Received non QUOTA_EXCEEDED_ERR on append",s),this.error({message:`${t} append of ${n.length}b failed for segment #${e.mediaIndex} in playlist ${e.playlist.id}`,metadata:{errorType:B.Error.StreamingFailedToAppendSegment}}),this.trigger("appenderror")}}appendToSourceBuffer_({segmentInfo:e,type:t,initSegment:n,data:s,bytes:r}){if(!r){const l=[s];let c=s.byteLength;n&&(l.unshift(n),c+=n.byteLength),r=hv({bytes:c,segments:l})}const a={segmentInfo:Mi({type:this.loaderType_,segment:e})};this.trigger({type:"segmentappendstart",metadata:a}),this.sourceUpdater_.appendBuffer({segmentInfo:e,type:t,bytes:r},this.handleAppendError_.bind(this,{segmentInfo:e,type:t,bytes:r}))}handleSegmentTimingInfo_(e,t,n){if(!this.pendingSegment_||t!==this.pendingSegment_.requestId)return;const s=this.pendingSegment_.segment,r=`${e}TimingInfo`;s[r]||(s[r]={}),s[r].transmuxerPrependedSeconds=n.prependedContentDuration||0,s[r].transmuxedPresentationStart=n.start.presentation,s[r].transmuxedDecodeStart=n.start.decode,s[r].transmuxedPresentationEnd=n.end.presentation,s[r].transmuxedDecodeEnd=n.end.decode,s[r].baseMediaDecodeTime=n.baseMediaDecodeTime}appendData_(e,t){const{type:n,data:s}=t;if(!s||!s.byteLength||n==="audio"&&this.audioDisabled_)return;const r=this.getInitSegmentAndUpdateState_({type:n,initSegment:t.initSegment,playlist:e.playlist,map:e.isFmp4?e.segment.map:null});this.appendToSourceBuffer_({segmentInfo:e,type:n,initSegment:r,data:s})}loadSegment_(e){if(this.state="WAITING",this.pendingSegment_=e,this.trimBackBuffer_(e),typeof e.timestampOffset=="number"&&this.transmuxer_&&this.transmuxer_.postMessage({action:"clearAllMp4Captions"}),!this.hasEnoughInfoToLoad_()){mi(this),this.loadQueue_.push(()=>{const t=je({},e,{forceTimestampOffset:!0});je(e,this.generateSegmentInfo_(t)),this.isPendingTimestampOffset_=!1,this.updateTransmuxerAndRequestSegment_(e)});return}this.updateTransmuxerAndRequestSegment_(e)}updateTransmuxerAndRequestSegment_(e){this.shouldUpdateTransmuxerTimestampOffset_(e.timestampOffset)&&(this.gopBuffer_.length=0,e.gopsToAlignWith=[],this.timeMapping_=0,this.transmuxer_.postMessage({action:"reset"}),this.transmuxer_.postMessage({action:"setTimestampOffset",timestampOffset:e.timestampOffset}));const t=this.createSimplifiedSegmentObj_(e),n=this.isEndOfStream_(e.mediaIndex,e.playlist,e.partIndex),s=this.mediaIndex!==null,r=e.timeline!==this.currentTimeline_&&e.timeline>0,a=n||s&&r;this.logger_(`Requesting
|
|
213
|
-
${
|
|
214
|
-
${Zi(e)}`),t.map&&!t.map.bytes&&(this.logger_("going to request init segment."),this.appendInitSegment_={video:!0,audio:!0}),e.abortRequests=nv({xhr:this.vhs_.xhr,xhrOptions:this.xhrOptions_,decryptionWorker:this.decrypter_,segment:t,abortFn:this.handleAbort_.bind(this,e),progressFn:this.handleProgress_.bind(this),trackInfoFn:this.handleTrackInfo_.bind(this),timingInfoFn:this.handleTimingInfo_.bind(this),videoSegmentTimingInfoFn:this.handleSegmentTimingInfo_.bind(this,"video",e.requestId),audioSegmentTimingInfoFn:this.handleSegmentTimingInfo_.bind(this,"audio",e.requestId),captionsFn:this.handleCaptions_.bind(this),isEndOfTimeline:a,endedTimelineFn:()=>{this.logger_("received endedtimeline callback")},id3Fn:this.handleId3_.bind(this),dataFn:this.handleData_.bind(this),doneFn:this.segmentRequestFinished_.bind(this),onTransmuxerLog:({message:l,level:c,stream:f})=>{this.logger_(`${Zi(e)} logged from transmuxer stream ${f} as a ${c}: ${l}`)},triggerSegmentEventFn:({type:l,segment:c,keyInfo:f,trackInfo:m,timingInfo:b})=>{const C={segmentInfo:Mi({segment:c})};f&&(C.keyInfo=f),m&&(C.trackInfo=m),b&&(C.timingInfo=b),this.trigger({type:l,metadata:C})}})}trimBackBuffer_(e){const t=Iv(this.seekable_(),this.currentTime_(),this.playlist_.targetDuration||10);t>0&&this.remove(0,t)}createSimplifiedSegmentObj_(e){const t=e.segment,n=e.part,s=e.segment.key||e.segment.map&&e.segment.map.key,r=e.segment.map&&!e.segment.map.bytes,a={resolvedUri:n?n.resolvedUri:t.resolvedUri,byterange:n?n.byterange:t.byterange,requestId:e.requestId,transmuxer:e.transmuxer,audioAppendStart:e.audioAppendStart,gopsToAlignWith:e.gopsToAlignWith,part:e.part,type:this.loaderType_,start:e.startOfSegment,duration:e.duration,isEncrypted:s,isMediaInitialization:r},l=e.playlist.segments[e.mediaIndex-1];if(l&&l.timeline===t.timeline&&(l.videoTimingInfo?a.baseStartTime=l.videoTimingInfo.transmuxedDecodeEnd:l.audioTimingInfo&&(a.baseStartTime=l.audioTimingInfo.transmuxedDecodeEnd)),t.key){const c=t.key.iv||new Uint32Array([0,0,0,e.mediaIndex+e.playlist.mediaSequence]);a.key=this.segmentKey(t.key),a.key.iv=c}return t.map&&(a.map=this.initSegmentForMap(t.map)),a}saveTransferStats_(e){this.mediaRequests+=1,e&&(this.mediaBytesTransferred+=e.bytesReceived,this.mediaTransferDuration+=e.roundTripTime)}saveBandwidthRelatedStats_(e,t){if(this.pendingSegment_.byteLength=t.bytesReceived,e<ir){this.logger_(`Ignoring segment's bandwidth because its duration of ${e} is less than the min to record ${ir}`);return}const n={bandwidthInfo:{from:this.bandwidth,to:t.bandwidth}};this.trigger({type:"bandwidthupdated",metadata:n}),this.bandwidth=t.bandwidth,this.roundTrip=t.roundTripTime}handleTimeout_(){this.mediaRequestsTimedout+=1,this.bandwidth=1,this.roundTrip=NaN,this.trigger("bandwidthupdate"),this.trigger("timeout")}segmentRequestFinished_(e,t,n){if(this.callQueue_.length){this.callQueue_.push(this.segmentRequestFinished_.bind(this,e,t,n));return}if(this.saveTransferStats_(t.stats),!this.pendingSegment_||t.requestId!==this.pendingSegment_.requestId)return;if(e){if(this.pendingSegment_=null,this.state="READY",e.code===Yt.ABORTED)return;if(this.pause(),e.code===Yt.TIMEOUT){this.handleTimeout_();return}this.mediaRequestsErrored+=1,this.error(e),this.trigger("error");return}const s=this.pendingSegment_;this.saveBandwidthRelatedStats_(s.duration,t.stats),s.endOfAllRequests=t.endOfAllRequests,n.gopInfo&&(this.gopBuffer_=vv(this.gopBuffer_,n.gopInfo,this.safeAppend_)),this.state="APPENDING",this.trigger("appending"),this.waitForAppendsToComplete_(s)}setTimeMapping_(e){const t=this.syncController_.mappingForTimeline(e);t!==null&&(this.timeMapping_=t)}updateMediaSecondsLoaded_(e){typeof e.start=="number"&&typeof e.end=="number"?this.mediaSecondsLoaded+=e.end-e.start:this.mediaSecondsLoaded+=e.duration}shouldUpdateTransmuxerTimestampOffset_(e){return e===null?!1:this.loaderType_==="main"&&e!==this.sourceUpdater_.videoTimestampOffset()||!this.audioDisabled_&&e!==this.sourceUpdater_.audioTimestampOffset()}trueSegmentStart_({currentStart:e,playlist:t,mediaIndex:n,firstVideoFrameTimeForData:s,currentVideoTimestampOffset:r,useVideoTimingInfo:a,videoTimingInfo:l,audioTimingInfo:c}){if(typeof e<"u")return e;if(!a)return c.start;const f=t.segments[n-1];return n===0||!f||typeof f.start>"u"||f.end!==s+r?s:l.start}waitForAppendsToComplete_(e){const t=this.getCurrentMediaInfo_(e);if(!t){this.error({message:"No starting media returned, likely due to an unsupported media format.",playlistExclusionDuration:1/0}),this.trigger("error");return}const{hasAudio:n,hasVideo:s,isMuxed:r}=t,a=this.loaderType_==="main"&&s,l=!this.audioDisabled_&&n&&!r;if(e.waitingOnAppends=0,!e.hasAppendedData_){!e.timingInfo&&typeof e.timestampOffset=="number"&&(this.isPendingTimestampOffset_=!0),e.timingInfo={start:0},e.waitingOnAppends++,this.isPendingTimestampOffset_||(this.updateSourceBufferTimestampOffset_(e),this.processMetadataQueue_()),this.checkAppendsDone_(e);return}a&&e.waitingOnAppends++,l&&e.waitingOnAppends++,a&&this.sourceUpdater_.videoQueueCallback(this.checkAppendsDone_.bind(this,e)),l&&this.sourceUpdater_.audioQueueCallback(this.checkAppendsDone_.bind(this,e))}checkAppendsDone_(e){this.checkForAbort_(e.requestId)||(e.waitingOnAppends--,e.waitingOnAppends===0&&this.handleAppendsDone_())}checkForIllegalMediaSwitch(e){const t=Cv(this.loaderType_,this.getCurrentMediaInfo_(),e);return t?(this.error({message:t,playlistExclusionDuration:1/0}),this.trigger("error"),!0):!1}updateSourceBufferTimestampOffset_(e){if(e.timestampOffset===null||typeof e.timingInfo.start!="number"||e.changedTimestampOffset||this.loaderType_!=="main")return;let t=!1;e.timestampOffset-=this.getSegmentStartTimeForTimestampOffsetCalculation_({videoTimingInfo:e.segment.videoTimingInfo,audioTimingInfo:e.segment.audioTimingInfo,timingInfo:e.timingInfo}),e.changedTimestampOffset=!0,e.timestampOffset!==this.sourceUpdater_.videoTimestampOffset()&&(this.sourceUpdater_.videoTimestampOffset(e.timestampOffset),t=!0),e.timestampOffset!==this.sourceUpdater_.audioTimestampOffset()&&(this.sourceUpdater_.audioTimestampOffset(e.timestampOffset),t=!0),t&&this.trigger("timestampoffset")}getSegmentStartTimeForTimestampOffsetCalculation_({videoTimingInfo:e,audioTimingInfo:t,timingInfo:n}){return this.useDtsForTimestampOffset_?e&&typeof e.transmuxedDecodeStart=="number"?e.transmuxedDecodeStart:t&&typeof t.transmuxedDecodeStart=="number"?t.transmuxedDecodeStart:n.start:n.start}updateTimingInfoEnd_(e){e.timingInfo=e.timingInfo||{};const t=this.getMediaInfo_(),n=this.loaderType_==="main"&&t&&t.hasVideo&&e.videoTimingInfo?e.videoTimingInfo:e.audioTimingInfo;n&&(e.timingInfo.end=typeof n.end=="number"?n.end:n.start+e.duration)}handleAppendsDone_(){if(this.pendingSegment_){const l={segmentInfo:Mi({type:this.loaderType_,segment:this.pendingSegment_})};this.trigger({type:"appendsdone",metadata:l})}if(!this.pendingSegment_){this.state="READY",this.paused()||this.monitorBuffer_();return}const e=this.pendingSegment_;e.part&&e.part.syncInfo?e.part.syncInfo.markAppended():e.segment.syncInfo&&e.segment.syncInfo.markAppended(),this.updateTimingInfoEnd_(e),this.shouldSaveSegmentTimingInfo_&&this.syncController_.saveSegmentTimingInfo({segmentInfo:e,shouldSaveTimelineMapping:this.loaderType_==="main"});const t=Dv(e,this.sourceType_);if(t&&(t.severity==="warn"?B.log.warn(t.message):this.logger_(t.message)),this.recordThroughput_(e),this.pendingSegment_=null,this.state="READY",e.isSyncRequest&&(this.trigger("syncinfoupdate"),!e.hasAppendedData_)){this.logger_(`Throwing away un-appended sync request ${Zi(e)}`);return}this.logger_(`Appended ${Zi(e)}`),this.addSegmentMetadataCue_(e),this.fetchAtBuffer_=!0,this.currentTimeline_!==e.timeline&&(this.timelineChangeController_.lastTimelineChange({type:this.loaderType_,from:this.currentTimeline_,to:e.timeline}),this.loaderType_==="main"&&!this.audioDisabled_&&this.timelineChangeController_.lastTimelineChange({type:"audio",from:this.currentTimeline_,to:e.timeline})),this.currentTimeline_=e.timeline,this.trigger("syncinfoupdate");const n=e.segment,s=e.part,r=n.end&&this.currentTime_()-n.end>e.playlist.targetDuration*3,a=s&&s.end&&this.currentTime_()-s.end>e.playlist.partTargetDuration*3;if(r||a){this.logger_(`bad ${r?"segment":"part"} ${Zi(e)}`),this.resetEverything();return}this.mediaIndex!==null&&this.trigger("bandwidthupdate"),this.trigger("progress"),this.mediaIndex=e.mediaIndex,this.partIndex=e.partIndex,this.isEndOfStream_(e.mediaIndex,e.playlist,e.partIndex)&&this.endOfStream(),this.trigger("appended"),e.hasAppendedData_&&this.mediaAppends++,this.paused()||this.monitorBuffer_()}recordThroughput_(e){if(e.duration<ir){this.logger_(`Ignoring segment's throughput because its duration of ${e.duration} is less than the min to record ${ir}`);return}const t=this.throughput.rate,n=Date.now()-e.endOfAllRequests+1,s=Math.floor(e.byteLength/n*8*1e3);this.throughput.rate+=(s-t)/++this.throughput.count}addSegmentMetadataCue_(e){if(!this.segmentMetadataTrack_)return;const t=e.segment,n=t.start,s=t.end;if(!yd(n)||!yd(s))return;ss(n,s,this.segmentMetadataTrack_);const r=x.WebKitDataCue||x.VTTCue,a={custom:t.custom,dateTimeObject:t.dateTimeObject,dateTimeString:t.dateTimeString,programDateTime:t.programDateTime,bandwidth:e.playlist.attributes.BANDWIDTH,resolution:e.playlist.attributes.RESOLUTION,codecs:e.playlist.attributes.CODECS,byteLength:e.byteLength,uri:e.uri,timeline:e.timeline,playlist:e.playlist.id,start:n,end:s},l=JSON.stringify(a),c=new r(n,s,l);c.value=a,this.segmentMetadataTrack_.addCue(c)}}function ni(){}const Ip=function(i){return typeof i!="string"?i:i.replace(/./,e=>e.toUpperCase())},Ov=["video","audio"],yo=(i,e)=>{const t=e[`${i}Buffer`];return t&&t.updating||e.queuePending[i]},Mv=(i,e)=>{for(let t=0;t<e.length;t++){const n=e[t];if(n.type==="mediaSource")return null;if(n.type===i)return t}return null},hn=(i,e)=>{if(e.queue.length===0)return;let t=0,n=e.queue[t];if(n.type==="mediaSource"){!e.updating()&&e.mediaSource.readyState!=="closed"&&(e.queue.shift(),n.action(e),n.doneFn&&n.doneFn(),hn("audio",e),hn("video",e));return}if(i!=="mediaSource"&&!(!e.ready()||e.mediaSource.readyState==="closed"||yo(i,e))){if(n.type!==i){if(t=Mv(i,e.queue),t===null)return;n=e.queue[t]}if(e.queue.splice(t,1),e.queuePending[i]=n,n.action(i,e),!n.doneFn){e.queuePending[i]=null,hn(i,e);return}}},xp=(i,e)=>{const t=e[`${i}Buffer`],n=Ip(i);t&&(t.removeEventListener("updateend",e[`on${n}UpdateEnd_`]),t.removeEventListener("error",e[`on${n}Error_`]),e.codecs[i]=null,e[`${i}Buffer`]=null)},zt=(i,e)=>i&&e&&Array.prototype.indexOf.call(i.sourceBuffers,e)!==-1,_t={appendBuffer:(i,e,t)=>(n,s)=>{const r=s[`${n}Buffer`];if(zt(s.mediaSource,r)){s.logger_(`Appending segment ${e.mediaIndex}'s ${i.length} bytes to ${n}Buffer`);try{r.appendBuffer(i)}catch(a){s.logger_(`Error with code ${a.code} `+(a.code===ip?"(QUOTA_EXCEEDED_ERR) ":"")+`when appending segment ${e.mediaIndex} to ${n}Buffer`),s.queuePending[n]=null,t(a)}}},remove:(i,e)=>(t,n)=>{const s=n[`${t}Buffer`];if(zt(n.mediaSource,s)){n.logger_(`Removing ${i} to ${e} from ${t}Buffer`);try{s.remove(i,e)}catch{n.logger_(`Remove ${i} to ${e} from ${t}Buffer failed`)}}},timestampOffset:i=>(e,t)=>{const n=t[`${e}Buffer`];zt(t.mediaSource,n)&&(t.logger_(`Setting ${e}timestampOffset to ${i}`),n.timestampOffset=i)},callback:i=>(e,t)=>{i()},endOfStream:i=>e=>{if(e.mediaSource.readyState==="open"){e.logger_(`Calling mediaSource endOfStream(${i||""})`);try{e.mediaSource.endOfStream(i)}catch(t){B.log.warn("Failed to call media source endOfStream",t)}}},duration:i=>e=>{e.logger_(`Setting mediaSource duration to ${i}`);try{e.mediaSource.duration=i}catch(t){B.log.warn("Failed to set media source duration",t)}},abort:()=>(i,e)=>{if(e.mediaSource.readyState!=="open")return;const t=e[`${i}Buffer`];if(zt(e.mediaSource,t)){e.logger_(`calling abort on ${i}Buffer`);try{t.abort()}catch(n){B.log.warn(`Failed to abort on ${i}Buffer`,n)}}},addSourceBuffer:(i,e)=>t=>{const n=Ip(i),s=cn(e);t.logger_(`Adding ${i}Buffer with codec ${e} to mediaSource`);const r=t.mediaSource.addSourceBuffer(s);r.addEventListener("updateend",t[`on${n}UpdateEnd_`]),r.addEventListener("error",t[`on${n}Error_`]),t.codecs[i]=e,t[`${i}Buffer`]=r},removeSourceBuffer:i=>e=>{const t=e[`${i}Buffer`];if(xp(i,e),!!zt(e.mediaSource,t)){e.logger_(`Removing ${i}Buffer with codec ${e.codecs[i]} from mediaSource`);try{e.mediaSource.removeSourceBuffer(t)}catch(n){B.log.warn(`Failed to removeSourceBuffer ${i}Buffer`,n)}}},changeType:i=>(e,t)=>{const n=t[`${e}Buffer`],s=cn(i);if(!zt(t.mediaSource,n))return;const r=i.substring(0,i.indexOf(".")),a=t.codecs[e];if(a.substring(0,a.indexOf("."))===r)return;const l={codecsChangeInfo:{from:a,to:i}};t.trigger({type:"codecschange",metadata:l}),t.logger_(`changing ${e}Buffer codec from ${a} to ${i}`);try{n.changeType(s),t.codecs[e]=i}catch(c){l.errorType=B.Error.StreamingCodecsChangeError,l.error=c,c.metadata=l,t.error_=c,t.trigger("error"),B.log.warn(`Failed to changeType on ${e}Buffer`,c)}}},bt=({type:i,sourceUpdater:e,action:t,doneFn:n,name:s})=>{e.queue.push({type:i,action:t,doneFn:n,name:s}),hn(i,e)},Td=(i,e)=>t=>{const n=e[`${i}Buffered`](),s=Wb(n);if(e.logger_(`received "updateend" event for ${i} Source Buffer: `,s),e.queuePending[i]){const r=e.queuePending[i].doneFn;e.queuePending[i]=null,r&&r(e[`${i}Error_`])}hn(i,e)};class Ap extends B.EventTarget{constructor(e){super(),this.mediaSource=e,this.sourceopenListener_=()=>hn("mediaSource",this),this.mediaSource.addEventListener("sourceopen",this.sourceopenListener_),this.logger_=Lt("SourceUpdater"),this.audioTimestampOffset_=0,this.videoTimestampOffset_=0,this.queue=[],this.queuePending={audio:null,video:null},this.delayedAudioAppendQueue_=[],this.videoAppendQueued_=!1,this.codecs={},this.onVideoUpdateEnd_=Td("video",this),this.onAudioUpdateEnd_=Td("audio",this),this.onVideoError_=t=>{this.videoError_=t},this.onAudioError_=t=>{this.audioError_=t},this.createdSourceBuffers_=!1,this.initializedEme_=!1,this.triggeredReady_=!1}initializedEme(){this.initializedEme_=!0,this.triggerReady()}hasCreatedSourceBuffers(){return this.createdSourceBuffers_}hasInitializedAnyEme(){return this.initializedEme_}ready(){return this.hasCreatedSourceBuffers()&&this.hasInitializedAnyEme()}createSourceBuffers(e){this.hasCreatedSourceBuffers()||(this.addOrChangeSourceBuffers(e),this.createdSourceBuffers_=!0,this.trigger("createdsourcebuffers"),this.triggerReady())}triggerReady(){this.ready()&&!this.triggeredReady_&&(this.triggeredReady_=!0,this.trigger("ready"))}addSourceBuffer(e,t){bt({type:"mediaSource",sourceUpdater:this,action:_t.addSourceBuffer(e,t),name:"addSourceBuffer"})}abort(e){bt({type:e,sourceUpdater:this,action:_t.abort(e),name:"abort"})}removeSourceBuffer(e){if(!this.canRemoveSourceBuffer()){B.log.error("removeSourceBuffer is not supported!");return}bt({type:"mediaSource",sourceUpdater:this,action:_t.removeSourceBuffer(e),name:"removeSourceBuffer"})}canRemoveSourceBuffer(){return!B.browser.IS_FIREFOX&&x.MediaSource&&x.MediaSource.prototype&&typeof x.MediaSource.prototype.removeSourceBuffer=="function"}static canChangeType(){return x.SourceBuffer&&x.SourceBuffer.prototype&&typeof x.SourceBuffer.prototype.changeType=="function"}canChangeType(){return this.constructor.canChangeType()}changeType(e,t){if(!this.canChangeType()){B.log.error("changeType is not supported!");return}bt({type:e,sourceUpdater:this,action:_t.changeType(t),name:"changeType"})}addOrChangeSourceBuffers(e){if(!e||typeof e!="object"||Object.keys(e).length===0)throw new Error("Cannot addOrChangeSourceBuffers to undefined codecs");Object.keys(e).forEach(t=>{const n=e[t];if(!this.hasCreatedSourceBuffers())return this.addSourceBuffer(t,n);this.canChangeType()&&this.changeType(t,n)})}appendBuffer(e,t){const{segmentInfo:n,type:s,bytes:r}=e;if(this.processedAppend_=!0,s==="audio"&&this.videoBuffer&&!this.videoAppendQueued_){this.delayedAudioAppendQueue_.push([e,t]),this.logger_(`delayed audio append of ${r.length} until video append`);return}const a=t;if(bt({type:s,sourceUpdater:this,action:_t.appendBuffer(r,n||{mediaIndex:-1},a),doneFn:t,name:"appendBuffer"}),s==="video"){if(this.videoAppendQueued_=!0,!this.delayedAudioAppendQueue_.length)return;const l=this.delayedAudioAppendQueue_.slice();this.logger_(`queuing delayed audio ${l.length} appendBuffers`),this.delayedAudioAppendQueue_.length=0,l.forEach(c=>{this.appendBuffer.apply(this,c)})}}audioBuffered(){return zt(this.mediaSource,this.audioBuffer)&&this.audioBuffer.buffered?this.audioBuffer.buffered:tt()}videoBuffered(){return zt(this.mediaSource,this.videoBuffer)&&this.videoBuffer.buffered?this.videoBuffer.buffered:tt()}buffered(){const e=zt(this.mediaSource,this.videoBuffer)?this.videoBuffer:null,t=zt(this.mediaSource,this.audioBuffer)?this.audioBuffer:null;return t&&!e?this.audioBuffered():e&&!t?this.videoBuffered():Xb(this.audioBuffered(),this.videoBuffered())}setDuration(e,t=ni){bt({type:"mediaSource",sourceUpdater:this,action:_t.duration(e),name:"duration",doneFn:t})}endOfStream(e=null,t=ni){typeof e!="string"&&(e=void 0),bt({type:"mediaSource",sourceUpdater:this,action:_t.endOfStream(e),name:"endOfStream",doneFn:t})}removeAudio(e,t,n=ni){if(!this.audioBuffered().length||this.audioBuffered().end(0)===0){n();return}bt({type:"audio",sourceUpdater:this,action:_t.remove(e,t),doneFn:n,name:"remove"})}removeVideo(e,t,n=ni){if(!this.videoBuffered().length||this.videoBuffered().end(0)===0){n();return}bt({type:"video",sourceUpdater:this,action:_t.remove(e,t),doneFn:n,name:"remove"})}updating(){return!!(yo("audio",this)||yo("video",this))}audioTimestampOffset(e){return typeof e<"u"&&this.audioBuffer&&this.audioTimestampOffset_!==e&&(bt({type:"audio",sourceUpdater:this,action:_t.timestampOffset(e),name:"timestampOffset"}),this.audioTimestampOffset_=e),this.audioTimestampOffset_}videoTimestampOffset(e){return typeof e<"u"&&this.videoBuffer&&this.videoTimestampOffset_!==e&&(bt({type:"video",sourceUpdater:this,action:_t.timestampOffset(e),name:"timestampOffset"}),this.videoTimestampOffset_=e),this.videoTimestampOffset_}audioQueueCallback(e){this.audioBuffer&&bt({type:"audio",sourceUpdater:this,action:_t.callback(e),name:"callback"})}videoQueueCallback(e){this.videoBuffer&&bt({type:"video",sourceUpdater:this,action:_t.callback(e),name:"callback"})}dispose(){this.trigger("dispose"),Ov.forEach(e=>{this.abort(e),this.canRemoveSourceBuffer()?this.removeSourceBuffer(e):this[`${e}QueueCallback`](()=>xp(e,this))}),this.videoAppendQueued_=!1,this.delayedAudioAppendQueue_.length=0,this.sourceopenListener_&&this.mediaSource.removeEventListener("sourceopen",this.sourceopenListener_),this.off()}}const vd=i=>decodeURIComponent(escape(String.fromCharCode.apply(null,i))),Rv=i=>{const e=new Uint8Array(i);return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")},Sd=new Uint8Array(`
|
|
212
|
+
`,this.mediaSequenceSync_.diagnostics),this.mediaSequenceSync_&&this.mediaSequenceSync_.isReliable){const R=this.getSyncInfoFromMediaSequenceSync_(v);if(!R){const L="No sync info found while using media sequence sync";return this.error({message:L,metadata:{errorType:B.Error.StreamingFailedToSelectNextSegment,error:new Error(L)}}),this.logger_("chooseNextRequest_ - no sync info found using media sequence sync"),null}this.logger_(`chooseNextRequest_ mediaSequence syncInfo (${R.start} --> ${R.end})`),E=R.segmentIndex,C=R.partIndex,P=R.start}else{this.logger_("chooseNextRequest_ - fallback to a regular segment selection algorithm, based on a syncPoint.");const R=ht.getMediaInfoForTime({exactManifestTimings:this.exactManifestTimings,playlist:this.playlist_,currentTime:v,startingPartIndex:this.syncPoint_.partIndex,startingSegmentIndex:this.syncPoint_.segmentIndex,startTime:this.syncPoint_.time});E=R.segmentIndex,C=R.partIndex,P=R.startTime}l.getMediaInfoForTime=this.fetchAtBuffer_?`bufferedEnd ${v}`:`currentTime ${v}`,l.mediaIndex=E,l.startOfSegment=P,l.partIndex=C,this.logger_(`choose next request. Playlist switched and we have a sync point. Media Index: ${l.mediaIndex} `)}const h=a[l.mediaIndex];let f=h&&typeof l.partIndex=="number"&&h.parts&&h.parts[l.partIndex];if(!h||typeof l.partIndex=="number"&&!f)return null;typeof l.partIndex!="number"&&h.parts&&(l.partIndex=0,f=h.parts[0]);const m=this.vhs_.playlists&&this.vhs_.playlists.main&&this.vhs_.playlists.main.independentSegments||this.playlist_.independentSegments;if(!i&&f&&!m&&!f.independent)if(l.partIndex===0){const E=a[l.mediaIndex-1],C=E.parts&&E.parts.length&&E.parts[E.parts.length-1];C&&C.independent&&(l.mediaIndex-=1,l.partIndex=E.parts.length-1,l.independent="previous segment")}else h.parts[l.partIndex-1].independent&&(l.partIndex-=1,l.independent="previous part");const T=this.mediaSource_&&this.mediaSource_.readyState==="ended";return l.mediaIndex>=a.length-1&&T&&!this.seeking_()?null:(this.shouldForceTimestampOffsetAfterResync_&&(this.shouldForceTimestampOffsetAfterResync_=!1,l.forceTimestampOffset=!0,this.logger_("choose next request. Force timestamp offset after loader resync")),this.generateSegmentInfo_(l))}getSyncInfoFromMediaSequenceSync_(e){if(!this.mediaSequenceSync_)return null;const t=Math.max(e,this.mediaSequenceSync_.start);e!==t&&this.logger_(`getSyncInfoFromMediaSequenceSync_. Pulled target time from ${e} to ${t}`);const i=this.mediaSequenceSync_.getSyncInfoForTime(t);if(!i)return null;if(!i.isAppended)return i;const n=this.mediaSequenceSync_.getSyncInfoForTime(i.end);return n?(n.isAppended&&this.logger_("getSyncInfoFromMediaSequenceSync_: We encounter unexpected scenario where next media sequence sync info is also appended!"),n):null}generateSegmentInfo_(e){const{independent:t,playlist:i,mediaIndex:n,startOfSegment:r,isSyncRequest:a,partIndex:l,forceTimestampOffset:h,getMediaInfoForTime:f}=e,m=i.segments[n],T=typeof l=="number"&&m.parts[l],E={requestId:"segment-loader-"+Math.random(),uri:T&&T.resolvedUri||m.resolvedUri,mediaIndex:n,partIndex:T?l:null,isSyncRequest:a,startOfSegment:r,playlist:i,bytes:null,encryptedBytes:null,timestampOffset:null,timeline:m.timeline,duration:T&&T.duration||m.duration,segment:m,part:T,byteLength:0,transmuxer:this.transmuxer_,getMediaInfoForTime:f,independent:t},C=typeof h<"u"?h:this.isPendingTimestampOffset_;E.timestampOffset=this.timestampOffsetForSegment_({segmentTimeline:m.timeline,currentTimeline:this.currentTimeline_,startOfSegment:r,buffered:this.buffered_(),overrideCheck:C});const P=za(this.sourceUpdater_.audioBuffered());return typeof P=="number"&&(E.audioAppendStart=P-this.sourceUpdater_.audioTimestampOffset()),this.sourceUpdater_.videoBuffered().length&&(E.gopsToAlignWith=mx(this.gopBuffer_,this.currentTime_()-this.sourceUpdater_.videoTimestampOffset(),this.timeMapping_)),E}timestampOffsetForSegment_(e){return Sx(e)}earlyAbortWhenNeeded_(e){if(this.vhs_.tech_.paused()||!this.xhrOptions_.timeout||!this.playlist_.attributes.BANDWIDTH||Date.now()-(e.firstBytesReceivedAt||Date.now())<1e3)return;const t=this.currentTime_(),i=e.bandwidth,n=this.pendingSegment_.duration,r=ht.estimateSegmentRequestTime(n,i,this.playlist_,e.bytesReceived),a=qv(this.buffered_(),t,this.vhs_.tech_.playbackRate())-1;if(r<=a)return;const l=nx({main:this.vhs_.playlists.main,currentTime:t,bandwidth:i,duration:this.duration_(),segmentDuration:n,timeUntilRebuffer:a,currentTimeline:this.currentTimeline_,syncController:this.syncController_});if(!l)return;const f=r-a-l.rebufferingImpact;let m=.5;a<=Xt&&(m=1),!(!l.playlist||l.playlist.uri===this.playlist_.uri||f<m)&&(this.bandwidth=l.playlist.attributes.BANDWIDTH*We.BANDWIDTH_VARIANCE+1,this.trigger("earlyabort"))}handleAbort_(e){this.logger_(`Aborting ${es(e)}`),this.mediaRequestsAborted+=1}handleProgress_(e,t){this.earlyAbortWhenNeeded_(t.stats),!this.checkForAbort_(t.requestId)&&this.trigger("progress")}handleTrackInfo_(e,t){const{hasAudio:i,hasVideo:n}=t,r={segmentInfo:Mi({type:this.loaderType_,segment:e}),trackInfo:{hasAudio:i,hasVideo:n}};this.trigger({type:"segmenttransmuxingtrackinfoavailable",metadata:r}),this.earlyAbortWhenNeeded_(e.stats),!this.checkForAbort_(e.requestId)&&(this.checkForIllegalMediaSwitch(t)||(t=t||{},_x(this.currentMediaInfo_,t)||(this.appendInitSegment_={audio:!0,video:!0},this.startingMediaInfo_=t,this.currentMediaInfo_=t,this.logger_("trackinfo update",t),this.trigger("trackinfo")),!this.checkForAbort_(e.requestId)&&(this.pendingSegment_.trackInfo=t,this.hasEnoughInfoToAppend_()?this.processCallQueue_():Ti(this))))}handleTimingInfo_(e,t,i,n){if(this.earlyAbortWhenNeeded_(e.stats),this.checkForAbort_(e.requestId))return;const r=this.pendingSegment_,a=_c(t);r[a]=r[a]||{},r[a][i]=n,this.logger_(`timinginfo: ${t} - ${i} - ${n}`),this.hasEnoughInfoToAppend_()?this.processCallQueue_():Ti(this)}handleCaptions_(e,t){if(this.earlyAbortWhenNeeded_(e.stats),this.checkForAbort_(e.requestId))return;if(t.length===0){this.logger_("SegmentLoader received no captions from a caption event");return}if(!this.pendingSegment_.hasAppendedData_){this.metadataQueue_.caption.push(this.handleCaptions_.bind(this,e,t));return}const n=this.sourceUpdater_.videoTimestampOffset()===null?this.sourceUpdater_.audioTimestampOffset():this.sourceUpdater_.videoTimestampOffset(),r={};t.forEach(a=>{r[a.stream]=r[a.stream]||{startTime:1/0,captions:[],endTime:0};const l=r[a.stream];l.startTime=Math.min(l.startTime,a.startTime+n),l.endTime=Math.max(l.endTime,a.endTime+n),l.captions.push(a)}),Object.keys(r).forEach(a=>{const{startTime:l,endTime:h,captions:f}=r[a],m=this.inbandTextTracks_;this.logger_(`adding cues from ${l} -> ${h} for ${a}`),ox(m,this.vhs_.tech_,a),un(l,h,m[a]),lx({captionArray:f,inbandTextTracks:m,timestampOffset:n})}),this.transmuxer_&&this.transmuxer_.postMessage({action:"clearParsedMp4Captions"})}handleId3_(e,t,i){if(this.earlyAbortWhenNeeded_(e.stats),this.checkForAbort_(e.requestId))return;if(!this.pendingSegment_.hasAppendedData_){this.metadataQueue_.id3.push(this.handleId3_.bind(this,e,t,i));return}this.addMetadataToTextTrack(i,t,this.duration_())}processMetadataQueue_(){this.metadataQueue_.id3.forEach(e=>e()),this.metadataQueue_.caption.forEach(e=>e()),this.metadataQueue_.id3=[],this.metadataQueue_.caption=[]}processCallQueue_(){const e=this.callQueue_;this.callQueue_=[],e.forEach(t=>t())}processLoadQueue_(){const e=this.loadQueue_;this.loadQueue_=[],e.forEach(t=>t())}hasEnoughInfoToLoad_(){if(this.loaderType_!=="audio")return!0;const e=this.pendingSegment_;return e?this.getCurrentMediaInfo_()?!_o({timelineChangeController:this.timelineChangeController_,currentTimeline:this.currentTimeline_,segmentTimeline:e.timeline,loaderType:this.loaderType_,audioDisabled:this.audioDisabled_}):!0:!1}getCurrentMediaInfo_(e=this.pendingSegment_){return e&&e.trackInfo||this.currentMediaInfo_}getMediaInfo_(e=this.pendingSegment_){return this.getCurrentMediaInfo_(e)||this.startingMediaInfo_}getPendingSegmentPlaylist(){return this.pendingSegment_?this.pendingSegment_.playlist:null}hasEnoughInfoToAppend_(){if(!this.sourceUpdater_.ready()||this.waitingOnRemove_||this.quotaExceededErrorRetryTimeout_)return!1;const e=this.pendingSegment_,t=this.getCurrentMediaInfo_();if(!e||!t)return!1;const{hasAudio:i,hasVideo:n,isMuxed:r}=t;return!(n&&!e.videoTimingInfo||i&&!this.audioDisabled_&&!r&&!e.audioTimingInfo||_o({timelineChangeController:this.timelineChangeController_,currentTimeline:this.currentTimeline_,segmentTimeline:e.timeline,loaderType:this.loaderType_,audioDisabled:this.audioDisabled_}))}handleData_(e,t){if(this.earlyAbortWhenNeeded_(e.stats),this.checkForAbort_(e.requestId))return;if(this.callQueue_.length||!this.hasEnoughInfoToAppend_()){Ti(this),this.callQueue_.push(this.handleData_.bind(this,e,t));return}const i=this.pendingSegment_;if(this.setTimeMapping_(i.timeline),this.updateMediaSecondsLoaded_(i.part||i.segment),this.mediaSource_.readyState!=="closed"){if(e.map&&(e.map=this.initSegmentForMap(e.map,!0),i.segment.map=e.map),e.key&&this.segmentKey(e.key,!0),i.isFmp4=e.isFmp4,i.timingInfo=i.timingInfo||{},i.isFmp4)this.trigger("fmp4"),i.timingInfo.start=i[_c(t.type)].start;else{const n=this.getCurrentMediaInfo_(),r=this.loaderType_==="main"&&n&&n.hasVideo;let a;r&&(a=i.videoTimingInfo.start),i.timingInfo.start=this.trueSegmentStart_({currentStart:i.timingInfo.start,playlist:i.playlist,mediaIndex:i.mediaIndex,currentVideoTimestampOffset:this.sourceUpdater_.videoTimestampOffset(),useVideoTimingInfo:r,firstVideoFrameTimeForData:a,videoTimingInfo:i.videoTimingInfo,audioTimingInfo:i.audioTimingInfo})}if(this.updateAppendInitSegmentStatus(i,t.type),this.updateSourceBufferTimestampOffset_(i),i.isSyncRequest){this.updateTimingInfoEnd_(i),this.syncController_.saveSegmentTimingInfo({segmentInfo:i,shouldSaveTimelineMapping:this.loaderType_==="main"});const n=this.chooseNextRequest_();if(n.mediaIndex!==i.mediaIndex||n.partIndex!==i.partIndex){this.logger_("sync segment was incorrect, not appending");return}this.logger_("sync segment was correct, appending")}i.hasAppendedData_=!0,this.processMetadataQueue_(),this.appendData_(i,t)}}updateAppendInitSegmentStatus(e,t){this.loaderType_==="main"&&typeof e.timestampOffset=="number"&&!e.changedTimestampOffset&&(this.appendInitSegment_={audio:!0,video:!0}),this.playlistOfLastInitSegment_[t]!==e.playlist&&(this.appendInitSegment_[t]=!0)}getInitSegmentAndUpdateState_({type:e,initSegment:t,map:i,playlist:n}){if(i){const r=Ar(i);if(this.activeInitSegmentId_===r)return null;t=this.initSegmentForMap(i,!0).bytes,this.activeInitSegmentId_=r}return t&&this.appendInitSegment_[e]?(this.playlistOfLastInitSegment_[e]=n,this.appendInitSegment_[e]=!1,this.activeInitSegmentId_=null,t):null}handleQuotaExceededError_({segmentInfo:e,type:t,bytes:i},n){const r=this.sourceUpdater_.audioBuffered(),a=this.sourceUpdater_.videoBuffered();r.length>1&&this.logger_("On QUOTA_EXCEEDED_ERR, found gaps in the audio buffer: "+Ui(r).join(", ")),a.length>1&&this.logger_("On QUOTA_EXCEEDED_ERR, found gaps in the video buffer: "+Ui(a).join(", "));const l=r.length?r.start(0):0,h=r.length?r.end(r.length-1):0,f=a.length?a.start(0):0,m=a.length?a.end(a.length-1):0;if(h-l<=tn&&m-f<=tn){this.logger_(`On QUOTA_EXCEEDED_ERR, single segment too large to append to buffer, triggering an error. Appended byte length: ${i.byteLength}, audio buffer: ${Ui(r).join(", ")}, video buffer: ${Ui(a).join(", ")}, `),this.error({message:"Quota exceeded error with append of a single segment of content",excludeUntil:1/0}),this.trigger("error");return}this.waitingOnRemove_=!0,this.callQueue_.push(this.appendToSourceBuffer_.bind(this,{segmentInfo:e,type:t,bytes:i}));const E=this.currentTime_()-tn;this.logger_(`On QUOTA_EXCEEDED_ERR, removing audio/video from 0 to ${E}`),this.remove(0,E,()=>{this.logger_(`On QUOTA_EXCEEDED_ERR, retrying append in ${tn}s`),this.waitingOnRemove_=!1,this.quotaExceededErrorRetryTimeout_=k.setTimeout(()=>{this.logger_("On QUOTA_EXCEEDED_ERR, re-processing call queue"),this.quotaExceededErrorRetryTimeout_=null,this.processCallQueue_()},tn*1e3)},!0)}handleAppendError_({segmentInfo:e,type:t,bytes:i},n){if(n){if(n.code===sf){this.handleQuotaExceededError_({segmentInfo:e,type:t,bytes:i});return}this.logger_("Received non QUOTA_EXCEEDED_ERR on append",n),this.error({message:`${t} append of ${i.length}b failed for segment #${e.mediaIndex} in playlist ${e.playlist.id}`,metadata:{errorType:B.Error.StreamingFailedToAppendSegment}}),this.trigger("appenderror")}}appendToSourceBuffer_({segmentInfo:e,type:t,initSegment:i,data:n,bytes:r}){if(!r){const l=[n];let h=n.byteLength;i&&(l.unshift(i),h+=i.byteLength),r=ax({bytes:h,segments:l})}const a={segmentInfo:Mi({type:this.loaderType_,segment:e})};this.trigger({type:"segmentappendstart",metadata:a}),this.sourceUpdater_.appendBuffer({segmentInfo:e,type:t,bytes:r},this.handleAppendError_.bind(this,{segmentInfo:e,type:t,bytes:r}))}handleSegmentTimingInfo_(e,t,i){if(!this.pendingSegment_||t!==this.pendingSegment_.requestId)return;const n=this.pendingSegment_.segment,r=`${e}TimingInfo`;n[r]||(n[r]={}),n[r].transmuxerPrependedSeconds=i.prependedContentDuration||0,n[r].transmuxedPresentationStart=i.start.presentation,n[r].transmuxedDecodeStart=i.start.decode,n[r].transmuxedPresentationEnd=i.end.presentation,n[r].transmuxedDecodeEnd=i.end.decode,n[r].baseMediaDecodeTime=i.baseMediaDecodeTime}appendData_(e,t){const{type:i,data:n}=t;if(!n||!n.byteLength||i==="audio"&&this.audioDisabled_)return;const r=this.getInitSegmentAndUpdateState_({type:i,initSegment:t.initSegment,playlist:e.playlist,map:e.isFmp4?e.segment.map:null});this.appendToSourceBuffer_({segmentInfo:e,type:i,initSegment:r,data:n})}loadSegment_(e){if(this.state="WAITING",this.pendingSegment_=e,this.trimBackBuffer_(e),typeof e.timestampOffset=="number"&&this.transmuxer_&&this.transmuxer_.postMessage({action:"clearAllMp4Captions"}),!this.hasEnoughInfoToLoad_()){Ti(this),this.loadQueue_.push(()=>{const t=je({},e,{forceTimestampOffset:!0});je(e,this.generateSegmentInfo_(t)),this.isPendingTimestampOffset_=!1,this.updateTransmuxerAndRequestSegment_(e)});return}this.updateTransmuxerAndRequestSegment_(e)}updateTransmuxerAndRequestSegment_(e){this.shouldUpdateTransmuxerTimestampOffset_(e.timestampOffset)&&(this.gopBuffer_.length=0,e.gopsToAlignWith=[],this.timeMapping_=0,this.transmuxer_.postMessage({action:"reset"}),this.transmuxer_.postMessage({action:"setTimestampOffset",timestampOffset:e.timestampOffset}));const t=this.createSimplifiedSegmentObj_(e),i=this.isEndOfStream_(e.mediaIndex,e.playlist,e.partIndex),n=this.mediaIndex!==null,r=e.timeline!==this.currentTimeline_&&e.timeline>0,a=i||n&&r;this.logger_(`Requesting
|
|
213
|
+
${If(e.uri)}
|
|
214
|
+
${es(e)}`),t.map&&!t.map.bytes&&(this.logger_("going to request init segment."),this.appendInitSegment_={video:!0,audio:!0}),e.abortRequests=Jb({xhr:this.vhs_.xhr,xhrOptions:this.xhrOptions_,decryptionWorker:this.decrypter_,segment:t,abortFn:this.handleAbort_.bind(this,e),progressFn:this.handleProgress_.bind(this),trackInfoFn:this.handleTrackInfo_.bind(this),timingInfoFn:this.handleTimingInfo_.bind(this),videoSegmentTimingInfoFn:this.handleSegmentTimingInfo_.bind(this,"video",e.requestId),audioSegmentTimingInfoFn:this.handleSegmentTimingInfo_.bind(this,"audio",e.requestId),captionsFn:this.handleCaptions_.bind(this),isEndOfTimeline:a,endedTimelineFn:()=>{this.logger_("received endedtimeline callback")},id3Fn:this.handleId3_.bind(this),dataFn:this.handleData_.bind(this),doneFn:this.segmentRequestFinished_.bind(this),onTransmuxerLog:({message:l,level:h,stream:f})=>{this.logger_(`${es(e)} logged from transmuxer stream ${f} as a ${h}: ${l}`)},triggerSegmentEventFn:({type:l,segment:h,keyInfo:f,trackInfo:m,timingInfo:T})=>{const C={segmentInfo:Mi({segment:h})};f&&(C.keyInfo=f),m&&(C.trackInfo=m),T&&(C.timingInfo=T),this.trigger({type:l,metadata:C})}})}trimBackBuffer_(e){const t=xx(this.seekable_(),this.currentTime_(),this.playlist_.targetDuration||10);t>0&&this.remove(0,t)}createSimplifiedSegmentObj_(e){const t=e.segment,i=e.part,n=e.segment.key||e.segment.map&&e.segment.map.key,r=e.segment.map&&!e.segment.map.bytes,a={resolvedUri:i?i.resolvedUri:t.resolvedUri,byterange:i?i.byterange:t.byterange,requestId:e.requestId,transmuxer:e.transmuxer,audioAppendStart:e.audioAppendStart,gopsToAlignWith:e.gopsToAlignWith,part:e.part,type:this.loaderType_,start:e.startOfSegment,duration:e.duration,isEncrypted:n,isMediaInitialization:r},l=e.playlist.segments[e.mediaIndex-1];if(l&&l.timeline===t.timeline&&(l.videoTimingInfo?a.baseStartTime=l.videoTimingInfo.transmuxedDecodeEnd:l.audioTimingInfo&&(a.baseStartTime=l.audioTimingInfo.transmuxedDecodeEnd)),t.key){const h=t.key.iv||new Uint32Array([0,0,0,e.mediaIndex+e.playlist.mediaSequence]);a.key=this.segmentKey(t.key),a.key.iv=h}return t.map&&(a.map=this.initSegmentForMap(t.map)),a}saveTransferStats_(e){this.mediaRequests+=1,e&&(this.mediaBytesTransferred+=e.bytesReceived,this.mediaTransferDuration+=e.roundTripTime)}saveBandwidthRelatedStats_(e,t){if(this.pendingSegment_.byteLength=t.bytesReceived,e<rr){this.logger_(`Ignoring segment's bandwidth because its duration of ${e} is less than the min to record ${rr}`);return}const i={bandwidthInfo:{from:this.bandwidth,to:t.bandwidth}};this.trigger({type:"bandwidthupdated",metadata:i}),this.bandwidth=t.bandwidth,this.roundTrip=t.roundTripTime}handleTimeout_(){this.mediaRequestsTimedout+=1,this.bandwidth=1,this.roundTrip=NaN,this.trigger("bandwidthupdate"),this.trigger("timeout")}segmentRequestFinished_(e,t,i){if(this.callQueue_.length){this.callQueue_.push(this.segmentRequestFinished_.bind(this,e,t,i));return}if(this.saveTransferStats_(t.stats),!this.pendingSegment_||t.requestId!==this.pendingSegment_.requestId)return;if(e){if(this.pendingSegment_=null,this.state="READY",e.code===Qt.ABORTED)return;if(this.pause(),e.code===Qt.TIMEOUT){this.handleTimeout_();return}this.mediaRequestsErrored+=1,this.error(e),this.trigger("error");return}const n=this.pendingSegment_;this.saveBandwidthRelatedStats_(n.duration,t.stats),n.endOfAllRequests=t.endOfAllRequests,i.gopInfo&&(this.gopBuffer_=gx(this.gopBuffer_,i.gopInfo,this.safeAppend_)),this.state="APPENDING",this.trigger("appending"),this.waitForAppendsToComplete_(n)}setTimeMapping_(e){const t=this.syncController_.mappingForTimeline(e);t!==null&&(this.timeMapping_=t)}updateMediaSecondsLoaded_(e){typeof e.start=="number"&&typeof e.end=="number"?this.mediaSecondsLoaded+=e.end-e.start:this.mediaSecondsLoaded+=e.duration}shouldUpdateTransmuxerTimestampOffset_(e){return e===null?!1:this.loaderType_==="main"&&e!==this.sourceUpdater_.videoTimestampOffset()||!this.audioDisabled_&&e!==this.sourceUpdater_.audioTimestampOffset()}trueSegmentStart_({currentStart:e,playlist:t,mediaIndex:i,firstVideoFrameTimeForData:n,currentVideoTimestampOffset:r,useVideoTimingInfo:a,videoTimingInfo:l,audioTimingInfo:h}){if(typeof e<"u")return e;if(!a)return h.start;const f=t.segments[i-1];return i===0||!f||typeof f.start>"u"||f.end!==n+r?n:l.start}waitForAppendsToComplete_(e){const t=this.getCurrentMediaInfo_(e);if(!t){this.error({message:"No starting media returned, likely due to an unsupported media format.",playlistExclusionDuration:1/0}),this.trigger("error");return}const{hasAudio:i,hasVideo:n,isMuxed:r}=t,a=this.loaderType_==="main"&&n,l=!this.audioDisabled_&&i&&!r;if(e.waitingOnAppends=0,!e.hasAppendedData_){!e.timingInfo&&typeof e.timestampOffset=="number"&&(this.isPendingTimestampOffset_=!0),e.timingInfo={start:0},e.waitingOnAppends++,this.isPendingTimestampOffset_||(this.updateSourceBufferTimestampOffset_(e),this.processMetadataQueue_()),this.checkAppendsDone_(e);return}a&&e.waitingOnAppends++,l&&e.waitingOnAppends++,a&&this.sourceUpdater_.videoQueueCallback(this.checkAppendsDone_.bind(this,e)),l&&this.sourceUpdater_.audioQueueCallback(this.checkAppendsDone_.bind(this,e))}checkAppendsDone_(e){this.checkForAbort_(e.requestId)||(e.waitingOnAppends--,e.waitingOnAppends===0&&this.handleAppendsDone_())}checkForIllegalMediaSwitch(e){const t=bx(this.loaderType_,this.getCurrentMediaInfo_(),e);return t?(this.error({message:t,playlistExclusionDuration:1/0}),this.trigger("error"),!0):!1}updateSourceBufferTimestampOffset_(e){if(e.timestampOffset===null||typeof e.timingInfo.start!="number"||e.changedTimestampOffset||this.loaderType_!=="main")return;let t=!1;e.timestampOffset-=this.getSegmentStartTimeForTimestampOffsetCalculation_({videoTimingInfo:e.segment.videoTimingInfo,audioTimingInfo:e.segment.audioTimingInfo,timingInfo:e.timingInfo}),e.changedTimestampOffset=!0,e.timestampOffset!==this.sourceUpdater_.videoTimestampOffset()&&(this.sourceUpdater_.videoTimestampOffset(e.timestampOffset),t=!0),e.timestampOffset!==this.sourceUpdater_.audioTimestampOffset()&&(this.sourceUpdater_.audioTimestampOffset(e.timestampOffset),t=!0),t&&this.trigger("timestampoffset")}getSegmentStartTimeForTimestampOffsetCalculation_({videoTimingInfo:e,audioTimingInfo:t,timingInfo:i}){return this.useDtsForTimestampOffset_?e&&typeof e.transmuxedDecodeStart=="number"?e.transmuxedDecodeStart:t&&typeof t.transmuxedDecodeStart=="number"?t.transmuxedDecodeStart:i.start:i.start}updateTimingInfoEnd_(e){e.timingInfo=e.timingInfo||{};const t=this.getMediaInfo_(),n=this.loaderType_==="main"&&t&&t.hasVideo&&e.videoTimingInfo?e.videoTimingInfo:e.audioTimingInfo;n&&(e.timingInfo.end=typeof n.end=="number"?n.end:n.start+e.duration)}handleAppendsDone_(){if(this.pendingSegment_){const h={segmentInfo:Mi({type:this.loaderType_,segment:this.pendingSegment_})};this.trigger({type:"appendsdone",metadata:h})}if(!this.pendingSegment_){this.state="READY",this.paused()||this.monitorBuffer_();return}const e=this.pendingSegment_;e.part&&e.part.syncInfo?e.part.syncInfo.markAppended():e.segment.syncInfo&&e.segment.syncInfo.markAppended(),this.updateTimingInfoEnd_(e),this.shouldSaveSegmentTimingInfo_&&this.syncController_.saveSegmentTimingInfo({segmentInfo:e,shouldSaveTimelineMapping:this.loaderType_==="main"});const t=Ix(e,this.sourceType_);if(t&&(t.severity==="warn"?B.log.warn(t.message):this.logger_(t.message)),this.recordThroughput_(e),this.pendingSegment_=null,this.state="READY",e.isSyncRequest&&(this.trigger("syncinfoupdate"),!e.hasAppendedData_)){this.logger_(`Throwing away un-appended sync request ${es(e)}`);return}this.logger_(`Appended ${es(e)}`),this.addSegmentMetadataCue_(e),this.fetchAtBuffer_=!0,this.currentTimeline_!==e.timeline&&(this.timelineChangeController_.lastTimelineChange({type:this.loaderType_,from:this.currentTimeline_,to:e.timeline}),this.loaderType_==="main"&&!this.audioDisabled_&&this.timelineChangeController_.lastTimelineChange({type:"audio",from:this.currentTimeline_,to:e.timeline})),this.currentTimeline_=e.timeline,this.trigger("syncinfoupdate");const i=e.segment,n=e.part,r=i.end&&this.currentTime_()-i.end>e.playlist.targetDuration*3,a=n&&n.end&&this.currentTime_()-n.end>e.playlist.partTargetDuration*3;if(r||a){this.logger_(`bad ${r?"segment":"part"} ${es(e)}`),this.resetEverything();return}this.mediaIndex!==null&&this.trigger("bandwidthupdate"),this.trigger("progress"),this.mediaIndex=e.mediaIndex,this.partIndex=e.partIndex,this.isEndOfStream_(e.mediaIndex,e.playlist,e.partIndex)&&this.endOfStream(),this.trigger("appended"),e.hasAppendedData_&&this.mediaAppends++,this.paused()||this.monitorBuffer_()}recordThroughput_(e){if(e.duration<rr){this.logger_(`Ignoring segment's throughput because its duration of ${e.duration} is less than the min to record ${rr}`);return}const t=this.throughput.rate,i=Date.now()-e.endOfAllRequests+1,n=Math.floor(e.byteLength/i*8*1e3);this.throughput.rate+=(n-t)/++this.throughput.count}addSegmentMetadataCue_(e){if(!this.segmentMetadataTrack_)return;const t=e.segment,i=t.start,n=t.end;if(!yc(i)||!yc(n))return;un(i,n,this.segmentMetadataTrack_);const r=k.WebKitDataCue||k.VTTCue,a={custom:t.custom,dateTimeObject:t.dateTimeObject,dateTimeString:t.dateTimeString,programDateTime:t.programDateTime,bandwidth:e.playlist.attributes.BANDWIDTH,resolution:e.playlist.attributes.RESOLUTION,codecs:e.playlist.attributes.CODECS,byteLength:e.byteLength,uri:e.uri,timeline:e.timeline,playlist:e.playlist.id,start:i,end:n},l=JSON.stringify(a),h=new r(i,n,l);h.value=a,this.segmentMetadataTrack_.addCue(h)}}function ri(){}const Af=function(s){return typeof s!="string"?s:s.replace(/./,e=>e.toUpperCase())},Ax=["video","audio"],vo=(s,e)=>{const t=e[`${s}Buffer`];return t&&t.updating||e.queuePending[s]},kx=(s,e)=>{for(let t=0;t<e.length;t++){const i=e[t];if(i.type==="mediaSource")return null;if(i.type===s)return t}return null},hs=(s,e)=>{if(e.queue.length===0)return;let t=0,i=e.queue[t];if(i.type==="mediaSource"){!e.updating()&&e.mediaSource.readyState!=="closed"&&(e.queue.shift(),i.action(e),i.doneFn&&i.doneFn(),hs("audio",e),hs("video",e));return}if(s!=="mediaSource"&&!(!e.ready()||e.mediaSource.readyState==="closed"||vo(s,e))){if(i.type!==s){if(t=kx(s,e.queue),t===null)return;i=e.queue[t]}if(e.queue.splice(t,1),e.queuePending[s]=i,i.action(s,e),!i.doneFn){e.queuePending[s]=null,hs(s,e);return}}},kf=(s,e)=>{const t=e[`${s}Buffer`],i=Af(s);t&&(t.removeEventListener("updateend",e[`on${i}UpdateEnd_`]),t.removeEventListener("error",e[`on${i}Error_`]),e.codecs[s]=null,e[`${s}Buffer`]=null)},Wt=(s,e)=>s&&e&&Array.prototype.indexOf.call(s.sourceBuffers,e)!==-1,yt={appendBuffer:(s,e,t)=>(i,n)=>{const r=n[`${i}Buffer`];if(Wt(n.mediaSource,r)){n.logger_(`Appending segment ${e.mediaIndex}'s ${s.length} bytes to ${i}Buffer`);try{r.appendBuffer(s)}catch(a){n.logger_(`Error with code ${a.code} `+(a.code===sf?"(QUOTA_EXCEEDED_ERR) ":"")+`when appending segment ${e.mediaIndex} to ${i}Buffer`),n.queuePending[i]=null,t(a)}}},remove:(s,e)=>(t,i)=>{const n=i[`${t}Buffer`];if(Wt(i.mediaSource,n)){i.logger_(`Removing ${s} to ${e} from ${t}Buffer`);try{n.remove(s,e)}catch{i.logger_(`Remove ${s} to ${e} from ${t}Buffer failed`)}}},timestampOffset:s=>(e,t)=>{const i=t[`${e}Buffer`];Wt(t.mediaSource,i)&&(t.logger_(`Setting ${e}timestampOffset to ${s}`),i.timestampOffset=s)},callback:s=>(e,t)=>{s()},endOfStream:s=>e=>{if(e.mediaSource.readyState==="open"){e.logger_(`Calling mediaSource endOfStream(${s||""})`);try{e.mediaSource.endOfStream(s)}catch(t){B.log.warn("Failed to call media source endOfStream",t)}}},duration:s=>e=>{e.logger_(`Setting mediaSource duration to ${s}`);try{e.mediaSource.duration=s}catch(t){B.log.warn("Failed to set media source duration",t)}},abort:()=>(s,e)=>{if(e.mediaSource.readyState!=="open")return;const t=e[`${s}Buffer`];if(Wt(e.mediaSource,t)){e.logger_(`calling abort on ${s}Buffer`);try{t.abort()}catch(i){B.log.warn(`Failed to abort on ${s}Buffer`,i)}}},addSourceBuffer:(s,e)=>t=>{const i=Af(s),n=fs(e);t.logger_(`Adding ${s}Buffer with codec ${e} to mediaSource`);const r=t.mediaSource.addSourceBuffer(n);r.addEventListener("updateend",t[`on${i}UpdateEnd_`]),r.addEventListener("error",t[`on${i}Error_`]),t.codecs[s]=e,t[`${s}Buffer`]=r},removeSourceBuffer:s=>e=>{const t=e[`${s}Buffer`];if(kf(s,e),!!Wt(e.mediaSource,t)){e.logger_(`Removing ${s}Buffer with codec ${e.codecs[s]} from mediaSource`);try{e.mediaSource.removeSourceBuffer(t)}catch(i){B.log.warn(`Failed to removeSourceBuffer ${s}Buffer`,i)}}},changeType:s=>(e,t)=>{const i=t[`${e}Buffer`],n=fs(s);if(!Wt(t.mediaSource,i))return;const r=s.substring(0,s.indexOf(".")),a=t.codecs[e];if(a.substring(0,a.indexOf("."))===r)return;const h={codecsChangeInfo:{from:a,to:s}};t.trigger({type:"codecschange",metadata:h}),t.logger_(`changing ${e}Buffer codec from ${a} to ${s}`);try{i.changeType(n),t.codecs[e]=s}catch(f){h.errorType=B.Error.StreamingCodecsChangeError,h.error=f,f.metadata=h,t.error_=f,t.trigger("error"),B.log.warn(`Failed to changeType on ${e}Buffer`,f)}}},_t=({type:s,sourceUpdater:e,action:t,doneFn:i,name:n})=>{e.queue.push({type:s,action:t,doneFn:i,name:n}),hs(s,e)},vc=(s,e)=>t=>{const i=e[`${s}Buffered`](),n=jv(i);if(e.logger_(`received "updateend" event for ${s} Source Buffer: `,n),e.queuePending[s]){const r=e.queuePending[s].doneFn;e.queuePending[s]=null,r&&r(e[`${s}Error_`])}hs(s,e)};class Pf extends B.EventTarget{constructor(e){super(),this.mediaSource=e,this.sourceopenListener_=()=>hs("mediaSource",this),this.mediaSource.addEventListener("sourceopen",this.sourceopenListener_),this.logger_=Pt("SourceUpdater"),this.audioTimestampOffset_=0,this.videoTimestampOffset_=0,this.queue=[],this.queuePending={audio:null,video:null},this.delayedAudioAppendQueue_=[],this.videoAppendQueued_=!1,this.codecs={},this.onVideoUpdateEnd_=vc("video",this),this.onAudioUpdateEnd_=vc("audio",this),this.onVideoError_=t=>{this.videoError_=t},this.onAudioError_=t=>{this.audioError_=t},this.createdSourceBuffers_=!1,this.initializedEme_=!1,this.triggeredReady_=!1}initializedEme(){this.initializedEme_=!0,this.triggerReady()}hasCreatedSourceBuffers(){return this.createdSourceBuffers_}hasInitializedAnyEme(){return this.initializedEme_}ready(){return this.hasCreatedSourceBuffers()&&this.hasInitializedAnyEme()}createSourceBuffers(e){this.hasCreatedSourceBuffers()||(this.addOrChangeSourceBuffers(e),this.createdSourceBuffers_=!0,this.trigger("createdsourcebuffers"),this.triggerReady())}triggerReady(){this.ready()&&!this.triggeredReady_&&(this.triggeredReady_=!0,this.trigger("ready"))}addSourceBuffer(e,t){_t({type:"mediaSource",sourceUpdater:this,action:yt.addSourceBuffer(e,t),name:"addSourceBuffer"})}abort(e){_t({type:e,sourceUpdater:this,action:yt.abort(e),name:"abort"})}removeSourceBuffer(e){if(!this.canRemoveSourceBuffer()){B.log.error("removeSourceBuffer is not supported!");return}_t({type:"mediaSource",sourceUpdater:this,action:yt.removeSourceBuffer(e),name:"removeSourceBuffer"})}canRemoveSourceBuffer(){return!B.browser.IS_FIREFOX&&k.MediaSource&&k.MediaSource.prototype&&typeof k.MediaSource.prototype.removeSourceBuffer=="function"}static canChangeType(){return k.SourceBuffer&&k.SourceBuffer.prototype&&typeof k.SourceBuffer.prototype.changeType=="function"}canChangeType(){return this.constructor.canChangeType()}changeType(e,t){if(!this.canChangeType()){B.log.error("changeType is not supported!");return}_t({type:e,sourceUpdater:this,action:yt.changeType(t),name:"changeType"})}addOrChangeSourceBuffers(e){if(!e||typeof e!="object"||Object.keys(e).length===0)throw new Error("Cannot addOrChangeSourceBuffers to undefined codecs");Object.keys(e).forEach(t=>{const i=e[t];if(!this.hasCreatedSourceBuffers())return this.addSourceBuffer(t,i);this.canChangeType()&&this.changeType(t,i)})}appendBuffer(e,t){const{segmentInfo:i,type:n,bytes:r}=e;if(this.processedAppend_=!0,n==="audio"&&this.videoBuffer&&!this.videoAppendQueued_){this.delayedAudioAppendQueue_.push([e,t]),this.logger_(`delayed audio append of ${r.length} until video append`);return}const a=t;if(_t({type:n,sourceUpdater:this,action:yt.appendBuffer(r,i||{mediaIndex:-1},a),doneFn:t,name:"appendBuffer"}),n==="video"){if(this.videoAppendQueued_=!0,!this.delayedAudioAppendQueue_.length)return;const l=this.delayedAudioAppendQueue_.slice();this.logger_(`queuing delayed audio ${l.length} appendBuffers`),this.delayedAudioAppendQueue_.length=0,l.forEach(h=>{this.appendBuffer.apply(this,h)})}}audioBuffered(){return Wt(this.mediaSource,this.audioBuffer)&&this.audioBuffer.buffered?this.audioBuffer.buffered:Ke()}videoBuffered(){return Wt(this.mediaSource,this.videoBuffer)&&this.videoBuffer.buffered?this.videoBuffer.buffered:Ke()}buffered(){const e=Wt(this.mediaSource,this.videoBuffer)?this.videoBuffer:null,t=Wt(this.mediaSource,this.audioBuffer)?this.audioBuffer:null;return t&&!e?this.audioBuffered():e&&!t?this.videoBuffered():Hv(this.audioBuffered(),this.videoBuffered())}setDuration(e,t=ri){_t({type:"mediaSource",sourceUpdater:this,action:yt.duration(e),name:"duration",doneFn:t})}endOfStream(e=null,t=ri){typeof e!="string"&&(e=void 0),_t({type:"mediaSource",sourceUpdater:this,action:yt.endOfStream(e),name:"endOfStream",doneFn:t})}removeAudio(e,t,i=ri){if(!this.audioBuffered().length||this.audioBuffered().end(0)===0){i();return}_t({type:"audio",sourceUpdater:this,action:yt.remove(e,t),doneFn:i,name:"remove"})}removeVideo(e,t,i=ri){if(!this.videoBuffered().length||this.videoBuffered().end(0)===0){i();return}_t({type:"video",sourceUpdater:this,action:yt.remove(e,t),doneFn:i,name:"remove"})}updating(){return!!(vo("audio",this)||vo("video",this))}audioTimestampOffset(e){return typeof e<"u"&&this.audioBuffer&&this.audioTimestampOffset_!==e&&(_t({type:"audio",sourceUpdater:this,action:yt.timestampOffset(e),name:"timestampOffset"}),this.audioTimestampOffset_=e),this.audioTimestampOffset_}videoTimestampOffset(e){return typeof e<"u"&&this.videoBuffer&&this.videoTimestampOffset_!==e&&(_t({type:"video",sourceUpdater:this,action:yt.timestampOffset(e),name:"timestampOffset"}),this.videoTimestampOffset_=e),this.videoTimestampOffset_}audioQueueCallback(e){this.audioBuffer&&_t({type:"audio",sourceUpdater:this,action:yt.callback(e),name:"callback"})}videoQueueCallback(e){this.videoBuffer&&_t({type:"video",sourceUpdater:this,action:yt.callback(e),name:"callback"})}dispose(){this.trigger("dispose"),Ax.forEach(e=>{this.abort(e),this.canRemoveSourceBuffer()?this.removeSourceBuffer(e):this[`${e}QueueCallback`](()=>kf(e,this))}),this.videoAppendQueued_=!1,this.delayedAudioAppendQueue_.length=0,this.sourceopenListener_&&this.mediaSource.removeEventListener("sourceopen",this.sourceopenListener_),this.off()}}const bc=s=>decodeURIComponent(escape(String.fromCharCode.apply(null,s))),Px=s=>{const e=new Uint8Array(s);return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")},xc=new Uint8Array(`
|
|
215
215
|
|
|
216
|
-
`.split("").map(
|
|
217
|
-
`,a=
|
|
218
|
-
`,
|
|
219
|
-
`,l++,a=C}),this.end_=a,this.storage_=s,this.diagnostics_=r}calculateBaseTime_(e,t,n){if(!this.storage_.size)return 0;if(this.storage_.has(e))return this.storage_.get(e).segmentSyncInfo.start;const s=Math.min(...this.storage_.keys());if(e<s){const r=s-e;let a=this.storage_.get(s).segmentSyncInfo.start;for(let l=0;l<r;l++){const c=t[l];a-=c.duration}return a}return n}isReliablePlaylist_(e,t){return e!=null&&Array.isArray(t)&&t.length}}class wd extends Pp{constructor(e){super(),this.parent_=e}calculateBaseTime_(e,t,n){if(!this.storage_.size){const s=this.parent_.getSyncInfoForMediaSequence(e);return s?s.segmentSyncInfo.start:0}return super.calculateBaseTime_(e,t,n)}}const $v=86400,za=[{name:"VOD",run:(i,e,t,n,s)=>t!==1/0?{time:0,segmentIndex:0,partIndex:null}:null},{name:"MediaSequence",run:(i,e,t,n,s,r)=>{const a=i.getMediaSequenceSync(r);if(!a||!a.isReliable)return null;const l=a.getSyncInfoForTime(s);return l?{time:l.start,partIndex:l.partIndex,segmentIndex:l.segmentIndex}:null}},{name:"ProgramDateTime",run:(i,e,t,n,s)=>{if(!Object.keys(i.timelineToDatetimeMappings).length)return null;let r=null,a=null;const l=ao(e);s=s||0;for(let c=0;c<l.length;c++){const f=e.endList||s===0?c:l.length-(c+1),m=l[f],b=m.segment,C=i.timelineToDatetimeMappings[b.timeline];if(!C||!b.dateTimeObject)continue;let w=b.dateTimeObject.getTime()/1e3+C;if(b.parts&&typeof m.partIndex=="number")for(let v=0;v<m.partIndex;v++)w+=b.parts[v].duration;const A=Math.abs(s-w);if(a!==null&&(A===0||a<A))break;a=A,r={time:w,segmentIndex:m.segmentIndex,partIndex:m.partIndex}}return r}},{name:"Segment",run:(i,e,t,n,s)=>{let r=null,a=null;s=s||0;const l=ao(e);for(let c=0;c<l.length;c++){const f=e.endList||s===0?c:l.length-(c+1),m=l[f],b=m.segment,C=m.part&&m.part.start||b&&b.start;if(b.timeline===n&&typeof C<"u"){const w=Math.abs(s-C);if(a!==null&&a<w)break;(!r||a===null||a>=w)&&(a=w,r={time:C,segmentIndex:m.segmentIndex,partIndex:m.partIndex})}}return r}},{name:"Discontinuity",run:(i,e,t,n,s)=>{let r=null;if(s=s||0,e.discontinuityStarts&&e.discontinuityStarts.length){let a=null;for(let l=0;l<e.discontinuityStarts.length;l++){const c=e.discontinuityStarts[l],f=e.discontinuitySequence+l+1,m=i.discontinuities[f];if(m){const b=Math.abs(s-m.time);if(a!==null&&a<b)break;(!r||a===null||a>=b)&&(a=b,r={time:m.time,segmentIndex:c,partIndex:null})}}}return r}},{name:"Playlist",run:(i,e,t,n,s)=>e.syncInfo?{time:e.syncInfo.time,segmentIndex:e.syncInfo.mediaSequence-e.mediaSequence,partIndex:null}:null}];class qv extends B.EventTarget{constructor(e={}){super(),this.timelines=[],this.discontinuities=[],this.timelineToDatetimeMappings={};const t=new Pp,n=new wd(t),s=new wd(t);this.mediaSequenceStorage_={main:t,audio:n,vtt:s},this.logger_=Lt("SyncController")}getMediaSequenceSync(e){return this.mediaSequenceStorage_[e]||null}getSyncPoint(e,t,n,s,r){if(t!==1/0)return za.find(({name:l})=>l==="VOD").run(this,e,t);const a=this.runStrategies_(e,t,n,s,r);if(!a.length)return null;for(const l of a){const{syncPoint:c,strategy:f}=l,{segmentIndex:m,time:b}=c;if(m<0)continue;const C=e.segments[m],w=b,A=w+C.duration;if(this.logger_(`Strategy: ${f}. Current time: ${s}. selected segment: ${m}. Time: [${w} -> ${A}]}`),s>=w&&s<A)return this.logger_("Found sync point with exact match: ",c),c}return this.selectSyncPoint_(a,{key:"time",value:s})}getExpiredTime(e,t){if(!e||!e.segments)return null;const n=this.runStrategies_(e,t,e.discontinuitySequence,0);if(!n.length)return null;const s=this.selectSyncPoint_(n,{key:"segmentIndex",value:0});return s.segmentIndex>0&&(s.time*=-1),Math.abs(s.time+ds({defaultDuration:e.targetDuration,durationList:e.segments,startIndex:s.segmentIndex,endIndex:0}))}runStrategies_(e,t,n,s,r){const a=[];for(let l=0;l<za.length;l++){const c=za[l],f=c.run(this,e,t,n,s,r);f&&(f.strategy=c.name,a.push({strategy:c.name,syncPoint:f}))}return a}selectSyncPoint_(e,t){let n=e[0].syncPoint,s=Math.abs(e[0].syncPoint[t.key]-t.value),r=e[0].strategy;for(let a=1;a<e.length;a++){const l=Math.abs(e[a].syncPoint[t.key]-t.value);l<s&&(s=l,n=e[a].syncPoint,r=e[a].strategy)}return this.logger_(`syncPoint for [${t.key}: ${t.value}] chosen with strategy [${r}]: [time:${n.time}, segmentIndex:${n.segmentIndex}`+(typeof n.partIndex=="number"?`,partIndex:${n.partIndex}`:"")+"]"),n}saveExpiredSegmentInfo(e,t){const n=t.mediaSequence-e.mediaSequence;if(n>$v){B.log.warn(`Not saving expired segment info. Media sequence gap ${n} is too large.`);return}for(let s=n-1;s>=0;s--){const r=e.segments[s];if(r&&typeof r.start<"u"){t.syncInfo={mediaSequence:e.mediaSequence+s,time:r.start},this.logger_(`playlist refresh sync: [time:${t.syncInfo.time}, mediaSequence: ${t.syncInfo.mediaSequence}]`),this.trigger("syncinfoupdate");break}}}setDateTimeMappingForStart(e){if(this.timelineToDatetimeMappings={},e.segments&&e.segments.length&&e.segments[0].dateTimeObject){const t=e.segments[0],n=t.dateTimeObject.getTime()/1e3;this.timelineToDatetimeMappings[t.timeline]=-n}}saveSegmentTimingInfo({segmentInfo:e,shouldSaveTimelineMapping:t}){const n=this.calculateSegmentTimeMapping_(e,e.timingInfo,t),s=e.segment;n&&(this.saveDiscontinuitySyncInfo_(e),e.playlist.syncInfo||(e.playlist.syncInfo={mediaSequence:e.playlist.mediaSequence+e.mediaIndex,time:s.start}));const r=s.dateTimeObject;s.discontinuity&&t&&r&&(this.timelineToDatetimeMappings[s.timeline]=-(r.getTime()/1e3))}timestampOffsetForTimeline(e){return typeof this.timelines[e]>"u"?null:this.timelines[e].time}mappingForTimeline(e){return typeof this.timelines[e]>"u"?null:this.timelines[e].mapping}calculateSegmentTimeMapping_(e,t,n){const s=e.segment,r=e.part;let a=this.timelines[e.timeline],l,c;if(typeof e.timestampOffset=="number")a={time:e.startOfSegment,mapping:e.startOfSegment-t.start},n&&(this.timelines[e.timeline]=a,this.trigger("timestampoffset"),this.logger_(`time mapping for timeline ${e.timeline}: [time: ${a.time}] [mapping: ${a.mapping}]`)),l=e.startOfSegment,c=t.end+a.mapping;else if(a)l=t.start+a.mapping,c=t.end+a.mapping;else return!1;return r&&(r.start=l,r.end=c),(!s.start||l<s.start)&&(s.start=l),s.end=c,!0}saveDiscontinuitySyncInfo_(e){const t=e.playlist,n=e.segment;if(n.discontinuity)this.discontinuities[n.timeline]={time:n.start,accuracy:0};else if(t.discontinuityStarts&&t.discontinuityStarts.length)for(let s=0;s<t.discontinuityStarts.length;s++){const r=t.discontinuityStarts[s],a=t.discontinuitySequence+s+1,l=r-e.mediaIndex,c=Math.abs(l);if(!this.discontinuities[a]||this.discontinuities[a].accuracy>c){let f;l<0?f=n.start-ds({defaultDuration:t.targetDuration,durationList:t.segments,startIndex:e.mediaIndex,endIndex:r}):f=n.end+ds({defaultDuration:t.targetDuration,durationList:t.segments,startIndex:e.mediaIndex+1,endIndex:r}),this.discontinuities[a]={time:f,accuracy:c}}}}dispose(){this.trigger("dispose"),this.off()}}class Vv extends B.EventTarget{constructor(){super(),this.pendingTimelineChanges_={},this.lastTimelineChanges_={}}clearPendingTimelineChange(e){this.pendingTimelineChanges_[e]=null,this.trigger("pendingtimelinechange")}pendingTimelineChange({type:e,from:t,to:n}){return typeof t=="number"&&typeof n=="number"&&(this.pendingTimelineChanges_[e]={type:e,from:t,to:n},this.trigger("pendingtimelinechange")),this.pendingTimelineChanges_[e]}lastTimelineChange({type:e,from:t,to:n}){if(typeof t=="number"&&typeof n=="number"){this.lastTimelineChanges_[e]={type:e,from:t,to:n},delete this.pendingTimelineChanges_[e];const s={timelineChangeInfo:{from:t,to:n}};this.trigger({type:"timelinechange",metadata:s})}return this.lastTimelineChanges_[e]}dispose(){this.trigger("dispose"),this.pendingTimelineChanges_={},this.lastTimelineChanges_={},this.off()}}const Hv=gp(fp(function(){var i=function(){function v(){this.listeners={}}var M=v.prototype;return M.on=function(D,R){this.listeners[D]||(this.listeners[D]=[]),this.listeners[D].push(R)},M.off=function(D,R){if(!this.listeners[D])return!1;var N=this.listeners[D].indexOf(R);return this.listeners[D]=this.listeners[D].slice(0),this.listeners[D].splice(N,1),N>-1},M.trigger=function(D){var R=this.listeners[D];if(R)if(arguments.length===2)for(var N=R.length,F=0;F<N;++F)R[F].call(this,arguments[1]);else for(var P=Array.prototype.slice.call(arguments,1),$=R.length,Y=0;Y<$;++Y)R[Y].apply(this,P)},M.dispose=function(){this.listeners={}},M.pipe=function(D){this.on("data",function(R){D.push(R)})},v}();/*! @name pkcs7 @version 1.0.4 @license Apache-2.0 */function e(v){return v.subarray(0,v.byteLength-v[v.byteLength-1])}/*! @name aes-decrypter @version 4.0.2 @license Apache-2.0 */const t=function(){const v=[[[],[],[],[],[]],[[],[],[],[],[]]],M=v[0],D=v[1],R=M[4],N=D[4];let F,P,$;const Y=[],X=[];let re,ce,be,he,Z,de;for(F=0;F<256;F++)X[(Y[F]=F<<1^(F>>7)*283)^F]=F;for(P=$=0;!R[P];P^=re||1,$=X[$]||1)for(he=$^$<<1^$<<2^$<<3^$<<4,he=he>>8^he&255^99,R[P]=he,N[he]=P,be=Y[ce=Y[re=Y[P]]],de=be*16843009^ce*65537^re*257^P*16843008,Z=Y[he]*257^he*16843008,F=0;F<4;F++)M[F][P]=Z=Z<<24^Z>>>8,D[F][he]=de=de<<24^de>>>8;for(F=0;F<5;F++)M[F]=M[F].slice(0),D[F]=D[F].slice(0);return v};let n=null;class s{constructor(M){n||(n=t()),this._tables=[[n[0][0].slice(),n[0][1].slice(),n[0][2].slice(),n[0][3].slice(),n[0][4].slice()],[n[1][0].slice(),n[1][1].slice(),n[1][2].slice(),n[1][3].slice(),n[1][4].slice()]];let D,R,N;const F=this._tables[0][4],P=this._tables[1],$=M.length;let Y=1;if($!==4&&$!==6&&$!==8)throw new Error("Invalid aes key size");const X=M.slice(0),re=[];for(this._key=[X,re],D=$;D<4*$+28;D++)N=X[D-1],(D%$===0||$===8&&D%$===4)&&(N=F[N>>>24]<<24^F[N>>16&255]<<16^F[N>>8&255]<<8^F[N&255],D%$===0&&(N=N<<8^N>>>24^Y<<24,Y=Y<<1^(Y>>7)*283)),X[D]=X[D-$]^N;for(R=0;D;R++,D--)N=X[R&3?D:D-4],D<=4||R<4?re[R]=N:re[R]=P[0][F[N>>>24]]^P[1][F[N>>16&255]]^P[2][F[N>>8&255]]^P[3][F[N&255]]}decrypt(M,D,R,N,F,P){const $=this._key[1];let Y=M^$[0],X=N^$[1],re=R^$[2],ce=D^$[3],be,he,Z;const de=$.length/4-2;let ee,Xe=4;const Ye=this._tables[1],$e=Ye[0],He=Ye[1],me=Ye[2],ge=Ye[3],mt=Ye[4];for(ee=0;ee<de;ee++)be=$e[Y>>>24]^He[X>>16&255]^me[re>>8&255]^ge[ce&255]^$[Xe],he=$e[X>>>24]^He[re>>16&255]^me[ce>>8&255]^ge[Y&255]^$[Xe+1],Z=$e[re>>>24]^He[ce>>16&255]^me[Y>>8&255]^ge[X&255]^$[Xe+2],ce=$e[ce>>>24]^He[Y>>16&255]^me[X>>8&255]^ge[re&255]^$[Xe+3],Xe+=4,Y=be,X=he,re=Z;for(ee=0;ee<4;ee++)F[(3&-ee)+P]=mt[Y>>>24]<<24^mt[X>>16&255]<<16^mt[re>>8&255]<<8^mt[ce&255]^$[Xe++],be=Y,Y=X,X=re,re=ce,ce=be}}class r extends i{constructor(){super(i),this.jobs=[],this.delay=1,this.timeout_=null}processJob_(){this.jobs.shift()(),this.jobs.length?this.timeout_=setTimeout(this.processJob_.bind(this),this.delay):this.timeout_=null}push(M){this.jobs.push(M),this.timeout_||(this.timeout_=setTimeout(this.processJob_.bind(this),this.delay))}}const a=function(v){return v<<24|(v&65280)<<8|(v&16711680)>>8|v>>>24},l=function(v,M,D){const R=new Int32Array(v.buffer,v.byteOffset,v.byteLength>>2),N=new s(Array.prototype.slice.call(M)),F=new Uint8Array(v.byteLength),P=new Int32Array(F.buffer);let $,Y,X,re,ce,be,he,Z,de;for($=D[0],Y=D[1],X=D[2],re=D[3],de=0;de<R.length;de+=4)ce=a(R[de]),be=a(R[de+1]),he=a(R[de+2]),Z=a(R[de+3]),N.decrypt(ce,be,he,Z,P,de),P[de]=a(P[de]^$),P[de+1]=a(P[de+1]^Y),P[de+2]=a(P[de+2]^X),P[de+3]=a(P[de+3]^re),$=ce,Y=be,X=he,re=Z;return F};class c{constructor(M,D,R,N){const F=c.STEP,P=new Int32Array(M.buffer),$=new Uint8Array(M.byteLength);let Y=0;for(this.asyncStream_=new r,this.asyncStream_.push(this.decryptChunk_(P.subarray(Y,Y+F),D,R,$)),Y=F;Y<P.length;Y+=F)R=new Uint32Array([a(P[Y-4]),a(P[Y-3]),a(P[Y-2]),a(P[Y-1])]),this.asyncStream_.push(this.decryptChunk_(P.subarray(Y,Y+F),D,R,$));this.asyncStream_.push(function(){N(null,e($))})}static get STEP(){return 32e3}decryptChunk_(M,D,R,N){return function(){const F=l(M,D,R);N.set(F,M.byteOffset)}}}var f=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof ar<"u"?ar:typeof self<"u"?self:{},m;typeof window<"u"?m=window:typeof f<"u"?m=f:typeof self<"u"?m=self:m={};var b=m,C=function(v){return ArrayBuffer.isView==="function"?ArrayBuffer.isView(v):v&&v.buffer instanceof ArrayBuffer},w=b.BigInt||Number;w("0x1"),w("0x100"),w("0x10000"),w("0x1000000"),w("0x100000000"),w("0x10000000000"),w("0x1000000000000"),w("0x100000000000000"),w("0x10000000000000000"),function(){var v=new Uint16Array([65484]),M=new Uint8Array(v.buffer,v.byteOffset,v.byteLength);return M[0]===255?"big":M[0]===204?"little":"unknown"}();const A=function(v){const M={};return Object.keys(v).forEach(D=>{const R=v[D];C(R)?M[D]={bytes:R.buffer,byteOffset:R.byteOffset,byteLength:R.byteLength}:M[D]=R}),M};self.onmessage=function(v){const M=v.data,D=new Uint8Array(M.encrypted.bytes,M.encrypted.byteOffset,M.encrypted.byteLength),R=new Uint32Array(M.key.bytes,M.key.byteOffset,M.key.byteLength/4),N=new Uint32Array(M.iv.bytes,M.iv.byteOffset,M.iv.byteLength/4);new c(D,R,N,function(F,P){self.postMessage(A({source:M.source,decrypted:P}),[P.buffer])})}}));var zv=pp(Hv);const Wv=i=>{let e=i.default?"main":"alternative";return i.characteristics&&i.characteristics.indexOf("public.accessibility.describes-video")>=0&&(e="main-desc"),e},Lp=(i,e)=>{i.abort(),i.pause(),e&&e.activePlaylistLoader&&(e.activePlaylistLoader.pause(),e.activePlaylistLoader=null)},_o=(i,e)=>{e.activePlaylistLoader=i,i.load()},Gv=(i,e)=>()=>{const{segmentLoaders:{[i]:t,main:n},mediaTypes:{[i]:s}}=e,r=s.activeTrack(),a=s.getActiveGroup(),l=s.activePlaylistLoader,c=s.lastGroup_;if(!(a&&c&&a.id===c.id)&&(s.lastGroup_=a,s.lastTrack_=r,Lp(t,s),!(!a||a.isMainPlaylist))){if(!a.playlistLoader){l&&n.resetEverything();return}t.resyncLoader(),_o(a.playlistLoader,s)}},Xv=(i,e)=>()=>{const{segmentLoaders:{[i]:t},mediaTypes:{[i]:n}}=e;n.lastGroup_=null,t.abort(),t.pause()},Kv=(i,e)=>()=>{const{mainPlaylistLoader:t,segmentLoaders:{[i]:n,main:s},mediaTypes:{[i]:r}}=e,a=r.activeTrack(),l=r.getActiveGroup(),c=r.activePlaylistLoader,f=r.lastTrack_;if(!(f&&a&&f.id===a.id)&&(r.lastGroup_=l,r.lastTrack_=a,Lp(n,r),!!l)){if(l.isMainPlaylist){if(!a||!f||a.id===f.id)return;const m=e.vhs.playlistController_,b=m.selectPlaylist();if(m.media()===b)return;r.logger_(`track change. Switching main audio from ${f.id} to ${a.id}`),t.pause(),s.resetEverything(),m.fastQualityChange_(b);return}if(i==="AUDIO"){if(!l.playlistLoader){s.setAudio(!0),s.resetEverything();return}n.setAudio(!0),s.setAudio(!1)}if(c===l.playlistLoader){_o(l.playlistLoader,r);return}n.track&&n.track(a),n.resetEverything(),_o(l.playlistLoader,r)}},Ar={AUDIO:(i,e)=>()=>{const{mediaTypes:{[i]:t},excludePlaylist:n}=e,s=t.activeTrack(),r=t.activeGroup(),a=(r.filter(c=>c.default)[0]||r[0]).id,l=t.tracks[a];if(s===l){n({error:{message:"Problem encountered loading the default audio track."}});return}B.log.warn("Problem encountered loading the alternate audio track.Switching back to default.");for(const c in t.tracks)t.tracks[c].enabled=t.tracks[c]===l;t.onTrackChanged()},SUBTITLES:(i,e)=>()=>{const{mediaTypes:{[i]:t}}=e;B.log.warn("Problem encountered loading the subtitle track.Disabling subtitle track.");const n=t.activeTrack();n&&(n.mode="disabled"),t.onTrackChanged()}},kd={AUDIO:(i,e,t)=>{if(!e)return;const{tech:n,requestOptions:s,segmentLoaders:{[i]:r}}=t;e.on("loadedmetadata",()=>{const a=e.media();r.playlist(a,s),(!n.paused()||a.endList&&n.preload()!=="none")&&r.load()}),e.on("loadedplaylist",()=>{r.playlist(e.media(),s),n.paused()||r.load()}),e.on("error",Ar[i](i,t))},SUBTITLES:(i,e,t)=>{const{tech:n,requestOptions:s,segmentLoaders:{[i]:r},mediaTypes:{[i]:a}}=t;e.on("loadedmetadata",()=>{const l=e.media();r.playlist(l,s),r.track(a.activeTrack()),(!n.paused()||l.endList&&n.preload()!=="none")&&r.load()}),e.on("loadedplaylist",()=>{r.playlist(e.media(),s),n.paused()||r.load()}),e.on("error",Ar[i](i,t))}},Yv={AUDIO:(i,e)=>{const{vhs:t,sourceType:n,segmentLoaders:{[i]:s},requestOptions:r,main:{mediaGroups:a},mediaTypes:{[i]:{groups:l,tracks:c,logger_:f}},mainPlaylistLoader:m}=e,b=Ss(m.main);(!a[i]||Object.keys(a[i]).length===0)&&(a[i]={main:{default:{default:!0}}},b&&(a[i].main.default.playlists=m.main.playlists));for(const C in a[i]){l[C]||(l[C]=[]);for(const w in a[i][C]){let A=a[i][C][w],v;if(b?(f(`AUDIO group '${C}' label '${w}' is a main playlist`),A.isMainPlaylist=!0,v=null):n==="vhs-json"&&A.playlists?v=new nn(A.playlists[0],t,r):A.resolvedUri?v=new nn(A.resolvedUri,t,r):A.playlists&&n==="dash"?v=new po(A.playlists[0],t,r,m):v=null,A=fe({id:w,playlistLoader:v},A),kd[i](i,A.playlistLoader,e),l[C].push(A),typeof c[w]>"u"){const M=new B.AudioTrack({id:w,kind:Wv(A),enabled:!1,language:A.language,default:A.default,label:w});c[w]=M}}}s.on("error",Ar[i](i,e))},SUBTITLES:(i,e)=>{const{tech:t,vhs:n,sourceType:s,segmentLoaders:{[i]:r},requestOptions:a,main:{mediaGroups:l},mediaTypes:{[i]:{groups:c,tracks:f}},mainPlaylistLoader:m}=e;for(const b in l[i]){c[b]||(c[b]=[]);for(const C in l[i][b]){if(!n.options_.useForcedSubtitles&&l[i][b][C].forced)continue;let w=l[i][b][C],A;if(s==="hls")A=new nn(w.resolvedUri,n,a);else if(s==="dash"){if(!w.playlists.filter(v=>v.excludeUntil!==1/0).length)return;A=new po(w.playlists[0],n,a,m)}else s==="vhs-json"&&(A=new nn(w.playlists?w.playlists[0]:w.resolvedUri,n,a));if(w=fe({id:C,playlistLoader:A},w),kd[i](i,w.playlistLoader,e),c[b].push(w),typeof f[C]>"u"){const v=t.addRemoteTextTrack({id:C,kind:"subtitles",default:w.default&&w.autoselect,language:w.language,label:C},!1).track;f[C]=v}}}r.on("error",Ar[i](i,e))},"CLOSED-CAPTIONS":(i,e)=>{const{tech:t,main:{mediaGroups:n},mediaTypes:{[i]:{groups:s,tracks:r}}}=e;for(const a in n[i]){s[a]||(s[a]=[]);for(const l in n[i][a]){const c=n[i][a][l];if(!/^(?:CC|SERVICE)/.test(c.instreamId))continue;const f=t.options_.vhs&&t.options_.vhs.captionServices||{};let m={label:l,language:c.language,instreamId:c.instreamId,default:c.default&&c.autoselect};if(f[m.instreamId]&&(m=fe(m,f[m.instreamId])),m.default===void 0&&delete m.default,s[a].push(fe({id:l},c)),typeof r[l]>"u"){const b=t.addRemoteTextTrack({id:m.instreamId,kind:"captions",default:m.default,language:m.language,label:m.label},!1).track;r[l]=b}}}}},Dp=(i,e)=>{for(let t=0;t<i.length;t++)if(hl(e,i[t])||i[t].playlists&&Dp(i[t].playlists,e))return!0;return!1},Qv=(i,e)=>t=>{const{mainPlaylistLoader:n,mediaTypes:{[i]:{groups:s}}}=e,r=n.media();if(!r)return null;let a=null;r.attributes[i]&&(a=s[r.attributes[i]]);const l=Object.keys(s);if(!a)if(i==="AUDIO"&&l.length>1&&Ss(e.main))for(let c=0;c<l.length;c++){const f=s[l[c]];if(Dp(f,r)){a=f;break}}else s.main?a=s.main:l.length===1&&(a=s[l[0]]);return typeof t>"u"?a:t===null||!a?null:a.filter(c=>c.id===t.id)[0]||null},Jv={AUDIO:(i,e)=>()=>{const{mediaTypes:{[i]:{tracks:t}}}=e;for(const n in t)if(t[n].enabled)return t[n];return null},SUBTITLES:(i,e)=>()=>{const{mediaTypes:{[i]:{tracks:t}}}=e;for(const n in t)if(t[n].mode==="showing"||t[n].mode==="hidden")return t[n];return null}},Zv=(i,{mediaTypes:e})=>()=>{const t=e[i].activeTrack();return t?e[i].activeGroup(t):null},eS=i=>{["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(f=>{Yv[f](f,i)});const{mediaTypes:e,mainPlaylistLoader:t,tech:n,vhs:s,segmentLoaders:{["AUDIO"]:r,main:a}}=i;["AUDIO","SUBTITLES"].forEach(f=>{e[f].activeGroup=Qv(f,i),e[f].activeTrack=Jv[f](f,i),e[f].onGroupChanged=Gv(f,i),e[f].onGroupChanging=Xv(f,i),e[f].onTrackChanged=Kv(f,i),e[f].getActiveGroup=Zv(f,i)});const l=e.AUDIO.activeGroup();if(l){const f=(l.filter(m=>m.default)[0]||l[0]).id;e.AUDIO.tracks[f].enabled=!0,e.AUDIO.onGroupChanged(),e.AUDIO.onTrackChanged(),e.AUDIO.getActiveGroup().playlistLoader?(a.setAudio(!1),r.setAudio(!0)):a.setAudio(!0)}t.on("mediachange",()=>{["AUDIO","SUBTITLES"].forEach(f=>e[f].onGroupChanged())}),t.on("mediachanging",()=>{["AUDIO","SUBTITLES"].forEach(f=>e[f].onGroupChanging())});const c=()=>{e.AUDIO.onTrackChanged(),n.trigger({type:"usage",name:"vhs-audio-change"})};n.audioTracks().addEventListener("change",c),n.remoteTextTracks().addEventListener("change",e.SUBTITLES.onTrackChanged),s.on("dispose",()=>{n.audioTracks().removeEventListener("change",c),n.remoteTextTracks().removeEventListener("change",e.SUBTITLES.onTrackChanged)}),n.clearTracks("audio");for(const f in e.AUDIO.tracks)n.audioTracks().addTrack(e.AUDIO.tracks[f])},tS=()=>{const i={};return["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(e=>{i[e]={groups:{},tracks:{},activePlaylistLoader:null,activeGroup:ni,activeTrack:ni,getActiveGroup:ni,onGroupChanged:ni,onTrackChanged:ni,lastTrack_:null,logger_:Lt(`MediaGroups[${e}]`)}}),i};class Cd{constructor(){this.priority_=[],this.pathwayClones_=new Map}set version(e){e===1&&(this.version_=e)}set ttl(e){this.ttl_=e||300}set reloadUri(e){e&&(this.reloadUri_=pt(this.reloadUri_,e))}set priority(e){e&&e.length&&(this.priority_=e)}set pathwayClones(e){e&&e.length&&(this.pathwayClones_=new Map(e.map(t=>[t.ID,t])))}get version(){return this.version_}get ttl(){return this.ttl_}get reloadUri(){return this.reloadUri_}get priority(){return this.priority_}get pathwayClones(){return this.pathwayClones_}}class iS extends B.EventTarget{constructor(e,t){super(),this.currentPathway=null,this.defaultPathway=null,this.queryBeforeStart=!1,this.availablePathways_=new Set,this.steeringManifest=new Cd,this.proxyServerUrl_=null,this.manifestType_=null,this.ttlTimeout_=null,this.request_=null,this.currentPathwayClones=new Map,this.nextPathwayClones=new Map,this.excludedSteeringManifestURLs=new Set,this.logger_=Lt("Content Steering"),this.xhr_=e,this.getBandwidth_=t}assignTagProperties(e,t){this.manifestType_=t.serverUri?"HLS":"DASH";const n=t.serverUri||t.serverURL;if(!n){this.logger_(`steering manifest URL is ${n}, cannot request steering manifest.`),this.trigger("error");return}if(n.startsWith("data:")){this.decodeDataUriManifest_(n.substring(n.indexOf(",")+1));return}this.steeringManifest.reloadUri=pt(e,n),this.defaultPathway=t.pathwayId||t.defaultServiceLocation,this.queryBeforeStart=t.queryBeforeStart,this.proxyServerUrl_=t.proxyServerURL,this.defaultPathway&&!this.queryBeforeStart&&this.trigger("content-steering")}requestSteeringManifest(e){const t=this.steeringManifest.reloadUri;if(!t)return;const n=e?t:this.getRequestURI(t);if(!n){this.logger_("No valid content steering manifest URIs. Stopping content steering."),this.trigger("error"),this.dispose();return}const s={contentSteeringInfo:{uri:n}};this.trigger({type:"contentsteeringloadstart",metadata:s}),this.request_=this.xhr_({uri:n,requestType:"content-steering-manifest"},(r,a)=>{if(r){if(a.status===410){this.logger_(`manifest request 410 ${r}.`),this.logger_(`There will be no more content steering requests to ${n} this session.`),this.excludedSteeringManifestURLs.add(n);return}if(a.status===429){const f=a.responseHeaders["retry-after"];this.logger_(`manifest request 429 ${r}.`),this.logger_(`content steering will retry in ${f} seconds.`),this.startTTLTimeout_(parseInt(f,10));return}this.logger_(`manifest failed to load ${r}.`),this.startTTLTimeout_();return}this.trigger({type:"contentsteeringloadcomplete",metadata:s});let l;try{l=JSON.parse(this.request_.responseText)}catch(f){const m={errorType:B.Error.StreamingContentSteeringParserError,error:f};this.trigger({type:"error",metadata:m})}this.assignSteeringProperties_(l);const c={contentSteeringInfo:s.contentSteeringInfo,contentSteeringManifest:{version:this.steeringManifest.version,reloadUri:this.steeringManifest.reloadUri,priority:this.steeringManifest.priority}};this.trigger({type:"contentsteeringparsed",metadata:c}),this.startTTLTimeout_()})}setProxyServerUrl_(e){const t=new x.URL(e),n=new x.URL(this.proxyServerUrl_);return n.searchParams.set("url",encodeURI(t.toString())),this.setSteeringParams_(n.toString())}decodeDataUriManifest_(e){const t=JSON.parse(x.atob(e));this.assignSteeringProperties_(t)}setSteeringParams_(e){const t=new x.URL(e),n=this.getPathway(),s=this.getBandwidth_();if(n){const r=`_${this.manifestType_}_pathway`;t.searchParams.set(r,n)}if(s){const r=`_${this.manifestType_}_throughput`;t.searchParams.set(r,s)}return t.toString()}assignSteeringProperties_(e){if(this.steeringManifest.version=e.VERSION,!this.steeringManifest.version){this.logger_(`manifest version is ${e.VERSION}, which is not supported.`),this.trigger("error");return}this.steeringManifest.ttl=e.TTL,this.steeringManifest.reloadUri=e["RELOAD-URI"],this.steeringManifest.priority=e["PATHWAY-PRIORITY"]||e["SERVICE-LOCATION-PRIORITY"],this.steeringManifest.pathwayClones=e["PATHWAY-CLONES"],this.nextPathwayClones=this.steeringManifest.pathwayClones,this.availablePathways_.size||(this.logger_("There are no available pathways for content steering. Ending content steering."),this.trigger("error"),this.dispose());const t=(n=>{for(const s of n)if(this.availablePathways_.has(s))return s;return[...this.availablePathways_][0]})(this.steeringManifest.priority);this.currentPathway!==t&&(this.currentPathway=t,this.trigger("content-steering"))}getPathway(){return this.currentPathway||this.defaultPathway}getRequestURI(e){if(!e)return null;const t=s=>this.excludedSteeringManifestURLs.has(s);if(this.proxyServerUrl_){const s=this.setProxyServerUrl_(e);if(!t(s))return s}const n=this.setSteeringParams_(e);return t(n)?null:n}startTTLTimeout_(e=this.steeringManifest.ttl){const t=e*1e3;this.ttlTimeout_=x.setTimeout(()=>{this.requestSteeringManifest()},t)}clearTTLTimeout_(){x.clearTimeout(this.ttlTimeout_),this.ttlTimeout_=null}abort(){this.request_&&this.request_.abort(),this.request_=null}dispose(){this.off("content-steering"),this.off("error"),this.abort(),this.clearTTLTimeout_(),this.currentPathway=null,this.defaultPathway=null,this.queryBeforeStart=null,this.proxyServerUrl_=null,this.manifestType_=null,this.ttlTimeout_=null,this.request_=null,this.excludedSteeringManifestURLs=new Set,this.availablePathways_=new Set,this.steeringManifest=new Cd}addAvailablePathway(e){e&&this.availablePathways_.add(e)}clearAvailablePathways(){this.availablePathways_.clear()}excludePathway(e){return this.availablePathways_.delete(e)}didDASHTagChange(e,t){return!t&&this.steeringManifest.reloadUri||t&&(pt(e,t.serverURL)!==this.steeringManifest.reloadUri||t.defaultServiceLocation!==this.defaultPathway||t.queryBeforeStart!==this.queryBeforeStart||t.proxyServerURL!==this.proxyServerUrl_)}getAvailablePathways(){return this.availablePathways_}}const nS=(i,e)=>{let t=null;return(...n)=>{clearTimeout(t),t=setTimeout(()=>{i.apply(null,n)},e)}},sS=10;let yi;const rS=["mediaRequests","mediaRequestsAborted","mediaRequestsTimedout","mediaRequestsErrored","mediaTransferDuration","mediaBytesTransferred","mediaAppends"],aS=function(i){return this.audioSegmentLoader_[i]+this.mainSegmentLoader_[i]},oS=function({currentPlaylist:i,buffered:e,currentTime:t,nextPlaylist:n,bufferLowWaterLine:s,bufferHighWaterLine:r,duration:a,bufferBasedABR:l,log:c}){if(!n)return B.log.warn("We received no playlist to switch to. Please check your stream."),!1;const f=`allowing switch ${i&&i.id||"null"} -> ${n.id}`;if(!i)return c(`${f} as current playlist is not set`),!0;if(n.id===i.id)return!1;const m=!!tn(e,t).length;if(!i.endList)return!m&&typeof i.partTargetDuration=="number"?(c(`not ${f} as current playlist is live llhls, but currentTime isn't in buffered.`),!1):(c(`${f} as current playlist is live`),!0);const b=ll(e,t),C=l?We.EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE:We.MAX_BUFFER_LOW_WATER_LINE;if(a<C)return c(`${f} as duration < max low water line (${a} < ${C})`),!0;const w=n.attributes.BANDWIDTH,A=i.attributes.BANDWIDTH;if(w<A&&(!l||b<r)){let v=`${f} as next bandwidth < current bandwidth (${w} < ${A})`;return l&&(v+=` and forwardBuffer < bufferHighWaterLine (${b} < ${r})`),c(v),!0}if((!l||w>A)&&b>=s){let v=`${f} as forwardBuffer >= bufferLowWaterLine (${b} >= ${s})`;return l&&(v+=` and next bandwidth > current bandwidth (${w} > ${A})`),c(v),!0}return c(`not ${f} as no switching criteria met`),!1};class lS extends B.EventTarget{constructor(e){super(),this.fastQualityChange_=nS(this.fastQualityChange_.bind(this),100);const{src:t,withCredentials:n,tech:s,bandwidth:r,externVhs:a,useCueTags:l,playlistExclusionDuration:c,enableLowInitialPlaylist:f,sourceType:m,cacheEncryptionKeys:b,bufferBasedABR:C,leastPixelDiffSelector:w,captionServices:A,experimentalUseMMS:v}=e;if(!t)throw new Error("A non-empty playlist URL or JSON manifest string is required");let{maxPlaylistRetries:M}=e;(M===null||typeof M>"u")&&(M=1/0),yi=a,this.bufferBasedABR=!!C,this.leastPixelDiffSelector=!!w,this.withCredentials=n,this.tech_=s,this.vhs_=s.vhs,this.player_=e.player_,this.sourceType_=m,this.useCueTags_=l,this.playlistExclusionDuration=c,this.maxPlaylistRetries=M,this.enableLowInitialPlaylist=f,this.usingManagedMediaSource_=!1,this.useCueTags_&&(this.cueTagsTrack_=this.tech_.addTextTrack("metadata","ad-cues"),this.cueTagsTrack_.inBandMetadataTrackDispatchType=""),this.requestOptions_={withCredentials:n,maxPlaylistRetries:M,timeout:null},this.on("error",this.pauseLoading),this.mediaTypes_=tS(),v&&x.ManagedMediaSource?(this.tech_.el_.disableRemotePlayback=!0,this.mediaSource=new x.ManagedMediaSource,this.usingManagedMediaSource_=!0,B.log("Using ManagedMediaSource")):x.MediaSource&&(this.mediaSource=new x.MediaSource),this.handleDurationChange_=this.handleDurationChange_.bind(this),this.handleSourceOpen_=this.handleSourceOpen_.bind(this),this.handleSourceEnded_=this.handleSourceEnded_.bind(this),this.load=this.load.bind(this),this.pause=this.pause.bind(this),this.mediaSource.addEventListener("durationchange",this.handleDurationChange_),this.mediaSource.addEventListener("sourceopen",this.handleSourceOpen_),this.mediaSource.addEventListener("sourceended",this.handleSourceEnded_),this.mediaSource.addEventListener("startstreaming",this.load),this.mediaSource.addEventListener("endstreaming",this.pause),this.seekable_=tt(),this.hasPlayed_=!1,this.syncController_=new qv(e),this.segmentMetadataTrack_=s.addRemoteTextTrack({kind:"metadata",label:"segment-metadata"},!1).track,this.decrypter_=new zv,this.sourceUpdater_=new Ap(this.mediaSource),this.inbandTextTracks_={},this.timelineChangeController_=new Vv,this.keyStatusMap_=new Map;const D={vhs:this.vhs_,parse708captions:e.parse708captions,useDtsForTimestampOffset:e.useDtsForTimestampOffset,captionServices:A,mediaSource:this.mediaSource,currentTime:this.tech_.currentTime.bind(this.tech_),seekable:()=>this.seekable(),seeking:()=>this.tech_.seeking(),duration:()=>this.duration(),hasPlayed:()=>this.hasPlayed_,goalBufferLength:()=>this.goalBufferLength(),bandwidth:r,syncController:this.syncController_,decrypter:this.decrypter_,sourceType:this.sourceType_,inbandTextTracks:this.inbandTextTracks_,cacheEncryptionKeys:b,sourceUpdater:this.sourceUpdater_,timelineChangeController:this.timelineChangeController_,exactManifestTimings:e.exactManifestTimings,addMetadataToTextTrack:this.addMetadataToTextTrack.bind(this)};this.mainPlaylistLoader_=this.sourceType_==="dash"?new po(t,this.vhs_,fe(this.requestOptions_,{addMetadataToTextTrack:this.addMetadataToTextTrack.bind(this)})):new nn(t,this.vhs_,fe(this.requestOptions_,{addDateRangesToTextTrack:this.addDateRangesToTextTrack_.bind(this)})),this.setupMainPlaylistLoaderListeners_(),this.mainSegmentLoader_=new mo(fe(D,{segmentMetadataTrack:this.segmentMetadataTrack_,loaderType:"main"}),e),this.audioSegmentLoader_=new mo(fe(D,{loaderType:"audio"}),e),this.subtitleSegmentLoader_=new Nv(fe(D,{loaderType:"vtt",featuresNativeTextTracks:this.tech_.featuresNativeTextTracks,loadVttJs:()=>new Promise((F,P)=>{function $(){s.off("vttjserror",Y),F()}function Y(){s.off("vttjsloaded",$),P()}s.one("vttjsloaded",$),s.one("vttjserror",Y),s.addWebVttScript_()})}),e);const R=()=>this.mainSegmentLoader_.bandwidth;this.contentSteeringController_=new iS(this.vhs_.xhr,R),this.setupSegmentLoaderListeners_(),this.bufferBasedABR&&(this.mainPlaylistLoader_.one("loadedplaylist",()=>this.startABRTimer_()),this.tech_.on("pause",()=>this.stopABRTimer_()),this.tech_.on("play",()=>this.startABRTimer_())),rS.forEach(F=>{this[F+"_"]=aS.bind(this,F)}),this.logger_=Lt("pc"),this.triggeredFmp4Usage=!1,this.tech_.preload()==="none"?(this.loadOnPlay_=()=>{this.loadOnPlay_=null,this.mainPlaylistLoader_.load()},this.tech_.one("play",this.loadOnPlay_)):this.mainPlaylistLoader_.load(),this.timeToLoadedData__=-1,this.mainAppendsToLoadedData__=-1,this.audioAppendsToLoadedData__=-1;const N=this.tech_.preload()==="none"?"play":"loadstart";this.tech_.one(N,()=>{const F=Date.now();this.tech_.one("loadeddata",()=>{this.timeToLoadedData__=Date.now()-F,this.mainAppendsToLoadedData__=this.mainSegmentLoader_.mediaAppends,this.audioAppendsToLoadedData__=this.audioSegmentLoader_.mediaAppends})})}mainAppendsToLoadedData_(){return this.mainAppendsToLoadedData__}audioAppendsToLoadedData_(){return this.audioAppendsToLoadedData__}appendsToLoadedData_(){const e=this.mainAppendsToLoadedData_(),t=this.audioAppendsToLoadedData_();return e===-1||t===-1?-1:e+t}timeToLoadedData_(){return this.timeToLoadedData__}checkABR_(e="abr"){const t=this.selectPlaylist();t&&this.shouldSwitchToMedia_(t)&&this.switchMedia_(t,e)}switchMedia_(e,t,n){const s=this.media(),r=s&&(s.id||s.uri),a=e&&(e.id||e.uri);if(r&&r!==a){this.logger_(`switch media ${r} -> ${a} from ${t}`);const l={renditionInfo:{id:a,bandwidth:e.attributes.BANDWIDTH,resolution:e.attributes.RESOLUTION,codecs:e.attributes.CODECS},cause:t};this.trigger({type:"renditionselected",metadata:l}),this.tech_.trigger({type:"usage",name:`vhs-rendition-change-${t}`})}this.mainPlaylistLoader_.media(e,n)}switchMediaForDASHContentSteering_(){["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(e=>{const t=this.mediaTypes_[e],n=t?t.activeGroup():null,s=this.contentSteeringController_.getPathway();if(n&&s){const r=(n.length?n[0].playlists:n.playlists).filter(a=>a.attributes.serviceLocation===s);r.length&&this.mediaTypes_[e].activePlaylistLoader.media(r[0])}})}startABRTimer_(){this.stopABRTimer_(),this.abrTimer_=x.setInterval(()=>this.checkABR_(),250)}stopABRTimer_(){this.tech_.scrubbing&&this.tech_.scrubbing()||(x.clearInterval(this.abrTimer_),this.abrTimer_=null)}getAudioTrackPlaylists_(){const e=this.main(),t=e&&e.playlists||[];if(!e||!e.mediaGroups||!e.mediaGroups.AUDIO)return t;const n=e.mediaGroups.AUDIO,s=Object.keys(n);let r;if(Object.keys(this.mediaTypes_.AUDIO.groups).length)r=this.mediaTypes_.AUDIO.activeTrack();else{const l=n.main||s.length&&n[s[0]];for(const c in l)if(l[c].default){r={label:c};break}}if(!r)return t;const a=[];for(const l in n)if(n[l][r.label]){const c=n[l][r.label];if(c.playlists&&c.playlists.length)a.push.apply(a,c.playlists);else if(c.uri)a.push(c);else if(e.playlists.length)for(let f=0;f<e.playlists.length;f++){const m=e.playlists[f];m.attributes&&m.attributes.AUDIO&&m.attributes.AUDIO===l&&a.push(m)}}return a.length?a:t}setupMainPlaylistLoaderListeners_(){this.mainPlaylistLoader_.on("loadedmetadata",()=>{const e=this.mainPlaylistLoader_.media(),t=e.targetDuration*1.5*1e3;oo(this.mainPlaylistLoader_.main,this.mainPlaylistLoader_.media())?this.requestOptions_.timeout=0:this.requestOptions_.timeout=t,e.endList&&this.tech_.preload()!=="none"&&(this.mainSegmentLoader_.playlist(e,this.requestOptions_),this.mainSegmentLoader_.load()),eS({sourceType:this.sourceType_,segmentLoaders:{AUDIO:this.audioSegmentLoader_,SUBTITLES:this.subtitleSegmentLoader_,main:this.mainSegmentLoader_},tech:this.tech_,requestOptions:this.requestOptions_,mainPlaylistLoader:this.mainPlaylistLoader_,vhs:this.vhs_,main:this.main(),mediaTypes:this.mediaTypes_,excludePlaylist:this.excludePlaylist.bind(this)}),this.triggerPresenceUsage_(this.main(),e),this.setupFirstPlay(),!this.mediaTypes_.AUDIO.activePlaylistLoader||this.mediaTypes_.AUDIO.activePlaylistLoader.media()?this.trigger("selectedinitialmedia"):this.mediaTypes_.AUDIO.activePlaylistLoader.one("loadedmetadata",()=>{this.trigger("selectedinitialmedia")})}),this.mainPlaylistLoader_.on("loadedplaylist",()=>{this.loadOnPlay_&&this.tech_.off("play",this.loadOnPlay_);let e=this.mainPlaylistLoader_.media();if(!e){this.attachContentSteeringListeners_(),this.initContentSteeringController_(),this.excludeUnsupportedVariants_();let t;if(this.enableLowInitialPlaylist&&(t=this.selectInitialPlaylist()),t||(t=this.selectPlaylist()),!t||!this.shouldSwitchToMedia_(t)||(this.initialMedia_=t,this.switchMedia_(this.initialMedia_,"initial"),!(this.sourceType_==="vhs-json"&&this.initialMedia_.segments)))return;e=this.initialMedia_}this.handleUpdatedMediaPlaylist(e)}),this.mainPlaylistLoader_.on("error",()=>{const e=this.mainPlaylistLoader_.error;this.excludePlaylist({playlistToExclude:e.playlist,error:e})}),this.mainPlaylistLoader_.on("mediachanging",()=>{this.mainSegmentLoader_.abort(),this.mainSegmentLoader_.pause()}),this.mainPlaylistLoader_.on("mediachange",()=>{const e=this.mainPlaylistLoader_.media(),t=e.targetDuration*1.5*1e3;oo(this.mainPlaylistLoader_.main,this.mainPlaylistLoader_.media())?this.requestOptions_.timeout=0:this.requestOptions_.timeout=t,this.sourceType_==="dash"&&this.mainPlaylistLoader_.isPaused&&this.mainPlaylistLoader_.load(),this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.playlist(e,this.requestOptions_),this.waitingForFastQualityPlaylistReceived_?this.runFastQualitySwitch_():this.mainSegmentLoader_.load(),this.tech_.trigger({type:"mediachange",bubbles:!0})}),this.mainPlaylistLoader_.on("playlistunchanged",()=>{const e=this.mainPlaylistLoader_.media();e.lastExcludeReason_!=="playlist-unchanged"&&this.stuckAtPlaylistEnd_(e)&&(this.excludePlaylist({error:{message:"Playlist no longer updating.",reason:"playlist-unchanged"}}),this.tech_.trigger("playliststuck"))}),this.mainPlaylistLoader_.on("renditiondisabled",()=>{this.tech_.trigger({type:"usage",name:"vhs-rendition-disabled"})}),this.mainPlaylistLoader_.on("renditionenabled",()=>{this.tech_.trigger({type:"usage",name:"vhs-rendition-enabled"})}),["manifestrequeststart","manifestrequestcomplete","manifestparsestart","manifestparsecomplete","playlistrequeststart","playlistrequestcomplete","playlistparsestart","playlistparsecomplete","renditiondisabled","renditionenabled"].forEach(e=>{this.mainPlaylistLoader_.on(e,t=>{this.player_.trigger(je({},t))})})}handleUpdatedMediaPlaylist(e){this.useCueTags_&&this.updateAdCues_(e),this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.playlist(e,this.requestOptions_),this.waitingForFastQualityPlaylistReceived_&&this.runFastQualitySwitch_(),this.updateDuration(!e.endList),this.tech_.paused()||(this.mainSegmentLoader_.load(),this.audioSegmentLoader_&&this.audioSegmentLoader_.load())}triggerPresenceUsage_(e,t){const n=e.mediaGroups||{};let s=!0;const r=Object.keys(n.AUDIO);for(const a in n.AUDIO)for(const l in n.AUDIO[a])n.AUDIO[a][l].uri||(s=!1);s&&this.tech_.trigger({type:"usage",name:"vhs-demuxed"}),Object.keys(n.SUBTITLES).length&&this.tech_.trigger({type:"usage",name:"vhs-webvtt"}),yi.Playlist.isAes(t)&&this.tech_.trigger({type:"usage",name:"vhs-aes"}),r.length&&Object.keys(n.AUDIO[r[0]]).length>1&&this.tech_.trigger({type:"usage",name:"vhs-alternate-audio"}),this.useCueTags_&&this.tech_.trigger({type:"usage",name:"vhs-playlist-cue-tags"})}shouldSwitchToMedia_(e){const t=this.mainPlaylistLoader_.media()||this.mainPlaylistLoader_.pendingMedia_,n=this.tech_.currentTime(),s=this.bufferLowWaterLine(),r=this.bufferHighWaterLine(),a=this.tech_.buffered();return oS({buffered:a,currentTime:n,currentPlaylist:t,nextPlaylist:e,bufferLowWaterLine:s,bufferHighWaterLine:r,duration:this.duration(),bufferBasedABR:this.bufferBasedABR,log:this.logger_})}setupSegmentLoaderListeners_(){this.mainSegmentLoader_.on("bandwidthupdate",()=>{this.checkABR_("bandwidthupdate"),this.tech_.trigger("bandwidthupdate")}),this.mainSegmentLoader_.on("timeout",()=>{this.bufferBasedABR&&this.mainSegmentLoader_.load()}),this.bufferBasedABR||this.mainSegmentLoader_.on("progress",()=>{this.trigger("progress")}),this.mainSegmentLoader_.on("error",()=>{const t=this.mainSegmentLoader_.error();this.excludePlaylist({playlistToExclude:t.playlist,error:t})}),this.mainSegmentLoader_.on("appenderror",()=>{this.error=this.mainSegmentLoader_.error_,this.trigger("error")}),this.mainSegmentLoader_.on("syncinfoupdate",()=>{this.onSyncInfoUpdate_()}),this.mainSegmentLoader_.on("timestampoffset",()=>{this.tech_.trigger({type:"usage",name:"vhs-timestamp-offset"})}),this.audioSegmentLoader_.on("syncinfoupdate",()=>{this.onSyncInfoUpdate_()}),this.audioSegmentLoader_.on("appenderror",()=>{this.error=this.audioSegmentLoader_.error_,this.trigger("error")}),this.mainSegmentLoader_.on("ended",()=>{this.logger_("main segment loader ended"),this.onEndOfStream()}),this.timelineChangeController_.on("audioTimelineBehind",()=>{const t=this.audioSegmentLoader_.pendingSegment_;if(!t||!t.segment||!t.segment.syncInfo)return;const n=t.segment.syncInfo.end+.01;this.tech_.setCurrentTime(n)}),this.timelineChangeController_.on("fixBadTimelineChange",()=>{this.logger_("Fix bad timeline change. Restarting al segment loaders..."),this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.resetEverything(),this.mediaTypes_.AUDIO.activePlaylistLoader&&(this.audioSegmentLoader_.pause(),this.audioSegmentLoader_.resetEverything()),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&(this.subtitleSegmentLoader_.pause(),this.subtitleSegmentLoader_.resetEverything()),this.load()}),this.mainSegmentLoader_.on("earlyabort",t=>{this.bufferBasedABR||(this.delegateLoaders_("all",["abort"]),this.excludePlaylist({error:{message:"Aborted early because there isn't enough bandwidth to complete the request without rebuffering."},playlistExclusionDuration:sS}))});const e=()=>{if(!this.sourceUpdater_.hasCreatedSourceBuffers())return this.tryToCreateSourceBuffers_();const t=this.getCodecsOrExclude_();t&&this.sourceUpdater_.addOrChangeSourceBuffers(t)};this.mainSegmentLoader_.on("trackinfo",e),this.audioSegmentLoader_.on("trackinfo",e),this.mainSegmentLoader_.on("fmp4",()=>{this.triggeredFmp4Usage||(this.tech_.trigger({type:"usage",name:"vhs-fmp4"}),this.triggeredFmp4Usage=!0)}),this.audioSegmentLoader_.on("fmp4",()=>{this.triggeredFmp4Usage||(this.tech_.trigger({type:"usage",name:"vhs-fmp4"}),this.triggeredFmp4Usage=!0)}),this.audioSegmentLoader_.on("ended",()=>{this.logger_("audioSegmentLoader ended"),this.onEndOfStream()}),["segmentselected","segmentloadstart","segmentloaded","segmentkeyloadstart","segmentkeyloadcomplete","segmentdecryptionstart","segmentdecryptioncomplete","segmenttransmuxingstart","segmenttransmuxingcomplete","segmenttransmuxingtrackinfoavailable","segmenttransmuxingtiminginfoavailable","segmentappendstart","appendsdone","bandwidthupdated","timelinechange","codecschange"].forEach(t=>{this.mainSegmentLoader_.on(t,n=>{this.player_.trigger(je({},n))}),this.audioSegmentLoader_.on(t,n=>{this.player_.trigger(je({},n))}),this.subtitleSegmentLoader_.on(t,n=>{this.player_.trigger(je({},n))})})}mediaSecondsLoaded_(){return Math.max(this.audioSegmentLoader_.mediaSecondsLoaded+this.mainSegmentLoader_.mediaSecondsLoaded)}load(){this.mainSegmentLoader_.load(),this.mediaTypes_.AUDIO.activePlaylistLoader&&this.audioSegmentLoader_.load(),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&this.subtitleSegmentLoader_.load()}pause(){this.mainSegmentLoader_.pause(),this.mediaTypes_.AUDIO.activePlaylistLoader&&this.audioSegmentLoader_.pause(),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&this.subtitleSegmentLoader_.pause()}fastQualityChange_(e=this.selectPlaylist()){if(e&&e===this.mainPlaylistLoader_.media()){this.logger_("skipping fastQualityChange because new media is same as old");return}this.switchMedia_(e,"fast-quality"),this.waitingForFastQualityPlaylistReceived_=!0}runFastQualitySwitch_(){this.waitingForFastQualityPlaylistReceived_=!1,this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.resetEverything(),this.mediaTypes_.AUDIO.activePlaylistLoader&&(this.audioSegmentLoader_.pause(),this.audioSegmentLoader_.resetEverything()),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&(this.subtitleSegmentLoader_.pause(),this.subtitleSegmentLoader_.resetEverything()),this.load()}play(){if(this.setupFirstPlay())return;this.tech_.ended()&&this.tech_.setCurrentTime(0),this.hasPlayed_&&this.load();const e=this.tech_.seekable();if(this.tech_.duration()===1/0&&this.tech_.currentTime()<e.start(0))return this.tech_.setCurrentTime(e.end(e.length-1))}setupFirstPlay(){const e=this.mainPlaylistLoader_.media();if(!e||this.tech_.paused()||this.hasPlayed_)return!1;if(!e.endList||e.start){const t=this.seekable();if(!t.length)return!1;const n=t.end(0);let s=n;if(e.start){const r=e.start.timeOffset;r<0?s=Math.max(n+r,t.start(0)):s=Math.min(n,r)}this.trigger("firstplay"),this.tech_.setCurrentTime(s)}return this.hasPlayed_=!0,this.load(),!0}handleSourceOpen_(){if(this.tryToCreateSourceBuffers_(),this.tech_.autoplay()){const e=this.tech_.play();typeof e<"u"&&typeof e.then=="function"&&e.then(null,t=>{})}this.trigger("sourceopen")}handleSourceEnded_(){if(!this.inbandTextTracks_.metadataTrack_)return;const e=this.inbandTextTracks_.metadataTrack_.cues;if(!e||!e.length)return;const t=this.duration();e[e.length-1].endTime=isNaN(t)||Math.abs(t)===1/0?Number.MAX_VALUE:t}handleDurationChange_(){this.tech_.trigger("durationchange")}onEndOfStream(){let e=this.mainSegmentLoader_.ended_;if(this.mediaTypes_.AUDIO.activePlaylistLoader){const t=this.mainSegmentLoader_.getCurrentMediaInfo_();!t||t.hasVideo?e=e&&this.audioSegmentLoader_.ended_:e=this.audioSegmentLoader_.ended_}e&&(this.stopABRTimer_(),this.sourceUpdater_.endOfStream())}stuckAtPlaylistEnd_(e){if(!this.seekable().length)return!1;const t=this.syncController_.getExpiredTime(e,this.duration());if(t===null)return!1;const n=yi.Playlist.playlistEnd(e,t),s=this.tech_.currentTime(),r=this.tech_.buffered();if(!r.length)return n-s<=Kt;const a=r.end(r.length-1);return a-s<=Kt&&n-a<=Kt}excludePlaylist({playlistToExclude:e=this.mainPlaylistLoader_.media(),error:t={},playlistExclusionDuration:n}){if(e=e||this.mainPlaylistLoader_.media(),n=n||t.playlistExclusionDuration||this.playlistExclusionDuration,!e){this.error=t,this.mediaSource.readyState!=="open"?this.trigger("error"):this.sourceUpdater_.endOfStream("network");return}e.playlistErrors_++;const s=this.mainPlaylistLoader_.main.playlists,r=s.filter(ta),a=r.length===1&&r[0]===e;if(s.length===1&&n!==1/0)return B.log.warn(`Problem encountered with playlist ${e.id}. Trying again since it is the only playlist.`),this.tech_.trigger("retryplaylist"),this.mainPlaylistLoader_.load(a);if(a){if(this.main().contentSteering){const A=this.pathwayAttribute_(e),v=this.contentSteeringController_.steeringManifest.ttl*1e3;this.contentSteeringController_.excludePathway(A),this.excludeThenChangePathway_(),setTimeout(()=>{this.contentSteeringController_.addAvailablePathway(A)},v);return}let w=!1;s.forEach(A=>{if(A===e)return;const v=A.excludeUntil;typeof v<"u"&&v!==1/0&&(w=!0,delete A.excludeUntil)}),w&&(B.log.warn("Removing other playlists from the exclusion list because the last rendition is about to be excluded."),this.tech_.trigger("retryplaylist"))}let l;e.playlistErrors_>this.maxPlaylistRetries?l=1/0:l=Date.now()+n*1e3,e.excludeUntil=l,t.reason&&(e.lastExcludeReason_=t.reason),this.tech_.trigger("excludeplaylist"),this.tech_.trigger({type:"usage",name:"vhs-rendition-excluded"});const c=this.selectPlaylist();if(!c){this.error="Playback cannot continue. No available working or supported playlists.",this.trigger("error");return}const f=t.internal?this.logger_:B.log.warn,m=t.message?" "+t.message:"";f(`${t.internal?"Internal problem":"Problem"} encountered with playlist ${e.id}.${m} Switching to playlist ${c.id}.`),c.attributes.AUDIO!==e.attributes.AUDIO&&this.delegateLoaders_("audio",["abort","pause"]),c.attributes.SUBTITLES!==e.attributes.SUBTITLES&&this.delegateLoaders_("subtitle",["abort","pause"]),this.delegateLoaders_("main",["abort","pause"]);const b=c.targetDuration/2*1e3||5*1e3,C=typeof c.lastRequest=="number"&&Date.now()-c.lastRequest<=b;return this.switchMedia_(c,"exclude",a||C)}pauseLoading(){this.delegateLoaders_("all",["abort","pause"]),this.stopABRTimer_()}delegateLoaders_(e,t){const n=[],s=e==="all";(s||e==="main")&&n.push(this.mainPlaylistLoader_);const r=[];(s||e==="audio")&&r.push("AUDIO"),(s||e==="subtitle")&&(r.push("CLOSED-CAPTIONS"),r.push("SUBTITLES")),r.forEach(a=>{const l=this.mediaTypes_[a]&&this.mediaTypes_[a].activePlaylistLoader;l&&n.push(l)}),["main","audio","subtitle"].forEach(a=>{const l=this[`${a}SegmentLoader_`];l&&(e===a||e==="all")&&n.push(l)}),n.forEach(a=>t.forEach(l=>{typeof a[l]=="function"&&a[l]()}))}setCurrentTime(e){const t=tn(this.tech_.buffered(),e);if(!(this.mainPlaylistLoader_&&this.mainPlaylistLoader_.media())||!this.mainPlaylistLoader_.media().segments)return 0;if(t&&t.length)return e;this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.resetEverything(),this.mediaTypes_.AUDIO.activePlaylistLoader&&(this.audioSegmentLoader_.pause(),this.audioSegmentLoader_.resetEverything()),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&(this.subtitleSegmentLoader_.pause(),this.subtitleSegmentLoader_.resetEverything()),this.load()}duration(){if(!this.mainPlaylistLoader_)return 0;const e=this.mainPlaylistLoader_.media();return e?e.endList?this.mediaSource?this.mediaSource.duration:yi.Playlist.duration(e):1/0:0}seekable(){return this.seekable_}getSeekableRange_(e,t){const n=e.media();if(!n)return null;const s=this.syncController_.getMediaSequenceSync(t);if(s&&s.isReliable){const l=s.start,c=s.end;if(!isFinite(l)||!isFinite(c))return null;const f=yi.Playlist.liveEdgeDelay(this.mainPlaylistLoader_.main,n),m=Math.max(0,c-f);return m<l?null:tt([[l,m]])}const r=this.syncController_.getExpiredTime(n,this.duration());if(r===null)return null;const a=yi.Playlist.seekable(n,r,yi.Playlist.liveEdgeDelay(this.mainPlaylistLoader_.main,n));return a.length?a:null}computeFinalSeekable_(e,t){if(!t)return e;const n=e.start(0),s=e.end(0),r=t.start(0),a=t.end(0);return r>s||n>a?e:tt([[Math.max(n,r),Math.min(s,a)]])}onSyncInfoUpdate_(){if(!this.mainPlaylistLoader_)return;const e=this.getSeekableRange_(this.mainPlaylistLoader_,"main");if(!e)return;let t;if(this.mediaTypes_.AUDIO.activePlaylistLoader&&(t=this.getSeekableRange_(this.mediaTypes_.AUDIO.activePlaylistLoader,"audio"),!t))return;const n=this.seekable_;if(this.seekable_=this.computeFinalSeekable_(e,t),!this.seekable_||n&&n.length&&this.seekable_.length&&n.start(0)===this.seekable_.start(0)&&n.end(0)===this.seekable_.end(0))return;this.logger_(`seekable updated [${Vc(this.seekable_)}]`);const s={seekableRanges:this.seekable_};this.trigger({type:"seekablerangeschanged",metadata:s}),this.tech_.trigger("seekablechanged")}updateDuration(e){if(this.updateDuration_&&(this.mediaSource.removeEventListener("sourceopen",this.updateDuration_),this.updateDuration_=null),this.mediaSource.readyState!=="open"){this.updateDuration_=this.updateDuration.bind(this,e),this.mediaSource.addEventListener("sourceopen",this.updateDuration_);return}if(e){const s=this.seekable();if(!s.length)return;(isNaN(this.mediaSource.duration)||this.mediaSource.duration<s.end(s.length-1))&&this.sourceUpdater_.setDuration(s.end(s.length-1));return}const t=this.tech_.buffered();let n=yi.Playlist.duration(this.mainPlaylistLoader_.media());t.length>0&&(n=Math.max(n,t.end(t.length-1))),this.mediaSource.duration!==n&&this.sourceUpdater_.setDuration(n)}dispose(){this.trigger("dispose"),this.decrypter_.terminate(),this.mainPlaylistLoader_.dispose(),this.mainSegmentLoader_.dispose(),this.contentSteeringController_.dispose(),this.keyStatusMap_.clear(),this.loadOnPlay_&&this.tech_.off("play",this.loadOnPlay_),["AUDIO","SUBTITLES"].forEach(e=>{const t=this.mediaTypes_[e].groups;for(const n in t)t[n].forEach(s=>{s.playlistLoader&&s.playlistLoader.dispose()})}),this.audioSegmentLoader_.dispose(),this.subtitleSegmentLoader_.dispose(),this.sourceUpdater_.dispose(),this.timelineChangeController_.dispose(),this.stopABRTimer_(),this.updateDuration_&&this.mediaSource.removeEventListener("sourceopen",this.updateDuration_),this.mediaSource.removeEventListener("durationchange",this.handleDurationChange_),this.mediaSource.removeEventListener("sourceopen",this.handleSourceOpen_),this.mediaSource.removeEventListener("sourceended",this.handleSourceEnded_),this.off()}main(){return this.mainPlaylistLoader_.main}media(){return this.mainPlaylistLoader_.media()||this.initialMedia_}areMediaTypesKnown_(){const e=!!this.mediaTypes_.AUDIO.activePlaylistLoader,t=!!this.mainSegmentLoader_.getCurrentMediaInfo_(),n=e?!!this.audioSegmentLoader_.getCurrentMediaInfo_():!0;return!(!t||!n)}getCodecsOrExclude_(){const e={main:this.mainSegmentLoader_.getCurrentMediaInfo_()||{},audio:this.audioSegmentLoader_.getCurrentMediaInfo_()||{}},t=this.mainSegmentLoader_.getPendingSegmentPlaylist()||this.media();e.video=e.main;const n=hs(this.main(),t),s={},r=!!this.mediaTypes_.AUDIO.activePlaylistLoader;if(e.main.hasVideo&&(s.video=n.video||e.main.videoCodec||J_),e.main.isMuxed&&(s.video+=`,${n.audio||e.main.audioCodec||vu}`),(e.main.hasAudio&&!e.main.isMuxed||e.audio.hasAudio||r)&&(s.audio=n.audio||e.main.audioCodec||e.audio.audioCodec||vu,e.audio.isFmp4=e.main.hasAudio&&!e.main.isMuxed?e.main.isFmp4:e.audio.isFmp4),!s.audio&&!s.video){this.excludePlaylist({playlistToExclude:t,error:{message:"Could not determine codecs for playlist."},playlistExclusionDuration:1/0});return}const a=(f,m)=>f?as(m,this.usingManagedMediaSource_):Aa(m),l={};let c;if(["video","audio"].forEach(function(f){if(s.hasOwnProperty(f)&&!a(e[f].isFmp4,s[f])){const m=e[f].isFmp4?"browser":"muxer";l[m]=l[m]||[],l[m].push(s[f]),f==="audio"&&(c=m)}}),r&&c&&t.attributes.AUDIO){const f=t.attributes.AUDIO;this.main().playlists.forEach(m=>{(m.attributes&&m.attributes.AUDIO)===f&&m!==t&&(m.excludeUntil=1/0)}),this.logger_(`excluding audio group ${f} as ${c} does not support codec(s): "${s.audio}"`)}if(Object.keys(l).length){const f=Object.keys(l).reduce((m,b)=>(m&&(m+=", "),m+=`${b} does not support codec(s): "${l[b].join(",")}"`,m),"")+".";this.excludePlaylist({playlistToExclude:t,error:{internal:!0,message:f},playlistExclusionDuration:1/0});return}if(this.sourceUpdater_.hasCreatedSourceBuffers()&&!this.sourceUpdater_.canChangeType()){const f=[];if(["video","audio"].forEach(m=>{const b=(Ht(this.sourceUpdater_.codecs[m]||"")[0]||{}).type,C=(Ht(s[m]||"")[0]||{}).type;b&&C&&b.toLowerCase()!==C.toLowerCase()&&f.push(`"${this.sourceUpdater_.codecs[m]}" -> "${s[m]}"`)}),f.length){this.excludePlaylist({playlistToExclude:t,error:{message:`Codec switching not supported: ${f.join(", ")}.`,internal:!0},playlistExclusionDuration:1/0});return}}return s}tryToCreateSourceBuffers_(){if(this.mediaSource.readyState!=="open"||this.sourceUpdater_.hasCreatedSourceBuffers()||!this.areMediaTypesKnown_())return;const e=this.getCodecsOrExclude_();if(!e)return;this.sourceUpdater_.createSourceBuffers(e);const t=[e.video,e.audio].filter(Boolean).join(",");this.excludeIncompatibleVariants_(t)}excludeUnsupportedVariants_(){const e=this.main().playlists,t=[];Object.keys(e).forEach(n=>{const s=e[n];if(t.indexOf(s.id)!==-1)return;t.push(s.id);const r=hs(this.main,s),a=[];r.audio&&!Aa(r.audio)&&!as(r.audio,this.usingManagedMediaSource_)&&a.push(`audio codec ${r.audio}`),r.video&&!Aa(r.video)&&!as(r.video,this.usingManagedMediaSource_)&&a.push(`video codec ${r.video}`),r.text&&r.text==="stpp.ttml.im1t"&&a.push(`text codec ${r.text}`),a.length&&(s.excludeUntil=1/0,this.logger_(`excluding ${s.id} for unsupported: ${a.join(", ")}`))})}excludeIncompatibleVariants_(e){const t=[],n=this.main().playlists,s=Ir(Ht(e)),r=pd(s),a=s.video&&Ht(s.video)[0]||null,l=s.audio&&Ht(s.audio)[0]||null;Object.keys(n).forEach(c=>{const f=n[c];if(t.indexOf(f.id)!==-1||f.excludeUntil===1/0)return;t.push(f.id);const m=[],b=hs(this.mainPlaylistLoader_.main,f),C=pd(b);if(!(!b.audio&&!b.video)){if(C!==r&&m.push(`codec count "${C}" !== "${r}"`),!this.sourceUpdater_.canChangeType()){const w=b.video&&Ht(b.video)[0]||null,A=b.audio&&Ht(b.audio)[0]||null;w&&a&&w.type.toLowerCase()!==a.type.toLowerCase()&&m.push(`video codec "${w.type}" !== "${a.type}"`),A&&l&&A.type.toLowerCase()!==l.type.toLowerCase()&&m.push(`audio codec "${A.type}" !== "${l.type}"`)}m.length&&(f.excludeUntil=1/0,this.logger_(`excluding ${f.id}: ${m.join(" && ")}`))}})}updateAdCues_(e){let t=0;const n=this.seekable();n.length&&(t=n.start(0)),Fv(e,this.cueTagsTrack_,t)}goalBufferLength(){const e=this.tech_.currentTime(),t=We.GOAL_BUFFER_LENGTH,n=We.GOAL_BUFFER_LENGTH_RATE,s=Math.max(t,We.MAX_GOAL_BUFFER_LENGTH);return Math.min(t+e*n,s)}bufferLowWaterLine(){const e=this.tech_.currentTime(),t=We.BUFFER_LOW_WATER_LINE,n=We.BUFFER_LOW_WATER_LINE_RATE,s=Math.max(t,We.MAX_BUFFER_LOW_WATER_LINE),r=Math.max(t,We.EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE);return Math.min(t+e*n,this.bufferBasedABR?r:s)}bufferHighWaterLine(){return We.BUFFER_HIGH_WATER_LINE}addDateRangesToTextTrack_(e){md(this.inbandTextTracks_,"com.apple.streaming",this.tech_),_v({inbandTextTracks:this.inbandTextTracks_,dateRanges:e})}addMetadataToTextTrack(e,t,n){const s=this.sourceUpdater_.videoBuffer?this.sourceUpdater_.videoTimestampOffset():this.sourceUpdater_.audioTimestampOffset();md(this.inbandTextTracks_,e,this.tech_),fv({inbandTextTracks:this.inbandTextTracks_,metadataArray:t,timestampOffset:s,videoDuration:n})}pathwayAttribute_(e){return e.attributes["PATHWAY-ID"]||e.attributes.serviceLocation}initContentSteeringController_(){const e=this.main();if(e.contentSteering){for(const t of e.playlists)this.contentSteeringController_.addAvailablePathway(this.pathwayAttribute_(t));if(this.contentSteeringController_.assignTagProperties(e.uri,e.contentSteering),this.contentSteeringController_.queryBeforeStart){this.contentSteeringController_.requestSteeringManifest(!0);return}this.tech_.one("canplay",()=>{this.contentSteeringController_.requestSteeringManifest()})}}resetContentSteeringController_(){this.contentSteeringController_.clearAvailablePathways(),this.contentSteeringController_.dispose(),this.initContentSteeringController_()}attachContentSteeringListeners_(){this.contentSteeringController_.on("content-steering",this.excludeThenChangePathway_.bind(this)),["contentsteeringloadstart","contentsteeringloadcomplete","contentsteeringparsed"].forEach(e=>{this.contentSteeringController_.on(e,t=>{this.trigger(je({},t))})}),this.sourceType_==="dash"&&this.mainPlaylistLoader_.on("loadedplaylist",()=>{const e=this.main();(this.contentSteeringController_.didDASHTagChange(e.uri,e.contentSteering)||(()=>{const t=this.contentSteeringController_.getAvailablePathways(),n=[];for(const s of e.playlists){const r=s.attributes.serviceLocation;if(r&&(n.push(r),!t.has(r)))return!0}return!!(!n.length&&t.size)})())&&this.resetContentSteeringController_()})}excludeThenChangePathway_(){const e=this.contentSteeringController_.getPathway();if(!e)return;this.handlePathwayClones_();const t=this.main().playlists,n=new Set;let s=!1;Object.keys(t).forEach(r=>{const a=t[r],l=this.pathwayAttribute_(a),c=l&&e!==l;a.excludeUntil===1/0&&a.lastExcludeReason_==="content-steering"&&!c&&(delete a.excludeUntil,delete a.lastExcludeReason_,s=!0);const f=!a.excludeUntil&&a.excludeUntil!==1/0;!n.has(a.id)&&c&&f&&(n.add(a.id),a.excludeUntil=1/0,a.lastExcludeReason_="content-steering",this.logger_(`excluding ${a.id} for ${a.lastExcludeReason_}`))}),this.contentSteeringController_.manifestType_==="DASH"&&Object.keys(this.mediaTypes_).forEach(r=>{const a=this.mediaTypes_[r];if(a.activePlaylistLoader){const l=a.activePlaylistLoader.media_;l&&l.attributes.serviceLocation!==e&&(s=!0)}}),s&&this.changeSegmentPathway_()}handlePathwayClones_(){const e=this.main().playlists,t=this.contentSteeringController_.currentPathwayClones,n=this.contentSteeringController_.nextPathwayClones;if(t&&t.size||n&&n.size){for(const[s,r]of t.entries())n.get(s)||(this.mainPlaylistLoader_.updateOrDeleteClone(r),this.contentSteeringController_.excludePathway(s));for(const[s,r]of n.entries()){const a=t.get(s);if(!a){e.filter(l=>l.attributes["PATHWAY-ID"]===r["BASE-ID"]).forEach(l=>{this.mainPlaylistLoader_.addClonePathway(r,l)}),this.contentSteeringController_.addAvailablePathway(s);continue}this.equalPathwayClones_(a,r)||(this.mainPlaylistLoader_.updateOrDeleteClone(r,!0),this.contentSteeringController_.addAvailablePathway(s))}this.contentSteeringController_.currentPathwayClones=new Map(JSON.parse(JSON.stringify([...n])))}}equalPathwayClones_(e,t){if(e["BASE-ID"]!==t["BASE-ID"]||e.ID!==t.ID||e["URI-REPLACEMENT"].HOST!==t["URI-REPLACEMENT"].HOST)return!1;const n=e["URI-REPLACEMENT"].PARAMS,s=t["URI-REPLACEMENT"].PARAMS;for(const r in n)if(n[r]!==s[r])return!1;for(const r in s)if(n[r]!==s[r])return!1;return!0}changeSegmentPathway_(){const e=this.selectPlaylist();this.pauseLoading(),this.contentSteeringController_.manifestType_==="DASH"&&this.switchMediaForDASHContentSteering_(),this.switchMedia_(e,"content-steering")}excludeNonUsablePlaylistsByKeyId_(){if(!this.mainPlaylistLoader_||!this.mainPlaylistLoader_.main)return;let e=0;const t="non-usable";this.mainPlaylistLoader_.main.playlists.forEach(n=>{const s=this.mainPlaylistLoader_.getKeyIdSet(n);!s||!s.size||s.forEach(r=>{const a="usable",l=this.keyStatusMap_.has(r)&&this.keyStatusMap_.get(r)===a,c=n.lastExcludeReason_===t&&n.excludeUntil===1/0;l?l&&c&&(delete n.excludeUntil,delete n.lastExcludeReason_,this.logger_(`enabling playlist ${n.id} because key ID ${r} is ${a}`)):(n.excludeUntil!==1/0&&n.lastExcludeReason_!==t&&(n.excludeUntil=1/0,n.lastExcludeReason_=t,this.logger_(`excluding playlist ${n.id} because the key ID ${r} doesn't exist in the keyStatusMap or is not ${a}`)),e++)})}),e>=this.mainPlaylistLoader_.main.playlists.length&&this.mainPlaylistLoader_.main.playlists.forEach(n=>{const s=n&&n.attributes&&n.attributes.RESOLUTION&&n.attributes.RESOLUTION.height<720,r=n.excludeUntil===1/0&&n.lastExcludeReason_===t;s&&r&&(delete n.excludeUntil,B.log.warn(`enabling non-HD playlist ${n.id} because all playlists were excluded due to ${t} key IDs`))})}addKeyStatus_(e,t){const n=(typeof e=="string"?e:Rv(e)).slice(0,32).toLowerCase();this.logger_(`KeyStatus '${t}' with key ID ${n} added to the keyStatusMap`),this.keyStatusMap_.set(n,t)}updatePlaylistByKeyStatus(e,t){this.addKeyStatus_(e,t),this.waitingForFastQualityPlaylistReceived_||this.excludeNonUsableThenChangePlaylist_(),this.mainPlaylistLoader_.off("loadedplaylist",this.excludeNonUsableThenChangePlaylist_.bind(this)),this.mainPlaylistLoader_.on("loadedplaylist",this.excludeNonUsableThenChangePlaylist_.bind(this))}excludeNonUsableThenChangePlaylist_(){this.excludeNonUsablePlaylistsByKeyId_(),this.fastQualityChange_()}}const uS=(i,e,t)=>n=>{const s=i.main.playlists[e],r=dl(s),a=ta(s);if(typeof n>"u")return a;n?delete s.disabled:s.disabled=!0;const l={renditionInfo:{id:e,bandwidth:s.attributes.BANDWIDTH,resolution:s.attributes.RESOLUTION,codecs:s.attributes.CODECS},cause:"fast-quality"};return n!==a&&!r&&(n?(t(s),i.trigger({type:"renditionenabled",metadata:l})):i.trigger({type:"renditiondisabled",metadata:l})),n};class dS{constructor(e,t,n){const{playlistController_:s}=e,r=s.fastQualityChange_.bind(s);if(t.attributes){const a=t.attributes.RESOLUTION;this.width=a&&a.width,this.height=a&&a.height,this.bandwidth=t.attributes.BANDWIDTH,this.frameRate=t.attributes["FRAME-RATE"]}this.codecs=hs(s.main(),t),this.playlist=t,this.id=n,this.enabled=uS(e.playlists,t.id,r)}}const hS=function(i){i.representations=()=>{const e=i.playlistController_.main(),t=Ss(e)?i.playlistController_.getAudioTrackPlaylists_():e.playlists;return t?t.filter(n=>!dl(n)).map((n,s)=>new dS(i,n,n.id)):[]}},Id=["seeking","seeked","pause","playing","error"];class cS extends B.EventTarget{constructor(e){super(),this.playlistController_=e.playlistController,this.tech_=e.tech,this.seekable=e.seekable,this.allowSeeksWithinUnsafeLiveWindow=e.allowSeeksWithinUnsafeLiveWindow,this.liveRangeSafeTimeDelta=e.liveRangeSafeTimeDelta,this.media=e.media,this.playedRanges_=[],this.consecutiveUpdates=0,this.lastRecordedTime=null,this.checkCurrentTimeTimeout_=null,this.logger_=Lt("PlaybackWatcher"),this.logger_("initialize");const t=()=>this.monitorCurrentTime_(),n=()=>this.monitorCurrentTime_(),s=()=>this.techWaiting_(),r=()=>this.resetTimeUpdate_(),a=this.playlistController_,l=["main","subtitle","audio"],c={};l.forEach(m=>{c[m]={reset:()=>this.resetSegmentDownloads_(m),updateend:()=>this.checkSegmentDownloads_(m)},a[`${m}SegmentLoader_`].on("appendsdone",c[m].updateend),a[`${m}SegmentLoader_`].on("playlistupdate",c[m].reset),this.tech_.on(["seeked","seeking"],c[m].reset)});const f=m=>{["main","audio"].forEach(b=>{a[`${b}SegmentLoader_`][m]("appended",this.seekingAppendCheck_)})};this.seekingAppendCheck_=()=>{this.fixesBadSeeks_()&&(this.consecutiveUpdates=0,this.lastRecordedTime=this.tech_.currentTime(),f("off"))},this.clearSeekingAppendCheck_=()=>f("off"),this.watchForBadSeeking_=()=>{this.clearSeekingAppendCheck_(),f("on")},this.tech_.on("seeked",this.clearSeekingAppendCheck_),this.tech_.on("seeking",this.watchForBadSeeking_),this.tech_.on("waiting",s),this.tech_.on(Id,r),this.tech_.on("canplay",n),this.tech_.one("play",t),this.dispose=()=>{this.clearSeekingAppendCheck_(),this.logger_("dispose"),this.tech_.off("waiting",s),this.tech_.off(Id,r),this.tech_.off("canplay",n),this.tech_.off("play",t),this.tech_.off("seeking",this.watchForBadSeeking_),this.tech_.off("seeked",this.clearSeekingAppendCheck_),l.forEach(m=>{a[`${m}SegmentLoader_`].off("appendsdone",c[m].updateend),a[`${m}SegmentLoader_`].off("playlistupdate",c[m].reset),this.tech_.off(["seeked","seeking"],c[m].reset)}),this.checkCurrentTimeTimeout_&&x.clearTimeout(this.checkCurrentTimeTimeout_),this.resetTimeUpdate_()}}monitorCurrentTime_(){this.checkCurrentTime_(),this.checkCurrentTimeTimeout_&&x.clearTimeout(this.checkCurrentTimeTimeout_),this.checkCurrentTimeTimeout_=x.setTimeout(this.monitorCurrentTime_.bind(this),250)}resetSegmentDownloads_(e){const t=this.playlistController_[`${e}SegmentLoader_`];this[`${e}StalledDownloads_`]>0&&this.logger_(`resetting possible stalled download count for ${e} loader`),this[`${e}StalledDownloads_`]=0,this[`${e}Buffered_`]=t.buffered_()}checkSegmentDownloads_(e){const t=this.playlistController_,n=t[`${e}SegmentLoader_`],s=n.buffered_(),r=Yb(this[`${e}Buffered_`],s);if(this[`${e}Buffered_`]=s,r){const a={bufferedRanges:s};t.trigger({type:"bufferedrangeschanged",metadata:a}),this.resetSegmentDownloads_(e);return}this[`${e}StalledDownloads_`]++,this.logger_(`found #${this[`${e}StalledDownloads_`]} ${e} appends that did not increase buffer (possible stalled download)`,{playlistId:n.playlist_&&n.playlist_.id,buffered:Ui(s)}),!(this[`${e}StalledDownloads_`]<10)&&(this.logger_(`${e} loader stalled download exclusion`),this.resetSegmentDownloads_(e),this.tech_.trigger({type:"usage",name:`vhs-${e}-download-exclusion`}),e!=="subtitle"&&t.excludePlaylist({error:{message:`Excessive ${e} segment downloading detected.`},playlistExclusionDuration:1/0}))}checkCurrentTime_(){if(this.tech_.paused()||this.tech_.seeking())return;const e=this.tech_.currentTime(),t=this.tech_.buffered();if(this.lastRecordedTime===e&&(!t.length||e+Kt>=t.end(t.length-1)))return this.techWaiting_();if(this.consecutiveUpdates>=5&&e===this.lastRecordedTime)this.consecutiveUpdates++,this.waiting_();else if(e===this.lastRecordedTime)this.consecutiveUpdates++;else{this.playedRanges_.push(tt([this.lastRecordedTime,e]));const n={playedRanges:this.playedRanges_};this.playlistController_.trigger({type:"playedrangeschanged",metadata:n}),this.consecutiveUpdates=0,this.lastRecordedTime=e}}resetTimeUpdate_(){this.consecutiveUpdates=0}fixesBadSeeks_(){if(!this.tech_.seeking())return!1;const e=this.seekable(),t=this.tech_.currentTime(),n=this.afterSeekableWindow_(e,t,this.media(),this.allowSeeksWithinUnsafeLiveWindow);let s;if(n&&(s=e.end(e.length-1)),this.beforeSeekableWindow_(e,t)){const w=e.start(0);s=w+(w===e.end(0)?0:Kt)}if(typeof s<"u")return this.logger_(`Trying to seek outside of seekable at time ${t} with seekable range ${Vc(e)}. Seeking to ${s}.`),this.tech_.setCurrentTime(s),!0;const r=this.playlistController_.sourceUpdater_,a=this.tech_.buffered(),l=r.audioBuffer?r.audioBuffered():null,c=r.videoBuffer?r.videoBuffered():null,f=this.media(),m=f.partTargetDuration?f.partTargetDuration:(f.targetDuration-Xt)*2,b=[l,c];for(let w=0;w<b.length;w++)if(b[w]&&ll(b[w],t)<m)return!1;const C=er(a,t);return C.length===0?!1:(s=C.start(0)+Kt,this.logger_(`Buffered region starts (${C.start(0)}) just beyond seek point (${t}). Seeking to ${s}.`),this.tech_.setCurrentTime(s),!0)}waiting_(){if(this.techWaiting_())return;const e=this.tech_.currentTime(),t=this.tech_.buffered(),n=tn(t,e);if(n.length&&e+3<=n.end(0)){this.resetTimeUpdate_(),this.tech_.setCurrentTime(e),this.logger_(`Stopped at ${e} while inside a buffered region [${n.start(0)} -> ${n.end(0)}]. Attempting to resume playback by seeking to the current time.`),this.tech_.trigger({type:"usage",name:"vhs-unknown-waiting"});return}}techWaiting_(){const e=this.seekable(),t=this.tech_.currentTime();if(this.tech_.seeking())return!0;if(this.beforeSeekableWindow_(e,t)){const a=e.end(e.length-1);return this.logger_(`Fell out of live window at time ${t}. Seeking to live point (seekable end) ${a}`),this.resetTimeUpdate_(),this.tech_.setCurrentTime(a),this.tech_.trigger({type:"usage",name:"vhs-live-resync"}),!0}const n=this.tech_.vhs.playlistController_.sourceUpdater_,s=this.tech_.buffered();if(this.videoUnderflow_({audioBuffered:n.audioBuffered(),videoBuffered:n.videoBuffered(),currentTime:t}))return this.resetTimeUpdate_(),this.tech_.setCurrentTime(t),this.tech_.trigger({type:"usage",name:"vhs-video-underflow"}),!0;const r=er(s,t);return r.length>0?(this.logger_(`Stopped at ${t} and seeking to ${r.start(0)}`),this.resetTimeUpdate_(),this.skipTheGap_(t),!0):!1}afterSeekableWindow_(e,t,n,s=!1){if(!e.length)return!1;let r=e.end(e.length-1)+Kt;const a=!n.endList,l=typeof n.partTargetDuration=="number";return a&&(l||s)&&(r=e.end(e.length-1)+n.targetDuration*3),t>r}beforeSeekableWindow_(e,t){return!!(e.length&&e.start(0)>0&&t<e.start(0)-this.liveRangeSafeTimeDelta)}videoUnderflow_({videoBuffered:e,audioBuffered:t,currentTime:n}){if(!e)return;let s;if(e.length&&t.length){const r=tn(e,n-3),a=tn(e,n),l=tn(t,n);l.length&&!a.length&&r.length&&(s={start:r.end(0),end:l.end(0)})}else er(e,n).length||(s=this.gapFromVideoUnderflow_(e,n));return s?(this.logger_(`Encountered a gap in video from ${s.start} to ${s.end}. Seeking to current time ${n}`),!0):!1}skipTheGap_(e){const t=this.tech_.buffered(),n=this.tech_.currentTime(),s=er(t,n);if(this.resetTimeUpdate_(),s.length===0||n!==e)return;this.logger_("skipTheGap_:","currentTime:",n,"scheduled currentTime:",e,"nextRange start:",s.start(0)),this.tech_.setCurrentTime(s.start(0)+Xt);const r={gapInfo:{from:n,to:s.start(0)}};this.playlistController_.trigger({type:"gapjumped",metadata:r}),this.tech_.trigger({type:"usage",name:"vhs-gap-skip"})}gapFromVideoUnderflow_(e,t){const n=Gb(e);for(let s=0;s<n.length;s++){const r=n.start(s),a=n.end(s);if(t-r<4&&t-r>2)return{start:r,end:a}}return null}}const pS={errorInterval:30,getSource(i){const e=this.tech({IWillNotUseThisInPlugins:!0}).currentSource_||this.currentSource();return i(e)}},Op=function(i,e){let t=0,n=0;const s=fe(pS,e);i.ready(()=>{i.trigger({type:"usage",name:"vhs-error-reload-initialized"})});const r=function(){n&&i.currentTime(n)},a=function(m){m!=null&&(n=i.duration()!==1/0&&i.currentTime()||0,i.one("loadedmetadata",r),i.src(m),i.trigger({type:"usage",name:"vhs-error-reload"}),i.play())},l=function(){if(Date.now()-t<s.errorInterval*1e3){i.trigger({type:"usage",name:"vhs-error-reload-canceled"});return}if(!s.getSource||typeof s.getSource!="function"){B.log.error("ERROR: reloadSourceOnError - The option getSource must be a function!");return}return t=Date.now(),s.getSource.call(i,a)},c=function(){i.off("loadedmetadata",r),i.off("error",l),i.off("dispose",c)},f=function(m){c(),Op(i,m)};i.on("error",l),i.on("dispose",c),i.reloadSourceOnError=f},gS=function(i){Op(this,i)};var Mp="3.16.2",fS="7.1.0",mS="1.3.1",yS="7.2.0",_S="4.0.2";const Oe={PlaylistLoader:nn,Playlist:gt,utils:TT,STANDARD_PLAYLIST_SELECTOR:fd,INITIAL_PLAYLIST_SELECTOR:dv,lastBandwidthSelector:fd,movingAverageBandwidthSelector:lv,comparePlaylistBandwidth:pl,comparePlaylistResolution:ov,xhr:ap()};Object.keys(We).forEach(i=>{Object.defineProperty(Oe,i,{get(){return B.log.warn(`using Vhs.${i} is UNSAFE be sure you know what you are doing`),We[i]},set(e){if(B.log.warn(`using Vhs.${i} is UNSAFE be sure you know what you are doing`),typeof e!="number"||e<0){B.log.warn(`value of Vhs.${i} must be greater than or equal to 0`);return}We[i]=e}})});const Rp="videojs-vhs",Up=function(i,e){const t=e.media();let n=-1;for(let s=0;s<i.length;s++)if(i[s].id===t.id){n=s;break}i.selectedIndex_=n,i.trigger({selectedIndex:n,type:"change"})},bS=function(i,e){e.representations().forEach(t=>{i.addQualityLevel(t)}),Up(i,e.playlists)};Oe.canPlaySource=function(){return B.log.warn("VHS is no longer a tech. Please remove it from your player's techOrder.")};const TS=(i,e,t)=>{if(!i)return i;let n={};e&&e.attributes&&e.attributes.CODECS&&(n=Ir(Ht(e.attributes.CODECS))),t&&t.attributes&&t.attributes.CODECS&&(n.audio=t.attributes.CODECS);const s=cn(n.video),r=cn(n.audio),a={};for(const l in i)a[l]={},r&&(a[l].audioContentType=r),s&&(a[l].videoContentType=s),e.contentProtection&&e.contentProtection[l]&&e.contentProtection[l].pssh&&(a[l].pssh=e.contentProtection[l].pssh),typeof i[l]=="string"&&(a[l].url=i[l]);return fe(i,a)},vS=(i,e)=>i.reduce((t,n)=>{if(!n.contentProtection)return t;const s=e.reduce((r,a)=>{const l=n.contentProtection[a];return l&&l.pssh&&(r[a]={pssh:l.pssh}),r},{});return Object.keys(s).length&&t.push(s),t},[]),SS=({player:i,sourceKeySystems:e,audioMedia:t,mainPlaylists:n})=>{if(!i.eme.initializeMediaKeys)return Promise.resolve();const s=t?n.concat([t]):n,r=vS(s,Object.keys(e)),a=[],l=[];return r.forEach(c=>{l.push(new Promise((f,m)=>{i.tech_.one("keysessioncreated",f)})),a.push(new Promise((f,m)=>{i.eme.initializeMediaKeys({keySystems:c},b=>{if(b){m(b);return}f()})}))}),Promise.race([Promise.all(a),Promise.race(l)])},ES=({player:i,sourceKeySystems:e,media:t,audioMedia:n})=>{const s=TS(e,t,n);return s?(i.currentSource().keySystems=s,s&&!i.eme?(B.log.warn("DRM encrypted source cannot be decrypted without a DRM plugin"),!1):!0):!1},Np=()=>{if(!x.localStorage)return null;const i=x.localStorage.getItem(Rp);if(!i)return null;try{return JSON.parse(i)}catch{return null}},wS=i=>{if(!x.localStorage)return!1;let e=Np();e=e?fe(e,i):i;try{x.localStorage.setItem(Rp,JSON.stringify(e))}catch{return!1}return e},kS=i=>i.toLowerCase().indexOf("data:application/vnd.videojs.vhs+json,")===0?JSON.parse(i.substring(i.indexOf(",")+1)):i,Bp=(i,e)=>{i._requestCallbackSet||(i._requestCallbackSet=new Set),i._requestCallbackSet.add(e)},Fp=(i,e)=>{i._responseCallbackSet||(i._responseCallbackSet=new Set),i._responseCallbackSet.add(e)},jp=(i,e)=>{i._requestCallbackSet&&(i._requestCallbackSet.delete(e),i._requestCallbackSet.size||delete i._requestCallbackSet)},$p=(i,e)=>{i._responseCallbackSet&&(i._responseCallbackSet.delete(e),i._responseCallbackSet.size||delete i._responseCallbackSet)};Oe.supportsNativeHls=function(){if(!G||!G.createElement)return!1;const i=G.createElement("video");return B.getTech("Html5").isSupported()?["application/vnd.apple.mpegurl","audio/mpegurl","audio/x-mpegurl","application/x-mpegurl","video/x-mpegurl","video/mpegurl","application/mpegurl"].some(function(e){return/maybe|probably/i.test(i.canPlayType(e))}):!1}();Oe.supportsNativeDash=function(){return!G||!G.createElement||!B.getTech("Html5").isSupported()?!1:/maybe|probably/i.test(G.createElement("video").canPlayType("application/dash+xml"))}();Oe.supportsTypeNatively=i=>i==="hls"?Oe.supportsNativeHls:i==="dash"?Oe.supportsNativeDash:!1;Oe.isSupported=function(){return B.log.warn("VHS is no longer a tech. Please remove it from your player's techOrder.")};Oe.xhr.onRequest=function(i){Bp(Oe.xhr,i)};Oe.xhr.onResponse=function(i){Fp(Oe.xhr,i)};Oe.xhr.offRequest=function(i){jp(Oe.xhr,i)};Oe.xhr.offResponse=function(i){$p(Oe.xhr,i)};const CS=B.getComponent("Component");class qp extends CS{constructor(e,t,n){if(super(t,n.vhs),typeof n.initialBandwidth=="number"&&(this.options_.bandwidth=n.initialBandwidth),this.logger_=Lt("VhsHandler"),t.options_&&t.options_.playerId){const s=B.getPlayer(t.options_.playerId);this.player_=s}if(this.tech_=t,this.source_=e,this.stats={},this.ignoreNextSeekingEvent_=!1,this.setOptions_(),this.options_.overrideNative&&t.overrideNativeAudioTracks&&t.overrideNativeVideoTracks)t.overrideNativeAudioTracks(!0),t.overrideNativeVideoTracks(!0);else if(this.options_.overrideNative&&(t.featuresNativeVideoTracks||t.featuresNativeAudioTracks))throw new Error("Overriding native VHS requires emulated tracks. See https://git.io/vMpjB");this.on(G,["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"],s=>{const r=G.fullscreenElement||G.webkitFullscreenElement||G.mozFullScreenElement||G.msFullscreenElement;r&&r.contains(this.tech_.el())?this.playlistController_.fastQualityChange_():this.playlistController_.checkABR_()}),this.on(this.tech_,"seeking",function(){if(this.ignoreNextSeekingEvent_){this.ignoreNextSeekingEvent_=!1;return}this.setCurrentTime(this.tech_.currentTime())}),this.on(this.tech_,"error",function(){this.tech_.error()&&this.playlistController_&&this.playlistController_.pauseLoading()}),this.on(this.tech_,"play",this.play)}setOptions_(e={}){if(this.options_=fe(this.options_,e),this.options_.withCredentials=this.options_.withCredentials||!1,this.options_.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions!==!1,this.options_.useDevicePixelRatio=this.options_.useDevicePixelRatio||!1,this.options_.useBandwidthFromLocalStorage=typeof this.source_.useBandwidthFromLocalStorage<"u"?this.source_.useBandwidthFromLocalStorage:this.options_.useBandwidthFromLocalStorage||!1,this.options_.useForcedSubtitles=this.options_.useForcedSubtitles||!1,this.options_.useNetworkInformationApi=this.options_.useNetworkInformationApi||!1,this.options_.useDtsForTimestampOffset=this.options_.useDtsForTimestampOffset||!1,this.options_.customTagParsers=this.options_.customTagParsers||[],this.options_.customTagMappers=this.options_.customTagMappers||[],this.options_.cacheEncryptionKeys=this.options_.cacheEncryptionKeys||!1,this.options_.llhls=this.options_.llhls!==!1,this.options_.bufferBasedABR=this.options_.bufferBasedABR||!1,typeof this.options_.playlistExclusionDuration!="number"&&(this.options_.playlistExclusionDuration=60),typeof this.options_.bandwidth!="number"&&this.options_.useBandwidthFromLocalStorage){const n=Np();n&&n.bandwidth&&(this.options_.bandwidth=n.bandwidth,this.tech_.trigger({type:"usage",name:"vhs-bandwidth-from-local-storage"})),n&&n.throughput&&(this.options_.throughput=n.throughput,this.tech_.trigger({type:"usage",name:"vhs-throughput-from-local-storage"}))}typeof this.options_.bandwidth!="number"&&(this.options_.bandwidth=We.INITIAL_BANDWIDTH),this.options_.enableLowInitialPlaylist=this.options_.enableLowInitialPlaylist&&this.options_.bandwidth===We.INITIAL_BANDWIDTH,["withCredentials","useDevicePixelRatio","customPixelRatio","limitRenditionByPlayerDimensions","bandwidth","customTagParsers","customTagMappers","cacheEncryptionKeys","playlistSelector","initialPlaylistSelector","bufferBasedABR","liveRangeSafeTimeDelta","llhls","useForcedSubtitles","useNetworkInformationApi","useDtsForTimestampOffset","exactManifestTimings","leastPixelDiffSelector"].forEach(n=>{typeof this.source_[n]<"u"&&(this.options_[n]=this.source_[n])}),this.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions,this.useDevicePixelRatio=this.options_.useDevicePixelRatio;const t=this.options_.customPixelRatio;typeof t=="number"&&t>=0&&(this.customPixelRatio=t)}setOptions(e={}){this.setOptions_(e)}src(e,t){if(!e)return;this.setOptions_(),this.options_.src=kS(this.source_.src),this.options_.tech=this.tech_,this.options_.externVhs=Oe,this.options_.sourceType=lh(t),this.options_.seekTo=r=>{this.tech_.setCurrentTime(r)},this.options_.player_=this.player_,this.playlistController_=new lS(this.options_);const n=fe({liveRangeSafeTimeDelta:Kt},this.options_,{seekable:()=>this.seekable(),media:()=>this.playlistController_.media(),playlistController:this.playlistController_});this.playbackWatcher_=new cS(n),this.attachStreamingEventListeners_(),this.playlistController_.on("error",()=>{const r=B.players[this.tech_.options_.playerId];let a=this.playlistController_.error;typeof a=="object"&&!a.code?a.code=3:typeof a=="string"&&(a={message:a,code:3}),r.error(a)});const s=this.options_.bufferBasedABR?Oe.movingAverageBandwidthSelector(.55):Oe.STANDARD_PLAYLIST_SELECTOR;this.playlistController_.selectPlaylist=this.selectPlaylist?this.selectPlaylist.bind(this):s.bind(this),this.playlistController_.selectInitialPlaylist=Oe.INITIAL_PLAYLIST_SELECTOR.bind(this),this.playlists=this.playlistController_.mainPlaylistLoader_,this.mediaSource=this.playlistController_.mediaSource,Object.defineProperties(this,{selectPlaylist:{get(){return this.playlistController_.selectPlaylist},set(r){this.playlistController_.selectPlaylist=r.bind(this)}},throughput:{get(){return this.playlistController_.mainSegmentLoader_.throughput.rate},set(r){this.playlistController_.mainSegmentLoader_.throughput.rate=r,this.playlistController_.mainSegmentLoader_.throughput.count=1}},bandwidth:{get(){let r=this.playlistController_.mainSegmentLoader_.bandwidth;const a=x.navigator.connection||x.navigator.mozConnection||x.navigator.webkitConnection,l=1e7;if(this.options_.useNetworkInformationApi&&a){const c=a.downlink*1e3*1e3;c>=l&&r>=l?r=Math.max(r,c):r=c}return r},set(r){this.playlistController_.mainSegmentLoader_.bandwidth=r,this.playlistController_.mainSegmentLoader_.throughput={rate:0,count:0}}},systemBandwidth:{get(){const r=1/(this.bandwidth||1);let a;return this.throughput>0?a=1/this.throughput:a=0,Math.floor(1/(r+a))},set(){B.log.error('The "systemBandwidth" property is read-only')}}}),this.options_.bandwidth&&(this.bandwidth=this.options_.bandwidth),this.options_.throughput&&(this.throughput=this.options_.throughput),Object.defineProperties(this.stats,{bandwidth:{get:()=>this.bandwidth||0,enumerable:!0},mediaRequests:{get:()=>this.playlistController_.mediaRequests_()||0,enumerable:!0},mediaRequestsAborted:{get:()=>this.playlistController_.mediaRequestsAborted_()||0,enumerable:!0},mediaRequestsTimedout:{get:()=>this.playlistController_.mediaRequestsTimedout_()||0,enumerable:!0},mediaRequestsErrored:{get:()=>this.playlistController_.mediaRequestsErrored_()||0,enumerable:!0},mediaTransferDuration:{get:()=>this.playlistController_.mediaTransferDuration_()||0,enumerable:!0},mediaBytesTransferred:{get:()=>this.playlistController_.mediaBytesTransferred_()||0,enumerable:!0},mediaSecondsLoaded:{get:()=>this.playlistController_.mediaSecondsLoaded_()||0,enumerable:!0},mediaAppends:{get:()=>this.playlistController_.mediaAppends_()||0,enumerable:!0},mainAppendsToLoadedData:{get:()=>this.playlistController_.mainAppendsToLoadedData_()||0,enumerable:!0},audioAppendsToLoadedData:{get:()=>this.playlistController_.audioAppendsToLoadedData_()||0,enumerable:!0},appendsToLoadedData:{get:()=>this.playlistController_.appendsToLoadedData_()||0,enumerable:!0},timeToLoadedData:{get:()=>this.playlistController_.timeToLoadedData_()||0,enumerable:!0},buffered:{get:()=>Ui(this.tech_.buffered()),enumerable:!0},currentTime:{get:()=>this.tech_.currentTime(),enumerable:!0},currentSource:{get:()=>this.tech_.currentSource_,enumerable:!0},currentTech:{get:()=>this.tech_.name_,enumerable:!0},duration:{get:()=>this.tech_.duration(),enumerable:!0},main:{get:()=>this.playlists.main,enumerable:!0},playerDimensions:{get:()=>this.tech_.currentDimensions(),enumerable:!0},seekable:{get:()=>Ui(this.tech_.seekable()),enumerable:!0},timestamp:{get:()=>Date.now(),enumerable:!0},videoPlaybackQuality:{get:()=>this.tech_.getVideoPlaybackQuality(),enumerable:!0}}),this.tech_.one("canplay",this.playlistController_.setupFirstPlay.bind(this.playlistController_)),this.tech_.on("bandwidthupdate",()=>{this.options_.useBandwidthFromLocalStorage&&wS({bandwidth:this.bandwidth,throughput:Math.round(this.throughput)})}),this.playlistController_.on("selectedinitialmedia",()=>{hS(this)}),this.playlistController_.sourceUpdater_.on("createdsourcebuffers",()=>{this.setupEme_()}),this.on(this.playlistController_,"progress",function(){this.tech_.trigger("progress")}),this.on(this.playlistController_,"firstplay",function(){this.ignoreNextSeekingEvent_=!0}),this.setupQualityLevels_(),this.tech_.el()&&(this.mediaSourceUrl_=x.URL.createObjectURL(this.playlistController_.mediaSource),(B.browser.IS_ANY_SAFARI||B.browser.IS_IOS)&&this.options_.overrideNative&&this.options_.sourceType==="hls"&&typeof this.tech_.addSourceElement=="function"?(this.tech_.addSourceElement(this.mediaSourceUrl_),this.tech_.addSourceElement(this.source_.src)):this.tech_.src(this.mediaSourceUrl_))}createKeySessions_(){const e=this.playlistController_.mediaTypes_.AUDIO.activePlaylistLoader;this.logger_("waiting for EME key session creation"),SS({player:this.player_,sourceKeySystems:this.source_.keySystems,audioMedia:e&&e.media(),mainPlaylists:this.playlists.main.playlists}).then(()=>{this.logger_("created EME key session"),this.playlistController_.sourceUpdater_.initializedEme()}).catch(t=>{this.logger_("error while creating EME key session",t),this.player_.error({message:"Failed to initialize media keys for EME",code:3})})}handleWaitingForKey_(){this.logger_("waitingforkey fired, attempting to create any new key sessions"),this.createKeySessions_()}setupEme_(){const e=this.playlistController_.mediaTypes_.AUDIO.activePlaylistLoader,t=ES({player:this.player_,sourceKeySystems:this.source_.keySystems,media:this.playlists.media(),audioMedia:e&&e.media()});if(this.player_.tech_.on("keystatuschange",n=>{this.playlistController_.updatePlaylistByKeyStatus(n.keyId,n.status)}),this.handleWaitingForKey_=this.handleWaitingForKey_.bind(this),this.player_.tech_.on("waitingforkey",this.handleWaitingForKey_),!t){this.playlistController_.sourceUpdater_.initializedEme();return}this.createKeySessions_()}setupQualityLevels_(){const e=B.players[this.tech_.options_.playerId];!e||!e.qualityLevels||this.qualityLevels_||(this.qualityLevels_=e.qualityLevels(),this.playlistController_.on("selectedinitialmedia",()=>{bS(this.qualityLevels_,this)}),this.playlists.on("mediachange",()=>{Up(this.qualityLevels_,this.playlists)}))}static version(){return{"@videojs/http-streaming":Mp,"mux.js":fS,"mpd-parser":mS,"m3u8-parser":yS,"aes-decrypter":_S}}version(){return this.constructor.version()}canChangeType(){return Ap.canChangeType()}play(){this.playlistController_.play()}setCurrentTime(e){this.playlistController_.setCurrentTime(e)}duration(){return this.playlistController_.duration()}seekable(){return this.playlistController_.seekable()}dispose(){this.playbackWatcher_&&this.playbackWatcher_.dispose(),this.playlistController_&&this.playlistController_.dispose(),this.qualityLevels_&&this.qualityLevels_.dispose(),this.tech_&&this.tech_.vhs&&delete this.tech_.vhs,this.mediaSourceUrl_&&x.URL.revokeObjectURL&&(x.URL.revokeObjectURL(this.mediaSourceUrl_),this.mediaSourceUrl_=null),this.tech_&&this.tech_.off("waitingforkey",this.handleWaitingForKey_),super.dispose()}convertToProgramTime(e,t){return IT({playlist:this.playlistController_.media(),time:e,callback:t})}seekToProgramTime(e,t,n=!0,s=2){return hp({programTime:e,playlist:this.playlistController_.media(),retryCount:s,pauseAfterSeek:n,seekTo:this.options_.seekTo,tech:this.options_.tech,callback:t})}setupXhrHooks_(){this.xhr.onRequest=e=>{Bp(this.xhr,e)},this.xhr.onResponse=e=>{Fp(this.xhr,e)},this.xhr.offRequest=e=>{jp(this.xhr,e)},this.xhr.offResponse=e=>{$p(this.xhr,e)},this.player_.trigger("xhr-hooks-ready")}attachStreamingEventListeners_(){const e=["seekablerangeschanged","bufferedrangeschanged","contentsteeringloadstart","contentsteeringloadcomplete","contentsteeringparsed"],t=["gapjumped","playedrangeschanged"];e.forEach(n=>{this.playlistController_.on(n,s=>{this.player_.trigger(je({},s))})}),t.forEach(n=>{this.playbackWatcher_.on(n,s=>{this.player_.trigger(je({},s))})})}}const Pr={name:"videojs-http-streaming",VERSION:Mp,canHandleSource(i,e={}){const t=fe(B.options,e);return!t.vhs.experimentalUseMMS&&!as("avc1.4d400d,mp4a.40.2",!1)?!1:Pr.canPlayType(i.type,t)},handleSource(i,e,t={}){const n=fe(B.options,t);return e.vhs=new qp(i,e,n),e.vhs.xhr=ap(),e.vhs.setupXhrHooks_(),e.vhs.src(i.src,i.type),e.vhs},canPlayType(i,e){const t=lh(i);if(!t)return"";const n=Pr.getOverrideNative(e);return!Oe.supportsTypeNatively(t)||n?"maybe":""},getOverrideNative(i={}){const{vhs:e={}}=i,t=!(B.browser.IS_ANY_SAFARI||B.browser.IS_IOS),{overrideNative:n=t}=e;return n}},IS=()=>as("avc1.4d400d,mp4a.40.2",!0);IS()&&B.getTech("Html5").registerSourceHandler(Pr,0);B.VhsHandler=qp;B.VhsSourceHandler=Pr;B.Vhs=Oe;B.use||B.registerComponent("Vhs",Oe);B.options.vhs=B.options.vhs||{};(!B.getPlugin||!B.getPlugin("reloadSourceOnError"))&&B.registerPlugin("reloadSourceOnError",gS);const xS=i=>{const e=_e.useRef();return _e.useEffect(()=>{if(!e.current&&i.current){const t=document.createElement("video-js");t.classList.add("vjs-big-play-centered"),i.current.appendChild(t),e.current=B(t,{controls:!1,playsinline:!0})}return()=>{e.current&&(e.current.dispose(),e.current=void 0)}},[]),e},Vp={time:0,adCount:0,adPosition:0,skipDelay:0,playing:!1,paused:!1,reset:()=>{},whyThisAd:null,hasAdUrl:!1,adAction:i=>{},playMuted:!1,muted:!1,autoplay:!0},xe=W.i(Vp),xd=i=>{if(!i)return 0;const e=i.duration(),t=i.currentTime();return e===void 0||isNaN(e)||t===void 0||isNaN(t)?0:Math.round(e-t)},AS=(i,e)=>{const t=Dy(i,e),n=xS(i),s=_e.useRef(),r=_e.useRef(!1),a=_e.useRef(!1),l=_e.useCallback(()=>{if(a.current)return;const w=t.get().nonceManager;if(w&&r.current)try{w.sendPlaybackEnd()}catch(A){console.warn("[PAL] sendPlaybackEnd failed",A)}a.current=!0},[t]),c=_e.useCallback(()=>{l(),n.current&&(n.current.pause(),n.current.src(void 0)),s.current=void 0,xe.set({...Vp,reset:c})},[n,l]);_e.useEffect(()=>{xe.setKey("reset",c)},[c]);const f=_e.useCallback(()=>{var w,A,v;const{adPosition:M,adCount:D}=xe.get();if(n.current){if(M<D){const R=M+1,{ads:N,muted:F,autoplay:P,nonceManager:$}=t.get(),Y=N[R-1];if(Y){(w=s.current)==null||w.complete(),s.current=new Dd.ue(null,Y.ad,Y.creative),s.current.on("clickthrough",X=>{if($)try{$.sendAdClick()}catch(re){console.warn("[PAL] sendAdClick failed",re)}window.open(X,"_blank")}),xe.setKey("adPosition",R),xe.setKey("playMuted",F),xe.setKey("skipDelay",Y.creative.skipDelay||0),xe.setKey("time",0),xe.setKey("adAction",X=>{s.current&&s.current.click(null,{CLICKPOS:[X.clientX,X.clientY]})}),xe.setKey("whyThisAd",Y.creative.icons.find(X=>X.program==="GoogleWhyThisAd")||null),xe.setKey("hasAdUrl",!!((A=Y.creative.videoClickThroughURLTemplate)!=null&&A.url)),n.current.src(Y.mediaFileUrl),xe.setKey("playing",!0),M===0?(xe.setKey("muted",F),xe.setKey("autoplay",P),F&&n.current.muted(!0),P?n.current.play():(n.current.pause(),xe.setKey("paused",!0))):n.current.play();return}}(v=s.current)==null||v.complete(),c()}},[n,c,t]),m=_e.useCallback(()=>{if(!n.current)return;const w=n.current.muted();n.current.muted(!w),xe.setKey("muted",!w),s.current&&s.current.setMuted(!w)},[n]),b=_e.useCallback(()=>{n.current&&(n.current.paused()?(n.current.play(),s.current&&s.current.setPaused(!1)):(n.current.pause(),s.current&&s.current.setPaused(!0)))},[n]),C=_e.useCallback(()=>{n.current&&(s.current&&s.current.skip(),f())},[f,n]);return _e.useEffect(()=>{const w=n.current;if(!w)return()=>{};const A=P=>{if(xe.setKey("playing",!0),xe.setKey("paused",!1),xe.setKey("time",xd(P.target.player)),!r.current){const $=t.get().nonceManager;if($)try{$.sendPlaybackStart(),r.current=!0,a.current=!1}catch(Y){console.warn("[PAL] sendPlaybackStart failed",Y)}}},v=()=>{var P;(P=s.current)==null||P.complete(),f()},M=P=>{xe.setKey("muted",P.target.player.muted())},D=()=>{xe.setKey("paused",!0)},R=P=>{P.target.tagName==="VIDEO"&&(xe.get().autoplay||b())},N=P=>{xe.setKey("time",xd(P.target.player)),s.current&&s.current.setProgress(P.target.player.currentTime())},F=()=>{c()};return w.on("play",A),w.on("ended",v),w.on("muted",M),w.on("pause",D),w.on("click",R),w.on("timeupdate",N),w.on("error",F),()=>{w.off("play",A),w.off("ended",v),w.off("muted",M),w.off("pause",D),w.off("click",R),w.off("timeupdate",N),w.off("error",F)}},[b,f,n,c,t]),_e.useEffect(()=>t.subscribe(w=>{w&&(r.current=!1,a.current=!1,xe.setKey("adCount",w.ads.length),xe.setKey("adPosition",0),f())}),[t,n,f]),_e.useEffect(()=>()=>{c()},[c]),[xe,m,b,C,s]},PS=({promotion:i,onClose:e,promotionId:t,externalAd:n,skipAutoClose:s})=>{var r,a,l,c,f;const m=_e.useRef(null),[b,C,w,A]=AS(m,n==null?void 0:n.url),{time:v,adCount:M,adPosition:D,skipDelay:R,playing:N,paused:F,reset:P,muted:$,playMuted:Y,autoplay:X,whyThisAd:re,hasAdUrl:ce,adAction:be}=W.useStore(b),he=((r=i.sponsor)==null?void 0:r.logo)&&i.logoMode===ue.PromotionLogoMode.CENTER;return z.jsxs(Bd,{className:"PromoOverlay",children:[z.jsxs(Fd,{children:[z.jsx(jd,{className:W.cx_default(!he&&$d),children:z.jsx(Vd,{style:{transform:"scale(1.5)"},children:"Ad"})}),z.jsxs(Ey,{children:[z.jsx(gy,{time:v,adCount:M,adPosition:D}),!!R&&N&&z.jsx(W.y,{timerClassName:"SkipTimerCount",className:"ClosePromoIcon",close:()=>{A()},duration:R,isPlaying:!F,skipIcon:!0}),s&&z.jsx(W.y,{className:"ClosePromoIcon",close:()=>{P(),e==null||e()}})]})]}),z.jsx(qd,{className:W.cx_default(ou,N&&lu,!N&&uu),children:z.jsxs(Sy,{ref:m,children:[re&&z.jsx(my,{whyThisAd:re}),z.jsxs(yy,{style:(re==null?void 0:re.xPosition)==="right"?{left:"8px"}:{right:"8px"},children:[Y&&z.jsx(by,{className:W.cx_default(!$&&"muted"),onClick:()=>C()}),F&&!X&&z.jsx(vy,{onClick:()=>w()})]})]})}),ce&&z.jsx(Hd,{className:W.cx_default(ou,N&&lu,!N&&uu),children:z.jsx(zd,{as:"button",onClick:be,style:{backgroundColor:((l=(a=i.banner)==null?void 0:a.ctaButton)==null?void 0:l.color)||"#009dc4",color:((f=(c=i.banner)==null?void 0:c.ctaButton)==null?void 0:f.textColor)||"#fff"},"data-a":"button","data-promo-id":t,"data-promo-type":i.type,target:"_blank",children:"Show more"})})]})},Ad=i=>{var e,t,n,s,r,a,l,c,f,m,b,C,w,A,v,M,D,R,N,F,P,$,Y,X,re,ce,be,he,Z,de;const{promotion:ee,open:Xe,advertisementPaused:Ye,togglePause:$e,controlVideo:He,skipAutoClose:me,promotionId:ge,onClose:mt,markAsViewed:Et,externalAd:we,isEventFired:le,fireEvent:Re,muted:Hi}=i,oi=ee.type===ue.PromotionType.INGAME_IAB11_LBAR||ee.type===ue.PromotionType.INGAME_IAB11||ee.type===ue.PromotionType.INGAME_IAB11_SIDEBAR,li=((e=ee.sponsor)==null?void 0:e.logo)&&ee.logoMode===ue.PromotionLogoMode.CENTER,Ei=!!((n=(t=ee.banner)==null?void 0:t.video)!=null&&n.url),yt=ee.autoPlayVideo===ue.AutoPlayVideo.ENABLED,ui=ee.playVideoMuted===ue.PlayVideoMuted.ENABLED;if(_e.useEffect(()=>{$e==null||$e(Ei||yt),Xe==null||Xe()},[]),_e.useEffect(()=>{ge&&ee.type&&Et&&Et()},[ge,ee.type,Et]),_e.useEffect(()=>()=>{He==null||He({muted:!1})},[He]),we)return z.jsx(PS,{...i,externalAd:we});let Ft=(s=ee.banner)==null?void 0:s.url;Ft&&Ft.indexOf("http")!==0&&(Ft=`https://${Ft}`);let wi=!0;return Ei&&(!Ye||!yt?wi=!0:wi=!1),z.jsxs(Bd,{className:"PromoOverlay",children:[z.jsxs("div",{children:[z.jsxs(Fd,{children:[z.jsxs(jd,{className:W.cx_default(!li&&$d),children:[((r=ee.sponsor)==null?void 0:r.logo)&&ee.logoMode===ue.PromotionLogoMode.LEFT&&z.jsx(su,{className:"PromoSponsorLogo",src:(a=ee.sponsor)==null?void 0:a.logo,alt:"promo"}),z.jsxs(oy,{style:{paddingLeft:(l=ee.sponsor)!=null&&l.logo&&ee.logoMode===ue.PromotionLogoMode.LEFT?"0px":"8px"},children:[((c=ee.sponsor)==null?void 0:c.logo)&&ee.logoMode===ue.PromotionLogoMode.LEFT&&z.jsx(ny,{children:(f=ee.sponsor)==null?void 0:f.name}),z.jsxs(ly,{className:"SponsorText",children:[z.jsx(Vd,{children:"AD"}),z.jsx(uy,{children:"SPONSORED"})]})]})]}),z.jsx(W.y,{className:"ClosePromoIcon",close:mt,autoClose:(m=ee.closeTimer)==null?void 0:m.auto,duration:me?0:(b=ee.closeTimer)==null?void 0:b.seconds,isPlaying:wi})]}),z.jsxs(qd,{children:[li&&z.jsx(su,{className:ry,src:(C=ee.sponsor)==null?void 0:C.logo,alt:"promo"}),z.jsx(ru,{children:(A=(w=ee.banner)==null?void 0:w.video)!=null&&A.url?z.jsx(W.Et,{source:(M=(v=ee.banner)==null?void 0:v.video)==null?void 0:M.url,poster:(R=(D=ee.banner)==null?void 0:D.video)==null?void 0:R.thumbnailUrl,aspectRatio:oi?"1/1":"2/1",onRender:()=>{le!=null&&le("video-rendered")||(W.eventBus.emit("advertisement",{action:"videoRendered",payload:{id:ge,type:ee.type}}),Re==null||Re("video-rendered"))},onQuartile:Dt=>{le!=null&&le(`video-quartile-${Dt}`)||(W.eventBus.emit("advertisement",{action:"quartileCompleted",payload:{id:ge,type:ee.type,quartile:Dt}}),Re==null||Re(`video-quartile-${Dt}`))},onMute:Dt=>{const Ot=Dt?"muted":"unmuted";le!=null&&le(Ot)||(W.eventBus.emit("advertisement",{action:Dt?"videoMuted":"videoUnmuted",payload:{id:ge,type:ee.type}}),Re==null||Re(Ot))},onPause:()=>{yt&&($e==null||$e(!0))},onReplay:()=>{le!=null&&le("replayed")||(W.eventBus.emit("advertisement",{action:"videoReplayed",payload:{id:ge,type:ee.type}}),Re==null||Re("replayed"))},onPlay:()=>{le!=null&&le("played")||(W.eventBus.emit("advertisement",{action:"videoPlay",payload:{id:ge,type:ee.type}}),Re==null||Re("played")),$e==null||$e(!1),le!=null&&le("played")&&le!=null&&le("ended")&&!(le!=null&&le("replayed"))&&(W.eventBus.emit("advertisement",{action:"videoReplayed",payload:{id:ge,type:ee.type}}),Re==null||Re("replayed"))},onEnd:()=>{le!=null&&le("ended")||(W.eventBus.emit("advertisement",{action:"videoEnd",payload:{id:ge,type:ee.type}}),Re==null||Re("ended"))},controlVideo:He,autoPlay:yt,playMuted:ui,muted:Hi}):(N=ee.banner)!=null&&N.imageUrl?z.jsx(sy,{style:oi?{aspectRatio:"1/1"}:{},src:(F=ee.banner)==null?void 0:F.imageUrl,alt:"promo"}):null}),!oi&&z.jsxs(ru,{children:[((P=ee.banner)==null?void 0:P.title)&&z.jsx(dy,{className:W.cx_default("AdvTitle",li&&hy),children:($=ee.banner)==null?void 0:$.title}),((Y=ee.banner)==null?void 0:Y.body)&&z.jsx(ay,{className:"AdvDescription",children:(X=ee.banner)==null?void 0:X.body})]})]})]}),ee.buttonType===ue.PromotionButtonType.BASIC&&z.jsx(Hd,{children:z.jsx(zd,{href:Ft,style:{backgroundColor:((ce=(re=ee.banner)==null?void 0:re.ctaButton)==null?void 0:ce.color)||"#009dc4",color:((he=(be=ee.banner)==null?void 0:be.ctaButton)==null?void 0:he.textColor)||"#fff"},"data-a":"button","data-promo-id":ge,"data-promo-type":ee.type,target:"_blank",children:(de=(Z=ee.banner)==null?void 0:Z.ctaButton)==null?void 0:de.label})})]})},LS=W.styled_default("div")({name:"SidebarContainer",class:"s1abskp8",propsAsIs:!1}),DS=({children:i,direction:e,style:t,className:n,hiding:s})=>z.jsx(bo,{direction:e,style:t,hiding:s,className:n,children:z.jsx(LS,{children:i})}),Pd=i=>(i==null?void 0:i.type)===ue.PromotionType.INGAME_IAB11_LBAR||(i==null?void 0:i.type)===ue.PromotionType.INGAME_IAB21_LBAR,OS=i=>(i==null?void 0:i.type)===ue.PromotionType.INGAME_IAB11_SIDEBAR||(i==null?void 0:i.type)===ue.PromotionType.INGAME_IAB21_SIDEBAR,MS=i=>(i==null?void 0:i.type)===ue.PromotionType.INGAME_IAB11||(i==null?void 0:i.type)===ue.PromotionType.INGAME_IAB21,RS=({advertisement:i,close:e,skipTypeCheck:t,skipAutoClose:n,layoutMode:s="side-by-side",sidebar:r,isNotification:a,banner:l,markAsViewed:c,open:f,externalAd:m,controlVideo:b,advertisementPaused:C,togglePause:w,isEventFired:A,fireEvent:v,muted:M})=>i.promotion?a&&i.notification?z.jsx(ty,{open:()=>f==null?void 0:f({fromNotification:!0}),notification:i.notification,promotionId:i.question.id,close:e}):!r&&!l&&(t||MS(i.promotion))?z.jsx(iy,{className:"PromoOverlayContainer",children:z.jsx(Ad,{markAsViewed:c,promotionId:i.question.id,promotion:i.promotion,onClose:e,open:f,skipAutoClose:n,externalAd:m,controlVideo:b,advertisementPaused:C,togglePause:w,isEventFired:A,fireEvent:v,muted:M})}):r&&(t||Pd(i.promotion)||OS(i.promotion)||m)?z.jsx(DS,{className:"PromoSidebarContainer",direction:r,hiding:!1,children:z.jsx(Ad,{markAsViewed:c,promotionId:i.question.id,promotion:i.promotion,externalAd:m,onClose:e,open:f,controlVideo:b,skipAutoClose:n,advertisementPaused:C,togglePause:w,isEventFired:A,fireEvent:v,muted:M})}):l&&Pd(i.promotion)?z.jsx(Od,{promotionId:i.question.id,hiding:!1,promotion:i.promotion,direction:l,isEventFired:A,fireEvent:v}):null:null,Ld=W.styled_default("div")({name:"AdvertisementUIWrap",class:"aa6pjif",propsAsIs:!1}),US=i=>{const e=i.target;if(e instanceof HTMLAnchorElement&&e.target==="_blank"){const t=e.getAttribute("data-promo-id")||"",n=e.getAttribute("data-promo-type")||ue.PromotionType.UNSET;e.getAttribute("data-a")==="button"&&W.eventBus.emit("advertisement",{action:"buttonSelect",payload:{id:t,type:n}}),e.getAttribute("data-a")==="banner"&&W.eventBus.emit("advertisement",{action:"bannerSelect",payload:{id:t,type:n}})}},NS=({gamification:i,advertisement:e,layoutMode:t,skipAutoClose:n,skipTypeCheck:s,sidebar:r,banner:a,notification:l,isMobileScreen:c,persistent:f,containerId:m,externalAd:b,controlVideo:C,muted:w})=>{var A,v,M,D,R,N,F,P,$,Y,X,re,ce,be,he,Z,de,ee,Xe,Ye,$e;const He=_e.useRef(null),me=W.useStore(e.$store),ge=W.useStore(i.openedQuestion.$store);W.b(He,{enabled:!!me.data,event:"click",listener:US});const mt=((M=(v=(A=me.data)==null?void 0:A.question)==null?void 0:v.backgroundImage)==null?void 0:M.landscapeUrl)||((R=(D=me.data)==null?void 0:D.promotion)==null?void 0:R.backgroundImageLandscapeUrl),Et=((P=(F=(N=me.data)==null?void 0:N.question)==null?void 0:F.backgroundImage)==null?void 0:P.portraitUrl)||((Y=($=me.data)==null?void 0:$.promotion)==null?void 0:Y.backgroundImagePortraitUrl),we=W.y$1({containerId:m,landscapeUrl:mt,portraitUrl:Et});if(((X=ge==null?void 0:ge.attributes)==null?void 0:X.adUnit)===ue.AdUnit.STANDART&&(be=(ce=(re=ge==null?void 0:ge.attributes)==null?void 0:re.adPromotion)==null?void 0:ce.banner)!=null&&be.imageUrl)return a?z.jsx(Ld,{ref:He,style:{height:"100%"},className:W.cx_default("SL-AdvertisementUIWrap",c&&"mobile-view"),children:z.jsx(hm,{cardId:ge.id,promotion:{...(he=ge==null?void 0:ge.attributes)==null?void 0:he.adPromotion,adUnit:(Z=ge==null?void 0:ge.attributes)==null?void 0:Z.adUnit}})}):null;const le=!a&&!r;if(me.data===void 0||!f&&me.isViewed)return null;const Re=((Xe=(ee=(de=me==null?void 0:me.data)==null?void 0:de.notification)==null?void 0:ee.promotion)==null?void 0:Xe.mode)===ue.NotificationPromotionMode.LOWER_THIRD;return z.jsxs(Ld,{ref:He,style:{height:le?"auto":"100%"},className:W.cx_default("SL-AdvertisementUIWrap",c&&"mobile-view",Re&&"SL-AdvertisementUIWrap--lower-third"),children:[!l&&we,z.jsx(RS,{skipTypeCheck:s,sidebar:r,banner:a,advertisement:me.data,advertisementPaused:!!me.isPaused,togglePause:me.togglePause,isEventFired:me.isEventFired,toggleMute:me.toggleMute,fireEvent:me.fireEvent,close:me.close,externalAd:b?me.externalAd:void 0,markAsViewed:(Ye=i.advertisement)==null?void 0:Ye.markAsViewed,open:($e=i.advertisement)==null?void 0:$e.open,layoutMode:t,isNotification:l,skipAutoClose:n,controlVideo:C,muted:w})]})},Hp=({sdk:i,sidebar:e,externalAd:t,banner:n,skipAutoClose:s,skipTypeCheck:r,layoutMode:a,isMobileScreen:l,persistent:c,notification:f,muted:m})=>{const b=W.useStore(i.featuresList.getStore()),[C,w]=_e.useState(!t),A=W.useStore(i.options);if(_e.useEffect(()=>{if(t){const M=document.createElement("script");M.async=!0,M.src="https://imasdk.googleapis.com/pal/sdkloader/pal.js",document.body.appendChild(M),M.onload=()=>{w(!0)}}},[t]),e&&n)return z.jsx("div",{style:{color:"red"},children:"define either sidebar or banner, not both."});if(n&&t)return z.jsx("div",{style:{color:"red"},children:"externalAd is not supported with banner"});if(!b)return null;const v=i.getFeature(ue.SdkOverlayType.GAMES);return!v||t&&!C?null:z.jsx(NS,{gamification:v,advertisement:v.advertisement,sidebar:e,banner:n,layoutMode:a,isMobileScreen:l,persistent:c,notification:f,skipTypeCheck:r,skipAutoClose:s,externalAd:t,controlVideo:i.controlVideoPlayer,containerId:A.containerId,muted:m})},BS=({event:i,sidebar:e,banner:t,isMobileScreen:n,skipAutoClose:s,persistent:r,theme:a,notification:l,skipTypeCheck:c,externalAd:f,muted:m=!1})=>{const b=W.useStreamLayer(),C=W.useStreamLayerUI(),w=W.useStreamLayerTheme();return b?f&&!C.promotionExternalAd?i!==void 0&&z.jsx(W.StreamLayerSDKEvent,{event:i}):!f&&C.promotionExternalAd?i!==void 0&&z.jsx(W.StreamLayerSDKEvent,{event:i}):e&&!C.promotionSidebar?i!==void 0&&z.jsx(W.StreamLayerSDKEvent,{event:i}):t&&!C.promotionBanner?i!==void 0&&z.jsx(W.StreamLayerSDKEvent,{event:i}):l&&!C.promotionNotification?i!==void 0&&z.jsx(W.StreamLayerSDKEvent,{event:i}):!t&&!e&&!l&&!C.promotionOverlay&&!c?i!==void 0&&z.jsx(W.StreamLayerSDKEvent,{event:i}):z.jsxs("div",{className:"StreamLayerSDK",children:[z.jsx(W.h,{customTheme:a??w.theme,themeMode:w.themeMode,children:z.jsx(Hp,{sdk:b,sidebar:e,banner:t,isMobileScreen:n,persistent:r,notification:l,skipTypeCheck:c,skipAutoClose:s,layoutMode:"side-by-side",externalAd:f,muted:m})}),i!==void 0&&z.jsx(W.StreamLayerSDKEvent,{event:i})]}):null};exports.StreamLayerSDKAdvertisement=BS;exports.StreamLayerSDKAdvertisementUI=Hp;
|
|
216
|
+
`.split("").map(s=>s.charCodeAt(0)));class Dx extends Error{constructor(){super("Trying to parse received VTT cues, but there is no WebVTT. Make sure vtt.js is loaded.")}}class Lx extends To{constructor(e,t={}){super(e,t),this.mediaSource_=null,this.subtitlesTrack_=null,this.featuresNativeTextTracks_=e.featuresNativeTextTracks,this.loadVttJs=e.loadVttJs,this.shouldSaveSegmentTimingInfo_=!1}buffered_(){if(!this.subtitlesTrack_||!this.subtitlesTrack_.cues||!this.subtitlesTrack_.cues.length)return Ke();const e=this.subtitlesTrack_.cues,t=e[0].startTime,i=e[e.length-1].startTime;return Ke([[t,i]])}initSegmentForMap(e,t=!1){if(!e)return null;const i=Ar(e);let n=this.initSegments_[i];if(t&&!n&&e.bytes){const r=xc.byteLength+e.bytes.byteLength,a=new Uint8Array(r);a.set(e.bytes),a.set(xc,e.bytes.byteLength),this.initSegments_[i]=n={resolvedUri:e.resolvedUri,byterange:e.byterange,bytes:a}}return n||e}couldBeginLoading_(){return this.playlist_&&this.subtitlesTrack_&&!this.paused()}init_(){return this.state="READY",this.resetEverything(),this.monitorBuffer_()}track(e){return typeof e>"u"?this.subtitlesTrack_:(this.subtitlesTrack_=e,this.state==="INIT"&&this.couldBeginLoading_()&&this.init_(),this.subtitlesTrack_)}remove(e,t){un(e,t,this.subtitlesTrack_)}fillBuffer_(){const e=this.chooseNextRequest_();if(e){if(this.syncController_.timestampOffsetForTimeline(e.timeline)===null){const t=()=>{this.state="READY",this.paused()||this.monitorBuffer_()};this.syncController_.one("timestampoffset",t),this.state="WAITING_ON_TIMELINE";return}this.loadSegment_(e)}}timestampOffsetForSegment_(){return null}chooseNextRequest_(){return this.skipEmptySegments_(super.chooseNextRequest_())}skipEmptySegments_(e){for(;e&&e.segment.empty;){if(e.mediaIndex+1>=e.playlist.segments.length){e=null;break}e=this.generateSegmentInfo_({playlist:e.playlist,mediaIndex:e.mediaIndex+1,startOfSegment:e.startOfSegment+e.duration,isSyncRequest:e.isSyncRequest})}return e}stopForError(e){this.error(e),this.state="READY",this.pause(),this.trigger("error")}segmentRequestFinished_(e,t,i){if(!this.subtitlesTrack_){this.state="READY";return}if(this.saveTransferStats_(t.stats),!this.pendingSegment_){this.state="READY",this.mediaRequestsAborted+=1;return}if(e){e.code===Qt.TIMEOUT&&this.handleTimeout_(),e.code===Qt.ABORTED?this.mediaRequestsAborted+=1:this.mediaRequestsErrored+=1,this.stopForError(e);return}const n=this.pendingSegment_,r=i.mp4VttCues&&i.mp4VttCues.length;r&&(n.mp4VttCues=i.mp4VttCues),this.saveBandwidthRelatedStats_(n.duration,t.stats),t.key&&this.segmentKey(t.key,!0),this.state="APPENDING",this.trigger("appending");const a=n.segment;if(a.map&&(a.map.bytes=t.map.bytes),n.bytes=t.bytes,typeof k.WebVTT!="function"&&typeof this.loadVttJs=="function"){this.state="WAITING_ON_VTTJS",this.loadVttJs().then(()=>this.segmentRequestFinished_(e,t,i),()=>this.stopForError({message:"Error loading vtt.js"}));return}a.requested=!0;try{this.parseVTTCues_(n)}catch(l){this.stopForError({message:l.message,metadata:{errorType:B.Error.StreamingVttParserError,error:l}});return}if(r||this.updateTimeMapping_(n,this.syncController_.timelines[n.timeline],this.playlist_),n.cues.length?n.timingInfo={start:n.cues[0].startTime,end:n.cues[n.cues.length-1].endTime}:n.timingInfo={start:n.startOfSegment,end:n.startOfSegment+n.duration},n.isSyncRequest){this.trigger("syncinfoupdate"),this.pendingSegment_=null,this.state="READY";return}n.byteLength=n.bytes.byteLength,this.mediaSecondsLoaded+=a.duration,n.cues.forEach(l=>{this.subtitlesTrack_.addCue(this.featuresNativeTextTracks_?new k.VTTCue(l.startTime,l.endTime,l.text):l)}),px(this.subtitlesTrack_),this.handleAppendsDone_()}handleData_(e,t){const i=e&&e.type==="vtt",n=t&&t.type==="text";i&&n&&super.handleData_(e,t)}updateTimingInfoEnd_(){}parseMp4VttCues_(e){const t=this.sourceUpdater_.videoTimestampOffset()===null?this.sourceUpdater_.audioTimestampOffset():this.sourceUpdater_.videoTimestampOffset();e.mp4VttCues.forEach(i=>{const n=i.start+t,r=i.end+t,a=new k.VTTCue(n,r,i.cueText);i.settings&&i.settings.split(" ").forEach(l=>{const h=l.split(":"),f=h[0],m=h[1];a[f]=isNaN(m)?m:Number(m)}),e.cues.push(a)})}parseVTTCues_(e){let t,i=!1;if(typeof k.WebVTT!="function")throw new Dx;if(e.cues=[],e.timestampmap={MPEGTS:0,LOCAL:0},e.mp4VttCues){this.parseMp4VttCues_(e);return}typeof k.TextDecoder=="function"?t=new k.TextDecoder("utf8"):(t=k.WebVTT.StringDecoder(),i=!0);const n=new k.WebVTT.Parser(k,k.vttjs,t);if(n.oncue=e.cues.push.bind(e.cues),n.ontimestampmap=a=>{e.timestampmap=a},n.onparsingerror=a=>{B.log.warn("Error encountered when parsing cues: "+a.message)},e.segment.map){let a=e.segment.map.bytes;i&&(a=bc(a)),n.parse(a)}let r=e.bytes;i&&(r=bc(r)),n.parse(r),n.flush()}updateTimeMapping_(e,t,i){const n=e.segment;if(!t)return;if(!e.cues.length){n.empty=!0;return}const{MPEGTS:r,LOCAL:a}=e.timestampmap,h=r/Ni.ONE_SECOND_IN_TS-a+t.mapping;if(e.cues.forEach(f=>{const m=f.endTime-f.startTime,T=this.handleRollover_(f.startTime+h,t.time);f.startTime=Math.max(T,0),f.endTime=Math.max(T+m,0)}),!i.syncInfo){const f=e.cues[0].startTime,m=e.cues[e.cues.length-1].startTime;i.syncInfo={mediaSequence:i.mediaSequence+e.mediaIndex,time:Math.min(f,m-n.duration)}}}handleRollover_(e,t){if(t===null)return e;let i=e*Ni.ONE_SECOND_IN_TS;const n=t*Ni.ONE_SECOND_IN_TS;let r;for(n<i?r=-8589934592:r=8589934592;Math.abs(i-n)>4294967296;)i+=r;return i/Ni.ONE_SECOND_IN_TS}}const Ox=function(s,e){const t=s.cues;for(let i=0;i<t.length;i++){const n=t[i];if(e>=n.adStartTime&&e<=n.adEndTime)return n}return null},Rx=function(s,e,t=0){if(!s.segments)return;let i=t,n;for(let r=0;r<s.segments.length;r++){const a=s.segments[r];if(n||(n=Ox(e,i+a.duration/2)),n){if("cueIn"in a){n.endTime=i,n.adEndTime=i,i+=a.duration,n=null;continue}if(i<n.endTime){i+=a.duration;continue}n.endTime+=a.duration}else if("cueOut"in a&&(n=new k.VTTCue(i,i+a.duration,a.cueOut),n.adStartTime=i,n.adEndTime=i+parseFloat(a.cueOut),e.addCue(n)),"cueOutCont"in a){const[l,h]=a.cueOutCont.split("/").map(parseFloat);n=new k.VTTCue(i,i+a.duration,""),n.adStartTime=i-l,n.adEndTime=n.adStartTime+h,e.addCue(n)}i+=a.duration}};class Sc{constructor({start:e,end:t,segmentIndex:i,partIndex:n=null,appended:r=!1}){this.start_=e,this.end_=t,this.segmentIndex_=i,this.partIndex_=n,this.appended_=r}isInRange(e){return e>=this.start&&e<this.end}markAppended(){this.appended_=!0}resetAppendedStatus(){this.appended_=!1}get isAppended(){return this.appended_}get start(){return this.start_}get end(){return this.end_}get segmentIndex(){return this.segmentIndex_}get partIndex(){return this.partIndex_}}class Mx{constructor(e,t=[]){this.segmentSyncInfo_=e,this.partsSyncInfo_=t}get segmentSyncInfo(){return this.segmentSyncInfo_}get partsSyncInfo(){return this.partsSyncInfo_}get hasPartsSyncInfo(){return this.partsSyncInfo_.length>0}resetAppendStatus(){this.segmentSyncInfo_.resetAppendedStatus(),this.partsSyncInfo_.forEach(e=>e.resetAppendedStatus())}}class Df{constructor(){this.storage_=new Map,this.diagnostics_="",this.isReliable_=!1,this.start_=-1/0,this.end_=1/0}get start(){return this.start_}get end(){return this.end_}get diagnostics(){return this.diagnostics_}get isReliable(){return this.isReliable_}resetAppendedStatus(){this.storage_.forEach(e=>e.resetAppendStatus())}update(e,t){const{mediaSequence:i,segments:n}=e;if(this.isReliable_=this.isReliablePlaylist_(i,n),!!this.isReliable_)return this.updateStorage_(n,i,this.calculateBaseTime_(i,n,t))}getSyncInfoForTime(e){for(const{segmentSyncInfo:t,partsSyncInfo:i}of this.storage_.values())if(i.length){for(const n of i)if(n.isInRange(e))return n}else if(t.isInRange(e))return t;return null}getSyncInfoForMediaSequence(e){return this.storage_.get(e)}updateStorage_(e,t,i){const n=new Map;let r=`
|
|
217
|
+
`,a=i,l=t;this.start_=a,e.forEach((h,f)=>{const m=this.storage_.get(l),T=a,E=T+h.duration,C=!!(m&&m.segmentSyncInfo&&m.segmentSyncInfo.isAppended),P=new Sc({start:T,end:E,appended:C,segmentIndex:f});h.syncInfo=P;let v=a;const R=(h.parts||[]).map((L,N)=>{const U=v,F=v+L.duration,D=!!(m&&m.partsSyncInfo&&m.partsSyncInfo[N]&&m.partsSyncInfo[N].isAppended),V=new Sc({start:U,end:F,appended:D,segmentIndex:f,partIndex:N});return v=F,r+=`Media Sequence: ${l}.${N} | Range: ${U} --> ${F} | Appended: ${D}
|
|
218
|
+
`,L.syncInfo=V,V});n.set(l,new Mx(P,R)),r+=`${If(h.resolvedUri)} | Media Sequence: ${l} | Range: ${T} --> ${E} | Appended: ${C}
|
|
219
|
+
`,l++,a=E}),this.end_=a,this.storage_=n,this.diagnostics_=r}calculateBaseTime_(e,t,i){if(!this.storage_.size)return 0;if(this.storage_.has(e))return this.storage_.get(e).segmentSyncInfo.start;const n=Math.min(...this.storage_.keys());if(e<n){const r=n-e;let a=this.storage_.get(n).segmentSyncInfo.start;for(let l=0;l<r;l++){const h=t[l];a-=h.duration}return a}return i}isReliablePlaylist_(e,t){return e!=null&&Array.isArray(t)&&t.length}}class Ec extends Df{constructor(e){super(),this.parent_=e}calculateBaseTime_(e,t,i){if(!this.storage_.size){const n=this.parent_.getSyncInfoForMediaSequence(e);return n?n.segmentSyncInfo.start:0}return super.calculateBaseTime_(e,t,i)}}const Nx=86400,Ka=[{name:"VOD",run:(s,e,t,i,n)=>t!==1/0?{time:0,segmentIndex:0,partIndex:null}:null},{name:"MediaSequence",run:(s,e,t,i,n,r)=>{const a=s.getMediaSequenceSync(r);if(!a||!a.isReliable)return null;const l=a.getSyncInfoForTime(n);return l?{time:l.start,partIndex:l.partIndex,segmentIndex:l.segmentIndex}:null}},{name:"ProgramDateTime",run:(s,e,t,i,n)=>{if(!Object.keys(s.timelineToDatetimeMappings).length)return null;let r=null,a=null;const l=uo(e);n=n||0;for(let h=0;h<l.length;h++){const f=e.endList||n===0?h:l.length-(h+1),m=l[f],T=m.segment,E=s.timelineToDatetimeMappings[T.timeline];if(!E||!T.dateTimeObject)continue;let P=T.dateTimeObject.getTime()/1e3+E;if(T.parts&&typeof m.partIndex=="number")for(let R=0;R<m.partIndex;R++)P+=T.parts[R].duration;const v=Math.abs(n-P);if(a!==null&&(v===0||a<v))break;a=v,r={time:P,segmentIndex:m.segmentIndex,partIndex:m.partIndex}}return r}},{name:"Segment",run:(s,e,t,i,n)=>{let r=null,a=null;n=n||0;const l=uo(e);for(let h=0;h<l.length;h++){const f=e.endList||n===0?h:l.length-(h+1),m=l[f],T=m.segment,E=m.part&&m.part.start||T&&T.start;if(T.timeline===i&&typeof E<"u"){const C=Math.abs(n-E);if(a!==null&&a<C)break;(!r||a===null||a>=C)&&(a=C,r={time:E,segmentIndex:m.segmentIndex,partIndex:m.partIndex})}}return r}},{name:"Discontinuity",run:(s,e,t,i,n)=>{let r=null;if(n=n||0,e.discontinuityStarts&&e.discontinuityStarts.length){let a=null;for(let l=0;l<e.discontinuityStarts.length;l++){const h=e.discontinuityStarts[l],f=e.discontinuitySequence+l+1,m=s.discontinuities[f];if(m){const T=Math.abs(n-m.time);if(a!==null&&a<T)break;(!r||a===null||a>=T)&&(a=T,r={time:m.time,segmentIndex:h,partIndex:null})}}}return r}},{name:"Playlist",run:(s,e,t,i,n)=>e.syncInfo?{time:e.syncInfo.time,segmentIndex:e.syncInfo.mediaSequence-e.mediaSequence,partIndex:null}:null}];class Ux extends B.EventTarget{constructor(e={}){super(),this.timelines=[],this.discontinuities=[],this.timelineToDatetimeMappings={};const t=new Df,i=new Ec(t),n=new Ec(t);this.mediaSequenceStorage_={main:t,audio:i,vtt:n},this.logger_=Pt("SyncController")}getMediaSequenceSync(e){return this.mediaSequenceStorage_[e]||null}getSyncPoint(e,t,i,n,r){if(t!==1/0)return Ka.find(({name:h})=>h==="VOD").run(this,e,t);const a=this.runStrategies_(e,t,i,n,r);if(!a.length)return null;for(const l of a){const{syncPoint:h,strategy:f}=l,{segmentIndex:m,time:T}=h;if(m<0)continue;const E=e.segments[m],C=T,P=C+E.duration;if(this.logger_(`Strategy: ${f}. Current time: ${n}. selected segment: ${m}. Time: [${C} -> ${P}]}`),n>=C&&n<P)return this.logger_("Found sync point with exact match: ",h),h}return this.selectSyncPoint_(a,{key:"time",value:n})}getExpiredTime(e,t){if(!e||!e.segments)return null;const i=this.runStrategies_(e,t,e.discontinuitySequence,0);if(!i.length)return null;const n=this.selectSyncPoint_(i,{key:"segmentIndex",value:0});return n.segmentIndex>0&&(n.time*=-1),Math.abs(n.time+mn({defaultDuration:e.targetDuration,durationList:e.segments,startIndex:n.segmentIndex,endIndex:0}))}runStrategies_(e,t,i,n,r){const a=[];for(let l=0;l<Ka.length;l++){const h=Ka[l],f=h.run(this,e,t,i,n,r);f&&(f.strategy=h.name,a.push({strategy:h.name,syncPoint:f}))}return a}selectSyncPoint_(e,t){let i=e[0].syncPoint,n=Math.abs(e[0].syncPoint[t.key]-t.value),r=e[0].strategy;for(let a=1;a<e.length;a++){const l=Math.abs(e[a].syncPoint[t.key]-t.value);l<n&&(n=l,i=e[a].syncPoint,r=e[a].strategy)}return this.logger_(`syncPoint for [${t.key}: ${t.value}] chosen with strategy [${r}]: [time:${i.time}, segmentIndex:${i.segmentIndex}`+(typeof i.partIndex=="number"?`,partIndex:${i.partIndex}`:"")+"]"),i}saveExpiredSegmentInfo(e,t){const i=t.mediaSequence-e.mediaSequence;if(i>Nx){B.log.warn(`Not saving expired segment info. Media sequence gap ${i} is too large.`);return}for(let n=i-1;n>=0;n--){const r=e.segments[n];if(r&&typeof r.start<"u"){t.syncInfo={mediaSequence:e.mediaSequence+n,time:r.start},this.logger_(`playlist refresh sync: [time:${t.syncInfo.time}, mediaSequence: ${t.syncInfo.mediaSequence}]`),this.trigger("syncinfoupdate");break}}}setDateTimeMappingForStart(e){if(this.timelineToDatetimeMappings={},e.segments&&e.segments.length&&e.segments[0].dateTimeObject){const t=e.segments[0],i=t.dateTimeObject.getTime()/1e3;this.timelineToDatetimeMappings[t.timeline]=-i}}saveSegmentTimingInfo({segmentInfo:e,shouldSaveTimelineMapping:t}){const i=this.calculateSegmentTimeMapping_(e,e.timingInfo,t),n=e.segment;i&&(this.saveDiscontinuitySyncInfo_(e),e.playlist.syncInfo||(e.playlist.syncInfo={mediaSequence:e.playlist.mediaSequence+e.mediaIndex,time:n.start}));const r=n.dateTimeObject;n.discontinuity&&t&&r&&(this.timelineToDatetimeMappings[n.timeline]=-(r.getTime()/1e3))}timestampOffsetForTimeline(e){return typeof this.timelines[e]>"u"?null:this.timelines[e].time}mappingForTimeline(e){return typeof this.timelines[e]>"u"?null:this.timelines[e].mapping}calculateSegmentTimeMapping_(e,t,i){const n=e.segment,r=e.part;let a=this.timelines[e.timeline],l,h;if(typeof e.timestampOffset=="number")a={time:e.startOfSegment,mapping:e.startOfSegment-t.start},i&&(this.timelines[e.timeline]=a,this.trigger("timestampoffset"),this.logger_(`time mapping for timeline ${e.timeline}: [time: ${a.time}] [mapping: ${a.mapping}]`)),l=e.startOfSegment,h=t.end+a.mapping;else if(a)l=t.start+a.mapping,h=t.end+a.mapping;else return!1;return r&&(r.start=l,r.end=h),(!n.start||l<n.start)&&(n.start=l),n.end=h,!0}saveDiscontinuitySyncInfo_(e){const t=e.playlist,i=e.segment;if(i.discontinuity)this.discontinuities[i.timeline]={time:i.start,accuracy:0};else if(t.discontinuityStarts&&t.discontinuityStarts.length)for(let n=0;n<t.discontinuityStarts.length;n++){const r=t.discontinuityStarts[n],a=t.discontinuitySequence+n+1,l=r-e.mediaIndex,h=Math.abs(l);if(!this.discontinuities[a]||this.discontinuities[a].accuracy>h){let f;l<0?f=i.start-mn({defaultDuration:t.targetDuration,durationList:t.segments,startIndex:e.mediaIndex,endIndex:r}):f=i.end+mn({defaultDuration:t.targetDuration,durationList:t.segments,startIndex:e.mediaIndex+1,endIndex:r}),this.discontinuities[a]={time:f,accuracy:h}}}}dispose(){this.trigger("dispose"),this.off()}}class Bx extends B.EventTarget{constructor(){super(),this.pendingTimelineChanges_={},this.lastTimelineChanges_={}}clearPendingTimelineChange(e){this.pendingTimelineChanges_[e]=null,this.trigger("pendingtimelinechange")}pendingTimelineChange({type:e,from:t,to:i}){return typeof t=="number"&&typeof i=="number"&&(this.pendingTimelineChanges_[e]={type:e,from:t,to:i},this.trigger("pendingtimelinechange")),this.pendingTimelineChanges_[e]}lastTimelineChange({type:e,from:t,to:i}){if(typeof t=="number"&&typeof i=="number"){this.lastTimelineChanges_[e]={type:e,from:t,to:i},delete this.pendingTimelineChanges_[e];const n={timelineChangeInfo:{from:t,to:i}};this.trigger({type:"timelinechange",metadata:n})}return this.lastTimelineChanges_[e]}dispose(){this.trigger("dispose"),this.pendingTimelineChanges_={},this.lastTimelineChanges_={},this.off()}}const Fx=mf(gf(function(){var s=function(){function v(){this.listeners={}}var R=v.prototype;return R.on=function(N,U){this.listeners[N]||(this.listeners[N]=[]),this.listeners[N].push(U)},R.off=function(N,U){if(!this.listeners[N])return!1;var F=this.listeners[N].indexOf(U);return this.listeners[N]=this.listeners[N].slice(0),this.listeners[N].splice(F,1),F>-1},R.trigger=function(N){var U=this.listeners[N];if(U)if(arguments.length===2)for(var F=U.length,D=0;D<F;++D)U[D].call(this,arguments[1]);else for(var V=Array.prototype.slice.call(arguments,1),X=U.length,G=0;G<X;++G)U[G].apply(this,V)},R.dispose=function(){this.listeners={}},R.pipe=function(N){this.on("data",function(U){N.push(U)})},v}();/*! @name pkcs7 @version 1.0.4 @license Apache-2.0 */function e(v){return v.subarray(0,v.byteLength-v[v.byteLength-1])}/*! @name aes-decrypter @version 4.0.2 @license Apache-2.0 */const t=function(){const v=[[[],[],[],[],[]],[[],[],[],[],[]]],R=v[0],L=v[1],N=R[4],U=L[4];let F,D,V;const X=[],G=[];let ae,fe,ve,he,Z,de;for(F=0;F<256;F++)G[(X[F]=F<<1^(F>>7)*283)^F]=F;for(D=V=0;!N[D];D^=ae||1,V=G[V]||1)for(he=V^V<<1^V<<2^V<<3^V<<4,he=he>>8^he&255^99,N[D]=he,U[he]=D,ve=X[fe=X[ae=X[D]]],de=ve*16843009^fe*65537^ae*257^D*16843008,Z=X[he]*257^he*16843008,F=0;F<4;F++)R[F][D]=Z=Z<<24^Z>>>8,L[F][he]=de=de<<24^de>>>8;for(F=0;F<5;F++)R[F]=R[F].slice(0),L[F]=L[F].slice(0);return v};let i=null;class n{constructor(R){i||(i=t()),this._tables=[[i[0][0].slice(),i[0][1].slice(),i[0][2].slice(),i[0][3].slice(),i[0][4].slice()],[i[1][0].slice(),i[1][1].slice(),i[1][2].slice(),i[1][3].slice(),i[1][4].slice()]];let L,N,U;const F=this._tables[0][4],D=this._tables[1],V=R.length;let X=1;if(V!==4&&V!==6&&V!==8)throw new Error("Invalid aes key size");const G=R.slice(0),ae=[];for(this._key=[G,ae],L=V;L<4*V+28;L++)U=G[L-1],(L%V===0||V===8&&L%V===4)&&(U=F[U>>>24]<<24^F[U>>16&255]<<16^F[U>>8&255]<<8^F[U&255],L%V===0&&(U=U<<8^U>>>24^X<<24,X=X<<1^(X>>7)*283)),G[L]=G[L-V]^U;for(N=0;L;N++,L--)U=G[N&3?L:L-4],L<=4||N<4?ae[N]=U:ae[N]=D[0][F[U>>>24]]^D[1][F[U>>16&255]]^D[2][F[U>>8&255]]^D[3][F[U&255]]}decrypt(R,L,N,U,F,D){const V=this._key[1];let X=R^V[0],G=U^V[1],ae=N^V[2],fe=L^V[3],ve,he,Z;const de=V.length/4-2;let ee,Xe=4;const Qe=this._tables[1],Ve=Qe[0],qe=Qe[1],be=Qe[2],me=Qe[3],pt=Qe[4];for(ee=0;ee<de;ee++)ve=Ve[X>>>24]^qe[G>>16&255]^be[ae>>8&255]^me[fe&255]^V[Xe],he=Ve[G>>>24]^qe[ae>>16&255]^be[fe>>8&255]^me[X&255]^V[Xe+1],Z=Ve[ae>>>24]^qe[fe>>16&255]^be[X>>8&255]^me[G&255]^V[Xe+2],fe=Ve[fe>>>24]^qe[X>>16&255]^be[G>>8&255]^me[ae&255]^V[Xe+3],Xe+=4,X=ve,G=he,ae=Z;for(ee=0;ee<4;ee++)F[(3&-ee)+D]=pt[X>>>24]<<24^pt[G>>16&255]<<16^pt[ae>>8&255]<<8^pt[fe&255]^V[Xe++],ve=X,X=G,G=ae,ae=fe,fe=ve}}class r extends s{constructor(){super(s),this.jobs=[],this.delay=1,this.timeout_=null}processJob_(){this.jobs.shift()(),this.jobs.length?this.timeout_=setTimeout(this.processJob_.bind(this),this.delay):this.timeout_=null}push(R){this.jobs.push(R),this.timeout_||(this.timeout_=setTimeout(this.processJob_.bind(this),this.delay))}}const a=function(v){return v<<24|(v&65280)<<8|(v&16711680)>>8|v>>>24},l=function(v,R,L){const N=new Int32Array(v.buffer,v.byteOffset,v.byteLength>>2),U=new n(Array.prototype.slice.call(R)),F=new Uint8Array(v.byteLength),D=new Int32Array(F.buffer);let V,X,G,ae,fe,ve,he,Z,de;for(V=L[0],X=L[1],G=L[2],ae=L[3],de=0;de<N.length;de+=4)fe=a(N[de]),ve=a(N[de+1]),he=a(N[de+2]),Z=a(N[de+3]),U.decrypt(fe,ve,he,Z,D,de),D[de]=a(D[de]^V),D[de+1]=a(D[de+1]^X),D[de+2]=a(D[de+2]^G),D[de+3]=a(D[de+3]^ae),V=fe,X=ve,G=he,ae=Z;return F};class h{constructor(R,L,N,U){const F=h.STEP,D=new Int32Array(R.buffer),V=new Uint8Array(R.byteLength);let X=0;for(this.asyncStream_=new r,this.asyncStream_.push(this.decryptChunk_(D.subarray(X,X+F),L,N,V)),X=F;X<D.length;X+=F)N=new Uint32Array([a(D[X-4]),a(D[X-3]),a(D[X-2]),a(D[X-1])]),this.asyncStream_.push(this.decryptChunk_(D.subarray(X,X+F),L,N,V));this.asyncStream_.push(function(){U(null,e(V))})}static get STEP(){return 32e3}decryptChunk_(R,L,N,U){return function(){const F=l(R,L,N);U.set(F,R.byteOffset)}}}var f=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof re.global<"u"?re.global:typeof self<"u"?self:{},m;typeof window<"u"?m=window:typeof f<"u"?m=f:typeof self<"u"?m=self:m={};var T=m,E=function(R){return ArrayBuffer.isView==="function"?ArrayBuffer.isView(R):R&&R.buffer instanceof ArrayBuffer},C=T.BigInt||Number;C("0x1"),C("0x100"),C("0x10000"),C("0x1000000"),C("0x100000000"),C("0x10000000000"),C("0x1000000000000"),C("0x100000000000000"),C("0x10000000000000000"),function(){var v=new Uint16Array([65484]),R=new Uint8Array(v.buffer,v.byteOffset,v.byteLength);return R[0]===255?"big":R[0]===204?"little":"unknown"}();const P=function(v){const R={};return Object.keys(v).forEach(L=>{const N=v[L];E(N)?R[L]={bytes:N.buffer,byteOffset:N.byteOffset,byteLength:N.byteLength}:R[L]=N}),R};self.onmessage=function(v){const R=v.data,L=new Uint8Array(R.encrypted.bytes,R.encrypted.byteOffset,R.encrypted.byteLength),N=new Uint32Array(R.key.bytes,R.key.byteOffset,R.key.byteLength/4),U=new Uint32Array(R.iv.bytes,R.iv.byteOffset,R.iv.byteLength/4);new h(L,N,U,function(F,D){self.postMessage(P({source:R.source,decrypted:D}),[D.buffer])})}}));var $x=pf(Fx);const jx=s=>{let e=s.default?"main":"alternative";return s.characteristics&&s.characteristics.indexOf("public.accessibility.describes-video")>=0&&(e="main-desc"),e},Lf=(s,e)=>{s.abort(),s.pause(),e&&e.activePlaylistLoader&&(e.activePlaylistLoader.pause(),e.activePlaylistLoader=null)},bo=(s,e)=>{e.activePlaylistLoader=s,s.load()},Vx=(s,e)=>()=>{const{segmentLoaders:{[s]:t,main:i},mediaTypes:{[s]:n}}=e,r=n.activeTrack(),a=n.getActiveGroup(),l=n.activePlaylistLoader,h=n.lastGroup_;if(!(a&&h&&a.id===h.id)&&(n.lastGroup_=a,n.lastTrack_=r,Lf(t,n),!(!a||a.isMainPlaylist))){if(!a.playlistLoader){l&&i.resetEverything();return}t.resyncLoader(),bo(a.playlistLoader,n)}},Hx=(s,e)=>()=>{const{segmentLoaders:{[s]:t},mediaTypes:{[s]:i}}=e;i.lastGroup_=null,t.abort(),t.pause()},qx=(s,e)=>()=>{const{mainPlaylistLoader:t,segmentLoaders:{[s]:i,main:n},mediaTypes:{[s]:r}}=e,a=r.activeTrack(),l=r.getActiveGroup(),h=r.activePlaylistLoader,f=r.lastTrack_;if(!(f&&a&&f.id===a.id)&&(r.lastGroup_=l,r.lastTrack_=a,Lf(i,r),!!l)){if(l.isMainPlaylist){if(!a||!f||a.id===f.id)return;const m=e.vhs.playlistController_,T=m.selectPlaylist();if(m.media()===T)return;r.logger_(`track change. Switching main audio from ${f.id} to ${a.id}`),t.pause(),n.resetEverything(),m.fastQualityChange_(T);return}if(s==="AUDIO"){if(!l.playlistLoader){n.setAudio(!0),n.resetEverything();return}i.setAudio(!0),n.setAudio(!1)}if(h===l.playlistLoader){bo(l.playlistLoader,r);return}i.track&&i.track(a),i.resetEverything(),bo(l.playlistLoader,r)}},Dr={AUDIO:(s,e)=>()=>{const{mediaTypes:{[s]:t},excludePlaylist:i}=e,n=t.activeTrack(),r=t.activeGroup(),a=(r.filter(h=>h.default)[0]||r[0]).id,l=t.tracks[a];if(n===l){i({error:{message:"Problem encountered loading the default audio track."}});return}B.log.warn("Problem encountered loading the alternate audio track.Switching back to default.");for(const h in t.tracks)t.tracks[h].enabled=t.tracks[h]===l;t.onTrackChanged()},SUBTITLES:(s,e)=>()=>{const{mediaTypes:{[s]:t}}=e;B.log.warn("Problem encountered loading the subtitle track.Disabling subtitle track.");const i=t.activeTrack();i&&(i.mode="disabled"),t.onTrackChanged()}},Cc={AUDIO:(s,e,t)=>{if(!e)return;const{tech:i,requestOptions:n,segmentLoaders:{[s]:r}}=t;e.on("loadedmetadata",()=>{const a=e.media();r.playlist(a,n),(!i.paused()||a.endList&&i.preload()!=="none")&&r.load()}),e.on("loadedplaylist",()=>{r.playlist(e.media(),n),i.paused()||r.load()}),e.on("error",Dr[s](s,t))},SUBTITLES:(s,e,t)=>{const{tech:i,requestOptions:n,segmentLoaders:{[s]:r},mediaTypes:{[s]:a}}=t;e.on("loadedmetadata",()=>{const l=e.media();r.playlist(l,n),r.track(a.activeTrack()),(!i.paused()||l.endList&&i.preload()!=="none")&&r.load()}),e.on("loadedplaylist",()=>{r.playlist(e.media(),n),i.paused()||r.load()}),e.on("error",Dr[s](s,t))}},zx={AUDIO:(s,e)=>{const{vhs:t,sourceType:i,segmentLoaders:{[s]:n},requestOptions:r,main:{mediaGroups:a},mediaTypes:{[s]:{groups:l,tracks:h,logger_:f}},mainPlaylistLoader:m}=e,T=wn(m.main);(!a[s]||Object.keys(a[s]).length===0)&&(a[s]={main:{default:{default:!0}}},T&&(a[s].main.default.playlists=m.main.playlists));for(const E in a[s]){l[E]||(l[E]=[]);for(const C in a[s][E]){let P=a[s][E][C],v;if(T?(f(`AUDIO group '${E}' label '${C}' is a main playlist`),P.isMainPlaylist=!0,v=null):i==="vhs-json"&&P.playlists?v=new ns(P.playlists[0],t,r):P.resolvedUri?v=new ns(P.resolvedUri,t,r):P.playlists&&i==="dash"?v=new go(P.playlists[0],t,r,m):v=null,P=ge({id:C,playlistLoader:v},P),Cc[s](s,P.playlistLoader,e),l[E].push(P),typeof h[C]>"u"){const R=new B.AudioTrack({id:C,kind:jx(P),enabled:!1,language:P.language,default:P.default,label:C});h[C]=R}}}n.on("error",Dr[s](s,e))},SUBTITLES:(s,e)=>{const{tech:t,vhs:i,sourceType:n,segmentLoaders:{[s]:r},requestOptions:a,main:{mediaGroups:l},mediaTypes:{[s]:{groups:h,tracks:f}},mainPlaylistLoader:m}=e;for(const T in l[s]){h[T]||(h[T]=[]);for(const E in l[s][T]){if(!i.options_.useForcedSubtitles&&l[s][T][E].forced)continue;let C=l[s][T][E],P;if(n==="hls")P=new ns(C.resolvedUri,i,a);else if(n==="dash"){if(!C.playlists.filter(R=>R.excludeUntil!==1/0).length)return;P=new go(C.playlists[0],i,a,m)}else n==="vhs-json"&&(P=new ns(C.playlists?C.playlists[0]:C.resolvedUri,i,a));if(C=ge({id:E,playlistLoader:P},C),Cc[s](s,C.playlistLoader,e),h[T].push(C),typeof f[E]>"u"){const v=t.addRemoteTextTrack({id:E,kind:"subtitles",default:C.default&&C.autoselect,language:C.language,label:E},!1).track;f[E]=v}}}r.on("error",Dr[s](s,e))},"CLOSED-CAPTIONS":(s,e)=>{const{tech:t,main:{mediaGroups:i},mediaTypes:{[s]:{groups:n,tracks:r}}}=e;for(const a in i[s]){n[a]||(n[a]=[]);for(const l in i[s][a]){const h=i[s][a][l];if(!/^(?:CC|SERVICE)/.test(h.instreamId))continue;const f=t.options_.vhs&&t.options_.vhs.captionServices||{};let m={label:l,language:h.language,instreamId:h.instreamId,default:h.default&&h.autoselect};if(f[m.instreamId]&&(m=ge(m,f[m.instreamId])),m.default===void 0&&delete m.default,n[a].push(ge({id:l},h)),typeof r[l]>"u"){const T=t.addRemoteTextTrack({id:m.instreamId,kind:"captions",default:m.default,language:m.language,label:m.label},!1).track;r[l]=T}}}}},Of=(s,e)=>{for(let t=0;t<s.length;t++)if(hl(e,s[t])||s[t].playlists&&Of(s[t].playlists,e))return!0;return!1},Wx=(s,e)=>t=>{const{mainPlaylistLoader:i,mediaTypes:{[s]:{groups:n}}}=e,r=i.media();if(!r)return null;let a=null;r.attributes[s]&&(a=n[r.attributes[s]]);const l=Object.keys(n);if(!a)if(s==="AUDIO"&&l.length>1&&wn(e.main))for(let h=0;h<l.length;h++){const f=n[l[h]];if(Of(f,r)){a=f;break}}else n.main?a=n.main:l.length===1&&(a=n[l[0]]);return typeof t>"u"?a:t===null||!a?null:a.filter(h=>h.id===t.id)[0]||null},Gx={AUDIO:(s,e)=>()=>{const{mediaTypes:{[s]:{tracks:t}}}=e;for(const i in t)if(t[i].enabled)return t[i];return null},SUBTITLES:(s,e)=>()=>{const{mediaTypes:{[s]:{tracks:t}}}=e;for(const i in t)if(t[i].mode==="showing"||t[i].mode==="hidden")return t[i];return null}},Kx=(s,{mediaTypes:e})=>()=>{const t=e[s].activeTrack();return t?e[s].activeGroup(t):null},Xx=s=>{["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(f=>{zx[f](f,s)});const{mediaTypes:e,mainPlaylistLoader:t,tech:i,vhs:n,segmentLoaders:{["AUDIO"]:r,main:a}}=s;["AUDIO","SUBTITLES"].forEach(f=>{e[f].activeGroup=Wx(f,s),e[f].activeTrack=Gx[f](f,s),e[f].onGroupChanged=Vx(f,s),e[f].onGroupChanging=Hx(f,s),e[f].onTrackChanged=qx(f,s),e[f].getActiveGroup=Kx(f,s)});const l=e.AUDIO.activeGroup();if(l){const f=(l.filter(T=>T.default)[0]||l[0]).id;e.AUDIO.tracks[f].enabled=!0,e.AUDIO.onGroupChanged(),e.AUDIO.onTrackChanged(),e.AUDIO.getActiveGroup().playlistLoader?(a.setAudio(!1),r.setAudio(!0)):a.setAudio(!0)}t.on("mediachange",()=>{["AUDIO","SUBTITLES"].forEach(f=>e[f].onGroupChanged())}),t.on("mediachanging",()=>{["AUDIO","SUBTITLES"].forEach(f=>e[f].onGroupChanging())});const h=()=>{e.AUDIO.onTrackChanged(),i.trigger({type:"usage",name:"vhs-audio-change"})};i.audioTracks().addEventListener("change",h),i.remoteTextTracks().addEventListener("change",e.SUBTITLES.onTrackChanged),n.on("dispose",()=>{i.audioTracks().removeEventListener("change",h),i.remoteTextTracks().removeEventListener("change",e.SUBTITLES.onTrackChanged)}),i.clearTracks("audio");for(const f in e.AUDIO.tracks)i.audioTracks().addTrack(e.AUDIO.tracks[f])},Yx=()=>{const s={};return["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(e=>{s[e]={groups:{},tracks:{},activePlaylistLoader:null,activeGroup:ri,activeTrack:ri,getActiveGroup:ri,onGroupChanged:ri,onTrackChanged:ri,lastTrack_:null,logger_:Pt(`MediaGroups[${e}]`)}}),s};class wc{constructor(){this.priority_=[],this.pathwayClones_=new Map}set version(e){e===1&&(this.version_=e)}set ttl(e){this.ttl_=e||300}set reloadUri(e){e&&(this.reloadUri_=dt(this.reloadUri_,e))}set priority(e){e&&e.length&&(this.priority_=e)}set pathwayClones(e){e&&e.length&&(this.pathwayClones_=new Map(e.map(t=>[t.ID,t])))}get version(){return this.version_}get ttl(){return this.ttl_}get reloadUri(){return this.reloadUri_}get priority(){return this.priority_}get pathwayClones(){return this.pathwayClones_}}class Qx extends B.EventTarget{constructor(e,t){super(),this.currentPathway=null,this.defaultPathway=null,this.queryBeforeStart=!1,this.availablePathways_=new Set,this.steeringManifest=new wc,this.proxyServerUrl_=null,this.manifestType_=null,this.ttlTimeout_=null,this.request_=null,this.currentPathwayClones=new Map,this.nextPathwayClones=new Map,this.excludedSteeringManifestURLs=new Set,this.logger_=Pt("Content Steering"),this.xhr_=e,this.getBandwidth_=t}assignTagProperties(e,t){this.manifestType_=t.serverUri?"HLS":"DASH";const i=t.serverUri||t.serverURL;if(!i){this.logger_(`steering manifest URL is ${i}, cannot request steering manifest.`),this.trigger("error");return}if(i.startsWith("data:")){this.decodeDataUriManifest_(i.substring(i.indexOf(",")+1));return}this.steeringManifest.reloadUri=dt(e,i),this.defaultPathway=t.pathwayId||t.defaultServiceLocation,this.queryBeforeStart=t.queryBeforeStart,this.proxyServerUrl_=t.proxyServerURL,this.defaultPathway&&!this.queryBeforeStart&&this.trigger("content-steering")}requestSteeringManifest(e){const t=this.steeringManifest.reloadUri;if(!t)return;const i=e?t:this.getRequestURI(t);if(!i){this.logger_("No valid content steering manifest URIs. Stopping content steering."),this.trigger("error"),this.dispose();return}const n={contentSteeringInfo:{uri:i}};this.trigger({type:"contentsteeringloadstart",metadata:n}),this.request_=this.xhr_({uri:i,requestType:"content-steering-manifest"},(r,a)=>{if(r){if(a.status===410){this.logger_(`manifest request 410 ${r}.`),this.logger_(`There will be no more content steering requests to ${i} this session.`),this.excludedSteeringManifestURLs.add(i);return}if(a.status===429){const f=a.responseHeaders["retry-after"];this.logger_(`manifest request 429 ${r}.`),this.logger_(`content steering will retry in ${f} seconds.`),this.startTTLTimeout_(parseInt(f,10));return}this.logger_(`manifest failed to load ${r}.`),this.startTTLTimeout_();return}this.trigger({type:"contentsteeringloadcomplete",metadata:n});let l;try{l=JSON.parse(this.request_.responseText)}catch(f){const m={errorType:B.Error.StreamingContentSteeringParserError,error:f};this.trigger({type:"error",metadata:m})}this.assignSteeringProperties_(l);const h={contentSteeringInfo:n.contentSteeringInfo,contentSteeringManifest:{version:this.steeringManifest.version,reloadUri:this.steeringManifest.reloadUri,priority:this.steeringManifest.priority}};this.trigger({type:"contentsteeringparsed",metadata:h}),this.startTTLTimeout_()})}setProxyServerUrl_(e){const t=new k.URL(e),i=new k.URL(this.proxyServerUrl_);return i.searchParams.set("url",encodeURI(t.toString())),this.setSteeringParams_(i.toString())}decodeDataUriManifest_(e){const t=JSON.parse(k.atob(e));this.assignSteeringProperties_(t)}setSteeringParams_(e){const t=new k.URL(e),i=this.getPathway(),n=this.getBandwidth_();if(i){const r=`_${this.manifestType_}_pathway`;t.searchParams.set(r,i)}if(n){const r=`_${this.manifestType_}_throughput`;t.searchParams.set(r,n)}return t.toString()}assignSteeringProperties_(e){if(this.steeringManifest.version=e.VERSION,!this.steeringManifest.version){this.logger_(`manifest version is ${e.VERSION}, which is not supported.`),this.trigger("error");return}this.steeringManifest.ttl=e.TTL,this.steeringManifest.reloadUri=e["RELOAD-URI"],this.steeringManifest.priority=e["PATHWAY-PRIORITY"]||e["SERVICE-LOCATION-PRIORITY"],this.steeringManifest.pathwayClones=e["PATHWAY-CLONES"],this.nextPathwayClones=this.steeringManifest.pathwayClones,this.availablePathways_.size||(this.logger_("There are no available pathways for content steering. Ending content steering."),this.trigger("error"),this.dispose());const i=(n=>{for(const r of n)if(this.availablePathways_.has(r))return r;return[...this.availablePathways_][0]})(this.steeringManifest.priority);this.currentPathway!==i&&(this.currentPathway=i,this.trigger("content-steering"))}getPathway(){return this.currentPathway||this.defaultPathway}getRequestURI(e){if(!e)return null;const t=n=>this.excludedSteeringManifestURLs.has(n);if(this.proxyServerUrl_){const n=this.setProxyServerUrl_(e);if(!t(n))return n}const i=this.setSteeringParams_(e);return t(i)?null:i}startTTLTimeout_(e=this.steeringManifest.ttl){const t=e*1e3;this.ttlTimeout_=k.setTimeout(()=>{this.requestSteeringManifest()},t)}clearTTLTimeout_(){k.clearTimeout(this.ttlTimeout_),this.ttlTimeout_=null}abort(){this.request_&&this.request_.abort(),this.request_=null}dispose(){this.off("content-steering"),this.off("error"),this.abort(),this.clearTTLTimeout_(),this.currentPathway=null,this.defaultPathway=null,this.queryBeforeStart=null,this.proxyServerUrl_=null,this.manifestType_=null,this.ttlTimeout_=null,this.request_=null,this.excludedSteeringManifestURLs=new Set,this.availablePathways_=new Set,this.steeringManifest=new wc}addAvailablePathway(e){e&&this.availablePathways_.add(e)}clearAvailablePathways(){this.availablePathways_.clear()}excludePathway(e){return this.availablePathways_.delete(e)}didDASHTagChange(e,t){return!t&&this.steeringManifest.reloadUri||t&&(dt(e,t.serverURL)!==this.steeringManifest.reloadUri||t.defaultServiceLocation!==this.defaultPathway||t.queryBeforeStart!==this.queryBeforeStart||t.proxyServerURL!==this.proxyServerUrl_)}getAvailablePathways(){return this.availablePathways_}}const Jx=(s,e)=>{let t=null;return(...i)=>{clearTimeout(t),t=setTimeout(()=>{s.apply(null,i)},e)}},Zx=10;let vi;const e1=["mediaRequests","mediaRequestsAborted","mediaRequestsTimedout","mediaRequestsErrored","mediaTransferDuration","mediaBytesTransferred","mediaAppends"],t1=function(s){return this.audioSegmentLoader_[s]+this.mainSegmentLoader_[s]},i1=function({currentPlaylist:s,buffered:e,currentTime:t,nextPlaylist:i,bufferLowWaterLine:n,bufferHighWaterLine:r,duration:a,bufferBasedABR:l,log:h}){if(!i)return B.log.warn("We received no playlist to switch to. Please check your stream."),!1;const f=`allowing switch ${s&&s.id||"null"} -> ${i.id}`;if(!s)return h(`${f} as current playlist is not set`),!0;if(i.id===s.id)return!1;const m=!!ss(e,t).length;if(!s.endList)return!m&&typeof s.partTargetDuration=="number"?(h(`not ${f} as current playlist is live llhls, but currentTime isn't in buffered.`),!1):(h(`${f} as current playlist is live`),!0);const T=ul(e,t),E=l?We.EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE:We.MAX_BUFFER_LOW_WATER_LINE;if(a<E)return h(`${f} as duration < max low water line (${a} < ${E})`),!0;const C=i.attributes.BANDWIDTH,P=s.attributes.BANDWIDTH;if(C<P&&(!l||T<r)){let v=`${f} as next bandwidth < current bandwidth (${C} < ${P})`;return l&&(v+=` and forwardBuffer < bufferHighWaterLine (${T} < ${r})`),h(v),!0}if((!l||C>P)&&T>=n){let v=`${f} as forwardBuffer >= bufferLowWaterLine (${T} >= ${n})`;return l&&(v+=` and next bandwidth > current bandwidth (${C} > ${P})`),h(v),!0}return h(`not ${f} as no switching criteria met`),!1};class s1 extends B.EventTarget{constructor(e){super(),this.fastQualityChange_=Jx(this.fastQualityChange_.bind(this),100);const{src:t,withCredentials:i,tech:n,bandwidth:r,externVhs:a,useCueTags:l,playlistExclusionDuration:h,enableLowInitialPlaylist:f,sourceType:m,cacheEncryptionKeys:T,bufferBasedABR:E,leastPixelDiffSelector:C,captionServices:P,experimentalUseMMS:v}=e;if(!t)throw new Error("A non-empty playlist URL or JSON manifest string is required");let{maxPlaylistRetries:R}=e;(R===null||typeof R>"u")&&(R=1/0),vi=a,this.bufferBasedABR=!!E,this.leastPixelDiffSelector=!!C,this.withCredentials=i,this.tech_=n,this.vhs_=n.vhs,this.player_=e.player_,this.sourceType_=m,this.useCueTags_=l,this.playlistExclusionDuration=h,this.maxPlaylistRetries=R,this.enableLowInitialPlaylist=f,this.usingManagedMediaSource_=!1,this.useCueTags_&&(this.cueTagsTrack_=this.tech_.addTextTrack("metadata","ad-cues"),this.cueTagsTrack_.inBandMetadataTrackDispatchType=""),this.requestOptions_={withCredentials:i,maxPlaylistRetries:R,timeout:null},this.on("error",this.pauseLoading),this.mediaTypes_=Yx(),v&&k.ManagedMediaSource?(this.tech_.el_.disableRemotePlayback=!0,this.mediaSource=new k.ManagedMediaSource,this.usingManagedMediaSource_=!0,B.log("Using ManagedMediaSource")):k.MediaSource&&(this.mediaSource=new k.MediaSource),this.handleDurationChange_=this.handleDurationChange_.bind(this),this.handleSourceOpen_=this.handleSourceOpen_.bind(this),this.handleSourceEnded_=this.handleSourceEnded_.bind(this),this.load=this.load.bind(this),this.pause=this.pause.bind(this),this.mediaSource.addEventListener("durationchange",this.handleDurationChange_),this.mediaSource.addEventListener("sourceopen",this.handleSourceOpen_),this.mediaSource.addEventListener("sourceended",this.handleSourceEnded_),this.mediaSource.addEventListener("startstreaming",this.load),this.mediaSource.addEventListener("endstreaming",this.pause),this.seekable_=Ke(),this.hasPlayed_=!1,this.syncController_=new Ux(e),this.segmentMetadataTrack_=n.addRemoteTextTrack({kind:"metadata",label:"segment-metadata"},!1).track,this.decrypter_=new $x,this.sourceUpdater_=new Pf(this.mediaSource),this.inbandTextTracks_={},this.timelineChangeController_=new Bx,this.keyStatusMap_=new Map;const L={vhs:this.vhs_,parse708captions:e.parse708captions,useDtsForTimestampOffset:e.useDtsForTimestampOffset,captionServices:P,mediaSource:this.mediaSource,currentTime:this.tech_.currentTime.bind(this.tech_),seekable:()=>this.seekable(),seeking:()=>this.tech_.seeking(),duration:()=>this.duration(),hasPlayed:()=>this.hasPlayed_,goalBufferLength:()=>this.goalBufferLength(),bandwidth:r,syncController:this.syncController_,decrypter:this.decrypter_,sourceType:this.sourceType_,inbandTextTracks:this.inbandTextTracks_,cacheEncryptionKeys:T,sourceUpdater:this.sourceUpdater_,timelineChangeController:this.timelineChangeController_,exactManifestTimings:e.exactManifestTimings,addMetadataToTextTrack:this.addMetadataToTextTrack.bind(this)};this.mainPlaylistLoader_=this.sourceType_==="dash"?new go(t,this.vhs_,ge(this.requestOptions_,{addMetadataToTextTrack:this.addMetadataToTextTrack.bind(this)})):new ns(t,this.vhs_,ge(this.requestOptions_,{addDateRangesToTextTrack:this.addDateRangesToTextTrack_.bind(this)})),this.setupMainPlaylistLoaderListeners_(),this.mainSegmentLoader_=new To(ge(L,{segmentMetadataTrack:this.segmentMetadataTrack_,loaderType:"main"}),e),this.audioSegmentLoader_=new To(ge(L,{loaderType:"audio"}),e),this.subtitleSegmentLoader_=new Lx(ge(L,{loaderType:"vtt",featuresNativeTextTracks:this.tech_.featuresNativeTextTracks,loadVttJs:()=>new Promise((F,D)=>{function V(){n.off("vttjserror",X),F()}function X(){n.off("vttjsloaded",V),D()}n.one("vttjsloaded",V),n.one("vttjserror",X),n.addWebVttScript_()})}),e);const N=()=>this.mainSegmentLoader_.bandwidth;this.contentSteeringController_=new Qx(this.vhs_.xhr,N),this.setupSegmentLoaderListeners_(),this.bufferBasedABR&&(this.mainPlaylistLoader_.one("loadedplaylist",()=>this.startABRTimer_()),this.tech_.on("pause",()=>this.stopABRTimer_()),this.tech_.on("play",()=>this.startABRTimer_())),e1.forEach(F=>{this[F+"_"]=t1.bind(this,F)}),this.logger_=Pt("pc"),this.triggeredFmp4Usage=!1,this.tech_.preload()==="none"?(this.loadOnPlay_=()=>{this.loadOnPlay_=null,this.mainPlaylistLoader_.load()},this.tech_.one("play",this.loadOnPlay_)):this.mainPlaylistLoader_.load(),this.timeToLoadedData__=-1,this.mainAppendsToLoadedData__=-1,this.audioAppendsToLoadedData__=-1;const U=this.tech_.preload()==="none"?"play":"loadstart";this.tech_.one(U,()=>{const F=Date.now();this.tech_.one("loadeddata",()=>{this.timeToLoadedData__=Date.now()-F,this.mainAppendsToLoadedData__=this.mainSegmentLoader_.mediaAppends,this.audioAppendsToLoadedData__=this.audioSegmentLoader_.mediaAppends})})}mainAppendsToLoadedData_(){return this.mainAppendsToLoadedData__}audioAppendsToLoadedData_(){return this.audioAppendsToLoadedData__}appendsToLoadedData_(){const e=this.mainAppendsToLoadedData_(),t=this.audioAppendsToLoadedData_();return e===-1||t===-1?-1:e+t}timeToLoadedData_(){return this.timeToLoadedData__}checkABR_(e="abr"){const t=this.selectPlaylist();t&&this.shouldSwitchToMedia_(t)&&this.switchMedia_(t,e)}switchMedia_(e,t,i){const n=this.media(),r=n&&(n.id||n.uri),a=e&&(e.id||e.uri);if(r&&r!==a){this.logger_(`switch media ${r} -> ${a} from ${t}`);const l={renditionInfo:{id:a,bandwidth:e.attributes.BANDWIDTH,resolution:e.attributes.RESOLUTION,codecs:e.attributes.CODECS},cause:t};this.trigger({type:"renditionselected",metadata:l}),this.tech_.trigger({type:"usage",name:`vhs-rendition-change-${t}`})}this.mainPlaylistLoader_.media(e,i)}switchMediaForDASHContentSteering_(){["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(e=>{const t=this.mediaTypes_[e],i=t?t.activeGroup():null,n=this.contentSteeringController_.getPathway();if(i&&n){const a=(i.length?i[0].playlists:i.playlists).filter(l=>l.attributes.serviceLocation===n);a.length&&this.mediaTypes_[e].activePlaylistLoader.media(a[0])}})}startABRTimer_(){this.stopABRTimer_(),this.abrTimer_=k.setInterval(()=>this.checkABR_(),250)}stopABRTimer_(){this.tech_.scrubbing&&this.tech_.scrubbing()||(k.clearInterval(this.abrTimer_),this.abrTimer_=null)}getAudioTrackPlaylists_(){const e=this.main(),t=e&&e.playlists||[];if(!e||!e.mediaGroups||!e.mediaGroups.AUDIO)return t;const i=e.mediaGroups.AUDIO,n=Object.keys(i);let r;if(Object.keys(this.mediaTypes_.AUDIO.groups).length)r=this.mediaTypes_.AUDIO.activeTrack();else{const l=i.main||n.length&&i[n[0]];for(const h in l)if(l[h].default){r={label:h};break}}if(!r)return t;const a=[];for(const l in i)if(i[l][r.label]){const h=i[l][r.label];if(h.playlists&&h.playlists.length)a.push.apply(a,h.playlists);else if(h.uri)a.push(h);else if(e.playlists.length)for(let f=0;f<e.playlists.length;f++){const m=e.playlists[f];m.attributes&&m.attributes.AUDIO&&m.attributes.AUDIO===l&&a.push(m)}}return a.length?a:t}setupMainPlaylistLoaderListeners_(){this.mainPlaylistLoader_.on("loadedmetadata",()=>{const t=this.mainPlaylistLoader_.media(),i=t.targetDuration*1.5*1e3;co(this.mainPlaylistLoader_.main,this.mainPlaylistLoader_.media())?this.requestOptions_.timeout=0:this.requestOptions_.timeout=i,t.endList&&this.tech_.preload()!=="none"&&(this.mainSegmentLoader_.playlist(t,this.requestOptions_),this.mainSegmentLoader_.load()),Xx({sourceType:this.sourceType_,segmentLoaders:{AUDIO:this.audioSegmentLoader_,SUBTITLES:this.subtitleSegmentLoader_,main:this.mainSegmentLoader_},tech:this.tech_,requestOptions:this.requestOptions_,mainPlaylistLoader:this.mainPlaylistLoader_,vhs:this.vhs_,main:this.main(),mediaTypes:this.mediaTypes_,excludePlaylist:this.excludePlaylist.bind(this)}),this.triggerPresenceUsage_(this.main(),t),this.setupFirstPlay(),!this.mediaTypes_.AUDIO.activePlaylistLoader||this.mediaTypes_.AUDIO.activePlaylistLoader.media()?this.trigger("selectedinitialmedia"):this.mediaTypes_.AUDIO.activePlaylistLoader.one("loadedmetadata",()=>{this.trigger("selectedinitialmedia")})}),this.mainPlaylistLoader_.on("loadedplaylist",()=>{this.loadOnPlay_&&this.tech_.off("play",this.loadOnPlay_);let t=this.mainPlaylistLoader_.media();if(!t){this.attachContentSteeringListeners_(),this.initContentSteeringController_(),this.excludeUnsupportedVariants_();let i;if(this.enableLowInitialPlaylist&&(i=this.selectInitialPlaylist()),i||(i=this.selectPlaylist()),!i||!this.shouldSwitchToMedia_(i)||(this.initialMedia_=i,this.switchMedia_(this.initialMedia_,"initial"),!(this.sourceType_==="vhs-json"&&this.initialMedia_.segments)))return;t=this.initialMedia_}this.handleUpdatedMediaPlaylist(t)}),this.mainPlaylistLoader_.on("error",()=>{const t=this.mainPlaylistLoader_.error;this.excludePlaylist({playlistToExclude:t.playlist,error:t})}),this.mainPlaylistLoader_.on("mediachanging",()=>{this.mainSegmentLoader_.abort(),this.mainSegmentLoader_.pause()}),this.mainPlaylistLoader_.on("mediachange",()=>{const t=this.mainPlaylistLoader_.media(),i=t.targetDuration*1.5*1e3;co(this.mainPlaylistLoader_.main,this.mainPlaylistLoader_.media())?this.requestOptions_.timeout=0:this.requestOptions_.timeout=i,this.sourceType_==="dash"&&this.mainPlaylistLoader_.isPaused&&this.mainPlaylistLoader_.load(),this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.playlist(t,this.requestOptions_),this.waitingForFastQualityPlaylistReceived_?this.runFastQualitySwitch_():this.mainSegmentLoader_.load(),this.tech_.trigger({type:"mediachange",bubbles:!0})}),this.mainPlaylistLoader_.on("playlistunchanged",()=>{const t=this.mainPlaylistLoader_.media();if(t.lastExcludeReason_==="playlist-unchanged")return;this.stuckAtPlaylistEnd_(t)&&(this.excludePlaylist({error:{message:"Playlist no longer updating.",reason:"playlist-unchanged"}}),this.tech_.trigger("playliststuck"))}),this.mainPlaylistLoader_.on("renditiondisabled",()=>{this.tech_.trigger({type:"usage",name:"vhs-rendition-disabled"})}),this.mainPlaylistLoader_.on("renditionenabled",()=>{this.tech_.trigger({type:"usage",name:"vhs-rendition-enabled"})}),["manifestrequeststart","manifestrequestcomplete","manifestparsestart","manifestparsecomplete","playlistrequeststart","playlistrequestcomplete","playlistparsestart","playlistparsecomplete","renditiondisabled","renditionenabled"].forEach(t=>{this.mainPlaylistLoader_.on(t,i=>{this.player_.trigger(je({},i))})})}handleUpdatedMediaPlaylist(e){this.useCueTags_&&this.updateAdCues_(e),this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.playlist(e,this.requestOptions_),this.waitingForFastQualityPlaylistReceived_&&this.runFastQualitySwitch_(),this.updateDuration(!e.endList),this.tech_.paused()||(this.mainSegmentLoader_.load(),this.audioSegmentLoader_&&this.audioSegmentLoader_.load())}triggerPresenceUsage_(e,t){const i=e.mediaGroups||{};let n=!0;const r=Object.keys(i.AUDIO);for(const a in i.AUDIO)for(const l in i.AUDIO[a])i.AUDIO[a][l].uri||(n=!1);n&&this.tech_.trigger({type:"usage",name:"vhs-demuxed"}),Object.keys(i.SUBTITLES).length&&this.tech_.trigger({type:"usage",name:"vhs-webvtt"}),vi.Playlist.isAes(t)&&this.tech_.trigger({type:"usage",name:"vhs-aes"}),r.length&&Object.keys(i.AUDIO[r[0]]).length>1&&this.tech_.trigger({type:"usage",name:"vhs-alternate-audio"}),this.useCueTags_&&this.tech_.trigger({type:"usage",name:"vhs-playlist-cue-tags"})}shouldSwitchToMedia_(e){const t=this.mainPlaylistLoader_.media()||this.mainPlaylistLoader_.pendingMedia_,i=this.tech_.currentTime(),n=this.bufferLowWaterLine(),r=this.bufferHighWaterLine(),a=this.tech_.buffered();return i1({buffered:a,currentTime:i,currentPlaylist:t,nextPlaylist:e,bufferLowWaterLine:n,bufferHighWaterLine:r,duration:this.duration(),bufferBasedABR:this.bufferBasedABR,log:this.logger_})}setupSegmentLoaderListeners_(){this.mainSegmentLoader_.on("bandwidthupdate",()=>{this.checkABR_("bandwidthupdate"),this.tech_.trigger("bandwidthupdate")}),this.mainSegmentLoader_.on("timeout",()=>{this.bufferBasedABR&&this.mainSegmentLoader_.load()}),this.bufferBasedABR||this.mainSegmentLoader_.on("progress",()=>{this.trigger("progress")}),this.mainSegmentLoader_.on("error",()=>{const i=this.mainSegmentLoader_.error();this.excludePlaylist({playlistToExclude:i.playlist,error:i})}),this.mainSegmentLoader_.on("appenderror",()=>{this.error=this.mainSegmentLoader_.error_,this.trigger("error")}),this.mainSegmentLoader_.on("syncinfoupdate",()=>{this.onSyncInfoUpdate_()}),this.mainSegmentLoader_.on("timestampoffset",()=>{this.tech_.trigger({type:"usage",name:"vhs-timestamp-offset"})}),this.audioSegmentLoader_.on("syncinfoupdate",()=>{this.onSyncInfoUpdate_()}),this.audioSegmentLoader_.on("appenderror",()=>{this.error=this.audioSegmentLoader_.error_,this.trigger("error")}),this.mainSegmentLoader_.on("ended",()=>{this.logger_("main segment loader ended"),this.onEndOfStream()}),this.timelineChangeController_.on("audioTimelineBehind",()=>{const i=this.audioSegmentLoader_.pendingSegment_;if(!i||!i.segment||!i.segment.syncInfo)return;const n=i.segment.syncInfo.end+.01;this.tech_.setCurrentTime(n)}),this.timelineChangeController_.on("fixBadTimelineChange",()=>{this.logger_("Fix bad timeline change. Restarting al segment loaders..."),this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.resetEverything(),this.mediaTypes_.AUDIO.activePlaylistLoader&&(this.audioSegmentLoader_.pause(),this.audioSegmentLoader_.resetEverything()),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&(this.subtitleSegmentLoader_.pause(),this.subtitleSegmentLoader_.resetEverything()),this.load()}),this.mainSegmentLoader_.on("earlyabort",i=>{this.bufferBasedABR||(this.delegateLoaders_("all",["abort"]),this.excludePlaylist({error:{message:"Aborted early because there isn't enough bandwidth to complete the request without rebuffering."},playlistExclusionDuration:Zx}))});const e=()=>{if(!this.sourceUpdater_.hasCreatedSourceBuffers())return this.tryToCreateSourceBuffers_();const i=this.getCodecsOrExclude_();i&&this.sourceUpdater_.addOrChangeSourceBuffers(i)};this.mainSegmentLoader_.on("trackinfo",e),this.audioSegmentLoader_.on("trackinfo",e),this.mainSegmentLoader_.on("fmp4",()=>{this.triggeredFmp4Usage||(this.tech_.trigger({type:"usage",name:"vhs-fmp4"}),this.triggeredFmp4Usage=!0)}),this.audioSegmentLoader_.on("fmp4",()=>{this.triggeredFmp4Usage||(this.tech_.trigger({type:"usage",name:"vhs-fmp4"}),this.triggeredFmp4Usage=!0)}),this.audioSegmentLoader_.on("ended",()=>{this.logger_("audioSegmentLoader ended"),this.onEndOfStream()}),["segmentselected","segmentloadstart","segmentloaded","segmentkeyloadstart","segmentkeyloadcomplete","segmentdecryptionstart","segmentdecryptioncomplete","segmenttransmuxingstart","segmenttransmuxingcomplete","segmenttransmuxingtrackinfoavailable","segmenttransmuxingtiminginfoavailable","segmentappendstart","appendsdone","bandwidthupdated","timelinechange","codecschange"].forEach(i=>{this.mainSegmentLoader_.on(i,n=>{this.player_.trigger(je({},n))}),this.audioSegmentLoader_.on(i,n=>{this.player_.trigger(je({},n))}),this.subtitleSegmentLoader_.on(i,n=>{this.player_.trigger(je({},n))})})}mediaSecondsLoaded_(){return Math.max(this.audioSegmentLoader_.mediaSecondsLoaded+this.mainSegmentLoader_.mediaSecondsLoaded)}load(){this.mainSegmentLoader_.load(),this.mediaTypes_.AUDIO.activePlaylistLoader&&this.audioSegmentLoader_.load(),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&this.subtitleSegmentLoader_.load()}pause(){this.mainSegmentLoader_.pause(),this.mediaTypes_.AUDIO.activePlaylistLoader&&this.audioSegmentLoader_.pause(),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&this.subtitleSegmentLoader_.pause()}fastQualityChange_(e=this.selectPlaylist()){if(e&&e===this.mainPlaylistLoader_.media()){this.logger_("skipping fastQualityChange because new media is same as old");return}this.switchMedia_(e,"fast-quality"),this.waitingForFastQualityPlaylistReceived_=!0}runFastQualitySwitch_(){this.waitingForFastQualityPlaylistReceived_=!1,this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.resetEverything(),this.mediaTypes_.AUDIO.activePlaylistLoader&&(this.audioSegmentLoader_.pause(),this.audioSegmentLoader_.resetEverything()),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&(this.subtitleSegmentLoader_.pause(),this.subtitleSegmentLoader_.resetEverything()),this.load()}play(){if(this.setupFirstPlay())return;this.tech_.ended()&&this.tech_.setCurrentTime(0),this.hasPlayed_&&this.load();const e=this.tech_.seekable();if(this.tech_.duration()===1/0&&this.tech_.currentTime()<e.start(0))return this.tech_.setCurrentTime(e.end(e.length-1))}setupFirstPlay(){const e=this.mainPlaylistLoader_.media();if(!e||this.tech_.paused()||this.hasPlayed_)return!1;if(!e.endList||e.start){const t=this.seekable();if(!t.length)return!1;const i=t.end(0);let n=i;if(e.start){const r=e.start.timeOffset;r<0?n=Math.max(i+r,t.start(0)):n=Math.min(i,r)}this.trigger("firstplay"),this.tech_.setCurrentTime(n)}return this.hasPlayed_=!0,this.load(),!0}handleSourceOpen_(){if(this.tryToCreateSourceBuffers_(),this.tech_.autoplay()){const e=this.tech_.play();typeof e<"u"&&typeof e.then=="function"&&e.then(null,t=>{})}this.trigger("sourceopen")}handleSourceEnded_(){if(!this.inbandTextTracks_.metadataTrack_)return;const e=this.inbandTextTracks_.metadataTrack_.cues;if(!e||!e.length)return;const t=this.duration();e[e.length-1].endTime=isNaN(t)||Math.abs(t)===1/0?Number.MAX_VALUE:t}handleDurationChange_(){this.tech_.trigger("durationchange")}onEndOfStream(){let e=this.mainSegmentLoader_.ended_;if(this.mediaTypes_.AUDIO.activePlaylistLoader){const t=this.mainSegmentLoader_.getCurrentMediaInfo_();!t||t.hasVideo?e=e&&this.audioSegmentLoader_.ended_:e=this.audioSegmentLoader_.ended_}e&&(this.stopABRTimer_(),this.sourceUpdater_.endOfStream())}stuckAtPlaylistEnd_(e){if(!this.seekable().length)return!1;const i=this.syncController_.getExpiredTime(e,this.duration());if(i===null)return!1;const n=vi.Playlist.playlistEnd(e,i),r=this.tech_.currentTime(),a=this.tech_.buffered();if(!a.length)return n-r<=Yt;const l=a.end(a.length-1);return l-r<=Yt&&n-l<=Yt}excludePlaylist({playlistToExclude:e=this.mainPlaylistLoader_.media(),error:t={},playlistExclusionDuration:i}){if(e=e||this.mainPlaylistLoader_.media(),i=i||t.playlistExclusionDuration||this.playlistExclusionDuration,!e){this.error=t,this.mediaSource.readyState!=="open"?this.trigger("error"):this.sourceUpdater_.endOfStream("network");return}e.playlistErrors_++;const n=this.mainPlaylistLoader_.main.playlists,r=n.filter(na),a=r.length===1&&r[0]===e;if(n.length===1&&i!==1/0)return B.log.warn(`Problem encountered with playlist ${e.id}. Trying again since it is the only playlist.`),this.tech_.trigger("retryplaylist"),this.mainPlaylistLoader_.load(a);if(a){if(this.main().contentSteering){const P=this.pathwayAttribute_(e),v=this.contentSteeringController_.steeringManifest.ttl*1e3;this.contentSteeringController_.excludePathway(P),this.excludeThenChangePathway_(),setTimeout(()=>{this.contentSteeringController_.addAvailablePathway(P)},v);return}let C=!1;n.forEach(P=>{if(P===e)return;const v=P.excludeUntil;typeof v<"u"&&v!==1/0&&(C=!0,delete P.excludeUntil)}),C&&(B.log.warn("Removing other playlists from the exclusion list because the last rendition is about to be excluded."),this.tech_.trigger("retryplaylist"))}let l;e.playlistErrors_>this.maxPlaylistRetries?l=1/0:l=Date.now()+i*1e3,e.excludeUntil=l,t.reason&&(e.lastExcludeReason_=t.reason),this.tech_.trigger("excludeplaylist"),this.tech_.trigger({type:"usage",name:"vhs-rendition-excluded"});const h=this.selectPlaylist();if(!h){this.error="Playback cannot continue. No available working or supported playlists.",this.trigger("error");return}const f=t.internal?this.logger_:B.log.warn,m=t.message?" "+t.message:"";f(`${t.internal?"Internal problem":"Problem"} encountered with playlist ${e.id}.${m} Switching to playlist ${h.id}.`),h.attributes.AUDIO!==e.attributes.AUDIO&&this.delegateLoaders_("audio",["abort","pause"]),h.attributes.SUBTITLES!==e.attributes.SUBTITLES&&this.delegateLoaders_("subtitle",["abort","pause"]),this.delegateLoaders_("main",["abort","pause"]);const T=h.targetDuration/2*1e3||5*1e3,E=typeof h.lastRequest=="number"&&Date.now()-h.lastRequest<=T;return this.switchMedia_(h,"exclude",a||E)}pauseLoading(){this.delegateLoaders_("all",["abort","pause"]),this.stopABRTimer_()}delegateLoaders_(e,t){const i=[],n=e==="all";(n||e==="main")&&i.push(this.mainPlaylistLoader_);const r=[];(n||e==="audio")&&r.push("AUDIO"),(n||e==="subtitle")&&(r.push("CLOSED-CAPTIONS"),r.push("SUBTITLES")),r.forEach(a=>{const l=this.mediaTypes_[a]&&this.mediaTypes_[a].activePlaylistLoader;l&&i.push(l)}),["main","audio","subtitle"].forEach(a=>{const l=this[`${a}SegmentLoader_`];l&&(e===a||e==="all")&&i.push(l)}),i.forEach(a=>t.forEach(l=>{typeof a[l]=="function"&&a[l]()}))}setCurrentTime(e){const t=ss(this.tech_.buffered(),e);if(!(this.mainPlaylistLoader_&&this.mainPlaylistLoader_.media())||!this.mainPlaylistLoader_.media().segments)return 0;if(t&&t.length)return e;this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.resetEverything(),this.mediaTypes_.AUDIO.activePlaylistLoader&&(this.audioSegmentLoader_.pause(),this.audioSegmentLoader_.resetEverything()),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&(this.subtitleSegmentLoader_.pause(),this.subtitleSegmentLoader_.resetEverything()),this.load()}duration(){if(!this.mainPlaylistLoader_)return 0;const e=this.mainPlaylistLoader_.media();return e?e.endList?this.mediaSource?this.mediaSource.duration:vi.Playlist.duration(e):1/0:0}seekable(){return this.seekable_}getSeekableRange_(e,t){const i=e.media();if(!i)return null;const n=this.syncController_.getMediaSequenceSync(t);if(n&&n.isReliable){const l=n.start,h=n.end;if(!isFinite(l)||!isFinite(h))return null;const f=vi.Playlist.liveEdgeDelay(this.mainPlaylistLoader_.main,i),m=Math.max(0,h-f);return m<l?null:Ke([[l,m]])}const r=this.syncController_.getExpiredTime(i,this.duration());if(r===null)return null;const a=vi.Playlist.seekable(i,r,vi.Playlist.liveEdgeDelay(this.mainPlaylistLoader_.main,i));return a.length?a:null}computeFinalSeekable_(e,t){if(!t)return e;const i=e.start(0),n=e.end(0),r=t.start(0),a=t.end(0);return r>n||i>a?e:Ke([[Math.max(i,r),Math.min(n,a)]])}onSyncInfoUpdate_(){if(!this.mainPlaylistLoader_)return;const e=this.getSeekableRange_(this.mainPlaylistLoader_,"main");if(!e)return;let t;if(this.mediaTypes_.AUDIO.activePlaylistLoader&&(t=this.getSeekableRange_(this.mediaTypes_.AUDIO.activePlaylistLoader,"audio"),!t))return;const i=this.seekable_;if(this.seekable_=this.computeFinalSeekable_(e,t),!this.seekable_||i&&i.length&&this.seekable_.length&&i.start(0)===this.seekable_.start(0)&&i.end(0)===this.seekable_.end(0))return;this.logger_(`seekable updated [${Hh(this.seekable_)}]`);const n={seekableRanges:this.seekable_};this.trigger({type:"seekablerangeschanged",metadata:n}),this.tech_.trigger("seekablechanged")}updateDuration(e){if(this.updateDuration_&&(this.mediaSource.removeEventListener("sourceopen",this.updateDuration_),this.updateDuration_=null),this.mediaSource.readyState!=="open"){this.updateDuration_=this.updateDuration.bind(this,e),this.mediaSource.addEventListener("sourceopen",this.updateDuration_);return}if(e){const n=this.seekable();if(!n.length)return;(isNaN(this.mediaSource.duration)||this.mediaSource.duration<n.end(n.length-1))&&this.sourceUpdater_.setDuration(n.end(n.length-1));return}const t=this.tech_.buffered();let i=vi.Playlist.duration(this.mainPlaylistLoader_.media());t.length>0&&(i=Math.max(i,t.end(t.length-1))),this.mediaSource.duration!==i&&this.sourceUpdater_.setDuration(i)}dispose(){this.trigger("dispose"),this.decrypter_.terminate(),this.mainPlaylistLoader_.dispose(),this.mainSegmentLoader_.dispose(),this.contentSteeringController_.dispose(),this.keyStatusMap_.clear(),this.loadOnPlay_&&this.tech_.off("play",this.loadOnPlay_),["AUDIO","SUBTITLES"].forEach(e=>{const t=this.mediaTypes_[e].groups;for(const i in t)t[i].forEach(n=>{n.playlistLoader&&n.playlistLoader.dispose()})}),this.audioSegmentLoader_.dispose(),this.subtitleSegmentLoader_.dispose(),this.sourceUpdater_.dispose(),this.timelineChangeController_.dispose(),this.stopABRTimer_(),this.updateDuration_&&this.mediaSource.removeEventListener("sourceopen",this.updateDuration_),this.mediaSource.removeEventListener("durationchange",this.handleDurationChange_),this.mediaSource.removeEventListener("sourceopen",this.handleSourceOpen_),this.mediaSource.removeEventListener("sourceended",this.handleSourceEnded_),this.off()}main(){return this.mainPlaylistLoader_.main}media(){return this.mainPlaylistLoader_.media()||this.initialMedia_}areMediaTypesKnown_(){const e=!!this.mediaTypes_.AUDIO.activePlaylistLoader,t=!!this.mainSegmentLoader_.getCurrentMediaInfo_(),i=e?!!this.audioSegmentLoader_.getCurrentMediaInfo_():!0;return!(!t||!i)}getCodecsOrExclude_(){const e={main:this.mainSegmentLoader_.getCurrentMediaInfo_()||{},audio:this.audioSegmentLoader_.getCurrentMediaInfo_()||{}},t=this.mainSegmentLoader_.getPendingSegmentPlaylist()||this.media();e.video=e.main;const i=gn(this.main(),t),n={},r=!!this.mediaTypes_.AUDIO.activePlaylistLoader;if(e.main.hasVideo&&(n.video=i.video||e.main.videoCodec||Gy),e.main.isMuxed&&(n.video+=`,${i.audio||e.main.audioCodec||bu}`),(e.main.hasAudio&&!e.main.isMuxed||e.audio.hasAudio||r)&&(n.audio=i.audio||e.main.audioCodec||e.audio.audioCodec||bu,e.audio.isFmp4=e.main.hasAudio&&!e.main.isMuxed?e.main.isFmp4:e.audio.isFmp4),!n.audio&&!n.video){this.excludePlaylist({playlistToExclude:t,error:{message:"Could not determine codecs for playlist."},playlistExclusionDuration:1/0});return}const a=(f,m)=>f?dn(m,this.usingManagedMediaSource_):La(m),l={};let h;if(["video","audio"].forEach(function(f){if(n.hasOwnProperty(f)&&!a(e[f].isFmp4,n[f])){const m=e[f].isFmp4?"browser":"muxer";l[m]=l[m]||[],l[m].push(n[f]),f==="audio"&&(h=m)}}),r&&h&&t.attributes.AUDIO){const f=t.attributes.AUDIO;this.main().playlists.forEach(m=>{(m.attributes&&m.attributes.AUDIO)===f&&m!==t&&(m.excludeUntil=1/0)}),this.logger_(`excluding audio group ${f} as ${h} does not support codec(s): "${n.audio}"`)}if(Object.keys(l).length){const f=Object.keys(l).reduce((m,T)=>(m&&(m+=", "),m+=`${T} does not support codec(s): "${l[T].join(",")}"`,m),"")+".";this.excludePlaylist({playlistToExclude:t,error:{internal:!0,message:f},playlistExclusionDuration:1/0});return}if(this.sourceUpdater_.hasCreatedSourceBuffers()&&!this.sourceUpdater_.canChangeType()){const f=[];if(["video","audio"].forEach(m=>{const T=(zt(this.sourceUpdater_.codecs[m]||"")[0]||{}).type,E=(zt(n[m]||"")[0]||{}).type;T&&E&&T.toLowerCase()!==E.toLowerCase()&&f.push(`"${this.sourceUpdater_.codecs[m]}" -> "${n[m]}"`)}),f.length){this.excludePlaylist({playlistToExclude:t,error:{message:`Codec switching not supported: ${f.join(", ")}.`,internal:!0},playlistExclusionDuration:1/0});return}}return n}tryToCreateSourceBuffers_(){if(this.mediaSource.readyState!=="open"||this.sourceUpdater_.hasCreatedSourceBuffers()||!this.areMediaTypesKnown_())return;const e=this.getCodecsOrExclude_();if(!e)return;this.sourceUpdater_.createSourceBuffers(e);const t=[e.video,e.audio].filter(Boolean).join(",");this.excludeIncompatibleVariants_(t)}excludeUnsupportedVariants_(){const e=this.main().playlists,t=[];Object.keys(e).forEach(i=>{const n=e[i];if(t.indexOf(n.id)!==-1)return;t.push(n.id);const r=gn(this.main,n),a=[];r.audio&&!La(r.audio)&&!dn(r.audio,this.usingManagedMediaSource_)&&a.push(`audio codec ${r.audio}`),r.video&&!La(r.video)&&!dn(r.video,this.usingManagedMediaSource_)&&a.push(`video codec ${r.video}`),r.text&&r.text==="stpp.ttml.im1t"&&a.push(`text codec ${r.text}`),a.length&&(n.excludeUntil=1/0,this.logger_(`excluding ${n.id} for unsupported: ${a.join(", ")}`))})}excludeIncompatibleVariants_(e){const t=[],i=this.main().playlists,n=kr(zt(e)),r=fc(n),a=n.video&&zt(n.video)[0]||null,l=n.audio&&zt(n.audio)[0]||null;Object.keys(i).forEach(h=>{const f=i[h];if(t.indexOf(f.id)!==-1||f.excludeUntil===1/0)return;t.push(f.id);const m=[],T=gn(this.mainPlaylistLoader_.main,f),E=fc(T);if(!(!T.audio&&!T.video)){if(E!==r&&m.push(`codec count "${E}" !== "${r}"`),!this.sourceUpdater_.canChangeType()){const C=T.video&&zt(T.video)[0]||null,P=T.audio&&zt(T.audio)[0]||null;C&&a&&C.type.toLowerCase()!==a.type.toLowerCase()&&m.push(`video codec "${C.type}" !== "${a.type}"`),P&&l&&P.type.toLowerCase()!==l.type.toLowerCase()&&m.push(`audio codec "${P.type}" !== "${l.type}"`)}m.length&&(f.excludeUntil=1/0,this.logger_(`excluding ${f.id}: ${m.join(" && ")}`))}})}updateAdCues_(e){let t=0;const i=this.seekable();i.length&&(t=i.start(0)),Rx(e,this.cueTagsTrack_,t)}goalBufferLength(){const e=this.tech_.currentTime(),t=We.GOAL_BUFFER_LENGTH,i=We.GOAL_BUFFER_LENGTH_RATE,n=Math.max(t,We.MAX_GOAL_BUFFER_LENGTH);return Math.min(t+e*i,n)}bufferLowWaterLine(){const e=this.tech_.currentTime(),t=We.BUFFER_LOW_WATER_LINE,i=We.BUFFER_LOW_WATER_LINE_RATE,n=Math.max(t,We.MAX_BUFFER_LOW_WATER_LINE),r=Math.max(t,We.EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE);return Math.min(t+e*i,this.bufferBasedABR?r:n)}bufferHighWaterLine(){return We.BUFFER_HIGH_WATER_LINE}addDateRangesToTextTrack_(e){gc(this.inbandTextTracks_,"com.apple.streaming",this.tech_),fx({inbandTextTracks:this.inbandTextTracks_,dateRanges:e})}addMetadataToTextTrack(e,t,i){const n=this.sourceUpdater_.videoBuffer?this.sourceUpdater_.videoTimestampOffset():this.sourceUpdater_.audioTimestampOffset();gc(this.inbandTextTracks_,e,this.tech_),cx({inbandTextTracks:this.inbandTextTracks_,metadataArray:t,timestampOffset:n,videoDuration:i})}pathwayAttribute_(e){return e.attributes["PATHWAY-ID"]||e.attributes.serviceLocation}initContentSteeringController_(){const e=this.main();if(e.contentSteering){for(const t of e.playlists)this.contentSteeringController_.addAvailablePathway(this.pathwayAttribute_(t));if(this.contentSteeringController_.assignTagProperties(e.uri,e.contentSteering),this.contentSteeringController_.queryBeforeStart){this.contentSteeringController_.requestSteeringManifest(!0);return}this.tech_.one("canplay",()=>{this.contentSteeringController_.requestSteeringManifest()})}}resetContentSteeringController_(){this.contentSteeringController_.clearAvailablePathways(),this.contentSteeringController_.dispose(),this.initContentSteeringController_()}attachContentSteeringListeners_(){this.contentSteeringController_.on("content-steering",this.excludeThenChangePathway_.bind(this)),["contentsteeringloadstart","contentsteeringloadcomplete","contentsteeringparsed"].forEach(t=>{this.contentSteeringController_.on(t,i=>{this.trigger(je({},i))})}),this.sourceType_==="dash"&&this.mainPlaylistLoader_.on("loadedplaylist",()=>{const t=this.main();(this.contentSteeringController_.didDASHTagChange(t.uri,t.contentSteering)||(()=>{const r=this.contentSteeringController_.getAvailablePathways(),a=[];for(const l of t.playlists){const h=l.attributes.serviceLocation;if(h&&(a.push(h),!r.has(h)))return!0}return!!(!a.length&&r.size)})())&&this.resetContentSteeringController_()})}excludeThenChangePathway_(){const e=this.contentSteeringController_.getPathway();if(!e)return;this.handlePathwayClones_();const i=this.main().playlists,n=new Set;let r=!1;Object.keys(i).forEach(a=>{const l=i[a],h=this.pathwayAttribute_(l),f=h&&e!==h;l.excludeUntil===1/0&&l.lastExcludeReason_==="content-steering"&&!f&&(delete l.excludeUntil,delete l.lastExcludeReason_,r=!0);const T=!l.excludeUntil&&l.excludeUntil!==1/0;!n.has(l.id)&&f&&T&&(n.add(l.id),l.excludeUntil=1/0,l.lastExcludeReason_="content-steering",this.logger_(`excluding ${l.id} for ${l.lastExcludeReason_}`))}),this.contentSteeringController_.manifestType_==="DASH"&&Object.keys(this.mediaTypes_).forEach(a=>{const l=this.mediaTypes_[a];if(l.activePlaylistLoader){const h=l.activePlaylistLoader.media_;h&&h.attributes.serviceLocation!==e&&(r=!0)}}),r&&this.changeSegmentPathway_()}handlePathwayClones_(){const t=this.main().playlists,i=this.contentSteeringController_.currentPathwayClones,n=this.contentSteeringController_.nextPathwayClones;if(i&&i.size||n&&n.size){for(const[a,l]of i.entries())n.get(a)||(this.mainPlaylistLoader_.updateOrDeleteClone(l),this.contentSteeringController_.excludePathway(a));for(const[a,l]of n.entries()){const h=i.get(a);if(!h){t.filter(m=>m.attributes["PATHWAY-ID"]===l["BASE-ID"]).forEach(m=>{this.mainPlaylistLoader_.addClonePathway(l,m)}),this.contentSteeringController_.addAvailablePathway(a);continue}this.equalPathwayClones_(h,l)||(this.mainPlaylistLoader_.updateOrDeleteClone(l,!0),this.contentSteeringController_.addAvailablePathway(a))}this.contentSteeringController_.currentPathwayClones=new Map(JSON.parse(JSON.stringify([...n])))}}equalPathwayClones_(e,t){if(e["BASE-ID"]!==t["BASE-ID"]||e.ID!==t.ID||e["URI-REPLACEMENT"].HOST!==t["URI-REPLACEMENT"].HOST)return!1;const i=e["URI-REPLACEMENT"].PARAMS,n=t["URI-REPLACEMENT"].PARAMS;for(const r in i)if(i[r]!==n[r])return!1;for(const r in n)if(i[r]!==n[r])return!1;return!0}changeSegmentPathway_(){const e=this.selectPlaylist();this.pauseLoading(),this.contentSteeringController_.manifestType_==="DASH"&&this.switchMediaForDASHContentSteering_(),this.switchMedia_(e,"content-steering")}excludeNonUsablePlaylistsByKeyId_(){if(!this.mainPlaylistLoader_||!this.mainPlaylistLoader_.main)return;let e=0;const t="non-usable";this.mainPlaylistLoader_.main.playlists.forEach(i=>{const n=this.mainPlaylistLoader_.getKeyIdSet(i);!n||!n.size||n.forEach(r=>{const a="usable",l=this.keyStatusMap_.has(r)&&this.keyStatusMap_.get(r)===a,h=i.lastExcludeReason_===t&&i.excludeUntil===1/0;l?l&&h&&(delete i.excludeUntil,delete i.lastExcludeReason_,this.logger_(`enabling playlist ${i.id} because key ID ${r} is ${a}`)):(i.excludeUntil!==1/0&&i.lastExcludeReason_!==t&&(i.excludeUntil=1/0,i.lastExcludeReason_=t,this.logger_(`excluding playlist ${i.id} because the key ID ${r} doesn't exist in the keyStatusMap or is not ${a}`)),e++)})}),e>=this.mainPlaylistLoader_.main.playlists.length&&this.mainPlaylistLoader_.main.playlists.forEach(i=>{const n=i&&i.attributes&&i.attributes.RESOLUTION&&i.attributes.RESOLUTION.height<720,r=i.excludeUntil===1/0&&i.lastExcludeReason_===t;n&&r&&(delete i.excludeUntil,B.log.warn(`enabling non-HD playlist ${i.id} because all playlists were excluded due to ${t} key IDs`))})}addKeyStatus_(e,t){const r=(typeof e=="string"?e:Px(e)).slice(0,32).toLowerCase();this.logger_(`KeyStatus '${t}' with key ID ${r} added to the keyStatusMap`),this.keyStatusMap_.set(r,t)}updatePlaylistByKeyStatus(e,t){this.addKeyStatus_(e,t),this.waitingForFastQualityPlaylistReceived_||this.excludeNonUsableThenChangePlaylist_(),this.mainPlaylistLoader_.off("loadedplaylist",this.excludeNonUsableThenChangePlaylist_.bind(this)),this.mainPlaylistLoader_.on("loadedplaylist",this.excludeNonUsableThenChangePlaylist_.bind(this))}excludeNonUsableThenChangePlaylist_(){this.excludeNonUsablePlaylistsByKeyId_(),this.fastQualityChange_()}}const n1=(s,e,t)=>i=>{const n=s.main.playlists[e],r=dl(n),a=na(n);if(typeof i>"u")return a;i?delete n.disabled:n.disabled=!0;const l={renditionInfo:{id:e,bandwidth:n.attributes.BANDWIDTH,resolution:n.attributes.RESOLUTION,codecs:n.attributes.CODECS},cause:"fast-quality"};return i!==a&&!r&&(i?(t(n),s.trigger({type:"renditionenabled",metadata:l})):s.trigger({type:"renditiondisabled",metadata:l})),i};class r1{constructor(e,t,i){const{playlistController_:n}=e,r=n.fastQualityChange_.bind(n);if(t.attributes){const a=t.attributes.RESOLUTION;this.width=a&&a.width,this.height=a&&a.height,this.bandwidth=t.attributes.BANDWIDTH,this.frameRate=t.attributes["FRAME-RATE"]}this.codecs=gn(n.main(),t),this.playlist=t,this.id=i,this.enabled=n1(e.playlists,t.id,r)}}const a1=function(s){s.representations=()=>{const e=s.playlistController_.main(),t=wn(e)?s.playlistController_.getAudioTrackPlaylists_():e.playlists;return t?t.filter(i=>!dl(i)).map((i,n)=>new r1(s,i,i.id)):[]}},Ic=["seeking","seeked","pause","playing","error"];class o1 extends B.EventTarget{constructor(e){super(),this.playlistController_=e.playlistController,this.tech_=e.tech,this.seekable=e.seekable,this.allowSeeksWithinUnsafeLiveWindow=e.allowSeeksWithinUnsafeLiveWindow,this.liveRangeSafeTimeDelta=e.liveRangeSafeTimeDelta,this.media=e.media,this.playedRanges_=[],this.consecutiveUpdates=0,this.lastRecordedTime=null,this.checkCurrentTimeTimeout_=null,this.logger_=Pt("PlaybackWatcher"),this.logger_("initialize");const t=()=>this.monitorCurrentTime_(),i=()=>this.monitorCurrentTime_(),n=()=>this.techWaiting_(),r=()=>this.resetTimeUpdate_(),a=this.playlistController_,l=["main","subtitle","audio"],h={};l.forEach(m=>{h[m]={reset:()=>this.resetSegmentDownloads_(m),updateend:()=>this.checkSegmentDownloads_(m)},a[`${m}SegmentLoader_`].on("appendsdone",h[m].updateend),a[`${m}SegmentLoader_`].on("playlistupdate",h[m].reset),this.tech_.on(["seeked","seeking"],h[m].reset)});const f=m=>{["main","audio"].forEach(T=>{a[`${T}SegmentLoader_`][m]("appended",this.seekingAppendCheck_)})};this.seekingAppendCheck_=()=>{this.fixesBadSeeks_()&&(this.consecutiveUpdates=0,this.lastRecordedTime=this.tech_.currentTime(),f("off"))},this.clearSeekingAppendCheck_=()=>f("off"),this.watchForBadSeeking_=()=>{this.clearSeekingAppendCheck_(),f("on")},this.tech_.on("seeked",this.clearSeekingAppendCheck_),this.tech_.on("seeking",this.watchForBadSeeking_),this.tech_.on("waiting",n),this.tech_.on(Ic,r),this.tech_.on("canplay",i),this.tech_.one("play",t),this.dispose=()=>{this.clearSeekingAppendCheck_(),this.logger_("dispose"),this.tech_.off("waiting",n),this.tech_.off(Ic,r),this.tech_.off("canplay",i),this.tech_.off("play",t),this.tech_.off("seeking",this.watchForBadSeeking_),this.tech_.off("seeked",this.clearSeekingAppendCheck_),l.forEach(m=>{a[`${m}SegmentLoader_`].off("appendsdone",h[m].updateend),a[`${m}SegmentLoader_`].off("playlistupdate",h[m].reset),this.tech_.off(["seeked","seeking"],h[m].reset)}),this.checkCurrentTimeTimeout_&&k.clearTimeout(this.checkCurrentTimeTimeout_),this.resetTimeUpdate_()}}monitorCurrentTime_(){this.checkCurrentTime_(),this.checkCurrentTimeTimeout_&&k.clearTimeout(this.checkCurrentTimeTimeout_),this.checkCurrentTimeTimeout_=k.setTimeout(this.monitorCurrentTime_.bind(this),250)}resetSegmentDownloads_(e){const t=this.playlistController_[`${e}SegmentLoader_`];this[`${e}StalledDownloads_`]>0&&this.logger_(`resetting possible stalled download count for ${e} loader`),this[`${e}StalledDownloads_`]=0,this[`${e}Buffered_`]=t.buffered_()}checkSegmentDownloads_(e){const t=this.playlistController_,i=t[`${e}SegmentLoader_`],n=i.buffered_(),r=zv(this[`${e}Buffered_`],n);if(this[`${e}Buffered_`]=n,r){const a={bufferedRanges:n};t.trigger({type:"bufferedrangeschanged",metadata:a}),this.resetSegmentDownloads_(e);return}this[`${e}StalledDownloads_`]++,this.logger_(`found #${this[`${e}StalledDownloads_`]} ${e} appends that did not increase buffer (possible stalled download)`,{playlistId:i.playlist_&&i.playlist_.id,buffered:Ui(n)}),!(this[`${e}StalledDownloads_`]<10)&&(this.logger_(`${e} loader stalled download exclusion`),this.resetSegmentDownloads_(e),this.tech_.trigger({type:"usage",name:`vhs-${e}-download-exclusion`}),e!=="subtitle"&&t.excludePlaylist({error:{message:`Excessive ${e} segment downloading detected.`},playlistExclusionDuration:1/0}))}checkCurrentTime_(){if(this.tech_.paused()||this.tech_.seeking())return;const e=this.tech_.currentTime(),t=this.tech_.buffered();if(this.lastRecordedTime===e&&(!t.length||e+Yt>=t.end(t.length-1)))return this.techWaiting_();if(this.consecutiveUpdates>=5&&e===this.lastRecordedTime)this.consecutiveUpdates++,this.waiting_();else if(e===this.lastRecordedTime)this.consecutiveUpdates++;else{this.playedRanges_.push(Ke([this.lastRecordedTime,e]));const i={playedRanges:this.playedRanges_};this.playlistController_.trigger({type:"playedrangeschanged",metadata:i}),this.consecutiveUpdates=0,this.lastRecordedTime=e}}resetTimeUpdate_(){this.consecutiveUpdates=0}fixesBadSeeks_(){if(!this.tech_.seeking())return!1;const t=this.seekable(),i=this.tech_.currentTime(),n=this.afterSeekableWindow_(t,i,this.media(),this.allowSeeksWithinUnsafeLiveWindow);let r;if(n&&(r=t.end(t.length-1)),this.beforeSeekableWindow_(t,i)){const P=t.start(0);r=P+(P===t.end(0)?0:Yt)}if(typeof r<"u")return this.logger_(`Trying to seek outside of seekable at time ${i} with seekable range ${Hh(t)}. Seeking to ${r}.`),this.tech_.setCurrentTime(r),!0;const a=this.playlistController_.sourceUpdater_,l=this.tech_.buffered(),h=a.audioBuffer?a.audioBuffered():null,f=a.videoBuffer?a.videoBuffered():null,m=this.media(),T=m.partTargetDuration?m.partTargetDuration:(m.targetDuration-Xt)*2,E=[h,f];for(let P=0;P<E.length;P++){if(!E[P])continue;if(ul(E[P],i)<T)return!1}const C=sr(l,i);return C.length===0?!1:(r=C.start(0)+Yt,this.logger_(`Buffered region starts (${C.start(0)}) just beyond seek point (${i}). Seeking to ${r}.`),this.tech_.setCurrentTime(r),!0)}waiting_(){if(this.techWaiting_())return;const e=this.tech_.currentTime(),t=this.tech_.buffered(),i=ss(t,e);if(i.length&&e+3<=i.end(0)){this.resetTimeUpdate_(),this.tech_.setCurrentTime(e),this.logger_(`Stopped at ${e} while inside a buffered region [${i.start(0)} -> ${i.end(0)}]. Attempting to resume playback by seeking to the current time.`),this.tech_.trigger({type:"usage",name:"vhs-unknown-waiting"});return}}techWaiting_(){const e=this.seekable(),t=this.tech_.currentTime();if(this.tech_.seeking())return!0;if(this.beforeSeekableWindow_(e,t)){const l=e.end(e.length-1);return this.logger_(`Fell out of live window at time ${t}. Seeking to live point (seekable end) ${l}`),this.resetTimeUpdate_(),this.tech_.setCurrentTime(l),this.tech_.trigger({type:"usage",name:"vhs-live-resync"}),!0}const i=this.tech_.vhs.playlistController_.sourceUpdater_,n=this.tech_.buffered();if(this.videoUnderflow_({audioBuffered:i.audioBuffered(),videoBuffered:i.videoBuffered(),currentTime:t}))return this.resetTimeUpdate_(),this.tech_.setCurrentTime(t),this.tech_.trigger({type:"usage",name:"vhs-video-underflow"}),!0;const a=sr(n,t);return a.length>0?(this.logger_(`Stopped at ${t} and seeking to ${a.start(0)}`),this.resetTimeUpdate_(),this.skipTheGap_(t),!0):!1}afterSeekableWindow_(e,t,i,n=!1){if(!e.length)return!1;let r=e.end(e.length-1)+Yt;const a=!i.endList,l=typeof i.partTargetDuration=="number";return a&&(l||n)&&(r=e.end(e.length-1)+i.targetDuration*3),t>r}beforeSeekableWindow_(e,t){return!!(e.length&&e.start(0)>0&&t<e.start(0)-this.liveRangeSafeTimeDelta)}videoUnderflow_({videoBuffered:e,audioBuffered:t,currentTime:i}){if(!e)return;let n;if(e.length&&t.length){const r=ss(e,i-3),a=ss(e,i),l=ss(t,i);l.length&&!a.length&&r.length&&(n={start:r.end(0),end:l.end(0)})}else sr(e,i).length||(n=this.gapFromVideoUnderflow_(e,i));return n?(this.logger_(`Encountered a gap in video from ${n.start} to ${n.end}. Seeking to current time ${i}`),!0):!1}skipTheGap_(e){const t=this.tech_.buffered(),i=this.tech_.currentTime(),n=sr(t,i);if(this.resetTimeUpdate_(),n.length===0||i!==e)return;this.logger_("skipTheGap_:","currentTime:",i,"scheduled currentTime:",e,"nextRange start:",n.start(0)),this.tech_.setCurrentTime(n.start(0)+Xt);const r={gapInfo:{from:i,to:n.start(0)}};this.playlistController_.trigger({type:"gapjumped",metadata:r}),this.tech_.trigger({type:"usage",name:"vhs-gap-skip"})}gapFromVideoUnderflow_(e,t){const i=Vv(e);for(let n=0;n<i.length;n++){const r=i.start(n),a=i.end(n);if(t-r<4&&t-r>2)return{start:r,end:a}}return null}}const l1={errorInterval:30,getSource(s){const t=this.tech({IWillNotUseThisInPlugins:!0}).currentSource_||this.currentSource();return s(t)}},Rf=function(s,e){let t=0,i=0;const n=ge(l1,e);s.ready(()=>{s.trigger({type:"usage",name:"vhs-error-reload-initialized"})});const r=function(){i&&s.currentTime(i)},a=function(m){m!=null&&(i=s.duration()!==1/0&&s.currentTime()||0,s.one("loadedmetadata",r),s.src(m),s.trigger({type:"usage",name:"vhs-error-reload"}),s.play())},l=function(){if(Date.now()-t<n.errorInterval*1e3){s.trigger({type:"usage",name:"vhs-error-reload-canceled"});return}if(!n.getSource||typeof n.getSource!="function"){B.log.error("ERROR: reloadSourceOnError - The option getSource must be a function!");return}return t=Date.now(),n.getSource.call(s,a)},h=function(){s.off("loadedmetadata",r),s.off("error",l),s.off("dispose",h)},f=function(m){h(),Rf(s,m)};s.on("error",l),s.on("dispose",h),s.reloadSourceOnError=f},u1=function(s){Rf(this,s)};var Mf="3.16.2",c1="7.1.0",d1="1.3.1",h1="7.2.0",f1="4.0.2";const Me={PlaylistLoader:ns,Playlist:ht,utils:mb,STANDARD_PLAYLIST_SELECTOR:mc,INITIAL_PLAYLIST_SELECTOR:rx,lastBandwidthSelector:mc,movingAverageBandwidthSelector:sx,comparePlaylistBandwidth:pl,comparePlaylistResolution:ix,xhr:of()};Object.keys(We).forEach(s=>{Object.defineProperty(Me,s,{get(){return B.log.warn(`using Vhs.${s} is UNSAFE be sure you know what you are doing`),We[s]},set(e){if(B.log.warn(`using Vhs.${s} is UNSAFE be sure you know what you are doing`),typeof e!="number"||e<0){B.log.warn(`value of Vhs.${s} must be greater than or equal to 0`);return}We[s]=e}})});const Nf="videojs-vhs",Uf=function(s,e){const t=e.media();let i=-1;for(let n=0;n<s.length;n++)if(s[n].id===t.id){i=n;break}s.selectedIndex_=i,s.trigger({selectedIndex:i,type:"change"})},p1=function(s,e){e.representations().forEach(t=>{s.addQualityLevel(t)}),Uf(s,e.playlists)};Me.canPlaySource=function(){return B.log.warn("VHS is no longer a tech. Please remove it from your player's techOrder.")};const m1=(s,e,t)=>{if(!s)return s;let i={};e&&e.attributes&&e.attributes.CODECS&&(i=kr(zt(e.attributes.CODECS))),t&&t.attributes&&t.attributes.CODECS&&(i.audio=t.attributes.CODECS);const n=fs(i.video),r=fs(i.audio),a={};for(const l in s)a[l]={},r&&(a[l].audioContentType=r),n&&(a[l].videoContentType=n),e.contentProtection&&e.contentProtection[l]&&e.contentProtection[l].pssh&&(a[l].pssh=e.contentProtection[l].pssh),typeof s[l]=="string"&&(a[l].url=s[l]);return ge(s,a)},g1=(s,e)=>s.reduce((t,i)=>{if(!i.contentProtection)return t;const n=e.reduce((r,a)=>{const l=i.contentProtection[a];return l&&l.pssh&&(r[a]={pssh:l.pssh}),r},{});return Object.keys(n).length&&t.push(n),t},[]),y1=({player:s,sourceKeySystems:e,audioMedia:t,mainPlaylists:i})=>{if(!s.eme.initializeMediaKeys)return Promise.resolve();const n=t?i.concat([t]):i,r=g1(n,Object.keys(e)),a=[],l=[];return r.forEach(h=>{l.push(new Promise((f,m)=>{s.tech_.one("keysessioncreated",f)})),a.push(new Promise((f,m)=>{s.eme.initializeMediaKeys({keySystems:h},T=>{if(T){m(T);return}f()})}))}),Promise.race([Promise.all(a),Promise.race(l)])},_1=({player:s,sourceKeySystems:e,media:t,audioMedia:i})=>{const n=m1(e,t,i);return n?(s.currentSource().keySystems=n,n&&!s.eme?(B.log.warn("DRM encrypted source cannot be decrypted without a DRM plugin"),!1):!0):!1},Bf=()=>{if(!k.localStorage)return null;const s=k.localStorage.getItem(Nf);if(!s)return null;try{return JSON.parse(s)}catch{return null}},T1=s=>{if(!k.localStorage)return!1;let e=Bf();e=e?ge(e,s):s;try{k.localStorage.setItem(Nf,JSON.stringify(e))}catch{return!1}return e},v1=s=>s.toLowerCase().indexOf("data:application/vnd.videojs.vhs+json,")===0?JSON.parse(s.substring(s.indexOf(",")+1)):s,Ff=(s,e)=>{s._requestCallbackSet||(s._requestCallbackSet=new Set),s._requestCallbackSet.add(e)},$f=(s,e)=>{s._responseCallbackSet||(s._responseCallbackSet=new Set),s._responseCallbackSet.add(e)},jf=(s,e)=>{s._requestCallbackSet&&(s._requestCallbackSet.delete(e),s._requestCallbackSet.size||delete s._requestCallbackSet)},Vf=(s,e)=>{s._responseCallbackSet&&(s._responseCallbackSet.delete(e),s._responseCallbackSet.size||delete s._responseCallbackSet)};Me.supportsNativeHls=function(){if(!K||!K.createElement)return!1;const s=K.createElement("video");return B.getTech("Html5").isSupported()?["application/vnd.apple.mpegurl","audio/mpegurl","audio/x-mpegurl","application/x-mpegurl","video/x-mpegurl","video/mpegurl","application/mpegurl"].some(function(t){return/maybe|probably/i.test(s.canPlayType(t))}):!1}();Me.supportsNativeDash=function(){return!K||!K.createElement||!B.getTech("Html5").isSupported()?!1:/maybe|probably/i.test(K.createElement("video").canPlayType("application/dash+xml"))}();Me.supportsTypeNatively=s=>s==="hls"?Me.supportsNativeHls:s==="dash"?Me.supportsNativeDash:!1;Me.isSupported=function(){return B.log.warn("VHS is no longer a tech. Please remove it from your player's techOrder.")};Me.xhr.onRequest=function(s){Ff(Me.xhr,s)};Me.xhr.onResponse=function(s){$f(Me.xhr,s)};Me.xhr.offRequest=function(s){jf(Me.xhr,s)};Me.xhr.offResponse=function(s){Vf(Me.xhr,s)};const b1=B.getComponent("Component");class Hf extends b1{constructor(e,t,i){if(super(t,i.vhs),typeof i.initialBandwidth=="number"&&(this.options_.bandwidth=i.initialBandwidth),this.logger_=Pt("VhsHandler"),t.options_&&t.options_.playerId){const n=B.getPlayer(t.options_.playerId);this.player_=n}if(this.tech_=t,this.source_=e,this.stats={},this.ignoreNextSeekingEvent_=!1,this.setOptions_(),this.options_.overrideNative&&t.overrideNativeAudioTracks&&t.overrideNativeVideoTracks)t.overrideNativeAudioTracks(!0),t.overrideNativeVideoTracks(!0);else if(this.options_.overrideNative&&(t.featuresNativeVideoTracks||t.featuresNativeAudioTracks))throw new Error("Overriding native VHS requires emulated tracks. See https://git.io/vMpjB");this.on(K,["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"],n=>{const r=K.fullscreenElement||K.webkitFullscreenElement||K.mozFullScreenElement||K.msFullscreenElement;r&&r.contains(this.tech_.el())?this.playlistController_.fastQualityChange_():this.playlistController_.checkABR_()}),this.on(this.tech_,"seeking",function(){if(this.ignoreNextSeekingEvent_){this.ignoreNextSeekingEvent_=!1;return}this.setCurrentTime(this.tech_.currentTime())}),this.on(this.tech_,"error",function(){this.tech_.error()&&this.playlistController_&&this.playlistController_.pauseLoading()}),this.on(this.tech_,"play",this.play)}setOptions_(e={}){if(this.options_=ge(this.options_,e),this.options_.withCredentials=this.options_.withCredentials||!1,this.options_.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions!==!1,this.options_.useDevicePixelRatio=this.options_.useDevicePixelRatio||!1,this.options_.useBandwidthFromLocalStorage=typeof this.source_.useBandwidthFromLocalStorage<"u"?this.source_.useBandwidthFromLocalStorage:this.options_.useBandwidthFromLocalStorage||!1,this.options_.useForcedSubtitles=this.options_.useForcedSubtitles||!1,this.options_.useNetworkInformationApi=this.options_.useNetworkInformationApi||!1,this.options_.useDtsForTimestampOffset=this.options_.useDtsForTimestampOffset||!1,this.options_.customTagParsers=this.options_.customTagParsers||[],this.options_.customTagMappers=this.options_.customTagMappers||[],this.options_.cacheEncryptionKeys=this.options_.cacheEncryptionKeys||!1,this.options_.llhls=this.options_.llhls!==!1,this.options_.bufferBasedABR=this.options_.bufferBasedABR||!1,typeof this.options_.playlistExclusionDuration!="number"&&(this.options_.playlistExclusionDuration=60),typeof this.options_.bandwidth!="number"&&this.options_.useBandwidthFromLocalStorage){const i=Bf();i&&i.bandwidth&&(this.options_.bandwidth=i.bandwidth,this.tech_.trigger({type:"usage",name:"vhs-bandwidth-from-local-storage"})),i&&i.throughput&&(this.options_.throughput=i.throughput,this.tech_.trigger({type:"usage",name:"vhs-throughput-from-local-storage"}))}typeof this.options_.bandwidth!="number"&&(this.options_.bandwidth=We.INITIAL_BANDWIDTH),this.options_.enableLowInitialPlaylist=this.options_.enableLowInitialPlaylist&&this.options_.bandwidth===We.INITIAL_BANDWIDTH,["withCredentials","useDevicePixelRatio","customPixelRatio","limitRenditionByPlayerDimensions","bandwidth","customTagParsers","customTagMappers","cacheEncryptionKeys","playlistSelector","initialPlaylistSelector","bufferBasedABR","liveRangeSafeTimeDelta","llhls","useForcedSubtitles","useNetworkInformationApi","useDtsForTimestampOffset","exactManifestTimings","leastPixelDiffSelector"].forEach(i=>{typeof this.source_[i]<"u"&&(this.options_[i]=this.source_[i])}),this.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions,this.useDevicePixelRatio=this.options_.useDevicePixelRatio;const t=this.options_.customPixelRatio;typeof t=="number"&&t>=0&&(this.customPixelRatio=t)}setOptions(e={}){this.setOptions_(e)}src(e,t){if(!e)return;this.setOptions_(),this.options_.src=v1(this.source_.src),this.options_.tech=this.tech_,this.options_.externVhs=Me,this.options_.sourceType=ld(t),this.options_.seekTo=r=>{this.tech_.setCurrentTime(r)},this.options_.player_=this.player_,this.playlistController_=new s1(this.options_);const i=ge({liveRangeSafeTimeDelta:Yt},this.options_,{seekable:()=>this.seekable(),media:()=>this.playlistController_.media(),playlistController:this.playlistController_});this.playbackWatcher_=new o1(i),this.attachStreamingEventListeners_(),this.playlistController_.on("error",()=>{const r=B.players[this.tech_.options_.playerId];let a=this.playlistController_.error;typeof a=="object"&&!a.code?a.code=3:typeof a=="string"&&(a={message:a,code:3}),r.error(a)});const n=this.options_.bufferBasedABR?Me.movingAverageBandwidthSelector(.55):Me.STANDARD_PLAYLIST_SELECTOR;this.playlistController_.selectPlaylist=this.selectPlaylist?this.selectPlaylist.bind(this):n.bind(this),this.playlistController_.selectInitialPlaylist=Me.INITIAL_PLAYLIST_SELECTOR.bind(this),this.playlists=this.playlistController_.mainPlaylistLoader_,this.mediaSource=this.playlistController_.mediaSource,Object.defineProperties(this,{selectPlaylist:{get(){return this.playlistController_.selectPlaylist},set(r){this.playlistController_.selectPlaylist=r.bind(this)}},throughput:{get(){return this.playlistController_.mainSegmentLoader_.throughput.rate},set(r){this.playlistController_.mainSegmentLoader_.throughput.rate=r,this.playlistController_.mainSegmentLoader_.throughput.count=1}},bandwidth:{get(){let r=this.playlistController_.mainSegmentLoader_.bandwidth;const a=k.navigator.connection||k.navigator.mozConnection||k.navigator.webkitConnection,l=1e7;if(this.options_.useNetworkInformationApi&&a){const h=a.downlink*1e3*1e3;h>=l&&r>=l?r=Math.max(r,h):r=h}return r},set(r){this.playlistController_.mainSegmentLoader_.bandwidth=r,this.playlistController_.mainSegmentLoader_.throughput={rate:0,count:0}}},systemBandwidth:{get(){const r=1/(this.bandwidth||1);let a;return this.throughput>0?a=1/this.throughput:a=0,Math.floor(1/(r+a))},set(){B.log.error('The "systemBandwidth" property is read-only')}}}),this.options_.bandwidth&&(this.bandwidth=this.options_.bandwidth),this.options_.throughput&&(this.throughput=this.options_.throughput),Object.defineProperties(this.stats,{bandwidth:{get:()=>this.bandwidth||0,enumerable:!0},mediaRequests:{get:()=>this.playlistController_.mediaRequests_()||0,enumerable:!0},mediaRequestsAborted:{get:()=>this.playlistController_.mediaRequestsAborted_()||0,enumerable:!0},mediaRequestsTimedout:{get:()=>this.playlistController_.mediaRequestsTimedout_()||0,enumerable:!0},mediaRequestsErrored:{get:()=>this.playlistController_.mediaRequestsErrored_()||0,enumerable:!0},mediaTransferDuration:{get:()=>this.playlistController_.mediaTransferDuration_()||0,enumerable:!0},mediaBytesTransferred:{get:()=>this.playlistController_.mediaBytesTransferred_()||0,enumerable:!0},mediaSecondsLoaded:{get:()=>this.playlistController_.mediaSecondsLoaded_()||0,enumerable:!0},mediaAppends:{get:()=>this.playlistController_.mediaAppends_()||0,enumerable:!0},mainAppendsToLoadedData:{get:()=>this.playlistController_.mainAppendsToLoadedData_()||0,enumerable:!0},audioAppendsToLoadedData:{get:()=>this.playlistController_.audioAppendsToLoadedData_()||0,enumerable:!0},appendsToLoadedData:{get:()=>this.playlistController_.appendsToLoadedData_()||0,enumerable:!0},timeToLoadedData:{get:()=>this.playlistController_.timeToLoadedData_()||0,enumerable:!0},buffered:{get:()=>Ui(this.tech_.buffered()),enumerable:!0},currentTime:{get:()=>this.tech_.currentTime(),enumerable:!0},currentSource:{get:()=>this.tech_.currentSource_,enumerable:!0},currentTech:{get:()=>this.tech_.name_,enumerable:!0},duration:{get:()=>this.tech_.duration(),enumerable:!0},main:{get:()=>this.playlists.main,enumerable:!0},playerDimensions:{get:()=>this.tech_.currentDimensions(),enumerable:!0},seekable:{get:()=>Ui(this.tech_.seekable()),enumerable:!0},timestamp:{get:()=>Date.now(),enumerable:!0},videoPlaybackQuality:{get:()=>this.tech_.getVideoPlaybackQuality(),enumerable:!0}}),this.tech_.one("canplay",this.playlistController_.setupFirstPlay.bind(this.playlistController_)),this.tech_.on("bandwidthupdate",()=>{this.options_.useBandwidthFromLocalStorage&&T1({bandwidth:this.bandwidth,throughput:Math.round(this.throughput)})}),this.playlistController_.on("selectedinitialmedia",()=>{a1(this)}),this.playlistController_.sourceUpdater_.on("createdsourcebuffers",()=>{this.setupEme_()}),this.on(this.playlistController_,"progress",function(){this.tech_.trigger("progress")}),this.on(this.playlistController_,"firstplay",function(){this.ignoreNextSeekingEvent_=!0}),this.setupQualityLevels_(),this.tech_.el()&&(this.mediaSourceUrl_=k.URL.createObjectURL(this.playlistController_.mediaSource),(B.browser.IS_ANY_SAFARI||B.browser.IS_IOS)&&this.options_.overrideNative&&this.options_.sourceType==="hls"&&typeof this.tech_.addSourceElement=="function"?(this.tech_.addSourceElement(this.mediaSourceUrl_),this.tech_.addSourceElement(this.source_.src)):this.tech_.src(this.mediaSourceUrl_))}createKeySessions_(){const e=this.playlistController_.mediaTypes_.AUDIO.activePlaylistLoader;this.logger_("waiting for EME key session creation"),y1({player:this.player_,sourceKeySystems:this.source_.keySystems,audioMedia:e&&e.media(),mainPlaylists:this.playlists.main.playlists}).then(()=>{this.logger_("created EME key session"),this.playlistController_.sourceUpdater_.initializedEme()}).catch(t=>{this.logger_("error while creating EME key session",t),this.player_.error({message:"Failed to initialize media keys for EME",code:3})})}handleWaitingForKey_(){this.logger_("waitingforkey fired, attempting to create any new key sessions"),this.createKeySessions_()}setupEme_(){const e=this.playlistController_.mediaTypes_.AUDIO.activePlaylistLoader,t=_1({player:this.player_,sourceKeySystems:this.source_.keySystems,media:this.playlists.media(),audioMedia:e&&e.media()});if(this.player_.tech_.on("keystatuschange",i=>{this.playlistController_.updatePlaylistByKeyStatus(i.keyId,i.status)}),this.handleWaitingForKey_=this.handleWaitingForKey_.bind(this),this.player_.tech_.on("waitingforkey",this.handleWaitingForKey_),!t){this.playlistController_.sourceUpdater_.initializedEme();return}this.createKeySessions_()}setupQualityLevels_(){const e=B.players[this.tech_.options_.playerId];!e||!e.qualityLevels||this.qualityLevels_||(this.qualityLevels_=e.qualityLevels(),this.playlistController_.on("selectedinitialmedia",()=>{p1(this.qualityLevels_,this)}),this.playlists.on("mediachange",()=>{Uf(this.qualityLevels_,this.playlists)}))}static version(){return{"@videojs/http-streaming":Mf,"mux.js":c1,"mpd-parser":d1,"m3u8-parser":h1,"aes-decrypter":f1}}version(){return this.constructor.version()}canChangeType(){return Pf.canChangeType()}play(){this.playlistController_.play()}setCurrentTime(e){this.playlistController_.setCurrentTime(e)}duration(){return this.playlistController_.duration()}seekable(){return this.playlistController_.seekable()}dispose(){this.playbackWatcher_&&this.playbackWatcher_.dispose(),this.playlistController_&&this.playlistController_.dispose(),this.qualityLevels_&&this.qualityLevels_.dispose(),this.tech_&&this.tech_.vhs&&delete this.tech_.vhs,this.mediaSourceUrl_&&k.URL.revokeObjectURL&&(k.URL.revokeObjectURL(this.mediaSourceUrl_),this.mediaSourceUrl_=null),this.tech_&&this.tech_.off("waitingforkey",this.handleWaitingForKey_),super.dispose()}convertToProgramTime(e,t){return xb({playlist:this.playlistController_.media(),time:e,callback:t})}seekToProgramTime(e,t,i=!0,n=2){return hf({programTime:e,playlist:this.playlistController_.media(),retryCount:n,pauseAfterSeek:i,seekTo:this.options_.seekTo,tech:this.options_.tech,callback:t})}setupXhrHooks_(){this.xhr.onRequest=e=>{Ff(this.xhr,e)},this.xhr.onResponse=e=>{$f(this.xhr,e)},this.xhr.offRequest=e=>{jf(this.xhr,e)},this.xhr.offResponse=e=>{Vf(this.xhr,e)},this.player_.trigger("xhr-hooks-ready")}attachStreamingEventListeners_(){const e=["seekablerangeschanged","bufferedrangeschanged","contentsteeringloadstart","contentsteeringloadcomplete","contentsteeringparsed"],t=["gapjumped","playedrangeschanged"];e.forEach(i=>{this.playlistController_.on(i,n=>{this.player_.trigger(je({},n))})}),t.forEach(i=>{this.playbackWatcher_.on(i,n=>{this.player_.trigger(je({},n))})})}}const Lr={name:"videojs-http-streaming",VERSION:Mf,canHandleSource(s,e={}){const t=ge(B.options,e);return!t.vhs.experimentalUseMMS&&!dn("avc1.4d400d,mp4a.40.2",!1)?!1:Lr.canPlayType(s.type,t)},handleSource(s,e,t={}){const i=ge(B.options,t);return e.vhs=new Hf(s,e,i),e.vhs.xhr=of(),e.vhs.setupXhrHooks_(),e.vhs.src(s.src,s.type),e.vhs},canPlayType(s,e){const t=ld(s);if(!t)return"";const i=Lr.getOverrideNative(e);return!Me.supportsTypeNatively(t)||i?"maybe":""},getOverrideNative(s={}){const{vhs:e={}}=s,t=!(B.browser.IS_ANY_SAFARI||B.browser.IS_IOS),{overrideNative:i=t}=e;return i}},x1=()=>dn("avc1.4d400d,mp4a.40.2",!0);x1()&&B.getTech("Html5").registerSourceHandler(Lr,0);B.VhsHandler=Hf;B.VhsSourceHandler=Lr;B.Vhs=Me;B.use||B.registerComponent("Vhs",Me);B.options.vhs=B.options.vhs||{};(!B.getPlugin||!B.getPlugin("reloadSourceOnError"))&&B.registerPlugin("reloadSourceOnError",u1);class S1{constructor(e){this.id=e.getAttribute("id"),this.allowMultipleAds=e.getAttribute("allowMultipleAds"),this.followRedirects=e.getAttribute("followRedirects"),this.vastAdData=null,this.adTagURI=null,this.customData=null;for(const t in e.childNodes){const i=e.childNodes[t];switch(i.localName){case"AdTagURI":this.adTagURI={templateType:i.getAttribute("templateType"),uri:(i.textContent||i.text||"").trim()};break;case"VASTAdData":for(this.vastAdData=i.firstChild;this.vastAdData&&this.vastAdData.nodeType!==1;)this.vastAdData=this.vastAdData.nextSibling;break;case"CustomAdData":this.customData=i;break}}}}function qf(s,e){const t=[];for(const i in s.childNodes){const n=s.childNodes[i];(n.nodeName===e||e===`vmap:${n.nodeName}`||n.nodeName===`vmap:${e}`)&&t.push(n)}return t}function E1(s){if(!s||!s.childNodes)return{};const e=s.childNodes,t=[];for(const n in e){const r=e[n];r.nodeName==="#cdata-section"&&t.push(r)}if(t&&t.length>0)try{return JSON.parse(t[0].data)}catch{}let i="";for(const n in e){const r=e[n];switch(r.nodeName){case"#text":i+=r.textContent.trim();break;case"#cdata-section":i+=r.data;break}}return i}function ml(s){const e={attributes:{},children:{},value:{}};e.value=E1(s);const t=s.attributes;if(t)for(const n in t){const r=t[n];r.nodeName&&r.nodeValue!==void 0&&r.nodeValue!==null&&(e.attributes[r.nodeName]=r.nodeValue)}const i=s.childNodes;if(i)for(const n in i){const r=i[n];r.nodeName&&r.nodeName.substring(0,1)!=="#"&&(e.children[r.nodeName]=ml(r))}return e}class C1{constructor(e){this.timeOffset=e.getAttribute("timeOffset"),this.breakType=e.getAttribute("breakType"),this.breakId=e.getAttribute("breakId"),this.repeatAfter=e.getAttribute("repeatAfter"),this.adSource=null,this.trackingEvents=[],this.extensions=[];for(const t in e.childNodes){const i=e.childNodes[t];switch(i.localName){case"AdSource":this.adSource=new S1(i);break;case"TrackingEvents":for(const n in i.childNodes){const r=i.childNodes[n];r.localName==="Tracking"&&this.trackingEvents.push({event:r.getAttribute("event"),uri:(r.textContent||r.text||"").trim()})}break;case"Extensions":this.extensions=qf(i,"Extension").map(n=>ml(n));break}}}track(e,t){for(const i in this.trackingEvents){const n=this.trackingEvents[i];if(n.event===e){let{uri:r}=n;n.event==="error"&&(r=r.replace("[ERRORCODE]",t)),this.tracker(r)}}}tracker(e){if(typeof window<"u"&&window!==null){const t=new Image;t.src=e}}}class w1{constructor(e){if(!e||!e.documentElement||e.documentElement.localName!=="VMAP")throw new Error("Not a VMAP document");this.version=e.documentElement.getAttribute("version"),this.adBreaks=[],this.extensions=[];for(const t in e.documentElement.childNodes){const i=e.documentElement.childNodes[t];switch(i.localName){case"AdBreak":this.adBreaks.push(new C1(i));break;case"Extensions":this.extensions=qf(i,"Extension").map(n=>ml(n));break}}}}const I1=(s,e)=>{const t=goog.pal,i=new t.ConsentSettings;i.allowStorage=!1;const n=new t.NonceLoader(i);return async()=>{try{const r=new URL(e),a=new t.NonceRequest;let l=localStorage.getItem("sl-device-id")||Qs.v4(),h=sessionStorage.getItem("sl-ad-session-id");h||(h=Qs.v4(),sessionStorage.setItem("sl-ad-session-id",h)),Qs.validate(l)||(l=Qs.v5(`https://${l}`,Qs.v5.URL)),r.searchParams.get("url")||r.searchParams.set("url","https://streamlayer.io"),r.searchParams.get("description_url")||r.searchParams.set("description_url","https://streamlayer.io"),a.adWillAutoPlay=r.searchParams.get("vpa")==="auto",a.adWillPlayMuted=r.searchParams.get("vpmute")==="1",a.continuousPlayback=!0,a.descriptionUrl=r.searchParams.get("description_url"),a.iconsSupported=!0,a.sessionId=l,a.supportedApiFrameworks="2,7,9",a.videoHeight=s.clientHeight,a.videoWidth=s.clientWidth;const f=await n.loadNonceManager(a);return r.searchParams.get("is_lat")==="[placeholder]"&&r.searchParams.set("is_lat","1"),r.searchParams.get("rdid")==="[placeholder]"&&r.searchParams.set("rdid",l),r.searchParams.get("correlator")==="[placeholder]"&&r.searchParams.set("correlator",h),r.searchParams.set("wta","1"),r.searchParams.set("givn",f.getNonce()),{url:r,manager:f}}catch(r){console.log("AdsManager could not be started",r);return}}},A1=new Lc._,k1=s=>s.creatives.find(e=>e.mediaFiles),P1=s=>{var e;const t=s==null?void 0:s.mediaFiles;return t!=null&&t.length&&((e=t.find(i=>i.fileURL))==null?void 0:e.fileURL)||""},sn=Oc.a({ads:[],autoplay:!0,muted:!1,nonceManager:void 0}),D1=(s,e)=>{const[t,i]=Te.useState(),n=Te.useRef(Date.now()),r=Te.useRef(Date.now());return Te.useEffect(()=>{if(!e||!(s!=null&&s.current))return;const a=I1(s.current,e),l=Date.now();n.current=l,sn.set({ads:[],autoplay:!0,muted:!1,nonceManager:void 0}),a().then(h=>{n.current===l&&h&&(i(h.url),sn.set({ads:[],autoplay:!0,muted:!1,nonceManager:h.manager}))}).catch(h=>{console.error(h)})},[s,e]),Te.useEffect(()=>{const a=async(l,h)=>{let f=[];if(l.searchParams.get("output")==="vmap"){const C=await fetch(l.toString()),P=new DOMParser,v=await C.text(),R=P.parseFromString(v,"text/xml");f=new w1(R).adBreaks.map(L=>L.adSource.adTagURI.uri)}else f=[l.toString()];const m=await Promise.all(f.map((C,P)=>A1.get(C).then(v=>{if(r.current===h){const R=v.ads.find(U=>U.creatives.length>0);if(!R)return;const L=k1(R),N=P1(L);return{creative:L,order:P,mediaFileUrl:N,ad:R,raw:v}}}))),T=l.searchParams.get("vpa")!=="click",E=l.searchParams.get("vpmute")==="1";sn.set({...sn.get(),ads:m.filter(C=>!!C),autoplay:T,muted:E})};if(t){const l=Date.now();r.current=l,a(t,l)}return()=>{r.current=0}},[t]),sn},L1=s=>{const e=Te.useRef();return Te.useEffect(()=>{if(!e.current&&s.current){const t=document.createElement("video-js");t.classList.add("vjs-big-play-centered"),s.current.appendChild(t),e.current=B(t,{controls:!1,playsinline:!0})}return()=>{e.current&&(e.current.dispose(),e.current=void 0)}},[]),e},zf={time:0,adCount:0,adPosition:0,skipDelay:0,playing:!1,paused:!1,reset:()=>{},whyThisAd:null,hasAdUrl:!1,adAction:s=>{},playMuted:!1,muted:!1,autoplay:!0},Ae=Oc.i(zf),Ac=s=>{if(!s)return 0;const e=s.duration(),t=s.currentTime();return e===void 0||isNaN(e)||t===void 0||isNaN(t)?0:Math.round(e-t)},O1=(s,e)=>{const t=D1(s,e),i=L1(s),n=Te.useRef(),r=Te.useRef(!1),a=Te.useRef(!1),l=Te.useCallback(()=>{if(a.current)return;const C=t.get().nonceManager;if(C&&r.current)try{C.sendPlaybackEnd()}catch(P){console.warn("[PAL] sendPlaybackEnd failed",P)}a.current=!0},[t]),h=Te.useCallback(()=>{l(),i.current&&(i.current.pause(),i.current.src(void 0)),n.current=void 0,Ae.set({...zf,reset:h})},[i,l]);Te.useEffect(()=>{Ae.setKey("reset",h)},[h]);const f=Te.useCallback(()=>{var C,P,v;const{adPosition:R,adCount:L}=Ae.get();if(i.current){if(R<L){const N=R+1,{ads:U,muted:F,autoplay:D,nonceManager:V}=t.get(),X=U[N-1];if(X){(C=n.current)==null||C.complete(),n.current=new Lc.z(null,X.ad,X.creative),n.current.on("clickthrough",G=>{if(V)try{V.sendAdClick()}catch(ae){console.warn("[PAL] sendAdClick failed",ae)}window.open(G,"_blank")}),Ae.setKey("adPosition",N),Ae.setKey("playMuted",F),Ae.setKey("skipDelay",X.creative.skipDelay||0),Ae.setKey("time",0),Ae.setKey("adAction",G=>{n.current&&n.current.click(null,{CLICKPOS:[G.clientX,G.clientY]})}),Ae.setKey("whyThisAd",X.creative.icons.find(G=>G.program==="GoogleWhyThisAd")||null),Ae.setKey("hasAdUrl",!!((P=X.creative.videoClickThroughURLTemplate)!=null&&P.url)),i.current.src(X.mediaFileUrl),Ae.setKey("playing",!0),R===0?(Ae.setKey("muted",F),Ae.setKey("autoplay",D),F&&i.current.muted(!0),D?i.current.play():(i.current.pause(),Ae.setKey("paused",!0))):i.current.play();return}}(v=n.current)==null||v.complete(),h()}},[i,h,t]),m=Te.useCallback(()=>{if(!i.current)return;const C=i.current.muted();i.current.muted(!C),Ae.setKey("muted",!C),n.current&&n.current.setMuted(!C)},[i]),T=Te.useCallback(()=>{i.current&&(i.current.paused()?(i.current.play(),n.current&&n.current.setPaused(!1)):(i.current.pause(),n.current&&n.current.setPaused(!0)))},[i]),E=Te.useCallback(()=>{i.current&&(n.current&&n.current.skip(),f())},[f,i]);return Te.useEffect(()=>{const C=i.current;if(!C)return()=>{};const P=D=>{if(Ae.setKey("playing",!0),Ae.setKey("paused",!1),Ae.setKey("time",Ac(D.target.player)),!r.current){const V=t.get().nonceManager;if(V)try{V.sendPlaybackStart(),r.current=!0,a.current=!1}catch(X){console.warn("[PAL] sendPlaybackStart failed",X)}}},v=()=>{var D;(D=n.current)==null||D.complete(),f()},R=D=>{Ae.setKey("muted",D.target.player.muted())},L=()=>{Ae.setKey("paused",!0)},N=D=>{D.target.tagName==="VIDEO"&&(Ae.get().autoplay||T())},U=D=>{Ae.setKey("time",Ac(D.target.player)),n.current&&n.current.setProgress(D.target.player.currentTime())},F=()=>{h()};return C.on("play",P),C.on("ended",v),C.on("muted",R),C.on("pause",L),C.on("click",N),C.on("timeupdate",U),C.on("error",F),()=>{C.off("play",P),C.off("ended",v),C.off("muted",R),C.off("pause",L),C.off("click",N),C.off("timeupdate",U),C.off("error",F)}},[T,f,i,h,t]),Te.useEffect(()=>t.subscribe(C=>{C&&(r.current=!1,a.current=!1,Ae.setKey("adCount",C.ads.length),Ae.setKey("adPosition",0),f())}),[t,i,f]),Te.useEffect(()=>()=>{h()},[h]),[Ae,m,T,E,n]},R1=({promotion:s,onClose:e,promotionId:t,externalAd:i,skipAutoClose:n})=>{var r,a,l,h,f;const m=Te.useRef(null),[T,E,C,P]=O1(m,i==null?void 0:i.url),{time:v,adCount:R,adPosition:L,skipDelay:N,playing:U,paused:F,reset:D,muted:V,playMuted:X,autoplay:G,whyThisAd:ae,hasAdUrl:fe,adAction:ve}=Q.useStore(T),he=((r=s.sponsor)==null?void 0:r.logo)&&s.logoMode===re.PromotionLogoMode.CENTER;return W.jsxs(Fc,{className:"PromoOverlay",children:[W.jsxs($c,{children:[W.jsx(jc,{className:Q.cx_default(!he&&Vc),children:W.jsx(qc,{style:{transform:"scale(1.5)"},children:"Ad"})}),W.jsxs(A0,{children:[W.jsx(T0,{time:v,adCount:R,adPosition:L}),!!N&&U&&W.jsx(ur.y,{timerClassName:"SkipTimerCount",className:"ClosePromoIcon",close:()=>{P()},duration:N,isPlaying:!F,skipIcon:!0}),n&&W.jsx(ur.y,{className:"ClosePromoIcon",close:()=>{D(),e==null||e()}})]})]}),W.jsx(Hc,{className:Q.cx_default(lu,U&&uu,!U&&cu),children:W.jsxs(I0,{ref:m,children:[ae&&W.jsx(b0,{whyThisAd:ae}),W.jsxs(x0,{style:(ae==null?void 0:ae.xPosition)==="right"?{left:"8px"}:{right:"8px"},children:[X&&W.jsx(E0,{className:Q.cx_default(!V&&"muted"),onClick:()=>E()}),F&&!G&&W.jsx(w0,{onClick:()=>C()})]})]})}),fe&&W.jsx(zc,{className:Q.cx_default(lu,U&&uu,!U&&cu),children:W.jsx(Wc,{as:"button",onClick:ve,style:{backgroundColor:((l=(a=s.banner)==null?void 0:a.ctaButton)==null?void 0:l.color)||"#009dc4",color:((f=(h=s.banner)==null?void 0:h.ctaButton)==null?void 0:f.textColor)||"#fff"},"data-a":"button","data-promo-id":t,"data-promo-type":s.type,target:"_blank",children:"Show more"})})]})},kc=s=>{var e,t,i,n,r,a,l,h,f,m,T,E,C,P,v,R,L,N,U,F,D,V,X,G,ae,fe,ve,he,Z,de;const{promotion:ee,open:Xe,advertisementPaused:Qe,togglePause:Ve,controlVideo:qe,skipAutoClose:be,promotionId:me,onClose:pt,markAsViewed:xt,externalAd:Ee,isEventFired:ce,fireEvent:Ue,muted:zi}=s,ui=ee.type===re.PromotionType.INGAME_IAB11_LBAR||ee.type===re.PromotionType.INGAME_IAB11||ee.type===re.PromotionType.INGAME_IAB11_SIDEBAR,ci=((e=ee.sponsor)==null?void 0:e.logo)&&ee.logoMode===re.PromotionLogoMode.CENTER,wi=!!((i=(t=ee.banner)==null?void 0:t.video)!=null&&i.url),mt=ee.autoPlayVideo===re.AutoPlayVideo.ENABLED,di=ee.playVideoMuted===re.PlayVideoMuted.ENABLED;if(Te.useEffect(()=>{Ve==null||Ve(wi||mt),Xe==null||Xe()},[]),Te.useEffect(()=>{me&&ee.type&&xt&&xt()},[me,ee.type,xt]),Te.useEffect(()=>()=>{qe==null||qe({muted:!1})},[qe]),Ee)return W.jsx(R1,{...s,externalAd:Ee});let Ft=(n=ee.banner)==null?void 0:n.url;Ft&&Ft.indexOf("http")!==0&&(Ft=`https://${Ft}`);let Ii=!0;return wi&&(!Qe||!mt?Ii=!0:Ii=!1),W.jsxs(Fc,{className:"PromoOverlay",children:[W.jsxs("div",{children:[W.jsxs($c,{children:[W.jsxs(jc,{className:Q.cx_default(!ci&&Vc),children:[((r=ee.sponsor)==null?void 0:r.logo)&&ee.logoMode===re.PromotionLogoMode.LEFT&&W.jsx(ru,{className:"PromoSponsorLogo",src:(a=ee.sponsor)==null?void 0:a.logo,alt:"promo"}),W.jsxs(h0,{style:{paddingLeft:(l=ee.sponsor)!=null&&l.logo&&ee.logoMode===re.PromotionLogoMode.LEFT?"0px":"8px"},children:[((h=ee.sponsor)==null?void 0:h.logo)&&ee.logoMode===re.PromotionLogoMode.LEFT&&W.jsx(l0,{children:(f=ee.sponsor)==null?void 0:f.name}),W.jsxs(f0,{className:"SponsorText",children:[W.jsx(qc,{children:"AD"}),W.jsx(p0,{children:"SPONSORED"})]})]})]}),W.jsx(ur.y,{className:"ClosePromoIcon",close:pt,autoClose:(m=ee.closeTimer)==null?void 0:m.auto,duration:be?0:(T=ee.closeTimer)==null?void 0:T.seconds,isPlaying:Ii})]}),W.jsxs(Hc,{children:[ci&&W.jsx(ru,{className:c0,src:(E=ee.sponsor)==null?void 0:E.logo,alt:"promo"}),W.jsx(au,{children:(P=(C=ee.banner)==null?void 0:C.video)!=null&&P.url?W.jsx(ur.Et,{source:(R=(v=ee.banner)==null?void 0:v.video)==null?void 0:R.url,poster:(N=(L=ee.banner)==null?void 0:L.video)==null?void 0:N.thumbnailUrl,aspectRatio:ui?"1/1":"2/1",onRender:()=>{ce!=null&&ce("video-rendered")||(qt.eventBus.emit("advertisement",{action:"videoRendered",payload:{id:me,type:ee.type}}),Ue==null||Ue("video-rendered"))},onQuartile:Dt=>{ce!=null&&ce(`video-quartile-${Dt}`)||(qt.eventBus.emit("advertisement",{action:"quartileCompleted",payload:{id:me,type:ee.type,quartile:Dt}}),Ue==null||Ue(`video-quartile-${Dt}`))},onMute:Dt=>{const Lt=Dt?"muted":"unmuted";ce!=null&&ce(Lt)||(qt.eventBus.emit("advertisement",{action:Dt?"videoMuted":"videoUnmuted",payload:{id:me,type:ee.type}}),Ue==null||Ue(Lt))},onPause:()=>{mt&&(Ve==null||Ve(!0))},onReplay:()=>{ce!=null&&ce("replayed")||(qt.eventBus.emit("advertisement",{action:"videoReplayed",payload:{id:me,type:ee.type}}),Ue==null||Ue("replayed"))},onPlay:()=>{ce!=null&&ce("played")||(qt.eventBus.emit("advertisement",{action:"videoPlay",payload:{id:me,type:ee.type}}),Ue==null||Ue("played")),Ve==null||Ve(!1),ce!=null&&ce("played")&&ce!=null&&ce("ended")&&!(ce!=null&&ce("replayed"))&&(qt.eventBus.emit("advertisement",{action:"videoReplayed",payload:{id:me,type:ee.type}}),Ue==null||Ue("replayed"))},onEnd:()=>{ce!=null&&ce("ended")||(qt.eventBus.emit("advertisement",{action:"videoEnd",payload:{id:me,type:ee.type}}),Ue==null||Ue("ended"))},controlVideo:qe,autoPlay:mt,playMuted:di,muted:zi}):(U=ee.banner)!=null&&U.imageUrl?W.jsx(u0,{style:ui?{aspectRatio:"1/1"}:{},src:(F=ee.banner)==null?void 0:F.imageUrl,alt:"promo"}):null}),!ui&&W.jsxs(au,{children:[((D=ee.banner)==null?void 0:D.title)&&W.jsx(m0,{className:Q.cx_default("AdvTitle",ci&&g0),children:(V=ee.banner)==null?void 0:V.title}),((X=ee.banner)==null?void 0:X.body)&&W.jsx(d0,{className:"AdvDescription",children:(G=ee.banner)==null?void 0:G.body})]})]})]}),ee.buttonType===re.PromotionButtonType.BASIC&&W.jsx(zc,{children:W.jsx(Wc,{href:Ft,style:{backgroundColor:((fe=(ae=ee.banner)==null?void 0:ae.ctaButton)==null?void 0:fe.color)||"#009dc4",color:((he=(ve=ee.banner)==null?void 0:ve.ctaButton)==null?void 0:he.textColor)||"#fff"},"data-a":"button","data-promo-id":me,"data-promo-type":ee.type,target:"_blank",children:(de=(Z=ee.banner)==null?void 0:Z.ctaButton)==null?void 0:de.label})})]})},M1=Q.styled_default("div")({name:"SidebarContainer",class:"s1abskp8",propsAsIs:!1}),N1=({children:s,direction:e,style:t,className:i,hiding:n})=>W.jsx(xo,{direction:e,style:t,hiding:n,className:i,children:W.jsx(M1,{children:s})}),Pc=s=>(s==null?void 0:s.type)===re.PromotionType.INGAME_IAB11_LBAR||(s==null?void 0:s.type)===re.PromotionType.INGAME_IAB21_LBAR,U1=s=>(s==null?void 0:s.type)===re.PromotionType.INGAME_IAB11_SIDEBAR||(s==null?void 0:s.type)===re.PromotionType.INGAME_IAB21_SIDEBAR,B1=s=>(s==null?void 0:s.type)===re.PromotionType.INGAME_IAB11||(s==null?void 0:s.type)===re.PromotionType.INGAME_IAB21,F1=({advertisement:s,close:e,skipTypeCheck:t,skipAutoClose:i,layoutMode:n="side-by-side",sidebar:r,isNotification:a,banner:l,markAsViewed:h,open:f,externalAd:m,controlVideo:T,advertisementPaused:E,togglePause:C,isEventFired:P,fireEvent:v,muted:R})=>s.promotion?a&&s.notification?W.jsx(a0,{open:()=>f==null?void 0:f({fromNotification:!0}),notification:s.notification,promotionId:s.question.id,close:e}):!r&&!l&&(t||B1(s.promotion))?W.jsx(o0,{className:"PromoOverlayContainer",children:W.jsx(kc,{markAsViewed:h,promotionId:s.question.id,promotion:s.promotion,onClose:e,open:f,skipAutoClose:i,externalAd:m,controlVideo:T,advertisementPaused:E,togglePause:C,isEventFired:P,fireEvent:v,muted:R})}):r&&(t||Pc(s.promotion)||U1(s.promotion)||m)?W.jsx(N1,{className:"PromoSidebarContainer",direction:r,hiding:!1,children:W.jsx(kc,{markAsViewed:h,promotionId:s.question.id,promotion:s.promotion,externalAd:m,onClose:e,open:f,controlVideo:T,skipAutoClose:i,advertisementPaused:E,togglePause:C,isEventFired:P,fireEvent:v,muted:R})}):l&&Pc(s.promotion)?W.jsx(Rc,{promotionId:s.question.id,hiding:!1,promotion:s.promotion,direction:l,isEventFired:P,fireEvent:v}):null:null,Dc=Q.styled_default("div")({name:"AdvertisementUIWrap",class:"aa6pjif",propsAsIs:!1}),$1=s=>{const e=s.target;if(e instanceof HTMLAnchorElement&&e.target==="_blank"){const t=e.getAttribute("data-promo-id")||"",i=e.getAttribute("data-promo-type")||re.PromotionType.UNSET;e.getAttribute("data-a")==="button"&&qt.eventBus.emit("advertisement",{action:"buttonSelect",payload:{id:t,type:i}}),e.getAttribute("data-a")==="banner"&&qt.eventBus.emit("advertisement",{action:"bannerSelect",payload:{id:t,type:i}})}},j1=({gamification:s,advertisement:e,layoutMode:t,skipAutoClose:i,skipTypeCheck:n,sidebar:r,banner:a,notification:l,isMobileScreen:h,persistent:f,containerId:m,externalAd:T,controlVideo:E,muted:C})=>{var P,v,R,L,N,U,F,D,V,X,G,ae,fe,ve,he,Z,de,ee,Xe,Qe,Ve;const qe=Te.useRef(null),be=Q.useStore(e.$store),me=Q.useStore(s.openedQuestion.$store);Zm.b(qe,{enabled:!!be.data,event:"click",listener:$1});const pt=((R=(v=(P=be.data)==null?void 0:P.question)==null?void 0:v.backgroundImage)==null?void 0:R.landscapeUrl)||((N=(L=be.data)==null?void 0:L.promotion)==null?void 0:N.backgroundImageLandscapeUrl),xt=((D=(F=(U=be.data)==null?void 0:U.question)==null?void 0:F.backgroundImage)==null?void 0:D.portraitUrl)||((X=(V=be.data)==null?void 0:V.promotion)==null?void 0:X.backgroundImagePortraitUrl),Ee=ig.y({containerId:m,landscapeUrl:pt,portraitUrl:xt});if(((G=me==null?void 0:me.attributes)==null?void 0:G.adUnit)===re.AdUnit.STANDART&&(ve=(fe=(ae=me==null?void 0:me.attributes)==null?void 0:ae.adPromotion)==null?void 0:fe.banner)!=null&&ve.imageUrl)return a?W.jsx(Dc,{ref:qe,style:{height:"100%"},className:Q.cx_default("SL-AdvertisementUIWrap",h&&"mobile-view"),children:W.jsx(gg,{cardId:me.id,promotion:{...(he=me==null?void 0:me.attributes)==null?void 0:he.adPromotion,adUnit:(Z=me==null?void 0:me.attributes)==null?void 0:Z.adUnit}})}):null;const ce=!a&&!r;if(be.data===void 0||!f&&be.isViewed)return null;const Ue=((Xe=(ee=(de=be==null?void 0:be.data)==null?void 0:de.notification)==null?void 0:ee.promotion)==null?void 0:Xe.mode)===re.NotificationPromotionMode.LOWER_THIRD;return W.jsxs(Dc,{ref:qe,style:{height:ce?"auto":"100%"},className:Q.cx_default("SL-AdvertisementUIWrap",h&&"mobile-view",Ue&&"SL-AdvertisementUIWrap--lower-third"),children:[!l&&Ee,W.jsx(F1,{skipTypeCheck:n,sidebar:r,banner:a,advertisement:be.data,advertisementPaused:!!be.isPaused,togglePause:be.togglePause,isEventFired:be.isEventFired,fireEvent:be.fireEvent,close:be.close,externalAd:T?be.externalAd:void 0,markAsViewed:(Qe=s.advertisement)==null?void 0:Qe.markAsViewed,open:(Ve=s.advertisement)==null?void 0:Ve.open,layoutMode:t,isNotification:l,skipAutoClose:i,controlVideo:E,muted:C})]})},Wf=({sdk:s,sidebar:e,externalAd:t,banner:i,skipAutoClose:n,skipTypeCheck:r,layoutMode:a,isMobileScreen:l,persistent:h,notification:f,muted:m})=>{const T=Q.useStore(s.featuresList.getStore()),[E,C]=Te.useState(!t),P=Q.useStore(s.options);if(Te.useEffect(()=>{if(t){const R=document.createElement("script");R.async=!0,R.src="https://imasdk.googleapis.com/pal/sdkloader/pal.js",document.body.appendChild(R),R.onload=()=>{C(!0)}}},[t]),e&&i)return W.jsx("div",{style:{color:"red"},children:"define either sidebar or banner, not both."});if(i&&t)return W.jsx("div",{style:{color:"red"},children:"externalAd is not supported with banner"});if(!T)return null;const v=s.getFeature(re.SdkOverlayType.GAMES);return!(v!=null&&v.advertisement)||t&&!E?null:W.jsx(j1,{gamification:v,advertisement:v.advertisement,sidebar:e,banner:i,layoutMode:a,isMobileScreen:l,persistent:h,notification:f,skipTypeCheck:r,skipAutoClose:n,externalAd:t,controlVideo:s.controlVideoPlayer,containerId:P.containerId,muted:m})},V1=({event:s,sidebar:e,banner:t,isMobileScreen:i,skipAutoClose:n,persistent:r,theme:a,notification:l,skipTypeCheck:h,externalAd:f,muted:m=!1})=>{const T=Vt.B(),E=Vt.F(),C=Vt.z();return T?f&&!E.promotionExternalAd?s!==void 0&&W.jsx(Vt.j,{event:s}):!f&&E.promotionExternalAd?s!==void 0&&W.jsx(Vt.j,{event:s}):e&&!E.promotionSidebar?s!==void 0&&W.jsx(Vt.j,{event:s}):t&&!E.promotionBanner?s!==void 0&&W.jsx(Vt.j,{event:s}):l&&!E.promotionNotification?s!==void 0&&W.jsx(Vt.j,{event:s}):!t&&!e&&!l&&!E.promotionOverlay&&!h?s!==void 0&&W.jsx(Vt.j,{event:s}):W.jsxs("div",{className:"StreamLayerSDK",children:[W.jsx(Jm.h,{customTheme:a??C.theme,themeMode:C.themeMode,children:W.jsx(Wf,{sdk:T,sidebar:e,banner:t,isMobileScreen:i,persistent:r,notification:l,skipTypeCheck:h,skipAutoClose:n,layoutMode:"side-by-side",externalAd:f,muted:m})}),s!==void 0&&W.jsx(Vt.j,{event:s})]}):null};exports.StreamLayerSDKAdvertisement=V1;exports.StreamLayerSDKAdvertisementUI=Wf;
|