1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./Kuc4_L8N.js","./Cdg6EMof.js","./entry.DmXOBG7B.css","./BVggu1I8.js","./CHw4VmoC.js","./HeroMinus.d4CzfsZf.css","./CY6AaQ41.js","./HeroPlus.CNe797aF.css","./WishListArticles.Cy_SlRVe.css","./BnFMaeFS.js","./VjkUZXLe.js","./i1-vcZyO.js","./6dIvEfpQ.js","./CYKM7cBn.js","./BTD3GOfA.js","./HeroMinusSmall.Cm2HSqRf.css","./CukMRnnJ.js","./HeroPlusSmall.CEBOdUJs.css","./zvyjRU8y.js","./HeroHeart.Bi5csg56.css","./d4J6xQTs.js","./BFjNtOgU.js","./index.BZhSH0sa.css","./BWbYhNrX.js","./paypal-sdk.YdItgnIj.css","./ExpressCheckout.BsUtZiYK.css","./Clq8NPYg.js","./Db2isWe6.js","./Pagination.CSSGHuy0.css","./iT9e5Eij.js","./eAdjwZLi.js","./eCUqOUNO.js","./Video.DGz7rLzS.css"])))=>i.map(i=>d[i]); 2import{G as Zs,k as K,l as q,m as j,d as jr,e as Gn,H as Tl,w as Ha,f as Va,I as kn,J as St,o as zc,K as jc,j as S,L as _i,M as ht,N as Ae,O as me,P as Pe,Q as xt,R as B0,S as G0,q as it,A as J,U as K0,x as Si,T as Dn,V as Ki,W as oh,r as Ot,X as No,Y as lh,Z as Cn,$ as Xc,a0 as Wa,z as Xe,a1 as z,a2 as Id,a3 as H0,a4 as V0,a5 as or,D as Em,a6 as W0,a as Qc,b as ym,a7 as q0,a8 as dh,a9 as Y0,aa as Tm,ab as xd,ac as lr,ad as z0,u as bm,ae as j0,af as ch,ag as X0,ah as Q0,ai as _m,aj as Z0,ak as J0,al as uh,am as hh,an as eE,ao as tE,ap as Cs,aq as iE,ar as ws,as as sE,at as nE,au as aa,n as rE,av as aE,aw as oE,ax as fh,ay as mh,az as nn,aA as lE,aB as dE,aC as oa,B as Qi,aD as Sm,aE as Ps,aF as la,aG as Gl,aH as cE}from"./Cdg6EMof.js";import{_ as Zc,a as uE,S as hE,W as fE}from"./BVggu1I8.js";import{_ as mE}from"./BnFMaeFS.js";import{_ as gE}from"./VjkUZXLe.js";import{_ as pE}from"./i1-vcZyO.js";import{n as gh}from"./6dIvEfpQ.js";import{Dropzone as vE}from"./CYKM7cBn.js";import{_ as Am}from"./BTD3GOfA.js";import{_ as Im}from"./CukMRnnJ.js";import{_ as EE}from"./zvyjRU8y.js";import{_ as yE}from"./d4J6xQTs.js";import{_ as TE,a as bE}from"./Clq8NPYg.js";import{_ as _E}from"./Db2isWe6.js";import{_ as SE}from"./iT9e5Eij.js";import{P as AE}from"./eAdjwZLi.js";import{u as ph}from"./eCUqOUNO.js";import"./CHw4VmoC.js";import"./CY6AaQ41.js";import"./BFjNtOgU.js";import"./BWbYhNrX.js";const IE={};function xE(s,e){return K(),q("span",null,[...e[0]||(e[0]=[j("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 512 512"},[j("path",{d:"M386.3 160L336 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l128 0c17.7 0 32-14.3 32-32l0-128c0-17.7-14.3-32-32-32s-32 14.3-32 32l0 51.2L414.4 97.6c-87.5-87.5-229.3-87.5-316.8 0s-87.5 229.3 0 316.8s229.3 87.5 316.8 0c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0c-62.5 62.5-163.8 62.5-226.3 0s-62.5-163.8 0-226.3s163.8-62.5 226.3 0L386.3 160z"})],-1)])])}const LE=Zs(IE,[["render",xE]]),RE={key:0,class:"label"},kE={key:1,class:"surcharge"},DE={key:2,class:"value"},CE={class:"text"},wE={key:3,class:"value"},PE=["src","alt"],ME=["innerHTML"],OE={key:0,class:"unit"},FE={key:4,class:"value"},$E={key:0,class:"button-prop"},NE=["innerHTML"],UE=["innerHTML"],BE={key:5,class:"value form-field"},GE={class:"control upload"},KE={class:"dz-message"},HE={class:"dropzone-custom-content"},VE={class:"dropzone-info"},WE={class:"is-size-4 dropzone-custom-title"},qE={class:"subtitle"},YE={class:"href"},zE={key:0,class:"dropzone-hint"},jE={class:"text-gray-400"},XE={key:0},QE={key:1},ZE={key:1,class:"upload-preview"},JE=["src","alt"],ey={class:"upload-file-info"},ty={class:"upload-file-name"},iy={key:0,class:"upload-file-size"},sy={class:"upload-actions flex justify-between"},ny={class:"help has-text-grey",key:"required"},ry={key:6,class:"value form-field"},ay={class:"control"},oy=["value"],ly={class:"help has-text-grey",key:"required"},dy={key:1,class:"flex flex-col gap-2"},cy=["type","value","min","max","onInput"],uy=["type","value","onInput"],hy={class:"help has-text-grey",key:"required"},fy={key:7,class:"form-field"},my={class:"options control"},gy=["disabled","onClick"],py={class:"button-prop"},vy={class:"tile"},Ey=["disabled","onClick"],yy={class:"label"},Ty={key:0},by={key:1},_y={key:1,class:"button-prop"},Sy={class:"button-label"},Ay={class:"text"},Iy={key:0,class:"surcharge"},xy={key:2,class:"button-prop"},Ly={class:"tile"},Ry={class:"button-label"},ky={class:"text"},Dy={key:0,class:"surcharge"},Cy={key:3,class:"button-prop"},wy={class:"tile placeholder"},Py={class:"button-label"},My={class:"text"},Oy={key:0,class:"surcharge"},Fy={key:4,class:"text-prop"},$y={class:"text"},Ny={key:0,class:"surcharge"},Uy=jr({__name:"Property",props:{property:{},validArticles:{},sellableArticles:{},allArticles:{},activeOption:{},userInput:{},hideLabel:{type:Boolean,default:!1},manageStock:{type:Boolean,default:!1},showDiscountLabel:{type:Boolean,default:!1},validation:{}},emits:["select","input","upload"],async setup(s,{emit:e}){let t,i;const n=Gn(),r=Tl();[t,i]=Ha(()=>Va("product")),await t,i();const a=n.settings?.["product-special-price-label"]||"layout-starburst",o=s,d=Wa(o,"property"),l=Wa(o,"activeOption"),c=Wa(o,"userInput"),u=Xe(),h=Xe(),f=Xe(),m=Xe(null),p=e;let g;n.settings?.["product-details-property-tile-size"]&&(g=n.settings?.["product-details-property-tile-size"]);let y;n.settings?.["product-details-property-tile-width"]&&(y=n.settings?.["product-details-property-tile-width"]);let T;n.settings?.["product-details-property-tile-aspect-ratio"]&&(T=n.settings?.["product-details-property-tile-aspect-ratio"]);let _="cover";n.settings?.["product-details-property-tile-display-cover"]!==void 0&&["true","1","yes",!0].includes(n.settings?.["product-details-property-tile-display-cover"])===!1&&(_="scale-down");let I;n.settings?.["product-details-property-tile-fill-empty-space"]&&(I=n.settings?.["product-details-property-tile-fill-empty-space"]);let R;n.settings?.["product-details-property-tile-fill-color"]&&(R=n.settings?.["product-details-property-tile-fill-color"]);let F="40";n.settings?.["product-details-img-max-height"]&&(F=kn(n.settings?.["product-details-img-max-height"]));const L=z(()=>d.value?.type!=="input"&&d.value?.type!=="upload"&&!d.value?.options?.length),w=z(()=>d.value?.options?.length>1),P=z(()=>d.value.type),k=z(()=>{let V="text";switch(d.value.inputField){case"textarea":case"number":V=d.value.inputField;break;default:case"textfield":V="text";break}return V}),G=z(()=>d.value?.articleRequired?!0:d.value?.isRequired??!0),se=V=>{const fe=Number(V);if(!(!Number.isFinite(fe)||fe<1))return Math.floor(fe)},oe=z(()=>Math.max(1,se(d.value?.minRows)||1,se(d.value?.maxRows)||1)),de=z(()=>{if(!(w.value||L.value||!d.value.options?.length))return Id(d.value.options[0].value||d.value.options[0].valueAlt)}),ae=z(()=>{if(!(w.value||L.value||!d.value.options?.length)&&d.value.options[0].valueAlt)return Id(d.value.options[0].valueAlt)}),ie=z(()=>{if(!(w.value||L.value||!d.value.options?.length)&&d.value.options[0].surcharge)return d.value.options[0].surcharge}),ue=z(()=>{let V=J("dd-MM-yyyy");switch(d.value.datetype){case"datetime":V=J("dd-MM-yyyy")+" HH:mm";break;case"week":V=J("week-yyyy");break;case"month":V=J("MM-yyyy");break;case"year":V="yyyy";break}const fe=de.value;if(fe)return H0(fe,V)}),ee=z(()=>{let V=r.currency;return V=(r.product?.salePrice||r.product?.price)?.customerGroup?.currency?.iso4217||r.currency,V}),te=z(()=>{if(!w.value||L.value)return;let V=d.value.options,fe="value";r.showNetPrices&&(fe="net_value"),r.defaultTax?.value;const Oe=r.product?.salePrice||r.product?.price;return Oe?.tax_rate!=null?Oe?.tax_rate:Oe?.tax?.value?Oe.tax.value:Oe?.tax_value&&Oe?.net_value&&Oe.tax_value*100/Oe.net_value,V.map(Fe=>{const Ue={...Fe};let Te=!0;if(d.value.articleRequired&&o.sellableArticles?.length){Te=!1;const H=o.sellableArticles.filter(rt=>{let qe=!1;
2return rt.propertyPivots.forEach(Xt=>{const bt=Xt.valueOption,Xi=Xt.property;Xi&&d.value.id===Xi.id&&bt[Fe.key]===Fe.value&&(qe=!0)}),qe});Te=!!H.length,Pe(Oe?.[fe],ee.value);let be,_e,Se=[],Ye={sale:[],regular:[]};if(H.forEach(rt=>{const qe=rt.salePrice||rt.price;if(!qe)return;Ye[rt.salePrice?"sale":"regular"].push(qe);const Xt=rt?.unit||r.product?.unit,bt=rt?.quantity||r.product?.quantity||1;Xt&&!Se.includes(Xt)&&Se.push(Xt),be?(be.from=Math.min(be.from,qe?.[fe]),be.to=Math.max(be.to,qe?.[fe]||0)):be={from:qe?.[fe],to:qe?.[fe]},_e?(_e.from=Math.min(_e.from,qe?.[fe]/bt),_e.to=Math.max(_e.to,qe?.[fe]/bt)):_e={from:qe?.[fe]/bt,to:qe?.[fe]/bt}}),be&&be.from<be.to?""+Pe(be.from,ee.value):be&&be.from===be.to&&Pe(be.from,ee.value),Se.length===1){let rt=Se[0];rt||(rt=J("product:piece")),_e&&_e.from<_e.to?_e.info=J("product:min-price-per-unit",{price:Pe(_e.from,ee.value),unit:rt}):_e&&_e.from===_e.to&&(_e.info=J("product:price-per-unit",{price:Pe(_e.from,ee.value),unit:rt}))}Ue.discount="none",Ye.sale.length&&Ye.regular.length?Ue.discount="some":Ye.sale.length&&(Ue.discount="all")}Ue.sellable=Te;let $e=!0;if(d.value.articleRequired&&!l.value&&o.validArticles?.length&&($e=!1,$e=!!o.validArticles.filter(be=>{let _e=!1;return be.propertyPivots.forEach(Se=>{const Ye=Se.valueOption,rt=Se.property;rt&&d.value.id===rt.id&&Ye[Fe.key]===Fe.value&&(_e=!0)}),_e}).length),Ue.available=$e,d.value?.component==="tile:article-image"&&d.value.articleRequired&&o.allArticles?.length){const H=o.allArticles.filter(_e=>{let Se=!1;return _e.propertyPivots.forEach(Ye=>{const rt=Ye.valueOption,qe=Ye.property;qe&&d.value.id===qe.id&&rt[Fe.key]===Fe.value&&(Se=!0)}),Se});let be;H.forEach(_e=>{be||_e?.media?.sort((Se,Ye)=>(Se?.position||0)-(Ye?.position||0))?.forEach(Se=>{be||Se.type==="image"&&Se.image&&Se?.settings?.show?.detail&&(be=Se)})}),be?Ue.image=be.image:Ue.image=void 0}return d.value?.component==="dropdown"&&(!$e||!Te?Ue.$isDisabled=!0:Ue.$isDisabled=!1),Ue})}),ve=z(()=>{const V=new Map;return d.value.options.forEach(fe=>{V.has(fe.group)||V.set(fe.group,{group:fe.group,value:fe.group})}),Array.from(V.values())}),X=z(()=>te.value?.length&&te.value.find(V=>V.image?.source?.url||V.image?.url||V.valueAlt)),Y=z(()=>{let V={};if(X.value){switch(g){case"small":V["--tile-width"]="37px",V["--tile-height"]="37px";break;case"medium":V["--tile-width"]="50px",V["--tile-height"]="50px";break}if(g==="custom"){const fe=T.split("/"),Oe=Number(fe[0])/Number(fe[1]);V["--tile-width"]=y,V["--tile-height"]=`${kn(y)/Oe}px`,V["--tile-aspect-ratio"]=T,V["--tile-object-fit"]=_,V["--tile-fill-type"]=I,V["--tile-fill-color"]=R}}return V}),Ie=z(()=>({[`property-id-${d.value.id}`]:d.value.id,[`property-key-${V0(d.value.key)}`]:d.value.key,selectable:w.value,"vertical-tile-orientation":X.value&&g==="custom",[`fill-tile-with-${I}`]:X.value&&g==="custom","has-options":te.value&&te.value.length>0,"has-surcharge":ie.value,"has-value":de.value||ae.value||c.value,"is-required":G.value,"is-hidden":L.value})),De=V=>{p("select",{property:d.value,option:V})},Re=V=>/\.(jpg|jpeg|png|gif|webp|bmp|tiff|svg)$/i.test(V),Ce=()=>{p("upload",{property:d.value,file:null}),or(()=>{m.value?.hiddenFileInput?.click()})},dt=Em(),je=()=>{if(!f.value)return;m.value&&(m.value.destroy(),m.value=null);const V=d.value.allowedMimeTypes?.map(Oe=>{const Fe=Oe.split("/")[1];return Fe==="jpeg"?".jpg,.jpeg":`.${Fe}`}).join(",")||".jpg,.jpeg,.png,.gif,.webp",fe=d.value.maxFileSize?d.value.maxFileSize/1024:5;m.value=new vE(f.value,{url:dt.public.apiEndpoint+dt.public.apiUploadRoute,maxFiles:1,maxFilesize:fe,acceptedFiles:V,previewTemplate:` 3 <div class="dz-preview dz-file-preview"> 4 <div class="dz-filename"> 5 <span data-dz-name></span> 6 </div> 7 <div class="dz-size" data-dz-size></div> 8 <div class="dz-thumbnail"> 9 <img data-dz-thumbnail /> 10 </div> 11 <div class="dz-progress"> 12 <span class="dz-upload" data-dz-uploadprogress></span> 13 </div> 14 <div class="dz-success-mark"> 15 <i class="fas fa-check"></i> 16 </div> 17 <div class="dz-error-mark"> 18 <i class="fas fa-times"></i> 19 </div> 20 <div class="dz-error-message">
21 <span data-dz-errormessage></span> 22 </div> 23 </div>`,timeout:360*1e3}),m.value.on("success",(Oe,Fe)=>{m.value?.removeFile(Oe),p("upload",{property:d.value,file:Oe,upload:Fe})}),m.value.on("error",(Oe,Fe)=>{const Ue=Fe?.message||J("form:an-error-occurred");Oe.previewElement.querySelectorAll(".dz-error-message span")[0].textContent=Ue,setTimeout(()=>m.value?.removeFile(Oe),4e3)})};St(f,V=>{V&&P.value==="upload"&&je()});const ne=V=>{if(V===0)return"0 B";const fe=1024,Oe=["B","KB","MB","GB"],Fe=Math.floor(Math.log(V)/Math.log(fe));return parseFloat((V/Math.pow(fe,Fe)).toFixed(1))+" "+Oe[Fe]},We=V=>V.map(Oe=>{const Fe=Oe.split("/")[1];return Fe==="jpeg"?"JPG":Fe?.toUpperCase()||Oe}).join(", ");return zc(()=>{u.value&&gh(u.value),P.value==="upload"&&je()}),jc(()=>{u.value&&gh.destroy(u.value),m.value&&(m.value.destroy(),m.value=null)}),(V,fe)=>{const Oe=gE,Fe=LE,Ue=pE,Te=Xc,$e=Zc;return S(L)?me("",!0):(K(),q("div",{key:0,class:ht(["property",S(Ie)]),style:_i(S(Y))},[S(d).label&&!s.hideLabel?(K(),q("div",RE,[j("label",null,Ae(S(d).label),1)])):me("",!0),!S(r).hidePrices&&S(ie)?(K(),q("div",kE,Ae(("moneyFormat"in V?V.moneyFormat:S(Pe))(S(ie),S(ee))),1)):me("",!0),S(de)&&S(P)==="date"?(K(),q("div",DE,[j("span",CE,Ae(S(ue)),1)])):S(de)&&S(P)!=="color"?(K(),q("div",wE,[Re(S(de))?(K(),q("img",{key:0,class:"image-preview",src:S(de),alt:S(d).label,style:_i({maxHeight:S(F)+"px"})},null,12,PE)):(K(),q(xt,{key:1},[j("span",{class:"text",innerHTML:("magicLinks"in V?V.magicLinks:S(B0))(S(de))},null,8,ME),S(d).type==="unit"&&S(d).unit?(K(),q("span",OE,Ae(S(d).unit),1)):me("",!0)],64))])):S(de)&&S(P)==="color"?(K(),q("div",FE,[S(ae)?(K(),q("div",$E,[j("div",{class:"tile",style:_i({background:S(ae)})},null,4),j("span",{innerHTML:S(de)},null,8,NE)])):(K(),q("span",{key:1,innerHTML:S(de)},null,8,UE))])):S(P)==="upload"?(K(),q("div",BE,[j("div",GE,[!S(c)?.fileData?.url||S(c)?.uploading?(K(),q("div",{key:0,class:ht(["dropzone",{disabled:S(c)?.uploading,"is-danger":s.validation?.errorMessage&&s.validation?.meta?.validated}]),ref_key:"dropzoneRef",ref:f,tabindex:"0",onKeyup:fe[0]||(fe[0]=G0(H=>S(m)?.hiddenFileInput?.click(),["enter","space"]))},[j("div",KE,[j("div",HE,[it(Oe,{class:"text-6xl"})]),j("div",VE,[j("div",WE,Ae(("t"in V?V.t:S(J))("form:move-files-here")),1),j("div",qE,[K0(Ae(("t"in V?V.t:S(J))("form:or")),1),j("span",YE,Ae(("t"in V?V.t:S(J))("form:click-here")),1)]),S(d).maxFileSize||S(d).allowedMimeTypes?.length?(K(),q("div",zE,[j("small",jE,[S(d).allowedMimeTypes?.length?(K(),q("span",XE,Ae(We(S(d).allowedMimeTypes)),1)):me("",!0),S(d).maxFileSize?(K(),q("span",QE," (max. "+Ae(ne(S(d).maxFileSize*1024))+")",1)):me("",!0)])])):me("",!0)])])],34)):me("",!0),S(c)?.fileData?.url&&!S(c)?.uploading?(K(),q("div",ZE,[j("img",{class:"upload-thumbnail",src:S(c).fileData.url,alt:S(c).fileData.name},null,8,JE),j("div",ey,[j("div",ty,Ae(S(c).fileData.name),1),S(c).fileData.size?(K(),q("div",iy,Ae(ne(S(c).fileData.size)),1)):me("",!0)]),j("div",sy,[j("button",{class:"button is-small is-link",type:"button",onClick:Ce},[it(Fe),j("span",null,Ae(("t"in V?V.t:S(J))("product:upload-change-file")),1)]),j("button",{class:"button is-small is-danger is-outlined",type:"button",onClick:fe[1]||(fe[1]=H=>p("upload",{property:S(d),file:null}))},[it(Ue),j("span",null,Ae(("t"in V?V.t:S(J))("product:upload-remove-file")),1)])])])):me("",!0),it(Dn,{name:"input-help",mode:"out-in"},{default:Si(()=>[s.validation?.errorMessage&&s.validation?.meta?.validated?(K(),q("p",{class:"help is-danger",key:s.validation?.errorMessage},Ae(s.validation.errorMessage),1)):S(G)?(K(),q("p",ny,Ae(("t"in V?V.t:S(J))("form:required-field")),1)):me("",!0)]),_:1}
23)])])):S(P)==="input"?(K(),q("div",ry,[j("div",ay,[S(k)==="textarea"?(K(),q(xt,{key:0},[j("textarea",{class:"textarea",ref_key:"textarea",ref:u,rows:4,value:S(c)?.pivot?.value,onInput:fe[2]||(fe[2]=H=>p("input",{property:S(d),value:H.target.value})),onFocus:fe[3]||(fe[3]=H=>H.target.select())},null,40,oy),it(Dn,{name:"input-help",mode:"out-in"},{default:Si(()=>[s.validation?.errorMessage&&s.validation?.meta?.validated?(K(),q("p",{class:"help is-danger",key:s.validation?.errorMessage},Ae(s.validation.errorMessage),1)):S(G)?(K(),q("p",ly,Ae(("t"in V?V.t:S(J))("form:required-field")),1)):me("",!0)]),_:1})],64)):(K(),q("div",dy,[(K(!0),q(xt,null,Ki(S(oe),(H,be)=>(K(),q("div",{class:"field-holder",key:be},[S(k)==="number"?(K(),q("input",{key:0,class:"input",type:S(k),value:("getNthLine"in V?V.getNthLine:S(oh))(S(c)?.pivot?.value,be),min:S(d).minInput,max:S(d).maxInput,onInput:_e=>p("input",{property:S(d),value:_e.target.value,row:be}),onFocus:fe[4]||(fe[4]=_e=>_e.target.select())},null,40,cy)):me("",!0),S(k)==="text"?(K(),q("input",{key:1,class:ht(["input",S(d).key]),type:S(k),value:("getNthLine"in V?V.getNthLine:S(oh))(S(c)?.pivot?.value,be),onInput:_e=>p("input",{property:S(d),value:_e.target.value,row:be}),onFocus:fe[5]||(fe[5]=_e=>_e.target.select())},null,42,uy)):me("",!0),it(Dn,{name:"input-help",mode:"out-in"},{default:Si(()=>[s.validation?.[`row-${be}`]?.errorMessage&&s.validation?.[`row-${be}`]?.meta?.validated||H>=S(oe)&&s.validation?.errorMessage?(K(),q("p",{class:"help is-danger",key:s.validation?.[`row-${be}`]?.errorMessage||s.validation?.errorMessage},Ae(s.validation?.[`row-${be}`]?.errorMessage||s.validation?.errorMessage),1)):H>=S(oe)&&S(d).minRows&&!s.validation?.meta?.validated?(K(),q("p",hy,Ae(("t"in V?V.t:S(J))("form:required-n-rows",{n:S(d).minRows})),1)):me("",!0)]),_:2},1024)]))),128))]))])])):S(te)?(K(),q("div",fy,[j("div",my,[S(d).component==="dropdown"&&S(w)?(K(),Ot(S(No),{key:0,modelValue:S(l),"onUpdate:modelValue":fe[6]||(fe[6]=H=>lh(l)?l.value=H:null),multiple:!1,options:S(te),searchable:S(te).length>10,"track-by":"id",label:"value",placeholder:("t"in V?V.t:S(J))("select"),"deselect-label":"","selected-label":("t"in V?V.t:S(J))("selected"),"select-label":"",onSelect:De,onRemove:De},null,8,["modelValue","options","searchable","placeholder","selected-label"])):S(d).component==="tile:grouped"&&S(w)?(K(),q(xt,{key:1},[it(S(No),{modelValue:S(h),"onUpdate:modelValue":fe[7]||(fe[7]=H=>lh(h)?h.value=H:null),multiple:!1,options:S(ve),searchable:S(ve).length>10,"track-by":"group",label:"value",placeholder:("t"in V?V.t:S(J))("select"),"deselect-label":"","selected-label":("t"in V?V.t:S(J))("selected"),"select-label":"",class:ht({"mb-4":S(h)!=null})},null,8,["modelValue","options","searchable","placeholder","selected-label","class"]),(K(!0),q(xt,null,Ki(S(te),H=>(K(),q(xt,null,[H?.group===S(h)?.group?(K(),q("button",{key:0,class:ht(["button is-small is-link option relative",{"is-active":S(l)?.id===H.id,"is-not-available":!H.available,"is-out-of-stock":!H.sellable}]),disabled:!s.validArticles?.length||!H.sellable,onClick:be=>De(H)},[j("div",py,[j("div",vy,[it(Te,{image:H.image,lazy:!0,"show-matching-background":S(g)==="custom"&&S(_)!=="cover"&&S(I)==="blur","object-fit":S(g)==="custom"?S(_):"contain",title:H.value,"missing-icon":"exclamation-triangle","hide-missing-info":!0,sizes:S(Y)["--tile-width"]?S(Y)["--tile-width"]:("getWidth"in V?V.getWidth:S(Cn))(H.image,("toPX"in V?V.toPX:S(kn))(S(Y)["--tile-height"]))},null,8,["image","show-matching-background","object-fit","title","sizes"])])])],10,gy)):me("",!0)],64))),256))],64)):(K(!0),q(xt,{key:2},Ki(S(te),H=>(K(),q("button",{class:ht(["button is-small is-link option relative",{"is-active":S(l)?.id===H.id,"is-not-available":!H.available,"is-out-of-stock":!H.sellable}]),disabled:!s.validArticles?.length||!H.sellable,onClick:be=>De(H)},[s.showDiscountLabel&&H.discount==="all"&&!S(r).hidePrices?(K(),q("div",{key:0,class:ht(["discount-wrap small",S(a)])},[j("div",yy,[S(a)==="layout-corner"?(K(),q("span",Ty,"SALE")):(K(),q("span",by,"%"))])],2)):me("",!0),S(P)==="color"&&H.valueAlt?(K(),q("div",_y,[j("div",{class:"tile",style:_i({background:H.valueAlt})},null,4),j("div",Sy,[j("span",Ay,Ae(H.value),1),!S(r).hidePrices&&H.price?(K(),q("span",Iy,Ae(("moneyFormat"in V?V.moneyFormat:S(Pe))(H.surcharge,S(ee))),1)):me("",!0)])])):H.image?(K(),q("div",xy,[j("div",Ly,[it(Te,{image:H.image,lazy:!0,"show-matching-background":S(g)==="custom"&&S(_)!=="cover"&&S(I)==="blur","object-fit":S(g)==="custom"?S(_):"contain",title:H.value,"missing-icon":"exclamation-triangle","hide-missing-info":!0,sizes:S(Y)["--tile-width"]?S(Y)["--tile-width"]:("getWidth"in V?V.getWidth:S(Cn))(H.image,("toPX"in V?V.toPX:S(kn))(S(Y)["--tile-height"]))},null,8,["image","show-matching-background","object-fit","title","sizes"])]),j("div",Ry,[j("span",ky,Ae(H.value),1),!S(r).hidePrices&&H.surcharge?(K(),q("span",Dy,Ae(("moneyFormat"in V?V.moneyFormat:S(Pe))(H.surcharge,S(ee))),1)):me("",!0)])])):S(X)&&S(g)==="custom"?(K(),q("div",Cy,[j("div",wy,[it($e)]),j("div",Py,[j("span",My,Ae(H.value),1),!S(r).hidePrices&&H.surcharge?(K(),q("span",Oy,Ae(("moneyFormat"in V?V.moneyFormat:S(Pe))(H.surcharge,S(ee))),1)):me("",!0)])])):(K(),q("div",Fy,[j("span",$y,Ae(H.value),1),!S(r).hidePrices&&H.surcharge?(K(),q("span",Ny,Ae(("moneyFormat"in V?V.moneyFormat:S(Pe))(H.surcharge,S(ee))),1)):me("",!0)]))],10,Ey))),256))]),it(Dn,{name:"input-help",mode:"out-in"},{default:Si(()=>
23[s.validation?.errorMessage&&s.validation?.meta?.validated?(K(),q("p",{class:"help is-danger",key:s.validation?.errorMessage},Ae(s.validation.errorMessage),1)):me("",!0)]),_:1})])):me("",!0)],6))}}}),By=Zs(Uy,[["__scopeId","data-v-2abf967f"]]),Gy={};function Ky(s,e){return K(),q("span",null,[...e[0]||(e[0]=[j("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 512 512"},[j("path",{d:"M34.5 420.4c-1.6 2.8-2.5 6-2.5 9.3c0 10.2 8.2 18.4 18.4 18.4l411.2 0c10.2 0 18.4-8.2 18.4-18.4c0-3.3-.9-6.4-2.5-9.3L276.5 75.8C272.2 68.5 264.4 64 256 64s-16.2 4.5-20.5 11.8L34.5 420.4zM6.9 404.2l201-344.6C217.9 42.5 236.2 32 256 32s38.1 10.5 48.1 27.6l201 344.6c4.5 7.7 6.9 16.5 6.9 25.4c0 27.8-22.6 50.4-50.4 50.4L50.4 480C22.6 480 0 457.4 0 429.6c0-8.9 2.4-17.7 6.9-25.4zM256 160c8.8 0 16 7.2 16 16l0 128c0 8.8-7.2 16-16 16s-16-7.2-16-16l0-128c0-8.8 7.2-16 16-16zM232 384a24 24 0 1 1 48 0 24 24 0 1 1 -48 0z"})],-1)])])}const Hy=Zs(Gy,[["render",Ky]]),Vy={class:"title"},Wy={class:"icon"},qy=["innerHTML"],Yy=jr({__name:"AccordionItem",props:{title:{},content:{},isClosed:{type:Boolean,default:!1},combineInfos:{type:Boolean,default:!1}},setup(s){const e=Gn(),t=s,i=Xe(!t.isClosed),n=()=>{i.value=!i.value},r=z(()=>({"--combine-infos-table-width-value":`${l.value}`,"--combine-infos-table-zebra-color":`${u.value}`})),a=z(()=>{const h=e.settings?.["product-details-table-view"]||!1;return["true","1","yes",!0].includes(h)}),o=z(()=>
23{const h=e.settings?.["product-details-table-view-lines"]||!1;return["true","1","yes",!0].includes(h)}),d=z(()=>{const h=e.settings?.["product-details-table-view-width"]||!1;return["true","1","yes",!0].includes(h)}),l=z(()=>{let h="auto";return d.value===!0&&(h=e.settings?.["product-details-table-view-width-value"]||"auto"),h}),c=z(()=>{const h=e.settings?.["product-details-table-view-zebra"]||!1;return["true","1","yes",!0].includes(h)}),u=z(()=>{let h="transparent";return c.value===!0&&(h=e.settings?.["product-details-table-view-zebra-color"]||"#f4f4f4"),h});return(h,f)=>{const m=Im,p=Am;return K(),q("div",{class:ht(["panel-item",{open:S(i)}])},[j("button",{class:"label",onClick:n},[j("div",Vy,Ae(s.title),1),j("div",Wy,[S(i)?me("",!0):(K(),Ot(m,{key:0,"stroke-width":1.3})),S(i)?(K(),Ot(p,{key:1,"stroke-width":1.3})):me("",!0)])]),t.combineInfos?(K(),Ot(Dn,{key:0,name:"slide-vertical",mode:"out-in"},{default:Si(()=>[S(i)?(K(),q("div",{key:0,class:ht(["content",{"table-zebra":S(u)!="transparent","table-lines":S(o),"table-view":S(a)}]),style:_i(S(r))},[W0(h.$slots,"default",{},void 0,!0)],6)):me("",!0)]),_:3})):(K(),Ot(Dn,{key:1,name:"slide-vertical",mode:"out-in"},{default:Si(()=>[S(i)?(K(),q("div",{key:0,class:"content",innerHTML:s.content},null,8,qy)):me("",!0)]),_:1}))],2)}}}),zy=Zs(Yy,[["__scopeId","data-v-d8e85c6c"]]),jy=["href","title"],Xy={class:"related-article-inner"},Qy={key:0,class:"untranslated-badge"},Zy={class:"label"},Jy={key:0},eT={key:1},tT={class:"image-wrap"},iT={key:1,class:"placeholder-wrap"},sT={class:"info-wrap"},nT={class:"name line-clamp-2 primary-color"},rT={key:0,class:"price"},aT={class:"price-innner"},oT={key:0,class:"sale"},lT={key:0,class:"unit-price"},dT=jr({__name:"Teaser",props:{relatedArticle:{},unitPriceSetting:{default:"show-if-differs"}},setup(s){const e=Gn(),t=Tl();Qc();const i=ym(),n=e.settings?.["product-special-price-label"]||"layout-starburst",r=z(()=>{const h=s.relatedArticle?.name,f=s.relatedArticle?.product?.name;return h||f||null});function a(h,f="list"){if(!h?.length)return null;const m=[...h].sort((p,g)=>(p?.position??0)-(g?.position??0));for(const p of m){const g=p?.settings?.show;if(((f==="list"?g?.list:g?.detail)??!0)===!0&&p?.type==="image"&&!p?.video)return p}return null}const o=z(()=>{const h=a(s.relatedArticle?.media,"list");if(h?.image)return h.image;const f=a(s.relatedArticle?.media,"detail");if(f?.image)return f.image;const m=a(s.relatedArticle?.product?.media,"list");if(m?.image)return m.image;const p=a(s.relatedArticle?.product?.media,"detail");return p?.image?p.image:null}),d=z(()=>{if(!s.relatedArticle?.product?.price)return null;let h="gross_value";t.showNetPrices&&(h="net_value");const f=s.relatedArticle?.product?.price,m=f?.customerGroup?.currency?.iso4217||t.currency;let p=f?.[h];return s.relatedArticle?.product?.surcharges?.length&&(p=s.relatedArticle?.product.surcharges.reduce((g,y)=>g+y[h],p)),{value:p,formatted:Pe(p,m),currency:m}}),l=z(()=>{if(s.unitPriceSetting==="hide")return null;let h="gross_value";t.showNetPrices&&(h="net_value");const f=c.value||d.value,m=f?.currency;let p=f?.value||f?.value;if(!p)return null;let g=s.relatedArticle?.product?.unit?.label;g||(g=J("product:piece"));const y=s.relatedArticle?.product?.unit?.quantity||1;if(y===1&&s.unitPriceSetting==="show-if-differs")return null;p/=y,s.relatedArticle?.product.surcharges?.length&&(p=s.relatedArticle.product.surcharges.reduce((_,I)=>_+I[h],p));const T=Pe(p,m);return{value:p,formatted:T,info:J("product:price-per-unit",{price:T,unit:g})}}),c=z(()=>{if(!s.relatedArticle.product?.salePrice)return null;let h="gross_value";t.showNetPrices&&(h="net_value");const f=s.relatedArticle.product?.salePrice,m=f?.customerGroup?.currency?.iso4217||t.currency;let p=f?.[h];return s.relatedArticle?.product?.surcharges?.length&&(p=s.relatedArticle?.product?.surcharges.reduce((g,y)=>g+y[h],p)),{value:p,formatted:Pe(p,m),currency:m}}),u=z(()=>({name:"shop-product",params:{product:s.relatedArticle.product.slug},query:void 0}));return(h,f)=>{const m=Xc,p=Zc;return K(),q("a",{class:"related-article-teaser-link primary-color",href:S(i).resolve(u.value).href,title:r.value},[j("div",{class:ht(["related-article",{"is-untranslated":s.relatedArticle._untranslated}])},[j("div",Xy,[s.relatedArticle._untranslated?(K(),q("div",Qy,[j("span",null,Ae(("t"in h?h.t:S(J))("product:not-translated")),1)])):me("",!0),c.value?.formatted&&!S(t).hidePrices?(K(),q("div",{key:1,class:ht(["discount-wrap",S(n)])},[j("div",Zy,[S(n)==="layout-corner"?(K(),q("span",Jy,"SALE")):(K(),q("span",eT,"%"))])],2)):me("",!0),j("div",tT,[o.value?(K(),Ot(m,{key:0,class:"rounded rounded-b-none overflow-hidden",image:o.value,lazy:"true","object-fit":h.scale-h.down,fit:"fit",title:r.value,alt:`${("t"in h?h.t:S(J))("image")}: ${r.value}`,sizes:"200"},null,8,["image","object-fit","title","alt"])):(K(),q("div",iT,[it(p)]))]),j("div",sT,[j("div",nT,Ae(r.value),1),S(t).hidePrices?me("",!0):(K(),q("div",rT,[j("div",aT,[j("span",{class:ht(["secondary-color",{strikethrough:c.value?.formatted}])},Ae(d.value?.formatted),3),c.value?.formatted?(K(),q("span",oT,Ae(c.value?.formatted),1)):me("",!0),f[0]||(f[0]=j("span",{class:"tax-info"},"*",-1))]),l.value?.info?(K(),q("div",lT,[j("span",null,Ae(l.value?.info),1)])):me("",!0)]))])])],2)],8,jy)}}}),cT=Zs(dT,[["__scopeId","data-v-25f114c3"]]),xm=Tm` 24query FetchArticleRelatedArticles( 25 $id: Int 26 $translate: Boolean = false 27 $withImageFiles: Boolean = false 28) { 29 CO_Article(id: $id) { 30 id 31 relatedArticles {
32 ...Article 33 product { 34 id 35 name 36 teaser 37 description 38 nr 39 slug 40 manage_stock 41 unit 42 quantity 43 shipping_points 44 out_of_stock_threshold 45 media { 46 ...Media 47 ...MediaSettings 48 } 49 price { 50 ...Price 51 } 52 mainPrice { 53 ...Price 54 } 55 salePrice { 56 ...Price 57 } 58 } 59 } 60 } 61} 62${q0.base} 63${dh.base} 64${dh.settings} 65${Y0.base} 66`,uT={key:0,class:"heading"},hT={class:"icon flex justify-center"},fT={class:"icon flex justify-center"},mT=jr({name:"RelatedArticles",__name:"index",props:{articles:{},relatedArticleIds:{},fallbackProductId:{},fallbackArticleId:{}},setup(s){const e=Gn(),t=Tl(),i=Qc(),n=xd();ym();const r={perPage:{desktop:6,tablet:4,phone:2},heading:{title:J("product:related-articles-heading"),show:!0}},a=Xe(0),o=Xe(0),d=Xe(),l=Xe([]),c=Xe(null),u=lr("apq").client,h=e.settings?.["related-articles-per-page-desktop"]||r.perPage.desktop,f=e.settings?.["related-articles-per-page-tablet"]||r.perPage.tablet,m=e.settings?.["related-articles-per-page-phone"]||r.perPage.phone,p=e.settings?.["related-articles-show-title"]||r.heading.show,g=e.settings?.["related-articles-title"],y=s,T=Wa(y,"relatedArticleIds"),_=Xe(!!y.relatedArticleIds?.length),I=z(()=>{const ne=g||J("product:related-articles-heading");return["true",!0,1,"1"].includes(p)?ne:void 0}),R=z(()=>{let ne=e.settings?.["product-card-aspect-ratio-preset"];return ne==="custom"&&(ne=e.settings?.["product-card-aspect-ratio-custom"]),ne}),F=z(()=>e.settings?.["product-card-background-color"]),L=z(()=>c.value?c.value.length:T.value&&T.value.length?T.value.length:y.articles?.length||0),w=z(()=>{const ne=Math.min(6,h);return Math.max(ne,Math.min(h,L.value))}),P=z(()=>{const ne=Math.min(4,f);return Math.max(ne,Math.min(f,L.value))}),k=z(()=>{const ne=Math.min(2,m);return Math.max(ne,Math.min(m,L.value))}),G=z(()=>{let ne=w.value;return o.value>1&&o.value<kn(ch.sm)?ne=k.value:o.value>1&&o.value<kn(ch.md)&&(ne=P.value),ne}),se=z(()=>Math.ceil(L.value/G.value)),oe=z(()=>{if(!y.articles||!y.articles.length)return[];const ne=a.value*G.value;return y.articles.slice(ne,ne+G.value)}),de=z(()=>T.value&&T.value.length?l.value:oe.value),ae=z(()=>{if(!T.value||!T.value.length)return[];const ne=a.value*G.value;return T.value.slice(ne,ne+G.value)}),ie=(ne,We=!1)=>{const V=X0(t),{mainPrice:fe,salePrice:Oe}=Q0(ne.prices,V);return{...ne,_untranslated:We,product:{id:ne.product_id,slug:ne.product_slug,name:ne.name,nr:ne.product_nr,media:ne.media,price:fe,salePrice:Oe,sellable:ne.sellable}}},ue=async()=>{if(!u)return!1;if(y.fallbackArticleId)try{const{data:ne}=await u.query({query:xm,variables:{id:y.fallbackArticleId}});if(ne?.CO_Article?.relatedArticles?.length)return c.value=ne.CO_Article.relatedArticles,!0}catch(ne){console.error("GraphQL article related articles fallback error:",ne?.message)}if(y.fallbackProductId)try{const{data:ne}=await u.query({query:_m,variables:{id:y.fallbackProductId}});if(ne?.CO_Product?.relatedArticles?.length)return c.value=ne.CO_Product.relatedArticles,!0}catch(ne){console.error("GraphQL product related articles fallback error:",ne?.message)}return!1},ee=()=>{if(!c.value)return;const ne=a.value*G.value;l.value=c.value.slice(ne,ne+G.value)},te=async()=>{if(c.value){ee();return}const ne=ae.value;if(!ne||!ne.length){l.value=[];return}const We=Em(),V=e.meilisearchKey,fe=We.public.meiliSearchEndpoint,Oe=We.public.meiliSearchArticlesIndexUid;if(!V||!fe||!Oe){_.value=!0,await ue(),ee(),_.value=!1;return}_.value=!0;try{const Fe=`${fe}indexes/${Oe}/search`,Ue=n.language,Te=Ue&&Ue!==e.defaultLanguage?.code;let $e=[];if(Te){const H=ne.map(qe=>`origin_id = ${qe}`).join(" OR "),_e=(await $fetch(Fe,{method:"POST",body:{limit:ne.length,filter:`(${H}) AND language_code = '${Ue}' AND status = 'enabled'`},headers:{Authorization:`Bearer ${V}`}}))?.hits||[],Se=new Set(_e.map(qe=>Number(qe.origin_id))),Ye=ne.filter(qe=>!Se.has(qe));let rt=[];if(Ye.length){const qe=Ye.map(bt=>`id = ${bt}`).join(" OR ");rt=(await $fetch(Fe,{method:"POST",body:{limit:Ye.length,filter:`(${qe}) AND language_code NOT EXISTS AND status = 'enabled'`},headers:{Authorization:`Bearer ${V}`}}))?.hits||[]}$e=[..._e,...rt]}else{const H=ne.map(_e=>`id = ${_e}`).join(" OR ");$e=(await $fetch(Fe,{method:"POST",body:{limit:ne.length,filter:`(${H}) AND status = 'enabled'`},headers:{Authorization:`Bearer ${V}`}}))?.hits||[]}if($e.length){const H=ne.map(be=>$e.find(_e=>
66Number(_e.origin_id)===be||Number(_e.id)===be)).filter(Boolean);l.value=H.map(be=>{const _e=Te&&!be.language_code;return ie(be,_e)})}else y.fallbackArticleId||y.fallbackProductId?(await ue(),ee()):l.value=[]}catch(Fe){console.error("Meilisearch related articles error:",Fe?.message||Fe),y.fallbackArticleId||y.fallbackProductId?(await ue(),ee()):l.value=[]}finally{_.value=!1}},ve=ne=>{a.value=ne-1};let X="";const Y=()=>{const We=ae.value.join(",");We!==X&&(X=We,te())};St(T,(ne,We)=>{const V=ne?ne.join(","):"",fe=We?We.join(","):"";V!==fe&&(a.value=0,l.value=[],c.value=null,X="",Y())}),St(a,()=>{T.value&&T.value.length&&Y()});const Ie=()=>{d.value&&(getComputedStyle(d.value),o.value=d.value.clientWidth||0)},De=z0(function(){Ie(),a.value=0},100);zc(async()=>{window.addEventListener("resize",De),Ie(),T.value&&T.value.length&&(await te(),X=ae.value.join(","))});const Re=bm();let Ce=!1;const dt=Re.hook("member:hydrated",async()=>{Ce=!0,T.value&&T.value.length&&(await te(),X=ae.value.join(","))});St(()=>i.hydrating,(ne,We)=>{We===!0&&ne===!1&&!Ce&&T.value&&T.value.length&&te().then(()=>{X=ae.value.join(",")})}),jc(async()=>{window.removeEventListener("resize",De),dt()});const je=z(()=>({"--card-background":F.value,"--card-aspect-ratio":R.value,"--per-page-desktop":w.value,"--per-page-tablet":P.value,"--per-page-phone":k.value}));return(ne,We)=>{const V=cT,fe=bE,Oe=TE,Fe=_E;return K(),q("div",{class:"related-articles-wrap",ref_key:"container",ref:d},[I.value?(K(),q("h3",uT,Ae(I.value),1)):me("",!0),j("div",{class:"related-articles-inner",style:_i(je.value)},[_.value?(K(!0),q(xt,{key:0},Ki(G.value,Ue=>(K(),q("div",{class:"loading-skeleton",key:Ue},[j("div",{class:"skeleton-shimmer rounded rounded-b-none",style:_i({"aspect-ratio":R.value||"1/1"})},null,4),We[0]||(We[0]=j0('<div class="mt-2" data-v-df46d243><div class="h-4 skeleton-shimmer rounded w-3/4" data-v-df46d243></div><div class="h-4 skeleton-shimmer rounded mt-1 w-1/2" data-v-df46d243></div></div><div class="mt-2 flex justify-end" data-v-df46d243><div class="h-4 skeleton-shimmer rounded w-16" data-v-df46d243></div></div>',2))]))),128)):(K(!0),q(xt,{key:1},Ki(de.value,Ue=>(K(),Ot(V,{relatedArticle:Ue},null,8,["relatedArticle"]))),256))],4),se.value>1?(K(),Ot(Fe,{key:1,class:"mt-4","last-page":se.value,"current-page":a.value+1,"nav-class":"pagination is-centered is-rounded",onChange:ve},{prev:Si(()=>[j("div",hT,[it(fe)])]),next:Si(()=>[j("div",fT,[it(Oe)])]),_:1},8,["last-page","current-page"])):me("",!0)],512)}}}),gT=Zs(mT,[["__scopeId","data-v-df46d243"]]),Ee={MEDIA_PLAY_REQUEST:"mediaplayrequest",MEDIA_PAUSE_REQUEST:"mediapauserequest",MEDIA_MUTE_REQUEST:"mediamuterequest",MEDIA_UNMUTE_REQUEST:"mediaunmuterequest",MEDIA_VOLUME_REQUEST:"mediavolumerequest",MEDIA_SEEK_REQUEST:"mediaseekrequest",MEDIA_AIRPLAY_REQUEST:"mediaairplayrequest",MEDIA_ENTER_FULLSCREEN_REQUEST:"mediaenterfullscreenrequest",MEDIA_EXIT_FULLSCREEN_REQUEST:"mediaexitfullscreenrequest",MEDIA_PREVIEW_REQUEST:"mediapreviewrequest",MEDIA_ENTER_PIP_REQUEST:"mediaenterpiprequest",MEDIA_EXIT_PIP_REQUEST:"mediaexitpiprequest",MEDIA_ENTER_CAST_REQUEST:"mediaentercastrequest",MEDIA_EXIT_CAST_REQUEST:"mediaexitcastrequest",MEDIA_SHOW_TEXT_TRACKS_REQUEST:"mediashowtexttracksrequest",MEDIA_HIDE_TEXT_TRACKS_REQUEST:"mediahidetexttracksrequest",MEDIA_SHOW_SUBTITLES_REQUEST:"mediashowsubtitlesrequest",MEDIA_DISABLE_SUBTITLES_REQUEST:"mediadisablesubtitlesrequest",MEDIA_TOGGLE_SUBTITLES_REQUEST:"mediatogglesubtitlesrequest",MEDIA_PLAYBACK_RATE_REQUEST:"mediaplaybackraterequest",MEDIA_RENDITION_REQUEST:"mediarenditionrequest",MEDIA_AUDIO_TRACK_REQUEST:"mediaaudiotrackrequest",MEDIA_SEEK_TO_LIVE_REQUEST:"mediaseektoliverequest",REGISTER_MEDIA_STATE_RECEIVER:"registermediastatereceiver",UNREGISTER_MEDIA_STATE_RECEIVER:"unregistermediastatereceiver"},st={MEDIA_CHROME_ATTRIBUTES:"mediachromeattributes",MEDIA_CONTROLLER:"mediacontroller"},Lm={MEDIA_AIRPLAY_UNAVAILABLE:"mediaAirplayUnavailable",MEDIA_FULLSCREEN_UNAVAILABLE:"mediaFullscreenUnavailable",MEDIA_PIP_UNAVAILABLE:"mediaPipUnavailable",MEDIA_CAST_UNAVAILABLE:"mediaCastUnavailable",MEDIA_RENDITION_UNAVAILABLE:"mediaRenditionUnavailable",MEDIA_AUDIO_TRACK_UNAVAILABLE:"mediaAudioTrackUnavailable",MEDIA_PAUSED:"mediaPaused",MEDIA_HAS_P
66LAYED:"mediaHasPlayed",MEDIA_ENDED:"mediaEnded",MEDIA_MUTED:"mediaMuted",MEDIA_VOLUME_LEVEL:"mediaVolumeLevel",MEDIA_VOLUME:"mediaVolume",MEDIA_VOLUME_UNAVAILABLE:"mediaVolumeUnavailable",MEDIA_IS_PIP:"mediaIsPip",MEDIA_IS_CASTING:"mediaIsCasting",MEDIA_IS_AIRPLAYING:"mediaIsAirplaying",MEDIA_SUBTITLES_LIST:"mediaSubtitlesList",MEDIA_SUBTITLES_SHOWING:"mediaSubtitlesShowing",MEDIA_IS_FULLSCREEN:"mediaIsFullscreen",MEDIA_PLAYBACK_RATE:"mediaPlaybackRate",MEDIA_CURRENT_TIME:"mediaCurrentTime",MEDIA_DURATION:"mediaDuration",MEDIA_SEEKABLE:"mediaSeekable",MEDIA_PREVIEW_TIME:"mediaPreviewTime",MEDIA_PREVIEW_IMAGE:"mediaPreviewImage",MEDIA_PREVIEW_COORDS:"mediaPreviewCoords",MEDIA_PREVIEW_CHAPTER:"mediaPreviewChapter",MEDIA_LOADING:"mediaLoading",MEDIA_BUFFERED:"mediaBuffered",MEDIA_STREAM_TYPE:"mediaStreamType",MEDIA_TARGET_LIVE_WINDOW:"mediaTargetLiveWindow",MEDIA_TIME_IS_LIVE:"mediaTimeIsLive",MEDIA_RENDITION_LIST:"mediaRenditionList",MEDIA_RENDITION_SELECTED:"mediaRenditionSelected",MEDIA_AUDIO_TRACK_LIST:"mediaAudioTrackList",MEDIA_AUDIO_TRACK_ENABLED:"mediaAudioTrackEnabled",MEDIA_CHAPTERS_CUES:"mediaChaptersCues"},Rm=Object.entries(Lm),x=Rm.reduce((s,[e,t])=>(s[e]=`${t.toLowerCase()}`,s),{}),Xn=Rm.reduce((s,[e,t])=>(s[e]=`${t.toLowerCase()}`,s),{USER_INACTIVE:"userinactivechange",BREAKPOINTS_CHANGE:"breakpointchange",BREAKPOINTS_COMPUTED:"breakpointscomputed"});Object.entries(Xn).reduce((s,[e,t])=>{const i=x[e];return i&&(s[t]=i),s},{userinactivechange:"userinactive"});const pT=Object.entries(x).reduce((s,[e,t])=>{const i=Xn[e];return i&&(s[t]=i),s},{userinactive:"userinactivechange"}),As={SUBTITLES:"subtitles",CAPTIONS:"captions",CHAPTERS:"chapters",METADATA:"metadata"},Pn={DISABLED:"disabled",SHOWING:"showing"},vh={MOUSE:"mouse",TOUCH:"touch"},hi={UNAVAILABLE:"unavailable",UNSUPPORTED:"unsupported"},ns={LIVE:"live",ON_DEMAND:"on-demand",UNKNOWN:"unknown"},vT={FULLSCREEN:"fullscreen"},ci={AUDIO_PLAYER:()=>"audio player",VIDEO_PLAYER:()=>"video player",VOLUME:()=>"volume",SEEK:()=>"seek",CLOSED_CAPTIONS:()=>"closed captions",PLAYBACK_RATE:({playbackRate:s=1}={})=>`current playback rate ${s}`,PLAYBACK_TIME:()=>"playback time",MEDIA_LOADING:()=>"media loading",SETTINGS:()=>"settings",AUDIO_TRACKS:()=>"audio tracks",QUALITY:()=>"quality"},Vt={PLAY:()=>"play",PAUSE:()=>"pause",MUTE:()=>"mute",UNMUTE:()=>"unmute",ENTER_AIRPLAY:()=>"start airplay",EXIT_AIRPLAY:()=>"stop airplay",ENTER_CAST:()=>"start casting",EXIT_CAST:()=>"stop casting",ENTER_FULLSCREEN:()=>"enter fullscreen mode",EXIT_FULLSCREEN:()=>"exit fullscreen mode",ENTER_PIP:()=>"enter picture in picture mode",EXIT_PIP:()=>"exit picture in picture mode",SEEK_FORWARD_N_SECS:({seekOffset:s=30}={})=>`seek forward ${s} seconds`,SEEK_BACK_N_SECS:({seekOffset:s=30}={})=>`seek back ${s} seconds`,SEEK_LIVE:()=>"seek to live",PLAYING_LIVE:()=>"playing live"};function ET(s){return s?.map(TT).join(" ")}function yT(s){return s?.split(/\s+/).map(bT)}function TT(s){if(s){const{id:e,width:t,height:i}=s;return[e,t,i].filter(n=>n!=null).join(":")}}function bT(s){if(s){const[e,t,i]=s.split(":");return{id:e,width:t,height:i}}}function _T(s){return s?.map(AT).join(" ")}function ST(s){return s?.split(/\s+/).map(IT)}function AT(s){if(s){const{id:e,kind:t,language:i,label:n}=s;return[e,t,i,n].filter(r=>r!=null).join(":")}}function IT(s){if(s){const[e,t,i,n]=s.split(":");return{id:e,kind:t,language:i,label:n}}}function xT(s){return typeof s=="number"&&!Number.isNaN(s)&&Number.isFinite(s)}const km=s=>new Promise(e=>setTimeout(e,s)),Eh=[{singular:"hour",plural:"hours"},{singular:"minute",plural:"minutes"},{singular:"second",plural:"seconds"}],LT=(s,e)=>{const t=s===1?Eh[e].singular:Eh[e].plural;return`${s} ${t}`},br=s=>{if(!xT(s))return"";const e=Math.abs(s),t=e!==s,i=new Date(0,0,0,0,0,e,0);return`${[i.getHours(),i.getMinutes(),i.getSeconds()].map((o,d)=>o&<(o,d)).filter(o=>o).join(", ")}${t?" remaining":""}`};function Hs(s,e){let t=!1;s<0&&(t=!0,s=0-s),s=s<0?0:s;let i=Math.floor(s%60),n=Math.floor(s/60%60),r=Math.floor(s/3600);const a=Math.floor(e/60%60),o=Math.floor(e/3600);return(isNaN(s)||s===1/0)&&(r=n=i="0"),r=r>0||o>0?r+":":"",n=((r||a>=10)&&n<10?"0"+n:n)+":",i=i<10?"0"+i:i,(t?"-":"")+r+n+i}let Dm=class{addEventListener(){}removeEventListener(){}dispatchEvent(){return!0}};class yh extends Dm{}class RT{observe(){}unobserve(){}disconnect(){}}const Cm={createElement:function(){return new Uo.HTMLElement},createElementNS:function(){return new Uo.HTMLElement},addEventListener(){},removeEventListener(){},dispatchEvent(s){return!1}},Uo={ResizeObserver:RT,document:Cm,Node:yh,HTMLElement:class extends yh{},DocumentFragment:class extends Dm{},customElements:{get:function(){},define:function(){},whenDefined:function(){}},localStorage:{getItem(s){return null},setItem(s,e){},removeItem(s){}},CustomEvent:function(){},getComputedStyle:function(){},navigator:{languages:[],get userAgent(){return""}},matchMedia(s){return{matches:!1,media:s}}},wm=typeof window>"u"||typeof window.customElements>"u",Pm=Object.keys(Uo).every(s=>s in globalThis),B=wm&&!Pm?Uo:globalThis,ke=wm&&!Pm?Cm:globalThis.document,Th=new WeakMap,Jc=s=>{let e=Th.get(s);return e||Th.set(s,e=new Set),e},Mm=new B.ResizeObserver(s=>{for(let e of s)for(let t of Jc(e.target))t(e)});function Kn(s,e){Jc(s).add(e),Mm.observe(s)}function Cr(s,e){const t=Jc(s);t.delete(e),t.size||Mm.unobserve(s)}function Ii(s){var e;
66return(e=Ld(s))!=null?e:Xr(s,"media-controller")}function Ld(s){var e;const{MEDIA_CONTROLLER:t}=st,i=s.getAttribute(t);if(i)return(e=bl(s))==null?void 0:e.getElementById(i)}const Om=(s,e,t=".value")=>{const i=s.querySelector(t);i&&(i.textContent=e)},kT=(s,e)=>{const t=`slot[name="${e}"]`,i=s.shadowRoot.querySelector(t);return i?i.children:[]},Fm=(s,e)=>kT(s,e)[0],ls=(s,e)=>!s||!e?!1:s?.contains(e)?!0:ls(s,e.getRootNode().host),Xr=(s,e)=>{if(!s)return null;const t=s.closest(e);return t||Xr(s.getRootNode().host,e)};function eu(s=document){var e;const t=s?.activeElement;return t?(e=eu(t.shadowRoot))!=null?e:t:null}function bl(s){var e;const t=(e=s?.getRootNode)==null?void 0:e.call(s);return t instanceof ShadowRoot||t instanceof Document?t:null}function DT(s,e=3){if(s.checkVisibility)return s.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0});let t=s;for(;t&&e>0;){const i=getComputedStyle(t);if(i.opacity==="0"||i.visibility==="hidden"||i.display==="none")return!1;t=t.parentElement,e--}return!0}function CT(s,e,t,i){const n=Kl(t,i),r=Kl(t,{x:s,y:e}),a=Kl(i,{x:s,y:e});return r>n||a>n?r>a?1:0:r/n}function Kl(s,e){return Math.sqrt(Math.pow(e.x-s.x,2)+Math.pow(e.y-s.y,2))}function At(s,e){const t=wT(s,i=>i===e);return t||$m(s,e)}function wT(s,e){var t;let i;for(i of s.querySelectorAll("style")){let n;try{n=(t=i.sheet)==null?void 0:t.cssRules}catch{continue}for(let r of n??[])if(e(r.selectorText))return r}}function $m(s,e){var t,i;const n=(t=s.querySelectorAll("style"))!=null?t:[],r=n?.[n.length-1];return r?.sheet?(r?.sheet.insertRule(`${e}{}`,r.sheet.cssRules.length),(i=r.sheet.cssRules)==null?void 0:i[r.sheet.cssRules.length-1]):(console.warn("Media Chrome: No style sheet found on style tag of",s),{style:{setProperty:()=>{},removeProperty:()=>"",getPropertyValue:()=>""}})}function Tt(s,e,t=Number.NaN){const i=s.getAttribute(e);return i!=null?+i:t}function Kt(s,e,t){const i=+t;if(t==null||Number.isNaN(i)){s.hasAttribute(e)&&s.removeAttribute(e);return}Tt(s,e,void 0)!==i&&s.setAttribute(e,`${i}`)}function Ft(s,e){return s.hasAttribute(e)}function $t(s,e,t){if(t==null){s.hasAttribute(e)&&s.removeAttribute(e);return}Ft(s,e)!=t&&s.toggleAttribute(e,t)}function Wt(s,e,t=null){var i;return(i=s.getAttribute(e))!=null?i:t}function qt(s,e,t){if(t==null){s.hasAttribute(e)&&s.removeAttribute(e);return}const i=`${t}`;Wt(s,e,void 0)!==i&&s.setAttribute(e,i)}var Nm=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},ms=(s,e,t)=>(Nm(s,e,"read from private field"),t?t.call(s):e.get(s)),PT=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},da=(s,e,t,i)=>(Nm(s,e,"write to private field"),e.set(s,t),t),Jt;const Um=ke.createElement("template");Um.innerHTML=` 67<style> 68 :host { 69 display: var(--media-control-display, var(--media-gesture-receiver-display, inline-block)); 70 box-sizing: border-box; 71 } 72</style> 73`;class MT extends B.HTMLElement{constructor(e={}){if(super(),PT(this,Jt,void 0),!this.shadowRoot){const t=this.attachShadow({mode:"open"}),i=Um.content.cloneNode(!0);this.nativeEl=i;let n=e.slotTemplate;n||(n=ke.createElement("template"),n.innerHTML=`<slot>${e.defaultContent||""}</slot>`),this.nativeEl.appendChild(n.content.cloneNode(!0)),t.appendChild(i)}}static get observedAttributes(){return[st.MEDIA_CONTROLLER,x.MEDIA_PAUSED]}attributeChangedCallback(e,t,i){var n,r,a,o,d;e===st.MEDIA_CONTROLLER&&(t&&((r=(n=ms(this,Jt))==null?void 0:n.unassociateElement)==null||r.call(n,this),da(this,Jt,null)),i&&this.isConnected&&(da(this,Jt,(a=this.getRootNode())==null?void 0:a.getElementById(i)),(d=(o=ms(this,Jt))==null?void 0:o.associateElement)==null||d.call(o,this)))}connectedCallback(){var e,t,i,n;this.tabIndex=-1,this.setAttribute("aria-hidden","true"),da(this,Jt,OT(this)),this.getAttribute(st.MEDIA_CONTROLLER)&&((t=(e=ms(this,Jt))==null?void 0:e.associateElement)==null||t.call(e,this)),(i=ms(this,Jt))==null||i.addEventListener("pointerdown",this),(n=ms(this,Jt))==null||n.addEventListener("click",this)}disconnectedCallback(){var e,t,i,n;this.getAttribute(st.MEDIA_CONTROLLER)&&((t=(e=ms(this,Jt))==null?void 0:e.unassociateElement)==null||t.call(e,this)),(i=ms(this,Jt))==null||i.removeEventListener("pointerdown",this),(n=ms(this,Jt))==null||n.removeEventListener("click",this),da(this,Jt,null)}handleEvent(e){var t;const i=(t=e.composedPath())==null?void 0:t[0];if(["video","media-controller"].includes(i?.localName)){if(e.type==="pointerdown")this._pointerType=e.pointerType;else if(e.type==="click"){const{clientX:r,clientY:a}=e,{left:o,top:d,width:l,height:c}=this.getBoundingClientRect(),u=r-o,h=a-d;if(u<0||h<0||u>l||h>c||l===0&&c===0)return;const{pointerType:f=this._pointerType}=e;if(this._pointerType=void 0,f===vh.TOUCH){this.handleTap(e);return}else if(f===vh.MOUSE){this.handleMouseClick(e);return}}}}get mediaPaused(){return Ft(this,x.MEDIA_PAUSED)}set mediaPaused(e){$t(this,x.MEDIA_PAUSED,e)}handleTap(e){}handleMouseClick(e){const t=this.mediaPaused?Ee.MEDIA_PLAY_REQUEST:Ee.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new B.CustomEvent(t,{composed:!0,bubbles:!0}))}}Jt=new WeakMap;function OT(s){var e;const t=s.getAttribute(st.MEDIA_CONTROLLER);return t?(e=s.getRootNode())==null?void 0:e.getElementById(t):Xr(s,"media-controller")}B.customElements.get("media-gesture-receiver")||B.customElements.define("media-gesture-receiver",MT);var FT=Object.defineProperty,$T=(s,e,t)=>e in s?FT(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,NT=(s,e,t)=>($T(s,e+"",t),t),tu=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},Rd=(s,e,t)=>(tu(s,e,"read from private field"),e.get(s)),Ms=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},Hl=(s,e,t,i)=>(tu(s,e,"write to private field"),e.set(s,t),t),Ai=(s,e,t)=>(tu(s,e,"access private method"),t),Bo,hn,kd,Bm,Dd,Gm,wr,_l,Sl,iu,Hn,Pr;const ze={AUDIO:"audio",AUTOHIDE:"autohide",BREAKPOINTS:"breakpoints",GESTURES_DISABLED:"gesturesdisabled",KEYBOARD_CONTROL:"keyboardcontrol",NO_AUTOHIDE:"noautohide",USER_INACTIVE:"userinactive"},Km=ke.createElement("template");Km.innerHTML=` 74 <style> 75 76 :host([${x.MEDIA_IS_FULLSCREEN}]) ::slotted([slot=media]) { 77 outline: none; 78 } 79 80 :host { 81 box-sizing: border-box; 82 position: relative; 83 display: inline-block; 84 line-height: 0; 85 background-color: var(--media-background-color, #000); 86 } 87 88 :host(:not([${ze.AUDIO}])) [part~=layer]:not([part~=media-layer]) { 89 position: absolute; 90 top: 0; 91 left: 0; 92 bottom: 0; 93 right: 0; 94 display: flex; 95 flex-flow: column nowrap; 96 align-items: start; 97 pointer-events: none; 98 background: none; 99 } 100 101 slot[name=media] { 102 display: var(--media-slot-display, contents); 103 } 104 105 106 :host([${ze.AUDIO}]) slot[name=media] { 107 display: var(--media-slot-display, none); 108 } 109 110 111 :host([${ze.AUDIO}]) [part~=layer][part~=gesture-layer] { 112 height: 0; 113 display: block; 114 } 115 116 117 :host(:not([${ze.AUDIO}])[${ze.GESTURES_DISABLED}]) ::slotted([slot=gestures-chrome]), 118 :host(:not([${ze.AUDIO}])[${ze.GESTURES_DISABLED}]) media-gesture-receiver[slot=gestures-chrome] { 119 display: none; 120 } 121 122 123 ::slotted(:not([slot=media]):not([slot=poster]):not(media-loading-indicator):not([hidden])) { 124 pointer-events: auto; 125 } 126 127 :host(:not([${ze.AUDIO}])) *[part~=layer][part~=centered-layer] { 128 align-items: center; 129 justify-content: center; 130 } 131 132 :host(:not([${ze.AUDIO}])) ::slotted(media-gesture-receiver[slot=gestures-chrome]), 133 :host(:not([${ze.AUDIO}])) media-gesture-receiver[slot=gestures-chrome] { 134 align-self: stretch; 135 flex-grow: 1; 136 } 137 138 slot[name=middle-chrome] { 139 display: inline; 140 flex-grow: 1; 141 pointer-events: none; 142 background: none; 143 } 144 145 146 ::slotted([slot=media]), 147 ::slotted([slot=poster]) { 148 width: 100%; 149 height: 100%; 150 } 151 152 153 :host(:not([${ze.AUDIO}])) .spacer { 154 flex-grow: 1; 155 } 156 157 158 :host(:-webkit-full-screen) { 159 160 width: 100% !important; 161 height: 100% !important; 162 } 163 164 165 ::slotted(:not([slot=media]):not([slot=poster]):not([${ze.NO_AUTOHIDE}]):not([hidden])) { 166 opacity: 1; 167 transition: opacity 0.25s; 168 } 169 170 171 :host([${ze.USER_INACTIVE}]:not([${x.MEDIA_PAUSED}]):not([${x.MEDIA_IS_AIRPLAYING}
171]):not([${x.MEDIA_IS_CASTING}]):not([${ze.AUDIO}])) ::slotted(:not([slot=media]):not([slot=poster]):not([${ze.NO_AUTOHIDE}])) { 172 opacity: 0; 173 transition: opacity 1s; 174 } 175 176 :host([${ze.USER_INACTIVE}]:not([${x.MEDIA_PAUSED}]):not([${x.MEDIA_IS_CASTING}]):not([${ze.AUDIO}])) ::slotted([slot=media]) { 177 cursor: none; 178 } 179 180 ::slotted(media-control-bar) { 181 align-self: stretch; 182 } 183 184 185 :host(:not([${ze.AUDIO}])[${x.MEDIA_HAS_PLAYED}]) slot[name=poster] { 186 display: none; 187 } 188 189 ::slotted([role="menu"]) { 190 align-self: end; 191 } 192 193 ::slotted([role="dialog"]) { 194 align-self: center; 195 } 196 </style> 197 198 <slot name="media" part="layer media-layer"></slot> 199 <slot name="poster" part="layer poster-layer"></slot> 200 <slot name="gestures-chrome" part="layer gesture-layer"> 201 <media-gesture-receiver slot="gestures-chrome"></media-gesture-receiver> 202 </slot> 203 <span part="layer vertical-layer"> 204 <slot name="top-chrome" part="top chrome"></slot> 205 <slot name="middle-chrome" part="middle chrome"></slot> 206 <slot name="centered-chrome" part="layer centered-layer center centered chrome"></slot> 207 208 <slot part="bottom chrome"></slot> 209 </span> 210`;const UT=Object.values(x),BT="sm:384 md:576 lg:768 xl:960";function GT(s){KT(s.target,s.contentRect.width)}function KT(s,e){var t;if(!s.isConnected)return;const i=(t=s.getAttribute(ze.BREAKPOINTS))!=null?t:BT,n=HT(i),r=VT(n,e);let a=!1;if(Object.keys(n).forEach(o=>{if(r.includes(o)){s.hasAttribute(`breakpoint${o}`)||(s.setAttribute(`breakpoint${o}`,""),a=!0);return}s.hasAttribute(`breakpoint${o}`)&&(s.removeAttribute(`breakpoint${o}`),a=!0)}),a){const o=new CustomEvent(Xn.BREAKPOINTS_CHANGE,{detail:r});s.dispatchEvent(o)}}function HT(s){const e=s.split(/\s+/);return Object.fromEntries(e.map(t=>t.split(":")))}function VT(s,e){return Object.keys(s).filter(t=>e>=s[t])}class Hm extends B.HTMLElement{constructor(){super(),Ms(this,kd),Ms(this,Dd),Ms(this,wr),Ms(this,Sl),Ms(this,Hn),Ms(this,Bo,0),Ms(this,hn,void 0),NT(this,"breakpointsComputed",!1),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Km.content.cloneNode(!0)));const e=a=>{const o=this.media;for(let d of a)d.type==="childList"&&(d.removedNodes.forEach(l=>{if(l.slot=="media"&&d.target==this){let c=d.previousSibling&&d.previousSibling.previousElementSibling;if(!c||!o)this.mediaUnsetCallback(l);else{let u=c.slot!=="media";for(;(c=c.previousSibling)!==null;)c.slot=="media"&&(u=!1);u&&this.mediaUnsetCallback(l)}}}),o&&d.addedNodes.forEach(l=>{l===o&&this.handleMediaUpdated(o)}))};new MutationObserver(e).observe(this,{childList:!0,subtree:!0});let i=!1;Kn(this,a=>{i||(setTimeout(()=>{GT(a),i=!1,this.breakpointsComputed||(this.breakpointsComputed=!0,this.dispatchEvent(new CustomEvent(Xn.BREAKPOINTS_COMPUTED,{bubbles:!0,composed:!0})))},0),i=!0)});let r=this.querySelector(":scope > slot[slot=media]");r&&r.addEventListener("slotchange",()=>{if(!r.assignedElements({flatten:!0}).length){Rd(this,hn)&&this.mediaUnsetCallback(Rd(this,hn));return}this.handleMediaUpdated(this.media)})}static get observedAttributes(){return[ze.AUTOHIDE,ze.GESTURES_DISABLED].concat(UT).filter(e=>![x.MEDIA_RENDITION_LIST,x.MEDIA_AUDIO_TRACK_LIST,x.MEDIA_CHAPTERS_CUES].includes(e))}attributeChangedCallback(e,t,i){e.toLowerCase()==ze.AUTOHIDE&&(this.autohide=i)}get media(){let e=this.querySelector(":scope > [slot=media]");return e?.nodeName=="SLOT"&&(e=e.assignedElements({flatten:!0})[0]),e}async handleMediaUpdated(e){e&&(Hl(this,hn,e),e.localName.includes("-")&&await B.customElements.whenDefined(e.localName),this.mediaSetCallback(e))}connectedCallback(){var e;const i=this.getAttribute(ze.AUDIO)!=null?ci.AUDIO_PLAYER():ci.VIDEO_PLAYER();this.setAttribute("role","region"),this.setAttribute("aria-label",i),this.handleMediaUpdated(this.media),this.setAttribute(ze.USER_INACTIVE,""),this.addEventListener("pointerdown",this),this.addEventListener("pointermove",this),this.addEventListener("pointerup",this),this.addEventListener("mouseleave",this),this.addEventListener("keyup",this),(e=B.window)==null||e.addEventListener("mouseup",this)}disconnectedCallback(){var e;this.media&&this.mediaUnsetCallback(this.media),(e=B.window)==null||e.removeEventListener("mouseup",this)}mediaSetCallback(e){}mediaUnsetCallback(e){Hl(this,hn,null)}handleEvent(e){switch(e.type){case"pointerdown":Hl(this,Bo,e.timeStamp);break;case"pointermove":Ai(this,kd,Bm).call(this,e);break;case"pointerup":Ai(this,Dd,Gm).call(this,e);break;case"mouseleave":Ai(this,wr,_l).call(this);break;case"mouseup":this.removeAttribute(ze.KEYBOARD_CONTROL);break;case"keyup":Ai(this,Hn,Pr).call(this),this.setAttribute(ze.KEYBOARD_CONTROL,"");break}}set autohide(e){e=Number(e),this._autohide=isNaN(e)?0:e}get autohide(){return this._autohide===void 0?2:this._autohide}}Bo=new WeakMap;hn=new WeakMap;kd=new WeakSet;Bm=function(s){s.pointerType!=="mouse"&&s.timeStamp-Rd(this,Bo)<250||(Ai(this,Sl,iu).call(this),clearTimeout(this._inactiveTimeout),[this,this.media].includes(s.target)&&Ai(this,Hn,Pr).call(this))};Dd=new WeakSet;Gm=function(s){if(s.pointerType==="touch"){const e=!this.hasAttribute(ze.USER_INACTIVE);[this,this.media].includes(s.target)&&e?Ai(this,wr,_l).call(this):Ai(this,Hn,Pr).call(this)}else s.composedPath().some(e=>["media-play-button","media-fullscreen-button"].includes(e?.localName))&&Ai(this,Hn,Pr).call(this)};wr=new WeakSet;_l=function(){if(this.autohide<0||this.hasAttribute(ze.USER_INACTIVE))return;this.setAttribute(ze.USER_INACTIVE,"");const s=new B.CustomEvent(Xn.USER_INACTIVE,{composed:!0,bubbles:!0,detail:!0});this.dispatchEvent(s)};Sl=new WeakSet;iu=function(){if(!this.hasAttribute(ze.USER_INACTIVE))return;this.removeAttribute(ze.USER_INACTIVE);const s=new B.CustomEvent(Xn.USER_INACTIVE,{composed:!0,bubbles:!0,detail:!1});this.dispatchEvent(s)};Hn=new WeakSet;Pr=function(){Ai(this,Sl,iu).call(this),clearTimeout(this._inactiveTimeout),!(this.autohide<0)&&(this._inactiveTimeout=setTimeout(()=>{Ai(this,wr,_l).call(this)},this.autohide*1e3))};B.customElements.get("media-container")||B.customElements.define("media-container",Hm);var Vm=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},Pt=(s,e,t)=>(Vm(s,e,"read from private field"),t?t.call(s):e.get(s)),Jn=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},ca=(s,e,t,i)=>(Vm(s,e,"write to private field"),e.set(s,t),t),fn,mn,Go,Ks,is,Es;class Al{constructor(e,t,{defaultValue:i}={defaultValue:void 0}){Jn(this,is),Jn(this,fn,void 0),Jn(this,mn,void 0),Jn(this,Go,void 0),Jn(this,Ks,new Set),ca(this,fn,e),ca(this,mn,t),ca(this,Go,new Set(i))}[Symbol.iterator](){return Pt(this,is,Es).values()}get length(){return Pt(this,is,Es).size}get value(){var e;return(e=[...Pt(this,is,Es)].join(" "))!=null?e:""}set value(e){var t;e!==this.value&&(ca(this,Ks,new Set),this.add(...(t=e?.split(" "))!=null?t:[]))}toString(){return this.value}item(e){return[...Pt(this,is,Es)][e]}values(){return Pt(this,is,Es).values()}
210forEach(e){Pt(this,is,Es).forEach(e)}add(...e){var t,i;e.forEach(n=>Pt(this,Ks).add(n)),!(this.value===""&&!((t=Pt(this,fn))!=null&&t.hasAttribute(`${Pt(this,mn)}`)))&&((i=Pt(this,fn))==null||i.setAttribute(`${Pt(this,mn)}`,`${this.value}`))}remove(...e){var t;e.forEach(i=>Pt(this,Ks).delete(i)),(t=Pt(this,fn))==null||t.setAttribute(`${Pt(this,mn)}`,`${this.value}`)}contains(e){return Pt(this,is,Es).has(e)}toggle(e,t){return typeof t<"u"?t?(this.add(e),!0):(this.remove(e),!1):this.contains(e)?(this.remove(e),!1):(this.add(e),!0)}replace(e,t){return this.remove(e),this.add(t),e===t}}fn=new WeakMap;mn=new WeakMap;Go=new WeakMap;Ks=new WeakMap;is=new WeakSet;Es=function(){return Pt(this,Ks).size?Pt(this,Ks):Pt(this,Go)};const WT=(s="")=>s.split(/\s+/),Wm=(s="")=>{let[e,t,i]=s.split(":");const n=i?decodeURIComponent(i):void 0;return e=e==="cc"?"captions":"subtitles",{kind:e,language:t,label:n}},Il=(s="",e={})=>WT(s).map(t=>{const i=Wm(t);return{...e,...i}}),qm=s=>s?Array.isArray(s)?s.map(e=>typeof e=="string"?Wm(e):e):typeof s=="string"?Il(s):[s]:[],Cd=({kind:s,label:e,language:t}={kind:"subtitles"})=>e?`${s==="captions"?"cc":"sb"}:${t}:${encodeURIComponent(e)}`:t,Mr=(s=[])=>Array.prototype.map.call(s,Cd).join(" "),qT=(s,e)=>t=>t[s]===e,Ym=s=>{const e=Object.entries(s).map(([t,i])=>qT(t,i));return t=>e.every(i=>i(t))},_r=(s,e=[],t=[])=>{const i=qm(t).map(Ym),n=r=>i.some(a=>a(r));Array.from(e).filter(n).forEach(r=>{r.mode=s})},xl=(s,e=()=>!0)=>{if(!s?.textTracks)return[];const t=typeof e=="function"?e:Ym(e);return Array.from(s.textTracks).filter(t)},zm=s=>{var e;return!!((e=s.mediaSubtitlesShowing)!=null&&e.length)||s.hasAttribute(x.MEDIA_SUBTITLES_SHOWING)},YT=s=>{var e;const{media:t,fullscreenElement:i}=s,n=i&&"requestFullscreen"in i?"requestFullscreen":i&&"webkitRequestFullScreen"in i?"webkitRequestFullScreen":void 0;if(n){const r=(e=i[n])==null?void 0:e.call(i);if(r instanceof Promise)return r.catch(()=>{})}else t?.webkitEnterFullscreen?t.webkitEnterFullscreen():t?.requestFullscreen&&t.requestFullscreen()},bh="exitFullscreen"in ke?"exitFullscreen":"webkitExitFullscreen"in ke?"webkitExitFullscreen":"webkitCancelFullScreen"in ke?"webkitCancelFullScreen":void 0,zT=s=>{var e;const{documentElement:t}=s;if(bh){const i=(e=t?.[bh])==null?void 0:e.call(t);if(i instanceof Promise)return i.catch(()=>{})}},dr="fullscreenElement"in ke?"fullscreenElement":"webkitFullscreenElement"in ke?"webkitFullscreenElement":void 0,jT=s=>{const{documentElement:e,media:t}=s,i=e?.[dr];return!i&&"webkitDisplayingFullscreen"in t&&"webkitPresentationMode"in t&&t.webkitDisplayingFullscreen&&t.webkitPresentationMode===vT.FULLSCREEN?t:i},XT=s=>{var e;const{media:t,documentElement:i,fullscreenElement:n=t}=s;if(!t||!i)return!1;const r=jT(s);if(!r)return!1;if(r===n||r===t)return!0;if(r.localName.includes("-")){let a=r.shadowRoot;if(!(dr in a))return ls(r,n);for(;a?.[dr];){if(a[dr]===n)return!0;a=(e=a[dr])==null?void 0:e.shadowRoot}}return!1},QT="fullscreenEnabled"in ke?"fullscreenEnabled":"webkitFullscreenEnabled"in ke?"webkitFullscreenEnabled":void 0,ZT=s=>{const{documentElement:e,media:t}=s;return!!e?.[QT]||t&&"webkitSupportsFullscreen"in t};let ua;const su=()=>{var s,e;return ua||(ua=(e=(s=ke)==null?void 0:s.createElement)==null?void 0:e.call(s,"video"),ua)},JT=async(s=su())=>{if(!s)return!1;const e=s.volume;return s.volume=e/2+.1,await km(0),s.volume!==e},eb=/.*Version\/.*Safari\/.*/.test(B.navigator.userAgent),jm=(s=su())=>B.matchMedia("(display-mode: standalone)").matches&&eb?!1:typeof s?.requestPictureInPicture=="function",Xm=(s=su())=>ZT({documentElement:ke,media:s}),tb=Xm(),ib=jm(),sb=!!B.WebKitPlaybackTargetAvailabilityEvent,nb=!!B.chrome,Ko=s=>xl(s.media,e=>[As.SUBTITLES,As.CAPTIONS].includes(e.kind)).sort((e,t)=>e.kind>=t.kind?1:-1),Qm=s=>xl(s.media,e=>e.mode===Pn.SHOWING&&[As.SUBTITLES,As.CAPTIONS].includes(e.kind)),Zm=(s,e)=>{const t=Ko(s),i=Qm(s),n=!!i.length;if(t.length){if(e===!1||n&&e!==!0)_r(Pn.DISABLED,t,i);else if(e===!0||!n&&e!==!1){let r=t[0];const{options:a}=s;if(!a?.noSubtitlesLangPref){const c=globalThis.localStorage.getItem("media-chrome-pref-subtitles-lang"),u=c?[c,...globalThis.navigator.languages]:globalThis.navigator.languages,h=t.filter(f=>u.some(m=>f.language.toLowerCase().startsWith(m.split("-")[0]))).sort((f,m)=>
210{const p=u.findIndex(y=>f.language.toLowerCase().startsWith(y.split("-")[0])),g=u.findIndex(y=>m.language.toLowerCase().startsWith(y.split("-")[0]));return p-g});h[0]&&(r=h[0])}const{language:o,label:d,kind:l}=r;_r(Pn.DISABLED,t,i),_r(Pn.SHOWING,t,[{language:o,label:d,kind:l}])}}},nu=(s,e)=>s===e?!0:typeof s!=typeof e?!1:typeof s=="number"&&Number.isNaN(s)&&Number.isNaN(e)?!0:typeof s!="object"?!1:Array.isArray(s)?rb(s,e):Object.entries(s).every(([t,i])=>t in e&&nu(i,e[t])),rb=(s,e)=>{const t=Array.isArray(s),i=Array.isArray(e);return t!==i?!1:t||i?s.length!==e.length?!1:s.every((n,r)=>nu(n,e[r])):!0},ab=Object.values(ns);let Ho;const ob=JT().then(s=>(Ho=s,Ho)),lb=async(...s)=>{await Promise.all(s.filter(e=>e).map(async e=>{if(!("localName"in e&&e instanceof B.HTMLElement))return;const t=e.localName;if(!t.includes("-"))return;const i=B.customElements.get(t);i&&e instanceof i||(await B.customElements.whenDefined(t),B.customElements.upgrade(e))}))},qa={mediaPaused:{get(s){var e;const{media:t}=s;return(e=t?.paused)!=null?e:!0},set(s,e){var t;const{media:i}=e;i&&(s?i.pause():(t=i.play())==null||t.catch(()=>{}))},mediaEvents:["play","playing","pause","emptied"]},mediaHasPlayed:{get(s,e){const{media:t}=s;return t?e?e.type==="playing":!t.paused:!1},mediaEvents:["playing","emptied"]},mediaEnded:{get(s){var e;const{media:t}=s;return(e=t?.ended)!=null?e:!1},mediaEvents:["seeked","ended","emptied"]},mediaPlaybackRate:{get(s){var e;const{media:t}=s;return(e=t?.playbackRate)!=null?e:1},set(s,e){const{media:t}=e;t&&Number.isFinite(+s)&&(t.playbackRate=+s)},mediaEvents:["ratechange","loadstart"]},mediaMuted:{get(s){var e;const{media:t}=s;return(e=t?.muted)!=null?e:!1},set(s,e){const{media:t}=e;t&&(t.muted=s)},mediaEvents:["volumechange"]},mediaVolume:{get(s){var e;const{media:t}=s;return(e=t?.volume)!=null?e:1},set(s,e){const{media:t}=e;if(t){try{s==null?B.localStorage.removeItem("media-chrome-pref-volume"):B.localStorage.setItem("media-chrome-pref-volume",s.toString())}catch{}Number.isFinite(+s)&&(t.volume=+s)}},mediaEvents:["volumechange"],stateOwnersUpdateHandlers:[(s,e)=>{const{options:{noVolumePref:t}}=e;if(!t)try{const i=B.localStorage.getItem("media-chrome-pref-volume");if(i==null)return;qa.mediaVolume.set(+i,e),s(i)}catch(i){console.debug("Error getting volume pref",i)}}]},mediaVolumeLevel:{get(s){const{media:e}=s;return typeof e?.volume>"u"?"high":e.muted||e.volume===0?"off":e.volume<.5?"low":e.volume<.75?"medium":"high"},mediaEvents:["volumechange"]},mediaCurrentTime:{get(s){var e;const{media:t}=s;return(e=t?.currentTime)!=null?e:0},set(s,e){const{media:t}=e;!t||t.readyState===0||(t.currentTime=s)},mediaEvents:["timeupdate","loadedmetadata"]},mediaDuration:{get(s){const{media:e,options:{defaultDuration:t}={}}=s;return t&&(!e||!e.duration||Number.isNaN(e.duration)||!Number.isFinite(e.duration))?t:Number.isFinite(e?.duration)?e.duration:Number.NaN},mediaEvents:["durationchange","loadedmetadata","emptied"]},mediaLoading:{get(s){const{media:e}=s;return e?.readyState<3},mediaEvents:["waiting","playing","emptied"]},mediaSeekable:{get(s){var e;const{media:t}=s;if(!((e=t?.seekable)!=null&&e.length))return;const i=t.seekable.start(0),n=t.seekable.end(t.seekable.length-1);if(!(!i&&!n))return[Number(i.toFixed(3)),Number(n.toFixed(3))]},mediaEvents:["loadedmetadata","emptied","progress","seekablechange"]},mediaBuffered:{get(s){var e;const{media:t}=s,i=(e=t?.buffered)!=null?e:[];return Array.from(i).map((n,r)=>[Number(i.start(r).toFixed(3)),Number(i.end(r).toFixed(3))])},mediaEvents:["progress","emptied"]},mediaStreamType:{get(s){const{media:e,options:{defaultStreamType:t}={}}=s,i=[ns.LIVE,ns.ON_DEMAND].includes(t)?t:void 0;if(!e)return i;const{streamType:n}=e;if(ab.includes(n))return n===ns.UNKNOWN?i:n;const r=e.duration;return r===1/0?ns.LIVE:Number.isFinite(r)?ns.ON_DEMAND:i},mediaEvents:["emptied","durationchange","loadedmetadata","streamtypechange"]},mediaTargetLiveWindow:{get(s){const{media:e}=s;if(!e)return Number.NaN;const{targetLiveWindow:t}=e,i=qa.mediaStreamType.get(s);return(t==null||Number.isNaN(t))&&i===ns.LIVE?0:t}
210,mediaEvents:["emptied","durationchange","loadedmetadata","streamtypechange","targetlivewindowchange"]},mediaTimeIsLive:{get(s){const{media:e,options:{liveEdgeOffset:t=10}={}}=s;if(!e)return!1;if(typeof e.liveEdgeStart=="number")return Number.isNaN(e.liveEdgeStart)?!1:e.currentTime>=e.liveEdgeStart;if(!(qa.mediaStreamType.get(s)===ns.LIVE))return!1;const n=e.seekable;if(!n)return!0;if(!n.length)return!1;const r=n.end(n.length-1)-t;return e.currentTime>=r},mediaEvents:["playing","timeupdate","progress","waiting","emptied"]},mediaSubtitlesList:{get(s){return Ko(s).map(({kind:e,label:t,language:i})=>({kind:e,label:t,language:i}))},mediaEvents:["loadstart"],textTracksEvents:["addtrack","removetrack"]},mediaSubtitlesShowing:{get(s){return Qm(s).map(({kind:e,label:t,language:i})=>({kind:e,label:t,language:i}))},mediaEvents:["loadstart"],textTracksEvents:["addtrack","removetrack","change"],stateOwnersUpdateHandlers:[(s,e)=>{var t,i;const{media:n,options:r}=e;if(!n)return;const a=o=>{var d;!r.defaultSubtitles||o&&![As.CAPTIONS,As.SUBTITLES].includes((d=o?.track)==null?void 0:d.kind)||Zm(e,!0)};return(t=n.textTracks)==null||t.addEventListener("addtrack",a),(i=n.textTracks)==null||i.addEventListener("removetrack",a),a(),()=>{var o,d;(o=n.textTracks)==null||o.removeEventListener("addtrack",a),(d=n.textTracks)==null||d.removeEventListener("removetrack",a)}}]},mediaChaptersCues:{get(s){var e;const{media:t}=s;if(!t)return[];const[i]=xl(t,{kind:As.CHAPTERS});return Array.from((e=i?.cues)!=null?e:[]).map(({text:n,startTime:r,endTime:a})=>({text:n,startTime:r,endTime:a}))},mediaEvents:["loadstart","loadedmetadata"],textTracksEvents:["addtrack","removetrack","change"],stateOwnersUpdateHandlers:[(s,e)=>{const{media:t}=e;if(!t)return;const i=t.querySelector('track[kind="chapters"][default][src]');return i?.addEventListener("load",s),()=>{i?.removeEventListener("load",s)}}]},mediaIsPip:{get(s){var e,t;const{media:i,documentElement:n}=s;if(!i||!n||!n.pictureInPictureElement)return!1;if(n.pictureInPictureElement===i)return!0;if(n.pictureInPictureElement instanceof HTMLMediaElement)return(e=i.localName)!=null&&e.includes("-")?ls(i,n.pictureInPictureElement):!1;if(n.pictureInPictureElement.localName.includes("-")){let r=n.pictureInPictureElement.shadowRoot;for(;r?.pictureInPictureElement;){if(r.pictureInPictureElement===i)return!0;r=(t=r.pictureInPictureElement)==null?void 0:t.shadowRoot}}return!1},set(s,e){const{media:t}=e;if(t)if(s){if(!ke.pictureInPictureEnabled){console.warn("MediaChrome: Picture-in-picture is not enabled");return}if(!t.requestPictureInPicture){console.warn("MediaChrome: The current media does not support picture-in-picture");return}const i=()=>{console.warn("MediaChrome: The media is not ready for picture-in-picture. It must have a readyState > 0.")};t.requestPictureInPicture().catch(n=>{if(n.code===11){if(!t.src){console.warn("MediaChrome: The media is not ready for picture-in-picture. It must have a src set.");return}if(t.readyState===0&&t.preload==="none"){const r=()=>{t.removeEventListener("loadedmetadata",a),t.preload="none"},a=()=>{t.requestPictureInPicture().catch(i),r()};t.addEventListener("loadedmetadata",a),t.preload="metadata",setTimeout(()=>{t.readyState===0&&i(),r()},1e3)}else throw n}else throw n})}else ke.pictureInPictureElement&&ke.exitPictureInPicture()},mediaEvents:["enterpictureinpicture","leavepictureinpicture"]},mediaRenditionList:{get(s){var e;const{media:t}=s;return[...(e=t?.videoRenditions)!=null?e:[]].map(i=>({...i}))},mediaEvents:["emptied","loadstart"],videoRenditionsEvents:["addrendition","removerendition"]},mediaRenditionSelected:{get(s){var e,t,i;const{media:n}=s;return(i=(t=n?.videoRenditions)==null?void 0:t[(e=n.videoRenditions)==null?void 0:e.selectedIndex])==null?void 0:i.id},set(s,e){const{media:t}=e;if(!t?.videoRenditions){console.warn("MediaController: Rendition selection not supported by this media.");return}const i=s,n=Array.prototype.findIndex.call(t.videoRenditions,r=>r.id==i);t.videoRenditions.selectedIndex!=n&&(t.videoRenditions.selectedIndex=n)},mediaEvents:["emptied"],videoRenditionsEvents:["addrendition","removerendition","change"]},mediaAudioTrackList:{get(s){var e;const{media:t}=s;return[...(e=t?.audioTracks)!=null?e:[]]},mediaEvents:["emptied","loadstart"],audioTracksEvents:["addtrack","removetrack"]},mediaAudioTrackEnabled:{get(s){var e,t;const{media:i}=s;return(t=[...(e=i?.audioTracks)!=null?e:[]].find(n=>n.enabled))==null?void 0:t.id},set(s,e){const{media:t}=e;if(!t?.audioTracks){console.warn("MediaChrome: Audio track selection not supported by this media.");return}const i=s;for(let n of t.audioTracks)n.enabled=i==n.id},mediaEvents:["emptied"],audioTracksEvents:["addtrack","removetrack","change"]},mediaIsFullscreen:{get(s){return XT(s)},set(s,e){s?YT(e):zT(e)},rootEvents:["fullscreenchange","webkitfullscreenchange"],mediaEvents:["webkitbeginfullscreen","webkitendfullscreen","webkitpresentationmodechanged"]},mediaIsCasting:{get(s){var e;const{media:t}=s;return!t?.remote||((e=t.remote)==null?void 0:e.state)==="disconnected"?!1:!!t.remote.state},set(s,e){var t,i;const{media:n}=e;if(n&&!(s&&((t=n.remote)==null?void 0:t.state)!=="disconnected")&&!(!s&&((i=n.remote)==null?void 0:i.state)!=="connected")){if(typeof n.remote.prompt!="function"){console.warn("MediaChrome: Casting is not supported in this environment");return}n.remote.prompt().catch(()=>{})}},remoteEvents:["connect","connecting","disconnect"]},mediaIsAirplaying:{get(){return!1},set(s,e){const{media:t}=e;if(t){if(!(t.webkitShowPlaybackTargetPicker&&B.WebKitPlaybackTargetAvailabilityEvent)){console.warn("MediaChrome: received a request to select AirPlay but AirPlay is not supported in this environment");return}t.webkitShowPlaybackTargetPicker()}},mediaEvents:["webkitcurrentplaybacktargetiswirelesschanged"]},mediaFullscreenUnavailable:{get(s){const{media:e}=s;if(!tb||!Xm(e))return hi.UNSUPPORTED}},mediaPipUnavailable:{get(s){const{media:e}=s;if(!ib||!jm(e))return hi.UNSUPPORTED}},mediaVolumeUnavailable:{get(s){const{media:e}=s;if(Ho===!1||e?.volume==null)return hi.UNSUPPORTED},stateOwnersUpdateHandlers:[s=>{Ho==null&&ob.then(e=>s(e?void 0:hi.UNSUPPORTED))}]},mediaCastUnavailable:{get(s,{availability:e="not-available"}={}){var t;const{media:i}=s;if(!nb||!((t=i?.remote)!=null&&t.state))return hi.UNSUPPORTED;if(!(e==null||e==="available"))return hi.UNAVAILABLE},stateOwnersUpdateHandlers:[(s,e)=>{var t;const{media:i}=e;return i?(i.disableRemotePlayback||i.hasAttribute("disableremoteplayback")||(t=i?.remote)==null||t.watchAvailability(r=>{s({availability:r?"available":"not-available"})}).catch(r=>{r.name==="NotSupportedError"?s({availability:null}):s({availability:"not-available"})}),()=>{var r;(r=i?.remote)==null||r.cancelWatchAvailability().catch(()=>{})}):void 0}]},mediaAirplayUnavailable:{get(s,e){if(!sb)return hi.UNSUPPORTED;if(e?.availability==="not-available")return hi.UNAVAILABLE},mediaEvents:["webkitplaybacktargetavailabilitychanged"],stateOwnersUpdateHandlers:[(s,e)=>{var t;const{media:i}=e;return i?(i.disableRemotePlayback||i.hasAttribute("disableremoteplayback")||(t=i?.remote)==null||t.watchAvailability(r=>{s({availability:r?"available":"not-available"})}).catch(r=>{r.name==="NotSupportedError"?s({availability:null}):s({availability:"not-available"})}),()=>{var r;(r=i?.remote)==null||r.cancelWatchAvailability().catch(()=>{})}):void 0}]},mediaRenditionUnavailable:{get(s){var e;const{media:t}=s;if(!t?.videoRenditions)return hi.UNSUPPORTED;if(!((e=t.videoRenditions)!=null&&e.length))return hi.UNAVAILABLE},mediaEvents:["emptied","loadstart"],videoRenditionsEvents:["addrendition","removerendition"]},mediaAudioTrackUnavailable:{get(s){var e,t;const{media:i}=s;if(!i?.audioTracks)return hi.UNSUPPORTED;if(((t=(e=i.audioTracks)==null?void 0:e.length)!=null?t:0)<=1)return hi.UNAVAILABLE},mediaEvents:["emptied","loadstart"],audioTracksEvents:["addtrack","removetrack"]}},db={[Ee.MEDIA_PREVIEW_REQUEST](s,e,{detail:t}){var i,n,r;const{media:a}=e,o=t??void 0;let d,l;if(a&&o!=null){const[f]=xl(a,{kind:As.METADATA,label:"thumbnails"}),m=Array.prototype.find.call((i=f?.cues)!=null?i:[],(p,g,y)=>g===0?p.endTime>o:g===y.length-1?p.startTime<=o:p.startTime<=o&&p.endTime>o);if(m){const p=/'^(?:[a-z]+:)?\/\//i.test(m.text)||(n=a?.querySelector('track[label="thumbnails"]'))==null?void 0:n.src,g=new URL(m.text,p);l=new URLSearchParams(g.hash).get("#xywh").split(",").map(T=>+T),d=g.href}}const c=s.mediaDuration.get(e);
210let h=(r=s.mediaChaptersCues.get(e).find((f,m,p)=>m===p.length-1&&c===f.endTime?f.startTime<=o&&f.endTime>=o:f.startTime<=o&&f.endTime>o))==null?void 0:r.text;return t!=null&&h==null&&(h=""),{mediaPreviewTime:o,mediaPreviewImage:d,mediaPreviewCoords:l,mediaPreviewChapter:h}},[Ee.MEDIA_PAUSE_REQUEST](s,e){s["mediaPaused"].set(!0,e)},[Ee.MEDIA_PLAY_REQUEST](s,e){var t;const i="mediaPaused";if(s.mediaStreamType.get(e)===ns.LIVE){const a=!(s.mediaTargetLiveWindow.get(e)>0),o=(t=s.mediaSeekable.get(e))==null?void 0:t[1];a&&o&&s.mediaCurrentTime.set(o,e)}s[i].set(!1,e)},[Ee.MEDIA_PLAYBACK_RATE_REQUEST](s,e,{detail:t}){const i="mediaPlaybackRate",n=t;s[i].set(n,e)},[Ee.MEDIA_MUTE_REQUEST](s,e){s["mediaMuted"].set(!0,e)},[Ee.MEDIA_UNMUTE_REQUEST](s,e){const t="mediaMuted";s.mediaVolume.get(e)||s.mediaVolume.set(.25,e),s[t].set(!1,e)},[Ee.MEDIA_VOLUME_REQUEST](s,e,{detail:t}){const i="mediaVolume",n=t;n&&s.mediaMuted.get(e)&&s.mediaMuted.set(!1,e),s[i].set(n,e)},[Ee.MEDIA_SEEK_REQUEST](s,e,{detail:t}){const i="mediaCurrentTime",n=t;s[i].set(n,e)},[Ee.MEDIA_SEEK_TO_LIVE_REQUEST](s,e){var t;const i="mediaCurrentTime",n=(t=s.mediaSeekable.get(e))==null?void 0:t[1];Number.isNaN(Number(n))&&s[i].set(n,e)},[Ee.MEDIA_SHOW_SUBTITLES_REQUEST](s,e,{detail:t}){var i;const{options:n}=e,r=Ko(e),a=qm(t),o=(i=a[0])==null?void 0:i.language;o&&!n.noSubtitlesLangPref&&B.localStorage.setItem("media-chrome-pref-subtitles-lang",o),_r(Pn.SHOWING,r,a)},[Ee.MEDIA_DISABLE_SUBTITLES_REQUEST](s,e,{detail:t}){const i=Ko(e),n=t??[];_r(Pn.DISABLED,i,n)},[Ee.MEDIA_TOGGLE_SUBTITLES_REQUEST](s,e,{detail:t}){Zm(e,t)},[Ee.MEDIA_RENDITION_REQUEST](s,e,{detail:t}){const i="mediaRenditionSelected",n=t;s[i].set(n,e)},[Ee.MEDIA_AUDIO_TRACK_REQUEST](s,e,{detail:t}){const i="mediaAudioTrackEnabled",n=t;s[i].set(n,e)},[Ee.MEDIA_ENTER_PIP_REQUEST](s,e){const t="mediaIsPip";s.mediaIsFullscreen.get(e)&&s.mediaIsFullscreen.set(!1,e),s[t].set(!0,e)},[Ee.MEDIA_EXIT_PIP_REQUEST](s,e){s["mediaIsPip"].set(!1,e)},[Ee.MEDIA_ENTER_FULLSCREEN_REQUEST](s,e){const t="mediaIsFullscreen";s.mediaIsPip.get(e)&&s.mediaIsPip.set(!1,e),s[t].set(!0,e)},[Ee.MEDIA_EXIT_FULLSCREEN_REQUEST](s,e){s["mediaIsFullscreen"].set(!1,e)},[Ee.MEDIA_ENTER_CAST_REQUEST](s,e){const t="mediaIsCasting";s.mediaIsFullscreen.get(e)&&s.mediaIsFullscreen.set(!1,e),s[t].set(!0,e)},[Ee.MEDIA_EXIT_CAST_REQUEST](s,e){s["mediaIsCasting"].set(!1,e)},[Ee.MEDIA_AIRPLAY_REQUEST](s,e){s["mediaIsAirplaying"].set(!0,e)}},cb=({media:s,fullscreenElement:e,documentElement:t,stateMediator:i=qa,requestMap:n=db,options:r={},monitorStateOwnersOnlyWithSubscriptions:a=!0})=>{const o=[],d={options:{...r}};let l=Object.freeze({mediaPreviewTime:void 0,mediaPreviewImage:void 0,mediaPreviewCoords:void 0,mediaPreviewChapter:void 0});const c=p=>{p!=null&&(nu(p,l)||(l=Object.freeze({...l,...p}),o.forEach(g=>g(l))))},u=()=>{const p=Object.entries(i).reduce((g,[y,{get:T}])=>(g[y]=T(d),g),{});c(p)},h={};let f;const m=async(p,g)=>{var y,T,_,I,R,F,L,w,P,k,G,se,oe,de,ae,ie;const ue=!!f;if(f={...d,...f??{},...p},ue)return;await lb(...Object.values(p));const ee=o.length>0&&g===0&&a,te=d.media!==f.media,ve=((y=d.media)==null?void 0:y.textTracks)!==((T=f.media)==null?void 0:T.textTracks),X=((_=d.media)==null?void 0:_.videoRenditions)!==((I=f.media)==null?void 0:I.videoRenditions),Y=((R=d.media)==null?void 0:R.audioTracks)!==((F=f.media)==null?void 0:F.audioTracks),Ie=((L=d.media)==null?void 0:L.remote)!==((w=f.media)==null?void 0:w.remote),De=d.documentElement!==f.documentElement,Re=!!d.media&&(te||ee),Ce=!!((P=d.media)!=null&&P.textTracks)&&(ve||ee),dt=!!((k=d.media)!=null&&k.videoRenditions)&&(X||ee),je=!!((G=d.media)!=null&&G.audioTracks)&&(Y||ee),ne=!!((se=d.media)!=null&&se.remote)&&(Ie||ee),We=!!d.documentElement&&(De||ee),V=Re||Ce||dt||je||ne||We,fe=o.length===0&&g===1&&a,Oe=!!f.media&&(te||fe),Fe=!!((oe=f.media)!=null&&oe.textTracks)&&(ve||fe),Ue=!!((de=f.media)!=null&&de.videoRenditions)&&(X||fe),Te=!!((ae=f.media)!=null&&ae.audioTracks)&&(Y||fe),$e=!!((ie=f.media)!=null&&ie.remote)&&(Ie||fe),H=!!f.documentElement&&(De||fe),be=Oe||Fe||Ue||Te||$e||H;if(!(V||be)){Object.entries(f).forEach(([Se,Ye])=>{d[Se]=Ye}),u(),f=void 0;return}
210Object.entries(i).forEach(([Se,{get:Ye,mediaEvents:rt=[],textTracksEvents:qe=[],videoRenditionsEvents:Xt=[],audioTracksEvents:bt=[],remoteEvents:Xi=[],rootEvents:kt=[],stateOwnersUpdateHandlers:Js=[]}])=>{h[Se]||(h[Se]={});const pt=ut=>{const _t=Ye(d,ut);c({[Se]:_t})};let Ze;Ze=h[Se].mediaEvents,rt.forEach(ut=>{Ze&&Re&&(d.media.removeEventListener(ut,Ze),h[Se].mediaEvents=void 0),Oe&&(f.media.addEventListener(ut,pt),h[Se].mediaEvents=pt)}),Ze=h[Se].textTracksEvents,qe.forEach(ut=>{var _t,Qt;Ze&&Ce&&((_t=d.media.textTracks)==null||_t.removeEventListener(ut,Ze),h[Se].textTracksEvents=void 0),Fe&&((Qt=f.media.textTracks)==null||Qt.addEventListener(ut,pt),h[Se].textTracksEvents=pt)}),Ze=h[Se].videoRenditionsEvents,Xt.forEach(ut=>{var _t,Qt;Ze&&dt&&((_t=d.media.videoRenditions)==null||_t.removeEventListener(ut,Ze),h[Se].videoRenditionsEvents=void 0),Ue&&((Qt=f.media.videoRenditions)==null||Qt.addEventListener(ut,pt),h[Se].videoRenditionsEvents=pt)}),Ze=h[Se].audioTracksEvents,bt.forEach(ut=>{var _t,Qt;Ze&&je&&((_t=d.media.audioTracks)==null||_t.removeEventListener(ut,Ze),h[Se].audioTracksEvents=void 0),Te&&((Qt=f.media.audioTracks)==null||Qt.addEventListener(ut,pt),h[Se].audioTracksEvents=pt)}),Ze=h[Se].remoteEvents,Xi.forEach(ut=>{var _t,Qt;Ze&&ne&&((_t=d.media.remote)==null||_t.removeEventListener(ut,Ze),h[Se].remoteEvents=void 0),$e&&((Qt=f.media.remote)==null||Qt.addEventListener(ut,pt),h[Se].remoteEvents=pt)}),Ze=h[Se].rootEvents,kt.forEach(ut=>{Ze&&We&&(d.documentElement.removeEventListener(ut,Ze),h[Se].rootEvents=void 0),H&&(f.documentElement.addEventListener(ut,pt),h[Se].rootEvents=pt)});const en=h[Se].stateOwnersUpdateHandlers;Js.forEach(ut=>{en&&V&&en(),be&&(h[Se].stateOwnersUpdateHandlers=ut(pt,f))})}),Object.entries(f).forEach(([Se,Ye])=>{d[Se]=Ye}),u(),f=void 0};return m({media:s,fullscreenElement:e,documentElement:t,options:r}
210),{dispatch(p){const{type:g,detail:y}=p;if(n[g]){c(n[g](i,d,p));return}g==="mediaelementchangerequest"?m({media:y}):g==="fullscreenelementchangerequest"?m({fullscreenElement:y}):g==="documentelementchangerequest"?m({documentElement:y}):g==="optionschangerequest"&&Object.entries(y??{}).forEach(([T,_])=>{d.options[T]=_})},getState(){return l},subscribe(p){return m({},o.length+1),o.push(p),p(l),()=>{const g=o.indexOf(p);g>=0&&(m({},o.length-1),o.splice(g,1))}}}};var ub=cb,ru=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},He=(s,e,t)=>(ru(s,e,"read from private field"),t?t.call(s):e.get(s)),Zi=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},gs=(s,e,t,i)=>(ru(s,e,"write to private field"),e.set(s,t),t),_s=(s,e,t)=>(ru(s,e,"access private method"),t),Ss,cr,ct,ur,Di,Ya,za,wd,Vn,Or,ja,Pd;const Jm=["ArrowLeft","ArrowRight","Enter"," ","f","m","k","c"],_h=10,Ve={DEFAULT_SUBTITLES:"defaultsubtitles",DEFAULT_STREAM_TYPE:"defaultstreamtype",DEFAULT_DURATION:"defaultduration",FULLSCREEN_ELEMENT:"fullscreenelement",HOTKEYS:"hotkeys",KEYS_USED:"keysused",LIVE_EDGE_OFFSET:"liveedgeoffset",NO_HOTKEYS:"nohotkeys",NO_VOLUME_PREF:"novolumepref",NO_SUBTITLES_LANG_PREF:"nosubtitleslangpref",NO_DEFAULT_STORE:"nodefaultstore",KEYBOARD_FORWARD_SEEK_OFFSET:"keyboardforwardseekoffset",KEYBOARD_BACKWARD_SEEK_OFFSET:"keyboardbackwardseekoffset"};class hb extends Hm{constructor(){super(),Zi(this,za),Zi(this,Vn),Zi(this,ja),Zi(this,Ss,new Al(this,Ve.HOTKEYS)),Zi(this,cr,void 0),Zi(this,ct,void 0),Zi(this,ur,void 0),Zi(this,Di,void 0),Zi(this,Ya,t=>{var i;(i=He(this,ct))==null||i.dispatch(t)}),this.mediaStateReceivers=[],this.associatedElementSubscriptions=new Map,this.associateElement(this);let e={};gs(this,ur,t=>{Object.entries(t).forEach(([i,n])=>{if(i in e&&e[i]===n)return;this.propagateMediaState(i,n);const r=i.toLowerCase(),a=new B.CustomEvent(pT[r],{composed:!0,detail:n});this.dispatchEvent(a)}),e=t}),this.enableHotkeys()}static get observedAttributes(){return super.observedAttributes.concat(Ve.NO_HOTKEYS,Ve.HOTKEYS,Ve.DEFAULT_STREAM_TYPE,Ve.DEFAULT_SUBTITLES,Ve.DEFAULT_DURATION)}get mediaStore(){return He(this,ct)}set mediaStore(e){var t,i;if(He(this,ct)&&((t=He(this,Di))==null||t.call(this),gs(this,Di,void 0)),gs(this,ct,e),!He(this,ct)&&!this.hasAttribute(Ve.NO_DEFAULT_STORE)){_s(this,za,wd).call(this);return}gs(this,Di,(i=He(this,ct))==null?void 0:i.subscribe(He(this,ur)))}get fullscreenElement(){var e;return(e=He(this,cr))!=null?e:this}set fullscreenElement(e){var t;this.hasAttribute(Ve.FULLSCREEN_ELEMENT)&&this.removeAttribute(Ve.FULLSCREEN_ELEMENT),gs(this,cr,e),(t=He(this,ct))==null||t.dispatch({type:"fullscreenelementchangerequest",detail:this.fullscreenElement})}attributeChangedCallback(e,t,i){var n,r,a,o,d,l;if(super.attributeChangedCallback(e,t,i),e===Ve.NO_HOTKEYS)i!==t&&i===""?(this.hasAttribute(Ve.HOTKEYS)&&console.warn("Media Chrome: Both `hotkeys` and `nohotkeys` have been set. All hotkeys will be disabled."),this.disableHotkeys()):i!==t&&i===null&&this.enableHotkeys();else if(e===Ve.HOTKEYS)He(this,Ss).value=i;else if(e===Ve.DEFAULT_SUBTITLES&&i!==t)(n=He(this,ct))==null||n.dispatch({type:"optionschangerequest",detail:{defaultSubtitles:this.hasAttribute(Ve.DEFAULT_SUBTITLES)}});else if(e===Ve.DEFAULT_STREAM_TYPE)(a=He(this,ct))==null||a.dispatch({type:"optionschangerequest",detail:{defaultStreamType:(r=this.getAttribute(Ve.DEFAULT_STREAM_TYPE))!=null?r:void 0}});else if(e===Ve.LIVE_EDGE_OFFSET)(o=He(this,ct))==null||o.dispatch({type:"optionschangerequest",detail:{liveEdgeOffset:this.hasAttribute(Ve.LIVE_EDGE_OFFSET)?+this.getAttribute(Ve.LIVE_EDGE_OFFSET):void 0}});else if(e===Ve.FULLSCREEN_ELEMENT){const c=i?(d=this.getRootNode())==null?void 0:d.getElementById(i):void 0;gs(this,cr,c),(l=He(this,ct))==null||l.dispatch({type:"fullscreenelementchangerequest",detail:this.fullscreenElement})}}connectedCallback(){var e,t;!He(this,ct)&&!this.hasAttribute(Ve.NO_DEFAULT_STORE)&&_s(this,za,wd).call(this),(e=He(this,ct))==null||e.dispatch({type:"documentelementchangerequest",detail:ke}),super.connectedCallback(),He(this,ct)&&!He(this,Di)&&gs(this,Di,(t=He(this,ct))==null?void 0:t.subscribe(He(this,ur))),this.enableHotkeys()}disconnectedCallback(){var e,t,i,n;(e=super.disconnectedCallback)==null||e.call(this),He(this,ct)&&((t=He(this,ct))==null||t.dis
210patch({type:"documentelementchangerequest",detail:void 0}),(i=He(this,ct))==null||i.dispatch({type:Ee.MEDIA_TOGGLE_SUBTITLES_REQUEST,detail:!1})),He(this,Di)&&((n=He(this,Di))==null||n.call(this),gs(this,Di,void 0))}mediaSetCallback(e){var t;super.mediaSetCallback(e),(t=He(this,ct))==null||t.dispatch({type:"mediaelementchangerequest",detail:e}),e.hasAttribute("tabindex")||(e.tabIndex=-1)}mediaUnsetCallback(e){var t;super.mediaUnsetCallback(e),(t=He(this,ct))==null||t.dispatch({type:"mediaelementchangerequest",detail:void 0})}propagateMediaState(e,t){Ih(this.mediaStateReceivers,e,t)}associateElement(e){if(!e)return;const{associatedElementSubscriptions:t}=this;if(t.has(e))return;const i=this.registerMediaStateReceiver.bind(this),n=this.unregisterMediaStateReceiver.bind(this),r=Eb(e,i,n);Object.values(Ee).forEach(a=>{e.addEventListener(a,He(this,Ya))}),t.set(e,r)}unassociateElement(e){if(!e)return;const{associatedElementSubscriptions:t}=this;if(!t.has(e))return;t.get(e)(),t.delete(e),Object.values(Ee).forEach(n=>{e.removeEventListener(n,He(this,Ya))})}registerMediaStateReceiver(e){if(!e)return;const t=this.mediaStateReceivers;t.indexOf(e)>-1||(t.push(e),He(this,ct)&&Object.entries(He(this,ct).getState()).forEach(([n,r])=>{Ih([e],n,r)}))}unregisterMediaStateReceiver(e){const t=this.mediaStateReceivers,i=t.indexOf(e);i<0||t.splice(i,1)}enableHotkeys(){this.addEventListener("keydown",_s(this,ja,Pd))}disableHotkeys(){this.removeEventListener("keydown",_s(this,ja,Pd)),this.removeEventListener("keyup",_s(this,Vn,Or))}get hotkeys(){return He(this,Ss)}keyboardShortcutHandler(e){var t,i,n,r,a,o;if(((r=(n=(t=e.target.getAttribute(Ve.KEYS_USED))==null?void 0:t.split(" "))!=null?n:(i=e.target)==null?void 0:i.keysUsed)!=null?r:[]).map(h=>h==="Space"?" ":h).filter(Boolean).includes(e.key))return;let l,c,u;if(!He(this,Ss).contains(`no${e.key.toLowerCase()}`)&&!(e.key===" "&&He(this,Ss).contains("nospace")))switch(e.key){case" ":case"k":l=He(this,ct).getState().mediaPaused?Ee.MEDIA_PLAY_REQUEST:Ee.MEDIA_PAUSE_REQUEST,this.dispatchEvent(new B.CustomEvent(l,{composed:!0,bubbles:!0}));break;case"m":l=this.mediaStore.getState().mediaVolumeLevel==="off"?Ee.MEDIA_UNMUTE_REQUEST:Ee.MEDIA_MUTE_REQUEST,this.dispatchEvent(new B.CustomEvent(l,{composed:!0,bubbles:!0}));break;case"f":l=this.mediaStore.getState().mediaIsFullscreen?Ee.MEDIA_EXIT_FULLSCREEN_REQUEST:Ee.MEDIA_ENTER_FULLSCREEN_REQUEST,this.dispatchEvent(new B.CustomEvent(l,{composed:!0,bubbles:!0}));break;case"c":this.dispatchEvent(new B.CustomEvent(Ee.MEDIA_TOGGLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0}));break;case"ArrowLeft":{const h=this.hasAttribute(Ve.KEYBOARD_BACKWARD_SEEK_OFFSET)?+this.getAttribute(Ve.KEYBOARD_BACKWARD_SEEK_OFFSET):_h;c=Math.max(((a=this.mediaStore.getState().mediaCurrentTime)!=null?a:0)-h,0),u=new B.CustomEvent(Ee.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:c}),this.dispatchEvent(u);break}case"ArrowRight":{const h=this.hasAttribute(Ve.KEYBOARD_FORWARD_SEEK_OFFSET)?+this.getAttribute(Ve.KEYBOARD_FORWARD_SEEK_OFFSET):_h;c=Math.max(((o=this.mediaStore.getState().mediaCurrentTime)!=null?o:0)+h,0),u=new B.CustomEvent(Ee.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:c}),this.dispatchEvent(u);break}}}}Ss=new WeakMap;cr=new WeakMap;ct=new WeakMap;ur=new WeakMap;Di=new WeakMap;Ya=new WeakMap;za=new WeakSet;wd=function(){var s;this.mediaStore=ub({media:this.media,fullscreenElement:this.fullscreenElement,options:{defaultSubtitles:this.hasAttribute(Ve.DEFAULT_SUBTITLES),defaultDuration:this.hasAttribute(Ve.DEFAULT_DURATION)?+this.getAttribute(Ve.DEFAULT_DURATION):void 0,defaultStreamType:(s=this.getAttribute(Ve.DEFAULT_STREAM_TYPE))!=null?s:void 0,liveEdgeOffset:this.hasAttribute(Ve.LIVE_EDGE_OFFSET)?+this.getAttribute(Ve.LIVE_EDGE_OFFSET):void 0,noVolumePref:this.hasAttribute(Ve.NO_VOLUME_PREF),noSubtitlesLangPref:this.hasAttribute(Ve.NO_SUBTITLES_LANG_PREF)}})};Vn=new WeakSet;Or=function(s){const{key:e}=s;if(!Jm.includes(e)){this.removeEventListener("keyup",_s(this,Vn,Or));return}this.keyboardShortcutHandler(s)};ja=new WeakSet;Pd=function(s){const{metaKey:e,altKey:t,key:i}=s;if(e||t||!Jm.includes(i)){this.removeEventListener("keyup",_s(this,Vn,Or));return}[" ","ArrowLeft","ArrowRight"].includes(i)&&!(He(this,Ss).contains(`no${i.toLowerCase()}
210`)||i===" "&&He(this,Ss).contains("nospace"))&&s.preventDefault(),this.addEventListener("keyup",_s(this,Vn,Or),{once:!0})};const fb=Object.values(x),mb=Object.values(Lm),eg=s=>{var e,t,i,n;let{observedAttributes:r}=s.constructor;!r&&((e=s.nodeName)!=null&&e.includes("-"))&&(B.customElements.upgrade(s),{observedAttributes:r}=s.constructor);const a=(n=(i=(t=s?.getAttribute)==null?void 0:t.call(s,st.MEDIA_CHROME_ATTRIBUTES))==null?void 0:i.split)==null?void 0:n.call(i,/\s+/);return Array.isArray(r||a)?(r||a).filter(o=>fb.includes(o)):[]},gb=s=>{var e,t;return(e=s.nodeName)!=null&&e.includes("-")&&B.customElements.get((t=s.nodeName)==null?void 0:t.toLowerCase())&&!(s instanceof B.customElements.get(s.nodeName.toLowerCase()))&&B.customElements.upgrade(s),mb.some(i=>i in s)},Md=s=>gb(s)||!!eg(s).length,Sh=s=>{var e;return(e=s?.join)==null?void 0:e.call(s,":")},Ah={[x.MEDIA_SUBTITLES_LIST]:Mr,[x.MEDIA_SUBTITLES_SHOWING]:Mr,[x.MEDIA_SEEKABLE]:Sh,[x.MEDIA_BUFFERED]:s=>s?.map(Sh).join(" "),[x.MEDIA_PREVIEW_COORDS]:s=>s?.join(" "),[x.MEDIA_RENDITION_LIST]:ET,[x.MEDIA_AUDIO_TRACK_LIST]:_T},pb=async(s,e,t)=>{var i,n;if(s.isConnected||await km(0),typeof t=="boolean"||t==null)return $t(s,e,t);if(typeof t=="number")return Kt(s,e,t);if(typeof t=="string")return qt(s,e,t);if(Array.isArray(t)&&!t.length)return s.removeAttribute(e);const r=(n=(i=Ah[e])==null?void 0:i.call(Ah,t))!=null?n:t;return s.setAttribute(e,r)},vb=s=>{var e;return!!((e=s.closest)!=null&&e.call(s,'*[slot="media"]'))},Us=(s,e)=>{if(vb(s))return;const t=(n,r)=>{var a,o;Md(n)&&r(n);const{children:d=[]}=n??{},l=(o=(a=n?.shadowRoot)==null?void 0:a.children)!=null?o:[];[...d,...l].forEach(u=>Us(u,r))},i=s?.nodeName.toLowerCase();if(i.includes("-")&&!Md(s)){B.customElements.whenDefined(i).then(()=>{t(s,e)});return}t(s,e)},Ih=(s,e,t)=>{s.forEach(i=>{if(e in i){i[e]=t;return}const n=eg(i),r=e.toLowerCase();n.includes(r)&&pb(i,r,t)})},Eb=(s,e,t)=>{Us(s,e);const i=c=>{var u;const h=(u=c?.composedPath()[0])!=null?u:c.target;e(h)},n=c=>{var u;const h=(u=c?.composedPath()[0])!=null?u:c.target;t(h)};s.addEventListener(Ee.REGISTER_MEDIA_STATE_RECEIVER,i),s.addEventListener(Ee.UNREGISTER_MEDIA_STATE_RECEIVER,n);const r=c=>{c.forEach(u=>{const{addedNodes:h=[],removedNodes:f=[],type:m,target:p,attributeName:g}=u;m==="childList"?(Array.prototype.forEach.call(h,y=>Us(y,e)),Array.prototype.forEach.call(f,y=>Us(y,t))):m==="attributes"&&g===st.MEDIA_CHROME_ATTRIBUTES&&(Md(p)?e(p):t(p))})};let a=[];const o=c=>{const u=c.target;u.name!=="media"&&(a.forEach(h=>Us(h,t)),a=[...u.assignedElements({flatten:!0})],a.forEach(h=>Us(h,e)))};s.addEventListener("slotchange",o);const d=new MutationObserver(r);return d.observe(s,{childList:!0,attributes:!0,subtree:!0}),()=>{Us(s,t),s.removeEventListener("slotchange",o),d.disconnect(),s.removeEventListener(Ee.REGISTER_MEDIA_STATE_RECEIVER,i),s.removeEventListener(Ee.UNREGISTER_MEDIA_STATE_RECEIVER,n)}};B.customElements.get("media-controller")||B.customElements.define("media-controller",hb);var yb=Object.defineProperty,Tb=(s,e,t)=>e in s?yb(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,bb=(s,e,t)=>(Tb(s,e+"",t),t),tg=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},fi=(s,e,t)=>(tg(s,e,"read from private field"),t?t.call(s):e.get(s)),ha=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},fa=(s,e,t,i)=>(tg(s,e,"write to private field"),e.set(s,t),t),Ci,Xa,gn,Qa;const ig=ke.createElement("template");ig.innerHTML=` 211<style> 212 :host { 213 font: var(--media-font, 214 var(--media-font-weight, bold) 215 var(--media-font-size, 14px) / 216 var(--media-text-content-height, var(--media-control-height, 24px)) 217 var(--media-font-family, helvetica neue, segoe ui, roboto, arial, sans-serif)); 218 color: var(--media-text-color, var(--media-primary-color, rgb(238 238 238))); 219 background: var(--media-control-background, var(--media-secondary-color, rgb(20 20 30 / .7))); 220 padding: var(--media-button-padding, var(--media-control-padding, 10px)); 221 justify-content: var(--media-button-justify-content, center); 222 display: inline-flex; 223 align-items: center; 224 vertical-align: middle; 225 box-sizing: border-box; 226 transition: background .15s linear; 227 pointer-events: auto; 228 cursor: pointer; 229 -webkit-tap-highlight-color: transparent; 230 } 231 232 233 :host(:focus-visible) { 234 box-shadow: inset 0 0 0 2px rgb(27 127 204 / .9); 235 outline: 0; 236 } 237 238 :host(:where(:focus)) { 239 box-shadow: none; 240 outline: 0; 241 } 242 243 :host(:hover) { 244 background: var(--media-control-hover-background, rgba(50 50 70 / .7)); 245 } 246 247 svg, img, ::slotted(svg), ::slotted(img) { 248 width: var(--media-button-icon-width); 249 height: var(--media-button-icon-height, var(--media-control-height, 24px)); 250 transform: var(--media-button-icon-transform); 251 transition: var(--media-button-icon-transition); 252 fill: var(--media-icon-color, var(--media-primary-color, rgb(238 238 238))); 253 vertical-align: middle; 254 max-width: 100%; 255 max-height: 100%; 256 min-width: 100%; 257 } 258</style> 259`;class ui extends B.HTMLElement{constructor(e={}){if(super(),ha(this,Ci,void 0),bb(this,"preventClick",!1),ha(this,Xa,t=>{this.preventClick||this.handleClick(t)}),ha(this,gn,t=>{const{key:i}=t;if(!this.keysUsed.includes(i)){this.removeEventListener("keyup",fi(this,gn));return}this.preventClick||this.handleClick(t)}),ha(this,Qa,t=>{const{metaKey:i,altKey:n,key:r}=t;if(i||n||!this.keysUsed.includes(r)){this.removeEventListener("keyup",fi(this,gn));return}this.addEventListener("keyup",fi(this,gn),{once:!0})}),!this.shadowRoot){this.attachShadow({mode:"open"});const t=ig.content.cloneNode(!0);this.nativeEl=t;let i=e.slotTemplate;i||(i=ke.createElement("template"),i.innerHTML=`<slot>${e.defaultContent||""}</slot>`),this.nativeEl.appendChild(i.content.cloneNode(!0)),this.shadowRoot.appendChild(t)}}static get observedAttributes(){return["disabled",st.MEDIA_CONTROLLER]}enable(){this.addEventListener("click",fi(this,Xa)),this.addEventListener("keydown",fi(this,Qa)),this.tabIndex=0}disable(){this.removeEventListener("click",fi(this,Xa)),this.removeEventListener("keydown",fi(this,Qa)),this.removeEventListener("keyup",fi(this,gn)),this.tabIndex=-1}attributeChangedCallback(e,t,i){var n,r,a,o,d;e===st.MEDIA_CONTROLLER?(t&&((r=(n=fi(this,Ci))==null?void 0:n.unassociateElement)==null||r.call(n,this),fa(this,Ci,null)),i&&this.isConnected&&(fa(this,Ci,(a=this.getRootNode())==null?void 0:a.getElementById(i)),(d=(o=fi(this,Ci))==null?void 0:o.associateElement)==null||d.call(o,this))):e==="disabled"&&i!==t&&(i==null?this.enable():this.disable())}connectedCallback(){var e,t,i;const{style:n}=At(this.shadowRoot,":host");n.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`),this.hasAttribute("disabled")||this.enable(),this.setAttribute("role","button");const r=this.getAttribute(st.MEDIA_CONTROLLER);r&&(fa(this,Ci,(e=this.getRootNode())==null?void 0:e.getElementById(r)),(i=(t=fi(this,Ci))==null?void 0:t.associateElement)==null||i.call(t,this))}disconnectedCallback(){var e,t;this.disable(),(t=(e=fi(this,Ci))==null?void 0:e.unassociateElement)==null||t.call(e,this),fa(this,Ci,null)}get keysUsed(){return["Enter"," "]}handleClick(e){}}Ci=new WeakMap;Xa=new WeakMap;gn=new WeakMap;Qa=new WeakMap;B.customElements.get("media-chrome-button")||B.customElements.define("media-chrome-button",ui);const xh=`<svg aria-hidden="true" viewBox="0 0 26 24"> 260 <path d="M22.13 3H3.87a.87.87 0 0 0-.87.87v13.26a.87.87 0 0 0 .87.87h3.4L9 16H5V5h16v11h-4l1.72 2h3.4a.87.87 0 0 0 .87-.87V3.87a.87.87 0 0 0-.86-.87Zm-8.75 11.44a.5.5 0 0 0-.76 0l-4.91 5.73a.5.5 0 0 0 .38.83h9.82a.501.501 0 0 0 .38-.83l-4.91-5.73Z"/> 261</svg> 262`,sg=ke.createElement("template");sg.innerHTML=` 263 <style> 264 :host([${x.MEDIA_IS_AIRPLAYING}]) slot:not([name=exit]):not([name=icon]) { 265 display: none !important; 266 } 267 268 269 :host(:not([${x.MEDIA_IS_AIRPLAYING}])) slot:not([name=enter]):not([name=icon]) { 270 display: none !important; 271 } 272 </style> 273 274 <slot name="icon"> 275 <slot name="enter">${xh}</slot> 276 <slot name="exit">${xh}</slot> 277 </slot> 278`;const Lh=s=>{const e=s.mediaIsAirplaying?Vt.EXIT_AIRPLAY():Vt.ENTER_AIRPLAY();s.setAttribute("aria-label",e)};class _b extends ui{static get observedAttributes(){return[...super.observedAttributes,x.MEDIA_IS_AIRPLAYING,x.MEDIA_AIRPLAY_UNAVAILABLE]}constructor(e={}){super({slotTemplate:sg,...e})}connectedCallback(){super.connectedCallback(),Lh(this)}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===x.MEDIA_IS_AIRPLAYING&&Lh(this)}get mediaIsAirplaying(){return Ft(this,x.MEDIA_IS_AIRPLAYING)}set mediaIsAirplaying(e){$t(this,x.MEDIA_IS_AIRPLAYING,e)}get mediaAirplayUnavailable(){return Wt(this,x.MEDIA_AIRPLAY_UNAVAILABLE)}set mediaAirplayUnavailable(e){qt(this,x.MEDIA_AIRPLAY_UNAVAILABLE,e)}handleClick(){const e=new B.CustomEvent(Ee.MEDIA_AIRPLAY_REQUEST,{composed:!0,bubbles:!0});this.dispatchEvent(e)}}B.customElements.get("media-airplay-button")||B.customElements.define("media-airplay-button",_b);function Sb({anchor:s,floating:e,placement:t}){let i=Ab({anchor:s,floating:e}),{x:n,y:r}=xb(i,t);return{x:n,y:r}}function Ab({anchor:s,floating:e}){return{anchor:Ib(s,e.offsetParent),floating:{x:0,y:0,width:e.offsetWidth,height:e.offsetHeight}}}function Ib(s,e){let t=s.getBoundingClientRect(),i=e.getBoundingClientRect();return{x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}function xb({anchor:s,floating:e},t){const i=Lb(t)==="x"?"y":"x",n=i==="y"?"height":"width",r=ng(t),a=s.x+s.width/2-e.width/2,o=s.y+s.height/2-e.height/2,d=s[n]/2-e[n]/2;let l;switch(r){case"top":l={x:a,y:s.y-e.height};break;case"bottom":l={x:a,y:s.y+s.height};break;case"right":l={x:s.x+s.width,y:o};break;case"left":l={x:s.x-e.width,y:o};break;default:l={x:s.x,y:s.y}}switch(t.split("-")[1]){case"start":l[i]-=d;break;case"end":l[i]+=d;break}return l}function ng(s){return s.split("-")[0]}
278function Lb(s){return["top","bottom"].includes(ng(s))?"y":"x"}var Rb=Object.defineProperty,kb=(s,e,t)=>e in s?Rb(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Vo=(s,e,t)=>(kb(s,typeof e!="symbol"?e+"":e,t),t);class au extends Event{constructor({action:e="auto",relatedTarget:t,...i}){super("invoke",i),Vo(this,"action"),Vo(this,"relatedTarget"),this.action=e,this.relatedTarget=t}}class Db extends Event{constructor({newState:e,oldState:t,...i}){super("toggle",i),Vo(this,"newState"),Vo(this,"oldState"),this.newState=e,this.oldState=t}}var Cb=Object.defineProperty,wb=(s,e,t)=>e in s?Cb(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Pb=(s,e,t)=>(wb(s,e+"",t),t),ou=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},Qe=(s,e,t)=>(ou(s,e,"read from private field"),t?t.call(s):e.get(s)),tt=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},ss=(s,e,t,i)=>(ou(s,e,"write to private field"),e.set(s,t),t),at=(s,e,t)=>(ou(s,e,"access private method"),t),wi,Vs,xs,rg,ag,Za,Ja,Ws,Od,og,Wo,eo,Fd,$d,lg,Nd,dg,Ud,cg,Mn,On,qs,Wn,qo,lu,Bd,ug,du,hg,Gd,fg,cu,mg,Kd,gg,Hd,pg,Sr,Yo,Vd,vg,Ar,zo,to,Wd;function qn({type:s,text:e,value:t,checked:i}){const n=ke.createElement("media-chrome-menu-item");n.type=s,n.part.add("menu-item"),n.part.add(s),n.value=t,n.checked=i;const r=ke.createElement("span");return r.textContent=e,n.append(r),n}function Ys(s,e){let t=s.querySelector(`:scope > [slot="${e}"]`);if(t?.nodeName=="SLOT"&&(t=t.assignedElements({flatten:!0})[0]),t)return t=t.cloneNode(!0),t;let i=s.shadowRoot.querySelector(`[name="${e}"] > svg`);return i?i.cloneNode(!0):""}const Eg=ke.createElement("template");Eg.innerHTML=` 279 <style> 280 :host { 281 font: var(--media-font, 282 var(--media-font-weight, normal) 283 var(--media-font-size, 14px) / 284 var(--media-text-content-height, var(--media-control-height, 24px)) 285 var(--media-font-family, helvetica neue, segoe ui, roboto, arial, sans-serif)); 286 color: var(--media-text-color, var(--media-primary-color, rgb(238 238 238))); 287 background: var(--media-menu-background, var(--media-control-background, var(--media-secondary-color, rgb(20 20 30 / .8)))); 288 border-radius: var(--media-menu-border-radius); 289 border: var(--media-menu-border, none); 290 display: var(--media-menu-display, inline-flex); 291 transition: var(--media-menu-transition-in, 292 visibility 0s, 293 opacity .2s ease-out, 294 transform .15s ease-out, 295 left .2s ease-in-out, 296 min-width .2s ease-in-out, 297 min-height .2s ease-in-out 298 ) !important; 299 300 visibility: var(--media-menu-visibility, visible); 301 opacity: var(--media-menu-opacity, 1); 302 max-height: var(--media-menu-max-height, var(--_menu-max-height, 300px)); 303 transform: var(--media-menu-transform-in, translateY(0) scale(1)); 304 flex-direction: column; 305 306 min-height: 0; 307 position: relative; 308 box-sizing: border-box; 309 } 310 311 :host([hidden]) { 312 transition: var(--media-menu-transition-out, 313 visibility .15s ease-in, 314 opacity .15s ease-in, 315 transform .15s ease-in 316 ) !important; 317 visibility: var(--media-menu-hidden-visibility, hidden); 318 opacity: var(--media-menu-hidden-opacity, 0); 319 max-height: var(--media-menu-hidden-max-height, 320 var(--media-menu-max-height, var(--_menu-max-height, 300px))); 321 transform: var(--media-menu-transform-out, translateY(2px) scale(.99)); 322 pointer-events: none; 323 } 324 325 :host([slot="submenu"]) { 326 background: none; 327 width: 100%; 328 min-height: 100%; 329 position: absolute; 330 bottom: 0; 331 right: -100%; 332 } 333 334 #container { 335 display: flex; 336 flex-direction: column; 337 min-height: 0; 338 transition: transform .2s ease-out; 339 transform: translate(0, 0); 340 } 341 342 #container.has-expanded { 343 transition: transform .2s ease-in; 344 transform: translate(-100%, 0); 345 } 346 347 slot[name="header"] { 348 display: flex; 349 padding: .4em .7em; 350 border-bottom: 1px solid rgb(255 255 255 / .25); 351 cursor: default; 352 } 353 354 slot[name="header"][hidden] { 355 display: none; 356 } 357 358 button[part~="back"] { 359 background: none; 360 color: inherit; 361 border: none; 362 padding: 0; 363 font: inherit; 364 cursor: pointer; 365 outline: inherit; 366 display: inline-flex; 367 align-items: center; 368 cursor: pointer; 369 } 370 371 svg[part~="back"] { 372 height: var(--media-menu-icon-height, var(--media-control-height, 24px)); 373 fill: var(--media-icon-color, var(--media-primary-color, rgb(238 238 238))); 374 display: block; 375 margin-right: .5ch; 376 } 377 378 slot:not([name]) { 379 gap: var(--media-menu-gap); 380 flex-direction: var(--media-menu-flex-direction, column); 381 overflow: var(--media-menu-overflow, hidden auto); 382 display: flex; 383 min-height: 0; 384 } 385 386 :host([role="menu"]) slot:not([name]) { 387 padding-block: .4em; 388 } 389 390 slot:not([name])::slotted([role="menu"]) { 391 background: none; 392 } 393 394 media-chrome-menu-item > span { 395 margin-right: .5ch; 396 max-width: var(--media-menu-item-max-width); 397 text-overflow: ellipsis; 398 overflow: hidden; 399 } 400 </style> 401 <style id="layout-row" media="width:0"> 402 403 slot[name="header"] { 404 padding: .4em .5em; 405 } 406 407 slot:not([name]) { 408 gap: var(--media-menu-gap, .25em); 409 flex-direction: var(--media-menu-flex-direction, row); 410 padding-inline: .5em; 411 } 412 413 media-chrome-menu-item { 414 padding: .3em .5em; 415 } 416 417 media-chrome-menu-item[aria-checked="true"] { 418 background: var(--media-menu-item-checked-background, rgb(255 255 255 / .2)); 419 } 420 421 422 media-chrome-menu-item::part(checked-indicator) { 423 display: var(--media-menu-item-checked-indicator-display, none); 424 } 425 </style> 426 <div id="container"> 427 <slot name="header" hidden> 428 <button part="back button" aria-label="Back to previous menu"> 429 <slot name="back-icon"> 430 <svg aria-hidden="true" viewBox="0 0 20 24" part="back indicator"> 431 <path d="m11.88 17.585.742-.669-4.2-4.665 4.2-4.666-.743-.669-4.803 5.335 4.803 5.334Z"/> 432 </svg> 433 </slot> 434 <slot name="title"></slot> 435 </button> 436 </slot> 437 <slot></slot> 438 </div> 439 <slot name="checked-indicator" hidden></slot> 440`;const Os={STYLE:"style",HIDDEN:"hidden",DISABLED:"disabled",ANCHOR:"anchor"};class ds extends B.HTMLElement{constructor(){super(),tt(this,Od),tt(this,eo),tt(this,$d),tt(this,Nd),tt(this,Ud),tt(this,qs),tt(this,qo),tt(this,Bd),tt(this,du),tt(this,Gd),tt(this,cu),tt(this,Kd),tt(this,Hd),tt(this,Sr),tt(this,Vd),tt(this,Ar),tt(this,to),tt(this,wi,void 0),tt(this,Vs,void 0),tt(this,xs,void 0),tt(this,rg,""),tt(this,ag,null),tt(this,Za,new Set),tt(this,Ja,void 0),tt(this,Ws,!1),tt(this,Wo,()=>{const e=Qe(this,Za),t=new Set(this.items);for(const i of e)t.has(i)||this.dispatchEvent(new CustomEvent("removemenuitem",{detail:i}));for(const i of t)e.has(i)||this.dispatchEvent(new CustomEvent("addmenuitem",{detail:i}));ss(this,Za,t)}),tt(this,Mn,()=>{at(this,qs,Wn).call(this,!1),at(this,qo,lu).call(this,!1)}),tt(this,On,()=>{at(this,qs,Wn).call(this,!1)}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.nativeEl=this.constructor.template.content.cloneNode(!0),this.shadowRoot.append(this.nativeEl)),this.container=this.shadowRoot.querySelector("#container"),this.defaultSlot=this.shadowRoot.querySelector("slot:not([name])"),this.shadowRoot.addEventListener("slotchange",this),ss(this,Ja,new MutationObserver(Qe(this,Wo))),Qe(this,Ja).observe(this.defaultSlot,{childList:!0})}static get observedAttributes(){return[Os.DISABLED,Os.HIDDEN,Os.STYLE,Os.ANCHOR,st.MEDIA_CONTROLLER]}static formatMenuItemText(e){return e}enable(){this.addEventListener("click",this),this.addEventListener("focusout",this),this.addEventListener("keydown",this),this.addEventListener("invoke",this),this.addEventListener("toggle",this)}disable(){this.removeEventListener("click",this),this.removeEventListener("focusout",this),this.removeEventListener("keyup",this),this.removeEventListener("invoke",this),this.removeEventListener("toggle",this)}handleEvent(e){switch(e.type){case"slotchange":at(this,Od,og).call(this,e);break;case"invoke":at(this,$d,lg).call(this,e);break;case"click":at(this,Bd,ug).call(this,e);break;case"toggle":at(this,Gd,fg).call(this,e);break;case"focusout":at(this,Kd,gg).call(this,e);break;case"keydown":at(this,Hd,pg).call(this,e);break}}connectedCallback(){var e,t;at(this,eo,Fd).call(this),this.hasAttribute("disabled")||this.enable(),this.role||(this.role="menu"),ss(this,wi,Ld(this)),(t=(e=Qe(this,wi))==null?void 0:e.associateElement)==null||t.call(e,this),this.hidden||(Kn(Fr(this),Qe(this,Mn)),Kn(this,Qe(this,On)))}disconnectedCallback(){var e,t;Cr(Fr(this),Qe(this,Mn)),Cr(this,Qe(this,On)),this.disable(),(t=(e=Qe(this,wi))==null?void 0:e.unassociateElement)==null||t.call(e,this),ss(this,wi,null)}attributeChangedCallback(e,t,i){var n,r,a,o;e===Os.HIDDEN&&i!==t?(Qe(this,Ws)||ss(this,Ws,!0),this.hidden?at(this,Ud,cg).call(this):at(this,Nd,dg).call(this),this.dispatchEvent(new Db({oldState:this.hidden?"open":"closed",newState:this.hidden?"closed":"open",bubbles:!0}))):e===st.MEDIA_CONTROLLER?(t&&((r=(n=Qe(this,wi))==null?void 0:n.unassociateElement)==null||r.call(n,this),ss(this,wi,null)),i&&this.isConnected&&(ss(this,wi,Ld(this)),(o=(a=Qe(this,wi))==null?void 0:a.associateElement)==null||o.call(a,this))):e===Os.DISABLED&&i!==t?i==null?this.enable():this.disable():e===Os.STYLE&&i!==t&&at(this,eo,Fd).call(this)}formatMenuItemText(e,t){return this.constructor.formatMenuItemText(e,t)}get anchor(){return this.getAttribute("anchor")}
440set anchor(e){this.setAttribute("anchor",`${e}`)}get anchorElement(){var e;return this.anchor?(e=bl(this))==null?void 0:e.querySelector(`#${this.anchor}`):null}get items(){return this.defaultSlot.assignedElements({flatten:!0}).filter(Mb)}get radioGroupItems(){return this.items.filter(e=>e.role==="menuitemradio")}get checkedItems(){return this.items.filter(e=>e.checked)}get value(){var e,t;return(t=(e=this.checkedItems[0])==null?void 0:e.value)!=null?t:""}set value(e){const t=this.items.find(i=>i.value===e);t&&at(this,to,Wd).call(this,t)}focus(){if(ss(this,Vs,eu()),this.items.length){at(this,Ar,zo).call(this,this.items[0]),this.items[0].focus();return}const e=this.querySelector('[autofocus], [tabindex]:not([tabindex="-1"]), [role="menu"]');e?.focus()}handleSelect(e){var t;const i=at(this,Sr,Yo).call(this,e);i&&(at(this,to,Wd).call(this,i,i.type==="checkbox"),Qe(this,xs)&&!this.hidden&&((t=Qe(this,Vs))==null||t.focus(),this.hidden=!0))}get keysUsed(){return["Enter","Escape","Tab"," ","ArrowDown","ArrowUp","Home","End"]}handleMove(e){var t,i;const{key:n}=e,r=this.items,a=(i=(t=at(this,Sr,Yo).call(this,e))!=null?t:at(this,Vd,vg).call(this))!=null?i:r[0],o=r.indexOf(a);let d=Math.max(0,o);n==="ArrowDown"?d++:n==="ArrowUp"?d--:e.key==="Home"?d=0:e.key==="End"&&(d=r.length-1),d<0&&(d=r.length-1),d>r.length-1&&(d=0),at(this,Ar,zo).call(this,r[d]),r[d].focus()}}wi=new WeakMap;Vs=new WeakMap;xs=new WeakMap;rg=new WeakMap;ag=new WeakMap;Za=new WeakMap;Ja=new WeakMap;Ws=new WeakMap;Od=new WeakSet;og=function(s){const e=s.target;for(let t of e.assignedNodes({flatten:!0}))t.nodeType===3&&t.textContent.trim()===""&&t.remove();if(["header","title"].includes(e.name)){const t=this.shadowRoot.querySelector('slot[name="header"]');t.hidden=e.assignedNodes().length===0}e.name||Qe(this,Wo).call(this)};Wo=new WeakMap;eo=new WeakSet;Fd=function(){var s;const e=this.shadowRoot.querySelector("#layout-row"),t=(s=getComputedStyle(this).getPropertyValue("--media-menu-layout"))==null?void 0:s.trim();e.setAttribute("media",t==="row"?"":"width:0")};$d=new WeakSet;lg=function(s){ss(this,xs,s.relatedTarget),ls(this,s.relatedTarget)||(this.hidden=!this.hidden)};Nd=new WeakSet;dg=function(){var s;(s=Qe(this,xs))==null||s.setAttribute("aria-expanded","true"),requestAnimationFrame(()=>at(this,qs,Wn).call(this,!1)),this.addEventListener("transitionend",()=>this.focus(),{once:!0}),Kn(Fr(this),Qe(this,Mn)),Kn(this,Qe(this,On))};Ud=new WeakSet;cg=function(){var s;(s=Qe(this,xs))==null||s.setAttribute("aria-expanded","false"),Cr(Fr(this),Qe(this,Mn)),Cr(this,Qe(this,On))};Mn=new WeakMap;On=new WeakMap;qs=new WeakSet;Wn=function(s,e){if(this.hasAttribute("mediacontroller")&&!this.anchor||this.hidden||!this.anchorElement)return;const{x:t,y:i}=Sb({anchor:this.anchorElement,floating:this,placement:"top-start"});e??(e=this.offsetWidth);const r=Fr(this).getBoundingClientRect(),a=this.anchorElement.getBoundingClientRect(),o=r.width-t-e,d=r.height-i-this.offsetHeight,l=r.height-a.height,{style:c}=At(this.shadowRoot,":host");s||c.setProperty("--media-menu-transition-in","none"),c.setProperty("position","absolute"),c.setProperty("right",`${Math.max(0,o)}px`),c.setProperty("bottom",`${d}px`),c.setProperty("--_menu-max-height",`${l}px`),c.removeProperty("--media-menu-transition-in")};qo=new WeakSet;lu=function(s){const e=this.querySelector('[role="menuitem"][aria-haspopup][aria-expanded="true"]'),t=e?.querySelector('[role="menu"]'),{style:i}=At(this.shadowRoot,":host");if(s||i.setProperty("--media-menu-transition-in","none"),t){const n=t.offsetHeight,r=Math.max(t.offsetWidth,e.offsetWidth);this.style.setProperty("min-width",`${r}px`),this.style.setProperty("min-height",`${n}px`),at(this,qs,Wn).call(this,s,r)}else this.style.removeProperty("min-width"),this.style.removeProperty("min-height"),at(this,qs,Wn).call(this,s);i.removeProperty("--media-menu-transition-in")};Bd=new WeakSet;ug=function(s){var e;if(s.stopPropagation(),s.composedPath().includes(Qe(this,du,hg))){(e=Qe(this,Vs))==null||e.focus(),this.hidden=!0;return}const t=at(this,Sr,Yo).call(this,s);!t||t.hasAttribute("disabled")||(at(this,Ar,zo).call(this,t),this.handleSelect(s))};du=new WeakSet;hg=function(){var s;return(s=this.shadowRoot.querySelector('slot[name="header"]').assignedElements({flatten:!0}))==null?void 0:s.find(t=>t.part.contains("back")&&t.part.contains("button"))};Gd=new WeakSet;fg=function(s){if(s.target===this)return;at(this,cu,mg).call(this);const e=Array.from(this.querySelectorAll('[role="menuitem"][aria-haspopup]'));for(const t of e)t.invokeTargetElement!=s.target&&s.newState=="open"&&t.getAttribute("aria-expanded")=="true"&&!t.invokeTargetElement.hidden&&t.invokeTargetElement.dispatchEvent(new au({relatedTarget:t}));for(const t of e)t.setAttribute("aria-expanded",`${!t.submenuElement.hidden}`);at(this,qo,lu).call(this,!0)};cu=new WeakSet;mg=function(){const e=this.querySelector('[role="menuitem"] > [role="menu"]:not([hidden])');this.container.classList.toggle("has-expanded",!!e)};Kd=new WeakSet;gg=function(s){var e;
440ls(this,s.relatedTarget)||(Qe(this,Ws)&&((e=Qe(this,Vs))==null||e.focus()),Qe(this,xs)&&Qe(this,xs)!==s.relatedTarget&&!this.hidden&&(this.hidden=!0))};Hd=new WeakSet;pg=function(s){var e,t,i,n,r;const{key:a,ctrlKey:o,altKey:d,metaKey:l}=s;if(!(o||d||l)&&this.keysUsed.includes(a))if(s.preventDefault(),s.stopPropagation(),a==="Tab"){if(Qe(this,Ws)){this.hidden=!0;return}s.shiftKey?(t=(e=this.previousElementSibling)==null?void 0:e.focus)==null||t.call(e):(n=(i=this.nextElementSibling)==null?void 0:i.focus)==null||n.call(i),this.blur()}else a==="Escape"?((r=Qe(this,Vs))==null||r.focus(),Qe(this,Ws)&&(this.hidden=!0)):a==="Enter"||a===" "?this.handleSelect(s):this.handleMove(s)};Sr=new WeakSet;Yo=function(s){return s.composedPath().find(e=>["menuitemradio","menuitemcheckbox"].includes(e.role))};Vd=new WeakSet;vg=function(){return this.items.find(s=>s.tabIndex===0)};Ar=new WeakSet;zo=function(s){for(const e of this.items)e.tabIndex=e===s?0:-1};to=new WeakSet;Wd=function(s,e){const t=[...this.checkedItems];s.type==="radio"&&this.radioGroupItems.forEach(i=>i.checked=!1),e?s.checked=!s.checked:s.checked=!0,this.checkedItems.some((i,n)=>i!=t[n])&&this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))};Pb(ds,"template",Eg);function Mb(s){return["menuitem","menuitemradio","menuitemcheckbox"].includes(s?.role)}function Fr(s){var e;return(e=s.getAttribute("bounds")?Xr(s,`#${s.getAttribute("bounds")}`):Ii(s)||s.parentElement)!=null?e:s}B.customElements.get("media-chrome-menu")||B.customElements.define("media-chrome-menu",ds);var uu=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},yg=(s,e,t)=>(uu(s,e,"read from private field"),t?t.call(s):e.get(s)),ma=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},qd=(s,e,t,i)=>(uu(s,e,"write to private field"),e.set(s,t),t),ga=(s,e,t)=>(uu(s,e,"access private method"),t),hr,jo,io,Yd,so,zd;class Ob extends ds{constructor(){super(...arguments),ma(this,io),ma(this,so),ma(this,hr,[]),ma(this,jo,void 0)}static get observedAttributes(){return[...super.observedAttributes,x.MEDIA_AUDIO_TRACK_LIST,x.MEDIA_AUDIO_TRACK_ENABLED,x.MEDIA_AUDIO_TRACK_UNAVAILABLE]}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===x.MEDIA_AUDIO_TRACK_ENABLED&&t!==i?this.value=i:e===x.MEDIA_AUDIO_TRACK_LIST&&t!==i&&(qd(this,hr,ST(i)),ga(this,io,Yd).call(this))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",ga(this,so,zd))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",ga(this,so,zd))}get anchorElement(){return this.anchor!=="auto"?super.anchorElement:Ii(this).querySelector("media-audio-track-menu-button")}get mediaAudioTrackList(){return yg(this,hr)}set mediaAudioTrackList(e){qd(this,hr,e),ga(this,io,Yd).call(this)}get mediaAudioTrackEnabled(){return Wt(this,x.MEDIA_AUDIO_TRACK_ENABLED)}set mediaAudioTrackEnabled(e){qt(this,x.MEDIA_AUDIO_TRACK_ENABLED,e)}}hr=new WeakMap;jo=new WeakMap;io=new WeakSet;Yd=function(){if(yg(this,jo)===JSON.stringify(this.mediaAudioTrackList))return;qd(this,jo,JSON.stringify(this.mediaAudioTrackList));const s=this.mediaAudioTrackList;this.defaultSlot.textContent="";for(const e of s){const t=this.formatMenuItemText(e.label,e),i=qn({type:"radio",text:t,value:`${e.id}`,checked:e.enabled});i.prepend(Ys(this,"checked-indicator")),this.defaultSlot.append(i)}};so=new WeakSet;zd=function(){if(this.value==null)return;const s=new B.CustomEvent(Ee.MEDIA_AUDIO_TRACK_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(s)};B.customElements.get("media-audio-track-menu")||B.customElements.define("media-audio-track-menu",Ob);class Qn extends ui{connectedCallback(){super.connectedCallback(),this.invokeTargetElement&&this.setAttribute("aria-haspopup","menu")}get invokeTarget(){return this.getAttribute("invoketarget")}set invokeTarget(e){this.setAttribute("invoketarget",`${e}`)}get invokeTargetElement(){var e;return this.invokeTarget?(e=bl(this))==null?void 0:e.querySelector(`#${this.invokeTarget}`):null}handleClick(){this.invokeTargetElement.dispatchEvent(new au({relatedTarget:this}))}}B.customElements.get("media-chrome-menu-button")||B.customElements.define("media-chrome-menu-button",Qn);const Fb=`<svg aria-hidden="true" viewBox="0 0 24 24"> 441 <path d="M11 17H9.5V7H11v10Zm-3-3H6.5v-4H8v4Zm6-5h-1.5v6H14V9Zm3 7h-1.5V8H17v8Z"/> 442 <path d="M22 12c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10Zm-2 0a8 8 0 1 0-16 0 8 8 0 0 0 16 0Z"/> 443</svg>`,Tg=ke.createElement("template");Tg.innerHTML=` 444 <slot name="icon">${Fb}</slot> 445`;class $b extends Qn{static get observedAttributes(){return[...super.observedAttributes,x.MEDIA_AUDIO_TRACK_ENABLED,x.MEDIA_AUDIO_TRACK_UNAVAILABLE]}constructor(){super({slotTemplate:Tg})}connectedCallback(){super.connectedCallback(),this.setAttribute("aria-label",ci.AU
445DIO_TRACKS())}get invokeTargetElement(){return this.invokeTarget!=null?super.invokeTargetElement:Ii(this).querySelector("media-audio-track-menu")}get mediaAudioTrackEnabled(){return Wt(this,x.MEDIA_AUDIO_TRACK_ENABLED)}set mediaAudioTrackEnabled(e){qt(this,x.MEDIA_AUDIO_TRACK_ENABLED,e)}}B.customElements.get("media-audio-track-menu-button")||B.customElements.define("media-audio-track-menu-button",$b);const Nb=`<svg aria-hidden="true" viewBox="0 0 26 24"> 446 <path d="M22.83 5.68a2.58 2.58 0 0 0-2.3-2.5c-3.62-.24-11.44-.24-15.06 0a2.58 2.58 0 0 0-2.3 2.5c-.23 4.21-.23 8.43 0 12.64a2.58 2.58 0 0 0 2.3 2.5c3.62.24 11.44.24 15.06 0a2.58 2.58 0 0 0 2.3-2.5c.23-4.21.23-8.43 0-12.64Zm-11.39 9.45a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.92 3.92 0 0 1 .92-2.77 3.18 3.18 0 0 1 2.43-1 2.94 2.94 0 0 1 2.13.78c.364.359.62.813.74 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.17 1.61 1.61 0 0 0-1.29.58 2.79 2.79 0 0 0-.5 1.89 3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.48 1.48 0 0 0 1-.37 2.1 2.1 0 0 0 .59-1.14l1.4.44a3.23 3.23 0 0 1-1.07 1.69Zm7.22 0a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.88 3.88 0 0 1 .93-2.77 3.14 3.14 0 0 1 2.42-1 3 3 0 0 1 2.16.82 2.8 2.8 0 0 1 .73 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.21 1.61 1.61 0 0 0-1.29.58A2.79 2.79 0 0 0 15 12a3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.44 1.44 0 0 0 1-.37 2.1 2.1 0 0 0 .6-1.15l1.4.44a3.17 3.17 0 0 1-1.1 1.7Z"/> 447</svg>`,Ub=`<svg aria-hidden="true" viewBox="0 0 26 24"> 448 <path d="M17.73 14.09a1.4 1.4 0 0 1-1 .37 1.579 1.579 0 0 1-1.27-.58A3 3 0 0 1 15 12a2.8 2.8 0 0 1 .5-1.85 1.63 1.63 0 0 1 1.29-.57 1.47 1.47 0 0 1 1.51 1.2l1.43-.34A2.89 2.89 0 0 0 19 9.07a3 3 0 0 0-2.14-.78 3.14 3.14 0 0 0-2.42 1 3.91 3.91 0 0 0-.93 2.78 3.74 3.74 0 0 0 .92 2.66 3.07 3.07 0 0 0 2.34 1 3.07 3.07 0 0 0 1.91-.57 3.17 3.17 0 0 0 1.07-1.74l-1.4-.45c-.083.43-.3.822-.62 1.12Zm-7.22 0a1.43 1.43 0 0 1-1 .37 1.58 1.58 0 0 1-1.27-.58A3 3 0 0 1 7.76 12a2.8 2.8 0 0 1 .5-1.85 1.63 1.63 0 0 1 1.29-.57 1.47 1.47 0 0 1 1.51 1.2l1.43-.34a2.81 2.81 0 0 0-.74-1.32 2.94 2.94 0 0 0-2.13-.78 3.18 3.18 0 0 0-2.43 1 4 4 0 0 0-.92 2.78 3.74 3.74 0 0 0 .92 2.66 3.07 3.07 0 0 0 2.34 1 3.07 3.07 0 0 0 1.91-.57 3.23 3.23 0 0 0 1.07-1.74l-1.4-.45a2.06 2.06 0 0 1-.6 1.07Zm12.32-8.41a2.59 2.59 0 0 0-2.3-2.51C18.72 3.05 15.86 3 13 3c-2.86 0-5.72.05-7.53.17a2.59 2.59 0 0 0-2.3 2.51c-.23 4.207-.23 8.423 0 12.63a2.57 2.57 0 0 0 2.3 2.5c1.81.13 4.67.19 7.53.19 2.86 0 5.72-.06 7.53-.19a2.57 2.57 0 0 0 2.3-2.5c.23-4.207.23-8.423 0-12.63Zm-1.49 12.53a1.11 1.11 0 0 1-.91 1.11c-1.67.11-4.45.18-7.43.18-2.98 0-5.76-.07-7.43-.18a1.11 1.11 0 0 1-.91-1.11c-.21-4.14-.21-8.29 0-12.43a1.11 1.11 0 0 1 .91-1.11C7.24 4.56 10 4.49 13 4.49s5.76.07 7.43.18a1.11 1.11 0 0 1 .91 1.11c.21 4.14.21 8.29 0 12.43Z"/> 449</svg>`,bg=ke.createElement("template");bg.innerHTML=` 450 <style> 451 :host([aria-checked="true"]) slot[name=off] { 452 display: none !important; 453 } 454 455 456 :host(:not([aria-checked="true"])) slot[name=on] { 457 display: none !important; 458 } 459 </style> 460 461 <slot name="icon"> 462 <slot name="on">${Nb}</slot> 463 <slot name="off">${Ub}</slot> 464 </slot> 465`;const Rh=s=>{s.setAttribute("aria-checked",zm(s))};class Bb extends ui{static get observedAttributes(){return[...super.observedAttributes,x.MEDIA_SUBTITLES_LIST,x.MEDIA_SUBTITLES_SHOWING]}constructor(e={}){super({slotTemplate:bg,...e}),this._captionsReady=!1}connectedCallback(){super.connectedCallback(),this.setAttribute("role","switch"),this.setAttribute("aria-label",ci.CLOSED_CAPTIONS()),Rh(this)}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===x.MEDIA_SUBTITLES_SHOWING&&Rh(this)}get mediaSubtitlesList(){return kh(this,x.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){Dh(this,x.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return kh(this,x.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){Dh(this,x.MEDIA_SUBTITLES_SHOWING,e)}handleClick(){this.dispatchEvent(new B.CustomEvent(Ee.MEDIA_TOGGLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0}))}}const kh=(s,e)=>{const t=s.getAttribute(e);return t?Il(t):[]},Dh=(s,e,t)=>{if(!t?.length){s.removeAttribute(e);return}const i=Mr(t);s.getAttribute(e)!==i&&s.setAttribute(e,i)};B.customElements.get("media-captions-button")||B.customElements.define("media-captions-button",Bb);var Gb=Object.defineProperty,Kb=(s,e,t)=>e in s?Gb(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Hb=(s,e,t)=>(Kb(s,e+"",t),t),hu=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},Vb=(s,e,t)=>(hu(s,e,"read from private field"),e.get(s)),Vl=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},Wb=(s,e,t,i)=>(hu(s,e,"write to private field"),e.set(s,t),t),Wl=(s,e,t)=>(hu(s,e,"access private method"),t),Xo,jd,_g,no,Xd;const qb=` 466 <svg aria-hidden="true" viewBox="0 0 26 24" part="captions-indicator indicator"> 467 <path d="M22.83 5.68a2.58 2.58 0 0 0-2.3-2.5c-3.62-.24-11.44-.24-15.06 0a2.58 2.58 0 0 0-2.3 2.5c-.23 4.21-.23 8.43 0 12.64a2.58 2.58 0 0 0 2.3 2.5c3.62.24 11.44.24 15.06 0a2.58 2.58 0 0 0 2.3-2.5c.23-4.21.23-8.43 0-12.64Zm-11.39 9.45a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.92 3.92 0 0 1 .92-2.77 3.18 3.18 0 0 1 2.43-1 2.94 2.94 0 0 1 2.13.78c.364.359.62.813.74 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.17 1.61 1.61 0 0 0-1.29.58 2.79 2.79
4670 0 0-.5 1.89 3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.48 1.48 0 0 0 1-.37 2.1 2.1 0 0 0 .59-1.14l1.4.44a3.23 3.23 0 0 1-1.07 1.69Zm7.22 0a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.88 3.88 0 0 1 .93-2.77 3.14 3.14 0 0 1 2.42-1 3 3 0 0 1 2.16.82 2.8 2.8 0 0 1 .73 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.21 1.61 1.61 0 0 0-1.29.58A2.79 2.79 0 0 0 15 12a3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.44 1.44 0 0 0 1-.37 2.1 2.1 0 0 0 .6-1.15l1.4.44a3.17 3.17 0 0 1-1.1 1.7Z"/> 468 </svg>`,Sg=ke.createElement("template");Sg.innerHTML=ds.template.innerHTML+` 469 <slot name="captions-indicator" hidden>${qb}</slot>`;class Ag extends ds{constructor(){super(...arguments),Vl(this,jd),Vl(this,no),Vl(this,Xo,void 0)}static get observedAttributes(){return[...super.observedAttributes,x.MEDIA_SUBTITLES_LIST,x.MEDIA_SUBTITLES_SHOWING]}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===x.MEDIA_SUBTITLES_LIST&&t!==i?Wl(this,jd,_g).call(this):e===x.MEDIA_SUBTITLES_SHOWING&&t!==i&&(this.value=i)}connectedCallback(){super.connectedCallback(),this.addEventListener("change",Wl(this,no,Xd))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",Wl(this,no,Xd))}get anchorElement(){return this.anchor!=="auto"?super.anchorElement:Ii(this).querySelector("media-captions-menu-button")}get mediaSubtitlesList(){return Ch(this,x.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){wh(this,x.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return Ch(this,x.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){wh(this,x.MEDIA_SUBTITLES_SHOWING,e)}}Xo=new WeakMap;jd=new WeakSet;_g=function(){var s;if(Vb(this,Xo)===JSON.stringify(this.mediaSubtitlesList))return;Wb(this,Xo,JSON.stringify(this.mediaSubtitlesList)),this.defaultSlot.textContent="";const e=!this.value,t=qn({type:"radio",text:this.formatMenuItemText("Off"),value:"off",checked:e});t.prepend(Ys(this,"checked-indicator")),this.defaultSlot.append(t);const i=this.mediaSubtitlesList;for(const n of i){const r=qn({type:"radio",text:this.formatMenuItemText(n.label,n),value:Cd(n),checked:this.value==Cd(n)});r.prepend(Ys(this,"checked-indicator")),((s=n.kind)!=null?s:"subs")==="captions"&&r.append(Ys(this,"captions-indicator")),this.defaultSlot.append(r)}};no=new WeakSet;Xd=function(){const s=this.mediaSubtitlesShowing,e=this.getAttribute(x.MEDIA_SUBTITLES_SHOWING),t=this.value!==e;if(s?.length&&t&&this.dispatchEvent(new B.CustomEvent(Ee.MEDIA_DISABLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:s})),!this.value||!t)return;const i=new B.CustomEvent(Ee.MEDIA_SHOW_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(i)};Hb(Ag,"template",Sg);const Ch=(s,e)=>{const t=s.getAttribute(e);return t?Il(t):[]},wh=(s,e,t)=>{if(!t?.length){s.removeAttribute(e);return}const i=Mr(t);s.getAttribute(e)!==i&&s.setAttribute(e,i)};B.customElements.get("media-captions-menu")||B.customElements.define("media-captions-menu",Ag);const Yb=`<svg aria-hidden="true" viewBox="0 0 26 24"> 470 <path d="M22.83 5.68a2.58 2.58 0 0 0-2.3-2.5c-3.62-.24-11.44-.24-15.06 0a2.58 2.58 0 0 0-2.3 2.5c-.23 4.21-.23 8.43 0 12.64a2.58 2.58 0 0 0 2.3 2.5c3.62.24 11.44.24 15.06 0a2.58 2.58 0 0 0 2.3-2.5c.23-4.21.23-8.43 0-12.64Zm-11.39 9.45a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.92 3.92 0 0 1 .92-2.77 3.18 3.18 0 0 1 2.43-1 2.94 2.94 0 0 1 2.13.78c.364.359.62.813.74 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.17 1.61 1.61 0 0 0-1.29.58 2.79 2.79 0 0 0-.5 1.89 3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.48 1.48 0 0 0 1-.37 2.1 2.1 0 0 0 .59-1.14l1.4.44a3.23 3.23 0 0 1-1.07 1.69Zm7.22 0a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.88 3.88 0 0 1 .93-2.77 3.14 3.14 0 0 1 2.42-1 3 3 0 0 1 2.16.82 2.8 2.8 0 0 1 .73 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.21 1.61 1.61 0 0 0-1.29.58A2.79 2.79 0 0 0 15 12a3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.44 1.44 0 0 0 1-.37 2.1 2.1 0 0 0 .6-1.15l1.4.44a3.17 3.17 0 0 1-1.1 1.7Z"/> 471</svg>`,zb=`<svg aria-hidden="true" viewBox="0 0 26 24"> 472 <path d="M17.73 14.09a1.4 1.4 0 0 1-1 .37 1.579 1.579 0 0 1-1.27-.58A3 3 0 0 1 15 12a2.8 2.8 0 0 1 .5-1.85 1.63 1.63 0 0 1 1.29-.57 1.47 1.47 0 0 1 1.51 1.2l1.43-.34A2.89 2.89 0 0 0 19 9.07a3 3 0 0 0-2.14-.78 3.14 3.14 0 0 0-2.42 1 3.91 3.91 0 0 0-.93 2.78 3.74 3.74 0 0 0 .92 2.66 3.07 3.07 0 0 0 2.34 1 3.07 3.07 0 0 0 1.91-.57 3.17 3.17 0 0 0 1.07-1.74l-1.4-.45c-.083.43-.3.822-.62 1.12Zm-7.22 0a1.43 1.43 0 0 1-1 .37 1.58 1.58 0 0 1-1.27-.58A3 3 0 0 1 7.76 12a2.8 2.8 0 0 1 .5-1.85 1.63 1.63 0 0 1 1.29-.57 1.47 1.47 0 0 1 1.51 1.2l1.43-.34a2.8
4721 2.81 0 0 0-.74-1.32 2.94 2.94 0 0 0-2.13-.78 3.18 3.18 0 0 0-2.43 1 4 4 0 0 0-.92 2.78 3.74 3.74 0 0 0 .92 2.66 3.07 3.07 0 0 0 2.34 1 3.07 3.07 0 0 0 1.91-.57 3.23 3.23 0 0 0 1.07-1.74l-1.4-.45a2.06 2.06 0 0 1-.6 1.07Zm12.32-8.41a2.59 2.59 0 0 0-2.3-2.51C18.72 3.05 15.86 3 13 3c-2.86 0-5.72.05-7.53.17a2.59 2.59 0 0 0-2.3 2.51c-.23 4.207-.23 8.423 0 12.63a2.57 2.57 0 0 0 2.3 2.5c1.81.13 4.67.19 7.53.19 2.86 0 5.72-.06 7.53-.19a2.57 2.57 0 0 0 2.3-2.5c.23-4.207.23-8.423 0-12.63Zm-1.49 12.53a1.11 1.11 0 0 1-.91 1.11c-1.67.11-4.45.18-7.43.18-2.98 0-5.76-.07-7.43-.18a1.11 1.11 0 0 1-.91-1.11c-.21-4.14-.21-8.29 0-12.43a1.11 1.11 0 0 1 .91-1.11C7.24 4.56 10 4.49 13 4.49s5.76.07 7.43.18a1.11 1.11 0 0 1 .91 1.11c.21 4.14.21 8.29 0 12.43Z"/> 473</svg>`,Ig=ke.createElement("template");Ig.innerHTML=` 474 <style> 475 :host([aria-checked="true"]) slot[name=off] { 476 display: none !important; 477 } 478 479 480 :host(:not([aria-checked="true"])) slot[name=on] { 481 display: none !important; 482 } 483 </style> 484 485 <slot name="icon"> 486 <slot name="on">${Yb}</slot> 487 <slot name="off">${zb}</slot> 488 </slot> 489`;const Ph=s=>{s.setAttribute("aria-checked",zm(s))};class jb extends Qn{static get observedAttributes(){return[...super.observedAttributes,x.MEDIA_SUBTITLES_LIST,x.MEDIA_SUBTITLES_SHOWING]}constructor(e={}){super({slotTemplate:Ig,...e}),this._captionsReady=!1}connectedCallback(){super.connectedCallback(),this.setAttribute("aria-label",ci.CLOSED_CAPTIONS()),Ph(this)}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===x.MEDIA_SUBTITLES_SHOWING&&Ph(this)}get invokeTargetElement(){return this.invokeTarget!=null?super.invokeTargetElement:Ii(this).querySelector("media-captions-menu")}get mediaSubtitlesList(){return Mh(this,x.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){Oh(this,x.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return Mh(this,x.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){Oh(this,x.MEDIA_SUBTITLES_SHOWING,e)}}const Mh=(s,e)=>{const t=s.getAttribute(e);return t?Il(t):[]},Oh=(s,e,t)=>{if(!t?.length){s.removeAttribute(e);return}const i=Mr(t);s.getAttribute(e)!==i&&s.setAttribute(e,i)};B.customElements.get("media-captions-menu-button")||B.customElements.define("media-captions-menu-button",jb);const Xb='<svg aria-hidden="true" viewBox="0 0 24 24"><g><path class="cast_caf_icon_arch0" d="M1,18 L1,21 L4,21 C4,19.3 2.66,18 1,18 L1,18 Z"/><path class="cast_caf_icon_arch1" d="M1,14 L1,16 C3.76,16 6,18.2 6,21 L8,21 C8,17.13 4.87,14 1,14 L1,14 Z"/><path class="cast_caf_icon_arch2" d="M1,10 L1,12 C5.97,12 10,16.0 10,21 L12,21 C12,14.92 7.07,10 1,10 L1,10 Z"/><path class="cast_caf_icon_box" d="M21,3 L3,3 C1.9,3 1,3.9 1,5 L1,8 L3,8 L3,5 L21,5 L21,19 L14,19 L14,21 L21,21 C22.1,21 23,20.1 23,19 L23,5 C23,3.9 22.1,3 21,3 L21,3 Z"/></g></svg>',Qb='<svg aria-hidden="true" viewBox="0 0 24 24"><g><path class="cast_caf_icon_arch0" d="M1,18 L1,21 L4,21 C4,19.3 2.66,18 1,18 L1,18 Z"/><path class="cast_caf_icon_arch1" d="M1,14 L1,16 C3.76,16 6,18.2 6,21 L8,21 C8,17.13 4.87,14 1,14 L1,14 Z"/><path class="cast_caf_icon_arch2" d="M1,10 L1,12 C5.97,12 10,16.0 10,21 L12,21 C12,14.92 7.07,10 1,10 L1,10 Z"/><path class="cast_caf_icon_box" d="M21,3 L3,3 C1.9,3 1,3.9 1,5 L1,8 L3,8 L3,5 L21,5 L21,19 L14,19 L14,21 L21,21 C22.1,21 23,20.1 23,19 L23,5 C23,3.9 22.1,3 21,3 L21,3 Z"/><path class="cast_caf_icon_boxfill" d="M5,7 L5,8.63 C8,8.6 13.37,14 13.37,17 L19,17 L19,7 Z"/></g></svg>',xg=ke.createElement("template");xg.innerHTML=` 490 <style> 491 :host([${x.MEDIA_IS_CASTING}]) slot:not([name=exit]):not([name=icon]) { 492 display: none !important; 493 } 494 495 496 :host(:not([${x.MEDIA_IS_CASTING}])) slot:not([name=enter]):not([name=icon]) { 497 display: none !important; 498 } 499 </style> 500 501 <slot name="icon"> 502 <slot name="enter">${Xb}</slot> 503 <slot name="exit">${Qb}</slot> 504 </slot> 505`;const Fh=s=>{const e=s.mediaIsCasting?Vt.EXIT_CAST():Vt.ENTER_CAST();s.setAttribute("aria-label",e)};class Zb extends ui{static get observedAttributes(){return[...super.observedAttributes,x.MEDIA_IS_CASTING,x.MEDIA_CAST_UNAVAILABLE]}constructor(e={}){super({slotTemplate:xg,...e})}connectedCallback(){super.connectedCallback(),Fh(this)}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===x.MEDIA_IS_CASTING&&Fh(this)}get mediaIsCasting(){return Ft(this,x.MEDIA_IS_CASTING)}set mediaIsCasting(e){$t(this,x.MEDIA_IS_CASTING,e)}get mediaCastUnavailable(){return Wt(this,x.MEDIA_CAST_UNAVAILABLE)}set mediaCastUnavailable(e){qt(this,x.MEDIA_CAST_UNAVAILABLE,e)}handleClick(){const e=this.mediaIsCasting?Ee.MEDIA_EXIT_CAST_REQUEST:Ee.MEDIA_ENTER_CAST_REQUEST;this.dispatchEvent(new B.CustomEvent(e,{composed:!0,bubbles:!0}))}}B.customElements.get("media-cast-button")||B.customElements.define("media-cast-button",Zb);var Jb=Object.defineProperty,e_=(s,e,t)=>e in s?Jb(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,t_=(s,e,t)=>(e_(s,e+"",t),t),fu=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},Fn=(s,e,t)=>(fu(s,e,"read from private field"),t?t.call(s):e.get(s)),Fs=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},Lg=(s,e,t,i)=>(fu(s,e,"write to private field"),e.set(s,t),t),er=(s,e,t)=>(fu(s,e,"access private method"),t),$r,Xs,Qd,Rg,Zd,kg,Jd,Dg,ec,Cg,tc,wg;const Pg=ke.createElement("template");Pg.innerHTML=` 506 <style> 507 :host { 508 font: var(--media-font, 509 var(--media-font-weight, normal) 510 var(--media-font-size, 14px) / 511 var(--media-text-content-height, var(--media-control-height, 24px)) 512 var(--media-font-family, helvetica neue, segoe ui, roboto, arial, sans-serif)); 513 color: var(--media-text-color, var(--media-primary-color, rgb(238 238 238))); 514 background: var(--media-dialog-background, var(--media-control-background, var(--media-secondary-color, rgb(20 20 30 / .8)))); 515 border-radius: var(--media-dialog-border-radius); 516 border: var(--media-dialog-border, none); 517 display: var(--media-dialog-display, inline-flex); 518 transition: var(--media-dialog-transition-in, 519 visibility 0s, 520 opacity .2s ease-out, 521 transform .15s ease-out 522 ) !important; 523 524 visibility: var(--media-dialog-visibility, visible); 525 opacity: var(--media-dialog-opacity, 1); 526 transform: var(--media-dialog-transform-in, translateY(0) scale(1)); 527 } 528 529 :host([hidden]) { 530 transition: var(--media-dialog-transition-out, 531 visibility .15s ease-in, 532 opacity .15s ease-in, 533 transform .15s ease-in 534 ) !important; 535 visibility: var(--media-dialog-hidden-visibility, hidden); 536 opacity: var(--media-dialog-hidden-opacity, 0); 537 transform: var(--media-dialog-transform-out, translateY(2px) scale(.99)); 538 pointer-events: none; 539 } 540 </style> 541 <slot></slot> 542`;const ql={HIDDEN:"hidden",ANCHOR:"anchor"};class Mg extends B.HTMLElement{constructor(){super(),Fs(this,Qd),Fs(this,Zd),Fs(this,Jd),Fs(this,ec),Fs(this,tc),Fs(this,$r,void 0),Fs(this,Xs,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.nativeEl=this.constructor.template.content.cloneNode(!0),this.shadowRoot.append(this.nativeEl)),this.addEventListener("invoke",this),this.addEventListener("focusout",this),this.addEventListener("keydown",this)}static get observedAttributes(){return[ql.HIDDEN,ql.ANCHOR]}handleEvent(e){switch(e.type){case"invoke":er(this,Jd,Dg).call(this,e);break;case"focusout":er(this,ec,Cg).call(this,e);break;case"keydown":er(this,tc,wg).call(this,e);break}}connectedCallback(){this.role||(this.role="dialog")}attributeChangedCallback(e,t,i){e===ql.HIDDEN&&i!==t&&(this.hidden?er(this,Zd,
542kg).call(this):er(this,Qd,Rg).call(this))}focus(){Lg(this,$r,eu());const e=this.querySelector('[autofocus], [tabindex]:not([tabindex="-1"]), [role="menu"]');e?.focus()}get keysUsed(){return["Escape","Tab"]}}$r=new WeakMap;Xs=new WeakMap;Qd=new WeakSet;Rg=function(){var s;(s=Fn(this,Xs))==null||s.setAttribute("aria-expanded","true"),this.addEventListener("transitionend",()=>this.focus(),{once:!0})};Zd=new WeakSet;kg=function(){var s;(s=Fn(this,Xs))==null||s.setAttribute("aria-expanded","false")};Jd=new WeakSet;Dg=function(s){Lg(this,Xs,s.relatedTarget),ls(this,s.relatedTarget)||(this.hidden=!this.hidden)};ec=new WeakSet;Cg=function(s){var e;ls(this,s.relatedTarget)||((e=Fn(this,$r))==null||e.focus(),Fn(this,Xs)&&Fn(this,Xs)!==s.relatedTarget&&!this.hidden&&(this.hidden=!0))};tc=new WeakSet;wg=function(s){var e,t,i,n,r;const{key:a,ctrlKey:o,altKey:d,metaKey:l}=s;o||d||l||this.keysUsed.includes(a)&&(s.preventDefault(),s.stopPropagation(),a==="Tab"?(s.shiftKey?(t=(e=this.previousElementSibling)==null?void 0:e.focus)==null||t.call(e):(n=(i=this.nextElementSibling)==null?void 0:i.focus)==null||n.call(i),this.blur()):a==="Escape"&&((r=Fn(this,$r))==null||r.focus(),this.hidden=!0))};t_(Mg,"template",Pg);B.customElements.get("media-chrome-dialog")||B.customElements.define("media-chrome-dialog",Mg);var i_=Object.defineProperty,s_=(s,e,t)=>e in s?i_(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,n_=(s,e,t)=>(s_(s,e+"",t),t),mu=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},Vi=(s,e,t)=>(mu(s,e,"read from private field"),t?t.call(s):e.get(s)),Ji=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},Yl=(s,e,t,i)=>(mu(s,e,"write to private field"),e.set(s,t),t),Hi=(s,e,t)=>(mu(s,e,"access private method"),t),ro,Ir,ic,Og,gu,Fg,pu,$g,Wi,Yn,Nr,sc,Ng,ao,nc;const Ug=ke.createElement("template");Ug.innerHTML=` 543 <style> 544 :host { 545 transition: var(--media-menu-item-transition, 546 background .15s linear, 547 opacity .2s ease-in-out 548 ); 549 outline: var(--media-menu-item-outline, 0); 550 outline-offset: var(--media-menu-item-outline-offset, -1px); 551 cursor: pointer; 552 display: flex; 553 align-items: center; 554 align-self: stretch; 555 justify-self: stretch; 556 white-space: nowrap; 557 white-space-collapse: collapse; 558 text-wrap: nowrap; 559 padding: .4em .8em .4em 1em; 560 } 561 562 :host(:focus-visible) { 563 box-shadow: var(--media-menu-item-focus-shadow, inset 0 0 0 2px rgb(27 127 204 / .9)); 564 outline: var(--media-menu-item-hover-outline, 0); 565 outline-offset: var(--media-menu-item-hover-outline-offset, var(--media-menu-item-outline-offset, -1px)); 566 } 567 568 :host(:hover) { 569 cursor: pointer; 570 background: var(--media-menu-item-hover-background, rgb(92 92 102 / .5)); 571 outline: var(--media-menu-item-hover-outline); 572 outline-offset: var(--media-menu-item-hover-outline-offset, var(--media-menu-item-outline-offset, -1px)); 573 } 574 575 :host([aria-checked="true"]) { 576 background: var(--media-menu-item-checked-background); 577 } 578 579 :host([hidden]) { 580 display: none; 581 } 582 583 :host([disabled]) { 584 pointer-events: none; 585 color: rgba(255, 255, 255, .3); 586 } 587 588 slot:not([name]) { 589 width: 100%; 590 } 591 592 slot:not([name="submenu"]) { 593 display: inline-flex; 594 align-items: center; 595 transition: inherit; 596 opacity: var(--media-menu-item-opacity, 1); 597 } 598 599 slot[name="description"] { 600 justify-content: end; 601 } 602 603 slot[name="description"] > span { 604 display: inline-block; 605 margin-inline: 1em .2em; 606 max-width: var(--media-menu-item-description-max-width, 100px); 607 text-overflow: ellipsis; 608 overflow: hidden; 609 font-size: .8em; 610 font-weight: 400; 611 text-align: right; 612 position: relative; 613 top: .04em; 614 } 615 616 slot[name="checked-indicator"] { 617 display: none; 618 } 619 620 :host(:is([role="menuitemradio"],[role="menuitemcheckbox"])) slot[name="checked-indicator"] { 621 display: var(--media-menu-item-checked-indicator-display, inline-block); 622 } 623 624 625 svg, img, ::slotted(svg), ::slotted(img) { 626 height: var(--media-menu-item-icon-height, var(--media-control-height, 24px)); 627 fill: var(--media-icon-color, var(--media-primary-color, rgb(238 238 238))); 628 display: block; 629 } 630 631 632 [part~="indicator"], 633 ::slotted([part~="indicator"]) { 634 fill: var(--media-menu-item-indicator-fill, 635 var(--media-icon-color, var(--media-primary-color, rgb(238 238 238)))); 636 height: var(--media-menu-item-indicator-height, 1.25em); 637 margin-right: .5ch; 638 } 639 640 [part~="checked-indicator"] { 641 visibility: hidden; 642 } 643 644 :host([aria-checked="true"]) [part~="checked-indicator"] { 645 visibility: visible; 646 } 647 </style> 648 <slot name="checked-indicator"> 649 <svg aria-hidden="true" viewBox="0 1 24 24" part="checked-indicator indicator"> 650 <path d="m10 15.17 9.193-9.191 1.414 1.414-10.606 10.606-6.364-6.364 1.414-1.414 4.95 4.95Z"/> 651 </svg> 652 </slot> 653 <slot name="prefix"></slot> 654 <slot></slot> 655 <slot name="description"></slot> 656 <slot name="suffix"></slot> 657 <slot name="submenu"></slot> 658`;const mi={TYPE:"type",VALUE:"value",CHECKED:"checked",DISABLED:"disabled"};class Ll extends B.HTMLElement{constructor(){super(),Ji(this,ic),Ji(this,gu),Ji(this,pu),Ji(this,Yn),Ji(this,sc),Ji(this,ao),Ji(this,ro,!1),Ji(this,Ir,void 0),Ji(this,Wi,()=>{var e,t;this.setAttribute("submenusize",`${this.submenuElement.items.length}`);const i=this.shadowRoot.querySelector('slot[name="description"]'),n=(t=(e=this.submenuElement.checkedItems)==null?void 0:e[0])==null?void 0:t.text,r=ke.createElement("span");r.textContent=n??"",i.replaceChildren(r)}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.append(this.constructor.template.content.cloneNode(!0))),this.shadowRoot.addEventListener("slotchange",this)}static get observedAttributes(){return[mi.TYPE,mi.DISABLED,mi.CHECKED,mi.VALUE]}enable(){this.hasAttribute("tabindex")||this.setAttribute("tabindex","-1"),tr(this)&&!this.hasAttribute("aria-checked")&&this.setAttribute("aria-checked","fal
658se"),this.addEventListener("click",this),this.addEventListener("keydown",this)}disable(){this.removeAttribute("tabindex"),this.removeEventListener("click",this),this.removeEventListener("keydown",this),this.removeEventListener("keyup",this)}handleEvent(e){switch(e.type){case"slotchange":Hi(this,ic,Og).call(this,e);break;case"click":this.handleClick(e);break;case"keydown":Hi(this,sc,Ng).call(this,e);break;case"keyup":Hi(this,Yn,Nr).call(this,e);break}}attributeChangedCallback(e,t,i){e===mi.CHECKED&&tr(this)&&!Vi(this,ro)?this.setAttribute("aria-checked",i!=null?"true":"false"):e===mi.TYPE&&i!==t?this.role="menuitem"+i:e===mi.DISABLED&&i!==t&&(i==null?this.enable():this.disable())}connectedCallback(){this.hasAttribute(mi.DISABLED)||this.enable(),this.role="menuitem"+this.type,Yl(this,Ir,rc(this,this.parentNode)),Hi(this,ao,nc).call(this)}disconnectedCallback(){this.disable(),Hi(this,ao,nc).call(this),Yl(this,Ir,null)}get invokeTarget(){return this.getAttribute("invoketarget")}set invokeTarget(e){this.setAttribute("invoketarget",`${e}`)}get invokeTargetElement(){var e;return this.invokeTarget?(e=bl(this))==null?void 0:e.querySelector(`#${this.invokeTarget}`):this.submenuElement}get submenuElement(){return this.shadowRoot.querySelector('slot[name="submenu"]').assignedElements({flatten:!0})[0]}get type(){var e;return(e=this.getAttribute(mi.TYPE))!=null?e:""}set type(e){this.setAttribute(mi.TYPE,`${e}`)}get value(){var e;return(e=this.getAttribute(mi.VALUE))!=null?e:this.text}set value(e){this.setAttribute(mi.VALUE,e)}get text(){var e;return((e=this.textContent)!=null?e:"").trim()}get checked(){if(tr(this))return this.getAttribute("aria-checked")==="true"}set checked(e){tr(this)&&(Yl(this,ro,!0),this.setAttribute("aria-checked",e?"true":"false"),e?this.part.add("checked"):this.part.remove("checked"))}handleClick(e){tr(this)||this.invokeTargetElement&&ls(this,e.target)&&this.invokeTargetElement.dispatchEvent(new au({relatedTarget:this}))}get keysUsed(){return["Enter"," "]}}ro=new WeakMap;Ir=new WeakMap;ic=new WeakSet;Og=function(s){const e=s.target;if(!e?.name)for(let i of e.assignedNodes({flatten:!0}))i instanceof Text&&i.textContent.trim()===""&&i.remove();e.name==="submenu"&&(this.submenuElement?Hi(this,gu,Fg).call(this):Hi(this,pu,$g).call(this))};gu=new WeakSet;Fg=async function(){this.setAttribute("aria-haspopup","menu"),this.setAttribute("aria-expanded",`${!this.submenuElement.hidden}`),this.submenuElement.addEventListener("change",Vi(this,Wi)),this.submenuElement.addEventListener("addmenuitem",Vi(this,Wi)),this.submenuElement.addEventListener("removemenuitem",Vi(this,Wi)),Vi(this,Wi).call(this)};pu=new WeakSet;$g=function(){this.removeAttribute("aria-haspopup"),this.removeAttribute("aria-expanded"),this.submenuElement.removeEventListener("change",Vi(this,Wi)),this.submenuElement.removeEventListener("addmenuitem",Vi(this,Wi)),this.submenuElement.removeEventListener("removemenuitem",Vi(this,Wi)),Vi(this,Wi).call(this)};Wi=new WeakMap;Yn=new WeakSet;Nr=function(s){const{key:e}=s;if(!this.keysUsed.includes(e)){this.removeEventListener("keyup",Hi(this,Yn,Nr));return}this.handleClick(s)};sc=new WeakSet;Ng=function(s){const{metaKey:e,altKey:t,key:i}=s;if(e||t||!this.keysUsed.includes(i)){this.removeEventListener("keyup",Hi(this,Yn,Nr));return}this.addEventListener("keyup",Hi(this,Yn,Nr),{once:!0})};ao=new WeakSet;nc=function(){var s;const e=(s=Vi(this,Ir))==null?void 0:s.radioGroupItems;if(!e)return;let t=e.filter(i=>i.getAttribute("aria-checked")==="true").pop();t||(t=e[0]);for(const i of e)i.setAttribute("aria-checked","false");t?.setAttribute("aria-checked","true")};n_(Ll,"template",Ug);function tr(s){return s.type==="radio"||s.type==="checkbox"}function rc(s,e){if(!s)return null;const{host:t}=s.getRootNode();return!e&&t?rc(s,t):e?.items?e:rc(e,e?.parentNode)}B.customElements.get("media-chrome-menu-item")||B.customElements.define("media-chrome-menu-item",Ll);var vu=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},ft=(s,e,t)=>(vu(s,e,"read from private field"),t?t.call(s):e.get(s)),Nt=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},ys=(s,e,t,i)=>(vu(s,e,"write to private field"),e.set(s,t),t),Ei=(s,e,t)=>(vu(s,e,"access private method"),t),Pi,Rl,oo,lo,Ti,Qo,co,uo,ho,Eu,Bg,fo,ac,mo,oc,Zo,yu,lc,Gg,dc,Kg,cc,Hg,uc,Vg;
658const Wg=ke.createElement("template");Wg.innerHTML=` 659 <style> 660 :host { 661 --_focus-box-shadow: var(--media-focus-box-shadow, inset 0 0 0 2px rgb(27 127 204 / .9)); 662 --_media-range-padding: var(--media-range-padding, var(--media-control-padding, 10px)); 663 664 box-shadow: var(--_focus-visible-box-shadow, none); 665 background: var(--media-control-background, var(--media-secondary-color, rgb(20 20 30 / .7))); 666 height: calc(var(--media-control-height, 24px) + 2 * var(--_media-range-padding)); 667 display: inline-flex; 668 align-items: center; 669 670 vertical-align: middle; 671 box-sizing: border-box; 672 position: relative; 673 width: 100px; 674 transition: background .15s linear; 675 cursor: pointer; 676 pointer-events: auto; 677 touch-action: none; 678 z-index: 1; 679 } 680 681 682 input[type=range]:focus { 683 outline: 0; 684 } 685 input[type=range]:focus::-webkit-slider-runnable-track { 686 outline: 0; 687 } 688 689 :host(:hover) { 690 background: var(--media-control-hover-background, rgb(50 50 70 / .7)); 691 } 692 693 #leftgap { 694 padding-left: var(--media-range-padding-left, var(--_media-range-padding)); 695 } 696 697 #rightgap { 698 padding-right: var(--media-range-padding-right, var(--_media-range-padding)); 699 } 700 701 #startpoint, 702 #endpoint { 703 position: absolute; 704 } 705 706 #endpoint { 707 right: 0; 708 } 709 710 #container { 711 712 width: var(--media-range-track-width, 100%); 713 transform: translate(var(--media-range-track-translate-x, 0px), var(--media-range-track-translate-y, 0px)); 714 position: relative; 715 height: 100%; 716 display: flex; 717 align-items: center; 718 min-width: 40px; 719 } 720 721 #range { 722 723 display: var(--media-time-range-hover-display, block); 724 bottom: var(--media-time-range-hover-bottom, -7px); 725 height: var(--media-time-range-hover-height, max(100% + 7px, 25px)); 726 width: 100%; 727 position: absolute; 728 cursor: pointer; 729 730 -webkit-appearance: none; 731 -webkit-tap-highlight-color: transparent; 732 background: transparent; 733 margin: 0; 734 z-index: 1; 735 } 736 737 @media (hover: hover) { 738 #range { 739 bottom: var(--media-time-range-hover-bottom, -5px); 740 height: var(--media-time-range-hover-height, max(100% + 5px, 20px)); 741 } 742 } 743 744 745 746 #range::-webkit-slider-thumb { 747 -webkit-appearance: none; 748 background: transparent; 749 width: .1px; 750 height: .1px; 751 } 752 753 754 #range::-moz-range-thumb { 755 background: transparent; 756 border: transparent; 757 width: .1px; 758 height: .1px; 759 } 760 761 #appearance { 762 height: var(--media-range-track-height, 4px); 763 display: flex; 764 flex-direction: column; 765 justify-content: center; 766 width: 100%; 767 position: absolute; 768 769 will-change: transform; 770 } 771 772 #background, 773 #track { 774 border-radius: var(--media-range-track-border-radius, 1px); 775 position: absolute; 776 width: 100%; 777 height: 100%; 778 } 779 780 #background { 781 background: var(--media-range-track-background, rgb(255 255 255 / .2)); 782 backdrop-filter: var(--media-range-track-background-backdrop-filter); 783 -webkit-backdrop-filter: var(--media-range-track-background-backdrop-filter); 784 } 785 786 #track { 787 border: var(--media-range-track-border, none); 788 outline: var(--media-range-track-outline); 789 outline-offset: var(--media-range-track-outline-offset); 790 backdrop-filter: var(--media-range-track-backdrop-filter); 791 -webkit-backdrop-filter: var(--media-range-track-backdrop-filter);
792 box-shadow: var(--media-range-track-box-shadow, none); 793 overflow: hidden; 794 } 795 796 #progress, 797 #highlight, 798 #pointer { 799 position: absolute; 800 height: 100%; 801 will-change: width; 802 } 803 804 #progress { 805 background: var(--media-range-bar-color, var(--media-primary-color, rgb(238 238 238))); 806 transition: var(--media-range-track-transition); 807 } 808 809 #pointer { 810 background: var(--media-range-track-pointer-background); 811 border-right: var(--media-range-track-pointer-border-right); 812 transition: visibility .25s, opacity .25s; 813 visibility: hidden; 814 opacity: 0; 815 } 816 817 @media (hover: hover) { 818 :host(:hover) #pointer { 819 transition: visibility .5s, opacity .5s; 820 visibility: visible; 821 opacity: 1; 822 } 823 } 824 825 #thumb { 826 width: var(--media-range-thumb-width, 10px); 827 height: var(--media-range-thumb-height, 10px); 828 margin-left: calc(var(--media-range-thumb-width, 10px) / -2); 829 border: var(--media-range-thumb-border, none); 830 border-radius: var(--media-range-thumb-border-radius, 10px); 831 background: var(--media-range-thumb-background, var(--media-primary-color, rgb(238 238 238))); 832 box-shadow: var(--media-range-thumb-box-shadow, 1px 1px 1px transparent); 833 transition: var(--media-range-thumb-transition); 834 transform: var(--media-range-thumb-transform, none); 835 opacity: var(--media-range-thumb-opacity, 1); 836 position: absolute; 837 left: 0; 838 cursor: pointer; 839 } 840 841 :host([disabled]) #thumb { 842 background-color: #777; 843 } 844 845 .segments #appearance { 846 height: var(--media-range-segment-hover-height, 7px); 847 } 848 849 #background, 850 #track { 851 clip-path: url(#segments-clipping); 852 } 853 854 #segments { 855 --segments-gap: var(--media-range-segments-gap, 2px); 856 position: absolute; 857 width: 100%; 858 height: 100%; 859 } 860 861 #segments-clipping { 862 transform: translateX(calc(var(--segments-gap) / 2)); 863 } 864 865 #segments-clipping:empty { 866 display: none; 867 } 868 869 #segments-clipping rect { 870 height: var(--media-range-track-height, 4px); 871 y: calc((var(--media-range-segment-hover-height, 7px) - var(--media-range-track-height, 4px)) / 2); 872 transition: var(--media-range-segment-transition, transform .1s ease-in-out); 873 transform: var(--media-range-segment-transform, scaleY(1)); 874 transform-origin: center; 875 } 876 </style> 877 <div id="leftgap"></div> 878 <div id="container"> 879 <div id="startpoint"></div> 880 <div id="endpoint"></div> 881 <div id="appearance" part="appearance"> 882 <div id="background"></div> 883 <div id="track"> 884 <div id="highlight"></div> 885 <div id="pointer"></div> 886 <div id="progress"></div> 887 </div> 888 <div id="thumb"></div> 889 <svg id="segments"><clipPath id="segments-clipping"></clipPath></svg> 890 </div>
891 <input id="range" type="range" min="0" max="1" step="any" value="0"> 892 </div> 893 <div id="rightgap"></div> 894`;class Tu extends B.HTMLElement{constructor(){super(),Nt(this,Eu),Nt(this,fo),Nt(this,mo),Nt(this,Zo),Nt(this,lc),Nt(this,dc),Nt(this,cc),Nt(this,uc),Nt(this,Pi,void 0),Nt(this,Rl,void 0),Nt(this,oo,void 0),Nt(this,lo,void 0),Nt(this,Ti,{}),Nt(this,Qo,[]),Nt(this,co,()=>{if(this.range.matches(":focus-visible")){const{style:e}=At(this.shadowRoot,":host");e.setProperty("--_focus-visible-box-shadow","var(--_focus-box-shadow)")}}),Nt(this,uo,()=>{const{style:e}=At(this.shadowRoot,":host");e.removeProperty("--_focus-visible-box-shadow")}),Nt(this,ho,()=>{const e=this.shadowRoot.querySelector("#segments-clipping");e&&e.parentNode.append(e)}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Wg.content.cloneNode(!0))),this.container=this.shadowRoot.querySelector("#container"),ys(this,oo,this.shadowRoot.querySelector("#startpoint")),ys(this,lo,this.shadowRoot.querySelector("#endpoint")),this.range=this.shadowRoot.querySelector("#range"),this.appearance=this.shadowRoot.querySelector("#appearance")}static get observedAttributes(){return["disabled","aria-disabled",st.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,i){var n,r,a,o,d;e===st.MEDIA_CONTROLLER?(t&&((r=(n=ft(this,Pi))==null?void 0:n.unassociateElement)==null||r.call(n,this),ys(this,Pi,null)),i&&this.isConnected&&(ys(this,Pi,(a=this.getRootNode())==null?void 0:a.getElementById(i)),(d=(o=ft(this,Pi))==null?void 0:o.associateElement)==null||d.call(o,this))):(e==="disabled"||e==="aria-disabled"&&t!==i)&&(i==null?(this.range.removeAttribute(e),Ei(this,fo,ac).call(this)):(this.range.setAttribute(e,i),Ei(this,mo,oc).call(this)))}connectedCallback(){var e,t,i;const{style:n}=At(this.shadowRoot,":host");n.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`),ft(this,Ti).pointer=At(this.shadowRoot,"#pointer"),ft(this,Ti).progress=At(this.shadowRoot,"#progress"),ft(this,Ti).thumb=At(this.shadowRoot,"#thumb");const r=this.getAttribute(st.MEDIA_CONTROLLER);r&&(ys(this,Pi,(e=this.getRootNode())==null?void 0:e.getElementById(r)),(i=(t=ft(this,Pi))==null?void 0:t.associateElement)==null||i.call(t,this)),this.updateBar(),this.shadowRoot.addEventListener("focusin",ft(this,co)),this.shadowRoot.addEventListener("focusout",ft(this,uo)),Ei(this,fo,ac).call(this),Kn(this.container,ft(this,ho))}disconnectedCallback(){var e,t;Ei(this,mo,oc).call(this),(t=(e=ft(this,Pi))==null?void 0:e.unassociateElement)==null||t.call(e,this),ys(this,Pi,null),this.shadowRoot.removeEventListener("focusin",ft(this,co)),this.shadowRoot.removeEventListener("focusout",ft(this,uo)),Cr(this.container,ft(this,ho))}updatePointerBar(e){var t;(t=ft(this,Ti).pointer)==null||t.style.setProperty("width",`${this.getPointerRatio(e)*100}%`)}updateBar(){var e,t;const i=this.range.valueAsNumber*100;(e=ft(this,Ti).progress)==null||e.style.setProperty("width",`${i}%`),(t=ft(this,Ti).thumb)==null||t.style.setProperty("left",`${i}%`)}updateSegments(e){const t=this.shadowRoot.querySelector("#segments-clipping");if(t.textContent="",this.container.classList.toggle("segments",!!e?.length),!e?.length)return;ft(this,Ti).activeSegment=$m(this.shadowRoot,"#segments-clipping rect:nth-child(0)");const i=[...new Set([+this.range.min,...e.flatMap(r=>[r.start,r.end]),+this.range.max])];ys(this,Qo,[...i]);const n=i.pop();for(const[r,a]of i.entries()){const[o,d]=[r===0,r===i.length-1],l=o?"calc(var(--segments-gap) / -1)":`${a*100}%`,u=`calc(${((d?n:i[r+1])-a)*100}%${o||d?"":" - var(--segments-gap)"})`,h=ke.createElementNS("http://www.w3.org/2000/svg","rect"),f=At(this.shadowRoot,`#segments-clipping rect:nth-child(${r+1})`);f.style.setProperty("x",l),f.style.setProperty("width",u),t.append(h)}}getPointerRatio(e){let t=CT(e.clientX,e.clientY,ft(this,oo).getBoundingClientRect(),ft(this,lo).getBoundingClientRect());return Math.max(0,Math.min(1,t))}get dragging(){return this.hasAttribute("dragging")}handleEvent(e){switch(e.type){case"pointermove":Ei(this,uc,Vg).call(this,e);break;case"input":this.updateBar();break;case"pointerenter":Ei(this,lc,Gg).call(this,e);break;case"pointerdown":Ei(this,Zo,yu).call(this,e);break;case"pointerup":Ei(this,dc,Kg).call(this);break;case"pointerleave":Ei(this,cc,Hg).call(this);break}}get keysUsed(){return["ArrowUp","ArrowRight","ArrowDown","ArrowLeft"]}}Pi=new WeakMap;Rl=new WeakMap;oo=new WeakMap;lo=new WeakMap;Ti=new WeakMap;Qo=new WeakMap;co=new WeakMap;uo=new WeakMap;ho=new WeakMap;Eu=new WeakSet;Bg=function(s){const e=ft(this,Ti).activeSegment;if(!e)return;const t=this.getPointerRatio(s),n=`#segments-clipping rect:nth-child(${ft(this,Qo).findIndex((r,a,o)=>{const d=o[a+1];return d!=null&&t>=r&&t<=d})+1})`;(e.selectorText!=n||!e.style.transform)&&(e.selectorText=n,e.style.setProperty("transform","var(--media-range-segment-hover-transform, scaleY(2))"))};fo=new WeakSet;ac=function(){this.hasAttribute("disabled")||(this.addEventListener("input",this),this.addEventListener("pointerdown",this),this.addEventListener("pointerenter",this))};mo=new WeakSet;oc=function(){var s,e;this.removeEventListener("input",this),this.removeEventListener("pointerdown",this),this.removeEventListener("pointerenter",this),(s=B.window)==null||s.removeEventListener("pointerup",this),(e=B.window)==null||e.removeEventListener("pointermove",this)};Zo=new WeakSet;yu=function(s){var e;ys(this,Rl,s.composedPath().includes(this.range)),(e=B.window)==null||e.addEventListener("pointerup",this)};lc=new WeakSet;Gg=function(s){var e;s.pointerType!=="mouse"&&Ei(this,Zo,yu).call(this,s),this.addEventListener("pointerleave",this),(e=B.window)==null||e.addEventListener("pointermove",this)};dc=new WeakSet;Kg=function(){var s;(s=B.window)==null||s.removeEventListener("pointerup",this),this.toggleAttribute("dragging",!1),this.range.disabled=this.hasAttribute("disabled")};cc=new WeakSet;Hg=function(){var s,e;this.removeEventListener("pointerleave",this),(s=B.window)==null||s.removeEventListener("pointermove",this),this.toggleAttribute("dragging",!1),this.range.disabled=this.hasAttribute("disabled"),(e=ft(this,Ti).activeSegment)==null||e.style.removeProperty("transform")};uc=new WeakSet;Vg=function(s){this.toggleAttribute("dragging",s.buttons===1||s.pointerType!=="mouse"),this.updatePointerBar(s),Ei(this,Eu,Bg).call(this,s),this.dragging&&(s.pointerType!=="mouse"||!ft(this,Rl))&&(this.range.disabled=!0,this.range.valueAsNumber=this.getPointerRatio(s),this.range.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})))};B.customElements.get("media-chrome-range")||B.customElements.define("media-chrome-range",Tu);var qg=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},pa=(s,e,t)=>(qg(s,e,"read from private field"),t?t.call(s):e.get(s)),r_=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},va=(s,e,t,i)=>(qg(s,e,"write to private field"),e.set(s,t),t),Mi;const Yg=ke.createElement("template");Yg.innerHTML=` 895 <style> 896 :host { 897 898 box-sizing: border-box; 899 display: var(--media-control-display, var(--media-control-bar-display, inline-flex)); 900 color: var(--media-text-color, var(--media-primary-color, rgb(238 238 238))); 901 --media-loading-indicator-icon-height: 44px; 902 } 903 904 ::slotted(media-time-range), 905 ::slotted(media-volume-range) { 906 min-height: 100%; 907 } 908 909 ::slotted(media-time-range), 910 ::slotted(media-clip-selector) { 911 flex-grow: 1; 912 } 913 </style> 914 915 <slot></slot> 916`;class a_ extends B.HTMLElement{constructor(){super(),r_(this,Mi,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Yg.content.cloneNode(!0)))}static get observedAttributes(){return[st.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,i){var n,r,a,o,d;e===st.MEDIA_CONTROLLER&&(t&&((r=(n=pa(this,Mi))==null?void 0:n.unassociateElement)==null||r.call(n,this),va(this,Mi,null)),i&&this.isConnected&&(va(this,Mi,(a=this.getRootNode())==null?void 0:a.getElementById(i)),(d=(o=pa(this,Mi))==null?void 0:o.associateElement)==null||d.call(o,this)))}connectedCallback(){var e,t,i;const n=this.getAttribute(st.MEDIA_CONTROLLER);n&&(va(this,Mi,(e=this.getRootNode())==null?void 0:e.getElementById(n)),(i=(t=pa(this,Mi))==null?void 0:t.associateElement)==null||i.call(t,this))}disconnectedCallback(){var e,t;(t=(e=pa(this,Mi))==null?void 0:e.unassociateElement)==null||t.call(e,this),va(this,Mi,null)}}Mi=new WeakMap;B.customElements.get("media-control-bar")||B.customElements.define("media-control-bar",a_);var zg=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},Ea=(s,e,t)=>(zg(s,e,"read from private field"),t?t.call(s):e.get(s)),o_=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},ya=(s,e,t,i)=>(zg(s,e,"write to private field"),e.set(s,t),t),Oi;const jg=ke.createElement("template");jg.innerHTML=` 917 <style> 918 :host { 919 font: var(--media-font, 920 var(--media-font-weight, normal) 921 var(--media-font-size, 14px) / 922 var(--media-text-content-height, var(--media-control-height, 24px)) 923 var(--media-font-family, helvetica neue, segoe ui, roboto, arial, sans-serif)); 924 color: var(--media-text-color, var(--media-primary-color, rgb(238 238 238))); 925 background: var(--media-text-background, var(--media-control-background, var(--media-secondary-color, rgb(20 20 30 / .7)))); 926 padding: var(--media-control-padding, 10px); 927 display: inline-flex; 928 justify-content: center; 929 align-items: center; 930 vertical-align: middle; 931 box-sizing: border-box; 932 text-align: center; 933 pointer-events: auto; 934 } 935 936 937 :host(:focus-visible) { 938 box-shadow: inset 0 0 0 2px rgb(27 127 204 / .9); 939 outline: 0; 940 } 941 942 943 :host(:where(:focus)) { 944 box-shadow: none; 945 outline: 0; 946 } 947 </style> 948 <slot></slot> 949`;class Qr extends B.HTMLElement{constructor(){super(),o_(this,Oi,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(jg.content.cloneNode(!0)))}static get observedAttributes(){return[st.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,i){var n,r,a,o,d;e===st.MEDIA_CONTROLLER&&(t&&((r=(n=Ea(this,Oi))==null?void 0:n.unassociateElement)==null||r.call(n,this),ya(this,Oi,null)),i&&this.isConnected&&(ya(this,Oi,(a=this.getRootNode())==null?void 0:a.getElementById(i)),(d=(o=Ea(this,Oi))==null?void 0:o.associateElement)==null||d.call(o,this)))}connectedCallback(){var e,t,i;const{style:n}=At(this.shadowRoot,":host");n.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`);const r=this.getAttribute(st.MEDIA_CONTROLLER);r&&(ya(this,Oi,(e=this.getRootNode())==null?void 0:e.getElementById(r)),(i=(t=Ea(this,Oi))==null?void 0:t.associateElement)==null||i.call(t,this))}disconnectedCallback(){var e,t;(t=(e=Ea(this,Oi))==null?void 0:e.unassociateElement)==null||t.call(e,this),ya(this,Oi,null)}}Oi=new WeakMap;B.customElements.get("media-text-display")||B.customElements.define("media-text-display",Qr);var l_=Qr,Xg=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},$h=(s,e,t)=>(Xg(s,e,"read from private field"),t?t.call(s):e.get(s)),d_=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},c_=(s,e,t,i)=>(Xg(s,e,"write to private field"),e.set(s,t),t),fr;class u_ extends Qr{constructor(){super(),d_(this,fr,void 0),c_(this,fr,this.shadowRoot.querySelector("slot")),$h(this,fr).textContent=Hs(0)}static get observedAttributes(){return[...super.observedAttributes,x.MEDIA_DURATION]}attributeChangedCallback(e,t,i){e===x.MEDIA_DURATION&&($h(this,fr).textContent=Hs(+i)),super.attributeChangedCallback(e,t,i)}get mediaDuration(){return Tt(this,x.MEDIA_DURATION)}set mediaDuration(e){Kt(this,x.MEDIA_DURATION,e)}}fr=new WeakMap;B.customElements.get("media-duration-display")||B.customElements.define("media-duration-display",u_);const h_=`<svg aria-hidden="true" viewBox="0 0 26 24"> 950 <path d="M16 3v2.5h3.5V9H22V3h-6ZM4 9h2.5V5.5H10V3H4v6Zm15.5 9.5H16V21h6v-6h-2.5v3.5ZM6.5 15H4v6h6v-2.5H6.5V15Z"/> 951</svg>`,f_=`<svg aria-hidden="true" viewBox="0 0 26 24"> 952 <path d="M18.5 6.5V3H16v6h6V6.5h-3.5ZM16 21h2.5v-3.5H22V15h-6v6ZM4 17.5h3.5V21H10v-6H4v2.5Zm3.5-11H4V9h6V3H7.5v3.5Z"/> 953</svg>`,Qg=ke.createElement("template");Qg.innerHTML=` 954 <style> 955 :host([${x.MEDIA_IS_FULLSCREEN}]) slot:not([name=exit]):not([name=icon]) { 956 display: none !important; 957 } 958 959 960 :host(:not([${x.MEDIA_IS_FULLSCREEN}])) slot:not([name=enter]):not([name=icon]) { 961 display: none !important; 962 } 963 </style> 964 965 <slot name="icon"> 966 <slot name="enter">${h_}</slot> 967 <slot name="exit">${f_}</slot> 968 </slot> 969`;const Nh=s=>{const e=s.mediaIsFullscreen?Vt.EXIT_FULLSCREEN():Vt.ENTER_FULLSCREEN();s.setAttribute("aria-label",e)};class m_ extends ui{static get observedAttributes(){return[...super.observedAttributes,x.MEDIA_IS_FULLSCREEN,x.MEDIA_FULLSCREEN_UNAVAILABLE]}constructor(e={}){super({slotTemplate:Qg,...e})}connectedCallback(){super.connectedCallback(),Nh(this)}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===x.MEDIA_IS_FULLSCREEN&&Nh(this)}get mediaFullscreenUnavailable(){return Wt(this,x.MEDIA_FULLSCREEN_UNAVAILABLE)}set mediaFullscreenUnavailable(e){qt(this,x.MEDIA_FULLSCREEN_UNAVAILABLE,e)}get mediaIsFullscreen(){return Ft(this,x.MEDIA_IS_FULLSCREEN)}set mediaIsFullscreen(e){$t(this,x.MEDIA_IS_FULLSCREEN,e)}handleClick(){const e=this.mediaIsFullscreen?Ee.MEDIA_EXIT_FULLSCREEN_REQUEST:Ee.MEDIA_ENTER_FULLSCREEN_REQUEST;this.dispatchEvent(new B.CustomEvent(e,{composed:!0,bubbles:!0}))}}B.customElements.get("media-fullscreen-button")||B.customElements.define("media-fullscreen-button",m_);const{MEDIA_TIME_IS_LIVE:go,MEDIA_PAUSED:xr}=x,{MEDIA_SEEK_TO_LIVE_REQUEST:g_,MEDIA_PLAY_REQUEST:p_}=Ee,v_='<svg viewBox="0 0 6 12"><circle cx="3" cy="6" r="2"></circle></svg>',Zg=ke.createElement("template");Zg.innerHTML=` 970 <style> 971 972 slot[name=indicator] > *, 973 :host ::slotted([slot=indicator]) { 974 975 min-width: auto; 976 fill: var(--media-live-button-icon-color, rgb(140, 140, 140)); 977 color: var(--media-live-button-icon-color, rgb(140, 140, 140)); 978 } 979 980 :host([${go}]:not([${xr}])) slot[name=indicator] > *, 981 :host([${go}]:not([${xr}])) ::slotted([slot=indicator]) { 982 fill: var(--media-live-button-indicator-color, rgb(255, 0, 0)); 983 color: var(--media-live-button-indicator-color, rgb(255, 0, 0)); 984 } 985 986 :host([${go}]:not([${xr}])) {
987 cursor: not-allowed; 988 } 989 990 </style> 991 992 <slot name="indicator">${v_}</slot> 993 994 <slot name="spacer"> </slot><slot name="text">LIVE</slot> 995`;const Uh=s=>{const e=s.mediaPaused||!s.mediaTimeIsLive,t=e?Vt.SEEK_LIVE():Vt.PLAYING_LIVE();s.setAttribute("aria-label",t),e?s.removeAttribute("aria-disabled"):s.setAttribute("aria-disabled","true")};class E_ extends ui{static get observedAttributes(){return[...super.observedAttributes,xr,go]}constructor(e={}){super({slotTemplate:Zg,...e})}connectedCallback(){Uh(this),super.connectedCallback()}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),Uh(this)}get mediaPaused(){return Ft(this,x.MEDIA_PAUSED)}set mediaPaused(e){$t(this,x.MEDIA_PAUSED,e)}get mediaTimeIsLive(){return Ft(this,x.MEDIA_TIME_IS_LIVE)}set mediaTimeIsLive(e){$t(this,x.MEDIA_TIME_IS_LIVE,e)}handleClick(){!this.mediaPaused&&this.mediaTimeIsLive||(this.dispatchEvent(new B.CustomEvent(g_,{composed:!0,bubbles:!0})),this.hasAttribute(xr)&&this.dispatchEvent(new B.CustomEvent(p_,{composed:!0,bubbles:!0})))}}B.customElements.get("media-live-button")||B.customElements.define("media-live-button",E_);var Jg=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},ir=(s,e,t)=>(Jg(s,e,"read from private field"),t?t.call(s):e.get(s)),Bh=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},sr=(s,e,t,i)=>(Jg(s,e,"write to private field"),e.set(s,t),t),Fi,po;const Gh={LOADING_DELAY:"loadingdelay"},ep=500,tp=ke.createElement("template"),y_=` 996<svg aria-hidden="true" viewBox="0 0 100 100"> 997 <path d="M73,50c0-12.7-10.3-23-23-23S27,37.3,27,50 M30.9,50c0-10.5,8.5-19.1,19.1-19.1S69.1,39.5,69.1,50"> 998 <animateTransform 999 attributeName="transform" 1000 attributeType="XML" 1001 type="rotate" 1002 dur="1s" 1003 from="0 50 50" 1004 to="360 50 50" 1005 repeatCount="indefinite" /> 1006 </path> 1007</svg> 1008`;tp.innerHTML=` 1009<style> 1010:host { 1011 display: var(--media-control-display, var(--media-loading-indicator-display, inline-block)); 1012 vertical-align: middle; 1013 box-sizing: border-box; 1014 --_loading-indicator-delay: var(--media-loading-indicator-transition-delay, ${ep}ms); 1015} 1016 1017#status { 1018 color: rgba(0,0,0,0); 1019 width: 0px; 1020 height: 0px; 1021} 1022 1023:host slot[name=icon] > *, 1024:host ::slotted([slot=icon]) { 1025 opacity: var(--media-loading-indicator-opacity, 0); 1026 transition: opacity 0.15s; 1027} 1028 1029:host([${x.MEDIA_LOADING}]:not([${x.MEDIA_PAUSED}])) slot[name=icon] > *, 1030:host([${x.MEDIA_LOADING}]:not([${x.MEDIA_PAUSED}])) ::slotted([slot=icon]) { 1031 opacity: var(--media-loading-indicator-opacity, 1); 1032 transition: opacity 0.15s var(--_loading-indicator-delay); 1033} 1034 1035:host #status { 1036 visibility: var(--media-loading-indicator-opacity, hidden); 1037 transition: visibility 0.15s; 1038} 1039 1040:host([${x.MEDIA_LOADING}]:not([${x.MEDIA_PAUSED}])) #status { 1041 visibility: var(--media-loading-indicator-opacity, visible); 1042 transition: visibility 0.15s var(--_loading-indicator-delay); 1043} 1044 1045svg, img, ::slotted(svg), ::slotted(img) { 1046 width: var(--media-loading-indicator-icon-width); 1047 height: var(--media-loading-indicator-icon-height, 100px); 1048 fill: var(--media-icon-color, var(--media-primary-color, rgb(238 238 238))); 1049 vertical-align: middle; 1050} 1051</style> 1052 1053<slot name="icon">${y_}</slot> 1054<div id="status" role="status" aria-live="polite">${ci.MEDIA_LOADING()}</div> 1055`;class T_ extends B.HTMLElement{constructor(){if(super(),Bh(this,Fi,void 0),Bh(this,po,ep),!this.shadowRoot){const e=this.attachShadow({mode:"open"}),t=tp.content.cloneNode(!0);e.appendChild(t)}}static get observedAttributes(){return[st.MEDIA_CONTROLLER,x.MEDIA_PAUSED,x.MEDIA_LOADING,Gh.LOADING_DELAY]}attributeChangedCallback(e,t,i){var n,r,a,o,d;e===Gh.LOADING_DELAY&&t!==i?this.loadingDelay=Number(i):e===st.MEDIA_CONTROLLER&&(t&&((r=(n=ir(this,Fi))==null?void 0:n.unassociateElement)==null||r.call(n,this),sr(this,Fi,null)),i&&this.isConnected&&(sr(this,Fi,(a=this.getRootNode())==null?void 0:a.getElementById(i)),(d=(o=ir(this,Fi))==null?void 0:o.associateElement)==null||d.call(o,this)))}connectedCallback(){var e,t,i;const n=this.getAttribute(st.MEDIA_CONTROLLER);n&&(sr(this,Fi,(e=this.getRootNode())==null?void 0:e.getElementById(n)),(i=(t=ir(this,Fi))==null?void 0:t.associateElement)==null||i.call(t,this))}disconnectedCallback(){var e,t;(t=(e=ir(this,Fi))==null?void 0:e.unassociateElement)==null||t.call(e,this),sr(this,Fi,null)}get loadingDelay(){return ir(this,po)}set loadingDelay(e){sr(this,po,e);const{style:t}=At(this.shadowRoot,":host");t.setProperty("--_loading-indicator-delay",`var(--media-loading-indicator-transition-delay, ${e}ms)`)}get mediaPaused(){return Ft(this,x.MEDIA_PAUSED)}set mediaPaused(e){$t(this,x.MEDIA_PAUSED,e)}get mediaLoading(){return Ft(this,x.MEDIA_LOADING)}set mediaLoading(e){$t(this,x.MEDIA_LOADING,e)}}Fi=new WeakMap;po=new WeakMap;B.customElements.get("media-loading-indicator")||B.customElements.define("media-loading-indicator",T_);const{MEDIA_VOLUME_LEVEL:nr}=x,b_=`<svg aria-hidden="true" viewBox="0 0 24 24"> 1056 <path d="M16.5 12A4.5 4.5 0 0 0 14 8v2.18l2.45 2.45a4.22 4.22 0 0 0 .05-.63Zm2.5 0a6.84 6.84 0 0 1-.54 2.64L20 16.15A8.8 8.8 0 0 0 21 12a9 9 0 0 0-7-8.77v2.06A7 7 0 0 1 19 12ZM4.27 3 3 4.27 7.73 9H3v6h4l5 5v-6.73l4.25 4.25A6.92 6.92 0 0 1 14 18.7v2.06A9 9 0 0 0 17.69 19l2 2.05L21 19.73l-9-9L4.27 3ZM12 4 9.91 6.09 12 8.18V4Z"/> 1057</svg>`,Kh=`<svg aria-hidden="true" viewBox="0 0 24 24"> 1058 <path d="M3 9v6h4l5 5V4L7 9H3Zm13.5 3A4.5 4.5 0 0 0 14 8v8a4.47 4.47 0 0 0 2.5-4Z"/> 1059</svg>`,__=`<svg aria-hidden="true" viewBox="0 0 24 24"> 1060 <path d="M3 9v6h4l5 5V4L7 9H3Zm13.5 3A4.5 4.5 0 0 0 14 8v8a4.47 4.47 0 0 0 2.5-4ZM14 3.23v2.06a7 7 0 0 1 0 13.42v2.06a9 9 0 0 0 0-17.54Z"/> 1061</svg>`,ip=ke.createElement("template");ip.innerHTML=` 1062 <style> 1063 1064 :host(:not([${nr}
1064])) slot:not([name=high]):not([name=icon]), 1065 :host([${nr}=high]) slot:not([name=high]):not([name=icon]) { 1066 display: none !important; 1067 } 1068 1069 :host([${nr}=off]) slot:not([name=off]):not([name=icon]) { 1070 display: none !important; 1071 } 1072 1073 :host([${nr}=low]) slot:not([name=low]):not([name=icon]) { 1074 display: none !important; 1075 } 1076 1077 :host([${nr}=medium]) slot:not([name=medium]):not([name=icon]) { 1078 display: none !important; 1079 } 1080 </style> 1081 1082 <slot name="icon"> 1083 <slot name="off">${b_}</slot> 1084 <slot name="low">${Kh}</slot> 1085 <slot name="medium">${Kh}</slot> 1086 <slot name="high">${__}</slot> 1087 </slot> 1088`;const Hh=s=>{const t=s.mediaVolumeLevel==="off"?Vt.UNMUTE():Vt.MUTE();s.setAttribute("aria-label",t)};class S_ extends ui{static get observedAttributes(){return[...super.observedAttributes,x.MEDIA_VOLUME_LEVEL]}constructor(e={}){super({slotTemplate:ip,...e})}connectedCallback(){Hh(this),super.connectedCallback()}attributeChangedCallback(e,t,i){e===x.MEDIA_VOLUME_LEVEL&&Hh(this),super.attributeChangedCallback(e,t,i)}get mediaVolumeLevel(){return Wt(this,x.MEDIA_VOLUME_LEVEL)}set mediaVolumeLevel(e){qt(this,x.MEDIA_VOLUME_LEVEL,e)}handleClick(){const e=this.mediaVolumeLevel==="off"?Ee.MEDIA_UNMUTE_REQUEST:Ee.MEDIA_MUTE_REQUEST;this.dispatchEvent(new B.CustomEvent(e,{composed:!0,bubbles:!0}))}}B.customElements.get("media-mute-button")||B.customElements.define("media-mute-button",S_);const Vh=`<svg aria-hidden="true" viewBox="0 0 28 24"> 1089 <path d="M24 3H4a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h20a1 1 0 0 0 1-1V4a1 1 0 0 0-1-1Zm-1 16H5V5h18v14Zm-3-8h-7v5h7v-5Z"/> 1090</svg>`,sp=ke.createElement("template");sp.innerHTML=` 1091 <style> 1092 :host([${x.MEDIA_IS_PIP}]) slot:not([name=exit]):not([name=icon]) { 1093 display: none !important; 1094 } 1095 1096 1097 :host(:not([${x.MEDIA_IS_PIP}])) slot:not([name=enter]):not([name=icon]) { 1098 display: none !important; 1099 } 1100 </style> 1101 1102 <slot name="icon"> 1103 <slot name="enter">${Vh}</slot> 1104 <slot name="exit">${Vh}</slot> 1105 </slot> 1106`;const Wh=s=>{const e=s.mediaIsPip?Vt.EXIT_PIP():Vt.ENTER_PIP();s.setAttribute("aria-label",e)};class A_ extends ui{static get observedAttributes(){return[...super.observedAttributes,x.MEDIA_IS_PIP,x.MEDIA_PIP_UNAVAILABLE]}constructor(e={}){super({slotTemplate:sp,...e})}connectedCallback(){Wh(this),super.connectedCallback()}attributeChangedCallback(e,t,i){e===x.MEDIA_IS_PIP&&Wh(this),super.attributeChangedCallback(e,t,i)}get mediaPipUnavailable(){return Wt(this,x.MEDIA_PIP_UNAVAILABLE)}set mediaPipUnavailable(e){qt(this,x.MEDIA_PIP_UNAVAILABLE,e)}get mediaIsPip(){return Ft(this,x.MEDIA_IS_PIP)}set mediaIsPip(e){$t(this,x.MEDIA_IS_PIP,e)}handleClick(){const e=this.mediaIsPip?Ee.MEDIA_EXIT_PIP_REQUEST:Ee.MEDIA_ENTER_PIP_REQUEST;this.dispatchEvent(new B.CustomEvent(e,{composed:!0,bubbles:!0}))}}B.customElements.get("media-pip-button")||B.customElements.define("media-pip-button",A_);var I_=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},Ta=(s,e,t)=>(I_(s,e,"read from private field"),t?t.call(s):e.get(s)),x_=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},pn;const zl={RATES:"rates"},np=[1,1.2,1.5,1.7,2],mr=1,rp=ke.createElement("template");rp.innerHTML=` 1107 <style> 1108 :host { 1109 min-width: 5ch; 1110 padding: var(--media-button-padding, var(--media-control-padding, 10px 5px)); 1111 } 1112 </style> 1113 <slot name="icon"></slot> 1114`;class L_ extends ui{constructor(e={}){super({slotTemplate:rp,...e}),x_(this,pn,new Al(this,zl.RATES,{defaultValue:np})),this.container=this.shadowRoot.querySelector('slot[name="icon"]'),this.container.innerHTML=`${mr}x`}static get observedAttributes(){return[...super.observedAttributes,x.MEDIA_PLAYBACK_RATE,zl.RATES]}attributeChangedCallback(e,t,i){if(super.attributeChangedCallback(e,t,i),e===zl.RATES&&(Ta(this,pn).value=i),e===x.MEDIA_PLAYBACK_RATE){const n=i?+i:Number.NaN,r=Number.isNaN(n)?mr:n;this.container.innerHTML=`${r}x`,this.setAttribute("aria-label",ci.PLAYBACK_RATE({playbackRate:r}))}}get rates(){return Ta(this,pn)}set rates(e){e?Array.isArray(e)&&(Ta(this,pn).value=e.join(" ")):Ta(this,pn).value=""}get mediaPlaybackRate(){return Tt(this,x.MEDIA_PLAYBACK_RATE,mr)}set mediaPlaybackRate(e){Kt(this,x.MEDIA_PLAYBACK_RATE,e)}handleClick(){var e,t;const i=Array.from(this.rates.values(),a=>+a).sort((a,o)=>a-o),n=(t=(e=i.find(a=>a>this.mediaPlaybackRate))!=null?e:i[0])!=null?t:mr,r=new B.CustomEvent(Ee.MEDIA_PLAYBACK_RATE_REQUEST,{composed:!0,bubbles:!0,detail:n});this.dispatchEvent(r)}}pn=new WeakMap;B.customElements.get("media-playback-rate-button")||B.customElements.define("media-playback-rate-button",L_);var ap=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},ba=(s,e,t)=>(ap(s,e,"read from private field"),t?t.call(s):e.get(s)),jl=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},rr=(s,e,t)=>(ap(s,e,"access private method"),t),vn,gr,vo,Eo,hc;const Xl={RATES:"rates"};class R_ extends ds{constructor(){super(),jl(this,gr),jl(this,Eo),jl(this,vn,new Al(this,Xl.RATES,{defaultValue:np})),rr(this,gr,vo).call(this)}static get observedAttributes(){return[...super.observedAttributes,x.MEDIA_PLAYBACK_RATE,Xl.RATES]}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===x.MEDIA_PLAYBACK_RATE&&t!=i?this.value=i:e===Xl.RATES&&t!=i&&(ba(this,vn).value=i,rr(this,gr,vo).call(this))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",rr(this,Eo,hc))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",rr(this,Eo,hc))}get anchorElement(){return this.anchor!=="auto"?super.anchorElement:Ii(this).querySelector("media-playback-rate-menu-button")}get rates(){return ba(this,vn)}set rates(e){e?Array.isArray(e)&&(ba(this,vn).value=e.join(" ")):ba(this,vn).value="",rr(this,gr,vo).call(this)}get mediaPlaybackRate(){return Tt(this,x.MEDIA_PLAYBACK_RATE,mr)}set mediaPlaybackRate(e){Kt(this,x.MEDIA_PLAYBACK_RATE,e)}}vn=new WeakMap;gr=new WeakSet;vo=function(){this.defaultSlot.textContent="";for(const s of this.rates){const e=qn({type:"radio",text:this.formatMenuItemText(`${s}x`,s),value:s,checked:this.mediaPlaybackRate==s});
1114e.prepend(Ys(this,"checked-indicator")),this.defaultSlot.append(e)}};Eo=new WeakSet;hc=function(){if(!this.value)return;const s=new B.CustomEvent(Ee.MEDIA_PLAYBACK_RATE_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(s)};B.customElements.get("media-playback-rate-menu")||B.customElements.define("media-playback-rate-menu",R_);var k_=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},_a=(s,e,t)=>(k_(s,e,"read from private field"),t?t.call(s):e.get(s)),D_=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},En;const Ql={RATES:"rates"},C_=[1,1.2,1.5,1.7,2],Zl=1,op=ke.createElement("template");op.innerHTML=` 1115 <style> 1116 :host { 1117 min-width: 5ch; 1118 padding: var(--media-button-padding, var(--media-control-padding, 10px 5px)); 1119 } 1120 </style> 1121 <slot name="icon"></slot> 1122`;class w_ extends Qn{constructor(e={}){super({slotTemplate:op,...e}),D_(this,En,new Al(this,Ql.RATES,{defaultValue:C_})),this.container=this.shadowRoot.querySelector('slot[name="icon"]'),this.container.innerHTML=`${Zl}x`}static get observedAttributes(){return[...super.observedAttributes,x.MEDIA_PLAYBACK_RATE,Ql.RATES]}attributeChangedCallback(e,t,i){if(super.attributeChangedCallback(e,t,i),e===Ql.RATES&&(_a(this,En).value=i),e===x.MEDIA_PLAYBACK_RATE){const n=i?+i:Number.NaN,r=Number.isNaN(n)?Zl:n;this.container.innerHTML=`${r}x`,this.setAttribute("aria-label",ci.PLAYBACK_RATE({playbackRate:r}))}}get invokeTargetElement(){return this.invokeTarget!=null?super.invokeTargetElement:Ii(this).querySelector("media-playback-rate-menu")}get rates(){return _a(this,En)}set rates(e){e?Array.isArray(e)&&(_a(this,En).value=e.join(" ")):_a(this,En).value=""}get mediaPlaybackRate(){return Tt(this,x.MEDIA_PLAYBACK_RATE,Zl)}set mediaPlaybackRate(e){Kt(this,x.MEDIA_PLAYBACK_RATE,e)}}En=new WeakMap;B.customElements.get("media-playback-rate-menu-button")||B.customElements.define("media-playback-rate-menu-button",w_);const P_=`<svg aria-hidden="true" viewBox="0 0 24 24"> 1123 <path d="m6 21 15-9L6 3v18Z"/> 1124</svg>`,M_=`<svg aria-hidden="true" viewBox="0 0 24 24"> 1125 <path d="M6 20h4V4H6v16Zm8-16v16h4V4h-4Z"/> 1126</svg>`,lp=ke.createElement("template");lp.innerHTML=` 1127 <style> 1128 :host([${x.MEDIA_PAUSED}]) slot[name=pause] { 1129 display: none !important; 1130 } 1131 1132 :host(:not([${x.MEDIA_PAUSED}])) slot[name=play] { 1133 display: none !important; 1134 } 1135 </style> 1136 1137 <slot name="icon"> 1138 <slot name="play">${P_}</slot> 1139 <slot name="pause">${M_}</slot> 1140 </slot> 1141`;const qh=s=>{const e=s.mediaPaused?Vt.PLAY():Vt.PAUSE();s.setAttribute("aria-label",e)};class O_ extends ui{static get observedAttributes(){return[...super.observedAttributes,x.MEDIA_PAUSED,x.MEDIA_ENDED]}constructor(e={}){super({slotTemplate:lp,...e})}connectedCallback(){qh(this),super.connectedCallback()}attributeChangedCallback(e,t,i){e===x.MEDIA_PAUSED&&qh(this),super.attributeChangedCallback(e,t,i)}get mediaPaused(){return Ft(this,x.MEDIA_PAUSED)}set mediaPaused(e){$t(this,x.MEDIA_PAUSED,e)}handleClick(){const e=this.mediaPaused?Ee.MEDIA_PLAY_REQUEST:Ee.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new B.CustomEvent(e,{composed:!0,bubbles:!0}))}}B.customElements.get("media-play-button")||B.customElements.define("media-play-button",O_);const xi={PLACEHOLDER_SRC:"placeholdersrc",SRC:"src"},dp=ke.createElement("template");dp.innerHTML=` 1142 <style> 1143 :host { 1144 pointer-events: none; 1145 display: var(--media-poster-image-display, inline-block); 1146 box-sizing: border-box; 1147 } 1148 1149 img { 1150 max-width: 100%; 1151 max-height: 100%; 1152 min-width: 100%; 1153 min-height: 100%; 1154 background-repeat: no-repeat; 1155 background-position: var(--media-poster-image-background-position, var(--media-object-position, center)); 1156 background-size: var(--media-poster-image-background-size, var(--media-object-fit, contain)); 1157 object-fit: var(--media-object-fit, contain); 1158 object-position: var(--media-object-position, center); 1159 } 1160 </style> 1161 1162 <img part="poster img" aria-hidden="true" id="image"/> 1163`;const F_=s=>{s.style.removeProperty("background-image")},$_=(s,e)=>{s.style["background-image"]=`url('${e}')`};class N_ extends B.HTMLElement{static get observedAttributes(){return[xi.PLACEHOLDER_SRC,xi.SRC]}constructor(){super(),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(dp.content.cloneNode(!0))),this.image=this.shadowRoot.querySelector("#image")}attributeChangedCallback(e,t,i){e===xi.SRC&&(i==null?this.image.removeAttribute(xi.SRC):this.image.setAttribute(xi.SRC,i)),e===xi.PLACEHOLDER_SRC&&(i==null?F_(this.image):$_(this.image,i))}get placeholderSrc(){return Wt(this,xi.PLACEHOLDER_SRC)}set placeholderSrc(e){qt(this,xi.SRC,e)}get src(){return Wt(this,xi.SRC)}set src(e){qt(this,xi.SRC,e)}}B.customElements.get("media-poster-image")||B.customElements.define("media-poster-image",N_);var cp=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},U_=(s,e,t)=>(cp(s,e,"read from private field"),t?t.call(s):e.get(s)),B_=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},G_=(s,e,t,i)=>(cp(s,e,"write to private field"),e.set(s,t),t),yo;class K_ extends l_{constructor(){super(),B_(this,yo,void 0),G_(this,yo,this.shadowRoot.querySelector("slot"))}static get observedAttributes(){return[...super.observedAttributes,x.MEDIA_PREVIEW_CHAPTER]}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===x.MEDIA_PREVIEW_CHAPTER&&i!==t&&i!=null&&(U_(this,yo).textContent=i,i!==""?this.setAttribute("aria-valuetext",`chapter: ${i}`):this.removeAttribute("aria-valuetext"))}get mediaPreviewChapter(){return Wt(this,x.MEDIA_PREVIEW_CHAPTER)}set mediaPreviewChapter(e){qt(this,x.MEDIA_PREVIEW_CHAPTER,e)}}yo=new WeakMap;B.customElements.get("media-preview-chapter-display")||B.customElements.define("media-preview-chapter-display",K_);var up=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},Sa=(s,e,t)=>(up(s,e,"read from private field"),t?t.call(s):e.get(s)),H_=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},Aa=(s,e,t,i)=>(up(s,e,"write to private field"),e.set(s,t),t),$i;const hp=ke.createElement("template");hp.innerHTML=` 1164 <style> 1165 :host { 1166 box-sizing: border-box; 1167 display: var(--media-control-display, var(--media-preview-thumbn
1167ail-display, inline-block)); 1168 overflow: hidden; 1169 } 1170 1171 img { 1172 display: none; 1173 position: relative; 1174 } 1175 </style> 1176 <img crossorigin loading="eager" decoding="async"> 1177`;class V_ extends B.HTMLElement{constructor(){super(),H_(this,$i,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(hp.content.cloneNode(!0)))}static get observedAttributes(){return[st.MEDIA_CONTROLLER,x.MEDIA_PREVIEW_IMAGE,x.MEDIA_PREVIEW_COORDS]}connectedCallback(){var e,t,i;const n=this.getAttribute(st.MEDIA_CONTROLLER);n&&(Aa(this,$i,(e=this.getRootNode())==null?void 0:e.getElementById(n)),(i=(t=Sa(this,$i))==null?void 0:t.associateElement)==null||i.call(t,this))}disconnectedCallback(){var e,t;(t=(e=Sa(this,$i))==null?void 0:e.unassociateElement)==null||t.call(e,this),Aa(this,$i,null)}attributeChangedCallback(e,t,i){var n,r,a,o,d;[x.MEDIA_PREVIEW_IMAGE,x.MEDIA_PREVIEW_COORDS].includes(e)&&this.update(),e===st.MEDIA_CONTROLLER&&(t&&((r=(n=Sa(this,$i))==null?void 0:n.unassociateElement)==null||r.call(n,this),Aa(this,$i,null)),i&&this.isConnected&&(Aa(this,$i,(a=this.getRootNode())==null?void 0:a.getElementById(i)),(d=(o=Sa(this,$i))==null?void 0:o.associateElement)==null||d.call(o,this)))}get mediaPreviewImage(){return Wt(this,x.MEDIA_PREVIEW_IMAGE)}set mediaPreviewImage(e){qt(this,x.MEDIA_PREVIEW_IMAGE,e)}get mediaPreviewCoords(){const e=this.getAttribute(x.MEDIA_PREVIEW_COORDS);if(e)return e.split(/\s+/).map(t=>+t)}set mediaPreviewCoords(e){if(!e){this.removeAttribute(x.MEDIA_PREVIEW_COORDS);return}this.setAttribute(x.MEDIA_PREVIEW_COORDS,e.join(" "))}update(){const e=this.mediaPreviewCoords,t=this.mediaPreviewImage;if(!(e&&t))return;const[i,n,r,a]=e,o=t.split("#")[0],d=getComputedStyle(this),{maxWidth:l,maxHeight:c,minWidth:u,minHeight:h}=d,f=Math.min(parseInt(l)/r,parseInt(c)/a),m=Math.max(parseInt(u)/r,parseInt(h)/a),p=f<1,g=p?f:m>1?m:1,{style:y}=At(this.shadowRoot,":host"),T=At(this.shadowRoot,"img").style,_=this.shadowRoot.querySelector("img"),I=p?"min":"max";y.setProperty(`${I}-width`,"initial","important"),y.setProperty(`${I}-height`,"initial","important"),y.width=`${r*g}px`,y.height=`${a*g}px`;const R=()=>{T.width=`${this.imgWidth*g}px`,T.height=`${this.imgHeight*g}px`,T.display="block"};_.src!==o&&(_.onload=()=>{this.imgWidth=_.naturalWidth,this.imgHeight=_.naturalHeight,R()},_.src=o,R()),R(),T.transform=`translate(-${i*g}px, -${n*g}px)`}}$i=new WeakMap;B.customElements.get("media-preview-thumbnail")||B.customElements.define("media-preview-thumbnail",V_);var fp=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},Yh=(s,e,t)=>(fp(s,e,"read from private field"),t?t.call(s):e.get(s)),W_=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},q_=(s,e,t,i)=>(fp(s,e,"write to private field"),e.set(s,t),t),pr;class Y_ extends Qr{constructor(){super(),W_(this,pr,void 0),q_(this,pr,this.shadowRoot.querySelector("slot")),Yh(this,pr).textContent=Hs(0)}static get observedAttributes(){return[...super.observedAttributes,x.MEDIA_PREVIEW_TIME]}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===x.MEDIA_PREVIEW_TIME&&i!=null&&(Yh(this,pr).textContent=Hs(i))}get mediaPreviewTime(){return Tt(this,x.MEDIA_PREVIEW_TIME)}set mediaPreviewTime(e){Kt(this,x.MEDIA_PREVIEW_TIME,e)}}pr=new WeakMap;B.customElements.get("media-preview-time-display")||B.customElements.define("media-preview-time-display",Y_);var bu=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},mp=(s,e,t)=>(bu(s,e,"read from private field"),t?t.call(s):e.get(s)),Ia=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},fc=(s,e,t,i)=>(bu(s,e,"write to private field"),e.set(s,t),t),xa=(s,e,t)=>(bu(s,e,"access private method"),t),vr,Jo,To,mc,bo,gc;class z_ extends ds{constructor(){super(...arguments),Ia(this,To),Ia(this,bo),Ia(this,vr,[]),Ia(this,Jo,void 0)}static get observedAttributes(){return[...super.observedAttributes,x.MEDIA_RENDITION_LIST,x.MEDIA_RENDITION_SELECTED,x.MEDIA_RENDITION_UNAVAILABLE]}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===x.MEDIA_RENDITION_SELECTED&&t!==i?this.value=i??"auto":e===x.MEDIA_RENDITION_LIST&&t!==i&&(fc(this,vr,yT(i)),xa(this,To,mc).call(this))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",xa(this,bo,gc))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",xa(this,bo,gc))}get anchorElement(){return this.anchor!=="auto"?super.anchorElement:Ii(this).querySelector("media-rendition-menu-button")}get mediaRenditionList(){return mp(this,vr)}set mediaRenditionList(e){fc(this,vr,e),xa(this,To,mc).call(this)}get mediaRenditionSelected(){return Wt(this,x.MEDIA_RENDITION_SELECTED)}set mediaRenditionSelected(e){qt(this,x.MEDIA_RENDITION_SELECTED,e)}}vr=new WeakMap;Jo=new WeakMap;To=new WeakSet;mc=function(){if(mp(this,Jo)===JSON.stringify(this.mediaRenditionList))return;fc(this,Jo,JSON.stringify(this.mediaRenditionList));const s=this.mediaRenditionList.sort((i,n)=>n.height-i.height);this.defaultSlot.textContent="";let e=!this.mediaRenditionSelected;for(const i of s){const n=this.formatMenuItemText(`${Math.min(i.width,i.height)}p`,i),r=qn({type:"radio",text:n,value:`${i.id}`,checked:i.selected&&!e});r.prepend(Ys(this,"checked-indicator")),this.defaultSlot.append(r)}const t=qn({type:"radio",text:this.formatMenuItemText("Auto"),value:"auto",checked:e});t.prepend(Ys(this,"checked-indicator")),this.defaultSlot.append(t)};bo=new WeakSet;gc=function(){if(this.value==null)return;const s=new B.CustomEvent(Ee.MEDIA_RENDITION_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(s)};B.customElements.get("media-rendition-menu")||B.customElements.define("media-rendition-menu",z_);const j_=`<svg aria-hidden="true" viewBox="0 0 24 24"> 1178 <path d="M13.5 2.5h2v6h-2v-2h-11v-2h11v-2Zm4 2h4v2h-4v-2Zm-12 4h2v6h-2v-2h-3v-2h3v-2Zm4 2h12v2h-12v-2Zm1 4h2v6h-2v-2h-8v-2h8v-2Zm4 2h7v2h-7v-2Z" /> 1179</svg>`,gp=ke.createElement("template");gp.innerHTML=` 1180 <slot name="icon">${j_}</slot> 1181`;class X_ extends Qn{static get observedAttributes(){return[...super.observedAttributes,x.MEDIA_RENDITION_SELECTED,x.MEDIA_RENDITION_UNAVAILABLE]}constructor(){super({slotTemplate:gp})}connectedCallback(){super.connectedCallback(),this.setAttribute("aria-label",ci.QUALITY())}get invokeTargetElement(){return this.invokeTarget!=null?super.invokeTargetElement:Ii(this).querySelector("media-rendition-menu")}get mediaRenditionSelected(){return Wt(this,x.MEDIA_RENDITION_SELECTED)}set mediaRenditionSelected(e){qt(this,x.MEDIA_RENDITION_SELECTED,e)}}B.customElements.get("media-rendition-menu-button")||B.customElements.define("media-rendition-menu-button",X_);const rn={SEEK_OFFSET:"seekoffset"},_o=30,Q_=`<svg aria-hidden="true" viewBox="0 0 20 24"><defs><style>.text{font-size:8px;font-family:Arial-BoldMT, Arial;font-weight:700;}</style></defs><text class="text value" transform="translate(2.18 19.87)">${_o}</text><path d="M10 6V3L4.37 7 10 10.94V8a5.54 5.54 0 0 1 1.9 10.48v2.12A7.5 7.5 0 0 0 10 6Z"/></svg>`,pp=ke.createElement("template");pp.innerHTML=` 1182 <slot name="icon">${Q_}</slot> 1183`;const Z_=0;class J_ extends ui{static get observedAttributes(){return[...super.observedAttributes,x.MEDIA_CURRENT_TIME,rn.SEEK_OFFSET]}constructor(e={}){super({slotTemplate:pp,...e})}connectedCallback(){this.seekOffset=Tt(this,rn.SEEK_OFFSET,_o),super.connectedCallback()}attributeChangedCallback(e,t,i){e===rn.SEEK_OFFSET&&(this.seekOffset=Tt(this,rn.SEEK_OFFSET,_o)),super.attributeChangedCallback(e,t,i)}get seekOffset(){return Tt(this,rn.SEEK_OFFSET,_o)}set seekOffset(e){Kt(this,rn.SEEK_OFFSET,e),this.setAttribute("aria-label",Vt.SEEK_BACK_N_SECS({seekOffset:this.seekOffset})),Om(Fm(this,"icon"),this.seekOffset)}get mediaCurrentTime(){return Tt(this,x.MEDIA_CURRENT_TIME,Z_)}set mediaCurrentTime(e){Kt(this,x.MEDIA_CURRENT_TIME,e)}handleClick(){const e=Math.max(this.mediaCurrentTime-this.seekOffset,0),t=new B.CustomEvent(Ee.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)}}B.customElements.get("media-seek-backward-button")||B.customElements.define("media-seek-backward-button",J_);const an={SEEK_OFFSET:"seekoffset"},So=30,eS=`<svg aria-hidden="true" viewBox="0 0 20 24"><defs><style>.text{font-size:8px;font-family:Arial-BoldMT, Arial;font-weight:700;}</style></defs><text class="text value" transform="translate(8.9 19.87)">${So}</text><path d="M10 6V3l5.61 4L10 10.94V8a5.54 5.54 0 0 0-1.9 10.48v2.12A7.5 7.5 0 0 1 10 6Z"/></svg>`,vp=ke.createElement("template");vp.innerHTML=` 1184 <slot name="icon">${eS}</slot> 1185`;const tS=0;class iS extends ui{static get observedAttributes(){return[...super.observedAttributes,x.MEDIA_CURRENT_TIME,an.SEEK_OFFSET]}constructor(e={}){super({slotTemplate:vp,...e})}connectedCallback(){this.seekOffset=Tt(this,an.SEEK_OFFSET,So),super.connectedCallback()}attributeChangedCallback(e,t,i){e===an.SEEK_OFFSET&&(this.seekOffset=Tt(this,an.SEEK_OFFSET,So)),super.attributeChangedCallback(e,t,i)}get seekOffset(){return Tt(this,an.SEEK_OFFSET,So)}set seekOffset(e){Kt(this,an.SEEK_OFFSET,e),this.setAttribute("aria-label",Vt.SEEK_FORWARD_N_SECS({seekOffset:this.seekOffset})),Om(Fm(this,"icon"),this.seekOffset)}get mediaCurrentTime(){return Tt(this,x.MEDIA_CURRENT_TIME,tS)}set mediaCurrentTime(e){Kt(this,x.MEDIA_CURRENT_TIME,e)}handleClick(){const e=this.mediaCurrentTime+this.seekOffset,t=new B.CustomEvent(Ee.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)}}B.customElements.get("media-seek-forward-button")||B.customElements.define("media-seek-forward-button",iS);var sS=Object.defineProperty,nS=(s,e,t)=>e in s?sS(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,rS=(s,e,t)=>(nS(s,e+"",t),t);const Ep=ke.createElement("template");Ep.innerHTML=ds.template.innerHTML+` 1186 <style> 1187 :host { 1188 background: var(--media-settings-menu-background, 1189 var(--media-menu-background, 1190 var(--media-control-background, 1191 var(--media-secondary-color, rgb(20 20 30 / .8))))); 1192 min-width: var(--media-settings-menu-min-width, 160px); 1193 border-radius: 2px 2px 0 0; 1194 overflow: hidden; 1195 } 1196 1197 :host([role="menu"]) { 1198 1199 justify-content: end; 1200 } 1201 1202 slot:not([name]) { 1203 justify-content: var(--media-settings-menu-justify-content); 1204 flex-direction: var(--media-settings-menu-flex-direction, column); 1205 overflow: visible; 1206 } 1207 1208 #container.has-expanded { 1209 --media-settings-menu-item-opacity: 0; 1210 } 1211 </style> 1212`;class yp extends ds{get anchorElement(){return this.anchor!=="auto"?super.anchorElement:Ii(this).querySelector("media-settings-menu-button")}}rS(yp,"template",Ep);B.customElements.get("media-settings-menu")||B.customElements.define("media-settings-menu",yp);const Tp=ke.createElement("template");Tp.innerHTML=` 1213 <slot name="icon"> 1214 <svg aria-hidden="true" viewBox="0 0 24 24"> 1215 <path d="M4.5 14.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5Zm7.5 0a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5Zm7.5 0a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5Z"/> 1216 </svg> 1217 </slot> 1218`;class aS extends Qn{static get observedAttributes(){return[...super.observedAttributes,"target"]}constructor(){super({slotTemplate:Tp})}connectedCallback(){super.connectedCallback(),this.setAttribute("aria-label",ci.SETTINGS())}get invokeTargetElement(){return this.invokeTarget!=null?super.invokeTargetElement:Ii(this).querySelector("media-settings-menu")}}B.customElements.get("media-settings-menu-button")||B.customElements.define("media-settings-menu-button",aS);var oS=Object.defineProperty,lS=(s,e,t)=>e in s?oS(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,dS=(s,e,t)=>(lS(s,e+"",t),t),zh;const el=ke.createElement("template");el.innerHTML=Ll.template.innerHTML+` 1219 <style> 1220 slot:not([name="submenu"]) { 1221 opacity: var(--media-settings-menu-item-opacity, var(--media-menu-item-opacity)); 1222 } 1223 1224 :host([aria-expanded="true"]:hover) { 1225 background: transparent; 1226 } 1227 </style> 1228`;(zh=el.content)!=null&&zh.querySelector&&(el.content.querySelector('slot[name="suffix"]').innerHTML=` 1229 <svg aria-hidden="true" viewBox="0 0 20 24"> 1230 <path d="m8.12 17.585-.742-.669 4.2-4.665-4.2-4.666.743-.669 4.803 5.335-4.803 5.334Z"/> 1231 </svg> 1232 `);class bp extends Ll{}dS(bp,"template",el);B.customElements.get("media-settings-menu-item")||B.customElements.define("media-settings-menu-item",bp);var _p=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},Jl=(s,e,t)=>(_p(s,e,"read from private field"),t?t.call(s):e.get(s)),cS=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},uS=(s,e,t,i)=>(_p(s,e,"write to private field"),e.set(s,t),t),yn;const bi={REMAINING:"remaining",SHOW_DURATION:"showduration",NO_TOGGLE:"notoggle"},jh=[...Object.values(bi),x.MEDIA_CURRENT_TIME,x.MEDIA_DURATION,x.MEDIA_SEEKABLE],Xh=["Enter"," "],hS=" / ",Qh=(s,{timesSep:e=hS}={})=>{var t,i;const n=s.hasAttribute(bi.REMAINING),r=s.hasAttribute(bi.SHOW_DURATION),a=(t=s.mediaCurrentTime)!=null?t:0,[,o]=(i=s.mediaSeekable)!=null?i:[];let d=0;Number.isFinite(s.mediaDuration)?d=s.mediaDuration:Number.isFinite(o)&&
1232(d=o);const l=Hs(n?0-(d-a):a);return r?`${l}${e}${Hs(d)}`:l},fS="video not loaded, unknown time.",mS=s=>{var e;const t=s.mediaCurrentTime,[,i]=(e=s.mediaSeekable)!=null?e:[];let n=null;if(Number.isFinite(s.mediaDuration)?n=s.mediaDuration:Number.isFinite(i)&&(n=i),t==null||n===null){s.setAttribute("aria-valuetext",fS);return}const r=s.hasAttribute(bi.REMAINING),a=s.hasAttribute(bi.SHOW_DURATION),o=br(r?0-(n-t):t);if(!a){s.setAttribute("aria-valuetext",o);return}const d=br(n),l=`${o} of ${d}`;s.setAttribute("aria-valuetext",l)};class gS extends Qr{constructor(){super(),cS(this,yn,void 0),uS(this,yn,this.shadowRoot.querySelector("slot")),Jl(this,yn).innerHTML=`${Qh(this)}`}static get observedAttributes(){return[...super.observedAttributes,...jh,"disabled"]}connectedCallback(){const{style:e}=At(this.shadowRoot,":host(:hover:not([notoggle]))");e.setProperty("cursor","pointer"),e.setProperty("background","var(--media-control-hover-background, rgba(50 50 70 / .7))"),this.hasAttribute("disabled")||this.enable(),this.setAttribute("role","progressbar"),this.setAttribute("aria-label",ci.PLAYBACK_TIME());const t=i=>{const{key:n}=i;if(!Xh.includes(n)){this.removeEventListener("keyup",t);return}this.toggleTimeDisplay()};this.addEventListener("keydown",i=>{const{metaKey:n,altKey:r,key:a}=i;if(n||r||!Xh.includes(a)){this.removeEventListener("keyup",t);return}this.addEventListener("keyup",t)}),this.addEventListener("click",this.toggleTimeDisplay),super.connectedCallback()}toggleTimeDisplay(){this.noToggle||(this.hasAttribute("remaining")?this.removeAttribute("remaining"):this.setAttribute("remaining",""))}disconnectedCallback(){this.disable(),super.disconnectedCallback()}attributeChangedCallback(e,t,i){jh.includes(e)?this.update():e==="disabled"&&i!==t&&(i==null?this.enable():this.disable()),super.attributeChangedCallback(e,t,i)}enable(){this.tabIndex=0}disable(){this.tabIndex=-1}get remaining(){return Ft(this,bi.REMAINING)}set remaining(e){$t(this,bi.REMAINING,e)}get showDuration(){return Ft(this,bi.SHOW_DURATION)}set showDuration(e){$t(this,bi.SHOW_DURATION,e)}get noToggle(){return Ft(this,bi.NO_TOGGLE)}set noToggle(e){$t(this,bi.NO_TOGGLE,e)}get mediaDuration(){return Tt(this,x.MEDIA_DURATION)}set mediaDuration(e){Kt(this,x.MEDIA_DURATION,e)}get mediaCurrentTime(){return Tt(this,x.MEDIA_CURRENT_TIME)}set mediaCurrentTime(e){Kt(this,x.MEDIA_CURRENT_TIME,e)}get mediaSeekable(){const e=this.getAttribute(x.MEDIA_SEEKABLE);if(e)return e.split(":").map(t=>+t)}set mediaSeekable(e){if(e==null){this.removeAttribute(x.MEDIA_SEEKABLE);return}this.setAttribute(x.MEDIA_SEEKABLE,e.join(":"))}update(){const e=Qh(this);mS(this),e!==Jl(this,yn).innerHTML&&(Jl(this,yn).innerHTML=e)}}yn=new WeakMap;B.customElements.get("media-time-display")||B.customElements.define("media-time-display",gS);var Sp=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},wt=(s,e,t)=>(Sp(s,e,"read from private field"),e.get(s)),Li=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},si=(s,e,t,i)=>(Sp(s,e,"write to private field"),e.set(s,t),t),pS=(s,e,t,i)=>({set _(n){si(s,e,n)},get _(){return wt(s,e)}}),Tn,Ao,bn,Er,Io,xo,Lo,_n,Bs,Ro;class vS{constructor(e,t,i){Li(this,Tn,void 0),Li(this,Ao,void 0),Li(this,bn,void 0),Li(this,Er,void 0),Li(this,Io,void 0),Li(this,xo,void 0),Li(this,Lo,void 0),Li(this,_n,void 0),Li(this,Bs,0),Li(this,Ro,(n=performance.now())=>{si(this,Bs,requestAnimationFrame(wt(this,Ro))),si(this,Er,performance.now()-wt(this,bn));const r=1e3/this.fps;if(wt(this,Er)>r){si(this,bn,n-wt(this,Er)%r);const a=1e3/((n-wt(this,Ao))/++pS(this,Io)._),o=(n-wt(this,xo))/1e3/this.duration;let d=wt(this,Lo)+o*this.playbackRate;d-wt(this,Tn).valueAsNumber>0?si(this,_n,this.playbackRate/this.duration/a):(si(this,_n,.995*wt(this,_n)),d=wt(this,Tn).valueAsNumber+wt(this,_n)),this.callback(d)}}),si(this,Tn,e),this.callback=t,this.fps=i}start(){wt(this,Bs)===0&&(si(this,bn,performance.now()),si(this,Ao,wt(this,bn)),si(this,Io,0),wt(this,Ro).call(this))}stop(){wt(this,Bs)!==0&&(cancelAnimationFrame(wt(this,Bs)),si(this,Bs,0))}update({start:e,duration:t,playbackRate:i}){const n=e-wt(this,Tn).valueAsNumber,r=Math.abs(t-this.duration);(n>0||n<-.03||r>=.5)&&this.callback(e),si(this,Lo,e),si(this,xo,performance.now()),this.duration=t,this.playbackRate=i}}Tn=new WeakMap;Ao=new WeakMap;bn=new WeakMap;Er=new WeakMap;Io=new WeakMap;xo=new WeakMap;Lo=new WeakMap;_n=new WeakMap;Bs=new WeakMap;Ro=new WeakMap;var _u=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},Lt=(s,e,t)=>(_u(s,e,"read from private field"),t?t.call(s):e.get(s)),Dt=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},Ni=(s,e,t,i)=>(_u(s,e,"write to private field"),e.set(s,t),t),Ht=(s,e,t)=>(_u(s,e,"access private method"),t),Sn,zs,tl,Lr,il,ko,Ur,Br,An,In,yr,Su,Ap,pc,sl,Au,nl,Iu,rl,xu,vc,Ip,Gr,al,Ec,xp;const ES="video not loaded, unknown time.",yS=s=>{const e=s.range,t=br(+Rp(s)),i=br(+s.mediaSeekableEnd),n=t&&i?`${t} of ${i}`:ES;e.setAttribute("aria-valuetext",n)},Lp=ke.createElement("template");Lp.innerHTML=` 1233 <style> 1234 :host { 1235 --media-box-border-radius: 4px; 1236 --media-box-padding-left: 10px; 1237 --media-box-padding-right: 10px; 1238 --media-preview-border-radius: var(--media-box-border-radius); 1239 --media-box-arrow-offset: var(--media-box-border-radius); 1240 --_control-background: var(--media-control-background, var(--media-secondary-color, rgb(20 20 30 / .7))); 1241 --_preview-background: var(--media-preview-background, var(--_control-background)); 1242 1243 1244 contain: layout; 1245 } 1246 1247 #highlight { 1248 background: var(--media-time-range-buffered-color, rgb(255 255 255 / .4)); 1249 } 1250 1251 #preview-rail, 1252 #current-rail { 1253 width: 100%; 1254 position: absolute; 1255 left: 0; 1256 bottom: 100%; 1257 pointer-events: none; 1258 will-change: transform; 1259 } 1260 1261 [part~="box"] { 1262 width: min-content; 1263 1264 position: absolute; 1265 bottom: 100%; 1266 flex-direction: column; 1267 align-items: center; 1268 transform: translateX(-50%); 1269 } 1270 1271 [part~="current-box"] { 1272 display: var(--media-current-box-display, var(--media-box-display, flex)); 1273 margin: var(--media-current-box-margin, var(--media-box-margin, 0 0 5px)); 1274 visibility: hidden; 1275 } 1276 1277 [part~="preview-box"] { 1278 display: var(--media-preview-box-display, var(--media-box-display, flex)); 1279 margin: var(--media-preview-box-margin, var(--media-box-margin, 0 0 5px)); 1280 transition-property: var(--media-preview-transition-property, visibility, opacity); 1281 transition-duration: var(--media-preview-transition-duration-out, .25s); 1282 transition-delay: var(--media-preview-transition-delay-out, 0s); 1283 visibility: hidden; 1284 opacity: 0; 1285 } 1286 1287 :host(:is([${x.MEDIA_PREVIEW_IMAGE}], [${x.MEDIA_PREVIEW_TIME}])[dragging]) [part~="preview-box"] { 1288 transition-duration: var(--media-preview-transition-duration-in, .5s); 1289 transition-delay: var(--media-preview-transition-delay-in, .25s); 1290 visibility: visible; 1291 opacity: 1; 1292 } 1293 1294 @media (hover: hover) { 1295 :host(:is([${x.MEDIA_PREVIEW_IMAGE}], [${x.MEDIA_PREVIEW_TIME}]):hover) [part~="preview-box"] { 1296 transition-duration: var(--media-preview-transition-duration-in, .5s); 1297 transition-delay: var(--media-preview-transition-delay-in, .25s); 1298 visibility: visible; 1299 opacity: 1; 1300 } 1301 } 1302
1303 media-preview-thumbnail, 1304 ::slotted(media-preview-thumbnail) { 1305 visibility: hidden; 1306 1307 transition: visibility 0s .25s; 1308 transition-delay: calc(var(--media-preview-transition-delay-out, 0s) + var(--media-preview-transition-duration-out, .25s)); 1309 background: var(--media-preview-thumbnail-background, var(--_preview-background)); 1310 box-shadow: var(--media-preview-thumbnail-box-shadow, 0 0 4px rgb(0 0 0 / .2)); 1311 max-width: var(--media-preview-thumbnail-max-width, 180px); 1312 max-height: var(--media-preview-thumbnail-max-height, 160px); 1313 min-width: var(--media-preview-thumbnail-min-width, 120px); 1314 min-height: var(--media-preview-thumbnail-min-height, 80px); 1315 border: var(--media-preview-thumbnail-border); 1316 border-radius: var(--media-preview-thumbnail-border-radius, 1317 var(--media-preview-border-radius) var(--media-preview-border-radius) 0 0); 1318 } 1319 1320 :host([${x.MEDIA_PREVIEW_IMAGE}][dragging]) media-preview-thumbnail, 1321 :host([${x.MEDIA_PREVIEW_IMAGE}][dragging]) ::slotted(media-preview-thumbnail) { 1322 transition-delay: var(--media-preview-transition-delay-in, .25s); 1323 visibility: visible; 1324 } 1325 1326 @media (hover: hover) { 1327 :host([${x.MEDIA_PREVIEW_IMAGE}]:hover) media-preview-thumbnail, 1328 :host([${x.MEDIA_PREVIEW_IMAGE}]:hover) ::slotted(media-preview-thumbnail) { 1329 transition-delay: var(--media-preview-transition-delay-in, .25s); 1330 visibility: visible; 1331 } 1332 1333 :host([${x.MEDIA_PREVIEW_TIME}]:hover) { 1334 --media-time-range-hover-display: block; 1335 } 1336 } 1337 1338 media-preview-chapter-display, 1339 ::slotted(media-preview-chapter-display) { 1340 font-size: var(--media-font-size, 13px); 1341 line-height: 17px; 1342 min-width: 0; 1343 visibility: hidden; 1344 1345 transition: min-width 0s, border-radius 0s, margin 0s, padding 0s, visibility 0s; 1346 transition-delay: calc(var(--media-preview-transition-delay-out, 0s) + var(--media-preview-transition-duration-out, .25s)); 1347 background: var(--media-preview-chapter-background, var(--_preview-background)); 1348 border-radius: var(--media-preview-chapter-border-radius, 1349 var(--media-preview-border-radius) var(--media-preview-border-radius) 1350 var(--media-preview-border-radius) var(--media-preview-border-radius)); 1351 padding: var(--media-preview-chapter-padding, 3.5px 9px); 1352 margin: var(--media-preview-chapter-margin, 0 0 5px); 1353 text-shadow: var(--media-preview-chapter-text-shadow, 0 0 4px rgb(0 0 0 / .75)); 1354 } 1355 1356 :host([${x.MEDIA_PREVIEW_IMAGE}]) media-preview-chapter-display, 1357 :host([${x.MEDIA_PREVIEW_IMAGE}]) ::slotted(media-preview-chapter-display) { 1358 transition-delay: var(--media-preview-transition-delay-in, .25s); 1359 border-radius: var(--media-preview-chapter-border-radius, 0); 1360 padding: var(--media-preview-chapter-padding, 3.5px 9px 0); 1361 margin: var(--media-preview-chapter-margin, 0); 1362 min-width: 100%; 1363 } 1364 1365 media-preview-chapter-display[${x.MEDIA_PREVIEW_CHAPTER}], 1366 ::slotted(media-preview-chapter-display[${x.MEDIA_PREVIEW_CHAPTER}]) { 1367 visibility: visible; 1368 } 1369 1370 media-preview-chapter-display:not([aria-valuetext]), 1371 ::slotted(media-preview-chapter-display:not([aria-valuetext])) { 1372 display: none; 1373 } 1374 1375 media-preview-time-display, 1376 ::slotted(media-preview-time-display), 1377 media-time-display, 1378 ::slotted(media-time-display) { 1379 font-size: var(--media-font-size, 13px); 1380 line-height: 17px; 1381 min-width: 0; 1382 1383 transition: min-width 0s, border-radius 0s; 1384 transition-delay: calc(var(--media-preview-transition-delay-out, 0s) + var(--media-preview-transition-duration-out, .25s)); 1385 background: var(--media-preview-time-background, var(--_preview-background)); 1386 border-radius: var(--media-preview-time-border-radius, 1387 var(--media-preview-border-radius) var(--media-preview-border-radius) 1388 var(--media-preview-border-radius) var(--media-preview-border-radius)); 1389 padding: var(--media-preview-time-padding, 3.5px 9px); 1390 margin: var(--media-preview-time-margin, 0); 1391 text-shadow: var(--media-preview-time-text-shadow, 0 0 4px rgb(0 0 0 / .75)); 1392 transform: translateX(min( 1393 max(calc(50% - var(--_box-width) / 2), 1394 calc(var(--_box-shift, 0))), 1395 calc(var(--_box-width) / 2 - 50%) 1396 )); 1397 } 1398 1399 :host([${x.MEDIA_PREVIEW_IMAGE}]) media-preview-time-display, 1400 :host([${x.MEDIA_PREVIEW_IMAGE}]) ::slotted(media-preview-time-display) { 1401 transition-delay: var(--media-preview-transition-delay-in, .25s); 1402 border-radius: var(--media-preview-time-border-radius, 1403 0 0 var(--media-preview-border-radius) var(--media-preview-border-radius)); 1404 min-width: 100%; 1405 } 1406 1407 :host([${x.MEDIA_PREVIEW_TIME}]:hover) { 1408 --media-time-range-hover-display: block; 1409 } 1410 1411 [part~="arrow"], 1412 ::slotted([part~="arrow"]) { 1413 display: var(--media-box-arrow-display, inline-block); 1414 transform: translateX(min( 1415 max(calc(50% - var(--_box-width) / 2 + var(--media-box-arrow-offset)), 1416 calc(var(--_box-shift, 0))), 1417 calc(var(--_box-width) / 2 - 50% - var(--media-box-arrow-offset)) 1418 )); 1419 1420 border-color: transparent; 1421 border-top-color: var(--media-box-arrow-background, var(--_control-background)); 1422 border-width: var(--media-box-arrow-border-width, 1423 var(--media-box-arrow-height, 5px) var(--media-box-arrow-width, 6px) 0); 1424 border-style: solid; 1425 justify-content: center; 1426 height: 0; 1427 } 1428 </style> 1429 <div id="preview-rail"> 1430 <slot name="preview" part="box preview-box">
1431 <media-preview-thumbnail></media-preview-thumbnail> 1432 <media-preview-chapter-display></media-preview-chapter-display> 1433 <media-preview-time-display></media-preview-time-display> 1434 <slot name="preview-arrow"><div part="arrow"></div></slot> 1435 </slot> 1436 </div> 1437 <div id="current-rail"> 1438 <slot name="current" part="box current-box"> 1439 1440 </slot> 1441 </div> 1442`;const La=(s,e=s.mediaCurrentTime)=>{const t=Number.isFinite(s.mediaSeekableStart)?s.mediaSeekableStart:0,i=Number.isFinite(s.mediaDuration)?s.mediaDuration:s.mediaSeekableEnd;if(Number.isNaN(i))return 0;const n=(e-t)/(i-t);return Math.max(0,Math.min(n,1))},Rp=(s,e=s.range.valueAsNumber)=>{const t=Number.isFinite(s.mediaSeekableStart)?s.mediaSeekableStart:0,i=Number.isFinite(s.mediaDuration)?s.mediaDuration:s.mediaSeekableEnd;return Number.isNaN(i)?0:e*(i-t)+t};class TS extends Tu{constructor(){super(),Dt(this,In),Dt(this,Su),Dt(this,sl),Dt(this,nl),Dt(this,rl),Dt(this,vc),Dt(this,Gr),Dt(this,Ec),Dt(this,Sn,void 0),Dt(this,zs,void 0),Dt(this,tl,void 0),Dt(this,Lr,void 0),Dt(this,il,void 0),Dt(this,ko,void 0),Dt(this,Ur,void 0),Dt(this,Br,void 0),Dt(this,An,void 0),Dt(this,pc,t=>{this.dragging||(this.range.valueAsNumber=t,this.updateBar())}),this.container.appendChild(Lp.content.cloneNode(!0)),Ni(this,tl,this.shadowRoot.querySelectorAll('[part~="box"]')),Ni(this,il,this.shadowRoot.querySelector('[part~="preview-box"]')),Ni(this,ko,this.shadowRoot.querySelector('[part~="current-box"]'));const e=getComputedStyle(this);Ni(this,Ur,parseInt(e.getPropertyValue("--media-box-padding-left"))),Ni(this,Br,parseInt(e.getPropertyValue("--media-box-padding-right"))),Ni(this,zs,new vS(this.range,Lt(this,pc),60))}static get observedAttributes(){return[...super.observedAttributes,x.MEDIA_PAUSED,x.MEDIA_DURATION,x.MEDIA_SEEKABLE,x.MEDIA_CURRENT_TIME,x.MEDIA_PREVIEW_IMAGE,x.MEDIA_PREVIEW_TIME,x.MEDIA_PREVIEW_CHAPTER,x.MEDIA_BUFFERED,x.MEDIA_PLAYBACK_RATE,x.MEDIA_LOADING,x.MEDIA_ENDED]}connectedCallback(){var e;super.connectedCallback(),this.range.setAttribute("aria-label",ci.SEEK()),Ht(this,In,yr).call(this),Ni(this,Sn,this.getRootNode()),(e=Lt(this,Sn))==null||e.addEventListener("transitionstart",this)}disconnectedCallback(){var e;super.disconnectedCallback(),Ht(this,In,yr).call(this),(e=Lt(this,Sn))==null||e.removeEventListener("transitionstart",this),Ni(this,Sn,null)}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),t!=i&&(e===x.MEDIA_CURRENT_TIME||e===x.MEDIA_PAUSED||e===x.MEDIA_ENDED||e===x.MEDIA_LOADING||e===x.MEDIA_DURATION||e===x.MEDIA_SEEKABLE?(Lt(this,zs).update({start:La(this),duration:this.mediaSeekableEnd-this.mediaSeekableStart,playbackRate:this.mediaPlaybackRate}),Ht(this,In,yr).call(this),yS(this)):e===x.MEDIA_BUFFERED&&this.updateBufferedBar(),(e===x.MEDIA_DURATION||e===x.MEDIA_SEEKABLE)&&(this.mediaChaptersCues=Lt(this,An),this.updateBar()))}get mediaChaptersCues(){return Lt(this,An)}set mediaChaptersCues(e){var t;Ni(this,An,e),this.updateSegments((t=Lt(this,An))==null?void 0:t.map(i=>({start:La(this,i.startTime),end:La(this,i.endTime)})))}get mediaPaused(){return Ft(this,x.MEDIA_PAUSED)}set mediaPaused(e){$t(this,x.MEDIA_PAUSED,e)}get mediaLoading(){return Ft(this,x.MEDIA_LOADING)}set mediaLoading(e){$t(this,x.MEDIA_LOADING,e)}get mediaDuration(){return Tt(this,x.MEDIA_DURATION)}set mediaDuration(e){Kt(this,x.MEDIA_DURATION,e)}get mediaCurrentTime(){return Tt(this,x.MEDIA_CURRENT_TIME)}set mediaCurrentTime(e){Kt(this,x.MEDIA_CURRENT_TIME,e)}get mediaPlaybackRate(){return Tt(this,x.MEDIA_PLAYBACK_RATE,1)}set mediaPlaybackRate(e){Kt(this,x.MEDIA_PLAYBACK_RATE,e)}get mediaBuffered(){const e=this.getAttribute(x.MEDIA_BUFFERED);return e?e.split(" ").map(t=>t.split(":").map(i=>+i)):[]}set mediaBuffered(e){if(!e){this.removeAttribute(x.MEDIA_BUFFERED);return}const t=e.map(i=>i.join(":")).join(" ");this.setAttribute(x.MEDIA_BUFFERED,t)}get mediaSeekable(){const e=this.getAttribute(x.MEDIA_SEEKABLE);if(e)return e.split(":").map(t=>+t)}set mediaSeekable(e){if(e==null){this.removeAttribute(x.MEDIA_SEEKABLE);return}this.setAttribute(x.MEDIA_SEEKABLE,e.join(":"))}get mediaSeekableEnd(){var e;const[,t=this.mediaDuration]=(e=this.mediaSeekable)!=null?e:[];return t}get mediaSeekableStart(){var e;const[t=0]=(e=this.mediaSeekable)!=null?e:[];return t}get mediaPreviewImage(){return Wt(this,x.MEDIA_PREVIEW_IMAGE)}set mediaPreviewImage(e){qt(this,x.MEDIA_PREVIEW_IMAGE,e)}get mediaPreviewTime(){return Tt(this,x.MEDIA_PREVIEW_TIME)}set mediaPreviewTime(e){Kt(this,x.MEDIA_PREVIEW_TIME,e)}get mediaEnded(){return Ft(this,x.MEDIA_ENDED)}set mediaEnded(e){$t(this,x.MEDIA_ENDED,e)}updateBar(){super.updateBar(),this.updateBufferedBar(),this.updateCurrentBox()}updateBufferedBar(){var e;const t=this.mediaBuffered;if(!t.length)return;let i;if(this.mediaEnded)i=1;else{const r=this.mediaCurrentTime,[,a=this.mediaSeekableStart]=(e=t.find(([o,d])=>o<=r&&r<=d))!=null?e:[];i=La(this,a)}const{style:n}=At(this.shadowRoot,"#highlight");n.setProperty("width",`${i*100}%`)}updateCurrentBox(){if(!this.shadowRoot.querySelector('slot[name="current"]').assignedElements().length)return;const t=At(this.shadowRoot,"#current-rail"),i=At(this.shadowRoot,'[part~="current-box"]'),n=Ht(this,sl,Au).call(this,Lt(this,ko)),r=Ht(this,nl,Iu).call(this,n,this.range.valueAsNumber),a=Ht(this,rl,xu).call(this,n,this.range.valueAsNumber);t.style.transform=`translateX(${r})`,t.style.setProperty("--_range-width",`${n.range.width}`),i.style.setProperty("--_box-shift",`${a}`),i.style.setProperty("--_box-width",`${n.box.width}px`),i.style.setProperty("visibility","initial")}handleEvent(e){switch(super.handleEvent(e),e.type){case"input":Ht(this,Ec,xp).call(this);break;case"pointermove":Ht(this,vc,Ip).call(this,e);break;case"pointerup":case"pointerleave":Ht(this,Gr,al).call(this,null);break;case"transitionstart":ls(e.target,this)&&setTimeout(()=>
1442Ht(this,In,yr).call(this),0);break}}}Sn=new WeakMap;zs=new WeakMap;tl=new WeakMap;Lr=new WeakMap;il=new WeakMap;ko=new WeakMap;Ur=new WeakMap;Br=new WeakMap;An=new WeakMap;In=new WeakSet;yr=function(){Ht(this,Su,Ap).call(this)?Lt(this,zs).start():Lt(this,zs).stop()};Su=new WeakSet;Ap=function(){return this.isConnected&&!this.mediaPaused&&!this.mediaLoading&&!this.mediaEnded&&this.mediaSeekableEnd>0&&DT(this)};pc=new WeakMap;sl=new WeakSet;Au=function(s){var e;const i=((e=this.getAttribute("bounds")?Xr(this,`#${this.getAttribute("bounds")}`):this.parentElement)!=null?e:this).getBoundingClientRect(),n=this.range.getBoundingClientRect(),r=s.offsetWidth,a=-(n.left-i.left-r/2),o=i.right-n.left-r/2;return{box:{width:r,min:a,max:o},bounds:i,range:n}};nl=new WeakSet;Iu=function(s,e){let t=`${e*100}%`;const{width:i,min:n,max:r}=s.box;if(!i)return t;if(Number.isNaN(n)||(t=`max(${`calc(1 / var(--_range-width) * 100 * ${n}% + var(--media-box-padding-left))`}, ${t})`),!Number.isNaN(r)){const o=`calc(1 / var(--_range-width) * 100 * ${r}% - var(--media-box-padding-right))`;t=`min(${t}, ${o})`}return t};rl=new WeakSet;xu=function(s,e){const{width:t,min:i,max:n}=s.box,r=e*s.range.width;if(r<i+Lt(this,Ur)){const a=s.range.left-s.bounds.left-Lt(this,Ur);return`${r-t/2+a}px`}if(r>n-Lt(this,Br)){const a=s.bounds.right-s.range.right-Lt(this,Br);return`${r+t/2-a-s.range.width}px`}return 0};vc=new WeakSet;Ip=function(s){const e=[...Lt(this,tl)].some(c=>s.composedPath().includes(c));if(!this.dragging&&(e||!s.composedPath().includes(this))){Ht(this,Gr,al).call(this,null);return}const t=this.mediaSeekableEnd;if(!t)return;const i=At(this.shadowRoot,"#preview-rail"),n=At(this.shadowRoot,'[part~="preview-box"]'),r=Ht(this,sl,Au).call(this,Lt(this,il));let a=(s.clientX-r.range.left)/r.range.width;a=Math.max(0,Math.min(1,a));const o=Ht(this,nl,Iu).call(this,r,a),d=Ht(this,rl,xu).call(this,r,a);i.style.transform=`translateX(${o})`,i.style.setProperty("--_range-width",`${r.range.width}`),n.style.setProperty("--_box-shift",`${d}`),n.style.setProperty("--_box-width",`${r.box.width}px`);const l=Math.round(Lt(this,Lr))-Math.round(a*t);Math.abs(l)<1&&a>.01&&a<.99||(Ni(this,Lr,a*t),Ht(this,Gr,al).call(this,Lt(this,Lr)))};Gr=new WeakSet;al=function(s){this.dispatchEvent(new B.CustomEvent(Ee.MEDIA_PREVIEW_REQUEST,{composed:!0,bubbles:!0,detail:s}))};Ec=new WeakSet;xp=function(){Lt(this,zs).stop();const s=Rp(this);this.dispatchEvent(new B.CustomEvent(Ee.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:s}))};B.customElements.get("media-time-range")||B.customElements.define("media-time-range",TS);const bS=1,_S=s=>s.mediaMuted?0:s.mediaVolume,SS=({value:s})=>`${Math.round(s*100)}%`;class AS extends Tu{static get observedAttributes(){return[...super.observedAttributes,x.MEDIA_VOLUME,x.MEDIA_MUTED,x.MEDIA_VOLUME_UNAVAILABLE]}constructor(){super(),this.range.addEventListener("input",()=>{const e=this.range.value,t=new B.CustomEvent(Ee.MEDIA_VOLUME_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)})}connectedCallback(){super.connectedCallback(),this.range.setAttribute("aria-label",ci.VOLUME())}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),(e===x.MEDIA_VOLUME||e===x.MEDIA_MUTED)&&(this.range.valueAsNumber=_S(this),this.range.setAttribute("aria-valuetext",SS(this.range)),this.updateBar())}get mediaVolume(){return Tt(this,x.MEDIA_VOLUME,bS)}set mediaVolume(e){Kt(this,x.MEDIA_VOLUME,e)}get mediaMuted(){return Ft(this,x.MEDIA_MUTED)}set mediaMuted(e){$t(this,x.MEDIA_MUTED,e)}get mediaVolumeUnavailable(){return Wt(this,x.MEDIA_VOLUME_UNAVAILABLE)}set mediaVolumeUnavailable(e){qt(this,x.MEDIA_VOLUME_UNAVAILABLE,e)}}B.customElements.get("media-volume-range")||B.customElements.define("media-volume-range",AS);const IS=["abort","canplay","canplaythrough","durationchange","emptied","encrypted","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting","waitingforkey","resize","enterpictureinpicture","leavepictureinpicture","webkitbeginfullscreen","webkitendfullscreen","webkitpresentationmodechanged"],kp=["autopictureinpicture","disablepictureinpicture","disableremoteplayback","autoplay","controls","controlslist","crossorigin","loop","muted","playsinline","poster","preload","src"];function xS(s){return` 1443 <style> 1444 :host { 1445 display: inline-flex; 1446 line-height: 0; 1447 flex-direction: column; 1448 justify-content: end; 1449 } 1450 1451 audio { 1452 width: 100%; 1453 } 1454 </style> 1455 <slot name="media"> 1456 <audio${Cp(s)}></audio> 1457 </slot> 1458 <slot></slot> 1459 `}function LS(s){return` 1460 <style> 1461 :host { 1462 display: inline-block; 1463 line-height: 0; 1464 } 1465 1466 video { 1467 max-width: 100%; 1468 max-height: 100%; 1469 min-width: 100%; 1470 min-height: 100%; 1471 object-fit: var(--media-object-fit, contain); 1472 object-position: var(--media-object-position, 50% 50%); 1473 } 1474 1475 video::-webkit-media-text-track-container { 1476 transform: var(--media-webkit-text-track-transform); 1477 transition: var(--media-webkit-text-track-transition); 1478 } 1479 </style> 1480 <slot name="media"> 1481 <video${Cp(s)}></video> 1482 </slot> 1483 <slot></slot> 1484 `}function Dp(s,{tag:e,is:t}){const i=globalThis.document?.createElement?.(e,{is:t}),n=i?RS(i):[];return class yc extends s{static getTemplateHTML=e.endsWith("audio")?xS:LS;static shadowRootOptions={mode:"open"};static Events=IS;static#e=!1;static get observedAttributes(){return yc.#t(),[...i?.constructor?.observedAttributes??[],...kp]}
1484static#t(){if(this.#e)return;this.#e=!0;const a=new Set(this.observedAttributes);a.delete("muted");for(const o of n)if(!(o in this.prototype))if(typeof i[o]=="function")this.prototype[o]=function(...d){return this.#r(),this.call?this.call(o,...d):this.nativeEl?.[o]?.apply(this.nativeEl,d)};else{const d={get(){this.#r();const l=o.toLowerCase();if(a.has(l)){const c=this.getAttribute(l);return c===null?!1:c===""?!0:c}return this.get?.(o)??this.nativeEl?.[o]}};o!==o.toUpperCase()&&(d.set=function(l){this.#r();const c=o.toLowerCase();if(a.has(c)){l===!0||l===!1||l==null?this.toggleAttribute(c,!!l):this.setAttribute(c,l);return}if(this.set){this.set(o,l);return}this.nativeEl&&(this.nativeEl[o]=l)}),Object.defineProperty(this.prototype,o,d)}}#i=!1;#s=null;#n=new Map;#a;get;set;call;get nativeEl(){return this.#r(),this.#s??this.querySelector(":scope > [slot=media]")??this.querySelector(e)??this.shadowRoot?.querySelector(e)??null}set nativeEl(a){this.#s=a}get defaultMuted(){return this.hasAttribute("muted")}set defaultMuted(a){this.toggleAttribute("muted",a)}get src(){return this.getAttribute("src")}set src(a){this.setAttribute("src",`${a}`)}get preload(){return this.getAttribute("preload")??this.nativeEl?.preload}set preload(a){this.setAttribute("preload",`${a}`)}#r(){this.#i||(this.#i=!0,this.init())}init(){if(!this.shadowRoot){this.attachShadow({mode:"open"});const a=kS(this.attributes);t&&(a.is=t),e&&(a.part=e),this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(a)}this.nativeEl.muted=this.hasAttribute("muted");for(const a of n)this.#c(a);this.#a=new MutationObserver(this.#d.bind(this)),this.shadowRoot.addEventListener("slotchange",()=>this.#o()),this.#o();for(const a of this.constructor.Events)this.shadowRoot.addEventListener(a,this,!0)}handleEvent(a){a.target===this.nativeEl&&this.dispatchEvent(new CustomEvent(a.type,{detail:a.detail}))}#o(){const a=new Map(this.#n);(this.shadowRoot?.querySelector("slot:not([name])")?.assignedElements({flatten:!0}).filter(l=>["track","source"].includes(l.localName))).forEach(l=>{a.delete(l);let c=this.#n.get(l);c||(c=l.cloneNode(),this.#n.set(l,c),this.#a?.observe(l,{attributes:!0})),this.nativeEl?.append(c),this.#l(c)}),a.forEach((l,c)=>{l.remove(),this.#n.delete(c)})}#d(a){for(const o of a)if(o.type==="attributes"){const{target:d,attributeName:l}=o,c=this.#n.get(d);c&&l&&(c.setAttribute(l,d.getAttribute(l)??""),this.#l(c))}}#l(a){a&&a.localName==="track"&&a.default&&(a.kind==="chapters"||a.kind==="metadata")&&a.track.mode==="disabled"&&(a.track.mode="hidden")}#c(a){if(Object.prototype.hasOwnProperty.call(this,a)){const o=this[a];delete this[a],this[a]=o}}attributeChangedCallback(a,o,d){this.#r(),this.#u(a,o,d)}#u(a,o,d){["id","class"].includes(a)||!yc.observedAttributes.includes(a)&&this.constructor.observedAttributes.includes(a)||(d===null?this.nativeEl?.removeAttribute(a):this.nativeEl?.getAttribute(a)!==d&&this.nativeEl?.setAttribute(a,d))}connectedCallback(){this.#r()}}}function RS(s){const e=[];for(let t=Object.getPrototypeOf(s);t&&t!==HTMLElement.prototype;t=Object.getPrototypeOf(t)){const i=Object.getOwnPropertyNames(t);e.push(...i)}return e}function Cp(s){let e="";for(const t in s){if(!kp.includes(t))continue;const i=s[t];i===""?e+=` ${t}`:e+=` ${t}="${i}"`}return e}function kS(s){const e={};for(const t of s)e[t.name]=t.value;return e}const DS=Dp(globalThis.HTMLElement??class{},{tag:"video"});Dp(globalThis.HTMLElement??class{},{tag:"audio"});class kl extends Event{track;constructor(e,t){super(e),this.track=t.track}}const Tc=new WeakMap;function pe(s){return Tc.get(s)??CS(s,{})}function CS(s,e){let t=Tc.get(s);return t||Tc.set(s,t={}),Object.assign(t,e)}function bc(s,e){const t=s.videoTracks;pe(e).media=s,pe(e).renditionSet||(pe(e).renditionSet=new Set);const i=pe(t).trackSet;i.add(e);const n=i.size-1;n in Sc.prototype||Object.defineProperty(Sc.prototype,n,{get(){return[...pe(this).trackSet][n]}}),queueMicrotask(()=>{t.dispatchEvent(new kl("addtrack",{track:e}))})}function _c(s){const e=pe(s).media?.videoTracks;if(!e)return;pe(e).trackSet.delete(s),queueMicrotask(()=>{e.dispatchEvent(new kl("removetrack",{track:s}))})}function wS(s){const e=pe(s).media.videoTracks??[];let t=!1;for(const i of e)i!==s&&(i.selected=!1,t=!0);if(t){if(pe(e).changeRequested)return;pe(e).changeRequested=!0,queueMicrotask(()=>{delete pe(e).changeRequested,e.dispatchEvent(new Event("change"))})}}
1484class Sc extends EventTarget{#e;#t;#i;constructor(){super(),pe(this).trackSet=new Set}get#s(){return pe(this).trackSet}[Symbol.iterator](){return this.#s.values()}get length(){return this.#s.size}getTrackById(e){return[...this.#s].find(t=>t.id===e)??null}get selectedIndex(){return[...this.#s].findIndex(e=>e.selected)}get onaddtrack(){return this.#e}set onaddtrack(e){this.#e&&(this.removeEventListener("addtrack",this.#e),this.#e=void 0),typeof e=="function"&&(this.#e=e,this.addEventListener("addtrack",e))}get onremovetrack(){return this.#t}set onremovetrack(e){this.#t&&(this.removeEventListener("removetrack",this.#t),this.#t=void 0),typeof e=="function"&&(this.#t=e,this.addEventListener("removetrack",e))}get onchange(){return this.#i}set onchange(e){this.#i&&(this.removeEventListener("change",this.#i),this.#i=void 0),typeof e=="function"&&(this.#i=e,this.addEventListener("change",e))}}class Dl extends Event{rendition;constructor(e,t){super(e),this.rendition=t.rendition}}function PS(s,e){const t=pe(s).media.videoRenditions;pe(e).media=pe(s).media,pe(e).track=s;const i=pe(s).renditionSet;i.add(e);const n=i.size-1;n in Ac.prototype||Object.defineProperty(Ac.prototype,n,{get(){return xn(this)[n]}}),queueMicrotask(()=>{s.selected&&t.dispatchEvent(new Dl("addrendition",{rendition:e}))})}function MS(s){const e=pe(s).media.videoRenditions,t=pe(s).track;pe(t).renditionSet.delete(s),queueMicrotask(()=>{pe(s).track.selected&&e.dispatchEvent(new Dl("removerendition",{rendition:s}))})}function OS(s){const e=pe(s).media.videoRenditions;!e||pe(e).changeRequested||(pe(e).changeRequested=!0,queueMicrotask(()=>{delete pe(e).changeRequested,pe(s).track.selected&&e.dispatchEvent(new Event("change"))}))}function xn(s){return[...pe(s).media.videoTracks].filter(t=>t.selected).flatMap(t=>[...pe(t).renditionSet])}class Ac extends EventTarget{#e;#t;#i;[Symbol.iterator](){return xn(this).values()}get length(){return xn(this).length}getRenditionById(e){return xn(this).find(t=>`${t.id}`==`${e}`)??null}get selectedIndex(){return xn(this).findIndex(e=>e.selected)}set selectedIndex(e){for(const[t,i]of xn(this).entries())i.selected=t===e}get onaddrendition(){return this.#e}set onaddrendition(e){this.#e&&(this.removeEventListener("addrendition",this.#e),this.#e=void 0),typeof e=="function"&&(this.#e=e,this.addEventListener("addrendition",e))}get onremoverendition(){return this.#t}set onremoverendition(e){this.#t&&(this.removeEventListener("removerendition",this.#t),this.#t=void 0),typeof e=="function"&&(this.#t=e,this.addEventListener("removerendition",e))}get onchange(){return this.#i}set onchange(e){this.#i&&(this.removeEventListener("change",this.#i),this.#i=void 0),typeof e=="function"&&(this.#i=e,this.addEventListener("change",e))}}class FS{src;id;width;height;bitrate;frameRate;codec;#e=!1;get selected(){return this.#e}set selected(e){this.#e!==e&&(this.#e=e,OS(this))}}class wp{id;kind;label="";language="";sourceBuffer;#e=!1;addRendition(e,t,i,n,r,a){const o=new FS;return o.src=e,o.width=t,o.height=i,o.frameRate=a,o.bitrate=r,o.codec=n,PS(this,o),o}removeRendition(e){MS(e)}get selected(){return this.#e}set selected(e){this.#e!==e&&(this.#e=e,e===!0&&wS(this))}}function $S(s,e){const t=pe(s).media.audioRenditions;pe(e).media=pe(s).media,pe(e).track=s;const i=pe(s).renditionSet;i.add(e);const n=i.size-1;n in Ic.prototype||Object.defineProperty(Ic.prototype,n,{get(){return Ln(this)[n]}}),queueMicrotask(()=>{s.enabled&&t.dispatchEvent(new Dl("addrendition",{rendition:e}))})}function NS(s){const e=pe(s).media.audioRenditions,t=pe(s).track;pe(t).renditionSet.delete(s),queueMicrotask(()=>{pe(s).track.enabled&&e.dispatchEvent(new Dl("removerendition",{rendition:s}))})}function US(s){const e=pe(s).media.audioRenditions;!e||pe(e).changeRequested||(pe(e).changeRequested=!0,queueMicrotask(()=>{delete pe(e).changeRequested,pe(s).track.enabled&&e.dispatchEvent(new Event("change"))}))}function Ln(s){return[...pe(s).media.audioTracks].filter(t=>t.enabled).flatMap(t=>[...pe(t).renditionSet])}class Ic extends EventTarget{#e;#t;#i;[Symbol.iterator](){return Ln(this).values()}get length(){return Ln(this).length}getRenditionById(e){return Ln(this).find(t=>`${t.id}`==`${e}`)??null}get selectedIndex(){return Ln(this).findIndex(e=>e.selected)}set selectedIndex(e){for(const[t,i]of Ln(this).entries())i.selected=t===e}get onaddrendition(){return this.#e}set onaddrendition(e){this.#e&&(this.removeEventListener("addrendition",this.#e),this.#e=void 0),typeof e=="function"&&(this.#e=e,this.addEventListener("addrendition",e))}get onremoverendition(){return this.#t}set onremoverendition(e){this.#t&&(this.removeEventListener("removerendition",this.#t),this.#t=void 0),typeof e=="function"&&(this.#t=e,this.addEventListener("removerendition",e))}get onchange(){return this.#i}set onchange(e){this.#i&&(this.removeEventListener("change",this.#i),this.#i=void 0),typeof e=="function"&&(this.#i=e,this.addEventListener("change",e))}}class BS{src;id;bitrate;codec;#e=!1;get selected(){return this.#e}set selected(e){this.#e!==e&&(this.#e=e,US(this))}}function xc(s,e){const t=s.audioTracks;pe(e).media=s,pe(e).renditionSet||(pe(e).renditionSet=new Set);const i=pe(t).trackSet;i.add(e);const n=i.size-1;
1484n in Rc.prototype||Object.defineProperty(Rc.prototype,n,{get(){return[...pe(this).trackSet][n]}}),queueMicrotask(()=>{t.dispatchEvent(new kl("addtrack",{track:e}))})}function Lc(s){const e=pe(s).media?.audioTracks;if(!e)return;pe(e).trackSet.delete(s),queueMicrotask(()=>{e.dispatchEvent(new kl("removetrack",{track:s}))})}function GS(s){const e=pe(s).media.audioTracks;!e||pe(e).changeRequested||(pe(e).changeRequested=!0,queueMicrotask(()=>{delete pe(e).changeRequested,e.dispatchEvent(new Event("change"))}))}class Rc extends EventTarget{#e;#t;#i;constructor(){super(),pe(this).trackSet=new Set}get#s(){return pe(this).trackSet}[Symbol.iterator](){return this.#s.values()}get length(){return this.#s.size}getTrackById(e){return[...this.#s].find(t=>t.id===e)??null}get onaddtrack(){return this.#e}set onaddtrack(e){this.#e&&(this.removeEventListener("addtrack",this.#e),this.#e=void 0),typeof e=="function"&&(this.#e=e,this.addEventListener("addtrack",e))}get onremovetrack(){return this.#t}set onremovetrack(e){this.#t&&(this.removeEventListener("removetrack",this.#t),this.#t=void 0),typeof e=="function"&&(this.#t=e,this.addEventListener("removetrack",e))}get onchange(){return this.#i}set onchange(e){this.#i&&(this.removeEventListener("change",this.#i),this.#i=void 0),typeof e=="function"&&(this.#i=e,this.addEventListener("change",e))}}class Pp{id;kind;label="";language="";sourceBuffer;#e=!1;addRendition(e,t,i){const n=new BS;return n.src=e,n.codec=t,n.bitrate=i,$S(this,n),n}removeRendition(e){NS(e)}get enabled(){return this.#e}set enabled(e){this.#e!==e&&(this.#e=e,GS(this))}}const Zh=ol(globalThis.HTMLMediaElement,"video"),Jh=ol(globalThis.HTMLMediaElement,"audio");function KS(s){if(!s?.prototype)return s;const e=ol(s,"video");(!e||`${e}`.includes("[native code]"))&&Object.defineProperty(s.prototype,"videoTracks",{get(){return HS(this)}});const t=ol(s,"audio");(!t||`${t}`.includes("[native code]"))&&Object.defineProperty(s.prototype,"audioTracks",{get(){return VS(this)}}),"addVideoTrack"in s.prototype||(s.prototype.addVideoTrack=function(r,a="",o=""){const d=new wp;return d.kind=r,d.label=a,d.language=o,bc(this,d),d}),"removeVideoTrack"in s.prototype||(s.prototype.removeVideoTrack=_c),"addAudioTrack"in s.prototype||(s.prototype.addAudioTrack=function(r,a="",o=""){const d=new Pp;return d.kind=r,d.label=a,d.language=o,xc(this,d),d}),"removeAudioTrack"in s.prototype||(s.prototype.removeAudioTrack=Lc),"videoRenditions"in s.prototype||Object.defineProperty(s.prototype,"videoRenditions",{get(){return i(this)}});const i=r=>{let a=pe(r).videoRenditions;return a||(a=new Ac,pe(a).media=r,pe(r).videoRenditions=a),a};"audioRenditions"in s.prototype||Object.defineProperty(s.prototype,"audioRenditions",{get(){return n(this)}});const n=r=>{let a=pe(r).audioRenditions;return a||(a=new Ic,pe(a).media=r,pe(r).audioRenditions=a),a};return s}function ol(s,e){if(s?.prototype)return Object.getOwnPropertyDescriptor(s.prototype,`${e}Tracks`)?.get}function HS(s){let e=pe(s).videoTracks;if(!e&&(e=new Sc,pe(s).videoTracks=e,Zh)){const t=Zh.call(s.nativeEl??s);for(const i of t)bc(s,i);t.addEventListener("change",()=>{e.dispatchEvent(new Event("change"))}),t.addEventListener("addtrack",i=>{if([...e].some(n=>n instanceof wp)){for(const n of t)_c(n);return}bc(s,i.track)}),t.addEventListener("removetrack",i=>{_c(i.track)})}return e}function VS(s){let e=pe(s).audioTracks;
1484if(!e&&(e=new Rc,pe(s).audioTracks=e,Jh)){const t=Jh.call(s.nativeEl??s);for(const i of t)xc(s,i);t.addEventListener("change",()=>{e.dispatchEvent(new Event("change"))}),t.addEventListener("addtrack",i=>{if([...e].some(n=>n instanceof Pp)){for(const n of t)Lc(n);return}xc(s,i.track)}),t.addEventListener("removetrack",i=>{Lc(i.track)})}return e}const he=Number.isFinite||function(s){return typeof s=="number"&&isFinite(s)},WS=Number.isSafeInteger||function(s){return typeof s=="number"&&Math.abs(s)<=qS},qS=Number.MAX_SAFE_INTEGER||9007199254740991;let ye=(function(s){return s.NETWORK_ERROR="networkError",s.MEDIA_ERROR="mediaError",s.KEY_SYSTEM_ERROR="keySystemError",s.MUX_ERROR="muxError",s.OTHER_ERROR="otherError",s})({}),$=(function(s){return s.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",s.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",s.KEY_SYSTEM_NO_SESSION="keySystemNoSession",s.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",s.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",s.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",s.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",s.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",s.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",s.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",s.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR="keySystemDestroyMediaKeysError",s.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR="keySystemDestroyCloseSessionError",s.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR="keySystemDestroyRemoveSessionError",s.MANIFEST_LOAD_ERROR="manifestLoadError",s.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",s.MANIFEST_PARSING_ERROR="manifestParsingError",s.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",s.LEVEL_EMPTY_ERROR="levelEmptyError",s.LEVEL_LOAD_ERROR="levelLoadError",s.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",s.LEVEL_PARSING_ERROR="levelParsingError",s.LEVEL_SWITCH_ERROR="levelSwitchError",s.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",s.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",s.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",s.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",s.FRAG_LOAD_ERROR="fragLoadError",s.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",s.FRAG_DECRYPT_ERROR="fragDecryptError",s.FRAG_PARSING_ERROR="fragParsingError",s.FRAG_GAP="fragGap",s.REMUX_ALLOC_ERROR="remuxAllocError",s.KEY_LOAD_ERROR="keyLoadError",s.KEY_LOAD_TIMEOUT="keyLoadTimeOut",s.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",s.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",s.BUFFER_APPEND_ERROR="bufferAppendError",s.BUFFER_APPENDING_ERROR="bufferAppendingError",s.BUFFER_STALLED_ERROR="bufferStalledError",s.BUFFER_FULL_ERROR="bufferFullError",s.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",s.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",s.ASSET_LIST_LOAD_ERROR="assetListLoadError",s.ASSET_LIST_LOAD_TIMEOUT="assetListLoadTimeout",s.ASSET_LIST_PARSING_ERROR="assetListParsingError",s.INTERSTITIAL_ASSET_ITEM_ERROR="interstitialAssetItemError",s.INTERNAL_EXCEPTION="internalException",s.INTERNAL_ABORTED="aborted",s.ATTACH_MEDIA_ERROR="attachMediaError",s.UNKNOWN="unknown",s})({}),v=(function(s){return s.MEDIA_ATTACHING="hlsMediaAttaching",s.MEDIA_ATTACHED="hlsMediaAttached",s.MEDIA_DETACHING="hlsMediaDetaching",s.MEDIA_DETACHED="hlsMediaDetached",s.MEDIA_ENDED="hlsMediaEnded",s.STALL_RESOLVED="hlsStallResolved",s.BUFFER_RESET="hlsBufferReset",s.BUFFER_CODECS="hlsBufferCodecs",s.BUFFER_CREATED="hlsBufferCreated",s.BUFFER_APPENDING="hlsBufferAppending",s.BUFFER_APPENDED="hlsBufferAppended",s.BUFFER_EOS="hlsBufferEos",s.BUFFERED_TO_END="hlsBufferedToEnd",s.BUFFER_FLUSHING="hlsBufferFlushing",s.BUFFER_FLUSHED="hlsBufferFlushed",s.MANIFEST_LOADING="hlsManifestLoading",s.MANIFEST_LOADED="hlsManifestLoaded",s.MANIFEST_PARSED="hlsManifestParsed",s.LEVEL_SWITCHING="hlsLevelSwitching",s.LEVEL_SWITCHED="hlsLevelSwitched",s.LEVEL_LOADING="hlsLevelLoading",s.LEVEL_LOADED="hlsLevelLoaded",s.LEVEL_UPDATED="hlsLevelUpdated",s.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",s.LEVELS_UPDATED="hlsLevelsUpdated",s.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",s.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",s.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",s.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",s.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",s.AUDIO_TRACK_UPDATED="hlsAudioTrackUpdated",s.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUp
1484dated",s.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",s.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",s.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",s.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",s.SUBTITLE_TRACK_UPDATED="hlsSubtitleTrackUpdated",s.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",s.CUES_PARSED="hlsCuesParsed",s.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",s.INIT_PTS_FOUND="hlsInitPtsFound",s.FRAG_LOADING="hlsFragLoading",s.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",s.FRAG_LOADED="hlsFragLoaded",s.FRAG_DECRYPTED="hlsFragDecrypted",s.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",s.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",s.FRAG_PARSING_METADATA="hlsFragParsingMetadata",s.FRAG_PARSED="hlsFragParsed",s.FRAG_BUFFERED="hlsFragBuffered",s.FRAG_CHANGED="hlsFragChanged",s.FPS_DROP="hlsFpsDrop",s.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",s.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",s.ERROR="hlsError",s.DESTROYING="hlsDestroying",s.KEY_LOADING="hlsKeyLoading",s.KEY_LOADED="hlsKeyLoaded",s.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",s.BACK_BUFFER_REACHED="hlsBackBufferReached",s.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",s.ASSET_LIST_LOADING="hlsAssetListLoading",s.ASSET_LIST_LOADED="hlsAssetListLoaded",s.INTERSTITIALS_UPDATED="hlsInterstitialsUpdated",s.INTERSTITIALS_BUFFERED_TO_BOUNDARY="hlsInterstitialsBufferedToBoundary",s.INTERSTITIAL_ASSET_PLAYER_CREATED="hlsInterstitialAssetPlayerCreated",s.INTERSTITIAL_STARTED="hlsInterstitialStarted",s.INTERSTITIAL_ASSET_STARTED="hlsInterstitialAssetStarted",s.INTERSTITIAL_ASSET_ENDED="hlsInterstitialAssetEnded",s.INTERSTITIAL_ASSET_ERROR="hlsInterstitialAssetError",s.INTERSTITIAL_ENDED="hlsInterstitialEnded",s.INTERSTITIALS_PRIMARY_RESUMED="hlsInterstitialsPrimaryResumed",s.PLAYOUT_LIMIT_REACHED="hlsPlayoutLimitReached",s.EVENT_CUE_ENTER="hlsEventCueEnter",s})({});var Ge={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},ge={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};class on{constructor(e,t=0,i=0){this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=i}sample(e,t){const i=Math.pow(this.alpha_,e);this.estimate_=t*(1-i)+i*this.estimate_,this.totalWeight_+=e}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){const e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}}class YS{constructor(e,t,i,n=100){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=i,this.minWeight_=.001,this.minDelayMs_=50,this.slow_
vendor: 3,667 bytes, line 1484
1484=new on(e),this.fast_=new on(t),this.defaultTTFB_=n,this.ttfb_=new on(e)}update(e,t){const{slow_:i,fast_:n,ttfb_:r}=this;i.halfLife!==e&&(this.slow_=new on(e,i.getEstimate(),i.getTotalWeight())),n.halfLife!==t&&(this.fast_=new on(t,n.getEstimate(),n.getTotalWeight())),r.halfLife!==e&&(this.ttfb_=new on(e,r.getEstimate(),r.getTotalWeight()))}sample(e,t){e=Math.max(e,this.minDelayMs_);const i=8*t,n=e/1e3,r=i/n;this.fast_.sample(n,r),this.slow_.sample(n,r)}sampleTTFB(e){const t=e/1e3,i=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(i,Math.max(e,5))}canEstimate(){return this.fast_.getTotalWeight()>=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}get defaultEstimate(){return this.defaultEstimate_}destroy(){}}function zS(s,e,t){return(e=XS(e))in s?Object.defineProperty(s,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):s[e]=t,s}function nt(){return nt=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},nt.apply(null,arguments)}function ef(s,e){var t=Object.keys(s);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(s);e&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(s,n).enumerable})),t.push.apply(t,i)}return t}function Je(s){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?ef(Object(t),!0).forEach(function(i){zS(s,i,t[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(t)):ef(Object(t)).forEach(function(i){Object.defineProperty(s,i,Object.getOwnPropertyDescriptor(t,i))})}return s}function jS(s,e){if(typeof s!="object"||!s)return s;var t=s[Symbol.toPrimitive];if(t!==void 0){var i=t.call(s,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(s)}function XS(s){var e=jS(s,"string");return typeof e=="symbol"?e:e+""}class pi{constructor(e,t){this.trace=void 0,this.debug=void 0,this.log=void 0,this.warn=void 0,this.info=void 0,this.error=void 0;const i=`[${e}]:`;this.trace=Ts,this.debug=t.debug.bind(null,i),this.log=t.log.bind(null,i),this.warn=t.warn.bind(null,i),this.info=t.info.bind(null,i),this.error=t.error.bind(null,i)}}const Ts=function(){},QS={trace:Ts,debug:Ts,log:Ts,warn:Ts,info:Ts,error:Ts};function kc(){return nt({},QS)}function ZS(s,e){const t=self.console[s];return t?t.bind(self.console,`${e?"["+e+"] ":""}[${s}] >`):Ts}function tf(s,e,t){return e[s]?e[s].bind(e):ZS(s,t)}const Dc=kc();function JS(s,e,t){const i=kc();if(typeof console=="object"&&s===!0||typeof s=="object"){const n=["debug","log","info","warn","error"];n.forEach(r=>{i[r]=tf(r,s,t)});try{i.log(`Debug logs enabled for "${e}" in hls.js version 1.6.15`)}catch{return kc()}n.forEach(r=>{Dc[r]=tf(r,s)})}else nt(Dc,i);return i}const et=Dc;function Ls(s=!0){return typeof self>"u"?void 0:(s||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function eA(s){return typeof self<"u"&&s===self.ManagedMediaSource}function Mp(s,e){const t=Object.keys(s),i=Object.keys(e),n=t.length,r=i.length;return!n||!r||n===r&&!t.some(a=>i.indexOf(a)===-1)}function li(s,e=!1){if(typeof TextDecoder<"u"){const l=new TextDecoder("utf-8").decode(s);if(e){const c=l.indexOf("\0");return c!==-1?l.substring(0,c):l}return l.replace(/\0/g,"")}const t=s.length;let i,n,r,a="",o=0;for(;o<t;){if(i=s[o++],i===0&&e)return a;
vendor: 28,449 bytes, line 1484
1484if(i===0||i===3)continue;switch(i>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:a+=String.fromCharCode(i);break;case 12:case 13:n=s[o++],a+=String.fromCharCode((i&31)<<6|n&63);break;case 14:n=s[o++],r=s[o++],a+=String.fromCharCode((i&15)<<12|(n&63)<<6|(r&63)<<0);break}}return a}function Bt(s){let e="";for(let t=0;t<s.length;t++){let i=s[t].toString(16);i.length<2&&(i="0"+i),e+=i}return e}function Op(s){return Uint8Array.from(s.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}function tA(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var ed={exports:{}},sf;function iA(){return sf||(sf=1,(function(s,e){(function(t){var i=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,n=/^(?=([^\/?#]*))\1([^]*)$/,r=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,o={buildAbsoluteURL:function(d,l,c){if(c=c||{},d=d.trim(),l=l.trim(),!l){if(!c.alwaysNormalize)return d;var u=o.parseURL(d);if(!u)throw new Error("Error trying to parse base URL.");return u.path=o.normalizePath(u.path),o.buildURLFromParts(u)}var h=o.parseURL(l);if(!h)throw new Error("Error trying to parse relative URL.");if(h.scheme)return c.alwaysNormalize?(h.path=o.normalizePath(h.path),o.buildURLFromParts(h)):l;var f=o.parseURL(d);if(!f)throw new Error("Error trying to parse base URL.");if(!f.netLoc&&f.path&&f.path[0]!=="/"){var m=n.exec(f.path);f.netLoc=m[1],f.path=m[2]}f.netLoc&&!f.path&&(f.path="/");var p={scheme:f.scheme,netLoc:h.netLoc,path:null,params:h.params,query:h.query,fragment:h.fragment};if(!h.netLoc&&(p.netLoc=f.netLoc,h.path[0]!=="/"))if(!h.path)p.path=f.path,h.params||(p.params=f.params,h.query||(p.query=f.query));else{var g=f.path,y=g.substring(0,g.lastIndexOf("/")+1)+h.path;p.path=o.normalizePath(y)}return p.path===null&&(p.path=c.alwaysNormalize?o.normalizePath(h.path):h.path),o.buildURLFromParts(p)},parseURL:function(d){var l=i.exec(d);return l?{scheme:l[1]||"",netLoc:l[2]||"",path:l[3]||"",params:l[4]||"",query:l[5]||"",fragment:l[6]||""}:null},normalizePath:function(d){for(d=d.split("").reverse().join("").replace(r,"");d.length!==(d=d.replace(a,"")).length;);return d.split("").reverse().join("")},buildURLFromParts:function(d){return d.scheme+d.netLoc+d.path+d.params+d.query+d.fragment}};s.exports=o})()})(ed)),ed.exports}var Lu=iA();class Ru{constructor(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}}var ot={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"};class Fp{constructor(e){this._byteRange=null,this._url=null,this._stats=null,this._streams=null,this.base=void 0,this.relurl=void 0,typeof e=="string"&&(e={url:e}),this.base=e,nA(this,"stats")}setByteRange(e,t){const i=e.split("@",2);let n;i.length===1?n=t?.byteRangeEndOffset||0:n=parseInt(i[1]),this._byteRange=[n,parseInt(i[0])+n]}get baseurl(){return this.base.url}get byteRange(){return this._byteRange===null?[]:this._byteRange}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get elementaryStreams(){return this._streams===null&&(this._streams={[ot.AUDIO]:null,[ot.VIDEO]:null,[ot.AUDIOVIDEO]:null}),this._streams}set elementaryStreams(e){this._streams=e}get hasStats(){return this._stats!==null}get hasStreams(){return this._streams!==null}get stats(){return this._stats===null&&(this._stats=new Ru),this._stats}set stats(e){this._stats=e}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Lu.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}clearElementaryStreamInfo(){const{elementaryStreams:e}=this;e[ot.AUDIO]=null,e[ot.VIDEO]=null,e[ot.AUDIOVIDEO]=null}}function yt(s){return s.sn!=="initSegment"}class td extends Fp{constructor(e,t){super(t),this._decryptdata=null,this._programDateTime=null,this._ref=null,this._bitrate=void 0,this.rawProgramDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.playlistOffset=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.urlId=0,this.type=e}get byteLength(){if(this.hasStats){const e=this.stats.total;if(e)return e}if(this.byteRange.length){const e=this.byteRange[0],t=this.byteRange[1];if(he(e)&&he(t))return t-e}return null}get bitrate(){return this.byteLength?this.byteLength*8/this.duration:this._bitrate?this._bitrate:null}set bitrate(e){this._bitrate=e}get decryptdata(){var e;const{levelkeys:t}=this;if(!t||t.NONE)return null;if(t.identity)this._decryptdata||(this._decryptdata=t.identity.getDecryptData(this.sn));else if(!((e=this._decryptdata)!=null&&e.keyId)){const i=Object.keys(t);if(i.length===1){const n=this._decryptdata=t[i[0]]||null;n&&(this._decryptdata=n.getDecryptData(this.sn,t))}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(this.programDateTime===null)return null;const e=he(this.duration)?this.duration:0;return this.programDateTime+e*1e3}get encrypted(){var e;if((e=this._decryptdata)!=null&&e.encrypted)return!0;if(this.levelkeys){var t;const i=Object.keys(this.levelkeys),n=i.length;if(n>1||n===1&&(t=this.levelkeys[i[0]])!=null&&t.encrypted)return!0}return!1}get programDateTime(){return this._programDateTime===null&&this.rawProgramDateTime&&(this.programDateTime=Date.parse(this.rawProgramDateTime)),this._programDateTime}set programDateTime(e){if(!he(e)){this._programDateTime=this.rawProgramDateTime=null;return}this._programDateTime=e}get ref(){return yt(this)?(this._ref||(this._ref={base:this.base,start:this.start,duration:this.duration,sn:this.sn,programDateTime:this.programDateTime}),this._ref):null}addStart(e){this.setStart(this.start+e)}setStart(e){this.start=e,this._ref&&(this._ref.start=e)}setDuration(e){this.duration=e,this._ref&&(this._ref.duration=e)}setKeyFormat(e){const t=this.levelkeys;if(t){var i;const n=t[e];n&&!((i=this._decryptdata)!=null&&i.keyId)&&(this._decryptdata=n.getDecryptData(this.sn,t))}}abortRequests(){var e,t;(e=this.loader)==null||e.abort(),(t=this.keyLoader)==null||t.abort()}setElementaryStreamInfo(e,t,i,n,r,a=!1){const{elementaryStreams:o}=this,d=o[e];if(!d){o[e]={startPTS:t,endPTS:i,startDTS:n,endDTS:r,partial:a};return}d.startPTS=Math.min(d.startPTS,t),d.endPTS=Math.max(d.endPTS,i),d.startDTS=Math.min(d.startDTS,n),d.endDTS=Math.max(d.endDTS,r)}}class sA extends Fp{constructor(e,t,i,n,r){super(i),this.fragOffset=0,this.duration=0,this.gap=!1,this.independent=!1,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.duration=e.decimalFloatingPoint("DURATION"),this.gap=e.bool("GAP"),this.independent=e.bool("INDEPENDENT"),this.relurl=e.enumeratedString("URI"),this.fragment=t,this.index=n;const a=e.enumeratedString("BYTERANGE");a&&this.setByteRange(a,r),r&&(this.fragOffset=r.fragOffset+r.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){const{elementaryStreams:e}=this;return!!(e.audio||e.video||e.audiovideo)}}function $p(s,e){const t=Object.getPrototypeOf(s);if(t){const i=Object.getOwnPropertyDescriptor(t,e);return i||$p(t,e)}}function nA(s,e){const t=$p(s,e);t&&(t.enumerable=!0,Object.defineProperty(s,e,t))}const nf=Math.pow(2,32)-1,rA=[].push,Np={video:1,audio:2,id3:3,text:4};function It(s){return String.fromCharCode.apply(null,s)}function Up(s,e){const t=s[e]<<8|s[e+1];return t<0?65536+t:t}function we(s,e){const t=Bp(s,e);return t<0?4294967296+t:t}function rf(s,e){let t=we(s,e);return t*=Math.pow(2,32),t+=we(s,e+4),t}function Bp(s,e){return s[e]<<24|s[e+1]<<16|s[e+2]<<8|s[e+3]}function aA(s){const e=s.byteLength;for(let t=0;t<e;){const i=we(s,t);if(i>8&&s[t+4]===109&&s[t+5]===111&&s[t+6]===111&&s[t+7]===102)return!0;t=i>1?t+i:e}return!1}function Be(s,e){const t=[];if(!e.length)return t;const i=s.byteLength;for(let n=0;n<i;){const r=we(s,n),a=It(s.subarray(n+4,n+8)),o=r>1?n+r:i;if(a===e[0])if(e.length===1)t.push(s.subarray(n+8,o));else{const d=Be(s.subarray(n+8,o),e.slice(1));d.length&&rA.apply(t,d)}n=o}return t}function oA(s){const e=[],t=s[0];let i=8;const n=we(s,i);i+=4;let r=0,a=0;t===0?(r=we(s,i),a=we(s,i+4),i+=8):(r=rf(s,i),a=rf(s,i+8),i+=16),i+=2;let o=s.length+a;const d=Up(s,i);i+=2;for(let l=0;l<d;l++){let c=i;const u=we(s,c);c+=4;const h=u&2147483647;if((u&2147483648)>>>31===1)return et.warn("SIDX has hierarchical references (not supported)"),null;const m=we(s,c);c+=4,e.push({referenceSize:h,subsegmentDuration:m,info:{duration:m/n,start:o,end:o+h-1}}),o+=h,c+=4,i=c}return{earliestPresentationTime:r,timescale:n,version:t,referencesCount:d,references:e}}function Gp(s){const e=[],t=Be(s,["moov","trak"]);for(let n=0;n<t.length;n++){const r=t[n],a=Be(r,["tkhd"])[0];if(a){let o=a[0];const d=we(a,o===0?12:20),l=Be(r,["mdia","mdhd"])[0];if(l){o=l[0];const c=we(l,o===0?12:20),u=Be(r,["mdia","hdlr"])[0];if(u){const h=It(u.subarray(8,12)),f={soun:ot.AUDIO,vide:ot.VIDEO}[h],m=Be(r,["mdia","minf","stbl","stsd"])[0],p=lA(m);f?(e[d]={timescale:c,type:f,stsd:p},e[f]=Je({timescale:c,id:d},p)):e[d]={timescale:c,type:h,stsd:p}}}}}return Be(s,["moov","mvex","trex"]).forEach(n=>{const r=we(n,4),a=e[r];a&&(a.default={duration:we(n,12),flags:we(n,20)})}),e}function lA(s){const e=s.subarray(8),t=e.subarray(86),i=It(e.subarray(4,8));let n=i,r;const a=i==="enca"||i==="encv";if(a){const l=Be(e,[i])[0].subarray(i==="enca"?28:78);Be(l,["sinf"]).forEach(u=>{const h=Be(u,["schm"])[0];if(h){const f=It(h.subarray(4,8));if(f==="cbcs"||f==="cenc"){const m=Be(u,["frma"])[0];m&&(n=It(m))}}})}const o=n;switch(n){case"avc1":case"avc2":case"avc3":case"avc4":{const d=Be(t,["avcC"])[0];d&&d.length>3&&(n+="."+ka(d[1])+ka(d[2])+ka(d[3]),r=Ra(o==="avc1"?"dva1":"dvav",t));break}case"mp4a":{const d=Be(e,[i])[0],l=Be(d.subarray(28),["esds"])[0];if(l&&l.length>7){let c=4;if(l[c++]!==3)break;c=id(l,c),c+=2;const u=l[c++];if(u&128&&(c+=2),u&64&&(c+=l[c++]),l[c++]!==4)break;c=id(l,c);const h=l[c++];if(h===64)n+="."+ka(h);else break;if(c+=12,l[c++]!==5)break;c=id(l,c);const f=l[c++];let m=(f&248)>>3;m===31&&(m+=1+((f&7)<<3)+((l[c]&224)>>5)),n+="."+m}break}case"hvc1":case"hev1":{const d=Be(t,["hvcC"])[0];if(d&&d.length>12){const l=d[1],c=["","A","B","C"][l>>6],u=l&31,h=we(d,2),f=(l&32)>>5?"H":"L",m=d[12],p=d.subarray(6,12);n+="."+c+u,n+="."+dA(h).toString(16).toUpperCase(),n+="."+f+m;let g="";for(let y=p.length;y--;){const T=p[y];(T||g)&&(g="."+T.toString(16).toUpperCase()+g)}n+=g}r=Ra(o=="hev1"?"dvhe":"dvh1",t);break}case"dvh1":case"dvhe":case"dvav":case"dva1":case"dav1":{n=Ra(n,t)||n;break}case"vp09":{const d=Be(t,["vpcC"])[0];if(d&&d.length>6){const l=d[4],c=d[5],u=d[6]>>4&15;n+="."+Bi(l)+"."+Bi(c)+"."+Bi(u)}break}case"av01":{const d=Be(t,["av1C"])[0];if(d&&d.length>2){const l=d[1]>>>5,c=d[1]&31,u=d[2]>>>7?"H":"M",h=(d[2]&64)>>6,f=(d[2]&32)>>5,m=l===2&&h?f?12:10:h?10:8,p=(d[2]&16)>>4,g=(d[2]&8)>>3,y=(d[2]&4)>>2,T=d[2]&3;n+="."+l+"."+Bi(c)+u+"."+Bi(m)+"."+p+"."+g+y+T+"."+Bi(1)+"."+Bi(1)+"."+Bi(1)+"."+0,r=Ra("dav1",t)}break}}return{codec:n,encrypted:a,supplemental:r}}function Ra(s,e){const t=Be(e,["dvvC"]),i=t.length?t[0]:Be(e,["dvcC"])[0];if(i){const n=i[2]>>1&127,r=i[2]<<5&32|i[3]>>3&31;return s+"."+Bi(n)+"."+Bi(r)}}function dA(s){let e=0;for(let t=0;t<32;t++)e|=(s>>t&1)<<31-t;return e>>>0}function id(s,e){const t=e+5;for(;s[e++]&128&&e<t;);return e}function ka(s){return("0"+s.toString(16).toUpperCase()).slice(-2)}function Bi(s){return(s<10?"0":"")+s}function cA(s,e){if(!s||!e)return;const t=e.keyId;t&&e.isCommonEncryption&&Kp(s,(i,n)=>{const r=i.subarray(8,24);r.some(a=>a!==0)||(et.log(`[eme] Patching keyId in 'enc${n?"a":"v"}>sinf>>tenc' box: ${Bt(r)} -> ${Bt(t)}`),i.set(t,8))})}function uA(s){const e=[];return Kp(s,t=>e.push(t.subarray(8,24))),e}function Kp(s,e){Be(s,["moov","trak"]).forEach(i=>{const n=Be(i,["mdia","minf","stbl","stsd"])[0];if(!n)return;const r=n.subarray(8);let a=Be(r,["enca"]);const o=a.length>0;o||(a=Be(r,["encv"])),a.forEach(d=>{const l=o?d.subarray(28):d.subarray(78);Be(l,["sinf"]).forEach(u=>{const h=Hp(u);h&&e(h,o)})})})}function Hp(s){const e=Be(s,["schm"])[0];if(e){const t=It(e.subarray(4,8));if(t==="cbcs"||t==="cenc"){const i=Be(s,["schi","tenc"])[0];if(i)return i}}}function hA(s,e,t){const i={},n=Be(s,["moof","traf"]);for(let r=0;r<n.length;r++){const a=n[r],o=Be(a,["tfhd"])[0],d=we(o,4),l=e[d];if(!l)continue;i[d]||(i[d]={start:NaN,duration:0,sampleCount:0,timescale:l.timescale,type:l.type});const c=i[d],u=Be(a,["tfdt"])[0];if(u){const _=u[0];let I=we(u,4);_===1&&(I===nf?t.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"):(I*=nf+1,I+=we(u,8))),he(I)&&(!he(c.start)||I<c.start)&&(c.start=I)}const h=l.default,f=we(o,0)|h?.flags;let m=h?.duration||0;f&8&&(f&2?m=we(o,12):m=we(o,8));const p=Be(a,["trun"]);let g=c.start||0,y=0,T=m;for(let _=0;_<p.length;_++){const I=p[_],R=we(I,4),F=c.sampleCount;c.sampleCount+=R;const L=I[3]&1,w=I[3]&4,P=I[2]&1,k=I[2]&2,G=I[2]&4,se=I[2]&8;let oe=8,de=R;for(L&&(oe+=4),w&&R&&(!(I[oe+1]&1)&&c.keyFrameIndex===void 0&&(c.keyFrameIndex=F),oe+=4,P?(T=we(I,oe),oe+=4):T=m,k&&(oe+=4),se&&(oe+=4),g+=T,y+=T,de--);de--;)P?(T=we(I,oe),oe+=4):T=m,k&&(oe+=4),G&&(I[oe+1]&1||c.keyFrameIndex===void 0&&(c.keyFrameIndex=c.sampleCount-(de+1),c.keyFrameStart=g),oe+=4),se&&(oe+=4),g+=T,y+=T;!y&&m&&(y+=m*R)}c.duration+=y}if(!Object.keys(i).some(r=>i[r].duration)){let r=1/0,a=0;const o=Be(s,["sidx"]);for(let d=0;d<o.length;d++){const l=oA(o[d]);if(l!=null&&l.references){r=Math.min(r,l.earliestPresentationTime/l.timescale);const c=l.references.reduce((u,h)=>u+h.info.duration||0,0);a=Math.max(a,c+l.earliestPresentationTime/l.timescale)}}a&&he(a)&&Object.keys(i).forEach(d=>{i[d].duration||(i[d].duration=a*i[d].timescale-i[d].start)})}return i}function fA(s){const e={valid:null,remainder:null},t=Be(s,["moof"]);if(t.length<2)return e.remainder=s,e;const i=t[t.length-1];return e.valid=s.slice(0,i.byteOffset-8),e.remainder=s.slice(i.byteOffset-8),e}function gi(s,e){const t=new Uint8Array(s.length+e.length);return t.set(s),t.set(e,s.length),t}function af(s,e){const t=[],i=e.samples,n=e.timescale,r=e.id;let a=!1;return Be(i,["moof"]).map(d=>{const l=d.byteOffset-8;Be(d,["traf"]).map(u=>{const h=Be(u,["tfdt"]).map(f=>{const m=f[0];let p=we(f,4);return m===1&&(p*=Math.pow(2,32),p+=we(f,8)),p/n})[0];return h!==void 0&&(s=h),Be(u,["tfhd"]).map(f=>{const m=we(f,4),p=we(f,0)&16777215,g=(p&1)!==0,y=(p&2)!==0,T=(p&8)!==0;let _=0;const I=(p&16)!==0;let R=0;const F=(p&32)!==0;let L=8;m===r&&(g&&(L+=8),y&&(L+=4),T&&(_=we(f,L),L+=4),I&&(R=we(f,L),L+=4),F&&(L+=4),e.type==="video"&&(a=Cl(e.codec)),Be(u,["trun"]).map(w=>{const P=w[0],k=we(w,0)&16777215,G=(k&1)!==0;let se=0;const oe=(k&4)!==0,de=(k&256)!==0;let ae=0;const ie=(k&512)!==0;let ue=0;const ee=(k&1024)!==0,te=(k&2048)!==0;let ve=0;const X=we(w,4);let Y=8;G&&(se=we(w,Y),Y+=4),oe&&(Y+=4);let Ie=se+l;for(let De=0;De<X;De++){if(de?(ae=we(w,Y),Y+=4):ae=_,ie?(ue=we(w,Y),Y+=4):ue=R,ee&&(Y+=4),te&&(P===0?ve=we(w,Y):ve=Bp(w,Y),Y+=4),e.type===ot.VIDEO){let Re=0;for(;Re<ue;){const Ce=we(i,Ie);if(Ie+=4,mA(a,i[Ie])){const dt=i.subarray(Ie,Ie+Ce);ku(dt,a?2:1,s+ve/n,t)}Ie+=Ce,Re+=Ce+4}}s+=ae/n}}))})})}),t}function Cl(s){if(!s)return!1;const e=s.substring(0,4);return e==="hvc1"||e==="hev1"||e==="dvh1"||e==="dvhe"}function mA(s,e){if(s){const t=e>>1&63;return t===39||t===40}else return(e&31)===6}function ku(s,e,t,i){const n=Vp(s);let r=0;r+=e;let a=0,o=0,d=0;for(;r<n.length;){a=0;do{if(r>=n.length)break;d=n[r++],a+=d}while(d===255);o=0;do{if(r>=n.length)break;d=n[r++],o+=d}while(d===255);const l=n.length-r;let c=r;if(o<l)r+=o;else if(o>l){et.error(`Malformed SEI payload. ${o} is too small, only ${l} bytes left to parse.`);break}if(a===4){if(n[c++]===181){const h=Up(n,c);if(c+=2,h===49){const f=we(n,c);if(c+=4,f===1195456820){const m=n[c++];if(m===3){const p=n[c++],g=31&p,y=64&p,T=y?2+g*3:0,_=new Uint8Array(T);if(y){_[0]=p;for(let I=1;I<T;I++)_[I]=n[c++]}i.push({type:m,payloadType:a,pts:t,bytes:_})}}}}}else if(a===5&&o>16){const u=[];for(let m=0;m<16;m++){const p=n[c++].toString(16);u.push(p.length==1?"0"+p:p),(m===3||m===5||m===7||m===9)&&u.push("-")}const h=o-16,f=new Uint8Array(h);for(let m=0;m<h;m++)f[m]=n[c++];i.push({payloadType:a,pts:t,uuid:u.join(""),userData:li(f),userDataBytes:f})}}}function Vp(s){const e=s.byteLength,t=[];let i=1;for(;i<e-2;)s[i]===0&&s[i+1]===0&&s[i+2]===3?(t.push(i+2),i+=2):i++;if(t.length===0)return s;const n=e-t.length,r=new Uint8Array(n);let a=0;for(i=0;i<n;a++,i++)a===t[0]&&(a++,t.shift()),r[i]=s[a];return r}function gA(s){const e=s[0];let t="",i="",n=0,r=0,a=0,o=0,d=0,l=0;if(e===0){for(;It(s.subarray(l,l+1))!=="\0";)t+=It(s.subarray(l,l+1)),l+=1;for(t+=It(s.subarray(l,l+1)),l+=1;It(s.subarray(l,l+1))!=="\0";)i+=It(s.subarray(l,l+1)),l+=1;i+=It(s.subarray(l,l+1)),l+=1,n=we(s,12),r=we(s,16),o=we(s,20),d=we(s,24),l=28}else if(e===1){l+=4,n=we(s,l),l+=4;const u=we(s,l);l+=4;const h=we(s,l);for(l+=4,a=2**32*u+h,WS(a)||(a=Number.MAX_SAFE_INTEGER,et.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=we(s,l),l+=4,d=we(s,l),l+=4;It(s.subarray(l,l+1))!=="\0";)t+=It(s.subarray(l,l+1)),l+=1;for(t+=It(s.subarray(l,l+1)),l+=1;It(s.subarray(l,l+1))!=="\0";)i+=It(s.subarray(l,l+1)),l+=1;i+=It(s.subarray(l,l+1)),l+=1}const c=s.subarray(l,s.byteLength);return{schemeIdUri:t,value:i,timeScale:n,presentationTime:a,presentationTimeDelta:r,eventDuration:o,id:d,payload:c}}function pA(s,...e){const t=e.length;let i=8,n=t;for(;n--;)i+=e[n].byteLength;const r=new Uint8Array(i);for(r[0]=i>>24&255,r[1]=i>>16&255,r[2]=i>>8&255,r[3]=i&255,r.set(s,4),n=0,i=8;n<t;n++)r.set(e[n],i),i+=e[n].byteLength;return r}function vA(s,e,t){if(s.byteLength!==16)throw new RangeError("Invalid system id");let i,n;i=0,n=new Uint8Array;let r;i>0?(r=new Uint8Array(4),e.length>0&&new DataView(r.buffer).setUint32(0,e.length,!1)):r=new Uint8Array;const a=new Uint8Array(4);return t.byteLength>0&&new DataView(a.buffer).setUint32(0,t.byteLength,!1),pA([112,115,115,104],new Uint8Array([i,0,0,0]),s,r,n,a,t)}function EA(s){const e=[];if(s instanceof ArrayBuffer){const t=s.byteLength;let i=0;for(;i+32<t;){const n=new DataView(s,i),r=yA(n);e.push(r),i+=r.size}}return e}function yA(s){const e=s.getUint32(0),t=s.byteOffset,i=s.byteLength;if(i<e)return{offset:t,size:i};if(s.getUint32(4)!==1886614376)return{offset:t,size:e};const r=s.getUint32(8)>>>24;if(r!==0&&r!==1)return{offset:t,size:e};const a=s.buffer,o=Bt(new Uint8Array(a,t+12,16));let d=null,l=null,c=0;if(r===0)c=28;else{const h=s.getUint32(28);if(!h||i<32+h*16)return{offset:t,size:e};d=[];for(let f=0;f<h;f++)d.push(new Uint8Array(a,t+32+f*16,16));c=32+h*16}if(!c)return{offset:t,size:e};const u=s.getUint32(c);return e-32<u?{offset:t,size:e}:(l=new Uint8Array(a,t+c+4,u),{version:r,systemId:o,kids:d,data:l,offset:t,size:e})}const Wp=()=>/\(Windows.+Firefox\//i.test(navigator.userAgent),zn={audio:{a3ds:1,"ac-3":.95,"ac-4":1,alac:.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":.9,enca:1,fLaC:.9,flac:.9,FLAC:.9,g719:1,g726:1,m4ae:1,mha1:1,mha2:1,mhm1:1,mhm2:1,mlpa:1,mp4a:1,"raw ":1,Opus:1,opus:1,samr:1,sawb:1,sawp:1,sevc:1,sqcp:1,ssmv:1,twos:1,ulaw:1},video:{avc1:1,avc2:1,avc3:1,avc4:1,avcp:1,av01:.8,dav1:.8,drac:1,dva1:1,dvav:1,dvh1:.7,dvhe:.7,encv:1,hev1:.75,hvc1:.75,mjp2:1,mp4v:1,mvc1:1,mvc2:1,mvc3:1,mvc4:1,resv:1,rv60:1,s263:1,svc1:1,svc2:1,"vc-1":1,vp08:1,vp09:.9},text:{stpp:1,wvtt:1}};function Du(s,e){const t=zn[e];return!!t&&!!t[s.slice(0,4)]}function Kr(s,e,t=!0){return!s.split(",").some(i=>!Cu(i,e,t))}function Cu(s,e,t=!0){var i;const n=Ls(t);return(i=n?.isTypeSupported(Hr(s,e)))!=null?i:!1}function Hr(s,e){return`${e}/mp4;codecs=${s}`}function of(s){if(s){const e=s.substring(0,4);return zn.video[e]}return 2}function ll(s){const e=Wp();return s.split(",").reduce((t,i)=>{const r=e&&Cl(i)?9:zn.video[i];return r?(r*2+t)/(t?3:2):(zn.audio[i]+t)/(t?2:1)},0)}const sd={};function TA(s,e=!0){if(sd[s])return sd[s];const t={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"],"mp4a.40.34":["mp3"]}[s];for(let n=0;n<t.length;n++){var i;if(Cu(t[n],"audio",e))return sd[s]=t[n],t[n];if(t[n]==="mp3"&&(i=Ls(e))!=null&&i.isTypeSupported("audio/mpeg"))return""}return s}const bA=/flac|opus|mp4a\.40\.34/i;function dl(s,e=!0){return s.replace(bA,t=>TA(t.toLowerCase(),e))}function _A(s,e){const t=[];if(s){const i=s.split(",");for(let n=0;n<i.length;n++)Du(i[n],"video")||t.push(i[n])}return e&&t.push(e),t.join(",")}function Do(s,e){if(s&&(s.length>4||["ac-3","ec-3","alac","fLaC","Opus"].indexOf(s)!==-1)&&(lf(s,"audio")||lf(s,"video")))return s;if(e){const t=e.split(",");if(t.length>1){if(s){for(let i=t.length;i--;)if(t[i].substring(0,4)===s.substring(0,4))return t[i]}return t[0]}}return e||s}function lf(s,e){return Du(s,e)&&Cu(s,e)}function SA(s){const e=s.split(",");for(let t=0;t<e.length;t++){const i=e[t].split(".");i.length>2&&i[0]==="avc1"&&(e[t]=`avc1.${parseInt(i[1]).toString(16)}${("000"+parseInt(i[2]).toString(16)).slice(-4)}`)}return e.join(",")}function AA(s){if(s.startsWith("av01.")){const e=s.split("."),t=["0","111","01","01","01","0"];for(let i=e.length;i>4&&i<10;i++)e[i]=t[i-4];return e.join(".")}return s}function df(s){const e=Ls(s)||{isTypeSupported:()=>!1};return{mpeg:e.isTypeSupported("audio/mpeg"),mp3:e.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:e.isTypeSupported('audio/mp4; codecs="ac-3"')}}function Cc(s){return s.replace(/^.+codecs=["']?([^"']+).*$/,"$1")}const IA={supported:!0,powerEfficient:!0,smooth:!0},xA={supported:!1,smooth:!1,powerEfficient:!1},qp={supported:!0,configurations:[],decodingInfoResults:[IA]};function Yp(s,e){return{supported:!1,configurations:e,decodingInfoResults:[xA],error:s}}function LA(s,e,t,i,n,r){const a=s.videoCodec,o=s.audioCodec?s.audioGroups:null,d=r?.audioCodec,l=r?.channels,c=l?parseInt(l):d?1/0:2;let u=null;if(o!=null&&o.length)try{o.length===1&&o[0]?u=e.groups[o[0]].channels:u=o.reduce((h,f)=>{if(f){const m=e.groups[f];if(!m)throw new Error(`Audio track group ${f} not found`);Object.keys(m.channels).forEach(p=>{h[p]=(h[p]||0)+m.channels[p]})}return h},{2:0})}catch{return!0}return a!==void 0&&(a.split(",").some(h=>Cl(h))||s.width>1920&&s.height>1088||s.height>1920&&s.width>1088||s.frameRate>Math.max(i,30)||s.videoRange!=="SDR"&&s.videoRange!==t||s.bitrate>Math.max(n,8e6))||!!u&&he(c)&&Object.keys(u).some(h=>parseInt(h)>c)}function zp(s,e,t,i={}){const n=s.videoCodec;if(!n&&!s.audioCodec||!t)return Promise.resolve(qp);const r=[],a=RA(s),o=a.length,d=kA(s,e,o>0),l=d.length;for(let c=o||1*l||1;c--;){const u={type:"media-source"};if(o&&(u.video=a[c%o]),l){u.audio=d[c%l];const h=u.audio.bitrate;u.video&&h&&(u.video.bitrate-=h)}r.push(u)}if(n){const c=navigator.userAgent;if(n.split(",").some(u=>Cl(u))&&Wp())return Promise.resolve(Yp(new Error(`Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent string: (${c})`),r))}return Promise.all(r.map(c=>{const u=CA(c);return i[u]||(i[u]=t.decodingInfo(c))})).then(c=>({supported:!c.some(u=>!u.supported),configurations:r,decodingInfoResults:c})).catch(c=>({supported:!1,configurations:r,decodingInfoResults:[],error:c}))}function RA(s){var e;const t=(e=s.videoCodec)==null?void 0:e.split(","),i=jp(s),n=s.width||640,r=s.height||480,a=s.frameRate||30,o=s.videoRange.toLowerCase();return t?t.map(d=>{const l={contentType:Hr(AA(d),"video"),width:n,height:r,bitrate:i,framerate:a};return o!=="sdr"&&(l.transferFunction=o),l}):[]}function kA(s,e,t){var i;const n=(i=s.audioCodec)==null?void 0:i.split(","),r=jp(s);return n&&s.audioGroups?s.audioGroups.reduce((a,o)=>{var d;const l=o?(d=e.groups[o])==null?void 0:d.tracks:null;return l?l.reduce((c,u)=>{if(u.groupId===o){const h=parseFloat(u.channels||"");n.forEach(f=>{const m={contentType:Hr(f,"audio"),bitrate:t?DA(f,r):r};h&&(m.channels=""+h),c.push(m)})}return c},a):a},[]):[]}function DA(s,e){if(e<=1)return 1;let t=128e3;return s==="ec-3"?t=768e3:s==="ac-3"&&(t=64e4),Math.min(e/2,t)}function jp(s){return Math.ceil(Math.max(s.bitrate*.9,s.averageBitrate)/1e3)*1e3||1}function CA(s){let e="";const{audio:t,video:i}=s;if(i){const n=Cc(i.contentType);e+=`${n}_r${i.height}x${i.width}f${Math.ceil(i.framerate)}${i.transferFunction||"sd"}_${Math.ceil(i.bitrate/1e5)}`}if(t){const n=Cc(t.contentType);e+=`${i?"_":""}${n}_c${t.channels}`}return e}const wc=["NONE","TYPE-0","TYPE-1",null];function wA(s){return wc.indexOf(s)>-1}const cl=["SDR","PQ","HLG"];function PA(s){return!!s&&cl.indexOf(s)>-1}var Co={No:"",Yes:"YES",v2:"v2"};function cf(s){const{canSkipUntil:e,canSkipDateRanges:t,age:i}=s,n=i<e/2;return e&&n?t?Co.v2:Co.Yes:Co.No}class uf{constructor(e,t,i){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=i}addDirectives(e){const t=new self.URL(e);return this.msn!==void 0&&t.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href}}class Vr{constructor(e){if(this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.supplemental=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=void 0,this._urlId=0,this.url=[e.url],this._attrs=[e.attrs],this.bitrate=e.bitrate,e.details&&(this.details=e.details),this.id=e.id||0,this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.frameRate=e.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=e.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.codecSet=[e.videoCodec,e.audioCodec].filter(i=>!!i).map(i=>i.substring(0,4)).join(","),"supplemental"in e){var t;this.supplemental=e.supplemental;const i=(t=e.supplemental)==null?void 0:t.videoCodec;i&&i!==e.videoCodec&&(this.codecSet+=`,${i.substring(0,4)}`)}this.addGroupId("audio",e.attrs.AUDIO),this.addGroupId("text",e.attrs.SUBTITLES)}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get averageBitrate(){return this._avgBitrate||this.realBitrate||this.bitrate}get attrs(){return this._attrs[0]}get codecs(){return this.attrs.CODECS||""}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get videoRange(){return this.attrs["VIDEO-RANGE"]||"SDR"}get score(){return this.attrs.optionalFloat("SCORE",0)}get uri(){return this.url[0]||""}hasAudioGroup(e){return hf(this._audioGroups,e)}hasSubtitleGroup(e){return hf(this._subtitleGroups,e)}get audioGroups(){return this._audioGroups}get subtitleGroups(){return this._subtitleGroups}addGroupId(e,t){if(t){if(e==="audio"){let i=this._audioGroups;i||(i=this._audioGroups=[]),i.indexOf(t)===-1&&i.push(t)}else if(e==="text"){let i=this._subtitleGroups;i||(i=this._subtitleGroups=[]),i.indexOf(t)===-1&&i.push(t)}}}get urlId(){return 0}set urlId(e){}get audioGroupIds(){return this.audioGroups?[this.audioGroupId]:void 0}get textGroupIds(){return this.subtitleGroups?[this.textGroupId]:void 0}get audioGroupId(){var e;return(e=this.audioGroups)==null?void 0:e[0]}get textGroupId(){var e;return(e=this.subtitleGroups)==null?void 0:e[0]}addFallback(){}}function hf(s,e){return!e||!s?!1:s.indexOf(e)!==-1}function MA(){if(typeof matchMedia=="function"){const s=matchMedia("(dynamic-range: high)"),e=matchMedia("bad query");if(s.media!==e.media)return s.matches===!0}return!1}function OA(s,e){let t=!1,i=[];if(s&&(t=s!=="SDR",i=[s]),e){i=e.allowedVideoRanges||cl.slice(0);const n=i.join("")!=="SDR"&&!e.videoCodec;t=e.preferHDR!==void 0?e.preferHDR:n&&MA(),t||(i=["SDR"])}return{preferHDR:t,allowedVideoRanges:i}}const FA=s=>{const e=new WeakSet;return(t,i)=>{if(s&&(i=s(t,i)),typeof i=="object"&&i!==null){if(e.has(i))return;e.add(i)}return i}},lt=(s,e)=>JSON.stringify(s,FA(e));function $A(s,e,t,i,n){const r=Object.keys(s),a=i?.channels,o=i?.audioCodec,d=n?.videoCodec,l=a&&parseInt(a)===2;
vendor: 4,209 bytes, line 1484
1484let c=!1,u=!1,h=1/0,f=1/0,m=1/0,p=1/0,g=0,y=[];const{preferHDR:T,allowedVideoRanges:_}=OA(e,n);for(let w=r.length;w--;){const P=s[r[w]];c||(c=P.channels[2]>0),h=Math.min(h,P.minHeight),f=Math.min(f,P.minFramerate),m=Math.min(m,P.minBitrate),_.filter(G=>P.videoRanges[G]>0).length>0&&(u=!0)}h=he(h)?h:0,f=he(f)?f:0;const I=Math.max(1080,h),R=Math.max(30,f);m=he(m)?m:t,t=Math.max(m,t),u||(e=void 0);const F=r.length>1;return{codecSet:r.reduce((w,P)=>{const k=s[P];if(P===w)return w;if(y=u?_.filter(G=>k.videoRanges[G]>0):[],F){if(k.minBitrate>t)return Ri(P,`min bitrate of ${k.minBitrate} > current estimate of ${t}`),w;if(!k.hasDefaultAudio)return Ri(P,"no renditions with default or auto-select sound found"),w;if(o&&P.indexOf(o.substring(0,4))%5!==0)return Ri(P,`audio codec preference "${o}" not found`),w;if(a&&!l){if(!k.channels[a])return Ri(P,`no renditions with ${a} channel sound found (channels options: ${Object.keys(k.channels)})`),w}else if((!o||l)&&c&&k.channels[2]===0)return Ri(P,"no renditions with stereo sound found"),w;if(k.minHeight>I)return Ri(P,`min resolution of ${k.minHeight} > maximum of ${I}`),w;if(k.minFramerate>R)return Ri(P,`min framerate of ${k.minFramerate} > maximum of ${R}`),w;if(!y.some(G=>k.videoRanges[G]>0))return Ri(P,`no variants with VIDEO-RANGE of ${lt(y)} found`),w;if(d&&P.indexOf(d.substring(0,4))%5!==0)return Ri(P,`video codec preference "${d}" not found`),w;if(k.maxScore<g)return Ri(P,`max score of ${k.maxScore} < selected max of ${g}`),w}return w&&(ll(P)>=ll(w)||k.fragmentError>s[w].fragmentError)?w:(p=k.minIndex,g=k.maxScore,P)},void 0),videoRanges:y,preferHDR:T,minFramerate:f,minBitrate:m,minIndex:p}}function Ri(s,e){et.log(`[abr] start candidates with "${s}" ignored because ${e}`)}function Xp(s){return s.reduce((e,t)=>{let i=e.groups[t.groupId];i||(i=e.groups[t.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),i.tracks.push(t);const n=t.channels||"2";return i.channels[n]=(i.channels[n]||0)+1,i.hasDefault=i.hasDefault||t.default,i.hasAutoSelect=i.hasAutoSelect||t.autoselect,i.hasDefault&&(e.hasDefaultAudio=!0),i.hasAutoSelect&&(e.hasAutoSelectAudio=!0),e},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function NA(s,e,t,i){return s.slice(t,i+1).reduce((n,r,a)=>{if(!r.codecSet)return n;const o=r.audioGroups;let d=n[r.codecSet];d||(n[r.codecSet]=d={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,minIndex:a,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!o,fragmentError:0}),d.minBitrate=Math.min(d.minBitrate,r.bitrate);const l=Math.min(r.height,r.width);return d.minHeight=Math.min(d.minHeight,l),d.minFramerate=Math.min(d.minFramerate,r.frameRate),d.minIndex=Math.min(d.minIndex,a),d.maxScore=Math.max(d.maxScore,r.score),d.fragmentError+=r.fragmentError,d.videoRanges[r.videoRange]=(d.videoRanges[r.videoRange]||0)+1,o&&o.forEach(c=>{if(!c)return;const u=e.groups[c];u&&(d.hasDefaultAudio=d.hasDefaultAudio||e.hasDefaultAudio?u.hasDefault:u.hasAutoSelect||!e.hasDefaultAudio&&!e.hasAutoSelectAudio,Object.keys(u.channels).forEach(h=>{d.channels[h]=(d.channels[h]||0)+u.channels[h]}))}),n},{})}function ff(s){if(!s)return s;const{lang:e,assocLang:t,characteristics:i,channels:n,audioCodec:r}=s;return{lang:e,assocLang:t,characteristics:i,channels:n,audioCodec:r}}function qi(s,e,t){if("attrs"in s){const i=e.indexOf(s);if(i!==-1)return i}for(let i=0;i<e.length;i++){const n=e[i];if(js(s,n,t))return i}return-1}function js(s,e,t){const{groupId:i,name:n,lang:r,assocLang:a,default:o}=s,d=s.forced;return(i===void 0||e.groupId===i)&&(n===void 0||e.name===n)&&(r===void 0||UA(r,e.lang))&&(r===void 0||e.assocLang===a)&&(o===void 0||e.default===o)&&(d===void 0||e.forced===d)&&(!("characteristics"in s)||BA(s.characteristics||"",e.characteristics))&&(t===void 0||t(s,e))}function UA(s,e="--"){return s.length===e.length?s===e:s.startsWith(e)||e.startsWith(s)}function BA(s,e=""){const t=s.split(","),i=e.split(",");return t.length===i.length&&!t.some(n=>i.indexOf(n)===-1)}function Gs(s,e){const{audioCodec:t,channels:i}=s;return(t===void 0||(e.audioCodec||"").substring(0,4)===t.substring(0,4))&&(i===void 0||i===(e.channels||"2"))}function GA(s,e,t,i,n){const r=e[i],o=e.reduce((h,f,m)=>{const p=f.uri;
vendor: 5,750 bytes, lines 1484-1494
1484return(h[p]||(h[p]=[])).push(m),h},{})[r.uri];o.length>1&&(i=Math.max.apply(Math,o));const d=r.videoRange,l=r.frameRate,c=r.codecSet.substring(0,4),u=mf(e,i,h=>{if(h.videoRange!==d||h.frameRate!==l||h.codecSet.substring(0,4)!==c)return!1;const f=h.audioGroups,m=t.filter(p=>!f||f.indexOf(p.groupId)!==-1);return qi(s,m,n)>-1});return u>-1?u:mf(e,i,h=>{const f=h.audioGroups,m=t.filter(p=>!f||f.indexOf(p.groupId)!==-1);return qi(s,m,n)>-1})}function mf(s,e,t){for(let i=e;i>-1;i--)if(t(s[i]))return i;for(let i=e+1;i<s.length;i++)if(t(s[i]))return i;return-1}function ul(s,e){var t;return!!s&&s!==((t=e.loadLevelObj)==null?void 0:t.uri)}class KA extends pi{constructor(e){super("abr",e.logger),this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=-1,this.firstSelection=-1,this._nextAutoLevel=-1,this.nextAutoLevelKey="",this.audioTracksByGroup=null,this.codecTiers=null,this.timer=-1,this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.rebufferNotice=-1,this.supportedCache={},this.bwEstimator=void 0,this._abandonRulesCheck=t=>{var i;const{fragCurrent:n,partCurrent:r,hls:a}=this,{autoLevelEnabled:o,media:d}=a;if(!n||!d)return;const l=performance.now(),c=r?r.stats:n.stats,u=r?r.duration:n.duration,h=l-c.loading.start,f=a.minAutoLevel,m=n.level,p=this._nextAutoLevel;if(c.aborted||c.loaded&&c.loaded===c.total||m<=f){this.clearTimer(),this._nextAutoLevel=-1;return}if(!o)return;const g=p>-1&&p!==m,y=!!t||g;if(!y&&(d.paused||!d.playbackRate||!d.readyState))return;const T=a.mainForwardBufferInfo;if(!y&&T===null)return;const _=this.bwEstimator.getEstimateTTFB(),I=Math.abs(d.playbackRate);if(h<=Math.max(_,1e3*(u/(I*2))))return;const R=T?T.len/I:0,F=c.loading.first?c.loading.first-c.loading.start:-1,L=c.loaded&&F>-1,w=this.getBwEstimate(),P=a.levels,k=P[m],G=Math.max(c.loaded,Math.round(u*(n.bitrate||k.averageBitrate)/8));let se=L?h-F:h;se<1&&L&&(se=Math.min(h,c.loaded*8/w));const oe=L?c.loaded*1e3/se:0,de=_/1e3,ae=oe?(G-c.loaded)/oe:G*8/w+de;if(ae<=R)return;const ie=oe?oe*8:w,ue=((i=t?.details||this.hls.latestLevelDetails)==null?void 0:i.live)===!0,ee=this.hls.config.abrBandWidthUpFactor;let te=Number.POSITIVE_INFINITY,ve;for(ve=m-1;ve>f;ve--){const De=P[ve].maxBitrate,Re=!P[ve].details||ue;if(te=this.getTimeToLoadFrag(de,ie,u*De,Re),te<Math.min(R,u+de))break}if(te>=ae||te>u*10)return;L?this.bwEstimator.sample(h-Math.min(_,F),c.loaded):this.bwEstimator.sampleTTFB(h);const X=P[ve].maxBitrate;this.getBwEstimate()*ee>X&&this.resetEstimator(X);const Y=this.findBestLevel(X,f,ve,0,R,1,1);Y>-1&&(ve=Y),this.warn(`Fragment ${n.sn}${r?" part "+r.index:""} of level ${m} is loading too slowly; 1485 Fragment duration: ${n.duration.toFixed(3)} 1486 Time to underbuffer: ${R.toFixed(3)} s 1487 Estimated load time for current fragment: ${ae.toFixed(3)} s 1488 Estimated load time for down switch fragment: ${te.toFixed(3)} s 1489 TTFB estimate: ${F|0} ms 1490 Current BW estimate: ${he(w)?w|0:"Unknown"} bps 1491 New BW estimate: ${this.getBwEstimate()|0} bps 1492 Switching to level ${ve} @ ${X|0} bps`),a.nextLoadLevel=a.nextAutoLevel=ve,this.clearTimer();const Ie=()=>{if(this.clearTimer(),this.fragCurrent===n&&this.hls.loadLevel===ve&&ve>0){const De=this.getStarvationDelay();if(this.warn(`Aborting inflight request ${ve>0?"and switching down":""} 1493 Fragment duration: ${n.duration.toFixed(3)} s 1494 Time to underbuffer: ${De.toFixed(3)} s`),n.abortRequests(),this.fragCurrent=this.partCurrent=null,ve>f){let Re=this.findBestLevel(this.hls.levels[f].bitrate,f,ve,0,De,1,1);Re===-1&&(Re=f),this.hls.nextLoadLevel=this.hls.nextAutoLevel=Re,this.resetEstimator(this.hls.levels[Re].bitrate)}}};g||ae>te*2?Ie():this.timer=self.setInterval(Ie,te*1e3),a.trigger(v.FRAG_LOAD_EMERGENCY_ABORTED,{frag:n,part:r,stats:c})},this.hls=e,this.bwEstimator=this.initEstimator(),this.registerListeners()}resetEstimator(e){e&&(this.log(`setting initial bwe to ${e}`),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()}initEstimator(){const e=this.hls.config;return new YS(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}registerListeners(){const{hls:e}=this;e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.FRAG_LOADING,this.onFragLoading,this),e.on(v.FRAG_LOADED,this.onFragLoaded,this),e.on(v.FRAG_BUFFERED,this.onFragBuffered,this),e.on(v.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(v.LEVEL_LOADED,this.onLevelLoaded,this),e.on(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(v.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(v.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e&&(e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.FRAG_LOADING,this.onFragLoading,this),e.off(v.FRAG_LOADED,this.onFragLoaded,this),e.off(v.FRAG_BUFFERED,this.onFragBuffered,this),e.off(v.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(v.LEVEL_LOADED,this.onLevelLoaded,this),e.off(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(v.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(v.ERROR,this.onError,this))}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=this.supportedCache=null,this.fragCurrent=this.partCurrent=null}onManifestLoading(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.supportedCache={},this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()}onLevelsUpdated(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null}onMaxAutoLevelUpdated(){this.firstSelection=-1,this.nextAutoLevelKey=""}onFragLoading(e,t){const i=t.frag;
vendor: 3,237 bytes, line 1494
1494if(!this.ignoreFragment(i)){if(!i.bitrateTest){var n;this.fragCurrent=i,this.partCurrent=(n=t.part)!=null?n:null}this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100)}}onLevelSwitching(e,t){this.clearTimer()}onError(e,t){if(!t.fatal)switch(t.details){case $.BUFFER_ADD_CODEC_ERROR:case $.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case $.FRAG_LOAD_TIMEOUT:{const i=t.frag,{fragCurrent:n,partCurrent:r}=this;if(i&&n&&i.sn===n.sn&&i.level===n.level){const a=performance.now(),o=r?r.stats:i.stats,d=a-o.loading.start,l=o.loading.first?o.loading.first-o.loading.start:-1;if(o.loaded&&l>-1){const u=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(d-Math.min(u,l),o.loaded)}else this.bwEstimator.sampleTTFB(d)}break}}}getTimeToLoadFrag(e,t,i,n){const r=e+i/t,a=n?e+this.lastLevelLoadSec:0;return r+a}onLevelLoaded(e,t){const i=this.hls.config,{loading:n}=t.stats,r=n.end-n.first;he(r)&&(this.lastLevelLoadSec=r/1e3),t.details.live?this.bwEstimator.update(i.abrEwmaSlowLive,i.abrEwmaFastLive):this.bwEstimator.update(i.abrEwmaSlowVoD,i.abrEwmaFastVoD),this.timer>-1&&this._abandonRulesCheck(t.levelInfo)}onFragLoaded(e,{frag:t,part:i}){const n=i?i.stats:t.stats;if(t.type===ge.MAIN&&this.bwEstimator.sampleTTFB(n.loading.first-n.loading.start),!this.ignoreFragment(t)){if(this.clearTimer(),t.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){const r=i?i.duration:t.duration,a=this.hls.levels[t.level],o=(a.loaded?a.loaded.bytes:0)+n.loaded,d=(a.loaded?a.loaded.duration:0)+r;a.loaded={bytes:o,duration:d},a.realBitrate=Math.round(8*o/d)}if(t.bitrateTest){const r={stats:n,frag:t,part:i,id:t.type};this.onFragBuffered(v.FRAG_BUFFERED,r),t.bitrateTest=!1}else this.lastLoadedFragLevel=t.level}}onFragBuffered(e,t){const{frag:i,part:n}=t,r=n!=null&&n.stats.loaded?n.stats:i.stats;if(r.aborted||this.ignoreFragment(i))return;const a=r.parsing.end-r.loading.start-Math.min(r.loading.first-r.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(a,r.loaded),r.bwEstimate=this.getBwEstimate(),i.bitrateTest?this.bitrateTestDelay=a/1e3:this.bitrateTestDelay=0}ignoreFragment(e){return e.type!==ge.MAIN||e.sn==="initSegment"}clearTimer(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)}get firstAutoLevel(){const{maxAutoLevel:e,minAutoLevel:t}=this.hls,i=this.getBwEstimate(),n=this.hls.config.maxStarvationDelay,r=this.findBestLevel(i,t,e,0,n,1,1);if(r>-1)return r;const a=this.hls.firstLevel,o=Math.min(Math.max(a,t),e);return this.warn(`Could not find best starting auto level. Defaulting to first in playlist ${a} clamped to ${o}`),o}get forcedAutoLevel(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}get nextAutoLevel(){const e=this.forcedAutoLevel,i=this.bwEstimator.canEstimate(),n=this.lastLoadedFragLevel>-1;if(e!==-1&&(!i||!n||this.nextAutoLevelKey===this.getAutoLevelKey()))return e;const r=i&&n?this.getNextABRAutoLevel():this.firstAutoLevel;if(e!==-1){const a=this.hls.levels;if(a.length>Math.max(e,r)&&a[e].loadError<=a[r].loadError)return e}return this._nextAutoLevel=r,this.nextAutoLevelKey=this.getAutoLevelKey(),r}getAutoLevelKey(){return`${this.getBwEstimate()}
1494_${this.getStarvationDelay().toFixed(2)}`}getNextABRAutoLevel(){const{fragCurrent:e,partCurrent:t,hls:i}=this;if(i.levels.length<=1)return i.loadLevel;const{maxAutoLevel:n,config:r,minAutoLevel:a}=i,o=t?t.duration:e?e.duration:0,d=this.getBwEstimate(),l=this.getStarvationDelay();let c=r.abrBandWidthFactor,u=r.abrBandWidthUpFactor;if(l){const g=this.findBestLevel(d,a,n,l,0,c,u);if(g>=0)return this.rebufferNotice=-1,g}let h=o?Math.min(o,r.maxStarvationDelay):r.maxStarvationDelay;if(!l){const g=this.bitrateTestDelay;g&&(h=(o?Math.min(o,r.maxLoadingDelay):r.maxLoadingDelay)-g,this.info(`bitrate test took ${Math.round(1e3*g)}ms, set first fragment max fetchDuration to ${Math.round(1e3*h)} ms`),c=u=1)}const f=this.findBestLevel(d,a,n,l,h,c,u);if(this.rebufferNotice!==f&&(this.rebufferNotice=f,this.info(`${l?"rebuffering expected":"buffer is empty"}, optimal quality level ${f}`)),f>-1)return f;const m=i.levels[a],p=i.loadLevelObj;return p&&m?.bitrate<p.bitrate?a:i.loadLevel}getStarvationDelay(){const e=this.hls,t=e.media;if(!t)return 1/0;const i=t&&t.playbackRate!==0?Math.abs(t.playbackRate):1,n=e.mainForwardBufferInfo;return(n?n.len:0)/i}getBwEstimate(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate}findBestLevel(e,t,i,n,r,a,o){var d;const l=n+r,c=this.lastLoadedFragLevel,u=c===-1?this.hls.firstLevel:c,{fragCurrent:h,partCurrent:f}=this,{levels:m,allAudioTracks:p,loadLevel:g,config:y}=this.hls;if(m.length===1)return 0;const T=m[u],_=!!((d=this.hls.latestLevelDetails)!=null&&d.live),I=g===-1||c===-1;let R,F="SDR",L=T?.frameRate||0;const{audioPreference:w,videoPreference:P}=y,k=this.audioTracksByGroup||(this.audioTracksByGroup=Xp(p));let G=-1;if(I){if(this.firstSelection!==-1)return this.firstSelection;const ie=this.codecTiers||(this.codecTiers=NA(m,k,t,i)),ue=$A(ie,F,e,w,P),{codecSet:ee,videoRanges:te,minFramerate:ve,minBitrate:X,minIndex:Y,preferHDR:Ie}=ue;G=Y,R=ee,F=Ie?te[te.length-1]:te[0],L=ve,e=Math.max(e,X),this.log(`picked start tier ${lt(ue)}`)}else R=T?.codecSet,F=T?.videoRange;const se=f?f.duration:h?h.duration:0,oe=this.bwEstimator.getEstimateTTFB()/1e3,de=[];for(let ie=i;ie>=t;ie--){var ae;const ue=m[ie],ee=ie>u;if(!ue)continue;if(y.useMediaCapabilities&&!ue.supportedResult&&!ue.supportedPromise){const Re=navigator.mediaCapabilities;typeof Re?.decodingInfo=="function"&&LA(ue,k,F,L,e,w)?(ue.supportedPromise=zp(ue,k,Re,this.supportedCache),ue.supportedPromise.then(Ce=>{if(!this.hls)return;ue.supportedResult=Ce;const dt=this.hls.levels,je=dt.indexOf(ue);Ce.error?this.warn(`MediaCapabilities decodingInfo error: "${Ce.error}" for level ${je} ${lt(Ce)}`):Ce.supported?Ce.decodingInfoResults.some(ne=>ne.smooth===!1||ne.powerEfficient===!1)&&this.log(`MediaCapabilities decodingInfo for level ${je} not smooth or powerEfficient: ${lt(Ce)}`):(this.warn(`Unsupported MediaCapabilities decodingInfo result for level ${je} ${lt(Ce)}`),je>-1&&dt.length>1&&(this.log(`Removing unsupported level ${je}`),this.hls.removeLevel(je),this.hls.loadLevel===-1&&(this.hls.nextLoadLevel=0)))}).catch(Ce=>{this.warn(`Error handling MediaCapabilities decodingInfo: ${Ce}`)})):ue.supportedResult=qp}if((R&&ue.codecSet!==R||F&&ue.videoRange!==F||ee&&L>ue.frameRate||!ee&&L>0&&L<ue.frameRate||(ae=ue.supportedResult)!=null&&(ae=ae.decodingInfoResults)!=null&&ae.some(Re=>Re.smooth===!1))&&(!I||ie!==G)){de.push(ie);continue}const te=ue.details,ve=(f?te?.partTarget:te?.averagetargetduration)||se;let X;ee?X=o*e:X=a*e;const Y=se&&n>=se*2&&r===0?ue.averageBitrate:ue.maxBitrate,Ie=this.getTimeToLoadFrag(oe,X,Y*ve,te===void 0);if(X>=Y&&(ie===c||ue.loadError===0&&ue.fragmentError===0)&&(Ie<=oe||!he(Ie)||_&&!this.bitrateTestDelay||Ie<l)){const Re=this.forcedAutoLevel;return ie!==g&&(Re===-1||Re!==g)&&(de.length&&this.trace(`Skipped level(s) ${de.join(",")} of ${i} max with CODECS and VIDEO-RANGE:"${m[de[0]].codecs}" ${m[de[0]].videoRange}; not compatible with "${R}" ${F}`),this.info(`switch candidate:${u}->${ie} adjustedbw(${Math.round(X)})-bitrate=${Math.round(X-Y)} ttfb:${oe.toFixed(1)} avgDuration:${ve.toFixed(1)} maxFetchDuration:${l.toFixed(1)} fetchDuration:${Ie.toFixed(1)}
1494 firstSelection:${I} codecSet:${ue.codecSet} videoRange:${ue.videoRange} hls.loadLevel:${g}`)),I&&(this.firstSelection=ie),ie}}return-1}set nextAutoLevel(e){const t=this.deriveNextAutoLevel(e);this._nextAutoLevel!==t&&(this.nextAutoLevelKey="",this._nextAutoLevel=t)}deriveNextAutoLevel(e){const{maxAutoLevel:t,minAutoLevel:i}=this.hls;return Math.min(Math.max(e,i),t)}}const Qp={search:function(s,e){let t=0,i=s.length-1,n=null,r=null;for(;t<=i;){n=(t+i)/2|0,r=s[n];const a=e(r);if(a>0)t=n+1;else if(a<0)i=n-1;else return r}return null}};function HA(s,e,t){if(e===null||!Array.isArray(s)||!s.length||!he(e))return null;const i=s[0].programDateTime;if(e<(i||0))return null;const n=s[s.length-1].endProgramDateTime;if(e>=(n||0))return null;for(let r=0;r<s.length;++r){const a=s[r];if(WA(e,t,a))return a}return null}function Qs(s,e,t=0,i=0,n=.005){let r=null;if(s){r=e[1+s.sn-e[0].sn]||null;const o=s.endDTS-t;o>0&&o<15e-7&&(t+=15e-7),r&&s.level!==r.level&&r.end<=s.end&&(r=e[2+s.sn-e[0].sn]||null)}else t===0&&e[0].start===0&&(r=e[0]);if(r&&((!s||s.level===r.level)&&gf(t,i,r)===0||VA(r,s,Math.min(n,i))))return r;const a=Qp.search(e,gf.bind(null,t,i));return a&&(a!==s||!r)?a:r}function VA(s,e,t){if(e&&e.start===0&&e.level<s.level&&(e.endPTS||0)>0){const i=e.tagList.reduce((n,r)=>(r[0]==="INF"&&(n+=parseFloat(r[1])),n),t);return s.start<=i}return!1}function gf(s=0,e=0,t){if(t.start<=s&&t.start+t.duration>s)return 0;const i=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0));return t.start+t.duration-i<=s?1:t.start-i>s&&t.start?-1:0}function WA(s,e,t){const i=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0))*1e3;return(t.endProgramDateTime||0)-i>s}function Zp(s,e,t){if(s&&s.startCC<=e&&s.endCC>=e){let i=s.fragments;const{fragmentHint:n}=s;n&&(i=i.concat(n));let r;return Qp.search(i,a=>a.cc<e?1:a.cc>e?-1:(r=a,a.end<=t?1:a.start>t?-1:0)),r||null}return null}function hl(s){switch(s.details){case $.FRAG_LOAD_TIMEOUT:case $.KEY_LOAD_TIMEOUT:case $.LEVEL_LOAD_TIMEOUT:case $.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function Jp(s){return s.details.startsWith("key")}function ev(s){return Jp(s)&&!!s.frag&&!s.frag.decryptdata}function pf(s,e){const t=hl(e);return s.default[`${t?"timeout":"error"}Retry`]}function wu(s,e){const t=s.backoff==="linear"?1:Math.pow(2,e);return Math.min(t*s.retryDelayMs,s.maxRetryDelayMs)}function vf(s){return Je(Je({},s),{errorRetry:null,timeoutRetry:null})}function fl(s,e,t,i){if(!s)return!1;const n=i?.code,r=e<s.maxNumRetry&&(qA(n)||!!t);return s.shouldRetry?s.shouldRetry(s,e,t,i,r):r}function qA(s){return Pc(s)||!!s&&(s<400||s>499)}function Pc(s){return s===0&&navigator.onLine===!1}var Ut={DoNothing:0,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,RetryRequest:5},ri={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,MoveAllAlternatesMatchingKey:4};class YA extends pi{constructor(e){super("error-controller",e.logger),this.hls=void 0,this.playlistError=0,this.hls=e,this.registerListeners()}registerListeners(){const e=this.hls;e.on(v.ERROR,this.onError,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const e=this.hls;e&&(e.off(v.ERROR,this.onError,this),e.off(v.ERROR,this.onErrorOut,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null}startLoad(e){}stopLoad(){this.playlistError=0}getVariantLevelIndex(e){return e?.type===ge.MAIN?e.level:this.getVariantIndex()}getVariantIndex(){var e;const t=this.hls,i=t.currentLevel;return(e=t.loadLevelObj)!=null&&e.details||i===-1?t.loadLevel:i}variantHasKey(e,t){if(e){var i;if((i=e.details)!=null&&i.hasKey(t))return!0;const n=e.audioGroups;if(n)return this.hls.allAudioTracks.filter(a=>n.indexOf(a.groupId)>=0).some(a=>{var o;return(o=a.details)==null?void 0:o.hasKey(t)})}return!1}onManifestLoading(){this.playlistError=0}onLevelUpdated(){this.playlistError=0}onError(e,t){var i;if(t.fatal)return;const n=this.hls,r=t.context;switch(t.details){case $.FRAG_LOAD_ERROR:case $.FRAG_LOAD_TIMEOUT:case $.
vendor: 4,726 bytes, line 1494
1494KEY_LOAD_ERROR:case $.KEY_LOAD_TIMEOUT:t.errorAction=this.getFragRetryOrSwitchAction(t);return;case $.FRAG_PARSING_ERROR:if((i=t.frag)!=null&&i.gap){t.errorAction=$n();return}case $.FRAG_GAP:case $.FRAG_DECRYPT_ERROR:{t.errorAction=this.getFragRetryOrSwitchAction(t),t.errorAction.action=Ut.SendAlternateToPenaltyBox;return}case $.LEVEL_EMPTY_ERROR:case $.LEVEL_PARSING_ERROR:{var a;const d=t.parent===ge.MAIN?t.level:n.loadLevel;t.details===$.LEVEL_EMPTY_ERROR&&((a=t.context)!=null&&(a=a.levelDetails)!=null&&a.live)?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,d):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,d))}return;case $.LEVEL_LOAD_ERROR:case $.LEVEL_LOAD_TIMEOUT:typeof r?.level=="number"&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,r.level));return;case $.AUDIO_TRACK_LOAD_ERROR:case $.AUDIO_TRACK_LOAD_TIMEOUT:case $.SUBTITLE_LOAD_ERROR:case $.SUBTITLE_TRACK_LOAD_TIMEOUT:if(r){const d=n.loadLevelObj;if(d&&(r.type===Ge.AUDIO_TRACK&&d.hasAudioGroup(r.groupId)||r.type===Ge.SUBTITLE_TRACK&&d.hasSubtitleGroup(r.groupId))){t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.loadLevel),t.errorAction.action=Ut.SendAlternateToPenaltyBox,t.errorAction.flags=ri.MoveAllAlternatesMatchingHost;return}}return;case $.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:t.errorAction={action:Ut.SendAlternateToPenaltyBox,flags:ri.MoveAllAlternatesMatchingHDCP};return;case $.KEY_SYSTEM_SESSION_UPDATE_FAILED:case $.KEY_SYSTEM_STATUS_INTERNAL_ERROR:case $.KEY_SYSTEM_NO_SESSION:t.errorAction={action:Ut.SendAlternateToPenaltyBox,flags:ri.MoveAllAlternatesMatchingKey};return;case $.BUFFER_ADD_CODEC_ERROR:case $.REMUX_ALLOC_ERROR:case $.BUFFER_APPEND_ERROR:if(!t.errorAction){var o;t.errorAction=this.getLevelSwitchAction(t,(o=t.level)!=null?o:n.loadLevel)}return;case $.INTERNAL_EXCEPTION:case $.BUFFER_APPENDING_ERROR:case $.BUFFER_FULL_ERROR:case $.LEVEL_SWITCH_ERROR:case $.BUFFER_STALLED_ERROR:case $.BUFFER_SEEK_OVER_HOLE:case $.BUFFER_NUDGE_ON_STALL:t.errorAction=$n();return}t.type===ye.KEY_SYSTEM_ERROR&&(t.levelRetry=!1,t.errorAction=$n())}getPlaylistRetryOrSwitchAction(e,t){const i=this.hls,n=pf(i.config.playlistLoadPolicy,e),r=this.playlistError++;if(fl(n,r,hl(e),e.response))return{action:Ut.RetryRequest,flags:ri.None,retryConfig:n,retryCount:r};const o=this.getLevelSwitchAction(e,t);return n&&(o.retryConfig=n,o.retryCount=r),o}getFragRetryOrSwitchAction(e){const t=this.hls,i=this.getVariantLevelIndex(e.frag),n=t.levels[i],{fragLoadPolicy:r,keyLoadPolicy:a}=t.config,o=pf(Jp(e)?a:r,e),d=t.levels.reduce((c,u)=>c+u.fragmentError,0);if(n&&(e.details!==$.FRAG_GAP&&n.fragmentError++,!ev(e)&&fl(o,d,hl(e),e.response)))return{action:Ut.RetryRequest,flags:ri.None,retryConfig:o,retryCount:d};const l=this.getLevelSwitchAction(e,i);return o&&(l.retryConfig=o,l.retryCount=d),l}getLevelSwitchAction(e,t){const i=this.hls;t==null&&(t=i.loadLevel);const n=this.hls.levels[t];if(n){var r,a;const l=e.details;n.loadError++,l===$.BUFFER_APPEND_ERROR&&n.fragmentError++;let c=-1;const{levels:u,loadLevel:h,minAutoLevel:f,maxAutoLevel:m}=i;!i.autoLevelEnabled&&!i.config.preserveManualLevelOnError&&(i.loadLevel=-1);const p=(r=e.frag)==null?void 0:r.type,y=(p===ge.AUDIO&&l===$.FRAG_PARSING_ERROR||e.sourceBufferName==="audio"&&(l===$.BUFFER_ADD_CODEC_ERROR||l===$.BUFFER_APPEND_ERROR))&&u.some(({audioCodec:F})=>n.audioCodec!==F),_=e.sourceBufferName==="video"&&(l===$.BUFFER_ADD_CODEC_ERROR||l===$.BUFFER_APPEND_ERROR)&&u.some(({codecSet:F,audioCodec:L})=>n.codecSet!==F&&n.audioCodec===L),{type:I,groupId:R}=(a=e.context)!=null?a:{};for(let F=u.length;F--;){const L=(F+h)%u.length;if(L!==h&&L>=f&&L<=m&&u[L].loadError===0){var o,d;const w=u[L];if(l===$.FRAG_GAP&&p===ge.MAIN&&e.frag){const P=u[L].details;if(P){const k=Qs(e.frag,P.fragments,e.frag.start);if(k!=null&&k.gap)continue}}else{if(I===Ge.AUDIO_TRACK&&w.hasAudioGroup(R)||I===Ge.SUBTITLE_TRACK&&w.hasSubtitleGroup(R))continue;if(p===ge.AUDIO&&(o=n.audioGroups)!=null&&o.some(P=>w.hasAudioGroup(P))||p===ge.SUBTITLE&&(d=n.subtitleGroups)!=null&&d.some(P=>w.hasSubtitleGroup(P))||y&&n.audioCodec===w.audioCodec||_&&n.codecSet===w.codecSet||!y&&n.codecSet!==w.codecSet)continue}c=L;break}}if(c>-1&&i.loadLevel!==c)return e.levelRetry=!0,this.playlistError=0,{action:Ut.SendAlternateToPenaltyBox,flags:ri.None,nextAutoLevel:c}}return{action:Ut.SendAlternateToPenaltyBox,flags:ri.MoveAllAlternatesMatchingHost}}onErrorOut(e,t){var i;switch((i=t.errorAction)==null?void 0:i.action){case Ut.DoNothing:break;case Ut.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(t),!t.errorAction.resolved&&t.details!==$.FRAG_GAP?t.fatal=!0:/MediaSource readyState: ended/.test(t.error.message)&&(this.warn(`MediaSource ended after "${t.sourceBufferName}
1494" sourceBuffer append error. Attempting to recover from media error.`),this.hls.recoverMediaError());break}if(t.fatal){this.hls.stopLoad();return}}sendAlternateToPenaltyBox(e){const t=this.hls,i=e.errorAction;if(!i)return;const{flags:n}=i,r=i.nextAutoLevel;switch(n){case ri.None:this.switchLevel(e,r);break;case ri.MoveAllAlternatesMatchingHDCP:{const d=this.getVariantLevelIndex(e.frag),l=t.levels[d],c=l?.attrs["HDCP-LEVEL"];if(i.hdcpLevel=c,c==="NONE")this.warn("HDCP policy resticted output with HDCP-LEVEL=NONE");else if(c){t.maxHdcpLevel=wc[wc.indexOf(c)-1],i.resolved=!0,this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`);break}}case ri.MoveAllAlternatesMatchingKey:{const d=e.decryptdata;if(d){const l=this.hls.levels,c=l.length;for(let h=c;h--;)if(this.variantHasKey(l[h],d)){var a,o;this.log(`Banned key found in level ${h} (${l[h].bitrate}bps) or audio group "${(a=l[h].audioGroups)==null?void 0:a.join(",")}" (${(o=e.frag)==null?void 0:o.type} fragment) ${Bt(d.keyId||[])}`),l[h].fragmentError++,l[h].loadError++,this.log(`Removing level ${h} with key error (${e.error})`),this.hls.removeLevel(h)}const u=e.frag;if(this.hls.levels.length<c)i.resolved=!0;else if(u&&u.type!==ge.MAIN){const h=u.decryptdata;h&&!d.matches(h)&&(i.resolved=!0)}}break}}i.resolved||this.switchLevel(e,r)}switchLevel(e,t){if(t!==void 0&&e.errorAction&&(this.warn(`switching to level ${t} after ${e.details}`),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel,e.details===$.BUFFER_ADD_CODEC_ERROR&&e.mimeType&&e.sourceBufferName!=="audiovideo")){const i=Cc(e.mimeType),n=this.hls.levels;for(let r=n.length;r--;)n[r][`${e.sourceBufferName}Codec`]===i&&(this.log(`Removing level ${r} for ${e.details} ("${i}" not supported)`),this.hls.removeLevel(r))}}}function $n(s){const e={action:Ut.DoNothing,flags:ri.None};return s&&(e.resolved=!0),e}var Rt={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"};class zA{constructor(e){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=e,this._registerListeners()}_registerListeners(){const{hls:e}=this;e&&(e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.BUFFER_APPENDED,this.onBufferAppended,this),e.on(v.FRAG_BUFFERED,this.onFragBuffered,this),e.on(v.FRAG_LOADED,this.onFragLoaded,this))}_unregisterListeners(){const{hls:e}=this;e&&(e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.BUFFER_APPENDED,this.onBufferAppended,this),e.off(v.FRAG_BUFFERED,this.onFragBuffered,this),e.off(v.FRAG_LOADED,this.onFragLoaded,this))}destroy(){this._unregisterListeners(),this.hls=this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(e,t){const i=this.activePartLists[t];if(i)for(let n=i.length;n--;){const r=i[n];if(!r)break;if(r.start<=e&&e<=r.end&&r.loaded)return r}return this.getBufferedFrag(e,t)}getBufferedFrag(e,t){return this.getFragAtPos(e,t,!0)}getFragAtPos(e,t,i){const{fragments:n}=this,r=Object.keys(n);for(let a=r.length;a--;){const o=n[r[a]];if(o?.body.type===t&&(!i||o.buffered)){const d=o.body;if(d.start<=e&&e<=d.end)return d}}return null}detectEvictedFragments(e,t,i,n,r){this.timeRanges&&(this.timeRanges[e]=t);const a=n?.fragment.sn||-1;Object.keys(this.fragments).forEach(o=>{const d=this.fragments[o];if(!d||a>=d.body.sn)return;if(!d.buffered&&(!d.loaded||r)){d.body.type===i&&this.removeFragment(d.body);return}const l=d.range[e];if(l){if(l.time.length===0){this.removeFragment(d.body);return}l.time.some(c=>{const u=!this.isTimeBuffered(c.startPTS,c.endPTS,t);return u&&this.removeFragment(d.body),u})}})}detectPartialFragments(e){const t=this.timeRanges;if(!t||e.frag.sn==="initSegment")return;const i=e.frag,n=ln(i),r=this.fragments[n];if(!r||r.buffered&&i.gap)return;const a=!i.relurl;Object.keys(t).forEach(o=>{const d=i.elementaryStreams[o];if(!d)return;const l=t[o],c=a||d.partial===!0;r.range[o]=this.getBufferedTimes(i,e.part,c,l)}),r.loaded=null,Object.keys(r.range).length?(this.bufferedEnd(r,i),Da(r)||this.removeParts(i.sn-1,i.type)):this.removeFragment(r.body)}bufferedEnd(e,t){e.buffered=!0,(e.body.endList=t.endList||e.body.endList)&&(this.endListFragments[e.body.type]=e)}removeParts(e,t){const i=this.activePartLists[t];i&&(this.activePartLists[t]=Ef(i,n=>n.fragment.sn>=e))}fragBuffered(e,t){const i=ln(e);let n=this.fragments[i];!n&&t&&(n=this.fragments[i]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),n&&(n.loaded=null,this.bufferedEnd(n,e))}getBufferedTimes(e,t,i,n){const r={time:[],partial:i},a=e.start,o=e.end,d=e.minEndPTS||o,l=e.maxStartPTS||a;for(let c=0;c<n.length;c++){const u=n.start(c)-this.bufferPadding,h=n.end(c)+this.bufferPadding;if(l>=u&&d<=h){r.time.push({startPTS:Math.max(a,n.start(c)),endPTS:Math.min(o,n.end(c))});break}else if(a<h&&o>u){const f=Math.max(a,n.start(c)),m=Math.min(o,n.end(c));m>f&&(r.partial=!0,r.time.push({startPTS:f,endPTS:m}))}else if(o<=u)break}return r}getPartialFragment(e){let t=null,i,n,r,a=0;const{bufferPadding:o,fragments:d}=this;
vendor: 6,014 bytes, line 1494
1494return Object.keys(d).forEach(l=>{const c=d[l];c&&Da(c)&&(n=c.body.start-o,r=c.body.end+o,e>=n&&e<=r&&(i=Math.min(e-n,r-e),a<=i&&(t=c.body,a=i)))}),t}isEndListAppended(e){const t=this.endListFragments[e];return t!==void 0&&(t.buffered||Da(t))}getState(e){const t=ln(e),i=this.fragments[t];return i?i.buffered?Da(i)?Rt.PARTIAL:Rt.OK:Rt.APPENDING:Rt.NOT_LOADED}isTimeBuffered(e,t,i){let n,r;for(let a=0;a<i.length;a++){if(n=i.start(a)-this.bufferPadding,r=i.end(a)+this.bufferPadding,e>=n&&t<=r)return!0;if(t<=n)return!1}return!1}onManifestLoading(){this.removeAllFragments()}onFragLoaded(e,t){if(t.frag.sn==="initSegment"||t.frag.bitrateTest)return;const i=t.frag,n=t.part?null:t,r=ln(i);this.fragments[r]={body:i,appendedPTS:null,loaded:n,buffered:!1,range:Object.create(null)}}onBufferAppended(e,t){const{frag:i,part:n,timeRanges:r,type:a}=t;if(i.sn==="initSegment")return;const o=i.type;if(n){let l=this.activePartLists[o];l||(this.activePartLists[o]=l=[]),l.push(n)}this.timeRanges=r;const d=r[a];this.detectEvictedFragments(a,d,o,n)}onFragBuffered(e,t){this.detectPartialFragments(t)}hasFragment(e){const t=ln(e);return!!this.fragments[t]}hasFragments(e){const{fragments:t}=this,i=Object.keys(t);if(!e)return i.length>0;for(let n=i.length;n--;){const r=t[i[n]];if(r?.body.type===e)return!0}return!1}hasParts(e){var t;return!!((t=this.activePartLists[e])!=null&&t.length)}removeFragmentsInRange(e,t,i,n,r){n&&!this.hasGaps||Object.keys(this.fragments).forEach(a=>{const o=this.fragments[a];if(!o)return;const d=o.body;d.type!==i||n&&!d.gap||d.start<t&&d.end>e&&(o.buffered||r)&&this.removeFragment(d)})}removeFragment(e){const t=ln(e);e.clearElementaryStreamInfo();const i=this.activePartLists[e.type];if(i){const n=e.sn;this.activePartLists[e.type]=Ef(i,r=>r.fragment.sn!==n)}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}removeAllFragments(){var e;this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1;const t=(e=this.hls)==null||(e=e.latestLevelDetails)==null?void 0:e.partList;t&&t.forEach(i=>i.clearElementaryStreamInfo())}}function Da(s){var e,t,i;return s.buffered&&!!(s.body.gap||(e=s.range.video)!=null&&e.partial||(t=s.range.audio)!=null&&t.partial||(i=s.range.audiovideo)!=null&&i.partial)}function ln(s){return`${s.type}_${s.level}_${s.sn}`}function Ef(s,e){return s.filter(t=>{const i=e(t);return i||t.clearElementaryStreamInfo(),i})}var Rs={cbc:0,ctr:1};class jA{constructor(e,t,i){this.subtle=void 0,this.aesIV=void 0,this.aesMode=void 0,this.subtle=e,this.aesIV=t,this.aesMode=i}decrypt(e,t){switch(this.aesMode){case Rs.cbc:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e);case Rs.ctr:return this.subtle.decrypt({name:"AES-CTR",counter:this.aesIV,length:64},t,e);default:throw new Error(`[AESCrypto] invalid aes mode ${this.aesMode}`)}}}function XA(s){const e=s.byteLength,t=e&&new DataView(s.buffer).getUint8(e-1);return t?s.slice(0,e-t):s}class QA{constructor(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}uint8ArrayToUint32Array_(e){const t=new DataView(e),i=new Uint32Array(4);for(let n=0;n<4;n++)i[n]=t.getUint32(n*4);return i}initTable(){const e=this.sBox,t=this.invSBox,i=this.subMix,n=i[0],r=i[1],a=i[2],o=i[3],d=this.invSubMix,l=d[0],c=d[1],u=d[2],h=d[3],f=new Uint32Array(256);let m=0,p=0,g=0;for(g=0;g<256;g++)g<128?f[g]=g<<1:f[g]=g<<1^283;for(g=0;g<256;g++){let y=p^p<<1^p<<2^p<<3^p<<4;y=y>>>8^y&255^99,e[m]=y,t[y]=m;const T=f[m],_=f[T],I=f[_];let R=f[y]*257^y*16843008;n[m]=R<<24|R>>>8,r[m]=R<<16|R>>>16,a[m]=R<<8|R>>>24,o[m]=R,R=I*16843009^_*65537^T*257^m*16843008,l[y]=R<<24|R>>>8,c[y]=R<<16|R>>>16,u[y]=R<<8|R>>>24,h[y]=R,m?(m=T^f[f[f[I^T]]],p^=f[f[p]]):m=p=1}}expandKey(e){const t=this.uint8ArrayToUint32Array_(e);let i=!0,n=0;for(;n<t.length&&i;)i=t[n]===this.key[n],n++;if(i)return;this.key=t;const r=this.keySize=t.length;if(r!==4&&r!==6&&r!==8)throw new Error("Invalid aes key size="+r);const a=this.ksRows=(r+6+1)*4;let o,d;const l=this.keySchedule=new Uint32Array(a),c=this.invKeySchedule=new Uint32Array(a),u=this.sBox,h=this.rcon,f=this.invSubMix,m=f[0],p=f[1],g=f[2],y=f[3];let T,_;for(o=0;o<a;o++){if(o<r){T=l[o]=t[o];continue}_=T,o%r===0?(_=_<<8|_>>>24,_=u[_>>>24]<<24|u[_>>>16&255]<<16|u[_>>>8&255]<<8|u[_&255],_^=h[o/r|0]<<24):r>6&&o%r===4&&(_=u[_>>>24]<<24|u[_>>>16&255]<<16|u[_>>>8&255]<<8|u[_&255]),l[o]=T=(l[o-r]^_)>>>0}for(d=0;d<a;d++)o=a-d,d&3?_=l[o]:_=l[o-4],d<4||o<=4?c[d]=_:c[d]=m[u[_>>>24]]^p[u[_>>>16&255]]^g[u[_>>>8&255]]^y[u[_&255]],c[d]=c[d]>>>0}networkToHostOrderSwap(e){return e<<24|(e&65280)<<8|(e&16711680)>>8|e>>>24}decrypt(e,t,i){const n=this.keySize+6,r=this.invKeySchedule,a=this.invSBox,o=this.invSubMix,d=o[0],l=o[1],c=o[2],u=o[3],h=this.uint8ArrayToUint32Array_(i);let f=h[0],m=h[1],p=h[2],g=h[3];const y=new Int32Array(e),T=new Int32Array(y.length);let _,I,R,F,L,w,P,k,G,se,oe,de,ae,ie;const ue=this.networkToHostOrderSwap;for(;t<y.length;){for(G=ue(y[t]),se=ue(y[t+1]),oe=ue(y[t+2]),de=ue(y[t+3]),L=G^r[0],w=de^r[1],P=oe^r[2],k=se^r[3],ae=4,ie=1;ie<n;ie++)_=d[L>>>24]^l[w>>16&255]^c[P>>8&255]^u[k&255]^r[ae],I=d[w>>>24]^l[P>>16&255]^c[k>>8&255]^u[L&255]^r[ae+1],R=d[P>>>24]^l[k>>16&255]^c[L>>8&255]^u[w&255]^r[ae+2],F=d[k>>>24]^l[L>>16&255]^c[w>>8&255]^u[P&255]^r[ae+3],L=_,w=I,P=R,k=F,ae=ae+4;_=a[L>>>24]<<24^a[w>>16&255]<<16^a[P>>8&255]<<8^a[k&255]^r[ae],I=a[w>>>24]<<24^a[P>>16&255]<<16^a[k>>8&255]<<8^a[L&255]^r[ae+1],R=a[P>>>24]<<24^a[k>>16&255]<<16^a[L>>8&255]<<8^a[w&255]^r[ae+2],F=a[k>>>24]<<24^a[L>>16&255]<<16^a[w>>8&255]<<8^a[P&255]^r[ae+3],T[t]=ue(_^f),T[t+1]=ue(F^m),T[t+2]=ue(R^p),T[t+3]=ue(I^g),f=G,m=se,p=oe,g=de,t
vendor: 16,269 bytes, line 1494
1494=t+4}return T.buffer}}class ZA{constructor(e,t,i){this.subtle=void 0,this.key=void 0,this.aesMode=void 0,this.subtle=e,this.key=t,this.aesMode=i}expandKey(){const e=JA(this.aesMode);return this.subtle.importKey("raw",this.key,{name:e},!1,["encrypt","decrypt"])}}function JA(s){switch(s){case Rs.cbc:return"AES-CBC";case Rs.ctr:return"AES-CTR";default:throw new Error(`[FastAESKey] invalid aes mode ${s}`)}}const eI=16;class Pu{constructor(e,{removePKCS7Padding:t=!0}={}){if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.enableSoftwareAES=void 0,this.enableSoftwareAES=e.enableSoftwareAES,this.removePKCS7Padding=t,t)try{const i=self.crypto;i&&(this.subtle=i.subtle||i.webkitSubtle)}catch{}this.useSoftware=!this.subtle}destroy(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}isSync(){return this.useSoftware}flush(){const{currentResult:e,remainderData:t}=this;if(!e||t)return this.reset(),null;const i=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?XA(i):i}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(e,t,i,n){return this.useSoftware?new Promise((r,a)=>{const o=ArrayBuffer.isView(e)?e:new Uint8Array(e);this.softwareDecrypt(o,t,i,n);const d=this.flush();d?r(d.buffer):a(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,i,n)}softwareDecrypt(e,t,i,n){const{currentIV:r,currentResult:a,remainderData:o}=this;if(n!==Rs.cbc||t.byteLength!==16)return et.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;this.logOnce("JS AES decrypt"),o&&(e=gi(o,e),this.remainderData=null);const d=this.getValidChunk(e);if(!d.length)return null;r&&(i=r);let l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new QA),l.expandKey(t);const c=a;return this.currentResult=l.decrypt(d.buffer,0,i),this.currentIV=d.slice(-16).buffer,c||null}webCryptoDecrypt(e,t,i,n){if(this.key!==t||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(e,t,i,n));this.key=t,this.fastAesKey=new ZA(this.subtle,t,n)}return this.fastAesKey.expandKey().then(r=>this.subtle?(this.logOnce("WebCrypto AES decrypt"),new jA(this.subtle,new Uint8Array(i),n).decrypt(e.buffer,r)):Promise.reject(new Error("web crypto not initialized"))).catch(r=>(et.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${r.name}: ${r.message}`),this.onWebCryptoError(e,t,i,n)))}onWebCryptoError(e,t,i,n){const r=this.enableSoftwareAES;if(r){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,i,n);const a=this.flush();if(a)return a.buffer}throw new Error("WebCrypto"+(r?" and softwareDecrypt":"")+": failed to decrypt data")}getValidChunk(e){let t=e;const i=e.length-e.length%eI;return i!==e.length&&(t=e.slice(0,i),this.remainderData=e.slice(i)),t}logOnce(e){this.logEnabled&&(et.log(`[decrypter]: ${e}`),this.logEnabled=!1)}}const yf=Math.pow(2,17);class tI{constructor(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(e,t){const i=e.url;if(!i)return Promise.reject(new rs({type:ye.NETWORK_ERROR,details:$.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error(`Fragment does not have a ${i?"part list":"url"}`),networkDetails:null}));this.abort();const n=this.config,r=n.fLoader,a=n.loader;return new Promise((o,d)=>{if(this.loader&&this.loader.destroy(),e.gap)if(e.tagList.some(m=>m[0]==="GAP")){d(bf(e));return}else e.gap=!1;const l=this.loader=r?new r(n):new a(n),c=Tf(e);e.loader=l;const u=vf(n.fragLoadPolicy.default),h={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:yf};e.stats=l.stats;const f={onSuccess:(m,p,g,y)=>{this.resetLoader(e,l);let T=m.data;g.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(T.slice(0,16)),T=T.slice(16)),o({frag:e,part:null,payload:T,networkDetails:y})},onError:(m,p,g,y)=>{this.resetLoader(e,l),d(new rs({type:ye.NETWORK_ERROR,details:$.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:Je({url:i,data:void 0},m),error:new Error(`HTTP Error ${m.code} ${m.text}`),networkDetails:g,stats:y}))},onAbort:(m,p,g)=>{this.resetLoader(e,l),d(new rs({type:ye.NETWORK_ERROR,details:$.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:g,stats:m}))},onTimeout:(m,p,g)=>{this.resetLoader(e,l),d(new rs({type:ye.NETWORK_ERROR,details:$.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${h.timeout}ms`),networkDetails:g,stats:m}))}};t&&(f.onProgress=(m,p,g,y)=>t({frag:e,part:null,payload:g,networkDetails:y})),l.load(c,h,f)})}loadPart(e,t,i){this.abort();const n=this.config,r=n.fLoader,a=n.loader;return new Promise((o,d)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap){d(bf(e,t));return}const l=this.loader=r?new r(n):new a(n),c=Tf(e,t);e.loader=l;const u=vf(n.fragLoadPolicy.default),h={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:yf};t.stats=l.stats,l.load(c,h,{onSuccess:(f,m,p,g)=>{this.resetLoader(e,l),this.updateStatsFromPart(e,t);const y={frag:e,part:t,payload:f.data,networkDetails:g};i(y),o(y)},onError:(f,m,p,g)=>{this.resetLoader(e,l),d(new rs({type:ye.NETWORK_ERROR,details:$.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:Je({url:c.url,data:void 0},f),error:new Error(`HTTP Error ${f.code} ${f.text}`),networkDetails:p,stats:g}))},onAbort:(f,m,p)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,l),d(new rs({type:ye.NETWORK_ERROR,details:$.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:p,stats:f}))},onTimeout:(f,m,p)=>{this.resetLoader(e,l),d(new rs({type:ye.NETWORK_ERROR,details:$.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error(`Timeout after ${h.timeout}ms`),networkDetails:p,stats:f}))}})})}updateStatsFromPart(e,t){const i=e.stats,n=t.stats,r=n.total;if(i.loaded+=n.loaded,r){const d=Math.round(e.duration/t.duration),l=Math.min(Math.round(i.loaded/r),d),u=(d-l)*Math.round(i.loaded/l);i.total=i.loaded+u}else i.total=Math.max(i.loaded,i.total);const a=i.loading,o=n.loading;a.start?a.first+=o.first-o.start:(a.start=o.start,a.first=o.first),a.end=o.end}resetLoader(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}}function Tf(s,e=null){const t=e||s,i={frag:s,part:e,responseType:"arraybuffer",url:t.url,headers:{},rangeStart:0,rangeEnd:0},n=t.byteRangeStartOffset,r=t.byteRangeEndOffset;if(he(n)&&he(r)){var a;let o=n,d=r;if(s.sn==="initSegment"&&iI((a=s.decryptdata)==null?void 0:a.method)){const l=r-n;l%16&&(d=r+(16-l%16)),n!==0&&(i.resetIV=!0,o=n-16)}i.rangeStart=o,i.rangeEnd=d}return i}function bf(s,e){const t=new Error(`GAP ${s.gap?"tag":"attribute"} found`),i={type:ye.MEDIA_ERROR,details:$.FRAG_GAP,fatal:!1,frag:s,error:t,networkDetails:null};return e&&(i.part=e),(e||s).stats.aborted=!0,new rs(i)}function iI(s){return s==="AES-128"||s==="AES-256"}class rs extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}}class tv extends pi{constructor(e,t){super(e,t),this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed()}onHandlerDestroying(){this.clearNextTick(),this.clearInterval()}onHandlerDestroyed(){}hasInterval(){return!!this._tickInterval}hasNextTick(){return!!this._tickTimer}setInterval(e){return this._tickInterval?!1:(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)}clearInterval(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1}clearNextTick(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1}tick(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}}class Mu{constructor(e,t,i,n=0,r=-1,a=!1){this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing=Ca(),this.buffering={audio:Ca(),video:Ca(),audiovideo:Ca()},this.level=e,this.sn=t,this.id=i,this.size=n,this.part=r,this.partial=a}}function Ca(){return{start:0,executeStart:0,executeEnd:0,end:0}}const _f={length:0,start:()=>0,end:()=>0};class Me{static isBuffered(e,t){if(e){const i=Me.getBuffered(e);for(let n=i.length;n--;)if(t>=i.start(n)&&t<=i.end(n))return!0}return!1}static bufferedRanges(e){if(e){const t=Me.getBuffered(e);return Me.timeRangesToArray(t)}return[]}static timeRangesToArray(e){const t=[];for(let i=0;i<e.length;i++)t.push({start:e.start(i),end:e.end(i)});return t}static bufferInfo(e,t,i){if(e){const n=Me.bufferedRanges(e);if(n.length)return Me.bufferedInfo(n,t,i)}return{len:0,start:t,end:t,bufferedIndex:-1}}static bufferedInfo(e,t,i){t=Math.max(0,t),e.length>1&&e.sort((c,u)=>c.start-u.start||u.end-c.end);let n=-1,r=[];if(i)for(let c=0;c<e.length;c++){t>=e[c].start&&t<=e[c].end&&(n=c);const u=r.length;if(u){const h=r[u-1].end;e[c].start-h<i?e[c].end>h&&(r[u-1].end=e[c].end):r.push(e[c])}else r.push(e[c])}else r=e;let a=0,o,d=t,l=t;for(let c=0;c<r.length;c++){const u=r[c].start,h=r[c].end;if(n===-1&&t>=u&&t<=h&&(n=c),t+i>=u&&t<h)d=u,l=h,a=l-t;else if(t+i<u){o=u;break}}return{len:a,start:d||0,end:l||0,nextStart:o,buffered:e,bufferedIndex:n}}static getBuffered(e){try{return e.buffered||_f}catch(t){return et.log("failed to get media.buffered",t),_f}}}const iv=/\{\$([a-zA-Z0-9-_]+)\}/g;function Sf(s){return iv.test(s)}function Mc(s,e){if(s.variableList!==null||s.hasVariableRefs){const t=s.variableList;return e.replace(iv,i=>{const n=i.substring(2,i.length-1),r=t?.[n];return r===void 0?(s.playlistParsingError||(s.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${n}"`)),i):r})}return e}function Af(s,e,t){let i=s.variableList;i||(s.variableList=i={});let n,r;if("QUERYPARAM"in e){n=e.QUERYPARAM;try{const a=new self.URL(t).searchParams;if(a.has(n))r=a.get(n);else throw new Error(`"${n}" does not match any query parameter in URI: "${t}"`)}catch(a){s.playlistParsingError||(s.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${a.message}`))}}else n=e.NAME,r=e.VALUE;n in i?s.playlistParsingError||(s.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${n}"`)):i[n]=r||""}function sI(s,e,t){const i=e.IMPORT;if(t&&i in t){let n=s.variableList;n||(s.variableList=n={}),n[i]=t[i]}else s.playlistParsingError||(s.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${i}"`))}const nI=/^(\d+)x(\d+)$/,If=/(.+?)=(".*?"|.*?)(?:,|$)/g;class mt{constructor(e,t){typeof e=="string"&&(e=mt.parseAttrList(e,t)),nt(this,e)}get clientAttrs(){return Object.keys(this).filter(e=>e.substring(0,2)==="X-")}decimalInteger(e){const t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t}hexadecimalInteger(e){if(this[e]){let t=(this[e]||"0x").slice(2);t=(t.length&1?"0":"")+t;const i=new Uint8Array(t.length/2);for(let n=0;n<t.length/2;n++)i[n]=parseInt(t.slice(n*2,n*2+2),16);return i}return null}hexadecimalIntegerAsNumber(e){const t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t}decimalFloatingPoint(e){return parseFloat(this[e])}optionalFloat(e,t){const i=this[e];return i?parseFloat(i):t}enumeratedString(e){return this[e]}enumeratedStringList(e,t){const i=this[e];return(i?i.split(/[ ,]+/):[]).reduce((n,r)=>(n[r.toLowerCase()]=!0,n),t)}bool(e){return this[e]==="YES"}decimalResolution(e){const t=nI.exec(this[e]);if(t!==null)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}static parseAttrList(e,t){let i;const n={};for(If.lastIndex=0;(i=If.exec(e))!==null;){const a=i[1].trim();let o=i[2];const d=o.indexOf('"')===0&&o.lastIndexOf('"')===o.length-1;let l=!1;if(d)o=o.slice(1,-1);else switch(a){case"IV":case"SCTE35-CMD":case"SCTE35-IN":case"SCTE35-OUT":l=!0}if(t&&(d||l))o=Mc(t,o);else if(!l&&!d)switch(a){case"CLOSED-CAPTIONS":if(o==="NONE")break;case"ALLOWED-CPC":case"CLASS":case"ASSOC-LANGUAGE":case"AUDIO":case"BYTERANGE":case"CHANNELS":case"CHARACTERISTICS":case"CODECS":case"DATA-ID":case"END-DATE":case"GROUP-ID":case"ID":case"IMPORT":case"INSTREAM-ID":case"KEYFORMAT":case"KEYFORMATVERSIONS":case"LANGUAGE":case"NAME":case"PATHWAY-ID":case"QUERYPARAM":case"RECENTLY-REMOVED-DATERANGES":case"SERVER-URI":case"STABLE-RENDITION-ID":case"STABLE-VARIANT-ID":case"START-DATE":case"SUBTITLES":case"SUPPLEMENTAL-CODECS":case"URI":case"VALUE":case"VIDEO":case"X-ASSET-LIST":case"X-ASSET-URI":et.warn(`${e}: attribute ${a} is missing quotes`)}n[a]=o}return n}}const rI="com.apple.hls.interstitial";function aI(s){return s!=="ID"&&s!=="CLASS"&&s!=="CUE"&&s!=="START-DATE"&&s!=="DURATION"&&s!=="END-DATE"&&s!=="END-ON-NEXT"}function oI(s){return s==="SCTE35-OUT"||s==="SCTE35-IN"||s==="SCTE35-CMD"}class sv{constructor(e,t,i=0){var n;if(this.attr=void 0,this.tagAnchor=void 0,this.tagOrder=void 0,this._startDate=void 0,this._endDate=void 0,this._dateAtEnd=void 0,this._cue=void 0,this._badValueForSameId=void 0,this.tagAnchor=t?.tagAnchor||null,this.tagOrder=(n=t?.tagOrder)!=null?n:i,t){const r=t.attr;for(const a in r)if(Object.prototype.hasOwnProperty.call(e,a)&&e[a]!==r[a]){et.warn(`DATERANGE tag attribute: "${a}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=a;break}e=nt(new mt({}),r,e)}if(this.attr=e,t?(this._startDate=t._startDate,this._cue=t._cue,this._endDate=t._endDate,this._dateAtEnd=t._dateAtEnd):this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){const r=t?.endDate||new Date(this.attr["END-DATE"]);he(r.getTime())&&(this._endDate=r)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get cue(){const e=this._cue;return e===void 0?this._cue=this.attr.enumeratedStringList(this.attr.CUE?"CUE":"X-CUE",{pre:!1,post:!1,once:!1}):e}get startTime(){const{tagAnchor:e}=this;return e===null||e.programDateTime===null?(et.warn(`Expected tagAnchor Fragment with PDT set for DateRange "${this.id}": ${e}`),NaN):e.start+(this.startDate.getTime()-e.programDateTime)/1e3}get startDate(){return this._startDate}get endDate(){const e=this._endDate||this._dateAtEnd;if(e)return e;const t=this.duration;return t!==null?this._dateAtEnd=new Date(this._startDate.getTime()+t*1e3):null}get duration(){if("DURATION"in this.attr){const e=this.attr.decimalFloatingPoint("DURATION");if(he(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isInterstitial(){return this.class===rI}get isValid(){return!!this.id&&!this._badValueForSameId&&he(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)&&(!this.attr.CUE||!this.cue.pre&&!this.cue.post||this.cue.pre!==this.cue.post)&&(!this.isInterstitial||"X-ASSET-URI"in this.attr||"X-ASSET-LIST"in this.attr)}}const lI=10;class dI{constructor(e){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.dateRangeTagCount=0,this.live=!0,this.requestScheduled=-1,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.drift
vendor: 4,538 bytes, line 1494
1494StartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.appliedTimelineOffset=void 0,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=e}reloaded(e){if(!e){this.advanced=!0,this.updated=!0;return}const t=this.lastPartSn-e.lastPartSn,i=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!i||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||t===0&&i>0,this.updated||this.advanced?this.misses=Math.floor(e.misses*.6):this.misses=e.misses+1}hasKey(e){return this.encryptedFragments.some(t=>{let i=t.decryptdata;return i||(t.setKeyFormat(e.keyFormat),i=t.decryptdata),!!i&&e.matches(i)})}get hasProgramDateTime(){return this.fragments.length?he(this.fragments[this.fragments.length-1].programDateTime):!1}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||lI}get drift(){const e=this.driftEndTime-this.driftStartTime;return e>0?(this.driftEnd-this.driftStart)*1e3/e:1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){return this.fragments.length?this.fragments[this.fragments.length-1].end:0}get fragmentStart(){return this.fragments.length?this.fragments[0].start:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].index:-1}get maxPartIndex(){const e=this.partList;if(e){const t=this.lastPartIndex;if(t!==-1){for(let i=e.length;i--;)if(e[i].index>t)return e[i].index;return t}}return 0}get lastPartSn(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}get expired(){if(this.live&&this.age&&this.misses<3){const e=this.partEnd-this.fragmentStart;return this.age>Math.max(e,this.totalduration)+this.levelTargetDuration}return!1}}function ml(s,e){return s.length===e.length?!s.some((t,i)=>t!==e[i]):!1}function xf(s,e){return!s&&!e?!0:!s||!e?!1:ml(s,e)}function Nn(s){return s==="AES-128"||s==="AES-256"||s==="AES-256-CTR"}function Ou(s){switch(s){case"AES-128":case"AES-256":return Rs.cbc;case"AES-256-CTR":return Rs.ctr;default:throw new Error(`invalid full segment method ${s}`)}}function Fu(s){return Uint8Array.from(atob(s),e=>e.charCodeAt(0))}function Oc(s){return Uint8Array.from(unescape(encodeURIComponent(s)),e=>e.charCodeAt(0))}function cI(s){const e=Oc(s).subarray(0,16),t=new Uint8Array(16);return t.set(e,16-e.length),t}function nv(s){const e=function(i,n,r){const a=i[n];i[n]=i[r],i[r]=a};e(s,0,3),e(s,1,2),e(s,4,5),e(s,6,7)}function rv(s){const e=s.split(":");let t=null;if(e[0]==="data"&&e.length===2){const i=e[1].split(";"),n=i[i.length-1].split(",");if(n.length===2){const r=n[0]==="base64",a=n[1];r?(i.splice(-1,1),t=Fu(a)):t=cI(a)}}return t}const gl=typeof self<"u"?self:void 0;var gt={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},Gt={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function wo(s){switch(s){case Gt.FAIRPLAY:return gt.FAIRPLAY;case Gt.PLAYREADY:return gt.PLAYREADY;case Gt.WIDEVINE:return gt.WIDEVINE;case Gt.CLEARKEY:return gt.CLEARKEY}}function nd(s){switch(s){case gt.FAIRPLAY:return Gt.FAIRPLAY;case gt.PLAYREADY:return Gt.PLAYREADY;case gt.WIDEVINE:return Gt.WIDEVINE;case gt.CLEARKEY:return Gt.CLEARKEY}}function Tr(s){const{drmSystems:e,widevineLicenseUrl:t}=s,i=e?[gt.FAIRPLAY,gt.WIDEVINE,gt.PLAYREADY,gt.CLEARKEY].filter(n=>!!e[n]):[];return!i[gt.WIDEVINE]&&t&&i.push(gt.WIDEVINE),i}const av=(function(s){return gl!=null&&(s=gl.navigator)!=null&&s.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null})();function uI(s,e,t,i){let n;switch(s){case gt.FAIRPLAY:n=["cenc","sinf"];break;case gt.WIDEVINE:case gt.PLAYREADY:n=["cenc"];break;case gt.CLEARKEY:n=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${s}`)}return hI(n,e,t,i)}function hI(s,e,t,i){return[{initDataTypes:s,persistentState:i.persistentState||"optional",distinctiveIdentifier:i.distinctiveIdentifier||"optional",sessionTypes:i.sessionTypes||[i.sessionType||"temporary"],audioCapabilities:e.map(r=>({contentType:`audio/mp4; codecs=${r}
1494`,robustness:i.audioRobustness||"",encryptionScheme:i.audioEncryptionScheme||null})),videoCapabilities:t.map(r=>({contentType:`video/mp4; codecs=${r}`,robustness:i.videoRobustness||"",encryptionScheme:i.videoEncryptionScheme||null}))}]}function fI(s){var e;return!!s&&(s.sessionType==="persistent-license"||!!((e=s.sessionTypes)!=null&&e.some(t=>t==="persistent-license")))}function ov(s){const e=new Uint16Array(s.buffer,s.byteOffset,s.byteLength/2),t=String.fromCharCode.apply(null,Array.from(e)),i=t.substring(t.indexOf("<"),t.length),a=new DOMParser().parseFromString(i,"text/xml").getElementsByTagName("KID")[0];if(a){const o=a.childNodes[0]?a.childNodes[0].nodeValue:a.getAttribute("VALUE");if(o){const d=Fu(o).subarray(0,16);return nv(d),d}}return null}let dn={};class Is{static clearKeyUriToKeyIdMap(){dn={}}static setKeyIdForUri(e,t){dn[e]=t}static addKeyIdForUri(e){const t=Object.keys(dn).length%Number.MAX_SAFE_INTEGER,i=new Uint8Array(16);return new DataView(i.buffer,12,4).setUint32(0,t),dn[e]=i,i}constructor(e,t,i,n=[1],r=null,a){this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=e,this.uri=t,this.keyFormat=i,this.keyFormatVersions=n,this.iv=r,this.encrypted=e?e!=="NONE":!1,this.isCommonEncryption=this.encrypted&&!Nn(e),a!=null&&a.startsWith("0x")&&(this.keyId=new Uint8Array(Op(a)))}matches(e){return e.uri===this.uri&&e.method===this.method&&e.encrypted===this.encrypted&&e.keyFormat===this.keyFormat&&ml(e.keyFormatVersions,this.keyFormatVersions)&&xf(e.iv,this.iv)&&xf(e.keyId,this.keyId)}isSupported(){if(this.method){if(Nn(this.method)||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES";switch(this.keyFormat){case Gt.FAIRPLAY:case Gt.WIDEVINE:case Gt.PLAYREADY:case Gt.CLEARKEY:return["SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1}getDecryptData(e,t){if(!this.encrypted||!this.uri)return null;if(Nn(this.method)){let r=this.iv;return r||(typeof e!="number"&&(et.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0),r=gI(e)),new Is(this.method,this.uri,"identity",this.keyFormatVersions,r)}if(this.keyId){const r=dn[this.uri];if(r&&!ml(this.keyId,r)&&Is.setKeyIdForUri(this.uri,this.keyId),this.pssh)return this}const i=rv(this.uri);if(i)switch(this.keyFormat){case Gt.WIDEVINE:if(this.pssh=i,!this.keyId){const r=EA(i.buffer);if(r.length){var n;const a=r[0];this.keyId=(n=a.kids)!=null&&n.length?a.kids[0]:null}}this.keyId||(this.keyId=Lf(t));break;case Gt.PLAYREADY:{const r=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=vA(r,null,i),this.keyId=ov(i);break}default:{let r=i.subarray(0,16);if(r.length!==16){const a=new Uint8Array(16);a.set(r,16-r.length),r=a}this.keyId=r;break}}if(!this.keyId||this.keyId.byteLength!==16){let r;r=mI(t),r||(r=Lf(t),r||(r=dn[this.uri])),r&&(this.keyId=r,Is.setKeyIdForUri(this.uri,r))}return this}}function mI(s){const e=s?.[Gt.WIDEVINE];return e?e.keyId:null}function Lf(s){const e=s?.[Gt.PLAYREADY];if(e){const t=rv(e.uri);if(t)return ov(t)}return null}function gI(s){const e=new Uint8Array(16);for(let t=12;t<16;t++)e[t]=s>>8*(15-t)&255;return e}const Rf=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g,kf=/#EXT-X-MEDIA:(.*)/g,pI=/^#EXT(?:INF|-X-TARGETDURATION):/m,rd=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#.*/.source].join("|"),"g"),vI=new RegExp([/#EXT-X-(PROGRAM-DATE-TIME|BYTERANGE|DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP|INDEPENDENT-SEGMENTS)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|"));class Yi{static findGroup(e,t){for(let i=0;i<e.length;i++){const n=e[i];if(n.id===t)return n}}static resolve(e,t){return Lu.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return pI.test(e)}static parseMasterPlaylist(e,t){const i=Sf(e),n={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:i},r=[];if(Rf.lastIndex=0,!e.startsWith("#EXTM3U"))return n.playlistParsingError=new Error("no EXTM3U delimiter"),n;let a;for(;(a=Rf.exec(e))!=null;)if(a[1]){var o;const l=new mt(a[1],n),c=Mc(n,a[2]),u={attrs:l,bitrate:l.decimalInteger("BANDWIDTH")||l.decimalInteger("AVERAGE-BANDWIDTH"),name:l.NAME,url:Yi.resolve(c,t)},h=l.decimalResolution("RESOLUTION");h&&(u.width=h.width,u.height=h.height),wf(l.CODECS,u);const f=l["SUPPLEMENTAL-CODECS"];f&&(u.supplemental={},wf(f,u.supplemental)),(o=u.unknownCodecs)!=null&&o.length||r.push(u),n.levels.push(u)}else if(a[3]){const l=a[3],c=a[4];switch(l){case"SESSION-DATA":{const u=new mt(c,n),h=u["DATA-ID"];h&&(n.sessionData===null&&(n.sessionData={}),n.sessionData[h]=u);break}case"SESSION-KEY":{const u=Df(c,t,n);u.encrypted&&u.isSupported()?(n.sessionKeys===null&&(n.sessionKeys=[]),n.sessionKeys.push(u)):et.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${c}"`);break}case"DEFINE":{{const u=new mt(c,n);Af(n,u,t)}break}case"CONTENT-STEERING":{const u=new mt(c,n);n.contentSteering={uri:Yi.resolve(u["SERVER-URI"],t),pathwayId:u["PATHWAY-ID"]||"."};break}case"START":{n.startTimeOffset=Cf(c);break}}}const d=r.length>0&&r.length<n.levels.length;return n.levels=d?r:n.levels,n.levels.length===0&&(n.playlistParsingError=new Error("no levels found in manifest")),n}static parseMasterPlaylistMedia(e,t,i){let n;const r={},a=i.levels,o={AUDIO:a.map(l=>({id:l.attrs.AUDIO,audioCodec:l.audioCodec}
vendor: 10,226 bytes, line 1494
1494)),SUBTITLES:a.map(l=>({id:l.attrs.SUBTITLES,textCodec:l.textCodec})),"CLOSED-CAPTIONS":[]};let d=0;for(kf.lastIndex=0;(n=kf.exec(e))!==null;){const l=new mt(n[1],i),c=l.TYPE;if(c){const u=o[c],h=r[c]||[];r[c]=h;const f=l.LANGUAGE,m=l["ASSOC-LANGUAGE"],p=l.CHANNELS,g=l.CHARACTERISTICS,y=l["INSTREAM-ID"],T={attrs:l,bitrate:0,id:d++,groupId:l["GROUP-ID"]||"",name:l.NAME||f||"",type:c,default:l.bool("DEFAULT"),autoselect:l.bool("AUTOSELECT"),forced:l.bool("FORCED"),lang:f,url:l.URI?Yi.resolve(l.URI,t):""};if(m&&(T.assocLang=m),p&&(T.channels=p),g&&(T.characteristics=g),y&&(T.instreamId=y),u!=null&&u.length){const _=Yi.findGroup(u,T.groupId)||u[0];Pf(T,_,"audioCodec"),Pf(T,_,"textCodec")}h.push(T)}}return r}static parseLevelPlaylist(e,t,i,n,r,a){var o;const d={url:t},l=new dI(t),c=l.fragments,u=[];let h=null,f=0,m=0,p=0,g=0,y=0,T=null,_=new td(n,d),I,R,F,L=-1,w=!1,P=null,k;if(rd.lastIndex=0,l.m3u8=e,l.hasVariableRefs=Sf(e),((o=rd.exec(e))==null?void 0:o[0])!=="#EXTM3U")return l.playlistParsingError=new Error("Missing format identifier #EXTM3U"),l;for(;(I=rd.exec(e))!==null;){w&&(w=!1,_=new td(n,d),_.playlistOffset=p,_.setStart(p),_.sn=f,_.cc=g,y&&(_.bitrate=y),_.level=i,h&&(_.initSegment=h,h.rawProgramDateTime&&(_.rawProgramDateTime=h.rawProgramDateTime,h.rawProgramDateTime=null),P&&(_.setByteRange(P),P=null)));const de=I[1];if(de){_.duration=parseFloat(de);const ae=(" "+I[2]).slice(1);_.title=ae||null,_.tagList.push(ae?["INF",de,ae]:["INF",de])}else if(I[3]){if(he(_.duration)){_.playlistOffset=p,_.setStart(p),F&&Of(_,F,l),_.sn=f,_.level=i,_.cc=g,c.push(_);const ae=(" "+I[3]).slice(1);_.relurl=Mc(l,ae),Fc(_,T,u),T=_,p+=_.duration,f++,m=0,w=!0}}else{if(I=I[0].match(vI),!I){et.warn("No matches on slow regex match for level playlist!");continue}for(R=1;R<I.length&&I[R]===void 0;R++);const ae=(" "+I[R]).slice(1),ie=(" "+I[R+1]).slice(1),ue=I[R+2]?(" "+I[R+2]).slice(1):null;switch(ae){case"BYTERANGE":T?_.setByteRange(ie,T):_.setByteRange(ie);break;case"PROGRAM-DATE-TIME":_.rawProgramDateTime=ie,_.tagList.push(["PROGRAM-DATE-TIME",ie]),L===-1&&(L=c.length);break;case"PLAYLIST-TYPE":l.type&&es(l,ae,I),l.type=ie.toUpperCase();break;case"MEDIA-SEQUENCE":l.startSN!==0?es(l,ae,I):c.length>0&&Ff(l,ae,I),f=l.startSN=parseInt(ie);break;case"SKIP":{l.skippedSegments&&es(l,ae,I);const ee=new mt(ie,l),te=ee.decimalInteger("SKIPPED-SEGMENTS");if(he(te)){l.skippedSegments+=te;for(let X=te;X--;)c.push(null);f+=te}const ve=ee.enumeratedString("RECENTLY-REMOVED-DATERANGES");ve&&(l.recentlyRemovedDateranges=(l.recentlyRemovedDateranges||[]).concat(ve.split(" ")));break}case"TARGETDURATION":l.targetduration!==0&&es(l,ae,I),l.targetduration=Math.max(parseInt(ie),1);break;case"VERSION":l.version!==null&&es(l,ae,I),l.version=parseInt(ie);break;case"INDEPENDENT-SEGMENTS":break;case"ENDLIST":l.live||es(l,ae,I),l.live=!1;break;case"#":(ie||ue)&&_.tagList.push(ue?[ie,ue]:[ie]);break;case"DISCONTINUITY":g++,_.tagList.push(["DIS"]);break;case"GAP":_.gap=!0,_.tagList.push([ae]);break;case"BITRATE":_.tagList.push([ae,ie]),y=parseInt(ie)*1e3,he(y)?_.bitrate=y:y=0;break;case"DATERANGE":{const ee=new mt(ie,l),te=new sv(ee,l.dateRanges[ee.ID],l.dateRangeTagCount);l.dateRangeTagCount++,te.isValid||l.skippedSegments?l.dateRanges[te.id]=te:et.warn(`Ignoring invalid DATERANGE tag: "${ie}"`),_.tagList.push(["EXT-X-DATERANGE",ie]);break}case"DEFINE":{{const ee=new mt(ie,l);"IMPORT"in ee?sI(l,ee,a):Af(l,ee,t)}break}case"DISCONTINUITY-SEQUENCE":l.startCC!==0?es(l,ae,I):c.length>0&&Ff(l,ae,I),l.startCC=g=parseInt(ie);break;case"KEY":{const ee=Df(ie,t,l);if(ee.isSupported()){if(ee.method==="NONE"){F=void 0;break}F||(F={});const te=F[ee.keyFormat];te!=null&&te.matches(ee)||(te&&(F=nt({},F)),F[ee.keyFormat]=ee)}else et.warn(`[Keys] Ignoring unsupported EXT-X-KEY tag: "${ie}"`);break}case"START":l.startTimeOffset=Cf(ie);break;case"MAP":{const ee=new mt(ie,l);if(_.duration){const te=new td(n,d);Mf(te,ee,i,F),h=te,_.initSegment=h,h.rawProgramDateTime&&!_.rawProgramDateTime&&(_.rawProgramDateTime=h.rawProgramDateTime)}else{const te=_.byteRangeEndOffset;if(te){const ve=_.byteRangeStartOffset;P=`${te-ve}@${ve}`}else P=null;Mf(_,ee,i,F),h=_,w=!0}h.cc=g;break}case"SERVER-CONTROL":{k&&es(l,ae,I),k=new mt(ie),l.canBlockReload=k.bool("CAN-BLOCK-RELOAD"),l.canSkipUntil=k.optionalFloat("CAN-SKIP-UNTIL",0),l.canSkipDateRanges=l.canSkipUntil>0&&k.bool("CAN-SKIP-DATERANGES"),l.partHoldBack=k.optionalFloat("PART-HOLD-BACK",0),l.holdBack=k.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{l.partTarget&&es(l,ae,I);const ee=new mt(ie);l.partTarget=ee.decimalFloatingPoint("PART-TARGET");break}case"PART":{let ee=l.partList;ee||(ee=l.partList=[]);const te=m>0?ee[ee.length-1]:void 0,ve=m++,X=new mt(ie,l),Y=new sA(X,_,d,ve,te);ee.push(Y),_.duration+=Y.duration;break}case"PRELOAD-HINT":{const ee=new mt(ie,l);l.preloadHint=ee;break}case"RENDITION-REPORT":{const ee=new mt(ie,l);l.renditionReports=l.renditionReports||[],l.renditionReports.push(ee);break}default:et.warn(`line parsed but not handled: ${I}`);break}}}T&&!T.relurl?(c.pop(),p-=T.duration,l.partList&&(l.fragmentHint=T)):l.partList&&(Fc(_,T,u),_.cc=g,l.fragmentHint=_,F&&Of(_,F,l)),l.targetduration||(l.playlistParsingError=new Error("Missing Target Duration"));const G=c.length,se=c[0],oe=c[G-1];if(p+=l.skippedSegments*l.targetduration,p>0&&G&&oe){l.averagetargetduration=p/G;const de=oe.sn;l.endSN=de!=="initSegment"?de:0,l.live||(oe.endList=!0),L>0&&(yI(c,L),se&&u.unshift(se))}return l.fragmentHint&&(p+=l.fragmentHint.duration),l.totalduration=p,u.length&&l.dateRangeTagCount&&se&&lv(u,l),l.endCC=g,l}}function lv(s,e){let t=s.length;if(!t)if(e.hasProgramDateTime){const o=e.fragments[e.fragments.length-1];s.push(o),t++}else return;const i=s[t-1],n=e.live?1/0:e.totalduration,r=Object.keys(e.dateRanges);for(let o=r.length;o--;){const d=e.dateRanges[r[o]],l=d.startDate.getTime();d.tagAnchor=i.ref;for(let c=t;c--;){var a;if(((a=s[c])==null?void 0:a.sn)<e.startSN)break;const u=EI(e,l,s,c,n);if(u!==-1){d.tagAnchor=e.fragments[u].ref;break}}}}function EI(s,e,t,i,n){const r=t[i];if(r){const o=r.programDateTime;if(e>=o||i===0){var a;const d=(((a=t[i+1])==null?void 0:a.start)||n)-r.start;if(e<=o+d*1e3){const l=t[i].sn-s.startSN;if(l<0)return-1;const c=s.fragments;if(c.length>t.length){const h=(t[i+1]||c[c.length-1]).sn-s.startSN;for(let f=h;f>l;f--){const m=c[f].programDateTime;if(e>=m&&e<m+c[f].duration*1e3)return f}}return l}}}return-1}function Df(s,e,t){var i,n;const r=new mt(s,t),a=(i=r.METHOD)!=null?i:"",o=r.URI,d=r.hexadecimalInteger("IV"),l=r.KEYFORMATVERSIONS,c=(n=r.KEYFORMAT)!=null?n:"identity";o&&r.IV&&!d&&et.error(`Invalid IV: ${r.IV}`);const u=o?Yi.resolve(o,e):"",h=(l||"1").split("/").map(Number).filter(Number.isFinite);return new Is(a,u,c,h,d,r.KEYID)}function Cf(s){const t=new mt(s).decimalFloatingPoint("TIME-OFFSET");return he(t)?t:null}function wf(s,e){let t=(s||"").split(/[ ,]+/).filter(i=>i);["video","audio","text"].forEach(i=>{const n=t.filter(r=>Du(r,i));n.length&&(e[`${i}Codec`]=n.map(r=>r.split("/")[0]).join(","),t=t.filter(r=>n.indexOf(r)===-1))}),e.unknownCodecs=t}function Pf(s,e,t){const i=e[t];i&&(s[t]=i)}function yI(s,e){let t=s[e];for(let i=e;i--;){const n=s[i];if(!n)return;n.programDateTime=t.programDateTime-n.duration*1e3,t=n}}function Fc(s,e,t){s.rawProgramDateTime?t.push(s):e!=null&&e.programDateTime&&(s.programDateTime=e.endProgramDateTime)}function Mf(s,e,t,i){s.relurl=e.URI,e.BYTERANGE&&s.setByteRange(e.BYTERANGE),s.level=t,s.sn="initSegment",i&&(s.levelkeys=i),s.initSegment=null}function Of(s,e,t){s.levelkeys=e;const{encryptedFragments:i}=t;(!i.length||i[i.length-1].levelkeys!==e)&&Object.keys(e).some(n=>e[n].isCommonEncryption)&&i.push(s)}function es(s,e,t){s.playlistParsingError=new Error(`#EXT-X-${e} must not appear more than once (${t[0]})`)}function Ff(s,e,t){s.playlistParsingError=new Error(`#EXT-X-${e} must appear before the first Media Segment (${t[0]})`)}function ad(s,e){const t=e.startPTS;if(he(t)){let i=0,n;e.sn>s.sn?(i=t-s.start,n=s):(i=s.start-t,n=e),n.duration!==i&&n.setDuration(i)}else e.sn>s.sn?s.cc===e.cc&&s.minEndPTS?e.setStart(s.start+(s.minEndPTS-s.start)):e.setStart(s.start+s.duration):e.setStart(Math.max(s.start-e.duration,0))}function dv(s,e,t,i,n,r,a){i-t<=0&&(a.warn("Fragment should have a positive duration",e),i=t+e.duration,r=n+e.duration);let d=t,l=i;const c=e.startPTS,u=e.endPTS;if(he(c)){const y=Math.abs(c-t);s&&y>s.totalduration?a.warn(`media timestamps and playlist times differ by ${y}s for level ${e.level} ${s.url}`):he(e.deltaPTS)?e.deltaPTS=Math.max(y,e.deltaPTS):e.deltaPTS=y,d=Math.max(t,c),t=Math.min(t,c),n=e.startDTS!==void 0?Math.min(n,e.startDTS):n,l=Math.min(i,u),i=Math.max(i,u),r=e.endDTS!==void 0?Math.max(r,e.endDTS):r}const h=t-e.start;e.start!==0&&e.setStart(t),e.setDuration(i-e.start),e.startPTS=t,e.maxStartPTS=d,e.startDTS=n,e.endPTS=i,e.minEndPTS=l,e.endDTS=r;const f=e.sn;if(!s||f<s.startSN||f>s.endSN)return 0;let m;const p=f-s.startSN,g=s.fragments;for(g[p]=e,m=p;m>0;m--)ad(g[m],g[m-1]);for(m=p;m<g.length-1;m++)ad(g[m],g[m+1]);return s.fragmentHint&&ad(g[g.length-1],s.fragmentHint),s.PTSKnown=s.alignedSliding=!0,h}function TI(s,e,t){if(s===e)return;let i=null;const n=s.fragments;for(let c=n.length-1;c>=0;c--){const u=n[c].initSegment;if(u){i=u;break}}s.fragmentHint&&delete s.fragmentHint.endPTS;let r;SI(s,e,(c,u,h,f)=>{if((!e.startCC||e.skippedSegments)&&u.cc!==c.cc){const m=c.cc-u.cc;for(let p=h;p<f.length;p++)f[p].cc+=m;e.endCC=f[f.length-1].cc}he(c.startPTS)&&he(c.endPTS)&&(u.setStart(u.startPTS=c.startPTS),u.startDTS=c.startDTS,u.maxStartPTS=c.maxStartPTS,u.endPTS=c.endPTS,u.endDTS=c.endDTS,u.minEndPTS=c.minEndPTS,u.setDuration(c.endPTS-c.startPTS),u.duration&&(r=u),e.PTSKnown=e.alignedSliding=!0),c.hasStreams&&(u.elementaryStreams=c.elementaryStreams),u.loader=c.loader,c.hasStats&&(u.stats=c.stats),c.initSegment&&(u.initSegment=c.initSegment,i=c.initSegment)});const a=e.fragments,o=e.fragmentHint?a.concat(e.fragmentHint):a;if(i&&o.forEach(c=>{var u;c&&(!c.initSegment||c.initSegment.relurl===((u=i)==null?void 0:u.relurl))&&(c.initSegment=i)}),e.skippedSegments){if(e.deltaUpdateFailed=a.some(c=>!c),e.deltaUpdateFailed){t.warn("[level-helper] Previous playlist missing segments ski
1494pped in delta playlist");for(let c=e.skippedSegments;c--;)a.shift();e.startSN=a[0].sn}else{e.canSkipDateRanges&&(e.dateRanges=bI(s.dateRanges,e,t));const c=s.fragments.filter(u=>u.rawProgramDateTime);if(s.hasProgramDateTime&&!e.hasProgramDateTime)for(let u=1;u<o.length;u++)o[u].programDateTime===null&&Fc(o[u],o[u-1],c);lv(c,e)}e.endCC=a[a.length-1].cc}if(!e.startCC){var d;const c=hv(s,e.startSN-1);e.startCC=(d=c?.cc)!=null?d:a[0].cc}_I(s.partList,e.partList,(c,u)=>{u.elementaryStreams=c.elementaryStreams,u.stats=c.stats}),r?dv(e,r,r.startPTS,r.endPTS,r.startDTS,r.endDTS,t):cv(s,e),a.length&&(e.totalduration=e.edge-a[0].start),e.driftStartTime=s.driftStartTime,e.driftStart=s.driftStart;const l=e.advancedDateTime;if(e.advanced&&l){const c=e.edge;e.driftStart||(e.driftStartTime=l,e.driftStart=c),e.driftEndTime=l,e.driftEnd=c}else e.driftEndTime=s.driftEndTime,e.driftEnd=s.driftEnd,e.advancedDateTime=s.advancedDateTime;e.requestScheduled===-1&&(e.requestScheduled=s.requestScheduled)}function bI(s,e,t){const{dateRanges:i,recentlyRemovedDateranges:n}=e,r=nt({},s);n&&n.forEach(d=>{delete r[d]});const o=Object.keys(r).length;
vendor: 40,612 bytes, lines 1494-1499
1494return o?(Object.keys(i).forEach(d=>{const l=r[d],c=new sv(i[d].attr,l);c.isValid?(r[d]=c,l||(c.tagOrder+=o)):t.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${lt(i[d].attr)}"`)}),r):i}function _I(s,e,t){if(s&&e){let i=0;for(let n=0,r=s.length;n<=r;n++){const a=s[n],o=e[n+i];a&&o&&a.index===o.index&&a.fragment.sn===o.fragment.sn?t(a,o):i--}}}function SI(s,e,t){const i=e.skippedSegments,n=Math.max(s.startSN,e.startSN)-e.startSN,r=(s.fragmentHint?1:0)+(i?e.endSN:Math.min(s.endSN,e.endSN))-e.startSN,a=e.startSN-s.startSN,o=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,d=s.fragmentHint?s.fragments.concat(s.fragmentHint):s.fragments;for(let l=n;l<=r;l++){const c=d[a+l];let u=o[l];if(i&&!u&&c&&(u=e.fragments[l]=c),c&&u){t(c,u,l,o);const h=c.relurl,f=u.relurl;if(h&&AI(h,f)){e.playlistParsingError=$f(`media sequence mismatch ${u.sn}:`,s,e,c,u);return}else if(c.cc!==u.cc){e.playlistParsingError=$f(`discontinuity sequence mismatch (${c.cc}!=${u.cc})`,s,e,c,u);return}}}}function $f(s,e,t,i,n){return new Error(`${s} ${n.url} 1495Playlist starting @${e.startSN} 1496${e.m3u8} 1497 1498Playlist starting @${t.startSN} 1499${t.m3u8}`)}function cv(s,e,t=!0){const i=e.startSN+e.skippedSegments-s.startSN,n=s.fragments,r=i>=0;let a=0;if(r&&i<n.length)a=n[i].start;else if(r&&e.startSN===s.endSN+1)a=s.fragmentEnd;else if(r&&t)a=s.fragmentStart+i*e.levelTargetDuration;else if(!e.skippedSegments&&e.fragmentStart===0)a=s.fragmentStart;else return;$c(e,a)}function $c(s,e){if(e){const t=s.fragments;for(let i=s.skippedSegments;i<t.length;i++)t[i].addStart(e);s.fragmentHint&&s.fragmentHint.addStart(e)}}function uv(s,e=1/0){let t=1e3*s.targetduration;if(s.updated){const i=s.fragments;if(i.length&&t*4>e){const r=i[i.length-1].duration*1e3;r<t&&(t=r)}}else t/=2;return Math.round(t)}function hv(s,e,t){if(!s)return null;let i=s.fragments[e-s.startSN];return i||(i=s.fragmentHint,i&&i.sn===e)?i:e<s.startSN&&t&&t.sn===e?t:null}function Nf(s,e,t){return s?fv(s.partList,e,t):null}function fv(s,e,t){if(s)for(let i=s.length;i--;){const n=s[i];if(n.index===t&&n.fragment.sn===e)return n}return null}function mv(s){s.forEach((e,t)=>{var i;(i=e.details)==null||i.fragments.forEach(n=>{n.level=t,n.initSegment&&(n.initSegment.level=t)})})}function AI(s,e){return s!==e&&e?Uf(s)!==Uf(e):!1}function Uf(s){return s.replace(/\?[^?]*$/,"")}function Rr(s,e){for(let i=0,n=s.length;i<n;i++){var t;if(((t=s[i])==null?void 0:t.cc)===e)return s[i]}return null}function II(s,e){return!!(s&&e.startCC<s.endCC&&e.endCC>s.startCC)}function Bf(s,e){const t=s.start+e;s.startPTS=t,s.setStart(t),s.endPTS=t+s.duration}function gv(s,e){const t=e.fragments;for(let i=0,n=t.length;i<n;i++)Bf(t[i],s);e.fragmentHint&&Bf(e.fragmentHint,s),e.alignedSliding=!0}function xI(s,e){s&&(pv(e,s),e.alignedSliding||pl(e,s),!e.alignedSliding&&!e.skippedSegments&&cv(s,e,!1))}function pv(s,e){if(!II(e,s))return;const t=Math.min(e.endCC,s.endCC),i=Rr(e.fragments,t),n=Rr(s.fragments,t);if(!i||!n)return;et.log(`Aligning playlist at start of dicontinuity sequence ${t}`);const r=i.start-n.start;gv(r,s)}function pl(s,e){if(!s.hasProgramDateTime||!e.hasProgramDateTime)return;const t=s.fragments,i=e.fragments;if(!t.length||!i.length)return;let n,r;const a=Math.min(e.endCC,s.endCC);e.startCC<a&&s.startCC<a&&(n=Rr(i,a),r=Rr(t,a)),(!n||!r)&&(n=i[Math.floor(i.length/2)],r=Rr(t,n.cc)||t[Math.floor(t.length/2)]);const o=n.programDateTime,d=r.programDateTime;if(!o||!d)return;const l=(d-o)/1e3-(r.start-n.start);gv(l,s)}function jt(s,e,t){ti(s,e,t),s.addEventListener(e,t)}function ti(s,e,t){s.removeEventListener(e,t)}const LI={toString:function(s){let e="";const t=s.length;for(let i=0;i<t;i++)e+=`[${s.start(i).toFixed(3)}-${s.end(i).toFixed(3)}]`;return e}},W={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"};class $u extends tv{constructor(e,t,i,n,r){super(n,e.logger),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=W.STOPPED,this.playlistType=void 0,this.media=null,this.mediaBuffer=null,this.config=void 0,this.bitrateTest=!1,this.lastCurrentTime=0,this.nextLoadPosition=0,this.startPosition=0,this.startTimeOffset=null,this.retryDate=0,this.levels=null,this.fragmentLoader=void 0,this.keyLoader=void 0,this.levelLastLoaded=null,this.startFragRequested=!1,this.decrypter=void 0,this.initPTS=[],this.buffering=!0,this.loadingParts=!1,this.loopSn=void 0,this.onMediaSeeking=()=>{const{config:a,fragCurrent:o,media:d,mediaBuffer:l,state:c}=this,u=d?d.currentTime:0,h=Me.bufferInfo(l||d,u,a.maxBufferHole),f=!h.len;if(this.log(`Media seeking to ${he(u)?u.toFixed(3):u}, state: ${c}, ${f?"out of":"in"} buffer`),this.state===W.ENDED)this.resetLoadingState();else if(o){const m=a.maxFragLookUpTolerance,p=o.start-m,g=o.start+o.duration+m;if(f||g<h.start||p>h.end){const y=u>g;(u<p||y)&&(y&&o.loader&&(this.log(`Cancelling fragment load for seek (sn: ${o.sn})`),o.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}if(d){this.fragmentTracker.removeFragmentsInRange(u,1/0,this.playlistType,!0);const m=this.lastCurrentTime;if(u>m&&(this.lastCurrentTime=u),!this.loadingParts){const p=Math.max(h.end,u),g=this.shouldLoadParts(this.getLevelDetails(),p);g&&(this.log(`LL-Part loading ON after seeking to ${u.toFixed(2)} with buffer @${p.toFixed(2)}`),this.loadingParts=g)}}this.hls.hasEnoughToStart||(this.log(`Setting ${f?"startPosition":"nextLoadPosition"} to ${u} for seek without enough to start`),this.nextLoadPosition=u,f&&(this.startPosition=u)),f&&this.state===W.IDLE&&this.tickImmediate()},this.onMediaEnded=()=>{this.log("setting startPosition to 0 because media ended"),this.startPosition=this.lastCurrentTime=0},this.playlistType=r,this.hls=e,this.fragmentLoader=new tI(e.config),this.keyLoader=i,this.fragmentTracker=t,this.config=e.config,this.decrypter=new Pu(e.config)}registerListeners(){const{hls:e}=this;e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(v.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(v.ERROR,this.onError,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(e){}stopLoad(){if(this.state===W.STOPPED)return;this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);const e=this.fragCurrent;e!=null&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=W.STOPPED}get startPositionValue(){const{nextLoadPosition:e,startPosition:t}=this;return t===-1&&e?e:t}get bufferingEnabled(){return this.buffering}pauseBuffering(){this.buffering=!1}resumeBuffering(){this.buffering=!0}get inFlightFrag(){return{frag:this.fragCurrent,state:this.state}}_streamEnded(e,t){if(t.live||!this.media)return!1;const i=e.end||0,n=this.config.timelineOffset||0;if(i<=n)return!1;const r=e.buffered;this.config.maxBufferHole&&r&&r.length>1&&(e=Me.bufferedInfo(r,e.start,0));const a=e.nextStart;if(a&&a>n&&a<t.edge||this.media.currentTime<e.start)return!1;const d=t.partList;if(d!=null&&d.length){const c=d[d.length-1];return Me.isBuffered(this.media,c.start+c.duration/2)}const l=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(l)}getLevelDetails(){if(this.levels&&this.levelLastLoaded!==null)return this.levelLastLoaded.details}get timelineOffset(){const e=this.config.timelineOffset;if(e){var t;return((t=this.getLevelDetails())==null?void 0:t.appliedTimelineOffset)||e}return 0}onMediaAttached(e,t){const i=this.media=this.mediaBuffer=t.media;jt(i,"seeking",this.onMediaSeeking),jt(i,"ended",this.onMediaEnded);const n=this.config;this.levels&&n.autoStartLoad&&this.state===W.STOPPED&&this.startLoad(n.startPosition)}onMediaDetaching(e,t){const i=!!t.transferMedia,n=this.media;if(n!==null){if(n.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),ti(n,"seeking",this.onMediaSeeking),ti(n,"ended",this.onMediaEnded),this.keyLoader&&!i&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loopSn=void 0,i){this.resetLoadingState(),this.resetTransmuxer();return}this.loadingParts=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}}onManifestLoading(){this.initPTS=[],this.levels=this.levelLastLoaded=this.fragCurrent=null,this.lastCurrentTime=this.startPosition=0,this.startFragRequested=!1}onError(e,t){}onManifestLoaded(e,t){this.startTimeOffset=t.startTimeOffset}onHandlerDestroying(){this.stopLoad(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),super.onHandlerDestroying(),this.hls=this.onMediaSeeking=this.onMediaEnded=null}onHandlerDestroyed(){this.state=W.STOPPED,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,super.onHandlerDestroyed()}loadFragment(e,t,i){this.startFragRequested=!0,this._loadFragForPlayback(e,t,i)}_loadFragForPlayback(e,t,i){const n=r=>{const a=r.frag;if(this.fragContextChanged(a)){this.warn(`${a.type} sn: ${a.sn}${r.part?" part: "+r.part.index:""} of ${this.fragInfo(a,!1,r.part)}) was dropped during download.`),this.fragmentTracker.removeFragment(a);return}a.stats.chunkCount++,this._handleFragmentLoadProgress(r)};this._doFragLoad(e,t,i,n).then(r=>{if(!r)return;const a=this.state,o=r.frag;if(this.fragContextChanged(o)){(a===W.FRAG_LOADING||!this.fragCurrent&&a===W.PARSING)&&(this.fragmentTracker.removeFragment(o),this.state=W.IDLE);return}"payload"in r&&(this.log(`Loaded ${o.type} sn: ${o.sn} of ${this.playlistLabel()} ${o.level}`),this.hls.trigger(v.FRAG_LOADED,r)),this._handleFragmentLoadComplete(r)}).catch(r=>{this.state===W.STOPPED||this.state===W.ERROR||(this.warn(`Frag error: ${r?.message||r}`),this.resetFragmentLoading(e))})}clearTrackerIfNeeded(e){var t;const{fragmentTracker:i}=this;if(i.getState(e)===Rt.APPENDING){const r=e.type,a=this.getFwdBufferInfo(this.mediaBuffer,r),o=Math.max(e.duration,a?a.len:this.config.maxBufferLength),d=this.backtrackFragment;((d?e.sn-d.sn:0)===1||this.reduceMaxBufferLength(o,e.duration))&&i.removeFragment(e)}else((t=this.mediaBuffer)==null?void 0:t.buffered.length)===0?i.removeAllFragments():i.hasParts(e.type)&&(i.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),i.getState(e)===Rt.PARTIAL&&i.removeFragment(e))}checkLiveUpdate(e){if(e.updated&&!e.live){const t=e.fragments[e.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type})}e.fragments[0]||(e.deltaUpdateFailed=!0)}waitForLive(e){const t=e.details;return t?.live&&t.type!=="EVENT"&&(this.levelLastLoaded!==e||t.expired)}flushMainBuffer(e,t,i=null){if(!(e-t))return;const n={startOffset:e,endOffset:t,type:i};this.hls.trigger(v.BUFFER_FLUSHING,n)}_loadInitSegment(e,t){this._doFragLoad(e,t).then(i=>{const n=i?.frag;if(!n||this.fragContextChanged(n)||!this.levels)throw new Error("init load aborted");return i}).then(i=>{const{hls:n}=this,{frag:r,payload:a}=i,o=r.decryptdata;if(a&&a.byteLength>0&&o!=null&&o.key&&o.iv&&Nn(o.method)){const d=self.performance.now();return this.decrypter.decrypt(new Uint8Array(a),o.key.buffer,o.iv.buffer,Ou(o.method)).catch(l=>{throw n.trigger(v.ERROR,{type:ye.MEDIA_ERROR,details:$.FRAG_DECRYPT_ERROR,fatal:!1,error:l,reason:l.message,frag:r}),l}).then(l=>{const c=self.performance.now();return n.trigger(v.FRAG_DECRYPTED,{frag:r,payload:l,stats:{tstart:d,tdecrypt:c}}),i.payload=l,this.completeInitSegmentLoad(i)})}return this.completeInitSegmentLoad(i)}).catch(i=>{this.state===W.STOPPED||this.state===W.ERROR||(this.warn(i),this.resetFragmentLoading(e))})}completeInitSegmentLoad(e){const{levels:t}=this;if(!t)throw new Error("init load aborted, missing levels");const i=e.frag.stats;this.state!==W.STOPPED&&(this.state=W.IDLE),e.frag.data=new Uint8Array(e.payload),i.parsing.start=i.buffering.start=self.performance.now(),i.parsing.end=i.buffering.end=self.performance.now(),this.tick()}unhandledEncryptionError(e,t){var i,n;const r=e.tracks;if(r&&!t.encrypted&&((i=r.audio)!=null&&i.encrypted||(n=r.video)!=null&&n.encrypted)&&(!this.config.emeEnabled||!this.keyLoader.emeController)){const a=this.media,o=new Error(`Encrypted track with no key in ${this.fragInfo(t)} (media ${a?"attached mediaKeys: "+a.mediaKeys:"detached"})`);return this.warn(o.message),!a||a.mediaKeys?!1:(this.hls.trigger(v.ERROR,{type:ye.KEY_SYSTEM_ERROR,details:$.KEY_SYSTEM_NO_KEYS,fatal:!1,error:o,frag:t}),this.resetTransmuxer(),!0)}return!1}fragContextChanged(e){const{fragCurrent:t}=this;return!e||!t||e.sn!==t.sn||e.level!==t.level}fragBufferedComplete(e,t){const i=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log(`Buffered ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,!1,t)} > buffer:${i?LI.toString(Me.getBuffered(i)):"(detached)"})`),yt(e)){var n;if(e.type!==ge.SUBTITLE){const a=e.elementaryStreams;if(!Object.keys(a).some(o=>!!a[o])){this.state=W.IDLE;return}}const r=(n=this.levels)==null?void 0:n[e.level];r!=null&&r.fragmentError&&(this.log(`Resetting level fragment error count of ${r.fragmentError} on frag buffered`),r.fragmentError=0)}this.state=W.IDLE}_handleFragmentLoadComplete(e){const{transmuxer:t}=this;if(!t)return;const{frag:i,part:n,partsLoaded:r}=e,a=!r||r.length===0||r.some(d=>!d),o=new Mu(i.level,i.sn,i.stats.chunkCount+1,0,n?n.index:-1,!a);t.flush(o)}_handleFragmentLoadProgress(e){}_doFragLoad(e,t,i=null,n){var r;this.fragCurrent=e;const a=t.details;if(!this.levels||!a)throw new Error(`frag load aborted, missing level${a?"":" detail"}s`);let o=null;if(e.encrypted&&!((r=e.decryptdata)!=null&&r.key)){if(this.log(`Loading key for ${e.sn} of [${a.startSN}-${a.endSN}], ${this.playlistLabel()} ${e.level}`),this.state=W.KEY_LOADING,this.fragCurrent=e,o=this.keyLoader.load(e).then(h=>{if(!this.fragContextChanged(h.frag))return this.hls.trigger(v.KEY_LOADED,h),this.state===W.KEY_LOADING&&(this.state=W.IDLE),h}),this.hls.trigger(v.KEY_LOADING,{frag:e}),this.fragCurrent===null)return this.log("context changed in KEY_LOADING"),Promise.resolve(null)}else e.encrypted||(o=this.keyLoader.loadClear(e,a.encryptedFragments,this.startFragRequested),o&&this.log("[eme] blocking frag load until media-keys acquired"));const d=this.fragPrevious;if(yt(e)&&(!d||e.sn!==d.sn)){const h=this.shouldLoadParts(t.details,e.end);h!==this.loadingParts&&(this.log(`LL-Part loading ${h?"ON":"OFF"} loading sn ${d?.sn}->${e.sn}`),this.loadingParts=h)}if(i=Math.max(e.start,i||0),this.loadingParts&&yt(e)){const h=a.partList;if(h&&n){i>a.fragmentEnd&&a.fragmentHint&&(e=a.fragmentHint);const f=this.getNextPart(h,e,i);if(f>-1){const m=h[f];e=this.fragCurrent=m.fragment,this.log(`Loading ${e.type} sn: ${e.sn} part: ${m.index} (${f}/${h.length-1}) of ${this.fragInfo(e,!1,m)}) cc: ${e.cc} [${a.startSN}-${a.endSN}], target: ${parseFloat(i.toFixed(3))}`),this.nextLoadPosition=m.start+m.duration,this.state=W.FRAG_LOADING;let p;return o?p=o.then(g=>!g||this.fragContextChanged(g.frag)?null:this.doFragPartsLoad(e,m,t,n)).catch(g=>this.handleFragLoadError(g)):p=this.doFragPartsLoad(e,m,t,n).catch(g=>this.handleFragLoadError(g)),this.hls.trigger(v.FRAG_LOADING,{frag:e,part:m,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):p}else if(!e.url||this.loadedEndOfParts(h,i))return Promise.resolve(null)}}if(yt(e)&&this.loadingParts){var l;this.log(`LL-Part loading OFF after next part miss @${i.toFixed(2)} Check buffer at sn: ${e.sn} loaded parts: ${(l=a.partList)==null?void 0:l.filter(h=>h.loaded).map(h=>`[${h.start}-${h.end}]`)}`),this.loadingParts=!1}else if(!e.url)return Promise.resolve(null);this.log(`Loading ${e.type} sn: ${e.sn} of ${this.fragInfo(e,!1)}) cc: ${e.cc} ${"["+a.startSN+"-"+a.endSN+"]"}, target: ${parseFloat(i.toFixed(3))}`),he(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=W.FRAG_LOADING;const c=this.config.progressive&&e.type!==ge.SUBTITLE;let u;return c&&o?u=o.then(h=>!h||this.fragContextChanged(h.frag)?null:this.fragmentLoader.load(e,n)).catch(h=>this.handleFragLoadError(h)):u=Promise.all([this.fragmentLoader.load(e,c?n:void 0),o]).then(([h])=>(!c&&n&&n(h),h)).catch(h=>this.handleFragLoadError(h)),this.hls.trigger(v.FRAG_LOADING,{frag:e,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):u}doFragPartsLoad(e,t,i,n){return new Promise((r,a)=>{var o;const d=[],l=(o=i.details)==null?void 0:o.partList,c=u=>{this.fragmentLoader.loadPart(e,u,n).then(h=>{d[u.index]=h;const f=h.part;this.hls.trigger(v.FRAG_LOADED,h);const m=Nf(i.details,e.sn,u.index+1)||fv(l,e.sn,u.index+1);if(m)c(m);else return r({frag:e,part:f,partsLoaded:d})}).catch(a)};c(t)})}handleFragLoadError(e){if("data"in e){const t=e.data;t.frag&&t.details===$.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):t.frag&&t.type===ye.KEY_SYSTEM_ERROR?(t.frag.abortRequests(),this.resetStartWhenNotLoaded(),this.resetFragmentLoading(t.frag)):this.hls.trigger(v.ERROR,t)}else this.hls.trigger(v.ERROR,{type:ye.OTHER_ERROR,details:$.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){const t=this.getCurrentContext(e);if(!t||this.state!==W.PARSING){!this.fragCurrent&&this.state!==W.STOPPED&&this.state!==W.ERROR&&(this.state=W.IDLE);return}const{frag:i,part:n,level:r}=t,a=self.performance.now();i.stats.parsing.end=a,n&&(n.stats.parsing.end=a);const o=this.getLevelDetails(),l=o&&i.sn>o.endSN||this.shouldLoadParts(o,i.end);l!==this.loadingParts&&(this.log(`LL-Part loading ${l?"ON":"OFF"} after parsing segment ending @${i.end.toFixed(2)}`),this.loadingParts=l),this.updateLevelTiming(i,n,r,e.partial)}shouldLoadParts(e,t){if(this.config.lowLatencyMode){if(!e)return this.loadingParts;if(e.partList){var i;const r=e.partList[0];if(r.fragment.type===ge.SUBTITLE)return!1;const a=r.end+(((i=e.fragmentHint)==null?void 0:i.duration)||0);if(t>=a){var n;if((this.hls.hasEnoughToStart?((n=this.media)==null?void 0:n.currentTime)||this.lastCurrentTime:this.getLoadPosition())>r.start-r.fragment.duration)return!0}}}return!1}getCurrentContext(e){const{levels:t,fragCurrent:i}=this,{level:n,sn:r,part:a}=e;if(!(t!=null&&t[n]))return this.warn(`Levels object was unset while buffering fragment ${r} of ${this.playlistLabel()} ${n}. The current chunk will not be buffered.`),null;const o=t[n],d=o.details,l=a>-1?Nf(d,r,a):null,c=l?l.fragment:hv(d,r,i);return c?(i&&i!==c&&(c.stats=i.stats),{frag:c,part:l,level:o}):null}bufferFragmentData(e,t,i,n,r){if(this.state!==W.PARSING)return;const{data1:a,data2:o}=e;let d=a;if(o&&(d=gi(a,o)),!d.length)return;const l=this.initPTS[t.cc],c=l?-l.baseTime/l.timescale:void 0,u={type:e.type,frag:t,part:i,chunkMeta:n,offset:c,parent:t.type,data:d};if(this.hls.trigger(v.BUFFER_APPENDING,u),e.dropped&&e.independent&&!i){if(r)return;this.flushBufferGap(t)}}flushBufferGap(e){const t=this.media;if(!t)return;if(!Me.isBuffered(t,t.currentTime)){this.flushMainBuffer(0,e.start);return}const i=t.currentTime,n=Me.bufferInfo(t,i,0),r=e.duration,a=Math.min(this.config.maxFragLookUpTolerance*2,r*.25),o=Math.max(Math.min(e.start-a,n.end-a),i+a);e.start-o>a&&this.flushMainBuffer(o,e.start)}getFwdBufferInfo(e,t){var i;const n=this.getLoadPosition();if(!he(n))return null;const a=this.lastCurrentTime>n||(i=this.media)!=null&&i.paused?0:this.config.maxBufferHole;return this.getFwdBufferInfoAtPos(e,n,t,a)}getFwdBufferInfoAtPos(e,t,i,n){const r=Me.bufferInfo(e,t,n);if(r.len===0&&r.nextStart!==void 0){const a=this.fragmentTracker.getBufferedFrag(t,i);if(a&&(r.nextStart<=a.end||a.gap)){const o=Math.max(Math.min(r.nextStart,a.end)-t,n);return Me.bufferInfo(e,t,o)}}return r}getMaxBufferLength(e){const{config:t}=this;let i;return e?i=Math.max(8*t.maxBufferSize/e,t.maxBufferLength):i=t.maxBufferLength,Math.min(i,t.maxMaxBufferLength)}reduceMaxBufferLength(e,t){const i=this.config,n=Math.max(Math.min(e-t,i.maxBufferLength),t),r=Math.max(e-t*3,i.maxMaxBufferLength/2,n);return r>=n?(i.maxMaxBufferLength=r,this.warn(`Reduce max buffer length to ${r}s`),!0):!1}getAppendedFrag(e,t=ge.MAIN){const i=this.fragmentTracker?this.fragmentTracker.getAppendedFrag(e,t):null;return i&&"fragment"in i?i.fragment:i}getNextFragment(e,t){const i=t.fragments,n=i.length;if(!n)return null;const{config:r}=this,a=i[0].start,o=r.lowLatencyMode&&!!t.partList;let d=null;if(t.live){const u=r.initialLiveManifestSize;if(n<u)return this.warn(`Not enough fragments to start playback (have: ${n}, need: ${u})`),null;if(!t.PTSKnown&&!this.startFragRequested&&this.startPosition===-1||e<a){var l;o&&!this.loadingParts&&(this.log("LL-Part loading ON for initial live fragment"),this.loadingParts=!0),d=this.getInitialLiveFragment(t);const h=this.hls.startPosition,f=this.hls.liveSyncPosition,m=d?(h!==-1&&h>=a?h:f)||d.start:e;this.log(`Setting startPosition to ${m} to match start frag at live edge. mainStart: ${h} liveSyncPosition: ${f} frag.start: ${(l=d)==null?void 0:l.start}`),this.startPosition=this.nextLoadPosition=m}}else e<=a&&(d=i[0]);if(!d){const u=this.loadingParts?t.partEnd:t.fragmentEnd;d=this.getFragmentAtPosition(e,u,t)}let c=this.filterReplacedPrimary(d,t);if(!c&&d){const u=d.sn-t.startSN;c=this.filterReplacedPrimary(i[u+1]||null,t)}return this.mapToInitFragWhenRequired(c)}isLoopLoading(e,t){const i=this.fragmentTracker.getState(e);return(i===Rt.OK||i===Rt.PARTIAL&&!!e.gap)&&this.nextLoadPosition>t}getNextFragmentLoopLoading(e,t,i,n,r){let a=null;if(e.gap&&(a=this.getNextFragment(this.nextLoadPosition,t),a&&!a.gap&&i.nextStart)){const o=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,i.nextStart,n,0);if(o!==null&&i.len+o.len>=r){const d=a.sn;return this.loopSn!==d&&(this.log(`buffer full after gaps in "${n}" playlist starting at sn: ${d}`),this.loopSn=d),null}}return this.loopSn=void 0,a}get primaryPrefetch(){if(Gf(this.config)){var e;if((e=this.hls.interstitialsManager)==null||(e=e.playingItem)==null?void 0:e.event)return!0}return!1}filterReplacedPrimary(e,t){if(!e)return e;if(Gf(this.config)&&e.type!==ge.SUBTITLE){const i=this.hls.interstitialsManager,n=i?.bufferingItem;if(n){const a=n.event;if(a){if(a.appendInPlace||Math.abs(e.start-n.start)>1||n.start===0)return null}else if(e.end<=n.start&&t?.live===!1||e.start>n.end&&n.nextEvent&&(n.nextEvent.appendInPlace||e.start-n.end>1))return null}const r=i?.playerQueue;if(r)for(let a=r.length;a--;){const o=r[a].interstitial;if(o.appendInPlace&&e.start>=o.startTime&&e.end<=o.resumeTime)return null}}return e}mapToInitFragWhenRequired(e){return e!=null&&e.initSegment&&!e.initSegment.data&&!this.bitrateTest?e.initSegment:e}getNextPart(e,t,i){let n=-1,r=!1,a=!0;for(let o=0,d=e.length;o<d;o++){const l=e[o];if(a=a&&!l.independent,n>-1&&i<l.start)break;const c=l.loaded;c?n=-1:(r||(l.independent||a)&&l.fragment===t)&&(l.fragment!==t&&this.warn(`Need buffer at ${i} but next unloaded part starts at ${l.start}`),n=o),r=c}return n}loadedEndOfParts(e,t){let i;for(let n=e.length;n--;){if(i=e[n],!i.loaded)return!1;if(t>i.start)return!0}return!1}getInitialLiveFragment(e){const t=e.fragments,i=this.fragPrevious;let n=null;if(i){if(e.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${i.programDateTime}`),n=HA(t,i.endProgramDateTime,this.config.maxFragLookUpTolerance)),!n){const r=i.sn+1;if(r>=e.startSN&&r<=e.endSN){const a=t[r-e.startSN];i.cc===a.cc&&(n=a,this.log(`Live playlist, switching playlist, load frag with next SN: ${n.sn}`))}n||(n=Zp(e,i.cc,i.end),n&&this.log(`Live playlist, switching playlist, load frag with same CC: ${n.sn}`))}}else{const r=this.hls.liveSyncPosition;r!==null&&(n=this.getFragmentAtPosition(r,this.bitrateTest?e.fragmentEnd:e.edge,e))}return n}getFragmentAtPosition(e,t,i){const{config:n}=this;let{fragPrevious:r}=this,{fragments:a,endSN:o}=i;const{fragmentHint:d}=i,{maxFragLookUpTolerance:l}=n,c=i.partList,u=!!(this.loadingParts&&c!=null&&c.length&&d);u&&!this.bitrateTest&&c[c.length-1].fragment.sn===d.sn&&(a=a.concat(d),o=d.sn);let h;if(e<t){var f;const p=e<this.lastCurrentTime||e>t-l||(f=this.media)!=null&&f.paused||!this.startFragRequested?0:l;h=Qs(r,a,e,p)}else h=a[a.length-1];if(h){const m=h.sn-i.startSN,p=this.fragmentTracker.getState(h);if((p===Rt.OK||p===Rt.PARTIAL&&h.gap)&&(r=h),r&&h.sn===r.sn&&(!u||c[0].fragment.sn>h.sn||!i.live)&&h.level===r.level){const y=a[m+1];h.sn<o&&this.fragmentTracker.getState(y)!==Rt.OK?h=y:h=null}}return h}alignPlaylists(e,t,i){const n=e.fragments.length;if(!n)return this.warn("No fragments in live playlist"),0;const r=e.fragmentStart,a=!t,o=e.alignedSliding&&he(r);if(a||!o&&!r){xI(i,e);const d=e.fragmentStart;return this.log(`Live playlist sliding: ${d.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${e.startSN} fragments: ${n}`),d}return r}waitForCdnTuneIn(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,e.partTarget*3)}setStartPosition(e,t){let i=this.startPosition;i<t&&(i=-1);const n=this.timelineOffset;if(i===-1){const r=this.startTimeOffset!==null,a=r?this.startTimeOffset:e.startTimeOffset;a!==null&&he(a)?(i=t+a,a<0&&(i+=e.edge),i=Math.min(Math.max(t,i),t+e.totalduration),this.log(`Setting startPosition to ${i} for start time offset ${a} found in ${r?"multivariant":"media"} playlist`),this.startPosition=i):e.live?(i=this.hls.liveSyncPosition||t,this.log(`Setting startPosition to -1 to start at live edge ${i}`),this.startPosition=-1):(this.log("setting startPosition to 0 by default"),this.startPosition=i=0),this.lastCurrentTime=i+n}this.nextLoadPosition=i+n}getLoadPosition(){var e;const{media:t}=this;let i=0;return(e=this.hls)!=null&&e.hasEnoughToStart&&t?i=t.currentTime:this.nextLoadPosition>=0&&(i=this.nextLoadPosition),i}handleFragLoadAborted(e,t){this.transmuxer&&e.type===this.playlistType&&yt(e)&&e.stats.aborted&&(this.log(`Fragment ${e.sn}${t?" part "+t.index:""} of ${this.playlistLabel()} ${e.level} was aborted`),this.resetFragmentLoading(e))}resetFragmentLoading(e){(!this.fragCurrent||!this.fragContextChanged(e)&&this.state!==W.FRAG_LOADING_WAITING_RETRY)&&(this.state=W.IDLE)}onFragmentOrKeyLoadError(e,t){var i;if(t.chunkMeta&&!t.frag){const y=this.getCurrentContext(t.chunkMeta);y&&(t.frag=y.frag)}const n=t.frag;if(!n||n.type!==e||!this.levels)return;if(this.fragContextChanged(n)){var r;this.warn(`Frag load error must match current frag to retry ${n.url} > ${(r=this.fragCurrent)==null?void 0:r.url}`);return}const a=t.details===$.FRAG_GAP;a&&this.fragmentTracker.fragBuffered(n,!0);const o=t.errorAction;if(!o){this.state=W.ERROR;return}const{action:d,flags:l,retryCount:c=0,retryConfig:u}=o,h=!!u,f=h&&d===Ut.RetryRequest,m=h&&!o.resolved&&l===ri.MoveAllAlternatesMatchingHost,p=(i=this.hls.latestLevelDetails)==null?void 0:i.live;if(!f&&m&&yt(n)&&!n.endList&&p&&!ev(t))this.resetFragmentErrors(e),this.treatAsGap(n),o.resolved=!0;else if((f||m)&&c<u.maxNumRetry){var g;const y=Pc((g=t.response)==null?void 0:g.code),T=wu(u,c);if(this.resetStartWhenNotLoaded(),this.retryDate=self.performance.now()+T,this.state=W.FRAG_LOADING_WAITING_RETRY,o.resolved=!0,y){this.log("Waiting for connection (offline)"),this.retryDate=1/0,t.reason="offline";return}this.warn(`Fragment ${n.sn} of ${e} ${n.level} errored with ${t.details}, retrying loading ${c+1}/${u.maxNumRetry} in ${T}ms`)}else if(u)if(this.resetFragmentErrors(e),c<u.maxNumRetry)!a&&d!==Ut.RemoveAlternatePermanently&&(o.resolved=!0);else{this.warn(`${t.details} reached or exceeded max retry (${c})`);return}else d===Ut.SendAlternateToPenaltyBox?this.state=W.WAITING_LEVEL:this.state=W.ERROR;this.tickImmediate()}checkRetryDate(){const e=self.performance.now(),t=this.retryDate,i=t===1/0;(!t||e>=t||i&&!Pc(0))&&(i&&this.log("Connection restored (online)"),this.resetStartWhenNotLoaded(),this.state=W.IDLE)}reduceLengthAndFlushBuffer(e){if(this.state===W.PARSING||this.state===W.PARSED){const t=e.frag,i=e.parent,n=this.getFwdBufferInfo(this.mediaBuffer,i),r=n&&n.len>.5;r&&this.reduceMaxBufferLength(n.len,t?.duration||10);const a=!r;return a&&this.warn(`Buffer full error while media.currentTime (${this.getLoadPosition()}) is not buffered, flush ${i} buffer`),t&&(this.fragmentTracker.removeFragment(t),this.nextLoadPosition=t.start),this.resetLoadingState(),a}return!1}resetFragmentErrors(e){e===ge.AUDIO&&(this.fragCurrent=null),this.hls.hasEnoughToStart||(this.startFragRequested=!1),this.state!==W.STOPPED&&(this.state=W.IDLE)}afterBufferFlushed(e,t,i){if(!e)return;const n=Me.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,n,i),this.state===W.ENDED&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==W.STOPPED&&(this.state=W.IDLE)}resetStartWhenNotLoaded(){if(!this.hls.hasEnoughToStart){this.startFragRequested=!1;const e=this.levelLastLoaded,t=e?e.details:null;t!=null&&t.live?(this.log("resetting startPosition for live start"),this.startPosition=-1,this.setStartPosition(t,t.fragmentStart),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(e){this.log(`Loading context changed while buffering sn ${e.sn} of ${this.playlistLabel()} ${e.level===-1?"<removed>":e.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(),this.resetLoadingState()}removeUnbufferedFrags(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}updateLevelTiming(e,t,i,n){const r=i.details;if(!r){this.warn("level.details undefined");return}if(!Object.keys(e.elementaryStreams).reduce((d,l)=>{const c=e.elementaryStreams[l];if(c){const u=c.endPTS-c.startPTS;if(u<=0)return this.warn(`Could not parse fragment ${e.sn} ${l} duration reliably (${u})`),d||!1;const h=n?0:dv(r,e,c.startPTS,c.endPTS,c.startDTS,c.endDTS,this);return this.hls.trigger(v.LEVEL_PTS_UPDATED,{details:r,level:i,drift:h,type:l,frag:e,start:c.startPTS,end:c.endPTS}),!0}return d},!1)){var o;const d=((o=this.transmuxer)==null?void 0:o.error)===null;if((i.fragmentError===0||d&&(i.fragmentError<2||e.endList))&&this.treatAsGap(e,i),d){const l=new Error(`Found no media in fragment ${e.sn} of ${this.playlistLabel()} ${e.level} resetting transmuxer to fallback to playlist timing`);if(this.warn(l.message),this.hls.trigger(v.ERROR,{type:ye.MEDIA_ERROR,details:$.FRAG_PARSING_ERROR,fatal:!1,error:l,frag:e,reason:`Found no media in msn ${e.sn} of ${this.playlistLabel()} "${i.url}"`}),!this.hls)return;this.resetTransmuxer()}}this.state=W.PARSED,this.log(`Parsed ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,!1,t)})`),this.hls.trigger(v.FRAG_PARSED,{frag:e,part:t})}playlistLabel(){return this.playlistType===ge.MAIN?"level":"track"}fragInfo(e,t=!0,i){var n,r;return`${this.playlistLabel()} ${e.level} (${i?"part":"frag"}:[${((n=t&&!i?e.startPTS:(i||e).start)!=null?n:NaN).toFixed(3)}-${((r=t&&!i?e.endPTS:(i||e).end)!=null?r:NaN).toFixed(3)}]${i&&e.type==="main"?"INDEPENDENT="+(i.independent?"YES":"NO"):""}`}treatAsGap(e,t){t&&t.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)}resetTransmuxer(){var e;(e=this.transmuxer)==null||e.reset()}recoverWorkerError(e){e.event==="demuxerWorker"&&(this.fragmentTracker.removeAllFragments(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),this.resetStartWhenNotLoaded(),this.resetLoadingState())}set state(e){const t=this._state;t!==e&&(this._state=e,this.log(`${t}->${e}`))}get state(){return this._state}}function Gf(s){return!!s.interstitialsController&&s.enableInterstitialPlayback!==!1}class vv{constructor(){this.chunks=[],this.dataLength=0}push(e){this.chunks.push(e),this.dataLength+=e.length}flush(){const{chunks:e,dataLength:t}=this;let i;if(e.length)e.length===1?i=e[0]:i=RI(e,t);else return new Uint8Array(0);return this.reset(),i}reset(){this.chunks.length=0,this.dataLength=0}}function RI(s,e){const t=new Uint8Array(e);let i=0;for(let n=0;n<s.length;n++){const r=s[n];t.set(r,i),i+=r.length}return t}var od={exports:{}},Kf;function kI(){return Kf||(Kf=1,(function(s){var e=Object.prototype.hasOwnProperty,t="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(t=!1));function n(d,l,c){this.fn=d,this.context=l,this.once=c||!1}function r(d,l,c,u,h){if(typeof c!="function")throw new TypeError("The listener must be a function");var f=new n(c,u||d,h),m=t?t+l:l;return d._events[m]?d._events[m].fn?d._events[m]=[d._events[m],f]:d._events[m].push(f):(d._events[m]=f,d._eventsCount++),d}function a(d,l){--d._eventsCount===0?d._events=new i:delete d._events[l]}function o(){this._events=new i,this._eventsCount=0}o.prototype.eventNames=function(){var l=[],c,u;if(this._eventsCount===0)return l;for(u in c=this._events)e.call(c,u)&&l.push(t?u.slice(1):u);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(c)):l},o.prototype.listeners=function(l){var c=t?t+l:l,u=this._events[c];if(!u)return[];if(u.fn)return[u.fn];for(var h=0,f=u.length,m=new Array(f);h<f;h++)m[h]=u[h].fn;return m},o.prototype.listenerCount=function(l){var c=t?t+l:l,u=this._events[c];return u?u.fn?1:u.length:0},o.prototype.emit=function(l,c,u,h,f,m){var p=t?t+l:l;if(!this._events[p])return!1;var g=this._events[p],y=arguments.length,T,_;if(g.fn){switch(g.once&&this.removeListener(l,g.fn,void 0,!0),y){case 1:return g.fn.call(g.context),!0;case 2:return g.fn.call(g.context,c),!0;case 3:return g.fn.call(g.context,c,u),!0;case 4:return g.fn.call(g.context,c,u,h),!0;case 5:return g.fn.call(g.context,c,u,h,f),!0;case 6:return g.fn.call(g.context,c,u,h,f,m),!0}for(_=1,T=new Array(y-1);_<y;_++)T[_-1]=arguments[_];g.fn.apply(g.context,T)}else{var I=g.length,R;for(_=0;_<I;_++)switch(g[_].once&&this.removeListener(l,g[_].fn,void 0,!0),y){case 1:g[_].fn.call(g[_].context);break;case 2:g[_].fn.call(g[_].context,c);break;case 3:g[_].fn.call(g[_].context,c,u);break;case 4:g[_].fn.call(g[_].context,c,u,h);break;default:if(!T)for(R=1,T=new Array(y-1);R<y;R++)T[R-1]=arguments[R];g[_].fn.apply(g[_].context,T)}}return!0},o.prototype.on=function(l,c,u){return r(this,l,c,u,!1)},o.prototype.once=function(l,c,u){return r(this,l,c,u,!0)},o.prototype.removeListener=function(l,c,u,h){var f=t?t+l:l;if(!this._events[f])return this;if(!c)return a(this,f),this;var m=this._events[f];if(m.fn)m.fn===c&&(!h||m.once)&&(!u||m.context===u)&&a(this,f);else{for(var p=0,g=[],y=m.length;p<y;p++)(m[p].fn!==c||h&&!m[p].once||u&&m[p].context!==u)&&g.push(m[p]);g.length?this._events[f]=g.length===1?g[0]:g:a(this,f)}return this},o.prototype.removeAllListeners=function(l){var c;return l?(c=t?t+l:l,this._events[c]&&a(this,c)):(this._events=new i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=t,o.EventEmitter=o,s.exports=o})(od)),od.exports}var DI=kI(),Nu=tA(DI);const Wr="1.6.15",jn={};function CI(){return typeof __HLS_WORKER_BUNDLE__=="function"}function wI(){const s=jn[Wr];if(s)return s.clientCount++,s;const e=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),t=self.URL.createObjectURL(e),n={worker:new self.Worker(t),objectURL:t,clientCount:1};return jn[Wr]=n,n}function PI(s){const e=jn[s];if(e)return e.clientCount++,e;const t=new self.URL(s,self.location.href).href,n={worker:new self.Worker(t),scriptURL:t,clientCount:1};return jn[s]=n,n}function MI(s){const e=jn[s||Wr];if(e&&e.clientCount--===1){const{worker:i,objectURL:n}=e;delete jn[s||Wr],n&&self.URL.revokeObjectURL(n),i.terminate()}}function Ev(s,e){return e+10<=s.length&&s[e]===51&&s[e+1]===68&&s[e+2]===73&&s[e+3]<255&&s[e+4]<255&&s[e+6]<128&&s[e+7]<128&&s[e+8]<128&&s[e+9]<128}function Uu(s,e){return e+10<=s.length&&s[e]===73&&s[e+1]===68&&s[e+2]===51&&s[e+3]<255&&s[e+4]<255&&s[e+6]<128&&s[e+7]<128&&s[e+8]<128&&s[e+9]<128}function wl(s,e){let t=0;return t=(s[e]&127)<<21,t|=(s[e+1]&127)<<14,t|=(s[e+2]&127)<<7,t|=s[e+3]&127,t}function qr(s,e){const t=e;let i=0;for(;Uu(s,e);){i+=10;const n=wl(s,e+6);i+=n,Ev(s,e+10)&&(i+=10),e+=i}if(i>0)return s.subarray(t,t+i)}function OI(s,e,t,i){const n=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],r=e[t+2],a=r>>2&15;if(a>12){const f=new Error(`invalid ADTS sampling index:${a}`);s.emit(v.ERROR,v.ERROR,{type:ye.MEDIA_ERROR,details:$.FRAG_PARSING_ERROR,fatal:!0,error:f,reason:f.message});return}const o=(r>>6&3)+1,d=e[t+3]>>6&3|(r&1)<<2,l="mp4a.40."+o,c=n[a];let u=a;(o===5||o===29)&&(u-=3);const h=[o<<3|(u&14)>>1,(u&1)<<7|d<<3];return et.log(`manifest codec:${i}, parsed codec:${l}, channels:${d}, rate:${c} (ADTS object type:${o} sampling index:${a})`),{config:h,samplerate:c,channelCount:d,codec:l,parsedCodec:l,manifestCodec:i}}function yv(s,e){return s[e]===255&&(s[e+1]&246)===240}function Tv(s,e){return s[e+1]&1?7:9}function Bu(s,e){return(s[e+3]&3)<<11|s[e+4]<<3|(s[e+5]&224)>>>5}function FI(s,e){return e+5<s.length}function vl(s,e){return e+1<s.length&&yv(s,e)}function $I(s,e){return FI(s,e)&&yv(s,e)&&Bu(s,e)<=s.length-e}function NI(s,e){if(vl(s,e)){const t=Tv(s,e);if(e+t>=s.length)return!1;const i=Bu(s,e);if(i<=t)return!1;const n=e+i;return n===s.length||vl(s,n)}return!1}function bv(s,e,t,i,n){if(!s.samplerate){const r=OI(e,t,i,n);if(!r)return;nt(s,r)}}function _v(s){return 1024*9e4/s}function UI(s,e){const t=Tv(s,e);if(e+t<=s.length){const i=Bu(s,e)-t;if(i>0)return{headerLength:t,frameLength:i}}}function Sv(s,e,t,i,n){const r=_v(s.samplerate),a=i+n*r,o=UI(e,t);let d;if(o){const{frameLength:u,headerLength:h}=o,f=h+u,m=Math.max(0,t+f-e.length);m?(d=new Uint8Array(f-h),d.set(e.subarray(t+h,e.length),0)):d=e.subarray(t+h,t+f);const p={unit:d,pts:a};return m||s.samples.push(p),{sample:p,length:f,missing:m}}const l=e.length-t;return d=new Uint8Array(l),d.set(e.subarray(t,e.length),0),{sample:{unit:d,pts:a},length:l,missing:-1}}function BI(s,e){return Uu(s,e)&&wl(s,e+6)+10<=s.length-e}function GI(s){return s instanceof ArrayBuffer?s:s.byteOffset==0&&s.byteLength==s.buffer.byteLength?s.buffer:new Uint8Array(s).buffer}function ld(s,e=0,t=1/0){return KI(s,e,t,Uint8Array)}function KI(s,e,t,i){const n=HI(s);let r=1;"BYTES_PER_ELEMENT"in i&&(r=i.BYTES_PER_ELEMENT);const a=VI(s)?s.byteOffset:0,o=(a+s.byteLength)/r,d=(a+e)/r,l=Math.floor(Math.max(0,Math.min(d,o))),c=Math.floor(Math.min(l+Math.max(t,0),o));return new i(n,l,c-l)}function HI(s){return s instanceof ArrayBuffer?s:s.buffer}function VI(s){return s&&s.buffer instanceof ArrayBuffer&&s.byteLength!==void 0&&s.byteOffset!==void 0}function WI(s){const e={key:s.type,description:"",data:"",mimeType:null,pictureType:null},t=3;if(s.size<2)return;if(s.data[0]!==t){console.log("Ignore frame with unrecognized character encoding");return}const i=s.data.subarray(1).indexOf(0);if(i===-1)return;const n=li(ld(s.data,1,i)),r=s.data[2+i],a=s.data.subarray(3+i).indexOf(0);if(a===-1)return;const o=li(ld(s.data,3+i,a));let d;return n==="-->"?d=li(ld(s.data,4+i+a)):d=GI(s.data.subarray(4+i+a)),e.mimeType=n,e.pictureType=r,e.description=o,e.data=d,e}function qI(s){if(s.size<2)return;const e=li(s.data,!0),t=new Uint8Array(s.data.subarray(e.length+1));return{key:s.type,info:e,data:t.buffer}}function YI(s){if(s.size<2)return;if(s.type==="TXXX"){let t=1;const i=li(s.data.subarray(t),!0);t+=i.length+1;const n=li(s.data.subarray(t));return{key:s.type,info:i,data:n}}const e=li(s.data.subarray(1));return{key:s.type,info:"",data:e}}function zI(s){if(s.type==="WXXX"){if(s.size<2)return;let t=1;const i=li(s.data.subarray(t),!0);t+=i.length+1;const n=li(s.data.subarray(t));return{key:s.type,info:i,data:n}}const e=li(s.data);return{key:s.type,info:"",data:e}}function jI(s){return s.type==="PRIV"?qI(s):s.type[0]==="W"?zI(s):s.type==="APIC"?WI(s):YI(s)}function XI(s){const e=String.fromCharCode(s[0],s[1],s[2],s[3]),t=wl(s,4),i=10;return{type:e,size:t,data:s.subarray(i,i+t)}}const wa=10,QI=10;function Av(s){let e=0;const t=[];for(;
vendor: 8,396 bytes, line 1499
1499Uu(s,e);){const i=wl(s,e+6);s[e+5]>>6&1&&(e+=wa),e+=wa;const n=e+i;for(;e+QI<n;){const r=XI(s.subarray(e)),a=jI(r);a&&t.push(a),e+=r.size+wa}Ev(s,e)&&(e+=wa)}return t}function Iv(s){return s&&s.key==="PRIV"&&s.info==="com.apple.streaming.transportStreamTimestamp"}function ZI(s){if(s.data.byteLength===8){const e=new Uint8Array(s.data),t=e[3]&1;let i=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7];return i/=45,t&&(i+=4772185884e-2),Math.round(i)}}function Gu(s){const e=Av(s);for(let t=0;t<e.length;t++){const i=e[t];if(Iv(i))return ZI(i)}}let oi=(function(s){return s.audioId3="org.id3",s.dateRange="com.apple.quicktime.HLS",s.emsg="https://aomedia.org/emsg/ID3",s.misbklv="urn:misb:KLV:bin:1910.1",s})({});function Gi(s="",e=9e4){return{type:s,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}class Ku{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}resetInitSegment(e,t,i,n){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(e){this.initPTS=e,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(e,t){return!1}appendFrame(e,t,i){}demux(e,t){this.cachedData&&(e=gi(this.cachedData,e),this.cachedData=null);let i=qr(e,0),n=i?i.length:0,r;const a=this._audioTrack,o=this._id3Track,d=i?Gu(i):void 0,l=e.length;for((this.basePTS===null||this.frameIndex===0&&he(d))&&(this.basePTS=JI(d,t,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),i&&i.length>0&&o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:oi.audioId3,duration:Number.POSITIVE_INFINITY});n<l;){if(this.canParse(e,n)){const c=this.appendFrame(a,e,n);c?(this.frameIndex++,this.lastPTS=c.sample.pts,n+=c.length,r=n):n=l}else BI(e,n)?(i=qr(e,n),o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:oi.audioId3,duration:Number.POSITIVE_INFINITY}),n+=i.length,r=n):n++;if(n===l&&r!==l){const c=e.slice(r);this.cachedData?this.cachedData=gi(this.cachedData,c):this.cachedData=c}}return{audioTrack:a,videoTrack:Gi(),id3Track:o,textTrack:Gi()}}demuxSampleAes(e,t,i){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(e){const t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:Gi(),id3Track:this._id3Track,textTrack:Gi()}}destroy(){this.cachedData=null,this._audioTrack=this._id3Track=void 0}}const JI=(s,e,t)=>{if(he(s))return s*90;const i=t?t.baseTime*9e4/t.timescale:0;return e*9e4+i};let Pa=null;const ex=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],tx=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],ix=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],sx=[0,1,1,4];function xv(s,e,t,i,n){if(t+24>e.length)return;const r=Lv(e,t);if(r&&t+r.frameLength<=e.length){const a=r.samplesPerFrame*9e4/r.sampleRate,o=i+n*a,d={unit:e.subarray(t,t+r.frameLength),pts:o,dts:o};return s.config=[],s.channelCount=r.channelCount,s.samplerate=r.sampleRate,s.samples.push(d),{sample:d,length:r.frameLength,missing:0}}}function Lv(s,e){const t=s[e+1]>>3&3,i=s[e+1]>>1&3,n=s[e+2]>>4&15,r=s[e+2]>>2&3;if(t!==1&&n!==0&&n!==15&&r!==3){const a=s[e+2]>>1&1,o=s[e+3]>>6,d=t===3?3-i:i===3?3:4,l=ex[d*14+n-1]*1e3,u=tx[(t===3?0:t===2?1:2)*3+r],h=o===3?1:2,f=ix[t][i],m=sx[i],p=f*8*m,g=Math.floor(f*l/u+a)*m;if(Pa===null){const _=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Pa=_?parseInt(_[1]):0}return Pa&&Pa<=87&&i===2&&l>=224e3&&o===0&&(s[e+3]=s[e+3]|128),{sampleRate:u,channelCount:h,frameLength:g,samplesPerFrame:p}}}function Hu(s,e){return s[e]===255&&(s[e+1]&224)===224&&(s[e+1]&6)!==0}function Rv(s,e){return e+1<s.length&&Hu(s,e)}function nx(s,e){return Hu(s,e)&&4<=s.length-e}function kv(s,e){if(e+1<s.length&&Hu(s,e)){const i=Lv(s,e);let n=4;i!=null&&i.frameLength&&(n=i.frameLength);const r=e+n;return r===s.length||Rv(s,r)}return!1}class rx extends Ku{constructor(e,t){super(),this.observer=void 0,this.config=void 0,this.observer=e,this.config=t}resetInitSegment(e,t,i,n){super.resetInitSegment(e,t,i,n),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:n,inputTimeScale:9e4,dropped:0}}static probe(e,t){if(!e)return!1;const i=qr(e,0);let n=i?.length||0;if(kv(e,n))return!1;for(let r=e.length;n<r;n++)if(NI(e,n))return t.log("ADTS sync word found !"),!0;return!1}canParse(e,t){return $I(e,t)}appendFrame(e,t,i){bv(e,this.observer,t,i,e.manifestCodec);const n=Sv(e,t,i,this.basePTS,this.frameIndex);if(n&&n.missing===0)return n}}const Dv=(s,e)=>{let t=0,i=5;e+=i;const n=new Uint32Array(1),r=new Uint32Array(1),a=new Uint8Array(1);for(;i>0;){a[0]=s[e];const o=Math.min(i,8),d=8-o;r[0]=4278190080>>>24+d<<d,n[0]=(a[0]&r[0])>>d,t=t?t<<o|n[0]:n[0],e+=1,i-=o}return t};class ax extends Ku{constructor(e){super(),this.observer=void 0,this.observer=e}resetInitSegment(e,t,i,n){super.resetInitSegment(e,t,i,n),this._audioTrack={container:"audio/ac-3",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"ac3",samples:[],manifestCodec:t,duration:n,inputTimeScale:9e4,dropped:0}}canParse(e,t){return t+64<e.length}appendFrame(e,t,i){const n=Cv(e,t,i,this.basePTS,this.frameIndex);if(n!==-1)return{sample:e.samples[e.samples.length-1],length:n,missing:0}}static probe(e){if(!e)return!1;const t=qr(e,0);if(!t)return!1;const i=t.length;return e[i]===11&&e[i+1]===119&&Gu(t)!==void 0&&Dv(e,i)<16}}function Cv(s,e,t,i,n){if(t+8>e.length||e[t]!==11||e[t+1]!==119)return-1;const r=e[t+4]>>6;if(r>=3)return-1;const o=[48e3,44100,32e3][r],d=e[t+4]&63,c=[64,69,96,64,70,96,80,87,120,80,88,120,96,104,144,96,105,144,112,121,168,112,122,168,128,139,192,128,140,192,160,174,240,160,175,240,192,208,288,192,209,288,224,243,336,224,244,336,256,278,384,256,279,384,320,348,480,320,349,480,384,417,576,384,418,576,448,487,672,448,488,672,512,557,768,512,558,768,640,696,960,640,697,960,768,835,1152,768,836,1152,896,975,1344,896,976,1344,1024,1114,1536,1024,1115,1536,1152,1253,1728,1152,1254,1728,1280,1393,1920,1280,1394,1920][d*3+r]*2;if(t+c>e.length)return-1;const u=e[t+6]>>5;let h=0;u===2?h+=2:(u&1&&u!==1&&(h+=2),u&4&&(h+=2));const f=(e[t+6]<<8|e[t+7])>>12-h&1,p=[2,1,2,3,3,4,4,5][u]+f,g=e[t+5]>>3,y=e[t+5]&7,T=new Uint8Array([r<<6|g<<1|y>>2,(y&3)<<6|u<<3|f<<2|d>>4,d<<4&224]),_=1536/o*9e4,I=i+n*_,R=e.subarray(t,t+c);return s.config=T,s.channelCount=p,s.samplerate=o,s.samples.push({unit:R,pts:I}),c}class ox extends Ku{resetInitSegment(e,t,i,n){super.resetInitSegment(e,t,i,n),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:t,duration:n,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;const t=qr(e,0);let i=t?.length||0;if(t&&e[i]===11&&e[i+1]===119&&Gu(t)!==void 0&&Dv(e,i)<=16)return!1;for(let n=e.length;i<n;i++)if(kv(e,i))return et.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return nx(e,t)}appendFrame(e,t,i){if(this.basePTS!==null)return xv(e,t,i,this.basePTS,this.frameIndex)}}const lx=/\/emsg[-/]ID3/i;class dx{constructor(e,t){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=t}resetTimeStamp(){}resetInitSegment(e,t,i,n){const r=this.videoTrack=Gi("video",1),a=this.audioTrack=Gi("audio",1),o=this.txtTrack=Gi("text",1);if(this.id3Track=Gi("id3",1),this.timeOffset=0,!(e!=null&&e.byteLength))return;const d=Gp(e);if(d.video){const{id:l,timescale:c,codec:u,supplemental:h}=d.video;r.id=l,r.timescale=o.timescale=c,r.codec=u,r.supplemental=h}if(d.audio){const{id:l,timescale:c,codec:u}=d.audio;a.id=l,a.timescale=c,a.codec=u}o.id=Np.text,r.sampleDuration=0,r.duration=a.duration=n}resetContiguity(){this.remainderData=null}static probe(e){return aA(e)}demux(e,t){this.timeOffset=t;let i=e;const n=this.videoTrack,r=this.txtTrack;if(this.config.progressive){this.remainderData&&(i=gi(this.remainderData,e));const o=fA(i);this.remainderData=o.remainder,n.samples=o.valid||new Uint8Array}else n.samples=i;const a=this.extractID3Track(n,t);
vendor: 4,622 bytes, line 1499
1499return r.samples=af(t,n),{videoTrack:n,audioTrack:this.audioTrack,id3Track:a,textTrack:this.txtTrack}}flush(){const e=this.timeOffset,t=this.videoTrack,i=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;const n=this.extractID3Track(t,this.timeOffset);return i.samples=af(e,t),{videoTrack:t,audioTrack:Gi(),id3Track:n,textTrack:Gi()}}extractID3Track(e,t){const i=this.id3Track;if(e.samples.length){const n=Be(e.samples,["emsg"]);n&&n.forEach(r=>{const a=gA(r);if(lx.test(a.schemeIdUri)){const o=Hf(a,t);let d=a.eventDuration===4294967295?Number.POSITIVE_INFINITY:a.eventDuration/a.timeScale;d<=.001&&(d=Number.POSITIVE_INFINITY);const l=a.payload;i.samples.push({data:l,len:l.byteLength,dts:o,pts:o,type:oi.emsg,duration:d})}else if(this.config.enableEmsgKLVMetadata&&a.schemeIdUri.startsWith("urn:misb:KLV:bin:1910.1")){const o=Hf(a,t);i.samples.push({data:a.payload,len:a.payload.byteLength,dts:o,pts:o,type:oi.misbklv,duration:Number.POSITIVE_INFINITY})}})}return i}demuxSampleAes(e,t,i){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){this.config=null,this.remainderData=null,this.videoTrack=this.audioTrack=this.id3Track=this.txtTrack=void 0}}function Hf(s,e){return he(s.presentationTime)?s.presentationTime/s.timeScale:e+s.presentationTimeDelta/s.timeScale}class cx{constructor(e,t,i){this.keyData=void 0,this.decrypter=void 0,this.keyData=i,this.decrypter=new Pu(t,{removePKCS7Padding:!1})}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer,Rs.cbc)}decryptAacSample(e,t,i){const n=e[t].unit;if(n.length<=16)return;const r=n.subarray(16,n.length-n.length%16),a=r.buffer.slice(r.byteOffset,r.byteOffset+r.length);this.decryptBuffer(a).then(o=>{const d=new Uint8Array(o);n.set(d,16),this.decrypter.isSync()||this.decryptAacSamples(e,t+1,i)}).catch(i)}decryptAacSamples(e,t,i){for(;;t++){if(t>=e.length){i();return}if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,i),!this.decrypter.isSync()))return}}getAvcEncryptedData(e){const t=Math.floor((e.length-48)/160)*16+16,i=new Int8Array(t);let n=0;for(let r=32;r<e.length-16;r+=160,n+=16)i.set(e.subarray(r,r+16),n);return i}getAvcDecryptedUnit(e,t){const i=new Uint8Array(t);let n=0;for(let r=32;r<e.length-16;r+=160,n+=16)e.set(i.subarray(n,n+16),r);return e}decryptAvcSample(e,t,i,n,r){const a=Vp(r.data),o=this.getAvcEncryptedData(a);this.decryptBuffer(o.buffer).then(d=>{r.data=this.getAvcDecryptedUnit(a,d),this.decrypter.isSync()||this.decryptAvcSamples(e,t,i+1,n)}).catch(n)}decryptAvcSamples(e,t,i,n){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,i=0){if(t>=e.length){n();return}const r=e[t].units;for(;!(i>=r.length);i++){const a=r[i];if(!(a.data.length<=48||a.type!==1&&a.type!==5)&&(this.decryptAvcSample(e,t,i,n,a),!this.decrypter.isSync()))return}}}}class wv{constructor(){this.VideoSample=null}createVideoSample(e,t,i){return{key:e,frame:!1,pts:t,dts:i,units:[],length:0}}getLastNalUnit(e){var t;let i=this.VideoSample,n;if((!i||i.units.length===0)&&(i=e[e.length-1]),(t=i)!=null&&t.units){const r=i.units;n=r[r.length-1]}return n}pushAccessUnit(e,t){if(e.units.length&&e.frame){if(e.pts===void 0){const i=t.samples,n=i.length;if(n){const r=i[n-1];e.pts=r.pts,e.dts=r.dts}else{t.dropped++;return}}t.samples.push(e)}}parseNALu(e,t,i){const n=t.byteLength;let r=e.naluState||0;const a=r,o=[];let d=0,l,c,u,h=-1,f=0;for(r===-1&&(h=0,f=this.getNALuType(t,0),r=0,d=1);d<n;){if(l=t[d++],!r){r=l?0:1;continue}if(r===1){r=l?0:2;continue}if(!l)r=3;else if(l===1){if(c=d-r-1,h>=0){const m={data:t.subarray(h,c),type:f};o.push(m)}else{const m=this.getLastNalUnit(e.samples);m&&(a&&d<=4-a&&m.state&&(m.data=m.data.subarray(0,m.data.byteLength-a)),c>0&&(m.data=gi(m.data,t.subarray(0,c)),m.state=0))}d<n?(u=this.getNALuType(t,d),h=d,f=u,r=0):r=-1}else r=0}if(h>=0&&r>=0){const m={data:t.subarray(h,n),type:f,state:r};o.push(m)}if(o.length===0){const m=this.getLastNalUnit(e.samples);m&&(m.data=gi(m.data,t))}return e.naluState=r,o}}class kr{constructor(e){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}loadWord(){const e=this.data,t=this.bytesAvailable,i=e.byteLength-t,n=new Uint8Array(4),r=Math.min(4,t);if(r===0)throw new Error("no bytes available");n.set(e.subarray(i,i+r)),this.word=new DataView(n.buffer).getUint32(0),this.bitsAvailable=r*8,this.bytesAvailable-=r}skipBits(e){let t;e=Math.min(e,this.bytesAvailable*8+this.bitsAvailable),this.bitsAvailable>
vendor: 8,394 bytes, line 1499
1499e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,t=e>>3,e-=t<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}readBits(e){let t=Math.min(this.bitsAvailable,e);const i=this.word>>>32-t;if(e>32&&et.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else if(this.bytesAvailable>0)this.loadWord();else throw new Error("no bits available");return t=e-t,t>0&&this.bitsAvailable?i<<t|this.readBits(t):i}skipLZ(){let e;for(e=0;e<this.bitsAvailable;++e)if((this.word&2147483648>>>e)!==0)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){const e=this.skipLZ();return this.readBits(e+1)-1}readEG(){const e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}readBoolean(){return this.readBits(1)===1}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}}class ux extends wv{parsePES(e,t,i,n){const r=this.parseNALu(e,i.data,n);let a=this.VideoSample,o,d=!1;i.data=null,a&&r.length&&!e.audFound&&(this.pushAccessUnit(a,e),a=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts)),r.forEach(l=>{var c,u;switch(l.type){case 1:{let p=!1;o=!0;const g=l.data;if(d&&g.length>4){const y=this.readSliceType(g);(y===2||y===4||y===7||y===9)&&(p=!0)}if(p){var h;(h=a)!=null&&h.frame&&!a.key&&(this.pushAccessUnit(a,e),a=this.VideoSample=null)}a||(a=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),a.frame=!0,a.key=p;break}case 5:o=!0,(c=a)!=null&&c.frame&&!a.key&&(this.pushAccessUnit(a,e),a=this.VideoSample=null),a||(a=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),a.key=!0,a.frame=!0;break;case 6:{o=!0,ku(l.data,1,i.pts,t.samples);break}case 7:{var f,m;o=!0,d=!0;const p=l.data,g=this.readSPS(p);if(!e.sps||e.width!==g.width||e.height!==g.height||((f=e.pixelRatio)==null?void 0:f[0])!==g.pixelRatio[0]||((m=e.pixelRatio)==null?void 0:m[1])!==g.pixelRatio[1]){e.width=g.width,e.height=g.height,e.pixelRatio=g.pixelRatio,e.sps=[p];const y=p.subarray(1,4);let T="avc1.";for(let _=0;_<3;_++){let I=y[_].toString(16);I.length<2&&(I="0"+I),T+=I}e.codec=T}break}case 8:o=!0,e.pps=[l.data];break;case 9:o=!0,e.audFound=!0,(u=a)!=null&&u.frame&&(this.pushAccessUnit(a,e),a=null),a||(a=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts));break;case 12:o=!0;break;default:o=!1;break}a&&o&&a.units.push(l)}),n&&a&&(this.pushAccessUnit(a,e),this.VideoSample=null)}getNALuType(e,t){return e[t]&31}readSliceType(e){const t=new kr(e);return t.readUByte(),t.readUEG(),t.readUEG()}skipScalingList(e,t){let i=8,n=8,r;for(let a=0;a<e;a++)n!==0&&(r=t.readEG(),n=(i+r+256)%256),i=n===0?i:n}readSPS(e){const t=new kr(e);let i=0,n=0,r=0,a=0,o,d,l;const c=t.readUByte.bind(t),u=t.readBits.bind(t),h=t.readUEG.bind(t),f=t.readBoolean.bind(t),m=t.skipBits.bind(t),p=t.skipEG.bind(t),g=t.skipUEG.bind(t),y=this.skipScalingList.bind(this);c();const T=c();if(u(5),m(3),c(),g(),T===100||T===110||T===122||T===244||T===44||T===83||T===86||T===118||T===128){const w=h();if(w===3&&m(1),g(),g(),m(1),f())for(d=w!==3?8:12,l=0;l<d;l++)f()&&(l<6?y(16,t):y(64,t))}g();const _=h();if(_===0)h();else if(_===1)for(m(1),p(),p(),o=h(),l=0;l<o;l++)p();g(),m(1);const I=h(),R=h(),F=u(1);F===0&&m(1),m(1),f()&&(i=h(),n=h(),r=h(),a=h());let L=[1,1];if(f()&&f())switch(c()){case 1:L=[1,1];break;case 2:L=[12,11];break;case 3:L=[10,11];break;case 4:L=[16,11];break;case 5:L=[40,33];break;case 6:L=[24,11];break;case 7:L=[20,11];break;case 8:L=[32,11];break;case 9:L=[80,33];break;case 10:L=[18,11];break;case 11:L=[15,11];break;case 12:L=[64,33];break;case 13:L=[160,99];break;case 14:L=[4,3];break;case 15:L=[3,2];break;case 16:L=[2,1];break;case 255:{L=[c()<<8|c(),c()<<8|c()];break}}return{width:Math.ceil((I+1)*16-i*2-n*2),height:(2-F)*(R+1)*16-(F?2:4)*(r+a),pixelRatio:L}}}class hx extends wv{constructor(...e){super(...e),this.initVPS=null}parsePES(e,t,i,n){const r=this.parseNALu(e,i.data,n);let a=this.VideoSample,o,d=!1;i.data=null,a&&r.length&&!e.audFound&&(this.pushAccessUnit(a,e),a=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts)),r.forEach(l=>{var c,u;switch(l.type){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:a||(a=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts)),a.frame=!0,o=!0;break;case 16:case 17:case 18:case 21:if(o=!0,d){var h;(h=a)!=null&&h.frame&&!a.key&&(this.pushAccessUnit(a,e),a=this.VideoSample=null)}a||(a=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),a.key=!0,a.frame=!0;break;case 19:case 20:o=!0,(c=a)!=null&&c.frame&&!a.key&&(this.pushAccessUnit(a,e),a=this.VideoSample=null),a||(a=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),a.key=!0,a.frame=!0;break;case 39:o=!0,ku(l.data,2,i.pts,t.samples);break;case 32:o=!0,e.vps||(typeof e.params!="object"&&(e.params={}),e.params=nt(e.params,this.readVPS(l.data)),this.initVPS=l.data),e.vps=[l.data];break;case 33:if(o=!0,d=!0,e.vps!==void 0&&e.vps[0]!==this.initVPS&&e.sps!==void 0&&!this.matchSPS(e.sps[0],l.data)&&(this.initVPS=e.vps[0],e.sps=e.pps=void 0),!e.sps){const f=this.readSPS(l.data);e.width=f.width,e.height=f.height,e.pixelRatio=f.pixelRatio,e.codec=f.codecString,e.sps=[],typeof e.params!="object"&&(e.params={});for(const m in f.params)e.params[m]=f.params[m]}this.pushParameterSet(e.sps,l.data,e.vps),a||(a=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),a.key=!0;break;case 34:if(o=!0,typeof e.params=="object"){if(!e.pps){e.pps=[];const f=this.readPPS(l.data);for(const m in f)e.params[m]=f[m]}this.pushParameterSet(e.pps,l.data,e.vps)}break;case 35:o=!0,e.audFound=!0,(u=a)!=null&&u.frame&&(this.pushAccessUnit(a,e),a=null),a||(a=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts));break;default:o=!1;break}a&&o&&a.units.push(l)}),n&&a&&(this.pushAccessUnit(a,e),this.VideoSample=null)}pushParameterSet(e,t,i){(i&&i[0]===this.initVPS||!i&&!e.length)&&e.push(t)}getNALuType(e,t){return(e[t]&126)>>>1}ebsp2rbsp(e){const t=new Uint8Array(e.byteLength);let i=0;for(let n=0;n<e.byteLength;n++)n>=2&&e[n]===3&&e[n-1]===0&&e[n-2]===0||(t[i]=e[n],i++);return new Uint8Array(t.buffer,0,i)}pushAccessUnit(e,t){super.pushAccessUnit(e,t),this.initVPS&&(this.initVPS=null)}readVPS(e){const t=new kr(e);t.readUByte(),t.readUByte(),t.readBits(4),t.skipBits(2),t.readBits(6);const i=t.readBits(3),n=t.readBoolean();return{numTemporalLayers:i+1,temporalIdNested:n}}readSPS(e){const t=new kr(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.readBits(4);const i=t.readBits(3);t.readBoolean();const n=t.readBits(2),r=t.readBoolean(),a=t.readBits(5),o=t.readUByte(),d=t.readUByte(),l=t.readUByte(),c=t.readUByte(),u=t.readUByte(),h=t.readUByte(),f=t.readUByte(),m=t.readUByte(),p=t.readUByte(),g=t.readUByte(),y=t.readUByte(),T=[],_=[];for(let Te=0;Te<i;Te++)T.push(t.readBoolean()),_.push(t.readBoolean());if(i>0)for(let Te=i;Te<8;Te++)t.readBits(2);for(let Te=0;Te<i;Te++)T[Te]&&(t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte()),_[Te]&&t.readUByte();t.readUEG();const I=t.readUEG();I==3&&t.skipBits(1);const R=t.readUEG(),F=t.readUEG(),L=t.readBoolean();let w=0,P=0,k=0,G=0;L&&(w+=t.readUEG(),P+=t.readUEG(),k+=t.readUEG(),G+=t.readUEG());const se=t.readUEG(),oe=t.readUEG(),de=t.readUEG(),ae=t.readBoolean();for(let Te=ae?0:i;Te<=i;Te++)t.skipUEG(),t.skipUEG(),t.skipUEG();if(t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.readBoolean()&&t.readBoolean())for(let $e=0;$e<4;$e++)for(let H=0;H<($e===3?2:6);H++)if(!t.readBoolean())t.readUEG();else{const _e=Math.min(64,1<<4+($e<<1));$e>1&&t.readEG();for(let Se=0;Se<_e;Se++)t.readEG()}t.readBoolean(),t.readBoolean(),t.readBoolean()&&(t.readUByte(),t.skipUEG(),t.skipUEG(),t.readBoolean());const ee=t.readUEG();let te=0;for(let Te=0;Te<ee;Te++){let $e=!1;if(Te!==0&&($e=t.readBoolean()),$e){Te===ee&&t.readUEG(),t.readBoolean(),t.readUEG();let H=0;for(let be=0;be<=te;be++){const _e=t.readBoolean();let Se=!1;_e||(Se=t.readBoolean()),(_e||Se)&&H++}te=H}else{const H=t.readUEG(),be=t.readUEG();te=H+be;for(let _e=0;_e<H;_e++)t.readUEG(),t.readBoolean();for(let _e=0;_e<be;_e++)t.readUEG(),t.readBoolean()}}if(t.readBoolean()){const Te=t.readUEG();for(let $e=0;$e<Te;$e++){for(let H=0;H<de+4;H++)t.readBits(1);t.readBits(1)}}
vendor: 13,962 bytes, line 1499
1499let X=0,Y=1,Ie=1,De=!0,Re=1,Ce=0;t.readBoolean(),t.readBoolean();let dt=!1;if(t.readBoolean()){if(t.readBoolean()){const Ye=t.readUByte(),rt=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2],qe=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1];Ye>0&&Ye<16?(Y=rt[Ye-1],Ie=qe[Ye-1]):Ye===255&&(Y=t.readBits(16),Ie=t.readBits(16))}if(t.readBoolean()&&t.readBoolean(),t.readBoolean()&&(t.readBits(3),t.readBoolean(),t.readBoolean()&&(t.readUByte(),t.readUByte(),t.readUByte())),t.readBoolean()&&(t.readUEG(),t.readUEG()),t.readBoolean(),t.readBoolean(),t.readBoolean(),dt=t.readBoolean(),dt&&(t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG()),t.readBoolean()&&(Re=t.readBits(32),Ce=t.readBits(32),t.readBoolean()&&t.readUEG(),t.readBoolean())){const qe=t.readBoolean(),Xt=t.readBoolean();let bt=!1;(qe||Xt)&&(bt=t.readBoolean(),bt&&(t.readUByte(),t.readBits(5),t.readBoolean(),t.readBits(5)),t.readBits(4),t.readBits(4),bt&&t.readBits(4),t.readBits(5),t.readBits(5),t.readBits(5));for(let Xi=0;Xi<=i;Xi++){De=t.readBoolean();const kt=De||t.readBoolean();let Js=!1;kt?t.readEG():Js=t.readBoolean();const pt=Js?1:t.readUEG()+1;if(qe)for(let Ze=0;Ze<pt;Ze++)t.readUEG(),t.readUEG(),bt&&(t.readUEG(),t.readUEG()),t.skipBits(1);if(Xt)for(let Ze=0;Ze<pt;Ze++)t.readUEG(),t.readUEG(),bt&&(t.readUEG(),t.readUEG()),t.skipBits(1)}}t.readBoolean()&&(t.readBoolean(),t.readBoolean(),t.readBoolean(),X=t.readUEG())}let ne=R,We=F;if(L){let Te=1,$e=1;I===1?Te=$e=2:I==2&&(Te=2),ne=R-Te*P-Te*w,We=F-$e*G-$e*k}const V=n?["A","B","C"][n]:"",fe=o<<24|d<<16|l<<8|c;let Oe=0;for(let Te=0;Te<32;Te++)Oe=(Oe|(fe>>Te&1)<<31-Te)>>>0;let Fe=Oe.toString(16);return a===1&&Fe==="2"&&(Fe="6"),{codecString:`hvc1.${V}${a}.${Fe}.${r?"H":"L"}${y}.B0`,params:{general_tier_flag:r,general_profile_idc:a,general_profile_space:n,general_profile_compatibility_flags:[o,d,l,c],general_constraint_indicator_flags:[u,h,f,m,p,g],general_level_idc:y,bit_depth:se+8,bit_depth_luma_minus8:se,bit_depth_chroma_minus8:oe,min_spatial_segmentation_idc:X,chroma_format_idc:I,frame_rate:{fixed:De,fps:Ce/Re}},width:ne,height:We,pixelRatio:[Y,Ie]}}readPPS(e){const t=new kr(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.skipUEG(),t.skipUEG(),t.skipBits(2),t.skipBits(3),t.skipBits(2),t.skipUEG(),t.skipUEG(),t.skipEG(),t.skipBits(2),t.readBoolean()&&t.skipUEG(),t.skipEG(),t.skipEG(),t.skipBits(4);const n=t.readBoolean(),r=t.readBoolean();let a=1;return r&&n?a=0:r?a=3:n&&(a=2),{parallelismType:a}}matchSPS(e,t){return String.fromCharCode.apply(null,e).substr(3)===String.fromCharCode.apply(null,t).substr(3)}}const Ct=188;class bs{constructor(e,t,i,n){this.logger=void 0,this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=e,this.config=t,this.typeSupported=i,this.logger=n,this.videoParser=null}static probe(e,t){const i=bs.syncOffset(e);return i>0&&t.warn(`MPEG2-TS detected but first sync word found @ offset ${i}`),i!==-1}static syncOffset(e){const t=e.length;let i=Math.min(Ct*5,t-Ct)+1,n=0;for(;n<i;){let r=!1,a=-1,o=0;for(let d=n;d<t;d+=Ct)if(e[d]===71&&(t-d===Ct||e[d+Ct]===71)){if(o++,a===-1&&(a=d,a!==0&&(i=Math.min(a+Ct*99,e.length-Ct)+1)),r||(r=Nc(e,d)===0),r&&o>1&&(a===0&&o>2||d+Ct>i))return a}else{if(o)return-1;break}n++}return-1}static createTrack(e,t){return{container:e==="video"||e==="audio"?"video/mp2t":void 0,type:e,id:Np[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:e==="audio"?t:void 0}}resetInitSegment(e,t,i,n){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=bs.createTrack("video"),this._videoTrack.duration=n,this._audioTrack=bs.createTrack("audio",n),this._id3Track=bs.createTrack("id3"),this._txtTrack=bs.createTrack("text"),this._audioTrack.segmentCodec="aac",this.videoParser=null,this.aacOverFlow=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=i}resetTimeStamp(){}resetContiguity(){const{_audioTrack:e,_videoTrack:t,_id3Track:i}=this;e&&(e.pesData=null),t&&(t.pesData=null),i&&(i.pesData=null),this.aacOverFlow=null,this.remainderData=null}demux(e,t,i=!1,n=!1){i||(this.sampleAes=null);let r;const a=this._videoTrack,o=this._audioTrack,d=this._id3Track,l=this._txtTrack;let c=a.pid,u=a.pesData,h=o.pid,f=d.pid,m=o.pesData,p=d.pesData,g=null,y=this.pmtParsed,T=this._pmtId,_=e.length;if(this.remainderData&&(e=gi(this.remainderData,e),_=e.length,this.remainderData=null),_<Ct&&!n)return this.remainderData=e,{audioTrack:o,videoTrack:a,id3Track:d,textTrack:l};const I=Math.max(0,bs.syncOffset(e));_-=(_-I)%Ct,_<e.byteLength&&!n&&(this.remainderData=new Uint8Array(e.buffer,_,e.buffer.byteLength-_));let R=0;for(let L=I;L<_;L+=Ct)if(e[L]===71){const w=!!(e[L+1]&64),P=Nc(e,L),k=(e[L+3]&48)>>4;let G;if(k>1){if(G=L+5+e[L+4],G===L+Ct)continue}else G=L+4;switch(P){case c:w&&(u&&(r=cn(u,this.logger))&&(this.readyVideoParser(a.segmentCodec),this.videoParser!==null&&this.videoParser.parsePES(a,l,r,!1)),u={data:[],size:0}),u&&(u.data.push(e.subarray(G,L+Ct)),u.size+=L+Ct-G);break;case h:if(w){if(m&&(r=cn(m,this.logger)))switch(o.segmentCodec){case"aac":this.parseAACPES(o,r);break;case"mp3":this.parseMPEGPES(o,r);break;case"ac3":this.parseAC3PES(o,r);break}m={data:[],size:0}}m&&(m.data.push(e.subarray(G,L+Ct)),m.size+=L+Ct-G);break;case f:w&&(p&&(r=cn(p,this.logger))&&this.parseID3PES(d,r),p={data:[],size:0}),p&&(p.data.push(e.subarray(G,L+Ct)),p.size+=L+Ct-G);break;case 0:w&&(G+=e[G]+1),T=this._pmtId=fx(e,G);break;case T:{w&&(G+=e[G]+1);const se=mx(e,G,this.typeSupported,i,this.observer,this.logger);c=se.videoPid,c>0&&(a.pid=c,a.segmentCodec=se.segmentVideoCodec),h=se.audioPid,h>0&&(o.pid=h,o.segmentCodec=se.segmentAudioCodec),f=se.id3Pid,f>0&&(d.pid=f),g!==null&&!y&&(this.logger.warn(`MPEG-TS PMT found at ${L} after unknown PID '${g}'. Backtracking to sync byte @${I} to parse all TS packets.`),g=null,L=I-188),y=this.pmtParsed=!0;break}case 17:case 8191:break;default:g=P;break}}else R++;R>0&&Uc(this.observer,new Error(`Found ${R} TS packet/s that do not start with 0x47`),void 0,this.logger),a.pesData=u,o.pesData=m,d.pesData=p;const F={audioTrack:o,videoTrack:a,id3Track:d,textTrack:l};return n&&this.extractRemainingSamples(F),F}flush(){const{remainderData:e}=this;this.remainderData=null;let t;return e?t=this.demux(e,-1,!1,!0):t={videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t}extractRemainingSamples(e){const{audioTrack:t,videoTrack:i,id3Track:n,textTrack:r}=e,a=i.pesData,o=t.pesData,d=n.pesData;let l;if(a&&(l=cn(a,this.logger))?(this.readyVideoParser(i.segmentCodec),this.videoParser!==null&&(this.videoParser.parsePES(i,r,l,!0),i.pesData=null)):i.pesData=a,o&&(l=cn(o,this.logger))){switch(t.segmentCodec){case"aac":this.parseAACPES(t,l);break;case"mp3":this.parseMPEGPES(t,l);break;case"ac3":this.parseAC3PES(t,l);break}t.pesData=null}else o!=null&&o.size&&this.logger.log("last AAC PES packet truncated,might overlap between fragments"),t.pesData=o;d&&(l=cn(d,this.logger))?(this.parseID3PES(n,l),n.pesData=null):n.pesData=d}demuxSampleAes(e,t,i){const n=this.demux(e,i,!0,!this.config.progressive),r=this.sampleAes=new cx(this.observer,this.config,t);return this.decrypt(n,r)}readyVideoParser(e){this.videoParser===null&&(e==="avc"?this.videoParser=new ux:e==="hevc"&&(this.videoParser=new hx))}decrypt(e,t){return new Promise(i=>{const{audioTrack:n,videoTrack:r}=e;n.samples&&n.segmentCodec==="aac"?t.decryptAacSamples(n.samples,0,()=>{r.samples?t.decryptAvcSamples(r.samples,0,0,()=>{i(e)}):i(e)}):r.samples&&t.decryptAvcSamples(r.samples,0,0,()=>{i(e)})})}destroy(){this.observer&&this.observer.removeAllListeners(),this.config=this.logger=this.observer=null,this.aacOverFlow=this.videoParser=this.remainderData=this.sampleAes=null,this._videoTrack=this._audioTrack=this._id3Track=this._txtTrack=void 0}parseAACPES(e,t){let i=0;const n=this.aacOverFlow;let r=t.data;if(n){this.aacOverFlow=null;const u=n.missing,h=n.sample.unit.byteLength;if(u===-1)r=gi(n.sample.unit,r);else{const f=h-u;n.sample.unit.set(r.subarray(0,u),f),e.samples.push(n.sample),i=n.missing}}let a,o;for(a=i,o=r.length;a<o-1&&!vl(r,a);a++);if(a!==i){let u;const h=a<o-1;if(h?u=`AAC PES did not start with ADTS header,offset:${a}`:u="No ADTS header found in AAC PES",Uc(this.observer,new Error(u),h,this.logger),!h)return}bv(e,this.observer,r,a,this.audioCodec);let d;if(t.pts!==void 0)d=t.pts;else if(n){const u=_v(e.samplerate);d=n.sample.pts+u}else{this.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}let l=0,c;for(;a<o;)if(c=Sv(e,r,a,d,l),a+=c.length,c.missing){this.aacOverFlow=c;break}else for(l++;a<o-1&&!vl(r,a);a++);}parseMPEGPES(e,t){const i=t.data,n=i.length;let r=0,a=0;const o=t.pts;if(o===void 0){this.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;a<n;)if(Rv(i,a)){const d=xv(e,i,a,o,r);if(d)a+=d.length,r++;else break}else a++}parseAC3PES(e,t){{const i=t.data,n=t.pts;if(n===void 0){this.logger.warn("[tsdemuxer]: AC3 PES unknown PTS");return}const r=i.length;let a=0,o=0,d;for(;o<r&&(d=Cv(e,i,o,n,a++))>0;)o+=d}}parseID3PES(e,t){if(t.pts===void 0){this.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}const i=nt({},t,{type:this._videoTrack?oi.emsg:oi.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(i)}}function Nc(s,e){return((s[e+1]&31)<<8)+s[e+2]}function fx(s,e){return(s[e+10]&31)<<8|s[e+11]}function mx(s,e,t,i,n,r){const a={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},o=(s[e+1]&15)<<8|s[e+2],d=e+3+o-4,l=(s[e+10]&15)<<8|s[e+11];for(e+=12+l;e<d;){const c=Nc(s,e),u=(s[e+3]&15)<<8|s[e+4];switch(s[e]){case 207:if(!i){dd("ADTS AAC",r);break}case 15:a.audioPid===-1&&(a.audioPid=c);break;case 21:a.id3Pid===-1&&(a.id3Pid=c);break;case 219:if(!i){dd("H.264",r);break}case 27:a.videoPid===-1&&(a.videoPid=c);break;case 3:case 4:!t.mpeg&&!t.mp3?r.log("MPEG audio found, not supported in this browser"):a.audioPid===-1&&(a.audioPid=c,a.segmentAudioCodec="mp3");break;case 193:if(!i){dd("AC-3",r);break}case 129:t.ac3?a.audioPid===-1&&(a.audioPid=c,a.segmentAudioCodec="ac3"):r.log("AC-3 audio found, not supported in this browser");break;case 6:if(a.audioPid===-1&&u>0){let h=e+5,f=u;for(;f>2;){s[h]===106&&(t.ac3!==!0?r.log("AC-3 audio found, not supported in this browser for now"):(a.audioPid=c,a.segmentAudioCodec="ac3"));const p=s[h+1]+2;h+=p,f-=p}}break;case 194:case 135:return Uc(n,new Error("Unsupported EC-3 in M2TS found"),void 0,r),a;case 36:a.videoPid===-1&&(a.videoPid=c,a.segmentVideoCodec="hevc",r.log("HEVC in M2TS found"));break}e+=u+5}return a}function Uc(s,e,t,i){i.warn(`parsing error: ${e.message}`),s.emit(v.ERROR,v.ERROR,{type:ye.MEDIA_ERROR,details:$.FRAG_PARSING_ERROR,fatal:!1,levelRetry:t,error:e,reason:e.message})}function dd(s,e){e.log(`${s} with AES-128-CBC encryption found in unencrypted stream`)}function cn(s,e){let t=0,i,n,r,a,o;const d=s.data;if(!s||s.size===0)return null;for(;d[0].length<19&&d.length>1;)d[0]=gi(d[0],d[1]),d.splice(1,1);if(i=d[0],(i[0]<<16)+(i[1]<<8)+i[2]===1){if(n=(i[4]<<8)+i[5],n&&n>s.size-6)return null;const c=i[7];c&192&&(a=(i[9]&14)*536870912+(i[10]&255)*4194304+(i[11]&254)*16384+(i[12]&255)*128+(i[13]&254)/2,c&64?(o=(i[14]&14)*536870912+(i[15]&255)*4194304+(i[16]&254)*16384+(i[17]&255)*128+(i[18]&254)/2,a-o>60*9e4&&(e.warn(`${Math.round((a-o)/9e4)}s delta between PTS and DTS, align them`),a=o)):o=a),r=i[8];let u=r+9;if(s.size<=u)return null;s.size-=u;const h=new Uint8Array(s.size);for(let f=0,m=d.length;f<m;f++){i=d[f];let p=i.byteLength;if(u)if(u>p){u-=p;continue}else i=i.subarray(u),p-=u,u=0;h.set(i,t),t+=p}return n&&(n-=r+3),{data:h,pts:a,dts:o,len:n}}return null}class gx{static getSilentFrame(e,t){switch(e){case"mp4a.40.2":if(t===1)return new Uint8Array([0,200,0,128,35,128]);if(t===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(t===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(t===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(t===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(t===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(t===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(t===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(t===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}}}const ps=Math.pow(2,32)-1;class O{static init(){O.types={avc1:[],avcC:[],hvc1:[],hvcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],dac3:[],"ac-3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};let e;for(e in O.types)O.types.hasOwnProperty(e)&&(O.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);const t=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]),i=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]);O.HDLR_TYPES={video:t,audio:i};const n=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),r=new
vendor: 4,361 bytes, line 1499
1499Uint8Array([0,0,0,0,0,0,0,0]);O.STTS=O.STSC=O.STCO=r,O.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),O.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),O.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),O.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);const a=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),d=new Uint8Array([0,0,0,1]);O.FTYP=O.box(O.types.ftyp,a,d,a,o),O.DINF=O.box(O.types.dinf,O.box(O.types.dref,n))}static box(e,...t){let i=8,n=t.length;const r=n;for(;n--;)i+=t[n].byteLength;const a=new Uint8Array(i);for(a[0]=i>>24&255,a[1]=i>>16&255,a[2]=i>>8&255,a[3]=i&255,a.set(e,4),n=0,i=8;n<r;n++)a.set(t[n],i),i+=t[n].byteLength;return a}static hdlr(e){return O.box(O.types.hdlr,O.HDLR_TYPES[e])}static mdat(e){return O.box(O.types.mdat,e)}static mdhd(e,t){t*=e;const i=Math.floor(t/(ps+1)),n=Math.floor(t%(ps+1));return O.box(O.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,i>>24,i>>16&255,i>>8&255,i&255,n>>24,n>>16&255,n>>8&255,n&255,85,196,0,0]))}static mdia(e){return O.box(O.types.mdia,O.mdhd(e.timescale||0,e.duration||0),O.hdlr(e.type),O.minf(e))}static mfhd(e){return O.box(O.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255]))}static minf(e){return e.type==="audio"?O.box(O.types.minf,O.box(O.types.smhd,O.SMHD),O.DINF,O.stbl(e)):O.box(O.types.minf,O.box(O.types.vmhd,O.VMHD),O.DINF,O.stbl(e))}static moof(e,t,i){return O.box(O.types.moof,O.mfhd(e),O.traf(i,t))}static moov(e){let t=e.length;const i=[];for(;t--;)i[t]=O.trak(e[t]);return O.box.apply(null,[O.types.moov,O.mvhd(e[0].timescale||0,e[0].duration||0)].concat(i).concat(O.mvex(e)))}static mvex(e){let t=e.length;const i=[];for(;t--;)i[t]=O.trex(e[t]);return O.box.apply(null,[O.types.mvex,...i])}static mvhd(e,t){t*=e;const i=Math.floor(t/(ps+1)),n=Math.floor(t%(ps+1)),r=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,i>>24,i>>16&255,i>>8&255,i&255,n>>24,n>>16&255,n>>8&255,n&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 O.box(O.types.mvhd,r)}static sdtp(e){const t=e.samples||[],i=new Uint8Array(4+t.length);let n,r;for(n=0;n<t.length;n++)r=t[n].flags,i[n+4]=r.dependsOn<<4|r.isDependedOn<<2|r.hasRedundancy;return O.box(O.types.sdtp,i)}static stbl(e){return O.box(O.types.stbl,O.stsd(e),O.box(O.types.stts,O.STTS),O.box(O.types.stsc,O.STSC),O.box(O.types.stsz,O.STSZ),O.box(O.types.stco,O.STCO))}static avc1(e){let t=[],i=[],n,r,a;for(n=0;n<e.sps.length;n++)r=e.sps[n],a=r.byteLength,t.push(a>>>8&255),t.push(a&255),t=t.concat(Array.prototype.slice.call(r));for(n=0;n<e.pps.length;n++)r=e.pps[n],a=r.byteLength,i.push(a>>>8&255),i.push(a&255),i=i.concat(Array.prototype.slice.call(r));const o=O.box(O.types.avcC,new Uint8Array([1,t[3],t[4],t[5],255,224|e.sps.length].concat(t).concat([e.pps.length]).concat(i))),d=e.width,l=e.height,c=e.pixelRatio[0],u=e.pixelRatio[1];return O.box(O.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,d>>8&255,d&255,l>>8&255,l&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),o,O.box(O.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),O.box(O.types.pasp,new Uint8Array([c>>24,c>>16&255,c>>8&255,c&255,u>>24,u>>16&255,u>>8&255,u&255])))}static esds(e){const t=e.config;return new Uint8Array([0,0,0,0,3,25,0,1,0,4,17,64,21,0,0,0,0,0,0,0,0,0,0,0,5,2,...t,6,1,2])}static audioStsd(e){const t=e.samplerate||0;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount||0,0,16,0,0,0,0,t>>8&255,t&255,0,0])}static mp4a(e){return O.box(O.types.mp4a,O.audioStsd(e),O.box(O.types.esds,O.esds(e)))}static mp3(e){return O.box(O.types[".mp3"],O.audioStsd(e))}static ac3(e){return O.box(O.types["ac-3"],O.audioStsd(e),O.box(O.types.dac3,e.config))}static stsd(e){const{segmentCodec:t}=e;if(e.type==="audio"){if(t==="aac")return O.box(O.types.stsd,O.STSD,O.mp4a(e));if(t==="ac3"&&e.config)return O.box(O.types.stsd,O.STSD,O.ac3(e));if(t==="mp3"&&e.codec==="mp3")return O.box(O.types.stsd,O.STSD,O.mp3(e))}else if(e.pps&&e.sps){if(t==="avc")return O.box(O.types.stsd,O.STSD,O.avc1(e));if(t==="hevc"&&e.vps)return O.box(O.types.stsd,O.STSD,O.hvc1(e))}
vendor: 24,198 bytes, line 1499
1499else throw new Error("video track missing pps or sps");throw new Error(`unsupported ${e.type} segment codec (${t}/${e.codec})`)}static tkhd(e){const t=e.id,i=(e.duration||0)*(e.timescale||0),n=e.width||0,r=e.height||0,a=Math.floor(i/(ps+1)),o=Math.floor(i%(ps+1));return O.box(O.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,t&255,0,0,0,0,a>>24,a>>16&255,a>>8&255,a&255,o>>24,o>>16&255,o>>8&255,o&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,n>>8&255,n&255,0,0,r>>8&255,r&255,0,0]))}static traf(e,t){const i=O.sdtp(e),n=e.id,r=Math.floor(t/(ps+1)),a=Math.floor(t%(ps+1));return O.box(O.types.traf,O.box(O.types.tfhd,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,n&255])),O.box(O.types.tfdt,new Uint8Array([1,0,0,0,r>>24,r>>16&255,r>>8&255,r&255,a>>24,a>>16&255,a>>8&255,a&255])),O.trun(e,i.length+16+20+8+16+8+8),i)}static trak(e){return e.duration=e.duration||4294967295,O.box(O.types.trak,O.tkhd(e),O.mdia(e))}static trex(e){const t=e.id;return O.box(O.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(e,t){const i=e.samples||[],n=i.length,r=12+16*n,a=new Uint8Array(r);let o,d,l,c,u,h;for(t+=8+r,a.set([e.type==="video"?1:0,0,15,1,n>>>24&255,n>>>16&255,n>>>8&255,n&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255],0),o=0;o<n;o++)d=i[o],l=d.duration,c=d.size,u=d.flags,h=d.cts,a.set([l>>>24&255,l>>>16&255,l>>>8&255,l&255,c>>>24&255,c>>>16&255,c>>>8&255,c&255,u.isLeading<<2|u.dependsOn,u.isDependedOn<<6|u.hasRedundancy<<4|u.paddingValue<<1|u.isNonSync,u.degradPrio&61440,u.degradPrio&15,h>>>24&255,h>>>16&255,h>>>8&255,h&255],12+16*o);return O.box(O.types.trun,a)}static initSegment(e){O.types||O.init();const t=O.moov(e);return gi(O.FTYP,t)}static hvc1(e){const t=e.params,i=[e.vps,e.sps,e.pps],n=4,r=new Uint8Array([1,t.general_profile_space<<6|(t.general_tier_flag?32:0)|t.general_profile_idc,t.general_profile_compatibility_flags[0],t.general_profile_compatibility_flags[1],t.general_profile_compatibility_flags[2],t.general_profile_compatibility_flags[3],t.general_constraint_indicator_flags[0],t.general_constraint_indicator_flags[1],t.general_constraint_indicator_flags[2],t.general_constraint_indicator_flags[3],t.general_constraint_indicator_flags[4],t.general_constraint_indicator_flags[5],t.general_level_idc,240|t.min_spatial_segmentation_idc>>8,255&t.min_spatial_segmentation_idc,252|t.parallelismType,252|t.chroma_format_idc,248|t.bit_depth_luma_minus8,248|t.bit_depth_chroma_minus8,0,parseInt(t.frame_rate.fps),n-1|t.temporal_id_nested<<2|t.num_temporal_layers<<3|(t.frame_rate.fixed?64:0),i.length]);let a=r.length;for(let m=0;m<i.length;m+=1){a+=3;for(let p=0;p<i[m].length;p+=1)a+=2+i[m][p].length}const o=new Uint8Array(a);o.set(r,0),a=r.length;const d=i.length-1;for(let m=0;m<i.length;m+=1){o.set(new Uint8Array([32+m|(m===d?128:0),0,i[m].length]),a),a+=3;for(let p=0;p<i[m].length;p+=1)o.set(new Uint8Array([i[m][p].length>>8,i[m][p].length&255]),a),a+=2,o.set(i[m][p],a),a+=i[m][p].length}const l=O.box(O.types.hvcC,o),c=e.width,u=e.height,h=e.pixelRatio[0],f=e.pixelRatio[1];return O.box(O.types.hvc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,c>>8&255,c&255,u>>8&255,u&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),l,O.box(O.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),O.box(O.types.pasp,new Uint8Array([h>>24,h>>16&255,h>>8&255,h&255,f>>24,f>>16&255,f>>8&255,f&255])))}}O.types=void 0;O.HDLR_TYPES=void 0;O.STTS=void 0;O.STSC=void 0;O.STCO=void 0;O.STSZ=void 0;O.VMHD=void 0;O.SMHD=void 0;O.STSD=void 0;O.FTYP=void 0;O.DINF=void 0;const Pv=9e4;function Vu(s,e,t=1,i=!1){const n=s*e*t;return i?Math.round(n):n}function px(s,e,t=1,i=!1){return Vu(s,e,1/t,i)}function ar(s,e=!1){return Vu(s,1e3,1/Pv,e)}function vx(s,e=1){return Vu(s,Pv,1/e)}function Vf(s){const{baseTime:e,timescale:t,trackId:i}=s;return`${e/t} (${e}/${t}) trackId: ${i}`}const Ex=10*1e3,yx=1024,Tx=1152,bx=1536;let un=null,cd=null;function Wf(s,e,t,i){return{duration:e,size:t,cts:i,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:s?2:1,isNonSync:s?0:1}}}class Po extends pi{constructor(e,t,i,n){if(super("mp4-remuxer",n),this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextVideoTs=null,this.nextAudioTs=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.videoTrackConfig=void 0,this.observer=e,this.config=t,this.typeSupported=i,this.ISGenerated=!1,un===null){const a=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);un=a?parseInt(a[1]):0}if(cd===null){const r=navigator.userAgent.match(/Safari\/(\d+)/i);cd=r?parseInt(r[1]):0}}destroy(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null}resetTimeStamp(e){const t=this._initPTS;(!t||!e||e.trackId!==t.trackId||e.baseTime!==t.baseTime||e.timescale!==t.timescale)&&this.log(`Reset initPTS: ${t&&Vf(t)} > ${e&&Vf(e)}`),this._initPTS=this._initDTS=e}resetNextTimestamp(){this.log("reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){this.log("ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0}getVideoStartPts(e){let t=!1;const i=e[0].pts,n=e.reduce((r,a)=>{let o=a.pts,d=o-r;return d<-4294967296&&(t=!0,o=ai(o,i),d=o-r),d>0?r:o},i);return t&&this.debug("PTS rollover detected"),n}remux(e,t,i,n,r,a,o,d){let l,c,u,h,f,m,p=r,g=r;const y=e.pid>-1,T=t.pid>-1,_=t.samples.length,I=e.samples.length>0,R=o&&_>0||_>1;if((!y||I)&&(!T||R)||this.ISGenerated||o){if(this.ISGenerated){var L,w,P,k;const de=this.videoTrackConfig;(de&&(t.width!==de.width||t.height!==de.height||((L=t.pixelRatio)==null?void 0:L[0])!==((w=de.pixelRatio)==null?void 0:w[0])||((P=t.pixelRatio)==null?void 0:P[1])!==((k=de.pixelRatio)==null?void 0:k[1]))||!de&&R||this.nextAudioTs===null&&I)&&this.resetInitSegment()}this.ISGenerated||(u=this.generateIS(e,t,r,a));const G=this.isVideoContiguous;let se=-1,oe;if(R&&(se=_x(t.samples),!G&&this.config.forceKeyFrameOnDiscontinuity))if(m=!0,se>0){this.warn(`Dropped ${se} out of ${_} video samples due to a missing keyframe`);const de=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(se),t.dropped+=se,g+=(t.samples[0].pts-de)/t.inputTimeScale,oe=g}else se===-1&&(this.warn(`No keyframe found out of ${_} video samples`),m=!1);if(this.ISGenerated){if(I&&R){const de=this.getVideoStartPts(t.samples),ie=(ai(e.samples[0].pts,de)-de)/t.inputTimeScale;p+=Math.max(0,ie),g+=Math.max(0,-ie)}if(I){if(e.samplerate||(this.warn("regenerate InitSegment as audio detected"),u=this.generateIS(e,t,r,a)),c=this.remuxAudio(e,p,this.isAudioContiguous,a,T||R||d===ge.AUDIO?g:void 0),R){const de=c?c.endPTS-c.startPTS:0;t.inputTimeScale||(this.warn("regenerate InitSegment as video detected"),u=this.generateIS(e,t,r,a)),l=this.remuxVideo(t,g,G,de)}}else R&&(l=this.remuxVideo(t,g,G,0));l&&(l.firstKeyFrame=se,l.independent=se!==-1,l.firstKeyFramePTS=oe)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(i.samples.length&&(f=Mv(i,r,this._initPTS,this._initDTS)),n.samples.length&&(h=Ov(n,r,this._initPTS))),{audio:c,video:l,initSegment:u,independent:m,text:h,id3:f}}computeInitPts(e,t,i,n){const r=Math.round(i*t);let a=ai(e,r);if(a<r+t)for(this.log(`Adjusting PTS for rollover in timeline near ${(r-a)/t} ${n}`);a<r+t;)a+=8589934592;return a-r}generateIS(e,t,i,n){const r=e.samples,a=t.samples,o=this.typeSupported,d={},l=this._initPTS;let c=!l||n,u="audio/mp4",h,f,m,p=-1;if(c&&(h=f=1/0),e.config&&r.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":o.mpeg?(u="audio/mpeg",e.codec=""):o.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3";break}d.audio={id:"audio",container:u,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&o.mpeg?new Uint8Array(0):O.initSegment([e]),metadata:{channelCount:e.channelCount}},c&&(p=e.id,m=e.inputTimeScale,!l||m!==l.timescale?h=f=this.computeInitPts(r[0].pts,m,i,"audio"):c=!1)}if(t.sps&&t.pps&&a.length){if(t.timescale=t.inputTimeScale,d.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:O.initSegment([t]),metadata:{width:t.width,height:t.height}},c)if(p=t.id,m=t.inputTimeScale,!l||m!==l.timescale){const g=this.getVideoStartPts(a),y=ai(a[0].dts,g),T=this.computeInitPts(y,m,i,"video"),_=this.computeInitPts(g,m,i,"video");f=Math.min(f,T),h=Math.min(h,_)}else c=!1;this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(d).length)return this.ISGenerated=!0,c?(l&&this.warn(`Timestamps at playlist time: ${n?"":"~"}${i} ${h/m} != initPTS: ${l.baseTime/l.timescale} (${l.baseTime}/${l.timescale}) trackId: ${l.trackId}`),this.log(`Found initPTS at playlist time: ${i} offset: ${h/m} (${h}/${m}) trackId: ${p}`),this._initPTS={baseTime:h,timescale:m,trackId:p},this._initDTS={baseTime:f,timescale:m,trackId:p}):h=m=void 0,{tracks:d,initPTS:h,timescale:m,trackId:p}}remuxVideo(e,t,i,n){const r=e.inputTimeScale,a=e.samples,o=[],d=a.length,l=this._initPTS,c=l.baseTime*r/l.timescale;let u=this.nextVideoTs,h=8,f=this.videoSampleDuration,m,p,g=Number.POSITIVE_INFINITY,y=Number.NEGATIVE_INFINITY,T=!1;if(!i||u===null){const X=c+t*r,Y=a[0].pts-ai(a[0].dts,a[0].pts);un&&u!==null&&Math.abs(X-Y-(u+c))<15e3?i=!0:u=X-Y-c}const _=u+c;for(let X=0;X<d;X++){const Y=a[X];Y.pts=ai(Y.pts,_),Y.dts=ai(Y.dts,_),Y.dts<a[X>0?X-1:X].dts&&(T=!0)}T&&a.sort(function(X,Y){const Ie=X.dts-Y.dts,De=X.pts-Y.pts;return Ie||De}),m=a[0].dts,p=a[a.length-1].dts;const I=p-m,R=I?Math.round(I/(d-1)):f||e.inputTimeScale/30;if(i){const X=m-_,Y=X>R,Ie=X<-1;if((Y||Ie)&&(Y?this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${ar(X,!0)} ms (${X}dts) hole between fragments detected at ${t.toFixed(3)}`):this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${ar(-X,!0)} ms (${X}dts) overlapping between fragments detected at ${t.toFixed(3)}`),!Ie||_>=a[0].pts||un)){m=_;const De=a[0].pts-X;if(Y)a[0].dts=m,a[0].pts=De;else{let Re=!0;for(let Ce=0;Ce<a.length&&!(a[Ce].dts>De&&Re);Ce++){const dt=a[Ce].pts;if(a[Ce].dts-=X,a[Ce].pts-=X,Ce<a.length-1){const je=a[Ce+1].pts,ne=a[Ce].pts,We=je<=ne,V=je<=dt;Re=We==V}}}this.log(`Video: Initial PTS/DTS adjusted: ${ar(De,!0)}/${ar(m,!0)}, delta: ${ar(X,!0)} ms`)}}m=Math.max(0,m);let F=0,L=0,w=m;for(let X=0;X<d;X++){const Y=a[X],Ie=Y.units,De=Ie.length;let Re=0;for(let Ce=0;Ce<De;Ce++)Re+=Ie[Ce].data.length;L+=Re,F+=De,Y.length=Re,Y.dts<w?(Y.dts=w,w+=R/4|0||1):w=Y.dts,g=Math.min(Y.pts,g),y=Math.max(Y.pts,y)}p=a[d-1].dts;const P=L+4*F+8;let k;try{k=new Uint8Array(P)}catch(X){this.observer.emit(v.ERROR,v.ERROR,{type:ye.MUX_ERROR,details:$.REMUX_ALLOC_ERROR,fatal:!1,error:X,bytes:P,reason:`fail allocating video mdat ${P}`});return}const G=new DataView(k.buffer);G.setUint32(0,P),k.set(O.types.mdat,4);let se=!1,oe=Number.POSITIVE_INFINITY,de=Number.POSITIVE_INFINITY,ae=Number.NEGATIVE_INFINITY,ie=Number.NEGATIVE_INFINITY;for(let X=0;X<d;X++){const Y=a[X],Ie=Y.units;let De=0;for(let dt=0,je=Ie.length;dt<je;dt++){const ne=Ie[dt],We=ne.data,V=ne.data.byteLength;G.setUint32(h,V),h+=4,k.set(We,h),h+=V,De+=4+V}let Re;if(X<d-1)f=a[X+1].dts-Y.dts,Re=a[X+1].pts-Y.pts;else{const dt=this.config,je=X>0?Y.dts-a[X-1].dts:R;if(Re=X>0?Y.pts-a[X-1].pts:R,dt.stretchShortVideoTrack&&this.nextAudioTs!==null){const ne=Math.floor(dt.maxBufferHole*r),We=(n?g+n*r:this.nextAudioTs+c)-Y.pts;We>ne?(f=We-je,f<0?f=je:se=!0,this.log(`It is approximately ${We/90} ms to the next segment; using duration ${f/90} ms for the last video frame.`)):f=je}else f=je}const Ce=Math.round(Y.pts-Y.dts);oe=Math.min(oe,f),ae=Math.max(ae,f),de=Math.min(de,Re),ie=Math.max(ie,Re),o.push(Wf(Y.key,f,De,Ce))}if(o.length){if(un){if(un<70){const X=o[0].flags;X.dependsOn=2,X.isNonSync=0}}else if(cd&&ie-de<ae-oe&&R/ae<.025&&o[0].cts===0){this.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let X=m;for(let Y=0,Ie=o.length;Y<Ie;Y++){const De=X+o[Y].duration,Re=X+o[Y].cts;if(Y<Ie-1){const Ce=De+o[Y+1].cts;o[Y].duration=Ce-Re}else o[Y].duration=Y?o[Y-1].duration:R;o[Y].cts=0,X=De}}}f=se||!f?R:f;const ue=p+f;this.nextVideoTs=u=ue-c,this.videoSampleDuration=f,this.isVideoContiguous=!0;const ve={data1:O.moof(e.sequenceNumber++,m,nt(e,{samples:o})),data2:k,startPTS:(g-c)/r,endPTS:(y+f-c)/r,startDTS:(m-c)/r,endDTS:u/r,type:"video",hasAudio:!1,hasVideo:!0,nb:o.length,dropped:e.dropped};return e.samples=[],e.dropped=0,ve}getSamplesPerFrame(e){switch(e.segmentCodec){case"mp3":return Tx;case"ac3":return bx;default:return yx}}remuxAudio(e,t,i,n,r){const a=e.inputTimeScale,o=e.samplerate?e.samplerate:a,d=a/o,l=this.getSamplesPerFrame(e),c=l*d,u=this._initPTS,h=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,f=[],m=r!==void 0;let p=e.samples,g=h?0:8,y=this.nextAudioTs||-1;const T=u.baseTime*a/u.timescale,_=T+t*a;if(this.isAudioContiguous=i=i||p.length&&y>0&&(n&&Math.abs(_-(y+T))<9e3||Math.abs(ai(p[0].pts,_)-(y+T))<20*c),p.forEach(function(ie){ie.pts=ai(ie.pts,_)}),!i||y<0){const ie=p.length;if(p=p.filter(ue=>ue.pts>=0),ie!==p.length&&this.warn(`Removed ${p.length-ie} of ${ie} samples (initPTS ${T} / ${a})`),!p.length)return;r===0?y=0:n&&!m?y=Math.max(0,_-T):y=p[0].pts-T}if(e.segmentCodec==="aac"){const ie=this.config.maxAudioFramesDrift;for(let ue=0,ee=y+T;ue<p.length;ue++){const te=p[ue],ve=te.pts,X=ve-ee,Y=Math.abs(1e3*X/a);if(X<=-ie*c&&m)ue===0&&(this.warn(`Audio frame @ ${(ve/a).toFixed(3)}s overlaps marker by ${Math.round(1e3*X/a)} ms.`),this.nextAudioTs=y=ve-T,ee=ve);else if(X>=ie*c&&Y<Ex&&m){let Ie=Math.round(X/c);for(ee=ve-Ie*c;ee<0&&Ie&&c;)Ie--,ee+=c;ue===0&&(this.nextAudioTs=y=ee-T),this.warn(`Injecting ${Ie} audio frames @ ${((ee-T)/a).toFixed(3)}s due to ${Math.round(1e3*X/a)} ms gap.`);for(let De=0;De<Ie;De++){let Re=gx.getSilentFrame(e.parsedCodec||e.manifestCodec||e.codec,e.channelCount);Re||(this.log("Unable to get silent frame for given audio codec; duplicating last frame instead."),Re=te.unit.subarray()),p.splice(ue,0,{unit:Re,pts:ee}),ee+=c,ue++}}te.pts=ee,ee+=c}}let I=null,R=null,F,L=0,w=p.length;for(;w--;)L+=p[w].unit.byteLength;for(let ie=0,ue=p.length;ie<ue;ie++){const ee=p[ie],te=ee.unit;let ve=ee.pts;if(R!==null){const Y=f[ie-1];Y.duration=Math.round((ve-R)/d)}else if(i&&e.segmentCodec==="aac"&&(ve=y+T),I=ve,L>0){L+=g;try{F=new Uint8Array(L)}catch(Y){this.observer.emit(v.ERROR,v.ERROR,{type:ye.MUX_ERROR,details:$.REMUX_ALLOC_ERROR,fatal:!1,error:Y,bytes:L,reason:`fail allocating audio mdat ${L}`});return}h||(new DataView(F.buffer).setUint32(0,L),F.set(O.types.mdat,4))}else return;F.set(te,g);const X=te.byteLength;g+=X,f.push(Wf(!0,l,X,0)),R=ve}const P=f.length;if(!P)return;const k=f[f.length-1];y=R-T,this.nextAudioTs=y+d*k.duration;const G=h?new Uint8Array(0):O.moof(e.sequenceNumber++,I/d,nt({},e,{samples:f}));e.samples=[];const se=(I-T)/a,oe=this.nextAudioTs/a,ae={data1:G,data2:F,startPTS:se,endPTS:oe,startDTS:se,endDTS:oe,type:"audio",hasAudio:!0,hasVideo:!1,nb:P};return this.isAudioContiguous=!0,ae}}function ai(s,e){let t;if(e===null)return s;for(e<s?t=-8589934592:t=8589934592;Math.abs(s-e)>4294967296;)s+=t;return s}function _x(s){for(let e=0;e<s.length;e++)if(s[e].key)return e;return-1}function Mv(s,e,t,i){const n=s.samples.length;if(!n)return;const r=s.inputTimeScale;for(let o=0;o<n;o++){const d=s.samples[o];d.pts=ai(d.pts-t.baseTime*r/t.timescale,e*r)/r,d.dts=ai(d.dts-i.baseTime*r/i.timescale,e*r)/r}const a=s.samples;return s.samples=[],{samples:a}}function Ov(s,e,t){const i=s.samples.length;if(!i)return;const n=s.inputTimeScale;for(let a=0;a<i;a++){const o=s.samples[a];o.pts=ai(o.pts-t.baseTime*n/t.timescale,e*n)/n}s.samples.sort((a,o)=>a.pts-o.pts);const r=s.samples;return s.samples=[],{samples:r}}class Sx extends pi{constructor(e,t,i,n){super("passthrough-remuxer",n),this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null,this.isVideoContiguous=!1}destroy(){}resetTimeStamp(e){this.lastEndTime=null;const t=this.initPTS;t&&e&&t.baseTime===e.baseTime&&t.timescale===e.timescale||(this.initPTS=e)}resetNextTimestamp(){this.isVideoContiguous=!1,this.lastEndTime=null}resetInitSegment(e,t,i,n){this.audioCodec=t,this.videoCodec=i,this.generateInitSegment(e,n),this.emitInitSegment=!0}generateInitSegment(e,t){let{audioCodec:i,videoCodec:n}=this;if(!(e!=null&&e.byteLength)){this.initTracks=void 0,this.initData=void 0;return}const{audio:r,video:a}=this.initData=Gp(e);if(t)cA(e,t);else{const d=r||a;d!=null&&d.encrypted&&this.warn(`Init segment with encrypted track with has no key ("${d.codec}")!`)}r&&(i=qf(r,ot.AUDIO,this)),a&&(n=qf(a,ot.VIDEO,this));const o={};r&&a?o.audiovideo={container:"video/mp4",codec:i+","+n,supplemental:a.supplemental,encrypted:a.encrypted,initSegment:e,id:"main"}:r?o.audio={container:"audio/mp4",codec:i,encrypted:r.encrypted,initSegment:e,id:"audio"}:a?o.video={container:"video/mp4",codec:n,supplemental:a.supplemental,encrypted:a.encrypted,initSegment:e,id:"main"}:this.warn("initSegment does not contain moov or trak boxes."),this.initTracks=o}remux(e,t,i,n,r,a){var o,d;let{initPTS:l,lastEndTime:c}=this;const u={audio:void 0,video:void 0,text:n,id3:i,initSegment:void 0};he(c)||(c=this.lastEndTime=r||0);const h=t.samples;if(!h.length)return u;const f={initPTS:void 0,timescale:void 0,trackId:void 0};let m=this.initData;if((o=m)!=null&&o.length||(this.generateInitSegment(h),m=this.initData),!((d=m)!=null&&d.length))return this.warn("Failed to generate initSegment."),u;this.emitInitSegment&&(f.tracks=this.initTracks,this.emitInitSegment=!1);const p=hA(h,m,this),g=m.audio?p[m.audio.id]:null,y=m.video?p[m.video.id]:null,T=Ma(y,1/0),_=Ma(g,1/0),I=Ma(y,0,!0),R=Ma(g,0,!0);let F=r,L=0;const w=g&&(!y||!l&&_<T||l&&l.trackId===m.audio.id),P=w?g:y;if(P){const ee=P.timescale,te=P.start-r*ee,ve=w?m.audio.id:m.video.id;F=P.start/ee,L=w?R-_:I-T,(a||!l)&&(Ax(l,F,r,L)||ee!==l.timescale)&&(l&&this.warn(`Timestamps at playlist time: ${a?"":"~"}${r} ${te/ee} != initPTS: ${l.baseTime/l.timescale} (${l.baseTime}/${l.timescale}) trackId: ${l.trackId}`),this.log(`Found initPTS at playlist time: ${r} offset: ${F-r} (${te}/${ee}) trackId: ${ve}`),l=null,f.initPTS=te,f.timescale=ee,f.trackId=ve)}else this.warn(`No audio or video samples found for initPTS at playlist time: ${r}`);l?(f.initPTS=l.baseTime,f.timescale=l.timescale,f.trackId=l.trackId):((!f.timescale||f.trackId===void 0||f.initPTS===void 0)&&(this.warn("Could not set initPTS"),f.initPTS=F,f.timescale=1,f.trackId=-1),this.initPTS=l={baseTime:f.initPTS,timescale:f.timescale,trackId:f.trackId});const k=F-l.baseTime/l.timescale,G=k+L;L>0?this.lastEndTime=G:(this.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const se=!!m.audio,oe=!!m.video;let de="";se&&(de+="audio"),oe&&(de+="video");const ae=(m.audio?m.audio.encrypted:!1)||(m.video?m.video.encrypted:!1),ie={data1:h,startPTS:k,startDTS:k,endPTS:G,endDTS:G,type:de,hasAudio:se,hasVideo:oe,nb:1,dropped:0,encrypted:ae};u.audio=se&&!oe?ie:void 0,u.video=oe?ie:void 0;const ue=y?.sampleCount;if(ue){const ee=y.keyFrameIndex,te=ee!==-1;ie.nb=ue,ie.dropped=ee===0||this.isVideoContiguous?0:te?ee:ue,ie.independent=te,ie.firstKeyFrame=ee,te&&y.keyFrameStart&&(ie.firstKeyFramePTS=(y.keyFrameStart-l.baseTime)/l.timescale),this.isVideoContiguous||(u.independent=te),this.isVideoContiguous||(this.isVideoContiguous=te),ie.dropped&&this.warn(`fmp4 does not start with IDR: firstIDR ${ee}/${ue} dropped: ${ie.dropped} start: ${ie.firstKeyFramePTS||"NA"}`)}return u.initSegment=f,u.id3=Mv(i,r,l,l),n.samples.length&&(u.text=Ov(n,r,l)),u}}function Ma(s,e,t=!1){return s?.start!==void 0?(s.start+(t?s.duration:0))/s.timescale:e}function Ax(s,e,t,i){if(s===null)return!0;const n=Math.max(i,1),r=e-s.baseTime/s.timescale;return Math.abs(r-t)>n}function qf(s,e,t){const i=s.codec;return i&&i.length>4?i:e===ot.AUDIO?i==="ec-3"||i==="ac-3"||i==="alac"?i:i==="fLaC"||i==="Opus"?dl(i,!1):(t.warn(`Unhandled audio codec "${i}" in mp4 MAP`),i||"mp4a"):(t.warn(`Unhandled video codec "${i}" in mp4 MAP`),i||"avc1")}let as;try{as=self.performance.now.bind(self.performance)}catch{as=Date.now}const Mo=[{demux:dx,remux:Sx},{demux:bs,remux:Po},{demux:rx,remux:Po},{demux:ox,remux:Po}];Mo.splice(2,0,{demux:ax,remux:Po});class Yf{constructor(e,t,i,n,r,a){this.asyncResult=!1,this.logger=void 0,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=e,this.typeSupported=t,this.config=i,this.id=r,this.logger=a}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(e,t,i,n){const r=i.transmuxing;r.executeStart=as();let a=new Uint8Array(e);const{currentTransmuxState:o,transmuxConfig:d}=this;n&&(this.currentTransmuxState=n);const{contiguous:l,discontinuity:c,trackSwitch:u,accurateTimeOffset:h,timeOffset:f,initSegmentChange:m}=n||o,{audioCodec:p,videoCodec:g,defaultInitPts:y,duration:T,initSegmentData:_}=d,I=Ix(a,t);if(I&&Nn(I.method)){const w=this.getDecrypter(),P=Ou(I.method);if(w.isSync()){let k=w.softwareDecrypt(a,I.key.buffer,I.iv.buffer,P);if(i.part>-1){const se=w.flush();k=se&&se.buffer}if(!k)return r.executeEnd=as(),ud(i);a=new Uint8Array(k)}else return this.asyncResult=!0,this.decryptionPromise=w.webCryptoDecrypt(a,I.key.buffer,I.iv.buffer,P).then(k=>{const G=this.push(k,null,i);return this.decryptionPromise=null,G}),this.decryptionPromise}const R=this.needsProbing(c,u);if(R){const w=this.configureTransmuxer(a);if(w)return this.logger.warn(`[transmuxer] ${w.message}`),this.observer.emit(v.ERROR,v.ERROR,{type:ye.MEDIA_ERROR,details:$.FRAG_PARSING_ERROR,fatal:!1,error:w,reason:w.message}),r.executeEnd=as(),ud(i)}(c||u||m||R)&&this.resetInitSegment(_,p,g,T,t),(c||m||R)&&this.resetInitialTimestamp(y),l||this.resetContiguity();const F=this.transmux(a,I,f,h,i);this.asyncResult=Yr(F);const L=this.currentTransmuxState;return L.contiguous=!0,L.discontinuity=!1,L.trackSwitch=!1,r.executeEnd=as(),F}flush(e){const t=e.transmuxing;t.executeStart=as();const{decrypter:i,currentTransmuxState:n,decryptionPromise:r}=this;if(r)return this.asyncResult=!0,r.then(()=>this.flush(e));const a=[],{timeOffset:o}=n;if(i){const u=i.flush();u&&a.push(this.push(u.buffer,null,e))}const{demuxer:d,remuxer:l}=this;if(!d||!l){t.executeEnd=as();const u=[ud(e)];return this.asyncResult?Promise.resolve(u):u}const c=d.flush(o);return Yr(c)?(this.asyncResult=!0,c.then(u=>(this.flushRemux(a,u,e),a))):(this.flushRemux(a,c,e),this.asyncResult?Promise.resolve(a):a)}flushRemux(e,t,i){const{audioTrack:n,videoTrack:r,id3Track:a,textTrack:o}=t,{accurateTimeOffset:d,timeOffset:l}=this.currentTransmuxState;this.logger.log(`[transmuxer.ts]: Flushed ${this.id} sn: ${i.sn}${i.part>-1?" part: "+i.part:""} of ${this.id===ge.MAIN?"level":"track"} ${i.level}`);const c=this.remuxer.remux(n,r,a,o,l,d,!0,this.id);e.push({remuxResult:c,chunkMeta:i}),i.transmuxing.executeEnd=as()}resetInitialTimestamp(e){const{demuxer:t,remuxer:i}=this;!t||!i||(t.resetTimeStamp(e),i.resetTimeStamp(e))}resetContiguity(){const{demuxer:e,remuxer:t}=this;!e||!t||(e.resetContiguity(),t.resetNextTimestamp())}resetInitSegment(e,t,i,n,r){const{demuxer:a,remuxer:o}=this;!a||!o||(a.resetInitSegment(e,t,i,n),o.resetInitSegment(e,t,i,r))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(e,t,i,n,r){let a;return t&&t.method==="SAMPLE-AES"?a=this.transmuxSampleAes(e,t,i,n,r):a=this.transmuxUnencrypted(e,i,n,r),a}transmuxUnencrypted(e,t,i,n){const{audioTrack:r,videoTrack:a,id3Track:o,textTrack:d}=this.demuxer.demux(e,t,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(r,a,o,d,t,i,!1,this.id),chunkMeta:n}}transmuxSampleAes(e,t,i,n,r){return this.demuxer.demuxSampleAes(e,t,i).then(a=>({remuxResult:this.remuxer.remux(a.audioTrack,a.videoTrack,a.id3Track,a.textTrack,i,n,!1,this.id),chunkMeta:r}))}
vendor: 3,935 bytes, line 1499
1499configureTransmuxer(e){const{config:t,observer:i,typeSupported:n}=this;let r;for(let u=0,h=Mo.length;u<h;u++){var a;if((a=Mo[u].demux)!=null&&a.probe(e,this.logger)){r=Mo[u];break}}if(!r)return new Error("Failed to find demuxer by probing fragment data");const o=this.demuxer,d=this.remuxer,l=r.remux,c=r.demux;(!d||!(d instanceof l))&&(this.remuxer=new l(i,t,n,this.logger)),(!o||!(o instanceof c))&&(this.demuxer=new c(i,t,n,this.logger),this.probe=c.probe)}needsProbing(e,t){return!this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e||(e=this.decrypter=new Pu(this.config)),e}}function Ix(s,e){let t=null;return s.byteLength>0&&e?.key!=null&&e.iv!==null&&e.method!=null&&(t=e),t}const ud=s=>({remuxResult:{},chunkMeta:s});function Yr(s){return"then"in s&&s.then instanceof Function}class xx{constructor(e,t,i,n,r){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=e,this.videoCodec=t,this.initSegmentData=i,this.duration=n,this.defaultInitPts=r||null}}class Lx{constructor(e,t,i,n,r,a){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=e,this.contiguous=t,this.accurateTimeOffset=i,this.trackSwitch=n,this.timeOffset=r,this.initSegmentChange=a}}let zf=0;class Fv{constructor(e,t,i,n){this.error=null,this.hls=void 0,this.id=void 0,this.instanceNo=zf++,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.onWorkerMessage=d=>{const l=d.data,c=this.hls;if(!(!c||!(l!=null&&l.event)||l.instanceNo!==this.instanceNo))switch(l.event){case"init":{var u;const h=(u=this.workerContext)==null?void 0:u.objectURL;h&&self.URL.revokeObjectURL(h);break}case"transmuxComplete":{this.handleTransmuxComplete(l.data);break}case"flush":{this.onFlush(l.data);break}case"workerLog":{c.logger[l.data.logType]&&c.logger[l.data.logType](l.data.message);break}default:{l.data=l.data||{},l.data.frag=this.frag,l.data.part=this.part,l.data.id=this.id,c.trigger(l.event,l.data);break}}},this.onWorkerError=d=>{if(!this.hls)return;const l=new Error(`${d.message} (${d.filename}:${d.lineno})`);this.hls.config.enableWorker=!1,this.hls.logger.warn(`Error in "${this.id}" Web Worker, fallback to inline`),this.hls.trigger(v.ERROR,{type:ye.OTHER_ERROR,details:$.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:l})};const r=e.config;this.hls=e,this.id=t,this.useWorker=!!r.enableWorker,this.onTransmuxComplete=i,this.onFlush=n;const a=(d,l)=>{l=l||{},l.frag=this.frag||void 0,d===v.ERROR&&(l=l,l.parent=this.id,l.part=this.part,this.error=l.error),this.hls.trigger(d,l)};this.observer=new Nu,this.observer.on(v.FRAG_DECRYPTED,a),this.observer.on(v.ERROR,a);const o=df(r.preferManagedMediaSource);if(this.useWorker&&typeof Worker<"u"){const d=this.hls.logger;if(r.workerPath||CI()){try{r.workerPath?(d.log(`loading Web Worker ${r.workerPath} for "${t}"`),this.workerContext=PI(r.workerPath)):(d.log(`injecting Web Worker for "${t}"`),this.workerContext=wI());const{worker:c}=this.workerContext;c.addEventListener("message",this.onWorkerMessage),c.addEventListener("error",this.onWorkerError),c.postMessage({instanceNo:this.instanceNo,cmd:"init",typeSupported:o,id:t,config:lt(r)})}catch(c){d.warn(`Error setting up "${t}" Web Worker, fallback to inline`,c),this.terminateWorker(),this.error=null,this.transmuxer=new Yf(this.observer,o,r,"",t,e.logger)}return}}this.transmuxer=new Yf(this.observer,o,r,"",t,e.logger)}reset(){if(this.frag=null,this.part=null,this.workerContext){const e=this.instanceNo;this.instanceNo=zf++;const t=this.hls.config,i=df(t.preferManagedMediaSource);this.workerContext.worker.postMessage({instanceNo:this.instanceNo,cmd:"reset",resetNo:e,typeSupported:i,id:this.id,c
vendor: 23,828 bytes, lines 1499-1505
1499onfig:lt(t)})}}terminateWorker(){if(this.workerContext){const{worker:e}=this.workerContext;this.workerContext=null,e.removeEventListener("message",this.onWorkerMessage),e.removeEventListener("error",this.onWorkerError),MI(this.hls.config.workerPath)}}destroy(){if(this.workerContext)this.terminateWorker(),this.onWorkerMessage=this.onWorkerError=null;else{const t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null)}const e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.part=null,this.observer=null,this.hls=null}push(e,t,i,n,r,a,o,d,l,c){var u,h;l.transmuxing.start=self.performance.now();const{instanceNo:f,transmuxer:m}=this,p=a?a.start:r.start,g=r.decryptdata,y=this.frag,T=!(y&&r.cc===y.cc),_=!(y&&l.level===y.level),I=y?l.sn-y.sn:-1,R=this.part?l.part-this.part.index:-1,F=I===0&&l.id>1&&l.id===y?.stats.chunkCount,L=!_&&(I===1||I===0&&(R===1||F&&R<=0)),w=self.performance.now();(_||I||r.stats.parsing.start===0)&&(r.stats.parsing.start=w),a&&(R||!L)&&(a.stats.parsing.start=w);const P=!(y&&((u=r.initSegment)==null?void 0:u.url)===((h=y.initSegment)==null?void 0:h.url)),k=new Lx(T,L,d,_,p,P);if(!L||T||P){this.hls.logger.log(`[transmuxer-interface]: Starting new transmux session for ${r.type} sn: ${l.sn}${l.part>-1?" part: "+l.part:""} ${this.id===ge.MAIN?"level":"track"}: ${l.level} id: ${l.id} 1500 discontinuity: ${T} 1501 trackSwitch: ${_} 1502 contiguous: ${L} 1503 accurateTimeOffset: ${d} 1504 timeOffset: ${p} 1505 initSegmentChange: ${P}`);const G=new xx(i,n,t,o,c);this.configureTransmuxer(G)}if(this.frag=r,this.part=a,this.workerContext)this.workerContext.worker.postMessage({instanceNo:f,cmd:"demux",data:e,decryptdata:g,chunkMeta:l,state:k},e instanceof ArrayBuffer?[e]:[]);else if(m){const G=m.push(e,g,l,k);Yr(G)?G.then(se=>{this.handleTransmuxComplete(se)}).catch(se=>{this.transmuxerError(se,l,"transmuxer-interface push error")}):this.handleTransmuxComplete(G)}}flush(e){e.transmuxing.start=self.performance.now();const{instanceNo:t,transmuxer:i}=this;if(this.workerContext)this.workerContext.worker.postMessage({instanceNo:t,cmd:"flush",chunkMeta:e});else if(i){const n=i.flush(e);Yr(n)?n.then(r=>{this.handleFlushResult(r,e)}).catch(r=>{this.transmuxerError(r,e,"transmuxer-interface flush error")}):this.handleFlushResult(n,e)}}transmuxerError(e,t,i){this.hls&&(this.error=e,this.hls.trigger(v.ERROR,{type:ye.MEDIA_ERROR,details:$.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,part:this.part||void 0,fatal:!1,error:e,err:e,reason:i}))}handleFlushResult(e,t){e.forEach(i=>{this.handleTransmuxComplete(i)}),this.onFlush(t)}configureTransmuxer(e){const{instanceNo:t,transmuxer:i}=this;this.workerContext?this.workerContext.worker.postMessage({instanceNo:t,cmd:"configure",config:e}):i&&i.configure(e)}handleTransmuxComplete(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}}const jf=100;class Rx extends $u{constructor(e,t,i){super(e,t,i,"audio-stream-controller",ge.AUDIO),this.mainAnchor=null,this.mainFragLoading=null,this.audioOnly=!1,this.bufferedTrack=null,this.switchingTrack=null,this.trackId=-1,this.waitingData=null,this.mainDetails=null,this.flushing=!1,this.bufferFlushed=!1,this.cachedTrackLoadedData=null,this.registerListeners()}onHandlerDestroying(){this.unregisterListeners(),super.onHandlerDestroying(),this.resetItem()}resetItem(){this.mainDetails=this.mainAnchor=this.mainFragLoading=this.bufferedTrack=this.switchingTrack=this.waitingData=this.cachedTrackLoadedData=null}registerListeners(){super.registerListeners();const{hls:e}=this;e.on(v.LEVEL_LOADED,this.onLevelLoaded,this),e.on(v.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(v.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(v.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(v.BUFFER_RESET,this.onBufferReset,this),e.on(v.BUFFER_CREATED,this.onBufferCreated,this),e.on(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(v.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(v.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(v.FRAG_LOADING,this.onFragLoading,this),e.on(v.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){const{hls:e}=this;e&&(super.unregisterListeners(),e.off(v.LEVEL_LOADED,this.onLevelLoaded,this),e.off(v.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(v.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(v.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(v.BUFFER_RESET,this.onBufferReset,this),e.off(v.BUFFER_CREATED,this.onBufferCreated,this),e.off(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(v.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(v.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(v.FRAG_LOADING,this.onFragLoading,this),e.off(v.FRAG_BUFFERED,this.onFragBuffered,this))}onInitPtsFound(e,{frag:t,id:i,initPTS:n,timescale:r,trackId:a}){if(i===ge.MAIN){const o=t.cc,d=this.fragCurrent;if(this.initPTS[o]={baseTime:n,timescale:r,trackId:a},this.log(`InitPTS for cc: ${o} found from main: ${n/r} (${n}/${r}) trackId: ${a}`),this.mainAnchor=t,this.state===W.WAITING_INIT_PTS){const l=this.waitingData;(!l&&!this.loadingParts||l&&l.frag.cc!==o)&&this.syncWithAnchor(t,l?.frag)}else!this.hls.hasEnoughToStart&&d&&d.cc!==o?(d.abortRequests(),this.syncWithAnchor(t,d)):this.state===W.IDLE&&this.tick()}}getLoadPosition(){return!this.startFragRequested&&this.nextLoadPosition>=0?this.nextLoadPosition:super.getLoadPosition()}syncWithAnchor(e,t){var i;const n=((i=this.mainFragLoading)==null?void 0:i.frag)||null;if(t&&n?.cc===t.cc)return;const r=(n||e).cc,a=this.getLevelDetails(),o=this.getLoadPosition(),d=Zp(a,r,o);d&&(this.log(`Syncing with main frag at ${d.start} cc ${d.cc}`),this.startFragRequested=!1,this.nextLoadPosition=d.start,this.resetLoadingState(),this.state===W.IDLE&&this.doTickIdle())}startLoad(e,t){if(!this.levels){this.startPosition=e,this.state=W.STOPPED;return}const i=this.lastCurrentTime;this.stopLoad(),this.setInterval(jf),i>0&&e===-1?(this.log(`Override startPosition with lastCurrentTime @${i.toFixed(3)}`),e=i,this.state=W.IDLE):this.state=W.WAITING_TRACK,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}doTick(){switch(this.state){case W.IDLE:this.doTickIdle();break;case W.WAITING_TRACK:{const{levels:e,trackId:t}=this,i=e?.[t],n=i?.details;if(n&&!this.waitForLive(i)){if(this.waitForCdnTuneIn(n))break;this.state=W.WAITING_INIT_PTS}break}case W.FRAG_LOADING_WAITING_RETRY:{this.checkRetryDate();break}case W.WAITING_INIT_PTS:{const e=this.waitingData;if(e){const{frag:t,part:i,cache:n,complete:r}=e,a=this.mainAnchor;if(this.initPTS[t.cc]!==void 0){this.waitingData=null,this.state=W.FRAG_LOADING;const o=n.flush().buffer,d={frag:t,part:i,payload:o,networkDetails:null};this._handleFragmentLoadProgress(d),r&&super._handleFragmentLoadComplete(d)}else a&&a.cc!==e.frag.cc&&this.syncWithAnchor(a,e.frag)}else this.state=W.IDLE}}this.onTickEnd()}resetLoadingState(){const e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null),super.resetLoadingState()}onTickEnd(){const{media:e}=this;e!=null&&e.readyState&&(this.lastCurrentTime=e.currentTime)}doTickIdle(){var e;const{hls:t,levels:i,media:n,trackId:r}=this,a=t.config;if(!this.buffering||!n&&!this.primaryPrefetch&&(this.startFragRequested||!a.startFragPrefetch)||!(i!=null&&i[r]))return;const o=i[r],d=o.details;if(!d||this.waitForLive(o)||this.waitForCdnTuneIn(d)){this.state=W.WAITING_TRACK,this.startFragRequested=!1;return}const l=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&l&&(this.bufferFlushed=!1,this.afterBufferFlushed(l,ot.AUDIO,ge.AUDIO));const c=this.getFwdBufferInfo(l,ge.AUDIO);if(c===null)return;if(!this.switchingTrack&&this._streamEnded(c,d)){t.trigger(v.BUFFER_EOS,{type:"audio"}),this.state=W.ENDED;return}const u=c.len,h=t.maxBufferLength,f=d.fragments,m=f[0].start,p=this.getLoadPosition(),g=this.flushing?p:c.end;if(this.switchingTrack&&n){const _=p;d.PTSKnown&&_<m&&(c.end>m||c.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),n.currentTime=m+.05)}if(u>=h&&!this.switchingTrack&&g<f[f.length-1].start)return;let y=this.getNextFragment(g,d);if(y&&this.isLoopLoading(y,g)&&(y=this.getNextFragmentLoopLoading(y,d,c,ge.MAIN,h)),!y){this.bufferFlushed=!0;return}let T=((e=this.mainFragLoading)==null?void 0:e.frag)||null;if(!this.audioOnly&&this.startFragRequested&&T&&yt(y)&&!y.endList&&(!d.live||!this.loadingParts&&g<this.hls.liveSyncPosition)&&(this.fragmentTracker.getState(T)===Rt.OK&&(this.mainFragLoading=T=null),T&&yt(T))){if(y.start>T.end){const I=this.fragmentTracker.getFragAtPos(g,ge.MAIN);I&&I.end>T.end&&(T=I,this.mainFragLoading={frag:I,targetBufferTime:null})}if(y.start>T.end)return}this.loadFragment(y,o,g)}onMediaDetaching(e,t){this.bufferFlushed=this.flushing=!1,super.onMediaDetaching(e,t)}onAudioTracksUpdated(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map(i=>new Vr(i))}onAudioTrackSwitching(e,t){const i=!!t.url;this.trackId=t.id;const{fragCurrent:n}=this;n&&(n.abortRequests(),this.removeUnbufferedFrags(n.start)),this.resetLoadingState(),i?(this.switchingTrack=t,this.flushAudioIfNeeded(t),this.state!==W.STOPPED&&(this.setInterval(jf),this.state=W.IDLE,this.tick())):(this.resetTransmuxer(),this.switchingTrack=null,this.bufferedTrack=t,this.clearInterval())}onManifestLoading(){super.onManifestLoading(),this.bufferFlushed=this.flushing=this.audioOnly=!1,this.resetItem(),this.trackId=-1}onLevelLoaded(e,t){this.mainDetails=t.details;const i=this.cachedTrackLoadedData;i&&(this.cachedTrackLoadedData=null,this.onAudioTrackLoaded(v.AUDIO_TRACK_LOADED,i))}onAudioTrackLoaded(e,t){var i;const{levels:n}=this,{details:r,id:a,groupId:o,track:d}=t;if(!n){this.warn(`Audio tracks reset while loading track ${a} "${d.name}" of "${o}"`);return}const l=this.mainDetails;if(!l||r.endCC>l.endCC||l.expired){this.cachedTrackLoadedData=t,this.state!==W.STOPPED&&(this.state=W.WAITING_TRACK);return}this.cachedTrackLoadedData=null,this.log(`Audio track ${a} "${d.name}" of "${o}" loaded [${r.startSN},${r.endSN}]${r.lastPartSn?`[part-${r.lastPartSn}-${r.lastPartIndex}]`:""},duration:${r.totalduration}`);const c=n[a];let u=0;if(r.live||(i=c.details)!=null&&i.live){if(this.checkLiveUpdate(r),r.deltaUpdateFailed)return;if(c.details){var h;u=this.alignPlaylists(r,c.details,(h=this.levelLastLoaded)==null?void 0:h.details)}r.alignedSliding||(pv(r,l),r.alignedSliding||pl(r,l),u=r.fragmentStart)}c.details=r,this.levelLastLoaded=c,this.startFragRequested||this.setStartPosition(l,u),this.hls.trigger(v.AUDIO_TRACK_UPDATED,{details:r,id:a,groupId:t.groupId}),this.state===W.WAITING_TRACK&&!this.waitForCdnTuneIn(r)&&(this.state=W.IDLE),this.tick()}_handleFragmentLoadProgress(e){var t;const i=e.frag,{part:n,payload:r}=e,{config:a,trackId:o,levels:d}=this;if(!d){this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`);return}const l=d[o];if(!l){this.warn("Audio track is undefined on fragment load progress");return}const c=l.details;if(!c){this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(i.start);return}const u=a.defaultAudioCodec||l.audioCodec||"mp4a.40.2";let h=this.transmuxer;h||(h=this.transmuxer=new Fv(this.hls,ge.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));const f=this.initPTS[i.cc],m=(t=i.initSegment)==null?void 0:t.data;if(f!==void 0){const g=n?n.index:-1,y=g!==-1,T=new Mu(i.level,i.sn,i.stats.chunkCount,r.byteLength,g,y);h.push(r,m,u,"",i,n,c.totalduration,!1,T,f)}else{this.log(`Unknown video PTS for cc ${i.cc}, waiting for video PTS before demuxing audio frag ${i.sn} of [${c.startSN} ,${c.endSN}],track ${o}`);const{cache:p}=this.waitingData=this.waitingData||{frag:i,part:n,cache:new vv,complete:!1};p.push(new Uint8Array(r)),this.state!==W.STOPPED&&(this.state=W.WAITING_INIT_PTS)}}_handleFragmentLoadComplete(e){if(this.waitingData){this.waitingData.complete=!0;return}super._handleFragmentLoadComplete(e)}onBufferReset(){this.mediaBuffer=null}onBufferCreated(e,t){this.bufferFlushed=this.flushing=!1;const i=t.tracks.audio;i&&(this.mediaBuffer=i.buffer||null)}onFragLoading(e,t){!this.audioOnly&&t.frag.type===ge.MAIN&&yt(t.frag)&&(this.mainFragLoading=t,this.state===W.IDLE&&this.tick())}onFragBuffered(e,t){const{frag:i,part:n}=t;if(i.type!==ge.AUDIO){!this.audioOnly&&i.type===ge.MAIN&&!i.elementaryStreams.video&&!i.elementaryStreams.audiovideo&&(this.audioOnly=!0,this.mainFragLoading=null);return}if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${n?" p: "+n.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);return}if(yt(i)){this.fragPrevious=i;const r=this.switchingTrack;r&&(this.bufferedTrack=r,this.switchingTrack=null,this.hls.trigger(v.AUDIO_TRACK_SWITCHED,Je({},r)))}this.fragBufferedComplete(i,n),this.media&&this.tick()}onError(e,t){var i;if(t.fatal){this.state=W.ERROR;return}switch(t.details){case $.FRAG_GAP:case $.FRAG_PARSING_ERROR:case $.FRAG_DECRYPT_ERROR:case $.FRAG_LOAD_ERROR:case $.FRAG_LOAD_TIMEOUT:case $.KEY_LOAD_ERROR:case $.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(ge.AUDIO,t);break;case $.AUDIO_TRACK_LOAD_ERROR:case $.AUDIO_TRACK_LOAD_TIMEOUT:case $.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===W.WAITING_TRACK&&((i=t.context)==null?void 0:i.type)===Ge.AUDIO_TRACK&&(this.state=W.IDLE);break;case $.BUFFER_ADD_CODEC_ERROR:case $.BUFFER_APPEND_ERROR:if(t.parent!=="audio")return;this.reduceLengthAndFlushBuffer(t)||this.resetLoadingState();break;case $.BUFFER_FULL_ERROR:if(t.parent!=="audio")return;this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case $.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}onBufferFlushing(e,{type:t}){t!==ot.VIDEO&&(this.flushing=!0)}onBufferFlushed(e,{type:t}){if(t!==ot.VIDEO){this.flushing=!1,this.bufferFlushed=!0,this.state===W.ENDED&&(this.state=W.IDLE);const i=this.mediaBuffer||this.media;i&&(this.afterBufferFlushed(i,t,ge.AUDIO),this.tick())}}_handleTransmuxComplete(e){var t;const i="audio",{hls:n}=this,{remuxResult:r,chunkMeta:a}=e,o=this.getCurrentContext(a);if(!o){this.resetWhenMissingContext(a);return}const{frag:d,part:l,level:c}=o,{details:u}=c,{audio:h,text:f,id3:m,initSegment:p}=r;if(this.fragContextChanged(d)||!u){this.fragmentTracker.removeFragment(d);return}if(this.state=W.PARSING,this.switchingTrack&&h&&this.completeAudioSwitch(this.switchingTrack),p!=null&&p.tracks){const g=d.initSegment||d;if(this.unhandledEncryptionError(p,d))return;this._bufferInitSegment(c,p.tracks,g,a),n.trigger(v.FRAG_PARSING_INIT_SEGMENT,{frag:g,id:i,tracks:p.tracks})}if(h){const{startPTS:g,endPTS:y,startDTS:T,endDTS:_}=h;l&&(l.elementaryStreams[ot.AUDIO]={startPTS:g,endPTS:y,startDTS:T,endDTS:_}),d.setElementaryStreamInfo(ot.AUDIO,g,y,T,_),this.bufferFragmentData(h,d,l,a)}if(m!=null&&(t=m.samples)!=null&&t.length){const g=nt({id:i,frag:d,details:u},m);n.trigger(v.FRAG_PARSING_METADATA,g)}if(f){const g=nt({id:i,frag:d,details:u},f);n.trigger(v.FRAG_PARSING_USERDATA,g)}}_bufferInitSegment(e,t,i,n){if(this.state!==W.PARSING||(t.video&&delete t.video,t.audiovideo&&delete t.audiovideo,!t.audio))return;const r=t.audio;r.id=ge.AUDIO;const a=e.audioCodec;this.log(`Init audio buffer, container:${r.container}, codecs[level/parsed]=[${a}/${r.codec}]`),a&&a.split(",").length===1&&(r.levelCodec=a),this.hls.trigger(v.BUFFER_CODECS,t);const o=r.initSegment;if(o!=null&&o.byteLength){const d={type:"audio",frag:i,part:null,chunkMeta:n,parent:i.type,data:o};this.hls.trigger(v.BUFFER_APPENDING,d)}this.tickImmediate()}loadFragment(e,t,i){const n=this.fragmentTracker.getState(e);if(this.switchingTrack||n===Rt.NOT_LOADED||n===Rt.PARTIAL){var r;if(!yt(e))this._loadInitSegment(e,t);else if((r=t.details)!=null&&r.live&&!this.initPTS[e.cc]){this.log(`Waiting for video PTS in continuity counter ${e.cc} of live stream before loading audio fragment ${e.sn} of level ${this.trackId}`),this.state=W.WAITING_INIT_PTS;const a=this.mainDetails;a&&a.fragmentStart!==t.details.fragmentStart&&pl(t.details,a)}else super.loadFragment(e,t,i)}else this.clearTrackerIfNeeded(e)}flushAudioIfNeeded(e){if(this.media&&this.bufferedTrack){const{name:t,lang:i,assocLang:n,characteristics:r,audioCodec:a,channels:o}=this.bufferedTrack;js({name:t,lang:i,assocLang:n,characteristics:r,audioCodec:a,channels:o},e,Gs)||(ul(e.url,this.hls)?(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"),this.bufferedTrack=null):this.bufferedTrack=e)}}completeAudioSwitch(e){const{hls:t}=this;this.flushAudioIfNeeded(e),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(v.AUDIO_TRACK_SWITCHED,Je({},e))}}class Wu extends pi{constructor(e,t){super(t,e.logger),this.hls=void 0,this.canLoad=!1,this.timer=-1,this.hls=e}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){this.timer!==-1&&(self.clearTimeout(this.timer),this.timer=-1)}startLoad(){this.canLoad=!0,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(e,t,i){const n=t?.renditionReports;if(n){let r=-1;for(let a=0;a<n.length;a++){const o=n[a];let d;try{d=new self.URL(o.URI,t.url).href}catch(l){this.warn(`Could not construct new URL for Rendition Report: ${l}`),d=o.URI||""}if(d===e){r=a;break}else d===e.substring(0,d.length)&&(r=a)}if(r!==-1){const a=n[r],o=parseInt(a["LAST-MSN"])||t.lastPartSn;let d=parseInt(a["LAST-PART"])||t.lastPartIndex;if(this.hls.config.lowLatencyMode){const c=Math.min(t.age-t.partTarget,t.targetduration);d>=0&&c>t.partTarget&&(d+=1)}const l=i&&cf(i);return new uf(o,d>=0?d:void 0,l)}}}loadPlaylist(e){this.clearTimer()}loadingPlaylist(e,t){this.clearTimer()}shouldLoadPlaylist(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}getUrlWithDirectives(e,t){if(t)try{return t.addDirectives(e)}catch(i){this.warn(`Could not construct new URL with HLS Delivery Directives: ${i}`)}return e}playlistLoaded(e,t,i){const{details:n,stats:r}=t,a=self.performance.now(),o=r.loading.first?Math.max(0,a-r.loading.first):0;n.advancedDateTime=Date.now()-o;const d=this.hls.config.timelineOffset;if(d!==n.appliedTimelineOffset){const c=Math.max(d||0,0);n.appliedTimelineOffset=c,n.fragments.forEach(u=>{u.setStart(u.playlistOffset+c)})}if(n.live||i!=null&&i.live){const c="levelInfo"in t?t.levelInfo:t.track;if(n.reloaded(i),i&&n.fragments.length>0){TI(i,n,this);const T=n.playlistParsingError;if(T){this.warn(T);const _=this.hls;if(!_.config.ignorePlaylistParsingErrors){var l;const{networkDetails:I}=t;_.trigger(v.ERROR,{type:ye.NETWORK_ERROR,details:$.LEVEL_PARSING_ERROR,fatal:!1,url:n.url,error:T,reason:T.message,level:t.level||void 0,parent:(l=n.fragments[0])==null?void 0:l.type,networkDetails:I,stats:r});return}n.playlistParsingError=null}}n.requestScheduled===-1&&(n.requestScheduled=r.loading.start);const u=this.hls.mainForwardBufferInfo,h=u?u.end-u.len:0,f=(n.edge-h)*1e3,m=uv(n,f);if(n.requestScheduled+m<a?n.requestScheduled=a:n.requestScheduled+=m,this.log(`live playlist ${e} ${n.advanced?"REFRESHED "+n.lastPartSn+"-"+n.lastPartIndex:n.updated?"UPDATED":"MISSED"}`),!this.canLoad||!n.live)return;let p,g,y;if(n.canBlockReload&&n.endSN&&n.advanced){const T=this.hls.config.lowLatencyMode,_=n.lastPartSn,I=n.endSN,R=n.lastPartIndex,F=R!==-1,L=_===I;F?L?(g=I+1,y=T?0:R):(g=_,y=T?R+1:n.maxPartIndex):g=I+1;const w=n.age,P=w+n.ageHeader;let k=Math.min(P-n.partTarget,n.targetduration*1.5);if(k>0){if(P>n.targetduration*3)this.log(`Playlist last advanced ${w.toFixed(2)}s ago. Omitting segment and part directives.`),g=void 0,y=void 0;else if(i!=null&&i.tuneInGoal&&P-n.partTarget>i.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${i.tuneInGoal} to: ${k} with playlist age: ${n.age}`),k=0;else{const G=Math.floor(k/n.targetduration);if(g+=G,y!==void 0){const se=Math.round(k%n.targetduration/n.partTarget);y+=se}this.log(`CDN Tune-in age: ${n.ageHeader}s last advanced ${w.toFixed(2)}s goal: ${k} skip sn ${G} to part ${y}`)}n.tuneInGoal=k}if(p=this.getDeliveryDirectives(n,t.deliveryDirectives,g,y),T||!L){n.requestScheduled=a,this.loadingPlaylist(c,p);return}}else(n.canBlockReload||n.canSkipUntil)&&(p=this.getDeliveryDirectives(n,t.deliveryDirectives,g,y));p&&g!==void 0&&n.canBlockReload&&(n.requestScheduled=r.loading.first+Math.max(m-o*2,m/2)),this.scheduleLoading(c,p,n)}else this.clearTimer()}scheduleLoading(e,t,i){const n=i||e.details;if(!n){this.loadingPlaylist(e,t);return}const r=self.performance.now(),a=n.requestScheduled;if(r>=a){this.loadingPlaylist(e,t);return}const o=a-r;this.log(`reload live playlist ${e.name||e.bitrate+"bps"} in ${Math.round(o)} ms`),this.clearTimer(),this.timer=self.setTimeout(()=>this.loadingPlaylist(e,t),o)}getDeliveryDirectives(e,t,i,n){let r=cf(e);return t!=null&&t.skip&&e.deltaUpdateFailed&&(i=t.msn,n=t.part,r=Co.No),new uf(i,n,r)}checkRetry(e){const t=e.details,i=hl(e),n=e.errorAction,{action:r,retryCount:a=0,retryConfig:o}=n||{},d=!!n&&!!o&&(r===Ut.RetryRequest||!n.resolved&&r===Ut.SendAlternateToPenaltyBox);if(d){var l;if(a>=o.maxNumRetry)return!1;if(i&&(l=e.context)!=null&&l.deliveryDirectives)this.warn(`Retrying playlist loading ${a+1}/${o.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{const c=wu(o,a);this.clearTimer(),this.timer=self.setTimeout(()=>this.loadPlaylist(),c),this.warn(`Retrying playlist loading ${a+1}/${o.maxNumRetry} after "${t}" in ${c}ms`)}e.levelRetry=!0,n.resolved=!0}return d}}function $v(s,e){if(s.length!==e.length)return!1;for(let t=0;t<s.length;t++)if(!zr(s[t].attrs,e[t].attrs))return!1;return!0}function zr(s,e,t){const i=s["STABLE-RENDITION-ID"];return i&&!t?i===e["STABLE-RENDITION-ID"]:!(t||["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED","ASSOC-LANGUAGE"]).some(n=>s[n]!==e[n])}function Bc(s,e){return e.label.toLowerCase()===s.name.toLowerCase()&&(!e.language||e.language.toLowerCase()===(s.lang||"").toLowerCase())}class kx extends Wu{constructor(e){super(e,"audio-track-controller"),this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){const{hls:e}=this;e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_PARSED,this.onManifestParsed,this),e.on(v.LEVEL_LOADING,this.onLevelLoading,this),e.on(v.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(v.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(v.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_PARSED,this.onManifestParsed,this),e.off(v.LEVEL_LOADING,this.onLevelLoading,this),e.off(v.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(v.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(v.ERROR,this.onError,this)}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy()}onManifestLoading(){this.tracks=[],this.tracksInGroup=[],this.groupIds=null,this.currentTrack=null,this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.audioTracks||[]}onAudioTrackLoaded(e,t){const{id:i,groupId:n,details:r}=t,a=this.tracksInGroup[i];if(!a||a.groupId!==n){this.warn(`Audio track with id:${i} and group:${n} not found in active group ${a?.groupId}`);return}const o=a.details;a.details=t.details,this.log(`Audio track ${i} "${a.name}" lang:${a.lang} group:${n} loaded [${r.startSN}-${r.endSN}]`),i===this.trackId&&this.playlistLoaded(i,t,o)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(!t)return;
vendor: 1,617 bytes, line 1505
1505const i=t.audioGroups||null,n=this.groupIds;let r=this.currentTrack;if(!i||n?.length!==i?.length||i!=null&&i.some(o=>n?.indexOf(o)===-1)){this.groupIds=i,this.trackId=-1,this.currentTrack=null;const o=this.tracks.filter(h=>!i||i.indexOf(h.groupId)!==-1);if(o.length)this.selectDefaultTrack&&!o.some(h=>h.default)&&(this.selectDefaultTrack=!1),o.forEach((h,f)=>{h.id=f});else if(!r&&!this.tracksInGroup.length)return;this.tracksInGroup=o;const d=this.hls.config.audioPreference;if(!r&&d){const h=qi(d,o,Gs);if(h>-1)r=o[h];else{const f=qi(d,this.tracks);r=this.tracks[f]}}let l=this.findTrackId(r);l===-1&&r&&(l=this.findTrackId(null));const c={audioTracks:o};this.log(`Updating audio tracks, ${o.length} track(s) found in group(s): ${i?.join(",")}`),this.hls.trigger(v.AUDIO_TRACKS_UPDATED,c);const u=this.trackId;if(l!==-1&&u===-1)this.setAudioTrack(l);else if(o.length&&u===-1){var a;const h=new Error(`No audio track selected for current audio group-ID(s): ${(a=this.groupIds)==null?void 0:a.join(",")} track count: ${o.length}`);this.warn(h.message),this.hls.trigger(v.ERROR,{type:ye.MEDIA_ERROR,details:$.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:h})}}}onError(e,t){t.fatal||!t.context||t.context.type===Ge.AUDIO_TRACK&&t.context.id===this.trackId&&(!this.groupIds||this.groupIds.indexOf(t.context.groupId)!==-1)&&this.checkRetry(t)}get allAudioTracks(){return this.tracks}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}setAudioOption(e){const t=this.hls;if(t.config.audioPreference=e,e){const i=this.allAudioTracks;
vendor: 6,811 bytes, lines 1505-1508
1505if(this.selectDefaultTrack=!1,i.length){const n=this.currentTrack;if(n&&js(e,n,Gs))return n;const r=qi(e,this.tracksInGroup,Gs);if(r>-1){const a=this.tracksInGroup[r];return this.setAudioTrack(r),a}else if(n){let a=t.loadLevel;a===-1&&(a=t.firstAutoLevel);const o=GA(e,t.levels,i,a,Gs);if(o===-1)return null;t.nextLoadLevel=o}if(e.channels||e.audioCodec){const a=qi(e,i);if(a>-1)return i[a]}}}return null}setAudioTrack(e){const t=this.tracksInGroup;if(e<0||e>=t.length){this.warn(`Invalid audio track id: ${e}`);return}this.selectDefaultTrack=!1;const i=this.currentTrack,n=t[e],r=n.details&&!n.details.live;if(e===this.trackId&&n===i&&r||(this.log(`Switching to audio-track ${e} "${n.name}" lang:${n.lang} group:${n.groupId} channels:${n.channels}`),this.trackId=e,this.currentTrack=n,this.hls.trigger(v.AUDIO_TRACK_SWITCHING,Je({},n)),r))return;const a=this.switchParams(n.url,i?.details,n.details);this.loadPlaylist(a)}findTrackId(e){const t=this.tracksInGroup;for(let i=0;i<t.length;i++){const n=t[i];if(!(this.selectDefaultTrack&&!n.default)&&(!e||js(e,n,Gs)))return i}if(e){const{name:i,lang:n,assocLang:r,characteristics:a,audioCodec:o,channels:d}=e;for(let l=0;l<t.length;l++){const c=t[l];if(js({name:i,lang:n,assocLang:r,characteristics:a,audioCodec:o,channels:d},c,Gs))return l}for(let l=0;l<t.length;l++){const c=t[l];if(zr(e.attrs,c.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return l}for(let l=0;l<t.length;l++){const c=t[l];if(zr(e.attrs,c.attrs,["LANGUAGE"]))return l}}return-1}loadPlaylist(e){super.loadPlaylist();const t=this.currentTrack;this.shouldLoadPlaylist(t)&&ul(t.url,this.hls)&&this.scheduleLoading(t,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);const i=e.id,n=e.groupId,r=this.getUrlWithDirectives(e.url,t),a=e.details,o=a?.age;this.log(`Loading audio-track ${i} "${e.name}" lang:${e.lang} group:${n}${t?.msn!==void 0?" at sn "+t.msn+" part "+t.part:""}${o&&a.live?" age "+o.toFixed(1)+(a.type&&" "+a.type||""):""} ${r}`),this.hls.trigger(v.AUDIO_TRACK_LOADING,{url:r,id:i,groupId:n,deliveryDirectives:t||null,track:e})}}class Dx{constructor(e){this.tracks=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.tracks=e}destroy(){this.tracks=this.queues=null}append(e,t,i){if(this.queues===null||this.tracks===null)return;const n=this.queues[t];n.push(e),n.length===1&&!i&&this.executeNext(t)}appendBlocker(e){return new Promise(t=>{const i={label:"async-blocker",execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};this.append(i,e)})}prependBlocker(e){return new Promise(t=>{if(this.queues){const i={label:"async-blocker-prepend",execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};this.queues[e].unshift(i)}})}removeBlockers(){this.queues!==null&&[this.queues.video,this.queues.audio,this.queues.audiovideo].forEach(e=>{var t;const i=(t=e[0])==null?void 0:t.label;(i==="async-blocker"||i==="async-blocker-prepend")&&(e[0].execute(),e.splice(0,1))})}unblockAudio(e){if(this.queues===null)return;this.queues.audio[0]===e&&this.shiftAndExecuteNext("audio")}executeNext(e){if(this.queues===null||this.tracks===null)return;const t=this.queues[e];if(t.length){const n=t[0];try{n.execute()}catch(r){var i;if(n.onError(r),this.queues===null||this.tracks===null)return;const a=(i=this.tracks[e])==null?void 0:i.buffer;a!=null&&a.updating||this.shiftAndExecuteNext(e)}}}shiftAndExecuteNext(e){this.queues!==null&&(this.queues[e].shift(),this.executeNext(e))}current(e){var t;return((t=this.queues)==null?void 0:t[e][0])||null}toString(){const{queues:e,tracks:t}=this;return e===null||t===null?"<destroyed>":` 1506${this.list("video")} 1507${this.list("audio")} 1508${this.list("audiovideo")}}`}list(e){var t,i;return(t=this.queues)!=null&&t[e]||(i=this.tracks)!=null&&i[e]?`${e}: (${this.listSbInfo(e)}) ${this.listOps(e)}`:""}listSbInfo(e){var t;const i=(t=this.tracks)==null?void 0:t[e],n=i?.buffer;return n?`SourceBuffer${n.updating?" updating":""}${i.ended?" ended":""}${i.ending?" ending":""}`:"none"}listOps(e){var t;return((t=this.queues)==null?void 0:t[e].map(i=>i.label).join(", "))||""}}const Xf=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,Nv="HlsJsTrackRemovedError";class Cx extends Error{constructor(e){super(e),this.name=Nv}}class wx extends pi{constructor(e,t){super("buffer-controller",e.logger),this.hls=void 0,this.fragmentTracker=void 0,this.details=null,this._objectUrl=null,this.operationQueue=null,this.bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.blockedAudioAppend=null,this.lastVideoAppendEnd=0,this.appendSource=void 0,this.transferData=void 0,this.overrides=void 0,this.appendErrors={audio:0,video:0,audiovideo:0},this.tracks={},this.sourceBuffers=[[null,null],[null,null]],this._onEndStreaming=i=>{var n;this.hls&&((n=this.mediaSource)==null?void 0:n.readyState)==="open"&&this.hls.pauseBuffering()},this._onStartStreaming=i=>{this.hls&&this.hls.resumeBuffering()},this._onMediaSourceOpen=i=>{const{media:n,mediaSource:r}=this;i&&this.log("Media source opened"),!(!n||!r)&&(r.removeEventListener("sourceopen",this._onMediaSourceOpen),n.removeEventListener("emptied",this._onMediaEmptied),this.updateDuration(),this.hls.trigger(v.MEDIA_ATTACHED,{media:n,mediaSource:r}),this.mediaSource!==null&&this.checkPendingTracks())},this._onMediaSourceClose=()=>{this.log("Media source closed")},this._onMediaSourceEnded=()=>{this.log("Media source ended")},this._onMediaEmptied=()=>{const{mediaSrc:i,_objectUrl:n}=this;i!==n&&this.error(`Media element src was set while attaching MediaSource (${n} > ${i})`)},this.hls=e,this.fragmentTracker=t,this.appendSource=eA(Ls(e.config.preferManagedMediaSource)),this.initTracks(),this.registerListeners()}hasSourceTypes(){return Object.keys(this.tracks).length>0}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.transferData=this.overrides=void 0,this.operationQueue&&(this.operationQueue.destroy(),this.operationQueue=null),this.hls=this.fragmentTracker=null,this._onMediaSourceOpen=this._onMediaSourceClose=null,this._onMediaSourceEnded=null,this._onStartStreaming=this._onEndStreaming=null}registerListeners(){const{hls:e}=this;e.on(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_PARSED,this.onManifestParsed,this),e.on(v.BUFFER_RESET,this.onBufferReset,this),e.on(v.BUFFER_APPENDING,this.onBufferAppending,this),e.on(v.BUFFER_CODECS,this.onBufferCodecs,this),e.on(v.BUFFER_EOS,this.onBufferEos,this),e.on(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(v.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(v.FRAG_PARSED,this.onFragParsed,this),e.on(v.FRAG_CHANGED,this.onFragChanged,this),e.on(v.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;
vendor: 20,871 bytes, lines 1508-1510
1508e.off(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_PARSED,this.onManifestParsed,this),e.off(v.BUFFER_RESET,this.onBufferReset,this),e.off(v.BUFFER_APPENDING,this.onBufferAppending,this),e.off(v.BUFFER_CODECS,this.onBufferCodecs,this),e.off(v.BUFFER_EOS,this.onBufferEos,this),e.off(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(v.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(v.FRAG_PARSED,this.onFragParsed,this),e.off(v.FRAG_CHANGED,this.onFragChanged,this),e.off(v.ERROR,this.onError,this)}transferMedia(){const{media:e,mediaSource:t}=this;if(!e)return null;const i={};if(this.operationQueue){const r=this.isUpdating();r||this.operationQueue.removeBlockers();const a=this.isQueued();(r||a)&&this.warn(`Transfering MediaSource with${a?" operations in queue":""}${r?" updating SourceBuffer(s)":""} ${this.operationQueue}`),this.operationQueue.destroy()}const n=this.transferData;return!this.sourceBufferCount&&n&&n.mediaSource===t?nt(i,n.tracks):this.sourceBuffers.forEach(r=>{const[a]=r;a&&(i[a]=nt({},this.tracks[a]),this.removeBuffer(a)),r[0]=r[1]=null}),{media:e,mediaSource:t,tracks:i}}initTracks(){const e={};this.sourceBuffers=[[null,null],[null,null]],this.tracks=e,this.resetQueue(),this.resetAppendErrors(),this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.lastVideoAppendEnd=0}onManifestLoading(){this.bufferCodecEventsTotal=0,this.details=null}onManifestParsed(e,t){var i;let n=2;(t.audio&&!t.video||!t.altAudio)&&(n=1),this.bufferCodecEventsTotal=n,this.log(`${n} bufferCodec event(s) expected.`),(i=this.transferData)!=null&&i.mediaSource&&this.sourceBufferCount&&n&&this.bufferCreated()}onMediaAttaching(e,t){const i=this.media=t.media;this.transferData=this.overrides=void 0;const n=Ls(this.appendSource);if(n){const r=!!t.mediaSource;(r||t.overrides)&&(this.transferData=t,this.overrides=t.overrides);const a=this.mediaSource=t.mediaSource||new n;if(this.assignMediaSource(a),r)this._objectUrl=i.src,this.attachTransferred();else{const o=this._objectUrl=self.URL.createObjectURL(a);if(this.appendSource)try{i.removeAttribute("src");const d=self.ManagedMediaSource;i.disableRemotePlayback=i.disableRemotePlayback||d&&a instanceof d,Qf(i),Px(i,o),i.load()}catch{i.src=o}else i.src=o}i.addEventListener("emptied",this._onMediaEmptied)}}assignMediaSource(e){var t,i;this.log(`${((t=this.transferData)==null?void 0:t.mediaSource)===e?"transferred":"created"} media source: ${(i=e.constructor)==null?void 0:i.name}`),e.addEventListener("sourceopen",this._onMediaSourceOpen),e.addEventListener("sourceended",this._onMediaSourceEnded),e.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(e.addEventListener("startstreaming",this._onStartStreaming),e.addEventListener("endstreaming",this._onEndStreaming))}attachTransferred(){const e=this.media,t=this.transferData;if(!t||!e)return;const i=this.tracks,n=t.tracks,r=n?Object.keys(n):null,a=r?r.length:0,o=()=>{Promise.resolve().then(()=>{this.media&&this.mediaSourceOpenOrEnded&&this._onMediaSourceOpen()})};if(n&&r&&a){if(!this.tracksReady){this.hls.config.startFragPrefetch=!0,this.log("attachTransferred: waiting for SourceBuffer track info");return}if(this.log(`attachTransferred: (bufferCodecEventsTotal ${this.bufferCodecEventsTotal}) 1509required tracks: ${lt(i,(d,l)=>d==="initSegment"?void 0:l)}; 1510transfer tracks: ${lt(n,(d,l)=>d==="initSegment"?void 0:l)}}`),!Mp(n,i)){t.mediaSource=null,t.tracks=void 0;const d=e.currentTime,l=this.details,c=Math.max(d,l?.fragments[0].start||0);if(c-d>1){this.log(`attachTransferred: waiting for playback to reach new tracks start time ${d} -> ${c}`);return}this.warn(`attachTransferred: resetting MediaSource for incompatible tracks ("${Object.keys(n)}"->"${Object.keys(i)}") start time: ${c} currentTime: ${d}`),this.onMediaDetaching(v.MEDIA_DETACHING,{}),this.onMediaAttaching(v.MEDIA_ATTACHING,t),e.currentTime=c;return}this.transferData=void 0,r.forEach(d=>{const l=d,c=n[l];if(c){const u=c.buffer;if(u){const h=this.fragmentTracker,f=c.id;if(h.hasFragments(f)||h.hasParts(f)){const g=Me.getBuffered(u);h.detectEvictedFragments(l,g,f,null,!0)}const m=hd(l),p=[l,u];this.sourceBuffers[m]=p,u.updating&&this.operationQueue&&this.operationQueue.prependBlocker(l),this.trackSourceBuffer(l,c)}}}),o(),this.bufferCreated()}else this.log("attachTransferred: MediaSource w/o SourceBuffers"),o()}get mediaSourceOpenOrEnded(){var e;const t=(e=this.mediaSource)==null?void 0:e.readyState;return t==="open"||t==="ended"}onMediaDetaching(e,t){const i=!!t.transferMedia;this.transferData=this.overrides=void 0;const{media:n,mediaSource:r,_objectUrl:a}=this;if(r){if(this.log(`media source ${i?"transferring":"detaching"}`),i)this.sourceBuffers.forEach(([o])=>{o&&this.removeBuffer(o)}),this.resetQueue();else{if(this.mediaSourceOpenOrEnded){const o=r.readyState==="open";try{const d=r.sourceBuffers;for(let l=d.length;l--;)o&&d[l].abort(),r.removeSourceBuffer(d[l]);o&&r.endOfStream()}catch(d){this.warn(`onMediaDetaching: ${d.message} while calling endOfStream`)}}this.sourceBufferCount&&this.onBufferReset()}r.removeEventListener("sourceopen",this._onMediaSourceOpen),r.removeEventListener("sourceended",this._onMediaSourceEnded),r.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(r.removeEventListener("startstreaming",this._onStartStreaming),r.removeEventListener("endstreaming",this._onEndStreaming)),this.mediaSource=null,this._objectUrl=null}n&&(n.removeEventListener("emptied",this._onMediaEmptied),i||(a&&self.URL.revokeObjectURL(a),this.mediaSrc===a?(n.removeAttribute("src"),this.appendSource&&Qf(n),n.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.media=null),this.hls.trigger(v.MEDIA_DETACHED,t)}onBufferReset(){this.sourceBuffers.forEach(([e])=>{e&&this.resetBuffer(e)}),this.initTracks()}resetBuffer(e){var t;const i=(t=this.tracks[e])==null?void 0:t.buffer;if(this.removeBuffer(e),i)try{var n;(n=this.mediaSource)!=null&&n.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(i)}catch(r){this.warn(`onBufferReset ${e}`,r)}delete this.tracks[e]}removeBuffer(e){this.removeBufferListeners(e),this.sourceBuffers[hd(e)]=[null,null];const t=this.tracks[e];t&&(t.buffer=void 0)}resetQueue(){this.operationQueue&&this.operationQueue.destroy(),this.operationQueue=new Dx(this.tracks)}onBufferCodecs(e,t){var i;const n=this.tracks,r=Object.keys(t);this.log(`BUFFER_CODECS: "${r}" (current SB count ${this.sourceBufferCount})`);const a="audiovideo"in t&&(n.audio||n.video)||n.audiovideo&&("audio"in t||"video"in t),o=!a&&this.sourceBufferCount&&this.media&&r.some(d=>!n[d]);if(a||o){this.warn(`Unsupported transition between "${Object.keys(n)}" and "${r}" SourceBuffers`);return}r.forEach(d=>{var l,c;const u=t[d],{id:h,codec:f,levelCodec:m,container:p,metadata:g,supplemental:y}=u;let T=n[d];const _=(l=this.transferData)==null||(l=l.tracks)==null?void 0:l[d],I=_!=null&&_.buffer?_:T,R=I?.pendingCodec||I?.codec,F=I?.levelCodec;T||(T=n[d]={buffer:void 0,listeners:[],codec:f,supplemental:y,container:p,levelCodec:m,metadata:g,id:h});const L=Do(R,F),w=L?.replace(Xf,"$1");let P=Do(f,m);const k=(c=P)==null?void 0:c.replace(Xf,"$1");P&&L&&w!==k&&(d.slice(0,5)==="audio"&&(P=dl(P,this.appendSource)),this.log(`switching codec ${R} to ${P}`),P!==(T.pendingCodec||T.codec)&&(T.pendingCodec=P),T.container=p,this.appendChangeType(d,p,P))}),(this.tracksReady||this.sourceBufferCount)&&(t.tracks=this.sourceBufferTracks),!this.sourceBufferCount&&(this.bufferCodecEventsTotal>1&&!this.tracks.video&&!t.video&&((i=t.audio)==null?void 0:i.id)==="main"&&(this.log("Main audio-only"),this.bufferCodecEventsTotal=1),this.mediaSourceOpenOrEnded&&this.checkPendingTracks())}get sourceBufferTracks(){return Object.keys(this.tracks).reduce((e,t)=>{const i=this.tracks[t];return e[t]={id:i.id,container:i.container,codec:i.codec,levelCodec:i.levelCodec},e},{})}appendChangeType(e,t,i){const n=`${t};codecs=${i}`,r={label:`change-type=${n}`,execute:()=>{const a=this.tracks[e];if(a){const o=a.buffer;o!=null&&o.changeType&&(this.log(`changing ${e} sourceBuffer type to ${n}`),o.changeType(n),a.codec=i,a.container=t)}this.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:a=>{this.warn(`Failed to change ${e} SourceBuffer type`,a)}};this.append(r,e,this.isPending(this.tracks[e]))}blockAudio(e){var t;const i=e.start,n=i+e.duration*.05;if(((t=this.fragmentTracker.getAppendedFrag(i,ge.MAIN))==null?void 0:t.gap)===!0)return;const a={label:"block-audio",execute:()=>{var o;const d=this.tracks.video;(this.lastVideoAppendEnd>n||d!=null&&d.buffer&&Me.isBuffered(d.buffer,n)||((o=this.fragmentTracker.getAppendedFrag(n,ge.MAIN))==null?void 0:o.gap)===!0)&&(this.blockedAudioAppend=null,this.shiftAndExecuteNext("audio"))},onStart:()=>{},onComplete:()=>{},onError:o=>{this.warn("Error executing block-audio operation",o)}};this.blockedAudioAppend={op:a,frag:e},this.append(a,"audio",!0)}unblockAudio(){const{blockedAudioAppend:e,operationQueue:t}=this;e&&t&&(this.blockedAudioAppend=null,t.unblockAudio(e.op))}onBufferAppending(e,t){const{tracks:i}=this,{data:n,type:r,parent:a,frag:o,part:d,chunkMeta:l,offset:c}=t,u=l.buffering[r],{sn:h,cc:f}=o,m=self.performance.now();u.start=m;const p=o.stats.buffering,g=d?d.stats.buffering:null;p.start===0&&(p.start=m),g&&g.start===0&&(g.start=m);const y=i.audio;let T=!1;r==="audio"&&y?.container==="audio/mpeg"&&(T=!this.lastMpegAudioChunk||l.id===1||this.lastMpegAudioChunk.sn!==l.sn,this.lastMpegAudioChunk=l);const _=i.video,I=_?.buffer;if(I&&h!=="initSegment"){const L=d||o,w=this.blockedAudioAppend;if(r==="audio"&&a!=="main"&&!this.blockedAudioAppend&&!(_.ending||_.ended)){const k=L.start+L.duration*.05,G=I.buffered,se=this.currentOp("video");!G.length&&!se?this.blockAudio(L):!se&&!Me.isBuffered(I,k)&&this.lastVideoAppendEnd<k&&this.blockAudio(L)}else if(r==="video"){const P=L.end;if(w){const k=w.frag.start;(P>k||P<this.lastVideoAppendEnd||Me.isBuffered(I,k))&&this.unblockAudio()}this.lastVideoAppendEnd=P}}const R=(d||o).start,F={label:`append-${r}`,execute:()=>{var L;u.executeStart=self.performance.now();const w=(L=this.tracks[r])==null?void 0:L.buffer;w&&(T?this.updateTimestampOffset(w,R,.1,r,h,f):c!==void 0&&he(c)&&this.updateTimestampOffset(w,c,1e-6,r,h,f)),this.appendExecutor(n,r)},onStart:()=>{},onComplete:()=>{const L=self.performance.now();u.executeEnd=u.end=L,p.first===0&&(p.first=L),g&&g.first===0&&(g.first=L);const w={};this.sourceBuffers.forEach(([P,k])=>{P&&(w[P]=Me.getBuffered(k))}),this.appendErrors[r]=0,r==="audio"||r==="video"?this.appendErrors.audiovideo=0:(this.appendErrors.audio=0,this.appendErrors.video=0),this.hls.trigger(v.BUFFER_APPENDED,{type:r,frag:o,part:d,chunkMeta:l,parent:o.type,timeRanges:w})},onError:L=>{var w;const P={type:ye.MEDIA_ERROR,parent:o.type,details:$.BUFFER_APPEND_ERROR,sourceBufferName:r,frag:o,part:d,chunkMeta:l,error:L,err:L,fatal:!1},k=(w=this.media)==null?void 0:w.error;if(L.code===DOMException.QUOTA_EXCEEDED_ERR||L.name=="QuotaExceededError"||"quota"in L)P.details=$.BUFFER_FULL_ERROR;else if(L.code===DOMException.INVALID_STATE_ERR&&this.mediaSourceOpenOrEnded&&!k)P.errorAction=$n(!0);else if(L.name===Nv&&this.sourceBufferCount===0)P.errorAction=$n(!0);else{const G=++this.appendErrors[r];this.warn(`Failed ${G}/${this.hls.config.appendErrorMaxRetry} times to append segment in "${r}" sourceBuffer (${k||"no media error"})`),(G>=this.hls.config.appendErrorMaxRetry||k)&&(P.fatal=!0)}this.hls.trigger(v.ERROR,P)}};this.log(`queuing "${r}" append sn: ${h}${d?" p: "+d.index:""} of ${o.type===ge.MAIN?"level":"track"} ${o.level} cc: ${f}`),this.append(F,r,this.isPending(this.tracks[r]))}getFlushOp(e,t,i){return this.log(`queuing "${e}" remove ${t}-${i}`),{label:"remove",execute:()=>{this.removeExecutor(e,t,i)},onStart:()=>{},onComplete:()=>{this.hls.trigger(v.BUFFER_FLUSHED,{type:e})},onError:n=>{this.warn(`Failed to remove ${t}-${i} from "${e}" SourceBuffer`,n)}}}onBufferFlushing(e,t){const{type:i,startOffset:n,endOffset:r}=t;i?this.append(this.getFlushOp(i,n,r),i):this.sourceBuffers.forEach(([a])=>{a&&this.append(this.getFlushOp(a,n,r),a)})}onFragParsed(e,t){const{frag:i,part:n}=t,r=[],a=n?n.elementaryStreams:i.elementaryStreams;a[ot.AUDIOVIDEO]?r.push("audiovideo"):(a[ot.AUDIO]&&r.push("audio"),a[ot.VIDEO]&&r.push("video"));const o=()=>{const d=self.performance.now();i.stats.buffering.end=d,n&&(n.stats.buffering.end=d);const l=n?n.stats:i.stats;this.hls.trigger(v.FRAG_BUFFERED,{frag:i,part:n,stats:l,id:i.type})};r.length===0&&this.warn(`Fragments must have at least one ElementaryStreamType set. type: ${i.type} level: ${i.level} sn: ${i.sn}`),this.blockBuffers(o,r).catch(d=>{this.warn(`Fragment buffered callback ${d}`),this.stepOperationQueue(this.sourceBufferTypes)})}onFragChanged(e,t){this.trimBuffers()}get bufferedToEnd(){return this.sourceBufferCount>0&&!this.sourceBuffers.some(([e])=>{if(e){const t=this.tracks[e];if(t)return!t.ended||t.ending}return!1})}onBufferEos(e,t){var i;this.sourceBuffers.forEach(([a])=>{if(a){const o=this.tracks[a];(!t.type||t.type===a)&&(o.ending=!0,o.ended||(o.ended=!0,this.log(`${a} buffer reached EOS`)))}});const n=((i=this.overrides)==null?void 0:i.endOfStream)!==!1;this.sourceBufferCount>0&&!this.sourceBuffers.some(([a])=>{var o;return a&&!((o=this.tracks[a])!=null&&o.ended)})?n?(this.log("Queueing EOS"),this.blockUntilOpen(()=>{this.tracksEnded();const{mediaSource:a}=this;if(!a||a.readyState!=="open"){a&&this.log(`Could not call mediaSource.endOfStream(). mediaSource.readyState: ${a.readyState}`);return}this.log("Calling mediaSource.endOfStream()"),a.endOfStream(),this.hls.trigger(v.BUFFERED_TO_END,void 0)})):(this.tracksEnded(),this.hls.trigger(v.BUFFERED_TO_END,void 0)):t.type==="video"&&this.unblockAudio()}tracksEnded(){this.sourceBuffers.forEach(([e])=>{if(e!==null){const t=this.tracks[e];t&&(t.ending=!1)}})}onLevelUpdated(e,{details:t}){t.fragments.length&&(this.details=t,this.updateDuration())}updateDuration(){this.blockUntilOpen(()=>{const e=this.getDurationAndRange();e&&this.updateMediaSource(e)})}onError(e,t){if(t.details===$.BUFFER_APPEND_ERROR&&t.frag){var i;const n=(i=t.errorAction)==null?void 0:i.nextAutoLevel;he(n)&&n!==t.frag.level&&this.resetAppendErrors()}}resetAppendErrors(){this.appendErrors={audio:0,video:0,audiovideo:0}}trimBuffers(){const{hls:e,details:t,media:i}=this;if(!i||t===null||!this.sourceBufferCount)return;const n=e.config,r=i.currentTime,a=t.levelTargetDuration,o=t.live&&n.liveBackBufferLength!==null?n.liveBackBufferLength:n.backBufferLength;if(he(o)&&o>=0){const l=Math.max(o,a),c=Math.floor(r/a)*a-l;this.flushBackBuffer(r,a,c)}const d=n.frontBufferFlushThreshold;if(he(d)&&d>0){const l=Math.max(n.maxBufferLength,d),c=Math.max(l,a),u=Math.floor(r/a)*a+c;this.flushFrontBuffer(r,a,u)}}flushBackBuffer(e,t,i){this.sourceBuffers.forEach(([n,r])=>{if(r){const o=Me.getBuffered(r);if(o.length>0&&i>o.start(0)){var a;this.hls.trigger(v.BACK_BUFFER_REACHED,{bufferEnd:i});const d=this.tracks[n];if((a=this.details)!=null&&a.live)this.hls.trigger(v.LIVE_BACK_BUFFER_REACHED,{bufferEnd:i});else if(d!=null&&d.ended){this.log(`Cannot flush ${n} back buffer while SourceBuffer is in ended state`);return}this.hls.trigger(v.BUFFER_FLUSHING,{startOffset:0,endOffset:i,type:n})}}})}flushFrontBuffer(e,t,i){this.sourceBuffers.forEach(([n,r])=>{if(r){const a=Me.getBuffered(r),o=a.length;if(o<2)return;const d=a.start(o-1),l=a.end(o-1);if(i>d||e>=d&&e<=l)return;this.hls.trigger(v.BUFFER_FLUSHING,{startOffset:d,endOffset:1/0,type:n})}})}getDurationAndRange(){var e;const{details:t,mediaSource:i}=this;if(!t||!this.media||i?.readyState!=="open")return null;const n=t.edge;if(t.live&&this.hls.config.liveDurationInfinity){if(t.fragments.length&&i.setLiveSeekableRange){const l=Math.max(0,t.fragmentStart),c=Math.max(l,n);return{duration:1/0,start:l,end:c}}return{duration:1/0}}const r=(e=this.overrides)==null?void 0:e.duration;if(r)return he(r)?{duration:r}:null;const a=this.media.duration,o=he(i.duration)?i.duration:0;return n>o&&n>a||!he(a)?{duration:n}:null}updateMediaSource({duration:e,start:t,end:i}){const n=this.mediaSource;!this.media||!n||n.readyState!=="open"||(n.duration!==e&&(he(e)&&this.log(`Updating MediaSource duration to ${e.toFixed(3)}`),n.duration=e),t!==void 0&&i!==void 0&&(this.log(`MediaSource duration is set to ${n.duration}. Setting seekable range to ${t}-${i}.`),n.setLiveSeekableRange(t,i)))}get tracksReady(){const e=this.pendingTrackCount;return e>0&&(e>=this.bufferCodecEventsTotal||this.isPending(this.tracks.audiovideo))}checkPendingTracks(){const{bufferCodecEventsTotal:e,pendingTrackCount:t,tracks:i}=this;if(this.log(`checkPendingTracks (pending: ${t} codec events expected: ${e}) ${lt(i)}`),this.tracksReady){var n;const r=(n=this.transferData)==null?void 0:n.tracks;r&&Object.keys(r).length?this.attachTransferred():this.createSourceBuffers()}}bufferCreated(){if(this.sourceBufferCount){const e={};this.sourceBuffers.forEach(([t,i])=>{if(t){const n=this.tracks[t];e[t]={buffer:i,container:n.container,codec:n.codec,supplemental:n.supplemental,levelCodec:n.levelCodec,id:n.id,metadata:n.metadata}}}),this.hls.trigger(v.BUFFER_CREATED,{tracks:e}),this.log(`SourceBuffers created. Running queue: ${this.operationQueue}`),this.sourceBuffers.forEach(([t])=>{this.executeNext(t)})}else{const e=new Error("could not create source buffer for media codec(s)");this.hls.trigger(v.ERROR,{type:ye.MEDIA_ERROR,details:$.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:e,reason:e.message})}}createSourceBuffers(){const{tracks:e,sourceBuffers:t,mediaSource:i}=this;if(!i)throw new Error("createSourceBuffers called when mediaSource was null");for(const r in e){const a=r,o=e[a];if(this.isPending(o)){const d=this.getTrackCodec(o,a),l=`${o.container};codecs=${d}`;o.codec=d,this.log(`creating sourceBuffer(${l})${this.currentOp(a)?" Queued":""} ${lt(o)}`);try{const c=i.addSourceBuffer(l),u=hd(a),h=[a,c];t[u]=h,o.buffer=c}catch(c){var n;this.error(`error while trying to add sourceBuffer: ${c.message}`),this.shiftAndExecuteNext(a),(n=this.operationQueue)==null||n.removeBlockers(),delete this.tracks[a],this.hls.trigger(v.ERROR,{type:ye.MEDIA_ERROR,details:$.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:c,sourceBufferName:a,mimeType:l,parent:o.id});return}this.trackSourceBuffer(a,o)}}this.bufferCreated()}getTrackCodec(e,t){const i=e.supplemental;let n=e.codec;i&&(t==="video"||t==="audiovideo")&&Kr(i,"video")&&(n=_A(n,i));const r=Do(n,e.levelCodec);return r?t.slice(0,5)==="audio"?dl(r,this.appendSource):r:""}trackSourceBuffer(e,t){const i=t.buffer;if(!i)return;const n=this.getTrackCodec(t,e);this.tracks[e]={buffer:i,codec:n,container:t.container,levelCodec:t.levelCodec,supplemental:t.supplemental,metadata:t.metadata,id:t.id,listeners:[]},this.removeBufferListeners(e),this.addBufferListener(e,"updatestart",this.onSBUpdateStart),this.addBufferListener(e,"updateend",this.onSBUpdateEnd),this.addBufferListener(e,"error",this.onSBUpdateError),this.appendSource&&this.addBufferListener(e,"bufferedchange",(r,a)=>{const o=a.removedRanges;o!=null&&o.length&&this.hls.trigger(v.BUFFER_FLUSHED,{type:r})})}get mediaSrc(){var e,t;const i=((e=this.media)==null||(t=e.querySelector)==null?void 0:t.call(e,"source"))||this.media;return i?.src}onSBUpdateStart(e){const t=this.currentOp(e);t&&t.onStart()}onSBUpdateEnd(e){var t;if(((t=this.mediaSource)==null?void 0:t.readyState)==="closed"){this.resetBuffer(e);return}const i=this.currentOp(e);i&&(i.onComplete(),this.shiftAndExecuteNext(e))}onSBUpdateError(e,t){var i;const n=new Error(`${e} SourceBuffer error. MediaSource readyState: ${(i=this.mediaSource)==null?void 0:i.readyState}`);this.error(`${n}`,t),this.hls.trigger(v.ERROR,{type:ye.MEDIA_ERROR,details:$.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:n,fatal:!1});const r=this.currentOp(e);r&&r.onError(n)}updateTimestampOffset(e,t,i,n,r,a){const o=t-e.timestampOffset;Math.abs(o)>=i&&(this.log(`Updating ${n} SourceBuffer timestampOffset to ${t} (sn: ${r} cc: ${a})`),e.timestampOffset=t)}removeExecutor(e,t,i){const{media:n,mediaSource:r}=this,a=this.tracks[e],o=a?.buffer;if(!n||!r||!o){this.warn(`Attempting to remove from the ${e} SourceBuffer, but it does not exist`),this.shiftAndExecuteNext(e);return}const d=he(n.duration)?n.duration:1/0,l=he(r.duration)?r.duration:1/0,c=Math.max(0,t),u=Math.min(i,d,l);u>c&&(!a.ending||a.ended)?(a.ended=!1,this.log(`Removing [${c},${u}] from the ${e} SourceBuffer`),o.remove(c,u)):this.shiftAndExecuteNext(e)}appendExecutor(e,t){const i=this.tracks[t],n=i?.buffer;if(!n)throw new Cx(`Attempting to append to the ${t} SourceBuffer, but it does not exist`);i.ending=!1,i.ended=!1,n.appendBuffer(e)}blockUntilOpen(e){if(this.isUpdating()||this.isQueued())this.blockBuffers(e).catch(t=>{this.warn(`SourceBuffer blocked callback ${t}
1510`),this.stepOperationQueue(this.sourceBufferTypes)});else try{e()}catch(t){this.warn(`Callback run without blocking ${this.operationQueue} ${t}`)}}isUpdating(){return this.sourceBuffers.some(([e,t])=>e&&t.updating)}isQueued(){return this.sourceBuffers.some(([e])=>e&&!!this.currentOp(e))}isPending(e){return!!e&&!e.buffer}blockBuffers(e,t=this.sourceBufferTypes){if(!t.length)return this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);const{operationQueue:i}=this,n=t.map(a=>this.appendBlocker(a));return t.length>1&&this.blockedAudioAppend&&this.unblockAudio(),Promise.all(n).then(a=>{i===this.operationQueue&&(e(),this.stepOperationQueue(this.sourceBufferTypes))})}stepOperationQueue(e){e.forEach(t=>{var i;const n=(i=this.tracks[t])==null?void 0:i.buffer;!n||n.updating||this.shiftAndExecuteNext(t)})}append(e,t,i){this.operationQueue&&this.operationQueue.append(e,t,i)}appendBlocker(e){if(this.operationQueue)return this.operationQueue.appendBlocker(e)}currentOp(e){return this.operationQueue?this.operationQueue.current(e):null}executeNext(e){e&&this.operationQueue&&this.operationQueue.executeNext(e)}shiftAndExecuteNext(e){this.operationQueue&&this.operationQueue.shiftAndExecuteNext(e)}get pendingTrackCount(){return Object.keys(this.tracks).reduce((e,t)=>e+(this.isPending(this.tracks[t])?1:0),0)}get sourceBufferCount(){return this.sourceBuffers.reduce((e,[t])=>e+(t?1:0),0)}get sourceBufferTypes(){return this.sourceBuffers.map(([e])=>e).filter(e=>!!e)}addBufferListener(e,t,i){const n=this.tracks[e];if(!n)return;const r=n.buffer;if(!r)return;const a=i.bind(this,e);n.listeners.push({event:t,listener:a}),r.addEventListener(t,a)}removeBufferListeners(e){const t=this.tracks[e];if(!t)return;const i=t.buffer;i&&(t.listeners.forEach(n=>{i.removeEventListener(n.event,n.listener)}),t.listeners.length=0)}}function Qf(s){const e=s.querySelectorAll("source");[].slice.call(e).forEach(t=>{s.removeChild(t)})}function Px(s,e){const t=self.document.createElement("source");t.type="video/mp4",t.src=e,s.appendChild(t)}function hd(s){return s==="audio"?1:0}class qu{constructor(e){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=e,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}setStreamController(e){this.streamController=e}destroy(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){const{hls:e}=this;e.on(v.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(v.MEDIA_ATTA
vendor: 3,502 bytes, line 1510
1510CHING,this.onMediaAttaching,this),e.on(v.MANIFEST_PARSED,this.onManifestParsed,this),e.on(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(v.BUFFER_CODECS,this.onBufferCodecs,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:e}=this;e.off(v.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(v.MANIFEST_PARSED,this.onManifestParsed,this),e.off(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(v.BUFFER_CODECS,this.onBufferCodecs,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(e,t){const i=this.hls.levels[t.droppedLevel];this.isLevelAllowed(i)&&this.restrictedLevels.push({bitrate:i.bitrate,height:i.height,width:i.width})}onMediaAttaching(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()}onManifestParsed(e,t){const i=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,i.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onLevelsUpdated(e,t){this.timer&&he(this.autoLevelCapping)&&this.detectPlayerSize()}onBufferCodecs(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onMediaDetaching(){this.stopCapping(),this.media=null}detectPlayerSize(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0){this.clientRect=null;return}const e=this.hls.levels;if(e.length){const t=this.hls,i=this.getMaxLevel(e.length-1);i!==this.autoLevelCapping&&t.logger.log(`Setting autoLevelCapping to ${i}: ${e[i].height}p@${e[i].bitrate} for media ${this.mediaWidth}x${this.mediaHeight}`),t.autoLevelCapping=i,t.autoLevelEnabled&&t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}}getMaxLevel(e){const t=this.hls.levels;if(!t.length)return-1;const i=t.filter((n,r)=>this.isLevelAllowed(n)&&r<=e);return this.clientRect=null,qu.getMaxLevelByMediaSize(i,this.mediaWidth,this.mediaHeight)}startCapping(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())}stopCapping(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)}getDimensions(){if(this.clientRect)return this.clientRect;const e=this.media,t={width:0,height:0};if(e){const i=e.getBoundingClientRect();t.width=i.width,t.height=i.height,!t.width&&!t.height&&(t.width=i.right-i.left||e.width||0,t.height=i.bottom-i.top||e.height||0)}return this.clientRect=t,t}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch{}return Math.min(e,this.hls.config.maxDevicePixelRatio)}isLevelAllowed(e){return!this.restrictedLevels.some(i=>e.bitrate===i.bitrate&&e.width===i.width&&e.height===i.height)}static getMaxLevelByMediaSize(e,t,i){if(!(e!=null&&e.length))return-1;const n=(o,d)=>d?o.width!==d.width||o.height!==d.height:!0;let r=e.length-1;const a=Math.max(t,i);for(let o=0;o<e.length;o+=1){const d=e[o];if((d.width>=a||d.height>=a)&&n(d,e[o+1])){r=o;break}}return r}}const Mx={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",
vendor: 4,255 bytes, line 1510
1510KEY:"k",OTHER:"o"},Zt=Mx,Ox={HLS:"h"},Fx=Ox;class zi{constructor(e,t){Array.isArray(e)&&(e=e.map(i=>i instanceof zi?i:new zi(i))),this.value=e,this.params=t}}const $x="Dict";function Nx(s){return Array.isArray(s)?JSON.stringify(s):s instanceof Map?"Map{}":s instanceof Set?"Set{}":typeof s=="object"?JSON.stringify(s):String(s)}function Ux(s,e,t,i){return new Error(`failed to ${s} "${Nx(e)}" as ${t}`,{cause:i})}function ji(s,e,t){return Ux("serialize",s,e,t)}class Uv{constructor(e){this.description=e}}const Zf="Bare Item",Bx="Boolean";function Gx(s){if(typeof s!="boolean")throw ji(s,Bx);return s?"?1":"?0"}function Kx(s){return btoa(String.fromCharCode(...s))}const Hx="Byte Sequence";function Vx(s){if(ArrayBuffer.isView(s)===!1)throw ji(s,Hx);return`:${Kx(s)}:`}const Wx="Integer";function qx(s){return s<-999999999999999||999999999999999<s}function Bv(s){if(qx(s))throw ji(s,Wx);return s.toString()}function Yx(s){return`@${Bv(s.getTime()/1e3)}`}function Gv(s,e){if(s<0)return-Gv(-s,e);const t=Math.pow(10,e);if(Math.abs(s*t%1-.5)<Number.EPSILON){const n=Math.floor(s*t);return(n%2===0?n:n+1)/t}else return Math.round(s*t)/t}const zx="Decimal";function jx(s){const e=Gv(s,3);if(Math.floor(Math.abs(e)).toString().length>12)throw ji(s,zx);const t=e.toString();return t.includes(".")?t:`${t}.0`}const Xx="String",Qx=/[\x00-\x1f\x7f]+/;function Zx(s){if(Qx.test(s))throw ji(s,Xx);return`"${s.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function Jx(s){return s.description||s.toString().slice(7,-1)}const eL="Token";function Jf(s){const e=Jx(s);if(/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(e)===!1)throw ji(e,eL);return e}function Gc(s){switch(typeof s){case"number":if(!he(s))throw ji(s,Zf);return Number.isInteger(s)?Bv(s):jx(s);case"string":return Zx(s);case"symbol":return Jf(s);case"boolean":return Gx(s);case"object":if(s instanceof Date)return Yx(s);if(s instanceof Uint8Array)return Vx(s);if(s instanceof Uv)return Jf(s);default:throw ji(s,Zf)}}const tL="Key";function Kc(s){if(/^[a-z*][a-z0-9\-_.*]*$/.test(s)===!1)throw ji(s,tL);return s}function Yu(s){return s==null?"":Object.entries(s).map(([e,t])=>t===!0?`;${Kc(e)}`:`;${Kc(e)}=${Gc(t)}`).join("")}function Kv(s){return s instanceof zi?`${Gc(s.value)}${Yu(s.params)}`:Gc(s)}function iL(s){return`(${s.value.map(Kv).join(" ")})${Yu(s.params)}`}function sL(s,e={whitespace:!0}){if(typeof s!="object"||s==null)throw ji(s,$x);const t=s instanceof Map?s.entries():Object.entries(s),i=e?.whitespace?" ":"";return Array.from(t).map(([n,r])=>{r instanceof zi||(r=new zi(r));let a=Kc(n);return r.value===!0?a+=Yu(r.params):(a+="=",Array.isArray(r.value)?a+=iL(r):a+=Kv(r)),a}).join(`,${i}`)}function Hv(s,e){return sL(s,e)}const ki="CMCD-Object",Et="CMCD-Request",$s="CMCD-Session",vs="CMCD-Status",nL={br:ki,ab:ki,d:ki,ot:ki,tb:ki,tpb:ki,lb:ki,tab:ki,lab:ki,url:ki,pb:Et,bl:Et,tbl:Et,dl:Et,ltc:Et,mtp:Et,nor:Et,nrr:Et,rc:Et,sn:Et,sta:Et,su:Et,ttfb:Et,ttfbb:Et,ttlb:Et,cmsdd:Et,cmsds:Et,smrt:Et,df:Et,cs:Et,ts:Et,cid:$s,pr:$s,sf:$s,sid:$s,st:$s,v:$s,msd:$s,bs:vs,bsd:vs,cdn:vs,rtp:vs,bg:vs,pt:vs,ec:vs,e:vs},rL={REQUEST:Et};function aL(s){return Object.keys(s).reduce((e,t)=>{var i;return(i=s[t])===null||i===void 0||i.forEach(n=>e[n]=t),e},{})}function oL(s,e){const t={};if(!s)return t;const i=Object.keys(s),n=e?aL(e):{};return i.reduce((r,a)=>{var o;const d=nL[a]||n[a]||rL.REQUEST,l=(o=r[d])!==null&&o!==void 0?o:r[d]={};return l[a]=s[a],r},t)}function lL(s){return["ot","sf","st","e","sta"].includes(s)}function dL(s){return typeof s=="number"?he(s):s!=null&&s!==""&&s!==!1}const Vv="event";function cL(s,e){const t=new URL(s),i=new URL(e);if(t.origin!==i.origin)return s;const n=t.pathname.split("/").slice(1),r=i.pathname.split("/").slice(1,-1);for(;n[0]===r[0];)n.shift(),r.shift();for(;r.length;)r.shift(),n.unshift("..");return n.join("/")+t.search+t.hash}const Oo=s=>Math.round(s),Hc=(s,e)=>Array.isArray(s)?s.map(t=>Hc(t,e)):s instanceof zi&&typeof s.value=="string"?new zi(Hc(s.value,e),s.params):(e.baseUrl&&(s=cL(s,e.baseUrl)),e.version===1?encodeURIComponent(s):s),Oa=s=>Oo(s/100)*100,uL=(s,e)=>{let t=s;return e.version>=2&&(s instanceof zi&&typeof s.value=="string"?t=new zi([s]):typeof s=="string"&&(t=[s])),Hc(t,e)},hL={br:Oo,d:Oo,bl:Oa,dl:Oa,mtp:Oa,nor:uL,rtp:Oa,tb:Oo}
1510,Wv="request",qv="response",zu=["ab","bg","bl","br","bs","bsd","cdn","cid","cs","df","ec","lab","lb","ltc","msd","mtp","pb","pr","pt","sf","sid","sn","st","sta","tab","tb","tbl","tpb","ts","v"],fL=["e"],mL=/^[a-zA-Z0-9-.]+-[a-zA-Z0-9-.]+$/;function Pl(s){return mL.test(s)}function gL(s){return zu.includes(s)||fL.includes(s)||Pl(s)}const Yv=["d","dl","nor","ot","rtp","su"];function pL(s){return zu.includes(s)||Yv.includes(s)||Pl(s)}const vL=["cmsdd","cmsds","rc","smrt","ttfb","ttfbb","ttlb","url"];function EL(s){return zu.includes(s)||Yv.includes(s)||vL.includes(s)||Pl(s)}const yL=["bl","br","bs","cid","d","dl","mtp","nor","nrr","ot","pr","rtp","sf","sid","st","su","tb","v"];function TL(s){return yL.includes(s)||Pl(s)}const bL={[qv]:EL,[Vv]:gL,[Wv]:pL};function zv(s,e={}){const t={};if(s==null||typeof s!="object")return t;const i=e.version||s.v||1,n=e.reportingMode||Wv,r=i===1?TL:bL[n];let a=Object.keys(s).filter(r);const o=e.filter;typeof o=="function"&&(a=a.filter(o));const d=n===qv||n===Vv;d&&!a.includes("ts")&&a.push("ts"),i>1&&!a.includes("v")&&a.push("v");const l=nt({},hL,e.formatters),c={version:i,reportingMode:n,baseUrl:e.baseUrl};return a.sort().forEach(u=>{let h=s[u];const f=l[u];if(typeof f=="function"&&(h=f(h,c)),u==="v"){if(i===1)return;h=i}u=="pr"&&h===1||(d&&u==="ts"&&!he(h)&&(h=Date.now()),dL(h)&&(lL(u)&&typeof h=="string"&&(h=new Uv(h)),t[u]=h))}),t}function _L(s,e={}){const t={};if(!s)return t;const i=zv(s,e),n=oL(i,e?.customHeaderMap);return Object.entries(n).reduce((r,[a,o])=>{const d=Hv(o,{whitespace:!1});return d&&(r[a]=d),r},t)}function SL(s,e,t){return nt(s,_L(e,t))}const AL="CMCD";function IL(s,e={}){return s?Hv(zv(s,e),{whitespace:!1}):""}function xL(s,e={}){if(!s)return"";const t=IL(s,e);return encodeURIComponent(t)}function LL(s,e={}){if(!s)return"";const t=xL(s,e);return`${AL}=${t}`}const em=/CMCD=[^&#]+/;function RL(s,e,t){const i=LL(e,t);if(!i)return s;if(em.test(s))return s.replace(em,i);const n=s.includes("?")?"&":"?";return`${s}${n}${i}`}class kL{constructor(e){this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.includeKeys=void 0,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=!0),this.buffering=!0},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1},this.applyPlaylistData=n=>{try{this.apply(n,{ot:Zt.MANIFEST,su:!this.initialized})}catch(r){this.hls.logger.warn("Could not generate manifest CMCD data.",r)}},this.applyFragmentData=n=>{try{const{frag:r,part:a}=n,o=this.hls.levels[r.level],d=this.getObjectType(r),l={d:(a||r).duration*1e3,ot:d};(d===Zt.VIDEO||d===Zt.AUDIO||d==Zt.MUXED)&&(l.br=o.bitrate/1e3,l.tb=this.getTopBandwidth(d)/1e3,l.bl=this.getBufferLength(d));const c=a?this.getNextPart(a):this.getNextFrag(r);c!=null&&c.url&&c.url!==r.url&&(l.nor=c.url),this.apply(n,l)}catch(r){this.hls.logger.warn("Could not generate segment CMCD data.",r)}},this.hls=e;const t=this.config=e.config,{cmcd:i}=t;i!=null&&(t.pLoader=this.createPlaylistLoader(),t.fLoader=this.createFragmentLoader(),this.sid=i.sessionId||e.sessionId,this.cid=i.contentId,this.useHeaders=i.useHeaders===!0,this.includeKeys=i.includeKeys,this.registerListeners())}registerListeners(){const e=this.hls;
1510e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHED,this.onMediaDetached,this),e.on(v.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const e=this.hls;e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHED,this.onMediaDetached,this),e.off(v.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null,this.onWaiting=this.onPlaying=this.media=null}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}onMediaDetached(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}onBufferCreated(e,t){var i,n;this.audioBuffer=(i=t.tracks.audio)==null?void 0:i.buffer,this.videoBuffer=(n=t.tracks.video)==null?void 0:n.buffer}createData(){var e;return{v:1,sf:Fx.HLS,sid:this.sid,cid:this.cid,pr:(e=this.media)==null?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){nt(t,this.createData());const i=t.ot===Zt.INIT||t.ot===Zt.VIDEO||t.ot===Zt.MUXED;this.starved&&i&&(t.bs=!0,t.su=!0,this.starved=!1),t.su==null&&(t.su=this.buffering);const{includeKeys:n}=this;n&&(t=Object.keys(t).reduce((a,o)=>(n.includes(o)&&(a[o]=t[o]),a),{}));const r={baseUrl:e.url};this.useHeaders?(e.headers||(e.headers={}),SL(e.headers,t,r)):e.url=RL(e.url,t,r)}getNextFrag(e){var t;const i=(t=this.hls.levels[e.level])==null?void 0:t.details;if(i){const n=e.sn-i.startSN;return i.fragments[n+1]}}getNextPart(e){var t;const{index:i,fragment:n}=e,r=(t=this.hls.levels[n.level])==null||(t=t.details)==null?void 0:t.partList;if(r){const{sn:a}=n;for(let o=r.length-1;o>=0;o--){const d=r[o];if(d.index===i&&d.fragment.sn===a)return r[o+1]}}}getObjectType(e){const{type:t}=e;if(t==="subtitle")return Zt.TIMED_TEXT;if(e.sn==="initSegment")return Zt.INIT;if(t==="audio")return Zt.AUDIO;if(t==="main")return this.hls.audioTracks.length?Zt.VIDEO:Zt.MUXED}getTopBandwidth(e){let t=0,i;const n=this.hls;if(e===Zt.AUDIO)i=n.audioTracks;else{const r=n.maxAutoLevel,a=r>-1?r+1:n.levels.length;i=n.levels.slice(0,a)}return i.forEach(r=>{r.bitrate>t&&(t=r.bitrate)}),t>0?t:NaN}getBufferLength(e){const t=this.media,i=e===Zt.AUDIO?this.audioBuffer:this.videoBuffer;return!i||!t?NaN:Me.bufferInfo(i,t.currentTime,this.config.maxBufferHole).len*1e3}createPlaylistLoader(){const{pLoader:e}=this.config,t=this.applyPlaylistData,i=e||this.config.loader;return class{constructor(r){this.loader=void 0,this.loader=new i(r)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(r,a,o){t(r),this.loader.load(r,a,o)}}}createFragmentLoader(){const{fLoader:e}=this.config,t=this.applyFragmentData,i=e||this.config.loader;return class{constructor(r){this.loader=void 0,this.loader=new i(r)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(r,a,o){t(r),this.loader.load(r,a,o)}}}}const DL=3e5;class CL extends pi{constructor(e){super("content-steering",e.logger),this.hls=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this._pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=e,this.registerListeners()}registerListeners(){const e=this.hls;e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(v.MANIFEST_PARSED,this.onManifestParsed,this),e.on(v.ERROR,this.onError,this)}unregisterListeners(){const e=this.hls;e&&(e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(v.MANIFEST_PARSED,this.onManifestParsed,this),e.off(v.ERROR,this.onError,this))}pathways(){return(this.levels||[]).reduce((e,t)=>(e.indexOf(t.pathwayId)===-1&&e.push(t.pathwayId),e),[])}get pathwayPriority(){return this._pathwayPriority}set pathwayPriority(e){this.updatePathwayPriority(e)}
1510startLoad(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){const e=this.timeToLoad*1e3-(performance.now()-this.updated);if(e>0){this.scheduleRefresh(this.uri,e);return}}this.loadSteeringManifest(this.uri)}}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()}clearTimeout(){this.reloadTimer!==-1&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(e){const t=this.levels;t&&(this.levels=t.filter(i=>i!==e))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(e,t){const{contentSteering:i}=t;i!==null&&(this.pathwayId=i.pathwayId,this.uri=i.uri,this.started&&this.startLoad())}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}onError(e,t){const{errorAction:i}=t;if(i?.action===Ut.SendAlternateToPenaltyBox&&i.flags===ri.MoveAllAlternatesMatchingHost){const n=this.levels;let r=this._pathwayPriority,a=this.pathwayId;if(t.context){const{groupId:o,pathwayId:d,type:l}=t.context;o&&n?a=this.getPathwayForGroupId(o,l,a):d&&(a=d)}a in this.penalizedPathways||(this.penalizedPathways[a]=performance.now()),!r&&n&&(r=this.pathways()),r&&r.length>1&&(this.updatePathwayPriority(r),i.resolved=this.pathwayId!==a),t.details===$.BUFFER_APPEND_ERROR&&!t.fatal?i.resolved=!0:i.resolved||this.warn(`Could not resolve ${t.details} ("${t.error.message}") with content-steering for Pathway: ${a} levels: ${n&&n.length} priorities: ${lt(r)} penalized: ${lt(this.penalizedPathways)}`)}}filterParsedLevels(e){this.levels=e;let t=this.getLevelsForPathway(this.pathwayId);if(t.length===0){const i=e[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${i}"`),t=this.getLevelsForPathway(i),this.pathwayId=i}return t.length!==e.length&&this.log(`Found ${t.length}/${e.length} levels in Pathway "${this.pathwayId}"`),t}getLevelsForPathway(e){return this.levels===null?[]:this.levels.filter(t=>e===t.pathwayId)}updatePathwayPriority(e){this._pathwayPriority=e;let t;const i=this.penalizedPathways,n=performance.now();
vendor: 4,346 bytes, line 1510
1510Object.keys(i).forEach(r=>{n-i[r]>DL&&delete i[r]});for(let r=0;r<e.length;r++){const a=e[r];if(a in i)continue;if(a===this.pathwayId)return;const o=this.hls.nextLoadLevel,d=this.hls.levels[o];if(t=this.getLevelsForPathway(a),t.length>0){this.log(`Setting Pathway to "${a}"`),this.pathwayId=a,mv(t),this.hls.trigger(v.LEVELS_UPDATED,{levels:t});const l=this.hls.levels[o];d&&l&&this.levels&&(l.attrs["STABLE-VARIANT-ID"]!==d.attrs["STABLE-VARIANT-ID"]&&l.bitrate!==d.bitrate&&this.log(`Unstable Pathways change from bitrate ${d.bitrate} to ${l.bitrate}`),this.hls.nextLoadLevel=o);break}}}getPathwayForGroupId(e,t,i){const n=this.getLevelsForPathway(i).concat(this.levels||[]);for(let r=0;r<n.length;r++)if(t===Ge.AUDIO_TRACK&&n[r].hasAudioGroup(e)||t===Ge.SUBTITLE_TRACK&&n[r].hasSubtitleGroup(e))return n[r].pathwayId;return i}clonePathways(e){const t=this.levels;if(!t)return;const i={},n={};e.forEach(r=>{const{ID:a,"BASE-ID":o,"URI-REPLACEMENT":d}=r;if(t.some(c=>c.pathwayId===a))return;const l=this.getLevelsForPathway(o).map(c=>{const u=new mt(c.attrs);u["PATHWAY-ID"]=a;const h=u.AUDIO&&`${u.AUDIO}_clone_${a}`,f=u.SUBTITLES&&`${u.SUBTITLES}_clone_${a}`;h&&(i[u.AUDIO]=h,u.AUDIO=h),f&&(n[u.SUBTITLES]=f,u.SUBTITLES=f);const m=jv(c.uri,u["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",d),p=new Vr({attrs:u,audioCodec:c.audioCodec,bitrate:c.bitrate,height:c.height,name:c.name,url:m,videoCodec:c.videoCodec,width:c.width});if(c.audioGroups)for(let g=1;g<c.audioGroups.length;g++)p.addGroupId("audio",`${c.audioGroups[g]}_clone_${a}`);if(c.subtitleGroups)for(let g=1;g<c.subtitleGroups.length;g++)p.addGroupId("text",`${c.subtitleGroups[g]}_clone_${a}`);return p});t.push(...l),tm(this.audioTracks,i,d,a),tm(this.subtitleTracks,n,d,a)})}loadSteeringManifest(e){const t=this.hls.config,i=t.loader;this.loader&&this.loader.destroy(),this.loader=new i(t);let n;try{n=new self.URL(e)}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest URI: ${e}`);return}if(n.protocol!=="data:"){const c=(this.hls.bandwidthEstimate||t.abrEwmaDefaultEstimate)|0;n.searchParams.set("_HLS_pathway",this.pathwayId),n.searchParams.set("_HLS_throughput",""+c)}const r={responseType:"json",url:n.href},a=t.steeringManifestLoadPolicy.default,o=a.errorRetry||a.timeoutRetry||{},d={loadPolicy:a,timeout:a.maxLoadTimeMs,maxRetry:o.maxNumRetry||0,retryDelay:o.retryDelayMs||0,maxRetryDelay:o.maxRetryDelayMs||0},l={onSuccess:(c,u,h,f)=>{this.log(`Loaded steering manifest: "${n}"`);const m=c.data;if(m?.VERSION!==1){this.log(`Steering VERSION ${m.VERSION} not supported!`);return}this.updated=performance.now(),this.timeToLoad=m.TTL;const{"RELOAD-URI":p,"PATHWAY-CLONES":g,"PATHWAY-PRIORITY":y}=m;if(p)try{this.uri=new self.URL(p,n).href}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${p}`);return}this.scheduleRefresh(this.uri||h.url),g&&this.clonePathways(g);const T={steeringManifest:m,url:n.toString()};this.hls.trigger(v.STEERING_MANIFEST_LOADED,T),y&&this.updatePathwayPriority(y)},onError:(c,u,h,f)=>{if(this.log(`Error loading steering manifest: ${c.code} ${c.text} (${u.url})`),this.stopLoad(),c.code===410){this.enabled=!1,this.log(`Steering manifest ${u.url} no longer available`);return}let m=this.timeToLoad*1e3;if(c.code===429){const p=this.loader;if(typeof p?.getResponseHeader=="function"){const g=p.getResponseHeader("Retry-After");g&&(m=parseFloat(g)*1e3)}this.log(`Steering manifest ${u.url} rate limited`);return}this.scheduleRefresh(this.uri||u.url,m)},onTimeout:(c,u,h)=>{this.log(`Timeout loading steering manifest (${u.url})`),this.scheduleRefresh(this.uri||u.url)}};this.log(`Requesting steering manifest: ${n}`),this.loader.load(r,d,l)}scheduleRefresh(e,t=this.timeToLoad*1e3){this.clearTimeout(),this.reloadTimer=self.setTimeout(()=>{var i;const n=(i=this.hls)==null?void 0:i.media;if(n&&!n.ended){this.loadSteeringManifest(e);return}this.scheduleRefresh(e,this.timeToLoad*1e3)},t)}}function tm(s,e,t,i){s&&Object.keys(e).forEach(n=>{const r=s.filter(a=>a.groupId===n).map(a=>{const o=nt({},a);return o.details=void 0,o.attrs=new mt(o.attrs),o.url=o.attrs.URI=jv(a.url,a.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",t),o.groupId=o.attrs["GROUP-ID"]=e[n],o.attrs["PATHWAY-ID"]=i,o});s.push(...r)})}function jv(s,e,t,i){const{HOST:n,PARAMS:r,[t]:a}=i;let o;e&&(o=a?.[e],o&&(s=o));const d=new self.URL(s);
1510return n&&!o&&(d.host=n),r&&Object.keys(r).sort().forEach(l=>{l&&d.searchParams.set(l,r[l])}),d.href}class Un extends pi{constructor(e){super("eme",e.logger),this.hls=void 0,this.config=void 0,this.media=null,this.mediaResolved=void 0,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.mediaKeys=null,this.setMediaKeysQueue=Un.CDMCleanupPromise?[Un.CDMCleanupPromise]:[],this.bannedKeyIds={},this.onMediaEncrypted=t=>{const{initDataType:i,initData:n}=t,r=`"${t.type}" event: init data type: "${i}"`;if(this.debug(r),n!==null){if(!this.keyFormatPromise){let a=Object.keys(this.keySystemAccessPromises);a.length||(a=Tr(this.config));const o=a.map(nd).filter(d=>!!d);this.keyFormatPromise=this.getKeyFormatPromise(o)}this.keyFormatPromise.then(a=>{const o=wo(a);if(i!=="sinf"||o!==gt.FAIRPLAY){this.log(`Ignoring "${t.type}" event with init data type: "${i}" for selected key-system ${o}`);return}let d;try{const f=It(new Uint8Array(n)),m=Fu(JSON.parse(f).sinf),p=Hp(m);if(!p)throw new Error("'schm' box missing or not cbcs/cenc with schi > tenc");d=new Uint8Array(p.subarray(8,24))}catch(f){this.warn(`${r} Failed to parse sinf: ${f}`);return}const l=Bt(d),{keyIdToKeySessionPromise:c,mediaKeySessions:u}=this;let h=c[l];for(let f=0;f<u.length;f++){const m=u[f],p=m.decryptdata;if(!p.keyId)continue;const g=Bt(p.keyId);if(ml(d,p.keyId)||p.uri.replace(/-/g,"").indexOf(l)!==-1){if(h=c[g],!h)continue;if(p.pssh)break;delete c[g],p.pssh=new Uint8Array(n),p.keyId=d,h=c[l]=h.then(()=>this.generateRequestWithPreferredKeySession(m,i,n,"encrypted-event-key-match")),h.catch(y=>this.handleError(y));break}}h||this.handleError(new Error(`Key ID ${l} not encountered in playlist. Key-system sessions ${u.length}.`))}).catch(a=>this.handleError(a))}},this.onWaitingForKey=t=>{this.log(`"${t.type}" event`)},this.hls=e,this.config=e.config,this.registerListeners()}destroy(){this.onDestroying(),this.onMediaDetached();const e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.config=this.keyIdToKeySessionPromise=null,this.onMediaEncrypted=this.onWaitingForKey=null}
1510registerListeners(){this.hls.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(v.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(v.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(v.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.on(v.DESTROYING,this.onDestroying,this)}unregisterListeners(){this.hls.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(v.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(v.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(v.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.off(v.DESTROYING,this.onDestroying,this)}getLicenseServerUrl(e){const{drmSystems:t,widevineLicenseUrl:i}=this.config,n=t?.[e];if(n)return n.licenseUrl;if(e===gt.WIDEVINE&&i)return i}getLicenseServerUrlOrThrow(e){const t=this.getLicenseServerUrl(e);if(t===void 0)throw new Error(`no license server URL configured for key-system "${e}"`);return t}getServerCertificateUrl(e){const{drmSystems:t}=this.config,i=t?.[e];if(i)return i.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${e}"]`)}attemptKeySystemAccess(e){const t=this.hls.levels,i=(a,o,d)=>!!a&&d.indexOf(a)===o,n=t.map(a=>a.audioCodec).filter(i),r=t.map(a=>a.videoCodec).filter(i);return n.length+r.length===0&&r.push("avc1.42e01e"),new Promise((a,o)=>{const d=l=>{const c=l.shift();this.getMediaKeysPromise(c,n,r).then(u=>a({keySystem:c,mediaKeys:u})).catch(u=>{l.length?d(l):u instanceof ni?o(u):o(new ni({type:ye.KEY_SYSTEM_ERROR,details:$.KEY_SYSTEM_NO_ACCESS,error:u,fatal:!0},u.message))})};d(e)})}requestMediaKeySystemAccess(e,t){const{requestMediaKeySystemAccessFunc:i}=this.config;if(typeof i!="function"){let n=`Configured requestMediaKeySystemAccess is not a function ${i}`;return av===null&&self.location.protocol==="http:"&&(n=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(n))}return i(e,t)}getMediaKeysPromise(e,t,i){var n;const r=uI(e,t,i,this.config.drmSystemOptions||{});let a=this.keySystemAccessPromises[e],o=(n=a)==null?void 0:n.keySystemAccess;if(!o){this.log(`Requesting encrypted media "${e}" key-system access with config: ${lt(r)}`),o=this.requestMediaKeySystemAccess(e,r);const d=a=this.keySystemAccessPromises[e]={keySystemAccess:o};return o.catch(l=>{this.log(`Failed to obtain access to key-system "${e}": ${l}`)}),o.then(l=>{this.log(`Access for key-system "${l.keySystem}" obtained`);const c=this.fetchServerCertificate(e);this.log(`Create media-keys for "${e}"`);const u=d.mediaKeys=l.createMediaKeys().then(h=>(this.log(`Media-keys created for "${e}"`),d.hasMediaKeys=!0,c.then(f=>f?this.setMediaKeysServerCertificate(h,e,f):h)));return u.catch(h=>{this.error(`Failed to create media-keys for "${e}"}: ${h}`)}),u})}return o.then(()=>a.mediaKeys)}createMediaKeySessionContext({decryptdata:e,keySystem:t,mediaKeys:i}){this.log(`Creating key-system session "${t}" keyId: ${Bt(e.keyId||[])} keyUri: ${e.uri}`);const n=i.createSession(),r={decryptdata:e,keySystem:t,mediaKeys:i,mediaKeysSession:n,keyStatus:"status-pending"};return this.mediaKeySessions.push(r),r}renewKeySession(e){const t=e.decryptdata;if(t.pssh){const i=this.createMediaKeySessionContext(e),n=Fa(t),r="cenc";this.keyIdToKeySessionPromise[n]=this.generateRequestWithPreferredKeySession(i,r,t.pssh.buffer,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)}updateKeySession(e,t){const i=e.mediaKeysSession;return this.log(`Updating key-session "${i.sessionId}" for keyId ${Bt(e.decryptdata.keyId||[])} 1511 } (data length: ${t.byteLength})`),i.update(t)}getSelectedKeySystemFormats(){return Object.keys(this.keySystemAccessPromises).map(e=>({keySystem:e,hasMediaKeys:this.keySystemAccessPromises[e].hasMediaKeys})).filter(({hasMediaKeys:e})=>!!e).map(({keySystem:e})=>nd(e)).filter(e=>!!e)}getKeySystemAccess(e){return this.getKeySystemSelectionPromise(e).then(({keySystem:t,mediaKeys:i})=>this.attemptSetMediaKeys(t,i))}selectKeySystem(e){return new Promise((t,i)=>{this.getKeySystemSelectionPromise(e).then(({keySystem:n})=>{const r=nd(n);r?t(r):i(new Error(`Unable to find format for key-system "${n}"`))}).catch(i)})}selectKeySystemFormat(e){const t=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${e.sn} ${e.type}: ${e.level}) key formats ${t.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(t)),this.keyFormatPromise}getKeyFormatPromise(e){const t=Tr(this.config),i=e.map(wo).filter(n=>!!n&&t.indexOf(n)!==-1);return this.selectKeySystem(i)}getKeyStatus(e){const{mediaKeySessions:t}=this;for(let i=0;i<t.length;i++){const n=wL(e,t[i]);if(n)return n}}loadKey(e){const t=e.keyInfo.decryptdata,i=Fa(t),n=this.bannedKeyIds[i];if(n||this.getKeyStatus(t)==="internal-error"){const o=im(n||"internal-error",t);return this.handleError(o,e.frag),Promise.reject(o)}const r=`(keyId: ${i} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${r}`);const a=this.keyIdToKeySessionPromise[i];if(!a){const o=this.getKeySystemForKeyPromise(t).then(({keySystem:d,mediaKeys:l})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${r}`),this.attemptSetMediaKeys(d,l).then(()=>(this.throwIfDestroyed(),this.createMediaKeySessionContext({keySystem:d,mediaKeys:l,decryptdata:t}))))).then(d=>{const l="cenc",c=t.pssh?t.pssh.buffer:null;return this.generateRequestWithPreferredKeySession(d,l,c,"playlist-key")});return o.catch(d=>this.handleError(d,e.frag)),this.keyIdToKeySessionPromise[i]=o,o}return a.catch(o=>{if(o instanceof ni){const d=Je({},o.data);this.getKeyStatus(t)==="internal-error"&&(d.decryptdata=t);const l=new ni(d,o.message);this.handleError(l,e.frag)}}),a}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e,t){if(this.hls)if(e instanceof ni){t&&(e.data.frag=t);const i=e.data.decryptdata;this.error(`${e.message}${i?` (${Bt(i.keyId||[])})`:""}`),this.hls.trigger(v.ERROR,e.data)}else this.error(e.message),this.hls.trigger(v.ERROR,{type:ye.KEY_SYSTEM_ERROR,details:$.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0})}
vendor: 16,779 bytes, line 1511
1511getKeySystemForKeyPromise(e){const t=Fa(e),i=this.keyIdToKeySessionPromise[t];if(!i){const n=wo(e.keyFormat),r=n?[n]:Tr(this.config);return this.attemptKeySystemAccess(r)}return i}getKeySystemSelectionPromise(e){if(e.length||(e=Tr(this.config)),e.length===0)throw new ni({type:ye.KEY_SYSTEM_ERROR,details:$.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${lt({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}attemptSetMediaKeys(e,t){if(this.mediaResolved=void 0,this.mediaKeys===t)return Promise.resolve();const i=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);const n=Promise.all(i).then(()=>this.media?this.media.setMediaKeys(t):new Promise((r,a)=>{this.mediaResolved=()=>{if(this.mediaResolved=void 0,!this.media)return a(new Error("Attempted to set mediaKeys without media element attached"));this.mediaKeys=t,this.media.setMediaKeys(t).then(r).catch(a)}}));return this.mediaKeys=t,this.setMediaKeysQueue.push(n),n.then(()=>{this.log(`Media-keys set for "${e}"`),i.push(n),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(r=>i.indexOf(r)===-1)})}generateRequestWithPreferredKeySession(e,t,i,n){var r;const a=(r=this.config.drmSystems)==null||(r=r[e.keySystem])==null?void 0:r.generateRequest;if(a)try{const m=a.call(this.hls,t,i,e);if(!m)throw new Error("Invalid response from configured generateRequest filter");t=m.initDataType,i=m.initData?m.initData:null,e.decryptdata.pssh=i?new Uint8Array(i):null}catch(m){if(this.warn(m.message),this.hls&&this.hls.config.debug)throw m}if(i===null)return this.log(`Skipping key-session request for "${n}" (no initData)`),Promise.resolve(e);const o=Fa(e.decryptdata),d=e.decryptdata.uri;this.log(`Generating key-session request for "${n}" keyId: ${o} URI: ${d} (init data type: ${t} length: ${i.byteLength})`);const l=new Nu,c=e._onmessage=m=>{const p=e.mediaKeysSession;if(!p){l.emit("error",new Error("invalid state"));return}const{messageType:g,message:y}=m;this.log(`"${g}" message event for session "${p.sessionId}" message size: ${y.byteLength}`),g==="license-request"||g==="license-renewal"?this.renewLicense(e,y).catch(T=>{l.eventNames().length?l.emit("error",T):this.handleError(T)}):g==="license-release"?e.keySystem===gt.FAIRPLAY&&this.updateKeySession(e,Oc("acknowledged")).then(()=>this.removeSession(e)).catch(T=>this.handleError(T)):this.warn(`unhandled media key message type "${g}"`)},u=(m,p)=>{p.keyStatus=m;let g;m.startsWith("usable")?l.emit("resolved"):m==="internal-error"||m==="output-restricted"||m==="output-downscaled"?g=im(m,p.decryptdata):m==="expired"?g=new Error(`key expired (keyId: ${o})`):m==="released"?g=new Error("key released"):m==="status-pending"||this.warn(`unhandled key status change "${m}" (keyId: ${o})`),g&&(l.eventNames().length?l.emit("error",g):this.handleError(g))},h=e._onkeystatuseschange=m=>{if(!e.mediaKeysSession){l.emit("error",new Error("invalid state"));return}const g=this.getKeyStatuses(e);if(!Object.keys(g).some(I=>g[I]!=="status-pending"))return;if(g[o]==="expired"){this.log(`Expired key ${lt(g)} in key-session "${e.mediaKeysSession.sessionId}"`),this.renewKeySession(e);return}let T=g[o];if(T)u(T,e);else{var _;e.keyStatusTimeouts||(e.keyStatusTimeouts={}),(_=e.keyStatusTimeouts)[o]||(_[o]=self.setTimeout(()=>{if(!e.mediaKeysSession||!this.mediaKeys)return;const R=this.getKeyStatus(e.decryptdata);if(R&&R!=="status-pending")return this.log(`No status for keyId ${o} in key-session "${e.mediaKeysSession.sessionId}". Using session key-status ${R} from other session.`),u(R,e);this.log(`key status for ${o} in key-session "${e.mediaKeysSession.sessionId}" timed out after 1000ms`),T="internal-error",u(T,e)},1e3)),this.log(`No status for keyId ${o} (${lt(g)}).`)}};jt(e.mediaKeysSession,"message",c),jt(e.mediaKeysSession,"keystatuseschange",h);const f=new Promise((m,p)=>{l.on("error",p),l.on("resolved",m)});return e.mediaKeysSession.generateRequest(t,i).then(()=>{this.log(`Request generated for key-session "${e.mediaKeysSession.sessionId}" keyId: ${o} URI: ${d}`)}).catch(m=>{throw new ni({type:ye.KEY_SYSTEM_ERROR,details:$.KEY_SYSTEM_NO_SESSION,error:m,decryptdata:e.decryptdata,fatal:!1},`Error generating key-session request: ${m}`)}).then(()=>f).catch(m=>(l.removeAllListeners(),this.removeSession(e).then(()=>{throw m}))).then(()=>(l.removeAllListeners(),e))}getKeyStatuses(e){const t={};return e.mediaKeysSession.keyStatuses.forEach((i,n)=>{if(typeof n=="string"&&typeof i=="object"){const o=n;n=i,i=o}const r="buffer"in n?new Uint8Array(n.buffer,n.byteOffset,n.byteLength):new Uint8Array(n);if(e.keySystem===gt.PLAYREADY&&r.length===16){const o=Bt(r);t[o]=i,nv(r)}const a=Bt(r);i==="internal-error"&&(this.bannedKeyIds[a]=i),this.log(`key status change "${i}" for keyStatuses keyId: ${a} key-session "${e.mediaKeysSession.sessionId}"`),t[a]=i}),t}fetchServerCertificate(e){const t=this.config,i=t.loader,n=new i(t),r=this.getServerCertificateUrl(e);return r?(this.log(`Fetching server certificate for "${e}"`),new Promise((a,o)=>{const d={responseType:"arraybuffer",url:r},l=t.certLoadPolicy.default,c={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},u={onSuccess:(h,f,m,p)=>{a(h.data)},onError:(h,f,m,p)=>{o(new ni({type:ye.KEY_SYSTEM_ERROR,details:$.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:m,response:Je({url:d.url,data:void 0},h)},`"${e}" certificate request failed (${r}). Status: ${h.code} (${h.text})`))},onTimeout:(h,f,m)=>{o(new ni({type:ye.KEY_SYSTEM_ERROR,details:$.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:m,response:{url:d.url,data:void 0}},`"${e}" certificate request timed out (${r})`))},onAbort:(h,f,m)=>{o(new Error("aborted"))}};n.load(d,c,u)})):Promise.resolve()}setMediaKeysServerCertificate(e,t,i){return new Promise((n,r)=>{e.setServerCertificate(i).then(a=>{this.log(`setServerCertificate ${a?"success":"not supported by CDM"} (${i.byteLength}) on "${t}"`),n(e)}).catch(a=>{r(new ni({type:ye.KEY_SYSTEM_ERROR,details:$.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:a,fatal:!0},a.message))})})}renewLicense(e,t){return this.requestLicense(e,new Uint8Array(t)).then(i=>this.updateKeySession(e,new Uint8Array(i)).catch(n=>{throw new ni({type:ye.KEY_SYSTEM_ERROR,details:$.KEY_SYSTEM_SESSION_UPDATE_FAILED,decryptdata:e.decryptdata,error:n,fatal:!1},n.message)}))}unpackPlayReadyKeyMessage(e,t){const i=String.fromCharCode.apply(null,new Uint16Array(t.buffer));if(!i.includes("PlayReadyKeyMessage"))return e.setRequestHeader("Content-Type","text/xml; charset=utf-8"),t;const n=new DOMParser().parseFromString(i,"application/xml"),r=n.querySelectorAll("HttpHeader");if(r.length>0){let c;for(let u=0,h=r.length;u<h;u++){var a,o;c=r[u];const f=(a=c.querySelector("name"))==null?void 0:a.textContent,m=(o=c.querySelector("value"))==null?void 0:o.textContent;f&&m&&e.setRequestHeader(f,m)}}const d=n.querySelector("Challenge"),l=d?.textContent;if(!l)throw new Error("Cannot find <Challenge> in key message");return Oc(atob(l))}setupLicenseXHR(e,t,i,n){const r=this.config.licenseXhrSetup;return r?Promise.resolve().then(()=>{if(!i.decryptdata)throw new Error("Key removed");return r.call(this.hls,e,t,i,n)}).catch(a=>{if(!i.decryptdata)throw a;return e.open("POST",t,!0),r.call(this.hls,e,t,i,n)}).then(a=>(e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:a||n})):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:n}))}requestLicense(e,t){const i=this.config.keyLoadPolicy.default;return new Promise((n,r)=>{const a=this.getLicenseServerUrlOrThrow(e.keySystem);this.log(`Sending license request to URL: ${a}`);const o=new XMLHttpRequest;o.responseType="arraybuffer",o.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return r(new Error("invalid state"));if(o.readyState===4)if(o.status===200){this._requestLicenseFailureCount=0;let d=o.response;this.log(`License received ${d instanceof ArrayBuffer?d.byteLength:d}`);const l=this.config.licenseResponseCallback;if(l)try{d=l.call(this.hls,o,a,e)}catch(c){this.error(c)}n(d)}else{const d=i.errorRetry,l=d?d.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>l||o.status>=400&&o.status<500)r(new ni({type:ye.KEY_SYSTEM_ERROR,details:$.KEY_SYSTEM_LICENSE_REQUEST_FAILED,decryptdata:e.decryptdata,fatal:!0,networkDetails:o,response:{url:a,data:void 0,code:o.status,text:o.statusText}},`License Request XHR failed (${a}). Status: ${o.status} (${o.statusText})`));else{const c=l-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${c} attempts left`),this.requestLicense(e,t).then(n,r)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=o,this.setupLicenseXHR(o,a,e,t).then(({xhr:d,licenseChallenge:l})=>{e.keySystem==gt.PLAYREADY&&(l=this.unpackPlayReadyKeyMessage(d,l)),d.send(l)}).catch(r)})}onDestroying(){this.unregisterListeners(),this._clear()}onMediaAttached(e,t){if(!this.config.emeEnabled)return;const i=t.media;this.media=i,jt(i,"encrypted",this.onMediaEncrypted),jt(i,"waitingforkey",this.onWaitingForKey);const n=this.mediaResolved;n?n():this.mediaKeys=i.mediaKeys}onMediaDetached(){const e=this.media;e&&(ti(e,"encrypted",this.onMediaEncrypted),ti(e,"waitingforkey",this.onWaitingForKey),this.media=null,this.mediaKeys=null)}_clear(){var e;this._requestLicenseFailureCount=0,this.keyIdToKeySessionPromise={},this.bannedKeyIds={};const t=this.mediaResolved;if(t&&t(),!this.mediaKeys&&!this.mediaKeySessions.length)return;const i=this.media,n=this.mediaKeySessions.slice();this.mediaKeySessions=[],this.mediaKeys=null,Is.clearKeyUriToKeyIdMap();const r=n.length;Un.CDMCleanupPromise=Promise.all(n.map(a=>this.removeSession(a)).concat((i==null||(e=i.setMediaKeys(null))==null?void 0:e.catch(a=>{this.log(`Could not clear media keys: ${a}`),this.hls&&this.hls.trigger(v.ERROR,{type:ye.OTHER_ERROR,details:$.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR,fatal:!1,error:new Error(`Could not clear media keys: ${a}`)})}))||Promise.resolve())).catch(a=>{this.log(`Could not close sessions and clear media keys: ${a}`),this.hls&&this.hls.trigger(v.ERROR,{type:ye.OTHER_ERROR,details:$.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close sessions and clear media keys: ${a}`)})}).then(()=>{r&&this.log("finished closing key sessions and clearing media keys")})}onManifestLoading(){this._clear()}onManifestLoaded(e,{sessionKeys:t}){if(!(!t||!this.config.emeEnabled)&&!this.keyFormatPromise){const i=t.reduce((n,r)=>(n.indexOf(r.keyFormat)===-1&&n.push(r.keyFormat),n),[]);this.log(`Selecting key-system from session-keys ${i.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(i)}}removeSession(e){const{mediaKeysSession:t,licenseXhr:i,decryptdata:n}=e;if(t){this.log(`Remove licenses and keys and close session "${t.sessionId}" keyId: ${Bt(n?.keyId||[])}`),e._onmessage&&(t.removeEventListener("message",e._onmessage),e._onmessage=void 0),e._onkeystatuseschange&&(t.removeEventListener("keystatuseschange",e._onkeystatuseschange),e._onkeystatuseschange=void 0),i&&i.readyState!==XMLHttpRequest.DONE&&i.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;const r=this.mediaKeySessions.indexOf(e);r>-1&&this.mediaKeySessions.splice(r,1);const{keyStatusTimeouts:a}=e;a&&Object.keys(a).forEach(l=>self.clearTimeout(a[l]));const{drmSystemOptions:o}=this.config;return(fI(o)?new Promise((l,c)=>{self.setTimeout(()=>c(new Error("MediaKeySession.remove() timeout")),8e3),t.remove().then(l).catch(c)}):Promise.resolve()).catch(l=>{this.log(`Could not remove session: ${l}`),this.hls&&this.hls.trigger(v.ERROR,{type:ye.OTHER_ERROR,details:$.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR,fatal:!1,error:new Error(`Could not remove session: ${l}`)})}).then(()=>t.close()).catch(l=>{this.log(`Could not close session: ${l}`),this.hls&&this.hls.trigger(v.ERROR,{type:ye.OTHER_ERROR,details:$.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close session: ${l}`)})})}return Promise.resolve()}}Un.CDMCleanupPromise=void 0;function Fa(s){if(!s)throw new Error("Could not read keyId of undefined decryptdata");if(s.keyId===null)throw new Error("keyId is null");return Bt(s.keyId)}function wL(s,e){if(s.keyId&&e.mediaKeysSession.keyStatuses.has(s.keyId))return e.mediaKeysSession.keyStatuses.get(s.keyId);if(s.matches(e.decryptdata))return e.keyStatus}class ni extends Error{constructor(e,t){super(t),this.data=void 0,e.error||(e.error=new Error(t)),this.data=e,e.err=e.error}}function im(s,e){const t=s==="output-restricted",i=t?$.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:$.KEY_SYSTEM_STATUS_INTERNAL_ERROR;return new ni({type:ye.KEY_SYSTEM_ERROR,details:i,fatal:!1,decryptdata:e},t?"HDCP level output restricted":`key status changed to "${s}"`)}class PL{constructor(e){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=e,this.registerListeners()}setStreamController(e){this.streamController=e}registerListeners(){this.hls.on(v.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.on(v.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListeners(){this.hls.off(v.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off(v.MEDIA_DETACHING,this.onMediaDetaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(e,t){const i=this.hls.config;if(i.capLevelOnFPSDrop){const n=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=n,n&&typeof n.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),i.fpsDroppedMonitoringPeriod)}}onMediaDetaching(){this.media=null}checkFPS(e,t,i){const n=performance.now();if(t){if(this.lastTime){const r=n-this.lastTime,a=i-this.lastDroppedFrames,o=t-this.lastDecodedFrames,d=1e3*a/r,l=this.hls;if(l.trigger(v.FPS_DROP,{currentDropped:a,currentDecoded:o,totalDroppedFrames:i}),d>0&&a>l.config.fpsDroppedMonitoringThreshold*o){let c=l.currentLevel;l.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+c),c>0&&(l.autoLevelCapping===-1||l.autoLevelCapping>=c)&&(c=c-1,l.trigger(v.FPS_DROP_LEVEL_CAPPING,{level:c,droppedLevel:l.currentLevel}),l.autoLevelCapping=c,this.streamController.nextLevelSwitch())}}this.lastTime=n,this.lastDroppedFrames=i,this.lastDecodedFrames=t}}checkFPSInterval(){const e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){const t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}}function Xv(s,e){let t;try{t=new Event("addtrack")}catch{t=document.createEvent("Event"),t.initEvent("addtrack",!1,!1)}t.track=s,e.dispatchEvent(t)}function Qv(s,e){const t=s.mode;if(t==="disabled"&&(s.mode="hidden"),s.cues&&!s.cues.getCueById(e.id))try{if(s.addCue(e),!s.cues.getCueById(e.id))throw new Error(`addCue is failed for: ${e}`)}catch(i){et.debug(`[texttrack-utils]: ${i}`);try{const n=new self.TextTrackCue(e.startTime,e.endTime,e.text);n.id=e.id,s.addCue(n)}catch(n){et.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${n}`)}}t==="disabled"&&(s.mode=t)}function wn(s,e){const t=s.mode;if(t==="disabled"&&(s.mode="hidden"),s.cues)for(let i=s.cues.length;i--;)e&&s.cues[i].removeEventListener("enter",e),s.removeCue(s.cues[i]);t==="disabled"&&(s.mode=t)}function Vc(s,e,t,i){const n=s.mode;if(n==="disabled"&&(s.mode="hidden"),s.cues&&s.cues.length>0){const r=OL(s.cues,e,t);for(let a=0;a<r.length;a++)(!i||i(r[a]))&&s.removeCue(r[a])}n==="disabled"&&(s.mode=n)}function ML(s,e){if(e<=s[0].startTime)return 0;const t=s.length-1;if(e>s[t].endTime)return-1;let i=0,n=t,r;for(;i<=n;)if(r=Math.floor((n+i)/2),e<s[r].startTime)n=r-1;else if(e>s[r].startTime&&i<t)i=r+1;else return r;return s[i].startTime-e<e-s[n].startTime?i:n}function OL(s,e,t){const i=[],n=ML(s,e);if(n>-1)for(let r=n,a=s.length;r<a;r++){const o=s[r];if(o.startTime>=e&&o.endTime<=t)i.push(o);else if(o.startTime>t)return i}return i}function Fo(s){const e=[];for(let t=0;t<s.length;t++){const i=s[t];(i.kind==="subtitles"||i.kind==="captions")&&i.label&&e.push(s[t])}return e}class FL extends Wu{constructor(e){super(e,"subtitle-track-controller"),this.media=null,this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.queuedDefaultTrack=-1,this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.onTextTracksChanged=()=>
1511{if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let t=null;const i=Fo(this.media.textTracks);for(let r=0;r<i.length;r++)if(i[r].mode==="hidden")t=i[r];else if(i[r].mode==="showing"){t=i[r
vendor: 2,157 bytes, line 1511
1511];break}const n=this.findTrackForTextTrack(t);this.subtitleTrack!==n&&this.setSubtitleTrack(n)},this.registerListeners()}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,this.onTextTracksChanged=this.asyncPollTrackChange=null,super.destroy()}get subtitleDisplay(){return this._subtitleDisplay}set subtitleDisplay(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes()}registerListeners(){const{hls:e}=this;e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_PARSED,this.onManifestParsed,this),e.on(v.LEVEL_LOADING,this.onLevelLoading,this),e.on(v.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(v.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(v.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_PARSED,this.onManifestParsed,this),e.off(v.LEVEL_LOADING,this.onLevelLoading,this),e.off(v.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(v.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(v.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))}pollTrackChange(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.onTextTracksChanged,e)}onMediaDetaching(e,t){const i=this.media;if(!i)return;const n=!!t.transferMedia;if(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||i.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),this.subtitleTrack=-1,this.media=null,n)return;
vendor: 5,055 bytes, line 1511
1511Fo(i.textTracks).forEach(a=>{wn(a)})}onManifestLoading(){this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.subtitleTracks}onSubtitleTrackLoaded(e,t){const{id:i,groupId:n,details:r}=t,a=this.tracksInGroup[i];if(!a||a.groupId!==n){this.warn(`Subtitle track with id:${i} and group:${n} not found in active group ${a?.groupId}`);return}const o=a.details;a.details=t.details,this.log(`Subtitle track ${i} "${a.name}" lang:${a.lang} group:${n} loaded [${r.startSN}-${r.endSN}]`),i===this.trackId&&this.playlistLoaded(i,t,o)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(!t)return;const i=t.subtitleGroups||null,n=this.groupIds;let r=this.currentTrack;if(!i||n?.length!==i?.length||i!=null&&i.some(a=>n?.indexOf(a)===-1)){this.groupIds=i,this.trackId=-1,this.currentTrack=null;const a=this.tracks.filter(c=>!i||i.indexOf(c.groupId)!==-1);if(a.length)this.selectDefaultTrack&&!a.some(c=>c.default)&&(this.selectDefaultTrack=!1),a.forEach((c,u)=>{c.id=u});else if(!r&&!this.tracksInGroup.length)return;this.tracksInGroup=a;const o=this.hls.config.subtitlePreference;if(!r&&o){this.selectDefaultTrack=!1;const c=qi(o,a);if(c>-1)r=a[c];else{const u=qi(o,this.tracks);r=this.tracks[u]}}let d=this.findTrackId(r);d===-1&&r&&(d=this.findTrackId(null));const l={subtitleTracks:a};this.log(`Updating subtitle tracks, ${a.length} track(s) found in "${i?.join(",")}" group-id`),this.hls.trigger(v.SUBTITLE_TRACKS_UPDATED,l),d!==-1&&this.trackId===-1&&this.setSubtitleTrack(d)}}findTrackId(e){const t=this.tracksInGroup,i=this.selectDefaultTrack;for(let n=0;n<t.length;n++){const r=t[n];if(!(i&&!r.default||!i&&!e)&&(!e||js(r,e)))return n}if(e){for(let n=0;n<t.length;n++){const r=t[n];if(zr(e.attrs,r.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return n}for(let n=0;n<t.length;n++){const r=t[n];if(zr(e.attrs,r.attrs,["LANGUAGE"]))return n}}return-1}findTrackForTextTrack(e){if(e){const t=this.tracksInGroup;for(let i=0;i<t.length;i++){const n=t[i];if(Bc(n,e))return i}}return-1}onError(e,t){t.fatal||!t.context||t.context.type===Ge.SUBTITLE_TRACK&&t.context.id===this.trackId&&(!this.groupIds||this.groupIds.indexOf(t.context.groupId)!==-1)&&this.checkRetry(t)}get allSubtitleTracks(){return this.tracks}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(e){this.selectDefaultTrack=!1,this.setSubtitleTrack(e)}setSubtitleOption(e){if(this.hls.config.subtitlePreference=e,e){if(e.id===-1)return this.setSubtitleTrack(-1),null;const t=this.allSubtitleTracks;if(this.selectDefaultTrack=!1,t.length){const i=this.currentTrack;if(i&&js(e,i))return i;const n=qi(e,this.tracksInGroup);if(n>-1){const r=this.tracksInGroup[n];return this.setSubtitleTrack(n),r}else{if(i)return null;{const r=qi(e,t);if(r>-1)return t[r]}}}}return null}loadPlaylist(e){super.loadPlaylist(),this.shouldLoadPlaylist(this.currentTrack)&&this.scheduleLoading(this.currentTrack,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);const i=e.id,n=e.groupId,r=this.getUrlWithDirectives(e.url,t),a=e.details,o=a?.age;this.log(`Loading subtitle ${i} "${e.name}" lang:${e.lang} group:${n}${t?.msn!==void 0?" at sn "+t.msn+" part "+t.part:""}${o&&a.live?" age "+o.toFixed(1)+(a.type&&" "+a.type||""):""} ${r}`),this.hls.trigger(v.SUBTITLE_TRACK_LOADING,{url:r,id:i,groupId:n,deliveryDirectives:t||null,track:e})}toggleTrackModes(){const{media:e}=this;if(!e)return;const t=Fo(e.textTracks),i=this.currentTrack;let n;if(i&&(n=t.filter(r=>Bc(i,r))[0],n||this.warn(`Unable to find subtitle TextTrack with name "${i.name}" and language "${i.lang}"`)),[].slice.call(t).forEach(r=>{r.mode!=="disabled"&&r!==n&&(r.mode="disabled")}),n){const r=this.subtitleDisplay?"showing":"hidden";n.mode!==r&&(n.mode=r)}}setSubtitleTrack(e){const t=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(e<-1||e>=t.length||!he(e)){this.warn(`Invalid subtitle track id: ${e}`);return}this.selectDefaultTrack=!1;const i=this.currentTrack,n=t[e]||null;if(this.trackId=e,this.currentTrack=n,this.toggleTrackModes(),!n){this.hls.trigger(v.SUBTITLE_TRACK_SWITCH,{id:e});return}const r=!!n.details&&!n.details.live;if(e===this.trackId&&n===i&&r)return;this.log(`Switching to subtitle-track ${e}`+(n?` "${n.name}" lang:${n.lang} group:${n.groupId}`:""));const{id:a,groupId:o="",name:d,type:l,url:c}=n;this.hls.trigger(v.SUBTITLE_TRACK_SWITCH,{id:a,groupId:o,name:d,type:l,url:c});const u=this.switchParams(n.url,i?.details,n.details);this.loadPlaylist(u)}}function $L(){try{return crypto.randomUUID()}catch{try{const e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}catch{let t=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,n=>{const r=(t+Math.random()*16)%16|0;return t=Math.floor(t/16),(n=="x"?r:r&3|8).toString(16)})}}}function Dr(s){let e=5381,t=s.length;for(;t;
vendor: 4,231 bytes, line 1511
1511)e=e*33^s.charCodeAt(--t);return(e>>>0).toString()}const Bn=.025;let El=(function(s){return s[s.Point=0]="Point",s[s.Range=1]="Range",s})({});function NL(s,e,t){return`${s.identifier}-${t+1}-${Dr(e)}`}class UL{constructor(e,t){this.base=void 0,this._duration=null,this._timelineStart=null,this.appendInPlaceDisabled=void 0,this.appendInPlaceStarted=void 0,this.dateRange=void 0,this.hasPlayed=!1,this.cumulativeDuration=0,this.resumeOffset=NaN,this.playoutLimit=NaN,this.restrictions={skip:!1,jump:!1},this.snapOptions={out:!1,in:!1},this.assetList=[],this.assetListLoader=void 0,this.assetListResponse=null,this.resumeAnchor=void 0,this.error=void 0,this.resetOnResume=void 0,this.base=t,this.dateRange=e,this.setDateRange(e)}setDateRange(e){this.dateRange=e,this.resumeOffset=e.attr.optionalFloat("X-RESUME-OFFSET",this.resumeOffset),this.playoutLimit=e.attr.optionalFloat("X-PLAYOUT-LIMIT",this.playoutLimit),this.restrictions=e.attr.enumeratedStringList("X-RESTRICT",this.restrictions),this.snapOptions=e.attr.enumeratedStringList("X-SNAP",this.snapOptions)}reset(){var e;this.appendInPlaceStarted=!1,(e=this.assetListLoader)==null||e.destroy(),this.assetListLoader=void 0,this.supplementsPrimary||(this.assetListResponse=null,this.assetList=[],this._duration=null)}isAssetPastPlayoutLimit(e){var t;if(e>0&&e>=this.assetList.length)return!0;const i=this.playoutLimit;return e<=0||isNaN(i)?!1:i===0?!0:(((t=this.assetList[e])==null?void 0:t.startOffset)||0)>i}findAssetIndex(e){return this.assetList.indexOf(e)}get identifier(){return this.dateRange.id}get startDate(){return this.dateRange.startDate}get startTime(){const e=this.dateRange.startTime;if(this.snapOptions.out){const t=this.dateRange.tagAnchor;if(t)return fd(e,t)}return e}get startOffset(){return this.cue.pre?0:this.startTime}get startIsAligned(){if(this.startTime===0||this.snapOptions.out)return!0;const e=this.dateRange.tagAnchor;if(e){const t=this.dateRange.startTime,i=fd(t,e);return t-i<.1}return!1}get resumptionOffset(){const e=this.resumeOffset,t=he(e)?e:this.duration;return this.cumulativeDuration+t}get resumeTime(){const e=this.startOffset+this.resumptionOffset;if(this.snapOptions.in){const t=this.resumeAnchor;if(t)return fd(e,t)}return e}get appendInPlace(){return this.appendInPlaceStarted?!0:this.appendInPlaceDisabled?!1:!!(!this.cue.once&&!this.cue.pre&&this.startIsAligned&&(isNaN(this.playoutLimit)&&isNaN(this.resumeOffset)||this.resumeOffset&&this.duration&&Math.abs(this.resumeOffset-this.duration)<Bn))}set appendInPlace(e){if(this.appendInPlaceStarted){this.resetOnResume=!e;return}this.appendInPlaceDisabled=!e}get timelineStart(){return this._timelineStart!==null?this._timelineStart:this.startTime}set timelineStart(e){this._timelineStart=e}get duration(){const e=this.playoutLimit;let t;return this._duration!==null?t=this._duration:this.dateRange.duration?t=this.dateRange.duration:t=this.dateRange.plannedDuration||0,!isNaN(e)&&e<t&&(t=e),t}set duration(e){this._duration=e}get cue(){return this.dateRange.cue}get timelineOccupancy(){return this.dateRange.attr["X-TIMELINE-OCCUPIES"]==="RANGE"?El.Range:El.Point}get supplementsPrimary(){return this.dateRange.attr["X-TIMELINE-STYLE"]==="PRIMARY"}get contentMayVary(){return this.dateRange.attr["X-CONTENT-MAY-VARY"]!=="NO"}get assetUrl(){return this.dateRange.attr["X-ASSET-URI"]}get assetListUrl(){return this.dateRange.attr["X-ASSET-LIST"]}get baseUrl(){return this.base.url}get assetListLoaded(){return this.assetList.length>0||this.assetListResponse!==null}toString(){return BL(this)}}function fd(s,e){return s-e.start<e.duration/2&&!(Math.abs(s-(e.start+e.duration))<Bn)?e.start:e.start+e.duration}function Zv(s,e,t){const i=new self.URL(s,t);return i.protocol!=="data:"&&i.searchParams.set("_HLS_primary_id",e),i}function md(s,e){for(;(t=s.assetList[++e])!=null&&t.error;)var t;return e}function BL(s){return`["${s.identifier}" ${s.cue.pre?"<pre>":s.cue.post?"<post>":""}${s.timelineStart.toFixed(2)}-${s.resumeTime.toFixed(2)}]`}function Rn(s){const e=s.timelineStart,t=s.duration||0;return`["${s.identifier}" ${e.toFixed(2)}-${(e+t).toFixed(2)}]`}class GL{constructor(e,t,i,n){this.hls=void 0,this.interstitial=void 0,this.assetItem=void 0,this.tracks=null,this.hasDetail
vendor: 4,234 bytes, line 1511
1511s=!1,this.mediaAttached=null,this._currentTime=void 0,this._bufferedEosTime=void 0,this.checkPlayout=()=>{this.reachedPlayout(this.currentTime)&&this.hls&&this.hls.trigger(v.PLAYOUT_LIMIT_REACHED,{})};const r=this.hls=new e(t);this.interstitial=i,this.assetItem=n;const a=()=>{this.hasDetails=!0};r.once(v.LEVEL_LOADED,a),r.once(v.AUDIO_TRACK_LOADED,a),r.once(v.SUBTITLE_TRACK_LOADED,a),r.on(v.MEDIA_ATTACHING,(o,{media:d})=>{this.removeMediaListeners(),this.mediaAttached=d,this.interstitial.playoutLimit&&(d.addEventListener("timeupdate",this.checkPlayout),this.appendInPlace&&r.on(v.BUFFER_APPENDED,()=>{const c=this.bufferedEnd;this.reachedPlayout(c)&&(this._bufferedEosTime=c,r.trigger(v.BUFFERED_TO_END,void 0))}))})}get appendInPlace(){return this.interstitial.appendInPlace}loadSource(){const e=this.hls;if(e)if(e.url)e.levels.length&&!e.started&&e.startLoad(-1,!0);else{let t=this.assetItem.uri;try{t=Zv(t,e.config.primarySessionId||"").href}catch{}e.loadSource(t)}}bufferedInPlaceToEnd(e){var t;if(!this.appendInPlace)return!1;if((t=this.hls)!=null&&t.bufferedToEnd)return!0;if(!e)return!1;const i=Math.min(this._bufferedEosTime||1/0,this.duration),n=this.timelineOffset,r=Me.bufferInfo(e,n,0);return this.getAssetTime(r.end)>=i-.02}reachedPlayout(e){const i=this.interstitial.playoutLimit;return this.startOffset+e>=i}get destroyed(){var e;return!((e=this.hls)!=null&&e.userConfig)}get assetId(){return this.assetItem.identifier}get interstitialId(){return this.assetItem.parentIdentifier}get media(){var e;return((e=this.hls)==null?void 0:e.media)||null}get bufferedEnd(){const e=this.media||this.mediaAttached;if(!e)return this._bufferedEosTime?this._bufferedEosTime:this.currentTime;const t=Me.bufferInfo(e,e.currentTime,.001);return this.getAssetTime(t.end)}get currentTime(){const e=this.media||this.mediaAttached;return e?this.getAssetTime(e.currentTime):this._currentTime||0}get duration(){const e=this.assetItem.duration;if(!e)return 0;const t=this.interstitial.playoutLimit;if(t){const i=t-this.startOffset;if(i>0&&i<e)return i}return e}get remaining(){const e=this.duration;return e?Math.max(0,e-this.currentTime):0}get startOffset(){return this.assetItem.startOffset}get timelineOffset(){var e;return((e=this.hls)==null?void 0:e.config.timelineOffset)||0}set timelineOffset(e){const t=this.timelineOffset;if(e!==t){const i=e-t;if(Math.abs(i)>1/9e4&&this.hls){if(this.hasDetails)throw new Error("Cannot set timelineOffset after playlists are loaded");this.hls.config.timelineOffset=e}}}getAssetTime(e){const t=this.timelineOffset,i=this.duration;return Math.min(Math.max(0,e-t),i)}removeMediaListeners(){const e=this.mediaAttached;e&&(this._currentTime=e.currentTime,this.bufferSnapShot(),e.removeEventListener("timeupdate",this.checkPlayout))}bufferSnapShot(){if(this.mediaAttached){var e;(e=this.hls)!=null&&e.bufferedToEnd&&(this._bufferedEosTime=this.bufferedEnd)}}destroy(){this.removeMediaListeners(),this.hls&&this.hls.destroy(),this.hls=null,this.tracks=this.mediaAttached=this.checkPlayout=null}attachMedia(e){var t;this.loadSource(),(t=this.hls)==null||t.attachMedia(e)}detachMedia(){var e;this.removeMediaListeners(),this.mediaAttached=null,(e=this.hls)==null||e.detachMedia()}resumeBuffering(){var e;(e=this.hls)==null||e.resumeBuffering()}pauseBuffering(){var e;(e=this.hls)==null||e.pauseBuffering()}transferMedia(){var e;return this.bufferSnapShot(),((e=this.hls)==null?void 0:e.transferMedia())||null}resetDetails(){const e=this.hls;if(e&&this.hasDetails){e.stopLoad();const t=i=>delete i.details;e.levels.forEach(t),e.allAudioTracks.forEach(t),e.allSubtitleTracks.forEach(t),this.hasDetails=!1}}on(e,t,i){var n;(n=this.hls)==null||n.on(e,t)}once(e,t,i){var n;(n=this.hls)==null||n.once(e,t)}off(e,t,i){var n;(n=this.hls)==null||n.off(e,t)}toString(){var e;return`HlsAssetPlayer: ${Rn(this.assetItem)} ${(e=this.hls)==null?void 0:e.sessionId} ${this.appendInPlace?"append-in-place":""}`}}const sm=.033;class KL extends pi{constructor(e,t){super("interstitials-sched",t),this.onScheduleUpdate=void 0,this.eventMap={},this.events=null,this.items=null,this.durations={primary:0,playout:0,integrated:0},this.onScheduleUpdate=e}destroy(){this.reset(),this.onScheduleUpdate=null}reset(){this.eventMap={}
vendor: 42,658 bytes, lines 1511-1512
1511,this.setDurations(0,0,0),this.events&&this.events.forEach(e=>e.reset()),this.events=this.items=null}resetErrorsInRange(e,t){return this.events?this.events.reduce((i,n)=>e<=n.startOffset&&t>n.startOffset?(delete n.error,i+1):i,0):0}get duration(){const e=this.items;return e?e[e.length-1].end:0}get length(){return this.items?this.items.length:0}getEvent(e){return e&&this.eventMap[e]||null}hasEvent(e){return e in this.eventMap}findItemIndex(e,t){if(e.event)return this.findEventIndex(e.event.identifier);let i=-1;e.nextEvent?i=this.findEventIndex(e.nextEvent.identifier)-1:e.previousEvent&&(i=this.findEventIndex(e.previousEvent.identifier)+1);const n=this.items;if(n)for(n[i]||(t===void 0&&(t=e.start),i=this.findItemIndexAtTime(t));i>=0&&(r=n[i])!=null&&r.event;){var r;i--}return i}findItemIndexAtTime(e,t){const i=this.items;if(i)for(let n=0;n<i.length;n++){let r=i[n];if(t&&t!=="primary"&&(r=r[t]),e===r.start||e>r.start&&e<r.end)return n}return-1}findJumpRestrictedIndex(e,t){const i=this.items;if(i)for(let n=e;n<=t&&i[n];n++){const r=i[n].event;if(r!=null&&r.restrictions.jump&&!r.appendInPlace)return n}return-1}findEventIndex(e){const t=this.items;if(t)for(let n=t.length;n--;){var i;if(((i=t[n].event)==null?void 0:i.identifier)===e)return n}return-1}findAssetIndex(e,t){const i=e.assetList,n=i.length;if(n>1)for(let r=0;r<n;r++){const a=i[r];if(!a.error){const o=a.timelineStart;if(t===o||t>o&&(t<o+(a.duration||0)||r===n-1))return r}}return 0}get assetIdAtEnd(){var e;const t=(e=this.items)==null||(e=e[this.length-1])==null?void 0:e.event;if(t){const i=t.assetList,n=i[i.length-1];if(n)return n.identifier}return null}parseInterstitialDateRanges(e,t){const i=e.main.details,{dateRanges:n}=i,r=this.events,a=this.parseDateRanges(n,{url:i.url},t),o=Object.keys(n),d=r?r.filter(l=>!o.includes(l.identifier)):[];a.length&&a.sort((l,c)=>{const u=l.cue.pre,h=l.cue.post,f=c.cue.pre,m=c.cue.post;if(u&&!f)return-1;if(f&&!u||h&&!m)return 1;if(m&&!h)return-1;if(!u&&!f&&!h&&!m){const p=l.startTime,g=c.startTime;if(p!==g)return p-g}return l.dateRange.tagOrder-c.dateRange.tagOrder}),this.events=a,d.forEach(l=>{this.removeEvent(l)}),this.updateSchedule(e,d)}updateSchedule(e,t=[],i=!1){const n=this.events||[];if(n.length||t.length||this.length<2){const r=this.items,a=this.parseSchedule(n,e);(i||t.length||r?.length!==a.length||a.some((d,l)=>Math.abs(d.playout.start-r[l].playout.start)>.005||Math.abs(d.playout.end-r[l].playout.end)>.005))&&(this.items=a,this.onScheduleUpdate(t,r))}}parseDateRanges(e,t,i){const n=[],r=Object.keys(e);for(let a=0;a<r.length;a++){const o=r[a],d=e[o];if(d.isInterstitial){let l=this.eventMap[o];l?l.setDateRange(d):(l=new UL(d,t),this.eventMap[o]=l,i===!1&&(l.appendInPlace=i)),n.push(l)}}return n}parseSchedule(e,t){const i=[],n=t.main.details,r=n.live?1/0:n.edge;let a=0;if(e=e.filter(d=>!d.error&&!(d.cue.once&&d.hasPlayed)),e.length){this.resolveOffsets(e,t);let d=0,l=0;if(e.forEach((c,u)=>{const h=c.cue.pre,f=c.cue.post,m=e[u-1]||null,p=c.appendInPlace,g=f?r:c.startOffset,y=c.duration,T=c.timelineOccupancy===El.Range?y:0,_=c.resumptionOffset,I=m?.startTime===g,R=g+c.cumulativeDuration;let F=p?R+y:g+_;if(h||!f&&g<=0){const w=l;l+=T,c.timelineStart=R;const P=a;a+=y,i.push({event:c,start:R,end:F,playout:{start:P,end:a},integrated:{start:w,end:l}})}else if(g<=r){if(!I){const k=g-d;if(k>sm){const G=d,se=l;l+=k;const oe=a;a+=k;const de={previousEvent:e[u-1]||null,nextEvent:c,start:G,end:G+k,playout:{start:oe,end:a},integrated:{start:se,end:l}};i.push(de)}else k>0&&m&&(m.cumulativeDuration+=k,i[i.length-1].end=g)}f&&(F=R),c.timelineStart=R;const w=l;l+=T;const P=a;a+=y,i.push({event:c,start:R,end:F,playout:{start:P,end:a},integrated:{start:w,end:l}})}else return;const L=c.resumeTime;f||L>r?d=r:d=L}),d<r){var o;const c=d,u=l,h=r-d;l+=h;const f=a;a+=h,i.push({previousEvent:((o=i[i.length-1])==null?void 0:o.event)||null,nextEvent:null,start:d,end:c+h,playout:{start:f,end:a},integrated:{start:u,end:l}})}this.setDurations(r,a,l)}else i.push({previousEvent:null,nextEvent:null,start:0,end:r,playout:{start:0,end:r},integrated:{start:0,end:r}}),this.setDurations(r,r,r);return i}setDurations(e,t,i){this.durations={primary:e,playout:t,integrated:i}}resolveOffsets(e,t){const i=t.main.details,n=i.live?1/0:i.edge;let r=0,a=-1;e.forEach((o,d)=>{const l=o.cue.pre,c=o.cue.post,u=l?0:c?n:o.startTime;this.updateAssetDurations(o),a===u?o.cumulativeDuration=r:(r=0,a=u),!c&&o.snapOptions.in&&(o.resumeAnchor=Qs(null,i.fragments,o.startOffset+o.resumptionOffset,0,0)||void 0),o.appendInPlace&&!o.appendInPlaceStarted&&(this.primaryCanResumeInPlaceAt(o,t)||(o.appendInPlace=!1)),!o.appendInPlace&&d+1<e.length&&e[d+1].startTime-e[d].resumeTime<sm&&(e[d+1].appendInPlace=!1,e[d+1].appendInPlace&&this.warn(`Could not change append strategy for abutting event ${o}`));const f=he(o.resumeOffset)?o.resumeOffset:o.duration;r+=f})}primaryCanResumeInPlaceAt(e,t){const i=e.resumeTime,n=e.startTime+e.resumptionOffset;return Math.abs(i-n)>Bn?(this.log(`"${e.identifier}" resumption ${i} not aligned with estimated timeline end ${n}`),!1):!Object.keys(t).some(a=>{const o=t[a].details,d=o.edge;if(i>=d)return this.log(`"${e.identifier}" resumption ${i} past ${a} playlist end ${d}`),!1;const l=Qs(null,o.fragments,i);if(!l)return this.log(`"${e.identifier}" resumption ${i} does not align with any fragments in ${a} playlist (${o.fragStart}-${o.fragmentEnd})`),!0;const c=a==="audio"?.175:0;return Math.abs(l.start-i)<Bn+c||Math.abs(l.end-i)<Bn+c?!1:(this.log(`"${e.identifier}" resumption ${i} not aligned with ${a} fragment bounds (${l.start}-${l.end} sn: ${l.sn} cc: ${l.cc})`),!0)})}updateAssetDurations(e){if(!e.assetListLoaded)return;const t=e.timelineStart;let i=0,n=!1,r=!1;for(let a=0;a<e.assetList.length;a++){const o=e.assetList[a],d=t+i;o.startOffset=i,o.timelineStart=d,n||(n=o.duration===null),r||(r=!!o.error);const l=o.error?0:o.duration||0;i+=l}n&&!r?e.duration=Math.max(i,e.duration):e.duration=i}removeEvent(e){e.reset(),delete this.eventMap[e.identifier]}}function vi(s){return`[${s.event?'"'+s.event.identifier+'"':"primary"}: ${s.start.toFixed(2)}-${s.end.toFixed(2)}]`}class HL{constructor(e){this.hls=void 0,this.hls=e}destroy(){this.hls=null}loadAssetList(e,t){const i=e.assetListUrl;let n;try{n=Zv(i,this.hls.sessionId,e.baseUrl)}catch(h){const f=this.assignAssetListError(e,$.ASSET_LIST_LOAD_ERROR,h,i);this.hls.trigger(v.ERROR,f);return}t&&n.protocol!=="data:"&&n.searchParams.set("_HLS_start_offset",""+t);const r=this.hls.config,a=r.loader,o=new a(r),d={responseType:"json",url:n.href},l=r.interstitialAssetListLoadPolicy.default,c={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},u={onSuccess:(h,f,m,p)=>{const g=h.data,y=g?.ASSETS;if(!Array.isArray(y)){const T=this.assignAssetListError(e,$.ASSET_LIST_PARSING_ERROR,new Error("Invalid interstitial asset list"),m.url,f,p);this.hls.trigger(v.ERROR,T);return}e.assetListResponse=g,this.hls.trigger(v.ASSET_LIST_LOADED,{event:e,assetListResponse:g,networkDetails:p})},onError:(h,f,m,p)=>{const g=this.assignAssetListError(e,$.ASSET_LIST_LOAD_ERROR,new Error(`Error loading X-ASSET-LIST: HTTP status ${h.code} ${h.text} (${f.url})`),f.url,p,m);this.hls.trigger(v.ERROR,g)},onTimeout:(h,f,m)=>{const p=this.assignAssetListError(e,$.ASSET_LIST_LOAD_TIMEOUT,new Error(`Timeout loading X-ASSET-LIST (${f.url})`),f.url,h,m);this.hls.trigger(v.ERROR,p)}};return o.load(d,c,u),this.hls.trigger(v.ASSET_LIST_LOADING,{event:e}),o}assignAssetListError(e,t,i,n,r,a){return e.error=i,{type:ye.NETWORK_ERROR,details:t,fatal:!1,interstitial:e,url:n,error:i,networkDetails:a,stats:r}}}function nm(s){var e;s==null||(e=s.play())==null||e.catch(()=>{})}function $a(s,e){return`[${s}] Advancing timeline position to ${e}`}class VL extends pi{constructor(e,t){super("interstitials",e.logger),this.HlsPlayerClass=void 0,this.hls=void 0,this.assetListLoader=void 0,this.mediaSelection=null,this.altSelection=null,this.media=null,this.detachedData=null,this.requiredTracks=null,this.manager=null,this.playerQueue=[],this.bufferedPos=-1,this.timelinePos=-1,this.schedule=void 0,this.playingItem=null,this.bufferingItem=null,this.waitingItem=null,this.endedItem=null,this.playingAsset=null,this.endedAsset=null,this.bufferingAsset=null,this.shouldPlay=!1,this.onPlay=()=>{this.shouldPlay=!0},this.onPause=()=>{this.shouldPlay=!1},this.onSeeking=()=>{const i=this.currentTime;if(i===void 0||this.playbackDisabled||!this.schedule)return;const n=i-this.timelinePos;if(Math.abs(n)<1/7056e5)return;const a=n<=-.01;this.timelinePos=i,this.bufferedPos=i;const o=this.playingItem;if(!o){this.checkBuffer();return}if(a&&this.schedule.resetErrorsInRange(i,i-n)&&this.updateSchedule(!0),this.checkBuffer(),a&&i<o.start||i>=o.end){var d;const f=this.findItemIndex(o);let m=this.schedule.findItemIndexAtTime(i);if(m===-1&&(m=f+(a?-1:1),this.log(`seeked ${a?"back ":""}to position not covered by schedule ${i} (resolving from ${f} to ${m})`)),!this.isInterstitial(o)&&(d=this.media)!=null&&d.paused&&(this.shouldPlay=!1),!a&&m>f){const p=this.schedule.findJumpRestrictedIndex(f+1,m);if(p>f){this.setSchedulePosition(p);return}}this.setSchedulePosition(m);return}const l=this.playingAsset;if(!l){if(this.playingLastItem&&this.isInterstitial(o)){const f=o.event.assetList[0];f&&(this.endedItem=this.playingItem,this.playingItem=null,this.setScheduleToAssetAtTime(i,f))}return}const c=l.timelineStart,u=l.duration||0;if(a&&i<c||i>=c+u){var h;(h=o.event)!=null&&h.appendInPlace&&(this.clearAssetPlayers(o.event,o),this.flushFrontBuffer(i)),this.setScheduleToAssetAtTime(i,l)}},this.onTimeupdate=()=>{const i=this.currentTime;if(i===void 0||this.playbackDisabled)return;if(i>this.timelinePos)this.timelinePos=i,i>this.bufferedPos&&this.checkBuffer();else return;const n=this.playingItem;if(!n||this.playingLastItem)return;if(i>=n.end){this.timelinePos=n.end;const o=this.findItemIndex(n);this.setSchedulePosition(o+1)}const r=this.playingAsset;if(!r)return;const a=r.timelineStart+(r.duration||0);i>=a&&this.setScheduleToAssetAtTime(i,r)},this.onScheduleUpdate=(i,n)=>{const r=this.schedule;if(!r)return;const a=this.playingItem,o=r.events||[],d=r.items||[],l=r.durations,c=i.map(p=>p.identifier),u=!!(o.length||c.length);(u||n)&&this.log(`INTERSTITIALS_UPDATED (${o.length}): ${o} 1512Schedule: ${d.map(p=>vi(p))} pos: ${this.timelinePos}`),c.length&&this.log(`Removed events ${c}`);let h=null,f=null;a&&(h=this.updateItem(a,this.timelinePos),this.itemsMatch(a,h)?this.playingItem=h:this.waitingItem=this.endedItem=null),this.waitingItem=this.updateItem(this.waitingItem),this.endedItem=this.updateItem(this.endedItem);const m=this.bufferingItem;if(m&&(f=this.updateItem(m,this.bufferedPos),this.itemsMatch(m,f)?this.bufferingItem=f:m.event&&(this.bufferingItem=this.playingItem,this.clearInterstitial(m.event,null))),i.forEach(p=>{p.assetList.forEach(g=>{this.clearAssetPlayer(g.identifier,null)})}),this.playerQueue.forEach(p=>{if(p.interstitial.appendInPlace){const g=p.assetItem.timelineStart,y=p.timelineOffset-g;if(y)try{p.timelineOffset=g}catch(T){Math.abs(y)>Bn&&this.warn(`${T} ("${p.assetId}" ${p.timelineOffset}->${g})`)}}}),u||n){if(this.hls.trigger(v.INTERSTITIALS_UPDATED,{events:o.slice(0),schedule:d.slice(0),durations:l,removedIds:c}),this.isInterstitial(a)&&c.includes(a.event.identifier)){this.warn(`Interstitial "${a.event.identifier}" removed while playing`),this.primaryFallback(a.event);return}a&&this.trimInPlace(h,a),m&&f!==h&&this.trimInPlace(f,m),this.checkBuffer()}},this.hls=e,this.HlsPlayerClass=t,this.assetListLoader=new HL(e),this.schedule=new KL(this.onScheduleUpdate,e.logger),this.registerListeners()}registerListeners(){const e=this.hls;e&&(e.on(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(v.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(v.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.on(v.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(v.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.on(v.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.on(v.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.on(v.BUFFER_APPENDED,this.onBufferAppended,this),e.on(v.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(v.BUFFERED_TO_END,this.onBufferedToEnd,this),e.on(v.MEDIA_ENDED,this.onMediaEnded,this),e.on(v.ERROR,this.onError,this),e.on(v.DESTROYING,this.onDestroying,this))}unregisterListeners(){const e=this.hls;e&&(e.off(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(v.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(v.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.off(v.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(v.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.off(v.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.off(v.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.off(v.BUFFER_CODECS,this.onBufferCodecs,this),e.off(v.BUFFER_APPENDED,this.onBufferAppended,this),e.off(v.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(v.BUFFERED_TO_END,this.onBufferedToEnd,this),e.off(v.MEDIA_ENDED,this.onMediaEnded,this),e.off(v.ERROR,this.onError,this),e.off(v.DESTROYING,this.onDestroying,this))}startLoad(){this.resumeBuffering()}stopLoad(){this.pauseBuffering()}resumeBuffering(){var e;(e=this.getBufferingPlayer())==null||e.resumeBuffering()}pauseBuffering(){var e;(e=this.getBufferingPlayer())==null||e.pauseBuffering()}destroy(){this.unregisterListeners(),this.stopLoad(),this.assetListLoader&&this.assetListLoader.destroy(),this.emptyPlayerQueue(),this.clearScheduleState(),this.schedule&&this.schedule.destroy(),this.media=this.detachedData=this.mediaSelection=this.requiredTracks=this.altSelection=this.schedule=this.manager=null,this.hls=this.HlsPlayerClass=this.log=null,this.assetListLoader=null,this.onPlay=this.onPause=this.onSeeking=this.onTimeupdate=null,this.onScheduleUpdate=null}onDestroying(){const e=this.primaryMedia||this.media;e&&this.removeMediaListeners(e)}removeMediaListeners(e){ti(e,"play",this.onPlay),ti(e,"pause",this.onPause),ti(e,"seeking",this.onSeeking),ti(e,"timeupdate",this.onTimeupdate)}onMediaAttaching(e,t){const i=this.media=t.media;jt(i,"seeking",this.onSeeking),jt(i,"timeupdate",this.onTimeupdate),jt(i,"play",this.onPlay),jt(i,"pause",this.onPause)}onMediaAttached(e,t){const i=this.effectivePlayingItem,n=this.detachedData;if(this.detachedData=null,i===null)this.checkStart();else if(!n){this.clearScheduleState();const r=this.findItemIndex(i);this.setSchedulePosition(r)}}clearScheduleState(){this.log("clear schedule state"),this.playingItem=this.bufferingItem=this.waitingItem=this.endedItem=this.playingAsset=this.endedAsset=this.bufferingAsset=null}onMediaDetaching(e,t){const i=!!t.transferMedia,n=this.media;if(this.media=null,!i&&(n&&this.removeMediaListeners(n),this.detachedData)){const r=this.getBufferingPlayer();r&&(this.log(`Removing schedule state for detachedData and ${r}`),this.playingAsset=this.endedAsset=this.bufferingAsset=this.bufferingItem=this.waitingItem=this.detachedData=null,r.detachMedia()),this.shouldPlay=!1}}get interstitialsManager(){if(!this.hls)return null;if(this.manager)return this.manager;const e=this,t=()=>e.bufferingItem||e.waitingItem,i=u=>u&&e.getAssetPlayer(u.identifier),n=(u,h,f,m,p)=>{if(u){let g=u[h].start;const y=u.event;if(y){if(h==="playout"||y.timelineOccupancy!==El.Point){const T=i(f);T?.interstitial===y&&(g+=T.assetItem.startOffset+T[p])}}else{const T=m==="bufferedPos"?a():e[m];g+=T-u.start}return g}return 0},r=(u,h)=>{var f;if(u!==0&&h!=="primary"&&(f=e.schedule)!=null&&f.length){var m;const p=e.schedule.findItemIndexAtTime(u),g=(m=e.schedule.items)==null?void 0:m[p];if(g){const y=g[h].start-g.start;return u+y}}return u},a=()=>{const u=e.bufferedPos;return u===Number.MAX_VALUE?o("primary"):Math.max(u,0)},o=u=>{var h,f;return(h=e.primaryDetails)!=null&&h.live?e.primaryDetails.edge:((f=e.schedule)==null?void 0:f.durations[u])||0},d=(u,h)=>{var f,m;const p=e.effectivePlayingItem;if(p!=null&&(f=p.event)!=null&&f.restrictions.skip||!e.schedule)return;e.log(`seek to ${u} "${h}"`);const g=e.effectivePlayingItem,y=e.schedule.findItemIndexAtTime(u,h),T=(m=e.schedule.items)==null?void 0:m[y],_=e.getBufferingPlayer(),I=_?.interstitial,R=I?.appendInPlace,F=g&&e.itemsMatch(g,T);if(g&&(R||F)){const L=i(e.playingAsset),w=L?.media||e.primaryMedia;if(w){const P=h==="primary"?w.currentTime:n(g,h,e.playingAsset,"timelinePos","currentTime"),k=u-P,G=(R?P:w.currentTime)+k;if(G>=0&&(!L||R||G<=L.duration)){w.currentTime=G;return}}}if(T){let L=u;if(h!=="primary"){const P=T[h].start,k=u-P;L=T.start+k}const w=!e.isInterstitial(T);if((!e.isInterstitial(g)||g.event.appendInPlace)&&(w||T.event.appendInPlace)){const P=e.media||(R?_?.media:null);P&&(P.currentTime=L)}else if(g){const P=e.findItemIndex(g);if(y>P){const G=e.schedule.findJumpRestrictedIndex(P+1,y);if(G>P){e.setSchedulePosition(G);return}}let k=0;if(w)e.timelinePos=L,e.checkBuffer();else{const G=T.event.assetList,se=u-(T[h]||T).start;for(let oe=G.length;oe--;){const de=G[oe];if(de.duration&&se>=de.startOffset&&se<de.startOffset+de.duration){k=oe;break}}}e.setSchedulePosition(y,k)}}},l=()=>{const u=e.effectivePlayingItem;if(e.isInterstitial(u))return u;const h=t();return e.isInterstitial(h)?h:null},c={get bufferedEnd(){const u=t(),h=e.bufferingItem;if(h&&h===u){var f;return n(h,"playout",e.bufferingAsset,"bufferedPos","bufferedEnd")-h.playout.start||((f=e.bufferingAsset)==null?void 0:f.startOffset)||0}return 0},get currentTime(){const u=l(),h=e.effectivePlayingItem;return h&&h===u?n(h,"playout",e.effectivePlayingAsset,"timelinePos","currentTime")-h.playout.start:0},set currentTime(u){const h=l(),f=e.effectivePlayingItem;f&&f===h&&d(u+f.playout.start,"playout")},get duration(){const u=l();return u?u.playout.end-u.playout.start:0},get assetPlayers(){var u;const h=(u=l())==null?void 0:u.event.assetList;return h?h.map(f=>e.getAssetPlayer(f.identifier)):[]},get playingIndex(){var u;const h=(u=l())==null?void 0:u.event;return h&&e.effectivePlayingAsset?h.findAssetIndex(e.effectivePlayingAsset):-1},get scheduleItem(){return l()}};return this.manager={get events(){var u;return((u=e.schedule)==null||(u=u.events)==null?void 0:u.slice(0))||[]},get schedule(){var u;return((u=e.schedule)==null||(u=u.items)==null?void 0:u.slice(0))||[]},get interstitialPlayer(){return l()?c:null},get playerQueue(){return e.playerQueue.slice(0)},get bufferingAsset(){return e.bufferingAsset},get bufferingItem(){return t()},get bufferingIndex(){const u=t();return e.findItemIndex(u)},get playingAsset(){return e.effectivePlayingAsset},get playingItem(){return e.effectivePlayingItem},get playingIndex(){const u=e.effectivePlayingItem;return e.findItemIndex(u)},primary:{get bufferedEnd(){return a()},get currentTime(){const u=e.timelinePos;return u>0?u:0},set currentTime(u){d(u,"primary")},get duration(){return o("primary")},get seekableStart(){var u;return((u=e.primaryDetails)==null?void 0:u.fragmentStart)||0}},integrated:{get bufferedEnd(){return n(t(),"integrated",e.bufferingAsset,"bufferedPos","bufferedEnd")},get currentTime(){return n(e.effectivePlayingItem,"integrated",e.effectivePlayingAsset,"timelinePos","currentTime")},set currentTime(u){d(u,"integrated")},get duration(){return o("integrated")},get seekableStart(){var u;return r(((u=e.primaryDetails)==null?void 0:u.fragmentStart)||0,"integrated")}},skip:()=>{const u=e.effectivePlayingItem,h=u?.event;if(h&&!h.restrictions.skip){const f=e.findItemIndex(u);if(h.appendInPlace){const m=u.playout.start+u.event.duration;d(m+.001,"playout")}else e.advanceAfterAssetEnded(h,f,1/0)}}}}get effectivePlayingItem(){return this.waitingItem||this.playingItem||this.endedItem}get effectivePlayingAsset(){return this.playingAsset||this.endedAsset}get playingLastItem(){var e;const t=this.playingItem,i=(e=this.schedule)==null?void 0:e.items;return!this.playbackStarted||!t||!i?!1:this.findItemIndex(t)===i.length-1}get playbackStarted(){return this.effectivePlayingItem!==null}get currentTime(){var e,t;if(this.mediaSelection===null)return;const i=this.waitingItem||this.playingItem;if(this.isInterstitial(i)&&!i.event.appendInPlace)return;let n=this.media;!n&&(e=this.bufferingItem)!=null&&(e=e.event)!=null&&e.appendInPlace&&(n=this.primaryMedia);const r=(t=n)==null?void 0:t.currentTime;if(!(r===void 0||!he(r)))return r}get primaryMedia(){var e;return this.media||((e=this.detachedData)==null?void 0:e.media)||null}isInterstitial(e){return!!(e!=null&&e.event)}retreiveMediaSource(e,t){const i=this.getAssetPlayer(e);i&&this.transferMediaFromPlayer(i,t)}transferMediaFromPlayer(e,t){const i=e.interstitial.appendInPlace,n=e.media;if(i&&n===this.primaryMedia){if(this.bufferingAsset=null,(!t||this.isInterstitial(t)&&!t.event.appendInPlace)&&t&&n){this.detachedData={media:n};return}const r=e.transferMedia();this.log(`transfer MediaSource from ${e} ${lt(r)}`),this.detachedData=r}else t&&n&&(this.shouldPlay||(this.shouldPlay=!n.paused))}transferMediaTo(e,t){var i,n;if(e.media===t)return;let r=null;const a=this.hls,o=e!==a,d=o&&e.interstitial.appendInPlace,l=(i=this.detachedData)==null?void 0:i.mediaSource;let c;if(a.media)d&&(r=a.transferMedia(),this.detachedData=r),c="Primary";else if(l){const m=this.getBufferingPlayer();m?(r=m.transferMedia(),c=`${m}`):c="detached MediaSource"}else c="detached media";if(!r){if(l)r=this.detachedData,this.log(`using detachedData: MediaSource ${lt(r)}`);else if(!this.detachedData||a.media===t){const m=this.playerQueue;m.length>1&&m.forEach(p=>{if(o&&p.interstitial.appendInPlace!==d){const g=p.interstitial;this.clearInterstitial(p.interstitial,null),g.appendInPlace=!1,g.appendInPlace&&this.warn(`Could not change append strategy for queued assets ${g}`)}}),this.hls.detachMedia(),this.detachedData={media:t}}}const u=r&&"mediaSource"in r&&((n=r.mediaSource)==null?void 0:n.readyState)!=="closed",h=u&&r?r:t;this.log(`${u?"transfering MediaSource":"attaching media"} to ${o?e:"Primary"} from ${c} (media.currentTime: ${t.currentTime})`);const f=this.schedule;if(h===r&&f){const m=o&&e.assetId===f.assetIdAtEnd;h.overrides={duration:f.duration,endOfStream:!o||m,cueRemoval:!o}}e.attachMedia(h)}onInterstitialCueEnter(){this.onTimeupdate()}checkStart(){const e=this.schedule,t=e?.events;if(!t||this.playbackDisabled||!this.media)return;this.bufferedPos===-1&&(this.bufferedPos=0);const i=this.timelinePos,n=this.effectivePlayingItem;if(i===-1){const r=this.hls.startPosition;if(this.log($a("checkStart",r)),this.timelinePos=r,t.length&&t[0].cue.pre){const a=e.findEventIndex(t[0].identifier);this.setSchedulePosition(a)}else if(r>=0||!this.primaryLive){const a=this.timelinePos=r>0?r:0,o=e.findItemIndexAtTime(a);this.setSchedulePosition(o)}}else if(n&&!this.playingItem){const r=e.findItemIndex(n);this.setSchedulePosition(r)}}advanceAssetBuffering(e,t){const i=e.event,n=i.findAssetIndex(t),r=md(i,n);if(!i.isAssetPastPlayoutLimit(r))this.bufferedToEvent(e,r);else if(this.schedule){var a;const o=(a=this.schedule.items)==null?void 0:a[this.findItemIndex(e)+1];o&&this.bufferedToItem(o)}}advanceAfterAssetEnded(e,t,i){const n=md(e,i);if(e.isAssetPastPlayoutLimit(n)){if(this.schedule){const r=this.schedule.items;if(r){const a=t+1,o=r.length;if(a>=o){this.setSchedulePosition(-1);return}const d=e.resumeTime;this.timelinePos<d&&(this.log($a("advanceAfterAssetEnded",d)),this.timelinePos=d,e.appendInPlace&&this.advanceInPlace(d),this.checkBuffer(this.bufferedPos<d)),this.setSchedulePosition(a)}}}else{if(e.appendInPlace){const r=e.assetList[n];r&&this.advanceInPlace(r.timelineStart)}this.setSchedulePosition(t,n)}}setScheduleToAssetAtTime(e,t){const i=this.schedule;if(!i)return;const n=t.parentIdentifier,r=i.getEvent(n);if(r){const a=i.findEventIndex(n),o=i.findAssetIndex(r,e);this.advanceAfterAssetEnded(r,a,o-1)}}setSchedulePosition(e,t){var i;const n=(i=this.schedule)==null?void 0:i.items;if(!n||this.playbackDisabled)return;const r=e>=0?n[e]:null;this.log(`setSchedulePosition ${e}, ${t} (${r&&vi(r)}) pos: ${this.timelinePos}`);const a=this.waitingItem||this.playingItem,o=this.playingLastItem;if(this.isInterstitial(a)){const c=a.event,u=this.playingAsset,h=u?.identifier,f=h?this.getAssetPlayer(h):null;if(f&&h&&(!this.eventItemsMatch(a,r)||t!==void 0&&h!==c.assetList[t].identifier)){var d;const m=c.findAssetIndex(u);if(this.log(`INTERSTITIAL_ASSET_ENDED ${m+1}/${c.assetList.length} ${Rn(u)}`),this.endedAsset=u,this.playingAsset=null,this.hls.trigger(v.INTERSTITIAL_ASSET_ENDED,{asset:u,assetListIndex:m,event:c,schedule:n.slice(0),scheduleIndex:e,player:f}),a!==this.playingItem){this.itemsMatch(a,this.playingItem)&&!this.playingAsset&&this.advanceAfterAssetEnded(c,this.findItemIndex(this.playingItem),m);return}this.retreiveMediaSource(h,r),f.media&&!((d=this.detachedData)!=null&&d.mediaSource)&&f.detachMedia()}if(!this.eventItemsMatch(a,r)&&(this.endedItem=a,this.playingItem=null,this.log(`INTERSTITIAL_ENDED ${c} ${vi(a)}`),c.hasPlayed=!0,this.hls.trigger(v.INTERSTITIAL_ENDED,{event:c,schedule:n.slice(0),scheduleIndex:e}),c.cue.once)){var l;this.updateSchedule();const m=(l=this.schedule)==null?void 0:l.items;if(r&&m){const p=this.findItemIndex(r);this.advanceSchedule(p,m,t,a,o)}return}}this.advanceSchedule(e,n,t,a,o)}advanceSchedule(e,t,i,n,r){const a=this.schedule;if(!a)return;const o=t[e]||null,d=this.primaryMedia,l=this.playerQueue;if(l.length&&l.forEach(c=>{const u=c.interstitial,h=a.findEventIndex(u.identifier);(h<e||h>e+1)&&this.clearInterstitial(u,o)}),this.isInterstitial(o)){this.timelinePos=Math.min(Math.max(this.timelinePos,o.start),o.end);const c=o.event;if(i===void 0){i=a.findAssetIndex(c,this.timelinePos);const m=md(c,i-1);if(c.isAssetPastPlayoutLimit(m)||c.appendInPlace&&this.timelinePos===o.end){this.advanceAfterAssetEnded(c,e,i);return}i=m}const u=this.waitingItem;this.assetsBuffered(o,d)||this.setBufferingItem(o);let h=this.preloadAssets(c,i);if(this.eventItemsMatch(o,u||n)||(this.waitingItem=o,this.log(`INTERSTITIAL_STARTED ${vi(o)} ${c.appendInPlace?"append in place":""}`),this.hls.trigger(v.INTERSTITIAL_STARTED,{event:c,schedule:t.slice(0),scheduleIndex:e})),!c.assetListLoaded){this.log(`Waiting for ASSET-LIST to complete loading ${c}`);return}if(c.assetListLoader&&(c.assetListLoader.destroy(),c.assetListLoader=void 0),!d){this.log(`Waiting for attachMedia to start Interstitial ${c}`);return}this.waitingItem=this.endedItem=null,this.playingItem=o;const f=c.assetList[i];if(!f){this.advanceAfterAssetEnded(c,e,i||0);return}if(h||(h=this.getAssetPlayer(f.identifier)),h===null||h.destroyed){const m=c.assetList.length;this.warn(`asset ${i+1}/${m} player destroyed ${c}`),h=this.createAssetPlayer(c,f,i),h.loadSource()}if(!this.eventItemsMatch(o,this.bufferingItem)&&c.appendInPlace&&this.isAssetBuffered(f))return;this.startAssetPlayer(h,i,t,e,d),this.shouldPlay&&nm(h.media)}else o?(this.resumePrimary(o,e,n),this.shouldPlay&&nm(this.hls.media)):r&&this.isInterstitial(n)&&(this.endedItem=null,this.playingItem=n,n.event.appendInPlace||this.attachPrimary(a.durations.primary,null))}get playbackDisabled(){return this.hls.config.enableInterstitialPlayback===!1}get primaryDetails(){var e;return(e=this.mediaSelection)==null?void 0:e.main.details}get primaryLive(){var e;return!!((e=this.primaryDetails)!=null&&e.live)}resumePrimary(e,t,i){var n,r;if(this.playingItem=e,this.playingAsset=this.endedAsset=null,this.waitingItem=this.endedItem=null,this.bufferedToItem(e),this.log(`resuming ${vi(e)}`),!((n=this.detachedData)!=null&&n.mediaSource)){let o=this.timelinePos;(o<e.start||o>=e.end)&&(o=this.getPrimaryResumption(e,t),this.log($a("resumePrimary",o)),this.timelinePos=o),this.attachPrimary(o,e)}if(!i)return;const a=(r=this.schedule)==null?void 0:r.items;a&&(this.log(`INTERSTITIALS_PRIMARY_RESUMED ${vi(e)}`),this.hls.trigger(v.INTERSTITIALS_PRIMARY_RESUMED,{schedule:a.slice(0),scheduleIndex:t}),this.checkBuffer())}getPrimaryResumption(e,t){const i=e.start;if(this.primaryLive){const n=this.primaryDetails;if(t===0)return this.hls.startPosition;if(n&&(i<n.fragmentStart||i>n.edge))return this.hls.liveSyncPosition||-1}return i}isAssetBuffered(e){const t=this.getAssetPlayer(e.identifier);return t!=null&&t.hls?t.hls.bufferedToEnd:Me.bufferInfo(this.primaryMedia,this.timelinePos,0).end+1>=e.timelineStart+(e.duration||0)}attachPrimary(e,t,i){t?this.setBufferingItem(t):this.bufferingItem=this.playingItem,this.bufferingAsset=null;const n=this.primaryMedia;if(!n)return;const r=this.hls;r.media?this.checkBuffer():(this.transferMediaTo(r,n),i&&this.startLoadingPrimaryAt(e,i)),i||(this.log($a("attachPrimary",e)),this.timelinePos=e,this.startLoadingPrimaryAt(e,i))}startLoadingPrimaryAt(e,t){var i;const n=this.hls;!n.loadingEnabled||!n.media||Math.abs((((i=n.mainForwardBufferInfo)==null?void 0:i.start)||n.media.currentTime)-e)>.5?n.startLoad(e,t):n.bufferingEnabled||n.resumeBuffering()}onManifestLoading(){var e;this.stopLoad(),(e=this.schedule)==null||e.reset(),this.emptyPlayerQueue(),this.clearScheduleState(),this.shouldPlay=!1,this.bufferedPos=this.timelinePos=-1,this.mediaSelection=this.altSelection=this.manager=this.requiredTracks=null,this.hls.off(v.BUFFER_CODECS,this.onBufferCodecs,this),this.hls.on(v.BUFFER_CODECS,this.onBufferCodecs,this)}onLevelUpdated(e,t){if(t.level===-1||!this.schedule)return;const i=this.hls.levels[t.level];if(!i.details)return;const n=Je(Je({},this.mediaSelection||this.altSelection),{},{main:i});this.mediaSelection=n,this.schedule.parseInterstitialDateRanges(n,this.hls.config.interstitialAppendInPlace),!this.effectivePlayingItem&&this.schedule.items&&this.checkStart()}onAudioTrackUpdated(e,t){const i=this.hls.audioTracks[t.id],n=this.mediaSelection;if(!n){this.altSelection=Je(Je({},this.altSelection),{},{audio:i});return}const r=Je(Je({},n),{},{audio:i});this.mediaSelection=r}onSubtitleTrackUpdated(e,t){const i=this.hls.subtitleTracks[t.id],n=this.mediaSelection;if(!n){this.altSelection=Je(Je({},this.altSelection),{},{subtitles:i});return}const r=Je(Je({},n),{},{subtitles:i});this.mediaSelection=r}onAudioTrackSwitching(e,t){const i=ff(t);this.playerQueue.forEach(({hls:n})=>n&&(n.setAudioOption(t)||n.setAudioOption(i)))}onSubtitleTrackSwitch(e,t){const i=ff(t);this.playerQueue.forEach(({hls:n})=>n&&(n.setSubtitleOption(t)||t.id!==-1&&n.setSubtitleOption(i)))}onBufferCodecs(e,t){const i=t.tracks;i&&(this.requiredTracks=i)}onBufferAppended(e,t){this.checkBuffer()}onBufferFlushed(e,t){const i=this.playingItem;if(i&&!this.itemsMatch(i,this.bufferingItem)&&!this.isInterstitial(i)){const n=this.timelinePos;this.bufferedPos=n,this.checkBuffer()}}onBufferedToEnd(e){if(!this.schedule)return;const t=this.schedule.events;if(this.bufferedPos<Number.MAX_VALUE&&t){for(let n=0;n<t.length;n++){const r=t[n];if(r.cue.post){var i;const a=this.schedule.findEventIndex(r.identifier),o=(i=this.schedule.items)==null?void 0:i[a];this.isInterstitial(o)&&this.eventItemsMatch(o,this.bufferingItem)&&this.bufferedToItem(o,0);break}}this.bufferedPos=Number.MAX_VALUE}}onMediaEnded(e){const t=this.playingItem;if(!this.playingLastItem&&t){const i=this.findItemIndex(t);this.setSchedulePosition(i+1)}else this.shouldPlay=!1}updateItem(e,t){var i;const n=(i=this.schedule)==null?void 0:i.items;if(e&&n){const r=this.findItemIndex(e,t);return n[r]||null}return null}trimInPlace(e,t){if(this.isInterstitial(e)&&e.event.appendInPlace&&t.end-e.end>.25){e.event.assetList.forEach((r,a)=>{e.event.isAssetPastPlayoutLimit(a)&&this.clearAssetPlayer(r.identifier,null)});const i=e.end+.25,n=Me.bufferInfo(this.primaryMedia,i,0);(n.end>i||(n.nextStart||0)>i)&&(this.log(`trim buffered interstitial ${vi(e)} (was ${vi(t)})`),this.attachPrimary(i,null,!0),this.flushFrontBuffer(i))}}itemsMatch(e,t){return!!t&&(e===t||e.event&&t.event&&this.eventItemsMatch(e,t)||!e.event&&!t.event&&this.findItemIndex(e)===this.findItemIndex(t))}eventItemsMatch(e,t){var i;return!!t&&(e===t||e.event.identifier===((i=t.event)==null?void 0:i.identifier))}findItemIndex(e,t){return e&&this.schedule?this.schedule.findItemIndex(e,t):-1}updateSchedule(e=!1){var t;const i=this.mediaSelection;i&&((t=this.schedule)==null||t.updateSchedule(i,[],e))}checkBuffer(e){var t;const i=(t=this.schedule)==null?void 0:t.items;if(!i)return;const n=Me.bufferInfo(this.primaryMedia,this.timelinePos,0);e&&(this.bufferedPos=this.timelinePos),e||(e=n.len<1),this.updateBufferedPos(n.end,i,e)}updateBufferedPos(e,t,i){const n=this.schedule,r=this.bufferingItem;if(this.bufferedPos>e||!n)return;if(t.length===1&&this.itemsMatch(t[0],r)){this.bufferedPos=e;return}const a=this.playingItem,o=this.findItemIndex(a);let d=n.findItemIndexAtTime(e);if(this.bufferedPos<e){var l;const c=this.findItemIndex(r),u=Math.min(c+1,t.length-1),h=t[u];if((d===-1&&r&&e>=r.end||(l=h.event)!=null&&l.appendInPlace&&e+.01>=h.start)&&(d=u),this.isInterstitial(r)){const f=r.event;if(u-o>1&&f.appendInPlace===!1||f.assetList.length===0&&f.assetListLoader)return}if(this.bufferedPos=e,d>c&&d>o)this.bufferedToItem(h);else{const f=this.primaryDetails;this.primaryLive&&f&&e>f.edge-f.targetduration&&h.start<f.edge+this.hls.config.interstitialLiveLookAhead&&this.isInterstitial(h)&&this.preloadAssets(h.event,0)}}else i&&a&&!this.itemsMatch(a,r)&&(d===o?this.bufferedToItem(a):d===o+1&&this.bufferedToItem(t[d]))}assetsBuffered(e,t){return e.event.assetList.length===0?!1:!e.event.assetList.some(n=>{const r=this.getAssetPlayer(n.identifier);return!(r!=null&&r.bufferedInPlaceToEnd(t))})}setBufferingItem(e){const t=this.bufferingItem,i=this.schedule;if(!this.itemsMatch(e,t)&&i){const{items:n,events:r}=i;if(!n||!r)return t;const a=this.isInterstitial(e),o=this.getBufferingPlayer();this.bufferingItem=e,this.bufferedPos=Math.max(e.start,Math.min(e.end,this.timelinePos));const d=o?o.remaining:t?t.end-this.timelinePos:0;if(this.log(`INTERSTITIALS_BUFFERED_TO_BOUNDARY ${vi(e)}`+(t?` (${d.toFixed(2)} remaining)`:"")),!this.playbackDisabled)if(a){const l=i.findAssetIndex(e.event,this.bufferedPos);e.event.assetList.forEach((c,u)=>{const h=this.getAssetPlayer(c.identifier);h&&(u===l&&h.loadSource(),h.resumeBuffering())})}else this.hls.resumeBuffering(),this.playerQueue.forEach(l=>l.pauseBuffering());this.hls.trigger(v.INTERSTITIALS_BUFFERED_TO_BOUNDARY,{events:r.slice(0),schedule:n.slice(0),bufferingIndex:this.findItemIndex(e),playingIndex:this.findItemIndex(this.playingItem)})}else this.bufferingItem!==e&&(this.bufferingItem=e);return t}bufferedToItem(e,t=0){const i=this.setBufferingItem(e);if(!this.playbackDisabled){if(this.isInterstitial(e))this.bufferedToEvent(e,t);else if(i!==null){this.bufferingAsset=null;const n=this.detachedData;n?n.mediaSource?this.attachPrimary(e.start,e,!0):this.preloadPrimary(e):this.preloadPrimary(e)}}}preloadPrimary(e){const t=this.findItemIndex(e),i=this.getPrimaryResumption(e,t);this.startLoadingPrimaryAt(i)}bufferedToEvent(e,t){const i=e.event,n=i.assetList.length===0&&!i.assetListLoader,r=i.cue.once;if(n||!r){const a=this.preloadAssets(i,t);if(a!=null&&a.interstitial.appendInPlace){const o=this.primaryMedia;o&&this.bufferAssetPlayer(a,o)}}}preloadAssets(e,t){const i=e.assetUrl,n=e.assetList.length,r=n===0&&!e.assetListLoader,a=e.cue.once;if(r){const d=e.timelineStart;if(e.appendInPlace){var o;const h=this.playingItem;!this.isInterstitial(h)&&(h==null||(o=h.nextEvent)==null?void 0:o.identifier)===e.identifier&&this.flushFrontBuffer(d+.25)}let l,c=0;if(!this.playingItem&&this.primaryLive&&(c=this.hls.startPosition,c===-1&&(c=this.hls.liveSyncPosition||0)),c&&!(e.cue.pre||e.cue.post)){const h=c-d;h>0&&(l=Math.round(h*1e3)/1e3)}if(this.log(`Load interstitial asset ${t+1}/${i?1:n} ${e}${l?` live-start: ${c} start-offset: ${l}`:""}`),i)return this.createAsset(e,0,0,d,e.duration,i);const u=this.assetListLoader.loadAssetList(e,l);u&&(e.assetListLoader=u)}else if(!a&&n){for(let l=t;l<n;l++){const c=e.assetList[l],u=this.getAssetPlayerQueueIndex(c.identifier);(u===-1||this.playerQueue[u].destroyed)&&!c.error&&this.createAssetPlayer(e,c,l)}const d=e.assetList[t];if(d){const l=this.getAssetPlayer(d.identifier);return l&&l.loadSource(),l}}return null}flushFrontBuffer(e){const t=this.requiredTracks;if(!t)return;this.log(`Removing front buffer starting at ${e}`),Object.keys(t).forEach(n=>{this.hls.trigger(v.BUFFER_FLUSHING,{startOffset:e,endOffset:1/0,type:n})})}getAssetPlayerQueueIndex(e){const t=this.playerQueue;for(let i=0;i<t.length;i++)if(e===t[i].assetId)return i;return-1}getAssetPlayer(e){const t=this.getAssetPlayerQueueIndex(e);return this.playerQueue[t]||null}getBufferingPlayer(){const{playerQueue:e,primaryMedia:t}=this;if(t){for(let i=0;i<e.length;i++)if(e[i].media===t)return e[i]}return null}createAsset(e,t,i,n,r,a){const o={parentIdentifier:e.identifier,identifier:NL(e,a,t),duration:r,startOffset:i,timelineStart:n,uri:a};return this.createAssetPlayer(e,o,t)}createAssetPlayer(e,t,i){const n=this.hls,r=n.userConfig;let a=r.videoPreference;const o=n.loadLevelObj||n.levels[n.currentLevel];(a||o)&&(a=nt({},a),o.videoCodec&&(a.videoCodec=o.videoCodec),o.videoRange&&(a.allowedVideoRanges=[o.videoRange]));const d=n.audioTracks[n.audioTrack],l=n.subtitleTracks[n.subtitleTrack];let c=0;if(this.primaryLive||e.appendInPlace){const I=this.timelinePos-t.timelineStart;if(I>1){const R=t.duration;R&&I<R&&(c=I)}}const u=t.identifier,h=Je(Je({},r),{},{maxMaxBufferLength:Math.min(180,n.config.maxMaxBufferLength),autoStartLoad:!0,startFragPrefetch:!0,primarySessionId:n.sessionId,assetPlayerId:u,abrEwmaDefaultEstimate:n.bandwidthEstimate,interstitialsController:void 0,startPosition:c,liveDurationInfinity:!1,testBandwidth:!1,videoPreference:a,audioPreference:d||r.audioPreference,subtitlePreference:l||r.subtitlePreference});e.appendInPlace&&(e.appendInPlaceStarted=!0,t.timelineStart&&(h.timelineOffset=t.timelineStart));const f=h.cmcd;f!=null&&f.sessionId&&f.contentId&&(h.cmcd=nt({},f,{contentId:Dr(t.uri)})),this.getAssetPlayer(u)&&this.warn(`Duplicate date range identifier ${e} and asset ${u}`);const m=new GL(this.HlsPlayerClass,h,e,t);this.playerQueue.push(m),e.assetList[i]=t;let p=!0;const g=I=>{if(I.live){var R;const w=new Error(`Interstitials MUST be VOD assets ${e}`),P={fatal:!0,type:ye.OTHER_ERROR,details:$.INTERSTITIAL_ASSET_ITEM_ERROR,error:w},k=((R=this.schedule)==null?void 0:R.findEventIndex(e.identifier))||-1;this.handleAssetItemError(P,e,k,i,w.message);return}const F=I.edge-I.fragmentStart,L=t.duration;(p||L===null||F>L)&&(p=!1,this.log(`Interstitial asset "${u}" duration change ${L} > ${F}`),t.duration=F,this.updateSchedule())};m.on(v.LEVEL_UPDATED,(I,{details:R})=>g(R)),m.on(v.LEVEL_PTS_UPDATED,(I,{details:R})=>g(R)),m.on(v.EVENT_CUE_ENTER,()=>this.onInterstitialCueEnter());const y=(I,R)=>{const F=this.getAssetPlayer(u);if(F&&R.tracks){F.off(v.BUFFER_CODECS,y),F.tracks=R.tracks;const L=this.primaryMedia;this.bufferingAsset===F.assetItem&&L&&!F.media&&this.bufferAssetPlayer(F,L)}};m.on(v.BUFFER_CODECS,y);const T=()=>{var I;const R=this.getAssetPlayer(u);if(this.log(`buffered to end of asset ${R}`),!R||!this.schedule)return;const F=this.schedule.findEventIndex(e.identifier),L=(I=this.schedule.items)==null?void 0:I[F];this.isInterstitial(L)&&this.advanceAssetBuffering(L,t)};m.on(v.BUFFERED_TO_END,T);const _=I=>()=>{if(!this.getAssetPlayer(u)||!this.schedule)return;this.shouldPlay=!0;const F=this.schedule.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,F,I)};return m.once(v.MEDIA_ENDED,_(i)),m.once(v.PLAYOUT_LIMIT_REACHED,_(1/0)),m.on(v.ERROR,(I,R)=>{if(!this.schedule)return;const F=this.getAssetPlayer(u);if(R.details===$.BUFFER_STALLED_ERROR){if(F!=null&&F.appendInPlace){this.handleInPlaceStall(e);return}this.onTimeupdate(),this.checkBuffer(!0);return}this.handleAssetItemError(R,e,this.schedule.findEventIndex(e.identifier),i,`Asset player error ${R.error} ${e}`)}),m.on(v.DESTROYING,()=>{if(!this.getAssetPlayer(u)||!this.schedule)return;const R=new Error(`Asset player destroyed unexpectedly ${u}`),F={fatal:!0,type:ye.OTHER_ERROR,details:$.INTERSTITIAL_ASSET_ITEM_ERROR,error:R};this.handleAssetItemError(F,e,this.schedule.findEventIndex(e.identifier),i,R.message)}),this.log(`INTERSTITIAL_ASSET_PLAYER_CREATED ${Rn(t)}`),this.hls.trigger(v.INTERSTITIAL_ASSET_PLAYER_CREATED,{asset:t,assetListIndex:i,event:e,player:m}),m}clearInterstitial(e,t){this.clearAssetPlayers(e,t),e.reset()}clearAssetPlayers(e,t){e.assetList.forEach(i=>{this.clearAssetPlayer(i.identifier,t)})}resetAssetPlayer(e){const t=this.getAssetPlayerQueueIndex(e);if(t!==-1){this.log(`reset asset player "${e}" after error`);const i=this.playerQueue[t];this.transferMediaFromPlayer(i,null),i.resetDetails()}}clearAssetPlayer(e,t){const i=this.getAssetPlayerQueueIndex(e);if(i!==-1){const n=this.playerQueue[i];this.log(`clear ${n} toSegment: ${t&&vi(t)}`),this.transferMediaFromPlayer(n,t),this.playerQueue.splice(i,1),n.destroy()}}emptyPlayerQueue(){let e;for(;e=this.playerQueue.pop();)e.destroy();this.playerQueue=[]}startAssetPlayer(e,t,i,n,r){const{interstitial:a,assetItem:o,assetId:d}=e,l=a.assetList.length,c=this.playingAsset;this.endedAsset=null,this.playingAsset=o,(!c||c.identifier!==d)&&(c&&(this.clearAssetPlayer(c.identifier,i[n]),delete c.error),this.log(`INTERSTITIAL_ASSET_STARTED ${t+1}/${l} ${Rn(o)}`),this.hls.trigger(v.INTERSTITIAL_ASSET_STARTED,{asset:o,assetListIndex:t,event:a,schedule:i.slice(0),scheduleIndex:n,player:e})),this.bufferAssetPlayer(e,r)}bufferAssetPlayer(e,t){var i,n;if(!this.schedule)return;const{interstitial:r,assetItem:a}=e,o=this.schedule.findEventIndex(r.identifier),d=(i=this.schedule.items)==null?void 0:i[o];if(!d)return;e.loadSource(),this.setBufferingItem(d),this.bufferingAsset=a;const l=this.getBufferingPlayer();if(l===e)return;const c=r.appendInPlace;if(c&&l?.interstitial.appendInPlace===!1)return;const u=l?.tracks||((n=this.detachedData)==null?void 0:n.tracks)||this.requiredTracks;if(c&&a!==this.playingAsset){if(!e.tracks){this.log(`Waiting for track info before buffering ${e}`);return}if(u&&!Mp(u,e.tracks)){const h=new Error(`Asset ${Rn(a)} SourceBuffer tracks ('${Object.keys(e.tracks)}') are not compatible with primary content tracks ('${Object.keys(u)}')`),f={fatal:!0,type:ye.OTHER_ERROR,details:$.INTERSTITIAL_ASSET_ITEM_ERROR,error:h},m=r.findAssetIndex(a);this.handleAssetItemError(f,r,o,m,h.message);return}}this.transferMediaTo(e,t)}handleInPlaceStall(e){const t=this.schedule,i=this.primaryMedia;if(!t||!i)return;
1512const n=i.currentTime,r=t.findAssetIndex(e,n),a=e.assetList[r];if(a){const o=this.getAssetPlayer(a.identifier);if(o){const d=o.currentTime||n-a.timelineStart,l=o.duration-d;if(this.warn(`Stalled at ${d} of ${d+l} in ${o} ${e} (media.currentTime: ${n})`),d&&(l/i.playbackRate<.5||o.bufferedInPlaceToEnd(i))&&o.hls){const c=t.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,c,r)}}}}advanceInPlace(e){const t=this.primaryMedia;t&&t.currentTime<e&&(t.currentTime=e)}handleAssetItemError(e,t,i,n,r){if(e.details===$.BUFFER_STALLED_ERROR)return;const a=t.assetList[n]||null;if(this.warn(`INTERSTITIAL_ASSET_ERROR ${a&&Rn(a)} ${e.error}`),!this.schedule)return;const o=a?.identifier||"",d=this.getAssetPlayerQueueIndex(o),l=this.playerQueue[d]||null,c=this.schedule.items,u=nt({},e,{fatal:!1,errorAction:$n(!0),asset:a,assetListIndex:n,event:t,schedule:c,scheduleIndex:i,player:l});if(this.hls.trigger(v.INTERSTITIAL_ASSET_ERROR,u),!e.fatal)return;const h=this.playingAsset,f=this.bufferingAsset,m=new Error(r);if(a&&(this.clearAssetPlayer(o,null),a.error=m),!t.assetList.some(p=>!p.error))t.error=m;else for(let p=n;p<t.assetList.length;p++)this.resetAssetPlayer(t.assetList[p].identifier);this.updateSchedule(!0),t.error?this.primaryFallback(t):h&&h.identifier===o?this.advanceAfterAssetEnded(t,i,n):f&&f.identifier===o&&this.isInterstitial(this.bufferingItem)&&this.advanceAssetBuffering(this.bufferingItem,f)}primaryFallback(e){const t=e.timelineStart,i=this.effectivePlayingItem;let n=this.timelinePos;if(i){this.log(`Fallback to primary from event "${e.identifier}" start: ${t} pos: ${n} playing: ${vi(i)} error: ${e.error}`),n===-1&&(n=this.hls.startPosition);const a=this.updateItem(i,n);this.itemsMatch(i,a)&&this.clearInterstitial(e,null),e.appendInPlace&&(this.attachPrimary(t,null),this.flushFrontBuffer(t))}else if(n===-1){this.checkStart();return}if(!this.schedule)return;const r=this.schedule.findItemIndexAtTime(n);this.setSchedulePosition(r)}onAssetListLoaded(e,t){var i,n;const r=t.event,a=r.identifier,o=t.assetListResponse.ASSETS;if(!((i=this.schedule)!=null&&i.hasEvent(a)))return;const d=r.timelineStart,l=r.duration;let c=0;o.forEach((p,g)=>{const y=parseFloat(p.DURATION);this.createAsset(r,g,c,d+c,y,p.URI),c+=y}),r.duration=c,this.log(`Loaded asset-list with duration: ${c} (was: ${l}) ${r}`);const u=this.waitingItem,h=u?.event.identifier===a;this.updateSchedule();const f=(n=this.bufferingItem)==null?void 0:n.event;if(h){var m;const p=this.schedule.findEventIndex(a),g=(m=this.schedule.items)==null?void 0:m[p];if(g){if(!this.playingItem&&this.timelinePos>g.end&&this.schedule.findItemIndexAtTime(this.timelinePos)!==p){r.error=new Error(`Interstitial ${o.length?"no longer within playback range":"asset-list is empty"} ${this.timelinePos} ${r}`),this.log(r.error.message),this.updateSchedule(!0),this.primaryFallback(r);return}this.setBufferingItem(g)}this.setSchedulePosition(p)}else if(f?.identifier===a){const p=r.assetList[0];if(p){const g=this.getAssetPlayer(p.identifier);if(f.appendInPlace){const y=this.primaryMedia;g&&y&&this.bufferAssetPlayer(g,y)}else g&&g.loadSource()}}}onError(e,t){if(this.schedule)switch(t.details){case $.ASSET_LIST_PARSING_ERROR:case $.ASSET_LIST_LOAD_ERROR:case $.ASSET_LIST_LOAD_TIMEOUT:{const i=t.interstitial;i&&(this.updateSchedule(!0),this.primaryFallback(i));break}case $.BUFFER_STALLED_ERROR:{const i=this.endedItem||this.waitingItem||this.playingItem;if(this.isInterstitial(i)&&i.event.appendInPlace){this.handleInPlaceStall(i.event);return}this.log(`Primary player stall @${this.timelinePos} bufferedPos: ${this.bufferedPos}`),this.onTimeupdate(),this.checkBuffer(!0);break}}}}const rm=500;class WL extends $u{constructor(e,t,i){super(e,t,i,"subtitle-stream-controller",ge.SUBTITLE),this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this.registerListeners()}onHandlerDestroying(){this.unregisterListeners(),super.onHandlerDestroying(),this.mainDetails=null}registerListeners(){super.registerListeners();const{hls:e}=this;e.on(v.LEVEL_LOADED,this.onLevelLoaded,this),e.on(v.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUp
vendor: 4,133 bytes, line 1512
1512dated,this),e.on(v.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(v.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(v.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(v.BUFFER_FLUSHING,this.onBufferFlushing,this)}unregisterListeners(){super.unregisterListeners();const{hls:e}=this;e.off(v.LEVEL_LOADED,this.onLevelLoaded,this),e.off(v.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(v.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(v.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(v.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(v.BUFFER_FLUSHING,this.onBufferFlushing,this)}startLoad(e,t){this.stopLoad(),this.state=W.IDLE,this.setInterval(rm),this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}onManifestLoading(){super.onManifestLoading(),this.mainDetails=null}onMediaDetaching(e,t){this.tracksBuffered=[],super.onMediaDetaching(e,t)}onLevelLoaded(e,t){this.mainDetails=t.details}onSubtitleFragProcessed(e,t){const{frag:i,success:n}=t;if(this.fragContextChanged(i)||(yt(i)&&(this.fragPrevious=i),this.state=W.IDLE),!n)return;const r=this.tracksBuffered[this.currentTrackId];if(!r)return;let a;const o=i.start;for(let l=0;l<r.length;l++)if(o>=r[l].start&&o<=r[l].end){a=r[l];break}const d=i.start+i.duration;a?a.end=d:(a={start:o,end:d},r.push(a)),this.fragmentTracker.fragBuffered(i),this.fragBufferedComplete(i,null),this.media&&this.tick()}onBufferFlushing(e,t){const{startOffset:i,endOffset:n}=t;if(i===0&&n!==Number.POSITIVE_INFINITY){const r=n-1;if(r<=0)return;t.endOffsetSubtitles=Math.max(0,r),this.tracksBuffered.forEach(a=>{for(let o=0;o<a.length;){if(a[o].end<=r){a.shift();continue}else if(a[o].start<r)a[o].start=r;else break;o++}}),this.fragmentTracker.removeFragmentsInRange(i,r,ge.SUBTITLE)}}onError(e,t){const i=t.frag;i?.type===ge.SUBTITLE&&(t.details===$.FRAG_GAP&&this.fragmentTracker.fragBuffered(i,!0),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==W.STOPPED&&(this.state=W.IDLE))}onSubtitleTracksUpdated(e,{subtitleTracks:t}){if(this.levels&&$v(this.levels,t)){this.levels=t.map(i=>new Vr(i));return}this.tracksBuffered=[],this.levels=t.map(i=>{const n=new Vr(i);return this.tracksBuffered[n.id]=[],n}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,ge.SUBTITLE),this.fragPrevious=null,this.mediaBuffer=null}onSubtitleTrackSwitch(e,t){var i;if(this.currentTrackId=t.id,!((i=this.levels)!=null&&i.length)||this.currentTrackId===-1){this.clearInterval();return}const n=this.levels[this.currentTrackId];n!=null&&n.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,n&&this.state!==W.STOPPED&&this.setInterval(rm)}onSubtitleTrackLoaded(e,t){var i;const{currentTrackId:n,levels:r}=this,{details:a,id:o}=t;if(!r){this.warn(`Subtitle tracks were reset while loading level ${o}`);return}const d=r[o];if(o>=r.length||!d)return;this.log(`Subtitle track ${o} loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""},duration:${a.totalduration}`),this.mediaBuffer=this.mediaBufferTimeRanges;let l=0;if(a.live||(i=d.details)!=null&&i.live){if(a.deltaUpdateFailed)return;const u=this.mainDetails;if(!u){this.startFragRequested=!1;return}const h=u.fragments[0];if(!d.details)a.hasProgramDateTime&&u.hasProgramDateTime?(pl(a,u),l=a.fragmentStart):h&&(l=h.start,$c(a,l));else{var c;l=this.alignPlaylists(a,d.details,(c=this.levelLastLoaded)==null?void 0:c.details),l===0&&h&&(l=h.start,$c(a,l))}u&&!this.startFragRequested&&this.setStartPosition(u,l)}d.details=a,this.levelLastLoaded=d,o===n&&(this.hls.trigger(v.SUBTITLE_TRACK_UPDATED,{details:a,id:o,groupId:t.groupId}),this.tick(),a.live&&!this.fragCurrent&&this.media&&this.state===W.IDLE&&(Qs(null,a.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),d.details=void 0)))}_handleFragmentLoadComplete(e){const{frag:t,payload:i}=e,n=t.decryptdata,r=this.hls;if(!this.fragContextChanged(t)&&i&&i.byteLength>0&&n!=null&&n.key&&n.iv&&Nn(n.method)){const a=performance.now();
vendor: 28,989 bytes, lines 1512-1523
1512this.decrypter.decrypt(new Uint8Array(i),n.key.buffer,n.iv.buffer,Ou(n.method)).catch(o=>{throw r.trigger(v.ERROR,{type:ye.MEDIA_ERROR,details:$.FRAG_DECRYPT_ERROR,fatal:!1,error:o,reason:o.message,frag:t}),o}).then(o=>{const d=performance.now();r.trigger(v.FRAG_DECRYPTED,{frag:t,payload:o,stats:{tstart:a,tdecrypt:d}})}).catch(o=>{this.warn(`${o.name}: ${o.message}`),this.state=W.IDLE})}}doTick(){if(!this.media){this.state=W.IDLE;return}if(this.state===W.IDLE){const{currentTrackId:e,levels:t}=this,i=t?.[e];if(!i||!t.length||!i.details||this.waitForLive(i))return;const{config:n}=this,r=this.getLoadPosition(),a=Me.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],r,n.maxBufferHole),{end:o,len:d}=a,l=i.details,c=this.hls.maxBufferLength+l.levelTargetDuration;if(d>c)return;const u=l.fragments,h=u.length,f=l.edge;let m=null;const p=this.fragPrevious;if(o<f){const T=n.maxFragLookUpTolerance,_=o>f-T?0:T;m=Qs(p,u,Math.max(u[0].start,o),_),!m&&p&&p.start<u[0].start&&(m=u[0])}else m=u[h-1];if(m=this.filterReplacedPrimary(m,i.details),!m)return;const g=m.sn-l.startSN,y=u[g-1];if(y&&y.cc===m.cc&&this.fragmentTracker.getState(y)===Rt.NOT_LOADED&&(m=y),this.fragmentTracker.getState(m)===Rt.NOT_LOADED){const T=this.mapToInitFragWhenRequired(m);T&&this.loadFragment(T,i,o)}}}loadFragment(e,t,i){yt(e)?super.loadFragment(e,t,i):this._loadInitSegment(e,t)}get mediaBufferTimeRanges(){return new qL(this.tracksBuffered[this.currentTrackId]||[])}}class qL{constructor(e){this.buffered=void 0;const t=(i,n,r)=>{if(n=n>>>0,n>r-1)throw new DOMException(`Failed to execute '${i}' on 'TimeRanges': The index provided (${n}) is greater than the maximum bound (${r})`);return e[n][i]};this.buffered={get length(){return e.length},end(i){return t("end",i,e.length)},start(i){return t("start",i,e.length)}}}}const YL={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},Jv=s=>String.fromCharCode(YL[s]||s),yi=15,ts=100,zL={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},jL={17:2,18:4,21:6,22:8,23:10,19:13,20:15},XL={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},QL={25:2,26:4,29:6,30:8,31:10,27:13,28:15},ZL=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class JL{constructor(){this.time=null,this.verboseLevel=0}log(e,t){if(this.verboseLevel>=e){const i=typeof t=="function"?t():t;et.log(`${this.time} [${e}] ${i}`)}}}const Ns=function(e){const t=[];for(let i=0;i<e.length;i++)t.push(e[i].toString(16));return t};class e0{constructor(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}reset(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}setStyles(e){const t=["foreground","underline","italics","background","flash"];for(let i=0;i<t.length;i++){const n=t[i];e.hasOwnProperty(n)&&(this[n]=e[n])}}isDefault(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash}equals(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash}copy(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash}toString(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}}class eR{constructor(){this.uchar=" ",this.penState=new e0}reset(){this.uchar=" ",this.penState.reset()}setChar(e,t){this.uchar=e,this.penState.copy(t)}setPenState(e){this.penState.copy(e)}equals(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)}copy(e){this.uchar=e.uchar,this.penState.copy(e.penState)}isEmpty(){return this.uchar===" "&&this.penState.isDefault()}}class tR{constructor(e){this.chars=[],this.pos=0,this.currPenState=new e0,this.cueStartTime=null,this.logger=void 0;for(let t=0;t<ts;t++)this.chars.push(new eR);this.logger=e}equals(e){for(let t=0;t<ts;t++)if(!this.chars[t].equals(e.chars[t]))return!1;return!0}copy(e){for(let t=0;t<ts;t++)this.chars[t].copy(e.chars[t])}isEmpty(){let e=!0;for(let t=0;t<ts;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e}setCursor(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>ts&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=ts)}moveCursor(e){const t=this.pos+e;if(e>1)for(let i=this.pos+1;i<t+1;i++)this.chars[i].setPenState(this.currPenState);this.setCursor(t)}backSpace(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}insertChar(e){e>=144&&this.backSpace();const t=Jv(e);if(this.pos>=ts){this.logger.log(0,()=>"Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1)}clearFromPos(e){let t;for(t=e;t<ts;t++)this.chars[t].reset()}clear(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}clearToEndOfRow(){this.clearFromPos(this.pos)}getTextString(){const e=[];let t=!0;for(let i=0;i<ts;i++){const n=this.chars[i].uchar;n!==" "&&(t=!1),e.push(n)}return t?"":e.join("")}setPenStyles(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)}}class gd{constructor(e){this.rows=[],this.currRow=yi-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(let t=0;t<yi;t++)this.rows.push(new tR(e));this.logger=e}reset(){for(let e=0;e<yi;e++)this.rows[e].clear();this.currRow=yi-1}equals(e){let t=!0;for(let i=0;i<yi;i++)if(!this.rows[i].equals(e.rows[i])){t=!1;break}return t}copy(e){for(let t=0;t<yi;t++)this.rows[t].copy(e.rows[t])}isEmpty(){let e=!0;for(let t=0;t<yi;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e}backSpace(){this.rows[this.currRow].backSpace()}clearToEndOfRow(){this.rows[this.currRow].clearToEndOfRow()}insertChar(e){this.rows[this.currRow].insertChar(e)}setPen(e){this.rows[this.currRow].setPenStyles(e)}moveCursor(e){this.rows[this.currRow].moveCursor(e)}setCursor(e){this.logger.log(2,"setCursor: "+e),this.rows[this.currRow].setCursor(e)}setPAC(e){this.logger.log(2,()=>"pacData = "+lt(e));let t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(let o=0;o<yi;o++)this.rows[o].clear();const r=this.currRow+1-this.nrRollUpRows,a=this.lastOutputScreen;if(a){const o=a.rows[r].cueStartTime,d=this.logger.time;if(o!==null&&d!==null&&o<d)for(let l=0;l<this.nrRollUpRows;l++)this.rows[t-this.nrRollUpRows+l+1].copy(a.rows[r+l])}}this.currRow=t;const i=this.rows[this.currRow];if(e.indent!==null){const r=e.indent,a=Math.max(r-1,0);i.setCursor(e.indent),e.color=i.chars[a].penState.foreground}const n={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(n)}setBkgData(e){this.logger.log(2,()=>"bkgData = "+lt(e)),this.backSpace(),this.setPen(e),this.insertChar(32)}setRollUpRows(e){this.nrRollUpRows=e}rollUp(){if(this.nrRollUpRows===null){this.logger.log(3,"roll_up but nrRollUpRows not set yet");return}this.logger.log(1,()=>this.getDisplayText());const e=this.currRow+1-this.nrRollUpRows,t=this.rows.splice(e,1)[0];t.clear(),this.rows.splice(this.currRow,0,t),this.logger.log(2,"Rolling up")}getDisplayText(e){e=e||!1;const t=[];let i="",n=-1;for(let r=0;r<yi;r++){const a=this.rows[r].getTextString();a&&(n=r+1,e?t.push("Row "+n+": '"+a+"'"):t.push(a.trim()))}return t.length>0&&(e?i="["+t.join(" | ")+"]":i=t.join(` 1513`)),i}getTextAndFormat(){return this.rows}}class am{constructor(e,t,i){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=e,this.outputFilter=t,this.mode=null,this.verbose=0,this.displayedMemory=new gd(i),this.nonDisplayedMemory=new gd(i),this.lastOutputScreen=new gd(i),this.currRollUpRow=this.displayedMemory.rows[yi-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=i}reset(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[yi-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}getHandler(){return this.outputFilter}setHandler(e){this.outputFilter=e}setPAC(e){this.writeScreen.setPAC(e)}setBkgData(e){this.writeScreen.setBkgData(e)}setMode(e){e!==this.mode&&(this.mode=e,this.logger.log(2,()=>"MODE="+e),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)}insertChars(e){for(let i=0;i<e.length;i++)this.writeScreen.insertChar(e[i]);const t=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,()=>t+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(1,()=>"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())}ccRCL(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}ccBS(){this.logger.log(2,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())}ccAOF(){}ccAON(){}ccDER(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}ccRU(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)}ccFON(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}ccRDC(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}ccTR(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}ccRTD(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}ccEDM(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}ccCR(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}ccENM(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}ccEOC(){if(this.logger.log(2,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){const e=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,()=>"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)}ccTO(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)}ccMIDROW(e){const t={flash:!1};if(t.underline=e%2===1,t.italics=e>=46,t.italics)t.foreground="white";else{const i=Math.floor(e/2)-16,n=["white","green","blue","cyan","red","yellow","magenta"];t.foreground=n[i]}this.logger.log(2,"MIDROW: "+lt(t)),this.writeScreen.setPen(t)}outputDataUpdate(e=!1){const t=this.logger.time;t!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=t:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t),this.lastOutputScreen.copy(this.displayedMemory))}cueSplitAtTime(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))}}class om{constructor(e,t,i){this.channels=void 0,this.currentChannel=0,this.cmdHistory=sR(),this.logger=void 0;const n=this.logger=new JL;this.channels=[null,new am(e,t,n),new am(e+1,i,n)]}getHandler(e){return this.channels[e].getHandler()}setHandler(e,t){this.channels[e].setHandler(t)}addData(e,t){this.logger.time=e;for(let i=0;i<t.length;i+=2){const n=t[i]&127,r=t[i+1]&127;let a=!1,o=null;if(n===0&&r===0)continue;this.logger.log(3,()=>"["+Ns([t[i],t[i+1]])+"] -> ("+Ns([n,r])+")");const d=this.cmdHistory;if(n>=16&&n<=31){if(iR(n,r,d)){Na(null,null,d),this.logger.log(3,()=>"Repeated command ("+Ns([n,r])+") is dropped");continue}Na(n,r,this.cmdHistory),a=this.parseCmd(n,r),a||(a=this.parseMidrow(n,r)),a||(a=this.parsePAC(n,r)),a||(a=this.parseBackgroundAttributes(n,r))}else Na(null,null,d);if(!a&&(o=this.parseChars(n,r),o)){const c=this.currentChannel;c&&c>0?this.channels[c].insertChars(o):this.logger.log(2,"No channel found yet. TEXT-MODE?")}!a&&!o&&this.logger.log(2,()=>"Couldn't parse cleaned data "+Ns([n,r])+" orig: "+Ns([t[i],t[i+1]]))}}parseCmd(e,t){const i=(e===20||e===28||e===21||e===29)&&t>=32&&t<=47,n=(e===23||e===31)&&t>=33&&t<=35;if(!(i||n))return!1;const r=e===20||e===21||e===23?1:2,a=this.channels[r];return e===20||e===21||e===28||e===29?t===32?a.ccRCL():t===33?a.ccBS():t===34?a.ccAOF():t===35?a.ccAON():t===36?a.ccDER():t===37?a.ccRU(2):t===38?a.ccRU(3):t===39?a.ccRU(4):t===40?a.ccFON():t===41?a.ccRDC():t===42?a.ccTR():t===43?a.ccRTD():t===44?a.ccEDM():t===45?a.ccCR():t===46?a.ccENM():t===47&&a.ccEOC():a.ccTO(t-32),this.currentChannel=r,!0}parseMidrow(e,t){let i=0;if((e===17||e===25)&&t>=32&&t<=47){if(e===17?i=1:i=2,i!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;const n=this.channels[i];return n?(n.ccMIDROW(t),this.logger.log(3,()=>"MIDROW ("+Ns([e,t])+")"),!0):!1}return!1}parsePAC(e,t){let i;const n=(e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127,r=(e===16||e===24)&&t>=64&&t<=95;if(!(n||r))return!1;const a=e<=23?1:2;t>=64&&t<=95?i=a===1?zL[e]:XL[e]:i=a===1?jL[e]:QL[e];const o=this.channels[a];return o?(o.setPAC(this.interpretPAC(i,t)),this.currentChannel=a,!0):!1}interpretPAC(e,t){let i;const n={color:null,italics:!1,indent:null,underline:!1,row:e};return t>95?i=t-96:i=t-64,n.underline=(i&1)===1,i<=13?n.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(i/2)]:i<=15?(n.italics=!0,n.color="white"):n.indent=Math.floor((i-16)/2)*4,n}parseChars(e,t){let i,n=null,r=null;if(e>=25?(i=2,r=e-8):(i=1,r=e),r>=17&&r<=19){let a;r===17?a=t+80:r===18?a=t+112:a=t+144,this.logger.log(2,()=>"Special char '"+Jv(a)+"' in channel "+i),n=[a]}else e>=32&&e<=127&&(n=t===0?[e]:[e,t]);return n&&this.logger.log(3,()=>"Char codes = "+Ns(n).join(",")),n}parseBackgroundAttributes(e,t){const i=(e===16||e===24)&&t>=32&&t<=47,n=(e===23||e===31)&&t>=45&&t<=47;if(!(i||n))return!1;let r;const a={};e===16||e===24?(r=Math.floor((t-32)/2),a.background=ZL[r],t%2===1&&(a.background=a.background+"_semi")):t===45?a.background="transparent":(a.foreground="black",t===47&&(a.underline=!0));const o=e<=23?1:2;return this.channels[o].setBkgData(a),!0}reset(){for(let e=0;e<Object.keys(this.channels).length;e++){const t=this.channels[e];t&&t.reset()}Na(null,null,this.cmdHistory)}cueSplitAtTime(e){for(let t=0;t<this.channels.length;t++){const i=this.channels[t];i&&i.cueSplitAtTime(e)}}}function Na(s,e,t){t.a=s,t.b=e}function iR(s,e,t){return t.a===s&&t.b===e}function sR(){return{a:null,b:null}}var ju=(function(){if(gl!=null&&gl.VTTCue)return self.VTTCue;const s=["","lr","rl"],e=["start","middle","end","left","right"];function t(o,d){if(typeof d!="string"||!Array.isArray(o))return!1;const l=d.toLowerCase();return~o.indexOf(l)?l:!1}function i(o){return t(s,o)}function n(o){return t(e,o)}function r(o,...d){let l=1;for(;l<arguments.length;l++){const c=arguments[l];for(const u in c)o[u]=c[u]}return o}function a(o,d,l){const c=this,u={enumerable:!0};c.hasBeenReset=!1;let h="",f=!1,m=o,p=d,g=l,y=null,T="",_=!0,I="auto",R="start",F=50,L="middle",w=50,P="middle";Object.defineProperty(c,"id",r({},u,{get:function(){return h},set:function(k){h=""+k}})),Object.defineProperty(c,"pauseOnExit",r({},u,{get:function(){return f},set:function(k){f=!!k}})),Object.defineProperty(c,"startTime",r({},u,{get:function(){return m},set:function(k){if(typeof k!="number")throw new TypeError("Start time must be set to a number.");m=k,this.hasBeenReset=!0}})),Object.defineProperty(c,"endTime",r({},u,{get:function(){return p},set:function(k){if(typeof k!="number")throw new TypeError("End time must be set to a number.");p=k,this.hasBeenReset=!0}})),Object.defineProperty(c,"text",r({},u,{get:function(){return g},set:function(k){g=""+k,this.hasBeenReset=!0}})),Object.defineProperty(c,"region",r({},u,{get:function(){return y},set:function(k){y=k,this.hasBeenReset=!0}})),Object.defineProperty(c,"vertical",r({},u,{get:function(){return T},set:function(k){const G=i(k);if(G===!1)throw new SyntaxError("An invalid or illegal string was specified.");T=G,this.hasBeenReset=!0}})),Object.defineProperty(c,"snapToLines",r({},u,{get:function(){return _},set:function(k){_=!!k,this.hasBeenReset=!0}})),Object.defineProperty(c,"line",r({},u,{get:function(){return I},set:function(k){if(typeof k!="number"&&k!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");I=k,this.hasBeenReset=!0}})),Object.defineProperty(c,"lineAlign",r({},u,{get:function(){return R},set:function(k){const G=n(k);if(!G)throw new SyntaxError("An invalid or illegal string was specified.");R=G,this.hasBeenReset=!0}})),Object.defineProperty(c,"position",r({},u,{get:function(){return F},set:function(k){if(k<0||k>100)throw new Error("Position must be between 0 and 100.");F=k,this.hasBeenReset=!0}})),Object.defineProperty(c,"positionAlign",r({},u,{get:function(){return L},set:function(k){const G=n(k);if(!G)throw new SyntaxError("An invalid or illegal string was specified.");L=G,this.hasBeenReset=!0}})),Object.defineProperty(c,"size",r({},u,{get:function(){return w},set:function(k){if(k<0||k>100)throw new Error("Size must be between 0 and 100.");w=k,this.hasBeenReset=!0}})),Object.defineProperty(c,"align",r({},u,{get:function(){return P},set:function(k){const G=n(k);if(!G)throw new SyntaxError("An invalid or illegal string was specified.");P=G,this.hasBeenReset=!0}})),c.displayState=void 0}return a.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},a})();class nR{decode(e,t){if(!e)return"";if(typeof e!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}function t0(s){function e(i,n,r,a){return(i|0)*3600+(n|0)*60+(r|0)+parseFloat(a||0)}const t=s.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return t?parseFloat(t[2])>59?e(t[2],t[3],0,t[4]):e(t[1],t[2],t[3],t[4]):null}class rR{constructor(){this.values=Object.create(null)}set(e,t){!this.get(e)&&t!==""&&(this.values[e]=t)}get(e,t,i){return i?this.has(e)?this.values[e]:t[i]:this.has(e)?this.values[e]:t}has(e){return e in this.values}alt(e,t,i){for(let n=0;n<i.length;++n)if(t===i[n]){this.set(e,t);break}}integer(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))}percent(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){const i=parseFloat(t);if(i>=0&&i<=100)return this.set(e,i),!0}return!1}}function i0(s,e,t,i){const n=i?s.split(i):[s];for(const r in n){if(typeof n[r]!="string")continue;const a=n[r].split(t);if(a.length!==2)continue;const o=a[0],d=a[1];e(o,d)}}const Wc=new ju(0,0,""),Ua=Wc.align==="middle"?"middle":"center";function aR(s,e,t){const i=s;function n(){const o=t0(s);if(o===null)throw new Error("Malformed timestamp: "+i);return s=s.replace(/^[^\sa-zA-Z-]+/,""),o}function r(o,d){const l=new rR;i0(o,function(h,f){let m;switch(h){case"region":for(let p=t.length-1;p>=0;p--)if(t[p].id===f){l.set(h,t[p].region);break}break;case"vertical":l.alt(h,f,["rl","lr"]);break;case"line":m=f.split(","),l.integer(h,m[0]),l.percent(h,m[0])&&l.set("snapToLines",!1),l.alt(h,m[0],["auto"]),m.length===2&&l.alt("lineAlign",m[1],["start",Ua,"end"]);break;case"position":m=f.split(","),l.percent(h,m[0]),m.length===2&&l.alt("positionAlign",m[1],["start",Ua,"end","line-left","line-right","auto"]);break;case"size":l.percent(h,f);break;case"align":l.alt(h,f,["start",Ua,"end","left","right"]);break}},/:/,/\s/),d.region=l.get("region",null),d.vertical=l.get("vertical","");let c=l.get("line","auto");c==="auto"&&Wc.line===-1&&(c=-1),d.line=c,d.lineAlign=l.get("lineAlign","start"),d.snapToLines=l.get("snapToLines",!0),d.size=l.get("size",100),d.align=l.get("align",Ua);let u=l.get("position","auto");u==="auto"&&Wc.position===50&&(u=d.align==="start"||d.align==="left"?0:d.align==="end"||d.align==="right"?100:50),d.position=u}function a(){s=s.replace(/^\s+/,"")}if(a(),e.startTime=n(),a(),s.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+i);s=s.slice(3),a(),e.endTime=n(),a(),r(s,e)}function s0(s){return s.replace(/<br(?: \/)?>/gi,` 1514`)}class oR{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new nR,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(e){const t=this;e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));function i(){let r=t.buffer,a=0;for(r=s0(r);a<r.length&&r[a]!=="\r"&&r[a]!==` 1515`;)++a;const o=r.slice(0,a);return r[a]==="\r"&&++a,r[a]===` 1516`&&++a,t.buffer=r.slice(a),o}function n(r){i0(r,function(a,o){},/:/)}try{let r="";if(t.state==="INITIAL"){if(!/\r\n|\n/.test(t.buffer))return this;r=i();const o=r.match(/^()?WEBVTT([ \t].*)?$/);if(!(o!=null&&o[0]))throw new Error("Malformed WebVTT signature.");t.state="HEADER"}let a=!1;for(;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(a?a=!1:r=i(),t.state){case"HEADER":/:/.test(r)?n(r):r||(t.state="ID");continue;case"NOTE":r||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(r)){t.state="NOTE";break}if(!r)continue;if(t.cue=new ju(0,0,""),t.state="CUE",r.indexOf("-->")===-1){t.cue.id=r;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{aR(r,t.cue,t.regionList)}catch{t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":{const o=r.indexOf("-->")!==-1;if(!r||o&&(a=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(t.cue===null)continue;t.cue.text&&(t.cue.text+=` 1517`),t.cue.text+=r}continue;case"BADCUE":r||(t.state="ID")}}}catch{t.state==="CUETEXT"&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state=t.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this}flush(){const e=this;try{if((e.cue||e.state==="HEADER")&&(e.buffer+=` 1518 1519`,e.parse()),e.state==="INITIAL"||e.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(t){e.onparsingerror&&e.onparsingerror(t)}return e.onflush&&e.onflush(),this}}const lR=/\r\n|\n\r|\n|\r/g,pd=function(e,t,i=0){return e.slice(i,i+t.length)===t},dR=function(e){let t=parseInt(e.slice(-3));const i=parseInt(e.slice(-6,-4)),n=parseInt(e.slice(-9,-7)),r=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!he(t)||!he(i)||!he(n)||!he(r))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*i,t+=60*1e3*n,t+=3600*1e3*r,t};function Xu(s,e,t){return Dr(s.toString())+Dr(e.toString())+Dr(t)}const cR=function(e,t,i){let n=e[t],r=e[n.prevCC];if(!r||!r.new&&n.new){e.ccOffset=e.presentationOffset=n.start,n.new=!1;return}for(;(a=r)!=null&&a.new;){var a;e.ccOffset+=n.start-r.start,n.new=!1,n=r,r=e[n.prevCC]}e.presentationOffset=i};function uR(s,e,t,i,n,r,a){const o=new oR,d=li(new Uint8Array(s)).trim().replace(lR,` 1520`).split(` 1521`),l=[],c=e?vx(e.baseTime,e.timescale):0;let u="00:00.000",h=0,f=0,m,p=!0;o.oncue=function(g){const y=t[i];let T=t.ccOffset;const _=(h-c)/9e4;if(y!=null&&y.new&&(f!==void 0?T=t.ccOffset=y.start:cR(t,i,_)),_){if(!e){m=new Error("Missing initPTS for VTT MPEGTS");return}T=_-t.presentationOffset}const I=g.endTime-g.startTime,R=ai((g.startTime+T-f)*9e4,n*9e4)/9e4;g.startTime=Math.max(R,0),g.endTime=Math.max(R+I,0);const F=g.text.trim();g.text=decodeURIComponent(encodeURIComponent(F)),g.id||(g.id=Xu(g.startTime,g.endTime,F)),g.endTime>0&&l.push(g)},o.onparsingerror=function(g){m=g},o.onflush=function(){if(m){a(m);return}r(l)},d.forEach(g=>{if(p)if(pd(g,"X-TIMESTAMP-MAP=")){p=!1,g.slice(16).split(",").forEach(y=>{pd(y,"LOCAL:")?u=y.slice(6):pd(y,"MPEGTS:")&&(h=parseInt(y.slice(7)))});try{f=dR(u)/1e3}catch(y){m=y}return}else g===""&&(p=!1);o.parse(g+` 1522`)}),o.flush()}const vd="stpp.ttml.im1t",n0=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,r0=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,hR={left:"start",center:"center",right:"end",start:"start",end:"end"};function lm(s,e,t,i){const n=Be(new Uint8Array(s),["mdat"]);if(n.length===0){i(new Error("Could not parse IMSC1 mdat"));return}const r=n.map(o=>li(o)),a=px(e.baseTime,1,e.timescale);try{r.forEach(o=>t(fR(o,a)))}catch(o){i(o)}}function fR(s,e){const n=new DOMParser().parseFromString(s,"text/xml").getElementsByTagName("tt")[0];if(!n)throw new Error("Invalid ttml");const r={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},a=Object.keys(r).reduce((u,h)=>(u[h]=n.getAttribute(`ttp:${h}`)||r[h],u),{}),o=n.getAttribute("xml:space")!=="preserve",d=dm(Ed(n,"styling","style")),l=dm(Ed(n,"layout","region")),c=Ed(n,"body","[begin]");return[].map.call(c,u=>{const h=a0(u,o);if(!h||!u.hasAttribute("begin"))return null;const f=Td(u.getAttribute("begin"),a),m=Td(u.getAttribute("dur"),a);let p=Td(u.getAttribute("end"),a);if(f===null)throw cm(u);if(p===null){if(m===null)throw cm(u);p=f+m}const g=new ju(f-e,p-e,h);g.id=Xu(g.startTime,g.endTime,g.text);const y=l[u.getAttribute("region")],T=d[u.getAttribute("style")],_=mR(y,T,d),{textAlign:I}=_;if(I){const R=hR[I];R&&(g.lineAlign=R),g.align=I}return nt(g,_),g}).filter(u=>u!==null)}function Ed(s,e,t){const i=s.getElementsByTagName(e)[0];return i?[].slice.call(i.querySelectorAll(t)):[]}function dm(s){return s.reduce((e,t)=>{const i=t.getAttribute("xml:id");return i&&(e[i]=t),e},{})}function a0(s,e){return[].slice.call(s.childNodes).reduce((t,i,n)=>{var r;return i.nodeName==="br"&&n?t+` 1523`:(r=i.childNodes)!=null&&r.length?a0(i,e):e?t+i.textContent.trim().replace(/\s+/g," "):t+i.textContent},"")}function mR(s,e,t){const i="http://www.w3.org/ns/ttml#styling";let n=null;const r=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],a=s!=null&&s.hasAttribute("style")?s.getAttribute("style"):null;return a&&t.hasOwnProperty(a)&&(n=t[a]),r.reduce((o,d)=>{const l=yd(e,i,d)||yd(s,i,d)||yd(n,i,d);return l&&(o[d]=l),o},{})}function yd(s,e,t){return s&&s.hasAttributeNS(e,t)?s.getAttributeNS(e,t):null}function cm(s){return new Error(`Could not parse ttml timestamp ${s}`)}function Td(s,e){if(!s)return null;let t=t0(s);return t===null&&(n0.test(s)?t=gR(s,e):r0.test(s)&&(t=pR(s,e))),t}function gR(s,e){const t=n0.exec(s),i=(t[4]|0)+(t[5]|0)/e.subFrameRate;return(t[1]|0)*3600+(t[2]|0)*60+(t[3]|0)+i/e.frameRate}function pR(s,e){const t=r0.exec(s),i=Number(t[1]);switch(t[2]){case"h":return i*3600;case"m":return i*60;case"ms":return i*1e3;case"f":return i/e.frameRate;case"t":return i/e.tickRate}return i}class Ba{constructor(e,t){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=e,this.trackName=t}dispatchCue(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}newCue(e,t,i){(this.startTime===null||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=i,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}}class vR{constructor(e){this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=hm(),this.captionsProperties=void 0,this.hls=e,this.config=e.config,this.Cues=e.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}}
vendor: 4,134 bytes, line 1523
1523,e.on(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(v.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(v.FRAG_LOADING,this.onFragLoading,this),e.on(v.FRAG_LOADED,this.onFragLoaded,this),e.on(v.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(v.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(v.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(v.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(v.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:e}=this;e.off(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(v.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(v.FRAG_LOADING,this.onFragLoading,this),e.off(v.FRAG_LOADED,this.onFragLoaded,this),e.off(v.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(v.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(v.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(v.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(v.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.media=null,this.cea608Parser1=this.cea608Parser2=void 0}initCea608Parsers(){const e=new Ba(this,"textTrack1"),t=new Ba(this,"textTrack2"),i=new Ba(this,"textTrack3"),n=new Ba(this,"textTrack4");this.cea608Parser1=new om(1,e,t),this.cea608Parser2=new om(3,i,n)}addCues(e,t,i,n,r){let a=!1;for(let o=r.length;o--;){const d=r[o],l=ER(d[0],d[1],t,i);if(l>=0&&(d[0]=Math.min(d[0],t),d[1]=Math.max(d[1],i),a=!0,l/(i-t)>.5))return}if(a||r.push([t,i]),this.config.renderTextTracksNatively){const o=this.captionsTracks[e];this.Cues.newCue(o,t,i,n)}else{const o=this.Cues.newCue(null,t,i,n);this.hls.trigger(v.CUES_PARSED,{type:"captions",cues:o,track:e})}}onInitPtsFound(e,{frag:t,id:i,initPTS:n,timescale:r,trackId:a}){const{unparsedVttFrags:o}=this;i===ge.MAIN&&(this.initPTS[t.cc]={baseTime:n,timescale:r,trackId:a}),o.length&&(this.unparsedVttFrags=[],o.forEach(d=>{this.initPTS[d.frag.cc]?this.onFragLoaded(v.FRAG_LOADED,d):this.hls.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:d.frag,error:new Error("Subtitle discontinuity domain does not match main")})}))}getExistingTrack(e,t){const{media:i}=this;if(i)for(let n=0;n<i.textTracks.length;n++){const r=i.textTracks[n];if(um(r,{name:e,lang:t,characteristics:"transcribes-spoken-dialog,describes-music-and-sound"}))return r}return null}createCaptionsTrack(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}createNativeTrack(e){if(this.captionsTracks[e])return;const{captionsProperties:t,captionsTracks:i,media:n}=this,{label:r,languageCode:a}=t[e],o=this.getExistingTrack(r,a);if(o)i[e]=o,wn(i[e]),Xv(i[e],n);else{const d=this.createTextTrack("captions",r,a);d&&(d[e]=!0,i[e]=d)}}createNonNativeTrack(e){if(this.nonNativeCaptionsTracks[e])return;const t=this.captionsProperties[e];if(!t)return;const i=t.label,n={_id:e,label:i,kind:"captions",default:t.media?!!t.media.default:!1,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=n,this.hls.trigger(v.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[n]})}createTextTrack(e,t,i){const n=this.media;if(n)return n.addTextTrack(e,t,i)}onMediaAttaching(e,t){this.media=t.media,t.mediaSource||this._cleanTracks()}onMediaDetaching(e,t){const i=!!t.transferMedia;if(this.media=null,i)return;const{captionsTracks:n}=this;Object.keys(n).forEach(r=>{wn(n[r]),delete n[r]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=hm(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}_cleanTracks(){const{media:e}=this;if(!e)return;const t=e.textTracks;if(t)for(let i=0;i<t.length;i++)wn(t[i])}
vendor: 20,919 bytes, line 1523
1523onSubtitleTracksUpdated(e,t){const i=t.subtitleTracks||[],n=i.some(r=>r.textCodec===vd);if(this.config.enableWebVTT||n&&this.config.enableIMSC1){if($v(this.tracks,i)){this.tracks=i;return}if(this.textTracks=[],this.tracks=i,this.config.renderTextTracksNatively){const a=this.media,o=a?Fo(a.textTracks):null;if(this.tracks.forEach((d,l)=>{let c;if(o){let u=null;for(let h=0;h<o.length;h++)if(o[h]&&um(o[h],d)){u=o[h],o[h]=null;break}u&&(c=u)}if(c)wn(c);else{const u=o0(d);c=this.createTextTrack(u,d.name,d.lang),c&&(c.mode="disabled")}c&&this.textTracks.push(c)}),o!=null&&o.length){const d=o.filter(l=>l!==null).map(l=>l.label);d.length&&this.hls.logger.warn(`Media element contains unused subtitle tracks: ${d.join(", ")}. Replace media element for each source to clear TextTracks and captions menu.`)}}else if(this.tracks.length){const a=this.tracks.map(o=>({label:o.name,kind:o.type.toLowerCase(),default:o.default,subtitleTrack:o}));this.hls.trigger(v.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:a})}}}onManifestLoaded(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(i=>{const n=/(?:CC|SERVICE)([1-4])/.exec(i.instreamId);if(!n)return;const r=`textTrack${n[1]}`,a=this.captionsProperties[r];a&&(a.label=i.name,i.lang&&(a.languageCode=i.lang),a.media=i)})}closedCaptionsForLevel(e){const t=this.hls.levels[e.level];return t?.attrs["CLOSED-CAPTIONS"]}onFragLoading(e,t){if(this.enabled&&t.frag.type===ge.MAIN){var i,n;const{cea608Parser1:r,cea608Parser2:a,lastSn:o}=this,{cc:d,sn:l}=t.frag,c=(i=(n=t.part)==null?void 0:n.index)!=null?i:-1;r&&a&&(l!==o+1||l===o&&c!==this.lastPartIndex+1||d!==this.lastCc)&&(r.reset(),a.reset()),this.lastCc=d,this.lastSn=l,this.lastPartIndex=c}}onFragLoaded(e,t){const{frag:i,payload:n}=t;if(i.type===ge.SUBTITLE)if(n.byteLength){const r=i.decryptdata,a="stats"in t;if(r==null||!r.encrypted||a){const o=this.tracks[i.level],d=this.vttCCs;d[i.cc]||(d[i.cc]={start:i.start,prevCC:this.prevCC,new:!0},this.prevCC=i.cc),o&&o.textCodec===vd?this._parseIMSC1(i,n):this._parseVTTs(t)}}else this.hls.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Empty subtitle payload")})}_parseIMSC1(e,t){const i=this.hls;lm(t,this.initPTS[e.cc],n=>{this._appendCues(n,e.level),i.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},n=>{i.logger.log(`Failed to parse IMSC1: ${n}`),i.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:n})})}_parseVTTs(e){var t;const{frag:i,payload:n}=e,{initPTS:r,unparsedVttFrags:a}=this,o=r.length-1;if(!r[i.cc]&&o===-1){a.push(e);return}const d=this.hls,l=(t=i.initSegment)!=null&&t.data?gi(i.initSegment.data,new Uint8Array(n)).buffer:n;uR(l,this.initPTS[i.cc],this.vttCCs,i.cc,i.start,c=>{this._appendCues(c,i.level),d.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:i})},c=>{const u=c.message==="Missing initPTS for VTT MPEGTS";u?a.push(e):this._fallbackToIMSC1(i,n),d.logger.log(`Failed to parse VTT cue: ${c}`),!(u&&o>i.cc)&&d.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:c})})}_fallbackToIMSC1(e,t){const i=this.tracks[e.level];i.textCodec||lm(t,this.initPTS[e.cc],()=>{i.textCodec=vd,this._parseIMSC1(e,t)},()=>{i.textCodec="wvtt"})}_appendCues(e,t){const i=this.hls;if(this.config.renderTextTracksNatively){const n=this.textTracks[t];if(!n||n.mode==="disabled")return;e.forEach(r=>Qv(n,r))}else{const n=this.tracks[t];if(!n)return;const r=n.default?"default":"subtitles"+t;i.trigger(v.CUES_PARSED,{type:"subtitles",cues:e,track:r})}}onFragDecrypted(e,t){const{frag:i}=t;i.type===ge.SUBTITLE&&this.onFragLoaded(v.FRAG_LOADED,t)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(e,t){if(!this.enabled||!this.config.enableCEA708Captions)return;const{frag:i,samples:n}=t;if(!(i.type===ge.MAIN&&this.closedCaptionsForLevel(i)==="NONE"))for(let r=0;r<n.length;r++){const a=n[r].bytes;if(a){this.cea608Parser1||this.initCea608Parsers();const o=this.extractCea608Data(a);this.cea608Parser1.addData(n[r].pts,o[0]),this.cea608Parser2.addData(n[r].pts,o[1])}}}onBufferFlushing(e,{startOffset:t,endOffset:i,endOffsetSubtitles:n,type:r}){const{media:a}=this;if(!(!a||a.currentTime<i)){if(!r||r==="video"){const{captionsTracks:o}=this;Object.keys(o).forEach(d=>Vc(o[d],t,i))}if(this.config.renderTextTracksNatively&&t===0&&n!==void 0){const{textTracks:o}=this;Object.keys(o).forEach(d=>Vc(o[d],t,n))}}}extractCea608Data(e){const t=[[],[]],i=e[0]&31;let n=2;for(let r=0;r<i;r++){const a=e[n++],o=127&e[n++],d=127&e[n++];if(o===0&&d===0)continue;if((4&a)!==0){const c=3&a;(c===0||c===1)&&(t[c].push(o),t[c].push(d))}}return t}}function o0(s){return s.characteristics&&/transcribes-spoken-dialog/gi.test(s.characteristics)&&/describes-music-and-sound/gi.test(s.characteristics)?"captions":"subtitles"}function um(s,e){return!!s&&s.kind===o0(e)&&Bc(e,s)}function ER(s,e,t,i){return Math.min(e,i)-Math.max(s,t)}function hm(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}const yR=/\s/,TR={newCue(s,e,t,i){const n=[];let r,a,o,d,l;const c=self.VTTCue||self.TextTrackCue;for(let h=0;h<i.rows.length;h++)if(r=i.rows[h],o=!0,d=0,l="",!r.isEmpty()){var u;for(let p=0;p<r.chars.length;p++)yR.test(r.chars[p].uchar)&&o?d++:(l+=r.chars[p].uchar,o=!1);r.cueStartTime=e,e===t&&(t+=1e-4),d>=16?d--:d++;const f=s0(l.trim()),m=Xu(e,t,f);s!=null&&(u=s.cues)!=null&&u.getCueById(m)||(a=new c(e,t,f),a.id=m,a.line=h+1,a.align="left",a.position=10+Math.min(80,Math.floor(d*8/32)*10),n.push(a))}return s&&n.length&&(n.sort((h,f)=>h.line==="auto"||f.line==="auto"?0:h.line>8&&f.line>8?f.line-h.line:h.line-f.line),n.forEach(h=>Qv(s,h))),n}};function bR(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}const _R=/(\d+)-(\d+)\/(\d+)/;class fm{constructor(e){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=null,this.response=null,this.controller=void 0,this.context=null,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=e.fetchSetup||xR,this.controller=new self.AbortController,this.stats=new Ru}destroy(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null}abortInternal(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(e,t,i){const n=this.stats;if(n.loading.start)throw new Error("Loader can only be used once.");n.loading.start=self.performance.now();const r=SR(e,this.controller.signal),a=e.responseType==="arraybuffer",o=a?"byteLength":"length",{maxTimeToFirstByteMs:d,maxLoadTimeMs:l}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=i,this.request=this.fetchSetup(e,r),self.clearTimeout(this.requestTimeout),t.timeout=d&&he(d)?d:l,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(n,e,this.response))},t.timeout),(Yr(this.request)?this.request.then(self.fetch):self.fetch(this.request)).then(u=>{var h;this.response=this.loader=u;const f=Math.max(self.performance.now(),n.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=l,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(n,e,this.response))},l-(f-n.loading.start)),!u.ok){const{status:p,statusText:g}=u;throw new LR(g||"fetch, bad network response",p,u)}n.loading.first=f,n.total=IR(u.headers)||n.total;const m=(h=this.callbacks)==null?void 0:h.onProgress;return m&&he(t.highWaterMark)?this.loadProgressively(u,n,e,t.highWaterMark,m):a?u.arrayBuffer():e.responseType==="json"?u.json():u.text()}).then(u=>{var h,f;const m=this.response;if(!m)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),n.loading.end=Math.max(self.performance.now(),n.loading.first);const p=u[o];p&&(n.loaded=n.total=p);const g={url:m.url,data:u,code:m.status},y=(h=this.callbacks)==null?void 0:h.onProgress;y&&!he(t.highWaterMark)&&y(n,e,u,m),(f=this.callbacks)==null||f.onSuccess(g,n,e,m)}).catch(u=>{var h;if(self.clearTimeout(this.requestTimeout),n.aborted)return;const f=u&&u.code||0,m=u?u.message:null;(h=this.callbacks)==null||h.onError({code:f,text:m},e,u?u.details:null,n)})}getCacheAge(){let e=null;if(this.response){const t=this.response.headers.get("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.response?this.response.headers.get(e):null}loadProgressively(e,t,i,n=0,r){const a=new vv,o=e.body.getReader(),d=()=>o.read().then(l=>{if(l.done)return a.dataLength&&r(t,i,a.flush().buffer,e),Promise.resolve(new ArrayBuffer(0));const c=l.value,u=c.length;return t.loaded+=u,u<n||a.dataLength?(a.push(c),a.dataLength>=n&&r(t,i,a.flush().buffer,e)):r(t,i,c.buffer,e),d()}).catch(()=>Promise.reject());return d()}}function SR(s,e){const t={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(nt({},s.headers))};return s.rangeEnd&&t.headers.set("Range","bytes="+s.rangeStart+"-"+String(s.rangeEnd-1)),t}function AR(s){const e=_R.exec(s);if(e)return parseInt(e[2])-parseInt(e[1])+1}function IR(s){const e=s.get("Content-Range");if(e){const i=AR(e);if(he(i))return i}const t=s.get("Content-Length");if(t)return parseInt(t)}function xR(s,e){return new self.Request(s.url,e)}class LR extends Error{constructor(e,t,i){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=i}}const RR=/^age:\s*[\d.]+\s*$/im;class l0{constructor(e){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=null,this.loader=null,this.stats=void 0,this.xhrSetup=e&&e.xhrSetup||null,this.stats=new Ru,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null}abortInternal(){const e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,e.readyState!==4&&(this.stats.aborted=!0,e.abort()))}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}load(e,t,i){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=i,this.loadInternal()}loadInternal(){const{config:e,context:t}=this;if(!e||!t)return;const i=this.loader=new self.XMLHttpRequest,n=this.stats;n.loading.first=0,n.loaded=0,n.aborted=!1;const r=this.xhrSetup;r?Promise.resolve().then(()=>{if(!(this.loader!==i||this.stats.aborted))return r(i,t.url)}).catch(a=>{if(!(this.loader!==i||this.stats.aborted))return i.open("GET",t.url,!0),r(i,t.url)}).then(()=>{this.loader!==i||this.stats.aborted||this.openAndSendXhr(i,t,e)}).catch(a=>{var o;(o=this.callbacks)==null||o.onError({code:i.status,text:a.message},t,i,n)}):this.openAndSendXhr(i,t,e)}openAndSendXhr(e,t,i){e.readyState||e.open("GET",t.url,!0);const n=t.headers,{maxTimeToFirstByteMs:r,maxLoadTimeMs:a}=i.loadPolicy;if(n)for(const o in n)e.setRequestHeader(o,n[o]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),i.timeout=r&&he(r)?r:a,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),i.timeout),e.send()}readystatechange(){const{context:e,loader:t,stats:i}=this;if(!e||!t)return;const n=t.readyState,r=this.config;if(!i.aborted&&n>=2&&(i.loading.first===0&&(i.loading.first=Math.max(self.performance.now(),i.loading.start),r.timeout!==r.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),r.timeout=r.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.loadPolicy.maxLoadTimeMs-(i.loading.first-i.loading.start)))),n===4)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;const l=t.status,c=t.responseType==="text"?t.responseText:null;if(l>=200&&l<300){const m=c??t.response;if(m!=null){var a,o;i.loading.end=Math.max(self.performance.now(),i.loading.first);const p=t.responseType==="arraybuffer"?m.byteLength:m.length;i.loaded=i.total=p,i.bwEstimate=i.total*8e3/(i.loading.end-i.loading.first);const g=(a=this.callbacks)==null?void 0:a.onProgress;g&&g(i,e,m,t);const y={url:t.responseURL,data:m,code:l};(o=this.callbacks)==null||o.onSuccess(y,i,e,t);return}}const u=r.loadPolicy.errorRetry,h=i.retry,f={url:e.url,data:void 0,code:l};if(fl(u,h,!1,f))this.retry(u);else{var d;et.error(`${l} while loading ${e.url}`),(d=this.callbacks)==null||d.onError({code:l,text:t.statusText},e,t,i)}}}loadtimeout(){if(!this.config)return;const e=this.config.loadPolicy.timeoutRetry,t=this.stats.retry;if(fl(e,t,!0))this.retry(e);else{var i;et.warn(`timeout while loading ${(i=this.context)==null?void 0:i.url}`);const n=this.callbacks;n&&(this.abortInternal(),n.onTimeout(this.stats,this.context,this.loader))}}retry(e){const{context:t,stats:i}=this;this.retryDelay=wu(e,i.retry),i.retry++,et.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${t?.url}, retrying ${i.retry}/${e.maxNumRetry} in ${this.retryDelay}ms`),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)}loadprogress(e){const t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)}getCacheAge(){let e=null;if(this.loader&&RR.test(this.loader.getAllResponseHeaders())){const t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.loader&&new RegExp(`^${e}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}}const kR={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},DR=Je(Je({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,maxDevicePixelRatio:Number.POSITIVE_INFINITY,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,startOnSegmentBoundary:!1,maxBufferSize:60*1e3*1e3,maxFragLookUpTolerance:.25,maxBufferHole:.1,detectStallWithCurrentTimeMs:1250,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,nudgeOnVideoHole:!0,liveSyncMode:"edge",liveSyncDurationCount:3,liveSyncOnStallIncrease:1,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,ignorePlaylistParsingErrors:!1,loader:l0,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:KA,bufferController:wx,capLevelController:qu,errorController:YA,fpsController:PL,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:av,requireKeySystemAccessOnStart:!1,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableEmsgKLVMetadata:!1,enableID3MetadataCues:!0,enableInterstitialPlayback:!0,interstitialAppendInPlace:!0,interstitialLiveLookAhead:10,useMediaCapabilities:!0,preserveManualLevelOnError:!1,certLoadPolicy:{default:kR},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},interstitialAssetListLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:3e4,timeoutRetry:{maxNumRetry:0,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:0,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},CR()),{},{subtitleStreamController:WL,subtitleTrackController:FL,timelineController:vR,audioStreamController:Rx,audioTrackController:kx,emeController:Un,cmcdController:kL,contentSteeringController:CL,interstitialsController:VL});function CR(){return{cueHandler:TR,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function wR(s,e,t){if((e.liveSyncDurationCount||e.liveMaxLatencyDurationCount)&&(e.liveSyncDuration||e.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(e.liveMaxLatencyDurationCount!==void 0&&(e.liveSyncDurationCount===void 0||e.liveMaxLatencyDurationCount<=e.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(e.liveMaxLatencyDuration!==void 0&&(e.liveSyncDuration===void 0||e.liveMaxLatencyDuration<=e.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');const i=qc(s),n=["manifest","level","frag"],r=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return n.forEach(a=>{const o=`${a==="level"?"playlist":a}LoadPolicy`,d=e[o]===void 0,l=[];r.forEach(c=>{const u=`${a}Loading${c}`,h=e[u];if(h!==void 0&&d){l.push(u);const f=i[o].default;switch(e[o]={default:f},c){case"TimeOut":f.maxLoadTimeMs=h,f.maxTimeToFirstByteMs=h;break;case"MaxRetry":f.errorRetry.maxNumRetry=h,f.timeoutRetry.maxNumRetry=h;break;case"RetryDelay":f.errorRetry.retryDelayMs=h,f.timeoutRetry.retryDelayMs=h;break;case"MaxRetryTimeout":f.errorRetry.maxRetryDelayMs=h,f.timeoutRetry.maxRetryDelayMs=h;break}}}),l.length&&t.warn(`hls.js config: "${l.join('", "')}" setting(s) are deprecated, use "${o}": ${lt(e[o])}`)}),Je(Je({},i),e)}function qc(s){return s&&typeof s=="object"?Array.isArray(s)?s.map(qc):Object.keys(s).reduce((e,t)=>(e[t]=qc(s[t]),e),{}):s}function PR(s,e){const t=s.loader;t!==fm&&t!==l0?(e.log("[config]: Custom loader detected, cannot enable progressive streaming"),s.progressive=!1):bR()&&(s.loader=fm,s.progressive=!0,s.enableSoftwareAES=!0,e.log("[config]: Progressive streaming enabled, using FetchLoader"))}const $o=2,MR=.1,OR=.05,FR=100;class $R extends tv{constructor(e,t){super("gap-controller",e.logger),this.hls=void 0,this.fragmentTracker=void 0,this.media=null,this.mediaSource=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.buffered={},this.lastCurrentTime=0,this.ended=0,this.waiting=0,this.onMediaPlaying=()=>{this.ended=0,this.waiting=0},this.onMediaWaiting=()=>{var i;(i=this.media)!=null&&i.seeking||(this.waiting=self.performance.now(),this.tick())},this.onMediaEnded=()=>{if(this.hls){var i;this.ended=((i=this.media)==null?void 0:i.currentTime)||1,this.hls.trigger(v.MEDIA_ENDED,{stalled:!1})}},this.hls=e,this.fragmentTracker=t,this.registerListeners()}registerListeners(){const{hls:e}=this;
vendor: 24,741 bytes, line 1523
1523e&&(e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.BUFFER_APPENDED,this.onBufferAppended,this))}unregisterListeners(){const{hls:e}=this;e&&(e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.BUFFER_APPENDED,this.onBufferAppended,this))}destroy(){super.destroy(),this.unregisterListeners(),this.media=this.hls=this.fragmentTracker=null,this.mediaSource=void 0}onMediaAttached(e,t){this.setInterval(FR),this.mediaSource=t.mediaSource;const i=this.media=t.media;jt(i,"playing",this.onMediaPlaying),jt(i,"waiting",this.onMediaWaiting),jt(i,"ended",this.onMediaEnded)}onMediaDetaching(e,t){this.clearInterval();const{media:i}=this;i&&(ti(i,"playing",this.onMediaPlaying),ti(i,"waiting",this.onMediaWaiting),ti(i,"ended",this.onMediaEnded),this.media=null),this.mediaSource=void 0}onBufferAppended(e,t){this.buffered=t.timeRanges}get hasBuffered(){return Object.keys(this.buffered).length>0}tick(){var e;if(!((e=this.media)!=null&&e.readyState)||!this.hasBuffered)return;const t=this.media.currentTime;this.poll(t,this.lastCurrentTime),this.lastCurrentTime=t}poll(e,t){var i,n;const r=(i=this.hls)==null?void 0:i.config;if(!r)return;const a=this.media;if(!a)return;const{seeking:o}=a,d=this.seeking&&!o,l=!this.seeking&&o,c=a.paused&&!o||a.ended||a.playbackRate===0;if(this.seeking=o,e!==t){t&&(this.ended=0),this.moved=!0,o||(this.nudgeRetry=0,r.nudgeOnVideoHole&&!c&&e>t&&this.nudgeOnVideoHole(e,t)),this.waiting===0&&this.stallResolved(e);return}if(l||d){d&&this.stallResolved(e);return}if(c){this.nudgeRetry=0,this.stallResolved(e),!this.ended&&a.ended&&this.hls&&(this.ended=e||1,this.hls.trigger(v.MEDIA_ENDED,{stalled:!1}));return}if(!Me.getBuffered(a).length){this.nudgeRetry=0;return}const u=Me.bufferInfo(a,e,0),h=u.nextStart||0,f=this.fragmentTracker;if(o&&f&&this.hls){const F=mm(this.hls.inFlightFragments,e),L=u.len>$o,w=!h||F||h-e>$o&&!f.getPartialFragment(e);if(L||w)return;this.moved=!1}const m=(n=this.hls)==null?void 0:n.latestLevelDetails;if(!this.moved&&this.stalled!==null&&f){if(!(u.len>0)&&!h)return;const L=Math.max(h,u.start||0)-e,P=!!(m!=null&&m.live)?m.targetduration*2:$o,k=Ga(e,f);if(L>0&&(L<=P||k)){a.paused||this._trySkipBufferHole(k);return}}const p=r.detectStallWithCurrentTimeMs,g=self.performance.now(),y=this.waiting;let T=this.stalled;if(T===null)if(y>0&&g-y<p)T=this.stalled=y;else{this.stalled=g;return}const _=g-T;if(!o&&(_>=p||y)&&this.hls){var I;if(((I=this.mediaSource)==null?void 0:I.readyState)==="ended"&&!(m!=null&&m.live)&&Math.abs(e-(m?.edge||0))<1){if(this.ended)return;this.ended=e||1,this.hls.trigger(v.MEDIA_ENDED,{stalled:!0});return}if(this._reportStall(u),!this.media||!this.hls)return}const R=Me.bufferInfo(a,e,r.maxBufferHole);this._tryFixBufferStall(R,_,e)}stallResolved(e){const t=this.stalled;if(t&&this.hls&&(this.stalled=null,this.stallReported)){const i=self.performance.now()-t;this.log(`playback not stuck anymore @${e}, after ${Math.round(i)}ms`),this.stallReported=!1,this.waiting=0,this.hls.trigger(v.STALL_RESOLVED,{})}}nudgeOnVideoHole(e,t){var i;const n=this.buffered.video;if(this.hls&&this.media&&this.fragmentTracker&&(i=this.buffered.audio)!=null&&i.length&&n&&n.length>1&&e>n.end(0)){const r=Me.bufferedInfo(Me.timeRangesToArray(this.buffered.audio),e,0);if(r.len>1&&t>=r.start){const a=Me.timeRangesToArray(n),o=Me.bufferedInfo(a,t,0).bufferedIndex;if(o>-1&&o<a.length-1){const d=Me.bufferedInfo(a,e,0).bufferedIndex,l=a[o].end,c=a[o+1].start;if((d===-1||d>o)&&c-l<1&&e-l<2){const u=new Error(`nudging playhead to flush pipeline after video hole. currentTime: ${e} hole: ${l} -> ${c} buffered index: ${d}`);this.warn(u.message),this.media.currentTime+=1e-6;let h=Ga(e,this.fragmentTracker);h&&"fragment"in h?h=h.fragment:h||(h=void 0);const f=Me.bufferInfo(this.media,e,0);this.hls.trigger(v.ERROR,{type:ye.MEDIA_ERROR,details:$.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:u,reason:u.message,frag:h,buffer:f.len,bufferInfo:f})}}}}}_tryFixBufferStall(e,t,i){var n,r;const{fragmentTracker:a,media:o}=this,d=(n=this.hls)==null?void 0:n.config;if(!o||!a||!d)return;const l=(r=this.hls)==null?void 0:r.latestLevelDetails,c=Ga(i,a);if((c||l!=null&&l.live&&i<l.fragmentStart)&&(this._trySkipBufferHole(c)||!this.media))return;const u=e.buffered,h=this.adjacentTraversal(e,i);(u&&u.length>1&&e.len>d.maxBufferHole||e.nextStart&&(e.nextStart-i<d.maxBufferHole||h))&&(t>d.highBufferWatchdogPeriod*1e3||this.waiting)&&(this.warn("Trying to nudge playhead over buffer-hole"),this._tryNudgeBuffer(e))}adjacentTraversal(e,t){const i=this.fragmentTracker,n=e.nextStart;if(i&&n){const r=i.getFragAtPos(t,ge.MAIN),a=i.getFragAtPos(n,ge.MAIN);if(r&&a)return a.sn-r.sn<2}return!1}_reportStall(e){const{hls:t,media:i,stallReported:n,stalled:r}=this;if(!n&&r!==null&&i&&t){this.stallReported=!0;const a=new Error(`Playback stalling at @${i.currentTime} due to low buffer (${lt(e)})`);this.warn(a.message),t.trigger(v.ERROR,{type:ye.MEDIA_ERROR,details:$.BUFFER_STALLED_ERROR,fatal:!1,error:a,buffer:e.len,bufferInfo:e,stalled:{start:r}})}}_trySkipBufferHole(e){var t;const{fragmentTracker:i,media:n}=this,r=(t=this.hls)==null?void 0:t.config;if(!n||!i||!r)return 0;const a=n.currentTime,o=Me.bufferInfo(n,a,0),d=a<o.start?o.start:o.nextStart;if(d&&this.hls){const c=o.len<=r.maxBufferHole,u=o.len>0&&o.len<1&&n.readyState<3,h=d-a;if(h>0&&(c||u)){if(h>r.maxBufferHole){let m=!1;if(a===0){const p=i.getAppendedFrag(0,ge.MAIN);p&&d<p.end&&(m=!0)}if(!m&&e){var l;if(!((l=this.hls.loadLevelObj)!=null&&l.details)||mm(this.hls.inFlightFragments,d))return 0;let g=!1,y=e.end;for(;y<d;){const T=Ga(y,i);if(T)y+=T.duration;else{g=!0;break}}if(g)return 0}}const f=Math.max(d+OR,a+MR);if(this.warn(`skipping hole, adjusting currentTime from ${a} to ${f}`),this.moved=!0,n.currentTime=f,!(e!=null&&e.gap)){const m=new Error(`fragment loaded with buffer holes, seeking from ${a} to ${f}`),p={type:ye.MEDIA_ERROR,details:$.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:m,reason:m.message,buffer:o.len,bufferInfo:o};e&&("fragment"in e?p.part=e:p.frag=e),this.hls.trigger(v.ERROR,p)}return f}}return 0}_tryNudgeBuffer(e){const{hls:t,media:i,nudgeRetry:n}=this,r=t?.config;if(!i||!r)return 0;const a=i.currentTime;if(this.nudgeRetry++,n<r.nudgeMaxRetry){const o=a+(n+1)*r.nudgeOffset,d=new Error(`Nudging 'currentTime' from ${a} to ${o}`);this.warn(d.message),i.currentTime=o,t.trigger(v.ERROR,{type:ye.MEDIA_ERROR,details:$.BUFFER_NUDGE_ON_STALL,error:d,fatal:!1,buffer:e.len,bufferInfo:e})}else{const o=new Error(`Playhead still not moving while enough data buffered @${a} after ${r.nudgeMaxRetry} nudges`);this.error(o.message),t.trigger(v.ERROR,{type:ye.MEDIA_ERROR,details:$.BUFFER_STALLED_ERROR,error:o,fatal:!0,buffer:e.len,bufferInfo:e})}}}function mm(s,e){const t=gm(s.main);if(t&&t.start<=e)return t;const i=gm(s.audio);return i&&i.start<=e?i:null}function gm(s){if(!s)return null;switch(s.state){case W.IDLE:case W.STOPPED:case W.ENDED:case W.ERROR:return null}return s.frag}function Ga(s,e){return e.getAppendedFrag(s,ge.MAIN)||e.getPartialFragment(s)}const NR=.25;function Yc(){if(!(typeof self>"u"))return self.VTTCue||self.TextTrackCue}function bd(s,e,t,i,n){let r=new s(e,t,"");try{r.value=i,n&&(r.type=n)}catch{r=new s(e,t,lt(n?Je({type:n},i):i))}return r}const Ka=(()=>{const s=Yc();try{s&&new s(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();class UR{constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.removeCues=!0,this.assetCue=void 0,this.onEventCueEnter=()=>{this.hls&&this.hls.trigger(v.EVENT_CUE_ENTER,{})},this.hls=e,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=this.onEventCueEnter=null}_registerListeners(){const{hls:e}=this;e&&(e.on(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(v.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(v.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}_unregisterListeners(){const{hls:e}=this;e&&(e.off(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(v.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(v.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}onMediaAttaching(e,t){var i;this.media=t.media,((i=t.overrides)==null?void 0:i.cueRemoval)===!1&&(this.removeCues=!1)}onMediaAttached(){var e;const t=(e=this.hls)==null?void 0:e.latestLevelDetails;t&&this.updateDateRangeCues(t)}onMediaDetaching(e,t){this.media=null,!t.transferMedia&&(this.id3Track&&(this.removeCues&&wn(this.id3Track,this.onEventCueEnter),this.id3Track=null),this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(e){const t=this.getID3Track(e.textTracks);return t.mode="hidden",t}getID3Track(e){if(this.media){for(let t=0;t<e.length;t++){const i=e[t];if(i.kind==="metadata"&&i.label==="id3")return Xv(i,this.media),i}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(e,t){if(!this.media||!this.hls)return;const{enableEmsgMetadataCues:i,enableID3MetadataCues:n}=this.hls.config;if(!i&&!n)return;const{samples:r}=t;this.id3Track||(this.id3Track=this.createTrack(this.media));const a=Yc();if(a)for(let o=0;o<r.length;o++){const d=r[o].type;if(d===oi.emsg&&!i||!n)continue;const l=Av(r[o].data),c=r[o].pts;let u=c+r[o].duration;u>Ka&&(u=Ka),u-c<=0&&(u=c+NR);for(let f=0;f<l.length;f++){const m=l[f];if(!Iv(m)){this.updateId3CueEnds(c,d);const p=bd(a,c,u,m,d);p&&this.id3Track.addCue(p)}}}}updateId3CueEnds(e,t){var i;const n=(i=this.id3Track)==null?void 0:i.cues;if(n)for(let r=n.length;r--;){const a=n[r];a.type===t&&a.startTime<e&&a.endTime===Ka&&(a.endTime=e)}}onBufferFlushing(e,{startOffset:t,endOffset:i,type:n}){const{id3Track:r,hls:a}=this;if(!a)return;const{config:{enableEmsgMetadataCues:o,enableID3MetadataCues:d}}=a;if(r&&(o||d)){let l;n==="audio"?l=c=>c.type===oi.audioId3&&d:n==="video"?l=c=>c.type===oi.emsg&&o:l=c=>c.type===oi.audioId3&&d||c.type===oi.emsg&&o,Vc(r,t,i,l)}}onLevelUpdated(e,{details:t}){this.updateDateRangeCues(t,!0)}onLevelPtsUpdated(e,t){Math.abs(t.drift)>.01&&this.updateDateRangeCues(t.details)}updateDateRangeCues(e,t){if(!this.hls||!this.media)return;const{assetPlayerId:i,timelineOffset:n,enableDateRangeMetadataCues:r,interstitialsController:a}=this.hls.config;if(!r)return;const o=Yc();if(i&&n&&!a){const{fragmentStart:p,fragmentEnd:g}=e;let y=this.assetCue;y?(y.startTime=p,y.endTime=g):o&&(y=this.assetCue=bd(o,p,g,{assetPlayerId:this.hls.config.assetPlayerId},"hlsjs.interstitial.asset"),y&&(y.id=i,this.id3Track||(this.id3Track=this.createTrack(this.media)),this.id3Track.addCue(y),y.addEventListener("enter",this.onEventCueEnter)))}if(!e.hasProgramDateTime)return;const{id3Track:d}=this,{dateRanges:l}=e,c=Object.keys(l);let u=this.dateRangeCuesAppended;if(d&&t){var h;if((h=d.cues)!=null&&h.length){const p=Object.keys(u).filter(g=>!c.includes(g));for(let g=p.length;g--;){var f;const y=p[g],T=(f=u[y])==null?void 0:f.cues;delete u[y],T&&Object.keys(T).forEach(_=>{const I=T[_];if(I){I.removeEventListener("enter",this.onEventCueEnter);try{d.removeCue(I)}catch{}}})}}else u=this.dateRangeCuesAppended={}}const m=e.fragments[e.fragments.length-1];if(!(c.length===0||!he(m?.programDateTime))){this.id3Track||(this.id3Track=this.createTrack(this.media));for(let p=0;p<c.length;p++){const g=c[p],y=l[g],T=y.startTime,_=u[g],I=_?.cues||{};let R=_?.durationKnown||!1,F=Ka;const{duration:L,endDate:w}=y;if(w&&L!==null)F=T+L,R=!0;else if(y.endOnNext&&!R){const k=c.reduce((G,se)=>{if(se!==y.id){const oe=l[se];if(oe.class===y.class&&oe.startDate>y.startDate&&(!G||y.startDate<G.startDate))return oe}return G},null);k&&(F=k.startTime,R=!0)}const P=Object.keys(y.attr);for(let k=0;k<P.length;k++){const G=P[k];if(!aI(G))continue;const se=I[G];if(se)R&&!(_!=null&&_.durationKnown)?se.endTime=F:Math.abs(se.startTime-T)>.01&&(se.startTime=T,se.endTime=F);else if(o){let oe=y.attr[G];oI(G)&&(oe=Op(oe));const ae=bd(o,T,F,{key:G,data:oe},oi.dateRange);ae&&(ae.id=g,this.id3Track.addCue(ae),I[G]=ae,a&&(G==="X-ASSET-LIST"||G==="X-ASSET-URL")&&ae.addEventListener("enter",this.onEventCueEnter))}}u[g]={cues:I,dateRange:y,durationKnown:R}}}}}class BR{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.currentTime=0,this.stallCount=0,this._latency=null,this._targetLatencyUpdated=!1,this.onTimeupdate=()=>{const{media:t}=this,i=this.levelDetails;if(!t||!i)return;this.currentTime=t.currentTime;const n=this.computeLatency();if(n===null)return;this._latency=n;const{lowLatencyMode:r,maxLiveSyncPlaybackRate:a}=this.config;if(!r||a===1||!i.live)return;const o=this.targetLatency;if(o===null)return;const d=n-o,l=Math.min(this.maxLatency,o+i.targetduration);if(d<l&&d>.05&&this.forwardBufferLength>1){const u=Math.min(2,Math.max(1,a)),h=Math.round(2/(1+Math.exp(-.75*d-this.edgeStalled))*20)/20,f=Math.min(u,Math.max(1,h));this.changeMediaPlaybackRate(t,f)}else t.playbackRate!==1&&t.playbackRate!==0&&this.changeMediaPlaybackRate(t,1)},this.hls=e,this.config=e.config,this.registerListeners()}get levelDetails(){var e;return((e=this.hls)==null?void 0:e.latestLevelDetails)||null}get latency(){return this._latency||0}get maxLatency(){const{config:e}=this;if(e.liveMaxLatencyDuration!==void 0)return e.liveMaxLatencyDuration;const t=this.levelDetails;return t?e.liveMaxLatencyDurationCount*t.targetduration:0}get targetLatency(){const e=this.levelDetails;if(e===null||this.hls===null)return null;const{holdBack:t,partHoldBack:i,targetduration:n}=e,{liveSyncDuration:r,liveSyncDurationCount:a,lowLatencyMode:o}=this.config,d=this.hls.userConfig;let l=o&&i||t;(this._targetLatencyUpdated||d.liveSyncDuration||d.liveSyncDurationCount||l===0)&&(l=r!==void 0?r:a*n);const c=n;return l+Math.min(this.stallCount*this.config.liveSyncOnStallIncrease,c)}set targetLatency(e){this.stallCount=0,this.config.liveSyncDuration=e,this._targetLatencyUpdated=!0}get liveSyncPosition(){const e=this.estimateLiveEdge(),t=this.targetLatency;if(e===null||t===null)return null;const i=this.levelDetails;if(i===null)return null;const n=i.edge,r=e-t-this.edgeStalled,a=n-i.totalduration,o=n-(this.config.lowLatencyMode&&i.partTarget||i.targetduration);return Math.min(Math.max(a,r),o)}get drift(){const e=this.levelDetails;return e===null?1:e.drift}get edgeStalled(){const e=this.levelDetails;if(e===null)return 0;const t=(this.config.lowLatencyMode&&e.partTarget||e.targetduration)*3;return Math.max(e.age-t,0)}get forwardBufferLength(){const{media:e}=this,t=this.levelDetails;if(!e||!t)return 0;const i=e.buffered.length;return(i?e.buffered.end(i-1):t.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.hls=null}registerListeners(){const{hls:e}=this;e&&(e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(v.ERROR,this.onError,this))}unregisterListeners(){const{hls:e}=this;e&&(e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(v.ERROR,this.onError,this))}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.onTimeupdate)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.onTimeupdate),this.media=null)}onManifestLoading(){this._latency=null,this.stallCount=0}onLevelUpdated(e,{details:t}){t.advanced&&this.onTimeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.onTimeupdate)}onError(e,t){var i;t.details===$.BUFFER_STALLED_ERROR&&(this.stallCount++,this.hls&&(i=this.levelDetails)!=null&&i.live&&this.hls.logger.warn("[latency-controller]: Stall detected, adjusting target latency"))}changeMediaPlaybackRate(e,t){var i,n;e.playbackRate!==t&&((i=this.hls)==null||i.logger.debug(`[latency-controller]: latency=${this.latency.toFixed(3)}, targetLatency=${(n=this.targetLatency)==null?void 0:n.toFixed(3)}, forwardBufferLength=${this.forwardBufferLength.toFixed(3)}: adjusting playback rate from ${e.playbackRate} to ${t}`),e.playbackRate=t)}estimateLiveEdge(){const e=this.levelDetails;return e===null?null:e.edge+e.age}computeLatency(){const e=this.estimateLiveEdge();return e===null?null:e-this.currentTime}}class GR extends Wu{constructor(e,t){super(e,"level-controller"),this._levels=[],this._firstLevel=-1,this._maxAutoLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=t,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(v.LEVEL_LOADED,this.onLevelLoaded,this),e.on(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(v.FRAG_BUFFERED,this.onFragBuffered,this),e.on(v.ERROR,this.onError,this)}_unregisterListeners(){const{hls:e}=this;e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(v.LEVEL_LOADED,this.onLevelLoaded,this),e.off(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(v.FRAG_BUFFERED,this.onFragBuffered,this),e.off(v.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}stopLoad(){this._levels.forEach(t=>{t.loadError=0,t.fragmentError=0}),super.stopLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1}onManifestLoading(e,t){this.resetLevels()}onManifestLoaded(e,t){const i=this.hls.config.preferManagedMediaSource,n=[],r={},a={};let o=!1,d=!1,l=!1;t.levels.forEach(c=>{const u=c.attrs;let{audioCodec:h,videoCodec:f}=c;h&&(c.audioCodec=h=dl(h,i)||void 0),f&&(f=c.videoCodec=SA(f));const{width:m,height:p,unknownCodecs:g}=c,y=g?.length||0;if(o||(o=!!(m&&p)),d||(d=!!f),l||(l=!!h),y||h&&!this.isAudioSupported(h)||f&&!this.isVideoSupported(f)){this.log(`Some or all CODECS not supported "${u.CODECS}"`);return}const{CODECS:T,"FRAME-RATE":_,"HDCP-LEVEL":I,"PATHWAY-ID":R,RESOLUTION:F,"VIDEO-RANGE":L}=u,P=`${`${R||"."}-`}${c.bitrate}-${F}-${_}-${T}-${L}-${I}`;if(r[P])if(r[P].uri!==c.url&&!c.attrs["PATHWAY-ID"]){const k=a[P]+=1;c.attrs["PATHWAY-ID"]=new Array(k+1).join(".");const G=this.createLevel(c);r[P]=G,n.push(G)}else r[P].addGroupId("audio",u.AUDIO),r[P].addGroupId("text",u.SUBTITLES);else{const k=this.createLevel(c);r[P]=k,a[P]=1,n.push(k)}}),this.filterAndSortMediaOptions(n,t,o,d,l)}createLevel(e){const t=new Vr(e),i=e.supplemental;if(i!=null&&i.videoCodec&&!this.isVideoSupported(i.videoCodec)){const n=new Error(`SUPPLEMENTAL-CODECS not supported "${i.videoCodec}"`);this.log(n.message),t.supportedResult=Yp(n,[])}return t}isAudioSupported(e){return Kr(e,"audio",this.hls.config.preferManagedMediaSource)}isVideoSupported(e){return Kr(e,"video",this.hls.config.preferManagedMediaSource)}filterAndSortMediaOptions(e,t,i,n,r){var a;let o=[],d=[],l=e;const c=((a=t.stats)==null?void 0:a.parsing)||{};if((i||n)&&r&&(l=l.filter(({videoCodec:T,videoRange:_,width:I,height:R})=>(!!T||!!(I&&R))&&PA(_))),l.length===0){Promise.resolve().then(()=>{if(this.hls){let T="no level with compatible codecs found in manifest",_=T;t.levels.length&&(_=`one or more CODECS in variant not supported: ${lt(t.levels.map(R=>R.attrs.CODECS).filter((R,F,L)=>L.indexOf(R)===F))}`,this.warn(_),T+=` (${_})`);const I=new Error(T);this.hls.trigger(v.ERROR,{type:ye.MEDIA_ERROR,details:$.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:I,reason:_})}}),c.end=performance.now();return}t.audioTracks&&(o=t.audioTracks.filter(T=>!T.audioCodec||this.isAudioSupported(T.audioCodec)),pm(o)),t.subtitles&&(d=t.subtitles,pm(d));const u=l.slice(0);l.sort((T,_)=>{if(T.attrs["HDCP-LEVEL"]!==_.attrs["HDCP-LEVEL"])return(T.attrs["HDCP-LEVEL"]||"")>(_.attrs["HDCP-LEVEL"]||"")?1:-1;if(i&&T.height!==_.height)return T.height-_.height;if(T.frameRate!==_.frameRate)return T.frameRate-_.frameRate;if(T.videoRange!==_.videoRange)return cl.indexOf(T.videoRange)-cl.indexOf(_.videoRange);if(T.videoCodec!==_.videoCodec){const I=of(T.videoCodec),R=of(_.videoCodec);if(I!==R)return R-I}if(T.uri===_.uri&&T.codecSet!==_.codecSet){const I=ll(T.codecSet),R=ll(_.codecSet);if(I!==R)return R-I}return T.averageBitrate!==_.averageBitrate?T.averageBitrate-_.averageBitrate:0});let h=u[0];if(this.steering&&(l=this.steering.filterParsedLevels(l),l.length!==u.length)){for(let T=0;T<u.length;T++)if(u[T].pathwayId===l[0].pathwayId){h=u[T];break}}this._levels=l;for(let T=0;T<l.length;T++)if(l[T]===h){var f;this._firstLevel=T;const _=h.bitrate,I=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${l.length} level(s) found, first bitrate: ${_}`),((f=this.hls.userConfig)==null?void 0:f.abrEwmaDefaultEstimate)===void 0){const R=Math.min(_,this.hls.config.abrEwmaDefaultEstimateMax);R>I&&I===this.hls.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=R)}break}const m=r&&!n,p=this.hls.config,g=!!(p.audioStreamController&&p.audioTrackController),y={levels:l,audioTracks:o,subtitleTracks:d,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:r,video:n,altAudio:g&&!m&&o.some(T=>!!T.url)};c.end=performance.now(),this.hls.trigger(v.MANIFEST_PARSED,y)}get levels(){return this._levels.length===0?null:this._levels}get loadLevelObj(){return this.currentLevel}get level(){return this.currentLevelIndex}set level(e){const t=this._levels;if(t.length===0)return;if(e<0||e>=t.length){const c=new Error("invalid level idx"),u=e<0;if(this.hls.trigger(v.ERROR,{type:ye.OTHER_ERROR,details:$.LEVEL_SWITCH_ERROR,level:e,fatal:u,error:c,reason:c.message}),u)return;e=Math.min(e,t.length-1)}const i=this.currentLevelIndex,n=this.currentLevel,r=n?n.attrs["PATHWAY-ID"]:void 0,a=t[e],o=a.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=a,i===e&&n&&r===o)return;this.log(`Switching to level ${e} (${a.height?a.height+"p ":""}${a.videoRange?a.videoRange+" ":""}${a.codecSet?a.codecSet+" ":""}@${a.bitrate})${o?" with Pathway "+o:""} from level ${i}${r?" with Pathway "+r:""}`);const d={level:e,attrs:a.attrs,details:a.details,bitrate:a.bitrate,averageBitrate:a.averageBitrate,maxBitrate:a.maxBitrate,realBitrate:a.realBitrate,width:a.width,height:a.height,codecSet:a.codecSet,audioCodec:a.audioCodec,videoCodec:a.videoCodec,audioGroups:a.audioGroups,subtitleGroups:a.subtitleGroups,loaded:a.loaded,loadError:a.loadError,fragmentError:a.fragmentError,name:a.name,id:a.id,uri:a.uri,url:a.url,urlId:0,audioGroupIds:a.audioGroupIds,textGroupIds:a.textGroupIds};this.hls.trigger(v.LEVEL_SWITCHING,d);const l=a.details;if(!l||l.live){const c=this.switchParams(a.uri,n?.details,l);this.loadPlaylist(c)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(e){this.manualLevelIndex=e,this._startLevel===void 0&&(this._startLevel=e),e!==-1&&(this.level=e)}get firstLevel(){return this._firstLevel}set firstLevel(e){this._firstLevel=e}get startLevel(){if(this._startLevel===void 0){const e=this.hls.config.startLevel;return e!==void 0?e:this.hls.firstAutoLevel}return this._startLevel}set startLevel(e){this._startLevel=e}get pathways(){return this.steering?this.steering.pathways():[]}get pathwayPriority(){return this.steering?this.steering.pathwayPriority:null}set pathwayPriority(e){if(this.steering){const t=this.steering.pathways(),i=e.filter(n=>t.indexOf(n)!==-1);if(e.length<1){this.warn(`pathwayPriority ${e} should contain at least one pathway from list: ${t}`);return}this.steering.pathwayPriority=i}}onError(e,t){t.fatal||!t.context||t.context.type===Ge.LEVEL&&t.context.level===this.level&&this.checkRetry(t)}onFragBuffered(e,{frag:t}){if(t!==void 0&&t.type===ge.MAIN){const i=t.elementaryStreams;if(!Object.keys(i).some(r=>!!i[r]))return;const n=this._levels[t.level];n!=null&&n.loadError&&(this.log(`Resetting level error count of ${n.loadError} on frag buffered`),n.loadError=0)}}onLevelLoaded(e,t){var i;const{level:n,details:r}=t,a=t.levelInfo;if(!a){var o;this.warn(`Invalid level index ${n}
1523`),(o=t.deliveryDirectives)!=null&&o.skip&&(r.deltaUpdateFailed=!0);return}if(a===this.currentLevel||t.withoutMultiVariant){a.fragmentError===0&&(a.loadError=0);let d=a.details;d===t.details&&d.advanced&&(d=void 0),this.playlistLoaded(n,t,d)}else(i=t.deliveryDirectives)!=null&&i.skip&&(r.deltaUpdateFailed=!0)}loadPlaylist(e){super.loadPlaylist(),this.shouldLoadPlaylist(this.currentLevel)&&this.scheduleLoading(this.currentLevel,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);const i=this.getUrlWithDirectives(e.uri,t),n=this.currentLevelIndex,r=e.attrs["PATHWAY-ID"],a=e.details,o=a?.age;this.log(`Loading level index ${n}${t?.msn!==void 0?" at sn "+t.msn+" part "+t.part:""}${r?" Pathway "+r:""}${o&&a.live?" age "+o.toFixed(1)+(a.type&&" "+a.type||""):""} ${i}`),this.hls.trigger(v.LEVEL_LOADING,{url:i,level:n,levelInfo:e,pathwayId:e.attrs["PATHWAY-ID"],id:0,deliveryDirectives:t||null})}get nextLoadLevel(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(e){this.level=e,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=e)}removeLevel(e){var t;if(this._levels.length===1)return;const i=this._levels.filter((r,a)=>a!==e?!0:(this.steering&&this.steering.removeLevel(r),r===this.currentLevel&&(this.currentLevel=null,this.currentLevelIndex=-1,r.details&&r.details.fragments.forEach(o=>o.level=-1)),!1));mv(i),this._levels=i,this.currentLevelIndex>-1&&(t=this.currentLevel)!=null&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.manualLevelIndex>-1&&(this.manualLevelIndex=this.currentLevelIndex);const n=i.length-1;this._firstLevel=Math.min(this._firstLevel,n),this._startLevel&&(this._startLevel=Math.min(this._startLevel,n)),this.hls.trigger(v.LEVELS_UPDATED,{levels:i})}onLevelsUpdated(e,{levels:t}){this._levels=t}checkMaxAutoUpdated(){const{autoLevelCapping:e,maxAutoLevel:t,maxHdcpLevel:i}=this.hls;this._maxAutoLevel!==t&&(this._maxAutoLevel=t,this.hls.trigger(v.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:e,levels:this.levels,maxAutoLevel:t,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:i}))}}function pm(s){const e={};s.forEach(t=>{const i=t.groupId||"";t.id=e[i]=e[i]||0,e[i]++})}function d0(){return self.SourceBuffer||self.WebKitSourceBuffer}function c0(){if(!Ls())return!1;const e=d0();return!e||e.prototype&&typeof e.prototype.appendBuffer=="function"&&typeof e.prototype.remove=="function"}function KR(){if(!c0())return!1;const s=Ls();return typeof s?.isTypeSupported=="function"&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(e=>s.isTypeSupported(Hr(e,"video")))||["mp4a.40.2","fLaC"].some(e=>s.isTypeSupported(Hr(e,"audio"))))}function HR(){var s;const e=d0();return typeof(e==null||(s=e.prototype)==null?void 0:s.changeType)=="function"}const VR=100;class WR extends $u{constructor(e,t,i){super(e,t,i,"stream-controller",ge.MAIN),this.audioCodecSwap=!1,this.level=-1,this._forceStartLoad=!1,this._hasEnoughToStart=!1,this.altAudio=0,this.audioOnly=!1,this.fragPlaying=null,this.fragLastKbps=0,this.couldBacktrack=!1,this.backtrackFragment=null,this.audioCodecSwitch=!1,this.videoBuffer=null,this.onMediaPlaying=()=>{this.tick()},this.onMediaSeeked=()=>{const n=this.media,r=n?n.currentTime:null;if(r===null||!he(r)||(this.log(`Media seeked to ${r.toFixed(3)}`),!this.getBufferedFrag(r)))return;const a=this.getFwdBufferInfoAtPos(n,r,ge.MAIN,0);if(a===null||a.len===0){this.warn(`Main forward buffer length at ${r} on "seeked" event ${a?a.len:"empty"})`);return}this.tick()},this.registerListeners()}registerListeners(){super.registerListeners();const{hls:e}=this;e.on(v.MANIFEST_PARSED,this.onManifestParsed,this),e.on(v.LEVEL_LOADING,this.onLevelLoading,this),e.on(v.LEVEL_LOADED,this.onLevelLoaded,this),e.on(v.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(v.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(v.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(v.BUFFER_CREATED,this.onBufferCreated,this),e.on(v.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(v.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){super.unregisterListeners();const{hls:e}=this;e.off(v.MANIFEST_PARSED,this.onManifestParsed,this),e.off(v.LEVEL_LOADED,this.onLevelLoaded,this),e.off(v.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(v.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(v.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(v.BUFFER_CREATED,this.onBufferCreated,this),e.off(v.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(v.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this.onMediaPlaying=this.onMediaSeeked=null,this.unregisterListeners(),super.onHandlerDestroying()}
vendor: 10,884 bytes, line 1523
1523startLoad(e,t){if(this.levels){const{lastCurrentTime:i,hls:n}=this;if(this.stopLoad(),this.setInterval(VR),this.level=-1,!this.startFragRequested){let r=n.startLevel;r===-1&&(n.config.testBandwidth&&this.levels.length>1?(r=0,this.bitrateTest=!0):r=n.firstAutoLevel),n.nextLoadLevel=r,this.level=n.loadLevel,this._hasEnoughToStart=!!t}i>0&&e===-1&&!t&&(this.log(`Override startPosition with lastCurrentTime @${i.toFixed(3)}`),e=i),this.state=W.IDLE,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}else this._forceStartLoad=!0,this.state=W.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case W.WAITING_LEVEL:{const{levels:e,level:t}=this,i=e?.[t],n=i?.details;if(n&&(!n.live||this.levelLastLoaded===i&&!this.waitForLive(i))){if(this.waitForCdnTuneIn(n))break;this.state=W.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=W.IDLE;break}break}case W.FRAG_LOADING_WAITING_RETRY:this.checkRetryDate();break}this.state===W.IDLE&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){var e;super.onTickEnd(),(e=this.media)!=null&&e.readyState&&this.media.seeking===!1&&(this.lastCurrentTime=this.media.currentTime),this.checkFragmentChanged()}doTickIdle(){const{hls:e,levelLastLoaded:t,levels:i,media:n}=this;if(t===null||!n&&!this.primaryPrefetch&&(this.startFragRequested||!e.config.startFragPrefetch)||this.altAudio&&this.audioOnly)return;const r=this.buffering?e.nextLoadLevel:e.loadLevel;if(!(i!=null&&i[r]))return;const a=i[r],o=this.getMainFwdBufferInfo();if(o===null)return;const d=this.getLevelDetails();if(d&&this._streamEnded(o,d)){const p={};this.altAudio===2&&(p.type="video"),this.hls.trigger(v.BUFFER_EOS,p),this.state=W.ENDED;return}if(!this.buffering)return;e.loadLevel!==r&&e.manualLevel===-1&&this.log(`Adapting to level ${r} from level ${this.level}`),this.level=e.nextLoadLevel=r;const l=a.details;if(!l||this.state===W.WAITING_LEVEL||this.waitForLive(a)){this.level=r,this.state=W.WAITING_LEVEL,this.startFragRequested=!1;return}const c=o.len,u=this.getMaxBufferLength(a.maxBitrate);if(c>=u)return;this.backtrackFragment&&this.backtrackFragment.start>o.end&&(this.backtrackFragment=null);const h=this.backtrackFragment?this.backtrackFragment.start:o.end;let f=this.getNextFragment(h,l);if(this.couldBacktrack&&!this.fragPrevious&&f&&yt(f)&&this.fragmentTracker.getState(f)!==Rt.OK){var m;const g=((m=this.backtrackFragment)!=null?m:f).sn-l.startSN,y=l.fragments[g-1];y&&f.cc===y.cc&&(f=y,this.fragmentTracker.removeFragment(y))}else this.backtrackFragment&&o.len&&(this.backtrackFragment=null);if(f&&this.isLoopLoading(f,h)){if(!f.gap){const g=this.audioOnly&&!this.altAudio?ot.AUDIO:ot.VIDEO,y=(g===ot.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;y&&this.afterBufferFlushed(y,g,ge.MAIN)}f=this.getNextFragmentLoopLoading(f,l,o,ge.MAIN,u)}f&&(f.initSegment&&!f.initSegment.data&&!this.bitrateTest&&(f=f.initSegment),this.loadFragment(f,a,h))}loadFragment(e,t,i){const n=this.fragmentTracker.getState(e);n===Rt.NOT_LOADED||n===Rt.PARTIAL?yt(e)?this.bitrateTest?(this.log(`Fragment ${e.sn} of level ${e.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(e,t)):super.loadFragment(e,t,i):this._loadInitSegment(e,t):this.clearTrackerIfNeeded(e)}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,ge.MAIN)}followingBufferedFrag(e){return e?this.getBufferedFrag(e.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}nextLevelSwitch(){const{levels:e,media:t}=this;if(t!=null&&t.readyState){let i;const n=this.getAppendedFrag(t.currentTime);n&&n.start>1&&this.flushMainBuffer(0,n.start-1);const r=this.getLevelDetails();if(r!=null&&r.live){const o=this.getMainFwdBufferInfo();if(!o||o.len<r.targetduration*2)return}if(!t.paused&&e){const o=this.hls.nextLoadLevel,d=e[o],l=this.fragLastKbps;l&&this.fragCurrent?i=this.fragCurrent.duration*d.maxBitrate/(1e3*l)+1:i=0}else i=0;const a=this.getBufferedFrag(t.currentTime+i);if(a){const o=this.followingBufferedFrag(a);if(o){this.abortCurrentFrag();const d=o.maxStartPTS?o.maxStartPTS:o.start,l=o.duration,c=Math.max(a.end,d+Math.min(Math.max(l-this.config.maxFragLookUpTolerance,l*(this.couldBacktrack?.5:.125)),l*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(c,Number.POSITIVE_INFINITY)}}}}abortCurrentFrag(){const e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case W.KEY_LOADING:case W.FRAG_LOADING:case W.FRAG_LOADING_WAITING_RETRY:case W.PARSING:case W.PARSED:this.state=W.IDLE;break}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(e,t){super.flushMainBuffer(e,t,this.altAudio===2?"video":null)}onMediaAttached(e,t){super.onMediaAttached(e,t);const i=t.media;jt(i,"playing",this.onMediaPlaying),jt(i,"seeked",this.onMediaSeeked)}onMediaDetaching(e,t){const{media:i}=this;i&&(ti(i,"playing",this.onMediaPlaying),ti(i,"seeked",this.onMediaSeeked)),this.videoBuffer=null,this.fragPlaying=null,super.onMediaDetaching(e,t),!t.transferMedia&&(this._hasEnoughToStart=!1)}onManifestLoading(){super.onManifestLoading(),this.log("Trigger BUFFER_RESET"),this.hls.trigger(v.BUFFER_RESET,void 0),this.couldBacktrack=!1,this.fragLastKbps=0,this.fragPlaying=this.backtrackFragment=null,this.altAudio=0,this.audioOnly=!1}onManifestParsed(e,t){let i=!1,n=!1;for(let r=0;r<t.levels.length;r++){const a=t.levels[r].audioCodec;a&&(i=i||a.indexOf("mp4a.40.2")!==-1,n=n||a.indexOf("mp4a.40.5")!==-1)}this.audioCodecSwitch=i&&n&&!HR(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1}onLevelLoading(e,t){const{levels:i}=this;if(!i||this.state!==W.IDLE)return;const n=t.levelInfo;(!n.details||n.details.live&&(this.levelLastLoaded!==n||n.details.expired)||this.waitForCdnTuneIn(n.details))&&(this.state=W.WAITING_LEVEL)}onLevelLoaded(e,t){var i;const{levels:n,startFragRequested:r}=this,a=t.level,o=t.details,d=o.totalduration;if(!n){this.warn(`Levels were reset while loading level ${a}`);return}this.log(`Level ${a} loaded [${o.startSN},${o.endSN}]${o.lastPartSn?`[part-${o.lastPartSn}-${o.lastPartIndex}]`:""}, cc [${o.startCC}, ${o.endCC}] duration:${d}`);const l=t.levelInfo,c=this.fragCurrent;c&&(this.state===W.FRAG_LOADING||this.state===W.FRAG_LOADING_WAITING_RETRY)&&c.level!==t.level&&c.loader&&this.abortCurrentFrag();let u=0;if(o.live||(i=l.details)!=null&&i.live){var h;if(this.checkLiveUpdate(o),o.deltaUpdateFailed)return;u=this.alignPlaylists(o,l.details,(h=this.levelLastLoaded)==null?void 0:h.details)}if(l.details=o,this.levelLastLoaded=l,r||this.setStartPosition(o,u),this.hls.trigger(v.LEVEL_UPDATED,{details:o,level:a}),this.state===W.WAITING_LEVEL){if(this.waitForCdnTuneIn(o))return;this.state=W.IDLE}r&&o.live&&this.synchronizeToLiveEdge(o),this.tick()}synchronizeToLiveEdge(e){const{config:t,media:i}=this;if(!i)return;const n=this.hls.liveSyncPosition,r=this.getLoadPosition(),a=e.fragmentStart,o=e.edge,d=r>=a-t.maxFragLookUpTolerance&&r<=o;if(n!==null&&i.duration>n&&(r<n||!d)){const c=t.liveMaxLatencyDuration!==void 0?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;if((!d&&i.readyState<4||r<o-c)&&(this._hasEnoughToStart||(this.nextLoadPosition=n),i.readyState))if(this.warn(`Playback: ${r.toFixed(3)} is located too far from the end of live sliding playlist: ${o}, reset currentTime to : ${n.toFixed(3)}`),this.config.liveSyncMode==="buffered"){var l;const u=Me.bufferInfo(i,n,0);if(!((l=u.buffered)!=null&&l.length)){i.currentTime=n;return}if(u.start<=r){i.currentTime=n;return}const{nextStart:f}=Me.bufferedInfo(u.buffered,r,0);f&&(i.currentTime=f)}else i.currentTime=n}}_handleFragmentLoadProgress(e){var t;const i=e.frag,{part:n,payload:r}=e,{levels:a}=this;if(!a){this.warn(`Levels were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`);return}const o=a[i.level];if(!o){this.warn(`Level ${i.level} not found on progress`);return}const d=o.details;if(!d){this.warn(`Dropping fragment ${i.sn} of level ${i.level} after level details were reset`),this.fragmentTracker.removeFragment(i);return}const l=o.videoCodec,c=d.PTSKnown||!d.live,u=(t=i.initSegment)==null?void 0:t.data,h=this._getAudioCodec(o),f=this.transmuxer=this.transmuxer||new Fv(this.hls,ge.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),m=n?n.index:-1,p=m!==-1,g=new Mu(i.level,i.sn,i.stats.chunkCount,r.byteLength,m,p),y=this.initPTS[i.cc];f.push(r,u,h,l,i,n,d.totalduration,c,g,y)}onAudioTrackSwitching(e,t){const i=this.hls,n=this.altAudio!==0;if(ul(t.url,i))this.altAudio=1;else{if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;const a=this.fragCurrent;a&&(this.log("Switching to main audio track, cancel main fragment load"),a.abortRequests(),this.fragmentTracker.removeFragment(a)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();if(n){this.altAudio=0,this.fragmentTracker.removeAllFragments(),i.once(v.BUFFER_FLUSHED,()=>{this.hls&&this.hls.trigger(v.AUDIO_TRACK_SWITCHED,t)}),i.trigger(v.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null});return}i.trigger(v.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){const i=ul(t.url,this.hls);if(i){const n=this.videoBuffer;n&&this.mediaBuffer!==n&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=n)}this.altAudio=i?2:0,this.tick()}onBufferCreated(e,t){const i=t.tracks;let n,r,a=!1;for(const o in i){const d=i[o];if(d.id==="main"){if(r=o,n=d,o==="video"){const l=i[o];l&&(this.videoBuffer=l.buffer)}}else a=!0}a&&n?(this.log(`Alternate track found, use ${r}.buffered to schedule main fragment loading`),this.mediaBuffer=n.buffer):this.mediaBuffer=this.media}onFragBuffered(e,t){const{frag:i,part:n}=t,r=i.type===ge.MAIN;if(r){if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${n?" p: "+n.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}`),this.state===W.PARSED&&(this.state=W.IDLE);return}const o=n?n.stats:i.stats;this.fragLastKbps=Math.round(8*o.total/(o.buffering.end-o.loading.first)),yt(i)&&(this.fragPrevious=i),this.fragBufferedComplete(i,n)}const a=this.media;a&&(!this._hasEnoughToStart&&Me.getBuffered(a).length&&(this._hasEnoughToStart=!0,this.seekToStartPos()),r&&this.tick())}get hasEnoughToStart(){return this._hasEnoughToStart}onError(e,t){var i;if(t.fatal){this.state=W.ERROR;return}switch(t.details){case $.FRAG_GAP:case $.FRAG_PARSING_ERROR:case $.FRAG_DECRYPT_ERROR:case $.FRAG_LOAD_ERROR:case $.FRAG_LOAD_TIMEOUT:case $.
vendor: 4,156 bytes, line 1523
1523KEY_LOAD_ERROR:case $.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(ge.MAIN,t);break;case $.LEVEL_LOAD_ERROR:case $.LEVEL_LOAD_TIMEOUT:case $.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===W.WAITING_LEVEL&&((i=t.context)==null?void 0:i.type)===Ge.LEVEL&&(this.state=W.IDLE);break;case $.BUFFER_ADD_CODEC_ERROR:case $.BUFFER_APPEND_ERROR:if(t.parent!=="main")return;this.reduceLengthAndFlushBuffer(t)&&this.resetLoadingState();break;case $.BUFFER_FULL_ERROR:if(t.parent!=="main")return;this.reduceLengthAndFlushBuffer(t)&&(!this.config.interstitialsController&&this.config.assetPlayerId?this._hasEnoughToStart=!0:this.flushMainBuffer(0,Number.POSITIVE_INFINITY));break;case $.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}onFragLoadEmergencyAborted(){this.state=W.IDLE,this._hasEnoughToStart||(this.startFragRequested=!1,this.nextLoadPosition=this.lastCurrentTime),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==ot.AUDIO||!this.altAudio){const i=(t===ot.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;i&&(this.afterBufferFlushed(i,t,ge.MAIN),this.tick())}}onLevelsUpdated(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level,this.level===-1&&this.resetWhenMissingContext(this.fragCurrent)),this.levels=t.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){const{media:e}=this;if(!e)return;const t=e.currentTime;let i=this.startPosition;if(i>=0&&t<i){if(e.seeking){this.log(`could not seek to ${i}, already seeking at ${t}`);return}const n=this.timelineOffset;n&&i&&(i+=n);const r=this.getLevelDetails(),a=Me.getBuffered(e),o=a.length?a.start(0):0,d=o-i,l=Math.max(this.config.maxBufferHole,this.config.maxFragLookUpTolerance);(this.config.startOnSegmentBoundary||d>0&&(d<l||this.loadingParts&&d<2*(r?.partTarget||0)))&&(this.log(`adjusting start position by ${d} to match buffer start`),i+=d,this.startPosition=i),t<i&&(this.log(`seek to target start position ${i} from current time ${t} buffer start ${o}`),e.currentTime=i)}}_getAudioCodec(e){let t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t.indexOf("mp4a.40.5")!==-1?t="mp4a.40.2":t="mp4a.40.5"),t}_loadBitrateTestFrag(e,t){e.bitrateTest=!0,this._doFragLoad(e,t).then(i=>{const{hls:n}=this,r=i?.frag;if(!r||this.fragContextChanged(r))return;t.fragmentError=0,this.state=W.IDLE,this.startFragRequested=!1,this.bitrateTest=!1;const a=r.stats;a.parsing.start=a.parsing.end=a.buffering.start=a.buffering.end=self.performance.now(),n.trigger(v.FRAG_LOADED,i),r.bitrateTest=!1}).catch(i=>{this.state===W.STOPPED||this.state===W.ERROR||(this.warn(i),this.resetFragmentLoading(e))})}_handleTransmuxComplete(e){const t=this.playlistType,{hls:i}=this,{remuxResult:n,chunkMeta:r}=e,a=this.getCurrentContext(r);if(!a){this.resetWhenMissingContext(r);return}const{frag:o,part:d,level:l}=a,{video:c,text:u,id3:h,initSegment:f}=n,{details:m}=l,p=this.altAudio?void 0:n.audio;if(this.fragContextChanged(o)){this.fragmentTracker.removeFragment(o);return}if(this.state=W.PARSING,f){const g=f.tracks;if(g){const I=o.initSegment||o;if(this.unhandledEncryptionError(f,o))return;this._bufferInitSegment(l,g,I,r),i.trigger(v.FRAG_PARSING_INIT_SEGMENT,{frag:I,id:t,tracks:g})}const y=f.initPTS,T=f.timescale,_=this.initPTS[o.cc];if(he(y)&&(!_||_.baseTime!==y||_.timescale!==T)){const I=f.trackId;this.initPTS[o.cc]={baseTime:y,timescale:T,trackId:I},i.trigger(v.INIT_PTS_FOUND,{frag:o,id:t,initPTS:y,timescale:T,trackId:I})}}if(c&&m){p&&c.type==="audiovideo"&&this.logMuxedErr(o);const g=m.fragments[o.sn-1-m.startSN],y=o.sn===m.startSN,T=!g||o.cc>g.cc;if(n.independent!==!1){const{startPTS:_,endPTS:I,startDTS:R,endDTS:F}=c;if(d)d.elementaryStreams[c.type]={startPTS:_,endPTS:I,startDTS:R,endDTS:F};else if(c.firstKeyFrame&&c.independent&&r.id===1&&!T&&(this.couldBacktrack=!0),c.dropped&&c.independent){const L=this.getMainFwdBufferInfo(),w=(L?L.end:this.getLoadPosition())+this.config.maxBufferHole,P=c.firstKeyFramePTS?c.firstKeyFramePTS:_;if(!y&&w<P-this.config.maxBufferHole&&!T){this.backtrack(o);return}else T&&(o.gap=!0);o.setElementaryStreamInfo(c.type,o.start,I,o.start,F,!0)}
vendor: 9,702 bytes, line 1523
1523else y&&_-(m.appliedTimelineOffset||0)>$o&&(o.gap=!0);o.setElementaryStreamInfo(c.type,_,I,R,F),this.backtrackFragment&&(this.backtrackFragment=o),this.bufferFragmentData(c,o,d,r,y||T)}else if(y||T)o.gap=!0;else{this.backtrack(o);return}}if(p){const{startPTS:g,endPTS:y,startDTS:T,endDTS:_}=p;d&&(d.elementaryStreams[ot.AUDIO]={startPTS:g,endPTS:y,startDTS:T,endDTS:_}),o.setElementaryStreamInfo(ot.AUDIO,g,y,T,_),this.bufferFragmentData(p,o,d,r)}if(m&&h!=null&&h.samples.length){const g={id:t,frag:o,details:m,samples:h.samples};i.trigger(v.FRAG_PARSING_METADATA,g)}if(m&&u){const g={id:t,frag:o,details:m,samples:u.samples};i.trigger(v.FRAG_PARSING_USERDATA,g)}}logMuxedErr(e){this.warn(`${yt(e)?"Media":"Init"} segment with muxed audiovideo where only video expected: ${e.url}`)}_bufferInitSegment(e,t,i,n){if(this.state!==W.PARSING)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&(delete t.audio,t.audiovideo&&this.logMuxedErr(i));const{audio:r,video:a,audiovideo:o}=t;if(r){const l=e.audioCodec;let c=Do(r.codec,l);c==="mp4a"&&(c="mp4a.40.5");const u=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){c&&(c.indexOf("mp4a.40.5")!==-1?c="mp4a.40.2":c="mp4a.40.5");const h=r.metadata;h&&"channelCount"in h&&(h.channelCount||1)!==1&&u.indexOf("firefox")===-1&&(c="mp4a.40.5")}c&&c.indexOf("mp4a.40.5")!==-1&&u.indexOf("android")!==-1&&r.container!=="audio/mpeg"&&(c="mp4a.40.2",this.log(`Android: force audio codec to ${c}`)),l&&l!==c&&this.log(`Swapping manifest audio codec "${l}" for "${c}"`),r.levelCodec=c,r.id=ge.MAIN,this.log(`Init audio buffer, container:${r.container}, codecs[selected/level/parsed]=[${c||""}/${l||""}/${r.codec}]`),delete t.audiovideo}if(a){a.levelCodec=e.videoCodec,a.id=ge.MAIN;const l=a.codec;if(l?.length===4)switch(l){case"hvc1":case"hev1":a.codec="hvc1.1.6.L120.90";break;case"av01":a.codec="av01.0.04M.08";break;case"avc1":a.codec="avc1.42e01e";break}this.log(`Init video buffer, container:${a.container}, codecs[level/parsed]=[${e.videoCodec||""}/${l}]${a.codec!==l?" parsed-corrected="+a.codec:""}${a.supplemental?" supplemental="+a.supplemental:""}`),delete t.audiovideo}o&&(this.log(`Init audiovideo buffer, container:${o.container}, codecs[level/parsed]=[${e.codecs}/${o.codec}]`),delete t.video,delete t.audio);const d=Object.keys(t);if(d.length){if(this.hls.trigger(v.BUFFER_CODECS,t),!this.hls)return;d.forEach(l=>{const u=t[l].initSegment;u!=null&&u.byteLength&&this.hls.trigger(v.BUFFER_APPENDING,{type:l,data:u,frag:i,part:null,chunkMeta:n,parent:i.type})})}this.tickImmediate()}getMainFwdBufferInfo(){const e=this.mediaBuffer&&this.altAudio===2?this.mediaBuffer:this.media;return this.getFwdBufferInfo(e,ge.MAIN)}get maxBufferLength(){const{levels:e,level:t}=this,i=e?.[t];return i?this.getMaxBufferLength(i.maxBitrate):this.config.maxBufferLength}backtrack(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=W.IDLE}checkFragmentChanged(){const e=this.media;let t=null;if(e&&e.readyState>1&&e.seeking===!1){const i=e.currentTime;if(Me.isBuffered(e,i)?t=this.getAppendedFrag(i):Me.isBuffered(e,i+.1)&&(t=this.getAppendedFrag(i+.1)),t){this.backtrackFragment=null;const n=this.fragPlaying,r=t.level;(!n||t.sn!==n.sn||n.level!==r)&&(this.fragPlaying=t,this.hls.trigger(v.FRAG_CHANGED,{frag:t}),(!n||n.level!==r)&&this.hls.trigger(v.LEVEL_SWITCHED,{level:r}))}}}get nextLevel(){const e=this.nextBufferedFrag;return e?e.level:-1}get currentFrag(){var e;if(this.fragPlaying)return this.fragPlaying;const t=((e=this.media)==null?void 0:e.currentTime)||this.lastCurrentTime;return he(t)?this.getAppendedFrag(t):null}get currentProgramDateTime(){var e;const t=((e=this.media)==null?void 0:e.currentTime)||this.lastCurrentTime;if(he(t)){const i=this.getLevelDetails(),n=this.currentFrag||(i?Qs(null,i.fragments,t):null);if(n){const r=n.programDateTime;if(r!==null){const a=r+(t-n.start)*1e3;return new Date(a)}}}return null}get currentLevel(){const e=this.currentFrag;return e?e.level:-1}get nextBufferedFrag(){const e=this.currentFrag;return e?this.followingBufferedFrag(e):null}get forceStartLoad(){return this._forceStartLoad}}class qR extends pi{constructor(e,t){super("key-loader",t),this.config=void 0,this.keyIdToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(const i in this.keyIdToKeyInfo){const n=this.keyIdToKeyInfo[i].loader;if(n){var t;if(e&&e!==((t=n.context)==null?void 0:t.frag.type))return;n.abort()}}}detach(){for(const e in this.keyIdToKeyInfo){const t=this.keyIdToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyIdToKeyInfo[e]}}destroy(){this.detach();for(const e in this.keyIdToKeyInfo){const t=this.keyIdToKeyInfo[e].loader;t&&t.destroy()}this.keyIdToKeyInfo={}}createKeyLoadError(e,t=$.KEY_LOAD_ERROR,i,n,r){return new rs({type:ye.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:r,error:i,networkDetails:n})}loadClear(e,t,i){if(this.emeController&&this.config.emeEnabled&&!this.emeController.getSelectedKeySystemFormats().length){if(t.length)for(let n=0,r=t.length;n<r;n++){const a=t[n];if(e.cc<=a.cc&&(!yt(e)||!yt(a)||e.sn<a.sn)||!i&&n==r-1)return this.emeController.selectKeySystemFormat(a).then(o=>{if(!this.emeController)return;a.setKeyFormat(o);const d=wo(o);if(d)return this.emeController.getKeySystemAccess([d])})}if(this.config.requireKeySystemAccessOnStart){const n=Tr(this.config);if(n.length)return this.emeController.getKeySystemAccess(n)}}return null}load(e){return!e.decryptdata&&e.encrypted&&this.emeController&&this.config.emeEnabled?this.emeController.selectKeySystemFormat(e).then(t=>this.loadInternal(e,t)):this.loadInternal(e)}loadInternal(e,t){var i,n;t&&e.setKeyFormat(t);const r=e.decryptdata;if(!r){const l=new Error(t?`Expected frag.decryptdata to be defined after setting format ${t}`:`Missing decryption data on fragment in onKeyLoading (emeEnabled with controller: ${this.emeController&&this.config.emeEnabled})`);return Promise.reject(this.createKeyLoadError(e,$.KEY_LOAD_ERROR,l))}const a=r.uri;if(!a)return Promise.reject(this.createKeyLoadError(e,$.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${a}"`)));const o=_d(r);let d=this.keyIdToKeyInfo[o];if((i=d)!=null&&i.decryptdata.key)return r.key=d.decryptdata.key,Promise.resolve({frag:e,keyInfo:d});if(this.emeController&&(n=d)!=null&&n.keyLoadPromise)switch(this.emeController.getKeyStatus(d.decryptdata)){case"usable":case"usable-in-future":return d.keyLoadPromise.then(c=>{const{keyInfo:u}=c;return r.key=u.decryptdata.key,{frag:e,keyInfo:u}})}switch(this.log(`${this.keyIdToKeyInfo[o]?"Rel":"L"}oading${r.keyId?" keyId: "+Bt(r.keyId):""} URI: ${r.uri} from ${e.type} ${e.level}`),d=this.keyIdToKeyInfo[o]={decryptdata:r,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},r.method){case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return r.keyFormat==="identity"?this.loadKeyHTTP(d,e):this.loadKeyEME(d,e);case"AES-128":case"AES-256":case"AES-256-CTR":return this.loadKeyHTTP(d,e);default:return Promise.reject(this.createKeyLoadError(e,$.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${r.method}"`)))}}loadKeyEME(e,t){const i={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){var n;if(!e.decryptdata.keyId&&(n=t.initSegment)!=null&&n.data){const a=uA(t.initSegment.data);if(a.length){let o=a[0];o.some(d=>d!==0)?(this.log(`Using keyId found in init segment ${Bt(o)}`),Is.setKeyIdForUri(e.decryptdata.uri,o)):(o=Is.addKeyIdForUri(e.decryptdata.uri),this.log(`Generating keyId to patch media ${Bt(o)}`)),e.decryptdata.keyId=o}}if(!e.decryptdata.keyId&&!yt(t))return Promise.resolve(i);const r=this.emeController.loadKey(i);return(e.keyLoadPromise=r.then(a=>(e.mediaKeySessionContext=a,i))).catch(a=>{throw e.keyLoadPromise=null,"data"in a&&(a.data.frag=t),a})}return Promise.resolve(i)}loadKeyHTTP(e,t){const i=this.config,n=i.loader,r=new n(i);return t.keyLoader=e.loader=r,e.keyLoadPromise=new Promise((a,o)=>{const d={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},l=i.keyLoadPolicy.default,c={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},u={onSuccess:(h,f,m,p)=>{const{frag:g,keyInfo:y}=m,T=_d(y.decryptdata);if(!g.decryptdata||y!==this.keyIdToKeyInfo[T])return o(this.createKeyLoadError(g,$.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),p));y.decryptdata.key=g.decryptdata.key=new Uint8Array(h.data),g.keyLoader=null,y.loader=null,a({frag:g,keyInfo:y})},onError:(h,f,m,p)=>{this.resetLoader(f),o(this.createKeyLoadError(t,$.KEY_LOAD_ERROR,new Error(`HTTP Error ${h.code} loading key ${h.text}`),m,Je({url:d.url,data:void 0},h)))},onTimeout:(h,f,m)=>{this.resetLoader(f),o(this.createKeyLoadError(t,$.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),m))},onAbort:(h,f,m)=>{this.resetLoader(f),o(this.createKeyLoadError(t,$.INTERNAL_ABORTED,new Error("key loading aborted"),m))}};r.load(d,c,u)})}resetLoader(e){const{frag:t,keyInfo:i,url:n}=e,r=i.loader;t.keyLoader===r&&(t.keyLoader=null,i.loader=null);const a=_d(i.decryptdata)||n;delete this.keyIdToKeyInfo[a],r&&r.destroy()}}function _d(s){if(s.keyFormat!==Gt.FAIRPLAY){const e=s.keyId;if(e)return Bt(e)}return s.uri}function vm(s){const{type:e}=s;switch(e){case Ge.AUDIO_TRACK:return ge.AUDIO;case Ge.SUBTITLE_TRACK:return ge.SUBTITLE;default:return ge.MAIN}}function Sd(s,e){let t=s.url;return(t===void 0||t.indexOf("data:")===0)&&(t=e.url),t}class YR{constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.onManifestLoaded=this.checkAutostartLoad,this.hls=e,this.registerListeners()}
vendor: 4,314 bytes, line 1523
1523startLoad(e){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){const{hls:e}=this;e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.LEVEL_LOADING,this.onLevelLoading,this),e.on(v.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(v.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.on(v.LEVELS_UPDATED,this.onLevelsUpdated,this)}unregisterListeners(){const{hls:e}=this;e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.LEVEL_LOADING,this.onLevelLoading,this),e.off(v.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(v.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.off(v.LEVELS_UPDATED,this.onLevelsUpdated,this)}createInternalLoader(e){const t=this.hls.config,i=t.pLoader,n=t.loader,r=i||n,a=new r(t);return this.loaders[e.type]=a,a}getInternalLoader(e){return this.loaders[e.type]}resetInternalLoader(e){this.loaders[e]&&delete this.loaders[e]}destroyInternalLoaders(){for(const e in this.loaders){const t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(e,t){const{url:i}=t;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:Ge.MANIFEST,url:i,deliveryDirectives:null,levelOrTrack:null})}onLevelLoading(e,t){const{id:i,level:n,pathwayId:r,url:a,deliveryDirectives:o,levelInfo:d}=t;this.load({id:i,level:n,pathwayId:r,responseType:"text",type:Ge.LEVEL,url:a,deliveryDirectives:o,levelOrTrack:d})}onAudioTrackLoading(e,t){const{id:i,groupId:n,url:r,deliveryDirectives:a,track:o}=t;this.load({id:i,groupId:n,level:null,responseType:"text",type:Ge.AUDIO_TRACK,url:r,deliveryDirectives:a,levelOrTrack:o})}onSubtitleTrackLoading(e,t){const{id:i,groupId:n,url:r,deliveryDirectives:a,track:o}=t;this.load({id:i,groupId:n,level:null,responseType:"text",type:Ge.SUBTITLE_TRACK,url:r,deliveryDirectives:a,levelOrTrack:o})}onLevelsUpdated(e,t){const i=this.loaders[Ge.LEVEL];if(i){const n=i.context;n&&!t.levels.some(r=>r===n.levelOrTrack)&&(i.abort(),delete this.loaders[Ge.LEVEL])}}load(e){var t;const i=this.hls.config;let n=this.getInternalLoader(e);if(n){const l=this.hls.logger,c=n.context;if(c&&c.levelOrTrack===e.levelOrTrack&&(c.url===e.url||c.deliveryDirectives&&!e.deliveryDirectives)){c.url===e.url?l.log(`[playlist-loader]: ignore ${e.url} ongoing request`):l.log(`[playlist-loader]: ignore ${e.url} in favor of ${c.url}`);return}l.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),n.abort()}let r;if(e.type===Ge.MANIFEST?r=i.manifestLoadPolicy.default:r=nt({},i.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),n=this.createInternalLoader(e),he((t=e.deliveryDirectives)==null?void 0:t.part)){let l;if(e.type===Ge.LEVEL&&e.level!==null?l=this.hls.levels[e.level].details:e.type===Ge.AUDIO_TRACK&&e.id!==null?l=this.hls.audioTracks[e.id].details:e.type===Ge.SUBTITLE_TRACK&&e.id!==null&&(l=this.hls.subtitleTracks[e.id].details),l){const c=l.partTarget,u=l.targetduration;if(c&&u){const h=Math.max(c*3,u*.8)*1e3;r=nt({},r,{maxTimeToFirstByteMs:Math.min(h,r.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(h,r.maxTimeToFirstByteMs)})}}}const a=r.errorRetry||r.timeoutRetry||{},o={loadPolicy:r,timeout:r.maxLoadTimeMs,maxRetry:a.maxNumRetry||0,retryDelay:a.retryDelayMs||0,maxRetryDelay:a.maxRetryDelayMs||0},d={onSuccess:(l,c,u,h)=>{const f=this.getInternalLoader(u);this.resetInternalLoader(u.type);const m=l.data;c.parsing.start=performance.now(),Yi.isMediaPlaylist(m)||u.type!==Ge.MANIFEST?this.handleTrackOrLevelPlaylist(l,c,u,h||null,f):this.handleMasterPlaylist(l,c,u,h)},onError:(l,c,u,h)=>{this.handleNetworkError(c,u,!1,l,h)},onTimeout:(l,c,u)=>{this.handleNetworkError(c,u,!0,void 0,l)}};n.load(e,o,d)}checkAutostartLoad(){if(!this.hls)return;const{config:{autoStartLoad:e,startPosition:t},forceStartLoad:i}=this.hls;(e||i)&&(this.hls.logger.log(`${e?"auto":"force"} startLoad with configured startPosition ${t}`),this.hls.startLoad(t))}handleMasterPlaylist(e,t,i,n){const r=this.hls,a=e.data,o=Sd(e,i),d=Yi.parseMasterPlaylist(a,o);if(d.playlistParsingError){t.parsing.end=performance.now(),this.handleManifestParsingError(e,i,d.playlistParsingError,n,t);return}const{contentSteering:l,levels:c,sessionData:u,sessionKeys:h,startTimeOffset:f,variableList:m}=d;
vendor: 6,251 bytes, line 1523
1523this.variableList=m,c.forEach(T=>{const{unknownCodecs:_}=T;if(_){const{preferManagedMediaSource:I}=this.hls.config;let{audioCodec:R,videoCodec:F}=T;for(let L=_.length;L--;){const w=_[L];Kr(w,"audio",I)?(T.audioCodec=R=R?`${R},${w}`:w,zn.audio[R.substring(0,4)]=2,_.splice(L,1)):Kr(w,"video",I)&&(T.videoCodec=F=F?`${F},${w}`:w,zn.video[F.substring(0,4)]=2,_.splice(L,1))}}});const{AUDIO:p=[],SUBTITLES:g,"CLOSED-CAPTIONS":y}=Yi.parseMasterPlaylistMedia(a,o,d);p.length&&!p.some(_=>!_.url)&&c[0].audioCodec&&!c[0].attrs.AUDIO&&(this.hls.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),p.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new mt({}),bitrate:0,url:""})),r.trigger(v.MANIFEST_LOADED,{levels:c,audioTracks:p,subtitles:g,captions:y,contentSteering:l,url:o,stats:t,networkDetails:n,sessionData:u,sessionKeys:h,startTimeOffset:f,variableList:m})}handleTrackOrLevelPlaylist(e,t,i,n,r){const a=this.hls,{id:o,level:d,type:l}=i,c=Sd(e,i),u=he(d)?d:he(o)?o:0,h=vm(i),f=Yi.parseLevelPlaylist(e.data,c,u,h,0,this.variableList);if(l===Ge.MANIFEST){const m={attrs:new mt({}),bitrate:0,details:f,name:"",url:c};f.requestScheduled=t.loading.start+uv(f,0),a.trigger(v.MANIFEST_LOADED,{levels:[m],audioTracks:[],url:c,stats:t,networkDetails:n,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),i.levelDetails=f,this.handlePlaylistLoaded(f,e,t,i,n,r)}handleManifestParsingError(e,t,i,n,r){this.hls.trigger(v.ERROR,{type:ye.NETWORK_ERROR,details:$.MANIFEST_PARSING_ERROR,fatal:t.type===Ge.MANIFEST,url:e.url,err:i,error:i,reason:i.message,response:e,context:t,networkDetails:n,stats:r})}handleNetworkError(e,t,i=!1,n,r){let a=`A network ${i?"timeout":"error"+(n?" (status "+n.code+")":"")} occurred while loading ${e.type}`;e.type===Ge.LEVEL?a+=`: ${e.level} id: ${e.id}`:(e.type===Ge.AUDIO_TRACK||e.type===Ge.SUBTITLE_TRACK)&&(a+=` id: ${e.id} group-id: "${e.groupId}"`);const o=new Error(a);this.hls.logger.warn(`[playlist-loader]: ${a}`);let d=$.UNKNOWN,l=!1;const c=this.getInternalLoader(e);switch(e.type){case Ge.MANIFEST:d=i?$.MANIFEST_LOAD_TIMEOUT:$.MANIFEST_LOAD_ERROR,l=!0;break;case Ge.LEVEL:d=i?$.LEVEL_LOAD_TIMEOUT:$.LEVEL_LOAD_ERROR,l=!1;break;case Ge.AUDIO_TRACK:d=i?$.AUDIO_TRACK_LOAD_TIMEOUT:$.AUDIO_TRACK_LOAD_ERROR,l=!1;break;case Ge.SUBTITLE_TRACK:d=i?$.SUBTITLE_TRACK_LOAD_TIMEOUT:$.SUBTITLE_LOAD_ERROR,l=!1;break}c&&this.resetInternalLoader(e.type);const u={type:ye.NETWORK_ERROR,details:d,fatal:l,url:e.url,loader:c,context:e,error:o,networkDetails:t,stats:r};if(n){const h=t?.url||e.url;u.response=Je({url:h,data:void 0},n)}this.hls.trigger(v.ERROR,u)}handlePlaylistLoaded(e,t,i,n,r,a){const o=this.hls,{type:d,level:l,levelOrTrack:c,id:u,groupId:h,deliveryDirectives:f}=n,m=Sd(t,n),p=vm(n);let g=typeof n.level=="number"&&p===ge.MAIN?l:void 0;const y=e.playlistParsingError;if(y){if(this.hls.logger.warn(`${y} ${e.url}`),!o.config.ignorePlaylistParsingErrors){o.trigger(v.ERROR,{type:ye.NETWORK_ERROR,details:$.LEVEL_PARSING_ERROR,fatal:!1,url:m,error:y,reason:y.message,response:t,context:n,level:g,parent:p,networkDetails:r,stats:i});return}e.playlistParsingError=null}if(!e.fragments.length){const T=e.playlistParsingError=new Error("No Segments found in Playlist");o.trigger(v.ERROR,{type:ye.NETWORK_ERROR,details:$.LEVEL_EMPTY_ERROR,fatal:!1,url:m,error:T,reason:T.message,response:t,context:n,level:g,parent:p,networkDetails:r,stats:i});return}switch(e.live&&a&&(a.getCacheAge&&(e.ageHeader=a.getCacheAge()||0),(!a.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),d){case Ge.MANIFEST:case Ge.LEVEL:if(g){if(!c)g=0;else if(c!==o.levels[g]){const T=o.levels.indexOf(c);T>-1&&(g=T)}}o.trigger(v.LEVEL_LOADED,{details:e,levelInfo:c||o.levels[0],level:g||0,id:u||0,stats:i,networkDetails:r,deliveryDirectives:f,withoutMultiVariant:d===Ge.MANIFEST});break;case Ge.AUDIO_TRACK:o.trigger(v.AUDIO_TRACK_LOADED,{details:e,track:c,id:u||0,groupId:h||"",stats:i,networkDetails:r,deliveryDirectives:f});break;case Ge.SUBTITLE_TRACK:o.trigger(v.SUBTITLE_TRACK_LOADED,{details:e,track:c,id:u||0,groupId:h||"",stats:i,networkDetails:r,deliveryDirectives:f});break}}}class Mt{static get version(){return Wr}static isMSESupported(){return c0()}static isSupported(){return KR()}static getMediaSource(){return Ls()}static get Events(){return v}static get MetadataSchema(){return oi}static get ErrorTypes(){return ye}static get ErrorDetails(){return $}static get DefaultConfig(){return Mt.defaultConfig?Mt.defaultConfig:DR}static set DefaultConfig(e){Mt.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.logger=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new Nu,this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioStreamController=void 0,this.subtititleStreamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.interstitialsController=void 0,this.gapController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this._url=null,this._sessionId=void 0,this.triggeringException=void 0,this.started=!1;const t=this.logger=JS(e.debug||!1,"Hls instance",e.assetPlayerId),i=this.config=wR(Mt.DefaultConfig,e,t);this.userConfig=e,i.progressive&&PR(i,t);const{abrController:n,bufferController:r,capLevelController:a,errorController:o,fpsController:d}=i,l=new o(this),c=this.abrController=new n(this),u=new zA(this),h=i.interstitialsController,f=h?this.interstitialsController=new h(this,Mt):null,m=this.bufferController=new r(this,u),p=this.capLevelController=new a(this),g=new d(this),y=new YR(this),T=i.contentSteeringController,_=T?new T(this):null,I=this.levelController=new GR(this,_),R=new UR(this),F=new qR(this.config,this.logger),L=this.streamController=new WR(this,u,F),w=this.gapController=new $R(this,u);p.setStreamController(L),g.setStreamController(L);const P=[y,I,L];f&&P.splice(1,0,f),_&&P.splice(1,0,_),this.networkControllers=P;
vendor: 8,024 bytes, line 1523
1523const k=[c,m,w,p,g,R,u];this.audioTrackController=this.createController(i.audioTrackController,P);const G=i.audioStreamController;G&&P.push(this.audioStreamController=new G(this,u,F)),this.subtitleTrackController=this.createController(i.subtitleTrackController,P);const se=i.subtitleStreamController;se&&P.push(this.subtititleStreamController=new se(this,u,F)),this.createController(i.timelineController,k),F.emeController=this.emeController=this.createController(i.emeController,k),this.cmcdController=this.createController(i.cmcdController,k),this.latencyController=this.createController(BR,k),this.coreComponents=k,P.push(l);const oe=l.onErrorOut;typeof oe=="function"&&this.on(v.ERROR,oe,l),this.on(v.MANIFEST_LOADED,y.onManifestLoaded,y)}createController(e,t){if(e){const i=new e(this);return t&&t.push(i),i}return null}on(e,t,i=this){this._emitter.on(e,t,i)}once(e,t,i=this){this._emitter.once(e,t,i)}removeAllListeners(e){this._emitter.removeAllListeners(e)}off(e,t,i=this,n){this._emitter.off(e,t,i,n)}listeners(e){return this._emitter.listeners(e)}emit(e,t,i){return this._emitter.emit(e,t,i)}trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(i){if(this.logger.error("An internal error happened while handling event "+e+'. Error message: "'+i.message+'". Here is a stacktrace:',i),!this.triggeringException){this.triggeringException=!0;const n=e===v.ERROR;this.trigger(v.ERROR,{type:ye.OTHER_ERROR,details:$.INTERNAL_EXCEPTION,fatal:n,event:e,error:i}),this.triggeringException=!1}}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){this.logger.log("destroy"),this.trigger(v.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this._url=null,this.networkControllers.forEach(t=>t.destroy()),this.networkControllers.length=0,this.coreComponents.forEach(t=>t.destroy()),this.coreComponents.length=0;const e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null}attachMedia(e){if(!e||"media"in e&&!e.media){const r=new Error(`attachMedia failed: invalid argument (${e})`);this.trigger(v.ERROR,{type:ye.OTHER_ERROR,details:$.ATTACH_MEDIA_ERROR,fatal:!0,error:r});return}this.logger.log("attachMedia"),this._media&&(this.logger.warn("media must be detached before attaching"),this.detachMedia());const t="media"in e,i=t?e.media:e,n=t?e:{media:i};this._media=i,this.trigger(v.MEDIA_ATTACHING,n)}detachMedia(){this.logger.log("detachMedia"),this.trigger(v.MEDIA_DETACHING,{}),this._media=null}transferMedia(){this._media=null;const e=this.bufferController.transferMedia();return this.trigger(v.MEDIA_DETACHING,{transferMedia:e}),e}loadSource(e){this.stopLoad();const t=this.media,i=this._url,n=this._url=Lu.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.logger.log(`loadSource:${n}`),t&&i&&(i!==n||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(v.MANIFEST_LOADING,{url:e})}get url(){return this._url}get hasEnoughToStart(){return this.streamController.hasEnoughToStart}get startPosition(){return this.streamController.startPositionValue}startLoad(e=-1,t){this.logger.log(`startLoad(${e+(t?", <skip seek to start>":"")})`),this.started=!0,this.resumeBuffering();for(let i=0;i<this.networkControllers.length&&(this.networkControllers[i].startLoad(e,t),!(!this.started||!this.networkControllers));i++);}stopLoad(){this.logger.log("stopLoad"),this.started=!1;for(let e=0;e<this.networkControllers.length&&(this.networkControllers[e].stopLoad(),!(this.started||!this.networkControllers));e++);}get loadingEnabled(){return this.started}get bufferingEnabled(){return this.streamController.bufferingEnabled}resumeBuffering(){this.bufferingEnabled||(this.logger.log("resume buffering"),this.networkControllers.forEach(e=>{e.resumeBuffering&&e.resumeBuffering()}))}pauseBuffering(){this.bufferingEnabled&&(this.logger.log("pause buffering"),this.networkControllers.forEach(e=>{e.pauseBuffering&&e.pauseBuffering()}))}get inFlightFragments(){const e={[ge.MAIN]:this.streamController.inFlightFrag};return this.audioStreamController&&(e[ge.AUDIO]=this.audioStreamController.inFlightFrag),this.subtititleStreamController&&(e[ge.SUBTITLE]=this.subtititleStreamController.inFlightFrag),e}swapAudioCodec(){this.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){this.logger.log("recoverMediaError");const e=this._media,t=e?.currentTime;this.detachMedia(),e&&(this.attachMedia(e),t&&this.startLoad(t))}removeLevel(e){this.levelController.removeLevel(e)}get sessionId(){let e=this._sessionId;return e||(e=this._sessionId=$L()),e}get levels(){const e=this.levelController.levels;return e||[]}get latestLevelDetails(){return this.streamController.getLevelDetails()||null}get loadLevelObj(){return this.levelController.loadLevelObj}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){this.logger.log(`set currentLevel:${e}`),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){this.logger.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(e){this.logger.log(`set loadLevel:${e}`),this.levelController.manualLevel=e}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(e){this.levelController.nextLoadLevel=e}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(e){this.logger.log(`set firstLevel:${e}`),this.levelController.firstLevel=e}get startLevel(){const e=this.levelController.startLevel;return e===-1&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e}set startLevel(e){this.logger.log(`set startLevel:${e}`),e!==-1&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(e){const t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimate():NaN}set bandwidthEstimate(e){this.abrController.resetEstimator(e)}get abrEwmaDefaultEstimate(){const{bwEstimator:e}=this.abrController;return e?e.defaultEstimate:NaN}get ttfbEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(this.logger.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){wA(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}get autoLevelEnabled(){return this.levelController.manualLevel===-1}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){const{levels:e,config:{minAutoBitrate:t}}=this;if(!e)return 0;const i=e.length;for(let n=0;n<i;n++)if(e[n].maxBitrate>=t)return n;return 0}get maxAutoLevel(){const{levels:e,autoLevelCapping:t,maxHdcpLevel:i}=this;let n;if(t===-1&&e!=null&&e.length?n=e.length-1:n=t,i)for(let r=n;r--;){const a=e[r].attrs["HDCP-LEVEL"];if(a&&a<=i)return r}return n}get firstAutoLevel(){return this.abrController.firstAutoLevel}get nextAutoLevel(){return this.abrController.nextAutoLevel}set nextAutoLevel(e){this.abrController.nextAutoLevel=e}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}get maxBufferLength(){return this.streamController.maxBufferLength}setAudioOption(e){var t;return((t=this.audioTrackController)==null?void 0:t.setAudioOption(e))||null}
1523setSubtitleOption(e){var t;return((t=this.subtitleTrackController)==null?void 0:t.setSubtitleOption(e))||null}get allAudioTracks(){const e=this.audioTrackController;return e?e.allAudioTracks:[]}get audioTracks(){const e=this.audioTrackController;return e?e.audioTracks:[]}get audioTrack(){const e=this.audioTrackController;return e?e.audioTrack:-1}set audioTrack(e){const t=this.audioTrackController;t&&(t.audioTrack=e)}get allSubtitleTracks(){const e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}get subtitleTracks(){const e=this.subtitleTrackController;return e?e.subtitleTracks:[]}get subtitleTrack(){const e=this.subtitleTrackController;return e?e.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(e){const t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}get subtitleDisplay(){const e=this.subtitleTrackController;return e?e.subtitleDisplay:!1}set subtitleDisplay(e){const t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(e){this.config.lowLatencyMode=e}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}set targetLatency(e){this.latencyController.targetLatency=e}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}get pathways(){return this.levelController.pathways}get pathwayPriority(){return this.levelController.pathwayPriority}set pathwayPriority(e){this.levelController.pathwayPriority=e}get bufferedToEnd(){var e;return!!((e=this.bufferController)!=null&&e.bufferedToEnd)}get interstitialsManager(){var e;return((e=this.interstitialsController)==null?void 0:e.interstitialsManager)||null}getMediaDecodingInfo(e,t=this.allAudioTracks){const i=Xp(t);return zp(e,i,navigator.mediaCapabilities)}}Mt.defaultConfig=void 0;const zR=s=>class extends s{static shadowRootOptions={...s.shadowRootOptions};static getTemplateHTML=(t,i={})=>{const{src:n,...r}=t;return` 1524 <script type="application/json" id="config"> 1525 ${JSON.stringify(i.config||{})} 1526 <\/script> 1527 ${s.getTemplateHTML(r)} 1528 `};#e=null;#t=null;constructor(){super(),this.#n("config")}get config(){return this.#t}set config(t){this.#t=t}attributeChangedCallback(t,i,n){t!=="src"&&super.attributeChangedCallback(t,i,n),t==="src"&&i!=n&&this.load()}#i(){var t,i;(t=this.#e)==null||t.remove(),(i=this.nativeEl)==null||i.removeEventListener("webkitcurrentplaybacktargetiswirelesschanged",this.#s),this.api&&(this.api.detachMedia(),this.api.destroy(),this.api=null)}async load(){var t,i;const n=!this.api;if(this.#i(),!!this.src){if(n&&!this.#t&&(this.#t=JSON.parse(((t=this.shadowRoot.getElementById("config"))==null?void 0:t.textContent)||"{}")),Mt.isSupported()){switch(await Promise.resolve(),this.api=new Mt({liveDurationInfinity:!0,autoStartLoad:!1,...this.config}),this.api.loadSource(this.src),this.api.attachMedia(this.nativeEl),this.nativeEl.preload){case"none":{const l=()=>this.api.startLoad();this.nativeEl.addEventListener("play",l,{once:!0}),this.api.on(Mt.Events.DESTROYING,()=>{this.nativeEl.removeEventListener("play",l)});break}case"metadata":{const l=this.api.config.maxBufferLength,c=this.api.config.maxBufferSize;this.api.config.maxBufferLength=1,this.api.config.maxBufferSize=1;const u=()=>{this.api.config.maxBufferLength=l,this.api.config.maxBufferSize=c};this.nativeEl.addEventListener("play",u,{once:!0}),this.api.on(Mt.Events.DESTROYING,()=>{this.nativeEl.removeEventListener("play",u)}),this.api.startLoad();break}default:this.api.startLoad()}this.nativeEl.webkitCurrentPlaybackTargetIsWireless&&this.api.stopLoad(),this.nativeEl.addEventListener("webkitcurrentplaybacktargetiswirelesschanged",this.#s),this.#e=document.createElement("source"),this.#e.setAttribute("type","application/x-mpegURL"),this.#e.setAttribute("src",this.src),this.nativeEl.disableRemotePlayback=!1,this.nativeEl.append(this.#e);const r=new WeakMap;this.api.on(Mt.Events.MANIFEST_PARSED,(l,c)=>{this.nativeEl.autoplay&&this.nativeEl.paused&&this.nativeEl.play().catch(h=>{console.warn("Autoplay failed:",h)}),d();let u=this.videoTracks.getTrackById("main");u||(u=this.addVideoTrack("main"),u.id="main",u.selected=!0);for(const[h,f]of c.levels.entries()){const m=u.addRendition(f.url[0],f.width,f.height,f.videoCodec,f.bitrate);r.set(f,`${h}`),m.id=`${h}`}for(let[h,f]of c.audioTracks.entries()){const m=f.default?"main":"alternative",p=this.addAudioTrack(m,f.name,f.lang);p.id=`${h}`,f.default&&(p.enabled=!0)}}),this.audioTracks.addEventListener("change",()=>{var l;const c=+((l=[...this.audioTracks].find(h=>h.enabled))==null?void 0:l.id),u=this.api.audioTracks.map(h=>h.id);c!=this.api.audioTrack&&u.includes(c)&&(this.api.audioTrack=c)}),this.api.on(Mt.Events.LEVELS_UPDATED,(l,c)=>{const u=this.videoTracks[this.videoTracks.selectedIndex??0];if(!u)return;const h=c.levels.map(f=>r.get(f));for(const f of this.videoRenditions)f.id&&!h.includes(f.id)&&u.removeRendition(f)});let a=null;this.api.on(Mt.Events.ERROR,(l,c)=>
1528{c.type===Mt.ErrorTypes.NETWORK_ERROR&&c.details===Mt.ErrorDetails.FRAG_LOAD_ERROR&&(a=c.frag.level)}),this.api.on(Mt.Events.LEVEL_SWITCHED,(l,c)=>{const u=c.level;a!==null&&u<a&&(console.warn(`â ï¸ hls.js downgraded quality from level ${a} to ${u} due to fragment load failure.`),this.videoRenditions.selectedIndex=u,a=null)});const o=l=>{const c=l.target.selectedIndex;c!=this.api.nextLevel&&(this.api.nextLevel=c)};(i=this.videoRenditions)==null||i.addEventListener("change",o);const d=()=>{for(const l of this.videoTracks)this.removeVideoTrack(l);for(const l of this.audioTracks)this.removeAudioTrack(l)};this.api.once(Mt.Events.DESTROYING,d);return}await Promise.resolve(),this.nativeEl.canPlayType("application/vnd.apple.mpegurl")&&(this.nativeEl.src=this.src)}}#s=()=>{var t,i,n;(t=this.nativeEl)!=null&&t.webkitCurrentPlaybackTargetIsWireless?(i=this.api)==null||i.stopLoad():(n=this.api)==null||n.startLoad()};#n(t){if(Object.prototype.hasOwnProperty.call(this,t)){const i=this[t];delete this[t],this[t]=i}}},jR=zR(KS(DS));globalThis.customElements&&!globalThis.customElements.get("hls-video")&&globalThis.customElements.define("hls-video",jR);function yl(s){"@babel/helpers - typeof";return yl=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},yl(s)}var XR=(typeof HTMLElement>"u"?"undefined":yl(HTMLElement))==="object";function Ad(s){return XR?s instanceof HTMLElement:s&&yl(s)==="object"&&s!==null&&s.nodeType===1&&typeof s.nodeName=="string"}function os(s,e){e.forEach(function(t){s.classList.add(t)})}function Ui(s,e){e.forEach(function(t){s.classList.remove(t)})}var QR=".drift-bounding-box,.drift-zoom-pane{position:absolute;pointer-events:none}@keyframes noop{0%{zoom:1}}@-webkit-keyframes noop{0%{zoom:1}}.drift-zoom-pane.drift-open{display:block}.drift-zoom-pane.drift-closing,.drift-zoom-pane.drift-opening{animation:noop 1ms;-webkit-animation:noop 1ms}.drift-zoom-pane{overflow:hidden;width:100%;height:100%;top:0;left:0}.drift-zoom-pane-loader{display:none}.drift-zoom-pane img{position:absolute;display:block;max-width:none;max-height:none}";function ZR(){if(!document.querySelector(".drift-base-styles")){var s=document.createElement("style");s.type="text/css",s.classList.add("drift-base-styles"),s.appendChild(document.createTextNode(QR));var e=document.head;e.insertBefore(s,e.firstChild)}}function ei(){throw new Error("Missing parameter")}function JR(s,e){if(!(s instanceof e))throw new TypeError("Cannot call a class as a function")}function ek(s,e){for(var t=0;t<e.length;t++){var i=e[t];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(s,i.key,i)}}function tk(s,e,t){return e&&ek(s.prototype,e),Object.defineProperty(s,"prototype",{writable:!1}),s}var ik=(function(){function s(e){JR(this,s),this.isShowing=!1;var t=e.namespace,i=t===void 0?null:t,n=e.zoomFactor,r=n===void 0?ei():n,a=e.containerEl,o=a===void 0?ei():a;this.settings={namespace:i,zoomFactor:r,containerEl:o},this.openClasses=this._buildClasses("open"),this._buildElement()}return tk(s,[{key:"_buildClasses",value:function(t){var i=["drift-".concat(t)],n=this.settings.namespace;return n&&i.push("".concat(n,"-").concat(t)),i}},{key:"_buildElement",value:function(){this.el=document.createElement("div"),os(this.el,this._buildClasses("bounding-box"))}},{key:"show",value:function(t,i){this.isShowing=!0,this.settings.containerEl.appendChild(this.el);var n=this.el.style;n.width="".concat(Math.round(t/this.settings.zoomFactor),"px"),n.height="".concat(Math.round(i/this.settings.zoomFactor),"px"),os(this.el,this.openClasses)}},{key:"hide",value:function(){this.isShowing&&this.settings.containerEl.removeChild(this.el),this.isShowing=!1,Ui(this.el,this.openClasses)}},{key:"setPosition",value:function(t,i,n){var r=window.pageXOffset,a=window.pageYOffset,o=n.left+t*n.width-this.el.clientWidth/2+r,d=n.top+i*n.height-this.el.clientHeight/2+a;o<n.left+r?o=n.left+r:o+this.el.clientWidth>n.left+n.width+r&&(o=n.left+n.width-this.el.clientWidth+r),d<n.top+a?d=n.top+a:d+this.el.clientHeight>n.top+n.height+a&&(d=n.top+n.height-this.el.clientHeight+a),this.el.style.left="".concat(o,"px"),this.el.style.top="".concat(d,"px")}}]),s})();function sk(s,e){if(!(s instanceof e))throw new TypeError("Cannot call a class as a function")}function nk(s,e){for(var t=0;t<e.length;t++){var i=e[t];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(s,i.key,i)}}function rk(s,e,t){return e&&nk(s.prototype,e),Object.defineProperty(s,"prototype",{writable:!1}),s}var ak=(function(){function s(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};sk(this,s),this._show=this._show.bind(this),this._hide=this._hide.bind(this),this._handleEntry=this._handleEntry.bind(this),this._handleMovement=this._handleMovement.bind(this);var t=e.el,i=t===void 0?ei():t,n=e.zoomPane,r=n===void 0?ei():n,a=e.sourceAttribute,o=a===void 0?ei():a,d=e.handleTouch,l=d===void 0?ei():d,c=e.onShow,u=c===void 0?null:c,h=e.onHide,f=h===void 0?null:h,m=e.hoverDelay,p=m===void 0?0:m,g=e.touchDelay,y=g===void 0?0:g,T=e.hoverBoundingBox,_=T===void 0?ei():T,I=e.touchBoundingBox,R=I===void 0?ei():I,F=e.namespace,L=F===void 0?null:F,w=e.zoomFactor,P=w===void 0?ei():w,k=e.boundingBoxContainer,G=k===void 0?ei():k,se=e.passive,oe
1528=se===void 0?!1:se;this.settings={el:i,zoomPane:r,sourceAttribute:o,handleTouch:l,onShow:u,onHide:f,hoverDelay:p,touchDelay:y,hoverBoundingBox:_,touchBoundingBox:R,namespace:L,zoomFactor:P,boundingBoxContainer:G,passive:oe},(this.settings.hoverBoundingBox||this.settings.touchBoundingBox)&&(this.boundingBox=new ik({namespace:this.settings.namespace,zoomFactor:this.settings.zoomFactor,containerEl:this.settings.boundingBoxContainer})),this.enabled=!0,this._bindEvents()}return rk(s,[{key:"_preventDefault",value:function(t){t.preventDefault()}},{key:"_preventDefaultAllowTouchScroll",value:function(t){(!this.settings.touchDelay||!this._isTouchEvent(t)||this.isShowing)&&t.preventDefault()}},{key:"_isTouchEvent",value:function(t){return!!t.touches}},{key:"_bindEvents",value:function(){this.settings.el.addEventListener("mouseenter",this._handleEntry),this.settings.el.addEventListener("mouseleave",this._hide),this.settings.el.addEventListener("mousemove",this._handleMovement);var t={passive:this.settings.passive};this.settings.handleTouch?(this.settings.el.addEventListener("touchstart",this._handleEntry,t),this.settings.el.addEventListener("touchend",this._hide),this.settings.el.addEventListener("touchmove",this._handleMovement,t)):(this.settings.el.addEventListener("touchstart",this._preventDefault,t),this.settings.el.addEventListener("touchend",this._preventDefault),this.settings.el.addEventListener("touchmove",this._preventDefault,t))}},{key:"_unbindEvents",value:function(){this.settings.el.removeEventListener("mouseenter",this._handleEntry),this.settings.el.removeEventListener("mouseleave",this._hide),this.settings.el.removeEventListener("mousemove",this._handleMovement),this.settings.handleTouch?(this.settings.el.removeEventListener("touchstart",this._handleEntry),this.settings.el.removeEventListener("touchend",this._hide),this.settings.el.removeEventListener("touchmove",this._handleMovement)):(this.settings.el.removeEventListener("touchstart",this._preventDefault),this.settings.el.removeEventListener("touchend",this._preventDefault),this.settings.el.removeEventListener("touchmove",this._preventDefault))}},{key:"_handleEntry",value:function(t){this._preventDefaultAllowTouchScroll(t),this._lastMovement=t,t.type=="mouseenter"&&this.settings.hoverDelay?this.entryTimeout=setTimeout(this._show,this.settings.hoverDelay):this.settings.touchDelay?this.entryTimeout=setTimeout(this._show,this.settings.touchDelay):this._show()}},{key:"_show",value:function(){if(this.enabled){var t=this.settings.onShow;if(t&&typeof t=="function"&&t(),this.settings.zoomPane.show(this.settings.el.getAttribute(this.settings.sourceAttribute),this.settings.el.clientWidth,this.settings.el.clientHeight),this._lastMovement){var i=this._lastMovement.touches;(i&&this.settings.touchBoundingBox||!i&&this.settings.hoverBoundingBox)&&this.boundingBox.show(this.settings.zoomPane.el.clientWidth,this.settings.zoomPane.el.clientHeight)}this._handleMovement()}}},{key:"_hide",value:function(t){t&&this._preventDefaultAllowTouchScroll(t),this._lastMovement=null,this.entryTimeout&&clearTimeout(this.entryTimeout),this.boundingBox&&this.boundingBox.hide();var i=this.settings.onHide;i&&typeof i=="function"&&i(),this.settings.zoomPane.hide()}},{key:"_handleMovement",value:function(t){if(t)this._preventDefaultAllowTouchScroll(t),this._lastMovement=t;else if(this._lastMovement)t=this._lastMovement;else return;var i,n;if(t.touches){var r=t.touches[0];i=r.clientX,n=r.clientY}else i=t.clientX,n=t.clientY;var a=this.settings.el,o=a.getBoundingClientRect(),d=i-o.left,l=n-o.top,c=d/this.settings.el.clientWidth,u=l/this.settings.el.clientHeight;this.boundingBox&&this.boundingBox.setPosition(c,u,o),this.settings.zoomPane.setPosition(c,u,o)}},{key:"isShowing",get:function(){return this.settings.zoomPane.isShowing}}]),s})();function ok(s,e){if(!(s instanceof e))throw new TypeError("Cannot call a class as a function")}function lk(s,e){for(var t=0;t<e.length;t++){var i=e[t];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(s,i.key,i)}}function dk(s,e,t){return e&&lk(s.prototype,e),Object.defineProperty(s,"prototype",{writable:!1}),s}var ck=(function(){function s(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};
1528if(ok(this,s),this.HAS_ANIMATION=!1,typeof document<"u"){var t=document.createElement("div").style;this.HAS_ANIMATION="animation"in t||"webkitAnimation"in t}this._completeShow=this._completeShow.bind(this),this._completeHide=this._completeHide.bind(this),this._handleLoad=this._handleLoad.bind(this),this.isShowing=!1;var i=e.container,n=i===void 0?null:i,r=e.zoomFactor,a=r===void 0?ei():r,o=e.inline,d=o===void 0?ei():o,l=e.namespace,c=l===void 0?null:l,u=e.showWhitespaceAtEdges,h=u===void 0?ei():u,f=e.containInline,m=f===void 0?ei():f,p=e.inlineOffsetX,g=p===void 0?0:p,y=e.inlineOffsetY,T=y===void 0?0:y,_=e.inlineContainer,I=_===void 0?document.body:_;this.settings={container:n,zoomFactor:a,inline:d,namespace:c,showWhitespaceAtEdges:h,containInline:m,inlineOffsetX:g,inlineOffsetY:T,inlineContainer:I},this.openClasses=this._buildClasses("open"),this.openingClasses=this._buildClasses("opening"),this.closingClasses=this._buildClasses("closing"),this.inlineClasses=this._buildClasses("inline"),this.loadingClasses=this._buildClasses("loading"),this._buildElement()}return dk(s,[{key:"_buildClasses",value:function(t){var i=["drift-".concat(t)],n=this.settings.namespace;return n&&i.push("".concat(n,"-").concat(t)),i}},{key:"_buildElement",value:function(){this.el=document.createElement("div"),os(this.el,this._buildClasses("zoom-pane"));var t=document.createElement("div");os(t,this._buildClasses("zoom-pane-loader")),this.el.appendChild(t),this.imgEl=document.createElement("img"),this.el.appendChild(this.imgEl)}}
1528,{key:"_setImageURL",value:function(t){this.imgEl.setAttribute("src",t)}},{key:"_setImageSize",value:function(t,i){this.imgEl.style.width="".concat(t*this.settings.zoomFactor,"px"),this.imgEl.style.height="".concat(i*this.settings.zoomFactor,"px")}},{key:"setPosition",value:function(t,i,n){var r=this.imgEl.offsetWidth,a=this.imgEl.offsetHeight,o=this.el.offsetWidth,d=this.el.offsetHeight,l=o/2,c=d/2,u=r*t,h=a*i,f=l-u,m=c-h,p=o-r,g=d-a,y=p>0,T=g>0,_=y?p/2:0,I=T?g/2:0,R=y?p/2:p,F=T?g/2:g;if(this.el.parentElement===this.settings.inlineContainer){var L=window.pageXOffset,w=window.pageYOffset,P=n.left+t*n.width-o/2+this.settings.inlineOffsetX+L,k=n.top+i*n.height-d/2+this.settings.inlineOffsetY+w;this.settings.containInline&&(P<n.left+L?P=n.left+L:P+o>n.left+n.width+L&&(P=n.left+n.width-o+L),k<n.top+w?k=n.top+w:k+d>n.top+n.height+w&&(k=n.top+n.height-d+w)),this.el.style.left="".concat(P,"px"),this.el.style.top="".concat(k,"px")}this.settings.showWhitespaceAtEdges||(f>_?f=_:f<R&&(f=R),m>I?m=I:m<F&&(m=F)),this.imgEl.style.transform="translate(".concat(f,"px, ").concat(m,"px)"),this.imgEl.style.webkitTransform="translate(".concat(f,"px, ").concat(m,"px)")}},{key:"_removeListenersAndResetClasses",value:function(){this.el.removeEventListener("animationend",this._completeShow),this.el.removeEventListener("animationend",this._completeHide),this.el.removeEventListener("webkitAnimationEnd",this._completeShow),this.el.removeEventListener("webkitAnimationEnd",this._completeHide),Ui(this.el,this.openClasses),Ui(this.el,this.closingClasses)}},{key:"show",value:function(t,i,n){this._removeListenersAndResetClasses(),this.isShowing=!0,os(this.el,this.openClasses),this.imgEl.getAttribute("src")!=t&&(os(this.el,this.loadingClasses),this.imgEl.addEventListener("load",this._handleLoad),this._setImageURL(t)),this._setImageSize(i,n),this._isInline?this._showInline():this._showInContainer(),this.HAS_ANIMATION&&(this.el.addEventListener("animationend",this._completeShow),this.el.addEventListener("webkitAnimationEnd",this._completeShow),os(this.el,this.openingClasses))}},{key:"_showInline",value:function(){this.settings.inlineContainer.appendChild(this.el),os(this.el,this.inlineClasses)}},{key:"_showInContainer",value:function(){this.settings.container.appendChild(this.el)}},{key:"hide",value:function(){this._removeListenersAndResetClasses(),this.isShowing=!1,this.HAS_ANIMATION?(this.el.addEventListener("animationend",this._completeHide),this.el.addEventListener("webkitAnimationEnd",this._completeHide),os(this.el,this.closingClasses)):(Ui(this.el,this.openClasses),Ui(this.el,this.inlineClasses))}},{key:"_completeShow",value:function(){this.el.removeEventListener("animationend",this._completeShow),this.el.removeEventListener("webkitAnimationEnd",this._completeShow),Ui(this.el,this.openingClasses)}},{key:"_completeHide",value:function(){this.el.removeEventListener("animationend",this._completeHide),this.el.removeEventListener("webkitAnimationEnd",this._completeHide),Ui(this.el,this.openClasses),Ui(this.el,this.closingClasses),Ui(this.el,this.inlineClasses),this.el.style.left="",this.el.style.top="",this.el.parentElement===this.settings.container?this.settings.container.removeChild(this.el):this.el.parentElement===this.settings.inlineContainer&&this.settings.inlineContainer.removeChild(this.el)}},{key:"_handleLoad",value:function(){this.imgEl.removeEventListener("load",this._handleLoad),Ui(this.el,this.loadingClasses)}},{key:"_isInline",get:function(){var t=this.settings.inline;return t===!0||typeof t=="number"&&window.innerWidth<=t}}]),s})();function uk(s,e){if(!(s instanceof e))throw new TypeError("Cannot call a class as a function")}function hk(s,e){for(var t=0;t<e.length;t++){var i=e[t];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(s,i.key,i)}}function fk(s,e,t){return e&&hk(s.prototype,e),Object.defineProperty(s,"prototype",{writable:!1}),s}var di=(function(){function s(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(uk(this,s),this.VERSION="1.5.1",this.triggerEl=e,this.destroy=this.destroy.bind(this),!Ad(this.triggerEl))throw new TypeError("`new Drift` requires a DOM element as its first argument.");var i=t.namespace||null,n=t.showWhitespaceAtEdges||!1,r=t.containInl
1528ine||!1,a=t.inlineOffsetX||0,o=t.inlineOffsetY||0,d=t.inlineContainer||document.body,l=t.sourceAttribute||"data-zoom",c=t.zoomFactor||3,u=t.paneContainer===void 0?document.body:t.paneContainer,h=t.inlinePane||375,f="handleTouch"in t?!!t.handleTouch:!0,m=t.onShow||null,p=t.onHide||null,g="injectBaseStyles"in t?!!t.injectBaseStyles:!0,y=t.hoverDelay||0,T=t.touchDelay||0,_=t.hoverBoundingBox||!1,I=t.touchBoundingBox||!1,R=t.boundingBoxContainer||document.body,F=t.passive||!1;if(h!==!0&&!Ad(u))throw new TypeError("`paneContainer` must be a DOM element when `inlinePane !== true`");if(!Ad(d))throw new TypeError("`inlineContainer` must be a DOM element");this.settings={namespace:i,showWhitespaceAtEdges:n,containInline:r,inlineOffsetX:a,inlineOffsetY:o,inlineContainer:d,sourceAttribute:l,zoomFactor:c,paneContainer:u,inlinePane:h,handleTouch:f,onShow:m,onHide:p,injectBaseStyles:g,hoverDelay:y,touchDelay:T,hoverBoundingBox:_,touchBoundingBox:I,boundingBoxContainer:R,passive:F},this.settings.injectBaseStyles&&ZR(),this._buildZoomPane(),this._buildTrigger()}return fk(s,[{key:"_buildZoomPane",value:function(){this.zoomPane=new ck({container:this.settings.paneContainer,zoomFactor:this.settings.zoomFactor,showWhitespaceAtEdges:this.settings.showWhitespaceAtEdges,containInline:this.settings.containInline,inline:this.settings.inlinePane,namespace:this.settings.namespace,inlineOffsetX:this.settings.inlineOffsetX,inlineOffsetY:this.settings.inlineOffsetY,inlineContainer:this.settings.inlineContainer})}},{key:"_buildTrigger",value:function(){this.trigger=new ak({el:this.triggerEl,zoomPane:this.zoomPane,handleTouch:this.settings.handleTouch,onShow:this.settings.onShow,onHide:this.settings.onHide,sourceAttribute:this.settings.sourceAttribute,hoverDelay:this.settings.hoverDelay,touchDelay:this.settings.touchDelay,hoverBoundingBox:this.settings.hoverBoundingBox,touchBoundingBox:this.settings.touchBoundingBox,namespace:this.settings.namespace,zoomFactor:this.settings.zoomFactor,boundingBoxContainer:this.settings.boundingBoxContainer,passive:this.settings.passive})}},{key:"setZoomImageURL",value:function(t){this.zoomPane._setImageURL(t)}},{key:"disable",value:function(){this.trigger.enabled=!1}},{key:"enable",value:function(){this.trigger.enabled=!0}},{key:"destroy",value:function(){this.trigger._hide(),this.trigger._unbindEvents()}},{key:"isShowing",get:function(){return this.zoomPane.isShowing}},{key:"zoomFactor",get:function(){return this.settings.zoomFactor},set:function(t){this.settings.zoomFactor=t,this.zoomPane.settings.zoomFactor=t,this.trigger.settings.zoomFactor=t,this.boundingBox.settings.zoomFactor=t}}]),s})();Object.defineProperty(di.prototype,"isShowing",{get:function(){return this.isShowing}});Object.defineProperty(di.prototype,"zoomFactor",{get:function(){return this.zoomFactor},set:function(e){this.zoomFactor=e}});di.prototype.setZoomImageURL=di.prototype.setZoomImageURL;di.prototype.disable=di.prototype.disable;di.prototype.enable=di.prototype.enable;di.prototype.destroy=di.prototype.destroy;const mk=Tm` 1529query FetchTicketSlotAvailability( 1530 $currentPage: Int! 1531 $perPage: Int! 1532 $filters: [PaginationFilterInput] 1533) { 1534 EX_EVNT_SlotsPaginated( 1535 currentPage: $currentPage 1536 perPage: $perPage 1537 order: "start_at" 1538 direction: "asc" 1539 filters: $filters 1540 ) { 1541 items { 1542 id 1543 available_seats 1544 canceled_at 1545 } 1546 } 1547} 1548`,gk=cE(()=>Sm(()=>import("./Kuc4_L8N.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32]),import.meta.url).then(s=>s.default||s)),pk={key:0,class:"details co-section container mx-auto"},vk={class:"sticky-box"},Ek={key:0,class:"placeholder rounded rounded-b-none h-96 w-96 mx-auto"},yk={key:0,class:"thumbnails"},Tk=["onClick","data-pswp-width","data-pswp-height","data-video-src","data-video-mime","data-media-id"],bk=["src"],_k={class:"name"},Sk={class:"nr"},Ak=["innerHTML"],Ik={class:"properties relative"},xk={key:1,class:"coupons mb-10"},Lk={class:"form-field"},Rk={class:"label"},kk={class:"control"},Dk={class:"coupon-option flex gap-2"},Ck={key:0,class:"amount"},wk={class:"coupon-option flex gap-2"},Pk={key:0,class:"amount"},Mk={key:2,class:"event-sessions mb-10"},Ok={class:"label"},Fk={class:"sessions"},$k={class:"date"},Nk={key:0,class:"seats is-full"},Uk={key:1,class:"seats"},Bk={key:0,class:"ticket-sold-out"},Gk={key:3,class:"ticket-categories mb-10"},Kk={class:"form-field"},Hk={class:"label"},Vk={class:"control"},Wk={class:"single-unit-price"},qk={key:0,class:"price"},Yk={key:0,class:"whitespace-nowrap sale"}
1548,zk=["innerHTML"],jk={key:1,class:"price-uvp"},Xk={class:"whitespace-nowrap"},Qk={key:5,class:"buttons noPrices"},Zk={class:"left"},Jk={key:0,class:"custom-number-input"},e1=["aria-label"],t1={class:"m-auto text-2xl font-light"},i1=["aria-label"],s1={class:"m-auto text-2xl font-light"},n1={class:"right"},r1=["href"],a1={class:"buttons relative"},o1={key:0,class:"articles-loading-bar"},l1={key:1,class:"alert warning mt-4 w-full flex items-center gap-2"},d1={class:"left flex gap-4"},c1=["disabled","aria-label"],u1={key:0,class:"wish-list-spinner spin"},h1=["disabled","aria-label"],f1={key:0,class:"wish-list-spinner spin"},m1={key:2,class:"custom-number-input"},g1=["disabled","aria-label"],p1={class:"m-auto text-2xl font-light"},v1=["disabled","aria-label"],E1=["disabled","aria-label"],y1={class:"m-auto text-2xl font-light"},T1={key:0,class:"right flex gap-4"},b1=["disabled","aria-label"],_1={key:0,class:"absolute inset-0 flex items-center justify-center"},S1={class:"accordion"},A1={class:"info-properties"},I1={key:1,class:"matrix co-section container mx-auto"},x1={key:2,class:"related-articles co-section container mx-auto"},L1={key:3,class:"related-articles co-section container mx-auto"},R1={key:4,class:"category-post co-section"},k1={name:"shop[product]"},D1=jr({...k1,async setup(s,{expose:e}){let t,i;const n=Z0(),r=Gn(),a=["true","1","yes",!0].includes(r.settings?.["express-checkout-on-product-page"]),o=xd(),d=J0(),l=Tl(),c=Qc();[t,i]=Ha(()=>Va("product")),await t,i(),[t,i]=Ha(()=>Va("shop")),await t,i(),[t,i]=Ha(()=>Va("form")),await t,i();const u=Xe(0),h=Xe(!1),f=Xe({}),m=Xe({});function p(E){if(!E)return;const b=l.indexedArticles?.find(C=>C.sku===E)||l.articles?.find(C=>C.sku===E);if(!b)return;const A=b.properties||[],M=[];A.forEach(C=>{const D=vt.value.find(ce=>ce.id===C.id);if(!D||!D.options||D.options.length<=1)return;const U=(C.values||[])[0];if(!U)return;const Z=(D.options||[]).find(ce=>ce.id===U.id);Z&&(f.value[D.id]={label:D.label,articleRequired:D.articleRequired,...Z,position:vt.value.findIndex(ce=>ce.id===D.id)},D.key&&M.push({propertyKey:D.key,optionId:Z.id}))}),or(()=>{M.forEach(({propertyKey:C,optionId:D})=>{T.fields?.[C]?.setValue&&T.fields[C].setValue(D)})})}const g=Xe(1),y=Xe(null),T=oE({validation:void 0,fields:{}}),_=Xe(null),I=Xe(null),R=Xe(null),F=Xe(null),L=Xe(null),w=Xe(null),P=r.settings?.["product-details-image-zoom-lens-size"]||"size-normal",k=r.settings?.["product-details-image-zoom-factor"]||"3",G=r.settings?.["product-details-image-shadow"]||"box-shadow-0",se=r.settings?.["product-details-thumbnail-position"]||"thumb-pos-b",oe=r.settings?.["product-details-property-show-discount-label"]||!1,de=r.settings?.["shop-hide-prices-for-guests-button-text"]||J("product:please-login"),ae=r.settings?.["shop-hide-prices-for-guests-button-link"]||"/login",ie=r.settings?.["product-details-matrix-x-achsis-attribute"],ue=r.settings?.["product-details-matrix-y-achsis-attribute"],ee=r.settings?.["shop-sell-regardless-of-stock"];e({picture:F,zoom:L,zoomInlineRight:w});const te=Xe(),ve=Xe([]),X=Xe([]),Y=Xe(!1),Ie=async E=>{const{client:b}=lr(),A=c.isAuthenticated?null:fh();if(!(!c.isAuthenticated&&!A))try{const{data:M}=await b.query({query:hE,variables:{product_id:parseInt(String(E)),cart:l.cart?.id?parseInt(String(l.cart.id)):null,session_id:A},fetchPolicy:"network-only"});ve.value=M?.CO_ShoppingCartArticles||[],ve.value.forEach(C=>{const D=C.article_id||C.article?.id;if(D){const U=mh(`matrix-input-qty:${D}`);U.value=C.qty||0}})}catch{ve.value=[]}},De=async E=>{const{client:b}=lr(),A=c.isAuthenticated?null:fh();if(!(!c.isAuthenticated&&!A))try{const{data:M}=await b.query({query:fE,variables:{product_id:parseInt(String(E)),wishList:l.wishList?.id?parseInt(String(l.wishList.id)):null,session_id:A},fetchPolicy:"network-only"});X.value=M?.CO_WishListArticles||[],X.value.forEach(C=>{const D=C.article_id||C.article?.id;if(D){const U=mh(`matrix-input-qty:${D}`);U.value=C.qty||0}})}catch{X.value=[]}},Re=Xe(new Map),Ce=z(()=>{if(h.value){const b=Re.value.get(h.value.id);if(b?.length)return b;if(h.value.relatedArticles?.length)return h.value.relatedArticles}if(Object.values(f.value).filter(b=>b.articleRequired).length>0&&H.value&&H.value.length)for(const b of H.value){const A=Re.value.get(b.id);if(A?.length)return A;if(b.relatedArticles&&b.relatedArticles.length)return b.relatedArticles}return l.relatedArticles||void 0}),dt=z(()=>l.indexedProduct?null:h.value?h.value.id:Object.values(f.value).filter(b=>b.articleRequired).length>0&&H.value?.length?H.value[0].id:null),je=lr("apq").client;St(dt,async E=>{if(!(!E||!je)&&!Re.value.has(E))try{const{data:b}=await je.query({query:xm,variables:{id:parseInt(String(E))}});b?.CO_Article?.relatedArticles?.length&&Re.value.set(E,b.CO_Article.relatedArticles)}catch(b){console.error("On-demand related articles fetch error:",b?.message)}},{immediate:!0});const ne=z(()=>{if(!l.indexedArticles||!l.indexedArticles.length)return;const E=A=>l.indexedArticles?.find(M=>String(M.id)===String(A));if(h.value){const A=E(h.value.id);if(A&&A.related_article_ids&&A.related_article_ids.length)return A.related_article_ids}if(te.value){const A=E(te.value.id);if(A&&A.related_article_ids&&A.related_article_ids.length)return A.related_article_ids}if(Object.values(f.value).filter(A=>A.articleRequired).length>0&&H.value&&H.value.length)for(const A of H.value){const M=E(A.id);if(M&&M.related_article_ids&&M.related_article_ids.length)return M.related_article_ids}if(l.indexedProduct&&l.indexedProduct.related_article_ids&&l.indexedProduct.related_article_ids.length)return l.indexedProduct.related_article_ids}),We=z(()=>{if(!l.indexedArticles?.length)return;const E=A=>l.indexedArticles?.find(M=>String(M.id)===String(A));if(h.value&&E(h.value.id)?.related_article_ids?.length)return parseInt(String(h.value.id));if(te.value&&E(te.value.id)?.related_article_ids?.length)return parseInt(String(te.value.id));if(Object.values(f.value).filter(A=>A.articleRequired).length>0&&H.value?.length){for(const A of H.value)if(E(A.id)?.related_article_ids?.length)return parseInt(String(A.id))}}),V=d.id,fe=Xe([...d.sections||[]]);St([()=>l.indexedProduct,()=>l.product],()=>{fe.value=[...d.sections||[]]}),St(()=>d.sections,E=>{E&&E.length&&d.id===V&&(fe.value=[...E])});const Oe=z(()=>{let E={};return fe.value.forEach(b=>{const A=b.area||"main";E[A]||(E[A]=[]),E[A].push(b)}),E}),Fe=z(()=>
1548l.product?.nr||l.indexedProduct?.nr),Ue=z(()=>{if(!r?.CMS||r?.CMS?.i18n)return d.language}),Te=z(()=>{if(l.articles?.length)return l.articles;if(!l.indexedArticles?.length)return[];let E;l.customer?.customerGroup?E=l.customer.customerGroup:l.resolvedGuestGroup.id?E={id:l.resolvedGuestGroup.id,key:l.resolvedGuestGroup.key,currency:l.resolvedGuestGroup.currency}:E=l.defaultCustomerGroup;const b=E?.key||"guests",A=E?.id,M=A&&A===l.defaultCustomerGroup?.id;return l.indexedArticles.map(C=>{const D=(C.properties||[]).filter(Ke=>Ke.source==="article"||Ke.article_required).flatMap(Ke=>(Ke.values||[]).map(zt=>({property:{id:Ke.id,key:Ke.key,propType:{value_field:Ke.type,value_field_alt:Ke.type}},valueOption:{[Ke.type]:Ke.type==="number"?parseFloat(zt.default):zt.default,id:zt.option_id||zt.id}}))),U=Ke=>{const zt=C.prices||[];return Ke==="sale"?zt.find(Le=>Le.type==="sale"&&Le.customer_group_id==A&&(!Le.start_at||nn(Le.start_at)<=new Date)&&(!Le.end_at||nn(Le.end_at)>=new Date)):M?zt.find(Le=>Le.type==="main"):zt.find(Le=>Le.type==="group"&&Le.customer_group_id==A)},Z=U("main"),ce=(C.prices||[]).find(Ke=>Ke.type==="main"),N=Z||(C.coupon?.type==="fixed"&&C.coupon?.amount?{id:0,gross_value:C.coupon.amount,net_value:C.coupon.amount}:void 0),Q=U("sale"),le=(C.media||[]).map(Ke=>({...Ke,settings:{show:{detail:Ke.detail!==!1,list:Ke.list!==!1}}})),Ne=C.qty?.[b]??0;return{id:C.id,sku:C.sku,name:C.name,slots:C.slots||[],slots_count:C.slots_count,requires_shipping:C.requires_shipping,propertyPivots:D,price:N?{id:N.id,value:N.gross_value,net_value:N.net_value,gross_value:N.gross_value,tax_rate:N.tax_rate,tax_value:N.tax_value,customerGroup:N.customer_group,surcharges:N.surcharges}:null,mainPrice:ce?{id:ce.id,value:ce.gross_value,net_value:ce.net_value,gross_value:ce.gross_value,tax_rate:ce.tax_rate,tax_value:ce.tax_value,customerGroup:ce.customer_group,surcharges:ce.surcharges}:null,salePrice:Q?{id:Q.id,value:Q.gross_value,net_value:Q.net_value,gross_value:Q.gross_value,tax_rate:Q.tax_rate,tax_value:Q.tax_value,customerGroup:Q.customer_group,surcharges:Q.surcharges}:null,media:le,qty_sum:Ne,sellable:C.sellable,unit:C.unit?.label,quantity:C.unit?.quantity||1,manage_stock:C.manage_stock,related_article_ids:C.related_article_ids,coupon:C.coupon,str:C.str,int:C.int,float:C.float,txt:C.txt,bool:C.bool,restock_date:C.restock_date}})}),$e=z(()=>{const E=Te.value,b=l.product?.manage_stock??l.indexedProduct?.manage_stock??!1;return!l.ignoreArticleStock&&b&&E?.length?E.filter(A=>{let M=0;return ve.value.forEach(C=>{String(C.article_id||C.article?.id)===String(A.id)&&(M+=C.qty)}),(A.qty_sum||0)>M}):E}),H=z(()=>{let E=$e.value;return $e.value?.length?$e.value.filter(b=>{const A=(l.product?.type||l.indexedProduct?.type)==="event";if((Jr.value||A)&&te.value&&te.value?.id!==b.id)return!1;let M=!0;return M&&b.propertyPivots.forEach(C=>{const D=C.valueOption,U=C.property;if(U&&f.value[U.id]){const Z=f.value[U.id];D[Z.key]!==Z.value&&(M=!1)}}),M}):E}),be=z(()=>{const E=r.settings?.["product-details-combine-infos"]||!1;return["true","1","yes",!0].includes(E)}),_e=z(()=>{const E=r.settings?.["product-details-hide-infos"]||!1;return["true","1","yes",!0].includes(E)}),Se=z(()=>r.settings?.["product-details-title"]||J("info")),Ye=z(()=>r.settings?.["product-desc-title"]||J("product:product-description")),rt=z(()=>{const E=r.settings?.["product-hide-desc"]||!1;return["true","1","yes",!0].includes(E)}),qe=z(()=>{const E=r.settings?.["product-details-custom-field-hide"]||!1;return["true","1","yes",!0].includes(E)}),Xt=z(()=>r.settings?.["product-details-custom-field-title"]),bt=z(()=>r.settings?.["product-details-custom-field-desc"]),Xi=z(()=>{let E=r.settings?.["shipping-info-addition"]||"";if(E||J("product:shipping-info-addition"),hs?.value?.taxRate!=null)return l.showNetPrices?`${J("product:plus-tax",{rate:lE(y.value,2)})} ${E}`.trim():`${J("product:incl-tax",{rate:y.value})} ${E}`.trim()}),kt=z(()=>r.settings?.["product-details-single-unit-price"]),Js=z(()=>{let E=!1;return["show-if-differs","show-always"].includes(kt.value)&&(E=r.settings?.["product-details-single-unit-hide-total-price"]||!1),E}),pt=z(()=>{let E=!1;return["show-if-differs","show-always"].includes(kt.value)?(E=r.settings?.["product-details-single-unit-hide-total-price"]||!1,E):["true",!0].includes(E)}),Ze=z(()=>{let E;return l.product?.translations?.length&&Ue.value?.code&&(E=l.product?.translations.find(b=>b.language?.code===Ue.value?.code),!E&&o.language&&(E=l.product?.translations.find(b=>b.language?.code===o.language))),E}),en=z(()=>{let E;if(H.value?.length&&Ue.value?.code){const b=H.value[0].translations||[];E=b.find(A=>A.language?.code===Ue.value?.code),!E&&o.language&&(E=b.find(A=>A.language?.code===o.language))}return E}),ut=z(()=>l.product?.id||l.indexedProduct?.id),_t=z(()=>{let E;return Ue.value?.code?(H.value?.length&&(E=en.value?.name),E||(E=Ze.value?.name)):H.value?.length&&(E=H.value[0].name),E||(E=l.product?.name||l.indexedProduct?.name),E}),Qt=z(()=>{let E;return Ue.value?.code&&(E=Ze.value?.teaser),E||(E=l.product?.teaser||l.indexedProduct?.teaser),E}),Zr=z(()=>{let E;if(H.value?.length&&(Ue.value?.code&&en.value?.description&&(E=en.value.description),!E&&H.value[0].description&&(E=H.value[0].description)),!E&&Ue.value?.code&&Ze.value&&(E=Ze.value.description),E||(E=l.product?.description||l.indexedProduct?.description),E)return Id(E)}),ks=z(()=>{let E=l.product?.media||l.indexedProduct?.media||[];return h.value?.media?E=h.value.media:Object.values(f.value).filter(b=>b.articleRequired).length&&H.value?.length&&H.value[0].media?.length&&(E=H.value[0].media),E=E.filter(b=>dE(b,"detail")),E.sort((b,A)=>(b?.position||0)-(A?.position||0))}),Qu=E=>{const b=E?.url||E?.source?.url||(E?.files||[]).find(A=>A?.mime?.startsWith("video/"))?.url;return b?`${b}#t=0.1`:null},vt=z(()=>{let E=[];if(!l.product&&l.indexedProduct?.properties?.length)l.indexedProduct.properties.forEac
1548h(b=>{const A=(b.values||[]).filter(U=>U.default||U.alternative).map(U=>{let Z,ce=0;const N=l.customer?.customerGroup?.id||l.resolvedGuestGroup.id||l.defaultCustomerGroup?.id;if(U.prices?.length&&N&&(Z=U.prices.find(le=>le.customer_group_id==N),Z)){let le="gross_value";l.showNetPrices&&(le="net_value"),ce=Z[le]}const Q={id:U.id,image:U.image,group:U.group,value:U.default,valueAlt:U.alternative,key:b.type,position:U.position||1/0,surcharge:ce,price:Z};return b?.type==="number"&&(Q.value=parseFloat(Q.value)),Q});let M=b.visible_on_detail_page;A.length===1&&A[0].price&&(M=!0),(b.type==="input"||b.type==="upload")&&(M=!0);let C=null;if(b.prices?.length){const U=l.customer?.customerGroup?.id||l.resolvedGuestGroup.id||l.defaultCustomerGroup?.id;U&&(C=b.prices.find(Z=>Z.customer_group_id==U))}const D={id:b.id,key:b.key,type:b.type,unit:b.unit,inputField:b.input_type,minRows:b.min_rows,maxRows:b.max_rows,minInput:b.min_input,maxInput:b.max_input,maxFileSize:b.max_file_size,allowedMimeTypes:b.allowed_mime_types,component:b.component,datetype:b.datetype,price:C,label:b.name,articleRequired:b.article_required,isRequired:b.
1548is_required??!0,options:A,visible:M};D.type==="input"&&D.minRows==null&&(D.minRows=1),E.push(D)});else{const b=A=>{const M=A.property?.propType;if(!M){console.error("Property type missing for property pivot",A);return}return A.valueOptions.map(D=>{const U=M.value_field;let Z=oa(D,U),ce;const N=M.value_field_alt;N&&(ce=oa(D,N));let Q,le;if((D.pivot?.price?.value>=0||D.price?.value>=0)&&(le=D.pivot?.price?.value||D.price.value,Q=D.pivot?.price||D.price,(l.customer?.tax_free||l.showNetPrices)&&(le/=1+y.value/100)),Ue.value?.code){const Ne=D?.translations?.find(Ke=>Ke.language?.code===Ue.value?.code);Ne?.[U]&&(Z=oa(Ne,U)),Ne?.[N]&&(ce=oa(Ne,N))}return{id:D.id,image:D.image,group:D.group,price:Q,surcharge:le,value:Z,valueAlt:ce,key:U,position:D.position||1/0}}).filter(D=>D.value||D.valueAlt)};l.product?.propertyPivots?.length&&l.product.propertyPivots.forEach(A=>{const M=A.property?.id,C=A.property?.key,D=A.property?.datetype,U=A.property?.propType?.key,Z=A.property?.unit,ce=A.property?.input_type,N=A.property?.min_rows,Q=A.property?.max_rows,le=A.property?.min_input,Ne=A.property?.max_input,Ke=A.property?.max_file_size,zt=A.property?.allowed_mime_types,Le=A.property?.component,re=A.property?.price;let ii=A.property?.visible_on_detail_page,na=A.property?.name;if(Ue.value?.code){const ah=A.property?.translations?.find(U0=>U0.language?.code===Ue.value?.code);ah?.name&&(na=ah.name)}const $0=A.property?.article_required,N0=A.property?.is_required??!0;(U==="input"||U==="upload")&&(ii=!0);const Bl=b(A);Bl?.length===1&&Bl[0].price&&(ii=!0);let ra={id:M,key:C,type:U,unit:Z,inputField:ce,minRows:N,maxRows:Q,minInput
1548:le,maxInput:Ne,maxFileSize:Ke,allowedMimeTypes:zt,component:Le,datetype:D,price:re,label:na,options:Bl,articleRequired:$0,isRequired:N0,visible:ii};ra.type==="input"&&ra.minRows==null&&(ra.minRows=1),E.push(ra)})}return E.filter(b=>b.visible===!0||b.options?.length>1)}),Zn=z(()=>{if(l.product)return l.product?.manage_stock||!1;if(l.indexedProduct)return l.indexedProduct?.manage_stock||!1}),u0=z(()=>vt.value.filter(E=>E?.options?.length===1).length||Zr.value),Jr=z(()=>l.product?.type==="coupon"||l.indexedProduct?.type==="coupon"),Ml=z(()=>Te.value?.filter(E=>E.coupon)??[]),ea=z(()=>vt.value.filter(E=>Jr.value&&E.articleRequired?!1:E.options.length>1)),Ds=z(()=>{const E=r.settings?.["product-details-matrix-x-achsis-attribute"],b=r.settings?.["product-details-matrix-y-achsis-attribute"],A=r.settings?.["product-details-matrix-customer-group-key-regex"];return A&&(!l.customer?.customerGroup?.key||!new RegExp(A).test(l.customer?.customerGroup?.key))?!1:["true","1","yes",!0].includes(r.settings?.["product-details-matrix"])&&ea.value.length<=2&&x0.value.length===0&&!!vt.value.find(M=>M.key===E&&M.options.length)&&!!vt.value.find(M=>M.key===b&&M.options.length)}),ta=z(()=>{const E=Te.value,b=new Map;return E.forEach(A=>{const M=`${A.str??""}_${A.int??""}`;b.has(M)||b.set(M,{name:A.str??null,int:A.int??null,articles:[]}),b.get(M).articles.push(A)}),Array.from(b.values()).sort((A,M)=>A.int===null&&M.int===null?0:A.int===null?1:M.int===null?-1:A.int-M.int)}),Zu=z(()=>ta.value.length>1||ta.value.length===1&&ta.value[0].name!==null),h0=E=>{if(!Zu.value)return vt.value;const b=new Set;return E.forEach(A=>{A.propertyPivots&&A.propertyPivots.forEach(M=>{M.valueOption?.id&&b.add(parseInt(String(M.valueOption.id)))})}),vt.value.map(A=>{const M=A.options.filter(C=>b.has(parseInt(String(C.id))));return{...A,options:M}})},f0=z(()=>X.value?.length>0),tn=E=>{te.value=E},Ju=()=>{te.value=void 0},eh=E=>{const b=E.coupon;
1548if(b)switch(b.type){case"percentage":return`${b.percentage}%`;case"fixed":let A="gross_value";l.showNetPrices&&(A="net_value");let M=b.amount;if(M||(M=E.price?.[A]),!M)return;const C=E.price?.customerGroup?.currency?.iso4217||l.currency;return Pe(M,C)}},m0=E=>{h.value&&h.value.id===E?.id?h.value=!1:E?.media&&(h.value=E)},g0=({property:E,option:b})=>{if(f.value[E.id]&&f.value[E.id].id===b.id)delete f.value[E.id];else{const A={label:E.label,articleRequired:E.articleRequired,...b};if(f.value[E.id]=A,f.value[E.id].position=vt.value.findIndex(M=>M.id===E.id),$e.value.length){let M=0;for(;!H.value.length&&M<1;){++M;let C=!1;C||vt.value.forEach(D=>{D.articleRequired&&D.options.length&&f.value[D.id]&&D.id!==E.id&&$e.value.filter(Z=>{let ce=!0;return Z.propertyPivots.forEach(N=>{const Q=N.valueOption,le=N.property;if(le&&D.id!==le.id&&f.value[le.id]){const Ne=f.value[le.id];Q[Ne.key]!==Ne.value&&(ce=!1)}}),ce}).length&&(delete f.value[D.id],C=!0)})}}}T.fields[E.key].setValue(f.value[E.id]?.id)};St([()=>n.params.sku,()=>vt.value?.length||0,()=>l.indexedArticles?.length||0,()=>l.articles?.length||0,()=>l.product?.propertyPivots?.length||0],([E,b,A,M])=>{E&&b&&(!A&&!M||p(String(E)))},{immediate:!0});const p0=({property:E,value:b,row:A=0})=>{if(m.value[E.id]||(m.value[E.id]={label:E.label,property:E,pivot:{value:""},position:vt.value.findIndex(M=>M.id===E.id)}),E.inputField==="textarea")b?m.value[E.id].pivot.value=b:delete m.value[E.id],T.fields?.[E.key]!==void 0&&T.fields[E.key].setValue(b||void 0);else{let M=m.value[E.id].pivot.value?m.value[E.id].pivot.value.split(` 1549`):[];for(M[A]=b;M.length&&M[M.length-1]==="";)M.pop();M.length===0?delete m.value[E.id]:m.value[E.id].pivot.value=M.join(` 1550`);const C=`row-${A}`;if(T.fields?.[E.key]?.[C]!==void 0&&T.fields[E.key][C].setValue(b||void 0),T.fields?.[E.key]!==void 0){const D=M.reduce((U,Z,ce)=>(U[`row-${ce}`]=Z,U),{});T.fields[E.key].setValue(D||void 0)}}},v0=({property:E,file:b,upload:A})=>{const M=vt.value.findIndex(D=>D.id===E.id);if(!b){const D=m.value[E.id]?.fileData?.url;D&&D.startsWith("blob:")&&URL.revokeObjectURL(D),delete m.value[E.id],T.fields?.[E.key]!==void 0&&T.fields[E.key].setValue(void 0);return}const C=URL.createObjectURL(b);m.value[E.id]={label:E.label,property:E,pivot:{value:String(A.id)},position:M,fileData:{id:A.id,url:C,name:A.name||b.name,mime:A.mime||b.type,size:A.size||b.size},uploading:!1},T.fields?.[E.key]!==void 0&&T.fields[E.key].setValue(String(A.id))},E0=async()=>{const{valid:E,errors:b}=await T.validation.validate();if(!E){const A={id:Qi(),title:J("error"),text:J("product:please-fill-all-required-fields"),type:"error",autoclose:8e3};r.addMessage(A);return}if(!H.value?.length||H.value.length>1){const A={id:Qi(),title:J("error"),text:J("technical-problem"),type:"error",autoclose:8e3};r.addMessage(A)}else{const A=H.value[0],M=A?.price?.gross_value||A?.price?.value,C=A?.coupon?.amount||A?.coupon?.type==="percentage",D=Jr.value&&!A?.coupon;if(!A?.id||!M&&!C||D){r.addMessage({id:Qi(),title:J("error"),text:J("technical-problem"),type:"error",autoclose:8e3});return}let U=ws(H.value[0]);if(l.product)U.product=ws(l.product),delete U.product.articles;else if(l.indexedProduct){const Le=l.indexedProduct;U.product={id:Le.id,nr:Le.nr,slug:Le.slug,name:Le.name,manage_stock:Le.manage_stock}}let Z=[];Object.values(f.value).map(Le=>{Le.articleRequired||Z.push(Le.id)});let ce=[];Object.values(m.value).map(Le=>{(Le.property.type==="input"||Le.property.type==="upload")&&ce.push({id:Le.property.id,pivot:Le.pivot})});let N=g.value;l.ignoreArticleStock||(N=Math.min(us.value,g.value));const Q={article:U,productPropertyValues:Z,filledUserInputs:ce,qty:N},le=[...ve.value],Ne=le.findIndex(Le=>String(Le.article_id||Le.article?.id)===String(U.id));Ne>=0?ve.value=le.map((Le,re)=>re===Ne?{...Le,qty:Le.qty+N}:Le):ve.value=[...le,{id:`optimistic-${Date.now()}`,article_id:U.id,qty:N,propertyValueOptions:[],properties:[]}];try{await l.addArticleToCart(Q,sh.value,{immediate:!0});const Le=U.salePrice||U.price,{track:re}=hh();re("AddToCart",{content_ids:[U.id],content_type:"product",value:Le?Le.gross_value:void 0,currency:l.currency});const ii=uh();ii.track("add_to_cart",{currency:ii.currencyOf(Le),value:Le?Le.gross_value:void 0,items:ii.toItems([U],{quantity:Q.qty||1})})}catch(Le){ve.value=le,console.error("Error adding article to cart:",Le);const re={id:Qi(),title:J("error"),text:J("technical-problem"),type:"error",autoclose:8e3};r.addMessage(re);return}const Ke=Object.values(f.value).map(Le=>({label:Le.label,value:Le.value,position:Le.position})),zt=Object.values(m.value).map(Le=>({label:Le.label,value:Le.pivot.value,position:Le.position}));ph().showAddToCartSuccess({name:_t.value,nr:Fe.value,price:fs.value?.formatted||hs.value?.formatted,values:[...Ke,...zt]}),f.value={},m.value={},g.value=1}},y0=async()=>{const{valid:E,errors:b}=await T.validation.validate();if(!E){const A={id:Qi(),title:J("error"),text:J("product:please-fill-all-required-fields"),type:"error",autoclose:8e3};r.addMessage(A);return}if(!H.value?.length||H.value.length>1){const A={id:Qi(),title:J("error"),text:J("technical-problem"),type:"error",autoclose:8e3};r.addMessage(A)}else{let A=ws(H.value[0]);if(l.product)A.product=ws(l.product),delete A.product.articles;else if(l.indexedProduct){const N=l.indexedProduct;A.product={id:N.id,nr:N.nr,slug:N.slug,name:N.name,manage_stock:N.manage_stock}}let M=[];Object.values(f.value).map(N=>{N.articleRequired||M.push(N.id)});let C=[];Object.values(m.value).map(N=>{(N.property.type==="input"||N.property.type==="upload")&&C.push({id:N.property.id,pivot:N.pivot})});let D=g.value;l.ignoreArticleStock||(D=Math.min(us.value,g.value));const U={article:A,productPropertyValues:M,filledUserInputs:C,qty:D};Y.value=!0;try{await l.addArticleToWishList(U,sh.value);const N=l.product?.id||l.indexedProduct?.id;N&&await De(parseInt(String(N)))}catch(N){console.error("Error adding article to wish list:",N);const Q={id:Qi(),title:J("error"),text:J("technical-problem"),type:"error",autoclose:8e3};r.addMessage(Q),Y.value=!1;return}Y.value=!1;const Z=Object.values(f.value).map(N=>({label:N.label,value:N.value,position:N.position})),ce=Object.values(m.value).map(N=>({label:N.label,value:N.pivot.value,position:N.position}));ph().showAddToWishlistSuccess({name:_t.value,nr:Fe.value,values:[...Z,...ce]}),f.value={},m.value={},g.value=1}},T0=async()=>{const E=l.product?.id||l.indexedProduct?.id;if(!E)return;Y.value=!0;const b=[...X.value];X.value=[];try{await l.dropProductFromWishList(parseInt(String(E)),b)}catch(C){X.value=b,console.error("Error removing article from wish list:",C);const D={id:Qi(),title:J("error"),text:J("technical-problem"),type:"error",autoclose:8e3};r.addMessage(D),Y.value=!1;return}Y.value=!1;let A=` 1551 <p>${J("product:article-removed-from-wish-list")}</p> 1552 <blockquote class="mt-2 pl-3 border-l-2 border-sky-300 border-opacity-50"> 1553 <h4 class="text-xl leading-none mb-1">${_t.value}</h4> 1554 <p class="text-xs mb-2 text-slate-600">#${Fe.value}</p> 1555 </blockquote> 1556 `;const M={id:Qi(),text:A,type:"info",autoclose:4e3};r.addMessage(M)},cs=z(()=>T.validation?.meta?.valid),us=z(()=>{let E=1/0;return Zn.value&&!l.ignoreArticleStock&&H.value?.length===1&&H.value[0]?.qty_sum!==null&&(E=H.value[0].qty_sum),E}),Ol=z(()=>Zn.value&&!l.ignoreArticleStock&&!$e.value?.length),b0=z(()=>{if(l.articlesLoading||ee===!0||ee==="true")return!1;let E=!1;if(l.product?.id)E=!$e.value?.length&&!ve.value?.length;else if(l.indexedProduct?.id){const b=l.resolvedGuestGroupKey||"guests";if(l.indexedArticles&&l.indexedArticles.length){const A=l.customer?.customerGroup?.key||l.defaultCustomerGroup?.key,M=c.isAuthenticated?A:b;E=!l.indexedArticles.some(C=>C.sellable&&C.sellable[M]===!0)}else{const A=l.customer?.customerGroup?.key||l.defaultCustomerGroup?.key,M=c.isAuthenticated?A:b;E=l.indexedProduct?.sellable?.[M]!==!0}}return E});St(()=>g.value,E=>{E<1?g.value=1:!l.ignoreArticleStock&&E>us.value&&(g.value=us.value),T.fields.qty.value=g.value}),St(()=>H.value?.length,E=>{T.fields.articles.value=H.value?.length}),St(()=>l.product?.id,E=>{E&&(Ie(E),De(E))},{immediate:!0}),St(()=>(l.product||l.indexedProduct)?.id,E=>{if(!E)return;const b=l.product||l.indexedProduct,A=b?.salePrice||b?.price,M=uh(),C=M.toItems([b]),D=C[0]?.price,{track:U}=hh();U("ViewContent",{content_ids:[E],content_type:"product",value:D,currency:l.currency}),M.track("view_item",{currency:M.currencyOf(A),value:D,items:C})},{immediate:!0}),St(()=>l.cart.initialized,E=>{E&&l.product?.id&&Ie(l.product.id)}),St(()=>l.wishList.initialized,E=>{E&&l.product?.id&&De(l.product.id)});const sn=z(()=>(l.product?.type||l.indexedProduct?.type)==="event"),ia=z(()=>[...te.value?.slots||l.product?.slots||l.indexedProduct?.slots||[]].map(b=>({...b,available_seats:b.available_seats??Fl.value[b.id]??null})).sort((b,A)=>(b.start_at||0)-(A.start_at||0))),Fl=Xe({}),_0=async()=>
1556{if(!sn.value)return;const E=l.product?.event?.id||l.indexedProduct?.event?.id;if(!(!E||!je))try{const{data:b}=await je.query({query:mk,variables:{currentPage:1,perPage:200,filters:[{key:"events",in:[parseInt(String(E))]}]},fetchPolicy:"network-only"}),A={};for(const M of b?.EX_EVNT_SlotsPaginated?.items||[])A[M.id]=M.canceled_at?0:M.available_seats;Fl.value=A}catch(b){console.error(b)}};St(()=>[sn.value,l.product?.id,l.indexedProduct?.id],()=>{_0()},{immediate:!0});const S0=E=>{const b=E?.slots||[];return b.length?b.some(A=>{const M=A.available_seats??Fl.value[A.id]??null;return M!==null&&M<1}):!1},th=z(()=>{if(!cs.value||Ol.value||$l.value||ea.value.length!==Object.keys(f.value).length)return;const E=H.value;return E?.length===1?E[0]:te.value}),A0=E=>{const b=(E?.name||"").trim();if(b)return b;const A=E?.slots_count??(E?.slots||[]).length;return J("shop:ticket-session-count",{count:A})},sa=z(()=>Te.value.map(E=>({...E,ticketVariantName:A0(E),$isDisabled:S0(E)}))),$l=z(()=>!sn.value||!ia.value.length?!1:ia.value.some(E=>E.available_seats!==null&&E.available_seats<1)),I0=E=>{if(!E?.start_at)return"";const b=new Date(E.start_at*1e3),A=E.end_at?new Date(E.end_at*1e3):null,M=b.toLocaleDateString(void 0,{weekday:"short",day:"2-digit",month:"2-digit",year:"numeric"}),C=b.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}),D=A?A.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}):null;return D?`${M}, ${C} - ${D}`:`${M}, ${C}`},Nl=z(()=>{if(!sn.value||!sa.value?.length)return;const E=n.query?.ticket;return sa.value.find(b=>String(b.id)===String(E))||sa.value[0]});Nl.value?tn(Nl.value):St(()=>Nl.value,E=>{E&&tn(E)});const Ul=z(()=>{const E=l.product?.type||l.indexedProduct?.type;if((l.product?.id||l.indexedProduct?.id)&&Te.value?.length&&E==="coupon")return[...Te.value].filter(M=>M.coupon?.type==="fixed"&&M.coupon?.amount).sort((M,C)=>(M.coupon?.amount||0)-(C.coupon?.amount||0))[0]||Te.value[0]});Ul.value?tn(Ul.value):St(()=>Ul.value,E=>{E&&tn(E)});const Yt=z(()=>{const E=Math.min(ks.value.length-1,u.value);return ks.value[E]}),x0=z(()=>vt.value.filter(E=>E.options&&E.options.length>1&&E.articleRequired===!1)),ih=z(()=>vt.value.filter(E=>E.options&&E.options.length<=1)),L0=z(()=>vt.value.filter(E=>E.options.length>1&&!f.value[E.id])),R0=z(()=>{let E={"product-details--matrix":Ds.value,"product-details--out-of-stock":Ol.value,"product-details--has-combined-infos":u0.value};for(const[b,A]of Object.entries(f.value))E[`selected-option-${A.id}`]=!0,E[`selected-property-${b}`]===void 0&&(E[`selected-property-${b}`]=!0);L0.value.forEach(b=>{E[`pending-property-${b.id}`]=!0});for(const[b,A]of Object.entries(m.value)){let M=A.pivot.value?A.pivot.value.trim().split(` 1557`):[];for(;M.length&&M[M.length-1]==="";)M.pop();E[`user-input-${b}`]=M.length}return E}),xe=z(()=>{let E=0;if(l.product===void 0&&l.indexedProduct!==void 0){l.indexedProduct.properties?.length&&l.indexedProduct.properties.forEach(b=>{if(b.values?.length!==1)return;const A=b.values[0];if(A.prices?.length){const M=l.customer?.customerGroup?.id||l.resolvedGuestGroup.id||l.defaultCustomerGroup?.id;if(M){const C=A.prices.find(D=>D.customer_group_id==M);if(C){let D="gross_value";l.showNetPrices&&(D="net_value"),E+=C[D]}}}});for(const[b,A]of Object.entries(f.value))A.surcharge&&(E+=A.surcharge);for(const[b,A]of Object.entries(m.value))if(A.pivot.value&&A.property?.price){let M=A.property.price.value||A.property.price.gross_value||0;(l.showNetPrices||l.customer?.tax_free)&&(M/=1+y.value/100),E+=M}}else{ih.value.forEach(b=>{b.options[0]?.surcharge&&(E+=b.options[0].surcharge)});for(const[b,A]of Object.entries(f.value))A.surcharge&&(E+=A.surcharge);for(const[b,A]of Object.entries(m.value))if(A.pivot.value&&A.property?.price){let M=A.property.price.value||A.property.price.gross_value||0;(l.showNetPrices||l.customer?.tax_free)&&(M/=1+y.value/100),E+=M}}return E}),sh=z(()=>{let E=[];ih.value.forEach(b=>{b.options[0]?.price&&E.push(b.options[0].price)});for(const[b,A]of Object.entries(f.value))A.price&&E.push(A.price);for(const[b,A]of Object.entries(m.value))A.pivot.value&&A.property?.price&&E.push(A.property.price);return E}),hs=z(()=>{const E="price";let b="gross_value";l.showNetPrices&&(b="net_value");let A=l.currency,M=l.defaultTax?.value,C,D,U;if(l.indexedProduct!==void 0){if(!l.indexedProduct?.prices?.length)return;b==="value"&&(b="gross_value");let Z,ce;if(l.customer?.customerGroup?ce=l.customer.customerGroup:l.resolvedGuestGroup.id?ce={id:l.resolvedGuestGroup.id,key:l.resolvedGuestGroup.key,currency:l.resolvedGuestGroup.currency}:ce=l.defaultCustomerGroup,ce?.id&&ce.id===l.defaultCustomerGroup?.id?Z=(l.indexedProduct.article?.prices||[]).find(Q=>Q.type==="main")||l.indexedProduct.prices.find(Q=>Q.type==="main"):Z=(l.indexedProduct.article?.prices||[]).find(Q=>Q.type==="group"&&Q.customer_group_id==ce?.id)||l.indexedProduct.prices.find(Q=>Q.type==="group"&&Q.customer_group_id==ce?.id),Z?.tax_rate!=null&&(M=Z.tax_rate),!M&&Z?.gross_value&&Z?.net_value&&(M=(Z.tax_value||0)*100/Z.net_value),H.value?.length){let Q=[];if(H.value.forEach(le=>{const Ne=le?.unit||l.indexedProduct?.unit?.label,Ke=le?.quantity||l.indexedProduct?.unit?.quantity||1;Ne&&!Q.includes(Ne)&&Q.push(Ne),le[E]&&le?.[E]?.[b]&&(D?(D.from=Math.min(D.from,le?.[E]?.[b]+xe.value),D.to=Math.max(D.to,le?.[E]?.[b]+xe.value||0)):D={from:le?.[E]?.[b]+xe.value,to:le?.[
1557E]?.[b]+xe.value},U?(U.from=Math.min(U.from,le?.[E]?.[b]/Ke+xe.value),U.to=Math.max(U.to,le?.[E]?.[b]/Ke+xe.value)):U={from:le?.[E]?.[b]/Ke+xe.value,to:le?.[E]?.[b]/Ke+xe.value})}),D&&D.from<D.to?C=J("product:min-price",{price:Pe(D.from,A)}):D&&D.from===D.to&&(C=Pe(D.from,A)),Q.length===1){let le=Q[0];le||(le=J("product:piece")),U&&U.from<U.to?U.info=J("product:min-price-per-unit",{price:Pe(U.from,A),unit:le}):U&&U.from===U.to&&(U.info=J("product:price-per-unit",{price:Pe(U.from,A),unit:le}))}}else if(l.indexedProduct.price_ranges?.length){const Q=l.indexedProduct.price_ranges.find(le=>le.customer_group_id==ce?.id&&(!le.type||le.type==="main"));Q&&(D={from:Q.min[b]+xe.value,to:Q.max[b]+xe.value},D.from<D.to?C=J("product:min-price",{price:Pe(D.from,A)}):C=Pe(D.from,A))}if(!D&&Z&&(C=Pe(Z[b]+xe.value,A),D={from:Z[b]+xe.value,to:Z[b]+xe.value}),!H.value?.length&&D){let Q=l.indexedProduct?.unit?.label;Q||(Q=J("product:piece"));const le=l.indexedProduct?.unit?.quantity||1;(pt.value||kt.value==="show-always"||le!==1&&kt.value!=="show-if-differs")&&(U={from:D.from/le,to:D.to/le,info:J("product:price-per-unit",{price:Pe(D.from/le,A),unit:Q})})}}else if(l.product!==void 0){const Z=l.product[E];if(A=Z?.customerGroup?.currency?.iso4217||l.currency,Z?.tax_rate!=null?M=Z?.tax_rate:Z?.tax?.value!=null?M=Z.tax.value:Z?.tax_value&&Z?.net_value&&(M=Z.tax_value*100/Z.net_value),Z?.[b]&&(C=Pe(Z?.[b]+xe.value,A)),H.value?.length){let ce=[];if(H.value.forEach(N=>{N.price?.id&&(N.price.id,l.product?.price?.id);const Q=N?.unit||l.product?.unit,le=N?.quantity||l.product?.quantity||1;Q&&!ce.includes(Q)&&ce.push(Q),N[E]&&N?.[E]?.[b]&&(D?(D.from=Math.min(D.from,N?.[E]?.[b]+xe.value),D.to=Math.max(D.to,N?.[E]?.[b]+xe.value||0)):D={from:N?.[E]?.[b]+xe.value,to:N?.[E]?.[b]+xe.value},U?(U.from=Math.min(U.from,N?.[E]?.[b]/le+xe.value),U.to=Math.max(U.to,N?.[E]?.[b]/le+xe.value)):U={from:N?.[E]?.[b]/le+xe.value,to:N?.[E]?.[b]/le+xe.value})}),D&&D.from<D.to?C=J("product:min-price",{price:Pe(D.from,A)}):D&&D.from===D.to&&(C=Pe(D.from,A)),ce.length===1){let N=ce[0];N||(N=J("product:piece")),U&&U.from<U.to?U.info=J("product:min-price-per-unit",{price:Pe(U.from,A),unit:N}):U&&U.from===U.to&&(U.info=J("product:price-per-unit",{price:Pe(U.from,A),unit:N}))}}else{D={from:(Z?.[b]||0)+xe.value,to:(Z?.[b]||0)+xe.value};let ce=l.product?.unit;ce||(ce=J("product:piece"));const N=l.product?.quantity||1;(pt.value||kt.value==="show-always"||N!==1&&kt.value!=="show-if-differs")&&(U={from:(Z?.[b]||0)/N+xe.value,to:(Z?.[b]||0)/N+xe.value,info:J("product:price-per-unit",{price:Pe((Z?.[b]||0)/N,A),unit:ce})})}}return kt.value==="hide"&&(U=void 0),kt.value==="show-if-differs"&&U?.from===D?.from&&U?.to===D?.to&&(U=void 0),{range:D,unitPrice:U,formatted:C,currency:A,taxRate:M}}),fs=z(()=>{const E="salePrice";let b="gross_value";l.showNetPrices&&(b="net_value");let A=l.currency,M=l.defaultTax?.value,C,D,U;if(l.indexedProduct!==void 0){if(!l.indexedProduct?.prices?.length)return;b==="value"&&(b="gross_value");let Z,ce;if(l.customer?.customerGroup?ce=l.customer.customerGroup:l.resolvedGuestGroup.id?ce={id:l.resolvedGuestGroup.id,key:l.resolvedGuestGroup.key,currency:l.resolvedGuestGroup.currency}:ce=l.defaultCustomerGroup,Z=(l.indexedProduct.article?.prices||[]).find(N=>N.type==="sale"&&N.customer_group_id==ce?.id&&nn(N.start_at)<=new Date&&nn(N.end_at)>=new Date)||l.indexedProduct.prices.find(N=>N.type==="sale"&&N.customer_group_id==ce?.id&&nn(N.start_at)<=new Date&&nn(N.end_at)>=new Date),Z?.tax_rate!=null&&(M=Z.tax_rate),!M&&Z?.gross_value&&Z?.net_value&&(M=(Z.tax_value||0)*100/Z.net_value),H.value?.length){let N=[];if(H.value.forEach(Q=>{const le=Q?.unit||l.indexedProduct?.unit?.label,Ne=Q?.quantity||l.indexedProduct?.unit?.quantity||1;le&&!N.includes(le)&&N.push(le),Q[E]&&Q?.[E]?.[b]&&(D?(D.from=Math.min(D.from,Q?.[E]?.[b]+xe.value),D.to=Math.max(D.to,Q?.[E]?.[b]+xe.value||0)):D={from:Q?.[E]?.[b]+xe.value,to:Q?.[E]?.[b]+xe.value},U?(U.from=Math.min(U.from,Q?.[E]?.[b]/Ne+xe.value),U.to=Math.max(U.to,Q?.[E]?.[b]/Ne+xe.value)):U={from:Q?.[E]?.[b]/Ne+xe.value,to:Q?.[E]?.[b]/Ne+xe.value})}),D&&D.from<D.to?C=J("product:min-price",{price:Pe(D.from,A)}):D&&D.from===D.to&&(C=Pe(D.from,A)),N.length===1){let Q=N[0];Q||(Q=J("product:piece")),U&&U.from<U.to?U.info=J("product:min-price-per-unit",{price:Pe(U.from,A),unit:Q}):U&&U.from===U.to&&(U.info=J("product:price-per-unit",{price:Pe(U.from,A),unit:Q}))}}else if(l.indexedProduct.price_ranges?.length){const N=l.indexedProduct.price_ranges.find(Q=>Q.customer_group_id==ce?.id&&Q.type==="sale");N&&(D={from:N.min[b]+xe.value,to:N.max[b]+xe.value},D.from<D.to?C=J("product:min-price",{price:Pe(D.from,A)}):C=Pe(D.from,A))}if(!D&&Z&&!H.value?.length&&(C=Pe(Z[b]+xe.value,A),D={from:Z[b]+xe.value,to:Z[b]+xe.value}),!H.value?.length&&D){let N=l.indexedProduct?.unit?.label;N||(N=J("product:piece"));const Q=l.indexedProduct?.unit?.quantity||1;(pt.value||kt.value==="show-always"||Q!==1&&kt.value!=="show-if-differs")&&(U={from:D.from/Q,to:D.to/Q,info:J("product:price-per-unit",{price:Pe(D.from/Q,A),unit:N})})}if(!D)return}else if(l.product!==void 0){const Z=l.product[E];if(A=Z?.customerGroup?.currency?.iso4217||l.currency,Z?.tax_rate!=null?M=Z?.tax_rate:Z?.tax?.value?M=Z.tax.value:Z?.tax_value&&Z?.net_value&&(M=Z.tax_value*100/Z.net_value),Z?.[b]&&(C=Pe(Z?.[b]+xe.value,A)),H.value?.length){let ce=[];if(H.value.forEach(N=>{N.price?.id&&N.price.id!==l.product?.price?.id&&H.value.length!==$e.value?.length&&(C="");const le=N?.unit||l.product?.unit,Ne=N?.quantity||l.product?.quantity||1;le&&!ce.includes(le)&&ce.push(le),N[E]&&N?.[E]?.[b]&&(D?(D.from=Math.min(D.from,N?.[E]?.[b]+xe.value),D.to=Math.max(D.to,N?.[E]?.[b]+xe.value||0)):D={from:N?.[E]?.[b]+xe.value,to:N?.[E]?.[b]+xe.value},U?(U.from=Math.min(U.from,N?.[E]?.[b]/Ne+xe.value),U.to=Math.max(U.to,N?.[E]?.[b]/Ne+xe.value)):U={from:N?.[E]?.[b]/Ne+xe.value,to:N?.[E]?.[b]/Ne+xe.value})}),D&&D.from<D.to?C=J("product:min-price",{price:Pe(D.from,A)}):D&&D.from===D.to&&(C=Pe(D.from,A)),ce.length===1){let N=ce[0];N||(N=J("product:piece")),U&&U.from<U.to?U.info=J("product:min-price-per-unit",{price:Pe(U.from,A),unit:N}):U&&U.from===U.to&&(U.info=J("product:price-per-unit",{price:Pe(U.from,A),unit:N}))}}else if(Z?.[b]){D={from:(Z?.[b]||0)+xe.value,to:(Z?.[b]||0)+xe.value};let ce=l.product?.unit;ce||(ce=J("product:piece"));const N=l.product?.quantity||1;(pt.value||kt.value==="show-always"||N!==1&&kt.value!=="show-if-differs")&&(U={from:(Z?.[b]||0)/N+xe.value,to:(Z?.[b]||0)/N+xe.value,info:J("product:price-per-unit",{price:Pe((Z?.[b]||0)/N,A),unit:ce})})}}return kt.value==="hide"&&(U=void 0),kt.value==="show-if-differs"&&U?.from===D?.from&&U?.to===D?.to&&(U=void 0),{range:D,unitPrice:U,formatted:C,currency:A,taxRate:M}}),k0=z(()=>r.settings?.["product-details-show-uvp-price"]),nh=z(()=>{const E=k0.value;if(!["gross","net"].includes(E))return;const b=E==="net"?"net_value":"gross_value";let A=l.currency,M;if(l.indexedProduct!==void 0){const C=(H.value||[]).map(U=>U.mainPrice?.[b]).filter(U=>U!=null);if(C.length){const U=Math.min(...C),Z=Math.max(...C);return{formatted:U<Z?J("product:min-price",{price:Pe(U,A)}):Pe(U,A),currency:A}}M=((l.indexedProduct.article?.prices||[]).find(U=>U.type==="main")||l.indexedProduct.prices?.find(U=>U.type==="main"))?.[b]}else if(l.product!==void 0){const C=l.product.mainPrice;A=C?.customerGroup?.currency?.iso4217||l.currency,M=C?.[b]}if(M!=null)return{formatted:Pe(M,A),currency:A}});St(()=>hs.value,E=>
1557{if(typeof E?.taxRate=="number")y.value=E?.taxRate;else switch(E?.taxRate){case"reduced":y.value=l.defaultReducedTax?.value;break;case"regular":y.value=l.defaultTax?.value;break;default:y.value=0;break}},{immediate:!0});const rh=async()=>{_.value&&_.value.destroy(),r.settings?.["product-details-image-zoom"]==="hover"&&r.settings?.["product-details-image-zoom-effect"]==="hover-inline"&&F.value&&L.value?(await or(),_.value=new di(F.value.querySelector(".picture-container"),{paneContainer:L.value,inlinePane:!1,handleTouch:!1,containInline:!0,sourceAttribute:"data-source",zoomFactor:parseInt(k)})):r.settings?.["product-details-image-zoom"]==="hover"&&r.settings?.["product-details-image-zoom-effect"]==="hover-image-right"&&F.value&&w.value?(await or(),_.value=new di(F.value.querySelector(".picture-container"),{paneContainer:w.value,inlinePane:!1,handleTouch:!1,containInline:!0,sourceAttribute:"data-source",zoomFactor:parseInt(k)})):r.settings?.["product-details-image-zoom"]==="hover"&&r.settings?.["product-details-image-zoom-effect"]==="hover-inline-lens"&&F.value&&L.value&&(await or(),_.value=new di(F.value.querySelector(".picture-container"),{paneContainer:L.value,inlinePane:!0,sourceAttribute:"data-source",namespace:P,zoomFactor:parseInt(k)}))},D0=async()=>{I.value&&I.value.destroy(),r.settings?.["product-details-image-zoom"]==="click"&&R.value&&F.value&&(I.value=new AE({gallery:R.value,children:"a.lightbox",showHideAnimationType:"zoom",padding:{top:60,bottom:60,left:60,right:60},errorMsg:J("could-not-load",{type:J("image")}),pswpModule:()=>Sm(()=>import("./BXDdABy_.js"),[],import.meta.url)}),ks.value?.length>1&&(I.value.on("uiRegister",()=>{I.value.pswp.ui.registerElement({name:"bulletsIndicator",className:"pswp__bullets-indicator",appendTo:"wrapper",onInit:(E,b)=>{const A=[];let M,C=-1;for(let D=0;D<b.getNumItems();D++){const U=b.options.dataSource?.items?.[D]?.dataset,Z=U?.pswpThumb,ce=U?.pswpType||"image";if(M=document.createElement("label"),M.className="pswp__bullet",M.onclick=N=>{A.indexOf(N.target)>=0&&b.goTo(A.indexOf(N.target))},Z){const N=document.createElement("img");N.src=Z,M.appendChild(N)}if(ce==="video"){const N=document.createElement("span");N.className="pswp__play",N.innerHTML='<svg fill="currentColor" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M8 5v14l11-7z"/></svg>',M.appendChild(N)}E.appendChild(M),A.push(M)}b.on("change",D=>{C>=0&&A[C].classList.remove("pswp__bullet--active"),A[b.currIndex].classList.add("pswp__bullet--active"),C=b.currIndex})}})}),I.value.addFilter("itemData",(E,b)=>{const A=E.element.dataset.mediaId;return A&&(E.media=ks.value.find(M=>M.id===A)),E.type==="video"&&(E.video={mime:E.element.dataset.videoMime,src:E.element.dataset.videoSrc}),E}),I.value.addFilter("preventPointerEvent",(E,b,A)=>(b.target.closest(".pswp__video-container")&&A==="down"&&(E=!1),E)),I.value.on("contentLoad",E=>{const{content:b}=E;if(b.type==="video"){E.preventDefault(),b.element=document.createElement("div"),b.element.className="pswp__video-container";const A=document.createElement("media-controller");A.style.width="100%",A.style.aspectRatio=`${b.data.width}/${b.data.height}`;const M=!!b.data?.media?.video?.hls||b.data?.video?.mime==="application/x-mpegURL";let C=document.createElement("video");M&&(C=document.createElement("hls-video")),C.slot="media",C.src=b.data.video.src,C.controls=!1,C.autoplay=!1,C.loop=!1,C.muted=!1,C.playsinline=!0,C.preload="auto",A.appendChild(C);const D=document.createElement("media-control-bar"),U=document.createElement("media-play-button"),Z=document.createElement("media-mute-button"),ce=document.createElement("media-volume-range"),N=document.createElement("media-time-range"),Q=document.createElement("media-fullscreen-button");if(D.appendChild(U),D.appendChild(Z),D.appendChild(ce),D.appendChild(N),M){const le=document.createElement("media-rendition-menu-button");D.appendChild(le)}if(D.appendChild(Q),M){const le=document.createElement("media-rendition-menu");le.hidden=!0,le.anchor="auto",A.appendChild(le)}A.appendChild(D),b.data.video=C,b.element.appendChild(A)}}),I.value.on("contentActivate",E=>{const{content:b}=E;b.type==="video"&&(b.data.video.currentTime=0,b.data.video.play())}),I.value.on("contentDeactivate",({content:E})=>{E.type==="video"&&(E.data.video.pause(),E.data.video.currentTime=0)}
1557)),typeof I.value?.init=="function"&&I.value.init())};St(()=>Yt.value,rh);const{i18n:C0}=eE(),w0=xd(),P0=Gn(),M0=(E,b=void 0)=>(b=b||{},b.lng=w0.language||P0.defaultLanguage?.code||"de",C0.t(E,b)),O0=z(()=>{const E={},b=M0;vt.value.forEach(C=>{const D=C.articleRequired||C.isRequired;if(C.options?.length>1&&(D?E[C.key]=Ps().required(b("form:is-a-required-field",{field:C.label})):E[C.key]=Ps().nullable()),C.type==="upload"&&(D?E[C.key]=la().required(b("product:upload-required")):E[C.key]=la().nullable()),C.type==="input"){const U={},Z=C.minRows||1,ce=Math.max(C.maxRows||Z,Z);if(C.inputField==="textarea"){let N=la().transform(Q=>typeof Q=="string"?Q.trim():Q);D?C.minInput?N=N.required(b("form:is-a-required-field",{field:C.label})).min(C.minInput,b("form:is-a-min-string-field",{field:C.label,min:C.minInput})):N=N.required(b("form:is-a-required-field",{field:C.label})):C.minInput&&(N=N.test("min-if-given",b("form:is-a-min-string-field",{field:C.label,min:C.minInput}),Q=>Q===void 0||Q===""||Q.length>=C.minInput)),C.maxInput&&(N=N.max(C.maxInput,b("form:is-a-max-string-field",{field:C.label,max:C.maxInput}))),D&&C.minRows&&(N=N.test("min-rows",b("form:is-a-min-rows-field",{field:C.label,min:C.minRows}),Q=>Q?.split(/\r?\n/).length>=C.minRows)),C.maxRows&&(N=N.test("max-rows",b("form:is-a-max-rows-field",{field:C.label,max:C.maxRows}),Q=>Q?.split(/\r?\n/).length<=C.maxRows)),E[C.key]=N}if(["textfield","number"].includes(C.inputField)){for(let Q=0;Q<ce;Q++){let le=C.inputField==="number"?Ps():la().transform(Ne=>typeof Ne=="string"?Ne.trim():Ne);if(C.minInput){const Ne=C.inputField==="number"?b("form:is-a-min-number-field",{field:b("form:this-input"),min:C.minInput}):b("form:is-a-min-string-field",{field:b("form:this-input"),min:C.minInput});le=le.test("min-if-given",Ne,Ke=>C.inputField==="number"?Ke==null||Ke>=C.minInput:Ke===void 0||Ke.trim()===""||Ke.trim().length>=C.minInput)}if(C.maxInput){const Ne=C.inputField==="number"?b("form:is-a-max-number-field",{field:C.label,max:C.maxInput}):b("form:is-a-max-string-field",{field:C.label,max:C.maxInput});le=le.max(C.maxInput,Ne)}U[`row-${Q}`]=le}let N=Gl().shape(U);D&&C.minRows&&(N=N.test("required-rows",b("form:is-a-min-rows-field",{field:C.label,min:C.minRows}),Q=>Object.values(Q).filter(le=>le!==void 0&&le!=="").length>=C.minRows)),E[C.key]=N}}});let A=Ps().required(b("form:is-a-required-field",{field:b("product:quantity")})).min(1,b("form:is-a-min-number-field",{field:b("product:quantity"),min:1}));l.ignoreArticleStock||(A=A.max(us.value,b("form:is-a-max-number-field",{field:b("product:quantity"),max:us.value})));const M={...E,price:Ps().required(b("form:is-a-required-field",{field:b("product:price")})),articles:Ps().min(1).max(1),qty:A};return Ds.value?Gl().shape({price:Ps().required(b("form:is-a-required-field",{field:b("product:price")}))}):Gl().shape(M)});T.validation=tE({validationSchema:O0,initialValues:{articles:H.value?.length,price:fs.value?.range?.from||hs.value?.range?.from,qty:1}});const F0=z(()=>{let E={};return vt.value.forEach(b=>{if(!(Jr.value&&b.articleRequired))if(b.type==="upload")E[b.key]=Cs(b.key);else if(b.type==="input"){if(E[b.key]=Cs(b.key),["textfield","number"].includes(b.inputField)){const A=Math.max(b.minRows||1,1),M=Math.max(b.maxRows||1,A);for(let C=0;C<M;C++){const D=`row-${C}`;E[b.key][D]=Cs(`${b.key}.${D}`)}}}else b.options?.length>1&&(E[b.key]=Cs(b.key))}),E});if(T.fields={...F0.value,price:Cs("price"),articles:Cs("articles"),qty:Cs("qty")},St(()=>fs.value?.range?.from||hs.value?.range?.from,E=>{T.fields?.price&&(T.fields.price.value=E)},{immediate:!0}),!l.product&&!l.indexedProduct){const b={slug:n.params.product};if(r?.CMS?.i18n){b.translate=!0;let M=d.language;M&&(M.default&&l.product?delete b.translate:(b.language={id:M?.id,code:M?.code},l?.indexedProduct?.origin_id&&(delete b.slug,b.translationOrigin=parseInt(l.indexedProduct.origin_id))))}const{client:A}=lr("apq");A.query({query:iE,variables:b}).then(({data:M,error:C})=>{const D=ws(M?.CO_Product);D&&(l.setProduct(D),D.id&&(Ie(D.id),De(D.id)))}),A.query({query:sE,variables:b}).then(({data:M,error:C})=>{const D=ws(M?.CO_Product);D?.articles?.length&&l.setArticles(D.articles)}),A.query({query:_m,variables:b}).then(({data:M,error:C})=>{const D=ws(M?.CO_Product);D?.relatedArticles?.length&&l.setRelatedArticles(D.relatedArticles)})}else if(l.indexedProduct){const E=l.indexedProduct.id||l.indexedProduct.origin_id;E&&(Ie(parseInt(E)),De(parseInt(E)))}return zc(()=>{const E=bm();E.payload?._translationNotFound&&(delete E.payload._translationNotFound,r.addMessage({id:Date.now().toString(),text:"Diese Seite wurde noch nicht übersetzt.",type:"warning",autoclose:8e3}));const b=E.payload?._deferredProductData;b&&(b.articles&&l.setArticles(b.articles),b.relatedArticles&&l.setRelatedArticles(b.relatedArticles),b.indexedArticles&&l.setIndexedArticles(b.indexedArticles),b.articlesLoading!==void 0&&(l.articlesLoading=b.articlesLoading),b.pageSections&&(d.sections=b.pageSections),b.pageView&&(d.view=b.pageView),delete E.payload._deferredProductData)}),nE(async()=>{await new Promise((E,b)=>{let A=0;const M=()=>
1557{if(R.value&&F.value&&L.value&&w.value)return E(!0);A<1e3&&(A++,setTimeout(M,0))};M()}),rh(),D0()}),jc(()=>{setTimeout(()=>{_.value&&(_.value.destroy(),_.value=null),I.value&&(I.value.destroy(),I.value=null)},500)}),(E,b)=>{const A=Zc,M=Xc,C=gk,D=mE,U=By,Z=Am,ce=Im,N=Hy,Q=EE,le=yE,Ne=zy,Ke=uE,zt=gT,Le=SE;return K(),q("div",{class:ht(["main-area product-details",S(R0)])},[S(l).product||S(l).indexedProduct?(K(),q("section",pk,[j("div",{class:ht(["media",S(se)]),ref_key:"gallery",ref:R},[j("div",vk,[S(ks)?.length?me("",!0):(K(),q("div",Ek,[it(A)])),S(Yt)?(K(),q("div",{key:1,class:"active-media",ref_key:"picture",ref:F},[S(Yt).type==="image"&&S(Yt).image?(K(),q("div",{key:0,class:ht(["product-image",S(G)]),ref_key:"zoom",ref:L},[it(M,{class:"lightbox",title:S(_t),image:S(Yt).image,lazy:!1,preload:!0,objectFit:"fill",is:S(r).settings?.["product-details-image-zoom"]==="click"?"a":"div",sizes:"100vw sm:50vw lg:50vw xl:50vw"},null,8,["title","image","is"])],2)):me("",!0),S(Yt).type==="video"&&S(Yt).video?(K(),q("div",{key:1,class:ht(["product-video w-full",S(G)]),style:_i({"--aspect-ratio":S(Yt).video.width/S(Yt).video.height})},[(K(),Ot(C,{key:S(Yt).id,video:S(Yt).video,lazy:!1,"hide-play-button":"",autoplay:""},null,8,["video"]))],6)):me("",!0)],512)):me("",!0)]),S(ks)?.length>1?(K(),q("ul",yk,[(K(!0),q(xt,null,Ki(S(ks),(re,ii)=>(K(),q("li",null,[re.type==="image"&&re.image?(K(),Ot(M,{key:0,class:ht({active:re.id===S(Yt).id,lightbox:S(r).settings?.["product-details-image-zoom"]==="click"&&re.i
1557d!==S(Yt).id}),title:S(_t),image:re.image,lazy:!1,"object-fit":"contain","missing-icon":"exclamation-triangle","hide-missing-info":!0,is:"a",onClick:aa(na=>u.value=ii,["stop","prevent"]),sizes:`${("getWidth"in E?E.getWidth:S(Cn))(re.image,50)} sm:${("getWidth"in E?E.getWidth:S(Cn))(re.image,60)} lg:${("getWidth"in E?E.getWidth:S(Cn))(re.image,80)} xl:${("getWidth"in E?E.getWidth:S(Cn))(re.image,100)}`},null,8,["class","title","image","onClick","sizes"])):re.type==="video"&&re.video?(K(),q("a",{key:1,class:ht(["video-container relative flex items-center justify-center",{active:re.id===S(Yt).id,lightbox:S(r).settings?.["product-details-image-zoom"]==="click"&&re.id!==S(Yt).id}]),href:"",style:_i({"--aspect-ratio":re.video.width/re.video.height}),onClick:aa(na=>u.value=ii,["stop","prevent"]),"data-pswp-type":"video","data-pswp-width":re.video.width,"data-pswp-height":re.video.height,"data-video-src":re.video?.hls?.url||re.video?.url||re.video?.source?.url,"data-video-mime":re.video?.hls?.mime||re.video?.mime||re.video?.source?.mime,"data-media-id":re.id},[Qu(re.video)?(K(),q("video",{key:0,class:"video-preview",src:Qu(re.video),preload:"metadata",muted:"",playsinline:"",tabindex:"-1","aria-hidden":"true"},null,8,bk)):me("",!0),it(D,{class:"video-preview-icon"})],14,Tk)):me("",!0)]))),256))])):me("",!0)],2),j("div",{class:"info zoom-container",ref_key:"zoomInlineRight",ref:w},[j("h1",_k,Ae(S(_t)),1),j("div",Sk,Ae(("t"in E?E.t:S(J))("product:nr"))+" "+Ae(S(Fe)),1),S(Qt)?(K(),q("div",{key:0,class:"teaser",innerHTML:S(Qt)},null,8,Ak)):me("",!0),j("div",Ik,[(K(!0),q(xt,null,Ki(S(vt),re=>(K(),q(xt,{key:`${S(ut)}-${re.id}`},[!S(Ds)||![S(ie),S(ue)].includes(re.key)?(K(),q(xt,{key:0},[!S(be)||re.type==="input"||re.type==="upload"||re.options?.length>1?(K(),Ot(U,{key:0,validation:S(T).fields[re.key],property:re,"active-option":f.value?.[re.id],"user-input":m.value?.[re.id],"sellable-articles":S($e),"valid-articles":S(H),"all-articles":S(Te),"manage-stock":S(Zn),"show-discount-label":["true","1","yes",!0].includes(S(oe)),onSelect:g0,onInput:p0,onUpload:v0},null,8,["validation","property","active-option","user-input","sellable-articles","valid-articles","all-articles","manage-stock","show-discount-label"])):me("",!0)],64)):me("",!0)],64))),128))]),(S(l).product?.type==="coupon"||S(l).indexedProduct?.type==="coupon")&&S(Te)?.length?(K(),q("div",xk,[j("div",Lk,[j("label",Rk,Ae(("t"in E?E.t:S(J))("shop:coupon-value")),1),j("div",kk,[it(S(No),{modelValue:te.value,"onUpdate:modelValue":b[0]||(b[0]=re=>te.value=re),multiple:!1,options:S(Ml),searchable:S(Ml).length>10,"track-by":"id",label:"value",placeholder:("t"in E?E.t:S(J))("select"),"deselect-label":"","selected-label":("t"in E?E.t:S(J))("selected"),"select-label":"",disabled:S(Ml).length===1,onSelect:tn,onRemove:Ju},{singleLabel:Si(re=>[j("div",Dk,[re.option.price||re.option.coupon?(K(),q("div",Ck,Ae(eh(re.option)),1)):me("",!0)])]),option:Si(re=>[j("div",wk,[re.option.price||re.option.coupon?(K(),q("div",Pk,Ae(eh(re.option)),1)):me("",!0)])]),_:1},8,["modelValue","options","searchable","placeholder","selected-label","disabled"])])])])):me("",!0),S(sn)&&S(ia).length?(K(),q("div",Mk,[j("label",Ok,Ae(("t"in E?E.t:S(J))("shop:ticket-valid-for")),1),j("ul",Fk,[(K(!0),q(xt,null,Ki(S(ia),re=>(K(),q("li",{class:ht(["session",{"is-full":re.available_seats!==null&&re.available_seats<1}]),key:re.id},[j("span",$k,Ae(I0(re)),1),re.available_seats!==null&&re.available_seats<1?(K(),q("span",Nk,Ae(("t"in E?E.t:S(J))("shop:ticket-sold-out")),1)):re.available_seats!==null&&re.available_seats<=5?(K(),q("span",Uk,Ae(("t"in E?E.t:S(J))("shop:ticket-seats-left",{count:re.available_seats})),1)):me("",!0)],2))),128))]),S($l)?(K(),q("p",Bk,Ae(("t"in E?E.t:S(J))("shop:ticket-sold-out-hint")),1)):me("",!0)])):me
1557("",!0),S(sn)&&S(Te)?.length>1?(K(),q("div",Gk,[j("div",Kk,[j("label",Hk,Ae(("t"in E?E.t:S(J))("shop:ticket-category")),1),j("div",Vk,[it(S(No),{modelValue:te.value,"onUpdate:modelValue":b[1]||(b[1]=re=>te.value=re),multiple:!1,options:S(sa),searchable:!1,"track-by":"id",label:"ticketVariantName",placeholder:("t"in E?E.t:S(J))("select"),"deselect-label":"","selected-label":("t"in E?E.t:S(J))("selected"),"select-label":"",onSelect:tn,onRemove:Ju},null,8,["modelValue","options","placeholder","selected-label"])])])])):me("",!0),!S(l).hidePrices&&(S(hs)||S(fs))?(K(),q("div",{key:4,class:ht(["price-tax",{"unitprice-in-focus":S(Js)==="true"}])},[j("small",Wk,Ae(S(fs)?.unitPrice?.info||S(hs)?.unitPrice?.info),1),S(pt)?me("",!0):(K(),q("div",qk,[j("span",{class:ht(["whitespace-nowrap secondary-color",{strikethrough:S(fs)?.formatted}])},Ae(S(hs)?.formatted),3),S(fs)?.formatted?(K(),q("span",Yk,Ae(S(fs).formatted),1)):me("",!0)])),j("div",{class:"tax-info",innerHTML:S(Xi)},null,8,zk),S(nh)?.formatted?(K(),q("div",jk,[b[5]||(b[5]=j("span",{class:"uvp-label"},"UVP",-1)),j("span",Xk,Ae(S(nh).formatted),1)])):me("",!0)],2)):me("",!0),S(l).hidePrices?(K(),q("div",Qk,[j("div",Zk,[S(Ds)?me("",!0):(K(),q("div",Jk,[j("button",{class:"decrease flex items-center",disabled:!0,"aria-label":("t"in E?E.t:S(J))("product:minus-one")},[j("span",t1,[it(Z)])],8,e1),j("input",{type:"number",name:"custom-input-number",style:_i({width:`calc(${g.value.toString().length}ch + 1.5rem)`}),disabled:"true",value:"1"},null,4),j("button",{class:"increase flex items-center",disabled:!0,"aria-label":("t"in E?E.t:S(J))("product:plus-one")},[j("span",s1,[it(ce)])],8,i1)]))]),j("div",n1,[j("a",{class:"button relative",href:S(ae)},[j("span",null,Ae(S(de)),1)],8,r1)])])):me("",!0),j("div",a1,[S(l).articlesLoading&&!S(l).articles?.length&&!S(l).indexedArticles?.length?(K(),q("div",o1)):me("",!0),S(b0)?(K(),q("div",l1,[it(N,{class:"text-xl"}),j("p",null,Ae(("t"in E?E.t:S(J))("product:out-of-stock")),1)])):(K(),q(xt,{key:2},[j("div",d1,[S(f0)?(K(),q("button",{key:1,class:"wish-list button is-link is-circle w-9",disabled:Y.value,"aria-label":("t"in E?E.t:S(J))("product:remove-from-wish-list"),onClick:aa(T0,["prevent"])},[Y.value?(K(),q("div",f1)):(K(),Ot(Q,{key:1,variant:"solid"}))],8,h1)):(K(),q("button",{key:0,class:"wish-list button is-link is-circle w-9",disabled:Y.value||!S(cs)||S(ea).length!==Object.keys(f.value).length,"aria-label":("t"in E?E.t:S(J))("product:add-to-wish-list"),onClick:aa(y0,["prevent"])},[Y.value?(K(),q("div",u1)):(K(),Ot(Q,{key:1,"stroke-width":2}))],8,c1)),b[6]||(b[6]=j("div",{class:"spacer grow"},null,-1)),!S(Ds)&&!S(l).hidePrices?(K(),q("div",m1,[j("button",{class:"decrease flex items-center",disabled:!S(cs),"aria-label":("t"in E?E.t:S(J))("product:minus-one"),onClick:b[2]||(b[2]=re=>g.value=Math.max(1,g.value-1))},[j("span",p1,[it(Z)])],8,g1),rE(j("input",{type:"number",name:"custom-input-number",class:ht({invalid:!S(l).ignoreArticleStock&&g.value>S(us)}),style:_i({width:`calc(${g.value.toString().length}ch + 1.5rem)`}),disabled:!S(cs),"aria-label":("t"in E?E.t:S(J))("product:quantity"),"onUpdate:modelValue":b[3]||(b[3]=re=>g.value=re)},null,14,v1),[[aE,g.value]]),j("button",{class:"increase flex items-center",disabled:!S(cs),"aria-label":("t"in E?E.t:S(J))("product:plus-one"),onClick:b[4]||(b[4]=re=>S(l).ignoreArticleStock?g.value++:g.value=Math.min(S(us),g.value+1))},[j("span",y1,[it(ce)])],8,E1)])):me("",!0)]),!S(Ds)&&!S(l).hidePrices?(K(),q("div",T1,[j("button",{class:"button relative",disabled:!S(cs)||S(Ol)||S($l)||S(ea).length!==Object.keys(f.value).length,"aria-label":("t"in E?E.t:S(J))("product:add-to-cart"),onClick:E0},[!S(l).product?.id&&!S(l).indexedProduct?.id?(K(),q("div",_1,[...b[7]||(b[7]=[j("div",{class:"button-loading-icon spin"},null,-1)])])):me("",!0),j("span",{class:ht({"opacity-20":!S(l).product?.id&&!S(l).indexedProduct?.id})},Ae(("t"in E?E.t:S(J))("product:add-to-cart")),3)],8,b1)])):me("",!0)],64))]),S(th)&&S(a)?(K(),Ot(le,{key:6,article:S(th),qty:g.value},null,8,["article","qty"])):me("",!0),j("div",S1,[S(be)&&S(vt).length?(K(),Ot(Ne,{key:0,class:"combine-infos",title:S(Se),content:S(vt),"is-closed":S(_e),"combine-infos":S(be)},{default:Si(()=>[j("div",A1,[(K(!0),q(xt,null,Ki(S(vt),re=>(K(),q(xt,{key:`${S(ut)}-${re.id}`},[re?.options?.length===1&&re.type!=="input"&&re.type!=="upload"?(K(),Ot(U,{key:0,valid:S(cs),property:re,"active-option":f.value?.[re.id],"user-input":m.value?.[re.id],"sellable-articles":S($e),"valid-articles":S(H),"all-articles":S(Te),"manage-stock":S(Zn)},null,8,["valid","property","active-option","user-input","sellable-articles","valid-articles","all-articles","manage-stock"])):me("",!0)],64))),128))])]),_:1},8,["title","content","is-closed","combine-infos"])):me("",!0),S(Zr)&&S(Zr).length?(K(),Ot(Ne,{key:1,class:"description",title:S(Ye),content:S(Zr),"is-closed":S(rt)},null,8,["title","content","is-closed"])):me("",!0),S(bt)&&S(bt).length?(K(),Ot(Ne,{key:2,class:"custom-field",title:S(Xt),content:S(bt),"is-closed":S(qe)},null,8,["title","content","is-closed"])):me("",!0)])],512)])):me("",!0),S(Ds)&&(S(l).product||S(l).indexedProduct)?(K(),q("section",I1,[(K(!0),q(xt,null,Ki(S(ta),(re,ii)=>(K(),q(xt,{key:`matrix-${re.int}-${ii}`},[S(Zu)&&re.name?(K(),q("h2",{key:0,class:ht(["matrix-title text-xl font-semibold mb-4 mt-8",{"mt-0":ii===0}])},Ae(re.name),3)):me("",!0),it(Ke,{valid:S(cs),properties:h0(re.articles),product:S(l).product||S(l).indexedProduct,articles:re.articles,surcharge:S(xe),"manage-stock":S(Zn),onToggleActiveArticle:m0,view:"product"},null,8,["valid","properties","product","articles","surcharge","manage-stock"])],64))),128))])):me
1557("",!0),S(ne)&&S(ne).length?(K(),q("section",x1,[it(zt,{"related-article-ids":S(ne),"fallback-product-id":S(l).indexedProduct?.id?parseInt(String(S(l).indexedProduct.id)):void 0,"fallback-article-id":S(We)},null,8,["related-article-ids","fallback-product-id","fallback-article-id"])])):S(Ce)&&S(Ce).length?(K(),q("section",L1,[it(zt,{articles:S(Ce)},null,8,["articles"])])):me("",!0),S(Oe)?.main?.length?(K(),q("section",R1,[it(Le,{root:"main",sections:S(Oe).main},null,8,["sections"])])):me("",!0)],2)}}}),sD=Zs(D1,[["__scopeId","data-v-d6979134"]]);export{sD as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.